Liveness Web Component

Introduction

The liveness web SDK is a versatile component that allows you to easily handle authentication process in your web application. The purpose of the SDK is to simplify the integration of our clients to the authentication app.

How the SDK works

The main highlights of the SDK are as the following:

The SDK can be easily embedded in any web application as a reusable web component, declared just like any other HTML element. By using the SDK as an embedded component, the entire journey can be handled within your own domain without the need for redirection to a new domain.

With a customised configuration object, you can set up the SDK according to your preferences.

The SDK event broadcast is a useful tool that provides visibility into user activity from the beginning to the end of the journey and allows you to respond to user interactions during the process by implementing a desired event handler.

SDK Integration Guide

Integrating liveness web SDK into your web application is a simple and straightforward process. You can follow the integration steps outlined in the following recipe:

🦉

Note: If you are loading your web page inside a React Native WebView, make sure to set the 'allowsInlineMediaPlayback' property to true. This ensures that the iOS camera functions correctly within the WebView. Please note that this property is iOS-specific and is set to false by default. Here’s an example of how to set it in your WebView component:

export default function Index() {
  return (
    <SafeAreaView style={{ flex: 1 }}>
      <WebView
        allowsInlineMediaPlayback={true}
        source={{ uri: '****' }} // replace with your web page URL
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#25292e',
    alignItems: 'center',
    justifyContent: 'center',
  },
  text: {
    color: '#fff',
  },
});

How to initialise the SDK

To initialise the SDK, you can use the LivenessWebSdk.init(config) method, which takes a configuration JSON object as input.

In the config object, you can provide specific values for the properties based on your requirements. Adjust the property names and values accordingly to customise the initialisation of the SDK for your web application.

config (JSON Object): The customised configuration used to initialise the SDK. The schema of the config JSON object is defined as follows:

Field

Type

Necessity

Default

Description

params.attempts

number

M

Indicates the number of attempts for liveness check.

params.livenessThreshold

float

M

Threshold for liveness check between 0.0 and 1.0

params.locale

object

O

Defines multilingual configuration for the SDK interface. Accepts an object with the following fields: • default — (string) default locale code (e.g. en, es-AR). • supported — (array) list of supported locale codes. • detectionOrder — (array) defines the locale detection priority (e.g. ["device", "default"]).

params.timeout

number

O

40000 ms

The maximum duration of inactivity (in milliseconds) allowed before the session is terminated.

prompts.instruction

string

O

Position your face within the oval.

Prompt for positioning the face.

prompts.faceDetected

string

O

Hold still for verification.

Prompt when a face is detected.

prompts.eyesClosed

string

O

Please keep your eyes open.

Prompt for keeping eyes open.

prompts.faceNotFound

string

O

Face not detected. Position your face within the oval.

Prompt when face is not detected.

prompts.faceTooFar

string

O

Move closer until your face fits within the oval.

Prompt when face is too far from the camera.

prompts.faceTooClose

string

O

Move back until your face fits within the oval.

Prompt when face is too close to the camera.

prompts.faceCropped

string

O

Please move your face inside the oval.

Prompt for adjusting the position of the face.

prompts.faceCloseToBorder

string

O

Position your face within the oval.

Prompt for positioning the face within the oval.

prompts.failedToPredictLandmarks

string

O

Face not detected. Position your face within the oval.

Prompt when facial landmarks cannot be detected.

prompts.tooManyFaces

string

O

Please ensure only one face is in the frame.

Prompt when multiple faces are detected.

prompts.faceAngleTooLarge

string

O

Please look straight at camera.

Prompt for facing the camera directly.

prompts.lowConfidence

string

O

Hold still for verification.

Prompt when the liveness check confidence level is low.

prompts.faceIsOccluded

string

O

Please ensure your face is not obstructed.

Prompt for ensuring the face is not obstructed

prompts.landscapeModeDetected

string

O

Please hold your device in portrait up mode.

Prompt for forcing the user to keep device in portrait

Logging Event Information

As mentioned, the SDK Event broadcast helps provide visibility into user activity from the beginning to the whole journey and allows you to respond to user interactions during the process by implementing a desired event handler in your code.

The "detail" property of each event provides details about that event. The fields of the "detail" property dispatched by the SDK are as follows:

  • type: It specifies the main event types triggered during the verification submission process. You can find a full list of event types in the following table.
  • body: This is an optional field that provides additional details about the event type. You can find more information about the body structure in the following table.
TypeBodyComments
SESSION_STARTED
SESSION_COMPLETED{


"image": "string",
"croppedImage": "string",
"livenessCheck": "string",
"livenessScore": number,
"additionalResult": any


}

• Image and cropped image as base64 string
• livenessCheck value is either LIVE or FAKE.

CAPTURING_FACE{


"attempt": number


}
FACE_DETECTED{


"attempt": number


}
PROCESSING_FACE{


"attempt": number


}
USER_PROMPTED{

"attempt": number,
"name": "string",
"message": "string"


}

name and message will be prompts field key and value respectively.

ERROR{

"name": "string",
"message": "string"


}

• Please refer to Error Codes section for more details.

  • Error Codes
NameMessage
BAD_REQUESTInvalid request. Please check SDK parameters provided.
CAMERA_ACCESS_DENIEDPlease allow camera access to continue.
GENERALIt looks like something went wrong. Please try again and if the problem still persists please contact your service provider.
TIMEOUTTimeout reached, cannot capture image.

Mobile and Desktop Browser Support

The liveness web SDK supports the following browsers on different platforms:

  • iOS: iOS Safari, Chrome and Firefox.
  • Android: Chrome, Samsung Internet browser and Firefox.
  • Desktop: Chrome, Safari, Firefox

Please ensure that the specified browser versions are met for optimal compatibility and functionality with the SDK.