mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-15 00:04:59 +08:00
Get E2EE password from the URL
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
264e34f1b0
commit
1a5898eb30
@ -19,6 +19,8 @@ import { useLocation } from "react-router-dom";
|
||||
|
||||
import { Config } from "./config/Config";
|
||||
|
||||
const PASSWORD_STRING = "?password=";
|
||||
|
||||
interface UrlParams {
|
||||
roomAlias: string | null;
|
||||
roomId: string | null;
|
||||
@ -86,6 +88,10 @@ interface UrlParams {
|
||||
* user's homeserver doesn't provide any.
|
||||
*/
|
||||
allowIceFallback: boolean;
|
||||
/**
|
||||
* E2EE password
|
||||
*/
|
||||
password: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,8 +109,17 @@ export const getUrlParams = (
|
||||
hash = window.location.hash
|
||||
): UrlParams => {
|
||||
let roomAlias: string | null = null;
|
||||
let password: string | null = null;
|
||||
|
||||
const passwordIndex = hash.indexOf(PASSWORD_STRING);
|
||||
const passwordStart =
|
||||
passwordIndex === -1 ? null : passwordIndex + PASSWORD_STRING.length;
|
||||
if (passwordStart) {
|
||||
password = hash.substring(passwordStart);
|
||||
}
|
||||
|
||||
if (!ignoreRoomAlias) {
|
||||
if (hash === "") {
|
||||
if (hash === "" || hash.startsWith("#" + PASSWORD_STRING)) {
|
||||
roomAlias = pathname.substring(1); // Strip the "/"
|
||||
|
||||
// Delete "/room/", if present
|
||||
@ -164,6 +179,7 @@ export const getUrlParams = (
|
||||
return {
|
||||
roomAlias,
|
||||
roomId,
|
||||
password,
|
||||
viaServers: getAllParams("via"),
|
||||
isEmbedded: hasParam("embed"),
|
||||
preload: hasParam("preload"),
|
||||
|
@ -36,6 +36,7 @@ import { E2EEConfig } from "../livekit/useLiveKit";
|
||||
import { InputField } from "../input/Input";
|
||||
import { useEnableE2EE } from "../settings/useSetting";
|
||||
import { MuteStates } from "./MuteStates";
|
||||
import { useUrlParams } from "../UrlParams";
|
||||
|
||||
interface Props {
|
||||
matrixInfo: MatrixInfo;
|
||||
@ -52,6 +53,8 @@ export const LobbyView: FC<Props> = ({
|
||||
isEmbedded,
|
||||
hideHeader,
|
||||
}) => {
|
||||
const { password } = useUrlParams();
|
||||
|
||||
const { t } = useTranslation();
|
||||
useLocationNavigation();
|
||||
|
||||
@ -65,7 +68,7 @@ export const LobbyView: FC<Props> = ({
|
||||
}, [joinCallButtonRef]);
|
||||
|
||||
const [e2eeSharedKey, setE2EESharedKey] = useState<string | undefined>(
|
||||
undefined
|
||||
password ?? undefined
|
||||
);
|
||||
|
||||
const onE2EESharedKeyChanged = useCallback(
|
||||
|
Loading…
Reference in New Issue
Block a user