Confirms a user’s account by verifying the username and confirmation code. Optionally, tags can be provided.
The username of the user to confirm.
The code sent to the user for verification.
Optional
tags: string[]Optional tags associated with the user.
A promise that resolves with an ESPAPIResponse
object if the user is successfully signed up.
Initiates the forgot password flow for a user by sending their username to the API.
The username of the user who wants to reset their password.
A promise that resolves with an ESPAPIResponse
indicating success.
Retrieves the currently logged-in user.
This method checks if the access token is available and valid. If the access token is expired, it attempts to refresh the session using the refresh token. If successful, it returns an instance of the ESPRMUser class containing the user's tokens. If no valid access token is found, it returns null.
A promise that resolves to an instance of ESPRMUser if the user is logged in, or null if not.
Logs in a user by their username and password, returning an ESPRMUser
instance upon success.
The username of the user logging in.
The password of the user.
A promise that resolves to an instance of ESPRMUser
containing the user's tokens.
Logs in a user using OAuth by first requesting an OAuth code and then exchanging it for tokens. This method combines the functionality of requesting OAuth code and logging in with the code.
The identity provider for which to request an OAuth login code.
A promise that resolves to an instance of ESPRMUser
containing user tokens.
Logs in a user using an OTP (One-Time Password) and a session token.
The username of the user attempting to log in.
The OTP received by the user.
The session token associated with the OTP request.
A promise that resolves to an instance of ESPRMUser
containing user tokens.
Registers a new user by providing their username and password.
The username for the new account.
The password for the new account.
A promise that resolves to an ESPAPIResponse
indicating the success in sending sign up code.
Sets a new password for a user by providing their username, a new password, and a verification code.
The username of the user who is setting a new password.
The new password to be set for the user.
The verification code used to authorize the password change.
A promise that resolves to an ESPAPIResponse
indicating the success of the operation.
The
ESPRMAuth
class provides comprehensive authentication functionality for users. It includes methods for account sign-up, login, password management, OTP-based authentication, and OAuth-based login flows. Key features include:This class simplifies the integration of authentication mechanisms in applications built on the ESP RainMaker ecosystem.