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 live facial verification, adding an extra layer of security.
Settings | Minimum version |
---|---|
minSdkVersion | 21 |
compileSdkVersion | 34 |
Java version | 8 |
Settings | Minimum version |
---|---|
Target | 12 |
Xcode | 13.4.1 |
yarn add @caf.io/react-native-face-liveness
# or
npm install @caf.io/react-native-face-liveness
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',
},
});
This method inicialize the face liveness.
Param | Type | Default | Description |
---|---|---|---|
mobileToken | string | Required | Usage token associated with your Identity account |
peopleId | string | Required | User CPF |
This hook provides the responses of method startFaceLiveness
and make the settings for face liveness.
Param | Type | Default | Description |
---|---|---|---|
options | FaceLivenessOptions | Optional | Settings for the face liveness |
Name | Type | Description |
---|---|---|
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. |
Name | Type | Description |
---|---|---|
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. |
Name | Type | Description |
---|---|---|
statusCode | string | Https code status |
message | string | Error message |
error | Error | Error enum |
Name | Type | Description |
---|---|---|
result | FaceLivenessResult or null | Shows when face liveness returns a successful capture |
error | FaceLivenessError or null | 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 |
Name | Type | Description |
---|---|---|
cafStage | Stage | Change the development environment |
filter | Filter | Change face liveness mask |
imageUrlExpirationTime | Time | Change the expiration time of the face liveness url |
enableScreenshots | boolean | Toggle user screenshots |
loadingScreen | boolean | Toggle face liveness loading screen |
Enum | Description |
---|---|
BETA | Beta environment |
PROD | Production environment |
DEV | Development environment |
Enum | Description |
---|---|
LINE_DRAWING | Alternative mask for face liveness |
NATURAL | Normal mask for face liveness |
Enum | Description |
---|---|
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 |
Enum | Description |
---|---|
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. |