Skip to main content
Version: 1.1.0

Web Component

Web component is an image capture tool that allows the user to perform registration and authorization through a web interface. Please note that the web component works only in Chromium-based browsers. There are two different versions of the Web Component available. One is designed to work with facial recognition scenarios (supports the new beta version of the LRS subsystem). The second one is designed for joint verification of images of faces and documents.

Without documents

Further instructions for installing and configuring the Web Component are suitable when using 3DiVi BAF without documents. In this case, you need to use tdvc-face-onboarding web component.

Install Web Component

The component is supplied as a TGZ archive. Also, for the tdvc-face-onboarding library to work, the tdvc library is required, which is also supplied as an archive. For the library to work correctly, you also need to install @tensorflow-models/facemesh. Move the archives to your project's root folder and add the following lines to your package.json in the dependencies section:

"@tdvc/face-onboarding": "file:tdvc-face-onboarding-{version}.tgz"
"@tensorflow-models/facemesh": "^0.0.5"

The archive version may differ. Example of the final package.json file:

img.png

After this, call the npm install command, which will install the library into your project.

Import and Use Web Component

Import the library and the styles. If needed, you can overwrite the styling. Example of importing a library and styles:

img.png

Now initialize the Web Component. To do this, fill out the configuration file described below:

The component provides two modules: registration and authorization. To use the component, create an instance of the TDVOnboarding module you need.
Each module accepts 3 configuration objects as parameters. Below is a description of each configuration:

serverConfig

  • baseUrl (string) - URL address of 3DiVi BAF. Required.

  • bafToken (string) - BAF Web API Secret Key. Required.

  • platformToken (string) - Platform service token. Required.

  • lrsToken (string) - Liveness Reflection service token. Required.

  • lrsDecryptKey (string) - Liveness Reflection service decrypt key. Required.

  • iceServers (TIceServer[]) - object with WebRTC settings. Required:

    • ip (string) - IP of stun server. Required.

    • port (string) - port of stun server. Required.

    • transport ('udp' | 'tcp') - protocol of stun server. Required.

    • user (string) - user of stun server. Required.

    • pass (string) - password for user of stun server. Required.

blConfig

  • showCameraSelect (boolean) - flag allowing camera selection. Required.

  • callbacks (object) - object with callback hooks. Available next hooks:

    • onValidate - the function that will be called after validation response received.

    • onError - the function that will be called on error.

  • applicationFields (TApplicantConfiguration) - setting up applicant fields that should be displayed during registration or authorization. The values of these fields will be sent to the request to create an applicant. Required. The accepted value is an object with the following content:

    applicationFields: {
    firstName: { enabled: false },
    lastName: { enabled: false },
    phone: { enabled: false },
    email: { enabled: true },
    referenceId: { enabled: false },
    };

interfaceConfig

  • mountElement (string) - Id of an element on the page where the component will be integrated. Required.

  • language (string) - current language. Required.

  • locales (TLocales) - custom locales for changing texts. For ease of use, we recommend writing one file with locales and using it in all configurations of the component. The accepted value is an object with the following content:

  locales: {
en: {
pages: {
Login: {
Authorization: 'Authorization',
Registration: 'Registration',
LoginButton: 'Continue',
InvalidEmail: 'Invalid email format',
MaxLengthField: 'Maximum field length 150 characters',
IsRequired: 'This field is required',
firstName: 'First name',
lastName: 'Last name',
phone: 'Phone',
email: 'Email',
referenceId: 'ReferenceId',
WrongPhone: 'Incorrect phone number',
},
Register: {
Header: 'Registration',
RegisterDescription1: 'Registering as ',
RegisterDescription2: 'Please complete the registration',
RegisterButton: 'Submit',
BackToLoginButton: 'Back',
DontMove: "Please don't move. Establishing a connection",
EstimateVideo: 'Checking the image quality',
Update: 'Update',
Processing: 'Processing in progress',
LoadModels: 'Loading models',
LoadVideoForm: 'Connecting the camera',
},
Authorize: {
Header: 'Authorization',
AuthorizeDescription1: 'Authorizing as ',
AuthorizeDescription2: 'Please complete the authorization',
AuthorizeButton: 'Submit',
BackToLoginButton: 'Back',
DontMove: "Please don't move. Establishing a connection",
EstimateVideo: 'Checking the image quality',
Update: 'Update',
Processing: 'Processing in progress',
LoadModels: 'Loading models',
LoadVideoForm: 'Connecting the camera',
},
Errors: {
FaceValidationError: 'The image did not pass verification',
AntispoofingValidationError: 'Liveness check failed',
LowImageQuality: 'Poor image quality',
NoFacesFound: 'No face found in the image',
SomeError: 'An error occurred, please try again later',
FacesDontBelongApplicant: 'Face matching check failed',
IDontSeeYou: "I can't see you",
MoveFaceOnCenter:
'Please position yourself so that your face is in the center of the circle on the screen',
LookAtCamera: 'Please, turn your face to the camera',
LittleFace: 'Move closer to the camera',
BigFace: 'Move further away from the camera',
AbortConnection:
'A connection to the server could not be established. Check the quality of the Internet and the web camera you are using.',
SlowEnternet:
'You have a slow internet connection. Image quality assessment may take longer',
InCorrectCamera:
'The selected camera is not available or does not meet the minimum requirements',
NoCamera: 'No cameras available',
NoPermission:
'Permission to access the camera was not obtained. For further work, allow access to the camera in your browser settings.',
MoreFaces: 'Many faces in the frame',
SafariError:
'Unfortunately, your browser is temporarily unsupported at the moment',
BackToLoginButton: 'Back',
ApplicantNotFound: 'Incorrect data entered',
ApplicantAlreadyExist: 'This user already exists',
},
Success: {
SuccessHeader: 'You have successfully passed verification',
},
},
}
};

Registration component initialization example:

import TDVOnboarding from '@tdvc/face-onboarding';
import {
TBLConfig,
TInterfaceConfig,
TServerConfig,
} from '@tdvc/face-onboarding/dist/types';
import '@tdvc/face-onboarding/dist/css/style.css';

const serverConfig: TServerConfig = {
baseUrl: 'http://127.0.0.1:5173',
bafToken: 'sk_00000000-0000-0000-0000-000000000000',
platformToken: '00000000-0000-0000-0000-000000000000',
lrsToken: '00000000-0000-0000-0000-000000000000',
lrsDecryptKey: '_iR_mxSoU4CLK5ReMmfck3zeKPgIiUhNLOKZYyszuCU=',
iceServers: [
{
ip: '127.0.0.1',
port: '32461',
transport: 'tcp',
user: 'user',
pass: 'pass',
},
],
};
const interfaceConfig: TInterfaceConfig = {
language: 'en',
mountElement: 'registrationEl',
locales,
};
const blConfig: TBLConfig = {
showCameraSelect: true,
applicationFields: {
firstName: { enabled: false },
lastName: { enabled: false },
phone: { enabled: false },
email: { enabled: true },
referenceId: { enabled: false },
},
};

const lib = new TDVOnboarding.Register(
serverConfig,
interfaceConfig,
blConfig
);

Methods

Destroy

The method completely dismantles the Web Component.

Example: img.png

With documents

Further instructions for installing and configuring the Web Component are suitable when using 3DiVi BAF with documents. In this case, you need to use tdvc-document-onboarding web component.

Install Web Component

Web Component is supplied as an npm package in the form of a .tgz archive. To install the Web Component, place it in the root of your project next to the package.json file.

In package.json in the dependencies section add the line:

"@tdvc/document-onboarding": "tdvc-document-onboarding-{version}.tgz".

The archive version may differ. Example of the final package.json file:

img.png

After this, call the npm install command, which will install the library into your project.

Import and Use Web Component

Import the library and the styles. If needed, you can overwrite the styling. Example of importing a library and styles:

img.png

Now initialize the Web Component. To do this, fill out the configuration file described below:

Description of the Web Component configuration
This section describes all available configuration fields of the Web Component:
  • el (string) - id of the element on the page where the Web Component is integrated (required field).

  • applicantId (string) - applicant id (required field).

  • domainId (string) - id of the domain that contains settings and styles for the Web Component (required field).

  • domainApi (string) - URL address for getting access to API (required field).

  • publicKey (string) - public key for getting access to API (required field).

  • isAuth (boolean) - flag used to indicate that only user authorization is required.

  • faceOnly (boolean) - flag used to indicate that registration and authorization should be by face only.

  • chunkPublicPath (string) - path to the folder with chunks. Specify the path on the server if you need to move the folder to a different location. The default path is 'networks'.

  • networkUrl (string) - path to the folder with neural networks. Specify the path on the server if you need to move the folder to a different location. The default path is 'networks'.

  • useCDN (boolean) - flag is enabled if you need to load 'networks' from a CDN, and not from your domain.

  • preferApiConfig (boolean) - flag is enabled if you prefer to use the TDV library configuration sent from BAF API instead of the configuration used when initializing the shell.

  • hideDocumentTitle (boolean) - this option enables/disables the display of document titles.

  • processingImageFormat (string) - this option switches the image format used for image processing.

  • callbacks (object) - an object with callback functions. The following functions are available:

    • onChange - callback function that will be called after each step has passed. The return value is an object with a type and an image.

    • onCameraError - function called if the camera is unavailable. The response value is an object with an error code and a message.

    • onReset - callback function that will be called after all steps are reset. The return value is an object with steps.

    • onRetakeHook - a function that will be called before resetting the current step. The return value is the object with the current step.

    • onValidate - a function that will be called after receiving a verification response. The return value is an object with verification information.

    • onError - a function that will be called in case of an error. The response value is an object with an error code and a message.

    • onReloaded - a function that will be called after the component reload is completed. This function doesn't return a value.

    • onMounted - a function that will be called on the mounted component. This function doesn't return a value.

    • submit - callback function that will be called after all steps have been completed. The return value is an object with the following content:

img.png

Example of Web Component initialization:

img.png

Methods

Restart

The method completely restarts the Web Component with the configuration with which it was initialized.

Example: img.png

Set Applicant

The method restarts the component with the passed applicant and the configuration with which it was initialized.

Example: img.png

Update config

The method restarts the component with the passed configuration.

Example: img.png