@better-auth/electron 1.5.0-beta.16 → 1.5.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/preload.d.mts +77 -4
  2. package/package.json +5 -5
@@ -5237,6 +5237,49 @@ type GenerateIdFn = (options: {
5237
5237
  model: ModelNames;
5238
5238
  size?: number | undefined;
5239
5239
  }) => string | false;
5240
+ /**
5241
+ * Configuration for dynamic base URL resolution.
5242
+ * Allows Better Auth to work with multiple domains (e.g., Vercel preview deployments).
5243
+ */
5244
+ type DynamicBaseURLConfig = {
5245
+ /**
5246
+ * List of allowed hostnames. Supports wildcard patterns.
5247
+ *
5248
+ * The derived host from the request will be validated against this list.
5249
+ * Uses the same wildcard matching as `trustedOrigins`.
5250
+ *
5251
+ * @example
5252
+ * ```ts
5253
+ * allowedHosts: [
5254
+ * "myapp.com", // Exact match
5255
+ * "*.vercel.app", // Any Vercel preview
5256
+ * "preview-*.myapp.com" // Pattern match
5257
+ * ]
5258
+ * ```
5259
+ */
5260
+ allowedHosts: string[];
5261
+ /**
5262
+ * Fallback URL to use if the derived host doesn't match any allowed host.
5263
+ * If not set, Better Auth will throw an error when the host doesn't match.
5264
+ *
5265
+ * @example "https://myapp.com"
5266
+ */
5267
+ fallback?: string | undefined;
5268
+ /**
5269
+ * Protocol to use when constructing the URL.
5270
+ * - `"https"`: Always use HTTPS (recommended for production)
5271
+ * - `"http"`: Always use HTTP (for local development)
5272
+ * - `"auto"`: Derive from `x-forwarded-proto` header or default to HTTPS
5273
+ *
5274
+ * @default "auto"
5275
+ */
5276
+ protocol?: "http" | "https" | "auto" | undefined;
5277
+ };
5278
+ /**
5279
+ * Base URL configuration.
5280
+ * Can be a static string or a dynamic config for multi-domain deployments.
5281
+ */
5282
+ type BaseURLConfig = string | DynamicBaseURLConfig;
5240
5283
  interface BetterAuthRateLimitStorage {
5241
5284
  get: (key: string) => Promise<RateLimit | null | undefined>;
5242
5285
  set: (key: string, value: RateLimit, update?: boolean | undefined) => Promise<void>;
@@ -5491,12 +5534,27 @@ type BetterAuthOptions = {
5491
5534
  /**
5492
5535
  * Base URL for the Better Auth. This is typically the
5493
5536
  * root URL where your application server is hosted.
5494
- * If not explicitly set,
5495
- * the system will check the following environment variable:
5496
5537
  *
5497
- * process.env.BETTER_AUTH_URL
5538
+ * Can be configured as:
5539
+ * - A static string: `"https://myapp.com"`
5540
+ * - A dynamic config with allowed hosts for multi-domain deployments
5541
+ *
5542
+ * If not explicitly set, the system will check environment variables:
5543
+ * `BETTER_AUTH_URL`, `NEXT_PUBLIC_BETTER_AUTH_URL`, etc.
5544
+ *
5545
+ * @example
5546
+ * ```ts
5547
+ * // Static URL
5548
+ * baseURL: "https://myapp.com"
5549
+ *
5550
+ * // Dynamic with allowed hosts (for Vercel, multi-domain, etc.)
5551
+ * baseURL: {
5552
+ * allowedHosts: ["myapp.com", "*.vercel.app", "preview-*.myapp.com"],
5553
+ * fallback: "https://myapp.com"
5554
+ * }
5555
+ * ```
5498
5556
  */
5499
- baseURL?: string | undefined;
5557
+ baseURL?: BaseURLConfig | undefined;
5500
5558
  /**
5501
5559
  * Base path for the Better Auth. This is typically
5502
5560
  * the path where the
@@ -5756,6 +5814,21 @@ type BetterAuthOptions = {
5756
5814
  * @default false
5757
5815
  */
5758
5816
  revokeSessionsOnPasswordReset?: boolean;
5817
+ /**
5818
+ * A callback function that is triggered when a user tries to sign up
5819
+ * with an email that already exists. Useful for notifying the existing user
5820
+ * that someone attempted to register with their email.
5821
+ *
5822
+ * This is only called when `requireEmailVerification: true` or `autoSignIn: false`.
5823
+ */
5824
+ onExistingUserSignUp?: (
5825
+ /**
5826
+ * @param user the existing user from the database
5827
+ */
5828
+
5829
+ data: {
5830
+ user: User;
5831
+ }, request?: Request) => Promise<void>;
5759
5832
  } | undefined;
5760
5833
  /**
5761
5834
  * list of social providers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/electron",
3
- "version": "1.5.0-beta.16",
3
+ "version": "1.5.0-beta.18",
4
4
  "type": "module",
5
5
  "description": "Better Auth integration for Electron applications.",
6
6
  "main": "dist/index.mjs",
@@ -82,8 +82,8 @@
82
82
  "better-call": "1.3.2",
83
83
  "electron": ">=36.0.0",
84
84
  "conf": "^15.0.2",
85
- "@better-auth/core": "1.5.0-beta.16",
86
- "better-auth": "1.5.0-beta.16"
85
+ "@better-auth/core": "1.5.0-beta.18",
86
+ "better-auth": "1.5.0-beta.18"
87
87
  },
88
88
  "dependencies": {
89
89
  "zod": "^4.3.5"
@@ -93,8 +93,8 @@
93
93
  "electron": "^38.8.0",
94
94
  "better-sqlite3": "^12.6.2",
95
95
  "tsdown": "^0.20.3",
96
- "@better-auth/core": "1.5.0-beta.16",
97
- "better-auth": "1.5.0-beta.16"
96
+ "@better-auth/core": "1.5.0-beta.18",
97
+ "better-auth": "1.5.0-beta.18"
98
98
  },
99
99
  "engines": {
100
100
  "node": ">=22.0.0"