Skip to main content
Version: v2

initialize

The initialize function creates an instance of the Beyond Identity SDK class Embedded, providing access to the rest of the SDK functions. The initialize function must be called first, before any other SDK functions.

Dependencies​

The initialize function requires the Beyond Identity SDK.

yarn add @beyondidentity/bi-sdk-js

or

npm install @beyondidentity/bi-sdk-js

Prerequisites​

Before making a call to initialize, you must import the Embedded namespace from the SDK.

import { Embedded } from '@beyondidentity/bi-sdk-js';

Parameters​

ParameterTypeDescription
configConfigAn optional configuration object.
↳ allowedDomainsstring[]An optional list of allowed domains.
↳ loggerLogAn optional interface for logging with method write(...data: any[]): void;.

Returns​

On success, returns an instance of the Embedded class.

Examples​

Example: create an instance of the Embedded namespace prior to calling its functions​

// --- Initialize with required arguments
try {
const embedded = await Embedded.initialize();
console.log("Initialization successful", embedded);
} catch (error) {
console.error("Initialization failed:", error);
}

// --- Initialize with required and optional arguments
const config = {
allowedDomains: ["example.com", "another-example.com"],
logger: function (logType, message) {
console.log(`[${logType}] ${message}`);
},
};

try {
const embedded = await Embedded.initialize(config);
console.log("Initialization successful", embedded);
} catch (error) {
console.error("Initialization failed:", error);
}