Make e2ee type clearer hopefully

This commit is contained in:
David Baker
2023-10-23 12:10:25 +01:00
parent 9126fb3f3e
commit f04beab99f
3 changed files with 25 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ import { Caption } from "../typography/Typography";
import { Form } from "../form/Form"; import { Form } from "../form/Form";
import { useOptInAnalytics } from "../settings/useSetting"; import { useOptInAnalytics } from "../settings/useSetting";
import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; import { AnalyticsNotice } from "../analytics/AnalyticsNotice";
import { E2eeType } from "../e2ee/e2eeType";
interface Props { interface Props {
client: MatrixClient; client: MatrixClient;
@@ -72,7 +73,11 @@ export const RegisteredView: FC<Props> = ({ client }) => {
setError(undefined); setError(undefined);
setLoading(true); setLoading(true);
const createRoomResult = await createRoom(client, roomName, true); const createRoomResult = await createRoom(
client,
roomName,
E2eeType.SHARED_KEY,
);
history.push( history.push(
getRelativeRoomUrl( getRelativeRoomUrl(

View File

@@ -43,6 +43,7 @@ import { generateRandomName } from "../auth/generateRandomName";
import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; import { AnalyticsNotice } from "../analytics/AnalyticsNotice";
import { useOptInAnalytics } from "../settings/useSetting"; import { useOptInAnalytics } from "../settings/useSetting";
import { Config } from "../config/Config"; import { Config } from "../config/Config";
import { E2eeType } from "../e2ee/e2eeType";
export const UnauthenticatedView: FC = () => { export const UnauthenticatedView: FC = () => {
const { setClient } = useClient(); const { setClient } = useClient();
@@ -84,7 +85,11 @@ export const UnauthenticatedView: FC = () => {
let createRoomResult; let createRoomResult;
try { try {
createRoomResult = await createRoom(client, roomName, true); createRoomResult = await createRoom(
client,
roomName,
E2eeType.SHARED_KEY,
);
} catch (error) { } catch (error) {
if (!setClient) { if (!setClient) {
throw error; throw error;

View File

@@ -38,6 +38,7 @@ import { loadOlm } from "./olm";
import { Config } from "./config/Config"; import { Config } from "./config/Config";
import { setLocalStorageItem } from "./useLocalStorage"; import { setLocalStorageItem } from "./useLocalStorage";
import { getRoomSharedKeyLocalStorageKey } from "./e2ee/sharedKeyManagement"; import { getRoomSharedKeyLocalStorageKey } from "./e2ee/sharedKeyManagement";
import { E2eeType } from "./e2ee/e2eeType";
export const fallbackICEServerAllowed = export const fallbackICEServerAllowed =
import.meta.env.VITE_FALLBACK_STUN_ALLOWED === "true"; import.meta.env.VITE_FALLBACK_STUN_ALLOWED === "true";
@@ -278,10 +279,20 @@ interface CreateRoomResult {
password?: string; password?: string;
} }
/**
* Create a new room ready for calls
*
* @param client Matrix client to use
* @param name The name of the room
* @param e2ee The type of e2ee call to create. Note that we would currently never
* create a room for per-participant e2ee calls: since it's used in
* embedded mode, we use the existing room.
* @returns Object holding information about the new room
*/
export async function createRoom( export async function createRoom(
client: MatrixClient, client: MatrixClient,
name: string, name: string,
e2ee: boolean, e2ee: E2eeType,
): Promise<CreateRoomResult> { ): Promise<CreateRoomResult> {
logger.log(`Creating room for group call`); logger.log(`Creating room for group call`);
const createPromise = client.createRoom({ const createPromise = client.createRoom({
@@ -346,7 +357,7 @@ export async function createRoom(
); );
let password; let password;
if (e2ee) { if (e2ee == E2eeType.SHARED_KEY) {
password = secureRandomBase64(16); password = secureRandomBase64(16);
setLocalStorageItem( setLocalStorageItem(
getRoomSharedKeyLocalStorageKey(result.room_id), getRoomSharedKeyLocalStorageKey(result.room_id),