plugins/two_factor library
Two-factor authentication: TOTP, OTP, and backup codes.
Requires the twoFactor() plugin on your Better Auth server. Importing this
library adds a twoFactor getter to BetterAuthClient.
Classes
- BackupCodesResponse
- Response from regenerating backup codes.
- BetterAuthTwoFactor
-
Typed wrapper for the Better Auth
twoFactor()plugin routes. - TotpUriResponse
- Response carrying just a TOTP URI.
- TwoFactorEnableBody
-
Body for enabling two-factor auth.
passwordre-authenticates the user. - TwoFactorEnableResponse
- Response from enabling 2FA: the TOTP URI to render as a QR code, plus one-time backup codes to show the user once.
- TwoFactorPasswordBody
- Body for routes that only need the user's password (disable, get TOTP URI).
- TwoFactorVerifyBody
- Body for verifying a code (TOTP, OTP, or backup code).
Extensions
- BackupCodesResponsePatterns on BackupCodesResponse
- Adds pattern-matching-related methods to BackupCodesResponse.
- TotpUriResponsePatterns on TotpUriResponse
- Adds pattern-matching-related methods to TotpUriResponse.
- TwoFactorEnableBodyPatterns on TwoFactorEnableBody
- Adds pattern-matching-related methods to TwoFactorEnableBody.
- TwoFactorEnableResponsePatterns on TwoFactorEnableResponse
- Adds pattern-matching-related methods to TwoFactorEnableResponse.
- TwoFactorExtension on BetterAuthClient
- TwoFactorPasswordBodyPatterns on TwoFactorPasswordBody
- Adds pattern-matching-related methods to TwoFactorPasswordBody.
- TwoFactorVerifyBodyPatterns on TwoFactorVerifyBody
- Adds pattern-matching-related methods to TwoFactorVerifyBody.