1.3.0 • Published 2 months ago

@caf.io/react-native-face-authenticator v1.3.0

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

About

The @caf.io/react-native-face-authenticator 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 and authentication.

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-authenticator
# or 
npm install @caf.io/react-native-face-authenticator

Usage

import React from 'react';
import { View, Button, StyleSheet } from 'react-native';
import { 
  startFaceAuthenticator,
  useFaceAuthenticator, 
  FaceAuthenticatorOptions, 
  Stage, 
  Filter, 
  Time 
} from '@caf.io/react-native-face-authenticator';

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

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

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

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

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

Methods

startFaceAuthenticator

This method inicialize the face authenticator.

Params

ParamTypeDefaultDescription
mobileTokenstringRequiredUsage token associated with your Identity account
peopleIdstringRequiredUser CPF

Hooks

useFaceAuthenticator

This hook provides the responses of method startFaceAuthenticator and make the settings for face authenticator.

Params

ParamTypeDefaultDescription
optionsFaceAuthenticatorOptionsOptionalSettings for the face authenticator

Responses

FaceAuthenticatorResponse

Types

FaceAuthenticatorResult

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.

FaceAuthenticatorError

NameTypeDescription
statusCodestringHttps code status
messagestringError message
errorErrorError enum

FaceAuthenticatorResponse

NameTypeDescription
resultFaceAuthenticatorResult or nullShows when face authenticator returns a successful capture
errorFaceAuthenticatorError or nullShows when the face authenticator return some error
cancelledbooleanShows when user cancel the face authenticator
isLoadingbooleanShows when the face authenticator is loading

FaceAuthenticatorOptions

NameTypeDescription
cafStageStageChange the development environment
filterFilterChange face authenticator mask
imageUrlExpirationTimeTimeChange the expiration time of the face liveness url
enableScreenshotsbooleanToggle user screenshots
loadingScreenbooleanToggle face authenticator 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.3.0

2 months ago

1.2.1

3 months ago

1.2.0

4 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.0.0

4 months ago