3. Integrate Bayun SDK

3.1 Add Bayun SDK into Project

  1. Import bayun.js file into index.html

  2. Copy the bayun.js file in the project public folder.

<script src="bayun.js"></script>

3.2 Add Bayun Dependencies

The following dependency is needed to use Facial Recognition for added protection at the time of login.

  1. Import vishwam-lib.js file into index.html

  2. Copy the vishwam-lib.js and models directory in the project folder.

<script src="vishwam-lib.js"></script>

3.3 Initialize BayunCore

Get BayunCore instance with appId, appSecret, appSalt, localStorageMode, enableFaceRecognition.

  • appId : Provided when an app is registered with Bayun.

  • appSecret : Provided when an app is registered with Bayun.

  • appSalt : Provided when an app is registered with Bayun.

  • localStorageMode : It can be SESSION_MODE or EXPLICIT_LOGOUT_MODE

    • SESSION_MODE : User data is encrypted and stored locally in sessionstorage. User data gets cleared when the page session ends and user will have to login with Bayun again.

    • EXPLICIT_LOGOUT_MODE : User data is encrypted and stored locally in localstorage. User data is kept in localstorage until the user logs out.

  • enableFaceRecognition : Boolean variable to determine whether or not to enable Face ID registration for a new user as an extra security measure. This Face ID works independently of the device-specific biometric (if any) available on the user’s end-device, and works from any device with a camera (including laptops and Android phones that may not have the built-in Face ID functionality). If enabled at the time of BayunCore init, each user can still decide on their own at the time of account registration if they want to also register their Face ID. If so chosen by the user at the time of account registration, they will be prompted to validate their Face ID every time they login from a new device. Check Register without Password function for more details.

  • baseURL : Provided when an app is registered with Bayun.

  • bayunServerPublicKey : Provided when an app is registered with Bayun.

const appId = "<appId>"; // provided on admin panel
const appSecret = "<appSecret>"; // provided on admin panel
const appSalt = "<appSalt>"; // provided on admin panel
const localStorageMode = BayunCore.LocalDataStorageMode.EXPLICIT_LOGOUT_MODE;
const enableFaceRecognition = true;
const baseURL = "<baseURL>"; // provided on admin panel
const bayunServerPublicKey = "<bayunServerPublicKey>"; // provided on admin panel

const bayunCore = BayunCore.init(appId, appSecret, appSalt, localStorageMode, baseURL, bayunServerPublicKey, enableFaceRecognition);

Last updated