Skip to content

Commit 0330ddf

Browse files
committed
base-acme-client.js
- add getNextNonce export - rename `newDirectoryAsync` to `newDirectory` (its still async) - rename `newNonceAsync` to `newNonce` (its still async) - changes to how errors/exceptions are returned - errors have `error.type` of `bac:failed:methodName` - exceptions have `error.type` of `bac:exception:methodName` - inside `error.details` is the message/exception - errors and exceptions from bac have an `error.status` of `777777` or similar
1 parent b4bfce7 commit 0330ddf

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

base-acme-client.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ import { createPrivateKey, createPublicKey, createHash, sign } from 'crypto';
1010
import { generateCSRWithExistingKeys } from 'simple-csr-generator';
1111

1212
const CONTENT_TYPE = "Content-Type";
13+
const CONTENT_TYPE_JOSE = 'application/jose+json';
1314

1415
const DIGEST = "sha256";
1516
const ALG_ECDSA = 'ES256';
1617

17-
const CONTENT_TYPE_JOSE = 'application/jose+json';
18-
1918
const METHOD_GET = "GET";
2019
const METHOD_POST = "POST";
2120
const METHOD_HEAD = "HEAD";
@@ -41,12 +40,7 @@ export async function newDirectory(mainDirectoryUrl) {
4140
const response = await fetchAndRetryUntilOk(mainDirectoryUrl, { method: METHOD_GET });
4241

4342
if (response) {
44-
if (response.ok) {
45-
return { answer: { directory: await response.json() } };
46-
}
47-
else {
48-
return { answer: { error: await response.json() } };
49-
}
43+
return { answer: response.ok ? { directory: await response.json() } : { error: await response.json() } };
5044
}
5145

5246
return notCompletedError("newDirectory");
@@ -70,12 +64,7 @@ export async function newNonce(newNonceUrl) {
7064
const response = await fetchAndRetryUntilOk(newNonceUrl, { method: METHOD_HEAD });
7165

7266
if (response) {
73-
if (response.ok) {
74-
return { answer: null, nonce: response.headers.get(REPLAY_NONCE) };
75-
}
76-
else {
77-
return { answer: { error: await response.json() } };
78-
}
67+
return response.ok ? { answer: null, nonce: response.headers.get(REPLAY_NONCE) } : { answer: { error: await response.json() } };
7968
}
8069

8170
return notCompletedError("newNonce");

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": "22.0.7",
4+
"version": "22.0.8",
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)