Remove unsafe blocks that aren't needed

This commit is contained in:
Cecylia Bocovich 2023-06-16 11:17:57 -04:00
parent 84d7691ab8
commit 3136a8ba85
No known key found for this signature in database
GPG Key ID: 009DE379FD9B7B90
1 changed files with 69 additions and 103 deletions

View File

@ -47,21 +47,17 @@ pub fn set_panic_hook() {
#[wasm_bindgen]
pub fn open_invite(invite: &[u8]) -> Result<String, JsValue> {
unsafe {
log(&format!("Using invite: {:?}", invite));
}
log(&format!("Using invite: {:?}", invite));
let token = match lox_utils::validate(invite) {
Ok(token) => token,
Err(e) => return Err(JsValue::from(e.to_string())),
};
let (request, state) = open_invite::request(&token);
let req_state = lox_utils::OpenReqState { request, state };
unsafe {
log(&format!(
"Formatted open invite request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted open invite request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -91,16 +87,14 @@ pub fn handle_new_lox_credential(
bridgeline: Some(lox_cred.1),
invitation: None,
};
unsafe {
log(&format!(
"Got new Lox Credential: {}",
serde_json::to_string(&lox_cred.lox_credential).unwrap()
));
log(&format!(
"Got new bridgeline: {}",
serde_json::to_string(&lox_cred.bridgeline).unwrap()
));
}
log(&format!(
"Got new Lox Credential: {}",
serde_json::to_string(&lox_cred.lox_credential).unwrap()
));
log(&format!(
"Got new bridgeline: {}",
serde_json::to_string(&lox_cred.bridgeline).unwrap()
));
Ok(serde_json::to_string(&lox_cred).unwrap())
}
@ -127,12 +121,10 @@ pub fn trust_promotion(open_lox_cred: String, lox_pub: String) -> Result<String,
request: tp_result.0,
state: tp_result.1,
};
unsafe {
log(&format!(
"Formatted Trust Promotion request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted Trust Promotion request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -152,12 +144,10 @@ pub fn handle_trust_promotion(
return Err(JsValue::from(e.to_string()));
}
};
unsafe {
log(&format!(
"Got new Migration Credential: {}",
serde_json::to_string(&migration_cred).unwrap()
));
}
log(&format!(
"Got new Migration Credential: {}",
serde_json::to_string(&migration_cred).unwrap()
));
Ok(serde_json::to_string(&migration_cred).unwrap())
}
@ -186,12 +176,10 @@ pub fn trust_migration(
request: tm_result.0,
state: tm_result.1,
};
unsafe {
log(&format!(
"Formatted Trust Migration request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted Trust Migration request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -220,12 +208,10 @@ pub fn handle_trust_migration(
return Err(JsValue::from(e.to_string()));
}
};
unsafe {
log(&format!(
"Got new Level 1 Credential: {}",
serde_json::to_string(&level_one_cred).unwrap()
));
}
log(&format!(
"Got new Level 1 Credential: {}",
serde_json::to_string(&level_one_cred).unwrap()
));
Ok(serde_json::to_string(&level_one_cred).unwrap())
}
@ -270,12 +256,10 @@ pub fn level_up(
request: lu_result.0,
state: lu_result.1,
};
unsafe {
log(&format!(
"Formatted Level Up request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted Level Up request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -304,12 +288,10 @@ pub fn handle_level_up(
return Err(JsValue::from(e.to_string()));
}
};
unsafe {
log(&format!(
"Got new Level Up Credential: {}",
serde_json::to_string(&level_up_cred).unwrap()
));
}
log(&format!(
"Got new Level Up Credential: {}",
serde_json::to_string(&level_up_cred).unwrap()
));
Ok(serde_json::to_string(&level_up_cred).unwrap())
}
@ -341,12 +323,10 @@ pub fn issue_invite(
request: issue_result.0,
state: issue_result.1,
};
unsafe {
log(&format!(
"Formatted Issue Invite request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted Issue Invite request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -379,12 +359,10 @@ pub fn handle_issue_invite(
invitation: Some(issue_invite_cred.1),
};
unsafe {
log(&format!(
"Got new Invitation Credential and Lox Credential: {}",
serde_json::to_string(&invitation_cred).unwrap()
));
}
log(&format!(
"Got new Invitation Credential and Lox Credential: {}",
serde_json::to_string(&invitation_cred).unwrap()
));
Ok(serde_json::to_string(&invitation_cred).unwrap())
}
@ -416,12 +394,10 @@ pub fn redeem_invite(invitation: String, lox_pub: String) -> Result<String, JsVa
request: redeem_result.0,
state: redeem_result.1,
};
unsafe {
log(&format!(
"Formatted Redeem Invite request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted Redeem Invite request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -451,12 +427,10 @@ pub fn handle_redeem_invite(
return Err(JsValue::from(e.to_string()));
}
};
unsafe {
log(&format!(
"Got new Trusted Lox Credential from Invitation: {}",
serde_json::to_string(&redeem_invite_cred).unwrap()
));
}
log(&format!(
"Got new Trusted Lox Credential from Invitation: {}",
serde_json::to_string(&redeem_invite_cred).unwrap()
));
Ok(serde_json::to_string(&redeem_invite_cred).unwrap())
}
@ -475,12 +449,10 @@ pub fn check_blockage(lox_cred: String, lox_pub: String) -> Result<String, JsVal
request: cb_result.0,
state: cb_result.1,
};
unsafe {
log(&format!(
"Formatted Check Blockage request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted Check Blockage request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -501,12 +473,10 @@ pub fn handle_check_blockage(
return Err(JsValue::from(e.to_string()));
}
};
unsafe {
log(&format!(
"Got new Blockage Migration Credential: {}",
serde_json::to_string(&migration_cred).unwrap()
));
}
log(&format!(
"Got new Blockage Migration Credential: {}",
serde_json::to_string(&migration_cred).unwrap()
));
Ok(serde_json::to_string(&migration_cred).unwrap())
}
@ -535,12 +505,10 @@ pub fn blockage_migration(
request: bm_result.0,
state: bm_result.1,
};
unsafe {
log(&format!(
"Formatted Blockage Migration request: {}",
serde_json::to_string(&req_state).unwrap()
));
}
log(&format!(
"Formatted Blockage Migration request: {}",
serde_json::to_string(&req_state).unwrap()
));
Ok(serde_json::to_string(&req_state).unwrap())
}
@ -570,11 +538,9 @@ pub fn handle_blockage_migration(
return Err(JsValue::from(e.to_string()));
}
};
unsafe {
log(&format!(
"Got new Lox Credential after Migration: {}",
serde_json::to_string(&lox_cred).unwrap()
));
}
log(&format!(
"Got new Lox Credential after Migration: {}",
serde_json::to_string(&lox_cred).unwrap()
));
Ok(serde_json::to_string(&lox_cred).unwrap())
}