From 00f89e7d1bfd3f660fcff22365ed07b7bec844f5 Mon Sep 17 00:00:00 2001 From: julian <julian@cypherstack.com> Date: Mon, 5 Dec 2022 13:59:07 -0600 Subject: [PATCH] added functionality to sec store interface --- .../flutter_secure_storage_interface.dart | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/lib/utilities/flutter_secure_storage_interface.dart b/lib/utilities/flutter_secure_storage_interface.dart index 2d9b19050..539f17847 100644 --- a/lib/utilities/flutter_secure_storage_interface.dart +++ b/lib/utilities/flutter_secure_storage_interface.dart @@ -37,6 +37,15 @@ abstract class SecureStorageInterface { MacOsOptions? mOptions, WindowsOptions? wOptions, }); + + Future<void> deleteAll({ + IOSOptions? iOptions, + AndroidOptions? aOptions, + LinuxOptions? lOptions, + WebOptions? webOptions, + MacOsOptions? mOptions, + WindowsOptions? wOptions, + }); } class DesktopSecureStore { @@ -54,6 +63,10 @@ class DesktopSecureStore { ); } + Future<void> close() async { + await isar.close(); + } + Future<String?> read({ required String key, }) async { @@ -192,6 +205,30 @@ class SecureStorageWrapper implements SecureStorageInterface { ); } } + + @override + Future<void> deleteAll({ + IOSOptions? iOptions, + AndroidOptions? aOptions, + LinuxOptions? lOptions, + WebOptions? webOptions, + MacOsOptions? mOptions, + WindowsOptions? wOptions, + }) async { + if (_isDesktop) { + // return (_store as DesktopSecureStore).deleteAll(); + throw UnimplementedError(); + } else { + return await (_store as FlutterSecureStorage).deleteAll( + iOptions: iOptions, + aOptions: aOptions, + lOptions: lOptions, + webOptions: webOptions, + mOptions: mOptions, + wOptions: wOptions, + ); + } + } } // Mock class for testing purposes @@ -252,6 +289,20 @@ class FakeSecureStorage implements SecureStorageInterface { _store.remove(key); } + @override + Future<void> deleteAll({ + IOSOptions? iOptions, + AndroidOptions? aOptions, + LinuxOptions? lOptions, + WebOptions? webOptions, + MacOsOptions? mOptions, + WindowsOptions? wOptions, + }) async { + _interactions++; + _deletes++; + _store.clear(); + } + @override dynamic get store => throw UnimplementedError(); }