Variable: initialize()

initialize: (initializeParams) => void

Initializes the SDK with the provided parameters. This function has to be called before using any other SDK functions, and as the bare minimum, it requires an access token.

Parameters

initializeParams

InitializeParams

An object with the parameters to initialize the SDK. The only required parameter is the accessToken.

  • accessToken: The access token to authenticate the user. This has to be previously generated using the OAuth authentication flow.
  • environment: Optional parameter to set the SDK’s environment. If not provided, the SDK will default to ENVIRONMENTS.PRODUCTION. Use ENVIRONMENTS.STAGING to set the SDK to staging.
  • branch: Optional parameter to set the SDK’s branch. This is only relevant when the environment is set to ‘staging’. The possible values are BRANCHES.MASTER, BRANCHES.SANDBOX and BRANCHES.QA. If not provided, the SDK will default to BRANCHES.MASTER.
  • operationSettings: Optional settings to configure the SDK’s operations that will be performed after the initialization. This can be also provided when calling the operation functions themselves.
  • uiParentElementId: The id of the DOM element where the SDK will be rendered.
  • mfaPreference: The MFA preference to use for the operations. This can be either MFA_METHODS.PASSKEY, MFA_METHODS.PAIRED_DEVICE or MFA_METHODS.SMS_OTP. If not provided, the SDK will default to MFA_METHODS.PASSKEY.

Returns

void

Throws

InvalidParametersError If the access token is not provided or the specified parameters don’t comply with the expected format.

Examples

// The simplest way to initialize the SDK is to provide an access token.
import { initialize } from '@qonto/embed-sdk/common';

const initializeParams = {
  accessToken: 'an-access-token',
};

initialize(initializeParams);
// Initializes the SDK to work in the staging environment, concretely in the sandbox branch. Also, it sets the
//  ID of the DOM element where the SDK will render the multi-factor authentication (MFA) UI if a sensitive
//  operation is requested after SDK initialization.
import { initialize, constants } from '@qonto/embed-sdk/common';

const initializeParams = {
  accessToken: 'an-access-token',
  environment: constants.ENVIRONMENTS.STAGING,
  operationSettings: {
    uiParentElementId: 'mfa-container',
  },
};
initialize(initializeParams);