mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-18 21:35:21 +01:00
DEL: Reset keychain after uninstall
This commit is contained in:
parent
1fcf8b2e8a
commit
7d9f81b543
@ -133,8 +133,6 @@ export const BlueStorageProvider = ({ children }) => {
|
||||
const getHodlHodlApiKey = BlueApp.getHodlHodlApiKey;
|
||||
const createFakeStorage = BlueApp.createFakeStorage;
|
||||
const decryptStorage = BlueApp.decryptStorage;
|
||||
const isDeleteWalletAfterUninstallEnabled = BlueApp.isDeleteWalletAfterUninstallEnabled;
|
||||
const setResetOnAppUninstallTo = BlueApp.setResetOnAppUninstallTo;
|
||||
const isPasswordInUse = BlueApp.isPasswordInUse;
|
||||
const cachedPassword = BlueApp.cachedPassword;
|
||||
const setIsAdancedModeEnabled = BlueApp.setIsAdancedModeEnabled;
|
||||
@ -182,9 +180,7 @@ export const BlueStorageProvider = ({ children }) => {
|
||||
setNewWalletAdded,
|
||||
resetWallets,
|
||||
getHodlHodlApiKey,
|
||||
isDeleteWalletAfterUninstallEnabled,
|
||||
decryptStorage,
|
||||
setResetOnAppUninstallTo,
|
||||
isPasswordInUse,
|
||||
setIsAdancedModeEnabled,
|
||||
setPreferredFiatCurrency,
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
HDSegwitElectrumSeedP2WPKHWallet,
|
||||
MultisigHDWallet,
|
||||
} from './';
|
||||
import { Platform } from 'react-native';
|
||||
const encryption = require('../blue_modules/encryption');
|
||||
const Realm = require('realm');
|
||||
const createHash = require('create-hash');
|
||||
@ -33,7 +32,6 @@ export class AppStorage {
|
||||
static ELECTRUM_SERVER_HISTORY = 'electrum_server_history';
|
||||
static PREFERRED_CURRENCY = 'preferredCurrency';
|
||||
static ADVANCED_MODE_ENABLED = 'advancedmodeenabled';
|
||||
static DELETE_WALLET_AFTER_UNINSTALL = 'deleteWalletAfterUninstall';
|
||||
static HODL_HODL_API_KEY = 'HODL_HODL_API_KEY';
|
||||
static HODL_HODL_SIGNATURE_KEY = 'HODL_HODL_SIGNATURE_KEY';
|
||||
static HODL_HODL_CONTRACTS = 'HODL_HODL_CONTRACTS';
|
||||
@ -76,16 +74,6 @@ export class AppStorage {
|
||||
}
|
||||
};
|
||||
|
||||
setResetOnAppUninstallTo = async value => {
|
||||
if (Platform.OS === 'ios') {
|
||||
await this.setItem(AppStorage.DELETE_WALLET_AFTER_UNINSTALL, value ? '1' : '');
|
||||
try {
|
||||
RNSecureKeyStore.setResetOnAppUninstallTo(value);
|
||||
} catch (Error) {
|
||||
console.warn(Error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
storageIsEncrypted = async () => {
|
||||
let data;
|
||||
@ -140,7 +128,6 @@ export class AppStorage {
|
||||
decryptStorage = async password => {
|
||||
if (password === this.cachedPassword) {
|
||||
this.cachedPassword = undefined;
|
||||
await this.setResetOnAppUninstallTo(true);
|
||||
await this.saveToDisk();
|
||||
this.wallets = [];
|
||||
this.tx_metadata = [];
|
||||
@ -150,16 +137,6 @@ export class AppStorage {
|
||||
}
|
||||
};
|
||||
|
||||
isDeleteWalletAfterUninstallEnabled = async () => {
|
||||
let deleteWalletsAfterUninstall;
|
||||
try {
|
||||
deleteWalletsAfterUninstall = await this.getItem(AppStorage.DELETE_WALLET_AFTER_UNINSTALL);
|
||||
} catch (_e) {
|
||||
deleteWalletsAfterUninstall = true;
|
||||
}
|
||||
return !!deleteWalletsAfterUninstall;
|
||||
};
|
||||
|
||||
encryptStorage = async password => {
|
||||
// assuming the storage is not yet encrypted
|
||||
await this.saveToDisk();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* global alert */
|
||||
import React, { useEffect, useState, useCallback, useContext } from 'react';
|
||||
import { ScrollView, Alert, Platform, TouchableOpacity, TouchableWithoutFeedback, StyleSheet } from 'react-native';
|
||||
import { ScrollView, Alert, TouchableOpacity, TouchableWithoutFeedback, StyleSheet } from 'react-native';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
||||
import { colors } from 'react-native-elements';
|
||||
@ -10,20 +10,11 @@ import { BlueLoading, SafeBlueArea, BlueSpacing20, BlueCard, BlueListItem, BlueH
|
||||
import Biometric from '../../class/biometrics';
|
||||
import loc from '../../loc';
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
import { isCatalyst } from '../../blue_modules/environment';
|
||||
const prompt = require('../../blue_modules/prompt');
|
||||
|
||||
const EncryptStorage = () => {
|
||||
const {
|
||||
isStorageEncrypted,
|
||||
setResetOnAppUninstallTo,
|
||||
encryptStorage,
|
||||
isDeleteWalletAfterUninstallEnabled,
|
||||
decryptStorage,
|
||||
saveToDisk,
|
||||
} = useContext(BlueStorageContext);
|
||||
const { isStorageEncrypted, encryptStorage, decryptStorage, saveToDisk } = useContext(BlueStorageContext);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteWalletsAfterUninstall, setDeleteWalletsAfterUninstall] = useState(false);
|
||||
const [biometrics, setBiometrics] = useState({ isDeviceBiometricCapable: false, isBiometricsEnabled: false, biometricsType: '' });
|
||||
const [storageIsEncryptedSwitchEnabled, setStorageIsEncryptedSwitchEnabled] = useState(false);
|
||||
const { navigate, popToTop } = useNavigation();
|
||||
@ -38,10 +29,8 @@ const EncryptStorage = () => {
|
||||
const isBiometricsEnabled = await Biometric.isBiometricUseEnabled();
|
||||
const isDeviceBiometricCapable = await Biometric.isDeviceBiometricCapable();
|
||||
const biometricsType = (await Biometric.biometricType()) || loc.settings.biometrics;
|
||||
const deleteWalletsAfterUninstall = await isDeleteWalletAfterUninstallEnabled();
|
||||
const isStorageEncryptedSwitchEnabled = await isStorageEncrypted();
|
||||
setStorageIsEncryptedSwitchEnabled(isStorageEncryptedSwitchEnabled);
|
||||
setDeleteWalletsAfterUninstall(deleteWalletsAfterUninstall);
|
||||
setBiometrics({ isBiometricsEnabled, isDeviceBiometricCapable, biometricsType });
|
||||
setIsLoading(false);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@ -67,17 +56,10 @@ const EncryptStorage = () => {
|
||||
|
||||
setIsLoading(false);
|
||||
setStorageIsEncryptedSwitchEnabled(await isStorageEncrypted());
|
||||
setDeleteWalletsAfterUninstall(await isDeleteWalletAfterUninstallEnabled());
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
};
|
||||
|
||||
const onDeleteWalletsAfterUninstallSwitch = async value => {
|
||||
await setResetOnAppUninstallTo(value);
|
||||
setDeleteWalletsAfterUninstall(value);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
};
|
||||
|
||||
const onEncryptStorageSwitch = async value => {
|
||||
setIsLoading(true);
|
||||
if (value === true) {
|
||||
@ -170,17 +152,6 @@ const EncryptStorage = () => {
|
||||
Component={TouchableWithoutFeedback}
|
||||
switch={{ onValueChange: onEncryptStorageSwitch, value: storageIsEncryptedSwitchEnabled }}
|
||||
/>
|
||||
{Platform.OS === 'ios' && !isCatalyst && (
|
||||
<BlueListItem
|
||||
hideChevron
|
||||
title={loc.settings.encrypt_del_uninstall}
|
||||
Component={TouchableWithoutFeedback}
|
||||
switch={{
|
||||
onValueChange: onDeleteWalletsAfterUninstallSwitch,
|
||||
value: deleteWalletsAfterUninstall,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{storageIsEncryptedSwitchEnabled && (
|
||||
<BlueListItem
|
||||
onPress={navigateToPlausibleDeniability}
|
||||
|
@ -1,11 +1,6 @@
|
||||
import { AppStorage } from '../../class';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import RNFS from 'react-native-fs';
|
||||
import RNSecureKeyStore, { ACCESSIBLE } from 'react-native-secure-key-store';
|
||||
import DefaultPreference from 'react-native-default-preference';
|
||||
import { Platform } from 'react-native';
|
||||
import { isCatalyst } from '../../blue_modules/environment';
|
||||
|
||||
export default class WalletMigrate {
|
||||
static expoDataDirectory = RNFS.DocumentDirectoryPath + '/ExponentExperienceData/%40overtorment%2Fbluewallet/RCTAsyncLocalStorage';
|
||||
|
||||
@ -15,41 +10,6 @@ export default class WalletMigrate {
|
||||
|
||||
// 0: Let's start!
|
||||
async start() {
|
||||
if (Platform.OS === 'ios' && !isCatalyst) {
|
||||
const defaultPreferenceGroupName = await DefaultPreference.getName();
|
||||
console.log('----- defaultPreferenceGroupName');
|
||||
console.log(defaultPreferenceGroupName);
|
||||
console.log('----- ');
|
||||
const isNotFirstLaunch = await DefaultPreference.get('RnSksIsAppInstalled');
|
||||
console.log('----- isNotFirstLaunch');
|
||||
console.log(isNotFirstLaunch);
|
||||
console.log('----- ');
|
||||
if (isNotFirstLaunch === undefined) {
|
||||
try {
|
||||
console.warn('It is the first launch...');
|
||||
await RNSecureKeyStore.setResetOnAppUninstallTo(false);
|
||||
let deleteWalletsFromKeychain = '1';
|
||||
try {
|
||||
deleteWalletsFromKeychain = await RNSecureKeyStore.get(AppStorage.DELETE_WALLET_AFTER_UNINSTALL);
|
||||
await RNSecureKeyStore.setResetOnAppUninstallTo(deleteWalletsFromKeychain === '1');
|
||||
await RNSecureKeyStore.get(AppStorage.DELETE_WALLET_AFTER_UNINSTALL);
|
||||
} catch (e) {
|
||||
console.log('----- deleteWalletsFromKeychain catch');
|
||||
console.log(e.message);
|
||||
await RNSecureKeyStore.setResetOnAppUninstallTo(deleteWalletsFromKeychain === '1');
|
||||
await RNSecureKeyStore.get(AppStorage.DELETE_WALLET_AFTER_UNINSTALL);
|
||||
}
|
||||
console.log('----- deleteWalletsFromKeychain');
|
||||
console.log(deleteWalletsFromKeychain);
|
||||
console.log('----- ');
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
} else {
|
||||
console.warn('It is NOT the first launch...');
|
||||
}
|
||||
await DefaultPreference.set('RnSksIsAppInstalled', '1');
|
||||
}
|
||||
return this.migrateDataFromExpo();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user