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) {