@n8n/backend-network 1.1.1 → 1.1.3

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 (56) 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/legacy.d.ts +4 -0
  5. package/dist/http/axios/legacy.js +214 -0
  6. package/dist/http/axios/legacy.js.map +1 -0
  7. package/dist/http/{http-request.d.ts → axios/request.d.ts} +7 -1
  8. package/dist/http/{http-request.js → axios/request.js} +15 -16
  9. package/dist/http/axios/request.js.map +1 -0
  10. package/dist/http/{outbound-user-agent.js → axios/user-agent.js} +3 -3
  11. package/dist/http/axios/user-agent.js.map +1 -0
  12. package/dist/http/{axios-utils.d.ts → axios/utils.d.ts} +4 -3
  13. package/dist/http/{axios-utils.js → axios/utils.js} +23 -15
  14. package/dist/http/axios/utils.js.map +1 -0
  15. package/dist/http/env-proxy-http-agent.d.ts +8 -0
  16. package/dist/http/env-proxy-http-agent.js +24 -0
  17. package/dist/http/env-proxy-http-agent.js.map +1 -0
  18. package/dist/http/env-proxy-https-agent.d.ts +9 -0
  19. package/dist/http/env-proxy-https-agent.js +24 -0
  20. package/dist/http/env-proxy-https-agent.js.map +1 -0
  21. package/dist/http/env-proxy-router.d.ts +12 -0
  22. package/dist/http/env-proxy-router.js +55 -0
  23. package/dist/http/env-proxy-router.js.map +1 -0
  24. package/dist/http/http-proxy.js +4 -57
  25. package/dist/http/http-proxy.js.map +1 -1
  26. package/dist/http/index.d.ts +7 -4
  27. package/dist/http/index.js +10 -24
  28. package/dist/http/index.js.map +1 -1
  29. package/dist/http/legacy-request.d.ts +7 -0
  30. package/dist/http/legacy-request.js +90 -0
  31. package/dist/http/legacy-request.js.map +1 -0
  32. package/dist/http/local-server.d.ts +9 -0
  33. package/dist/http/local-server.js +31 -0
  34. package/dist/http/local-server.js.map +1 -0
  35. package/dist/http/node-agents.d.ts +21 -0
  36. package/dist/http/node-agents.js +65 -0
  37. package/dist/http/node-agents.js.map +1 -0
  38. package/dist/http/outbound-http.d.ts +42 -0
  39. package/dist/http/outbound-http.js +56 -0
  40. package/dist/http/outbound-http.js.map +1 -0
  41. package/dist/http/undici/transport.d.ts +12 -0
  42. package/dist/http/undici/transport.js +62 -0
  43. package/dist/http/undici/transport.js.map +1 -0
  44. package/dist/ssrf/ssrf-protection.service.d.ts +2 -0
  45. package/dist/ssrf/ssrf-protection.service.js +7 -0
  46. package/dist/ssrf/ssrf-protection.service.js.map +1 -1
  47. package/dist/testing.d.ts +4 -0
  48. package/dist/testing.js +14 -0
  49. package/dist/testing.js.map +1 -0
  50. package/package.json +28 -8
  51. package/dist/http/axios-config.js.map +0 -1
  52. package/dist/http/axios-utils.js.map +0 -1
  53. package/dist/http/http-request.js.map +0 -1
  54. package/dist/http/outbound-user-agent.js.map +0 -1
  55. /package/dist/http/{axios-config.d.ts → axios/config.d.ts} +0 -0
  56. /package/dist/http/{outbound-user-agent.d.ts → axios/user-agent.d.ts} +0 -0
@@ -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-prox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AkB;QACtD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,iBAAiB,EAAE,CAAC;YAC/C,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAC7B,cAAS,CAAC,GAAG,CAAC,uBAAM,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"}
@@ -14,61 +14,8 @@ const https_1 = __importDefault(require("https"));
14
14
  const https_proxy_agent_1 = require("https-proxy-agent");
15
15
  const n8n_workflow_1 = require("n8n-workflow");
16
16
  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
- }
17
+ const env_proxy_http_agent_1 = require("./env-proxy-http-agent");
18
+ const env_proxy_https_agent_1 = require("./env-proxy-https-agent");
72
19
  function resolveProxyUrl(targetUrl) {
73
20
  return (0, proxy_from_env_1.getProxyForUrl)(targetUrl) || undefined;
74
21
  }
@@ -102,8 +49,8 @@ function installGlobalProxyAgent() {
102
49
  NO_PROXY: process.env.NO_PROXY ?? process.env.no_proxy,
103
50
  ALL_PROXY: process.env.ALL_PROXY ?? process.env.all_proxy,
104
51
  });
105
- http_1.default.globalAgent = new HttpProxyManager();
106
- https_1.default.globalAgent = new HttpsProxyManager();
52
+ http_1.default.globalAgent = new env_proxy_http_agent_1.EnvProxyHttpAgent();
53
+ https_1.default.globalAgent = new env_proxy_https_agent_1.EnvProxyHttpsAgent();
107
54
  }
108
55
  }
109
56
  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,CAA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ACpC,eAAK,CAAC,WAAW,GAAG,IAAI,eAAK,CAAC,KAAK,EAAE,CAAC;AACvC,CAAC"}
@@ -1,8 +1,11 @@
1
1
  export { createHttpProxyAgent, createHttpsProxyAgent, installGlobalProxyAgent, resolveProxyUrl, } from './http-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 } from './undici/transport';
10
+ export { OutboundHttp, type HttpRequestClient, type HttpRequestClientOptions, type HttpTransport, type HttpTransportOptions, } from './outbound-http';
11
+ 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.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,6 @@ 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; } });
39
25
  //# 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,OAAA;AAEhB,+CAA8D;AAArD,4HAAA,4BAA4B,OAAA;AACrC,6CAYuB;AAXtB,mHAAA,oBAAoB,OAAA;AACpB,0HAAA,2BAA2B,OAAA;AAC3B,kHAAA,mBAAmB,OAAA;AACnB,uHAAA,wBAAwB,OAAA;AACxB,iHAAA,kBAAkB,OAAA;AAClB,sHAAA,uBAAuB,OAAA;AACvB,8GAAA,eAAe,OAAA;AACf,6GAAA,cAAc,OAAA;AACd,sHAAA,uBAAuB,OAAA;AACvB,0GAAA,WAAW,OAAA;AACX,8GAAA,eAAe,OAAA;AAEhB,+CAKwB;AAJvB,wHAAA,wBAAwB,OAAA;AACxB,2GAAA,WAAW,OAAA;AACX,2GAAA,WAAW,OAAA;AACX,+GAAA,eAAe,OAAA;AAEhB,6DAI+B;AAH9B,oIAAA,6BAA6B,OAAA;AAC7B,6HAAA,sBAAsB,OAAA;AACtB,qIAAA,8BAA8B,OAAA;AAE/B,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,iDAAiE;AAAxD,+GAAA,cAAc,OAAA;AAAE,+GAAA,cAAc,OAAA;AACvC,iDAAiD;AAAxC,+GAAA,cAAc,OAAA"}
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,OAAA;AAEhB,yCAA8D;AAArD,sHAAA,4BAA4B,OAAA;AACrC,uCAA4C;AAAnC,oGAAA,WAAW,OAAA;AACpB,2CAA+D;AAAtD,sGAAA,WAAW,OAAA;AAAE,0GAAA,eAAe,OAAA;AACrC,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,iDAAiE;AAAxD,+GAAA,cAAc,OAAA;AAAE,+GAAA,cAAc,OAAA;AACvC,iDAAiD;AAAxC,+GAAA,cAAc,OAAA;AAGvB,iDAMyB;AALxB,6GAAA,YAAY,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,90 @@
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 legacy_1 = require("./axios/legacy");
8
+ const request_1 = require("./axios/request");
9
+ const utils_1 = require("./axios/utils");
10
+ const binary_string_1 = require("./binary-string");
11
+ const parse_incoming_message_1 = require("./parse-incoming-message");
12
+ async function executeLegacyRequest(requestObject, ssrfBridge, logger, callbacks) {
13
+ let axiosConfig = {
14
+ maxBodyLength: Infinity,
15
+ maxContentLength: -1,
16
+ };
17
+ const url = (0, utils_1.resolveLegacyRequestUrl)(requestObject);
18
+ await (0, utils_1.validateUrlSsrf)(url, ssrfBridge);
19
+ axiosConfig = Object.assign(axiosConfig, await (0, legacy_1.buildAxiosConfigFromLegacyRequest)(requestObject, ssrfBridge));
20
+ (0, utils_1.throwIfDomainNotAllowed)(axiosConfig, requestObject.allowedDomains);
21
+ try {
22
+ const response = await (0, request_1.invokeAxios)(axiosConfig, requestObject.auth);
23
+ let body = response.data;
24
+ if (body instanceof node_http_1.IncomingMessage && axiosConfig.responseType === 'stream') {
25
+ (0, parse_incoming_message_1.parseIncomingMessage)(body);
26
+ }
27
+ else if (body === '') {
28
+ body = axiosConfig.responseType === 'arraybuffer' ? Buffer.alloc(0) : undefined;
29
+ }
30
+ await callbacks?.onFetched?.();
31
+ return requestObject.resolveWithFullResponse
32
+ ? {
33
+ body,
34
+ headers: { ...response.headers },
35
+ statusCode: response.status,
36
+ statusMessage: response.statusText,
37
+ request: response.request,
38
+ }
39
+ : body;
40
+ }
41
+ catch (error) {
42
+ const { config, response } = error;
43
+ if (error.isAxiosError) {
44
+ error.config = error.request = undefined;
45
+ const options = {};
46
+ for (const key of ['url', 'method', 'data', 'headers']) {
47
+ if (config && key in config) {
48
+ options[key] = config[key];
49
+ }
50
+ }
51
+ error.options = options;
52
+ if (response) {
53
+ logger.debug('Request proxied to Axios failed', { status: response.status });
54
+ let responseData = response.data;
55
+ if (Buffer.isBuffer(responseData) || responseData instanceof node_stream_1.Readable) {
56
+ responseData = await (0, binary_string_1.binaryToString)(responseData);
57
+ }
58
+ if (requestObject.simple === false) {
59
+ if (requestObject.resolveWithFullResponse) {
60
+ return {
61
+ body: responseData,
62
+ headers: response.headers,
63
+ statusCode: response.status,
64
+ statusMessage: response.statusText,
65
+ };
66
+ }
67
+ else {
68
+ return responseData;
69
+ }
70
+ }
71
+ error.message = `${response.status} - ${JSON.stringify(responseData)}`;
72
+ throw Object.assign(error, {
73
+ statusCode: response.status,
74
+ status: response.status,
75
+ error: responseData,
76
+ response: {
77
+ headers: response.headers,
78
+ status: response.status,
79
+ statusText: response.statusText,
80
+ },
81
+ });
82
+ }
83
+ else if ('rejectUnauthorized' in requestObject && error.code?.includes('CERT')) {
84
+ throw new n8n_workflow_1.NodeSslError(error);
85
+ }
86
+ }
87
+ throw error;
88
+ }
89
+ }
90
+ //# sourceMappingURL=legacy-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-request.js","sourceRoot":"","sources":["../../src/http/legacy-request.ts"],"names":[],"mappings":";;AAwCA,oDAuGC;AAtID,+CAA4C;AAC5C,yCAA4C;AAC5C,6CAAuC;AAEvC,2CAAmE;AACnE,6CAA8C;AAC9C,yCAAkG;AAClG,mDAAiD;AACjD,qEAAgE;AAuBzD,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,a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BACzB,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): 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,65 @@
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.startsWith('http://') || value.startsWith('https://');
18
+ }
19
+ function buildNodeAgents(proxy, ssrf, agentOptions) {
20
+ if (agentOptions?.lookup) {
21
+ throw new n8n_workflow_1.UnexpectedError('`agentOptions.lookup` is not supported: DNS resolution is managed by the SSRF policy. Remove it from `agentOptions`.');
22
+ }
23
+ const lookup = ssrf !== 'disabled' ? ssrf.createSecureLookup() : undefined;
24
+ if (proxy === false) {
25
+ return applyConnectionGuard({
26
+ httpAgent: new node_http_1.default.Agent({ ...agentOptions, lookup }),
27
+ httpsAgent: new node_https_1.default.Agent({ ...agentOptions, lookup }),
28
+ }, ssrf);
29
+ }
30
+ if (proxy === 'env') {
31
+ return applyConnectionGuard({
32
+ httpAgent: new env_proxy_http_agent_1.EnvProxyHttpAgent(lookup, agentOptions),
33
+ httpsAgent: new env_proxy_https_agent_1.EnvProxyHttpsAgent(lookup, agentOptions),
34
+ }, ssrf);
35
+ }
36
+ return {
37
+ httpAgent: new http_proxy_agent_1.HttpProxyAgent(proxy, { ...agentOptions }),
38
+ httpsAgent: new https_proxy_agent_1.HttpsProxyAgent(proxy, { ...agentOptions }),
39
+ };
40
+ }
41
+ function applyConnectionGuard(agents, ssrf) {
42
+ if (ssrf !== 'disabled') {
43
+ installConnectionGuard(agents.httpAgent, ssrf);
44
+ installConnectionGuard(agents.httpsAgent, ssrf);
45
+ }
46
+ return agents;
47
+ }
48
+ function installConnectionGuard(target, ssrf) {
49
+ const createConnection = target.createConnection.bind(target);
50
+ target.createConnection = (options, onConnect) => {
51
+ const host = options.host ?? options.hostname ?? undefined;
52
+ if (typeof host === 'string') {
53
+ const result = ssrf.validateConnectionHost(host);
54
+ if (!result.ok) {
55
+ if (onConnect) {
56
+ onConnect(result.error);
57
+ return undefined;
58
+ }
59
+ throw result.error;
60
+ }
61
+ }
62
+ return createConnection(options, onConnect);
63
+ };
64
+ }
65
+ //# 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,kDAEC;AAsCD,0CAuCC;AA+BD,wDAmBC;AAvJD,uDAAkD;AAClD,yDAAoD;AACpD,+CAA+C;AAC/C,0DAA6B;AAC7B,4DAA+B;AAG/B,iEAA2D;AAC3D,mEAA6D;AAc7D,SAAgB,mBAAmB,CAAC,KAAa;IAChD,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAA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M,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,42 @@
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 { type LegacyRequestCallbacks } from './legacy-request';
7
+ import type { NodeAgentOptions, ProxyOption, SsrfOption } from './node-agents';
8
+ import { SsrfProtectionService } from '../ssrf';
9
+ import { type CustomFetch, type TransportTimeoutOptions } from './undici/transport';
10
+ export interface HttpRequestClientOptions {
11
+ ssrf?: SsrfOption;
12
+ }
13
+ export interface HttpTransportOptions {
14
+ proxy?: ProxyOption;
15
+ ssrf?: SsrfOption;
16
+ timeouts?: TransportTimeoutOptions;
17
+ }
18
+ export interface HttpRequestClient {
19
+ request(options: IHttpRequestOptions & {
20
+ returnFullResponse: true;
21
+ }): Promise<IN8nHttpFullResponse>;
22
+ request(options: IHttpRequestOptions & {
23
+ returnFullResponse?: false;
24
+ }): Promise<IN8nHttpResponse>;
25
+ request(options: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
26
+ requestLegacy(options: IRequestOptions, callbacks?: LegacyRequestCallbacks): Promise<unknown>;
27
+ }
28
+ export interface HttpTransport {
29
+ asCustomFetch(): CustomFetch;
30
+ getDispatcher(): Dispatcher;
31
+ getNodeAgent(agentOptions?: NodeAgentOptions): {
32
+ httpAgent: http.Agent;
33
+ httpsAgent: https.Agent;
34
+ };
35
+ }
36
+ export declare class OutboundHttp {
37
+ private readonly ssrfProtection;
38
+ private readonly logger;
39
+ constructor(ssrfProtection: SsrfProtectionService, logger: Logger);
40
+ requests(options?: HttpRequestClientOptions): HttpRequestClient;
41
+ transport(options?: HttpTransportOptions): HttpTransport;
42
+ }
@@ -0,0 +1,56 @@
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 request_1 = require("./axios/request");
16
+ const legacy_request_1 = require("./legacy-request");
17
+ const node_agents_1 = require("./node-agents");
18
+ const ssrf_1 = require("../ssrf");
19
+ const transport_1 = require("./undici/transport");
20
+ let OutboundHttp = class OutboundHttp {
21
+ constructor(ssrfProtection, logger) {
22
+ this.ssrfProtection = ssrfProtection;
23
+ this.logger = logger;
24
+ }
25
+ requests(options) {
26
+ const ssrf = options?.ssrf ?? this.ssrfProtection;
27
+ const ssrfBridge = ssrf === 'disabled' ? undefined : ssrf;
28
+ return {
29
+ request: (async (requestOptions) => await (0, request_1.httpRequest)(requestOptions, ssrfBridge)),
30
+ requestLegacy: async (requestOptions, callbacks) => await (0, legacy_request_1.executeLegacyRequest)(requestOptions, ssrfBridge, this.logger, callbacks),
31
+ };
32
+ }
33
+ transport(options) {
34
+ const proxy = options?.proxy ?? 'env';
35
+ const ssrf = options?.ssrf ?? this.ssrfProtection;
36
+ const timeouts = options?.timeouts;
37
+ const lazyDispatcher = lazy(() => (0, transport_1.buildDispatcher)(proxy, ssrf, timeouts));
38
+ const lazyNodeAgents = lazy(() => (0, node_agents_1.buildNodeAgents)(proxy, ssrf));
39
+ return {
40
+ asCustomFetch: () => async (input, init) => await (0, transport_1.dispatchedFetch)(lazyDispatcher(), input, init),
41
+ getDispatcher: () => lazyDispatcher(),
42
+ getNodeAgent: (agentOptions) => agentOptions !== undefined ? (0, node_agents_1.buildNodeAgents)(proxy, ssrf, agentOptions) : lazyNodeAgents(),
43
+ };
44
+ }
45
+ };
46
+ exports.OutboundHttp = OutboundHttp;
47
+ exports.OutboundHttp = OutboundHttp = __decorate([
48
+ (0, di_1.Service)(),
49
+ __metadata("design:paramtypes", [ssrf_1.SsrfProtectionService,
50
+ backend_common_1.Logger])
51
+ ], OutboundHttp);
52
+ function lazy(factory) {
53
+ let cached;
54
+ return () => (cached ??= { value: factory() }).value;
55
+ }
56
+ //# sourceMappingURL=outbound-http.js.map
@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AAG,EAAE,CAAC,IAAA,6BAAe,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAEhE,OAAO;YACN,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC1C,MAAM,IAAA,2BAAe,EAAC,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;YACrD,aAAa,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE;YACrC,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;AAzCY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,YAAO,GAAE;qCAGyB,4BAAqB;QAC7B,uBAAM;GAHpB,YAAY,CAyCxB;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,12 @@
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 interface TransportTimeoutOptions {
6
+ headersTimeout?: number;
7
+ bodyTimeout?: number;
8
+ connectTimeout?: number;
9
+ }
10
+ export declare function buildDispatcher(proxy: ProxyOption, ssrf: SsrfOption, timeouts?: TransportTimeoutOptions): Dispatcher;
11
+ export declare function createSsrfInterceptor(bridge: SsrfBridge): Dispatcher.DispatcherComposeInterceptor;
12
+ export declare function dispatchedFetch(dispatcher: Dispatcher, input: RequestInfo | URL, init?: RequestInit): Promise<Response>;