Skip to content

Commit 1c5ef5a

Browse files
committed
alternative without createKeyMaterialFromBuffer
1 parent ca645b7 commit 1c5ef5a

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"livekit-client": "^2.11.3",
103103
"lodash-es": "^4.17.21",
104104
"loglevel": "^1.9.1",
105-
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#591bc1e794463aa78d41fc1fe075c4911e7d5d32",
105+
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#f3f4a1f7e2f5f2c26cf4fce89a729a9197f619b5",
106106
"matrix-widget-api": "1.11.0",
107107
"normalize.css": "^8.0.1",
108108
"observable-hooks": "^4.2.3",

src/e2ee/matrixKeyProvider.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
55
Please see LICENSE in the repository root for full details.
66
*/
77

8-
import { BaseKeyProvider, createKeyMaterialFromBuffer } from "livekit-client";
8+
import { BaseKeyProvider } from "livekit-client";
99
import { logger } from "matrix-js-sdk/lib/logger";
1010
import {
1111
type MatrixRTCSession,
@@ -44,20 +44,29 @@ export class MatrixKeyProvider extends BaseKeyProvider {
4444
encryptionKeyIndex: number,
4545
participantId: string,
4646
): void => {
47-
createKeyMaterialFromBuffer(encryptionKey).then(
48-
(keyMaterial) => {
49-
this.onSetEncryptionKey(keyMaterial, participantId, encryptionKeyIndex);
50-
51-
logger.debug(
52-
`Sent new key to livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`,
53-
);
54-
},
55-
(e) => {
56-
logger.error(
57-
`Failed to create key material from buffer for livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`,
58-
e,
59-
);
60-
},
61-
);
47+
crypto.subtle
48+
.importKey("raw", encryptionKey, "HKDF", false, [
49+
"deriveBits",
50+
"deriveKey",
51+
])
52+
.then(
53+
(keyMaterial) => {
54+
this.onSetEncryptionKey(
55+
keyMaterial,
56+
participantId,
57+
encryptionKeyIndex,
58+
);
59+
60+
logger.debug(
61+
`Sent new key to livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`,
62+
);
63+
},
64+
(e) => {
65+
logger.error(
66+
`Failed to create key material from buffer for livekit room=${this.rtcSession?.room.roomId} participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex}`,
67+
e,
68+
);
69+
},
70+
);
6271
};
6372
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7007,7 +7007,7 @@ __metadata:
70077007
livekit-client: "npm:^2.11.3"
70087008
lodash-es: "npm:^4.17.21"
70097009
loglevel: "npm:^1.9.1"
7010-
matrix-js-sdk: "github:matrix-org/matrix-js-sdk#591bc1e794463aa78d41fc1fe075c4911e7d5d32"
7010+
matrix-js-sdk: "github:matrix-org/matrix-js-sdk#f3f4a1f7e2f5f2c26cf4fce89a729a9197f619b5"
70117011
matrix-widget-api: "npm:1.11.0"
70127012
normalize.css: "npm:^8.0.1"
70137013
observable-hooks: "npm:^4.2.3"
@@ -9610,9 +9610,9 @@ __metadata:
96109610
languageName: node
96119611
linkType: hard
96129612

9613-
"matrix-js-sdk@github:matrix-org/matrix-js-sdk#591bc1e794463aa78d41fc1fe075c4911e7d5d32":
9613+
"matrix-js-sdk@github:matrix-org/matrix-js-sdk#f3f4a1f7e2f5f2c26cf4fce89a729a9197f619b5":
96149614
version: 37.5.0
9615-
resolution: "matrix-js-sdk@https://github.com/matrix-org/matrix-js-sdk.git#commit=591bc1e794463aa78d41fc1fe075c4911e7d5d32"
9615+
resolution: "matrix-js-sdk@https://github.com/matrix-org/matrix-js-sdk.git#commit=f3f4a1f7e2f5f2c26cf4fce89a729a9197f619b5"
96169616
dependencies:
96179617
"@babel/runtime": "npm:^7.12.5"
96189618
"@matrix-org/matrix-sdk-crypto-wasm": "npm:^14.0.1"
@@ -9629,7 +9629,7 @@ __metadata:
96299629
sdp-transform: "npm:^2.14.1"
96309630
unhomoglyph: "npm:^1.0.6"
96319631
uuid: "npm:11"
9632-
checksum: 10c0/50dbacf55bc9b0721c5b57c75088c37456ac71624dd2e9731aa964ac13f0b61dba0e805b0be8f355a891a644aae6a4f4b95eb435b22fb4d6cbda4e674a02d0cd
9632+
checksum: 10c0/14058044851110df967252ab9df0dcc480b2f60cedfb049edb51f8b8925d131f78b4ee9b974e5cdd39093fa32ce7e3318523059c82ecce290fa2fe03ed98506b
96339633
languageName: node
96349634
linkType: hard
96359635

0 commit comments

Comments
 (0)