@signalwire/js 4.0.0-dev-20261126145046 → 4.0.0-dev-20261126194627
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 +69 -10
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +69 -10
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +69 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +35 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +69 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser.mjs
CHANGED
|
@@ -22742,6 +22742,7 @@ var SignalWire = class extends Destroyable {
|
|
|
22742
22742
|
this._credentialRecovered = false;
|
|
22743
22743
|
this._isConnected$ = this.createBehaviorSubject(false);
|
|
22744
22744
|
this._isRegistered$ = this.createBehaviorSubject(false);
|
|
22745
|
+
this._registrationIntended = false;
|
|
22745
22746
|
this._errors$ = this.createReplaySubject(1);
|
|
22746
22747
|
this._warnings$ = this.createReplaySubject(10);
|
|
22747
22748
|
this._options = {};
|
|
@@ -22751,6 +22752,7 @@ var SignalWire = class extends Destroyable {
|
|
|
22751
22752
|
...PreferencesContainer.instance.defaultSignalWireOptions,
|
|
22752
22753
|
...options
|
|
22753
22754
|
};
|
|
22755
|
+
this._registrationIntended = !this._options.skipRegister;
|
|
22754
22756
|
if (this._options.storageImplementation) this._deps.storageImpl = this._options.storageImplementation;
|
|
22755
22757
|
if (this._options.persistSession) this._deps.persistSession = true;
|
|
22756
22758
|
if (this._options.webSocketConstructor) this._deps.WebSocket = this._options.webSocketConstructor;
|
|
@@ -23061,15 +23063,23 @@ var SignalWire = class extends Destroyable {
|
|
|
23061
23063
|
}
|
|
23062
23064
|
async init() {
|
|
23063
23065
|
this._user$.next(new User(this._deps.http));
|
|
23064
|
-
if (!this._options.skipConnection) await this.
|
|
23066
|
+
if (!this._options.skipConnection) await this.openSession();
|
|
23065
23067
|
if (!this._options.reconnectAttachedCalls && this._attachManager) await this._attachManager.flush();
|
|
23066
|
-
|
|
23068
|
+
await this.registerIfIntended();
|
|
23069
|
+
this.handleAttachments();
|
|
23070
|
+
}
|
|
23071
|
+
async registerIfIntended() {
|
|
23072
|
+
if (!this._registrationIntended || this.isRegistered) return;
|
|
23073
|
+
if (this._pendingRegistration) {
|
|
23074
|
+
await this._pendingRegistration.catch(() => void 0);
|
|
23075
|
+
return;
|
|
23076
|
+
}
|
|
23077
|
+
try {
|
|
23067
23078
|
await this.register();
|
|
23068
23079
|
} catch (error) {
|
|
23069
23080
|
logger$1.error("[SignalWire] Registration failed:", error);
|
|
23070
23081
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
23071
23082
|
}
|
|
23072
|
-
this.handleAttachments();
|
|
23073
23083
|
}
|
|
23074
23084
|
async handleAttachments() {
|
|
23075
23085
|
if (!this._attachManager) {
|
|
@@ -23121,7 +23131,18 @@ var SignalWire = class extends Destroyable {
|
|
|
23121
23131
|
}
|
|
23122
23132
|
}
|
|
23123
23133
|
/**
|
|
23124
|
-
* Establishes the WebSocket connection
|
|
23134
|
+
* Establishes the WebSocket connection, authenticates the session, and
|
|
23135
|
+
* registers the user to receive inbound calls (see {@link register}).
|
|
23136
|
+
*
|
|
23137
|
+
* Registration is skipped while the client is opted out: constructed with
|
|
23138
|
+
* `skipRegister` and not yet {@link register | registered}, or after
|
|
23139
|
+
* {@link unregister}. A failed registration does not reject `connect()`; it
|
|
23140
|
+
* is reported on {@link errors$} and leaves {@link isRegistered} `false`.
|
|
23141
|
+
*
|
|
23142
|
+
* Connecting and registering can each await the credential provider's
|
|
23143
|
+
* `refresh()` or `authenticate()` to re-mint the credential. The SDK sets no
|
|
23144
|
+
* time limit on those calls, so `connect()` can take as long as they do;
|
|
23145
|
+
* avoid wrapping it in a short timeout.
|
|
23125
23146
|
*
|
|
23126
23147
|
* ## Reconnection behavior
|
|
23127
23148
|
*
|
|
@@ -23137,6 +23158,9 @@ var SignalWire = class extends Destroyable {
|
|
|
23137
23158
|
* - A per-attempt `connectionTimeout` (default **10 s**) aborts the
|
|
23138
23159
|
* attempt and schedules the next retry if the server does not respond.
|
|
23139
23160
|
*
|
|
23161
|
+
* Once a reconnected session authenticates, the user is registered again
|
|
23162
|
+
* unless the client is opted out.
|
|
23163
|
+
*
|
|
23140
23164
|
* Calling {@link disconnect} stops the reconnection loop entirely.
|
|
23141
23165
|
*
|
|
23142
23166
|
* ## Message handling during temporary disconnections
|
|
@@ -23158,6 +23182,10 @@ var SignalWire = class extends Destroyable {
|
|
|
23158
23182
|
* `'reconnecting'`, `'disconnecting'`, or `'disconnected'`.
|
|
23159
23183
|
*/
|
|
23160
23184
|
async connect() {
|
|
23185
|
+
await this.openSession();
|
|
23186
|
+
await this.registerIfIntended();
|
|
23187
|
+
}
|
|
23188
|
+
async openSession() {
|
|
23161
23189
|
await this.teardownTransportAndSession();
|
|
23162
23190
|
await this.fetchUserOrRecover();
|
|
23163
23191
|
const errorHandler = (error) => {
|
|
@@ -23179,6 +23207,9 @@ var SignalWire = class extends Destroyable {
|
|
|
23179
23207
|
await this._clientSession.connect();
|
|
23180
23208
|
this._clientSession.onAuthenticationRejected = () => void this.disconnect();
|
|
23181
23209
|
await this._refreshCoordinator?.activate(this._deps.user, this._clientSession);
|
|
23210
|
+
this.subscribeTo(this._clientSession.authenticated$.pipe((0, import_cjs$1.filter)((authenticated) => !authenticated)), () => {
|
|
23211
|
+
this._pendingRegistration = void 0;
|
|
23212
|
+
});
|
|
23182
23213
|
this.subscribeTo(this._clientSession.authenticated$.pipe((0, import_cjs$1.skip)(1), (0, import_cjs$1.filter)(Boolean)), async () => {
|
|
23183
23214
|
try {
|
|
23184
23215
|
await this._refreshCoordinator?.activate(this._deps.user, this._clientSession);
|
|
@@ -23186,6 +23217,7 @@ var SignalWire = class extends Destroyable {
|
|
|
23186
23217
|
logger$1.error("[SignalWire] Refresh re-arm after reconnect failed (non-fatal):", error);
|
|
23187
23218
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
23188
23219
|
}
|
|
23220
|
+
if (!this._registrationIntended) return;
|
|
23189
23221
|
try {
|
|
23190
23222
|
logger$1.debug("[SignalWire] Re-registering user after reconnect");
|
|
23191
23223
|
await this.register();
|
|
@@ -23357,7 +23389,7 @@ var SignalWire = class extends Destroyable {
|
|
|
23357
23389
|
logger$1.warn("[SignalWire] Failed to initialize VisibilityController:", error);
|
|
23358
23390
|
}
|
|
23359
23391
|
try {
|
|
23360
|
-
this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "4.0.0-dev-
|
|
23392
|
+
this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "4.0.0-dev-20261126194627" });
|
|
23361
23393
|
} catch (error) {
|
|
23362
23394
|
logger$1.warn("[SignalWire] Failed to initialize DiagnosticsCollector:", error);
|
|
23363
23395
|
}
|
|
@@ -23373,8 +23405,12 @@ var SignalWire = class extends Destroyable {
|
|
|
23373
23405
|
* receiving inbound calls while keeping the session alive, use
|
|
23374
23406
|
* `unregister()` instead.
|
|
23375
23407
|
*
|
|
23408
|
+
* Registration ends with the session, so {@link isRegistered} becomes
|
|
23409
|
+
* `false`.
|
|
23410
|
+
*
|
|
23376
23411
|
* The client can be reconnected by calling {@link connect} again,
|
|
23377
|
-
* which creates a fresh transport and session
|
|
23412
|
+
* which creates a fresh transport and session and registers the user
|
|
23413
|
+
* again unless the client is opted out (see {@link connect}).
|
|
23378
23414
|
*/
|
|
23379
23415
|
async disconnect() {
|
|
23380
23416
|
this._refreshCoordinator?.suspend();
|
|
@@ -23396,6 +23432,7 @@ var SignalWire = class extends Destroyable {
|
|
|
23396
23432
|
logger$1.warn("[SignalWire] Error disconnecting previous session:", error);
|
|
23397
23433
|
}
|
|
23398
23434
|
session.destroy();
|
|
23435
|
+
this._isRegistered$.next(false);
|
|
23399
23436
|
}
|
|
23400
23437
|
if (transport) transport.destroy();
|
|
23401
23438
|
this._clientSession = void 0;
|
|
@@ -23412,11 +23449,25 @@ var SignalWire = class extends Destroyable {
|
|
|
23412
23449
|
* Waits for authentication to complete before sending the registration.
|
|
23413
23450
|
* If the initial attempt fails, reauthentication is attempted automatically.
|
|
23414
23451
|
*
|
|
23452
|
+
* The client stays registered across {@link connect} and automatic
|
|
23453
|
+
* reconnects until {@link unregister} is called.
|
|
23454
|
+
*
|
|
23415
23455
|
* @throws {InvalidCredentialsError} If registration and reauthentication both fail.
|
|
23416
23456
|
*/
|
|
23417
23457
|
async register() {
|
|
23458
|
+
this._registrationIntended = true;
|
|
23459
|
+
if (!this._pendingRegistration) {
|
|
23460
|
+
const pending = this.sendRegistration().finally(() => {
|
|
23461
|
+
if (this._pendingRegistration === pending) this._pendingRegistration = void 0;
|
|
23462
|
+
});
|
|
23463
|
+
this._pendingRegistration = pending;
|
|
23464
|
+
}
|
|
23465
|
+
return this._pendingRegistration;
|
|
23466
|
+
}
|
|
23467
|
+
async sendRegistration() {
|
|
23418
23468
|
try {
|
|
23419
23469
|
await this.waitAuthentication();
|
|
23470
|
+
if (!this._registrationIntended) return;
|
|
23420
23471
|
await this._transport.execute(RPCExecute({
|
|
23421
23472
|
method: "subscriber.online",
|
|
23422
23473
|
params: {}
|
|
@@ -23430,14 +23481,18 @@ var SignalWire = class extends Destroyable {
|
|
|
23430
23481
|
}
|
|
23431
23482
|
logger$1.debug("[SignalWire] Failed to register user, attempting credential recovery...");
|
|
23432
23483
|
const outcome = await this.recoverAndRetry(async () => {
|
|
23484
|
+
if (!this._registrationIntended) return false;
|
|
23433
23485
|
await this._transport.execute(RPCExecute({
|
|
23434
23486
|
method: "subscriber.online",
|
|
23435
23487
|
params: {}
|
|
23436
23488
|
}));
|
|
23489
|
+
return true;
|
|
23437
23490
|
});
|
|
23438
23491
|
if (outcome.ok) {
|
|
23439
|
-
|
|
23440
|
-
|
|
23492
|
+
if (outcome.value) {
|
|
23493
|
+
logger$1.debug("[SignalWire] Recovery restored registration");
|
|
23494
|
+
this._isRegistered$.next(true);
|
|
23495
|
+
}
|
|
23441
23496
|
return;
|
|
23442
23497
|
}
|
|
23443
23498
|
const failureCause = outcome.error ?? error;
|
|
@@ -23450,8 +23505,12 @@ var SignalWire = class extends Destroyable {
|
|
|
23450
23505
|
* Unregisters the user, going offline for inbound calls.
|
|
23451
23506
|
*
|
|
23452
23507
|
* The WebSocket connection remains open; use {@link disconnect} to fully close it.
|
|
23508
|
+
* The client stays unregistered across {@link connect} and automatic
|
|
23509
|
+
* reconnects until {@link register} is called, even if this call rejects.
|
|
23453
23510
|
*/
|
|
23454
23511
|
async unregister() {
|
|
23512
|
+
this._registrationIntended = false;
|
|
23513
|
+
this._pendingRegistration = void 0;
|
|
23455
23514
|
try {
|
|
23456
23515
|
await this._transport.execute(RPCExecute({
|
|
23457
23516
|
method: "subscriber.offline",
|
|
@@ -23912,7 +23971,7 @@ var StaticCredentialProvider = class {
|
|
|
23912
23971
|
/**
|
|
23913
23972
|
* Library version from package.json, injected at build time.
|
|
23914
23973
|
*/
|
|
23915
|
-
const version = "4.0.0-dev-
|
|
23974
|
+
const version = "4.0.0-dev-20261126194627";
|
|
23916
23975
|
/**
|
|
23917
23976
|
* Flag indicating the library has been loaded and is ready to use.
|
|
23918
23977
|
* For UMD builds: `window.SignalWire.ready`
|
|
@@ -23934,7 +23993,7 @@ const ready = true;
|
|
|
23934
23993
|
*/
|
|
23935
23994
|
const emitReadyEvent = () => {
|
|
23936
23995
|
if (typeof window !== "undefined") {
|
|
23937
|
-
const event = new CustomEvent("signalwire:js:ready", { detail: { version: "4.0.0-dev-
|
|
23996
|
+
const event = new CustomEvent("signalwire:js:ready", { detail: { version: "4.0.0-dev-20261126194627" } });
|
|
23938
23997
|
window.dispatchEvent(event);
|
|
23939
23998
|
}
|
|
23940
23999
|
};
|