DEL: Remove package

This commit is contained in:
Marcos Rodriguez Velez 2024-06-03 21:27:21 -04:00
parent 9b6434715e
commit fc4dddd1df
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
13 changed files with 102 additions and 116 deletions

View File

@ -1,4 +1,4 @@
import { createNavigationContainerRef, NavigationAction, ParamListBase } from '@react-navigation/native';
import { createNavigationContainerRef, NavigationAction, ParamListBase, StackActions } from '@react-navigation/native';
export const navigationRef = createNavigationContainerRef<ParamListBase>();
@ -18,7 +18,13 @@ export function reset() {
if (navigationRef.isReady()) {
navigationRef.current?.reset({
index: 0,
routes: [{ name: 'UnlockWithScreenRoot' }],
routes: [{ name: 'UnlockWithScreen' }],
});
}
}
export function popToTop() {
if (navigationRef.isReady()) {
navigationRef.current?.dispatch(StackActions.popToTop());
}
}

View File

@ -6,7 +6,7 @@ import { ListItem } from 'react-native-elements';
import Share from 'react-native-share';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import confirm from '../../helpers/confirm';
import { useBiometrics } from '../../hooks/useBiometrics';
import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
import loc, { formatBalance } from '../../loc';
import { BitcoinUnit } from '../../models/bitcoinUnits';
import presentAlert from '../Alert';
@ -32,7 +32,7 @@ type NavigationProps = NativeStackNavigationProp<DetailViewStackParamList>;
const AddressItem = ({ item, balanceUnit, walletID, allowSignVerifyMessage }: AddressItemProps) => {
const { wallets } = useStorage();
const { colors } = useTheme();
const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics();
const { isBiometricUseCapableAndEnabled } = useBiometrics();
const hasTransactions = item.transactions > 0;

View File

@ -1,7 +1,6 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import { Alert, Platform } from 'react-native';
import ReactNativeBiometrics, { BiometryTypes as RNBiometryTypes } from 'react-native-biometrics';
import PasscodeAuth from 'react-native-passcode-auth';
import RNSecureKeyStore, { ACCESSIBLE } from 'react-native-secure-key-store';
import loc from '../loc';
import * as NavigationService from '../NavigationService';
@ -17,18 +16,18 @@ const Biometrics = 'Biometrics';
const clearKeychain = async () => {
try {
console.log('Wiping keychain');
console.log('Wiping key: data');
console.debug('Wiping keychain');
console.debug('Wiping key: data');
await RNSecureKeyStore.set('data', JSON.stringify({ data: { wallets: [] } }), {
accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
});
console.log('Wiped key: data');
console.log('Wiping key: data_encrypted');
console.debug('Wiped key: data');
console.debug('Wiping key: data_encrypted');
await RNSecureKeyStore.set('data_encrypted', '', { accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY });
console.log('Wiped key: data_encrypted');
console.log('Wiping key: STORAGEKEY');
console.debug('Wiped key: data_encrypted');
console.debug('Wiping key: STORAGEKEY');
await RNSecureKeyStore.set(STORAGEKEY, '', { accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY });
console.log('Wiped key: STORAGEKEY');
console.debug('Wiped key: STORAGEKEY');
NavigationService.reset();
} catch (error: any) {
console.warn(error);
@ -36,33 +35,34 @@ const clearKeychain = async () => {
}
};
const requestDevicePasscode = async () => {
let isDevicePasscodeSupported: boolean | undefined = false;
const unlockWithBiometrics = async () => {
try {
isDevicePasscodeSupported = await PasscodeAuth.isSupported();
if (isDevicePasscodeSupported) {
const isAuthenticated = await PasscodeAuth.authenticate();
if (isAuthenticated) {
Alert.alert(
loc.settings.encrypt_tstorage,
loc.settings.biom_remove_decrypt,
[
{ text: loc._.cancel, style: 'cancel' },
{
text: loc._.ok,
style: 'destructive',
onPress: async () => await clearKeychain(),
},
],
{ cancelable: false },
);
}
const { available } = await rnBiometrics.isSensorAvailable();
if (!available) {
return false;
}
} catch {
isDevicePasscodeSupported = undefined;
}
if (isDevicePasscodeSupported === false) {
presentAlert({ message: loc.settings.biom_no_passcode });
return new Promise<boolean>(resolve => {
rnBiometrics
.simplePrompt({ promptMessage: loc.settings.biom_conf_identity })
.then((result: { success: any }) => {
if (result.success) {
resolve(true);
} else {
console.debug('Biometrics authentication failed');
resolve(false);
}
})
.catch((error: Error) => {
console.debug('Biometrics authentication error');
presentAlert({ message: error.message });
resolve(false);
});
});
} catch (e: Error | any) {
console.debug('Biometrics authentication error', e);
presentAlert({ message: e.message });
return false;
}
};
@ -75,13 +75,35 @@ const showKeychainWipeAlert = () => {
{
text: loc._.cancel,
onPress: () => {
console.log('Cancel Pressed');
console.debug('Cancel Pressed');
},
style: 'cancel',
},
{
text: loc._.ok,
onPress: () => requestDevicePasscode(),
onPress: async () => {
const { available } = await rnBiometrics.isSensorAvailable();
if (!available) {
presentAlert({ message: loc.settings.biom_no_passcode });
return;
}
const isAuthenticated = await unlockWithBiometrics();
if (isAuthenticated) {
Alert.alert(
loc.settings.encrypt_tstorage,
loc.settings.biom_remove_decrypt,
[
{ text: loc._.cancel, style: 'cancel' },
{
text: loc._.ok,
style: 'destructive',
onPress: async () => await clearKeychain(),
},
],
{ cancelable: false },
);
}
},
style: 'default',
},
],
@ -108,19 +130,20 @@ const useBiometrics = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const isDeviceBiometricCapable = async () => {
const isDeviceBiometricCapable = useCallback(async () => {
try {
const { available } = await rnBiometrics.isSensorAvailable();
return available;
} catch (e) {
console.log('Biometrics isDeviceBiometricCapable failed');
console.log(e);
console.debug('Biometrics isDeviceBiometricCapable failed');
console.debug(e);
setBiometricUseEnabled(false);
}
return false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const type = async () => {
const type = useCallback(async () => {
try {
const { available, biometryType } = await rnBiometrics.isSensorAvailable();
if (!available) {
@ -129,55 +152,34 @@ const useBiometrics = () => {
return biometryType;
} catch (e) {
console.log('Biometrics biometricType failed');
console.log(e);
console.debug('Biometrics biometricType failed');
console.debug(e);
return undefined;
}
};
}, []);
const isBiometricUseEnabled = async () => {
const isBiometricUseEnabled = useCallback(async () => {
try {
const enabledBiometrics = await getItem(STORAGEKEY);
return !!enabledBiometrics;
} catch (_) {}
return false;
};
}, [getItem]);
const isBiometricUseCapableAndEnabled = async () => {
const isBiometricUseCapableAndEnabled = useCallback(async () => {
const isEnabled = await isBiometricUseEnabled();
const isCapable = await isDeviceBiometricCapable();
return isEnabled && isCapable;
};
}, [isBiometricUseEnabled, isDeviceBiometricCapable]);
const setBiometricUseEnabled = async (value: boolean) => {
await setItem(STORAGEKEY, value === true ? '1' : '');
setBiometricEnabled(value);
};
const unlockWithBiometrics = async () => {
const isCapable = await isDeviceBiometricCapable();
if (isCapable) {
return new Promise(resolve => {
rnBiometrics
.simplePrompt({ promptMessage: loc.settings.biom_conf_identity })
.then((result: { success: any }) => {
if (result.success) {
resolve(true);
} else {
console.log('Biometrics authentication failed');
resolve(false);
}
})
.catch((error: Error) => {
console.log('Biometrics authentication error');
presentAlert({ message: error.message });
resolve(false);
});
});
}
return false;
};
const setBiometricUseEnabled = useCallback(
async (value: boolean) => {
await setItem(STORAGEKEY, value === true ? '1' : '');
setBiometricEnabled(value);
},
[setItem],
);
return {
isDeviceBiometricCapable,
@ -185,11 +187,9 @@ const useBiometrics = () => {
isBiometricUseEnabled,
isBiometricUseCapableAndEnabled,
setBiometricUseEnabled,
unlockWithBiometrics,
clearKeychain,
requestDevicePasscode,
biometricEnabled,
};
};
export { FaceID, TouchID, Biometrics, RNBiometryTypes as BiometricType, useBiometrics, showKeychainWipeAlert };
export { FaceID, TouchID, Biometrics, RNBiometryTypes as BiometricType, useBiometrics, showKeychainWipeAlert, unlockWithBiometrics };

View File

@ -1,7 +1,7 @@
import { useNavigation, NavigationProp, ParamListBase } from '@react-navigation/native';
import { navigationRef } from '../NavigationService';
import { presentWalletExportReminder } from '../helpers/presentWalletExportReminder';
import { useBiometrics } from './useBiometrics';
import { unlockWithBiometrics, useBiometrics } from './useBiometrics';
import { useStorage } from './context/useStorage';
// List of screens that require biometrics
@ -13,7 +13,7 @@ const requiresWalletExportIsSaved = ['ReceiveDetailsRoot', 'WalletAddresses'];
export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>(): T => {
const originalNavigation = useNavigation<T>();
const { wallets, saveToDisk } = useStorage();
const { isBiometricUseEnabled, unlockWithBiometrics } = useBiometrics();
const { isBiometricUseEnabled } = useBiometrics();
const enhancedNavigate: NavigationProp<ParamListBase>['navigate'] = (screenOrOptions: any, params?: any) => {
let screenName: string;

View File

@ -24,8 +24,6 @@ PODS:
- lottie-react-native (6.7.2):
- lottie-ios (= 4.4.1)
- React-Core
- PasscodeAuth (1.0.0):
- React
- RCT-Folly (2021.07.22.00):
- boost
- DoubleConversion
@ -530,7 +528,6 @@ DEPENDENCIES:
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- libevent (~> 2.1.12)
- lottie-react-native (from `../node_modules/lottie-react-native`)
- PasscodeAuth (from `../node_modules/react-native-passcode-auth`)
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
@ -629,8 +626,6 @@ EXTERNAL SOURCES:
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
lottie-react-native:
:path: "../node_modules/lottie-react-native"
PasscodeAuth:
:path: "../node_modules/react-native-passcode-auth"
RCT-Folly:
:podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
RCTRequired:
@ -784,7 +779,6 @@ SPEC CHECKSUMS:
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
lottie-ios: e047b1d2e6239b787cc5e9755b988869cf190494
lottie-react-native: 17547b2f3c7034e2ae8672833fdb63262164d18a
PasscodeAuth: 3e88093ff46c31a952d8b36c488240de980517be
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: 264adaca1d8b1a9c078761891898d4142df05313
RCTTypeSafety: 279a89da7058a69899778a127be73fab38b84499

View File

@ -240,7 +240,7 @@
"biometrics_no_longer_available": "Your device settings have changed and no longer match the selected security settings in the app. Please re-enable biometrics or passcode, then restart the app to apply these changes.",
"biom_10times": "You have attempted to enter your password 10 times. Would you like to reset your storage? This will remove all wallets and decrypt your storage.",
"biom_conf_identity": "Please confirm your identity.",
"biom_no_passcode": "Your device does not have a passcode. In order to proceed, please configure a passcode in the Settings app.",
"biom_no_passcode": "Your device does not have a passcode or biometrics enabled. In order to proceed, please configure a passcode or biometric in the Settings app.",
"biom_remove_decrypt": "All your wallets will be removed and your storage will be decrypted. Are you sure you want to proceed?",
"currency": "Currency",
"currency_source": "Price is obtained from",

12
package-lock.json generated
View File

@ -79,7 +79,6 @@
"react-native-localize": "3.1.0",
"react-native-modal": "13.0.1",
"react-native-obscure": "https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb",
"react-native-passcode-auth": "https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
"react-native-permissions": "4.1.5",
"react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783",
"react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376",
@ -19775,12 +19774,6 @@
"react-native": "^0.60.5"
}
},
"node_modules/react-native-passcode-auth": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/BlueWallet/react-native-passcode-auth.git#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
"integrity": "sha512-8FL4NDMZZVrbHr1f4555dV+GY3PLpmSbJ1wIbdW1r6zSaFe59g9ns4sdLliisjO+RvyDJP7UDPDaeu+2iJ26Bg==",
"license": "ISC"
},
"node_modules/react-native-permissions": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-4.1.5.tgz",
@ -37528,11 +37521,6 @@
"integrity": "sha512-bmzbnlXII8hW7steqwouzQW9cJ+mdA8HJ8pWkb0KD60jC5dYgJ0e66wgUiSTDNFPrvlEKriE4eEanoJFj7Q9pg==",
"from": "react-native-obscure@https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb"
},
"react-native-passcode-auth": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-passcode-auth.git#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
"integrity": "sha512-8FL4NDMZZVrbHr1f4555dV+GY3PLpmSbJ1wIbdW1r6zSaFe59g9ns4sdLliisjO+RvyDJP7UDPDaeu+2iJ26Bg==",
"from": "react-native-passcode-auth@https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12"
},
"react-native-permissions": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-4.1.5.tgz",

View File

@ -164,7 +164,6 @@
"react-native-localize": "3.1.0",
"react-native-modal": "13.0.1",
"react-native-obscure": "https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb",
"react-native-passcode-auth": "https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
"react-native-permissions": "4.1.5",
"react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783",
"react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376",

View File

@ -4,7 +4,7 @@ import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapt
import { BlueTextCentered } from '../BlueComponents';
import Button from '../components/Button';
import SafeArea from '../components/SafeArea';
import { BiometricType, useBiometrics } from '../hooks/useBiometrics';
import { BiometricType, unlockWithBiometrics, useBiometrics } from '../hooks/useBiometrics';
import loc from '../loc';
import { useStorage } from '../hooks/context/useStorage';
@ -53,7 +53,7 @@ const UnlockWith: React.FC = () => {
const [state, dispatch] = useReducer(reducer, initialState);
const isUnlockingWallets = useRef(false);
const { setWalletsInitialized, isStorageEncrypted, startAndDecrypt } = useStorage();
const { deviceBiometricType, unlockWithBiometrics, isBiometricUseCapableAndEnabled, isBiometricUseEnabled } = useBiometrics();
const { deviceBiometricType, isBiometricUseCapableAndEnabled, isBiometricUseEnabled } = useBiometrics();
useEffect(() => {
setWalletsInitialized(false);

View File

@ -14,7 +14,7 @@ import { ArrowPicker } from '../../components/ArrowPicker';
import Button from '../../components/Button';
import SafeArea from '../../components/SafeArea';
import { useTheme } from '../../components/themes';
import { useBiometrics } from '../../hooks/useBiometrics';
import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
import loc from '../../loc';
import { BitcoinUnit } from '../../models/bitcoinUnits';
import { useStorage } from '../../hooks/context/useStorage';
@ -34,7 +34,7 @@ type LdkOpenChannelProps = RouteProp<
const LdkOpenChannel = (props: any) => {
const { wallets, fetchAndSaveWalletTransactions } = useStorage();
const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics();
const { isBiometricUseCapableAndEnabled } = useBiometrics();
const { colors }: { colors: any } = useTheme();
const { navigate, setParams } = useNavigation();
const {

View File

@ -16,7 +16,7 @@ import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/h
import SafeArea from '../../components/SafeArea';
import { satoshiToBTC, satoshiToLocalCurrency } from '../../blue_modules/currency';
import * as BlueElectrum from '../../blue_modules/BlueElectrum';
import { useBiometrics } from '../../hooks/useBiometrics';
import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
import { TWallet, CreateTransactionTarget } from '../../class/wallets/types';
import PayjoinTransaction from '../../class/payjoin-transaction';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
@ -66,7 +66,7 @@ type ConfirmNavigationProp = NativeStackNavigationProp<SendDetailsStackParamList
const Confirm: React.FC = () => {
const { wallets, fetchAndSaveWalletTransactions, counterpartyMetadata, isElectrumDisabled } = useStorage();
const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics();
const { isBiometricUseCapableAndEnabled } = useBiometrics();
const navigation = useExtendedNavigation<ConfirmNavigationProp>();
const route = useRoute<ConfirmRouteProp>(); // Get the route and its params
const { recipients, targets, walletID, fee, memo, tx, satoshiPerByte, psbt, payjoinUrl } = route.params; // Destructure params
@ -148,7 +148,6 @@ const Confirm: React.FC = () => {
satoshiPerByte,
wallet,
feeSatoshi,
unlockWithBiometrics,
],
);

View File

@ -8,7 +8,7 @@ import presentAlert from '../../components/Alert';
import ListItem from '../../components/ListItem';
import { useTheme } from '../../components/themes';
import prompt from '../../helpers/prompt';
import { useBiometrics } from '../../hooks/useBiometrics';
import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
import loc from '../../loc';
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
import { useStorage } from '../../hooks/context/useStorage';
@ -56,7 +56,7 @@ const reducer = (state: State, action: Action): State => {
const EncryptStorage = () => {
const { isStorageEncrypted, encryptStorage, decryptStorage, saveToDisk } = useStorage();
const { isDeviceBiometricCapable, biometricEnabled, setBiometricUseEnabled, deviceBiometricType, unlockWithBiometrics } = useBiometrics();
const { isDeviceBiometricCapable, biometricEnabled, setBiometricUseEnabled, deviceBiometricType } = useBiometrics();
const [state, dispatch] = useReducer(reducer, initialState);
const { navigate, dispatch: navigationDispatch } = useExtendedNavigation();
const { colors } = useTheme();

View File

@ -44,7 +44,7 @@ import SquareEnumeratedWords, { SquareEnumeratedWordsContentAlign } from '../../
import { useTheme } from '../../components/themes';
import prompt from '../../helpers/prompt';
import { scanQrHelper } from '../../helpers/scan-qr';
import { useBiometrics } from '../../hooks/useBiometrics';
import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
import usePrivacy from '../../hooks/usePrivacy';
import loc from '../../loc';
@ -56,7 +56,7 @@ const ViewEditMultisigCosigners: React.FC = () => {
const hasLoaded = useRef(false);
const { colors } = useTheme();
const { wallets, setWalletsWithNewOrder, isElectrumDisabled } = useStorage();
const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics();
const { isBiometricUseCapableAndEnabled } = useBiometrics();
const { isAdvancedModeEnabled } = useSettings();
const { navigate, dispatch, addListener } = useExtendedNavigation();
const openScannerButtonRef = useRef();