forked from root/acme.js
make Prettier v2
This commit is contained in:
parent
87e3555a5a
commit
29a47e8fa4
|
@ -11,7 +11,7 @@ A._getAccountKid = function(me, options) {
|
||||||
// It's just fine if there's no account, we'll go get the key id we need via the existing key
|
// It's just fine if there's no account, we'll go get the key id we need via the existing key
|
||||||
var kid =
|
var kid =
|
||||||
options.kid ||
|
options.kid ||
|
||||||
(options.account && (options.account.key && options.account.key.kid));
|
(options.account && options.account.key && options.account.key.kid);
|
||||||
|
|
||||||
if (kid) {
|
if (kid) {
|
||||||
return Promise.resolve(kid);
|
return Promise.resolve(kid);
|
||||||
|
|
19
acme.js
19
acme.js
|
@ -1236,14 +1236,8 @@ ACME._prepRequest = function(me, options) {
|
||||||
options.domains = options.domains || _csr.altnames;
|
options.domains = options.domains || _csr.altnames;
|
||||||
_csr.altnames = _csr.altnames || [];
|
_csr.altnames = _csr.altnames || [];
|
||||||
if (
|
if (
|
||||||
options.domains
|
options.domains.slice(0).sort().join(' ') !==
|
||||||
.slice(0)
|
_csr.altnames.slice(0).sort().join(' ')
|
||||||
.sort()
|
|
||||||
.join(' ') !==
|
|
||||||
_csr.altnames
|
|
||||||
.slice(0)
|
|
||||||
.sort()
|
|
||||||
.join(' ')
|
|
||||||
) {
|
) {
|
||||||
return Promise.reject(
|
return Promise.reject(
|
||||||
new Error('certificate altnames do not match requested domains')
|
new Error('certificate altnames do not match requested domains')
|
||||||
|
@ -1347,10 +1341,7 @@ ACME._csrToUrlBase64 = function(csr) {
|
||||||
// TODO use PEM.parseBlock()
|
// TODO use PEM.parseBlock()
|
||||||
// nix PEM headers, if any
|
// nix PEM headers, if any
|
||||||
if ('-' === csr[0]) {
|
if ('-' === csr[0]) {
|
||||||
csr = csr
|
csr = csr.split(/\n+/).slice(1, -1).join('');
|
||||||
.split(/\n+/)
|
|
||||||
.slice(1, -1)
|
|
||||||
.join('');
|
|
||||||
}
|
}
|
||||||
return Enc.base64ToUrlBase64(csr.trim().replace(/\s+/g, ''));
|
return Enc.base64ToUrlBase64(csr.trim().replace(/\s+/g, ''));
|
||||||
};
|
};
|
||||||
|
@ -1359,9 +1350,7 @@ ACME._csrToUrlBase64 = function(csr) {
|
||||||
ACME._prnd = function (n) {
|
ACME._prnd = function (n) {
|
||||||
var rnd = '';
|
var rnd = '';
|
||||||
while (rnd.length / 2 < n) {
|
while (rnd.length / 2 < n) {
|
||||||
var i = Math.random()
|
var i = Math.random().toString().substr(2);
|
||||||
.toString()
|
|
||||||
.substr(2);
|
|
||||||
var h = parseInt(i, 10).toString(16);
|
var h = parseInt(i, 10).toString(16);
|
||||||
if (h.length % 2) {
|
if (h.length % 2) {
|
||||||
h = '0' + h;
|
h = '0' + h;
|
||||||
|
|
|
@ -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();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -247,12 +247,7 @@ module.exports = function() {
|
||||||
|
|
||||||
function random() {
|
function random() {
|
||||||
return (
|
return (
|
||||||
parseInt(
|
parseInt(Math.random().toString().slice(2, 99), 10)
|
||||||
Math.random()
|
|
||||||
.toString()
|
|
||||||
.slice(2, 99),
|
|
||||||
10
|
|
||||||
)
|
|
||||||
.toString(16)
|
.toString(16)
|
||||||
.slice(0, 4) + '例'
|
.slice(0, 4) + '例'
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,10 +33,7 @@ native
|
||||||
|
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
var nonce = '20';
|
var nonce = '20';
|
||||||
var needle = crypto
|
var needle = crypto.randomBytes(3).toString('hex').slice(0, 5);
|
||||||
.randomBytes(3)
|
|
||||||
.toString('hex')
|
|
||||||
.slice(0, 5);
|
|
||||||
native
|
native
|
||||||
._hashcash({
|
._hashcash({
|
||||||
alg: 'SHA-256',
|
alg: 'SHA-256',
|
||||||
|
|
Loading…
Reference in New Issue