feat(relay): rendezvous-relay service — 7 packages + plans (contracts/transport/agent/control-plane/e2e/auth/web)
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.
This commit is contained in:
41
term-relay/data-plane/authz-port.ts
Normal file
41
term-relay/data-plane/authz-port.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* P5 authorization SEAM (FIX 6a). These interfaces MIRROR relay-auth's frozen §6a shapes
|
||||
* (`UpgradeContext` / `AuthzOutcome` / `DpopContext` / `Authorizer`). P5 (`relay-auth/`) is not
|
||||
* built in this package's build graph, so — per the "program against interfaces / DI seams,
|
||||
* don't hard-import an unbuilt sibling" rule — P1 defines the port here and injects an impl.
|
||||
*
|
||||
* INTEGRATION POINT: when relay-auth lands, replace these local declarations with
|
||||
* `import type { UpgradeContext, AuthzOutcome, DpopContext, Authorizer } from 'relay-auth'`
|
||||
* (structurally identical). P1 holds NO authz logic — the decision is P5's alone.
|
||||
*/
|
||||
import type { CapabilityRight } from 'relay-contracts'
|
||||
|
||||
/** Proof-of-possession material P5 needs; P1 passes it through, never inspects it. */
|
||||
export interface DpopContext {
|
||||
readonly proof: string | null
|
||||
readonly publicKeyThumbprint: string | null
|
||||
}
|
||||
|
||||
/** Everything P5's `onUpgrade`/`onReattach` needs to make the deny-by-default decision. */
|
||||
export interface UpgradeContext {
|
||||
readonly capabilityRaw: string // opaque token string; P5 verifies the signature
|
||||
readonly originHeader: string // retained for Origin/CSWSH check (P5)
|
||||
readonly expectedAud: string // = the resolved subdomain (Host-confusion guard, INV1)
|
||||
readonly requestedHostId: string // P1 NAMES the resolved host; P5 gates token.host against it
|
||||
readonly requiredRight: CapabilityRight
|
||||
readonly remoteAddrHash: string // salted hash (audit only, INV10)
|
||||
readonly activeSessionCount: number
|
||||
readonly dpop: DpopContext
|
||||
readonly principal: string | null // P5 resolves from the signed token (INV3)
|
||||
}
|
||||
|
||||
/** P5's verdict. The `ok` branch carries the VERIFIED token's `jti` (OQ5 resolved). */
|
||||
export type AuthzOutcome =
|
||||
| { readonly ok: true; readonly hostId: string; readonly principal: string; readonly jti: string }
|
||||
| { readonly ok: false; readonly status: 401 | 403 }
|
||||
|
||||
/** The single authorizer (P5). P1 injects it and supplies the ctx; P5 makes every decision. */
|
||||
export interface Authorizer {
|
||||
onUpgrade(ctx: UpgradeContext, now: number): Promise<AuthzOutcome>
|
||||
onReattach(ctx: UpgradeContext & { readonly sessionId: string }, now: number): Promise<AuthzOutcome>
|
||||
}
|
||||
Reference in New Issue
Block a user