Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@better-auth/core

Package Overview
Dependencies
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@better-auth/core - npm Package Compare versions

Comparing version
1.5.0-beta.16
to
1.5.0-beta.17
+1
-1
dist/context/global.mjs

@@ -5,3 +5,3 @@ //#region src/context/global.ts

const __context = {};
const __betterAuthVersion = "1.5.0-beta.16";
const __betterAuthVersion = "1.5.0-beta.17";
/**

@@ -8,0 +8,0 @@ * We store context instance in the globalThis.

@@ -0,5 +1,5 @@

import { getAuthTables } from "../get-tables.mjs";
import { getColorDepth } from "../../env/color-depth.mjs";
import { TTY_COLORS, createLogger } from "../../env/logger.mjs";
import "../../env/index.mjs";
import { getAuthTables } from "../get-tables.mjs";
import { BetterAuthError } from "../../error/index.mjs";

@@ -6,0 +6,0 @@ import { safeJSONParse } from "../../utils/json.mjs";

import { Awaitable, AwaitableFunction, LiteralString, LiteralUnion, Prettify, Primitive, UnionToIntersection } from "./types/helper.mjs";
import { BetterAuthPlugin, BetterAuthPluginErrorCodePart, HookEndpointContext } from "./types/plugin.mjs";
import { BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, GenerateIdFn, StoreIdentifierOption } from "./types/init-options.mjs";
import { BaseURLConfig, BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, DynamicBaseURLConfig, GenerateIdFn, StoreIdentifierOption } from "./types/init-options.mjs";
import { BetterAuthCookie, BetterAuthCookies } from "./types/cookie.mjs";

@@ -8,2 +8,2 @@ import { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext } from "./types/context.mjs";

import { StandardSchemaV1 } from "./types/index.mjs";
export { AuthContext, Awaitable, AwaitableFunction, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookie, BetterAuthCookies, BetterAuthDBOptions, BetterAuthOptions, BetterAuthPlugin, BetterAuthPluginErrorCodePart, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InfoContext, InternalAdapter, LiteralString, LiteralUnion, PluginContext, Prettify, Primitive, StandardSchemaV1, StoreIdentifierOption, UnionToIntersection };
export { AuthContext, Awaitable, AwaitableFunction, BaseURLConfig, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookie, BetterAuthCookies, BetterAuthDBOptions, BetterAuthOptions, BetterAuthPlugin, BetterAuthPluginErrorCodePart, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, ClientAtomListener, ClientFetchOption, ClientStore, DynamicBaseURLConfig, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InfoContext, InternalAdapter, LiteralString, LiteralUnion, PluginContext, Prettify, Primitive, StandardSchemaV1, StoreIdentifierOption, UnionToIntersection };
import { Awaitable, AwaitableFunction, LiteralString, LiteralUnion, Prettify, Primitive, UnionToIntersection } from "./helper.mjs";
import { BetterAuthPlugin, BetterAuthPluginErrorCodePart, HookEndpointContext } from "./plugin.mjs";
import { BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, GenerateIdFn, StoreIdentifierOption } from "./init-options.mjs";
import { BaseURLConfig, BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, DynamicBaseURLConfig, GenerateIdFn, StoreIdentifierOption } from "./init-options.mjs";
import { BetterAuthCookie, BetterAuthCookies } from "./cookie.mjs";

@@ -5,0 +5,0 @@ import { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext } from "./context.mjs";

@@ -30,2 +30,45 @@ import { DBFieldAttribute, ModelNames, SecondaryStorage } from "../db/type.mjs";

}) => string | false;
/**
* Configuration for dynamic base URL resolution.
* Allows Better Auth to work with multiple domains (e.g., Vercel preview deployments).
*/
type DynamicBaseURLConfig = {
/**
* List of allowed hostnames. Supports wildcard patterns.
*
* The derived host from the request will be validated against this list.
* Uses the same wildcard matching as `trustedOrigins`.
*
* @example
* ```ts
* allowedHosts: [
* "myapp.com", // Exact match
* "*.vercel.app", // Any Vercel preview
* "preview-*.myapp.com" // Pattern match
* ]
* ```
*/
allowedHosts: string[];
/**
* Fallback URL to use if the derived host doesn't match any allowed host.
* If not set, Better Auth will throw an error when the host doesn't match.
*
* @example "https://myapp.com"
*/
fallback?: string | undefined;
/**
* Protocol to use when constructing the URL.
* - `"https"`: Always use HTTPS (recommended for production)
* - `"http"`: Always use HTTP (for local development)
* - `"auto"`: Derive from `x-forwarded-proto` header or default to HTTPS
*
* @default "auto"
*/
protocol?: "http" | "https" | "auto" | undefined;
};
/**
* Base URL configuration.
* Can be a static string or a dynamic config for multi-domain deployments.
*/
type BaseURLConfig = string | DynamicBaseURLConfig;
interface BetterAuthRateLimitStorage {

@@ -285,8 +328,23 @@ get: (key: string) => Promise<RateLimit | null | undefined>;

* root URL where your application server is hosted.
* If not explicitly set,
* the system will check the following environment variable:
*
* process.env.BETTER_AUTH_URL
* Can be configured as:
* - A static string: `"https://myapp.com"`
* - A dynamic config with allowed hosts for multi-domain deployments
*
* If not explicitly set, the system will check environment variables:
* `BETTER_AUTH_URL`, `NEXT_PUBLIC_BETTER_AUTH_URL`, etc.
*
* @example
* ```ts
* // Static URL
* baseURL: "https://myapp.com"
*
* // Dynamic with allowed hosts (for Vercel, multi-domain, etc.)
* baseURL: {
* allowedHosts: ["myapp.com", "*.vercel.app", "preview-*.myapp.com"],
* fallback: "https://myapp.com"
* }
* ```
*/
baseURL?: string | undefined;
baseURL?: BaseURLConfig | undefined;
/**

@@ -403,3 +461,2 @@ * Base path for the Better Auth. This is typically

*/
data: {

@@ -413,3 +470,2 @@ user: User;

*/
request?: Request) => Promise<void>;

@@ -551,2 +607,16 @@ /**

revokeSessionsOnPasswordReset?: boolean;
/**
* A callback function that is triggered when a user tries to sign up
* with an email that already exists. Useful for notifying the existing user
* that someone attempted to register with their email.
*
* This is only called when `requireEmailVerification: true` or `autoSignIn: false`.
*/
onExistingUserSignUp?: (
/**
* @param user the existing user from the database
*/
data: {
user: User;
}, request?: Request) => Promise<void>;
} | undefined;

@@ -1232,3 +1302,3 @@ /**

//#endregion
export { BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, GenerateIdFn, StoreIdentifierOption };
export { BaseURLConfig, BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, DynamicBaseURLConfig, GenerateIdFn, StoreIdentifierOption };
//# sourceMappingURL=init-options.d.mts.map
{
"name": "@better-auth/core",
"version": "1.5.0-beta.16",
"version": "1.5.0-beta.17",
"description": "The most comprehensive authentication framework for TypeScript.",

@@ -5,0 +5,0 @@ "type": "module",

@@ -17,2 +17,3 @@ export type { StandardSchemaV1 } from "@standard-schema/spec";

export type {
BaseURLConfig,
BetterAuthAdvancedOptions,

@@ -24,2 +25,3 @@ BetterAuthDBOptions,

BetterAuthRateLimitStorage,
DynamicBaseURLConfig,
GenerateIdFn,

@@ -26,0 +28,0 @@ StoreIdentifierOption,

@@ -49,2 +49,49 @@ import type { Database as BunDatabase } from "bun:sqlite";

/**
* Configuration for dynamic base URL resolution.
* Allows Better Auth to work with multiple domains (e.g., Vercel preview deployments).
*/
export type DynamicBaseURLConfig = {
/**
* List of allowed hostnames. Supports wildcard patterns.
*
* The derived host from the request will be validated against this list.
* Uses the same wildcard matching as `trustedOrigins`.
*
* @example
* ```ts
* allowedHosts: [
* "myapp.com", // Exact match
* "*.vercel.app", // Any Vercel preview
* "preview-*.myapp.com" // Pattern match
* ]
* ```
*/
allowedHosts: string[];
/**
* Fallback URL to use if the derived host doesn't match any allowed host.
* If not set, Better Auth will throw an error when the host doesn't match.
*
* @example "https://myapp.com"
*/
fallback?: string | undefined;
/**
* Protocol to use when constructing the URL.
* - `"https"`: Always use HTTPS (recommended for production)
* - `"http"`: Always use HTTP (for local development)
* - `"auto"`: Derive from `x-forwarded-proto` header or default to HTTPS
*
* @default "auto"
*/
protocol?: "http" | "https" | "auto" | undefined;
};
/**
* Base URL configuration.
* Can be a static string or a dynamic config for multi-domain deployments.
*/
export type BaseURLConfig = string | DynamicBaseURLConfig;
export interface BetterAuthRateLimitStorage {

@@ -350,8 +397,23 @@ get: (key: string) => Promise<RateLimit | null | undefined>;

* root URL where your application server is hosted.
* If not explicitly set,
* the system will check the following environment variable:
*
* process.env.BETTER_AUTH_URL
* Can be configured as:
* - A static string: `"https://myapp.com"`
* - A dynamic config with allowed hosts for multi-domain deployments
*
* If not explicitly set, the system will check environment variables:
* `BETTER_AUTH_URL`, `NEXT_PUBLIC_BETTER_AUTH_URL`, etc.
*
* @example
* ```ts
* // Static URL
* baseURL: "https://myapp.com"
*
* // Dynamic with allowed hosts (for Vercel, multi-domain, etc.)
* baseURL: {
* allowedHosts: ["myapp.com", "*.vercel.app", "preview-*.myapp.com"],
* fallback: "https://myapp.com"
* }
* ```
*/
baseURL?: string | undefined;
baseURL?: BaseURLConfig | undefined;
/**

@@ -632,2 +694,16 @@ * Base path for the Better Auth. This is typically

revokeSessionsOnPasswordReset?: boolean;
/**
* A callback function that is triggered when a user tries to sign up
* with an email that already exists. Useful for notifying the existing user
* that someone attempted to register with their email.
*
* This is only called when `requireEmailVerification: true` or `autoSignIn: false`.
*/
onExistingUserSignUp?: (
/**
* @param user the existing user from the database
*/
data: { user: User },
request?: Request,
) => Promise<void>;
}

@@ -634,0 +710,0 @@ | undefined;