Blockage Migration tested and fixed up
This commit is contained in:
parent
e12bff83e3
commit
ddf95d1335
|
@ -129,7 +129,7 @@ lox_cred = await init().then(() => {
|
|||
let prepared_invitation = prepare_invite(lox_cred);
|
||||
// Trusted Invitation Request
|
||||
let requested_invitation = redeem_invite(prepared_invitation, pubkeys);
|
||||
// Issue an Invitation cred
|
||||
// Redeem an Invitation cred
|
||||
let lox_cred_from_invite = await init().then(() => {
|
||||
set_panic_hook();
|
||||
let cred = requested_cred("/redeem", requested_invitation).then((response)=> {
|
||||
|
@ -158,7 +158,7 @@ let requested_blockage_migration = blockage_migration(lox_cred, check_migration_
|
|||
set_panic_hook();
|
||||
let cred = requested_cred("/blockagemigration", requested_blockage_migration).then((response)=> {
|
||||
console.log("Got Lox Credential for new bucket: " + response);
|
||||
return handle_blockage_migration(requested_check_blockage, response);
|
||||
return handle_blockage_migration(requested_blockage_migration, response, pubkeys);
|
||||
});
|
||||
return cred;
|
||||
});
|
||||
|
|
|
@ -59,6 +59,13 @@ struct CheckBlockageReqState {
|
|||
state: check_blockage::State,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
struct BlockageMigReqState {
|
||||
request: blockage_migration::Request,
|
||||
state: blockage_migration::State,
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct PubKeys {
|
||||
|
@ -530,7 +537,7 @@ pub fn check_blockage(lox_cred: String, lox_pub: String) -> Result<String, JsVal
|
|||
};
|
||||
unsafe {
|
||||
log(&format!(
|
||||
"Formatted Trust Promotion request: {}",
|
||||
"Formatted Check Blockage request: {}",
|
||||
serde_json::to_string(&req_state).unwrap()
|
||||
));
|
||||
}
|
||||
|
@ -555,7 +562,7 @@ pub fn handle_check_blockage(
|
|||
};
|
||||
unsafe {
|
||||
log(&format!(
|
||||
"Got new Migration Credential: {}",
|
||||
"Got new Blockage Migration Credential: {}",
|
||||
serde_json::to_string(&migration_cred).unwrap()
|
||||
));
|
||||
}
|
||||
|
@ -569,20 +576,20 @@ pub fn blockage_migration(lox_cred: String, check_migration_cred: String, lox_pu
|
|||
let pubkeys: PubKeys = serde_json::from_str(&lox_pub).unwrap();
|
||||
let mig_cred: Migration = serde_json::from_str(&check_migration_cred).unwrap();
|
||||
let bm_result =
|
||||
match migration::request(&lox_cred.lox_credential, &mig_cred, &pubkeys.lox_pub, &pubkeys.migration_pub) {
|
||||
Ok(tm_result) => tm_result,
|
||||
match blockage_migration::request(&lox_cred.lox_credential, &mig_cred, &pubkeys.lox_pub, &pubkeys.migration_pub) {
|
||||
Ok(bm_result) => bm_result,
|
||||
Err(e) => {
|
||||
log(&format!("Error: {:?}", e.to_string()));
|
||||
return Err(JsValue::from(e.to_string()));
|
||||
}
|
||||
};
|
||||
let req_state = MigReqState {
|
||||
let req_state = BlockageMigReqState {
|
||||
request: bm_result.0,
|
||||
state: bm_result.1,
|
||||
};
|
||||
unsafe {
|
||||
log(&format!(
|
||||
"Formatted Trust Migration request: {}",
|
||||
"Formatted Blockage Migration request: {}",
|
||||
serde_json::to_string(&req_state).unwrap()
|
||||
));
|
||||
}
|
||||
|
@ -596,11 +603,11 @@ pub fn handle_blockage_migration(
|
|||
lox_pub: String
|
||||
) -> Result<String, JsValue> {
|
||||
let pubkeys: PubKeys = serde_json::from_str(&lox_pub).unwrap();
|
||||
let req_state: MigReqState = serde_json::from_str(&blockage_migration_request).unwrap();
|
||||
let req_state: BlockageMigReqState = serde_json::from_str(&blockage_migration_request).unwrap();
|
||||
let deserialized_state = req_state.state;
|
||||
let deserialized_response = serde_json::from_str(&blockage_migration_response).unwrap();
|
||||
let lox_cred =
|
||||
match migration::handle_response(deserialized_state, deserialized_response, &pubkeys.lox_pub) {
|
||||
match blockage_migration::handle_response(deserialized_state, deserialized_response, &pubkeys.lox_pub) {
|
||||
Ok(lox_cred) => LoxCredential {
|
||||
lox_credential: lox_cred,
|
||||
bridgeline: None,
|
||||
|
@ -613,7 +620,7 @@ pub fn handle_blockage_migration(
|
|||
};
|
||||
unsafe {
|
||||
log(&format!(
|
||||
"Got new Level 1 Credential: {}",
|
||||
"Got new Lox Credential after Migration: {}",
|
||||
serde_json::to_string(&lox_cred).unwrap()
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue