Skip to content

Commit e1f9399

Browse files
authored
feat: clear local storage data store (#241)
1 parent 99035c7 commit e1f9399

File tree

7 files changed

+82
-14
lines changed

7 files changed

+82
-14
lines changed

packages/cosmos_ui_components/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ packages:
6969
description:
7070
path: "packages/cosmos_utils"
7171
ref: main
72-
resolved-ref: "2946ddfdab692a9d9f4752c4af83c2b1083f51e6"
72+
resolved-ref: "99035c7be78a9959591220c8efb3e1e122274c03"
7373
url: "https://github.com/tendermint/flutter.git"
7474
source: git
7575
version: "0.0.1"

packages/transaction_signing_gateway/lib/storage/biometric_data_store.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,29 @@ class BiometricDataStore implements SecureDataStore {
124124
return left(BiometricCredentialsStorageFailure.unsupported());
125125
}
126126
}
127+
128+
@override
129+
Future<Either<CredentialsStorageFailure, bool>> clearAllData() async {
130+
try {
131+
final biometricStorage = BiometricStorage();
132+
final storageFile = await biometricStorage.getStorage(
133+
storageFileName,
134+
options: _storageFileInitOptions,
135+
promptInfo: promptInfo,
136+
);
137+
await storageFile.delete();
138+
return right(true);
139+
} catch (ex, stack) {
140+
logError(ex, stack);
141+
return left(
142+
CredentialsStorageFailure(
143+
'Error while clearing data in Biometric storage',
144+
cause: ex,
145+
stack: stack,
146+
),
147+
);
148+
}
149+
}
127150
}
128151

129152
Map<String, String?> _decodeMap(String json) => (json.trim().isEmpty

packages/transaction_signing_gateway/lib/storage/flutter_secure_storage_data_store.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ class FlutterSecureStorageDataStore implements SecureDataStore {
88
}) : _store = storage ?? const FlutterSecureStorage();
99

1010
final FlutterSecureStorage _store;
11+
static const iosOptions = IOSOptions(accessibility: IOSAccessibility.passcode);
12+
static const androidOptions = AndroidOptions(encryptedSharedPreferences: true);
1113

1214
@override
1315
Future<Either<CredentialsStorageFailure, String?>> readSecureText({required String key}) async {
1416
try {
1517
return right(
1618
await _store.read(
1719
key: key,
18-
iOptions: const IOSOptions(accessibility: IOSAccessibility.passcode),
19-
aOptions: const AndroidOptions(encryptedSharedPreferences: true),
20+
iOptions: iosOptions,
21+
aOptions: androidOptions,
2022
),
2123
);
2224
} catch (ex, stack) {
@@ -52,4 +54,24 @@ class FlutterSecureStorageDataStore implements SecureDataStore {
5254
);
5355
}
5456
}
57+
58+
@override
59+
Future<Either<CredentialsStorageFailure, bool>> clearAllData() async {
60+
try {
61+
await _store.deleteAll(
62+
iOptions: iosOptions,
63+
aOptions: androidOptions,
64+
);
65+
return right(true);
66+
} catch (ex, stack) {
67+
logError(ex, stack);
68+
return left(
69+
CredentialsStorageFailure(
70+
"Could not delete secure data'",
71+
cause: ex,
72+
stack: stack,
73+
),
74+
);
75+
}
76+
}
5577
}

packages/transaction_signing_gateway/lib/storage/shared_prefs_plain_data_store.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,21 @@ class SharedPrefsPlainDataStore implements PlainDataStore {
7979
);
8080
}
8181
}
82+
83+
@override
84+
Future<Either<CredentialsStorageFailure, bool>> clearAllData() async {
85+
try {
86+
final prefs = await sharedPreferencesProvider();
87+
return right(await prefs.clear());
88+
} catch (ex, stack) {
89+
logError(ex, stack);
90+
return left(
91+
CredentialsStorageFailure(
92+
'Error while clearing all data',
93+
cause: ex,
94+
stack: stack,
95+
),
96+
);
97+
}
98+
}
8299
}

packages/transaction_signing_gateway/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ packages:
167167
description:
168168
path: "packages/cosmos_utils"
169169
ref: main
170-
resolved-ref: "2946ddfdab692a9d9f4752c4af83c2b1083f51e6"
170+
resolved-ref: "99035c7be78a9959591220c8efb3e1e122274c03"
171171
url: "https://github.com/tendermint/flutter.git"
172172
source: git
173173
version: "0.0.1"
@@ -673,7 +673,7 @@ packages:
673673
name: win32
674674
url: "https://pub.dartlang.org"
675675
source: hosted
676-
version: "2.4.1"
676+
version: "2.4.4"
677677
xdg_directories:
678678
dependency: transitive
679679
description:

packages/transaction_signing_gateway/test/mocks/test_memory_store.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ class TestMemoryStore implements PlainDataStore, SecureDataStore {
77
@override
88
Future<Either<CredentialsStorageFailure, Map<String, String?>>> readAllPlainText() async => right({..._values});
99

10+
@override
11+
Future<Either<CredentialsStorageFailure, bool>> clearAllData() async {
12+
_values.clear();
13+
return right(true);
14+
}
15+
1016
@override
1117
Future<Either<CredentialsStorageFailure, String?>> readPlainText({
1218
required String key,

starport_template/pubspec.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ packages:
153153
description:
154154
path: "packages/cosmos_auth"
155155
ref: main
156-
resolved-ref: "2946ddfdab692a9d9f4752c4af83c2b1083f51e6"
156+
resolved-ref: "99035c7be78a9959591220c8efb3e1e122274c03"
157157
url: "https://github.com/tendermint/flutter.git"
158158
source: git
159159
version: "0.0.1"
@@ -162,7 +162,7 @@ packages:
162162
description:
163163
path: "packages/cosmos_ui_components"
164164
ref: main
165-
resolved-ref: "2946ddfdab692a9d9f4752c4af83c2b1083f51e6"
165+
resolved-ref: "99035c7be78a9959591220c8efb3e1e122274c03"
166166
url: "https://github.com/tendermint/flutter.git"
167167
source: git
168168
version: "0.0.1"
@@ -171,7 +171,7 @@ packages:
171171
description:
172172
path: "packages/cosmos_utils"
173173
ref: main
174-
resolved-ref: "2946ddfdab692a9d9f4752c4af83c2b1083f51e6"
174+
resolved-ref: "99035c7be78a9959591220c8efb3e1e122274c03"
175175
url: "https://github.com/tendermint/flutter.git"
176176
source: git
177177
version: "0.0.1"
@@ -651,14 +651,14 @@ packages:
651651
name: share_plus_macos
652652
url: "https://pub.dartlang.org"
653653
source: hosted
654-
version: "2.0.2"
654+
version: "2.1.0"
655655
share_plus_platform_interface:
656656
dependency: transitive
657657
description:
658658
name: share_plus_platform_interface
659659
url: "https://pub.dartlang.org"
660660
source: hosted
661-
version: "2.0.1"
661+
version: "2.1.0"
662662
share_plus_web:
663663
dependency: transitive
664664
description:
@@ -788,7 +788,7 @@ packages:
788788
description:
789789
path: "packages/transaction_signing_gateway"
790790
ref: main
791-
resolved-ref: "2946ddfdab692a9d9f4752c4af83c2b1083f51e6"
791+
resolved-ref: "99035c7be78a9959591220c8efb3e1e122274c03"
792792
url: "https://github.com/tendermint/flutter.git"
793793
source: git
794794
version: "0.0.1"
@@ -847,7 +847,7 @@ packages:
847847
name: url_launcher_web
848848
url: "https://pub.dartlang.org"
849849
source: hosted
850-
version: "2.0.6"
850+
version: "2.0.9"
851851
url_launcher_windows:
852852
dependency: transitive
853853
description:
@@ -882,7 +882,7 @@ packages:
882882
name: win32
883883
url: "https://pub.dartlang.org"
884884
source: hosted
885-
version: "2.4.1"
885+
version: "2.4.4"
886886
xdg_directories:
887887
dependency: transitive
888888
description:
@@ -906,4 +906,4 @@ packages:
906906
version: "3.1.0"
907907
sdks:
908908
dart: ">=2.15.0 <3.0.0"
909-
flutter: ">=2.8.0"
909+
flutter: ">=2.10.0"

0 commit comments

Comments
 (0)