mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-22 10:34:17 +01:00
Cw 540 encrypt shared (#1269)
* start writing migration * save * finishing up migration * more fixes * fixes * migration fixes * remove commented code and ensure widget initialization in root.dart * use securekey static functions everywhere applicable
This commit is contained in:
@@ -72,11 +72,11 @@ class AuthService with Store {
|
||||
|
||||
void saveLastAuthTime() {
|
||||
int timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
sharedPreferences.setInt(PreferencesKey.lastAuthTimeMilliseconds, timestamp);
|
||||
secureStorage.write(key: SecureKey.lastAuthTimeMilliseconds, value: timestamp.toString());
|
||||
}
|
||||
|
||||
bool requireAuth() {
|
||||
final timestamp = sharedPreferences.getInt(PreferencesKey.lastAuthTimeMilliseconds);
|
||||
Future<bool> requireAuth() async {
|
||||
final timestamp = int.tryParse(await secureStorage.read(key: SecureKey.lastAuthTimeMilliseconds) ?? '0');
|
||||
final duration = _durationToRequireAuth(timestamp ?? 0);
|
||||
final requiredPinInterval = settingsStore.pinTimeOutDuration;
|
||||
|
||||
@@ -100,7 +100,7 @@ class AuthService with Store {
|
||||
'Either route or onAuthSuccess param must be passed.');
|
||||
|
||||
if (!conditionToDetermineIfToUse2FA) {
|
||||
if (!requireAuth() && !_alwaysAuthenticateRoutes.contains(route)) {
|
||||
if (!(await requireAuth()) && !_alwaysAuthenticateRoutes.contains(route)) {
|
||||
if (onAuthSuccess != null) {
|
||||
onAuthSuccess(true);
|
||||
} else {
|
||||
|
||||
@@ -213,8 +213,6 @@ class BackupService {
|
||||
final defaultBuyProvider = data[PreferencesKey.defaultBuyProvider] as int?;
|
||||
final currentTransactionPriorityKeyLegacy =
|
||||
data[PreferencesKey.currentTransactionPriorityKeyLegacy] as int?;
|
||||
final allowBiometricalAuthentication =
|
||||
data[PreferencesKey.allowBiometricalAuthenticationKey] as bool?;
|
||||
final currentBitcoinElectrumSererId =
|
||||
data[PreferencesKey.currentBitcoinElectrumSererIdKey] as int?;
|
||||
final currentLanguageCode = data[PreferencesKey.currentLanguageCode] as String?;
|
||||
@@ -227,23 +225,6 @@ class BackupService {
|
||||
data[PreferencesKey.currentDefaultSettingsMigrationVersion] as int?;
|
||||
final moneroTransactionPriority = data[PreferencesKey.moneroTransactionPriority] as int?;
|
||||
final bitcoinTransactionPriority = data[PreferencesKey.bitcoinTransactionPriority] as int?;
|
||||
final selectedCake2FAPreset = data[PreferencesKey.selectedCake2FAPreset] as int?;
|
||||
final shouldRequireTOTP2FAForAccessingWallet =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForAccessingWallet] as bool?;
|
||||
final shouldRequireTOTP2FAForSendsToContact =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForSendsToContact] as bool?;
|
||||
final shouldRequireTOTP2FAForSendsToNonContact =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForSendsToNonContact] as bool?;
|
||||
final shouldRequireTOTP2FAForSendsToInternalWallets =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForSendsToInternalWallets] as bool?;
|
||||
final shouldRequireTOTP2FAForExchangesToInternalWallets =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForExchangesToInternalWallets] as bool?;
|
||||
final shouldRequireTOTP2FAForAddingContacts =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForAddingContacts] as bool?;
|
||||
final shouldRequireTOTP2FAForCreatingNewWallets =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForCreatingNewWallets] as bool?;
|
||||
final shouldRequireTOTP2FAForAllSecurityAndBackupSettings =
|
||||
data[PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings] as bool?;
|
||||
final sortBalanceTokensBy = data[PreferencesKey.sortBalanceBy] as int?;
|
||||
final pinNativeTokenAtTop = data[PreferencesKey.pinNativeTokenAtTop] as bool?;
|
||||
final useEtherscan = data[PreferencesKey.useEtherscan] as bool?;
|
||||
@@ -294,14 +275,7 @@ class BackupService {
|
||||
if (currentTransactionPriorityKeyLegacy != null)
|
||||
await _sharedPreferences.setInt(
|
||||
PreferencesKey.currentTransactionPriorityKeyLegacy, currentTransactionPriorityKeyLegacy);
|
||||
|
||||
if (DeviceInfo.instance.isDesktop) {
|
||||
await _sharedPreferences.setBool(PreferencesKey.allowBiometricalAuthenticationKey, false);
|
||||
} else if (allowBiometricalAuthentication != null) {
|
||||
await _sharedPreferences.setBool(
|
||||
PreferencesKey.allowBiometricalAuthenticationKey, allowBiometricalAuthentication);
|
||||
}
|
||||
|
||||
|
||||
if (currentBitcoinElectrumSererId != null)
|
||||
await _sharedPreferences.setInt(
|
||||
PreferencesKey.currentBitcoinElectrumSererIdKey, currentBitcoinElectrumSererId);
|
||||
@@ -344,43 +318,6 @@ class BackupService {
|
||||
await _sharedPreferences.setInt(
|
||||
PreferencesKey.bitcoinTransactionPriority, bitcoinTransactionPriority);
|
||||
|
||||
if (selectedCake2FAPreset != null)
|
||||
await _sharedPreferences.setInt(PreferencesKey.selectedCake2FAPreset, selectedCake2FAPreset);
|
||||
|
||||
if (shouldRequireTOTP2FAForAccessingWallet != null)
|
||||
await _sharedPreferences.setBool(PreferencesKey.shouldRequireTOTP2FAForAccessingWallet,
|
||||
shouldRequireTOTP2FAForAccessingWallet);
|
||||
|
||||
if (shouldRequireTOTP2FAForSendsToContact != null)
|
||||
await _sharedPreferences.setBool(PreferencesKey.shouldRequireTOTP2FAForSendsToContact,
|
||||
shouldRequireTOTP2FAForSendsToContact);
|
||||
|
||||
if (shouldRequireTOTP2FAForSendsToNonContact != null)
|
||||
await _sharedPreferences.setBool(PreferencesKey.shouldRequireTOTP2FAForSendsToNonContact,
|
||||
shouldRequireTOTP2FAForSendsToNonContact);
|
||||
|
||||
if (shouldRequireTOTP2FAForSendsToInternalWallets != null)
|
||||
await _sharedPreferences.setBool(PreferencesKey.shouldRequireTOTP2FAForSendsToInternalWallets,
|
||||
shouldRequireTOTP2FAForSendsToInternalWallets);
|
||||
|
||||
if (shouldRequireTOTP2FAForExchangesToInternalWallets != null)
|
||||
await _sharedPreferences.setBool(
|
||||
PreferencesKey.shouldRequireTOTP2FAForExchangesToInternalWallets,
|
||||
shouldRequireTOTP2FAForExchangesToInternalWallets);
|
||||
|
||||
if (shouldRequireTOTP2FAForAddingContacts != null)
|
||||
await _sharedPreferences.setBool(PreferencesKey.shouldRequireTOTP2FAForAddingContacts,
|
||||
shouldRequireTOTP2FAForAddingContacts);
|
||||
|
||||
if (shouldRequireTOTP2FAForCreatingNewWallets != null)
|
||||
await _sharedPreferences.setBool(PreferencesKey.shouldRequireTOTP2FAForCreatingNewWallets,
|
||||
shouldRequireTOTP2FAForCreatingNewWallets);
|
||||
|
||||
if (shouldRequireTOTP2FAForAllSecurityAndBackupSettings != null)
|
||||
await _sharedPreferences.setBool(
|
||||
PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
||||
shouldRequireTOTP2FAForAllSecurityAndBackupSettings);
|
||||
|
||||
if (sortBalanceTokensBy != null)
|
||||
await _sharedPreferences.setInt(PreferencesKey.sortBalanceBy, sortBalanceTokensBy);
|
||||
|
||||
@@ -532,8 +469,6 @@ class BackupService {
|
||||
PreferencesKey.currentPinLength: _sharedPreferences.getInt(PreferencesKey.currentPinLength),
|
||||
PreferencesKey.currentTransactionPriorityKeyLegacy:
|
||||
_sharedPreferences.getInt(PreferencesKey.currentTransactionPriorityKeyLegacy),
|
||||
PreferencesKey.allowBiometricalAuthenticationKey:
|
||||
_sharedPreferences.getBool(PreferencesKey.allowBiometricalAuthenticationKey),
|
||||
PreferencesKey.currentBitcoinElectrumSererIdKey:
|
||||
_sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey),
|
||||
PreferencesKey.currentLanguageCode:
|
||||
@@ -550,24 +485,6 @@ class BackupService {
|
||||
_sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority),
|
||||
PreferencesKey.currentFiatApiModeKey:
|
||||
_sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey),
|
||||
PreferencesKey.selectedCake2FAPreset:
|
||||
_sharedPreferences.getInt(PreferencesKey.selectedCake2FAPreset),
|
||||
PreferencesKey.shouldRequireTOTP2FAForAccessingWallet:
|
||||
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForAccessingWallet),
|
||||
PreferencesKey.shouldRequireTOTP2FAForSendsToContact:
|
||||
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForSendsToContact),
|
||||
PreferencesKey.shouldRequireTOTP2FAForSendsToNonContact:
|
||||
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForSendsToNonContact),
|
||||
PreferencesKey.shouldRequireTOTP2FAForSendsToInternalWallets:
|
||||
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForSendsToInternalWallets),
|
||||
PreferencesKey.shouldRequireTOTP2FAForExchangesToInternalWallets: _sharedPreferences
|
||||
.getBool(PreferencesKey.shouldRequireTOTP2FAForExchangesToInternalWallets),
|
||||
PreferencesKey.shouldRequireTOTP2FAForAddingContacts:
|
||||
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForAddingContacts),
|
||||
PreferencesKey.shouldRequireTOTP2FAForCreatingNewWallets:
|
||||
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForCreatingNewWallets),
|
||||
PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings: _sharedPreferences
|
||||
.getBool(PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings),
|
||||
PreferencesKey.sortBalanceBy: _sharedPreferences.getInt(PreferencesKey.sortBalanceBy),
|
||||
PreferencesKey.pinNativeTokenAtTop:
|
||||
_sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop),
|
||||
|
||||
Reference in New Issue
Block a user