Authentication Methods
Cavos supports multiple authentication methods:| Method | Identity | Use Case |
|---|---|---|
| Google OAuth | Email, name, profile picture | Quick social login |
| Apple OAuth | Email (optionally hidden), name | Privacy-focused social login |
| Email/Password | Email verified with link | Traditional authentication |
| Passkey-Only | Anonymous, no email | Privacy-first apps |
Social Login (Google/Apple)
(…) 17: All authentication methods create a self-custodial StarkNet wallet tied to your identity. 18: 19: ## Social Login (Google/Apple) 20: 21: ### Login with Google 22: 23:tsx 24: import { useCavos } from '@cavos/react'; 25: 26: function LoginButton() { 27: const { login, isAuthenticated, user, address } = useCavos(); 28: 29: if (isAuthenticated) { 30: return ( 31: <div> 32: <p>Welcome, {user?.name}</p> 33: <p>Wallet: {address}</p> 34: </div> 35: ); 36: } 37: 38: return ( 39: <button onClick={() => login('google')}> 40: Login with Google 41: </button> 42: ); 43: } 44:
45:
46: ### Login with Apple
47:
48: tsx 49: <button onClick={() => login('apple')}> 50: Login with Apple 51: </button> 52:
53:
54: ### Social Login Flow
55:
56: 1. User clicks login button
57: 2. SDK redirects to Google/Apple OAuth
58: 3. User authenticates with their account
59: 4. Provider redirects back with JWT token
60: 5. SDK derives wallet address from OAuth identity
61: 6. Wallet is ready to use (session key is registered on first transaction)
62:
63:
64: Your wallet address is deterministically derived from your OAuth identity (Google/Apple user ID). Same account = same wallet address across devices.
65:
tsx 74: import { useCavos } from '@cavos/react'; 75: 76: function RegisterForm() { 77: const { register, isLoading } = useCavos(); 78: const [email, setEmail] = useState(''); 79: const [password, setPassword] = useState(''); 80: const [error, setError] = useState(''); 81: 82: const handleRegister = async () => { 83: try { 84: await register('firebase', { email, password }); 85: // User receives verification email automatically 86: alert('Check your email to verify your account!'); 87: } catch (err) { 88: setError(err.message || 'Registration failed'); 89: } 90: }; 91: 92: return ( 93: <form onSubmit={(e) => { e.preventDefault(); handleRegister(); }}> 94: <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Email" /> 95: <input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="Password" /> 96: <button type="submit" disabled={isLoading}>Register</button> 97: {error && <p>{error}</p>} 98: </form> 99: ); 100: } 101:
102:
103: ### 2. Login & Verification
104:
105: If a user tries to login without verifying their email, the SDK will throw an EmailNotVerifiedError.
106:
107: tsx 108: const handleLogin = async () => { 109: try { 110: await login('firebase', { email, password }); 111: } catch (err) { 112: if (err.name === 'EmailNotVerifiedError') { 113: // User MUST verify email before proceeding 114: alert('Please verify your email first.'); 115: } 116: } 117: }; 118:
119:
120: ### 3. Verification Management
121:
122: You can manually check verification status or resend the email:
123:
124: tsx 125: const { cavos } = useCavos(); 126: 127: // Check if verified 128: if (!await cavos.isEmailVerified(email)) { 129: // Resend email 130: await cavos.resendVerificationEmail(email); 131: } 132:
133:
134:
135: Verification emails are rate-limited to 60 seconds.
136:
Your wallet address is derived from your Firebase User ID. Same email = same wallet address, even if you reset your password.
Passkey-Only Authentication
For apps that don’t need user identity, use passkey-only mode:How It Works
WhencreateWallet() is called without prior authentication:
- SDK checks for existing passkey wallet
- If found, prompts for biometric authentication
- If not found, creates new passkey and wallet
- Wallet is deployed gaslessly
Session Management
Check Authentication State
Logout
Session Restoration
The SDK automatically restores sessions on page load:- OAuth sessions: Restored from browser storage
- Passkey wallets: Restored from local storage (requires biometric)

