@signalwire/js 4.0.0-dev-20260410161919 → 4.0.0-dev-20260413184400
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 +934 -614
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +934 -614
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +698 -379
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +688 -369
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -139,7 +139,7 @@ const asyncRetry = async ({ asyncCallable, maxRetries: retries = DEFAULT_MAX_RET
|
|
|
139
139
|
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/controllers/HTTPRequestController.ts
|
|
142
|
-
const logger$
|
|
142
|
+
const logger$28 = require_operators.getLogger();
|
|
143
143
|
const GET_PARAMS = {
|
|
144
144
|
method: "GET",
|
|
145
145
|
headers: { Accept: "application/json" }
|
|
@@ -202,7 +202,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
202
202
|
this._responses$.next(response);
|
|
203
203
|
return response;
|
|
204
204
|
} catch (error) {
|
|
205
|
-
logger$
|
|
205
|
+
logger$28.error("[HTTPRequestController] Request error:", error);
|
|
206
206
|
this._status$.next("error");
|
|
207
207
|
const err = error instanceof Error ? error : new Error("HTTP request failed", { cause: error });
|
|
208
208
|
this._errors$.next(err);
|
|
@@ -229,7 +229,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
229
229
|
const url = this.buildURL(request.url);
|
|
230
230
|
const headers = this.buildHeaders(request.headers);
|
|
231
231
|
const timeout$4 = request.timeout ?? this.requestTimeout;
|
|
232
|
-
logger$
|
|
232
|
+
logger$28.debug("[HTTPRequestController] Executing request:", {
|
|
233
233
|
method: request.method,
|
|
234
234
|
url,
|
|
235
235
|
headers: Object.keys(headers).reduce((acc, key) => {
|
|
@@ -249,7 +249,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
249
249
|
});
|
|
250
250
|
clearTimeout(timeoutId);
|
|
251
251
|
const httpResponse = await this.convertResponse(response);
|
|
252
|
-
logger$
|
|
252
|
+
logger$28.debug("[HTTPRequestController] Response received:", {
|
|
253
253
|
status: response.status,
|
|
254
254
|
statusText: response.statusText,
|
|
255
255
|
headers: [...response.headers.entries()],
|
|
@@ -259,7 +259,7 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
259
259
|
} catch (error) {
|
|
260
260
|
clearTimeout(timeoutId);
|
|
261
261
|
if (error instanceof Error && error.name === "AbortError") throw new require_operators.RequestTimeoutError(`Request timeout after ${timeout$4}ms`, { cause: error });
|
|
262
|
-
logger$
|
|
262
|
+
logger$28.error("[HTTPRequestController] Request failed:", error);
|
|
263
263
|
throw error;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -273,8 +273,8 @@ var HTTPRequestController = class HTTPRequestController {
|
|
|
273
273
|
const credential = this.getCredential();
|
|
274
274
|
if (credential.token) {
|
|
275
275
|
headers.Authorization = `Bearer ${credential.token}`;
|
|
276
|
-
logger$
|
|
277
|
-
} else logger$
|
|
276
|
+
logger$28.debug("[HTTPRequestController] Using Bearer token auth, token length:", credential.token.length);
|
|
277
|
+
} else logger$28.warn("[HTTPRequestController] No credentials available for authentication");
|
|
278
278
|
return headers;
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
@@ -423,6 +423,19 @@ const DEFAULT_RECONNECT_DELAY_MAX_MS = 3e3;
|
|
|
423
423
|
const DEFAULT_DEVICE_DEBOUNCE_TIME_MS = 1500;
|
|
424
424
|
const DEFAULT_DEVICE_POLLING_INTERVAL_MS = 0;
|
|
425
425
|
const PREFERENCES_STORAGE_KEY = "sw:preferences";
|
|
426
|
+
/** Scope value that enables automatic token refresh. */
|
|
427
|
+
const SAT_REFRESH_SCOPE = "sat:refresh";
|
|
428
|
+
/** API endpoints for device token operations. */
|
|
429
|
+
const DEVICE_TOKEN_ENDPOINT = "/api/fabric/subscriber/devices/token";
|
|
430
|
+
const DEVICE_REFRESH_ENDPOINT = "/api/fabric/subscriber/devices/refresh";
|
|
431
|
+
/** Default device token TTL in seconds (15 minutes). */
|
|
432
|
+
const DEVICE_TOKEN_DEFAULT_EXPIRE_IN = 900;
|
|
433
|
+
/** Buffer time in milliseconds before expiry to trigger refresh. */
|
|
434
|
+
const DEVICE_TOKEN_REFRESH_BUFFER_MS = 3e4;
|
|
435
|
+
/** Maximum retry attempts for device token refresh on transient failure. */
|
|
436
|
+
const DEVICE_TOKEN_REFRESH_MAX_RETRIES = 3;
|
|
437
|
+
/** Base delay in milliseconds for exponential backoff on refresh retry. */
|
|
438
|
+
const DEVICE_TOKEN_REFRESH_RETRY_BASE_MS = 1e3;
|
|
426
439
|
/** JSON-RPC error code for requester validation failure (corrupted auth state). */
|
|
427
440
|
const RPC_ERROR_REQUESTER_VALIDATION_FAILED = -32003;
|
|
428
441
|
/** JSON-RPC error code for invalid params (e.g., missing authentication block). */
|
|
@@ -513,7 +526,7 @@ function fromMsToSec(milliseconds) {
|
|
|
513
526
|
|
|
514
527
|
//#endregion
|
|
515
528
|
//#region src/containers/PreferencesContainer.ts
|
|
516
|
-
const logger$
|
|
529
|
+
const logger$27 = require_operators.getLogger();
|
|
517
530
|
var PreferencesContainer = class PreferencesContainer {
|
|
518
531
|
static get instance() {
|
|
519
532
|
this._instance ??= new PreferencesContainer();
|
|
@@ -1175,7 +1188,7 @@ var ClientPreferences = class {
|
|
|
1175
1188
|
if (!this._storage) return;
|
|
1176
1189
|
const data = collectStoredPreferences();
|
|
1177
1190
|
this._storage.setItem(PREFERENCES_STORAGE_KEY, data, "local").catch((error) => {
|
|
1178
|
-
logger$
|
|
1191
|
+
logger$27.error(`[ClientPreferences] Failed to save preferences: ${String(error)}`);
|
|
1179
1192
|
});
|
|
1180
1193
|
}
|
|
1181
1194
|
/** Loads preferences from storage and applies them to the container. */
|
|
@@ -1184,14 +1197,14 @@ var ClientPreferences = class {
|
|
|
1184
1197
|
this._storage.getItem(PREFERENCES_STORAGE_KEY, "local").then((stored) => {
|
|
1185
1198
|
if (stored) applyStoredPreferences(stored);
|
|
1186
1199
|
}).catch((error) => {
|
|
1187
|
-
logger$
|
|
1200
|
+
logger$27.error(`[ClientPreferences] Failed to load preferences: ${String(error)}`);
|
|
1188
1201
|
});
|
|
1189
1202
|
}
|
|
1190
1203
|
};
|
|
1191
1204
|
|
|
1192
1205
|
//#endregion
|
|
1193
1206
|
//#region src/controllers/NavigatorDeviceController.ts
|
|
1194
|
-
const logger$
|
|
1207
|
+
const logger$26 = require_operators.getLogger();
|
|
1195
1208
|
/** Maps a device kind to its storage key. */
|
|
1196
1209
|
const DEVICE_STORAGE_KEYS = {
|
|
1197
1210
|
audioinput: DEVICE_STORAGE_KEY_AUDIO_INPUT,
|
|
@@ -1213,7 +1226,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1213
1226
|
super();
|
|
1214
1227
|
this.webRTCApiProvider = webRTCApiProvider;
|
|
1215
1228
|
this.deviceChangeHandler = () => {
|
|
1216
|
-
logger$
|
|
1229
|
+
logger$26.debug("[DeviceController] Device change detected");
|
|
1217
1230
|
this.enumerateDevices();
|
|
1218
1231
|
};
|
|
1219
1232
|
this._devicesState$ = this.createBehaviorSubject(initialDevicesState);
|
|
@@ -1278,13 +1291,13 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1278
1291
|
return this.cachedObservable("videoInputDevices$", () => this._devicesState$.pipe((0, rxjs.map)((state) => state.videoinput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$)));
|
|
1279
1292
|
}
|
|
1280
1293
|
get selectedAudioInputDevice$() {
|
|
1281
|
-
return this.cachedObservable("selectedAudioInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, rxjs.map)((state) => state.audioinput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.tap)((info) => logger$
|
|
1294
|
+
return this.cachedObservable("selectedAudioInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, rxjs.map)((state) => state.audioinput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.tap)((info) => logger$26.debug("[DeviceController] Selected audio input device changed:", info))));
|
|
1282
1295
|
}
|
|
1283
1296
|
get selectedAudioOutputDevice$() {
|
|
1284
|
-
return this.cachedObservable("selectedAudioOutputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, rxjs.map)((state) => state.audiooutput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.tap)((info) => logger$
|
|
1297
|
+
return this.cachedObservable("selectedAudioOutputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, rxjs.map)((state) => state.audiooutput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.tap)((info) => logger$26.debug("[DeviceController] Selected audio output device changed:", info))));
|
|
1285
1298
|
}
|
|
1286
1299
|
get selectedVideoInputDevice$() {
|
|
1287
|
-
return this.cachedObservable("selectedVideoInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, rxjs.map)((state) => state.videoinput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.tap)((info) => logger$
|
|
1300
|
+
return this.cachedObservable("selectedVideoInputDevice$", () => this._selectedDevicesState$.asObservable().pipe((0, rxjs.map)((state) => state.videoinput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.tap)((info) => logger$26.debug("[DeviceController] Selected video input device changed:", info))));
|
|
1288
1301
|
}
|
|
1289
1302
|
get selectedAudioInputDevice() {
|
|
1290
1303
|
if (this._audioInputDisabled$.value) return null;
|
|
@@ -1359,7 +1372,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1359
1372
|
if (device) this.persistDeviceSelection("audioinput", device);
|
|
1360
1373
|
}
|
|
1361
1374
|
selectVideoInputDevice(device) {
|
|
1362
|
-
logger$
|
|
1375
|
+
logger$26.debug("[DeviceController] Setting selected video input device:", device);
|
|
1363
1376
|
if (this._videoInputDisabled$.value && device) this._videoInputDisabled$.next(false);
|
|
1364
1377
|
const previous = this._selectedDevicesState$.value.videoinput;
|
|
1365
1378
|
if (previous && previous.deviceId !== device?.deviceId) this._deviceHistory.push("videoinput", previous);
|
|
@@ -1416,7 +1429,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1416
1429
|
}
|
|
1417
1430
|
const fromHistory = this._deviceHistory.findInHistory(kind, devices);
|
|
1418
1431
|
if (fromHistory) {
|
|
1419
|
-
logger$
|
|
1432
|
+
logger$26.debug(`[DeviceController] Device disappeared, falling back to history: ${fromHistory.label}`);
|
|
1420
1433
|
this.emitDeviceRecovered(kind, selected, fromHistory, "device_disconnected");
|
|
1421
1434
|
return fromHistory;
|
|
1422
1435
|
}
|
|
@@ -1469,7 +1482,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1469
1482
|
try {
|
|
1470
1483
|
await this._storageManager.setItem(DEVICE_STORAGE_KEYS[kind], stored, "local");
|
|
1471
1484
|
} catch (error) {
|
|
1472
|
-
logger$
|
|
1485
|
+
logger$26.error(`[DeviceController] Failed to persist device selection for ${kind}:`, error);
|
|
1473
1486
|
}
|
|
1474
1487
|
}
|
|
1475
1488
|
async loadPersistedDevices() {
|
|
@@ -1485,7 +1498,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1485
1498
|
[kind]: stored
|
|
1486
1499
|
};
|
|
1487
1500
|
} catch (error) {
|
|
1488
|
-
logger$
|
|
1501
|
+
logger$26.error(`[DeviceController] Failed to load persisted device for ${kind}:`, error);
|
|
1489
1502
|
}
|
|
1490
1503
|
}
|
|
1491
1504
|
/** Clears device history, persisted selections, and re-enumerates devices. */
|
|
@@ -1503,7 +1516,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1503
1516
|
this.disableDeviceMonitoring();
|
|
1504
1517
|
this.webRTCApiProvider.mediaDevices.addEventListener("devicechange", this.deviceChangeHandler);
|
|
1505
1518
|
if (PreferencesContainer.instance.devicePollingInterval > 0) this._devicesPoolingSubscription = (0, rxjs.interval)(PreferencesContainer.instance.devicePollingInterval).subscribe(() => {
|
|
1506
|
-
logger$
|
|
1519
|
+
logger$26.debug("[DeviceController] Polling devices due to interval");
|
|
1507
1520
|
this.enumerateDevices();
|
|
1508
1521
|
});
|
|
1509
1522
|
this.enumerateDevices();
|
|
@@ -1529,13 +1542,13 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1529
1542
|
videoinput: []
|
|
1530
1543
|
});
|
|
1531
1544
|
this._devicesState$.next(devicesByKind);
|
|
1532
|
-
logger$
|
|
1545
|
+
logger$26.debug("[DeviceController] Devices enumerated:", {
|
|
1533
1546
|
audioInputs: devicesByKind.audioinput.length,
|
|
1534
1547
|
audioOutputs: devicesByKind.audiooutput.length,
|
|
1535
1548
|
videoInputs: devicesByKind.videoinput.length
|
|
1536
1549
|
});
|
|
1537
1550
|
} catch (error) {
|
|
1538
|
-
logger$
|
|
1551
|
+
logger$26.error("[DeviceController] Failed to enumerate devices:", error);
|
|
1539
1552
|
this._errors$.next(error);
|
|
1540
1553
|
}
|
|
1541
1554
|
}
|
|
@@ -1551,7 +1564,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1551
1564
|
stream.getTracks().forEach((t) => t.stop());
|
|
1552
1565
|
return capabilities;
|
|
1553
1566
|
} catch (error) {
|
|
1554
|
-
logger$
|
|
1567
|
+
logger$26.error("[DeviceController] Failed to get device capabilities:", error);
|
|
1555
1568
|
this._errors$.next(error);
|
|
1556
1569
|
throw error;
|
|
1557
1570
|
}
|
|
@@ -1802,7 +1815,7 @@ var DependencyContainer = class {
|
|
|
1802
1815
|
|
|
1803
1816
|
//#endregion
|
|
1804
1817
|
//#region src/controllers/CryptoController.ts
|
|
1805
|
-
const logger$
|
|
1818
|
+
const logger$25 = require_operators.getLogger();
|
|
1806
1819
|
const DPOP_DB_NAME = "sw-dpop";
|
|
1807
1820
|
const DPOP_DB_VERSION = 1;
|
|
1808
1821
|
const DPOP_STORE_NAME = "keys";
|
|
@@ -1861,7 +1874,7 @@ async function loadKeyPairFromDB() {
|
|
|
1861
1874
|
tx.oncomplete = () => db.close();
|
|
1862
1875
|
});
|
|
1863
1876
|
} catch (error) {
|
|
1864
|
-
logger$
|
|
1877
|
+
logger$25.warn("[DPoP] Failed to load key pair from IndexedDB:", error);
|
|
1865
1878
|
return null;
|
|
1866
1879
|
}
|
|
1867
1880
|
}
|
|
@@ -1881,7 +1894,7 @@ async function saveKeyPairToDB(keyPair) {
|
|
|
1881
1894
|
};
|
|
1882
1895
|
});
|
|
1883
1896
|
} catch (error) {
|
|
1884
|
-
logger$
|
|
1897
|
+
logger$25.warn("[DPoP] Failed to save key pair to IndexedDB:", error);
|
|
1885
1898
|
}
|
|
1886
1899
|
}
|
|
1887
1900
|
async function deleteKeyPairFromDB() {
|
|
@@ -1900,7 +1913,7 @@ async function deleteKeyPairFromDB() {
|
|
|
1900
1913
|
};
|
|
1901
1914
|
});
|
|
1902
1915
|
} catch (error) {
|
|
1903
|
-
logger$
|
|
1916
|
+
logger$25.warn("[DPoP] Failed to delete key pair from IndexedDB:", error);
|
|
1904
1917
|
}
|
|
1905
1918
|
}
|
|
1906
1919
|
/**
|
|
@@ -1960,13 +1973,13 @@ var CryptoController = class {
|
|
|
1960
1973
|
this._publicJwk = await crypto.subtle.exportKey("jwk", stored.publicKey);
|
|
1961
1974
|
this._fingerprint = await computeJwkThumbprint(this._publicJwk);
|
|
1962
1975
|
this._initialized = true;
|
|
1963
|
-
logger$
|
|
1976
|
+
logger$25.debug("[DPoP] Key pair restored from IndexedDB, fingerprint:", this._fingerprint);
|
|
1964
1977
|
return this._fingerprint;
|
|
1965
1978
|
} catch (error) {
|
|
1966
|
-
logger$
|
|
1979
|
+
logger$25.warn("[DPoP] Stored key pair unusable, generating new one:", error);
|
|
1967
1980
|
await deleteKeyPairFromDB();
|
|
1968
1981
|
}
|
|
1969
|
-
logger$
|
|
1982
|
+
logger$25.debug("[DPoP] Generating RSA key pair");
|
|
1970
1983
|
this._keyPair = await crypto.subtle.generateKey({
|
|
1971
1984
|
name: "RSASSA-PKCS1-v1_5",
|
|
1972
1985
|
modulusLength: 2048,
|
|
@@ -1981,7 +1994,7 @@ var CryptoController = class {
|
|
|
1981
1994
|
this._fingerprint = await computeJwkThumbprint(this._publicJwk);
|
|
1982
1995
|
this._initialized = true;
|
|
1983
1996
|
await saveKeyPairToDB(this._keyPair);
|
|
1984
|
-
logger$
|
|
1997
|
+
logger$25.debug("[DPoP] Key pair generated and persisted, fingerprint:", this._fingerprint);
|
|
1985
1998
|
return this._fingerprint;
|
|
1986
1999
|
}
|
|
1987
2000
|
/**
|
|
@@ -2047,7 +2060,7 @@ var CryptoController = class {
|
|
|
2047
2060
|
this._fingerprint = null;
|
|
2048
2061
|
this._initialized = false;
|
|
2049
2062
|
deleteKeyPairFromDB();
|
|
2050
|
-
logger$
|
|
2063
|
+
logger$25.debug("[DPoP] Controller destroyed");
|
|
2051
2064
|
}
|
|
2052
2065
|
get publicJwk() {
|
|
2053
2066
|
if (!this._publicJwk) throw new require_operators.DPoPInitError("CryptoController not initialized. Call init() first.");
|
|
@@ -2070,7 +2083,7 @@ var CryptoController = class {
|
|
|
2070
2083
|
|
|
2071
2084
|
//#endregion
|
|
2072
2085
|
//#region src/controllers/NetworkMonitor.ts
|
|
2073
|
-
const logger$
|
|
2086
|
+
const logger$24 = require_operators.getLogger();
|
|
2074
2087
|
/**
|
|
2075
2088
|
* Safely check whether we are running in a browser environment
|
|
2076
2089
|
* with `window` and the relevant event targets.
|
|
@@ -2127,7 +2140,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2127
2140
|
}
|
|
2128
2141
|
attachListeners() {
|
|
2129
2142
|
if (!hasBrowserNetworkEvents()) {
|
|
2130
|
-
logger$
|
|
2143
|
+
logger$24.debug("NetworkMonitor: no browser environment detected, skipping event listeners");
|
|
2131
2144
|
return;
|
|
2132
2145
|
}
|
|
2133
2146
|
window.addEventListener("online", this._onOnline);
|
|
@@ -2135,7 +2148,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2135
2148
|
const connection = getNetworkConnection();
|
|
2136
2149
|
if (connection) connection.addEventListener("change", this._onConnectionChange);
|
|
2137
2150
|
this._listenersAttached = true;
|
|
2138
|
-
logger$
|
|
2151
|
+
logger$24.debug("NetworkMonitor: event listeners attached");
|
|
2139
2152
|
}
|
|
2140
2153
|
removeListeners() {
|
|
2141
2154
|
if (!this._listenersAttached) return;
|
|
@@ -2146,10 +2159,10 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2146
2159
|
if (connection) connection.removeEventListener("change", this._onConnectionChange);
|
|
2147
2160
|
}
|
|
2148
2161
|
this._listenersAttached = false;
|
|
2149
|
-
logger$
|
|
2162
|
+
logger$24.debug("NetworkMonitor: event listeners removed");
|
|
2150
2163
|
}
|
|
2151
2164
|
handleOnline() {
|
|
2152
|
-
logger$
|
|
2165
|
+
logger$24.info("NetworkMonitor: browser went online");
|
|
2153
2166
|
this._isOnline$.next(true);
|
|
2154
2167
|
this._networkChange$.next({
|
|
2155
2168
|
type: "online",
|
|
@@ -2158,7 +2171,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2158
2171
|
});
|
|
2159
2172
|
}
|
|
2160
2173
|
handleOffline() {
|
|
2161
|
-
logger$
|
|
2174
|
+
logger$24.info("NetworkMonitor: browser went offline");
|
|
2162
2175
|
this._isOnline$.next(false);
|
|
2163
2176
|
this._networkChange$.next({
|
|
2164
2177
|
type: "offline",
|
|
@@ -2167,7 +2180,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2167
2180
|
}
|
|
2168
2181
|
handleConnectionChange() {
|
|
2169
2182
|
const networkType = getNetworkType();
|
|
2170
|
-
logger$
|
|
2183
|
+
logger$24.info(`NetworkMonitor: connection changed — effectiveType=${networkType ?? "unknown"}`);
|
|
2171
2184
|
this._networkChange$.next({
|
|
2172
2185
|
type: "connection_change",
|
|
2173
2186
|
timestamp: Date.now(),
|
|
@@ -2282,7 +2295,7 @@ function getNavigatorMediaDevices() {
|
|
|
2282
2295
|
|
|
2283
2296
|
//#endregion
|
|
2284
2297
|
//#region src/controllers/PreflightRunner.ts
|
|
2285
|
-
const logger$
|
|
2298
|
+
const logger$23 = require_operators.getLogger();
|
|
2286
2299
|
const DEFAULT_MEDIA_TEST_DURATION_S = 10;
|
|
2287
2300
|
const ICE_GATHERING_TIMEOUT_MS = 1e4;
|
|
2288
2301
|
const SIGNALING_RTT_TIMEOUT_MS = 5e3;
|
|
@@ -2331,7 +2344,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2331
2344
|
if (!this._options.skipMediaTest) try {
|
|
2332
2345
|
bandwidth = await this.testMediaBandwidth(destination);
|
|
2333
2346
|
} catch (error) {
|
|
2334
|
-
logger$
|
|
2347
|
+
logger$23.warn("[PreflightRunner] Media bandwidth test failed:", error);
|
|
2335
2348
|
warnings.push("Media bandwidth test failed");
|
|
2336
2349
|
}
|
|
2337
2350
|
return {
|
|
@@ -2343,7 +2356,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2343
2356
|
warnings
|
|
2344
2357
|
};
|
|
2345
2358
|
} catch (error) {
|
|
2346
|
-
logger$
|
|
2359
|
+
logger$23.error("[PreflightRunner] Preflight test failed:", error);
|
|
2347
2360
|
throw new require_operators.PreflightError("preflight", error instanceof Error ? error : new Error(String(error)));
|
|
2348
2361
|
} finally {
|
|
2349
2362
|
this.destroy();
|
|
@@ -2374,7 +2387,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2374
2387
|
if (track.kind === "video" && track.readyState === "live") videoWorking = true;
|
|
2375
2388
|
}
|
|
2376
2389
|
} catch (error) {
|
|
2377
|
-
logger$
|
|
2390
|
+
logger$23.warn("[PreflightRunner] Device test failed:", error);
|
|
2378
2391
|
} finally {
|
|
2379
2392
|
if (audioStream) audioStream.getTracks().forEach((t) => t.stop());
|
|
2380
2393
|
}
|
|
@@ -2397,18 +2410,19 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2397
2410
|
let pc;
|
|
2398
2411
|
try {
|
|
2399
2412
|
pc = new RTCPeerConnection({ iceServers: this.iceServers });
|
|
2413
|
+
const peerConnection = pc;
|
|
2400
2414
|
const candidateTypes = /* @__PURE__ */ new Set();
|
|
2401
2415
|
const startTime = Date.now();
|
|
2402
2416
|
const gatheringComplete = new Promise((resolve) => {
|
|
2403
|
-
const timer$
|
|
2404
|
-
|
|
2417
|
+
const timer$2 = setTimeout(resolve, ICE_GATHERING_TIMEOUT_MS);
|
|
2418
|
+
peerConnection.onicecandidate = (event) => {
|
|
2405
2419
|
if (event.candidate) {
|
|
2406
2420
|
const candidateStr = event.candidate.candidate;
|
|
2407
2421
|
if (candidateStr.includes("typ host")) candidateTypes.add("host");
|
|
2408
2422
|
if (candidateStr.includes("typ srflx")) candidateTypes.add("srflx");
|
|
2409
2423
|
if (candidateStr.includes("typ relay")) candidateTypes.add("relay");
|
|
2410
2424
|
} else {
|
|
2411
|
-
clearTimeout(timer$
|
|
2425
|
+
clearTimeout(timer$2);
|
|
2412
2426
|
resolve();
|
|
2413
2427
|
}
|
|
2414
2428
|
};
|
|
@@ -2431,7 +2445,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2431
2445
|
rttMs
|
|
2432
2446
|
};
|
|
2433
2447
|
} catch (error) {
|
|
2434
|
-
logger$
|
|
2448
|
+
logger$23.warn("[PreflightRunner] ICE connectivity test failed:", error);
|
|
2435
2449
|
return {
|
|
2436
2450
|
type: "failed",
|
|
2437
2451
|
turnReachable: false,
|
|
@@ -2478,7 +2492,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2478
2492
|
|
|
2479
2493
|
//#endregion
|
|
2480
2494
|
//#region src/controllers/VisibilityController.ts
|
|
2481
|
-
const logger$
|
|
2495
|
+
const logger$22 = require_operators.getLogger();
|
|
2482
2496
|
/**
|
|
2483
2497
|
* Checks whether the document visibility API is available.
|
|
2484
2498
|
*/
|
|
@@ -2515,8 +2529,8 @@ var VisibilityController = class extends Destroyable {
|
|
|
2515
2529
|
this._boundHandler = this._handleVisibilityChange.bind(this);
|
|
2516
2530
|
if (this._hasVisibilityApi) {
|
|
2517
2531
|
document.addEventListener("visibilitychange", this._boundHandler);
|
|
2518
|
-
logger$
|
|
2519
|
-
} else logger$
|
|
2532
|
+
logger$22.debug("VisibilityController: listening for visibilitychange events");
|
|
2533
|
+
} else logger$22.debug("VisibilityController: document visibility API not available, defaulting to visible");
|
|
2520
2534
|
}
|
|
2521
2535
|
/**
|
|
2522
2536
|
* Observable of the current visibility state.
|
|
@@ -2541,7 +2555,7 @@ var VisibilityController = class extends Destroyable {
|
|
|
2541
2555
|
destroy() {
|
|
2542
2556
|
if (this._hasVisibilityApi) {
|
|
2543
2557
|
document.removeEventListener("visibilitychange", this._boundHandler);
|
|
2544
|
-
logger$
|
|
2558
|
+
logger$22.debug("VisibilityController: removed visibilitychange listener");
|
|
2545
2559
|
}
|
|
2546
2560
|
super.destroy();
|
|
2547
2561
|
}
|
|
@@ -2559,7 +2573,7 @@ var VisibilityController = class extends Destroyable {
|
|
|
2559
2573
|
timestamp: Date.now()
|
|
2560
2574
|
};
|
|
2561
2575
|
this._visibilityChange$.next(changeEvent);
|
|
2562
|
-
logger$
|
|
2576
|
+
logger$22.debug("VisibilityController: visibility changed", {
|
|
2563
2577
|
from: previousState,
|
|
2564
2578
|
to: newState
|
|
2565
2579
|
});
|
|
@@ -2762,7 +2776,7 @@ const RPCEventAckResponse = (id) => makeRPCResponse({
|
|
|
2762
2776
|
|
|
2763
2777
|
//#endregion
|
|
2764
2778
|
//#region src/managers/AttachManager.ts
|
|
2765
|
-
const logger$
|
|
2779
|
+
const logger$21 = require_operators.getLogger();
|
|
2766
2780
|
var AttachManager = class {
|
|
2767
2781
|
constructor(storage, deviceController, reconnectCallsTimeout, attachKey) {
|
|
2768
2782
|
this.storage = storage;
|
|
@@ -2774,6 +2788,7 @@ var AttachManager = class {
|
|
|
2774
2788
|
const attached = await this.readAttached();
|
|
2775
2789
|
for (const callId of Object.keys(attached)) await this.detach({
|
|
2776
2790
|
id: callId,
|
|
2791
|
+
nodeId: attached[callId].nodeId,
|
|
2777
2792
|
mediaDirections: attached[callId].mediaDirections
|
|
2778
2793
|
});
|
|
2779
2794
|
}
|
|
@@ -2784,7 +2799,7 @@ var AttachManager = class {
|
|
|
2784
2799
|
try {
|
|
2785
2800
|
return await this.storage.getItem(this.attachKey) ?? {};
|
|
2786
2801
|
} catch (error) {
|
|
2787
|
-
logger$
|
|
2802
|
+
logger$21.warn("[AttachManager] Failed to retrieve attached calls from storage", error);
|
|
2788
2803
|
return {};
|
|
2789
2804
|
}
|
|
2790
2805
|
}
|
|
@@ -2792,20 +2807,20 @@ var AttachManager = class {
|
|
|
2792
2807
|
try {
|
|
2793
2808
|
await this.storage.setItem(this.attachKey, attached);
|
|
2794
2809
|
} catch (error) {
|
|
2795
|
-
logger$
|
|
2810
|
+
logger$21.warn("[AttachManager] Failed to write attached calls to storage", error);
|
|
2796
2811
|
}
|
|
2797
2812
|
}
|
|
2798
2813
|
async attach(call) {
|
|
2799
2814
|
if (!call.to) {
|
|
2800
|
-
logger$
|
|
2815
|
+
logger$21.warn("[AttachManager] Skip attach for calls with no destination");
|
|
2801
2816
|
return;
|
|
2802
2817
|
}
|
|
2803
2818
|
const attachment = {
|
|
2819
|
+
nodeId: call.nodeId,
|
|
2804
2820
|
destination: call.to,
|
|
2805
2821
|
mediaDirections: call.mediaDirections,
|
|
2806
2822
|
audioInputDevice: call.mediaDirections.audio !== "inactive" ? this.deviceController.selectedAudioInputDevice : null,
|
|
2807
2823
|
videoInputDevice: call.mediaDirections.video !== "inactive" ? this.deviceController.selectedVideoInputDevice : null,
|
|
2808
|
-
nodeId: call.nodeId,
|
|
2809
2824
|
attachedAt: Date.now()
|
|
2810
2825
|
};
|
|
2811
2826
|
const updated = {
|
|
@@ -2848,15 +2863,15 @@ var AttachManager = class {
|
|
|
2848
2863
|
callId,
|
|
2849
2864
|
...options
|
|
2850
2865
|
});
|
|
2851
|
-
logger$
|
|
2866
|
+
logger$21.info(`[AttachManager] Reattached call ${callId} (attempt ${attempt})`);
|
|
2852
2867
|
succeeded = true;
|
|
2853
2868
|
break;
|
|
2854
2869
|
} catch (error) {
|
|
2855
|
-
logger$
|
|
2870
|
+
logger$21.warn(`[AttachManager] Reattach attempt ${attempt}/3 failed for call ${callId}:`, error);
|
|
2856
2871
|
if (attempt < 3) await new Promise((r) => setTimeout(r, (attempt + 1) * 1e3));
|
|
2857
2872
|
}
|
|
2858
2873
|
if (!succeeded) {
|
|
2859
|
-
logger$
|
|
2874
|
+
logger$21.warn(`[AttachManager] Reattach failed after 3 attempts for call ${callId}, removing reference`);
|
|
2860
2875
|
await this.detach({
|
|
2861
2876
|
id: callId,
|
|
2862
2877
|
mediaDirections: attachment.mediaDirections
|
|
@@ -2870,12 +2885,13 @@ var AttachManager = class {
|
|
|
2870
2885
|
*/
|
|
2871
2886
|
buildCallOptions(attachment) {
|
|
2872
2887
|
const { audio: audioDirection, video: videoDirection } = attachment.mediaDirections;
|
|
2873
|
-
const { audioInputDevice, videoInputDevice } = attachment;
|
|
2888
|
+
const { audioInputDevice, videoInputDevice, nodeId } = attachment;
|
|
2874
2889
|
const receiveAudio = audioDirection.includes("recv");
|
|
2875
2890
|
const receiveVideo = videoDirection.includes("recv");
|
|
2876
2891
|
const sendAudio = audioDirection.includes("send");
|
|
2877
2892
|
const sendVideo = videoDirection.includes("send");
|
|
2878
2893
|
return {
|
|
2894
|
+
nodeId,
|
|
2879
2895
|
receiveAudio,
|
|
2880
2896
|
receiveVideo,
|
|
2881
2897
|
inputAudioDeviceConstraints: sendAudio ? {
|
|
@@ -2886,7 +2902,6 @@ var AttachManager = class {
|
|
|
2886
2902
|
video: true,
|
|
2887
2903
|
...this.deviceController.deviceInfoToConstraints(videoInputDevice)
|
|
2888
2904
|
} : void 0,
|
|
2889
|
-
nodeId: attachment.nodeId ?? void 0,
|
|
2890
2905
|
reattach: true
|
|
2891
2906
|
};
|
|
2892
2907
|
}
|
|
@@ -3159,7 +3174,7 @@ function toggleHandraiseMethod(is) {
|
|
|
3159
3174
|
|
|
3160
3175
|
//#endregion
|
|
3161
3176
|
//#region src/core/entities/Participant.ts
|
|
3162
|
-
const logger$
|
|
3177
|
+
const logger$20 = require_operators.getLogger();
|
|
3163
3178
|
const initialState = {};
|
|
3164
3179
|
/**
|
|
3165
3180
|
* Represents a participant in a call.
|
|
@@ -3537,7 +3552,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3537
3552
|
try {
|
|
3538
3553
|
await this.vertoManager.addScreenMedia();
|
|
3539
3554
|
} catch (error) {
|
|
3540
|
-
logger$
|
|
3555
|
+
logger$20.error("[Participant.startScreenShare] Screen share error:", error);
|
|
3541
3556
|
}
|
|
3542
3557
|
}
|
|
3543
3558
|
/** Observable of the current screen share status. */
|
|
@@ -3557,7 +3572,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3557
3572
|
try {
|
|
3558
3573
|
await this.vertoManager.addInputDevice(options);
|
|
3559
3574
|
} catch (error) {
|
|
3560
|
-
logger$
|
|
3575
|
+
logger$20.error("[Participant.startScreenShare] Screen share error:", error);
|
|
3561
3576
|
}
|
|
3562
3577
|
}
|
|
3563
3578
|
/** Removes an additional media input device by ID. */
|
|
@@ -3619,7 +3634,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3619
3634
|
*/
|
|
3620
3635
|
exitStudioModeIfActive() {
|
|
3621
3636
|
if (this._studioAudio$.value) {
|
|
3622
|
-
logger$
|
|
3637
|
+
logger$20.debug("[SelfParticipant] Exiting studio audio mode due to individual flag toggle");
|
|
3623
3638
|
this._studioAudio$.next(false);
|
|
3624
3639
|
}
|
|
3625
3640
|
}
|
|
@@ -3643,7 +3658,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3643
3658
|
try {
|
|
3644
3659
|
await super.mute();
|
|
3645
3660
|
} catch (error) {
|
|
3646
|
-
logger$
|
|
3661
|
+
logger$20.warn("[Participant.toggleAudioInput] Server Error while muting audio input, proceeding with local toggle anyway", error);
|
|
3647
3662
|
} finally {
|
|
3648
3663
|
this.vertoManager.muteMainAudioInputDevice();
|
|
3649
3664
|
}
|
|
@@ -3653,7 +3668,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3653
3668
|
try {
|
|
3654
3669
|
await super.unmute();
|
|
3655
3670
|
} catch (error) {
|
|
3656
|
-
logger$
|
|
3671
|
+
logger$20.warn("[Participant.toggleAudioInput] Server Error while unmuting audio input, proceeding with local toggle anyway", error);
|
|
3657
3672
|
} finally {
|
|
3658
3673
|
await this.vertoManager.unmuteMainAudioInputDevice();
|
|
3659
3674
|
}
|
|
@@ -3663,7 +3678,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3663
3678
|
try {
|
|
3664
3679
|
await super.muteVideo();
|
|
3665
3680
|
} catch (error) {
|
|
3666
|
-
logger$
|
|
3681
|
+
logger$20.warn("[Participant.toggleVideoInput] Server Error while muting video input, proceeding with local toggle anyway", error);
|
|
3667
3682
|
} finally {
|
|
3668
3683
|
this.vertoManager.muteMainVideoInputDevice();
|
|
3669
3684
|
}
|
|
@@ -3673,7 +3688,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3673
3688
|
try {
|
|
3674
3689
|
await super.unmuteVideo();
|
|
3675
3690
|
} catch (error) {
|
|
3676
|
-
logger$
|
|
3691
|
+
logger$20.warn("[Participant.toggleVideoInput] Server Error while unmuting video input, proceeding with local toggle anyway", error);
|
|
3677
3692
|
} finally {
|
|
3678
3693
|
await this.vertoManager.unmuteMainVideoInputDevice();
|
|
3679
3694
|
}
|
|
@@ -3767,7 +3782,7 @@ function isLayoutChangedPayload(value) {
|
|
|
3767
3782
|
|
|
3768
3783
|
//#endregion
|
|
3769
3784
|
//#region src/managers/CallEventsManager.ts
|
|
3770
|
-
const logger$
|
|
3785
|
+
const logger$19 = require_operators.getLogger();
|
|
3771
3786
|
const initialSessionState = {};
|
|
3772
3787
|
/** @internal */
|
|
3773
3788
|
var CallEventsManager = class extends Destroyable {
|
|
@@ -3871,7 +3886,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3871
3886
|
}
|
|
3872
3887
|
initSubscriptions() {
|
|
3873
3888
|
this.subscribeTo(this.callJoinedEvent$, (callJoinedEvent) => {
|
|
3874
|
-
logger$
|
|
3889
|
+
logger$19.debug("[CallEventsManager] Handling call.joined event for call/session IDs:", {
|
|
3875
3890
|
callId: callJoinedEvent.call_id,
|
|
3876
3891
|
roomSessionId: callJoinedEvent.room_session_id
|
|
3877
3892
|
});
|
|
@@ -3898,19 +3913,19 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3898
3913
|
if (this._self$.value?.capabilities.setLayout) this.updateLayouts();
|
|
3899
3914
|
});
|
|
3900
3915
|
this.subscribeTo(this.memberUpdates$, (member) => {
|
|
3901
|
-
logger$
|
|
3916
|
+
logger$19.debug("[CallEventsManager] Handling member update event for member ID:", member);
|
|
3902
3917
|
this.upsertParticipant(member);
|
|
3903
3918
|
});
|
|
3904
3919
|
this.subscribeTo(this.webRtcCallSession.memberLeft$, (memberLeftEvent) => {
|
|
3905
|
-
logger$
|
|
3920
|
+
logger$19.debug("[CallEventsManager] Handling member.left event for member ID:", memberLeftEvent.member.member_id);
|
|
3906
3921
|
const participants = { ...this._participants$.value };
|
|
3907
3922
|
if (memberLeftEvent.member.member_id in participants) {
|
|
3908
3923
|
delete participants[memberLeftEvent.member.member_id];
|
|
3909
3924
|
this._participants$.next(participants);
|
|
3910
|
-
} else logger$
|
|
3925
|
+
} else logger$19.warn(`[CallEventsManager] Received member.left event for unknown member ID: ${memberLeftEvent.member.member_id}`);
|
|
3911
3926
|
});
|
|
3912
3927
|
this.subscribeTo(this.webRtcCallSession.callUpdated$, (callUpdatedEvent) => {
|
|
3913
|
-
logger$
|
|
3928
|
+
logger$19.debug("[CallEventsManager] Handling call.updated event:", callUpdatedEvent);
|
|
3914
3929
|
const roomSession = callUpdatedEvent.room_session;
|
|
3915
3930
|
this._sessionState$.next({
|
|
3916
3931
|
...this._sessionState$.value,
|
|
@@ -3925,7 +3940,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3925
3940
|
});
|
|
3926
3941
|
});
|
|
3927
3942
|
this.subscribeTo(this.layoutChangedEvent$, (layoutChangedEvent) => {
|
|
3928
|
-
logger$
|
|
3943
|
+
logger$19.debug("[CallEventsManager] Handling layout.changed event:", layoutChangedEvent);
|
|
3929
3944
|
this._sessionState$.next({
|
|
3930
3945
|
...this._sessionState$.value,
|
|
3931
3946
|
layout_name: layoutChangedEvent.id,
|
|
@@ -3935,10 +3950,10 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3935
3950
|
});
|
|
3936
3951
|
}
|
|
3937
3952
|
updateParticipantPositions(layoutChangedEvent) {
|
|
3938
|
-
if (Object.keys(this._participants$.value).length > 0 && !layoutChangedEvent.layers.some((layer) => !!layer.member_id)) logger$
|
|
3939
|
-
layoutChangedEvent.layers.filter((layer) =>
|
|
3940
|
-
if (!
|
|
3941
|
-
logger$
|
|
3953
|
+
if (Object.keys(this._participants$.value).length > 0 && !layoutChangedEvent.layers.some((layer) => !!layer.member_id)) logger$19.warn("[CallEventsManager] No layers with member_id found in layout.changed event. Nothing to update.");
|
|
3954
|
+
layoutChangedEvent.layers.filter((layer) => !!layer.member_id).filter((layer) => {
|
|
3955
|
+
if (!(layer.member_id in this._participants$.value)) {
|
|
3956
|
+
logger$19.warn(`[CallEventsManager] Skipping layout layer for unknown member_id: ${layer.member_id}`);
|
|
3942
3957
|
return false;
|
|
3943
3958
|
}
|
|
3944
3959
|
return true;
|
|
@@ -3961,7 +3976,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3961
3976
|
layouts: response.result.layouts
|
|
3962
3977
|
});
|
|
3963
3978
|
}).catch((error) => {
|
|
3964
|
-
logger$
|
|
3979
|
+
logger$19.error("[CallEventsManager] Error fetching layouts:", error);
|
|
3965
3980
|
});
|
|
3966
3981
|
}
|
|
3967
3982
|
updateParticipants(members) {
|
|
@@ -3977,7 +3992,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3977
3992
|
}
|
|
3978
3993
|
const participant = this._participants$.value[member.member_id];
|
|
3979
3994
|
const oldValue = participant.value;
|
|
3980
|
-
logger$
|
|
3995
|
+
logger$19.debug("[CallEventsManager] Updating participant:", member.member_id, {
|
|
3981
3996
|
oldValue,
|
|
3982
3997
|
newValue: member
|
|
3983
3998
|
});
|
|
@@ -3990,17 +4005,17 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3990
4005
|
}
|
|
3991
4006
|
get callJoinedEvent$() {
|
|
3992
4007
|
return this.cachedObservable("callJoinedEvent$", () => this.webRtcCallSession.callEvent$.pipe((0, rxjs.filter)(isCallJoinedPayload), (0, rxjs.tap)((event) => {
|
|
3993
|
-
logger$
|
|
4008
|
+
logger$19.debug("[CallEventsManager] Call joined event:", event);
|
|
3994
4009
|
})));
|
|
3995
4010
|
}
|
|
3996
4011
|
get layoutChangedEvent$() {
|
|
3997
4012
|
return this.cachedObservable("layoutChangedEvent$", () => this.webRtcCallSession.callEvent$.pipe(require_operators.filterAs(isLayoutChangedPayload, "layout"), (0, rxjs.tap)((event) => {
|
|
3998
|
-
logger$
|
|
4013
|
+
logger$19.debug("[CallEventsManager] Layout changed event:", event);
|
|
3999
4014
|
})));
|
|
4000
4015
|
}
|
|
4001
4016
|
get memberUpdates$() {
|
|
4002
4017
|
return this.cachedObservable("memberUpdates$", () => (0, rxjs.merge)(this.webRtcCallSession.memberJoined$, this.webRtcCallSession.memberUpdated$, this.webRtcCallSession.memberTalking$).pipe((0, rxjs.map)((event) => event.member), (0, rxjs.tap)((event) => {
|
|
4003
|
-
logger$
|
|
4018
|
+
logger$19.debug("[CallEventsManager] Member update event:", event);
|
|
4004
4019
|
})));
|
|
4005
4020
|
}
|
|
4006
4021
|
destroy() {
|
|
@@ -4256,7 +4271,7 @@ function appendStereoParams(fmtpLine, maxBitrate) {
|
|
|
4256
4271
|
|
|
4257
4272
|
//#endregion
|
|
4258
4273
|
//#region src/controllers/ICEGatheringController.ts
|
|
4259
|
-
const logger$
|
|
4274
|
+
const logger$18 = require_operators.getLogger();
|
|
4260
4275
|
var ICEGatheringController = class extends Destroyable {
|
|
4261
4276
|
constructor(peerConnection, peerConnectionControllerNegotiating$, options = {}) {
|
|
4262
4277
|
super();
|
|
@@ -4264,23 +4279,23 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4264
4279
|
this.peerConnectionControllerNegotiating$ = peerConnectionControllerNegotiating$;
|
|
4265
4280
|
this.onicegatheringstatechangeHandler = () => {
|
|
4266
4281
|
const { iceGatheringState } = this.peerConnection;
|
|
4267
|
-
logger$
|
|
4282
|
+
logger$18.debug(`[ICEGatheringController] ICE gathering state changed to: ${iceGatheringState}`);
|
|
4268
4283
|
if (iceGatheringState === "gathering") this._iceCandidatesState.next({
|
|
4269
4284
|
state: "gathering",
|
|
4270
4285
|
validSDP: false
|
|
4271
4286
|
});
|
|
4272
4287
|
};
|
|
4273
4288
|
this.onicecandidateHandler = (event) => {
|
|
4274
|
-
logger$
|
|
4289
|
+
logger$18.debug("[ICEGatheringController] ICE candidate event received:", event.candidate);
|
|
4275
4290
|
this.removeTimer("iceCandidateTimer");
|
|
4276
4291
|
if (event.candidate) this.iceCandidateTimer = setTimeout(() => {
|
|
4277
4292
|
if (this.peerConnection.iceGatheringState !== "complete") {
|
|
4278
|
-
logger$
|
|
4293
|
+
logger$18.warn("[ICEGatheringController] ICE candidate timeout, using current SDP");
|
|
4279
4294
|
this.handleICECandidateTimeout();
|
|
4280
4295
|
}
|
|
4281
4296
|
}, this.iceCandidateTimeout);
|
|
4282
4297
|
else {
|
|
4283
|
-
logger$
|
|
4298
|
+
logger$18.debug("[ICEGatheringController] ICE gathering completed: null candidate received");
|
|
4284
4299
|
this.removeTimer("iceGatheringTimer");
|
|
4285
4300
|
this.handleICEGatheringComplete();
|
|
4286
4301
|
}
|
|
@@ -4298,7 +4313,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4298
4313
|
this.setupEventListeners();
|
|
4299
4314
|
this.iceGatheringTimer = setTimeout(() => {
|
|
4300
4315
|
if (this.peerConnection.iceGatheringState !== "complete") {
|
|
4301
|
-
logger$
|
|
4316
|
+
logger$18.warn("[ICEGatheringController] ICE gathering timeout, using current SDP");
|
|
4302
4317
|
this.handleICEGatheringTimeout();
|
|
4303
4318
|
}
|
|
4304
4319
|
}, this.iceGatheringTimeout);
|
|
@@ -4325,9 +4340,9 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4325
4340
|
this.relayOnly = value;
|
|
4326
4341
|
}
|
|
4327
4342
|
handleICEGatheringComplete() {
|
|
4328
|
-
logger$
|
|
4329
|
-
logger$
|
|
4330
|
-
logger$
|
|
4343
|
+
logger$18.debug("[ICEGatheringController] Handling ICE gathering complete");
|
|
4344
|
+
logger$18.debug(`[ICEGatheringController] Checking ICE gathering state: ${this.peerConnection.iceGatheringState}`);
|
|
4345
|
+
logger$18.debug("[ICEGatheringController] ICE gathering complete");
|
|
4331
4346
|
this._iceCandidatesState.next({
|
|
4332
4347
|
state: "complete",
|
|
4333
4348
|
validSDP: this.hasValidLocalDescriptionSDP
|
|
@@ -4343,21 +4358,21 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4343
4358
|
this.removeTimer("iceGatheringTimer");
|
|
4344
4359
|
const validSDP = this.hasValidLocalDescriptionSDP;
|
|
4345
4360
|
if (validSDP) {
|
|
4346
|
-
logger$
|
|
4361
|
+
logger$18.debug("[ICEGatheringController] Local SDP is valid");
|
|
4347
4362
|
this._iceCandidatesState.next({
|
|
4348
4363
|
state: "timeout",
|
|
4349
4364
|
validSDP
|
|
4350
4365
|
});
|
|
4351
4366
|
this.stopGathering();
|
|
4352
|
-
} else logger$
|
|
4367
|
+
} else logger$18.debug("### ICE gathering timeout\n", this.peerConnection.localDescription?.sdp);
|
|
4353
4368
|
}
|
|
4354
4369
|
handleICECandidateTimeout() {
|
|
4355
4370
|
if (this.iceCandidateTimer) this.removeTimer("iceCandidateTimer");
|
|
4356
|
-
logger$
|
|
4371
|
+
logger$18.warn("[ICEGatheringController] ICE candidate timeout");
|
|
4357
4372
|
const validSDP = this.hasValidLocalDescriptionSDP;
|
|
4358
4373
|
if (!validSDP && !this.relayOnly) this.restartICEGatheringWithRelayOnly();
|
|
4359
4374
|
else {
|
|
4360
|
-
logger$
|
|
4375
|
+
logger$18.debug("[ICEGatheringController] Using current SDP due to ICE candidate timeout");
|
|
4361
4376
|
this._iceCandidatesState.next({
|
|
4362
4377
|
state: "timeout",
|
|
4363
4378
|
validSDP
|
|
@@ -4366,7 +4381,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4366
4381
|
}
|
|
4367
4382
|
}
|
|
4368
4383
|
restartICEGatheringWithRelayOnly() {
|
|
4369
|
-
logger$
|
|
4384
|
+
logger$18.debug("[ICEGatheringController] Restarting ICE gathering with relay-only candidates");
|
|
4370
4385
|
this.relayOnly = true;
|
|
4371
4386
|
this.peerConnection.setConfiguration({
|
|
4372
4387
|
...this.peerConnection.getConfiguration(),
|
|
@@ -4374,14 +4389,14 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4374
4389
|
});
|
|
4375
4390
|
if (!(this.peerConnection.connectionState === "connected")) this.peerConnection.restartIce();
|
|
4376
4391
|
}
|
|
4377
|
-
removeTimer(timer$
|
|
4378
|
-
if (this[timer$
|
|
4379
|
-
clearTimeout(this[timer$
|
|
4380
|
-
this[timer$
|
|
4392
|
+
removeTimer(timer$2) {
|
|
4393
|
+
if (this[timer$2]) {
|
|
4394
|
+
clearTimeout(this[timer$2]);
|
|
4395
|
+
this[timer$2] = void 0;
|
|
4381
4396
|
}
|
|
4382
4397
|
}
|
|
4383
4398
|
clearAllTimers() {
|
|
4384
|
-
logger$
|
|
4399
|
+
logger$18.debug("[ICEGatheringController] Clearing all timers");
|
|
4385
4400
|
this.removeTimer("iceGatheringTimer");
|
|
4386
4401
|
this.removeTimer("iceCandidateTimer");
|
|
4387
4402
|
}
|
|
@@ -4390,7 +4405,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4390
4405
|
this.peerConnection.removeEventListener("icecandidate", this.onicecandidateHandler);
|
|
4391
4406
|
}
|
|
4392
4407
|
destroy() {
|
|
4393
|
-
logger$
|
|
4408
|
+
logger$18.debug("[ICEGatheringController] Destroying ICEGatheringController");
|
|
4394
4409
|
this.clearAllTimers();
|
|
4395
4410
|
this.removeEventListeners();
|
|
4396
4411
|
super.destroy();
|
|
@@ -4399,7 +4414,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4399
4414
|
|
|
4400
4415
|
//#endregion
|
|
4401
4416
|
//#region src/controllers/LocalStreamController.ts
|
|
4402
|
-
const logger$
|
|
4417
|
+
const logger$17 = require_operators.getLogger();
|
|
4403
4418
|
var LocalStreamController = class extends Destroyable {
|
|
4404
4419
|
constructor(options) {
|
|
4405
4420
|
super();
|
|
@@ -4437,26 +4452,26 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4437
4452
|
* Build the local media stream based on the provided options.
|
|
4438
4453
|
*/
|
|
4439
4454
|
async buildLocalStream() {
|
|
4440
|
-
logger$
|
|
4455
|
+
logger$17.debug("[LocalStreamController] Building local media stream.");
|
|
4441
4456
|
let stream;
|
|
4442
4457
|
if (this.options.inputAudioStream ?? this.options.inputVideoStream) {
|
|
4443
4458
|
const tracks = [...this.options.inputAudioStream?.getTracks() ?? [], ...this.options.inputVideoStream?.getTracks() ?? []];
|
|
4444
4459
|
stream = new MediaStream(tracks);
|
|
4445
4460
|
} else if (this.options.propose === "screenshare") {
|
|
4446
|
-
logger$
|
|
4461
|
+
logger$17.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", Boolean(this.options.inputAudioDeviceConstraints));
|
|
4447
4462
|
stream = await this.options.getDisplayMedia({
|
|
4448
4463
|
video: true,
|
|
4449
4464
|
audio: Boolean(this.options.inputAudioDeviceConstraints)
|
|
4450
4465
|
});
|
|
4451
|
-
logger$
|
|
4466
|
+
logger$17.debug("[LocalStreamController] Screen share media obtained:", stream);
|
|
4452
4467
|
} else {
|
|
4453
4468
|
const constraints = {
|
|
4454
4469
|
audio: this.options.inputAudioDeviceConstraints,
|
|
4455
4470
|
video: this.options.inputVideoDeviceConstraints
|
|
4456
4471
|
};
|
|
4457
|
-
logger$
|
|
4472
|
+
logger$17.debug("[LocalStreamController] Requesting user media with constraints:", constraints);
|
|
4458
4473
|
stream = await this.options.getUserMedia(constraints);
|
|
4459
|
-
logger$
|
|
4474
|
+
logger$17.debug("[LocalStreamController] User media obtained:", stream);
|
|
4460
4475
|
}
|
|
4461
4476
|
this._localStream$.next(stream);
|
|
4462
4477
|
return stream;
|
|
@@ -4473,7 +4488,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4473
4488
|
this._localStream$.next(localStream);
|
|
4474
4489
|
if (track.kind === "video") this._localVideoTracks$.next(localStream.getVideoTracks());
|
|
4475
4490
|
else this._localAudioTracks$.next(localStream.getAudioTracks());
|
|
4476
|
-
logger$
|
|
4491
|
+
logger$17.debug(`[LocalStreamController] ${track.kind} track added:`, track.id);
|
|
4477
4492
|
return localStream;
|
|
4478
4493
|
}
|
|
4479
4494
|
/**
|
|
@@ -4485,7 +4500,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4485
4500
|
const stream = this._localStream$.value;
|
|
4486
4501
|
const track = stream?.getTracks().find((t) => t.id === trackId);
|
|
4487
4502
|
if (!track) {
|
|
4488
|
-
logger$
|
|
4503
|
+
logger$17.debug(`[LocalStreamController] track not found: ${trackId}`);
|
|
4489
4504
|
return;
|
|
4490
4505
|
}
|
|
4491
4506
|
track.removeEventListener("ended", this.mediaTrackEndedHandler);
|
|
@@ -4494,7 +4509,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4494
4509
|
this._localStream$.next(stream);
|
|
4495
4510
|
if (track.kind === "video") this._localVideoTracks$.next(stream?.getVideoTracks() ?? []);
|
|
4496
4511
|
else this._localAudioTracks$.next(stream?.getAudioTracks() ?? []);
|
|
4497
|
-
logger$
|
|
4512
|
+
logger$17.debug(`[LocalStreamController] ${track.kind} track removed:`, trackId);
|
|
4498
4513
|
return track;
|
|
4499
4514
|
}
|
|
4500
4515
|
/**
|
|
@@ -4529,7 +4544,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4529
4544
|
*/
|
|
4530
4545
|
stopAllTracks() {
|
|
4531
4546
|
this._localStream$.value?.getTracks().forEach((track) => {
|
|
4532
|
-
logger$
|
|
4547
|
+
logger$17.debug(`[LocalStreamController] Stopping local track: ${track.kind}`);
|
|
4533
4548
|
track.removeEventListener("ended", this.mediaTrackEndedHandler);
|
|
4534
4549
|
track.stop();
|
|
4535
4550
|
});
|
|
@@ -4545,7 +4560,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4545
4560
|
|
|
4546
4561
|
//#endregion
|
|
4547
4562
|
//#region src/controllers/TransceiverController.ts
|
|
4548
|
-
const logger$
|
|
4563
|
+
const logger$16 = require_operators.getLogger();
|
|
4549
4564
|
const getDirection = (send, recv) => {
|
|
4550
4565
|
if (send && recv) return "sendrecv";
|
|
4551
4566
|
else if (send && !recv) return "sendonly";
|
|
@@ -4647,7 +4662,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
4647
4662
|
sendEncodings: isAudio ? void 0 : this.sendEncodings,
|
|
4648
4663
|
streams: direction === "recvonly" ? void 0 : [localStream]
|
|
4649
4664
|
};
|
|
4650
|
-
logger$
|
|
4665
|
+
logger$16.debug(`[TransceiverController] Setting up transceiver sender for local ${track.kind} track:`, {
|
|
4651
4666
|
transceiver,
|
|
4652
4667
|
transceiverParams
|
|
4653
4668
|
});
|
|
@@ -4655,11 +4670,11 @@ var TransceiverController = class extends Destroyable {
|
|
|
4655
4670
|
await transceiver.sender.replaceTrack(track);
|
|
4656
4671
|
transceiver.direction = transceiverParams.direction;
|
|
4657
4672
|
if (transceiverParams.streams?.some((stream) => Boolean(stream))) {
|
|
4658
|
-
logger$
|
|
4673
|
+
logger$16.debug(`[TransceiverController] Setting streams for transceiver sender for local ${track.kind} track:`, transceiverParams.streams);
|
|
4659
4674
|
transceiver.sender.setStreams(...transceiverParams.streams);
|
|
4660
4675
|
}
|
|
4661
4676
|
} else {
|
|
4662
|
-
logger$
|
|
4677
|
+
logger$16.debug(`[TransceiverController] Adding new transceiver for local ${track.kind} track:`, track.id);
|
|
4663
4678
|
this.peerConnection.addTransceiver(track, transceiverParams);
|
|
4664
4679
|
}
|
|
4665
4680
|
}
|
|
@@ -4673,13 +4688,13 @@ var TransceiverController = class extends Destroyable {
|
|
|
4673
4688
|
if (options.updateTransceiverDirection) transceiver.direction = "inactive";
|
|
4674
4689
|
}
|
|
4675
4690
|
} catch (error) {
|
|
4676
|
-
logger$
|
|
4691
|
+
logger$16.error("[TransceiverController] stopTrackSender error", kind, error);
|
|
4677
4692
|
this.options.onError?.(new require_operators.MediaTrackError("stopTrackSender", kind, error));
|
|
4678
4693
|
}
|
|
4679
4694
|
}
|
|
4680
4695
|
async restoreTrackSender(kind) {
|
|
4681
4696
|
try {
|
|
4682
|
-
logger$
|
|
4697
|
+
logger$16.debug("[TransceiverController] restoreTrackSender called", kind);
|
|
4683
4698
|
const constraints = {};
|
|
4684
4699
|
const transceivers = this.transceiverByKind(kind);
|
|
4685
4700
|
for (const transceiver of transceivers) {
|
|
@@ -4689,23 +4704,23 @@ var TransceiverController = class extends Destroyable {
|
|
|
4689
4704
|
if (trackKind === "audio" || trackKind === "video") constraints[trackKind] = this.getConstraintsFor(trackKind);
|
|
4690
4705
|
}
|
|
4691
4706
|
}
|
|
4692
|
-
logger$
|
|
4707
|
+
logger$16.debug("[TransceiverController] restoreTrackSender constraints:", constraints);
|
|
4693
4708
|
if (Object.keys(constraints).length === 0) {
|
|
4694
|
-
logger$
|
|
4709
|
+
logger$16.warn("[TransceiverController] restoreTrackSender: no tracks need restoration", kind);
|
|
4695
4710
|
return;
|
|
4696
4711
|
}
|
|
4697
4712
|
const newTracks = (await this.options.getUserMedia(constraints)).getTracks();
|
|
4698
|
-
logger$
|
|
4713
|
+
logger$16.debug("[TransceiverController] restoreTrackSender new tracks:", newTracks);
|
|
4699
4714
|
for (const newTrack of newTracks) {
|
|
4700
4715
|
this.options.localStreamController.addTrack(newTrack);
|
|
4701
4716
|
const trackKind = newTrack.kind;
|
|
4702
4717
|
const transceiverOfKind = this.transceiverByKind(trackKind)[0];
|
|
4703
4718
|
transceiverOfKind.direction = trackKind === "audio" ? this.audioDirection : this.videoDirection;
|
|
4704
|
-
logger$
|
|
4719
|
+
logger$16.debug("[TransceiverController] restoreTrackSender setting direction for", trackKind, transceiverOfKind.direction);
|
|
4705
4720
|
await transceiverOfKind.sender.replaceTrack(newTrack);
|
|
4706
4721
|
}
|
|
4707
4722
|
} catch (error) {
|
|
4708
|
-
logger$
|
|
4723
|
+
logger$16.error("[TransceiverController] restoreTrackSender error", kind, error);
|
|
4709
4724
|
this.options.onError?.(new require_operators.MediaTrackError("restoreTrackSender", kind, error));
|
|
4710
4725
|
}
|
|
4711
4726
|
}
|
|
@@ -4746,14 +4761,14 @@ var TransceiverController = class extends Destroyable {
|
|
|
4746
4761
|
};
|
|
4747
4762
|
try {
|
|
4748
4763
|
await track.applyConstraints(constraintsToApply);
|
|
4749
|
-
logger$
|
|
4750
|
-
logger$
|
|
4764
|
+
logger$16.debug(`[TransceiverController] Updated ${kind} sender constraints:`, constraintsToApply);
|
|
4765
|
+
logger$16.debug(`[TransceiverController] Updated ${kind} sender constraints:`, track.getConstraints());
|
|
4751
4766
|
} catch (error) {
|
|
4752
|
-
logger$
|
|
4767
|
+
logger$16.warn(`[TransceiverController] applyConstraints failed for ${kind} track ${track.id}, attempting track replacement fallback:`, error);
|
|
4753
4768
|
try {
|
|
4754
4769
|
await this.replaceTrackFallback(sender, track, kind, constraintsToApply);
|
|
4755
4770
|
} catch (fallbackError) {
|
|
4756
|
-
logger$
|
|
4771
|
+
logger$16.warn(`[TransceiverController] Track replacement fallback also failed for ${kind} track:`, fallbackError);
|
|
4757
4772
|
this.options.onError?.(new require_operators.MediaTrackError("updateSendersConstraints", kind, fallbackError));
|
|
4758
4773
|
}
|
|
4759
4774
|
}
|
|
@@ -4781,7 +4796,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
4781
4796
|
if (!newTrack) throw new require_operators.MediaTrackError("replaceTrackFallback", kind, /* @__PURE__ */ new Error("getUserMedia returned no track of the requested kind"));
|
|
4782
4797
|
await sender.replaceTrack(newTrack);
|
|
4783
4798
|
this.options.localStreamController.addTrack(newTrack);
|
|
4784
|
-
logger$
|
|
4799
|
+
logger$16.debug(`[TransceiverController] Track replacement fallback succeeded for ${kind}. New track: ${newTrack.id}`);
|
|
4785
4800
|
}
|
|
4786
4801
|
getMediaDirections() {
|
|
4787
4802
|
if (this.peerConnection.connectionState === "connected") return this.peerConnection.getTransceivers().reduce((acc, transceiver) => {
|
|
@@ -4811,7 +4826,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
4811
4826
|
|
|
4812
4827
|
//#endregion
|
|
4813
4828
|
//#region src/controllers/RTCPeerConnectionController.ts
|
|
4814
|
-
const logger$
|
|
4829
|
+
const logger$15 = require_operators.getLogger();
|
|
4815
4830
|
var RTCPeerConnectionController = class extends Destroyable {
|
|
4816
4831
|
constructor(options = {}, remoteSessionDescription, deviceController) {
|
|
4817
4832
|
super();
|
|
@@ -4827,43 +4842,43 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
4827
4842
|
this.oniceconnectionstatechangeHandler = () => {
|
|
4828
4843
|
if (this.peerConnection) {
|
|
4829
4844
|
const { iceConnectionState } = this.peerConnection;
|
|
4830
|
-
logger$
|
|
4845
|
+
logger$15.debug(`[RTCPeerConnectionController] ICE connection state changed to: ${iceConnectionState}`);
|
|
4831
4846
|
this._iceConnectionState$.next(this.peerConnection.iceConnectionState);
|
|
4832
4847
|
}
|
|
4833
4848
|
};
|
|
4834
4849
|
this.onconnectionstatechangeHandler = () => {
|
|
4835
4850
|
if (this.peerConnection) {
|
|
4836
4851
|
const { connectionState } = this.peerConnection;
|
|
4837
|
-
logger$
|
|
4852
|
+
logger$15.debug(`[RTCPeerConnectionController] Connection state changed to: ${connectionState}`);
|
|
4838
4853
|
if (connectionState === "connected") this.removeConnectionTimer();
|
|
4839
4854
|
this._connectionState$.next(this.peerConnection.connectionState);
|
|
4840
4855
|
}
|
|
4841
4856
|
};
|
|
4842
4857
|
this.onsignalingstatechangeHandler = () => {
|
|
4843
|
-
logger$
|
|
4858
|
+
logger$15.debug(`[RTCPeerConnectionController] Signaling state changed to: ${this.peerConnection?.signalingState}`);
|
|
4844
4859
|
};
|
|
4845
4860
|
this.onicegatheringstatechangeHandler = () => {
|
|
4846
4861
|
if (this.peerConnection) this._iceGatheringState$.next(this.peerConnection.iceGatheringState);
|
|
4847
4862
|
};
|
|
4848
4863
|
this.onnegotiationneededHandler = (event) => {
|
|
4849
|
-
logger$
|
|
4864
|
+
logger$15.debug("[RTCPeerConnectionController] Negotiation needed event received.", event);
|
|
4850
4865
|
this.negotiationNeeded$.next();
|
|
4851
4866
|
};
|
|
4852
4867
|
this.updateSelectedInputDevice = async (kind, deviceInfo) => {
|
|
4853
4868
|
try {
|
|
4854
4869
|
const { localStream } = this;
|
|
4855
4870
|
if (!localStream) {
|
|
4856
|
-
logger$
|
|
4871
|
+
logger$15.warn("[RTCPeerConnectionController] No local stream available to update input device.");
|
|
4857
4872
|
return;
|
|
4858
4873
|
}
|
|
4859
|
-
logger$
|
|
4874
|
+
logger$15.debug(`[RTCPeerConnectionController] Updating selected ${kind} input device:`, localStream.getTracks());
|
|
4860
4875
|
const track = localStream.getTracks().find((track$1) => track$1.kind === kind);
|
|
4861
4876
|
if (track) {
|
|
4862
4877
|
this.transceiverController?.stopTrackSender(kind);
|
|
4863
4878
|
this.localStream?.removeTrack(track);
|
|
4864
|
-
logger$
|
|
4879
|
+
logger$15.debug(`[RTCPeerConnectionController] Stopped existing ${kind} track: ${track.id}`, localStream.getTracks());
|
|
4865
4880
|
if (!deviceInfo) {
|
|
4866
|
-
logger$
|
|
4881
|
+
logger$15.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
|
|
4867
4882
|
return;
|
|
4868
4883
|
}
|
|
4869
4884
|
const streamTrack = (await this.getUserMedia({ [kind]: {
|
|
@@ -4871,15 +4886,15 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
4871
4886
|
...this.deviceController.deviceInfoToConstraints(deviceInfo)
|
|
4872
4887
|
} })).getTracks().find((t) => t.kind === kind);
|
|
4873
4888
|
if (streamTrack) {
|
|
4874
|
-
logger$
|
|
4889
|
+
logger$15.debug(`[RTCPeerConnectionController] Adding new ${kind} track: ${streamTrack.id}`);
|
|
4875
4890
|
this.localStream?.addTrack(streamTrack);
|
|
4876
4891
|
await this.transceiverController?.replaceSenderTrack(kind, streamTrack);
|
|
4877
|
-
logger$
|
|
4892
|
+
logger$15.debug(`[RTCPeerConnectionController] Added new ${kind} track: ${streamTrack.id}`, this.localStream?.getTracks());
|
|
4878
4893
|
}
|
|
4879
4894
|
}
|
|
4880
|
-
logger$
|
|
4895
|
+
logger$15.debug(`[RTCPeerConnectionController] ${kind} input device selected:`, deviceInfo?.label);
|
|
4881
4896
|
} catch (error) {
|
|
4882
|
-
logger$
|
|
4897
|
+
logger$15.error(`[RTCPeerConnectionController] Failed to select ${kind} input device:`, error);
|
|
4883
4898
|
this._errors$.next(error);
|
|
4884
4899
|
throw error;
|
|
4885
4900
|
}
|
|
@@ -5116,15 +5131,15 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5116
5131
|
this.setupPeerConnection();
|
|
5117
5132
|
this.subscribeTo(this.negotiationNeeded$.pipe((0, rxjs.auditTime)(0), (0, rxjs.exhaustMap)(async () => this.startNegotiation())), {
|
|
5118
5133
|
next: () => {
|
|
5119
|
-
logger$
|
|
5134
|
+
logger$15.debug("[RTCPeerConnectionController] Start Negotiation completed successfully");
|
|
5120
5135
|
},
|
|
5121
5136
|
error: (error) => {
|
|
5122
|
-
logger$
|
|
5137
|
+
logger$15.error("[RTCPeerConnectionController] Start Negotiation error:", error);
|
|
5123
5138
|
this._errors$.next(error);
|
|
5124
5139
|
}
|
|
5125
5140
|
});
|
|
5126
5141
|
this.subscribeTo((0, rxjs.merge)(this.deviceController.selectedAudioInputDevice$.pipe((0, rxjs.map)((deviceInfo) => ["audio", deviceInfo])), this.deviceController.selectedVideoInputDevice$.pipe((0, rxjs.map)((deviceInfo) => ["video", deviceInfo]))).pipe((0, rxjs.skipWhile)(() => !this.localStreamController.localStream)), async ([kind, deviceInfo]) => {
|
|
5127
|
-
logger$
|
|
5142
|
+
logger$15.debug(`[RTCPeerConnectionController] Selected input device changed for:`, {
|
|
5128
5143
|
kind,
|
|
5129
5144
|
deviceInfo
|
|
5130
5145
|
});
|
|
@@ -5141,7 +5156,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5141
5156
|
this._initialized$.next(true);
|
|
5142
5157
|
}
|
|
5143
5158
|
} catch (error) {
|
|
5144
|
-
logger$
|
|
5159
|
+
logger$15.error("[RTCPeerConnectionController] Initialization error:", error);
|
|
5145
5160
|
this._errors$.next(error);
|
|
5146
5161
|
this.destroy();
|
|
5147
5162
|
}
|
|
@@ -5173,22 +5188,22 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5173
5188
|
}
|
|
5174
5189
|
async startNegotiation() {
|
|
5175
5190
|
if (this.isNegotiating) {
|
|
5176
|
-
logger$
|
|
5191
|
+
logger$15.debug("[RTCPeerConnectionController] Negotiation already in progress, skipping.");
|
|
5177
5192
|
return;
|
|
5178
5193
|
}
|
|
5179
5194
|
this.setupEventListeners();
|
|
5180
5195
|
if (this.type === "answer") {
|
|
5181
|
-
logger$
|
|
5196
|
+
logger$15.debug("[RTCPeerConnectionController] This is an answer type still, skipping offer creation.");
|
|
5182
5197
|
return;
|
|
5183
5198
|
}
|
|
5184
5199
|
this._isNegotiating$.next(true);
|
|
5185
|
-
logger$
|
|
5200
|
+
logger$15.debug("[RTCPeerConnectionController] Starting negotiation.");
|
|
5186
5201
|
try {
|
|
5187
5202
|
const { offerOptions } = this;
|
|
5188
|
-
logger$
|
|
5203
|
+
logger$15.debug("[RTCPeerConnectionController] Creating offer with options:", offerOptions);
|
|
5189
5204
|
await this.createOffer(offerOptions);
|
|
5190
5205
|
} catch (error) {
|
|
5191
|
-
logger$
|
|
5206
|
+
logger$15.error("[RTCPeerConnectionController] Error during negotiation:", error);
|
|
5192
5207
|
this._errors$.next(error);
|
|
5193
5208
|
}
|
|
5194
5209
|
}
|
|
@@ -5204,14 +5219,14 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5204
5219
|
let readyToConnect = status !== "failed";
|
|
5205
5220
|
try {
|
|
5206
5221
|
if (status === "received" && sdp) {
|
|
5207
|
-
logger$
|
|
5222
|
+
logger$15.debug("[RTCPeerConnectionController] Received answer SDP:", sdp);
|
|
5208
5223
|
await this._setRemoteDescription({
|
|
5209
5224
|
type: "answer",
|
|
5210
5225
|
sdp
|
|
5211
5226
|
});
|
|
5212
5227
|
}
|
|
5213
5228
|
} catch (error) {
|
|
5214
|
-
logger$
|
|
5229
|
+
logger$15.error("[RTCPeerConnectionController] Error updating answer status:", error);
|
|
5215
5230
|
this._errors$.next(error);
|
|
5216
5231
|
readyToConnect = false;
|
|
5217
5232
|
} finally {
|
|
@@ -5230,7 +5245,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5230
5245
|
await this.handleOfferReceived();
|
|
5231
5246
|
break;
|
|
5232
5247
|
case "failed":
|
|
5233
|
-
logger$
|
|
5248
|
+
logger$15.error("[RTCPeerConnectionController] Offer failed to be processed by remote.");
|
|
5234
5249
|
break;
|
|
5235
5250
|
case "sent":
|
|
5236
5251
|
default:
|
|
@@ -5262,7 +5277,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5262
5277
|
}
|
|
5263
5278
|
await this.setupLocalTracks();
|
|
5264
5279
|
const { answerOptions } = this;
|
|
5265
|
-
logger$
|
|
5280
|
+
logger$15.debug("[RTCPeerConnectionController] Creating inbound answer with options:", answerOptions);
|
|
5266
5281
|
await this.createAnswer(answerOptions);
|
|
5267
5282
|
}
|
|
5268
5283
|
async handleOfferReceived() {
|
|
@@ -5270,7 +5285,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5270
5285
|
this._isNegotiating$.next(true);
|
|
5271
5286
|
await this._setRemoteDescription(this.sdpInit);
|
|
5272
5287
|
const { answerOptions } = this;
|
|
5273
|
-
logger$
|
|
5288
|
+
logger$15.debug("[RTCPeerConnectionController] Creating answer with options:", answerOptions);
|
|
5274
5289
|
await this.createAnswer(answerOptions);
|
|
5275
5290
|
}
|
|
5276
5291
|
readyToConnect() {
|
|
@@ -5278,7 +5293,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5278
5293
|
this.connectionTimer = setTimeout(() => {
|
|
5279
5294
|
this.removeConnectionTimer();
|
|
5280
5295
|
if (this.peerConnection?.connectionState !== "connected") {
|
|
5281
|
-
logger$
|
|
5296
|
+
logger$15.debug("[RTCPeerConnectionController] Connection timeout, restarting ICE gathering with relay only.");
|
|
5282
5297
|
this.iceGatheringController.restartICEGatheringWithRelayOnly();
|
|
5283
5298
|
}
|
|
5284
5299
|
}, this.connectionTimeout);
|
|
@@ -5300,14 +5315,14 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5300
5315
|
const stereo = this.options.stereo ?? PreferencesContainer.instance.stereoAudio;
|
|
5301
5316
|
if (preferredAudioCodecs.length > 0 || preferredVideoCodecs.length > 0) {
|
|
5302
5317
|
result = setCodecPreferences(result, preferredAudioCodecs, preferredVideoCodecs);
|
|
5303
|
-
logger$
|
|
5318
|
+
logger$15.debug("[RTCPeerConnectionController] Applied codec preferences to SDP", {
|
|
5304
5319
|
preferredAudioCodecs,
|
|
5305
5320
|
preferredVideoCodecs
|
|
5306
5321
|
});
|
|
5307
5322
|
}
|
|
5308
5323
|
if (stereo) {
|
|
5309
5324
|
result = enableStereoOpus(result);
|
|
5310
|
-
logger$
|
|
5325
|
+
logger$15.debug("[RTCPeerConnectionController] Applied stereo Opus to SDP");
|
|
5311
5326
|
}
|
|
5312
5327
|
return Promise.resolve(result);
|
|
5313
5328
|
}
|
|
@@ -5366,18 +5381,18 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5366
5381
|
...this.peerConnection.getConfiguration(),
|
|
5367
5382
|
iceTransportPolicy: "relay"
|
|
5368
5383
|
});
|
|
5369
|
-
logger$
|
|
5384
|
+
logger$15.debug("[RTCPeerConnectionController] ICE transport policy set to relay-only");
|
|
5370
5385
|
} catch (error) {
|
|
5371
|
-
logger$
|
|
5386
|
+
logger$15.warn("[RTCPeerConnectionController] Failed to set relay-only policy:", error);
|
|
5372
5387
|
}
|
|
5373
5388
|
this.setupEventListeners();
|
|
5374
5389
|
this._isNegotiating$.next(true);
|
|
5375
|
-
logger$
|
|
5390
|
+
logger$15.debug(`[RTCPeerConnectionController] Triggering ICE restart${relayOnly ? " (relay-only)" : ""}.`);
|
|
5376
5391
|
try {
|
|
5377
5392
|
const offer = await this.peerConnection.createOffer({ iceRestart: true });
|
|
5378
5393
|
await this.setLocalDescription(offer);
|
|
5379
5394
|
} catch (error) {
|
|
5380
|
-
logger$
|
|
5395
|
+
logger$15.error("[RTCPeerConnectionController] ICE restart offer failed:", error);
|
|
5381
5396
|
this._errors$.next(error);
|
|
5382
5397
|
this.negotiationEnded();
|
|
5383
5398
|
if (policyChanged) this.restoreIceTransportPolicy();
|
|
@@ -5391,9 +5406,9 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5391
5406
|
...this.peerConnection.getConfiguration(),
|
|
5392
5407
|
iceTransportPolicy: this.options.relayOnly ? "relay" : "all"
|
|
5393
5408
|
});
|
|
5394
|
-
logger$
|
|
5409
|
+
logger$15.debug("[RTCPeerConnectionController] ICE transport policy restored");
|
|
5395
5410
|
} catch (error) {
|
|
5396
|
-
logger$
|
|
5411
|
+
logger$15.warn("[RTCPeerConnectionController] Failed to restore ICE transport policy:", error);
|
|
5397
5412
|
}
|
|
5398
5413
|
}
|
|
5399
5414
|
/**
|
|
@@ -5405,13 +5420,13 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5405
5420
|
await this.setupRemoteTracks();
|
|
5406
5421
|
}
|
|
5407
5422
|
async setupLocalTracks() {
|
|
5408
|
-
logger$
|
|
5423
|
+
logger$15.debug("[RTCPeerConnectionController] Setting up local tracks/transceivers.");
|
|
5409
5424
|
const localStream = this.localStream ?? await this.localStreamController.buildLocalStream();
|
|
5410
5425
|
if (this.transceiverController?.useAddStream ?? false) {
|
|
5411
|
-
logger$
|
|
5426
|
+
logger$15.warn("[RTCPeerConnectionController] Using deprecated addStream API to add local stream.");
|
|
5412
5427
|
this.peerConnection?.addStream(localStream);
|
|
5413
5428
|
if (!this.isNegotiating) {
|
|
5414
|
-
logger$
|
|
5429
|
+
logger$15.debug("[RTCPeerConnectionController] Forcing negotiationneeded after local tracks setup.");
|
|
5415
5430
|
this.negotiationNeeded$.next();
|
|
5416
5431
|
}
|
|
5417
5432
|
return;
|
|
@@ -5427,7 +5442,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5427
5442
|
const transceivers = (kind === "audio" ? this.transceiverController?.audioTransceivers : this.transceiverController?.videoTransceivers) ?? [];
|
|
5428
5443
|
await this.transceiverController?.setupTransceiverSender(track, localStream, transceivers[index]);
|
|
5429
5444
|
} else {
|
|
5430
|
-
logger$
|
|
5445
|
+
logger$15.debug(`[RTCPeerConnectionController] Using addTrack for local ${kind} track:`, track.id);
|
|
5431
5446
|
this.peerConnection?.addTrack(track, localStream);
|
|
5432
5447
|
}
|
|
5433
5448
|
}
|
|
@@ -5444,7 +5459,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5444
5459
|
async setupRemoteTracks() {
|
|
5445
5460
|
if (!this.peerConnection) throw new require_operators.DependencyError("RTCPeerConnection is not initialized");
|
|
5446
5461
|
this.peerConnection.ontrack = (event) => {
|
|
5447
|
-
logger$
|
|
5462
|
+
logger$15.debug("[RTCPeerConnectionController] Remote track received:", event.track.kind);
|
|
5448
5463
|
if (event.streams[0]) this._remoteStream$.next(event.streams[0]);
|
|
5449
5464
|
else {
|
|
5450
5465
|
const existingTracks = this._remoteStream$.value?.getTracks() ?? [];
|
|
@@ -5470,9 +5485,9 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5470
5485
|
try {
|
|
5471
5486
|
const localStream = this.localStreamController.addTrack(track);
|
|
5472
5487
|
this.peerConnection.addTrack(track, localStream);
|
|
5473
|
-
logger$
|
|
5488
|
+
logger$15.debug(`[RTCPeerConnectionController] ${track.kind} track added:`, track.id);
|
|
5474
5489
|
} catch (error) {
|
|
5475
|
-
logger$
|
|
5490
|
+
logger$15.error(`[RTCPeerConnectionController] Failed to add ${track.kind} track:`, error);
|
|
5476
5491
|
this._errors$.next(error);
|
|
5477
5492
|
throw error;
|
|
5478
5493
|
}
|
|
@@ -5489,15 +5504,15 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5489
5504
|
}
|
|
5490
5505
|
const sender = this.peerConnection.getSenders().find((sender$1) => sender$1.track?.id === trackId);
|
|
5491
5506
|
if (!sender) {
|
|
5492
|
-
logger$
|
|
5507
|
+
logger$15.debug(`[RTCPeerConnectionController] track not found: ${trackId}`);
|
|
5493
5508
|
return;
|
|
5494
5509
|
}
|
|
5495
5510
|
try {
|
|
5496
5511
|
this.peerConnection.removeTrack(sender);
|
|
5497
5512
|
this.localStreamController.removeTrack(trackId);
|
|
5498
|
-
logger$
|
|
5513
|
+
logger$15.debug(`[RTCPeerConnectionController] ${sender.track?.kind} track removed:`, trackId);
|
|
5499
5514
|
} catch (error) {
|
|
5500
|
-
logger$
|
|
5515
|
+
logger$15.error(`[RTCPeerConnectionController] Failed to remove ${sender.track?.kind} track:`, error);
|
|
5501
5516
|
this._errors$.next(error);
|
|
5502
5517
|
throw error;
|
|
5503
5518
|
}
|
|
@@ -5524,7 +5539,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5524
5539
|
async replaceAudioTrackWithConstraints(constraints) {
|
|
5525
5540
|
const senders = this.peerConnection?.getSenders().filter((s) => s.track?.kind === "audio" && s.track.readyState === "live");
|
|
5526
5541
|
if (!senders || senders.length === 0) {
|
|
5527
|
-
logger$
|
|
5542
|
+
logger$15.warn("[RTCPeerConnectionController] No live audio sender to replace");
|
|
5528
5543
|
return;
|
|
5529
5544
|
}
|
|
5530
5545
|
for (const sender of senders) {
|
|
@@ -5542,7 +5557,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5542
5557
|
const newTrack = (await this.getUserMedia({ audio: mergedConstraints })).getAudioTracks()[0];
|
|
5543
5558
|
await sender.replaceTrack(newTrack);
|
|
5544
5559
|
this.localStreamController.addTrack(newTrack);
|
|
5545
|
-
logger$
|
|
5560
|
+
logger$15.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
|
|
5546
5561
|
}
|
|
5547
5562
|
}
|
|
5548
5563
|
/**
|
|
@@ -5550,7 +5565,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5550
5565
|
* Completes all observables to prevent memory leaks.
|
|
5551
5566
|
*/
|
|
5552
5567
|
destroy() {
|
|
5553
|
-
logger$
|
|
5568
|
+
logger$15.debug(`[RTCPeerConnectionController] Destroying RTCPeerConnectionController. ${this.propose}`);
|
|
5554
5569
|
this.removeConnectionTimer();
|
|
5555
5570
|
this._iceGatheringController?.destroy();
|
|
5556
5571
|
this.localStreamController.destroy();
|
|
@@ -5574,7 +5589,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5574
5589
|
}
|
|
5575
5590
|
stopRemoteTracks() {
|
|
5576
5591
|
this._remoteStream$.value?.getTracks().forEach((track) => {
|
|
5577
|
-
logger$
|
|
5592
|
+
logger$15.debug(`[RTCPeerConnectionController] Stopping remote track: ${track.kind}`);
|
|
5578
5593
|
track.stop();
|
|
5579
5594
|
});
|
|
5580
5595
|
}
|
|
@@ -5591,7 +5606,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5591
5606
|
...params,
|
|
5592
5607
|
sdp: finalRemote
|
|
5593
5608
|
};
|
|
5594
|
-
logger$
|
|
5609
|
+
logger$15.debug("[RTCPeerConnectionController] Setting remote description:", answer);
|
|
5595
5610
|
return this.peerConnection.setRemoteDescription(answer);
|
|
5596
5611
|
}
|
|
5597
5612
|
};
|
|
@@ -5629,7 +5644,7 @@ function isVertoPingInnerParams(value) {
|
|
|
5629
5644
|
|
|
5630
5645
|
//#endregion
|
|
5631
5646
|
//#region src/managers/VertoManager.ts
|
|
5632
|
-
const logger$
|
|
5647
|
+
const logger$14 = require_operators.getLogger();
|
|
5633
5648
|
var VertoManager = class extends Destroyable {
|
|
5634
5649
|
constructor(callSession) {
|
|
5635
5650
|
super();
|
|
@@ -5655,6 +5670,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5655
5670
|
this._screenShareTimeoutMs = 5e4;
|
|
5656
5671
|
this._nodeId$ = this.createBehaviorSubject(options.nodeId ?? null);
|
|
5657
5672
|
this.onError = options.onError;
|
|
5673
|
+
this.onModifyFailed = options.onModifyFailed;
|
|
5658
5674
|
this.initSubscriptions();
|
|
5659
5675
|
this.initMainPeerConnection();
|
|
5660
5676
|
}
|
|
@@ -5667,7 +5683,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5667
5683
|
try {
|
|
5668
5684
|
await this.executeVerto(vertoModifyMessage);
|
|
5669
5685
|
} catch (error) {
|
|
5670
|
-
logger$
|
|
5686
|
+
logger$14.warn("[WebRTCManager] Call might already be disconnected, error sending Verto hold:", error);
|
|
5671
5687
|
throw error;
|
|
5672
5688
|
}
|
|
5673
5689
|
}
|
|
@@ -5680,7 +5696,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5680
5696
|
try {
|
|
5681
5697
|
await this.executeVerto(vertoModifyMessage);
|
|
5682
5698
|
} catch (error) {
|
|
5683
|
-
logger$
|
|
5699
|
+
logger$14.warn("[WebRTCManager] Call might already be disconnected, error sending Verto unhold:", error);
|
|
5684
5700
|
throw error;
|
|
5685
5701
|
}
|
|
5686
5702
|
}
|
|
@@ -5733,7 +5749,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5733
5749
|
if (event.member_id) this.setSelfIdIfNull(event.member_id);
|
|
5734
5750
|
});
|
|
5735
5751
|
this.subscribeTo(this.vertoMedia$, (event) => {
|
|
5736
|
-
logger$
|
|
5752
|
+
logger$14.debug("[WebRTCManager] Received Verto media event (early media SDP):", event);
|
|
5737
5753
|
this._signalingStatus$.next("ringing");
|
|
5738
5754
|
const { sdp, callID } = event;
|
|
5739
5755
|
this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
|
|
@@ -5742,7 +5758,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5742
5758
|
});
|
|
5743
5759
|
});
|
|
5744
5760
|
this.subscribeTo(this.vertoAnswer$, (event) => {
|
|
5745
|
-
logger$
|
|
5761
|
+
logger$14.debug("[WebRTCManager] Received Verto answer event:", event);
|
|
5746
5762
|
this._signalingStatus$.next("connecting");
|
|
5747
5763
|
const { sdp, callID } = event;
|
|
5748
5764
|
this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
|
|
@@ -5751,7 +5767,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5751
5767
|
});
|
|
5752
5768
|
});
|
|
5753
5769
|
this.subscribeTo(this.vertoMediaParams$, (event) => {
|
|
5754
|
-
logger$
|
|
5770
|
+
logger$14.debug("[WebRTCManager] Received Verto mediaParams event:", event);
|
|
5755
5771
|
const { mediaParams, callID } = event;
|
|
5756
5772
|
const rtcPeerConnController = this._rtcPeerConnectionsMap.get(callID);
|
|
5757
5773
|
const { audio, video } = mediaParams;
|
|
@@ -5765,13 +5781,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5765
5781
|
timestamp: Date.now()
|
|
5766
5782
|
});
|
|
5767
5783
|
} catch (error) {
|
|
5768
|
-
logger$
|
|
5784
|
+
logger$14.warn("[WebRTCManager] Error applying server-pushed media params:", error);
|
|
5769
5785
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
5770
5786
|
}
|
|
5771
5787
|
})();
|
|
5772
5788
|
});
|
|
5773
5789
|
this.subscribeTo(this.vertoPing$, (vertoPing) => {
|
|
5774
|
-
this.attachManager.attach(this.
|
|
5790
|
+
this.attachManager.attach(this.buildAttachableCall());
|
|
5775
5791
|
this.sendVertoPong(vertoPing);
|
|
5776
5792
|
});
|
|
5777
5793
|
}
|
|
@@ -5787,13 +5803,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5787
5803
|
*/
|
|
5788
5804
|
setNodeIdIfNull(nodeId) {
|
|
5789
5805
|
if (!this._nodeId$.value && nodeId) {
|
|
5790
|
-
logger$
|
|
5806
|
+
logger$14.debug(`[WebRTCManager] Early node_id set: ${nodeId}`);
|
|
5791
5807
|
this._nodeId$.next(nodeId);
|
|
5792
5808
|
}
|
|
5793
5809
|
}
|
|
5794
5810
|
setSelfIdIfNull(selfId) {
|
|
5795
5811
|
if (!this._selfId$.value && selfId) {
|
|
5796
|
-
logger$
|
|
5812
|
+
logger$14.debug(`[WebRTCManager] Early selfId set: ${selfId}`);
|
|
5797
5813
|
this._selfId$.next(selfId);
|
|
5798
5814
|
}
|
|
5799
5815
|
}
|
|
@@ -5802,7 +5818,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5802
5818
|
const vertoPongMessage = VertoPong({ ...vertoPing });
|
|
5803
5819
|
await this.executeVerto(vertoPongMessage);
|
|
5804
5820
|
} catch (error) {
|
|
5805
|
-
logger$
|
|
5821
|
+
logger$14.warn("[WebRTCManager] Call might disconnect, error sending Verto pong:", error);
|
|
5806
5822
|
this.onError?.(new require_operators.VertoPongError(error));
|
|
5807
5823
|
}
|
|
5808
5824
|
}
|
|
@@ -5812,7 +5828,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5812
5828
|
if (audio) await this.mainPeerConnection.updateSendersConstraints("audio", audio);
|
|
5813
5829
|
if (video) await this.mainPeerConnection.updateSendersConstraints("video", video);
|
|
5814
5830
|
} catch (error) {
|
|
5815
|
-
logger$
|
|
5831
|
+
logger$14.warn("[WebRTCManager] Error updating media constraints:", error);
|
|
5816
5832
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
5817
5833
|
throw error;
|
|
5818
5834
|
}
|
|
@@ -5820,6 +5836,15 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5820
5836
|
get selfId() {
|
|
5821
5837
|
return this._selfId$.value;
|
|
5822
5838
|
}
|
|
5839
|
+
/** Build an AttachableCall from the current call state. */
|
|
5840
|
+
buildAttachableCall(idOverride) {
|
|
5841
|
+
return {
|
|
5842
|
+
nodeId: this.nodeId ?? void 0,
|
|
5843
|
+
id: idOverride ?? this.webRtcCallSession.id,
|
|
5844
|
+
to: this.webRtcCallSession.to,
|
|
5845
|
+
mediaDirections: this.webRtcCallSession.mediaDirections
|
|
5846
|
+
};
|
|
5847
|
+
}
|
|
5823
5848
|
/**
|
|
5824
5849
|
* Request a video keyframe via RTCP PLI/FIR.
|
|
5825
5850
|
*
|
|
@@ -5833,20 +5858,20 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5833
5858
|
try {
|
|
5834
5859
|
const pc = this.mainPeerConnection.peerConnection;
|
|
5835
5860
|
if (!pc) {
|
|
5836
|
-
logger$
|
|
5861
|
+
logger$14.warn("[WebRTCManager] No peer connection for keyframe request");
|
|
5837
5862
|
return;
|
|
5838
5863
|
}
|
|
5839
5864
|
const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
|
|
5840
5865
|
if (!videoReceiver) {
|
|
5841
|
-
logger$
|
|
5866
|
+
logger$14.warn("[WebRTCManager] No video receiver for keyframe request");
|
|
5842
5867
|
return;
|
|
5843
5868
|
}
|
|
5844
5869
|
if (typeof videoReceiver.requestKeyFrame === "function") {
|
|
5845
5870
|
videoReceiver.requestKeyFrame();
|
|
5846
|
-
logger$
|
|
5847
|
-
} else logger$
|
|
5871
|
+
logger$14.debug("[WebRTCManager] Keyframe requested via RTCRtpReceiver.requestKeyFrame()");
|
|
5872
|
+
} else logger$14.debug("[WebRTCManager] requestKeyFrame() not supported, skipping");
|
|
5848
5873
|
} catch (error) {
|
|
5849
|
-
logger$
|
|
5874
|
+
logger$14.warn("[WebRTCManager] Keyframe request failed (non-fatal):", error);
|
|
5850
5875
|
}
|
|
5851
5876
|
}
|
|
5852
5877
|
/**
|
|
@@ -5864,13 +5889,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5864
5889
|
try {
|
|
5865
5890
|
const controller = this.mainPeerConnection;
|
|
5866
5891
|
if (!controller.peerConnection) {
|
|
5867
|
-
logger$
|
|
5892
|
+
logger$14.warn("[WebRTCManager] No peer connection for ICE restart");
|
|
5868
5893
|
return;
|
|
5869
5894
|
}
|
|
5870
5895
|
await controller.triggerIceRestart(relayOnly);
|
|
5871
|
-
logger$
|
|
5896
|
+
logger$14.info(`[WebRTCManager] ICE restart initiated${relayOnly ? " (relay-only)" : ""}`);
|
|
5872
5897
|
} catch (error) {
|
|
5873
|
-
logger$
|
|
5898
|
+
logger$14.error("[WebRTCManager] ICE restart failed:", error);
|
|
5874
5899
|
throw error;
|
|
5875
5900
|
}
|
|
5876
5901
|
}
|
|
@@ -5888,13 +5913,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5888
5913
|
const entries = Array.from(this._rtcPeerConnectionsMap.entries());
|
|
5889
5914
|
for (const [id, controller] of entries) try {
|
|
5890
5915
|
if (!controller.peerConnection) {
|
|
5891
|
-
logger$
|
|
5916
|
+
logger$14.debug(`[WebRTCManager] No peer connection for leg ${id}, skipping ICE restart`);
|
|
5892
5917
|
continue;
|
|
5893
5918
|
}
|
|
5894
5919
|
await controller.triggerIceRestart(relayOnly);
|
|
5895
|
-
logger$
|
|
5920
|
+
logger$14.info(`[WebRTCManager] ICE restart initiated for leg ${id}${relayOnly ? " (relay-only)" : ""}`);
|
|
5896
5921
|
} catch (error) {
|
|
5897
|
-
logger$
|
|
5922
|
+
logger$14.warn(`[WebRTCManager] ICE restart failed for leg ${id}:`, error);
|
|
5898
5923
|
}
|
|
5899
5924
|
}
|
|
5900
5925
|
/**
|
|
@@ -5906,7 +5931,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5906
5931
|
requestKeyframeAll() {
|
|
5907
5932
|
for (const [id, controller] of this._rtcPeerConnectionsMap) {
|
|
5908
5933
|
if (controller.isScreenShare) {
|
|
5909
|
-
logger$
|
|
5934
|
+
logger$14.debug(`[WebRTCManager] Skipping keyframe for send-only screen share leg ${id}`);
|
|
5910
5935
|
continue;
|
|
5911
5936
|
}
|
|
5912
5937
|
try {
|
|
@@ -5916,10 +5941,10 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5916
5941
|
if (!videoReceiver) continue;
|
|
5917
5942
|
if (typeof videoReceiver.requestKeyFrame === "function") {
|
|
5918
5943
|
videoReceiver.requestKeyFrame();
|
|
5919
|
-
logger$
|
|
5944
|
+
logger$14.debug(`[WebRTCManager] Keyframe requested for leg ${id}`);
|
|
5920
5945
|
}
|
|
5921
5946
|
} catch (error) {
|
|
5922
|
-
logger$
|
|
5947
|
+
logger$14.warn(`[WebRTCManager] Keyframe request failed for leg ${id} (non-fatal):`, error);
|
|
5923
5948
|
}
|
|
5924
5949
|
}
|
|
5925
5950
|
}
|
|
@@ -5967,7 +5992,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5967
5992
|
}
|
|
5968
5993
|
async sendLocalDescription(message, rtcPeerConnController) {
|
|
5969
5994
|
const vertoMethod = message.method;
|
|
5970
|
-
const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController,
|
|
5995
|
+
const optionalsParams = this.getSendLocalSDPOptionalParams(rtcPeerConnController, message);
|
|
5971
5996
|
try {
|
|
5972
5997
|
const response = await this.executeVerto(message, optionalsParams);
|
|
5973
5998
|
switch (vertoMethod) {
|
|
@@ -5980,8 +6005,9 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5980
6005
|
default:
|
|
5981
6006
|
}
|
|
5982
6007
|
} catch (error) {
|
|
5983
|
-
logger$
|
|
6008
|
+
logger$14.error(`[WebRTCManager] Error sending Verto ${vertoMethod}:`, error);
|
|
5984
6009
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6010
|
+
if (vertoMethod === "verto.modify") this.onModifyFailed?.();
|
|
5985
6011
|
}
|
|
5986
6012
|
}
|
|
5987
6013
|
async processModifyResponse(response, rtcPeerConnController) {
|
|
@@ -5994,7 +6020,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
5994
6020
|
sdp
|
|
5995
6021
|
});
|
|
5996
6022
|
} catch (error) {
|
|
5997
|
-
logger$
|
|
6023
|
+
logger$14.warn("[WebRTCManager] Error processing modify response:", error);
|
|
5998
6024
|
const modifyError = error instanceof Error ? error : new Error(String(error), { cause: error });
|
|
5999
6025
|
this.onError?.(modifyError);
|
|
6000
6026
|
}
|
|
@@ -6006,19 +6032,24 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6006
6032
|
this._nodeId$.next(require_operators.getValueFrom(response, "result.node_id") ?? null);
|
|
6007
6033
|
const memberId = require_operators.getValueFrom(response, "result.result.result.memberID") ?? null;
|
|
6008
6034
|
const callId = require_operators.getValueFrom(response, "result.result.result.callID") ?? null;
|
|
6009
|
-
logger$
|
|
6035
|
+
logger$14.debug("[WebRTCManager] Verto invite response:", {
|
|
6010
6036
|
callId,
|
|
6011
6037
|
memberId,
|
|
6012
6038
|
response
|
|
6013
6039
|
});
|
|
6014
6040
|
this._selfId$.next(memberId);
|
|
6015
6041
|
rtcPeerConnController.setMemberId(memberId);
|
|
6016
|
-
if (callId)
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
logger$
|
|
6042
|
+
if (callId) {
|
|
6043
|
+
this.webRtcCallSession.addCallId(callId);
|
|
6044
|
+
this.attachManager.attach(this.buildAttachableCall(callId));
|
|
6045
|
+
} else logger$14.warn("[WebRTCManager] Cannot attach call, missing callId:", {
|
|
6046
|
+
nodeId: this.nodeId,
|
|
6047
|
+
callId
|
|
6048
|
+
});
|
|
6049
|
+
logger$14.info("[WebRTCManager] Verto invite successful");
|
|
6050
|
+
logger$14.debug(`[WebRTCManager] nodeid: ${this._nodeId$.value}, selfId: ${this._selfId$.value}`);
|
|
6020
6051
|
} else {
|
|
6021
|
-
logger$
|
|
6052
|
+
logger$14.error("[WebRTCManager] Verto invite failed:", response);
|
|
6022
6053
|
const inviteError = response.error ? new require_operators.JSONRPCError(response.error.code, response.error.message, response.error.data) : /* @__PURE__ */ new Error("Verto invite failed: unexpected response");
|
|
6023
6054
|
this.onError?.(inviteError);
|
|
6024
6055
|
}
|
|
@@ -6063,17 +6094,17 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6063
6094
|
if (options.initOffer) this.handleInboundAnswer(rtcPeerConnController);
|
|
6064
6095
|
}
|
|
6065
6096
|
async handleInboundAnswer(rtcPeerConnController) {
|
|
6066
|
-
logger$
|
|
6097
|
+
logger$14.debug("[WebRTCManager] Waiting for inbound call to be accepted or rejected");
|
|
6067
6098
|
const vertoByeOrAccepted = await (0, rxjs.firstValueFrom)((0, rxjs.race)(this.vertoBye$, this.webRtcCallSession.answered$).pipe((0, rxjs.takeUntil)(this.destroyed$))).catch(() => null);
|
|
6068
6099
|
if (vertoByeOrAccepted === null) {
|
|
6069
|
-
logger$
|
|
6100
|
+
logger$14.debug("[WebRTCManager] Inbound answer handler aborted (destroyed).");
|
|
6070
6101
|
return;
|
|
6071
6102
|
}
|
|
6072
6103
|
if (isVertoByeMessage(vertoByeOrAccepted)) {
|
|
6073
|
-
logger$
|
|
6104
|
+
logger$14.info("[WebRTCManager] Inbound call ended by remote before answer.");
|
|
6074
6105
|
this.callSession?.destroy();
|
|
6075
6106
|
} else if (!vertoByeOrAccepted) {
|
|
6076
|
-
logger$
|
|
6107
|
+
logger$14.info("[WebRTCManager] Inbound call rejected by user.");
|
|
6077
6108
|
try {
|
|
6078
6109
|
await this.bye("USER_BUSY");
|
|
6079
6110
|
} finally {
|
|
@@ -6081,21 +6112,22 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6081
6112
|
this.callSession?.destroy();
|
|
6082
6113
|
}
|
|
6083
6114
|
} else {
|
|
6084
|
-
logger$
|
|
6115
|
+
logger$14.debug("[WebRTCManager] Inbound call accepted, creating SDP answer");
|
|
6085
6116
|
const answerOptions = this.webRtcCallSession.answerMediaOptions;
|
|
6086
6117
|
try {
|
|
6087
6118
|
await rtcPeerConnController.acceptInbound(answerOptions);
|
|
6088
6119
|
} catch (error) {
|
|
6089
|
-
logger$
|
|
6120
|
+
logger$14.error("[WebRTCManager] Error creating inbound answer:", error);
|
|
6090
6121
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6091
6122
|
}
|
|
6092
6123
|
}
|
|
6093
6124
|
}
|
|
6094
6125
|
setupVertoAttachHandler() {
|
|
6095
6126
|
this.subscribeTo(this.vertoAttach$, async (vertoAttach) => {
|
|
6096
|
-
logger$
|
|
6127
|
+
logger$14.debug("[WebRTCManager] Received Verto attach event for existing call:", vertoAttach);
|
|
6097
6128
|
const { callID } = vertoAttach;
|
|
6098
6129
|
await this.attachManager.attach({
|
|
6130
|
+
nodeId: this.nodeId ?? void 0,
|
|
6099
6131
|
id: callID,
|
|
6100
6132
|
to: vertoAttach.callee_id_number,
|
|
6101
6133
|
mediaDirections: {
|
|
@@ -6140,11 +6172,11 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6140
6172
|
setupVertoByeHandler() {
|
|
6141
6173
|
this.subscribeTo(this.vertoBye$, () => {
|
|
6142
6174
|
this._signalingStatus$.next("disconnected");
|
|
6143
|
-
this.attachManager.detach(this.
|
|
6175
|
+
this.attachManager.detach(this.buildAttachableCall());
|
|
6144
6176
|
this.callSession?.destroy();
|
|
6145
6177
|
});
|
|
6146
6178
|
}
|
|
6147
|
-
getSendLocalSDPOptionalParams(rtcPeerConnController,
|
|
6179
|
+
getSendLocalSDPOptionalParams(rtcPeerConnController, vertoMessage) {
|
|
6148
6180
|
let subscribe = void 0;
|
|
6149
6181
|
if (!rtcPeerConnController.firstSDPExchangeCompleted) {
|
|
6150
6182
|
subscribe = [];
|
|
@@ -6152,7 +6184,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6152
6184
|
else if (rtcPeerConnController.isAdditionalDevice) subscribe.push(...PreferencesContainer.instance.inviteSubscribeAdditionalDevice);
|
|
6153
6185
|
else if (rtcPeerConnController.isScreenShare) subscribe.push(...PreferencesContainer.instance.inviteSubscribeScreenshare);
|
|
6154
6186
|
}
|
|
6155
|
-
const isInvite =
|
|
6187
|
+
const isInvite = isVertoInviteMessage(vertoMessage);
|
|
6156
6188
|
const isReattach = isInvite && this.webRtcCallSession.options.reattach;
|
|
6157
6189
|
return {
|
|
6158
6190
|
callID: rtcPeerConnController.id,
|
|
@@ -6161,13 +6193,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6161
6193
|
};
|
|
6162
6194
|
}
|
|
6163
6195
|
async sendLocalDescriptionOnceAccepted(vertoMessageRequest, rtcPeerConnectionController) {
|
|
6164
|
-
logger$
|
|
6196
|
+
logger$14.debug("[WebRTCManager] Waiting for call to be accepted or ended before sending answer");
|
|
6165
6197
|
const vertoByeOrAccepted = await (0, rxjs.firstValueFrom)((0, rxjs.race)(this.vertoBye$, this.webRtcCallSession.answered$));
|
|
6166
6198
|
if (isVertoByeMessage(vertoByeOrAccepted)) {
|
|
6167
|
-
logger$
|
|
6199
|
+
logger$14.info("[WebRTCManager] Call ended before answer was sent.");
|
|
6168
6200
|
this.callSession?.destroy();
|
|
6169
6201
|
} else if (!vertoByeOrAccepted) {
|
|
6170
|
-
logger$
|
|
6202
|
+
logger$14.info("[WebRTCManager] Call was not accepted, sending verto.bye.");
|
|
6171
6203
|
try {
|
|
6172
6204
|
await this.bye("USER_BUSY");
|
|
6173
6205
|
} finally {
|
|
@@ -6175,14 +6207,14 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6175
6207
|
this.callSession?.destroy();
|
|
6176
6208
|
}
|
|
6177
6209
|
} else {
|
|
6178
|
-
logger$
|
|
6210
|
+
logger$14.debug("[WebRTCManager] Call accepted, sending answer");
|
|
6179
6211
|
try {
|
|
6180
6212
|
this._signalingStatus$.next("connecting");
|
|
6181
6213
|
await this.sendLocalDescription(vertoMessageRequest, rtcPeerConnectionController);
|
|
6182
6214
|
await rtcPeerConnectionController.updateAnswerStatus({ status: "sent" });
|
|
6183
|
-
await this.attachManager.attach(this.
|
|
6215
|
+
await this.attachManager.attach(this.buildAttachableCall());
|
|
6184
6216
|
} catch (error) {
|
|
6185
|
-
logger$
|
|
6217
|
+
logger$14.error("[WebRTCManager] Error sending Verto answer:", error);
|
|
6186
6218
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6187
6219
|
await rtcPeerConnectionController.updateAnswerStatus({ status: "failed" });
|
|
6188
6220
|
}
|
|
@@ -6273,10 +6305,10 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6273
6305
|
});
|
|
6274
6306
|
await (0, rxjs.firstValueFrom)(rtcPeerConnController.connectionState$.pipe((0, rxjs.filter)((state) => state === "connected"), (0, rxjs.take)(1), (0, rxjs.timeout)(this._screenShareTimeoutMs)));
|
|
6275
6307
|
this._screenShareStatus$.next("started");
|
|
6276
|
-
logger$
|
|
6308
|
+
logger$14.info("[WebRTCManager] Screen share started successfully.");
|
|
6277
6309
|
return rtcPeerConnController.id;
|
|
6278
6310
|
} catch (error) {
|
|
6279
|
-
logger$
|
|
6311
|
+
logger$14.warn("[WebRTCManager] Error initializing additional peer connection:", error);
|
|
6280
6312
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6281
6313
|
if (rtcPeerConnController) rtcPeerConnController.destroy();
|
|
6282
6314
|
this._screenShareStatus$.next("none");
|
|
@@ -6295,9 +6327,9 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6295
6327
|
if (removeTrack) return this.mainPeerConnection.stopTrackSender(removeTrack, { updateTransceiverDirection: true });
|
|
6296
6328
|
}
|
|
6297
6329
|
async removeScreenMedia() {
|
|
6298
|
-
if (!["starting", "started"].includes(this._screenShareStatus$.value)) logger$
|
|
6330
|
+
if (!["starting", "started"].includes(this._screenShareStatus$.value)) logger$14.warn("[WebRTCManager] No active screen share to stop.");
|
|
6299
6331
|
if (!this._screenShareId) {
|
|
6300
|
-
logger$
|
|
6332
|
+
logger$14.debug("[WebRTCManager] No screen share peer connection found.");
|
|
6301
6333
|
return;
|
|
6302
6334
|
}
|
|
6303
6335
|
this._screenShareStatus$.next("stopping");
|
|
@@ -6326,12 +6358,12 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6326
6358
|
dialogParams: this.dialogParams(rtcPeerConnController)
|
|
6327
6359
|
}));
|
|
6328
6360
|
} catch (error) {
|
|
6329
|
-
logger$
|
|
6361
|
+
logger$14.warn("[WebRTCManager] Call might already be disconnected, error sending Verto bye:", error);
|
|
6330
6362
|
throw error;
|
|
6331
6363
|
}
|
|
6332
6364
|
}
|
|
6333
6365
|
async bye(cause) {
|
|
6334
|
-
this.attachManager.detach(this.
|
|
6366
|
+
this.attachManager.detach(this.buildAttachableCall());
|
|
6335
6367
|
const rtcPeerConnController = this._rtcPeerConnectionsMap.get(this.webRtcCallSession.id);
|
|
6336
6368
|
if (rtcPeerConnController) await this.executeVertoBye(rtcPeerConnController, cause);
|
|
6337
6369
|
}
|
|
@@ -6344,7 +6376,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6344
6376
|
try {
|
|
6345
6377
|
await this.executeVerto(vertoInfoMessage);
|
|
6346
6378
|
} catch (error) {
|
|
6347
|
-
logger$
|
|
6379
|
+
logger$14.warn("[WebRTCManager] Error sending DTMF digits:", error);
|
|
6348
6380
|
throw error;
|
|
6349
6381
|
}
|
|
6350
6382
|
}
|
|
@@ -6355,10 +6387,10 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6355
6387
|
action: "transfer"
|
|
6356
6388
|
});
|
|
6357
6389
|
try {
|
|
6358
|
-
logger$
|
|
6390
|
+
logger$14.debug("[WebRTCManager] Transferring call with options:", options);
|
|
6359
6391
|
await this.executeVerto(message);
|
|
6360
6392
|
} catch (error) {
|
|
6361
|
-
logger$
|
|
6393
|
+
logger$14.error("[WebRTCManager] Error transferring call:", error);
|
|
6362
6394
|
throw error;
|
|
6363
6395
|
}
|
|
6364
6396
|
}
|
|
@@ -6380,7 +6412,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6380
6412
|
*
|
|
6381
6413
|
* Extends Destroyable for automatic RxJS cleanup.
|
|
6382
6414
|
*/
|
|
6383
|
-
const logger$
|
|
6415
|
+
const logger$13 = require_operators.getLogger();
|
|
6384
6416
|
const DEFAULT_POLLING_INTERVAL_MS = 1e3;
|
|
6385
6417
|
const DEFAULT_BASELINE_SAMPLES = 10;
|
|
6386
6418
|
const DEFAULT_NO_AUDIO_PACKET_THRESHOLD_MS = 2e3;
|
|
@@ -6396,6 +6428,12 @@ function computePacketLossPercent(lost, received) {
|
|
|
6396
6428
|
if (total === 0) return 0;
|
|
6397
6429
|
return lost / total * 100;
|
|
6398
6430
|
}
|
|
6431
|
+
function isInboundRtpStat(stat) {
|
|
6432
|
+
return typeof stat === "object" && stat !== null && "type" in stat && stat.type === "inbound-rtp";
|
|
6433
|
+
}
|
|
6434
|
+
function isCandidatePairStat(stat) {
|
|
6435
|
+
return typeof stat === "object" && stat !== null && "type" in stat && stat.type === "candidate-pair";
|
|
6436
|
+
}
|
|
6399
6437
|
var RTCStatsMonitor = class extends Destroyable {
|
|
6400
6438
|
constructor(peerConnection, config = {}) {
|
|
6401
6439
|
super();
|
|
@@ -6464,9 +6502,9 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
6464
6502
|
const now = Date.now();
|
|
6465
6503
|
this.lastAudioPacketChangeTime = now;
|
|
6466
6504
|
this.lastVideoPacketChangeTime = now;
|
|
6467
|
-
logger$
|
|
6505
|
+
logger$13.debug("[RTCStatsMonitor] Starting stats monitoring");
|
|
6468
6506
|
this.subscribeTo((0, rxjs.interval)(this.pollingIntervalMs).pipe((0, rxjs.filter)(() => this.running), (0, rxjs.switchMap)(() => (0, rxjs.from)(this.peerConnection.getStats()).pipe((0, rxjs.catchError)((err) => {
|
|
6469
|
-
logger$
|
|
6507
|
+
logger$13.warn("[RTCStatsMonitor] Failed to get stats:", err);
|
|
6470
6508
|
return rxjs.EMPTY;
|
|
6471
6509
|
}))), (0, rxjs.filter)(() => this.running), (0, rxjs.map)((report) => this.extractSample(report))), (sample) => this._sample$.next(sample));
|
|
6472
6510
|
this.subscribeTo(this._sample$.pipe((0, rxjs.take)(this.baselineSampleCount), (0, rxjs.toArray)(), (0, rxjs.map)((samples) => ({
|
|
@@ -6474,7 +6512,7 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
6474
6512
|
jitter: samples.reduce((s, b) => s + b.audioJitter, 0) / samples.length,
|
|
6475
6513
|
ready: true
|
|
6476
6514
|
}))), (baseline) => {
|
|
6477
|
-
logger$
|
|
6515
|
+
logger$13.debug(`[RTCStatsMonitor] Baseline established: rtt=${baseline.rtt.toFixed(1)}ms, jitter=${baseline.jitter.toFixed(1)}ms`);
|
|
6478
6516
|
this._baseline$.next(baseline);
|
|
6479
6517
|
});
|
|
6480
6518
|
this.subscribeTo(this._sample$.pipe((0, rxjs.scan)((acc, sample) => ({
|
|
@@ -6511,10 +6549,10 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
6511
6549
|
stop() {
|
|
6512
6550
|
if (!this.running) return;
|
|
6513
6551
|
this.running = false;
|
|
6514
|
-
logger$
|
|
6552
|
+
logger$13.debug("[RTCStatsMonitor] Stopping stats monitoring");
|
|
6515
6553
|
}
|
|
6516
6554
|
destroy() {
|
|
6517
|
-
logger$
|
|
6555
|
+
logger$13.debug("[RTCStatsMonitor] Destroying RTCStatsMonitor");
|
|
6518
6556
|
this.stop();
|
|
6519
6557
|
super.destroy();
|
|
6520
6558
|
}
|
|
@@ -6527,17 +6565,15 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
6527
6565
|
let roundTripTime = 0;
|
|
6528
6566
|
let availableOutgoingBitrate;
|
|
6529
6567
|
report.forEach((stat) => {
|
|
6530
|
-
if (stat.
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
videoPacketsLost += stat.packetsLost ?? 0;
|
|
6538
|
-
}
|
|
6568
|
+
if (isInboundRtpStat(stat)) if (stat.kind === "audio") {
|
|
6569
|
+
audioPacketsReceived += stat.packetsReceived ?? this.lastAudioPacketsReceived;
|
|
6570
|
+
audioPacketsLost += stat.packetsLost ?? 0;
|
|
6571
|
+
audioJitter = Math.max(audioJitter, (stat.jitter ?? 0) * 1e3);
|
|
6572
|
+
} else {
|
|
6573
|
+
videoPacketsReceived += stat.packetsReceived ?? this.lastVideoPacketsReceived;
|
|
6574
|
+
videoPacketsLost += stat.packetsLost ?? 0;
|
|
6539
6575
|
}
|
|
6540
|
-
if (stat
|
|
6576
|
+
if (isCandidatePairStat(stat) && stat.state === "succeeded" && stat.nominated) {
|
|
6541
6577
|
roundTripTime = stat.currentRoundTripTime ? stat.currentRoundTripTime * 1e3 : this.lastRoundTripTime;
|
|
6542
6578
|
availableOutgoingBitrate = stat.availableOutgoingBitrate ?? this.lastAvailableOutgoingBitrate;
|
|
6543
6579
|
}
|
|
@@ -6644,7 +6680,7 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
6644
6680
|
|
|
6645
6681
|
//#endregion
|
|
6646
6682
|
//#region src/managers/CallRecoveryManager.ts
|
|
6647
|
-
const logger$
|
|
6683
|
+
const logger$12 = require_operators.getLogger();
|
|
6648
6684
|
const DEFAULT_DEBOUNCE_TIME_MS = 2e3;
|
|
6649
6685
|
const DEFAULT_COOLDOWN_MS = 1e4;
|
|
6650
6686
|
const DEFAULT_ICE_GRACE_PERIOD_MS = 3e3;
|
|
@@ -6680,7 +6716,7 @@ const DEGRADATION_ONLY_ISSUES = new Set([
|
|
|
6680
6716
|
* A state machine tracks the pipeline: IDLE -> DEBOUNCING -> RECOVERING -> COOLDOWN.
|
|
6681
6717
|
*/
|
|
6682
6718
|
var CallRecoveryManager = class extends Destroyable {
|
|
6683
|
-
constructor(callbacks, config = {}) {
|
|
6719
|
+
constructor(callbacks, inputs, config = {}) {
|
|
6684
6720
|
super();
|
|
6685
6721
|
this._recoveryState$ = this.createBehaviorSubject("idle");
|
|
6686
6722
|
this._recoveryEvent$ = this.createSubject();
|
|
@@ -6694,6 +6730,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6694
6730
|
this._cooldownUntil = 0;
|
|
6695
6731
|
this._pipelineStop$ = this.createSubject();
|
|
6696
6732
|
this._callbacks = callbacks;
|
|
6733
|
+
this._inputs = inputs;
|
|
6697
6734
|
this._config = {
|
|
6698
6735
|
debounceTimeMs: config.debounceTimeMs ?? DEFAULT_DEBOUNCE_TIME_MS,
|
|
6699
6736
|
cooldownMs: config.cooldownMs ?? DEFAULT_COOLDOWN_MS,
|
|
@@ -6740,10 +6777,10 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6740
6777
|
*/
|
|
6741
6778
|
async requestIceRestart() {
|
|
6742
6779
|
if (this._recoveryState$.value === "recovering") {
|
|
6743
|
-
logger$
|
|
6780
|
+
logger$12.info("CallRecoveryManager: manual ICE restart skipped — recovery already in progress");
|
|
6744
6781
|
return;
|
|
6745
6782
|
}
|
|
6746
|
-
logger$
|
|
6783
|
+
logger$12.info("CallRecoveryManager: manual ICE restart requested");
|
|
6747
6784
|
this.transitionTo("recovering");
|
|
6748
6785
|
await this.executeIceRestart(false);
|
|
6749
6786
|
this.startCooldown();
|
|
@@ -6759,7 +6796,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6759
6796
|
* WebSocket reconnect or call state recovers to 'connected'.
|
|
6760
6797
|
*/
|
|
6761
6798
|
reset() {
|
|
6762
|
-
logger$
|
|
6799
|
+
logger$12.info("CallRecoveryManager: resetting counters");
|
|
6763
6800
|
this._attemptCount = 0;
|
|
6764
6801
|
this._keyframeBurstCount = 0;
|
|
6765
6802
|
this._keyframeBurstStart = 0;
|
|
@@ -6768,6 +6805,22 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6768
6805
|
this.transitionTo("idle");
|
|
6769
6806
|
}
|
|
6770
6807
|
/**
|
|
6808
|
+
* Notify the recovery manager that a verto.modify (ICE restart SDP exchange)
|
|
6809
|
+
* failed at the signaling layer. Resets cooldown and pushes a new trigger
|
|
6810
|
+
* so recovery can re-attempt.
|
|
6811
|
+
*/
|
|
6812
|
+
notifyModifyFailed() {
|
|
6813
|
+
if (this._recoveryState$.value === "cooldown" || this._recoveryState$.value === "idle") {
|
|
6814
|
+
logger$12.info("CallRecoveryManager: verto.modify failed — re-entering recovery");
|
|
6815
|
+
this._cooldownUntil = 0;
|
|
6816
|
+
this.transitionTo("idle");
|
|
6817
|
+
this.pushTrigger({
|
|
6818
|
+
source: "network",
|
|
6819
|
+
detail: "modify_failed_during_recovery"
|
|
6820
|
+
});
|
|
6821
|
+
}
|
|
6822
|
+
}
|
|
6823
|
+
/**
|
|
6771
6824
|
* Feed bandwidth information for graceful degradation (Section 22).
|
|
6772
6825
|
* Call this from the stats monitor with current available outgoing bitrate.
|
|
6773
6826
|
*/
|
|
@@ -6782,7 +6835,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6782
6835
|
reason: `bandwidth ${bitrateKbps}kbps below threshold ${this._config.degradationBitrateThreshold}kbps`,
|
|
6783
6836
|
timestamp: Date.now()
|
|
6784
6837
|
});
|
|
6785
|
-
logger$
|
|
6838
|
+
logger$12.warn(`CallRecoveryManager: disabling video — bandwidth ${bitrateKbps}kbps < ${this._config.degradationBitrateThreshold}kbps`);
|
|
6786
6839
|
} else if (wasConstrained && bitrateKbps >= this._config.degradationRecoveryThreshold) {
|
|
6787
6840
|
this._bandwidthConstrained$.next(false);
|
|
6788
6841
|
this._callbacks.enableVideo();
|
|
@@ -6791,7 +6844,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6791
6844
|
reason: `bandwidth ${bitrateKbps}kbps recovered above ${this._config.degradationRecoveryThreshold}kbps`,
|
|
6792
6845
|
timestamp: Date.now()
|
|
6793
6846
|
});
|
|
6794
|
-
logger$
|
|
6847
|
+
logger$12.info(`CallRecoveryManager: restoring video — bandwidth ${bitrateKbps}kbps >= ${this._config.degradationRecoveryThreshold}kbps`);
|
|
6795
6848
|
}
|
|
6796
6849
|
}
|
|
6797
6850
|
/**
|
|
@@ -6810,14 +6863,14 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6810
6863
|
handleWebSocketReconnect() {
|
|
6811
6864
|
const pcState = this._callbacks.getPeerConnectionState();
|
|
6812
6865
|
if (pcState === "connected" || pcState === "completed") {
|
|
6813
|
-
logger$
|
|
6866
|
+
logger$12.info("CallRecoveryManager: signal-only reconnect — peer connection still alive");
|
|
6814
6867
|
this.emitEvent({
|
|
6815
6868
|
action: "signal_reconnect",
|
|
6816
6869
|
reason: "WebSocket reconnected, peer connection still connected",
|
|
6817
6870
|
timestamp: Date.now()
|
|
6818
6871
|
});
|
|
6819
6872
|
} else {
|
|
6820
|
-
logger$
|
|
6873
|
+
logger$12.info("CallRecoveryManager: full reconnect — peer connection also down");
|
|
6821
6874
|
this.emitEvent({
|
|
6822
6875
|
action: "full_reconnect",
|
|
6823
6876
|
reason: "WebSocket reconnected, peer connection not connected — ICE restart needed",
|
|
@@ -6838,10 +6891,10 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6838
6891
|
initPipeline() {
|
|
6839
6892
|
this.subscribeTo(this._trigger$.pipe((0, rxjs.tap)(() => {
|
|
6840
6893
|
if (this._recoveryState$.value === "idle") this.transitionTo("debouncing");
|
|
6841
|
-
}), (0, rxjs.debounceTime)(this._config.debounceTimeMs), (0, rxjs.filter)(() => this.passGateChecks()), (0, rxjs.exhaustMap)((trigger) => this.executeTieredRecovery(trigger)), (0, rxjs.takeUntil)((0, rxjs.merge)(this._destroyed$, this._pipelineStop$))), {
|
|
6894
|
+
}), (0, rxjs.debounceTime)(this._config.debounceTimeMs), (0, rxjs.withLatestFrom)(this._inputs.signalingReady$), (0, rxjs.filter)(([, signalingReady]) => this.passGateChecks(signalingReady)), (0, rxjs.map)(([trigger]) => trigger), (0, rxjs.exhaustMap)((trigger) => this.executeTieredRecovery(trigger)), (0, rxjs.takeUntil)((0, rxjs.merge)(this._destroyed$, this._pipelineStop$))), {
|
|
6842
6895
|
next: () => {},
|
|
6843
6896
|
error: (err) => {
|
|
6844
|
-
logger$
|
|
6897
|
+
logger$12.error("CallRecoveryManager: pipeline error", err);
|
|
6845
6898
|
this.transitionTo("idle");
|
|
6846
6899
|
}
|
|
6847
6900
|
});
|
|
@@ -6868,27 +6921,27 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6868
6921
|
reason: `no packet loss for ${this._config.packetLossRecoveryDelaySec}s — restoring video`,
|
|
6869
6922
|
timestamp: Date.now()
|
|
6870
6923
|
});
|
|
6871
|
-
logger$
|
|
6924
|
+
logger$12.info(`CallRecoveryManager: restoring video — no packet loss for ${this._config.packetLossRecoveryDelaySec}s`);
|
|
6872
6925
|
});
|
|
6873
6926
|
}
|
|
6874
|
-
passGateChecks() {
|
|
6927
|
+
passGateChecks(signalingReady) {
|
|
6875
6928
|
if (this._callbacks.isNegotiating()) {
|
|
6876
|
-
logger$
|
|
6929
|
+
logger$12.debug("CallRecoveryManager: gate blocked — negotiation in progress");
|
|
6877
6930
|
this.transitionTo("idle");
|
|
6878
6931
|
return false;
|
|
6879
6932
|
}
|
|
6880
|
-
if (!
|
|
6881
|
-
logger$
|
|
6933
|
+
if (!signalingReady) {
|
|
6934
|
+
logger$12.debug("CallRecoveryManager: gate blocked — signaling not ready");
|
|
6882
6935
|
this.transitionTo("idle");
|
|
6883
6936
|
return false;
|
|
6884
6937
|
}
|
|
6885
6938
|
if (!this._callbacks.isCallConnected()) {
|
|
6886
|
-
logger$
|
|
6939
|
+
logger$12.debug("CallRecoveryManager: gate blocked — call not connected");
|
|
6887
6940
|
this.transitionTo("idle");
|
|
6888
6941
|
return false;
|
|
6889
6942
|
}
|
|
6890
6943
|
if (this.isCooldownActive()) {
|
|
6891
|
-
logger$
|
|
6944
|
+
logger$12.debug("CallRecoveryManager: gate blocked — cooldown active");
|
|
6892
6945
|
this.transitionTo("cooldown");
|
|
6893
6946
|
return false;
|
|
6894
6947
|
}
|
|
@@ -6899,9 +6952,9 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6899
6952
|
}
|
|
6900
6953
|
executeTieredRecovery(trigger) {
|
|
6901
6954
|
this.transitionTo("recovering");
|
|
6902
|
-
logger$
|
|
6955
|
+
logger$12.info(`CallRecoveryManager: starting tiered recovery — source=${trigger.source} detail=${trigger.detail}`);
|
|
6903
6956
|
return (0, rxjs.from)(this.runTiers(trigger)).pipe((0, rxjs.tap)(() => this.startCooldown()), (0, rxjs.catchError)((err) => {
|
|
6904
|
-
logger$
|
|
6957
|
+
logger$12.error("CallRecoveryManager: tiered recovery failed", err);
|
|
6905
6958
|
this.startCooldown();
|
|
6906
6959
|
return rxjs.EMPTY;
|
|
6907
6960
|
}));
|
|
@@ -6909,7 +6962,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6909
6962
|
async runTiers(trigger) {
|
|
6910
6963
|
this.executeKeyframe(trigger.detail);
|
|
6911
6964
|
if (trigger.issueType && DEGRADATION_ONLY_ISSUES.has(trigger.issueType)) {
|
|
6912
|
-
logger$
|
|
6965
|
+
logger$12.debug(`CallRecoveryManager: degradation-only issue (${trigger.issueType}) — Tier 1 only, skipping ICE restart`);
|
|
6913
6966
|
return;
|
|
6914
6967
|
}
|
|
6915
6968
|
if (this._attemptCount < this._config.maxAttempts) {
|
|
@@ -6926,13 +6979,13 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6926
6979
|
maxAttempts: this._config.maxAttempts,
|
|
6927
6980
|
timestamp: Date.now()
|
|
6928
6981
|
});
|
|
6929
|
-
logger$
|
|
6982
|
+
logger$12.warn("CallRecoveryManager: max recovery attempts reached");
|
|
6930
6983
|
}
|
|
6931
6984
|
}
|
|
6932
6985
|
executeKeyframe(reason) {
|
|
6933
6986
|
const now = Date.now();
|
|
6934
6987
|
if (now < this._keyframeCooldownUntil) {
|
|
6935
|
-
logger$
|
|
6988
|
+
logger$12.debug("CallRecoveryManager: keyframe request skipped — cooldown active");
|
|
6936
6989
|
return;
|
|
6937
6990
|
}
|
|
6938
6991
|
if (now - this._keyframeBurstStart > this._config.keyframeBurstWindowMs) {
|
|
@@ -6941,7 +6994,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6941
6994
|
}
|
|
6942
6995
|
if (this._keyframeBurstCount >= this._config.keyframeMaxBurst) {
|
|
6943
6996
|
this._keyframeCooldownUntil = now + this._config.keyframeCooldownMs;
|
|
6944
|
-
logger$
|
|
6997
|
+
logger$12.debug(`CallRecoveryManager: keyframe burst limit reached (${this._config.keyframeMaxBurst}), cooldown until ${this._keyframeCooldownUntil}`);
|
|
6945
6998
|
return;
|
|
6946
6999
|
}
|
|
6947
7000
|
this._keyframeBurstCount += 1;
|
|
@@ -6951,12 +7004,12 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6951
7004
|
reason,
|
|
6952
7005
|
timestamp: now
|
|
6953
7006
|
});
|
|
6954
|
-
logger$
|
|
7007
|
+
logger$12.debug(`CallRecoveryManager: keyframe requested (burst ${this._keyframeBurstCount}/${this._config.keyframeMaxBurst})`);
|
|
6955
7008
|
}
|
|
6956
7009
|
async executeIceRestart(relayOnly) {
|
|
6957
7010
|
this._attemptCount += 1;
|
|
6958
7011
|
const tier = relayOnly ? "Tier 3 (relay-only)" : "Tier 2 (standard)";
|
|
6959
|
-
logger$
|
|
7012
|
+
logger$12.info(`CallRecoveryManager: ${tier} ICE restart — attempt ${this._attemptCount}/${this._config.maxAttempts}`);
|
|
6960
7013
|
this.emitEvent({
|
|
6961
7014
|
action: "reinvite_started",
|
|
6962
7015
|
reason: `${tier} ICE restart`,
|
|
@@ -6973,7 +7026,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6973
7026
|
maxAttempts: this._config.maxAttempts,
|
|
6974
7027
|
timestamp: Date.now()
|
|
6975
7028
|
});
|
|
6976
|
-
logger$
|
|
7029
|
+
logger$12.info(`CallRecoveryManager: ${tier} ICE restart succeeded`);
|
|
6977
7030
|
this._attemptCount = 0;
|
|
6978
7031
|
return true;
|
|
6979
7032
|
}
|
|
@@ -6984,7 +7037,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6984
7037
|
maxAttempts: this._config.maxAttempts,
|
|
6985
7038
|
timestamp: Date.now()
|
|
6986
7039
|
});
|
|
6987
|
-
logger$
|
|
7040
|
+
logger$12.warn(`CallRecoveryManager: ${tier} ICE restart failed`);
|
|
6988
7041
|
return false;
|
|
6989
7042
|
} catch {
|
|
6990
7043
|
this.emitEvent({
|
|
@@ -6994,7 +7047,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
6994
7047
|
maxAttempts: this._config.maxAttempts,
|
|
6995
7048
|
timestamp: Date.now()
|
|
6996
7049
|
});
|
|
6997
|
-
logger$
|
|
7050
|
+
logger$12.warn(`CallRecoveryManager: ${tier} ICE restart timed out`);
|
|
6998
7051
|
return false;
|
|
6999
7052
|
}
|
|
7000
7053
|
}
|
|
@@ -7015,7 +7068,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7015
7068
|
transitionTo(state) {
|
|
7016
7069
|
const prev = this._recoveryState$.value;
|
|
7017
7070
|
if (prev !== state) {
|
|
7018
|
-
logger$
|
|
7071
|
+
logger$12.debug(`CallRecoveryManager: state ${prev} -> ${state}`);
|
|
7019
7072
|
this._recoveryState$.next(state);
|
|
7020
7073
|
}
|
|
7021
7074
|
}
|
|
@@ -7117,7 +7170,7 @@ function mosToQualityLevel(mos) {
|
|
|
7117
7170
|
|
|
7118
7171
|
//#endregion
|
|
7119
7172
|
//#region src/core/entities/Call.ts
|
|
7120
|
-
const logger$
|
|
7173
|
+
const logger$11 = require_operators.getLogger();
|
|
7121
7174
|
/**
|
|
7122
7175
|
* Ratio between the critical and warning RTT spike multipliers.
|
|
7123
7176
|
* Warning threshold = baseline * warningMultiplier (default 3x)
|
|
@@ -7135,7 +7188,7 @@ const fromDestinationParams = (destination) => {
|
|
|
7135
7188
|
});
|
|
7136
7189
|
return params;
|
|
7137
7190
|
} catch (error) {
|
|
7138
|
-
logger$
|
|
7191
|
+
logger$11.warn(`Failed to parse destination URI: ${destination}`, error);
|
|
7139
7192
|
return {};
|
|
7140
7193
|
}
|
|
7141
7194
|
};
|
|
@@ -7194,7 +7247,10 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7194
7247
|
this.subscribeTo((0, rxjs.merge)(this._status$.asObservable(), this.vertoManager.signalingStatus$).pipe((0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this._destroyed$)), (status) => {
|
|
7195
7248
|
this._lastMergedStatus = status;
|
|
7196
7249
|
if (status === "connected" && !this._statsMonitor) this.initResilienceSubsystems();
|
|
7197
|
-
else if (status === "disconnected"
|
|
7250
|
+
else if (status === "disconnected") {
|
|
7251
|
+
this._statsMonitor?.destroy();
|
|
7252
|
+
this._statsMonitor = void 0;
|
|
7253
|
+
} else if (status === "destroyed" || status === "failed") this.stopResilienceSubsystems();
|
|
7198
7254
|
});
|
|
7199
7255
|
}
|
|
7200
7256
|
/** Observable stream of errors from media, signaling, and peer connection layers. */
|
|
@@ -7213,6 +7269,10 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7213
7269
|
this.destroy();
|
|
7214
7270
|
}
|
|
7215
7271
|
}
|
|
7272
|
+
/** Notify the recovery manager that a verto.modify signaling exchange failed. */
|
|
7273
|
+
notifyModifyFailed() {
|
|
7274
|
+
this._recoveryManager?.notifyModifyFailed();
|
|
7275
|
+
}
|
|
7216
7276
|
/** Whether this call is `'inbound'` or `'outbound'`. */
|
|
7217
7277
|
get direction() {
|
|
7218
7278
|
return this.options.initOffer ? "inbound" : "outbound";
|
|
@@ -7326,7 +7386,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7326
7386
|
if (isJSONRPCErrorResponse(response)) throw new require_operators.JSONRPCError(parseInt(response.result?.code ?? "0"), `Error response from method ${method}: ${response.result?.code} ${response.result?.message}`, void 0, void 0, request.id);
|
|
7327
7387
|
return response;
|
|
7328
7388
|
} catch (error) {
|
|
7329
|
-
logger$
|
|
7389
|
+
logger$11.error(`[Call] Error executing method ${method} with params`, params, error);
|
|
7330
7390
|
throw error;
|
|
7331
7391
|
}
|
|
7332
7392
|
}
|
|
@@ -7529,9 +7589,9 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7529
7589
|
*/
|
|
7530
7590
|
initResilienceSubsystems() {
|
|
7531
7591
|
const pc = this.rtcPeerConnection;
|
|
7532
|
-
logger$
|
|
7592
|
+
logger$11.debug(`[Call] initResilienceSubsystems: pc=${pc ? "exists" : "undefined"}, connectionState=${pc?.connectionState}`);
|
|
7533
7593
|
if (!pc) {
|
|
7534
|
-
logger$
|
|
7594
|
+
logger$11.warn("[Call] No peer connection available, skipping resilience init");
|
|
7535
7595
|
return;
|
|
7536
7596
|
}
|
|
7537
7597
|
try {
|
|
@@ -7566,21 +7626,20 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7566
7626
|
disableVideo: () => {
|
|
7567
7627
|
try {
|
|
7568
7628
|
this.vertoManager.muteMainVideoInputDevice();
|
|
7569
|
-
logger$
|
|
7629
|
+
logger$11.debug("[Call] Recovery manager disabled video");
|
|
7570
7630
|
} catch {
|
|
7571
|
-
logger$
|
|
7631
|
+
logger$11.debug("[Call] Recovery manager failed to disable video");
|
|
7572
7632
|
}
|
|
7573
7633
|
},
|
|
7574
7634
|
enableVideo: () => {
|
|
7575
7635
|
this.vertoManager.unmuteMainVideoInputDevice().catch(() => {
|
|
7576
|
-
logger$
|
|
7636
|
+
logger$11.debug("[Call] Recovery manager failed to enable video");
|
|
7577
7637
|
});
|
|
7578
7638
|
},
|
|
7579
7639
|
isNegotiating: () => this.vertoManager.mainPeerConnection.isNegotiating,
|
|
7580
|
-
isWebSocketConnected: () => this._lastMergedStatus !== "disconnected",
|
|
7581
7640
|
isCallConnected: () => this._lastMergedStatus === "connected",
|
|
7582
7641
|
getPeerConnectionState: () => pc.connectionState
|
|
7583
|
-
}, {
|
|
7642
|
+
}, { signalingReady$: this.clientSession.authenticated$ }, {
|
|
7584
7643
|
debounceTimeMs: prefs.recoveryDebounceTime,
|
|
7585
7644
|
cooldownMs: prefs.recoveryCooldown,
|
|
7586
7645
|
iceGracePeriodMs: prefs.iceDisconnectedGracePeriod,
|
|
@@ -7623,6 +7682,15 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7623
7682
|
});
|
|
7624
7683
|
this.subscribeTo(this._recoveryManager.recoveryEvent$, (event) => {
|
|
7625
7684
|
this._recoveryEvent$.next(event);
|
|
7685
|
+
if (event.action === "max_attempts_reached") {
|
|
7686
|
+
logger$11.warn("[Call] All recovery attempts exhausted, terminating call");
|
|
7687
|
+
this.emitError({
|
|
7688
|
+
kind: "network",
|
|
7689
|
+
fatal: true,
|
|
7690
|
+
error: /* @__PURE__ */ new Error("Call recovery failed: all attempts exhausted"),
|
|
7691
|
+
callId: this.id
|
|
7692
|
+
});
|
|
7693
|
+
}
|
|
7626
7694
|
});
|
|
7627
7695
|
this.subscribeTo(this._recoveryManager.bandwidthConstrained$, (constrained) => {
|
|
7628
7696
|
this._bandwidthConstrained$.next(constrained);
|
|
@@ -7635,13 +7703,13 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7635
7703
|
else if (event.type === "online") this._recoveryManager?.handleWebSocketReconnect();
|
|
7636
7704
|
});
|
|
7637
7705
|
this.subscribeTo(this.clientSession.authenticated$.pipe((0, rxjs.skip)(1), (0, rxjs.filter)(Boolean)), () => {
|
|
7638
|
-
logger$
|
|
7706
|
+
logger$11.debug("[Call] WebSocket reconnected — notifying recovery manager");
|
|
7639
7707
|
this._recoveryManager?.handleWebSocketReconnect();
|
|
7640
7708
|
});
|
|
7641
7709
|
this._statsMonitor.start();
|
|
7642
|
-
logger$
|
|
7710
|
+
logger$11.debug("[Call] Resilience subsystems initialized for call", this.id);
|
|
7643
7711
|
} catch (error) {
|
|
7644
|
-
logger$
|
|
7712
|
+
logger$11.warn("[Call] Failed to initialize resilience subsystems:", error);
|
|
7645
7713
|
}
|
|
7646
7714
|
}
|
|
7647
7715
|
/**
|
|
@@ -7703,19 +7771,19 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7703
7771
|
}
|
|
7704
7772
|
isCallSessionEvent(event) {
|
|
7705
7773
|
try {
|
|
7706
|
-
logger$
|
|
7774
|
+
logger$11.debug("[Call] Checking if event is for this call session:", event);
|
|
7707
7775
|
const callId = require_operators.getValueFrom(event, "params.params.callID") ?? require_operators.getValueFrom(event, "params.call_id");
|
|
7708
7776
|
const roomSessionId = require_operators.getValueFrom(event, "params.room_session_id");
|
|
7709
|
-
logger$
|
|
7777
|
+
logger$11.debug(`[Call] Extracted session identifiers callID: ${callId} and roomSessionID: ${roomSessionId} from event:`);
|
|
7710
7778
|
return callId === this.id || !!callId && this.callEventsManager.isCallIdValid(callId) || !!roomSessionId && this.callEventsManager.isRoomSessionIdValid(roomSessionId);
|
|
7711
7779
|
} catch (error) {
|
|
7712
|
-
logger$
|
|
7780
|
+
logger$11.error("[Call] Error checking if event is for this call session:", error);
|
|
7713
7781
|
return false;
|
|
7714
7782
|
}
|
|
7715
7783
|
}
|
|
7716
7784
|
get callSessionEvents$() {
|
|
7717
7785
|
return this.cachedObservable("callSessionEvents$", () => this.clientSession.signalingEvent$.pipe((0, rxjs.filter)((event) => this.isCallSessionEvent(event)), (0, rxjs.tap)((event) => {
|
|
7718
|
-
logger$
|
|
7786
|
+
logger$11.debug("[Call] Received call session event:", event);
|
|
7719
7787
|
}), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.share)()));
|
|
7720
7788
|
}
|
|
7721
7789
|
/** Observable of call-updated events. */
|
|
@@ -7786,10 +7854,10 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7786
7854
|
return filtered$;
|
|
7787
7855
|
}
|
|
7788
7856
|
get webrtcMessages$() {
|
|
7789
|
-
return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isWebrtcMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$
|
|
7857
|
+
return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isWebrtcMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$11.debug("[Call] Event is a WebRTC message event:", event)), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.share)()));
|
|
7790
7858
|
}
|
|
7791
7859
|
get callEvent$() {
|
|
7792
|
-
return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isSignalwireCallMetadata, "params"), (0, rxjs.tap)((event) => logger$
|
|
7860
|
+
return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isSignalwireCallMetadata, "params"), (0, rxjs.tap)((event) => logger$11.debug("[Call] Event is a call event:", event)), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.share)()));
|
|
7793
7861
|
}
|
|
7794
7862
|
get layoutEvent$() {
|
|
7795
7863
|
return this.cachedObservable("layoutEvent$", () => this.callEvent$.pipe(require_operators.filterAs(isLayoutChangedMetadata, "params")));
|
|
@@ -7923,10 +7991,10 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7923
7991
|
message
|
|
7924
7992
|
};
|
|
7925
7993
|
this.clientSession.execute(WebrtcVerto(params)).catch((error) => {
|
|
7926
|
-
logger$
|
|
7994
|
+
logger$11.warn(`[Call] verto.subscribe for '${eventType}' failed (non-fatal):`, error);
|
|
7927
7995
|
});
|
|
7928
7996
|
} catch (error) {
|
|
7929
|
-
logger$
|
|
7997
|
+
logger$11.warn(`[Call] Failed to send verto.subscribe for '${eventType}':`, error);
|
|
7930
7998
|
}
|
|
7931
7999
|
}
|
|
7932
8000
|
};
|
|
@@ -7948,6 +8016,7 @@ function inferCallErrorKind(error) {
|
|
|
7948
8016
|
function isFatalError(error) {
|
|
7949
8017
|
if (error instanceof require_operators.VertoPongError) return false;
|
|
7950
8018
|
if (error instanceof require_operators.MediaTrackError) return false;
|
|
8019
|
+
if (error instanceof require_operators.RPCTimeoutError) return false;
|
|
7951
8020
|
return true;
|
|
7952
8021
|
}
|
|
7953
8022
|
/**
|
|
@@ -7979,6 +8048,9 @@ var CallFactory = class {
|
|
|
7979
8048
|
callId: callInstance.id
|
|
7980
8049
|
};
|
|
7981
8050
|
callInstance.emitError(callError);
|
|
8051
|
+
},
|
|
8052
|
+
onModifyFailed: () => {
|
|
8053
|
+
callInstance.notifyModifyFailed();
|
|
7982
8054
|
}
|
|
7983
8055
|
}),
|
|
7984
8056
|
callEventsManager: new CallEventsManager(callInstance)
|
|
@@ -7992,7 +8064,7 @@ var CallFactory = class {
|
|
|
7992
8064
|
|
|
7993
8065
|
//#endregion
|
|
7994
8066
|
//#region src/behaviors/Collection.ts
|
|
7995
|
-
const logger$
|
|
8067
|
+
const logger$10 = require_operators.getLogger();
|
|
7996
8068
|
var Fetcher = class {
|
|
7997
8069
|
constructor(endpoint, params, http) {
|
|
7998
8070
|
this.endpoint = endpoint;
|
|
@@ -8016,7 +8088,7 @@ var Fetcher = class {
|
|
|
8016
8088
|
this.hasMore = !!this.nextUrl;
|
|
8017
8089
|
return result.data.filter(this.filter).map(this.mapper);
|
|
8018
8090
|
}
|
|
8019
|
-
logger$
|
|
8091
|
+
logger$10.error("Failed to fetch entity");
|
|
8020
8092
|
return [];
|
|
8021
8093
|
}
|
|
8022
8094
|
async id(v) {
|
|
@@ -8088,7 +8160,7 @@ var EntityCollection = class extends Destroyable {
|
|
|
8088
8160
|
this._hasMore$.next(this.fetchController.hasMore ?? false);
|
|
8089
8161
|
this.loading$.next(false);
|
|
8090
8162
|
} catch (error) {
|
|
8091
|
-
logger$
|
|
8163
|
+
logger$10.error(`Failed to fetch initial collection data`, error);
|
|
8092
8164
|
this._hasMore$.next(this.fetchController.hasMore ?? false);
|
|
8093
8165
|
this.loading$.next(false);
|
|
8094
8166
|
this.onError?.(new require_operators.CollectionFetchError("fetchMore", error));
|
|
@@ -8102,7 +8174,7 @@ var EntityCollection = class extends Destroyable {
|
|
|
8102
8174
|
if (data) this.upsertData(data);
|
|
8103
8175
|
return data;
|
|
8104
8176
|
} catch (error) {
|
|
8105
|
-
logger$
|
|
8177
|
+
logger$10.error(`Failed to fetch data for (${String(key)}:${String(value)}) :`, error);
|
|
8106
8178
|
this.loading$.next(false);
|
|
8107
8179
|
this.onError?.(new require_operators.CollectionFetchError(`tryFetch(${String(key)})`, error));
|
|
8108
8180
|
}
|
|
@@ -8133,9 +8205,9 @@ var EntityCollection = class extends Destroyable {
|
|
|
8133
8205
|
}
|
|
8134
8206
|
};
|
|
8135
8207
|
var EntityCollectionTransformed = class {
|
|
8136
|
-
constructor(originalCollection, filter$
|
|
8208
|
+
constructor(originalCollection, filter$14 = (i) => !!i, mapper = (item) => item) {
|
|
8137
8209
|
this.originalCollection = originalCollection;
|
|
8138
|
-
this.filter = filter$
|
|
8210
|
+
this.filter = filter$14;
|
|
8139
8211
|
this.mapper = mapper;
|
|
8140
8212
|
}
|
|
8141
8213
|
get loading$() {
|
|
@@ -8352,13 +8424,13 @@ var Address = class extends Destroyable {
|
|
|
8352
8424
|
|
|
8353
8425
|
//#endregion
|
|
8354
8426
|
//#region src/core/utils.ts
|
|
8355
|
-
const logger$
|
|
8427
|
+
const logger$9 = require_operators.getLogger();
|
|
8356
8428
|
const isRPCConnectResult = (e) => {
|
|
8357
|
-
logger$
|
|
8429
|
+
logger$9.debug("isRPCConnectResult check:", e);
|
|
8358
8430
|
if (!e || typeof e !== "object") return false;
|
|
8359
8431
|
const result = e;
|
|
8360
8432
|
const is = typeof result.identity === "string" && typeof result.protocol === "string" && typeof result.authorization === "object" && typeof result.authorization.jti === "string" && typeof result.authorization.project_id === "string" && typeof result.authorization.fabric_subscriber === "object";
|
|
8361
|
-
logger$
|
|
8433
|
+
logger$9.debug("isRPCConnectResult check result:", is);
|
|
8362
8434
|
return is;
|
|
8363
8435
|
};
|
|
8364
8436
|
var PendingRPC = class PendingRPC {
|
|
@@ -8367,7 +8439,7 @@ var PendingRPC = class PendingRPC {
|
|
|
8367
8439
|
}
|
|
8368
8440
|
constructor(request, responses$, options) {
|
|
8369
8441
|
this.id = (0, uuid.v4)();
|
|
8370
|
-
logger$
|
|
8442
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}: method:${request.method}] Creating PendingRPC`);
|
|
8371
8443
|
this.request = request;
|
|
8372
8444
|
const timeoutMs = options?.timeoutMs ?? PendingRPC.defaultTimeoutMs;
|
|
8373
8445
|
const signal = options?.signal;
|
|
@@ -8378,10 +8450,10 @@ var PendingRPC = class PendingRPC {
|
|
|
8378
8450
|
}
|
|
8379
8451
|
let isSettled = false;
|
|
8380
8452
|
const subscription = (0, rxjs.race)(responses$.pipe((0, rxjs.filter)((result) => result.id === request.id), (0, rxjs.take)(1)), new rxjs.Observable((subscriber) => {
|
|
8381
|
-
const timer$
|
|
8453
|
+
const timer$2 = setTimeout(() => {
|
|
8382
8454
|
subscriber.error(new require_operators.RPCTimeoutError(request.id, timeoutMs));
|
|
8383
8455
|
}, timeoutMs);
|
|
8384
|
-
return () => clearTimeout(timer$
|
|
8456
|
+
return () => clearTimeout(timer$2);
|
|
8385
8457
|
}), signal ? new rxjs.Observable((subscriber) => {
|
|
8386
8458
|
const abortHandler = () => {
|
|
8387
8459
|
subscriber.error(new DOMException("The operation was aborted", "AbortError"));
|
|
@@ -8393,22 +8465,22 @@ var PendingRPC = class PendingRPC {
|
|
|
8393
8465
|
isSettled = true;
|
|
8394
8466
|
if (response.error) {
|
|
8395
8467
|
const rpcError = new require_operators.JSONRPCError(response.error.code, response.error.message, response.error.data, void 0, request.id);
|
|
8396
|
-
logger$
|
|
8468
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Rejecting promise with RPC error:`, rpcError);
|
|
8397
8469
|
reject(rpcError);
|
|
8398
8470
|
} else {
|
|
8399
|
-
logger$
|
|
8471
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Resolving promise with response:`, response);
|
|
8400
8472
|
resolve(response);
|
|
8401
8473
|
}
|
|
8402
8474
|
subscription.unsubscribe();
|
|
8403
8475
|
},
|
|
8404
8476
|
error: (error) => {
|
|
8405
|
-
logger$
|
|
8477
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Rejecting promise with error:`, error);
|
|
8406
8478
|
isSettled = true;
|
|
8407
8479
|
reject(error);
|
|
8408
8480
|
subscription.unsubscribe();
|
|
8409
8481
|
},
|
|
8410
8482
|
complete: () => {
|
|
8411
|
-
logger$
|
|
8483
|
+
logger$9.debug(`[PendingRPC(${this.id}) request:${request.id}] Observable completed`);
|
|
8412
8484
|
if (!isSettled) reject(new require_operators.RPCTimeoutError(request.id, timeoutMs));
|
|
8413
8485
|
subscription.unsubscribe();
|
|
8414
8486
|
}
|
|
@@ -8428,7 +8500,7 @@ var PendingRPC = class PendingRPC {
|
|
|
8428
8500
|
|
|
8429
8501
|
//#endregion
|
|
8430
8502
|
//#region src/managers/ClientSessionManager.ts
|
|
8431
|
-
const logger$
|
|
8503
|
+
const logger$8 = require_operators.getLogger();
|
|
8432
8504
|
const getAddressSearchURI = (options) => {
|
|
8433
8505
|
const to = options.to?.split("?")[0];
|
|
8434
8506
|
const from$8 = options.from?.startsWith("subscriber://") ? options.from.replace("subscriber://", "") : options.from;
|
|
@@ -8522,7 +8594,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8522
8594
|
try {
|
|
8523
8595
|
return await this.transport.execute(request, options);
|
|
8524
8596
|
} catch (error) {
|
|
8525
|
-
logger$
|
|
8597
|
+
logger$8.debug("[Session] Execute Error", error);
|
|
8526
8598
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
8527
8599
|
throw error;
|
|
8528
8600
|
}
|
|
@@ -8536,40 +8608,40 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8536
8608
|
return true;
|
|
8537
8609
|
}
|
|
8538
8610
|
setupMessageHandlers() {
|
|
8539
|
-
logger$
|
|
8611
|
+
logger$8.debug("[Session] Setting up message handlers");
|
|
8540
8612
|
this.subscribeTo(this.authStateEvent$, async (authStateEvent) => {
|
|
8541
|
-
logger$
|
|
8613
|
+
logger$8.debug("[Session] Authorization state event received:", authStateEvent);
|
|
8542
8614
|
try {
|
|
8543
8615
|
await this.updateAuthorizationStateInStorage(authStateEvent.authorization_state);
|
|
8544
8616
|
} catch (error) {
|
|
8545
|
-
logger$
|
|
8617
|
+
logger$8.error("[Session] Failed to handle authorization state update:", error);
|
|
8546
8618
|
this._errors$.next(new require_operators.AuthStateHandlerError(error));
|
|
8547
8619
|
}
|
|
8548
8620
|
});
|
|
8549
8621
|
this.subscribeTo(this.transport.connectionStatus$.pipe((0, rxjs.filter)((status) => status === "connected"), (0, rxjs.exhaustMap)(() => {
|
|
8550
|
-
logger$
|
|
8622
|
+
logger$8.debug("[Session] Connection established, initiating authentication");
|
|
8551
8623
|
return (0, rxjs.from)(this.authenticate()).pipe((0, rxjs.catchError)((error) => {
|
|
8552
8624
|
this.handleAuthenticationError(error).catch((err) => {
|
|
8553
|
-
logger$
|
|
8625
|
+
logger$8.error("[Session] Error handling authentication failure:", err);
|
|
8554
8626
|
});
|
|
8555
8627
|
return rxjs.EMPTY;
|
|
8556
8628
|
}));
|
|
8557
8629
|
})), void 0);
|
|
8558
8630
|
this.subscribeTo(this.vertoInvite$, async (invite) => {
|
|
8559
|
-
logger$
|
|
8631
|
+
logger$8.debug("[Session] Verto invite received:", invite);
|
|
8560
8632
|
try {
|
|
8561
8633
|
await this.createInboundCall(invite);
|
|
8562
8634
|
} catch (error) {
|
|
8563
|
-
logger$
|
|
8635
|
+
logger$8.error("[Session] Error handling Verto invite:", error);
|
|
8564
8636
|
this._errors$.next(new require_operators.VertoInviteHandlerError(error));
|
|
8565
8637
|
}
|
|
8566
8638
|
});
|
|
8567
8639
|
this.subscribeTo(this.vertoAttach$, async (attach) => {
|
|
8568
|
-
logger$
|
|
8640
|
+
logger$8.debug("[Session] Verto attach received:", attach);
|
|
8569
8641
|
try {
|
|
8570
8642
|
await this.handleVertoAttach(attach);
|
|
8571
8643
|
} catch (error) {
|
|
8572
|
-
logger$
|
|
8644
|
+
logger$8.error("[Session] Error handling Verto attach:", error);
|
|
8573
8645
|
this._errors$.next(new require_operators.VertoAttachHandlerError(error));
|
|
8574
8646
|
}
|
|
8575
8647
|
});
|
|
@@ -8579,36 +8651,36 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8579
8651
|
const storedState = await this.storage.getItem(this.authorizationStateKey);
|
|
8580
8652
|
this.authorizationState$.next(storedState ?? void 0);
|
|
8581
8653
|
} catch (error) {
|
|
8582
|
-
logger$
|
|
8654
|
+
logger$8.error("Failed to retrieve authorization state from storage:", error);
|
|
8583
8655
|
this.authorizationState$.next(void 0);
|
|
8584
8656
|
}
|
|
8585
8657
|
}
|
|
8586
8658
|
async updateAuthorizationStateInStorage(authorizationState) {
|
|
8587
8659
|
if (!authorizationState) {
|
|
8588
|
-
logger$
|
|
8660
|
+
logger$8.debug("[Session] Removing authorization state from storage");
|
|
8589
8661
|
try {
|
|
8590
8662
|
await this.storage.removeItem(this.authorizationStateKey);
|
|
8591
8663
|
this.authorizationState$.next(void 0);
|
|
8592
8664
|
} catch (error) {
|
|
8593
|
-
logger$
|
|
8665
|
+
logger$8.error("Failed to remove authorization state from storage:", error);
|
|
8594
8666
|
throw error;
|
|
8595
8667
|
}
|
|
8596
8668
|
return;
|
|
8597
8669
|
}
|
|
8598
8670
|
try {
|
|
8599
|
-
logger$
|
|
8671
|
+
logger$8.debug("[Session] Updating authorization state in storage");
|
|
8600
8672
|
await this.storage.setItem(this.authorizationStateKey, authorizationState);
|
|
8601
8673
|
this.authorizationState$.next(authorizationState);
|
|
8602
8674
|
} catch (error) {
|
|
8603
|
-
logger$
|
|
8675
|
+
logger$8.error("Failed to retrieve authorization state from storage:", error);
|
|
8604
8676
|
throw error;
|
|
8605
8677
|
}
|
|
8606
8678
|
}
|
|
8607
8679
|
get authStateEvent$() {
|
|
8608
8680
|
return this.cachedObservable("authStateEvent$", () => this.signalingEvent$.pipe((0, rxjs.tap)((msg) => {
|
|
8609
|
-
logger$
|
|
8681
|
+
logger$8.debug("[Session] Received incoming message:", msg);
|
|
8610
8682
|
}), require_operators.filterAs(isSignalwireAuthorizationStateMetadata, "params"), (0, rxjs.tap)((event) => {
|
|
8611
|
-
logger$
|
|
8683
|
+
logger$8.debug("[Session] Authorization state event received:", event.authorization_state);
|
|
8612
8684
|
})));
|
|
8613
8685
|
}
|
|
8614
8686
|
get signalingEvent$() {
|
|
@@ -8646,15 +8718,15 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8646
8718
|
await (0, rxjs.firstValueFrom)(this.authenticated$.pipe((0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.filter)(Boolean), (0, rxjs.take)(1), (0, rxjs.timeout)({ first: 15e3 })));
|
|
8647
8719
|
}
|
|
8648
8720
|
async handleAuthenticationError(error) {
|
|
8649
|
-
logger$
|
|
8721
|
+
logger$8.error("Authentication error:", error);
|
|
8650
8722
|
const isRecoverableAuthError = error instanceof require_operators.JSONRPCError && (error.code === RPC_ERROR_REQUESTER_VALIDATION_FAILED || error.code === RPC_ERROR_INVALID_PARAMS || error.code === RPC_ERROR_AUTHENTICATION_FAILED);
|
|
8651
8723
|
const hasStoredState = await (0, rxjs.firstValueFrom)(this.authorizationState$.pipe((0, rxjs.take)(1))) !== void 0;
|
|
8652
8724
|
if (isRecoverableAuthError && hasStoredState) {
|
|
8653
|
-
logger$
|
|
8725
|
+
logger$8.debug("[Session] Recoverable auth error — cleaning up stored state and reconnecting fresh");
|
|
8654
8726
|
try {
|
|
8655
8727
|
await this.cleanupStoredConnectionParams();
|
|
8656
8728
|
} catch (cleanupError) {
|
|
8657
|
-
logger$
|
|
8729
|
+
logger$8.error("Failed to cleanup stored connection params:", cleanupError);
|
|
8658
8730
|
} finally {
|
|
8659
8731
|
this.transport.reconnect();
|
|
8660
8732
|
}
|
|
@@ -8669,19 +8741,19 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8669
8741
|
try {
|
|
8670
8742
|
await this.storage.setItem(this.authorizationStateKey, authorization_state);
|
|
8671
8743
|
} catch (error) {
|
|
8672
|
-
logger$
|
|
8744
|
+
logger$8.error("Failed to update authorization state in storage:", error);
|
|
8673
8745
|
this._errors$.next(new require_operators.AuthStateHandlerError(error));
|
|
8674
8746
|
}
|
|
8675
8747
|
}
|
|
8676
8748
|
async reauthenticate(token, dpopToken, options) {
|
|
8677
|
-
logger$
|
|
8749
|
+
logger$8.debug("[Session] Re-authenticating session");
|
|
8678
8750
|
try {
|
|
8679
8751
|
let resolvedDpopToken = dpopToken;
|
|
8680
8752
|
if (!resolvedDpopToken && this.dpopManager?.initialized) try {
|
|
8681
8753
|
resolvedDpopToken = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
8682
8754
|
} catch (error) {
|
|
8683
8755
|
if (this._clientBound) throw error;
|
|
8684
|
-
logger$
|
|
8756
|
+
logger$8.warn("[Session] Failed to create DPoP proof for reauthenticate:", error);
|
|
8685
8757
|
}
|
|
8686
8758
|
const request = RPCReauthenticate({
|
|
8687
8759
|
project: this._authorization$.value?.project_id ?? "",
|
|
@@ -8689,24 +8761,24 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8689
8761
|
...resolvedDpopToken ? { dpop_token: resolvedDpopToken } : {}
|
|
8690
8762
|
});
|
|
8691
8763
|
await (0, rxjs.lastValueFrom)((0, rxjs.from)(this.transport.execute(request)).pipe(require_operators.throwOnRPCError(), (0, rxjs.take)(1), (0, rxjs.catchError)((err) => {
|
|
8692
|
-
logger$
|
|
8764
|
+
logger$8.error("[Session] Re-authentication RPC failed:", err);
|
|
8693
8765
|
throw err;
|
|
8694
8766
|
})));
|
|
8695
8767
|
if (options?.clientBound) this._clientBound = true;
|
|
8696
|
-
logger$
|
|
8768
|
+
logger$8.debug("[Session] Re-authentication successful, updating stored auth state");
|
|
8697
8769
|
} catch (error) {
|
|
8698
|
-
logger$
|
|
8770
|
+
logger$8.error("[Session] Re-authentication failed:", error);
|
|
8699
8771
|
this._errors$.next(new require_operators.AuthStateHandlerError(error));
|
|
8700
8772
|
throw error;
|
|
8701
8773
|
}
|
|
8702
8774
|
}
|
|
8703
8775
|
async authenticate() {
|
|
8704
|
-
logger$
|
|
8776
|
+
logger$8.debug("[Session] Starting authentication process");
|
|
8705
8777
|
const persistedParams = await (0, rxjs.firstValueFrom)((0, rxjs.combineLatest)({
|
|
8706
8778
|
protocol: this.transport.protocol$,
|
|
8707
8779
|
authorization_state: this.authorizationState$
|
|
8708
8780
|
}).pipe((0, rxjs.take)(1)));
|
|
8709
|
-
logger$
|
|
8781
|
+
logger$8.debug("[Session] Persisted params:\n", {
|
|
8710
8782
|
protocol: persistedParams.protocol,
|
|
8711
8783
|
authStateLength: persistedParams.authorization_state?.length
|
|
8712
8784
|
});
|
|
@@ -8714,16 +8786,16 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8714
8786
|
const storedToken = this.getCredential().token;
|
|
8715
8787
|
const isReconnect = hasReconnectState && storedToken;
|
|
8716
8788
|
let dpopToken;
|
|
8717
|
-
if (isReconnect) logger$
|
|
8789
|
+
if (isReconnect) logger$8.debug("[Session] Reconnecting with stored jwt_token + authorization_state");
|
|
8718
8790
|
else if (this.onBeforeReconnect && this._clientBound) {
|
|
8719
|
-
logger$
|
|
8791
|
+
logger$8.debug("[Session] Refreshing credentials before fresh connect");
|
|
8720
8792
|
await this.onBeforeReconnect();
|
|
8721
8793
|
}
|
|
8722
8794
|
if ((!isReconnect || this._clientBound) && this.dpopManager?.initialized) try {
|
|
8723
8795
|
dpopToken = await this.dpopManager.createRpcProof({ method: "signalwire.connect" });
|
|
8724
8796
|
} catch (error) {
|
|
8725
8797
|
if (this._clientBound) throw error;
|
|
8726
|
-
logger$
|
|
8798
|
+
logger$8.warn("[Session] Failed to create DPoP proof for connect, proceeding without:", error);
|
|
8727
8799
|
}
|
|
8728
8800
|
const rpcConnectRequest = RPCConnect({
|
|
8729
8801
|
authentication: isReconnect ? { jwt_token: storedToken } : this.authentication,
|
|
@@ -8740,12 +8812,12 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8740
8812
|
} : {}
|
|
8741
8813
|
});
|
|
8742
8814
|
const response = await (0, rxjs.lastValueFrom)((0, rxjs.from)(this.transport.execute(rpcConnectRequest)).pipe(require_operators.throwOnRPCError(), (0, rxjs.map)((res) => res.result), (0, rxjs.filter)(isRPCConnectResult), (0, rxjs.tap)(() => {
|
|
8743
|
-
logger$
|
|
8815
|
+
logger$8.debug("[Session] Response passed filter, processing authentication result");
|
|
8744
8816
|
}), (0, rxjs.take)(1), (0, rxjs.catchError)((err) => {
|
|
8745
|
-
logger$
|
|
8817
|
+
logger$8.error("[Session] Authentication RPC failed:", err);
|
|
8746
8818
|
throw err;
|
|
8747
8819
|
})));
|
|
8748
|
-
logger$
|
|
8820
|
+
logger$8.debug("[Session] Processing authentication result:", {
|
|
8749
8821
|
hasProtocol: !!response.protocol,
|
|
8750
8822
|
hasAuthorization: !!response.authorization,
|
|
8751
8823
|
hasIceServers: !!response.ice_servers
|
|
@@ -8754,7 +8826,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8754
8826
|
this._authorization$.next(response.authorization);
|
|
8755
8827
|
this._iceServers$.next(response.ice_servers ?? []);
|
|
8756
8828
|
this._authenticated$.next(true);
|
|
8757
|
-
logger$
|
|
8829
|
+
logger$8.debug("[Session] Authentication completed successfully");
|
|
8758
8830
|
}
|
|
8759
8831
|
async disconnect() {
|
|
8760
8832
|
this.transport.disconnect();
|
|
@@ -8791,11 +8863,11 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8791
8863
|
async handleVertoAttach(attach) {
|
|
8792
8864
|
const { callID } = attach;
|
|
8793
8865
|
if (callID in this._calls$.value) {
|
|
8794
|
-
logger$
|
|
8866
|
+
logger$8.debug(`[Session] Verto attach for existing call ${callID}, deferring to per-call handler`);
|
|
8795
8867
|
return;
|
|
8796
8868
|
}
|
|
8797
8869
|
const storedOptions = this.attachManager.consumePendingAttachment(callID);
|
|
8798
|
-
logger$
|
|
8870
|
+
logger$8.debug(`[Session] Creating reattached call for callID: ${callID}`);
|
|
8799
8871
|
const callSession = await this.createCall({
|
|
8800
8872
|
nodeId: attach.node_id,
|
|
8801
8873
|
callId: callID,
|
|
@@ -8827,7 +8899,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8827
8899
|
});
|
|
8828
8900
|
return callSession;
|
|
8829
8901
|
} catch (error) {
|
|
8830
|
-
logger$
|
|
8902
|
+
logger$8.error("[Session] Error creating outbound call:", error);
|
|
8831
8903
|
callSession?.destroy();
|
|
8832
8904
|
const callError = new require_operators.CallCreateError(error instanceof rxjs.TimeoutError ? "Call create timeout" : "Call creation failed", error, "outbound");
|
|
8833
8905
|
this._errors$.next(callError);
|
|
@@ -8845,7 +8917,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8845
8917
|
address = this._directory.get(addressId);
|
|
8846
8918
|
if (!address) throw new require_operators.DependencyError(`Address ID: ${addressId} not found`);
|
|
8847
8919
|
} catch {
|
|
8848
|
-
logger$
|
|
8920
|
+
logger$8.warn(`[Session] Directory lookup failed for ${addressURI}, proceeding with raw URI`);
|
|
8849
8921
|
}
|
|
8850
8922
|
const callSession = this.callFactory.createCall(address, { ...options });
|
|
8851
8923
|
this.subscribeTo(callSession.status$.pipe((0, rxjs.filter)((status) => status === "destroyed"), (0, rxjs.take)(1)), () => {
|
|
@@ -8854,7 +8926,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
8854
8926
|
});
|
|
8855
8927
|
return callSession;
|
|
8856
8928
|
} catch (error) {
|
|
8857
|
-
logger$
|
|
8929
|
+
logger$8.error("[Session] Error creating call session:", error);
|
|
8858
8930
|
throw new require_operators.CallCreateError("Call create error", error, options.initOffer ? "inbound" : "outbound");
|
|
8859
8931
|
}
|
|
8860
8932
|
}
|
|
@@ -8902,7 +8974,7 @@ const isString = (obj) => typeof obj === "string";
|
|
|
8902
8974
|
|
|
8903
8975
|
//#endregion
|
|
8904
8976
|
//#region src/managers/ConversationsManager.ts
|
|
8905
|
-
const logger$
|
|
8977
|
+
const logger$7 = require_operators.getLogger();
|
|
8906
8978
|
var ConversationMessagesFetcher = class extends Fetcher {
|
|
8907
8979
|
constructor(groupId, http) {
|
|
8908
8980
|
super(`/api/fabric/conversations/${groupId}/messages`, "page_size=100", http);
|
|
@@ -8942,13 +9014,13 @@ var ConversationsManager = class {
|
|
|
8942
9014
|
}
|
|
8943
9015
|
throw new require_operators.ConversationError("Join Failed - Unexpected response");
|
|
8944
9016
|
} catch (error) {
|
|
8945
|
-
logger$
|
|
9017
|
+
logger$7.error("[ConversationsManager] Failed to join conversation:", error);
|
|
8946
9018
|
throw error;
|
|
8947
9019
|
}
|
|
8948
9020
|
}
|
|
8949
9021
|
async getConversationMessageCollection(addressId) {
|
|
8950
9022
|
const groupId = this.groupIds.get(addressId) ?? await this.join(addressId);
|
|
8951
|
-
return Promise.resolve(new ConversationMessageCollection(groupId, this.clientSession.signalingEvent$.pipe(require_operators.filterAs(isConversationMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$
|
|
9023
|
+
return Promise.resolve(new ConversationMessageCollection(groupId, this.clientSession.signalingEvent$.pipe(require_operators.filterAs(isConversationMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$7.debug("[ConversationsManager ] Conversation Event:", event)), (0, rxjs.map)((params) => ({ ...params }))), this.http, this.onError));
|
|
8952
9024
|
}
|
|
8953
9025
|
async sendText(text, destinationAddressId) {
|
|
8954
9026
|
const groupId = this.groupIds.get(destinationAddressId) ?? await this.join(destinationAddressId);
|
|
@@ -8965,12 +9037,221 @@ var ConversationsManager = class {
|
|
|
8965
9037
|
})).ok) return;
|
|
8966
9038
|
throw new require_operators.ConversationError("Send Text Failed - Unexpected response");
|
|
8967
9039
|
} catch (error) {
|
|
8968
|
-
logger$
|
|
9040
|
+
logger$7.error("[ConversationsManager] Failed to send text message:", error);
|
|
8969
9041
|
throw error;
|
|
8970
9042
|
}
|
|
8971
9043
|
}
|
|
8972
9044
|
};
|
|
8973
9045
|
|
|
9046
|
+
//#endregion
|
|
9047
|
+
//#region src/managers/DeviceTokenManager.ts
|
|
9048
|
+
const logger$6 = require_operators.getLogger();
|
|
9049
|
+
/**
|
|
9050
|
+
* Resolves the token expiry timestamp (epoch seconds) using a 3-tier priority chain:
|
|
9051
|
+
* 1. `data.expires_at` — server-provided absolute timestamp
|
|
9052
|
+
* 2. `data.expires_in` — server-provided relative lifetime
|
|
9053
|
+
* 3. Fallback to `DEVICE_TOKEN_DEFAULT_EXPIRE_IN` with a warning
|
|
9054
|
+
*/
|
|
9055
|
+
function resolveExpiresAt(data) {
|
|
9056
|
+
if (data.expires_at) return data.expires_at;
|
|
9057
|
+
if (data.expires_in) return Math.floor(Date.now() / 1e3) + data.expires_in;
|
|
9058
|
+
logger$6.warn("[DeviceToken] Could not determine token expiry, using default");
|
|
9059
|
+
return Math.floor(Date.now() / 1e3) + DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9060
|
+
}
|
|
9061
|
+
/**
|
|
9062
|
+
* Resolves the token TTL in seconds from a fresh response.
|
|
9063
|
+
* Called at token receive time so `expires_at - now` reflects the original lifetime.
|
|
9064
|
+
*
|
|
9065
|
+
* 1. `data.expires_in` — server-provided TTL directly
|
|
9066
|
+
* 2. `data.expires_at - now` — derive TTL from absolute timestamp
|
|
9067
|
+
* 3. Fallback to `DEVICE_TOKEN_DEFAULT_EXPIRE_IN`
|
|
9068
|
+
*/
|
|
9069
|
+
function resolveExpireIn(data) {
|
|
9070
|
+
if (data.expires_in) return data.expires_in;
|
|
9071
|
+
if (data.expires_at) return Math.max(data.expires_at - Math.floor(Date.now() / 1e3), 1);
|
|
9072
|
+
return DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9073
|
+
}
|
|
9074
|
+
/**
|
|
9075
|
+
* Manages the Client Bound SAT lifecycle: activation, token exchange,
|
|
9076
|
+
* reauthentication, and automatic refresh scheduling.
|
|
9077
|
+
*
|
|
9078
|
+
* Extends {@link Destroyable} for automatic RxJS subscription and subject cleanup.
|
|
9079
|
+
* Uses a reactive pipeline (`BehaviorSubject` + `switchMap(timer())`) instead of
|
|
9080
|
+
* raw `setTimeout` for refresh scheduling.
|
|
9081
|
+
*/
|
|
9082
|
+
var DeviceTokenManager = class extends Destroyable {
|
|
9083
|
+
constructor(dpopManager, http, errorHandler, getCredential) {
|
|
9084
|
+
super();
|
|
9085
|
+
this.dpopManager = dpopManager;
|
|
9086
|
+
this.http = http;
|
|
9087
|
+
this.errorHandler = errorHandler;
|
|
9088
|
+
this.getCredential = getCredential;
|
|
9089
|
+
this._currentToken$ = this.createBehaviorSubject(null);
|
|
9090
|
+
this._refreshInProgress = false;
|
|
9091
|
+
this._effectiveExpireIn = DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9092
|
+
this.subscribeTo(this._currentToken$.pipe((0, rxjs.filter)(Boolean), (0, rxjs.switchMap)((tokenData) => {
|
|
9093
|
+
const expiresAt = resolveExpiresAt(tokenData);
|
|
9094
|
+
const refreshIn = Math.max(expiresAt * 1e3 - Date.now() - DEVICE_TOKEN_REFRESH_BUFFER_MS, 1e3);
|
|
9095
|
+
logger$6.debug(`[DeviceToken] Scheduling Client Bound SAT refresh in ${refreshIn}ms`);
|
|
9096
|
+
return (0, rxjs.timer)(refreshIn);
|
|
9097
|
+
})), () => {
|
|
9098
|
+
this.executeRefresh();
|
|
9099
|
+
});
|
|
9100
|
+
}
|
|
9101
|
+
/** Current token TTL in milliseconds. Used to extend cached credential expiry on refresh. */
|
|
9102
|
+
get effectiveExpireIn() {
|
|
9103
|
+
return this._effectiveExpireIn;
|
|
9104
|
+
}
|
|
9105
|
+
/**
|
|
9106
|
+
* Activates the Client Bound SAT flow when the subscriber's token has
|
|
9107
|
+
* `sat:refresh` scope.
|
|
9108
|
+
*
|
|
9109
|
+
* Steps:
|
|
9110
|
+
* 1. Check subscriber's `sat_claims` for `sat:refresh` scope
|
|
9111
|
+
* 2. Call `/api/fabric/subscriber/devices/token` with a DPoP proof
|
|
9112
|
+
* 3. Reauthenticate the session with the Client Bound SAT + DPoP proof
|
|
9113
|
+
* 4. Emit token to trigger the reactive refresh pipeline
|
|
9114
|
+
*/
|
|
9115
|
+
async activate(subscriber, session, updateCredential) {
|
|
9116
|
+
const { satClaims } = subscriber;
|
|
9117
|
+
if (!satClaims?.scope?.includes(SAT_REFRESH_SCOPE)) {
|
|
9118
|
+
logger$6.debug("[DeviceToken] No sat:refresh scope, skipping Client Bound SAT activation");
|
|
9119
|
+
return;
|
|
9120
|
+
}
|
|
9121
|
+
this._session = session;
|
|
9122
|
+
this._updateCredential = updateCredential;
|
|
9123
|
+
try {
|
|
9124
|
+
const tokenData = await this.obtainToken();
|
|
9125
|
+
if (!tokenData.expires_at && !tokenData.expires_in && satClaims.expires_at) tokenData.expires_at = satClaims.expires_at;
|
|
9126
|
+
this._effectiveExpireIn = resolveExpireIn(tokenData);
|
|
9127
|
+
const rpcProof = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
9128
|
+
await session.reauthenticate(tokenData.token, rpcProof, { clientBound: true });
|
|
9129
|
+
updateCredential({ token: tokenData.token });
|
|
9130
|
+
logger$6.info("[DeviceToken] Client Bound SAT activated successfully");
|
|
9131
|
+
this._currentToken$.next(tokenData);
|
|
9132
|
+
} catch (error) {
|
|
9133
|
+
logger$6.error("[DeviceToken] Failed to activate Client Bound SAT:", error);
|
|
9134
|
+
this.errorHandler(new require_operators.DPoPInitError(error, "Failed to activate Client Bound SAT"));
|
|
9135
|
+
const credential = this.getCredential();
|
|
9136
|
+
const expiresAt = satClaims.expires_at ?? (credential.expiry_at ? credential.expiry_at / 1e3 : Date.now() / 1e3 + DEVICE_TOKEN_DEFAULT_EXPIRE_IN / 1e3);
|
|
9137
|
+
this._currentToken$.next({
|
|
9138
|
+
token: credential.token ?? "",
|
|
9139
|
+
expires_at: expiresAt
|
|
9140
|
+
});
|
|
9141
|
+
}
|
|
9142
|
+
}
|
|
9143
|
+
/**
|
|
9144
|
+
* Obtains a Client Bound SAT from `/api/fabric/subscriber/devices/token`.
|
|
9145
|
+
* Returns the full {@link DeviceTokenResponse} including expiry metadata.
|
|
9146
|
+
*/
|
|
9147
|
+
async obtainToken() {
|
|
9148
|
+
const dpopProof = await this.dpopManager.createHttpProof({
|
|
9149
|
+
method: "POST",
|
|
9150
|
+
uri: DEVICE_TOKEN_ENDPOINT
|
|
9151
|
+
});
|
|
9152
|
+
const response = await this.http.request({
|
|
9153
|
+
url: DEVICE_TOKEN_ENDPOINT,
|
|
9154
|
+
...POST_PARAMS,
|
|
9155
|
+
body: JSON.stringify({
|
|
9156
|
+
dpop_token: dpopProof,
|
|
9157
|
+
expire_in: DEVICE_TOKEN_DEFAULT_EXPIRE_IN
|
|
9158
|
+
})
|
|
9159
|
+
});
|
|
9160
|
+
if (!response.ok || !response.body) throw new require_operators.DeviceTokenError(`Failed to obtain device token: ${response.status} ${response.statusText}`);
|
|
9161
|
+
const data = JSON.parse(response.body);
|
|
9162
|
+
if (!data.token) throw new require_operators.DeviceTokenError("Device token response missing token field");
|
|
9163
|
+
return data;
|
|
9164
|
+
}
|
|
9165
|
+
/**
|
|
9166
|
+
* Refreshes the Client Bound SAT via `/api/fabric/subscriber/devices/refresh`.
|
|
9167
|
+
*
|
|
9168
|
+
* Creates a fresh DPoP proof, calls the refresh endpoint, reauthenticates
|
|
9169
|
+
* the WebSocket session, and returns the new token data (scheduling is
|
|
9170
|
+
* handled by the reactive pipeline).
|
|
9171
|
+
*/
|
|
9172
|
+
async refreshToken(session, currentToken, updateCredential) {
|
|
9173
|
+
logger$6.debug("[DeviceToken] Refreshing Client Bound SAT");
|
|
9174
|
+
const dpopProof = await this.dpopManager.createHttpProof({
|
|
9175
|
+
method: "POST",
|
|
9176
|
+
uri: DEVICE_REFRESH_ENDPOINT,
|
|
9177
|
+
accessToken: currentToken
|
|
9178
|
+
});
|
|
9179
|
+
const response = await this.http.request({
|
|
9180
|
+
url: DEVICE_REFRESH_ENDPOINT,
|
|
9181
|
+
...POST_PARAMS,
|
|
9182
|
+
body: JSON.stringify({
|
|
9183
|
+
dpop_token: dpopProof,
|
|
9184
|
+
expire_in: this._effectiveExpireIn
|
|
9185
|
+
})
|
|
9186
|
+
});
|
|
9187
|
+
if (!response.ok || !response.body) throw new require_operators.TokenRefreshError(`Failed to refresh device token: ${response.status} ${response.statusText}`);
|
|
9188
|
+
const data = JSON.parse(response.body);
|
|
9189
|
+
if (!data.token) throw new require_operators.TokenRefreshError("Device token refresh response missing token field");
|
|
9190
|
+
if (!data.expires_at && !data.expires_in) data.expires_in = this._effectiveExpireIn;
|
|
9191
|
+
this._effectiveExpireIn = resolveExpireIn(data);
|
|
9192
|
+
const rpcProof = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
9193
|
+
await session.reauthenticate(data.token, rpcProof);
|
|
9194
|
+
updateCredential({ token: data.token });
|
|
9195
|
+
logger$6.info("[DeviceToken] Client Bound SAT refreshed successfully");
|
|
9196
|
+
return data;
|
|
9197
|
+
}
|
|
9198
|
+
/**
|
|
9199
|
+
* Executes a refresh with retry and exponential backoff.
|
|
9200
|
+
* On success, emits to `_currentToken$` to schedule the next refresh.
|
|
9201
|
+
* On all retries exhausted, emits to `errorHandler`.
|
|
9202
|
+
*/
|
|
9203
|
+
async executeRefresh() {
|
|
9204
|
+
if (this._refreshInProgress) {
|
|
9205
|
+
logger$6.debug("[DeviceToken] Refresh already in progress, skipping");
|
|
9206
|
+
return;
|
|
9207
|
+
}
|
|
9208
|
+
const session = this._session;
|
|
9209
|
+
const updateCredential = this._updateCredential;
|
|
9210
|
+
if (!session || !updateCredential) {
|
|
9211
|
+
logger$6.warn("[DeviceToken] Cannot refresh: session or updateCredential not set");
|
|
9212
|
+
return;
|
|
9213
|
+
}
|
|
9214
|
+
if (!session.authenticated) {
|
|
9215
|
+
logger$6.debug("[DeviceToken] Session not authenticated, deferring refresh");
|
|
9216
|
+
return;
|
|
9217
|
+
}
|
|
9218
|
+
this._refreshInProgress = true;
|
|
9219
|
+
try {
|
|
9220
|
+
const currentToken = this.getCredential().token;
|
|
9221
|
+
if (!currentToken) throw new require_operators.TokenRefreshError("No current token available for refresh");
|
|
9222
|
+
const newTokenData = await this.retryRefresh(session, currentToken, updateCredential);
|
|
9223
|
+
this._currentToken$.next(newTokenData);
|
|
9224
|
+
} catch (error) {
|
|
9225
|
+
logger$6.error("[DeviceToken] Automatic Client Bound SAT refresh failed:", error);
|
|
9226
|
+
this.errorHandler(error instanceof require_operators.TokenRefreshError ? error : new require_operators.TokenRefreshError("Automatic token refresh failed", error));
|
|
9227
|
+
} finally {
|
|
9228
|
+
this._refreshInProgress = false;
|
|
9229
|
+
}
|
|
9230
|
+
}
|
|
9231
|
+
/**
|
|
9232
|
+
* Retries `refreshToken()` up to `DEVICE_TOKEN_REFRESH_MAX_RETRIES` times
|
|
9233
|
+
* with exponential backoff (1s, 2s, 4s).
|
|
9234
|
+
*/
|
|
9235
|
+
async retryRefresh(session, currentToken, updateCredential) {
|
|
9236
|
+
let lastError;
|
|
9237
|
+
for (let attempt = 0; attempt < DEVICE_TOKEN_REFRESH_MAX_RETRIES; attempt++) try {
|
|
9238
|
+
return await this.refreshToken(session, currentToken, updateCredential);
|
|
9239
|
+
} catch (error) {
|
|
9240
|
+
lastError = error;
|
|
9241
|
+
if (attempt < DEVICE_TOKEN_REFRESH_MAX_RETRIES - 1) {
|
|
9242
|
+
const delay = DEVICE_TOKEN_REFRESH_RETRY_BASE_MS * Math.pow(2, attempt);
|
|
9243
|
+
logger$6.warn(`[DeviceToken] Refresh attempt ${attempt + 1} failed, retrying in ${delay}ms`);
|
|
9244
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
9245
|
+
}
|
|
9246
|
+
}
|
|
9247
|
+
throw lastError instanceof Error ? lastError : new require_operators.TokenRefreshError("All refresh retries exhausted", lastError);
|
|
9248
|
+
}
|
|
9249
|
+
/** Cleans up the manager, cancelling the reactive pipeline and all subscriptions. */
|
|
9250
|
+
destroy() {
|
|
9251
|
+
super.destroy();
|
|
9252
|
+
}
|
|
9253
|
+
};
|
|
9254
|
+
|
|
8974
9255
|
//#endregion
|
|
8975
9256
|
//#region src/managers/DiagnosticsCollector.ts
|
|
8976
9257
|
const logger$5 = require_operators.getLogger();
|
|
@@ -9900,13 +10181,43 @@ var SignalWire = class extends Destroyable {
|
|
|
9900
10181
|
this._errors$.next(error);
|
|
9901
10182
|
});
|
|
9902
10183
|
await this._clientSession.connect();
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
10184
|
+
if (this._dpopManager?.initialized) {
|
|
10185
|
+
if (this._refreshTimerId) {
|
|
10186
|
+
clearTimeout(this._refreshTimerId);
|
|
10187
|
+
this._refreshTimerId = void 0;
|
|
10188
|
+
logger$1.debug("[SignalWire] Developer refresh disabled — Client Bound SAT activation starting");
|
|
10189
|
+
}
|
|
10190
|
+
this._deviceTokenManager = new DeviceTokenManager(this._dpopManager, this._deps.http, (error) => this._errors$.next(error), () => this._deps.credential);
|
|
10191
|
+
await this._deviceTokenManager.activate(this._deps.subscriber, this._clientSession, (cred) => {
|
|
10192
|
+
this._deps.credential = {
|
|
10193
|
+
...this._deps.credential,
|
|
10194
|
+
...cred
|
|
10195
|
+
};
|
|
10196
|
+
});
|
|
10197
|
+
}
|
|
10198
|
+
this.subscribeTo(this._clientSession.authenticated$.pipe((0, rxjs.skip)(1), (0, rxjs.filter)(Boolean)), async () => {
|
|
10199
|
+
try {
|
|
10200
|
+
if (this._deviceTokenManager) {
|
|
10201
|
+
await this._deviceTokenManager.activate(this._deps.subscriber, this._clientSession, (cred) => {
|
|
10202
|
+
this._deps.credential = {
|
|
10203
|
+
...this._deps.credential,
|
|
10204
|
+
...cred
|
|
10205
|
+
};
|
|
10206
|
+
});
|
|
10207
|
+
logger$1.debug("[SignalWire] Client Bound SAT re-activated after reconnect");
|
|
10208
|
+
}
|
|
10209
|
+
} catch (error) {
|
|
10210
|
+
logger$1.error("[SignalWire] Client Bound SAT re-activation failed (non-fatal):", error);
|
|
10211
|
+
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
10212
|
+
}
|
|
10213
|
+
try {
|
|
10214
|
+
logger$1.debug("[SignalWire] Re-registering subscriber after reconnect");
|
|
10215
|
+
await this.register();
|
|
9906
10216
|
logger$1.debug("[SignalWire] Subscriber re-registered successfully after reconnect");
|
|
9907
|
-
}
|
|
10217
|
+
} catch (error) {
|
|
9908
10218
|
logger$1.error("[SignalWire] Re-registration failed after reconnect:", error);
|
|
9909
|
-
|
|
10219
|
+
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
10220
|
+
}
|
|
9910
10221
|
});
|
|
9911
10222
|
const conversationManager = new ConversationsManager(this._clientSession, this._deps.http, () => this._deps.getSubscriberFromAddressId(), errorHandler);
|
|
9912
10223
|
const directory = new DirectoryManager(this._deps.http, this._clientSession, conversationManager, errorHandler);
|
|
@@ -10329,6 +10640,8 @@ var SignalWire = class extends Destroyable {
|
|
|
10329
10640
|
* Triggers the browser's media permission dialog and captures the user's device selections.
|
|
10330
10641
|
*
|
|
10331
10642
|
* @param options - Which permissions to request.
|
|
10643
|
+
* @param options.audio - Whether to request audio permission.
|
|
10644
|
+
* @param options.video - Whether to request video permission.
|
|
10332
10645
|
* @returns The permission result with selected devices.
|
|
10333
10646
|
*/
|
|
10334
10647
|
async requestMediaPermissions(options = {
|
|
@@ -10360,8 +10673,14 @@ var SignalWire = class extends Destroyable {
|
|
|
10360
10673
|
logger$1.warn("[SignalWire] Media permission request failed:", error);
|
|
10361
10674
|
}
|
|
10362
10675
|
await this._deviceController.enumerateDevices();
|
|
10363
|
-
if (audioGranted && selectedAudioDevice)
|
|
10364
|
-
|
|
10676
|
+
if (audioGranted && selectedAudioDevice) {
|
|
10677
|
+
const audioDeviceId = selectedAudioDevice.deviceId;
|
|
10678
|
+
selectedAudioDevice = this.audioInputDevices.find((d) => d.deviceId === audioDeviceId) ?? selectedAudioDevice;
|
|
10679
|
+
}
|
|
10680
|
+
if (videoGranted && selectedVideoDevice) {
|
|
10681
|
+
const videoDeviceId = selectedVideoDevice.deviceId;
|
|
10682
|
+
selectedVideoDevice = this.videoInputDevices.find((d) => d.deviceId === videoDeviceId) ?? selectedVideoDevice;
|
|
10683
|
+
}
|
|
10365
10684
|
if (audioGranted && selectedAudioDevice && !this.selectedAudioInputDevice) this.selectAudioInputDevice(selectedAudioDevice);
|
|
10366
10685
|
if (videoGranted && selectedVideoDevice && !this.selectedVideoInputDevice) this.selectVideoInputDevice(selectedVideoDevice);
|
|
10367
10686
|
return {
|