@certd/acme-client 1.21.2 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/package.json +2 -2
- package/src/http.js +18 -11
- package/src/index.js +4 -0
- package/types/index.d.ts +4 -0
package/README.md
CHANGED
|
@@ -59,6 +59,9 @@ const client = new acme.Client({
|
|
|
59
59
|
acme.directory.buypass.staging;
|
|
60
60
|
acme.directory.buypass.production;
|
|
61
61
|
|
|
62
|
+
acme.directory.google.staging;
|
|
63
|
+
acme.directory.google.production;
|
|
64
|
+
|
|
62
65
|
acme.directory.letsencrypt.staging;
|
|
63
66
|
acme.directory.letsencrypt.production;
|
|
64
67
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Simple and unopinionated ACME client",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "nmorsman",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.22.0",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"types": "types/index.d.ts",
|
|
9
9
|
"license": "MIT",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"bugs": {
|
|
60
60
|
"url": "https://github.com/publishlab/node-acme-client/issues"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "47fe3d5826661f678d081ab53e67c847a3239d88"
|
|
63
63
|
}
|
package/src/http.js
CHANGED
|
@@ -36,8 +36,11 @@ class HttpClient {
|
|
|
36
36
|
this.externalAccountBinding = externalAccountBinding;
|
|
37
37
|
|
|
38
38
|
this.maxBadNonceRetries = 5;
|
|
39
|
-
this.directory = null;
|
|
40
39
|
this.jwk = null;
|
|
40
|
+
|
|
41
|
+
this.directoryCache = null;
|
|
42
|
+
this.directoryMaxAge = 86400;
|
|
43
|
+
this.directoryTimestamp = 0;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
/**
|
|
@@ -70,15 +73,17 @@ class HttpClient {
|
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
/**
|
|
73
|
-
*
|
|
76
|
+
* Get ACME provider directory
|
|
74
77
|
*
|
|
75
78
|
* https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.1
|
|
76
79
|
*
|
|
77
|
-
* @returns {Promise}
|
|
80
|
+
* @returns {Promise<object>} ACME directory contents
|
|
78
81
|
*/
|
|
79
82
|
|
|
80
83
|
async getDirectory() {
|
|
81
|
-
|
|
84
|
+
const age = (Math.floor(Date.now() / 1000) - this.directoryTimestamp);
|
|
85
|
+
|
|
86
|
+
if (!this.directoryCache || (age > this.directoryMaxAge)) {
|
|
82
87
|
const resp = await this.request(this.directoryUrl, 'get');
|
|
83
88
|
|
|
84
89
|
if (resp.status >= 400) {
|
|
@@ -89,8 +94,10 @@ class HttpClient {
|
|
|
89
94
|
throw new Error('Attempting to read ACME directory returned no data');
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
this.
|
|
97
|
+
this.directoryCache = resp.data;
|
|
93
98
|
}
|
|
99
|
+
|
|
100
|
+
return this.directoryCache;
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
/**
|
|
@@ -134,13 +141,13 @@ class HttpClient {
|
|
|
134
141
|
*/
|
|
135
142
|
|
|
136
143
|
async getResourceUrl(resource) {
|
|
137
|
-
await this.getDirectory();
|
|
144
|
+
const dir = await this.getDirectory();
|
|
138
145
|
|
|
139
|
-
if (!
|
|
146
|
+
if (!dir[resource]) {
|
|
140
147
|
throw new Error(`Unable to locate API resource URL in ACME directory: "${resource}"`);
|
|
141
148
|
}
|
|
142
149
|
|
|
143
|
-
return
|
|
150
|
+
return dir[resource];
|
|
144
151
|
}
|
|
145
152
|
|
|
146
153
|
/**
|
|
@@ -151,10 +158,10 @@ class HttpClient {
|
|
|
151
158
|
*/
|
|
152
159
|
|
|
153
160
|
async getMetaField(field) {
|
|
154
|
-
await this.getDirectory();
|
|
161
|
+
const dir = await this.getDirectory();
|
|
155
162
|
|
|
156
|
-
if (('meta' in
|
|
157
|
-
return
|
|
163
|
+
if (('meta' in dir) && (field in dir.meta)) {
|
|
164
|
+
return dir.meta[field];
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
return null;
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,10 @@ exports.directory = {
|
|
|
13
13
|
staging: 'https://api.test4.buypass.no/acme/directory',
|
|
14
14
|
production: 'https://api.buypass.com/acme/directory',
|
|
15
15
|
},
|
|
16
|
+
google: {
|
|
17
|
+
staging: 'https://dv.acme-v02.test-api.pki.goog/directory',
|
|
18
|
+
production: 'https://dv.acme-v02.api.pki.goog/directory',
|
|
19
|
+
},
|
|
16
20
|
letsencrypt: {
|
|
17
21
|
staging: 'https://acme-staging-v02.api.letsencrypt.org/directory',
|
|
18
22
|
production: 'https://acme-v02.api.letsencrypt.org/directory',
|