// Type definitions for node-ssh 7.0 // Project: https://github.com/steelbrain/node-ssh // Definitions by: Junxiao Shi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// import { ClientChannel, ExecOptions as ssh2ExecOptions, SFTPWrapper } from "ssh2"; import { TransferOptions } from "ssh2-streams"; declare namespace SSH { type Shell = ClientChannel; type SFTP = SFTPWrapper; interface ConfigGiven { host: string; port?: number; username: string; password?: string; privateKey?: string; onKeyboardInteractive?: () => void | boolean; } interface ExecOptions { cwd?: string; stdin?: string; options?: ssh2ExecOptions; onStdout?: (chunk: Buffer) => void; onStderr?: (chunk: Buffer) => void; } interface ExecResult { stdout: string; stderr: string; code: number; signal?: string; } interface PutFilesOptions { sftp?: SFTP; sftpOptions?: TransferOptions; concurrency?: number; } interface PutDirectoryOptions { sftp?: SFTP; sftpOptions?: TransferOptions; concurrency?: number; recursive?: boolean; tick?: (localPath: string, remotePath: string, error: Error | null | undefined) => void; validate?: (localPath: string) => boolean; } } declare class SSH { constructor(); connect(givenConfig: SSH.ConfigGiven): Promise; requestShell(): Promise; requestSFTP(): Promise; mkdir(path: string, type: "exec"): Promise; mkdir(path: string, type?: "sftp", givenSftp?: SSH.SFTP): Promise; exec(command: string, parameters?: ReadonlyArray, options?: SSH.ExecOptions & { stream?: "stdout"|"stderr" }): Promise; exec(command: string, parameters?: ReadonlyArray, options?: SSH.ExecOptions & { stream: "both" }): Promise; execCommand(givenCommand: string, options?: SSH.ExecOptions): Promise; getFile(localFile: string, remoteFile: string, givenSftp?: SSH.SFTP, givenOpts?: TransferOptions): Promise; putFile(localFile: string, remoteFile: string, givenSftp?: SSH.SFTP, givenOpts?: TransferOptions): Promise; putFiles(files: ReadonlyArray<{ local: string, remote: string }>, givenConfig?: SSH.PutFilesOptions): Promise; putDirectory(localDirectory: string, remoteDirectory: string, givenConfig?: SSH.PutDirectoryOptions): Promise; dispose(): void; } export = SSH;