fix(client): refuse insecure credential transport

Merged
TH
1d ago
+91-30

Summary

Complete ADR 0041 credential admission on 0.22 (#5182), which already includes refusal through #5191. This four-file port checks the Metro companion's environment before registration, awaits default proxy admission before preparing upstream credentials, and masks the configured origin in public errors. The 0.21.x warning remains on its release line.

Before / after

  • Metro companion startup now checks admission using the worker's own environment before bridge registration.
  • The default proxy now refuses before building upstream credentials. /health retains HTTP 400, INVALID_ARGS, the nested details.reason, and the hint. The public message masks the configured origin. /rpc applies the same masking within its existing JSON-RPC envelope.

Validation

At dddd87b9c34714daaa0d1ae000704abbe070144a, all 16 focused tests passed in daemon-proxy-credential-transport.test.ts and client-companion-tunnel-worker.test.ts. Focused oxlint and oxfmt passed for daemon-proxy.ts. The earlier CI job rejected the proxy file at 1,001 lines. The follow-up simplifies the default fetch declaration to meet the 1,000-line limit while preserving behavior. Hosted lint passed at that head.

Coverage failed in an inherited daemon-client test. A local probe confirmed that the fixture's released port could be rebound. CI did not establish port reuse. A separate test commit keeps the port bound and closes HTTP requests before responding.

At 1fc668992eb59e0ed611e093f20c78b2d83aecc4, all 13 tests in daemon-client-ensuring.test.ts passed locally with loopback required. Hosted CI and review are pending.