From 2c68c57d10fe3ee4977ba1681e67b158666f8ea1 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Tue, 18 Mar 2025 19:52:22 -0700 Subject: [PATCH] Don't export / import pin codes when making / restoring backups (#2089) * initial commit * remove print --- lib/core/backup_service.dart | 8 +------- lib/src/screens/pin_code/pin_code_widget.dart | 6 +++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 03f20363d..df9442306 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -449,8 +449,6 @@ class BackupService { final keychainJSON = json.decode(utf8.decode(decryptedKeychainDumpFileData)) as Map; final keychainWalletsInfo = keychainJSON['wallets'] as List; - final decodedPin = keychainJSON['pin'] as String; - final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword); final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword); final backupPassword = keychainJSON[backupPasswordKey] as String; @@ -461,8 +459,6 @@ class BackupService { await importWalletKeychainInfo(info); }); - await _secureStorage.write(key: pinCodeKey, value: encodedPinCode(pin: decodedPin)); - keychainDumpFile.deleteSync(); } @@ -481,8 +477,6 @@ class BackupService { Future _exportKeychainDumpV2(String password, {String keychainSalt = secrets.backupKeychainSalt}) async { final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword); - final encodedPin = await _secureStorage.read(key: key); - final decodedPin = decodedPinCode(pin: encodedPin!); final wallets = await Future.wait(_walletInfoSource.values.map((walletInfo) async { return { 'name': walletInfo.name, @@ -493,7 +487,7 @@ class BackupService { final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword); final backupPassword = await _secureStorage.read(key: backupPasswordKey); final data = utf8.encode( - json.encode({'pin': decodedPin, 'wallets': wallets, backupPasswordKey: backupPassword})); + json.encode({'wallets': wallets, backupPasswordKey: backupPassword})); final encrypted = await _encryptV2(Uint8List.fromList(data), '$keychainSalt$password'); return encrypted; diff --git a/lib/src/screens/pin_code/pin_code_widget.dart b/lib/src/screens/pin_code/pin_code_widget.dart index dcd875d7a..f6249576d 100644 --- a/lib/src/screens/pin_code/pin_code_widget.dart +++ b/lib/src/screens/pin_code/pin_code_widget.dart @@ -119,11 +119,11 @@ class PinCodeState extends State { color: Theme.of(context).extension()!.titleColor, ); - return RawKeyboardListener( + return KeyboardListener( focusNode: FocusNode(), autofocus: true, - onKey: (keyEvent) { - if (keyEvent is RawKeyDownEvent) { + onKeyEvent: (keyEvent) { + if (keyEvent is KeyDownEvent) { if (keyEvent.logicalKey.keyLabel == "Backspace") { _pop(); return;