From e255ea0b615558d5c2411be67fef31d8fe67c761 Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 7 Sep 2022 10:40:25 +0700 Subject: [PATCH] TF-886 Add encryption cipher for token oidc in hive database --- lib/features/caching/token_oidc_cache_client.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/features/caching/token_oidc_cache_client.dart b/lib/features/caching/token_oidc_cache_client.dart index c40dadbda..2047b7e09 100644 --- a/lib/features/caching/token_oidc_cache_client.dart +++ b/lib/features/caching/token_oidc_cache_client.dart @@ -98,10 +98,14 @@ class TokenOidcCacheClient extends HiveCacheClient { @override Future> openBox() async { - if (Hive.isBoxOpen(tableName)) { - return Hive.box(tableName); - } - return Hive.openBox(tableName); + return Future.sync(() async { + final encryptionKey = await getEncryptionKey(); + return Hive.openBox( + tableName, + encryptionCipher: HiveAesCipher(encryptionKey!)); + }).catchError((error) { + throw error; + }); } @override