import { type Dispatcher } from 'undici'; import { NetworkError } from './types'; import type { TrueConfAccountConfig, TrueConfResponse, TrueConfRequest, OAuthTokenResponse, Logger } from './types'; export declare function hostPort(config: { serverUrl: string; useTls: boolean; port?: number; }): string; export declare function buildWsUrl(config: TrueConfAccountConfig): string; export declare function buildTokenUrl(config: TrueConfAccountConfig): string; export declare function acquireToken(config: TrueConfAccountConfig, options?: { dispatcher?: Dispatcher; }): Promise; export interface WsClientOptions { ca?: Buffer; tlsVerify?: boolean; forceReconnect?: (reason: string) => Promise; } export declare class WsClient { private ws; private idCounter; private matcher; private progressHandlers; botUserId: string | null; onInboundMessage: ((msg: TrueConfRequest) => void | Promise) | null; onClose: ((code: number, reason: string) => void) | null; onPong: (() => void) | null; logger: Logger | null; ca: Buffer | undefined; tlsVerify: boolean; private pushListeners; private authListeners; private readonly forceReconnect?; private authBarrier; constructor(options?: WsClientOptions); buildClientOptions(): { rejectUnauthorized: false; } | { ca: Buffer; } | undefined; onFileProgress(fileId: string, handler: (progress: number) => void): void; offFileProgress(fileId: string): void; onPush(listener: (method: string, payload: Record) => void): () => void; onAuth(listener: () => void): () => void; private makeDeferred; resetAuthBarrier(reason?: string): void; markAuthenticated(): void; markAuthFailed(err: Error): void; waitAuthenticated(timeoutMs?: number): Promise; connect(config: TrueConfAccountConfig, token: string): Promise; sendRequest(method: string, payload: Record, traceId?: string): Promise; private sendRequestInternal; send(msg: object): void; close(): void; ping(): void; terminate(): void; } export type TerminalCause = { kind: 'shutdown'; cause: Error; } | { kind: 'dns_exhausted'; retries: number; cause: NetworkError; } | { kind: 'auth_exhausted'; retries: number; cause: NetworkError; }; interface LifecycleOptions { onConnectionClosed?: (code: number, reason: string) => void; onConnected?: () => void; onDisconnected?: () => void; onTerminalFailure?: (terminal: TerminalCause) => void; } export declare class ConnectionLifecycle { private wsClient; private config; private logger; private options?; private heartbeatTimer; private tokenRefreshTimer; private reconnectTimer; private lastPingAt; private lastPongAt; private backoffMs; private shuttingDown; private reconnecting; private startInFlight; private dnsRetryCount; private oauthFailCount; private reconnectInflight; private suppressNextCloseReconnect; constructor(wsClient: WsClient, config: TrueConfAccountConfig, logger: Logger, options?: (LifecycleOptions & { dispatcher?: Dispatcher; }) | undefined); start(): Promise; shutdown(): void; forceReconnect(reason: string): Promise; private startTimers; private stopTimers; private handleClose; private heartbeatTick; private escalateDeadConnection; private isDnsError; private isAuthTerminalError; private scheduleReconnect; private cancelReconnect; private refreshAndReconnect; } export {}; //# sourceMappingURL=ws-client.d.ts.map