Skip to content

Commit

Permalink
ADD: Password/Passcode/Apple Watch unlock for iOS and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosrdz authored and Overtorment committed Sep 17, 2020
1 parent 9f67733 commit 13a0d00
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
37 changes: 23 additions & 14 deletions class/biometrics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global alert */
import Biometrics from 'react-native-biometrics';
import FingerprintScanner from 'react-native-fingerprint-scanner';
import { Platform, Alert } from 'react-native';
import PasscodeAuth from 'react-native-passcode-auth';
import * as NavigationService from '../NavigationService';
Expand All @@ -10,13 +10,13 @@ const BlueApp = require('../BlueApp');

export default class Biometric {
static STORAGEKEY = 'Biometrics';
static FaceID = Biometrics.FaceID;
static TouchID = Biometrics.TouchID;
static Biometrics = Biometrics.Biometrics;
static FaceID = 'Face ID';
static TouchID = 'Touch ID';
static Biometrics = 'Biometrics';

static async isDeviceBiometricCapable() {
const isDeviceBiometricCapable = await Biometrics.isSensorAvailable();
if (isDeviceBiometricCapable.available) {
const isDeviceBiometricCapable = await FingerprintScanner.isSensorAvailable();
if (isDeviceBiometricCapable) {
return true;
}
Biometric.setBiometricUseEnabled(false);
Expand All @@ -25,8 +25,8 @@ export default class Biometric {

static async biometricType() {
try {
const isSensorAvailable = await Biometrics.isSensorAvailable();
return isSensorAvailable.biometryType;
const isSensorAvailable = await FingerprintScanner.isSensorAvailable();
return isSensorAvailable;
} catch (e) {
console.log(e);
}
Expand All @@ -46,6 +46,7 @@ export default class Biometric {
static async isBiometricUseCapableAndEnabled() {
const isBiometricUseEnabled = await Biometric.isBiometricUseEnabled();
const isDeviceBiometricCapable = await Biometric.isDeviceBiometricCapable();
console.warn(isBiometricUseEnabled && isDeviceBiometricCapable)
return isBiometricUseEnabled && isDeviceBiometricCapable;
}

Expand All @@ -57,8 +58,8 @@ export default class Biometric {
const isDeviceBiometricCapable = await Biometric.isDeviceBiometricCapable();
if (isDeviceBiometricCapable) {
try {
const isConfirmed = await Biometrics.simplePrompt({ promptMessage: 'Please confirm your identity.' });
return isConfirmed.success;
const isConfirmed = await FingerprintScanner.authenticate({ description: 'Please confirm your identity.', fallbackEnabled: true });
return isConfirmed;
} catch (_e) {
return false;
}
Expand Down Expand Up @@ -109,10 +110,18 @@ export default class Biometric {
'Storage',
`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.`,
[
{ text: loc._.cancel, onPress: () => {
NavigationService.dispatch(CommonActions.setParams({index: 0, routes: [
{ name: 'UnlockWithScreenRoot' }, { params: { unlockOnComponentMount: false }}]}));
}, style: 'cancel' },
{
text: loc._.cancel,
onPress: () => {
NavigationService.dispatch(
CommonActions.setParams({
index: 0,
routes: [{ name: 'UnlockWithScreenRoot' }, { params: { unlockOnComponentMount: false } }],
}),
);
},
style: 'cancel',
},
{
text: loc._.ok,
onPress: () => Biometric.requestDevicePasscode(),
Expand Down
12 changes: 6 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ PODS:
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- React-jsinspector (0.62.2)
- react-native-biometrics (2.0.0):
- React
- react-native-blue-crypto (1.0.0):
- React
- react-native-blur (0.8.0):
Expand All @@ -260,6 +258,8 @@ PODS:
- React
- react-native-document-picker (3.5.4):
- React
- react-native-fingerprint-scanner (6.0.0):
- React
- react-native-geolocation (2.0.2):
- React
- react-native-image-picker (2.3.3):
Expand Down Expand Up @@ -435,11 +435,11 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-biometrics (from `../node_modules/react-native-biometrics`)
- react-native-blue-crypto (from `../node_modules/react-native-blue-crypto`)
- "react-native-blur (from `../node_modules/@react-native-community/blur`)"
- react-native-camera (from `../node_modules/react-native-camera`)
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
- react-native-fingerprint-scanner (from `../node_modules/react-native-fingerprint-scanner`)
- "react-native-geolocation (from `../node_modules/@react-native-community/geolocation`)"
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- react-native-randombytes (from `../node_modules/react-native-randombytes`)
Expand Down Expand Up @@ -540,8 +540,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-biometrics:
:path: "../node_modules/react-native-biometrics"
react-native-blue-crypto:
:path: "../node_modules/react-native-blue-crypto"
react-native-blur:
Expand All @@ -550,6 +548,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-camera"
react-native-document-picker:
:path: "../node_modules/react-native-document-picker"
react-native-fingerprint-scanner:
:path: "../node_modules/react-native-fingerprint-scanner"
react-native-geolocation:
:path: "../node_modules/@react-native-community/geolocation"
react-native-image-picker:
Expand Down Expand Up @@ -670,11 +670,11 @@ SPEC CHECKSUMS:
React-jsi: b6dc94a6a12ff98e8877287a0b7620d365201161
React-jsiexecutor: 1540d1c01bb493ae3124ed83351b1b6a155db7da
React-jsinspector: 512e560d0e985d0e8c479a54a4e5c147a9c83493
react-native-biometrics: c892904948a32295b128f633bcc11eda020645c5
react-native-blue-crypto: 23f1558ad3d38d7a2edb7e2f6ed1bc520ed93e56
react-native-blur: cad4d93b364f91e7b7931b3fa935455487e5c33c
react-native-camera: 9a0db39fc97a479fe472e86ce424545478133a2f
react-native-document-picker: c5752781fbc0c126c627c1549b037c139444a4cf
react-native-fingerprint-scanner: c68136ca57e3704d7bdf5faa554ea535ce15b1d0
react-native-geolocation: cbd9d6bd06bac411eed2671810f454d4908484a8
react-native-image-picker: a6c3d644751a388b0fc8b56822ff7cbd398a3008
react-native-randombytes: 991545e6eaaf700b4ee384c291ef3d572e0b2ca8
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@
"react": "16.11.0",
"react-localization": "1.0.15",
"react-native": "0.62.2",
"react-native-biometrics": "git+https://github.com/BlueWallet/react-native-biometrics.git#f62b0b193e10376d4a0e8195c700a364ed4e5aaa",
"react-native-blue-crypto": "git+https://github.com/Overtorment/react-native-blue-crypto.git",
"react-native-camera": "3.38.0",
"react-native-default-preference": "1.4.3",
"react-native-device-info": "6.0.1",
"react-native-document-picker": "git+https://github.com/BlueWallet/react-native-document-picker.git#3684d4fcc2bc0b47c32be39024e4796004c3e428",
"react-native-elements": "2.2.1",
"react-native-fingerprint-scanner": "git+https://github.com/BlueWallet/react-native-fingerprint-scanner.git#5988a07c31e0600d187ec8a0593681dcdd6daa20",
"react-native-fs": "2.16.6",
"react-native-gesture-handler": "1.7.0",
"react-native-handoff": "git+https://github.com/marcosrdz/react-native-handoff.git",
Expand Down

0 comments on commit 13a0d00

Please sign in to comment.