import { ToolDb, ToolDbNetworkAdapter } from "tool-db"; export default class toolDbWebrtc extends ToolDbNetworkAdapter { private wnd; private wss; private sockets; private socketListeners; private peerMap; private connectedPeers; private socketRetryPeriods; private reconnectionPaused; private pendingReconnections; private nostrSecretKey; private nostrPublicKey; private nostrPubkeyHex; private nostrRelays; private nostrRelayUrls; private nostrSubscriptionIds; private nostrKind; private nostrTopic; private nostrPendingOffers; private onDisconnect; private peersCheck; private isPeerDisconnected; private announceInterval; private peersCheckInterval; private handleOnline; private handleOffline; /** * Initialize Nostr keypair for signing events */ private initNostrKeys; /** * Get the Nostr event kind based on topic */ private getNostrKind; /** * Create and sign a Nostr event */ private createNostrEvent; /** * Create a Nostr subscription request */ private createNostrSubscription; /** * Create a Nostr unsubscribe request */ private createNostrUnsubscribe; /** * Connect to a Nostr relay */ private connectNostrRelay; /** * Handle incoming Nostr messages */ private onNostrMessage; /** * Send an offer to a specific peer via Nostr */ private sendNostrOffer; /** * Handle an incoming Nostr offer */ private handleNostrOffer; /** * Handle an incoming Nostr answer */ private handleNostrAnswer; /** * Announce ourselves to a Nostr relay */ private announceToNostr; /** * Announce to all Nostr relays */ private announceToAllNostrRelays; /** * Initialize webrtc peer with proper ICE configuration */ private initPeer; private handledOffers; private offerPool; private trackerUrls; private infoHash; /** * Make connection offers (sdp) to send to the tracker */ private makeOffers; /** * When we successfully connect to a webrtc peer */ private onPeerConnect; /** * Handle the webrtc peer connection */ private onConnect; /** * Clean the announce offers pool - also removes stale offers */ private cleanPool; /** * Makes a websocket connection to a tracker with exponential backoff reconnection */ private makeSocket; /** * Reconnect to a socket with exponential backoff */ private reconnectSocket; /** * Schedule a reconnection with exponential backoff */ private scheduleReconnect; /** * Announce ourselves to a tracker (send "announce") */ private announce; /** * Announce ourselves to all trackers and Nostr relays */ private announceAll; /** * Handle the tracker messages */ private onSocketMessage; /** * Leave the tracker and Nostr relays */ onLeave: () => Promise; constructor(db: ToolDb); close(clientId: string): void; }