UNPKG

@better-auth-ui/core

Version:

Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.

129 lines (128 loc) 3.98 kB
import { TwoFactorMethod } from './two-factor-challenge'; import { TwoFactorLocalization } from './two-factor-localization'; declare module "../../lib/view-paths" { /** Widens `AuthViewPaths` with the two-factor path when this plugin is imported. */ interface AuthViewPaths { /** @default "two-factor" */ twoFactor?: string; } } export type TwoFactorPluginOptions = { /** * Override the plugin's default localization strings. * @remarks `TwoFactorLocalization` */ localization?: Partial<TwoFactorLocalization>; /** * URL segment for the two-factor challenge view. * @remarks `string` * @default "two-factor" */ path?: string; /** * Number of characters rendered by the TOTP and OTP inputs. * * Keep this in sync with Better Auth's `twoFactor({ totpOptions: { digits } })` * and `twoFactor({ otpOptions: { digits } })` server options. * * @remarks `number` * @default 6 */ codeLength?: number; /** * Offer backup-code recovery on the challenge view and expose backup-code * management in settings. * * Turn this off when the server sets `backupCodeOptions: { enabled: false }`. * * @remarks `boolean` * @default true */ backupCodes?: boolean; /** * Show the "Trust this device" checkbox on the challenge view. * * @remarks `boolean` * @default true */ trustDevice?: boolean; /** * Manage two-factor without asking for a password. * * Mirrors Better Auth's `twoFactor({ allowPasswordless })` server option, * which only skips the password for accounts that have no credential * account (e.g. passkey-only users) — set both or neither. * * @remarks `boolean` * @default false */ allowPasswordless?: boolean; /** * Methods users can choose while enrolling in two-factor authentication. * * Add `"otp"` only when the server configures `otpOptions.sendOTP`. * * @remarks `TwoFactorMethod[]` * @default ["totp"] */ enrollmentMethods?: TwoFactorMethod[]; }; export declare const twoFactorPlugin: ((options?: TwoFactorPluginOptions | undefined) => { localization: { twoFactor: string; twoFactorDescription: string; enableTwoFactor: string; disableTwoFactor: string; twoFactorEnabled: string; twoFactorDisabled: string; passwordConfirmation: string; chooseEnrollmentMethod: string; authenticatorApp: string; authenticatorAppDescription: string; deliveredCode: string; deliveredCodeDescription: string; scanQrCode: string; setupKey: string; setupKeyCopied: string; setupKeyCopyFailed: string; authenticatorCode: string; authenticatorCodeDescription: string; emailedCode: string; emailedCodeDescription: string; sendEmailCode: string; backupCode: string; backupCodeDescription: string; backupCodes: string; backupCodesForWebsite: string; backupCodesDescription: string; backupCodesCopied: string; backupCodesCopyFailed: string; downloadBackupCodes: string; printBackupCodes: string; regenerateBackupCodes: string; backupCodesRegenerated: string; useAuthenticator: string; useEmailedCode: string; useBackupCode: string; trustDevice: string; trustDeviceDescription: string; verify: string; codeLengthMismatch: string; backToSignIn: string; done: string; }; codeLength: number; backupCodes: boolean; trustDevice: boolean; allowPasswordless: boolean; enrollmentMethods: TwoFactorMethod[]; viewPaths: { auth: { twoFactor: string; }; }; } & { id: "twoFactor"; }) & { id: "twoFactor"; };