import { PerfectWS } from '../../PerfectWS.js'; import { WebSocketForce, WSLike } from '../../utils/WebSocketForce.js'; export type RemoteServerOptions = { password?: string; id?: string; verbose?: boolean; webSocketConstructor?: new (url: string | URL) => WSLike; debugging?: boolean; /** * Logs auth handshake lifecycle events (connecting, connected, rejected, * disconnected, unusual throws) - the same lines `verbose` prints for these * events, without enabling verbose's full per-request tracing. Defaults to * following `debugging`; set explicitly to override that. `verbose: true` * always forces this on regardless, since these events are a subset of what * verbose already logs. */ logAuthFlow?: boolean; autoReconnect?: boolean; /** Delay before retrying a connection that closed for a reason other than a * password rejection. Defaults to 3s. */ delayBeforeReconnect?: number; /** * Delay before retrying after the host closed the connection because of a wrong * password or the password rate limit. Defaults to the host's default rate-limit * window split across its allowed attempts (`windowMs / maxAttempts`, plus a * small margin) - if the host's `passwordRateLimit` is customized, set this to * match (`windowMs / maxAttempts` + a small safety margin). */ passwordFailureDelay?: number; /** Enables PureRPC. Both peers must explicitly use PerfectWSAdvanced and opt in. */ fullTrustedRPC?: boolean; /** Protocol implementation for the persistent router. Defaults to the BSON-only PerfectWS. */ perfectWSConstructor?: Constructor; }; export type InitializeRemoteServer = { ws: WebSocketForce; clientId: string; }; type RouterFor = ReturnType['router']; export declare class RemoteServer { private _options; private readonly _server; private _on; private _unregisterFns; clients: Map; constructor(_options?: RemoteServerOptions); get router(): RouterFor; private _start; /** * Attach a client to this remote server. This will initialize the connection and allow the client to communicate with the server. * @param ws The WebSocket or URL to attach to the server. If a WebSocket is provided, auto-reconnect will not be enabled. * @returns A function to unregister the client from the server. */ attachClient(ws: WSLike | string | URL, password?: string | undefined): Promise<() => void>; private _getWSClient; private _internalInitializeMethods; /** * Extra method we want to expose the client could initialize on the server state. * This is a simple PerfectWS router - does not use the perfectWSConstructor for internal initialization. */ protected initializeMethods(router: ReturnType['router'], options: InitializeRemoteServer): any | Promise; stop(): void; } export {};