mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-10 12:54:38 +00:00
Merge branch 'CW-394-mac-auth-2' of https://github.com/cake-tech/cake_wallet into CW-565-sign-messages
This commit is contained in:
commit
b84b761ef8
16 changed files with 67 additions and 51 deletions
2
.github/workflows/pr_test_build.yml
vendored
2
.github/workflows/pr_test_build.yml
vendored
|
@ -42,7 +42,7 @@ jobs:
|
||||||
- name: Flutter action
|
- name: Flutter action
|
||||||
uses: subosito/flutter-action@v1
|
uses: subosito/flutter-action@v1
|
||||||
with:
|
with:
|
||||||
flutter-version: "3.13.9"
|
flutter-version: "3.19.5"
|
||||||
channel: stable
|
channel: stable
|
||||||
|
|
||||||
- name: Install package dependencies
|
- name: Install package dependencies
|
||||||
|
|
|
@ -24,15 +24,13 @@ dependency_overrides:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/cake-tech/web3dart.git
|
url: https://github.com/cake-tech/web3dart.git
|
||||||
ref: cake
|
ref: cake
|
||||||
|
watcher: ^1.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
build_runner: ^2.4.7
|
build_runner: ^2.4.7
|
||||||
|
|
||||||
dependency_overrides:
|
|
||||||
watcher: ^1.1.0
|
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
# assets:
|
# assets:
|
||||||
# - images/a_dot_burr.jpeg
|
# - images/a_dot_burr.jpeg
|
||||||
|
|
|
@ -38,6 +38,7 @@ dependency_overrides:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/cake-tech/ledger-flutter.git
|
url: https://github.com/cake-tech/ledger-flutter.git
|
||||||
ref: cake
|
ref: cake
|
||||||
|
watcher: ^1.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -28,6 +28,7 @@ dependency_overrides:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/cake-tech/web3dart.git
|
url: https://github.com/cake-tech/web3dart.git
|
||||||
ref: cake
|
ref: cake
|
||||||
|
watcher: ^1.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -35,8 +36,6 @@ dev_dependencies:
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^2.0.0
|
||||||
build_runner: ^2.4.7
|
build_runner: ^2.4.7
|
||||||
|
|
||||||
dependency_overrides:
|
|
||||||
watcher: ^1.1.0
|
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
|
|
|
@ -42,12 +42,7 @@ class AuthService with Store {
|
||||||
Future<void> setPassword(String password) async {
|
Future<void> setPassword(String password) async {
|
||||||
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||||
final encodedPassword = encodedPinCode(pin: password);
|
final encodedPassword = encodedPinCode(pin: password);
|
||||||
// secure storage has a weird bug on macOS, where overwriting a key doesn't work, unless
|
await writeSecureStorage(secureStorage, key: key, value: encodedPassword);
|
||||||
// we delete what's there first:
|
|
||||||
if (Platform.isMacOS) {
|
|
||||||
await secureStorage.delete(key: key);
|
|
||||||
}
|
|
||||||
await secureStorage.write(key: key, value: encodedPassword);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> canAuthenticate() async {
|
Future<bool> canAuthenticate() async {
|
||||||
|
@ -74,7 +69,11 @@ class AuthService with Store {
|
||||||
|
|
||||||
void saveLastAuthTime() {
|
void saveLastAuthTime() {
|
||||||
int timestamp = DateTime.now().millisecondsSinceEpoch;
|
int timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||||
secureStorage.write(key: SecureKey.lastAuthTimeMilliseconds, value: timestamp.toString());
|
writeSecureStorage(
|
||||||
|
secureStorage,
|
||||||
|
key: SecureKey.lastAuthTimeMilliseconds,
|
||||||
|
value: timestamp.toString(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> requireAuth() async {
|
Future<bool> requireAuth() async {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:cake_wallet/core/secure_storage.dart';
|
||||||
import 'package:cake_wallet/themes/theme_list.dart';
|
import 'package:cake_wallet/themes/theme_list.dart';
|
||||||
import 'package:cake_wallet/utils/device_info.dart';
|
import 'package:cake_wallet/utils/device_info.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
|
@ -373,16 +374,15 @@ class BackupService {
|
||||||
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||||
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
||||||
|
|
||||||
await _flutterSecureStorage.delete(key: backupPasswordKey);
|
await writeSecureStorage(_flutterSecureStorage, key: backupPasswordKey, value: backupPassword);
|
||||||
await _flutterSecureStorage.write(key: backupPasswordKey, value: backupPassword);
|
|
||||||
|
|
||||||
keychainWalletsInfo.forEach((dynamic rawInfo) async {
|
keychainWalletsInfo.forEach((dynamic rawInfo) async {
|
||||||
final info = rawInfo as Map<String, dynamic>;
|
final info = rawInfo as Map<String, dynamic>;
|
||||||
await importWalletKeychainInfo(info);
|
await importWalletKeychainInfo(info);
|
||||||
});
|
});
|
||||||
|
|
||||||
await _flutterSecureStorage.delete(key: pinCodeKey);
|
await writeSecureStorage(_flutterSecureStorage,
|
||||||
await _flutterSecureStorage.write(key: pinCodeKey, value: encodedPinCode(pin: decodedPin));
|
key: pinCodeKey, value: encodedPinCode(pin: decodedPin));
|
||||||
|
|
||||||
keychainDumpFile.deleteSync();
|
keychainDumpFile.deleteSync();
|
||||||
}
|
}
|
||||||
|
@ -401,16 +401,15 @@ class BackupService {
|
||||||
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||||
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
||||||
|
|
||||||
await _flutterSecureStorage.delete(key: backupPasswordKey);
|
await writeSecureStorage(_flutterSecureStorage, key: backupPasswordKey, value: backupPassword);
|
||||||
await _flutterSecureStorage.write(key: backupPasswordKey, value: backupPassword);
|
|
||||||
|
|
||||||
keychainWalletsInfo.forEach((dynamic rawInfo) async {
|
keychainWalletsInfo.forEach((dynamic rawInfo) async {
|
||||||
final info = rawInfo as Map<String, dynamic>;
|
final info = rawInfo as Map<String, dynamic>;
|
||||||
await importWalletKeychainInfo(info);
|
await importWalletKeychainInfo(info);
|
||||||
});
|
});
|
||||||
|
|
||||||
await _flutterSecureStorage.delete(key: pinCodeKey);
|
await writeSecureStorage(_flutterSecureStorage,
|
||||||
await _flutterSecureStorage.write(key: pinCodeKey, value: encodedPinCode(pin: decodedPin));
|
key: pinCodeKey, value: encodedPinCode(pin: decodedPin));
|
||||||
|
|
||||||
keychainDumpFile.deleteSync();
|
keychainDumpFile.deleteSync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,7 @@ class KeyService {
|
||||||
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
|
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
|
||||||
final encodedPassword = encodeWalletPassword(password: password);
|
final encodedPassword = encodeWalletPassword(password: password);
|
||||||
|
|
||||||
await _secureStorage.delete(key: key);
|
await writeSecureStorage(_secureStorage, key: key, value: encodedPassword);
|
||||||
await _secureStorage.write(key: key, value: encodedPassword);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteWalletPassword({required String walletName}) async {
|
Future<void> deleteWalletPassword({required String walletName}) async {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
// For now, we can create a utility function to handle this.
|
// For now, we can create a utility function to handle this.
|
||||||
//
|
//
|
||||||
|
@ -25,3 +26,13 @@ Future<String?> readSecureStorage(FlutterSecureStorage secureStorage, String key
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> writeSecureStorage(FlutterSecureStorage secureStorage,
|
||||||
|
{required String key, required String value}) async {
|
||||||
|
// delete the value before writing on macOS because of a weird bug
|
||||||
|
// https://github.com/mogol/flutter_secure_storage/issues/581
|
||||||
|
if (Platform.isMacOS) {
|
||||||
|
await secureStorage.delete(key: key);
|
||||||
|
}
|
||||||
|
await secureStorage.write(key: key, value: value);
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ class BiometricAuth {
|
||||||
bool canAuthenticate;
|
bool canAuthenticate;
|
||||||
try {
|
try {
|
||||||
canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();
|
canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();
|
||||||
|
await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(0);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print("Exception checking support. $error");
|
print("Exception checking support. $error");
|
||||||
canAuthenticate = false;
|
canAuthenticate = false;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:cake_wallet/core/secure_storage.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
@ -147,8 +148,8 @@ Future<void> ios_migrate_pin() async {
|
||||||
|
|
||||||
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||||
final encodedPassword = encodedPinCode(pin: pinPassword);
|
final encodedPassword = encodedPinCode(pin: pinPassword);
|
||||||
await flutterSecureStorage.delete(key: key);
|
await writeSecureStorage(flutterSecureStorage, key: key, value: encodedPassword);
|
||||||
await flutterSecureStorage.write(key: key, value: encodedPassword);
|
|
||||||
await prefs.setBool('ios_migration_pin_completed', true);
|
await prefs.setBool('ios_migration_pin_completed', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/core/secure_storage.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:cw_core/cake_hive.dart';
|
import 'package:cw_core/cake_hive.dart';
|
||||||
|
|
||||||
|
@ -10,8 +11,7 @@ Future<List<int>> getEncryptionKey(
|
||||||
key = CakeHive.generateSecureKey();
|
key = CakeHive.generateSecureKey();
|
||||||
final keyStringified = key.join(',');
|
final keyStringified = key.join(',');
|
||||||
String storageKey = 'transactionDescriptionsBoxKey';
|
String storageKey = 'transactionDescriptionsBoxKey';
|
||||||
await secureStorage.delete(key: storageKey);
|
await writeSecureStorage(secureStorage, key: storageKey, value: keyStringified);
|
||||||
await secureStorage.write(key: storageKey, value: keyStringified);
|
|
||||||
} else {
|
} else {
|
||||||
key = stringifiedKey.split(',').map((i) => int.parse(i)).toList();
|
key = stringifiedKey.split(',').map((i) => int.parse(i)).toList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:cake_wallet/core/secure_storage.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
@ -58,7 +59,6 @@ class ChatwootWidgetState extends State<ChatwootWidget> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> storeCookie(String value) async {
|
Future<void> storeCookie(String value) async {
|
||||||
await widget.secureStorage.delete(key: COOKIE_KEY);
|
await writeSecureStorage(widget.secureStorage, key: COOKIE_KEY, value: value);
|
||||||
await widget.secureStorage.write(key: COOKIE_KEY, value: value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||||
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
|
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
|
||||||
|
import 'package:cake_wallet/core/secure_storage.dart';
|
||||||
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
||||||
import 'package:cake_wallet/entities/provider_types.dart';
|
import 'package:cake_wallet/entities/provider_types.dart';
|
||||||
import 'package:cake_wallet/entities/cake_2fa_preset_options.dart';
|
import 'package:cake_wallet/entities/cake_2fa_preset_options.dart';
|
||||||
|
@ -434,79 +435,83 @@ abstract class SettingsStoreBase with Store {
|
||||||
// secure storage keys:
|
// secure storage keys:
|
||||||
reaction(
|
reaction(
|
||||||
(_) => allowBiometricalAuthentication,
|
(_) => allowBiometricalAuthentication,
|
||||||
(bool biometricalAuthentication) => secureStorage.write(
|
(bool biometricalAuthentication) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.allowBiometricalAuthenticationKey,
|
key: SecureKey.allowBiometricalAuthenticationKey,
|
||||||
value: biometricalAuthentication.toString()));
|
value: biometricalAuthentication.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => selectedCake2FAPreset,
|
(_) => selectedCake2FAPreset,
|
||||||
(Cake2FAPresetsOptions selectedCake2FAPreset) => secureStorage.write(
|
(Cake2FAPresetsOptions selectedCake2FAPreset) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.selectedCake2FAPreset,
|
key: SecureKey.selectedCake2FAPreset,
|
||||||
value: selectedCake2FAPreset.serialize().toString()));
|
value: selectedCake2FAPreset.serialize().toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForAccessingWallet,
|
(_) => shouldRequireTOTP2FAForAccessingWallet,
|
||||||
(bool requireTOTP2FAForAccessingWallet) => secureStorage.write(
|
(bool requireTOTP2FAForAccessingWallet) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForAccessingWallet,
|
key: SecureKey.shouldRequireTOTP2FAForAccessingWallet,
|
||||||
value: requireTOTP2FAForAccessingWallet.toString()));
|
value: requireTOTP2FAForAccessingWallet.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForSendsToContact,
|
(_) => shouldRequireTOTP2FAForSendsToContact,
|
||||||
(bool requireTOTP2FAForSendsToContact) => secureStorage.write(
|
(bool requireTOTP2FAForSendsToContact) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForSendsToContact,
|
key: SecureKey.shouldRequireTOTP2FAForSendsToContact,
|
||||||
value: requireTOTP2FAForSendsToContact.toString()));
|
value: requireTOTP2FAForSendsToContact.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForSendsToNonContact,
|
(_) => shouldRequireTOTP2FAForSendsToNonContact,
|
||||||
(bool requireTOTP2FAForSendsToNonContact) => secureStorage.write(
|
(bool requireTOTP2FAForSendsToNonContact) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForSendsToNonContact,
|
key: SecureKey.shouldRequireTOTP2FAForSendsToNonContact,
|
||||||
value: requireTOTP2FAForSendsToNonContact.toString()));
|
value: requireTOTP2FAForSendsToNonContact.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForSendsToInternalWallets,
|
(_) => shouldRequireTOTP2FAForSendsToInternalWallets,
|
||||||
(bool requireTOTP2FAForSendsToInternalWallets) => secureStorage.write(
|
(bool requireTOTP2FAForSendsToInternalWallets) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForSendsToInternalWallets,
|
key: SecureKey.shouldRequireTOTP2FAForSendsToInternalWallets,
|
||||||
value: requireTOTP2FAForSendsToInternalWallets.toString()));
|
value: requireTOTP2FAForSendsToInternalWallets.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForExchangesToInternalWallets,
|
(_) => shouldRequireTOTP2FAForExchangesToInternalWallets,
|
||||||
(bool requireTOTP2FAForExchangesToInternalWallets) => secureStorage.write(
|
(bool requireTOTP2FAForExchangesToInternalWallets) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForExchangesToInternalWallets,
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToInternalWallets,
|
||||||
value: requireTOTP2FAForExchangesToInternalWallets.toString()));
|
value: requireTOTP2FAForExchangesToInternalWallets.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForExchangesToExternalWallets,
|
(_) => shouldRequireTOTP2FAForExchangesToExternalWallets,
|
||||||
(bool requireTOTP2FAForExchangesToExternalWallets) => secureStorage.write(
|
(bool requireTOTP2FAForExchangesToExternalWallets) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForExchangesToExternalWallets,
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToExternalWallets,
|
||||||
value: requireTOTP2FAForExchangesToExternalWallets.toString()));
|
value: requireTOTP2FAForExchangesToExternalWallets.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForAddingContacts,
|
(_) => shouldRequireTOTP2FAForAddingContacts,
|
||||||
(bool requireTOTP2FAForAddingContacts) => secureStorage.write(
|
(bool requireTOTP2FAForAddingContacts) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForAddingContacts,
|
key: SecureKey.shouldRequireTOTP2FAForAddingContacts,
|
||||||
value: requireTOTP2FAForAddingContacts.toString()));
|
value: requireTOTP2FAForAddingContacts.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForCreatingNewWallets,
|
(_) => shouldRequireTOTP2FAForCreatingNewWallets,
|
||||||
(bool requireTOTP2FAForCreatingNewWallets) => secureStorage.write(
|
(bool requireTOTP2FAForCreatingNewWallets) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForCreatingNewWallets,
|
key: SecureKey.shouldRequireTOTP2FAForCreatingNewWallets,
|
||||||
value: requireTOTP2FAForCreatingNewWallets.toString()));
|
value: requireTOTP2FAForCreatingNewWallets.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
(_) => shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
||||||
(bool requireTOTP2FAForAllSecurityAndBackupSettings) => secureStorage.write(
|
(bool requireTOTP2FAForAllSecurityAndBackupSettings) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
key: SecureKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
||||||
value: requireTOTP2FAForAllSecurityAndBackupSettings.toString()));
|
value: requireTOTP2FAForAllSecurityAndBackupSettings.toString()));
|
||||||
|
|
||||||
reaction((_) => useTOTP2FA,
|
reaction(
|
||||||
(bool use) => secureStorage.write(key: SecureKey.useTOTP2FA, value: use.toString()));
|
(_) => useTOTP2FA,
|
||||||
|
(bool use) =>
|
||||||
|
writeSecureStorage(secureStorage, key: SecureKey.useTOTP2FA, value: use.toString()));
|
||||||
|
|
||||||
reaction((_) => totpSecretKey,
|
reaction(
|
||||||
(String totpKey) => secureStorage.write(key: SecureKey.totpSecretKey, value: totpKey));
|
(_) => totpSecretKey,
|
||||||
|
(String totpKey) =>
|
||||||
|
writeSecureStorage(secureStorage, key: SecureKey.totpSecretKey, value: totpKey));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
(_) => pinTimeOutDuration,
|
(_) => pinTimeOutDuration,
|
||||||
(PinCodeRequiredDuration pinCodeInterval) => secureStorage.write(
|
(PinCodeRequiredDuration pinCodeInterval) => writeSecureStorage(secureStorage,
|
||||||
key: SecureKey.pinTimeOutDuration, value: pinCodeInterval.value.toString()));
|
key: SecureKey.pinTimeOutDuration, value: pinCodeInterval.value.toString()));
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
|
|
|
@ -109,8 +109,9 @@ abstract class AuthViewModelBase with Store {
|
||||||
final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();
|
final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final authenticated = await _flutterLocalAuthenticationPlugin.authenticate();
|
if (await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated()) {
|
||||||
if (!authenticated) {
|
state = ExecutedSuccessfullyState();
|
||||||
|
} else {
|
||||||
throw Exception('Biometric authentication failed');
|
throw Exception('Biometric authentication failed');
|
||||||
}
|
}
|
||||||
state = ExecutedSuccessfullyState();
|
state = ExecutedSuccessfullyState();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/core/secure_storage.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||||
|
@ -37,8 +38,7 @@ abstract class EditBackupPasswordViewModelBase with Store {
|
||||||
@action
|
@action
|
||||||
Future<void> save() async {
|
Future<void> save() async {
|
||||||
final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||||
await secureStorage.delete(key: key);
|
await writeSecureStorage(secureStorage, key: key, value: backupPassword);
|
||||||
await secureStorage.write(key: key, value: backupPassword);
|
|
||||||
secretStore.write(key: key, value: backupPassword);
|
secretStore.write(key: key, value: backupPassword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,9 @@ dependencies:
|
||||||
hive: ^2.2.3
|
hive: ^2.2.3
|
||||||
hive_flutter: ^1.1.0
|
hive_flutter: ^1.1.0
|
||||||
local_auth_android: 1.0.21
|
local_auth_android: 1.0.21
|
||||||
flutter_local_authentication: ^1.2.0
|
flutter_local_authentication:
|
||||||
|
git:
|
||||||
|
url: https://github.com/cake-tech/flutter_local_authentication
|
||||||
package_info: ^2.0.0
|
package_info: ^2.0.0
|
||||||
#package_info_plus: ^1.4.2
|
#package_info_plus: ^1.4.2
|
||||||
devicelocale:
|
devicelocale:
|
||||||
|
|
Loading…
Reference in a new issue