From 5ef208e78910bd613452da23f6fd35b1e3e89384 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 13 Oct 2023 10:30:06 +0100 Subject: [PATCH] Remove E2EE setting Since e2ee is enabled by default now --- public/locales/en-GB/app.json | 2 -- src/e2ee/sharedKeyManagement.ts | 4 +--- src/home/RegisteredView.tsx | 11 +++-------- src/home/UnauthenticatedView.tsx | 11 ++--------- src/room/GroupCallView.tsx | 7 +------ src/room/useLoadGroupCall.ts | 5 +---- src/settings/SettingsModal.tsx | 19 ------------------- src/settings/useSetting.ts | 11 ----------- 8 files changed, 8 insertions(+), 62 deletions(-) diff --git a/public/locales/en-GB/app.json b/public/locales/en-GB/app.json index 625761f4..b09179e1 100644 --- a/public/locales/en-GB/app.json +++ b/public/locales/en-GB/app.json @@ -36,10 +36,8 @@ "Developer Settings": "Developer Settings", "Display name": "Display name", "Element Call Home": "Element Call Home", - "Enable end-to-end encryption (password protected calls)": "Enable end-to-end encryption (password protected calls)", "Encrypted": "Encrypted", "End call": "End call", - "End-to-end encryption isn't supported on your browser.": "End-to-end encryption isn't supported on your browser.", "Exit full screen": "Exit full screen", "Expose developer settings in the settings window.": "Expose developer settings in the settings window.", "Feedback": "Feedback", diff --git a/src/e2ee/sharedKeyManagement.ts b/src/e2ee/sharedKeyManagement.ts index 21c54481..8190aed8 100644 --- a/src/e2ee/sharedKeyManagement.ts +++ b/src/e2ee/sharedKeyManagement.ts @@ -16,7 +16,6 @@ limitations under the License. import { useEffect, useMemo } from "react"; -import { useEnableE2EE } from "../settings/useSetting"; import { useLocalStorage } from "../useLocalStorage"; import { useClient } from "../ClientContext"; import { useUrlParams } from "../UrlParams"; @@ -29,10 +28,9 @@ const useInternalRoomSharedKey = ( roomId: string, ): [string | null, (value: string) => void] => { const key = useMemo(() => getRoomSharedKeyLocalStorageKey(roomId), [roomId]); - const [e2eeEnabled] = useEnableE2EE(); const [roomSharedKey, setRoomSharedKey] = useLocalStorage(key); - return [e2eeEnabled ? roomSharedKey : null, setRoomSharedKey]; + return [roomSharedKey, setRoomSharedKey]; }; const useKeyFromUrl = (roomId: string): string | null => { diff --git a/src/home/RegisteredView.tsx b/src/home/RegisteredView.tsx index 691ba18b..c5ff8cfa 100644 --- a/src/home/RegisteredView.tsx +++ b/src/home/RegisteredView.tsx @@ -38,7 +38,7 @@ import { UserMenuContainer } from "../UserMenuContainer"; import { JoinExistingCallModal } from "./JoinExistingCallModal"; import { Caption } from "../typography/Typography"; import { Form } from "../form/Form"; -import { useEnableE2EE, useOptInAnalytics } from "../settings/useSetting"; +import { useOptInAnalytics } from "../settings/useSetting"; import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; interface Props { @@ -57,7 +57,6 @@ export const RegisteredView: FC = ({ client }) => { () => setJoinExistingCallModalOpen(false), [setJoinExistingCallModalOpen], ); - const [e2eeEnabled] = useEnableE2EE(); const onSubmit: FormEventHandler = useCallback( (e: FormEvent) => { @@ -73,11 +72,7 @@ export const RegisteredView: FC = ({ client }) => { setError(undefined); setLoading(true); - const createRoomResult = await createRoom( - client, - roomName, - e2eeEnabled ?? false, - ); + const createRoomResult = await createRoom(client, roomName, true); history.push( getRelativeRoomUrl( @@ -101,7 +96,7 @@ export const RegisteredView: FC = ({ client }) => { } }); }, - [client, history, setJoinExistingCallModalOpen, e2eeEnabled], + [client, history, setJoinExistingCallModalOpen], ); const recentRooms = useGroupCallRooms(client); diff --git a/src/home/UnauthenticatedView.tsx b/src/home/UnauthenticatedView.tsx index 18fc47cf..91e8b56e 100644 --- a/src/home/UnauthenticatedView.tsx +++ b/src/home/UnauthenticatedView.tsx @@ -41,7 +41,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 { useOptInAnalytics } from "../settings/useSetting"; import { Config } from "../config/Config"; export const UnauthenticatedView: FC = () => { @@ -62,8 +62,6 @@ export const UnauthenticatedView: FC = () => { const history = useHistory(); const { t } = useTranslation(); - const [e2eeEnabled] = useEnableE2EE(); - const onSubmit: FormEventHandler = useCallback( (e) => { e.preventDefault(); @@ -86,11 +84,7 @@ export const UnauthenticatedView: FC = () => { let createRoomResult; try { - createRoomResult = await createRoom( - client, - roomName, - e2eeEnabled ?? false, - ); + createRoomResult = await createRoom(client, roomName, true); } catch (error) { if (!setClient) { throw error; @@ -142,7 +136,6 @@ export const UnauthenticatedView: FC = () => { history, setJoinExistingCallModalOpen, setClient, - e2eeEnabled, ], ); diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index c629a5dc..4b2f4cfa 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -40,7 +40,6 @@ import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMembership import { enterRTCSession, leaveRTCSession } from "../rtcSessionHelpers"; import { useMatrixRTCSessionJoinState } from "../useMatrixRTCSessionJoinState"; import { useIsRoomE2EE, useRoomSharedKey } from "../e2ee/sharedKeyManagement"; -import { useEnableE2EE } from "../settings/useSetting"; import { useRoomAvatar } from "./useRoomAvatar"; import { useRoomName } from "./useRoomName"; import { useJoinRule } from "./useJoinRule"; @@ -256,8 +255,6 @@ export const GroupCallView: FC = ({ } }, [isJoined, rtcSession]); - const [e2eeEnabled] = useEnableE2EE(); - const e2eeConfig = useMemo( () => (e2eeSharedKey ? { sharedKey: e2eeSharedKey } : undefined), [e2eeSharedKey], @@ -293,7 +290,7 @@ export const GroupCallView: FC = ({ const { t } = useTranslation(); - if (e2eeEnabled && isRoomE2EE && !e2eeSharedKey) { + if (isRoomE2EE && !e2eeSharedKey) { return ( = ({ ); - } else if (!e2eeEnabled && isRoomE2EE) { - return ; } const shareModal = ( diff --git a/src/room/useLoadGroupCall.ts b/src/room/useLoadGroupCall.ts index 423706ec..9b300d36 100644 --- a/src/room/useLoadGroupCall.ts +++ b/src/room/useLoadGroupCall.ts @@ -23,7 +23,6 @@ import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession"; import type { Room } from "matrix-js-sdk/src/models/room"; import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall"; -import { useEnableE2EE } from "../settings/useSetting"; export type GroupCallLoaded = { kind: "loaded"; @@ -57,8 +56,6 @@ export const useLoadGroupCall = ( const { t } = useTranslation(); const [state, setState] = useState({ kind: "loading" }); - const [e2eeEnabled] = useEnableE2EE(); - useEffect(() => { const fetchOrCreateRoom = async (): Promise => { let room: Room | null = null; @@ -129,7 +126,7 @@ export const useLoadGroupCall = ( .then(fetchOrCreateGroupCall) .then((rtcSession) => setState({ kind: "loaded", rtcSession })) .catch((error) => setState({ kind: "failed", error })); - }, [client, roomIdOrAlias, viaServers, t, e2eeEnabled]); + }, [client, roomIdOrAlias, viaServers, t]); return state; }; diff --git a/src/settings/SettingsModal.tsx b/src/settings/SettingsModal.tsx index fe183d59..9c90bc10 100644 --- a/src/settings/SettingsModal.tsx +++ b/src/settings/SettingsModal.tsx @@ -33,7 +33,6 @@ import { useOptInAnalytics, useDeveloperSettingsTab, useShowConnectionStats, - useEnableE2EE, isFirefox, } from "./useSetting"; import { FieldRow, InputField } from "../input/Input"; @@ -64,7 +63,6 @@ export const SettingsModal: FC = (props) => { useDeveloperSettingsTab(); const [showConnectionStats, setShowConnectionStats] = useShowConnectionStats(); - const [enableE2EE, setEnableE2EE] = useEnableE2EE(); // Generate a `SelectInput` with a list of devices for a given device kind. const generateDeviceSelection = ( @@ -243,23 +241,6 @@ export const SettingsModal: FC = (props) => { } /> - - ): void => - setEnableE2EE?.(e.target.checked) - } - /> - ); diff --git a/src/settings/useSetting.ts b/src/settings/useSetting.ts index 399ed356..a2733b98 100644 --- a/src/settings/useSetting.ts +++ b/src/settings/useSetting.ts @@ -15,7 +15,6 @@ limitations under the License. */ import { useCallback, useMemo } from "react"; -import { isE2EESupported } from "livekit-client"; import { PosthogAnalytics } from "../analytics/PosthogAnalytics"; import { @@ -91,16 +90,6 @@ export const useOptInAnalytics = (): DisableableSetting => { return [false, null]; }; -export const useEnableE2EE = (): DisableableSetting => { - const settingVal = useSetting( - "enable-end-to-end-encryption", - true, - ); - if (isE2EESupported()) return settingVal; - - return [false, null]; -}; - export const useDeveloperSettingsTab = (): Setting => useSetting("developer-settings-tab", false);