2.5 KiB
Browser discovery and simultaneous server connections
The server adds a bounded discover_servers RPC and local /discovery HTTP
handler using its existing mDNS dependency. Advertisements are validated, sorted
and deduplicated; only valid Pipelines /connect records are returned. The web
front door exposes this as authenticated GET /api/discovery. This searches the
hosting machine's LAN, which can differ from the browser's current network.
For browser federation, authenticated same-origin POST /api/peers/:serverId
accepts {endpoints:[wsURLs],password?:string} and responds with connected,
needs_password, and successful connected_endpoints. It signs into each remote
machine directly, retaining cookies only in proxy memory, scoped to the local
login session, server id and exact registered alias. DELETE revokes that server.
A proxy restart requires signing into remote peers again; remote harness sessions
and background work are independent and are not stopped by this relay.
The browser opens /peers/:serverId/connect?endpoint=<original ws URL> and reads
files/artifacts/updates or uploads through /peers/:serverId/<resource>, using the
same optional endpoint query. These are same-origin paths, so HTTPS browsers can
reach trusted LAN servers without cross-origin cookies or mixed-content sockets.
Local browser cookies and Origin are never forwarded to remote machines; only the
selected peer's exact stored credential is used. No redirects are followed, no
remote Set-Cookie is exposed, and proxying is limited to registered endpoints and
known application resource paths. Mutating registration calls require same Origin
and JSON, and all endpoints remain behind the local login gate.
New local sessions have unique nonce-bearing signed cookies, while existing legacy cookies remain valid. Profile edits revoke previous aliases immediately; registration generations prevent late responses resurrecting deleted profiles. Failed reauthentication to an unchanged profile preserves its existing cookie and websocket. Expired owner records close their sockets and are pruned before limits.
Verification: all 13 Node tests passed, including isolated real HTTP/WS peers, per-browser and per-server cookie isolation, scoped files and websocket routing, authenticated discovery, revocation races, failed sign-in preservation, and owner expiry cleanup. Go discovery/protocol/server tests and focused vet passed. All fixtures used loopback/scratch state; no operator sessions, passwords, deployments or workflows were changed. Parent owns Flutter integration and delivery.