Instnt Core JavaScript Library

Instnt Core JavaScript library provides the core functionality for the Instnt web SDKs (React, Angular, and Vanilla JavaScript SDK). The JS library helps Instnt maintain a common codebase across its web SDKs to avoid duplications and overhead maintenance.

The library does not bundle with web SDKs. It streams from the server-side during the initial Instnt SDK setup (aka begin transaction). This enables smoother enhancement and upkeep without customers needing to frequently update the Instnt web SDKs.

Instnt React and Angular SDKs provide framework-specific components that facilitate easier integrations with apps developed within those frameworks. We encourage you to use the SDK components when applicable.

The Core JS library functions are wrapped in the Instnt object, which becomes available for access after the Instnt SDK initializes successfully. The properties and functions associated with the object are used to execute various operations, such as performing document scans on the client-side and interacting with Instnt's API. The library provides a set of events used across the three Instnt web SDKs. Below are the details and events generated by the Instant object functions and web SDK components.

Instnt object

Property

Type

Description

instnttxnid

UUID

Instnt Transaction ID

form_key

string

Instnt Workflow ID

otpVerification

boolean

Whether Instnt Workflow has OTP verification enabled

documentVerification

boolean

Whether Instnt Workflow has document verification enabled

 

Instnt functions

Method

Sync | Async

Parameters

Events Triggered

Description

onEvent

Async

event

 

An event handler receiving Instnt events.

init

Async

   

Initializes an Instnt signup session.

captureDocument

Sync

documentType,

documentSide,

captureMode = "Auto",

autoUpload = true

document.captured

document.uploaded (if autoUpload = true)

document.capture-cancelled

Captures a document, using device camera such as driver's license, passport.

captureSelfie

Sync

captureMode, autoUpload

document.captured

document.uploaded (if autoUpload = true)

document.capture-cancelled

Captures a selfie image using device camera.

uploadAttachment

Async

attachment, documentSide

isSelfie = false

document.uploaded

document.error

Upload a document file to Instnt server.

verifyDocuments

Async

documentType

document.verification-initiated

document.error

Initiate document verification on Instnt server.

submitSignupData

Async

data which is a JavaScript object with key:value pair of user entered data

transaction.processed

transaction.error

Submit the user entered data to Instnt server and initiate customer approval process.

getTransactionStatus

Async

instnttxnid

 

Returns the status of the transaction (instead of triggering an event) that includes the workflow fields verification and document verification status

sendOTP

Async

mobileNumber

otp.sent

otp.error

Sends one-time password to the mobile number provided.

verifyOTP

Async

mobileNumber, otpCode

otp.verified

otp.error

Verifies one-time password to the provided mobile number.

 

Instnt Events

Name

Content

Description

Instnt Initialized

{
"type":"transaction.initiated",
"data":{
"instnt":"object"
}
}

This signifies that the Instnt framework has finished initializing and is ready to accept user input.

Instnt object contains a transaction ID and SDK functions.

Document Captured

{type: ‘document.captured’,

data: {

document_type,

document_side

}}

Image capture completed.

Document uploaded

{type: ‘document.uploaded’,

data: {

document_type,

document_side,

error

}}

Captured document has been uploaded.

Capture Cancelled

{type: ‘document.capture-cancelled’,

data: {

document_type,

document_side,

error

}}

Image capture has been cancelled.

Capture onEvent

{

type: 'document.capture-onEvent',

data: {

documentSettings,

statusCode,

statusCodeMessage,

data

}

}

The SDK calls the function you pass to setOnEvent when an image is captured that does not meet the minimum requirements specified in the current capture settings. See the table below for specific detail on handling this event.

Documents verification initiated

{type: ‘document.verification-initiated’,

data: {

instnttxnid,

}}

Indicates that document verification process initiated at Instnt's backend. To get the decision, submit the data by calling appropriate SDK method instnt.submitData()

Document error

{type: 'document.error',

data: {

message,

status,

type

}}

Error processing document verification.

OTP sent

{type: 'otp.sent’,

data: {

mobileNumber,

instnttxnid

}}

OTP sent.

OTP Verified

{type: 'otp.verified’,

data: {

mobileNumber,

otpCode,

instnttxnid

}}

OTP verified.

OTP error

{type: 'otp.error',

data: {

message,

type

}}

Error while OTP verification process.

Application Processed

{type: ‘transaction.processed’,

data: {

decision: string,

instnttxnid: UUID

}}

User approval process completed.

Application processing error

{type: ‘transaction.error',

data: {

decision: string,

instnttxnid: UUID

}}

 

 

Document Capture onEvent

The SDK emits document.capture-onEvent when an image captured does not meet the minimum requirements specified in the current capture settings. When this event triggers, the SDK continues to stream the user camera feed, but the SDK stops evaluating images and responding to user interactions.
The event has three parameters- errorCode, statusCodeMessage, data.

Parameter Name

Type

Description

errorCode

number

A number indicating the reason the image did not pass minimum requirements. Possible Values:

1: A face was not detected in the image but face detection was enabled

2: The image was too blurry and did not fall within the blur threshold specified by the SDK’s current capture settings.

3: The image has too much glare and did not fall within the glare threshold specified by the SDK’s current capture settings.

4: A barcode was not detected in the image but barcode detection was enabled.

errorDescription

string

A string summary of the reason indicated by the errorCode.

data

object

An object containing detailed data about the reason the bad image event was thrown.

data.focusStatus

string

When “Yes”, indicates that the image met the focus threshold. specified in the SDK current capture settings. When “No”, indicates that the image did not meet the focus threshold.

data.focusValue

number

A numerical representation of the amount of focus found in the image. This number must be greater than the capture setting threshold.

data.glareStatus

string

When “Yes”, indicates that the image met the glare threshold. specified in the SDK current capture settings. When “No”, indicates that the image did not meet the glare threshold.

data.faceDetectionStatus

string

When “Yes”, indicates that a face was detected in the image. When “No”, indicates that a face was not detected in the image. This will always be “Yes” if face detection is disabled.

data.barcodeDetectionStatus

string

When “Yes”, indicates that a barcode was detected in the image. When “No”, indicates that a barcode was not detected in the image. This will always be “Yes” if barcode detection is disabled.

data.eventCount

number

The current images number in relation to the captureAttempts specified for this document scan in the capture settings.

data.image

string

A base64 encoded byte array for the captured image. This image does not meet minimum requirements.

 

Recommendations for handling these events: 

  • We recommend presenting an error message to the end-user with details about how the captured image does not meet minimum requirements, and they will need to try again.
  • Key off of errorCode when deciding what to tell the end-user. The event object used shows more granular details about why an image does not meet the requirements.

Recommendations for handling these events:

 

  • We recommend presenting an error message to the end-user with details about how the captured image does not meet minimum requirements, and they will need to try again.

  • Key off of errorCode when deciding what to tell the end-user. The event object used shows more granular details about why an image does not meet the requirements.

Examples on how to handle document capture quality with onEvent:

 

As per the document added for “Document Capture onEvent”:

We have “document.capture-onEvent” in the events section, and it is triggered by the SDK when an image is captured that does not meet the minimum requirements specified in the current capture settings.

As mentioned in the event processing details, the SDK emits “document.capture-onEvent” with a data object. This includes all the details of the captured image and indicates that it does not meet the specified minimum requirements.

Below is an example added to illustrate the above points and how we receive the details:

 

FrontImageCapture for document(License) with default settings of AID:

    >  Focus: Fail

    >  Face: Fail

    >  Glare: Pass

BackImageCapture for document(License) with default settings of AID:

    > Focus: Pass

    > Glare: Pass

    > Barcode: Fail
FrontImageCapture.jpg
FrontImageCapture
Screenshot 2024-08-01 at 7.09.27 PM.png
BackImageCapture.jpg
BackImageCapture
Screenshot 2024-08-01 at 7.09.35 PM.png

Document And Selfie Capture Settings:

 

When capturing documents or selfie images, the capture settings determine the thresholds and requirements for an image to be considered high enough quality.

There are two settings for each scanning method exposed by the SDK. You can initialize these classes just like any others. The scan methods are

● DocumentSettings

● SelfieSettings

The recommended values are set as the default values for both classes. These do not need to change unless indicated otherwise.
For both setting classes, the defaults are the recommended values unless indicated otherwise. There are only a couple that we recommend changing, see recommendations highlighted in the table below.