TO REVERT: More logs to debug

This commit is contained in:
Valere
2025-05-14 09:59:56 +02:00
parent cc617c1347
commit 85271f416b

View File

@@ -16,6 +16,11 @@ import {
type MatrixRTCSession, type MatrixRTCSession,
MatrixRTCSessionEvent, MatrixRTCSessionEvent,
} from "matrix-js-sdk/lib/matrixrtc"; } 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 { export class MatrixKeyProvider extends BaseKeyProvider {
private rtcSession?: MatrixRTCSession; private rtcSession?: MatrixRTCSession;
@@ -34,8 +39,9 @@ export class MatrixKeyProvider extends BaseKeyProvider {
participantIdentity?: string, participantIdentity?: string,
keyIndex?: number, keyIndex?: number,
): void => { ): void => {
logger.debug( tmpLogPrefix(
`key ratcheted event received for ${participantIdentity} at index ${keyIndex}`, `key ratcheted event received for ${participantIdentity} at index ${keyIndex}`,
`key=${encodeBase64(new Uint8Array(ratchetResult.chainKey))}`,
); );
this.rtcSession?.onKeyRatcheted( this.rtcSession?.onKeyRatcheted(
ratchetResult.chainKey, ratchetResult.chainKey,
@@ -70,13 +76,16 @@ export class MatrixKeyProvider extends BaseKeyProvider {
MatrixRTCSessionEvent.EncryptionKeyQueryRatchetStep, MatrixRTCSessionEvent.EncryptionKeyQueryRatchetStep,
this.doRatchetKey, this.doRatchetKey,
); );
tmpLogPrefix(`setRTCSession SESSION CHANGED`);
// The new session could be aware of keys of which the old session wasn't, // The new session could be aware of keys of which the old session wasn't,
// so emit key changed events // so emit key changed events
this.rtcSession.reemitEncryptionKeys(); this.rtcSession.reemitEncryptionKeys();
} }
private doRatchetKey = (participantId: string, keyIndex: number): void => { private doRatchetKey = (participantId: string, keyIndex: number): void => {
tmpLogPrefix(
`doRatchetKey participantId=${participantId} keyIndex=${keyIndex}`,
);
this.ratchetKey(participantId, keyIndex); this.ratchetKey(participantId, keyIndex);
}; };
@@ -85,11 +94,14 @@ export class MatrixKeyProvider extends BaseKeyProvider {
encryptionKeyIndex: number, encryptionKeyIndex: number,
participantId: string, participantId: string,
): void => { ): void => {
tmpLogPrefix(
`onEncryptionKeyChanged participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex} key=${encodeBase64(encryptionKey)}`,
);
importKey(encryptionKey, "HKDF", "derive").then( importKey(encryptionKey, "HKDF", "derive").then(
(keyMaterial) => { (keyMaterial) => {
this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex); this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex);
logger.debug( tmpLogPrefix(
`Sent new key to livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`, `Sent new key to livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`,
); );
}, },