livekit-client 2.11.4 → 2.12.0
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 +25 -14
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +100 -15
- 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/api/SignalClient.d.ts +2 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/KeyProvider.d.ts +8 -5
- package/dist/src/e2ee/KeyProvider.d.ts.map +1 -1
- package/dist/src/e2ee/events.d.ts +8 -3
- package/dist/src/e2ee/events.d.ts.map +1 -1
- package/dist/src/e2ee/types.d.ts +5 -1
- package/dist/src/e2ee/types.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +4 -4
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +2 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +1 -0
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +11 -1
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +2 -1
- package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +8 -5
- package/dist/ts4.2/src/e2ee/events.d.ts +8 -3
- package/dist/ts4.2/src/e2ee/types.d.ts +5 -1
- package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +4 -4
- package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -1
- package/dist/ts4.2/src/room/Room.d.ts +1 -0
- package/dist/ts4.2/src/room/events.d.ts +11 -1
- package/dist/ts4.2/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/api/SignalClient.ts +10 -0
- package/src/e2ee/E2eeManager.ts +6 -1
- package/src/e2ee/KeyProvider.ts +13 -6
- package/src/e2ee/events.ts +12 -3
- package/src/e2ee/types.ts +8 -1
- package/src/e2ee/worker/FrameCryptor.ts +8 -4
- package/src/e2ee/worker/ParticipantKeyHandler.test.ts +104 -4
- package/src/e2ee/worker/ParticipantKeyHandler.ts +22 -23
- package/src/e2ee/worker/e2ee.worker.ts +7 -2
- package/src/room/RTCEngine.ts +7 -0
- package/src/room/Room.ts +20 -0
- package/src/room/events.ts +11 -0
- package/src/room/participant/LocalParticipant.ts +0 -5
- package/src/room/track/RemoteAudioTrack.ts +3 -2
- package/src/version.ts +1 -1
@@ -549,11 +549,16 @@ class CryptorError extends LivekitError {
|
|
549
549
|
var KeyProviderEvent;
|
550
550
|
(function (KeyProviderEvent) {
|
551
551
|
KeyProviderEvent["SetKey"] = "setKey";
|
552
|
+
/** Event for requesting to ratchet the key used to encrypt the stream */
|
552
553
|
KeyProviderEvent["RatchetRequest"] = "ratchetRequest";
|
554
|
+
/** Emitted when a key is ratcheted. Could be after auto-ratcheting on decryption failure or
|
555
|
+
* following a `RatchetRequest`, will contain the ratcheted key material */
|
553
556
|
KeyProviderEvent["KeyRatcheted"] = "keyRatcheted";
|
554
557
|
})(KeyProviderEvent || (KeyProviderEvent = {}));
|
555
558
|
var KeyHandlerEvent;
|
556
559
|
(function (KeyHandlerEvent) {
|
560
|
+
/** Emitted when a key has been ratcheted. Is emitted when any key has been ratcheted
|
561
|
+
* i.e. when the FrameCryptor tried to ratchet when decryption is failing */
|
557
562
|
KeyHandlerEvent["KeyRatcheted"] = "keyRatcheted";
|
558
563
|
})(KeyHandlerEvent || (KeyHandlerEvent = {}));
|
559
564
|
var EncryptionEvent;
|
@@ -1416,11 +1421,12 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
1416
1421
|
if (ratchetOpts.ratchetCount < _this.keyProviderOptions.ratchetWindowSize) {
|
1417
1422
|
workerLogger.debug("ratcheting key attempt ".concat(ratchetOpts.ratchetCount, " of ").concat(_this.keyProviderOptions.ratchetWindowSize, ", for kind ").concat(encodedFrame instanceof RTCEncodedAudioFrame ? 'audio' : 'video'));
|
1418
1423
|
let ratchetedKeySet;
|
1424
|
+
let ratchetResult;
|
1419
1425
|
if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === _this.keys.getKeySet(keyIndex)) {
|
1420
1426
|
// only ratchet if the currently set key is still the same as the one used to decrypt this frame
|
1421
1427
|
// if not, it might be that a different frame has already ratcheted and we try with that one first
|
1422
|
-
|
1423
|
-
ratchetedKeySet = yield deriveKeys(
|
1428
|
+
ratchetResult = yield _this.keys.ratchetKey(keyIndex, false);
|
1429
|
+
ratchetedKeySet = yield deriveKeys(ratchetResult.cryptoKey, _this.keyProviderOptions.ratchetSalt);
|
1424
1430
|
}
|
1425
1431
|
const frame = yield _this.decryptFrame(encodedFrame, keyIndex, initialMaterial || keySet, {
|
1426
1432
|
ratchetCount: ratchetOpts.ratchetCount + 1,
|
@@ -1430,7 +1436,7 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
1430
1436
|
// before updating the keys, make sure that the keySet used for this frame is still the same as the currently set key
|
1431
1437
|
// if it's not, a new key might have been set already, which we don't want to override
|
1432
1438
|
if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === _this.keys.getKeySet(keyIndex)) {
|
1433
|
-
_this.keys.setKeySet(ratchetedKeySet, keyIndex,
|
1439
|
+
_this.keys.setKeySet(ratchetedKeySet, keyIndex, ratchetResult);
|
1434
1440
|
// decryption was successful, set the new key index to reflect the ratcheted key set
|
1435
1441
|
_this.keys.setCurrentKeyIndex(keyIndex);
|
1436
1442
|
}
|
@@ -1734,12 +1740,17 @@ class ParticipantKeyHandler extends eventsExports.EventEmitter {
|
|
1734
1740
|
throw new TypeError("Cannot ratchet key without a valid keyset of participant ".concat(this.participantIdentity));
|
1735
1741
|
}
|
1736
1742
|
const currentMaterial = keySet.material;
|
1737
|
-
const
|
1743
|
+
const chainKey = yield ratchet(currentMaterial, this.keyProviderOptions.ratchetSalt);
|
1744
|
+
const newMaterial = yield importKey(chainKey, currentMaterial.algorithm.name, 'derive');
|
1745
|
+
const ratchetResult = {
|
1746
|
+
chainKey,
|
1747
|
+
cryptoKey: newMaterial
|
1748
|
+
};
|
1738
1749
|
if (setKey) {
|
1739
|
-
|
1740
|
-
this.
|
1750
|
+
// Set the new key and emit a ratchet event with the ratcheted chain key
|
1751
|
+
yield this.setKeyFromMaterial(newMaterial, currentKeyIndex, ratchetResult);
|
1741
1752
|
}
|
1742
|
-
resolve(
|
1753
|
+
resolve(ratchetResult);
|
1743
1754
|
} catch (e) {
|
1744
1755
|
reject(e);
|
1745
1756
|
} finally {
|
@@ -1774,7 +1785,7 @@ class ParticipantKeyHandler extends eventsExports.EventEmitter {
|
|
1774
1785
|
setKeyFromMaterial(material_1, keyIndex_1) {
|
1775
1786
|
return __awaiter(this, arguments, void 0, function (material, keyIndex) {
|
1776
1787
|
var _this2 = this;
|
1777
|
-
let
|
1788
|
+
let ratchetedResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
1778
1789
|
return function* () {
|
1779
1790
|
const keySet = yield deriveKeys(material, _this2.keyProviderOptions.ratchetSalt);
|
1780
1791
|
const newIndex = keyIndex >= 0 ? keyIndex % _this2.cryptoKeyRing.length : _this2.currentKeyIndex;
|
@@ -1783,16 +1794,16 @@ class ParticipantKeyHandler extends eventsExports.EventEmitter {
|
|
1783
1794
|
algorithm: material.algorithm,
|
1784
1795
|
ratchetSalt: _this2.keyProviderOptions.ratchetSalt
|
1785
1796
|
});
|
1786
|
-
_this2.setKeySet(keySet, newIndex,
|
1797
|
+
_this2.setKeySet(keySet, newIndex, ratchetedResult);
|
1787
1798
|
if (newIndex >= 0) _this2.currentKeyIndex = newIndex;
|
1788
1799
|
}();
|
1789
1800
|
});
|
1790
1801
|
}
|
1791
1802
|
setKeySet(keySet, keyIndex) {
|
1792
|
-
let
|
1803
|
+
let ratchetedResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
1793
1804
|
this.cryptoKeyRing[keyIndex % this.cryptoKeyRing.length] = keySet;
|
1794
|
-
if (
|
1795
|
-
this.emit(KeyHandlerEvent.KeyRatcheted,
|
1805
|
+
if (ratchetedResult) {
|
1806
|
+
this.emit(KeyHandlerEvent.KeyRatcheted, ratchetedResult, this.participantIdentity, keyIndex);
|
1796
1807
|
}
|
1797
1808
|
}
|
1798
1809
|
setCurrentKeyIndex(index) {
|
@@ -2005,13 +2016,13 @@ function setupCryptorErrorEvents(cryptor) {
|
|
2005
2016
|
postMessage(msg);
|
2006
2017
|
});
|
2007
2018
|
}
|
2008
|
-
function emitRatchetedKeys(
|
2019
|
+
function emitRatchetedKeys(ratchetResult, participantIdentity, keyIndex) {
|
2009
2020
|
const msg = {
|
2010
2021
|
kind: "ratchetKey",
|
2011
2022
|
data: {
|
2012
2023
|
participantIdentity,
|
2013
2024
|
keyIndex,
|
2014
|
-
|
2025
|
+
ratchetResult
|
2015
2026
|
}
|
2016
2027
|
};
|
2017
2028
|
postMessage(msg);
|