This has not been audited, skips some security precautions, and is likely highly fingerprintable. It is for educational and experimental purposes only.
A TypeScript implementation of the Tor anonymization and anti-censorship protocol, runnable in Node.js or directly in a browser tab via Snowflake.
The repo is a yarn workspace. Each package is independently published-shaped and tested; the examples wire them together for concrete use cases.
Implemented:
- Client circuit to clearweb (3-hop ntor + relay cells)
- Client circuit to v3 hidden services (rend-spec-v3, INTRODUCE/RENDEZVOUS, hs-ntor)
- Hosting v3 hidden services (server side: ESTABLISH_INTRO with KH-bound MAC, descriptor build/sign/publish, INTRODUCE2 decrypt, hs-ntor server, rendezvous virtual hop)
- Browser support via Snowflake (WSS → turbotunnel → KCP → SMUX → TLS 1.3 → Tor)
- Signed-consensus verification (against the hardcoded mainnet authorities; injectable trust anchor for chutney/test nets)
- Bandwidth-weighted relay selection with exit-policy filtering
- CI integration tests against the live Tor network and a local chutney test net
- SOCKS5 proxy server (
SocksProxyServer) that fronts arbitrary clients with a Tor circuit; supports CONNECT, RESOLVE, and RESOLVE_PTR (proposal-100) to IPv4/IPv6/domain targets, with USERNAME_PASSWORD as a stream-isolation key
Not implemented:
- Guard / middle / exit relay (this is a client-only stack)
- Directory authority
packages/tor— the Tor protocol implementation: cells, circuits, link/relay protocols, ntor handshake, directory client, consensus parsing+verification, hidden-service client + server. Standalone in Node.js with a TLS channel; the entry point most users want isconnectRandomCircuitWithSafeBootstrap()frompackages/tor/src/build-circuit/mainnet.ts. To host an onion service, the entry point ispublishHiddenService(...)inpackages/tor/src/hidden-service-host.ts— takes any bootstrappedTorClient(mainnet, chutney, or browser/Snowflake) and surfaces inbound BEGIN-streams via anonConnectioncallback.packages/snowflake— the client side of the Snowflake pluggable transport in pure TypeScript: encapsulation framing, turbotunnel preamble, KCP reliable-over-packet, and SMUX v2 multiplexing. As far as we know, this is the second client implementation of the Snowflake stack anywhere (the canonical Go client being the first; Arti shells out to it).packages/browser— browser glue that composes Snowflake + Tor into a single TLS-1.3-capable channel that runs entirely in a tab or service worker, using@reclaimprotocol/tls. Layer-by-layer protocol stack documented inpackages/browser/README.md.packages/crypto—tor-crypto: the small set of primitives Tor needs (Curve25519, Ed25519, AES-CTR, SHA-1/2/3, HKDF, PKCS#1 RSA verify), with isomorphic Node and browser entry points.
examples/tamanegi-browser— Vite static site that browses the web through Tor entirely from a browser tab via Snowflake. ("Tamanegi" 🧅 is Japanese for "onion".) The HTML it fetches renders inside an<iframe srcdoc>.examples/node-fetch— minimal Node script that does an HTTPS request through a 3-hop Tor circuit usingnode-fetchand thetorpackage's HTTP agent.examples/http-proxy— local HTTP proxy server that fronts arbitrary clients with a Tor circuit per upstream connection. Useful for plugging existing tooling (curl, browsers, scripts) into the in-process Tor stack without changing them.examples/socks-proxy— local SOCKS5 proxy server backed by a Tor circuit. Same idea ashttp-proxybut speaks the protocol every Tor-aware tool already knows; supports CONNECT plus Tor's anonymous-DNS RESOLVE / RESOLVE_PTR (proposal 100). Implementation lives inpackages/torat the'tor/socks'subpath.
# install deps (yarn 4 via corepack)
yarn install
# run the unit test suite (every package)
yarn test
# typecheck everything
yarn typecheck
# format + lint
yarn format
yarn lint
# live integration tests (require network access; chutney tests
# additionally need a local chutney install — see packages/tor/scripts/ci-chutney.sh)
yarn test:live