Amalgamate E2EEMode & E2eeType
This commit is contained in:
@@ -41,14 +41,10 @@ import {
|
|||||||
useECConnectionState,
|
useECConnectionState,
|
||||||
} from "./useECConnectionState";
|
} from "./useECConnectionState";
|
||||||
import { MatrixKeyProvider } from "../e2ee/matrixKeyProvider";
|
import { MatrixKeyProvider } from "../e2ee/matrixKeyProvider";
|
||||||
|
import { E2eeType } from "../e2ee/e2eeType";
|
||||||
export enum E2EEMode {
|
|
||||||
PerParticipantKey = "per_participant_key",
|
|
||||||
SharedKey = "shared_key",
|
|
||||||
}
|
|
||||||
|
|
||||||
export type E2EEConfig = {
|
export type E2EEConfig = {
|
||||||
mode: E2EEMode;
|
mode: E2eeType;
|
||||||
sharedKey?: string;
|
sharedKey?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,14 +60,17 @@ export function useLiveKit(
|
|||||||
e2eeConfig?: E2EEConfig,
|
e2eeConfig?: E2EEConfig,
|
||||||
): UseLivekitResult {
|
): UseLivekitResult {
|
||||||
const e2eeOptions = useMemo((): E2EEOptions | undefined => {
|
const e2eeOptions = useMemo((): E2EEOptions | undefined => {
|
||||||
if (!e2eeConfig) return undefined;
|
if (!e2eeConfig || e2eeConfig.mode === E2eeType.NONE) return undefined;
|
||||||
|
|
||||||
if (e2eeConfig.mode === E2EEMode.PerParticipantKey) {
|
if (e2eeConfig.mode === E2eeType.PER_PARTICIPANT) {
|
||||||
return {
|
return {
|
||||||
keyProvider: new MatrixKeyProvider(),
|
keyProvider: new MatrixKeyProvider(),
|
||||||
worker: new E2EEWorker(),
|
worker: new E2EEWorker(),
|
||||||
};
|
};
|
||||||
} else if (e2eeConfig.mode === E2EEMode.SharedKey && e2eeConfig.sharedKey) {
|
} else if (
|
||||||
|
e2eeConfig.mode === E2eeType.SHARED_KEY &&
|
||||||
|
e2eeConfig.sharedKey
|
||||||
|
) {
|
||||||
return {
|
return {
|
||||||
keyProvider: new ExternalE2EEKeyProvider(),
|
keyProvider: new ExternalE2EEKeyProvider(),
|
||||||
worker: new E2EEWorker(),
|
worker: new E2EEWorker(),
|
||||||
@@ -82,9 +81,12 @@ export function useLiveKit(
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!e2eeConfig || !e2eeOptions) return;
|
if (!e2eeConfig || !e2eeOptions) return;
|
||||||
|
|
||||||
if (e2eeConfig.mode === E2EEMode.PerParticipantKey) {
|
if (e2eeConfig.mode === E2eeType.PER_PARTICIPANT) {
|
||||||
(e2eeOptions.keyProvider as MatrixKeyProvider).setRTCSession(rtcSession);
|
(e2eeOptions.keyProvider as MatrixKeyProvider).setRTCSession(rtcSession);
|
||||||
} else if (e2eeConfig.mode === E2EEMode.SharedKey && e2eeConfig.sharedKey) {
|
} else if (
|
||||||
|
e2eeConfig.mode === E2eeType.SHARED_KEY &&
|
||||||
|
e2eeConfig.sharedKey
|
||||||
|
) {
|
||||||
(e2eeOptions.keyProvider as ExternalE2EEKeyProvider).setKey(
|
(e2eeOptions.keyProvider as ExternalE2EEKeyProvider).setKey(
|
||||||
e2eeConfig.sharedKey,
|
e2eeConfig.sharedKey,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ import { useRoomAvatar } from "./useRoomAvatar";
|
|||||||
import { useRoomName } from "./useRoomName";
|
import { useRoomName } from "./useRoomName";
|
||||||
import { useJoinRule } from "./useJoinRule";
|
import { useJoinRule } from "./useJoinRule";
|
||||||
import { InviteModal } from "./InviteModal";
|
import { InviteModal } from "./InviteModal";
|
||||||
import { E2EEConfig, E2EEMode } from "../livekit/useLiveKit";
|
import { E2EEConfig } from "../livekit/useLiveKit";
|
||||||
import { useUrlParams } from "../UrlParams";
|
import { useUrlParams } from "../UrlParams";
|
||||||
|
import { E2eeType } from "../e2ee/e2eeType";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@@ -262,9 +263,9 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
|
|
||||||
const e2eeConfig = useMemo((): E2EEConfig | undefined => {
|
const e2eeConfig = useMemo((): E2EEConfig | undefined => {
|
||||||
if (perParticipantE2EE) {
|
if (perParticipantE2EE) {
|
||||||
return { mode: E2EEMode.PerParticipantKey };
|
return { mode: E2eeType.PER_PARTICIPANT };
|
||||||
} else if (e2eeSharedKey) {
|
} else if (e2eeSharedKey) {
|
||||||
return { mode: E2EEMode.SharedKey, sharedKey: e2eeSharedKey };
|
return { mode: E2eeType.SHARED_KEY, sharedKey: e2eeSharedKey };
|
||||||
}
|
}
|
||||||
}, [perParticipantE2EE, e2eeSharedKey]);
|
}, [perParticipantE2EE, e2eeSharedKey]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user