mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-27 19:29:19 +00:00
fixup prettier
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
|||||||
BaseKeyProvider,
|
BaseKeyProvider,
|
||||||
importKey,
|
importKey,
|
||||||
KeyProviderEvent,
|
KeyProviderEvent,
|
||||||
type RatchetResult
|
type RatchetResult,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import {
|
import {
|
||||||
@@ -20,14 +20,28 @@ import {
|
|||||||
export class MatrixKeyProvider extends BaseKeyProvider {
|
export class MatrixKeyProvider extends BaseKeyProvider {
|
||||||
private rtcSession?: MatrixRTCSession;
|
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() {
|
public constructor() {
|
||||||
super({ ratchetWindowSize: 10, keyringSize: 10 });
|
super({ ratchetWindowSize: 10, keyringSize: 10 });
|
||||||
|
|
||||||
this.onKeyRatchetComplete = (ratchetResult: RatchetResult, participantIdentity?: string, keyIndex?: number): void => {
|
this.onKeyRatchetComplete = (
|
||||||
logger.debug(`key ratcheted event received for ${participantIdentity} at index ${keyIndex}`);
|
ratchetResult: RatchetResult,
|
||||||
this.rtcSession?.onKeyRatcheted(ratchetResult.chainKey,participantIdentity, keyIndex);
|
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);
|
this.on(KeyProviderEvent.KeyRatcheted, this.onKeyRatchetComplete);
|
||||||
@@ -43,7 +57,6 @@ export class MatrixKeyProvider extends BaseKeyProvider {
|
|||||||
MatrixRTCSessionEvent.EncryptionKeyQueryRatchetStep,
|
MatrixRTCSessionEvent.EncryptionKeyQueryRatchetStep,
|
||||||
this.doRatchetKey,
|
this.doRatchetKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rtcSession = rtcSession;
|
this.rtcSession = rtcSession;
|
||||||
@@ -58,22 +71,21 @@ export class MatrixKeyProvider extends BaseKeyProvider {
|
|||||||
this.doRatchetKey,
|
this.doRatchetKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// 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 => {
|
||||||
this.ratchetKey(participantId, keyIndex);
|
this.ratchetKey(participantId, keyIndex);
|
||||||
}
|
};
|
||||||
|
|
||||||
private onEncryptionKeyChanged = (
|
private onEncryptionKeyChanged = (
|
||||||
encryptionKey: Uint8Array,
|
encryptionKey: Uint8Array,
|
||||||
encryptionKeyIndex: number,
|
encryptionKeyIndex: number,
|
||||||
participantId: string,
|
participantId: string,
|
||||||
): void => {
|
): void => {
|
||||||
importKey(encryptionKey, "HKDF", 'derive').then(
|
importKey(encryptionKey, "HKDF", "derive").then(
|
||||||
(keyMaterial) => {
|
(keyMaterial) => {
|
||||||
this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex);
|
this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user