dsh-ssh-workbench 0.0.0-stage → 1.7.0

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 (98) hide show
  1. package/CHANGELOG.md +552 -0
  2. package/CONTRIBUTING.md +63 -0
  3. package/LICENSE +21 -0
  4. package/README.md +178 -2
  5. package/SECURITY.md +27 -0
  6. package/cordis.patch.yml +5 -0
  7. package/docs/architecture.md +146 -0
  8. package/docs/execution-model.md +83 -0
  9. package/docs/images/chat-at-resource.png +0 -0
  10. package/docs/images/plugin.png +0 -0
  11. package/docs/images/remote-workbench.png +0 -0
  12. package/docs/images/workbench.png +0 -0
  13. package/docs/quickstart.md +106 -0
  14. package/lib/client.js +4991 -0
  15. package/lib/core/activity.js +88 -0
  16. package/lib/core/background.js +69 -0
  17. package/lib/core/broker.js +802 -0
  18. package/lib/core/dialect.js +28 -0
  19. package/lib/core/errors.js +138 -0
  20. package/lib/core/execution-stats.js +88 -0
  21. package/lib/core/gate-pwsh.js +88 -0
  22. package/lib/core/gate.js +572 -0
  23. package/lib/core/guard.js +123 -0
  24. package/lib/core/known-hosts.js +74 -0
  25. package/lib/core/live-executions.js +101 -0
  26. package/lib/core/local-file-api.js +174 -0
  27. package/lib/core/localfs.js +381 -0
  28. package/lib/core/managed-context.js +276 -0
  29. package/lib/core/mentions.js +216 -0
  30. package/lib/core/paths.js +104 -0
  31. package/lib/core/posix-quote.js +4 -0
  32. package/lib/core/posix-shell.js +89 -0
  33. package/lib/core/prefs.js +38 -0
  34. package/lib/core/remote-exec-tool.js +394 -0
  35. package/lib/core/remote-file-tools.js +559 -0
  36. package/lib/core/remote-shell-tool.js +310 -0
  37. package/lib/core/secrets.js +95 -0
  38. package/lib/core/server-ref.js +61 -0
  39. package/lib/core/shell-adapters.js +48 -0
  40. package/lib/core/ssh.js +761 -0
  41. package/lib/core/store.js +83 -0
  42. package/lib/core/terminals.js +299 -0
  43. package/lib/core/win32-adapter.js +141 -0
  44. package/lib/index.js +409 -0
  45. package/lib/routes.js +759 -0
  46. package/locale/en.json +6 -0
  47. package/locale/zh.json +6 -0
  48. package/package.json +89 -4
  49. package/vendor/NOTICE.md +50 -0
  50. package/vendor/XTERM-LICENSE +21 -0
  51. package/vendor/node_modules/asn1/LICENSE +19 -0
  52. package/vendor/node_modules/asn1/README.md +50 -0
  53. package/vendor/node_modules/asn1/lib/ber/errors.js +13 -0
  54. package/vendor/node_modules/asn1/lib/ber/index.js +27 -0
  55. package/vendor/node_modules/asn1/lib/ber/reader.js +262 -0
  56. package/vendor/node_modules/asn1/lib/ber/types.js +36 -0
  57. package/vendor/node_modules/asn1/lib/ber/writer.js +317 -0
  58. package/vendor/node_modules/asn1/lib/index.js +20 -0
  59. package/vendor/node_modules/asn1/package.json +31 -0
  60. package/vendor/node_modules/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
  61. package/vendor/node_modules/bcrypt-pbkdf/LICENSE +66 -0
  62. package/vendor/node_modules/bcrypt-pbkdf/README.md +45 -0
  63. package/vendor/node_modules/bcrypt-pbkdf/index.js +556 -0
  64. package/vendor/node_modules/bcrypt-pbkdf/package.json +15 -0
  65. package/vendor/node_modules/safer-buffer/LICENSE +21 -0
  66. package/vendor/node_modules/safer-buffer/Readme.md +156 -0
  67. package/vendor/node_modules/safer-buffer/dangerous.js +58 -0
  68. package/vendor/node_modules/safer-buffer/package.json +34 -0
  69. package/vendor/node_modules/safer-buffer/safer.js +77 -0
  70. package/vendor/node_modules/tweetnacl/AUTHORS.md +28 -0
  71. package/vendor/node_modules/tweetnacl/LICENSE +24 -0
  72. package/vendor/node_modules/tweetnacl/README.md +459 -0
  73. package/vendor/node_modules/tweetnacl/nacl-fast.js +2388 -0
  74. package/vendor/node_modules/tweetnacl/nacl.js +1175 -0
  75. package/vendor/node_modules/tweetnacl/package.json +58 -0
  76. package/vendor/ssh2/LICENSE +19 -0
  77. package/vendor/ssh2/lib/Channel.js +295 -0
  78. package/vendor/ssh2/lib/agent.js +1123 -0
  79. package/vendor/ssh2/lib/client.js +2176 -0
  80. package/vendor/ssh2/lib/http-agents.js +84 -0
  81. package/vendor/ssh2/lib/index.js +44 -0
  82. package/vendor/ssh2/lib/keygen.js +582 -0
  83. package/vendor/ssh2/lib/protocol/Protocol.js +2136 -0
  84. package/vendor/ssh2/lib/protocol/SFTP.js +4052 -0
  85. package/vendor/ssh2/lib/protocol/constants.js +356 -0
  86. package/vendor/ssh2/lib/protocol/crypto/poly1305.js +43 -0
  87. package/vendor/ssh2/lib/protocol/crypto.js +1602 -0
  88. package/vendor/ssh2/lib/protocol/handlers.js +16 -0
  89. package/vendor/ssh2/lib/protocol/handlers.misc.js +1285 -0
  90. package/vendor/ssh2/lib/protocol/kex.js +1908 -0
  91. package/vendor/ssh2/lib/protocol/keyParser.js +1484 -0
  92. package/vendor/ssh2/lib/protocol/node-fs-compat.js +115 -0
  93. package/vendor/ssh2/lib/protocol/utils.js +356 -0
  94. package/vendor/ssh2/lib/protocol/zlib.js +255 -0
  95. package/vendor/ssh2/lib/server.js +1380 -0
  96. package/vendor/ssh2/lib/utils.js +336 -0
  97. package/vendor/ssh2/package.json +34 -0
  98. package/vendor/xterm.js +53 -0
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "tweetnacl",
3
+ "version": "0.14.5",
4
+ "description": "Port of TweetNaCl cryptographic library to JavaScript",
5
+ "main": "nacl-fast.js",
6
+ "types": "nacl.d.ts",
7
+ "directories": {
8
+ "test": "test"
9
+ },
10
+ "scripts": {
11
+ "build": "uglifyjs nacl.js -c -m -o nacl.min.js && uglifyjs nacl-fast.js -c -m -o nacl-fast.min.js",
12
+ "test-node": "tape test/*.js | faucet",
13
+ "test-node-all": "make -C test/c && tape test/*.js test/c/*.js | faucet",
14
+ "test-browser": "NACL_SRC=${NACL_SRC:='nacl.min.js'} && npm run build-test-browser && cat $NACL_SRC test/browser/_bundle.js | tape-run | faucet",
15
+ "build-test-browser": "browserify test/browser/init.js test/*.js | uglifyjs -c -m -o test/browser/_bundle.js 2>/dev/null && browserify test/browser/init.js test/*.quick.js | uglifyjs -c -m -o test/browser/_bundle-quick.js 2>/dev/null",
16
+ "test": "npm run test-node-all && npm run test-browser",
17
+ "bench": "node test/benchmark/bench.js",
18
+ "lint": "eslint nacl.js nacl-fast.js test/*.js test/benchmark/*.js"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/dchest/tweetnacl-js.git"
23
+ },
24
+ "keywords": [
25
+ "crypto",
26
+ "cryptography",
27
+ "curve25519",
28
+ "ed25519",
29
+ "encrypt",
30
+ "hash",
31
+ "key",
32
+ "nacl",
33
+ "poly1305",
34
+ "public",
35
+ "salsa20",
36
+ "signatures"
37
+ ],
38
+ "author": "TweetNaCl-js contributors",
39
+ "license": "Unlicense",
40
+ "bugs": {
41
+ "url": "https://github.com/dchest/tweetnacl-js/issues"
42
+ },
43
+ "homepage": "https://tweetnacl.js.org",
44
+ "devDependencies": {
45
+ "browserify": "^13.0.0",
46
+ "eslint": "^2.2.0",
47
+ "faucet": "^0.0.1",
48
+ "tap-browser-color": "^0.1.2",
49
+ "tape": "^4.4.0",
50
+ "tape-run": "^2.1.3",
51
+ "tweetnacl-util": "^0.13.3",
52
+ "uglify-js": "^2.6.1"
53
+ },
54
+ "browser": {
55
+ "buffer": false,
56
+ "crypto": false
57
+ }
58
+ }
@@ -0,0 +1,19 @@
1
+ Copyright Brian White. All rights reserved.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ IN THE SOFTWARE.
@@ -0,0 +1,295 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ Duplex: DuplexStream,
5
+ Readable: ReadableStream,
6
+ Writable: WritableStream,
7
+ } = require('stream');
8
+
9
+ const {
10
+ CHANNEL_EXTENDED_DATATYPE: { STDERR },
11
+ } = require('./protocol/constants.js');
12
+ const { bufferSlice } = require('./protocol/utils.js');
13
+
14
+ const PACKET_SIZE = 32 * 1024;
15
+ const MAX_WINDOW = 2 * 1024 * 1024;
16
+ const WINDOW_THRESHOLD = MAX_WINDOW / 2;
17
+
18
+ class ClientStderr extends ReadableStream {
19
+ constructor(channel, streamOpts) {
20
+ super(streamOpts);
21
+
22
+ this._channel = channel;
23
+ }
24
+ _read(n) {
25
+ if (this._channel._waitChanDrain) {
26
+ this._channel._waitChanDrain = false;
27
+ if (this._channel.incoming.window <= WINDOW_THRESHOLD)
28
+ windowAdjust(this._channel);
29
+ }
30
+ }
31
+ }
32
+
33
+ class ServerStderr extends WritableStream {
34
+ constructor(channel) {
35
+ super({ highWaterMark: MAX_WINDOW });
36
+
37
+ this._channel = channel;
38
+ }
39
+
40
+ _write(data, encoding, cb) {
41
+ const channel = this._channel;
42
+ const protocol = channel._client._protocol;
43
+ const outgoing = channel.outgoing;
44
+ const packetSize = outgoing.packetSize;
45
+ const id = outgoing.id;
46
+ let window = outgoing.window;
47
+ const len = data.length;
48
+ let p = 0;
49
+
50
+ if (outgoing.state !== 'open')
51
+ return;
52
+
53
+ while (len - p > 0 && window > 0) {
54
+ let sliceLen = len - p;
55
+ if (sliceLen > window)
56
+ sliceLen = window;
57
+ if (sliceLen > packetSize)
58
+ sliceLen = packetSize;
59
+
60
+ if (p === 0 && sliceLen === len)
61
+ protocol.channelExtData(id, data, STDERR);
62
+ else
63
+ protocol.channelExtData(id, bufferSlice(data, p, p + sliceLen), STDERR);
64
+
65
+ p += sliceLen;
66
+ window -= sliceLen;
67
+ }
68
+
69
+ outgoing.window = window;
70
+
71
+ if (len - p > 0) {
72
+ if (window === 0)
73
+ channel._waitWindow = true;
74
+ if (p > 0)
75
+ channel._chunkErr = bufferSlice(data, p, len);
76
+ else
77
+ channel._chunkErr = data;
78
+ channel._chunkcbErr = cb;
79
+ return;
80
+ }
81
+
82
+ cb();
83
+ }
84
+ }
85
+
86
+ class Channel extends DuplexStream {
87
+ constructor(client, info, opts) {
88
+ const streamOpts = {
89
+ highWaterMark: MAX_WINDOW,
90
+ allowHalfOpen: (!opts || (opts && opts.allowHalfOpen !== false)),
91
+ emitClose: false,
92
+ };
93
+ super(streamOpts);
94
+ this.allowHalfOpen = streamOpts.allowHalfOpen;
95
+
96
+ const server = !!(opts && opts.server);
97
+
98
+ this.server = server;
99
+ this.type = info.type;
100
+ this.subtype = undefined;
101
+
102
+ /*
103
+ incoming and outgoing contain these properties:
104
+ {
105
+ id: undefined,
106
+ window: undefined,
107
+ packetSize: undefined,
108
+ state: 'closed'
109
+ }
110
+ */
111
+ this.incoming = info.incoming;
112
+ this.outgoing = info.outgoing;
113
+ this._callbacks = [];
114
+
115
+ this._client = client;
116
+ this._hasX11 = false;
117
+ this._exit = {
118
+ code: undefined,
119
+ signal: undefined,
120
+ dump: undefined,
121
+ desc: undefined,
122
+ };
123
+
124
+ this.stdin = this.stdout = this;
125
+
126
+ if (server)
127
+ this.stderr = new ServerStderr(this);
128
+ else
129
+ this.stderr = new ClientStderr(this, streamOpts);
130
+
131
+ // Outgoing data
132
+ this._waitWindow = false; // SSH-level backpressure
133
+
134
+ // Incoming data
135
+ this._waitChanDrain = false; // Channel Readable side backpressure
136
+
137
+ this._chunk = undefined;
138
+ this._chunkcb = undefined;
139
+ this._chunkErr = undefined;
140
+ this._chunkcbErr = undefined;
141
+
142
+ this.on('finish', onFinish)
143
+ .on('prefinish', onFinish); // For node v0.11+
144
+
145
+ this.on('end', onEnd).on('close', onEnd);
146
+ }
147
+
148
+ _read(n) {
149
+ if (this._waitChanDrain) {
150
+ this._waitChanDrain = false;
151
+ if (this.incoming.window <= WINDOW_THRESHOLD)
152
+ windowAdjust(this);
153
+ }
154
+ }
155
+
156
+ _write(data, encoding, cb) {
157
+ const protocol = this._client._protocol;
158
+ const outgoing = this.outgoing;
159
+ const packetSize = outgoing.packetSize;
160
+ const id = outgoing.id;
161
+ let window = outgoing.window;
162
+ const len = data.length;
163
+ let p = 0;
164
+
165
+ if (outgoing.state !== 'open')
166
+ return;
167
+
168
+ while (len - p > 0 && window > 0) {
169
+ let sliceLen = len - p;
170
+ if (sliceLen > window)
171
+ sliceLen = window;
172
+ if (sliceLen > packetSize)
173
+ sliceLen = packetSize;
174
+
175
+ if (p === 0 && sliceLen === len)
176
+ protocol.channelData(id, data);
177
+ else
178
+ protocol.channelData(id, bufferSlice(data, p, p + sliceLen));
179
+
180
+ p += sliceLen;
181
+ window -= sliceLen;
182
+ }
183
+
184
+ outgoing.window = window;
185
+
186
+ if (len - p > 0) {
187
+ if (window === 0)
188
+ this._waitWindow = true;
189
+ if (p > 0)
190
+ this._chunk = bufferSlice(data, p, len);
191
+ else
192
+ this._chunk = data;
193
+ this._chunkcb = cb;
194
+ return;
195
+ }
196
+
197
+ cb();
198
+ }
199
+
200
+ eof() {
201
+ if (this.outgoing.state === 'open') {
202
+ this.outgoing.state = 'eof';
203
+ this._client._protocol.channelEOF(this.outgoing.id);
204
+ }
205
+ }
206
+
207
+ close() {
208
+ if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {
209
+ this.outgoing.state = 'closing';
210
+ this._client._protocol.channelClose(this.outgoing.id);
211
+ }
212
+ }
213
+
214
+ destroy() {
215
+ this.end();
216
+ this.close();
217
+ return this;
218
+ }
219
+
220
+ // Session type-specific methods =============================================
221
+ setWindow(rows, cols, height, width) {
222
+ if (this.server)
223
+ throw new Error('Client-only method called in server mode');
224
+
225
+ if (this.type === 'session'
226
+ && (this.subtype === 'shell' || this.subtype === 'exec')
227
+ && this.writable
228
+ && this.outgoing.state === 'open') {
229
+ this._client._protocol.windowChange(this.outgoing.id,
230
+ rows,
231
+ cols,
232
+ height,
233
+ width);
234
+ }
235
+ }
236
+
237
+ signal(signalName) {
238
+ if (this.server)
239
+ throw new Error('Client-only method called in server mode');
240
+
241
+ if (this.type === 'session'
242
+ && this.writable
243
+ && this.outgoing.state === 'open') {
244
+ this._client._protocol.signal(this.outgoing.id, signalName);
245
+ }
246
+ }
247
+
248
+ exit(statusOrSignal, coreDumped, msg) {
249
+ if (!this.server)
250
+ throw new Error('Server-only method called in client mode');
251
+
252
+ if (this.type === 'session'
253
+ && this.writable
254
+ && this.outgoing.state === 'open') {
255
+ if (typeof statusOrSignal === 'number') {
256
+ this._client._protocol.exitStatus(this.outgoing.id, statusOrSignal);
257
+ } else {
258
+ this._client._protocol.exitSignal(this.outgoing.id,
259
+ statusOrSignal,
260
+ coreDumped,
261
+ msg);
262
+ }
263
+ }
264
+ }
265
+
266
+ }
267
+
268
+ function onFinish() {
269
+ this.eof();
270
+ if (this.server || !this.allowHalfOpen)
271
+ this.close();
272
+ this.writable = false;
273
+ }
274
+
275
+ function onEnd() {
276
+ this.readable = false;
277
+ }
278
+
279
+ function windowAdjust(self) {
280
+ if (self.outgoing.state === 'closed')
281
+ return;
282
+ const amt = MAX_WINDOW - self.incoming.window;
283
+ if (amt <= 0)
284
+ return;
285
+ self.incoming.window += amt;
286
+ self._client._protocol.channelWindowAdjust(self.outgoing.id, amt);
287
+ }
288
+
289
+ module.exports = {
290
+ Channel,
291
+ MAX_WINDOW,
292
+ PACKET_SIZE,
293
+ windowAdjust,
294
+ WINDOW_THRESHOLD,
295
+ };