Variable: initialize()
initialize: (Initializes the SDK with the provided parameters. Despite the SDK can be used without calling this function beforehand, in stateful environments like in a single page application running in a browser, it is recommended. This is true because theinitializeParams
) =>void
initialize
function accepts some parameters that in case of not
being passed to it, they would have to be passed in every function call made
to the SDK.
In order to easier call functions afterwards, this function has to be called
before using any other SDK functions, and as the bare minimum, it requires an
access token.
It’s 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 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 toENVIRONMENTS.PRODUCTION
. UseENVIRONMENTS.STAGING
to set the SDK to staging.branch
: Optional parameter to set the SDK’s branch. This is only relevant when theenvironment
is set toENVIRONMENTS.STAGING
. The possible values areBRANCHES.MASTER
,BRANCHES.SANDBOX
andBRANCHES.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 be rendered.mfaPreference
: The MFA preference to use for the operations. This can be eitherMFA_METHODS.PASSKEY
,MFA_METHODS.PAIRED_DEVICE
orMFA_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.