@signalwire/js 4.0.0-rc.0 → 4.0.0-rc.1

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
@@ -812,7 +812,7 @@ interface Member {
812
812
  member_id: string;
813
813
  call_id: string;
814
814
  name: string;
815
- type: 'member' | 'screen';
815
+ type: 'member' | 'screen' | 'device' | (string & {});
816
816
  parent_id?: string;
817
817
  requested_position?: string;
818
818
  handraised: boolean;
@@ -820,17 +820,17 @@ interface Member {
820
820
  audio_muted: boolean;
821
821
  video_muted: boolean;
822
822
  deaf: boolean;
823
- input_volume: number;
824
- output_volume: number;
825
- input_sensitivity: number;
823
+ input_volume?: number;
824
+ output_volume?: number;
825
+ input_sensitivity?: number;
826
826
  echo_cancellation: boolean;
827
827
  auto_gain: boolean;
828
828
  noise_suppression: boolean;
829
829
  lowbitrate: boolean;
830
830
  denoise: boolean;
831
- talking: boolean;
832
- isAudience: boolean;
833
- meta: Record<string, unknown>;
831
+ talking?: boolean;
832
+ isAudience?: boolean;
833
+ meta?: Record<string, unknown>;
834
834
  subscriber_id: string;
835
835
  address_id: string;
836
836
  updated?: string[];
@@ -952,6 +952,15 @@ interface RoomUpdatedPayload {
952
952
  room_id: string;
953
953
  room_session_id: string;
954
954
  }
955
+ /**
956
+ * Describes the peer (remote) call referenced from a call.state event.
957
+ *
958
+ * Mirrors the backend (relay.c) `peer` shape.
959
+ */
960
+ interface CallStateRelatedCall {
961
+ call_id?: string;
962
+ node_id?: string;
963
+ }
955
964
  interface CallStatePayload {
956
965
  call_id: string;
957
966
  node_id: string;
@@ -959,10 +968,19 @@ interface CallStatePayload {
959
968
  call_state: SignalingCallStates;
960
969
  direction: CallDirection;
961
970
  device: CallDevice;
962
- start_time: number;
963
- answer_time: number;
964
- end_time: number;
971
+ /**
972
+ * Epoch timestamps for the call lifecycle. Optional because pre-answer
973
+ * states (e.g. `created`, `ringing`) do not have an `answer_time`/`end_time`
974
+ * and the backend reports them as `0` or omits them.
975
+ */
976
+ start_time?: number;
977
+ answer_time?: number;
978
+ end_time?: number;
965
979
  room_session_id: string;
980
+ /** The peer (remote) call this call is connected to, if any. */
981
+ peer?: CallStateRelatedCall;
982
+ /** Application-defined tag associated with the call. */
983
+ tag?: string;
966
984
  }
967
985
  interface CallPlayPayload {
968
986
  control_id: string;
@@ -1508,6 +1526,8 @@ interface MemberCapabilities {
1508
1526
  readonly meta: boolean;
1509
1527
  readonly remove: boolean;
1510
1528
  readonly audioFlags: boolean;
1529
+ readonly denoise: boolean;
1530
+ readonly lowbitrate: boolean;
1511
1531
  }
1512
1532
  /**
1513
1533
  * Call-level capabilities state
@@ -1861,6 +1881,8 @@ declare class Participant extends Destroyable implements CallParticipant {
1861
1881
  get addressId(): string | undefined;
1862
1882
  /** Server node ID for this participant, or `undefined` if not available. */
1863
1883
  get nodeId(): string | undefined;
1884
+ /** Call ID for this participant's leg, or `undefined` if not available. */
1885
+ get callId(): string | undefined;
1864
1886
  /** @internal */
1865
1887
  get value(): Partial<Member>;
1866
1888
  /** Toggles the deafened state (mutes/unmutes incoming audio). */
@@ -1885,6 +1907,7 @@ declare class Participant extends Destroyable implements CallParticipant {
1885
1907
  toggleAudioInputAutoGain(): Promise<void>;
1886
1908
  /** Toggles noise suppression on the audio input. */
1887
1909
  toggleNoiseSuppression(): Promise<void>;
1910
+ /** Toggles low-bitrate mode for this participant's media. */
1888
1911
  toggleLowbitrate(): Promise<void>;
1889
1912
  /**
1890
1913
  * Adjusts the **conference-only** microphone energy gate / sensitivity level
@@ -1925,6 +1948,14 @@ declare class Participant extends Destroyable implements CallParticipant {
1925
1948
  setAudioOutputVolume(value: number): Promise<void>;
1926
1949
  /**
1927
1950
  * Sets the participant's position in the video layout.
1951
+ *
1952
+ * Requires the `member.position` capability. The gateway keys positions by the
1953
+ * **target member's own** `call_id`/`node_id` (see issue #19400 and the legacy
1954
+ * `setPositions` implementation), so this sends the participant's own call
1955
+ * context — matching {@link Participant.remove}. A resolved promise does not
1956
+ * guarantee a visible change: the backend silently returns `200` (no-op) for
1957
+ * non-conference targets.
1958
+ *
1928
1959
  * @param value - The {@link VideoPosition} to assign (e.g. `'auto'`, `'reserved-0'`).
1929
1960
  */
1930
1961
  setPosition(value: VideoPosition): Promise<void>;
@@ -2098,6 +2129,7 @@ interface CallParticipant {
2098
2129
  readonly userId: string | undefined;
2099
2130
  readonly addressId: string | undefined;
2100
2131
  readonly nodeId: string | undefined;
2132
+ readonly callId: string | undefined;
2101
2133
  readonly isTalking: boolean;
2102
2134
  readonly position: LayoutLayer | undefined;
2103
2135
  readonly isAudience: boolean;
@@ -3112,7 +3144,34 @@ declare class ClientSessionManager extends Destroyable implements SessionState {
3112
3144
  private get authentication();
3113
3145
  connect(): Promise<void>;
3114
3146
  private handleAuthenticationError;
3147
+ /**
3148
+ * Clear the resume state (authorization_state + protocol) only.
3149
+ *
3150
+ * This is the stale-auth-state recovery helper used by handleAuthError:
3151
+ * the server rejected a reconnect, so the resume state is discarded and a
3152
+ * fresh connect follows. Attach records are deliberately preserved — the
3153
+ * session lives on through the reconnect and reattachCalls() needs the
3154
+ * stored call references afterwards. Do NOT add detachAll() here.
3155
+ *
3156
+ * For public teardown (disconnect/destroy), use {@link teardownSessionState}
3157
+ * instead, which clears the attach records as well.
3158
+ */
3115
3159
  cleanupStoredConnectionParams(): Promise<void>;
3160
+ /**
3161
+ * Public-teardown helper for disconnect()/destroy(). Clears the resume
3162
+ * state (authorization_state + protocol) AND the attach records as one
3163
+ * atomic unit.
3164
+ *
3165
+ * The two stores are coupled: the backend only honors attach records
3166
+ * within the session identified by the resume state, so ending the
3167
+ * session must clear both. Clearing one without the other strands records
3168
+ * no future session can honor (disconnect) or revives a session the
3169
+ * developer explicitly ended (destroy).
3170
+ *
3171
+ * Distinct from {@link cleanupStoredConnectionParams}, which keeps the
3172
+ * attach records for the stale-auth-state recovery path.
3173
+ */
3174
+ teardownSessionState(): Promise<void>;
3116
3175
  protected updateAuthState(authorization_state: string): Promise<void>;
3117
3176
  reauthenticate(token: string, dpopToken?: string, options?: {
3118
3177
  clientBound?: boolean;
@@ -3424,8 +3483,12 @@ interface SignalWireOptions {
3424
3483
  * When `false` (default), session data lives in `sessionStorage` and is
3425
3484
  * lost on reload.
3426
3485
  *
3427
- * Call {@link SignalWire.destroy | destroy()} to clear all persisted state
3428
- * (explicit logout).
3486
+ * Both {@link SignalWire.disconnect | disconnect()} and
3487
+ * {@link SignalWire.destroy | destroy()} end the session and clear the
3488
+ * persisted resume state and attach records; credentials and device
3489
+ * preferences survive. Use `resetToDefaults()` for a full wipe, or
3490
+ * `unregister()` to temporarily stop receiving inbound calls while keeping
3491
+ * the session alive.
3429
3492
  */
3430
3493
  persistSession?: boolean;
3431
3494
  /** Custom storage implementation for persistence. */
@@ -3639,6 +3702,14 @@ declare class SignalWire extends Destroyable implements DeviceController {
3639
3702
  /**
3640
3703
  * Disconnects the WebSocket and tears down the current session.
3641
3704
  *
3705
+ * Ends the session identified by the protocol and clears its persisted
3706
+ * resume state (`authorization_state` + protocol) and attach records
3707
+ * together — a later {@link connect} with the same credentials starts a
3708
+ * fresh session and cannot reattach to the ended session's calls.
3709
+ * Credentials and device preferences are preserved. To temporarily stop
3710
+ * receiving inbound calls while keeping the session alive, use
3711
+ * `unregister()` instead.
3712
+ *
3642
3713
  * The client can be reconnected by calling {@link connect} again,
3643
3714
  * which creates a fresh transport and session.
3644
3715
  */
@@ -3820,7 +3891,15 @@ declare class SignalWire extends Destroyable implements DeviceController {
3820
3891
  * attached call IDs, and all SDK storage keys, then re-enumerates devices.
3821
3892
  */
3822
3893
  resetToDefaults(): Promise<void>;
3823
- /** Destroys the client, clearing timers and releasing all resources. */
3894
+ /**
3895
+ * Destroys the client, clearing timers and releasing all resources.
3896
+ *
3897
+ * Intentionally destroying the client ends its session: the resume state
3898
+ * (`authorization_state` + protocol) and the attach records are both
3899
+ * cleared. Credentials and device preferences are preserved — use
3900
+ * {@link resetToDefaults} for a full wipe. To temporarily stop receiving
3901
+ * inbound calls while keeping the session alive, use `unregister()`.
3902
+ */
3824
3903
  destroy(): void;
3825
3904
  }
3826
3905
  //#endregion
@@ -4698,10 +4777,21 @@ declare class WebRTCCall extends Destroyable implements CallManager {
4698
4777
  /** Observable that emits `true` when answered, `false` when rejected. */
4699
4778
  get answered$(): Observable<boolean>;
4700
4779
  /**
4701
- * Sets the call layout and participant positions.
4780
+ * Sets the call layout and, optionally, individual participant positions.
4781
+ *
4782
+ * The gateway `call.layout.set` DTO has **no** `positions` member, so when
4783
+ * `positions` is provided this method issues a `call.member.position.set`
4784
+ * request per member (via {@link Participant.setPosition}, which keys each
4785
+ * position by that member's own call context) alongside `call.layout.set`
4786
+ * (issue #19400, Flag #6).
4787
+ *
4788
+ * **These operations are NOT atomic.** The layout is applied first, then each
4789
+ * member position sequentially, so members may briefly flash into their
4790
+ * default slots before being moved to the requested positions.
4702
4791
  *
4703
4792
  * @param layout - Layout name (must be one of {@link layouts}).
4704
- * @param positions - Map of member IDs to {@link VideoPosition} values.
4793
+ * @param positions - Optional map of member IDs to {@link VideoPosition} values.
4794
+ * When omitted or empty, only the layout is changed.
4705
4795
  * @throws {InvalidParams} If the layout is not in the available {@link layouts}.
4706
4796
  *
4707
4797
  * @example
@@ -4711,7 +4801,7 @@ declare class WebRTCCall extends Destroyable implements CallManager {
4711
4801
  * });
4712
4802
  * ```
4713
4803
  */
4714
- setLayout(layout: string, positions: Record<string, VideoPosition>): Promise<void>;
4804
+ setLayout(layout: string, positions?: Record<string, VideoPosition>): Promise<void>;
4715
4805
  /**
4716
4806
  * Transfers the call to another destination.
4717
4807
  *