@signalwire/js 4.0.0-beta.0 → 4.0.0-beta.10

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.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as JSONRPCRequest, r as JSONRPCResponse, t as EventChannel } from "./base-aVtoG8Wk.mjs";
1
+ import { a as JSONRPCSuccessResponse, i as JSONRPCResponse, n as JSONRPCErrorResponse, r as JSONRPCRequest, t as EventChannel } from "./base-CQPEW1lJ.mjs";
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";
@@ -8,7 +8,32 @@ declare abstract class Destroyable {
8
8
  protected subscriptions: Subscription[];
9
9
  protected subjects: Subject<unknown>[];
10
10
  protected _destroyed$: Subject<void>;
11
+ private _observableCache?;
11
12
  destroy(): void;
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>;
12
37
  protected subscribeTo<T>(observable: Observable<T>, observerOrNext: Partial<Observer<T>> | ((value: T) => void) | undefined): void;
13
38
  protected createSubject<T>(): Subject<T>;
14
39
  protected createReplaySubject<T>(bufferSize?: number, windowTime?: number): ReplaySubject<T>;
@@ -182,6 +207,50 @@ interface CredentialProvider {
182
207
  */
183
208
  refresh?: () => Promise<SDKCredential>;
184
209
  }
210
+ /**
211
+ * Provides custom WebRTC API implementations for non-standard environments.
212
+ *
213
+ * Use this when the standard browser WebRTC APIs are not available or need
214
+ * to be replaced (e.g., Citrix HDX, React Native, Electron).
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * import { SignalWire, type WebRTCApiProvider } from '@signalwire/js';
219
+ *
220
+ * const provider: WebRTCApiProvider = {
221
+ * RTCPeerConnection: CustomRTCPeerConnection,
222
+ * mediaDevices: {
223
+ * getUserMedia: (constraints) => customGetUserMedia(constraints),
224
+ * enumerateDevices: () => customEnumerateDevices(),
225
+ * addEventListener: (type, listener) => { ... },
226
+ * removeEventListener: (type, listener) => { ... },
227
+ * }
228
+ * };
229
+ *
230
+ * const client = new SignalWire(credentialProvider, { webRTCApiProvider: provider });
231
+ * ```
232
+ */
233
+ interface WebRTCApiProvider {
234
+ /** Custom RTCPeerConnection constructor. */
235
+ RTCPeerConnection: typeof RTCPeerConnection;
236
+ /** Custom media device access. Only the methods used by the SDK are required. */
237
+ mediaDevices: WebRTCMediaDevices;
238
+ }
239
+ /**
240
+ * Subset of the `MediaDevices` interface actually used by the SDK.
241
+ *
242
+ * Implementations only need to provide these methods — the full browser
243
+ * `MediaDevices` type is intentionally not required so that React Native
244
+ * and other non-browser environments can conform without polyfilling
245
+ * unused APIs.
246
+ */
247
+ interface WebRTCMediaDevices {
248
+ getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
249
+ getDisplayMedia?(options: DisplayMediaStreamOptions): Promise<MediaStream>;
250
+ enumerateDevices(): Promise<MediaDeviceInfo[]>;
251
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject): void;
252
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void;
253
+ }
185
254
  //#endregion
186
255
  //#region src/managers/StorageManager.d.ts
187
256
  declare class StorageManager {
@@ -459,6 +528,11 @@ type CallDevice = CallDeviceWebRTCOrSIP | CallDevicePhone;
459
528
  type VideoPosition = 'auto' | `reserved-${number}` | `standard-${number}` | 'off-canvas' | 'playback' | 'full-screen';
460
529
  //#endregion
461
530
  //#region src/core/RPCMessages/types/common.d.ts
531
+ interface MemberTarget {
532
+ member_id: string;
533
+ call_id: string;
534
+ node_id: string;
535
+ }
462
536
  interface Member {
463
537
  room_session_id: string;
464
538
  room_id: string;
@@ -535,56 +609,10 @@ interface ConversationDetails {
535
609
  start_time: number;
536
610
  end_time?: number;
537
611
  }
538
- interface PartialDialogParams {
539
- callID: string;
540
- }
541
- interface AudioMediaParams {
542
- autoGainControl: boolean;
543
- echoCancellation: boolean;
544
- noiseSuppression: boolean;
545
- }
546
- interface FrameRateConstraint {
547
- min: number;
548
- ideal: number;
549
- max: number;
550
- }
551
- interface AspectRatioConstraint {
552
- exact: number;
553
- }
554
- interface DimensionConstraint {
555
- min: number;
556
- ideal: number;
557
- }
558
- interface VideoAdvancedConstraint {
559
- width: DimensionConstraint;
560
- height: DimensionConstraint;
561
- frameRate: FrameRateConstraint;
562
- }
563
- interface VideoMediaParams {
564
- frameRate: FrameRateConstraint;
565
- aspectRatio: AspectRatioConstraint;
566
- width: DimensionConstraint;
567
- height: DimensionConstraint;
568
- advanced: VideoAdvancedConstraint[];
569
- resizeMode: string;
570
- }
571
- interface MediaParams {
572
- audio?: AudioMediaParams;
573
- video?: VideoMediaParams;
574
- }
575
612
  //#endregion
576
613
  //#region src/core/RPCMessages/types/verto.d.ts
577
- interface VertoAnswerParams {
578
- callID: string;
579
- sdp: string;
580
- }
581
- interface VertoMediaParamsParams {
582
- callID: string;
583
- mediaParams: MediaParams;
584
- }
585
- interface VertoPingParams {
586
- callID: string;
587
- dialogParams: PartialDialogParams;
614
+ interface VertoParams {
615
+ userVariables?: Record<string, unknown>;
588
616
  }
589
617
  //#endregion
590
618
  //#region src/core/RPCMessages/types/events.d.ts
@@ -595,7 +623,7 @@ interface WebrtcMessagePayload {
595
623
  jsonrpc: '2.0';
596
624
  id: number;
597
625
  method: string;
598
- params: VertoAnswerParams | VertoMediaParamsParams | VertoPingParams;
626
+ params: VertoParams;
599
627
  }
600
628
  interface CallJoinedPayload {
601
629
  room_session: RoomSession;
@@ -692,7 +720,6 @@ interface ConversationMessagePayload {
692
720
  conversation_name: string;
693
721
  user_name: string;
694
722
  }
695
- type ConversationMessageUpdatedPayload = ConversationMessagePayload;
696
723
  //#endregion
697
724
  //#region src/behaviors/types/collection.types.d.ts
698
725
  interface Entity {
@@ -729,6 +756,7 @@ declare class EntityCollection<T extends Entity = Entity> extends Destroyable im
729
756
  private observablesRegistry;
730
757
  private updateSubscription;
731
758
  private upsertData;
759
+ private _hasMore$;
732
760
  private _destroy$;
733
761
  constructor(fetchController: FetchController<T>, update$: Observable<Partial<T>>, onError?: ((error: Error) => void) | undefined);
734
762
  get loading(): boolean;
@@ -747,6 +775,7 @@ declare class EntityCollectionTransformed<O extends Entity = Entity, T extends E
747
775
  private originalCollection;
748
776
  private filter;
749
777
  private mapper;
778
+ private _values$?;
750
779
  constructor(originalCollection: EntityCollection<O>, filter?: (i: unknown) => i is O, mapper?: (item: O) => T);
751
780
  get loading$(): Observable<boolean>;
752
781
  get loading(): boolean;
@@ -762,11 +791,77 @@ declare class EntityCollectionTransformed<O extends Entity = Entity, T extends E
762
791
  //#endregion
763
792
  //#region src/managers/types/verto-manager.types.d.ts
764
793
  type ScreenShareStatus = 'none' | 'starting' | 'started' | 'stopping';
765
- type SignalingStatus = 'trying' | 'ringing' | 'connecting' | 'connected' | 'disconnected' | 'failed';
794
+ type SignalingStatus = Extract<CallStatus, 'trying' | 'ringing' | 'connecting' | 'connected' | 'disconnected' | 'failed'>;
766
795
  interface TransferOptions {
767
796
  destination: string;
768
797
  }
769
798
  //#endregion
799
+ //#region src/core/errors.d.ts
800
+ declare class UnexpectedError extends Error {
801
+ at?: string | undefined;
802
+ constructor(at?: string | undefined, options?: ErrorOptions);
803
+ }
804
+ declare class InvalidCredentialsError extends Error {
805
+ reason: string;
806
+ constructor(reason?: string, options?: ErrorOptions);
807
+ }
808
+ /**
809
+ * Semantic category of a call-lifecycle error.
810
+ *
811
+ * - `'media'` – RTCPeerConnection / media device failure
812
+ * - `'signaling'` – Verto / JSON-RPC protocol error
813
+ * - `'timeout'` – Call setup timed out waiting for a response
814
+ * - `'rejected'` – Remote side rejected the call
815
+ * - `'network'` – Transport lost during an active call
816
+ * - `'internal'` – Unexpected / unknown error
817
+ */
818
+ type CallErrorKind = 'media' | 'signaling' | 'timeout' | 'rejected' | 'network' | 'internal';
819
+ /**
820
+ * Structured error emitted on `call.errors$`.
821
+ *
822
+ * Provides actionable metadata so consumers can react without
823
+ * resorting to `instanceof` checks on raw `Error` objects.
824
+ */
825
+ interface CallError {
826
+ /** Semantic category of the error. */
827
+ readonly kind: CallErrorKind;
828
+ /**
829
+ * Whether the error terminates the call.
830
+ * When `true`, the call will automatically transition to `'failed'`
831
+ * and be destroyed — no further action is needed from the consumer.
832
+ */
833
+ readonly fatal: boolean;
834
+ /** The underlying error. */
835
+ readonly error: Error;
836
+ /** ID of the call that produced this error. */
837
+ readonly callId: string;
838
+ }
839
+ declare class CallCreateError extends Error {
840
+ message: string;
841
+ error: unknown;
842
+ direction: 'inbound' | 'outbound';
843
+ constructor(message: string, error?: unknown, direction?: 'inbound' | 'outbound', options?: ErrorOptions);
844
+ }
845
+ declare class VertoPongError extends Error {
846
+ originalError: unknown;
847
+ constructor(originalError: unknown);
848
+ }
849
+ declare class MessageParseError extends Error {
850
+ originalError: unknown;
851
+ constructor(originalError: unknown);
852
+ }
853
+ declare class CollectionFetchError extends Error {
854
+ operation: string;
855
+ originalError: unknown;
856
+ constructor(operation: string, originalError: unknown);
857
+ }
858
+ declare class MediaTrackError extends Error {
859
+ operation: string;
860
+ kind: string;
861
+ originalError: unknown;
862
+ constructor(operation: string, kind: string, originalError: unknown);
863
+ }
864
+ //#endregion
770
865
  //#region src/core/RPCMessages/RPCConnect.d.ts
771
866
  interface Authorization {
772
867
  jti: string;
@@ -969,7 +1064,7 @@ interface VertoManager {
969
1064
  * Callback type for executing call methods
970
1065
  * Injected to avoid circular dependency with Call class
971
1066
  */
972
- type ExecuteMethod = <T extends JSONRPCResponse = JSONRPCResponse>(target: string, method: string, args: Record<string, unknown>) => Promise<T>;
1067
+ type ExecuteMethod = <T extends JSONRPCResponse = JSONRPCResponse>(target: string | MemberTarget, method: string, args: Record<string, unknown>) => Promise<T>;
973
1068
  type ParticipantState = Member & {
974
1069
  position: LayoutLayer;
975
1070
  };
@@ -1341,10 +1436,12 @@ interface Call extends CallState {
1341
1436
  readonly remoteStream$: Observable<MediaStream | null>;
1342
1437
  readonly remoteStream: MediaStream | null;
1343
1438
  readonly rtcPeerConnection: RTCPeerConnection | undefined;
1344
- readonly errors$: Observable<Error>;
1439
+ readonly errors$: Observable<CallError>;
1345
1440
  readonly signalingEvent$: Observable<Record<string, unknown>>;
1346
1441
  readonly address?: CallAddress;
1347
1442
  readonly address$: Observable<CallAddress | undefined>;
1443
+ userVariables?: Record<string, unknown>;
1444
+ readonly userVariables$: Observable<Record<string, unknown>>;
1348
1445
  hangup(): Promise<void>;
1349
1446
  toggleLock(): Promise<void>;
1350
1447
  toggleHold(): Promise<void>;
@@ -1354,10 +1451,11 @@ interface Call extends CallState {
1354
1451
  transfer(options: TransferOptions): Promise<void>;
1355
1452
  toggleIncomingVideo(): Promise<void>;
1356
1453
  toggleIncomingAudio(): Promise<void>;
1357
- answer(): void;
1454
+ answer(options?: MediaOptions): void;
1358
1455
  reject(): void;
1359
1456
  sendDigits(digits: string): Promise<void>;
1360
1457
  executeMethod<T extends JSONRPCResponse = JSONRPCResponse>(target: string, method: string, args: Record<string, unknown>): Promise<T>;
1458
+ execute<T extends JSONRPCResponse = JSONRPCResponse>(request: JSONRPCRequest, options?: PendingRPCOptions): Promise<T>;
1361
1459
  }
1362
1460
  /**
1363
1461
  * Extended Call interface with internal management capabilities
@@ -1373,6 +1471,7 @@ interface CallManager extends Call {
1373
1471
  readonly nodeId$: Observable<string | null>;
1374
1472
  readonly nodeId: string | null;
1375
1473
  readonly answered$: Observable<boolean>;
1474
+ readonly answerMediaOptions?: MediaOptions;
1376
1475
  readonly callUpdated$: Observable<CallUpdatedPayload>;
1377
1476
  readonly memberJoined$: Observable<MemberJoinedPayload>;
1378
1477
  readonly memberLeft$: Observable<MemberLeftPayload>;
@@ -1384,7 +1483,6 @@ interface CallManager extends Call {
1384
1483
  addCallId(callId: string): void;
1385
1484
  /** @internal */
1386
1485
  createParticipant(memberId: string, selfId?: string | null): Participant | SelfParticipant;
1387
- execute<T extends JSONRPCResponse = JSONRPCResponse>(request: JSONRPCRequest, options?: PendingRPCOptions): Promise<T>;
1388
1486
  destroy(): void;
1389
1487
  }
1390
1488
  //#endregion
@@ -1622,18 +1720,52 @@ declare class TransportManager extends Destroyable {
1622
1720
  private readonly storage;
1623
1721
  private readonly protocolKey;
1624
1722
  private readonly onError?;
1723
+ /**
1724
+ * Normalise a server event timestamp to epoch seconds.
1725
+ *
1726
+ * The server uses two formats:
1727
+ * - `webrtc.message`: float epoch seconds (e.g. 1774372099.022817)
1728
+ * - all other events: int epoch microseconds (e.g. 1774372099925857)
1729
+ *
1730
+ * Values above 1e12 are treated as microseconds and divided by 1e6.
1731
+ */
1732
+ private static toEpochSeconds;
1733
+ /**
1734
+ * Extract the event timestamp from a signalwire.event message.
1735
+ * Returns `null` for messages that have no timestamp
1736
+ * (e.g. signalwire.authorization.state, RPC responses).
1737
+ */
1738
+ private static extractEventTimestamp;
1625
1739
  private initialized$;
1626
1740
  protocol$: rxjs0.ReplaySubject<string | undefined>;
1627
1741
  private isConnecting;
1628
1742
  private isConnected;
1629
1743
  private ackEvent;
1630
1744
  private replySignalwirePing;
1745
+ /**
1746
+ * Filter that drops events whose timestamp predates the current session.
1747
+ *
1748
+ * On each new connection the session epoch is reset (see `resetSessionEpoch`).
1749
+ * The first timestamped event after reset establishes the epoch.
1750
+ * Subsequent events with timestamps older than the epoch are discarded —
1751
+ * this guards against stale events replayed by the server after a reconnect.
1752
+ *
1753
+ * Events without a timestamp (e.g. signalwire.authorization.state) and
1754
+ * non-event messages (RPC responses) always pass through.
1755
+ */
1756
+ private discardStaleEvents;
1757
+ private _sessionEpoch;
1631
1758
  private _outgoingMessages$;
1632
1759
  private _webSocketConnections;
1633
1760
  private _jsonRPCMessage$;
1634
1761
  private _jsonRPCResponse$;
1635
1762
  private _incomingEvent$;
1636
1763
  constructor(storage: StorageManager, protocolKey: string, webSocketConstructor: WebSocketAdapter | NodeSocketAdapter, relayHost: string, onError?: ((error: Error) => void) | undefined);
1764
+ /**
1765
+ * Reset the session epoch. Call this before each signalwire.connect
1766
+ * so that the first event after authentication establishes the new baseline.
1767
+ */
1768
+ resetSessionEpoch(): void;
1637
1769
  setProtocol(protocol: string | undefined): Promise<void>;
1638
1770
  get incomingEvent$(): Observable<JSONRPCRequest | JSONRPCResponse>;
1639
1771
  get connectionStatus$(): Observable<string>;
@@ -1723,8 +1855,41 @@ interface ClientSession {
1723
1855
  readonly iceServers: RTCIceServer[] | undefined;
1724
1856
  }
1725
1857
  //#endregion
1858
+ //#region src/interfaces/SessionState.d.ts
1859
+ /**
1860
+ * Extended session interface that adds call management and authentication
1861
+ * state on top of the narrow ClientSession contract.
1862
+ *
1863
+ * Accessible via `client.session`. Call and CallFactory continue to depend
1864
+ * only on the narrow ClientSession interface.
1865
+ */
1866
+ interface SessionState extends ClientSession {
1867
+ /**
1868
+ * Observable stream of currently active inbound calls.
1869
+ * Filters `calls$` to only include calls with `direction === 'inbound'`.
1870
+ */
1871
+ readonly incomingCalls$: Observable<Call[]>;
1872
+ /**
1873
+ * Current snapshot of active inbound calls.
1874
+ */
1875
+ readonly incomingCalls: Call[];
1876
+ /**
1877
+ * Observable stream of all currently active calls (both inbound and outbound).
1878
+ */
1879
+ readonly calls$: Observable<Call[]>;
1880
+ /**
1881
+ * Current snapshot of all active calls.
1882
+ */
1883
+ readonly calls: Call[];
1884
+ /**
1885
+ * Observable that emits `true` once the session has been authenticated,
1886
+ * and `false` after disconnect.
1887
+ */
1888
+ readonly authenticated$: Observable<boolean>;
1889
+ }
1890
+ //#endregion
1726
1891
  //#region src/managers/ClientSessionManager.d.ts
1727
- declare class ClientSessionManager extends Destroyable implements ClientSession {
1892
+ declare class ClientSessionManager extends Destroyable implements SessionState {
1728
1893
  private credential;
1729
1894
  private readonly transport;
1730
1895
  private readonly storage;
@@ -1735,16 +1900,16 @@ declare class ClientSessionManager extends Destroyable implements ClientSession
1735
1900
  private readonly agent;
1736
1901
  private readonly eventAcks;
1737
1902
  initialized$: Observable<boolean>;
1738
- authorization$: rxjs0.Subject<Authorization>;
1739
1903
  private authorizationState$;
1740
1904
  private connectVersion;
1905
+ private _authorization$;
1741
1906
  private _errors$;
1742
1907
  private _directory?;
1743
1908
  private _authenticated$;
1744
1909
  private _subscriberInfo$;
1745
1910
  private _calls$;
1746
1911
  private _iceServers$;
1747
- constructor(credential: SDKCredential, transport: TransportManager, storage: StorageManager, authorizationStateKey: string, deviceController: DeviceController, attachManager: AttachManager);
1912
+ constructor(credential: SDKCredential, transport: TransportManager, storage: StorageManager, authorizationStateKey: string, deviceController: DeviceController, attachManager: AttachManager, webRTCApiProvider: WebRTCApiProvider);
1748
1913
  get incomingCalls$(): Observable<Call[]>;
1749
1914
  get incomingCalls(): Call[];
1750
1915
  get subscriberInfo$(): Observable<Address | null>;
@@ -1752,6 +1917,8 @@ declare class ClientSessionManager extends Destroyable implements ClientSession
1752
1917
  get calls$(): Observable<Call[]>;
1753
1918
  get calls(): Call[];
1754
1919
  get iceServers(): RTCIceServer[] | undefined;
1920
+ get authorization$(): Observable<Authorization | undefined>;
1921
+ get authorization(): Authorization | undefined;
1755
1922
  get errors$(): Observable<Error>;
1756
1923
  get authenticated$(): Observable<boolean>;
1757
1924
  get authenticated(): boolean;
@@ -1768,84 +1935,146 @@ declare class ClientSessionManager extends Destroyable implements ClientSession
1768
1935
  private loadAuthorizationStateFromStorage;
1769
1936
  private updateAuthorizationStateInStorage;
1770
1937
  private get authStateEvent$();
1771
- get signalingEvent$(): Observable<{
1938
+ get signalingEvent$(): Observable<(Omit<{
1772
1939
  event_type: "webrtc.message";
1773
- event_channel: string;
1940
+ event_channel: EventChannel;
1774
1941
  timestamp: number;
1942
+ project_id?: string;
1943
+ node_id?: string;
1944
+ is_author?: boolean;
1945
+ params: WebrtcMessagePayload;
1946
+ }, "event_channel" | "project_id" | "node_id"> & {
1947
+ event_channel: string;
1775
1948
  project_id: string;
1776
1949
  node_id: string;
1777
- params: WebrtcMessagePayload;
1778
- } | {
1950
+ }) | {
1779
1951
  event_type: "signalwire.authorization.state";
1780
1952
  params: SignalwireAuthorizationStatePayload;
1781
- } | {
1953
+ } | (Omit<{
1782
1954
  event_type: "call.joined";
1783
- event_channel: string;
1955
+ event_channel: EventChannel;
1784
1956
  timestamp: number;
1957
+ project_id?: string;
1958
+ node_id?: string;
1959
+ is_author?: boolean;
1785
1960
  params: CallJoinedPayload;
1786
- } | {
1787
- event_type: "call.left";
1961
+ }, "event_channel"> & {
1788
1962
  event_channel: string;
1963
+ }) | (Omit<{
1964
+ event_type: "call.left";
1965
+ event_channel: EventChannel;
1789
1966
  timestamp: number;
1967
+ project_id?: string;
1968
+ node_id?: string;
1969
+ is_author?: boolean;
1790
1970
  params: CallLeftPayload;
1791
- } | {
1792
- event_type: "call.updated";
1971
+ }, "event_channel"> & {
1793
1972
  event_channel: string;
1973
+ }) | (Omit<{
1974
+ event_type: "call.updated";
1975
+ event_channel: EventChannel;
1794
1976
  timestamp: number;
1977
+ project_id?: string;
1978
+ node_id?: string;
1979
+ is_author?: boolean;
1795
1980
  params: CallUpdatedPayload;
1796
- } | {
1797
- event_type: "call.state";
1981
+ }, "event_channel"> & {
1798
1982
  event_channel: string;
1983
+ }) | (Omit<{
1984
+ event_type: "call.state";
1985
+ event_channel: EventChannel;
1799
1986
  timestamp: number;
1987
+ project_id?: string;
1988
+ node_id?: string;
1989
+ is_author?: boolean;
1800
1990
  params: CallStatePayload;
1801
- } | {
1802
- event_type: "call.play";
1991
+ }, "event_channel"> & {
1803
1992
  event_channel: string;
1993
+ }) | (Omit<{
1994
+ event_type: "call.play";
1995
+ event_channel: EventChannel;
1804
1996
  timestamp: number;
1997
+ project_id?: string;
1998
+ node_id?: string;
1999
+ is_author?: boolean;
1805
2000
  params: CallPlayPayload;
1806
- } | {
1807
- event_type: "call.connect";
2001
+ }, "event_channel"> & {
1808
2002
  event_channel: string;
2003
+ }) | (Omit<{
2004
+ event_type: "call.connect";
2005
+ event_channel: EventChannel;
1809
2006
  timestamp: number;
2007
+ project_id?: string;
2008
+ node_id?: string;
2009
+ is_author?: boolean;
1810
2010
  params: CallConnectPayload;
1811
- } | {
2011
+ }, "event_channel"> & {
2012
+ event_channel: string;
2013
+ }) | Omit<{
1812
2014
  event_type: "member.updated";
1813
2015
  event_channel: EventChannel;
1814
2016
  timestamp: number;
2017
+ project_id?: string;
2018
+ node_id?: string;
2019
+ is_author?: boolean;
1815
2020
  params: MemberUpdatedPayload;
1816
- } | {
2021
+ }, never> | Omit<{
1817
2022
  event_type: "member.joined";
1818
2023
  event_channel: EventChannel;
1819
2024
  timestamp: number;
2025
+ project_id?: string;
2026
+ node_id?: string;
2027
+ is_author?: boolean;
1820
2028
  params: MemberJoinedPayload;
1821
- } | {
2029
+ }, never> | Omit<{
1822
2030
  event_type: "member.left";
1823
2031
  event_channel: EventChannel;
1824
2032
  timestamp: number;
2033
+ project_id?: string;
2034
+ node_id?: string;
2035
+ is_author?: boolean;
1825
2036
  params: MemberLeftPayload;
1826
- } | {
2037
+ }, never> | Omit<{
1827
2038
  event_type: "member.talking";
1828
2039
  event_channel: EventChannel;
1829
2040
  timestamp: number;
2041
+ project_id?: string;
2042
+ node_id?: string;
2043
+ is_author?: boolean;
1830
2044
  params: MemberTalkingPayload;
1831
- } | {
2045
+ }, never> | Omit<{
1832
2046
  event_type: "layout.changed";
1833
2047
  event_channel: EventChannel;
1834
2048
  timestamp: number;
2049
+ project_id?: string;
2050
+ node_id?: string;
2051
+ is_author?: boolean;
1835
2052
  params: LayoutChangedPayload;
1836
- } | {
2053
+ }, never> | (Omit<{
1837
2054
  event_type: "conversation.message";
2055
+ event_channel: EventChannel;
2056
+ timestamp: number;
2057
+ project_id?: string;
2058
+ node_id?: string;
2059
+ is_author?: boolean;
2060
+ params: ConversationMessagePayload;
2061
+ }, "event_channel" | "timestamp" | "is_author"> & {
1838
2062
  event_channel: string;
1839
2063
  timestamp: string;
1840
2064
  is_author: boolean;
1841
- params: ConversationMessagePayload;
1842
- } | {
2065
+ }) | (Omit<{
1843
2066
  event_type: "conversation.message.updated";
2067
+ event_channel: EventChannel;
2068
+ timestamp: number;
2069
+ project_id?: string;
2070
+ node_id?: string;
2071
+ is_author?: boolean;
2072
+ params: ConversationMessagePayload;
2073
+ }, "event_channel" | "timestamp" | "is_author"> & {
1844
2074
  event_channel: string;
1845
2075
  timestamp: string;
1846
2076
  is_author: boolean;
1847
- params: ConversationMessageUpdatedPayload;
1848
- }>;
2077
+ })>;
1849
2078
  private get vertoInvite$();
1850
2079
  private get contexts();
1851
2080
  private get eventing();
@@ -1855,6 +2084,7 @@ declare class ClientSessionManager extends Destroyable implements ClientSession
1855
2084
  private handleAuthenticationError;
1856
2085
  cleanupStoredConnectionParams(): Promise<void>;
1857
2086
  protected updateAuthState(authorization_state: string): Promise<void>;
2087
+ reauthenticate(token: string): Promise<void>;
1858
2088
  private authenticate;
1859
2089
  disconnect(): Promise<void>;
1860
2090
  private createInboundCall;
@@ -1862,89 +2092,152 @@ declare class ClientSessionManager extends Destroyable implements ClientSession
1862
2092
  private createCall;
1863
2093
  destroy(): void;
1864
2094
  }
1865
- declare class ClientSessionWrapper {
2095
+ declare class ClientSessionWrapper implements SessionState {
1866
2096
  private clientSessionManager;
1867
2097
  constructor(clientSessionManager: ClientSessionManager);
1868
2098
  get authenticated$(): Observable<boolean>;
1869
2099
  get authenticated(): boolean;
1870
- get signalingEvent$(): Observable<{
2100
+ get signalingEvent$(): Observable<(Omit<{
1871
2101
  event_type: "webrtc.message";
1872
- event_channel: string;
2102
+ event_channel: EventChannel;
1873
2103
  timestamp: number;
2104
+ project_id?: string;
2105
+ node_id?: string;
2106
+ is_author?: boolean;
2107
+ params: WebrtcMessagePayload;
2108
+ }, "event_channel" | "project_id" | "node_id"> & {
2109
+ event_channel: string;
1874
2110
  project_id: string;
1875
2111
  node_id: string;
1876
- params: WebrtcMessagePayload;
1877
- } | {
2112
+ }) | {
1878
2113
  event_type: "signalwire.authorization.state";
1879
2114
  params: SignalwireAuthorizationStatePayload;
1880
- } | {
2115
+ } | (Omit<{
1881
2116
  event_type: "call.joined";
1882
- event_channel: string;
2117
+ event_channel: EventChannel;
1883
2118
  timestamp: number;
2119
+ project_id?: string;
2120
+ node_id?: string;
2121
+ is_author?: boolean;
1884
2122
  params: CallJoinedPayload;
1885
- } | {
1886
- event_type: "call.left";
2123
+ }, "event_channel"> & {
1887
2124
  event_channel: string;
2125
+ }) | (Omit<{
2126
+ event_type: "call.left";
2127
+ event_channel: EventChannel;
1888
2128
  timestamp: number;
2129
+ project_id?: string;
2130
+ node_id?: string;
2131
+ is_author?: boolean;
1889
2132
  params: CallLeftPayload;
1890
- } | {
1891
- event_type: "call.updated";
2133
+ }, "event_channel"> & {
1892
2134
  event_channel: string;
2135
+ }) | (Omit<{
2136
+ event_type: "call.updated";
2137
+ event_channel: EventChannel;
1893
2138
  timestamp: number;
2139
+ project_id?: string;
2140
+ node_id?: string;
2141
+ is_author?: boolean;
1894
2142
  params: CallUpdatedPayload;
1895
- } | {
1896
- event_type: "call.state";
2143
+ }, "event_channel"> & {
1897
2144
  event_channel: string;
2145
+ }) | (Omit<{
2146
+ event_type: "call.state";
2147
+ event_channel: EventChannel;
1898
2148
  timestamp: number;
2149
+ project_id?: string;
2150
+ node_id?: string;
2151
+ is_author?: boolean;
1899
2152
  params: CallStatePayload;
1900
- } | {
1901
- event_type: "call.play";
2153
+ }, "event_channel"> & {
1902
2154
  event_channel: string;
2155
+ }) | (Omit<{
2156
+ event_type: "call.play";
2157
+ event_channel: EventChannel;
1903
2158
  timestamp: number;
2159
+ project_id?: string;
2160
+ node_id?: string;
2161
+ is_author?: boolean;
1904
2162
  params: CallPlayPayload;
1905
- } | {
1906
- event_type: "call.connect";
2163
+ }, "event_channel"> & {
1907
2164
  event_channel: string;
2165
+ }) | (Omit<{
2166
+ event_type: "call.connect";
2167
+ event_channel: EventChannel;
1908
2168
  timestamp: number;
2169
+ project_id?: string;
2170
+ node_id?: string;
2171
+ is_author?: boolean;
1909
2172
  params: CallConnectPayload;
1910
- } | {
2173
+ }, "event_channel"> & {
2174
+ event_channel: string;
2175
+ }) | Omit<{
1911
2176
  event_type: "member.updated";
1912
2177
  event_channel: EventChannel;
1913
2178
  timestamp: number;
2179
+ project_id?: string;
2180
+ node_id?: string;
2181
+ is_author?: boolean;
1914
2182
  params: MemberUpdatedPayload;
1915
- } | {
2183
+ }, never> | Omit<{
1916
2184
  event_type: "member.joined";
1917
2185
  event_channel: EventChannel;
1918
2186
  timestamp: number;
2187
+ project_id?: string;
2188
+ node_id?: string;
2189
+ is_author?: boolean;
1919
2190
  params: MemberJoinedPayload;
1920
- } | {
2191
+ }, never> | Omit<{
1921
2192
  event_type: "member.left";
1922
2193
  event_channel: EventChannel;
1923
2194
  timestamp: number;
2195
+ project_id?: string;
2196
+ node_id?: string;
2197
+ is_author?: boolean;
1924
2198
  params: MemberLeftPayload;
1925
- } | {
2199
+ }, never> | Omit<{
1926
2200
  event_type: "member.talking";
1927
2201
  event_channel: EventChannel;
1928
2202
  timestamp: number;
2203
+ project_id?: string;
2204
+ node_id?: string;
2205
+ is_author?: boolean;
1929
2206
  params: MemberTalkingPayload;
1930
- } | {
2207
+ }, never> | Omit<{
1931
2208
  event_type: "layout.changed";
1932
2209
  event_channel: EventChannel;
1933
2210
  timestamp: number;
2211
+ project_id?: string;
2212
+ node_id?: string;
2213
+ is_author?: boolean;
1934
2214
  params: LayoutChangedPayload;
1935
- } | {
2215
+ }, never> | (Omit<{
1936
2216
  event_type: "conversation.message";
2217
+ event_channel: EventChannel;
2218
+ timestamp: number;
2219
+ project_id?: string;
2220
+ node_id?: string;
2221
+ is_author?: boolean;
2222
+ params: ConversationMessagePayload;
2223
+ }, "event_channel" | "timestamp" | "is_author"> & {
1937
2224
  event_channel: string;
1938
2225
  timestamp: string;
1939
2226
  is_author: boolean;
1940
- params: ConversationMessagePayload;
1941
- } | {
2227
+ }) | (Omit<{
1942
2228
  event_type: "conversation.message.updated";
2229
+ event_channel: EventChannel;
2230
+ timestamp: number;
2231
+ project_id?: string;
2232
+ node_id?: string;
2233
+ is_author?: boolean;
2234
+ params: ConversationMessagePayload;
2235
+ }, "event_channel" | "timestamp" | "is_author"> & {
1943
2236
  event_channel: string;
1944
2237
  timestamp: string;
1945
2238
  is_author: boolean;
1946
- params: ConversationMessageUpdatedPayload;
1947
- }>;
2239
+ })>;
2240
+ get iceServers(): RTCIceServer[] | undefined;
1948
2241
  execute<T extends JSONRPCResponse = JSONRPCResponse>(request: JSONRPCRequest, options?: PendingRPCOptions): Promise<T>;
1949
2242
  get incomingCalls$(): Observable<Call[]>;
1950
2243
  get incomingCalls(): Call[];
@@ -1959,8 +2252,6 @@ interface SignalWireOptions {
1959
2252
  skipConnection?: boolean;
1960
2253
  /** Skip automatic subscriber registration on construction. */
1961
2254
  skipRegister?: boolean;
1962
- /** Skip reconnecting to previously attached calls. */
1963
- skipReconnect?: boolean;
1964
2255
  /** Skip monitoring media device changes. */
1965
2256
  skipDeviceMonitoring?: boolean;
1966
2257
  /** Whether to reconnect to previously attached calls. */
@@ -1971,6 +2262,8 @@ interface SignalWireOptions {
1971
2262
  storageImplementation?: Storage;
1972
2263
  /** Custom WebSocket constructor */
1973
2264
  webSocketConstructor?: WebSocketAdapter | NodeSocketAdapter;
2265
+ /** Custom WebRTC API provider */
2266
+ webRTCApiProvider?: WebRTCApiProvider;
1974
2267
  }
1975
2268
  /** Options for {@link SignalWire.dial}. Extends {@link MediaOptions} with dial-specific settings. */
1976
2269
  interface DialOptions extends MediaOptions {}
@@ -2188,38 +2481,9 @@ declare class StaticCredentialProvider implements CredentialProvider {
2188
2481
  authenticate(): Promise<SDKCredential>;
2189
2482
  }
2190
2483
  //#endregion
2191
- //#region src/core/errors.d.ts
2192
- declare class CallCreateError extends Error {
2193
- message: string;
2194
- error: unknown;
2195
- constructor(message: string, error?: unknown, options?: ErrorOptions);
2196
- }
2197
- declare class VertoPongError extends Error {
2198
- originalError: unknown;
2199
- constructor(originalError: unknown);
2200
- }
2201
- declare class MessageParseError extends Error {
2202
- originalError: unknown;
2203
- constructor(originalError: unknown);
2204
- }
2205
- declare class CollectionFetchError extends Error {
2206
- operation: string;
2207
- originalError: unknown;
2208
- constructor(operation: string, originalError: unknown);
2209
- }
2210
- declare class MediaTrackError extends Error {
2211
- operation: string;
2212
- kind: string;
2213
- originalError: unknown;
2214
- constructor(operation: string, kind: string, originalError: unknown);
2215
- }
2216
- //#endregion
2217
2484
  //#region src/controllers/RTCPeerConnectionController.d.ts
2218
2485
  interface RTCPeerConnectionControllerOptions extends MediaOptions {
2219
2486
  callId?: string;
2220
- WebRTCPeerConnectionConstructor?: typeof RTCPeerConnection;
2221
- getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
2222
- getDisplayMedia?: (options: DisplayMediaStreamOptions) => Promise<MediaStream>;
2223
2487
  rtcConfiguration?: RTCConfiguration;
2224
2488
  simulcast?: boolean;
2225
2489
  sfu?: boolean;
@@ -2230,6 +2494,7 @@ interface RTCPeerConnectionControllerOptions extends MediaOptions {
2230
2494
  relayOnly?: boolean;
2231
2495
  iceCandidateTimeout?: number;
2232
2496
  iceGatheringTimeout?: number;
2497
+ webRTCApiProvider?: WebRTCApiProvider;
2233
2498
  }
2234
2499
  type RTCPeerConnectionControllerOptionsPartial = Partial<RTCPeerConnectionControllerOptions>;
2235
2500
  interface UpdateSDPStatusParams {
@@ -2269,6 +2534,7 @@ declare class RTCPeerConnectionController extends Destroyable {
2269
2534
  private _initialized$;
2270
2535
  private _remoteDescription$;
2271
2536
  private _remoteStream$;
2537
+ private _remoteOfferMediaDirections;
2272
2538
  constructor(options?: RTCPeerConnectionControllerOptionsPartial, remoteSessionDescription?: string, deviceController?: DeviceController);
2273
2539
  private get iceGatheringController();
2274
2540
  private get shouldEmitLocalDescription();
@@ -2336,6 +2602,12 @@ declare class RTCPeerConnectionController extends Destroyable {
2336
2602
  status,
2337
2603
  sdp
2338
2604
  }: UpdateSDPStatusParams): Promise<void>;
2605
+ /**
2606
+ * Accept an inbound call by creating the SDP answer.
2607
+ * Optionally override media options before the answer is generated.
2608
+ * Must be called after initialization for inbound (answer-type) connections.
2609
+ */
2610
+ acceptInbound(mediaOverrides?: MediaOptions): Promise<void>;
2339
2611
  private handleOfferReceived;
2340
2612
  private readyToConnect;
2341
2613
  private setRemoteDescriptionBefore;
@@ -2426,15 +2698,13 @@ declare class CallEventsManager extends Destroyable {
2426
2698
  private originCallId?;
2427
2699
  private callIds;
2428
2700
  private roomSessionIds;
2429
- private _status$;
2430
2701
  private _participants$;
2431
2702
  private _self$;
2432
2703
  private _sessionState$;
2433
2704
  constructor(webRtcCallSession: CallManager, options?: WebRTCCallEventManagerOptions);
2434
2705
  get participants$(): Observable<CallParticipant[]>;
2706
+ get participants(): CallParticipant[];
2435
2707
  get self$(): Observable<CallSelfParticipant>;
2436
- get status$(): Observable<CallStatus>;
2437
- get status(): CallStatus;
2438
2708
  isRoomSessionIdValid(roomSessionId: string): boolean;
2439
2709
  addCallId(callId: string): void;
2440
2710
  isCallIdValid(callId: string): boolean;
@@ -2515,19 +2785,24 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2515
2785
  readonly id: string;
2516
2786
  /** Destination URI this call was placed to. */
2517
2787
  to?: string;
2518
- protected readonly participantsMap: Map<string, Participant>;
2519
2788
  private vertoManager;
2520
2789
  private callEventsManager;
2521
2790
  private participantFactory;
2522
2791
  private _errors$;
2523
2792
  private _status$;
2793
+ private _lastMergedStatus;
2524
2794
  private _answered$;
2795
+ private _answerMediaOptions?;
2525
2796
  private _holdState;
2797
+ private _userVariables$;
2526
2798
  constructor(clientSession: ClientSession, options: CallOptions, initialization: CallInitialization, address?: Address | undefined);
2527
2799
  /** Observable stream of errors from media, signaling, and peer connection layers. */
2528
- get errors$(): Observable<Error>;
2529
- /** @internal Push an error to the call's error stream. */
2530
- emitError(error: Error): void;
2800
+ get errors$(): Observable<CallError>;
2801
+ /**
2802
+ * @internal Push an error to the call's error stream.
2803
+ * Fatal errors automatically transition the call to `'failed'` and destroy it.
2804
+ */
2805
+ emitError(callError: CallError): void;
2531
2806
  /** Whether this call is `'inbound'` or `'outbound'`. */
2532
2807
  get direction(): CallDirection;
2533
2808
  /** Observable of the address associated with this call. */
@@ -2561,7 +2836,7 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2561
2836
  /** Current snapshot of layout layers. */
2562
2837
  get layoutLayers(): LayoutLayer[];
2563
2838
  /** Executes a Verto RPC method targeting a specific participant. */
2564
- executeMethod<T extends JSONRPCResponse = JSONRPCResponse>(target: string, method: string, args: Record<string, unknown>): Promise<T>;
2839
+ executeMethod<T extends JSONRPCResponse = JSONRPCResponse>(target: string | MemberTarget, method: string, args: Record<string, unknown>): Promise<T>;
2565
2840
  private buildMethodParams;
2566
2841
  /** Observable of the current call status (e.g. `'ringing'`, `'connected'`). */
2567
2842
  get status$(): Observable<CallStatus>;
@@ -2609,6 +2884,12 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2609
2884
  get remoteStream$(): Observable<MediaStream>;
2610
2885
  /** Current remote media stream, or `null` if not available. */
2611
2886
  get remoteStream(): MediaStream | null;
2887
+ /** Observable of custom user variables associated with the call. */
2888
+ get userVariables$(): Observable<Record<string, unknown>>;
2889
+ /** a copy of the current custom user variables of the call. */
2890
+ get userVariables(): Record<string, unknown>;
2891
+ /** Merge current custom user variables of the call. */
2892
+ set userVariables(variables: Record<string, unknown>);
2612
2893
  /** @internal */
2613
2894
  createParticipant(memberId: string, selfId?: string | null): Participant | SelfParticipant;
2614
2895
  /** Observable of the current audio/video send/receive directions. */
@@ -2656,8 +2937,10 @@ declare class WebRTCCall extends Destroyable implements CallManager {
2656
2937
  hangup(): Promise<void>;
2657
2938
  /** Sends DTMF digits (e.g. `'1234#'`) on the call. */
2658
2939
  sendDigits(dtmf: string): Promise<void>;
2659
- /** Accepts an inbound call. */
2660
- answer(): void;
2940
+ /** Accepts an inbound call, optionally overriding media options for the answer. */
2941
+ answer(options?: MediaOptions): void;
2942
+ /** Media options provided when answering. Used internally by the VertoManager. */
2943
+ get answerMediaOptions(): MediaOptions | undefined;
2661
2944
  /** Rejects an inbound call. */
2662
2945
  reject(): void;
2663
2946
  /** Observable that emits `true` when answered, `false` when rejected. */
@@ -2686,5 +2969,5 @@ declare const version: string;
2686
2969
  */
2687
2970
  declare const ready: boolean;
2688
2971
  //#endregion
2689
- export { Address, type AddressHistory, type Call, type CallAddress, CallCreateError, type CallOptions, type CallParticipant, type CallSelfParticipant, type CallState, type CallStatus, ClientPreferences, CollectionFetchError, type DialOptions, type Directory, type ExecuteMethod, type LayoutLayer, type MediaDirection, type MediaDirections, type MediaOptions, MediaTrackError, MessageParseError, type NodeSocketAdapter, Participant, type SDKCredential, SelfParticipant, SignalWire, type SignalWireOptions, StaticCredentialProvider, Subscriber, type TextMessage, VertoPongError, WebRTCCall, type WebSocketAdapter, embeddableCall, isSelfParticipant, ready, version };
2972
+ export { Address, type AddressHistory, type Call, type CallAddress, type CallCapabilitiesState, CallCreateError, type CallError, type CallErrorKind, type CallOptions, type CallParticipant, type CallSelfParticipant, type CallState, type CallStatus, ClientPreferences, CollectionFetchError, type CredentialProvider, type DeviceController, type DialOptions, type Directory, type ExecuteMethod, InvalidCredentialsError, type JSONRPCErrorResponse, type JSONRPCRequest, type JSONRPCResponse, type JSONRPCSuccessResponse, type LayoutLayer, type MediaDirection, type MediaDirections, type MediaOptions, MediaTrackError, type MemberCapabilities, MessageParseError, type NodeSocketAdapter, type OnOffCapability, Participant, type PendingRPCOptions, type SDKCredential, SelfCapabilities, SelfParticipant, type SessionState, SignalWire, type SignalWireOptions, StaticCredentialProvider, type Storage, Subscriber, type TextMessage, type TransferOptions, UnexpectedError, VertoPongError, type VideoPosition, type WebRTCApiProvider, WebRTCCall, type WebRTCMediaDevices, type WebSocketAdapter, embeddableCall, isSelfParticipant, ready, version };
2690
2973
  //# sourceMappingURL=index.d.mts.map