@n8n/backend-network 1.1.1 → 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.
Files changed (78) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/http/{axios-config.js → axios/config.js} +3 -3
  3. package/dist/http/axios/config.js.map +1 -0
  4. package/dist/http/axios/invoke.d.ts +2 -0
  5. package/dist/http/axios/invoke.js +30 -0
  6. package/dist/http/axios/invoke.js.map +1 -0
  7. package/dist/http/axios/legacy.d.ts +6 -0
  8. package/dist/http/axios/legacy.js +219 -0
  9. package/dist/http/axios/legacy.js.map +1 -0
  10. package/dist/http/axios/redirect.d.ts +14 -0
  11. package/dist/http/axios/redirect.js +120 -0
  12. package/dist/http/axios/redirect.js.map +1 -0
  13. package/dist/http/{http-request.d.ts → axios/request.d.ts} +7 -2
  14. package/dist/http/{http-request.js → axios/request.js} +29 -45
  15. package/dist/http/axios/request.js.map +1 -0
  16. package/dist/http/{outbound-user-agent.js → axios/user-agent.js} +3 -3
  17. package/dist/http/axios/user-agent.js.map +1 -0
  18. package/dist/http/{axios-utils.d.ts → axios/utils.d.ts} +10 -4
  19. package/dist/http/{axios-utils.js → axios/utils.js} +55 -15
  20. package/dist/http/axios/utils.js.map +1 -0
  21. package/dist/http/binary-buffer.d.ts +1 -1
  22. package/dist/http/binary-buffer.js +47 -9
  23. package/dist/http/binary-buffer.js.map +1 -1
  24. package/dist/http/client-default-headers.d.ts +4 -0
  25. package/dist/http/client-default-headers.js +24 -0
  26. package/dist/http/client-default-headers.js.map +1 -0
  27. package/dist/http/client-options.d.ts +7 -0
  28. package/dist/http/client-options.js +3 -0
  29. package/dist/http/client-options.js.map +1 -0
  30. package/dist/http/client-request-error.d.ts +11 -0
  31. package/dist/http/client-request-error.js +37 -0
  32. package/dist/http/client-request-error.js.map +1 -0
  33. package/dist/http/env-proxy-http-agent.d.ts +8 -0
  34. package/dist/http/env-proxy-http-agent.js +24 -0
  35. package/dist/http/env-proxy-http-agent.js.map +1 -0
  36. package/dist/http/env-proxy-https-agent.d.ts +9 -0
  37. package/dist/http/env-proxy-https-agent.js +24 -0
  38. package/dist/http/env-proxy-https-agent.js.map +1 -0
  39. package/dist/http/env-proxy-router.d.ts +12 -0
  40. package/dist/http/env-proxy-router.js +55 -0
  41. package/dist/http/env-proxy-router.js.map +1 -0
  42. package/dist/http/http-proxy.d.ts +1 -0
  43. package/dist/http/http-proxy.js +10 -62
  44. package/dist/http/http-proxy.js.map +1 -1
  45. package/dist/http/index.d.ts +10 -4
  46. package/dist/http/index.js +15 -24
  47. package/dist/http/index.js.map +1 -1
  48. package/dist/http/legacy-request.d.ts +7 -0
  49. package/dist/http/legacy-request.js +100 -0
  50. package/dist/http/legacy-request.js.map +1 -0
  51. package/dist/http/local-server.d.ts +9 -0
  52. package/dist/http/local-server.js +31 -0
  53. package/dist/http/local-server.js.map +1 -0
  54. package/dist/http/node-agents.d.ts +21 -0
  55. package/dist/http/node-agents.js +67 -0
  56. package/dist/http/node-agents.js.map +1 -0
  57. package/dist/http/outbound-http.d.ts +41 -0
  58. package/dist/http/outbound-http.js +75 -0
  59. package/dist/http/outbound-http.js.map +1 -0
  60. package/dist/http/undici/transport.d.ts +29 -0
  61. package/dist/http/undici/transport.js +102 -0
  62. package/dist/http/undici/transport.js.map +1 -0
  63. package/dist/ssrf/ssrf-protection.service.d.ts +2 -0
  64. package/dist/ssrf/ssrf-protection.service.js +7 -0
  65. package/dist/ssrf/ssrf-protection.service.js.map +1 -1
  66. package/dist/testing.d.ts +4 -0
  67. package/dist/testing.js +14 -0
  68. package/dist/testing.js.map +1 -0
  69. package/dist/transport.d.ts +4 -0
  70. package/dist/transport.js +10 -0
  71. package/dist/transport.js.map +1 -0
  72. package/package.json +40 -12
  73. package/dist/http/axios-config.js.map +0 -1
  74. package/dist/http/axios-utils.js.map +0 -1
  75. package/dist/http/http-request.js.map +0 -1
  76. package/dist/http/outbound-user-agent.js.map +0 -1
  77. /package/dist/http/{axios-config.d.ts → axios/config.d.ts} +0 -0
  78. /package/dist/http/{outbound-user-agent.d.ts → axios/user-agent.d.ts} +0 -0
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveProxyUrl = resolveProxyUrl;
7
7
  exports.createHttpProxyAgent = createHttpProxyAgent;
8
8
  exports.createHttpsProxyAgent = createHttpsProxyAgent;
9
+ exports.hasProxyEnvironmentVariables = hasProxyEnvironmentVariables;
9
10
  exports.installGlobalProxyAgent = installGlobalProxyAgent;
10
11
  exports.uninstallGlobalProxyAgent = uninstallGlobalProxyAgent;
11
12
  const http_1 = __importDefault(require("http"));
@@ -14,61 +15,8 @@ const https_1 = __importDefault(require("https"));
14
15
  const https_proxy_agent_1 = require("https-proxy-agent");
15
16
  const n8n_workflow_1 = require("n8n-workflow");
16
17
  const proxy_from_env_1 = require("proxy-from-env");
17
- function buildTargetUrl(hostname, port, protocol) {
18
- const defaultPort = protocol === 'https' ? 443 : 80;
19
- const portSuffix = port === defaultPort ? '' : `:${port}`;
20
- return `${protocol}://${hostname}${portSuffix}`;
21
- }
22
- function extractHostInfo(options, defaultPort) {
23
- const hostname = options.hostname ?? options.host ?? 'localhost';
24
- const port = typeof options.port === 'string' ? parseInt(options.port, 10) : (options.port ?? defaultPort);
25
- return { hostname: String(hostname), port: Number(port) };
26
- }
27
- function getOrCreateProxyAgent(cache, proxyUrl, createAgent) {
28
- let proxyAgent = cache.get(proxyUrl);
29
- if (!proxyAgent) {
30
- proxyAgent = createAgent(proxyUrl);
31
- cache.set(proxyUrl, proxyAgent);
32
- }
33
- return proxyAgent;
34
- }
35
- function createFallbackAgent(agentClass) {
36
- return new agentClass();
37
- }
38
- class HttpProxyManager extends http_1.default.Agent {
39
- constructor() {
40
- super(...arguments);
41
- this.proxyAgentCache = new Map();
42
- this.fallbackAgent = createFallbackAgent(http_1.default.Agent);
43
- }
44
- addRequest(req, options) {
45
- const { hostname, port } = extractHostInfo(options, 80);
46
- const targetUrl = buildTargetUrl(hostname, port, 'http');
47
- const proxyUrl = (0, proxy_from_env_1.getProxyForUrl)(targetUrl);
48
- if (proxyUrl) {
49
- const proxyAgent = getOrCreateProxyAgent(this.proxyAgentCache, proxyUrl, (url) => new http_proxy_agent_1.HttpProxyAgent(url));
50
- return proxyAgent.addRequest(req, options);
51
- }
52
- return this.fallbackAgent.addRequest(req, options);
53
- }
54
- }
55
- class HttpsProxyManager extends https_1.default.Agent {
56
- constructor() {
57
- super(...arguments);
58
- this.proxyAgentCache = new Map();
59
- this.fallbackAgent = createFallbackAgent(https_1.default.Agent);
60
- }
61
- addRequest(req, options) {
62
- const { hostname, port } = extractHostInfo(options, 443);
63
- const targetUrl = buildTargetUrl(hostname, port, 'https');
64
- const proxyUrl = (0, proxy_from_env_1.getProxyForUrl)(targetUrl);
65
- if (proxyUrl) {
66
- const proxyAgent = getOrCreateProxyAgent(this.proxyAgentCache, proxyUrl, (url) => new https_proxy_agent_1.HttpsProxyAgent(url));
67
- return proxyAgent.addRequest(req, options);
68
- }
69
- return this.fallbackAgent.addRequest(req, options);
70
- }
71
- }
18
+ const env_proxy_http_agent_1 = require("./env-proxy-http-agent");
19
+ const env_proxy_https_agent_1 = require("./env-proxy-https-agent");
72
20
  function resolveProxyUrl(targetUrl) {
73
21
  return (0, proxy_from_env_1.getProxyForUrl)(targetUrl) || undefined;
74
22
  }
@@ -87,11 +35,11 @@ function createHttpsProxyAgent(customProxyUrl = null, targetUrl, options) {
87
35
  return new https_1.default.Agent(options);
88
36
  }
89
37
  function hasProxyEnvironmentVariables() {
90
- return Boolean(process.env.HTTP_PROXY ??
91
- process.env.http_proxy ??
92
- process.env.HTTPS_PROXY ??
93
- process.env.https_proxy ??
94
- process.env.ALL_PROXY ??
38
+ return Boolean(process.env.HTTP_PROXY ||
39
+ process.env.http_proxy ||
40
+ process.env.HTTPS_PROXY ||
41
+ process.env.https_proxy ||
42
+ process.env.ALL_PROXY ||
95
43
  process.env.all_proxy);
96
44
  }
97
45
  function installGlobalProxyAgent() {
@@ -102,8 +50,8 @@ function installGlobalProxyAgent() {
102
50
  NO_PROXY: process.env.NO_PROXY ?? process.env.no_proxy,
103
51
  ALL_PROXY: process.env.ALL_PROXY ?? process.env.all_proxy,
104
52
  });
105
- http_1.default.globalAgent = new HttpProxyManager();
106
- https_1.default.globalAgent = new HttpsProxyManager();
53
+ http_1.default.globalAgent = new env_proxy_http_agent_1.EnvProxyHttpAgent();
54
+ https_1.default.globalAgent = new env_proxy_https_agent_1.EnvProxyHttpsAgent();
107
55
  }
108
56
  }
109
57
  function uninstallGlobalProxyAgent() {
@@ -1 +1 @@
1
- {"version":3,"file":"http-proxy.js","sourceRoot":"","sources":["../../src/http/http-proxy.ts"],"names":[],"mappings":";;;;;AAqGA,0CAEC;AAED,oDAYC;AAED,sDAYC;AAaD,0DAYC;AAED,8DAGC;AAjKD,gDAAwB;AACxB,uDAAkD;AAClD,kDAA0B;AAC1B,yDAAoD;AACpD,+CAA2C;AAC3C,mDAAgD;AAMhD,SAAS,cAAc,CAAC,QAAgB,EAAE,IAAY,EAAE,QAA0B;IACjF,MAAM,WAAW,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,MAAM,UAAU,GAAG,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAC1D,OAAO,GAAG,QAAQ,MAAM,QAAQ,GAAG,UAAU,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,eAAe,CACvB,OAA4B,EAC5B,WAAmB;IAEnB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC;IACjE,MAAM,IAAI,GACT,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,C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-proxy';
2
- export { configureGlobalAxiosDefaults } from './axios-config';
3
- export { createFormDataObject, generateContentLengthHeader, getBeforeRedirectFn, getHostFromRequestObject, isFormDataInstance, resolveLegacyRequestUrl, searchForHeader, setAxiosAgents, throwIfDomainNotAllowed, tryParseUrl, validateUrlSsrf, } from './axios-utils';
4
- export { convertN8nRequestToAxios, httpRequest, invokeAxios, removeEmptyBody, } from './http-request';
5
- export { applyDefaultOutboundUserAgent, buildRfcStyleUserAgent, getDefaultN8nOutboundUserAgent, } from './outbound-user-agent';
2
+ export { configureGlobalAxiosDefaults } from './axios/config';
3
+ export { tryParseUrl } from './axios/utils';
4
+ export { httpRequest, removeEmptyBody } from './axios/request';
6
5
  export { parseIncomingMessage } from './parse-incoming-message';
7
6
  export { binaryToBuffer, streamToBuffer } from './binary-buffer';
8
7
  export { binaryToString } from './binary-string';
8
+ export type { NodeAgentOptions, ProxyOption, ProxyUrl, SsrfOption } from './node-agents';
9
+ export type { CustomFetch, RequestAuthorizer } from './undici/transport';
10
+ export { OutboundHttp, type HttpRequestClient, type HttpTransport, type HttpTransportOptions, } from './outbound-http';
11
+ export { httpStatusFromError, isConnectionRefusedError, isHttpRequestError, markHttpRequestError, type HttpRequestError, } from './client-request-error';
12
+ export type { HttpRequestDefaultHeaders } from './client-default-headers';
13
+ export type { HttpRequestClientOptions } from './client-options';
14
+ export type { LegacyRequestCallbacks } from './legacy-request';
@@ -1,34 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.binaryToString = exports.streamToBuffer = exports.binaryToBuffer = exports.parseIncomingMessage = exports.getDefaultN8nOutboundUserAgent = exports.buildRfcStyleUserAgent = exports.applyDefaultOutboundUserAgent = exports.removeEmptyBody = exports.invokeAxios = exports.httpRequest = exports.convertN8nRequestToAxios = exports.validateUrlSsrf = exports.tryParseUrl = exports.throwIfDomainNotAllowed = exports.setAxiosAgents = exports.searchForHeader = exports.resolveLegacyRequestUrl = exports.isFormDataInstance = exports.getHostFromRequestObject = exports.getBeforeRedirectFn = exports.generateContentLengthHeader = exports.createFormDataObject = exports.configureGlobalAxiosDefaults = exports.resolveProxyUrl = exports.installGlobalProxyAgent = exports.createHttpsProxyAgent = exports.createHttpProxyAgent = void 0;
3
+ exports.markHttpRequestError = exports.isHttpRequestError = exports.isConnectionRefusedError = exports.httpStatusFromError = exports.OutboundHttp = exports.binaryToString = exports.streamToBuffer = exports.binaryToBuffer = exports.parseIncomingMessage = exports.removeEmptyBody = exports.httpRequest = exports.tryParseUrl = exports.configureGlobalAxiosDefaults = exports.resolveProxyUrl = exports.installGlobalProxyAgent = exports.createHttpsProxyAgent = exports.createHttpProxyAgent = void 0;
4
4
  var http_proxy_1 = require("./http-proxy");
5
5
  Object.defineProperty(exports, "createHttpProxyAgent", { enumerable: true, get: function () { return http_proxy_1.createHttpProxyAgent; } });
6
6
  Object.defineProperty(exports, "createHttpsProxyAgent", { enumerable: true, get: function () { return http_proxy_1.createHttpsProxyAgent; } });
7
7
  Object.defineProperty(exports, "installGlobalProxyAgent", { enumerable: true, get: function () { return http_proxy_1.installGlobalProxyAgent; } });
8
8
  Object.defineProperty(exports, "resolveProxyUrl", { enumerable: true, get: function () { return http_proxy_1.resolveProxyUrl; } });
9
- var axios_config_1 = require("./axios-config");
10
- Object.defineProperty(exports, "configureGlobalAxiosDefaults", { enumerable: true, get: function () { return axios_config_1.configureGlobalAxiosDefaults; } });
11
- var axios_utils_1 = require("./axios-utils");
12
- Object.defineProperty(exports, "createFormDataObject", { enumerable: true, get: function () { return axios_utils_1.createFormDataObject; } });
13
- Object.defineProperty(exports, "generateContentLengthHeader", { enumerable: true, get: function () { return axios_utils_1.generateContentLengthHeader; } });
14
- Object.defineProperty(exports, "getBeforeRedirectFn", { enumerable: true, get: function () { return axios_utils_1.getBeforeRedirectFn; } });
15
- Object.defineProperty(exports, "getHostFromRequestObject", { enumerable: true, get: function () { return axios_utils_1.getHostFromRequestObject; } });
16
- Object.defineProperty(exports, "isFormDataInstance", { enumerable: true, get: function () { return axios_utils_1.isFormDataInstance; } });
17
- Object.defineProperty(exports, "resolveLegacyRequestUrl", { enumerable: true, get: function () { return axios_utils_1.resolveLegacyRequestUrl; } });
18
- Object.defineProperty(exports, "searchForHeader", { enumerable: true, get: function () { return axios_utils_1.searchForHeader; } });
19
- Object.defineProperty(exports, "setAxiosAgents", { enumerable: true, get: function () { return axios_utils_1.setAxiosAgents; } });
20
- Object.defineProperty(exports, "throwIfDomainNotAllowed", { enumerable: true, get: function () { return axios_utils_1.throwIfDomainNotAllowed; } });
21
- Object.defineProperty(exports, "tryParseUrl", { enumerable: true, get: function () { return axios_utils_1.tryParseUrl; } });
22
- Object.defineProperty(exports, "validateUrlSsrf", { enumerable: true, get: function () { return axios_utils_1.validateUrlSsrf; } });
23
- var http_request_1 = require("./http-request");
24
- Object.defineProperty(exports, "convertN8nRequestToAxios", { enumerable: true, get: function () { return http_request_1.convertN8nRequestToAxios; } });
25
- Object.defineProperty(exports, "httpRequest", { enumerable: true, get: function () { return http_request_1.httpRequest; } });
26
- Object.defineProperty(exports, "invokeAxios", { enumerable: true, get: function () { return http_request_1.invokeAxios; } });
27
- Object.defineProperty(exports, "removeEmptyBody", { enumerable: true, get: function () { return http_request_1.removeEmptyBody; } });
28
- var outbound_user_agent_1 = require("./outbound-user-agent");
29
- Object.defineProperty(exports, "applyDefaultOutboundUserAgent", { enumerable: true, get: function () { return outbound_user_agent_1.applyDefaultOutboundUserAgent; } });
30
- Object.defineProperty(exports, "buildRfcStyleUserAgent", { enumerable: true, get: function () { return outbound_user_agent_1.buildRfcStyleUserAgent; } });
31
- Object.defineProperty(exports, "getDefaultN8nOutboundUserAgent", { enumerable: true, get: function () { return outbound_user_agent_1.getDefaultN8nOutboundUserAgent; } });
9
+ var config_1 = require("./axios/config");
10
+ Object.defineProperty(exports, "configureGlobalAxiosDefaults", { enumerable: true, get: function () { return config_1.configureGlobalAxiosDefaults; } });
11
+ var utils_1 = require("./axios/utils");
12
+ Object.defineProperty(exports, "tryParseUrl", { enumerable: true, get: function () { return utils_1.tryParseUrl; } });
13
+ var request_1 = require("./axios/request");
14
+ Object.defineProperty(exports, "httpRequest", { enumerable: true, get: function () { return request_1.httpRequest; } });
15
+ Object.defineProperty(exports, "removeEmptyBody", { enumerable: true, get: function () { return request_1.removeEmptyBody; } });
32
16
  var parse_incoming_message_1 = require("./parse-incoming-message");
33
17
  Object.defineProperty(exports, "parseIncomingMessage", { enumerable: true, get: function () { return parse_incoming_message_1.parseIncomingMessage; } });
34
18
  var binary_buffer_1 = require("./binary-buffer");
@@ -36,4 +20,11 @@ Object.defineProperty(exports, "binaryToBuffer", { enumerable: true, get: functi
36
20
  Object.defineProperty(exports, "streamToBuffer", { enumerable: true, get: function () { return binary_buffer_1.streamToBuffer; } });
37
21
  var binary_string_1 = require("./binary-string");
38
22
  Object.defineProperty(exports, "binaryToString", { enumerable: true, get: function () { return binary_string_1.binaryToString; } });
23
+ var outbound_http_1 = require("./outbound-http");
24
+ Object.defineProperty(exports, "OutboundHttp", { enumerable: true, get: function () { return outbound_http_1.OutboundHttp; } });
25
+ var client_request_error_1 = require("./client-request-error");
26
+ Object.defineProperty(exports, "httpStatusFromError", { enumerable: true, get: function () { return client_request_error_1.httpStatusFromError; } });
27
+ Object.defineProperty(exports, "isConnectionRefusedError", { enumerable: true, get: function () { return client_request_error_1.isConnectionRefusedError; } });
28
+ Object.defineProperty(exports, "isHttpRequestError", { enumerable: true, get: function () { return client_request_error_1.isHttpRequestError; } });
29
+ Object.defineProperty(exports, "markHttpRequestError", { enumerable: true, get: function () { return client_request_error_1.markHttpRequestError; } });
39
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":";;;AAAA,2CAKsB;AAJrB,kHAAA,oBAAoB,OAAA;AACpB,mHAAA,qBAAqB,OAAA;AACrB,qHAAA,uBAAuB,OAAA;AACvB,6GAAA,eAAe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,iDAKyB;AAJxB,6GAAA,YAAY,OAAA;AAKb,+DAMgC;AAL/B,2HAAA,mBAAmB,OAAA;AACnB,gIAAA,wBAAwB,OAAA;AACxB,0HAAA,kBAAkB,OAAA;AAClB,4HAAA,oBAAoB,OAAA"}
@@ -0,0 +1,7 @@
1
+ import type { Logger } from '@n8n/backend-common';
2
+ import type { IRequestOptions } from 'n8n-workflow';
3
+ import type { SsrfBridge } from '../ssrf';
4
+ export interface LegacyRequestCallbacks {
5
+ onFetched?: () => Promise<void> | void;
6
+ }
7
+ export declare function executeLegacyRequest(requestObject: IRequestOptions, ssrfBridge: SsrfBridge | undefined, logger: Logger, callbacks?: LegacyRequestCallbacks): Promise<unknown>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeLegacyRequest = executeLegacyRequest;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const node_http_1 = require("node:http");
6
+ const node_stream_1 = require("node:stream");
7
+ const invoke_1 = require("./axios/invoke");
8
+ const legacy_1 = require("./axios/legacy");
9
+ const redirect_1 = require("./axios/redirect");
10
+ const utils_1 = require("./axios/utils");
11
+ const binary_string_1 = require("./binary-string");
12
+ const parse_incoming_message_1 = require("./parse-incoming-message");
13
+ async function executeLegacyRequest(requestObject, ssrfBridge, logger, callbacks) {
14
+ let axiosConfig = {
15
+ maxBodyLength: Infinity,
16
+ maxContentLength: -1,
17
+ };
18
+ const url = (0, utils_1.resolveLegacyRequestUrl)(requestObject);
19
+ await (0, utils_1.validateUrlSsrf)(url, ssrfBridge);
20
+ axiosConfig = Object.assign(axiosConfig, await (0, legacy_1.buildAxiosConfigFromLegacyRequest)(requestObject, ssrfBridge));
21
+ (0, utils_1.throwIfDomainNotAllowed)(axiosConfig, requestObject.allowedDomains);
22
+ try {
23
+ const response = (0, redirect_1.shouldFollowRedirectsManually)(axiosConfig, requestObject.proxy, ssrfBridge)
24
+ ? await (0, redirect_1.followSsrfRedirects)(axiosConfig, {
25
+ ssrf: ssrfBridge,
26
+ proxyConfig: requestObject.proxy,
27
+ agentOptions: (0, legacy_1.buildLegacyAgentOptions)(requestObject),
28
+ allowedDomains: requestObject.allowedDomains,
29
+ sendCredentialsOnCrossOriginRedirect: requestObject.sendCredentialsOnCrossOriginRedirect ?? true,
30
+ authSendImmediately: requestObject.auth?.sendImmediately,
31
+ })
32
+ : await (0, invoke_1.invokeAxios)(axiosConfig, requestObject.auth?.sendImmediately);
33
+ let body = response.data;
34
+ if (body instanceof node_http_1.IncomingMessage && axiosConfig.responseType === 'stream') {
35
+ (0, parse_incoming_message_1.parseIncomingMessage)(body);
36
+ }
37
+ else if (body === '') {
38
+ body = axiosConfig.responseType === 'arraybuffer' ? Buffer.alloc(0) : undefined;
39
+ }
40
+ await callbacks?.onFetched?.();
41
+ return requestObject.resolveWithFullResponse
42
+ ? {
43
+ body,
44
+ headers: { ...response.headers },
45
+ statusCode: response.status,
46
+ statusMessage: response.statusText,
47
+ request: response.request,
48
+ }
49
+ : body;
50
+ }
51
+ catch (error) {
52
+ const { config, response } = error;
53
+ if (error.isAxiosError) {
54
+ error.config = error.request = undefined;
55
+ const options = {};
56
+ for (const key of ['url', 'method', 'data', 'headers']) {
57
+ if (config && key in config) {
58
+ options[key] = config[key];
59
+ }
60
+ }
61
+ error.options = options;
62
+ if (response) {
63
+ logger.debug('Request proxied to Axios failed', { status: response.status });
64
+ let responseData = response.data;
65
+ if (Buffer.isBuffer(responseData) || responseData instanceof node_stream_1.Readable) {
66
+ responseData = await (0, binary_string_1.binaryToString)(responseData);
67
+ }
68
+ if (requestObject.simple === false) {
69
+ if (requestObject.resolveWithFullResponse) {
70
+ return {
71
+ body: responseData,
72
+ headers: response.headers,
73
+ statusCode: response.status,
74
+ statusMessage: response.statusText,
75
+ };
76
+ }
77
+ else {
78
+ return responseData;
79
+ }
80
+ }
81
+ error.message = `${response.status} - ${JSON.stringify(responseData)}`;
82
+ throw Object.assign(error, {
83
+ statusCode: response.status,
84
+ status: response.status,
85
+ error: responseData,
86
+ response: {
87
+ headers: response.headers,
88
+ status: response.status,
89
+ statusText: response.statusText,
90
+ },
91
+ });
92
+ }
93
+ else if ('rejectUnauthorized' in requestObject && error.code?.includes('CERT')) {
94
+ throw new n8n_workflow_1.NodeSslError(error);
95
+ }
96
+ }
97
+ throw error;
98
+ }
99
+ }
100
+ //# sourceMappingURL=legacy-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-request.js","sourceRoot":"","sources":["../../src/http/legacy-request.ts"],"names":[],"mappings":";;AAyCA,oDAiHC;AAjJD,+CAA4C;AAC5C,yCAA4C;AAC5C,6CAAuC;AAGvC,2CAA6C;AAC7C,2CAA4F;AAC5F,+CAAsF;AACtF,yCAAkG;AAClG,mDAAiD;AACjD,qEAAgE;AAsBzD,KAAK,UAAU,oBAAoB,CACzC,aAA8B,EAC9B,UAAkC,EAClC,MAAc,EACd,SAAkC;IAElC,IAAI,WAAW,GAAuB;QACrC,aAAa,EAAE,QAAQ;QAKvB,gBAAgB,EAAE,CAAC,CAAC;KACpB,CAAC;IAEF,MAAM,GAAG,GAAG,IAAA,+BAAuB,EAAC,aAAa,CAAC,CAAC;IACnD,MAAM,IAAA,uBAAe,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAEvC,WAAW,GAAG,MAAM,CAAC,MAAM,CAC1B,WAAW,EACX,MAAM,IAAA,0CAAiC,EAAC,aAAa,EAAE,UAAU,CAAC,CAClE,CAAC;IACF,IAAA,+BAAuB,EAAC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAEnE,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,IAAA,wCAA6B,EAAC,WAAW,EAAE,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC;YAC3F,CAAC,CAAC,MAAM,IAAA,8BAAmB,EAAC,WAAW,EAAE;gBACvC,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,aAAa,CAAC,KAAK;gBAChC,YAA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vB,KAAK,EAAE,YAAY;oBACnB,QAAQ,EAAE;wBACT,OAAO,EAAE,QAAQ,CAAC,OAAO;wBACzB,MAAM,EAAE,QAAQ,CAAC,MAAM;wBACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;qBAC/B;iBACD,CAAC,CAAC;YACJ,CAAC;iBAAM,IAAI,oBAAoB,IAAI,aAAa,IAAI,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAClF,MAAM,IAAI,2BAAY,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;QAED,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ import http from 'node:http';
2
+ export interface LocalServer {
3
+ url: string;
4
+ hostWithPort: string;
5
+ captured: string[];
6
+ clear: () => void;
7
+ close: () => Promise<void>;
8
+ }
9
+ export declare function startServer(handler: http.RequestListener): Promise<LocalServer>;
@@ -0,0 +1,31 @@
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.startServer = startServer;
7
+ const node_http_1 = __importDefault(require("node:http"));
8
+ const node_util_1 = require("node:util");
9
+ const LOOPBACK = '127.0.0.1';
10
+ async function startServer(handler) {
11
+ const captured = [];
12
+ const server = node_http_1.default.createServer((req, res) => {
13
+ captured.push(req.url ?? '');
14
+ handler(req, res);
15
+ });
16
+ await new Promise((resolve, reject) => {
17
+ server.listen(0, LOOPBACK, resolve);
18
+ server.on('error', reject);
19
+ });
20
+ const { port } = server.address();
21
+ return {
22
+ url: `http://${LOOPBACK}:${port}`,
23
+ hostWithPort: `${LOOPBACK}:${port}`,
24
+ captured,
25
+ clear: () => {
26
+ captured.length = 0;
27
+ },
28
+ close: async () => await (0, node_util_1.promisify)(server.close.bind(server))(),
29
+ };
30
+ }
31
+ //# sourceMappingURL=local-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-server.js","sourceRoot":"","sources":["../../src/http/local-server.ts"],"names":[],"mappings":";;;;;AAaA,kCAoBC;AAjCD,0DAA6B;AAE7B,yCAAsC;AAUtC,MAAM,QAAQ,GAAG,WAAW,CAAC;AACtB,KAAK,UAAU,WAAW,CAAC,OAA6B;IAC9D,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,mBAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC7C,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACpC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAC;IACjD,OAAO;QACN,GAAG,EAAE,UAAU,QAAQ,IAAI,IAAI,EAAE;QACjC,YAAY,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE;QACnC,QAAQ;QACR,KAAK,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,IAAA,qBAAS,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE;KAC/D,CAAC;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import http from 'node:http';
2
+ import https from 'node:https';
3
+ import type { SsrfBridge } from '../ssrf';
4
+ export type ProxyUrl = `${'http' | 'https'}://${string}`;
5
+ export declare function isSupportedProxyUrl(value: string | null | undefined): value is ProxyUrl;
6
+ export type ProxyOption = 'env' | ProxyUrl | false;
7
+ export type SsrfOption = SsrfBridge | 'disabled';
8
+ export type NodeAgentOptions = https.AgentOptions;
9
+ export declare function buildNodeAgents(proxy: ProxyOption, ssrf: SsrfOption, agentOptions?: NodeAgentOptions): {
10
+ httpAgent: http.Agent;
11
+ httpsAgent: https.Agent;
12
+ };
13
+ type ConnectionOptions = {
14
+ host?: string | null;
15
+ hostname?: string | null;
16
+ };
17
+ type CreateConnection = (options: ConnectionOptions, onConnect?: (error: Error | null, stream?: unknown) => void) => unknown;
18
+ export declare function installConnectionGuard(target: {
19
+ createConnection: CreateConnection;
20
+ }, ssrf: SsrfBridge): void;
21
+ export {};
@@ -0,0 +1,67 @@
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.isSupportedProxyUrl = isSupportedProxyUrl;
7
+ exports.buildNodeAgents = buildNodeAgents;
8
+ exports.installConnectionGuard = installConnectionGuard;
9
+ const http_proxy_agent_1 = require("http-proxy-agent");
10
+ const https_proxy_agent_1 = require("https-proxy-agent");
11
+ const n8n_workflow_1 = require("n8n-workflow");
12
+ const node_http_1 = __importDefault(require("node:http"));
13
+ const node_https_1 = __importDefault(require("node:https"));
14
+ const env_proxy_http_agent_1 = require("./env-proxy-http-agent");
15
+ const env_proxy_https_agent_1 = require("./env-proxy-https-agent");
16
+ function isSupportedProxyUrl(value) {
17
+ return (value !== null &&
18
+ value !== undefined &&
19
+ (value.startsWith('http://') || value.startsWith('https://')));
20
+ }
21
+ function buildNodeAgents(proxy, ssrf, agentOptions) {
22
+ if (agentOptions?.lookup) {
23
+ throw new n8n_workflow_1.UnexpectedError('`agentOptions.lookup` is not supported: DNS resolution is managed by the SSRF policy. Remove it from `agentOptions`.');
24
+ }
25
+ const lookup = ssrf !== 'disabled' ? ssrf.createSecureLookup() : undefined;
26
+ if (proxy === false) {
27
+ return applyConnectionGuard({
28
+ httpAgent: new node_http_1.default.Agent({ ...agentOptions, lookup }),
29
+ httpsAgent: new node_https_1.default.Agent({ ...agentOptions, lookup }),
30
+ }, ssrf);
31
+ }
32
+ if (proxy === 'env') {
33
+ return applyConnectionGuard({
34
+ httpAgent: new env_proxy_http_agent_1.EnvProxyHttpAgent(lookup, agentOptions),
35
+ httpsAgent: new env_proxy_https_agent_1.EnvProxyHttpsAgent(lookup, agentOptions),
36
+ }, ssrf);
37
+ }
38
+ return {
39
+ httpAgent: new http_proxy_agent_1.HttpProxyAgent(proxy, { ...agentOptions }),
40
+ httpsAgent: new https_proxy_agent_1.HttpsProxyAgent(proxy, { ...agentOptions }),
41
+ };
42
+ }
43
+ function applyConnectionGuard(agents, ssrf) {
44
+ if (ssrf !== 'disabled') {
45
+ installConnectionGuard(agents.httpAgent, ssrf);
46
+ installConnectionGuard(agents.httpsAgent, ssrf);
47
+ }
48
+ return agents;
49
+ }
50
+ function installConnectionGuard(target, ssrf) {
51
+ const createConnection = target.createConnection.bind(target);
52
+ target.createConnection = (options, onConnect) => {
53
+ const host = options.host ?? options.hostname ?? undefined;
54
+ if (typeof host === 'string') {
55
+ const result = ssrf.validateConnectionHost(host);
56
+ if (!result.ok) {
57
+ if (onConnect) {
58
+ onConnect(result.error);
59
+ return undefined;
60
+ }
61
+ throw result.error;
62
+ }
63
+ }
64
+ return createConnection(options, onConnect);
65
+ };
66
+ }
67
+ //# sourceMappingURL=node-agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-agents.js","sourceRoot":"","sources":["../../src/http/node-agents.ts"],"names":[],"mappings":";;;;;AAsBA,kDAMC;AAsCD,0CAuCC;AA+BD,wDAmBC;AA3JD,uDAAkD;AAClD,yDAAoD;AACpD,+CAA+C;AAC/C,0DAA6B;AAC7B,4DAA+B;AAG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ACH,CAAC;AAgBD,SAAS,oBAAoB,CAC5B,MAA0D,EAC1D,IAAgB;IAEhB,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACzB,sBAAsB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC/C,sBAAsB,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAMD,SAAgB,sBAAsB,CACrC,MAA8C,EAC9C,IAAgB;IAEhB,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,CAAC,gBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE;QAChD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ,IAAI,SAAS,CAAC;QAC3D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;gBAChB,IAAI,SAAS,EAAE,CAAC;oBACf,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACxB,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,MAAM,MAAM,CAAC,KAAK,CAAC;YACpB,CAAC;QACF,CAAC;QACD,OAAO,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC7C,CAAC,CAAC;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { Logger } from '@n8n/backend-common';
2
+ import type { IHttpRequestOptions, IN8nHttpFullResponse, IN8nHttpResponse, IRequestOptions } from 'n8n-workflow';
3
+ import type http from 'node:http';
4
+ import type https from 'node:https';
5
+ import type { Dispatcher } from 'undici';
6
+ import { SsrfProtectionService } from '../ssrf';
7
+ import { HttpRequestClientOptions } from './client-options';
8
+ import { type LegacyRequestCallbacks } from './legacy-request';
9
+ import type { NodeAgentOptions, ProxyOption, SsrfOption } from './node-agents';
10
+ import { type CustomFetch, type RequestAuthorizer, type TransportTimeoutOptions } from './undici/transport';
11
+ export interface HttpTransportOptions {
12
+ proxy?: ProxyOption;
13
+ ssrf?: SsrfOption;
14
+ timeouts?: TransportTimeoutOptions;
15
+ authorize?: RequestAuthorizer;
16
+ }
17
+ export interface HttpRequestClient {
18
+ request(options: IHttpRequestOptions & {
19
+ returnFullResponse: true;
20
+ }): Promise<IN8nHttpFullResponse>;
21
+ request(options: IHttpRequestOptions & {
22
+ returnFullResponse?: false;
23
+ }): Promise<IN8nHttpResponse>;
24
+ request(options: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
25
+ requestLegacy(options: IRequestOptions, callbacks?: LegacyRequestCallbacks): Promise<unknown>;
26
+ }
27
+ export interface HttpTransport {
28
+ asCustomFetch(): CustomFetch;
29
+ getDispatcher(): Dispatcher;
30
+ getNodeAgent(agentOptions?: NodeAgentOptions): {
31
+ httpAgent: http.Agent;
32
+ httpsAgent: https.Agent;
33
+ };
34
+ }
35
+ export declare class OutboundHttp {
36
+ private readonly ssrfProtection;
37
+ private readonly logger;
38
+ constructor(ssrfProtection: SsrfProtectionService, logger: Logger);
39
+ requests(options?: HttpRequestClientOptions): HttpRequestClient;
40
+ transport(options?: HttpTransportOptions): HttpTransport;
41
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OutboundHttp = void 0;
13
+ const backend_common_1 = require("@n8n/backend-common");
14
+ const di_1 = require("@n8n/di");
15
+ const ssrf_1 = require("../ssrf");
16
+ const request_1 = require("./axios/request");
17
+ const client_default_headers_1 = require("./client-default-headers");
18
+ const client_request_error_1 = require("./client-request-error");
19
+ const legacy_request_1 = require("./legacy-request");
20
+ const node_agents_1 = require("./node-agents");
21
+ const transport_1 = require("./undici/transport");
22
+ let OutboundHttp = class OutboundHttp {
23
+ constructor(ssrfProtection, logger) {
24
+ this.ssrfProtection = ssrfProtection;
25
+ this.logger = logger;
26
+ }
27
+ requests(options) {
28
+ const ssrf = options?.ssrf ?? this.ssrfProtection;
29
+ const ssrfBridge = ssrf === 'disabled' ? undefined : ssrf;
30
+ const applyDefaults = (requestOptions) => (0, client_default_headers_1.withClientDefaults)(requestOptions, options?.baseURL, options?.headers);
31
+ async function request(requestOptions) {
32
+ try {
33
+ return await (0, request_1.httpRequest)(applyDefaults(requestOptions), ssrfBridge);
34
+ }
35
+ catch (error) {
36
+ throw (0, client_request_error_1.markHttpRequestError)(error);
37
+ }
38
+ }
39
+ return {
40
+ request,
41
+ requestLegacy: async (requestOptions, callbacks) => {
42
+ try {
43
+ return await (0, legacy_request_1.executeLegacyRequest)(requestOptions, ssrfBridge, this.logger, callbacks);
44
+ }
45
+ catch (error) {
46
+ throw (0, client_request_error_1.markHttpRequestError)(error);
47
+ }
48
+ },
49
+ };
50
+ }
51
+ transport(options) {
52
+ const proxy = options?.proxy ?? 'env';
53
+ const ssrf = options?.ssrf ?? this.ssrfProtection;
54
+ const timeouts = options?.timeouts;
55
+ const authorize = options?.authorize;
56
+ const dispatcherTransport = (0, transport_1.createDispatcherTransport)({ proxy, ssrf, timeouts, authorize });
57
+ const lazyNodeAgents = lazy(() => (0, node_agents_1.buildNodeAgents)(proxy, ssrf));
58
+ return {
59
+ asCustomFetch: () => dispatcherTransport.asCustomFetch(),
60
+ getDispatcher: () => dispatcherTransport.getDispatcher(),
61
+ getNodeAgent: (agentOptions) => agentOptions !== undefined ? (0, node_agents_1.buildNodeAgents)(proxy, ssrf, agentOptions) : lazyNodeAgents(),
62
+ };
63
+ }
64
+ };
65
+ exports.OutboundHttp = OutboundHttp;
66
+ exports.OutboundHttp = OutboundHttp = __decorate([
67
+ (0, di_1.Service)(),
68
+ __metadata("design:paramtypes", [ssrf_1.SsrfProtectionService,
69
+ backend_common_1.Logger])
70
+ ], OutboundHttp);
71
+ function lazy(factory) {
72
+ let cached;
73
+ return () => (cached ??= { value: factory() }).value;
74
+ }
75
+ //# sourceMappingURL=outbound-http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbound-http.js","sourceRoot":"","sources":["../../src/http/outbound-http.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAA6C;AAC7C,gCAAkC;AAWlC,kCAAgD;AAChD,6CAA8C;AAC9C,qEAA8D;AAE9D,iEAA8D;AAC9D,qDAAqF;AAErF,+CAAgD;AAChD,kDAK4B;AAsHrB,IAAM,YAAY,GAAlB,MAAM,YAAY;IACxB,YACkB,cAAqC,EACrC,MAAc;QADd,mBAAc,GAAd,cAAc,CAAuB;QACrC,WAAM,GAAN,MAAM,CAAQ;IAC7B,CAAC;IAMJ,QAAQ,CAAC,OAAkC;QAC1C,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC;QAClD,MAAM,UAAU,GAAG,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1D,MAAM,aAAa,GAAG,CAAC,cAAmC,EAAuB,EAAE,CAClF,IAAA,2CAAkB,EAAC,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,O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BAAmB,CAAC,aAAa,EAAE;YACxD,YAAY,EAAE,CAAC,YAAY,EAAE,EAAE,CAC9B,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAA,6BAAe,EAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE;SAC3F,CAAC;IACH,CAAC;CACD,CAAA;AArEY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,YAAO,GAAE;qCAGyB,4BAAqB;QAC7B,uBAAM;GAHpB,YAAY,CAqExB;AAED,SAAS,IAAI,CAAI,OAAgB;IAChC,IAAI,MAAgC,CAAC;IACrC,OAAO,GAAG,EAAE,CAAC,CAAC,MAAM,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { Dispatcher } from 'undici';
2
+ import type { SsrfBridge } from '../../ssrf';
3
+ import type { ProxyOption, SsrfOption } from '../node-agents';
4
+ export type CustomFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
5
+ export type RequestAuthorizer = (url: URL) => Promise<void>;
6
+ export interface TransportTimeoutOptions {
7
+ headersTimeout?: number;
8
+ bodyTimeout?: number;
9
+ connectTimeout?: number;
10
+ }
11
+ export interface CreateDispatcherTransportOptions {
12
+ proxy?: ProxyOption;
13
+ ssrf?: SsrfOption;
14
+ timeouts?: TransportTimeoutOptions;
15
+ authorize?: RequestAuthorizer;
16
+ }
17
+ export interface DispatcherTransport {
18
+ asCustomFetch(): CustomFetch;
19
+ getDispatcher(): Dispatcher;
20
+ }
21
+ export interface BuildDispatcherOptions {
22
+ timeouts?: TransportTimeoutOptions;
23
+ authorize?: RequestAuthorizer;
24
+ }
25
+ export declare function buildDispatcher(proxy: ProxyOption, ssrf: SsrfOption, options?: BuildDispatcherOptions): Dispatcher;
26
+ export declare function createDispatcherTransport(options?: CreateDispatcherTransportOptions): DispatcherTransport;
27
+ export declare function createSsrfInterceptor(bridge: SsrfBridge): Dispatcher.DispatcherComposeInterceptor;
28
+ export declare function createAuthorizationInterceptor(authorize: RequestAuthorizer): Dispatcher.DispatcherComposeInterceptor;
29
+ export declare function dispatchedFetch(dispatcher: Dispatcher, input: RequestInfo | URL, init?: RequestInit): Promise<Response>;