@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 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.21.2",
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": "031df8fc35f60650d509b448efe1124e06ac7553"
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
- * Ensure provider directory exists
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
- if (!this.directory) {
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.directory = resp.data;
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 (!this.directory[resource]) {
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 this.directory[resource];
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 this.directory) && (field in this.directory.meta)) {
157
- return this.directory.meta[field];
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',
package/types/index.d.ts CHANGED
@@ -87,6 +87,10 @@ export const directory: {
87
87
  staging: string,
88
88
  production: string
89
89
  },
90
+ google: {
91
+ staging: string,
92
+ production: string
93
+ },
90
94
  letsencrypt: {
91
95
  staging: string,
92
96
  production: string