Merge pull request #484 from kinode-dao/dr/import-keyfile-fix

fix import keyfile!
This commit is contained in:
doria 2024-08-13 16:54:16 +03:00 committed by GitHub
commit e1573a793a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -62,7 +62,7 @@ function ImportKeyfile({
credentials: 'include',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
keyfile: Buffer.from(localKey).toString('base64'),
keyfile: Buffer.from(localKey).toString('utf8'),
password_hash: hashed_password,
}),
});

View File

@ -443,6 +443,7 @@ async fn handle_import_keyfile(
sender: Arc<RegistrationSender>,
provider: Arc<RootProvider<PubSubFrontend>>,
) -> Result<impl Reply, Rejection> {
println!("received base64 keyfile: {}\r", info.keyfile);
// if keyfile was not present in node and is present from user upload
let encoded_keyfile = match base64_standard.decode(info.keyfile) {
Ok(k) => k,
@ -455,6 +456,10 @@ async fn handle_import_keyfile(
}
};
println!(
"received keyfile: {}\r",
String::from_utf8_lossy(&encoded_keyfile)
);
let (decoded_keyfile, mut our) =
match keygen::decode_keyfile(&encoded_keyfile, &info.password_hash) {
Ok(k) => {