@certd/acme-client 1.25.9 → 1.26.1
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/package.json +3 -3
- package/src/auto.js +3 -3
- package/src/index.js +2 -0
- package/src/verify.js +24 -19
- package/types/index.d.ts +4 -2
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.26.1",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"types": "types/index.d.ts",
|
|
9
9
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"asn1js": "^3.0.5",
|
|
21
21
|
"axios": "^1.7.2",
|
|
22
22
|
"debug": "^4.3.5",
|
|
23
|
-
"https-proxy-agent": "^7.0.
|
|
23
|
+
"https-proxy-agent": "^7.0.5",
|
|
24
24
|
"node-forge": "^1.3.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"bugs": {
|
|
60
60
|
"url": "https://github.com/publishlab/node-acme-client/issues"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "daf575e7c3b808e6b7db48e50c62ebd9fa213b0a"
|
|
63
63
|
}
|
package/src/auto.js
CHANGED
|
@@ -118,16 +118,16 @@ module.exports = async (client, userOpts) => {
|
|
|
118
118
|
/* Trigger challengeCreateFn() */
|
|
119
119
|
log(`[auto] [${d}] Trigger challengeCreateFn()`);
|
|
120
120
|
const keyAuthorization = await client.getChallengeKeyAuthorization(challenge);
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
try {
|
|
123
|
-
|
|
123
|
+
const { recordReq, recordRes, dnsProvider } = await opts.challengeCreateFn(authz, challenge, keyAuthorization);
|
|
124
124
|
log(`[auto] [${d}] challengeCreateFn success`);
|
|
125
125
|
log(`[auto] [${d}] add challengeRemoveFn()`);
|
|
126
126
|
clearTasks.push(async () => {
|
|
127
127
|
/* Trigger challengeRemoveFn(), suppress errors */
|
|
128
128
|
log(`[auto] [${d}] Trigger challengeRemoveFn()`);
|
|
129
129
|
try {
|
|
130
|
-
await opts.challengeRemoveFn(authz, challenge, keyAuthorization,
|
|
130
|
+
await opts.challengeRemoveFn(authz, challenge, keyAuthorization, recordReq, recordRes, dnsProvider);
|
|
131
131
|
}
|
|
132
132
|
catch (e) {
|
|
133
133
|
log(`[auto] [${d}] challengeRemoveFn threw error: ${e.message}`);
|
package/src/index.js
CHANGED
package/src/verify.js
CHANGED
|
@@ -66,17 +66,35 @@ async function walkDnsChallengeRecord(recordName, resolver = dns) {
|
|
|
66
66
|
log(`Checking name for TXT records: ${recordName}`);
|
|
67
67
|
const txtRecords = await resolver.resolveTxt(recordName);
|
|
68
68
|
|
|
69
|
-
if (txtRecords.length) {
|
|
69
|
+
if (txtRecords && txtRecords.length) {
|
|
70
70
|
log(`Found ${txtRecords.length} TXT records at ${recordName}`);
|
|
71
|
+
log(`TXT records: ${JSON.stringify(txtRecords)}`);
|
|
71
72
|
return [].concat(...txtRecords);
|
|
72
73
|
}
|
|
74
|
+
return [];
|
|
73
75
|
}
|
|
74
76
|
catch (e) {
|
|
75
|
-
log(`
|
|
77
|
+
log(`Resolve TXT records error, ${recordName} :${e.message}`);
|
|
78
|
+
throw e;
|
|
76
79
|
}
|
|
80
|
+
}
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
async function walkTxtRecord(recordName) {
|
|
83
|
+
try {
|
|
84
|
+
/* Default DNS resolver first */
|
|
85
|
+
log('Attempting to resolve TXT with default DNS resolver first');
|
|
86
|
+
const res = await walkDnsChallengeRecord(recordName);
|
|
87
|
+
if (res && res.length > 0) {
|
|
88
|
+
return res;
|
|
89
|
+
}
|
|
90
|
+
throw new Error('No TXT records found');
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
/* Authoritative DNS resolver */
|
|
94
|
+
log(`Error using default resolver, attempting to resolve TXT with authoritative NS: ${e.message}`);
|
|
95
|
+
const authoritativeResolver = await util.getAuthoritativeDnsResolver(recordName);
|
|
96
|
+
return await walkDnsChallengeRecord(recordName, authoritativeResolver);
|
|
97
|
+
}
|
|
80
98
|
}
|
|
81
99
|
|
|
82
100
|
/**
|
|
@@ -92,24 +110,10 @@ async function walkDnsChallengeRecord(recordName, resolver = dns) {
|
|
|
92
110
|
*/
|
|
93
111
|
|
|
94
112
|
async function verifyDnsChallenge(authz, challenge, keyAuthorization, prefix = '_acme-challenge.') {
|
|
95
|
-
let recordValues = [];
|
|
96
113
|
const recordName = `${prefix}${authz.identifier.value}`;
|
|
97
114
|
log(`Resolving DNS TXT from record: ${recordName}`);
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
/* Default DNS resolver first */
|
|
101
|
-
log('Attempting to resolve TXT with default DNS resolver first');
|
|
102
|
-
recordValues = await walkDnsChallengeRecord(recordName);
|
|
103
|
-
}
|
|
104
|
-
catch (e) {
|
|
105
|
-
/* Authoritative DNS resolver */
|
|
106
|
-
log(`Error using default resolver, attempting to resolve TXT with authoritative NS: ${e.message}`);
|
|
107
|
-
const authoritativeResolver = await util.getAuthoritativeDnsResolver(recordName);
|
|
108
|
-
recordValues = await walkDnsChallengeRecord(recordName, authoritativeResolver);
|
|
109
|
-
}
|
|
110
|
-
|
|
115
|
+
const recordValues = await walkTxtRecord(recordName);
|
|
111
116
|
log(`DNS query finished successfully, found ${recordValues.length} TXT records`);
|
|
112
|
-
|
|
113
117
|
if (!recordValues.length || !recordValues.includes(keyAuthorization)) {
|
|
114
118
|
throw new Error(`Authorization not found in DNS TXT record: ${recordName},need:${keyAuthorization},found:${recordValues}`);
|
|
115
119
|
}
|
|
@@ -153,4 +157,5 @@ module.exports = {
|
|
|
153
157
|
'http-01': verifyHttpChallenge,
|
|
154
158
|
'dns-01': verifyDnsChallenge,
|
|
155
159
|
'tls-alpn-01': verifyTlsAlpnChallenge,
|
|
160
|
+
walkTxtRecord,
|
|
156
161
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -55,8 +55,8 @@ export interface ClientExternalAccountBindingOptions {
|
|
|
55
55
|
|
|
56
56
|
export interface ClientAutoOptions {
|
|
57
57
|
csr: CsrBuffer | CsrString;
|
|
58
|
-
challengeCreateFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string) => Promise<any>;
|
|
59
|
-
challengeRemoveFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string, recordRes:any) => Promise<any>;
|
|
58
|
+
challengeCreateFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string) => Promise<{recordReq:any,recordRes:any,dnsProvider:any}>;
|
|
59
|
+
challengeRemoveFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string,recordReq:any, recordRes:any,dnsProvider:any) => Promise<any>;
|
|
60
60
|
email?: string;
|
|
61
61
|
termsOfServiceAgreed?: boolean;
|
|
62
62
|
skipChallengeVerification?: boolean;
|
|
@@ -197,3 +197,5 @@ export const axios: AxiosInstance;
|
|
|
197
197
|
*/
|
|
198
198
|
|
|
199
199
|
export function setLogger(fn: (msg: string) => void): void;
|
|
200
|
+
|
|
201
|
+
export function walkTxtRecord(record: any): Promise<string[]>;
|