@johnhenry/wsh 0.44.0 → 0.44.1
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/README.md +18 -4
- package/package.json +3 -1
- package/src/reverse-host.mjs +19 -3
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ Or via CDN:
|
|
|
66
66
|
- **MCP bridge** -- discover and invoke remote MCP tools through the control channel
|
|
67
67
|
- **Session recording** -- own JSON schema (asciicast-v2-shaped, not a playable asciicast file -- see note below) recording and playback with seek/pause/resume
|
|
68
68
|
- **Key management** -- IndexedDB storage with OPFS encrypted backup (PBKDF2 + AES-256-GCM)
|
|
69
|
-
- **110 message types** -- handshake, channel, gateway, guest sharing, compression negotiation, copilot, policy, authorized-key management, and more
|
|
69
|
+
- **110 message types** -- handshake, channel, gateway, guest sharing, compression negotiation, copilot, policy, authorized-key management, and more. [`spec/message-matrix.md`](spec/message-matrix.md) says, for each, whether the JS host, JS client, Rust host and Rust client implement it (generated from the spec and the source; CI fails when it is stale), and [COMPATIBILITY.md](COMPATIBILITY.md) is the policy for changing the protocol without breaking a released peer
|
|
70
70
|
|
|
71
71
|
> **Session recording is asciicast-v2-shaped, but not an asciicast file.**
|
|
72
72
|
> The JS `SessionRecorder.toJSON()` export borrows asciicast v2's vocabulary --
|
|
@@ -608,9 +608,23 @@ await bindSocket(upgradedSocket, Promise.resolve(attach), { dataStreams: false }
|
|
|
608
608
|
```
|
|
609
609
|
|
|
610
610
|
`npm run size` prints raw and gzip bytes per entry point (and a few single-import probes, which show tree-shaking at
|
|
611
|
-
work) against `scripts/bundle-budget.json`; CI runs it and
|
|
612
|
-
`npm run size -- --update` rewrites the budget
|
|
613
|
-
|
|
611
|
+
work) against `scripts/bundle-budget.json`; CI runs it (and writes the table to the job summary) and `npm test` fails a
|
|
612
|
+
bundle more than 10% over its budget. `npm run size -- --update` rewrites the budget and the table below after a deliberate
|
|
613
|
+
change; CI fails when the table is not the budget's. Sizes are of this package's own code: `@noble/post-quantum`, the
|
|
614
|
+
optional ML-KEM backend, is left out of the measurement. What a page ships is what its bundler keeps of these
|
|
615
|
+
(`"sideEffects": false`; the single-import rows show how little a `generateKeyPair` or `createConnectionFactory` import pulls in).
|
|
616
|
+
|
|
617
|
+
<!-- bundle-size:start (generated by `npm run size -- --update`; do not edit) -->
|
|
618
|
+
| browser bundle | minified | gzip |
|
|
619
|
+
| --- | ---: | ---: |
|
|
620
|
+
| `@johnhenry/wsh` (whole entry point) | 159.1 kB | 47.8 kB |
|
|
621
|
+
| `@johnhenry/wsh/memory` (whole entry point) | 223.8 kB | 69.7 kB |
|
|
622
|
+
| `@johnhenry/wsh/host` (whole entry point) | 121.2 kB | 39.9 kB |
|
|
623
|
+
| `@johnhenry/wsh/reverse` (whole entry point) | 211.2 kB | 65.1 kB |
|
|
624
|
+
| `import { generateKeyPair } from '@johnhenry/wsh'` | 0.4 kB | 0.3 kB |
|
|
625
|
+
| `import { WshClient } from '@johnhenry/wsh'` | 131.2 kB | 39.1 kB |
|
|
626
|
+
| `import { createConnectionFactory } from '@johnhenry/wsh/host'` | 98.0 kB | 32.0 kB |
|
|
627
|
+
<!-- bundle-size:end -->
|
|
614
628
|
|
|
615
629
|
### Signing with a page-held signer
|
|
616
630
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnhenry/wsh",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"description": "Web Shell \u2014 browser-native remote command execution over WebTransport and WebSocket with Ed25519 authentication",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -86,6 +86,8 @@
|
|
|
86
86
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
87
87
|
"codegen": "node spec/codegen.mjs",
|
|
88
88
|
"codegen:check": "node scripts/codegen-check.mjs",
|
|
89
|
+
"matrix": "node scripts/message-matrix.mjs",
|
|
90
|
+
"matrix:check": "node scripts/message-matrix.mjs --check",
|
|
89
91
|
"examples": "for f in examples/0*.mjs; do echo \"== $f\" && node \"$f\" || exit 1; done",
|
|
90
92
|
"example:01": "node examples/01-frames-survive-fragmented-transport.mjs",
|
|
91
93
|
"example:02": "node examples/02-tampered-challenge-fails-authentication.mjs",
|
package/src/reverse-host.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { MSG, reverseAccept, reverseReject, reverseChallenge } from './messages.
|
|
|
20
20
|
import { MULTI_OPERATOR_FEATURE } from './server/relay.mjs';
|
|
21
21
|
import { E2E_SIGN_FEATURE, E2EResponder } from './e2e-exchange.mjs';
|
|
22
22
|
import { OPERATOR_PROOF_FEATURE, E2E_SEALED_FEATURE, createReverseChallenge, verifyOperatorProof } from './operator-proof.mjs';
|
|
23
|
-
import { SealedBridge } from './bridge-seal.mjs';
|
|
23
|
+
import { SealedBridge, BRIDGE_CHANNEL_ID } from './bridge-seal.mjs';
|
|
24
24
|
import { resolveBackends } from './host-backends.mjs';
|
|
25
25
|
import { createConnectionFactory, hostFeatures } from './server/connection.mjs';
|
|
26
26
|
import { validateOnShare } from './shares.mjs';
|
|
@@ -266,7 +266,16 @@ export function createReverseHostWith({
|
|
|
266
266
|
let giveUp = null;
|
|
267
267
|
const who = { fingerprint: from, username: operatorName };
|
|
268
268
|
let unsealedReported = false;
|
|
269
|
-
|
|
269
|
+
// #162: the operator sends its first frame the moment ITS half of the exchange is done, which can be before this
|
|
270
|
+
// host has derived its own key (it still decapsulates and combines after the ciphertext arrives). Bridge-level
|
|
271
|
+
// frames of this bridge's session that arrive in that window are held (bounded), not dropped as "not sealed".
|
|
272
|
+
let exchanging = false;
|
|
273
|
+
const early = [];
|
|
274
|
+
const MAX_EARLY_FRAMES = 16;
|
|
275
|
+
const openSealed = (frame) => {
|
|
276
|
+
chain = chain.then(async () => base.receiveMessage(await sealed.open(frame))).catch((e) => onLog(`[reverse] dropped a sealed frame: ${e.message}`));
|
|
277
|
+
};
|
|
278
|
+
const fail = (why) => { early.length = 0; onLog(`[reverse] sealed bridge with ${from.slice(0, 12)} failed: ${why}`); notifyRefused('seal-failed', who, why); endBridge(from); };
|
|
270
279
|
if (mustSeal) {
|
|
271
280
|
giveUp = setTimeout(() => { if (!sealed) fail('no key exchange in time'); }, proofTimeoutMs * 2);
|
|
272
281
|
giveUp.unref?.();
|
|
@@ -275,20 +284,27 @@ export function createReverseHostWith({
|
|
|
275
284
|
receiveMessage(msg) {
|
|
276
285
|
if (sealed) {
|
|
277
286
|
if (!sealed.isFrame(msg)) { onLog('[reverse] dropped a plaintext message on a sealed bridge'); return; }
|
|
278
|
-
|
|
287
|
+
openSealed(msg);
|
|
279
288
|
return;
|
|
280
289
|
}
|
|
281
290
|
if (msg.type === MSG.KEY_EXCHANGE && msg.session_id === challenge.sessionId) {
|
|
291
|
+
exchanging = true;
|
|
282
292
|
chain = chain.then(async () => {
|
|
283
293
|
const result = await responder.respond(msg, (reply) => conn.sendRelayControl(reply, to()));
|
|
284
294
|
if (result.key) {
|
|
285
295
|
sealed = new SealedBridge({ key: result.key, sessionId: challenge.sessionId, role: 'responder' });
|
|
286
296
|
clearTimeout(giveUp);
|
|
287
297
|
onLog(`[reverse] bridge to ${from.slice(0, 12)} sealed${result.hybrid ? ' (hybrid)' : ''}`);
|
|
298
|
+
for (const frame of early.splice(0)) openSealed(frame);
|
|
288
299
|
}
|
|
289
300
|
}).catch((e) => fail(e.message));
|
|
290
301
|
return;
|
|
291
302
|
}
|
|
303
|
+
if (exchanging && msg.type === MSG.ENCRYPTED_FRAME && msg.channel_id === BRIDGE_CHANNEL_ID && msg.session_id === challenge.sessionId) {
|
|
304
|
+
if (early.length < MAX_EARLY_FRAMES) early.push(msg);
|
|
305
|
+
else onLog('[reverse] dropped a sealed frame: too many arrived before the key exchange finished');
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
292
308
|
if (mustSeal) {
|
|
293
309
|
onLog(`[reverse] dropped a message that is not sealed (type ${msg.type}) on a bridge that must be`);
|
|
294
310
|
if (!unsealedReported) { unsealedReported = true; notifyRefused('not-sealed', who, `a message that is not sealed (type ${msg.type}) on a bridge that must be`); }
|