Skip to content

Commit

Permalink
Treat MissingKey as decryption failure to prevent spamming the logs (#…
Browse files Browse the repository at this point in the history
…1241)

* Apply valid key logic to MissingKey

* Changeset

* Lint

* Remove redundant conditional

* Update empty-lemons-move.md
  • Loading branch information
hughns authored Sep 3, 2024
1 parent b81fdb9 commit 2d3bf60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/empty-lemons-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Treat MissingKey as decryption failure to prevent spamming the logs
4 changes: 3 additions & 1 deletion src/e2ee/worker/FrameCryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export class FrameCryptor extends BaseFrameCryptor {
}
} catch (error) {
if (error instanceof CryptorError && error.reason === CryptorErrorReason.InvalidKey) {
// emit an error if the key handler thinks we have a valid key
if (this.keys.hasValidKey) {
this.emit(CryptorEvent.Error, error);
this.keys.decryptionFailure();
Expand All @@ -369,7 +370,7 @@ export class FrameCryptor extends BaseFrameCryptor {
}
}
} else if (!this.keys.getKeySet(keyIndex) && this.keys.hasValidKey) {
// emit an error in case the key index is out of bounds but the key handler thinks we still have a valid key
// emit an error if the key index is out of bounds but the key handler thinks we still have a valid key
workerLogger.warn(`skipping decryption due to missing key at index ${keyIndex}`);
this.emit(
CryptorEvent.Error,
Expand All @@ -379,6 +380,7 @@ export class FrameCryptor extends BaseFrameCryptor {
this.participantIdentity,
),
);
this.keys.decryptionFailure();
}
}

Expand Down

0 comments on commit 2d3bf60

Please sign in to comment.