n8n-core 2.25.2 → 2.26.1
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/binary-data/file-system.manager.d.ts +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/errors/error-reporter.js +2 -0
- package/dist/errors/error-reporter.js.map +1 -1
- package/dist/errors/workflow-has-issues.error.d.ts +2 -1
- package/dist/errors/workflow-has-issues.error.js +24 -2
- package/dist/errors/workflow-has-issues.error.js.map +1 -1
- package/dist/execution-engine/active-workflows.d.ts +3 -3
- package/dist/execution-engine/active-workflows.js +16 -16
- package/dist/execution-engine/active-workflows.js.map +1 -1
- package/dist/execution-engine/index.d.ts +5 -9
- package/dist/execution-engine/node-execution-context/base-execute-context.d.ts +8 -2
- package/dist/execution-engine/node-execution-context/base-execute-context.js +1 -1
- package/dist/execution-engine/node-execution-context/base-execute-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/credentials-test-context.js +2 -2
- package/dist/execution-engine/node-execution-context/credentials-test-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/index.d.ts +0 -1
- package/dist/execution-engine/node-execution-context/index.js +1 -3
- package/dist/execution-engine/node-execution-context/index.js.map +1 -1
- package/dist/execution-engine/node-execution-context/local-load-options-context.js +3 -2
- package/dist/execution-engine/node-execution-context/local-load-options-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/node-execution-context.d.ts +9 -3
- package/dist/execution-engine/node-execution-context/node-execution-context.js +3 -1
- package/dist/execution-engine/node-execution-context/node-execution-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helper-functions.d.ts +1 -18
- package/dist/execution-engine/node-execution-context/utils/request-helper-functions.js +3 -1058
- package/dist/execution-engine/node-execution-context/utils/request-helper-functions.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/authentication.d.ts +3 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/authentication.js +117 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/authentication.js.map +1 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-utils.d.ts +4 -2
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-utils.js +18 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-utils.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/factory.d.ts +2 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/factory.js +78 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/factory.js.map +1 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/http-request.d.ts +7 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/http-request.js +146 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/http-request.js.map +1 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/index.d.ts +2 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/index.js +4 -14
- package/dist/execution-engine/node-execution-context/utils/request-helpers/index.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/legacy-request-adapter.d.ts +5 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/legacy-request-adapter.js +301 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/legacy-request-adapter.js.map +1 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/oauth.d.ts +5 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/oauth.js +288 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/oauth.js.map +1 -0
- package/dist/execution-engine/node-execution-context/utils/{outbound-user-agent.js → request-helpers/outbound-user-agent.js} +2 -2
- package/dist/execution-engine/node-execution-context/utils/request-helpers/outbound-user-agent.js.map +1 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/pagination.d.ts +4 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/pagination.js +165 -0
- package/dist/execution-engine/node-execution-context/utils/request-helpers/pagination.js.map +1 -0
- package/dist/execution-engine/triggers-and-pollers.d.ts +2 -2
- package/dist/execution-engine/triggers-and-pollers.js +2 -2
- package/dist/execution-engine/triggers-and-pollers.js.map +1 -1
- package/dist/execution-engine/workflow-execute.js +24 -3
- package/dist/execution-engine/workflow-execute.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/nodes-loader/directory-loader.js +8 -2
- package/dist/nodes-loader/directory-loader.js.map +1 -1
- package/dist/ssrf/dns-resolver.d.ts +13 -0
- package/dist/ssrf/dns-resolver.js +93 -0
- package/dist/ssrf/dns-resolver.js.map +1 -0
- package/dist/ssrf/hostname-matcher.d.ts +6 -0
- package/dist/ssrf/hostname-matcher.js +38 -0
- package/dist/ssrf/hostname-matcher.js.map +1 -0
- package/dist/ssrf/in-memory-dns-cache.service.d.ts +11 -0
- package/dist/ssrf/in-memory-dns-cache.service.js +61 -0
- package/dist/ssrf/in-memory-dns-cache.service.js.map +1 -0
- package/dist/ssrf/index.d.ts +5 -0
- package/dist/ssrf/index.js +10 -0
- package/dist/ssrf/index.js.map +1 -0
- package/dist/ssrf/ip-range-builder.d.ts +10 -0
- package/dist/ssrf/ip-range-builder.js +52 -0
- package/dist/ssrf/ip-range-builder.js.map +1 -0
- package/dist/ssrf/ssrf-blocked-ip.error.d.ts +6 -0
- package/dist/ssrf/ssrf-blocked-ip.error.js +21 -0
- package/dist/ssrf/ssrf-blocked-ip.error.js.map +1 -0
- package/dist/ssrf/ssrf-protection.service.d.ts +30 -0
- package/dist/ssrf/ssrf-protection.service.js +159 -0
- package/dist/ssrf/ssrf-protection.service.js.map +1 -0
- package/package.json +21 -19
- package/dist/execution-engine/node-execution-context/utils/outbound-user-agent.js.map +0 -1
- /package/dist/execution-engine/node-execution-context/utils/{outbound-user-agent.d.ts → request-helpers/outbound-user-agent.d.ts} +0 -0
|
@@ -10,1064 +10,9 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
15
|
};
|
|
38
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
exports.invokeAxios = invokeAxios;
|
|
41
|
-
exports.parseRequestObject = parseRequestObject;
|
|
42
|
-
exports.proxyRequestToAxios = proxyRequestToAxios;
|
|
43
|
-
exports.convertN8nRequestToAxios = convertN8nRequestToAxios;
|
|
44
|
-
exports.httpRequest = httpRequest;
|
|
45
|
-
exports.applyPaginationRequestData = applyPaginationRequestData;
|
|
46
|
-
exports.requestOAuth2 = requestOAuth2;
|
|
47
|
-
exports.requestOAuth1 = requestOAuth1;
|
|
48
|
-
exports.refreshOAuth2Token = refreshOAuth2Token;
|
|
49
|
-
exports.httpRequestWithAuthentication = httpRequestWithAuthentication;
|
|
50
|
-
exports.requestWithAuthentication = requestWithAuthentication;
|
|
51
|
-
const backend_common_1 = require("@n8n/backend-common");
|
|
52
|
-
const client_oauth2_1 = require("@n8n/client-oauth2");
|
|
53
|
-
const di_1 = require("@n8n/di");
|
|
54
|
-
const axios_1 = __importDefault(require("axios"));
|
|
55
|
-
const crypto_1 = __importStar(require("crypto"));
|
|
56
|
-
const http_1 = require("http");
|
|
57
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
58
|
-
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
59
|
-
const merge_1 = __importDefault(require("lodash/merge"));
|
|
60
|
-
const pick_1 = __importDefault(require("lodash/pick"));
|
|
61
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
62
|
-
const oauth_1_0a_1 = __importDefault(require("oauth-1.0a"));
|
|
63
|
-
const qs_1 = require("qs");
|
|
64
|
-
const stream_1 = require("stream");
|
|
65
|
-
const eval_mock_helpers_1 = require("../../../execution-engine/eval-mock-helpers");
|
|
66
|
-
const binary_helper_functions_1 = require("./binary-helper-functions");
|
|
67
|
-
const outbound_user_agent_1 = require("./outbound-user-agent");
|
|
68
|
-
const parse_incoming_message_1 = require("./parse-incoming-message");
|
|
69
|
-
require("./request-helpers/axios-config");
|
|
70
|
-
const request_helpers_1 = require("./request-helpers");
|
|
71
|
-
const axios_utils_1 = require("./request-helpers/axios-utils");
|
|
72
|
-
async function invokeAxios(axiosConfig, authOptions = {}) {
|
|
73
|
-
try {
|
|
74
|
-
return await (0, axios_1.default)(axiosConfig);
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
if (authOptions.sendImmediately !== false || !(error instanceof axios_1.default.AxiosError))
|
|
78
|
-
throw error;
|
|
79
|
-
const { response } = error;
|
|
80
|
-
if (response?.status !== 401 || !response.headers['www-authenticate']?.includes('nonce')) {
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
const { auth } = axiosConfig;
|
|
84
|
-
delete axiosConfig.auth;
|
|
85
|
-
axiosConfig = (0, request_helpers_1.digestAuthAxiosConfig)(axiosConfig, response, auth);
|
|
86
|
-
return await (0, axios_1.default)(axiosConfig);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function parseRequestObject(requestObject, ssrfBridge) {
|
|
90
|
-
const axiosConfig = {};
|
|
91
|
-
if (requestObject.headers !== undefined) {
|
|
92
|
-
axiosConfig.headers = requestObject.headers;
|
|
93
|
-
}
|
|
94
|
-
const contentTypeHeaderKeyName = axiosConfig.headers &&
|
|
95
|
-
Object.keys(axiosConfig.headers).find((headerName) => headerName.toLowerCase() === 'content-type');
|
|
96
|
-
const contentType = contentTypeHeaderKeyName &&
|
|
97
|
-
axiosConfig.headers?.[contentTypeHeaderKeyName];
|
|
98
|
-
if (contentType === 'application/x-www-form-urlencoded' && requestObject.formData === undefined) {
|
|
99
|
-
if (typeof requestObject.body === 'string') {
|
|
100
|
-
axiosConfig.data = requestObject.body;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
const allData = Object.assign(requestObject.body || {}, requestObject.form || {});
|
|
104
|
-
if (requestObject.useQuerystring === true) {
|
|
105
|
-
axiosConfig.data = (0, qs_1.stringify)(allData, { arrayFormat: 'repeat' });
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
axiosConfig.data = (0, qs_1.stringify)(allData);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else if (contentType?.includes('multipart/form-data')) {
|
|
113
|
-
if (requestObject.formData !== undefined && (0, request_helpers_1.isFormDataInstance)(requestObject.formData)) {
|
|
114
|
-
axiosConfig.data = requestObject.formData;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
const allData = {
|
|
118
|
-
...requestObject.body,
|
|
119
|
-
...requestObject.formData,
|
|
120
|
-
};
|
|
121
|
-
axiosConfig.data = (0, request_helpers_1.createFormDataObject)(allData);
|
|
122
|
-
}
|
|
123
|
-
delete axiosConfig.headers?.[contentTypeHeaderKeyName];
|
|
124
|
-
const headers = axiosConfig.data.getHeaders();
|
|
125
|
-
axiosConfig.headers = Object.assign(axiosConfig.headers || {}, headers);
|
|
126
|
-
await (0, request_helpers_1.generateContentLengthHeader)(axiosConfig);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
if (requestObject.form !== undefined && requestObject.body === undefined) {
|
|
130
|
-
axiosConfig.data =
|
|
131
|
-
typeof requestObject.form === 'string'
|
|
132
|
-
? (0, qs_1.stringify)(requestObject.form, { format: 'RFC3986' })
|
|
133
|
-
: (0, qs_1.stringify)(requestObject.form).toString();
|
|
134
|
-
if (axiosConfig.headers !== undefined) {
|
|
135
|
-
const headerName = (0, request_helpers_1.searchForHeader)(axiosConfig, 'content-type');
|
|
136
|
-
if (headerName) {
|
|
137
|
-
delete axiosConfig.headers[headerName];
|
|
138
|
-
}
|
|
139
|
-
axiosConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
axiosConfig.headers = {
|
|
143
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else if (requestObject.formData !== undefined) {
|
|
148
|
-
if (axiosConfig.headers !== undefined) {
|
|
149
|
-
const headers = Object.keys(axiosConfig.headers);
|
|
150
|
-
headers.forEach((header) => {
|
|
151
|
-
if (header.toLowerCase() === 'content-type') {
|
|
152
|
-
delete axiosConfig.headers?.[header];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if ((0, request_helpers_1.isFormDataInstance)(requestObject.formData)) {
|
|
157
|
-
axiosConfig.data = requestObject.formData;
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
axiosConfig.data = (0, request_helpers_1.createFormDataObject)(requestObject.formData);
|
|
161
|
-
}
|
|
162
|
-
const headers = axiosConfig.data.getHeaders();
|
|
163
|
-
axiosConfig.headers = Object.assign(axiosConfig.headers || {}, headers);
|
|
164
|
-
await (0, request_helpers_1.generateContentLengthHeader)(axiosConfig);
|
|
165
|
-
}
|
|
166
|
-
else if (requestObject.body !== undefined) {
|
|
167
|
-
if (requestObject.form !== undefined && requestObject.body) {
|
|
168
|
-
requestObject.body = Object.assign(requestObject.body, requestObject.form);
|
|
169
|
-
}
|
|
170
|
-
axiosConfig.data = requestObject.body;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (requestObject.uri !== undefined) {
|
|
174
|
-
axiosConfig.url = requestObject.uri?.toString();
|
|
175
|
-
}
|
|
176
|
-
if (requestObject.url !== undefined) {
|
|
177
|
-
axiosConfig.url = requestObject.url?.toString();
|
|
178
|
-
}
|
|
179
|
-
if (requestObject.baseURL !== undefined) {
|
|
180
|
-
axiosConfig.baseURL = requestObject.baseURL?.toString();
|
|
181
|
-
}
|
|
182
|
-
if (requestObject.method !== undefined) {
|
|
183
|
-
axiosConfig.method = requestObject.method;
|
|
184
|
-
}
|
|
185
|
-
if (requestObject.qs !== undefined && Object.keys(requestObject.qs).length > 0) {
|
|
186
|
-
axiosConfig.params = requestObject.qs;
|
|
187
|
-
}
|
|
188
|
-
function hasArrayFormatOptions(arg) {
|
|
189
|
-
if (typeof arg.qsStringifyOptions === 'object' &&
|
|
190
|
-
arg.qsStringifyOptions !== null &&
|
|
191
|
-
!Array.isArray(arg.qsStringifyOptions) &&
|
|
192
|
-
'arrayFormat' in arg.qsStringifyOptions) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
if (requestObject.useQuerystring === true ||
|
|
198
|
-
(hasArrayFormatOptions(requestObject) &&
|
|
199
|
-
requestObject.qsStringifyOptions.arrayFormat === 'repeat')) {
|
|
200
|
-
axiosConfig.paramsSerializer = (params) => {
|
|
201
|
-
return (0, qs_1.stringify)(params, { arrayFormat: 'repeat' });
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
else if (requestObject.useQuerystring === false) {
|
|
205
|
-
axiosConfig.paramsSerializer = (params) => {
|
|
206
|
-
return (0, qs_1.stringify)(params, { arrayFormat: 'indices' });
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
if (hasArrayFormatOptions(requestObject) &&
|
|
210
|
-
requestObject.qsStringifyOptions.arrayFormat === 'brackets') {
|
|
211
|
-
axiosConfig.paramsSerializer = (params) => {
|
|
212
|
-
return (0, qs_1.stringify)(params, { arrayFormat: 'brackets' });
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
if (requestObject.auth !== undefined) {
|
|
216
|
-
if (requestObject.auth.bearer !== undefined) {
|
|
217
|
-
axiosConfig.headers = Object.assign(axiosConfig.headers || {}, {
|
|
218
|
-
Authorization: `Bearer ${requestObject.auth.bearer}`,
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
const authObj = requestObject.auth;
|
|
223
|
-
axiosConfig.auth = {
|
|
224
|
-
username: (authObj.user || authObj.username),
|
|
225
|
-
password: (authObj.password || authObj.pass),
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (requestObject.json === true) {
|
|
230
|
-
const acceptHeaderExists = axiosConfig.headers === undefined
|
|
231
|
-
? false
|
|
232
|
-
: Object.keys(axiosConfig.headers)
|
|
233
|
-
.map((headerKey) => headerKey.toLowerCase())
|
|
234
|
-
.includes('accept');
|
|
235
|
-
if (!acceptHeaderExists) {
|
|
236
|
-
axiosConfig.headers = Object.assign(axiosConfig.headers || {}, {
|
|
237
|
-
Accept: 'application/json',
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (requestObject.json === false || requestObject.json === undefined) {
|
|
242
|
-
axiosConfig.transformResponse = (res) => res;
|
|
243
|
-
}
|
|
244
|
-
const { method } = requestObject;
|
|
245
|
-
if ((requestObject.followRedirect !== false &&
|
|
246
|
-
(!method || method === 'GET' || method === 'HEAD')) ||
|
|
247
|
-
requestObject.followAllRedirects) {
|
|
248
|
-
axiosConfig.maxRedirects = requestObject.maxRedirects;
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
axiosConfig.maxRedirects = 0;
|
|
252
|
-
}
|
|
253
|
-
const host = (0, request_helpers_1.getHostFromRequestObject)(requestObject);
|
|
254
|
-
const agentOptions = { ...requestObject.agentOptions };
|
|
255
|
-
if (host) {
|
|
256
|
-
agentOptions.servername = host;
|
|
257
|
-
}
|
|
258
|
-
if (requestObject.rejectUnauthorized === false) {
|
|
259
|
-
agentOptions.rejectUnauthorized = false;
|
|
260
|
-
agentOptions.secureOptions = crypto_1.default.constants.SSL_OP_LEGACY_SERVER_CONNECT;
|
|
261
|
-
}
|
|
262
|
-
if (requestObject.timeout !== undefined) {
|
|
263
|
-
axiosConfig.timeout = requestObject.timeout;
|
|
264
|
-
}
|
|
265
|
-
const secureLookup = ssrfBridge?.createSecureLookup();
|
|
266
|
-
(0, request_helpers_1.setAxiosAgents)(axiosConfig, agentOptions, requestObject.proxy, secureLookup);
|
|
267
|
-
axiosConfig.beforeRedirect = (0, request_helpers_1.getBeforeRedirectFn)(agentOptions, axiosConfig, requestObject.proxy, requestObject.sendCredentialsOnCrossOriginRedirect ?? true, requestObject.allowedDomains, ssrfBridge);
|
|
268
|
-
if (requestObject.useStream) {
|
|
269
|
-
axiosConfig.responseType = 'stream';
|
|
270
|
-
}
|
|
271
|
-
else if (requestObject.encoding === null) {
|
|
272
|
-
axiosConfig.responseType = 'arraybuffer';
|
|
273
|
-
}
|
|
274
|
-
const allHeaders = axiosConfig.headers ? Object.keys(axiosConfig.headers) : [];
|
|
275
|
-
if (!allHeaders.some((headerKey) => headerKey.toLowerCase() === 'accept')) {
|
|
276
|
-
axiosConfig.headers = Object.assign(axiosConfig.headers || {}, { accept: '*/*' });
|
|
277
|
-
}
|
|
278
|
-
if (requestObject.json !== false &&
|
|
279
|
-
axiosConfig.data !== undefined &&
|
|
280
|
-
axiosConfig.data !== '' &&
|
|
281
|
-
!(axiosConfig.data instanceof Buffer) &&
|
|
282
|
-
!allHeaders.some((headerKey) => headerKey.toLowerCase() === 'content-type')) {
|
|
283
|
-
axiosConfig.headers = Object.assign(axiosConfig.headers || {}, {
|
|
284
|
-
'content-type': 'application/json',
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
if (requestObject.simple === false) {
|
|
288
|
-
axiosConfig.validateStatus = () => true;
|
|
289
|
-
}
|
|
290
|
-
(0, outbound_user_agent_1.applyDefaultOutboundUserAgent)(axiosConfig);
|
|
291
|
-
return axiosConfig;
|
|
292
|
-
}
|
|
293
|
-
async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject, options) {
|
|
294
|
-
let axiosConfig = {
|
|
295
|
-
maxBodyLength: Infinity,
|
|
296
|
-
maxContentLength: -1,
|
|
297
|
-
};
|
|
298
|
-
let configObject;
|
|
299
|
-
if (typeof uriOrObject === 'string') {
|
|
300
|
-
configObject = { uri: uriOrObject, ...options };
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
configObject = uriOrObject ?? {};
|
|
304
|
-
}
|
|
305
|
-
const ssrfBridge = additionalData?.ssrfBridge;
|
|
306
|
-
const url = resolveLegacyRequestUrl(configObject);
|
|
307
|
-
await validateUrlSsrf(url, ssrfBridge);
|
|
308
|
-
axiosConfig = Object.assign(axiosConfig, await parseRequestObject(configObject, ssrfBridge));
|
|
309
|
-
(0, axios_utils_1.throwIfDomainNotAllowed)(axiosConfig, configObject.allowedDomains);
|
|
310
|
-
try {
|
|
311
|
-
const response = await invokeAxios(axiosConfig, configObject.auth);
|
|
312
|
-
let body = response.data;
|
|
313
|
-
if (body instanceof http_1.IncomingMessage && axiosConfig.responseType === 'stream') {
|
|
314
|
-
(0, parse_incoming_message_1.parseIncomingMessage)(body);
|
|
315
|
-
}
|
|
316
|
-
else if (body === '') {
|
|
317
|
-
body = axiosConfig.responseType === 'arraybuffer' ? Buffer.alloc(0) : undefined;
|
|
318
|
-
}
|
|
319
|
-
await additionalData?.hooks?.runHook('nodeFetchedData', [workflow?.id, node]);
|
|
320
|
-
return configObject.resolveWithFullResponse
|
|
321
|
-
? {
|
|
322
|
-
body,
|
|
323
|
-
headers: { ...response.headers },
|
|
324
|
-
statusCode: response.status,
|
|
325
|
-
statusMessage: response.statusText,
|
|
326
|
-
request: response.request,
|
|
327
|
-
}
|
|
328
|
-
: body;
|
|
329
|
-
}
|
|
330
|
-
catch (error) {
|
|
331
|
-
const { config, response } = error;
|
|
332
|
-
if (error.isAxiosError) {
|
|
333
|
-
error.config = error.request = undefined;
|
|
334
|
-
error.options = (0, pick_1.default)(config ?? {}, ['url', 'method', 'data', 'headers']);
|
|
335
|
-
if (response) {
|
|
336
|
-
di_1.Container.get(backend_common_1.Logger).debug('Request proxied to Axios failed', { status: response.status });
|
|
337
|
-
let responseData = response.data;
|
|
338
|
-
if (Buffer.isBuffer(responseData) || responseData instanceof stream_1.Readable) {
|
|
339
|
-
responseData = await (0, binary_helper_functions_1.binaryToString)(responseData);
|
|
340
|
-
}
|
|
341
|
-
if (configObject.simple === false) {
|
|
342
|
-
if (configObject.resolveWithFullResponse) {
|
|
343
|
-
return {
|
|
344
|
-
body: responseData,
|
|
345
|
-
headers: response.headers,
|
|
346
|
-
statusCode: response.status,
|
|
347
|
-
statusMessage: response.statusText,
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
return responseData;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
error.message = `${response.status} - ${JSON.stringify(responseData)}`;
|
|
355
|
-
throw Object.assign(error, {
|
|
356
|
-
statusCode: response.status,
|
|
357
|
-
status: response.status,
|
|
358
|
-
error: responseData,
|
|
359
|
-
response: (0, pick_1.default)(response, ['headers', 'status', 'statusText']),
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
else if ('rejectUnauthorized' in configObject && error.code?.includes('CERT')) {
|
|
363
|
-
throw new n8n_workflow_1.NodeSslError(error);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
throw error;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
function convertN8nRequestToAxios(n8nRequest, ssrfBridge) {
|
|
370
|
-
const { headers, method, timeout, auth, proxy, url } = n8nRequest;
|
|
371
|
-
const axiosRequest = {
|
|
372
|
-
headers: headers ?? {},
|
|
373
|
-
method,
|
|
374
|
-
timeout,
|
|
375
|
-
auth,
|
|
376
|
-
url,
|
|
377
|
-
maxBodyLength: Infinity,
|
|
378
|
-
maxContentLength: Infinity,
|
|
379
|
-
};
|
|
380
|
-
axiosRequest.params = n8nRequest.qs;
|
|
381
|
-
if (n8nRequest.abortSignal) {
|
|
382
|
-
axiosRequest.signal = n8nRequest.abortSignal;
|
|
383
|
-
}
|
|
384
|
-
if (n8nRequest.baseURL !== undefined) {
|
|
385
|
-
axiosRequest.baseURL = n8nRequest.baseURL;
|
|
386
|
-
}
|
|
387
|
-
if (n8nRequest.disableFollowRedirect === true) {
|
|
388
|
-
axiosRequest.maxRedirects = 0;
|
|
389
|
-
}
|
|
390
|
-
if (n8nRequest.encoding !== undefined) {
|
|
391
|
-
axiosRequest.responseType = n8nRequest.encoding;
|
|
392
|
-
}
|
|
393
|
-
const host = (0, request_helpers_1.getHostFromRequestObject)(n8nRequest);
|
|
394
|
-
const agentOptions = { ...n8nRequest.agentOptions };
|
|
395
|
-
if (host) {
|
|
396
|
-
agentOptions.servername = host;
|
|
397
|
-
}
|
|
398
|
-
if (n8nRequest.skipSslCertificateValidation === true) {
|
|
399
|
-
agentOptions.rejectUnauthorized = false;
|
|
400
|
-
}
|
|
401
|
-
const secureLookup = ssrfBridge?.createSecureLookup();
|
|
402
|
-
(0, request_helpers_1.setAxiosAgents)(axiosRequest, agentOptions, proxy, secureLookup);
|
|
403
|
-
axiosRequest.beforeRedirect = (0, request_helpers_1.getBeforeRedirectFn)(agentOptions, axiosRequest, n8nRequest.proxy, n8nRequest.sendCredentialsOnCrossOriginRedirect ?? true, n8nRequest.allowedDomains, ssrfBridge);
|
|
404
|
-
if (n8nRequest.arrayFormat !== undefined) {
|
|
405
|
-
axiosRequest.paramsSerializer = (params) => {
|
|
406
|
-
return (0, qs_1.stringify)(params, { arrayFormat: n8nRequest.arrayFormat });
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
const { body } = n8nRequest;
|
|
410
|
-
if (body) {
|
|
411
|
-
const existingContentTypeHeaderKey = (0, request_helpers_1.searchForHeader)(axiosRequest, 'content-type');
|
|
412
|
-
if (existingContentTypeHeaderKey === undefined) {
|
|
413
|
-
axiosRequest.headers = axiosRequest.headers || {};
|
|
414
|
-
if ((0, request_helpers_1.isFormDataInstance)(body)) {
|
|
415
|
-
axiosRequest.headers = {
|
|
416
|
-
...axiosRequest.headers,
|
|
417
|
-
...body.getHeaders(),
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
else if (body instanceof URLSearchParams) {
|
|
421
|
-
axiosRequest.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
else if (axiosRequest.headers?.[existingContentTypeHeaderKey] === 'application/x-www-form-urlencoded') {
|
|
425
|
-
axiosRequest.data = new URLSearchParams(n8nRequest.body);
|
|
426
|
-
}
|
|
427
|
-
if (typeof body === 'string' || (typeof body === 'object' && !(0, n8n_workflow_1.isObjectEmpty)(body))) {
|
|
428
|
-
axiosRequest.data = body;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
if (n8nRequest.json) {
|
|
432
|
-
const key = (0, request_helpers_1.searchForHeader)(axiosRequest, 'accept');
|
|
433
|
-
if (!key) {
|
|
434
|
-
axiosRequest.headers = {
|
|
435
|
-
...axiosRequest.headers,
|
|
436
|
-
Accept: 'application/json',
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
(0, outbound_user_agent_1.applyDefaultOutboundUserAgent)(axiosRequest);
|
|
441
|
-
if (n8nRequest.ignoreHttpStatusErrors) {
|
|
442
|
-
const ignoreHttpStatusErrors = n8nRequest.ignoreHttpStatusErrors;
|
|
443
|
-
if ((0, request_helpers_1.isIgnoreStatusErrorConfig)(ignoreHttpStatusErrors)) {
|
|
444
|
-
axiosRequest.validateStatus = (status) => {
|
|
445
|
-
return !ignoreHttpStatusErrors.except.includes(status);
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
axiosRequest.validateStatus = () => true;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return axiosRequest;
|
|
453
|
-
}
|
|
454
|
-
async function validateUrlSsrf(url, ssrfBridge) {
|
|
455
|
-
if (!ssrfBridge || !url)
|
|
456
|
-
return;
|
|
457
|
-
const parsed = (0, request_helpers_1.tryParseUrl)(url);
|
|
458
|
-
if (!parsed)
|
|
459
|
-
return;
|
|
460
|
-
const result = await ssrfBridge.validateUrl(parsed);
|
|
461
|
-
if (!result.ok) {
|
|
462
|
-
throw result.error;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
function resolveLegacyRequestUrl(requestObject) {
|
|
466
|
-
const rawUrl = requestObject.uri?.toString() ?? requestObject.url?.toString();
|
|
467
|
-
const baseURL = requestObject.baseURL?.toString();
|
|
468
|
-
return (0, request_helpers_1.buildTargetUrl)(rawUrl, baseURL) ?? rawUrl;
|
|
469
|
-
}
|
|
470
|
-
const NoBodyHttpMethods = ['GET', 'HEAD', 'OPTIONS'];
|
|
471
|
-
const removeEmptyBody = (requestOptions) => {
|
|
472
|
-
const method = requestOptions.method || 'GET';
|
|
473
|
-
if (NoBodyHttpMethods.includes(method) && (0, isEmpty_1.default)(requestOptions.body)) {
|
|
474
|
-
delete requestOptions.body;
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
exports.removeEmptyBody = removeEmptyBody;
|
|
478
|
-
async function httpRequest(requestOptions, ssrfBridge) {
|
|
479
|
-
(0, exports.removeEmptyBody)(requestOptions);
|
|
480
|
-
const url = (0, request_helpers_1.buildTargetUrl)(requestOptions.url, requestOptions.baseURL) ?? requestOptions.url;
|
|
481
|
-
await validateUrlSsrf(url, ssrfBridge);
|
|
482
|
-
const axiosRequest = convertN8nRequestToAxios(requestOptions, ssrfBridge);
|
|
483
|
-
if (axiosRequest.data === undefined ||
|
|
484
|
-
(axiosRequest.method !== undefined && axiosRequest.method.toUpperCase() === 'GET')) {
|
|
485
|
-
delete axiosRequest.data;
|
|
486
|
-
}
|
|
487
|
-
(0, axios_utils_1.throwIfDomainNotAllowed)(axiosRequest, requestOptions.allowedDomains);
|
|
488
|
-
const result = await invokeAxios(axiosRequest, requestOptions.auth);
|
|
489
|
-
if (requestOptions.returnFullResponse) {
|
|
490
|
-
return {
|
|
491
|
-
body: result.data,
|
|
492
|
-
headers: result.headers,
|
|
493
|
-
statusCode: result.status,
|
|
494
|
-
statusMessage: result.statusText,
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
return result.data;
|
|
498
|
-
}
|
|
499
|
-
function applyPaginationRequestData(requestData, paginationRequestData) {
|
|
500
|
-
const preparedPaginationData = {
|
|
501
|
-
...paginationRequestData,
|
|
502
|
-
uri: paginationRequestData.url,
|
|
503
|
-
};
|
|
504
|
-
if ('formData' in requestData) {
|
|
505
|
-
preparedPaginationData.formData = paginationRequestData.body;
|
|
506
|
-
delete preparedPaginationData.body;
|
|
507
|
-
}
|
|
508
|
-
else if ('form' in requestData) {
|
|
509
|
-
preparedPaginationData.form = paginationRequestData.body;
|
|
510
|
-
delete preparedPaginationData.body;
|
|
511
|
-
}
|
|
512
|
-
return (0, merge_1.default)({}, requestData, preparedPaginationData);
|
|
513
|
-
}
|
|
514
|
-
function createOAuth2Client(credentials) {
|
|
515
|
-
const scopes = credentials.scope
|
|
516
|
-
?.split(' ')
|
|
517
|
-
.map((s) => s.trim())
|
|
518
|
-
.filter(Boolean);
|
|
519
|
-
return new client_oauth2_1.ClientOAuth2({
|
|
520
|
-
clientId: credentials.clientId,
|
|
521
|
-
clientSecret: credentials.clientSecret,
|
|
522
|
-
accessTokenUri: credentials.accessTokenUrl,
|
|
523
|
-
scopes: scopes?.length ? scopes : undefined,
|
|
524
|
-
ignoreSSLIssues: credentials.ignoreSSLIssues,
|
|
525
|
-
authentication: credentials.authentication ?? 'header',
|
|
526
|
-
...(credentials.additionalBodyProperties && {
|
|
527
|
-
additionalBodyProperties: (0, n8n_workflow_1.jsonParse)(credentials.additionalBodyProperties, {
|
|
528
|
-
fallbackValue: {},
|
|
529
|
-
}),
|
|
530
|
-
}),
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
function buildSigningToken(client, tokenData, oAuth2Options) {
|
|
534
|
-
const accessToken = (0, get_1.default)(tokenData, oAuth2Options?.property) || tokenData.accessToken;
|
|
535
|
-
const refreshToken = tokenData.refreshToken;
|
|
536
|
-
return client.createToken({
|
|
537
|
-
...tokenData,
|
|
538
|
-
...(accessToken ? { access_token: accessToken } : {}),
|
|
539
|
-
...(refreshToken ? { refresh_token: refreshToken } : {}),
|
|
540
|
-
}, oAuth2Options?.tokenType || tokenData.tokenType);
|
|
541
|
-
}
|
|
542
|
-
async function decryptOAuth2TokenDataIfConfigured(additionalData, tokenData, jweEnabled) {
|
|
543
|
-
if (!jweEnabled)
|
|
544
|
-
return tokenData;
|
|
545
|
-
const proxy = additionalData['oauth-jwe']?.oauthJweProxyProvider;
|
|
546
|
-
if (!proxy || !tokenData)
|
|
547
|
-
return tokenData;
|
|
548
|
-
return await proxy.decryptOAuth2TokenData(tokenData);
|
|
549
|
-
}
|
|
550
|
-
async function refreshOrFetchToken(ctx) {
|
|
551
|
-
const { credentials, token, credentialsType, node, additionalData, oAuth2Options, logger, helpers, } = ctx;
|
|
552
|
-
const tokenRefreshOptions = {};
|
|
553
|
-
if (oAuth2Options?.includeCredentialsOnRefreshOnBody) {
|
|
554
|
-
const body = {
|
|
555
|
-
client_id: credentials.clientId,
|
|
556
|
-
...(credentials.grantType === 'authorizationCode' && {
|
|
557
|
-
client_secret: credentials.clientSecret,
|
|
558
|
-
}),
|
|
559
|
-
};
|
|
560
|
-
tokenRefreshOptions.body = body;
|
|
561
|
-
tokenRefreshOptions.headers = { Authorization: '' };
|
|
562
|
-
}
|
|
563
|
-
logger.debug(`OAuth2 token for "${credentialsType}" used by node "${node.name}" expired. Revalidating.`);
|
|
564
|
-
let newToken;
|
|
565
|
-
if (credentials.grantType === 'clientCredentials') {
|
|
566
|
-
newToken = await token.client.credentials.getToken();
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
newToken = await token.refresh(tokenRefreshOptions);
|
|
570
|
-
}
|
|
571
|
-
logger.debug(`OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`);
|
|
572
|
-
const refreshedTokenData = await decryptOAuth2TokenDataIfConfigured(additionalData, newToken.data, credentials.jweEnabled === true);
|
|
573
|
-
credentials.oauthTokenData = refreshedTokenData;
|
|
574
|
-
const preAuthData = await additionalData.credentialsHelper.runPreAuthentication({ helpers }, credentials, credentialsType);
|
|
575
|
-
let signingToken = newToken;
|
|
576
|
-
if (preAuthData) {
|
|
577
|
-
Object.assign(credentials, preAuthData);
|
|
578
|
-
signingToken = buildSigningToken(token.client, credentials.oauthTokenData, oAuth2Options);
|
|
579
|
-
}
|
|
580
|
-
if (!node.credentials?.[credentialsType]) {
|
|
581
|
-
throw new n8n_workflow_1.ApplicationError('Node does not have credential type', {
|
|
582
|
-
extra: { nodeName: node.name, credentialType: credentialsType },
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
const nodeCredentials = node.credentials[credentialsType];
|
|
586
|
-
await additionalData.credentialsHelper.updateCredentialsOauthTokenData(nodeCredentials, credentialsType, credentials, additionalData);
|
|
587
|
-
return signingToken;
|
|
588
|
-
}
|
|
589
|
-
function resolveTokenExpiredStatusCode(oAuth2Options, credentials) {
|
|
590
|
-
return credentials?.tokenExpiredStatusCode ?? oAuth2Options?.tokenExpiredStatusCode ?? 401;
|
|
591
|
-
}
|
|
592
|
-
async function requestOAuth2(credentialsType, requestOptions, node, additionalData, oAuth2Options, isN8nRequest = false) {
|
|
593
|
-
(0, exports.removeEmptyBody)(requestOptions);
|
|
594
|
-
const credentials = (await this.getCredentials(credentialsType));
|
|
595
|
-
if (credentials.grantType === 'authorizationCode' && credentials.oauthTokenData === undefined) {
|
|
596
|
-
throw new n8n_workflow_1.ApplicationError('OAuth credentials not connected');
|
|
597
|
-
}
|
|
598
|
-
const oAuthClient = createOAuth2Client(credentials);
|
|
599
|
-
let oauthTokenData = credentials.oauthTokenData;
|
|
600
|
-
if (credentials.grantType === 'clientCredentials' &&
|
|
601
|
-
(oauthTokenData === undefined ||
|
|
602
|
-
Object.keys(oauthTokenData).length === 0 ||
|
|
603
|
-
oauthTokenData.access_token === '')) {
|
|
604
|
-
let tokenResult;
|
|
605
|
-
try {
|
|
606
|
-
tokenResult = await oAuthClient.credentials.getToken();
|
|
607
|
-
}
|
|
608
|
-
catch (error) {
|
|
609
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
610
|
-
throw new n8n_workflow_1.ApplicationError(`Failed to acquire OAuth2 access token: ${message}`, {
|
|
611
|
-
cause: error,
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
const { data } = tokenResult;
|
|
615
|
-
if (!node.credentials?.[credentialsType]) {
|
|
616
|
-
throw new n8n_workflow_1.ApplicationError('Node does not have credential type', {
|
|
617
|
-
extra: { nodeName: node.name },
|
|
618
|
-
tags: { credentialType: credentialsType },
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
const nodeCredentials = node.credentials[credentialsType];
|
|
622
|
-
const initialTokenData = (await decryptOAuth2TokenDataIfConfigured(additionalData, data, credentials.jweEnabled === true));
|
|
623
|
-
credentials.oauthTokenData = initialTokenData;
|
|
624
|
-
await additionalData.credentialsHelper.updateCredentialsOauthTokenData(nodeCredentials, credentialsType, credentials, additionalData);
|
|
625
|
-
oauthTokenData = initialTokenData;
|
|
626
|
-
}
|
|
627
|
-
const preAuthData = await additionalData.credentialsHelper.runPreAuthentication({ helpers: this.helpers }, credentials, credentialsType);
|
|
628
|
-
if (preAuthData) {
|
|
629
|
-
Object.assign(credentials, preAuthData);
|
|
630
|
-
oauthTokenData = credentials.oauthTokenData;
|
|
631
|
-
}
|
|
632
|
-
const token = buildSigningToken(oAuthClient, oauthTokenData, oAuth2Options);
|
|
633
|
-
requestOptions.rejectUnauthorized = !credentials.ignoreSSLIssues;
|
|
634
|
-
const newRequestOptions = token.sign(requestOptions);
|
|
635
|
-
const newRequestHeaders = (newRequestOptions.headers = newRequestOptions.headers ?? {});
|
|
636
|
-
if (oAuth2Options?.keepBearer === false && typeof newRequestHeaders.Authorization === 'string') {
|
|
637
|
-
newRequestHeaders.Authorization = newRequestHeaders.Authorization.split(' ')[1];
|
|
638
|
-
}
|
|
639
|
-
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
|
640
|
-
Object.assign(newRequestHeaders, {
|
|
641
|
-
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
const tokenExpiredStatusCode = resolveTokenExpiredStatusCode(oAuth2Options, credentials);
|
|
645
|
-
const shouldSkipTokenRefresh = oAuth2Options?.skipTokenRefresh === true;
|
|
646
|
-
const refreshCtx = {
|
|
647
|
-
credentials,
|
|
648
|
-
token,
|
|
649
|
-
credentialsType,
|
|
650
|
-
node,
|
|
651
|
-
additionalData,
|
|
652
|
-
oAuth2Options,
|
|
653
|
-
logger: this.logger,
|
|
654
|
-
helpers: this.helpers,
|
|
655
|
-
};
|
|
656
|
-
const retryWithNewToken = async (makeRequest) => {
|
|
657
|
-
const newToken = await refreshOrFetchToken(refreshCtx);
|
|
658
|
-
const refreshedRequestOptions = newToken.sign(requestOptions);
|
|
659
|
-
refreshedRequestOptions.headers = refreshedRequestOptions.headers ?? {};
|
|
660
|
-
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
|
661
|
-
Object.assign(refreshedRequestOptions.headers, {
|
|
662
|
-
[oAuth2Options.keyToIncludeInAccessTokenHeader]: newToken.accessToken,
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
return await makeRequest(refreshedRequestOptions);
|
|
666
|
-
};
|
|
667
|
-
if (isN8nRequest) {
|
|
668
|
-
return await this.helpers.httpRequest(newRequestOptions).catch(async (error) => {
|
|
669
|
-
if (!shouldSkipTokenRefresh && error.response?.status === tokenExpiredStatusCode) {
|
|
670
|
-
return await retryWithNewToken(async (opts) => await this.helpers.httpRequest(opts));
|
|
671
|
-
}
|
|
672
|
-
throw error;
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
return await this.helpers
|
|
676
|
-
.request(newRequestOptions)
|
|
677
|
-
.then((response) => {
|
|
678
|
-
const requestOptions = newRequestOptions;
|
|
679
|
-
if (!shouldSkipTokenRefresh &&
|
|
680
|
-
requestOptions.resolveWithFullResponse === true &&
|
|
681
|
-
requestOptions.simple === false &&
|
|
682
|
-
response.statusCode === tokenExpiredStatusCode) {
|
|
683
|
-
throw response;
|
|
684
|
-
}
|
|
685
|
-
return response;
|
|
686
|
-
})
|
|
687
|
-
.catch(async (error) => {
|
|
688
|
-
if (!shouldSkipTokenRefresh && error.statusCode === tokenExpiredStatusCode) {
|
|
689
|
-
return await retryWithNewToken(async (opts) => await this.helpers.request(opts));
|
|
690
|
-
}
|
|
691
|
-
throw error;
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
async function requestOAuth1(credentialsType, requestOptions, isN8nRequest = false) {
|
|
695
|
-
(0, exports.removeEmptyBody)(requestOptions);
|
|
696
|
-
const credentials = await this.getCredentials(credentialsType);
|
|
697
|
-
if (credentials === undefined) {
|
|
698
|
-
throw new n8n_workflow_1.ApplicationError('No credentials were returned');
|
|
699
|
-
}
|
|
700
|
-
if (credentials.oauthTokenData === undefined) {
|
|
701
|
-
throw new n8n_workflow_1.ApplicationError('OAuth credentials not connected');
|
|
702
|
-
}
|
|
703
|
-
const oauth = new oauth_1_0a_1.default({
|
|
704
|
-
consumer: {
|
|
705
|
-
key: credentials.consumerKey,
|
|
706
|
-
secret: credentials.consumerSecret,
|
|
707
|
-
},
|
|
708
|
-
signature_method: credentials.signatureMethod,
|
|
709
|
-
hash_function(base, key) {
|
|
710
|
-
let algorithm;
|
|
711
|
-
switch (credentials.signatureMethod) {
|
|
712
|
-
case 'HMAC-SHA256':
|
|
713
|
-
algorithm = 'sha256';
|
|
714
|
-
break;
|
|
715
|
-
case 'HMAC-SHA512':
|
|
716
|
-
algorithm = 'sha512';
|
|
717
|
-
break;
|
|
718
|
-
default:
|
|
719
|
-
algorithm = 'sha1';
|
|
720
|
-
break;
|
|
721
|
-
}
|
|
722
|
-
return (0, crypto_1.createHmac)(algorithm, key).update(base).digest('base64');
|
|
723
|
-
},
|
|
724
|
-
});
|
|
725
|
-
const oauthTokenData = credentials.oauthTokenData;
|
|
726
|
-
const token = {
|
|
727
|
-
key: oauthTokenData.oauth_token,
|
|
728
|
-
secret: oauthTokenData.oauth_token_secret,
|
|
729
|
-
};
|
|
730
|
-
requestOptions.data = { ...requestOptions.qs, ...requestOptions.form };
|
|
731
|
-
if ('uri' in requestOptions && !requestOptions.url) {
|
|
732
|
-
requestOptions.url = requestOptions.uri;
|
|
733
|
-
delete requestOptions.uri;
|
|
734
|
-
}
|
|
735
|
-
requestOptions.headers = oauth.toHeader(oauth.authorize(requestOptions, token));
|
|
736
|
-
if (isN8nRequest) {
|
|
737
|
-
return await this.helpers.httpRequest(requestOptions);
|
|
738
|
-
}
|
|
739
|
-
return await this.helpers
|
|
740
|
-
.request(requestOptions)
|
|
741
|
-
.catch(async (error) => {
|
|
742
|
-
throw error;
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
async function refreshOAuth2Token(credentialsType, node, additionalData, oAuth2Options) {
|
|
746
|
-
const credentials = (await this.getCredentials(credentialsType));
|
|
747
|
-
if (credentials.grantType === 'authorizationCode' && credentials.oauthTokenData === undefined) {
|
|
748
|
-
throw new n8n_workflow_1.ApplicationError('OAuth credentials not connected');
|
|
749
|
-
}
|
|
750
|
-
const oAuthClient = createOAuth2Client(credentials);
|
|
751
|
-
const oauthTokenData = credentials.oauthTokenData;
|
|
752
|
-
const token = buildSigningToken(oAuthClient, oauthTokenData, oAuth2Options);
|
|
753
|
-
const newToken = await refreshOrFetchToken({
|
|
754
|
-
credentials,
|
|
755
|
-
token,
|
|
756
|
-
credentialsType,
|
|
757
|
-
node,
|
|
758
|
-
additionalData,
|
|
759
|
-
oAuth2Options,
|
|
760
|
-
logger: this.logger,
|
|
761
|
-
helpers: this.helpers,
|
|
762
|
-
});
|
|
763
|
-
return newToken.data;
|
|
764
|
-
}
|
|
765
|
-
async function httpRequestWithAuthentication(credentialsType, requestOptions, workflow, node, additionalData, additionalCredentialOptions) {
|
|
766
|
-
(0, exports.removeEmptyBody)(requestOptions);
|
|
767
|
-
if ('getExecutionCancelSignal' in this) {
|
|
768
|
-
requestOptions.abortSignal = this.getExecutionCancelSignal();
|
|
769
|
-
}
|
|
770
|
-
let credentialsDecrypted;
|
|
771
|
-
if (additionalData.evalLlmMockHandler) {
|
|
772
|
-
const evalMockResponse = await (0, eval_mock_helpers_1.callEvalMockHandler)(additionalData.evalLlmMockHandler, requestOptions, node, requestOptions.returnFullResponse);
|
|
773
|
-
if (evalMockResponse !== undefined)
|
|
774
|
-
return evalMockResponse;
|
|
775
|
-
}
|
|
776
|
-
try {
|
|
777
|
-
const parentTypes = additionalData.credentialsHelper.getParentTypes(credentialsType);
|
|
778
|
-
if (parentTypes.includes('oAuth1Api')) {
|
|
779
|
-
return await requestOAuth1.call(this, credentialsType, requestOptions, true);
|
|
780
|
-
}
|
|
781
|
-
if (parentTypes.includes('oAuth2Api')) {
|
|
782
|
-
return await requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, additionalCredentialOptions?.oauth2, true);
|
|
783
|
-
}
|
|
784
|
-
if (additionalCredentialOptions?.credentialsDecrypted) {
|
|
785
|
-
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
credentialsDecrypted =
|
|
789
|
-
await this.getCredentials(credentialsType);
|
|
790
|
-
}
|
|
791
|
-
if (credentialsDecrypted === undefined) {
|
|
792
|
-
throw new n8n_workflow_1.NodeOperationError(node, `Node "${node.name}" does not have any credentials of type "${credentialsType}" set`, { level: 'warning' });
|
|
793
|
-
}
|
|
794
|
-
const data = await additionalData.credentialsHelper.preAuthentication({ helpers: this.helpers }, credentialsDecrypted, credentialsType, node, false);
|
|
795
|
-
if (data) {
|
|
796
|
-
Object.assign(credentialsDecrypted, data);
|
|
797
|
-
}
|
|
798
|
-
requestOptions = await additionalData.credentialsHelper.authenticate(credentialsDecrypted, credentialsType, requestOptions, workflow, node);
|
|
799
|
-
return await httpRequest(requestOptions, additionalData.ssrfBridge);
|
|
800
|
-
}
|
|
801
|
-
catch (error) {
|
|
802
|
-
if (error.response?.status === 401 &&
|
|
803
|
-
additionalData.credentialsHelper.preAuthentication !== undefined) {
|
|
804
|
-
try {
|
|
805
|
-
if (credentialsDecrypted !== undefined) {
|
|
806
|
-
const data = await additionalData.credentialsHelper.preAuthentication({ helpers: this.helpers }, credentialsDecrypted, credentialsType, node, true);
|
|
807
|
-
if (data) {
|
|
808
|
-
Object.assign(credentialsDecrypted, data);
|
|
809
|
-
}
|
|
810
|
-
requestOptions = await additionalData.credentialsHelper.authenticate(credentialsDecrypted, credentialsType, requestOptions, workflow, node);
|
|
811
|
-
}
|
|
812
|
-
return await httpRequest(requestOptions, additionalData.ssrfBridge);
|
|
813
|
-
}
|
|
814
|
-
catch (error) {
|
|
815
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
async function requestWithAuthentication(credentialsType, requestOptions, workflow, node, additionalData, additionalCredentialOptions, itemIndex) {
|
|
822
|
-
(0, exports.removeEmptyBody)(requestOptions);
|
|
823
|
-
let credentialsDecrypted;
|
|
824
|
-
if (additionalData.evalLlmMockHandler) {
|
|
825
|
-
const evalMockResponse = await (0, eval_mock_helpers_1.callEvalMockHandler)(additionalData.evalLlmMockHandler, (0, eval_mock_helpers_1.normalizeLegacyRequest)(requestOptions), node, requestOptions.resolveWithFullResponse, 'legacy');
|
|
826
|
-
if (evalMockResponse !== undefined)
|
|
827
|
-
return evalMockResponse;
|
|
828
|
-
}
|
|
829
|
-
try {
|
|
830
|
-
const parentTypes = additionalData.credentialsHelper.getParentTypes(credentialsType);
|
|
831
|
-
if (credentialsType === 'oAuth1Api' || parentTypes.includes('oAuth1Api')) {
|
|
832
|
-
return await requestOAuth1.call(this, credentialsType, requestOptions, false);
|
|
833
|
-
}
|
|
834
|
-
if (credentialsType === 'oAuth2Api' || parentTypes.includes('oAuth2Api')) {
|
|
835
|
-
return await requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, additionalCredentialOptions?.oauth2, false);
|
|
836
|
-
}
|
|
837
|
-
if (additionalCredentialOptions?.credentialsDecrypted) {
|
|
838
|
-
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
|
839
|
-
}
|
|
840
|
-
else {
|
|
841
|
-
credentialsDecrypted = await this.getCredentials(credentialsType, itemIndex);
|
|
842
|
-
}
|
|
843
|
-
if (credentialsDecrypted === undefined) {
|
|
844
|
-
throw new n8n_workflow_1.NodeOperationError(node, `Node "${node.name}" does not have any credentials of type "${credentialsType}" set`, { level: 'warning' });
|
|
845
|
-
}
|
|
846
|
-
const data = await additionalData.credentialsHelper.preAuthentication({ helpers: this.helpers }, credentialsDecrypted, credentialsType, node, false);
|
|
847
|
-
if (data) {
|
|
848
|
-
Object.assign(credentialsDecrypted, data);
|
|
849
|
-
}
|
|
850
|
-
requestOptions = (await additionalData.credentialsHelper.authenticate(credentialsDecrypted, credentialsType, requestOptions, workflow, node));
|
|
851
|
-
return await proxyRequestToAxios(workflow, additionalData, node, requestOptions);
|
|
852
|
-
}
|
|
853
|
-
catch (error) {
|
|
854
|
-
try {
|
|
855
|
-
if (credentialsDecrypted !== undefined) {
|
|
856
|
-
const data = await additionalData.credentialsHelper.preAuthentication({ helpers: this.helpers }, credentialsDecrypted, credentialsType, node, true);
|
|
857
|
-
if (data) {
|
|
858
|
-
Object.assign(credentialsDecrypted, data);
|
|
859
|
-
requestOptions = (await additionalData.credentialsHelper.authenticate(credentialsDecrypted, credentialsType, requestOptions, workflow, node));
|
|
860
|
-
return await proxyRequestToAxios(workflow, additionalData, node, requestOptions);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
throw error;
|
|
864
|
-
}
|
|
865
|
-
catch (error) {
|
|
866
|
-
if (error instanceof n8n_workflow_1.ExecutionBaseError)
|
|
867
|
-
throw error;
|
|
868
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
const getRequestHelperFunctions = (workflow, node, additionalData, runExecutionData = null, connectionInputData = []) => {
|
|
873
|
-
const getResolvedValue = (parameterValue, itemIndex, runIndex, executeData, additionalKeys, returnObjectAsString = false) => {
|
|
874
|
-
const mode = 'internal';
|
|
875
|
-
if (typeof parameterValue === 'object' ||
|
|
876
|
-
(typeof parameterValue === 'string' && parameterValue.charAt(0) === '=')) {
|
|
877
|
-
return workflow.expression.getParameterValue(parameterValue, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, additionalKeys ?? {}, executeData, returnObjectAsString);
|
|
878
|
-
}
|
|
879
|
-
return parameterValue;
|
|
880
|
-
};
|
|
881
|
-
async function requestWithAuthenticationPaginated(requestOptions, itemIndex, paginationOptions, credentialsType, additionalCredentialOptions) {
|
|
882
|
-
const responseData = [];
|
|
883
|
-
if (!requestOptions.qs) {
|
|
884
|
-
requestOptions.qs = {};
|
|
885
|
-
}
|
|
886
|
-
requestOptions.resolveWithFullResponse = true;
|
|
887
|
-
requestOptions.simple = false;
|
|
888
|
-
let tempResponseData;
|
|
889
|
-
let makeAdditionalRequest;
|
|
890
|
-
let paginateRequestData;
|
|
891
|
-
const runIndex = 0;
|
|
892
|
-
const additionalKeys = {
|
|
893
|
-
$request: requestOptions,
|
|
894
|
-
$response: {},
|
|
895
|
-
$version: node.typeVersion,
|
|
896
|
-
$pageCount: 0,
|
|
897
|
-
};
|
|
898
|
-
const executeData = {
|
|
899
|
-
data: {},
|
|
900
|
-
node,
|
|
901
|
-
source: null,
|
|
902
|
-
};
|
|
903
|
-
const hashData = {
|
|
904
|
-
identicalCount: 0,
|
|
905
|
-
previousLength: 0,
|
|
906
|
-
previousHash: '',
|
|
907
|
-
};
|
|
908
|
-
do {
|
|
909
|
-
paginateRequestData = getResolvedValue(paginationOptions.request, itemIndex, runIndex, executeData, additionalKeys, false);
|
|
910
|
-
const tempRequestOptions = applyPaginationRequestData(requestOptions, paginateRequestData);
|
|
911
|
-
if (!(0, request_helpers_1.tryParseUrl)(tempRequestOptions.uri)) {
|
|
912
|
-
throw new n8n_workflow_1.NodeOperationError(node, `'${paginateRequestData.url}' is not a valid URL.`, {
|
|
913
|
-
itemIndex,
|
|
914
|
-
runIndex,
|
|
915
|
-
type: 'invalid_url',
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
if (credentialsType) {
|
|
919
|
-
tempResponseData = await this.helpers.requestWithAuthentication.call(this, credentialsType, tempRequestOptions, additionalCredentialOptions);
|
|
920
|
-
}
|
|
921
|
-
else {
|
|
922
|
-
tempResponseData = await this.helpers.request(tempRequestOptions);
|
|
923
|
-
}
|
|
924
|
-
const newResponse = Object.assign({
|
|
925
|
-
body: {},
|
|
926
|
-
headers: {},
|
|
927
|
-
statusCode: 0,
|
|
928
|
-
}, (0, pick_1.default)(tempResponseData, ['body', 'headers', 'statusCode']));
|
|
929
|
-
let contentBody;
|
|
930
|
-
if (newResponse.body instanceof stream_1.Readable && paginationOptions.binaryResult !== true) {
|
|
931
|
-
contentBody = await (0, binary_helper_functions_1.binaryToString)(newResponse.body);
|
|
932
|
-
const responseContentType = newResponse.headers['content-type']?.toString() ?? '';
|
|
933
|
-
if (responseContentType.includes('application/json')) {
|
|
934
|
-
newResponse.body = (0, n8n_workflow_1.jsonParse)(contentBody, { fallbackValue: {} });
|
|
935
|
-
}
|
|
936
|
-
else {
|
|
937
|
-
newResponse.body = contentBody;
|
|
938
|
-
}
|
|
939
|
-
tempResponseData.__bodyResolved = true;
|
|
940
|
-
tempResponseData.body = newResponse.body;
|
|
941
|
-
}
|
|
942
|
-
else {
|
|
943
|
-
contentBody = newResponse.body;
|
|
944
|
-
}
|
|
945
|
-
if (paginationOptions.binaryResult !== true || tempResponseData.headers.etag) {
|
|
946
|
-
let contentLength = 0;
|
|
947
|
-
if ('content-length' in tempResponseData.headers) {
|
|
948
|
-
contentLength = parseInt(tempResponseData.headers['content-length']) || 0;
|
|
949
|
-
}
|
|
950
|
-
if (hashData.previousLength === contentLength) {
|
|
951
|
-
let hash;
|
|
952
|
-
if (tempResponseData.headers.etag) {
|
|
953
|
-
hash = tempResponseData.headers.etag;
|
|
954
|
-
}
|
|
955
|
-
else {
|
|
956
|
-
if (typeof contentBody !== 'string') {
|
|
957
|
-
contentBody = JSON.stringify(contentBody);
|
|
958
|
-
}
|
|
959
|
-
hash = crypto_1.default.createHash('md5').update(contentBody).digest('base64');
|
|
960
|
-
}
|
|
961
|
-
if (hashData.previousHash === hash) {
|
|
962
|
-
hashData.identicalCount += 1;
|
|
963
|
-
if (hashData.identicalCount > 2) {
|
|
964
|
-
throw new n8n_workflow_1.NodeOperationError(node, 'The returned response was identical 5x, so requests got stopped', {
|
|
965
|
-
itemIndex,
|
|
966
|
-
description: 'Check if "Pagination Completed When" has been configured correctly.',
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
else {
|
|
971
|
-
hashData.identicalCount = 0;
|
|
972
|
-
}
|
|
973
|
-
hashData.previousHash = hash;
|
|
974
|
-
}
|
|
975
|
-
else {
|
|
976
|
-
hashData.identicalCount = 0;
|
|
977
|
-
}
|
|
978
|
-
hashData.previousLength = contentLength;
|
|
979
|
-
}
|
|
980
|
-
responseData.push(tempResponseData);
|
|
981
|
-
additionalKeys.$response = newResponse;
|
|
982
|
-
additionalKeys.$pageCount = (additionalKeys.$pageCount ?? 0) + 1;
|
|
983
|
-
const maxRequests = getResolvedValue(paginationOptions.maxRequests, itemIndex, runIndex, executeData, additionalKeys, false);
|
|
984
|
-
if (maxRequests && additionalKeys.$pageCount >= maxRequests) {
|
|
985
|
-
break;
|
|
986
|
-
}
|
|
987
|
-
makeAdditionalRequest = getResolvedValue(paginationOptions.continue, itemIndex, runIndex, executeData, additionalKeys, false);
|
|
988
|
-
if (makeAdditionalRequest) {
|
|
989
|
-
if (paginationOptions.requestInterval) {
|
|
990
|
-
const requestInterval = getResolvedValue(paginationOptions.requestInterval, itemIndex, runIndex, executeData, additionalKeys, false);
|
|
991
|
-
await (0, n8n_workflow_1.sleep)(requestInterval);
|
|
992
|
-
}
|
|
993
|
-
if (tempResponseData.statusCode < 200 || tempResponseData.statusCode >= 300) {
|
|
994
|
-
let data = tempResponseData.body;
|
|
995
|
-
if (data instanceof stream_1.Readable && paginationOptions.binaryResult !== true) {
|
|
996
|
-
data = await (0, binary_helper_functions_1.binaryToString)(data);
|
|
997
|
-
}
|
|
998
|
-
else if (typeof data === 'object') {
|
|
999
|
-
data = JSON.stringify(data);
|
|
1000
|
-
}
|
|
1001
|
-
throw Object.assign(new Error(`${tempResponseData.statusCode} - "${data?.toString()}"`), {
|
|
1002
|
-
statusCode: tempResponseData.statusCode,
|
|
1003
|
-
error: data,
|
|
1004
|
-
isAxiosError: true,
|
|
1005
|
-
response: {
|
|
1006
|
-
headers: tempResponseData.headers,
|
|
1007
|
-
status: tempResponseData.statusCode,
|
|
1008
|
-
statusText: tempResponseData.statusMessage,
|
|
1009
|
-
},
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
} while (makeAdditionalRequest);
|
|
1014
|
-
return responseData;
|
|
1015
|
-
}
|
|
1016
|
-
const evalLlmMock = additionalData.evalLlmMockHandler;
|
|
1017
|
-
return {
|
|
1018
|
-
httpRequest: async (requestOptions) => {
|
|
1019
|
-
if (evalLlmMock) {
|
|
1020
|
-
const evalMockResponse = await (0, eval_mock_helpers_1.callEvalMockHandler)(evalLlmMock, requestOptions, node, requestOptions.returnFullResponse);
|
|
1021
|
-
if (evalMockResponse !== undefined)
|
|
1022
|
-
return evalMockResponse;
|
|
1023
|
-
}
|
|
1024
|
-
if (additionalData.otel?.injectTraceHeaders) {
|
|
1025
|
-
requestOptions.headers ??= {};
|
|
1026
|
-
additionalData.otel.injectTraceHeaders(additionalData.executionId, node.name, requestOptions.headers);
|
|
1027
|
-
}
|
|
1028
|
-
return await httpRequest(requestOptions, additionalData.ssrfBridge);
|
|
1029
|
-
},
|
|
1030
|
-
requestWithAuthenticationPaginated,
|
|
1031
|
-
async httpRequestWithAuthentication(credentialsType, requestOptions, additionalCredentialOptions) {
|
|
1032
|
-
return await httpRequestWithAuthentication.call(this, credentialsType, requestOptions, workflow, node, additionalData, additionalCredentialOptions);
|
|
1033
|
-
},
|
|
1034
|
-
async refreshOAuth2Token(credentialsType, oAuth2Options) {
|
|
1035
|
-
return await refreshOAuth2Token.call(this, credentialsType, node, additionalData, oAuth2Options);
|
|
1036
|
-
},
|
|
1037
|
-
request: async (uriOrObject, options) => {
|
|
1038
|
-
if (evalLlmMock) {
|
|
1039
|
-
const wantsFull = typeof uriOrObject !== 'string' && uriOrObject.resolveWithFullResponse;
|
|
1040
|
-
const evalMockResponse = await (0, eval_mock_helpers_1.callEvalMockHandler)(evalLlmMock, (0, eval_mock_helpers_1.normalizeLegacyRequest)(uriOrObject, options), node, wantsFull, 'legacy');
|
|
1041
|
-
if (evalMockResponse !== undefined)
|
|
1042
|
-
return evalMockResponse;
|
|
1043
|
-
}
|
|
1044
|
-
if (additionalData.otel?.injectTraceHeaders) {
|
|
1045
|
-
const target = typeof uriOrObject === 'string' ? (options ??= {}) : uriOrObject;
|
|
1046
|
-
target.headers ??= {};
|
|
1047
|
-
additionalData.otel.injectTraceHeaders(additionalData.executionId, node.name, target.headers);
|
|
1048
|
-
}
|
|
1049
|
-
return await proxyRequestToAxios(workflow, additionalData, node, uriOrObject, options);
|
|
1050
|
-
},
|
|
1051
|
-
async requestWithAuthentication(credentialsType, requestOptions, additionalCredentialOptions, itemIndex) {
|
|
1052
|
-
return await requestWithAuthentication.call(this, credentialsType, requestOptions, workflow, node, additionalData, additionalCredentialOptions, itemIndex);
|
|
1053
|
-
},
|
|
1054
|
-
async requestOAuth1(credentialsType, requestOptions) {
|
|
1055
|
-
if (evalLlmMock) {
|
|
1056
|
-
const evalMockResponse = await (0, eval_mock_helpers_1.callEvalMockHandler)(evalLlmMock, (0, eval_mock_helpers_1.normalizeLegacyRequest)(requestOptions), node, requestOptions.resolveWithFullResponse, 'legacy');
|
|
1057
|
-
if (evalMockResponse !== undefined)
|
|
1058
|
-
return evalMockResponse;
|
|
1059
|
-
}
|
|
1060
|
-
return await requestOAuth1.call(this, credentialsType, requestOptions);
|
|
1061
|
-
},
|
|
1062
|
-
async requestOAuth2(credentialsType, requestOptions, oAuth2Options) {
|
|
1063
|
-
if (evalLlmMock) {
|
|
1064
|
-
const evalMockResponse = await (0, eval_mock_helpers_1.callEvalMockHandler)(evalLlmMock, (0, eval_mock_helpers_1.normalizeLegacyRequest)(requestOptions), node, requestOptions.resolveWithFullResponse, 'legacy');
|
|
1065
|
-
if (evalMockResponse !== undefined)
|
|
1066
|
-
return evalMockResponse;
|
|
1067
|
-
}
|
|
1068
|
-
return await requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, oAuth2Options);
|
|
1069
|
-
},
|
|
1070
|
-
};
|
|
1071
|
-
};
|
|
1072
|
-
exports.getRequestHelperFunctions = getRequestHelperFunctions;
|
|
17
|
+
__exportStar(require("./request-helpers"), exports);
|
|
1073
18
|
//# sourceMappingURL=request-helper-functions.js.map
|