UNPKG

@quadible/web-sdk

Version:

The web sdk for Quadible's behavioral authentication service.

75 lines (49 loc) 2.27 kB
![image](https://user-images.githubusercontent.com/3382344/74355490-9f9d3e80-4dc5-11ea-97aa-711adcd139f6.png) # Web SDK This package helps you integrate Quadible's behavioural authentication into a web client. ## Installation ### npm ```sh npm i -S @quadible/web-sdk ``` ## Usage Typescript is supported out of the box (no need for `@types`). ```ts import BehavioralAuthSDK from '@quadible/web-sdk'; (async () => { const client = new BehavioralAuthSDK({ apiKey: '<api-key>', // How often to push data to the server. Default: 15 seconds pushIntervalMs: 15_000, // Enable periodic collection of frames from the webcam useWebcam: true, lockScreenOnAuthLost: true, // Enable compression (default: false), compression: true, serviceUrl: 'https://api.quadible.io', }); // Start collecting and pushing biometrics to the service client.start(); // Assign a photo to a user client.assignPhotoToUser(base64ImageDataUrl); // Manually send a frame for authentication const result = await client.authenticateFrame(base64ImageDataUrl); // Show popup dialog to assign photo (throws if canceled) const result = await client.assignPhotoToUserPopup({ clickOutsideToClose: true, }); // Later, ask the service to authenticate the user const result = await client.authenticate(); client.stop(); // Clear the session (e.g. when the user logs out) client.clearSession(); // Listen for errors and warnings client.on('error', (error) => console.log(error)); client.on('warning', (warning) => console.log(warning)); })(); ``` If not loaded as a module, you can use `window.BehavioralAuthSDK`. Copyright 2024 Quadible This software is the property of Quadible and is protected under copyright law. Unauthorized copying, distribution, or use of this software, in whole or in part, without express permission from Quadible is strictly prohibited. This repository and its contents are for authorized internal use only. External sharing or modification is not permitted unless written consent is obtained from Quadible. For inquiries about permitted usage or licensing, contact [info@quadible.co.uk](mailto:info@quadible.co.uk).