wip get passphrase from the backend

This commit is contained in:
lebaudantoine
2025-01-04 13:20:55 +01:00
parent 83d4028e84
commit 1cf26eec19
3 changed files with 9 additions and 6 deletions
+2
View File
@@ -143,6 +143,8 @@ class RoomSerializer(serializers.ModelSerializer):
output["is_administrable"] = is_admin
output['passphrase'] = "thisisapassphrase"
return output
@@ -4,6 +4,7 @@ export type ApiRoom = {
slug: string
is_public: boolean
is_administrable: boolean
passphrase: string
livekit?: {
url: string
room: string
@@ -68,14 +68,11 @@ export const Conference = ({
retry: false,
})
const e2eePassphrase = typeof window !== 'undefined' && 'thisisapassphrase'
const worker =
typeof window !== 'undefined' &&
e2eePassphrase &&
new Worker(new URL('livekit-client/e2ee-worker', import.meta.url))
const e2eeEnabled = !!(e2eePassphrase && worker)
const e2eeEnabled = !!worker
const keyProvider = new ExternalE2EEKeyProvider()
const [e2eeSetupComplete, setE2eeSetupComplete] = useState(false)
@@ -108,9 +105,12 @@ export const Conference = ({
const room = useMemo(() => new Room(roomOptions), [roomOptions])
useEffect(() => {
if (!data) {
return
}
if (e2eeEnabled) {
keyProvider
.setKey('thisisapassphrase')
.setKey(data.passphrase)
.then(() => {
room.setE2EEEnabled(true).catch((e) => {
if (e instanceof DeviceUnsupportedError) {
@@ -127,7 +127,7 @@ export const Conference = ({
} else {
setE2eeSetupComplete(true)
}
}, [e2eeEnabled, room, e2eePassphrase])
}, [e2eeEnabled, room, data])
const [showInviteDialog, setShowInviteDialog] = useState(mode === 'create')