Fix javascript to handle values properly

This commit is contained in:
onyinyang 2023-01-26 00:17:14 -05:00
parent 5852a53c2b
commit a2e329ddf5
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
2 changed files with 10 additions and 8 deletions

View File

@ -1,18 +1,20 @@
import init, { open_invite, set_panic_hook } from "./pkg/lox_wasm.js"; import init, { open_invite, set_panic_hook } from "./pkg/lox_wasm.js";
var pubkeys = request_pubkeys().then((pubkeys) => { let pubkeys = await request_pubkeys();
pubkeys console.log(pubkeys);
});
console.log(pubkeys)
init().then(() => { let requested = await init().then(() => {
set_panic_hook(); set_panic_hook();
requested = request_open_invite().then((token) => { let requested = request_open_invite().then((token) => {
open_invite(token); return open_invite(token);
}); });
return requested;
// unsigned_open_lox_credential = handle_new_lox_credential(requested, pubkeys); // unsigned_open_lox_credential = handle_new_lox_credential(requested, pubkeys);
// lox_credential = request_new_lox_credential(request_cred[0]).then((lox_cred) => { // lox_credential = request_new_lox_credential(request_cred[0]).then((lox_cred) => {
// handle_new_lox_credential(request_cred[1], response, pubkey); // handle_new_lox_credential(request_cred[1], response, pubkey);
// }) // })
}); });
console.log("Got request and state "+requested);
function request_open_invite() { function request_open_invite() {
return new Promise((fulfill, reject) => { return new Promise((fulfill, reject) => {

View File

@ -56,7 +56,7 @@ fn deconcat_string(concatString: String) -> (String, String) {
#[wasm_bindgen] #[wasm_bindgen]
pub fn handle_new_lox_credential(open_lox_result: String, lox_pub: String) -> Result<String, JsValue> { pub fn handle_new_lox_credential(open_lox_result: String, open_lox_response: String, lox_pub: String) -> Result<String, JsValue> {
unsafe { unsafe {
log(&format!("Using server response: {:?}", open_lox_result)); log(&format!("Using server response: {:?}", open_lox_result));
} }