From cddd71f02650ce1d968469747a5810d84ade678d Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 13 May 2025 11:28:19 +0200 Subject: [PATCH] fixup prettier --- src/e2ee/matrixKeyProvider.ts | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index 350fb4be..fd6f1717 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -9,7 +9,7 @@ import { BaseKeyProvider, importKey, KeyProviderEvent, - type RatchetResult + type RatchetResult, } from "livekit-client"; import { logger } from "matrix-js-sdk/lib/logger"; import { @@ -20,14 +20,28 @@ import { export class MatrixKeyProvider extends BaseKeyProvider { private rtcSession?: MatrixRTCSession; - private readonly onKeyRatchetComplete: (ratchetResult: RatchetResult, participantIdentity?: string, keyIndex?: number) => void; + private readonly onKeyRatchetComplete: ( + ratchetResult: RatchetResult, + participantIdentity?: string, + keyIndex?: number, + ) => void; public constructor() { super({ ratchetWindowSize: 10, keyringSize: 10 }); - this.onKeyRatchetComplete = (ratchetResult: RatchetResult, participantIdentity?: string, keyIndex?: number): void => { - logger.debug(`key ratcheted event received for ${participantIdentity} at index ${keyIndex}`); - this.rtcSession?.onKeyRatcheted(ratchetResult.chainKey,participantIdentity, keyIndex); + this.onKeyRatchetComplete = ( + ratchetResult: RatchetResult, + participantIdentity?: string, + keyIndex?: number, + ): void => { + logger.debug( + `key ratcheted event received for ${participantIdentity} at index ${keyIndex}`, + ); + this.rtcSession?.onKeyRatcheted( + ratchetResult.chainKey, + participantIdentity, + keyIndex, + ); }; this.on(KeyProviderEvent.KeyRatcheted, this.onKeyRatchetComplete); @@ -43,7 +57,6 @@ export class MatrixKeyProvider extends BaseKeyProvider { MatrixRTCSessionEvent.EncryptionKeyQueryRatchetStep, this.doRatchetKey, ); - } this.rtcSession = rtcSession; @@ -58,22 +71,21 @@ export class MatrixKeyProvider extends BaseKeyProvider { this.doRatchetKey, ); - // 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 => { - this.ratchetKey(participantId, keyIndex); - } + private doRatchetKey = (participantId: string, keyIndex: number): void => { + this.ratchetKey(participantId, keyIndex); + }; private onEncryptionKeyChanged = ( encryptionKey: Uint8Array, encryptionKeyIndex: number, participantId: string, ): void => { - importKey(encryptionKey, "HKDF", 'derive').then( + importKey(encryptionKey, "HKDF", "derive").then( (keyMaterial) => { this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex);