diff --git a/src/livekit/options.ts b/src/livekit/options.ts index 5115f213..e808149b 100644 --- a/src/livekit/options.ts +++ b/src/livekit/options.ts @@ -6,7 +6,9 @@ import { TrackPublishDefaults, VideoPreset, VideoPresets, + ExternalE2EEKeyProvider, } from "livekit-client"; +import E2EEWorker from "livekit-client/e2ee-worker?worker"; const defaultLiveKitPublishOptions: TrackPublishDefaults = { audioPreset: AudioPresets.music, @@ -22,7 +24,16 @@ const defaultLiveKitPublishOptions: TrackPublishDefaults = { backupCodec: { codec: "vp8", encoding: VideoPresets.h720.encoding }, } as const; +const e2eeWorker = new E2EEWorker(); +const e2eeKeyProvider = new ExternalE2EEKeyProvider(); +e2eeKeyProvider.setKey("not secret password"); + export const defaultLiveKitOptions: RoomOptions = { + e2ee: { + keyProvider: e2eeKeyProvider, + worker: e2eeWorker, + }, + // automatically manage subscribed video quality adaptiveStream: true, diff --git a/src/livekit/useLiveKit.ts b/src/livekit/useLiveKit.ts index 7a0a5330..6b862a66 100644 --- a/src/livekit/useLiveKit.ts +++ b/src/livekit/useLiveKit.ts @@ -32,12 +32,14 @@ export function useLiveKit( return options; }, [userChoices.video, userChoices.audio]); + const roomWithoutProps = useMemo(() => new Room(roomOptions), [roomOptions]); + const { room } = useLiveKitRoom({ token: sfuConfig?.jwt, serverUrl: sfuConfig?.url, audio: userChoices.audio?.enabled ?? false, video: userChoices.video?.enabled ?? false, - options: roomOptions, + room: roomWithoutProps, }); return room; diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index b8284975..0140061d 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -102,6 +102,8 @@ export function ActiveCall(props: ActiveCallProps) { return null; } + livekitRoom.setE2EEEnabled(true); + return (