mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Improve test profile script
This commit is contained in:
11
README.md
11
README.md
@@ -360,14 +360,13 @@ 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:
|
Use the helper script below to populate a profile with sample entries for testing:
|
||||||
|
|
||||||
```bash
|
```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.
|
The script now determines the fingerprint from the generated seed and stores the
|
||||||
After populating the vault, the script prints the derived **fingerprint** and
|
vault under `~/.seedpass/<fingerprint>`. It also prints the fingerprint after
|
||||||
automatically publishes the encrypted index to Nostr under that fingerprint.
|
creation and publishes the encrypted index to Nostr. Use that same seed phrase
|
||||||
Use the same seed phrase when loading SeedPass so it can retrieve the data from
|
to load SeedPass so it can automatically retrieve the data from Nostr.
|
||||||
Nostr.
|
|
||||||
|
|
||||||
### Automatically Updating the Script Checksum
|
### Automatically Updating the Script Checksum
|
||||||
|
|
||||||
|
@@ -37,15 +37,15 @@ import gzip
|
|||||||
DEFAULT_PASSWORD = "testpassword"
|
DEFAULT_PASSWORD = "testpassword"
|
||||||
|
|
||||||
|
|
||||||
def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path]:
|
def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path, str]:
|
||||||
"""Create or load a profile and return the seed phrase and manager."""
|
"""Create or load a profile and return the seed phrase, manager, directory and fingerprint."""
|
||||||
profile_dir = APP_DIR / profile_name
|
temp_dir = APP_DIR / profile_name
|
||||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
temp_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
seed_key = derive_key_from_password(DEFAULT_PASSWORD)
|
seed_key = derive_key_from_password(DEFAULT_PASSWORD)
|
||||||
seed_mgr = EncryptionManager(seed_key, profile_dir)
|
seed_mgr = EncryptionManager(seed_key, temp_dir)
|
||||||
seed_file = profile_dir / "parent_seed.enc"
|
seed_file = temp_dir / "parent_seed.enc"
|
||||||
clear_path = profile_dir / "seed_phrase.txt"
|
clear_path = temp_dir / "seed_phrase.txt"
|
||||||
|
|
||||||
if seed_file.exists():
|
if seed_file.exists():
|
||||||
seed_phrase = seed_mgr.decrypt_parent_seed()
|
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.write_text(seed_phrase)
|
||||||
clear_path.chmod(0o600)
|
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)
|
index_key = derive_index_key(seed_phrase)
|
||||||
enc_mgr = EncryptionManager(index_key, profile_dir)
|
enc_mgr = EncryptionManager(index_key, profile_dir)
|
||||||
vault = Vault(enc_mgr, profile_dir)
|
vault = Vault(enc_mgr, profile_dir)
|
||||||
cfg_mgr = ConfigManager(vault, profile_dir)
|
cfg_mgr = ConfigManager(vault, profile_dir)
|
||||||
backup_mgr = BackupManager(profile_dir, cfg_mgr)
|
backup_mgr = BackupManager(profile_dir, cfg_mgr)
|
||||||
entry_mgr = EntryManager(vault, backup_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:
|
def random_secret(length: int = 16) -> str:
|
||||||
@@ -132,8 +146,7 @@ def main() -> None:
|
|||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
seed, entry_mgr, dir_path = initialize_profile(args.profile)
|
seed, entry_mgr, dir_path, fingerprint = initialize_profile(args.profile)
|
||||||
fingerprint = generate_fingerprint(seed)
|
|
||||||
print(f"Using profile directory: {dir_path}")
|
print(f"Using profile directory: {dir_path}")
|
||||||
print(f"Parent seed: {seed}")
|
print(f"Parent seed: {seed}")
|
||||||
if fingerprint:
|
if fingerprint:
|
||||||
|
Reference in New Issue
Block a user