mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Add auto-sync mechanism for Nostr
This commit is contained in:
@@ -16,6 +16,7 @@ import getpass
|
||||
import os
|
||||
from typing import Optional
|
||||
import shutil
|
||||
import time
|
||||
from termcolor import colored
|
||||
|
||||
from password_manager.encryption import EncryptionManager
|
||||
@@ -47,6 +48,7 @@ from pathlib import Path
|
||||
|
||||
from local_bip85.bip85 import BIP85
|
||||
from bip_utils import Bip39SeedGenerator, Bip39MnemonicGenerator, Bip39Languages
|
||||
from datetime import datetime
|
||||
|
||||
from utils.fingerprint_manager import FingerprintManager
|
||||
|
||||
@@ -83,6 +85,10 @@ class PasswordManager:
|
||||
self.nostr_client: Optional[NostrClient] = None
|
||||
self.config_manager: Optional[ConfigManager] = None
|
||||
|
||||
# Track changes to trigger periodic Nostr sync
|
||||
self.is_dirty: bool = False
|
||||
self.last_update: float = time.time()
|
||||
|
||||
# Initialize the fingerprint manager first
|
||||
self.initialize_fingerprint_manager()
|
||||
|
||||
@@ -735,6 +741,10 @@ class PasswordManager:
|
||||
website_name, length, username, url, blacklisted=False
|
||||
)
|
||||
|
||||
# Mark database as dirty for background sync
|
||||
self.is_dirty = True
|
||||
self.last_update = time.time()
|
||||
|
||||
# Generate the password using the assigned index
|
||||
password = self.password_generator.generate_password(length, index)
|
||||
|
||||
@@ -911,6 +921,10 @@ class PasswordManager:
|
||||
index, new_username, new_url, new_blacklisted
|
||||
)
|
||||
|
||||
# Mark database as dirty for background sync
|
||||
self.is_dirty = True
|
||||
self.last_update = time.time()
|
||||
|
||||
print(colored(f"Entry updated successfully for index {index}.", "green"))
|
||||
|
||||
# Push the updated index to Nostr so changes are backed up.
|
||||
@@ -949,6 +963,10 @@ class PasswordManager:
|
||||
|
||||
self.entry_manager.delete_entry(index_to_delete)
|
||||
|
||||
# Mark database as dirty for background sync
|
||||
self.is_dirty = True
|
||||
self.last_update = time.time()
|
||||
|
||||
# Push updated index to Nostr after deletion
|
||||
try:
|
||||
encrypted_data = self.get_encrypted_data()
|
||||
|
Reference in New Issue
Block a user