Socket
Socket
Sign inDemoInstall

node-ssh

Package Overview
Dependencies
26
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 13.1.0 to 13.2.0

147

lib/cjs/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -26,10 +30,10 @@ if (k2 === undefined) k2 = k;

exports.NodeSSH = exports.SSHError = void 0;
const assert_1 = __importStar(require("assert"));
const fs_1 = __importDefault(require("fs"));
const is_stream_1 = __importDefault(require("is-stream"));
const make_dir_1 = __importDefault(require("make-dir"));
const path_1 = __importDefault(require("path"));
const make_dir_1 = __importDefault(require("make-dir"));
const is_stream_1 = __importDefault(require("is-stream"));
const sb_promise_queue_1 = require("sb-promise-queue");
const sb_scandir_1 = __importDefault(require("sb-scandir"));
const shell_escape_1 = __importDefault(require("shell-escape"));
const sb_scandir_1 = __importDefault(require("sb-scandir"));
const sb_promise_queue_1 = require("sb-promise-queue");
const assert_1 = __importStar(require("assert"));
const ssh2_1 = __importDefault(require("ssh2"));

@@ -125,10 +129,10 @@ const DEFAULT_CONCURRENCY = 1;

async connect(givenConfig) {
assert_1.default(givenConfig != null && typeof givenConfig === 'object', 'config must be a valid object');
(0, assert_1.default)(givenConfig != null && typeof givenConfig === 'object', 'config must be a valid object');
const config = { ...givenConfig };
assert_1.default(config.username != null && typeof config.username === 'string', 'config.username must be a valid string');
(0, assert_1.default)(config.username != null && typeof config.username === 'string', 'config.username must be a valid string');
if (config.host != null) {
assert_1.default(typeof config.host === 'string', 'config.host must be a valid string');
(0, assert_1.default)(typeof config.host === 'string', 'config.host must be a valid string');
}
else if (config.sock != null) {
assert_1.default(typeof config.sock === 'object', 'config.sock must be a valid object');
(0, assert_1.default)(typeof config.sock === 'object', 'config.sock must be a valid object');
}

@@ -140,10 +144,10 @@ else {

if (config.privateKey != null) {
assert_1.default(typeof config.privateKey === 'string', 'config.privateKey must be a valid string');
assert_1.default(config.privateKeyPath == null, 'config.privateKeyPath must not be specified when config.privateKey is specified');
(0, assert_1.default)(typeof config.privateKey === 'string', 'config.privateKey must be a valid string');
(0, assert_1.default)(config.privateKeyPath == null, 'config.privateKeyPath must not be specified when config.privateKey is specified');
}
else if (config.privateKeyPath != null) {
assert_1.default(typeof config.privateKeyPath === 'string', 'config.privateKeyPath must be a valid string');
assert_1.default(config.privateKey == null, 'config.privateKey must not be specified when config.privateKeyPath is specified');
(0, assert_1.default)(typeof config.privateKeyPath === 'string', 'config.privateKeyPath must be a valid string');
(0, assert_1.default)(config.privateKey == null, 'config.privateKey must not be specified when config.privateKeyPath is specified');
}
assert_1.default(config.passphrase == null || typeof config.passphrase === 'string', 'config.passphrase must be null or a valid string');
(0, assert_1.default)(config.passphrase == null || typeof config.passphrase === 'string', 'config.passphrase must be null or a valid string');
if (config.privateKeyPath != null) {

@@ -163,6 +167,6 @@ // Must be an fs path

else if (config.password != null) {
assert_1.default(typeof config.password === 'string', 'config.password must be a valid string');
(0, assert_1.default)(typeof config.password === 'string', 'config.password must be a valid string');
}
if (config.tryKeyboard != null) {
assert_1.default(typeof config.tryKeyboard === 'boolean', 'config.tryKeyboard must be a valid boolean');
(0, assert_1.default)(typeof config.tryKeyboard === 'boolean', 'config.tryKeyboard must be a valid boolean');
}

@@ -172,3 +176,3 @@ if (config.tryKeyboard) {

if (config.onKeyboardInteractive != null) {
assert_1.default(typeof config.onKeyboardInteractive === 'function', 'config.onKeyboardInteractive must be a valid function');
(0, assert_1.default)(typeof config.onKeyboardInteractive === 'function', 'config.onKeyboardInteractive must be a valid function');
}

@@ -234,3 +238,3 @@ else if (password != null) {

async withShell(callback, options) {
assert_1.default(typeof callback === 'function', 'callback must be a valid function');
(0, assert_1.default)(typeof callback === 'function', 'callback must be a valid function');
const shell = await this.requestShell(options);

@@ -241,7 +245,3 @@ try {

finally {
// Try to close gracefully
if (!shell.close()) {
// Destroy local socket if it doesn't work
shell.destroy();
}
shell.destroy();
}

@@ -265,3 +265,3 @@ }

async withSFTP(callback) {
assert_1.default(typeof callback === 'function', 'callback must be a valid function');
(0, assert_1.default)(typeof callback === 'function', 'callback must be a valid function');
const sftp = await this.requestSFTP();

@@ -276,14 +276,15 @@ try {

async execCommand(givenCommand, options = {}) {
assert_1.default(typeof givenCommand === 'string', 'command must be a valid string');
assert_1.default(options != null && typeof options === 'object', 'options must be a valid object');
assert_1.default(options.cwd == null || typeof options.cwd === 'string', 'options.cwd must be a valid string');
assert_1.default(options.stdin == null || typeof options.stdin === 'string' || is_stream_1.default.readable(options.stdin), 'options.stdin must be a valid string or readable stream');
assert_1.default(options.execOptions == null || typeof options.execOptions === 'object', 'options.execOptions must be a valid object');
assert_1.default(options.encoding == null || typeof options.encoding === 'string', 'options.encoding must be a valid string');
assert_1.default(options.onChannel == null || typeof options.onChannel === 'function', 'options.onChannel must be a valid function');
assert_1.default(options.onStdout == null || typeof options.onStdout === 'function', 'options.onStdout must be a valid function');
assert_1.default(options.onStderr == null || typeof options.onStderr === 'function', 'options.onStderr must be a valid function');
(0, assert_1.default)(typeof givenCommand === 'string', 'command must be a valid string');
(0, assert_1.default)(options != null && typeof options === 'object', 'options must be a valid object');
(0, assert_1.default)(options.cwd == null || typeof options.cwd === 'string', 'options.cwd must be a valid string');
(0, assert_1.default)(options.stdin == null || typeof options.stdin === 'string' || is_stream_1.default.readable(options.stdin), 'options.stdin must be a valid string or readable stream');
(0, assert_1.default)(options.execOptions == null || typeof options.execOptions === 'object', 'options.execOptions must be a valid object');
(0, assert_1.default)(options.encoding == null || typeof options.encoding === 'string', 'options.encoding must be a valid string');
(0, assert_1.default)(options.onChannel == null || typeof options.onChannel === 'function', 'options.onChannel must be a valid function');
(0, assert_1.default)(options.onStdout == null || typeof options.onStdout === 'function', 'options.onStdout must be a valid function');
(0, assert_1.default)(options.onStderr == null || typeof options.onStderr === 'function', 'options.onStderr must be a valid function');
(0, assert_1.default)(options.noTrim == null || typeof options.noTrim === 'boolean', 'options.noTrim must be a boolean');
let command = givenCommand;
if (options.cwd) {
command = `cd ${shell_escape_1.default([options.cwd])} ; ${command}`;
command = `cd ${(0, shell_escape_1.default)([options.cwd])} ; ${command}`;
}

@@ -334,7 +335,13 @@ const connection = this.getConnection();

channel.on('close', () => {
let stdout = output.stdout.join('');
let stderr = output.stderr.join('');
if (options.noTrim !== true) {
stdout = stdout.trim();
stderr = stderr.trim();
}
resolve({
code: code != null ? code : null,
signal: signal != null ? signal : null,
stdout: output.stdout.join('').trim(),
stderr: output.stderr.join('').trim(),
stdout,
stderr,
});

@@ -346,10 +353,10 @@ });

async exec(command, parameters, options = {}) {
assert_1.default(typeof command === 'string', 'command must be a valid string');
assert_1.default(Array.isArray(parameters), 'parameters must be a valid array');
assert_1.default(options != null && typeof options === 'object', 'options must be a valid object');
assert_1.default(options.stream == null || ['both', 'stdout', 'stderr'].includes(options.stream), 'options.stream must be one of both, stdout, stderr');
(0, assert_1.default)(typeof command === 'string', 'command must be a valid string');
(0, assert_1.default)(Array.isArray(parameters), 'parameters must be a valid array');
(0, assert_1.default)(options != null && typeof options === 'object', 'options must be a valid object');
(0, assert_1.default)(options.stream == null || ['both', 'stdout', 'stderr'].includes(options.stream), 'options.stream must be one of both, stdout, stderr');
for (let i = 0, { length } = parameters; i < length; i += 1) {
assert_1.default(typeof parameters[i] === 'string', `parameters[${i}] must be a valid string`);
(0, assert_1.default)(typeof parameters[i] === 'string', `parameters[${i}] must be a valid string`);
}
const completeCommand = `${command}${parameters.length > 0 ? ` ${shell_escape_1.default(parameters)}` : ''}`;
const completeCommand = `${command}${parameters.length > 0 ? ` ${(0, shell_escape_1.default)(parameters)}` : ''}`;
const response = await this.execCommand(completeCommand, options);

@@ -368,5 +375,5 @@ if (options.stream == null || options.stream === 'stdout') {

async mkdir(path, method = 'sftp', givenSftp = null) {
assert_1.default(typeof path === 'string', 'path must be a valid string');
assert_1.default(typeof method === 'string' && (method === 'sftp' || method === 'exec'), 'method must be either sftp or exec');
assert_1.default(givenSftp == null || typeof givenSftp === 'object', 'sftp must be a valid object');
(0, assert_1.default)(typeof path === 'string', 'path must be a valid string');
(0, assert_1.default)(typeof method === 'string' && (method === 'sftp' || method === 'exec'), 'method must be either sftp or exec');
(0, assert_1.default)(givenSftp == null || typeof givenSftp === 'object', 'sftp must be a valid object');
if (method === 'exec') {

@@ -394,6 +401,6 @@ await this.exec('mkdir', ['-p', unixifyPath(path)]);

async getFile(localFile, remoteFile, givenSftp = null, transferOptions = null) {
assert_1.default(typeof localFile === 'string', 'localFile must be a valid string');
assert_1.default(typeof remoteFile === 'string', 'remoteFile must be a valid string');
assert_1.default(givenSftp == null || typeof givenSftp === 'object', 'sftp must be a valid object');
assert_1.default(transferOptions == null || typeof transferOptions === 'object', 'transferOptions must be a valid object');
(0, assert_1.default)(typeof localFile === 'string', 'localFile must be a valid string');
(0, assert_1.default)(typeof remoteFile === 'string', 'remoteFile must be a valid string');
(0, assert_1.default)(givenSftp == null || typeof givenSftp === 'object', 'sftp must be a valid object');
(0, assert_1.default)(transferOptions == null || typeof transferOptions === 'object', 'transferOptions must be a valid object');
const sftp = givenSftp || (await this.requestSFTP());

@@ -419,7 +426,7 @@ try {

async putFile(localFile, remoteFile, givenSftp = null, transferOptions = null) {
assert_1.default(typeof localFile === 'string', 'localFile must be a valid string');
assert_1.default(typeof remoteFile === 'string', 'remoteFile must be a valid string');
assert_1.default(givenSftp == null || typeof givenSftp === 'object', 'sftp must be a valid object');
assert_1.default(transferOptions == null || typeof transferOptions === 'object', 'transferOptions must be a valid object');
assert_1.default(await new Promise((resolve) => {
(0, assert_1.default)(typeof localFile === 'string', 'localFile must be a valid string');
(0, assert_1.default)(typeof remoteFile === 'string', 'remoteFile must be a valid string');
(0, assert_1.default)(givenSftp == null || typeof givenSftp === 'object', 'sftp must be a valid object');
(0, assert_1.default)(transferOptions == null || typeof transferOptions === 'object', 'transferOptions must be a valid object');
(0, assert_1.default)(await new Promise((resolve) => {
fs_1.default.access(localFile, fs_1.default.constants.R_OK, (err) => {

@@ -456,8 +463,8 @@ resolve(err === null);

async putFiles(files, { concurrency = DEFAULT_CONCURRENCY, sftp: givenSftp = null, transferOptions = {} } = {}) {
assert_1.default(Array.isArray(files), 'files must be an array');
(0, assert_1.default)(Array.isArray(files), 'files must be an array');
for (let i = 0, { length } = files; i < length; i += 1) {
const file = files[i];
assert_1.default(file, 'files items must be valid objects');
assert_1.default(file.local && typeof file.local === 'string', `files[${i}].local must be a string`);
assert_1.default(file.remote && typeof file.remote === 'string', `files[${i}].remote must be a string`);
(0, assert_1.default)(file, 'files items must be valid objects');
(0, assert_1.default)(file.local && typeof file.local === 'string', `files[${i}].local must be a string`);
(0, assert_1.default)(file.remote && typeof file.remote === 'string', `files[${i}].remote must be a string`);
}

@@ -493,4 +500,4 @@ const transferred = [];

async putDirectory(localDirectory, remoteDirectory, { concurrency = DEFAULT_CONCURRENCY, sftp: givenSftp = null, transferOptions = {}, recursive = true, tick = DEFAULT_TICK, validate = DEFAULT_VALIDATE, } = {}) {
assert_1.default(typeof localDirectory === 'string' && localDirectory, 'localDirectory must be a string');
assert_1.default(typeof remoteDirectory === 'string' && remoteDirectory, 'remoteDirectory must be a string');
(0, assert_1.default)(typeof localDirectory === 'string' && localDirectory, 'localDirectory must be a string');
(0, assert_1.default)(typeof remoteDirectory === 'string' && remoteDirectory, 'remoteDirectory must be a string');
const localDirectoryStat = await new Promise((resolve) => {

@@ -501,6 +508,6 @@ fs_1.default.stat(localDirectory, (err, stat) => {

});
assert_1.default(localDirectoryStat != null, `localDirectory does not exist at ${localDirectory}`);
assert_1.default(localDirectoryStat.isDirectory(), `localDirectory is not a directory at ${localDirectory}`);
(0, assert_1.default)(localDirectoryStat != null, `localDirectory does not exist at ${localDirectory}`);
(0, assert_1.default)(localDirectoryStat.isDirectory(), `localDirectory is not a directory at ${localDirectory}`);
const sftp = givenSftp || (await this.requestSFTP());
const scanned = await sb_scandir_1.default(localDirectory, {
const scanned = await (0, sb_scandir_1.default)(localDirectory, {
recursive,

@@ -557,4 +564,4 @@ validate,

async getDirectory(localDirectory, remoteDirectory, { concurrency = DEFAULT_CONCURRENCY, sftp: givenSftp = null, transferOptions = {}, recursive = true, tick = DEFAULT_TICK, validate = DEFAULT_VALIDATE, } = {}) {
assert_1.default(typeof localDirectory === 'string' && localDirectory, 'localDirectory must be a string');
assert_1.default(typeof remoteDirectory === 'string' && remoteDirectory, 'remoteDirectory must be a string');
(0, assert_1.default)(typeof localDirectory === 'string' && localDirectory, 'localDirectory must be a string');
(0, assert_1.default)(typeof remoteDirectory === 'string' && remoteDirectory, 'remoteDirectory must be a string');
const localDirectoryStat = await new Promise((resolve) => {

@@ -565,6 +572,6 @@ fs_1.default.stat(localDirectory, (err, stat) => {

});
assert_1.default(localDirectoryStat != null, `localDirectory does not exist at ${localDirectory}`);
assert_1.default(localDirectoryStat.isDirectory(), `localDirectory is not a directory at ${localDirectory}`);
(0, assert_1.default)(localDirectoryStat != null, `localDirectory does not exist at ${localDirectory}`);
(0, assert_1.default)(localDirectoryStat.isDirectory(), `localDirectory is not a directory at ${localDirectory}`);
const sftp = givenSftp || (await this.requestSFTP());
const scanned = await sb_scandir_1.default(remoteDirectory, {
const scanned = await (0, sb_scandir_1.default)(remoteDirectory, {
recursive,

@@ -619,3 +626,3 @@ validate,

.add(async () => {
await make_dir_1.default(path_1.default.join(localDirectory, directory));
await (0, make_dir_1.default)(path_1.default.join(localDirectory, directory));
})

@@ -622,0 +629,0 @@ .catch(reject);

/// <reference types="node" />
/// <reference types="node" />
import SSH2, { AcceptConnection, Channel, ClientChannel, ConnectConfig, ExecOptions, Prompt, PseudoTtyOptions, RejectConnection, SFTPWrapper, ShellOptions, TcpConnectionDetails, TransferOptions, UNIXConnectionDetails } from 'ssh2';
import stream from 'stream';
import SSH2, { ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions, PseudoTtyOptions, ShellOptions, Channel, TcpConnectionDetails, AcceptConnection, RejectConnection, UNIXConnectionDetails } from 'ssh2';
import { Prompt, TransferOptions } from 'ssh2-streams';
export declare type Config = ConnectConfig & {
export type Config = ConnectConfig & {
password?: string;

@@ -17,2 +17,3 @@ privateKey?: string;

encoding?: BufferEncoding;
noTrim?: boolean;
onChannel?: (clientChannel: ClientChannel) => void;

@@ -41,4 +42,4 @@ onStdout?: (chunk: Buffer) => void;

}
export declare type SSHMkdirMethod = 'sftp' | 'exec';
export declare type SSHForwardInListener = (details: TcpConnectionDetails, accept: AcceptConnection<ClientChannel>, reject: RejectConnection) => void;
export type SSHMkdirMethod = 'sftp' | 'exec';
export type SSHForwardInListener = (details: TcpConnectionDetails, accept: AcceptConnection<ClientChannel>, reject: RejectConnection) => void;
export interface SSHForwardInDetails {

@@ -48,3 +49,3 @@ dispose(): Promise<void>;

}
export declare type SSHForwardInStreamLocalListener = (info: UNIXConnectionDetails, accept: AcceptConnection, reject: RejectConnection) => void;
export type SSHForwardInStreamLocalListener = (info: UNIXConnectionDetails, accept: AcceptConnection, reject: RejectConnection) => void;
export interface SSHForwardInStreamLocalDetails {

@@ -51,0 +52,0 @@ dispose(): Promise<void>;

{
"name": "node-ssh",
"version": "13.1.0",
"version": "13.2.0",
"description": "SSH2 with Promises",

@@ -45,12 +45,15 @@ "main": "lib/cjs/index.js",

"devDependencies": {
"@types/shell-escape": "^0.2.0",
"ava": "^3.15.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@types/node": "18",
"@types/shell-escape": "^0.2.1",
"@types/ssh2": "^1.11.13",
"ava": "^5.3.1",
"eslint-config-steelbrain": "^11.0.0",
"node-pty": "^0.10.1",
"node-pty": "^1.0.0",
"ssh2": "^1.14.0",
"ssh2-streams": "^0.4.10",
"ts-node": "^10.1.0",
"typescript": "^4.3.5"
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"dependencies": {
"@types/ssh2": "^1.11.9",
"is-stream": "^2.0.0",

@@ -61,3 +64,3 @@ "make-dir": "^3.1.0",

"shell-escape": "^0.2.0",
"ssh2": "^1.11.0"
"ssh2": "^1.14.0"
},

@@ -64,0 +67,0 @@ "ava": {

@@ -6,2 +6,9 @@ Node-SSH - SSH2 with Promises

#### Installation
```sh
$ npm install node-ssh # If you're using npm
$ yarn add node-ssh # If you're using Yarn
```
#### Example

@@ -102,60 +109,66 @@

// API reference in Typescript typing format:
import SSH2, {
AcceptConnection,
Channel,
ClientChannel,
ConnectConfig,
ExecOptions,
Prompt,
PseudoTtyOptions,
RejectConnection,
SFTPWrapper,
ShellOptions,
TcpConnectionDetails,
TransferOptions,
UNIXConnectionDetails,
} from 'ssh2'
import stream from 'stream'
import { Client, ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions, PseudoTtyOptions | ShellOptions } from 'ssh2';
import { Prompt, TransferOptions } from 'ssh2-streams';
// ^ You do NOT need to import these package, these are here for reference of where the
// types are coming from.
declare type Config = ConnectConfig & {
host?: string;
port?: number;
username?: string;
password?: string;
privateKeyPath?: string;
privateKey?: string;
passphrase?: string;
tryKeyboard?: boolean;
onKeyboardInteractive?: (
name: string,
instructions: string,
lang: string,
prompts: Prompt[],
finish: (responses: string[]) => void
) => void;
};
interface SSHExecCommandOptions {
cwd?: string;
stdin?: string | stream.Readable;
execOptions?: ExecOptions;
encoding?: BufferEncoding;
onChannel?: (clientChannel: ClientChannel) => void;
onStdout?: (chunk: Buffer) => void;
onStderr?: (chunk: Buffer) => void;
export type Config = ConnectConfig & {
password?: string
privateKey?: string
privateKeyPath?: string
tryKeyboard?: boolean
onKeyboardInteractive?: (
name: string,
instructions: string,
lang: string,
prompts: Prompt[],
finish: (responses: string[]) => void,
) => void
}
interface SSHExecCommandResponse {
stdout: string;
stderr: string;
code: number | null;
signal: string | null;
export interface SSHExecCommandOptions {
cwd?: string
stdin?: string | stream.Readable
execOptions?: ExecOptions
encoding?: BufferEncoding
noTrim?: boolean
onChannel?: (clientChannel: ClientChannel) => void
onStdout?: (chunk: Buffer) => void
onStderr?: (chunk: Buffer) => void
}
interface SSHExecOptions extends SSHExecCommandOptions {
stream?: 'stdout' | 'stderr' | 'both';
export interface SSHExecCommandResponse {
stdout: string
stderr: string
code: number | null
signal: string | null
}
interface SSHPutFilesOptions {
sftp?: SFTPWrapper | null;
concurrency?: number;
transferOptions?: TransferOptions;
export interface SSHExecOptions extends SSHExecCommandOptions {
stream?: 'stdout' | 'stderr' | 'both'
}
interface SSHGetPutDirectoryOptions extends SSHPutFilesOptions {
tick?: (localFile: string, remoteFile: string, error: Error | null) => void;
validate?: (path: string) => boolean;
recursive?: boolean;
export interface SSHPutFilesOptions {
sftp?: SFTPWrapper | null
concurrency?: number
transferOptions?: TransferOptions
}
type SSHForwardInListener = (
export interface SSHGetPutDirectoryOptions extends SSHPutFilesOptions {
tick?: (localFile: string, remoteFile: string, error: Error | null) => void
validate?: (path: string) => boolean
recursive?: boolean
}
export type SSHMkdirMethod = 'sftp' | 'exec'
export type SSHForwardInListener = (
details: TcpConnectionDetails,

@@ -165,8 +178,7 @@ accept: AcceptConnection<ClientChannel>,

) => void
interface SSHForwardInDetails {
export interface SSHForwardInDetails {
dispose(): Promise<void>
port: number
}
type SSHForwardInStreamLocalListener = (
export type SSHForwardInStreamLocalListener = (
info: UNIXConnectionDetails,

@@ -176,113 +188,76 @@ accept: AcceptConnection,

) => void
interface SSHForwardInStreamLocalDetails {
export interface SSHForwardInStreamLocalDetails {
dispose(): Promise<void>
}
export class SSHError extends Error {
code: string | null
constructor(message: string, code?: string | null)
}
class NodeSSH {
connection: Client | null;
export class NodeSSH {
connection: SSH2.Client | null
connect(config: Config): Promise<this>;
isConnected(): boolean;
requestShell(
options?: PseudoTtyOptions | ShellOptions | false
): Promise<ClientChannel>;
withShell(
callback: (channel: ClientChannel) => Promise<void>,
options?: PseudoTtyOptions | ShellOptions | false
): Promise<void>;
requestSFTP(): Promise<SFTPWrapper>;
withSFTP(
callback: (sftp: SFTPWrapper) => Promise<void>
): Promise<void>;
execCommand(
command: string,
options?: SSHExecCommandOptions
): Promise<SSHExecCommandResponse>;
exec(
command: string,
parameters: string[],
options?: SSHExecOptions & {
stream?: 'stdout' | 'stderr';
}
): Promise<string>;
exec(
command: string,
parameters: string[],
options?: SSHExecOptions & {
stream: 'both';
}
): Promise<SSHExecCommandResponse>;
mkdir(
path: string,
method?: 'sftp' | 'exec',
sftp?: SFTPWrapper | null
): Promise<void>;
getFile(
localFile: string,
remoteFile: string,
sftp?: SFTPWrapper | null,
transferOptions?: TransferOptions | null
): Promise<void>;
putFile(
localFile: string,
remoteFile: string,
sftp?: SFTPWrapper | null,
transferOptions?: TransferOptions | null
): Promise<void>;
putFiles(files: Array<{
local: string;
remote: string;
}>, options?: SSHPutFilesOptions): Promise<void>;
putDirectory(
localDirectory: string,
remoteDirectory: string,
options?: SSHGetPutDirectoryOptions
): Promise<boolean>;
getDirectory(
localDirectory: string,
remoteDirectory: string,
options?: SSHGetPutDirectoryOptions
): Promise<boolean>;
forwardIn(
remoteAddr: string,
remotePort: number,
onConnection?: SSHForwardInListener
): Promise<SSHForwardInDetails>;
forwardOut(
srcIP: string,
srcPort: number,
dstIP: string,
dstPort: number
): Promise<Channel>;
forwardInStreamLocal(
socketPath: string,
onConnection?: SSHForwardInStreamLocalListener,
): Promise<SSHForwardInStreamLocalDetails>;
forwardOutStreamLocal(
socketPath: string
): Promise<Channel>;
dispose(): void;
connect(config: Config): Promise<this>
isConnected(): boolean
requestShell(options?: PseudoTtyOptions | ShellOptions | false): Promise<ClientChannel>
withShell(
callback: (channel: ClientChannel) => Promise<void>,
options?: PseudoTtyOptions | ShellOptions | false,
): Promise<void>
requestSFTP(): Promise<SFTPWrapper>
withSFTP(callback: (sftp: SFTPWrapper) => Promise<void>): Promise<void>
execCommand(givenCommand: string, options?: SSHExecCommandOptions): Promise<SSHExecCommandResponse>
exec(
command: string,
parameters: string[],
options?: SSHExecOptions & {
stream?: 'stdout' | 'stderr'
},
): Promise<string>
exec(
command: string,
parameters: string[],
options?: SSHExecOptions & {
stream: 'both'
},
): Promise<SSHExecCommandResponse>
mkdir(path: string, method?: SSHMkdirMethod, givenSftp?: SFTPWrapper | null): Promise<void>
getFile(
localFile: string,
remoteFile: string,
givenSftp?: SFTPWrapper | null,
transferOptions?: TransferOptions | null,
): Promise<void>
putFile(
localFile: string,
remoteFile: string,
givenSftp?: SFTPWrapper | null,
transferOptions?: TransferOptions | null,
): Promise<void>
putFiles(
files: {
local: string
remote: string
}[],
{ concurrency, sftp: givenSftp, transferOptions }?: SSHPutFilesOptions,
): Promise<void>
putDirectory(
localDirectory: string,
remoteDirectory: string,
{ concurrency, sftp: givenSftp, transferOptions, recursive, tick, validate }?: SSHGetPutDirectoryOptions,
): Promise<boolean>
getDirectory(
localDirectory: string,
remoteDirectory: string,
{ concurrency, sftp: givenSftp, transferOptions, recursive, tick, validate }?: SSHGetPutDirectoryOptions,
): Promise<boolean>
forwardIn(remoteAddr: string, remotePort: number, onConnection?: SSHForwardInListener): Promise<SSHForwardInDetails>
forwardOut(srcIP: string, srcPort: number, dstIP: string, dstPort: number): Promise<Channel>
forwardInStreamLocal(
socketPath: string,
onConnection?: SSHForwardInStreamLocalListener,
): Promise<SSHForwardInStreamLocalDetails>
forwardOutStreamLocal(socketPath: string): Promise<Channel>
dispose(): void
}
module.exports = NodeSSH;
```

@@ -289,0 +264,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc