From 062c6c542142ca1119d2e767ea4c8eab6b6403f1 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Mon, 23 Sep 2024 12:32:12 +0100 Subject: [PATCH] Handle case of encryption key for an index to be undefined As per https://github.com/matrix-org/matrix-js-sdk/pull/4423 the key can be undefined and so we should handle this rather than waiting for SubtleCrypto.importKey() to fail. --- src/e2ee/matrixKeyProvider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index d84c3684c..634dbd6b1 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -41,7 +41,9 @@ export class MatrixKeyProvider extends BaseKeyProvider { encryptionKeys, ] of this.rtcSession.getEncryptionKeys()) { for (const [index, encryptionKey] of encryptionKeys.entries()) { - this.onEncryptionKeyChanged(encryptionKey, index, participant); + if (encryptionKey) { + this.onEncryptionKeyChanged(encryptionKey, index, participant); + } } } }