livekit-client 1.14.0 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +25 -44
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +418 -206
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  10. package/dist/src/e2ee/utils.d.ts +0 -1
  11. package/dist/src/e2ee/utils.d.ts.map +1 -1
  12. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  13. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
  14. package/dist/src/proto/livekit_models_pb.d.ts +87 -11
  15. package/dist/src/proto/livekit_models_pb.d.ts.map +1 -1
  16. package/dist/src/proto/livekit_rtc_pb.d.ts +0 -4
  17. package/dist/src/proto/livekit_rtc_pb.d.ts.map +1 -1
  18. package/dist/src/room/PCTransport.d.ts +20 -1
  19. package/dist/src/room/PCTransport.d.ts.map +1 -1
  20. package/dist/src/room/RTCEngine.d.ts +1 -1
  21. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  22. package/dist/src/room/Room.d.ts.map +1 -1
  23. package/dist/src/room/defaults.d.ts +1 -0
  24. package/dist/src/room/defaults.d.ts.map +1 -1
  25. package/dist/src/room/events.d.ts +1 -1
  26. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  27. package/dist/src/room/timers.d.ts +1 -1
  28. package/dist/src/room/timers.d.ts.map +1 -1
  29. package/dist/src/room/track/LocalAudioTrack.d.ts +1 -1
  30. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  31. package/dist/src/room/track/LocalTrack.d.ts +3 -3
  32. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  33. package/dist/src/room/track/LocalVideoTrack.d.ts +2 -1
  34. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  35. package/dist/src/room/track/RemoteTrack.d.ts.map +1 -1
  36. package/dist/src/room/track/options.d.ts +6 -1
  37. package/dist/src/room/track/options.d.ts.map +1 -1
  38. package/dist/src/room/track/utils.d.ts +2 -1
  39. package/dist/src/room/track/utils.d.ts.map +1 -1
  40. package/dist/src/room/utils.d.ts.map +1 -1
  41. package/dist/src/utils/cloneDeep.d.ts +2 -0
  42. package/dist/src/utils/cloneDeep.d.ts.map +1 -0
  43. package/dist/src/version.d.ts +1 -1
  44. package/dist/src/version.d.ts.map +1 -1
  45. package/dist/ts4.2/src/e2ee/utils.d.ts +0 -1
  46. package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +87 -11
  47. package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +0 -4
  48. package/dist/ts4.2/src/room/PCTransport.d.ts +20 -1
  49. package/dist/ts4.2/src/room/RTCEngine.d.ts +1 -1
  50. package/dist/ts4.2/src/room/defaults.d.ts +1 -0
  51. package/dist/ts4.2/src/room/events.d.ts +1 -1
  52. package/dist/ts4.2/src/room/timers.d.ts +1 -1
  53. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +1 -1
  54. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +3 -3
  55. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -1
  56. package/dist/ts4.2/src/room/track/options.d.ts +6 -1
  57. package/dist/ts4.2/src/room/track/utils.d.ts +1 -0
  58. package/dist/ts4.2/src/utils/cloneDeep.d.ts +2 -0
  59. package/dist/ts4.2/src/version.d.ts +1 -1
  60. package/package.json +14 -14
  61. package/src/connectionHelper/checks/webrtc.ts +1 -1
  62. package/src/e2ee/E2eeManager.ts +2 -1
  63. package/src/e2ee/utils.ts +0 -10
  64. package/src/e2ee/worker/FrameCryptor.ts +13 -14
  65. package/src/e2ee/worker/ParticipantKeyHandler.ts +4 -5
  66. package/src/e2ee/worker/e2ee.worker.ts +3 -1
  67. package/src/proto/livekit_models_pb.ts +140 -15
  68. package/src/proto/livekit_rtc_pb.ts +1 -7
  69. package/src/room/PCTransport.ts +116 -1
  70. package/src/room/RTCEngine.ts +49 -85
  71. package/src/room/Room.ts +15 -11
  72. package/src/room/defaults.ts +4 -2
  73. package/src/room/events.ts +1 -1
  74. package/src/room/participant/LocalParticipant.ts +45 -56
  75. package/src/room/track/LocalAudioTrack.ts +1 -1
  76. package/src/room/track/LocalTrack.ts +8 -5
  77. package/src/room/track/LocalVideoTrack.ts +2 -1
  78. package/src/room/track/RemoteTrack.ts +8 -6
  79. package/src/room/track/options.ts +7 -7
  80. package/src/room/track/utils.ts +17 -8
  81. package/src/room/utils.ts +3 -0
  82. package/src/utils/cloneDeep.test.ts +54 -0
  83. package/src/utils/cloneDeep.ts +11 -0
  84. package/src/version.ts +1 -1
@@ -12,7 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
12
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
14
  ***************************************************************************** */
15
- /* global Reflect, Promise */
15
+ /* global Reflect, Promise, SuppressedError, Symbol */
16
16
 
17
17
 
18
18
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -23,7 +23,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
23
23
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
24
  step((generator = generator.apply(thisArg, _arguments || [])).next());
25
25
  });
26
- }
26
+ }
27
+
28
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
29
+ var e = new Error(message);
30
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
+ };
27
32
 
28
33
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
29
34
 
@@ -793,28 +798,6 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
793
798
  }
794
799
  var eventsExports = events.exports;
795
800
 
796
- var AudioPresets;
797
- (function (AudioPresets) {
798
- AudioPresets.telephone = {
799
- maxBitrate: 12000
800
- };
801
- AudioPresets.speech = {
802
- maxBitrate: 20000
803
- };
804
- AudioPresets.music = {
805
- maxBitrate: 32000
806
- };
807
- AudioPresets.musicStereo = {
808
- maxBitrate: 48000
809
- };
810
- AudioPresets.musicHighQuality = {
811
- maxBitrate: 64000
812
- };
813
- AudioPresets.musicHighQualityStereo = {
814
- maxBitrate: 96000
815
- };
816
- })(AudioPresets || (AudioPresets = {}));
817
-
818
801
  function isVideoFrame(frame) {
819
802
  return 'type' in frame;
820
803
  }
@@ -1183,8 +1166,8 @@ class FrameCryptor extends BaseFrameCryptor {
1183
1166
  }
1184
1167
  } else if (!this.keys.getKeySet(keyIndex) && this.keys.hasValidKey) {
1185
1168
  // emit an error in case the key index is out of bounds but the key handler thinks we still have a valid key
1186
- workerLogger.warn('skipping decryption due to missing key at index');
1187
- this.emit(CryptorEvent.Error, new CryptorError("missing key at index for participant ".concat(this.participantIdentity), CryptorErrorReason.MissingKey));
1169
+ workerLogger.warn("skipping decryption due to missing key at index ".concat(keyIndex));
1170
+ this.emit(CryptorEvent.Error, new CryptorError("missing key at index ".concat(keyIndex, " for participant ").concat(this.participantIdentity), CryptorErrorReason.MissingKey));
1188
1171
  }
1189
1172
  });
1190
1173
  }
@@ -1242,7 +1225,7 @@ class FrameCryptor extends BaseFrameCryptor {
1242
1225
  if (ratchetOpts.ratchetCount < this.keyProviderOptions.ratchetWindowSize) {
1243
1226
  workerLogger.debug("ratcheting key attempt ".concat(ratchetOpts.ratchetCount, " of ").concat(this.keyProviderOptions.ratchetWindowSize, ", for kind ").concat(encodedFrame instanceof RTCEncodedAudioFrame ? 'audio' : 'video'));
1244
1227
  let ratchetedKeySet;
1245
- if (keySet === this.keys.getKeySet(keyIndex)) {
1228
+ if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === this.keys.getKeySet(keyIndex)) {
1246
1229
  // only ratchet if the currently set key is still the same as the one used to decrypt this frame
1247
1230
  // if not, it might be that a different frame has already ratcheted and we try with that one first
1248
1231
  const newMaterial = yield this.keys.ratchetKey(keyIndex, false);
@@ -1253,22 +1236,21 @@ class FrameCryptor extends BaseFrameCryptor {
1253
1236
  encryptionKey: ratchetedKeySet === null || ratchetedKeySet === void 0 ? void 0 : ratchetedKeySet.encryptionKey
1254
1237
  });
1255
1238
  if (frame && ratchetedKeySet) {
1256
- this.keys.setKeySet(ratchetedKeySet, keyIndex, true);
1257
- // decryption was successful, set the new key index to reflect the ratcheted key set
1258
- this.keys.setCurrentKeyIndex(keyIndex);
1239
+ // before updating the keys, make sure that the keySet used for this frame is still the same as the currently set key
1240
+ // if it's not, a new key might have been set already, which we don't want to override
1241
+ if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === this.keys.getKeySet(keyIndex)) {
1242
+ this.keys.setKeySet(ratchetedKeySet, keyIndex, true);
1243
+ // decryption was successful, set the new key index to reflect the ratcheted key set
1244
+ this.keys.setCurrentKeyIndex(keyIndex);
1245
+ }
1259
1246
  }
1260
1247
  return frame;
1261
1248
  } else {
1262
1249
  /**
1263
- * Since the key it is first send and only afterwards actually used for encrypting, there were
1264
- * situations when the decrypting failed due to the fact that the received frame was not encrypted
1265
- * yet and ratcheting, of course, did not solve the problem. So if we fail RATCHET_WINDOW_SIZE times,
1266
- * we come back to the initial key.
1250
+ * Because we only set a new key once decryption has been successful,
1251
+ * we can be sure that we don't need to reset the key to the initial material at this point
1252
+ * as the key has not been updated on the keyHandler instance
1267
1253
  */
1268
- if (initialMaterial) {
1269
- workerLogger.debug('resetting to initial material');
1270
- this.keys.setKeyFromMaterial(initialMaterial.material, keyIndex);
1271
- }
1272
1254
  workerLogger.warn('maximum ratchet attempts exceeded');
1273
1255
  throw new CryptorError("valid key missing for participant ".concat(this.participantIdentity), CryptorErrorReason.InvalidKey);
1274
1256
  }
@@ -1562,12 +1544,11 @@ class ParticipantKeyHandler extends eventsExports.EventEmitter {
1562
1544
  let keyIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1563
1545
  let emitRatchetEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1564
1546
  return __awaiter(this, void 0, void 0, function* () {
1565
- workerLogger.debug('setting new key');
1566
- if (keyIndex >= 0) {
1567
- this.currentKeyIndex = keyIndex % this.cryptoKeyRing.length;
1568
- }
1547
+ const newIndex = keyIndex >= 0 ? keyIndex % this.cryptoKeyRing.length : -1;
1548
+ workerLogger.debug("setting new key with index ".concat(newIndex));
1569
1549
  const keySet = yield deriveKeys(material, this.keyProviderOptions.ratchetSalt);
1570
- this.setKeySet(keySet, this.currentKeyIndex, emitRatchetEvent);
1550
+ this.setKeySet(keySet, newIndex >= 0 ? newIndex : this.currentKeyIndex, emitRatchetEvent);
1551
+ if (newIndex >= 0) this.currentKeyIndex = newIndex;
1571
1552
  });
1572
1553
  }
1573
1554
  setKeySet(keySet, keyIndex) {
@@ -1643,7 +1624,7 @@ onmessage = ev => {
1643
1624
  workerLogger.warn('set shared key');
1644
1625
  setSharedKey(data.key, data.keyIndex);
1645
1626
  } else if (data.participantIdentity) {
1646
- workerLogger.warn("set participant sender key ".concat(data.participantIdentity));
1627
+ workerLogger.warn("set participant sender key ".concat(data.participantIdentity, " index ").concat(data.keyIndex));
1647
1628
  getParticipantKeyHandler(data.participantIdentity).setKey(data.key, data.keyIndex);
1648
1629
  } else {
1649
1630
  workerLogger.error('no participant Id was provided and shared key usage is disabled');