WebSocket support for Astrid capsules (wasm32-unknown-unknown), built in
user space over the net host function: rustls (RustCrypto provider,
host-clock TimeProvider) + WebSocket framing over
astrid_sdk::net::TcpStream. No host-ABI changes: WS/HTTP live in system
space, not host space.
spikes/hello-wss— feasibility spike (PASSED 2026-07-11): from inside a capsule#[astrid::run]loop — TCP → TLS 1.3 → tungsteniteHTTP 101upgrade → NOSTRREQ→ liveEVENTfrom the Unicity relay in ~1.1 s, plusnostr::Keys::generate()at runtime.vendor/(repo root) — vendored patches required on wasm32-unknown-unknown, both upstreamable:rustls-pki-types: compileUnixTime::now()(panicking stub) so rustls'sstdfeature builds; clients with a customTimeProvidernever call it.nostr: drop the browser-only wasm deps (getrandom+js,instant+wasm-bindgen) that break ComponentEncoder. Never callTimestamp::now()on wasm — feed time from the host clock.
astrid-ws/ — poll-friendly WebSocket client for Astrid capsules.
- Core (
WsClient<S: Read + Write>): resumable handshake,poll()that mapsWouldBlock→Pending, queued sends flushed by later polls, auto-pong, graceful close. Unit-tested on the host against a real tungstenite server over an in-memory pipe. astridfeature (wasm32 only):connect_ws/connect_wssoverastrid_sdk::net::TcpStream, TLS via rustls (RustCrypto provider, webpki roots, host-clock TimeProvider).getrandom02-shimfeature: exposesgetrandom02_fill(getrandom 0.2 →astrid:syshost CSPRNG). Registration must happen in YOUR capsule crate — getrandom 0.2 backends only register from the wasm root:getrandom02::register_custom_getrandom!(astrid_ws::getrandom02_fill)(full snippet inastrid-ws/src/rng.rsdocs).
Consumers need the vendored rustls-pki-types patch in their workspace
([patch.crates-io] → vendor/rustls-pki-types) until it is upstreamed.
Run-loop rule: capsules are single-threaded — call poll() on a tick
(the stream read timeout is the tick length) and interleave your IPC
handling. Never block forever.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.