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
@@ -1,11 +1,11 @@
1
- import { existsSync, readFileSync, realpathSync, statSync } from 'fs';
2
- import { dirname, extname, join, resolve } from 'path';
3
- import { fileURLToPath } from 'url';
4
- import { createClickHouseProvider, createHttpProvider, createPostgresProvider, createSqliteProvider, createStorageProvider, } from '../providers/events/helpers.js';
5
- import { initializeEventIngestion, isEventIngestionInitialized } from '../utils/event-ingestion.js';
6
- import { injectEventHooks } from '../utils/hook-injector.js';
7
- import { serveIndexHtml as getIndexHtml } from '../utils/html-injector.js';
8
- import { decryptSession, isSessionValid, STUDIO_COOKIE_NAME } from '../utils/session.js';
1
+ import { existsSync, readFileSync, realpathSync, statSync } from "fs";
2
+ import { dirname, extname, join, resolve } from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { createClickHouseProvider, createHttpProvider, createPostgresProvider, createSqliteProvider, createStorageProvider, } from "../providers/events/helpers.js";
5
+ import { initializeEventIngestion, isEventIngestionInitialized } from "../utils/event-ingestion.js";
6
+ import { injectEventHooks } from "../utils/hook-injector.js";
7
+ import { serveIndexHtml as getIndexHtml } from "../utils/html-injector.js";
8
+ import { decryptSession, isSessionValid, STUDIO_COOKIE_NAME } from "../utils/session.js";
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
11
11
  const __realdir = (() => {
@@ -23,15 +23,15 @@ export async function initializeEventIngestionAndHooks(config) {
23
23
  if (config.events?.enabled && !isEventIngestionInitialized()) {
24
24
  let provider;
25
25
  if (config.events.provider &&
26
- typeof config.events.provider === 'object' &&
27
- typeof config.events.provider.ingest === 'function') {
26
+ typeof config.events.provider === "object" &&
27
+ typeof config.events.provider.ingest === "function") {
28
28
  provider = config.events.provider;
29
29
  }
30
30
  else if (config.events.client && config.events.clientType) {
31
31
  switch (config.events.clientType) {
32
- case 'postgres':
33
- case 'prisma':
34
- case 'drizzle':
32
+ case "postgres":
33
+ case "prisma":
34
+ case "drizzle":
35
35
  try {
36
36
  provider = createPostgresProvider({
37
37
  client: config.events.client,
@@ -43,7 +43,7 @@ export async function initializeEventIngestionAndHooks(config) {
43
43
  throw error;
44
44
  }
45
45
  break;
46
- case 'sqlite':
46
+ case "sqlite":
47
47
  try {
48
48
  provider = createSqliteProvider({
49
49
  client: config.events.client,
@@ -54,13 +54,13 @@ export async function initializeEventIngestionAndHooks(config) {
54
54
  throw error;
55
55
  }
56
56
  break;
57
- case 'clickhouse':
57
+ case "clickhouse":
58
58
  provider = createClickHouseProvider({
59
59
  client: config.events.client,
60
60
  table: config.events.tableName,
61
61
  });
62
62
  break;
63
- case 'http':
63
+ case "http":
64
64
  provider = createHttpProvider({
65
65
  url: config.events.client,
66
66
  headers: config.events.headers || {},
@@ -73,7 +73,7 @@ export async function initializeEventIngestionAndHooks(config) {
73
73
  if (authAdapter) {
74
74
  provider = createStorageProvider({
75
75
  adapter: authAdapter,
76
- tableName: config.events.tableName || 'auth_events',
76
+ tableName: config.events.tableName || "auth_events",
77
77
  });
78
78
  }
79
79
  }
@@ -95,62 +95,62 @@ export async function initializeEventIngestionAndHooks(config) {
95
95
  export async function handleStudioRequest(request, config) {
96
96
  try {
97
97
  const isSelfHosted = !!config.basePath;
98
- const basePath = config.basePath || '';
98
+ const basePath = config.basePath || "";
99
99
  let path = request.url;
100
- const [pathname, queryString] = path.split('?');
100
+ const [pathname, queryString] = path.split("?");
101
101
  if (isSelfHosted && basePath) {
102
- const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
102
+ const normalizedBasePath = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
103
103
  let normalizedPath = pathname;
104
- if (normalizedPath === normalizedBasePath || normalizedPath === normalizedBasePath + '/') {
105
- normalizedPath = '/';
104
+ if (normalizedPath === normalizedBasePath || normalizedPath === normalizedBasePath + "/") {
105
+ normalizedPath = "/";
106
106
  }
107
- else if (normalizedPath.startsWith(normalizedBasePath + '/')) {
107
+ else if (normalizedPath.startsWith(normalizedBasePath + "/")) {
108
108
  normalizedPath = normalizedPath.slice(normalizedBasePath.length);
109
109
  }
110
110
  else if (normalizedPath.startsWith(normalizedBasePath)) {
111
- normalizedPath = normalizedPath.slice(normalizedBasePath.length) || '/';
111
+ normalizedPath = normalizedPath.slice(normalizedBasePath.length) || "/";
112
112
  }
113
- path = normalizedPath + (queryString ? '?' + queryString : '');
113
+ path = normalizedPath + (queryString ? "?" + queryString : "");
114
114
  }
115
115
  else {
116
- path = pathname + (queryString ? '?' + queryString : '');
116
+ path = pathname + (queryString ? "?" + queryString : "");
117
117
  }
118
- if (path === '' || path === '/') {
119
- path = '/';
118
+ if (path === "" || path === "/") {
119
+ path = "/";
120
120
  }
121
- if (path.startsWith('/assets/') ||
122
- path === '/vite.svg' ||
123
- path === '/favicon.svg' ||
124
- path === '/logo.png') {
121
+ if (path.startsWith("/assets/") ||
122
+ path === "/vite.svg" ||
123
+ path === "/favicon.svg" ||
124
+ path === "/logo.png") {
125
125
  return handleStaticFile(path, config);
126
126
  }
127
- if (path === '/') {
127
+ if (path === "/") {
128
128
  return handleStaticFile(path, config);
129
129
  }
130
- const spaRoutes = ['/login', '/access-denied'];
131
- if (spaRoutes.some((r) => path === r || path.startsWith(r + '?'))) {
130
+ const spaRoutes = ["/login", "/access-denied"];
131
+ if (spaRoutes.some((r) => path === r || path.startsWith(r + "?"))) {
132
132
  return handleStaticFile(path, config);
133
133
  }
134
- if (path.startsWith('/api/')) {
134
+ if (path.startsWith("/api/")) {
135
135
  if (isSelfHosted && isProtectedApiPath(path)) {
136
136
  const sessionResult = verifyStudioSession(request, config);
137
137
  if (!sessionResult.valid) {
138
- return jsonResponse(401, { error: 'Unauthorized', message: sessionResult.error });
138
+ return jsonResponse(401, { error: "Unauthorized", message: sessionResult.error });
139
139
  }
140
140
  }
141
141
  return await handleApiRoute(request, path, config);
142
142
  }
143
143
  if (isSelfHosted) {
144
- const acceptHeader = request.headers['accept'] || request.headers['Accept'] || '';
145
- const wantsJson = acceptHeader.includes('application/json') ||
146
- acceptHeader === '*/*' ||
147
- !acceptHeader.includes('text/html');
144
+ const acceptHeader = request.headers["accept"] || request.headers["Accept"] || "";
145
+ const wantsJson = acceptHeader.includes("application/json") ||
146
+ acceptHeader === "*/*" ||
147
+ !acceptHeader.includes("text/html");
148
148
  if (wantsJson) {
149
- const apiPath = '/api' + path;
149
+ const apiPath = "/api" + path;
150
150
  if (isProtectedApiPath(apiPath)) {
151
151
  const sessionResult = verifyStudioSession(request, config);
152
152
  if (!sessionResult.valid) {
153
- return jsonResponse(401, { error: 'Unauthorized', message: sessionResult.error });
153
+ return jsonResponse(401, { error: "Unauthorized", message: sessionResult.error });
154
154
  }
155
155
  }
156
156
  return await handleApiRoute(request, apiPath, config);
@@ -161,10 +161,10 @@ export async function handleStudioRequest(request, config) {
161
161
  return handleStaticFile(path, config);
162
162
  }
163
163
  catch (error) {
164
- console.error('Studio handler error:', error);
164
+ console.error("Studio handler error:", error);
165
165
  return jsonResponse(500, {
166
- error: 'Internal server error',
167
- message: error instanceof Error ? error.message : 'Unknown error',
166
+ error: "Internal server error",
167
+ message: error instanceof Error ? error.message : "Unknown error",
168
168
  });
169
169
  }
170
170
  }
@@ -192,46 +192,46 @@ function getSessionSecret(config) {
192
192
  return (config.access?.secret ||
193
193
  config.auth?.options?.secret ||
194
194
  process.env.BETTER_AUTH_SECRET ||
195
- 'studio-default-secret');
195
+ "studio-default-secret");
196
196
  }
197
197
  function parseCookies(cookieHeader) {
198
198
  if (!cookieHeader)
199
199
  return {};
200
200
  const cookies = {};
201
- cookieHeader.split(';').forEach((part) => {
202
- const [name, ...rest] = part.trim().split('=');
201
+ cookieHeader.split(";").forEach((part) => {
202
+ const [name, ...rest] = part.trim().split("=");
203
203
  if (name) {
204
- cookies[name] = rest.join('=');
204
+ cookies[name] = rest.join("=");
205
205
  }
206
206
  });
207
207
  return cookies;
208
208
  }
209
209
  function verifyStudioSession(request, config) {
210
- const cookieHeader = request.headers['cookie'] || request.headers['Cookie'];
210
+ const cookieHeader = request.headers["cookie"] || request.headers["Cookie"];
211
211
  const cookies = parseCookies(cookieHeader);
212
212
  const sessionCookie = cookies[STUDIO_COOKIE_NAME];
213
213
  if (!sessionCookie) {
214
- return { valid: false, error: 'No session cookie' };
214
+ return { valid: false, error: "No session cookie" };
215
215
  }
216
216
  const session = decryptSession(sessionCookie, getSessionSecret(config));
217
217
  if (!isSessionValid(session)) {
218
- return { valid: false, error: 'Session expired' };
218
+ return { valid: false, error: "Session expired" };
219
219
  }
220
220
  return { valid: true, session };
221
221
  }
222
222
  function isProtectedApiPath(path) {
223
223
  const publicPaths = [
224
- '/api/auth/sign-in',
225
- '/api/auth/session',
226
- '/api/auth/logout',
227
- '/api/auth/verify',
228
- '/api/auth/oauth',
229
- '/api/health',
224
+ "/api/auth/sign-in",
225
+ "/api/auth/session",
226
+ "/api/auth/logout",
227
+ "/api/auth/verify",
228
+ "/api/auth/oauth",
229
+ "/api/health",
230
230
  ];
231
231
  return !publicPaths.some((p) => path.startsWith(p));
232
232
  }
233
233
  async function handleApiRoute(request, path, config) {
234
- const { routeApiRequest } = await import('../routes/api-router.js');
234
+ const { routeApiRequest } = await import("../routes/api-router.js");
235
235
  try {
236
236
  const result = await routeApiRequest({
237
237
  path: path,
@@ -239,18 +239,18 @@ async function handleApiRoute(request, path, config) {
239
239
  headers: request.headers,
240
240
  body: request.body,
241
241
  auth: config.auth,
242
- basePath: config.basePath || '/api/studio',
242
+ basePath: config.basePath || "/api/studio",
243
243
  accessConfig: config.access,
244
244
  studioConfig: config,
245
245
  });
246
- const headers = { 'Content-Type': 'application/json' };
246
+ const headers = { "Content-Type": "application/json" };
247
247
  if (result.cookies && result.cookies.length > 0) {
248
248
  const cookieStrings = result.cookies.map((c) => {
249
249
  let cookie = `${c.name}=${c.value}`;
250
250
  if (c.options.httpOnly)
251
- cookie += '; HttpOnly';
251
+ cookie += "; HttpOnly";
252
252
  if (c.options.secure)
253
- cookie += '; Secure';
253
+ cookie += "; Secure";
254
254
  if (c.options.sameSite)
255
255
  cookie += `; SameSite=${c.options.sameSite}`;
256
256
  if (c.options.maxAge !== undefined)
@@ -259,7 +259,7 @@ async function handleApiRoute(request, path, config) {
259
259
  cookie += `; Path=${c.options.path}`;
260
260
  return cookie;
261
261
  });
262
- headers['Set-Cookie'] = cookieStrings.join(', ');
262
+ headers["Set-Cookie"] = cookieStrings.join(", ");
263
263
  }
264
264
  return {
265
265
  status: result.status,
@@ -268,26 +268,26 @@ async function handleApiRoute(request, path, config) {
268
268
  };
269
269
  }
270
270
  catch (error) {
271
- console.error('API route error:', error);
272
- return jsonResponse(500, { error: 'Internal server error' });
271
+ console.error("API route error:", error);
272
+ return jsonResponse(500, { error: "Internal server error" });
273
273
  }
274
274
  }
275
275
  function isNextJsProject() {
276
276
  try {
277
277
  const cwd = process.cwd();
278
278
  // Check for .next directory (build output)
279
- if (existsSync(join(cwd, '.next'))) {
279
+ if (existsSync(join(cwd, ".next"))) {
280
280
  return true;
281
281
  }
282
282
  // Check for next.config.js or next.config.ts
283
- if (existsSync(join(cwd, 'next.config.js')) || existsSync(join(cwd, 'next.config.ts'))) {
283
+ if (existsSync(join(cwd, "next.config.js")) || existsSync(join(cwd, "next.config.ts"))) {
284
284
  return true;
285
285
  }
286
286
  // Check package.json for next dependency
287
- const pkgPath = join(cwd, 'package.json');
287
+ const pkgPath = join(cwd, "package.json");
288
288
  if (existsSync(pkgPath)) {
289
289
  try {
290
- const pkgContent = readFileSync(pkgPath, 'utf-8');
290
+ const pkgContent = readFileSync(pkgPath, "utf-8");
291
291
  const pkg = JSON.parse(pkgContent);
292
292
  if (pkg.dependencies?.next || pkg.devDependencies?.next) {
293
293
  return true;
@@ -301,14 +301,14 @@ function isNextJsProject() {
301
301
  }
302
302
  function findPublicDir() {
303
303
  const candidates = [];
304
- const debug = process.env.VERCEL === '1' || process.env.NODE_ENV === 'production';
304
+ const debug = process.env.VERCEL === "1" || process.env.NODE_ENV === "production";
305
305
  const isNextJs = isNextJsProject();
306
306
  // PRIORITY 1: Direct resolution from __dirname (most reliable)
307
307
  if (__dirname) {
308
- const directPublic = resolve(__dirname, '../public');
308
+ const directPublic = resolve(__dirname, "../public");
309
309
  candidates.unshift(directPublic);
310
310
  if (debug && !existsSync(directPublic)) {
311
- console.log('[Studio] Direct path not found:', directPublic);
311
+ console.log("[Studio] Direct path not found:", directPublic);
312
312
  }
313
313
  }
314
314
  // PRIORITY 2: Extract package root from __dirname path (handles pnpm store)
@@ -316,19 +316,19 @@ function findPublicDir() {
316
316
  const packageMatch = __dirname.match(/(.+[/\\]better-auth-studio)(?:[/\\]dist[/\\]core)?$/);
317
317
  if (packageMatch) {
318
318
  const packageRoot = packageMatch[1];
319
- candidates.unshift(join(packageRoot, 'dist', 'public'));
319
+ candidates.unshift(join(packageRoot, "dist", "public"));
320
320
  }
321
321
  }
322
322
  // PRIORITY 3: Walk up from __dirname to find node_modules
323
323
  if (__dirname) {
324
324
  let searchDir = __dirname;
325
325
  for (let i = 0; i < 10; i++) {
326
- const nmPath = join(searchDir, 'node_modules', 'better-auth-studio', 'dist', 'public');
326
+ const nmPath = join(searchDir, "node_modules", "better-auth-studio", "dist", "public");
327
327
  if (existsSync(nmPath)) {
328
328
  candidates.unshift(nmPath);
329
329
  break;
330
330
  }
331
- const parent = resolve(searchDir, '..');
331
+ const parent = resolve(searchDir, "..");
332
332
  if (parent === searchDir)
333
333
  break;
334
334
  searchDir = parent;
@@ -340,16 +340,16 @@ function findPublicDir() {
340
340
  if (moduleUrl) {
341
341
  const modulePath = fileURLToPath(moduleUrl);
342
342
  const moduleDir = dirname(modulePath);
343
- candidates.push(resolve(moduleDir, '../public'));
343
+ candidates.push(resolve(moduleDir, "../public"));
344
344
  // Also walk up from module location to find node_modules
345
345
  let moduleSearchDir = moduleDir;
346
346
  for (let i = 0; i < 10; i++) {
347
- const nmPath = join(moduleSearchDir, 'node_modules', 'better-auth-studio', 'dist', 'public');
347
+ const nmPath = join(moduleSearchDir, "node_modules", "better-auth-studio", "dist", "public");
348
348
  if (existsSync(nmPath)) {
349
349
  candidates.push(nmPath);
350
350
  break;
351
351
  }
352
- const parent = resolve(moduleSearchDir, '..');
352
+ const parent = resolve(moduleSearchDir, "..");
353
353
  if (parent === moduleSearchDir)
354
354
  break;
355
355
  moduleSearchDir = parent;
@@ -361,9 +361,9 @@ function findPublicDir() {
361
361
  if (isNextJs) {
362
362
  try {
363
363
  const cwd = process.cwd();
364
- const nextServer = join(cwd, '.next', 'server');
364
+ const nextServer = join(cwd, ".next", "server");
365
365
  if (existsSync(nextServer)) {
366
- candidates.push(join(nextServer, 'node_modules', 'better-auth-studio', 'dist', 'public'), join(nextServer, 'chunks', 'node_modules', 'better-auth-studio', 'dist', 'public'));
366
+ candidates.push(join(nextServer, "node_modules", "better-auth-studio", "dist", "public"), join(nextServer, "chunks", "node_modules", "better-auth-studio", "dist", "public"));
367
367
  }
368
368
  }
369
369
  catch (err) {
@@ -373,7 +373,7 @@ function findPublicDir() {
373
373
  // PRIORITY 6: Current working directory (all projects)
374
374
  try {
375
375
  const cwd = process.cwd();
376
- candidates.push(join(cwd, 'node_modules', 'better-auth-studio', 'dist', 'public'), join(cwd, 'static', 'studio'));
376
+ candidates.push(join(cwd, "node_modules", "better-auth-studio", "dist", "public"), join(cwd, "static", "studio"));
377
377
  }
378
378
  catch (err) { }
379
379
  // Validate candidates
@@ -382,10 +382,10 @@ function findPublicDir() {
382
382
  if (existsSync(candidate)) {
383
383
  const stats = statSync(candidate);
384
384
  if (stats.isDirectory()) {
385
- const indexPath = join(candidate, 'index.html');
385
+ const indexPath = join(candidate, "index.html");
386
386
  if (existsSync(indexPath)) {
387
387
  if (debug) {
388
- console.log('[Studio] ✓ Found public directory:', candidate);
388
+ console.log("[Studio] ✓ Found public directory:", candidate);
389
389
  }
390
390
  return candidate;
391
391
  }
@@ -395,9 +395,9 @@ function findPublicDir() {
395
395
  catch (error) { }
396
396
  }
397
397
  if (debug) {
398
- console.error('[Studio] ✗ Could not find public directory');
399
- console.error('[Studio] __dirname:', __dirname);
400
- console.error('[Studio] Checked', candidates.length, 'candidates');
398
+ console.error("[Studio] ✗ Could not find public directory");
399
+ console.error("[Studio] __dirname:", __dirname);
400
+ console.error("[Studio] Checked", candidates.length, "candidates");
401
401
  }
402
402
  return null;
403
403
  }
@@ -407,12 +407,12 @@ function handleStaticFile(path, config) {
407
407
  cachedPublicDir = findPublicDir();
408
408
  }
409
409
  if (!cachedPublicDir) {
410
- if (path === '/' || path === '') {
410
+ if (path === "/" || path === "") {
411
411
  return {
412
412
  status: 503,
413
413
  headers: {
414
- 'Content-Type': 'text/html',
415
- 'Cache-Control': 'no-cache',
414
+ "Content-Type": "text/html",
415
+ "Cache-Control": "no-cache",
416
416
  },
417
417
  body: `<!DOCTYPE html>
418
418
  <html>
@@ -519,15 +519,15 @@ function handleStaticFile(path, config) {
519
519
  };
520
520
  }
521
521
  return jsonResponse(503, {
522
- error: 'Public directory not found',
523
- message: 'Studio UI assets could not be located. This is likely a Vercel bundling issue.',
524
- suggestion: 'For Next.js, add outputFileTracingIncludes to next.config.js to include the public directory. See the HTML error page for details.',
522
+ error: "Public directory not found",
523
+ message: "Studio UI assets could not be located. This is likely a Vercel bundling issue.",
524
+ suggestion: "For Next.js, add outputFileTracingIncludes to next.config.js to include the public directory. See the HTML error page for details.",
525
525
  });
526
526
  }
527
527
  return handleStaticFileFromDir(path, cachedPublicDir, config);
528
528
  }
529
529
  function handleStaticFileFromDir(path, publicDir, config) {
530
- if (path === '/' || path === '') {
530
+ if (path === "/" || path === "") {
531
531
  return serveIndexHtml(publicDir, config);
532
532
  }
533
533
  const filePath = join(publicDir, path);
@@ -537,8 +537,8 @@ function handleStaticFileFromDir(path, publicDir, config) {
537
537
  return {
538
538
  status: 200,
539
539
  headers: {
540
- 'Content-Type': contentType,
541
- 'Cache-Control': getCacheControl(path),
540
+ "Content-Type": contentType,
541
+ "Cache-Control": getCacheControl(path),
542
542
  },
543
543
  body: content,
544
544
  };
@@ -550,8 +550,8 @@ function serveIndexHtml(publicDir, config) {
550
550
  return {
551
551
  status: 200,
552
552
  headers: {
553
- 'Content-Type': 'text/html',
554
- 'Cache-Control': 'no-cache',
553
+ "Content-Type": "text/html",
554
+ "Cache-Control": "no-cache",
555
555
  },
556
556
  body: html,
557
557
  };
@@ -559,31 +559,31 @@ function serveIndexHtml(publicDir, config) {
559
559
  function jsonResponse(status, data) {
560
560
  return {
561
561
  status,
562
- headers: { 'Content-Type': 'application/json' },
562
+ headers: { "Content-Type": "application/json" },
563
563
  body: JSON.stringify(data),
564
564
  };
565
565
  }
566
566
  function getContentType(ext) {
567
567
  const types = {
568
- '.html': 'text/html',
569
- '.js': 'application/javascript',
570
- '.css': 'text/css',
571
- '.json': 'application/json',
572
- '.png': 'image/png',
573
- '.jpg': 'image/jpeg',
574
- '.jpeg': 'image/jpeg',
575
- '.svg': 'image/svg+xml',
576
- '.ico': 'image/x-icon',
577
- '.woff': 'font/woff',
578
- '.woff2': 'font/woff2',
579
- '.ttf': 'font/ttf',
568
+ ".html": "text/html",
569
+ ".js": "application/javascript",
570
+ ".css": "text/css",
571
+ ".json": "application/json",
572
+ ".png": "image/png",
573
+ ".jpg": "image/jpeg",
574
+ ".jpeg": "image/jpeg",
575
+ ".svg": "image/svg+xml",
576
+ ".ico": "image/x-icon",
577
+ ".woff": "font/woff",
578
+ ".woff2": "font/woff2",
579
+ ".ttf": "font/ttf",
580
580
  };
581
- return types[ext] || 'application/octet-stream';
581
+ return types[ext] || "application/octet-stream";
582
582
  }
583
583
  function getCacheControl(path) {
584
584
  if (path.match(/\.(js|css|png|jpg|jpeg|svg|woff|woff2|ttf)$/)) {
585
- return 'public, max-age=31536000, immutable';
585
+ return "public, max-age=31536000, immutable";
586
586
  }
587
- return 'no-cache';
587
+ return "no-cache";
588
588
  }
589
589
  //# sourceMappingURL=handler.js.map
package/dist/data.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AuthConfig } from './config.js';
1
+ import type { AuthConfig } from "./config.js";
2
2
  export interface User {
3
3
  id: string;
4
4
  email?: string;
@@ -34,5 +34,5 @@ export interface PaginatedResult<T> {
34
34
  limit: number;
35
35
  totalPages: number;
36
36
  }
37
- export declare function getAuthData(_authConfig: AuthConfig, type?: 'stats' | 'users' | 'sessions' | 'providers' | 'deleteUser' | 'updateUser' | 'analytics', options?: any, configPath?: string, preloadedAdapter?: any): Promise<any>;
37
+ export declare function getAuthData(_authConfig: AuthConfig, type?: "stats" | "users" | "sessions" | "providers" | "deleteUser" | "updateUser" | "analytics", options?: any, configPath?: string, preloadedAdapter?: any): Promise<any>;
38
38
  //# sourceMappingURL=data.d.ts.map