From b0097ecb8ba484c8636d8766f7c3cef20d33bda0 Mon Sep 17 00:00:00 2001 From: Continuist Date: Thu, 30 Oct 2025 13:18:31 -0400 Subject: [PATCH] Add user profiles to import function --- libs/sharenet-passport/src/wasm.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libs/sharenet-passport/src/wasm.rs b/libs/sharenet-passport/src/wasm.rs index aef9ab6..f51d8c5 100644 --- a/libs/sharenet-passport/src/wasm.rs +++ b/libs/sharenet-passport/src/wasm.rs @@ -13,7 +13,7 @@ use crate::infrastructure::{ Ed25519KeyDeriver, 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}; /// 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 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, &password, ).map_err(|e| JsValue::from_str(&format!("Failed to decrypt passport: {}", e)))?; - // Create passport - let passport = Passport::new( + // Create passport with decrypted user profiles instead of creating a new default one + let did = Did::new(&public_key); + let passport = Passport { seed, public_key, private_key, - passport_file.univ_id, - ); + did, + univ_id: passport_file.univ_id, + user_profiles, + }; let result = serde_wasm_bindgen::to_value(&passport) .map_err(|e| JsValue::from_str(&format!("Serialization error: {}", e)))?;