aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-11-25 20:59:54 +0100
committermetamuffin <metamuffin@disroot.org>2024-11-25 20:59:54 +0100
commit440c12ac024e84f166eaa4115ef6715c39de2eea (patch)
tree11f4a32e3478d6babee7fb30349c47d7f7983168
parent55f58e1d7017ef0038840e2a9d506cfaf85e8ea8 (diff)
downloadkeks-meet-440c12ac024e84f166eaa4115ef6715c39de2eea.tar
keks-meet-440c12ac024e84f166eaa4115ef6715c39de2eea.tar.bz2
keks-meet-440c12ac024e84f166eaa4115ef6715c39de2eea.tar.zst
replace window usage with globalThis
-rw-r--r--client-web/source/preferences/ui.ts2
-rw-r--r--client-web/source/protocol/crypto.ts14
-rw-r--r--client-web/source/protocol/mod.ts4
-rw-r--r--client-web/source/resource/track.ts6
-rw-r--r--client-web/source/sw/client.ts2
-rw-r--r--client-web/source/user/local.ts2
6 files changed, 15 insertions, 15 deletions
diff --git a/client-web/source/preferences/ui.ts b/client-web/source/preferences/ui.ts
index c710f54..0f26c14 100644
--- a/client-web/source/preferences/ui.ts
+++ b/client-web/source/preferences/ui.ts
@@ -97,7 +97,7 @@ export function ui_preferences(): HTMLElement {
)
const reset = e("div", {},
e("span", {}, PO.clear_prefs),
- e("button", { onclick: () => { if (confirm("really clear all preferences?")) { localStorage.clear(); window.location.reload() } } }, "RESET"),
+ e("button", { onclick: () => { if (confirm("really clear all preferences?")) { localStorage.clear(); globalThis.location.reload() } } }, "RESET"),
)
const table = document.createElement("table")
diff --git a/client-web/source/protocol/crypto.ts b/client-web/source/protocol/crypto.ts
index ebb552a..b75e816 100644
--- a/client-web/source/protocol/crypto.ts
+++ b/client-web/source/protocol/crypto.ts
@@ -14,14 +14,14 @@ const HASH_SALT = base64_to_buf("keksmeet/roomhashsaltA==")
export async function derive_seeded_key(seed: string): Promise<CryptoKey> {
log("crypto", "deriving crytographic key...")
- const seed_key = await window.crypto.subtle.importKey(
+ const seed_key = await globalThis.crypto.subtle.importKey(
"raw",
new TextEncoder().encode(seed),
"PBKDF2",
false,
["deriveKey"]
)
- const key = await window.crypto.subtle.deriveKey(
+ const key = await globalThis.crypto.subtle.deriveKey(
{ name: "PBKDF2", salt: CRYPTO_SALT, iterations: 250000, hash: "SHA-512" },
seed_key,
{ name: "AES-GCM", length: 256 },
@@ -34,14 +34,14 @@ export async function derive_seeded_key(seed: string): Promise<CryptoKey> {
export async function room_hash(input: string): Promise<string> {
log("crypto", "deriving room hash...")
- const seed_key = await window.crypto.subtle.importKey(
+ const seed_key = await globalThis.crypto.subtle.importKey(
"raw",
new TextEncoder().encode(input),
"PBKDF2",
false,
["deriveBits"]
)
- const key = await window.crypto.subtle.deriveBits(
+ const key = await globalThis.crypto.subtle.deriveBits(
{ name: "PBKDF2", salt: HASH_SALT, iterations: 250000, hash: "SHA-512" },
seed_key,
512
@@ -51,8 +51,8 @@ export async function room_hash(input: string): Promise<string> {
}
export async function encrypt(key: CryptoKey, data: string): Promise<string> {
- const iv = window.crypto.getRandomValues(new Uint8Array(IV_LENGTH));
- const ciphertext = new Uint8Array(await window.crypto.subtle.encrypt(
+ const iv = globalThis.crypto.getRandomValues(new Uint8Array(IV_LENGTH));
+ const ciphertext = new Uint8Array(await globalThis.crypto.subtle.encrypt(
{ name: "AES-GCM", iv },
key,
new TextEncoder().encode(data)
@@ -69,7 +69,7 @@ export async function decrypt(key: CryptoKey, data: string): Promise<string> {
const buf = base64_to_buf(data);
const iv = buf.slice(0, IV_LENGTH);
const ciphertext = buf.slice(IV_LENGTH);
- const decryptedContent = await window.crypto.subtle.decrypt(
+ const decryptedContent = await globalThis.crypto.subtle.decrypt(
{ name: "AES-GCM", iv },
key,
ciphertext
diff --git a/client-web/source/protocol/mod.ts b/client-web/source/protocol/mod.ts
index d554820..de4293d 100644
--- a/client-web/source/protocol/mod.ts
+++ b/client-web/source/protocol/mod.ts
@@ -21,7 +21,7 @@ export class SignalingConnection {
constructor() { }
async connect(): Promise<SignalingConnection> {
log("ws", "connecting…")
- const ws_url = new URL(`${window.location.protocol.endsWith("s:") ? "wss" : "ws"}://${window.location.host}/signaling`)
+ const ws_url = new URL(`${globalThis.location.protocol.endsWith("s:") ? "wss" : "ws"}://${globalThis.location.host}/signaling`)
this.websocket = new WebSocket(ws_url)
this.websocket.onerror = () => this.on_error()
this.websocket.onclose = () => this.on_close()
@@ -38,7 +38,7 @@ export class SignalingConnection {
on_close() {
log("ws", "websocket closed");
setTimeout(() => {
- window.location.reload()
+ globalThis.location.reload()
}, 1000)
}
on_open() {
diff --git a/client-web/source/resource/track.ts b/client-web/source/resource/track.ts
index 56c2b30..e2af5e9 100644
--- a/client-web/source/resource/track.ts
+++ b/client-web/source/resource/track.ts
@@ -211,7 +211,7 @@ function check_volume(stream: MediaStream, cb: (vol: number) => void) {
export async function create_camera_res() {
log("media", "requesting user media (camera)")
- const user_media = await window.navigator.mediaDevices.getUserMedia({
+ const user_media = await globalThis.navigator.mediaDevices.getUserMedia({
video: {
facingMode: { ideal: PREFS.camera_facing_mode },
frameRate: { ideal: PREFS.video_fps },
@@ -223,7 +223,7 @@ export async function create_camera_res() {
export async function create_screencast_res() {
log("media", "requesting user media (screen)")
- const user_media = await window.navigator.mediaDevices.getDisplayMedia({
+ const user_media = await globalThis.navigator.mediaDevices.getDisplayMedia({
video: {
frameRate: { ideal: PREFS.video_fps },
width: { ideal: PREFS.video_resolution }
@@ -235,7 +235,7 @@ export async function create_screencast_res() {
export async function create_mic_res() {
log("media", "requesting user media (audio)")
- const user_media = await window.navigator.mediaDevices.getUserMedia({
+ const user_media = await globalThis.navigator.mediaDevices.getUserMedia({
audio: {
channelCount: { ideal: 1 },
noiseSuppression: { ideal: PREFS.rnnoise ? false : PREFS.native_noise_suppression },
diff --git a/client-web/source/sw/client.ts b/client-web/source/sw/client.ts
index 431e601..83d7267 100644
--- a/client-web/source/sw/client.ts
+++ b/client-web/source/sw/client.ts
@@ -42,7 +42,7 @@ export async function update_serviceworker() {
const regs = await globalThis.navigator.serviceWorker.getRegistrations()
for (const r of regs) await r.unregister()
log("sw", "cleared all workers")
- setTimeout(() => window.location.reload(), 500)
+ setTimeout(() => globalThis.location.reload(), 500)
}
function start_handler() {
diff --git a/client-web/source/user/local.ts b/client-web/source/user/local.ts
index a90a6f2..371efff 100644
--- a/client-web/source/user/local.ts
+++ b/client-web/source/user/local.ts
@@ -52,7 +52,7 @@ export class LocalUser extends User {
log("media", "awaiting local resource")
let t!: LocalResource;
try { t = await tp }
- catch (e) { log({ scope: "media", warn: true }, e.toString()) }
+ catch (e) { log({ scope: "media", warn: true }, (e as object).toString()) }
if (!t) return
log("media", "ok")
this.add_resource(t)