@johnhenry/wsh 0.44.0 → 0.45.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.
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 --
@@ -481,6 +481,19 @@ unix_connect = ["/var/run/docker.sock", "/run/user/1000/wsh/"] # OpenUnix: exac
481
481
  unix_listen = ["/run/user/1000/wsh/"] # ListenUnix: sockets a client may ask the host to create
482
482
  unix_replace_stale = false # replace a stale socket file only if the request asks AND this is true
483
483
  unix_max_listeners = 4 # per client connection
484
+ # TCP reverse tunnels (`enable_reverse_tunnels = true`) and UDP flows: the Node host's bounds and defaults
485
+ reverse_ports = [0, "1024-65535"] # ports a client may ask for; a list REPLACES this default, so below 1024 only when named
486
+ reverse_max_listeners = 4 # per client connection
487
+ reverse_max_connections_per_listener = 16
488
+ reverse_backlog = 8 # listen(2) backlog
489
+ reverse_idle_secs = 300 # an accepted connection quiet for this long is closed; 0 = never
490
+ udp_max_flows = 16 # per client connection
491
+ udp_packets_per_second_per_flow = 500
492
+ udp_packets_per_second_per_client = 2000
493
+ udp_bytes_per_second_per_client = 4194304 # both directions; the amplification bound. 0 on any rate = no limit
494
+ udp_idle_secs = 60 # no datagram in either direction for this long closes the flow (at least 1)
495
+ udp_datagrams = true # offer `gateway-datagram` on WebTransport: a client that lists it too gets UDP payloads as datagrams; false = control stream only
496
+ udp_oversize = "reliable" # a payload over one datagram: "reliable" (control stream, ordered, retransmitted) or "drop"
484
497
  max_buffered_bytes = 4194304 # per connection, for a peer without gateway-credit (at least 262144)
485
498
  max_client_buffered_bytes = 33554432
486
499
  ```
@@ -608,9 +621,23 @@ await bindSocket(upgradedSocket, Promise.resolve(attach), { dataStreams: false }
608
621
  ```
609
622
 
610
623
  `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 `npm test` fails a bundle more than 10% over its budget.
612
- `npm run size -- --update` rewrites the budget after a deliberate change. Sizes are of this package's own code:
613
- `@noble/post-quantum`, the optional ML-KEM backend, is left out of the measurement.
624
+ work) against `scripts/bundle-budget.json`; CI runs it (and writes the table to the job summary) and `npm test` fails a
625
+ bundle more than 10% over its budget. `npm run size -- --update` rewrites the budget and the table below after a deliberate
626
+ change; CI fails when the table is not the budget's. Sizes are of this package's own code: `@noble/post-quantum`, the
627
+ optional ML-KEM backend, is left out of the measurement. What a page ships is what its bundler keeps of these
628
+ (`"sideEffects": false`; the single-import rows show how little a `generateKeyPair` or `createConnectionFactory` import pulls in).
629
+
630
+ <!-- bundle-size:start (generated by `npm run size -- --update`; do not edit) -->
631
+ | browser bundle | minified | gzip |
632
+ | --- | ---: | ---: |
633
+ | `@johnhenry/wsh` (whole entry point) | 159.1 kB | 47.8 kB |
634
+ | `@johnhenry/wsh/memory` (whole entry point) | 223.8 kB | 69.7 kB |
635
+ | `@johnhenry/wsh/host` (whole entry point) | 121.2 kB | 39.9 kB |
636
+ | `@johnhenry/wsh/reverse` (whole entry point) | 211.2 kB | 65.1 kB |
637
+ | `import { generateKeyPair } from '@johnhenry/wsh'` | 0.4 kB | 0.3 kB |
638
+ | `import { WshClient } from '@johnhenry/wsh'` | 131.2 kB | 39.1 kB |
639
+ | `import { createConnectionFactory } from '@johnhenry/wsh/host'` | 98.0 kB | 32.0 kB |
640
+ <!-- bundle-size:end -->
614
641
 
615
642
  ### Signing with a page-held signer
616
643
 
@@ -1233,8 +1260,32 @@ no such channel** (the error lists the channels it does offer and how to serve o
1233
1260
  attempts from 500 ms, doubling), re-sends the client's `initialize` to the new channel without telling the client, answers a request
1234
1261
  that was in flight with a JSON-RPC error (`-32603`, the client may retry) and delivers what the client sent meanwhile (at most 200
1235
1262
  messages). `--target` is not offered: rpc channels are not per target on any host (#121). The same bridge is a function,
1236
- `runMcpStdioBridge()` from `@johnhenry/wsh/mcp-stdio`. **Rust: not built** -- the `wsh` CLI has no `wsh mcp`, because `wsh-client` has no
1237
- rpc channel yet; `wsh-mcp` needs Node.
1263
+ `runMcpStdioBridge()` from `@johnhenry/wsh/mcp-stdio`.
1264
+
1265
+ **Rust: `wsh mcp`** does the same without Node (the next `rust-v` release):
1266
+
1267
+ ```
1268
+ wsh mcp [options] [user@]host|URL # a ws://, wss:// or https:// URL works as the target, as everywhere in wsh
1269
+ -i, --identity NAME the key to log in with: a name in ~/.wsh/keys (what `wsh keygen NAME` makes), default "default"
1270
+ --channel NAME the rpc channel to open (default mcp)
1271
+ --host-key KEY pin the host: 64 hex digits or an ssh-ed25519 line; it must prove that key, known_hosts is neither read nor written
1272
+ --no-reconnect, --reconnect-attempts N, --timeout MS
1273
+ --via URL through a pipe relay, as for every command that dials one host
1274
+ ```
1275
+
1276
+ ```json
1277
+ { "mcpServers": { "remote": { "command": "wsh", "args": ["mcp", "-i", "default", "--host-key", "<fingerprint>", "me@host.example"] } } }
1278
+ ```
1279
+
1280
+ Behaviour, exit statuses, reconnect, the held-message bound and `stdout` carrying MCP only are as above. What differs from `wsh-mcp`:
1281
+ the identity is a keystore name (`-i`), not a file; without `--host-key` the host is checked against `known_hosts` like every `wsh`
1282
+ command (a first use is refused unless `--accept-new-host-key`, because stdin is the MCP stream and cannot answer a prompt; a key
1283
+ that changed is always refused); `--target` is refused with the usual message. **The Rust `wsh-server` offers no `mcp` rpc channel**
1284
+ (hosting an MCP server is an embedding concern), so `wsh mcp` against it exits 2 with `offers no "mcp" channel (it offers: wsh-host)`;
1285
+ `wsh tools` reaches the tools a `wsh-server` is configured with (`[[mcp.tools]]`). Against a released `wsh-server`, `wsh mcp --channel
1286
+ wsh-host` works (it is the same rpc channel, and a handy check). Not covered: a sealed session (`--sealed`) carries no rpc channels
1287
+ on any host, so `wsh mcp --sealed` is refused; WebTransport (`https://`) opens the channel's stream but the Rust client has only
1288
+ been run against WebSocket hosts.
1238
1289
 
1239
1290
  ### Host key (fingerprint / TOFU)
1240
1291
 
@@ -1703,7 +1754,7 @@ instead of dragging its own toolchain and CI job into an unrelated
1703
1754
  browser-app repo. It was previously deleted from clawser by accident
1704
1755
  (2026-03-14) and restored (2026-07-05) before this move.
1705
1756
 
1706
- Four crates, workspace-versioned (currently `0.15.0`):
1757
+ Four crates, workspace-versioned (currently `0.16.0`):
1707
1758
 
1708
1759
  | Crate | Kind | Description |
1709
1760
  |-------|------|--------------|
@@ -1852,8 +1903,8 @@ than left to be found.
1852
1903
  | Remove a remote file | `WshClient.fileRemove()` | `file_transfer::remove()`, `wsh sftp`'s `rm` | **Wire-unified**: `FileOp`/`FileResult` (`op: "remove"`) -- refused today by every `wsh-server` release ("not yet implemented"), the same refusal on both sides |
1853
1904
  | Install an authorized key | `WshClient.addAuthorizedKey()` | `wsh_client::WshClient::add_authorized_key()`, `wsh copy-id` | **Wire-unified** (wsh #59): `AuthorizedKeyAdd`/`AuthorizedKeyResult`, replacing a Rust-CLI-only shell command with a message every implementation can send |
1854
1905
  | Host identity / TOFU | `WshKnownHosts` (localStorage-backed) | `KnownHosts`/`HostStatus` (`~/.wsh/known_hosts`-backed); the client sends `host-key-nonce`, verifies `host-key`/`host-key-sig`, pins only a proven key, and a first use needs `--accept-new-host-key` or a yes at a terminal (`--require-host-key` refuses a host with no proof); `wsh-server` has an opt-in host key (`[server] host_key`) | **Unified** (wsh #59, #145): both pin a PROVEN `ServerHello.host_fingerprint`. A Rust server with no `host_key` configured (the default, so released clients keep working) proves nothing |
1855
- | Typed RPC channels (`openRpc`, `rpc` sessions; `wsh-host`, `wsh-fs`, `mcp`) | `WshClient.openRpc()`, `RpcChannel` | Rust `wsh-server` (`rust-v0.4.0`+): `wsh-host`, and `wsh-fs` when `[rpc] fs_root` is set; no client yet in `wsh-client` | **No wire change**: `Open { kind: 'rpc', command: <protocol> }` plus `rpc*` `ServerHello` features, negotiated so it fails fast elsewhere; the Rust server serves it on WebSocket/QMux only |
1856
- | MCP over stdio for MCP clients that launch a command (#127) | `wsh-mcp` (the package's `bin`) and `runMcpStdioBridge()` from `@johnhenry/wsh/mcp-stdio`: opens the host's `mcp` rpc channel, reconnects, a clear error when the host offers none | **not built**: no `wsh mcp`, because `wsh-client` has no rpc channel; the Rust `wsh-server` also serves no `mcp` rpc channel (it answers `McpDiscover`/`McpCall`, which `WshMcpBridge` uses) | **JS-only for now** -- no wire change (the channel is #85's) |
1906
+ | Typed RPC channels (`openRpc`, `rpc` sessions; `wsh-host`, `wsh-fs`, `mcp`) | `WshClient.openRpc()`, `RpcChannel` | Rust `wsh-server` (`rust-v0.4.0`+): `wsh-host`, and `wsh-fs` when `[rpc] fs_root` is set. **Client:** `WshClient::open_rpc(protocol)` in `wsh-client` (the next `rust-v` release; #127) returns an `RpcChannel` that sends and receives JSON-RPC messages (`rpc_offer()` tells what the host serves); it opens the channel's data stream over WebSocket/QMux (and WebTransport, not exercised against a host) and enforces `rpc-max-message`. It does not correlate requests or interpret `$/cancel` / `$/progress` (its one user, `wsh mcp`, passes MCP through), and there are no typed `wsh-fs` helpers in Rust (the Rust file commands use `FileOp`) | **No wire change**: `Open { kind: 'rpc', command: <protocol> }` plus `rpc*` `ServerHello` features, negotiated so it fails fast elsewhere; the Rust server serves it on WebSocket/QMux only. (`rpc` is now listed in the spec's `ChannelKind`; the bytes are what they were, the Rust server already read the kind from the raw message) |
1907
+ | MCP over stdio for MCP clients that launch a command (#127) | `wsh-mcp` (the package's `bin`) and `runMcpStdioBridge()` from `@johnhenry/wsh/mcp-stdio`: opens the host's `mcp` rpc channel, reconnects, a clear error when the host offers none | `wsh mcp [user@]host\|URL` (the next `rust-v` release): the same bridge, behaviour for behaviour (`--channel`, `--host-key`, reconnect with `initialize` replayed, in-flight requests answered with an error, 200 held messages, exit 2 with the channels the host offers). Identity is `-i NAME` (a `wsh keygen` key), the host is pinned by `known_hosts` or `--host-key`, `--via` works. **`wsh-server` serves no `mcp` rpc channel, so `wsh mcp` to it exits 2 and says it offers `wsh-host`** (use `wsh tools` there: it answers `McpDiscover` / `McpCall`) | **Unified** -- no wire change (the channel is #85's); tested against a Node host and a memory host with the MCP SDK's stdio client (`test/rust/wsh-mcp.test.mjs`) |
1857
1908
  | Exec stdin + EOF, separate stderr | `exec({ stdin })`, `session.closeStdin()`, `session.onStderr` | `SessionOpts { stdio: Some("pipes") }`, `WshSession::read_stderr()` / `close_stdin()`; `wsh host command` uses them whenever its stdin is a pipe or a file and the host offers `exec-pipes` | **Wire-unified, negotiated** (#105): `Open.stdio = "pipes"` + `OpenOk.stderr_channel_id` + zero-length `SessionData` as EOF, offered by the `exec-pipes` `ServerHello` feature. `@johnhenry/wsh/server` needs none of it (stream-mode EOF); the Rust `wsh-server` (`rust-v0.5.0`+) runs such an exec on pipes, everything else on the PTY. Against a host without `exec-pipes` the CLI still forwards stdin, but cannot tell the command it ended |
1858
1909
  | Signals and resize for a one-off command | `session.signal()`, `session.resize()` | `wsh host command` forwards SIGINT/SIGTERM/SIGHUP (the same signal twice disconnects); `wsh --tty host command` also forwards terminal resizes | **Wire-unified** (`Signal`, `Resize`). The Rust `wsh-server` delivers `Signal` (#145) to a pty session's foreground process group (what ^C reaches) and to an exec-on-pipes command's own process group, for `HUP INT QUIT TERM KILL USR1 USR2 WINCH CONT STOP TSTP ALRM` (with or without `SIG`); another name is ignored, and only the control attachment of the connection that owns the channel can send one. Not delivered on Windows |
1859
1910
  | Dial target | a URL | `wsh [user@]host` (dials `https://` then `wss://` on `--port`), or a full URL: `wsh wss://host:8443/rendezvous/ab12 command`, `ws://127.0.0.1:PORT/` | **CLI-only convenience**: a URL is dialled exactly as given (no transport fallback; `--port` and `--transport` do not apply). Plain `ws://` is accepted only to a loopback host |
@@ -1864,8 +1915,8 @@ than left to be found.
1864
1915
  | Post-quantum E2E (experimental) | `initiateE2E()` (WebCrypto ML-KEM-768 or `@noble/post-quantum` fallback) | `E2eKeyExchange` (`ml-kem` crate) | **Wire-unified** algorithm and transcript; key material backends differ by platform necessity |
1865
1916
  | Unix-domain socket forwarding, both directions; named endpoints (#120) | `client.openUnix()`, `listenUnix()`, `forwardUnix()` (Node: `-L`/`-R` shapes with unix and TCP ends mixed), `openEndpoint()`; host: `gateway: { unix, endpoints }`, `createMemoryHost({ endpoints })` | `wsh-server` serves `OpenUnix`/`ListenUnix` (`[gateway] unix_connect`, `unix_listen`, `unix_replace_stale`, `unix_max_listeners`; same policy as the Node host); `wsh-client` has `open_tcp`/`open_unix`/`open_endpoint`/`listen_unix`/`listen_tcp`; CLI `wsh -L` / `-R` / `-N` with TCP, unix and `endpoint=NAME` ends, also through `--via` | **Wire-unified, both directions** (#145). A Rust host does not offer named endpoints (an in-page host does); the CLI reaches them. See [Forwarding with `wsh -L`](#forwarding-with-wsh--l---r---n) |
1866
1917
  | Gateway flow control (#123) | credit per connection (`GatewayCredit`, feature `gateway-credit`); host caps for peers without it | `wsh-server` and `wsh-client`: 256 KiB per direction when both list `gateway-credit`; without it, per-connection and per-client byte caps (`max_buffered_bytes` 4 MiB, `max_client_buffered_bytes` 32 MiB) close the connection that exceeds them | **Wire-unified, negotiated**; an older peer on either side keeps working under the caps. `OpenUdp` flows are metered too (a datagram without credit is dropped) |
1867
- | TCP reverse tunnels (`ListenRequest`, #98) | `@johnhenry/wsh/server` `gateway.reverse` (off by default; loopback unless the operator lists addresses; port allow-list, nothing below 1024 unless named; bounded listeners/connections/backlog/idle); client `listenTcp(port, { onConnection })` | `wsh-server` `[gateway] enable_reverse_tunnels` + `reverse_bind_addr` (off by default, loopback, client `bind_addr` ignored); no port allow-list; no per-listener connection, backlog or idle bounds beyond `max_connections` | **Wire-unified** (`ListenRequest`/`ListenOk`/`ListenFail`/`InboundOpen`/`InboundAccept`; the JS host sends the real `peer_addr`/`peer_port`). **Rust still needs**: a port allow-list and per-client listener / per-listener connection / idle bounds to match the JS host. Accepted connections are metered by `gateway-credit` now |
1868
- | UDP (`OpenUdp`) as WebTransport datagrams (#124) | `client.openUdp()` over WebTransport when both ends list `gateway-datagram`: payloads are datagrams (4-byte flow id + payload), read from `maxDatagramSize`; oversize goes on the control stream (or drops); bounds: flows, packet and byte rates, idle; policy as TCP. Host: `gateway.udp`; Playwright test from Chromium | `wsh-server` serves `OpenUdp` over the reliable control stream only (one `GatewayData` per datagram); no datagrams, no rate bounds | **JS only for now** (negotiated by `gateway-datagram`, so a Rust peer keeps the reliable path). **Rust must implement**: list `gateway-datagram` in `ServerHello.features` on a WebTransport connection, accept/send datagrams `[gateway_id u32 BE][payload]` for `OpenUdp` flows when the client listed it (ignore the id of an unknown flow), read `maxDatagramSize` and send a bigger payload as `GatewayData` (or drop, by config), `connect()` the UDP socket to the checked address, and the same rate/flow bounds |
1918
+ | TCP reverse tunnels (`ListenRequest`, #98) | `@johnhenry/wsh/server` `gateway.reverse` (off by default; loopback unless the operator lists addresses; port allow-list, nothing below 1024 unless named; bounded listeners/connections/backlog/idle); client `listenTcp(port, { onConnection })` | `wsh-server` `[gateway] enable_reverse_tunnels` + `reverse_bind_addr` (off by default, loopback, client `bind_addr` ignored); **`reverse_ports`** (default `[0, "1024-65535"]`, a list replaces it), **`reverse_max_listeners`** 4, **`reverse_max_connections_per_listener`** 16, **`reverse_backlog`** 8, **`reverse_idle_secs`** 300, with the Node host's defaults and refusal sentences (the next `rust-v` release; **breaking** for a deployment that listened below 1024 or kept a quiet tunnel for more than 5 minutes, see the CHANGELOG) | **Wire-unified** (`ListenRequest`/`ListenOk`/`ListenFail`/`InboundOpen`/`InboundAccept`; the JS host sends the real `peer_addr`/`peer_port`); **same bounds on both hosts**. Accepted connections are metered by `gateway-credit`. The Rust idle limit watches only a connection the relay is reading (one parked on the client's credit is bounded by the credit window and the caps instead) |
1919
+ | UDP (`OpenUdp`) as WebTransport datagrams (#124) | `client.openUdp()` over WebTransport when both ends list `gateway-datagram`: payloads are datagrams (4-byte flow id + payload), read from `maxDatagramSize`; oversize goes on the control stream (or drops); bounds: flows, packet and byte rates, idle; policy as TCP. Host: `gateway.udp`; Playwright test from Chromium | `wsh-server` (the next `rust-v` release): the socket is `connect()`ed to the checked address, with **the same bounds as the JS host**: `udp_max_flows` 16, `udp_packets_per_second_per_flow` 500, `udp_packets_per_second_per_client` 2000, `udp_bytes_per_second_per_client` 4 MiB (both directions, `0` = no limit), `udp_idle_secs` 60 counted in both directions, on BOTH paths. **Over WebTransport it lists `gateway-datagram` in `ServerHello.features`** (`udp_datagrams`, default `true`) and, for a client that lists it too, carries the payloads as datagrams `[gateway_id u32 BE][payload]` (a datagram for an unknown flow or one that is malformed is dropped); the limit is read from the QUIC connection for every payload (`max_datagram_size`) and a payload over it goes on the control stream as `GatewayData`, or is dropped with `udp_oversize = "drop"`. A client that did not list the feature, and every WebSocket client, is served over the control stream (one `GatewayData` per datagram) exactly as before. No `gatewayStats()` counters yet (the Node host's `datagramsFromClient`, `rateDropped`, ...); drops are logged at `debug` | **Same on both hosts** (negotiated by `gateway-datagram`: a released peer on either side keeps the reliable path). Tested end to end: the JS client over a real QUIC session against the Rust binary (`test/rust/wsh-rust-server-udp-datagrams.test.mjs`) and unit tests of the framing, the policy and the bounds; **not tested**: a browser (Chromium) against the Rust server (the Playwright test runs against the Node host), and datagrams on a sealed session (WebTransport is never sealed on `wsh-server`, and the JS client sends none when it seals) |
1869
1920
  | Gateway destination policy by resolved address | `@johnhenry/wsh/server` `gateway`: resolved address checked, `allowPrivate` | fixed in the Rust release after `rust-v0.6.0`: a loopback/private/link-local/ULA/CGNAT/unspecified/multicast address is refused after resolution unless a rule names it, and the server connects to the address it checked | **Same rule on both sides** (a Rust server released before that still has the name-only check) |
1870
1921
  | Operator proof to the peer, sealed bridge, signed initiator half (#117) | `reverseConnect(.., { sealed, requirePeerProof })`; host `createReverseHost({ requireOperatorProof })`; relay lists `operator-proof` | **Operator proof: yes.** The Rust relay lists `operator-proof` and carries `ReverseChallenge`/`ReverseProof`/`ReverseConnect.features`; `wsh reverse-connect` answers a challenge (`--operator-proof` / `--no-operator-proof`; by default only for a peer that registered the `operator-proof` capability, because a released Rust host cannot decode the field); `wsh reverse` / `wsh agent run` challenge, verify BEFORE accepting, and take `--require-operator-proof` and `--allow-operator`. **Sealed bridge and both signed `KeyExchange` halves: yes** (`wsh reverse-connect --sealed`; a host with an identity states `e2e` / `e2e-sign` / `e2e-sealed` in its `ReverseAccept` once it has proven the operator). The exchange is byte-identical to JS (transcripts compared against vectors printed by the JS code), hybrid X25519+ML-KEM-768 negotiated exactly as JS does, X25519 when the peer lists no ML-KEM key. A host started with `--require-operator-proof` REQUIRES the sealed bridge (the JS rule): until the key exists it hears and sends nothing but the key exchange, and drops a bridge that has not sealed in 10 s; an operator that does not seal gets no answer to its plain messages. Every message that would cross the relay travels as an `EncryptedFrame` on channel 0; a plain message (wrapped or not) is dropped; **a frame that does not open (tampered, replayed, reordered) closes the bridge** (stricter than the JS host, which drops the frame and ignores the rest). Not covered: a direct or pipe-relayed connection, and `GatewayData` outside a reverse bridge (#155) | **Wire-unified, negotiated** (`ReverseConnect.features`, `operator-proof`, `e2e-sealed`); both implementations seal a reverse bridge |
1871
1922
  | Channel binding of the login signature (#119) | `requireChannelBinding` (client and server); kinds `host`, `cert-hash`, `tls-exporter` | Kind `host`: the client binds to the proven host key (`--require-channel-binding`, and it honours `channel-binding-required`), and `wsh-server` offers it and can require it (`[server] require_channel_binding`, needs `host_key`). `cert-hash` and `tls-exporter`: not in Rust (the Rust WebTransport client has no certificate-hash pinning; `ConnectConfig.cert_hash` binds it if a caller supplies one) | **Wire-unified, negotiated** (`channel-binding:<kind>` features); verified against the spec's test vectors |
@@ -1934,7 +1985,7 @@ plus one `SHA256SUMS` file covering every archive in the release. These
1934
1985
  names are a stable contract other repos (clawser) pin and download by --
1935
1986
  do not change them without coordinating downstream.
1936
1987
 
1937
- `wsh --version` and `wsh-server --version` print the workspace version the binary was built from (`wsh 0.15.0`), which is the
1988
+ `wsh --version` and `wsh-server --version` print the workspace version the binary was built from (`wsh 0.16.0`), which is the
1938
1989
  number in the `rust-vX.Y.Z` tag. Binaries of `rust-v0.9.0` to `rust-v0.10.0` printed a fixed `0.1.0`, so against one of those the
1939
1990
  version cannot be read from the binary (look for a flag in `wsh --help` instead).
1940
1991
 
@@ -2056,14 +2107,18 @@ out explicitly below rather than left to be discovered.
2056
2107
  peers that connect to it. `bindAddr: '0.0.0.0'` (or an `allowBindAddrs` entry that does the same) puts that on every
2057
2108
  interface of the host, so firewall it and keep `ports` narrow. The client sees each peer's address (`InboundOpen`) and
2058
2109
  can reject it, but behind a NAT or proxy that address is not the real source. The Rust server's defaults are the
2059
- same (loopback, off) but it has no port allow-list.
2110
+ same (loopback, off, ports `0` and `1024-65535`, 4 listeners per client, 16 connections per listener, a backlog of
2111
+ 8, a 5-minute idle limit): `reverse_ports`, `reverse_max_listeners`, `reverse_max_connections_per_listener`,
2112
+ `reverse_backlog` and `reverse_idle_secs` under `[gateway]`; the same applies to its UDP flows (`udp_*`).
2060
2113
  - **UDP is not authenticated or private beyond the tunnel.** `allow: ['*']` with a public resolver lets every authorized
2061
2114
  client send UDP to the internet from the host's address (a DNS-sized query, or a spoofed-looking flood limited only by
2062
2115
  the packet rates above); the bounds make that slow, not impossible, and an origin that answers many large datagrams
2063
2116
  to one small one is bounded by `bytesPerSecondPerClient`, not eliminated. WebTransport datagrams can be dropped,
2064
2117
  reordered and duplicated by the network, and are only as private as the QUIC connection that carries them (a
2065
2118
  datagram flow is not covered by E2E sealing, which is for sessions). A payload that did not fit a datagram travels on the
2066
- reliable stream by default (see the README section above).
2119
+ reliable stream by default (see the README section above). On the Rust server a datagram is heard only after the
2120
+ connection has authenticated, for a flow that connection opened (an unknown or malformed one is dropped), and goes
2121
+ through the same per-flow, per-client and byte limits as a payload on the control stream.
2067
2122
 
2068
2123
  - **What the gateway does NOT protect against.** A name that resolves to a *public* address is dialled as the client
2069
2124
  asked, so `allow: ['*']` is an open proxy to the internet for every authorized client. Through `socks` the proxy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnhenry/wsh",
3
- "version": "0.44.0",
3
+ "version": "0.45.0",
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/index.d.ts CHANGED
@@ -217,6 +217,8 @@ export const CHANNEL_KIND: {
217
217
  readonly TCP: 'tcp';
218
218
  readonly UDP: 'udp';
219
219
  readonly JOB: 'job';
220
+ /** A typed object-mode channel (#85): `Open.command` names the protocol. `client.openRpc()` sends it. */
221
+ readonly RPC: 'rpc';
220
222
  };
221
223
 
222
224
  /** Authentication method constants. */
@@ -183,6 +183,7 @@ export const CHANNEL_KIND = Object.freeze({
183
183
  TCP: 'tcp',
184
184
  UDP: 'udp',
185
185
  JOB: 'job',
186
+ RPC: 'rpc',
186
187
  });
187
188
 
188
189
  // ── Auth methods ──────────────────────────────────────────────────────
@@ -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
- const fail = (why) => { onLog(`[reverse] sealed bridge with ${from.slice(0, 12)} failed: ${why}`); notifyRefused('seal-failed', who, why); endBridge(from); };
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
- chain = chain.then(async () => base.receiveMessage(await sealed.open(msg))).catch((e) => onLog(`[reverse] dropped a sealed frame: ${e.message}`));
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`); }