livekit-client 1.13.0 → 1.13.2
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/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +122 -105
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +172 -109
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +4 -3
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/KeyProvider.d.ts +7 -6
- package/dist/src/e2ee/KeyProvider.d.ts.map +1 -1
- package/dist/src/e2ee/events.d.ts +34 -0
- package/dist/src/e2ee/events.d.ts.map +1 -0
- package/dist/src/e2ee/index.d.ts +1 -0
- package/dist/src/e2ee/index.d.ts.map +1 -1
- package/dist/src/e2ee/types.d.ts +17 -33
- package/dist/src/e2ee/types.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +15 -12
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +6 -8
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +1 -0
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/processor/types.d.ts +2 -1
- package/dist/src/room/track/processor/types.d.ts.map +1 -1
- package/dist/ts4.2/src/e2ee/E2eeManager.d.ts +4 -3
- package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +7 -6
- package/dist/ts4.2/src/e2ee/events.d.ts +34 -0
- package/dist/ts4.2/src/e2ee/index.d.ts +1 -0
- package/dist/ts4.2/src/e2ee/types.d.ts +17 -33
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +15 -12
- package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +6 -8
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -0
- package/dist/ts4.2/src/room/track/processor/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/e2ee/E2eeManager.ts +105 -77
- package/src/e2ee/KeyProvider.ts +23 -13
- package/src/e2ee/events.ts +48 -0
- package/src/e2ee/index.ts +1 -0
- package/src/e2ee/types.ts +19 -41
- package/src/e2ee/worker/FrameCryptor.ts +51 -43
- package/src/e2ee/worker/ParticipantKeyHandler.ts +25 -27
- package/src/e2ee/worker/e2ee.worker.ts +61 -68
- package/src/room/PCTransport.ts +12 -2
- package/src/room/RTCEngine.ts +0 -1
- package/src/room/Room.ts +20 -15
- package/src/room/participant/LocalParticipant.ts +5 -1
- package/src/room/track/LocalTrack.ts +18 -10
- package/src/room/track/facingMode.ts +1 -1
- package/src/room/track/processor/types.ts +2 -1
@@ -285,7 +285,6 @@ var loglevel = {exports: {}};
|
|
285
285
|
});
|
286
286
|
})(loglevel);
|
287
287
|
var loglevelExports = loglevel.exports;
|
288
|
-
var log$1 = /*@__PURE__*/getDefaultExportFromCjs(loglevelExports);
|
289
288
|
|
290
289
|
var LogLevel;
|
291
290
|
(function (LogLevel) {
|
@@ -11841,7 +11840,7 @@ function getMatch(exp, ua) {
|
|
11841
11840
|
return match && match.length >= id && match[id] || '';
|
11842
11841
|
}
|
11843
11842
|
|
11844
|
-
var version$1 = "1.13.
|
11843
|
+
var version$1 = "1.13.2";
|
11845
11844
|
|
11846
11845
|
const version = version$1;
|
11847
11846
|
const protocolVersion = 9;
|
@@ -13916,6 +13915,26 @@ const KEY_PROVIDER_DEFAULTS = {
|
|
13916
13915
|
failureTolerance: DECRYPTION_FAILURE_TOLERANCE
|
13917
13916
|
};
|
13918
13917
|
|
13918
|
+
var KeyProviderEvent;
|
13919
|
+
(function (KeyProviderEvent) {
|
13920
|
+
KeyProviderEvent["SetKey"] = "setKey";
|
13921
|
+
KeyProviderEvent["RatchetRequest"] = "ratchetRequest";
|
13922
|
+
KeyProviderEvent["KeyRatcheted"] = "keyRatcheted";
|
13923
|
+
})(KeyProviderEvent || (KeyProviderEvent = {}));
|
13924
|
+
var KeyHandlerEvent;
|
13925
|
+
(function (KeyHandlerEvent) {
|
13926
|
+
KeyHandlerEvent["KeyRatcheted"] = "keyRatcheted";
|
13927
|
+
})(KeyHandlerEvent || (KeyHandlerEvent = {}));
|
13928
|
+
var EncryptionEvent;
|
13929
|
+
(function (EncryptionEvent) {
|
13930
|
+
EncryptionEvent["ParticipantEncryptionStatusChanged"] = "participantEncryptionStatusChanged";
|
13931
|
+
EncryptionEvent["EncryptionError"] = "encryptionError";
|
13932
|
+
})(EncryptionEvent || (EncryptionEvent = {}));
|
13933
|
+
var CryptorEvent;
|
13934
|
+
(function (CryptorEvent) {
|
13935
|
+
CryptorEvent["Error"] = "cryptorError";
|
13936
|
+
})(CryptorEvent || (CryptorEvent = {}));
|
13937
|
+
|
13919
13938
|
function isE2EESupported() {
|
13920
13939
|
return isInsertableStreamSupported() || isScriptTransformSupported();
|
13921
13940
|
}
|
@@ -14029,32 +14048,35 @@ class BaseKeyProvider extends eventsExports.EventEmitter {
|
|
14029
14048
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
14030
14049
|
super();
|
14031
14050
|
/**
|
14032
|
-
* callback being invoked after a ratchet request has been performed on
|
14051
|
+
* callback being invoked after a ratchet request has been performed on a participant
|
14033
14052
|
* that surfaces the new key material.
|
14034
14053
|
* @param material
|
14035
14054
|
* @param keyIndex
|
14036
14055
|
*/
|
14037
14056
|
this.onKeyRatcheted = (material, keyIndex) => {
|
14038
|
-
|
14057
|
+
livekitLogger.debug('key ratcheted event received', {
|
14058
|
+
material,
|
14059
|
+
keyIndex
|
14060
|
+
});
|
14039
14061
|
};
|
14040
14062
|
this.keyInfoMap = new Map();
|
14041
14063
|
this.options = Object.assign(Object.assign({}, KEY_PROVIDER_DEFAULTS), options);
|
14042
|
-
this.on(
|
14064
|
+
this.on(KeyProviderEvent.KeyRatcheted, this.onKeyRatcheted);
|
14043
14065
|
}
|
14044
14066
|
/**
|
14045
14067
|
* callback to invoke once a key has been set for a participant
|
14046
14068
|
* @param key
|
14047
|
-
* @param
|
14069
|
+
* @param participantIdentity
|
14048
14070
|
* @param keyIndex
|
14049
14071
|
*/
|
14050
|
-
onSetEncryptionKey(key,
|
14072
|
+
onSetEncryptionKey(key, participantIdentity, keyIndex) {
|
14051
14073
|
const keyInfo = {
|
14052
14074
|
key,
|
14053
|
-
|
14075
|
+
participantIdentity,
|
14054
14076
|
keyIndex
|
14055
14077
|
};
|
14056
|
-
this.keyInfoMap.set("".concat(
|
14057
|
-
this.emit(
|
14078
|
+
this.keyInfoMap.set("".concat(participantIdentity !== null && participantIdentity !== void 0 ? participantIdentity : 'shared', "-").concat(keyIndex !== null && keyIndex !== void 0 ? keyIndex : 0), keyInfo);
|
14079
|
+
this.emit(KeyProviderEvent.SetKey, keyInfo);
|
14058
14080
|
}
|
14059
14081
|
getKeys() {
|
14060
14082
|
return Array.from(this.keyInfoMap.values());
|
@@ -14062,8 +14084,8 @@ class BaseKeyProvider extends eventsExports.EventEmitter {
|
|
14062
14084
|
getOptions() {
|
14063
14085
|
return this.options;
|
14064
14086
|
}
|
14065
|
-
ratchetKey(
|
14066
|
-
this.emit(
|
14087
|
+
ratchetKey(participantIdentity, keyIndex) {
|
14088
|
+
this.emit(KeyProviderEvent.RatchetRequest, participantIdentity, keyIndex);
|
14067
14089
|
}
|
14068
14090
|
}
|
14069
14091
|
/**
|
@@ -14075,14 +14097,19 @@ class ExternalE2EEKeyProvider extends BaseKeyProvider {
|
|
14075
14097
|
constructor() {
|
14076
14098
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
14077
14099
|
const opts = Object.assign(Object.assign({}, options), {
|
14078
|
-
sharedKey: true
|
14100
|
+
sharedKey: true,
|
14101
|
+
// for a shared key provider failing to decrypt for a specific participant
|
14102
|
+
// should not mark the key as invalid, so we accept wrong keys forever
|
14103
|
+
// and won't try to auto-ratchet
|
14104
|
+
ratchetWindowSize: 0,
|
14105
|
+
failureTolerance: -1
|
14079
14106
|
});
|
14080
14107
|
super(opts);
|
14081
14108
|
}
|
14082
14109
|
/**
|
14083
14110
|
* Accepts a passphrase that's used to create the crypto keys.
|
14084
14111
|
* When passing in a string, PBKDF2 is used.
|
14085
|
-
*
|
14112
|
+
* When passing in an Array buffer of cryptographically random numbers, HKDF is being used. (recommended)
|
14086
14113
|
* @param key
|
14087
14114
|
*/
|
14088
14115
|
setKey(key) {
|
@@ -14093,14 +14120,6 @@ class ExternalE2EEKeyProvider extends BaseKeyProvider {
|
|
14093
14120
|
}
|
14094
14121
|
}
|
14095
14122
|
|
14096
|
-
const EncryptionEvent = {
|
14097
|
-
ParticipantEncryptionStatusChanged: 'participantEncryptionStatusChanged',
|
14098
|
-
Error: 'encryptionError'
|
14099
|
-
};
|
14100
|
-
const CryptorEvent = {
|
14101
|
-
Error: 'cryptorError'
|
14102
|
-
};
|
14103
|
-
|
14104
14123
|
function r(r, e, n) {
|
14105
14124
|
var i, t, o;
|
14106
14125
|
void 0 === e && (e = 50), void 0 === n && (n = {});
|
@@ -14317,8 +14336,22 @@ class LocalTrack extends Track {
|
|
14317
14336
|
newTrack.addEventListener('unmute', this.handleTrackUnmuteEvent);
|
14318
14337
|
this._constraints = newTrack.getConstraints();
|
14319
14338
|
}
|
14339
|
+
let processedTrack;
|
14340
|
+
if (this.processor && newTrack && this.processorElement) {
|
14341
|
+
livekitLogger.debug('restarting processor');
|
14342
|
+
if (this.kind === 'unknown') {
|
14343
|
+
throw TypeError('cannot set processor on track of unknown kind');
|
14344
|
+
}
|
14345
|
+
attachToElement(newTrack, this.processorElement);
|
14346
|
+
yield this.processor.restart({
|
14347
|
+
track: newTrack,
|
14348
|
+
kind: this.kind,
|
14349
|
+
element: this.processorElement
|
14350
|
+
});
|
14351
|
+
processedTrack = this.processor.processedTrack;
|
14352
|
+
}
|
14320
14353
|
if (this.sender) {
|
14321
|
-
yield this.sender.replaceTrack(newTrack);
|
14354
|
+
yield this.sender.replaceTrack(processedTrack !== null && processedTrack !== void 0 ? processedTrack : newTrack);
|
14322
14355
|
}
|
14323
14356
|
this._mediaStreamTrack = newTrack;
|
14324
14357
|
if (newTrack) {
|
@@ -14327,7 +14360,7 @@ class LocalTrack extends Track {
|
|
14327
14360
|
// when a valid track is replace, we'd want to start producing
|
14328
14361
|
yield this.resumeUpstream();
|
14329
14362
|
this.attachedElements.forEach(el => {
|
14330
|
-
attachToElement(newTrack, el);
|
14363
|
+
attachToElement(processedTrack !== null && processedTrack !== void 0 ? processedTrack : newTrack, el);
|
14331
14364
|
});
|
14332
14365
|
}
|
14333
14366
|
});
|
@@ -14427,14 +14460,6 @@ class LocalTrack extends Track {
|
|
14427
14460
|
livekitLogger.debug('re-acquired MediaStreamTrack');
|
14428
14461
|
yield this.setMediaStreamTrack(newTrack);
|
14429
14462
|
this._constraints = constraints;
|
14430
|
-
if (this.processor) {
|
14431
|
-
const processor = this.processor;
|
14432
|
-
yield this.setProcessor(processor);
|
14433
|
-
} else {
|
14434
|
-
this.attachedElements.forEach(el => {
|
14435
|
-
attachToElement(this._mediaStreamTrack, el);
|
14436
|
-
});
|
14437
|
-
}
|
14438
14463
|
this.emit(TrackEvent.Restarted, this);
|
14439
14464
|
return this;
|
14440
14465
|
});
|
@@ -14606,9 +14631,6 @@ class LocalTrack extends Track {
|
|
14606
14631
|
* @experimental
|
14607
14632
|
*/
|
14608
14633
|
class E2EEManager extends eventsExports.EventEmitter {
|
14609
|
-
get isEnabled() {
|
14610
|
-
return this.encryptionEnabled;
|
14611
|
-
}
|
14612
14634
|
constructor(options) {
|
14613
14635
|
super();
|
14614
14636
|
this.onWorkerMessage = ev => {
|
@@ -14619,17 +14641,25 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14619
14641
|
} = ev.data;
|
14620
14642
|
switch (kind) {
|
14621
14643
|
case 'error':
|
14622
|
-
|
14623
|
-
|
14624
|
-
|
14625
|
-
|
14644
|
+
livekitLogger.error(data.error.message);
|
14645
|
+
this.emit(EncryptionEvent.EncryptionError, data.error);
|
14646
|
+
break;
|
14647
|
+
case 'initAck':
|
14648
|
+
if (data.enabled) {
|
14649
|
+
this.keyProvider.getKeys().forEach(keyInfo => {
|
14650
|
+
this.postKey(keyInfo);
|
14651
|
+
});
|
14652
|
+
}
|
14626
14653
|
break;
|
14627
14654
|
case 'enable':
|
14628
|
-
if (this.encryptionEnabled !== data.enabled &&
|
14629
|
-
this.emit(EncryptionEvent.ParticipantEncryptionStatusChanged, data.enabled,
|
14655
|
+
if (this.encryptionEnabled !== data.enabled && data.participantIdentity === ((_a = this.room) === null || _a === void 0 ? void 0 : _a.localParticipant.identity)) {
|
14656
|
+
this.emit(EncryptionEvent.ParticipantEncryptionStatusChanged, data.enabled, this.room.localParticipant);
|
14630
14657
|
this.encryptionEnabled = data.enabled;
|
14631
|
-
} else if (data.
|
14632
|
-
const participant = (_b = this.room) === null || _b === void 0 ? void 0 : _b.getParticipantByIdentity(data.
|
14658
|
+
} else if (data.participantIdentity) {
|
14659
|
+
const participant = (_b = this.room) === null || _b === void 0 ? void 0 : _b.getParticipantByIdentity(data.participantIdentity);
|
14660
|
+
if (!participant) {
|
14661
|
+
throw TypeError("couldn't set encryption status, participant not found".concat(data.participantIdentity));
|
14662
|
+
}
|
14633
14663
|
this.emit(EncryptionEvent.ParticipantEncryptionStatusChanged, data.enabled, participant);
|
14634
14664
|
}
|
14635
14665
|
if (this.encryptionEnabled) {
|
@@ -14639,7 +14669,7 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14639
14669
|
}
|
14640
14670
|
break;
|
14641
14671
|
case 'ratchetKey':
|
14642
|
-
this.keyProvider.emit(
|
14672
|
+
this.keyProvider.emit(KeyProviderEvent.KeyRatcheted, data.material, data.keyIndex);
|
14643
14673
|
break;
|
14644
14674
|
}
|
14645
14675
|
};
|
@@ -14647,7 +14677,7 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14647
14677
|
livekitLogger.error('e2ee worker encountered an error:', {
|
14648
14678
|
error: ev.error
|
14649
14679
|
});
|
14650
|
-
this.emit(EncryptionEvent.
|
14680
|
+
this.emit(EncryptionEvent.EncryptionError, ev.error);
|
14651
14681
|
};
|
14652
14682
|
this.keyProvider = options.keyProvider;
|
14653
14683
|
this.worker = options.worker;
|
@@ -14684,22 +14714,9 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14684
14714
|
/**
|
14685
14715
|
* @internal
|
14686
14716
|
*/
|
14687
|
-
setParticipantCryptorEnabled(enabled,
|
14688
|
-
|
14689
|
-
|
14690
|
-
if (this.worker) {
|
14691
|
-
const enableMsg = {
|
14692
|
-
kind: 'enable',
|
14693
|
-
data: {
|
14694
|
-
enabled,
|
14695
|
-
participantId
|
14696
|
-
}
|
14697
|
-
};
|
14698
|
-
this.worker.postMessage(enableMsg);
|
14699
|
-
} else {
|
14700
|
-
throw new ReferenceError('failed to enable e2ee, worker is not ready');
|
14701
|
-
}
|
14702
|
-
});
|
14717
|
+
setParticipantCryptorEnabled(enabled, participantIdentity) {
|
14718
|
+
livekitLogger.debug("set e2ee to ".concat(enabled, " for participant ").concat(participantIdentity));
|
14719
|
+
this.postEnable(enabled, participantIdentity);
|
14703
14720
|
}
|
14704
14721
|
/**
|
14705
14722
|
* @internal
|
@@ -14726,34 +14743,40 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14726
14743
|
});
|
14727
14744
|
});
|
14728
14745
|
}
|
14729
|
-
})
|
14730
|
-
room.on(RoomEvent.TrackUnsubscribed, (track, _, participant) => {
|
14746
|
+
}).on(RoomEvent.TrackUnsubscribed, (track, _, participant) => {
|
14731
14747
|
var _a;
|
14732
14748
|
const msg = {
|
14733
14749
|
kind: 'removeTransform',
|
14734
14750
|
data: {
|
14735
|
-
|
14751
|
+
participantIdentity: participant.identity,
|
14736
14752
|
trackId: track.mediaStreamID
|
14737
14753
|
}
|
14738
14754
|
};
|
14739
14755
|
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage(msg);
|
14740
|
-
})
|
14741
|
-
room.on(RoomEvent.TrackSubscribed, (track, pub, participant) => {
|
14756
|
+
}).on(RoomEvent.TrackSubscribed, (track, pub, participant) => {
|
14742
14757
|
this.setupE2EEReceiver(track, participant.identity, pub.trackInfo);
|
14758
|
+
}).on(RoomEvent.SignalConnected, () => {
|
14759
|
+
if (!this.room) {
|
14760
|
+
throw new TypeError("expected room to be present on signal connect");
|
14761
|
+
}
|
14762
|
+
this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled, this.room.localParticipant.identity);
|
14763
|
+
keyProvider.getKeys().forEach(keyInfo => {
|
14764
|
+
this.postKey(keyInfo);
|
14765
|
+
});
|
14743
14766
|
});
|
14744
14767
|
room.localParticipant.on(ParticipantEvent.LocalTrackPublished, publication => __awaiter(this, void 0, void 0, function* () {
|
14745
|
-
this.setupE2EESender(publication.track, publication.track.sender
|
14768
|
+
this.setupE2EESender(publication.track, publication.track.sender);
|
14746
14769
|
}));
|
14747
|
-
keyProvider.on(
|
14770
|
+
keyProvider.on(KeyProviderEvent.SetKey, keyInfo => this.postKey(keyInfo)).on(KeyProviderEvent.RatchetRequest, (participantId, keyIndex) => this.postRatchetRequest(participantId, keyIndex));
|
14748
14771
|
}
|
14749
|
-
postRatchetRequest(
|
14772
|
+
postRatchetRequest(participantIdentity, keyIndex) {
|
14750
14773
|
if (!this.worker) {
|
14751
14774
|
throw Error('could not ratchet key, worker is missing');
|
14752
14775
|
}
|
14753
14776
|
const msg = {
|
14754
14777
|
kind: 'ratchetRequest',
|
14755
14778
|
data: {
|
14756
|
-
|
14779
|
+
participantIdentity: participantIdentity,
|
14757
14780
|
keyIndex
|
14758
14781
|
}
|
14759
14782
|
};
|
@@ -14762,30 +14785,51 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14762
14785
|
postKey(_ref) {
|
14763
14786
|
let {
|
14764
14787
|
key,
|
14765
|
-
|
14788
|
+
participantIdentity,
|
14766
14789
|
keyIndex
|
14767
14790
|
} = _ref;
|
14791
|
+
var _a;
|
14768
14792
|
if (!this.worker) {
|
14769
14793
|
throw Error('could not set key, worker is missing');
|
14770
14794
|
}
|
14771
14795
|
const msg = {
|
14772
14796
|
kind: 'setKey',
|
14773
14797
|
data: {
|
14774
|
-
|
14798
|
+
participantIdentity: participantIdentity,
|
14799
|
+
isPublisher: participantIdentity === ((_a = this.room) === null || _a === void 0 ? void 0 : _a.localParticipant.identity),
|
14775
14800
|
key,
|
14776
14801
|
keyIndex
|
14777
14802
|
}
|
14778
14803
|
};
|
14779
14804
|
this.worker.postMessage(msg);
|
14780
14805
|
}
|
14806
|
+
postEnable(enabled, participantIdentity) {
|
14807
|
+
if (this.worker) {
|
14808
|
+
const enableMsg = {
|
14809
|
+
kind: 'enable',
|
14810
|
+
data: {
|
14811
|
+
enabled,
|
14812
|
+
participantIdentity
|
14813
|
+
}
|
14814
|
+
};
|
14815
|
+
this.worker.postMessage(enableMsg);
|
14816
|
+
} else {
|
14817
|
+
throw new ReferenceError('failed to enable e2ee, worker is not ready');
|
14818
|
+
}
|
14819
|
+
}
|
14781
14820
|
postRTPMap(map) {
|
14821
|
+
var _a;
|
14782
14822
|
if (!this.worker) {
|
14783
|
-
throw
|
14823
|
+
throw TypeError('could not post rtp map, worker is missing');
|
14824
|
+
}
|
14825
|
+
if (!((_a = this.room) === null || _a === void 0 ? void 0 : _a.localParticipant.identity)) {
|
14826
|
+
throw TypeError('could not post rtp map, local participant identity is missing');
|
14784
14827
|
}
|
14785
14828
|
const msg = {
|
14786
14829
|
kind: 'setRTPMap',
|
14787
14830
|
data: {
|
14788
|
-
map
|
14831
|
+
map,
|
14832
|
+
participantIdentity: this.room.localParticipant.identity
|
14789
14833
|
}
|
14790
14834
|
};
|
14791
14835
|
this.worker.postMessage(msg);
|
@@ -14811,19 +14855,19 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14811
14855
|
}
|
14812
14856
|
this.handleReceiver(track.receiver, track.mediaStreamID, remoteId, track.kind === 'video' ? mimeTypeToVideoCodecString(trackInfo.mimeType) : undefined);
|
14813
14857
|
}
|
14814
|
-
setupE2EESender(track, sender
|
14858
|
+
setupE2EESender(track, sender) {
|
14815
14859
|
if (!(track instanceof LocalTrack) || !sender) {
|
14816
14860
|
if (!sender) livekitLogger.warn('early return because sender is not ready');
|
14817
14861
|
return;
|
14818
14862
|
}
|
14819
|
-
this.handleSender(sender, track.mediaStreamID,
|
14863
|
+
this.handleSender(sender, track.mediaStreamID, undefined);
|
14820
14864
|
}
|
14821
14865
|
/**
|
14822
14866
|
* Handles the given {@code RTCRtpReceiver} by creating a {@code TransformStream} which will inject
|
14823
14867
|
* a frame decoder.
|
14824
14868
|
*
|
14825
14869
|
*/
|
14826
|
-
handleReceiver(receiver, trackId,
|
14870
|
+
handleReceiver(receiver, trackId, participantIdentity, codec) {
|
14827
14871
|
return __awaiter(this, void 0, void 0, function* () {
|
14828
14872
|
if (!this.worker) {
|
14829
14873
|
return;
|
@@ -14831,7 +14875,7 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14831
14875
|
if (isScriptTransformSupported()) {
|
14832
14876
|
const options = {
|
14833
14877
|
kind: 'decode',
|
14834
|
-
|
14878
|
+
participantIdentity,
|
14835
14879
|
trackId,
|
14836
14880
|
codec
|
14837
14881
|
};
|
@@ -14845,7 +14889,7 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14845
14889
|
data: {
|
14846
14890
|
trackId,
|
14847
14891
|
codec,
|
14848
|
-
|
14892
|
+
participantIdentity: participantIdentity
|
14849
14893
|
}
|
14850
14894
|
};
|
14851
14895
|
this.worker.postMessage(msg);
|
@@ -14872,7 +14916,7 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14872
14916
|
writableStream: writable,
|
14873
14917
|
trackId: trackId,
|
14874
14918
|
codec,
|
14875
|
-
|
14919
|
+
participantIdentity: participantIdentity
|
14876
14920
|
}
|
14877
14921
|
};
|
14878
14922
|
this.worker.postMessage(msg, [readable, writable]);
|
@@ -14886,15 +14930,19 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14886
14930
|
* a frame encoder.
|
14887
14931
|
*
|
14888
14932
|
*/
|
14889
|
-
handleSender(sender, trackId,
|
14933
|
+
handleSender(sender, trackId, codec) {
|
14934
|
+
var _a;
|
14890
14935
|
if (E2EE_FLAG in sender || !this.worker) {
|
14891
14936
|
return;
|
14892
14937
|
}
|
14938
|
+
if (!((_a = this.room) === null || _a === void 0 ? void 0 : _a.localParticipant.identity) || this.room.localParticipant.identity === '') {
|
14939
|
+
throw TypeError('local identity needs to be known in order to set up encrypted sender');
|
14940
|
+
}
|
14893
14941
|
if (isScriptTransformSupported()) {
|
14894
14942
|
livekitLogger.info('initialize script transform');
|
14895
14943
|
const options = {
|
14896
14944
|
kind: 'encode',
|
14897
|
-
|
14945
|
+
participantIdentity: this.room.localParticipant.identity,
|
14898
14946
|
trackId,
|
14899
14947
|
codec
|
14900
14948
|
};
|
@@ -14911,7 +14959,7 @@ class E2EEManager extends eventsExports.EventEmitter {
|
|
14911
14959
|
writableStream: senderStreams.writable,
|
14912
14960
|
codec,
|
14913
14961
|
trackId,
|
14914
|
-
|
14962
|
+
participantIdentity: this.room.localParticipant.identity
|
14915
14963
|
}
|
14916
14964
|
};
|
14917
14965
|
this.worker.postMessage(msg, [senderStreams.readable, senderStreams.writable]);
|
@@ -15853,7 +15901,8 @@ class PCTransport extends eventsExports.EventEmitter {
|
|
15853
15901
|
return;
|
15854
15902
|
} catch (e) {
|
15855
15903
|
livekitLogger.warn("not able to set ".concat(sd.type, ", falling back to unmodified sdp"), {
|
15856
|
-
error: e
|
15904
|
+
error: e,
|
15905
|
+
sdp: munged
|
15857
15906
|
});
|
15858
15907
|
sd.sdp = originalSdp;
|
15859
15908
|
}
|
@@ -15873,6 +15922,14 @@ class PCTransport extends eventsExports.EventEmitter {
|
|
15873
15922
|
} else if (typeof e === 'string') {
|
15874
15923
|
msg = e;
|
15875
15924
|
}
|
15925
|
+
const fields = {
|
15926
|
+
error: msg,
|
15927
|
+
sdp: sd.sdp
|
15928
|
+
};
|
15929
|
+
if (!remote && this.pc.remoteDescription) {
|
15930
|
+
fields.remoteSdp = this.pc.remoteDescription;
|
15931
|
+
}
|
15932
|
+
livekitLogger.error("unable to set ".concat(sd.type), fields);
|
15876
15933
|
throw new NegotiationError(msg);
|
15877
15934
|
}
|
15878
15935
|
});
|
@@ -19879,6 +19936,9 @@ class LocalParticipant extends Participant {
|
|
19879
19936
|
get lastMicrophoneError() {
|
19880
19937
|
return this.microphoneError;
|
19881
19938
|
}
|
19939
|
+
get isE2EEEnabled() {
|
19940
|
+
return this.encryptionType !== Encryption_Type.NONE;
|
19941
|
+
}
|
19882
19942
|
getTrack(source) {
|
19883
19943
|
const track = super.getTrack(source);
|
19884
19944
|
if (track) {
|
@@ -20258,7 +20318,7 @@ class LocalParticipant extends Participant {
|
|
20258
20318
|
});
|
20259
20319
|
}
|
20260
20320
|
publish(track, opts, isStereo) {
|
20261
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
20321
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
20262
20322
|
return __awaiter(this, void 0, void 0, function* () {
|
20263
20323
|
const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => track instanceof LocalTrack && publishedTrack.source === track.source);
|
20264
20324
|
if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
|
@@ -20306,8 +20366,8 @@ class LocalParticipant extends Participant {
|
|
20306
20366
|
source: Track.sourceToProto(track.source),
|
20307
20367
|
disableDtx: !((_a = opts.dtx) !== null && _a !== void 0 ? _a : true),
|
20308
20368
|
encryption: this.encryptionType,
|
20309
|
-
stereo: isStereo
|
20310
|
-
|
20369
|
+
stereo: isStereo,
|
20370
|
+
disableRed: !((_b = opts.red) !== null && _b !== void 0 ? _b : true)
|
20311
20371
|
});
|
20312
20372
|
// compute encodings and layers for video
|
20313
20373
|
let encodings;
|
@@ -20322,7 +20382,7 @@ class LocalParticipant extends Participant {
|
|
20322
20382
|
} catch (e) {
|
20323
20383
|
// use defaults, it's quite painful for congestion control without simulcast
|
20324
20384
|
// so using default dims according to publish settings
|
20325
|
-
const defaultRes = (
|
20385
|
+
const defaultRes = (_d = (_c = this.roomOptions.videoCaptureDefaults) === null || _c === void 0 ? void 0 : _c.resolution) !== null && _d !== void 0 ? _d : VideoPresets.h720.resolution;
|
20326
20386
|
dims = {
|
20327
20387
|
width: defaultRes.width,
|
20328
20388
|
height: defaultRes.height
|
@@ -20337,7 +20397,7 @@ class LocalParticipant extends Participant {
|
|
20337
20397
|
if (track instanceof LocalVideoTrack) {
|
20338
20398
|
if (isSVCCodec(opts.videoCodec)) {
|
20339
20399
|
// set scalabilityMode to 'L3T3_KEY' by default
|
20340
|
-
opts.scalabilityMode = (
|
20400
|
+
opts.scalabilityMode = (_e = opts.scalabilityMode) !== null && _e !== void 0 ? _e : 'L3T3_KEY';
|
20341
20401
|
}
|
20342
20402
|
// set up backup
|
20343
20403
|
if (opts.videoCodec && opts.backupCodec && opts.videoCodec !== opts.backupCodec.codec) {
|
@@ -20362,7 +20422,7 @@ class LocalParticipant extends Participant {
|
|
20362
20422
|
req.simulcastCodecs = [new SimulcastCodec({
|
20363
20423
|
codec: opts.videoCodec,
|
20364
20424
|
cid: track.mediaStreamTrack.id,
|
20365
|
-
enableSimulcastLayers: (
|
20425
|
+
enableSimulcastLayers: (_f = opts.simulcast) !== null && _f !== void 0 ? _f : false
|
20366
20426
|
})];
|
20367
20427
|
}
|
20368
20428
|
}
|
@@ -20370,9 +20430,9 @@ class LocalParticipant extends Participant {
|
|
20370
20430
|
req.layers = videoLayersFromEncodings(req.width, req.height, encodings, isSVCCodec(opts.videoCodec));
|
20371
20431
|
} else if (track.kind === Track.Kind.Audio) {
|
20372
20432
|
encodings = [{
|
20373
|
-
maxBitrate: (
|
20374
|
-
priority: (
|
20375
|
-
networkPriority: (
|
20433
|
+
maxBitrate: (_h = (_g = opts.audioPreset) === null || _g === void 0 ? void 0 : _g.maxBitrate) !== null && _h !== void 0 ? _h : opts.audioBitrate,
|
20434
|
+
priority: (_k = (_j = opts.audioPreset) === null || _j === void 0 ? void 0 : _j.priority) !== null && _k !== void 0 ? _k : 'high',
|
20435
|
+
networkPriority: (_m = (_l = opts.audioPreset) === null || _l === void 0 ? void 0 : _l.priority) !== null && _m !== void 0 ? _m : 'high'
|
20376
20436
|
}];
|
20377
20437
|
}
|
20378
20438
|
if (!this.engine || this.engine.isClosed) {
|
@@ -20434,10 +20494,10 @@ class LocalParticipant extends Participant {
|
|
20434
20494
|
this.engine.publisher.setTrackCodecBitrate({
|
20435
20495
|
transceiver: trackTransceiver,
|
20436
20496
|
codec: 'opus',
|
20437
|
-
maxbr: ((
|
20497
|
+
maxbr: ((_o = encodings[0]) === null || _o === void 0 ? void 0 : _o.maxBitrate) ? encodings[0].maxBitrate / 1000 : 0
|
20438
20498
|
});
|
20439
20499
|
}
|
20440
|
-
} else if (track.codec && isSVCCodec(track.codec) && ((
|
20500
|
+
} else if (track.codec && isSVCCodec(track.codec) && ((_p = encodings[0]) === null || _p === void 0 ? void 0 : _p.maxBitrate)) {
|
20441
20501
|
this.engine.publisher.setTrackCodecBitrate({
|
20442
20502
|
cid: req.cid,
|
20443
20503
|
codec: track.codec,
|
@@ -21344,7 +21404,10 @@ class Room extends eventsExports.EventEmitter {
|
|
21344
21404
|
setE2EEEnabled(enabled) {
|
21345
21405
|
return __awaiter(this, void 0, void 0, function* () {
|
21346
21406
|
if (this.e2eeManager) {
|
21347
|
-
yield Promise.all([this.localParticipant.setE2EEEnabled(enabled)
|
21407
|
+
yield Promise.all([this.localParticipant.setE2EEEnabled(enabled)]);
|
21408
|
+
if (this.localParticipant.identity !== '') {
|
21409
|
+
this.e2eeManager.setParticipantCryptorEnabled(enabled, this.localParticipant.identity);
|
21410
|
+
}
|
21348
21411
|
} else {
|
21349
21412
|
throw Error('e2ee not configured, please set e2ee settings within the room options');
|
21350
21413
|
}
|
@@ -21360,7 +21423,7 @@ class Room extends eventsExports.EventEmitter {
|
|
21360
21423
|
}
|
21361
21424
|
this.emit(RoomEvent.ParticipantEncryptionStatusChanged, enabled, participant);
|
21362
21425
|
});
|
21363
|
-
this.e2eeManager.on(EncryptionEvent.
|
21426
|
+
this.e2eeManager.on(EncryptionEvent.EncryptionError, error => this.emit(RoomEvent.EncryptionError, error));
|
21364
21427
|
(_a = this.e2eeManager) === null || _a === void 0 ? void 0 : _a.setup(this);
|
21365
21428
|
}
|
21366
21429
|
}
|
@@ -21798,7 +21861,11 @@ class Room extends eventsExports.EventEmitter {
|
|
21798
21861
|
livekitLogger.warn('tried to create RemoteParticipant for local participant');
|
21799
21862
|
return;
|
21800
21863
|
}
|
21801
|
-
const participant = this.
|
21864
|
+
const participant = this.participants.get(participantId);
|
21865
|
+
if (!participant) {
|
21866
|
+
livekitLogger.error("Tried to add a track for a participant, that's not present. Sid: ".concat(participantId));
|
21867
|
+
return;
|
21868
|
+
}
|
21802
21869
|
let adaptiveStreamSettings;
|
21803
21870
|
if (this.options.adaptiveStream) {
|
21804
21871
|
if (typeof this.options.adaptiveStream === 'object') {
|
@@ -21914,16 +21981,12 @@ class Room extends eventsExports.EventEmitter {
|
|
21914
21981
|
if (this.participants.has(id)) {
|
21915
21982
|
return this.participants.get(id);
|
21916
21983
|
}
|
21917
|
-
// it's possible for the RTC track to arrive before signaling data
|
21918
|
-
// when this happens, we'll create the participant and make the track work
|
21919
21984
|
const participant = this.createParticipant(id, info);
|
21920
21985
|
this.participants.set(id, participant);
|
21921
|
-
|
21922
|
-
|
21923
|
-
|
21924
|
-
|
21925
|
-
this.emitWhenConnected(RoomEvent.ParticipantConnected, participant);
|
21926
|
-
}
|
21986
|
+
this.identityToSid.set(info.identity, info.sid);
|
21987
|
+
// if we have valid info and the participant wasn't in the map before, we can assume the participant is new
|
21988
|
+
// firing here to make sure that `ParticipantConnected` fires before the initial track events
|
21989
|
+
this.emitWhenConnected(RoomEvent.ParticipantConnected, participant);
|
21927
21990
|
// also forward events
|
21928
21991
|
// trackPublished is only fired for tracks added after both local participant
|
21929
21992
|
// and remote participant joined the room
|
@@ -22755,7 +22818,7 @@ function facingModeFromLocalTrack(localTrack) {
|
|
22755
22818
|
// 1. Try to get facingMode from track settings.
|
22756
22819
|
if ('facingMode' in trackSettings) {
|
22757
22820
|
const rawFacingMode = trackSettings.facingMode;
|
22758
|
-
|
22821
|
+
livekitLogger.debug('rawFacingMode', {
|
22759
22822
|
rawFacingMode
|
22760
22823
|
});
|
22761
22824
|
if (rawFacingMode && typeof rawFacingMode === 'string' && isFacingModeValue(rawFacingMode)) {
|
@@ -22767,7 +22830,7 @@ function facingModeFromLocalTrack(localTrack) {
|
|
22767
22830
|
}
|
22768
22831
|
// 2. If we don't have a high confidence we try to get the facing mode from the device label.
|
22769
22832
|
if (['low', 'medium'].includes(result.confidence)) {
|
22770
|
-
|
22833
|
+
livekitLogger.debug("Try to get facing mode from device label: (".concat(track.label, ")"));
|
22771
22834
|
const labelAnalysisResult = facingModeFromDeviceLabel(track.label);
|
22772
22835
|
if (labelAnalysisResult !== undefined) {
|
22773
22836
|
result = labelAnalysisResult;
|
@@ -22813,5 +22876,5 @@ function isFacingModeValue(item) {
|
|
22813
22876
|
return item === undefined || allowedValues.includes(item);
|
22814
22877
|
}
|
22815
22878
|
|
22816
|
-
export { AudioPresets, BaseKeyProvider, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, MediaDeviceFailure, NegotiationError, Participant, ParticipantEvent, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RoomState, ScreenSharePresets, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, importKey, isBackupCodec, isBrowserSupported, isCodecEqual, isE2EESupported, isInsertableStreamSupported, isScriptTransformSupported, isVideoFrame, mimeTypeToVideoCodecString, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs };
|
22879
|
+
export { AudioPresets, BaseKeyProvider, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, KeyHandlerEvent, KeyProviderEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, MediaDeviceFailure, NegotiationError, Participant, ParticipantEvent, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RoomState, ScreenSharePresets, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, importKey, isBackupCodec, isBrowserSupported, isCodecEqual, isE2EESupported, isInsertableStreamSupported, isScriptTransformSupported, isVideoFrame, mimeTypeToVideoCodecString, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs };
|
22817
22880
|
//# sourceMappingURL=livekit-client.esm.mjs.map
|