livekit-client 2.0.7 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1002,6 +1002,12 @@ class FrameCryptor extends BaseFrameCryptor {
1002
1002
  * @param keys
1003
1003
  */
1004
1004
  setParticipant(id, keys) {
1005
+ workerLogger.debug('setting new participant on cryptor', Object.assign(Object.assign({}, this.logContext), {
1006
+ participant: id
1007
+ }));
1008
+ if (this.participantIdentity) {
1009
+ workerLogger.error('cryptor has already a participant set, participant should have been unset before', Object.assign({}, this.logContext));
1010
+ }
1005
1011
  this.participantIdentity = id;
1006
1012
  this.keys = keys;
1007
1013
  this.sifGuard.reset();
@@ -1649,7 +1655,7 @@ onmessage = ev => {
1649
1655
  break;
1650
1656
  case 'enable':
1651
1657
  setEncryptionEnabled(data.enabled, data.participantIdentity);
1652
- workerLogger.info('updated e2ee enabled status');
1658
+ workerLogger.info("updated e2ee enabled status for ".concat(data.participantIdentity, " to ").concat(data.enabled));
1653
1659
  // acknowledge enable call successful
1654
1660
  postMessage(ev.data);
1655
1661
  break;
@@ -1709,7 +1715,18 @@ function handleRatchetRequest(data) {
1709
1715
  });
1710
1716
  }
1711
1717
  function getTrackCryptor(participantIdentity, trackId) {
1712
- let cryptor = participantCryptors.find(c => c.getTrackId() === trackId);
1718
+ let cryptors = participantCryptors.filter(c => c.getTrackId() === trackId);
1719
+ if (cryptors.length > 1) {
1720
+ const debugInfo = cryptors.map(c => {
1721
+ return {
1722
+ participant: c.getParticipantIdentity()
1723
+ };
1724
+ }).join(',');
1725
+ workerLogger.error("Found multiple cryptors for the same trackID ".concat(trackId, ". target participant: ").concat(participantIdentity, " "), {
1726
+ participants: debugInfo
1727
+ });
1728
+ }
1729
+ let cryptor = cryptors[0];
1713
1730
  if (!cryptor) {
1714
1731
  workerLogger.info('creating new cryptor for', {
1715
1732
  participantIdentity
@@ -1751,7 +1768,14 @@ function getSharedKeyHandler() {
1751
1768
  return sharedKeyHandler;
1752
1769
  }
1753
1770
  function unsetCryptorParticipant(trackId, participantIdentity) {
1754
- const cryptor = participantCryptors.find(c => c.getParticipantIdentity() === participantIdentity && c.getTrackId() === trackId);
1771
+ const cryptors = participantCryptors.filter(c => c.getParticipantIdentity() === participantIdentity && c.getTrackId() === trackId);
1772
+ if (cryptors.length > 1) {
1773
+ workerLogger.error('Found multiple cryptors for the same participant and trackID combination', {
1774
+ trackId,
1775
+ participantIdentity
1776
+ });
1777
+ }
1778
+ const cryptor = cryptors[0];
1755
1779
  if (!cryptor) {
1756
1780
  workerLogger.warn('Could not unset participant on cryptor', {
1757
1781
  trackId,