node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
'use strict';
module.exports = require('asn1.js').define('AlgorithmIdentifer', /* @this */ function() {
this.seq().obj(
this.key('algorithm').objid(),
this.key('parameters').optional().any()
);
});

View File

@@ -0,0 +1,13 @@
'use strict';
var AlgorithmIdentifier = require('./algorithm-identifier');
var Version = require('./version');
module.exports = require('asn1.js').define('PrivateKeyInfo', /* @this */ function() {
this.seq().obj(
this.key('version').use(Version),
this.key('privateKeyAlgorithm').use(AlgorithmIdentifier),
this.key('privateKey').octstr(),
this.key('attributes').optional().any()
);
});

View File

@@ -0,0 +1,10 @@
'use strict';
var AlgorithmIdentifier = require('./algorithm-identifier');
module.exports = require('asn1.js').define('PublicKeyInfo', /* @this */ function() {
this.seq().obj(
this.key('algorithm').use(AlgorithmIdentifier),
this.key('PublicKey').bitstr()
);
});

5
server/node_modules/jwk-to-pem/src/asn1/version.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = require('asn1.js').define('Version', /* @this */ function() {
this.int();
});

13
server/node_modules/jwk-to-pem/src/b64-to-bn.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
var BN = require('asn1.js').bignum,
Buffer = require('safe-buffer').Buffer;
module.exports = function base64ToBigNum(val, zero) {
var buf = Buffer.from(val, 'base64');
var bn = val = new BN(buf, 10, 'be').iabs();
if (zero) {
buf.fill(0);
}
return bn;
};

156
server/node_modules/jwk-to-pem/src/ec.js generated vendored Normal file
View File

@@ -0,0 +1,156 @@
'use strict';
var asn1 = require('asn1.js'),
Buffer = require('safe-buffer').Buffer,
EC = require('elliptic').ec;
var b64ToBn = require('./b64-to-bn');
var PublicKeyInfo = require('./asn1/public-key-info'),
PrivateKeyInfo = require('./asn1/private-key-info'),
Version = require('./asn1/version');
var ECParameters = asn1.define('ECParameters', /* @this */ function() {
this.choice({
namedCurve: this.objid()
});
});
var ecPrivkeyVer1 = 1;
var ECPrivateKey = asn1.define('ECPrivateKey', /* @this */ function() {
this.seq().obj(
this.key('version').use(Version),
this.key('privateKey').octstr(),
this.key('parameters').explicit(0).optional().any(),
this.key('publicKey').explicit(1).optional().bitstr()
);
});
var curves = {
'P-256': 'p256',
'P-384': 'p384',
'P-521': 'p521'
};
var oids = {
'P-256': [1, 2, 840, 10045, 3, 1, 7],
'P-384': [1, 3, 132, 0, 34],
'P-521': [1, 3, 132, 0, 35]
};
var parameters = {};
var algorithms = {};
Object.keys(oids).forEach(function(crv) {
parameters[crv] = ECParameters.encode({
type: 'namedCurve',
value: oids[crv]
}, 'der');
algorithms[crv] = {
algorithm: [1, 2, 840, 10045, 2, 1],
parameters: parameters[crv]
};
});
oids = null;
function ecJwkToBuffer(jwk, opts) {
if ('string' !== typeof jwk.crv) {
throw new TypeError('Expected "jwk.crv" to be a String');
}
var hasD = 'string' === typeof jwk.d;
var xyTypes = hasD
? ['undefined', 'string']
: ['string'];
if (-1 === xyTypes.indexOf(typeof jwk.x)) {
throw new TypeError('Expected "jwk.x" to be a String');
}
if (-1 === xyTypes.indexOf(typeof jwk.y)) {
throw new TypeError('Expected "jwk.y" to be a String');
}
if (opts.private && !hasD) {
throw new TypeError('Expected "jwk.d" to be a String');
}
var curveName = curves[jwk.crv];
if (!curveName) {
throw new Error('Unsupported curve "' + jwk.crv + '"');
}
var curve = new EC(curveName);
var key = {};
var hasPub = jwk.x && jwk.y;
if (hasPub) {
key.pub = {
x: b64ToBn(jwk.x, false),
y: b64ToBn(jwk.y, false)
};
}
if (opts.private || !hasPub) {
key.priv = b64ToBn(jwk.d, true);
}
key = curve.keyPair(key);
var keyValidation = key.validate();
if (!keyValidation.result) {
throw new Error('Invalid key for curve: "' + keyValidation.reason + '"');
}
var result = keyToPem(jwk.crv, key, opts);
return result;
}
function keyToPem(crv, key, opts) {
var compact = false;
var publicKey = key.getPublic(compact, 'hex');
publicKey = Buffer.from(publicKey, 'hex');
publicKey = {
unused: 0,
data: publicKey
};
var result;
if (opts.private) {
var privateKey = key.getPrivate('hex');
privateKey = Buffer.from(privateKey, 'hex');
result = PrivateKeyInfo.encode({
version: 0,
privateKeyAlgorithm: algorithms[crv],
privateKey: ECPrivateKey.encode({
version: ecPrivkeyVer1,
privateKey: privateKey,
parameters: parameters[crv],
publicKey: publicKey
}, 'der')
}, 'pem', {
label: 'PRIVATE KEY'
});
privateKey.fill(0);
} else {
result = PublicKeyInfo.encode({
algorithm: algorithms[crv],
PublicKey: publicKey
}, 'pem', {
label: 'PUBLIC KEY'
});
}
// This is in an if incase asn1.js adds a trailing \n
// istanbul ignore else
if ('\n' !== result.slice(-1)) {
result += '\n';
}
return result;
}
module.exports = ecJwkToBuffer;

38
server/node_modules/jwk-to-pem/src/jwk-to-pem.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
'use strict';
var ec = require('./ec'),
rsa = require('./rsa');
/**
*
* @param {{kty:'EC', crv:string, d:string, x?:string, y?:string} | {kty:'EC', crv:string, x:string, y:string} | {kty:'RSA', e:string, n:string, d?:string, p?:string, q?:string, dp?:string, dq?:string, qi?:string}} jwk
* @param {{private:boolean}=} opts
* @returns {string}
*/
function jwkToBuffer(jwk, opts) {
if ('object' !== typeof jwk || null === jwk) {
throw new TypeError('Expected "jwk" to be an Object');
}
var kty = jwk.kty;
if ('string' !== typeof kty) {
throw new TypeError('Expected "jwk.kty" to be a String');
}
opts = opts || {};
opts.private = opts.private === true;
switch (kty) {
case 'EC': {
return ec(jwk, opts);
}
case 'RSA': {
return rsa(jwk, opts);
}
default: {
throw new Error('Unsupported key type "' + kty + '"');
}
}
}
module.exports = jwkToBuffer;

115
server/node_modules/jwk-to-pem/src/rsa.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
'use strict';
var asn1 = require('asn1.js');
var b64ToBn = require('./b64-to-bn');
var PublicKeyInfo = require('./asn1/public-key-info'),
PrivateKeyInfo = require('./asn1/private-key-info'),
Version = require('./asn1/version');
var RSAPrivateKey = asn1.define('RSAPrivateKey', /* @this */ function() {
this.seq().obj(
this.key('version').use(Version),
this.key('modulus').int(),
this.key('publicExponent').int(),
this.key('privateExponent').int(),
this.key('prime1').int(),
this.key('prime2').int(),
this.key('exponent1').int(),
this.key('exponent2').int(),
this.key('coefficient').int()
);
});
var RSAPublicKey = asn1.define('RSAPublicKey', /* @this */ function() {
this.seq().obj(
this.key('modulus').int(),
this.key('publicExponent').int()
);
});
var algorithm = {
algorithm: [1, 2, 840, 113549, 1, 1, 1],
parameters: [5, 0]
};
function rsaJwkToBuffer(jwk, opts) {
if ('string' !== typeof jwk.e) {
throw new TypeError('Expected "jwk.e" to be a String');
}
if ('string' !== typeof jwk.n) {
throw new TypeError('Expected "jwk.n" to be a String');
}
if (opts.private) {
if ('string' !== typeof jwk.d) {
throw new TypeError('Expected "jwk.d" to be a String');
}
if ('string' !== typeof jwk.p) {
throw new TypeError('Expected "jwk.p" to be a String');
}
if ('string' !== typeof jwk.q) {
throw new TypeError('Expected "jwk.q" to be a String');
}
if ('string' !== typeof jwk.dp) {
throw new TypeError('Expected "jwk.dp" to be a String');
}
if ('string' !== typeof jwk.dq) {
throw new TypeError('Expected "jwk.dq" to be a String');
}
if ('string' !== typeof jwk.qi) {
throw new TypeError('Expected "jwk.qi" to be a String');
}
}
var pem;
if (opts.private) {
pem = PrivateKeyInfo.encode({
version: 0,
privateKeyAlgorithm: algorithm,
privateKey: RSAPrivateKey.encode({
version: 0,
modulus: b64ToBn(jwk.n, false),
publicExponent: b64ToBn(jwk.e, false),
privateExponent: b64ToBn(jwk.d, true),
prime1: b64ToBn(jwk.p, true),
prime2: b64ToBn(jwk.q, true),
exponent1: b64ToBn(jwk.dp, true),
exponent2: b64ToBn(jwk.dq, true),
coefficient: b64ToBn(jwk.qi, true)
}, 'der')
}, 'pem', {
label: 'PRIVATE KEY'
});
} else {
pem = PublicKeyInfo.encode({
algorithm: algorithm,
PublicKey: {
unused: 0,
data: RSAPublicKey.encode({
modulus: b64ToBn(jwk.n, false),
publicExponent: b64ToBn(jwk.e, false)
}, 'der')
}
}, 'pem', {
label: 'PUBLIC KEY'
});
}
// This is in an if incase asn1.js adds a trailing \n
// istanbul ignore else
if ('\n' !== pem.slice(-1)) {
pem += '\n';
}
return pem;
}
module.exports = rsaJwkToBuffer;