@signalwire/js 4.0.0-dev-20260428183200 → 4.0.0-dev-20260429174756

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.
@@ -461,9 +461,9 @@ var require_Subscriber = /* @__PURE__ */ __commonJSMin(((exports) => {
461
461
  var NotificationFactories_1 = require_NotificationFactories();
462
462
  var timeoutProvider_1 = require_timeoutProvider();
463
463
  var errorContext_1$2 = require_errorContext();
464
- var Subscriber$1 = function(_super) {
465
- __extends$16(Subscriber$2, _super);
466
- function Subscriber$2(destination) {
464
+ var Subscriber = function(_super) {
465
+ __extends$16(Subscriber$1, _super);
466
+ function Subscriber$1(destination) {
467
467
  var _this = _super.call(this) || this;
468
468
  _this.isStopped = false;
469
469
  if (destination) {
@@ -472,54 +472,54 @@ var require_Subscriber = /* @__PURE__ */ __commonJSMin(((exports) => {
472
472
  } else _this.destination = exports.EMPTY_OBSERVER;
473
473
  return _this;
474
474
  }
475
- Subscriber$2.create = function(next, error, complete) {
475
+ Subscriber$1.create = function(next, error, complete) {
476
476
  return new SafeSubscriber(next, error, complete);
477
477
  };
478
- Subscriber$2.prototype.next = function(value) {
478
+ Subscriber$1.prototype.next = function(value) {
479
479
  if (this.isStopped) handleStoppedNotification(NotificationFactories_1.nextNotification(value), this);
480
480
  else this._next(value);
481
481
  };
482
- Subscriber$2.prototype.error = function(err) {
482
+ Subscriber$1.prototype.error = function(err) {
483
483
  if (this.isStopped) handleStoppedNotification(NotificationFactories_1.errorNotification(err), this);
484
484
  else {
485
485
  this.isStopped = true;
486
486
  this._error(err);
487
487
  }
488
488
  };
489
- Subscriber$2.prototype.complete = function() {
489
+ Subscriber$1.prototype.complete = function() {
490
490
  if (this.isStopped) handleStoppedNotification(NotificationFactories_1.COMPLETE_NOTIFICATION, this);
491
491
  else {
492
492
  this.isStopped = true;
493
493
  this._complete();
494
494
  }
495
495
  };
496
- Subscriber$2.prototype.unsubscribe = function() {
496
+ Subscriber$1.prototype.unsubscribe = function() {
497
497
  if (!this.closed) {
498
498
  this.isStopped = true;
499
499
  _super.prototype.unsubscribe.call(this);
500
500
  this.destination = null;
501
501
  }
502
502
  };
503
- Subscriber$2.prototype._next = function(value) {
503
+ Subscriber$1.prototype._next = function(value) {
504
504
  this.destination.next(value);
505
505
  };
506
- Subscriber$2.prototype._error = function(err) {
506
+ Subscriber$1.prototype._error = function(err) {
507
507
  try {
508
508
  this.destination.error(err);
509
509
  } finally {
510
510
  this.unsubscribe();
511
511
  }
512
512
  };
513
- Subscriber$2.prototype._complete = function() {
513
+ Subscriber$1.prototype._complete = function() {
514
514
  try {
515
515
  this.destination.complete();
516
516
  } finally {
517
517
  this.unsubscribe();
518
518
  }
519
519
  };
520
- return Subscriber$2;
520
+ return Subscriber$1;
521
521
  }(Subscription_1$10.Subscription);
522
- exports.Subscriber = Subscriber$1;
522
+ exports.Subscriber = Subscriber;
523
523
  var _bind = Function.prototype.bind;
524
524
  function bind(fn, thisArg) {
525
525
  return _bind.call(fn, thisArg);
@@ -583,7 +583,7 @@ var require_Subscriber = /* @__PURE__ */ __commonJSMin(((exports) => {
583
583
  return _this;
584
584
  }
585
585
  return SafeSubscriber$1;
586
- }(Subscriber$1);
586
+ }(Subscriber);
587
587
  exports.SafeSubscriber = SafeSubscriber;
588
588
  function handleUnhandledError(error) {
589
589
  if (config_1$2.config.useDeprecatedSynchronousErrorHandling) errorContext_1$2.captureError(error);
@@ -11219,15 +11219,15 @@ var DependencyContainer = class {
11219
11219
  this._baseURL = this.apiHost;
11220
11220
  this._credential = {};
11221
11221
  }
11222
- get subscriberId() {
11223
- return this.subscriber.id;
11222
+ get userId() {
11223
+ return this.user.id;
11224
11224
  }
11225
- get subscriber() {
11226
- if (!this._subscriber) throw new DependencyError("Subscriber");
11227
- return this._subscriber;
11225
+ get user() {
11226
+ if (!this._user) throw new DependencyError("User");
11227
+ return this._user;
11228
11228
  }
11229
- set subscriber(subscriber) {
11230
- this._subscriber = subscriber;
11229
+ set user(user) {
11230
+ this._user = user;
11231
11231
  }
11232
11232
  get storage() {
11233
11233
  if (!this._storageManager) {
@@ -11273,16 +11273,16 @@ var DependencyContainer = class {
11273
11273
  this._deviceController = void 0;
11274
11274
  }
11275
11275
  get authorizationStateKey() {
11276
- return `sw:${this.subscriberId}:as`;
11276
+ return `sw:${this.userId}:as`;
11277
11277
  }
11278
11278
  get protocolKey() {
11279
- return `sw:${this.subscriberId}:pt`;
11279
+ return `sw:${this.userId}:pt`;
11280
11280
  }
11281
11281
  get attachedCallsKey() {
11282
- return `sw:${this.subscriberId}:att`;
11282
+ return `sw:${this.userId}:att`;
11283
11283
  }
11284
- getSubscriberFromAddressId() {
11285
- return this.subscriber.addresses[0]?.id ?? "";
11284
+ getUserFromAddressId() {
11285
+ return this.user.addresses[0]?.id ?? "";
11286
11286
  }
11287
11287
  set baseURL(baseURL) {
11288
11288
  this._baseURL = baseURL;
@@ -12112,14 +12112,14 @@ var Fetchable = class extends Destroyable {
12112
12112
  };
12113
12113
 
12114
12114
  //#endregion
12115
- //#region src/core/entities/Subscriber.ts
12115
+ //#region src/core/entities/User.ts
12116
12116
  /**
12117
- * Authenticated subscriber profile.
12117
+ * Authenticated user profile.
12118
12118
  *
12119
12119
  * Fetched automatically when a {@link SignalWire} connects.
12120
12120
  * Contains identity, contact, and organization details.
12121
12121
  */
12122
- var Subscriber = class extends Fetchable {
12122
+ var User = class extends Fetchable {
12123
12123
  constructor(http) {
12124
12124
  super("/api/fabric/subscriber/info", http);
12125
12125
  }
@@ -13713,9 +13713,9 @@ var Participant = class extends Destroyable {
13713
13713
  get meta$() {
13714
13714
  return this.cachedObservable("meta$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.meta), (0, import_operators$1.distinctUntilChanged)()));
13715
13715
  }
13716
- /** Observable of the participant's subscriber ID. */
13717
- get subscriberId$() {
13718
- return this.cachedObservable("subscriberId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.subscriber_id), (0, import_operators$1.distinctUntilChanged)()));
13716
+ /** Observable of the participant's user ID. */
13717
+ get userId$() {
13718
+ return this.cachedObservable("userId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.subscriber_id), (0, import_operators$1.distinctUntilChanged)()));
13719
13719
  }
13720
13720
  /** Observable of the participant's address ID. */
13721
13721
  get addressId$() {
@@ -13819,8 +13819,8 @@ var Participant = class extends Destroyable {
13819
13819
  get meta() {
13820
13820
  return this._state$.value.meta;
13821
13821
  }
13822
- /** Subscriber ID of this participant, or `undefined` if not available. */
13823
- get subscriberId() {
13822
+ /** User ID of this participant, or `undefined` if not available. */
13823
+ get userId() {
13824
13824
  return this._state$.value.subscriber_id;
13825
13825
  }
13826
13826
  /** Address ID of this participant, or `undefined` if not available. */
@@ -19622,7 +19622,7 @@ var ClientSessionManager = class extends Destroyable {
19622
19622
  this._errors$ = this.createReplaySubject(1);
19623
19623
  this._authState$ = this.createBehaviorSubject({ kind: "unauthenticated" });
19624
19624
  this._wasClientBound = false;
19625
- this._subscriberInfo$ = this.createBehaviorSubject(null);
19625
+ this._userInfo$ = this.createBehaviorSubject(null);
19626
19626
  this._calls$ = this.createBehaviorSubject({});
19627
19627
  this._iceServers$ = this.createBehaviorSubject([]);
19628
19628
  attachManager.setSession(this);
@@ -19635,11 +19635,11 @@ var ClientSessionManager = class extends Destroyable {
19635
19635
  get incomingCalls() {
19636
19636
  return Object.values(this._calls$.value).filter((call) => call.direction === "inbound");
19637
19637
  }
19638
- get subscriberInfo$() {
19639
- return this._subscriberInfo$.asObservable();
19638
+ get userInfo$() {
19639
+ return this._userInfo$.asObservable();
19640
19640
  }
19641
- get subscriberInfo() {
19642
- return this._subscriberInfo$.value;
19641
+ get userInfo() {
19642
+ return this._userInfo$.value;
19643
19643
  }
19644
19644
  get calls$() {
19645
19645
  return this.cachedObservable("calls$", () => this._calls$.pipe((0, import_cjs$7.map)((calls) => Object.values(calls))));
@@ -20085,22 +20085,22 @@ var ConversationMessageCollection = class extends EntityCollection {
20085
20085
  }
20086
20086
  };
20087
20087
  var ConversationsManager = class {
20088
- constructor(clientSession, http, getSubscriberAddressId, onError) {
20088
+ constructor(clientSession, http, getUserAddressId, onError) {
20089
20089
  this.clientSession = clientSession;
20090
20090
  this.http = http;
20091
- this.getSubscriberAddressId = getSubscriberAddressId;
20091
+ this.getUserAddressId = getUserAddressId;
20092
20092
  this.onError = onError;
20093
20093
  this.groupIds = /* @__PURE__ */ new Map();
20094
20094
  }
20095
20095
  async join(addressId) {
20096
- const subscriberFromAddressId = this.getSubscriberAddressId();
20096
+ const userFromAddressId = this.getUserAddressId();
20097
20097
  try {
20098
20098
  const response = await this.http.request({
20099
20099
  ...POST_PARAMS,
20100
20100
  url: `/api/fabric/conversations/join`,
20101
20101
  body: JSON.stringify({
20102
- from_fabric_address_id: subscriberFromAddressId,
20103
- fabric_address_ids: [addressId, subscriberFromAddressId]
20102
+ from_fabric_address_id: userFromAddressId,
20103
+ fabric_address_ids: [addressId, userFromAddressId]
20104
20104
  })
20105
20105
  });
20106
20106
  if (response.ok && !!response.body) {
@@ -20122,14 +20122,14 @@ var ConversationsManager = class {
20122
20122
  }
20123
20123
  async sendText(text, destinationAddressId) {
20124
20124
  const groupId = this.groupIds.get(destinationAddressId) ?? await this.join(destinationAddressId);
20125
- const subscriberFromAddressId = this.getSubscriberAddressId();
20125
+ const userFromAddressId = this.getUserAddressId();
20126
20126
  try {
20127
20127
  if ((await this.http.request({
20128
20128
  ...POST_PARAMS,
20129
20129
  url: "/api/fabric/messages",
20130
20130
  body: JSON.stringify({
20131
20131
  group_id: groupId,
20132
- from_fabric_address_id: subscriberFromAddressId,
20132
+ from_fabric_address_id: userFromAddressId,
20133
20133
  text
20134
20134
  })
20135
20135
  })).ok) return;
@@ -20202,17 +20202,17 @@ var DeviceTokenManager = class extends Destroyable {
20202
20202
  return this._effectiveExpireIn;
20203
20203
  }
20204
20204
  /**
20205
- * Activates the Client Bound SAT flow when the subscriber's token has
20205
+ * Activates the Client Bound SAT flow when the user's token has
20206
20206
  * `sat:refresh` scope.
20207
20207
  *
20208
20208
  * Steps:
20209
- * 1. Check subscriber's `sat_claims` for `sat:refresh` scope
20209
+ * 1. Check user's `sat_claims` for `sat:refresh` scope
20210
20210
  * 2. Call `/api/fabric/subscriber/devices/token` with a DPoP proof
20211
20211
  * 3. Reauthenticate the session with the Client Bound SAT + DPoP proof
20212
20212
  * 4. Emit token to trigger the reactive refresh pipeline
20213
20213
  */
20214
- async activate(subscriber, session, updateCredential) {
20215
- const { satClaims } = subscriber;
20214
+ async activate(user, session, updateCredential) {
20215
+ const { satClaims } = user;
20216
20216
  if (!satClaims?.scope?.includes(SAT_REFRESH_SCOPE)) {
20217
20217
  logger$6.debug("[DeviceToken] No sat:refresh scope, skipping Client Bound SAT activation");
20218
20218
  return;
@@ -21059,7 +21059,7 @@ var SignalWire = class extends Destroyable {
21059
21059
  constructor(credentialProvider, options = {}) {
21060
21060
  super();
21061
21061
  this.preferences = new ClientPreferences();
21062
- this._subscriber$ = this.createBehaviorSubject(void 0);
21062
+ this._user$ = this.createBehaviorSubject(void 0);
21063
21063
  this._directory$ = this.createBehaviorSubject(void 0);
21064
21064
  this._isConnected$ = this.createBehaviorSubject(false);
21065
21065
  this._isRegistered$ = this.createBehaviorSubject(false);
@@ -21199,7 +21199,7 @@ var SignalWire = class extends Destroyable {
21199
21199
  if (this._deps.persistSession) this._deps.storage.setItem("sw:cached_credential", credential, "local");
21200
21200
  }
21201
21201
  async init() {
21202
- this._subscriber$.next(new Subscriber(this._deps.http));
21202
+ this._user$.next(new User(this._deps.http));
21203
21203
  if (!this._options.skipConnection) await this.connect();
21204
21204
  if (!this._options.reconnectAttachedCalls && this._attachManager) await this._attachManager.flush();
21205
21205
  if (!this._options.skipRegister) try {
@@ -21263,13 +21263,13 @@ var SignalWire = class extends Destroyable {
21263
21263
  async connect() {
21264
21264
  await this.teardownTransportAndSession();
21265
21265
  try {
21266
- const subscriber = this._subscriber$.value;
21267
- if (!subscriber) throw new UnexpectedError("Subscriber not initialized before connect");
21268
- if (!await (0, import_cjs$1.firstValueFrom)(subscriber.fetched$)) throw new UnexpectedError("Failed to fetch subscriber information - fetched$ emitted false");
21269
- this._deps.subscriber = subscriber;
21266
+ const user = this._user$.value;
21267
+ if (!user) throw new UnexpectedError("User not initialized before connect");
21268
+ if (!await (0, import_cjs$1.firstValueFrom)(user.fetched$)) throw new UnexpectedError("Failed to fetch user information - fetched$ emitted false");
21269
+ this._deps.user = user;
21270
21270
  } catch (error) {
21271
- logger$1.error(`[SignalWire] Failed to fetch subscriber information: ${error instanceof Error ? error.message : "Unknown error"}. This usually means the subscriber token is invalid or expired.`);
21272
- throw new UnexpectedError("Error fetching subscriber information", { cause: error });
21271
+ logger$1.error(`[SignalWire] Failed to fetch user information: ${error instanceof Error ? error.message : "Unknown error"}. This usually means the user token is invalid or expired.`);
21272
+ throw new UnexpectedError("Error fetching user information", { cause: error });
21273
21273
  }
21274
21274
  const errorHandler = (error) => {
21275
21275
  this._errors$.next(error);
@@ -21303,7 +21303,7 @@ var SignalWire = class extends Destroyable {
21303
21303
  logger$1.debug("[SignalWire] Developer refresh disabled — Client Bound SAT activation starting");
21304
21304
  }
21305
21305
  this._deviceTokenManager = new DeviceTokenManager(this._dpopManager, this._deps.http, (error) => this._errors$.next(error), () => this._deps.credential);
21306
- await this._deviceTokenManager.activate(this._deps.subscriber, this._clientSession, (cred) => {
21306
+ await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
21307
21307
  this._deps.credential = {
21308
21308
  ...this._deps.credential,
21309
21309
  ...cred
@@ -21313,7 +21313,7 @@ var SignalWire = class extends Destroyable {
21313
21313
  this.subscribeTo(this._clientSession.authenticated$.pipe((0, import_cjs$1.skip)(1), (0, import_cjs$1.filter)(Boolean)), async () => {
21314
21314
  try {
21315
21315
  if (this._deviceTokenManager) {
21316
- await this._deviceTokenManager.activate(this._deps.subscriber, this._clientSession, (cred) => {
21316
+ await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
21317
21317
  this._deps.credential = {
21318
21318
  ...this._deps.credential,
21319
21319
  ...cred
@@ -21326,15 +21326,15 @@ var SignalWire = class extends Destroyable {
21326
21326
  this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
21327
21327
  }
21328
21328
  try {
21329
- logger$1.debug("[SignalWire] Re-registering subscriber after reconnect");
21329
+ logger$1.debug("[SignalWire] Re-registering user after reconnect");
21330
21330
  await this.register();
21331
- logger$1.debug("[SignalWire] Subscriber re-registered successfully after reconnect");
21331
+ logger$1.debug("[SignalWire] User re-registered successfully after reconnect");
21332
21332
  } catch (error) {
21333
21333
  logger$1.error("[SignalWire] Re-registration failed after reconnect:", error);
21334
21334
  this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
21335
21335
  }
21336
21336
  });
21337
- const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.getSubscriberFromAddressId(), errorHandler);
21337
+ const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.getUserFromAddressId(), errorHandler);
21338
21338
  const directory = new DirectoryManager(this._deps.http, this._clientSession, conversationManager, errorHandler);
21339
21339
  this._directory$.next(directory);
21340
21340
  this._clientSession.setDirectory(directory);
@@ -21345,22 +21345,22 @@ var SignalWire = class extends Destroyable {
21345
21345
  });
21346
21346
  }
21347
21347
  /**
21348
- * Observable that emits the {@link Subscriber} profile once fetched,
21348
+ * Observable that emits the {@link User} profile once fetched,
21349
21349
  * or `undefined` before authentication completes.
21350
21350
  *
21351
21351
  * @example
21352
21352
  * ```ts
21353
- * client.subscriber$.subscribe(sub => {
21354
- * if (sub) console.log('Logged in as', sub.email);
21353
+ * client.user$.subscribe(u => {
21354
+ * if (u) console.log('Logged in as', u.email);
21355
21355
  * });
21356
21356
  * ```
21357
21357
  */
21358
- get subscriber$() {
21359
- return this.deferEmission(this._subscriber$.asObservable());
21358
+ get user$() {
21359
+ return this.deferEmission(this._user$.asObservable());
21360
21360
  }
21361
- /** Current subscriber snapshot, or `undefined` if not yet authenticated. */
21362
- get subscriber() {
21363
- return this._subscriber$.value;
21361
+ /** Current user snapshot, or `undefined` if not yet authenticated. */
21362
+ get user() {
21363
+ return this._user$.value;
21364
21364
  }
21365
21365
  /**
21366
21366
  * Observable that emits the {@link Directory} instance once the client is connected,
@@ -21384,11 +21384,11 @@ var SignalWire = class extends Destroyable {
21384
21384
  get directory() {
21385
21385
  return this._directory$.value;
21386
21386
  }
21387
- /** Observable that emits when the subscriber registration state changes. */
21387
+ /** Observable that emits when the user registration state changes. */
21388
21388
  get isRegistered$() {
21389
21389
  return this.deferEmission(this._isRegistered$.asObservable());
21390
21390
  }
21391
- /** Whether the subscriber is currently registered. */
21391
+ /** Whether the user is currently registered. */
21392
21392
  get isRegistered() {
21393
21393
  return this._isRegistered$.value;
21394
21394
  }
@@ -21521,7 +21521,7 @@ var SignalWire = class extends Destroyable {
21521
21521
  await (0, import_cjs$1.firstValueFrom)(this.ready$.pipe((0, import_cjs$1.filter)((ready$1) => ready$1 === true)));
21522
21522
  }
21523
21523
  /**
21524
- * Registers the subscriber as online to receive inbound calls and events.
21524
+ * Registers the user as online to receive inbound calls and events.
21525
21525
  *
21526
21526
  * Waits for authentication to complete before sending the registration.
21527
21527
  * If the initial attempt fails, reauthentication is attempted automatically.
@@ -21542,7 +21542,7 @@ var SignalWire = class extends Destroyable {
21542
21542
  this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
21543
21543
  throw error;
21544
21544
  }
21545
- logger$1.debug("[SignalWire] Failed to register subscriber, trying reauthentication...");
21545
+ logger$1.debug("[SignalWire] Failed to register user, trying reauthentication...");
21546
21546
  try {
21547
21547
  await this._clientSession.reauthenticate(this._deps.credential.token);
21548
21548
  logger$1.debug("[SignalWire] Reauthentication successful, retrying register()");
@@ -21553,14 +21553,14 @@ var SignalWire = class extends Destroyable {
21553
21553
  this._isRegistered$.next(true);
21554
21554
  } catch (reauthError) {
21555
21555
  logger$1.error("[SignalWire] Reauthentication failed during register():", reauthError);
21556
- const registerError = new InvalidCredentialsError("Failed to register subscriber, and reauthentication attempt also failed. Please check your credentials.", { cause: reauthError instanceof Error ? reauthError : new Error(String(reauthError), { cause: reauthError }) });
21556
+ const registerError = new InvalidCredentialsError("Failed to register user, and reauthentication attempt also failed. Please check your credentials.", { cause: reauthError instanceof Error ? reauthError : new Error(String(reauthError), { cause: reauthError }) });
21557
21557
  this._errors$.next(registerError);
21558
21558
  throw registerError;
21559
21559
  }
21560
21560
  }
21561
21561
  }
21562
21562
  /**
21563
- * Unregisters the subscriber, going offline for inbound calls.
21563
+ * Unregisters the user, going offline for inbound calls.
21564
21564
  *
21565
21565
  * The WebSocket connection remains open; use {@link disconnect} to fully close it.
21566
21566
  */
@@ -21572,7 +21572,7 @@ var SignalWire = class extends Destroyable {
21572
21572
  }));
21573
21573
  this._isRegistered$.next(false);
21574
21574
  } catch (error) {
21575
- logger$1.error("[SignalWire] Failed to unregister subscriber:", error);
21575
+ logger$1.error("[SignalWire] Failed to unregister user:", error);
21576
21576
  this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
21577
21577
  throw error;
21578
21578
  }
@@ -22065,9 +22065,9 @@ exports.SelfCapabilities = SelfCapabilities;
22065
22065
  exports.SelfParticipant = SelfParticipant;
22066
22066
  exports.SignalWire = SignalWire;
22067
22067
  exports.StaticCredentialProvider = StaticCredentialProvider;
22068
- exports.Subscriber = Subscriber;
22069
22068
  exports.TokenRefreshError = TokenRefreshError;
22070
22069
  exports.UnexpectedError = UnexpectedError;
22070
+ exports.User = User;
22071
22071
  exports.VertoPongError = VertoPongError;
22072
22072
  exports.WebRTCCall = WebRTCCall;
22073
22073
  exports.embeddableCall = embeddableCall;