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