@dataleon/web-sdk
v1.0.6
Published
SDK Web pour l'intégration Dataleon
Readme
Dataleon Web SDK
JavaScript SDK to integrate Dataleon verification into your web applications via a secure modal.
Features
- Opens a modal with an iframe for the Dataleon verification flow.
- Simple usage with a session URL provided by your back-office or Dataleon API.
- Handles session end statuses (
STARTED,FINISHED,FAILED,ABORTED,CANCELED) via callback.
Requirements
- An active Dataleon account.
- A session URL generated by your server or the Dataleon back-office.
Installation
Add the SDK to your project:
Via npm
npm install --save @dataleon/web-sdkOr via a <script> tag
<script src="https://customer-assets.eu-west-1.dataleon.ai/sdk/js/latest/dataleon.min.js"></script>Usage
1. Import
import { Dataleon } from '@dataleon/web-sdk';
// or in CommonJS:
// const { Dataleon } = require('@dataleon/web-sdk');2. Create and open the modal
const sdk = new Dataleon({
sessionUrl: 'https://dataleon.io/verify/session/SESSION_ID', // Replace with your session URL
width: 400, // Modal width (optional, default: 400)
height: 600 // Modal height (optional, default: 600)
});
// Set the result callback
sdk.onResult(function(status) {
if (status === "STARTED") {
// Verification started
} else if (status === "FINISHED") {
// Verification successful
} else if (status === "FAILED") {
// Verification failed
} else if (status === "ABORTED") {
// User aborted
} else if (status === "CANCELED") {
// User canceled
}
});
// Open the modal
sdk.openModal();3. Manual close (optional)
You can close the modal at any time with:
sdk.closeModal();Full example
import { Dataleon } from '@dataleon/web-sdk';
const sdk = new Dataleon({
sessionUrl: 'https://dataleon.io/verify/session/SESSION_ID'
});
sdk.onResult(function(status) {
alert('Verification status: ' + status);
});
sdk.openModal();Notes
- The modal opens centered on the screen and covers the rest of the page.
- The SDK listens for postMessage events from the
dataleon.iodomain for security. - Camera/microphone permissions are handled automatically by the browser via the iframe.
For more information, see the official Dataleon documentation.
