@quadible/web-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.5-rc.26 • Public • Published

image

Web SDK

This package helps you integrate Quadible's behavioural authentication into a web client.

Installation

npm

npm i -S @quadible/web-sdk

cdn

<script src="https://api.quadible.com/lib/web-sdk/1.0.0/quadible.min.js"></script>

1-line auto start

You can load and start the library directly by providing your api key:

<script src="https://api.quadible.com/lib/web-sdk/1.0.0/<api-key>/quadible.min.js"></script>

Usage

Typescript is supported out of the box (no need for @types).

import BehavioralAuthSDK from '@quadible/web-sdk';

(async () => {
    const client = new BehavioralAuthSDK({ 
        apiKey: '<api-key>',
        clientId: '<client-id>',
        clientSecret: '<client-secret>',
        userId: '<app-user-id>',

        // How often to push data to the server. Default: 15 seconds
        pushIntervalMs: 20000,

        // Enable periodic collection of frames from the webcam
        useWebcam: true,
        lockScreenOnAuthLost: true
    });

    // 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();

    // Change user id if needed
    client.stop();
    client.setUserId('<app-user-id>');
    client.start();

    // 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.

If using the 1-line auto start method, the client instance can be found under window._bauthsdk.

Package Sidebar

Install

Weekly Downloads

235

Version

1.0.5-rc.26

License

ISC

Unpacked Size

1.53 MB

Total Files

94

Last publish

Collaborators

  • raelgor
  • n.palaghias