@mablhq/mabl-cli 2.79.7 → 2.79.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/http/axiosProxyConfig.js
CHANGED
|
@@ -37,8 +37,11 @@ function axiosProxyConfig(httpConfig) {
|
|
|
37
37
|
}
|
|
38
38
|
return maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
40
|
+
function removeIpv6Brackets(input) {
|
|
41
|
+
if (input.startsWith('[') && input.endsWith(']')) {
|
|
42
|
+
return input.slice(1, -1);
|
|
43
|
+
}
|
|
44
|
+
return input;
|
|
42
45
|
}
|
|
43
46
|
function proxyUrlToPortConfig(proxyUrl) {
|
|
44
47
|
const defaultPort = proxyUrl.protocol === 'https:' ? 443 : 80;
|
|
@@ -46,9 +49,7 @@ function proxyUrlToPortConfig(proxyUrl) {
|
|
|
46
49
|
const portNumber = maybePortNumberMatch
|
|
47
50
|
? parseInt(maybePortNumberMatch)
|
|
48
51
|
: defaultPort;
|
|
49
|
-
|
|
50
|
-
(proxyUrl.search ? proxyUrl.pathname + proxyUrl.search : proxyUrl.pathname);
|
|
51
|
-
hostname = hostname.replace(new RegExp(`${escapeRegexDots(proxyUrl.hostname)}/$`), proxyUrl.hostname);
|
|
52
|
+
const hostname = removeIpv6Brackets(proxyUrl.hostname);
|
|
52
53
|
const config = {
|
|
53
54
|
host: hostname,
|
|
54
55
|
port: portNumber,
|
|
@@ -70,18 +71,33 @@ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, _proxyType)
|
|
|
70
71
|
};
|
|
71
72
|
newConfig.proxy = false;
|
|
72
73
|
const authConfig = config.proxy.auth;
|
|
73
|
-
let proxyString = 'http
|
|
74
|
+
let proxyString = `${config.proxy?.protocol || 'http:'}//`;
|
|
74
75
|
if (authConfig) {
|
|
75
76
|
proxyString += `${authConfig.username}:${authConfig.password}@`;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
+
if (config.proxy.host.includes(':')) {
|
|
79
|
+
proxyString += `[${config.proxy.host}]`;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
proxyString += config.proxy.host;
|
|
83
|
+
}
|
|
84
|
+
proxyString += `:${config.proxy.port}`;
|
|
85
|
+
const parsedProxyUrl = new URL(proxyString);
|
|
86
|
+
const hostname = removeIpv6Brackets(parsedProxyUrl.hostname);
|
|
87
|
+
const proxyUrl = {
|
|
88
|
+
hostname,
|
|
89
|
+
port: parsedProxyUrl.port,
|
|
90
|
+
protocol: parsedProxyUrl.protocol,
|
|
91
|
+
username: parsedProxyUrl.username,
|
|
92
|
+
password: parsedProxyUrl.password,
|
|
93
|
+
};
|
|
78
94
|
const rejectUnauthorized = sslVerify === true;
|
|
79
95
|
const httpAgentConfig = {
|
|
80
96
|
keepAlive: true,
|
|
81
97
|
keepAliveMsecs: 1000,
|
|
82
98
|
maxSockets: 256,
|
|
83
99
|
maxFreeSockets: 256,
|
|
84
|
-
proxy:
|
|
100
|
+
proxy: proxyUrl,
|
|
85
101
|
proxyRequestOptions: {
|
|
86
102
|
rejectUnauthorized,
|
|
87
103
|
},
|
|
@@ -90,6 +106,14 @@ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, _proxyType)
|
|
|
90
106
|
...httpAgentConfig,
|
|
91
107
|
rejectUnauthorized,
|
|
92
108
|
};
|
|
109
|
+
console.log('Using proxy agent configuration', {
|
|
110
|
+
...httpsAgentConfig,
|
|
111
|
+
proxy: {
|
|
112
|
+
...proxyUrl,
|
|
113
|
+
username: proxyUrl.username ? '*****' : undefined,
|
|
114
|
+
password: proxyUrl.password ? '*****' : undefined,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
93
117
|
newConfig.httpsAgent = new hpagent_1.HttpsProxyAgent(httpsAgentConfig);
|
|
94
118
|
newConfig.httpAgent = new hpagent_1.HttpProxyAgent(httpAgentConfig);
|
|
95
119
|
return newConfig;
|