Authentication sub-client — email OTP, OAuth, wallet sign-in, and session lifecycle. Exposed on CrossmintClient.auth.
Observable via state (immediate), stateListenable (Flutter ValueListenable), or states (Stream). Call restoreSession on app startup (once CrossmintClient.initialize has completed) so any persisted JWT can hydrate before the first frame.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → CrossmintAuthState
-
The current auth state snapshot.
no setter
-
stateListenable
→ ValueListenable<
CrossmintAuthState> -
Reactive handle on state — suitable for ValueListenableBuilder.
no setter
-
states
→ Stream<
CrossmintAuthState> -
Stream of auth-state changes. Emits on every state mutation.
no setter
Methods
-
authenticateWallet(
String address, String type, String signature) → Future< bool> - Completes wallet-based authentication with the signed challenge.
-
completeOAuth(
Uri callbackUri) → Future< bool> - Completes an OAuth flow from a deep-link callback URI. Normally invoked by CrossmintAuthCallbackRouter; call directly only for custom routing.
-
completeOAuthWithOneTimeSecret(
String oneTimeSecret) → Future< bool> -
Completes an OAuth flow from a one-time secret (SSR / server-mediated
callbacks). Returns
trueon success. -
confirmEmailOtp(
{required String email, required String emailId, required String token}) → Future< bool> -
Submits an email OTP challenge — pass the
emailIdfrom the challenge and thetokenthe user entered. Returnstrueon success. -
getSession(
) → Future< CrossmintAuthSession?> -
Returns the current session (JWT + metadata), or
nullif not signed in. Does not hit the network — reads from in-memory state. -
getUser(
{bool forceRefresh = false}) → Future< CrossmintAuthenticatedUser?> -
Returns the authenticated user's profile. Caches the result; pass
forceRefresh: trueto bypass the cache and refetch. -
loginWithOAuth(
CrossmintOAuthProvider provider) → Future< void> -
Opens the Crossmint-hosted OAuth flow for
provider(Google, Twitter, etc.). The response comes back through CrossmintAuthCallbackRouter — make sure it is started before calling this. -
logout(
) → Future< void> - Signs the user out — clears persisted storage, cached session/user, and POSTs to the Crossmint (or custom) logout endpoint.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
restoreSession(
) → Future< void> -
Reads any persisted session from CrossmintAuthStorage and applies it
to the client. Safe to call once per app launch — prefer using the
result of
CrossmintClient.initializewhich calls this internally. -
sendEmailOtp(
String email) → Future< CrossmintEmailOtpChallenge> -
Requests the Crossmint API to send an email OTP to
email. Returns a challenge that confirmEmailOtp completes. -
setJwt(
String? jwt) → Future< void> - Sets a custom JWT for "Bring Your Own Auth" (BYOA) flows.
-
signInWithWallet(
String address, String type) → Future< CrossmintWalletAuthChallenge> -
Starts wallet-based authentication. Returns a challenge that the wallet
must sign.
typeis'evm'or'solana'. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited