@mablhq/mabl-cli 1.26.0 → 1.26.5

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/util/httpUtil.js CHANGED
@@ -28,6 +28,7 @@ const cliConfigProvider_1 = require("../providers/cliConfigProvider");
28
28
  const https = __importStar(require("https"));
29
29
  const pureUtil_1 = require("./pureUtil");
30
30
  const https_proxy_agent_1 = require("https-proxy-agent");
31
+ const hpagent_1 = require("hpagent");
31
32
  exports.USER_AGENT = `${(0, pureUtil_1.getCliName)()}@${(0, pureUtil_1.getCliVersion)()}`;
32
33
  exports.USER_AGENT_HEADER = 'User-Agent';
33
34
  exports.EXECUTION_ENGINE_SSL_VERIFY = false;
@@ -51,7 +52,7 @@ function axiosProxyConfig(httpConfig) {
51
52
  if ((_a = httpConfig.proxyHost) === null || _a === void 0 ? void 0 : _a.href) {
52
53
  config.proxy = proxyUrlToPortConfig(httpConfig.proxyHost);
53
54
  }
54
- return maybeGetModifiedAxiosConfigForHttpProxy(config, httpConfig.sslVerify);
55
+ return maybeGetModifiedAxiosConfigForHttpProxy(config, httpConfig.sslVerify, httpConfig.proxyType);
55
56
  }
56
57
  exports.axiosProxyConfig = axiosProxyConfig;
57
58
  function escapeRegexDots(input) {
@@ -80,7 +81,7 @@ function proxyUrlToPortConfig(proxyUrl) {
80
81
  return config;
81
82
  }
82
83
  exports.proxyUrlToPortConfig = proxyUrlToPortConfig;
83
- function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify) {
84
+ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType) {
84
85
  var _a, _b;
85
86
  if (config.proxy &&
86
87
  (((_a = config.proxy) === null || _a === void 0 ? void 0 : _a.protocol) === 'http:' || ((_b = config.proxy) === null || _b === void 0 ? void 0 : _b.protocol) === 'http')) {
@@ -89,16 +90,35 @@ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify) {
89
90
  };
90
91
  newConfig.proxy = false;
91
92
  const authConfig = config.proxy.auth;
92
- const configOptions = {
93
- host: config.proxy.host,
94
- port: config.proxy.port,
95
- auth: authConfig
96
- ? `${authConfig.username}:${authConfig.password}`
97
- : undefined,
98
- rejectUnauthorized: sslVerify !== false,
99
- };
100
- newConfig.httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
101
- newConfig.httpAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
93
+ if (proxyType === 'current') {
94
+ let proxyString = 'http://';
95
+ if (authConfig !== undefined) {
96
+ proxyString += `${authConfig.username}:${authConfig.password}@`;
97
+ }
98
+ proxyString += `${config.proxy.host}:${config.proxy.port}`;
99
+ const agentConfig = {
100
+ keepAlive: true,
101
+ keepAliveMsecs: 1000,
102
+ maxSockets: 256,
103
+ maxFreeSockets: 256,
104
+ proxy: proxyString,
105
+ rejectUnauthorized: sslVerify !== false,
106
+ };
107
+ newConfig.httpsAgent = new hpagent_1.HttpsProxyAgent(agentConfig);
108
+ newConfig.httpAgent = new hpagent_1.HttpsProxyAgent(agentConfig);
109
+ }
110
+ else {
111
+ const configOptions = {
112
+ host: config.proxy.host,
113
+ port: config.proxy.port,
114
+ auth: authConfig
115
+ ? `${authConfig.username}:${authConfig.password}`
116
+ : undefined,
117
+ rejectUnauthorized: sslVerify !== false,
118
+ };
119
+ newConfig.httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
120
+ newConfig.httpAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
121
+ }
102
122
  return newConfig;
103
123
  }
104
124
  return config;