hivessh
Version:
HiveSsh is an innovative library designed to streamline SSH2 connections and simplify task execution on Linux servers.
84 lines • 3.27 kB
TypeScript
import { ClientChannel, ExecOptions, Client as SshClient } from "ssh2";
import { Readable } from "stream";
import { Awaitable } from "./utils/base.js";
export interface ArrayOptions {
concurrency?: number;
signal?: AbortSignal;
encoding?: BufferEncoding;
}
export interface CmdChannelOptions extends ExecOptions {
pwd?: string;
env?: NodeJS.ProcessEnv;
timeoutMillis?: number;
sudo?: boolean;
}
export interface CmdChannelSettings extends ExecOptions {
pwd: string;
env: NodeJS.ProcessEnv | undefined;
timeoutMillis: number;
sudo: boolean;
}
export declare const defaultCmdChannelSettings: CmdChannelSettings;
export type CmdExecOptions = CmdChannelOptions & ChannelToPromiseOptions;
export interface SshChannelExit {
cmd: string;
out: string;
chunks: [boolean, string][];
anyErr: boolean;
anyStd: boolean;
code: number;
signal?: string;
dump?: string;
desc?: string;
}
export declare class SshChannelExitError extends Error {
exit: SshChannelExit;
constructor(message: string, exit: SshChannelExit);
}
export type SshChannelToPromise = (options?: ChannelToPromiseOptions) => Promise<SshChannelExit>;
export interface SshChannelExtras {
cmd: string;
timeout?: NodeJS.Timeout | undefined;
settings: CmdChannelSettings;
stdout: Readable;
toPromise: SshChannelToPromise;
}
export type SshChannel = Omit<ClientChannel, "stdout"> & SshChannelExtras;
export declare function toSshChannel(channel: ClientChannel, extras: SshChannelExtras): SshChannel;
export declare function execSshChannel(sshClient: SshClient, cmd: string, options?: CmdChannelOptions): Promise<SshChannel>;
export type StreamDataMapper = (data: string, err: boolean) => Awaitable<string | undefined | void>;
export type StreamDataFilter = (data: string, err: boolean, options?: Pick<ArrayOptions, "signal">) => Awaitable<boolean>;
export interface ChannelToPromiseOptions {
mapOut?: StreamDataMapper;
mapStdOut?: StreamDataMapper;
mapErrOut?: StreamDataMapper;
filterOut?: StreamDataFilter;
filterStdOut?: StreamDataFilter;
filterErrOut?: StreamDataFilter;
filterOutOptions?: ArrayOptions;
filterStdOutOptions?: ArrayOptions;
filterErrOutOptions?: ArrayOptions;
throwOnOut?: boolean;
throwOnStdOut?: boolean;
throwOnErrOut?: boolean;
expectedExitCode?: number | number[];
}
export interface ChannelToPromiseSettings {
mapOut: StreamDataMapper | undefined;
mapStdOut: StreamDataMapper | undefined;
mapErrOut: StreamDataMapper | undefined;
filterOut: StreamDataFilter | undefined;
filterStdOut: StreamDataFilter | undefined;
filterErrOut: StreamDataFilter | undefined;
filterOutOptions: ArrayOptions | undefined;
filterStdOutOptions: ArrayOptions | undefined;
filterErrOutOptions: ArrayOptions | undefined;
throwOnOut: boolean | undefined;
throwOnStdOut: boolean;
throwOnErrOut: boolean;
expectedExitCode: number[];
}
export declare const defaultChannelToPromiseSettings: ChannelToPromiseSettings;
export declare function checkDataChunk(chunk: any): string;
export declare function sshChannelToPromise(channel: ClientChannel, cmd: string): SshChannelToPromise;
//# sourceMappingURL=SshExec.d.ts.map