@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.umd.js
CHANGED
|
@@ -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
|
|
465
|
-
__extends$16(Subscriber$
|
|
466
|
-
function Subscriber$
|
|
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$
|
|
475
|
+
Subscriber$1.create = function(next, error, complete) {
|
|
476
476
|
return new SafeSubscriber(next, error, complete);
|
|
477
477
|
};
|
|
478
|
-
Subscriber$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
503
|
+
Subscriber$1.prototype._next = function(value) {
|
|
504
504
|
this.destination.next(value);
|
|
505
505
|
};
|
|
506
|
-
Subscriber$
|
|
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$
|
|
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$
|
|
520
|
+
return Subscriber$1;
|
|
521
521
|
}(Subscription_1$10.Subscription);
|
|
522
|
-
exports.Subscriber = Subscriber
|
|
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
|
|
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
|
|
11223
|
-
return this.
|
|
11222
|
+
get userId() {
|
|
11223
|
+
return this.user.id;
|
|
11224
11224
|
}
|
|
11225
|
-
get
|
|
11226
|
-
if (!this.
|
|
11227
|
-
return this.
|
|
11225
|
+
get user() {
|
|
11226
|
+
if (!this._user) throw new DependencyError("User");
|
|
11227
|
+
return this._user;
|
|
11228
11228
|
}
|
|
11229
|
-
set
|
|
11230
|
-
this.
|
|
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.
|
|
11276
|
+
return `sw:${this.userId}:as`;
|
|
11277
11277
|
}
|
|
11278
11278
|
get protocolKey() {
|
|
11279
|
-
return `sw:${this.
|
|
11279
|
+
return `sw:${this.userId}:pt`;
|
|
11280
11280
|
}
|
|
11281
11281
|
get attachedCallsKey() {
|
|
11282
|
-
return `sw:${this.
|
|
11282
|
+
return `sw:${this.userId}:att`;
|
|
11283
11283
|
}
|
|
11284
|
-
|
|
11285
|
-
return this.
|
|
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/
|
|
12115
|
+
//#region src/core/entities/User.ts
|
|
12116
12116
|
/**
|
|
12117
|
-
* Authenticated
|
|
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
|
|
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
|
|
13717
|
-
get
|
|
13718
|
-
return this.cachedObservable("
|
|
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
|
-
/**
|
|
13823
|
-
get
|
|
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. */
|
|
@@ -15427,6 +15427,12 @@ var TransceiverController = class extends Destroyable {
|
|
|
15427
15427
|
scaleResolutionDownBy: Number(rid) * 6 || 1
|
|
15428
15428
|
}));
|
|
15429
15429
|
}
|
|
15430
|
+
/**
|
|
15431
|
+
* Resolve the current MediaTrackConstraints for an input kind, normalising
|
|
15432
|
+
* boolean shorthand to an empty object. Public so the surrounding
|
|
15433
|
+
* RTCPeerConnectionController can drive its own pipeline-aware getUserMedia
|
|
15434
|
+
* call with the same effective constraints the transceiver would have used.
|
|
15435
|
+
*/
|
|
15430
15436
|
getConstraintsFor(kind) {
|
|
15431
15437
|
const constraints = kind === "audio" ? this.inputAudioDeviceConstraints : this.inputVideoDeviceConstraints;
|
|
15432
15438
|
return typeof constraints === "boolean" ? {} : constraints;
|
|
@@ -15753,7 +15759,19 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
15753
15759
|
return this._memberId;
|
|
15754
15760
|
}
|
|
15755
15761
|
stopTrackSender(kind, options = { updateTransceiverDirection: false }) {
|
|
15756
|
-
|
|
15762
|
+
const audioCovered = kind === "audio" || kind === "both";
|
|
15763
|
+
if (audioCovered && this._localAudioPipeline) this.stopRawAudioInputForPipeline();
|
|
15764
|
+
if (!audioCovered) this.transceiverController?.stopTrackSender(kind, options);
|
|
15765
|
+
else if (kind === "both") this.transceiverController?.stopTrackSender("video", options);
|
|
15766
|
+
else if (!this._localAudioPipeline) this.transceiverController?.stopTrackSender(kind, options);
|
|
15767
|
+
}
|
|
15768
|
+
stopRawAudioInputForPipeline() {
|
|
15769
|
+
const rawTracks = this.localStreamController.localAudioTracks;
|
|
15770
|
+
for (const track of rawTracks) if (track.readyState === "live") {
|
|
15771
|
+
track.stop();
|
|
15772
|
+
this.localStreamController.removeTrack(track.id);
|
|
15773
|
+
}
|
|
15774
|
+
this._localAudioPipeline?.setInputTrack(null);
|
|
15757
15775
|
}
|
|
15758
15776
|
get isNegotiating$() {
|
|
15759
15777
|
return this._isNegotiating$.asObservable();
|
|
@@ -16258,8 +16276,27 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
16258
16276
|
await this.transceiverController?.setupRemoteTransceivers(this.type);
|
|
16259
16277
|
}
|
|
16260
16278
|
async restoreTrackSender(kind) {
|
|
16261
|
-
|
|
16262
|
-
if (
|
|
16279
|
+
const audioCovered = kind === "audio" || kind === "both";
|
|
16280
|
+
if (audioCovered && this._localAudioPipeline) await this.restoreRawAudioInputForPipeline();
|
|
16281
|
+
if (!audioCovered) await this.transceiverController?.restoreTrackSender(kind);
|
|
16282
|
+
else if (kind === "both") await this.transceiverController?.restoreTrackSender("video");
|
|
16283
|
+
else if (!this._localAudioPipeline) await this.transceiverController?.restoreTrackSender(kind);
|
|
16284
|
+
}
|
|
16285
|
+
async restoreRawAudioInputForPipeline() {
|
|
16286
|
+
if (!this._localAudioPipeline) return;
|
|
16287
|
+
const constraints = this.transceiverController?.getConstraintsFor("audio") ?? {};
|
|
16288
|
+
let stream;
|
|
16289
|
+
try {
|
|
16290
|
+
stream = await this.getUserMedia({ audio: constraints });
|
|
16291
|
+
} catch (error) {
|
|
16292
|
+
logger$16.error("[RTCPeerConnectionController] Failed to re-acquire mic for pipeline restore:", error);
|
|
16293
|
+
this._errors$.next(toError(error));
|
|
16294
|
+
return;
|
|
16295
|
+
}
|
|
16296
|
+
const newTrack = stream.getAudioTracks().at(0);
|
|
16297
|
+
if (!newTrack) return;
|
|
16298
|
+
this.localStreamController.addTrack(newTrack);
|
|
16299
|
+
this._localAudioPipeline.setInputTrack(newTrack);
|
|
16263
16300
|
}
|
|
16264
16301
|
/**
|
|
16265
16302
|
* Return the lazily-created {@link LocalAudioPipeline}, constructing it on
|
|
@@ -19622,7 +19659,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19622
19659
|
this._errors$ = this.createReplaySubject(1);
|
|
19623
19660
|
this._authState$ = this.createBehaviorSubject({ kind: "unauthenticated" });
|
|
19624
19661
|
this._wasClientBound = false;
|
|
19625
|
-
this.
|
|
19662
|
+
this._userInfo$ = this.createBehaviorSubject(null);
|
|
19626
19663
|
this._calls$ = this.createBehaviorSubject({});
|
|
19627
19664
|
this._iceServers$ = this.createBehaviorSubject([]);
|
|
19628
19665
|
attachManager.setSession(this);
|
|
@@ -19635,11 +19672,11 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
19635
19672
|
get incomingCalls() {
|
|
19636
19673
|
return Object.values(this._calls$.value).filter((call) => call.direction === "inbound");
|
|
19637
19674
|
}
|
|
19638
|
-
get
|
|
19639
|
-
return this.
|
|
19675
|
+
get userInfo$() {
|
|
19676
|
+
return this._userInfo$.asObservable();
|
|
19640
19677
|
}
|
|
19641
|
-
get
|
|
19642
|
-
return this.
|
|
19678
|
+
get userInfo() {
|
|
19679
|
+
return this._userInfo$.value;
|
|
19643
19680
|
}
|
|
19644
19681
|
get calls$() {
|
|
19645
19682
|
return this.cachedObservable("calls$", () => this._calls$.pipe((0, import_cjs$7.map)((calls) => Object.values(calls))));
|
|
@@ -20085,22 +20122,22 @@ var ConversationMessageCollection = class extends EntityCollection {
|
|
|
20085
20122
|
}
|
|
20086
20123
|
};
|
|
20087
20124
|
var ConversationsManager = class {
|
|
20088
|
-
constructor(clientSession, http,
|
|
20125
|
+
constructor(clientSession, http, getUserAddressId, onError) {
|
|
20089
20126
|
this.clientSession = clientSession;
|
|
20090
20127
|
this.http = http;
|
|
20091
|
-
this.
|
|
20128
|
+
this.getUserAddressId = getUserAddressId;
|
|
20092
20129
|
this.onError = onError;
|
|
20093
20130
|
this.groupIds = /* @__PURE__ */ new Map();
|
|
20094
20131
|
}
|
|
20095
20132
|
async join(addressId) {
|
|
20096
|
-
const
|
|
20133
|
+
const userFromAddressId = this.getUserAddressId();
|
|
20097
20134
|
try {
|
|
20098
20135
|
const response = await this.http.request({
|
|
20099
20136
|
...POST_PARAMS,
|
|
20100
20137
|
url: `/api/fabric/conversations/join`,
|
|
20101
20138
|
body: JSON.stringify({
|
|
20102
|
-
from_fabric_address_id:
|
|
20103
|
-
fabric_address_ids: [addressId,
|
|
20139
|
+
from_fabric_address_id: userFromAddressId,
|
|
20140
|
+
fabric_address_ids: [addressId, userFromAddressId]
|
|
20104
20141
|
})
|
|
20105
20142
|
});
|
|
20106
20143
|
if (response.ok && !!response.body) {
|
|
@@ -20122,14 +20159,14 @@ var ConversationsManager = class {
|
|
|
20122
20159
|
}
|
|
20123
20160
|
async sendText(text, destinationAddressId) {
|
|
20124
20161
|
const groupId = this.groupIds.get(destinationAddressId) ?? await this.join(destinationAddressId);
|
|
20125
|
-
const
|
|
20162
|
+
const userFromAddressId = this.getUserAddressId();
|
|
20126
20163
|
try {
|
|
20127
20164
|
if ((await this.http.request({
|
|
20128
20165
|
...POST_PARAMS,
|
|
20129
20166
|
url: "/api/fabric/messages",
|
|
20130
20167
|
body: JSON.stringify({
|
|
20131
20168
|
group_id: groupId,
|
|
20132
|
-
from_fabric_address_id:
|
|
20169
|
+
from_fabric_address_id: userFromAddressId,
|
|
20133
20170
|
text
|
|
20134
20171
|
})
|
|
20135
20172
|
})).ok) return;
|
|
@@ -20202,17 +20239,17 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
20202
20239
|
return this._effectiveExpireIn;
|
|
20203
20240
|
}
|
|
20204
20241
|
/**
|
|
20205
|
-
* Activates the Client Bound SAT flow when the
|
|
20242
|
+
* Activates the Client Bound SAT flow when the user's token has
|
|
20206
20243
|
* `sat:refresh` scope.
|
|
20207
20244
|
*
|
|
20208
20245
|
* Steps:
|
|
20209
|
-
* 1. Check
|
|
20246
|
+
* 1. Check user's `sat_claims` for `sat:refresh` scope
|
|
20210
20247
|
* 2. Call `/api/fabric/subscriber/devices/token` with a DPoP proof
|
|
20211
20248
|
* 3. Reauthenticate the session with the Client Bound SAT + DPoP proof
|
|
20212
20249
|
* 4. Emit token to trigger the reactive refresh pipeline
|
|
20213
20250
|
*/
|
|
20214
|
-
async activate(
|
|
20215
|
-
const { satClaims } =
|
|
20251
|
+
async activate(user, session, updateCredential) {
|
|
20252
|
+
const { satClaims } = user;
|
|
20216
20253
|
if (!satClaims?.scope?.includes(SAT_REFRESH_SCOPE)) {
|
|
20217
20254
|
logger$6.debug("[DeviceToken] No sat:refresh scope, skipping Client Bound SAT activation");
|
|
20218
20255
|
return;
|
|
@@ -21059,7 +21096,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21059
21096
|
constructor(credentialProvider, options = {}) {
|
|
21060
21097
|
super();
|
|
21061
21098
|
this.preferences = new ClientPreferences();
|
|
21062
|
-
this.
|
|
21099
|
+
this._user$ = this.createBehaviorSubject(void 0);
|
|
21063
21100
|
this._directory$ = this.createBehaviorSubject(void 0);
|
|
21064
21101
|
this._isConnected$ = this.createBehaviorSubject(false);
|
|
21065
21102
|
this._isRegistered$ = this.createBehaviorSubject(false);
|
|
@@ -21199,7 +21236,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21199
21236
|
if (this._deps.persistSession) this._deps.storage.setItem("sw:cached_credential", credential, "local");
|
|
21200
21237
|
}
|
|
21201
21238
|
async init() {
|
|
21202
|
-
this.
|
|
21239
|
+
this._user$.next(new User(this._deps.http));
|
|
21203
21240
|
if (!this._options.skipConnection) await this.connect();
|
|
21204
21241
|
if (!this._options.reconnectAttachedCalls && this._attachManager) await this._attachManager.flush();
|
|
21205
21242
|
if (!this._options.skipRegister) try {
|
|
@@ -21263,13 +21300,13 @@ var SignalWire = class extends Destroyable {
|
|
|
21263
21300
|
async connect() {
|
|
21264
21301
|
await this.teardownTransportAndSession();
|
|
21265
21302
|
try {
|
|
21266
|
-
const
|
|
21267
|
-
if (!
|
|
21268
|
-
if (!await (0, import_cjs$1.firstValueFrom)(
|
|
21269
|
-
this._deps.
|
|
21303
|
+
const user = this._user$.value;
|
|
21304
|
+
if (!user) throw new UnexpectedError("User not initialized before connect");
|
|
21305
|
+
if (!await (0, import_cjs$1.firstValueFrom)(user.fetched$)) throw new UnexpectedError("Failed to fetch user information - fetched$ emitted false");
|
|
21306
|
+
this._deps.user = user;
|
|
21270
21307
|
} catch (error) {
|
|
21271
|
-
logger$1.error(`[SignalWire] Failed to fetch
|
|
21272
|
-
throw new UnexpectedError("Error fetching
|
|
21308
|
+
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.`);
|
|
21309
|
+
throw new UnexpectedError("Error fetching user information", { cause: error });
|
|
21273
21310
|
}
|
|
21274
21311
|
const errorHandler = (error) => {
|
|
21275
21312
|
this._errors$.next(error);
|
|
@@ -21303,7 +21340,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21303
21340
|
logger$1.debug("[SignalWire] Developer refresh disabled — Client Bound SAT activation starting");
|
|
21304
21341
|
}
|
|
21305
21342
|
this._deviceTokenManager = new DeviceTokenManager(this._dpopManager, this._deps.http, (error) => this._errors$.next(error), () => this._deps.credential);
|
|
21306
|
-
await this._deviceTokenManager.activate(this._deps.
|
|
21343
|
+
await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
|
|
21307
21344
|
this._deps.credential = {
|
|
21308
21345
|
...this._deps.credential,
|
|
21309
21346
|
...cred
|
|
@@ -21313,7 +21350,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21313
21350
|
this.subscribeTo(this._clientSession.authenticated$.pipe((0, import_cjs$1.skip)(1), (0, import_cjs$1.filter)(Boolean)), async () => {
|
|
21314
21351
|
try {
|
|
21315
21352
|
if (this._deviceTokenManager) {
|
|
21316
|
-
await this._deviceTokenManager.activate(this._deps.
|
|
21353
|
+
await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
|
|
21317
21354
|
this._deps.credential = {
|
|
21318
21355
|
...this._deps.credential,
|
|
21319
21356
|
...cred
|
|
@@ -21326,15 +21363,15 @@ var SignalWire = class extends Destroyable {
|
|
|
21326
21363
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21327
21364
|
}
|
|
21328
21365
|
try {
|
|
21329
|
-
logger$1.debug("[SignalWire] Re-registering
|
|
21366
|
+
logger$1.debug("[SignalWire] Re-registering user after reconnect");
|
|
21330
21367
|
await this.register();
|
|
21331
|
-
logger$1.debug("[SignalWire]
|
|
21368
|
+
logger$1.debug("[SignalWire] User re-registered successfully after reconnect");
|
|
21332
21369
|
} catch (error) {
|
|
21333
21370
|
logger$1.error("[SignalWire] Re-registration failed after reconnect:", error);
|
|
21334
21371
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21335
21372
|
}
|
|
21336
21373
|
});
|
|
21337
|
-
const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.
|
|
21374
|
+
const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.getUserFromAddressId(), errorHandler);
|
|
21338
21375
|
const directory = new DirectoryManager(this._deps.http, this._clientSession, conversationManager, errorHandler);
|
|
21339
21376
|
this._directory$.next(directory);
|
|
21340
21377
|
this._clientSession.setDirectory(directory);
|
|
@@ -21345,22 +21382,22 @@ var SignalWire = class extends Destroyable {
|
|
|
21345
21382
|
});
|
|
21346
21383
|
}
|
|
21347
21384
|
/**
|
|
21348
|
-
* Observable that emits the {@link
|
|
21385
|
+
* Observable that emits the {@link User} profile once fetched,
|
|
21349
21386
|
* or `undefined` before authentication completes.
|
|
21350
21387
|
*
|
|
21351
21388
|
* @example
|
|
21352
21389
|
* ```ts
|
|
21353
|
-
* client.
|
|
21354
|
-
* if (
|
|
21390
|
+
* client.user$.subscribe(u => {
|
|
21391
|
+
* if (u) console.log('Logged in as', u.email);
|
|
21355
21392
|
* });
|
|
21356
21393
|
* ```
|
|
21357
21394
|
*/
|
|
21358
|
-
get
|
|
21359
|
-
return this.deferEmission(this.
|
|
21395
|
+
get user$() {
|
|
21396
|
+
return this.deferEmission(this._user$.asObservable());
|
|
21360
21397
|
}
|
|
21361
|
-
/** Current
|
|
21362
|
-
get
|
|
21363
|
-
return this.
|
|
21398
|
+
/** Current user snapshot, or `undefined` if not yet authenticated. */
|
|
21399
|
+
get user() {
|
|
21400
|
+
return this._user$.value;
|
|
21364
21401
|
}
|
|
21365
21402
|
/**
|
|
21366
21403
|
* Observable that emits the {@link Directory} instance once the client is connected,
|
|
@@ -21384,11 +21421,11 @@ var SignalWire = class extends Destroyable {
|
|
|
21384
21421
|
get directory() {
|
|
21385
21422
|
return this._directory$.value;
|
|
21386
21423
|
}
|
|
21387
|
-
/** Observable that emits when the
|
|
21424
|
+
/** Observable that emits when the user registration state changes. */
|
|
21388
21425
|
get isRegistered$() {
|
|
21389
21426
|
return this.deferEmission(this._isRegistered$.asObservable());
|
|
21390
21427
|
}
|
|
21391
|
-
/** Whether the
|
|
21428
|
+
/** Whether the user is currently registered. */
|
|
21392
21429
|
get isRegistered() {
|
|
21393
21430
|
return this._isRegistered$.value;
|
|
21394
21431
|
}
|
|
@@ -21521,7 +21558,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21521
21558
|
await (0, import_cjs$1.firstValueFrom)(this.ready$.pipe((0, import_cjs$1.filter)((ready$1) => ready$1 === true)));
|
|
21522
21559
|
}
|
|
21523
21560
|
/**
|
|
21524
|
-
* Registers the
|
|
21561
|
+
* Registers the user as online to receive inbound calls and events.
|
|
21525
21562
|
*
|
|
21526
21563
|
* Waits for authentication to complete before sending the registration.
|
|
21527
21564
|
* If the initial attempt fails, reauthentication is attempted automatically.
|
|
@@ -21542,7 +21579,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21542
21579
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21543
21580
|
throw error;
|
|
21544
21581
|
}
|
|
21545
|
-
logger$1.debug("[SignalWire] Failed to register
|
|
21582
|
+
logger$1.debug("[SignalWire] Failed to register user, trying reauthentication...");
|
|
21546
21583
|
try {
|
|
21547
21584
|
await this._clientSession.reauthenticate(this._deps.credential.token);
|
|
21548
21585
|
logger$1.debug("[SignalWire] Reauthentication successful, retrying register()");
|
|
@@ -21553,14 +21590,14 @@ var SignalWire = class extends Destroyable {
|
|
|
21553
21590
|
this._isRegistered$.next(true);
|
|
21554
21591
|
} catch (reauthError) {
|
|
21555
21592
|
logger$1.error("[SignalWire] Reauthentication failed during register():", reauthError);
|
|
21556
|
-
const registerError = new InvalidCredentialsError("Failed to register
|
|
21593
|
+
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
21594
|
this._errors$.next(registerError);
|
|
21558
21595
|
throw registerError;
|
|
21559
21596
|
}
|
|
21560
21597
|
}
|
|
21561
21598
|
}
|
|
21562
21599
|
/**
|
|
21563
|
-
* Unregisters the
|
|
21600
|
+
* Unregisters the user, going offline for inbound calls.
|
|
21564
21601
|
*
|
|
21565
21602
|
* The WebSocket connection remains open; use {@link disconnect} to fully close it.
|
|
21566
21603
|
*/
|
|
@@ -21572,7 +21609,7 @@ var SignalWire = class extends Destroyable {
|
|
|
21572
21609
|
}));
|
|
21573
21610
|
this._isRegistered$.next(false);
|
|
21574
21611
|
} catch (error) {
|
|
21575
|
-
logger$1.error("[SignalWire] Failed to unregister
|
|
21612
|
+
logger$1.error("[SignalWire] Failed to unregister user:", error);
|
|
21576
21613
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
21577
21614
|
throw error;
|
|
21578
21615
|
}
|
|
@@ -22065,9 +22102,9 @@ exports.SelfCapabilities = SelfCapabilities;
|
|
|
22065
22102
|
exports.SelfParticipant = SelfParticipant;
|
|
22066
22103
|
exports.SignalWire = SignalWire;
|
|
22067
22104
|
exports.StaticCredentialProvider = StaticCredentialProvider;
|
|
22068
|
-
exports.Subscriber = Subscriber;
|
|
22069
22105
|
exports.TokenRefreshError = TokenRefreshError;
|
|
22070
22106
|
exports.UnexpectedError = UnexpectedError;
|
|
22107
|
+
exports.User = User;
|
|
22071
22108
|
exports.VertoPongError = VertoPongError;
|
|
22072
22109
|
exports.WebRTCCall = WebRTCCall;
|
|
22073
22110
|
exports.embeddableCall = embeddableCall;
|