@n8n/backend-network 1.1.2 → 1.2.0
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/dist/build.tsbuildinfo +1 -1
- package/dist/http/{axios-config.js → axios/config.js} +3 -3
- package/dist/http/axios/config.js.map +1 -0
- package/dist/http/axios/invoke.d.ts +2 -0
- package/dist/http/axios/invoke.js +30 -0
- package/dist/http/axios/invoke.js.map +1 -0
- package/dist/http/axios/legacy.d.ts +6 -0
- package/dist/http/axios/legacy.js +219 -0
- package/dist/http/axios/legacy.js.map +1 -0
- package/dist/http/axios/redirect.d.ts +14 -0
- package/dist/http/axios/redirect.js +120 -0
- package/dist/http/axios/redirect.js.map +1 -0
- package/dist/http/{http-request.d.ts → axios/request.d.ts} +7 -2
- package/dist/http/{http-request.js → axios/request.js} +29 -45
- package/dist/http/axios/request.js.map +1 -0
- package/dist/http/{outbound-user-agent.js → axios/user-agent.js} +3 -3
- package/dist/http/axios/user-agent.js.map +1 -0
- package/dist/http/{axios-utils.d.ts → axios/utils.d.ts} +10 -4
- package/dist/http/{axios-utils.js → axios/utils.js} +55 -15
- package/dist/http/axios/utils.js.map +1 -0
- package/dist/http/binary-buffer.d.ts +1 -1
- package/dist/http/binary-buffer.js +47 -9
- package/dist/http/binary-buffer.js.map +1 -1
- package/dist/http/client-default-headers.d.ts +4 -0
- package/dist/http/client-default-headers.js +24 -0
- package/dist/http/client-default-headers.js.map +1 -0
- package/dist/http/client-options.d.ts +7 -0
- package/dist/http/client-options.js +3 -0
- package/dist/http/client-options.js.map +1 -0
- package/dist/http/client-request-error.d.ts +11 -0
- package/dist/http/client-request-error.js +37 -0
- package/dist/http/client-request-error.js.map +1 -0
- package/dist/http/env-proxy-http-agent.d.ts +8 -0
- package/dist/http/env-proxy-http-agent.js +24 -0
- package/dist/http/env-proxy-http-agent.js.map +1 -0
- package/dist/http/env-proxy-https-agent.d.ts +9 -0
- package/dist/http/env-proxy-https-agent.js +24 -0
- package/dist/http/env-proxy-https-agent.js.map +1 -0
- package/dist/http/env-proxy-router.d.ts +12 -0
- package/dist/http/env-proxy-router.js +55 -0
- package/dist/http/env-proxy-router.js.map +1 -0
- package/dist/http/http-proxy.d.ts +1 -0
- package/dist/http/http-proxy.js +10 -62
- package/dist/http/http-proxy.js.map +1 -1
- package/dist/http/index.d.ts +10 -4
- package/dist/http/index.js +15 -24
- package/dist/http/index.js.map +1 -1
- package/dist/http/legacy-request.d.ts +7 -0
- package/dist/http/legacy-request.js +100 -0
- package/dist/http/legacy-request.js.map +1 -0
- package/dist/http/local-server.d.ts +9 -0
- package/dist/http/local-server.js +31 -0
- package/dist/http/local-server.js.map +1 -0
- package/dist/http/node-agents.d.ts +21 -0
- package/dist/http/node-agents.js +67 -0
- package/dist/http/node-agents.js.map +1 -0
- package/dist/http/outbound-http.d.ts +41 -0
- package/dist/http/outbound-http.js +75 -0
- package/dist/http/outbound-http.js.map +1 -0
- package/dist/http/undici/transport.d.ts +29 -0
- package/dist/http/undici/transport.js +102 -0
- package/dist/http/undici/transport.js.map +1 -0
- package/dist/ssrf/ssrf-protection.service.d.ts +2 -0
- package/dist/ssrf/ssrf-protection.service.js +7 -0
- package/dist/ssrf/ssrf-protection.service.js.map +1 -1
- package/dist/testing.d.ts +4 -0
- package/dist/testing.js +14 -0
- package/dist/testing.js.map +1 -0
- package/dist/transport.d.ts +4 -0
- package/dist/transport.js +10 -0
- package/dist/transport.js.map +1 -0
- package/package.json +40 -12
- package/dist/http/axios-config.js.map +0 -1
- package/dist/http/axios-utils.js.map +0 -1
- package/dist/http/http-request.js.map +0 -1
- package/dist/http/outbound-user-agent.js.map +0 -1
- /package/dist/http/{axios-config.d.ts → axios/config.d.ts} +0 -0
- /package/dist/http/{outbound-user-agent.d.ts → axios/user-agent.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../../../src/http/axios/user-agent.ts"],"names":[],"mappings":";;AA2BA,wDAEC;AAUD,wEAQC;AAMD,sEAOC;AA5DD,wCAAgD;AAChD,gCAAoC;AAEpC,yCAAiC;AAEjC,mCAA0C;AAE1C,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAC1C,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,SAAS,cAAc;IACtB,IAAI,CAAC;QAGJ,MAAM,GAAG,GAAG,OAAO,CAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,0BAA0B,CAAC,CAAwB,CAAC;QACxF,OAAO,GAAG,CAAC,OAAO,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,OAAO,CAAC;IAChB,CAAC;AACF,CAAC;AAQD,SAAgB,sBAAsB,CAAC,OAAe;IACrD,OAAO,gCAAgC,OAAO,MAAM,eAAe,GAAG,CAAC;AACxE,CAAC;AAUD,SAAgB,8BAA8B;IAC7C,MAAM,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,GAAG,cAAS,CAAC,GAAG,CAAC,0BAAiB,CAAC,CAAC;IAE1F,IAAI,CAAC,sBAAsB;QAAE,OAAO,iBAAiB,CAAC;IAEtD,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,oBAAoB,CAAC;IAEjE,OAAO,sBAAsB,CAAC,cAAc,EAAE,CAAC,CAAC;AACjD,CAAC;AAMD,SAAgB,6BAA6B,CAAC,WAA+B;IAC5E,IAAI,IAAA,uBAAe,EAAC,WAAW,EAAE,YAAY,CAAC;QAAE,OAAO;IAEvD,WAAW,CAAC,OAAO,GAAG;QACrB,GAAG,WAAW,CAAC,OAAO;QACtB,YAAY,EAAE,8BAA8B,EAAE;KAC9C,CAAC;AACH,CAAC"}
|
|
@@ -2,7 +2,8 @@ import type { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
|
2
2
|
import FormData from 'form-data';
|
|
3
3
|
import type { AgentOptions } from 'https';
|
|
4
4
|
import { type IHttpRequestOptions, type IRequestOptions, type IgnoreStatusErrorConfig } from 'n8n-workflow';
|
|
5
|
-
import type { SsrfBridge } from '
|
|
5
|
+
import type { SsrfBridge } from '../../ssrf';
|
|
6
|
+
import type { ProxyOption, SsrfOption } from '../node-agents';
|
|
6
7
|
export declare function throwIfDomainNotAllowed(configOrUrl: AxiosRequestConfig | string, allowedDomains?: string): void;
|
|
7
8
|
export declare function tryParseUrl(url: string): URL | null;
|
|
8
9
|
export declare function isIgnoreStatusErrorConfig(ignoreHttpStatusErrors: unknown): ignoreHttpStatusErrors is IgnoreStatusErrorConfig;
|
|
@@ -12,13 +13,18 @@ export declare const getHostFromRequestObject: (requestObject: Partial<{
|
|
|
12
13
|
uri: string;
|
|
13
14
|
baseURL: string;
|
|
14
15
|
}>) => string | null;
|
|
15
|
-
export declare
|
|
16
|
+
export declare function resolveProxyOption(customProxyUrl: string | null): ProxyOption;
|
|
17
|
+
export declare const getBeforeRedirectFn: (agentOptions: AgentOptions, axiosConfig: AxiosRequestConfig, proxyConfig: IHttpRequestOptions["proxy"] | string | undefined, sendCredentialsOnCrossOriginRedirect: boolean, allowedDomains?: string, ssrf?: SsrfOption) => (redirectedRequest: Record<string, any>) => void;
|
|
16
18
|
export declare function digestAuthAxiosConfig(axiosConfig: AxiosRequestConfig, response: AxiosResponse, auth: AxiosRequestConfig['auth']): AxiosRequestConfig;
|
|
17
19
|
export declare const createFormDataObject: (data: Record<string, unknown>) => FormData;
|
|
18
20
|
export declare function isFormDataInstance(data: unknown): data is FormData;
|
|
21
|
+
export declare function buildAgentOptions(n8nRequest: IHttpRequestOptions): AgentOptions;
|
|
22
|
+
export declare function isRedirectStatus(status: number): boolean;
|
|
23
|
+
export declare function getRedirectLocation(response: AxiosResponse): string | undefined;
|
|
24
|
+
export declare function isProxyPotentiallyActive(proxyConfig?: IHttpRequestOptions['proxy'] | string): boolean;
|
|
19
25
|
export declare function generateContentLengthHeader(config: AxiosRequestConfig): Promise<void>;
|
|
20
|
-
export declare function getUrlFromProxyConfig(proxyConfig: IHttpRequestOptions['proxy'] | string): string | null;
|
|
26
|
+
export declare function getUrlFromProxyConfig(proxyConfig: IHttpRequestOptions['proxy'] | string | undefined | null): string | null;
|
|
21
27
|
export declare function buildTargetUrl(url?: string, baseURL?: string): string | undefined;
|
|
22
|
-
export declare function setAxiosAgents(config: AxiosRequestConfig, agentOptions?: AgentOptions, proxyConfig?: IHttpRequestOptions['proxy'] | string,
|
|
28
|
+
export declare function setAxiosAgents(config: AxiosRequestConfig, agentOptions?: AgentOptions, proxyConfig?: IHttpRequestOptions['proxy'] | string, ssrf?: SsrfOption): void;
|
|
23
29
|
export declare function validateUrlSsrf(url: string | undefined, ssrfBridge?: SsrfBridge): Promise<void>;
|
|
24
30
|
export declare function resolveLegacyRequestUrl(requestObject: IRequestOptions): string | undefined;
|
|
@@ -8,8 +8,13 @@ exports.throwIfDomainNotAllowed = throwIfDomainNotAllowed;
|
|
|
8
8
|
exports.tryParseUrl = tryParseUrl;
|
|
9
9
|
exports.isIgnoreStatusErrorConfig = isIgnoreStatusErrorConfig;
|
|
10
10
|
exports.searchForHeader = searchForHeader;
|
|
11
|
+
exports.resolveProxyOption = resolveProxyOption;
|
|
11
12
|
exports.digestAuthAxiosConfig = digestAuthAxiosConfig;
|
|
12
13
|
exports.isFormDataInstance = isFormDataInstance;
|
|
14
|
+
exports.buildAgentOptions = buildAgentOptions;
|
|
15
|
+
exports.isRedirectStatus = isRedirectStatus;
|
|
16
|
+
exports.getRedirectLocation = getRedirectLocation;
|
|
17
|
+
exports.isProxyPotentiallyActive = isProxyPotentiallyActive;
|
|
13
18
|
exports.generateContentLengthHeader = generateContentLengthHeader;
|
|
14
19
|
exports.getUrlFromProxyConfig = getUrlFromProxyConfig;
|
|
15
20
|
exports.buildTargetUrl = buildTargetUrl;
|
|
@@ -22,7 +27,8 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
22
27
|
const crypto_1 = __importDefault(require("crypto"));
|
|
23
28
|
const form_data_1 = __importDefault(require("form-data"));
|
|
24
29
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
25
|
-
const http_proxy_1 = require("
|
|
30
|
+
const http_proxy_1 = require("../http-proxy");
|
|
31
|
+
const node_agents_1 = require("../node-agents");
|
|
26
32
|
function throwIfDomainNotAllowed(configOrUrl, allowedDomains) {
|
|
27
33
|
const url = typeof configOrUrl === 'string' ? configOrUrl : axios_1.default.getUri(configOrUrl);
|
|
28
34
|
(0, n8n_workflow_1.assertUrlAllowed)({ url, allowedDomains });
|
|
@@ -59,22 +65,29 @@ const getHostFromRequestObject = (requestObject) => {
|
|
|
59
65
|
}
|
|
60
66
|
};
|
|
61
67
|
exports.getHostFromRequestObject = getHostFromRequestObject;
|
|
62
|
-
|
|
68
|
+
function resolveProxyOption(customProxyUrl) {
|
|
69
|
+
if (!customProxyUrl) {
|
|
70
|
+
return 'env';
|
|
71
|
+
}
|
|
72
|
+
if ((0, node_agents_1.isSupportedProxyUrl)(customProxyUrl)) {
|
|
73
|
+
return customProxyUrl;
|
|
74
|
+
}
|
|
75
|
+
di_1.Container.get(backend_common_1.Logger).warn(`Ignoring unsupported proxy URL "${customProxyUrl}", falling back to environment proxy settings`);
|
|
76
|
+
return 'env';
|
|
77
|
+
}
|
|
78
|
+
const getBeforeRedirectFn = (agentOptions, axiosConfig, proxyConfig, sendCredentialsOnCrossOriginRedirect, allowedDomains, ssrf = 'disabled') => (redirectedRequest) => {
|
|
63
79
|
throwIfDomainNotAllowed(redirectedRequest.href, allowedDomains);
|
|
64
|
-
if (
|
|
65
|
-
|
|
80
|
+
if (ssrf !== 'disabled') {
|
|
81
|
+
ssrf.validateRedirectSync(redirectedRequest.href);
|
|
66
82
|
}
|
|
67
83
|
const redirectAgentOptions = {
|
|
68
84
|
...agentOptions,
|
|
69
85
|
servername: redirectedRequest.hostname,
|
|
70
86
|
};
|
|
71
87
|
const customProxyUrl = proxyConfig ? getUrlFromProxyConfig(proxyConfig) : null;
|
|
72
|
-
const
|
|
73
|
-
? { ...redirectAgentOptions, lookup: ssrfBridge.createSecureLookup() }
|
|
74
|
-
: redirectAgentOptions;
|
|
88
|
+
const proxy = resolveProxyOption(customProxyUrl);
|
|
75
89
|
const targetUrl = redirectedRequest.href;
|
|
76
|
-
const httpAgent = (0,
|
|
77
|
-
const httpsAgent = (0, http_proxy_1.createHttpsProxyAgent)(customProxyUrl, targetUrl, effectiveRedirectOptions);
|
|
90
|
+
const { httpAgent, httpsAgent } = (0, node_agents_1.buildNodeAgents)(proxy, ssrf, redirectAgentOptions);
|
|
78
91
|
redirectedRequest.agent = redirectedRequest.href.startsWith('https://')
|
|
79
92
|
? httpsAgent
|
|
80
93
|
: httpAgent;
|
|
@@ -172,6 +185,29 @@ function isFormDataInstance(data) {
|
|
|
172
185
|
'append' in data &&
|
|
173
186
|
typeof data.append === 'function'));
|
|
174
187
|
}
|
|
188
|
+
function buildAgentOptions(n8nRequest) {
|
|
189
|
+
const host = (0, exports.getHostFromRequestObject)(n8nRequest);
|
|
190
|
+
const agentOptions = { ...n8nRequest.agentOptions };
|
|
191
|
+
if (host) {
|
|
192
|
+
agentOptions.servername = host;
|
|
193
|
+
}
|
|
194
|
+
if (n8nRequest.skipSslCertificateValidation === true) {
|
|
195
|
+
agentOptions.rejectUnauthorized = false;
|
|
196
|
+
}
|
|
197
|
+
return agentOptions;
|
|
198
|
+
}
|
|
199
|
+
function isRedirectStatus(status) {
|
|
200
|
+
return status >= 300 && status < 400;
|
|
201
|
+
}
|
|
202
|
+
function getRedirectLocation(response) {
|
|
203
|
+
const headers = response.headers;
|
|
204
|
+
const location = headers?.location;
|
|
205
|
+
return typeof location === 'string' ? location : undefined;
|
|
206
|
+
}
|
|
207
|
+
function isProxyPotentiallyActive(proxyConfig) {
|
|
208
|
+
const configSupported = (0, node_agents_1.isSupportedProxyUrl)(getUrlFromProxyConfig(proxyConfig));
|
|
209
|
+
return configSupported || (0, http_proxy_1.hasProxyEnvironmentVariables)();
|
|
210
|
+
}
|
|
175
211
|
async function generateContentLengthHeader(config) {
|
|
176
212
|
if (!isFormDataInstance(config.data)) {
|
|
177
213
|
return;
|
|
@@ -195,6 +231,9 @@ async function generateContentLengthHeader(config) {
|
|
|
195
231
|
}
|
|
196
232
|
}
|
|
197
233
|
function getUrlFromProxyConfig(proxyConfig) {
|
|
234
|
+
if (!proxyConfig) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
198
237
|
if (typeof proxyConfig === 'string') {
|
|
199
238
|
const isValidUrl = !!tryParseUrl(proxyConfig);
|
|
200
239
|
return isValidUrl ? proxyConfig : null;
|
|
@@ -227,16 +266,17 @@ function buildTargetUrl(url, baseURL) {
|
|
|
227
266
|
return undefined;
|
|
228
267
|
}
|
|
229
268
|
}
|
|
230
|
-
function setAxiosAgents(config, agentOptions, proxyConfig,
|
|
269
|
+
function setAxiosAgents(config, agentOptions, proxyConfig, ssrf = 'disabled') {
|
|
231
270
|
if (config.httpAgent || config.httpsAgent)
|
|
232
271
|
return;
|
|
233
|
-
const customProxyUrl = getUrlFromProxyConfig(proxyConfig);
|
|
234
272
|
const targetUrl = buildTargetUrl(config.url, config.baseURL);
|
|
235
273
|
if (!targetUrl)
|
|
236
274
|
return;
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
275
|
+
const customProxyUrl = proxyConfig ? getUrlFromProxyConfig(proxyConfig) : null;
|
|
276
|
+
const proxy = resolveProxyOption(customProxyUrl);
|
|
277
|
+
const { httpAgent, httpsAgent } = (0, node_agents_1.buildNodeAgents)(proxy, ssrf, agentOptions);
|
|
278
|
+
config.httpAgent = httpAgent;
|
|
279
|
+
config.httpsAgent = httpsAgent;
|
|
240
280
|
}
|
|
241
281
|
async function validateUrlSsrf(url, ssrfBridge) {
|
|
242
282
|
if (!ssrfBridge || !url)
|
|
@@ -254,4 +294,4 @@ function resolveLegacyRequestUrl(requestObject) {
|
|
|
254
294
|
const baseURL = requestObject.baseURL?.toString();
|
|
255
295
|
return buildTargetUrl(rawUrl, baseURL) ?? rawUrl;
|
|
256
296
|
}
|
|
257
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
export declare function streamToBuffer(stream: Readable, idleTimeoutMs?: number): Promise<Buffer>;
|
|
3
3
|
export declare function binaryToBuffer(body: Buffer | Readable): Promise<Buffer>;
|
|
@@ -2,18 +2,56 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.streamToBuffer = streamToBuffer;
|
|
4
4
|
exports.binaryToBuffer = binaryToBuffer;
|
|
5
|
+
const config_1 = require("@n8n/config");
|
|
6
|
+
const di_1 = require("@n8n/di");
|
|
5
7
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
-
async function streamToBuffer(stream) {
|
|
8
|
+
async function streamToBuffer(stream, idleTimeoutMs) {
|
|
9
|
+
const timeout = idleTimeoutMs ?? di_1.Container.get(config_1.HttpRequestConfig).responseBodyReadTimeout;
|
|
10
|
+
const useTimer = Number.isFinite(timeout) && timeout > 0;
|
|
7
11
|
return await new Promise((resolve, reject) => {
|
|
8
12
|
const chunks = [];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
let settled = false;
|
|
14
|
+
let timer;
|
|
15
|
+
const clearTimer = () => {
|
|
16
|
+
if (timer)
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
timer = undefined;
|
|
19
|
+
};
|
|
20
|
+
const armTimer = () => {
|
|
21
|
+
if (!useTimer)
|
|
22
|
+
return;
|
|
23
|
+
clearTimer();
|
|
24
|
+
timer = setTimeout(() => {
|
|
25
|
+
stream.destroy();
|
|
26
|
+
settle(() => reject(new n8n_workflow_1.UnexpectedError(`Response body timed out after ${timeout}ms without data`)));
|
|
27
|
+
}, timeout);
|
|
28
|
+
timer.unref?.();
|
|
29
|
+
};
|
|
30
|
+
const onData = (chunk) => {
|
|
31
|
+
chunks.push(chunk);
|
|
32
|
+
armTimer();
|
|
33
|
+
};
|
|
34
|
+
const onEnd = () => settle(() => resolve(Buffer.concat(chunks)));
|
|
35
|
+
const onError = (cause) => settle(() => reject(cause.code === 'Z_DATA_ERROR'
|
|
36
|
+
? new n8n_workflow_1.UnexpectedError('Failed to decompress response', { cause })
|
|
37
|
+
: cause));
|
|
38
|
+
const onClose = () => settle(() => reject(new n8n_workflow_1.UnexpectedError('Stream closed before completing')));
|
|
39
|
+
function settle(action) {
|
|
40
|
+
if (settled)
|
|
41
|
+
return;
|
|
42
|
+
settled = true;
|
|
43
|
+
clearTimer();
|
|
44
|
+
stream.off('data', onData);
|
|
45
|
+
stream.off('end', onEnd);
|
|
46
|
+
stream.off('error', onError);
|
|
47
|
+
stream.off('close', onClose);
|
|
48
|
+
action();
|
|
49
|
+
}
|
|
50
|
+
stream.on('data', onData);
|
|
51
|
+
stream.once('end', onEnd);
|
|
52
|
+
stream.once('error', onError);
|
|
53
|
+
stream.once('close', onClose);
|
|
54
|
+
armTimer();
|
|
17
55
|
});
|
|
18
56
|
}
|
|
19
57
|
async function binaryToBuffer(body) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary-buffer.js","sourceRoot":"","sources":["../../src/http/binary-buffer.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"binary-buffer.js","sourceRoot":"","sources":["../../src/http/binary-buffer.ts"],"names":[],"mappings":";;AAeA,wCA8DC;AAGD,wCAGC;AAnFD,wCAAgD;AAChD,gCAAoC;AACpC,+CAA+C;AAaxC,KAAK,UAAU,cAAc,CAAC,MAAgB,EAAE,aAAsB;IAC5E,MAAM,OAAO,GAAG,aAAa,IAAI,cAAS,CAAC,GAAG,CAAC,0BAAiB,CAAC,CAAC,uBAAuB,CAAC;IAC1F,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;IAEzD,OAAO,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpD,MAAM,MAAM,GAAa,EAAE,CAAC;Q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,CAAC,CAAC;QAE9E,SAAS,MAAM,CAAC,MAAkB;YACjC,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,UAAU,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7B,MAAM,EAAE,CAAC;QACV,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9B,QAAQ,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACJ,CAAC;AAGM,KAAK,UAAU,cAAc,CAAC,IAAuB;IAC3D,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IHttpRequestOptions } from 'n8n-workflow';
|
|
2
|
+
import type { HttpRequestClientOptions } from './client-options';
|
|
3
|
+
export type HttpRequestDefaultHeaders = Record<string, string | undefined>;
|
|
4
|
+
export declare function withClientDefaults(requestOptions: IHttpRequestOptions, baseURL: HttpRequestClientOptions['baseURL'], headers: HttpRequestClientOptions['headers']): IHttpRequestOptions;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withClientDefaults = withClientDefaults;
|
|
4
|
+
function withClientDefaults(requestOptions, baseURL, headers) {
|
|
5
|
+
if (baseURL === undefined && headers === undefined) {
|
|
6
|
+
return requestOptions;
|
|
7
|
+
}
|
|
8
|
+
const merged = { ...requestOptions };
|
|
9
|
+
if (baseURL !== undefined && merged.baseURL === undefined) {
|
|
10
|
+
merged.baseURL = baseURL;
|
|
11
|
+
}
|
|
12
|
+
if (headers !== undefined) {
|
|
13
|
+
const defaults = typeof headers === 'function' ? headers() : headers;
|
|
14
|
+
const combined = { ...defaults, ...requestOptions.headers };
|
|
15
|
+
for (const key of Object.keys(combined)) {
|
|
16
|
+
if (combined[key] === undefined) {
|
|
17
|
+
delete combined[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
merged.headers = combined;
|
|
21
|
+
}
|
|
22
|
+
return merged;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=client-default-headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-default-headers.js","sourceRoot":"","sources":["../../src/http/client-default-headers.ts"],"names":[],"mappings":";;AAgBA,gDA2BC;AA3BD,SAAgB,kBAAkB,CACjC,cAAmC,EACnC,OAA4C,EAC5C,OAA4C;IAE5C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACpD,OAAO,cAAc,CAAC;IACvB,CAAC;IAED,MAAM,MAAM,GAAwB,EAAE,GAAG,cAAc,EAAE,CAAC;IAE1D,IAAI,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3D,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACrE,MAAM,QAAQ,GAA4B,EAAE,GAAG,QAAQ,EAAE,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;QACrF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzC,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBACjC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;YACtB,CAAC;QACF,CAAC;QACD,MAAM,CAAC,OAAO,GAAG,QAA0C,CAAC;IAC7D,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HttpRequestDefaultHeaders } from './client-default-headers';
|
|
2
|
+
import type { SsrfOption } from './node-agents';
|
|
3
|
+
export interface HttpRequestClientOptions {
|
|
4
|
+
ssrf?: SsrfOption;
|
|
5
|
+
baseURL?: string;
|
|
6
|
+
headers?: HttpRequestDefaultHeaders | (() => HttpRequestDefaultHeaders);
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-options.js","sourceRoot":"","sources":["../../src/http/client-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function isConnectionRefusedError(error: unknown): boolean;
|
|
2
|
+
export declare function httpStatusFromError(error: unknown): number | undefined;
|
|
3
|
+
export interface HttpRequestError extends Error {
|
|
4
|
+
code?: string;
|
|
5
|
+
response?: {
|
|
6
|
+
status?: number;
|
|
7
|
+
data?: unknown;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function markHttpRequestError<E>(error: E): E;
|
|
11
|
+
export declare function isHttpRequestError(error: unknown): error is HttpRequestError;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isConnectionRefusedError = isConnectionRefusedError;
|
|
4
|
+
exports.httpStatusFromError = httpStatusFromError;
|
|
5
|
+
exports.markHttpRequestError = markHttpRequestError;
|
|
6
|
+
exports.isHttpRequestError = isHttpRequestError;
|
|
7
|
+
function isConnectionRefusedError(error) {
|
|
8
|
+
return (typeof error === 'object' &&
|
|
9
|
+
error !== null &&
|
|
10
|
+
'code' in error &&
|
|
11
|
+
error.code === 'ECONNREFUSED');
|
|
12
|
+
}
|
|
13
|
+
function httpStatusFromError(error) {
|
|
14
|
+
if (typeof error === 'object' && error !== null && 'response' in error) {
|
|
15
|
+
const response = error.response;
|
|
16
|
+
if (response && typeof response.status === 'number') {
|
|
17
|
+
return response.status;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const HTTP_REQUEST_ERROR = Symbol.for('n8n.backend-network.http-request-error');
|
|
23
|
+
function markHttpRequestError(error) {
|
|
24
|
+
if (typeof error === 'object' && error !== null) {
|
|
25
|
+
Object.defineProperty(error, HTTP_REQUEST_ERROR, {
|
|
26
|
+
value: true,
|
|
27
|
+
enumerable: false,
|
|
28
|
+
configurable: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return error;
|
|
32
|
+
}
|
|
33
|
+
function isHttpRequestError(error) {
|
|
34
|
+
return (error instanceof Error &&
|
|
35
|
+
error[HTTP_REQUEST_ERROR] === true);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=client-request-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-request-error.js","sourceRoot":"","sources":["../../src/http/client-request-error.ts"],"names":[],"mappings":";;AAYA,4DAOC;AAKD,kDAQC;AAuBD,oDASC;AAOD,gDAKC;AAhED,SAAgB,wBAAwB,CAAC,KAAc;IACtD,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACd,KAA4B,CAAC,IAAI,KAAK,cAAc,CACrD,CAAC;AACH,CAAC;AAKD,SAAgB,mBAAmB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,UAAU,IAAI,KAAK,EAAE,CAAC;QACxE,MAAM,QAAQ,GAAI,KAA6C,CAAC,QAAQ,CAAC;QACzE,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,QAAQ,CAAC,MAAM,CAAC;QACxB,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAgBD,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AAOhF,SAAgB,oBAAoB,CAAI,KAAQ;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,kBAAkB,EAAE;YAChD,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;SAClB,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAOD,SAAgB,kBAAkB,CAAC,KAAc;IAChD,OAAO,CACN,KAAK,YAAY,KAAK;QACrB,KAA4C,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAC1E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import type { LookupFunction } from 'node:net';
|
|
3
|
+
import type { NodeAgentOptions } from './node-agents';
|
|
4
|
+
export declare class EnvProxyHttpAgent extends http.Agent {
|
|
5
|
+
private readonly router;
|
|
6
|
+
constructor(lookup?: LookupFunction, agentOptions?: NodeAgentOptions);
|
|
7
|
+
addRequest(req: http.ClientRequest, options: http.RequestOptions): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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.EnvProxyHttpAgent = void 0;
|
|
7
|
+
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
8
|
+
const node_http_1 = __importDefault(require("node:http"));
|
|
9
|
+
const env_proxy_router_1 = require("./env-proxy-router");
|
|
10
|
+
class EnvProxyHttpAgent extends node_http_1.default.Agent {
|
|
11
|
+
constructor(lookup, agentOptions) {
|
|
12
|
+
super({ ...agentOptions, lookup });
|
|
13
|
+
this.router = new env_proxy_router_1.EnvProxyRouter('http', 80, (proxyUrl) => new http_proxy_agent_1.HttpProxyAgent(proxyUrl, { ...agentOptions }));
|
|
14
|
+
}
|
|
15
|
+
addRequest(req, options) {
|
|
16
|
+
const proxyAgent = this.router.resolve(options);
|
|
17
|
+
if (proxyAgent) {
|
|
18
|
+
return proxyAgent.addRequest(req, options);
|
|
19
|
+
}
|
|
20
|
+
super.addRequest(req, options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.EnvProxyHttpAgent = EnvProxyHttpAgent;
|
|
24
|
+
//# sourceMappingURL=env-proxy-http-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-proxy-http-agent.js","sourceRoot":"","sources":["../../src/http/env-proxy-http-agent.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAkD;AAClD,0DAA6B;AAG7B,yDAAoD;AAepD,MAAa,iBAAkB,SAAQ,mBAAI,CAAC,KAAK;IAGhD,YAAY,MAAuB,EAAE,YAA+B;QACnE,KAAK,CAAC,EAAE,GAAG,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,iCAAc,CAC/B,MAAM,EACN,EAAE,EACF,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,iCAAc,CAAC,QAAQ,EAAE,EAAE,GAAG,YAAY,EAAE,CAAC,CAC/D,CAAC;IACH,CAAC;IAED,UAAU,CAAC,GAAuB,EAAE,OAA4B;QAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEhD,IAAI,UAAU,EAAE,CAAC;YAChB,OAAO,UAAU,CAAC,UAAU,CAAC,GAAyB,EAAE,OAA2B,CAAC,CAAC;QACtF,CAAC;QAGD,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;CACD;AAtBD,8CAsBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
import https from 'node:https';
|
|
3
|
+
import type { LookupFunction } from 'node:net';
|
|
4
|
+
import type { NodeAgentOptions } from './node-agents';
|
|
5
|
+
export declare class EnvProxyHttpsAgent extends https.Agent {
|
|
6
|
+
private readonly router;
|
|
7
|
+
constructor(lookup?: LookupFunction, agentOptions?: NodeAgentOptions);
|
|
8
|
+
addRequest(req: http.ClientRequest, options: https.RequestOptions): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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.EnvProxyHttpsAgent = void 0;
|
|
7
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
8
|
+
const node_https_1 = __importDefault(require("node:https"));
|
|
9
|
+
const env_proxy_router_1 = require("./env-proxy-router");
|
|
10
|
+
class EnvProxyHttpsAgent extends node_https_1.default.Agent {
|
|
11
|
+
constructor(lookup, agentOptions) {
|
|
12
|
+
super({ ...agentOptions, lookup });
|
|
13
|
+
this.router = new env_proxy_router_1.EnvProxyRouter('https', 443, (proxyUrl) => new https_proxy_agent_1.HttpsProxyAgent(proxyUrl, { ...agentOptions }));
|
|
14
|
+
}
|
|
15
|
+
addRequest(req, options) {
|
|
16
|
+
const proxyAgent = this.router.resolve(options);
|
|
17
|
+
if (proxyAgent) {
|
|
18
|
+
return proxyAgent.addRequest(req, options);
|
|
19
|
+
}
|
|
20
|
+
super.addRequest(req, options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.EnvProxyHttpsAgent = EnvProxyHttpsAgent;
|
|
24
|
+
//# sourceMappingURL=env-proxy-https-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-proxy-https-agent.js","sourceRoot":"","sources":["../../src/http/env-proxy-https-agent.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAoD;AAEpD,4DAA+B;AAG/B,yDAAoD;AAQpD,MAAa,kBAAmB,SAAQ,oBAAK,CAAC,KAAK;IAGlD,YAAY,MAAuB,EAAE,YAA+B;QACnE,KAAK,CAAC,EAAE,GAAG,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,iCAAc,CAC/B,OAAO,EACP,GAAG,EACH,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,mCAAe,CAAC,QAAQ,EAAE,EAAE,GAAG,YAAY,EAAE,CAAC,CAChE,CAAC;IACH,CAAC;IAED,UAAU,CAAC,GAAuB,EAAE,OAA6B;QAChE,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEhD,IAAI,UAAU,EAAE,CAAC;YAChB,OAAO,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,OAA4B,CAAC,CAAC;QACjE,CAAC;QAGD,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;CACD;AAtBD,gDAsBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
export declare class EnvProxyRouter<TProxyAgent> {
|
|
3
|
+
private readonly scheme;
|
|
4
|
+
private readonly defaultPort;
|
|
5
|
+
private readonly createProxyAgent;
|
|
6
|
+
private readonly proxyCache;
|
|
7
|
+
private cacheLimitWarned;
|
|
8
|
+
constructor(scheme: 'http' | 'https', defaultPort: number, createProxyAgent: (proxyUrl: string) => TProxyAgent);
|
|
9
|
+
resolve(options: http.RequestOptions): TProxyAgent | undefined;
|
|
10
|
+
private cacheAgent;
|
|
11
|
+
private resolvePort;
|
|
12
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvProxyRouter = void 0;
|
|
4
|
+
const backend_common_1 = require("@n8n/backend-common");
|
|
5
|
+
const di_1 = require("@n8n/di");
|
|
6
|
+
const proxy_from_env_1 = require("proxy-from-env");
|
|
7
|
+
const MAX_CACHED_AGENTS = 64;
|
|
8
|
+
class EnvProxyRouter {
|
|
9
|
+
constructor(scheme, defaultPort, createProxyAgent) {
|
|
10
|
+
this.scheme = scheme;
|
|
11
|
+
this.defaultPort = defaultPort;
|
|
12
|
+
this.createProxyAgent = createProxyAgent;
|
|
13
|
+
this.proxyCache = new Map();
|
|
14
|
+
this.cacheLimitWarned = false;
|
|
15
|
+
}
|
|
16
|
+
resolve(options) {
|
|
17
|
+
const hostname = String(options.hostname ?? options.host ?? 'localhost');
|
|
18
|
+
const port = this.resolvePort(options.port);
|
|
19
|
+
const portSuffix = port === this.defaultPort ? '' : `:${port}`;
|
|
20
|
+
const proxyUrl = (0, proxy_from_env_1.getProxyForUrl)(`${this.scheme}://${hostname}${portSuffix}`);
|
|
21
|
+
if (!proxyUrl) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const cached = this.proxyCache.get(proxyUrl);
|
|
25
|
+
if (cached) {
|
|
26
|
+
return cached;
|
|
27
|
+
}
|
|
28
|
+
const agent = this.createProxyAgent(proxyUrl);
|
|
29
|
+
this.cacheAgent(proxyUrl, agent);
|
|
30
|
+
return agent;
|
|
31
|
+
}
|
|
32
|
+
cacheAgent(proxyUrl, agent) {
|
|
33
|
+
if (this.proxyCache.size >= MAX_CACHED_AGENTS) {
|
|
34
|
+
if (!this.cacheLimitWarned) {
|
|
35
|
+
this.cacheLimitWarned = true;
|
|
36
|
+
di_1.Container.get(backend_common_1.Logger).warn(`${this.scheme} proxy agent cache reached its limit of ${MAX_CACHED_AGENTS} entries; not caching further proxy agents. This is unexpected and likely indicates a misconfiguration.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.proxyCache.set(proxyUrl, agent);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
resolvePort(rawPort) {
|
|
44
|
+
const parsed = typeof rawPort === 'string' ? parseInt(rawPort, 10) : rawPort;
|
|
45
|
+
if (Number.isInteger(parsed)) {
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
if (rawPort !== undefined && rawPort !== null) {
|
|
49
|
+
di_1.Container.get(backend_common_1.Logger).warn(`Unparseable port "${String(rawPort)}" for ${this.scheme} proxy routing, falling back to default port ${this.defaultPort}`);
|
|
50
|
+
}
|
|
51
|
+
return this.defaultPort;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.EnvProxyRouter = EnvProxyRouter;
|
|
55
|
+
//# sourceMappingURL=env-proxy-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-proxy-router.js","sourceRoot":"","sources":["../../src/http/env-proxy-router.ts"],"names":[],"mappings":";;;AAAA,wDAA6C;AAC7C,gCAAoC;AAEpC,mDAAgD;AAEhD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAU7B,MAAa,cAAc;IAM1B,YACkB,MAAwB,EACxB,WAAmB,EACnB,gBAAmD;QAFnD,WAAM,GAAN,MAAM,CAAkB;Q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CAAC,CAAC,IAAI,CACzB,GAAG,IAAI,CAAC,MAAM,2CAA2C,iBAAiB,yGAAyG,CACnL,CAAC;YACH,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IAEO,WAAW,CAAC,OAAoC;QACvD,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7E,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,OAAO,MAAgB,CAAC;QACzB,CAAC;QACD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YAC/C,cAAS,CAAC,GAAG,CAAC,uBAAM,CAAC,CAAC,IAAI,CACzB,qBAAqB,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,MAAM,gDAAgD,IAAI,CAAC,WAAW,EAAE,CAC1H,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;CACD;AA5DD,wCA4DC"}
|
|
@@ -3,5 +3,6 @@ import https from 'https';
|
|
|
3
3
|
export declare function resolveProxyUrl(targetUrl: string): string | undefined;
|
|
4
4
|
export declare function createHttpProxyAgent(customProxyUrl: string | null | undefined, targetUrl: string, options?: http.AgentOptions): http.Agent;
|
|
5
5
|
export declare function createHttpsProxyAgent(customProxyUrl: string | null | undefined, targetUrl: string, options?: https.AgentOptions): https.Agent;
|
|
6
|
+
export declare function hasProxyEnvironmentVariables(): boolean;
|
|
6
7
|
export declare function installGlobalProxyAgent(): void;
|
|
7
8
|
export declare function uninstallGlobalProxyAgent(): void;
|