Skip to content

Commit fc32537

Browse files
committed
base-acme-client.js
fetchAndRetryProtectedUntilOk can be silenced now remove answer wrapper simplify entire API to get or error eg. order.get | order.error account.get | account.error directory.get | directory.error
1 parent 295bdaf commit fc32537

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ Fetch a protected resource with multiple retry attempts and progressive backoff.
531531
* @param {Object} privateKey - The private key for signing the request
532532
* @param {Object} acmeDirectory - The ACME directory containing URLs for ACME operations
533533
* @param {number} [attempts=6] - Maximum number of fetch attempts (default: 6)
534+
* @param {boolean} silent - true to suppress console output on failure attempt
534535
*
535536
* @returns {Promise<Response|undefined>} The response or undefined if all attempts fail
536537
*
@@ -555,7 +556,7 @@ Fetch a protected resource with multiple retry attempts and progressive backoff.
555556
* // Process successful response
556557
* }
557558
*/
558-
export async function fetchAndRetryProtectedUntilOk(payload, protectedHeader, privateKey, acmeDirectory, attempts = 3) { /*...*/ }
559+
export async function fetchAndRetryProtectedUntilOk(payload, protectedHeader, privateKey, acmeDirectory, attempts = 3, silent = false) { /*...*/ }
559560
```
560561

561562
</details>

base-acme-client.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ export async function fetchAndRetryUntilOk(fetchInput, init, attempts = 6, silen
529529
* @param {Object} privateKey - The private key for signing the request
530530
* @param {Object} acmeDirectory - The ACME directory containing URLs for ACME operations
531531
* @param {number} [attempts=6] - Maximum number of fetch attempts (default: 6)
532+
* @param {boolean} silent - true to suppress console output on failure attempt
532533
*
533534
* @returns {Promise<Response|undefined>} The response or undefined if all attempts fail
534535
*
@@ -553,7 +554,7 @@ export async function fetchAndRetryUntilOk(fetchInput, init, attempts = 6, silen
553554
* // Process successful response
554555
* }
555556
*/
556-
export async function fetchAndRetryProtectedUntilOk(payload, protectedHeader, privateKey, acmeDirectory, attempts = 3) {
557+
export async function fetchAndRetryProtectedUntilOk(payload, protectedHeader, privateKey, acmeDirectory, attempts = 3, silent = false) {
557558
let a = 1;
558559

559560
while (a <= attempts) {
@@ -588,7 +589,9 @@ export async function fetchAndRetryProtectedUntilOk(payload, protectedHeader, pr
588589

589590
protectedHeader.nonce = undefined;
590591

591-
console.log(a - 1, "attempt failed, trying again", protectedHeader);
592+
if (!silent) {
593+
console.log(a - 1, "attempt failed, trying again", protectedHeader);
594+
}
592595

593596
await new Promise((resolve) => setTimeout(() => { resolve(); }, 2250 * a)); // Each failed attempt will delay itself slightly more
594597
} catch (exception) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "base-acme-client",
33
"author": "FirstTimeEZ",
4-
"version": "30.0.2",
4+
"version": "30.0.3",
55
"description": "Implementation of the Automatic Certificate Management Environment in Javascript (RFC8555)",
66
"main": "base-acme-client.js",
77
"type": "module",

0 commit comments

Comments
 (0)