- New users: requestOtp → verifyOtp (creates account)
- Existing users: requestOtp → verifyOtp (login)
Returns
| Name | Type | Default value | Description |
|---|---|---|---|
user | any | storedState.user | - |
account | any | storedState.account | - |
isAuthenticated | boolean | storedState.isAuthenticated | - |
sessionSecrets | SessionSecrets | - | - |
isExistingUser | any | - | - |
isLoading | any | - | - |
loadingOperation | any | - | - |
error | any | - | - |
errorCode | any | - | - |
sessionStatus | SessionStatus | - | - |
sessionExpiresAt | number | - | - |
ensureValidSession() | () => Promise<void> | - | Ensure session is valid (auto-refreshes if needed) Use before critical operations like signing transactions. |
requestOtp() | (email, options?) => Promise<void> | - | Request OTP code via email (handles new and existing users) |
verifyOtp() | (otpCode) => Promise<void> | - | Verify OTP code (creates account for new users, logs in existing users) |
logout() | () => void | - | Logout and clear all authentication data Note: Can also use useAccount().disconnect() |
clearError() | () => void | - | Clear error state |
refreshSessionSecrets() | () => Promise<void> | - | Refresh session secrets using HTTP-only cookie Called automatically when account exists but no active session secrets. |