Don't export / import pin codes when making / restoring backups (#2089)
* initial commit * remove print
Matthew Fosse committed
Mar 18, 2025 at 19:52 UTC
2c68c57d10fe3ee4977ba1681e67b158666f8ea1
2 files changed
+4
-10
lib/core/backup_service.dart
+1
-7
@@ -449,8 +449,6 @@ class BackupService {
449
final keychainJSON =
450
json.decode(utf8.decode(decryptedKeychainDumpFileData)) as Map<String, dynamic>;
451
final keychainWalletsInfo = keychainJSON['wallets'] as List;
452
- final decodedPin = keychainJSON['pin'] as String;
453
- final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
452
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
453
final backupPassword = keychainJSON[backupPasswordKey] as String;
454
@@ -461,8 +459,6 @@ class BackupService {
459
await importWalletKeychainInfo(info);
460
});
461
464
- await _secureStorage.write(key: pinCodeKey, value: encodedPinCode(pin: decodedPin));
465
-
462
keychainDumpFile.deleteSync();
463
}
464
@@ -481,8 +477,6 @@ class BackupService {
477
Future<Uint8List> _exportKeychainDumpV2(String password,
478
{String keychainSalt = secrets.backupKeychainSalt}) async {
479
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
484
- final encodedPin = await _secureStorage.read(key: key);
485
- final decodedPin = decodedPinCode(pin: encodedPin!);
480
final wallets = await Future.wait(_walletInfoSource.values.map((walletInfo) async {
481
return {
482
'name': walletInfo.name,
@@ -493,7 +487,7 @@ class BackupService {
487
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
488
final backupPassword = await _secureStorage.read(key: backupPasswordKey);
489
final data = utf8.encode(
496
- json.encode({'pin': decodedPin, 'wallets': wallets, backupPasswordKey: backupPassword}));
490
+ json.encode({'wallets': wallets, backupPasswordKey: backupPassword}));
491
final encrypted = await _encryptV2(Uint8List.fromList(data), '$keychainSalt$password');
492
493
return encrypted;
lib/src/screens/pin_code/pin_code_widget.dart
+3
-3
@@ -119,11 +119,11 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
119
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
120
);
121
122
- return RawKeyboardListener(
122
+ return KeyboardListener(
123
focusNode: FocusNode(),
124
autofocus: true,
125
- onKey: (keyEvent) {
126
- if (keyEvent is RawKeyDownEvent) {
125
+ onKeyEvent: (keyEvent) {
126
+ if (keyEvent is KeyDownEvent) {
127
if (keyEvent.logicalKey.keyLabel == "Backspace") {
128
_pop();
129
return;