Add user profiles to import function
Some checks are pending
Sharenet Passport CI / test-native (push) Waiting to run
Sharenet Passport CI / test-wasm-headless (push) Waiting to run
Sharenet Passport CI / test-wasm-webdriver (push) Waiting to run
Sharenet Passport CI / build-wasm (push) Waiting to run
Sharenet Passport CI / lint (push) Waiting to run
Some checks are pending
Sharenet Passport CI / test-native (push) Waiting to run
Sharenet Passport CI / test-wasm-headless (push) Waiting to run
Sharenet Passport CI / test-wasm-webdriver (push) Waiting to run
Sharenet Passport CI / build-wasm (push) Waiting to run
Sharenet Passport CI / lint (push) Waiting to run
This commit is contained in:
parent
181adee26c
commit
b0097ecb8b
1 changed files with 9 additions and 6 deletions
|
|
@ -13,7 +13,7 @@ use crate::infrastructure::{
|
||||||
Ed25519KeyDeriver,
|
Ed25519KeyDeriver,
|
||||||
XChaCha20FileEncryptor,
|
XChaCha20FileEncryptor,
|
||||||
};
|
};
|
||||||
use crate::domain::entities::{Passport, UserIdentity, UserPreferences, PassportFile, RecoveryPhrase, UserProfile};
|
use crate::domain::entities::{Passport, UserIdentity, UserPreferences, PassportFile, RecoveryPhrase, UserProfile, Did};
|
||||||
use crate::domain::traits::{MnemonicGenerator, KeyDeriver, FileEncryptor};
|
use crate::domain::traits::{MnemonicGenerator, KeyDeriver, FileEncryptor};
|
||||||
|
|
||||||
/// Create a new passport with the given universe ID and password
|
/// Create a new passport with the given universe ID and password
|
||||||
|
|
@ -114,18 +114,21 @@ pub fn import_from_encrypted_data(
|
||||||
|
|
||||||
// Decrypt the passport file using the password
|
// Decrypt the passport file using the password
|
||||||
let encryptor = XChaCha20FileEncryptor;
|
let encryptor = XChaCha20FileEncryptor;
|
||||||
let (seed, public_key, private_key, _user_profiles) = encryptor.decrypt(
|
let (seed, public_key, private_key, user_profiles) = encryptor.decrypt(
|
||||||
&passport_file,
|
&passport_file,
|
||||||
&password,
|
&password,
|
||||||
).map_err(|e| JsValue::from_str(&format!("Failed to decrypt passport: {}", e)))?;
|
).map_err(|e| JsValue::from_str(&format!("Failed to decrypt passport: {}", e)))?;
|
||||||
|
|
||||||
// Create passport
|
// Create passport with decrypted user profiles instead of creating a new default one
|
||||||
let passport = Passport::new(
|
let did = Did::new(&public_key);
|
||||||
|
let passport = Passport {
|
||||||
seed,
|
seed,
|
||||||
public_key,
|
public_key,
|
||||||
private_key,
|
private_key,
|
||||||
passport_file.univ_id,
|
did,
|
||||||
);
|
univ_id: passport_file.univ_id,
|
||||||
|
user_profiles,
|
||||||
|
};
|
||||||
|
|
||||||
let result = serde_wasm_bindgen::to_value(&passport)
|
let result = serde_wasm_bindgen::to_value(&passport)
|
||||||
.map_err(|e| JsValue::from_str(&format!("Serialization error: {}", e)))?;
|
.map_err(|e| JsValue::from_str(&format!("Serialization error: {}", e)))?;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue