Skip to content

Commit

Permalink
Merge pull request #183 from SelfLender/release/2.2.0
Browse files Browse the repository at this point in the history
Release 2.2.0
  • Loading branch information
dgasch512 authored Jun 7, 2022
2 parents 33bbabd + b5a8b34 commit 7e1ff50
Show file tree
Hide file tree
Showing 11 changed files with 338 additions and 133 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.2.0] - 2020-02-10
## Changed
- iOS
+ Fixed compatability issue with XCode 12
+ Added optional passcode fallback for iOS devices when FaceID or TouchID fails and the device has a passcode set.
+ Added `fallbackPromptMessage` to `simplePrompt`. This controls the message that is shown when FaceID or TouchID has failed and the prompt falls back to the device passcode for authentication.
- Android
+ Upgraded androidx.biometric 1.1.0
* Added `allowDeviceCredentials` option, for android devices, to `isSensorAvailable`, `createSignature` and `simplePrompt`. This option is only affects devices running API 30 or greater. Devices running API 29 or less cannot support device credentials when performing crypto based authentication. See https://developer.android.com/reference/androidx/biometric/BiometricPrompt.PromptInfo.Builder#setAllowedAuthenticators(int)
+ Updated `build.gradle` file to avoid unnecessary downloads and potential conflicts when the library is included as a module dependency in an application project.

## [2.1.4] - 2020-02-10
## Changed
- Removed duplicate onAuthenticationError call in android
Expand Down
85 changes: 63 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ or npm:

`$ npm install react-native-biometrics --save`

### Install pods

`$ npx pod-install`

### Link / Autolinking

On React Native 0.60+ the [CLI autolink feature](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) links the module while building the app.
Expand All @@ -30,7 +34,7 @@ On React Native 0.60+ the [CLI autolink feature](https://github.com/react-native

This package requires an iOS target SDK version of iOS 10 or higher

Ensure that you have the `NSFaceIDUsageDescription` entry set in your react native iOS project, or Face ID will not work properly. This description will be will be presented to the user the first time a biometrics action is taken, and the user will be asked if they want to allow the app to use Face ID. If the user declines the usage of face id for the app, the `isSensorAvailable` function will indicate biometrics is unavailable until the face id permission is specifically allowed for the app by the user.
Ensure that you have the `NSFaceIDUsageDescription` entry set in your react native iOS project, or Face ID will not work properly. This description will be presented to the user the first time a biometrics action is taken, and the user will be asked if they want to allow the app to use Face ID. If the user declines the usage of face id for the app, the `isSensorAvailable` function will indicate biometrics is unavailable until the face id permission is specifically allowed for the app by the user.

#### Android

Expand All @@ -44,7 +48,7 @@ This package is designed to make server authentication using biometrics easier.

When a user enrolls in biometrics, a key pair is generated. The private key is stored securely on the device and the public key is sent to a server for registration. When the user wishes to authenticate, the user is prompted for biometrics, which unlocks the securely stored private key. Then a cryptographic signature is generated and sent to the server for verification. The server then verifies the signature. If the verification was successful, the server returns an appropriate response and authorizes the user.

## Constants
## Biometry Types

### TouchID (iOS only)

Expand All @@ -53,11 +57,13 @@ A constant for the touch id sensor type, evaluates to `'TouchID'`
__Example__

```js
import ReactNativeBiometrics from 'react-native-biometrics'
import ReactNativeBiometrics, { BiometryTypes } from 'react-native-biometrics'

const rnBiometrics = new ReactNativeBiometrics()

const { biometryType } = await ReactNativeBiometrics.isSensorAvailable()
const { biometryType } = await rnBiometrics.isSensorAvailable()

if (biometryType === ReactNativeBiometrics.TouchID) {
if (biometryType === BiometryTypes.TouchID) {
//do something fingerprint specific
}
```
Expand All @@ -69,11 +75,13 @@ A constant for the face id sensor type, evaluates to `'FaceID'`
__Example__

```js
import ReactNativeBiometrics from 'react-native-biometrics'
import ReactNativeBiometrics, { BiometryTypes } from 'react-native-biometrics'

const rnBiometrics = new ReactNativeBiometrics()

const { biometryType } = await ReactNativeBiometrics.isSensorAvailable()
const { biometryType } = await rnBiometrics.isSensorAvailable()

if (biometryType === ReactNativeBiometrics.FaceID) {
if (biometryType === BiometryTypes.FaceID) {
//do something face id specific
}
```
Expand All @@ -85,16 +93,37 @@ A constant for generic Biometrics, evaluates to `'Biometrics'`
__Example__

```js
import ReactNativeBiometrics from 'react-native-biometrics'
import ReactNativeBiometrics, { BiometryTypes } from 'react-native-biometrics'

const { biometryType } = await ReactNativeBiometrics.isSensorAvailable()
const rnBiometrics = new ReactNativeBiometrics()

if (biometryType === ReactNativeBiometrics.Biometrics) {
const { biometryType } = await rnBiometrics.isSensorAvailable()

if (biometryType === BiometryTypes.Biometrics) {
//do something face id specific
}
```

## Methods
## Class

## Constructor

__Options Object__
| Parameter | Type | Description | iOS | Android |
| --- | --- | --- | --- | --- |
| allowDeviceCredentials | boolean | Boolean that will enable the ability for the device passcode to be used instead of biometric information. On iOS, the prompt will only be shown after biometrics has failed twice. On Android, the prompt will be shown on the biometric prompt and does not require the user to attempt to use biometrics information first. Note: This feature is not supported on Android versions prior to API 30. |||

__Example__

```js
import ReactNativeBiometrics from 'react-native-biometrics'

const rnBiometrics = new ReactNativeBiometrics({ allowDeviceCredentials: true })

// Perform operations as normal
// All prompts will allow for fallback to the device's credentials for authentication

```

### isSensorAvailable()

Expand All @@ -111,17 +140,19 @@ __Result Object__
__Example__

```js
import ReactNativeBiometrics from 'react-native-biometrics'
import ReactNativeBiometrics, { BiometryTypes } from 'react-native-biometrics'

ReactNativeBiometrics.isSensorAvailable()
const rnBiometrics = new ReactNativeBiometrics()

rnBiometrics.isSensorAvailable()
.then((resultObject) => {
const { available, biometryType } = resultObject

if (available && biometryType === ReactNativeBiometrics.TouchID) {
if (available && biometryType === BiometryTypes.TouchID) {
console.log('TouchID is supported')
} else if (available && biometryType === ReactNativeBiometrics.FaceID) {
} else if (available && biometryType === BiometryTypes.FaceID) {
console.log('FaceID is supported')
} else if (available && biometryType === ReactNativeBiometrics.Biometrics) {
} else if (available && biometryType === BiometryTypes.Biometrics) {
console.log('Biometrics is supported')
} else {
console.log('Biometrics not supported')
Expand All @@ -144,7 +175,9 @@ __Example__
```js
import ReactNativeBiometrics from 'react-native-biometrics'

ReactNativeBiometrics.createKeys('Confirm fingerprint')
const rnBiometrics = new ReactNativeBiometrics()

rnBiometrics.createKeys()
.then((resultObject) => {
const { publicKey } = resultObject
console.log(publicKey)
Expand All @@ -167,7 +200,8 @@ __Example__
```js
import ReactNativeBiometrics from 'react-native-biometrics'

ReactNativeBiometrics.biometricKeysExist()
const rnBiometrics = new ReactNativeBiometrics()
rnBiometrics.biometricKeysExist()
.then((resultObject) => {
const { keysExist } = resultObject

Expand All @@ -194,7 +228,9 @@ __Example__
```js
import ReactNativeBiometrics from 'react-native-biometrics'

ReactNativeBiometrics.deleteKeys()
const rnBiometrics = new ReactNativeBiometrics()

rnBiometrics.deleteKeys()
.then((resultObject) => {
const { keysDeleted } = resultObject

Expand Down Expand Up @@ -236,7 +272,9 @@ import ReactNativeBiometrics from 'react-native-biometrics'
let epochTimeSeconds = Math.round((new Date()).getTime() / 1000).toString()
let payload = epochTimeSeconds + 'some message'

ReactNativeBiometrics.createSignature({
const rnBiometrics = new ReactNativeBiometrics()

rnBiometrics.createSignature({
promptMessage: 'Sign in',
payload: payload
})
Expand All @@ -261,6 +299,7 @@ __Options Object__
| Parameter | Type | Description | iOS | Android |
| --- | --- | --- | --- | --- |
| promptMessage | string | Message that will be displayed in the biometrics prompt |||
| fallbackPromptMessage | string | Message that will be shown when FaceID or TouchID has failed and a passcode has been set on the device. |||
| cancelButtonText | string | Text to be displayed for the cancel button on biometric prompts, defaults to `Cancel` |||

__Result Object__
Expand All @@ -275,7 +314,9 @@ __Example__
```js
import ReactNativeBiometrics from 'react-native-biometrics'

ReactNativeBiometrics.simplePrompt({promptMessage: 'Confirm fingerprint'})
const rnBiometrics = new ReactNativeBiometrics()

rnBiometrics.simplePrompt({promptMessage: 'Confirm fingerprint'})
.then((resultObject) => {
const { success } = resultObject

Expand Down
38 changes: 22 additions & 16 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@ apply plugin: 'com.android.library'

description = 'react-native-biometrics'

def DEFAULT_COMPILE_SDK_VERSION = 29
def DEFAULT_BUILD_TOOLS_VERSION = "29.0.2"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 29

buildscript {
repositories {
google()
jcenter()
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
if (project == rootProject) {
repositories {
mavenCentral()
maven { url "$rootDir/../node_modules/react-native/android" }
google()
}

dependencies {
classpath("com.android.tools.build:gradle:3.6.2")

}
}
}

dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
}
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
compileSdkVersion safeExtGet('compileSdkVersion', 29)

defaultConfig {
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 29)
}
lintOptions {
abortOnError false
Expand All @@ -33,10 +38,11 @@ android {

repositories {
mavenCentral()
maven { url "$rootDir/../node_modules/react-native/android" }
google()
}

dependencies {
implementation 'androidx.biometric:biometric:1.0.1'
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'com.facebook.react:react-native:+'
}
15 changes: 15 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 7e1ff50

Please sign in to comment.