From fc6be2aa9756e45b26a0e1cef9f7658509e8f05b Mon Sep 17 00:00:00 2001 From: fosse Date: Wed, 13 Dec 2023 16:08:30 -0500 Subject: [PATCH] save --- lib/entities/default_settings_migration.dart | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 22868ae28..6466a5b41 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -185,6 +185,8 @@ Future defaultSettingsMigration( case 25: await rewriteSecureStoragePin(secureStorage: secureStorage); break; + case 26: + await pinEncryptionMigration(secureStorage: secureStorage); default: break; } @@ -378,6 +380,31 @@ Node getMoneroDefaultNode({required Box nodes}) { } } +Future pinEncryptionMigration({required FlutterSecureStorage secureStorage}) async { + try { + // first, get the encoded pin: + final keyForPinCode = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword); + String? encodedPin; + encodedPin = await secureStorage.read(key: keyForPinCode); + + // if (encodedPin == null) { + // return; + // } + + // // ensure we overwrite by deleting the old key first: + // await secureStorage.delete(key: keyForPinCode); + // await secureStorage.write( + // key: keyForPinCode, + // value: encodedPin, + // iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock), + // mOptions: MacOsOptions(accessibility: KeychainAccessibility.first_unlock), + // ); + } catch (e) { + // failure isn't really an option since we'll be updating how pins are stored and used + print(e); + } +} + Future rewriteSecureStoragePin({required FlutterSecureStorage secureStorage}) async { // the bug only affects ios/mac: if (!Platform.isIOS && !Platform.isMacOS) {