upsertKey method
Store or update an encrypted shared key for a user
Implementation
Future<void> upsertKey(String userId, String sharedKey, {String? password}) async {
final key = password ?? _defaultPassword;
final encryptedKey = _encryptSharedKey(userId, sharedKey, key);
_sharedKeysCache[userId] = sharedKey; // Store the decrypted key in the cache
await _database.insert(
tableSharedKeys,
{
columnUserId: userId,
columnSharedKey: encryptedKey, // Store the encrypted key
},
conflictAlgorithm: ConflictAlgorithm.replace,
);
}