Variable: initialize()
initialize: (Initializes the SDK with the provided parameters. Calling this function is not mandatory, but in stateful environments like in a single page application running in a browser, it is recommended. TheinitializeParams) =>void
initialize function is useful
to pass data to the SDK that otherwise would have to be passed in every
function call.
In order to call functions afterward without having to pass repetitive
parameters to them, it is helpful to call this function before using any
other SDK functions. In client side environments, it expects at least the
operationSettings.proxyEndpointDescriptor param, while in server side
environments it expects at least an accessToken.
It’s also useful to rely on the exposed SDK constants to pass some of the
parameters.
Parameters
initializeParams
InitializeParams
An object with the parameters to initialize the SDK.
The only required parameter is the proxyEndpointDescriptor in client
environments or accessToken in server environments.
accessToken: The access token to authenticate the user. This has to be previously generated using the OAuth authentication flow. Only needed in server side usage, and not recommended in client side.environment: Optional parameter to set the SDK’s environment. If not provided, the SDK will default toENVIRONMENTS.PRODUCTION. UseENVIRONMENTS.STAGINGto set the SDK to staging.branch: Optional parameter to set the SDK’s branch. This is only relevant when theenvironmentis set toENVIRONMENTS.STAGING. The possible values areBRANCHES.MASTER,BRANCHES.SANDBOXandBRANCHES.QA. If not provided, the SDK will default toBRANCHES.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 render UI in those functions that involve rendering UI in the caller website. Normally, it will make more sense to add this param when calling functions that require rendering UI, because each function call will likely render the UI under a different parent.mfaPreference: The MFA preference to use for the operations. This can be eitherMFA_METHODS.PASSKEY,MFA_METHODS.PAIRED_DEVICEorMFA_METHODS.SMS_OTP. If not provided, the SDK will default toMFA_METHODS.PASSKEY.locale: Optional 2 digit language code to set the language in which the UI elements injected by the SDK will show the text.
Returns
void
Throws
InvalidParametersError If the access token is not provided or the specified
parameters don’t comply with the expected format.