Do not allow joining a call without E2EE key
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
@@ -14,13 +14,12 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useEffect, useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { randomString } from "matrix-js-sdk/src/randomstring";
|
|
||||||
|
|
||||||
import { useEnableE2EE } from "../settings/useSetting";
|
import { useEnableE2EE } from "../settings/useSetting";
|
||||||
import { useLocalStorage } from "../useLocalStorage";
|
import { useLocalStorage } from "../useLocalStorage";
|
||||||
|
|
||||||
const getRoomSharedKeyLocalStorageKey = (roomId: string): string =>
|
export const getRoomSharedKeyLocalStorageKey = (roomId: string): string =>
|
||||||
`room-shared-key-${roomId}`;
|
`room-shared-key-${roomId}`;
|
||||||
|
|
||||||
export const useRoomSharedKey = (
|
export const useRoomSharedKey = (
|
||||||
@@ -30,11 +29,5 @@ export const useRoomSharedKey = (
|
|||||||
const [e2eeEnabled] = useEnableE2EE();
|
const [e2eeEnabled] = useEnableE2EE();
|
||||||
const [roomSharedKey, setRoomSharedKey] = useLocalStorage(key);
|
const [roomSharedKey, setRoomSharedKey] = useLocalStorage(key);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if ((roomSharedKey && roomSharedKey !== "") || !e2eeEnabled) return;
|
|
||||||
|
|
||||||
setRoomSharedKey(randomString(32));
|
|
||||||
}, [roomSharedKey, e2eeEnabled, setRoomSharedKey]);
|
|
||||||
|
|
||||||
return e2eeEnabled ? [roomSharedKey, setRoomSharedKey] : [null, null];
|
return e2eeEnabled ? [roomSharedKey, setRoomSharedKey] : [null, null];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
import { useState, useCallback, FormEvent, FormEventHandler } from "react";
|
import { useState, useCallback, FormEvent, FormEventHandler } from "react";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
|
import { randomString } from "matrix-js-sdk/src/randomstring";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -40,6 +41,8 @@ import { CallType, CallTypeDropdown } from "./CallTypeDropdown";
|
|||||||
import { useOptInAnalytics } from "../settings/useSetting";
|
import { useOptInAnalytics } from "../settings/useSetting";
|
||||||
import { AnalyticsNotice } from "../analytics/AnalyticsNotice";
|
import { AnalyticsNotice } from "../analytics/AnalyticsNotice";
|
||||||
import { E2EEBanner } from "../E2EEBanner";
|
import { E2EEBanner } from "../E2EEBanner";
|
||||||
|
import { setLocalStorageItem } from "../useLocalStorage";
|
||||||
|
import { getRoomSharedKeyLocalStorageKey } from "../e2ee/sharedKeyManagement";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
client: MatrixClient;
|
client: MatrixClient;
|
||||||
@@ -70,11 +73,14 @@ export function RegisteredView({ client, isPasswordlessUser }: Props) {
|
|||||||
setError(undefined);
|
setError(undefined);
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const [roomAlias] = await createRoom(client, roomName, ptt);
|
const [roomAlias, roomId] = await createRoom(client, roomName, ptt);
|
||||||
|
|
||||||
if (roomAlias) {
|
setLocalStorageItem(
|
||||||
history.push(`/${roomAlias.substring(1).split(":")[0]}`);
|
getRoomSharedKeyLocalStorageKey(roomId),
|
||||||
}
|
randomString(32)
|
||||||
|
);
|
||||||
|
|
||||||
|
history.push(`/${roomAlias.substring(1).split(":")[0]}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
submit().catch((error) => {
|
submit().catch((error) => {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import { MuteStates, useMuteStates } from "./MuteStates";
|
|||||||
import { useMediaDevices, MediaDevices } from "../livekit/MediaDevicesContext";
|
import { useMediaDevices, MediaDevices } from "../livekit/MediaDevicesContext";
|
||||||
import { useRoomSharedKey } from "../e2ee/sharedKeyManagement";
|
import { useRoomSharedKey } from "../e2ee/sharedKeyManagement";
|
||||||
import { PASSWORD_STRING, useUrlParams } from "../UrlParams";
|
import { PASSWORD_STRING, useUrlParams } from "../UrlParams";
|
||||||
|
import { useEnableE2EE } from "../settings/useSetting";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@@ -244,6 +245,7 @@ export function GroupCallView({
|
|||||||
}
|
}
|
||||||
}, [groupCall, state, leave]);
|
}, [groupCall, state, leave]);
|
||||||
|
|
||||||
|
const [e2eeEnabled] = useEnableE2EE();
|
||||||
const [e2eeSharedKey, setE2EESharedKey] = useRoomSharedKey(
|
const [e2eeSharedKey, setE2EESharedKey] = useRoomSharedKey(
|
||||||
groupCall.room.roomId
|
groupCall.room.roomId
|
||||||
);
|
);
|
||||||
@@ -275,6 +277,18 @@ export function GroupCallView({
|
|||||||
groupCall.enter();
|
groupCall.enter();
|
||||||
}, [groupCall]);
|
}, [groupCall]);
|
||||||
|
|
||||||
|
if (!password && !e2eeSharedKey && e2eeEnabled) {
|
||||||
|
return (
|
||||||
|
<ErrorView
|
||||||
|
error={
|
||||||
|
new Error(
|
||||||
|
"No E2EE key provided: please make sure the URL you're using to join this call has been retrieved using the in-app button."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const livekitServiceURL =
|
const livekitServiceURL =
|
||||||
groupCall.livekitServiceURL ?? Config.get().livekit?.livekit_service_url;
|
groupCall.livekitServiceURL ?? Config.get().livekit?.livekit_service_url;
|
||||||
if (!livekitServiceURL) {
|
if (!livekitServiceURL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user