FaceLiveness

The @caf.io/react-native-face-liveness library is a powerful tool for integrating facial liveness detection functionality into React Native applications. It allows developers to easily incorporate liv

Requirements

The libraries are compatible only with React Native versions that are 0.66.5 or later.

Android

SettingsMinimum version

minSdkVersion

21

compileSdkVersion

34

Java version

8

To publish your app on the Google Play Store, you must complete a data safety form. Since we integrate with the FingerPrintJS SDK, you'll need to provide the following information:

Question in Google Play Console's data safety formResponse

Does your app collect or share any of the required user data types?

Yes.

What type of data is collected?

Device or other identifiers.

Is this data collected, shared, or both?

Collected.

Is this data processed ephemerally?

Yes.

Why is this user data collected?

Fraud Prevention, Security, and Compliance.

iOS

SettingsMinimum version

Target

12

Xcode

14.3.1

Swift

5.5

Installation

yarn add @caf.io/react-native-face-liveness
# or 
npm install @caf.io/react-native-face-liveness

Android

If you're utilizing Expo for your project, be sure to include that line in android/build.gradle.

allprojects { 
  repositories { 
    ... 
    maven { url 'https://repo.combateafraude.com/android/release' }
    maven { url 'https://raw.githubusercontent.com/iProov/android/master/maven/' }
    maven { url 'https://maven.fpregistry.io/releases' }
    maven { url 'https://jitpack.io' }
  } 
}

iOS

In the Podfile in the iOS folder, add this following sources:

source 'https://github.com/combateafraude/iOS.git'
source 'https://cdn.cocoapods.org'

After editing your Podfile, save it and install the SDK along with its dependencies by running the following command:

pod install

Usage

import React from 'react';
import { View, Button, StyleSheet } from 'react-native';
import { 
  startFaceLiveness,
  useFaceLiveness, 
  FaceLivenessOptions, 
  Stage, 
  Filter, 
  Time 
} from '@caf.io/react-native-face-liveness';

export default function App() {
  const mobileToken: string = "";
  const peopleId: string = "";

  const options: FaceLivenessOptions = {
    cafStage: Stage.PROD,
    filter: Filter.NATURAL,
    imageUrlExpirationTime: Time.THREE_HOURS,
    enableScreenshots: true,
    loadingScreen: true
  } // optional

  const { 
    result, 
    error, 
    cancelled, 
    isLoading 
  } = useFaceLiveness(options);

  return (
    <View style={styles.container}>
      <Button 
        title="Press" 
        onPress={() => startFaceLiveness(mobileToken, peopleId)} 
      />
    </View>
  );
} 

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Methods

startFaceLiveness

This method inicialize the face liveness.

Params

ParamTypeRequiredDescription

mobileToken

string

Yes

Usage token associated with your Identity account

peopleId

string

Yes

User CPF

Hooks

useFaceLiveness

This hook provides the responses of method startFaceLiveness and make the settings for face liveness.

Params

ParamTypeRequiredDescription

options

FaceLivenessOptions

No

Settings for the face liveness

Responses

FaceLivenessResponse

Types

FaceLivenessResult

NameTypeDescription

signedResponse

string

Signed response from the CAF server confirming that the captured selfie has a real face. This parameter is used to get an extra layer of security, checking that the signature of the response is not broken, or caused by request interception. If it is broken, there is a strong indication of request interception.

signedResponse params

NameTypeDescription

requestId

string

Request identifier.

isAlive

boolean

Validation of a living person, identifies whether the user passed successfully or not.

token

string

Request token.

userId

string

User identifier provided for the request.

imageUrl

string

Temporary link to the image, generated by our API.

personId

string

User identifier provided for the SDK.

sdkVersion

string

Sdk version in use.

iat

string

Token expiration.

FaceLivenessError

NameTypeDescription

statusCode

string

Https code status

message

string

Error message

error

Error enum

FaceLivenessResponse

NameTypeDescription

result

Shows when face liveness returns a successful capture

error

Shows when the face livenes return some error

cancelled

boolean

Shows when user cancel the liveness

isLoading

boolean

Shows when the face liveness is loading

FaceLivenessOptions

NameTypeDescription

cafStage

Change the development environment

filter

Change face liveness mask

imageUrlExpirationTime

Change the expiration time of the face liveness url

enableScreenshots

boolean

Toggle user screenshots

loadingScreen

boolean

Toggle face liveness loading screen

Enums

Stage

EnumDescription

BETA

Beta environment

PROD

Production environment

Filter

EnumDescription

LINE_DRAWING

Alternative mask for face liveness

NATURAL

Normal mask for face liveness

Time

EnumDescription

THREE_HOURS

Image url expiration time expires in three hours

THIRTY_DAYS

Image url expiration time expires in thirty days

THIRTY_MIN

Image url expiration time expires in thirty minutes

Error

EnumDescription

ServerReason

A server-side error/token invalidation occurred. The associated string (if available) will contain further information about the error.

NetworkReason

An error occurred with the video streaming process. The associated string (if available) will contain further information about the error.

UnknownReason

An unknown error has occurred. The associated string will contain further information about the error. These errors should be reported to iProov for further investigation.

UnexpectedReason

An unxpected error has occurred

CameraPermission

The user disallowed access to the camera when prompted. You should direct the user to re-try.

Last updated

Logo

2023 © Caf. - All rights reserved