fix: Pass hive cipher

This commit is contained in:
Krille Fear 2021-11-19 09:50:04 +01:00
parent 5d055d6eb6
commit 746f06d834

View File

@ -16,7 +16,7 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
FlutterFluffyBoxDatabase( FlutterFluffyBoxDatabase(
String name, String name,
String path, { String path, {
List<int>? key, HiveCipher? key,
}) : super( }) : super(
name, name,
path, path,
@ -27,7 +27,7 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
static Future<FluffyBoxDatabase> databaseBuilder(Client client) async { static Future<FluffyBoxDatabase> databaseBuilder(Client client) async {
Logs().d('Open FluffyBox...'); Logs().d('Open FluffyBox...');
List<int>? hiverCipher; HiveAesCipher? hiverCipher;
try { try {
// Workaround for secure storage is calling Platform.operatingSystem on web // Workaround for secure storage is calling Platform.operatingSystem on web
if (kIsWeb) throw MissingPluginException(); if (kIsWeb) throw MissingPluginException();
@ -47,7 +47,7 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
final rawEncryptionKey = await secureStorage.read(key: _cipherStorageKey); final rawEncryptionKey = await secureStorage.read(key: _cipherStorageKey);
if (rawEncryptionKey == null) throw MissingPluginException(); if (rawEncryptionKey == null) throw MissingPluginException();
hiverCipher = base64Url.decode(rawEncryptionKey); hiverCipher = HiveAesCipher(base64Url.decode(rawEncryptionKey));
} on MissingPluginException catch (_) { } on MissingPluginException catch (_) {
Logs().i('FluffyBox encryption is not supported on this platform'); Logs().i('FluffyBox encryption is not supported on this platform');
} }