@better-auth-ui/core
Version:
Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.
138 lines (137 loc) • 4.71 kB
TypeScript
import { AuthPluginBase, AuthPluginLocalizationContext } from '../../lib/auth-plugin';
import { PhoneNumberAdapter, PhoneNumberCountryCode } from './phone-number';
import { PhoneNumberLocalization } from './phone-number-localization';
declare module "../../lib/view-paths" {
/** Widens `AuthViewPaths` with the phone-number routes when this plugin is imported. */
interface AuthViewPaths {
/** @default "phone-number" */
phoneNumber?: string;
/** @default "phone-number-forgot-password" */
phoneNumberForgotPassword?: string;
/** @default "phone-number-reset-password" */
phoneNumberResetPassword?: string;
}
}
export type PhoneNumberPluginOptions = {
/**
* Adapter used to format, validate, and normalize phone numbers.
* @default defaultPhoneNumberAdapter
*/
adapter?: PhoneNumberAdapter;
/**
* Country selected before the user enters a phone number.
* @default The first configured country, or "US" when `countries` is omitted.
*/
defaultCountry?: PhoneNumberCountryCode;
/** Countries shown in the country selector. Defaults to all supported countries. */
countries?: readonly PhoneNumberCountryCode[];
/** Locale used for country names and sorting. Defaults to the runtime locale. */
locale?: string;
/**
* Override the plugin's default localization strings.
* @remarks `PhoneNumberLocalization`
*/
localization?: Partial<PhoneNumberLocalization>;
/**
* URL segment for the phone-number sign-in view.
* @default "phone-number"
*/
path?: string;
/**
* URL segment for requesting a phone password reset.
* @default "phone-number-forgot-password"
*/
forgotPasswordPath?: string;
/**
* URL segment for completing a phone password reset.
* @default "phone-number-reset-password"
*/
resetPasswordPath?: string;
/**
* Number of characters rendered by the code input.
*
* Keep this in sync with Better Auth's `phoneNumber({ otpLength })` option.
* @default 6
*/
otpLength?: number;
/**
* Offer passwordless sign-in by sending a verification code.
* @default true
*/
signIn?: boolean;
/**
* Offer phone-number and password sign-in.
*
* Users need a Better Auth credential account before this strategy can
* authenticate them.
* @default false
*/
passwordSignIn?: boolean;
/**
* Add the phone-number password-reset routes and link.
*
* Requires `sendPasswordResetOTP` in the Better Auth server plugin.
* @default false
*/
passwordReset?: boolean;
/**
* Add a verified phone-number card to account settings.
* @default true
*/
changePhoneNumber?: boolean;
};
export declare const phoneNumberPlugin: ((options?: PhoneNumberPluginOptions | undefined) => {
adapter: PhoneNumberAdapter;
countries: readonly import('libphonenumber-js/min').CountryCode[] | undefined;
defaultCountry: import('libphonenumber-js/min').CountryCode;
locale: string | undefined;
localization: {
country: string;
invalidPhoneNumber: string;
phoneNumber: string;
phoneNumberPlaceholder: string;
phoneCode: string;
sendCode: string;
verifyCode: string;
codeSentTo: string;
codeLengthMismatch: string;
useDifferentPhoneNumber: string;
usePassword: string;
useVerificationCode: string;
forgotPassword: string;
resetPassword: string;
changePhoneNumber: string;
updatePhoneNumber: string;
phoneNumberUpdated: string;
removePhoneNumber: string;
phoneNumberRemoved: string;
removePhoneNumberTitle: string;
removePhoneNumberDescription: string;
cancel: string;
};
_localizationResolver: (plugin: AuthPluginBase, context: AuthPluginLocalizationContext) => {
locale: string;
id: string;
localization?: Record<string, unknown>;
_localizationOverrides?: Record<string, unknown>;
_localizationResolver?: import('../..').AuthPluginLocalizationResolver;
viewPaths?: import('../..').AuthPluginViewPaths;
additionalFields?: import('../..').AdditionalFields;
};
otpLength: number;
signIn: boolean;
passwordSignIn: boolean;
passwordReset: boolean;
changePhoneNumber: boolean;
viewPaths: {
auth: {
phoneNumber: string;
phoneNumberForgotPassword: string;
phoneNumberResetPassword: string;
};
};
} & {
id: "phoneNumber";
}) & {
id: "phoneNumber";
};