A Node harness for browser-built workers
anon-rpc's Node harness runs a hash-pinned worker inside a sandbox where it starts with nothing and every capability is a host grant. Atmos forks it so that a worker built for the browser, such as the Nym worker, can run there too.
Why fork it
The upstream harness runs workers in a QuickJS interpreter compiled to WebAssembly. QuickJS has no WebAssembly engine of its own, and the Nym worker is a 10 MB WebAssembly client that also opens a WebSocket to its entry gateway. Neither is available in the upstream sandbox, so the Nym worker cannot start there.
What changed
| Upstream | Atmos fork | |
|---|---|---|
| Sandbox | QuickJS, interpreted | a separate V8 isolate (isolated-vm) |
| WebAssembly | none | V8’s own; the promise forms are built on the synchronous ones |
| Guest JavaScript speed | about 50× slower than V8 | V8 speed |
fetch | granted, host-performed, address policy | unchanged |
| WebSocket | none | granted (webSocket), host-opened under the same address policy |
| Browser platform pieces | none | granted (web): base64, Blob URLs, an in-sandbox Worker and MessageChannel, Request, events, DOMException |
| Bundle | fetched from the resolvers each boot | optional cache by hash, rechecked on every load |
The guest still starts with nothing: no process, no require, no module loader, no network of its own. web adds only pure computation. webSocket and fetch are the only ways out, and both go through the host’s address policy.
How it is tested
- Upstream’s own suite passes unchanged on the V8 sandbox. It checks the realm escape, the missing ambient platform, the address policy, and hostile workers: an infinite loop, deep recursion and heap exhaustion. All three are contained, and the host survives.
- A live Nym boot (
test/nym.mjs) loads the hash-pinned worker, connects through the mixnet and answers JSON-RPC calls.
Nym on the Node harness
The live, hash-pinned Nym worker boots in the forked harness with no browser. In one run it connected to an exit router in 1.3 seconds, was ready at 18.9 seconds, and answered eth_blockNumber through the mixnet in about 0.6 seconds. The self-hosted endpoint runs on it by default: a 5-minute wallet-style session answered all 73 calls, 69 of them proof-checked.
Getting there took one fix that matters to anyone porting a browser worker. The Nym client sends its binary frames as Blob objects, so a WebSocket grant must send a Blob’s bytes, not read it like a typed array.
Use it
import { AnonRpcWorker } from "./harness/node-harness/dist/host.js";
const worker = new AnonRpcWorker({
address: "0x3aCD9742C68F6d993066Ae25533e09b9e1f60eD0", // Nym worker, mainnet specifier
preExisting: { rpcProvider },
capabilities: { fetch: true, webSocket: true, web: true },
limits: { memoryBytes: 1024 ** 3, deadlineMs: 60_000 },
bundleCacheDir: ".bundles",
});
await worker.ready; createAtmosClient takes the class as its Worker option, so the Atmos client runs on either harness unchanged.