better-auth-studio 1.1.3-beta.5 → 1.1.3-beta.51

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 (192) hide show
  1. package/README.md +108 -16
  2. package/dist/adapters/astro.d.ts +0 -1
  3. package/dist/adapters/astro.js +5 -2
  4. package/dist/adapters/elysia.d.ts +0 -1
  5. package/dist/adapters/elysia.js +7 -33
  6. package/dist/adapters/express.d.ts +0 -1
  7. package/dist/adapters/express.js +4 -1
  8. package/dist/adapters/hono.d.ts +0 -1
  9. package/dist/adapters/hono.js +7 -27
  10. package/dist/adapters/nextjs.d.ts +0 -1
  11. package/dist/adapters/nextjs.js +5 -2
  12. package/dist/adapters/nuxt.d.ts +0 -1
  13. package/dist/adapters/nuxt.js +5 -2
  14. package/dist/adapters/remix.d.ts +0 -1
  15. package/dist/adapters/remix.js +5 -2
  16. package/dist/adapters/solid-start.d.ts +0 -1
  17. package/dist/adapters/solid-start.js +5 -2
  18. package/dist/adapters/svelte-kit.d.ts +0 -1
  19. package/dist/adapters/svelte-kit.js +5 -2
  20. package/dist/adapters/tanstack-start.d.ts +0 -1
  21. package/dist/adapters/tanstack-start.js +5 -2
  22. package/dist/add-svelte-kit-env-modules.d.ts +0 -1
  23. package/dist/add-svelte-kit-env-modules.js +0 -1
  24. package/dist/auth-adapter.d.ts +5 -2
  25. package/dist/auth-adapter.js +29 -3
  26. package/dist/cli/commands/init.d.ts +0 -1
  27. package/dist/cli/commands/init.js +0 -1
  28. package/dist/cli.d.ts +0 -1
  29. package/dist/cli.js +6 -1
  30. package/dist/config.d.ts +0 -1
  31. package/dist/config.js +0 -1
  32. package/dist/core/handler.d.ts +0 -1
  33. package/dist/core/handler.js +36 -5
  34. package/dist/data.d.ts +0 -1
  35. package/dist/data.js +69 -14
  36. package/dist/geo-service.d.ts +0 -1
  37. package/dist/geo-service.js +0 -1
  38. package/dist/get-tsconfig-info.d.ts +0 -1
  39. package/dist/get-tsconfig-info.js +0 -1
  40. package/dist/index.d.ts +0 -1
  41. package/dist/index.js +0 -1
  42. package/dist/providers/events/helpers.d.ts +3 -2
  43. package/dist/providers/events/helpers.js +303 -93
  44. package/dist/public/assets/main-C-R_HO98.css +1 -0
  45. package/dist/public/assets/main-MRP9atW1.js +1267 -0
  46. package/dist/public/index.html +2 -2
  47. package/dist/public/shaders.png +0 -0
  48. package/dist/routes/api-router.d.ts +2 -3
  49. package/dist/routes/api-router.js +0 -1
  50. package/dist/routes.d.ts +2 -3
  51. package/dist/routes.js +785 -157
  52. package/dist/studio.d.ts +0 -1
  53. package/dist/studio.js +6 -4
  54. package/dist/types/events.d.ts +0 -1
  55. package/dist/types/events.js +34 -99
  56. package/dist/types/handler.d.ts +12 -2
  57. package/dist/types/handler.js +0 -1
  58. package/dist/types/index.d.ts +0 -1
  59. package/dist/types/index.js +0 -1
  60. package/dist/utils/access-rules.d.ts +19 -0
  61. package/dist/utils/access-rules.js +126 -0
  62. package/dist/utils/auth-callbacks-injector.d.ts +0 -1
  63. package/dist/utils/auth-callbacks-injector.js +0 -1
  64. package/dist/utils/database-detection.d.ts +0 -1
  65. package/dist/utils/database-detection.js +33 -4
  66. package/dist/utils/event-ingestion.d.ts +0 -1
  67. package/dist/utils/event-ingestion.js +1 -1
  68. package/dist/utils/hook-injector.d.ts +0 -1
  69. package/dist/utils/hook-injector.js +35 -34
  70. package/dist/utils/html-injector.d.ts +1 -7
  71. package/dist/utils/html-injector.js +15 -1
  72. package/dist/utils/org-hooks-injector.d.ts +0 -1
  73. package/dist/utils/org-hooks-injector.js +0 -1
  74. package/dist/utils/package-json.d.ts +1 -1
  75. package/dist/utils/package-json.js +21 -1
  76. package/dist/utils/paths.d.ts +0 -1
  77. package/dist/utils/paths.js +0 -1
  78. package/dist/utils/reason-messages.d.ts +5 -0
  79. package/dist/utils/reason-messages.js +32 -0
  80. package/dist/utils/session.d.ts +0 -1
  81. package/dist/utils/session.js +0 -1
  82. package/dist/utils.d.ts +0 -1
  83. package/dist/utils.js +0 -1
  84. package/package.json +3 -4
  85. package/dist/adapters/astro.d.ts.map +0 -1
  86. package/dist/adapters/astro.js.map +0 -1
  87. package/dist/adapters/elysia.d.ts.map +0 -1
  88. package/dist/adapters/elysia.js.map +0 -1
  89. package/dist/adapters/express.d.ts.map +0 -1
  90. package/dist/adapters/express.js.map +0 -1
  91. package/dist/adapters/hono.d.ts.map +0 -1
  92. package/dist/adapters/hono.js.map +0 -1
  93. package/dist/adapters/nextjs.d.ts.map +0 -1
  94. package/dist/adapters/nextjs.js.map +0 -1
  95. package/dist/adapters/nuxt.d.ts.map +0 -1
  96. package/dist/adapters/nuxt.js.map +0 -1
  97. package/dist/adapters/remix.d.ts.map +0 -1
  98. package/dist/adapters/remix.js.map +0 -1
  99. package/dist/adapters/solid-start.d.ts.map +0 -1
  100. package/dist/adapters/solid-start.js.map +0 -1
  101. package/dist/adapters/svelte-kit.d.ts.map +0 -1
  102. package/dist/adapters/svelte-kit.js.map +0 -1
  103. package/dist/adapters/tanstack-start.d.ts.map +0 -1
  104. package/dist/adapters/tanstack-start.js.map +0 -1
  105. package/dist/add-svelte-kit-env-modules.d.ts.map +0 -1
  106. package/dist/add-svelte-kit-env-modules.js.map +0 -1
  107. package/dist/auth-adapter.d.ts.map +0 -1
  108. package/dist/auth-adapter.js.map +0 -1
  109. package/dist/cli/commands/init.d.ts.map +0 -1
  110. package/dist/cli/commands/init.js.map +0 -1
  111. package/dist/cli.d.ts.map +0 -1
  112. package/dist/cli.js.map +0 -1
  113. package/dist/config.d.ts.map +0 -1
  114. package/dist/config.js.map +0 -1
  115. package/dist/core/handler.d.ts.map +0 -1
  116. package/dist/core/handler.js.map +0 -1
  117. package/dist/data.d.ts.map +0 -1
  118. package/dist/data.js.map +0 -1
  119. package/dist/geo-service.d.ts.map +0 -1
  120. package/dist/geo-service.js.map +0 -1
  121. package/dist/get-tsconfig-info.d.ts.map +0 -1
  122. package/dist/get-tsconfig-info.js.map +0 -1
  123. package/dist/index.d.ts.map +0 -1
  124. package/dist/index.js.map +0 -1
  125. package/dist/providers/events/helpers.d.ts.map +0 -1
  126. package/dist/providers/events/helpers.js.map +0 -1
  127. package/dist/public/assets/main-BeTtwdv9.js +0 -1216
  128. package/dist/public/assets/main-Dx_SZlEy.css +0 -1
  129. package/dist/routes/api-router.d.ts.map +0 -1
  130. package/dist/routes/api-router.js.map +0 -1
  131. package/dist/routes.d.ts.map +0 -1
  132. package/dist/routes.js.map +0 -1
  133. package/dist/studio.d.ts.map +0 -1
  134. package/dist/studio.js.map +0 -1
  135. package/dist/types/events.d.ts.map +0 -1
  136. package/dist/types/events.js.map +0 -1
  137. package/dist/types/handler.d.ts.map +0 -1
  138. package/dist/types/handler.js.map +0 -1
  139. package/dist/types/index.d.ts.map +0 -1
  140. package/dist/types/index.js.map +0 -1
  141. package/dist/utils/auth-callbacks-injector.d.ts.map +0 -1
  142. package/dist/utils/auth-callbacks-injector.js.map +0 -1
  143. package/dist/utils/auth-callbacks-wrapper.d.ts +0 -7
  144. package/dist/utils/auth-callbacks-wrapper.d.ts.map +0 -1
  145. package/dist/utils/auth-callbacks-wrapper.js +0 -133
  146. package/dist/utils/auth-callbacks-wrapper.js.map +0 -1
  147. package/dist/utils/database-detection.d.ts.map +0 -1
  148. package/dist/utils/database-detection.js.map +0 -1
  149. package/dist/utils/database-hook-injector.d.ts +0 -3
  150. package/dist/utils/database-hook-injector.d.ts.map +0 -1
  151. package/dist/utils/database-hook-injector.js +0 -145
  152. package/dist/utils/database-hook-injector.js.map +0 -1
  153. package/dist/utils/email-otp-hooks-injector.d.ts +0 -45
  154. package/dist/utils/email-otp-hooks-injector.d.ts.map +0 -1
  155. package/dist/utils/email-otp-hooks-injector.js +0 -141
  156. package/dist/utils/email-otp-hooks-injector.js.map +0 -1
  157. package/dist/utils/event-ingestion.d.ts.map +0 -1
  158. package/dist/utils/event-ingestion.js.map +0 -1
  159. package/dist/utils/hook-injector.d.ts.map +0 -1
  160. package/dist/utils/hook-injector.js.map +0 -1
  161. package/dist/utils/html-injector.d.ts.map +0 -1
  162. package/dist/utils/html-injector.js.map +0 -1
  163. package/dist/utils/org-hooks-injector.d.ts.map +0 -1
  164. package/dist/utils/org-hooks-injector.js.map +0 -1
  165. package/dist/utils/org-hooks-wrapper.d.ts +0 -80
  166. package/dist/utils/org-hooks-wrapper.d.ts.map +0 -1
  167. package/dist/utils/org-hooks-wrapper.js +0 -807
  168. package/dist/utils/org-hooks-wrapper.js.map +0 -1
  169. package/dist/utils/organization-hooks-wrapper.d.ts +0 -44
  170. package/dist/utils/organization-hooks-wrapper.d.ts.map +0 -1
  171. package/dist/utils/organization-hooks-wrapper.js +0 -345
  172. package/dist/utils/organization-hooks-wrapper.js.map +0 -1
  173. package/dist/utils/package-json.d.ts.map +0 -1
  174. package/dist/utils/package-json.js.map +0 -1
  175. package/dist/utils/paths.d.ts.map +0 -1
  176. package/dist/utils/paths.js.map +0 -1
  177. package/dist/utils/server-init.d.ts +0 -10
  178. package/dist/utils/server-init.d.ts.map +0 -1
  179. package/dist/utils/server-init.js +0 -40
  180. package/dist/utils/server-init.js.map +0 -1
  181. package/dist/utils/session.d.ts.map +0 -1
  182. package/dist/utils/session.js.map +0 -1
  183. package/dist/utils.d.ts.map +0 -1
  184. package/dist/utils.js.map +0 -1
  185. package/public/assets/main-BeTtwdv9.js +0 -1216
  186. package/public/assets/main-Dx_SZlEy.css +0 -1
  187. package/public/favicon.svg +0 -6
  188. package/public/index.html +0 -14
  189. package/public/logo.png +0 -0
  190. package/public/vite.svg +0 -5
  191. package/scripts/download-geolite2.js +0 -42
  192. package/scripts/generate-default-db.js +0 -462
package/README.md CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
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.
8
8
 
9
+ ## Demo Snapshot
10
+
11
+ ![Demo of Better Auth Studio](https://gk6bju9ndq.ufs.sh/f/M5pOhOFFvHQJcwmo00jXSlBtbRHTF15ujAQLPx3VpcKgMOz0)
12
+
9
13
  ## ✨ Try Better Auth Studio Demo
10
14
 
11
15
  You can try a live, demo version of Better Auth Studio here:
@@ -21,11 +25,11 @@ This online demo lets you explore the admin studio UI. Please note this is a tes
21
25
 
22
26
  ### Hosted Version
23
27
 
24
- For the hosted version, please join the waitlist: **[better-auth.build](https://better-auth.build)**
28
+ For the hosted version: **[better-auth.build](https://better-auth.build)**
25
29
 
26
30
  ### Installation
27
31
 
28
- 📖 **[Documentation](https://better-auth-studio.vercel.app)**
32
+ 📖 **[Documentation](https://better-auth.studio)**
29
33
 
30
34
  **Recommended: Install as a dev dependency** (for project-specific versions):
31
35
 
@@ -77,7 +81,7 @@ Before using Better Auth Studio, ensure you have:
77
81
 
78
82
  - **Node.js** (v18 or higher)
79
83
  - **A Better Auth project** with a valid `auth.ts` configuration file
80
- - **Database setup** (Prisma, Drizzle, or SQLite)
84
+ - **Database setup** (Prisma, Drizzle, Kysely, or SQLite)
81
85
 
82
86
  ## 🔧 Configuration
83
87
 
@@ -87,9 +91,10 @@ Better Auth Studio automatically detects and works with:
87
91
 
88
92
  - **Prisma** (`prismaAdapter`)
89
93
  - **Drizzle** (`drizzleAdapter`)
94
+ - **Kysely** (`database: { db, type }`)
90
95
  - **SQLite** (`new Database()` from better-sqlite3)
91
- - **PostgreSQL** (via Prisma or Drizzle)
92
- - **MySQL** (via Prisma or Drizzle)
96
+ - **PostgreSQL** (via Prisma, Drizzle, or Kysely)
97
+ - **MySQL** (via Prisma, Drizzle, or Kysely)
93
98
 
94
99
  ### Example Configuration Files
95
100
 
@@ -127,6 +132,31 @@ export const auth = betterAuth({
127
132
  });
128
133
  ```
129
134
 
135
+ #### Kysely Setup
136
+
137
+ ```typescript
138
+ // auth.ts
139
+ import { betterAuth } from "better-auth";
140
+ import { Kysely, PostgresDialect } from "kysely";
141
+ import { Pool } from "pg";
142
+
143
+ const db = new Kysely<any>({
144
+ dialect: new PostgresDialect({
145
+ pool: new Pool({
146
+ connectionString: process.env.DATABASE_URL,
147
+ }),
148
+ }),
149
+ });
150
+
151
+ export const auth = betterAuth({
152
+ database: {
153
+ db,
154
+ type: "postgres", // or "mysql", "sqlite", "mssql"
155
+ },
156
+ // ... other config
157
+ });
158
+ ```
159
+
130
160
  #### SQLite Setup
131
161
 
132
162
  ```typescript
@@ -154,7 +184,7 @@ export const auth = betterAuth({
154
184
  - **Delete users** - Remove users from the system
155
185
  - **Bulk operations** - Seed multiple test users
156
186
  - **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.
187
+ - **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`, Drizzle push, or a Kysely migration) to add the `lastSeenAt` column to the user table.
158
188
 
159
189
  ### 🏢 Organization Management
160
190
 
@@ -183,12 +213,14 @@ pnpx better-auth-studio start [options]
183
213
 
184
214
  **Options:**
185
215
 
186
- - `--port <number>` - Specify port (default: 3000)
216
+ - `--port <number>` - Specify port (default: 3002)
187
217
  - `--host <string>` - Specify host (default: localhost)
188
218
  - `--no-open` - Don't automatically open browser
189
219
  - `--config <path>` - Path to auth config file (default: auto-detect)
190
220
  - `--watch` - Watch for changes in auth config file and reload server automatically
191
221
 
222
+ `3002` is just the standalone Studio default so it does not clash with apps that already use `3000`. You can run Studio on `3000`, `4000`, or any other free port.
223
+
192
224
  **Examples:**
193
225
 
194
226
  ```bash
@@ -266,6 +298,62 @@ pnpm add better-auth-studio
266
298
 
267
299
  > **Note:** The CLI usage (standalone studio) can be installed as a dev dependency, but self-hosting requires it in `dependencies` for production deployments.
268
300
 
301
+ ### Docker (Standalone Self-Host)
302
+
303
+ If you want to run Better Auth Studio in its own container, this repository includes a Docker setup for the standalone CLI server.
304
+
305
+ This mode is useful when:
306
+
307
+ - you want a separate admin container
308
+ - your Better Auth app already lives in its own repository
309
+ - you want Docker-managed `node_modules` and package-manager cache volumes
310
+
311
+ > **Important:** The standalone container still needs your Better Auth project mounted into it, because Studio loads your real `auth.ts` and `studio.config.*` files at runtime.
312
+
313
+ Build the image from this repository:
314
+
315
+ ```bash
316
+ docker build -t better-auth-studio:self-host .
317
+ ```
318
+
319
+ Run it with Docker Compose:
320
+
321
+ ```bash
322
+ HOST_PROJECT_PATH=/absolute/path/to/your-better-auth-project \
323
+ CONFIG_PATH=./auth.ts \
324
+ docker compose -f docker/compose.yml up --build
325
+ ```
326
+
327
+ If your auth config is not at the project root, pass it explicitly:
328
+
329
+ ```bash
330
+ HOST_PROJECT_PATH=/absolute/path/to/your-better-auth-project \
331
+ CONFIG_PATH=./src/lib/auth.ts \
332
+ docker compose -f docker/compose.yml up --build
333
+ ```
334
+
335
+ If you already used the older filename, `docker/docker-compose.self-host.yml` still works too.
336
+
337
+ What the container does:
338
+
339
+ - mounts your Better Auth project into `/workspace`
340
+ - installs project dependencies into Docker volumes on first boot
341
+ - starts `better-auth-studio start --host 0.0.0.0 --port 3002 --no-open`
342
+
343
+ Useful environment variables:
344
+
345
+ - `HOST_PROJECT_PATH` - absolute path to your Better Auth project on the host machine
346
+ - `CONFIG_PATH` - optional auth config path inside the mounted project, for example `./src/lib/auth.ts`
347
+ - `PORT` - studio port, defaults to `3002`
348
+ - `WATCH` - set to `true` to enable watch mode
349
+ - `AUTO_INSTALL` - set to `false` if your container/project already has dependencies installed
350
+ - `PROJECT_INSTALL_CMD` - optional custom install command for non-standard setups
351
+ - `GEO_DB_PATH` - optional GeoLite database path inside the mounted project
352
+
353
+ If you change the Studio port, make sure your Better Auth config also trusts that origin when needed. The examples usually include both `http://localhost:3000` and `http://localhost:3002` for that reason.
354
+
355
+ If you already embed Studio in your server with the framework adapters below, that remains the recommended production setup. The Docker flow is mainly for running the standalone Studio server in a containerized environment.
356
+
269
357
  ### Setup
270
358
 
271
359
  **Step 1: Initialize configuration**
@@ -290,6 +378,8 @@ const config: StudioConfig = {
290
378
  access: {
291
379
  roles: ["admin"],
292
380
  allowEmails: ["admin@example.com"],
381
+ allowIpAddresses: ["127.0.0.1", "::1", "192.168.*"],
382
+ blockIpAddresses: ["203.0.113.45"],
293
383
  },
294
384
  };
295
385
 
@@ -335,15 +425,17 @@ Access at `http://localhost:3000/api/studio`
335
425
 
336
426
  ### Configuration Options
337
427
 
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) |
428
+ | Option | Required | Description |
429
+ | ------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
430
+ | `auth` | Yes | Your Better Auth instance |
431
+ | `basePath` | Yes | URL path where studio is mounted |
432
+ | `access.allowEmails` | No | Array of admin email addresses |
433
+ | `access.roles` | No | Array of allowed user roles |
434
+ | `access.allowIpAddresses` | No | IP allowlist for Studio requests. Supports exact IPs and wildcard patterns (example: `192.168.*`) |
435
+ | `access.blockIpAddresses` | No | IP blocklist for Studio requests. Supports exact IPs and wildcard patterns |
436
+ | `ipAddress` | No | IP geolocation for Events/Sessions: `provider` ("ipinfo" \| "ipapi"), `apiToken`, `baseUrl`, optional `endpoint` (ipinfo: "lite" \| "lookup") |
437
+ | `lastSeenAt` | No | Enable last-seen tracking: `{ enabled: true, columnName?: string }` |
438
+ | `metadata` | No | Custom branding (title, theme) |
347
439
 
348
440
  ## 📝 Development
349
441
 
@@ -19,4 +19,3 @@ import type { StudioConfig } from "../types/handler.js";
19
19
  export declare function betterAuthStudio(config: StudioConfig): (ctx: {
20
20
  request: Request;
21
21
  }) => Promise<Response>;
22
- //# sourceMappingURL=astro.d.ts.map
@@ -93,9 +93,12 @@ async function convertAstroToUniversal(ctx, config) {
93
93
  };
94
94
  }
95
95
  function universalToResponse(res) {
96
+ const headers = new Headers(res.headers);
97
+ res.setCookies?.forEach((cookie) => {
98
+ headers.append("Set-Cookie", cookie);
99
+ });
96
100
  return new Response(res.body, {
97
101
  status: res.status,
98
- headers: res.headers,
102
+ headers,
99
103
  });
100
104
  }
101
- //# sourceMappingURL=astro.js.map
@@ -4,4 +4,3 @@ import type { StudioConfig } from "../types/handler.js";
4
4
  * Elysia adapter for Better Auth Studio
5
5
  */
6
6
  export declare function betterAuthStudio(config: StudioConfig): (context: Context) => Promise<any>;
7
- //# sourceMappingURL=elysia.d.ts.map
@@ -70,38 +70,12 @@ async function convertElysiaToUniversal(context) {
70
70
  };
71
71
  }
72
72
  function sendElysiaResponse(context, universal) {
73
- context.set.status = universal.status;
74
- Object.entries(universal.headers).forEach(([key, value]) => {
75
- context.set.headers[key] = value;
73
+ const headers = new Headers(universal.headers);
74
+ universal.setCookies?.forEach((cookie) => {
75
+ headers.append("Set-Cookie", cookie);
76
+ });
77
+ return new Response(universal.body, {
78
+ status: universal.status,
79
+ headers,
76
80
  });
77
- if (Buffer.isBuffer(universal.body)) {
78
- return new Response(universal.body, {
79
- status: universal.status,
80
- headers: universal.headers,
81
- });
82
- }
83
- else if (typeof universal.body === "string") {
84
- const contentType = universal.headers["content-type"] || universal.headers["Content-Type"] || "";
85
- if (contentType.includes("application/json")) {
86
- try {
87
- return JSON.parse(universal.body);
88
- }
89
- catch {
90
- return universal.body;
91
- }
92
- }
93
- else if (contentType.includes("text/html")) {
94
- return new Response(universal.body, {
95
- status: universal.status,
96
- headers: universal.headers,
97
- });
98
- }
99
- else {
100
- return universal.body;
101
- }
102
- }
103
- else {
104
- return String(universal.body);
105
- }
106
81
  }
107
- //# sourceMappingURL=elysia.js.map
@@ -4,4 +4,3 @@ import type { StudioConfig } from "../types/handler.js";
4
4
  * Express adapter for Better Auth Studio
5
5
  */
6
6
  export declare function betterAuthStudio(config: StudioConfig): ExpressRouter;
7
- //# sourceMappingURL=express.d.ts.map
@@ -28,6 +28,7 @@ function convertExpressToUniversal(req) {
28
28
  url: req.originalUrl,
29
29
  method: req.method,
30
30
  headers: req.headers,
31
+ ip: req.ip,
31
32
  body: req.body,
32
33
  };
33
34
  }
@@ -36,6 +37,9 @@ function sendExpressResponse(res, universal) {
36
37
  Object.entries(universal.headers).forEach(([key, value]) => {
37
38
  res.setHeader(key, value);
38
39
  });
40
+ if (universal.setCookies?.length) {
41
+ res.setHeader("Set-Cookie", universal.setCookies);
42
+ }
39
43
  if (Buffer.isBuffer(universal.body)) {
40
44
  res.end(universal.body);
41
45
  }
@@ -43,4 +47,3 @@ function sendExpressResponse(res, universal) {
43
47
  res.send(universal.body);
44
48
  }
45
49
  }
46
- //# sourceMappingURL=express.js.map
@@ -4,4 +4,3 @@ import type { StudioConfig } from "../types/handler.js";
4
4
  * Hono adapter for Better Auth Studio
5
5
  */
6
6
  export declare function betterAuthStudio(config: StudioConfig): (c: Context) => Promise<Response>;
7
- //# sourceMappingURL=hono.d.ts.map
@@ -53,32 +53,12 @@ async function convertHonoToUniversal(c) {
53
53
  };
54
54
  }
55
55
  function sendHonoResponse(c, universal) {
56
- c.status(universal.status);
57
- Object.entries(universal.headers).forEach(([key, value]) => {
58
- c.header(key, value);
56
+ const headers = new Headers(universal.headers);
57
+ universal.setCookies?.forEach((cookie) => {
58
+ headers.append("Set-Cookie", cookie);
59
+ });
60
+ return new Response(universal.body, {
61
+ status: universal.status,
62
+ headers,
59
63
  });
60
- if (Buffer.isBuffer(universal.body)) {
61
- return c.body(universal.body);
62
- }
63
- else if (typeof universal.body === "string") {
64
- const contentType = universal.headers["content-type"] || universal.headers["Content-Type"] || "";
65
- if (contentType.includes("application/json")) {
66
- try {
67
- return c.json(JSON.parse(universal.body));
68
- }
69
- catch {
70
- return c.text(universal.body);
71
- }
72
- }
73
- else if (contentType.includes("text/html")) {
74
- return c.html(universal.body);
75
- }
76
- else {
77
- return c.text(universal.body);
78
- }
79
- }
80
- else {
81
- return c.text(String(universal.body));
82
- }
83
64
  }
84
- //# sourceMappingURL=hono.js.map
@@ -1,3 +1,2 @@
1
1
  import type { StudioConfig } from "../types/handler.js";
2
2
  export declare function betterAuthStudio(config: StudioConfig): (request: Request) => Promise<Response>;
3
- //# sourceMappingURL=nextjs.d.ts.map
@@ -52,9 +52,12 @@ async function requestToUniversal(req) {
52
52
  };
53
53
  }
54
54
  function universalToResponse(res) {
55
+ const headers = new Headers(res.headers);
56
+ res.setCookies?.forEach((cookie) => {
57
+ headers.append("Set-Cookie", cookie);
58
+ });
55
59
  return new Response(res.body, {
56
60
  status: res.status,
57
- headers: res.headers,
61
+ headers,
58
62
  });
59
63
  }
60
- //# sourceMappingURL=nextjs.js.map
@@ -16,4 +16,3 @@ import type { StudioConfig } from "../types/handler.js";
16
16
  * auto-imports enabled for h3 utilities.
17
17
  */
18
18
  export declare function betterAuthStudio(config: StudioConfig): (event: any) => Promise<Response | any>;
19
- //# sourceMappingURL=nuxt.d.ts.map
@@ -112,9 +112,12 @@ function getRequestURL(event) {
112
112
  function universalToResponse(res) {
113
113
  // Simply return a Response object - Nuxt/h3 will handle it properly
114
114
  // Nuxt will handle client disconnections automatically
115
+ const headers = new Headers(res.headers);
116
+ res.setCookies?.forEach((cookie) => {
117
+ headers.append("Set-Cookie", cookie);
118
+ });
115
119
  return new Response(res.body, {
116
120
  status: res.status,
117
- headers: res.headers,
121
+ headers,
118
122
  });
119
123
  }
120
- //# sourceMappingURL=nuxt.js.map
@@ -23,4 +23,3 @@ import type { StudioConfig } from "../types/handler.js";
23
23
  export declare function betterAuthStudio(config: StudioConfig): ({ request }: {
24
24
  request: Request;
25
25
  }) => Promise<Response>;
26
- //# sourceMappingURL=remix.d.ts.map
@@ -96,9 +96,12 @@ async function convertRemixToUniversal({ request }, config) {
96
96
  };
97
97
  }
98
98
  function universalToResponse(res) {
99
+ const headers = new Headers(res.headers);
100
+ res.setCookies?.forEach((cookie) => {
101
+ headers.append("Set-Cookie", cookie);
102
+ });
99
103
  return new Response(res.body, {
100
104
  status: res.status,
101
- headers: res.headers,
105
+ headers,
102
106
  });
103
107
  }
104
- //# sourceMappingURL=remix.js.map
@@ -27,4 +27,3 @@ type ApiEvent = {
27
27
  */
28
28
  export declare function betterAuthStudio(config: StudioConfig): (event: ApiEvent) => Promise<Response>;
29
29
  export {};
30
- //# sourceMappingURL=solid-start.d.ts.map
@@ -94,9 +94,12 @@ async function convertSolidStartToUniversal(event, config) {
94
94
  };
95
95
  }
96
96
  function universalToResponse(res) {
97
+ const headers = new Headers(res.headers);
98
+ res.setCookies?.forEach((cookie) => {
99
+ headers.append("Set-Cookie", cookie);
100
+ });
97
101
  return new Response(res.body, {
98
102
  status: res.status,
99
- headers: res.headers,
103
+ headers,
100
104
  });
101
105
  }
102
- //# sourceMappingURL=solid-start.js.map
@@ -33,4 +33,3 @@ import type { StudioConfig } from "../types/handler.js";
33
33
  * ```
34
34
  */
35
35
  export declare function betterAuthStudio(config: StudioConfig): (event: RequestEvent) => Promise<Response>;
36
- //# sourceMappingURL=svelte-kit.d.ts.map
@@ -106,9 +106,12 @@ async function convertSvelteKitToUniversal(event, config) {
106
106
  };
107
107
  }
108
108
  function universalToResponse(res) {
109
+ const headers = new Headers(res.headers);
110
+ res.setCookies?.forEach((cookie) => {
111
+ headers.append("Set-Cookie", cookie);
112
+ });
109
113
  return new Response(res.body, {
110
114
  status: res.status,
111
- headers: res.headers,
115
+ headers,
112
116
  });
113
117
  }
114
- //# sourceMappingURL=svelte-kit.js.map
@@ -29,4 +29,3 @@ type TanStackStartHandlerContext = {
29
29
  */
30
30
  export declare function betterAuthStudio(config: StudioConfig): ({ request }: TanStackStartHandlerContext) => Promise<Response>;
31
31
  export {};
32
- //# sourceMappingURL=tanstack-start.d.ts.map
@@ -100,9 +100,12 @@ async function convertTanStackStartToUniversal(request, config) {
100
100
  };
101
101
  }
102
102
  function universalToResponse(res) {
103
+ const headers = new Headers(res.headers);
104
+ res.setCookies?.forEach((cookie) => {
105
+ headers.append("Set-Cookie", cookie);
106
+ });
103
107
  return new Response(res.body, {
104
108
  status: res.status,
105
- headers: res.headers,
109
+ headers,
106
110
  });
107
111
  }
108
- //# sourceMappingURL=tanstack-start.js.map
@@ -1,2 +1 @@
1
1
  export declare function addSvelteKitEnvModules(alias: Record<string, string>): void;
2
- //# sourceMappingURL=add-svelte-kit-env-modules.d.ts.map
@@ -12,4 +12,3 @@ export function addSvelteKitEnvModules(alias) {
12
12
  alias["$app/types"] = "@sveltejs/kit";
13
13
  alias["$app/*"] = "@sveltejs/kit";
14
14
  }
15
- //# sourceMappingURL=add-svelte-kit-env-modules.js.map
@@ -1,4 +1,4 @@
1
- import type { InternalAdapter } from "better-auth";
1
+ import { type InternalAdapter } from "better-auth";
2
2
  type OptionalFields<T> = {
3
3
  [K in keyof T]?: T[K];
4
4
  };
@@ -8,6 +8,10 @@ export interface AuthAdapter extends UserInternalAdapter {
8
8
  createAccount: (data: any) => Promise<any>;
9
9
  createVerification: (data: any) => Promise<any>;
10
10
  createOrganization: (data: any) => Promise<any>;
11
+ count?: (options: {
12
+ model: string;
13
+ where?: any;
14
+ }) => Promise<number>;
11
15
  create?: (...args: any[]) => Promise<any>;
12
16
  update?: (...args: any[]) => Promise<any>;
13
17
  delete?: (...args: any[]) => Promise<any>;
@@ -34,4 +38,3 @@ export declare function createMockSession(adapter: AuthAdapter, userId: string,
34
38
  export declare function createMockAccount(adapter: AuthAdapter, userId: string, index: number, providerId?: string): Promise<any>;
35
39
  export declare function createMockVerification(adapter: AuthAdapter, _userId: string, index: number): Promise<any>;
36
40
  export {};
37
- //# sourceMappingURL=auth-adapter.d.ts.map
@@ -102,8 +102,14 @@ export async function getAuthAdapter(configPath) {
102
102
  image: data.image || `https://api.dicebear.com/7.x/avataaars/svg?seed=${data.email}`,
103
103
  },
104
104
  });
105
- const hashedPassword = await hashPassword(data.password);
106
105
  if (data.password) {
106
+ let hashedPassword = data.password;
107
+ try {
108
+ hashedPassword = await hashPassword(data.password);
109
+ }
110
+ catch (err) {
111
+ console.log({ err });
112
+ }
107
113
  try {
108
114
  await adapter.create({
109
115
  model: "account",
@@ -117,7 +123,9 @@ export async function getAuthAdapter(configPath) {
117
123
  },
118
124
  });
119
125
  }
120
- catch (_accountError) { }
126
+ catch (_accountError) {
127
+ console.log({ _accountError });
128
+ }
121
129
  }
122
130
  return user;
123
131
  },
@@ -193,6 +201,25 @@ export async function getAuthAdapter(configPath) {
193
201
  return [];
194
202
  }
195
203
  },
204
+ count: async (options) => {
205
+ try {
206
+ if (typeof adapter.count === "function") {
207
+ return await adapter.count(options);
208
+ }
209
+ if (typeof adapter.findMany === "function") {
210
+ const rows = await adapter.findMany({
211
+ model: options.model,
212
+ where: options.where,
213
+ limit: 100000,
214
+ });
215
+ return Array.isArray(rows) ? rows.length : 0;
216
+ }
217
+ return 0;
218
+ }
219
+ catch (_error) {
220
+ return 0;
221
+ }
222
+ },
196
223
  findMany: async (options) => {
197
224
  try {
198
225
  if (typeof adapter.findMany === "function") {
@@ -488,4 +515,3 @@ export async function createMockVerification(adapter, _userId, index) {
488
515
  };
489
516
  return await adapter.createVerification(verificationData);
490
517
  }
491
- //# sourceMappingURL=auth-adapter.js.map
@@ -1,4 +1,3 @@
1
1
  export declare function initCommand(options?: {
2
2
  apiDir?: string;
3
3
  }): Promise<void>;
4
- //# sourceMappingURL=init.d.ts.map
@@ -252,4 +252,3 @@ function detectFramework() {
252
252
  catch { }
253
253
  return "unknown";
254
254
  }
255
- //# sourceMappingURL=init.js.map
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js CHANGED
@@ -281,6 +281,12 @@ program
281
281
  else if (content.includes("prismaAdapter")) {
282
282
  databaseInfo = "Prisma";
283
283
  }
284
+ else if (content.includes("kyselyAdapter") ||
285
+ content.includes("Kysely") ||
286
+ content.includes('from "kysely"') ||
287
+ content.includes("from 'kysely'")) {
288
+ databaseInfo = "Kysely";
289
+ }
284
290
  else if (authConfig.database.adapter && authConfig.database.provider) {
285
291
  const adapter = authConfig.database.adapter;
286
292
  const adapterName = adapter.charAt(0).toUpperCase() + adapter.slice(1);
@@ -364,4 +370,3 @@ program
364
370
  }
365
371
  });
366
372
  program.parse();
367
- //# sourceMappingURL=cli.js.map
package/dist/config.d.ts CHANGED
@@ -50,4 +50,3 @@ export declare function getConfig({ cwd, configPath, shouldThrowOnError, noCache
50
50
  }): Promise<any>;
51
51
  export { possiblePaths };
52
52
  export declare function findAuthConfig(configPath?: string): Promise<AuthConfig | null>;
53
- //# sourceMappingURL=config.d.ts.map
package/dist/config.js CHANGED
@@ -298,4 +298,3 @@ export async function findAuthConfig(configPath) {
298
298
  return null;
299
299
  }
300
300
  }
301
- //# sourceMappingURL=config.js.map
@@ -9,4 +9,3 @@ export declare function initializeEventIngestionAndHooks(config: StudioConfig):
9
9
  */
10
10
  export declare function handleStudioRequest(request: UniversalRequest, config: StudioConfig): Promise<UniversalResponse>;
11
11
  export declare function getAuthAdapter(auth: any): Promise<any>;
12
- //# sourceMappingURL=handler.d.ts.map