X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fkiak.git;a=blobdiff_plain;f=host.js;h=f70732b454c8f58f48664fe1e7b39096f532eca6;hp=e6600de00e2c2564bf939d3b6310270156c75657;hb=10b1fcdf58cde8a6c6d5ebfa4bba76ef2adcf3dd;hpb=fee7676065c0016e999b2069b6a2b1a28d2b48d4 diff --git a/host.js b/host.js index e6600de..f70732b 100644 --- a/host.js +++ b/host.js @@ -11,7 +11,7 @@ if ("WebSocket" in window) { /* Message is offer from client */ console.log("Incoming connection " + msg) - /* State machine to parse offer */ + /* TODO: State machine to parse offer */ /* New Client Connection*/ hpc = new RTCPeerConnection() @@ -28,7 +28,8 @@ if ("WebSocket" in window) { pubKey: hpk }) clients.push({ - sdp: hpc.localDescription + host-sdp: hpc.localDescription, + client-sdp: hpc.remoteDescription, clientPubKey: msg.pubKey }) }) @@ -40,3 +41,18 @@ else { document.body.innerHTML = 'Websockets not supported in your browser' }) } +/* TODO: duplicate in both client.js and host.jhs */ +function getPublicKey() { + /* Check local storage for public key */ + if (window.localStorage.getItem('public-key') === undefined) { + /* If doesn't exist, generate public and private key pair, store in + local storage */ + crypto.subtle.generateKey({name:'RSA-OAEP', length: 192}, true, ['encrypt', 'decrypt']) + .then((keyPair) => { + /* TODO: Do we need to store the private key as well? */ + window.localStorage.setItem('public-key', keyPair.type.public.toString()) + }) + } + console.log(window.localStorage.getItem('public-key')) + return window.localStorage.getItem('public-key') +}