mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Merge pull request #333 from PR0M3TH3AN/codex/investigate-seedpass-sync-issue
Fix test profile directory mismatch
This commit is contained in:
12
README.md
12
README.md
@@ -360,14 +360,14 @@ pytest -vv -s -n 0 src/tests/test_nostr_index_size.py --desktop --max-entries=10
|
||||
Use the helper script below to populate a profile with sample entries for testing:
|
||||
|
||||
```bash
|
||||
python scripts/generate_test_profile.py --profile my_profile --count 100
|
||||
python scripts/generate_test_profile.py --profile demo_profile --count 100
|
||||
```
|
||||
|
||||
This command creates `~/.seedpass/my_profile` if needed and adds 100 example entries.
|
||||
After populating the vault, the script prints the derived **fingerprint** and
|
||||
automatically publishes the encrypted index to Nostr under that fingerprint.
|
||||
Use the same seed phrase when loading SeedPass so it can retrieve the data from
|
||||
Nostr.
|
||||
The script now determines the fingerprint from the generated seed and stores the
|
||||
vault under `~/.seedpass/<fingerprint>`. It also prints the fingerprint after
|
||||
creation and publishes the encrypted index to Nostr. Use that same seed phrase
|
||||
to load SeedPass. The app checks Nostr on startup and pulls any newer snapshot
|
||||
so your vault stays in sync across machines.
|
||||
|
||||
### Automatically Updating the Script Checksum
|
||||
|
||||
|
@@ -37,15 +37,15 @@ import gzip
|
||||
DEFAULT_PASSWORD = "testpassword"
|
||||
|
||||
|
||||
def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path]:
|
||||
"""Create or load a profile and return the seed phrase and manager."""
|
||||
profile_dir = APP_DIR / profile_name
|
||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||
def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path, str]:
|
||||
"""Create or load a profile and return the seed phrase, manager, directory and fingerprint."""
|
||||
temp_dir = APP_DIR / profile_name
|
||||
temp_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
seed_key = derive_key_from_password(DEFAULT_PASSWORD)
|
||||
seed_mgr = EncryptionManager(seed_key, profile_dir)
|
||||
seed_file = profile_dir / "parent_seed.enc"
|
||||
clear_path = profile_dir / "seed_phrase.txt"
|
||||
seed_mgr = EncryptionManager(seed_key, temp_dir)
|
||||
seed_file = temp_dir / "parent_seed.enc"
|
||||
clear_path = temp_dir / "seed_phrase.txt"
|
||||
|
||||
if seed_file.exists():
|
||||
seed_phrase = seed_mgr.decrypt_parent_seed()
|
||||
@@ -65,13 +65,27 @@ def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path]:
|
||||
clear_path.write_text(seed_phrase)
|
||||
clear_path.chmod(0o600)
|
||||
|
||||
fingerprint = generate_fingerprint(seed_phrase) or profile_name
|
||||
profile_dir = APP_DIR / fingerprint
|
||||
if profile_dir != temp_dir:
|
||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||
for p in temp_dir.iterdir():
|
||||
target = profile_dir / p.name
|
||||
if not target.exists():
|
||||
p.rename(target)
|
||||
try:
|
||||
temp_dir.rmdir()
|
||||
except OSError:
|
||||
pass
|
||||
seed_mgr.fingerprint_dir = profile_dir
|
||||
|
||||
index_key = derive_index_key(seed_phrase)
|
||||
enc_mgr = EncryptionManager(index_key, profile_dir)
|
||||
vault = Vault(enc_mgr, profile_dir)
|
||||
cfg_mgr = ConfigManager(vault, profile_dir)
|
||||
backup_mgr = BackupManager(profile_dir, cfg_mgr)
|
||||
entry_mgr = EntryManager(vault, backup_mgr)
|
||||
return seed_phrase, entry_mgr, profile_dir
|
||||
return seed_phrase, entry_mgr, profile_dir, fingerprint
|
||||
|
||||
|
||||
def random_secret(length: int = 16) -> str:
|
||||
@@ -132,8 +146,7 @@ def main() -> None:
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
seed, entry_mgr, dir_path = initialize_profile(args.profile)
|
||||
fingerprint = generate_fingerprint(seed)
|
||||
seed, entry_mgr, dir_path, fingerprint = initialize_profile(args.profile)
|
||||
print(f"Using profile directory: {dir_path}")
|
||||
print(f"Parent seed: {seed}")
|
||||
if fingerprint:
|
||||
|
@@ -302,7 +302,7 @@ class PasswordManager:
|
||||
# Initialize BIP85 and other managers
|
||||
self.initialize_bip85()
|
||||
self.initialize_managers()
|
||||
self.sync_index_from_nostr_if_missing()
|
||||
self.sync_index_from_nostr()
|
||||
print(
|
||||
colored(
|
||||
f"Seed profile {fingerprint} selected and managers initialized.",
|
||||
@@ -432,7 +432,7 @@ class PasswordManager:
|
||||
# Initialize BIP85 and other managers
|
||||
self.initialize_bip85()
|
||||
self.initialize_managers()
|
||||
self.sync_index_from_nostr_if_missing()
|
||||
self.sync_index_from_nostr()
|
||||
print(colored(f"Switched to seed profile {selected_fingerprint}.", "green"))
|
||||
|
||||
# Re-initialize NostrClient with the new fingerprint
|
||||
@@ -616,7 +616,7 @@ class PasswordManager:
|
||||
|
||||
self.initialize_bip85()
|
||||
self.initialize_managers()
|
||||
self.sync_index_from_nostr_if_missing()
|
||||
self.sync_index_from_nostr()
|
||||
return fingerprint # Return the generated or added fingerprint
|
||||
else:
|
||||
logging.error("Invalid BIP-85 seed phrase. Exiting.")
|
||||
@@ -757,7 +757,7 @@ class PasswordManager:
|
||||
|
||||
self.initialize_bip85()
|
||||
self.initialize_managers()
|
||||
self.sync_index_from_nostr_if_missing()
|
||||
self.sync_index_from_nostr()
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to encrypt and save parent seed: {e}", exc_info=True)
|
||||
print(colored(f"Error: Failed to encrypt and save parent seed: {e}", "red"))
|
||||
|
Reference in New Issue
Block a user