@certd/acme-client 1.22.3 → 1.22.6

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Simple and unopinionated ACME client",
4
4
  "private": false,
5
5
  "author": "nmorsman",
6
- "version": "1.22.3",
6
+ "version": "1.22.6",
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": "aa936c279e2c83727ee444ada25ee7b14b847801"
62
+ "gitHead": "3bbbc41062efb116c0af0bcfc41f9933ce918202"
63
63
  }
package/src/client.js CHANGED
@@ -100,7 +100,7 @@ class AcmeClient {
100
100
  max: this.opts.backoffMax,
101
101
  };
102
102
 
103
- this.http = new HttpClient(this.opts.directoryUrl, this.opts.accountKey, this.opts.externalAccountBinding);
103
+ this.http = new HttpClient(this.opts.directoryUrl, this.opts.accountKey, this.opts.externalAccountBinding, this.opts.urlMapping);
104
104
  this.api = new AcmeApi(this.http, this.opts.accountUrl);
105
105
  }
106
106
 
package/src/http.js CHANGED
@@ -12,10 +12,11 @@ const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
12
12
  let httpsAgent = null;
13
13
  if (httpsProxy) {
14
14
  httpsAgent = new HttpsProxyAgent(httpsProxy);
15
+ log(`use https_proxy:${httpsProxy}`);
15
16
  }
16
17
  const axios = axios1.create({
17
18
  proxy: false,
18
- httpsAgent
19
+ httpsAgent,
19
20
  });
20
21
 
21
22
  /**
@@ -30,7 +31,7 @@ const axios = axios1.create({
30
31
  */
31
32
 
32
33
  class HttpClient {
33
- constructor(directoryUrl, accountKey, externalAccountBinding = {}) {
34
+ constructor(directoryUrl, accountKey, externalAccountBinding = {}, urlMapping = {}) {
34
35
  this.directoryUrl = directoryUrl;
35
36
  this.accountKey = accountKey;
36
37
  this.externalAccountBinding = externalAccountBinding;
@@ -41,6 +42,7 @@ class HttpClient {
41
42
  this.directoryCache = null;
42
43
  this.directoryMaxAge = 86400;
43
44
  this.directoryTimestamp = 0;
45
+ this.urlMapping = urlMapping;
44
46
  }
45
47
 
46
48
  /**
@@ -53,6 +55,16 @@ class HttpClient {
53
55
  */
54
56
 
55
57
  async request(url, method, opts = {}) {
58
+ if (this.urlMapping && this.urlMapping.enabled === true && this.urlMapping.mappings) {
59
+ // eslint-disable-next-line no-restricted-syntax
60
+ for (const key in this.urlMapping.mappings) {
61
+ if (url.includes(key)) {
62
+ const newUrl = url.replace(key, this.urlMapping.mappings[key]);
63
+ log(`use reverse proxy: ${newUrl}`);
64
+ url = newUrl;
65
+ }
66
+ }
67
+ }
56
68
  opts.url = url;
57
69
  opts.method = method;
58
70
  opts.validateStatus = null;
package/types/index.d.ts CHANGED
@@ -27,6 +27,11 @@ export interface Authorization extends rfc8555.Authorization {
27
27
  url: string;
28
28
  }
29
29
 
30
+ export type UrlMapping={
31
+ enabled: boolean
32
+ mappings: Record<string, string>
33
+ }
34
+
30
35
  /**
31
36
  * Client
32
37
  */
@@ -39,6 +44,7 @@ export interface ClientOptions {
39
44
  backoffAttempts?: number;
40
45
  backoffMin?: number;
41
46
  backoffMax?: number;
47
+ urlMapping?: UrlMapping;
42
48
  }
43
49
 
44
50
  export interface ClientExternalAccountBindingOptions {