diff --git a/crates/lox-distributor/src/request_handler.rs b/crates/lox-distributor/src/request_handler.rs index b81c5b6..53dd0a2 100644 --- a/crates/lox-distributor/src/request_handler.rs +++ b/crates/lox-distributor/src/request_handler.rs @@ -374,7 +374,6 @@ mod tests { // Test Open Invite and get response let invite_response_str = body_to_string(invite_response).await; - println!("Base64 invite {:?}", invite_response_str); let response_data: lox_utils::Invite = serde_json::from_str(&invite_response_str).unwrap(); let token = match lox_utils::validate(&response_data.invite) { Ok(token) => token, diff --git a/crates/lox-wasm/index.js b/crates/lox-wasm/index.js index 6f337a9..2c491a3 100644 --- a/crates/lox-wasm/index.js +++ b/crates/lox-wasm/index.js @@ -199,7 +199,7 @@ function request_open_invite() { return new Promise((fulfill, reject) => { loxServerPostRequest("/invite", null).then((response) => { console.log("Got invitation token: " + response.invite); - fulfill(response.invite); + fulfill(JSON.stringify(response)); return; }).catch(() => { console.log("Error requesting open invite from Lox server"); diff --git a/crates/lox-wasm/src/lib.rs b/crates/lox-wasm/src/lib.rs index de93383..f15bb8c 100644 --- a/crates/lox-wasm/src/lib.rs +++ b/crates/lox-wasm/src/lib.rs @@ -29,9 +29,13 @@ pub fn set_panic_hook() { // Receives an invite and prepares an open_invite request, returning the // Request and State #[wasm_bindgen] -pub fn open_invite(invite: &[u8]) -> Result { - log(&format!("Using invite: {:?}", invite)); - let token = match lox_utils::validate(invite) { +pub fn open_invite(base64_invite: String) -> Result { + log(&format!("Using invite: {:?}", base64_invite)); + let invite: lox_utils::Invite = match serde_json::from_str(&base64_invite) { + Ok(invite) => invite, + Err(e) => return Err(JsValue::from(e.to_string())), + }; + let token = match lox_utils::validate(&invite.invite) { Ok(token) => token, Err(e) => return Err(JsValue::from(e.to_string())), };