mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
bfb78eded9
* 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>
31 lines
1.1 KiB
Dart
31 lines
1.1 KiB
Dart
import 'package:cake_wallet/core/secure_storage.dart';
|
|
import 'package:cake_wallet/entities/secret_store_key.dart';
|
|
import 'package:cake_wallet/entities/encrypt.dart';
|
|
|
|
class KeyService {
|
|
KeyService(this._secureStorage);
|
|
|
|
final SecureStorage _secureStorage;
|
|
|
|
Future<String> getWalletPassword({required String walletName}) async {
|
|
final key =
|
|
generateStoreKeyFor(key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
|
|
final encodedPassword = await _secureStorage.read(key: key);
|
|
return decodeWalletPassword(password: encodedPassword!);
|
|
}
|
|
|
|
Future<void> saveWalletPassword({required String walletName, required String password}) async {
|
|
final key =
|
|
generateStoreKeyFor(key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
|
|
final encodedPassword = encodeWalletPassword(password: password);
|
|
|
|
await _secureStorage.write(key: key, value: encodedPassword);
|
|
}
|
|
|
|
Future<void> deleteWalletPassword({required String walletName}) async {
|
|
final key =
|
|
generateStoreKeyFor(key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
|
|
|
|
await _secureStorage.delete(key: key);
|
|
}
|
|
}
|