better-auth-studio 1.1.2-beta.15 → 1.1.2-beta.16
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.
- package/README.md +36 -23
- package/data/default-geo.json +1 -1
- package/dist/adapters/astro.d.ts +1 -1
- package/dist/adapters/astro.js +13 -13
- package/dist/adapters/elysia.d.ts +2 -2
- package/dist/adapters/elysia.js +13 -13
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +4 -4
- package/dist/adapters/hono.d.ts +2 -2
- package/dist/adapters/hono.js +12 -12
- package/dist/adapters/nextjs.d.ts +1 -1
- package/dist/adapters/nextjs.js +10 -10
- package/dist/adapters/nuxt.d.ts +1 -1
- package/dist/adapters/nuxt.js +22 -22
- package/dist/adapters/remix.d.ts +1 -1
- package/dist/adapters/remix.js +13 -13
- package/dist/adapters/solid-start.d.ts +1 -1
- package/dist/adapters/solid-start.js +13 -13
- package/dist/adapters/svelte-kit.d.ts +2 -2
- package/dist/adapters/svelte-kit.js +13 -13
- package/dist/adapters/tanstack-start.d.ts +1 -1
- package/dist/adapters/tanstack-start.js +13 -13
- package/dist/add-svelte-kit-env-modules.js +11 -11
- package/dist/auth-adapter.d.ts +1 -1
- package/dist/auth-adapter.js +96 -96
- package/dist/cli/commands/init.js +57 -57
- package/dist/cli.js +75 -75
- package/dist/config.d.ts +5 -5
- package/dist/config.js +37 -37
- package/dist/core/handler.d.ts +1 -1
- package/dist/core/handler.js +115 -115
- package/dist/data.d.ts +2 -2
- package/dist/data.js +60 -60
- package/dist/geo-service.js +78 -78
- package/dist/get-tsconfig-info.js +4 -4
- package/dist/index.d.ts +8 -8
- package/dist/index.js +6 -6
- package/dist/providers/events/helpers.d.ts +2 -2
- package/dist/providers/events/helpers.js +156 -156
- package/dist/routes/api-router.d.ts +2 -2
- package/dist/routes/api-router.js +3 -3
- package/dist/routes.d.ts +4 -4
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +1272 -1272
- package/dist/routes.js.map +1 -1
- package/dist/studio.d.ts +3 -3
- package/dist/studio.js +64 -64
- package/dist/types/events.d.ts +7 -7
- package/dist/types/events.js +165 -165
- package/dist/types/handler.d.ts +5 -5
- package/dist/utils/auth-callbacks-injector.d.ts +2 -2
- package/dist/utils/auth-callbacks-injector.js +27 -27
- package/dist/utils/auth-callbacks-wrapper.d.ts +3 -3
- package/dist/utils/auth-callbacks-wrapper.js +117 -107
- package/dist/utils/database-detection.d.ts +1 -1
- package/dist/utils/database-detection.js +44 -44
- package/dist/utils/database-hook-injector.d.ts +3 -3
- package/dist/utils/database-hook-injector.js +135 -131
- package/dist/utils/email-otp-hooks-injector.d.ts +28 -12
- package/dist/utils/email-otp-hooks-injector.js +104 -97
- package/dist/utils/event-ingestion.d.ts +5 -5
- package/dist/utils/event-ingestion.d.ts.map +1 -1
- package/dist/utils/event-ingestion.js +14 -16
- package/dist/utils/event-ingestion.js.map +1 -1
- package/dist/utils/hook-injector.d.ts +2 -2
- package/dist/utils/hook-injector.js +199 -199
- package/dist/utils/html-injector.d.ts +3 -3
- package/dist/utils/html-injector.js +37 -37
- package/dist/utils/org-hooks-injector.d.ts +3 -3
- package/dist/utils/org-hooks-injector.js +63 -63
- package/dist/utils/org-hooks-wrapper.d.ts +41 -35
- package/dist/utils/org-hooks-wrapper.js +778 -658
- package/dist/utils/organization-hooks-wrapper.d.ts +23 -17
- package/dist/utils/organization-hooks-wrapper.js +325 -277
- package/dist/utils/package-json.js +11 -11
- package/dist/utils/paths.js +1 -1
- package/dist/utils/server-init.d.ts +1 -1
- package/dist/utils/server-init.js +25 -25
- package/dist/utils/session.js +12 -12
- package/dist/utils.js +24 -24
- package/package.json +26 -26
- package/scripts/download-geolite2.js +8 -8
- package/scripts/generate-default-db.js +324 -324
- package/scripts/postinstall.js +25 -25
package/dist/studio.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { WebSocket } from
|
|
2
|
-
import { WebSocketServer } from
|
|
3
|
-
import type { AuthConfig } from
|
|
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
|
|
2
|
-
import { createServer } from
|
|
3
|
-
import { dirname, join } from
|
|
4
|
-
import { fileURLToPath } from
|
|
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
|
|
6
|
+
import babelPresetReact from "@babel/preset-react";
|
|
7
7
|
// @ts-expect-error - No types available
|
|
8
|
-
import babelPresetTypeScript from
|
|
9
|
-
import { loadConfig } from
|
|
10
|
-
import chalk from
|
|
11
|
-
import cors from
|
|
12
|
-
import express from
|
|
13
|
-
import open from
|
|
14
|
-
import { WebSocketServer } from
|
|
15
|
-
import { getPathAliases } from
|
|
16
|
-
import { createRoutes } from
|
|
17
|
-
import { serveIndexHtml } from
|
|
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: [
|
|
28
|
+
origin: ["http://localhost:3000", "http://localhost:3001", "http://localhost:3002"],
|
|
29
29
|
credentials: true,
|
|
30
30
|
}));
|
|
31
|
-
app.use(express.json({ limit:
|
|
32
|
-
app.use(express.urlencoded({ extended: true, limit:
|
|
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(
|
|
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(
|
|
42
|
+
ws.on("close", () => {
|
|
43
43
|
clearInterval(heartbeat);
|
|
44
44
|
});
|
|
45
|
-
ws.on(
|
|
45
|
+
ws.on("error", (_error) => {
|
|
46
46
|
clearInterval(heartbeat);
|
|
47
47
|
});
|
|
48
48
|
ws.send(JSON.stringify({
|
|
49
|
-
type:
|
|
50
|
-
message:
|
|
49
|
+
type: "connected",
|
|
50
|
+
message: "Connected to Better Auth Studio (watch mode)",
|
|
51
51
|
}));
|
|
52
|
-
if (typeof onWatchConnection ===
|
|
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,
|
|
62
|
-
? join(__dirname,
|
|
63
|
-
: join(__dirname,
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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:
|
|
96
|
+
[babelPresetReact, { runtime: "automatic" }],
|
|
97
97
|
],
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
|
-
extensions: [
|
|
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(
|
|
132
|
+
app.use("/assets", express.static(join(publicDir, "assets"), {
|
|
133
133
|
setHeaders: (res) => {
|
|
134
|
-
res.setHeader(
|
|
134
|
+
res.setHeader("Cache-Control", "public, max-age=31536000");
|
|
135
135
|
},
|
|
136
136
|
}));
|
|
137
|
-
app.get(
|
|
138
|
-
res.sendFile(join(publicDir,
|
|
137
|
+
app.get("/vite.svg", (_req, res) => {
|
|
138
|
+
res.sendFile(join(publicDir, "vite.svg"));
|
|
139
139
|
});
|
|
140
|
-
app.get(
|
|
141
|
-
res.sendFile(join(publicDir,
|
|
140
|
+
app.get("/favicon.svg", (_req, res) => {
|
|
141
|
+
res.sendFile(join(publicDir, "favicon.svg"));
|
|
142
142
|
});
|
|
143
|
-
app.get(
|
|
144
|
-
res.sendFile(join(publicDir,
|
|
143
|
+
app.get("/logo.png", (_req, res) => {
|
|
144
|
+
res.sendFile(join(publicDir, "logo.png"));
|
|
145
145
|
});
|
|
146
|
-
app.get(
|
|
146
|
+
app.get("*", (_req, res) => {
|
|
147
147
|
const html = serveIndexHtml(publicDir, {
|
|
148
|
-
basePath:
|
|
148
|
+
basePath: "", // CLI studio uses root path
|
|
149
149
|
metadata: {
|
|
150
|
-
title:
|
|
151
|
-
theme:
|
|
150
|
+
title: "Better Auth Studio",
|
|
151
|
+
theme: "dark",
|
|
152
152
|
},
|
|
153
153
|
});
|
|
154
|
-
res.setHeader(
|
|
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(
|
|
161
|
-
process.stdout.write(chalk.green(
|
|
162
|
-
process.stdout.write(
|
|
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(
|
|
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(
|
|
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(
|
|
175
|
+
process.stdout.write("\n");
|
|
176
176
|
if (studioEnabled) {
|
|
177
|
-
process.stdout.write(chalk.white(
|
|
178
|
-
process.stdout.write(
|
|
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(
|
|
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(
|
|
191
|
+
process.stdout.write(chalk.gray("ℹ️ Events are disabled\n"));
|
|
192
192
|
}
|
|
193
|
-
process.stdout.write(
|
|
193
|
+
process.stdout.write("\n");
|
|
194
194
|
}
|
|
195
195
|
if (watchMode) {
|
|
196
|
-
process.stdout.write(chalk.white(
|
|
197
|
-
process.stdout.write(
|
|
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(
|
|
200
|
-
process.stdout.write(chalk.gray(
|
|
201
|
-
process.stdout.write(
|
|
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(
|
|
209
|
+
process.on("SIGINT", () => {
|
|
210
210
|
server.close(() => {
|
|
211
211
|
process.exit(0);
|
|
212
212
|
});
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export type AuthEventType =
|
|
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:
|
|
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:
|
|
13
|
+
source: "app" | "api";
|
|
14
14
|
display?: {
|
|
15
15
|
message: string;
|
|
16
|
-
severity?:
|
|
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?:
|
|
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?:
|
|
43
|
-
}, status?:
|
|
42
|
+
status?: "success" | "failed";
|
|
43
|
+
}, status?: "success" | "failed"): "info" | "success" | "warning" | "failed";
|
|
44
44
|
//# sourceMappingURL=events.d.ts.map
|