Socket
Socket
Sign inDemoInstall

node-ssh

Package Overview
Dependencies
12
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.0.0 to 11.1.0

10

CHANGELOG.md

@@ -0,1 +1,5 @@

#### 11.1.0
- Add support for `options` in `withShell` and `requestShell`
#### 11.0.0

@@ -14,3 +18,3 @@

* Fix unixification of paths (Thanks @mbr4477)
* Fix unixification of paths in more places (Thanks @mbr4477)

@@ -69,3 +73,3 @@ #### 10.0.0

#### 4.3.3
#### 4.2.3

@@ -111,4 +115,2 @@ * Fix passing options in `execCommand`

Confidently, this is the most stable version of this module to date :tada:
* Rename `.end` to `.dispose`

@@ -115,0 +117,0 @@ * Rename `.get` to `.getFile`

39

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]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeSSH = exports.SSHError = void 0;
const fs_1 = __importDefault(require("fs"));

@@ -200,6 +187,6 @@ const path_1 = __importDefault(require("path"));

}
async requestShell() {
async requestShell(options) {
const connection = this.getConnection();
return new Promise((resolve, reject) => {
connection.shell((err, res) => {
const callback = (err, res) => {
if (err) {

@@ -211,8 +198,14 @@ reject(err);

}
});
};
if (options == null) {
connection.shell(callback);
}
else {
connection.shell(options, callback);
}
});
}
async withShell(callback) {
async withShell(callback, options) {
assert_1.default(typeof callback === 'function', 'callback must be a valid function');
const shell = await this.requestShell();
const shell = await this.requestShell(options);
try {

@@ -219,0 +212,0 @@ await callback(shell);

/// <reference types="node" />
import SSH2, { ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions } from 'ssh2';
import SSH2, { ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions, PseudoTtyOptions, ShellOptions } from 'ssh2';
import { Prompt, TransferOptions } from 'ssh2-streams';

@@ -48,4 +48,4 @@ export declare type Config = ConnectConfig & {

isConnected(): boolean;
requestShell(): Promise<ClientChannel>;
withShell(callback: (channel: ClientChannel) => Promise<void>): Promise<void>;
requestShell(options?: PseudoTtyOptions | ShellOptions | false): Promise<ClientChannel>;
withShell(callback: (channel: ClientChannel) => Promise<void>, options?: PseudoTtyOptions | ShellOptions | false): Promise<void>;
requestSFTP(): Promise<SFTPWrapper>;

@@ -52,0 +52,0 @@ withSFTP(callback: (sftp: SFTPWrapper) => Promise<void>): Promise<void>;

{
"name": "node-ssh",
"version": "11.0.0",
"version": "11.1.0",
"description": "SS2 with Promises",

@@ -5,0 +5,0 @@ "main": "lib/cjs/index.js",

@@ -9,8 +9,7 @@ Node-SSH - SSH2 with Promises

```js
var path, NodeSSH, ssh, fs
const fs = require('fs')
const path = require('path')
const {NodeSSH} = require('node-ssh')
fs = require('fs')
path = require('path')
NodeSSH = require('node-ssh')
ssh = new NodeSSH()
const ssh = new NodeSSH()

@@ -104,3 +103,3 @@ ssh.connect({

// API reference in Typescript typing format:
import { Client, ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions } from 'ssh2';
import { Client, ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions, PseudoTtyOptions | ShellOptions } from 'ssh2';
import { Prompt, TransferOptions } from 'ssh2-streams';

@@ -167,6 +166,9 @@ // ^ You do NOT need to import these package, these are here for reference of where the

requestShell(): Promise<ClientChannel>;
requestShell(
options?: PseudoTtyOptions | ShellOptions | false
): Promise<ClientChannel>;
withShell(
callback: (channel: ClientChannel) => Promise<void>
callback: (channel: ClientChannel) => Promise<void>,
options?: PseudoTtyOptions | ShellOptions | false
): Promise<void>;

@@ -259,12 +261,19 @@

tryKeyboard: true,
onKeyboardInteractive: (name, instructions, instructionsLang, prompts, finish) => {
if (prompts.length > 0 && prompts[0].prompt.toLowerCase().includes('password')) {
finish([password])
}
})
// Or if you want to add some custom keyboard-interactive logic:
ssh.connect({
host: 'localhost',
username: 'steel',
port: 22,
tryKeyboard: true,
onKeyboardInteractive(name, instructions, instructionsLang, prompts, finish) {
if (prompts.length > 0 && prompts[0].prompt.toLowerCase().includes('password')) {
finish([password])
}
}
})
```
For further information see: https://github.com/mscdex/ssh2/issues/604

@@ -271,0 +280,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