import { BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, UnionToIntersection } from "@better-auth/core";
//#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
//#region src/standard-schema.d.ts
/** The Standard Schema interface. */
interface StandardSchemaV1 {
/** The Standard Schema properties. */
readonly "~standard": StandardSchemaV1.Props ;
}
declare namespace StandardSchemaV1 {
/** The Standard Schema properties interface. */
interface Props {
/** The version number of the standard. */
readonly version: 1;
/** The vendor name of the schema library. */
readonly vendor: string;
/** Validates unknown input values. */
readonly validate: (value: unknown) => Result | Promise>;
/** Inferred types associated with the schema. */
readonly types?: Types | undefined;
}
/** The result interface of the validate function. */
type Result = SuccessResult | FailureResult;
/** The result interface if validation succeeds. */
interface SuccessResult {
/** The typed output value. */
readonly value: Output;
/** The non-existent issues. */
readonly issues?: undefined;
}
/** The result interface if validation fails. */
interface FailureResult {
/** The issues of failed validation. */
readonly issues: ReadonlyArray;
}
/** The issue interface of the failure output. */
interface Issue {
/** The error message of the issue. */
readonly message: string;
/** The path of the issue, if any. */
readonly path?: ReadonlyArray | undefined;
}
/** The path segment interface of the issue. */
interface PathSegment {
/** The key representing a path segment. */
readonly key: PropertyKey;
}
/** The Standard Schema types interface. */
interface Types {
/** The input type of the schema. */
readonly input: Input;
/** The output type of the schema. */
readonly output: Output;
}
/** Infers the input type of a Standard Schema. */
type InferInput = NonNullable["input"];
/** Infers the output type of a Standard Schema. */
type InferOutput = NonNullable["output"];
} //#endregion
//#endregion
//#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.3.6/node_modules/better-call/dist/error.d.mts
declare const statusCodes: {
OK: number;
CREATED: number;
ACCEPTED: number;
NO_CONTENT: number;
MULTIPLE_CHOICES: number;
MOVED_PERMANENTLY: number;
FOUND: number;
SEE_OTHER: number;
NOT_MODIFIED: number;
TEMPORARY_REDIRECT: number;
BAD_REQUEST: number;
UNAUTHORIZED: number;
PAYMENT_REQUIRED: number;
FORBIDDEN: number;
NOT_FOUND: number;
METHOD_NOT_ALLOWED: number;
NOT_ACCEPTABLE: number;
PROXY_AUTHENTICATION_REQUIRED: number;
REQUEST_TIMEOUT: number;
CONFLICT: number;
GONE: number;
LENGTH_REQUIRED: number;
PRECONDITION_FAILED: number;
PAYLOAD_TOO_LARGE: number;
URI_TOO_LONG: number;
UNSUPPORTED_MEDIA_TYPE: number;
RANGE_NOT_SATISFIABLE: number;
EXPECTATION_FAILED: number;
"I'M_A_TEAPOT": number;
MISDIRECTED_REQUEST: number;
UNPROCESSABLE_ENTITY: number;
LOCKED: number;
FAILED_DEPENDENCY: number;
TOO_EARLY: number;
UPGRADE_REQUIRED: number;
PRECONDITION_REQUIRED: number;
TOO_MANY_REQUESTS: number;
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
UNAVAILABLE_FOR_LEGAL_REASONS: number;
INTERNAL_SERVER_ERROR: number;
NOT_IMPLEMENTED: number;
BAD_GATEWAY: number;
SERVICE_UNAVAILABLE: number;
GATEWAY_TIMEOUT: number;
HTTP_VERSION_NOT_SUPPORTED: number;
VARIANT_ALSO_NEGOTIATES: number;
INSUFFICIENT_STORAGE: number;
LOOP_DETECTED: number;
NOT_EXTENDED: number;
NETWORK_AUTHENTICATION_REQUIRED: number;
};
type Status = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
declare class InternalAPIError extends Error {
status: keyof typeof statusCodes | Status;
body: ({
message?: string;
code?: string;
cause?: unknown;
} & Record) | undefined;
headers: HeadersInit;
statusCode: number;
constructor(status?: keyof typeof statusCodes | Status, body?: ({
message?: string;
code?: string;
cause?: unknown;
} & Record) | undefined, headers?: HeadersInit, statusCode?: number);
}
type APIError = InstanceType;
declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED" | undefined, body?: ({
message?: string;
code?: string;
cause?: unknown;
} & Record) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
errorStack: string | undefined;
}; //#endregion
//#endregion
//#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.3.6/node_modules/better-call/dist/openapi.d.mts
//#region src/openapi.d.ts
type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
interface OpenAPIParameter {
in: "query" | "path" | "header" | "cookie";
name?: string;
description?: string;
required?: boolean;
schema?: {
type: OpenAPISchemaType;
format?: string | undefined;
items?: {
type: OpenAPISchemaType;
};
enum?: string[];
minLength?: number;
description?: string | undefined;
default?: string | undefined;
example?: string | undefined;
};
}
//#endregion
//#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.3.6/node_modules/better-call/dist/endpoint.d.mts
//#region src/endpoint.d.ts
interface EndpointBaseOptions {
/**
* Query Schema
*/
query?: StandardSchemaV1;
/**
* Error Schema
*/
error?: StandardSchemaV1;
/**
* If true headers will be required to be passed in the context
*/
requireHeaders?: boolean;
/**
* If true request object will be required
*/
requireRequest?: boolean;
/**
* Clone the request object from the router
*/
cloneRequest?: boolean;
/**
* If true the body will be undefined
*/
disableBody?: boolean;
/**
* Endpoint metadata
*/
metadata?: {
/**
* Open API definition
*/
openapi?: {
summary?: string;
description?: string;
tags?: string[];
operationId?: string;
parameters?: OpenAPIParameter[];
requestBody?: {
content: {
"application/json": {
schema: {
type?: OpenAPISchemaType;
properties?: Record;
required?: string[];
$ref?: string;
};
};
};
};
responses?: {
[status: string]: {
description: string;
content?: {
"application/json"?: {
schema: {
type?: OpenAPISchemaType;
properties?: Record;
required?: string[];
$ref?: string;
};
};
"text/plain"?: {
schema?: {
type?: OpenAPISchemaType;
properties?: Record;
required?: string[];
$ref?: string;
};
};
"text/html"?: {
schema?: {
type?: OpenAPISchemaType;
properties?: Record;
required?: string[];
$ref?: string;
};
};
};
};
};
};
/**
* Infer body and query type from ts interface
*
* useful for generic and dynamic types
*
* @example
* ```ts
* const endpoint = createEndpoint("/path", {
* method: "POST",
* body: z.record(z.string()),
* $Infer: {
* body: {} as {
* type: InferTypeFromOptions // custom type inference
* }
* }
* }, async(ctx)=>{
* const body = ctx.body
* })
* ```
*/
$Infer?: {
/**
* Body
*/
body?: any;
/**
* Query
*/
query?: Record;
};
/**
* If enabled, endpoint won't be exposed over a router
* @deprecated Use path-less endpoints instead
*/
SERVER_ONLY?: boolean;
/**
* If enabled, endpoint won't be exposed as an action to the client
* @deprecated Use path-less endpoints instead
*/
isAction?: boolean;
/**
* Defines the places where the endpoint will be available
*
* Possible options:
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
* - `http` - the endpoint is only exposed to the router
* @default "rpc"
*/
scope?: "rpc" | "server" | "http";
/**
* List of allowed media types (MIME types) for the endpoint
*
* if provided, only the media types in the list will be allowed to be passed in the body
*
* @example
* ```ts
* const endpoint = createEndpoint("/path", {
* method: "POST",
* allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
* }, async(ctx)=>{
* const body = ctx.body
* })
* ```
*/
allowedMediaTypes?: string[];
/**
* Extra metadata
*/
[key: string]: any;
};
/**
* List of middlewares to use
*/
use?: Middleware[];
/**
* A callback to run before any API error is throw or returned
*
* @param e - The API error
* @returns - The response to return
*/
onAPIError?: (e: APIError) => void | Promise;
/**
* A callback to run before a validation error is thrown
* You can customize the validation error message by throwing your own APIError
*/
onValidationError?: ({
issues,
message
}: {
message: string;
issues: readonly StandardSchemaV1.Issue[];
}) => void | Promise;
}
type EndpointBodyMethodOptions = {
/**
* Request Method
*/
method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
/**
* Body Schema
*/
body?: StandardSchemaV1;
} | {
/**
* Request Method
*/
method: "GET" | "HEAD" | ("GET" | "HEAD")[];
/**
* Body Schema
*/
body?: never;
} | {
/**
* Request Method
*/
method: "*";
/**
* Body Schema
*/
body?: StandardSchemaV1;
} | {
/**
* Request Method
*/
method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
/**
* Body Schema
*/
body?: StandardSchemaV1;
};
type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
//#endregion
//#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.3.6/node_modules/better-call/dist/middleware.d.mts
//#region src/middleware.d.ts
interface MiddlewareOptions extends Omit {}
type MiddlewareInputContext = InferBodyInput & InferQueryInput & InferRequestInput & InferHeadersInput & {
asResponse?: boolean;
returnHeaders?: boolean;
use?: Middleware[];
};
type Middleware Promise = any> = Handler & {
options: Options;
}; //#endregion
//#endregion
//#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.3.6/node_modules/better-call/dist/context.d.mts
type InferBodyInput : undefined)> = undefined extends Body ? {
body?: Body;
} : {
body: Body;
};
type InferQueryInput : Record | undefined)> = undefined extends Query ? {
query?: Query;
} : {
query: Query;
};
type InferRequestInput = Option["requireRequest"] extends true ? {
request: Request;
} : {
request?: Request;
};
type InferHeadersInput = Option["requireHeaders"] extends true ? {
headers: HeadersInit;
} : {
headers?: HeadersInit;
};
//#endregion
//#region src/types.d.ts
type ALL_PLUGIN_ERROR_CODE_KEYS = keyof UnionToIntersection<{ [Key in Exclude]: BetterAuthPluginRegistry[Key] extends {
creator: infer C;
} ? C extends ((...args: any[]) => infer P) ? P extends {
$ERROR_CODES: infer E;
} ? E : {} : {} : {} }[Exclude]>;
type InternalTranslationDictionary = Partial<{ [Key in ALL_PLUGIN_ERROR_CODE_KEYS]: string }>;
/**
* Translation dictionary mapping error codes to translated messages
*/
type TranslationDictionary = InternalTranslationDictionary & Record;
/**
* Locale detection strategy
*/
type LocaleDetectionStrategy = "header" | "cookie" | "session" | "callback";
/**
* Options for the i18n plugin
*/
interface I18nOptions {
/**
* Translation dictionaries keyed by locale code
* @example
* {
* en: { USER_NOT_FOUND: "User not found" },
* fr: { USER_NOT_FOUND: "Utilisateur non trouvé" }
* }
*/
translations: { [Locale in Locales[number]]: TranslationDictionary };
/**
* Default/fallback locale when detection fails
* @default "en"
*/
defaultLocale?: Locales[number] | undefined;
/**
* Locale detection strategies in priority order
* @default ["header"]
*/
detection?: LocaleDetectionStrategy[] | undefined;
/**
* Cookie name for locale detection (when "cookie" strategy is used)
* @default "locale"
*/
localeCookie?: string | undefined;
/**
* User field name for stored locale preference (when "session" strategy is used)
* @default "locale"
*/
userLocaleField?: string | undefined;
/**
* Custom locale detection function (when "callback" strategy is used).
* @example
* getLocale: (ctx) => {
* return ctx.headers?.get("X-Custom-Locale") ?? null;
* }
*/
getLocale?: undefined | ((ctx: GenericEndpointContext) => Promise | Locales[number] | null);
}
//#endregion
//#region src/index.d.ts
declare module "@better-auth/core" {
interface BetterAuthPluginRegistry {
i18n: {
creator: typeof i18n;
};
}
}
/**
* i18n plugin for Better Auth
*
* Translates error messages based on detected locale.
*
* @example
* ```ts
* import { betterAuth } from "better-auth";
* import { i18n } from "@better-auth/i18n";
*
* export const auth = betterAuth({
* plugins: [
* i18n({
* translations: {
* en: { USER_NOT_FOUND: "User not found" },
* fr: { USER_NOT_FOUND: "Utilisateur non trouvé" },
* },
* detection: ["header", "cookie"],
* }),
* ],
* });
* ```
*/
declare const i18n: (options: I18nOptions) => {
id: "i18n";
version: string;
hooks: {
after: {
matcher: () => true;
handler: (inputContext: MiddlewareInputContext) => Promise;
}[];
};
options: {
translations: { [Locale in Locales[number]]: TranslationDictionary };
defaultLocale: Locales[number];
detection: LocaleDetectionStrategy[];
localeCookie: string;
userLocaleField: string;
getLocale?: ((ctx: GenericEndpointContext) => Locales[number] | Promise | null) | undefined;
};
};
//#endregion
export { TranslationDictionary as i, I18nOptions as n, LocaleDetectionStrategy as r, i18n as t };