import init, { open_invite, set_panic_hook } from "./pkg/lox_wasm.js"; init().then(() => { set_panic_hook(); requested = request_open_invite().then((token) => { open_invite(token); }); // lox_credential = request_new_lox_credential(request_cred[0]).then((lox_cred) => { // handle_new_lox_credential(request_cred[1], response, pubkey); // }) }); function request_open_invite() { return new Promise((fulfill, reject) => { loxServerRequest("").then((response) => { console.log("Got invitation token: " + response.invite); fulfill(response.invite); return; }).catch(() => { console.log("Error requesting open invite from Lox server"); reject(); }); }); } function loxServerRequest(data) { return new Promise((fulfill, reject) => { const xhr = new XMLHttpRequest(data); xhr.onreadystatechange = function() { if (xhr.DONE !== xhr.readyState) { return; } if (xhr.status !== 200) { console.log("Error. Status code: "+xhr.status); console.log(xhr); reject(); return; } const response = JSON.parse(xhr.responseText); fulfill(response); return; }; try { if (data != ""){ xhr.open('GET', "http://localhost:8001"); } else { xhr.open("Post", "http://localhost:8001") xhr.setRequestHeader("Content-Type", "application/json"); var data = JSON.stringify({}) } } catch (err) { console.log("Error connecting to lox bridge db"); reject(); return; } xhr.send(data); }); } // The correct key should be matched against a public commit to the key to // verify that the key issuer is in fact the correct Bridge Authority function loxKeyRequest(key_type) { return new Promise((fulfull, reject) => { }) }