1.4.0 • Published 2 months ago

@caf.io/react-native-face-liveness v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

About

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.

Minimum Requirements

Android

SettingsMinimum version
minSdkVersion21
compileSdkVersion34
Java version8

iOS

SettingsMinimum version
Target12
Xcode13.4.1

Getting Started

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

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

ParamTypeDefaultDescription
mobileTokenstringRequiredUsage token associated with your Identity account
peopleIdstringRequiredUser CPF

Hooks

useFaceLiveness

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

Params

ParamTypeDefaultDescription
optionsFaceLivenessOptionsOptionalSettings for the face liveness

Responses

FaceLivenessResponse

Types

FaceLivenessResult

NameTypeDescription
signedResponsestringSigned 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
requestIdstringRequest identifier.
isAlivebooleanValidation of a living person, identifies whether the user passed successfully or not.
tokenstringRequest token.
userIdstringUser identifier provided for the request.
imageUrlstringTemporary link to the image, generated by our API.
personIdstringUser identifier provided for the SDK.
sdkVersionstringSdk version in use.
iatstringToken expiration.

FaceLivenessError

NameTypeDescription
statusCodestringHttps code status
messagestringError message
errorErrorError enum

FaceLivenessResponse

NameTypeDescription
resultFaceLivenessResult or nullShows when face liveness returns a successful capture
errorFaceLivenessError or nullShows when the face livenes return some error
cancelledbooleanShows when user cancel the liveness
isLoadingbooleanShows when the face liveness is loading

FaceLivenessOptions

NameTypeDescription
cafStageStageChange the development environment
filterFilterChange face liveness mask
imageUrlExpirationTimeTimeChange the expiration time of the face liveness url
enableScreenshotsbooleanToggle user screenshots
loadingScreenbooleanToggle face liveness loading screen

Enums

Stage

EnumDescription
BETABeta environment
PRODProduction environment
DEVDevelopment environment

Filter

EnumDescription
LINE_DRAWINGAlternative mask for face liveness
NATURALNormal mask for face liveness

Time

EnumDescription
THREE_HOURSImage url expiration time expires in three hours
THIRTY_DAYSImage url expiration time expires in thirty days
THIRTY_MINImage url expiration time expires in thirty minutes

Error

EnumDescription
ServerReasonA server-side error/token invalidation occurred. The associated string (if available) will contain further information about the error.
NetworkReasonAn error occurred with the video streaming process. The associated string (if available) will contain further information about the error.
UnknownReasonAn unknown error has occurred. The associated string will contain further information about the error. These errors should be reported to iProov for further investigation.
UnexpectedReasonAn unxpected error has occurred
CameraPermissionThe user disallowed access to the camera when prompted. You should direct the user to re-try.
1.4.0

2 months ago

1.3.1

3 months ago

1.3.0

4 months ago

1.2.0

4 months ago

1.1.0

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago