@signalwire/js 4.0.0-dev-20261001133709 → 4.0.0-dev-20261125185248

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.
@@ -9114,6 +9114,10 @@ const MEDIA_ACCESS_DENIAL_NAMES = [
9114
9114
  ];
9115
9115
  /** Error names browsers use when the capture hardware is already held exclusively. */
9116
9116
  const MEDIA_DEVICE_IN_USE_NAMES = ["NotReadableError", "TrackStartError"];
9117
+ const INACTIVE_MEDIA_DIRECTIONS = Object.freeze({
9118
+ audio: "inactive",
9119
+ video: "inactive"
9120
+ });
9117
9121
  /** Default polling interval for RTCPeerConnection.getStats() in milliseconds. */
9118
9122
  const DEFAULT_STATS_POLLING_INTERVAL_MS = 1e3;
9119
9123
  /** Number of initial samples used to build a baseline for spike detection. */
@@ -17086,10 +17090,7 @@ var RTCPeerConnectionController = class extends Destroyable {
17086
17090
  });
17087
17091
  }
17088
17092
  get mediaDirections() {
17089
- return this.transceiverController?.getMediaDirections() ?? this._remoteOfferMediaDirections ?? {
17090
- audio: "inactive",
17091
- video: "inactive"
17092
- };
17093
+ return this.transceiverController?.getMediaDirections() ?? this._remoteOfferMediaDirections ?? INACTIVE_MEDIA_DIRECTIONS;
17093
17094
  }
17094
17095
  async _setRemoteDescription(params) {
17095
17096
  if (!this.peerConnection) throw new DependencyError("RTCPeerConnection is not initialized");
@@ -17266,7 +17267,7 @@ var WebRTCVertoManager = class extends VertoManager {
17266
17267
  }
17267
17268
  }
17268
17269
  get mediaDirections() {
17269
- return this.mainPeerConnection.mediaDirections;
17270
+ return this._rtcPeerConnectionsMap.get(this.webRtcCallSession.id)?.mediaDirections ?? INACTIVE_MEDIA_DIRECTIONS;
17270
17271
  }
17271
17272
  get rtcPeerConnections$() {
17272
17273
  return this._rtcPeerConnections$.asObservable();
@@ -17724,7 +17725,7 @@ var WebRTCVertoManager = class extends VertoManager {
17724
17725
  if (rtcPeerConnController.isMainDevice) {
17725
17726
  this._selfId$.next(memberId);
17726
17727
  this._nodeId$.next(nodeId);
17727
- this.attachManager.attach(this.buildAttachableCall(callId, nodeId ?? void 0));
17728
+ if (this._rtcPeerConnectionsMap.has(this.webRtcCallSession.id)) this.attachManager.attach(this.buildAttachableCall(callId, nodeId ?? void 0));
17728
17729
  }
17729
17730
  if (callId) this.webRtcCallSession.addCallId(callId);
17730
17731
  logger$16.info("[WebRTCManager] Verto invite successful");
@@ -17900,7 +17901,7 @@ var WebRTCVertoManager = class extends VertoManager {
17900
17901
  this.emitMainSignalingStatus(rtcPeerConnectionController.id, "connecting");
17901
17902
  await this.sendLocalDescription(vertoMessageRequest, rtcPeerConnectionController);
17902
17903
  await rtcPeerConnectionController.updateAnswerStatus({ status: "sent" });
17903
- await this.attachManager.attach(this.buildAttachableCall());
17904
+ if (this._rtcPeerConnectionsMap.has(this.webRtcCallSession.id)) await this.attachManager.attach(this.buildAttachableCall());
17904
17905
  } catch (error) {
17905
17906
  logger$16.error("[WebRTCManager] Error sending Verto answer:", error);
17906
17907
  this.reportLegError(toError(error), rtcPeerConnectionController);
@@ -19671,7 +19672,7 @@ var WebRTCCall = class extends Destroyable {
19671
19672
  get mediaDirections$() {
19672
19673
  return this.deferEmission(this.vertoManager.mediaDirections$).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
19673
19674
  }
19674
- /** Current audio/video send/receive directions. */
19675
+ /** Current audio/video send/receive directions. Both are `'inactive'` once the call is destroyed. */
19675
19676
  get mediaDirections() {
19676
19677
  return this.vertoManager.mediaDirections;
19677
19678
  }
@@ -20695,6 +20696,8 @@ var ClientSessionManager = class extends Destroyable {
20695
20696
  this._errors$ = this.createReplaySubject(1);
20696
20697
  this._authState$ = this.createBehaviorSubject({ kind: "unauthenticated" });
20697
20698
  this._wasClientBound = false;
20699
+ this._lastFreshConnectReminted = false;
20700
+ this._remintBeforeNextFreshConnect = false;
20698
20701
  this._userInfo$ = this.createBehaviorSubject(null);
20699
20702
  this._calls$ = this.createBehaviorSubject({});
20700
20703
  this._iceServers$ = this.createBehaviorSubject([]);
@@ -20900,7 +20903,17 @@ var ClientSessionManager = class extends Destroyable {
20900
20903
  if (isRecoverableAuthError$1 && hasStoredState) {
20901
20904
  logger$9.debug("[Session] Recoverable auth error — cleaning up stored state and reconnecting fresh");
20902
20905
  await this.discardResumeStateAndReconnect();
20903
- } else this._errors$.next(error);
20906
+ } else if (isRecoverableAuthError$1 && this.onBeforeReconnect && !this._lastFreshConnectReminted) {
20907
+ logger$9.debug("[Session] Fresh connect refused — re-minting the credential and retrying once");
20908
+ this._remintBeforeNextFreshConnect = true;
20909
+ this.transport.reconnect();
20910
+ } else {
20911
+ this._errors$.next(error);
20912
+ if (isRecoverableAuthError$1) {
20913
+ this.transport.disconnect();
20914
+ this.onAuthenticationRejected?.();
20915
+ }
20916
+ }
20904
20917
  }
20905
20918
  /**
20906
20919
  * Clear the resume state (authorization_state + protocol) and ask the
@@ -20992,6 +21005,7 @@ var ClientSessionManager = class extends Destroyable {
20992
21005
  }
20993
21006
  async authenticate() {
20994
21007
  logger$9.debug("[Session] Starting authentication process");
21008
+ this._lastFreshConnectReminted = false;
20995
21009
  const persistedParams = await (0, import_cjs$7.firstValueFrom)((0, import_cjs$7.combineLatest)({
20996
21010
  protocol: this.transport.protocol$,
20997
21011
  authorization_state: this.authorizationState$
@@ -21008,8 +21022,11 @@ var ClientSessionManager = class extends Destroyable {
21008
21022
  else {
21009
21023
  const credential = this.getCredential();
21010
21024
  const credentialExpired = credential.expiry_at !== void 0 && credential.expiry_at <= Date.now() + CREDENTIAL_EXPIRY_SKEW_MS;
21011
- if (this.onBeforeReconnect && (this.clientBound || credentialExpired)) {
21025
+ const remint = this.clientBound || credentialExpired || this._remintBeforeNextFreshConnect;
21026
+ this._remintBeforeNextFreshConnect = false;
21027
+ if (this.onBeforeReconnect && remint) {
21012
21028
  logger$9.debug("[Session] Refreshing credentials before fresh connect");
21029
+ this._lastFreshConnectReminted = true;
21013
21030
  await this.onBeforeReconnect();
21014
21031
  }
21015
21032
  }
@@ -23069,6 +23086,7 @@ var SignalWire = class extends Destroyable {
23069
23086
  this.persistClientBoundMarker(Boolean(authorization?.cnf?.jkt));
23070
23087
  });
23071
23088
  await this._clientSession.connect();
23089
+ this._clientSession.onAuthenticationRejected = () => void this.disconnect();
23072
23090
  await this._refreshCoordinator?.activate(this._deps.user, this._clientSession);
23073
23091
  this.subscribeTo(this._clientSession.authenticated$.pipe((0, import_cjs$1.skip)(1), (0, import_cjs$1.filter)(Boolean)), async () => {
23074
23092
  try {
@@ -23248,7 +23266,7 @@ var SignalWire = class extends Destroyable {
23248
23266
  logger$1.warn("[SignalWire] Failed to initialize VisibilityController:", error);
23249
23267
  }
23250
23268
  try {
23251
- this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "4.0.0-dev-20261001133709" });
23269
+ this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "4.0.0-dev-20261125185248" });
23252
23270
  } catch (error) {
23253
23271
  logger$1.warn("[SignalWire] Failed to initialize DiagnosticsCollector:", error);
23254
23272
  }
@@ -23803,7 +23821,7 @@ var StaticCredentialProvider = class {
23803
23821
  /**
23804
23822
  * Library version from package.json, injected at build time.
23805
23823
  */
23806
- const version = "4.0.0-dev-20261001133709";
23824
+ const version = "4.0.0-dev-20261125185248";
23807
23825
  /**
23808
23826
  * Flag indicating the library has been loaded and is ready to use.
23809
23827
  * For UMD builds: `window.SignalWire.ready`
@@ -23825,7 +23843,7 @@ const ready = true;
23825
23843
  */
23826
23844
  const emitReadyEvent = () => {
23827
23845
  if (typeof window !== "undefined") {
23828
- const event = new CustomEvent("signalwire:js:ready", { detail: { version: "4.0.0-dev-20261001133709" } });
23846
+ const event = new CustomEvent("signalwire:js:ready", { detail: { version: "4.0.0-dev-20261125185248" } });
23829
23847
  window.dispatchEvent(event);
23830
23848
  }
23831
23849
  };