Multi-tenant reverse-tunnel service ("ngrok for Claude Code" with E2E): a
host-agent dials OUT to an operator-run relay; external devices reach the host
THROUGH the relay, routed by per-tenant subdomain, forwarding ciphertext only
(the relay never sees plaintext). Lets a customer reach their own self-hosted
web-terminal from anywhere with zero networking setup.
Packages — all tsc-strict + vitest green (656 tests), cross-package integration verified:
- relay-contracts: frozen shared contracts (mux frame codec, data model,
capability token, E2E envelope, pairing) — the src/types.ts analog
- term-relay: native WS mux + stateless data plane (subdomain routing, ciphertext forward)
- agent: host-agent (pairing, per-host Ed25519 + mTLS dial-out, forwards to 127.0.0.1:3000)
- control-plane: accounts/hosts registry, pairing-code flow, routing table, provisioning
- relay-e2e: browser<->agent E2E (X25519 ECDH through relay, AEAD, anti-replay, recoverable replay key)
- relay-auth: Passkey/WebAuthn, capability tokens, per-host certs, deny-by-default tenant isolation
- relay-web: browser login + Web Crypto E2E + client-side preview rendering
Security invariants INV1-15 enforced; cross-tenant isolation CI tripwire live
(.github/workflows/relay-tripwire.yml). Design + implementation-level plans in
docs/PLAN_RELAY_*.md and docs/EXPLORE_RELAY_SERVICE.md.
NOTE: generated autonomously per the reviewed plans. The security-critical
packages (relay-e2e, relay-auth) REQUIRE expert security audit before any real
deployment — passing tests prove self-consistency, not resistance to attackers.
Base app (src/, public/) unchanged; concurrent desktop work left uncommitted.
44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
/**
|
|
* W0 shared injection seams (DEPENDENCY-CYCLE BREAKER) — PLAN_RELAY_AGENT §2 / T2.
|
|
*
|
|
* These are intra-`agent/` seam *types only*. NO cross-plan frozen contract lives here —
|
|
* those stay in `relay-contracts/`. Declaring them once at W0 lets W2/W3 transport tasks
|
|
* (T7/T10/T12/T14) consume a stable type WITHOUT a task-level cycle (see §3 T10↔T14 note).
|
|
*
|
|
* This module MUST remain side-effect-free and runtime-dependency-free (type-only): a test
|
|
* asserts importing it pulls in no `ws`/crypto runtime, so W2/W3 can depend on it freely.
|
|
*/
|
|
|
|
/**
|
|
* Minimal WS surface the transport layer needs. dial/tunnel/backoff/loopback share it so no
|
|
* per-task redeclare and no drift. Adapters wrap the real `ws` socket into this shape.
|
|
*/
|
|
export interface WsLike {
|
|
send(d: Uint8Array): void
|
|
on(ev: 'message' | 'close' | 'error', cb: (...a: unknown[]) => void): void
|
|
close(): void
|
|
}
|
|
|
|
/** Why a host stopped tunnelling. `renewal-refused`/`goaway-revoked` ⇒ do NOT reconnect. */
|
|
export type RevokeReason = 'renewal-refused' | 'goaway-revoked' | 'operator'
|
|
|
|
/**
|
|
* Revocation seam — T14 IMPLEMENTS it; T10's reconnectLoop only CONSUMES `isRevoked()`.
|
|
* One-way edge (T14 → wires T10's loop), so there is no task cycle.
|
|
*/
|
|
export interface RevocationState {
|
|
isRevoked(): boolean
|
|
markRevoked(reason: RevokeReason): void
|
|
}
|
|
|
|
/**
|
|
* Minimal timer seam so heartbeat (T9) / cert rotation (T13) are testable with fake timers
|
|
* without depending on Node's global timer types leaking into the transport surface.
|
|
*/
|
|
export interface TimerLike {
|
|
setTimeout(cb: () => void, ms: number): unknown
|
|
clearTimeout(handle: unknown): void
|
|
setInterval(cb: () => void, ms: number): unknown
|
|
clearInterval(handle: unknown): void
|
|
}
|