import { EventEmitter } from "node:events"; import { type AddressedMessageEvent, type CustodyPendingEvent, type DeliveryPendingEvent, type DeliveryStatusEvent, type ObservedSendAckEvent, type StructuredErrorEvent } from "./types.js"; import { type WsHeartbeatOptions } from "./ws-heartbeat.js"; export declare class ConnectorError extends Error { readonly code: string; readonly to?: string; constructor(message: string, code: string, to?: string); } export type SendOutcomeUnknownReason = "ack_timeout" | "connection_closed" | "services_answer_lost"; export declare class SendOutcomeUnknownError extends Error { readonly code: "SEND_OUTCOME_UNKNOWN"; readonly retryable: false; readonly attempts: 1; readonly messageId: string; readonly reason: SendOutcomeUnknownReason; constructor(messageId: string, reason: SendOutcomeUnknownReason); } type ConnectorClientEvents = { message_received: (event: AddressedMessageEvent) => void; custody_pending: (event: CustodyPendingEvent) => void; send_ack: (event: ObservedSendAckEvent) => void; delivery_pending: (event: DeliveryPendingEvent) => void; delivery_status: (event: DeliveryStatusEvent) => void; structured_error: (event: StructuredErrorEvent) => void; error: (error: Error) => void; connected: () => void; disconnected: () => void; }; export interface ConnectorClientOptions { keepalive?: Pick; hostVersion?: string; } export type ChannelState = "connecting" | "connected" | "reconnecting" | "disconnected"; export type RegistrationOutcome = { state: "accepted"; } | { state: "refused"; reason: string; } | { state: "replaced"; } | { state: "none"; }; export declare class ConnectorClient extends EventEmitter { private readonly url; private readonly token; private ws; private intentionalClose; private backoffMs; private alreadyConnectedRetries; private reconnectTimer; private keepalive; private readonly keepaliveOptions; private readonly hostVersion; private registerResolve; private registerReject; private registerTimer; private registration; private everDropped; private lastKnownSeq; private readonly pendingSeqMessages; private readonly seenPayloadIds; private readonly seenPayloadIdOrder; private pendingSends; constructor(url: string, token: string, options?: ConnectorClientOptions); connect(): Promise; disconnect(): void; getChannelState(): ChannelState; getRegistration(): RegistrationOutcome; send(to: string, content: string, contentType?: string, metadata?: Record): Promise; sendTyping(to: string, isTyping: boolean): boolean; ackDelivery(upToSeq: number): boolean; requestGapFill(sinceSeq: number): boolean; on(event: K, listener: ConnectorClientEvents[K]): this; on(event: string | symbol, listener: (...args: unknown[]) => void): this; once(event: K, listener: ConnectorClientEvents[K]): this; once(event: string | symbol, listener: (...args: unknown[]) => void): this; off(event: K, listener: ConnectorClientEvents[K]): this; off(event: string | symbol, listener: (...args: unknown[]) => void): this; emit(event: K, ...args: Parameters): boolean; emit(event: string | symbol, ...args: unknown[]): boolean; private doConnect; private sendRegister; private startRegisterTimeout; private resolveRegister; private rejectRegister; private handleMessage; private dispatchAddressed; private handleAddressedMessage; private handleDeliverySkip; private acceptContiguous; private drainPendingSeqMessagesFrom; private rememberPayloadId; private handleRegisterAck; private handleSendAck; private handleStructuredError; private handleClose; private handleError; private scheduleReconnect; private calculateBackoff; private nextExponentialBackoff; private clearReconnectTimer; private cleanupConnection; private sendEvent; private sendSerializedEvent; } export {}; //# sourceMappingURL=connector-client.d.ts.map