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/studio.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { WebSocket } from 'ws';
2
- import { WebSocketServer } from 'ws';
3
- import type { AuthConfig } from './config.js';
1
+ import type { WebSocket } from "ws";
2
+ import { WebSocketServer } from "ws";
3
+ import type { AuthConfig } from "./config.js";
4
4
  interface StudioOptions {
5
5
  port: number;
6
6
  host: string;
package/dist/studio.js CHANGED
@@ -1,20 +1,20 @@
1
- import { existsSync } from 'node:fs';
2
- import { createServer } from 'node:http';
3
- import { dirname, join } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
1
+ import { existsSync } from "node:fs";
2
+ import { createServer } from "node:http";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
5
  // @ts-expect-error - No types available
6
- import babelPresetReact from '@babel/preset-react';
6
+ import babelPresetReact from "@babel/preset-react";
7
7
  // @ts-expect-error - No types available
8
- import babelPresetTypeScript from '@babel/preset-typescript';
9
- import { loadConfig } from 'c12';
10
- import chalk from 'chalk';
11
- import cors from 'cors';
12
- import express from 'express';
13
- import open from 'open';
14
- import { WebSocketServer } from 'ws';
15
- import { getPathAliases } from './config.js';
16
- import { createRoutes } from './routes.js';
17
- import { serveIndexHtml } from './utils/html-injector.js';
8
+ import babelPresetTypeScript from "@babel/preset-typescript";
9
+ import { loadConfig } from "c12";
10
+ import chalk from "chalk";
11
+ import cors from "cors";
12
+ import express from "express";
13
+ import open from "open";
14
+ import { WebSocketServer } from "ws";
15
+ import { getPathAliases } from "./config.js";
16
+ import { createRoutes } from "./routes.js";
17
+ import { serveIndexHtml } from "./utils/html-injector.js";
18
18
  const __filename = fileURLToPath(import.meta.url);
19
19
  const __dirname = dirname(__filename);
20
20
  const createClickableLink = (url, styledText) => {
@@ -25,31 +25,31 @@ export async function startStudio(options) {
25
25
  const app = express();
26
26
  const server = createServer(app);
27
27
  app.use(cors({
28
- origin: ['http://localhost:3000', 'http://localhost:3001', 'http://localhost:3002'],
28
+ origin: ["http://localhost:3000", "http://localhost:3001", "http://localhost:3002"],
29
29
  credentials: true,
30
30
  }));
31
- app.use(express.json({ limit: '50mb' }));
32
- app.use(express.urlencoded({ extended: true, limit: '50mb' }));
31
+ app.use(express.json({ limit: "50mb" }));
32
+ app.use(express.urlencoded({ extended: true, limit: "50mb" }));
33
33
  let wss = null;
34
34
  if (watchMode) {
35
35
  wss = new WebSocketServer({ server });
36
- wss.on('connection', (ws) => {
36
+ wss.on("connection", (ws) => {
37
37
  const heartbeat = setInterval(() => {
38
38
  if (ws.readyState === ws.OPEN) {
39
39
  ws.ping();
40
40
  }
41
41
  }, 30000);
42
- ws.on('close', () => {
42
+ ws.on("close", () => {
43
43
  clearInterval(heartbeat);
44
44
  });
45
- ws.on('error', (_error) => {
45
+ ws.on("error", (_error) => {
46
46
  clearInterval(heartbeat);
47
47
  });
48
48
  ws.send(JSON.stringify({
49
- type: 'connected',
50
- message: 'Connected to Better Auth Studio (watch mode)',
49
+ type: "connected",
50
+ message: "Connected to Better Auth Studio (watch mode)",
51
51
  }));
52
- if (typeof onWatchConnection === 'function') {
52
+ if (typeof onWatchConnection === "function") {
53
53
  try {
54
54
  onWatchConnection(ws);
55
55
  }
@@ -58,16 +58,16 @@ export async function startStudio(options) {
58
58
  });
59
59
  }
60
60
  app.use(createRoutes(authConfig, configPath, geoDbPath));
61
- const publicDir = existsSync(join(__dirname, '../public'))
62
- ? join(__dirname, '../public')
63
- : join(__dirname, '../../public');
61
+ const publicDir = existsSync(join(__dirname, "../public"))
62
+ ? join(__dirname, "../public")
63
+ : join(__dirname, "../../public");
64
64
  let studioEnabled = false;
65
65
  let studioConfigPath = null;
66
66
  const possibleFiles = [
67
- 'studio.config.ts',
68
- 'studio.config.js',
69
- 'studio.config.mjs',
70
- 'studio.config.cjs',
67
+ "studio.config.ts",
68
+ "studio.config.js",
69
+ "studio.config.mjs",
70
+ "studio.config.cjs",
71
71
  ];
72
72
  for (const file of possibleFiles) {
73
73
  const path = join(process.cwd(), file);
@@ -93,11 +93,11 @@ export async function startStudio(options) {
93
93
  allExtensions: true,
94
94
  },
95
95
  ],
96
- [babelPresetReact, { runtime: 'automatic' }],
96
+ [babelPresetReact, { runtime: "automatic" }],
97
97
  ],
98
98
  },
99
99
  },
100
- extensions: ['.ts', '.js', '.tsx', '.jsx'],
100
+ extensions: [".ts", ".js", ".tsx", ".jsx"],
101
101
  alias,
102
102
  interopDefault: true,
103
103
  };
@@ -129,76 +129,76 @@ export async function startStudio(options) {
129
129
  }
130
130
  catch (_error) { }
131
131
  }
132
- app.use('/assets', express.static(join(publicDir, 'assets'), {
132
+ app.use("/assets", express.static(join(publicDir, "assets"), {
133
133
  setHeaders: (res) => {
134
- res.setHeader('Cache-Control', 'public, max-age=31536000');
134
+ res.setHeader("Cache-Control", "public, max-age=31536000");
135
135
  },
136
136
  }));
137
- app.get('/vite.svg', (_req, res) => {
138
- res.sendFile(join(publicDir, 'vite.svg'));
137
+ app.get("/vite.svg", (_req, res) => {
138
+ res.sendFile(join(publicDir, "vite.svg"));
139
139
  });
140
- app.get('/favicon.svg', (_req, res) => {
141
- res.sendFile(join(publicDir, 'favicon.svg'));
140
+ app.get("/favicon.svg", (_req, res) => {
141
+ res.sendFile(join(publicDir, "favicon.svg"));
142
142
  });
143
- app.get('/logo.png', (_req, res) => {
144
- res.sendFile(join(publicDir, 'logo.png'));
143
+ app.get("/logo.png", (_req, res) => {
144
+ res.sendFile(join(publicDir, "logo.png"));
145
145
  });
146
- app.get('*', (_req, res) => {
146
+ app.get("*", (_req, res) => {
147
147
  const html = serveIndexHtml(publicDir, {
148
- basePath: '', // CLI studio uses root path
148
+ basePath: "", // CLI studio uses root path
149
149
  metadata: {
150
- title: 'Better Auth Studio',
151
- theme: 'dark',
150
+ title: "Better Auth Studio",
151
+ theme: "dark",
152
152
  },
153
153
  });
154
- res.setHeader('Content-Type', 'text/html');
154
+ res.setHeader("Content-Type", "text/html");
155
155
  res.send(html);
156
156
  });
157
157
  server.listen(port, host, () => {
158
158
  const url = `http://${host}:${port}`;
159
159
  if (logStartup) {
160
- process.stdout.write('\n');
161
- process.stdout.write(chalk.green('✔ Better Auth Studio is running!\n'));
162
- process.stdout.write('\n');
160
+ process.stdout.write("\n");
161
+ process.stdout.write(chalk.green("✔ Better Auth Studio is running!\n"));
162
+ process.stdout.write("\n");
163
163
  process.stdout.write(chalk.white(`🌐 Open your browser and navigate to: `));
164
164
  const styledUrl1 = chalk.green(chalk.underline(url));
165
165
  process.stdout.write(createClickableLink(url, styledUrl1));
166
- process.stdout.write('\n');
166
+ process.stdout.write("\n");
167
167
  process.stdout.write(chalk.white(`📊 Dashboard available at: `));
168
168
  const styledUrl2 = chalk.green(chalk.underline(url));
169
169
  process.stdout.write(createClickableLink(url, styledUrl2));
170
- process.stdout.write('\n');
170
+ process.stdout.write("\n");
171
171
  process.stdout.write(chalk.white(`🔧 API endpoints available at: `));
172
172
  const apiUrl = `${url}/api`;
173
173
  const styledApiUrl = chalk.green(chalk.underline(apiUrl));
174
174
  process.stdout.write(createClickableLink(apiUrl, styledApiUrl));
175
- process.stdout.write('\n');
175
+ process.stdout.write("\n");
176
176
  if (studioEnabled) {
177
- process.stdout.write(chalk.white('📋 Studio config found: studio.config.ts\n'));
178
- process.stdout.write('\n');
177
+ process.stdout.write(chalk.white("📋 Studio config found: studio.config.ts\n"));
178
+ process.stdout.write("\n");
179
179
  }
180
180
  if (eventsStatus) {
181
181
  if (eventsStatus.enabled) {
182
182
  if (eventsStatus.configured) {
183
- const clientTypeInfo = eventsStatus.clientType ? ` (${eventsStatus.clientType})` : '';
183
+ const clientTypeInfo = eventsStatus.clientType ? ` (${eventsStatus.clientType})` : "";
184
184
  process.stdout.write(chalk.green(`✅ Events enabled${clientTypeInfo} - configuration is valid\n`));
185
185
  }
186
186
  else {
187
- process.stdout.write(chalk.yellow('⚠️ Events enabled but not fully configured - ensure you have a client/provider set up\n'));
187
+ process.stdout.write(chalk.yellow("⚠️ Events enabled but not fully configured - ensure you have a client/provider set up\n"));
188
188
  }
189
189
  }
190
190
  else {
191
- process.stdout.write(chalk.gray('ℹ️ Events are disabled\n'));
191
+ process.stdout.write(chalk.gray("ℹ️ Events are disabled\n"));
192
192
  }
193
- process.stdout.write('\n');
193
+ process.stdout.write("\n");
194
194
  }
195
195
  if (watchMode) {
196
- process.stdout.write(chalk.white('👀 Watch mode enabled - config changes will reload automatically\n'));
197
- process.stdout.write('\n');
196
+ process.stdout.write(chalk.white("👀 Watch mode enabled - config changes will reload automatically\n"));
197
+ process.stdout.write("\n");
198
198
  }
199
- process.stdout.write('\n');
200
- process.stdout.write(chalk.gray('Press Ctrl+C to stop the studio\n'));
201
- process.stdout.write('\n');
199
+ process.stdout.write("\n");
200
+ process.stdout.write(chalk.gray("Press Ctrl+C to stop the studio\n"));
201
+ process.stdout.write("\n");
202
202
  }
203
203
  if (openBrowser) {
204
204
  setTimeout(() => {
@@ -206,7 +206,7 @@ export async function startStudio(options) {
206
206
  }, 1000);
207
207
  }
208
208
  });
209
- process.on('SIGINT', () => {
209
+ process.on("SIGINT", () => {
210
210
  server.close(() => {
211
211
  process.exit(0);
212
212
  });
@@ -1,25 +1,25 @@
1
- export type AuthEventType = 'user.joined' | 'user.logged_in' | 'user.updated' | 'user.logged_out' | 'user.password_changed' | 'user.email_verified' | 'user.banned' | 'user.unbanned' | 'user.deleted' | 'user.delete_verification_requested' | 'organization.created' | 'organization.deleted' | 'organization.updated' | 'member.added' | 'member.removed' | 'member.role_changed' | 'session.created' | 'login.failed' | 'password.reset_requested' | 'password.reset_completed' | 'password.reset_requested_otp' | 'password.reset_completed_otp' | 'oauth.linked' | 'oauth.unlinked' | 'oauth.sign_in' | 'team.created' | 'team.updated' | 'team.deleted' | 'team.member.added' | 'team.member.removed' | 'invitation.created' | 'invitation.accepted' | 'invitation.rejected' | 'invitation.cancelled';
1
+ export type AuthEventType = "user.joined" | "user.logged_in" | "user.updated" | "user.logged_out" | "user.password_changed" | "user.email_verified" | "user.banned" | "user.unbanned" | "user.deleted" | "user.delete_verification_requested" | "organization.created" | "organization.deleted" | "organization.updated" | "member.added" | "member.removed" | "member.role_changed" | "session.created" | "login.failed" | "password.reset_requested" | "password.reset_completed" | "password.reset_requested_otp" | "password.reset_completed_otp" | "oauth.linked" | "oauth.unlinked" | "oauth.sign_in" | "team.created" | "team.updated" | "team.deleted" | "team.member.added" | "team.member.removed" | "invitation.created" | "invitation.accepted" | "invitation.rejected" | "invitation.cancelled";
2
2
  export interface AuthEvent {
3
3
  id: string;
4
4
  type: AuthEventType;
5
5
  timestamp: Date;
6
- status: 'success' | 'failed';
6
+ status: "success" | "failed";
7
7
  userId?: string;
8
8
  sessionId?: string;
9
9
  organizationId?: string;
10
10
  metadata?: Record<string, any>;
11
11
  ipAddress?: string;
12
12
  userAgent?: string;
13
- source: 'app' | 'api';
13
+ source: "app" | "api";
14
14
  display?: {
15
15
  message: string;
16
- severity?: 'info' | 'success' | 'warning' | 'failed';
16
+ severity?: "info" | "success" | "warning" | "failed";
17
17
  };
18
18
  }
19
19
  export interface EventQueryOptions {
20
20
  limit?: number;
21
21
  after?: string;
22
- sort?: 'asc' | 'desc';
22
+ sort?: "asc" | "desc";
23
23
  type?: string;
24
24
  userId?: string;
25
25
  since?: Date;
@@ -39,6 +39,6 @@ export interface EventIngestionProvider {
39
39
  export declare const EVENT_TEMPLATES: Record<AuthEventType, (event: AuthEvent) => string>;
40
40
  export declare function getEventSeverity(event: AuthEvent | {
41
41
  type: AuthEventType;
42
- status?: 'success' | 'failed';
43
- }, status?: 'success' | 'failed'): 'info' | 'success' | 'warning' | 'failed';
42
+ status?: "success" | "failed";
43
+ }, status?: "success" | "failed"): "info" | "success" | "warning" | "failed";
44
44
  //# sourceMappingURL=events.d.ts.map