/** * Upstream WebSocket client for the proxy's renderer bridge. * * `new WebSocket(url)` cannot set request headers, so the bridge used to move * the tenant identity into the query string -- where the renderer, correctly, * refuses to read it. This client speaks the same handshake through * `WebSocketStream`, which does accept headers, so the bridge hop can carry the * exact identity headers every other proxied request carries. * * The surface is deliberately `WebSocket`-shaped (`readyState`, `send`, * `close`, `onopen`/`onmessage`/`onerror`/`onclose` receiving real DOM events) * so the bridge wiring in `main.ts` is unchanged by the transport swap. * * @module proxy/websocket-client */ export interface UpstreamWebSocketConnection { readonly readable: ReadableStream; readonly writable: WritableStream; } /** The subset of `WebSocketStream` this client depends on. */ export interface UpstreamWebSocketStream { readonly opened: Promise; readonly closed: Promise<{ closeCode?: number; reason?: string; }>; close(closeInfo?: { closeCode?: number; reason?: string; }): void; } export type UpstreamWebSocketStreamFactory = (url: string, init: { headers: [string, string][]; }) => UpstreamWebSocketStream; /** * Resolve the runtime's `WebSocketStream`. * * Fails loudly rather than falling back to `new WebSocket(url)`: a silent * fallback would drop the identity headers again and reproduce the 502 this * client exists to fix. The proxy binary is compiled with `--unstable-net`. */ export declare function resolveUpstreamWebSocketStreamFactory(): UpstreamWebSocketStreamFactory; /** A `WebSocket`-shaped client that presents request headers on connect. */ export declare class UpstreamWebSocket { #private; onopen: ((event: Event) => void) | null; onmessage: ((event: MessageEvent) => void) | null; onerror: ((event: Event) => void) | null; onclose: ((event: CloseEvent) => void) | null; constructor(url: URL | string, headers: Headers, factory: UpstreamWebSocketStreamFactory); get readyState(): number; send(data: string | ArrayBufferLike | ArrayBufferView | Blob): void; close(code?: number, reason?: string): void; } export declare function connectUpstreamWebSocket(url: URL | string, headers: Headers, factory?: UpstreamWebSocketStreamFactory): UpstreamWebSocket; //# sourceMappingURL=websocket-client.d.ts.map