aboutsummaryrefslogtreecommitdiff
path: root/client-web/source/index.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-04-04 11:15:03 +0200
committermetamuffin <metamuffin@disroot.org>2023-04-04 11:15:03 +0200
commit99d1ab55dfb1714d8f574060e618dc93c94f245c (patch)
treeb01f6ccb6b4060f120a71145fbbded0131c9430e /client-web/source/index.ts
parent84587df365c61297e08d00f28317b452681a4b84 (diff)
parentfe36a0640f2e36baad1f08033f09b49bdd0f1062 (diff)
downloadkeks-meet-99d1ab55dfb1714d8f574060e618dc93c94f245c.tar
keks-meet-99d1ab55dfb1714d8f574060e618dc93c94f245c.tar.bz2
keks-meet-99d1ab55dfb1714d8f574060e618dc93c94f245c.tar.zst
Merge branch 'master' of codeberg.org:metamuffin/keks-meet
Diffstat (limited to 'client-web/source/index.ts')
-rw-r--r--client-web/source/index.ts59
1 files changed, 38 insertions, 21 deletions
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 852e48f..3610ead 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -17,18 +17,20 @@ import { Room } from "./room.ts"
export const VERSION = "0.1.12"
export const ROOM_CONTAINER = esection({ class: "room", aria_label: "user list" })
-export const RTC_CONFIG: RTCConfiguration = {
- iceServers: [
- {
- urls: [
- "turn:meet.metamuffin.org:16900",
- "stun:meet.metamuffin.org:16900"
- ],
- username: "keksmeet",
- credential: "ujCmetg6bm0"
- },
- ],
- iceCandidatePoolSize: 10,
+export interface ClientConfig {
+ appearance?: {
+ accent: string
+ accent_dark: string
+ accent_light: string
+ background: string
+ background_dark: string
+ }
+ webrtc: {
+ stun: string,
+ turn?: string,
+ turn_user?: string,
+ turn_cred?: string
+ }
}
export interface User {
@@ -50,27 +52,42 @@ window.onbeforeunload = ev => {
let r: Room;
export async function main() {
- log("*", "starting up")
- document.body.innerHTML = "" // remove existing elements
- const room_name = load_params().rname
+ document.body.append(LOGGER_CONTAINER)
+ log("*", "loading client config")
+ const config_res = await fetch("/config.json")
+ if (!config_res.ok) return log({ scope: "*", error: true }, "cannot load config")
+ const config: ClientConfig = await config_res.json()
+ log("*", "config loaded. starting")
+
+ document.body.querySelectorAll("p").forEach(e => e.remove())
+ const room_secret = load_params().rsecret
if (!globalThis.RTCPeerConnection) return log({ scope: "webrtc", error: true }, "WebRTC not supported.")
if (!globalThis.isSecureContext) log({ scope: "*", warn: true }, "This page is not in a 'Secure Context'")
if (!globalThis.crypto.subtle) return log({ scope: "crypto", error: true }, "SubtleCrypto not availible")
if (!globalThis.navigator.serviceWorker) log({ scope: "*", warn: true }, "Your browser does not support the Service Worker API, some features dont work without it.")
- if (room_name.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
- if (room_name.length == 0) return window.location.href = "/" // send them back to the start page
- if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room name now - e2ee is insecure!")
+ if (room_secret.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
+ if (room_secret.length == 0) return window.location.href = "/" // send them back to the start page
+ if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room secret now - e2ee is insecure!")
+
+ const conn = await (new SignalingConnection().connect(room_secret))
+ const rtc_config: RTCConfiguration = {
+ iceCandidatePoolSize: 10,
+ iceServers: [{
+ urls: [config.webrtc.stun, ...(config.webrtc.turn ? [config.webrtc.turn] : [])],
+ credential: config.webrtc.turn_cred,
+ username: config.webrtc.turn_user,
+ }]
+ }
- const conn = await (new SignalingConnection().connect(room_name))
- r = new Room(conn)
+ r = new Room(conn, rtc_config)
setup_keybinds(r)
r.on_ready = () => {
new BottomMenu(r)
new MenuBr()
}
- document.body.append(ROOM_CONTAINER, OVERLAYS, LOGGER_CONTAINER)
+ document.body.prepend(ROOM_CONTAINER, OVERLAYS)
if (globalThis.navigator.serviceWorker) init_serviceworker()
}