Incode WebSDK reference
Method documentation for the webSDK
create
Description:
You need to call this method before using the SDK. The method returns an instance of the SDK.
Parameters:
Name | Type | Description |
---|---|---|
apiKey | string | API key |
apiURL | string | API URL |
lang | string | Language (en or es) |
encrypt | boolean | Indicates the use of encryption (default: false) |
translations | object | The object with the translations. (Ask support) (optional) |
opencvURL | string | The URL of opencv (optional) |
facefinderURL | string | The URL of facefinder (optional) |
darkMode | boolean | Show dark variants of all tutorials (default: false) |
fingerprintApiKey | string | The fingerprint API key (optional). |
Returns
-
Object:
The SDK instance
Example:
// Get onBoarding instance
const onBoarding = OnBoarding.create({
apiKey: "myApiKey",
apiURL: "myApiURL",
lang: "en",
});
// You can save it on a global variable
var onBoarding = OnBoarding.create({ apiKey: "myApiKey", apiURL: "myApiURL" });
// use the instance
onBoarding.createSession(countryCode).then((token) => {
// save token
});
isDesktop
Description:
This function informs you if the user is using a desktop computer (it can be a laptop)
Example:
if (onBoarding.isDesktop()) {
onBoarding.renderRedirectToMobile(containerRef.current, {
onSuccess: () => {
renderFinishScreen();
},
session: session,
flowId: flowId,
});
} else {
// show mobile normal flow
renderFrontId();
}
renderRedirectToMobile
Description:
This method renders the Redirect Component
Parameters:
Name | Type | Description |
---|---|---|
container | HTMLElement | |
options Object | object | options object |
Options:
Name | Type | Description |
---|---|---|
session | object* | The session object you get in createSession (Mandatory) |
flowId | string | ID of the flow that will be used in the mobile |
onSuccess | function* | Callback when the onboarding in mobile was successful and completed |
url | string | URL to be redirected to |
showSms | boolean | Boolean flag indicating if the SMS component should be shown |
allowReEnrollment | boolean | Boolean flag indicating if user re-enrollment is allowed |
externalId | string | External ID to concatenate to URL if needed |
assets | object | Object containing assets from the dashboard |
expired | boolean | Boolean flag indicating if a session is expired |
smsText | string | Custom text to be send in SMS. The URL is concatenated after this text |
Example:
const flowId = "someflowid";
const session = await onBoarding.createSession("ALL", null, {
configurationId: flowId,
});
if (onBoarding.isDesktop()) {
onBoarding.renderRedirectToMobile(containerRef.current, {
onSuccess: () => {
renderFinishScreen();
},
session: session,
flowId: flowId,
});
} else {
// show mobile normal flow
renderFrontId();
}
renderUserConsent
Description:
Renders a privacy consent interface within a specified DOM element. This function allows for displaying a consent form that is either predefined in the dashboard or uses a default configuration.
Parameters:
Name | Type | Description |
---|---|---|
element | HTMLElement | The DOM element where the consent interface will be rendered. If null , the function will not perform any operation. |
options | object | An object containing configuration options for the consent interface. The options object includes the properties described below: |
options.session | Session | The session object containing user session data, necessary for determining the consent state or user preferences. |
options.onSuccess | () => void | A callback function that is called when the user provides consent, facilitating further actions or analytics tracking. |
options.title | string (Optional) | The title of the consent dialog. If not specified, a default title from the dashboard or predefined settings will be used. |
options.text | string (Optional) | The descriptive text displayed in the consent dialog, providing context or details about the consent being requested. Falls back to a default if not provided. |
Example:
// Locate the DOM element where the consent dialog should be rendered
const consentElement = document.getElementById("consent-root");
// Define the onSuccess callback function
const handleConsentGiven = () => {
console.log("User consent granted.");
};
// Define the configuration options for the consent dialog
const consentOptions = {
session: session,
onSuccess: handleConsentGiven,
title: "Privacy and Cookies Consent",
text: "We use cookies to ensure you get the best experience on our website. By continuing, you agree to our privacy policy.",
// Optionally, provide a custom JSX component for additional consent options
customCheck: null, // Assuming no custom JSX element is provided
};
// Call the renderUserConsent function with the defined parameters
renderUserConsent(consentElement, consentOptions);
renderCombinedConsent
Description:
Renders a combined consent interface within a specified DOM element. This function allows for displaying a consent form that is predefined in the dashboard.
Parameters:
Name | Type | Description |
---|---|---|
element | HTMLElement | The DOM element where the consent interface will be rendered. If null , the function will not perform any operation. |
consentId | string | Id of a consent configured in dashboard |
token | Session | The session object get in createSession |
onSuccess | () => void | A callback function that is called when the user provides consent, facilitating further actions or analytics tracking. |
Example:
// Locate the DOM element where the consent screen should be rendered
const consentElement = document.getElementById("consent-root");
// Define the onSuccess callback function
const handleConsentGiven = () => {
console.log("Combined consent given.");
};
// Define the configuration options for the consent screen
const consentOptions = {
token: session,
onSuccess: handleConsentGiven,
consentId: "someConsentId", // id of a consent created in dashboard
};
// Call the renderCombinedConsent function with the defined parameters
renderCombinedConsent(consentElement, consentOptions);
sendGeolocation
Description:
This is almost the same as addGeolocation
with the difference being that this will automatically ask the user for the coordinates.
Parameters:
Name | Type | Description |
---|---|---|
token | string | access token to be used in all other methods. |
Returns:
-
Object:
JSON object
-
JSON example:
{ "location": "Belgrade, Serbia" }
Example:
onBoarding.sendGeolocation({ token }).then((res) => res);
sendFingerprint
Description:
Sends relevant information about the user's device and Incode's Web SDK:
- Browser version
- Device model
- Application type (Web application)
- OS and OS version
- Incode's Web SDK version
- User's IP address
Parameters:
Name | Type | Description |
---|---|---|
token | string | access token to be used in all other methods. |
Returns:
- Object:
{
"success": boolean,
"sessionStatus": string
}
Example:
onBoarding.sendFingerprint({ token: session.token }).then((response) => {
console.log(response.success);
});
renderDocumentSelector
Description:
This method renders a Document Selector in a given container. It provides various customization options and callbacks for different stages of the document selection process. It accepts the same parameters as renderCamera
, excluding type
.
Parameters:
Name | Type | Description |
---|---|---|
element | React.ReactNode | Element | The container element or node where the document selector will be rendered. |
options | RenderCameraProps object | Configuration options for the document selector. |
Options:
Name | Type | Default | Description |
---|---|---|---|
onSuccess | function | emptyFunc | Callback when the document selection is successful. |
onError | function | emptyFunc | Callback when there is an error in the document selection process. |
numberOfTries | number | 3 | The number of attempts allowed for document selection. |
onLog | function | emptyFunc | A function for logging. |
permissionMessage | string | The message shown in the permission screen. | |
permissionBackgroundColor | string | The background color of the permission screen. | |
token | object | The session token. | |
timeout | number | 40000 | The timeout duration in milliseconds. |
sendBase64 | boolean | true | Flag to determine if the image should be sent in base64 format. |
documentType | string | The type of document to be selected. | |
showPreview | boolean | false | Flag to show preview after document capture. |
stream | MediaStream | A media stream object. | |
nativeCamera | boolean | false | Flag to use the native camera for capture. |
hideRetake | boolean | false | Flag to hide the retake option. |
showTutorial | boolean | false | Flag to show a tutorial. |
showPaperDLTutorial | boolean | false | Flag to show a paper driver's license tutorial. |
onlyCapture | boolean | false | Flag to allow only capturing of images/documents. |
scanPdf417 | boolean | false | Flag to scan for PDF417 barcodes. |
videoTutorialSrc | string | Source of the video tutorial. | |
showCustomCameraPermissionScreen | boolean | false | Flag to show a custom camera permission screen. |
isSecondId | boolean | false | Flag to indicate if the document is a second ID. |
fullScreen | boolean | true | Flag to enable full-screen mode. |
assistedOnboarding | boolean | false | Flag to enable assisted onboarding. |
isRecordingEnabled | boolean | false | Flag to enable recording during capture. |
onRestartOnboarding | function | reload | Callback to restart the onboarding process. |
showDoublePermissionsRequest | boolean | false | Flag to show a double permissions request. |
onlyAllowCapture | boolean | false | Flag to allow only capture (disables uploading of files/images). |
disableFullScreen | boolean | false | Flag to disable full-screen behavior (uses container width/height). |
onStreamReady | function | emptyFunc | Callback when the stream is ready. |
showAutoCaptureIDOverlay | boolean | false | Flag to show an automatic capture ID overlay. |
showManualCaptureIDOverlay | boolean | false | Flag to show a manual capture ID overlay. |
skipProcessFace | boolean | false | Flag to skip processing of the face in the document. |
defaultHorizontalMask | boolean | false | Flag to use a default horizontal mask for the capture. |
isFixedMask | boolean | false | Flag to indicate if the mask is fixed. |
blurrinessStrictMode | boolean | false | Flag to enable strict mode for blurriness detection. |
Usage Example:
const element = document.getElementById("your-container-id");
const onSuccess = () => {
/* success handler code */
};
const onError = () => {
/* error handler code */
};
renderDocumentSelector(element, {
onSuccess,
onError,
// ...other options
});
renderCamera
Description:
This method is going to render the camera with the autodetect and notifications
in the browser.
Parameters:
Name | Type | Description | |||||||
---|---|---|---|---|---|---|---|---|---|
type | string | type of captured image: `'front' | 'back' | 'selfie | document | passport | secondId | thirdId | insuranceCard'` |
container | HTMLElement | ||||||||
optionsObject | object | options object |
Options:
Name | Type | Description |
---|---|---|
onSuccess | function | Callback when the detect was successful, with param object |
onError | function | Callback when the detect was unsuccessful |
token | Object | The session object (optional if not presented is readed from state) |
numberOfTries | Number | The number of capturing attempts |
onLog | function | A function with a logger |
permissionMessage | String | The message in the permission screen. Default: "Press "Allow" to continue." |
permissionBackgroundColor | String | The background of permissions screen. Default: "#696969 |
sendBase64 | boolean | If you need to send the image in base64, set this to true (only if type = 'selfie' ) |
timeout | number | The timeout in milliseconds before enabling the option for manual capture (starts only after an ID or face has been detected) |
showPreview | boolean | Set to true to show capture preview. (only if type = 'selfie' ) |
stream | MediaStream | If you send a stream, it won't ask the user again. This is an advanced option. |
nativeCamera | boolean | This is only optional for documents. If set to true, it's going to use the native camera for the capture (default: false) |
showTutorial | boolean | Option to show the tutorial (default: false) |
isRecordingEnabled | boolean | Option to record the capture camera (default: false) |
onRestartOnboarding | function | Callback for the restart flow after camera access is denied (default: () => window.location.reload() ) |
showDoublePermissionsRequest | boolean | Option to show the custom permission prompt (default: false) |
onlyAllowCapture | boolean | Option to disable the uploading of files and images. Only works when the type is document and nativeCamera is set to true (default: false ) |
disableFullScreen | boolean | Option to disable the full screen behaviour our SDK has. This will use the container width and height. Use this only for Desktop apps. (default:false ) |
showCustomCameraPermissionScreen | boolean | Option to open a modal with instructions to allow camera permissions when user denies them. (default:false ) |
onSuccess parameters:
Name | Type | Description |
---|---|---|
classification | Boolean | Is server classified image as a Id flag |
correctGlare | Boolean | Is the glare in good range flag |
correctSharpness | Boolean | Is the sharpness in the good range flag |
countryCode | String | Valid ISO alpha-2 or alpha-3 code of the ID issuing country |
glare | Number | Glare level |
horizontalResolution | Number | Horizontal resolution in pixels |
issueName | String | Name of provided ID |
issueYear | Number | The year when the ID was issued |
readability | Boolean | Is the data readable from the ID flag |
sessionStatus | String | Current status of the session |
sharpness | Number | Sharpness level |
skipBackIdCapture | Boolean | Flag for skipping back ID capture |
typeOfId | String | Type of ID (ID, Passport...) |
failedReason | String | Classification fail reason. |
Returns:
-
Object:
JSON object
Name Type Description close function This will close the camera and will unmount the component
Example:
const { close } = incode.renderCamera("front", container, {
onSuccess: onSuccess,
onError: onError,
});
// then you can close the SDK from your code
document.querySelector("#close-modal").addEventListener("click", () => {
close(); // this will close the component prematurely, so use it only if you want to abort the process and close the camera
});
processId
Description:
This method should be called once the uploads of the front and back sides of the ID
are over. Incode validations, tests and OCR parsing are processed during this method.
To fetch OCR data, use the ocrData method. Parameter queueName is needed so it can
be determined in which queue the interview should go. Once this is called, the
user is no longer able to upload the ID (front, back side, passport or insurance
card)!
Parameters:
Name | Type | Description |
---|---|---|
token | string | access token. |
Returns:
-
Object:
JSON object
-
JSON example:
{ "success": true }
Example:
const response = await onBoarding.processId({
token,
});
renderVideoSelfie
Description:
This method renders the VideoSelfie Component.
Localization not Supported
For videoSelfie to work a fixed language must be selected during
/omni/start
(How to Start a Session).Please provide it along with the other parameters:
{"language": "en-US"}
Parameters:
Name | Type | Description |
---|---|---|
container | HTMLElement | |
options Object | object | options object |
callback Object | object | options object |
Options:
Name | Type | Description |
---|---|---|
token | String | The token string (Mandatory) |
showTutorial | boolean | Option to show the tutorial (default: false) |
modules | Array[String] | The modules you want to perform in video selfie. Check the table to see all available modules (The default is all modules) |
speechToTextCheck | boolean | Option to perform the speech to text check. If this is false, the videoSelfie always will call onSuccess (default: true) |
performLiveness | boolean | Off/On liveness check, by default it is false |
videoSelfieAsSelfie | boolean | The option to choose from which image you will make a face check, from selfie or video selfie. If it is true it will be from selfie |
compareOCREnabled | boolean | Option to off/on front OCR check (default: false) |
compareIDEnabled | boolean | Option to off/on front ID check (default: true) |
compareBackOCREnabled | boolean | Option to off/on back OCR check (default: false) |
compareBackIDEnabled | boolean | Option to off/on back ID check (default: false) |
questionsCount | Number | Option to set number of questions in questions module (default: 3) |
Modules
Name | Description |
---|---|
selfie | Selfie step |
front | Front ID step |
back | Back ID step |
poa | Proof of address step |
questions | Random questions step |
speech | The user will perform an authorization. Important: this step is mandatory and needs to be the last one |
Callback
Name | Type | Description |
---|---|---|
onSuccess | function | Callback when the videoselfue was successful. If this is called it means the speech detection was successful. |
onError | function | Callback when the detect was unsuccessful. If this is called it means the speech detection was unsuccessful |
numberOfTries | number | The number of tries in speech-to-text |
Example:
onBoarding.renderVideoSelfie(
container,
{
token: session,
showTutorial: true,
modules: ["front", "back", "speech", "selfie"], // you can add 'poa' and 'questions'
speechToTextCheck: true, // this is the check for the speech
},
{
onSuccess: () => alert("speech detected"),
onError: () => alert("speech not detected"),
numberOfTries: 3,
}
);
renderConference
Description:
This method will render the Conference component
Parameters:
Name | Type | Description |
---|---|---|
container | HTMLElement | |
options Object | object | options object |
callback Object | object | callbacks object |
Options:
Name | Type | Description |
---|---|---|
token | Object | The session object (Mandatory) |
showOTP | Boolean | If true, it will render the OTP screen before conference |
numberOfTries | Number | The number of tries that the user has for OTP. If you put -1 the user will have infinite tries. Default: 3 |
queue | String | The queue for the video conference. Default: '' |
Callbacks:
Name | Type | Description |
---|---|---|
onSuccess | function | Passes the status as a parameter. Possible statuses are: close, deny, approve |
onError | function | Callback when the detect was unsuccessful. Something went wrong in the conference |
onConnect | function | Callback when the conference is connected |
onLog | function | Callback for the logging |
Example:
onBoarding.renderConference(
container,
{
token: token,
showOTP: false,
},
{
onSuccess: (status) => {
log(status);
switch (status) {
case "close":
console.log("The conference was close");
goToStep("closeCase");
break;
case "deny":
console.log("The conference was denied");
goToStep("denyCase");
break;
case "close":
console.log("The conference was approved");
goToStep("approveCase");
break;
}
},
}
);
renderLogin
Description:
This method renders the Face Login Component
Parameters:
Name | Type | Description |
---|---|---|
element | Element | The DOM element where the login component will be rendered. |
onSuccess | function | Callback when the detect was successful. |
onError | function | Callback when an error happened. |
timeout | number (optional) | Maximum time allowed for the login process, after which the onError callback is triggered. |
stopAtAccessDenied | boolean (optional) | Flag to trigger onError callback when access denied event happened. |
stopAtError | boolean (optional) | Flag to trigger onError callback when any error event happened. |
isOneToOne | boolean (optional) | Specifies if the login is for a one-to-one session.If true you will need to send oneToOneProps |
oneToOneProps | Object (optional) | Object containing additional properties for one-to-one sessions. |
oneToOneProps.phone | string (optional) | Phone number to use for one-to-one session authentication. |
oneToOneProps.identityId | string (optional) | Identity ID for the user in one-to-one sessions. (Client Id) |
oneToOneProps.email | string (optional) | Email address to use for one-to-one session authentication. |
showCustomCameraPermissionScreen | boolean (optional) | Whether to show a custom camera permission screen instead of the default browser prompt. |
isKiosk | boolean (optional) | Indicates if the login is being used in a kiosk mode. |
Example:
incode.renderLogin(container, {
onSuccess: onSuccess,
onError: onError,
});
renderEnterCurp
Description:
This method renders the component to enter and validate CURP.
Parameters:
Name | Type | Description |
---|---|---|
token | string | access token to be used in all other methods. |
Example:
incode.renderEnterCurp(document.getElementById('app'), {
token: session.token,
onSuccess: console.log,
onError: console.log,,
})
renderSignature
Description:
This method will render the Signature Component.
Parameters:
Name | Type | Description |
---|---|---|
container | HTMLElement | |
options Object | object | options object |
Options:
Name | Type | Description |
---|---|---|
token | String | The token string (Mandatory) |
onSuccess | function | Callback when the upload of signature was successful |
onError | function | Callback when the upload of signature was unsuccessful |
type | string | Type of signature. This can be used for sign contracts |
initials | boolean | If true, this will send initials and not signature |
title | jsx | The title element in JSX syntax |
subtitle | jsx | The subtitle element in JSX syntax |
canvasBackgroundColor | string | The background color of the canvas (default: '#fff') |
canvasBorderColor | string | The border color of the canvas (default: '#20263d') |
penColor | string | The pen color of the canvas (default: '#20263d') |
Example:
onBoarding.renderSignature(document.getElementById("app"), {
token: session.token,
onSuccess: console.log,
onError: console.log,
});
addPhone
Description:
Add phone number to an interview. If a customer with that phone number already exists, an error
will be thrown.
Parameters:
Name | Type | Description |
---|---|---|
token | string | access token to be used in all other methods. |
phone | string | customer's phone number |
Returns:
-
Object:
JSON object
-
JSON example:
{ "success": true }
Example:
onBoarding.addPhone({ token, phone }).then((res) => res);
addCustomFields
Description:
This endpoint is used for adding custom fields to current onboarding session.
Parameters:
Name | Type | Description |
---|---|---|
token | string | access token to be used in all other methods. |
fields | object | Object of custom fields that will be inserted. |
Returns:
-
Object:
JSON object
-
`Parameters:
Name Type Description success boolean If the call was called correctly. -
JSON example:
{ "success": true }
Example:
incode.addCustomFields({
token: session.token,
fields: { watchlistName: name },
});
renderBiometricConsent
Description:
This method renders the component with biometric consent screen. It should be shown as a first screen if createSession function returns showMandatoryConsent
with true
value (in that case createSession will also return regulationType
which you have to pass as param into this function).
Parameters:
Name | Type | Description |
---|---|---|
token | object | The session object get in createSession |
onSuccess | function | Callback after consent is successfully given |
onCancel | function | Callback after consent is canceled |
regulationType | string | State string received in createSession method if users Geo Ip Location is in California, Texas, Illinois or Washington (possible values: US_California, US_Texas, US_Illinois or US_Washington) |
Example:
incode.renderBiometricConsent(document.getElementById("app"), {
token: session,
onSuccess: console.log,
onCancel: console.log,
regulationType: "US_Illinois",
});
renderMlConsent
Description:
This method will render the ML Consent component.
Parameters:
Name | Type | Description |
---|---|---|
container | HTMLElement | |
options Object | object | options object |
Options:
Name | Type | Description |
---|---|---|
token | object | The token object (mandatory). |
type | string | ML Type (Worldwide) |
onSuccess | function | Callback when the upload of signature was successful |
Example:
onBoarding.renderMlConsent(document.getElementById("app"), {
token: session,
onSuccess() {
console.log("ML accepted");
},
});
renderQr
Description:
This method renders a Qr code which when scanned will open a specified URL or web flow application.
Parameters:
Name | Type | Description |
---|---|---|
container | HTMLElement | |
options Object | object | options object |
Options:
Name | Type | Description |
---|---|---|
session | object* | The session object you get in createSession (Mandatory) |
flowId | string | ID of the flow that will be used in the mobile |
onSuccess | function* | Callback when the onboarding in mobile was successful and completed |
url | string | URL to be redirected to |
primaryColor | string | A hexcode string for styling, ie #000000 |
secondaryColor | boolean | A hexcode string for styling, ie #FFFFFF |
sizePx | number | A single number representing width and height in pixels |
Example:
const flowId = "someflowid";
const session = await onBoarding.createSession("ALL", null, {
configurationId: flowId,
});
if (onBoarding.isDesktop()) {
onBoarding.renderQr(containerRef.current, {
onSuccess: () => {
showFinishScreen();
},
session: session,
flowId: flowId,
});
} else {
// show mobile normal flow
renderFrontId();
}
renderQrScanner
Description:
This method will render the QR Scanner component.
Parameters:
Name | Type | Description |
---|---|---|
container | HTMLElement | |
options Object | object | options object |
Options:
Name | Type | Description |
---|---|---|
session | object | The session object (mandatory). |
onSuccess | function | Callback when the upload of signature was successful |
Example:
onBoarding.renderQrScanner(document.getElementById("app"), {
session: session,
onSuccess() {
console.log("QR scanned");
},
});
Updated about 2 months ago