@mablhq/mabl-cli 1.41.4 → 1.42.7

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.
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.MablHttpAgent = void 0;
30
+ const http_1 = __importDefault(require("http"));
31
+ const agent_base_1 = require("agent-base");
32
+ const axiosProxyConfig_1 = require("./axiosProxyConfig");
33
+ const https = __importStar(require("https"));
34
+ const httpUtil_1 = require("./httpUtil");
35
+ class MablHttpAgent extends agent_base_1.Agent {
36
+ constructor(httpAgent, httpsAgent) {
37
+ super();
38
+ this.httpAgent = httpAgent;
39
+ this.httpsAgent = httpsAgent;
40
+ }
41
+ static async createNewInstance(config) {
42
+ const constructorParameters = await MablHttpAgent.getConstructorParameters(config.httpAgent, config.httpsAgent);
43
+ if (config.proxyConfig) {
44
+ const axiosConfig = (0, axiosProxyConfig_1.axiosProxyConfig)(config.proxyConfig);
45
+ constructorParameters.httpAgent = axiosConfig.httpAgent;
46
+ constructorParameters.httpsAgent = axiosConfig.httpsAgent;
47
+ }
48
+ return new MablHttpAgent(constructorParameters.httpAgent, constructorParameters.httpsAgent);
49
+ }
50
+ static async getConstructorParameters(httpAgent, httpsAgent) {
51
+ var _a, _b;
52
+ const proxyConfig = await (0, axiosProxyConfig_1.currentProxyConfig)('test');
53
+ return {
54
+ httpAgent: (_a = httpAgent !== null && httpAgent !== void 0 ? httpAgent : proxyConfig.httpAgent) !== null && _a !== void 0 ? _a : http_1.default.globalAgent,
55
+ httpsAgent: (_b = httpsAgent !== null && httpsAgent !== void 0 ? httpsAgent : proxyConfig.httpsAgent) !== null && _b !== void 0 ? _b : https.globalAgent,
56
+ };
57
+ }
58
+ callback(req, opts) {
59
+ var _a;
60
+ if ((_a = this.maybeGetFirstStringHeader(req, httpUtil_1.USER_AGENT_HEADER)) === null || _a === void 0 ? void 0 : _a.startsWith('PostmanRuntime/')) {
61
+ req.setHeader(httpUtil_1.USER_AGENT_HEADER, httpUtil_1.USER_AGENT);
62
+ }
63
+ return Promise.resolve(opts.secureEndpoint ? this.httpsAgent : this.httpAgent);
64
+ }
65
+ maybeGetFirstStringHeader(req, name) {
66
+ const value = req.getHeader(name);
67
+ if (Array.isArray(value)) {
68
+ return value[0].toString();
69
+ }
70
+ return value === null || value === void 0 ? void 0 : value.toString();
71
+ }
72
+ }
73
+ exports.MablHttpAgent = MablHttpAgent;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isPrivateAddress = exports.isForbiddenHeader = exports.isForbiddenHost = exports.RequestFilteringHttpAgent = void 0;
27
+ const rangeCheck = __importStar(require("range_check"));
28
+ const RequestSecurityError_1 = require("./RequestSecurityError");
29
+ const MablHttpAgent_1 = require("./MablHttpAgent");
30
+ const FORBIDDEN_HOSTS = new Set(['metadata.google.internal']);
31
+ const FORBIDDEN_IP_RANGES = ['169.254.169.254/32'];
32
+ const FORBIDDEN_HEADERS = {
33
+ 'metadata-flavor': 'google',
34
+ 'x-google-metadata-request': undefined,
35
+ };
36
+ const FORBIDDEN_HEADER_NAMES = Object.keys(FORBIDDEN_HEADERS);
37
+ const RFC_1918_RANGES = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'];
38
+ const LOCAL_ADDRESSES = new Set(['127.0.0.1', '::1']);
39
+ const LOCAL_HOSTS = new Set(['localhost']);
40
+ class RequestFilteringHttpAgent extends MablHttpAgent_1.MablHttpAgent {
41
+ constructor(httpAgent, httpsAgent) {
42
+ super(httpAgent, httpsAgent);
43
+ }
44
+ static async createNewInstance() {
45
+ const constructorParameters = await MablHttpAgent_1.MablHttpAgent.getConstructorParameters();
46
+ return new RequestFilteringHttpAgent(constructorParameters.httpAgent, constructorParameters.httpsAgent);
47
+ }
48
+ callback(req, opts) {
49
+ if (isForbiddenHost(opts.host)) {
50
+ return Promise.reject(new RequestSecurityError_1.RequestSecurityError('Request contains forbidden host'));
51
+ }
52
+ else if (containsForbiddenHeader(opts.headers)) {
53
+ return Promise.reject(new RequestSecurityError_1.RequestSecurityError('Request contains forbidden header'));
54
+ }
55
+ else if (isPrivateAddress(opts.host)) {
56
+ return Promise.reject(new RequestSecurityError_1.RequestSecurityError('Request contains private address'));
57
+ }
58
+ return super.callback(req, opts);
59
+ }
60
+ }
61
+ exports.RequestFilteringHttpAgent = RequestFilteringHttpAgent;
62
+ function isForbiddenHost(host) {
63
+ if (!host) {
64
+ return false;
65
+ }
66
+ if (rangeCheck.isIP(host)) {
67
+ return rangeCheck.inRange(host, FORBIDDEN_IP_RANGES);
68
+ }
69
+ const normalizedHost = host.toLowerCase();
70
+ return FORBIDDEN_HOSTS.has(normalizedHost);
71
+ }
72
+ exports.isForbiddenHost = isForbiddenHost;
73
+ function containsForbiddenHeader(headers) {
74
+ if (!headers) {
75
+ return false;
76
+ }
77
+ return Object.keys(headers).some((header) => isForbiddenHeader(header, headers[header]));
78
+ }
79
+ function isForbiddenHeader(headerName, headerValue) {
80
+ const normalizedHeaderName = headerName.toLowerCase().trim();
81
+ if (!FORBIDDEN_HEADER_NAMES.includes(normalizedHeaderName)) {
82
+ return false;
83
+ }
84
+ const forbiddenHeaderValue = FORBIDDEN_HEADERS[normalizedHeaderName];
85
+ if (!forbiddenHeaderValue) {
86
+ return true;
87
+ }
88
+ if (!headerValue) {
89
+ return false;
90
+ }
91
+ const headerValueType = typeof headerValue;
92
+ if (headerValueType === 'string') {
93
+ const normalizedHeaderValue = headerValue.toLowerCase().trim();
94
+ return normalizedHeaderValue == forbiddenHeaderValue;
95
+ }
96
+ else if (headerValueType === 'number') {
97
+ return headerValue == forbiddenHeaderValue;
98
+ }
99
+ else if (Array.isArray(headerValue)) {
100
+ return headerValue.some((value) => isForbiddenHeader(headerName, value));
101
+ }
102
+ return false;
103
+ }
104
+ exports.isForbiddenHeader = isForbiddenHeader;
105
+ function isPrivateAddress(host) {
106
+ if (!host) {
107
+ return false;
108
+ }
109
+ if (rangeCheck.isIP(host)) {
110
+ if (rangeCheck.inRange(host, RFC_1918_RANGES)) {
111
+ return true;
112
+ }
113
+ const normalizedIP = rangeCheck.searchIP(host);
114
+ return LOCAL_ADDRESSES.has(normalizedIP);
115
+ }
116
+ const normalizedHostname = host.toLowerCase();
117
+ return LOCAL_HOSTS.has(normalizedHostname);
118
+ }
119
+ exports.isPrivateAddress = isPrivateAddress;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestSecurityError = void 0;
4
+ class RequestSecurityError extends Error {
5
+ constructor(m) {
6
+ super(m);
7
+ }
8
+ }
9
+ exports.RequestSecurityError = RequestSecurityError;
@@ -23,15 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.maybeGetModifiedAxiosConfigForHttpProxy = exports.proxyUrlToPortConfig = exports.axiosProxyConfig = exports.currentProxyConfig = exports.EXECUTION_ENGINE_SSL_VERIFY = exports.USER_AGENT_HEADER = exports.USER_AGENT = void 0;
26
+ exports.maybeGetModifiedAxiosConfigForHttpProxy = exports.proxyUrlToPortConfig = exports.axiosProxyConfig = exports.currentProxyConfig = void 0;
27
27
  const cliConfigProvider_1 = require("../providers/cliConfigProvider");
28
28
  const https = __importStar(require("https"));
29
- const pureUtil_1 = require("./pureUtil");
30
29
  const https_proxy_agent_1 = require("https-proxy-agent");
31
30
  const hpagent_1 = require("hpagent");
32
- exports.USER_AGENT = `${(0, pureUtil_1.getCliName)()}@${(0, pureUtil_1.getCliVersion)()}`;
33
- exports.USER_AGENT_HEADER = 'User-Agent';
34
- exports.EXECUTION_ENGINE_SSL_VERIFY = false;
31
+ const httpUtil_1 = require("./httpUtil");
35
32
  async function currentProxyConfig(mode = 'mabl') {
36
33
  const httpConfig = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http;
37
34
  return axiosProxyConfig(mode === 'test' ? httpConfig === null || httpConfig === void 0 ? void 0 : httpConfig.test : httpConfig === null || httpConfig === void 0 ? void 0 : httpConfig.mabl);
@@ -41,7 +38,7 @@ function axiosProxyConfig(httpConfig) {
41
38
  var _a;
42
39
  const config = {
43
40
  headers: {
44
- [exports.USER_AGENT_HEADER]: exports.USER_AGENT,
41
+ [httpUtil_1.USER_AGENT_HEADER]: httpUtil_1.USER_AGENT,
45
42
  },
46
43
  };
47
44
  if (!httpConfig.sslVerify) {
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.postProcessHeaders = exports.getHttpAgent = exports.GENERAL_API_STEP_EXECUTION_ERROR_CODE = exports.EXECUTION_ENGINE_SSL_VERIFY = exports.USER_AGENT_HEADER = exports.USER_AGENT = void 0;
4
+ const socks_proxy_agent_1 = require("socks-proxy-agent");
5
+ const pureUtil_1 = require("../util/pureUtil");
6
+ const MablHttpAgent_1 = require("./MablHttpAgent");
7
+ const RequestFilteringHttpAgent_1 = require("./RequestFilteringHttpAgent");
8
+ exports.USER_AGENT = `${(0, pureUtil_1.getCliName)()}@${(0, pureUtil_1.getCliVersion)()}`;
9
+ exports.USER_AGENT_HEADER = 'User-Agent';
10
+ exports.EXECUTION_ENGINE_SSL_VERIFY = false;
11
+ exports.GENERAL_API_STEP_EXECUTION_ERROR_CODE = '-1';
12
+ function getHttpAgent(shouldFilterHttpRequests, linkServer, proxyConfig) {
13
+ const linkAgent = maybeGetSocksAgent(linkServer);
14
+ if (linkAgent) {
15
+ return MablHttpAgent_1.MablHttpAgent.createNewInstance({
16
+ httpAgent: linkAgent,
17
+ httpsAgent: linkAgent,
18
+ });
19
+ }
20
+ else if (shouldFilterHttpRequests) {
21
+ return RequestFilteringHttpAgent_1.RequestFilteringHttpAgent.createNewInstance();
22
+ }
23
+ return MablHttpAgent_1.MablHttpAgent.createNewInstance({ proxyConfig });
24
+ }
25
+ exports.getHttpAgent = getHttpAgent;
26
+ function maybeGetSocksAgent(linkServer) {
27
+ if (!linkServer) {
28
+ return;
29
+ }
30
+ const agentOptions = {
31
+ host: linkServer.forwarding_host,
32
+ port: linkServer.forwarding_port,
33
+ userId: linkServer.workspace_id,
34
+ password: linkServer.label,
35
+ tls: {
36
+ rejectUnauthorized: false,
37
+ },
38
+ };
39
+ return new socks_proxy_agent_1.SocksProxyAgent(agentOptions);
40
+ }
41
+ function postProcessHeaders(response) {
42
+ var _a, _b, _c;
43
+ const parsed = {};
44
+ const rawHeaders = (_b = (_a = response.request) === null || _a === void 0 ? void 0 : _a.res) === null || _b === void 0 ? void 0 : _b.rawHeaders;
45
+ if (rawHeaders) {
46
+ for (let i = 0; i + 1 < rawHeaders.length; i += 2) {
47
+ const headerName = rawHeaders[i].toLowerCase();
48
+ const headerValue = rawHeaders[i + 1];
49
+ parsed[headerName] = ((_c = parsed[headerName]) !== null && _c !== void 0 ? _c : []).concat(headerValue);
50
+ }
51
+ }
52
+ return parsed;
53
+ }
54
+ exports.postProcessHeaders = postProcessHeaders;
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RequestInterceptor = exports.headerStringToProtocol = exports.headerStringToHeaders = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const loggingProvider_1 = require("../providers/logging/loggingProvider");
9
+ const uuid_1 = require("uuid");
10
+ const httpUtil_1 = require("./httpUtil");
11
+ const MAX_SERIALIZED_BODY_SIZE_BYTES = 1024 * 1024;
12
+ const HEADER_EXTRACT_REGEXP = /^(?<rawKey>[^:]+)(:)(?<value>.*)$/;
13
+ function headerStringToHeaders(rawHeader) {
14
+ const headers = {};
15
+ if (!rawHeader) {
16
+ return headers;
17
+ }
18
+ rawHeader
19
+ .split(/\r?\n/)
20
+ .filter((value) => value !== '')
21
+ .filter((value) => HEADER_EXTRACT_REGEXP.test(value))
22
+ .map((value) => value.match(HEADER_EXTRACT_REGEXP).groups)
23
+ .forEach(({ rawKey, value }) => {
24
+ var _a;
25
+ const normalizedHeader = rawKey.toLowerCase().trim();
26
+ const values = (_a = headers[normalizedHeader]) !== null && _a !== void 0 ? _a : [];
27
+ if (value === null || value === void 0 ? void 0 : value.trim()) {
28
+ values.push(value.trim());
29
+ }
30
+ headers[normalizedHeader] = values;
31
+ });
32
+ return headers;
33
+ }
34
+ exports.headerStringToHeaders = headerStringToHeaders;
35
+ function headerStringToProtocol(rawHeader) {
36
+ var _a, _b, _c;
37
+ if (!rawHeader) {
38
+ return;
39
+ }
40
+ const firstRowTrimmed = (_b = (_a = rawHeader.split(/\r?\n/, 2)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.trim();
41
+ return (_c = firstRowTrimmed === null || firstRowTrimmed === void 0 ? void 0 : firstRowTrimmed.match(/\s(\S+)$/)) === null || _c === void 0 ? void 0 : _c[1];
42
+ }
43
+ exports.headerStringToProtocol = headerStringToProtocol;
44
+ function headerRecordToHeaderMultiMap(input) {
45
+ const result = {};
46
+ Object.entries(input).forEach(([key, value]) => {
47
+ result[key] = [value];
48
+ });
49
+ return result;
50
+ }
51
+ function handleRawResponseBody(body) {
52
+ body = body !== null && body !== void 0 ? body : '';
53
+ switch (typeof body) {
54
+ case 'number':
55
+ case 'boolean':
56
+ return body.toString();
57
+ case 'string':
58
+ return body.substring(0, MAX_SERIALIZED_BODY_SIZE_BYTES);
59
+ case 'object':
60
+ const serializedBody = JSON.stringify(body);
61
+ if (serializedBody.length <= MAX_SERIALIZED_BODY_SIZE_BYTES) {
62
+ return body;
63
+ }
64
+ return serializedBody.substring(0, MAX_SERIALIZED_BODY_SIZE_BYTES);
65
+ default:
66
+ throw new Error(`Unhandled request intercept body type: [${typeof body}]`);
67
+ }
68
+ }
69
+ class RequestInterceptor {
70
+ constructor() {
71
+ this.interceptedRequests = [];
72
+ this.handleRequest = this.handleRequest.bind(this);
73
+ this.handleResponse = this.handleResponse.bind(this);
74
+ this.handleError = this.handleError.bind(this);
75
+ }
76
+ get interceptedRequestBuffer() {
77
+ return [...this.interceptedRequests];
78
+ }
79
+ clearInterceptBuffer() {
80
+ this.interceptedRequests = [];
81
+ }
82
+ registerInterceptors(axiosInstance) {
83
+ this.requestInterceptorId = axiosInstance.interceptors.request.use(this.handleRequest, this.handleError);
84
+ this.responseInterceptorId = axios_1.default.interceptors.response.use(this.handleResponse, this.handleError);
85
+ }
86
+ ejectInterceptors(axiosInstance) {
87
+ try {
88
+ if (this.requestInterceptorId !== undefined) {
89
+ axiosInstance.interceptors.request.eject(this.requestInterceptorId);
90
+ }
91
+ }
92
+ catch (e) {
93
+ loggingProvider_1.logger.warn(`Unable to eject request interceptor ${this.requestInterceptorId}`);
94
+ }
95
+ try {
96
+ if (this.responseInterceptorId !== undefined) {
97
+ axiosInstance.interceptors.response.eject(this.responseInterceptorId);
98
+ }
99
+ }
100
+ catch (e) {
101
+ loggingProvider_1.logger.warn(`Unable to eject request interceptor ${this.responseInterceptorId}`);
102
+ }
103
+ }
104
+ handleRequest(config) {
105
+ var _a, _b, _c;
106
+ try {
107
+ const requestId = (0, uuid_1.v4)();
108
+ config.mablRequestId = requestId;
109
+ this.interceptedRequests.push({
110
+ requestId,
111
+ request: {
112
+ headers: (_a = config.headers) !== null && _a !== void 0 ? _a : {},
113
+ url: (_b = config === null || config === void 0 ? void 0 : config.url) !== null && _b !== void 0 ? _b : '<Unknown URL>',
114
+ method: (_c = config.method) === null || _c === void 0 ? void 0 : _c.toUpperCase(),
115
+ request_sent_time: Date.now(),
116
+ },
117
+ });
118
+ }
119
+ catch (e) {
120
+ loggingProvider_1.logger.warn('Error in the response interceptor', e);
121
+ }
122
+ return config;
123
+ }
124
+ handleResponse(response) {
125
+ try {
126
+ const responseReceivedTime = Date.now();
127
+ const chainEntry = this.getOrCreateEntry(response.config);
128
+ const request = response.request;
129
+ if (request) {
130
+ chainEntry.request.headers = headerStringToHeaders(request._header);
131
+ chainEntry.request.protocol = (request === null || request === void 0 ? void 0 : request._header)
132
+ ? headerStringToProtocol(request._header)
133
+ : '<Unknown protocol>';
134
+ }
135
+ chainEntry.response = {
136
+ headers: headerRecordToHeaderMultiMap(response.headers),
137
+ status: response.status,
138
+ response_received_time: responseReceivedTime,
139
+ body: handleRawResponseBody(response.data),
140
+ };
141
+ }
142
+ catch (e) {
143
+ loggingProvider_1.logger.warn('Error in the response interceptor', e);
144
+ }
145
+ return response;
146
+ }
147
+ handleError(error) {
148
+ var _a;
149
+ try {
150
+ const config = error.config;
151
+ let chainEntry;
152
+ if (config) {
153
+ chainEntry = this.getOrCreateEntry(config);
154
+ }
155
+ else if (this.interceptedRequests.length) {
156
+ chainEntry =
157
+ this.interceptedRequests[this.interceptedRequests.length - 1];
158
+ }
159
+ if (chainEntry) {
160
+ chainEntry.error = {
161
+ code: (_a = error.code) !== null && _a !== void 0 ? _a : httpUtil_1.GENERAL_API_STEP_EXECUTION_ERROR_CODE,
162
+ message: error.message,
163
+ error_received_time: Date.now(),
164
+ };
165
+ }
166
+ if (error.response) {
167
+ this.handleResponse(error.response);
168
+ }
169
+ }
170
+ catch (e) {
171
+ loggingProvider_1.logger.warn('Error in the error interceptor', e);
172
+ }
173
+ return Promise.reject(error);
174
+ }
175
+ getOrCreateEntry(config) {
176
+ const existingEntry = this.findEntry(config);
177
+ if (existingEntry) {
178
+ return existingEntry;
179
+ }
180
+ this.handleRequest(config);
181
+ return this.findEntry(config);
182
+ }
183
+ findEntry(config) {
184
+ return this.interceptedRequests.find((chain) => chain.requestId === config.mablRequestId);
185
+ }
186
+ }
187
+ exports.RequestInterceptor = RequestInterceptor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mablhq/mabl-cli",
3
- "version": "1.41.4",
3
+ "version": "1.42.7",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "The official mabl command line interface tool",
6
6
  "main": "index.js",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@mablhq/newman-reporter-mabl-console": "0.1.0",
24
- "@playwright/test": "1.25.1",
24
+ "@playwright/test": "1.25.2",
25
25
  "@types/fs-extra": "8.1.1",
26
26
  "@types/serve-handler": "6.1.0",
27
27
  "@types/tmp": "0.2.0",
@@ -66,7 +66,7 @@
66
66
  "newman": "5.3.2",
67
67
  "open": "6.4.0",
68
68
  "ora": "4.0.4",
69
- "playwright-core": "1.25.1",
69
+ "playwright-core": "1.25.2",
70
70
  "pluralize": "8.0.0",
71
71
  "pngjs": "6.0.0",
72
72
  "portfinder": "1.0.28",
@@ -13,7 +13,7 @@ const mablApiClientFactory_1 = require("../api/mablApiClientFactory");
13
13
  const loggingProvider_1 = require("./logging/loggingProvider");
14
14
  const pureUtil_1 = require("../util/pureUtil");
15
15
  const OktaClient_1 = require("../auth/OktaClient");
16
- const httpUtil_1 = require("../util/httpUtil");
16
+ const axiosProxyConfig_1 = require("../http/axiosProxyConfig");
17
17
  const types_2 = require("./types");
18
18
  const humanizeDuration = require('humanize-duration');
19
19
  const inquirer = require('inquirer');
@@ -24,7 +24,7 @@ class AuthenticationProvider {
24
24
  }
25
25
  async getOktaClient() {
26
26
  if (!this.oktaClient) {
27
- const client = axios_1.default.create(await (0, httpUtil_1.currentProxyConfig)());
27
+ const client = axios_1.default.create(await (0, axiosProxyConfig_1.currentProxyConfig)());
28
28
  this.oktaClient = new OktaClient_1.OktaClient(client);
29
29
  }
30
30
  return this.oktaClient;
@@ -32,7 +32,7 @@ const conf_1 = __importDefault(require("conf"));
32
32
  const types_1 = require("./types");
33
33
  const types_2 = require("../api/types");
34
34
  const configKeys_1 = require("../commands/config/config_cmds/configKeys");
35
- const httpUtil_1 = require("../util/httpUtil");
35
+ const httpUtil_1 = require("../http/httpUtil");
36
36
  const crypto = __importStar(require("crypto"));
37
37
  const loggingProvider_1 = require("./logging/loggingProvider");
38
38
  const utilities_1 = require("../utilities");
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.decodeTestConfigAsParamsForParsedUrlProtocol = exports.encodeTestConfigAsParamsForParsedUrlProtocol = exports.b64EncodeUnicodeInNode = exports.b64DecodeUnicodeInNode = exports.TEST_CONFIG_URL_PARAM_KEY = void 0;
7
+ const querystring_1 = __importDefault(require("querystring"));
8
+ const MAX_PARSED_URL_PROTOCOL_PARAMS_LENGTH = 2000;
9
+ exports.TEST_CONFIG_URL_PARAM_KEY = 'scriptConfig';
10
+ function b64DecodeUnicodeInNode(encoded) {
11
+ return Buffer.from(encoded, 'base64').toString();
12
+ }
13
+ exports.b64DecodeUnicodeInNode = b64DecodeUnicodeInNode;
14
+ function b64EncodeUnicodeInNode(text) {
15
+ return Buffer.from(text).toString('base64');
16
+ }
17
+ exports.b64EncodeUnicodeInNode = b64EncodeUnicodeInNode;
18
+ function encodeTestConfigAsParamsForParsedUrlProtocol(testConfig, b64Encode) {
19
+ const encoded = querystring_1.default.stringify({
20
+ ...testConfig,
21
+ [exports.TEST_CONFIG_URL_PARAM_KEY]: b64Encode(JSON.stringify(testConfig)),
22
+ });
23
+ if (encoded.length > MAX_PARSED_URL_PROTOCOL_PARAMS_LENGTH) {
24
+ throw new Error('Test parameters exceed size limit. Please use the mabl Desktop App to create or edit tests.');
25
+ }
26
+ return encoded;
27
+ }
28
+ exports.encodeTestConfigAsParamsForParsedUrlProtocol = encodeTestConfigAsParamsForParsedUrlProtocol;
29
+ function decodeTestConfigAsParamsForParsedUrlProtocol(encoded, b64Decode, useV2) {
30
+ const params = querystring_1.default.parse(encoded);
31
+ if (useV2 && params[exports.TEST_CONFIG_URL_PARAM_KEY]) {
32
+ return JSON.parse(b64Decode(params[exports.TEST_CONFIG_URL_PARAM_KEY]));
33
+ }
34
+ delete params[exports.TEST_CONFIG_URL_PARAM_KEY];
35
+ return params;
36
+ }
37
+ exports.decodeTestConfigAsParamsForParsedUrlProtocol = decodeTestConfigAsParamsForParsedUrlProtocol;
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.removeUploadDirs = exports.cleanupOldFiles = exports.downloadFileUpload = void 0;
30
30
  const axios_1 = __importDefault(require("axios"));
31
- const httpUtil_1 = require("./httpUtil");
31
+ const axiosProxyConfig_1 = require("../http/axiosProxyConfig");
32
32
  const path_1 = __importDefault(require("path"));
33
33
  const fs = __importStar(require("fs-extra"));
34
34
  const stream_1 = require("stream");
@@ -42,7 +42,7 @@ async function downloadFileUpload(fileUploadUrl, fileUpload, downloadDirectory,
42
42
  client = mablApiClient.httpClient;
43
43
  }
44
44
  else {
45
- client = axios_1.default.create(await (0, httpUtil_1.currentProxyConfig)());
45
+ client = axios_1.default.create(await (0, axiosProxyConfig_1.currentProxyConfig)());
46
46
  }
47
47
  try {
48
48
  const finalDirectory = path_1.default.normalize(`${downloadDirectory}/${fileUpload.id}`);