cake_wallet/lib/store/secret_store.dart
Adegoke David bfb78eded9
CW-599-Extract-Secure-Storage (#1353)
* feat: Modify app to depend on secure storage abstraction instead of the direct package

* chore: Revert command

* Update configure.dart [skip ci]

* Update configure.dart

* Fix conflicts

* clean up and fixes

* minor fix

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-05-08 23:23:27 +03:00

28 lines
924 B
Dart

import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:mobx/mobx.dart';
part 'secret_store.g.dart';
class SecretStore = SecretStoreBase with _$SecretStore;
abstract class SecretStoreBase with Store {
static Future<SecretStore> load(SecureStorage storage) async {
final secretStore = SecretStore();
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
final backupPassword = await storage.read(key: backupPasswordKey);
// FIX-ME: backupPassword ?? '' ???
secretStore.write(key: backupPasswordKey, value: backupPassword ?? '');
return secretStore;
}
SecretStoreBase() : values = ObservableMap<String, String>();
ObservableMap values;
String read(String key) => values[key] as String;
String write({required String key, required String value}) =>
values[key] = value;
}