/** * WebRTC ICE helpers matching Android Carrier WebrtcClient.getIceServers() / * CarrierExtension.getTurnServerInfo() (carrier_get_turn_server). * * Online Android Beagle gathers STUN+TURN against a Carrier bootstrap node's * coturn (UDP/3478) using Carrier long-term credentials. Browser / Node WebRTC * stacks need the same list — not the tokyo.fi.chat static relay used only as * a fallback for the peer SDK's own messaging UDP relay path. */ import { CARRIER_TURN_PORT, CARRIER_TURN_REALM } from "./turn-creds.js"; import type { NetworkNode } from "./types/peer.js"; /** Same shape as Android CarrierExtension.TurnServerInfo / CarrierTurnServer. */ export interface CarrierTurnServerInfo { server: string; port: number; username: string; password: string; realm: string; } /** Browser / wrtc RTCIceServer-compatible entry. */ export interface RtcIceServer { urls: string | string[]; username?: string; credential?: string; } export interface BuildIceServersOptions { /** Bootstrap / bootnodes that run Carrier TURN on port 3478. */ bootstrapNodes: NetworkNode[]; ourUserid: string; ourSecretKey: Uint8Array; /** * How many bootstrap TURNs to advertise. Android returns one; browsers often * benefit from a few (default 3). Cap with this. */ limit?: number; /** Also advertise turn:?transport=tcp (useful for UDP-blocked browsers). */ includeTcpTurn?: boolean; } /** * Derive TURN info for one bootnode — peer analogue of * carrier_get_turn_server / CarrierExtension.getTurnServerInfo(). */ export declare function getTurnServerInfoForBootnode(opts: { bootnode: NetworkNode; ourUserid: string; ourSecretKey: Uint8Array; }): CarrierTurnServerInfo; /** * Build RTCIceServer entries from TURN info the way Android WebrtcClient does: * stun:host:port + turn:host:port with the same username/password. */ export declare function iceServersFromTurnInfo(info: CarrierTurnServerInfo, opts?: { includeTcpTurn?: boolean; }): RtcIceServer[]; /** * Build a WebRTC iceServers list from Carrier bootstrap nodes. * Fresh nonce/credentials on every call (same as Android). */ export declare function getIceServers(opts: BuildIceServersOptions): RtcIceServer[]; export { CARRIER_TURN_PORT, CARRIER_TURN_REALM };