Skip to content

Functions

clearUser

clearUser(options?): Promise<boolean>

Clears the user context for all subsequent events in the browser session

Parameters

NameTypeDescription
options?ObjectReserved for future use

Returns

Promise<boolean>

Indicates if the call succeeded


setAuthenticatedUser

setAuthenticatedUser(userId, options?): Promise<boolean>

Sets the user context for all subsequent events in the browser session (or until the user is explicitly cleared). It should be set only after you've fully authenticated the user (including, for example, any 2FA that was required)

Parameters

NameTypeDescription
userIdstringOpaque identifier of the user in your system
options?ObjectReserved for future use

Returns

Promise<boolean>

Indicates if the call succeeded


triggerActionEvent

triggerActionEvent(actionType, options?): Promise<ActionResponse>

Reports a user action event to the SDK

Parameters

NameTypeDescription
actionTypestringType of user action event that was predefined in the Mosaic server
options?ActionEventOptions-

Returns

Promise<ActionResponse>

Indicates if the call succeeded


getSessionToken

getSessionToken(): Promise<string>

Get a session token, which can be used to trigger an action event via backend API. Requires setting enableSessionToken to true in the SDK configuration.

Returns

Promise<string>

The session token.

getSecureSessionToken

getSecureSessionToken(actionType?, expirationSeconds?): Promise<string>

Get a secured session token, the recommended token type for backend integrations. It adds device binding and stronger protection against token theft and replay compared to the regular session token.

Parameters

NameTypeDescription
actionType?string | nullOptional. Binds the token to a specific action type (e.g., "login", "transaction"). Default: null.
expirationSeconds?numberOptional. Sets the token validity period in seconds. Default: 300 (5 minutes). Max: 3600 (60 minutes).

Returns

Promise<string>

The secured session token (JWT).