From fa5b014abec5f71f8c2f8ef3ea46742011547cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 22 Aug 2023 17:23:29 +0200 Subject: [PATCH 01/26] E2EE for embeded mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/e2ee/matrixKeyProvider.ts | 81 +++++++++++++++++++++++++++++++++++ src/livekit/useLiveKit.ts | 5 ++- src/room/InCallView.tsx | 1 + 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/e2ee/matrixKeyProvider.ts diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts new file mode 100644 index 000000000..2d0bc1a80 --- /dev/null +++ b/src/e2ee/matrixKeyProvider.ts @@ -0,0 +1,81 @@ +/* +Copyright 2023 New Vector Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { logger } from "@sentry/utils"; +import { + BaseKeyProvider, + KeyProviderOptions, + createKeyMaterialFromString, +} from "livekit-client"; +import { CallMembership } from "matrix-js-sdk/src/matrixrtc/CallMembership"; +import { + MatrixRTCSession, + MatrixRTCSessionEvent, +} from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession"; + +export class MatrixKeyProvider extends BaseKeyProvider { + constructor( + private rtcSession: MatrixRTCSession, + keyProviderOptions: Partial = {} + ) { + super(keyProviderOptions); + + const encryptionKey = this.rtcSession.activeEncryptionKey; + if (!encryptionKey) { + throw new Error( + "MatrixKeyProvider requires the given MatrixRTCSession to have an activeEncryptionKey" + ); + } + + this.rtcSession.on( + MatrixRTCSessionEvent.MembershipsChanged, + this.onMemberShipsChanged + ); + this.rtcSession.on( + MatrixRTCSessionEvent.ActiveEncryptionKeyChanged, + this.onEncryptionKeyChanged + ); + + this.onEncryptionKeyChanged(encryptionKey); + this.onMemberShipsChanged([], this.rtcSession.memberships); + } + + private onEncryptionKeyChanged = async (key: string) => { + this.onSetEncryptionKey(await createKeyMaterialFromString(key), undefined); + }; + + private onMemberShipsChanged = async ( + _: CallMembership[], + newMemberships: CallMembership[] + ) => { + for (const membership of newMemberships) { + const participantId = `${membership.member.userId}:${membership.deviceId}`; + const encryptionKey = await membership.getActiveEncryptionKey(); + + if (!encryptionKey) { + logger.warn( + `Participant ${participantId} did not share a key over Matrix` + ); + continue; + } + + this.onSetEncryptionKey( + await createKeyMaterialFromString(encryptionKey), + participantId + ); + } + }; +} diff --git a/src/livekit/useLiveKit.ts b/src/livekit/useLiveKit.ts index 1f5704b33..5adccee1f 100644 --- a/src/livekit/useLiveKit.ts +++ b/src/livekit/useLiveKit.ts @@ -17,7 +17,6 @@ limitations under the License. import { ConnectionState, E2EEOptions, - ExternalE2EEKeyProvider, Room, RoomOptions, setLogLevel, @@ -26,6 +25,8 @@ import { useLiveKitRoom } from "@livekit/components-react"; import { useEffect, useMemo, useRef } from "react"; import E2EEWorker from "livekit-client/e2ee-worker?worker"; import { logger } from "matrix-js-sdk/src/logger"; +import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession"; +import { ExternalE2EEKeyProvider } from "livekit-client/dist/src/e2ee/KeyProvider"; import { defaultLiveKitOptions } from "./options"; import { SFUConfig } from "./openIDSFU"; @@ -39,6 +40,7 @@ import { ECConnectionState, useECConnectionState, } from "./useECConnectionState"; +import { MatrixKeyProvider } from "../e2ee/matrixKeyProvider"; export type E2EEConfig = { sharedKey: string; @@ -53,6 +55,7 @@ interface UseLivekitResult { export function useLiveKit( muteStates: MuteStates, + rtcSession: MatrixRTCSession, sfuConfig?: SFUConfig, e2eeConfig?: E2EEConfig ): UseLivekitResult { diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 76cb7c07f..22723a08d 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -95,6 +95,7 @@ export function ActiveCall(props: ActiveCallProps) { const sfuConfig = useOpenIDSFU(props.client, props.rtcSession); const { livekitRoom, connState } = useLiveKit( props.muteStates, + props.rtcSession, sfuConfig, props.e2eeConfig ); From b45c8924a65f84de8b3743b5d30c6b6d6c254015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 23 Aug 2023 11:01:49 +0200 Subject: [PATCH 02/26] Handle embedding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/E2EEBanner.tsx | 4 +-- src/UrlParams.ts | 5 ++++ src/e2ee/matrixKeyProvider.ts | 28 ++++++++++++-------- src/e2ee/sharedKeyManagement.ts | 32 +++++++++++++++++++---- src/home/RegisteredView.tsx | 4 +-- src/home/UnauthenticatedView.tsx | 4 +-- src/livekit/useLiveKit.ts | 44 ++++++++++++++++++++++---------- src/room/GroupCallView.tsx | 39 +++++++++++++++++----------- src/room/useLoadGroupCall.ts | 4 +-- src/rtcSessionHelpers.ts | 7 +++-- src/settings/SettingsModal.tsx | 4 +-- src/settings/useSetting.ts | 7 ++--- src/widget.ts | 2 ++ 13 files changed, 125 insertions(+), 59 deletions(-) diff --git a/src/E2EEBanner.tsx b/src/E2EEBanner.tsx index 774f3582a..28b9e3498 100644 --- a/src/E2EEBanner.tsx +++ b/src/E2EEBanner.tsx @@ -19,10 +19,10 @@ import { Trans } from "react-i18next"; import { Banner } from "./Banner"; import styles from "./E2EEBanner.module.css"; import { ReactComponent as LockOffIcon } from "./icons/LockOff.svg"; -import { useEnableE2EE } from "./settings/useSetting"; +import { useEnableE2EE } from "./e2ee/sharedKeyManagement"; export const E2EEBanner = () => { - const [e2eeEnabled] = useEnableE2EE(); + const e2eeEnabled = useEnableE2EE(); if (e2eeEnabled) return null; return ( diff --git a/src/UrlParams.ts b/src/UrlParams.ts index e6f0cd05b..0ba9e0492 100644 --- a/src/UrlParams.ts +++ b/src/UrlParams.ts @@ -92,6 +92,10 @@ interface UrlParams { * E2EE password */ password: string | null; + /** + * Whether we the app should use per participant keys for E2EE. + */ + perParticipantE2EE: boolean; } /** @@ -190,6 +194,7 @@ export const getUrlParams = ( fontScale: Number.isNaN(fontScale) ? null : fontScale, analyticsID: getParam("analyticsID"), allowIceFallback: hasParam("allowIceFallback"), + perParticipantE2EE: hasParam("perParticipantE2EE"), }; }; diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index 2d0bc1a80..532cb0e49 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -15,11 +15,7 @@ limitations under the License. */ import { logger } from "@sentry/utils"; -import { - BaseKeyProvider, - KeyProviderOptions, - createKeyMaterialFromString, -} from "livekit-client"; +import { BaseKeyProvider, createKeyMaterialFromString } from "livekit-client"; import { CallMembership } from "matrix-js-sdk/src/matrixrtc/CallMembership"; import { MatrixRTCSession, @@ -27,19 +23,29 @@ import { } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession"; export class MatrixKeyProvider extends BaseKeyProvider { - constructor( - private rtcSession: MatrixRTCSession, - keyProviderOptions: Partial = {} - ) { - super(keyProviderOptions); + private rtcSession?: MatrixRTCSession; - const encryptionKey = this.rtcSession.activeEncryptionKey; + public setRTCSession(rtcSession: MatrixRTCSession) { + const encryptionKey = rtcSession.activeEncryptionKey; if (!encryptionKey) { throw new Error( "MatrixKeyProvider requires the given MatrixRTCSession to have an activeEncryptionKey" ); } + if (this.rtcSession) { + this.rtcSession.off( + MatrixRTCSessionEvent.MembershipsChanged, + this.onMemberShipsChanged + ); + this.rtcSession.off( + MatrixRTCSessionEvent.ActiveEncryptionKeyChanged, + this.onEncryptionKeyChanged + ); + } + + this.rtcSession = rtcSession; + this.rtcSession.on( MatrixRTCSessionEvent.MembershipsChanged, this.onMemberShipsChanged diff --git a/src/e2ee/sharedKeyManagement.ts b/src/e2ee/sharedKeyManagement.ts index 83eca2eae..9fb087086 100644 --- a/src/e2ee/sharedKeyManagement.ts +++ b/src/e2ee/sharedKeyManagement.ts @@ -15,8 +15,9 @@ limitations under the License. */ import { useEffect, useMemo } from "react"; +import { isE2EESupported } from "livekit-client"; -import { useEnableE2EE } from "../settings/useSetting"; +import { useEnableSPAE2EE } from "../settings/useSetting"; import { useLocalStorage } from "../useLocalStorage"; import { useClient } from "../ClientContext"; import { PASSWORD_STRING, useUrlParams } from "../UrlParams"; @@ -28,7 +29,7 @@ export const useInternalRoomSharedKey = ( roomId: string ): [string | null, (value: string) => void] => { const key = useMemo(() => getRoomSharedKeyLocalStorageKey(roomId), [roomId]); - const [e2eeEnabled] = useEnableE2EE(); + const [e2eeEnabled] = useEnableSPAE2EE(); const [roomSharedKey, setRoomSharedKey] = useLocalStorage(key); return [e2eeEnabled ? roomSharedKey : null, setRoomSharedKey]; @@ -67,7 +68,7 @@ export const useManageRoomSharedKey = (roomId: string): string | null => { }; export const useIsRoomE2EE = (roomId: string): boolean | null => { - const { isEmbedded } = useUrlParams(); + const { isEmbedded, perParticipantE2EE } = useUrlParams(); const client = useClient(); const room = useMemo( () => client.client?.getRoom(roomId) ?? null, @@ -75,11 +76,32 @@ export const useIsRoomE2EE = (roomId: string): boolean | null => { ); const isE2EE = useMemo(() => { if (isEmbedded) { - return false; + return perParticipantE2EE; } else { return room ? !room?.getCanonicalAlias() : null; } - }, [isEmbedded, room]); + }, [room, isEmbedded, perParticipantE2EE]); return isE2EE; }; + +export const useEnableEmbeddedE2EE = (): boolean => { + const { isEmbedded, perParticipantE2EE } = useUrlParams(); + + if (!isEmbedded) return false; + if (!isE2EESupported()) return false; + + return perParticipantE2EE; +}; + +export const useEnableE2EE = (): boolean => { + const [spaE2EEEnabled] = useEnableSPAE2EE(); + const embeddedE2EEEnabled = useEnableEmbeddedE2EE(); + + const e2eeEnabled = useMemo( + () => spaE2EEEnabled || embeddedE2EEEnabled, + [spaE2EEEnabled, embeddedE2EEEnabled] + ); + + return e2eeEnabled; +}; diff --git a/src/home/RegisteredView.tsx b/src/home/RegisteredView.tsx index 42aba9e82..511b89f7e 100644 --- a/src/home/RegisteredView.tsx +++ b/src/home/RegisteredView.tsx @@ -38,7 +38,7 @@ import { JoinExistingCallModal } from "./JoinExistingCallModal"; import { Caption, Title } from "../typography/Typography"; import { Form } from "../form/Form"; import { CallType, CallTypeDropdown } from "./CallTypeDropdown"; -import { useEnableE2EE, useOptInAnalytics } from "../settings/useSetting"; +import { useEnableSPAE2EE, useOptInAnalytics } from "../settings/useSetting"; import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; import { E2EEBanner } from "../E2EEBanner"; import { setLocalStorageItem } from "../useLocalStorage"; @@ -57,7 +57,7 @@ export function RegisteredView({ client, isPasswordlessUser }: Props) { const history = useHistory(); const { t } = useTranslation(); const { modalState, modalProps } = useModalTriggerState(); - const [e2eeEnabled] = useEnableE2EE(); + const [e2eeEnabled] = useEnableSPAE2EE(); const onSubmit: FormEventHandler = useCallback( (e: FormEvent) => { diff --git a/src/home/UnauthenticatedView.tsx b/src/home/UnauthenticatedView.tsx index 721c56d14..c0099b6c9 100644 --- a/src/home/UnauthenticatedView.tsx +++ b/src/home/UnauthenticatedView.tsx @@ -40,7 +40,7 @@ import styles from "./UnauthenticatedView.module.css"; import commonStyles from "./common.module.css"; import { generateRandomName } from "../auth/generateRandomName"; import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; -import { useEnableE2EE, useOptInAnalytics } from "../settings/useSetting"; +import { useEnableSPAE2EE, useOptInAnalytics } from "../settings/useSetting"; import { Config } from "../config/Config"; import { E2EEBanner } from "../E2EEBanner"; import { getRoomSharedKeyLocalStorageKey } from "../e2ee/sharedKeyManagement"; @@ -60,7 +60,7 @@ export const UnauthenticatedView: FC = () => { const history = useHistory(); const { t } = useTranslation(); - const [e2eeEnabled] = useEnableE2EE(); + const [e2eeEnabled] = useEnableSPAE2EE(); const onSubmit: FormEventHandler = useCallback( (e) => { diff --git a/src/livekit/useLiveKit.ts b/src/livekit/useLiveKit.ts index 5adccee1f..337872fd6 100644 --- a/src/livekit/useLiveKit.ts +++ b/src/livekit/useLiveKit.ts @@ -16,7 +16,7 @@ limitations under the License. import { ConnectionState, - E2EEOptions, + ExternalE2EEKeyProvider, Room, RoomOptions, setLogLevel, @@ -42,8 +42,14 @@ import { } from "./useECConnectionState"; import { MatrixKeyProvider } from "../e2ee/matrixKeyProvider"; +export enum E2EEMode { + PerParticipantKey = "per_participant_key", + SharedKey = "shared_key", +} + export type E2EEConfig = { - sharedKey: string; + mode: E2EEMode; + sharedKey?: string; }; setLogLevel("debug"); @@ -60,21 +66,33 @@ export function useLiveKit( e2eeConfig?: E2EEConfig ): UseLivekitResult { const e2eeOptions = useMemo(() => { - if (!e2eeConfig?.sharedKey) return undefined; + if (!e2eeConfig) return undefined; - return { - keyProvider: new ExternalE2EEKeyProvider(), - worker: new E2EEWorker(), - } as E2EEOptions; + if (e2eeConfig.mode === E2EEMode.PerParticipantKey) { + return { + keyProvider: new MatrixKeyProvider(), + worker: new E2EEWorker(), + }; + } else if (e2eeConfig.mode === E2EEMode.SharedKey && e2eeConfig.sharedKey) { + return { + keyProvider: new ExternalE2EEKeyProvider(), + worker: new E2EEWorker(), + }; + } }, [e2eeConfig]); useEffect(() => { - if (!e2eeConfig?.sharedKey || !e2eeOptions) return; - - (e2eeOptions.keyProvider as ExternalE2EEKeyProvider).setKey( - e2eeConfig?.sharedKey - ); - }, [e2eeOptions, e2eeConfig?.sharedKey]); + if (!e2eeOptions) return; + if (!e2eeConfig) return; + + if (e2eeConfig.mode === E2EEMode.PerParticipantKey) { + (e2eeOptions.keyProvider as MatrixKeyProvider).setRTCSession(rtcSession); + } else if (e2eeConfig.mode === E2EEMode.SharedKey && e2eeConfig.sharedKey) { + (e2eeOptions.keyProvider as ExternalE2EEKeyProvider).setKey( + e2eeConfig.sharedKey + ); + } + }, [e2eeOptions, e2eeConfig, rtcSession]); const initialMuteStates = useRef(muteStates); const devices = useMediaDevices(); diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index 57182b040..bef42b018 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -40,8 +40,12 @@ import { useMatrixRTCSessionJoinState } from "../useMatrixRTCSessionJoinState"; import { useManageRoomSharedKey, useIsRoomE2EE, + useEnableEmbeddedE2EE, + useEnableE2EE, } from "../e2ee/sharedKeyManagement"; -import { useEnableE2EE } from "../settings/useSetting"; +import { useEnableSPAE2EE } from "../settings/useSetting"; +import { E2EEConfig, E2EEMode } from "../livekit/useLiveKit"; +import { useUrlParams } from "../UrlParams"; declare global { interface Window { @@ -71,6 +75,10 @@ export function GroupCallView({ const e2eeSharedKey = useManageRoomSharedKey(rtcSession.room.roomId); const isRoomE2EE = useIsRoomE2EE(rtcSession.room.roomId); + const [spaE2EEEnabled] = useEnableSPAE2EE(); + const embeddedE2EEEnabled = useEnableEmbeddedE2EE(); + const e2eeEnabled = useEnableE2EE(); + const { perParticipantE2EE } = useUrlParams(); const { t } = useTranslation(); @@ -153,7 +161,7 @@ export function GroupCallView({ } } - enterRTCSession(rtcSession); + enterRTCSession(rtcSession, embeddedE2EEEnabled); PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date()); // we only have room sessions right now, so call ID is the emprty string - we use the room ID @@ -172,18 +180,18 @@ export function GroupCallView({ widget!.lazyActions.off(ElementWidgetActions.JoinCall, onJoin); }; } - }, [rtcSession, preload]); + }, [rtcSession, preload, embeddedE2EEEnabled]); useEffect(() => { if (isEmbedded && !preload) { // In embedded mode, bypass the lobby and just enter the call straight away - enterRTCSession(rtcSession); + enterRTCSession(rtcSession, embeddedE2EEEnabled); PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date()); // use the room ID as above PosthogAnalytics.instance.eventCallStarted.track(rtcSession.room.roomId); } - }, [rtcSession, isEmbedded, preload]); + }, [rtcSession, isEmbedded, preload, embeddedE2EEEnabled]); const [left, setLeft] = useState(false); const [leaveError, setLeaveError] = useState(undefined); @@ -237,20 +245,21 @@ export function GroupCallView({ } }, [isJoined, rtcSession]); - const [e2eeEnabled] = useEnableE2EE(); - - const e2eeConfig = useMemo( - () => (e2eeSharedKey ? { sharedKey: e2eeSharedKey } : undefined), - [e2eeSharedKey] - ); + const e2eeConfig = useMemo((): E2EEConfig | undefined => { + if (perParticipantE2EE) { + return { mode: E2EEMode.PerParticipantKey }; + } else if (e2eeSharedKey) { + return { mode: E2EEMode.SharedKey, sharedKey: e2eeSharedKey }; + } + }, [perParticipantE2EE, e2eeSharedKey]); const onReconnect = useCallback(() => { setLeft(false); setLeaveError(undefined); - enterRTCSession(rtcSession); - }, [rtcSession]); + enterRTCSession(rtcSession, embeddedE2EEEnabled); + }, [rtcSession, embeddedE2EEEnabled]); - if (e2eeEnabled && isRoomE2EE && !e2eeSharedKey) { + if (spaE2EEEnabled && isRoomE2EE && !e2eeSharedKey) { return ( enterRTCSession(rtcSession)} + onEnter={() => enterRTCSession(rtcSession, embeddedE2EEEnabled)} isEmbedded={isEmbedded} hideHeader={hideHeader} /> diff --git a/src/room/useLoadGroupCall.ts b/src/room/useLoadGroupCall.ts index 9218bf32c..23f068a47 100644 --- a/src/room/useLoadGroupCall.ts +++ b/src/room/useLoadGroupCall.ts @@ -26,7 +26,7 @@ import type { Room } from "matrix-js-sdk/src/models/room"; import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall"; import { setLocalStorageItem } from "../useLocalStorage"; import { isLocalRoomId, createRoom, roomNameFromRoomId } from "../matrix-utils"; -import { useEnableE2EE } from "../settings/useSetting"; +import { useEnableSPAE2EE } from "../settings/useSetting"; import { getRoomSharedKeyLocalStorageKey } from "../e2ee/sharedKeyManagement"; export type GroupCallLoaded = { @@ -62,7 +62,7 @@ export const useLoadGroupCall = ( const { t } = useTranslation(); const [state, setState] = useState({ kind: "loading" }); - const [e2eeEnabled] = useEnableE2EE(); + const [e2eeEnabled] = useEnableSPAE2EE(); useEffect(() => { const fetchOrCreateRoom = async (): Promise => { diff --git a/src/rtcSessionHelpers.ts b/src/rtcSessionHelpers.ts index 3d62f9804..9cfcdcd23 100644 --- a/src/rtcSessionHelpers.ts +++ b/src/rtcSessionHelpers.ts @@ -33,7 +33,10 @@ function makeFocus(livekitAlias: string): LivekitFocus { }; } -export function enterRTCSession(rtcSession: MatrixRTCSession) { +export function enterRTCSession( + rtcSession: MatrixRTCSession, + encryptMedia: boolean +) { PosthogAnalytics.instance.eventCallEnded.cacheStartCall(new Date()); PosthogAnalytics.instance.eventCallStarted.track(rtcSession.room.roomId); @@ -44,7 +47,7 @@ export function enterRTCSession(rtcSession: MatrixRTCSession) { // right now we asume everything is a room-scoped call const livekitAlias = rtcSession.room.roomId; - rtcSession.joinRoomSession([makeFocus(livekitAlias)]); + rtcSession.joinRoomSession([makeFocus(livekitAlias)], encryptMedia); } export function leaveRTCSession(rtcSession: MatrixRTCSession) { diff --git a/src/settings/SettingsModal.tsx b/src/settings/SettingsModal.tsx index 0d4983ed4..501283703 100644 --- a/src/settings/SettingsModal.tsx +++ b/src/settings/SettingsModal.tsx @@ -34,7 +34,7 @@ import { useOptInAnalytics, useDeveloperSettingsTab, useShowConnectionStats, - useEnableE2EE, + useEnableSPAE2EE, } from "./useSetting"; import { FieldRow, InputField } from "../input/Input"; import { Button } from "../button"; @@ -69,7 +69,7 @@ export const SettingsModal = (props: Props) => { useDeveloperSettingsTab(); const [showConnectionStats, setShowConnectionStats] = useShowConnectionStats(); - const [enableE2EE, setEnableE2EE] = useEnableE2EE(); + const [enableE2EE, setEnableE2EE] = useEnableSPAE2EE(); const downloadDebugLog = useDownloadDebugLog(); diff --git a/src/settings/useSetting.ts b/src/settings/useSetting.ts index 5d86a4b64..344f0d426 100644 --- a/src/settings/useSetting.ts +++ b/src/settings/useSetting.ts @@ -89,14 +89,15 @@ export const useOptInAnalytics = (): DisableableSetting => { return [false, null]; }; -export const useEnableE2EE = (): DisableableSetting => { +export const useEnableSPAE2EE = (): DisableableSetting => { const settingVal = useSetting( "enable-end-to-end-encryption", false ); - if (isE2EESupported()) return settingVal; - return [false, null]; + if (!isE2EESupported()) return [false, null]; + + return settingVal; }; export const useDeveloperSettingsTab = () => diff --git a/src/widget.ts b/src/widget.ts index 324dbe4a0..b948f5755 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -79,6 +79,8 @@ export const widget: WidgetHelpers | null = (() => { logger.info("Widget API is available"); const api = new WidgetApi(widgetId, parentOrigin); api.requestCapability(MatrixCapabilities.AlwaysOnScreen); + api.requestCapabilityToSendEvent(EventType.CallEncryptionPrefix); + api.requestCapabilityToReceiveEvent(EventType.CallEncryptionPrefix); // Set up the lazy action emitter, but only for select actions that we // intend for the app to handle From f279bd69d7a41116450de4ecf1123e3727cd4106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 24 Aug 2023 12:09:10 +0200 Subject: [PATCH 03/26] Remove unnecessary call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/widget.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/widget.ts b/src/widget.ts index b948f5755..aec8fd3d2 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -23,7 +23,6 @@ import type { MatrixClient } from "matrix-js-sdk/src/client"; import type { IWidgetApiRequest } from "matrix-widget-api"; import { LazyEventEmitter } from "./LazyEventEmitter"; import { getUrlParams } from "./UrlParams"; -import { Config } from "./config/Config"; // Subset of the actions in matrix-react-sdk export enum ElementWidgetActions { @@ -164,9 +163,6 @@ export const widget: WidgetHelpers | null = (() => { const clientPromise = new Promise((resolve) => { (async () => { - // wait for the config file to be ready (we load very early on so it might not - // be otherwise) - await Config.init(); await client.startClient(); resolve(client); })(); From 127e8c9103e5252c9ffa18b690a5d62c49d0e9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 28 Aug 2023 10:46:02 +0200 Subject: [PATCH 04/26] `sharedKeyManagement.ts` -> `e2eeHooks.ts` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/E2EEBanner.tsx | 2 +- src/e2ee/{sharedKeyManagement.ts => e2eeHooks.ts} | 0 src/home/CallList.tsx | 2 +- src/home/RegisteredView.tsx | 2 +- src/home/UnauthenticatedView.tsx | 2 +- src/room/GroupCallView.tsx | 2 +- src/room/InCallView.tsx | 2 +- src/room/InviteModal.tsx | 2 +- src/room/LobbyView.tsx | 2 +- src/room/useLoadGroupCall.ts | 2 +- 10 files changed, 9 insertions(+), 9 deletions(-) rename src/e2ee/{sharedKeyManagement.ts => e2eeHooks.ts} (100%) diff --git a/src/E2EEBanner.tsx b/src/E2EEBanner.tsx index 28b9e3498..c1a44cb5e 100644 --- a/src/E2EEBanner.tsx +++ b/src/E2EEBanner.tsx @@ -19,7 +19,7 @@ import { Trans } from "react-i18next"; import { Banner } from "./Banner"; import styles from "./E2EEBanner.module.css"; import { ReactComponent as LockOffIcon } from "./icons/LockOff.svg"; -import { useEnableE2EE } from "./e2ee/sharedKeyManagement"; +import { useEnableE2EE } from "./e2ee/e2eeHooks"; export const E2EEBanner = () => { const e2eeEnabled = useEnableE2EE(); diff --git a/src/e2ee/sharedKeyManagement.ts b/src/e2ee/e2eeHooks.ts similarity index 100% rename from src/e2ee/sharedKeyManagement.ts rename to src/e2ee/e2eeHooks.ts diff --git a/src/home/CallList.tsx b/src/home/CallList.tsx index 1e36360eb..169711700 100644 --- a/src/home/CallList.tsx +++ b/src/home/CallList.tsx @@ -25,7 +25,7 @@ import styles from "./CallList.module.css"; import { getRoomUrl } from "../matrix-utils"; import { Body } from "../typography/Typography"; import { GroupCallRoom } from "./useGroupCallRooms"; -import { useRoomSharedKey } from "../e2ee/sharedKeyManagement"; +import { useRoomSharedKey } from "../e2ee/e2eeHooks"; interface CallListProps { rooms: GroupCallRoom[]; diff --git a/src/home/RegisteredView.tsx b/src/home/RegisteredView.tsx index 511b89f7e..d0829b250 100644 --- a/src/home/RegisteredView.tsx +++ b/src/home/RegisteredView.tsx @@ -42,7 +42,7 @@ import { useEnableSPAE2EE, useOptInAnalytics } from "../settings/useSetting"; import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; import { E2EEBanner } from "../E2EEBanner"; import { setLocalStorageItem } from "../useLocalStorage"; -import { getRoomSharedKeyLocalStorageKey } from "../e2ee/sharedKeyManagement"; +import { getRoomSharedKeyLocalStorageKey } from "../e2ee/e2eeHooks"; interface Props { client: MatrixClient; diff --git a/src/home/UnauthenticatedView.tsx b/src/home/UnauthenticatedView.tsx index c0099b6c9..cbdbd298b 100644 --- a/src/home/UnauthenticatedView.tsx +++ b/src/home/UnauthenticatedView.tsx @@ -43,7 +43,7 @@ import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; import { useEnableSPAE2EE, useOptInAnalytics } from "../settings/useSetting"; import { Config } from "../config/Config"; import { E2EEBanner } from "../E2EEBanner"; -import { getRoomSharedKeyLocalStorageKey } from "../e2ee/sharedKeyManagement"; +import { getRoomSharedKeyLocalStorageKey } from "../e2ee/e2eeHooks"; import { setLocalStorageItem } from "../useLocalStorage"; export const UnauthenticatedView: FC = () => { diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index bef42b018..a5dd15900 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -42,7 +42,7 @@ import { useIsRoomE2EE, useEnableEmbeddedE2EE, useEnableE2EE, -} from "../e2ee/sharedKeyManagement"; +} from "../e2ee/e2eeHooks"; import { useEnableSPAE2EE } from "../settings/useSetting"; import { E2EEConfig, E2EEMode } from "../livekit/useLiveKit"; import { useUrlParams } from "../UrlParams"; diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 22723a08d..4fcf4ee29 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -76,7 +76,7 @@ import { E2EELock } from "../E2EELock"; import { useWakeLock } from "../useWakeLock"; import { useMergedRefs } from "../useMergedRefs"; import { MuteStates } from "./MuteStates"; -import { useIsRoomE2EE } from "../e2ee/sharedKeyManagement"; +import { useIsRoomE2EE } from "../e2ee/e2eeHooks"; import { useOpenIDSFU } from "../livekit/openIDSFU"; import { ECConnectionState } from "../livekit/useECConnectionState"; diff --git a/src/room/InviteModal.tsx b/src/room/InviteModal.tsx index 98c622987..32eb39c40 100644 --- a/src/room/InviteModal.tsx +++ b/src/room/InviteModal.tsx @@ -21,7 +21,7 @@ import { Modal, ModalContent, ModalProps } from "../Modal"; import { CopyButton } from "../button"; import { getRoomUrl } from "../matrix-utils"; import styles from "./InviteModal.module.css"; -import { useRoomSharedKey } from "../e2ee/sharedKeyManagement"; +import { useRoomSharedKey } from "../e2ee/e2eeHooks"; interface Props extends Omit { roomId: string; diff --git a/src/room/LobbyView.tsx b/src/room/LobbyView.tsx index a34595c91..5ddb3219e 100644 --- a/src/room/LobbyView.tsx +++ b/src/room/LobbyView.tsx @@ -26,7 +26,7 @@ import { Body, Link } from "../typography/Typography"; import { useLocationNavigation } from "../useLocationNavigation"; import { MatrixInfo, VideoPreview } from "./VideoPreview"; import { MuteStates } from "./MuteStates"; -import { useRoomSharedKey } from "../e2ee/sharedKeyManagement"; +import { useRoomSharedKey } from "../e2ee/e2eeHooks"; interface Props { matrixInfo: MatrixInfo; diff --git a/src/room/useLoadGroupCall.ts b/src/room/useLoadGroupCall.ts index 23f068a47..0b7a0c530 100644 --- a/src/room/useLoadGroupCall.ts +++ b/src/room/useLoadGroupCall.ts @@ -27,7 +27,7 @@ import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall"; import { setLocalStorageItem } from "../useLocalStorage"; import { isLocalRoomId, createRoom, roomNameFromRoomId } from "../matrix-utils"; import { useEnableSPAE2EE } from "../settings/useSetting"; -import { getRoomSharedKeyLocalStorageKey } from "../e2ee/sharedKeyManagement"; +import { getRoomSharedKeyLocalStorageKey } from "../e2ee/e2eeHooks"; export type GroupCallLoaded = { kind: "loaded"; From b57454fbc135fecd84313a9586229eaba25ae26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 29 Aug 2023 16:50:26 +0200 Subject: [PATCH 05/26] Change embedded E2EE implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/e2ee/matrixKeyProvider.ts | 64 +++++++++++------------------------ src/livekit/useLiveKit.ts | 1 - 2 files changed, 20 insertions(+), 45 deletions(-) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index 532cb0e49..31dfeb336 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -14,9 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { logger } from "@sentry/utils"; import { BaseKeyProvider, createKeyMaterialFromString } from "livekit-client"; -import { CallMembership } from "matrix-js-sdk/src/matrixrtc/CallMembership"; import { MatrixRTCSession, MatrixRTCSessionEvent, @@ -26,20 +24,9 @@ export class MatrixKeyProvider extends BaseKeyProvider { private rtcSession?: MatrixRTCSession; public setRTCSession(rtcSession: MatrixRTCSession) { - const encryptionKey = rtcSession.activeEncryptionKey; - if (!encryptionKey) { - throw new Error( - "MatrixKeyProvider requires the given MatrixRTCSession to have an activeEncryptionKey" - ); - } - if (this.rtcSession) { this.rtcSession.off( - MatrixRTCSessionEvent.MembershipsChanged, - this.onMemberShipsChanged - ); - this.rtcSession.off( - MatrixRTCSessionEvent.ActiveEncryptionKeyChanged, + MatrixRTCSessionEvent.EncryptionKeyChanged, this.onEncryptionKeyChanged ); } @@ -47,41 +34,30 @@ export class MatrixKeyProvider extends BaseKeyProvider { this.rtcSession = rtcSession; this.rtcSession.on( - MatrixRTCSessionEvent.MembershipsChanged, - this.onMemberShipsChanged - ); - this.rtcSession.on( - MatrixRTCSessionEvent.ActiveEncryptionKeyChanged, + MatrixRTCSessionEvent.EncryptionKeyChanged, this.onEncryptionKeyChanged ); - this.onEncryptionKeyChanged(encryptionKey); - this.onMemberShipsChanged([], this.rtcSession.memberships); + for (const [ + participant, + encryptionKey, + ] of this.rtcSession.encryptionKeys.entries()) { + this.onEncryptionKeyChanged( + encryptionKey, + participant.userId, + participant.deviceId + ); + } } - private onEncryptionKeyChanged = async (key: string) => { - this.onSetEncryptionKey(await createKeyMaterialFromString(key), undefined); - }; - - private onMemberShipsChanged = async ( - _: CallMembership[], - newMemberships: CallMembership[] + private onEncryptionKeyChanged = async ( + encryptionKey: string, + userId: string, + deviceId: string ) => { - for (const membership of newMemberships) { - const participantId = `${membership.member.userId}:${membership.deviceId}`; - const encryptionKey = await membership.getActiveEncryptionKey(); - - if (!encryptionKey) { - logger.warn( - `Participant ${participantId} did not share a key over Matrix` - ); - continue; - } - - this.onSetEncryptionKey( - await createKeyMaterialFromString(encryptionKey), - participantId - ); - } + this.onSetEncryptionKey( + await createKeyMaterialFromString(encryptionKey), + `${userId}:${deviceId}` + ); }; } diff --git a/src/livekit/useLiveKit.ts b/src/livekit/useLiveKit.ts index 337872fd6..5a8775a1b 100644 --- a/src/livekit/useLiveKit.ts +++ b/src/livekit/useLiveKit.ts @@ -26,7 +26,6 @@ import { useEffect, useMemo, useRef } from "react"; import E2EEWorker from "livekit-client/e2ee-worker?worker"; import { logger } from "matrix-js-sdk/src/logger"; import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession"; -import { ExternalE2EEKeyProvider } from "livekit-client/dist/src/e2ee/KeyProvider"; import { defaultLiveKitOptions } from "./options"; import { SFUConfig } from "./openIDSFU"; From ee304fb4b325bb11eea056e305e5a89ebc9b9de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 25 Aug 2023 14:55:15 +0200 Subject: [PATCH 06/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 8e9facdf6..356cf43f7 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#c444e374407cee40643438e01270e1e6e2835e82", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#ebcdd161cdf695d720420e421f8aee5775d5d21d", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index d3d8d77be..bb3374047 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10949,9 +10949,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#c444e374407cee40643438e01270e1e6e2835e82": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#ebcdd161cdf695d720420e421f8aee5775d5d21d": version "27.2.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/c444e374407cee40643438e01270e1e6e2835e82" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/ebcdd161cdf695d720420e421f8aee5775d5d21d" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" @@ -10961,17 +10961,17 @@ matrix-events-sdk@0.0.1: jwt-decode "^3.1.2" loglevel "^1.7.1" matrix-events-sdk "0.0.1" - matrix-widget-api "^1.5.0" + matrix-widget-api "^1.6.0" oidc-client-ts "^2.2.4" p-retry "4" sdp-transform "^2.14.1" unhomoglyph "^1.0.6" uuid "9" -matrix-widget-api@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.5.0.tgz#4ae3e46a7f2854f944ddaf8a5af63d72fba76c45" - integrity sha512-hKGfqQKK5qVMwW0Sp8l2TiuW8UuHafTvUZNSWBPghedB/rSFbVLlr0mufuEV0iq/pQ7ChW96q/WEC6Llie4SnA== +matrix-widget-api@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.6.0.tgz#f0075411edffc6de339580ade7e6e6e6edb01af4" + integrity sha512-VXIJyAZ/WnBmT4C7ePqevgMYGneKMCP/0JuCOqntSsaNlCRHJvwvTxmqUU+ufOpzIF5gYNyIrAjbgrEbK3iqJQ== dependencies: "@types/events" "^3.0.0" events "^3.2.0" From 1a7b7c94705b83fd2366cde25298b1baadb9904e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 31 Aug 2023 14:13:02 +0200 Subject: [PATCH 07/26] Update-js sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 356cf43f7..ae37e6860 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#ebcdd161cdf695d720420e421f8aee5775d5d21d", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#ab05751ed00fd66e9a1de07957e11b673a72369d", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index bb3374047..d9c164b9b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10949,9 +10949,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#ebcdd161cdf695d720420e421f8aee5775d5d21d": - version "27.2.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/ebcdd161cdf695d720420e421f8aee5775d5d21d" +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#ab05751ed00fd66e9a1de07957e11b673a72369d": + version "28.0.0" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/ab05751ed00fd66e9a1de07957e11b673a72369d" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 912ed55f1ea97f45774031fe2433b3c078f58281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 4 Sep 2023 16:01:32 +0200 Subject: [PATCH 08/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ae37e6860..2add20c39 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#ab05751ed00fd66e9a1de07957e11b673a72369d", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#6ee456eb3cb31b196ea8ded7730de61397291684", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index d9c164b9b..da9c870f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10949,9 +10949,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#ab05751ed00fd66e9a1de07957e11b673a72369d": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#6ee456eb3cb31b196ea8ded7730de61397291684": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/ab05751ed00fd66e9a1de07957e11b673a72369d" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/6ee456eb3cb31b196ea8ded7730de61397291684" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From ae04cfc53edb2c09fdac7930f8e1dd3de5cc8d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 4 Sep 2023 16:04:49 +0200 Subject: [PATCH 09/26] Add a comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/e2ee/matrixKeyProvider.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index 31dfeb336..afba326a7 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -42,6 +42,8 @@ export class MatrixKeyProvider extends BaseKeyProvider { participant, encryptionKey, ] of this.rtcSession.encryptionKeys.entries()) { + // The new session could be aware of keys of which the old session wasn't, + // so emit a key changed event. this.onEncryptionKeyChanged( encryptionKey, participant.userId, From 2ec75571d08833f6399d8b0c91aeb1dab7b8cd4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 4 Sep 2023 16:15:54 +0200 Subject: [PATCH 10/26] Fix `useEnableSPAE2EE` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/settings/useSetting.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/settings/useSetting.ts b/src/settings/useSetting.ts index f857dad11..8076bf6b5 100644 --- a/src/settings/useSetting.ts +++ b/src/settings/useSetting.ts @@ -23,6 +23,7 @@ import { setLocalStorageItem, useLocalStorage, } from "../useLocalStorage"; +import { useEnableEmbeddedE2EE } from "../e2ee/e2eeHooks"; type Setting = [T, (value: T) => void]; type DisableableSetting = [T, ((value: T) => void) | null]; @@ -90,11 +91,13 @@ export const useOptInAnalytics = (): DisableableSetting => { }; export const useEnableSPAE2EE = (): DisableableSetting => { + const embeddedE2EEEnabled = useEnableEmbeddedE2EE(); const settingVal = useSetting( "enable-end-to-end-encryption", true ); + if (embeddedE2EEEnabled) return [false, null]; if (!isE2EESupported()) return [false, null]; return settingVal; From 5862f911bcbacd4d3b355941950ae8d354b6c56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 4 Sep 2023 16:56:08 +0200 Subject: [PATCH 11/26] Fix map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/e2ee/matrixKeyProvider.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index afba326a7..c4ae66ed7 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -41,25 +41,20 @@ export class MatrixKeyProvider extends BaseKeyProvider { for (const [ participant, encryptionKey, - ] of this.rtcSession.encryptionKeys.entries()) { + ] of this.rtcSession.getEncryptionKeys()) { // The new session could be aware of keys of which the old session wasn't, // so emit a key changed event. - this.onEncryptionKeyChanged( - encryptionKey, - participant.userId, - participant.deviceId - ); + this.onEncryptionKeyChanged(encryptionKey, participant); } } private onEncryptionKeyChanged = async ( encryptionKey: string, - userId: string, - deviceId: string + participantId: string ) => { this.onSetEncryptionKey( await createKeyMaterialFromString(encryptionKey), - `${userId}:${deviceId}` + participantId ); }; } From 8516e528cbbbec9cee90c410429bdca4e2076ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 4 Sep 2023 17:02:33 +0200 Subject: [PATCH 12/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 3d810b1b0..52ada144f 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#6ee456eb3cb31b196ea8ded7730de61397291684", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#3498399221c9c8cef500cac595344da415fcca50", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index 311f10e2e..d87e2b85f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#6ee456eb3cb31b196ea8ded7730de61397291684": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#3498399221c9c8cef500cac595344da415fcca50": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/6ee456eb3cb31b196ea8ded7730de61397291684" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/3498399221c9c8cef500cac595344da415fcca50" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" @@ -11598,7 +11598,7 @@ matrix-events-sdk@0.0.1: jwt-decode "^3.1.2" loglevel "^1.7.1" matrix-events-sdk "0.0.1" - matrix-widget-api "^1.5.0" + matrix-widget-api "^1.6.0" oidc-client-ts "^2.2.4" p-retry "4" sdp-transform "^2.14.1" From 18185be49cb7569db3380130908c25bb70aa85f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 4 Sep 2023 18:23:22 +0200 Subject: [PATCH 13/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 52ada144f..9bbf3dfb1 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#3498399221c9c8cef500cac595344da415fcca50", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#36a26621c36267120d0e40f97daf0de7a9ceb9d4", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index d87e2b85f..1d1bb2534 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#3498399221c9c8cef500cac595344da415fcca50": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#36a26621c36267120d0e40f97daf0de7a9ceb9d4": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/3498399221c9c8cef500cac595344da415fcca50" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/36a26621c36267120d0e40f97daf0de7a9ceb9d4" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 0ac651b03aaf4e09b92cd21d4798e862dffca763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 6 Sep 2023 08:18:37 +0200 Subject: [PATCH 14/26] Explicit logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/e2ee/matrixKeyProvider.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index c4ae66ed7..0b810e01e 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -52,6 +52,10 @@ export class MatrixKeyProvider extends BaseKeyProvider { encryptionKey: string, participantId: string ) => { + console.log( + `Embedded-E2EE-LOG onEncryptionKeyChanged participantId=${participantId} encryptionKey=${encryptionKey}` + ); + this.onSetEncryptionKey( await createKeyMaterialFromString(encryptionKey), participantId From 6bc6d50bceff5e1b44f7feb1e05a1df2873fbd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 6 Sep 2023 08:19:25 +0200 Subject: [PATCH 15/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9bbf3dfb1..5b60cbf27 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#36a26621c36267120d0e40f97daf0de7a9ceb9d4", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#46fb3576657e0ad56714b7c1dd4db1d2daa2d8f3", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index 1d1bb2534..af530b4d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#36a26621c36267120d0e40f97daf0de7a9ceb9d4": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#46fb3576657e0ad56714b7c1dd4db1d2daa2d8f3": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/36a26621c36267120d0e40f97daf0de7a9ceb9d4" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/46fb3576657e0ad56714b7c1dd4db1d2daa2d8f3" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From ba5c0424bf91ea628fa04714e8e1912b67dbc72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 17:02:01 +0200 Subject: [PATCH 16/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5b60cbf27..ff26c625a 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#46fb3576657e0ad56714b7c1dd4db1d2daa2d8f3", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#451d26e726ad40fd902a8bd755c702694288a7fd", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index af530b4d9..ae32e3f77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#46fb3576657e0ad56714b7c1dd4db1d2daa2d8f3": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#451d26e726ad40fd902a8bd755c702694288a7fd": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/46fb3576657e0ad56714b7c1dd4db1d2daa2d8f3" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/451d26e726ad40fd902a8bd755c702694288a7fd" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 3a16dbe54eb85bd4407a4310eadcee28188f9109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 17:14:01 +0200 Subject: [PATCH 17/26] Update encryption key on mute change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/room/InCallView.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index ed3775a62..c1fb0911f 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -174,14 +174,14 @@ export function InCallView({ room: livekitRoom, }); - const toggleMicrophone = useCallback( - () => muteStates.audio.setEnabled?.((e) => !e), - [muteStates] - ); - const toggleCamera = useCallback( - () => muteStates.video.setEnabled?.((e) => !e), - [muteStates] - ); + const toggleMicrophone = useCallback(() => { + muteStates.audio.setEnabled?.((e) => !e); + rtcSession.updateEncryptionKeyEvent(); + }, [muteStates, rtcSession]); + const toggleCamera = useCallback(() => { + muteStates.video.setEnabled?.((e) => !e); + rtcSession.updateEncryptionKeyEvent(); + }, [muteStates, rtcSession]); const joinRule = useJoinRule(rtcSession.room); From 3d57faca2671534b515a73e7b25b2532835eb8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 17:14:59 +0200 Subject: [PATCH 18/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ff26c625a..2e94541f7 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#451d26e726ad40fd902a8bd755c702694288a7fd", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#adeb5673ec0f2ab1be4e8613c5ee1607ed52312d", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index ae32e3f77..3c81586a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#451d26e726ad40fd902a8bd755c702694288a7fd": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#adeb5673ec0f2ab1be4e8613c5ee1607ed52312d": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/451d26e726ad40fd902a8bd755c702694288a7fd" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/adeb5673ec0f2ab1be4e8613c5ee1607ed52312d" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 8bae276fabada392e9e057e08240af43d11fcaeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 17:32:35 +0200 Subject: [PATCH 19/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2e94541f7..0a184584e 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#adeb5673ec0f2ab1be4e8613c5ee1607ed52312d", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#e44674b8f823e470bf8edccc236d984e49d8d933", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index 3c81586a9..bbeb185f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#adeb5673ec0f2ab1be4e8613c5ee1607ed52312d": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#e44674b8f823e470bf8edccc236d984e49d8d933": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/adeb5673ec0f2ab1be4e8613c5ee1607ed52312d" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/e44674b8f823e470bf8edccc236d984e49d8d933" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 3a62eccdea17d48121261decd8eb866f57294c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 17:39:33 +0200 Subject: [PATCH 20/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0a184584e..93b472653 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#e44674b8f823e470bf8edccc236d984e49d8d933", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#f93f2f85649f4609cb5aeac476f6c5419447c674", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index bbeb185f7..6ce914295 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#e44674b8f823e470bf8edccc236d984e49d8d933": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#f93f2f85649f4609cb5aeac476f6c5419447c674": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/e44674b8f823e470bf8edccc236d984e49d8d933" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/f93f2f85649f4609cb5aeac476f6c5419447c674" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 2f6b1ea37c699b26070154315b8bff08580df26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 17:45:42 +0200 Subject: [PATCH 21/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 93b472653..00213c1c0 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#f93f2f85649f4609cb5aeac476f6c5419447c674", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#94ab1ddc106ca92e0493af19980ddb78db75386e", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index 6ce914295..49d124bd5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#f93f2f85649f4609cb5aeac476f6c5419447c674": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#94ab1ddc106ca92e0493af19980ddb78db75386e": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/f93f2f85649f4609cb5aeac476f6c5419447c674" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/94ab1ddc106ca92e0493af19980ddb78db75386e" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From ff9982683e28097eded4edcbba169fc8857e79e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 18:07:43 +0200 Subject: [PATCH 22/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 00213c1c0..1b32727fb 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#94ab1ddc106ca92e0493af19980ddb78db75386e", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#f65ed72d6eaf71711a61db7f05e04899fb137e2d", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index 49d124bd5..d703207c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#94ab1ddc106ca92e0493af19980ddb78db75386e": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#f65ed72d6eaf71711a61db7f05e04899fb137e2d": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/94ab1ddc106ca92e0493af19980ddb78db75386e" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/f65ed72d6eaf71711a61db7f05e04899fb137e2d" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From a0f1184c405acc5062c0d9fcaad7ff3fba8b1df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 7 Sep 2023 18:29:30 +0200 Subject: [PATCH 23/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1b32727fb..180df8d5a 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#f65ed72d6eaf71711a61db7f05e04899fb137e2d", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#838cf3aa4bb221d7b83b9d8726aabf808f73d5b0", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index d703207c4..920992a7a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#f65ed72d6eaf71711a61db7f05e04899fb137e2d": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#838cf3aa4bb221d7b83b9d8726aabf808f73d5b0": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/f65ed72d6eaf71711a61db7f05e04899fb137e2d" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/838cf3aa4bb221d7b83b9d8726aabf808f73d5b0" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 645b123bea5e00df3347b62e912f8c5368942f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 10 Sep 2023 12:10:13 +0200 Subject: [PATCH 24/26] Handle indices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/e2ee/matrixKeyProvider.ts | 23 ++++++++++++++--------- src/room/InCallView.tsx | 6 ++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index 0b810e01e..abf1236e4 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -38,27 +38,32 @@ export class MatrixKeyProvider extends BaseKeyProvider { this.onEncryptionKeyChanged ); + // The new session could be aware of keys of which the old session wasn't, + // so emit a key changed event. for (const [ participant, - encryptionKey, + encryptionKeys, ] of this.rtcSession.getEncryptionKeys()) { - // The new session could be aware of keys of which the old session wasn't, - // so emit a key changed event. - this.onEncryptionKeyChanged(encryptionKey, participant); + for (const [index, encryptionKey] of encryptionKeys.entries()) { + this.onEncryptionKeyChanged(encryptionKey, index, participant); + } } } private onEncryptionKeyChanged = async ( encryptionKey: string, + encryptionKeyIndex: number, participantId: string ) => { - console.log( - `Embedded-E2EE-LOG onEncryptionKeyChanged participantId=${participantId} encryptionKey=${encryptionKey}` - ); - this.onSetEncryptionKey( await createKeyMaterialFromString(encryptionKey), - participantId + participantId, + encryptionKeyIndex + ); + + console.log( + `Embedded-E2EE-LOG onEncryptionKeyChanged participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex} encryptionKey=${encryptionKey}`, + this.getKeys() ); }; } diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index c1fb0911f..3b2100e30 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -176,12 +176,10 @@ export function InCallView({ const toggleMicrophone = useCallback(() => { muteStates.audio.setEnabled?.((e) => !e); - rtcSession.updateEncryptionKeyEvent(); - }, [muteStates, rtcSession]); + }, [muteStates]); const toggleCamera = useCallback(() => { muteStates.video.setEnabled?.((e) => !e); - rtcSession.updateEncryptionKeyEvent(); - }, [muteStates, rtcSession]); + }, [muteStates]); const joinRule = useJoinRule(rtcSession.room); From fce220c55fa37c2e644957711165831d83fe2e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 10 Sep 2023 12:11:03 +0200 Subject: [PATCH 25/26] Update js-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 180df8d5a..a8dc61b62 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "i18next-http-backend": "^1.4.4", "livekit-client": "^1.12.3", "lodash": "^4.17.21", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#838cf3aa4bb221d7b83b9d8726aabf808f73d5b0", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#72093c8cb020a52ba67c97137e687ae65ed5c9b6", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/yarn.lock b/yarn.lock index 920992a7a..6b8ea355b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11586,9 +11586,9 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#838cf3aa4bb221d7b83b9d8726aabf808f73d5b0": +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#72093c8cb020a52ba67c97137e687ae65ed5c9b6": version "28.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/838cf3aa4bb221d7b83b9d8726aabf808f73d5b0" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/72093c8cb020a52ba67c97137e687ae65ed5c9b6" dependencies: "@babel/runtime" "^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm" "^1.2.1" From 28035b50289af2403e6d15f889be45b47a579838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 12 Sep 2023 18:34:36 +0200 Subject: [PATCH 26/26] Post-merge fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/room/ShareModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/room/ShareModal.tsx b/src/room/ShareModal.tsx index b1f28c707..3ecc346b3 100644 --- a/src/room/ShareModal.tsx +++ b/src/room/ShareModal.tsx @@ -20,7 +20,7 @@ import { useTranslation } from "react-i18next"; import { Modal, ModalContent, ModalProps } from "../Modal"; import { CopyButton } from "../button"; import { getRoomUrl } from "../matrix-utils"; -import styles from "./InviteModal.module.css"; +import styles from "./ShareModal.module.css"; import { useRoomSharedKey } from "../e2ee/e2eeHooks"; interface Props extends Omit {