@signalwire/js 4.0.0-dev-20260511184148 → 4.0.0-dev-20260714201720
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 +1072 -607
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +1072 -606
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +970 -668
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +266 -34
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +266 -34
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +900 -599
- package/dist/index.mjs.map +1 -1
- package/dist/operators/index.cjs +1 -1
- package/dist/operators/index.mjs +1 -1
- package/dist/{operators-D6a2J1KA.cjs → operators-B8ipd4Xl.cjs} +561 -1
- package/dist/operators-B8ipd4Xl.cjs.map +1 -0
- package/dist/{operators-CX_lCCJm.mjs → operators-BlUtq-t0.mjs} +166 -2
- package/dist/operators-BlUtq-t0.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/operators-CX_lCCJm.mjs.map +0 -1
- package/dist/operators-D6a2J1KA.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_operators = require('./operators-
|
|
1
|
+
const require_operators = require('./operators-B8ipd4Xl.cjs');
|
|
2
2
|
let jwt_decode = require("jwt-decode");
|
|
3
3
|
let rxjs = require("rxjs");
|
|
4
4
|
let uuid = require("uuid");
|
|
@@ -131,7 +131,7 @@ const asyncRetry = async ({ asyncCallable, maxRetries: retries = DEFAULT_MAX_RET
|
|
|
131
131
|
|
|
132
132
|
//#endregion
|
|
133
133
|
//#region src/controllers/HTTPRequestController.ts
|
|
134
|
-
const logger$
|
|
134
|
+
const logger$31 = require_operators.getLogger();
|
|
135
135
|
const GET_PARAMS = {
|
|
136
136
|
method: "GET",
|
|
137
137
|
headers: { Accept: "application/json" }
|
|
@@ -195,7 +195,7 @@ var HTTPRequestController = class HTTPRequestController extends Destroyable {
|
|
|
195
195
|
this._responses$.next(response);
|
|
196
196
|
return response;
|
|
197
197
|
} catch (error) {
|
|
198
|
-
logger$
|
|
198
|
+
logger$31.error("[HTTPRequestController] Request error:", error);
|
|
199
199
|
this._status$.next("error");
|
|
200
200
|
const err = error instanceof Error ? error : new Error("HTTP request failed", { cause: error });
|
|
201
201
|
this._errors$.next(err);
|
|
@@ -222,7 +222,7 @@ var HTTPRequestController = class HTTPRequestController extends Destroyable {
|
|
|
222
222
|
const url = this.buildURL(request.url);
|
|
223
223
|
const headers = this.buildHeaders(request.headers);
|
|
224
224
|
const timeout$4 = request.timeout ?? this.requestTimeout;
|
|
225
|
-
logger$
|
|
225
|
+
logger$31.debug("[HTTPRequestController] Executing request:", {
|
|
226
226
|
method: request.method,
|
|
227
227
|
url,
|
|
228
228
|
headers: Object.keys(headers).reduce((acc, key) => {
|
|
@@ -242,7 +242,7 @@ var HTTPRequestController = class HTTPRequestController extends Destroyable {
|
|
|
242
242
|
});
|
|
243
243
|
clearTimeout(timeoutId);
|
|
244
244
|
const httpResponse = await this.convertResponse(response);
|
|
245
|
-
logger$
|
|
245
|
+
logger$31.debug("[HTTPRequestController] Response received:", {
|
|
246
246
|
status: response.status,
|
|
247
247
|
statusText: response.statusText,
|
|
248
248
|
headers: [...response.headers.entries()],
|
|
@@ -252,7 +252,7 @@ var HTTPRequestController = class HTTPRequestController extends Destroyable {
|
|
|
252
252
|
} catch (error) {
|
|
253
253
|
clearTimeout(timeoutId);
|
|
254
254
|
if (error instanceof Error && error.name === "AbortError") throw new require_operators.RequestTimeoutError(`Request timeout after ${timeout$4}ms`, { cause: error });
|
|
255
|
-
logger$
|
|
255
|
+
logger$31.error("[HTTPRequestController] Request failed:", error);
|
|
256
256
|
throw error;
|
|
257
257
|
}
|
|
258
258
|
}
|
|
@@ -266,8 +266,8 @@ var HTTPRequestController = class HTTPRequestController extends Destroyable {
|
|
|
266
266
|
const credential = this.getCredential();
|
|
267
267
|
if (credential.token) {
|
|
268
268
|
headers.Authorization = `Bearer ${credential.token}`;
|
|
269
|
-
logger$
|
|
270
|
-
} else logger$
|
|
269
|
+
logger$31.debug("[HTTPRequestController] Using Bearer token auth, token length:", credential.token.length);
|
|
270
|
+
} else logger$31.warn("[HTTPRequestController] No credentials available for authentication");
|
|
271
271
|
return headers;
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
@@ -404,130 +404,6 @@ var DeviceHistoryManager = class {
|
|
|
404
404
|
}
|
|
405
405
|
};
|
|
406
406
|
|
|
407
|
-
//#endregion
|
|
408
|
-
//#region src/core/constants.ts
|
|
409
|
-
const INVITE_VERSION = 1e3;
|
|
410
|
-
const DEFAULT_ICE_CANDIDATE_TIMEOUT_MS = 600;
|
|
411
|
-
const DEFAULT_ICE_GATHERING_TIMEOUT_MS = 6e3;
|
|
412
|
-
const DEFAULT_RECONNECT_CALLS_TIMEOUT_MS = 300 * 1e3;
|
|
413
|
-
const DEFAULT_CONNECTION_TIMEOUT_MS = 1e4;
|
|
414
|
-
const DEFAULT_RECONNECT_DELAY_MIN_MS = 100;
|
|
415
|
-
const DEFAULT_RECONNECT_DELAY_MAX_MS = 3e3;
|
|
416
|
-
const DEFAULT_DEVICE_DEBOUNCE_TIME_MS = 1500;
|
|
417
|
-
const DEFAULT_DEVICE_POLLING_INTERVAL_MS = 0;
|
|
418
|
-
const PREFERENCES_STORAGE_KEY = "sw:preferences";
|
|
419
|
-
/** Scope value that enables automatic token refresh. */
|
|
420
|
-
const SAT_REFRESH_SCOPE = "sat:refresh";
|
|
421
|
-
/** API endpoints for device token operations. */
|
|
422
|
-
const DEVICE_TOKEN_ENDPOINT = "/api/fabric/subscriber/devices/token";
|
|
423
|
-
const DEVICE_REFRESH_ENDPOINT = "/api/fabric/subscriber/devices/refresh";
|
|
424
|
-
/** Default device token TTL in seconds (15 minutes). */
|
|
425
|
-
const DEVICE_TOKEN_DEFAULT_EXPIRE_IN = 900;
|
|
426
|
-
/** Buffer time in milliseconds before expiry to trigger refresh. */
|
|
427
|
-
const DEVICE_TOKEN_REFRESH_BUFFER_MS = 3e4;
|
|
428
|
-
/** Maximum retry attempts for device token refresh on transient failure. */
|
|
429
|
-
const DEVICE_TOKEN_REFRESH_MAX_RETRIES = 3;
|
|
430
|
-
/** Base delay in milliseconds for exponential backoff on refresh retry. */
|
|
431
|
-
const DEVICE_TOKEN_REFRESH_RETRY_BASE_MS = 1e3;
|
|
432
|
-
/** Maximum retry attempts for developer credential refresh on transient failure. */
|
|
433
|
-
const CREDENTIAL_REFRESH_MAX_RETRIES = 5;
|
|
434
|
-
/** Base delay in milliseconds for exponential backoff on credential refresh retry. */
|
|
435
|
-
const CREDENTIAL_REFRESH_RETRY_BASE_MS = 1e3;
|
|
436
|
-
/** Maximum delay in milliseconds for credential refresh backoff. */
|
|
437
|
-
const CREDENTIAL_REFRESH_MAX_DELAY_MS = 3e4;
|
|
438
|
-
/** Buffer in milliseconds before token expiry to trigger refresh. */
|
|
439
|
-
const CREDENTIAL_REFRESH_BUFFER_MS = 5e3;
|
|
440
|
-
/** JSON-RPC error code for requester validation failure (corrupted auth state). */
|
|
441
|
-
const RPC_ERROR_REQUESTER_VALIDATION_FAILED = -32003;
|
|
442
|
-
/** JSON-RPC error code for invalid params (e.g., missing authentication block). */
|
|
443
|
-
const RPC_ERROR_INVALID_PARAMS = -32602;
|
|
444
|
-
/** JSON-RPC error code for authentication failure (invalid token, missing DPoP, etc.). */
|
|
445
|
-
const RPC_ERROR_AUTHENTICATION_FAILED = -32002;
|
|
446
|
-
/** Default polling interval for RTCPeerConnection.getStats() in milliseconds. */
|
|
447
|
-
const DEFAULT_STATS_POLLING_INTERVAL_MS = 1e3;
|
|
448
|
-
/** Number of initial samples used to build a baseline for spike detection. */
|
|
449
|
-
const DEFAULT_STATS_BASELINE_SAMPLES = 10;
|
|
450
|
-
/** Duration in ms with no inbound audio packets before emitting a critical issue. */
|
|
451
|
-
const DEFAULT_STATS_NO_PACKET_THRESHOLD_MS = 2e3;
|
|
452
|
-
/** Multiplier applied to baseline RTT to detect a warning-level RTT spike. */
|
|
453
|
-
const DEFAULT_STATS_RTT_SPIKE_MULTIPLIER = 3;
|
|
454
|
-
/** Packet loss fraction (0-1) above which a warning is emitted. */
|
|
455
|
-
const DEFAULT_STATS_PACKET_LOSS_THRESHOLD = .05;
|
|
456
|
-
/** Multiplier applied to baseline jitter to detect a jitter spike. */
|
|
457
|
-
const DEFAULT_STATS_JITTER_SPIKE_MULTIPLIER = 4;
|
|
458
|
-
/** Number of seconds of metrics history to retain. */
|
|
459
|
-
const DEFAULT_STATS_HISTORY_SIZE = 30;
|
|
460
|
-
/** Maximum keyframe requests allowed within a single burst window. */
|
|
461
|
-
const DEFAULT_KEYFRAME_MAX_BURST$1 = 3;
|
|
462
|
-
/** Duration of the keyframe burst window in milliseconds. */
|
|
463
|
-
const DEFAULT_KEYFRAME_BURST_WINDOW_MS$1 = 3e3;
|
|
464
|
-
/** Cooldown period in ms after burst limit is reached before allowing more keyframes. */
|
|
465
|
-
const DEFAULT_KEYFRAME_COOLDOWN_MS$1 = 1e4;
|
|
466
|
-
/** Minimum time between re-INVITE attempts in milliseconds. */
|
|
467
|
-
const DEFAULT_REINVITE_DEBOUNCE_TIME_MS = 1e4;
|
|
468
|
-
/** Maximum number of re-INVITE attempts per call. */
|
|
469
|
-
const DEFAULT_REINVITE_MAX_ATTEMPTS = 3;
|
|
470
|
-
/** Timeout for a single re-INVITE attempt in milliseconds. */
|
|
471
|
-
const DEFAULT_REINVITE_TIMEOUT_MS = 5e3;
|
|
472
|
-
/** Debounce window in ms to collapse multiple detection signals into one trigger. */
|
|
473
|
-
const DEFAULT_RECOVERY_DEBOUNCE_TIME_MS = 2e3;
|
|
474
|
-
/** Cooldown period in ms between recovery attempts. */
|
|
475
|
-
const DEFAULT_RECOVERY_COOLDOWN_MS = 1e4;
|
|
476
|
-
/** Grace period in ms before treating ICE 'disconnected' as a failure. */
|
|
477
|
-
const DEFAULT_ICE_DISCONNECTED_GRACE_PERIOD_MS = 3e3;
|
|
478
|
-
/** Timeout for a single ICE restart attempt in milliseconds. */
|
|
479
|
-
const DEFAULT_ICE_RESTART_TIMEOUT_MS$1 = 5e3;
|
|
480
|
-
/** Maximum recovery attempts before emitting 'max_attempts_reached'. */
|
|
481
|
-
const DEFAULT_MAX_RECOVERY_ATTEMPTS = 3;
|
|
482
|
-
/** Upper bound in ms for waiting on iceGatheringState === 'complete' after an ICE restart. */
|
|
483
|
-
const ICE_GATHERING_COMPLETE_TIMEOUT_MS = 1e4;
|
|
484
|
-
/** Upper bound in ms for waiting on RTCPeerConnection.connectionState === 'connected' after a recovery ICE restart. */
|
|
485
|
-
const PEER_CONNECTION_RECOVERY_WAIT_MS = 5e3;
|
|
486
|
-
/** Polling interval in ms while waiting for RTCPeerConnection.connectionState to transition. */
|
|
487
|
-
const PEER_CONNECTION_RECOVERY_POLL_MS = 100;
|
|
488
|
-
/** Polling interval for LocalAudioPipeline.level$ (ms). ~30fps is smooth for meters. */
|
|
489
|
-
const AUDIO_LEVEL_POLL_INTERVAL_MS = 33;
|
|
490
|
-
/** RMS level threshold (0..1) above which the local participant is considered speaking. */
|
|
491
|
-
const VAD_THRESHOLD = .03;
|
|
492
|
-
/** Hold window in ms below the threshold before speaking$ flips back to false. */
|
|
493
|
-
const VAD_HOLD_MS = 250;
|
|
494
|
-
/** Whether to persist device selections to storage by default. */
|
|
495
|
-
const DEFAULT_PERSIST_DEVICE_SELECTION = true;
|
|
496
|
-
/** Whether to auto-apply device changes to active calls by default. */
|
|
497
|
-
const DEFAULT_SYNC_DEVICES_TO_ACTIVE_CALLS = true;
|
|
498
|
-
/** Storage keys for persisted device selections. */
|
|
499
|
-
const DEVICE_STORAGE_KEY_AUDIO_INPUT = "sw:device:audioinput";
|
|
500
|
-
const DEVICE_STORAGE_KEY_AUDIO_OUTPUT = "sw:device:audiooutput";
|
|
501
|
-
const DEVICE_STORAGE_KEY_VIDEO_INPUT = "sw:device:videoinput";
|
|
502
|
-
/** Whether to auto-mute video when the tab becomes hidden. */
|
|
503
|
-
const DEFAULT_AUTO_MUTE_VIDEO_ON_HIDDEN = false;
|
|
504
|
-
/** Whether to re-enumerate devices when the page becomes visible. */
|
|
505
|
-
const DEFAULT_REFRESH_DEVICES_ON_VISIBLE = true;
|
|
506
|
-
/** Whether to check peer connection health when the page becomes visible. */
|
|
507
|
-
const DEFAULT_CHECK_CONNECTION_ON_VISIBLE = true;
|
|
508
|
-
/** Whether automatic video degradation on low bandwidth is enabled. */
|
|
509
|
-
const DEFAULT_ENABLE_AUTO_DEGRADATION = true;
|
|
510
|
-
/** Bitrate in kbps below which video is automatically disabled. */
|
|
511
|
-
const DEFAULT_DEGRADATION_BITRATE_THRESHOLD_KBPS = 150;
|
|
512
|
-
/** Bitrate in kbps above which video is automatically re-enabled (hysteresis). */
|
|
513
|
-
const DEFAULT_DEGRADATION_RECOVERY_THRESHOLD_KBPS = 300;
|
|
514
|
-
/** Whether relay-only escalation is enabled as a last-resort recovery tier. */
|
|
515
|
-
const DEFAULT_ENABLE_RELAY_FALLBACK = true;
|
|
516
|
-
/** Whether to listen for browser online/offline/connection events. */
|
|
517
|
-
const DEFAULT_ENABLE_NETWORK_CHANGE_DETECTION = true;
|
|
518
|
-
/** Whether to intercept server-sent media-timeout hangups and attempt recovery. */
|
|
519
|
-
const DEFAULT_ENABLE_SERVER_HANGUP_INTERCEPTION = true;
|
|
520
|
-
/** Default video track constraints applied when video is enabled without explicit constraints. */
|
|
521
|
-
const DEFAULT_VIDEO_CONSTRAINTS = {
|
|
522
|
-
width: { ideal: 1280 },
|
|
523
|
-
height: { ideal: 720 },
|
|
524
|
-
aspectRatio: 16 / 9
|
|
525
|
-
};
|
|
526
|
-
/** Whether stereo Opus is enabled by default. */
|
|
527
|
-
const DEFAULT_STEREO_AUDIO = false;
|
|
528
|
-
/** Max average bitrate for stereo Opus in bits per second. */
|
|
529
|
-
const DEFAULT_STEREO_MAX_AVERAGE_BITRATE = 51e4;
|
|
530
|
-
|
|
531
407
|
//#endregion
|
|
532
408
|
//#region src/utils/time.ts
|
|
533
409
|
function fromSecToMs(seconds) {
|
|
@@ -539,23 +415,23 @@ function fromMsToSec(milliseconds) {
|
|
|
539
415
|
|
|
540
416
|
//#endregion
|
|
541
417
|
//#region src/containers/PreferencesContainer.ts
|
|
542
|
-
const logger$
|
|
418
|
+
const logger$30 = require_operators.getLogger();
|
|
543
419
|
var PreferencesContainer = class PreferencesContainer {
|
|
544
420
|
static get instance() {
|
|
545
421
|
this._instance ??= new PreferencesContainer();
|
|
546
422
|
return this._instance;
|
|
547
423
|
}
|
|
548
424
|
constructor() {
|
|
549
|
-
this.deviceDebounceTime = DEFAULT_DEVICE_DEBOUNCE_TIME_MS;
|
|
550
|
-
this.devicePollingInterval = DEFAULT_DEVICE_POLLING_INTERVAL_MS;
|
|
551
|
-
this.reconnectCallsTimeout = DEFAULT_RECONNECT_CALLS_TIMEOUT_MS;
|
|
552
|
-
this.connectionTimeout = DEFAULT_CONNECTION_TIMEOUT_MS;
|
|
553
|
-
this.reconnectDelayMin = DEFAULT_RECONNECT_DELAY_MIN_MS;
|
|
554
|
-
this.reconnectDelayMax = DEFAULT_RECONNECT_DELAY_MAX_MS;
|
|
425
|
+
this.deviceDebounceTime = require_operators.DEFAULT_DEVICE_DEBOUNCE_TIME_MS;
|
|
426
|
+
this.devicePollingInterval = require_operators.DEFAULT_DEVICE_POLLING_INTERVAL_MS;
|
|
427
|
+
this.reconnectCallsTimeout = require_operators.DEFAULT_RECONNECT_CALLS_TIMEOUT_MS;
|
|
428
|
+
this.connectionTimeout = require_operators.DEFAULT_CONNECTION_TIMEOUT_MS;
|
|
429
|
+
this.reconnectDelayMin = require_operators.DEFAULT_RECONNECT_DELAY_MIN_MS;
|
|
430
|
+
this.reconnectDelayMax = require_operators.DEFAULT_RECONNECT_DELAY_MAX_MS;
|
|
555
431
|
this.disableUdpIceServers = false;
|
|
556
432
|
this.relayOnly = false;
|
|
557
|
-
this.iceCandidateTimeout = DEFAULT_ICE_CANDIDATE_TIMEOUT_MS;
|
|
558
|
-
this.iceGatheringTimeout = DEFAULT_ICE_GATHERING_TIMEOUT_MS;
|
|
433
|
+
this.iceCandidateTimeout = require_operators.DEFAULT_ICE_CANDIDATE_TIMEOUT_MS;
|
|
434
|
+
this.iceGatheringTimeout = require_operators.DEFAULT_ICE_GATHERING_TIMEOUT_MS;
|
|
559
435
|
this.defaultSignalWireOptions = {
|
|
560
436
|
skipConnection: false,
|
|
561
437
|
skipRegister: false,
|
|
@@ -582,38 +458,38 @@ var PreferencesContainer = class PreferencesContainer {
|
|
|
582
458
|
"call.joined"
|
|
583
459
|
];
|
|
584
460
|
this.userVariables = {};
|
|
585
|
-
this.statsPollingInterval = DEFAULT_STATS_POLLING_INTERVAL_MS;
|
|
586
|
-
this.statsBaselineSamples = DEFAULT_STATS_BASELINE_SAMPLES;
|
|
587
|
-
this.statsNoPacketThreshold = DEFAULT_STATS_NO_PACKET_THRESHOLD_MS;
|
|
588
|
-
this.statsRttSpikeMultiplier = DEFAULT_STATS_RTT_SPIKE_MULTIPLIER;
|
|
589
|
-
this.statsPacketLossThreshold = DEFAULT_STATS_PACKET_LOSS_THRESHOLD;
|
|
590
|
-
this.statsJitterSpikeMultiplier = DEFAULT_STATS_JITTER_SPIKE_MULTIPLIER;
|
|
591
|
-
this.statsHistorySize = DEFAULT_STATS_HISTORY_SIZE;
|
|
592
|
-
this.keyframeMaxBurst = DEFAULT_KEYFRAME_MAX_BURST
|
|
593
|
-
this.keyframeBurstWindow = DEFAULT_KEYFRAME_BURST_WINDOW_MS
|
|
594
|
-
this.keyframeCooldown = DEFAULT_KEYFRAME_COOLDOWN_MS
|
|
595
|
-
this.reinviteDebounceTime = DEFAULT_REINVITE_DEBOUNCE_TIME_MS;
|
|
596
|
-
this.reinviteMaxAttempts = DEFAULT_REINVITE_MAX_ATTEMPTS;
|
|
597
|
-
this.reinviteTimeout = DEFAULT_REINVITE_TIMEOUT_MS;
|
|
598
|
-
this.recoveryDebounceTime = DEFAULT_RECOVERY_DEBOUNCE_TIME_MS;
|
|
599
|
-
this.recoveryCooldown = DEFAULT_RECOVERY_COOLDOWN_MS;
|
|
600
|
-
this.iceDisconnectedGracePeriod = DEFAULT_ICE_DISCONNECTED_GRACE_PERIOD_MS;
|
|
601
|
-
this.iceRestartTimeout = DEFAULT_ICE_RESTART_TIMEOUT_MS
|
|
602
|
-
this.maxRecoveryAttempts = DEFAULT_MAX_RECOVERY_ATTEMPTS;
|
|
603
|
-
this.enableRelayFallback = DEFAULT_ENABLE_RELAY_FALLBACK;
|
|
604
|
-
this.enableNetworkChangeDetection = DEFAULT_ENABLE_NETWORK_CHANGE_DETECTION;
|
|
605
|
-
this.enableServerHangupInterception = DEFAULT_ENABLE_SERVER_HANGUP_INTERCEPTION;
|
|
606
|
-
this.persistDeviceSelection = DEFAULT_PERSIST_DEVICE_SELECTION;
|
|
607
|
-
this.syncDevicesToActiveCalls = DEFAULT_SYNC_DEVICES_TO_ACTIVE_CALLS;
|
|
608
|
-
this.autoMuteVideoOnHidden = DEFAULT_AUTO_MUTE_VIDEO_ON_HIDDEN;
|
|
609
|
-
this.refreshDevicesOnVisible = DEFAULT_REFRESH_DEVICES_ON_VISIBLE;
|
|
610
|
-
this.checkConnectionOnVisible = DEFAULT_CHECK_CONNECTION_ON_VISIBLE;
|
|
461
|
+
this.statsPollingInterval = require_operators.DEFAULT_STATS_POLLING_INTERVAL_MS;
|
|
462
|
+
this.statsBaselineSamples = require_operators.DEFAULT_STATS_BASELINE_SAMPLES;
|
|
463
|
+
this.statsNoPacketThreshold = require_operators.DEFAULT_STATS_NO_PACKET_THRESHOLD_MS;
|
|
464
|
+
this.statsRttSpikeMultiplier = require_operators.DEFAULT_STATS_RTT_SPIKE_MULTIPLIER;
|
|
465
|
+
this.statsPacketLossThreshold = require_operators.DEFAULT_STATS_PACKET_LOSS_THRESHOLD;
|
|
466
|
+
this.statsJitterSpikeMultiplier = require_operators.DEFAULT_STATS_JITTER_SPIKE_MULTIPLIER;
|
|
467
|
+
this.statsHistorySize = require_operators.DEFAULT_STATS_HISTORY_SIZE;
|
|
468
|
+
this.keyframeMaxBurst = require_operators.DEFAULT_KEYFRAME_MAX_BURST;
|
|
469
|
+
this.keyframeBurstWindow = require_operators.DEFAULT_KEYFRAME_BURST_WINDOW_MS;
|
|
470
|
+
this.keyframeCooldown = require_operators.DEFAULT_KEYFRAME_COOLDOWN_MS;
|
|
471
|
+
this.reinviteDebounceTime = require_operators.DEFAULT_REINVITE_DEBOUNCE_TIME_MS;
|
|
472
|
+
this.reinviteMaxAttempts = require_operators.DEFAULT_REINVITE_MAX_ATTEMPTS;
|
|
473
|
+
this.reinviteTimeout = require_operators.DEFAULT_REINVITE_TIMEOUT_MS;
|
|
474
|
+
this.recoveryDebounceTime = require_operators.DEFAULT_RECOVERY_DEBOUNCE_TIME_MS;
|
|
475
|
+
this.recoveryCooldown = require_operators.DEFAULT_RECOVERY_COOLDOWN_MS;
|
|
476
|
+
this.iceDisconnectedGracePeriod = require_operators.DEFAULT_ICE_DISCONNECTED_GRACE_PERIOD_MS;
|
|
477
|
+
this.iceRestartTimeout = require_operators.DEFAULT_ICE_RESTART_TIMEOUT_MS;
|
|
478
|
+
this.maxRecoveryAttempts = require_operators.DEFAULT_MAX_RECOVERY_ATTEMPTS;
|
|
479
|
+
this.enableRelayFallback = require_operators.DEFAULT_ENABLE_RELAY_FALLBACK;
|
|
480
|
+
this.enableNetworkChangeDetection = require_operators.DEFAULT_ENABLE_NETWORK_CHANGE_DETECTION;
|
|
481
|
+
this.enableServerHangupInterception = require_operators.DEFAULT_ENABLE_SERVER_HANGUP_INTERCEPTION;
|
|
482
|
+
this.persistDeviceSelection = require_operators.DEFAULT_PERSIST_DEVICE_SELECTION;
|
|
483
|
+
this.syncDevicesToActiveCalls = require_operators.DEFAULT_SYNC_DEVICES_TO_ACTIVE_CALLS;
|
|
484
|
+
this.autoMuteVideoOnHidden = require_operators.DEFAULT_AUTO_MUTE_VIDEO_ON_HIDDEN;
|
|
485
|
+
this.refreshDevicesOnVisible = require_operators.DEFAULT_REFRESH_DEVICES_ON_VISIBLE;
|
|
486
|
+
this.checkConnectionOnVisible = require_operators.DEFAULT_CHECK_CONNECTION_ON_VISIBLE;
|
|
611
487
|
this.defaultAudioConstraints = void 0;
|
|
612
488
|
this.defaultVideoConstraints = void 0;
|
|
613
|
-
this.stereoAudio = DEFAULT_STEREO_AUDIO;
|
|
614
|
-
this.enableAutoDegradation = DEFAULT_ENABLE_AUTO_DEGRADATION;
|
|
615
|
-
this.degradationBitrateThreshold = DEFAULT_DEGRADATION_BITRATE_THRESHOLD_KBPS;
|
|
616
|
-
this.degradationRecoveryThreshold = DEFAULT_DEGRADATION_RECOVERY_THRESHOLD_KBPS;
|
|
489
|
+
this.stereoAudio = require_operators.DEFAULT_STEREO_AUDIO;
|
|
490
|
+
this.enableAutoDegradation = require_operators.DEFAULT_ENABLE_AUTO_DEGRADATION;
|
|
491
|
+
this.degradationBitrateThreshold = require_operators.DEFAULT_DEGRADATION_BITRATE_THRESHOLD_KBPS;
|
|
492
|
+
this.degradationRecoveryThreshold = require_operators.DEFAULT_DEGRADATION_RECOVERY_THRESHOLD_KBPS;
|
|
617
493
|
this.preferredVideoCodecs = [];
|
|
618
494
|
this.preferredAudioCodecs = [];
|
|
619
495
|
}
|
|
@@ -1200,17 +1076,17 @@ var ClientPreferences = class {
|
|
|
1200
1076
|
_saveToStorage() {
|
|
1201
1077
|
if (!this._storage) return;
|
|
1202
1078
|
const data = collectStoredPreferences();
|
|
1203
|
-
this._storage.setItem(PREFERENCES_STORAGE_KEY, data, "local").catch((error) => {
|
|
1204
|
-
logger$
|
|
1079
|
+
this._storage.setItem(require_operators.PREFERENCES_STORAGE_KEY, data, "local").catch((error) => {
|
|
1080
|
+
logger$30.error(`[ClientPreferences] Failed to save preferences: ${String(error)}`);
|
|
1205
1081
|
});
|
|
1206
1082
|
}
|
|
1207
1083
|
/** Loads preferences from storage and applies them to the container. */
|
|
1208
1084
|
_loadFromStorage() {
|
|
1209
1085
|
if (!this._storage) return;
|
|
1210
|
-
this._storage.getItem(PREFERENCES_STORAGE_KEY, "local").then((stored) => {
|
|
1086
|
+
this._storage.getItem(require_operators.PREFERENCES_STORAGE_KEY, "local").then((stored) => {
|
|
1211
1087
|
if (stored) applyStoredPreferences(stored);
|
|
1212
1088
|
}).catch((error) => {
|
|
1213
|
-
logger$
|
|
1089
|
+
logger$30.error(`[ClientPreferences] Failed to load preferences: ${String(error)}`);
|
|
1214
1090
|
});
|
|
1215
1091
|
}
|
|
1216
1092
|
};
|
|
@@ -1231,12 +1107,12 @@ function toError(value) {
|
|
|
1231
1107
|
|
|
1232
1108
|
//#endregion
|
|
1233
1109
|
//#region src/controllers/NavigatorDeviceController.ts
|
|
1234
|
-
const logger$
|
|
1110
|
+
const logger$29 = require_operators.getLogger();
|
|
1235
1111
|
/** Maps a device kind to its storage key. */
|
|
1236
1112
|
const DEVICE_STORAGE_KEYS = {
|
|
1237
|
-
audioinput: DEVICE_STORAGE_KEY_AUDIO_INPUT,
|
|
1238
|
-
audiooutput: DEVICE_STORAGE_KEY_AUDIO_OUTPUT,
|
|
1239
|
-
videoinput: DEVICE_STORAGE_KEY_VIDEO_INPUT
|
|
1113
|
+
audioinput: require_operators.DEVICE_STORAGE_KEY_AUDIO_INPUT,
|
|
1114
|
+
audiooutput: require_operators.DEVICE_STORAGE_KEY_AUDIO_OUTPUT,
|
|
1115
|
+
videoinput: require_operators.DEVICE_STORAGE_KEY_VIDEO_INPUT
|
|
1240
1116
|
};
|
|
1241
1117
|
const initialDevicesState = {
|
|
1242
1118
|
audioinput: [],
|
|
@@ -1253,7 +1129,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1253
1129
|
super();
|
|
1254
1130
|
this.webRTCApiProvider = webRTCApiProvider;
|
|
1255
1131
|
this.deviceChangeHandler = () => {
|
|
1256
|
-
logger$
|
|
1132
|
+
logger$29.debug("[DeviceController] Device change detected");
|
|
1257
1133
|
this.enumerateDevices();
|
|
1258
1134
|
};
|
|
1259
1135
|
this._devicesState$ = this.createBehaviorSubject(initialDevicesState);
|
|
@@ -1318,13 +1194,13 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1318
1194
|
return this.cachedObservable("videoInputDevices$", () => this._devicesState$.pipe((0, rxjs.map)((state) => state.videoinput), (0, rxjs.distinctUntilChanged)(), (0, rxjs.takeUntil)(this.destroyed$)));
|
|
1319
1195
|
}
|
|
1320
1196
|
get selectedAudioInputDevice$() {
|
|
1321
|
-
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$
|
|
1197
|
+
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$29.debug("[DeviceController] Selected audio input device changed:", info))));
|
|
1322
1198
|
}
|
|
1323
1199
|
get selectedAudioOutputDevice$() {
|
|
1324
|
-
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$
|
|
1200
|
+
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$29.debug("[DeviceController] Selected audio output device changed:", info))));
|
|
1325
1201
|
}
|
|
1326
1202
|
get selectedVideoInputDevice$() {
|
|
1327
|
-
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$
|
|
1203
|
+
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$29.debug("[DeviceController] Selected video input device changed:", info))));
|
|
1328
1204
|
}
|
|
1329
1205
|
get selectedAudioInputDevice() {
|
|
1330
1206
|
if (this._audioInputDisabled$.value) return null;
|
|
@@ -1399,7 +1275,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1399
1275
|
if (device) this.persistDeviceSelection("audioinput", device);
|
|
1400
1276
|
}
|
|
1401
1277
|
selectVideoInputDevice(device) {
|
|
1402
|
-
logger$
|
|
1278
|
+
logger$29.debug("[DeviceController] Setting selected video input device:", device);
|
|
1403
1279
|
if (this._videoInputDisabled$.value && device) this._videoInputDisabled$.next(false);
|
|
1404
1280
|
const previous = this._selectedDevicesState$.value.videoinput;
|
|
1405
1281
|
if (previous && previous.deviceId !== device?.deviceId) this._deviceHistory.push("videoinput", previous);
|
|
@@ -1456,7 +1332,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1456
1332
|
}
|
|
1457
1333
|
const fromHistory = this._deviceHistory.findInHistory(kind, devices);
|
|
1458
1334
|
if (fromHistory) {
|
|
1459
|
-
logger$
|
|
1335
|
+
logger$29.debug(`[DeviceController] Device disappeared, falling back to history: ${fromHistory.label}`);
|
|
1460
1336
|
this.emitDeviceRecovered(kind, selected, fromHistory, "device_disconnected");
|
|
1461
1337
|
return fromHistory;
|
|
1462
1338
|
}
|
|
@@ -1509,7 +1385,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1509
1385
|
try {
|
|
1510
1386
|
await this._storageManager.setItem(DEVICE_STORAGE_KEYS[kind], stored, "local");
|
|
1511
1387
|
} catch (error) {
|
|
1512
|
-
logger$
|
|
1388
|
+
logger$29.error(`[DeviceController] Failed to persist device selection for ${kind}:`, error);
|
|
1513
1389
|
}
|
|
1514
1390
|
}
|
|
1515
1391
|
async loadPersistedDevices() {
|
|
@@ -1525,7 +1401,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1525
1401
|
[kind]: stored
|
|
1526
1402
|
};
|
|
1527
1403
|
} catch (error) {
|
|
1528
|
-
logger$
|
|
1404
|
+
logger$29.error(`[DeviceController] Failed to load persisted device for ${kind}:`, error);
|
|
1529
1405
|
}
|
|
1530
1406
|
}
|
|
1531
1407
|
/** Clears device history, persisted selections, and re-enumerates devices. */
|
|
@@ -1543,7 +1419,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1543
1419
|
this.disableDeviceMonitoring();
|
|
1544
1420
|
this.webRTCApiProvider.mediaDevices.addEventListener("devicechange", this.deviceChangeHandler);
|
|
1545
1421
|
if (PreferencesContainer.instance.devicePollingInterval > 0) this._devicesPoolingSubscription = (0, rxjs.interval)(PreferencesContainer.instance.devicePollingInterval).subscribe(() => {
|
|
1546
|
-
logger$
|
|
1422
|
+
logger$29.debug("[DeviceController] Polling devices due to interval");
|
|
1547
1423
|
this.enumerateDevices();
|
|
1548
1424
|
});
|
|
1549
1425
|
this.enumerateDevices();
|
|
@@ -1569,13 +1445,13 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1569
1445
|
videoinput: []
|
|
1570
1446
|
});
|
|
1571
1447
|
this._devicesState$.next(devicesByKind);
|
|
1572
|
-
logger$
|
|
1448
|
+
logger$29.debug("[DeviceController] Devices enumerated:", {
|
|
1573
1449
|
audioInputs: devicesByKind.audioinput.length,
|
|
1574
1450
|
audioOutputs: devicesByKind.audiooutput.length,
|
|
1575
1451
|
videoInputs: devicesByKind.videoinput.length
|
|
1576
1452
|
});
|
|
1577
1453
|
} catch (error) {
|
|
1578
|
-
logger$
|
|
1454
|
+
logger$29.error("[DeviceController] Failed to enumerate devices:", error);
|
|
1579
1455
|
this._errors$.next(toError(error));
|
|
1580
1456
|
}
|
|
1581
1457
|
}
|
|
@@ -1591,7 +1467,7 @@ var NavigatorDeviceController = class extends Destroyable {
|
|
|
1591
1467
|
stream.getTracks().forEach((t) => t.stop());
|
|
1592
1468
|
return capabilities;
|
|
1593
1469
|
} catch (error) {
|
|
1594
|
-
logger$
|
|
1470
|
+
logger$29.error("[DeviceController] Failed to get device capabilities:", error);
|
|
1595
1471
|
this._errors$.next(toError(error));
|
|
1596
1472
|
throw error;
|
|
1597
1473
|
}
|
|
@@ -1842,7 +1718,7 @@ var DependencyContainer = class {
|
|
|
1842
1718
|
|
|
1843
1719
|
//#endregion
|
|
1844
1720
|
//#region src/controllers/CryptoController.ts
|
|
1845
|
-
const logger$
|
|
1721
|
+
const logger$28 = require_operators.getLogger();
|
|
1846
1722
|
const DPOP_DB_NAME = "sw-dpop";
|
|
1847
1723
|
const DPOP_DB_VERSION = 1;
|
|
1848
1724
|
const DPOP_STORE_NAME = "keys";
|
|
@@ -1901,7 +1777,7 @@ async function loadKeyPairFromDB() {
|
|
|
1901
1777
|
tx.oncomplete = () => db.close();
|
|
1902
1778
|
});
|
|
1903
1779
|
} catch (error) {
|
|
1904
|
-
logger$
|
|
1780
|
+
logger$28.warn("[DPoP] Failed to load key pair from IndexedDB:", error);
|
|
1905
1781
|
return null;
|
|
1906
1782
|
}
|
|
1907
1783
|
}
|
|
@@ -1921,7 +1797,7 @@ async function saveKeyPairToDB(keyPair) {
|
|
|
1921
1797
|
};
|
|
1922
1798
|
});
|
|
1923
1799
|
} catch (error) {
|
|
1924
|
-
logger$
|
|
1800
|
+
logger$28.warn("[DPoP] Failed to save key pair to IndexedDB:", error);
|
|
1925
1801
|
}
|
|
1926
1802
|
}
|
|
1927
1803
|
async function deleteKeyPairFromDB() {
|
|
@@ -1940,7 +1816,7 @@ async function deleteKeyPairFromDB() {
|
|
|
1940
1816
|
};
|
|
1941
1817
|
});
|
|
1942
1818
|
} catch (error) {
|
|
1943
|
-
logger$
|
|
1819
|
+
logger$28.warn("[DPoP] Failed to delete key pair from IndexedDB:", error);
|
|
1944
1820
|
}
|
|
1945
1821
|
}
|
|
1946
1822
|
/**
|
|
@@ -2000,13 +1876,13 @@ var CryptoController = class {
|
|
|
2000
1876
|
this._publicJwk = await crypto.subtle.exportKey("jwk", stored.publicKey);
|
|
2001
1877
|
this._fingerprint = await computeJwkThumbprint(this._publicJwk);
|
|
2002
1878
|
this._initialized = true;
|
|
2003
|
-
logger$
|
|
1879
|
+
logger$28.debug("[DPoP] Key pair restored from IndexedDB, fingerprint:", this._fingerprint);
|
|
2004
1880
|
return this._fingerprint;
|
|
2005
1881
|
} catch (error) {
|
|
2006
|
-
logger$
|
|
1882
|
+
logger$28.warn("[DPoP] Stored key pair unusable, generating new one:", error);
|
|
2007
1883
|
await deleteKeyPairFromDB();
|
|
2008
1884
|
}
|
|
2009
|
-
logger$
|
|
1885
|
+
logger$28.debug("[DPoP] Generating RSA key pair");
|
|
2010
1886
|
this._keyPair = await crypto.subtle.generateKey({
|
|
2011
1887
|
name: "RSASSA-PKCS1-v1_5",
|
|
2012
1888
|
modulusLength: 2048,
|
|
@@ -2021,7 +1897,7 @@ var CryptoController = class {
|
|
|
2021
1897
|
this._fingerprint = await computeJwkThumbprint(this._publicJwk);
|
|
2022
1898
|
this._initialized = true;
|
|
2023
1899
|
await saveKeyPairToDB(this._keyPair);
|
|
2024
|
-
logger$
|
|
1900
|
+
logger$28.debug("[DPoP] Key pair generated and persisted, fingerprint:", this._fingerprint);
|
|
2025
1901
|
return this._fingerprint;
|
|
2026
1902
|
}
|
|
2027
1903
|
/**
|
|
@@ -2087,7 +1963,7 @@ var CryptoController = class {
|
|
|
2087
1963
|
this._fingerprint = null;
|
|
2088
1964
|
this._initialized = false;
|
|
2089
1965
|
deleteKeyPairFromDB();
|
|
2090
|
-
logger$
|
|
1966
|
+
logger$28.debug("[DPoP] Controller destroyed");
|
|
2091
1967
|
}
|
|
2092
1968
|
get publicJwk() {
|
|
2093
1969
|
if (!this._publicJwk) throw new require_operators.DPoPInitError("CryptoController not initialized. Call init() first.");
|
|
@@ -2110,7 +1986,7 @@ var CryptoController = class {
|
|
|
2110
1986
|
|
|
2111
1987
|
//#endregion
|
|
2112
1988
|
//#region src/controllers/NetworkMonitor.ts
|
|
2113
|
-
const logger$
|
|
1989
|
+
const logger$27 = require_operators.getLogger();
|
|
2114
1990
|
/**
|
|
2115
1991
|
* Safely check whether we are running in a browser environment
|
|
2116
1992
|
* with `window` and the relevant event targets.
|
|
@@ -2167,7 +2043,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2167
2043
|
}
|
|
2168
2044
|
attachListeners() {
|
|
2169
2045
|
if (!hasBrowserNetworkEvents()) {
|
|
2170
|
-
logger$
|
|
2046
|
+
logger$27.debug("NetworkMonitor: no browser environment detected, skipping event listeners");
|
|
2171
2047
|
return;
|
|
2172
2048
|
}
|
|
2173
2049
|
window.addEventListener("online", this._onOnline);
|
|
@@ -2175,7 +2051,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2175
2051
|
const connection = getNetworkConnection();
|
|
2176
2052
|
if (connection) connection.addEventListener("change", this._onConnectionChange);
|
|
2177
2053
|
this._listenersAttached = true;
|
|
2178
|
-
logger$
|
|
2054
|
+
logger$27.debug("NetworkMonitor: event listeners attached");
|
|
2179
2055
|
}
|
|
2180
2056
|
removeListeners() {
|
|
2181
2057
|
if (!this._listenersAttached) return;
|
|
@@ -2186,10 +2062,10 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2186
2062
|
if (connection) connection.removeEventListener("change", this._onConnectionChange);
|
|
2187
2063
|
}
|
|
2188
2064
|
this._listenersAttached = false;
|
|
2189
|
-
logger$
|
|
2065
|
+
logger$27.debug("NetworkMonitor: event listeners removed");
|
|
2190
2066
|
}
|
|
2191
2067
|
handleOnline() {
|
|
2192
|
-
logger$
|
|
2068
|
+
logger$27.info("NetworkMonitor: browser went online");
|
|
2193
2069
|
this._isOnline$.next(true);
|
|
2194
2070
|
this._networkChange$.next({
|
|
2195
2071
|
type: "online",
|
|
@@ -2198,7 +2074,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2198
2074
|
});
|
|
2199
2075
|
}
|
|
2200
2076
|
handleOffline() {
|
|
2201
|
-
logger$
|
|
2077
|
+
logger$27.info("NetworkMonitor: browser went offline");
|
|
2202
2078
|
this._isOnline$.next(false);
|
|
2203
2079
|
this._networkChange$.next({
|
|
2204
2080
|
type: "offline",
|
|
@@ -2207,7 +2083,7 @@ var NetworkMonitor = class extends Destroyable {
|
|
|
2207
2083
|
}
|
|
2208
2084
|
handleConnectionChange() {
|
|
2209
2085
|
const networkType = getNetworkType();
|
|
2210
|
-
logger$
|
|
2086
|
+
logger$27.info(`NetworkMonitor: connection changed — effectiveType=${networkType ?? "unknown"}`);
|
|
2211
2087
|
this._networkChange$.next({
|
|
2212
2088
|
type: "connection_change",
|
|
2213
2089
|
timestamp: Date.now(),
|
|
@@ -2322,7 +2198,7 @@ function getNavigatorMediaDevices() {
|
|
|
2322
2198
|
|
|
2323
2199
|
//#endregion
|
|
2324
2200
|
//#region src/controllers/PreflightRunner.ts
|
|
2325
|
-
const logger$
|
|
2201
|
+
const logger$26 = require_operators.getLogger();
|
|
2326
2202
|
const DEFAULT_MEDIA_TEST_DURATION_S = 10;
|
|
2327
2203
|
const ICE_GATHERING_TIMEOUT_MS = 1e4;
|
|
2328
2204
|
const SIGNALING_RTT_TIMEOUT_MS = 5e3;
|
|
@@ -2371,7 +2247,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2371
2247
|
if (!this._options.skipMediaTest) try {
|
|
2372
2248
|
bandwidth = await this.testMediaBandwidth(destination);
|
|
2373
2249
|
} catch (error) {
|
|
2374
|
-
logger$
|
|
2250
|
+
logger$26.warn("[PreflightRunner] Media bandwidth test failed:", error);
|
|
2375
2251
|
warnings.push("Media bandwidth test failed");
|
|
2376
2252
|
}
|
|
2377
2253
|
return {
|
|
@@ -2383,7 +2259,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2383
2259
|
warnings
|
|
2384
2260
|
};
|
|
2385
2261
|
} catch (error) {
|
|
2386
|
-
logger$
|
|
2262
|
+
logger$26.error("[PreflightRunner] Preflight test failed:", error);
|
|
2387
2263
|
throw new require_operators.PreflightError("preflight", error instanceof Error ? error : new Error(String(error)));
|
|
2388
2264
|
} finally {
|
|
2389
2265
|
this.destroy();
|
|
@@ -2414,7 +2290,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2414
2290
|
if (track.kind === "video" && track.readyState === "live") videoWorking = true;
|
|
2415
2291
|
}
|
|
2416
2292
|
} catch (error) {
|
|
2417
|
-
logger$
|
|
2293
|
+
logger$26.warn("[PreflightRunner] Device test failed:", error);
|
|
2418
2294
|
} finally {
|
|
2419
2295
|
if (audioStream) audioStream.getTracks().forEach((t) => t.stop());
|
|
2420
2296
|
}
|
|
@@ -2472,7 +2348,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2472
2348
|
rttMs
|
|
2473
2349
|
};
|
|
2474
2350
|
} catch (error) {
|
|
2475
|
-
logger$
|
|
2351
|
+
logger$26.warn("[PreflightRunner] ICE connectivity test failed:", error);
|
|
2476
2352
|
return {
|
|
2477
2353
|
type: "failed",
|
|
2478
2354
|
turnReachable: false,
|
|
@@ -2519,7 +2395,7 @@ var PreflightRunner = class extends Destroyable {
|
|
|
2519
2395
|
|
|
2520
2396
|
//#endregion
|
|
2521
2397
|
//#region src/controllers/VisibilityController.ts
|
|
2522
|
-
const logger$
|
|
2398
|
+
const logger$25 = require_operators.getLogger();
|
|
2523
2399
|
/**
|
|
2524
2400
|
* Checks whether the document visibility API is available.
|
|
2525
2401
|
*/
|
|
@@ -2556,8 +2432,8 @@ var VisibilityController = class extends Destroyable {
|
|
|
2556
2432
|
this._boundHandler = this._handleVisibilityChange.bind(this);
|
|
2557
2433
|
if (this._hasVisibilityApi) {
|
|
2558
2434
|
document.addEventListener("visibilitychange", this._boundHandler);
|
|
2559
|
-
logger$
|
|
2560
|
-
} else logger$
|
|
2435
|
+
logger$25.debug("VisibilityController: listening for visibilitychange events");
|
|
2436
|
+
} else logger$25.debug("VisibilityController: document visibility API not available, defaulting to visible");
|
|
2561
2437
|
}
|
|
2562
2438
|
/**
|
|
2563
2439
|
* Observable of the current visibility state.
|
|
@@ -2582,7 +2458,7 @@ var VisibilityController = class extends Destroyable {
|
|
|
2582
2458
|
destroy() {
|
|
2583
2459
|
if (this._hasVisibilityApi) {
|
|
2584
2460
|
document.removeEventListener("visibilitychange", this._boundHandler);
|
|
2585
|
-
logger$
|
|
2461
|
+
logger$25.debug("VisibilityController: removed visibilitychange listener");
|
|
2586
2462
|
}
|
|
2587
2463
|
super.destroy();
|
|
2588
2464
|
}
|
|
@@ -2600,7 +2476,7 @@ var VisibilityController = class extends Destroyable {
|
|
|
2600
2476
|
timestamp: Date.now()
|
|
2601
2477
|
};
|
|
2602
2478
|
this._visibilityChange$.next(changeEvent);
|
|
2603
|
-
logger$
|
|
2479
|
+
logger$25.debug("VisibilityController: visibility changed", {
|
|
2604
2480
|
from: previousState,
|
|
2605
2481
|
to: newState
|
|
2606
2482
|
});
|
|
@@ -2803,7 +2679,7 @@ const RPCEventAckResponse = (id) => makeRPCResponse({
|
|
|
2803
2679
|
|
|
2804
2680
|
//#endregion
|
|
2805
2681
|
//#region src/managers/AttachManager.ts
|
|
2806
|
-
const logger$
|
|
2682
|
+
const logger$24 = require_operators.getLogger();
|
|
2807
2683
|
var AttachManager = class {
|
|
2808
2684
|
constructor(storage, deviceController, reconnectCallsTimeout, attachKey) {
|
|
2809
2685
|
this.storage = storage;
|
|
@@ -2824,7 +2700,7 @@ var AttachManager = class {
|
|
|
2824
2700
|
try {
|
|
2825
2701
|
return await this.storage.getItem(this.attachKey) ?? {};
|
|
2826
2702
|
} catch (error) {
|
|
2827
|
-
logger$
|
|
2703
|
+
logger$24.warn("[AttachManager] Failed to retrieve attached calls from storage", error);
|
|
2828
2704
|
return {};
|
|
2829
2705
|
}
|
|
2830
2706
|
}
|
|
@@ -2832,7 +2708,7 @@ var AttachManager = class {
|
|
|
2832
2708
|
try {
|
|
2833
2709
|
await this.storage.setItem(this.attachKey, attached);
|
|
2834
2710
|
} catch (error) {
|
|
2835
|
-
logger$
|
|
2711
|
+
logger$24.warn("[AttachManager] Failed to write attached calls to storage", error);
|
|
2836
2712
|
}
|
|
2837
2713
|
}
|
|
2838
2714
|
/**
|
|
@@ -2851,7 +2727,7 @@ var AttachManager = class {
|
|
|
2851
2727
|
}
|
|
2852
2728
|
async attach(call) {
|
|
2853
2729
|
if (!call.to) {
|
|
2854
|
-
logger$
|
|
2730
|
+
logger$24.warn("[AttachManager] Skip attach for calls with no destination");
|
|
2855
2731
|
return;
|
|
2856
2732
|
}
|
|
2857
2733
|
const destination = call.to;
|
|
@@ -2904,15 +2780,15 @@ var AttachManager = class {
|
|
|
2904
2780
|
callId,
|
|
2905
2781
|
...options
|
|
2906
2782
|
});
|
|
2907
|
-
logger$
|
|
2783
|
+
logger$24.info(`[AttachManager] Reattached call ${callId} (attempt ${attempt})`);
|
|
2908
2784
|
succeeded = true;
|
|
2909
2785
|
break;
|
|
2910
2786
|
} catch (error) {
|
|
2911
|
-
logger$
|
|
2787
|
+
logger$24.warn(`[AttachManager] Reattach attempt ${attempt}/3 failed for call ${callId}:`, error);
|
|
2912
2788
|
if (attempt < 3) await new Promise((r) => setTimeout(r, (attempt + 1) * 1e3));
|
|
2913
2789
|
}
|
|
2914
2790
|
if (!succeeded) {
|
|
2915
|
-
logger$
|
|
2791
|
+
logger$24.warn(`[AttachManager] Reattach failed after 3 attempts for call ${callId}, removing reference`);
|
|
2916
2792
|
await this.detach({
|
|
2917
2793
|
id: callId,
|
|
2918
2794
|
mediaDirections: attachment.mediaDirections
|
|
@@ -2998,7 +2874,9 @@ const DEFAULT_MEMBER_CAPABILITIES = {
|
|
|
2998
2874
|
position: false,
|
|
2999
2875
|
meta: false,
|
|
3000
2876
|
remove: false,
|
|
3001
|
-
audioFlags: false
|
|
2877
|
+
audioFlags: false,
|
|
2878
|
+
denoise: false,
|
|
2879
|
+
lowbitrate: false
|
|
3002
2880
|
};
|
|
3003
2881
|
/**
|
|
3004
2882
|
* Default call capabilities with no permissions
|
|
@@ -3071,7 +2949,9 @@ function computeMemberCapabilities(flags, memberType) {
|
|
|
3071
2949
|
position: hasBooleanCapability(flags, memberType, null, "position"),
|
|
3072
2950
|
meta: hasBooleanCapability(flags, memberType, null, "meta"),
|
|
3073
2951
|
remove: hasBooleanCapability(flags, memberType, null, "remove"),
|
|
3074
|
-
audioFlags: hasBooleanCapability(flags, memberType, null, "audioflags")
|
|
2952
|
+
audioFlags: hasBooleanCapability(flags, memberType, null, "audioflags"),
|
|
2953
|
+
denoise: hasBooleanCapability(flags, memberType, null, "denoise"),
|
|
2954
|
+
lowbitrate: hasBooleanCapability(flags, memberType, null, "lowbitrate")
|
|
3075
2955
|
};
|
|
3076
2956
|
}
|
|
3077
2957
|
/**
|
|
@@ -3226,7 +3106,7 @@ function toggleHandraiseMethod(is) {
|
|
|
3226
3106
|
|
|
3227
3107
|
//#endregion
|
|
3228
3108
|
//#region src/core/entities/Participant.ts
|
|
3229
|
-
const logger$
|
|
3109
|
+
const logger$23 = require_operators.getLogger();
|
|
3230
3110
|
const initialState = {};
|
|
3231
3111
|
/**
|
|
3232
3112
|
* Represents a participant in a call.
|
|
@@ -3452,6 +3332,10 @@ var Participant = class extends Destroyable {
|
|
|
3452
3332
|
get nodeId() {
|
|
3453
3333
|
return this._state$.value.node_id;
|
|
3454
3334
|
}
|
|
3335
|
+
/** Call ID for this participant's leg, or `undefined` if not available. */
|
|
3336
|
+
get callId() {
|
|
3337
|
+
return this._state$.value.call_id;
|
|
3338
|
+
}
|
|
3455
3339
|
/** @internal */
|
|
3456
3340
|
get value() {
|
|
3457
3341
|
return this._state$.value;
|
|
@@ -3513,8 +3397,9 @@ var Participant = class extends Destroyable {
|
|
|
3513
3397
|
noise_suppression: !this.noiseSuppression
|
|
3514
3398
|
});
|
|
3515
3399
|
}
|
|
3400
|
+
/** Toggles low-bitrate mode for this participant's media. */
|
|
3516
3401
|
async toggleLowbitrate() {
|
|
3517
|
-
|
|
3402
|
+
await this.executeMethod(this.id, "call.lowbitrate.set", { lowbitrate: !this.lowbitrate });
|
|
3518
3403
|
}
|
|
3519
3404
|
/**
|
|
3520
3405
|
* Adjusts the **conference-only** microphone energy gate / sensitivity level
|
|
@@ -3561,10 +3446,27 @@ var Participant = class extends Destroyable {
|
|
|
3561
3446
|
}
|
|
3562
3447
|
/**
|
|
3563
3448
|
* Sets the participant's position in the video layout.
|
|
3449
|
+
*
|
|
3450
|
+
* Requires the `member.position` capability. The gateway keys positions by the
|
|
3451
|
+
* **target member's own** `call_id`/`node_id` (see issue #19400 and the legacy
|
|
3452
|
+
* `setPositions` implementation), so this sends the participant's own call
|
|
3453
|
+
* context — matching {@link Participant.remove}. A resolved promise does not
|
|
3454
|
+
* guarantee a visible change: the backend silently returns `200` (no-op) for
|
|
3455
|
+
* non-conference targets.
|
|
3456
|
+
*
|
|
3564
3457
|
* @param value - The {@link VideoPosition} to assign (e.g. `'auto'`, `'reserved-0'`).
|
|
3565
3458
|
*/
|
|
3566
3459
|
async setPosition(value) {
|
|
3567
|
-
|
|
3460
|
+
const state = this._state$.value;
|
|
3461
|
+
const target = {
|
|
3462
|
+
member_id: this.id,
|
|
3463
|
+
call_id: state.call_id ?? "",
|
|
3464
|
+
node_id: state.node_id ?? ""
|
|
3465
|
+
};
|
|
3466
|
+
await this.executeMethod(target, "call.member.position.set", { targets: [{
|
|
3467
|
+
target,
|
|
3468
|
+
position: value
|
|
3469
|
+
}] });
|
|
3568
3470
|
}
|
|
3569
3471
|
/** Removes this participant from the call. */
|
|
3570
3472
|
async remove() {
|
|
@@ -3654,12 +3556,21 @@ var SelfParticipant = class extends Participant {
|
|
|
3654
3556
|
noise_suppression: true
|
|
3655
3557
|
});
|
|
3656
3558
|
}
|
|
3657
|
-
/**
|
|
3559
|
+
/**
|
|
3560
|
+
* Starts sharing the local screen.
|
|
3561
|
+
*
|
|
3562
|
+
* The call is unaffected when acquisition fails.
|
|
3563
|
+
*
|
|
3564
|
+
* @throws The raw `getDisplayMedia` error. A dismissed picker or a
|
|
3565
|
+
* permission denial rejects with a `NotAllowedError` `DOMException` —
|
|
3566
|
+
* inspect `error.name` to tell benign cancels apart from real failures.
|
|
3567
|
+
*/
|
|
3658
3568
|
async startScreenShare() {
|
|
3659
3569
|
try {
|
|
3660
3570
|
await this.vertoManager.addScreenMedia();
|
|
3661
3571
|
} catch (error) {
|
|
3662
|
-
logger$
|
|
3572
|
+
logger$23.error("[Participant.startScreenShare] Screen share error:", error);
|
|
3573
|
+
throw error;
|
|
3663
3574
|
}
|
|
3664
3575
|
}
|
|
3665
3576
|
/** Observable of the current screen share status. */
|
|
@@ -3674,12 +3585,20 @@ var SelfParticipant = class extends Participant {
|
|
|
3674
3585
|
async stopScreenShare() {
|
|
3675
3586
|
return this.vertoManager.removeScreenMedia();
|
|
3676
3587
|
}
|
|
3677
|
-
/**
|
|
3588
|
+
/**
|
|
3589
|
+
* Adds an additional media input device to the call.
|
|
3590
|
+
*
|
|
3591
|
+
* The call is unaffected when acquisition fails.
|
|
3592
|
+
*
|
|
3593
|
+
* @throws The raw `getUserMedia` error (e.g. `NotAllowedError` on
|
|
3594
|
+
* permission denial) — inspect `error.name` to decide how to react.
|
|
3595
|
+
*/
|
|
3678
3596
|
async addAdditionalDevice(options) {
|
|
3679
3597
|
try {
|
|
3680
3598
|
await this.vertoManager.addInputDevice(options);
|
|
3681
3599
|
} catch (error) {
|
|
3682
|
-
logger$
|
|
3600
|
+
logger$23.error("[Participant.addAdditionalDevice] Additional device error:", error);
|
|
3601
|
+
throw error;
|
|
3683
3602
|
}
|
|
3684
3603
|
}
|
|
3685
3604
|
/** Removes an additional media input device by ID. */
|
|
@@ -3741,7 +3660,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3741
3660
|
*/
|
|
3742
3661
|
exitStudioModeIfActive() {
|
|
3743
3662
|
if (this._studioAudio$.value) {
|
|
3744
|
-
logger$
|
|
3663
|
+
logger$23.debug("[SelfParticipant] Exiting studio audio mode due to individual flag toggle");
|
|
3745
3664
|
this._studioAudio$.next(false);
|
|
3746
3665
|
}
|
|
3747
3666
|
}
|
|
@@ -3765,7 +3684,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3765
3684
|
try {
|
|
3766
3685
|
await super.mute();
|
|
3767
3686
|
} catch (error) {
|
|
3768
|
-
logger$
|
|
3687
|
+
logger$23.warn("[Participant.toggleAudioInput] Server Error while muting audio input, proceeding with local toggle anyway", error);
|
|
3769
3688
|
} finally {
|
|
3770
3689
|
this.vertoManager.muteMainAudioInputDevice();
|
|
3771
3690
|
}
|
|
@@ -3775,7 +3694,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3775
3694
|
try {
|
|
3776
3695
|
await super.unmute();
|
|
3777
3696
|
} catch (error) {
|
|
3778
|
-
logger$
|
|
3697
|
+
logger$23.warn("[Participant.toggleAudioInput] Server Error while unmuting audio input, proceeding with local toggle anyway", error);
|
|
3779
3698
|
} finally {
|
|
3780
3699
|
await this.vertoManager.unmuteMainAudioInputDevice();
|
|
3781
3700
|
}
|
|
@@ -3785,7 +3704,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3785
3704
|
try {
|
|
3786
3705
|
await super.muteVideo();
|
|
3787
3706
|
} catch (error) {
|
|
3788
|
-
logger$
|
|
3707
|
+
logger$23.warn("[Participant.toggleVideoInput] Server Error while muting video input, proceeding with local toggle anyway", error);
|
|
3789
3708
|
} finally {
|
|
3790
3709
|
this.vertoManager.muteMainVideoInputDevice();
|
|
3791
3710
|
}
|
|
@@ -3795,7 +3714,7 @@ var SelfParticipant = class extends Participant {
|
|
|
3795
3714
|
try {
|
|
3796
3715
|
await super.unmuteVideo();
|
|
3797
3716
|
} catch (error) {
|
|
3798
|
-
logger$
|
|
3717
|
+
logger$23.warn("[Participant.toggleVideoInput] Server Error while unmuting video input, proceeding with local toggle anyway", error);
|
|
3799
3718
|
} finally {
|
|
3800
3719
|
await this.vertoManager.unmuteMainVideoInputDevice();
|
|
3801
3720
|
}
|
|
@@ -3889,7 +3808,7 @@ function isLayoutChangedPayload(value) {
|
|
|
3889
3808
|
|
|
3890
3809
|
//#endregion
|
|
3891
3810
|
//#region src/managers/CallEventsManager.ts
|
|
3892
|
-
const logger$
|
|
3811
|
+
const logger$22 = require_operators.getLogger();
|
|
3893
3812
|
const initialSessionState = {};
|
|
3894
3813
|
/** @internal */
|
|
3895
3814
|
var CallEventsManager = class extends Destroyable {
|
|
@@ -3993,7 +3912,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
3993
3912
|
}
|
|
3994
3913
|
initSubscriptions() {
|
|
3995
3914
|
this.subscribeTo(this.callJoinedEvent$, (callJoinedEvent) => {
|
|
3996
|
-
logger$
|
|
3915
|
+
logger$22.debug("[CallEventsManager] Handling call.joined event for call/session IDs:", {
|
|
3997
3916
|
callId: callJoinedEvent.call_id,
|
|
3998
3917
|
roomSessionId: callJoinedEvent.room_session_id
|
|
3999
3918
|
});
|
|
@@ -4020,19 +3939,19 @@ var CallEventsManager = class extends Destroyable {
|
|
|
4020
3939
|
if (this._self$.value?.capabilities.setLayout) this.updateLayouts();
|
|
4021
3940
|
});
|
|
4022
3941
|
this.subscribeTo(this.memberUpdates$, (member) => {
|
|
4023
|
-
logger$
|
|
3942
|
+
logger$22.debug("[CallEventsManager] Handling member update event for member ID:", member);
|
|
4024
3943
|
this.upsertParticipant(member);
|
|
4025
3944
|
});
|
|
4026
3945
|
this.subscribeTo(this.webRtcCallSession.memberLeft$, (memberLeftEvent) => {
|
|
4027
|
-
logger$
|
|
3946
|
+
logger$22.debug("[CallEventsManager] Handling member.left event for member ID:", memberLeftEvent.member.member_id);
|
|
4028
3947
|
const participants = { ...this._participants$.value };
|
|
4029
3948
|
if (memberLeftEvent.member.member_id in participants) {
|
|
4030
3949
|
delete participants[memberLeftEvent.member.member_id];
|
|
4031
3950
|
this._participants$.next(participants);
|
|
4032
|
-
} else logger$
|
|
3951
|
+
} else logger$22.warn(`[CallEventsManager] Received member.left event for unknown member ID: ${memberLeftEvent.member.member_id}`);
|
|
4033
3952
|
});
|
|
4034
3953
|
this.subscribeTo(this.webRtcCallSession.callUpdated$, (callUpdatedEvent) => {
|
|
4035
|
-
logger$
|
|
3954
|
+
logger$22.debug("[CallEventsManager] Handling call.updated event:", callUpdatedEvent);
|
|
4036
3955
|
const roomSession = callUpdatedEvent.room_session;
|
|
4037
3956
|
this._sessionState$.next({
|
|
4038
3957
|
...this._sessionState$.value,
|
|
@@ -4047,7 +3966,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
4047
3966
|
});
|
|
4048
3967
|
});
|
|
4049
3968
|
this.subscribeTo(this.layoutChangedEvent$, (layoutChangedEvent) => {
|
|
4050
|
-
logger$
|
|
3969
|
+
logger$22.debug("[CallEventsManager] Handling layout.changed event:", layoutChangedEvent);
|
|
4051
3970
|
this._sessionState$.next({
|
|
4052
3971
|
...this._sessionState$.value,
|
|
4053
3972
|
layout_name: layoutChangedEvent.id,
|
|
@@ -4057,10 +3976,10 @@ var CallEventsManager = class extends Destroyable {
|
|
|
4057
3976
|
});
|
|
4058
3977
|
}
|
|
4059
3978
|
updateParticipantPositions(layoutChangedEvent) {
|
|
4060
|
-
if (Object.keys(this._participants$.value).length > 0 && !layoutChangedEvent.layers.some((layer) => !!layer.member_id)) logger$
|
|
3979
|
+
if (Object.keys(this._participants$.value).length > 0 && !layoutChangedEvent.layers.some((layer) => !!layer.member_id)) logger$22.warn("[CallEventsManager] No layers with member_id found in layout.changed event. Nothing to update.");
|
|
4061
3980
|
layoutChangedEvent.layers.filter((layer) => !!layer.member_id).filter((layer) => {
|
|
4062
3981
|
if (!(layer.member_id in this._participants$.value)) {
|
|
4063
|
-
logger$
|
|
3982
|
+
logger$22.warn(`[CallEventsManager] Skipping layout layer for unknown member_id: ${layer.member_id}`);
|
|
4064
3983
|
return false;
|
|
4065
3984
|
}
|
|
4066
3985
|
return true;
|
|
@@ -4083,7 +4002,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
4083
4002
|
layouts: response.result.layouts
|
|
4084
4003
|
});
|
|
4085
4004
|
}).catch((error) => {
|
|
4086
|
-
logger$
|
|
4005
|
+
logger$22.error("[CallEventsManager] Error fetching layouts:", error);
|
|
4087
4006
|
});
|
|
4088
4007
|
}
|
|
4089
4008
|
updateParticipants(members) {
|
|
@@ -4099,7 +4018,7 @@ var CallEventsManager = class extends Destroyable {
|
|
|
4099
4018
|
}
|
|
4100
4019
|
const participant = this._participants$.value[member.member_id];
|
|
4101
4020
|
const oldValue = participant.value;
|
|
4102
|
-
logger$
|
|
4021
|
+
logger$22.debug("[CallEventsManager] Updating participant:", member.member_id, {
|
|
4103
4022
|
oldValue,
|
|
4104
4023
|
newValue: member
|
|
4105
4024
|
});
|
|
@@ -4112,17 +4031,17 @@ var CallEventsManager = class extends Destroyable {
|
|
|
4112
4031
|
}
|
|
4113
4032
|
get callJoinedEvent$() {
|
|
4114
4033
|
return this.cachedObservable("callJoinedEvent$", () => this.webRtcCallSession.callEvent$.pipe((0, rxjs.filter)(isCallJoinedPayload), (0, rxjs.tap)((event) => {
|
|
4115
|
-
logger$
|
|
4034
|
+
logger$22.debug("[CallEventsManager] Call joined event:", event);
|
|
4116
4035
|
})));
|
|
4117
4036
|
}
|
|
4118
4037
|
get layoutChangedEvent$() {
|
|
4119
4038
|
return this.cachedObservable("layoutChangedEvent$", () => this.webRtcCallSession.callEvent$.pipe(require_operators.filterAs(isLayoutChangedPayload, "layout"), (0, rxjs.tap)((event) => {
|
|
4120
|
-
logger$
|
|
4039
|
+
logger$22.debug("[CallEventsManager] Layout changed event:", event);
|
|
4121
4040
|
})));
|
|
4122
4041
|
}
|
|
4123
4042
|
get memberUpdates$() {
|
|
4124
4043
|
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) => {
|
|
4125
|
-
logger$
|
|
4044
|
+
logger$22.debug("[CallEventsManager] Member update event:", event);
|
|
4126
4045
|
})));
|
|
4127
4046
|
}
|
|
4128
4047
|
destroy() {
|
|
@@ -4282,7 +4201,7 @@ function reorderCodecs(sdp, preferredVideo = [], preferredAudio = []) {
|
|
|
4282
4201
|
* // a=fmtp:111 minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1;maxaveragebitrate=510000
|
|
4283
4202
|
* ```
|
|
4284
4203
|
*/
|
|
4285
|
-
function enableStereoOpus(sdp, maxBitrate = DEFAULT_STEREO_MAX_AVERAGE_BITRATE) {
|
|
4204
|
+
function enableStereoOpus(sdp, maxBitrate = require_operators.DEFAULT_STEREO_MAX_AVERAGE_BITRATE) {
|
|
4286
4205
|
if (!sdp) return sdp;
|
|
4287
4206
|
const opusPayloadType = findOpusPayloadType(sdp);
|
|
4288
4207
|
if (opusPayloadType === null) return sdp;
|
|
@@ -4378,7 +4297,7 @@ function appendStereoParams(fmtpLine, maxBitrate) {
|
|
|
4378
4297
|
|
|
4379
4298
|
//#endregion
|
|
4380
4299
|
//#region src/controllers/ICEGatheringController.ts
|
|
4381
|
-
const logger$
|
|
4300
|
+
const logger$21 = require_operators.getLogger();
|
|
4382
4301
|
var ICEGatheringController = class extends Destroyable {
|
|
4383
4302
|
constructor(peerConnection, peerConnectionControllerNegotiating$, options = {}) {
|
|
4384
4303
|
super();
|
|
@@ -4386,23 +4305,23 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4386
4305
|
this.peerConnectionControllerNegotiating$ = peerConnectionControllerNegotiating$;
|
|
4387
4306
|
this.onicegatheringstatechangeHandler = () => {
|
|
4388
4307
|
const { iceGatheringState } = this.peerConnection;
|
|
4389
|
-
logger$
|
|
4308
|
+
logger$21.debug(`[ICEGatheringController] ICE gathering state changed to: ${iceGatheringState}`);
|
|
4390
4309
|
if (iceGatheringState === "gathering") this._iceCandidatesState.next({
|
|
4391
4310
|
state: "gathering",
|
|
4392
4311
|
validSDP: false
|
|
4393
4312
|
});
|
|
4394
4313
|
};
|
|
4395
4314
|
this.onicecandidateHandler = (event) => {
|
|
4396
|
-
logger$
|
|
4315
|
+
logger$21.debug("[ICEGatheringController] ICE candidate event received:", event.candidate);
|
|
4397
4316
|
this.removeTimer("iceCandidateTimer");
|
|
4398
4317
|
if (event.candidate) this.iceCandidateTimer = setTimeout(() => {
|
|
4399
4318
|
if (this.peerConnection.iceGatheringState !== "complete") {
|
|
4400
|
-
logger$
|
|
4319
|
+
logger$21.warn("[ICEGatheringController] ICE candidate timeout, using current SDP");
|
|
4401
4320
|
this.handleICECandidateTimeout();
|
|
4402
4321
|
}
|
|
4403
4322
|
}, this.iceCandidateTimeout);
|
|
4404
4323
|
else {
|
|
4405
|
-
logger$
|
|
4324
|
+
logger$21.debug("[ICEGatheringController] ICE gathering completed: null candidate received");
|
|
4406
4325
|
this.removeTimer("iceGatheringTimer");
|
|
4407
4326
|
this.handleICEGatheringComplete();
|
|
4408
4327
|
}
|
|
@@ -4411,8 +4330,8 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4411
4330
|
state: "new",
|
|
4412
4331
|
validSDP: false
|
|
4413
4332
|
});
|
|
4414
|
-
this.iceCandidateTimeout = options.iceCandidateTimeout ?? DEFAULT_ICE_CANDIDATE_TIMEOUT_MS;
|
|
4415
|
-
this.iceGatheringTimeout = options.iceGatheringTimeout ?? DEFAULT_ICE_GATHERING_TIMEOUT_MS;
|
|
4333
|
+
this.iceCandidateTimeout = options.iceCandidateTimeout ?? require_operators.DEFAULT_ICE_CANDIDATE_TIMEOUT_MS;
|
|
4334
|
+
this.iceGatheringTimeout = options.iceGatheringTimeout ?? require_operators.DEFAULT_ICE_GATHERING_TIMEOUT_MS;
|
|
4416
4335
|
this.relayOnly = options.relayOnly ?? false;
|
|
4417
4336
|
this.setupEventListeners();
|
|
4418
4337
|
this.subscribeTo(this.peerConnectionControllerNegotiating$.pipe((0, rxjs.filter)((isNegotiating) => isNegotiating)), (isNegotiating) => {
|
|
@@ -4420,7 +4339,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4420
4339
|
this.setupEventListeners();
|
|
4421
4340
|
this.iceGatheringTimer = setTimeout(() => {
|
|
4422
4341
|
if (this.peerConnection.iceGatheringState !== "complete") {
|
|
4423
|
-
logger$
|
|
4342
|
+
logger$21.warn("[ICEGatheringController] ICE gathering timeout, using current SDP");
|
|
4424
4343
|
this.handleICEGatheringTimeout();
|
|
4425
4344
|
}
|
|
4426
4345
|
}, this.iceGatheringTimeout);
|
|
@@ -4447,9 +4366,9 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4447
4366
|
this.relayOnly = value;
|
|
4448
4367
|
}
|
|
4449
4368
|
handleICEGatheringComplete() {
|
|
4450
|
-
logger$
|
|
4451
|
-
logger$
|
|
4452
|
-
logger$
|
|
4369
|
+
logger$21.debug("[ICEGatheringController] Handling ICE gathering complete");
|
|
4370
|
+
logger$21.debug(`[ICEGatheringController] Checking ICE gathering state: ${this.peerConnection.iceGatheringState}`);
|
|
4371
|
+
logger$21.debug("[ICEGatheringController] ICE gathering complete");
|
|
4453
4372
|
this._iceCandidatesState.next({
|
|
4454
4373
|
state: "complete",
|
|
4455
4374
|
validSDP: this.hasValidLocalDescriptionSDP
|
|
@@ -4465,21 +4384,21 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4465
4384
|
this.removeTimer("iceGatheringTimer");
|
|
4466
4385
|
const validSDP = this.hasValidLocalDescriptionSDP;
|
|
4467
4386
|
if (validSDP) {
|
|
4468
|
-
logger$
|
|
4387
|
+
logger$21.debug("[ICEGatheringController] Local SDP is valid");
|
|
4469
4388
|
this._iceCandidatesState.next({
|
|
4470
4389
|
state: "timeout",
|
|
4471
4390
|
validSDP
|
|
4472
4391
|
});
|
|
4473
4392
|
this.stopGathering();
|
|
4474
|
-
} else logger$
|
|
4393
|
+
} else logger$21.debug("### ICE gathering timeout\n", this.peerConnection.localDescription?.sdp);
|
|
4475
4394
|
}
|
|
4476
4395
|
handleICECandidateTimeout() {
|
|
4477
4396
|
if (this.iceCandidateTimer) this.removeTimer("iceCandidateTimer");
|
|
4478
|
-
logger$
|
|
4397
|
+
logger$21.warn("[ICEGatheringController] ICE candidate timeout");
|
|
4479
4398
|
const validSDP = this.hasValidLocalDescriptionSDP;
|
|
4480
4399
|
if (!validSDP && !this.relayOnly) this.restartICEGatheringWithRelayOnly();
|
|
4481
4400
|
else {
|
|
4482
|
-
logger$
|
|
4401
|
+
logger$21.debug("[ICEGatheringController] Using current SDP due to ICE candidate timeout");
|
|
4483
4402
|
this._iceCandidatesState.next({
|
|
4484
4403
|
state: "timeout",
|
|
4485
4404
|
validSDP
|
|
@@ -4488,7 +4407,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4488
4407
|
}
|
|
4489
4408
|
}
|
|
4490
4409
|
restartICEGatheringWithRelayOnly() {
|
|
4491
|
-
logger$
|
|
4410
|
+
logger$21.debug("[ICEGatheringController] Restarting ICE gathering with relay-only candidates");
|
|
4492
4411
|
this.relayOnly = true;
|
|
4493
4412
|
this.peerConnection.setConfiguration({
|
|
4494
4413
|
...this.peerConnection.getConfiguration(),
|
|
@@ -4503,7 +4422,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4503
4422
|
}
|
|
4504
4423
|
}
|
|
4505
4424
|
clearAllTimers() {
|
|
4506
|
-
logger$
|
|
4425
|
+
logger$21.debug("[ICEGatheringController] Clearing all timers");
|
|
4507
4426
|
this.removeTimer("iceGatheringTimer");
|
|
4508
4427
|
this.removeTimer("iceCandidateTimer");
|
|
4509
4428
|
}
|
|
@@ -4512,7 +4431,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4512
4431
|
this.peerConnection.removeEventListener("icecandidate", this.onicecandidateHandler);
|
|
4513
4432
|
}
|
|
4514
4433
|
destroy() {
|
|
4515
|
-
logger$
|
|
4434
|
+
logger$21.debug("[ICEGatheringController] Destroying ICEGatheringController");
|
|
4516
4435
|
this.clearAllTimers();
|
|
4517
4436
|
this.removeEventListeners();
|
|
4518
4437
|
super.destroy();
|
|
@@ -4521,7 +4440,7 @@ var ICEGatheringController = class extends Destroyable {
|
|
|
4521
4440
|
|
|
4522
4441
|
//#endregion
|
|
4523
4442
|
//#region src/controllers/LocalAudioPipeline.ts
|
|
4524
|
-
const logger$
|
|
4443
|
+
const logger$20 = require_operators.getLogger();
|
|
4525
4444
|
/**
|
|
4526
4445
|
* Web Audio pipeline for the local microphone stream.
|
|
4527
4446
|
*
|
|
@@ -4557,9 +4476,9 @@ var LocalAudioPipeline = class extends Destroyable {
|
|
|
4557
4476
|
this._destination = this._audioContext.createMediaStreamDestination();
|
|
4558
4477
|
this._gainNode.connect(this._analyser);
|
|
4559
4478
|
this._analyser.connect(this._destination);
|
|
4560
|
-
this._speakingThreshold = options.speakingThreshold ?? VAD_THRESHOLD;
|
|
4561
|
-
this._speakingHoldMs = options.speakingHoldMs ?? VAD_HOLD_MS;
|
|
4562
|
-
this._pollIntervalMs = options.pollIntervalMs ?? AUDIO_LEVEL_POLL_INTERVAL_MS;
|
|
4479
|
+
this._speakingThreshold = options.speakingThreshold ?? require_operators.VAD_THRESHOLD;
|
|
4480
|
+
this._speakingHoldMs = options.speakingHoldMs ?? require_operators.VAD_HOLD_MS;
|
|
4481
|
+
this._pollIntervalMs = options.pollIntervalMs ?? require_operators.AUDIO_LEVEL_POLL_INTERVAL_MS;
|
|
4563
4482
|
const initial = options.initialGain ?? 1;
|
|
4564
4483
|
this._gain$.next(initial);
|
|
4565
4484
|
this.applyEffectiveGain();
|
|
@@ -4633,7 +4552,7 @@ var LocalAudioPipeline = class extends Destroyable {
|
|
|
4633
4552
|
try {
|
|
4634
4553
|
this._inputSource.disconnect();
|
|
4635
4554
|
} catch (error) {
|
|
4636
|
-
logger$
|
|
4555
|
+
logger$20.debug("[LocalAudioPipeline] input disconnect warning:", error);
|
|
4637
4556
|
}
|
|
4638
4557
|
this._inputSource = null;
|
|
4639
4558
|
}
|
|
@@ -4643,7 +4562,7 @@ var LocalAudioPipeline = class extends Destroyable {
|
|
|
4643
4562
|
this._inputSource = this._audioContext.createMediaStreamSource(this._inputStream);
|
|
4644
4563
|
this._inputSource.connect(this._gainNode);
|
|
4645
4564
|
if (this._audioContext.state === "suspended") this._audioContext.resume().catch((error) => {
|
|
4646
|
-
logger$
|
|
4565
|
+
logger$20.warn("[LocalAudioPipeline] AudioContext resume failed:", error);
|
|
4647
4566
|
});
|
|
4648
4567
|
}
|
|
4649
4568
|
destroy() {
|
|
@@ -4658,7 +4577,7 @@ var LocalAudioPipeline = class extends Destroyable {
|
|
|
4658
4577
|
this._analyser.disconnect();
|
|
4659
4578
|
} catch {}
|
|
4660
4579
|
this._audioContext.close().catch((error) => {
|
|
4661
|
-
logger$
|
|
4580
|
+
logger$20.debug("[LocalAudioPipeline] audio context close warning:", error);
|
|
4662
4581
|
});
|
|
4663
4582
|
super.destroy();
|
|
4664
4583
|
}
|
|
@@ -4684,7 +4603,7 @@ var LocalAudioPipeline = class extends Destroyable {
|
|
|
4684
4603
|
|
|
4685
4604
|
//#endregion
|
|
4686
4605
|
//#region src/controllers/LocalStreamController.ts
|
|
4687
|
-
const logger$
|
|
4606
|
+
const logger$19 = require_operators.getLogger();
|
|
4688
4607
|
var LocalStreamController = class extends Destroyable {
|
|
4689
4608
|
constructor(options) {
|
|
4690
4609
|
super();
|
|
@@ -4722,26 +4641,26 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4722
4641
|
* Build the local media stream based on the provided options.
|
|
4723
4642
|
*/
|
|
4724
4643
|
async buildLocalStream() {
|
|
4725
|
-
logger$
|
|
4644
|
+
logger$19.debug("[LocalStreamController] Building local media stream.");
|
|
4726
4645
|
let stream;
|
|
4727
4646
|
if (this.options.inputAudioStream ?? this.options.inputVideoStream) {
|
|
4728
4647
|
const tracks = [...this.options.inputAudioStream?.getTracks() ?? [], ...this.options.inputVideoStream?.getTracks() ?? []];
|
|
4729
4648
|
stream = new MediaStream(tracks);
|
|
4730
4649
|
} else if (this.options.propose === "screenshare") {
|
|
4731
|
-
logger$
|
|
4650
|
+
logger$19.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", Boolean(this.options.inputAudioDeviceConstraints));
|
|
4732
4651
|
stream = await this.options.getDisplayMedia({
|
|
4733
4652
|
video: true,
|
|
4734
4653
|
audio: Boolean(this.options.inputAudioDeviceConstraints)
|
|
4735
4654
|
});
|
|
4736
|
-
logger$
|
|
4655
|
+
logger$19.debug("[LocalStreamController] Screen share media obtained:", stream);
|
|
4737
4656
|
} else {
|
|
4738
4657
|
const constraints = {
|
|
4739
4658
|
audio: this.options.inputAudioDeviceConstraints,
|
|
4740
4659
|
video: this.options.inputVideoDeviceConstraints
|
|
4741
4660
|
};
|
|
4742
|
-
logger$
|
|
4661
|
+
logger$19.debug("[LocalStreamController] Requesting user media with constraints:", constraints);
|
|
4743
4662
|
stream = await this.options.getUserMedia(constraints);
|
|
4744
|
-
logger$
|
|
4663
|
+
logger$19.debug("[LocalStreamController] User media obtained:", stream);
|
|
4745
4664
|
}
|
|
4746
4665
|
this._localStream$.next(stream);
|
|
4747
4666
|
this._localAudioTracks$.next(stream.getAudioTracks());
|
|
@@ -4760,7 +4679,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4760
4679
|
this._localStream$.next(localStream);
|
|
4761
4680
|
if (track.kind === "video") this._localVideoTracks$.next(localStream.getVideoTracks());
|
|
4762
4681
|
else this._localAudioTracks$.next(localStream.getAudioTracks());
|
|
4763
|
-
logger$
|
|
4682
|
+
logger$19.debug(`[LocalStreamController] ${track.kind} track added:`, track.id);
|
|
4764
4683
|
return localStream;
|
|
4765
4684
|
}
|
|
4766
4685
|
/**
|
|
@@ -4772,7 +4691,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4772
4691
|
const stream = this._localStream$.value;
|
|
4773
4692
|
const track = stream?.getTracks().find((t) => t.id === trackId);
|
|
4774
4693
|
if (!track) {
|
|
4775
|
-
logger$
|
|
4694
|
+
logger$19.debug(`[LocalStreamController] track not found: ${trackId}`);
|
|
4776
4695
|
return;
|
|
4777
4696
|
}
|
|
4778
4697
|
track.removeEventListener("ended", this.mediaTrackEndedHandler);
|
|
@@ -4781,7 +4700,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4781
4700
|
this._localStream$.next(stream);
|
|
4782
4701
|
if (track.kind === "video") this._localVideoTracks$.next(stream?.getVideoTracks() ?? []);
|
|
4783
4702
|
else this._localAudioTracks$.next(stream?.getAudioTracks() ?? []);
|
|
4784
|
-
logger$
|
|
4703
|
+
logger$19.debug(`[LocalStreamController] ${track.kind} track removed:`, trackId);
|
|
4785
4704
|
return track;
|
|
4786
4705
|
}
|
|
4787
4706
|
/**
|
|
@@ -4816,7 +4735,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4816
4735
|
*/
|
|
4817
4736
|
stopAllTracks() {
|
|
4818
4737
|
this._localStream$.value?.getTracks().forEach((track) => {
|
|
4819
|
-
logger$
|
|
4738
|
+
logger$19.debug(`[LocalStreamController] Stopping local track: ${track.kind}`);
|
|
4820
4739
|
track.removeEventListener("ended", this.mediaTrackEndedHandler);
|
|
4821
4740
|
track.stop();
|
|
4822
4741
|
});
|
|
@@ -4832,7 +4751,7 @@ var LocalStreamController = class extends Destroyable {
|
|
|
4832
4751
|
|
|
4833
4752
|
//#endregion
|
|
4834
4753
|
//#region src/controllers/TransceiverController.ts
|
|
4835
|
-
const logger$
|
|
4754
|
+
const logger$18 = require_operators.getLogger();
|
|
4836
4755
|
const getDirection = (send, recv) => {
|
|
4837
4756
|
if (send && recv) return "sendrecv";
|
|
4838
4757
|
else if (send && !recv) return "sendonly";
|
|
@@ -4940,7 +4859,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
4940
4859
|
sendEncodings: isAudio ? void 0 : this.sendEncodings,
|
|
4941
4860
|
streams: direction === "recvonly" ? void 0 : [localStream]
|
|
4942
4861
|
};
|
|
4943
|
-
logger$
|
|
4862
|
+
logger$18.debug(`[TransceiverController] Setting up transceiver sender for local ${track.kind} track:`, {
|
|
4944
4863
|
transceiver,
|
|
4945
4864
|
transceiverParams
|
|
4946
4865
|
});
|
|
@@ -4948,11 +4867,11 @@ var TransceiverController = class extends Destroyable {
|
|
|
4948
4867
|
await transceiver.sender.replaceTrack(track);
|
|
4949
4868
|
transceiver.direction = transceiverParams.direction;
|
|
4950
4869
|
if (transceiverParams.streams?.some((stream) => Boolean(stream))) {
|
|
4951
|
-
logger$
|
|
4870
|
+
logger$18.debug(`[TransceiverController] Setting streams for transceiver sender for local ${track.kind} track:`, transceiverParams.streams);
|
|
4952
4871
|
transceiver.sender.setStreams(...transceiverParams.streams);
|
|
4953
4872
|
}
|
|
4954
4873
|
} else {
|
|
4955
|
-
logger$
|
|
4874
|
+
logger$18.debug(`[TransceiverController] Adding new transceiver for local ${track.kind} track:`, track.id);
|
|
4956
4875
|
this.peerConnection.addTransceiver(track, transceiverParams);
|
|
4957
4876
|
}
|
|
4958
4877
|
}
|
|
@@ -4966,13 +4885,13 @@ var TransceiverController = class extends Destroyable {
|
|
|
4966
4885
|
if (options.updateTransceiverDirection) transceiver.direction = "inactive";
|
|
4967
4886
|
}
|
|
4968
4887
|
} catch (error) {
|
|
4969
|
-
logger$
|
|
4888
|
+
logger$18.error("[TransceiverController] stopTrackSender error", kind, error);
|
|
4970
4889
|
this.options.onError?.(new require_operators.MediaTrackError("stopTrackSender", kind, error));
|
|
4971
4890
|
}
|
|
4972
4891
|
}
|
|
4973
4892
|
async restoreTrackSender(kind) {
|
|
4974
4893
|
try {
|
|
4975
|
-
logger$
|
|
4894
|
+
logger$18.debug("[TransceiverController] restoreTrackSender called", kind);
|
|
4976
4895
|
const constraints = {};
|
|
4977
4896
|
const transceivers = this.transceiverByKind(kind);
|
|
4978
4897
|
for (const transceiver of transceivers) {
|
|
@@ -4982,23 +4901,23 @@ var TransceiverController = class extends Destroyable {
|
|
|
4982
4901
|
if (trackKind === "audio" || trackKind === "video") constraints[trackKind] = this.getConstraintsFor(trackKind);
|
|
4983
4902
|
}
|
|
4984
4903
|
}
|
|
4985
|
-
logger$
|
|
4904
|
+
logger$18.debug("[TransceiverController] restoreTrackSender constraints:", constraints);
|
|
4986
4905
|
if (Object.keys(constraints).length === 0) {
|
|
4987
|
-
logger$
|
|
4906
|
+
logger$18.warn("[TransceiverController] restoreTrackSender: no tracks need restoration", kind);
|
|
4988
4907
|
return;
|
|
4989
4908
|
}
|
|
4990
4909
|
const newTracks = (await this.options.getUserMedia(constraints)).getTracks();
|
|
4991
|
-
logger$
|
|
4910
|
+
logger$18.debug("[TransceiverController] restoreTrackSender new tracks:", newTracks);
|
|
4992
4911
|
for (const newTrack of newTracks) {
|
|
4993
4912
|
this.options.localStreamController.addTrack(newTrack);
|
|
4994
4913
|
const trackKind = newTrack.kind;
|
|
4995
4914
|
const transceiverOfKind = this.transceiverByKind(trackKind)[0];
|
|
4996
4915
|
transceiverOfKind.direction = trackKind === "audio" ? this.audioDirection : this.videoDirection;
|
|
4997
|
-
logger$
|
|
4916
|
+
logger$18.debug("[TransceiverController] restoreTrackSender setting direction for", trackKind, transceiverOfKind.direction);
|
|
4998
4917
|
await transceiverOfKind.sender.replaceTrack(newTrack);
|
|
4999
4918
|
}
|
|
5000
4919
|
} catch (error) {
|
|
5001
|
-
logger$
|
|
4920
|
+
logger$18.error("[TransceiverController] restoreTrackSender error", kind, error);
|
|
5002
4921
|
this.options.onError?.(new require_operators.MediaTrackError("restoreTrackSender", kind, error));
|
|
5003
4922
|
}
|
|
5004
4923
|
}
|
|
@@ -5039,14 +4958,14 @@ var TransceiverController = class extends Destroyable {
|
|
|
5039
4958
|
};
|
|
5040
4959
|
try {
|
|
5041
4960
|
await track.applyConstraints(constraintsToApply);
|
|
5042
|
-
logger$
|
|
5043
|
-
logger$
|
|
4961
|
+
logger$18.debug(`[TransceiverController] Updated ${kind} sender constraints:`, constraintsToApply);
|
|
4962
|
+
logger$18.debug(`[TransceiverController] Updated ${kind} sender constraints:`, track.getConstraints());
|
|
5044
4963
|
} catch (error) {
|
|
5045
|
-
logger$
|
|
4964
|
+
logger$18.warn(`[TransceiverController] applyConstraints failed for ${kind} track ${track.id}, attempting track replacement fallback:`, error);
|
|
5046
4965
|
try {
|
|
5047
4966
|
await this.replaceTrackFallback(sender, track, kind, constraintsToApply);
|
|
5048
4967
|
} catch (fallbackError) {
|
|
5049
|
-
logger$
|
|
4968
|
+
logger$18.warn(`[TransceiverController] Track replacement fallback also failed for ${kind} track:`, fallbackError);
|
|
5050
4969
|
this.options.onError?.(new require_operators.MediaTrackError("updateSendersConstraints", kind, fallbackError));
|
|
5051
4970
|
}
|
|
5052
4971
|
}
|
|
@@ -5074,7 +4993,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
5074
4993
|
if (!newTrack) throw new require_operators.MediaTrackError("replaceTrackFallback", kind, /* @__PURE__ */ new Error("getUserMedia returned no track of the requested kind"));
|
|
5075
4994
|
await sender.replaceTrack(newTrack);
|
|
5076
4995
|
this.options.localStreamController.addTrack(newTrack);
|
|
5077
|
-
logger$
|
|
4996
|
+
logger$18.debug(`[TransceiverController] Track replacement fallback succeeded for ${kind}. New track: ${newTrack.id}`);
|
|
5078
4997
|
}
|
|
5079
4998
|
getMediaDirections() {
|
|
5080
4999
|
if (this.peerConnection.connectionState === "connected") return this.peerConnection.getTransceivers().reduce((acc, transceiver) => {
|
|
@@ -5104,7 +5023,7 @@ var TransceiverController = class extends Destroyable {
|
|
|
5104
5023
|
|
|
5105
5024
|
//#endregion
|
|
5106
5025
|
//#region src/controllers/RTCPeerConnectionController.ts
|
|
5107
|
-
const logger$
|
|
5026
|
+
const logger$17 = require_operators.getLogger();
|
|
5108
5027
|
var RTCPeerConnectionController = class extends Destroyable {
|
|
5109
5028
|
constructor(options = {}, remoteSessionDescription, deviceController) {
|
|
5110
5029
|
super();
|
|
@@ -5120,43 +5039,43 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5120
5039
|
this.oniceconnectionstatechangeHandler = () => {
|
|
5121
5040
|
if (this.peerConnection) {
|
|
5122
5041
|
const { iceConnectionState } = this.peerConnection;
|
|
5123
|
-
logger$
|
|
5042
|
+
logger$17.debug(`[RTCPeerConnectionController] ICE connection state changed to: ${iceConnectionState}`);
|
|
5124
5043
|
this._iceConnectionState$.next(this.peerConnection.iceConnectionState);
|
|
5125
5044
|
}
|
|
5126
5045
|
};
|
|
5127
5046
|
this.onconnectionstatechangeHandler = () => {
|
|
5128
5047
|
if (this.peerConnection) {
|
|
5129
5048
|
const { connectionState } = this.peerConnection;
|
|
5130
|
-
logger$
|
|
5049
|
+
logger$17.debug(`[RTCPeerConnectionController] Connection state changed to: ${connectionState}`);
|
|
5131
5050
|
if (connectionState === "connected") this.removeConnectionTimer();
|
|
5132
5051
|
this._connectionState$.next(this.peerConnection.connectionState);
|
|
5133
5052
|
}
|
|
5134
5053
|
};
|
|
5135
5054
|
this.onsignalingstatechangeHandler = () => {
|
|
5136
|
-
logger$
|
|
5055
|
+
logger$17.debug(`[RTCPeerConnectionController] Signaling state changed to: ${this.peerConnection?.signalingState}`);
|
|
5137
5056
|
};
|
|
5138
5057
|
this.onicegatheringstatechangeHandler = () => {
|
|
5139
5058
|
if (this.peerConnection) this._iceGatheringState$.next(this.peerConnection.iceGatheringState);
|
|
5140
5059
|
};
|
|
5141
5060
|
this.onnegotiationneededHandler = (event) => {
|
|
5142
|
-
logger$
|
|
5061
|
+
logger$17.debug("[RTCPeerConnectionController] Negotiation needed event received.", event);
|
|
5143
5062
|
this.negotiationNeeded$.next();
|
|
5144
5063
|
};
|
|
5145
5064
|
this.updateSelectedInputDevice = async (kind, deviceInfo) => {
|
|
5146
5065
|
try {
|
|
5147
5066
|
const { localStream } = this;
|
|
5148
5067
|
if (!localStream) {
|
|
5149
|
-
logger$
|
|
5068
|
+
logger$17.warn("[RTCPeerConnectionController] No local stream available to update input device.");
|
|
5150
5069
|
return;
|
|
5151
5070
|
}
|
|
5152
|
-
logger$
|
|
5071
|
+
logger$17.debug(`[RTCPeerConnectionController] Updating selected ${kind} input device:`, localStream.getTracks());
|
|
5153
5072
|
const track = localStream.getTracks().find((track$1) => track$1.kind === kind);
|
|
5154
5073
|
if (track) {
|
|
5155
5074
|
this.transceiverController?.stopTrackSender(kind);
|
|
5156
5075
|
this.localStreamController.removeTrack(track.id);
|
|
5157
|
-
logger$
|
|
5076
|
+
logger$17.debug(`[RTCPeerConnectionController] Stopped existing ${kind} track: ${track.id}`, localStream.getTracks());
|
|
5158
5077
|
if (!deviceInfo) {
|
|
5159
|
-
logger$
|
|
5078
|
+
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected: none`);
|
|
5160
5079
|
return;
|
|
5161
5080
|
}
|
|
5162
5081
|
const streamTrack = (await this.getUserMedia({ [kind]: {
|
|
@@ -5164,16 +5083,16 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5164
5083
|
...this.deviceController.deviceInfoToConstraints(deviceInfo)
|
|
5165
5084
|
} })).getTracks().find((t) => t.kind === kind);
|
|
5166
5085
|
if (streamTrack) {
|
|
5167
|
-
logger$
|
|
5086
|
+
logger$17.debug(`[RTCPeerConnectionController] Adding new ${kind} track: ${streamTrack.id}`);
|
|
5168
5087
|
this.localStreamController.addTrack(streamTrack);
|
|
5169
5088
|
await this.transceiverController?.replaceSenderTrack(kind, streamTrack);
|
|
5170
|
-
logger$
|
|
5089
|
+
logger$17.debug(`[RTCPeerConnectionController] Added new ${kind} track: ${streamTrack.id}`, this.localStream?.getTracks());
|
|
5171
5090
|
}
|
|
5172
5091
|
}
|
|
5173
|
-
logger$
|
|
5092
|
+
logger$17.debug(`[RTCPeerConnectionController] ${kind} input device selected:`, deviceInfo?.label);
|
|
5174
5093
|
} catch (error) {
|
|
5175
|
-
logger$
|
|
5176
|
-
this._errors$.next(
|
|
5094
|
+
logger$17.error(`[RTCPeerConnectionController] Failed to select ${kind} input device:`, error);
|
|
5095
|
+
this._errors$.next(new require_operators.MediaTrackError("updateSelectedInputDevice", kind, error));
|
|
5177
5096
|
throw error;
|
|
5178
5097
|
}
|
|
5179
5098
|
};
|
|
@@ -5395,7 +5314,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5395
5314
|
case "main":
|
|
5396
5315
|
default: return {
|
|
5397
5316
|
...options,
|
|
5398
|
-
offerToReceiveAudio: true,
|
|
5317
|
+
offerToReceiveAudio: this.options.receiveAudio ?? true,
|
|
5399
5318
|
offerToReceiveVideo: this.options.receiveVideo ?? Boolean(this.inputVideoDeviceConstraints)
|
|
5400
5319
|
};
|
|
5401
5320
|
}
|
|
@@ -5422,15 +5341,15 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5422
5341
|
this.setupPeerConnection();
|
|
5423
5342
|
this.subscribeTo(this.negotiationNeeded$.pipe((0, rxjs.auditTime)(0), (0, rxjs.exhaustMap)(async () => this.startNegotiation())), {
|
|
5424
5343
|
next: () => {
|
|
5425
|
-
logger$
|
|
5344
|
+
logger$17.debug("[RTCPeerConnectionController] Start Negotiation completed successfully");
|
|
5426
5345
|
},
|
|
5427
5346
|
error: (error) => {
|
|
5428
|
-
logger$
|
|
5347
|
+
logger$17.error("[RTCPeerConnectionController] Start Negotiation error:", error);
|
|
5429
5348
|
this._errors$.next(toError(error));
|
|
5430
5349
|
}
|
|
5431
5350
|
});
|
|
5432
5351
|
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]) => {
|
|
5433
|
-
logger$
|
|
5352
|
+
logger$17.debug(`[RTCPeerConnectionController] Selected input device changed for:`, {
|
|
5434
5353
|
kind,
|
|
5435
5354
|
deviceInfo
|
|
5436
5355
|
});
|
|
@@ -5447,7 +5366,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5447
5366
|
this._initialized$.next(true);
|
|
5448
5367
|
}
|
|
5449
5368
|
} catch (error) {
|
|
5450
|
-
logger$
|
|
5369
|
+
logger$17.error("[RTCPeerConnectionController] Initialization error:", error);
|
|
5451
5370
|
this._errors$.next(toError(error));
|
|
5452
5371
|
this.destroy();
|
|
5453
5372
|
}
|
|
@@ -5479,22 +5398,22 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5479
5398
|
}
|
|
5480
5399
|
async startNegotiation() {
|
|
5481
5400
|
if (this.isNegotiating) {
|
|
5482
|
-
logger$
|
|
5401
|
+
logger$17.debug("[RTCPeerConnectionController] Negotiation already in progress, skipping.");
|
|
5483
5402
|
return;
|
|
5484
5403
|
}
|
|
5485
5404
|
this.setupEventListeners();
|
|
5486
5405
|
if (this.type === "answer") {
|
|
5487
|
-
logger$
|
|
5406
|
+
logger$17.debug("[RTCPeerConnectionController] This is an answer type still, skipping offer creation.");
|
|
5488
5407
|
return;
|
|
5489
5408
|
}
|
|
5490
5409
|
this._isNegotiating$.next(true);
|
|
5491
|
-
logger$
|
|
5410
|
+
logger$17.debug("[RTCPeerConnectionController] Starting negotiation.");
|
|
5492
5411
|
try {
|
|
5493
5412
|
const { offerOptions } = this;
|
|
5494
|
-
logger$
|
|
5413
|
+
logger$17.debug("[RTCPeerConnectionController] Creating offer with options:", offerOptions);
|
|
5495
5414
|
await this.createOffer(offerOptions);
|
|
5496
5415
|
} catch (error) {
|
|
5497
|
-
logger$
|
|
5416
|
+
logger$17.error("[RTCPeerConnectionController] Error during negotiation:", error);
|
|
5498
5417
|
this._errors$.next(toError(error));
|
|
5499
5418
|
}
|
|
5500
5419
|
}
|
|
@@ -5510,14 +5429,14 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5510
5429
|
let readyToConnect = status !== "failed";
|
|
5511
5430
|
try {
|
|
5512
5431
|
if (status === "received" && sdp) {
|
|
5513
|
-
logger$
|
|
5432
|
+
logger$17.debug("[RTCPeerConnectionController] Received answer SDP:", sdp);
|
|
5514
5433
|
await this._setRemoteDescription({
|
|
5515
5434
|
type: "answer",
|
|
5516
5435
|
sdp
|
|
5517
5436
|
});
|
|
5518
5437
|
}
|
|
5519
5438
|
} catch (error) {
|
|
5520
|
-
logger$
|
|
5439
|
+
logger$17.error("[RTCPeerConnectionController] Error updating answer status:", error);
|
|
5521
5440
|
this._errors$.next(toError(error));
|
|
5522
5441
|
readyToConnect = false;
|
|
5523
5442
|
} finally {
|
|
@@ -5536,7 +5455,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5536
5455
|
await this.handleOfferReceived();
|
|
5537
5456
|
break;
|
|
5538
5457
|
case "failed":
|
|
5539
|
-
logger$
|
|
5458
|
+
logger$17.error("[RTCPeerConnectionController] Offer failed to be processed by remote.");
|
|
5540
5459
|
break;
|
|
5541
5460
|
case "sent":
|
|
5542
5461
|
default:
|
|
@@ -5549,13 +5468,14 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5549
5468
|
*/
|
|
5550
5469
|
async acceptInbound(mediaOverrides) {
|
|
5551
5470
|
if (mediaOverrides) {
|
|
5552
|
-
const { audio, video, receiveAudio, receiveVideo } = mediaOverrides;
|
|
5471
|
+
const { audio, video, receiveAudio, receiveVideo, fallbackToReceiveOnly } = mediaOverrides;
|
|
5553
5472
|
this.options = {
|
|
5554
5473
|
...this.options,
|
|
5555
5474
|
...audio !== void 0 ? { audio } : {},
|
|
5556
5475
|
...video !== void 0 ? { video } : {},
|
|
5557
5476
|
...receiveAudio !== void 0 ? { receiveAudio } : {},
|
|
5558
|
-
...receiveVideo !== void 0 ? { receiveVideo } : {}
|
|
5477
|
+
...receiveVideo !== void 0 ? { receiveVideo } : {},
|
|
5478
|
+
...fallbackToReceiveOnly !== void 0 ? { fallbackToReceiveOnly } : {}
|
|
5559
5479
|
};
|
|
5560
5480
|
this.transceiverController?.updateOptions({
|
|
5561
5481
|
receiveAudio: this.receiveAudio,
|
|
@@ -5568,7 +5488,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5568
5488
|
}
|
|
5569
5489
|
await this.setupLocalTracks();
|
|
5570
5490
|
const { answerOptions } = this;
|
|
5571
|
-
logger$
|
|
5491
|
+
logger$17.debug("[RTCPeerConnectionController] Creating inbound answer with options:", answerOptions);
|
|
5572
5492
|
await this.createAnswer(answerOptions);
|
|
5573
5493
|
}
|
|
5574
5494
|
async handleOfferReceived() {
|
|
@@ -5576,7 +5496,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5576
5496
|
this._isNegotiating$.next(true);
|
|
5577
5497
|
await this._setRemoteDescription(this.sdpInit);
|
|
5578
5498
|
const { answerOptions } = this;
|
|
5579
|
-
logger$
|
|
5499
|
+
logger$17.debug("[RTCPeerConnectionController] Creating answer with options:", answerOptions);
|
|
5580
5500
|
await this.createAnswer(answerOptions);
|
|
5581
5501
|
}
|
|
5582
5502
|
readyToConnect() {
|
|
@@ -5584,7 +5504,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5584
5504
|
this.connectionTimer = setTimeout(() => {
|
|
5585
5505
|
this.removeConnectionTimer();
|
|
5586
5506
|
if (this.peerConnection?.connectionState !== "connected") {
|
|
5587
|
-
logger$
|
|
5507
|
+
logger$17.debug("[RTCPeerConnectionController] Connection timeout, restarting ICE gathering with relay only.");
|
|
5588
5508
|
this.iceGatheringController.restartICEGatheringWithRelayOnly();
|
|
5589
5509
|
}
|
|
5590
5510
|
}, this.connectionTimeout);
|
|
@@ -5606,14 +5526,14 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5606
5526
|
const stereo = this.options.stereo ?? PreferencesContainer.instance.stereoAudio;
|
|
5607
5527
|
if (preferredAudioCodecs.length > 0 || preferredVideoCodecs.length > 0) {
|
|
5608
5528
|
result = setCodecPreferences(result, preferredAudioCodecs, preferredVideoCodecs);
|
|
5609
|
-
logger$
|
|
5529
|
+
logger$17.debug("[RTCPeerConnectionController] Applied codec preferences to SDP", {
|
|
5610
5530
|
preferredAudioCodecs,
|
|
5611
5531
|
preferredVideoCodecs
|
|
5612
5532
|
});
|
|
5613
5533
|
}
|
|
5614
5534
|
if (stereo) {
|
|
5615
5535
|
result = enableStereoOpus(result);
|
|
5616
|
-
logger$
|
|
5536
|
+
logger$17.debug("[RTCPeerConnectionController] Applied stereo Opus to SDP");
|
|
5617
5537
|
}
|
|
5618
5538
|
return Promise.resolve(result);
|
|
5619
5539
|
}
|
|
@@ -5669,25 +5589,25 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5669
5589
|
...this.peerConnection.getConfiguration(),
|
|
5670
5590
|
iceTransportPolicy: "relay"
|
|
5671
5591
|
});
|
|
5672
|
-
logger$
|
|
5592
|
+
logger$17.debug("[RTCPeerConnectionController] ICE transport policy set to relay-only");
|
|
5673
5593
|
} catch (error) {
|
|
5674
|
-
logger$
|
|
5594
|
+
logger$17.warn("[RTCPeerConnectionController] Failed to set relay-only policy:", error);
|
|
5675
5595
|
}
|
|
5676
5596
|
this.setupEventListeners();
|
|
5677
5597
|
this._isNegotiating$.next(true);
|
|
5678
|
-
logger$
|
|
5598
|
+
logger$17.debug(`[RTCPeerConnectionController] Triggering ICE restart${relayOnly ? " (relay-only)" : ""}.`);
|
|
5679
5599
|
try {
|
|
5680
5600
|
const offer = await this.peerConnection.createOffer({ iceRestart: true });
|
|
5681
5601
|
await this.setLocalDescription(offer);
|
|
5682
5602
|
} catch (error) {
|
|
5683
|
-
logger$
|
|
5603
|
+
logger$17.error("[RTCPeerConnectionController] ICE restart offer failed:", error);
|
|
5684
5604
|
this._errors$.next(toError(error));
|
|
5685
5605
|
this.negotiationEnded();
|
|
5686
5606
|
if (policyChanged) this.restoreIceTransportPolicy();
|
|
5687
5607
|
throw error;
|
|
5688
5608
|
}
|
|
5689
|
-
if (policyChanged) (0, rxjs.firstValueFrom)((0, rxjs.race)(this._iceGatheringState$.pipe((0, rxjs.filter)((state) => state === "complete"), (0, rxjs.take)(1)), (0, rxjs.timer)(ICE_GATHERING_COMPLETE_TIMEOUT_MS).pipe((0, rxjs.map)(() => "timeout")))).then(() => this.restoreIceTransportPolicy()).catch((error) => {
|
|
5690
|
-
logger$
|
|
5609
|
+
if (policyChanged) (0, rxjs.firstValueFrom)((0, rxjs.race)(this._iceGatheringState$.pipe((0, rxjs.filter)((state) => state === "complete"), (0, rxjs.take)(1)), (0, rxjs.timer)(require_operators.ICE_GATHERING_COMPLETE_TIMEOUT_MS).pipe((0, rxjs.map)(() => "timeout")))).then(() => this.restoreIceTransportPolicy()).catch((error) => {
|
|
5610
|
+
logger$17.warn("[RTCPeerConnectionController] Error waiting for ICE gathering to complete:", error);
|
|
5691
5611
|
this.restoreIceTransportPolicy();
|
|
5692
5612
|
});
|
|
5693
5613
|
}
|
|
@@ -5697,9 +5617,9 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5697
5617
|
...this.peerConnection.getConfiguration(),
|
|
5698
5618
|
iceTransportPolicy: this.options.relayOnly ? "relay" : "all"
|
|
5699
5619
|
});
|
|
5700
|
-
logger$
|
|
5620
|
+
logger$17.debug("[RTCPeerConnectionController] ICE transport policy restored");
|
|
5701
5621
|
} catch (error) {
|
|
5702
|
-
logger$
|
|
5622
|
+
logger$17.warn("[RTCPeerConnectionController] Failed to restore ICE transport policy:", error);
|
|
5703
5623
|
}
|
|
5704
5624
|
}
|
|
5705
5625
|
/**
|
|
@@ -5711,13 +5631,25 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5711
5631
|
await this.setupRemoteTracks();
|
|
5712
5632
|
}
|
|
5713
5633
|
async setupLocalTracks() {
|
|
5714
|
-
logger$
|
|
5715
|
-
|
|
5634
|
+
logger$17.debug("[RTCPeerConnectionController] Setting up local tracks/transceivers.");
|
|
5635
|
+
if (this.hasNoLocalMediaToSend()) {
|
|
5636
|
+
if (!this.receiveAudio && !this.receiveVideo) throw new require_operators.InvalidParams("Call requests no media: enable audio/video or receiveAudio/receiveVideo");
|
|
5637
|
+
logger$17.debug("[RTCPeerConnectionController] No local media requested; negotiating receive-only.");
|
|
5638
|
+
this.setupReceiveOnlyTransceivers();
|
|
5639
|
+
return;
|
|
5640
|
+
}
|
|
5641
|
+
let localStream;
|
|
5642
|
+
try {
|
|
5643
|
+
localStream = this.localStream ?? await this.localStreamController.buildLocalStream();
|
|
5644
|
+
} catch (error) {
|
|
5645
|
+
this.handleLocalMediaFailure(error);
|
|
5646
|
+
return;
|
|
5647
|
+
}
|
|
5716
5648
|
if (this.transceiverController?.useAddStream ?? false) {
|
|
5717
|
-
logger$
|
|
5649
|
+
logger$17.warn("[RTCPeerConnectionController] Using deprecated addStream API to add local stream.");
|
|
5718
5650
|
this.peerConnection?.addStream(localStream);
|
|
5719
5651
|
if (!this.isNegotiating) {
|
|
5720
|
-
logger$
|
|
5652
|
+
logger$17.debug("[RTCPeerConnectionController] Forcing negotiationneeded after local tracks setup.");
|
|
5721
5653
|
this.negotiationNeeded$.next();
|
|
5722
5654
|
}
|
|
5723
5655
|
return;
|
|
@@ -5733,12 +5665,54 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5733
5665
|
const transceivers = (kind === "audio" ? this.transceiverController?.audioTransceivers : this.transceiverController?.videoTransceivers) ?? [];
|
|
5734
5666
|
await this.transceiverController?.setupTransceiverSender(track, localStream, transceivers[index]);
|
|
5735
5667
|
} else {
|
|
5736
|
-
logger$
|
|
5668
|
+
logger$17.debug(`[RTCPeerConnectionController] Using addTrack for local ${kind} track:`, track.id);
|
|
5737
5669
|
this.peerConnection?.addTrack(track, localStream);
|
|
5738
5670
|
}
|
|
5739
5671
|
}
|
|
5740
5672
|
}
|
|
5741
5673
|
}
|
|
5674
|
+
/** True for a main connection with no local media to send. */
|
|
5675
|
+
hasNoLocalMediaToSend() {
|
|
5676
|
+
const hasInputStreams = Boolean(this.options.inputAudioStream ?? this.options.inputVideoStream);
|
|
5677
|
+
return this.propose === "main" && !this.localStream && !hasInputStreams && !this.inputAudioDeviceConstraints && !this.inputVideoDeviceConstraints;
|
|
5678
|
+
}
|
|
5679
|
+
/** The media kinds this connection wants to send: 'audiovideo' | 'video' | 'audio'. */
|
|
5680
|
+
get requestedMediaKinds() {
|
|
5681
|
+
const wantsAudio = Boolean(this.inputAudioDeviceConstraints);
|
|
5682
|
+
const wantsVideo = Boolean(this.inputVideoDeviceConstraints);
|
|
5683
|
+
if (wantsAudio && wantsVideo) return "audiovideo";
|
|
5684
|
+
return wantsVideo ? "video" : "audio";
|
|
5685
|
+
}
|
|
5686
|
+
/**
|
|
5687
|
+
* Handle a local media acquisition failure with a typed, semantically
|
|
5688
|
+
* accurate MediaAccessError created at the acquisition site:
|
|
5689
|
+
* - Auxiliary connections (screenshare / additional-device) throw a
|
|
5690
|
+
* non-fatal error — VertoManager surfaces it and the call is unaffected.
|
|
5691
|
+
* - The main connection degrades to receive-only when allowed (default),
|
|
5692
|
+
* otherwise fails with a fatal error.
|
|
5693
|
+
*/
|
|
5694
|
+
handleLocalMediaFailure(error) {
|
|
5695
|
+
if (this.propose === "screenshare") throw new require_operators.MediaAccessError("startScreenShare", "screen", error, false);
|
|
5696
|
+
if (this.propose === "additional-device") throw new require_operators.MediaAccessError("addInputDevice", this.requestedMediaKinds, error, false);
|
|
5697
|
+
const canReceive = this.receiveAudio || this.receiveVideo;
|
|
5698
|
+
if (!((this.options.fallbackToReceiveOnly ?? true) && canReceive)) throw new require_operators.MediaAccessError("acquireLocalMedia", this.requestedMediaKinds, error, true);
|
|
5699
|
+
logger$17.warn("[RTCPeerConnectionController] Local media unavailable; continuing receive-only:", error);
|
|
5700
|
+
this._errors$.next(new require_operators.MediaAccessError("acquireLocalMedia", this.requestedMediaKinds, error, false));
|
|
5701
|
+
this.setupReceiveOnlyTransceivers();
|
|
5702
|
+
}
|
|
5703
|
+
/**
|
|
5704
|
+
* Negotiate receive-only m-lines when there are no local tracks to send.
|
|
5705
|
+
* Only offer-type connections add transceivers — answer-type connections
|
|
5706
|
+
* reuse the transceivers created from the remote offer.
|
|
5707
|
+
*/
|
|
5708
|
+
setupReceiveOnlyTransceivers() {
|
|
5709
|
+
if (this.type !== "offer") return;
|
|
5710
|
+
if (this.transceiverController?.useAddTransceivers ?? false) {
|
|
5711
|
+
this.peerConnection?.addTransceiver("audio", { direction: this.receiveAudio ? "recvonly" : "inactive" });
|
|
5712
|
+
this.peerConnection?.addTransceiver("video", { direction: this.receiveVideo ? "recvonly" : "inactive" });
|
|
5713
|
+
}
|
|
5714
|
+
if (!this.isNegotiating) this.negotiationNeeded$.next();
|
|
5715
|
+
}
|
|
5742
5716
|
async getUserMedia(constraints) {
|
|
5743
5717
|
return (this.options.webRTCApiProvider?.mediaDevices ?? navigator.mediaDevices).getUserMedia(constraints);
|
|
5744
5718
|
}
|
|
@@ -5750,7 +5724,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5750
5724
|
async setupRemoteTracks() {
|
|
5751
5725
|
if (!this.peerConnection) throw new require_operators.DependencyError("RTCPeerConnection is not initialized");
|
|
5752
5726
|
this.peerConnection.ontrack = (event) => {
|
|
5753
|
-
logger$
|
|
5727
|
+
logger$17.debug("[RTCPeerConnectionController] Remote track received:", event.track.kind);
|
|
5754
5728
|
if (event.streams[0]) this._remoteStream$.next(event.streams[0]);
|
|
5755
5729
|
else {
|
|
5756
5730
|
const existingTracks = this._remoteStream$.value?.getTracks() ?? [];
|
|
@@ -5774,8 +5748,8 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5774
5748
|
try {
|
|
5775
5749
|
stream = await this.getUserMedia({ audio: constraints });
|
|
5776
5750
|
} catch (error) {
|
|
5777
|
-
logger$
|
|
5778
|
-
this._errors$.next(
|
|
5751
|
+
logger$17.error("[RTCPeerConnectionController] Failed to re-acquire mic for pipeline restore:", error);
|
|
5752
|
+
this._errors$.next(new require_operators.MediaTrackError("restoreAudioPipelineInput", "audio", error));
|
|
5779
5753
|
return;
|
|
5780
5754
|
}
|
|
5781
5755
|
const newTrack = stream.getAudioTracks().at(0);
|
|
@@ -5796,7 +5770,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5796
5770
|
try {
|
|
5797
5771
|
this._localAudioPipeline = new LocalAudioPipeline();
|
|
5798
5772
|
} catch (error) {
|
|
5799
|
-
logger$
|
|
5773
|
+
logger$17.warn("[RTCPeerConnectionController] Failed to create LocalAudioPipeline:", error);
|
|
5800
5774
|
return null;
|
|
5801
5775
|
}
|
|
5802
5776
|
this.subscribeTo(this.localStreamController.localAudioTracks$, () => {
|
|
@@ -5818,7 +5792,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5818
5792
|
try {
|
|
5819
5793
|
await sender.replaceTrack(this._localAudioPipeline.outputTrack);
|
|
5820
5794
|
} catch (error) {
|
|
5821
|
-
logger$
|
|
5795
|
+
logger$17.warn("[RTCPeerConnectionController] Failed to route audio sender through pipeline:", error);
|
|
5822
5796
|
}
|
|
5823
5797
|
}
|
|
5824
5798
|
/**
|
|
@@ -5834,10 +5808,10 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5834
5808
|
try {
|
|
5835
5809
|
const localStream = this.localStreamController.addTrack(track);
|
|
5836
5810
|
this.peerConnection.addTrack(track, localStream);
|
|
5837
|
-
logger$
|
|
5811
|
+
logger$17.debug(`[RTCPeerConnectionController] ${track.kind} track added:`, track.id);
|
|
5838
5812
|
} catch (error) {
|
|
5839
|
-
logger$
|
|
5840
|
-
this._errors$.next(
|
|
5813
|
+
logger$17.error(`[RTCPeerConnectionController] Failed to add ${track.kind} track:`, error);
|
|
5814
|
+
this._errors$.next(new require_operators.MediaTrackError("addLocalTrack", track.kind, error));
|
|
5841
5815
|
throw error;
|
|
5842
5816
|
}
|
|
5843
5817
|
}
|
|
@@ -5853,16 +5827,16 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5853
5827
|
}
|
|
5854
5828
|
const sender = this.peerConnection.getSenders().find((sender$1) => sender$1.track?.id === trackId);
|
|
5855
5829
|
if (!sender) {
|
|
5856
|
-
logger$
|
|
5830
|
+
logger$17.debug(`[RTCPeerConnectionController] track not found: ${trackId}`);
|
|
5857
5831
|
return;
|
|
5858
5832
|
}
|
|
5859
5833
|
try {
|
|
5860
5834
|
this.peerConnection.removeTrack(sender);
|
|
5861
5835
|
this.localStreamController.removeTrack(trackId);
|
|
5862
|
-
logger$
|
|
5836
|
+
logger$17.debug(`[RTCPeerConnectionController] ${sender.track?.kind} track removed:`, trackId);
|
|
5863
5837
|
} catch (error) {
|
|
5864
|
-
logger$
|
|
5865
|
-
this._errors$.next(
|
|
5838
|
+
logger$17.error(`[RTCPeerConnectionController] Failed to remove ${sender.track?.kind} track:`, error);
|
|
5839
|
+
this._errors$.next(new require_operators.MediaTrackError("removeLocalTrack", sender.track?.kind ?? "unknown", error));
|
|
5866
5840
|
throw error;
|
|
5867
5841
|
}
|
|
5868
5842
|
}
|
|
@@ -5888,7 +5862,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5888
5862
|
async replaceAudioTrackWithConstraints(constraints) {
|
|
5889
5863
|
const senders = this.peerConnection?.getSenders().filter((s) => s.track?.kind === "audio" && s.track.readyState === "live");
|
|
5890
5864
|
if (!senders || senders.length === 0) {
|
|
5891
|
-
logger$
|
|
5865
|
+
logger$17.warn("[RTCPeerConnectionController] No live audio sender to replace");
|
|
5892
5866
|
return;
|
|
5893
5867
|
}
|
|
5894
5868
|
for (const sender of senders) {
|
|
@@ -5906,7 +5880,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5906
5880
|
const newTrack = (await this.getUserMedia({ audio: mergedConstraints })).getAudioTracks()[0];
|
|
5907
5881
|
await sender.replaceTrack(newTrack);
|
|
5908
5882
|
this.localStreamController.addTrack(newTrack);
|
|
5909
|
-
logger$
|
|
5883
|
+
logger$17.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
|
|
5910
5884
|
}
|
|
5911
5885
|
}
|
|
5912
5886
|
/**
|
|
@@ -5914,7 +5888,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5914
5888
|
* Completes all observables to prevent memory leaks.
|
|
5915
5889
|
*/
|
|
5916
5890
|
destroy() {
|
|
5917
|
-
logger$
|
|
5891
|
+
logger$17.debug(`[RTCPeerConnectionController] Destroying RTCPeerConnectionController. ${this.propose}`);
|
|
5918
5892
|
this.removeConnectionTimer();
|
|
5919
5893
|
this._iceGatheringController?.destroy();
|
|
5920
5894
|
this._localAudioPipeline?.destroy();
|
|
@@ -5940,7 +5914,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5940
5914
|
}
|
|
5941
5915
|
stopRemoteTracks() {
|
|
5942
5916
|
this._remoteStream$.value?.getTracks().forEach((track) => {
|
|
5943
|
-
logger$
|
|
5917
|
+
logger$17.debug(`[RTCPeerConnectionController] Stopping remote track: ${track.kind}`);
|
|
5944
5918
|
track.stop();
|
|
5945
5919
|
});
|
|
5946
5920
|
}
|
|
@@ -5957,7 +5931,7 @@ var RTCPeerConnectionController = class extends Destroyable {
|
|
|
5957
5931
|
...params,
|
|
5958
5932
|
sdp: finalRemote
|
|
5959
5933
|
};
|
|
5960
|
-
logger$
|
|
5934
|
+
logger$17.debug("[RTCPeerConnectionController] Setting remote description:", answer);
|
|
5961
5935
|
return this.peerConnection.setRemoteDescription(answer);
|
|
5962
5936
|
}
|
|
5963
5937
|
};
|
|
@@ -5972,7 +5946,11 @@ function isVertoInviteMessage(value) {
|
|
|
5972
5946
|
const msg = value;
|
|
5973
5947
|
return msg.method === "verto.invite" && isObject(msg.params) && hasProperty(msg.params, "sdp") && hasProperty(msg.params, "callID");
|
|
5974
5948
|
}
|
|
5975
|
-
|
|
5949
|
+
/**
|
|
5950
|
+
* Guards inbound `verto.bye` frames (server → client). Outbound bye messages are
|
|
5951
|
+
* built locally and never type-guarded, so only the inbound shape is asserted.
|
|
5952
|
+
*/
|
|
5953
|
+
function isVertoByeInboundMessage(value) {
|
|
5976
5954
|
if (!isVertoMethodMessage(value)) return false;
|
|
5977
5955
|
return value.method === "verto.bye";
|
|
5978
5956
|
}
|
|
@@ -5992,10 +5970,18 @@ function isVertoMediaParamsInnerParams(value) {
|
|
|
5992
5970
|
function isVertoPingInnerParams(value) {
|
|
5993
5971
|
return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "method") && value.method === "verto.ping";
|
|
5994
5972
|
}
|
|
5973
|
+
/**
|
|
5974
|
+
* Guards the params of an inbound `verto.bye` frame (top-level `callID`). Use
|
|
5975
|
+
* this to recognise the bye payload extracted by `vertoBye$`, e.g. when racing
|
|
5976
|
+
* it against a boolean answer/reject signal.
|
|
5977
|
+
*/
|
|
5978
|
+
function isVertoByeInboundParamsGuard(value) {
|
|
5979
|
+
return isObject(value) && hasProperty(value, "callID") && typeof value.callID === "string";
|
|
5980
|
+
}
|
|
5995
5981
|
|
|
5996
5982
|
//#endregion
|
|
5997
5983
|
//#region src/managers/VertoManager.ts
|
|
5998
|
-
const logger$
|
|
5984
|
+
const logger$16 = require_operators.getLogger();
|
|
5999
5985
|
/**
|
|
6000
5986
|
* Decide what value goes on the `node_id` field of a `webrtc.verto` envelope.
|
|
6001
5987
|
*
|
|
@@ -6051,7 +6037,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6051
6037
|
try {
|
|
6052
6038
|
await this.executeVerto(vertoModifyMessage);
|
|
6053
6039
|
} catch (error) {
|
|
6054
|
-
logger$
|
|
6040
|
+
logger$16.warn("[WebRTCManager] Call might already be disconnected, error sending Verto hold:", error);
|
|
6055
6041
|
throw error;
|
|
6056
6042
|
}
|
|
6057
6043
|
}
|
|
@@ -6064,7 +6050,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6064
6050
|
try {
|
|
6065
6051
|
await this.executeVerto(vertoModifyMessage);
|
|
6066
6052
|
} catch (error) {
|
|
6067
|
-
logger$
|
|
6053
|
+
logger$16.warn("[WebRTCManager] Call might already be disconnected, error sending Verto unhold:", error);
|
|
6068
6054
|
throw error;
|
|
6069
6055
|
}
|
|
6070
6056
|
}
|
|
@@ -6117,7 +6103,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6117
6103
|
if (event.member_id) this.setSelfIdIfNull(event.member_id);
|
|
6118
6104
|
});
|
|
6119
6105
|
this.subscribeTo(this.vertoMedia$, (event) => {
|
|
6120
|
-
logger$
|
|
6106
|
+
logger$16.debug("[WebRTCManager] Received Verto media event (early media SDP):", event);
|
|
6121
6107
|
const { sdp, callID } = event;
|
|
6122
6108
|
this.emitMainSignalingStatus(callID, "ringing");
|
|
6123
6109
|
this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
|
|
@@ -6126,7 +6112,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6126
6112
|
});
|
|
6127
6113
|
});
|
|
6128
6114
|
this.subscribeTo(this.vertoAnswer$, (event) => {
|
|
6129
|
-
logger$
|
|
6115
|
+
logger$16.debug("[WebRTCManager] Received Verto answer event:", event);
|
|
6130
6116
|
const { sdp, callID } = event;
|
|
6131
6117
|
this.emitMainSignalingStatus(callID, "connecting");
|
|
6132
6118
|
this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
|
|
@@ -6135,7 +6121,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6135
6121
|
});
|
|
6136
6122
|
});
|
|
6137
6123
|
this.subscribeTo(this.vertoMediaParams$, (event) => {
|
|
6138
|
-
logger$
|
|
6124
|
+
logger$16.debug("[WebRTCManager] Received Verto mediaParams event:", event);
|
|
6139
6125
|
const { mediaParams, callID } = event;
|
|
6140
6126
|
const rtcPeerConnController = this._rtcPeerConnectionsMap.get(callID);
|
|
6141
6127
|
const { audio, video } = mediaParams;
|
|
@@ -6149,7 +6135,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6149
6135
|
timestamp: Date.now()
|
|
6150
6136
|
});
|
|
6151
6137
|
} catch (error) {
|
|
6152
|
-
logger$
|
|
6138
|
+
logger$16.warn("[WebRTCManager] Error applying server-pushed media params:", error);
|
|
6153
6139
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6154
6140
|
}
|
|
6155
6141
|
})();
|
|
@@ -6171,13 +6157,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6171
6157
|
*/
|
|
6172
6158
|
setNodeIdIfNull(nodeId) {
|
|
6173
6159
|
if (!this._nodeId$.value && nodeId) {
|
|
6174
|
-
logger$
|
|
6160
|
+
logger$16.debug(`[WebRTCManager] Early node_id set: ${nodeId}`);
|
|
6175
6161
|
this._nodeId$.next(nodeId);
|
|
6176
6162
|
}
|
|
6177
6163
|
}
|
|
6178
6164
|
setSelfIdIfNull(selfId) {
|
|
6179
6165
|
if (!this._selfId$.value && selfId) {
|
|
6180
|
-
logger$
|
|
6166
|
+
logger$16.debug(`[WebRTCManager] Early selfId set: ${selfId}`);
|
|
6181
6167
|
this._selfId$.next(selfId);
|
|
6182
6168
|
}
|
|
6183
6169
|
}
|
|
@@ -6186,7 +6172,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6186
6172
|
const vertoPongMessage = VertoPong({ ...vertoPing });
|
|
6187
6173
|
await this.executeVerto(vertoPongMessage);
|
|
6188
6174
|
} catch (error) {
|
|
6189
|
-
logger$
|
|
6175
|
+
logger$16.warn("[WebRTCManager] Call might disconnect, error sending Verto pong:", error);
|
|
6190
6176
|
this.onError?.(new require_operators.VertoPongError(error));
|
|
6191
6177
|
}
|
|
6192
6178
|
}
|
|
@@ -6196,7 +6182,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6196
6182
|
if (audio) await this.mainPeerConnection.updateSendersConstraints("audio", audio);
|
|
6197
6183
|
if (video) await this.mainPeerConnection.updateSendersConstraints("video", video);
|
|
6198
6184
|
} catch (error) {
|
|
6199
|
-
logger$
|
|
6185
|
+
logger$16.warn("[WebRTCManager] Error updating media constraints:", error);
|
|
6200
6186
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6201
6187
|
throw error;
|
|
6202
6188
|
}
|
|
@@ -6226,20 +6212,20 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6226
6212
|
try {
|
|
6227
6213
|
const pc = this.mainPeerConnection.peerConnection;
|
|
6228
6214
|
if (!pc) {
|
|
6229
|
-
logger$
|
|
6215
|
+
logger$16.warn("[WebRTCManager] No peer connection for keyframe request");
|
|
6230
6216
|
return;
|
|
6231
6217
|
}
|
|
6232
6218
|
const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
|
|
6233
6219
|
if (!videoReceiver) {
|
|
6234
|
-
logger$
|
|
6220
|
+
logger$16.warn("[WebRTCManager] No video receiver for keyframe request");
|
|
6235
6221
|
return;
|
|
6236
6222
|
}
|
|
6237
6223
|
if (typeof videoReceiver.requestKeyFrame === "function") {
|
|
6238
6224
|
videoReceiver.requestKeyFrame();
|
|
6239
|
-
logger$
|
|
6240
|
-
} else logger$
|
|
6225
|
+
logger$16.debug("[WebRTCManager] Keyframe requested via RTCRtpReceiver.requestKeyFrame()");
|
|
6226
|
+
} else logger$16.debug("[WebRTCManager] requestKeyFrame() not supported, skipping");
|
|
6241
6227
|
} catch (error) {
|
|
6242
|
-
logger$
|
|
6228
|
+
logger$16.warn("[WebRTCManager] Keyframe request failed (non-fatal):", error);
|
|
6243
6229
|
}
|
|
6244
6230
|
}
|
|
6245
6231
|
/**
|
|
@@ -6257,13 +6243,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6257
6243
|
try {
|
|
6258
6244
|
const controller = this.mainPeerConnection;
|
|
6259
6245
|
if (!controller.peerConnection) {
|
|
6260
|
-
logger$
|
|
6246
|
+
logger$16.warn("[WebRTCManager] No peer connection for ICE restart");
|
|
6261
6247
|
return;
|
|
6262
6248
|
}
|
|
6263
6249
|
await controller.triggerIceRestart(relayOnly);
|
|
6264
|
-
logger$
|
|
6250
|
+
logger$16.info(`[WebRTCManager] ICE restart initiated${relayOnly ? " (relay-only)" : ""}`);
|
|
6265
6251
|
} catch (error) {
|
|
6266
|
-
logger$
|
|
6252
|
+
logger$16.error("[WebRTCManager] ICE restart failed:", error);
|
|
6267
6253
|
throw error;
|
|
6268
6254
|
}
|
|
6269
6255
|
}
|
|
@@ -6281,13 +6267,13 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6281
6267
|
const entries = Array.from(this._rtcPeerConnectionsMap.entries());
|
|
6282
6268
|
for (const [id, controller] of entries) try {
|
|
6283
6269
|
if (!controller.peerConnection) {
|
|
6284
|
-
logger$
|
|
6270
|
+
logger$16.debug(`[WebRTCManager] No peer connection for leg ${id}, skipping ICE restart`);
|
|
6285
6271
|
continue;
|
|
6286
6272
|
}
|
|
6287
6273
|
await controller.triggerIceRestart(relayOnly);
|
|
6288
|
-
logger$
|
|
6274
|
+
logger$16.info(`[WebRTCManager] ICE restart initiated for leg ${id}${relayOnly ? " (relay-only)" : ""}`);
|
|
6289
6275
|
} catch (error) {
|
|
6290
|
-
logger$
|
|
6276
|
+
logger$16.warn(`[WebRTCManager] ICE restart failed for leg ${id}:`, error);
|
|
6291
6277
|
}
|
|
6292
6278
|
}
|
|
6293
6279
|
/**
|
|
@@ -6299,7 +6285,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6299
6285
|
requestKeyframeAll() {
|
|
6300
6286
|
for (const [id, controller] of this._rtcPeerConnectionsMap) {
|
|
6301
6287
|
if (controller.isScreenShare) {
|
|
6302
|
-
logger$
|
|
6288
|
+
logger$16.debug(`[WebRTCManager] Skipping keyframe for send-only screen share leg ${id}`);
|
|
6303
6289
|
continue;
|
|
6304
6290
|
}
|
|
6305
6291
|
try {
|
|
@@ -6309,10 +6295,10 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6309
6295
|
if (!videoReceiver) continue;
|
|
6310
6296
|
if (typeof videoReceiver.requestKeyFrame === "function") {
|
|
6311
6297
|
videoReceiver.requestKeyFrame();
|
|
6312
|
-
logger$
|
|
6298
|
+
logger$16.debug(`[WebRTCManager] Keyframe requested for leg ${id}`);
|
|
6313
6299
|
}
|
|
6314
6300
|
} catch (error) {
|
|
6315
|
-
logger$
|
|
6301
|
+
logger$16.warn(`[WebRTCManager] Keyframe request failed for leg ${id} (non-fatal):`, error);
|
|
6316
6302
|
}
|
|
6317
6303
|
}
|
|
6318
6304
|
}
|
|
@@ -6329,7 +6315,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6329
6315
|
return this.cachedObservable("vertoMediaParams$", () => this.webRtcCallSession.webrtcMessages$.pipe(require_operators.filterAs(isVertoMediaParamsInnerParams, "params"), (0, rxjs.takeUntil)(this.destroyed$)));
|
|
6330
6316
|
}
|
|
6331
6317
|
get vertoBye$() {
|
|
6332
|
-
return this.cachedObservable("vertoBye$", () => this.webRtcCallSession.webrtcMessages$.pipe(require_operators.filterAs(
|
|
6318
|
+
return this.cachedObservable("vertoBye$", () => this.webRtcCallSession.webrtcMessages$.pipe(require_operators.filterAs(isVertoByeInboundMessage, "params"), (0, rxjs.takeUntil)(this.destroyed$)));
|
|
6333
6319
|
}
|
|
6334
6320
|
get vertoAttach$() {
|
|
6335
6321
|
return this.cachedObservable("vertoAttach$", () => this.webRtcCallSession.webrtcMessages$.pipe(require_operators.filterAs(isVertoAttachMessage, "params"), (0, rxjs.takeUntil)(this.destroyed$)));
|
|
@@ -6373,7 +6359,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6373
6359
|
default:
|
|
6374
6360
|
}
|
|
6375
6361
|
} catch (error) {
|
|
6376
|
-
logger$
|
|
6362
|
+
logger$16.error(`[WebRTCManager] Error sending Verto ${vertoMethod}:`, error);
|
|
6377
6363
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6378
6364
|
if (vertoMethod === "verto.modify") this.onModifyFailed?.();
|
|
6379
6365
|
}
|
|
@@ -6388,7 +6374,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6388
6374
|
sdp
|
|
6389
6375
|
});
|
|
6390
6376
|
} catch (error) {
|
|
6391
|
-
logger$
|
|
6377
|
+
logger$16.warn("[WebRTCManager] Error processing modify response:", error);
|
|
6392
6378
|
const modifyError = error instanceof Error ? error : new Error(String(error), { cause: error });
|
|
6393
6379
|
this.onError?.(modifyError);
|
|
6394
6380
|
}
|
|
@@ -6398,7 +6384,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6398
6384
|
const rtcPeerConnController = this._rtcPeerConnectionsMap.get(callId);
|
|
6399
6385
|
if (!rtcPeerConnController) {
|
|
6400
6386
|
const signalingError = new require_operators.DependencyError(`Cannot emit signaling status, RTCPeerConnectionController not found for callID: ${callId}`);
|
|
6401
|
-
logger$
|
|
6387
|
+
logger$16.error("[WebRTCManager] Failed to emit signaling status:", {
|
|
6402
6388
|
callId,
|
|
6403
6389
|
status,
|
|
6404
6390
|
signalingError
|
|
@@ -6414,7 +6400,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6414
6400
|
this._nodeId$.next(require_operators.getValueFrom(response, "result.node_id") ?? null);
|
|
6415
6401
|
const memberId = require_operators.getValueFrom(response, "result.result.result.memberID") ?? null;
|
|
6416
6402
|
const callId = require_operators.getValueFrom(response, "result.result.result.callID") ?? null;
|
|
6417
|
-
logger$
|
|
6403
|
+
logger$16.debug("[WebRTCManager] Verto invite response:", {
|
|
6418
6404
|
callId,
|
|
6419
6405
|
memberId,
|
|
6420
6406
|
response
|
|
@@ -6424,14 +6410,14 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6424
6410
|
if (callId) {
|
|
6425
6411
|
this.webRtcCallSession.addCallId(callId);
|
|
6426
6412
|
this.attachManager.attach(this.buildAttachableCall(callId));
|
|
6427
|
-
} else logger$
|
|
6413
|
+
} else logger$16.warn("[WebRTCManager] Cannot attach call, missing callId:", {
|
|
6428
6414
|
nodeId: this.nodeId,
|
|
6429
6415
|
callId
|
|
6430
6416
|
});
|
|
6431
|
-
logger$
|
|
6432
|
-
logger$
|
|
6417
|
+
logger$16.info("[WebRTCManager] Verto invite successful");
|
|
6418
|
+
logger$16.debug(`[WebRTCManager] nodeid: ${this._nodeId$.value}, selfId: ${this._selfId$.value}`);
|
|
6433
6419
|
} else {
|
|
6434
|
-
logger$
|
|
6420
|
+
logger$16.error("[WebRTCManager] Verto invite failed:", response);
|
|
6435
6421
|
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");
|
|
6436
6422
|
this.onError?.(inviteError);
|
|
6437
6423
|
}
|
|
@@ -6458,6 +6444,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6458
6444
|
inputVideoStream: options.inputVideoStream,
|
|
6459
6445
|
receiveAudio: options.receiveAudio,
|
|
6460
6446
|
receiveVideo: options.receiveVideo,
|
|
6447
|
+
fallbackToReceiveOnly: options.fallbackToReceiveOnly,
|
|
6461
6448
|
webRTCApiProvider: this.webRTCApiProvider,
|
|
6462
6449
|
preferredVideoCodecs: options.preferredVideoCodecs,
|
|
6463
6450
|
preferredAudioCodecs: options.preferredAudioCodecs,
|
|
@@ -6476,17 +6463,17 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6476
6463
|
if (options.initOffer) this.handleInboundAnswer(rtcPeerConnController);
|
|
6477
6464
|
}
|
|
6478
6465
|
async handleInboundAnswer(rtcPeerConnController) {
|
|
6479
|
-
logger$
|
|
6466
|
+
logger$16.debug("[WebRTCManager] Waiting for inbound call to be accepted or rejected");
|
|
6480
6467
|
const vertoByeOrAccepted = await (0, rxjs.firstValueFrom)((0, rxjs.race)(this.vertoBye$, this.webRtcCallSession.answered$).pipe((0, rxjs.takeUntil)(this.destroyed$))).catch(() => null);
|
|
6481
6468
|
if (vertoByeOrAccepted === null) {
|
|
6482
|
-
logger$
|
|
6469
|
+
logger$16.debug("[WebRTCManager] Inbound answer handler aborted (destroyed).");
|
|
6483
6470
|
return;
|
|
6484
6471
|
}
|
|
6485
|
-
if (
|
|
6486
|
-
logger$
|
|
6472
|
+
if (isVertoByeInboundParamsGuard(vertoByeOrAccepted)) {
|
|
6473
|
+
logger$16.info("[WebRTCManager] Inbound call ended by remote before answer.");
|
|
6487
6474
|
this.callSession?.destroy();
|
|
6488
6475
|
} else if (!vertoByeOrAccepted) {
|
|
6489
|
-
logger$
|
|
6476
|
+
logger$16.info("[WebRTCManager] Inbound call rejected by user.");
|
|
6490
6477
|
try {
|
|
6491
6478
|
await this.bye("USER_BUSY");
|
|
6492
6479
|
} finally {
|
|
@@ -6494,19 +6481,19 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6494
6481
|
this.callSession?.destroy();
|
|
6495
6482
|
}
|
|
6496
6483
|
} else {
|
|
6497
|
-
logger$
|
|
6484
|
+
logger$16.debug("[WebRTCManager] Inbound call accepted, creating SDP answer");
|
|
6498
6485
|
const answerOptions = this.webRtcCallSession.answerMediaOptions;
|
|
6499
6486
|
try {
|
|
6500
6487
|
await rtcPeerConnController.acceptInbound(answerOptions);
|
|
6501
6488
|
} catch (error) {
|
|
6502
|
-
logger$
|
|
6489
|
+
logger$16.error("[WebRTCManager] Error creating inbound answer:", error);
|
|
6503
6490
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6504
6491
|
}
|
|
6505
6492
|
}
|
|
6506
6493
|
}
|
|
6507
6494
|
setupVertoAttachHandler() {
|
|
6508
6495
|
this.subscribeTo(this.vertoAttach$, async (vertoAttach) => {
|
|
6509
|
-
logger$
|
|
6496
|
+
logger$16.debug("[WebRTCManager] Received Verto attach event for existing call:", vertoAttach);
|
|
6510
6497
|
const { callID } = vertoAttach;
|
|
6511
6498
|
await this.attachManager.attach({
|
|
6512
6499
|
nodeId: this.nodeId ?? void 0,
|
|
@@ -6578,17 +6565,17 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6578
6565
|
};
|
|
6579
6566
|
}
|
|
6580
6567
|
async sendLocalDescriptionOnceAccepted(vertoMessageRequest, rtcPeerConnectionController) {
|
|
6581
|
-
logger$
|
|
6568
|
+
logger$16.debug("[WebRTCManager] Waiting for call to be accepted or ended before sending answer");
|
|
6582
6569
|
const vertoByeOrAccepted = await (0, rxjs.firstValueFrom)((0, rxjs.race)(this.vertoBye$, this.webRtcCallSession.answered$).pipe((0, rxjs.takeUntil)(this.destroyed$))).catch(() => null);
|
|
6583
6570
|
if (vertoByeOrAccepted === null) {
|
|
6584
|
-
logger$
|
|
6571
|
+
logger$16.debug("[WebRTCManager] Destroyed while waiting for call acceptance");
|
|
6585
6572
|
return;
|
|
6586
6573
|
}
|
|
6587
|
-
if (
|
|
6588
|
-
logger$
|
|
6574
|
+
if (isVertoByeInboundParamsGuard(vertoByeOrAccepted)) {
|
|
6575
|
+
logger$16.info("[WebRTCManager] Call ended before answer was sent.");
|
|
6589
6576
|
this.callSession?.destroy();
|
|
6590
6577
|
} else if (!vertoByeOrAccepted) {
|
|
6591
|
-
logger$
|
|
6578
|
+
logger$16.info("[WebRTCManager] Call was not accepted, sending verto.bye.");
|
|
6592
6579
|
try {
|
|
6593
6580
|
await this.bye("USER_BUSY");
|
|
6594
6581
|
} finally {
|
|
@@ -6596,14 +6583,14 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6596
6583
|
this.callSession?.destroy();
|
|
6597
6584
|
}
|
|
6598
6585
|
} else {
|
|
6599
|
-
logger$
|
|
6586
|
+
logger$16.debug("[WebRTCManager] Call accepted, sending answer");
|
|
6600
6587
|
try {
|
|
6601
6588
|
this.emitMainSignalingStatus(rtcPeerConnectionController.id, "connecting");
|
|
6602
6589
|
await this.sendLocalDescription(vertoMessageRequest, rtcPeerConnectionController);
|
|
6603
6590
|
await rtcPeerConnectionController.updateAnswerStatus({ status: "sent" });
|
|
6604
6591
|
await this.attachManager.attach(this.buildAttachableCall());
|
|
6605
6592
|
} catch (error) {
|
|
6606
|
-
logger$
|
|
6593
|
+
logger$16.error("[WebRTCManager] Error sending Verto answer:", error);
|
|
6607
6594
|
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6608
6595
|
await rtcPeerConnectionController.updateAnswerStatus({ status: "failed" });
|
|
6609
6596
|
}
|
|
@@ -6629,7 +6616,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6629
6616
|
screenShare: rtcPeerConnectionController.isScreenShare,
|
|
6630
6617
|
additionalDevice: rtcPeerConnectionController.isAdditionalDevice,
|
|
6631
6618
|
pingSupported: true,
|
|
6632
|
-
version: INVITE_VERSION
|
|
6619
|
+
version: require_operators.INVITE_VERSION
|
|
6633
6620
|
};
|
|
6634
6621
|
}
|
|
6635
6622
|
muteMainAudioInputDevice() {
|
|
@@ -6684,9 +6671,11 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6684
6671
|
await this.initAdditionalPeerConnection("screenshare", options);
|
|
6685
6672
|
}
|
|
6686
6673
|
async initAdditionalPeerConnection(propose, options) {
|
|
6674
|
+
const isScreenShare = propose === "screenshare";
|
|
6675
|
+
let firstPeerConnectionError;
|
|
6687
6676
|
let rtcPeerConnController = null;
|
|
6688
6677
|
try {
|
|
6689
|
-
this._screenShareStatus$.next("starting");
|
|
6678
|
+
if (isScreenShare) this._screenShareStatus$.next("starting");
|
|
6690
6679
|
rtcPeerConnController = new RTCPeerConnectionController({
|
|
6691
6680
|
...options,
|
|
6692
6681
|
...this.RTCPeerConnectionConfig,
|
|
@@ -6694,21 +6683,27 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6694
6683
|
webRTCApiProvider: this.webRTCApiProvider
|
|
6695
6684
|
}, void 0, this.deviceController);
|
|
6696
6685
|
this.setupLocalDescriptionHandler(rtcPeerConnController);
|
|
6697
|
-
if (
|
|
6686
|
+
if (isScreenShare) this._screenShareId = rtcPeerConnController.id;
|
|
6698
6687
|
this._rtcPeerConnectionsMap.set(rtcPeerConnController.id, rtcPeerConnController);
|
|
6699
6688
|
this._rtcPeerConnections$.next(Array.from(this._rtcPeerConnectionsMap.values()));
|
|
6700
6689
|
this.subscribeTo(rtcPeerConnController.errors$, (error) => {
|
|
6701
|
-
|
|
6690
|
+
firstPeerConnectionError ??= error;
|
|
6691
|
+
this.onError?.(error, { fatal: false });
|
|
6702
6692
|
});
|
|
6703
6693
|
await (0, rxjs.firstValueFrom)(rtcPeerConnController.connectionState$.pipe((0, rxjs.filter)((state) => state === "connected"), (0, rxjs.take)(1), (0, rxjs.timeout)(this._screenShareTimeoutMs), (0, rxjs.takeUntil)(this.destroyed$)));
|
|
6704
|
-
this._screenShareStatus$.next("started");
|
|
6705
|
-
logger$
|
|
6694
|
+
if (isScreenShare) this._screenShareStatus$.next("started");
|
|
6695
|
+
logger$16.info(`[WebRTCManager] Additional peer connection connected (${propose}).`);
|
|
6706
6696
|
return rtcPeerConnController.id;
|
|
6707
6697
|
} catch (error) {
|
|
6708
|
-
logger$
|
|
6709
|
-
this.onError?.(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
6698
|
+
logger$16.warn("[WebRTCManager] Error initializing additional peer connection:", error);
|
|
6710
6699
|
if (rtcPeerConnController) rtcPeerConnController.destroy();
|
|
6711
|
-
this._screenShareStatus$.next("none");
|
|
6700
|
+
if (isScreenShare) this._screenShareStatus$.next("none");
|
|
6701
|
+
if (firstPeerConnectionError) throw firstPeerConnectionError instanceof require_operators.MediaAccessError && firstPeerConnectionError.originalError instanceof Error ? firstPeerConnectionError.originalError : firstPeerConnectionError;
|
|
6702
|
+
if (error instanceof rxjs.EmptyError) {
|
|
6703
|
+
logger$16.debug("[WebRTCManager] Additional peer connection aborted before connecting.");
|
|
6704
|
+
return;
|
|
6705
|
+
}
|
|
6706
|
+
throw error instanceof Error ? error : new Error(String(error), { cause: error });
|
|
6712
6707
|
}
|
|
6713
6708
|
}
|
|
6714
6709
|
async removeInputDevices(id) {
|
|
@@ -6724,9 +6719,9 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6724
6719
|
if (removeTrack) return this.mainPeerConnection.stopTrackSender(removeTrack, { updateTransceiverDirection: true });
|
|
6725
6720
|
}
|
|
6726
6721
|
async removeScreenMedia() {
|
|
6727
|
-
if (!["starting", "started"].includes(this._screenShareStatus$.value)) logger$
|
|
6722
|
+
if (!["starting", "started"].includes(this._screenShareStatus$.value)) logger$16.warn("[WebRTCManager] No active screen share to stop.");
|
|
6728
6723
|
if (!this._screenShareId) {
|
|
6729
|
-
logger$
|
|
6724
|
+
logger$16.debug("[WebRTCManager] No screen share peer connection found.");
|
|
6730
6725
|
return;
|
|
6731
6726
|
}
|
|
6732
6727
|
this._screenShareStatus$.next("stopping");
|
|
@@ -6755,7 +6750,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6755
6750
|
dialogParams: this.dialogParams(rtcPeerConnController)
|
|
6756
6751
|
}));
|
|
6757
6752
|
} catch (error) {
|
|
6758
|
-
logger$
|
|
6753
|
+
logger$16.warn("[WebRTCManager] Call might already be disconnected, error sending Verto bye:", error);
|
|
6759
6754
|
throw error;
|
|
6760
6755
|
}
|
|
6761
6756
|
}
|
|
@@ -6773,7 +6768,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6773
6768
|
try {
|
|
6774
6769
|
await this.executeVerto(vertoInfoMessage);
|
|
6775
6770
|
} catch (error) {
|
|
6776
|
-
logger$
|
|
6771
|
+
logger$16.warn("[WebRTCManager] Error sending DTMF digits:", error);
|
|
6777
6772
|
throw error;
|
|
6778
6773
|
}
|
|
6779
6774
|
}
|
|
@@ -6784,10 +6779,10 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6784
6779
|
action: "transfer"
|
|
6785
6780
|
});
|
|
6786
6781
|
try {
|
|
6787
|
-
logger$
|
|
6782
|
+
logger$16.debug("[WebRTCManager] Transferring call with options:", options);
|
|
6788
6783
|
await this.executeVerto(message);
|
|
6789
6784
|
} catch (error) {
|
|
6790
|
-
logger$
|
|
6785
|
+
logger$16.error("[WebRTCManager] Error transferring call:", error);
|
|
6791
6786
|
throw error;
|
|
6792
6787
|
}
|
|
6793
6788
|
}
|
|
@@ -6803,7 +6798,7 @@ var WebRTCVertoManager = class extends VertoManager {
|
|
|
6803
6798
|
|
|
6804
6799
|
//#endregion
|
|
6805
6800
|
//#region src/controllers/RemoteAudioMeter.ts
|
|
6806
|
-
const logger$
|
|
6801
|
+
const logger$15 = require_operators.getLogger();
|
|
6807
6802
|
/**
|
|
6808
6803
|
* Read-only audio level meter for a remote MediaStream. Attaches an
|
|
6809
6804
|
* AnalyserNode to a MediaStreamAudioSourceNode so it observes the stream
|
|
@@ -6823,7 +6818,7 @@ var RemoteAudioMeter = class extends Destroyable {
|
|
|
6823
6818
|
this._analyser.fftSize = 2048;
|
|
6824
6819
|
this._analyser.smoothingTimeConstant = .3;
|
|
6825
6820
|
this._analyserBuffer = new Uint8Array(new ArrayBuffer(this._analyser.fftSize));
|
|
6826
|
-
this._pollIntervalMs = options.pollIntervalMs ?? AUDIO_LEVEL_POLL_INTERVAL_MS;
|
|
6821
|
+
this._pollIntervalMs = options.pollIntervalMs ?? require_operators.AUDIO_LEVEL_POLL_INTERVAL_MS;
|
|
6827
6822
|
}
|
|
6828
6823
|
/** RMS level of the remote audio, 0..1. 0 when no stream is attached. */
|
|
6829
6824
|
get level$() {
|
|
@@ -6838,7 +6833,7 @@ var RemoteAudioMeter = class extends Destroyable {
|
|
|
6838
6833
|
try {
|
|
6839
6834
|
this._source.disconnect();
|
|
6840
6835
|
} catch (error) {
|
|
6841
|
-
logger$
|
|
6836
|
+
logger$15.debug("[RemoteAudioMeter] source disconnect warning:", error);
|
|
6842
6837
|
}
|
|
6843
6838
|
this._source = null;
|
|
6844
6839
|
this._stream = null;
|
|
@@ -6855,7 +6850,7 @@ var RemoteAudioMeter = class extends Destroyable {
|
|
|
6855
6850
|
this._source = null;
|
|
6856
6851
|
}
|
|
6857
6852
|
this._audioContext.close().catch((error) => {
|
|
6858
|
-
logger$
|
|
6853
|
+
logger$15.debug("[RemoteAudioMeter] audio context close warning:", error);
|
|
6859
6854
|
});
|
|
6860
6855
|
super.destroy();
|
|
6861
6856
|
}
|
|
@@ -6879,7 +6874,7 @@ var RemoteAudioMeter = class extends Destroyable {
|
|
|
6879
6874
|
*
|
|
6880
6875
|
* Extends Destroyable for automatic RxJS cleanup.
|
|
6881
6876
|
*/
|
|
6882
|
-
const logger$
|
|
6877
|
+
const logger$14 = require_operators.getLogger();
|
|
6883
6878
|
const DEFAULT_POLLING_INTERVAL_MS = 1e3;
|
|
6884
6879
|
const DEFAULT_BASELINE_SAMPLES = 10;
|
|
6885
6880
|
const DEFAULT_NO_AUDIO_PACKET_THRESHOLD_MS = 2e3;
|
|
@@ -6969,9 +6964,9 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
6969
6964
|
const now = Date.now();
|
|
6970
6965
|
this.lastAudioPacketChangeTime = now;
|
|
6971
6966
|
this.lastVideoPacketChangeTime = now;
|
|
6972
|
-
logger$
|
|
6967
|
+
logger$14.debug("[RTCStatsMonitor] Starting stats monitoring");
|
|
6973
6968
|
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) => {
|
|
6974
|
-
logger$
|
|
6969
|
+
logger$14.warn("[RTCStatsMonitor] Failed to get stats:", err);
|
|
6975
6970
|
return rxjs.EMPTY;
|
|
6976
6971
|
}))), (0, rxjs.filter)(() => this.running), (0, rxjs.map)((report) => this.extractSample(report))), (sample) => this._sample$.next(sample));
|
|
6977
6972
|
this.subscribeTo(this._sample$.pipe((0, rxjs.take)(this.baselineSampleCount), (0, rxjs.toArray)(), (0, rxjs.map)((samples) => ({
|
|
@@ -6979,7 +6974,7 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
6979
6974
|
jitter: samples.reduce((s, b) => s + b.audioJitter, 0) / samples.length,
|
|
6980
6975
|
ready: true
|
|
6981
6976
|
}))), (baseline) => {
|
|
6982
|
-
logger$
|
|
6977
|
+
logger$14.debug(`[RTCStatsMonitor] Baseline established: rtt=${baseline.rtt.toFixed(1)}ms, jitter=${baseline.jitter.toFixed(1)}ms`);
|
|
6983
6978
|
this._baseline$.next(baseline);
|
|
6984
6979
|
});
|
|
6985
6980
|
this.subscribeTo(this._sample$.pipe((0, rxjs.scan)((acc, sample) => ({
|
|
@@ -7016,10 +7011,10 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
7016
7011
|
stop() {
|
|
7017
7012
|
if (!this.running) return;
|
|
7018
7013
|
this.running = false;
|
|
7019
|
-
logger$
|
|
7014
|
+
logger$14.debug("[RTCStatsMonitor] Stopping stats monitoring");
|
|
7020
7015
|
}
|
|
7021
7016
|
destroy() {
|
|
7022
|
-
logger$
|
|
7017
|
+
logger$14.debug("[RTCStatsMonitor] Destroying RTCStatsMonitor");
|
|
7023
7018
|
this.stop();
|
|
7024
7019
|
super.destroy();
|
|
7025
7020
|
}
|
|
@@ -7147,7 +7142,7 @@ var RTCStatsMonitor = class extends Destroyable {
|
|
|
7147
7142
|
|
|
7148
7143
|
//#endregion
|
|
7149
7144
|
//#region src/managers/CallRecoveryManager.ts
|
|
7150
|
-
const logger$
|
|
7145
|
+
const logger$13 = require_operators.getLogger();
|
|
7151
7146
|
const DEFAULT_DEBOUNCE_TIME_MS = 2e3;
|
|
7152
7147
|
const DEFAULT_COOLDOWN_MS = 1e4;
|
|
7153
7148
|
const DEFAULT_ICE_GRACE_PERIOD_MS = 3e3;
|
|
@@ -7244,10 +7239,10 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7244
7239
|
*/
|
|
7245
7240
|
async requestIceRestart() {
|
|
7246
7241
|
if (this._recoveryState$.value === "recovering") {
|
|
7247
|
-
logger$
|
|
7242
|
+
logger$13.info("CallRecoveryManager: manual ICE restart skipped — recovery already in progress");
|
|
7248
7243
|
return;
|
|
7249
7244
|
}
|
|
7250
|
-
logger$
|
|
7245
|
+
logger$13.info("CallRecoveryManager: manual ICE restart requested");
|
|
7251
7246
|
this.transitionTo("recovering");
|
|
7252
7247
|
await this.executeIceRestart(false);
|
|
7253
7248
|
this.startCooldown();
|
|
@@ -7263,7 +7258,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7263
7258
|
* WebSocket reconnect or call state recovers to 'connected'.
|
|
7264
7259
|
*/
|
|
7265
7260
|
reset() {
|
|
7266
|
-
logger$
|
|
7261
|
+
logger$13.info("CallRecoveryManager: resetting counters");
|
|
7267
7262
|
this._attemptCount = 0;
|
|
7268
7263
|
this._keyframeBurstCount = 0;
|
|
7269
7264
|
this._keyframeBurstStart = 0;
|
|
@@ -7278,7 +7273,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7278
7273
|
*/
|
|
7279
7274
|
notifyModifyFailed() {
|
|
7280
7275
|
if (this._recoveryState$.value === "cooldown" || this._recoveryState$.value === "idle") {
|
|
7281
|
-
logger$
|
|
7276
|
+
logger$13.info("CallRecoveryManager: verto.modify failed — re-entering recovery");
|
|
7282
7277
|
this._cooldownUntil = 0;
|
|
7283
7278
|
this.transitionTo("idle");
|
|
7284
7279
|
this.pushTrigger({
|
|
@@ -7302,7 +7297,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7302
7297
|
reason: `bandwidth ${bitrateKbps}kbps below threshold ${this._config.degradationBitrateThreshold}kbps`,
|
|
7303
7298
|
timestamp: Date.now()
|
|
7304
7299
|
});
|
|
7305
|
-
logger$
|
|
7300
|
+
logger$13.warn(`CallRecoveryManager: disabling video — bandwidth ${bitrateKbps}kbps < ${this._config.degradationBitrateThreshold}kbps`);
|
|
7306
7301
|
} else if (wasConstrained && bitrateKbps >= this._config.degradationRecoveryThreshold) {
|
|
7307
7302
|
this._bandwidthConstrained$.next(false);
|
|
7308
7303
|
this._callbacks.enableVideo();
|
|
@@ -7311,7 +7306,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7311
7306
|
reason: `bandwidth ${bitrateKbps}kbps recovered above ${this._config.degradationRecoveryThreshold}kbps`,
|
|
7312
7307
|
timestamp: Date.now()
|
|
7313
7308
|
});
|
|
7314
|
-
logger$
|
|
7309
|
+
logger$13.info(`CallRecoveryManager: restoring video — bandwidth ${bitrateKbps}kbps >= ${this._config.degradationRecoveryThreshold}kbps`);
|
|
7315
7310
|
}
|
|
7316
7311
|
}
|
|
7317
7312
|
/**
|
|
@@ -7330,14 +7325,14 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7330
7325
|
handleWebSocketReconnect() {
|
|
7331
7326
|
const pcState = this._callbacks.getPeerConnectionState();
|
|
7332
7327
|
if (pcState === "connected" || pcState === "completed") {
|
|
7333
|
-
logger$
|
|
7328
|
+
logger$13.info("CallRecoveryManager: signal-only reconnect — peer connection still alive");
|
|
7334
7329
|
this.emitEvent({
|
|
7335
7330
|
action: "signal_reconnect",
|
|
7336
7331
|
reason: "WebSocket reconnected, peer connection still connected",
|
|
7337
7332
|
timestamp: Date.now()
|
|
7338
7333
|
});
|
|
7339
7334
|
} else {
|
|
7340
|
-
logger$
|
|
7335
|
+
logger$13.info("CallRecoveryManager: full reconnect — peer connection also down");
|
|
7341
7336
|
this.emitEvent({
|
|
7342
7337
|
action: "full_reconnect",
|
|
7343
7338
|
reason: "WebSocket reconnected, peer connection not connected — ICE restart needed",
|
|
@@ -7361,7 +7356,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7361
7356
|
}), (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$))), {
|
|
7362
7357
|
next: () => {},
|
|
7363
7358
|
error: (err) => {
|
|
7364
|
-
logger$
|
|
7359
|
+
logger$13.error("CallRecoveryManager: pipeline error", err);
|
|
7365
7360
|
this.transitionTo("idle");
|
|
7366
7361
|
}
|
|
7367
7362
|
});
|
|
@@ -7388,27 +7383,27 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7388
7383
|
reason: `no packet loss for ${this._config.packetLossRecoveryDelaySec}s — restoring video`,
|
|
7389
7384
|
timestamp: Date.now()
|
|
7390
7385
|
});
|
|
7391
|
-
logger$
|
|
7386
|
+
logger$13.info(`CallRecoveryManager: restoring video — no packet loss for ${this._config.packetLossRecoveryDelaySec}s`);
|
|
7392
7387
|
});
|
|
7393
7388
|
}
|
|
7394
7389
|
passGateChecks(signalingReady) {
|
|
7395
7390
|
if (this._callbacks.isNegotiating()) {
|
|
7396
|
-
logger$
|
|
7391
|
+
logger$13.debug("CallRecoveryManager: gate blocked — negotiation in progress");
|
|
7397
7392
|
this.transitionTo("idle");
|
|
7398
7393
|
return false;
|
|
7399
7394
|
}
|
|
7400
7395
|
if (!signalingReady) {
|
|
7401
|
-
logger$
|
|
7396
|
+
logger$13.debug("CallRecoveryManager: gate blocked — signaling not ready");
|
|
7402
7397
|
this.transitionTo("idle");
|
|
7403
7398
|
return false;
|
|
7404
7399
|
}
|
|
7405
7400
|
if (!this._callbacks.isCallConnected()) {
|
|
7406
|
-
logger$
|
|
7401
|
+
logger$13.debug("CallRecoveryManager: gate blocked — call not connected");
|
|
7407
7402
|
this.transitionTo("idle");
|
|
7408
7403
|
return false;
|
|
7409
7404
|
}
|
|
7410
7405
|
if (this.isCooldownActive()) {
|
|
7411
|
-
logger$
|
|
7406
|
+
logger$13.debug("CallRecoveryManager: gate blocked — cooldown active");
|
|
7412
7407
|
this.transitionTo("cooldown");
|
|
7413
7408
|
return false;
|
|
7414
7409
|
}
|
|
@@ -7419,9 +7414,9 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7419
7414
|
}
|
|
7420
7415
|
executeTieredRecovery(trigger) {
|
|
7421
7416
|
this.transitionTo("recovering");
|
|
7422
|
-
logger$
|
|
7417
|
+
logger$13.info(`CallRecoveryManager: starting tiered recovery — source=${trigger.source} detail=${trigger.detail}`);
|
|
7423
7418
|
return (0, rxjs.from)(this.runTiers(trigger)).pipe((0, rxjs.tap)(() => this.startCooldown()), (0, rxjs.catchError)((err) => {
|
|
7424
|
-
logger$
|
|
7419
|
+
logger$13.error("CallRecoveryManager: tiered recovery failed", err);
|
|
7425
7420
|
this.startCooldown();
|
|
7426
7421
|
return rxjs.EMPTY;
|
|
7427
7422
|
}));
|
|
@@ -7429,7 +7424,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7429
7424
|
async runTiers(trigger) {
|
|
7430
7425
|
this.executeKeyframe(trigger.detail);
|
|
7431
7426
|
if (trigger.issueType && DEGRADATION_ONLY_ISSUES.has(trigger.issueType)) {
|
|
7432
|
-
logger$
|
|
7427
|
+
logger$13.debug(`CallRecoveryManager: degradation-only issue (${trigger.issueType}) — Tier 1 only, skipping ICE restart`);
|
|
7433
7428
|
return;
|
|
7434
7429
|
}
|
|
7435
7430
|
if (this._attemptCount < this._config.maxAttempts) {
|
|
@@ -7446,13 +7441,13 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7446
7441
|
maxAttempts: this._config.maxAttempts,
|
|
7447
7442
|
timestamp: Date.now()
|
|
7448
7443
|
});
|
|
7449
|
-
logger$
|
|
7444
|
+
logger$13.warn("CallRecoveryManager: max recovery attempts reached");
|
|
7450
7445
|
}
|
|
7451
7446
|
}
|
|
7452
7447
|
executeKeyframe(reason) {
|
|
7453
7448
|
const now = Date.now();
|
|
7454
7449
|
if (now < this._keyframeCooldownUntil) {
|
|
7455
|
-
logger$
|
|
7450
|
+
logger$13.debug("CallRecoveryManager: keyframe request skipped — cooldown active");
|
|
7456
7451
|
return;
|
|
7457
7452
|
}
|
|
7458
7453
|
if (now - this._keyframeBurstStart > this._config.keyframeBurstWindowMs) {
|
|
@@ -7461,7 +7456,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7461
7456
|
}
|
|
7462
7457
|
if (this._keyframeBurstCount >= this._config.keyframeMaxBurst) {
|
|
7463
7458
|
this._keyframeCooldownUntil = now + this._config.keyframeCooldownMs;
|
|
7464
|
-
logger$
|
|
7459
|
+
logger$13.debug(`CallRecoveryManager: keyframe burst limit reached (${this._config.keyframeMaxBurst}), cooldown until ${this._keyframeCooldownUntil}`);
|
|
7465
7460
|
return;
|
|
7466
7461
|
}
|
|
7467
7462
|
this._keyframeBurstCount += 1;
|
|
@@ -7471,12 +7466,12 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7471
7466
|
reason,
|
|
7472
7467
|
timestamp: now
|
|
7473
7468
|
});
|
|
7474
|
-
logger$
|
|
7469
|
+
logger$13.debug(`CallRecoveryManager: keyframe requested (burst ${this._keyframeBurstCount}/${this._config.keyframeMaxBurst})`);
|
|
7475
7470
|
}
|
|
7476
7471
|
async executeIceRestart(relayOnly) {
|
|
7477
7472
|
this._attemptCount += 1;
|
|
7478
7473
|
const tier = relayOnly ? "Tier 3 (relay-only)" : "Tier 2 (standard)";
|
|
7479
|
-
logger$
|
|
7474
|
+
logger$13.info(`CallRecoveryManager: ${tier} ICE restart — attempt ${this._attemptCount}/${this._config.maxAttempts}`);
|
|
7480
7475
|
this.emitEvent({
|
|
7481
7476
|
action: "reinvite_started",
|
|
7482
7477
|
reason: `${tier} ICE restart`,
|
|
@@ -7493,7 +7488,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7493
7488
|
maxAttempts: this._config.maxAttempts,
|
|
7494
7489
|
timestamp: Date.now()
|
|
7495
7490
|
});
|
|
7496
|
-
logger$
|
|
7491
|
+
logger$13.info(`CallRecoveryManager: ${tier} ICE restart succeeded`);
|
|
7497
7492
|
this._attemptCount = 0;
|
|
7498
7493
|
return true;
|
|
7499
7494
|
}
|
|
@@ -7504,7 +7499,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7504
7499
|
maxAttempts: this._config.maxAttempts,
|
|
7505
7500
|
timestamp: Date.now()
|
|
7506
7501
|
});
|
|
7507
|
-
logger$
|
|
7502
|
+
logger$13.warn(`CallRecoveryManager: ${tier} ICE restart failed`);
|
|
7508
7503
|
return false;
|
|
7509
7504
|
} catch {
|
|
7510
7505
|
this.emitEvent({
|
|
@@ -7514,7 +7509,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7514
7509
|
maxAttempts: this._config.maxAttempts,
|
|
7515
7510
|
timestamp: Date.now()
|
|
7516
7511
|
});
|
|
7517
|
-
logger$
|
|
7512
|
+
logger$13.warn(`CallRecoveryManager: ${tier} ICE restart timed out`);
|
|
7518
7513
|
return false;
|
|
7519
7514
|
}
|
|
7520
7515
|
}
|
|
@@ -7535,7 +7530,7 @@ var CallRecoveryManager = class extends Destroyable {
|
|
|
7535
7530
|
transitionTo(state) {
|
|
7536
7531
|
const prev = this._recoveryState$.value;
|
|
7537
7532
|
if (prev !== state) {
|
|
7538
|
-
logger$
|
|
7533
|
+
logger$13.debug(`CallRecoveryManager: state ${prev} -> ${state}`);
|
|
7539
7534
|
this._recoveryState$.next(state);
|
|
7540
7535
|
}
|
|
7541
7536
|
}
|
|
@@ -7637,7 +7632,13 @@ function mosToQualityLevel(mos) {
|
|
|
7637
7632
|
|
|
7638
7633
|
//#endregion
|
|
7639
7634
|
//#region src/core/entities/Call.ts
|
|
7640
|
-
const logger$
|
|
7635
|
+
const logger$12 = require_operators.getLogger();
|
|
7636
|
+
/**
|
|
7637
|
+
* Verto method for setting member layout positions. Its gateway DTO requires a
|
|
7638
|
+
* `targets` array whose entries are `{ target, position }` (NOT bare targets),
|
|
7639
|
+
* so {@link WebRTCCall.buildMethodParams} special-cases it. See issue #19400.
|
|
7640
|
+
*/
|
|
7641
|
+
const POSITION_SET_METHOD = "call.member.position.set";
|
|
7641
7642
|
/**
|
|
7642
7643
|
* Ratio between the critical and warning RTT spike multipliers.
|
|
7643
7644
|
* Warning threshold = baseline * warningMultiplier (default 3x)
|
|
@@ -7655,7 +7656,7 @@ const fromDestinationParams = (destination) => {
|
|
|
7655
7656
|
});
|
|
7656
7657
|
return params;
|
|
7657
7658
|
} catch (error) {
|
|
7658
|
-
logger$
|
|
7659
|
+
logger$12.warn(`Failed to parse destination URI: ${destination}`, error);
|
|
7659
7660
|
return {};
|
|
7660
7661
|
}
|
|
7661
7662
|
};
|
|
@@ -7845,7 +7846,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7845
7846
|
* @throws {JSONRPCError} If the RPC call returns an error.
|
|
7846
7847
|
*/
|
|
7847
7848
|
async executeMethod(target, method, args) {
|
|
7848
|
-
const params = this.buildMethodParams(target, args);
|
|
7849
|
+
const params = this.buildMethodParams(target, args, method);
|
|
7849
7850
|
const request = buildRPCRequest({
|
|
7850
7851
|
method,
|
|
7851
7852
|
params
|
|
@@ -7855,16 +7856,20 @@ var WebRTCCall = class extends Destroyable {
|
|
|
7855
7856
|
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);
|
|
7856
7857
|
return response;
|
|
7857
7858
|
} catch (error) {
|
|
7858
|
-
logger$
|
|
7859
|
+
logger$12.error(`[Call] Error executing method ${method} with params`, params, error);
|
|
7859
7860
|
throw error;
|
|
7860
7861
|
}
|
|
7861
7862
|
}
|
|
7862
|
-
buildMethodParams(target, args) {
|
|
7863
|
+
buildMethodParams(target, args, method) {
|
|
7863
7864
|
const self = {
|
|
7864
7865
|
node_id: this.nodeId ?? "",
|
|
7865
7866
|
call_id: this.id,
|
|
7866
7867
|
member_id: this.vertoManager.selfId ?? ""
|
|
7867
7868
|
};
|
|
7869
|
+
if (method === POSITION_SET_METHOD) return {
|
|
7870
|
+
...args,
|
|
7871
|
+
self
|
|
7872
|
+
};
|
|
7868
7873
|
if (typeof target === "object") return {
|
|
7869
7874
|
...args,
|
|
7870
7875
|
self,
|
|
@@ -8058,9 +8063,9 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8058
8063
|
*/
|
|
8059
8064
|
initResilienceSubsystems() {
|
|
8060
8065
|
const pc = this.rtcPeerConnection;
|
|
8061
|
-
logger$
|
|
8066
|
+
logger$12.debug(`[Call] initResilienceSubsystems: pc=${pc ? "exists" : "undefined"}, connectionState=${pc?.connectionState}`);
|
|
8062
8067
|
if (!pc) {
|
|
8063
|
-
logger$
|
|
8068
|
+
logger$12.warn("[Call] No peer connection available, skipping resilience init");
|
|
8064
8069
|
return;
|
|
8065
8070
|
}
|
|
8066
8071
|
try {
|
|
@@ -8095,14 +8100,14 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8095
8100
|
disableVideo: () => {
|
|
8096
8101
|
try {
|
|
8097
8102
|
this.vertoManager.muteMainVideoInputDevice();
|
|
8098
|
-
logger$
|
|
8103
|
+
logger$12.debug("[Call] Recovery manager disabled video");
|
|
8099
8104
|
} catch {
|
|
8100
|
-
logger$
|
|
8105
|
+
logger$12.debug("[Call] Recovery manager failed to disable video");
|
|
8101
8106
|
}
|
|
8102
8107
|
},
|
|
8103
8108
|
enableVideo: () => {
|
|
8104
8109
|
this.vertoManager.unmuteMainVideoInputDevice().catch(() => {
|
|
8105
|
-
logger$
|
|
8110
|
+
logger$12.debug("[Call] Recovery manager failed to enable video");
|
|
8106
8111
|
});
|
|
8107
8112
|
},
|
|
8108
8113
|
isNegotiating: () => this.vertoManager.mainPeerConnection.isNegotiating,
|
|
@@ -8152,7 +8157,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8152
8157
|
this.subscribeTo(this._recoveryManager.recoveryEvent$, (event) => {
|
|
8153
8158
|
this._recoveryEvent$.next(event);
|
|
8154
8159
|
if (event.action === "max_attempts_reached") {
|
|
8155
|
-
logger$
|
|
8160
|
+
logger$12.warn("[Call] All recovery attempts exhausted, terminating call");
|
|
8156
8161
|
this.emitError({
|
|
8157
8162
|
kind: "network",
|
|
8158
8163
|
fatal: true,
|
|
@@ -8172,13 +8177,13 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8172
8177
|
else if (event.type === "online") this._recoveryManager?.handleWebSocketReconnect();
|
|
8173
8178
|
});
|
|
8174
8179
|
this.subscribeTo(this.clientSession.authenticated$.pipe((0, rxjs.skip)(1), (0, rxjs.filter)(Boolean)), () => {
|
|
8175
|
-
logger$
|
|
8180
|
+
logger$12.debug("[Call] WebSocket reconnected — notifying recovery manager");
|
|
8176
8181
|
this._recoveryManager?.handleWebSocketReconnect();
|
|
8177
8182
|
});
|
|
8178
8183
|
this._statsMonitor.start();
|
|
8179
|
-
logger$
|
|
8184
|
+
logger$12.debug("[Call] Resilience subsystems initialized for call", this.id);
|
|
8180
8185
|
} catch (error) {
|
|
8181
|
-
logger$
|
|
8186
|
+
logger$12.warn("[Call] Failed to initialize resilience subsystems:", error);
|
|
8182
8187
|
}
|
|
8183
8188
|
}
|
|
8184
8189
|
/**
|
|
@@ -8193,13 +8198,13 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8193
8198
|
async waitForPeerConnectionConnected() {
|
|
8194
8199
|
const pc = this.rtcPeerConnection;
|
|
8195
8200
|
if (!pc) return false;
|
|
8196
|
-
const deadline = Date.now() + PEER_CONNECTION_RECOVERY_WAIT_MS;
|
|
8201
|
+
const deadline = Date.now() + require_operators.PEER_CONNECTION_RECOVERY_WAIT_MS;
|
|
8197
8202
|
for (;;) {
|
|
8198
8203
|
const state = pc.connectionState;
|
|
8199
8204
|
if (state === "connected") return true;
|
|
8200
8205
|
if (state === "failed" || state === "closed") return false;
|
|
8201
8206
|
if (Date.now() >= deadline) return false;
|
|
8202
|
-
await new Promise((resolve) => setTimeout(resolve, PEER_CONNECTION_RECOVERY_POLL_MS));
|
|
8207
|
+
await new Promise((resolve) => setTimeout(resolve, require_operators.PEER_CONNECTION_RECOVERY_POLL_MS));
|
|
8203
8208
|
}
|
|
8204
8209
|
}
|
|
8205
8210
|
/**
|
|
@@ -8261,19 +8266,19 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8261
8266
|
}
|
|
8262
8267
|
isCallSessionEvent(event) {
|
|
8263
8268
|
try {
|
|
8264
|
-
logger$
|
|
8269
|
+
logger$12.debug("[Call] Checking if event is for this call session:", event);
|
|
8265
8270
|
const callId = require_operators.getValueFrom(event, "params.params.callID") ?? require_operators.getValueFrom(event, "params.call_id");
|
|
8266
8271
|
const roomSessionId = require_operators.getValueFrom(event, "params.room_session_id");
|
|
8267
|
-
logger$
|
|
8272
|
+
logger$12.debug(`[Call] Extracted session identifiers callID: ${callId} and roomSessionID: ${roomSessionId} from event:`);
|
|
8268
8273
|
return callId === this.id || !!callId && this.callEventsManager.isCallIdValid(callId) || !!roomSessionId && this.callEventsManager.isRoomSessionIdValid(roomSessionId);
|
|
8269
8274
|
} catch (error) {
|
|
8270
|
-
logger$
|
|
8275
|
+
logger$12.error("[Call] Error checking if event is for this call session:", error);
|
|
8271
8276
|
return false;
|
|
8272
8277
|
}
|
|
8273
8278
|
}
|
|
8274
8279
|
get callSessionEvents$() {
|
|
8275
8280
|
return this.cachedObservable("callSessionEvents$", () => this.clientSession.signalingEvent$.pipe((0, rxjs.filter)((event) => this.isCallSessionEvent(event)), (0, rxjs.tap)((event) => {
|
|
8276
|
-
logger$
|
|
8281
|
+
logger$12.debug("[Call] Received call session event:", event);
|
|
8277
8282
|
}), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.share)()));
|
|
8278
8283
|
}
|
|
8279
8284
|
/** Observable of call-updated events. */
|
|
@@ -8343,16 +8348,16 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8343
8348
|
this._customSubscriptions.set(eventType, filtered$);
|
|
8344
8349
|
}, (error) => {
|
|
8345
8350
|
this._customSubscriptions.delete(eventType);
|
|
8346
|
-
logger$
|
|
8351
|
+
logger$12.warn(`[Call] verto.subscribe for '${eventType}' failed, not caching:`, error);
|
|
8347
8352
|
});
|
|
8348
8353
|
this._customSubscriptions.set(eventType, filtered$);
|
|
8349
8354
|
return filtered$;
|
|
8350
8355
|
}
|
|
8351
8356
|
get webrtcMessages$() {
|
|
8352
|
-
return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isWebrtcMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$
|
|
8357
|
+
return this.cachedObservable("webrtcMessages$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isWebrtcMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$12.debug("[Call] Event is a WebRTC message event:", event)), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.share)()));
|
|
8353
8358
|
}
|
|
8354
8359
|
get callEvent$() {
|
|
8355
|
-
return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isSignalwireCallMetadata, "params"), (0, rxjs.tap)((event) => logger$
|
|
8360
|
+
return this.cachedObservable("callEvent$", () => this.callSessionEvents$.pipe(require_operators.filterAs(isSignalwireCallMetadata, "params"), (0, rxjs.tap)((event) => logger$12.debug("[Call] Event is a call event:", event)), (0, rxjs.takeUntil)(this.destroyed$), (0, rxjs.share)()));
|
|
8356
8361
|
}
|
|
8357
8362
|
get layoutEvent$() {
|
|
8358
8363
|
return this.cachedObservable("layoutEvent$", () => this.callEvent$.pipe(require_operators.filterAs(isLayoutChangedMetadata, "params")));
|
|
@@ -8430,10 +8435,21 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8430
8435
|
return this.deferEmission(this._answered$.asObservable());
|
|
8431
8436
|
}
|
|
8432
8437
|
/**
|
|
8433
|
-
* Sets the call layout and participant positions.
|
|
8438
|
+
* Sets the call layout and, optionally, individual participant positions.
|
|
8439
|
+
*
|
|
8440
|
+
* The gateway `call.layout.set` DTO has **no** `positions` member, so when
|
|
8441
|
+
* `positions` is provided this method issues a `call.member.position.set`
|
|
8442
|
+
* request per member (via {@link Participant.setPosition}, which keys each
|
|
8443
|
+
* position by that member's own call context) alongside `call.layout.set`
|
|
8444
|
+
* (issue #19400, Flag #6).
|
|
8445
|
+
*
|
|
8446
|
+
* **These operations are NOT atomic.** The layout is applied first, then each
|
|
8447
|
+
* member position sequentially, so members may briefly flash into their
|
|
8448
|
+
* default slots before being moved to the requested positions.
|
|
8434
8449
|
*
|
|
8435
8450
|
* @param layout - Layout name (must be one of {@link layouts}).
|
|
8436
|
-
* @param positions -
|
|
8451
|
+
* @param positions - Optional map of member IDs to {@link VideoPosition} values.
|
|
8452
|
+
* When omitted or empty, only the layout is changed.
|
|
8437
8453
|
* @throws {InvalidParams} If the layout is not in the available {@link layouts}.
|
|
8438
8454
|
*
|
|
8439
8455
|
* @example
|
|
@@ -8446,10 +8462,17 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8446
8462
|
async setLayout(layout, positions) {
|
|
8447
8463
|
if (!this.layouts.includes(layout)) throw new require_operators.InvalidParams(`Layout ${layout} is not available in the current call layouts: ${this.layouts.join(", ")}`);
|
|
8448
8464
|
const selfId = await (0, rxjs.firstValueFrom)(this.selfId$.pipe((0, rxjs.filter)((id) => id !== null)));
|
|
8449
|
-
await this.executeMethod(selfId, "call.layout.set", {
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8465
|
+
await this.executeMethod(selfId, "call.layout.set", { layout });
|
|
8466
|
+
const positionEntries = Object.entries(positions ?? {});
|
|
8467
|
+
if (positionEntries.length === 0) return;
|
|
8468
|
+
for (const [memberId, position] of positionEntries) {
|
|
8469
|
+
const participant = this.participants.find((p) => p.id === memberId);
|
|
8470
|
+
if (!participant) {
|
|
8471
|
+
logger$12.warn(`[Call] setLayout: member ${memberId} not found in participants; skipping position ${position}`);
|
|
8472
|
+
continue;
|
|
8473
|
+
}
|
|
8474
|
+
await participant.setPosition(position);
|
|
8475
|
+
}
|
|
8453
8476
|
}
|
|
8454
8477
|
/**
|
|
8455
8478
|
* Transfers the call to another destination.
|
|
@@ -8481,7 +8504,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8481
8504
|
setLocalMicrophoneGain(value) {
|
|
8482
8505
|
const pipeline = this.vertoManager.ensureLocalAudioPipeline();
|
|
8483
8506
|
if (!pipeline) {
|
|
8484
|
-
logger$
|
|
8507
|
+
logger$12.warn("[Call] setLocalMicrophoneGain: audio pipeline unavailable");
|
|
8485
8508
|
return;
|
|
8486
8509
|
}
|
|
8487
8510
|
const percent = Math.max(0, Math.min(200, value));
|
|
@@ -8526,7 +8549,7 @@ var WebRTCCall = class extends Destroyable {
|
|
|
8526
8549
|
enablePushToTalk() {
|
|
8527
8550
|
const pipeline = this.vertoManager.ensureLocalAudioPipeline();
|
|
8528
8551
|
if (!pipeline) {
|
|
8529
|
-
logger$
|
|
8552
|
+
logger$12.warn("[Call] enablePushToTalk: audio pipeline unavailable");
|
|
8530
8553
|
return;
|
|
8531
8554
|
}
|
|
8532
8555
|
pipeline.setPTTActive(false);
|
|
@@ -8623,6 +8646,7 @@ function inferCallErrorKind(error) {
|
|
|
8623
8646
|
if (error instanceof require_operators.RPCTimeoutError) return "timeout";
|
|
8624
8647
|
if (error instanceof require_operators.JSONRPCError) return "signaling";
|
|
8625
8648
|
if (error instanceof require_operators.MediaTrackError) return "media";
|
|
8649
|
+
if (error instanceof require_operators.MediaAccessError) return "media";
|
|
8626
8650
|
if (error instanceof require_operators.WebSocketConnectionError || error instanceof require_operators.TransportConnectionError) return "network";
|
|
8627
8651
|
return "internal";
|
|
8628
8652
|
}
|
|
@@ -8631,14 +8655,15 @@ function inferCallErrorKind(error) {
|
|
|
8631
8655
|
* destroy the call, because the session will reauthenticate and any pending
|
|
8632
8656
|
* RPC can then be retried. */
|
|
8633
8657
|
const RECOVERABLE_RPC_CODES = new Set([
|
|
8634
|
-
RPC_ERROR_REQUESTER_VALIDATION_FAILED,
|
|
8635
|
-
RPC_ERROR_AUTHENTICATION_FAILED,
|
|
8636
|
-
RPC_ERROR_INVALID_PARAMS
|
|
8658
|
+
require_operators.RPC_ERROR_REQUESTER_VALIDATION_FAILED,
|
|
8659
|
+
require_operators.RPC_ERROR_AUTHENTICATION_FAILED,
|
|
8660
|
+
require_operators.RPC_ERROR_INVALID_PARAMS
|
|
8637
8661
|
]);
|
|
8638
8662
|
/** Determines whether an error should be fatal (destroy the call). */
|
|
8639
8663
|
function isFatalError(error) {
|
|
8640
8664
|
if (error instanceof require_operators.VertoPongError) return false;
|
|
8641
8665
|
if (error instanceof require_operators.MediaTrackError) return false;
|
|
8666
|
+
if (error instanceof require_operators.MediaAccessError) return error.fatal;
|
|
8642
8667
|
if (error instanceof require_operators.RPCTimeoutError) return false;
|
|
8643
8668
|
if (error instanceof require_operators.JSONRPCError && RECOVERABLE_RPC_CODES.has(error.code)) return false;
|
|
8644
8669
|
return true;
|
|
@@ -8664,10 +8689,10 @@ var CallFactory = class {
|
|
|
8664
8689
|
return {
|
|
8665
8690
|
vertoManager: new WebRTCVertoManager(callInstance, this.attachManager, this.deviceController, this.webRTCApiProvider, {
|
|
8666
8691
|
nodeId: options.nodeId,
|
|
8667
|
-
onError: (error) => {
|
|
8692
|
+
onError: (error, options$1) => {
|
|
8668
8693
|
const callError = {
|
|
8669
8694
|
kind: inferCallErrorKind(error),
|
|
8670
|
-
fatal: isFatalError(error),
|
|
8695
|
+
fatal: options$1?.fatal ?? isFatalError(error),
|
|
8671
8696
|
error,
|
|
8672
8697
|
callId: callInstance.id
|
|
8673
8698
|
};
|
|
@@ -8688,7 +8713,7 @@ var CallFactory = class {
|
|
|
8688
8713
|
|
|
8689
8714
|
//#endregion
|
|
8690
8715
|
//#region src/behaviors/Collection.ts
|
|
8691
|
-
const logger$
|
|
8716
|
+
const logger$11 = require_operators.getLogger();
|
|
8692
8717
|
var Fetcher = class {
|
|
8693
8718
|
constructor(endpoint, params, http) {
|
|
8694
8719
|
this.endpoint = endpoint;
|
|
@@ -8712,7 +8737,7 @@ var Fetcher = class {
|
|
|
8712
8737
|
this.hasMore = !!this.nextUrl;
|
|
8713
8738
|
return result.data.filter(this.filter).map(this.mapper);
|
|
8714
8739
|
}
|
|
8715
|
-
logger$
|
|
8740
|
+
logger$11.error("Failed to fetch entity");
|
|
8716
8741
|
return [];
|
|
8717
8742
|
}
|
|
8718
8743
|
async id(v) {
|
|
@@ -8788,7 +8813,7 @@ var EntityCollection = class extends Destroyable {
|
|
|
8788
8813
|
this._hasMore$.next(this.fetchController.hasMore ?? false);
|
|
8789
8814
|
this._loading$.next(false);
|
|
8790
8815
|
} catch (error) {
|
|
8791
|
-
logger$
|
|
8816
|
+
logger$11.error(`Failed to fetch initial collection data`, error);
|
|
8792
8817
|
this._hasMore$.next(this.fetchController.hasMore ?? false);
|
|
8793
8818
|
this._loading$.next(false);
|
|
8794
8819
|
this.onError?.(new require_operators.CollectionFetchError("fetchMore", error));
|
|
@@ -8802,7 +8827,7 @@ var EntityCollection = class extends Destroyable {
|
|
|
8802
8827
|
if (data) this.upsertData(data);
|
|
8803
8828
|
return data;
|
|
8804
8829
|
} catch (error) {
|
|
8805
|
-
logger$
|
|
8830
|
+
logger$11.error(`Failed to fetch data for (${String(key)}:${String(value)}) :`, error);
|
|
8806
8831
|
this._loading$.next(false);
|
|
8807
8832
|
this.onError?.(new require_operators.CollectionFetchError(`tryFetch(${String(key)})`, error));
|
|
8808
8833
|
}
|
|
@@ -9049,13 +9074,13 @@ var Address = class extends Destroyable {
|
|
|
9049
9074
|
|
|
9050
9075
|
//#endregion
|
|
9051
9076
|
//#region src/core/utils.ts
|
|
9052
|
-
const logger$
|
|
9077
|
+
const logger$10 = require_operators.getLogger();
|
|
9053
9078
|
const isRPCConnectResult = (e) => {
|
|
9054
|
-
logger$
|
|
9079
|
+
logger$10.debug("isRPCConnectResult check:", e);
|
|
9055
9080
|
if (!e || typeof e !== "object") return false;
|
|
9056
9081
|
const result = e;
|
|
9057
9082
|
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";
|
|
9058
|
-
logger$
|
|
9083
|
+
logger$10.debug("isRPCConnectResult check result:", is);
|
|
9059
9084
|
return is;
|
|
9060
9085
|
};
|
|
9061
9086
|
var PendingRPC = class PendingRPC {
|
|
@@ -9064,7 +9089,7 @@ var PendingRPC = class PendingRPC {
|
|
|
9064
9089
|
}
|
|
9065
9090
|
constructor(request, responses$, options) {
|
|
9066
9091
|
this.id = (0, uuid.v4)();
|
|
9067
|
-
logger$
|
|
9092
|
+
logger$10.debug(`[PendingRPC(${this.id}) request:${request.id}: method:${request.method}] Creating PendingRPC`);
|
|
9068
9093
|
this.request = request;
|
|
9069
9094
|
const timeoutMs = options?.timeoutMs ?? PendingRPC.defaultTimeoutMs;
|
|
9070
9095
|
const signal = options?.signal;
|
|
@@ -9090,22 +9115,22 @@ var PendingRPC = class PendingRPC {
|
|
|
9090
9115
|
isSettled = true;
|
|
9091
9116
|
if (response.error) {
|
|
9092
9117
|
const rpcError = new require_operators.JSONRPCError(response.error.code, response.error.message, response.error.data, void 0, request.id);
|
|
9093
|
-
logger$
|
|
9118
|
+
logger$10.debug(`[PendingRPC(${this.id}) request:${request.id}] Rejecting promise with RPC error:`, rpcError);
|
|
9094
9119
|
reject(rpcError);
|
|
9095
9120
|
} else {
|
|
9096
|
-
logger$
|
|
9121
|
+
logger$10.debug(`[PendingRPC(${this.id}) request:${request.id}] Resolving promise with response:`, response);
|
|
9097
9122
|
resolve(response);
|
|
9098
9123
|
}
|
|
9099
9124
|
subscription.unsubscribe();
|
|
9100
9125
|
},
|
|
9101
9126
|
error: (error) => {
|
|
9102
|
-
logger$
|
|
9127
|
+
logger$10.debug(`[PendingRPC(${this.id}) request:${request.id}] Rejecting promise with error:`, error);
|
|
9103
9128
|
isSettled = true;
|
|
9104
9129
|
reject(error);
|
|
9105
9130
|
subscription.unsubscribe();
|
|
9106
9131
|
},
|
|
9107
9132
|
complete: () => {
|
|
9108
|
-
logger$
|
|
9133
|
+
logger$10.debug(`[PendingRPC(${this.id}) request:${request.id}] Observable completed`);
|
|
9109
9134
|
if (!isSettled) reject(new require_operators.RPCTimeoutError(request.id, timeoutMs));
|
|
9110
9135
|
subscription.unsubscribe();
|
|
9111
9136
|
}
|
|
@@ -9125,7 +9150,18 @@ var PendingRPC = class PendingRPC {
|
|
|
9125
9150
|
|
|
9126
9151
|
//#endregion
|
|
9127
9152
|
//#region src/managers/ClientSessionManager.ts
|
|
9128
|
-
const logger$
|
|
9153
|
+
const logger$9 = require_operators.getLogger();
|
|
9154
|
+
/**
|
|
9155
|
+
* Decide whether an error emitted on `call.errors$` during dial should
|
|
9156
|
+
* abort the dial. A non-fatal MediaAccessError means the call degraded to
|
|
9157
|
+
* receive-only and still connects — everything else rejects `dial()` with
|
|
9158
|
+
* the real cause.
|
|
9159
|
+
*
|
|
9160
|
+
* Pure function — exported for unit testing.
|
|
9161
|
+
*/
|
|
9162
|
+
function shouldAbortDial(callError) {
|
|
9163
|
+
return callError.fatal || !(callError.error instanceof require_operators.MediaAccessError);
|
|
9164
|
+
}
|
|
9129
9165
|
const getAddressSearchURI = (options) => {
|
|
9130
9166
|
const to = options.to?.split("?")[0];
|
|
9131
9167
|
const from$8 = options.from?.startsWith("subscriber://") ? options.from.replace("subscriber://", "") : options.from;
|
|
@@ -9223,7 +9259,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9223
9259
|
try {
|
|
9224
9260
|
return await this.transport.execute(request, options);
|
|
9225
9261
|
} catch (error) {
|
|
9226
|
-
logger$
|
|
9262
|
+
logger$9.debug("[Session] Execute Error", error);
|
|
9227
9263
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
9228
9264
|
throw error;
|
|
9229
9265
|
}
|
|
@@ -9237,13 +9273,13 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9237
9273
|
return true;
|
|
9238
9274
|
}
|
|
9239
9275
|
setupMessageHandlers() {
|
|
9240
|
-
logger$
|
|
9276
|
+
logger$9.debug("[Session] Setting up message handlers");
|
|
9241
9277
|
this.subscribeTo(this.authStateEvent$, async (authStateEvent) => {
|
|
9242
|
-
logger$
|
|
9278
|
+
logger$9.debug("[Session] Authorization state event received:", authStateEvent);
|
|
9243
9279
|
try {
|
|
9244
9280
|
await this.updateAuthorizationStateInStorage(authStateEvent.authorization_state);
|
|
9245
9281
|
} catch (error) {
|
|
9246
|
-
logger$
|
|
9282
|
+
logger$9.error("[Session] Failed to handle authorization state update:", error);
|
|
9247
9283
|
this._errors$.next(new require_operators.AuthStateHandlerError(error));
|
|
9248
9284
|
}
|
|
9249
9285
|
});
|
|
@@ -9251,29 +9287,29 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9251
9287
|
if (this._authState$.value.kind === "authenticated") this._authState$.next({ kind: "unauthenticated" });
|
|
9252
9288
|
});
|
|
9253
9289
|
this.subscribeTo(this.transport.connectionStatus$.pipe((0, rxjs.filter)((status) => status === "connected"), (0, rxjs.exhaustMap)(() => {
|
|
9254
|
-
logger$
|
|
9290
|
+
logger$9.debug("[Session] Connection established, initiating authentication");
|
|
9255
9291
|
return (0, rxjs.from)(this.authenticate()).pipe((0, rxjs.catchError)((error) => {
|
|
9256
9292
|
this.handleAuthenticationError(error).catch((err) => {
|
|
9257
|
-
logger$
|
|
9293
|
+
logger$9.error("[Session] Error handling authentication failure:", err);
|
|
9258
9294
|
});
|
|
9259
9295
|
return rxjs.EMPTY;
|
|
9260
9296
|
}));
|
|
9261
9297
|
})), void 0);
|
|
9262
9298
|
this.subscribeTo(this.vertoInvite$, async (invite) => {
|
|
9263
|
-
logger$
|
|
9299
|
+
logger$9.debug("[Session] Verto invite received:", invite);
|
|
9264
9300
|
try {
|
|
9265
9301
|
await this.createInboundCall(invite);
|
|
9266
9302
|
} catch (error) {
|
|
9267
|
-
logger$
|
|
9303
|
+
logger$9.error("[Session] Error handling Verto invite:", error);
|
|
9268
9304
|
this._errors$.next(new require_operators.VertoInviteHandlerError(error));
|
|
9269
9305
|
}
|
|
9270
9306
|
});
|
|
9271
9307
|
this.subscribeTo(this.vertoAttach$, async (attach) => {
|
|
9272
|
-
logger$
|
|
9308
|
+
logger$9.debug("[Session] Verto attach received:", attach);
|
|
9273
9309
|
try {
|
|
9274
9310
|
await this.handleVertoAttach(attach);
|
|
9275
9311
|
} catch (error) {
|
|
9276
|
-
logger$
|
|
9312
|
+
logger$9.error("[Session] Error handling Verto attach:", error);
|
|
9277
9313
|
this._errors$.next(new require_operators.VertoAttachHandlerError(error));
|
|
9278
9314
|
}
|
|
9279
9315
|
});
|
|
@@ -9283,36 +9319,36 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9283
9319
|
const storedState = await this.storage.getItem(this.authorizationStateKey);
|
|
9284
9320
|
this.authorizationState$.next(storedState ?? void 0);
|
|
9285
9321
|
} catch (error) {
|
|
9286
|
-
logger$
|
|
9322
|
+
logger$9.error("Failed to retrieve authorization state from storage:", error);
|
|
9287
9323
|
this.authorizationState$.next(void 0);
|
|
9288
9324
|
}
|
|
9289
9325
|
}
|
|
9290
9326
|
async updateAuthorizationStateInStorage(authorizationState) {
|
|
9291
9327
|
if (!authorizationState) {
|
|
9292
|
-
logger$
|
|
9328
|
+
logger$9.debug("[Session] Removing authorization state from storage");
|
|
9293
9329
|
try {
|
|
9294
9330
|
await this.storage.removeItem(this.authorizationStateKey);
|
|
9295
9331
|
this.authorizationState$.next(void 0);
|
|
9296
9332
|
} catch (error) {
|
|
9297
|
-
logger$
|
|
9333
|
+
logger$9.error("Failed to remove authorization state from storage:", error);
|
|
9298
9334
|
throw error;
|
|
9299
9335
|
}
|
|
9300
9336
|
return;
|
|
9301
9337
|
}
|
|
9302
9338
|
try {
|
|
9303
|
-
logger$
|
|
9339
|
+
logger$9.debug("[Session] Updating authorization state in storage");
|
|
9304
9340
|
await this.storage.setItem(this.authorizationStateKey, authorizationState);
|
|
9305
9341
|
this.authorizationState$.next(authorizationState);
|
|
9306
9342
|
} catch (error) {
|
|
9307
|
-
logger$
|
|
9343
|
+
logger$9.error("Failed to retrieve authorization state from storage:", error);
|
|
9308
9344
|
throw error;
|
|
9309
9345
|
}
|
|
9310
9346
|
}
|
|
9311
9347
|
get authStateEvent$() {
|
|
9312
9348
|
return this.cachedObservable("authStateEvent$", () => this.signalingEvent$.pipe((0, rxjs.tap)((msg) => {
|
|
9313
|
-
logger$
|
|
9349
|
+
logger$9.debug("[Session] Received incoming message:", msg);
|
|
9314
9350
|
}), require_operators.filterAs(isSignalwireAuthorizationStateMetadata, "params"), (0, rxjs.tap)((event) => {
|
|
9315
|
-
logger$
|
|
9351
|
+
logger$9.debug("[Session] Authorization state event received:", event.authorization_state);
|
|
9316
9352
|
})));
|
|
9317
9353
|
}
|
|
9318
9354
|
get signalingEvent$() {
|
|
@@ -9350,42 +9386,72 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9350
9386
|
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 })));
|
|
9351
9387
|
}
|
|
9352
9388
|
async handleAuthenticationError(error) {
|
|
9353
|
-
logger$
|
|
9354
|
-
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);
|
|
9389
|
+
logger$9.error("Authentication error:", error);
|
|
9390
|
+
const isRecoverableAuthError = error instanceof require_operators.JSONRPCError && (error.code === require_operators.RPC_ERROR_REQUESTER_VALIDATION_FAILED || error.code === require_operators.RPC_ERROR_INVALID_PARAMS || error.code === require_operators.RPC_ERROR_AUTHENTICATION_FAILED);
|
|
9355
9391
|
const hasStoredState = await (0, rxjs.firstValueFrom)(this.authorizationState$.pipe((0, rxjs.take)(1))) !== void 0;
|
|
9356
9392
|
if (isRecoverableAuthError && hasStoredState) {
|
|
9357
|
-
logger$
|
|
9393
|
+
logger$9.debug("[Session] Recoverable auth error — cleaning up stored state and reconnecting fresh");
|
|
9358
9394
|
try {
|
|
9359
9395
|
await this.cleanupStoredConnectionParams();
|
|
9360
9396
|
} catch (cleanupError) {
|
|
9361
|
-
logger$
|
|
9397
|
+
logger$9.error("Failed to cleanup stored connection params:", cleanupError);
|
|
9362
9398
|
} finally {
|
|
9363
9399
|
this.transport.reconnect();
|
|
9364
9400
|
}
|
|
9365
9401
|
} else this._errors$.next(error);
|
|
9366
9402
|
}
|
|
9403
|
+
/**
|
|
9404
|
+
* Clear the resume state (authorization_state + protocol) only.
|
|
9405
|
+
*
|
|
9406
|
+
* This is the stale-auth-state recovery helper used by handleAuthError:
|
|
9407
|
+
* the server rejected a reconnect, so the resume state is discarded and a
|
|
9408
|
+
* fresh connect follows. Attach records are deliberately preserved — the
|
|
9409
|
+
* session lives on through the reconnect and reattachCalls() needs the
|
|
9410
|
+
* stored call references afterwards. Do NOT add detachAll() here.
|
|
9411
|
+
*
|
|
9412
|
+
* For public teardown (disconnect/destroy), use {@link teardownSessionState}
|
|
9413
|
+
* instead, which clears the attach records as well.
|
|
9414
|
+
*/
|
|
9367
9415
|
async cleanupStoredConnectionParams() {
|
|
9368
9416
|
await this.transport.setProtocol(void 0);
|
|
9369
9417
|
await this.updateAuthorizationStateInStorage(void 0);
|
|
9370
9418
|
this._authorization$.next(void 0);
|
|
9371
9419
|
}
|
|
9420
|
+
/**
|
|
9421
|
+
* Public-teardown helper for disconnect()/destroy(). Clears the resume
|
|
9422
|
+
* state (authorization_state + protocol) AND the attach records as one
|
|
9423
|
+
* atomic unit.
|
|
9424
|
+
*
|
|
9425
|
+
* The two stores are coupled: the backend only honors attach records
|
|
9426
|
+
* within the session identified by the resume state, so ending the
|
|
9427
|
+
* session must clear both. Clearing one without the other strands records
|
|
9428
|
+
* no future session can honor (disconnect) or revives a session the
|
|
9429
|
+
* developer explicitly ended (destroy).
|
|
9430
|
+
*
|
|
9431
|
+
* Distinct from {@link cleanupStoredConnectionParams}, which keeps the
|
|
9432
|
+
* attach records for the stale-auth-state recovery path.
|
|
9433
|
+
*/
|
|
9434
|
+
async teardownSessionState() {
|
|
9435
|
+
await this.cleanupStoredConnectionParams();
|
|
9436
|
+
await this.attachManager.detachAll();
|
|
9437
|
+
}
|
|
9372
9438
|
async updateAuthState(authorization_state) {
|
|
9373
9439
|
try {
|
|
9374
9440
|
await this.storage.setItem(this.authorizationStateKey, authorization_state);
|
|
9375
9441
|
} catch (error) {
|
|
9376
|
-
logger$
|
|
9442
|
+
logger$9.error("Failed to update authorization state in storage:", error);
|
|
9377
9443
|
this._errors$.next(new require_operators.AuthStateHandlerError(error));
|
|
9378
9444
|
}
|
|
9379
9445
|
}
|
|
9380
9446
|
async reauthenticate(token, dpopToken, options) {
|
|
9381
|
-
logger$
|
|
9447
|
+
logger$9.debug("[Session] Re-authenticating session");
|
|
9382
9448
|
try {
|
|
9383
9449
|
let resolvedDpopToken = dpopToken;
|
|
9384
9450
|
if (!resolvedDpopToken && this.dpopManager?.initialized) try {
|
|
9385
9451
|
resolvedDpopToken = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
9386
9452
|
} catch (error) {
|
|
9387
9453
|
if (this.clientBound) throw error;
|
|
9388
|
-
logger$
|
|
9454
|
+
logger$9.warn("[Session] Failed to create DPoP proof for reauthenticate:", error);
|
|
9389
9455
|
}
|
|
9390
9456
|
const request = RPCReauthenticate({
|
|
9391
9457
|
project: this._authorization$.value?.project_id ?? "",
|
|
@@ -9393,24 +9459,24 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9393
9459
|
...resolvedDpopToken ? { dpop_token: resolvedDpopToken } : {}
|
|
9394
9460
|
});
|
|
9395
9461
|
await (0, rxjs.lastValueFrom)((0, rxjs.from)(this.transport.execute(request)).pipe(require_operators.throwOnRPCError(), (0, rxjs.take)(1), (0, rxjs.catchError)((err) => {
|
|
9396
|
-
logger$
|
|
9462
|
+
logger$9.error("[Session] Re-authentication RPC failed:", err);
|
|
9397
9463
|
throw err;
|
|
9398
9464
|
})));
|
|
9399
9465
|
if (options?.clientBound) this._wasClientBound = true;
|
|
9400
|
-
logger$
|
|
9466
|
+
logger$9.debug("[Session] Re-authentication successful, updating stored auth state");
|
|
9401
9467
|
} catch (error) {
|
|
9402
|
-
logger$
|
|
9468
|
+
logger$9.error("[Session] Re-authentication failed:", error);
|
|
9403
9469
|
this._errors$.next(new require_operators.AuthStateHandlerError(error));
|
|
9404
9470
|
throw error;
|
|
9405
9471
|
}
|
|
9406
9472
|
}
|
|
9407
9473
|
async authenticate() {
|
|
9408
|
-
logger$
|
|
9474
|
+
logger$9.debug("[Session] Starting authentication process");
|
|
9409
9475
|
const persistedParams = await (0, rxjs.firstValueFrom)((0, rxjs.combineLatest)({
|
|
9410
9476
|
protocol: this.transport.protocol$,
|
|
9411
9477
|
authorization_state: this.authorizationState$
|
|
9412
9478
|
}).pipe((0, rxjs.take)(1)));
|
|
9413
|
-
logger$
|
|
9479
|
+
logger$9.debug("[Session] Persisted params:\n", {
|
|
9414
9480
|
protocol: persistedParams.protocol,
|
|
9415
9481
|
authStateLength: persistedParams.authorization_state?.length
|
|
9416
9482
|
});
|
|
@@ -9418,16 +9484,16 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9418
9484
|
const storedToken = this.getCredential().token;
|
|
9419
9485
|
const isReconnect = hasReconnectState && storedToken;
|
|
9420
9486
|
let dpopToken;
|
|
9421
|
-
if (isReconnect) logger$
|
|
9487
|
+
if (isReconnect) logger$9.debug("[Session] Reconnecting with stored jwt_token + authorization_state");
|
|
9422
9488
|
else if (this.onBeforeReconnect && this.clientBound) {
|
|
9423
|
-
logger$
|
|
9489
|
+
logger$9.debug("[Session] Refreshing credentials before fresh connect");
|
|
9424
9490
|
await this.onBeforeReconnect();
|
|
9425
9491
|
}
|
|
9426
9492
|
if ((!isReconnect || this.clientBound) && this.dpopManager?.initialized) try {
|
|
9427
9493
|
dpopToken = await this.dpopManager.createRpcProof({ method: "signalwire.connect" });
|
|
9428
9494
|
} catch (error) {
|
|
9429
9495
|
if (this.clientBound) throw error;
|
|
9430
|
-
logger$
|
|
9496
|
+
logger$9.warn("[Session] Failed to create DPoP proof for connect, proceeding without:", error);
|
|
9431
9497
|
}
|
|
9432
9498
|
const rpcConnectRequest = RPCConnect({
|
|
9433
9499
|
authentication: isReconnect ? { jwt_token: storedToken } : this.authentication,
|
|
@@ -9444,12 +9510,12 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9444
9510
|
} : {}
|
|
9445
9511
|
});
|
|
9446
9512
|
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)(() => {
|
|
9447
|
-
logger$
|
|
9513
|
+
logger$9.debug("[Session] Response passed filter, processing authentication result");
|
|
9448
9514
|
}), (0, rxjs.take)(1), (0, rxjs.catchError)((err) => {
|
|
9449
|
-
logger$
|
|
9515
|
+
logger$9.error("[Session] Authentication RPC failed:", err);
|
|
9450
9516
|
throw err;
|
|
9451
9517
|
})));
|
|
9452
|
-
logger$
|
|
9518
|
+
logger$9.debug("[Session] Processing authentication result:", {
|
|
9453
9519
|
hasProtocol: !!response.protocol,
|
|
9454
9520
|
hasAuthorization: !!response.authorization,
|
|
9455
9521
|
hasIceServers: !!response.ice_servers
|
|
@@ -9458,12 +9524,12 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9458
9524
|
this._authorization$.next(response.authorization);
|
|
9459
9525
|
this._iceServers$.next(response.ice_servers ?? []);
|
|
9460
9526
|
this._authState$.next({ kind: "authenticated" });
|
|
9461
|
-
logger$
|
|
9527
|
+
logger$9.debug("[Session] Authentication completed successfully");
|
|
9462
9528
|
}
|
|
9463
9529
|
async disconnect() {
|
|
9464
9530
|
this.transport.disconnect();
|
|
9465
9531
|
this._authState$.next({ kind: "unauthenticated" });
|
|
9466
|
-
await this.
|
|
9532
|
+
await this.teardownSessionState();
|
|
9467
9533
|
}
|
|
9468
9534
|
async createInboundCall(invite) {
|
|
9469
9535
|
const callSession = await this.createCall({
|
|
@@ -9494,11 +9560,11 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9494
9560
|
async handleVertoAttach(attach) {
|
|
9495
9561
|
const { callID } = attach;
|
|
9496
9562
|
if (callID in this._calls$.value) {
|
|
9497
|
-
logger$
|
|
9563
|
+
logger$9.debug(`[Session] Verto attach for existing call ${callID}, deferring to per-call handler`);
|
|
9498
9564
|
return;
|
|
9499
9565
|
}
|
|
9500
9566
|
const storedOptions = await this.attachManager.consumePendingAttachment(callID);
|
|
9501
|
-
logger$
|
|
9567
|
+
logger$9.debug(`[Session] Creating reattached call for callID: ${callID}`);
|
|
9502
9568
|
const callSession = await this.createCall({
|
|
9503
9569
|
nodeId: attach.node_id,
|
|
9504
9570
|
callId: callID,
|
|
@@ -9522,14 +9588,14 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9522
9588
|
to: destinationURI,
|
|
9523
9589
|
...options
|
|
9524
9590
|
});
|
|
9525
|
-
await (0, rxjs.firstValueFrom)((0, rxjs.race)(callSession.selfId$.pipe((0, rxjs.filter)((id) => Boolean(id)), (0, rxjs.take)(1), (0, rxjs.timeout)(this.callCreateTimeout)), callSession.errors$.pipe((0, rxjs.take)(1), (0, rxjs.switchMap)((callError) => (0, rxjs.throwError)(() => callError.error)))));
|
|
9591
|
+
await (0, rxjs.firstValueFrom)((0, rxjs.race)(callSession.selfId$.pipe((0, rxjs.filter)((id) => Boolean(id)), (0, rxjs.take)(1), (0, rxjs.timeout)(this.callCreateTimeout)), callSession.errors$.pipe((0, rxjs.filter)(shouldAbortDial), (0, rxjs.take)(1), (0, rxjs.switchMap)((callError) => (0, rxjs.throwError)(() => callError.error)))));
|
|
9526
9592
|
this._calls$.next({
|
|
9527
9593
|
[`${callSession.id}`]: callSession,
|
|
9528
9594
|
...this._calls$.value
|
|
9529
9595
|
});
|
|
9530
9596
|
return callSession;
|
|
9531
9597
|
} catch (error) {
|
|
9532
|
-
logger$
|
|
9598
|
+
logger$9.error("[Session] Error creating outbound call:", error);
|
|
9533
9599
|
callSession?.destroy();
|
|
9534
9600
|
const callError = new require_operators.CallCreateError(error instanceof rxjs.TimeoutError ? "Call create timeout" : "Call creation failed", error, "outbound");
|
|
9535
9601
|
this._errors$.next(callError);
|
|
@@ -9547,7 +9613,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9547
9613
|
address = this._directory.get(addressId);
|
|
9548
9614
|
if (!address) throw new require_operators.DependencyError(`Address ID: ${addressId} not found`);
|
|
9549
9615
|
} catch {
|
|
9550
|
-
logger$
|
|
9616
|
+
logger$9.warn(`[Session] Directory lookup failed for ${addressURI}, proceeding with raw URI`);
|
|
9551
9617
|
}
|
|
9552
9618
|
const callSession = this.callFactory.createCall(address, { ...options });
|
|
9553
9619
|
this.subscribeTo(callSession.status$.pipe((0, rxjs.filter)((status) => status === "destroyed"), (0, rxjs.take)(1)), () => {
|
|
@@ -9556,7 +9622,7 @@ var ClientSessionManager = class extends Destroyable {
|
|
|
9556
9622
|
});
|
|
9557
9623
|
return callSession;
|
|
9558
9624
|
} catch (error) {
|
|
9559
|
-
logger$
|
|
9625
|
+
logger$9.error("[Session] Error creating call session:", error);
|
|
9560
9626
|
throw new require_operators.CallCreateError("Call create error", error, options.initOffer ? "inbound" : "outbound");
|
|
9561
9627
|
}
|
|
9562
9628
|
}
|
|
@@ -9604,7 +9670,7 @@ const isString = (obj) => typeof obj === "string";
|
|
|
9604
9670
|
|
|
9605
9671
|
//#endregion
|
|
9606
9672
|
//#region src/managers/ConversationsManager.ts
|
|
9607
|
-
const logger$
|
|
9673
|
+
const logger$8 = require_operators.getLogger();
|
|
9608
9674
|
var ConversationMessagesFetcher = class extends Fetcher {
|
|
9609
9675
|
constructor(groupId, http) {
|
|
9610
9676
|
super(`/api/fabric/conversations/${groupId}/messages`, "page_size=100", http);
|
|
@@ -9644,13 +9710,13 @@ var ConversationsManager = class {
|
|
|
9644
9710
|
}
|
|
9645
9711
|
throw new require_operators.ConversationError("Join Failed - Unexpected response");
|
|
9646
9712
|
} catch (error) {
|
|
9647
|
-
logger$
|
|
9713
|
+
logger$8.error("[ConversationsManager] Failed to join conversation:", error);
|
|
9648
9714
|
throw error;
|
|
9649
9715
|
}
|
|
9650
9716
|
}
|
|
9651
9717
|
async getConversationMessageCollection(addressId) {
|
|
9652
9718
|
const groupId = this.groupIds.get(addressId) ?? await this.join(addressId);
|
|
9653
|
-
return Promise.resolve(new ConversationMessageCollection(groupId, this.clientSession.signalingEvent$.pipe(require_operators.filterAs(isConversationMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$
|
|
9719
|
+
return Promise.resolve(new ConversationMessageCollection(groupId, this.clientSession.signalingEvent$.pipe(require_operators.filterAs(isConversationMessageMetadata, "params"), (0, rxjs.tap)((event) => logger$8.debug("[ConversationsManager ] Conversation Event:", event)), (0, rxjs.map)((params) => ({ ...params }))), this.http, this.onError));
|
|
9654
9720
|
}
|
|
9655
9721
|
async sendText(text, destinationAddressId) {
|
|
9656
9722
|
const groupId = this.groupIds.get(destinationAddressId) ?? await this.join(destinationAddressId);
|
|
@@ -9667,7 +9733,7 @@ var ConversationsManager = class {
|
|
|
9667
9733
|
})).ok) return;
|
|
9668
9734
|
throw new require_operators.ConversationError("Send Text Failed - Unexpected response");
|
|
9669
9735
|
} catch (error) {
|
|
9670
|
-
logger$
|
|
9736
|
+
logger$8.error("[ConversationsManager] Failed to send text message:", error);
|
|
9671
9737
|
throw error;
|
|
9672
9738
|
}
|
|
9673
9739
|
}
|
|
@@ -9675,7 +9741,7 @@ var ConversationsManager = class {
|
|
|
9675
9741
|
|
|
9676
9742
|
//#endregion
|
|
9677
9743
|
//#region src/managers/DeviceTokenManager.ts
|
|
9678
|
-
const logger$
|
|
9744
|
+
const logger$7 = require_operators.getLogger();
|
|
9679
9745
|
/**
|
|
9680
9746
|
* Resolves the token expiry timestamp (epoch seconds) using a 3-tier priority chain:
|
|
9681
9747
|
* 1. `data.expires_at` — server-provided absolute timestamp
|
|
@@ -9685,8 +9751,8 @@ const logger$6 = require_operators.getLogger();
|
|
|
9685
9751
|
function resolveExpiresAt(data) {
|
|
9686
9752
|
if (data.expires_at) return data.expires_at;
|
|
9687
9753
|
if (data.expires_in) return Math.floor(Date.now() / 1e3) + data.expires_in;
|
|
9688
|
-
logger$
|
|
9689
|
-
return Math.floor(Date.now() / 1e3) + DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9754
|
+
logger$7.warn("[DeviceToken] Could not determine token expiry, using default");
|
|
9755
|
+
return Math.floor(Date.now() / 1e3) + require_operators.DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9690
9756
|
}
|
|
9691
9757
|
/**
|
|
9692
9758
|
* Resolves the token TTL in seconds from a fresh response.
|
|
@@ -9699,7 +9765,7 @@ function resolveExpiresAt(data) {
|
|
|
9699
9765
|
function resolveExpireIn(data) {
|
|
9700
9766
|
if (data.expires_in) return data.expires_in;
|
|
9701
9767
|
if (data.expires_at) return Math.max(data.expires_at - Math.floor(Date.now() / 1e3), 1);
|
|
9702
|
-
return DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9768
|
+
return require_operators.DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9703
9769
|
}
|
|
9704
9770
|
/**
|
|
9705
9771
|
* Manages the Client Bound SAT lifecycle: activation, token exchange,
|
|
@@ -9718,11 +9784,12 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9718
9784
|
this.getCredential = getCredential;
|
|
9719
9785
|
this._currentToken$ = this.createBehaviorSubject(null);
|
|
9720
9786
|
this._refreshInProgress = false;
|
|
9721
|
-
this.
|
|
9787
|
+
this._paused = false;
|
|
9788
|
+
this._effectiveExpireIn = require_operators.DEVICE_TOKEN_DEFAULT_EXPIRE_IN;
|
|
9722
9789
|
this.subscribeTo(this._currentToken$.pipe((0, rxjs.filter)(Boolean), (0, rxjs.switchMap)((tokenData) => {
|
|
9723
9790
|
const expiresAt = resolveExpiresAt(tokenData);
|
|
9724
|
-
const refreshIn = Math.max(expiresAt * 1e3 - Date.now() - DEVICE_TOKEN_REFRESH_BUFFER_MS, 1e3);
|
|
9725
|
-
logger$
|
|
9791
|
+
const refreshIn = Math.max(expiresAt * 1e3 - Date.now() - require_operators.DEVICE_TOKEN_REFRESH_BUFFER_MS, 1e3);
|
|
9792
|
+
logger$7.debug(`[DeviceToken] Scheduling Client Bound SAT refresh in ${refreshIn}ms`);
|
|
9726
9793
|
return (0, rxjs.timer)(refreshIn);
|
|
9727
9794
|
})), () => {
|
|
9728
9795
|
this.executeRefresh();
|
|
@@ -9736,7 +9803,12 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9736
9803
|
* Activates the Client Bound SAT flow when the user's token has
|
|
9737
9804
|
* `sat:refresh` scope.
|
|
9738
9805
|
*
|
|
9739
|
-
*
|
|
9806
|
+
* Returns an {@link ActivationResult} indicating whether the manager
|
|
9807
|
+
* took ownership of refresh duties. The caller must use the `activated`
|
|
9808
|
+
* boolean to decide whether to keep its own refresh path armed — when
|
|
9809
|
+
* `activated` is `false`, the caller is responsible for refresh.
|
|
9810
|
+
*
|
|
9811
|
+
* Steps on success:
|
|
9740
9812
|
* 1. Check user's `sat_claims` for `sat:refresh` scope
|
|
9741
9813
|
* 2. Call `/api/fabric/subscriber/devices/token` with a DPoP proof
|
|
9742
9814
|
* 3. Reauthenticate the session with the Client Bound SAT + DPoP proof
|
|
@@ -9744,47 +9816,66 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9744
9816
|
*/
|
|
9745
9817
|
async activate(user, session, updateCredential) {
|
|
9746
9818
|
const { satClaims } = user;
|
|
9747
|
-
if (!satClaims?.scope?.includes(SAT_REFRESH_SCOPE)) {
|
|
9748
|
-
logger$
|
|
9749
|
-
return
|
|
9819
|
+
if (!satClaims?.scope?.includes(require_operators.SAT_REFRESH_SCOPE)) {
|
|
9820
|
+
logger$7.debug("[DeviceToken] No sat:refresh scope, skipping Client Bound SAT activation");
|
|
9821
|
+
return {
|
|
9822
|
+
activated: false,
|
|
9823
|
+
reason: "no-scope"
|
|
9824
|
+
};
|
|
9750
9825
|
}
|
|
9751
9826
|
this._session = session;
|
|
9752
9827
|
this._updateCredential = updateCredential;
|
|
9753
9828
|
try {
|
|
9829
|
+
const cached = this._currentToken$.value;
|
|
9830
|
+
if (cached && this.isTokenFresh(cached)) {
|
|
9831
|
+
logger$7.debug("[DeviceToken] Reusing cached Client Bound SAT — skipping /devices/token");
|
|
9832
|
+
const rpcProof$1 = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
9833
|
+
await session.reauthenticate(cached.token, rpcProof$1, { clientBound: true });
|
|
9834
|
+
updateCredential({ token: cached.token });
|
|
9835
|
+
return { activated: true };
|
|
9836
|
+
}
|
|
9754
9837
|
const tokenData = await this.obtainToken();
|
|
9755
9838
|
if (!tokenData.expires_at && !tokenData.expires_in && satClaims.expires_at) tokenData.expires_at = satClaims.expires_at;
|
|
9756
9839
|
this._effectiveExpireIn = resolveExpireIn(tokenData);
|
|
9757
9840
|
const rpcProof = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
9758
9841
|
await session.reauthenticate(tokenData.token, rpcProof, { clientBound: true });
|
|
9759
9842
|
updateCredential({ token: tokenData.token });
|
|
9760
|
-
logger$
|
|
9843
|
+
logger$7.info("[DeviceToken] Client Bound SAT activated successfully");
|
|
9761
9844
|
this._currentToken$.next(tokenData);
|
|
9845
|
+
return { activated: true };
|
|
9762
9846
|
} catch (error) {
|
|
9763
|
-
logger$
|
|
9847
|
+
logger$7.error("[DeviceToken] Failed to activate Client Bound SAT:", error);
|
|
9764
9848
|
this.errorHandler(new require_operators.DPoPInitError(error, "Failed to activate Client Bound SAT"));
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
expires_at: expiresAt
|
|
9770
|
-
});
|
|
9849
|
+
return {
|
|
9850
|
+
activated: false,
|
|
9851
|
+
reason: "endpoint-failed"
|
|
9852
|
+
};
|
|
9771
9853
|
}
|
|
9772
9854
|
}
|
|
9773
9855
|
/**
|
|
9856
|
+
* Returns true when the cached token has enough headroom before expiry to
|
|
9857
|
+
* be safely reused on reactivation. The headroom matches the refresh
|
|
9858
|
+
* buffer, so a token within the refresh window is treated as stale (the
|
|
9859
|
+
* reactive pipeline is about to refresh it anyway).
|
|
9860
|
+
*/
|
|
9861
|
+
isTokenFresh(token) {
|
|
9862
|
+
return resolveExpiresAt(token) * 1e3 - Date.now() > require_operators.DEVICE_TOKEN_REFRESH_BUFFER_MS;
|
|
9863
|
+
}
|
|
9864
|
+
/**
|
|
9774
9865
|
* Obtains a Client Bound SAT from `/api/fabric/subscriber/devices/token`.
|
|
9775
9866
|
* Returns the full {@link DeviceTokenResponse} including expiry metadata.
|
|
9776
9867
|
*/
|
|
9777
9868
|
async obtainToken() {
|
|
9778
9869
|
const dpopProof = await this.dpopManager.createHttpProof({
|
|
9779
9870
|
method: "POST",
|
|
9780
|
-
uri: DEVICE_TOKEN_ENDPOINT
|
|
9871
|
+
uri: require_operators.DEVICE_TOKEN_ENDPOINT
|
|
9781
9872
|
});
|
|
9782
9873
|
const response = await this.http.request({
|
|
9783
|
-
url: DEVICE_TOKEN_ENDPOINT,
|
|
9874
|
+
url: require_operators.DEVICE_TOKEN_ENDPOINT,
|
|
9784
9875
|
...POST_PARAMS,
|
|
9785
9876
|
body: JSON.stringify({
|
|
9786
9877
|
dpop_token: dpopProof,
|
|
9787
|
-
expire_in: DEVICE_TOKEN_DEFAULT_EXPIRE_IN
|
|
9878
|
+
expire_in: require_operators.DEVICE_TOKEN_DEFAULT_EXPIRE_IN
|
|
9788
9879
|
})
|
|
9789
9880
|
});
|
|
9790
9881
|
if (!response.ok || !response.body) throw new require_operators.DeviceTokenError(`Failed to obtain device token: ${response.status} ${response.statusText}`);
|
|
@@ -9800,14 +9891,14 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9800
9891
|
* handled by the reactive pipeline).
|
|
9801
9892
|
*/
|
|
9802
9893
|
async refreshToken(session, currentToken, updateCredential) {
|
|
9803
|
-
logger$
|
|
9894
|
+
logger$7.debug("[DeviceToken] Refreshing Client Bound SAT");
|
|
9804
9895
|
const dpopProof = await this.dpopManager.createHttpProof({
|
|
9805
9896
|
method: "POST",
|
|
9806
|
-
uri: DEVICE_REFRESH_ENDPOINT,
|
|
9897
|
+
uri: require_operators.DEVICE_REFRESH_ENDPOINT,
|
|
9807
9898
|
accessToken: currentToken
|
|
9808
9899
|
});
|
|
9809
9900
|
const response = await this.http.request({
|
|
9810
|
-
url: DEVICE_REFRESH_ENDPOINT,
|
|
9901
|
+
url: require_operators.DEVICE_REFRESH_ENDPOINT,
|
|
9811
9902
|
...POST_PARAMS,
|
|
9812
9903
|
body: JSON.stringify({
|
|
9813
9904
|
dpop_token: dpopProof,
|
|
@@ -9822,7 +9913,7 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9822
9913
|
const rpcProof = await this.dpopManager.createRpcProof({ method: "signalwire.reauthenticate" });
|
|
9823
9914
|
await session.reauthenticate(data.token, rpcProof);
|
|
9824
9915
|
updateCredential({ token: data.token });
|
|
9825
|
-
logger$
|
|
9916
|
+
logger$7.info("[DeviceToken] Client Bound SAT refreshed successfully");
|
|
9826
9917
|
return data;
|
|
9827
9918
|
}
|
|
9828
9919
|
/**
|
|
@@ -9831,18 +9922,22 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9831
9922
|
* On all retries exhausted, emits to `errorHandler`.
|
|
9832
9923
|
*/
|
|
9833
9924
|
async executeRefresh() {
|
|
9925
|
+
if (this._paused) {
|
|
9926
|
+
logger$7.debug("[DeviceToken] Manager paused, skipping refresh");
|
|
9927
|
+
return;
|
|
9928
|
+
}
|
|
9834
9929
|
if (this._refreshInProgress) {
|
|
9835
|
-
logger$
|
|
9930
|
+
logger$7.debug("[DeviceToken] Refresh already in progress, skipping");
|
|
9836
9931
|
return;
|
|
9837
9932
|
}
|
|
9838
9933
|
const session = this._session;
|
|
9839
9934
|
const updateCredential = this._updateCredential;
|
|
9840
9935
|
if (!session || !updateCredential) {
|
|
9841
|
-
logger$
|
|
9936
|
+
logger$7.warn("[DeviceToken] Cannot refresh: session or updateCredential not set");
|
|
9842
9937
|
return;
|
|
9843
9938
|
}
|
|
9844
9939
|
if (!session.authenticated) {
|
|
9845
|
-
logger$
|
|
9940
|
+
logger$7.debug("[DeviceToken] Session not authenticated, deferring refresh");
|
|
9846
9941
|
return;
|
|
9847
9942
|
}
|
|
9848
9943
|
this._refreshInProgress = true;
|
|
@@ -9852,7 +9947,7 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9852
9947
|
const newTokenData = await this.retryRefresh(session, currentToken, updateCredential);
|
|
9853
9948
|
this._currentToken$.next(newTokenData);
|
|
9854
9949
|
} catch (error) {
|
|
9855
|
-
logger$
|
|
9950
|
+
logger$7.error("[DeviceToken] Automatic Client Bound SAT refresh failed:", error);
|
|
9856
9951
|
this.errorHandler(error instanceof require_operators.TokenRefreshError ? error : new require_operators.TokenRefreshError("Automatic token refresh failed", error));
|
|
9857
9952
|
} finally {
|
|
9858
9953
|
this._refreshInProgress = false;
|
|
@@ -9864,24 +9959,221 @@ var DeviceTokenManager = class extends Destroyable {
|
|
|
9864
9959
|
*/
|
|
9865
9960
|
async retryRefresh(session, currentToken, updateCredential) {
|
|
9866
9961
|
let lastError;
|
|
9867
|
-
for (let attempt = 0; attempt < DEVICE_TOKEN_REFRESH_MAX_RETRIES; attempt++) try {
|
|
9962
|
+
for (let attempt = 0; attempt < require_operators.DEVICE_TOKEN_REFRESH_MAX_RETRIES; attempt++) try {
|
|
9868
9963
|
return await this.refreshToken(session, currentToken, updateCredential);
|
|
9869
9964
|
} catch (error) {
|
|
9870
9965
|
lastError = error;
|
|
9871
|
-
if (attempt < DEVICE_TOKEN_REFRESH_MAX_RETRIES - 1) {
|
|
9872
|
-
const delay = DEVICE_TOKEN_REFRESH_RETRY_BASE_MS * Math.pow(2, attempt);
|
|
9873
|
-
logger$
|
|
9966
|
+
if (attempt < require_operators.DEVICE_TOKEN_REFRESH_MAX_RETRIES - 1) {
|
|
9967
|
+
const delay = require_operators.DEVICE_TOKEN_REFRESH_RETRY_BASE_MS * Math.pow(2, attempt);
|
|
9968
|
+
logger$7.warn(`[DeviceToken] Refresh attempt ${attempt + 1} failed, retrying in ${delay}ms`);
|
|
9874
9969
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
9875
9970
|
}
|
|
9876
9971
|
}
|
|
9877
9972
|
throw lastError instanceof Error ? lastError : new require_operators.TokenRefreshError("All refresh retries exhausted", lastError);
|
|
9878
9973
|
}
|
|
9974
|
+
/**
|
|
9975
|
+
* Stops the reactive refresh pipeline from firing. Use when the underlying
|
|
9976
|
+
* session is being torn down (e.g., during {@link SignalWire.disconnect})
|
|
9977
|
+
* so a scheduled refresh cannot fire against a destroyed session.
|
|
9978
|
+
*
|
|
9979
|
+
* The manager's state (cached token, effective TTL, subscriptions) is
|
|
9980
|
+
* preserved — call {@link resume} to re-enable firing after reconnect.
|
|
9981
|
+
*/
|
|
9982
|
+
pause() {
|
|
9983
|
+
this._paused = true;
|
|
9984
|
+
}
|
|
9985
|
+
/** Re-enables the reactive refresh pipeline after a previous {@link pause}. */
|
|
9986
|
+
resume() {
|
|
9987
|
+
this._paused = false;
|
|
9988
|
+
}
|
|
9879
9989
|
/** Cleans up the manager, cancelling the reactive pipeline and all subscriptions. */
|
|
9880
9990
|
destroy() {
|
|
9881
9991
|
super.destroy();
|
|
9882
9992
|
}
|
|
9883
9993
|
};
|
|
9884
9994
|
|
|
9995
|
+
//#endregion
|
|
9996
|
+
//#region src/managers/CredentialRefreshCoordinator.ts
|
|
9997
|
+
const logger$6 = require_operators.getLogger();
|
|
9998
|
+
const defaultDeviceTokenManagerFactory = (dpopManager, http, errorHandler, getCredential) => new DeviceTokenManager(dpopManager, http, errorHandler, getCredential);
|
|
9999
|
+
/**
|
|
10000
|
+
* Centralizes credential-refresh ownership across the two competing
|
|
10001
|
+
* mechanisms — developer-provided `CredentialProvider.refresh()` and the
|
|
10002
|
+
* Client Bound SAT path via {@link DeviceTokenManager}.
|
|
10003
|
+
*
|
|
10004
|
+
* Maintains the invariant: **at most one refresh mechanism is armed at a
|
|
10005
|
+
* time, and at least one is armed whenever the current credential has an
|
|
10006
|
+
* `expiry_at`**.
|
|
10007
|
+
*
|
|
10008
|
+
* Replaces the previous design where refresh state was distributed across
|
|
10009
|
+
* `SignalWire` (timer field, scheduler method, activation helper) and
|
|
10010
|
+
* `DeviceTokenManager` (reactive pipeline). Centralizing the invariant in
|
|
10011
|
+
* one component eliminates the bug class that produced issue #19074.
|
|
10012
|
+
*
|
|
10013
|
+
* Race-safety:
|
|
10014
|
+
* - `_activating` flag prevents overlapping `activate()` calls from racing.
|
|
10015
|
+
* - `_activationGeneration` lets late resolutions detect they've been
|
|
10016
|
+
* preempted by a newer activation (e.g., reconnect during in-flight
|
|
10017
|
+
* `obtainToken`).
|
|
10018
|
+
*/
|
|
10019
|
+
var CredentialRefreshCoordinator = class extends Destroyable {
|
|
10020
|
+
constructor(dpopManager, deps) {
|
|
10021
|
+
super();
|
|
10022
|
+
this.deps = deps;
|
|
10023
|
+
this._activating = false;
|
|
10024
|
+
this._activationGeneration = 0;
|
|
10025
|
+
if (dpopManager?.initialized) this._deviceTokenManager = (deps.deviceTokenManagerFactory ?? defaultDeviceTokenManagerFactory)(dpopManager, deps.http, (error) => deps.notifier.onError(error), () => deps.store.read());
|
|
10026
|
+
}
|
|
10027
|
+
/** True when the Client Bound SAT path is available (DPoP initialized). */
|
|
10028
|
+
get clientBoundSATAvailable() {
|
|
10029
|
+
return this._deviceTokenManager !== void 0;
|
|
10030
|
+
}
|
|
10031
|
+
/** True when the developer-provided refresh timer is currently armed. */
|
|
10032
|
+
get developerRefreshArmed() {
|
|
10033
|
+
return this._developerTimerId !== void 0;
|
|
10034
|
+
}
|
|
10035
|
+
/**
|
|
10036
|
+
* Arms the developer-provided refresh timer to fire shortly before
|
|
10037
|
+
* `expiresAt`. Replaces any previously scheduled developer refresh.
|
|
10038
|
+
*
|
|
10039
|
+
* Idempotent — multiple calls just reschedule. On retry exhaustion,
|
|
10040
|
+
* invokes `deps.onRefreshExhausted` so the orchestrator can disconnect.
|
|
10041
|
+
*/
|
|
10042
|
+
scheduleDeveloperRefresh(provider, expiresAt, attempt = 0) {
|
|
10043
|
+
if (this._developerTimerId !== void 0) clearTimeout(this._developerTimerId);
|
|
10044
|
+
const refreshInterval = attempt === 0 ? Math.max(expiresAt - Date.now() - require_operators.CREDENTIAL_REFRESH_BUFFER_MS, 1e3) : Math.min(require_operators.CREDENTIAL_REFRESH_RETRY_BASE_MS * Math.pow(2, attempt) * (.5 + Math.random() * .5), require_operators.CREDENTIAL_REFRESH_MAX_DELAY_MS);
|
|
10045
|
+
this._developerTimerId = setTimeout(async () => {
|
|
10046
|
+
try {
|
|
10047
|
+
if (!provider.refresh) throw new require_operators.InvalidCredentialsError("Credential provider does not support refresh");
|
|
10048
|
+
const newCredentials = await provider.refresh();
|
|
10049
|
+
this.deps.store.write(newCredentials);
|
|
10050
|
+
this.deps.store.persist(newCredentials);
|
|
10051
|
+
logger$6.info("[Coordinator] Credentials refreshed successfully.");
|
|
10052
|
+
if (newCredentials.expiry_at) this.scheduleDeveloperRefresh(provider, newCredentials.expiry_at, 0);
|
|
10053
|
+
} catch (error) {
|
|
10054
|
+
const nextAttempt = attempt + 1;
|
|
10055
|
+
logger$6.error(`[Coordinator] Credential refresh failed (attempt ${nextAttempt}/${require_operators.CREDENTIAL_REFRESH_MAX_RETRIES}):`, error);
|
|
10056
|
+
this.deps.notifier.onError(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
10057
|
+
if (nextAttempt < require_operators.CREDENTIAL_REFRESH_MAX_RETRIES) this.scheduleDeveloperRefresh(provider, expiresAt, nextAttempt);
|
|
10058
|
+
else {
|
|
10059
|
+
logger$6.error("[Coordinator] Credential refresh exhausted all retries. Disconnecting.");
|
|
10060
|
+
this.deps.notifier.onError(new require_operators.TokenRefreshError("Credential refresh failed after max retries"));
|
|
10061
|
+
this.deps.notifier.onRefreshExhausted();
|
|
10062
|
+
}
|
|
10063
|
+
}
|
|
10064
|
+
}, refreshInterval);
|
|
10065
|
+
}
|
|
10066
|
+
/**
|
|
10067
|
+
* Cancels any scheduled developer-provided refresh. Idempotent.
|
|
10068
|
+
*
|
|
10069
|
+
* @internal Used by the coordinator's own activation flow. External
|
|
10070
|
+
* callers should use {@link suspend} for disconnect-time quiescence —
|
|
10071
|
+
* `suspend()` also pauses the internal Client Bound SAT pipeline.
|
|
10072
|
+
*/
|
|
10073
|
+
cancelDeveloperRefresh() {
|
|
10074
|
+
if (this._developerTimerId !== void 0) {
|
|
10075
|
+
clearTimeout(this._developerTimerId);
|
|
10076
|
+
this._developerTimerId = void 0;
|
|
10077
|
+
}
|
|
10078
|
+
}
|
|
10079
|
+
/**
|
|
10080
|
+
* Suspends both refresh paths — cancels the developer timer and pauses
|
|
10081
|
+
* the internal reactive pipeline. Use when the underlying session is
|
|
10082
|
+
* being torn down (e.g., {@link SignalWire.disconnect}). The next
|
|
10083
|
+
* {@link activate} call re-enables the internal pipeline.
|
|
10084
|
+
*
|
|
10085
|
+
* The internal manager's cached token survives — see
|
|
10086
|
+
* {@link DeviceTokenManager.pause} — so a subsequent reconnect can
|
|
10087
|
+
* skip the `/devices/token` exchange entirely.
|
|
10088
|
+
*/
|
|
10089
|
+
suspend() {
|
|
10090
|
+
this.cancelDeveloperRefresh();
|
|
10091
|
+
this._deviceTokenManager?.pause();
|
|
10092
|
+
}
|
|
10093
|
+
/**
|
|
10094
|
+
* Asks the Client Bound SAT path to take over refresh. If it accepts,
|
|
10095
|
+
* the developer-provided timer (if any) is cancelled. If it declines, the
|
|
10096
|
+
* developer timer remains armed and a `credential_refresh_fallback`
|
|
10097
|
+
* warning is emitted.
|
|
10098
|
+
*
|
|
10099
|
+
* **Idempotent** — re-entrant calls during an in-flight activation are
|
|
10100
|
+
* dropped. Use `_activationGeneration` to detect stale resolutions
|
|
10101
|
+
* (e.g., a reconnect-triggered activate() that races with an earlier one).
|
|
10102
|
+
*/
|
|
10103
|
+
async activate(user, session) {
|
|
10104
|
+
if (this._activating) {
|
|
10105
|
+
logger$6.debug("[Coordinator] activate() in flight; ignoring re-entrant call");
|
|
10106
|
+
return;
|
|
10107
|
+
}
|
|
10108
|
+
if (!this._deviceTokenManager) return;
|
|
10109
|
+
this._deviceTokenManager.resume();
|
|
10110
|
+
const generation = ++this._activationGeneration;
|
|
10111
|
+
this._activating = true;
|
|
10112
|
+
try {
|
|
10113
|
+
const result = await this.withActivationTimeout(this._deviceTokenManager.activate(user, session, (cred) => this.deps.store.merge(cred)));
|
|
10114
|
+
if (generation !== this._activationGeneration) {
|
|
10115
|
+
logger$6.debug("[Coordinator] activate() result discarded (preempted by newer activation)");
|
|
10116
|
+
return;
|
|
10117
|
+
}
|
|
10118
|
+
if (result.activated) {
|
|
10119
|
+
this.cancelDeveloperRefresh();
|
|
10120
|
+
logger$6.debug("[Coordinator] Developer refresh disabled — Client Bound SAT owns refresh");
|
|
10121
|
+
return;
|
|
10122
|
+
}
|
|
10123
|
+
logger$6.warn(`[SignalWire] [SW-REFRESH-FALLBACK] Client Bound SAT declined (reason=${result.reason}); using developer-provided refresh handler.`);
|
|
10124
|
+
this.deps.notifier.onWarning({
|
|
10125
|
+
code: "credential_refresh_fallback",
|
|
10126
|
+
source: "CredentialProvider",
|
|
10127
|
+
reason: result.reason,
|
|
10128
|
+
message: `Client Bound SAT activation declined (${result.reason}); using developer-provided refresh.`
|
|
10129
|
+
});
|
|
10130
|
+
} finally {
|
|
10131
|
+
this._activating = false;
|
|
10132
|
+
}
|
|
10133
|
+
}
|
|
10134
|
+
destroy() {
|
|
10135
|
+
this.cancelDeveloperRefresh();
|
|
10136
|
+
this._deviceTokenManager?.destroy();
|
|
10137
|
+
this._deviceTokenManager = void 0;
|
|
10138
|
+
super.destroy();
|
|
10139
|
+
}
|
|
10140
|
+
/**
|
|
10141
|
+
* Races the manager's `activate()` against a hard timeout. A wedged HTTP
|
|
10142
|
+
* layer (e.g., proxy issues) could otherwise hang the activation
|
|
10143
|
+
* indefinitely, leaving the session with no refresh mechanism while the
|
|
10144
|
+
* `_activating` guard blocks subsequent retries.
|
|
10145
|
+
*
|
|
10146
|
+
* On timeout, the manager is paused immediately. The inner `activate()`
|
|
10147
|
+
* may still complete in the background and emit to `_currentToken$`,
|
|
10148
|
+
* which would normally arm the reactive refresh pipeline; pausing
|
|
10149
|
+
* prevents that pipeline from firing while the developer refresh path
|
|
10150
|
+
* is the active mechanism — preserving the "at most one mechanism
|
|
10151
|
+
* armed" invariant. The next `activate()` call resumes the manager.
|
|
10152
|
+
*/
|
|
10153
|
+
async withActivationTimeout(inner) {
|
|
10154
|
+
return new Promise((resolve) => {
|
|
10155
|
+
const timer$3 = setTimeout(() => {
|
|
10156
|
+
this._deviceTokenManager?.pause();
|
|
10157
|
+
resolve({
|
|
10158
|
+
activated: false,
|
|
10159
|
+
reason: "activation-timeout"
|
|
10160
|
+
});
|
|
10161
|
+
}, require_operators.CREDENTIAL_ACTIVATE_TIMEOUT_MS);
|
|
10162
|
+
inner.then((result) => {
|
|
10163
|
+
clearTimeout(timer$3);
|
|
10164
|
+
resolve(result);
|
|
10165
|
+
}, (error) => {
|
|
10166
|
+
clearTimeout(timer$3);
|
|
10167
|
+
this.deps.notifier.onError(error instanceof Error ? error : new Error(String(error)));
|
|
10168
|
+
resolve({
|
|
10169
|
+
activated: false,
|
|
10170
|
+
reason: "endpoint-failed"
|
|
10171
|
+
});
|
|
10172
|
+
});
|
|
10173
|
+
});
|
|
10174
|
+
}
|
|
10175
|
+
};
|
|
10176
|
+
|
|
9885
10177
|
//#endregion
|
|
9886
10178
|
//#region src/managers/DiagnosticsCollector.ts
|
|
9887
10179
|
const logger$5 = require_operators.getLogger();
|
|
@@ -10399,6 +10691,10 @@ var TransportManager = class extends Destroyable {
|
|
|
10399
10691
|
if (!isSignalwireRequest(message)) return true;
|
|
10400
10692
|
const eventChannel = message.params.event_channel;
|
|
10401
10693
|
if (!eventChannel) return true;
|
|
10694
|
+
if (message.params.event_type.startsWith("conversation.")) {
|
|
10695
|
+
logger$2.debug(`[Transport] Received conversation event: ${message.params.event_type} (event_channel: ${eventChannel})`);
|
|
10696
|
+
return true;
|
|
10697
|
+
}
|
|
10402
10698
|
const currentProtocol = this._currentProtocol;
|
|
10403
10699
|
if (!currentProtocol) return true;
|
|
10404
10700
|
if (!eventChannel.includes(currentProtocol)) {
|
|
@@ -10591,6 +10887,7 @@ var SignalWire = class extends Destroyable {
|
|
|
10591
10887
|
this._isConnected$ = this.createBehaviorSubject(false);
|
|
10592
10888
|
this._isRegistered$ = this.createBehaviorSubject(false);
|
|
10593
10889
|
this._errors$ = this.createReplaySubject(1);
|
|
10890
|
+
this._warnings$ = this.createReplaySubject(10);
|
|
10594
10891
|
this._options = {};
|
|
10595
10892
|
this._deps = new DependencyContainer();
|
|
10596
10893
|
this._credentialProvider = credentialProvider;
|
|
@@ -10650,6 +10947,27 @@ var SignalWire = class extends Destroyable {
|
|
|
10650
10947
|
*/
|
|
10651
10948
|
async resolveCredentials() {
|
|
10652
10949
|
const fingerprint = await this.initDPoP();
|
|
10950
|
+
this._refreshCoordinator = new CredentialRefreshCoordinator(this._dpopManager, {
|
|
10951
|
+
http: this._deps.http,
|
|
10952
|
+
notifier: {
|
|
10953
|
+
onError: (error) => this._errors$.next(error),
|
|
10954
|
+
onWarning: (warning) => this._warnings$.next(warning),
|
|
10955
|
+
onRefreshExhausted: () => void this.disconnect()
|
|
10956
|
+
},
|
|
10957
|
+
store: {
|
|
10958
|
+
read: () => this._deps.credential,
|
|
10959
|
+
write: (credential) => {
|
|
10960
|
+
this._deps.credential = credential;
|
|
10961
|
+
},
|
|
10962
|
+
merge: (partial) => {
|
|
10963
|
+
this._deps.credential = {
|
|
10964
|
+
...this._deps.credential,
|
|
10965
|
+
...partial
|
|
10966
|
+
};
|
|
10967
|
+
},
|
|
10968
|
+
persist: (credential) => this.persistCredential(credential)
|
|
10969
|
+
}
|
|
10970
|
+
});
|
|
10653
10971
|
if (this._credentialProvider) return this.validateCredentials(this._credentialProvider, void 0, fingerprint);
|
|
10654
10972
|
for (const scope of this._deps.persistSession ? ["local", "session"] : ["session"]) try {
|
|
10655
10973
|
const cached = await this._deps.storage.getItem("sw:cached_credential", scope);
|
|
@@ -10679,7 +10997,16 @@ var SignalWire = class extends Destroyable {
|
|
|
10679
10997
|
logger$1.error("[SignalWire] Provided credentials have expired.");
|
|
10680
10998
|
throw new require_operators.InvalidCredentialsError("Provided credentials have expired.");
|
|
10681
10999
|
}
|
|
10682
|
-
if (_credentials.expiry_at && credentialProvider?.refresh) this.
|
|
11000
|
+
if (_credentials.expiry_at && credentialProvider?.refresh) this._refreshCoordinator?.scheduleDeveloperRefresh(credentialProvider, _credentials.expiry_at);
|
|
11001
|
+
else if (_credentials.expiry_at && !credentialProvider?.refresh) {
|
|
11002
|
+
logger$1.warn(`[SignalWire] [SW-NO-REFRESH-HANDLER] Credential has expiry_at=${_credentials.expiry_at} but no refresh handler. Session will terminate at expiry unless the SAT has 'sat:refresh' scope.`);
|
|
11003
|
+
this._warnings$.next({
|
|
11004
|
+
code: "credential_no_refresh_handler",
|
|
11005
|
+
source: "CredentialProvider",
|
|
11006
|
+
message: "Credential has expiry_at but no refresh handler. Session will terminate at expiry unless the SAT carries 'sat:refresh' scope.",
|
|
11007
|
+
expiresAt: _credentials.expiry_at
|
|
11008
|
+
});
|
|
11009
|
+
}
|
|
10683
11010
|
this._deps.credential = _credentials;
|
|
10684
11011
|
this.persistCredential(_credentials);
|
|
10685
11012
|
if (this.isConnected && this._clientSession.authenticated && _credentials.token) try {
|
|
@@ -10690,35 +11017,6 @@ var SignalWire = class extends Destroyable {
|
|
|
10690
11017
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
10691
11018
|
}
|
|
10692
11019
|
}
|
|
10693
|
-
/**
|
|
10694
|
-
* Schedules credential refresh with exponential backoff retry on failure.
|
|
10695
|
-
* On success, resets attempt counter and schedules the next refresh.
|
|
10696
|
-
* After exhausting retries, emits TokenRefreshError and disconnects.
|
|
10697
|
-
*/
|
|
10698
|
-
scheduleCredentialRefresh(credentialProvider, expiresAt, attempt = 0) {
|
|
10699
|
-
if (this._refreshTimerId !== void 0) clearTimeout(this._refreshTimerId);
|
|
10700
|
-
const refreshInterval = attempt === 0 ? Math.max(expiresAt - Date.now() - CREDENTIAL_REFRESH_BUFFER_MS, 1e3) : Math.min(CREDENTIAL_REFRESH_RETRY_BASE_MS * Math.pow(2, attempt) * (.5 + Math.random() * .5), CREDENTIAL_REFRESH_MAX_DELAY_MS);
|
|
10701
|
-
this._refreshTimerId = setTimeout(async () => {
|
|
10702
|
-
try {
|
|
10703
|
-
if (!credentialProvider.refresh) throw new require_operators.InvalidCredentialsError("Credential provider does not support refresh");
|
|
10704
|
-
const newCredentials = await credentialProvider.refresh();
|
|
10705
|
-
this._deps.credential = newCredentials;
|
|
10706
|
-
this.persistCredential(newCredentials);
|
|
10707
|
-
logger$1.info("[SignalWire] Credentials refreshed successfully.");
|
|
10708
|
-
if (newCredentials.expiry_at) this.scheduleCredentialRefresh(credentialProvider, newCredentials.expiry_at, 0);
|
|
10709
|
-
} catch (error) {
|
|
10710
|
-
const nextAttempt = attempt + 1;
|
|
10711
|
-
logger$1.error(`[SignalWire] Credential refresh failed (attempt ${nextAttempt}/${CREDENTIAL_REFRESH_MAX_RETRIES}):`, error);
|
|
10712
|
-
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
10713
|
-
if (nextAttempt < CREDENTIAL_REFRESH_MAX_RETRIES) this.scheduleCredentialRefresh(credentialProvider, expiresAt, nextAttempt);
|
|
10714
|
-
else {
|
|
10715
|
-
logger$1.error("[SignalWire] Credential refresh exhausted all retries. Disconnecting.");
|
|
10716
|
-
this._errors$.next(new require_operators.TokenRefreshError("Credential refresh failed after max retries"));
|
|
10717
|
-
this.disconnect();
|
|
10718
|
-
}
|
|
10719
|
-
}
|
|
10720
|
-
}, refreshInterval);
|
|
10721
|
-
}
|
|
10722
11020
|
/** Persist credential to localStorage when persistSession is enabled. */
|
|
10723
11021
|
persistCredential(credential) {
|
|
10724
11022
|
if (!credential.token) return;
|
|
@@ -10812,6 +11110,7 @@ var SignalWire = class extends Destroyable {
|
|
|
10812
11110
|
logger$1.debug("[SignalWire] Credential expired, refreshing before reconnect");
|
|
10813
11111
|
const newCredentials = await this._credentialProvider.authenticate(fingerprint ? { fingerprint } : void 0);
|
|
10814
11112
|
this._deps.credential = newCredentials;
|
|
11113
|
+
if (newCredentials.expiry_at && this._credentialProvider.refresh) this._refreshCoordinator?.scheduleDeveloperRefresh(this._credentialProvider, newCredentials.expiry_at);
|
|
10815
11114
|
logger$1.debug("[SignalWire] Credential refreshed successfully for reconnect");
|
|
10816
11115
|
} catch (error) {
|
|
10817
11116
|
logger$1.error("[SignalWire] Failed to refresh credentials for reconnect:", error);
|
|
@@ -10823,33 +11122,12 @@ var SignalWire = class extends Destroyable {
|
|
|
10823
11122
|
this._errors$.next(error);
|
|
10824
11123
|
});
|
|
10825
11124
|
await this._clientSession.connect();
|
|
10826
|
-
|
|
10827
|
-
if (this._refreshTimerId) {
|
|
10828
|
-
clearTimeout(this._refreshTimerId);
|
|
10829
|
-
this._refreshTimerId = void 0;
|
|
10830
|
-
logger$1.debug("[SignalWire] Developer refresh disabled — Client Bound SAT activation starting");
|
|
10831
|
-
}
|
|
10832
|
-
this._deviceTokenManager = new DeviceTokenManager(this._dpopManager, this._deps.http, (error) => this._errors$.next(error), () => this._deps.credential);
|
|
10833
|
-
await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
|
|
10834
|
-
this._deps.credential = {
|
|
10835
|
-
...this._deps.credential,
|
|
10836
|
-
...cred
|
|
10837
|
-
};
|
|
10838
|
-
});
|
|
10839
|
-
}
|
|
11125
|
+
await this._refreshCoordinator?.activate(this._deps.user, this._clientSession);
|
|
10840
11126
|
this.subscribeTo(this._clientSession.authenticated$.pipe((0, rxjs.skip)(1), (0, rxjs.filter)(Boolean)), async () => {
|
|
10841
11127
|
try {
|
|
10842
|
-
|
|
10843
|
-
await this._deviceTokenManager.activate(this._deps.user, this._clientSession, (cred) => {
|
|
10844
|
-
this._deps.credential = {
|
|
10845
|
-
...this._deps.credential,
|
|
10846
|
-
...cred
|
|
10847
|
-
};
|
|
10848
|
-
});
|
|
10849
|
-
logger$1.debug("[SignalWire] Client Bound SAT re-activated after reconnect");
|
|
10850
|
-
}
|
|
11128
|
+
await this._refreshCoordinator?.activate(this._deps.user, this._clientSession);
|
|
10851
11129
|
} catch (error) {
|
|
10852
|
-
logger$1.error("[SignalWire]
|
|
11130
|
+
logger$1.error("[SignalWire] Refresh re-arm after reconnect failed (non-fatal):", error);
|
|
10853
11131
|
this._errors$.next(error instanceof Error ? error : new Error(String(error), { cause: error }));
|
|
10854
11132
|
}
|
|
10855
11133
|
try {
|
|
@@ -10935,6 +11213,19 @@ var SignalWire = class extends Destroyable {
|
|
|
10935
11213
|
get errors$() {
|
|
10936
11214
|
return this.deferEmission(this._errors$.asObservable());
|
|
10937
11215
|
}
|
|
11216
|
+
/**
|
|
11217
|
+
* Observable stream of non-fatal SDK warnings.
|
|
11218
|
+
*
|
|
11219
|
+
* Subscribe to detect SDK behaviors that affect session liveness or developer-facing
|
|
11220
|
+
* contracts but do not warrant disconnection — e.g., a fallback from Client Bound SAT
|
|
11221
|
+
* refresh to the developer-provided `refresh()` because the SAT lacks `sat:refresh`
|
|
11222
|
+
* scope. Discriminated by `code`.
|
|
11223
|
+
*
|
|
11224
|
+
* Independent from {@link errors$}: existing error consumers are not notified.
|
|
11225
|
+
*/
|
|
11226
|
+
get warnings$() {
|
|
11227
|
+
return this.deferEmission(this._warnings$.asObservable());
|
|
11228
|
+
}
|
|
10938
11229
|
/** Platform WebRTC capabilities detected at construction time. */
|
|
10939
11230
|
get platformCapabilities() {
|
|
10940
11231
|
this._platformCapabilities ??= detectPlatformCapabilities(this._options.webRTCApiProvider);
|
|
@@ -11003,7 +11294,7 @@ var SignalWire = class extends Destroyable {
|
|
|
11003
11294
|
logger$1.warn("[SignalWire] Failed to initialize VisibilityController:", error);
|
|
11004
11295
|
}
|
|
11005
11296
|
try {
|
|
11006
|
-
this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "
|
|
11297
|
+
this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "4.0.0-rc.1" });
|
|
11007
11298
|
} catch (error) {
|
|
11008
11299
|
logger$1.warn("[SignalWire] Failed to initialize DiagnosticsCollector:", error);
|
|
11009
11300
|
}
|
|
@@ -11011,14 +11302,19 @@ var SignalWire = class extends Destroyable {
|
|
|
11011
11302
|
/**
|
|
11012
11303
|
* Disconnects the WebSocket and tears down the current session.
|
|
11013
11304
|
*
|
|
11305
|
+
* Ends the session identified by the protocol and clears its persisted
|
|
11306
|
+
* resume state (`authorization_state` + protocol) and attach records
|
|
11307
|
+
* together — a later {@link connect} with the same credentials starts a
|
|
11308
|
+
* fresh session and cannot reattach to the ended session's calls.
|
|
11309
|
+
* Credentials and device preferences are preserved. To temporarily stop
|
|
11310
|
+
* receiving inbound calls while keeping the session alive, use
|
|
11311
|
+
* `unregister()` instead.
|
|
11312
|
+
*
|
|
11014
11313
|
* The client can be reconnected by calling {@link connect} again,
|
|
11015
11314
|
* which creates a fresh transport and session.
|
|
11016
11315
|
*/
|
|
11017
11316
|
async disconnect() {
|
|
11018
|
-
|
|
11019
|
-
clearTimeout(this._refreshTimerId);
|
|
11020
|
-
this._refreshTimerId = void 0;
|
|
11021
|
-
}
|
|
11317
|
+
this._refreshCoordinator?.suspend();
|
|
11022
11318
|
this._diagnosticsCollector?.record("connection", "disconnected");
|
|
11023
11319
|
await this.teardownTransportAndSession();
|
|
11024
11320
|
this._isConnected$.next(false);
|
|
@@ -11405,15 +11701,20 @@ var SignalWire = class extends Destroyable {
|
|
|
11405
11701
|
prefs.preferredVideoInput = null;
|
|
11406
11702
|
await this._deviceController.clearDeviceState();
|
|
11407
11703
|
}
|
|
11408
|
-
/**
|
|
11704
|
+
/**
|
|
11705
|
+
* Destroys the client, clearing timers and releasing all resources.
|
|
11706
|
+
*
|
|
11707
|
+
* Intentionally destroying the client ends its session: the resume state
|
|
11708
|
+
* (`authorization_state` + protocol) and the attach records are both
|
|
11709
|
+
* cleared. Credentials and device preferences are preserved — use
|
|
11710
|
+
* {@link resetToDefaults} for a full wipe. To temporarily stop receiving
|
|
11711
|
+
* inbound calls while keeping the session alive, use `unregister()`.
|
|
11712
|
+
*/
|
|
11409
11713
|
destroy() {
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
this._refreshTimerId = void 0;
|
|
11413
|
-
}
|
|
11414
|
-
this._deviceTokenManager?.destroy();
|
|
11714
|
+
this._refreshCoordinator?.destroy();
|
|
11715
|
+
this._refreshCoordinator = void 0;
|
|
11415
11716
|
this._dpopManager?.destroy();
|
|
11416
|
-
|
|
11717
|
+
this._clientSession.teardownSessionState();
|
|
11417
11718
|
this._transport.destroy();
|
|
11418
11719
|
this._clientSession.destroy();
|
|
11419
11720
|
try {
|
|
@@ -11527,7 +11828,7 @@ var StaticCredentialProvider = class {
|
|
|
11527
11828
|
/**
|
|
11528
11829
|
* Library version from package.json, injected at build time.
|
|
11529
11830
|
*/
|
|
11530
|
-
const version = "
|
|
11831
|
+
const version = "4.0.0-rc.1";
|
|
11531
11832
|
/**
|
|
11532
11833
|
* Flag indicating the library has been loaded and is ready to use.
|
|
11533
11834
|
* For UMD builds: `window.SignalWire.ready`
|
|
@@ -11549,7 +11850,7 @@ const ready = true;
|
|
|
11549
11850
|
*/
|
|
11550
11851
|
const emitReadyEvent = () => {
|
|
11551
11852
|
if (typeof window !== "undefined") {
|
|
11552
|
-
const event = new CustomEvent("signalwire:js:ready", { detail: { version: "
|
|
11853
|
+
const event = new CustomEvent("signalwire:js:ready", { detail: { version: "4.0.0-rc.1" } });
|
|
11553
11854
|
window.dispatchEvent(event);
|
|
11554
11855
|
}
|
|
11555
11856
|
};
|
|
@@ -11564,6 +11865,7 @@ exports.DPoPInitError = require_operators.DPoPInitError;
|
|
|
11564
11865
|
exports.DeviceTokenError = require_operators.DeviceTokenError;
|
|
11565
11866
|
exports.EmbedTokenCredentialProvider = EmbedTokenCredentialProvider;
|
|
11566
11867
|
exports.InvalidCredentialsError = require_operators.InvalidCredentialsError;
|
|
11868
|
+
exports.MediaAccessError = require_operators.MediaAccessError;
|
|
11567
11869
|
exports.MediaTrackError = require_operators.MediaTrackError;
|
|
11568
11870
|
exports.MessageParseError = require_operators.MessageParseError;
|
|
11569
11871
|
exports.OverconstrainedFallbackError = require_operators.OverconstrainedFallbackError;
|