Skip to content

FluxbaseAuth

new FluxbaseAuth(fetch, autoRefresh, persist): FluxbaseAuth

ParameterTypeDefault value
fetchFluxbaseFetchundefined
autoRefreshbooleantrue
persistbooleantrue

FluxbaseAuth

disable2FA(password): Promise<DataResponse<TwoFactorDisableResponse>>

Disable 2FA for the current user (Supabase-compatible) Unenrolls the MFA factor

ParameterTypeDescription
passwordstringUser password for confirmation

Promise<DataResponse<TwoFactorDisableResponse>>

Promise with unenrolled factor id


enable2FA(code): Promise<DataResponse<TwoFactorEnableResponse>>

Enable 2FA after verifying the TOTP code (Supabase-compatible) Verifies the TOTP code and returns new tokens with MFA session

ParameterTypeDescription
codestringTOTP code from authenticator app

Promise<DataResponse<TwoFactorEnableResponse>>

Promise with access_token, refresh_token, and user


exchangeCodeForSession(code): Promise<FluxbaseAuthResponse>

Exchange OAuth authorization code for session This is typically called in your OAuth callback handler

ParameterTypeDescription
codestringAuthorization code from OAuth callback

Promise<FluxbaseAuthResponse>


get2FAStatus(): Promise<DataResponse<TwoFactorStatusResponse>>

Check 2FA status for the current user (Supabase-compatible) Lists all enrolled MFA factors

Promise<DataResponse<TwoFactorStatusResponse>>

Promise with all factors and TOTP factors


getAccessToken(): null | string

Get the current access token

null | string


getCurrentUser(): Promise<UserResponse>

Get the current user from the server

Promise<UserResponse>


getOAuthProviders(): Promise<DataResponse<OAuthProvidersResponse>>

Get list of enabled OAuth providers

Promise<DataResponse<OAuthProvidersResponse>>


getOAuthUrl(provider, options?): Promise<DataResponse<OAuthUrlResponse>>

Get OAuth authorization URL for a provider

ParameterTypeDescription
providerstringOAuth provider name (e.g., ‘google’, ‘github’)
options?OAuthOptionsOptional OAuth configuration

Promise<DataResponse<OAuthUrlResponse>>


getSession(): Promise<FluxbaseResponse<object>>

Get the current session (Supabase-compatible) Returns the session from the client-side cache without making a network request

Promise<FluxbaseResponse<object>>


getUser(): Promise<FluxbaseResponse<object>>

Get the current user (Supabase-compatible) Returns the user from the client-side session without making a network request For server-side validation, use getCurrentUser() instead

Promise<FluxbaseResponse<object>>


getUserIdentities(): Promise<DataResponse<UserIdentitiesResponse>>

Get user identities (linked OAuth providers) - Supabase-compatible Lists all OAuth identities linked to the current user

Promise<DataResponse<UserIdentitiesResponse>>

Promise with list of user identities


linkIdentity(credentials): Promise<DataResponse<OAuthUrlResponse>>

Link an OAuth identity to current user - Supabase-compatible Links an additional OAuth provider to the existing account

ParameterTypeDescription
credentialsLinkIdentityCredentialsProvider to link

Promise<DataResponse<OAuthUrlResponse>>

Promise with OAuth URL to complete linking


onAuthStateChange(callback): object

Listen to auth state changes (Supabase-compatible)

ParameterTypeDescription
callbackAuthStateChangeCallbackFunction called when auth state changes

object

Object containing subscription data

NameType
dataobject
data.subscriptionAuthSubscription
const { data: { subscription } } = client.auth.onAuthStateChange((event, session) => {
console.log('Auth event:', event, session)
})
// Later, to unsubscribe:
subscription.unsubscribe()

reauthenticate(): Promise<DataResponse<ReauthenticateResponse>>

Reauthenticate to get security nonce - Supabase-compatible Get a security nonce for sensitive operations (password change, etc.)

Promise<DataResponse<ReauthenticateResponse>>

Promise with nonce for reauthentication


refreshSession(): Promise<FluxbaseResponse<object>>

Refresh the session (Supabase-compatible) Returns a new session with refreshed tokens

Promise<FluxbaseResponse<object>>


refreshToken(): Promise<FluxbaseResponse<object>>

Refresh the session (Supabase-compatible alias) Alias for refreshSession() to maintain compatibility with Supabase naming Returns a new session with refreshed tokens

Promise<FluxbaseResponse<object>>


resendOtp(params): Promise<DataResponse<OTPResponse>>

Resend OTP (One-Time Password) - Supabase-compatible Resend OTP code when user doesn’t receive it

ParameterTypeDescription
paramsResendOtpParamsResend parameters including type and email/phone

Promise<DataResponse<OTPResponse>>

Promise with OTP-style response


resetPassword(token, newPassword): Promise<DataResponse<AuthResponseData>>

Reset password with token (Supabase-compatible) Complete the password reset process with a valid token

ParameterTypeDescription
tokenstringPassword reset token
newPasswordstringNew password to set

Promise<DataResponse<AuthResponseData>>

Promise with user and new session


resetPasswordForEmail(email, _options?): Promise<DataResponse<PasswordResetResponse>>

Supabase-compatible alias for sendPasswordReset()

ParameterTypeDescription
emailstringEmail address to send reset link to
_options?objectOptional redirect configuration (currently not used)
_options.redirectTo?string-

Promise<DataResponse<PasswordResetResponse>>

Promise with OTP-style response


sendMagicLink(email, options?): Promise<DataResponse<MagicLinkResponse>>

Send magic link for passwordless authentication (Supabase-compatible)

ParameterTypeDescription
emailstringEmail address to send magic link to
options?MagicLinkOptionsOptional configuration for magic link

Promise<DataResponse<MagicLinkResponse>>

Promise with OTP-style response


sendPasswordReset(email): Promise<DataResponse<PasswordResetResponse>>

Send password reset email (Supabase-compatible) Sends a password reset link to the provided email address

ParameterTypeDescription
emailstringEmail address to send reset link to

Promise<DataResponse<PasswordResetResponse>>

Promise with OTP-style response


setSession(session): Promise<FluxbaseAuthResponse>

Set the session manually (Supabase-compatible) Useful for restoring a session from storage or SSR scenarios

ParameterTypeDescription
sessionobjectObject containing access_token and refresh_token
session.access_tokenstring-
session.refresh_tokenstring-

Promise<FluxbaseAuthResponse>

Promise with session data


setup2FA(issuer?): Promise<DataResponse<TwoFactorSetupResponse>>

Setup 2FA for the current user (Supabase-compatible) Enrolls a new MFA factor and returns TOTP details

ParameterTypeDescription
issuer?stringOptional custom issuer name for the QR code (e.g., “MyApp”). If not provided, uses server default.

Promise<DataResponse<TwoFactorSetupResponse>>

Promise with factor id, type, and TOTP setup details


signIn(credentials): Promise<FluxbaseResponse<SignInWith2FAResponse | AuthResponseData>>

Sign in with email and password (Supabase-compatible) Returns { user, session } if successful, or SignInWith2FAResponse if 2FA is required

ParameterType
credentialsSignInCredentials

Promise<FluxbaseResponse<SignInWith2FAResponse | AuthResponseData>>


signInAnonymously(): Promise<FluxbaseAuthResponse>

Sign in anonymously Creates a temporary anonymous user session

Promise<FluxbaseAuthResponse>


signInWithIdToken(credentials): Promise<FluxbaseAuthResponse>

Sign in with ID token (for native mobile apps) - Supabase-compatible Authenticate using native mobile app ID tokens (Google, Apple)

ParameterTypeDescription
credentialsSignInWithIdTokenCredentialsProvider, ID token, and optional nonce

Promise<FluxbaseAuthResponse>

Promise with user and session


signInWithOAuth(provider, options?): Promise<DataResponse<object>>

Convenience method to initiate OAuth sign-in Redirects the user to the OAuth provider’s authorization page

ParameterTypeDescription
providerstringOAuth provider name (e.g., ‘google’, ‘github’)
options?OAuthOptionsOptional OAuth configuration

Promise<DataResponse<object>>


signInWithOtp(credentials): Promise<DataResponse<OTPResponse>>

Sign in with OTP (One-Time Password) - Supabase-compatible Sends a one-time password via email or SMS for passwordless authentication

ParameterTypeDescription
credentialsSignInWithOtpCredentialsEmail or phone number and optional configuration

Promise<DataResponse<OTPResponse>>

Promise with OTP-style response


signInWithPassword(credentials): Promise<FluxbaseResponse<SignInWith2FAResponse | AuthResponseData>>

Sign in with email and password (Supabase-compatible) Alias for signIn() to maintain compatibility with common authentication patterns Returns { user, session } if successful, or SignInWith2FAResponse if 2FA is required

ParameterType
credentialsSignInCredentials

Promise<FluxbaseResponse<SignInWith2FAResponse | AuthResponseData>>


signOut(): Promise<VoidResponse>

Sign out the current user

Promise<VoidResponse>


signUp(credentials): Promise<FluxbaseAuthResponse>

Sign up with email and password (Supabase-compatible) Returns session when email confirmation is disabled Returns null session when email confirmation is required

ParameterType
credentialsSignUpCredentials

Promise<FluxbaseAuthResponse>


startAutoRefresh(): void

Start the automatic token refresh timer This is called automatically when autoRefresh is enabled and a session exists Only works in browser environments

void


stopAutoRefresh(): void

Stop the automatic token refresh timer Call this when you want to disable auto-refresh without signing out

void


unlinkIdentity(params): Promise<VoidResponse>

Unlink an OAuth identity from current user - Supabase-compatible Removes a linked OAuth provider from the account

ParameterTypeDescription
paramsUnlinkIdentityParamsIdentity to unlink

Promise<VoidResponse>

Promise with void response


updateUser(attributes): Promise<UserResponse>

Update the current user (Supabase-compatible)

ParameterTypeDescription
attributesUpdateUserAttributesUser attributes to update (email, password, data for metadata)

Promise<UserResponse>


verify2FA(request): Promise<DataResponse<TwoFactorLoginResponse>>

Verify 2FA code during login (Supabase-compatible) Call this after signIn returns requires_2fa: true

ParameterTypeDescription
requestTwoFactorVerifyRequestUser ID and TOTP code

Promise<DataResponse<TwoFactorLoginResponse>>

Promise with access_token, refresh_token, and user


verifyMagicLink(token): Promise<FluxbaseAuthResponse>

Verify magic link token and sign in

ParameterTypeDescription
tokenstringMagic link token from email

Promise<FluxbaseAuthResponse>


verifyOtp(params): Promise<FluxbaseAuthResponse>

Verify OTP (One-Time Password) - Supabase-compatible Verify OTP tokens for various authentication flows

ParameterTypeDescription
paramsVerifyOtpParamsOTP verification parameters including token and type

Promise<FluxbaseAuthResponse>

Promise with user and session if successful


verifyResetToken(token): Promise<DataResponse<VerifyResetTokenResponse>>

Verify password reset token Check if a password reset token is valid before allowing password reset

ParameterTypeDescription
tokenstringPassword reset token to verify

Promise<DataResponse<VerifyResetTokenResponse>>