Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Crossmint/crossmint-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheCrossmintAuthClient class provides client-side authentication functionality including OAuth, email OTP, Farcaster, and smart wallet authentication. It handles token management, automatic refresh, and secure storage of authentication credentials.
Installation
Creating an Instance
Configuration
Configuration object for the auth client
Methods
getUser
Retrieves the currently authenticated user’s information.Promise<User>
Throws: CrossmintAuthenticationError if the user is not authenticated or request fails
getOAuthUrl
Generates an OAuth URL for the specified provider.OAuth provider:
'google', 'twitter', 'facebook', etc.Promise<string> - The OAuth authorization URL
Throws: CrossmintAuthenticationError if the origin is unauthorized or request fails
sendEmailOtp
Sends a one-time password to the specified email address.Email address to send the OTP to
Promise<{ emailId: string }> - Contains the email ID needed for confirmation
Throws: CrossmintAuthenticationError if sending fails
confirmEmailOtp
Confirms an email OTP and completes authentication.Email address that received the OTP
Email ID returned from
sendEmailOtpThe 6-digit OTP code
Promise<string> - One-time secret for completing authentication
Throws: CrossmintAuthenticationError if verification fails
signInWithFarcaster
Authenticates a user using Farcaster.Farcaster sign-in data from
@farcaster/auth-kitPromise<string> - One-time secret for completing authentication
Throws: CrossmintAuthenticationError if authentication fails
signInWithSmartWallet
Initiates smart wallet authentication by requesting a signature challenge.Wallet address
Blockchain type
Promise<{ message: string; nonce: string }> - Challenge data to sign
Throws: CrossmintAuthenticationError if request fails
authenticateSmartWallet
Completes smart wallet authentication with a signed message.Wallet address
Blockchain type
Signed message from the wallet
Promise<{ oneTimeSecret: string }> - One-time secret for session establishment
Throws: CrossmintAuthenticationError if authentication fails
handleRefreshAuthMaterial
Manually triggers token refresh. This is automatically scheduled before token expiration.Custom refresh token secret. If not provided, uses stored token.
Promise<AuthMaterialWithUser | null> - New auth material or null if refresh fails
logout
Logs out the current user and clears all stored credentials.Promise<void>
Types
AuthMaterialWithUser
OAuthProvider
Error Handling
Best Practices
- Token Refresh: The client automatically refreshes tokens before expiration. Don’t manually refresh unless necessary.
- Storage: Use custom storage providers for React Native or other non-browser environments.
- Error Handling: Always handle
CrossmintAuthenticationErrorfor authentication failures. - Server Routes: For Next.js or other server frameworks, provide custom
refreshRouteandlogoutRoutefor secure cookie handling.