refactor(core): Centralize SSH Tunnel management (#9906)

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-07-04 12:29:44 +02:00
committed by GitHub
parent 86018aa6e0
commit 85aa560a5d
25 changed files with 525 additions and 630 deletions

View File

@@ -8,6 +8,7 @@ import type { SecureContextOptions } from 'tls';
import type { Readable } from 'stream';
import type { URLSearchParams } from 'url';
import type { RequestBodyMatcher } from 'nock';
import type { Client as SSHClient } from 'ssh2';
import type { AuthenticationMethod } from './Authentication';
import type { CODE_EXECUTION_MODES, CODE_LANGUAGES, LOG_LEVELS } from './Constants';
@@ -717,7 +718,7 @@ export type ICredentialTestFunction = (
) => Promise<INodeCredentialTestResult>;
export interface ICredentialTestFunctions {
helpers: {
helpers: SSHTunnelFunctions & {
request: (uriOrObject: string | object, options?: object) => Promise<any>;
};
}
@@ -816,6 +817,28 @@ export interface RequestHelperFunctions {
): Promise<any>;
}
export type SSHCredentials = {
sshHost: string;
sshPort: number;
sshUser: string;
} & (
| {
sshAuthenticateWith: 'password';
sshPassword: string;
}
| {
sshAuthenticateWith: 'privateKey';
// TODO: rename this to `sshPrivateKey`
privateKey: string;
// TODO: rename this to `sshPassphrase`
passphrase?: string;
}
);
export interface SSHTunnelFunctions {
getSSHClient(credentials: SSHCredentials): Promise<SSHClient>;
}
export type NodeTypeAndVersion = {
name: string;
type: string;
@@ -899,6 +922,7 @@ export type IExecuteFunctions = ExecuteFunctions.GetNodeParameterFn &
BaseHelperFunctions &
BinaryHelperFunctions &
FileSystemHelperFunctions &
SSHTunnelFunctions &
JsonHelperFunctions & {
normalizeItems(items: INodeExecutionData | INodeExecutionData[]): INodeExecutionData[];
constructExecutionMetaData(
@@ -948,7 +972,7 @@ export interface ILoadOptionsFunctions extends FunctionsBase {
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object | undefined;
getCurrentNodeParameters(): INodeParameters | undefined;
helpers: RequestHelperFunctions;
helpers: RequestHelperFunctions & SSHTunnelFunctions;
}
export interface IPollFunctions
@@ -986,6 +1010,7 @@ export interface ITriggerFunctions
helpers: RequestHelperFunctions &
BaseHelperFunctions &
BinaryHelperFunctions &
SSHTunnelFunctions &
JsonHelperFunctions;
}