From 85271f416b828b5121b7f93d9ace87658fb58ebd Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 14 May 2025 09:59:56 +0200 Subject: [PATCH] TO REVERT: More logs to debug --- src/e2ee/matrixKeyProvider.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index fd6f1717..c827e987 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -16,6 +16,11 @@ import { type MatrixRTCSession, MatrixRTCSessionEvent, } from "matrix-js-sdk/lib/matrixrtc"; +import { encodeBase64 } from "matrix-js-sdk"; + +function tmpLogPrefix(msg: string): void { + logger.debug(`[RTCEncryption][MatrixKeyProvider] - ${msg}`); +} export class MatrixKeyProvider extends BaseKeyProvider { private rtcSession?: MatrixRTCSession; @@ -34,8 +39,9 @@ export class MatrixKeyProvider extends BaseKeyProvider { participantIdentity?: string, keyIndex?: number, ): void => { - logger.debug( + tmpLogPrefix( `key ratcheted event received for ${participantIdentity} at index ${keyIndex}`, + `key=${encodeBase64(new Uint8Array(ratchetResult.chainKey))}`, ); this.rtcSession?.onKeyRatcheted( ratchetResult.chainKey, @@ -70,13 +76,16 @@ export class MatrixKeyProvider extends BaseKeyProvider { MatrixRTCSessionEvent.EncryptionKeyQueryRatchetStep, this.doRatchetKey, ); - + tmpLogPrefix(`setRTCSession SESSION CHANGED`); // The new session could be aware of keys of which the old session wasn't, // so emit key changed events this.rtcSession.reemitEncryptionKeys(); } private doRatchetKey = (participantId: string, keyIndex: number): void => { + tmpLogPrefix( + `doRatchetKey participantId=${participantId} keyIndex=${keyIndex}`, + ); this.ratchetKey(participantId, keyIndex); }; @@ -85,11 +94,14 @@ export class MatrixKeyProvider extends BaseKeyProvider { encryptionKeyIndex: number, participantId: string, ): void => { + tmpLogPrefix( + `onEncryptionKeyChanged participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex} key=${encodeBase64(encryptionKey)}`, + ); importKey(encryptionKey, "HKDF", "derive").then( (keyMaterial) => { this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex); - logger.debug( + tmpLogPrefix( `Sent new key to livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`, ); },