import { RTCSession } from 'jssip'; /** * A tiny typed event emitter. We ship our own rather than depend on Node's * `events` module so the bundle stays browser-native and dependency-free (beyond * the bundled JsSIP). `Events` maps each event name to its payload type; `void` * marks a payload-less event. */ type Listener = (payload: T) => void; declare class Emitter { private handlers; on(event: K, fn: Listener): this; once(event: K, fn: Listener): this; off(event: K, fn: Listener): this; protected emit(event: K, payload?: Events[K]): void; } /** Public types shared across the SDK. */ type LogLevel = 'none' | 'error' | 'info' | 'debug'; /** * A custom log sink. Receives each emitted line (already filtered by * {@link PhoneOptions.logLevel}) with its level and arguments — `'none'` never * reaches it since nothing is emitted at that level. */ type LogSink = (level: 'error' | 'info' | 'debug', ...args: unknown[]) => void; interface PhoneOptions { /** * Console log verbosity. Defaults to `'none'` — the SDK is silent unless you * opt in. `'error'` \| `'info'` \| `'debug'`, where `'debug'` also turns on * JsSIP's own wire-level tracing. All output goes to the browser DevTools * console, prefixed `[voice-sdk]`; nothing leaves the page. */ logLevel?: LogLevel; /** * Custom log sink. When provided, emitted log lines (still gated by * `logLevel`) are handed to this callback **instead of** the console, so you * can route them into your own UI, log store, or telemetry. JsSIP's own * wire-level trace (at `logLevel: 'debug'`) still goes to the console. */ onLog?: LogSink; /** * WSS endpoint the phone connects to. Must be the platform FQDN (its TLS * cert is issued for the name, not the bare IP). Defaults to production; * override only for testing. */ wssUrl?: string; /** SIP realm / domain. Defaults to the production realm. */ realm?: string; /** * Fallback ICE servers (STUN/TURN). In production the reliable, NAT-crossing * ICE config is delivered per-session in the mint response and passed to * {@link Phone.authenticate}; this option is only a default/override. */ iceServers?: RTCIceServer[]; /** * Max time (ms) to spend gathering ICE candidates before placing/answering a * call. Default 3000. On UDP-restricted networks, unreachable STUN/TURN-UDP * candidates otherwise stall gathering for ~39.5s (RFC 5389) before the call * proceeds; this cap sends the offer/answer with the candidates already * gathered (host + TCP/TLS relay), so calls connect in seconds. On good * networks gathering finishes well within the cap, so it costs nothing. Set to * 0 to disable and always wait for full gathering. */ iceGatheringTimeout?: number; } /** * The credentials the developer's backend obtained from `POST * /api/phone-tokens/mint` and handed to the browser. `authenticate` also accepts * a bare token string when you have no per-session ICE config yet. */ interface AuthCredentials { /** The signed, short-lived phone token (JWT). */ token: string; /** ICE servers for this session (from the mint response). */ iceServers?: RTCIceServer[]; } interface CallOptions { /** * Opaque developer metadata echoed back on every platform event for this * call. Max 500 characters (platform limit). Sent as the * `X-Sauti-Custom-Payload` INVITE header. */ customPayload?: string; } /** Claims carried by a phone token (decoded locally, signature NOT verified). */ interface TokenClaims { /** SIP extension this token is scoped to. */ sub: string; /** Account uuid. */ acc: string; /** End-user uuid. */ eu?: string; /** Max concurrent calls. */ mc?: number; exp?: number; iat?: number; typ?: string; } interface MediaDevices { inputs: MediaDeviceInfo[]; outputs: MediaDeviceInfo[]; } /** Structured reason attached to `ended` / `failed` / `registrationFailed`. */ interface FailureReason { /** JsSIP's coarse cause string (e.g. `'Rejected'`, `'Canceled'`). */ cause?: string; /** SIP status code, when the failure carried a response. */ statusCode?: number; /** SIP reason phrase, when present. */ reason?: string; } declare class Logger { private sink?; private threshold; constructor(level?: LogLevel, sink?: LogSink | undefined); setLevel(level: LogLevel): void; private write; error(...args: unknown[]): void; info(...args: unknown[]): void; debug(...args: unknown[]): void; } /** * Owns the single hidden `