@certd/acme-client 1.20.15 → 1.20.16
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 +19 -20
- package/package.json +11 -11
- package/src/api.js +1 -17
- package/src/auto.js +12 -12
- package/src/axios.js +1 -4
- package/src/client.js +18 -42
- package/src/crypto/forge.js +18 -31
- package/src/crypto/index.js +25 -40
- package/src/http.js +3 -14
- package/src/index.js +4 -8
- package/src/logger.js +1 -3
- package/src/util.js +2 -13
- package/src/verify.js +1 -6
- package/types/index.d.ts +0 -6
- package/types/index.test-d.ts +0 -1
- package/types/rfc8555.d.ts +0 -4
package/README.md
CHANGED
|
@@ -9,13 +9,13 @@ This module is written to handle communication with a Boulder/Let's Encrypt-styl
|
|
|
9
9
|
|
|
10
10
|
## Compatibility
|
|
11
11
|
|
|
12
|
-
| acme-client
|
|
13
|
-
|
|
|
14
|
-
| v5.x
|
|
15
|
-
| v4.x
|
|
16
|
-
| v3.x
|
|
17
|
-
| v2.x
|
|
18
|
-
| v1.x
|
|
12
|
+
| acme-client | Node.js | |
|
|
13
|
+
| ----------- | ------- | ----------------------------------------- |
|
|
14
|
+
| v5.x | >= v16 | [Upgrade guide](docs/upgrade-v5.md) |
|
|
15
|
+
| v4.x | >= v10 | [Changelog](CHANGELOG.md#v400-2020-05-29) |
|
|
16
|
+
| v3.x | >= v8 | [Changelog](CHANGELOG.md#v300-2019-07-13) |
|
|
17
|
+
| v2.x | >= v4 | [Changelog](CHANGELOG.md#v200-2018-04-02) |
|
|
18
|
+
| v1.x | >= v4 | [Changelog](CHANGELOG.md#v100-2017-10-20) |
|
|
19
19
|
|
|
20
20
|
## Table of contents
|
|
21
21
|
|
|
@@ -49,7 +49,7 @@ const accountPrivateKey = '<PEM encoded private key>';
|
|
|
49
49
|
|
|
50
50
|
const client = new acme.Client({
|
|
51
51
|
directoryUrl: acme.directory.letsencrypt.staging,
|
|
52
|
-
accountKey: accountPrivateKey
|
|
52
|
+
accountKey: accountPrivateKey,
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -75,8 +75,8 @@ const client = new acme.Client({
|
|
|
75
75
|
accountKey: accountPrivateKey,
|
|
76
76
|
externalAccountBinding: {
|
|
77
77
|
kid: 'YOUR-EAB-KID',
|
|
78
|
-
hmacKey: 'YOUR-EAB-HMAC-KEY'
|
|
79
|
-
}
|
|
78
|
+
hmacKey: 'YOUR-EAB-HMAC-KEY',
|
|
79
|
+
},
|
|
80
80
|
});
|
|
81
81
|
```
|
|
82
82
|
|
|
@@ -90,7 +90,7 @@ In some cases, for example with some EAB providers, this account creation step m
|
|
|
90
90
|
const client = new acme.Client({
|
|
91
91
|
directoryUrl: acme.directory.letsencrypt.staging,
|
|
92
92
|
accountKey: accountPrivateKey,
|
|
93
|
-
accountUrl: 'https://acme-v02.api.letsencrypt.org/acme/acct/12345678'
|
|
93
|
+
accountUrl: 'https://acme-v02.api.letsencrypt.org/acme/acct/12345678',
|
|
94
94
|
});
|
|
95
95
|
```
|
|
96
96
|
|
|
@@ -113,8 +113,7 @@ const privateRsaKey = await acme.crypto.createPrivateRsaKey();
|
|
|
113
113
|
const privateEcdsaKey = await acme.crypto.createPrivateEcdsaKey();
|
|
114
114
|
|
|
115
115
|
const [certificateKey, certificateCsr] = await acme.crypto.createCsr({
|
|
116
|
-
|
|
117
|
-
altNames: ['example.com']
|
|
116
|
+
altNames: ['example.com', '*.example.com'],
|
|
118
117
|
});
|
|
119
118
|
```
|
|
120
119
|
|
|
@@ -139,7 +138,7 @@ const autoOpts = {
|
|
|
139
138
|
email: 'test@example.com',
|
|
140
139
|
termsOfServiceAgreed: true,
|
|
141
140
|
challengeCreateFn: async (authz, challenge, keyAuthorization) => {},
|
|
142
|
-
challengeRemoveFn: async (authz, challenge, keyAuthorization) => {}
|
|
141
|
+
challengeRemoveFn: async (authz, challenge, keyAuthorization) => {},
|
|
143
142
|
};
|
|
144
143
|
|
|
145
144
|
const certificate = await client.auto(autoOpts);
|
|
@@ -156,7 +155,7 @@ To modify challenge priority, provide a list of challenge types in `challengePri
|
|
|
156
155
|
```js
|
|
157
156
|
await client.auto({
|
|
158
157
|
...,
|
|
159
|
-
challengePriority: ['http-01', 'dns-01']
|
|
158
|
+
challengePriority: ['http-01', 'dns-01'],
|
|
160
159
|
});
|
|
161
160
|
```
|
|
162
161
|
|
|
@@ -171,7 +170,7 @@ To completely disable `acme-client`s internal challenge verification, enable `sk
|
|
|
171
170
|
```js
|
|
172
171
|
await client.auto({
|
|
173
172
|
...,
|
|
174
|
-
skipChallengeVerification: true
|
|
173
|
+
skipChallengeVerification: true,
|
|
175
174
|
});
|
|
176
175
|
```
|
|
177
176
|
|
|
@@ -185,14 +184,14 @@ For more fine-grained control you can interact with the ACME API using the metho
|
|
|
185
184
|
```js
|
|
186
185
|
const account = await client.createAccount({
|
|
187
186
|
termsOfServiceAgreed: true,
|
|
188
|
-
contact: ['mailto:test@example.com']
|
|
187
|
+
contact: ['mailto:test@example.com'],
|
|
189
188
|
});
|
|
190
189
|
|
|
191
190
|
const order = await client.createOrder({
|
|
192
191
|
identifiers: [
|
|
193
192
|
{ type: 'dns', value: 'example.com' },
|
|
194
|
-
{ type: 'dns', value: '*.example.com' }
|
|
195
|
-
]
|
|
193
|
+
{ type: 'dns', value: '*.example.com' },
|
|
194
|
+
],
|
|
196
195
|
});
|
|
197
196
|
```
|
|
198
197
|
|
|
@@ -207,7 +206,7 @@ const acme = require('acme-client');
|
|
|
207
206
|
|
|
208
207
|
acme.axios.defaults.proxy = {
|
|
209
208
|
host: '127.0.0.1',
|
|
210
|
-
port: 9000
|
|
209
|
+
port: 9000,
|
|
211
210
|
};
|
|
212
211
|
```
|
|
213
212
|
|
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.20.
|
|
6
|
+
"version": "1.20.16",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"types": "types/index.d.ts",
|
|
9
9
|
"license": "MIT",
|
|
@@ -16,24 +16,24 @@
|
|
|
16
16
|
"types"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@peculiar/x509": "^1.
|
|
19
|
+
"@peculiar/x509": "^1.10.0",
|
|
20
20
|
"asn1js": "^3.0.5",
|
|
21
|
-
"axios": "^1.
|
|
21
|
+
"axios": "^1.7.2",
|
|
22
22
|
"debug": "^4.1.1",
|
|
23
23
|
"https-proxy-agent": "^7.0.4",
|
|
24
24
|
"node-forge": "^1.3.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@types/node": "^20.
|
|
27
|
+
"@types/node": "^20.12.12",
|
|
28
28
|
"chai": "^4.4.1",
|
|
29
|
-
"chai-as-promised": "^7.1.
|
|
30
|
-
"eslint": "^8.
|
|
29
|
+
"chai-as-promised": "^7.1.2",
|
|
30
|
+
"eslint": "^8.57.0",
|
|
31
31
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
32
32
|
"eslint-plugin-import": "^2.29.1",
|
|
33
|
-
"jsdoc-to-markdown": "^8.0.
|
|
34
|
-
"mocha": "^10.
|
|
35
|
-
"nock": "^13.5.
|
|
36
|
-
"tsd": "^0.
|
|
33
|
+
"jsdoc-to-markdown": "^8.0.1",
|
|
34
|
+
"mocha": "^10.4.0",
|
|
35
|
+
"nock": "^13.5.4",
|
|
36
|
+
"tsd": "^0.31.0",
|
|
37
37
|
"typescript": "^4.8.4",
|
|
38
38
|
"uuid": "^8.3.2"
|
|
39
39
|
},
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"bugs": {
|
|
60
60
|
"url": "https://github.com/publishlab/node-acme-client/issues"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "d46dab4fdda738fac0be87a60a3af6037feb42d4"
|
|
63
63
|
}
|
package/src/api.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
const util = require('./util');
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* AcmeApi
|
|
10
9
|
*
|
|
@@ -18,7 +17,6 @@ class AcmeApi {
|
|
|
18
17
|
this.accountUrl = accountUrl;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
20
|
/**
|
|
23
21
|
* Get account URL
|
|
24
22
|
*
|
|
@@ -34,7 +32,6 @@ class AcmeApi {
|
|
|
34
32
|
return this.accountUrl;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
35
|
/**
|
|
39
36
|
* ACME API request
|
|
40
37
|
*
|
|
@@ -59,7 +56,6 @@ class AcmeApi {
|
|
|
59
56
|
return resp;
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
|
|
63
59
|
/**
|
|
64
60
|
* ACME API request by resource name helper
|
|
65
61
|
*
|
|
@@ -78,7 +74,6 @@ class AcmeApi {
|
|
|
78
74
|
return this.apiRequest(resourceUrl, payload, validStatusCodes, { includeJwsKid, includeExternalAccountBinding });
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
|
|
82
77
|
/**
|
|
83
78
|
* Get Terms of Service URL if available
|
|
84
79
|
*
|
|
@@ -91,7 +86,6 @@ class AcmeApi {
|
|
|
91
86
|
return this.http.getMetaField('termsOfService');
|
|
92
87
|
}
|
|
93
88
|
|
|
94
|
-
|
|
95
89
|
/**
|
|
96
90
|
* Create new account
|
|
97
91
|
*
|
|
@@ -104,7 +98,7 @@ class AcmeApi {
|
|
|
104
98
|
async createAccount(data) {
|
|
105
99
|
const resp = await this.apiResourceRequest('newAccount', data, [200, 201], {
|
|
106
100
|
includeJwsKid: false,
|
|
107
|
-
includeExternalAccountBinding: (data.onlyReturnExisting !== true)
|
|
101
|
+
includeExternalAccountBinding: (data.onlyReturnExisting !== true),
|
|
108
102
|
});
|
|
109
103
|
|
|
110
104
|
/* Set account URL */
|
|
@@ -115,7 +109,6 @@ class AcmeApi {
|
|
|
115
109
|
return resp;
|
|
116
110
|
}
|
|
117
111
|
|
|
118
|
-
|
|
119
112
|
/**
|
|
120
113
|
* Update account
|
|
121
114
|
*
|
|
@@ -129,7 +122,6 @@ class AcmeApi {
|
|
|
129
122
|
return this.apiRequest(this.getAccountUrl(), data, [200, 202]);
|
|
130
123
|
}
|
|
131
124
|
|
|
132
|
-
|
|
133
125
|
/**
|
|
134
126
|
* Update account key
|
|
135
127
|
*
|
|
@@ -143,7 +135,6 @@ class AcmeApi {
|
|
|
143
135
|
return this.apiResourceRequest('keyChange', data, [200]);
|
|
144
136
|
}
|
|
145
137
|
|
|
146
|
-
|
|
147
138
|
/**
|
|
148
139
|
* Create new order
|
|
149
140
|
*
|
|
@@ -157,7 +148,6 @@ class AcmeApi {
|
|
|
157
148
|
return this.apiResourceRequest('newOrder', data, [201]);
|
|
158
149
|
}
|
|
159
150
|
|
|
160
|
-
|
|
161
151
|
/**
|
|
162
152
|
* Get order
|
|
163
153
|
*
|
|
@@ -171,7 +161,6 @@ class AcmeApi {
|
|
|
171
161
|
return this.apiRequest(url, null, [200]);
|
|
172
162
|
}
|
|
173
163
|
|
|
174
|
-
|
|
175
164
|
/**
|
|
176
165
|
* Finalize order
|
|
177
166
|
*
|
|
@@ -186,7 +175,6 @@ class AcmeApi {
|
|
|
186
175
|
return this.apiRequest(url, data, [200]);
|
|
187
176
|
}
|
|
188
177
|
|
|
189
|
-
|
|
190
178
|
/**
|
|
191
179
|
* Get identifier authorization
|
|
192
180
|
*
|
|
@@ -200,7 +188,6 @@ class AcmeApi {
|
|
|
200
188
|
return this.apiRequest(url, null, [200]);
|
|
201
189
|
}
|
|
202
190
|
|
|
203
|
-
|
|
204
191
|
/**
|
|
205
192
|
* Update identifier authorization
|
|
206
193
|
*
|
|
@@ -215,7 +202,6 @@ class AcmeApi {
|
|
|
215
202
|
return this.apiRequest(url, data, [200]);
|
|
216
203
|
}
|
|
217
204
|
|
|
218
|
-
|
|
219
205
|
/**
|
|
220
206
|
* Complete challenge
|
|
221
207
|
*
|
|
@@ -230,7 +216,6 @@ class AcmeApi {
|
|
|
230
216
|
return this.apiRequest(url, data, [200]);
|
|
231
217
|
}
|
|
232
218
|
|
|
233
|
-
|
|
234
219
|
/**
|
|
235
220
|
* Revoke certificate
|
|
236
221
|
*
|
|
@@ -245,6 +230,5 @@ class AcmeApi {
|
|
|
245
230
|
}
|
|
246
231
|
}
|
|
247
232
|
|
|
248
|
-
|
|
249
233
|
/* Export API */
|
|
250
234
|
module.exports = AcmeApi;
|
package/src/auto.js
CHANGED
|
@@ -14,10 +14,9 @@ const defaultOpts = {
|
|
|
14
14
|
skipChallengeVerification: false,
|
|
15
15
|
challengePriority: ['http-01', 'dns-01'],
|
|
16
16
|
challengeCreateFn: async () => { throw new Error('Missing challengeCreateFn()'); },
|
|
17
|
-
challengeRemoveFn: async () => { throw new Error('Missing challengeRemoveFn()'); }
|
|
17
|
+
challengeRemoveFn: async () => { throw new Error('Missing challengeRemoveFn()'); },
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
/**
|
|
22
21
|
* ACME client auto mode
|
|
23
22
|
*
|
|
@@ -26,8 +25,8 @@ const defaultOpts = {
|
|
|
26
25
|
* @returns {Promise<buffer>} Certificate
|
|
27
26
|
*/
|
|
28
27
|
|
|
29
|
-
module.exports = async
|
|
30
|
-
const opts =
|
|
28
|
+
module.exports = async (client, userOpts) => {
|
|
29
|
+
const opts = { ...defaultOpts, ...userOpts };
|
|
31
30
|
const accountPayload = { termsOfServiceAgreed: opts.termsOfServiceAgreed };
|
|
32
31
|
|
|
33
32
|
if (!Buffer.isBuffer(opts.csr)) {
|
|
@@ -38,7 +37,6 @@ module.exports = async function(client, userOpts) {
|
|
|
38
37
|
accountPayload.contact = [`mailto:${opts.email}`];
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
|
|
42
40
|
/**
|
|
43
41
|
* Register account
|
|
44
42
|
*/
|
|
@@ -54,7 +52,6 @@ module.exports = async function(client, userOpts) {
|
|
|
54
52
|
await client.createAccount(accountPayload);
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
|
|
58
55
|
/**
|
|
59
56
|
* Parse domains from CSR
|
|
60
57
|
*/
|
|
@@ -65,7 +62,6 @@ module.exports = async function(client, userOpts) {
|
|
|
65
62
|
|
|
66
63
|
log(`[auto] Resolved ${uniqueDomains.length} unique domains from parsing the Certificate Signing Request`);
|
|
67
64
|
|
|
68
|
-
|
|
69
65
|
/**
|
|
70
66
|
* Place order
|
|
71
67
|
*/
|
|
@@ -77,7 +73,6 @@ module.exports = async function(client, userOpts) {
|
|
|
77
73
|
|
|
78
74
|
log(`[auto] Placed certificate order successfully, received ${authorizations.length} identity authorizations`);
|
|
79
75
|
|
|
80
|
-
|
|
81
76
|
/**
|
|
82
77
|
* Resolve and satisfy challenges
|
|
83
78
|
*/
|
|
@@ -176,7 +171,6 @@ module.exports = async function(client, userOpts) {
|
|
|
176
171
|
await challengeFunc(authz);
|
|
177
172
|
});
|
|
178
173
|
|
|
179
|
-
|
|
180
174
|
function runAllPromise(tasks) {
|
|
181
175
|
let promise = Promise.resolve();
|
|
182
176
|
tasks.forEach((task) => {
|
|
@@ -196,7 +190,6 @@ module.exports = async function(client, userOpts) {
|
|
|
196
190
|
return Promise.all(results);
|
|
197
191
|
}
|
|
198
192
|
|
|
199
|
-
|
|
200
193
|
try {
|
|
201
194
|
log('开始challenge');
|
|
202
195
|
await runPromisePa(challengePromises);
|
|
@@ -216,11 +209,18 @@ module.exports = async function(client, userOpts) {
|
|
|
216
209
|
}
|
|
217
210
|
catch (e) {
|
|
218
211
|
log('证书申请失败');
|
|
219
|
-
|
|
212
|
+
log(e);
|
|
213
|
+
throw new Error(`证书申请失败:${e.message}`);
|
|
220
214
|
}
|
|
221
215
|
finally {
|
|
222
216
|
log(`清理challenge痕迹,length:${clearTasks.length}`);
|
|
223
|
-
|
|
217
|
+
try {
|
|
218
|
+
await runAllPromise(clearTasks);
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
log('清理challenge失败');
|
|
222
|
+
log(e);
|
|
223
|
+
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
// try {
|
package/src/axios.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
const axios = require('axios');
|
|
6
6
|
const pkg = require('./../package.json');
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* Instance
|
|
11
10
|
*/
|
|
@@ -19,9 +18,8 @@ instance.defaults.headers.common['User-Agent'] = `node-${pkg.name}/${pkg.version
|
|
|
19
18
|
instance.defaults.acmeSettings = {
|
|
20
19
|
httpChallengePort: 80,
|
|
21
20
|
httpsChallengePort: 443,
|
|
22
|
-
tlsAlpnChallengePort: 443
|
|
21
|
+
tlsAlpnChallengePort: 443,
|
|
23
22
|
};
|
|
24
|
-
|
|
25
23
|
// instance.defaults.proxy = {
|
|
26
24
|
// host: '192.168.34.139',
|
|
27
25
|
// port: 10811
|
|
@@ -35,7 +33,6 @@ instance.defaults.acmeSettings = {
|
|
|
35
33
|
|
|
36
34
|
instance.defaults.adapter = 'http';
|
|
37
35
|
|
|
38
|
-
|
|
39
36
|
/**
|
|
40
37
|
* Export instance
|
|
41
38
|
*/
|
package/src/client.js
CHANGED
|
@@ -13,7 +13,6 @@ const verify = require('./verify');
|
|
|
13
13
|
const util = require('./util');
|
|
14
14
|
const auto = require('./auto');
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* ACME states
|
|
19
18
|
*
|
|
@@ -24,7 +23,6 @@ const validStates = ['ready', 'valid'];
|
|
|
24
23
|
const pendingStates = ['pending', 'processing'];
|
|
25
24
|
const invalidStates = ['invalid'];
|
|
26
25
|
|
|
27
|
-
|
|
28
26
|
/**
|
|
29
27
|
* Default options
|
|
30
28
|
*
|
|
@@ -38,10 +36,9 @@ const defaultOpts = {
|
|
|
38
36
|
externalAccountBinding: {},
|
|
39
37
|
backoffAttempts: 10,
|
|
40
38
|
backoffMin: 5000,
|
|
41
|
-
backoffMax: 30000
|
|
39
|
+
backoffMax: 30000,
|
|
42
40
|
};
|
|
43
41
|
|
|
44
|
-
|
|
45
42
|
/**
|
|
46
43
|
* AcmeClient
|
|
47
44
|
*
|
|
@@ -61,7 +58,7 @@ const defaultOpts = {
|
|
|
61
58
|
* ```js
|
|
62
59
|
* const client = new acme.Client({
|
|
63
60
|
* directoryUrl: acme.directory.letsencrypt.staging,
|
|
64
|
-
* accountKey: 'Private key goes here'
|
|
61
|
+
* accountKey: 'Private key goes here',
|
|
65
62
|
* });
|
|
66
63
|
* ```
|
|
67
64
|
*
|
|
@@ -73,7 +70,7 @@ const defaultOpts = {
|
|
|
73
70
|
* accountUrl: 'Optional account URL goes here',
|
|
74
71
|
* backoffAttempts: 10,
|
|
75
72
|
* backoffMin: 5000,
|
|
76
|
-
* backoffMax: 30000
|
|
73
|
+
* backoffMax: 30000,
|
|
77
74
|
* });
|
|
78
75
|
* ```
|
|
79
76
|
*
|
|
@@ -84,8 +81,8 @@ const defaultOpts = {
|
|
|
84
81
|
* accountKey: 'Private key goes here',
|
|
85
82
|
* externalAccountBinding: {
|
|
86
83
|
* kid: 'YOUR-EAB-KID',
|
|
87
|
-
* hmacKey: 'YOUR-EAB-HMAC-KEY'
|
|
88
|
-
* }
|
|
84
|
+
* hmacKey: 'YOUR-EAB-HMAC-KEY',
|
|
85
|
+
* },
|
|
89
86
|
* });
|
|
90
87
|
* ```
|
|
91
88
|
*/
|
|
@@ -96,19 +93,17 @@ class AcmeClient {
|
|
|
96
93
|
opts.accountKey = Buffer.from(opts.accountKey);
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
this.opts =
|
|
100
|
-
|
|
96
|
+
this.opts = { ...defaultOpts, ...opts };
|
|
101
97
|
this.backoffOpts = {
|
|
102
98
|
attempts: this.opts.backoffAttempts,
|
|
103
99
|
min: this.opts.backoffMin,
|
|
104
|
-
max: this.opts.backoffMax
|
|
100
|
+
max: this.opts.backoffMax,
|
|
105
101
|
};
|
|
106
102
|
|
|
107
103
|
this.http = new HttpClient(this.opts.directoryUrl, this.opts.accountKey, this.opts.externalAccountBinding);
|
|
108
104
|
this.api = new AcmeApi(this.http, this.opts.accountUrl);
|
|
109
105
|
}
|
|
110
106
|
|
|
111
|
-
|
|
112
107
|
/**
|
|
113
108
|
* Get Terms of Service URL if available
|
|
114
109
|
*
|
|
@@ -128,7 +123,6 @@ class AcmeClient {
|
|
|
128
123
|
return this.api.getTermsOfServiceUrl();
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
|
|
132
126
|
/**
|
|
133
127
|
* Get current account URL
|
|
134
128
|
*
|
|
@@ -150,7 +144,6 @@ class AcmeClient {
|
|
|
150
144
|
return this.api.getAccountUrl();
|
|
151
145
|
}
|
|
152
146
|
|
|
153
|
-
|
|
154
147
|
/**
|
|
155
148
|
* Create a new account
|
|
156
149
|
*
|
|
@@ -162,7 +155,7 @@ class AcmeClient {
|
|
|
162
155
|
* @example Create a new account
|
|
163
156
|
* ```js
|
|
164
157
|
* const account = await client.createAccount({
|
|
165
|
-
* termsOfServiceAgreed: true
|
|
158
|
+
* termsOfServiceAgreed: true,
|
|
166
159
|
* });
|
|
167
160
|
* ```
|
|
168
161
|
*
|
|
@@ -170,7 +163,7 @@ class AcmeClient {
|
|
|
170
163
|
* ```js
|
|
171
164
|
* const account = await client.createAccount({
|
|
172
165
|
* termsOfServiceAgreed: true,
|
|
173
|
-
* contact: ['mailto:test@example.com']
|
|
166
|
+
* contact: ['mailto:test@example.com'],
|
|
174
167
|
* });
|
|
175
168
|
* ```
|
|
176
169
|
*/
|
|
@@ -196,7 +189,6 @@ class AcmeClient {
|
|
|
196
189
|
}
|
|
197
190
|
}
|
|
198
191
|
|
|
199
|
-
|
|
200
192
|
/**
|
|
201
193
|
* Update existing account
|
|
202
194
|
*
|
|
@@ -208,7 +200,7 @@ class AcmeClient {
|
|
|
208
200
|
* @example Update existing account
|
|
209
201
|
* ```js
|
|
210
202
|
* const account = await client.updateAccount({
|
|
211
|
-
* contact: ['mailto:foo@example.com']
|
|
203
|
+
* contact: ['mailto:foo@example.com'],
|
|
212
204
|
* });
|
|
213
205
|
* ```
|
|
214
206
|
*/
|
|
@@ -236,7 +228,6 @@ class AcmeClient {
|
|
|
236
228
|
return resp.data;
|
|
237
229
|
}
|
|
238
230
|
|
|
239
|
-
|
|
240
231
|
/**
|
|
241
232
|
* Update account private key
|
|
242
233
|
*
|
|
@@ -282,7 +273,6 @@ class AcmeClient {
|
|
|
282
273
|
return resp.data;
|
|
283
274
|
}
|
|
284
275
|
|
|
285
|
-
|
|
286
276
|
/**
|
|
287
277
|
* Create a new order
|
|
288
278
|
*
|
|
@@ -296,8 +286,8 @@ class AcmeClient {
|
|
|
296
286
|
* const order = await client.createOrder({
|
|
297
287
|
* identifiers: [
|
|
298
288
|
* { type: 'dns', value: 'example.com' },
|
|
299
|
-
* { type: 'dns', value: 'test.example.com' }
|
|
300
|
-
* ]
|
|
289
|
+
* { type: 'dns', value: 'test.example.com' },
|
|
290
|
+
* ],
|
|
301
291
|
* });
|
|
302
292
|
* ```
|
|
303
293
|
*/
|
|
@@ -314,7 +304,6 @@ class AcmeClient {
|
|
|
314
304
|
return resp.data;
|
|
315
305
|
}
|
|
316
306
|
|
|
317
|
-
|
|
318
307
|
/**
|
|
319
308
|
* Refresh order object from CA
|
|
320
309
|
*
|
|
@@ -376,7 +365,6 @@ class AcmeClient {
|
|
|
376
365
|
return resp.data;
|
|
377
366
|
}
|
|
378
367
|
|
|
379
|
-
|
|
380
368
|
/**
|
|
381
369
|
* Get identifier authorizations from order
|
|
382
370
|
*
|
|
@@ -406,7 +394,6 @@ class AcmeClient {
|
|
|
406
394
|
}));
|
|
407
395
|
}
|
|
408
396
|
|
|
409
|
-
|
|
410
397
|
/**
|
|
411
398
|
* Deactivate identifier authorization
|
|
412
399
|
*
|
|
@@ -427,10 +414,7 @@ class AcmeClient {
|
|
|
427
414
|
throw new Error('Unable to deactivate identifier authorization, URL not found');
|
|
428
415
|
}
|
|
429
416
|
|
|
430
|
-
const data = {
|
|
431
|
-
status: 'deactivated'
|
|
432
|
-
};
|
|
433
|
-
|
|
417
|
+
const data = { status: 'deactivated' };
|
|
434
418
|
const resp = await this.api.updateAuthorization(authz.url, data);
|
|
435
419
|
|
|
436
420
|
/* Add URL to response */
|
|
@@ -438,7 +422,6 @@ class AcmeClient {
|
|
|
438
422
|
return resp.data;
|
|
439
423
|
}
|
|
440
424
|
|
|
441
|
-
|
|
442
425
|
/**
|
|
443
426
|
* Get key authorization for ACME challenge
|
|
444
427
|
*
|
|
@@ -480,7 +463,6 @@ class AcmeClient {
|
|
|
480
463
|
throw new Error(`Unable to produce key authorization, unknown challenge type: ${challenge.type}`);
|
|
481
464
|
}
|
|
482
465
|
|
|
483
|
-
|
|
484
466
|
/**
|
|
485
467
|
* Verify that ACME challenge is satisfied
|
|
486
468
|
*
|
|
@@ -515,7 +497,6 @@ class AcmeClient {
|
|
|
515
497
|
return util.retry(verifyFn, this.backoffOpts);
|
|
516
498
|
}
|
|
517
499
|
|
|
518
|
-
|
|
519
500
|
/**
|
|
520
501
|
* Notify CA that challenge has been completed
|
|
521
502
|
*
|
|
@@ -536,7 +517,6 @@ class AcmeClient {
|
|
|
536
517
|
return resp.data;
|
|
537
518
|
}
|
|
538
519
|
|
|
539
|
-
|
|
540
520
|
/**
|
|
541
521
|
* Wait for ACME provider to verify status on a order, authorization or challenge
|
|
542
522
|
*
|
|
@@ -593,7 +573,6 @@ class AcmeClient {
|
|
|
593
573
|
return util.retry(verifyFn, this.backoffOpts);
|
|
594
574
|
}
|
|
595
575
|
|
|
596
|
-
|
|
597
576
|
/**
|
|
598
577
|
* Get certificate from ACME order
|
|
599
578
|
*
|
|
@@ -640,7 +619,6 @@ class AcmeClient {
|
|
|
640
619
|
return resp.data;
|
|
641
620
|
}
|
|
642
621
|
|
|
643
|
-
|
|
644
622
|
/**
|
|
645
623
|
* Revoke certificate
|
|
646
624
|
*
|
|
@@ -660,7 +638,7 @@ class AcmeClient {
|
|
|
660
638
|
* ```js
|
|
661
639
|
* const certificate = { ... }; // Previously created certificate
|
|
662
640
|
* const result = await client.revokeCertificate(certificate, {
|
|
663
|
-
* reason: 4
|
|
641
|
+
* reason: 4,
|
|
664
642
|
* });
|
|
665
643
|
* ```
|
|
666
644
|
*/
|
|
@@ -671,7 +649,6 @@ class AcmeClient {
|
|
|
671
649
|
return resp.data;
|
|
672
650
|
}
|
|
673
651
|
|
|
674
|
-
|
|
675
652
|
/**
|
|
676
653
|
* Auto mode
|
|
677
654
|
*
|
|
@@ -689,7 +666,7 @@ class AcmeClient {
|
|
|
689
666
|
* @example Order a certificate using auto mode
|
|
690
667
|
* ```js
|
|
691
668
|
* const [certificateKey, certificateRequest] = await acme.crypto.createCsr({
|
|
692
|
-
*
|
|
669
|
+
* altNames: ['test.example.com'],
|
|
693
670
|
* });
|
|
694
671
|
*
|
|
695
672
|
* const certificate = await client.auto({
|
|
@@ -701,14 +678,14 @@ class AcmeClient {
|
|
|
701
678
|
* },
|
|
702
679
|
* challengeRemoveFn: async (authz, challenge, keyAuthorization) => {
|
|
703
680
|
* // Clean up challenge here
|
|
704
|
-
* }
|
|
681
|
+
* },
|
|
705
682
|
* });
|
|
706
683
|
* ```
|
|
707
684
|
*
|
|
708
685
|
* @example Order a certificate using auto mode with preferred chain
|
|
709
686
|
* ```js
|
|
710
687
|
* const [certificateKey, certificateRequest] = await acme.crypto.createCsr({
|
|
711
|
-
*
|
|
688
|
+
* altNames: ['test.example.com'],
|
|
712
689
|
* });
|
|
713
690
|
*
|
|
714
691
|
* const certificate = await client.auto({
|
|
@@ -717,7 +694,7 @@ class AcmeClient {
|
|
|
717
694
|
* termsOfServiceAgreed: true,
|
|
718
695
|
* preferredChain: 'DST Root CA X3',
|
|
719
696
|
* challengeCreateFn: async () => {},
|
|
720
|
-
* challengeRemoveFn: async () => {}
|
|
697
|
+
* challengeRemoveFn: async () => {},
|
|
721
698
|
* });
|
|
722
699
|
* ```
|
|
723
700
|
*/
|
|
@@ -727,6 +704,5 @@ class AcmeClient {
|
|
|
727
704
|
}
|
|
728
705
|
}
|
|
729
706
|
|
|
730
|
-
|
|
731
707
|
/* Export client */
|
|
732
708
|
module.exports = AcmeClient;
|