@certd/acme-client 1.38.7 → 1.38.9
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/client.js +4 -1
- package/src/http.js +3 -2
- package/src/index.js +26 -0
- package/src/util.js +8 -2
- package/types/index.d.ts +3 -0
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.38.
|
|
6
|
+
"version": "1.38.9",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "scr/index.js",
|
|
9
9
|
"main": "src/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"types"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@certd/basic": "^1.38.
|
|
21
|
+
"@certd/basic": "^1.38.9",
|
|
22
22
|
"@peculiar/x509": "^1.11.0",
|
|
23
23
|
"asn1js": "^3.0.5",
|
|
24
24
|
"axios": "^1.9.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"bugs": {
|
|
71
71
|
"url": "https://github.com/publishlab/node-acme-client/issues"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b30cb5d7dc8311af4863da7dc8781f7264ba0545"
|
|
74
74
|
}
|
package/src/client.js
CHANGED
|
@@ -601,7 +601,10 @@ class AcmeClient {
|
|
|
601
601
|
};
|
|
602
602
|
|
|
603
603
|
this.log(`[${d}] Waiting for valid status (等待valid状态): ${item.url}`, JSON.stringify(this.backoffOpts));
|
|
604
|
-
|
|
604
|
+
const log = (...args)=>{
|
|
605
|
+
this.logger.info(...args)
|
|
606
|
+
}
|
|
607
|
+
return util.retry(verifyFn, this.backoffOpts,log);
|
|
605
608
|
}
|
|
606
609
|
|
|
607
610
|
/**
|
package/src/http.js
CHANGED
|
@@ -74,8 +74,9 @@ class HttpClient {
|
|
|
74
74
|
if (this.urlMapping && this.urlMapping.enabled && this.urlMapping.mappings) {
|
|
75
75
|
// eslint-disable-next-line no-restricted-syntax
|
|
76
76
|
for (const key in this.urlMapping.mappings) {
|
|
77
|
+
const value = this.urlMapping.mappings[key];
|
|
77
78
|
if (url.includes(key)) {
|
|
78
|
-
const newUrl = url.replace(key,
|
|
79
|
+
const newUrl = url.replace(key, value);
|
|
79
80
|
this.log(`use reverse proxy: ${newUrl}`);
|
|
80
81
|
url = newUrl;
|
|
81
82
|
}
|
|
@@ -193,7 +194,7 @@ class HttpClient {
|
|
|
193
194
|
const dir = await this.getDirectory();
|
|
194
195
|
|
|
195
196
|
if (!dir[resource]) {
|
|
196
|
-
throw new Error(`Unable to locate API resource URL in ACME directory: "${resource}"
|
|
197
|
+
throw new Error(`Unable to locate API resource URL in ACME directory: "${resource}",获取ACME接口地址信息失败,可能网络不稳定或该证书颁发机构服务器崩溃,目录地址:${this.directoryUrl},请测试地址是否可以正常访问并显示json格式的URL地址列表`);
|
|
197
198
|
}
|
|
198
199
|
|
|
199
200
|
return dir[resource];
|
package/src/index.js
CHANGED
|
@@ -57,6 +57,32 @@ export function getDirectoryUrl(opts) {
|
|
|
57
57
|
return list.production
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
|
|
61
|
+
export function getAllSslProviderDomains() {
|
|
62
|
+
const list = Object.values(directory).map((item) => {
|
|
63
|
+
let url = item.production.replace('https://', '')
|
|
64
|
+
url = url.substring(0, url.indexOf('/'))
|
|
65
|
+
return url
|
|
66
|
+
})
|
|
67
|
+
return list
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let sslProviderReverseProxies = {}
|
|
71
|
+
|
|
72
|
+
function initSslProviderReverseProxies() {
|
|
73
|
+
for (const sslProvider of getAllSslProviderDomains()) {
|
|
74
|
+
sslProviderReverseProxies[sslProvider] = ""
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
initSslProviderReverseProxies()
|
|
78
|
+
|
|
79
|
+
export function getSslProviderReverseProxies() {
|
|
80
|
+
return sslProviderReverseProxies
|
|
81
|
+
}
|
|
82
|
+
export function setSslProviderReverseProxies(reverseProxies) {
|
|
83
|
+
Object.assign(sslProviderReverseProxies, reverseProxies)
|
|
84
|
+
}
|
|
85
|
+
|
|
60
86
|
/**
|
|
61
87
|
* Crypto
|
|
62
88
|
*/
|
package/src/util.js
CHANGED
|
@@ -52,11 +52,17 @@ async function retryPromise(fn, attempts, backoff, logger = log) {
|
|
|
52
52
|
let aborted = false;
|
|
53
53
|
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
55
|
+
const setAbort = () => { aborted = true; }
|
|
56
|
+
const data = await fn(setAbort);
|
|
56
57
|
return data;
|
|
57
58
|
}
|
|
58
59
|
catch (e) {
|
|
59
|
-
if (aborted
|
|
60
|
+
if (aborted){
|
|
61
|
+
logger(`用户取消重试`);
|
|
62
|
+
throw e;
|
|
63
|
+
}
|
|
64
|
+
if ( ((backoff.attempts + 1) >= attempts)) {
|
|
65
|
+
logger(`重试次数超过${attempts}次`);
|
|
60
66
|
throw e;
|
|
61
67
|
}
|
|
62
68
|
|
package/types/index.d.ts
CHANGED
|
@@ -118,6 +118,9 @@ export const directory: {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
export function getDirectoryUrl(opts:{sslProvider:string, pkType: string}): string;
|
|
121
|
+
export function getAllSslProviderDomains(): string[];
|
|
122
|
+
export function getSslProviderReverseProxies(): Record<string, string>;
|
|
123
|
+
export function setSslProviderReverseProxies(reverseProxies: Record<string, string>): void;
|
|
121
124
|
|
|
122
125
|
/**
|
|
123
126
|
* Crypto
|