mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-24 08:09:19 +00:00
Merge branch 'main' into CW-492-moonpay
This commit is contained in:
commit
2462806fb4
5 changed files with 70 additions and 57 deletions
|
@ -38,6 +38,9 @@ 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
|
||||||
|
// we delete what's there first:
|
||||||
|
await secureStorage.delete(key: key);
|
||||||
await secureStorage.write(key: key, value: encodedPassword);
|
await secureStorage.write(key: key, value: encodedPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +107,7 @@ class AuthService with Store {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Navigator.of(context).pushNamed(Routes.auth,
|
Navigator.of(context).pushNamed(Routes.auth,
|
||||||
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) async {
|
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) async {
|
||||||
|
@ -140,8 +142,6 @@ class AuthService with Store {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/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';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
@ -254,7 +255,8 @@ class BackupService {
|
||||||
final lookupsENS = data[PreferencesKey.lookupsENS] as bool?;
|
final lookupsENS = data[PreferencesKey.lookupsENS] as bool?;
|
||||||
final syncAll = data[PreferencesKey.syncAllKey] as bool?;
|
final syncAll = data[PreferencesKey.syncAllKey] as bool?;
|
||||||
final syncMode = data[PreferencesKey.syncModeKey] as int?;
|
final syncMode = data[PreferencesKey.syncModeKey] as int?;
|
||||||
final autoGenerateSubaddressStatus = data[PreferencesKey.autoGenerateSubaddressStatusKey] as int?;
|
final autoGenerateSubaddressStatus =
|
||||||
|
data[PreferencesKey.autoGenerateSubaddressStatusKey] as int?;
|
||||||
|
|
||||||
await _sharedPreferences.setString(PreferencesKey.currentWalletName, currentWalletName);
|
await _sharedPreferences.setString(PreferencesKey.currentWalletName, currentWalletName);
|
||||||
|
|
||||||
|
@ -291,9 +293,12 @@ class BackupService {
|
||||||
await _sharedPreferences.setInt(
|
await _sharedPreferences.setInt(
|
||||||
PreferencesKey.currentTransactionPriorityKeyLegacy, currentTransactionPriorityKeyLegacy);
|
PreferencesKey.currentTransactionPriorityKeyLegacy, currentTransactionPriorityKeyLegacy);
|
||||||
|
|
||||||
if (allowBiometricalAuthentication != null && !Platform.isMacOS && !Platform.isLinux)
|
if (Platform.isMacOS || Platform.isLinux) {
|
||||||
|
await _sharedPreferences.setBool(PreferencesKey.allowBiometricalAuthenticationKey, false);
|
||||||
|
} else if (allowBiometricalAuthentication != null) {
|
||||||
await _sharedPreferences.setBool(
|
await _sharedPreferences.setBool(
|
||||||
PreferencesKey.allowBiometricalAuthenticationKey, allowBiometricalAuthentication);
|
PreferencesKey.allowBiometricalAuthenticationKey, allowBiometricalAuthentication);
|
||||||
|
}
|
||||||
|
|
||||||
if (currentBitcoinElectrumSererId != null)
|
if (currentBitcoinElectrumSererId != null)
|
||||||
await _sharedPreferences.setInt(
|
await _sharedPreferences.setInt(
|
||||||
|
@ -309,14 +314,19 @@ class BackupService {
|
||||||
if (fiatApiMode != null)
|
if (fiatApiMode != null)
|
||||||
await _sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, fiatApiMode);
|
await _sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, fiatApiMode);
|
||||||
if (autoGenerateSubaddressStatus != null)
|
if (autoGenerateSubaddressStatus != null)
|
||||||
await _sharedPreferences.setInt(PreferencesKey.autoGenerateSubaddressStatusKey,
|
await _sharedPreferences.setInt(
|
||||||
autoGenerateSubaddressStatus);
|
PreferencesKey.autoGenerateSubaddressStatusKey, autoGenerateSubaddressStatus);
|
||||||
|
|
||||||
if (currentPinLength != null)
|
if (currentPinLength != null)
|
||||||
await _sharedPreferences.setInt(PreferencesKey.currentPinLength, currentPinLength);
|
await _sharedPreferences.setInt(PreferencesKey.currentPinLength, currentPinLength);
|
||||||
|
|
||||||
if (currentTheme != null && DeviceInfo.instance.isMobile)
|
if (currentTheme != null && DeviceInfo.instance.isMobile) {
|
||||||
await _sharedPreferences.setInt(PreferencesKey.currentTheme, currentTheme);
|
await _sharedPreferences.setInt(PreferencesKey.currentTheme, currentTheme);
|
||||||
|
// enforce dark theme on desktop platforms until the design is ready:
|
||||||
|
} else if (DeviceInfo.instance.isDesktop) {
|
||||||
|
await _sharedPreferences.setInt(PreferencesKey.currentTheme, ThemeList.darkTheme.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (exchangeStatus != null)
|
if (exchangeStatus != null)
|
||||||
await _sharedPreferences.setInt(PreferencesKey.exchangeStatusKey, exchangeStatus);
|
await _sharedPreferences.setInt(PreferencesKey.exchangeStatusKey, exchangeStatus);
|
||||||
|
@ -389,19 +399,17 @@ class BackupService {
|
||||||
await _sharedPreferences.setBool(PreferencesKey.lookupsYatService, lookupsYatService);
|
await _sharedPreferences.setBool(PreferencesKey.lookupsYatService, lookupsYatService);
|
||||||
|
|
||||||
if (lookupsUnstoppableDomains != null)
|
if (lookupsUnstoppableDomains != null)
|
||||||
await _sharedPreferences.setBool(PreferencesKey.lookupsUnstoppableDomains, lookupsUnstoppableDomains);
|
await _sharedPreferences.setBool(
|
||||||
|
PreferencesKey.lookupsUnstoppableDomains, lookupsUnstoppableDomains);
|
||||||
|
|
||||||
if (lookupsOpenAlias != null)
|
if (lookupsOpenAlias != null)
|
||||||
await _sharedPreferences.setBool(PreferencesKey.lookupsOpenAlias, lookupsOpenAlias);
|
await _sharedPreferences.setBool(PreferencesKey.lookupsOpenAlias, lookupsOpenAlias);
|
||||||
|
|
||||||
if (lookupsENS != null)
|
if (lookupsENS != null) await _sharedPreferences.setBool(PreferencesKey.lookupsENS, lookupsENS);
|
||||||
await _sharedPreferences.setBool(PreferencesKey.lookupsENS, lookupsENS);
|
|
||||||
|
|
||||||
if (syncAll != null)
|
if (syncAll != null) await _sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
|
||||||
await _sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
|
|
||||||
|
|
||||||
if (syncMode != null)
|
if (syncMode != null) await _sharedPreferences.setInt(PreferencesKey.syncModeKey, syncMode);
|
||||||
await _sharedPreferences.setInt(PreferencesKey.syncModeKey, syncMode);
|
|
||||||
|
|
||||||
await preferencesFile.delete();
|
await preferencesFile.delete();
|
||||||
}
|
}
|
||||||
|
@ -505,7 +513,8 @@ class BackupService {
|
||||||
_sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey),
|
_sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey),
|
||||||
PreferencesKey.disableBuyKey: _sharedPreferences.getBool(PreferencesKey.disableBuyKey),
|
PreferencesKey.disableBuyKey: _sharedPreferences.getBool(PreferencesKey.disableBuyKey),
|
||||||
PreferencesKey.disableSellKey: _sharedPreferences.getBool(PreferencesKey.disableSellKey),
|
PreferencesKey.disableSellKey: _sharedPreferences.getBool(PreferencesKey.disableSellKey),
|
||||||
PreferencesKey.defaultBuyProvider: _sharedPreferences.getInt(PreferencesKey.defaultBuyProvider),
|
PreferencesKey.defaultBuyProvider:
|
||||||
|
_sharedPreferences.getInt(PreferencesKey.defaultBuyProvider),
|
||||||
PreferencesKey.isDarkThemeLegacy:
|
PreferencesKey.isDarkThemeLegacy:
|
||||||
_sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy),
|
_sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy),
|
||||||
PreferencesKey.currentPinLength: _sharedPreferences.getInt(PreferencesKey.currentPinLength),
|
PreferencesKey.currentPinLength: _sharedPreferences.getInt(PreferencesKey.currentPinLength),
|
||||||
|
@ -547,28 +556,20 @@ class BackupService {
|
||||||
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForCreatingNewWallets),
|
_sharedPreferences.getBool(PreferencesKey.shouldRequireTOTP2FAForCreatingNewWallets),
|
||||||
PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings: _sharedPreferences
|
PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings: _sharedPreferences
|
||||||
.getBool(PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings),
|
.getBool(PreferencesKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings),
|
||||||
PreferencesKey.sortBalanceBy:
|
PreferencesKey.sortBalanceBy: _sharedPreferences.getInt(PreferencesKey.sortBalanceBy),
|
||||||
_sharedPreferences.getInt(PreferencesKey.sortBalanceBy),
|
|
||||||
PreferencesKey.pinNativeTokenAtTop:
|
PreferencesKey.pinNativeTokenAtTop:
|
||||||
_sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop),
|
_sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop),
|
||||||
PreferencesKey.useEtherscan:
|
PreferencesKey.useEtherscan: _sharedPreferences.getBool(PreferencesKey.useEtherscan),
|
||||||
_sharedPreferences.getBool(PreferencesKey.useEtherscan),
|
PreferencesKey.lookupsTwitter: _sharedPreferences.getBool(PreferencesKey.lookupsTwitter),
|
||||||
PreferencesKey.lookupsTwitter:
|
PreferencesKey.lookupsMastodon: _sharedPreferences.getBool(PreferencesKey.lookupsMastodon),
|
||||||
_sharedPreferences.getBool(PreferencesKey.lookupsTwitter),
|
|
||||||
PreferencesKey.lookupsMastodon:
|
|
||||||
_sharedPreferences.getBool(PreferencesKey.lookupsMastodon),
|
|
||||||
PreferencesKey.lookupsYatService:
|
PreferencesKey.lookupsYatService:
|
||||||
_sharedPreferences.getBool(PreferencesKey.lookupsYatService),
|
_sharedPreferences.getBool(PreferencesKey.lookupsYatService),
|
||||||
PreferencesKey.lookupsUnstoppableDomains:
|
PreferencesKey.lookupsUnstoppableDomains:
|
||||||
_sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains),
|
_sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains),
|
||||||
PreferencesKey.lookupsOpenAlias:
|
PreferencesKey.lookupsOpenAlias: _sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias),
|
||||||
_sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias),
|
PreferencesKey.lookupsENS: _sharedPreferences.getBool(PreferencesKey.lookupsENS),
|
||||||
PreferencesKey.lookupsENS:
|
PreferencesKey.syncModeKey: _sharedPreferences.getInt(PreferencesKey.syncModeKey),
|
||||||
_sharedPreferences.getBool(PreferencesKey.lookupsENS),
|
PreferencesKey.syncAllKey: _sharedPreferences.getBool(PreferencesKey.syncAllKey),
|
||||||
PreferencesKey.syncModeKey:
|
|
||||||
_sharedPreferences.getInt(PreferencesKey.syncModeKey),
|
|
||||||
PreferencesKey.syncAllKey:
|
|
||||||
_sharedPreferences.getBool(PreferencesKey.syncAllKey),
|
|
||||||
PreferencesKey.autoGenerateSubaddressStatusKey:
|
PreferencesKey.autoGenerateSubaddressStatusKey:
|
||||||
_sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey),
|
_sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey),
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,18 +2,18 @@ import 'package:encrypt/encrypt.dart';
|
||||||
// import 'package:password/password.dart';
|
// import 'package:password/password.dart';
|
||||||
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
||||||
|
|
||||||
String encrypt({required String source, required String key, int keyLength = 16}) {
|
String encrypt({required String source, required String key}) {
|
||||||
final _key = Key.fromUtf8(key);
|
final _key = Key.fromUtf8(key);
|
||||||
final iv = IV.fromLength(keyLength);
|
final iv = IV.allZerosOfLength(16);
|
||||||
final encrypter = Encrypter(AES(_key));
|
final encrypter = Encrypter(AES(_key));
|
||||||
final encrypted = encrypter.encrypt(source, iv: iv);
|
final encrypted = encrypter.encrypt(source, iv: iv);
|
||||||
|
|
||||||
return encrypted.base64;
|
return encrypted.base64;
|
||||||
}
|
}
|
||||||
|
|
||||||
String decrypt({required String source, required String key, int keyLength = 16}) {
|
String decrypt({required String source, required String key}) {
|
||||||
final _key = Key.fromUtf8(key);
|
final _key = Key.fromUtf8(key);
|
||||||
final iv = IV.fromLength(keyLength);
|
final iv = IV.allZerosOfLength(16);
|
||||||
final encrypter = Encrypter(AES(_key));
|
final encrypter = Encrypter(AES(_key));
|
||||||
final decrypted = encrypter.decrypt64(source, iv: iv);
|
final decrypted = encrypter.decrypt64(source, iv: iv);
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,9 @@ class WalletRestorePage extends BasePage {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 20, bottom: 24, left: 24, right: 24),
|
padding: EdgeInsets.only(top: 20, bottom: 24, left: 24, right: 24),
|
||||||
child: Observer(
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Observer(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return LoadingPrimaryButton(
|
return LoadingPrimaryButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
@ -214,6 +216,16 @@ class WalletRestorePage extends BasePage {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.advancedPrivacySettings, arguments: walletRestoreViewModel.type);
|
||||||
|
},
|
||||||
|
child: Text(S.of(context).advanced_privacy_settings),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -49,7 +49,7 @@ dependencies:
|
||||||
lottie: ^1.3.0
|
lottie: ^1.3.0
|
||||||
animate_do: ^2.1.0
|
animate_do: ^2.1.0
|
||||||
cupertino_icons: ^1.0.5
|
cupertino_icons: ^1.0.5
|
||||||
encrypt: 5.0.1
|
encrypt: 5.0.2
|
||||||
crypto: ^3.0.2
|
crypto: ^3.0.2
|
||||||
# password: ^1.0.0
|
# password: ^1.0.0
|
||||||
basic_utils: ^5.6.1
|
basic_utils: ^5.6.1
|
||||||
|
|
Loading…
Reference in a new issue