@flatscout/browser-bridge
v1.0.0
Published
Server-side WebSocket bridge that lets a paired Flatscout browser extension proxy HTTPS requests from the user's real Chrome/Firefox session into the Flatscout agent.
Readme
@flatscout/browser-bridge
Server-side WebSocket bridge that lets a paired Flatscout browser extension proxy HTTPS requests from the user's real Chrome/Firefox session into the Flatscout agent.
The point of the bridge: source plugins that target DataDome/Cloudflare-protected hosts (Homegate, ImmoScout24) call BrowserBridgeTransport.request(...); the request is forwarded to the connected extension, which runs fetch() inside a hidden tab loaded at the target's homepage via chrome.scripting.executeScript({ world: 'MAIN' }). The page's own DataDome-hooked window.fetch signs the request, so the upstream sees a legitimate web-app call. The response is shipped back over the WS.
Daemon-only
BrowserBridgeTransport.request() dispatches through an in-process getCurrentBridge() singleton. That means only the process running flatscout start can route requests through the bridge — sibling commands (flatscout scan --source homegate) cannot, even when they see a fresh heartbeat file. Source plugins detect this and fall back to Playwright transparently.
Components
protocol.ts— Zod schemas for the wire format (hello,welcome,reject,request,response,error). SinglePROTOCOL_VERSIONconstant; server + extension must agree.secret.ts— 32-byte random shared secret persisted at${dataDir}/bridge-secret(mode 0600). First file in Flatscout to use this dataDir-secret pattern. Constant-time validation viacrypto.timingSafeEqual.server.ts—startBridgeServer({ dataDir, port })binds awsWebSocketServerto127.0.0.1only (hard-coded; never0.0.0.0), exposesdispatch(req)to source plugins, tracks one connected extension at a time.heartbeat.ts— writes${dataDir}/bridge.status.jsonevery ~5s soflatscout bridge statusandflatscout doctorcan read connection state without opening a second WS client.transport.ts—Transportinterface +BrowserBridgeTransportadapter (same surface asUndiciTransport/PlaywrightTransportin source plugins).
Used by
@flatscout/server— starts the bridge whentop.bridge.enabledis true.@flatscout/cli—flatscout bridge pairprints the pairing URL + token;flatscout bridge statusreads the heartbeat file;flatscout doctorprobes the same file.@flatscout/source-homegate— selectsBrowserBridgeTransportfirst when the bridge is connected.@flatscout/source-immoscout24— paginates IS24 SRP HTML through the bridge and parseswindow.__INITIAL_STATE__for full-detail listings; optional PDP enrichment for contact channels.
License
MIT.
