diff --git a/packages/cli/src/middlewares/auth.ts b/packages/cli/src/middlewares/auth.ts index 8b3a53cca6..f6a9764280 100644 --- a/packages/cli/src/middlewares/auth.ts +++ b/packages/cli/src/middlewares/auth.ts @@ -10,7 +10,6 @@ import type { AuthenticatedRequest } from '@/requests'; import config from '@/config'; import { AUTH_COOKIE_NAME, EDITOR_UI_DIST_DIR } from '@/constants'; import { issueCookie, resolveJwtContent } from '@/auth/jwt'; -import type { UserRepository } from '@db/repositories'; import { canSkipAuth } from '@/decorators/registerController'; const jwtFromRequest = (req: Request) => { diff --git a/packages/core/package.json b/packages/core/package.json index 51caa50a81..2be1ecba64 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -60,8 +60,6 @@ "p-cancelable": "^2.0.0", "pretty-bytes": "^5.6.0", "qs": "^6.10.1", - "request": "^2.88.2", - "request-promise-native": "^1.0.7", "uuid": "^8.3.2" } } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 2835045425..9e1a4d8b17 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -97,9 +97,8 @@ import get from 'lodash/get'; import type { Request, Response } from 'express'; import FormData from 'form-data'; import path from 'path'; -import type { OptionsWithUri, OptionsWithUrl, RequestCallback, RequiredUriUrl } from 'request'; +import type { OptionsWithUri, OptionsWithUrl } from 'request'; import type { RequestPromiseOptions } from 'request-promise-native'; -import requestPromise from 'request-promise-native'; import FileType from 'file-type'; import { lookup, extension } from 'mime-types'; import type { IncomingHttpHeaders } from 'http'; @@ -142,10 +141,6 @@ axios.defaults.paramsSerializer = (params) => { return stringify(params, { arrayFormat: 'indices' }); }; -const requestPromiseWithDefaults = requestPromise.defaults({ - timeout: 300000, // 5 minutes -}); - const pushFormDataValue = (form: FormData, key: string, value: any) => { if (value?.hasOwnProperty('value') && value.hasOwnProperty('options')) { form.append(key, value.value, value.options); @@ -596,21 +591,12 @@ type ConfigObject = { }; export async function proxyRequestToAxios( - workflow: Workflow, - additionalData: IWorkflowExecuteAdditionalData, - node: INode, - uriOrObject: string | IDataObject, - options?: IDataObject, + workflow: Workflow | undefined, + additionalData: IWorkflowExecuteAdditionalData | undefined, + node: INode | undefined, + uriOrObject: string | object, + options?: object, ): Promise { - // Check if there's a better way of getting this config here - if (process.env.N8N_USE_DEPRECATED_REQUEST_LIB) { - return requestPromiseWithDefaults.call( - null, - uriOrObject as unknown as RequiredUriUrl & RequestPromiseOptions, - options as unknown as RequestCallback, - ); - } - let axiosConfig: AxiosRequestConfig = { maxBodyLength: Infinity, maxContentLength: Infinity, @@ -667,7 +653,7 @@ export async function proxyRequestToAxios( body = undefined; } } - await additionalData.hooks?.executeHookFunctions('nodeFetchedData', [workflow.id, node]); + await additionalData?.hooks?.executeHookFunctions('nodeFetchedData', [workflow?.id, node]); return { body, headers: response.headers, @@ -684,7 +670,7 @@ export async function proxyRequestToAxios( body = undefined; } } - await additionalData.hooks?.executeHookFunctions('nodeFetchedData', [workflow.id, node]); + await additionalData?.hooks?.executeHookFunctions('nodeFetchedData', [workflow?.id, node]); return body; } } catch (error) { @@ -1074,13 +1060,13 @@ async function prepareBinaryData( /** * Makes a request using OAuth data for authentication * - * @param {(OptionsWithUri | requestPromise.RequestPromiseOptions)} requestOptions + * @param {(OptionsWithUri | RequestPromiseOptions)} requestOptions * */ export async function requestOAuth2( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions | IHttpRequestOptions, + requestOptions: OptionsWithUri | RequestPromiseOptions | IHttpRequestOptions, node: INode, additionalData: IWorkflowExecuteAdditionalData, oAuth2Options?: IOAuth2Options, @@ -1311,11 +1297,7 @@ export async function requestOAuth2( export async function requestOAuth1( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: - | OptionsWithUrl - | OptionsWithUri - | requestPromise.RequestPromiseOptions - | IHttpRequestOptions, + requestOptions: OptionsWithUrl | OptionsWithUri | RequestPromiseOptions | IHttpRequestOptions, isN8nRequest = false, ) { const credentials = await this.getCredentials(credentialsType); @@ -1569,7 +1551,7 @@ export function normalizeItems( export async function requestWithAuthentication( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions, + requestOptions: OptionsWithUri | RequestPromiseOptions, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, @@ -2228,7 +2210,7 @@ const getRequestHelperFunctions = ( async requestOAuth1( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions, + requestOptions: OptionsWithUrl | RequestPromiseOptions, ): Promise { return requestOAuth1.call(this, credentialsType, requestOptions); }, @@ -2236,7 +2218,7 @@ const getRequestHelperFunctions = ( async requestOAuth2( this: IAllExecuteFunctions, credentialsType: string, - requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions, + requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options, ): Promise { return requestOAuth2.call( @@ -2732,7 +2714,9 @@ export function getExecuteSingleFunctions( export function getCredentialTestFunctions(): ICredentialTestFunctions { return { helpers: { - request: requestPromiseWithDefaults, + request: async (uriOrObject: string | object, options?: object) => { + return proxyRequestToAxios(undefined, undefined, undefined, uriOrObject, options); + }, }, }; } diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index e260be8b82..737d60da98 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -828,7 +828,6 @@ "promise-ftp": "^1.3.5", "pyodide": "^0.22.1", "redis": "^3.1.1", - "request": "^2.88.2", "rhea": "^1.0.11", "rss-parser": "^3.7.0", "semver": "^7.3.8", diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index d4a056d655..46238b1e7d 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -6,7 +6,7 @@ import type { IncomingHttpHeaders } from 'http'; import type { Readable } from 'stream'; import type { URLSearchParams } from 'url'; import type { OptionsWithUri, OptionsWithUrl } from 'request'; -import type { RequestPromiseOptions, RequestPromiseAPI } from 'request-promise-native'; +import type { RequestPromiseOptions } from 'request-promise-native'; import type { PathLike } from 'fs'; import type { CODE_EXECUTION_MODES, CODE_LANGUAGES } from './Constants'; @@ -657,7 +657,7 @@ export type ICredentialTestFunction = ( export interface ICredentialTestFunctions { helpers: { - request: RequestPromiseAPI; + request: (uriOrObject: string | object, options?: object) => Promise; }; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c1ad530bd5..cb88aaec2d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -621,12 +621,6 @@ importers: qs: specifier: ^6.10.1 version: 6.11.0 - request: - specifier: ^2.88.2 - version: 2.88.2 - request-promise-native: - specifier: ^1.0.7 - version: 1.0.9(request@2.88.2) uuid: specifier: ^8.3.2 version: 8.3.2 @@ -1159,9 +1153,6 @@ importers: redis: specifier: ^3.1.1 version: 3.1.2 - request: - specifier: ^2.88.2 - version: 2.88.2 rhea: specifier: ^1.0.11 version: 1.0.24 @@ -19222,29 +19213,6 @@ packages: throttleit: 1.0.0 dev: true - /request-promise-core@1.1.4(request@2.88.2): - resolution: {integrity: sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw==} - engines: {node: '>=0.10.0'} - peerDependencies: - request: ^2.34 - dependencies: - lodash: 4.17.21 - request: 2.88.2 - dev: false - - /request-promise-native@1.0.9(request@2.88.2): - resolution: {integrity: sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g==} - engines: {node: '>=0.12.0'} - deprecated: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142 - peerDependencies: - request: ^2.34 - dependencies: - request: 2.88.2 - request-promise-core: 1.1.4(request@2.88.2) - stealthy-require: 1.1.1 - tough-cookie: 2.5.0 - dev: false - /request@2.88.2: resolution: {integrity: sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==} engines: {node: '>= 6'} @@ -20289,11 +20257,6 @@ packages: resolution: {integrity: sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==} dev: true - /stealthy-require@1.1.1: - resolution: {integrity: sha512-ZnWpYnYugiOVEY5GkcuJK1io5V8QmNYChG62gSit9pQVGErXtrKuPC55ITaVSukmMta5qpMU7vqLt2Lnni4f/g==} - engines: {node: '>=0.10.0'} - dev: false - /stop-iteration-iterator@1.0.0: resolution: {integrity: sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==} engines: {node: '>= 0.4'}