import type { Server } from 'bun'; /** * Store WebSocket event in the database * Note: This function is now a no-op. WebSocket events are tracked internally by ts-broadcasting. */ export declare function storeWebSocketEvent(_type: 'disconnection' | 'error' | 'success', _socket: string, _details: string): Promise; /** * Install (or clear) the global WebSocket authenticator. Called once * at server boot; pass `null` to disable auth (the unauthed default). */ export declare function setWsAuthenticator(fn: WsAuthenticator | null): void; /** Read the currently-installed authenticator. Useful for tests. */ export declare function getWsAuthenticator(): WsAuthenticator | null; /** * Handle WebSocket request upgrade. If an authenticator is installed * (see `setWsAuthenticator`), it runs FIRST and a 401 is returned on * failure (stacksjs/stacks#1877 R-1). Without an authenticator the * upgrade proceeds for backwards-compat — the function still works * the same way it did before. */ export declare function handleWebSocketRequest(req: Request, server: Server): Promise; /** * Optional authenticator invoked at WebSocket handshake time. * * Apps install one via `setWsAuthenticator(fn)` to require a valid * token / cookie / signed query param BEFORE the upgrade goes through * (stacksjs/stacks#1877 R-1). Without an authenticator, the upgrade * proceeds as before — useful for local-dev / public-broadcast apps, * but production apps should always install one. * * The returned `data` is attached to the upgraded socket as `ws.data` * so per-message authorization can read it back without re-parsing * the auth token on every frame. */ export type WsAuthenticator = (req: Request) => Promise | WsAuthResult; /** Result returned from a `WsAuthenticator`. */ export type WsAuthResult = | { ok: true, data?: Record } | { ok: false, status?: number, message?: string }