From b6d93e0f322901dfc1fee23f3d396a68e61e1b29 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 9 Sep 2022 11:42:06 +0200 Subject: crypto stuff --- client-web/source/protocol/mod.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'client-web/source/protocol/mod.ts') diff --git a/client-web/source/protocol/mod.ts b/client-web/source/protocol/mod.ts index 76b1290..f86e96f 100644 --- a/client-web/source/protocol/mod.ts +++ b/client-web/source/protocol/mod.ts @@ -1,6 +1,17 @@ +import { crypto_seeded_key } from "./crypto.ts" export class SignalingConnection { - constructor(room: string) { - + room!: string + websocket!: WebSocket + signaling_id!: string + key!: CryptoKey + + constructor() { } + async connect(room: string): Promise { + this.key = await crypto_seeded_key(room) + const ws_url = new URL(`${window.location.protocol.endsWith("s:") ? "wss" : "ws"}://${window.location.host}/signaling/${encodeURIComponent(this.signaling_id)}`) + this.websocket = new WebSocket(ws_url) + await new Promise(r => this.websocket!.onopen = r) + return this } } -- cgit v1.2.3-70-g09d2