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

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 (194) hide show
  1. package/README.md +145 -16
  2. package/dist/adapters/astro.d.ts +0 -1
  3. package/dist/adapters/astro.js +5 -2
  4. package/dist/adapters/cloudflare-workers.d.ts +101 -0
  5. package/dist/adapters/cloudflare-workers.js +494 -0
  6. package/dist/adapters/elysia.d.ts +0 -1
  7. package/dist/adapters/elysia.js +7 -33
  8. package/dist/adapters/express.d.ts +0 -1
  9. package/dist/adapters/express.js +4 -1
  10. package/dist/adapters/hono.d.ts +0 -1
  11. package/dist/adapters/hono.js +7 -27
  12. package/dist/adapters/nextjs.d.ts +0 -1
  13. package/dist/adapters/nextjs.js +5 -2
  14. package/dist/adapters/nuxt.d.ts +0 -1
  15. package/dist/adapters/nuxt.js +5 -2
  16. package/dist/adapters/remix.d.ts +0 -1
  17. package/dist/adapters/remix.js +5 -2
  18. package/dist/adapters/solid-start.d.ts +0 -1
  19. package/dist/adapters/solid-start.js +5 -2
  20. package/dist/adapters/svelte-kit.d.ts +0 -1
  21. package/dist/adapters/svelte-kit.js +5 -2
  22. package/dist/adapters/tanstack-start.d.ts +0 -1
  23. package/dist/adapters/tanstack-start.js +5 -2
  24. package/dist/add-svelte-kit-env-modules.d.ts +0 -1
  25. package/dist/add-svelte-kit-env-modules.js +0 -1
  26. package/dist/auth-adapter.d.ts +5 -2
  27. package/dist/auth-adapter.js +29 -3
  28. package/dist/cli/commands/init.d.ts +0 -1
  29. package/dist/cli/commands/init.js +0 -1
  30. package/dist/cli.d.ts +0 -1
  31. package/dist/cli.js +6 -1
  32. package/dist/config.d.ts +0 -1
  33. package/dist/config.js +0 -1
  34. package/dist/core/handler.d.ts +0 -1
  35. package/dist/core/handler.js +36 -5
  36. package/dist/data.d.ts +0 -1
  37. package/dist/data.js +69 -14
  38. package/dist/geo-service.d.ts +0 -1
  39. package/dist/geo-service.js +0 -1
  40. package/dist/get-tsconfig-info.d.ts +0 -1
  41. package/dist/get-tsconfig-info.js +0 -1
  42. package/dist/index.d.ts +0 -1
  43. package/dist/index.js +0 -1
  44. package/dist/providers/events/helpers.d.ts +3 -2
  45. package/dist/providers/events/helpers.js +303 -93
  46. package/dist/public/assets/main-C-R_HO98.css +1 -0
  47. package/dist/public/assets/main-MRP9atW1.js +1267 -0
  48. package/dist/public/index.html +2 -2
  49. package/dist/public/shaders.png +0 -0
  50. package/dist/routes/api-router.d.ts +2 -3
  51. package/dist/routes/api-router.js +0 -1
  52. package/dist/routes.d.ts +2 -3
  53. package/dist/routes.js +785 -157
  54. package/dist/studio.d.ts +0 -1
  55. package/dist/studio.js +6 -4
  56. package/dist/types/events.d.ts +0 -1
  57. package/dist/types/events.js +34 -99
  58. package/dist/types/handler.d.ts +13 -3
  59. package/dist/types/handler.js +0 -1
  60. package/dist/types/index.d.ts +0 -1
  61. package/dist/types/index.js +0 -1
  62. package/dist/utils/access-rules.d.ts +19 -0
  63. package/dist/utils/access-rules.js +126 -0
  64. package/dist/utils/auth-callbacks-injector.d.ts +0 -1
  65. package/dist/utils/auth-callbacks-injector.js +0 -1
  66. package/dist/utils/database-detection.d.ts +0 -1
  67. package/dist/utils/database-detection.js +33 -4
  68. package/dist/utils/event-ingestion.d.ts +0 -1
  69. package/dist/utils/event-ingestion.js +1 -1
  70. package/dist/utils/hook-injector.d.ts +0 -1
  71. package/dist/utils/hook-injector.js +35 -34
  72. package/dist/utils/html-injector.d.ts +1 -7
  73. package/dist/utils/html-injector.js +15 -1
  74. package/dist/utils/org-hooks-injector.d.ts +0 -1
  75. package/dist/utils/org-hooks-injector.js +0 -1
  76. package/dist/utils/package-json.d.ts +1 -1
  77. package/dist/utils/package-json.js +21 -1
  78. package/dist/utils/paths.d.ts +0 -1
  79. package/dist/utils/paths.js +0 -1
  80. package/dist/utils/reason-messages.d.ts +5 -0
  81. package/dist/utils/reason-messages.js +32 -0
  82. package/dist/utils/session.d.ts +0 -1
  83. package/dist/utils/session.js +0 -1
  84. package/dist/utils.d.ts +0 -1
  85. package/dist/utils.js +0 -1
  86. package/package.json +4 -4
  87. package/dist/adapters/astro.d.ts.map +0 -1
  88. package/dist/adapters/astro.js.map +0 -1
  89. package/dist/adapters/elysia.d.ts.map +0 -1
  90. package/dist/adapters/elysia.js.map +0 -1
  91. package/dist/adapters/express.d.ts.map +0 -1
  92. package/dist/adapters/express.js.map +0 -1
  93. package/dist/adapters/hono.d.ts.map +0 -1
  94. package/dist/adapters/hono.js.map +0 -1
  95. package/dist/adapters/nextjs.d.ts.map +0 -1
  96. package/dist/adapters/nextjs.js.map +0 -1
  97. package/dist/adapters/nuxt.d.ts.map +0 -1
  98. package/dist/adapters/nuxt.js.map +0 -1
  99. package/dist/adapters/remix.d.ts.map +0 -1
  100. package/dist/adapters/remix.js.map +0 -1
  101. package/dist/adapters/solid-start.d.ts.map +0 -1
  102. package/dist/adapters/solid-start.js.map +0 -1
  103. package/dist/adapters/svelte-kit.d.ts.map +0 -1
  104. package/dist/adapters/svelte-kit.js.map +0 -1
  105. package/dist/adapters/tanstack-start.d.ts.map +0 -1
  106. package/dist/adapters/tanstack-start.js.map +0 -1
  107. package/dist/add-svelte-kit-env-modules.d.ts.map +0 -1
  108. package/dist/add-svelte-kit-env-modules.js.map +0 -1
  109. package/dist/auth-adapter.d.ts.map +0 -1
  110. package/dist/auth-adapter.js.map +0 -1
  111. package/dist/cli/commands/init.d.ts.map +0 -1
  112. package/dist/cli/commands/init.js.map +0 -1
  113. package/dist/cli.d.ts.map +0 -1
  114. package/dist/cli.js.map +0 -1
  115. package/dist/config.d.ts.map +0 -1
  116. package/dist/config.js.map +0 -1
  117. package/dist/core/handler.d.ts.map +0 -1
  118. package/dist/core/handler.js.map +0 -1
  119. package/dist/data.d.ts.map +0 -1
  120. package/dist/data.js.map +0 -1
  121. package/dist/geo-service.d.ts.map +0 -1
  122. package/dist/geo-service.js.map +0 -1
  123. package/dist/get-tsconfig-info.d.ts.map +0 -1
  124. package/dist/get-tsconfig-info.js.map +0 -1
  125. package/dist/index.d.ts.map +0 -1
  126. package/dist/index.js.map +0 -1
  127. package/dist/providers/events/helpers.d.ts.map +0 -1
  128. package/dist/providers/events/helpers.js.map +0 -1
  129. package/dist/public/assets/main-BeTtwdv9.js +0 -1216
  130. package/dist/public/assets/main-Dx_SZlEy.css +0 -1
  131. package/dist/routes/api-router.d.ts.map +0 -1
  132. package/dist/routes/api-router.js.map +0 -1
  133. package/dist/routes.d.ts.map +0 -1
  134. package/dist/routes.js.map +0 -1
  135. package/dist/studio.d.ts.map +0 -1
  136. package/dist/studio.js.map +0 -1
  137. package/dist/types/events.d.ts.map +0 -1
  138. package/dist/types/events.js.map +0 -1
  139. package/dist/types/handler.d.ts.map +0 -1
  140. package/dist/types/handler.js.map +0 -1
  141. package/dist/types/index.d.ts.map +0 -1
  142. package/dist/types/index.js.map +0 -1
  143. package/dist/utils/auth-callbacks-injector.d.ts.map +0 -1
  144. package/dist/utils/auth-callbacks-injector.js.map +0 -1
  145. package/dist/utils/auth-callbacks-wrapper.d.ts +0 -7
  146. package/dist/utils/auth-callbacks-wrapper.d.ts.map +0 -1
  147. package/dist/utils/auth-callbacks-wrapper.js +0 -133
  148. package/dist/utils/auth-callbacks-wrapper.js.map +0 -1
  149. package/dist/utils/database-detection.d.ts.map +0 -1
  150. package/dist/utils/database-detection.js.map +0 -1
  151. package/dist/utils/database-hook-injector.d.ts +0 -3
  152. package/dist/utils/database-hook-injector.d.ts.map +0 -1
  153. package/dist/utils/database-hook-injector.js +0 -145
  154. package/dist/utils/database-hook-injector.js.map +0 -1
  155. package/dist/utils/email-otp-hooks-injector.d.ts +0 -45
  156. package/dist/utils/email-otp-hooks-injector.d.ts.map +0 -1
  157. package/dist/utils/email-otp-hooks-injector.js +0 -141
  158. package/dist/utils/email-otp-hooks-injector.js.map +0 -1
  159. package/dist/utils/event-ingestion.d.ts.map +0 -1
  160. package/dist/utils/event-ingestion.js.map +0 -1
  161. package/dist/utils/hook-injector.d.ts.map +0 -1
  162. package/dist/utils/hook-injector.js.map +0 -1
  163. package/dist/utils/html-injector.d.ts.map +0 -1
  164. package/dist/utils/html-injector.js.map +0 -1
  165. package/dist/utils/org-hooks-injector.d.ts.map +0 -1
  166. package/dist/utils/org-hooks-injector.js.map +0 -1
  167. package/dist/utils/org-hooks-wrapper.d.ts +0 -80
  168. package/dist/utils/org-hooks-wrapper.d.ts.map +0 -1
  169. package/dist/utils/org-hooks-wrapper.js +0 -807
  170. package/dist/utils/org-hooks-wrapper.js.map +0 -1
  171. package/dist/utils/organization-hooks-wrapper.d.ts +0 -44
  172. package/dist/utils/organization-hooks-wrapper.d.ts.map +0 -1
  173. package/dist/utils/organization-hooks-wrapper.js +0 -345
  174. package/dist/utils/organization-hooks-wrapper.js.map +0 -1
  175. package/dist/utils/package-json.d.ts.map +0 -1
  176. package/dist/utils/package-json.js.map +0 -1
  177. package/dist/utils/paths.d.ts.map +0 -1
  178. package/dist/utils/paths.js.map +0 -1
  179. package/dist/utils/server-init.d.ts +0 -10
  180. package/dist/utils/server-init.d.ts.map +0 -1
  181. package/dist/utils/server-init.js +0 -40
  182. package/dist/utils/server-init.js.map +0 -1
  183. package/dist/utils/session.d.ts.map +0 -1
  184. package/dist/utils/session.js.map +0 -1
  185. package/dist/utils.d.ts.map +0 -1
  186. package/dist/utils.js.map +0 -1
  187. package/public/assets/main-BeTtwdv9.js +0 -1216
  188. package/public/assets/main-Dx_SZlEy.css +0 -1
  189. package/public/favicon.svg +0 -6
  190. package/public/index.html +0 -14
  191. package/public/logo.png +0 -0
  192. package/public/vite.svg +0 -5
  193. package/scripts/download-geolite2.js +0 -42
  194. 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
 
@@ -333,17 +423,56 @@ app.listen(3000);
333
423
 
334
424
  Access at `http://localhost:3000/api/studio`
335
425
 
426
+ ### Cloudflare Workers
427
+
428
+ Use the Worker adapter when the Studio shell needs to run in a non-Node runtime. The adapter avoids Node-only imports, serves UI assets from Workers Assets or an asset map, and delegates Studio API routes to an edge-compatible handler.
429
+
430
+ ```typescript
431
+ import { betterAuthStudio } from "better-auth-studio/cloudflare-workers";
432
+ import { auth } from "./auth";
433
+
434
+ type Env = {
435
+ ASSETS: { fetch(request: Request): Promise<Response> | Response };
436
+ };
437
+
438
+ const studio = betterAuthStudio<Env>({
439
+ auth,
440
+ basePath: "/studio",
441
+ // Optional when your Worker has the default ASSETS binding.
442
+ assets: (env) => env.ASSETS,
443
+ apiHandler: async (request) => {
444
+ // Handle /api/* Studio routes with edge-compatible code here.
445
+ return new Response(JSON.stringify({ error: "Not implemented" }), {
446
+ status: 501,
447
+ headers: { "Content-Type": "application/json" },
448
+ });
449
+ },
450
+ });
451
+
452
+ export default {
453
+ fetch(request: Request, env: Env, ctx: ExecutionContext) {
454
+ return studio(request, env, ctx);
455
+ },
456
+ };
457
+ ```
458
+
459
+ Access at `https://your-worker.example.com/studio`
460
+
461
+ The built-in Studio API router still depends on Node-only modules, so Workers deployments should provide `apiHandler` for `/api/*` routes. Better Auth auth routes under `/auth/*` are delegated to `auth.handler` when available.
462
+
336
463
  ### Configuration Options
337
464
 
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) |
465
+ | Option | Required | Description |
466
+ | ------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
467
+ | `auth` | Yes | Your Better Auth instance |
468
+ | `basePath` | Yes | URL path where studio is mounted |
469
+ | `access.allowEmails` | No | Array of admin email addresses |
470
+ | `access.roles` | No | Array of allowed user roles |
471
+ | `access.allowIpAddresses` | No | IP allowlist for Studio requests. Supports exact IPs and wildcard patterns (example: `192.168.*`) |
472
+ | `access.blockIpAddresses` | No | IP blocklist for Studio requests. Supports exact IPs and wildcard patterns |
473
+ | `ipAddress` | No | IP geolocation for Events/Sessions: `provider` ("ipinfo" \| "ipapi"), `apiToken`, `baseUrl`, optional `endpoint` (ipinfo: "lite" \| "lookup") |
474
+ | `lastSeenAt` | No | Enable last-seen tracking: `{ enabled: true, columnName?: string }` |
475
+ | `metadata` | No | Custom branding (title, theme) |
347
476
 
348
477
  ## 📝 Development
349
478
 
@@ -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
@@ -0,0 +1,101 @@
1
+ type MaybePromise<T> = T | Promise<T>;
2
+ export type CloudflareStudioAsset = string | Uint8Array | ArrayBuffer | Response;
3
+ export type CloudflareStudioAssetMap = Record<string, CloudflareStudioAsset>;
4
+ export type CloudflareStudioAssetBinding = {
5
+ fetch(request: Request): MaybePromise<Response>;
6
+ };
7
+ export type CloudflareStudioAssetSource<Env = unknown> = CloudflareStudioAssetBinding | CloudflareStudioAssetMap | ((env: Env) => MaybePromise<CloudflareStudioAssetBinding | CloudflareStudioAssetMap | null | undefined>);
8
+ export type CloudflareStudioMetadata = {
9
+ title?: string;
10
+ logo?: string;
11
+ favicon?: string;
12
+ company?: {
13
+ name?: string;
14
+ website?: string;
15
+ supportEmail?: string;
16
+ };
17
+ theme?: "dark" | "light" | "auto";
18
+ colors?: {
19
+ primary?: string;
20
+ secondary?: string;
21
+ accent?: string;
22
+ };
23
+ features?: {
24
+ users?: boolean;
25
+ sessions?: boolean;
26
+ organizations?: boolean;
27
+ analytics?: boolean;
28
+ tools?: boolean;
29
+ security?: boolean;
30
+ };
31
+ links?: Array<{
32
+ label: string;
33
+ url: string;
34
+ }>;
35
+ custom?: Record<string, unknown>;
36
+ };
37
+ export type CloudflareStudioAccessConfig = {
38
+ roles?: string[];
39
+ allowEmails?: string[];
40
+ allowIpAddresses?: string[];
41
+ blockIpAddresses?: string[];
42
+ sessionDuration?: number;
43
+ secret?: string;
44
+ };
45
+ export type CloudflareStudioApiContext<Env = unknown, Ctx = unknown> = {
46
+ env: Env;
47
+ ctx: Ctx;
48
+ path: string;
49
+ originalPath: string;
50
+ basePath: string;
51
+ config: CloudflareStudioConfig<Env, Ctx>;
52
+ };
53
+ export type CloudflareStudioApiHandler<Env = unknown, Ctx = unknown> = (request: Request, context: CloudflareStudioApiContext<Env, Ctx>) => MaybePromise<Response | null | undefined>;
54
+ export type CloudflareStudioIndexContext<Env = unknown, Ctx = unknown> = {
55
+ env: Env;
56
+ ctx: Ctx;
57
+ path: string;
58
+ config: CloudflareStudioConfig<Env, Ctx>;
59
+ };
60
+ export type CloudflareStudioConfig<Env = unknown, Ctx = unknown> = {
61
+ auth?: {
62
+ handler?: (request: Request) => MaybePromise<Response>;
63
+ [key: string]: unknown;
64
+ };
65
+ basePath?: string;
66
+ access?: CloudflareStudioAccessConfig;
67
+ metadata?: CloudflareStudioMetadata;
68
+ lastSeenAt?: {
69
+ enabled?: boolean;
70
+ columnName?: string;
71
+ };
72
+ tools?: {
73
+ exclude?: string[];
74
+ };
75
+ events?: {
76
+ enabled?: boolean;
77
+ liveMarquee?: {
78
+ enabled?: boolean;
79
+ pollInterval?: number;
80
+ speed?: number;
81
+ pauseOnHover?: boolean;
82
+ limit?: number;
83
+ sort?: "asc" | "desc";
84
+ colors?: Record<string, string>;
85
+ timeWindow?: Record<string, unknown>;
86
+ };
87
+ };
88
+ assets?: CloudflareStudioAssetSource<Env>;
89
+ indexHtml?: string | ((context: CloudflareStudioIndexContext<Env, Ctx>) => MaybePromise<string | Response | null | undefined>);
90
+ apiHandler?: CloudflareStudioApiHandler<Env, Ctx>;
91
+ };
92
+ export type CloudflareStudioFetchHandler<Env = unknown, Ctx = unknown> = (request: Request, env?: Env, ctx?: Ctx) => Promise<Response>;
93
+ /**
94
+ * Cloudflare Workers adapter for Better Auth Studio.
95
+ *
96
+ * This entrypoint avoids Node-only imports at module load time. It can serve Studio
97
+ * UI assets from a Workers Assets binding or an in-memory asset map and delegates
98
+ * API routes to an edge-compatible handler supplied by the host app.
99
+ */
100
+ export declare function betterAuthStudio<Env = unknown, Ctx = unknown>(config: CloudflareStudioConfig<Env, Ctx>): CloudflareStudioFetchHandler<Env, Ctx>;
101
+ export {};