Skip to main content
This is a complete reference for the SnackBaseClient class, the main entry point for the SnackBase JavaScript SDK.

Constructor

Create a new SnackBaseClient instance:

Configuration

Properties

Auth State

Services

Methods

Configuration

getConfig()

Get the current client configuration.
Returns: The merged configuration object with defaults applied.

Authentication

login(credentials)

Authenticate with email and password.
Alias for: client.auth.loginWithPassword()

logout()

Log out the current user.
Alias for: client.auth.logout()

register(data)

Register a new user and account.
Alias for: client.auth.register()

refreshToken()

Refresh the access token.
Alias for: client.auth.refreshToken()

getCurrentUser()

Get the current authenticated user profile.
Alias for: client.auth.getCurrentUser()

forgotPassword(data)

Initiate password reset flow.
Alias for: client.auth.forgotPassword()

resetPassword(data)

Reset password using a token.
Alias for: client.auth.resetPassword()

verifyEmail(token)

Verify email using a token.
Alias for: client.auth.verifyEmail()

resendVerificationEmail()

Resend the verification email to the current user.
Alias for: client.auth.resendVerificationEmail()

getSAMLUrl(provider, account, relayState?)

Generate SAML SSO authorization URL.
Alias for: client.auth.getSAMLUrl()

handleSAMLCallback(params)

Handle SAML callback.
Alias for: client.auth.handleSAMLCallback()

getSAMLMetadata(provider, account)

Get SAML metadata.
Alias for: client.auth.getSAMLMetadata()

Events

on(event, listener)

Subscribe to authentication events.
Returns: Unsubscribe function Events:
  • auth:login - User logged in
  • auth:logout - User logged out
  • auth:refresh - Token refreshed
  • auth:error - Authentication error
Example:

Complete Example

Next Steps