mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-03 12:06:21 +01:00
FIX: Decouple RNSecureKeyStore from encryptStorage component.
This commit is contained in:
parent
78a6f1f525
commit
865e7dbe40
5 changed files with 27 additions and 23 deletions
|
@ -522,6 +522,7 @@ export class BlueListItem extends Component {
|
||||||
}}
|
}}
|
||||||
subtitleStyle={{ color: BlueApp.settings.alternativeTextColor }}
|
subtitleStyle={{ color: BlueApp.settings.alternativeTextColor }}
|
||||||
subtitleNumberOfLines={1}
|
subtitleNumberOfLines={1}
|
||||||
|
titleNumberOfLines={0}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,7 +23,7 @@ export class AppStorage {
|
||||||
static ELECTRUM_TCP_PORT = 'electrum_tcp_port';
|
static ELECTRUM_TCP_PORT = 'electrum_tcp_port';
|
||||||
static PREFERRED_CURRENCY = 'preferredCurrency';
|
static PREFERRED_CURRENCY = 'preferredCurrency';
|
||||||
static ADVANCED_MODE_ENABLED = 'advancedmodeenabled';
|
static ADVANCED_MODE_ENABLED = 'advancedmodeenabled';
|
||||||
|
static DELETEWALLETAFTERUNINSTALLKEY = 'deleteWalletAfterUninstall';
|
||||||
constructor() {
|
constructor() {
|
||||||
/** {Array.<AbstractWallet>} */
|
/** {Array.<AbstractWallet>} */
|
||||||
this.wallets = [];
|
this.wallets = [];
|
||||||
|
@ -88,6 +88,11 @@ export class AppStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setResetOnAppUninstallTo(value) {
|
||||||
|
await this.setItem('deleteWalletAfterUninstall', value === true ? '1' : '');
|
||||||
|
await RNSecureKeyStore.setResetOnAppUninstallTo(value);
|
||||||
|
}
|
||||||
|
|
||||||
async storageIsEncrypted() {
|
async storageIsEncrypted() {
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
|
@ -164,6 +169,16 @@ export class AppStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async isDeleteWalletAfterUninstallEnabled() {
|
||||||
|
let deleteWalletsAfterUninstall;
|
||||||
|
try {
|
||||||
|
deleteWalletsAfterUninstall = await this.getItem('deleteWalletAfterUninstall');
|
||||||
|
} catch (_e) {
|
||||||
|
deleteWalletsAfterUninstall = true;
|
||||||
|
}
|
||||||
|
return !!deleteWalletsAfterUninstall;
|
||||||
|
}
|
||||||
|
|
||||||
async encryptStorage(password) {
|
async encryptStorage(password) {
|
||||||
// assuming the storage is not yet encrypted
|
// assuming the storage is not yet encrypted
|
||||||
await this.saveToDisk();
|
await this.saveToDisk();
|
||||||
|
|
|
@ -14,7 +14,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
def sharedPods
|
def sharedPods
|
||||||
pod 'React', :path => '../node_modules/react-native/'
|
pod 'React', :path => '../node_modules/react-native/'
|
||||||
pod 'React-Core', :path => '../node_modules/react-native/React'
|
pod 'React-Core', :path => '../node_modules/react-native/React'
|
||||||
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
|
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
|
||||||
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
|
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
|
||||||
|
@ -72,7 +72,7 @@ target 'BlueWalletWatch Extension' do
|
||||||
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
|
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
|
||||||
# use_frameworks!
|
# use_frameworks!
|
||||||
platform :watchos, '5.1'
|
platform :watchos, '5.1'
|
||||||
pod 'EFQRCode', '~> 5.0.0'
|
pod 'EFQRCode', '5.0.0'
|
||||||
# Pods for BlueWalletWatch Extension
|
# Pods for BlueWalletWatch Extension
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ PODS:
|
||||||
- BVLinearGradient (2.5.4):
|
- BVLinearGradient (2.5.4):
|
||||||
- React
|
- React
|
||||||
- DoubleConversion (1.1.6)
|
- DoubleConversion (1.1.6)
|
||||||
- EFQRCode (5.0.0):
|
- EFQRCode (5.0.1):
|
||||||
- swift_qrcodejs (~> 1.1.1)
|
- swift_qrcodejs (~> 1.1.1)
|
||||||
- Folly (2018.10.22.00):
|
- Folly (2018.10.22.00):
|
||||||
- boost-for-react-native
|
- boost-for-react-native
|
||||||
|
@ -317,7 +317,7 @@ SPEC CHECKSUMS:
|
||||||
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
|
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
|
||||||
BVLinearGradient: 8cbc5155c978f2e43098818c91d206d07aae6d30
|
BVLinearGradient: 8cbc5155c978f2e43098818c91d206d07aae6d30
|
||||||
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
|
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
|
||||||
EFQRCode: 07437cfbce3a1e497397a4f3d766c980d8972608
|
EFQRCode: 239efec4dd406d9c635dd937525fc40960ce2e9f
|
||||||
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
|
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
|
||||||
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
|
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
|
||||||
RCTSystemSetting: 9279ff44c49bb4fb0a5d335a0851852c8f3eda99
|
RCTSystemSetting: 9279ff44c49bb4fb0a5d335a0851852c8f3eda99
|
||||||
|
|
|
@ -3,7 +3,6 @@ import React, { Component } from 'react';
|
||||||
import { View, Alert, Platform, TouchableOpacity } from 'react-native';
|
import { View, Alert, Platform, TouchableOpacity } from 'react-native';
|
||||||
import { BlueLoading, BlueHeaderDefaultSub, BlueListItem, SafeBlueArea, BlueNavigationStyle } from '../../BlueComponents';
|
import { BlueLoading, BlueHeaderDefaultSub, BlueListItem, SafeBlueArea, BlueNavigationStyle } from '../../BlueComponents';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import RNSecureKeyStore, { ACCESSIBLE } from 'react-native-secure-key-store';
|
|
||||||
import AsyncStorage from '@react-native-community/async-storage';
|
import AsyncStorage from '@react-native-community/async-storage';
|
||||||
import { AppStorage } from '../../class';
|
import { AppStorage } from '../../class';
|
||||||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
||||||
|
@ -18,30 +17,21 @@ export default class EncryptStorage extends Component {
|
||||||
title: loc.settings.security,
|
title: loc.settings.security,
|
||||||
});
|
});
|
||||||
|
|
||||||
static deleteWalletAfterUninstall = 'deleteWalletAfterUninstall';
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
language: loc.getLanguage(),
|
language: loc.getLanguage(),
|
||||||
|
deleteWalletsAfterUninstall: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
let deleteWalletsAfterUninstall = true;
|
|
||||||
try {
|
|
||||||
deleteWalletsAfterUninstall = await RNSecureKeyStore.get(EncryptStorage.deleteWalletAfterUninstall);
|
|
||||||
deleteWalletsAfterUninstall =
|
|
||||||
deleteWalletsAfterUninstall === true || deleteWalletsAfterUninstall === '1' || deleteWalletsAfterUninstall === 1;
|
|
||||||
} catch (_e) {
|
|
||||||
deleteWalletsAfterUninstall = true;
|
|
||||||
}
|
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
advancedModeEnabled: (await AsyncStorage.getItem(AppStorage.ADVANCED_MODE_ENABLED)) || false,
|
advancedModeEnabled: (await AsyncStorage.getItem(AppStorage.ADVANCED_MODE_ENABLED)) || false,
|
||||||
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
|
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
|
||||||
deleteWalletsAfterUninstall,
|
deleteWalletsAfterUninstall: await BlueApp.isDeleteWalletAfterUninstallEnabled(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,25 +44,23 @@ export default class EncryptStorage extends Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
|
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
|
||||||
deleteWalletAfterUninstall: await RNSecureKeyStore.get(EncryptStorage.deleteWalletAfterUninstall),
|
deleteWalletAfterUninstall: await BlueApp.isDeleteWalletAfterUninstallEnabled(),
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
|
||||||
if (password) {
|
if (password) {
|
||||||
alert(loc._.bad_password);
|
alert(loc._.bad_password);
|
||||||
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
|
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
|
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
|
||||||
deleteWalletAfterUninstall: await RNSecureKeyStore.get(EncryptStorage.deleteWalletAfterUninstall),
|
deleteWalletAfterUninstall: await BlueApp.isDeleteWalletAfterUninstallEnabled(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onDeleteWalletsAfterUninstallSwitch = async value => {
|
onDeleteWalletsAfterUninstallSwitch = async value => {
|
||||||
await RNSecureKeyStore.setResetOnAppUninstallTo(value);
|
await BlueApp.setResetOnAppUninstallTo(value);
|
||||||
await RNSecureKeyStore.set(EncryptStorage.deleteWalletAfterUninstall, value, { accessible: ACCESSIBLE.WHEN_UNLOCKED });
|
|
||||||
this.setState({ deleteWalletsAfterUninstall: value });
|
this.setState({ deleteWalletsAfterUninstall: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue