@johnhenry/wsh 0.41.0 → 0.43.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
- - **108 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
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 --
@@ -713,10 +713,20 @@ const s = await client.openSession({ type: 'exec', command: 'echo hello' });
713
713
  `ReverseConnect` at a time (a concurrent one is told `busy: ... retry in a
714
714
  moment`), since a `ReverseAccept` does not name its operator; and at the cap
715
715
  the reason is `busy: this peer already has its maximum of n operators`
716
- (`busyPeerFull(n)`). The **Rust relay is still one operator per peer**: it
717
- never sends `ReverseClose` and rejects the second operator; the new spec
718
- fields are regenerated into the Rust types and ignored there. Tracked for the
719
- Rust relay in #93.
716
+ (`busyPeerFull(n)`). The **Rust relay and the Rust peer do this too** (#93): `wsh-server --enable-relay`
717
+ with `[relay] max_operators_per_peer = n` in its config (default `1`, 1 to 64; above 1 it advertises
718
+ `relay-multi-operator`), and `wsh --max-operators n reverse ...` / `wsh --max-operators n agent run ...` on the
719
+ peer (default `1`; the peer states the feature only to a relay that advertises it, and serves one operator at a
720
+ time on any other). The Rust relay rejects a busy peer's next operator with a `ReverseReject` carrying the same
721
+ `busy:` reasons. Differences from the JS relay, kept so nothing existing changes: when an operator leaves a peer
722
+ that serves one, the Rust relay leaves the peer connected (it may take the operator back), where the JS relay
723
+ closes it; and a peer that goes away leaves its operators connected. A Rust peer serving several operators keeps
724
+ each operator's sessions, processes and files apart (when one leaves, only its work is killed), takes each
725
+ operator's `--allow-operator` decision and operator proof on its own, and **does not seal bridges** (a
726
+ connection holds one seal): `--max-operators` above 1 is refused together with `--require-operator-proof`, and
727
+ an operator that insists on `--sealed` is refused by such a peer. The Rust relay also carries
728
+ `KeyExchange.signature` and advertises `e2e-sign`, so a JS reverse host signs its half of an end-to-end
729
+ exchange through it.
720
730
  - **On the peer**, the bridged operator is served by the same connection code as
721
731
  a direct client, over an in-memory message pipe instead of a socket. Nothing a
722
732
  client opens can cross the relay but control messages, so exec sessions are
@@ -843,7 +853,7 @@ sides; a host that does not require proof is exactly as exposed as before), the
843
853
  messages and seals nothing itself), and a compromised *operator* key (it proves the key, not the
844
854
  person). A relay can still refuse service by dropping the challenge.
845
855
 
846
- #### A sealed session (#155, host: JS; client: the Rust CLI so far)
856
+ #### A sealed session (#155, host: JS and the Rust `wsh-server`; client: the JS client and the Rust CLI)
847
857
 
848
858
  `createMemoryHost({ hostKey, dataStreams: false, sealSession: 'offer' | 'require' })` (and `createWshServer`, for a connection
849
859
  accepted with `dataStreams: false`) seals the WHOLE session end to end. After login the client sends a `KeyExchange` whose
@@ -858,8 +868,32 @@ downgrade. Only `--sealed` is a guarantee: sealing "on its own" rests on a `Serv
858
868
  login, so a client that must never talk in the clear passes `--sealed` (against a host that requires sealing, a stripped client is
859
869
  refused, but what it sent before the refusal -- its commands, if any -- was already readable). What it does NOT cover: the handshake before login (the user name, the login public key and the host key proof are
860
870
  readable by the relay; the signed key exchange is not secret), the sizes and timing of traffic, a host whose connection has client-opened
861
- QMux data streams (not offered there), and a denial of service (a relay can always drop or cut). The JS client has no sealed
862
- session yet, so against a JS client use a host that only `'offer'`s.
871
+ QMux data streams (not offered there), and a denial of service (a relay can always drop or cut).
872
+
873
+ The JS client is the initiator too: `client.connect(url, { sealSession: false | 'auto' | true })` (also `WshClient.exec`).
874
+ `'auto'`, the default, seals only against a host that says `e2e-session-required` (so a client written before this option keeps
875
+ talking plainly to a host that merely offers it, and a host that requires sealing no longer refuses it); `true` seals or fails --
876
+ a host that does not offer `e2e-session`, one that proved no host key, or a password login is refused BEFORE a credential is
877
+ sent, with a sentence; `false` never seals. `client.sessionSealed` says whether it is. The exchange is bound to the host key the
878
+ host PROVED on this connection: it authenticates that key, not whose it is, so pin the host as well (`expectHostKey` /
879
+ `knownHosts`), or a relay that presents its own host key and terminates the exchange is the host to this client. Once sealed, a
880
+ plain message from the host is dropped, a frame that does not open ends the connection (`onError`, then `onClose`), `openStream()`
881
+ is refused and datagrams are neither sent nor heard (UDP uses the reliable path). `'auto'` is not a guarantee, for the reason above;
882
+ `true` is.
883
+
884
+ The Rust `wsh-server` is a responder too: `[server] seal_session = "off" | "offer" | "require"` (default `off`: no feature is
885
+ advertised and no released client is affected; `offer` and `require` need `host_key`, else the config is refused at start). On a
886
+ WebSocket connection it advertises `e2e-session` (and `e2e-session-required` with `require`), and after a KEY login it answers the
887
+ signed key exchange (it verifies the login key's signature, signs its reply with the host key) with the same `SealGate` the CLI uses;
888
+ from then on every control message but ping/pong is an `EncryptedFrame` both ways, gateway data included, and a frame that does not open
889
+ closes the connection. `offer` serves a client that never asks as before. `require` serves nothing in the clear: a plain message before
890
+ the key exists is answered with an error and the connection is closed, a password login is refused, and WebTransport connections and
891
+ WISP tunnels are refused (they cannot be sealed; connect over WebSocket). **Typed rpc channels (`wsh-fs`, ...) are not offered while
892
+ `seal_session` is on** (they ride client-opened data streams, which are not frames; the server says so at start). WebTransport on an
893
+ `offer` server is served as before and does not list `e2e-session`, so a client that must seal (`sealSession: true`, `--sealed`) is
894
+ refused there before a credential is sent. The same limits apply as for the JS host: the handshake before login, sizes and timing,
895
+ and a denial of service are not covered, and sealing "on its own" (`'auto'`, the CLI without `--sealed`) against an `offer` server is
896
+ not a guarantee. Pin the server's host key on the client (`expectHostKey`, `known_hosts`): the exchange authenticates the key the server proved.
863
897
 
864
898
  #### Knowing who a host turned away: `onRefused` (#163)
865
899
 
@@ -907,7 +941,7 @@ handshake and the session traffic -- is readable by it unless the two ends seal
907
941
  (per-session `initiateE2E`, or the **sealed session** below); it cannot forge the operator's signature or the host's.
908
942
  **Until you seal the session, treat a pipe relay as trusted for secrecy AND integrity**: it can read every control message and
909
943
  all gateway and endpoint data (`GatewayData`: TCP, unix sockets, named endpoints) and alter forwarded bytes after the handshake
910
- (#155). Pin the host key, require channel binding, use `wss://` to a relay you trust, or seal the session. It can drop, delay or
944
+ (#155; the JS client's `sealSession: true` and the CLI's `--sealed` seal it against a JS host that offers it). Pin the host key, require channel binding, use `wss://` to a relay you trust, or seal the session. It can drop, delay or
911
945
  cut a connection, and it sees who dials which id and how much they send.
912
946
 
913
947
  *CLI side (#145).* `wsh --via wss://relay/r/<id> user@host [command...]` dials the operator side
@@ -1199,6 +1233,47 @@ The host advertises `file-write` / `file-rename` in `ServerHello`; the client
1199
1233
  throws instead of sending to a host without them (the Rust `wsh-server`
1200
1234
  refuses these ops).
1201
1235
 
1236
+ ### Execution targets (#121)
1237
+
1238
+ A host that fronts several places to run things (containers, VMs, workers, sandboxes) names them, instead of overloading `username` or
1239
+ prefixing the command. Off unless you give `targets` (to `createWshServer`, `createMemoryHost`, or `createConnectionFactory` through
1240
+ `resolveBackends`); then the host advertises `targets` in `ServerHello.features`.
1241
+
1242
+ ```js
1243
+ createWshServer({
1244
+ auth: { authorizedKeys },
1245
+ targets: {
1246
+ web: { description: 'the web container', exec: true },
1247
+ db: { description: 'the database VM', exec: (command, io) => runInVm(io.target, command, io), fs: dbFiles,
1248
+ authorize: (who, { target, kind }) => who.fingerprint === DBA_KEY }, // kind: exec | pty | file | endpoint | list
1249
+ },
1250
+ // requireTarget: true, // an Open, FileOp or OpenEndpoint that names no target is refused: nothing runs on the host itself
1251
+ });
1252
+ const targets = await client.listTargets(); // [{ name, description?, capabilities }] -- only what THIS key may use
1253
+ await client.openSession({ type: 'exec', command: 'psql -c ...', target: 'db' }); // also exec(url, cmd, { target })
1254
+ await client.fileOperation('list', '/var/lib', { target: 'db' }); // FileOp.target
1255
+ await client.openEndpoint('metrics', { target: 'web' }); // OpenEndpoint.target
1256
+ ```
1257
+
1258
+ Each target has its own `exec`, `pty`, `fs` and `endpoints` (the same forms as the host's own, `exec: true` and `fs: { root }` included on
1259
+ Node); the host's own are used only by a request that names no target. A target without a backend for the request refuses it (`exec is
1260
+ not enabled for this target`): a request is never run somewhere else. `io.target` (exec), `{ target }` in the pty `spawn` options, in every
1261
+ file backend call and on an endpoint's `duplex.target` tell a shared function which target it serves. `authorize(who, { target, kind })` is
1262
+ asked for every request that names the target and for `listTargets()`; only `true` lets the caller on, and a refused target and one that
1263
+ does not exist get the same answer (`no such target`), so the reply does not say which targets exist. A target without `authorize` is open
1264
+ to every key the host authenticated, as the host's own `exec` is. A `target` the client sends to a host that does not advertise `targets` is
1265
+ not sent (the client throws); a raw one is refused (`this host has no targets`). `createReverseHost` takes no `targets`.
1266
+
1267
+ What it does **not** do: `requireTarget` covers `Open` (exec, pty, file, rpc), `FileOp` and `OpenEndpoint`, not the gateway (`OpenTcp`,
1268
+ `OpenUnix`, `ListenRequest`, ...), MCP, the `rpc` channels (`wsh-fs`, ... are the host's own and are refused when a target is named), or
1269
+ `Attach` to a session that already exists (it was opened on its target, and its owner may attach as before). A target is an authorization
1270
+ boundary only as far as your `authorize` and your backends make it one: the library routes and refuses, it does not isolate anything.
1271
+
1272
+ The Rust CLI names one with `wsh --target NAME [user@]host [command...]` (or `wsh --target NAME connect [user@]host`) and lists them with
1273
+ `wsh targets [user@]host [--json]`; `--target` is refused (exit 2) by file transfer, forwarding, `--share`, `-N` and every other subcommand,
1274
+ and sent only to a host that advertises `targets`. The Rust `wsh-server` has no targets (it states no feature and refuses any request that
1275
+ names one).
1276
+
1202
1277
  ### Compatibility: announce vs. primer
1203
1278
 
1204
1279
  An exec session's output flows on a second, client-opened stream, and a QMux
@@ -1273,7 +1348,7 @@ closes the channel when received.
1273
1348
  | Protocol | Methods |
1274
1349
  |---|---|
1275
1350
  | `wsh-host` | `host.info` -> `{ version, protocol, features (this connection's ServerHello), hostFingerprint, user, rpc }`; `host.ping` -> `{ time }` |
1276
- | `wsh-fs` | `stat`, `list`, `mkdir`, `remove`, `rename { path, newPath }`, `write { path, data, offset? }`, `upload { path, data, offset? }` (offset omitted/0 creates or truncates, later offsets continue in place: chunk big files), `read { path, offset?, length? }` and `download { path }` (the bytes arrive as `$/progress` chunks of at most 64 KiB; the result is `{ size, offset, length, eof }`). Same confinement as `fs`: no traversal or symlink escapes, `readOnly`, `maxFileBytes`; policy refusals are `-32003`. |
1351
+ | `wsh-fs` | `stat`, `list` (entries sorted by name in UTF-16 code-unit order on every platform and on both hosts: upper case before lower case, whatever the filesystem's case rules), `mkdir`, `remove`, `rename { path, newPath }`, `write { path, data, offset? }`, `upload { path, data, offset? }` (offset omitted/0 creates or truncates, later offsets continue in place: chunk big files), `read { path, offset?, length? }` and `download { path }` (the bytes arrive as `$/progress` chunks of at most 64 KiB; the result is `{ size, offset, length, eof }`). Same confinement as `fs`: no traversal or symlink escapes, `readOnly`, `maxFileBytes`; policy refusals are `-32003`. |
1277
1352
  | `mcp` | The MCP JSON-RPC surface verbatim; see below |
1278
1353
 
1279
1354
  When a host advertises `rpc-protocol:wsh-fs`, `fileStat` / `fileList` / `fileRead` /
@@ -1474,7 +1549,7 @@ so options the platform gains later need no change here.
1474
1549
 
1475
1550
  | Export | Description |
1476
1551
  |--------|-------------|
1477
- | `MSG` | 108 message type constants (hex opcodes) |
1552
+ | `MSG` | 110 message type constants (hex opcodes) |
1478
1553
  | `CHANNEL_KIND` | Channel types: `pty`, `exec`, `meta`, `file`, `tcp`, `udp`, `job` |
1479
1554
  | `AUTH_METHOD` | Auth methods: `pubkey`, `password` |
1480
1555
  | `cborEncode` / `cborDecode` | CBOR codec (maps, arrays, strings, ints, bytes, bools, null, floats) |
@@ -1498,7 +1573,7 @@ instead of dragging its own toolchain and CI job into an unrelated
1498
1573
  browser-app repo. It was previously deleted from clawser by accident
1499
1574
  (2026-03-14) and restored (2026-07-05) before this move.
1500
1575
 
1501
- Four crates, workspace-versioned (currently `0.12.0`):
1576
+ Four crates, workspace-versioned (currently `0.14.0`):
1502
1577
 
1503
1578
  | Crate | Kind | Description |
1504
1579
  |-------|------|--------------|
@@ -1523,6 +1598,9 @@ disconnects. `wsh connect` ends when the remote session does. Diagnostics go to
1523
1598
  never into the command's stdout. TLS uses the platform trust store, and `SSL_CERT_FILE` points it at another certificate (how a self-signed host is trusted); a plain
1524
1599
  `ws://` URL is accepted only for a loopback host.
1525
1600
 
1601
+ `wsh --target NAME [user@]host [command...]` runs on one of the host's execution targets and `wsh targets [user@]host` lists the ones this key may
1602
+ use (see [Execution targets](#execution-targets-121)); it is sent only to a host that advertises `targets`.
1603
+
1526
1604
  ### Forwarding with `wsh -L` / `-R` / `-N`
1527
1605
 
1528
1606
  Modelled on OpenSSH. The forwards live as long as the connection does (`wsh -L ... user@host` also runs the command or
@@ -1651,7 +1729,7 @@ than left to be found.
1651
1729
  | Host that runs in a browser page (`createMemoryHost`, `@johnhenry/wsh/reverse`) | yes, with injected `pty` / `fs` / `hostKey` | no (a Rust host is a process) | **JS-only**. A Rust *client* can operate such a host only with `dataStreams: false` (#132): the released Rust client over WebSocket cannot open QMux data streams, and says nothing in `Hello` that a host could use to decide. `wsh scp` works against such a host with the Rust client of the next `rust-v` release (it speaks `FileChunk`, #140); a released `rust-v0.11.0` or older `wsh scp` hangs against it (`wsh ls` and exec work) |
1652
1730
  | Interactive shell UI | none -- this SDK is a protocol client, not a terminal emulator; pair with xterm.js/ghostty-web | `wsh connect`, `wsh sftp` (line-oriented REPL) | **Deliberately not unified** -- a browser embeds a terminal widget the host page owns; a CLI process owns its own TTY |
1653
1731
  | Attach / resume | `attachSession()`, `resumeSession()`, `WshSession.seq` | `attach_session()`, `resume_session()` | **Wire-unified** (`Attach`/`Resume`/`Presence`); `seq` = cumulative output bytes. `@johnhenry/wsh/server` honours `last_seq` (bounded ring, gap errors) and answers Presence with `channel_id`/`seq`; the Rust `wsh-server` does the same (`rust-v0.2.0`+; fixed 256 KiB ring) |
1654
- | Reverse-connect / relay peer | `connectReverse()`, `trustRelayPeer()`; `@johnhenry/wsh/server`: `relay` option and `createReverseHost()` | `wsh reverse`, `wsh agent` (persistent, with startup-unit install) | **Wire-unified** (registration, discovery, signed peer records); **daemonization is CLI-only** -- a browser tab cannot be a background OS service. The Node relay is default-deny and bridges one operator per peer unless `maxOperatorsPerPeer` is raised (`busy:` reasons say so); E2E and bridged feature gates need `rust-v0.3.0`+ on the Rust side; several operators per peer and the signed `KeyExchange` are JS-relay only for now |
1732
+ | Reverse-connect / relay peer | `connectReverse()`, `trustRelayPeer()`; `@johnhenry/wsh/server`: `relay` option and `createReverseHost()` | `wsh reverse`, `wsh agent` (persistent, with startup-unit install) | **Wire-unified** (registration, discovery, signed peer records); **daemonization is CLI-only** -- a browser tab cannot be a background OS service. The Node relay is default-deny and bridges one operator per peer unless `maxOperatorsPerPeer` is raised (`busy:` reasons say so); E2E and bridged feature gates need `rust-v0.3.0`+ on the Rust side. **Several operators per peer (#93): both relays** (`maxOperatorsPerPeer`; `[relay] max_operators_per_peer`, default 1) **and both peers** (`createReverseHost({ maxOperators })`; `wsh --max-operators n reverse` / `agent run`, default 1), negotiated by `relay-multi-operator`; a Rust peer serving several operators does not seal bridges (see the reverse-mode notes), and the Rust relay leaves a peer connected when its operator leaves. The signed `KeyExchange` (`e2e-sign`) is carried by the Rust relay too |
1655
1733
  | 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 |
1656
1734
  | 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) |
1657
1735
  | 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) |
@@ -1661,8 +1739,9 @@ than left to be found.
1661
1739
  | 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 |
1662
1740
  | 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 |
1663
1741
  | Pipe relay (#118) | `@johnhenry/wsh/pipe-relay` | operator side only (#145): `wsh --via wss://relay/r/<id> user@host command...` (also `connect`, `scp`, `ls`, `sftp`, `copy-id`), or the URL as the target. The host side of a pipe is not implemented in Rust. As on a direct connection the Rust client verifies the host-key proof (`host-key` / `host-key-sig` over its own nonce) before sending a credential, pins only a proven key, and binds the login to it (channel binding `host`; `test/rust/wsh-cli-identity.test.mjs`); the pipe-relayed session itself is not sealed (see Security model). `wsh -N -L` exits non-zero when the host drops the session (#156), and the error lines show the relay and a shortened id, never the whole rendezvous id | **Deliberately a relay without wsh parsing** -- nothing to unify on the wire. `--via` keeps `user@host` as the identity: its key is recorded in `known_hosts` under `host:port` (what a direct connection uses), never under the relay's address; a URL target is recorded under the URL's own authority, i.e. the relay's. The URL is not saved to `last_session.json` (the id is a capability) |
1742
+ | Execution targets (#121): `Open.target`, `FileOp.target`, `OpenEndpoint.target`, `ListTargets` / `TargetList` | host: `targets` on `createWshServer` / `createMemoryHost` (own backends and `authorize(who, { target, kind })` per target, `requireTarget`); client: `openSession({ target })`, `exec(.., { target })`, `fileOperation(.., { target })`, `openEndpoint(.., { target })`, `listTargets()` | CLI: `wsh --target NAME [user@]host [command...]` and `wsh connect` (exec and shells only; every other subcommand, `-L`/`-R`/`-N` and `--share` refuse `--target`), `wsh targets [user@]host [--json]`; the client's `open_session(SessionOpts { target })` and `list_targets()` (file and endpoint calls send no target). **A Rust host with targets: not built**: `wsh-server` states no `targets`, refuses a request that names one and answers `ListTargets` with an error | **Wire-unified, negotiated** (`targets` feature; every new field optional, never sent to a host that did not advertise it) |
1664
1743
  | Operator-side shared folders (`--share`, #159) | host side: `onShare(name, fs, who)` on `createMemoryHost` / `createWshServer` / `createReverseHost` (the host *uses* the operator's directories; `fs` is an object of async file operations, also shaped like an `fs` backend; `fs.root` is the operator's advisory, unverified path for the share, #164). The JS client does not offer shares | CLI side: `wsh --share NAME=/abs/dir[:ro\|:rw]` offers them, with each directory's path unless `--share-hide-path` (`wsh_client::share`, `wsh-cli`'s `sharefs`: descriptor-relative, never follows a link, see [Sharing a directory](#sharing-a-directory-with-the-host-wsh---share-159)); unix only. **A Rust host that uses shares: not built** (`wsh-server` does not state `shares`) | **Wire-unified, negotiated**: the host states the feature `shares`; the client sends one `ShareOffer` after login (opcodes `0xa8` `ShareOffer`, `0xa9` `ShareRequest`, host to client, `0xaa` `ShareReply`). No change notification, no sharing over `reverse-connect` |
1665
- | Sealed session: any authenticated connection incl. gateway/endpoint data (#155) | host `sealSession: 'offer' \| 'require'` (stage b); the JS client does not seal yet | `wsh --sealed ...` (or automatic against `e2e-session-required`) seals a direct or pipe-relayed session; `wsh-server` does not offer it yet | **Wire-unified, negotiated** (`e2e-session`, `e2e-session-required`, `KeyExchange` for the connection's session id, `EncryptedFrame` channel 0) |
1744
+ | Sealed session: any authenticated connection incl. gateway/endpoint data (#155) | host `sealSession: 'offer' \| 'require'` (stage b); client `connect(url, { sealSession: false \| 'auto' \| true })` (stage c) | `wsh --sealed ...` (or automatic against `e2e-session-required`) seals a direct or pipe-relayed session; `wsh-server` offers or requires it on WebSocket (`[server] seal_session = "off" \| "offer" \| "require"`, needs `host_key`; `require` refuses WebTransport, WISP tunnels and password logins; no typed rpc channels while it is on) | **Wire-unified, negotiated** (`e2e-session`, `e2e-session-required`, `KeyExchange` for the connection's session id, `EncryptedFrame` channel 0) |
1666
1745
  | Refusal event with stable reason codes (`onRefused`, #163) | `onRefused({ reason, who, detail })` on `createMemoryHost` / `createWshServer` / `createReverseHost`; `REFUSAL_REASONS` from `@johnhenry/wsh/host` | none: `wsh-server` and `wsh reverse` log a refusal, they have no callback (an embedding process has none) | **JS-only** -- a host-side callback of the embedding API, no wire change |
1667
1746
  | `AuthOk.ttl` enforced, `token` opaque (#125) | `connectionTtlMs`; `client.authTtl` | `wsh-server` sends `ttl: 0` (no lifetime promised; `session_ttl` is the lifetime of a *detached* session) and an HMAC token that nothing accepts back | **Wire-compatible**: both fields are still sent (released peers require them). **Changed in the Rust server after `rust-v0.6.0`**: it used to send `session_ttl` (86400), which nothing enforced. The Rust client ignores `ttl` |
1668
1747
  | `clientEnv` allow-list (#126) | default `TERM`, `COLORTERM`, `LANG`, `LANGUAGE`, `LC_*` | `wsh-server`: the same default; `[server] client_env = true` (everything, the old behaviour), `false` (nothing) or a list of names / `PREFIX*` (replaces the default) | **Both hosts**; wire unchanged. **Breaking default in the Rust server**, see the CHANGELOG |
@@ -1722,7 +1801,7 @@ plus one `SHA256SUMS` file covering every archive in the release. These
1722
1801
  names are a stable contract other repos (clawser) pin and download by --
1723
1802
  do not change them without coordinating downstream.
1724
1803
 
1725
- `wsh --version` and `wsh-server --version` print the workspace version the binary was built from (`wsh 0.12.0`), which is the
1804
+ `wsh --version` and `wsh-server --version` print the workspace version the binary was built from (`wsh 0.14.0`), which is the
1726
1805
  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
1727
1806
  version cannot be read from the binary (look for a flag in `wsh --help` instead).
1728
1807
 
@@ -1773,6 +1852,21 @@ out explicitly below rather than left to be discovered.
1773
1852
  entry client-side and reports a `verified` boolean, independent of
1774
1853
  trusting the relay.
1775
1854
 
1855
+ - **Execution targets: a name the client sends and the host decides on (#121).** Off unless `targets` is given. The host runs
1856
+ `authorize(who, { target, kind })` for every request that names a target (and `listTargets()`), and a refused target looks like an
1857
+ unknown one. It does NOT isolate targets from each other: a key allowed on two can use both, the library only routes and refuses, so the
1858
+ isolation a target gives is your backends'. `requireTarget` does not cover the gateway, MCP or `Attach`; without it a request with no
1859
+ target runs on the host's own backends, which any authenticated key can use, so a deployment that confines a key to one target must set
1860
+ `requireTarget` (or leave the host with no backends of its own). The Rust `wsh-server` has no targets and refuses any request that names one.
1861
+ - **Several operators per peer share one peer, and the relay decides who is who (#93).** Off unless both the relay
1862
+ (`maxOperatorsPerPeer`, `[relay] max_operators_per_peer`) and the peer (`maxOperators`, `--max-operators`) are
1863
+ set above 1. The relay stamps each message with its own record of the sender's authenticated key and removes
1864
+ `to_fingerprint`; it checks the inner of a forward a peer wrote (size, decodes, a forwardable type) and drops what it
1865
+ cannot address. It does NOT protect operators from each other beyond that: they run as the same OS user as the
1866
+ peer, so a command one operator starts can read or kill another's files and processes. A Rust peer serving several
1867
+ operators cannot seal bridges (one seal per connection), so its bridges are as private as the relay is honest;
1868
+ use one operator per peer where that matters (`--require-operator-proof` needs it and is refused otherwise).
1869
+
1776
1870
  - **The Node gateway checks where a connection goes, not only what it was called.** `gateway.allow` matches the name a
1777
1871
  client sent, and then the address it resolves to must be globally routable (or permitted by `allowPrivate` or an
1778
1872
  IP-literal rule); the connection is made to that checked address, and `ResolveDns` answers are filtered the same way.
@@ -1962,15 +2056,16 @@ What this does **not** protect against:
1962
2056
  JS host's, above): nothing is promised or enforced at connection level; do not
1963
2057
  treat the token as a credential.
1964
2058
  - **`wsh --via` (pipe relay from the Rust CLI) is the operator side only, and
1965
- still not sealed** (the sealed bridge of `wsh reverse-connect --sealed` covers
1966
- reverse bridges only; #155 tracks sealing a direct or pipe-relayed connection and
1967
- its gateway data). The Rust client now verifies the host-key proof
2059
+ not sealed unless you ask** (`wsh --sealed` seals a direct or pipe-relayed session, gateway
2060
+ data included, against a host that offers `e2e-session`: the JS host with `sealSession`, or
2061
+ `wsh-server` with `seal_session`; #155. Without `--sealed` the session is plain, and a relay reads
2062
+ it). The Rust client now verifies the host-key proof
1968
2063
  (`host-key` / `host-key-sig` over its own `host-key-nonce`) before sending
1969
2064
  any credential, records only a PROVEN key in `known_hosts`, binds the login
1970
2065
  signature to that key (channel binding `host`), and refuses a changed key
1971
2066
  always. A replayed `ServerHello` or an impostor's key is refused as the JS
1972
- client refuses it. What is still unprotected: the bridge is not sealed
1973
- end to end (a pipe-relayed session has no sealing layer yet, #155), so the relay sees
2067
+ client refuses it. What is still unprotected without `--sealed`: the session is not sealed
2068
+ end to end, so the relay sees
1974
2069
  session traffic in the clear unless the legs are TLS and it is trusted not
1975
2070
  to read them (it terminates each leg's TLS), and it can stamp an identity on
1976
2071
  a plain message after the handshake. A host with no host key proves nothing:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnhenry/wsh",
3
- "version": "0.41.0",
3
+ "version": "0.43.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",