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

1.0.5-dev.2 • 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,

    // Enable real user monitoring (Default: false)
    rum: 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.

Test Locally

Create an .env file like this:

SERVICE_URL=http://localhost:8080
SIGNING_KEY=b92a8e9113423356fec9574f7c941554ef824b4b
ORG_ID=64e748156c67598e34d5ccdd
EXTERNAL_USER_ID=kosmas2

and run:

npm run dev

To test with the current version modify the start command to force using current version (and not the version configured in the org)

sdk.start(true);

Package Sidebar

Install

npm i @quadible/web-sdk

Weekly Downloads

4

Version

1.0.5-dev.2

License

ISC

Unpacked Size

1.61 MB

Total Files

94

Last publish

Collaborators

  • raelgor
  • n.palaghias