Skip to content

API

This section details the methods and events available for interacting with the SDK, providing comprehensive control over its functionalities.

Available methods and properties

You can obtain an instance of the SDK through a query selector and then leverage the methods outlined below.

/** Get Instance from rendered tag in the DOM */
const VDVideo = document.querySelector('vd-video')

/** Call initializeSdk method */
VDVideo.initializeSdk()

An instance of the SDK class is also globally available via window.vdVideo.VDVideo. This allows you to access static values or perform operations before attaching the SDK to the DOM.

initializeSdk

This method initializes and configures the SDK. It must be called before using any other SDK functionality.

For a practical usage example, refer to the Initialize installation section.

Parameters

config (required) — string | object Defines the properties required to configure the SDK:

  • If provided as a string, it must be the path to the configuration file.
  • If provided as an object, it must be a valid configuration object that complies with the defined schema.

See the Configuration object example for reference.

Return Value

Promise<boolean> — Resolves to true if the SDK was successfully initialized.

Example

const config = "myAssetsPaths/config.json"
const result: Promise<boolean> = await VDVideo.initializeSdk(config);

getPackageVersion()

Retrieves the current version of the SDK.

Return Value

string — Returns a string representing the SDK version, in the format x.x.x.

Example

const sdkVersion = VDVideo.getPackageVersion();

events

A static property that exposes all public SDK event names. Useful for subscribing to and managing SDK-related events dynamically.

Return Value

string[] — Returns an array of strings, each representing a public SDK event.

Example

const events = window.vdVideo.VDVideo.events;
console.log(events); // ['VD_mounted', 'VD_loaded', ...]

Dispatched events

The SDK dispatches a set of events to communicate that the corresponding actions have been taken. Each event is logged in the console by the SDK in this manner event_name detail, and dispatched as CustomEvent containing a detail as described below:

Event Name Event Detail Event Trigger
VD_mounted "sdkName": "VD-VIDEO", "type": "info", "legacyEvent": "VDVideo_mounted", "legacyDetailIsUndefined": true When the SDK is mounted
VD_loaded "sdkName": "VD-VIDEO", "type": "info", "flowType": "video" When the SDK is fully loaded
VD_instructions "sdkName": "VD-VIDEO", "type": "info", "flowType": "video" When initial instructions are displayed
VD_cameraPermissionsGranted "sdkName": "VD-VIDEO", "type": "info", "flowType": "video" When the user grants camera permissions
VD_cameraStarted "sdkName": "VD-VIDEO", "type": "info", "cameraLabels": "Camera Label", "legacyEvent": "VDVideo_cameraStarted", "legacyDetailIsUndefined": true, "flowType": "video" When the camera starts successfully
VD_cameraVideoPlayStarted "type": "info", "sdkName": "VD-VIDEO", "size": {"width": 1920, "height": 1080}, "cameraLabels": "Logitech StreamCam (046d:0893)", "legacyDetailIsUndefined": true, "flowType": "video" When the camera video playback begins
VD_cameraRecorderSetup "sdkName": "VD-VIDEO", "legacyEvent": "VDVideo_standardVideoRecorderStart", "isAlternative": false When the camera recording is configured
VDVideo_faceDetection {} When face detection is completed
VDVideo_obverseDetection {} When the front side of the document is captured
VD_cameraRecorderStop "sdkName": "VD-VIDEO", "_recordedBlob": {}, "isAlternative": false, "alternativeBlob": null, "legacyEvent": "VDVideo_standardVideoRecorderStop" When the camera recording is stopped
VDVideo_reverseDetection {} When the back side of the document is captured
VD_successTickFinish "flowType": "video", "legacyDetailIsUndefined": true, "legacyEvent": undefined, "sdkName": "VD-VIDEO", "type": "info" When the success tick animation finishes
VD_capture "flow": "video", "type": "info", "sdkName": "VD-VIDEO" When the video capture is complete
VD_processFinished "sdkName": "VD-VIDEO", "type": "info", "legacyDetailIsUndefined": true, "flowType": "video" When the whole process is finished, either successfully or with an error
VD_cameraFailureDefaultError detail: {"type": "error", "errorType": "The camera of the device has not started.", "sdkName": "VD-VIDEO", "legacyEvent": "VDVideo_cameraFailureError", "legacyDetailIsUndefined": true, "flowType": "video"} When camera can't be initialised for any reason
VD_cameraFailureVideoNotFoundError "type": "error", "errorType": "The video has not started on the device.", "sdkName": "VD-VIDEO" When no usable camera is found to perform the flow
VD_cameraFailurePermissionError "type": "error", "errorType": "The browser does not accept the permissions of the camera", "sdkName": "VD-VIDEO" When camera permissions are denied
VD_detectionTimeout detail: {"sdkName": "VD-VIDEO", "type": "info", "legacyEvent": "VDVideo_detectionTimeout", "legacyDetailIsUndefined": true, "flowType": "video"} When the flow ends due to timeout
VD_closeButtonClicked "sdkName": "VD-VIDEO", "type": "info", "legacyDetailIsUndefined": true, "flowType": "video" When the close button is clicked and user exits from confirmation modal
VD_orientationStyleChanged "type": "info", "sdkName": "VD-VIDEO", "data": {"sdkInPortrait": false}, "flowType": "video" When screen orientation changes to an unsupported layout
VD_orientationChanged "type": "info", "sdkName": "VD-VIDEO", "data": {"orientation": "portrait"} When screen orientation changes to an unsupported layout
VD_restarProcess "sdkName": "VD-VIDEO", "type": "error", "code": 8002, "errorType": "SDK detection fails and should be restarted" When the process needs to be restarted due to an error
VD_restartFromModal "sdkName": "VD-VIDEO", "type": "info", flowType: "video" When the process needs to be restarted after help modal
VD_processRestarted "sdkName": "VD-VIDEO", "type": "info", "flowType": "video" When the process restarts due to an error
VD_restartClicked "type": "info", "sdkName": "VD-VIDEO", "legacyDetailIsUndefined": true, "flowType": "video" When the restart button is clicked after feedback screen
VD_loseFocus detail: {"sdkName": "VD-VIDEO", "type": "info", "flowType": "video"} When the user has lost the focus on the browser tab.
VD_unmounted "sdkName": "VD-VIDEO","type": "info","legacyEvent": "VDVideo_unmounted", "legacyDetailIsUndefined": true When the SDK is unmounted
VD_loseFocus detail: {"sdkName": "VD-VIDEO", "type": "error", "flowType": "videos"} When the window loses focus

VD_cameraFailurePermissionError in Safari

In safari these permission errors can happen indefinitely, please visit the FAQ page for more information.