make Prettier v2
This commit is contained in:
parent
e880ef3f83
commit
b1df7af626
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"printWidth": 80,
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"useTabs": true
|
||||||
|
}
|
|
@ -13,10 +13,7 @@ module.exports = function(bitlen, exp) {
|
||||||
}
|
}
|
||||||
var keypair = ursa.generatePrivateKey(bitlen, exp);
|
var keypair = ursa.generatePrivateKey(bitlen, exp);
|
||||||
var result = {
|
var result = {
|
||||||
privateKeyPem: keypair
|
privateKeyPem: keypair.toPrivatePem().toString('ascii').trim()
|
||||||
.toPrivatePem()
|
|
||||||
.toString('ascii')
|
|
||||||
.trim()
|
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,10 +10,7 @@ Keypairs._sign = function(opts, payload) {
|
||||||
// node specifies RSA-SHAxxx even when it's actually ecdsa (it's all encoded x509 shasums anyway)
|
// node specifies RSA-SHAxxx even when it's actually ecdsa (it's all encoded x509 shasums anyway)
|
||||||
// TODO opts.alg = (protect||header).alg
|
// TODO opts.alg = (protect||header).alg
|
||||||
var nodeAlg = 'SHA' + Keypairs._getBits(opts);
|
var nodeAlg = 'SHA' + Keypairs._getBits(opts);
|
||||||
var binsig = crypto
|
var binsig = crypto.createSign(nodeAlg).update(payload).sign(pem);
|
||||||
.createSign(nodeAlg)
|
|
||||||
.update(payload)
|
|
||||||
.sign(pem);
|
|
||||||
|
|
||||||
if ('EC' === opts.jwk.kty && !/x509|asn1/i.test(opts.format)) {
|
if ('EC' === opts.jwk.kty && !/x509|asn1/i.test(opts.format)) {
|
||||||
// ECDSA JWT signatures differ from "normal" ECDSA signatures
|
// ECDSA JWT signatures differ from "normal" ECDSA signatures
|
||||||
|
|
|
@ -9,9 +9,6 @@ sha2.sum = function(alg, str) {
|
||||||
var sha = 'sha' + String(alg).replace(/^sha-?/i, '');
|
var sha = 'sha' + String(alg).replace(/^sha-?/i, '');
|
||||||
// utf8 is the default for strings
|
// utf8 is the default for strings
|
||||||
var buf = Buffer.from(str);
|
var buf = Buffer.from(str);
|
||||||
return crypto
|
return crypto.createHash(sha).update(buf).digest();
|
||||||
.createHash(sha)
|
|
||||||
.update(buf)
|
|
||||||
.digest();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,14 +89,14 @@ Keypairs.parseOrGenerate({ key: null })
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
Keypairs.parse({ key: JSON.stringify(pair.private) }).then(function(
|
Keypairs.parse({ key: JSON.stringify(pair.private) }).then(
|
||||||
pair
|
function (pair) {
|
||||||
) {
|
|
||||||
if (!pair.private || !pair.public) {
|
if (!pair.private || !pair.public) {
|
||||||
throw new Error('missing key pairs (stringified jwt)');
|
throw new Error('missing key pairs (stringified jwt)');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
Keypairs.parse({
|
Keypairs.parse({
|
||||||
key: JSON.stringify(pair.private),
|
key: JSON.stringify(pair.private),
|
||||||
public: true
|
public: true
|
||||||
|
|
Loading…
Reference in New Issue