@signalwire/js 4.0.0-dev-20260428212324 → 4.0.0-dev-20260430003639
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/browser.mjs +119 -82
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +119 -82
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +105 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -48
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +50 -48
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +105 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser.mjs
CHANGED
|
@@ -457,9 +457,9 @@ var require_Subscriber = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
457
457
|
var NotificationFactories_1 = require_NotificationFactories();
|
|
458
458
|
var timeoutProvider_1 = require_timeoutProvider();
|
|
459
459
|
var errorContext_1$2 = require_errorContext();
|
|
460
|
-
var Subscriber
|
|
461
|
-
__extends$16(Subscriber$
|
|
462
|
-
function Subscriber$
|
|
460
|
+
var Subscriber = function(_super) {
|
|
461
|
+
__extends$16(Subscriber$1, _super);
|
|
462
|
+
function Subscriber$1(destination) {
|
|
463
463
|
var _this = _super.call(this) || this;
|
|
464
464
|
_this.isStopped = false;
|
|
465
465
|
if (destination) {
|
|
@@ -468,54 +468,54 @@ var require_Subscriber = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
468
468
|
} else _this.destination = exports.EMPTY_OBSERVER;
|
|
469
469
|
return _this;
|
|
470
470
|
}
|
|
471
|
-
Subscriber$
|
|
471
|
+
Subscriber$1.create = function(next, error, complete) {
|
|
472
472
|
return new SafeSubscriber(next, error, complete);
|
|
473
473
|
};
|
|
474
|
-
Subscriber$
|
|
474
|
+
Subscriber$1.prototype.next = function(value) {
|
|
475
475
|
if (this.isStopped) handleStoppedNotification(NotificationFactories_1.nextNotification(value), this);
|
|
476
476
|
else this._next(value);
|
|
477
477
|
};
|
|
478
|
-
Subscriber$
|
|
478
|
+
Subscriber$1.prototype.error = function(err) {
|
|
479
479
|
if (this.isStopped) handleStoppedNotification(NotificationFactories_1.errorNotification(err), this);
|
|
480
480
|
else {
|
|
481
481
|
this.isStopped = true;
|
|
482
482
|
this._error(err);
|
|
483
483
|
}
|
|
484
484
|
};
|
|
485
|
-
Subscriber$
|
|
485
|
+
Subscriber$1.prototype.complete = function() {
|
|
486
486
|
if (this.isStopped) handleStoppedNotification(NotificationFactories_1.COMPLETE_NOTIFICATION, this);
|
|
487
487
|
else {
|
|
488
488
|
this.isStopped = true;
|
|
489
489
|
this._complete();
|
|
490
490
|
}
|
|
491
491
|
};
|
|
492
|
-
Subscriber$
|
|
492
|
+
Subscriber$1.prototype.unsubscribe = function() {
|
|
493
493
|
if (!this.closed) {
|
|
494
494
|
this.isStopped = true;
|
|
495
495
|
_super.prototype.unsubscribe.call(this);
|
|
496
496
|
this.destination = null;
|
|
497
497
|
}
|
|
498
498
|
};
|
|
499
|
-
Subscriber$
|
|
499
|
+
Subscriber$1.prototype._next = function(value) {
|
|
500
500
|
this.destination.next(value);
|
|
501
501
|
};
|
|
502
|
-
Subscriber$
|
|
502
|
+
Subscriber$1.prototype._error = function(err) {
|
|
503
503
|
try {
|
|
504
504
|
this.destination.error(err);
|
|
505
505
|
} finally {
|
|
506
506
|
this.unsubscribe();
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
|
-
Subscriber$
|
|
509
|
+
Subscriber$1.prototype._complete = function() {
|
|
510
510
|
try {
|
|
511
511
|
this.destination.complete();
|
|
512
512
|
} finally {
|
|
513
513
|
this.unsubscribe();
|
|
514
514
|
}
|
|
515
515
|
};
|
|
516
|
-
return Subscriber$
|
|
516
|
+
return Subscriber$1;
|
|
517
517
|
}(Subscription_1$10.Subscription);
|
|
518
|
-
exports.Subscriber = Subscriber
|
|
518
|
+
exports.Subscriber = Subscriber;
|
|
519
519
|
var _bind = Function.prototype.bind;
|
|
520
520
|
function bind(fn, thisArg) {
|
|
521
521
|
return _bind.call(fn, thisArg);
|
|
@@ -579,7 +579,7 @@ var require_Subscriber = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
579
579
|
return _this;
|
|
580
580
|
}
|
|
581
581
|
return SafeSubscriber$1;
|
|
582
|
-
}(Subscriber
|
|
582
|
+
}(Subscriber);
|
|
583
583
|
exports.SafeSubscriber = SafeSubscriber;
|
|
584
584
|
function handleUnhandledError(error) {
|
|
585
585
|
if (config_1$2.config.useDeprecatedSynchronousErrorHandling) errorContext_1$2.captureError(error);
|
|
@@ -11215,15 +11215,15 @@ var DependencyContainer = class {
|
|
|
11215
11215
|
this._baseURL = this.apiHost;
|
|
11216
11216
|
this._credential = {};
|
|
11217
11217
|
}
|
|
11218
|
-
get
|
|
11219
|
-
return this.
|
|
11218
|
+
get userId() {
|
|
11219
|
+
return this.user.id;
|
|
11220
11220
|
}
|
|
11221
|
-
get
|
|
11222
|
-
if (!this.
|
|
11223
|
-
return this.
|
|
11221
|
+
get user() {
|
|
11222
|
+
if (!this._user) throw new DependencyError("User");
|
|
11223
|
+
return this._user;
|
|
11224
11224
|
}
|
|
11225
|
-
set
|
|
11226
|
-
this.
|
|
11225
|
+
set user(user) {
|
|
11226
|
+
this._user = user;
|
|
11227
11227
|
}
|
|
11228
11228
|
get storage() {
|
|
11229
11229
|
if (!this._storageManager) {
|
|
@@ -11269,16 +11269,16 @@ var DependencyContainer = class {
|
|
|
11269
11269
|
this._deviceController = void 0;
|
|
11270
11270
|
}
|
|
11271
11271
|
get authorizationStateKey() {
|
|
11272
|
-
return `sw:${this.
|
|
11272
|
+
return `sw:${this.userId}:as`;
|
|
11273
11273
|
}
|
|
11274
11274
|
get protocolKey() {
|
|
11275
|
-
return `sw:${this.
|
|
11275
|
+
return `sw:${this.userId}:pt`;
|
|
11276
11276
|
}
|
|
11277
11277
|
get attachedCallsKey() {
|
|
11278
|
-
return `sw:${this.
|
|
11278
|
+
return `sw:${this.userId}:att`;
|
|
11279
11279
|
}
|
|
11280
|
-
|
|
11281
|
-
return this.
|
|
11280
|
+
getUserFromAddressId() {
|
|
11281
|
+
return this.user.addresses[0]?.id ?? "";
|
|
11282
11282
|
}
|
|
11283
11283
|
set baseURL(baseURL) {
|
|
11284
11284
|
this._baseURL = baseURL;
|
|
@@ -12108,14 +12108,14 @@ var Fetchable = class extends Destroyable {
|
|
|
12108
12108
|
};
|
|
12109
12109
|
|
|
12110
12110
|
//#endregion
|
|
12111
|
-
//#region src/core/entities/
|
|
12111
|
+
//#region src/core/entities/User.ts
|
|
12112
12112
|
/**
|
|
12113
|
-
* Authenticated
|
|
12113
|
+
* Authenticated user profile.
|
|
12114
12114
|
*
|
|
12115
12115
|
* Fetched automatically when a {@link SignalWire} connects.
|
|
12116
12116
|
* Contains identity, contact, and organization details.
|
|
12117
12117
|
*/
|
|
12118
|
-
var
|
|
12118
|
+
var User = class extends Fetchable {
|
|
12119
12119
|
constructor(http) {
|
|
12120
12120
|
super("/api/fabric/subscriber/info", http);
|
|
12121
12121
|
}
|
|
@@ -13709,9 +13709,9 @@ var Participant = class extends Destroyable {
|
|
|
13709
13709
|
get meta$() {
|
|
13710
13710
|
return this.cachedObservable("meta$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.meta), (0, import_operators$1.distinctUntilChanged)()));
|
|
13711
13711
|
}
|
|
13712
|
-
/** Observable of the participant's
|
|
13713
|
-
get
|
|
13714
|
-
return this.cachedObservable("
|
|
13712
|
+
/** Observable of the participant's user ID. */
|
|
13713
|
+
get userId$() {
|
|
13714
|
+
return this.cachedObservable("userId$", () => this._state$.pipe((0, import_operators$1.map)((state) => state.subscriber_id), (0, import_operators$1.distinctUntilChanged)()));
|
|
13715
13715
|
}
|
|
13716
13716
|
/** Observable of the participant's address ID. */
|
|
13717
13717
|
get addressId$() {
|
|
@@ -13815,8 +13815,8 @@ var Participant = class extends Destroyable {
|
|
|
13815
13815
|
get meta() {
|
|
13816
13816
|
return this._state$.value.meta;
|
|
13817
13817
|
}
|
|
13818
|
-
/**
|
|
13819
|
-
get
|
|
13818
|
+
/** User ID of this participant, or `undefined` if not available. */
|
|
13819
|
+
get userId() {
|
|
13820
13820
|
return this._state$.value.subscriber_id;
|
|
13821
13821
|
}
|
|
13822
13822
|
/** Address ID of this participant, or `undefined` if not available. */
|
|
@@ -15423,6 +15423,12 @@ var TransceiverController = class extends Destroyable {
|
|
|
15423
15423
|
scaleResolutionDownBy: Number(rid) * 6 || 1
|
|
15424
15424
|
}));
|
|
15425
15425
|
}
|
|
15426
|
+
/**
|
|
15427
|
+
* Resolve the current MediaTrackConstraints for an input kind, normalising
|
|
15428
|
+
* boolean shorthand to an empty object. Public so the surrounding
|
|
15429
|
+
* RTCPeerConnectionController can drive its own pipeline-aware getUserMedia
|
|
15430
|
+
* call with the same effective constraints the transceiver would have used.
|
|
15431
|
+
*/
|
|
15426
15432
|
getConstraintsFor(kind) {
|
|
15427
15433
|
const constraints = kind === "audio" ? this.inputAudioDeviceConstraints : this.inputVideoDeviceConstraints;
|
|
15428
15434
|
return typeof constraints === "boolean" ? {} : constraints;
|
|
@@ -15749,7 +15755,19 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15749
15755
|
return this._memberId;
|
|
15750
15756
|
}
|
|
15751
15757
|
stopTrackSender(kind, options = { updateTransceiverDirection: false }) {
|
|
15752
|
-
|
|
15758
|
+
const audioCovered = kind === "audio" || kind === "both";
|
|
15759
|
+
if (audioCovered && this._localAudioPipeline) this.stopRawAudioInputForPipeline();
|
|
15760
|
+
if (!audioCovered) this.transceiverController?.stopTrackSender(kind, options);
|
|
15761
|
+
else if (kind === "both") this.transceiverController?.stopTrackSender("video", options);
|
|
15762
|
+
else if (!this._localAudioPipeline) this.transceiverController?.stopTrackSender(kind, options);
|
|
15763
|
+
}
|
|
15764
|
+
stopRawAudioInputForPipeline() {
|
|
15765
|
+
const rawTracks = this.localStreamController.localAudioTracks;
|
|
15766
|
+
for (const track of rawTracks) if (track.readyState === "live") {
|
|
15767
|
+
track.stop();
|
|
15768
|
+
this.localStreamController.removeTrack(track.id);
|
|
15769
|
+
}
|
|
15770
|
+
this._localAudioPipeline?.setInputTrack(null);
|
|
15753
15771
|
}
|
|
15754
15772
|
get isNegotiating$() {
|
|
15755
15773
|
return this._isNegotiating$.asObservable();
|
|
@@ -16254,8 +16272,27 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16254
16272
|
await this.transceiverController?.setupRemoteTransceivers(this.type);
|
|
16255
16273
|
}
|
|
16256
16274
|
async restoreTrackSender(kind) {
|
|
16257
|
-
|
|
16258
|
-
if (
|
|
16275
|
+
const audioCovered = kind === "audio" || kind === "both";
|
|
16276
|
+
if (audioCovered && this._localAudioPipeline) await this.restoreRawAudioInputForPipeline();
|
|
16277
|
+
if (!audioCovered) await this.transceiverController?.restoreTrackSender(kind);
|
|
16278
|
+
else if (kind === "both") await this.transceiverController?.restoreTrackSender("video");
|
|
16279
|
+
else if (!this._localAudioPipeline) await this.transceiverController?.restoreTrackSender(kind);
|
|
16280
|
+
}
|
|
16281
|
+
async restoreRawAudioInputForPipeline() {
|
|
16282
|
+
if (!this._localAudioPipeline) return;
|
|
16283
|
+
const constraints = this.transceiverController?.getConstraintsFor("audio") ?? {};
|
|
16284
|
+
let stream;
|
|
16285
|
+
try {
|
|
16286
|
+
stream = await this.getUserMedia({ audio: constraints });
|
|
16287
|
+
} catch (error) {
|
|
16288
|
+
logger$16.error("[RTCPeerConnectionController] Failed to re-acquire mic for pipeline restore:", error);
|
|
16289
|
+
this._errors$.next(toError(error));
|
|
16290
|
+
return;
|
|
16291
|
+
}
|
|
16292
|
+
const newTrack = stream.getAudioTracks().at(0);
|
|
16293
|
+
if (!newTrack) return;
|
|
16294
|
+
this.localStreamController.addTrack(newTrack);
|
|
16295
|
+
this._localAudioPipeline.setInputTrack(newTrack);
|
|
16259
16296
|
}
|
|
16260
16297
|
/**
|
|
16261
16298
|
* Return the lazily-created {@link LocalAudioPipeline}, constructing it on
|
|
@@ -19618,7 +19655,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19618
19655
|
this._errors$ = this.createReplaySubject(1);
|
|
19619
19656
|
this._authState$ = this.createBehaviorSubject({ kind: "unauthenticated" });
|
|
19620
19657
|
this._wasClientBound = false;
|
|
19621
|
-
this.
|
|
19658
|
+
this._userInfo$ = this.createBehaviorSubject(null);
|
|
19622
19659
|
this._calls$ = this.createBehaviorSubject({});
|
|
19623
19660
|
this._iceServers$ = this.createBehaviorSubject([]);
|
|
19624
19661
|
attachManager.setSession(this);
|
|
@@ -19631,11 +19668,11 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19631
19668
|
get incomingCalls() {
|
|
19632
19669
|
return Object.values(this._calls$.value).filter((call) => call.direction === "inbound");
|
|
19633
19670
|
}
|
|
19634
|
-
get
|
|
19635
|
-
return this.
|
|
19671
|
+
get userInfo$() {
|
|
19672
|
+
return this._userInfo$.asObservable();
|
|
19636
19673
|
}
|
|
19637
|
-
get
|
|
19638
|
-
return this.
|
|
19674
|
+
get userInfo() {
|
|
19675
|
+
return this._userInfo$.value;
|
|
19639
19676
|
}
|
|
19640
19677
|
get calls$() {
|
|
19641
19678
|
return this.cachedObservable("calls$", () => this._calls$.pipe((0, import_cjs$7.map)((calls) => Object.values(calls))));
|
|
@@ -20081,22 +20118,22 @@ var ConversationMessageCollection = class extends EntityCollection {
|
|
|
20081
20118
|
}
|
|
20082
20119
|
};
|
|
20083
20120
|
var ConversationsManager = class {
|
|
20084
|
-
constructor(clientSession, http,
|
|
20121
|
+
constructor(clientSession, http, getUserAddressId, onError) {
|
|
20085
20122
|
this.clientSession = clientSession;
|
|
20086
20123
|
this.http = http;
|
|
20087
|
-
this.
|
|
20124
|
+
this.getUserAddressId = getUserAddressId;
|
|
20088
20125
|
this.onError = onError;
|
|
20089
20126
|
this.groupIds = /* @__PURE__ */ new Map();
|
|
20090
20127
|
}
|
|
20091
20128
|
async join(addressId) {
|
|
20092
|
-
const
|
|
20129
|
+
const userFromAddressId = this.getUserAddressId();
|
|
20093
20130
|
try {
|
|
20094
20131
|
const response = await this.http.request({
|
|
20095
20132
|
...POST_PARAMS,
|
|
20096
20133
|
url: `/api/fabric/conversations/join`,
|
|
20097
20134
|
body: JSON.stringify({
|
|
20098
|
-
from_fabric_address_id:
|
|
20099
|
-
fabric_address_ids: [addressId,
|
|
20135
|
+
from_fabric_address_id: userFromAddressId,
|
|
20136
|
+
fabric_address_ids: [addressId, userFromAddressId]
|
|
20100
20137
|
})
|
|
20101
20138
|
});
|
|
20102
20139
|
if (response.ok && !!response.body) {
|
|
@@ -20118,14 +20155,14 @@ var ConversationsManager = class {
|
|
|
20118
20155
|
}
|
|
20119
20156
|
async sendText(text, destinationAddressId) {
|
|
20120
20157
|
const groupId = this.groupIds.get(destinationAddressId) ?? await this.join(destinationAddressId);
|
|
20121
|
-
const
|
|
20158
|
+
const userFromAddressId = this.getUserAddressId();
|
|
20122
20159
|
try {
|
|
20123
20160
|
if ((await this.http.request({
|
|
20124
20161
|
...POST_PARAMS,
|
|
20125
20162
|
url: "/api/fabric/messages",
|
|
20126
20163
|
body: JSON.stringify({
|
|
20127
20164
|
group_id: groupId,
|
|
20128
|
-
from_fabric_address_id:
|
|
20165
|
+
from_fabric_address_id: userFromAddressId,
|
|
20129
20166
|
text
|
|
20130
20167
|
})
|
|
20131
20168
|
})).ok) return;
|
|
@@ -20198,17 +20235,17 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
20198
20235
|
return this._effectiveExpireIn;
|
|
20199
20236
|
}
|
|
20200
20237
|
/**
|
|
20201
|
-
* Activates the Client Bound SAT flow when the
|
|
20238
|
+
* Activates the Client Bound SAT flow when the user's token has
|
|
20202
20239
|
* `sat:refresh` scope.
|
|
20203
20240
|
*
|
|
20204
20241
|
* Steps:
|
|
20205
|
-
* 1. Check
|
|
20242
|
+
* 1. Check user's `sat_claims` for `sat:refresh` scope
|
|
20206
20243
|
* 2. Call `/api/fabric/subscriber/devices/token` with a DPoP proof
|
|
20207
20244
|
* 3. Reauthenticate the session with the Client Bound SAT + DPoP proof
|
|
20208
20245
|
* 4. Emit token to trigger the reactive refresh pipeline
|
|
20209
20246
|
*/
|
|
20210
|
-
async activate(
|
|
20211
|
-
const { satClaims } =
|
|
20247
|
+
async activate(user, session, updateCredential) {
|
|
20248
|
+
const { satClaims } = user;
|
|
20212
20249
|
if (!satClaims?.scope?.includes(SAT_REFRESH_SCOPE)) {
|
|
20213
20250
|
logger$6.debug("[DeviceToken] No sat:refresh scope, skipping Client Bound SAT activation");
|
|
20214
20251
|
return;
|
|
@@ -21055,7 +21092,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21055
21092
|
constructor(credentialProvider, options = {}) {
|
|
21056
21093
|
super();
|
|
21057
21094
|
this.preferences = new ClientPreferences();
|
|
21058
|
-
this.
|
|
21095
|
+
this._user$ = this.createBehaviorSubject(void 0);
|
|
21059
21096
|
this._directory$ = this.createBehaviorSubject(void 0);
|
|
21060
21097
|
this._isConnected$ = this.createBehaviorSubject(false);
|
|
21061
21098
|
this._isRegistered$ = this.createBehaviorSubject(false);
|
|
@@ -21195,7 +21232,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21195
21232
|
if (this._deps.persistSession) this._deps.storage.setItem("sw:cached_credential", credential, "local");
|
|
21196
21233
|
}
|
|
21197
21234
|
async init() {
|
|
21198
|
-
this.
|
|
21235
|
+
this._user$.next(new User(this._deps.http));
|
|
21199
21236
|
if (!this._options.skipConnection) await this.connect();
|
|
21200
21237
|
if (!this._options.reconnectAttachedCalls && this._attachManager) await this._attachManager.flush();
|
|
21201
21238
|
if (!this._options.skipRegister) try {
|
|
@@ -21259,13 +21296,13 @@ var SignalWire = class extends Destroyable {
|
|
|
21259
21296
|
async connect() {
|
|
21260
21297
|
await this.teardownTransportAndSession();
|
|
21261
21298
|
try {
|
|
21262
|
-
const
|
|
21263
|
-
if (!
|
|
21264
|
-
if (!await (0, import_cjs$1.firstValueFrom)(
|
|
21265
|
-
this._deps.
|
|
21299
|
+
const user = this._user$.value;
|
|
21300
|
+
if (!user) throw new UnexpectedError("User not initialized before connect");
|
|
21301
|
+
if (!await (0, import_cjs$1.firstValueFrom)(user.fetched$)) throw new UnexpectedError("Failed to fetch user information - fetched$ emitted false");
|
|
21302
|
+
this._deps.user = user;
|
|
21266
21303
|
} catch (error) {
|
|
21267
|
-
logger$1.error(`[SignalWire] Failed to fetch
|
|
21268
|
-
throw new UnexpectedError("Error fetching
|
|
21304
|
+
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.`);
|
|
21305
|
+
throw new UnexpectedError("Error fetching user information", { cause: error });
|
|
21269
21306
|
}
|
|
21270
21307
|
const errorHandler = (error) => {
|
|
21271
21308
|
this._errors$.next(error);
|
|
@@ -21299,7 +21336,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21299
21336
|
logger$1.debug("[SignalWire] Developer refresh disabled — Client Bound SAT activation starting");
|
|
21300
21337
|
}
|
|
21301
21338
|
this._deviceTokenManager = new DeviceTokenManager(this._dpopManager, this._deps.http, (error) => this._errors$.next(error), () => this._deps.credential);
|
|
21302
|
-
await this._deviceTokenManager.activate(this._deps.
|
|
21339
|
+
await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
|
|
21303
21340
|
this._deps.credential = {
|
|
21304
21341
|
...this._deps.credential,
|
|
21305
21342
|
...cred
|
|
@@ -21309,7 +21346,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21309
21346
|
this.subscribeTo(this._clientSession.authenticated$.pipe((0, import_cjs$1.skip)(1), (0, import_cjs$1.filter)(Boolean)), async () => {
|
|
21310
21347
|
try {
|
|
21311
21348
|
if (this._deviceTokenManager) {
|
|
21312
|
-
await this._deviceTokenManager.activate(this._deps.
|
|
21349
|
+
await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
|
|
21313
21350
|
this._deps.credential = {
|
|
21314
21351
|
...this._deps.credential,
|
|
21315
21352
|
...cred
|
|
@@ -21322,15 +21359,15 @@ var SignalWire = class extends Destroyable {
|
|
|
21322
21359
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21323
21360
|
}
|
|
21324
21361
|
try {
|
|
21325
|
-
logger$1.debug("[SignalWire] Re-registering
|
|
21362
|
+
logger$1.debug("[SignalWire] Re-registering user after reconnect");
|
|
21326
21363
|
await this.register();
|
|
21327
|
-
logger$1.debug("[SignalWire]
|
|
21364
|
+
logger$1.debug("[SignalWire] User re-registered successfully after reconnect");
|
|
21328
21365
|
} catch (error) {
|
|
21329
21366
|
logger$1.error("[SignalWire] Re-registration failed after reconnect:", error);
|
|
21330
21367
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21331
21368
|
}
|
|
21332
21369
|
});
|
|
21333
|
-
const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.
|
|
21370
|
+
const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.getUserFromAddressId(), errorHandler);
|
|
21334
21371
|
const directory = new DirectoryManager(this._deps.http, this._clientSession, conversationManager, errorHandler);
|
|
21335
21372
|
this._directory$.next(directory);
|
|
21336
21373
|
this._clientSession.setDirectory(directory);
|
|
@@ -21341,22 +21378,22 @@ var SignalWire = class extends Destroyable {
|
|
|
21341
21378
|
});
|
|
21342
21379
|
}
|
|
21343
21380
|
/**
|
|
21344
|
-
* Observable that emits the {@link
|
|
21381
|
+
* Observable that emits the {@link User} profile once fetched,
|
|
21345
21382
|
* or `undefined` before authentication completes.
|
|
21346
21383
|
*
|
|
21347
21384
|
* @example
|
|
21348
21385
|
* ```ts
|
|
21349
|
-
* client.
|
|
21350
|
-
* if (
|
|
21386
|
+
* client.user$.subscribe(u => {
|
|
21387
|
+
* if (u) console.log('Logged in as', u.email);
|
|
21351
21388
|
* });
|
|
21352
21389
|
* ```
|
|
21353
21390
|
*/
|
|
21354
|
-
get
|
|
21355
|
-
return this.deferEmission(this.
|
|
21391
|
+
get user$() {
|
|
21392
|
+
return this.deferEmission(this._user$.asObservable());
|
|
21356
21393
|
}
|
|
21357
|
-
/** Current
|
|
21358
|
-
get
|
|
21359
|
-
return this.
|
|
21394
|
+
/** Current user snapshot, or `undefined` if not yet authenticated. */
|
|
21395
|
+
get user() {
|
|
21396
|
+
return this._user$.value;
|
|
21360
21397
|
}
|
|
21361
21398
|
/**
|
|
21362
21399
|
* Observable that emits the {@link Directory} instance once the client is connected,
|
|
@@ -21380,11 +21417,11 @@ var SignalWire = class extends Destroyable {
|
|
|
21380
21417
|
get directory() {
|
|
21381
21418
|
return this._directory$.value;
|
|
21382
21419
|
}
|
|
21383
|
-
/** Observable that emits when the
|
|
21420
|
+
/** Observable that emits when the user registration state changes. */
|
|
21384
21421
|
get isRegistered$() {
|
|
21385
21422
|
return this.deferEmission(this._isRegistered$.asObservable());
|
|
21386
21423
|
}
|
|
21387
|
-
/** Whether the
|
|
21424
|
+
/** Whether the user is currently registered. */
|
|
21388
21425
|
get isRegistered() {
|
|
21389
21426
|
return this._isRegistered$.value;
|
|
21390
21427
|
}
|
|
@@ -21517,7 +21554,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21517
21554
|
await (0, import_cjs$1.firstValueFrom)(this.ready$.pipe((0, import_cjs$1.filter)((ready$1) => ready$1 === true)));
|
|
21518
21555
|
}
|
|
21519
21556
|
/**
|
|
21520
|
-
* Registers the
|
|
21557
|
+
* Registers the user as online to receive inbound calls and events.
|
|
21521
21558
|
*
|
|
21522
21559
|
* Waits for authentication to complete before sending the registration.
|
|
21523
21560
|
* If the initial attempt fails, reauthentication is attempted automatically.
|
|
@@ -21538,7 +21575,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21538
21575
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21539
21576
|
throw error;
|
|
21540
21577
|
}
|
|
21541
|
-
logger$1.debug("[SignalWire] Failed to register
|
|
21578
|
+
logger$1.debug("[SignalWire] Failed to register user, trying reauthentication...");
|
|
21542
21579
|
try {
|
|
21543
21580
|
await this._clientSession.reauthenticate(this._deps.credential.token);
|
|
21544
21581
|
logger$1.debug("[SignalWire] Reauthentication successful, retrying register()");
|
|
@@ -21549,14 +21586,14 @@ var SignalWire = class extends Destroyable {
|
|
|
21549
21586
|
this._isRegistered$.next(true);
|
|
21550
21587
|
} catch (reauthError) {
|
|
21551
21588
|
logger$1.error("[SignalWire] Reauthentication failed during register():", reauthError);
|
|
21552
|
-
const registerError = new InvalidCredentialsError("Failed to register
|
|
21589
|
+
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 }) });
|
|
21553
21590
|
this._errors$.next(registerError);
|
|
21554
21591
|
throw registerError;
|
|
21555
21592
|
}
|
|
21556
21593
|
}
|
|
21557
21594
|
}
|
|
21558
21595
|
/**
|
|
21559
|
-
* Unregisters the
|
|
21596
|
+
* Unregisters the user, going offline for inbound calls.
|
|
21560
21597
|
*
|
|
21561
21598
|
* The WebSocket connection remains open; use {@link disconnect} to fully close it.
|
|
21562
21599
|
*/
|
|
@@ -21568,7 +21605,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21568
21605
|
}));
|
|
21569
21606
|
this._isRegistered$.next(false);
|
|
21570
21607
|
} catch (error) {
|
|
21571
|
-
logger$1.error("[SignalWire] Failed to unregister
|
|
21608
|
+
logger$1.error("[SignalWire] Failed to unregister user:", error);
|
|
21572
21609
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21573
21610
|
throw error;
|
|
21574
21611
|
}
|
|
@@ -22043,5 +22080,5 @@ emitReadyEvent();
|
|
|
22043
22080
|
if (typeof process === "undefined") globalThis.process = { env: { NODE_ENV: "production" } };
|
|
22044
22081
|
|
|
22045
22082
|
//#endregion
|
|
22046
|
-
export { Address, CallCreateError, ClientPreferences, CollectionFetchError, DPoPInitError, DeviceTokenError, EmbedTokenCredentialProvider, InvalidCredentialsError, MediaTrackError, MessageParseError, OverconstrainedFallbackError, Participant, PreflightError, RecoveryError, SelfCapabilities, SelfParticipant, SignalWire, StaticCredentialProvider,
|
|
22083
|
+
export { Address, CallCreateError, ClientPreferences, CollectionFetchError, DPoPInitError, DeviceTokenError, EmbedTokenCredentialProvider, InvalidCredentialsError, MediaTrackError, MessageParseError, OverconstrainedFallbackError, Participant, PreflightError, RecoveryError, SelfCapabilities, SelfParticipant, SignalWire, StaticCredentialProvider, TokenRefreshError, UnexpectedError, User, VertoPongError, WebRTCCall, embeddableCall, getLogger, isSelfParticipant, ready, setDebugOptions, setLogLevel, setLogger, version };
|
|
22047
22084
|
//# sourceMappingURL=browser.mjs.map
|