🔱: [acme] sync upgrade with 3 commits [trident-sync]

Clean up eslintrc, style refactor and formatting fixes
Update auto.js

see https://github.com/publishlab/node-acme-client/issues/88#issuecomment-2105255828
This commit is contained in:
GitHub Actions Bot
2024-05-22 19:24:07 +00:00
parent c9d5cda953
commit 0f1ae6ccd9
34 changed files with 175 additions and 422 deletions
+3 -15
View File
@@ -7,7 +7,6 @@ const { getJwk } = require('./crypto');
const { log } = require('./logger');
const axios = require('./axios');
/**
* ACME HTTP client
*
@@ -30,7 +29,6 @@ class HttpClient {
this.jwk = null;
}
/**
* HTTP request
*
@@ -60,7 +58,6 @@ class HttpClient {
return resp;
}
/**
* Ensure provider directory exists
*
@@ -85,7 +82,6 @@ class HttpClient {
}
}
/**
* Get JSON Web Key
*
@@ -100,7 +96,6 @@ class HttpClient {
return this.jwk;
}
/**
* Get nonce from directory API endpoint
*
@@ -120,7 +115,6 @@ class HttpClient {
return resp.headers['replay-nonce'];
}
/**
* Get URL for a directory resource
*
@@ -138,7 +132,6 @@ class HttpClient {
return this.directory[resource];
}
/**
* Get directory meta field
*
@@ -156,7 +149,6 @@ class HttpClient {
return null;
}
/**
* Prepare HTTP request body for signature
*
@@ -189,11 +181,10 @@ class HttpClient {
/* Body */
return {
payload: payload ? Buffer.from(JSON.stringify(payload)).toString('base64url') : '',
protected: Buffer.from(JSON.stringify(header)).toString('base64url')
protected: Buffer.from(JSON.stringify(header)).toString('base64url'),
};
}
/**
* Create JWS HTTP request body using HMAC
*
@@ -216,7 +207,6 @@ class HttpClient {
return result;
}
/**
* Create JWS HTTP request body using RSA or ECC
*
@@ -257,13 +247,12 @@ class HttpClient {
result.signature = signer.sign({
key: this.accountKey,
padding: RSA_PKCS1_PADDING,
dsaEncoding: 'ieee-p1363'
dsaEncoding: 'ieee-p1363',
}, 'base64url');
return result;
}
/**
* Signed HTTP request
*
@@ -299,7 +288,7 @@ class HttpClient {
const data = this.createSignedBody(url, payload, { nonce, kid });
const resp = await this.request(url, 'post', { data });
/* Retry on bad nonce - https://datatracker.ietf.org/doc/html/draft-ietf-acme-acme-10#section-6.4 */
/* Retry on bad nonce - https://datatracker.ietf.org/doc/html/rfc8555#section-6.5 */
if (resp.data && resp.data.type && (resp.status === 400) && (resp.data.type === 'urn:ietf:params:acme:error:badNonce') && (attempts < this.maxBadNonceRetries)) {
nonce = resp.headers['replay-nonce'] || null;
attempts += 1;
@@ -313,6 +302,5 @@ class HttpClient {
}
}
/* Export client */
module.exports = HttpClient;