import init, { open_invite, set_panic_hook } from "./pkg/lox_wasm.js"; var pubkeys = request_pubkeys().then((pubkeys) => { pubkeys }); console.log(pubkeys) init().then(() => { set_panic_hook(); requested = request_open_invite().then((token) => { open_invite(token); }); // unsigned_open_lox_credential = handle_new_lox_credential(requested, pubkeys); // 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("/invite").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 request_pubkeys() { return new Promise((fulfill, reject) => { loxServerRequest("/pubkeys").then((response) => { console.log("Got pubkeys: " + JSON.parse(response)); fulfill(JSON.parse(response)); 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 { xhr.open('GET', "http://localhost:8001"+data); //xhr.open("Post", "http://localhost:8001"+data) //xhr.setRequestHeader("Content-Type", "application/json"); //var data = JSON.stringify({}) } catch (err) { console.log("Error connecting to lox bridge db"); reject(); return; } xhr.send(); }); } // 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) => { }) }