Update wasm for base64 encoded invite

This commit is contained in:
onyinyang 2024-03-04 14:09:22 -05:00
parent 0a12b0fc52
commit 0e28602812
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
3 changed files with 8 additions and 5 deletions

View File

@ -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,

View File

@ -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");

View File

@ -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<String, JsValue> {
log(&format!("Using invite: {:?}", invite));
let token = match lox_utils::validate(invite) {
pub fn open_invite(base64_invite: String) -> Result<String, JsValue> {
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())),
};