Add wasm_bindgen for handling new lox credential
This commit is contained in:
parent
5d60807a42
commit
d473b53745
|
@ -10,7 +10,7 @@ license = "MIT"
|
|||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
lox = { git = "https://gitlab.torproject.org/onyinyang/lox.git" }
|
||||
lox = { git = "https://gitlab.torproject.org/onyinyang/lox.git", branch = "master" }
|
||||
wasm-bindgen = "0.2"
|
||||
serde_json = "1.0.87"
|
||||
serde-wasm-bindgen = "0.4.5"
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use lox::bridge_table::BridgeLine;
|
||||
use lox::cred;
|
||||
use lox::proto::open_invite;
|
||||
use lox::{IssuerPubKey, OPENINV_LENGTH};
|
||||
use serde_json;
|
||||
use serde_wasm_bindgen;
|
||||
//use serde_wasm_bindgen;
|
||||
use std::array::TryFromSliceError;
|
||||
use std::panic;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -49,15 +48,16 @@ fn concat_string(request: String, state: String) -> String {
|
|||
return new_string;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn handle_new_lox_credential(state: String, response: String) -> Result<String, JsValue> {
|
||||
pub fn handle_new_lox_credential(state: String, response: String, lox_pub: String) -> Result<String, JsValue> {
|
||||
unsafe {
|
||||
log(&format!("Using server response: {:?}", response));
|
||||
}
|
||||
let deserialized_state = serde_json::from_str(&state).unwrap();
|
||||
let deserialized_response = serde_json::from_str(&response).unwrap();
|
||||
let lox_cred = match open_invite::handle_response(deserialized_state, deserialized_response, lox_pub) {
|
||||
let deserialized_pubkey = serde_json::from_str(&lox_pub).unwrap();
|
||||
let lox_cred = match open_invite::handle_response(deserialized_state, deserialized_response, &deserialized_pubkey) {
|
||||
Ok(lox_cred) => lox_cred,
|
||||
Err(e) => return Err(JsValue::from(e.to_string())),
|
||||
};
|
||||
|
@ -67,8 +67,9 @@ pub fn handle_new_lox_credential(state: String, response: String) -> Result<Stri
|
|||
log(&format!("Got new Lox Credential: {}", serialized_credential));
|
||||
log(&format!("Got new bridgeline: {}", serialized_bridgeline));
|
||||
}
|
||||
Ok((serialized_credential, serialized_bridgeline))
|
||||
} */
|
||||
let open_lox_response = concat_string(serialized_credential, serialized_bridgeline);
|
||||
Ok(open_lox_response)
|
||||
}
|
||||
|
||||
/* Somehow get pubkeys and return to function
|
||||
#[wasm_bindgen]
|
||||
|
|
Loading…
Reference in New Issue