Skip to main content
Interface for auth manager implementations. Defines the public contract that both real and mock implementations must satisfy.

Methods

getUser()

Gets the current user, or null if there is no user signed in.

Returns

| null | User

isSignedIn()

Returns whether the user is signed in.

Returns

Promise<boolean>

signOut()

Signs out the user, clearing all authentication state.

Returns

Promise<void>

addAuthStateChangeCallback()

Adds a callback to be called when the auth state changes.

Parameters

Returns

void

getToken()

Gets the access token, refreshing if needed, or null if the user is not signed in.

Parameters

Returns

Promise<null | string>

getTokenExpiration()

Gets the expiration time of the access token, or null if the user is not signed in.

Returns

Promise<null | number>

getWalletSecretId()

Gets the currently registered wallet secret ID, refreshing if needed.

Returns

Promise<string> The wallet secret ID.

getXWalletAuth()

Gets the X-Wallet-Auth header value. Throws an error if the user is not signed in.

Parameters

Returns

Promise<string>

getAuthState()

Gets the authentication state.

Returns

| null | AuthState

setAuthState()

Sets the authentication state.

Parameters

Returns

Promise<void>

clearAuthState()

Clears the authentication state.

Returns

Promise<void>

ensureInitialized()

Awaitable method whose promise only resolves when the auth manager is ready to be used.

Returns

Promise<void>