mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-07 21:45:18 +00:00
developer settings for ratcheting
This commit is contained in:
@@ -5,7 +5,11 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BaseKeyProvider, createKeyMaterialFromBuffer } from "livekit-client";
|
import {
|
||||||
|
BaseKeyProvider,
|
||||||
|
createKeyMaterialFromBuffer,
|
||||||
|
KeyProviderEvent,
|
||||||
|
} from "livekit-client";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import {
|
import {
|
||||||
type MatrixRTCSession,
|
type MatrixRTCSession,
|
||||||
@@ -16,7 +20,11 @@ export class MatrixKeyProvider extends BaseKeyProvider {
|
|||||||
private rtcSession?: MatrixRTCSession;
|
private rtcSession?: MatrixRTCSession;
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super({ ratchetWindowSize: 100, keyringSize: 256 });
|
// ratchetWindowSize the amount of ratchets we try consecutively before
|
||||||
|
// throwing an error log. After those attempts we will still try more retry batches.
|
||||||
|
// So there can be more than 10 ratchets in total.
|
||||||
|
super({ ratchetWindowSize: 10, keyringSize: 256 });
|
||||||
|
this.on(KeyProviderEvent.KeyRatcheted, this.onKeyRatcheted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setRTCSession(rtcSession: MatrixRTCSession): void {
|
public setRTCSession(rtcSession: MatrixRTCSession): void {
|
||||||
@@ -60,4 +68,12 @@ export class MatrixKeyProvider extends BaseKeyProvider {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public onKeyRatcheted = (material: CryptoKey, keyIndex?: number): void => {
|
||||||
|
logger.debug(
|
||||||
|
`Key ratcheted event received for livekit room=${this.rtcSession?.room.roomId} keyIndex=${keyIndex}`,
|
||||||
|
`material:`,
|
||||||
|
material,
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
type RoomOptions,
|
type RoomOptions,
|
||||||
Track,
|
Track,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import { useEffect, useMemo, useRef } from "react";
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
||||||
import E2EEWorker from "livekit-client/e2ee-worker?worker";
|
import E2EEWorker from "livekit-client/e2ee-worker?worker";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
@@ -37,6 +37,7 @@ import { type EncryptionSystem } from "../e2ee/sharedKeyManagement";
|
|||||||
interface UseLivekitResult {
|
interface UseLivekitResult {
|
||||||
livekitRoom?: Room;
|
livekitRoom?: Room;
|
||||||
connState: ECConnectionState;
|
connState: ECConnectionState;
|
||||||
|
doKeyRatchet: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLiveKit(
|
export function useLiveKit(
|
||||||
@@ -331,8 +332,16 @@ export function useLiveKit(
|
|||||||
}
|
}
|
||||||
}, [room, devices, connectionState]);
|
}, [room, devices, connectionState]);
|
||||||
|
|
||||||
|
const doKeyRatchet = useCallback(() => {
|
||||||
|
// not providing a key index will default to the current key
|
||||||
|
e2eeOptions?.keyProvider.ratchetKey(
|
||||||
|
room.localParticipant.identity,
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
}, [e2eeOptions?.keyProvider, room.localParticipant.identity]);
|
||||||
return {
|
return {
|
||||||
connState: connectionState,
|
connState: connectionState,
|
||||||
livekitRoom: room,
|
livekitRoom: room,
|
||||||
|
doKeyRatchet,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export interface ActiveCallProps
|
|||||||
|
|
||||||
export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||||
const sfuConfig = useOpenIDSFU(props.client, props.rtcSession);
|
const sfuConfig = useOpenIDSFU(props.client, props.rtcSession);
|
||||||
const { livekitRoom, connState } = useLiveKit(
|
const { livekitRoom, connState, doKeyRatchet } = useLiveKit(
|
||||||
props.rtcSession,
|
props.rtcSession,
|
||||||
props.muteStates,
|
props.muteStates,
|
||||||
sfuConfig,
|
sfuConfig,
|
||||||
@@ -164,6 +164,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
|||||||
vm={vm}
|
vm={vm}
|
||||||
livekitRoom={livekitRoom}
|
livekitRoom={livekitRoom}
|
||||||
connState={connState}
|
connState={connState}
|
||||||
|
doKeyRatchet={doKeyRatchet}
|
||||||
/>
|
/>
|
||||||
</ReactionsSenderProvider>
|
</ReactionsSenderProvider>
|
||||||
</RoomContext.Provider>
|
</RoomContext.Provider>
|
||||||
@@ -184,6 +185,7 @@ export interface InCallViewProps {
|
|||||||
otelGroupCallMembership?: OTelGroupCallMembership;
|
otelGroupCallMembership?: OTelGroupCallMembership;
|
||||||
connState: ECConnectionState;
|
connState: ECConnectionState;
|
||||||
onShareClick: (() => void) | null;
|
onShareClick: (() => void) | null;
|
||||||
|
doKeyRatchet?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const InCallView: FC<InCallViewProps> = ({
|
export const InCallView: FC<InCallViewProps> = ({
|
||||||
@@ -198,6 +200,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
hideHeader,
|
hideHeader,
|
||||||
connState,
|
connState,
|
||||||
onShareClick,
|
onShareClick,
|
||||||
|
doKeyRatchet,
|
||||||
}) => {
|
}) => {
|
||||||
const { supportsReactions, sendReaction, toggleRaisedHand } =
|
const { supportsReactions, sendReaction, toggleRaisedHand } =
|
||||||
useReactionsSender();
|
useReactionsSender();
|
||||||
@@ -710,6 +713,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
tab={settingsTab}
|
tab={settingsTab}
|
||||||
onTabChange={setSettingsTab}
|
onTabChange={setSettingsTab}
|
||||||
livekitRoom={livekitRoom}
|
livekitRoom={livekitRoom}
|
||||||
|
doKeyRatchet={doKeyRatchet}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
|
|
||||||
import { type ChangeEvent, type FC, useCallback, useMemo } from "react";
|
import { type ChangeEvent, type FC, useCallback, useMemo } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { Button } from "@vector-im/compound-web";
|
||||||
|
|
||||||
import { FieldRow, InputField } from "../input/Input";
|
import { FieldRow, InputField } from "../input/Input";
|
||||||
import {
|
import {
|
||||||
@@ -25,9 +26,14 @@ import { useUrlParams } from "../UrlParams";
|
|||||||
interface Props {
|
interface Props {
|
||||||
client: MatrixClient;
|
client: MatrixClient;
|
||||||
livekitRoom?: LivekitRoom;
|
livekitRoom?: LivekitRoom;
|
||||||
|
doKeyRatchet?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DeveloperSettingsTab: FC<Props> = ({ client, livekitRoom }) => {
|
export const DeveloperSettingsTab: FC<Props> = ({
|
||||||
|
client,
|
||||||
|
livekitRoom,
|
||||||
|
doKeyRatchet,
|
||||||
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [duplicateTiles, setDuplicateTiles] = useSetting(duplicateTilesSetting);
|
const [duplicateTiles, setDuplicateTiles] = useSetting(duplicateTilesSetting);
|
||||||
const [debugTileLayout, setDebugTileLayout] = useSetting(
|
const [debugTileLayout, setDebugTileLayout] = useSetting(
|
||||||
@@ -88,7 +94,13 @@ export const DeveloperSettingsTab: FC<Props> = ({ client, livekitRoom }) => {
|
|||||||
{t("developer_mode.device_id", {
|
{t("developer_mode.device_id", {
|
||||||
id: client.getDeviceId() || "unknown",
|
id: client.getDeviceId() || "unknown",
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>{" "}
|
||||||
|
<FieldRow>
|
||||||
|
<Button size="sm" onClick={() => doKeyRatchet?.()}>
|
||||||
|
{" "}
|
||||||
|
Ratchet current key{" "}
|
||||||
|
</Button>{" "}
|
||||||
|
</FieldRow>
|
||||||
<FieldRow>
|
<FieldRow>
|
||||||
<InputField
|
<InputField
|
||||||
id="duplicateTiles"
|
id="duplicateTiles"
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ interface Props {
|
|||||||
client: MatrixClient;
|
client: MatrixClient;
|
||||||
roomId?: string;
|
roomId?: string;
|
||||||
livekitRoom?: LivekitRoom;
|
livekitRoom?: LivekitRoom;
|
||||||
|
doKeyRatchet?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultSettingsTab: SettingsTab = "audio";
|
export const defaultSettingsTab: SettingsTab = "audio";
|
||||||
@@ -61,6 +62,7 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
client,
|
client,
|
||||||
roomId,
|
roomId,
|
||||||
livekitRoom,
|
livekitRoom,
|
||||||
|
doKeyRatchet,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -144,7 +146,13 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
const developerTab: Tab<SettingsTab> = {
|
const developerTab: Tab<SettingsTab> = {
|
||||||
key: "developer",
|
key: "developer",
|
||||||
name: t("settings.developer_tab_title"),
|
name: t("settings.developer_tab_title"),
|
||||||
content: <DeveloperSettingsTab client={client} livekitRoom={livekitRoom} />,
|
content: (
|
||||||
|
<DeveloperSettingsTab
|
||||||
|
client={client}
|
||||||
|
livekitRoom={livekitRoom}
|
||||||
|
doKeyRatchet={doKeyRatchet}
|
||||||
|
/>
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
const tabs = [audioTab, videoTab];
|
const tabs = [audioTab, videoTab];
|
||||||
|
|||||||
Reference in New Issue
Block a user