make Prettier v2

This commit is contained in:
AJ ONeal 2020-07-28 15:42:32 -06:00
parent e880ef3f83
commit b1df7af626
19 changed files with 146 additions and 147 deletions

8
.prettierrc Normal file
View File

@ -0,0 +1,8 @@
{
"bracketSpacing": true,
"printWidth": 80,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "none",
"useTabs": true
}

View File

@ -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;
}; };

View File

@ -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

View File

@ -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();
}); });
}; };

View File

@ -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