ssh-client-wrapper 3.4.5 → 3.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -287,7 +287,7 @@ class SshClientWrapper {
287
287
  */
288
288
  async disconnect() {
289
289
  debug(`disconnect from ${this.hostInfo.host} called`);
290
- this.deps.disconnect(this.hostInfo);
290
+ return this.deps.disconnect(this.hostInfo);
291
291
  }
292
292
 
293
293
  /**
package/lib/sshError.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { stripTerminalSequences } from "./util.js";
2
2
 
3
3
  const MAX_OUTPUT = 4096;
4
+ const OK_PREFIX = "SCWOK";
4
5
  const FAIL_PREFIX = "SCWFAIL";
5
6
 
6
7
  //messages of ssh after which there is nothing to wait for. The first match wins.
@@ -56,18 +57,19 @@ export const makeSshError = (output, hostInfo)=>{
56
57
 
57
58
  /**
58
59
  * make the command line which is typed into the shell of the master pty
59
- * the shell prints the mark only if ssh fails. The mark is written with "" in it,
60
- * so that the line which the terminal echoes back does not contain the mark itself.
61
- * "||" is understood by sh, bash, zsh, fish and csh.
60
+ * the remote host echoes okMark if the login succeeds, and the shell prints failMark only if ssh fails.
61
+ * Both marks are written with "" in them, so that the line which the terminal echoes back (in one or more pieces)
62
+ * does not contain them. "||" is understood by sh, bash, zsh, fish and csh.
62
63
  * @param {string} cmd - ssh command
63
64
  * @param {Array} args - arguments of ssh
64
- * @param {string} words - string which the remote host echoes if the login succeeds
65
- * @param {string} failId - string which makes the mark unique. It must differ from words
66
- * @returns {object} - { line: command line, failMark: string which is printed if ssh fails }
65
+ * @param {string} words - string which makes okMark unique
66
+ * @param {string} failId - string which makes failMark unique. It must differ from words
67
+ * @returns {object} - { line: command line, okMark: string which tells success, failMark: string which tells failure }
67
68
  */
68
69
  export const makeMasterCommand = (cmd, args, words, failId)=>{
69
70
  return {
70
- line: `${cmd} ${args.join(" ")} echo ${words} || echo ${FAIL_PREFIX}""-${failId}\n`,
71
+ line: `${cmd} ${args.join(" ")} echo ${OK_PREFIX}""-${words} || echo ${FAIL_PREFIX}""-${failId}\n`,
72
+ okMark: `${OK_PREFIX}-${words}`,
71
73
  failMark: `${FAIL_PREFIX}-${failId}`
72
74
  };
73
75
  };
package/lib/sshExec.js CHANGED
@@ -237,9 +237,7 @@ export async function connect(hostInfo, timeout = 60) {
237
237
  let over = false;
238
238
 
239
239
  debug(`create master ssh session to ${hostInfo.host}`);
240
- const words = crypto.randomUUID();
241
- const re = new RegExp(`^${words}`);
242
- const { line, failMark } = makeMasterCommand(sshCmd, getSshOption(hostInfo), words, crypto.randomUUID());
240
+ const { line, okMark, failMark } = makeMasterCommand(sshCmd, getSshOption(hostInfo), crypto.randomUUID(), crypto.randomUUID());
243
241
 
244
242
  let ac = null;
245
243
  let output = "";
@@ -264,7 +262,7 @@ export async function connect(hostInfo, timeout = 60) {
264
262
  output = `${output}${chunk}`.slice(-65536);
265
263
  debugVerbose(chunk);
266
264
 
267
- if (re.test(chunk)) {
265
+ if (output.includes(okMark)) {
268
266
  debug("test done. call exit on remotehost");
269
267
  done = true;
270
268
  resolve();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh-client-wrapper",
3
- "version": "3.4.5",
3
+ "version": "3.4.6",
4
4
  "description": "wrapper library for open ssh client and rsync",
5
5
  "keywords": [
6
6
  "ssh",