better-auth-studio 1.1.2-beta.4 → 1.1.2-beta.41
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 +51 -78
- package/data/default-geo.json +12 -1
- package/dist/adapters/astro.d.ts +1 -1
- package/dist/adapters/astro.d.ts.map +1 -1
- package/dist/adapters/astro.js +17 -15
- package/dist/adapters/astro.js.map +1 -1
- package/dist/adapters/elysia.d.ts +2 -2
- package/dist/adapters/elysia.d.ts.map +1 -1
- package/dist/adapters/elysia.js +17 -15
- package/dist/adapters/elysia.js.map +1 -1
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +8 -6
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/hono.d.ts +2 -2
- package/dist/adapters/hono.d.ts.map +1 -1
- package/dist/adapters/hono.js +16 -14
- package/dist/adapters/hono.js.map +1 -1
- package/dist/adapters/nextjs.d.ts +1 -1
- package/dist/adapters/nextjs.d.ts.map +1 -1
- package/dist/adapters/nextjs.js +14 -12
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nuxt.d.ts +1 -1
- package/dist/adapters/nuxt.d.ts.map +1 -1
- package/dist/adapters/nuxt.js +26 -24
- package/dist/adapters/nuxt.js.map +1 -1
- package/dist/adapters/remix.d.ts +1 -1
- package/dist/adapters/remix.d.ts.map +1 -1
- package/dist/adapters/remix.js +17 -15
- package/dist/adapters/remix.js.map +1 -1
- package/dist/adapters/solid-start.d.ts +1 -1
- package/dist/adapters/solid-start.d.ts.map +1 -1
- package/dist/adapters/solid-start.js +17 -15
- package/dist/adapters/solid-start.js.map +1 -1
- package/dist/adapters/svelte-kit.d.ts +2 -2
- package/dist/adapters/svelte-kit.d.ts.map +1 -1
- package/dist/adapters/svelte-kit.js +17 -15
- package/dist/adapters/svelte-kit.js.map +1 -1
- package/dist/adapters/tanstack-start.d.ts +1 -1
- package/dist/adapters/tanstack-start.d.ts.map +1 -1
- package/dist/adapters/tanstack-start.js +17 -15
- package/dist/adapters/tanstack-start.js.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/core/handler.js +130 -115
- package/dist/core/handler.js.map +1 -1
- package/dist/data.d.ts +2 -2
- package/dist/data.js +60 -60
- package/dist/geo-service.d.ts +20 -2
- package/dist/geo-service.d.ts.map +1 -1
- package/dist/geo-service.js +185 -82
- package/dist/geo-service.js.map +1 -1
- package/dist/get-tsconfig-info.js +4 -4
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/providers/events/helpers.d.ts +11 -2
- package/dist/providers/events/helpers.d.ts.map +1 -1
- package/dist/providers/events/helpers.js +443 -155
- package/dist/providers/events/helpers.js.map +1 -1
- package/dist/public/assets/main-Cx3iOHjX.js +1216 -0
- package/dist/public/assets/main-Djae8maC.css +1 -0
- package/dist/public/index.html +2 -2
- package/dist/routes/api-router.d.ts +3 -1
- package/dist/routes/api-router.d.ts.map +1 -1
- package/dist/routes/api-router.js +3 -3
- package/dist/routes/api-router.js.map +1 -1
- package/dist/routes.d.ts +6 -4
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +1529 -1309
- package/dist/routes.js.map +1 -1
- package/dist/studio.d.ts +3 -3
- package/dist/studio.d.ts.map +1 -1
- package/dist/studio.js +64 -65
- package/dist/studio.js.map +1 -1
- package/dist/types/events.d.ts +18 -7
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/events.js +185 -165
- package/dist/types/events.js.map +1 -1
- package/dist/types/handler.d.ts +43 -4
- package/dist/types/handler.d.ts.map +1 -1
- package/dist/types/handler.js.map +1 -1
- 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 +43 -12
- package/dist/utils/event-ingestion.js.map +1 -1
- package/dist/utils/hook-injector.d.ts +8 -2
- package/dist/utils/hook-injector.d.ts.map +1 -1
- package/dist/utils/hook-injector.js +447 -199
- package/dist/utils/hook-injector.js.map +1 -1
- package/dist/utils/html-injector.d.ts +17 -2
- package/dist/utils/html-injector.d.ts.map +1 -1
- package/dist/utils/html-injector.js +44 -39
- package/dist/utils/html-injector.js.map +1 -1
- 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.d.ts +0 -1
- package/dist/utils/session.d.ts.map +1 -1
- package/dist/utils/session.js +19 -12
- package/dist/utils/session.js.map +1 -1
- package/dist/utils.js +24 -24
- package/package.json +26 -24
- package/public/assets/main-Cx3iOHjX.js +1216 -0
- package/public/assets/main-Djae8maC.css +1 -0
- package/public/index.html +2 -2
- package/scripts/download-geolite2.js +22 -15
- package/scripts/generate-default-db.js +324 -324
- package/scripts/postinstall.js +25 -25
- package/dist/public/assets/main-CEuuUcyk.css +0 -1
- package/dist/public/assets/main-vSWh5Mvp.js +0 -1194
- package/public/assets/main-CEuuUcyk.css +0 -1
- package/public/assets/main-vSWh5Mvp.js +0 -1194
package/README.md
CHANGED
|
@@ -1,67 +1,21 @@
|
|
|
1
|
-
# Better Auth Studio
|
|
1
|
+
# Better Auth Studio
|
|
2
2
|
|
|
3
3
|
> ⚠️ **Beta Version Notice**
|
|
4
|
-
>
|
|
4
|
+
>
|
|
5
5
|
> Better Auth Studio is currently in **beta** and in early development. You may encounter bugs or incomplete features. Please report any issues you find on our GitHub repository to help us improve the project. Your feedback is greatly appreciated!
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
A web-based studio interface for managing Better Auth applications. Better Auth Studio provides a comprehensive dashboard for managing users, organizations, teams, and more.
|
|
9
8
|
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJ4L7IilBo7ItO3420CBLpvnPJlA6j5zaFYZbG" alt="Better Auth Studio Preview 4" width="100%" />
|
|
21
|
-
</td>
|
|
22
|
-
</tr>
|
|
23
|
-
<tr>
|
|
24
|
-
<td width="50%">
|
|
25
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJdiXpY6GJ15hUVAwrQyozdc6PpIXfSi7GWkeR" alt="Better Auth Studio Preview 2" width="100%" />
|
|
26
|
-
</td>
|
|
27
|
-
<td width="50%">
|
|
28
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJNAk2JU1Cviwfb1ltHVgPJF9BWxzE2m60rQaK" alt="Better Auth Studio Preview 6" width="100%" />
|
|
29
|
-
</td>
|
|
30
|
-
</tr>
|
|
31
|
-
<tr>
|
|
32
|
-
<td width="50%">
|
|
33
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJgSyVwl0dZe8UGVJLkR74CQXb9m1wzKIqhTME" alt="Better Auth Studio Preview 11" width="100%" />
|
|
34
|
-
</td>
|
|
35
|
-
<td width="50%">
|
|
36
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJODyqbs8p2EKCNef8H9XqPm4cIwjaQVRUAFg7" alt="Better Auth Studio Preview 8" width="100%" />
|
|
37
|
-
</td>
|
|
38
|
-
</tr>
|
|
39
|
-
<tr>
|
|
40
|
-
<td width="50%">
|
|
41
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJ2syhnQSdgJ9w13MfvHiGYPs07AkpWQSXm6Nj" alt="Better Auth Studio Preview 12" width="100%" />
|
|
42
|
-
</td>
|
|
43
|
-
<td width="50%">
|
|
44
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJcW7cwWXSlBtbRHTF15ujAQLPx3VpcKgMOz08" alt="Better Auth Studio Preview 3" width="100%" />
|
|
45
|
-
</td>
|
|
46
|
-
</tr>
|
|
47
|
-
<tr>
|
|
48
|
-
<td width="50%">
|
|
49
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJnAGpd3rzcKd2Hu4wkD0jJbApf78rC1VgZORT" alt="Better Auth Studio Preview 10" width="100%" />
|
|
50
|
-
</td>
|
|
51
|
-
<td width="50%">
|
|
52
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJK6lXYfaxUOknshdjxpSgwV6mq7DtH3aMZXWK" alt="Better Auth Studio Preview 13" width="100%" />
|
|
53
|
-
</td>
|
|
54
|
-
</tr>
|
|
55
|
-
<tr>
|
|
56
|
-
<td width="50%">
|
|
57
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJhZFdrWmjbSvOe01IQl7r68LUfVKuFcNqAydt" alt="Better Auth Studio Preview 14" width="100%" />
|
|
58
|
-
</td>
|
|
59
|
-
<td width="50%">
|
|
60
|
-
<img src="https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJwnJFq9htT259fPAQY0eIdDmn7O4xVlGaCjZR" alt="Better Auth Studio Preview 5" width="100%" />
|
|
61
|
-
</td>
|
|
62
|
-
</tr>
|
|
63
|
-
</table>
|
|
64
|
-
</div>
|
|
9
|
+
## ✨ Try Better Auth Studio Demo
|
|
10
|
+
|
|
11
|
+
You can try a live, demo version of Better Auth Studio here:
|
|
12
|
+
|
|
13
|
+
👉 **[https://bt-nextjs.vercel.app/admin](https://bt-nextjs.vercel.app/admin)**
|
|
14
|
+
|
|
15
|
+
- **Login email:** `admin@user.com`
|
|
16
|
+
- **Password:** `admin@user.com`
|
|
17
|
+
|
|
18
|
+
This online demo lets you explore the admin studio UI. Please note this is a test environment.
|
|
65
19
|
|
|
66
20
|
## 🚀 Quick Start
|
|
67
21
|
|
|
@@ -88,24 +42,27 @@ pnpm add -g better-auth-studio
|
|
|
88
42
|
Or use pnpx to run it without installation:
|
|
89
43
|
|
|
90
44
|
```bash
|
|
91
|
-
pnpx better-auth-studio [cmd]
|
|
45
|
+
pnpx better-auth-studio [cmd]
|
|
92
46
|
```
|
|
93
47
|
|
|
94
48
|
### Basic Usage
|
|
95
49
|
|
|
96
50
|
1. **Navigate to your Better Auth project directory**
|
|
51
|
+
|
|
97
52
|
```bash
|
|
98
53
|
cd your-better-auth-project
|
|
99
54
|
```
|
|
100
55
|
|
|
101
56
|
2. **Start the studio**
|
|
102
|
-
|
|
57
|
+
|
|
103
58
|
If installed as dev dependency:
|
|
59
|
+
|
|
104
60
|
```bash
|
|
105
61
|
pnpm better-auth-studio start
|
|
106
62
|
```
|
|
107
|
-
|
|
63
|
+
|
|
108
64
|
Or with pnpx:
|
|
65
|
+
|
|
109
66
|
```bash
|
|
110
67
|
pnpx better-auth-studio start
|
|
111
68
|
```
|
|
@@ -129,7 +86,7 @@ Before using Better Auth Studio, ensure you have:
|
|
|
129
86
|
Better Auth Studio automatically detects and works with:
|
|
130
87
|
|
|
131
88
|
- **Prisma** (`prismaAdapter`)
|
|
132
|
-
- **Drizzle** (`drizzleAdapter`)
|
|
89
|
+
- **Drizzle** (`drizzleAdapter`)
|
|
133
90
|
- **SQLite** (`new Database()` from better-sqlite3)
|
|
134
91
|
- **PostgreSQL** (via Prisma or Drizzle)
|
|
135
92
|
- **MySQL** (via Prisma or Drizzle)
|
|
@@ -137,6 +94,7 @@ Better Auth Studio automatically detects and works with:
|
|
|
137
94
|
### Example Configuration Files
|
|
138
95
|
|
|
139
96
|
#### Prisma Setup
|
|
97
|
+
|
|
140
98
|
```typescript
|
|
141
99
|
// auth.ts
|
|
142
100
|
import { betterAuth } from "better-auth";
|
|
@@ -154,6 +112,7 @@ export const auth = betterAuth({
|
|
|
154
112
|
```
|
|
155
113
|
|
|
156
114
|
#### Drizzle Setup
|
|
115
|
+
|
|
157
116
|
```typescript
|
|
158
117
|
// auth.ts
|
|
159
118
|
import { betterAuth } from "better-auth";
|
|
@@ -169,6 +128,7 @@ export const auth = betterAuth({
|
|
|
169
128
|
```
|
|
170
129
|
|
|
171
130
|
#### SQLite Setup
|
|
131
|
+
|
|
172
132
|
```typescript
|
|
173
133
|
// auth.ts
|
|
174
134
|
import { betterAuth } from "better-auth";
|
|
@@ -183,17 +143,21 @@ export const auth = betterAuth({
|
|
|
183
143
|
## 🎯 Features
|
|
184
144
|
|
|
185
145
|
### 📊 Dashboard
|
|
146
|
+
|
|
186
147
|
- **Overview statistics** - User, teams and organization counts data
|
|
187
148
|
|
|
188
149
|
### 👥 User Management
|
|
150
|
+
|
|
189
151
|
- **View all users** - Paginated list with search and filtering
|
|
190
152
|
- **Create users** - Add new users with email/password
|
|
191
153
|
- **Edit users** - Update user information, email verification status
|
|
192
154
|
- **Delete users** - Remove users from the system
|
|
193
155
|
- **Bulk operations** - Seed multiple test users
|
|
194
156
|
- **User details** - View user profiles, and accounts
|
|
157
|
+
- **Last seen** - When events are enabled, the studio injects an optional `lastSeenAt` field on the user model and updates it on each sign-in or session creation. Run your database migration (e.g. `prisma migrate dev` or Drizzle push) to add the `lastSeenAt` column to the user table.
|
|
195
158
|
|
|
196
159
|
### 🏢 Organization Management
|
|
160
|
+
|
|
197
161
|
- **View organizations** - List all organizations with pagination
|
|
198
162
|
- **Create organizations** - Add new organizations with custom slugs
|
|
199
163
|
- **Edit organizations** - Update organization details
|
|
@@ -203,6 +167,7 @@ export const auth = betterAuth({
|
|
|
203
167
|
- **Bulk seeding** - Generate test organizations and teams
|
|
204
168
|
|
|
205
169
|
### ⚙️ Settings & Configuration
|
|
170
|
+
|
|
206
171
|
- **Plugin status** - Check which Better Auth plugins are enabled
|
|
207
172
|
- **Database configuration** - View current database adapter and settings
|
|
208
173
|
- **Social providers** - Configure OAuth providers (GitHub, Google, etc.)
|
|
@@ -211,11 +176,13 @@ export const auth = betterAuth({
|
|
|
211
176
|
## 🛠️ Command Line Options
|
|
212
177
|
|
|
213
178
|
### Start Studio
|
|
179
|
+
|
|
214
180
|
```bash
|
|
215
181
|
pnpx better-auth-studio start [options]
|
|
216
182
|
```
|
|
217
183
|
|
|
218
184
|
**Options:**
|
|
185
|
+
|
|
219
186
|
- `--port <number>` - Specify port (default: 3000)
|
|
220
187
|
- `--host <string>` - Specify host (default: localhost)
|
|
221
188
|
- `--no-open` - Don't automatically open browser
|
|
@@ -223,6 +190,7 @@ pnpx better-auth-studio start [options]
|
|
|
223
190
|
- `--watch` - Watch for changes in auth config file and reload server automatically
|
|
224
191
|
|
|
225
192
|
**Examples:**
|
|
193
|
+
|
|
226
194
|
```bash
|
|
227
195
|
# Start on custom port (if installed as dev dependency)
|
|
228
196
|
pnpm better-auth-studio start --port 3001
|
|
@@ -248,6 +216,7 @@ pnpx better-auth-studio start --port 3001 --watch --config ./src/auth.ts
|
|
|
248
216
|
Specify a custom path to your auth config file when it's in a non-standard location or auto-detection fails.
|
|
249
217
|
|
|
250
218
|
**Example:**
|
|
219
|
+
|
|
251
220
|
```bash
|
|
252
221
|
# With relative path
|
|
253
222
|
pnpm better-auth-studio start --config ./src/lib/auth.ts
|
|
@@ -263,6 +232,7 @@ pnpm better-auth-studio start --config /path/to/project/auth.ts
|
|
|
263
232
|
Automatically reload the server when your `auth.ts` file changes. Perfect for development when iterating on your auth configuration.
|
|
264
233
|
|
|
265
234
|
**Example:**
|
|
235
|
+
|
|
266
236
|
```bash
|
|
267
237
|
# Start with watch mode enabled
|
|
268
238
|
pnpx better-auth-studio start --watch
|
|
@@ -271,6 +241,7 @@ pnpx better-auth-studio start --watch
|
|
|
271
241
|
**How it works:** Monitors your auth config file for changes, automatically restarts the server, and updates the browser UI via WebSocket - no manual refresh needed.
|
|
272
242
|
|
|
273
243
|
### Other Commands
|
|
244
|
+
|
|
274
245
|
```bash
|
|
275
246
|
# Check version
|
|
276
247
|
pnpx better-auth-studio --version
|
|
@@ -298,11 +269,13 @@ pnpm add better-auth-studio
|
|
|
298
269
|
### Setup
|
|
299
270
|
|
|
300
271
|
**Step 1: Initialize configuration**
|
|
272
|
+
|
|
301
273
|
```bash
|
|
302
274
|
pnpx better-auth-studio init
|
|
303
275
|
```
|
|
304
276
|
|
|
305
277
|
This creates a `studio.config.ts` file:
|
|
278
|
+
|
|
306
279
|
```typescript
|
|
307
280
|
import type { StudioConfig } from "better-auth-studio";
|
|
308
281
|
import { auth } from "./lib/auth";
|
|
@@ -326,19 +299,14 @@ export default config;
|
|
|
326
299
|
### Next.js (App Router)
|
|
327
300
|
|
|
328
301
|
The init command automatically creates `app/api/studio/[[...path]]/route.ts`:
|
|
302
|
+
|
|
329
303
|
```typescript
|
|
330
|
-
import {
|
|
304
|
+
import { betterAuthStudio } from "better-auth-studio/nextjs";
|
|
331
305
|
import studioConfig from "@/studio.config";
|
|
332
306
|
|
|
333
|
-
const handler =
|
|
307
|
+
const handler = betterAuthStudio(studioConfig);
|
|
334
308
|
|
|
335
|
-
export {
|
|
336
|
-
handler as GET,
|
|
337
|
-
handler as POST,
|
|
338
|
-
handler as PUT,
|
|
339
|
-
handler as DELETE,
|
|
340
|
-
handler as PATCH,
|
|
341
|
-
};
|
|
309
|
+
export { handler as GET, handler as POST, handler as PUT, handler as DELETE, handler as PATCH };
|
|
342
310
|
```
|
|
343
311
|
|
|
344
312
|
Access at `http://localhost:3000/api/studio`
|
|
@@ -346,6 +314,7 @@ Access at `http://localhost:3000/api/studio`
|
|
|
346
314
|
### Express
|
|
347
315
|
|
|
348
316
|
Add the studio handler to your server:
|
|
317
|
+
|
|
349
318
|
```typescript
|
|
350
319
|
import express from "express";
|
|
351
320
|
import { toNodeHandler } from "better-auth/node";
|
|
@@ -366,17 +335,20 @@ Access at `http://localhost:3000/api/studio`
|
|
|
366
335
|
|
|
367
336
|
### Configuration Options
|
|
368
337
|
|
|
369
|
-
| Option
|
|
370
|
-
|
|
371
|
-
| `auth`
|
|
372
|
-
| `basePath`
|
|
373
|
-
| `access.allowEmails` | No
|
|
374
|
-
| `access.roles`
|
|
375
|
-
| `
|
|
338
|
+
| Option | Required | Description |
|
|
339
|
+
| -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
340
|
+
| `auth` | Yes | Your Better Auth instance |
|
|
341
|
+
| `basePath` | Yes | URL path where studio is mounted |
|
|
342
|
+
| `access.allowEmails` | No | Array of admin email addresses |
|
|
343
|
+
| `access.roles` | No | Array of allowed user roles |
|
|
344
|
+
| `ipAddress` | No | IP geolocation for Events/Sessions: `provider` ("ipinfo" \| "ipapi"), `apiToken`, `baseUrl`, optional `endpoint` (ipinfo: "lite" \| "lookup") |
|
|
345
|
+
| `lastSeenAt` | No | Enable last-seen tracking: `{ enabled: true, columnName?: string }` |
|
|
346
|
+
| `metadata` | No | Custom branding (title, theme) |
|
|
376
347
|
|
|
377
348
|
## 📝 Development
|
|
378
349
|
|
|
379
350
|
### Running from Source
|
|
351
|
+
|
|
380
352
|
```bash
|
|
381
353
|
# Clone the repository
|
|
382
354
|
git clone https://github.com/Kinfe123/better-auth-studio.git
|
|
@@ -393,6 +365,7 @@ pnpm dev
|
|
|
393
365
|
```
|
|
394
366
|
|
|
395
367
|
### Contributing
|
|
368
|
+
|
|
396
369
|
1. Fork the repository
|
|
397
370
|
2. Create a feature branch
|
|
398
371
|
3. Make your changes
|
package/data/default-geo.json
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
"description": "Default IP geolocation database for Better Auth Studio",
|
|
5
5
|
"coverage": "Major IP ranges worldwide",
|
|
6
6
|
"ranges": [
|
|
7
|
+
{
|
|
8
|
+
"country": "Ethiopia",
|
|
9
|
+
"countryCode": "ET",
|
|
10
|
+
"city": "Addis Ababa",
|
|
11
|
+
"region": "Addis Ababa",
|
|
12
|
+
"ranges": [
|
|
13
|
+
{ "min": "102.208.97.0", "max": "102.208.97.255" },
|
|
14
|
+
{ "min": "102.208.99.0", "max": "102.208.99.255" },
|
|
15
|
+
{ "min": "102.213.68.0", "max": "102.213.68.255" }
|
|
16
|
+
]
|
|
17
|
+
},
|
|
7
18
|
{
|
|
8
19
|
"country": "United States",
|
|
9
20
|
"countryCode": "US",
|
|
@@ -1123,4 +1134,4 @@
|
|
|
1123
1134
|
],
|
|
1124
1135
|
"totalRanges": 255,
|
|
1125
1136
|
"countries": 12
|
|
1126
|
-
}
|
|
1137
|
+
}
|
package/dist/adapters/astro.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../src/adapters/astro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../src/adapters/astro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,IAMrC,KAAK;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAG,OAAO,CAAC,QAAQ,CAAC,CAa5D"}
|
package/dist/adapters/astro.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { handleStudioRequest } from
|
|
2
|
-
import { injectEventHooks } from
|
|
1
|
+
import { handleStudioRequest } from "../core/handler.js";
|
|
2
|
+
import { injectEventHooks, injectLastSeenAtHooks } from "../utils/hook-injector.js";
|
|
3
3
|
/**
|
|
4
4
|
* Astro adapter for Better Auth Studio
|
|
5
5
|
*
|
|
@@ -18,8 +18,10 @@ import { injectEventHooks } from '../utils/hook-injector.js';
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export function betterAuthStudio(config) {
|
|
21
|
-
if (config.
|
|
22
|
-
|
|
21
|
+
if (config.auth) {
|
|
22
|
+
injectLastSeenAtHooks(config.auth, config);
|
|
23
|
+
if (config.events?.enabled)
|
|
24
|
+
injectEventHooks(config.auth, config.events);
|
|
23
25
|
}
|
|
24
26
|
return async (ctx) => {
|
|
25
27
|
try {
|
|
@@ -28,10 +30,10 @@ export function betterAuthStudio(config) {
|
|
|
28
30
|
return universalToResponse(universalRes);
|
|
29
31
|
}
|
|
30
32
|
catch (error) {
|
|
31
|
-
console.error(
|
|
32
|
-
return new Response(JSON.stringify({ error:
|
|
33
|
+
console.error("Studio handler error:", error);
|
|
34
|
+
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
|
33
35
|
status: 500,
|
|
34
|
-
headers: {
|
|
36
|
+
headers: { "Content-Type": "application/json" },
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
};
|
|
@@ -40,16 +42,16 @@ async function convertAstroToUniversal(ctx, config) {
|
|
|
40
42
|
const request = ctx.request;
|
|
41
43
|
let body;
|
|
42
44
|
const method = request.method;
|
|
43
|
-
if (method !==
|
|
44
|
-
const contentType = request.headers.get(
|
|
45
|
-
if (contentType.includes(
|
|
45
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
46
|
+
const contentType = request.headers.get("content-type") || "";
|
|
47
|
+
if (contentType.includes("application/json")) {
|
|
46
48
|
try {
|
|
47
49
|
body = await request.json();
|
|
48
50
|
}
|
|
49
51
|
catch { }
|
|
50
52
|
}
|
|
51
|
-
else if (contentType.includes(
|
|
52
|
-
contentType.includes(
|
|
53
|
+
else if (contentType.includes("application/x-www-form-urlencoded") ||
|
|
54
|
+
contentType.includes("multipart/form-data")) {
|
|
53
55
|
try {
|
|
54
56
|
const formData = await request.formData();
|
|
55
57
|
body = Object.fromEntries(formData.entries());
|
|
@@ -75,12 +77,12 @@ async function convertAstroToUniversal(ctx, config) {
|
|
|
75
77
|
request.headers.forEach((value, key) => {
|
|
76
78
|
headers[key] = value;
|
|
77
79
|
});
|
|
78
|
-
const basePath = config.basePath ||
|
|
79
|
-
const normalizedBasePath = basePath.endsWith(
|
|
80
|
+
const basePath = config.basePath || "/api/studio";
|
|
81
|
+
const normalizedBasePath = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
|
|
80
82
|
const url = new URL(request.url);
|
|
81
83
|
let path = url.pathname;
|
|
82
84
|
if (path.startsWith(normalizedBasePath)) {
|
|
83
|
-
path = path.slice(normalizedBasePath.length) ||
|
|
85
|
+
path = path.slice(normalizedBasePath.length) || "/";
|
|
84
86
|
}
|
|
85
87
|
const pathWithQuery = path + url.search;
|
|
86
88
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro.js","sourceRoot":"","sources":["../../src/adapters/astro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"astro.js","sourceRoot":"","s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,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,aAAa,CAAC;IAClD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAErF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;IAExB,IAAI,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACxC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;IACtD,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC;IAExC,OAAO;QACL,GAAG,EAAE,aAAa;QAClB,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI;KACL,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAsB;IACjD,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE;QAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elysia.d.ts","sourceRoot":"","sources":["../../src/adapters/elysia.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"elysia.d.ts","sourceRoot":"","sources":["../../src/adapters/elysia.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,IAMrC,SAAS,OAAO,kBAY/B"}
|
package/dist/adapters/elysia.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { handleStudioRequest } from
|
|
2
|
-
import { injectEventHooks } from
|
|
1
|
+
import { handleStudioRequest } from "../core/handler.js";
|
|
2
|
+
import { injectEventHooks, injectLastSeenAtHooks } from "../utils/hook-injector.js";
|
|
3
3
|
/**
|
|
4
4
|
* Elysia adapter for Better Auth Studio
|
|
5
5
|
*/
|
|
6
6
|
export function betterAuthStudio(config) {
|
|
7
|
-
if (config.
|
|
8
|
-
|
|
7
|
+
if (config.auth) {
|
|
8
|
+
injectLastSeenAtHooks(config.auth, config);
|
|
9
|
+
if (config.events?.enabled)
|
|
10
|
+
injectEventHooks(config.auth, config.events);
|
|
9
11
|
}
|
|
10
12
|
return async (context) => {
|
|
11
13
|
try {
|
|
@@ -14,28 +16,28 @@ export function betterAuthStudio(config) {
|
|
|
14
16
|
return sendElysiaResponse(context, universalRes);
|
|
15
17
|
}
|
|
16
18
|
catch (error) {
|
|
17
|
-
console.error(
|
|
19
|
+
console.error("Studio handler error:", error);
|
|
18
20
|
context.set.status = 500;
|
|
19
|
-
return { error:
|
|
21
|
+
return { error: "Internal server error" };
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
async function convertElysiaToUniversal(context) {
|
|
24
26
|
let body;
|
|
25
27
|
const method = context.request.method;
|
|
26
|
-
if (method !==
|
|
28
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
27
29
|
const elysiaBody = context.body ?? context.query ?? undefined;
|
|
28
30
|
if (elysiaBody !== undefined) {
|
|
29
31
|
body = elysiaBody;
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
|
-
const contentType = context.request.headers.get(
|
|
34
|
+
const contentType = context.request.headers.get("content-type") || "";
|
|
33
35
|
try {
|
|
34
|
-
if (contentType.includes(
|
|
36
|
+
if (contentType.includes("application/json")) {
|
|
35
37
|
body = await context.request.json();
|
|
36
38
|
}
|
|
37
|
-
else if (contentType.includes(
|
|
38
|
-
contentType.includes(
|
|
39
|
+
else if (contentType.includes("application/x-www-form-urlencoded") ||
|
|
40
|
+
contentType.includes("multipart/form-data")) {
|
|
39
41
|
const formData = await context.request.formData();
|
|
40
42
|
body = Object.fromEntries(formData.entries());
|
|
41
43
|
}
|
|
@@ -78,9 +80,9 @@ function sendElysiaResponse(context, universal) {
|
|
|
78
80
|
headers: universal.headers,
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
|
-
else if (typeof universal.body ===
|
|
82
|
-
const contentType = universal.headers[
|
|
83
|
-
if (contentType.includes(
|
|
83
|
+
else if (typeof universal.body === "string") {
|
|
84
|
+
const contentType = universal.headers["content-type"] || universal.headers["Content-Type"] || "";
|
|
85
|
+
if (contentType.includes("application/json")) {
|
|
84
86
|
try {
|
|
85
87
|
return JSON.parse(universal.body);
|
|
86
88
|
}
|
|
@@ -88,7 +90,7 @@ function sendElysiaResponse(context, universal) {
|
|
|
88
90
|
return universal.body;
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
else if (contentType.includes(
|
|
93
|
+
else if (contentType.includes("text/html")) {
|
|
92
94
|
return new Response(universal.body, {
|
|
93
95
|
status: universal.status,
|
|
94
96
|
headers: universal.headers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elysia.js","sourceRoot":"","sources":["../../src/adapters/elysia.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"elysia.js","sourceRoot":"","s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ACxB,CAAC;QACH,CAAC;aAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7C,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE;gBAClC,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,OAAO,EAAE,SAAS,CAAC,OAAO;aAC3B,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,SAAS,CAAC,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Router as ExpressRouter } from
|
|
2
|
-
import type { StudioConfig } from
|
|
1
|
+
import type { Router as ExpressRouter } from "express";
|
|
2
|
+
import type { StudioConfig } from "../types/handler.js";
|
|
3
3
|
/**
|
|
4
4
|
* Express adapter for Better Auth Studio
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAmC,MAAM,SAAS,CAAC;AAGxF,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAmC,MAAM,SAAS,CAAC;AAGxF,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAqBpE"}
|
package/dist/adapters/express.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { Router } from
|
|
2
|
-
import { handleStudioRequest } from
|
|
3
|
-
import { injectEventHooks } from
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { handleStudioRequest } from "../core/handler.js";
|
|
3
|
+
import { injectEventHooks, injectLastSeenAtHooks } from "../utils/hook-injector.js";
|
|
4
4
|
/**
|
|
5
5
|
* Express adapter for Better Auth Studio
|
|
6
6
|
*/
|
|
7
7
|
export function betterAuthStudio(config) {
|
|
8
|
-
if (config.
|
|
9
|
-
|
|
8
|
+
if (config.auth) {
|
|
9
|
+
injectLastSeenAtHooks(config.auth, config);
|
|
10
|
+
if (config.events?.enabled)
|
|
11
|
+
injectEventHooks(config.auth, config.events);
|
|
10
12
|
}
|
|
11
13
|
const router = Router();
|
|
12
|
-
router.all(
|
|
14
|
+
router.all("*", async (req, res, next) => {
|
|
13
15
|
try {
|
|
14
16
|
const universalReq = convertExpressToUniversal(req);
|
|
15
17
|
const universalRes = await handleStudioRequest(universalReq, config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEpF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAoB;IACnD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC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Q,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
package/dist/adapters/hono.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../src/adapters/hono.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../src/adapters/hono.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAAE,YAAY,EAAuC,MAAM,qBAAqB,CAAC;AAG7F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,IAMrC,GAAG,OAAO,uBAYzB"}
|