summaryrefslogtreecommitdiff
path: root/client-web
diff options
context:
space:
mode:
Diffstat (limited to 'client-web')
-rw-r--r--client-web/public/start.html10
-rw-r--r--client-web/source/index.ts2
-rw-r--r--client-web/source/protocol/crypto.ts25
3 files changed, 24 insertions, 13 deletions
diff --git a/client-web/public/start.html b/client-web/public/start.html
index 1a8080e..8316cee 100644
--- a/client-web/public/start.html
+++ b/client-web/public/start.html
@@ -6,7 +6,6 @@
<link rel="stylesheet" href="/assets/style/master.css" />
<title>keks-meet</title>
</head>
-
<body>
<div class="start-box">
<h2>keks-meet</h2>
@@ -33,7 +32,8 @@
const submit = document.createElement("input");
submit.type = "button";
- submit.addEventListener("click", () => {
+ function go() {
+ room_input.disabled = true;
if (room_input.value.length == 0) {
const random = window.crypto.getRandomValues(
new Uint8Array(32)
@@ -44,6 +44,12 @@
}
const url = `/room#${encodeURIComponent(room_input.value)}`;
window.location.href = url;
+ }
+ submit.addEventListener("click", () => {
+ go();
+ });
+ room_input.addEventListener("keydown", (ev) => {
+ if (ev.code == "Enter") go();
});
submit.value = "Join room!";
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index e8bbc0b..7dfdb59 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -36,7 +36,7 @@ export async function main() {
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 (room_name.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
- if (room_name.length == 0) window.location.href = "/" // send them back to the start page
+ 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 you room name now - e2ee is insecure!")
const conn = await (new SignalingConnection().connect(room_name))
diff --git a/client-web/source/protocol/crypto.ts b/client-web/source/protocol/crypto.ts
index 79b7e1d..654e80b 100644
--- a/client-web/source/protocol/crypto.ts
+++ b/client-web/source/protocol/crypto.ts
@@ -56,16 +56,21 @@ export async function crypto_encrypt(key: CryptoKey, data: string): Promise<stri
}
export async function crypt_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(
- { name: "AES-GCM", iv },
- key,
- ciphertext
- );
- const plain = new TextDecoder().decode(decryptedContent);
- return plain
+ try {
+ 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(
+ { name: "AES-GCM", iv },
+ key,
+ ciphertext
+ );
+ const plain = new TextDecoder().decode(decryptedContent);
+ return plain
+ } catch (_e) {
+ log({ scope: "crypto", warn: true }, "unable to decrypt")
+ return "{}" // :)
+ }
}
export function base64_to_buf(data: string): Uint8Array {