import { BridgeConnection } from './bridge-connection.cjs'; import { WebSocketClient } from './websocket.cjs'; import { KeyPair, FailedToConnectEvent, BridgeDisconnectedEvent } from './types.cjs'; import 'ws'; /** * Options for creating a bridge */ interface CreateOptions { origin?: string; bridgeId?: string; keyPair?: KeyPair; resume?: boolean; remotePublicKey?: Uint8Array; autoconnect?: boolean; reconnect?: boolean; keepalive?: boolean; debug?: boolean; pingInterval?: number; bridgeUrl?: string; } /** * Options for joining a bridge */ interface JoinOptions { keyPair?: KeyPair; resume?: boolean; reconnect?: boolean; keepalive?: boolean; debug?: boolean; pingInterval?: number; bridgeUrl?: string; } /** * Functional bridge interface returned by create() and join() */ interface BridgeInterface extends Disposable { websocket: WebSocketClient | undefined; connection: BridgeConnection; onConnect: (callback: (reconnection: boolean) => void) => () => void; onFailedToConnect: (callback: (event: FailedToConnectEvent) => void) => () => void; onSecureChannelEstablished: (callback: () => void) => () => void; onRawMessage: (callback: (message: any) => void) => () => void; onSecureMessage: (callback: (message: any) => void) => () => void; onError: (callback: (error: string) => void) => () => void; onDisconnect: (callback: (event: BridgeDisconnectedEvent) => void) => () => void; isBridgeConnected: () => boolean; isSecureChannelEstablished: () => boolean; sendMessage: (method: string, params?: any) => Promise; connectionString: string; origin: string; bridgeId: string; getPublicKey: () => string; getRemotePublicKey: () => string; getKeyPair: () => KeyPair; close: () => void; cleanup: () => void; } /** * Main Bridge class - provides static methods for creating and joining bridges */ declare class Bridge { /** * Create a new bridge connection as the creator * @param options Options for creating a bridge * @returns A promise that resolves to a functional bridge interface */ static create(options?: CreateOptions): Promise; /** * Join an existing bridge connection as the joiner * @param uri The connection string from the creator * @param options Options for joining a bridge * @returns A promise that resolves to a functional bridge interface */ static join(uri: string, options?: JoinOptions): Promise; private static parseConnectionString; /** * Generate a new ECDH key pair * @returns A promise that resolves to a key pair */ static generateKeyPair(): Promise; } export { Bridge, type BridgeInterface, type CreateOptions, type JoinOptions };