mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-08 20:09:19 +00:00
Alternative without createKeyMaterialFromBuffer
This commit is contained in:
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BaseKeyProvider, createKeyMaterialFromBuffer } from "livekit-client";
|
import { BaseKeyProvider } from "livekit-client";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import {
|
import {
|
||||||
type MatrixRTCSession,
|
type MatrixRTCSession,
|
||||||
@@ -44,20 +44,29 @@ export class MatrixKeyProvider extends BaseKeyProvider {
|
|||||||
encryptionKeyIndex: number,
|
encryptionKeyIndex: number,
|
||||||
participantId: string,
|
participantId: string,
|
||||||
): void => {
|
): void => {
|
||||||
createKeyMaterialFromBuffer(encryptionKey.buffer as ArrayBuffer).then(
|
crypto.subtle
|
||||||
(keyMaterial) => {
|
.importKey("raw", encryptionKey, "HKDF", false, [
|
||||||
this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex);
|
"deriveBits",
|
||||||
|
"deriveKey",
|
||||||
|
])
|
||||||
|
.then(
|
||||||
|
(keyMaterial) => {
|
||||||
|
this.onSetEncryptionKey(
|
||||||
|
keyMaterial,
|
||||||
|
participantId,
|
||||||
|
encryptionKeyIndex,
|
||||||
|
);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`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}`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(e) => {
|
(e) => {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Failed to create key material from buffer for livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`,
|
`Failed to create key material from buffer for livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`,
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user