bdy 1.23.6-dev → 1.23.7-dev

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.
Files changed (205) hide show
  1. package/distTs/package.json +10 -2
  2. package/distTs/src/agent/linux.js +53 -3
  3. package/distTs/src/agent/manager.js +3 -6
  4. package/distTs/src/agent/osx.js +51 -3
  5. package/distTs/src/agent/system.js +400 -21
  6. package/distTs/src/agent/windows.js +4 -7
  7. package/distTs/src/command/agent/debug.js +2 -2
  8. package/distTs/src/command/agent/install.js +37 -10
  9. package/distTs/src/command/agent/restart.js +2 -2
  10. package/distTs/src/command/agent/run.js +3 -0
  11. package/distTs/src/command/agent/start.js +2 -2
  12. package/distTs/src/command/agent/status.js +19 -0
  13. package/distTs/src/command/agent/stop.js +2 -2
  14. package/distTs/src/command/agent/uninstall.js +5 -8
  15. package/distTs/src/command/agent/update.js +2 -2
  16. package/distTs/src/command/artifact/publish.js +3 -1
  17. package/distTs/src/command/version.js +13 -5
  18. package/distTs/src/logger.js +40 -4
  19. package/distTs/src/texts.js +35 -19
  20. package/distTs/src/utils.js +98 -3
  21. package/node_modules/asn1/Jenkinsfile +65 -0
  22. package/node_modules/asn1/LICENSE +19 -0
  23. package/node_modules/asn1/README.md +50 -0
  24. package/node_modules/asn1/lib/ber/errors.js +13 -0
  25. package/node_modules/asn1/lib/ber/index.js +27 -0
  26. package/node_modules/asn1/lib/ber/reader.js +262 -0
  27. package/node_modules/asn1/lib/ber/types.js +36 -0
  28. package/node_modules/asn1/lib/ber/writer.js +317 -0
  29. package/node_modules/asn1/lib/index.js +20 -0
  30. package/node_modules/asn1/package.json +31 -0
  31. package/node_modules/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
  32. package/node_modules/bcrypt-pbkdf/LICENSE +66 -0
  33. package/node_modules/bcrypt-pbkdf/README.md +45 -0
  34. package/node_modules/bcrypt-pbkdf/index.js +556 -0
  35. package/node_modules/bcrypt-pbkdf/package.json +15 -0
  36. package/node_modules/safer-buffer/LICENSE +21 -0
  37. package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  38. package/node_modules/safer-buffer/Readme.md +156 -0
  39. package/node_modules/safer-buffer/dangerous.js +58 -0
  40. package/node_modules/safer-buffer/package.json +34 -0
  41. package/node_modules/safer-buffer/safer.js +77 -0
  42. package/node_modules/safer-buffer/tests.js +406 -0
  43. package/node_modules/ssh2/.eslintignore +4 -0
  44. package/node_modules/ssh2/.eslintrc.js +5 -0
  45. package/node_modules/ssh2/.github/workflows/ci.yml +110 -0
  46. package/node_modules/ssh2/.github/workflows/lint.yml +27 -0
  47. package/node_modules/ssh2/LICENSE +19 -0
  48. package/node_modules/ssh2/README.md +1529 -0
  49. package/node_modules/ssh2/SFTP.md +413 -0
  50. package/node_modules/ssh2/examples/server-chat.js +238 -0
  51. package/node_modules/ssh2/examples/sftp-server-download-only.js +134 -0
  52. package/node_modules/ssh2/install.js +27 -0
  53. package/node_modules/ssh2/lib/Channel.js +295 -0
  54. package/node_modules/ssh2/lib/agent.js +1123 -0
  55. package/node_modules/ssh2/lib/client.js +2176 -0
  56. package/node_modules/ssh2/lib/http-agents.js +84 -0
  57. package/node_modules/ssh2/lib/index.js +44 -0
  58. package/node_modules/ssh2/lib/keygen.js +582 -0
  59. package/node_modules/ssh2/lib/protocol/Protocol.js +2136 -0
  60. package/node_modules/ssh2/lib/protocol/SFTP.js +4052 -0
  61. package/node_modules/ssh2/lib/protocol/constants.js +356 -0
  62. package/node_modules/ssh2/lib/protocol/crypto/binding.gyp +23 -0
  63. package/node_modules/ssh2/lib/protocol/crypto/poly1305.js +43 -0
  64. package/node_modules/ssh2/lib/protocol/crypto/src/binding.cc +2300 -0
  65. package/node_modules/ssh2/lib/protocol/crypto.js +1602 -0
  66. package/node_modules/ssh2/lib/protocol/handlers.js +16 -0
  67. package/node_modules/ssh2/lib/protocol/handlers.misc.js +1285 -0
  68. package/node_modules/ssh2/lib/protocol/kex.js +1908 -0
  69. package/node_modules/ssh2/lib/protocol/keyParser.js +1484 -0
  70. package/node_modules/ssh2/lib/protocol/node-fs-compat.js +115 -0
  71. package/node_modules/ssh2/lib/protocol/utils.js +356 -0
  72. package/node_modules/ssh2/lib/protocol/zlib.js +255 -0
  73. package/node_modules/ssh2/lib/server.js +1380 -0
  74. package/node_modules/ssh2/lib/utils.js +336 -0
  75. package/node_modules/ssh2/package.json +49 -0
  76. package/node_modules/ssh2/test/common.js +316 -0
  77. package/node_modules/ssh2/test/fixtures/bad_rsa_private_key +26 -0
  78. package/node_modules/ssh2/test/fixtures/https_cert.pem +33 -0
  79. package/node_modules/ssh2/test/fixtures/https_key.pem +52 -0
  80. package/node_modules/ssh2/test/fixtures/id_dsa +12 -0
  81. package/node_modules/ssh2/test/fixtures/id_ecdsa +5 -0
  82. package/node_modules/ssh2/test/fixtures/id_rsa +15 -0
  83. package/node_modules/ssh2/test/fixtures/id_rsa.ppk +26 -0
  84. package/node_modules/ssh2/test/fixtures/id_rsa_enc +30 -0
  85. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa +21 -0
  86. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub +1 -0
  87. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub.result +7 -0
  88. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.result +7 -0
  89. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc +22 -0
  90. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub +1 -0
  91. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub.result +7 -0
  92. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.result +7 -0
  93. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm +23 -0
  94. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub +1 -0
  95. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub.result +7 -0
  96. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.result +7 -0
  97. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa +9 -0
  98. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub +1 -0
  99. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub.result +7 -0
  100. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.result +7 -0
  101. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc +10 -0
  102. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub +1 -0
  103. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub.result +8 -0
  104. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.result +7 -0
  105. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm +10 -0
  106. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub +1 -0
  107. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub.result +8 -0
  108. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.result +7 -0
  109. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519 +7 -0
  110. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub +1 -0
  111. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub.result +7 -0
  112. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.result +7 -0
  113. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa +27 -0
  114. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub +1 -0
  115. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub.result +7 -0
  116. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.result +7 -0
  117. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc +28 -0
  118. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub +1 -0
  119. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub.result +8 -0
  120. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.result +7 -0
  121. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm +29 -0
  122. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub +1 -0
  123. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub.result +8 -0
  124. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.result +7 -0
  125. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa +12 -0
  126. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub +1 -0
  127. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub.result +7 -0
  128. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.result +7 -0
  129. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc +15 -0
  130. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub +1 -0
  131. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub.result +8 -0
  132. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.result +7 -0
  133. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa +5 -0
  134. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub +1 -0
  135. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub.result +7 -0
  136. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.result +7 -0
  137. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc +8 -0
  138. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub +1 -0
  139. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub.result +8 -0
  140. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.result +7 -0
  141. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa +27 -0
  142. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub +1 -0
  143. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub.result +7 -0
  144. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.result +7 -0
  145. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc +30 -0
  146. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub +1 -0
  147. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub.result +8 -0
  148. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.result +7 -0
  149. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256 +54 -0
  150. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub +1 -0
  151. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub.result +6 -0
  152. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.result +6 -0
  153. package/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc +17 -0
  154. package/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc.result +7 -0
  155. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa +26 -0
  156. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa.result +7 -0
  157. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc +18 -0
  158. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc.result +7 -0
  159. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub +9 -0
  160. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub.result +7 -0
  161. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub +10 -0
  162. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub.result +7 -0
  163. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub +11 -0
  164. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub.result +7 -0
  165. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub +11 -0
  166. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub.result +7 -0
  167. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub +8 -0
  168. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub.result +7 -0
  169. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub +13 -0
  170. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub.result +7 -0
  171. package/node_modules/ssh2/test/fixtures/openssh_new_rsa +27 -0
  172. package/node_modules/ssh2/test/fixtures/ssh_host_dsa_key +12 -0
  173. package/node_modules/ssh2/test/fixtures/ssh_host_ecdsa_key +5 -0
  174. package/node_modules/ssh2/test/fixtures/ssh_host_rsa_key +15 -0
  175. package/node_modules/ssh2/test/test-exec.js +578 -0
  176. package/node_modules/ssh2/test/test-integration-openssh.js +486 -0
  177. package/node_modules/ssh2/test/test-keygen.js +60 -0
  178. package/node_modules/ssh2/test/test-misc-client-server.js +1460 -0
  179. package/node_modules/ssh2/test/test-openssh.js +261 -0
  180. package/node_modules/ssh2/test/test-protocol-crypto.js +631 -0
  181. package/node_modules/ssh2/test/test-protocol-keyparser.js +177 -0
  182. package/node_modules/ssh2/test/test-server-hostkeys.js +138 -0
  183. package/node_modules/ssh2/test/test-sftp.js +842 -0
  184. package/node_modules/ssh2/test/test-shell.js +109 -0
  185. package/node_modules/ssh2/test/test-userauth-agent-openssh.js +110 -0
  186. package/node_modules/ssh2/test/test-userauth-agent.js +171 -0
  187. package/node_modules/ssh2/test/test-userauth.js +611 -0
  188. package/node_modules/ssh2/test/test-worker-imports.js +25 -0
  189. package/node_modules/ssh2/test/test.js +20 -0
  190. package/node_modules/ssh2/util/build_pagent.bat +2 -0
  191. package/node_modules/ssh2/util/pagent.c +88 -0
  192. package/node_modules/ssh2/util/pagent.exe +0 -0
  193. package/node_modules/tweetnacl/.npmignore +4 -0
  194. package/node_modules/tweetnacl/AUTHORS.md +28 -0
  195. package/node_modules/tweetnacl/CHANGELOG.md +221 -0
  196. package/node_modules/tweetnacl/LICENSE +24 -0
  197. package/node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
  198. package/node_modules/tweetnacl/README.md +459 -0
  199. package/node_modules/tweetnacl/nacl-fast.js +2388 -0
  200. package/node_modules/tweetnacl/nacl-fast.min.js +2 -0
  201. package/node_modules/tweetnacl/nacl.d.ts +98 -0
  202. package/node_modules/tweetnacl/nacl.js +1175 -0
  203. package/node_modules/tweetnacl/nacl.min.js +1 -0
  204. package/node_modules/tweetnacl/package.json +58 -0
  205. package/package.json +10 -2
@@ -0,0 +1,611 @@
1
+ 'use strict';
2
+
3
+ const assert = require('assert');
4
+ const { inspect } = require('util');
5
+
6
+ const {
7
+ fixtureKey,
8
+ mustCall,
9
+ mustNotCall,
10
+ setup,
11
+ } = require('./common.js');
12
+
13
+ const serverCfg = { hostKeys: [ fixtureKey('ssh_host_rsa_key').raw ] };
14
+
15
+ const debug = false;
16
+
17
+ // Keys ========================================================================
18
+ [
19
+ { desc: 'RSA (old OpenSSH)',
20
+ clientKey: fixtureKey('id_rsa') },
21
+ { desc: 'RSA (new OpenSSH)',
22
+ clientKey: fixtureKey('openssh_new_rsa') },
23
+ { desc: 'RSA (encrypted)',
24
+ clientKey: fixtureKey('id_rsa_enc', 'foobarbaz'),
25
+ passphrase: 'foobarbaz' },
26
+ { desc: 'DSA',
27
+ clientKey: fixtureKey('id_dsa') },
28
+ { desc: 'ECDSA',
29
+ clientKey: fixtureKey('id_ecdsa') },
30
+ { desc: 'PPK',
31
+ clientKey: fixtureKey('id_rsa.ppk') },
32
+ ].forEach((test) => {
33
+ const { desc, clientKey, passphrase } = test;
34
+ const username = 'Key User';
35
+ const { server } = setup(
36
+ desc,
37
+ {
38
+ client: { username, privateKey: clientKey.raw, passphrase },
39
+ server: serverCfg,
40
+
41
+ debug,
42
+ }
43
+ );
44
+
45
+ server.on('connection', mustCall((conn) => {
46
+ let authAttempt = 0;
47
+ conn.on('authentication', mustCall((ctx) => {
48
+ assert(ctx.username === username,
49
+ `Wrong username: ${ctx.username}`);
50
+ switch (++authAttempt) {
51
+ case 1:
52
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
53
+ return ctx.reject();
54
+ case 3:
55
+ assert(ctx.signature, 'Missing publickey signature');
56
+ // FALLTHROUGH
57
+ case 2:
58
+ assert(ctx.method === 'publickey',
59
+ `Wrong auth method: ${ctx.method}`);
60
+ assert(ctx.key.algo === clientKey.key.type,
61
+ `Wrong key algo: ${ctx.key.algo}`);
62
+ assert.deepStrictEqual(clientKey.key.getPublicSSH(),
63
+ ctx.key.data,
64
+ 'Public key mismatch');
65
+ break;
66
+ }
67
+ if (ctx.signature) {
68
+ const result =
69
+ clientKey.key.verify(ctx.blob, ctx.signature, ctx.hashAlgo);
70
+ assert(result === true, 'Could not verify publickey signature');
71
+ }
72
+ ctx.accept();
73
+ }, 3)).on('ready', mustCall(() => {
74
+ conn.end();
75
+ }));
76
+ }));
77
+ });
78
+
79
+
80
+ // Password ====================================================================
81
+ {
82
+ const username = 'Password User';
83
+ const password = 'hi mom';
84
+ const { server } = setup(
85
+ 'Password',
86
+ {
87
+ client: { username, password },
88
+ server: serverCfg,
89
+
90
+ debug,
91
+ }
92
+ );
93
+
94
+ server.on('connection', mustCall((conn) => {
95
+ let authAttempt = 0;
96
+ conn.on('authentication', mustCall((ctx) => {
97
+ assert(ctx.username === username,
98
+ `Wrong username: ${ctx.username}`);
99
+ if (++authAttempt === 1) {
100
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
101
+ return ctx.reject();
102
+ }
103
+ assert(ctx.method === 'password',
104
+ `Wrong auth method: ${ctx.method}`);
105
+ assert(ctx.password === password,
106
+ `Wrong password: ${ctx.password}`);
107
+ ctx.accept();
108
+ }, 2)).on('ready', mustCall(() => {
109
+ conn.end();
110
+ }));
111
+ }));
112
+ }
113
+ {
114
+ const username = '';
115
+ const password = 'hi mom';
116
+ const { server } = setup(
117
+ 'Password (empty username)',
118
+ {
119
+ client: { username, password },
120
+ server: serverCfg,
121
+
122
+ debug,
123
+ }
124
+ );
125
+
126
+ server.on('connection', mustCall((conn) => {
127
+ let authAttempt = 0;
128
+ conn.on('authentication', mustCall((ctx) => {
129
+ assert(ctx.username === username,
130
+ `Wrong username: ${ctx.username}`);
131
+ if (++authAttempt === 1) {
132
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
133
+ return ctx.reject();
134
+ }
135
+ assert(ctx.method === 'password',
136
+ `Wrong auth method: ${ctx.method}`);
137
+ assert(ctx.password === password,
138
+ `Wrong password: ${ctx.password}`);
139
+ ctx.accept();
140
+ }, 2)).on('ready', mustCall(() => {
141
+ conn.end();
142
+ }));
143
+ }));
144
+ }
145
+ {
146
+ const username = 'foo';
147
+ const oldPassword = 'bar';
148
+ const newPassword = 'baz';
149
+ const changePrompt = 'Prithee changeth thy password';
150
+ const { client, server } = setup(
151
+ 'Password (change requested)',
152
+ {
153
+ client: { username, password: oldPassword },
154
+ server: serverCfg,
155
+
156
+ debug,
157
+ }
158
+ );
159
+
160
+ server.on('connection', mustCall((conn) => {
161
+ let authAttempt = 0;
162
+ conn.on('authentication', mustCall((ctx) => {
163
+ assert(ctx.username === username,
164
+ `Wrong username: ${ctx.username}`);
165
+ if (++authAttempt === 1) {
166
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
167
+ return ctx.reject();
168
+ }
169
+ assert(ctx.method === 'password',
170
+ `Wrong auth method: ${ctx.method}`);
171
+ assert(ctx.password === oldPassword,
172
+ `Wrong old password: ${ctx.password}`);
173
+ ctx.requestChange(changePrompt, mustCall((newPassword_) => {
174
+ assert(newPassword_ === newPassword,
175
+ `Wrong new password: ${newPassword_}`);
176
+ ctx.accept();
177
+ }));
178
+ }, 2)).on('ready', mustCall(() => {
179
+ conn.end();
180
+ }));
181
+ }));
182
+
183
+ client.on('change password', mustCall((prompt, done) => {
184
+ assert(prompt === changePrompt, `Wrong password change prompt: ${prompt}`);
185
+ process.nextTick(done, newPassword);
186
+ }));
187
+ }
188
+
189
+
190
+ // Hostbased ===================================================================
191
+ {
192
+ const localUsername = 'Local User Foo';
193
+ const localHostname = 'Local Host Bar';
194
+ const username = 'Hostbased User';
195
+ const clientKey = fixtureKey('id_rsa');
196
+ const { server } = setup(
197
+ 'Hostbased',
198
+ {
199
+ client: {
200
+ username,
201
+ privateKey: clientKey.raw,
202
+ localUsername,
203
+ localHostname,
204
+ },
205
+ server: serverCfg,
206
+
207
+ debug,
208
+ }
209
+ );
210
+
211
+ server.on('connection', mustCall((conn) => {
212
+ let authAttempt = 0;
213
+ conn.on('authentication', mustCall((ctx) => {
214
+ assert(ctx.username === username,
215
+ `Wrong username: ${ctx.username}`);
216
+ switch (++authAttempt) {
217
+ case 1:
218
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
219
+ return ctx.reject();
220
+ case 2:
221
+ assert(ctx.method === 'publickey',
222
+ `Wrong auth method: ${ctx.method}`);
223
+ return ctx.reject();
224
+ case 3: {
225
+ assert(ctx.method === 'hostbased',
226
+ `Wrong auth method: ${ctx.method}`);
227
+ assert(ctx.key.algo === clientKey.key.type,
228
+ `Wrong key algo: ${ctx.key.algo}`);
229
+ assert.deepStrictEqual(clientKey.key.getPublicSSH(),
230
+ ctx.key.data,
231
+ 'Public key mismatch');
232
+ assert(ctx.signature, 'Expected signature');
233
+ assert(ctx.localHostname === localHostname, 'Wrong local hostname');
234
+ assert(ctx.localUsername === localUsername, 'Wrong local username');
235
+ const result =
236
+ clientKey.key.verify(ctx.blob, ctx.signature, ctx.hashAlgo);
237
+ assert(result === true, 'Could not verify hostbased signature');
238
+
239
+ break;
240
+ }
241
+ }
242
+ ctx.accept();
243
+ }, 3)).on('ready', mustCall(() => {
244
+ conn.end();
245
+ }));
246
+ }));
247
+ }
248
+
249
+
250
+ // keyboard-interactive ========================================================
251
+ {
252
+ const username = 'Keyboard-Interactive User';
253
+ const request = {
254
+ name: 'SSH2 Authentication',
255
+ instructions: 'These are instructions',
256
+ prompts: [
257
+ { prompt: 'Password: ', echo: false },
258
+ { prompt: 'Is the cake a lie? ', echo: true },
259
+ ],
260
+ };
261
+ const responses = [
262
+ 'foobarbaz',
263
+ 'yes',
264
+ ];
265
+ const { client, server } = setup(
266
+ 'Password (empty username)',
267
+ {
268
+ client: {
269
+ username,
270
+ tryKeyboard: true,
271
+ },
272
+ server: serverCfg,
273
+
274
+ debug,
275
+ }
276
+ );
277
+
278
+ server.on('connection', mustCall((conn) => {
279
+ let authAttempt = 0;
280
+ conn.on('authentication', mustCall((ctx) => {
281
+ assert(ctx.username === username,
282
+ `Wrong username: ${ctx.username}`);
283
+ if (++authAttempt === 1) {
284
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
285
+ return ctx.reject();
286
+ }
287
+ assert(ctx.method === 'keyboard-interactive',
288
+ `Wrong auth method: ${ctx.method}`);
289
+ ctx.prompt(request.prompts,
290
+ request.name,
291
+ request.instructions,
292
+ mustCall((responses_) => {
293
+ assert.deepStrictEqual(responses_, responses);
294
+ ctx.accept();
295
+ }));
296
+ }, 2)).on('ready', mustCall(() => {
297
+ conn.end();
298
+ }));
299
+ }));
300
+
301
+ client.on('keyboard-interactive',
302
+ mustCall((name, instructions, lang, prompts, finish) => {
303
+ assert(name === request.name, `Wrong prompt name: ${name}`);
304
+ assert(instructions === request.instructions,
305
+ `Wrong prompt instructions: ${instructions}`);
306
+ assert.deepStrictEqual(
307
+ prompts,
308
+ request.prompts,
309
+ `Wrong prompts: ${inspect(prompts)}`
310
+ );
311
+ process.nextTick(finish, responses);
312
+ }));
313
+ }
314
+
315
+ // authHandler() tests =========================================================
316
+ {
317
+ const username = 'foo';
318
+ const password = '1234';
319
+ const clientKey = fixtureKey('id_rsa');
320
+ const { server } = setup(
321
+ 'authHandler() (sync)',
322
+ {
323
+ client: {
324
+ username,
325
+ password,
326
+ privateKey: clientKey.raw,
327
+
328
+ authHandler: mustCall((methodsLeft, partial, cb) => {
329
+ assert(methodsLeft === null, 'expected null methodsLeft');
330
+ assert(partial === null, 'expected null partial');
331
+ return 'none';
332
+ }),
333
+ },
334
+ server: serverCfg,
335
+
336
+ debug,
337
+ }
338
+ );
339
+
340
+ server.on('connection', mustCall((conn) => {
341
+ conn.on('authentication', mustCall((ctx) => {
342
+ assert(ctx.username === username, `Wrong username: ${ctx.username}`);
343
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
344
+ ctx.accept();
345
+ })).on('ready', mustCall(() => {
346
+ conn.end();
347
+ }));
348
+ }));
349
+ }
350
+ {
351
+ const username = 'foo';
352
+ const password = '1234';
353
+ const clientKey = fixtureKey('id_rsa');
354
+ const { server } = setup(
355
+ 'authHandler() (async)',
356
+ {
357
+ client: {
358
+ username,
359
+ password,
360
+ privateKey: clientKey.raw,
361
+
362
+ authHandler: mustCall((methodsLeft, partial, cb) => {
363
+ assert(methodsLeft === null, 'expected null methodsLeft');
364
+ assert(partial === null, 'expected null partial');
365
+ process.nextTick(mustCall(cb), 'none');
366
+ }),
367
+ },
368
+ server: serverCfg,
369
+
370
+ debug,
371
+ }
372
+ );
373
+
374
+ server.on('connection', mustCall((conn) => {
375
+ conn.on('authentication', mustCall((ctx) => {
376
+ assert(ctx.username === username, `Wrong username: ${ctx.username}`);
377
+ assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
378
+ ctx.accept();
379
+ })).on('ready', mustCall(() => {
380
+ conn.end();
381
+ }));
382
+ }));
383
+ }
384
+ {
385
+ const username = 'foo';
386
+ const password = '1234';
387
+ const clientKey = fixtureKey('id_rsa');
388
+ const { client, server } = setup(
389
+ 'authHandler() (no methods left -- sync)',
390
+ {
391
+ client: {
392
+ username,
393
+ password,
394
+ privateKey: clientKey.raw,
395
+
396
+ authHandler: mustCall((methodsLeft, partial, cb) => {
397
+ assert(methodsLeft === null, 'expected null methodsLeft');
398
+ assert(partial === null, 'expected null partial');
399
+ return false;
400
+ }),
401
+ },
402
+ server: serverCfg,
403
+
404
+ debug,
405
+ noForceClientReady: true,
406
+ noForceServerReady: true,
407
+ }
408
+ );
409
+
410
+ // Remove default client error handler added by `setup()` since we are
411
+ // expecting an error in this case
412
+ client.removeAllListeners('error');
413
+
414
+ client.on('error', mustCall((err) => {
415
+ assert.strictEqual(err.level, 'client-authentication');
416
+ assert(/configured authentication methods failed/i.test(err.message),
417
+ 'Wrong error message');
418
+ }));
419
+
420
+ server.on('connection', mustCall((conn) => {
421
+ conn.on('authentication', mustNotCall())
422
+ .on('ready', mustNotCall());
423
+ }));
424
+ }
425
+ {
426
+ const username = 'foo';
427
+ const password = '1234';
428
+ const clientKey = fixtureKey('id_rsa');
429
+ const { client, server } = setup(
430
+ 'authHandler() (no methods left -- async)',
431
+ {
432
+ client: {
433
+ username,
434
+ password,
435
+ privateKey: clientKey.raw,
436
+
437
+ authHandler: mustCall((methodsLeft, partial, cb) => {
438
+ assert(methodsLeft === null, 'expected null methodsLeft');
439
+ assert(partial === null, 'expected null partial');
440
+ process.nextTick(mustCall(cb), false);
441
+ }),
442
+ },
443
+ server: serverCfg,
444
+
445
+ debug,
446
+ noForceClientReady: true,
447
+ noForceServerReady: true,
448
+ }
449
+ );
450
+
451
+ // Remove default client error handler added by `setup()` since we are
452
+ // expecting an error in this case
453
+ client.removeAllListeners('error');
454
+
455
+ client.on('error', mustCall((err) => {
456
+ assert.strictEqual(err.level, 'client-authentication');
457
+ assert(/configured authentication methods failed/i.test(err.message),
458
+ 'Wrong error message');
459
+ }));
460
+
461
+ server.on('connection', mustCall((conn) => {
462
+ conn.on('authentication', mustNotCall())
463
+ .on('ready', mustNotCall());
464
+ }));
465
+ }
466
+ {
467
+ const username = 'foo';
468
+ const password = '1234';
469
+ const clientKey = fixtureKey('id_rsa');
470
+ const events = [];
471
+ const expectedEvents = [
472
+ 'client', 'server', 'client', 'server'
473
+ ];
474
+ let clientCalls = 0;
475
+ const { client, server } = setup(
476
+ 'authHandler() (multi-step)',
477
+ {
478
+ client: {
479
+ username,
480
+ password,
481
+ privateKey: clientKey.raw,
482
+
483
+ authHandler: mustCall((methodsLeft, partial, cb) => {
484
+ events.push('client');
485
+ switch (++clientCalls) {
486
+ case 1:
487
+ assert(methodsLeft === null, 'expected null methodsLeft');
488
+ assert(partial === null, 'expected null partial');
489
+ return 'publickey';
490
+ case 2:
491
+ assert.deepStrictEqual(
492
+ methodsLeft,
493
+ ['password'],
494
+ `expected 'password' method left, saw: ${methodsLeft}`
495
+ );
496
+ assert(partial === true, 'expected partial success');
497
+ return 'password';
498
+ }
499
+ }, 2),
500
+ },
501
+ server: serverCfg,
502
+
503
+ debug,
504
+ }
505
+ );
506
+
507
+ server.on('connection', mustCall((conn) => {
508
+ let attempts = 0;
509
+ conn.on('authentication', mustCall((ctx) => {
510
+ assert(++attempts === clientCalls, 'server<->client state mismatch');
511
+ assert(ctx.username === username,
512
+ `Unexpected username: ${ctx.username}`);
513
+ events.push('server');
514
+ switch (attempts) {
515
+ case 1:
516
+ assert(ctx.method === 'publickey',
517
+ `Wrong auth method: ${ctx.method}`);
518
+ assert(ctx.key.algo === clientKey.key.type,
519
+ `Unexpected key algo: ${ctx.key.algo}`);
520
+ assert.deepEqual(clientKey.key.getPublicSSH(),
521
+ ctx.key.data,
522
+ 'Public key mismatch');
523
+ ctx.reject(['password'], true);
524
+ break;
525
+ case 2:
526
+ assert(ctx.method === 'password',
527
+ `Wrong auth method: ${ctx.method}`);
528
+ assert(ctx.password === password,
529
+ `Unexpected password: ${ctx.password}`);
530
+ ctx.accept();
531
+ break;
532
+ }
533
+ }, 2)).on('ready', mustCall(() => {
534
+ conn.end();
535
+ }));
536
+ }));
537
+
538
+ client.on('close', mustCall(() => {
539
+ assert.deepStrictEqual(events, expectedEvents);
540
+ }));
541
+ }
542
+ {
543
+ const username = 'foo';
544
+ const password = '1234';
545
+ const { server } = setup(
546
+ 'authHandler() (custom auth configuration)',
547
+ {
548
+ client: {
549
+ username: 'bar',
550
+ password: '5678',
551
+
552
+ authHandler: mustCall((methodsLeft, partial, cb) => {
553
+ assert(methodsLeft === null, 'expected null methodsLeft');
554
+ assert(partial === null, 'expected null partial');
555
+ return {
556
+ type: 'password',
557
+ username,
558
+ password,
559
+ };
560
+ }),
561
+ },
562
+ server: serverCfg,
563
+
564
+ debug,
565
+ }
566
+ );
567
+
568
+ server.on('connection', mustCall((conn) => {
569
+ conn.on('authentication', mustCall((ctx) => {
570
+ assert(ctx.username === username, `Wrong username: ${ctx.username}`);
571
+ assert(ctx.method === 'password', `Wrong auth method: ${ctx.method}`);
572
+ assert(ctx.password === password, `Unexpected password: ${ctx.password}`);
573
+ ctx.accept();
574
+ })).on('ready', mustCall(() => {
575
+ conn.end();
576
+ }));
577
+ }));
578
+ }
579
+ {
580
+ const username = 'foo';
581
+ const password = '1234';
582
+ const { server } = setup(
583
+ 'authHandler() (simple construction with custom auth configuration)',
584
+ {
585
+ client: {
586
+ username: 'bar',
587
+ password: '5678',
588
+
589
+ authHandler: [{
590
+ type: 'password',
591
+ username,
592
+ password,
593
+ }],
594
+ },
595
+ server: serverCfg,
596
+
597
+ debug,
598
+ }
599
+ );
600
+
601
+ server.on('connection', mustCall((conn) => {
602
+ conn.on('authentication', mustCall((ctx) => {
603
+ assert(ctx.username === username, `Wrong username: ${ctx.username}`);
604
+ assert(ctx.method === 'password', `Wrong auth method: ${ctx.method}`);
605
+ assert(ctx.password === password, `Unexpected password: ${ctx.password}`);
606
+ ctx.accept();
607
+ })).on('ready', mustCall(() => {
608
+ conn.end();
609
+ }));
610
+ }));
611
+ }
@@ -0,0 +1,25 @@
1
+ // Test for thread-safety issues caused by subsequent imports of the module
2
+ // in worker threads: https://github.com/mscdex/ssh2/issues/1393.
3
+ // Each subsequent worker increases probability of abnormal termination.
4
+ // The probability of a false pass due to zero response becomes negligible
5
+ // for 4 consecutive workers.
6
+ 'use strict';
7
+
8
+ let Worker, isMainThread;
9
+ try {
10
+ ({ Worker, isMainThread } = require('worker_threads'));
11
+ } catch (e) {
12
+ if (e.code !== 'MODULE_NOT_FOUND') throw e;
13
+ process.exit(0);
14
+ }
15
+ require('../lib/index.js');
16
+
17
+ if (isMainThread) {
18
+ async function runWorker() {
19
+ return new Promise((r) => new Worker(__filename).on('exit', r));
20
+ }
21
+ runWorker()
22
+ .then(runWorker)
23
+ .then(runWorker)
24
+ .then(runWorker);
25
+ }
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ const { spawnSync } = require('child_process');
4
+ const { readdirSync } = require('fs');
5
+ const { join } = require('path');
6
+
7
+ const files = readdirSync(__dirname).sort();
8
+ for (const filename of files) {
9
+ if (filename.startsWith('test-')) {
10
+ const path = join(__dirname, filename);
11
+ console.log(`> Running ${filename} ...`);
12
+ const result = spawnSync(`${process.argv0} ${path}`, {
13
+ shell: true,
14
+ stdio: 'inherit',
15
+ windowsHide: true
16
+ });
17
+ if (result.status !== 0)
18
+ process.exitCode = 1;
19
+ }
20
+ }
@@ -0,0 +1,2 @@
1
+ @cl /Ox pagent.c User32.lib
2
+ @del /Q *.obj