feat: Implement note encryption and synchronization features
- Added NoteEncryption class for encrypting and decrypting note content using AES-GCM. - Updated NoteRepository to handle synchronization of notes and categories with the server, including encryption of note data before sending. - Introduced SyncRequest and SyncResponse models for managing synchronization data. - Enhanced LocalVaultService to store and retrieve the encryption key. - Modified HomeScreen and SettingsScreen to trigger synchronization after note operations and manage API endpoint settings. - Added SyncStatusIndicator to provide visual feedback on synchronization status in the app title bar. - Created Category model to manage note categories with encryption support. - Updated note model to include UUID, server version, deletion status, and category ID. - Added necessary UI elements for displaying and managing the encryption key in SettingsScreen. - Updated dependencies in pubspec.yaml for cryptography and HTTP handling.
This commit is contained in:
@@ -74,6 +74,14 @@ class LocalVaultService {
|
||||
return _secureStorage.read(key: _encryptionKeyStorageKey);
|
||||
}
|
||||
|
||||
Future<void> storeEncryptionKey(String encryptionKey) async {
|
||||
await _secureStorage.write(key: _encryptionKeyStorageKey, value: encryptionKey);
|
||||
}
|
||||
|
||||
String generateEncryptionKey() {
|
||||
return _generateEncryptionKey();
|
||||
}
|
||||
|
||||
Future<bool> hasEncryptionKey() async {
|
||||
return (await readStoredEncryptionKeyRaw()) != null;
|
||||
}
|
||||
@@ -117,10 +125,7 @@ class LocalVaultService {
|
||||
Future<String> createEncryptionKey({bool protectWithBiometrics = false}) async {
|
||||
final String encryptionKey = _generateEncryptionKey();
|
||||
|
||||
await _secureStorage.write(
|
||||
key: _encryptionKeyStorageKey,
|
||||
value: encryptionKey,
|
||||
);
|
||||
await storeEncryptionKey(encryptionKey);
|
||||
|
||||
// If requested, try to enable biometric protection. Only enable on mobile
|
||||
// platforms and only if the authentication succeeds.
|
||||
|
||||
Reference in New Issue
Block a user