@signalwire/js 4.0.0-dev-20260318145605 → 4.0.0-dev-20260326210326

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as JSONRPCSuccessResponse, i as JSONRPCResponse, n as JSONRPCErrorResponse, r as JSONRPCRequest, t as EventChannel } from "./base-BxFSgMTI.cjs";
1
+ import { a as JSONRPCSuccessResponse, i as JSONRPCResponse, n as JSONRPCErrorResponse, r as JSONRPCRequest, t as EventChannel } from "./base-Cif20s3C.cjs";
2
2
  import * as rxjs0 from "rxjs";
3
3
  import { BehaviorSubject, Observable, Observer, ReplaySubject, Subject, Subscription } from "rxjs";
4
4
  import { URL as URL$1 } from "node:url";
@@ -11,6 +11,29 @@ declare abstract class Destroyable {
11
11
  private _observableCache?;
12
12
  destroy(): void;
13
13
  protected cachedObservable<T>(key: string, factory: () => Observable<T>): Observable<T>;
14
+ /**
15
+ * Like `cachedObservable`, but defers emissions to the microtask queue
16
+ * via `observeOn(asapScheduler)`.
17
+ *
18
+ * Use ONLY for public-facing observable getters that external consumers
19
+ * subscribe to. Prevents a class of bugs where `BehaviorSubject` or
20
+ * `ReplaySubject` replays synchronously during `subscribe()`, before
21
+ * the subscription variable is assigned in the caller's scope.
22
+ *
23
+ * Do NOT use for observables consumed internally by the SDK — internal
24
+ * code using `subscribeTo()`, `firstValueFrom()`, or `withLatestFrom()`
25
+ * depends on synchronous emission delivery.
26
+ */
27
+ protected publicCachedObservable<T>(key: string, factory: () => Observable<T>): Observable<T>;
28
+ /**
29
+ * Wraps an observable so emissions are deferred to the microtask queue.
30
+ *
31
+ * Use ONLY for public-facing getters that expose a subject via
32
+ * `.asObservable()` without going through `cachedObservable`.
33
+ *
34
+ * Do NOT use for observables consumed internally by the SDK.
35
+ */
36
+ protected deferEmission<T>(observable: Observable<T>): Observable<T>;
14
37
  protected subscribeTo<T>(observable: Observable<T>, observerOrNext: Partial<Observer<T>> | ((value: T) => void) | undefined): void;
15
38
  protected createSubject<T>(): Subject<T>;
16
39
  protected createReplaySubject<T>(bufferSize?: number, windowTime?: number): ReplaySubject<T>;
@@ -34,9 +57,9 @@ interface MediaDirections {
34
57
  }
35
58
  /** Options controlling which media tracks to send and receive. */
36
59
  interface MediaOptions {
37
- /** Enable audio input. */
60
+ /** Enable audio input. Defaults to `true` when not specified. */
38
61
  audio?: boolean;
39
- /** Enable video input. */
62
+ /** Enable video input. Defaults to `false` when not specified. */
40
63
  video?: boolean;
41
64
  /** Custom constraints for the audio input track. */
42
65
  inputAudioDeviceConstraints?: MediaTrackConstraints;
@@ -53,6 +76,7 @@ interface MediaOptions {
53
76
  }
54
77
  //#endregion
55
78
  //#region src/core/types/common.types.d.ts
79
+ /** JSON-compatible value type for serializable data structures. */
56
80
  interface JSONSerializable {
57
81
  [key: string]: JSONSerializable | string | number | boolean | null | undefined | JSONSerializable[];
58
82
  }
@@ -101,6 +125,7 @@ interface HTTPResponse<T extends HttpBody = string> {
101
125
  /** Final URL after any redirects */
102
126
  url: string;
103
127
  }
128
+ /** Browser-compatible WebSocket client interface. */
104
129
  interface WebSocketClient {
105
130
  addEventListener: WebSocket['addEventListener'];
106
131
  removeEventListener: WebSocket['removeEventListener'];
@@ -108,6 +133,7 @@ interface WebSocketClient {
108
133
  close: WebSocket['close'];
109
134
  readyState: WebSocket['readyState'];
110
135
  }
136
+ /** Node.js WebSocket client interface with event listener overloads. */
111
137
  interface NodeSocketClient extends WebSocketClient {
112
138
  addEventListener(method: 'open' | 'close' | 'error' | 'message', cb: (event: unknown) => void, options?: unknown): void;
113
139
  removeEventListener(method: 'open' | 'close' | 'error' | 'message', cb: (event: unknown) => void): void;
@@ -124,20 +150,26 @@ interface NodeSocketAdapter {
124
150
  }
125
151
  /** Browser-compatible WebSocket constructor type. */
126
152
  type WebSocketAdapter = new (url: string | URL, protocols?: string | string[]) => WebSocketClient;
127
- /** Authentication credentials for the SDK. */
153
+ /**
154
+ * Authentication credentials for the SDK.
155
+ *
156
+ * At least one of `token` or `authorizationState` must be provided.
157
+ */
128
158
  interface SDKCredential {
129
- /** JWT subscriber access token. */
159
+ /** JWT subscriber access token (SAT). */
130
160
  token?: string;
131
161
  /** Pre-authorized session state (alternative to token). */
132
162
  authorizationState?: string;
133
- /** Token expiry timestamp in milliseconds since epoch. */
163
+ /** Token expiry timestamp in milliseconds since epoch. When set, the SDK attempts credential refresh before expiry. */
134
164
  expiry_at?: number;
135
165
  }
136
166
  /** Types of addressable resources in the fabric. */
137
167
  type ResourceType = 'app' | 'call' | 'room' | 'subscriber';
138
168
  //#endregion
139
169
  //#region src/dependencies/interfaces.d.ts
170
+ /** Persistence scope: browser `localStorage` or `sessionStorage`. */
140
171
  type StorageScope = 'local' | 'session';
172
+ /** Key-value storage interface for persisting SDK preferences and state. */
141
173
  interface Storage {
142
174
  setItem(key: string, value: string | null, scope: StorageScope): Promise<void>;
143
175
  getItem(key: string, scope: StorageScope): Promise<string | null>;
@@ -397,40 +429,70 @@ declare abstract class Fetchable<T = unknown> extends Destroyable {
397
429
  * Pure address-related types (no implementation dependencies)
398
430
  * Types that reference model implementations are in interfaces.ts
399
431
  */
432
+ /** Raw address response from the SignalWire Fabric API. */
400
433
  interface GetAddressResponse {
434
+ /** Unique address identifier. */
401
435
  id: string;
436
+ /** Human-readable display name. */
402
437
  display_name: string;
438
+ /** Resource name (used as a URI for dialing). */
403
439
  name: string;
440
+ /** URL for an avatar or preview image. */
404
441
  preview_url?: string;
442
+ /** URL for a cover image. */
405
443
  cover_url?: string;
444
+ /** Underlying resource identifier. */
406
445
  resource_id: string;
446
+ /** Type of the underlying resource. */
407
447
  type: ResourceType;
448
+ /** Available communication channels for this address. */
408
449
  channels: {
450
+ /** Audio-only channel URI. */
409
451
  audio?: string;
452
+ /** Messaging channel URI. */
410
453
  messaging?: string;
454
+ /** Video channel URI. */
411
455
  video?: string;
412
456
  };
457
+ /** Whether the address resource is currently locked. */
413
458
  locked: boolean;
459
+ /** ISO 8601 timestamp when the address was created. */
414
460
  created_at: string;
415
461
  }
416
462
  //#endregion
417
463
  //#region src/core/types/subscriber.types.d.ts
464
+ /** Raw subscriber profile response from the SignalWire Fabric API. */
418
465
  interface GetSubscriberInfoResponse {
466
+ /** Unique subscriber identifier. */
419
467
  id: string;
468
+ /** Subscriber's email address. */
420
469
  email: string;
470
+ /** Subscriber's first name. */
421
471
  first_name?: string;
472
+ /** Subscriber's last name. */
422
473
  last_name?: string;
474
+ /** Subscriber's display name. */
423
475
  display_name?: string;
476
+ /** Subscriber's job title. */
424
477
  job_title?: string;
478
+ /** Subscriber's time zone offset. */
425
479
  time_zone?: number;
480
+ /** Subscriber's country. */
426
481
  country?: string;
482
+ /** Subscriber's region or state. */
427
483
  region?: string;
484
+ /** Subscriber's company name. */
428
485
  company_name?: string;
486
+ /** Key for push notification delivery. */
429
487
  push_notification_key: string;
488
+ /** Application-level settings for this subscriber. */
430
489
  app_settings?: {
490
+ /** Display name configured at the application level. */
431
491
  display_name: string;
492
+ /** Permission scopes granted to this subscriber. */
432
493
  scopes: string[];
433
494
  };
495
+ /** Fabric addresses associated with this subscriber. */
434
496
  fabric_addresses: GetAddressResponse[];
435
497
  }
436
498
  //#endregion
@@ -476,32 +538,63 @@ declare class Subscriber extends Fetchable<GetSubscriberInfoResponse> {
476
538
  }
477
539
  //#endregion
478
540
  //#region src/core/types/call.types.d.ts
541
+ /** SDP role for the peer connection negotiation. */
479
542
  type RTCPeerConnectionType = 'offer' | 'answer';
543
+ /** Purpose of the peer connection (primary call, screen share, or additional device). */
480
544
  type RTCPeerConnectionPropose = 'main' | 'screenshare' | 'additional-device';
545
+ /** States during call connection establishment. */
481
546
  type CallConnectStates = 'connecting' | 'connected';
547
+ /** Lifecycle states of the signaling protocol for a call. */
482
548
  type SignalingCallStates = 'created' | 'ringing' | 'answered' | 'ending' | 'ended';
549
+ /** Whether the call is inbound (received) or outbound (initiated). */
483
550
  type CallDirection = 'inbound' | 'outbound';
551
+ /** Playback state of media being played into a call. */
484
552
  type CallPlayState = 'playing' | 'paused' | 'finished';
553
+ /** Common parameters shared by all call device types. */
485
554
  interface CallDeviceCommonParams {
555
+ /** Optional SIP headers to include in the call setup. */
486
556
  headers?: unknown[];
487
557
  }
558
+ /** Parameters for a WebRTC or SIP call device. */
488
559
  interface CallDeviceWebRTCOrSIPParams extends CallDeviceCommonParams {
560
+ /** Source address or URI for the call. */
489
561
  from: string;
562
+ /** Destination address or URI for the call. */
490
563
  to: string;
491
564
  }
565
+ /** Parameters for a phone (PSTN) call device. */
492
566
  interface CallDevicePhoneParams extends CallDeviceCommonParams {
567
+ /** Caller phone number (E.164 format). */
493
568
  from_number: string;
569
+ /** Destination phone number (E.164 format). */
494
570
  to_number: string;
495
571
  }
572
+ /** A WebRTC or SIP call device descriptor. */
496
573
  interface CallDeviceWebRTCOrSIP {
574
+ /** Transport type for the device. */
497
575
  type: 'webrtc' | 'sip';
576
+ /** Connection parameters for the device. */
498
577
  params: CallDeviceWebRTCOrSIPParams;
499
578
  }
579
+ /** A phone (PSTN) call device descriptor. */
500
580
  interface CallDevicePhone {
581
+ /** Transport type for the device. */
501
582
  type: 'phone';
583
+ /** Connection parameters for the device. */
502
584
  params: CallDevicePhoneParams;
503
585
  }
586
+ /** Discriminated union of call device types (WebRTC, SIP, or phone). */
504
587
  type CallDevice = CallDeviceWebRTCOrSIP | CallDevicePhone;
588
+ /**
589
+ * Position of a participant's video within the layout canvas.
590
+ *
591
+ * - `'auto'` — Automatically positioned by the layout engine.
592
+ * - `` `reserved-${number}` `` — A reserved slot in the layout (e.g., `'reserved-0'`).
593
+ * - `` `standard-${number}` `` — A standard slot in the layout (e.g., `'standard-1'`).
594
+ * - `'off-canvas'` — Participant is not visible in the layout.
595
+ * - `'playback'` — Playback position for media streams.
596
+ * - `'full-screen'` — Participant occupies the entire canvas.
597
+ */
505
598
  type VideoPosition = 'auto' | `reserved-${number}` | `standard-${number}` | 'off-canvas' | 'playback' | 'full-screen';
506
599
  //#endregion
507
600
  //#region src/core/RPCMessages/types/common.d.ts
@@ -978,38 +1071,84 @@ declare class SelfCapabilities extends Destroyable {
978
1071
  }
979
1072
  //#endregion
980
1073
  //#region src/core/entities/types/participant.types.d.ts
1074
+ /** Options for selecting a media device. */
981
1075
  interface SelectDeviceOptions {
982
1076
  savePreference?: boolean;
983
1077
  }
984
1078
  //#endregion
985
1079
  //#region src/interfaces/DeviceController.d.ts
986
1080
  /**
987
- * Device interface for media device management
988
- * Provides access to media devices and device selection
1081
+ * Interface for media device management.
1082
+ *
1083
+ * Provides reactive access to available media devices, device selection,
1084
+ * and monitoring for device changes (connect/disconnect).
989
1085
  */
990
1086
  interface DeviceController {
1087
+ /** Observable list of available audio input (microphone) devices. */
991
1088
  readonly audioInputDevices$: Observable<MediaDeviceInfo[]>;
1089
+ /** Observable list of available audio output (speaker) devices. */
992
1090
  readonly audioOutputDevices$: Observable<MediaDeviceInfo[]>;
1091
+ /** Observable list of available video input (camera) devices. */
993
1092
  readonly videoInputDevices$: Observable<MediaDeviceInfo[]>;
1093
+ /** Observable of the currently selected audio input device, or `null` if none. */
994
1094
  readonly selectedAudioInputDevice$: Observable<MediaDeviceInfo | null>;
1095
+ /** Observable of the currently selected audio output device, or `null` if none. */
995
1096
  readonly selectedAudioOutputDevice$: Observable<MediaDeviceInfo | null>;
1097
+ /** Observable of the currently selected video input device, or `null` if none. */
996
1098
  readonly selectedVideoInputDevice$: Observable<MediaDeviceInfo | null>;
1099
+ /** Currently selected audio input device, or `null` if none. */
997
1100
  readonly selectedAudioInputDevice: MediaDeviceInfo | null;
1101
+ /** Currently selected audio output device, or `null` if none. */
998
1102
  readonly selectedAudioOutputDevice: MediaDeviceInfo | null;
1103
+ /** Currently selected video input device, or `null` if none. */
999
1104
  readonly selectedVideoInputDevice: MediaDeviceInfo | null;
1105
+ /** Current snapshot of available audio input devices. */
1000
1106
  readonly audioInputDevices: MediaDeviceInfo[];
1107
+ /** Current snapshot of available audio output devices. */
1001
1108
  readonly audioOutputDevices: MediaDeviceInfo[];
1109
+ /** Current snapshot of available video input devices. */
1002
1110
  readonly videoInputDevices: MediaDeviceInfo[];
1111
+ /** Media track constraints for the selected audio input device. */
1003
1112
  readonly selectedAudioInputDeviceConstraints: MediaTrackConstraints;
1113
+ /** Media track constraints for the selected video input device. */
1004
1114
  readonly selectedVideoInputDeviceConstraints: MediaTrackConstraints;
1115
+ /**
1116
+ * Converts a {@link MediaDeviceInfo} to track constraints suitable for `getUserMedia`.
1117
+ * @param deviceInfo - The device to convert, or `null` for default constraints.
1118
+ */
1005
1119
  deviceInfoToConstraints(deviceInfo: MediaDeviceInfo | null): MediaTrackConstraints;
1120
+ /**
1121
+ * Sets the preferred audio input device for future calls.
1122
+ * @param device - The device to select, or `null` to use the system default.
1123
+ */
1006
1124
  selectAudioInputDevice(device: MediaDeviceInfo | null): void;
1125
+ /**
1126
+ * Sets the preferred video input device for future calls.
1127
+ * @param device - The device to select, or `null` to use the system default.
1128
+ */
1007
1129
  selectVideoInputDevice(device: MediaDeviceInfo | null): void;
1130
+ /**
1131
+ * Sets the preferred audio output device for future calls.
1132
+ * @param device - The device to select, or `null` to use the system default.
1133
+ */
1008
1134
  selectAudioOutputDevice(device: MediaDeviceInfo | null): void;
1135
+ /** Starts monitoring for media device changes (connect/disconnect). */
1009
1136
  enableDeviceMonitoring(): void;
1137
+ /** Stops monitoring for media device changes. */
1010
1138
  disableDeviceMonitoring(): void;
1139
+ /**
1140
+ * Returns the capabilities of a media device.
1141
+ * @param deviceInfo - The device to query.
1142
+ * @returns The device capabilities, or `null` if unavailable.
1143
+ */
1011
1144
  getDeviceCapabilities(deviceInfo: MediaDeviceInfo): Promise<MediaTrackCapabilities | null>;
1145
+ /**
1146
+ * Checks whether a device is still available and usable.
1147
+ * @param deviceInfo - The device to validate, or `null`.
1148
+ * @returns `true` if the device is valid and available. Returns `false` for `null`, audio output devices, or unavailable devices.
1149
+ */
1012
1150
  isValidDevice(deviceInfo: MediaDeviceInfo | null): Promise<boolean>;
1151
+ /** Observable stream of errors from device enumeration and monitoring. */
1013
1152
  readonly errors$: Observable<Error>;
1014
1153
  }
1015
1154
  //#endregion
@@ -1113,22 +1252,39 @@ declare class Participant extends Destroyable implements CallParticipant {
1113
1252
  get name(): string | undefined;
1114
1253
  /** Participant type (e.g. `'member'`, `'screen'`). */
1115
1254
  get type(): string | undefined;
1255
+ /** Whether the participant has raised their hand. */
1116
1256
  get handraised(): boolean;
1257
+ /** Whether the participant is visible in the layout. */
1117
1258
  get visible(): boolean;
1259
+ /** Whether the participant's audio is muted. */
1118
1260
  get audioMuted(): boolean;
1261
+ /** Whether the participant's video is muted. */
1119
1262
  get videoMuted(): boolean;
1263
+ /** Whether the participant is deafened (incoming audio muted). */
1120
1264
  get deaf(): boolean;
1265
+ /** Current microphone input volume level, or `undefined` if not set. */
1121
1266
  get inputVolume(): number | undefined;
1267
+ /** Current speaker output volume level, or `undefined` if not set. */
1122
1268
  get outputVolume(): number | undefined;
1269
+ /** Current microphone input sensitivity level, or `undefined` if not set. */
1123
1270
  get inputSensitivity(): number | undefined;
1271
+ /** Whether echo cancellation is enabled. */
1124
1272
  get echoCancellation(): boolean;
1273
+ /** Whether automatic gain control is enabled. */
1125
1274
  get autoGain(): boolean;
1275
+ /** Whether noise suppression is enabled. */
1126
1276
  get noiseSuppression(): boolean;
1277
+ /** Whether low-bitrate mode is active. */
1127
1278
  get lowbitrate(): boolean;
1279
+ /** Whether noise reduction (denoise) is active. */
1128
1280
  get denoise(): boolean;
1281
+ /** Custom metadata for this participant, or `undefined` if not set. */
1129
1282
  get meta(): Record<string, unknown> | undefined;
1283
+ /** Subscriber ID of this participant, or `undefined` if not available. */
1130
1284
  get subscriberId(): string | undefined;
1285
+ /** Address ID of this participant, or `undefined` if not available. */
1131
1286
  get addressId(): string | undefined;
1287
+ /** Server node ID for this participant, or `undefined` if not available. */
1132
1288
  get nodeId(): string | undefined;
1133
1289
  /** @internal */
1134
1290
  get value(): Partial<Member>;
@@ -1157,18 +1313,38 @@ declare class Participant extends Destroyable implements CallParticipant {
1157
1313
  toggleLowbitrate(): Promise<void>;
1158
1314
  /** Sets the microphone input sensitivity level. */
1159
1315
  setAudioInputSensitivity(value: number): Promise<void>;
1160
- /** Sets the microphone input volume level. */
1316
+ /**
1317
+ * Sets the microphone input volume level.
1318
+ * @param value - Volume level (0-100).
1319
+ */
1161
1320
  setAudioInputVolume(value: number): Promise<void>;
1162
- /** Sets the speaker output volume level. */
1321
+ /**
1322
+ * Sets the speaker output volume level.
1323
+ * @param value - Volume level (0-100).
1324
+ */
1163
1325
  setAudioOutputVolume(value: number): Promise<void>;
1164
- /** Sets the participant's position in the video layout. */
1326
+ /**
1327
+ * Sets the participant's position in the video layout.
1328
+ * @param value - The {@link VideoPosition} to assign (e.g. `'auto'`, `'reserved-0'`).
1329
+ */
1165
1330
  setPosition(value: VideoPosition): Promise<void>;
1166
1331
  /** Removes this participant from the call. */
1167
1332
  remove(): Promise<void>;
1168
1333
  /** Ends the call for this participant. */
1169
1334
  end(): Promise<void>;
1335
+ /**
1336
+ * Replaces custom metadata for this participant.
1337
+ * @param _meta - Metadata object to set.
1338
+ * @throws {UnimplementedError} Not yet implemented.
1339
+ */
1170
1340
  setMeta(_meta: Record<string, unknown>): Promise<void>;
1341
+ /**
1342
+ * Merges values into custom metadata (unlike {@link setMeta} which replaces).
1343
+ * @param _meta - Metadata to merge.
1344
+ * @throws {UnimplementedError} Not yet implemented.
1345
+ */
1171
1346
  updateMeta(_meta: Record<string, unknown>): Promise<void>;
1347
+ /** Destroys the participant, releasing all subscriptions and references. */
1172
1348
  destroy(): void;
1173
1349
  }
1174
1350
  /**
@@ -1184,6 +1360,7 @@ declare class SelfParticipant extends Participant implements CallSelfParticipant
1184
1360
  * Contains all capability flags as both observables and values.
1185
1361
  */
1186
1362
  readonly capabilities: SelfCapabilities;
1363
+ /** @internal */
1187
1364
  constructor(id: string, executeMethod: ExecuteMethod, vertoManager: VertoManager, deviceController: DeviceController);
1188
1365
  destroy(): void;
1189
1366
  /** Starts sharing the local screen. */
@@ -1231,9 +1408,13 @@ declare class SelfParticipant extends Participant implements CallSelfParticipant
1231
1408
  setVideoInputDeviceConstraints(constraints: MediaTrackConstraints): Promise<void>;
1232
1409
  /** Selects the audio output device. Optionally saves as a preference. */
1233
1410
  selectAudioOutputDevice(device: MediaDeviceInfo, options?: SelectDeviceOptions): void;
1411
+ /** Mutes local audio. Falls back to local device mute if the server RPC fails. */
1234
1412
  mute(): Promise<void>;
1413
+ /** Unmutes local audio. Falls back to local device unmute if the server RPC fails. */
1235
1414
  unmute(): Promise<void>;
1415
+ /** Mutes local video. Falls back to local device mute if the server RPC fails. */
1236
1416
  muteVideo(): Promise<void>;
1417
+ /** Unmutes local video. Falls back to local device unmute if the server RPC fails. */
1237
1418
  unmuteVideo(): Promise<void>;
1238
1419
  }
1239
1420
  /** Type guard that checks if a participant is the local {@link SelfParticipant}. */
@@ -1470,7 +1651,7 @@ interface CallManager extends Call {
1470
1651
  * This interface breaks the circular dependency between Address and Directory
1471
1652
  * by providing a minimal contract that Address needs from the Directory.
1472
1653
  *
1473
- * @typeParam TAddress - The Address type, defaults to never to enforce explicit typing
1654
+ * @template TAddress - The Address type, defaults to never to enforce explicit typing
1474
1655
  *
1475
1656
  * @remarks
1476
1657
  * Uses a generic type parameter to maintain type safety while avoiding
@@ -1491,7 +1672,7 @@ interface AddressProvider<TAddress = never> {
1491
1672
  * Address history entry from conversation messages
1492
1673
  * Contains a reference to the sender address as an observable
1493
1674
  *
1494
- * @typeParam TAddress - The Address type, provided by the implementation
1675
+ * @template TAddress - The Address type, provided by the implementation
1495
1676
  *
1496
1677
  * @remarks
1497
1678
  * Uses a generic type parameter to maintain type safety while avoiding
@@ -1509,7 +1690,7 @@ interface AddressHistory<TAddress = never> {
1509
1690
  * Text message from conversation
1510
1691
  * Contains a reference to the sender address as an observable
1511
1692
  *
1512
- * @typeParam TAddress - The Address type, provided by the implementation
1693
+ * @template TAddress - The Address type, provided by the implementation
1513
1694
  *
1514
1695
  * @remarks
1515
1696
  * Uses a generic type parameter to maintain type safety while avoiding
@@ -1652,11 +1833,35 @@ declare class Address extends Destroyable {
1652
1833
  get locked(): boolean;
1653
1834
  /** Observable indicating whether the address (room) is locked. */
1654
1835
  get locked$(): Observable<boolean>;
1655
- /** Sends a text message to this address. */
1836
+ /**
1837
+ * Sends a text message to this address.
1838
+ *
1839
+ * @param text - The message text to send.
1840
+ *
1841
+ * @example
1842
+ * ```ts
1843
+ * await address.sendText('Hello!');
1844
+ * ```
1845
+ */
1656
1846
  sendText(text: string): Promise<void>;
1657
- /** Collection of text messages for this address, with pagination support. */
1847
+ /**
1848
+ * Collection of text messages for this address, with pagination support.
1849
+ *
1850
+ * Returns `undefined` until {@link textMessages$} has been subscribed to (lazy-loaded).
1851
+ * Filters to `'chat'` subtype messages from the conversation.
1852
+ *
1853
+ * @see {@link textMessages$} to trigger lazy loading.
1854
+ * @see {@link sendText} to send a new message.
1855
+ */
1658
1856
  get textMessage(): EntityCollectionTransformed<GetConversationMessageResponse, TextMessage<Address>> | undefined;
1659
- /** Collection of call history entries for this address, with pagination support. */
1857
+ /**
1858
+ * Collection of call history entries for this address, with pagination support.
1859
+ *
1860
+ * Returns `undefined` until {@link history$} has been subscribed to (lazy-loaded).
1861
+ * Filters to `'log'` subtype messages including kind, status, start/end times.
1862
+ *
1863
+ * @see {@link history$} to trigger lazy loading.
1864
+ */
1660
1865
  get history(): EntityCollectionTransformed<GetConversationMessageResponse, AddressHistory<Address>> | undefined;
1661
1866
  /** Observable of active call states for this address. @throws {UnimplementedError} Requires presence support. */
1662
1867
  get activity$(): Observable<CallState[]>;
@@ -1697,18 +1902,52 @@ declare class TransportManager extends Destroyable {
1697
1902
  private readonly storage;
1698
1903
  private readonly protocolKey;
1699
1904
  private readonly onError?;
1905
+ /**
1906
+ * Normalise a server event timestamp to epoch seconds.
1907
+ *
1908
+ * The server uses two formats:
1909
+ * - `webrtc.message`: float epoch seconds (e.g. 1774372099.022817)
1910
+ * - all other events: int epoch microseconds (e.g. 1774372099925857)
1911
+ *
1912
+ * Values above 1e12 are treated as microseconds and divided by 1e6.
1913
+ */
1914
+ private static toEpochSeconds;
1915
+ /**
1916
+ * Extract the event timestamp from a signalwire.event message.
1917
+ * Returns `null` for messages that have no timestamp
1918
+ * (e.g. signalwire.authorization.state, RPC responses).
1919
+ */
1920
+ private static extractEventTimestamp;
1700
1921
  private initialized$;
1701
1922
  protocol$: rxjs0.ReplaySubject<string | undefined>;
1702
1923
  private isConnecting;
1703
1924
  private isConnected;
1704
1925
  private ackEvent;
1705
1926
  private replySignalwirePing;
1927
+ /**
1928
+ * Filter that drops events whose timestamp predates the current session.
1929
+ *
1930
+ * On each new connection the session epoch is reset (see `resetSessionEpoch`).
1931
+ * The first timestamped event after reset establishes the epoch.
1932
+ * Subsequent events with timestamps older than the epoch are discarded —
1933
+ * this guards against stale events replayed by the server after a reconnect.
1934
+ *
1935
+ * Events without a timestamp (e.g. signalwire.authorization.state) and
1936
+ * non-event messages (RPC responses) always pass through.
1937
+ */
1938
+ private discardStaleEvents;
1939
+ private _sessionEpoch;
1706
1940
  private _outgoingMessages$;
1707
1941
  private _webSocketConnections;
1708
1942
  private _jsonRPCMessage$;
1709
1943
  private _jsonRPCResponse$;
1710
1944
  private _incomingEvent$;
1711
1945
  constructor(storage: StorageManager, protocolKey: string, webSocketConstructor: WebSocketAdapter | NodeSocketAdapter, relayHost: string, onError?: ((error: Error) => void) | undefined);
1946
+ /**
1947
+ * Reset the session epoch. Call this before each signalwire.connect
1948
+ * so that the first event after authentication establishes the new baseline.
1949
+ */
1950
+ resetSessionEpoch(): void;
1712
1951
  setProtocol(protocol: string | undefined): Promise<void>;
1713
1952
  get incomingEvent$(): Observable<JSONRPCRequest | JSONRPCResponse>;
1714
1953
  get connectionStatus$(): Observable<string>;
@@ -2238,6 +2477,12 @@ declare class SignalWire extends Destroyable implements DeviceController {
2238
2477
  private _options;
2239
2478
  private _refreshTimerId?;
2240
2479
  private _deps;
2480
+ /**
2481
+ * Creates a new SignalWire client and begins connecting.
2482
+ *
2483
+ * @param credentialProvider - Provider that supplies authentication credentials.
2484
+ * @param options - Configuration options (connection, device monitoring, preferences).
2485
+ */
2241
2486
  constructor(credentialProvider: CredentialProvider, options?: SignalWireOptions);
2242
2487
  private validateCredentials;
2243
2488
  private init;
@@ -2324,18 +2569,52 @@ declare class SignalWire extends Destroyable implements DeviceController {
2324
2569
  get ready$(): Observable<boolean>;
2325
2570
  /** Observable stream of errors from transport, authentication, and devices. */
2326
2571
  get errors$(): Observable<Error>;
2327
- /** Disconnects the WebSocket and tears down the session. */
2572
+ /**
2573
+ * Disconnects the WebSocket and tears down the current session.
2574
+ *
2575
+ * The client can be reconnected by calling {@link connect} again,
2576
+ * which creates a fresh transport and session.
2577
+ */
2328
2578
  disconnect(): Promise<void>;
2329
2579
  private waitAuthentication;
2330
- /** Registers the subscriber as online to receive inbound calls and events. */
2580
+ /**
2581
+ * Registers the subscriber as online to receive inbound calls and events.
2582
+ *
2583
+ * Waits for authentication to complete before sending the registration.
2584
+ * If the initial attempt fails, reauthentication is attempted automatically.
2585
+ *
2586
+ * @throws {InvalidCredentialsError} If registration and reauthentication both fail.
2587
+ */
2331
2588
  register(): Promise<void>;
2332
- /** Unregisters the subscriber, going offline for inbound calls. */
2589
+ /**
2590
+ * Unregisters the subscriber, going offline for inbound calls.
2591
+ *
2592
+ * The WebSocket connection remains open; use {@link disconnect} to fully close it.
2593
+ */
2333
2594
  unregister(): Promise<void>;
2334
2595
  /**
2335
2596
  * Places an outbound call to the given destination.
2336
- * @param destination - Address URI string or {@link Address} instance to call.
2337
- * @param options - Media and dial options (audio/video, constraints).
2597
+ *
2598
+ * Waits for authentication before dialing. Media options are merged from
2599
+ * saved preferences, destination query parameters (e.g. `?channel=video`),
2600
+ * and the provided `options` (highest priority).
2601
+ *
2602
+ * Returns a {@link Call} in `'ringing'` state. Subscribe to {@link Call.status$}
2603
+ * to track progression through `'connected'` → `'disconnected'`.
2604
+ *
2605
+ * @param destination - Address URI string (e.g. `'/public/my-room'`) or {@link Address} instance.
2606
+ * @param options - Media and dial options (audio/video, device constraints). Overrides defaults.
2338
2607
  * @returns The created {@link Call} instance.
2608
+ * @throws {Error} If authentication is not complete or call creation fails.
2609
+ *
2610
+ * @example
2611
+ * ```ts
2612
+ * const call = await client.dial('/public/conference', {
2613
+ * audio: true,
2614
+ * video: true,
2615
+ * });
2616
+ * call.status$.subscribe(status => console.log('Call:', status));
2617
+ * ```
2339
2618
  */
2340
2619
  dial(destination: string | Address, options?: DialOptions): Promise<Call>;
2341
2620
  /** The underlying client session for advanced RPC operations. */
@@ -2380,8 +2659,19 @@ declare class SignalWire extends Destroyable implements DeviceController {
2380
2659
  enableDeviceMonitoring(): void;
2381
2660
  /** Stops monitoring for media device changes. */
2382
2661
  disableDeviceMonitoring(): void;
2662
+ /**
2663
+ * Returns the capabilities of a media device.
2664
+ * @param deviceInfo - The device to query.
2665
+ * @returns The device capabilities, or `null` if unavailable.
2666
+ */
2383
2667
  getDeviceCapabilities(deviceInfo: MediaDeviceInfo): Promise<MediaTrackCapabilities | null>;
2668
+ /**
2669
+ * Checks whether a device is still available and usable.
2670
+ * @param deviceInfo - The device to validate, or `null`.
2671
+ * @returns `true` if the device is valid and available. Returns `false` for `null`, audio output devices, or unavailable devices.
2672
+ */
2384
2673
  isValidDevice(deviceInfo: MediaDeviceInfo | null): Promise<boolean>;
2674
+ /** Destroys the client, clearing timers and releasing all resources. */
2385
2675
  destroy(): void;
2386
2676
  }
2387
2677
  //#endregion
@@ -2768,17 +3058,45 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2768
3058
  get participants(): CallParticipant[];
2769
3059
  /** The local participant, or `null` if not yet joined. */
2770
3060
  get self(): CallSelfParticipant | null;
3061
+ /** Toggles the call lock state, preventing or allowing new participants from joining. */
2771
3062
  toggleLock(): Promise<void>;
3063
+ /**
3064
+ * Toggles the hold state of the call (pauses/resumes local media transmission).
3065
+ *
3066
+ * Distinct from {@link Participant.toggleMute} which mutes individual tracks.
3067
+ */
2772
3068
  toggleHold(): Promise<void>;
3069
+ /** @throws {UnimplementedError} Not yet implemented. Status tracked via {@link recording$}. */
2773
3070
  startRecording(): Promise<void>;
3071
+ /** @throws {UnimplementedError} Not yet implemented. Status tracked via {@link streaming$}. */
2774
3072
  startStreaming(): Promise<void>;
3073
+ /**
3074
+ * Replaces the call's custom metadata.
3075
+ * @param _meta - Metadata object to set.
3076
+ * @throws {UnimplementedError} Not yet implemented.
3077
+ */
2775
3078
  setMeta(_meta: Record<string, unknown>): Promise<void>;
3079
+ /**
3080
+ * Merges values into the call's custom metadata (unlike {@link setMeta} which replaces).
3081
+ * @param _meta - Metadata to merge.
3082
+ * @throws {UnimplementedError} Not yet implemented.
3083
+ */
2776
3084
  updateMeta(_meta: Record<string, unknown>): Promise<void>;
2777
3085
  /** Observable of layout layer positions for all participants. */
2778
3086
  get layoutLayers$(): Observable<LayoutLayer[]>;
2779
3087
  /** Current snapshot of layout layers. */
2780
3088
  get layoutLayers(): LayoutLayer[];
2781
- /** Executes a Verto RPC method targeting a specific participant. */
3089
+ /**
3090
+ * Executes a Verto RPC method targeting a specific participant.
3091
+ *
3092
+ * Constructs call context (node_id, call_id, member_id) and sends the RPC request.
3093
+ *
3094
+ * @param target - Target member ID string, or a {@link MemberTarget} object.
3095
+ * @param method - Verto method name (e.g. `'call.mute'`, `'call.member.remove'`).
3096
+ * @param args - Parameters for the RPC method.
3097
+ * @returns The RPC response.
3098
+ * @throws {JSONRPCError} If the RPC call returns an error.
3099
+ */
2782
3100
  executeMethod<T extends JSONRPCResponse = JSONRPCResponse>(target: string | MemberTarget, method: string, args: Record<string, unknown>): Promise<T>;
2783
3101
  private buildMethodParams;
2784
3102
  /** Observable of the current call status (e.g. `'ringing'`, `'connected'`). */
@@ -2840,7 +3158,16 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2840
3158
  /** Current audio/video send/receive directions. */
2841
3159
  get mediaDirections(): MediaDirections;
2842
3160
  protected get participantsId$(): Observable<string[]>;
2843
- /** Executes a raw JSON-RPC request on the client session. */
3161
+ /**
3162
+ * Executes a raw JSON-RPC request on the client session.
3163
+ *
3164
+ * Lower-level than {@link executeMethod} — allows full control over the RPC request structure.
3165
+ *
3166
+ * @param request - Complete JSON-RPC request object.
3167
+ * @param options - Optional RPC execution options (timeout, etc.).
3168
+ * @returns The RPC response.
3169
+ * @throws {JSONRPCError} If the RPC call returns an error response.
3170
+ */
2844
3171
  execute<T extends JSONRPCResponse = JSONRPCResponse>(request: JSONRPCRequest, options?: PendingRPCOptions): Promise<T>;
2845
3172
  /** Observable of the local participant's member ID. */
2846
3173
  get selfId$(): Observable<string | null>;
@@ -2854,9 +3181,9 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2854
3181
  private get callSessionEvents$();
2855
3182
  /** Observable of call-updated events. */
2856
3183
  get callUpdated$(): Observable<CallUpdatedPayload>;
2857
- /** Observable of member-joined events. */
3184
+ /** Observable of member-joined events, emitted when a remote participant joins the call. */
2858
3185
  get memberJoined$(): Observable<MemberJoinedPayload>;
2859
- /** Observable of member-left events. */
3186
+ /** Observable of member-left events, emitted when a participant leaves the call. */
2860
3187
  get memberLeft$(): Observable<MemberLeftPayload>;
2861
3188
  /** Observable of member-updated events (mute, volume, etc.). */
2862
3189
  get memberUpdated$(): Observable<MemberUpdatedPayload>;
@@ -2876,25 +3203,78 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2876
3203
  get callEvent$(): Observable<WebrtcMessagePayload | CallJoinedPayload | CallLeftPayload | CallUpdatedPayload | CallStatePayload | CallPlayPayload | CallConnectPayload | MemberUpdatedPayload | MemberJoinedPayload | MemberLeftPayload | MemberTalkingPayload | LayoutChangedPayload | ConversationMessagePayload>;
2877
3204
  /** Observable of layout-changed signaling events. */
2878
3205
  get layoutEvent$(): Observable<LayoutChangedPayload>;
2879
- /** Hangs up the call and releases all resources. */
3206
+ /**
3207
+ * Hangs up the call and releases all resources.
3208
+ *
3209
+ * Sends a Verto `bye` to the server, transitions status to `'disconnecting'`,
3210
+ * then destroys the call. After this, the call instance is no longer usable.
3211
+ *
3212
+ * @example
3213
+ * ```ts
3214
+ * await call.hangup();
3215
+ * ```
3216
+ */
2880
3217
  hangup(): Promise<void>;
2881
- /** Sends DTMF digits (e.g. `'1234#'`) on the call. */
3218
+ /**
3219
+ * Sends DTMF digits on the call.
3220
+ *
3221
+ * @param dtmf - The digit string to send (e.g. `'1234#'`).
3222
+ *
3223
+ * @example
3224
+ * ```ts
3225
+ * await call.sendDigits('1234#');
3226
+ * ```
3227
+ */
2882
3228
  sendDigits(dtmf: string): Promise<void>;
2883
- /** Accepts an inbound call, optionally overriding media options for the answer. */
3229
+ /**
3230
+ * Accepts an inbound call, optionally overriding media options for the answer.
3231
+ *
3232
+ * @param options - Optional media constraints for the answer (audio/video).
3233
+ *
3234
+ * @example
3235
+ * ```ts
3236
+ * // Accept with defaults
3237
+ * call.answer();
3238
+ *
3239
+ * // Accept audio-only
3240
+ * call.answer({ audio: true, video: false });
3241
+ * ```
3242
+ * @see {@link reject} to decline the call instead.
3243
+ * @see {@link answered$} to observe the acceptance state.
3244
+ */
2884
3245
  answer(options?: MediaOptions): void;
2885
3246
  /** Media options provided when answering. Used internally by the VertoManager. */
2886
3247
  get answerMediaOptions(): MediaOptions | undefined;
2887
- /** Rejects an inbound call. */
3248
+ /**
3249
+ * Rejects an inbound call, preventing media negotiation.
3250
+ *
3251
+ * @see {@link answer} to accept the call instead.
3252
+ * @see {@link answered$} to observe the rejection state.
3253
+ */
2888
3254
  reject(): void;
2889
3255
  /** Observable that emits `true` when answered, `false` when rejected. */
2890
3256
  get answered$(): Observable<boolean>;
2891
3257
  /**
2892
3258
  * Sets the call layout and participant positions.
3259
+ *
2893
3260
  * @param layout - Layout name (must be one of {@link layouts}).
2894
- * @param positions - Map of member IDs to video positions.
3261
+ * @param positions - Map of member IDs to {@link VideoPosition} values.
3262
+ * @throws {InvalidParams} If the layout is not in the available {@link layouts}.
3263
+ *
3264
+ * @example
3265
+ * ```ts
3266
+ * await call.setLayout('grid-responsive', {
3267
+ * [participantId]: 'reserved-0',
3268
+ * });
3269
+ * ```
2895
3270
  */
2896
3271
  setLayout(layout: string, positions: Record<string, VideoPosition>): Promise<void>;
2897
- /** Transfers the call to other participants. */
3272
+ /**
3273
+ * Transfers the call to another destination.
3274
+ *
3275
+ * @param options - Transfer configuration including the target destination.
3276
+ * @see {@link status$} to observe the transfer progress.
3277
+ */
2898
3278
  transfer(options: TransferOptions): Promise<void>;
2899
3279
  /** Destroys the call, releasing all resources and subscriptions. */
2900
3280
  destroy(): void;