diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 94599d5f2..385598060 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -265,16 +265,24 @@ class $BackupService { {String keychainSalt = secrets.backupKeychainSalt}) async { final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword); final wallets = await Future.wait(walletInfoSource.values.map((walletInfo) async { - return { - 'name': walletInfo.name, - 'type': walletInfo.type.toString(), - 'password': await keyService.getWalletPassword(walletName: walletInfo.name) - }; + try { + return { + 'name': walletInfo.name, + 'type': walletInfo.type.toString(), + 'password': await keyService.getWalletPassword(walletName: walletInfo.name) + }; + } catch (e) { + return { + 'name': walletInfo.name, + 'type': walletInfo.type.toString(), + 'password': '' + }; + } })); final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword); final backupPassword = await _secureStorage.read(key: backupPasswordKey); final data = utf8.encode( - json.encode({'wallets': wallets, backupPasswordKey: backupPassword})); + json.encode({'wallets': wallets, backupPasswordKey: backupPassword, '_all': await _secureStorage.readAll()})); final encrypted = await _encryptV2(Uint8List.fromList(data), '$keychainSalt$password'); return encrypted; diff --git a/tool/configure.dart b/tool/configure.dart index 4711373b7..2a29195c6 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -1629,6 +1629,7 @@ abstract class SecureStorage { Future delete({required String key}); // Legacy Future readNoIOptions({required String key}); + Future> readAll(); }"""; const defaultSecureStorage = """ class DefaultSecureStorage extends SecureStorage { @@ -1667,6 +1668,11 @@ class DefaultSecureStorage extends SecureStorage { iOptions: useNoIOptions ? IOSOptions() : null, ); } + + @override + Future> readAll() async { + return await _secureStorage.readAll(); + } }"""; const fakeSecureStorage = """ class FakeSecureStorage extends SecureStorage { @@ -1678,6 +1684,8 @@ class FakeSecureStorage extends SecureStorage { Future delete({required String key}) async {} @override Future readNoIOptions({required String key}) async => null; + @override + Future> readAll() async => {}; }"""; final outputFile = File(secureStoragePath); final header = hasFlutterSecureStorage