Overview
Core application logic is localized within the src/utils/ directory. While plugins interact with the system via a limited SDK, internal modules have full access to low-level APIs for database operations, cryptographic workflows, and import/export handling.
Database
The application uses NeDB (via @seald-io/nedb) as its primary persistence layer. The database file, vault.db, is managed in src/utils/db.js and located in the application data directory.
- Instance: Exports a singleton
dbinstance withautoload: true. - Storage: The file path is resolved dynamically using
window.nw.App.dataPathto ensure cross-platform compatibility.
Cryptography
Located in src/utils/crypto.js, this module implementation uses Node.js crypto to handle all sensitive transformations and manage the active Vault Key.
- Algorithm: Uses
AES-256-GCMfor all encryption tasks. Output follows a structurediv:tag:ciphertexthex-encoded format. - Generation Utilities:
generateSaltandgenerateVaultKeyproduce random hex-encoded strings (16-byte and 32-byte respectively) to initialize thevaultSaltand the primary DEK. - Key Management:
initKeyandclearKeymanage a module-levelENCRYPTION_KEY(the Vault Key / DEK). Theencryptanddecryptfunctions use this active key (or a provided custom key) to process data with automated IV and Auth Tag handling. - Derivation: The
deriveKeyhelper utilizesscryptSyncto produce consistent 32-byte KEKs from a secret (Master Password or hardware identifier) and a salt string (vaultSalt). - Hardware Binding:
encryptWithHardwareIdanddecryptWithHardwareIdbind the session token to the device by using Machine ID and the storedvaultSaltto derive a device-specific key for wrapping or unwrapping the Vault Key.
Data Service
The service in src/utils/dataService.js facilitates data portability, acting as a bridge between the live database and JSON export files in which each record’s sensitive value is re-encrypted under a key derived from the export (or import) password.
- Import Flow:
previewImportvalidates the JSON structure and returns statistics. TheimportDatafunction performs "key translation" by decrypting items with the import password and re-encrypting them with the active Vault Key. - Export Flow:
previewExportqueries the database for exportable records and calculates totals by type. TheexportDatafunction generates a fresh 16-byte salt, re-encrypts the selected records with an export-specific key, and utilizes the nativeshowSaveFilePickerAPI for secure file writing. - Data Cleanup: During import, system-specific fields like
_idare stripped, and dates are normalized to ensure consistent records and database integrity.
Utility Helpers
The src/utils/ directory also contains specialized tools that enforce consistent behavior across the application.
sorter.js: A universal sorting engine that prioritizes data integrity and expiration status before performing alphabetical sorting across all record types.totp.js: A wrapper for 6-digit code generation usingotpauth. It provides the current token and expiration metadata, including anisExpiringflag for the final 5-second window.viewTransition.js: Implements native View Transitions with custom animations.delays.js: ProvideswithDelayto ensure a minimum execution time for async operations, preventing UI flickering during fast state updates.
Summary
The internal architecture relies on the coordination between core utilities and specialized services. These modules should be accessed via Zustand stores or dedicated maintenance flows to keep the UI layer thin and decoupled from low-level logic.