livekit-client 2.0.8 → 2.0.9

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.
@@ -327,10 +327,6 @@ livekitLogger.setDefaultLevel(LogLevel.info);
327
327
  const workerLogger = loglevelExports.getLogger('lk-e2ee');
328
328
 
329
329
  const ENCRYPTION_ALGORITHM = 'AES-GCM';
330
- // We use a ringbuffer of keys so we can change them and still decode packets that were
331
- // encrypted with an old key. We use a size of 16 which corresponds to the four bits
332
- // in the frame trailer.
333
- const KEYRING_SIZE = 16;
334
330
  // How many consecutive frames can fail decrypting before a particular key gets marked as invalid
335
331
  const DECRYPTION_FAILURE_TOLERANCE = 10;
336
332
  // We copy the first bytes of the VP8 payload unencrypted.
@@ -358,7 +354,8 @@ const KEY_PROVIDER_DEFAULTS = {
358
354
  sharedKey: false,
359
355
  ratchetSalt: SALT,
360
356
  ratchetWindowSize: 8,
361
- failureTolerance: DECRYPTION_FAILURE_TOLERANCE
357
+ failureTolerance: DECRYPTION_FAILURE_TOLERANCE,
358
+ keyringSize: 16
362
359
  };
363
360
  const MAX_SIF_COUNT = 100;
364
361
  const MAX_SIF_DURATION = 2000;
@@ -1503,7 +1500,10 @@ class ParticipantKeyHandler extends eventsExports.EventEmitter {
1503
1500
  this.decryptionFailureCount = 0;
1504
1501
  this._hasValidKey = true;
1505
1502
  this.currentKeyIndex = 0;
1506
- this.cryptoKeyRing = new Array(KEYRING_SIZE).fill(undefined);
1503
+ if (keyProviderOptions.keyringSize < 1 || keyProviderOptions.keyringSize > 255) {
1504
+ throw new TypeError('Keyring size needs to be between 1 and 256');
1505
+ }
1506
+ this.cryptoKeyRing = new Array(keyProviderOptions.keyringSize).fill(undefined);
1507
1507
  this.keyProviderOptions = keyProviderOptions;
1508
1508
  this.ratchetPromiseMap = new Map();
1509
1509
  this.participantIdentity = participantIdentity;