@abtnode/util 1.8.27 → 1.8.28

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.
Files changed (2) hide show
  1. package/lib/axios.js +33 -3
  2. package/package.json +13 -12
package/lib/axios.js CHANGED
@@ -1,5 +1,35 @@
1
- // set proxy to false to fix bug with HTTPS_PROXY environment
2
- // https://github.com/axios/axios/issues/3384
3
- const { default: axios } = require('axios');
1
+ const axios = require('axios').default;
2
+ const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent');
3
+
4
+ function proxyInterceptor(config) {
5
+ /* istanbul ignore if */
6
+ if (config.socketPath != null) return config;
7
+
8
+ const { proxy } = config;
9
+
10
+ /* istanbul ignore if */
11
+ if (proxy === false) return config;
12
+
13
+ const httpProxyUrl = process.env.HTTP_PROXY || process.env.http_proxy;
14
+ const httpsProxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy;
15
+
16
+ const proxyOptions = Object.assign(
17
+ { keepAlive: true, keepAliveMsecs: 1000, maxSockets: 256, maxFreeSockets: 256 },
18
+ config.proxyOptions || {}
19
+ );
20
+
21
+ if (httpProxyUrl) {
22
+ config.proxy = false;
23
+ config.httpAgent = new HttpProxyAgent({ proxy: httpProxyUrl, ...proxyOptions });
24
+ }
25
+ if (httpsProxyUrl) {
26
+ config.proxy = false;
27
+ config.httpsAgent = new HttpsProxyAgent({ proxy: httpsProxyUrl, ...proxyOptions });
28
+ }
29
+
30
+ return config;
31
+ }
32
+
33
+ axios.interceptors.request.use(proxyInterceptor);
4
34
 
5
35
  module.exports = axios;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.27",
6
+ "version": "1.8.28",
7
7
  "description": "ArcBlock's JavaScript utility",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,13 +18,13 @@
18
18
  "author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@abtnode/constant": "1.8.27",
22
- "@abtnode/logger": "1.8.27",
23
- "@arcblock/jwt": "^1.17.20",
24
- "@blocklet/constant": "1.8.27",
25
- "@ocap/mcrypto": "1.17.20",
26
- "@ocap/util": "1.17.20",
27
- "@ocap/wallet": "1.17.20",
21
+ "@abtnode/constant": "1.8.28",
22
+ "@abtnode/logger": "1.8.28",
23
+ "@arcblock/jwt": "^1.17.23",
24
+ "@blocklet/constant": "1.8.28",
25
+ "@ocap/mcrypto": "1.17.23",
26
+ "@ocap/util": "1.17.23",
27
+ "@ocap/wallet": "1.17.23",
28
28
  "axios": "^0.27.2",
29
29
  "axios-mock-adapter": "^1.21.2",
30
30
  "axon": "^2.0.3",
@@ -35,6 +35,7 @@
35
35
  "folder-walker": "^3.2.0",
36
36
  "form-data": "^4.0.0",
37
37
  "hasha": "^5.2.2",
38
+ "hpagent": "^1.1.0",
38
39
  "internal-ip": "^6.2.0",
39
40
  "is-docker": "^2.2.1",
40
41
  "json-stable-stringify": "^1.0.1",
@@ -44,7 +45,7 @@
44
45
  "public-ip": "^4.0.4",
45
46
  "pump": "^3.0.0",
46
47
  "read-last-lines": "^1.8.0",
47
- "semver": "^7.3.7",
48
+ "semver": "^7.3.8",
48
49
  "semver-sort": "^1.0.0",
49
50
  "shelljs": "^0.8.5",
50
51
  "stream-to-promise": "^3.0.0",
@@ -56,10 +57,10 @@
56
57
  "which": "^2.0.2"
57
58
  },
58
59
  "devDependencies": {
59
- "detect-port": "^1.3.0",
60
- "express": "^4.18.1",
60
+ "detect-port": "^1.5.1",
61
+ "express": "^4.18.2",
61
62
  "fs-extra": "^10.1.0",
62
63
  "jest": "^27.5.1"
63
64
  },
64
- "gitHead": "84b2cb3ee703479f17e88c91650ecf3015cbf6af"
65
+ "gitHead": "af7aacf5507177600ae563ab597cb42d7223b113"
65
66
  }