better-auth-studio 1.1.2-beta.15 → 1.1.2-beta.17

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 (88) hide show
  1. package/README.md +38 -25
  2. package/data/default-geo.json +1 -1
  3. package/dist/adapters/astro.d.ts +1 -1
  4. package/dist/adapters/astro.js +13 -13
  5. package/dist/adapters/elysia.d.ts +2 -2
  6. package/dist/adapters/elysia.js +13 -13
  7. package/dist/adapters/express.d.ts +2 -2
  8. package/dist/adapters/express.js +4 -4
  9. package/dist/adapters/hono.d.ts +2 -2
  10. package/dist/adapters/hono.js +12 -12
  11. package/dist/adapters/nextjs.d.ts +1 -1
  12. package/dist/adapters/nextjs.js +10 -10
  13. package/dist/adapters/nuxt.d.ts +1 -1
  14. package/dist/adapters/nuxt.js +22 -22
  15. package/dist/adapters/remix.d.ts +1 -1
  16. package/dist/adapters/remix.js +13 -13
  17. package/dist/adapters/solid-start.d.ts +1 -1
  18. package/dist/adapters/solid-start.js +13 -13
  19. package/dist/adapters/svelte-kit.d.ts +2 -2
  20. package/dist/adapters/svelte-kit.js +13 -13
  21. package/dist/adapters/tanstack-start.d.ts +1 -1
  22. package/dist/adapters/tanstack-start.js +13 -13
  23. package/dist/add-svelte-kit-env-modules.js +11 -11
  24. package/dist/auth-adapter.d.ts +1 -1
  25. package/dist/auth-adapter.js +96 -96
  26. package/dist/cli/commands/init.js +57 -57
  27. package/dist/cli.js +75 -75
  28. package/dist/config.d.ts +5 -5
  29. package/dist/config.js +37 -37
  30. package/dist/core/handler.d.ts +1 -1
  31. package/dist/core/handler.js +115 -115
  32. package/dist/data.d.ts +2 -2
  33. package/dist/data.js +60 -60
  34. package/dist/geo-service.js +78 -78
  35. package/dist/get-tsconfig-info.js +4 -4
  36. package/dist/index.d.ts +8 -8
  37. package/dist/index.js +6 -6
  38. package/dist/providers/events/helpers.d.ts +2 -2
  39. package/dist/providers/events/helpers.js +156 -156
  40. package/dist/public/assets/{main-Cu8ik7af.js → main-tA7wDMDp.js} +1 -1
  41. package/dist/public/index.html +1 -1
  42. package/dist/routes/api-router.d.ts +2 -2
  43. package/dist/routes/api-router.js +3 -3
  44. package/dist/routes.d.ts +4 -4
  45. package/dist/routes.d.ts.map +1 -1
  46. package/dist/routes.js +1272 -1272
  47. package/dist/routes.js.map +1 -1
  48. package/dist/studio.d.ts +3 -3
  49. package/dist/studio.js +64 -64
  50. package/dist/types/events.d.ts +7 -7
  51. package/dist/types/events.js +165 -165
  52. package/dist/types/handler.d.ts +5 -5
  53. package/dist/utils/auth-callbacks-injector.d.ts +2 -2
  54. package/dist/utils/auth-callbacks-injector.js +27 -27
  55. package/dist/utils/auth-callbacks-wrapper.d.ts +3 -3
  56. package/dist/utils/auth-callbacks-wrapper.js +117 -107
  57. package/dist/utils/database-detection.d.ts +1 -1
  58. package/dist/utils/database-detection.js +44 -44
  59. package/dist/utils/database-hook-injector.d.ts +3 -3
  60. package/dist/utils/database-hook-injector.js +135 -131
  61. package/dist/utils/email-otp-hooks-injector.d.ts +28 -12
  62. package/dist/utils/email-otp-hooks-injector.js +104 -97
  63. package/dist/utils/event-ingestion.d.ts +5 -5
  64. package/dist/utils/event-ingestion.d.ts.map +1 -1
  65. package/dist/utils/event-ingestion.js +14 -16
  66. package/dist/utils/event-ingestion.js.map +1 -1
  67. package/dist/utils/hook-injector.d.ts +2 -2
  68. package/dist/utils/hook-injector.js +199 -199
  69. package/dist/utils/html-injector.d.ts +3 -3
  70. package/dist/utils/html-injector.js +37 -37
  71. package/dist/utils/org-hooks-injector.d.ts +3 -3
  72. package/dist/utils/org-hooks-injector.js +63 -63
  73. package/dist/utils/org-hooks-wrapper.d.ts +41 -35
  74. package/dist/utils/org-hooks-wrapper.js +778 -658
  75. package/dist/utils/organization-hooks-wrapper.d.ts +23 -17
  76. package/dist/utils/organization-hooks-wrapper.js +325 -277
  77. package/dist/utils/package-json.js +11 -11
  78. package/dist/utils/paths.js +1 -1
  79. package/dist/utils/server-init.d.ts +1 -1
  80. package/dist/utils/server-init.js +25 -25
  81. package/dist/utils/session.js +12 -12
  82. package/dist/utils.js +24 -24
  83. package/package.json +47 -55
  84. package/public/assets/{main-Cu8ik7af.js → main-tA7wDMDp.js} +1 -1
  85. package/public/index.html +1 -1
  86. package/scripts/download-geolite2.js +8 -8
  87. package/scripts/generate-default-db.js +324 -324
  88. package/scripts/postinstall.js +25 -25
package/dist/cli.js CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, readFileSync } from 'node:fs';
3
- import { basename, dirname, isAbsolute, join, relative } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import chalk from 'chalk';
6
- import chokidar from 'chokidar';
7
- import { Command } from 'commander';
8
- import { WebSocket } from 'ws';
9
- import { initCommand } from './cli/commands/init.js';
10
- import { findAuthConfig } from './config.js';
11
- import { startStudio } from './studio.js';
12
- import { detectDatabaseWithDialect } from './utils/database-detection.js';
13
- import { possibleConfigFiles } from './utils.js';
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { basename, dirname, isAbsolute, join, relative } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import chalk from "chalk";
6
+ import chokidar from "chokidar";
7
+ import { Command } from "commander";
8
+ import { WebSocket } from "ws";
9
+ import { initCommand } from "./cli/commands/init.js";
10
+ import { findAuthConfig } from "./config.js";
11
+ import { startStudio } from "./studio.js";
12
+ import { detectDatabaseWithDialect } from "./utils/database-detection.js";
13
+ import { possibleConfigFiles } from "./utils.js";
14
14
  async function findAuthConfigPath() {
15
15
  let currentDir = process.cwd();
16
16
  const maxDepth = 10;
@@ -35,8 +35,8 @@ let currentStudio = null;
35
35
  let watcher = null;
36
36
  let webSocketServer = null;
37
37
  const createDefaultStatusPayload = () => ({
38
- type: 'studio_status',
39
- status: 'up_to_date',
38
+ type: "studio_status",
39
+ status: "up_to_date",
40
40
  updatedAt: Date.now(),
41
41
  });
42
42
  let lastStatusMessage = JSON.stringify(createDefaultStatusPayload());
@@ -54,10 +54,10 @@ const handleWatchConnection = (ws) => {
54
54
  };
55
55
  function broadcastWatchMessage(message, options) {
56
56
  const payload = JSON.stringify(message);
57
- if (options?.remember === 'status') {
57
+ if (options?.remember === "status") {
58
58
  lastStatusMessage = payload;
59
59
  }
60
- if (options?.remember === 'change') {
60
+ if (options?.remember === "change") {
61
61
  lastConfigChangeMessage = payload;
62
62
  }
63
63
  if (!webSocketServer?.clients || webSocketServer.clients.size === 0) {
@@ -102,7 +102,7 @@ function getFileDisplayInfo(filePath) {
102
102
  };
103
103
  }
104
104
  function formatChangeLabel(fileInfo) {
105
- return fileInfo.filePath || fileInfo.fileName || 'auth config';
105
+ return fileInfo.filePath || fileInfo.fileName || "auth config";
106
106
  }
107
107
  async function startStudioWithWatch(options) {
108
108
  const { port, host, openBrowser, authConfig, configPath, watchMode, geoDbPath } = options;
@@ -123,49 +123,49 @@ async function startStudioWithWatch(options) {
123
123
  const resolvedPath = isAbsolute(configPath) ? configPath : join(process.cwd(), configPath);
124
124
  const fileInfo = getFileDisplayInfo(configPath);
125
125
  broadcastWatchMessage({
126
- type: 'studio_status',
127
- status: 'up_to_date',
126
+ type: "studio_status",
127
+ status: "up_to_date",
128
128
  updatedAt: Date.now(),
129
129
  fileName: fileInfo.fileName,
130
130
  filePath: fileInfo.filePath,
131
- }, { remember: 'status' });
131
+ }, { remember: "status" });
132
132
  watcher = chokidar.watch(resolvedPath, {
133
133
  persistent: true,
134
134
  ignoreInitial: true,
135
135
  });
136
- watcher.on('change', async (changedPath) => {
136
+ watcher.on("change", async (changedPath) => {
137
137
  const changeInfo = getFileDisplayInfo(changedPath || configPath);
138
138
  const changeLabel = formatChangeLabel(changeInfo);
139
139
  process.stdout.write(`${chalk.yellow(`\n↻ Reloading Better Auth Studio (changed ${changeLabel})`)}\n`);
140
140
  try {
141
141
  broadcastWatchMessage({
142
- type: 'studio_status',
143
- status: 'refreshing',
142
+ type: "studio_status",
143
+ status: "refreshing",
144
144
  updatedAt: Date.now(),
145
145
  fileName: changeInfo.fileName,
146
146
  filePath: changeInfo.filePath,
147
- }, { remember: 'status' });
147
+ }, { remember: "status" });
148
148
  broadcastWatchMessage({
149
- type: 'config_change_detected',
150
- message: 'Auth configuration change detected',
149
+ type: "config_change_detected",
150
+ message: "Auth configuration change detected",
151
151
  fileName: changeInfo.fileName,
152
152
  filePath: changeInfo.filePath,
153
153
  changedAt: Date.now(),
154
154
  });
155
155
  await new Promise((resolve) => setTimeout(resolve, 75));
156
- if (currentStudio && typeof currentStudio.close === 'function') {
156
+ if (currentStudio && typeof currentStudio.close === "function") {
157
157
  await currentStudio.close();
158
158
  }
159
159
  const newAuthConfig = await findAuthConfig(configPath);
160
160
  if (!newAuthConfig) {
161
161
  broadcastWatchMessage({
162
- type: 'studio_status',
163
- status: 'error',
162
+ type: "studio_status",
163
+ status: "error",
164
164
  updatedAt: Date.now(),
165
- message: 'Unable to reload auth configuration.',
165
+ message: "Unable to reload auth configuration.",
166
166
  fileName: changeInfo.fileName,
167
167
  filePath: changeInfo.filePath,
168
- }, { remember: 'status' });
168
+ }, { remember: "status" });
169
169
  return;
170
170
  }
171
171
  const newStudioResult = await startStudio({
@@ -182,45 +182,45 @@ async function startStudioWithWatch(options) {
182
182
  currentStudio = newStudioResult.server;
183
183
  webSocketServer = newStudioResult.wss;
184
184
  broadcastWatchMessage({
185
- type: 'studio_status',
186
- status: 'up_to_date',
185
+ type: "studio_status",
186
+ status: "up_to_date",
187
187
  updatedAt: Date.now(),
188
188
  fileName: changeInfo.fileName,
189
189
  filePath: changeInfo.filePath,
190
- }, { remember: 'status' });
190
+ }, { remember: "status" });
191
191
  broadcastWatchMessage({
192
- type: 'config_changed',
193
- message: 'Configuration has been reloaded',
192
+ type: "config_changed",
193
+ message: "Configuration has been reloaded",
194
194
  fileName: changeInfo.fileName,
195
195
  filePath: changeInfo.filePath,
196
196
  changedAt: Date.now(),
197
- }, { remember: 'change' });
197
+ }, { remember: "change" });
198
198
  process.stdout.write(`${chalk.green(`✔ Reload complete (${changeLabel})`)}\n`);
199
199
  }
200
200
  catch (error) {
201
201
  broadcastWatchMessage({
202
- type: 'studio_status',
203
- status: 'error',
202
+ type: "studio_status",
203
+ status: "error",
204
204
  updatedAt: Date.now(),
205
- message: error instanceof Error ? error.message : 'Unknown error',
205
+ message: error instanceof Error ? error.message : "Unknown error",
206
206
  fileName: changeInfo.fileName,
207
207
  filePath: changeInfo.filePath,
208
- }, { remember: 'status' });
209
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
208
+ }, { remember: "status" });
209
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
210
210
  process.stdout.write(`${chalk.red(`✖ Reload failed (${changeLabel}) - ${errorMessage}`)}\n`);
211
211
  }
212
212
  });
213
- watcher.on('error', (_error) => { });
213
+ watcher.on("error", (_error) => { });
214
214
  }
215
215
  // Handle graceful shutdown
216
- process.on('SIGINT', async () => {
216
+ process.on("SIGINT", async () => {
217
217
  if (watcher) {
218
218
  await watcher.close();
219
219
  }
220
220
  if (webSocketServer) {
221
221
  webSocketServer.close();
222
222
  }
223
- if (currentStudio && typeof currentStudio.close === 'function') {
223
+ if (currentStudio && typeof currentStudio.close === "function") {
224
224
  await currentStudio.close();
225
225
  }
226
226
  process.exit(0);
@@ -230,28 +230,28 @@ const program = new Command();
230
230
  function getPackageVersion() {
231
231
  try {
232
232
  const __dirname = dirname(fileURLToPath(import.meta.url));
233
- const packageJsonPath = join(__dirname, '../package.json');
233
+ const packageJsonPath = join(__dirname, "../package.json");
234
234
  if (existsSync(packageJsonPath)) {
235
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
236
- return packageJson.version || '1.0.0';
235
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
236
+ return packageJson.version || "1.0.0";
237
237
  }
238
238
  }
239
239
  catch (_error) { }
240
- return '1.0.0';
240
+ return "1.0.0";
241
241
  }
242
242
  program
243
- .name('better-auth-studio')
244
- .description('Better Auth Studio - Admin dashboard for Better Auth')
243
+ .name("better-auth-studio")
244
+ .description("Better Auth Studio - Admin dashboard for Better Auth")
245
245
  .version(getPackageVersion());
246
246
  program
247
- .command('start')
248
- .description('Start Better Auth Studio')
249
- .option('-p, --port <port>', 'Port to run the studio on', '3002')
250
- .option('-h, --host <host>', 'Host to run the studio on', 'localhost')
251
- .option('-c, --config <path>', 'Path to the auth configuration file')
252
- .option('--geo-db <path>', 'Path to MaxMind GeoLite2 database file (.mmdb)')
253
- .option('-w, --watch', 'Watch for changes in auth config file and reload server')
254
- .option('--no-open', 'Do not open browser automatically')
247
+ .command("start")
248
+ .description("Start Better Auth Studio")
249
+ .option("-p, --port <port>", "Port to run the studio on", "3002")
250
+ .option("-h, --host <host>", "Host to run the studio on", "localhost")
251
+ .option("-c, --config <path>", "Path to the auth configuration file")
252
+ .option("--geo-db <path>", "Path to MaxMind GeoLite2 database file (.mmdb)")
253
+ .option("-w, --watch", "Watch for changes in auth config file and reload server")
254
+ .option("--no-open", "Do not open browser automatically")
255
255
  .action(async (options) => {
256
256
  try {
257
257
  const resolvedConfigPath = normalizeConfigPath(options.config) || (await findAuthConfigPath());
@@ -262,7 +262,7 @@ program
262
262
  if (!authConfig) {
263
263
  process.exit(1);
264
264
  }
265
- let databaseInfo = 'Not configured';
265
+ let databaseInfo = "Not configured";
266
266
  try {
267
267
  const detectedDb = await detectDatabaseWithDialect();
268
268
  if (detectedDb) {
@@ -271,15 +271,15 @@ program
271
271
  }
272
272
  catch (_error) { }
273
273
  // Fallback to existing logic
274
- if (databaseInfo === 'Not configured' && authConfig.database) {
274
+ if (databaseInfo === "Not configured" && authConfig.database) {
275
275
  const configPath = await findAuthConfigPath();
276
276
  if (configPath) {
277
- const content = readFileSync(configPath, 'utf-8');
278
- if (content.includes('drizzleAdapter')) {
279
- databaseInfo = 'Drizzle';
277
+ const content = readFileSync(configPath, "utf-8");
278
+ if (content.includes("drizzleAdapter")) {
279
+ databaseInfo = "Drizzle";
280
280
  }
281
- else if (content.includes('prismaAdapter')) {
282
- databaseInfo = 'Prisma';
281
+ else if (content.includes("prismaAdapter")) {
282
+ databaseInfo = "Prisma";
283
283
  }
284
284
  else if (authConfig.database.adapter && authConfig.database.provider) {
285
285
  const adapter = authConfig.database.adapter;
@@ -307,21 +307,21 @@ program
307
307
  }
308
308
  }
309
309
  }
310
- let _providersInfo = 'None';
311
- if (authConfig.socialProviders && typeof authConfig.socialProviders === 'object') {
310
+ let _providersInfo = "None";
311
+ if (authConfig.socialProviders && typeof authConfig.socialProviders === "object") {
312
312
  const providerNames = Object.keys(authConfig.socialProviders);
313
313
  if (providerNames.length > 0) {
314
- _providersInfo = providerNames.join(', ');
314
+ _providersInfo = providerNames.join(", ");
315
315
  }
316
316
  }
317
317
  else if (authConfig.providers && Array.isArray(authConfig.providers)) {
318
318
  const providerNames = authConfig.providers.map((p) => p.type || p.name).filter(Boolean);
319
319
  if (providerNames.length > 0) {
320
- _providersInfo = providerNames.join(', ');
320
+ _providersInfo = providerNames.join(", ");
321
321
  }
322
322
  }
323
323
  if (options.watch && !configPathForRoutes) {
324
- console.warn('⚠ Unable to locate your auth config file. Watch mode will be disabled for this session.');
324
+ console.warn("⚠ Unable to locate your auth config file. Watch mode will be disabled for this session.");
325
325
  }
326
326
  if (options.watch && configPathForRoutes) {
327
327
  await startStudioWithWatch({
@@ -351,15 +351,15 @@ program
351
351
  }
352
352
  });
353
353
  program
354
- .command('init')
355
- .description('Initialize Better Auth Studio for self-hosting')
356
- .option('--api-dir <path>', 'Custom app directory path for Next.js (e.g., "app" or "src/app"). The command will auto-detect "app" or "src/app" if not provided.')
354
+ .command("init")
355
+ .description("Initialize Better Auth Studio for self-hosting")
356
+ .option("--api-dir <path>", 'Custom app directory path for Next.js (e.g., "app" or "src/app"). The command will auto-detect "app" or "src/app" if not provided.')
357
357
  .action(async (options) => {
358
358
  try {
359
359
  await initCommand({ apiDir: options.apiDir });
360
360
  }
361
361
  catch (error) {
362
- console.error(chalk.red('Error initializing studio:'), error);
362
+ console.error(chalk.red("Error initializing studio:"), error);
363
363
  process.exit(1);
364
364
  }
365
365
  });
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BetterAuthOptions } from 'better-auth';
1
+ import type { BetterAuthOptions } from "better-auth";
2
2
  export interface AuthProvider {
3
3
  type: string;
4
4
  clientId?: string;
@@ -26,7 +26,7 @@ export interface AuthConfig {
26
26
  connectionString?: string;
27
27
  [key: string]: any;
28
28
  };
29
- emailAndPassword?: BetterAuthOptions['emailAndPassword'];
29
+ emailAndPassword?: BetterAuthOptions["emailAndPassword"];
30
30
  socialProviders?: Array<{
31
31
  id?: string;
32
32
  name: string;
@@ -35,9 +35,9 @@ export interface AuthConfig {
35
35
  redirectURI?: string;
36
36
  enabled: boolean;
37
37
  }>;
38
- trustedOrigins?: BetterAuthOptions['trustedOrigins'];
39
- plugins?: BetterAuthOptions['plugins'];
40
- advanced?: BetterAuthOptions['advanced'] & Record<string, any>;
38
+ trustedOrigins?: BetterAuthOptions["trustedOrigins"];
39
+ plugins?: BetterAuthOptions["plugins"];
40
+ advanced?: BetterAuthOptions["advanced"] & Record<string, any>;
41
41
  [key: string]: any;
42
42
  }
43
43
  declare let possiblePaths: string[];
package/dist/config.js CHANGED
@@ -1,14 +1,14 @@
1
- import fs, { existsSync } from 'node:fs';
2
- import path from 'node:path';
1
+ import fs, { existsSync } from "node:fs";
2
+ import path from "node:path";
3
3
  // @ts-expect-error - No types available
4
- import babelPresetReact from '@babel/preset-react';
4
+ import babelPresetReact from "@babel/preset-react";
5
5
  // @ts-expect-error - No types available
6
- import babelPresetTypeScript from '@babel/preset-typescript';
7
- import { BetterAuthError, logger } from 'better-auth';
8
- import { loadConfig } from 'c12';
9
- import { addSvelteKitEnvModules } from './add-svelte-kit-env-modules.js';
10
- import { getTsconfigInfo } from './get-tsconfig-info.js';
11
- let possiblePaths = ['auth.ts', 'auth.js', 'auth.server.js', 'auth.server.ts'];
6
+ import babelPresetTypeScript from "@babel/preset-typescript";
7
+ import { BetterAuthError, logger } from "better-auth";
8
+ import { loadConfig } from "c12";
9
+ import { addSvelteKitEnvModules } from "./add-svelte-kit-env-modules.js";
10
+ import { getTsconfigInfo } from "./get-tsconfig-info.js";
11
+ let possiblePaths = ["auth.ts", "auth.js", "auth.server.js", "auth.server.ts"];
12
12
  possiblePaths = [
13
13
  ...possiblePaths,
14
14
  ...possiblePaths.map((it) => `lib/server/${it}`),
@@ -26,7 +26,7 @@ function findTsconfigPath(startDir) {
26
26
  let currentDir = path.resolve(startDir);
27
27
  const root = path.parse(currentDir).root;
28
28
  while (currentDir !== root) {
29
- const tsconfigPath = path.join(currentDir, 'tsconfig.json');
29
+ const tsconfigPath = path.join(currentDir, "tsconfig.json");
30
30
  if (fs.existsSync(tsconfigPath)) {
31
31
  return currentDir;
32
32
  }
@@ -36,7 +36,7 @@ function findTsconfigPath(startDir) {
36
36
  }
37
37
  function resolveReferencePath(configDir, refPath) {
38
38
  const resolvedPath = path.resolve(configDir, refPath);
39
- if (refPath.endsWith('.json')) {
39
+ if (refPath.endsWith(".json")) {
40
40
  return resolvedPath;
41
41
  }
42
42
  if (fs.existsSync(resolvedPath)) {
@@ -48,7 +48,7 @@ function resolveReferencePath(configDir, refPath) {
48
48
  }
49
49
  catch { }
50
50
  }
51
- return path.resolve(configDir, refPath, 'tsconfig.json');
51
+ return path.resolve(configDir, refPath, "tsconfig.json");
52
52
  }
53
53
  function getPathAliasesRecursive(tsconfigPath, visited = new Set()) {
54
54
  if (visited.has(tsconfigPath)) {
@@ -61,16 +61,16 @@ function getPathAliasesRecursive(tsconfigPath, visited = new Set()) {
61
61
  }
62
62
  try {
63
63
  const tsConfig = getTsconfigInfo(undefined, tsconfigPath);
64
- const { paths = {}, baseUrl = '.' } = tsConfig.compilerOptions || {};
64
+ const { paths = {}, baseUrl = "." } = tsConfig.compilerOptions || {};
65
65
  const result = {};
66
66
  const configDir = path.dirname(tsconfigPath);
67
67
  const obj = Object.entries(paths);
68
68
  for (const [alias, aliasPaths] of obj) {
69
69
  for (const aliasedPath of aliasPaths) {
70
70
  const resolvedBaseUrl = path.resolve(configDir, baseUrl);
71
- const finalAlias = alias.slice(-1) === '*' ? alias.slice(0, -1) : alias;
72
- const finalAliasedPath = aliasedPath.slice(-1) === '*' ? aliasedPath.slice(0, -1) : aliasedPath;
73
- result[finalAlias || ''] = path.join(resolvedBaseUrl, finalAliasedPath);
71
+ const finalAlias = alias.slice(-1) === "*" ? alias.slice(0, -1) : alias;
72
+ const finalAliasedPath = aliasedPath.slice(-1) === "*" ? aliasedPath.slice(0, -1) : aliasedPath;
73
+ result[finalAlias || ""] = path.join(resolvedBaseUrl, finalAliasedPath);
74
74
  }
75
75
  }
76
76
  if (tsConfig.extends) {
@@ -104,7 +104,7 @@ function getPathAliasesRecursive(tsconfigPath, visited = new Set()) {
104
104
  }
105
105
  }
106
106
  export function getPathAliases(cwd) {
107
- const tsConfigPath = path.join(cwd, 'tsconfig.json');
107
+ const tsConfigPath = path.join(cwd, "tsconfig.json");
108
108
  if (!fs.existsSync(tsConfigPath)) {
109
109
  return null;
110
110
  }
@@ -117,7 +117,7 @@ export function getPathAliases(cwd) {
117
117
  if (error instanceof Error) {
118
118
  logger.error(error.message);
119
119
  }
120
- throw new BetterAuthError('Error parsing tsconfig.json');
120
+ throw new BetterAuthError("Error parsing tsconfig.json");
121
121
  }
122
122
  }
123
123
  /**
@@ -139,21 +139,21 @@ const jitiOptions = (cwd, noCache = false) => {
139
139
  allExtensions: true,
140
140
  },
141
141
  ],
142
- [babelPresetReact, { runtime: 'automatic' }],
142
+ [babelPresetReact, { runtime: "automatic" }],
143
143
  ],
144
144
  },
145
145
  },
146
- extensions: ['.ts', '.js', '.tsx', '.jsx'],
146
+ extensions: [".ts", ".js", ".tsx", ".jsx"],
147
147
  alias,
148
148
  interopDefault: true,
149
149
  };
150
150
  };
151
151
  const isDefaultExport = (object) => {
152
- return (typeof object === 'object' &&
152
+ return (typeof object === "object" &&
153
153
  object !== null &&
154
154
  !Array.isArray(object) &&
155
155
  Object.keys(object).length > 0 &&
156
- 'options' in object);
156
+ "options" in object);
157
157
  };
158
158
  export async function getConfig({ cwd, configPath, shouldThrowOnError = false, noCache = false, }) {
159
159
  try {
@@ -171,14 +171,14 @@ export async function getConfig({ cwd, configPath, shouldThrowOnError = false, n
171
171
  dotenv: true,
172
172
  jitiOptions: jitiOptions(projectRoot, noCache),
173
173
  });
174
- if (!('auth' in config) && !isDefaultExport(config)) {
174
+ if (!("auth" in config) && !isDefaultExport(config)) {
175
175
  if (shouldThrowOnError) {
176
176
  throw new Error(`Couldn't read your auth config in ${resolvedPath}. Make sure to default export your auth instance or to export as a variable named auth.`);
177
177
  }
178
178
  logger.error(`Couldn't read your auth config in ${resolvedPath}. Make sure to default export your auth instance or to export as a variable named auth.`);
179
179
  process.exit(1);
180
180
  }
181
- configFile = 'auth' in config ? config.auth?.options : config.options;
181
+ configFile = "auth" in config ? config.auth?.options : config.options;
182
182
  }
183
183
  if (!configFile) {
184
184
  for (const possiblePath of possiblePaths) {
@@ -197,18 +197,18 @@ export async function getConfig({ cwd, configPath, shouldThrowOnError = false, n
197
197
  throw new Error("Couldn't read your auth config. Make sure to default export your auth instance or to export as a variable named auth.");
198
198
  }
199
199
  logger.error("Couldn't read your auth config.");
200
- logger.info('Make sure to default export your auth instance or to export as a variable named auth.');
200
+ logger.info("Make sure to default export your auth instance or to export as a variable named auth.");
201
201
  process.exit(1);
202
202
  }
203
203
  break;
204
204
  }
205
205
  }
206
206
  catch (e) {
207
- if (typeof e === 'object' &&
207
+ if (typeof e === "object" &&
208
208
  e &&
209
- 'message' in e &&
210
- typeof e.message === 'string' &&
211
- e.message.includes('This module cannot be imported from a Client Component module')) {
209
+ "message" in e &&
210
+ typeof e.message === "string" &&
211
+ e.message.includes("This module cannot be imported from a Client Component module")) {
212
212
  if (shouldThrowOnError) {
213
213
  throw new Error(`Please remove import 'server-only' from your auth config file temporarily. The CLI cannot resolve the configuration with it included. You can re-add it after running the CLI.`);
214
214
  }
@@ -226,11 +226,11 @@ export async function getConfig({ cwd, configPath, shouldThrowOnError = false, n
226
226
  return configFile;
227
227
  }
228
228
  catch (e) {
229
- if (typeof e === 'object' &&
229
+ if (typeof e === "object" &&
230
230
  e &&
231
- 'message' in e &&
232
- typeof e.message === 'string' &&
233
- e.message.includes('This module cannot be imported from a Client Component module')) {
231
+ "message" in e &&
232
+ typeof e.message === "string" &&
233
+ e.message.includes("This module cannot be imported from a Client Component module")) {
234
234
  if (shouldThrowOnError) {
235
235
  throw new Error(`Please remove import 'server-only' from your auth config file temporarily. The CLI cannot resolve the configuration with it included. You can re-add it after running the CLI.`);
236
236
  }
@@ -255,8 +255,8 @@ export async function findAuthConfig(configPath) {
255
255
  if (betterAuthConfig) {
256
256
  const authConfig = {
257
257
  database: {
258
- type: betterAuthConfig.database ? 'drizzle' : 'unknown',
259
- adapter: 'drizzle-adapter',
258
+ type: betterAuthConfig.database ? "drizzle" : "unknown",
259
+ adapter: "drizzle-adapter",
260
260
  ...betterAuthConfig.database,
261
261
  },
262
262
  emailAndPassword: {
@@ -279,10 +279,10 @@ export async function findAuthConfig(configPath) {
279
279
  : [],
280
280
  trustedOrigins: Array.isArray(betterAuthConfig.trustedOrigins)
281
281
  ? betterAuthConfig.trustedOrigins
282
- : ['http://localhost:3000'],
282
+ : ["http://localhost:3000"],
283
283
  advanced: {
284
284
  defaultCookieAttributes: betterAuthConfig.advanced?.defaultCookieAttributes || {
285
- sameSite: 'none',
285
+ sameSite: "none",
286
286
  secure: true,
287
287
  httpOnly: true,
288
288
  },
@@ -1,4 +1,4 @@
1
- import type { StudioConfig, UniversalRequest, UniversalResponse } from '../types/handler.js';
1
+ import type { StudioConfig, UniversalRequest, UniversalResponse } from "../types/handler.js";
2
2
  /**
3
3
  * Initialize event ingestion and inject hooks
4
4
  */