/** * SOCKETS * ======= * * A websocket handshake cannot carry headers in a browser, so the service and the * credential travel as subprotocols, with the credential falling back to the query * string when it contains characters a subprotocol token cannot hold. * * The global `WebSocket` is used where there is one (browsers, Node 22+). Node * before that gets the `ws` package if it is installed. */ export type SocketHandlers = { onOpen(): void; onMessage(data: string): void; onClose(code: number, reason: string): void; onError(error: unknown): void; }; export type SocketConnection = { send(data: string): void; close(code?: number, reason?: string): void; }; export type SocketFactory = (url: string, protocols: string[], handlers: SocketHandlers) => SocketConnection; export type HandshakeTarget = { url: string; protocols: string[]; }; /** * Builds the websocket URL and subprotocols for a service. * * The credential prefers the subprotocol because a URL ends up in access logs. */ export declare function buildHandshake(serverUrl: string, service: string, apiKey: string): HandshakeTarget; export declare const defaultSocketFactory: SocketFactory;