▸ clearUser(options?): Promise<boolean>
Clears the user context for all subsequent events in the browser session
| Name | Type | Description |
|---|---|---|
options? | Object | Reserved for future use |
Promise<boolean>
Indicates if the call succeeded
▸ 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). Use this when the code that completes authentication does not have access to the original login actionToken; otherwise, prefer reportActionResult() with result set to success and options.userId.
| Name | Type | Description |
|---|---|---|
userId | string | Opaque identifier of the user in your system |
options? | Object | Reserved for future use |
Promise<boolean>
Indicates if the call succeeded
▸ triggerActionEvent(actionType, options?): Promise<ActionResponse>
Reports a user action event to the SDK
| Name | Type | Description |
|---|---|---|
actionType | string | Type of user action event that was predefined in the Mosaic server |
options? | ActionEventOptions | - |
Promise<ActionResponse>
Indicates if the call succeeded
▸ reportActionResult(actionToken, result, options?): Promise<boolean>
Reports the result of an action for which a recommendation was previously issued. This includes whether the user successfully completed the action and, when applicable, the type of challenge that was presented. The provided actionToken identifies the original action record. If options.userId is included, Mosaic updates the user ID on that original action record. For successful login-type actions, it also sets that same user for subsequent browser-session events. This is the recommended way to report a successful login when the original actionToken is available.
| Name | Type | Description |
|---|---|---|
actionToken | string | The token returned when the action was triggered by triggerActionEvent() method |
result | ActionResult | The outcome of the action |
options? | ActionResultOptions | Additional context associated with the action result |
Promise<boolean>
Indicates if the call succeeded
▸ 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.
Promise<string>
The session token.
▸ 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.
| Name | Type | Description |
|---|---|---|
actionType? | string | null | Optional. Binds the token to a specific action type (e.g., "login", "transaction"). Default: null. |
expirationSeconds? | number | Optional. Sets the token validity period in seconds. Default: 300 (5 minutes). Max: 3600 (60 minutes). |
Promise<string>
The secured session token (JWT).