import { PerfectWS } from '../../PerfectWS.js'; import { WebSocketForce, WSLike } from '../../utils/WebSocketForce.js'; export type RemoteClientOptions = { password?: string; id?: string; verbose?: boolean; webSocketConstructor?: new (url: string) => 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 server closed the connection because of a * wrong password or the password rate limit. Defaults to the server's default * rate-limit window split across its allowed attempts (`windowMs / maxAttempts`, * plus a small margin) - if the server'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; } & ({ wsServer: WSLike; } | { url: string; }); export type InitializeRemoteClient = { ws: WebSocketForce; serverId: string; }; type RouterFor = ReturnType['router']; export declare class RemoteClient { private _options; private readonly _client; private _serverId?; private _wsServer?; private _activeAttemptWs?; private _loopAbortController?; private _on; get serverId(): string | undefined; constructor(_options: RemoteClientOptions); get router(): RouterFor; start(): void; private _connectionLoop; private _getWSServer; private _internalInitializeMethods; /** * Extra method we want to expose the server could initialize on the client side state. * This is a simple PerfectWS router - does not use the perfectWSConstructor for internal initialization. */ protected initializeMethods(router: ReturnType['router'], options: InitializeRemoteClient): any | Promise; stop(): void; } export {};