@vite-hub/auth 0.3.0 → 0.4.0
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 +49 -34
- package/dist/{abilities-DfAnFYwG.d.ts → abilities-CbmTAoS_.d.ts} +1 -1
- package/dist/abilities.d.ts +1 -1
- package/dist/{ability-error-CqgBrBfR.js → ability-error-IeZQBr_-.js} +1 -1
- package/dist/agent.js +6 -5
- package/dist/{auth-instance-CR6b1W80.js → auth-instance-CmDogt4D.js} +20 -13
- package/dist/cli.js +1 -1
- package/dist/{console-runtime-DTopBP-x.d.ts → console-runtime-D2ai-Et5.d.ts} +1 -1
- package/dist/{console-runtime-J9_Vx9pT.js → console-runtime-_LrpyCYY.js} +2 -2
- package/dist/console-runtime.d.ts +2 -2
- package/dist/console-runtime.js +1 -1
- package/dist/console.d.ts +1 -1
- package/dist/{database-options-BRNef9oy.js → database-options-DpOVjUti.js} +1 -1
- package/dist/{database-schema-options-ENuRMduM.js → database-schema-options-Sk-1Bvyu.js} +1 -1
- package/dist/database.d.ts +1 -1
- package/dist/database.js +3 -3
- package/dist/{definition-CqQMcDEK.js → definition-BCaLA9kW.js} +146 -8
- package/dist/{error-diagnostics-C8XtVz0i.js → error-diagnostics-Dymr-S_n.js} +40 -4
- package/dist/{events-ByzenEVj.js → events-DCfuicoo.js} +6 -14
- package/dist/forward.js +1 -1
- package/dist/index.d.ts +3 -8
- package/dist/index.js +3 -3
- package/dist/internal/server.d.ts +3 -3
- package/dist/internal/server.js +6 -858
- package/dist/mcp-config-DRRlCAWN.js +18 -0
- package/dist/mcp-token-CpxLyl_p.js +222 -0
- package/dist/mcp.d.ts +96 -85
- package/dist/mcp.js +3 -184
- package/dist/{members-D9lfaEO_.js → members-DdlsS8kJ.js} +5 -5
- package/dist/nuxt.d.ts +15 -2
- package/dist/nuxt.js +9 -12
- package/dist/{presets-BGZi6Dfu.d.ts → presets-CHndEv5i.d.ts} +3 -4
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +3 -13
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/empty-abilities.d.ts +1 -1
- package/dist/runtime/empty-definition.d.ts +2 -1
- package/dist/runtime/empty-definition.js +2 -1
- package/dist/runtime/nuxt.js +2 -2
- package/dist/runtime/server.d.ts +1 -1
- package/dist/runtime/vue-nuxt.js +15 -7
- package/dist/schema.js +1 -1
- package/dist/server-BG_MFd4q.js +980 -0
- package/dist/{server-C0qnKN2W.d.ts → server-BM-RSf1T.d.ts} +76 -15
- package/dist/{server-bQGzVQ--.d.ts → server-C8TlOrSy.d.ts} +3 -3
- package/dist/server.d.ts +2 -2
- package/dist/server.js +3 -3
- package/dist/{session-cookies-BbH3UR2m.js → session-cookies-DVzjOKc7.js} +69 -5
- package/dist/{set-cookie-C8NOhdRE.js → set-cookie-DmqWq6kj.js} +1 -1
- package/dist/{shared-BwcdRGxD.js → shared-DRtfuFsV.js} +1 -1
- package/dist/{table-specs-8gq_FCaq.js → table-specs-CURphR3n.js} +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +2 -2
- package/dist/{types-CNaeH2Fd.d.ts → types-CruflEFI.d.ts} +62 -43
- package/dist/{vite-CV400XXY.js → vite-Dy0Xhq4H.js} +195 -149
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +2 -2
- package/dist/vue.d.ts +4 -19
- package/dist/vue.js +6 -9
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @vite-hub/auth
|
|
2
2
|
|
|
3
3
|
<p>
|
|
4
|
-
<a href="https://vitehub.dev"><img alt="ViteHub" src="https://
|
|
5
|
-
<img alt="TypeScript" src="https://
|
|
6
|
-
<img alt="Better Auth" src="https://
|
|
7
|
-
<img alt="Vite" src="https://
|
|
4
|
+
<a href="https://vitehub.dev"><img alt="ViteHub" src="https://img.shields.io/static/v1?label=ViteHub&message=vitehub.dev&color=blue"></a>
|
|
5
|
+
<img alt="TypeScript" src="https://img.shields.io/static/v1?label=TypeScript&message=ready&color=blue">
|
|
6
|
+
<img alt="Better Auth" src="https://img.shields.io/static/v1?label=Better+Auth&message=powered&color=blue">
|
|
7
|
+
<img alt="Vite" src="https://img.shields.io/static/v1?label=Vite&message=discovery&color=blue">
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
10
|
`@vite-hub/auth` defines one server-owned Auth Definition and turns it into a Better Auth server for ViteHub apps.
|
|
@@ -76,6 +76,24 @@ export default defineAuth({
|
|
|
76
76
|
|
|
77
77
|
The plugin also adds a column for each `additionalFields` entry of `user`, `session`, `account`, and `verification`, and the tables and columns of `twoFactor()`, `username()`, `anonymous()`, `phoneNumber()`, `lastLoginMethod()`, `apiKey()` from `@better-auth/api-key`, and `stripe()` from `@better-auth/stripe` when the Definition module imports and calls them. It writes them to `.vitehub/auth/schema.ts` with `createAuthSqliteSchema()` or `createAuthPostgresSchema()`. Write `additionalFields` inline with a literal `type`, or Auth fails with `AUTH_C0055`. Tables of other plugins go in the Database Definition. When the SQLite Database has some of the tables already, for example an app that wrote the Better Auth tables itself, the plugin reads them from the snapshot of the latest migration, and `createAuthSqliteSchema(options, existing)` keeps their column defaults, unique keys, indexes, and foreign keys. The next migration then adds columns, tables, and indexes and rebuilds no table, so the drop of a rebuild cannot delete the rows that reference `user` or `organization`. The tables of `authSqliteSchema` and `authPostgresSchema` have typed columns. Before it opens the Database, the adapter compares the tables and columns that the options need with the Database, and fails with `AUTH_C0056` for a missing one or for model or field remapping.
|
|
78
78
|
|
|
79
|
+
## Delete an account
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// server/auth.ts
|
|
83
|
+
import { defineAuth } from "@vite-hub/auth";
|
|
84
|
+
import { authDatabase } from "@vite-hub/auth/database";
|
|
85
|
+
|
|
86
|
+
export default defineAuth({
|
|
87
|
+
database: authDatabase(),
|
|
88
|
+
emailAndPassword: { enabled: true },
|
|
89
|
+
deleteAccount: true,
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`deleteAccount` turns on Better Auth `deleteUser`. Use stored Auth without `stateless()` or `session.cookieCache.enabled` so existing sessions can be revoked. Before Better Auth deletes the user, Auth deletes the user's Comments messages and Forms submissions in that app, then rows in Better Auth tables that reference the user, such as passkeys and MCP tokens, even without foreign keys. To delete database-backed API keys, list only the configurations that reference users in `deleteAccount.userApiKeyConfigIds`. Use `"default"` for an unnamed user-owned configuration. Unlisted configurations are left alone.
|
|
94
|
+
|
|
95
|
+
Pass `deleteAccount: { beforeDelete }` to delete the app's own rows first, or throw an `APIError` there to keep the account. When a primitive fails, Auth keeps the account and fails with `AUTH_DELETE_ACCOUNT_FAILED`. Better Auth `user.deleteUser` fails with `AUTH_DELETE_USER_UNSUPPORTED`.
|
|
96
|
+
|
|
79
97
|
## First admin
|
|
80
98
|
|
|
81
99
|
`VITEHUB_ADMINS` is a comma-separated list of social accounts, each `<provider>:<account id>`, such as `github:22072217`. When a listed account signs in or is linked, its user gets the first `adminRoles` entry of Better Auth's `admin()` plugin (`admin` by default), in place of the default role. Removing an entry does not remove the role. Without `admin()`, Auth fails with `AUTH_C0051`. The Auth Console lists the rule in its access notes. Emails are refused (`AUTH_C0058`), because a password sign-up does not prove email ownership. The removed `VITEHUB_ADMIN_EMAILS` fails with `AUTH_C0057`.
|
|
@@ -155,9 +173,9 @@ export default defineAuth(({ env, requestOrigin }) => ({
|
|
|
155
173
|
routes: ["/app", "/app/**"],
|
|
156
174
|
signIn: {
|
|
157
175
|
provider: "github",
|
|
158
|
-
callbackURL: "/app",
|
|
159
176
|
errorCallbackURL: "/app?auth_error=github",
|
|
160
177
|
},
|
|
178
|
+
afterSignIn: "/app",
|
|
161
179
|
},
|
|
162
180
|
socialProviders: {
|
|
163
181
|
github: {
|
|
@@ -174,7 +192,9 @@ Behind a proxy that ends TLS, set Better Auth's `advanced.trustedProxyHeaders: t
|
|
|
174
192
|
|
|
175
193
|
Each Auth request or route guard runs its Definition callback once, then once more with the forwarded origin if the effective options trust proxy headers and that origin differs. If the second run disables trust, Auth keeps the request URL's origin and disables proxy trust. The guard uses the same resolved options for session lookup, route authorization, and automatic provider sign-in. A later request resolves fresh options. Requests with equal resolved options share one Better Auth instance. Plain values compare by value. Functions, adapters, and bindings compare by identity, so an instance never keeps an object that another request created. `authDatabase()` adapters compare by Database name. A change to a variable that the instance uses, such as `VITEHUB_SECRET`, `BETTER_AUTH_SECRET`, `VITEHUB_ADMINS`, or `VITEHUB_MEMBERS`, gives a new instance on the next request. A callback that creates plugins or other adapters on each call builds a new instance on each request, so create them outside the callback when they do not depend on the request. All guards of one request share one session lookup: access routes, `requireAuth()`, `requireAuthorization()`, `withAuth()`, `withAuthorization()`, and `withAnonymousAuthorization()`.
|
|
176
194
|
|
|
177
|
-
|
|
195
|
+
With a provider in `access.signIn`, the Auth route also answers `GET /api/auth/sign-in?redirect=/docs` and `GET /api/auth/sign-out?redirect=/`, below the Auth Base Path. The sign-in path starts `access.signIn` and comes back to `redirect` (default: `access.afterSignIn`, or `/`). A signed-in visitor goes to `redirect` at once. The sign-out path ends the session and goes to `redirect` (default `/`). It refuses a request from another site (`Sec-Fetch-Site` `cross-site` or `same-site`) and a prefetch or prerender (`Sec-Purpose`) with `403`. `redirect` must be a path of the app, below `app.baseURL` like the page guard's `?redirect=`, or the answer is `400`. Without a provider in `access.signIn`, Better Auth answers these paths with `404`.
|
|
196
|
+
|
|
197
|
+
The generated Nitro middleware starts the provider of `access.signIn` when one of the configured `access.routes` needs a browser redirect. A sign-in page, such as `signIn: "/login"`, is for the Nuxt page guard: server guards answer `401`. Route objects can add an `authorize` callback when a valid session is not sufficient:
|
|
178
198
|
|
|
179
199
|
```ts
|
|
180
200
|
import { defineAuth } from "@vite-hub/auth"
|
|
@@ -195,17 +215,17 @@ Generated route middleware uses `createAuthAccessHandler(routes, definition?, pu
|
|
|
195
215
|
|
|
196
216
|
The Nitro build fails with `AUTH_B0002` when a route rule caches or prerenders a path that `access.routes` guards for `GET` or `HEAD`: `swr`, `cache`, `isr`, `prerender`, or `static`. A cached response is made for one visitor and served to others. Set `cache: false` or `prerender: false` on the guarded pattern to turn off a wider rule. In development, a route rule update that caches a guarded path logs `AUTH_B0002` as a warning.
|
|
197
217
|
|
|
198
|
-
`access.public` lists paths that no access route guards, in the same form as `access.routes`. With `routes: ["/**"]`, every other path needs a session, so the app is private by default.
|
|
218
|
+
`access.public` lists paths that no access route guards, in the same form as `access.routes`. With `routes: ["/**"]`, every other path needs a session, so the app is private by default. The Auth route, `<basePath>/**` (`/api/auth/**` by default), is always public, so people can sign in. A route rule that caches only public paths passes `AUTH_B0002`. Write the list inline: the Vite plugin reads it at build time, and other values fail with `AUTH_C0064`.
|
|
199
219
|
|
|
200
220
|
```ts
|
|
201
221
|
import { defineAuth } from "@vite-hub/auth";
|
|
202
222
|
|
|
203
223
|
export default defineAuth({
|
|
204
|
-
access: { routes: ["/**"], public: ["/", "/login"
|
|
224
|
+
access: { routes: ["/**"], public: ["/", "/login"] },
|
|
205
225
|
});
|
|
206
226
|
```
|
|
207
227
|
|
|
208
|
-
`access.policy: { allow, recheck }` decides who can sign in and stay signed in. Auth calls `allow({ user, accessToken })` when it creates a session; only `true` lets the person in. It calls `allow` again for a session once `recheck`
|
|
228
|
+
`access.policy: { allow, recheck }` decides who can sign in and stay signed in. Auth calls `allow({ user, accessToken })` when it creates a session; only `true` lets the person in. It calls `allow` again for a session once the `recheck` duration (default `"5m"`) has passed, on the next Better Auth request with the session cookie, which includes every `getSession()` call and guard. A refusal deletes the session and its cookies, and the request continues signed out. A throw fails the request and keeps the session. `accessToken(providerId)` returns the user's provider access token, decrypted, so `allow` can call `checkGitHubOrgMember()` or another provider. Throw its `AUTH_GITHUB_UNAVAILABLE` error, so a GitHub outage keeps the sessions. `verifyMcpRequest()` asks the same policy for the user of an MCP access token. The answers are in memory per process. The policy needs a `database` or `secondaryStorage` adapter (`AUTH_C0066`).
|
|
209
229
|
|
|
210
230
|
ViteHub runs `authorize` only after authentication. Return `true` to allow the request, `false` for a `403`, or a `Response` for a custom result. The callback receives the authenticated `user`, `session`, and request; role semantics remain owned by the host. Only `true` grants access. ViteHub sends a `Response` unchanged when it is a Response of this runtime: the native `Response.prototype.status` getter accepts it. Create it with the global `Response`. Every other value gets `403`, including a Response from another Fetch implementation such as the `undici` package, a proxy, and an object shaped like a Response.
|
|
211
231
|
|
|
@@ -228,7 +248,7 @@ Annotate the input type when the host does not infer it, for example inside `def
|
|
|
228
248
|
`withAuth()` returns JSON `401` without a session and starts the `access.signIn` redirect for HTML requests. Every JSON refusal of the guards has one body in H3's error format: `{ status, statusText, message, data: { code } }`. The code is `SIGNED_OUT` for `401` and `FORBIDDEN` for `403`. Read the code, not the message. `withAuthorization()` applies one `authorize` rule: `true` for any session or a callback. It returns JSON `401` without a session, `403` when the callback returns `false`, or the callback's `Response`. It never redirects to sign-in. The callback gets `{ event, request, session, user }`: `event` is the input of the guarded handler, such as the H3 event. Blob serve routes and Source Collections use it for their `authorize` option.
|
|
229
249
|
`withAnonymousAuthorization(authorize, handler, definition?)` also runs the callback for a signed-out caller, with `session` and `user` set to `null`. `false` returns `401` for that caller and `403` for a signed-in one. Blob serve routes use it with `serve.anonymous: true`.
|
|
230
250
|
|
|
231
|
-
To check inside a handler, call `requireAuth(event)` or `requireAuthorization(event, authorize)`. Each returns the frozen `authorization` or throws an H3 `HTTPError
|
|
251
|
+
To check inside a handler, call `requireAuth(event)` or `requireAuthorization(event, authorize)`. Each returns the frozen `authorization` or throws an H3 `HTTPError`. The default Definition's generated registry types plugin and custom fields. Additional session fields are optional because API-key sessions can omit them. Passing an explicit Definition gives you Better Auth's core fields instead of the registry's fields. The errors match the guards above: `requireAuth()` throws `401` or the `access.signIn` redirect, and `requireAuthorization()` throws `401`, `403`, or an HTTP error from the callback's `Response`. The error has the same code in `data.code`, also for the text `403` of an HTML request.
|
|
232
252
|
|
|
233
253
|
The inline guards use H3's JSON error format. They keep the response status and headers, except `content-length`, which changes with the body. JSON object fields stay at the top level, and other JSON values become `data`. JSON media types, such as `application/problem+json`, stay unchanged. Text becomes `message` with a JSON content type. Use `withAuthorization()` when the response body must stay unchanged.
|
|
234
254
|
|
|
@@ -364,11 +384,11 @@ export const session = useUserSession();
|
|
|
364
384
|
|
|
365
385
|
`session.signOut()` calls Better Auth's `signOut()` and sets `user` and `session` to `null` at once, in every component that reads the session. It does not wait for Better Auth to read the session again. `signOut({ redirectTo: "/" })` then opens that page: a plain Vue app loads it with `location.assign()`, and Nuxt opens it with `navigateTo()`. Better Auth gets the other options, such as `fetchOptions`, and `signOut()` returns Better Auth's result. When the sign-out fails, the session and the page stay. When the server answers with the provider's sign-out page, such as with OpenID Connect logout, `signOut()` opens that page in place of `redirectTo`, after the `onSignOut()` listeners, and only when it is an `http:` or `https:` page. With `disableRedirect: true`, it returns that page in `data.url` and opens `redirectTo`.
|
|
366
386
|
|
|
367
|
-
On the server, `signOut(event, { redirectTo })` from `@vite-hub/auth/server` ends the session of a request event or a Web `Request` and returns the response that clears the session cookies: a `303` redirect to `redirectTo`, or `204` without it. If Better Auth returns a provider logout URL, the response redirects there first and passes `redirectTo` as the return URL. Return it from a route such as `server/routes/logout.get.ts`. `redirectTo` must be a path of the app, or it throws `AUTH_SIGN_OUT_REDIRECT_INVALID`.
|
|
387
|
+
On the server, `signOut(event, { redirectTo })` from `@vite-hub/auth/server` ends the session of a request event or a Web `Request` and returns the response that clears the session cookies: a `303` redirect to `redirectTo`, or `204` without it. If Better Auth returns a provider logout URL, the response redirects there first and passes `redirectTo` as the return URL. Return it from a route such as `server/routes/logout.get.ts`. With `access.signIn`, a link to `/api/auth/sign-out` does the same without a route of your own. `redirectTo` must be a path of the app, or it throws `AUTH_SIGN_OUT_REDIRECT_INVALID`.
|
|
368
388
|
|
|
369
389
|
That default talks to `/api/auth` on the same origin. In a Nuxt app below `app.baseURL`, such as `/app/`, it talks to `/app/api/auth`, and the server serves Auth routes and OAuth callbacks below the same path.
|
|
370
390
|
|
|
371
|
-
In Nuxt, the default client also uses the Auth Definition's `basePath`. With `basePath: "/auth"` below `app.baseURL` `/app/`, `useUserSession()
|
|
391
|
+
In Nuxt, the default client also uses the Auth Definition's `basePath`. With `basePath: "/auth"` below `app.baseURL` `/app/`, `useUserSession()` and the page guard both call `/app/auth`. They share one Better Auth client. In the browser, the client uses the `app.baseURL` of the page, so a `NUXT_APP_BASE_URL` that a deployment sets at runtime also applies. On the server, Nuxt reads the session from the Nitro route, below the base path of the build.
|
|
372
392
|
|
|
373
393
|
```ts
|
|
374
394
|
// server/auth.ts
|
|
@@ -413,7 +433,7 @@ const { data } = await client.admin.listUsers({ query: { limit: 10 } });
|
|
|
413
433
|
|
|
414
434
|
The exported `createAuthClient` keeps Better Auth's option and plugin inference for a second client with its own base path or plugins. Without `basePath`, it uses the same path as the default client. The zero-config composables use ViteHub's shared default client. Its type is `RegisteredAuthClient`: `hubAuth()` writes the type of the Auth Definition to `.vitehub/types/auth.d.ts`, so `user` and `session` have the fields that `additionalFields`, server plugins such as `admin()`, and `customSession()` add. The client imports only this type, not server code. A client from `createAuthClient()` needs Better Auth's client plugins, such as `customSessionClient<RegisteredAuth>()`, and `inferAdditionalFields<RegisteredAuth>()` for the same fields. React, Svelte, Solid, and other framework clients remain available from Better Auth's framework entrypoints.
|
|
415
435
|
|
|
416
|
-
The client loads `better-auth/vue` the first time you use it, not when you create it. An app can create its client in a plugin, and only the pages that sign in or read the session download Better Auth. Calls such as `signIn.social()` wait for the load. `
|
|
436
|
+
The client loads `better-auth/vue` the first time you use it, not when you create it. An app can create its client in a plugin, and only the pages that sign in or read the session download Better Auth. Calls such as `signIn.social()` wait for the load. `useUserSession()` returns its refs at once: they are pending until the client loads in the browser. In Nuxt, a call in a component starts with the session that the server read for the request, so it is settled during server rendering and hydration. The browser then does not load Better Auth or read the session again until the session can change: a call such as `signOut()`, `refresh()`, the tab shows again, the network comes back, another tab signs out or updates the user, Better Auth's `refetchInterval` passes, or the session expires. Like Better Auth, it waits while the browser is offline. Better Auth then starts with the server's session, so a read that fails does not sign the page out. So without a page guard, a page that only shows the user reads the session once, on the server. When the server's session is unknown, such as on a prerendered page, the browser loads Better Auth at once. For a member that is not a call or a hook, such as `$store`, get Better Auth's own client with `loadAuthClient()`:
|
|
417
437
|
|
|
418
438
|
```ts fragment
|
|
419
439
|
import { loadAuthClient } from "@vite-hub/auth/vue";
|
|
@@ -423,7 +443,7 @@ const client = await loadAuthClient(authClient);
|
|
|
423
443
|
client.$store.listen("$sessionSignal", () => {});
|
|
424
444
|
```
|
|
425
445
|
|
|
426
|
-
All calls of `
|
|
446
|
+
All calls of `useUserSession()` for one client share one session state: one for each page in the browser, and one for each request on the server. A list of 100 components that call `useUserSession()` makes one Better Auth subscription, not 100. `refresh()` reads the session again, updates every component, and returns the session, or `null` without one. Calls at the same time share one read. On the server, `refresh()` returns the session that the server read for the request, and does not load Better Auth. `ready` is `true` after the first read. It stays `true` while a later read runs, and after a read that failed.
|
|
427
447
|
|
|
428
448
|
```ts fragment
|
|
429
449
|
import { useUserSession } from "@vite-hub/auth/vue";
|
|
@@ -464,7 +484,7 @@ Nuxt uses the Auth Definition's base path for the shared browser client. In othe
|
|
|
464
484
|
|
|
465
485
|
## Nuxt: server session and page guard
|
|
466
486
|
|
|
467
|
-
In Nuxt, the server reads the session only for a page that needs it: a page with an `auth` guard, or a page whose components call `useUserSession()
|
|
487
|
+
In Nuxt, the server reads the session only for a page that needs it: a page with an `auth` guard, or a page whose components call `useUserSession()` or `useAbility()`, or render `<Can>`. It reads the session once for each page request, waits for it before it renders those components, settles their refs as soon as it has the session, so an async `setup()` can wait for `ready`, and sends it to the browser in the page payload, without the session token. `useUserSession()` starts from it, so a signed-in page renders signed in on the server and does not flash signed out while Better Auth loads. A call outside a component, such as in a plugin or a route middleware, cannot make the server wait, so on the server it starts pending unless the page guard already read the session. To protect a page, use the `auth` page guard. A request without a session cookie skips the lookup, so pages for signed-out visitors do not load Better Auth. A prerendered or cached page was rendered without the visitor's cookie, so its session counts as unknown.
|
|
468
488
|
|
|
469
489
|
The browser downloads Better Auth's client only when the page uses it. The Auth composables come the same way: with a page that calls them or renders `<Can>`, or when the browser opens a page with an `auth` guard. The Auth plugin in the app entry is about 2 KB gzipped. Nuxt prefetches neither on other pages.
|
|
470
490
|
|
|
@@ -488,36 +508,31 @@ const { data: sessions } = await useAsyncData("sessions", async () => {
|
|
|
488
508
|
|
|
489
509
|
| `auth` | Who may open the page | Others go to |
|
|
490
510
|
| --- | --- | --- |
|
|
491
|
-
| `'user'` or `true` | Visitors with a session | `
|
|
492
|
-
| `'guest'` | Visitors without a session, such as on the login page | `
|
|
511
|
+
| `'user'` or `true` | Visitors with a session | `access.signIn` (default `/login`), with `?redirect=<the page>`. A provider opens `<basePath>/sign-in`. |
|
|
512
|
+
| `'guest'` | Visitors without a session, such as on the login page | `access.afterSignIn` (default `/`) |
|
|
493
513
|
| `{ only, redirectTo }` | `only` is `'user'` or `'guest'` | `redirectTo` |
|
|
494
514
|
| `false` or unset | Everyone | |
|
|
495
515
|
|
|
496
516
|
```ts
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
517
|
+
// server/auth.ts
|
|
518
|
+
import { defineAuth } from "@vite-hub/auth"
|
|
519
|
+
|
|
520
|
+
export default defineAuth({
|
|
521
|
+
access: { signIn: "/sign-in", afterSignIn: "/app" },
|
|
501
522
|
})
|
|
502
523
|
```
|
|
503
524
|
|
|
504
|
-
On client navigation, the guard reads the session into the same state as `useUserSession()
|
|
525
|
+
On client navigation, the guard reads the session into the same state as `useUserSession()`. When the guard finds that the session ended, such as after a sign-out in another tab, every component shows the visitor as signed out before the redirect.
|
|
505
526
|
|
|
506
|
-
The guard runs when the route changes.
|
|
527
|
+
The guard runs when the route changes. On a `'user'` page, `signOut()` of `useUserSession()` sends the visitor to its sign-in page, with `?redirect=<the page>`. `redirectTo` takes priority. With provider sign-in and no `redirectTo`, Nuxt shows a signed-out page instead of starting OAuth again: even `/` might be protected. Pass `signOut({ redirectTo: '/goodbye' })` to send the visitor to a public page of your choice. Other pages stay open by default.
|
|
507
528
|
|
|
508
529
|
The page guard decides where the browser goes. Protect data in server routes with `withAuth()`, `requireAuth()`, or `access.routes`. Read [Protect pages in Nuxt](https://vitehub.dev/docs/auth/protect-pages) for the full task.
|
|
509
530
|
|
|
510
531
|
## GitHub organization membership
|
|
511
532
|
|
|
512
|
-
`
|
|
513
|
-
|
|
514
|
-
```ts fragment
|
|
515
|
-
import { isGitHubOrgMember } from "@vite-hub/auth";
|
|
516
|
-
|
|
517
|
-
const member = await isGitHubOrgMember(account.accessToken, "acme", { cacheMs: 300_000 });
|
|
518
|
-
```
|
|
533
|
+
`checkGitHubOrgMember(accessToken, org, { cacheMs, timeoutMs })` from `@vite-hub/auth` returns `[undefined, undefined]` only for an active membership. The token needs `read:org`. A pending invitation, a non-2xx response, a network error, or a timeout (default 5 seconds) returns `[error, undefined]`, so the app can say why access failed. There is no cache by default. With `cacheMs`, a successful check is kept in memory for that time per token and organization, under a SHA-256 key.
|
|
519
534
|
|
|
520
|
-
`
|
|
535
|
+
`error.code` is `AUTH_GITHUB_TOKEN_INVALID` (401 or no token), `AUTH_GITHUB_ORG_ACCESS_DENIED` (403, a missing `read:org` scope, or SAML single sign-on that the token is not authorized for), `AUTH_GITHUB_UNAVAILABLE` (network error, timeout, 429, 5xx, or rate limit), or `AUTH_GITHUB_NOT_ORG_MEMBER` (404 or a pending invitation). An empty `org` throws `AUTH_GITHUB_ORG_REQUIRED`.
|
|
521
536
|
|
|
522
537
|
```ts fragment
|
|
523
538
|
import { checkGitHubOrgMember } from "@vite-hub/auth";
|
|
@@ -547,7 +562,7 @@ export default defineAuth({
|
|
|
547
562
|
});
|
|
548
563
|
```
|
|
549
564
|
|
|
550
|
-
`@vite-hub/auth/mcp` makes Better Auth the OAuth 2.1 authorization server of an MCP server that the app owns, such as `/mcp`. `mcpOAuth({ resource, loginPage })` returns `jwt()`, `oauthProvider()` with open dynamic registration for native MCP clients, and a guard that bounds the registration body and its fields. `serveMcpOAuthDiscovery(request)` answers the protected resource, authorization server, and OpenID documents at the origin root, with CORS for any origin and `204` for an `OPTIONS` preflight, and returns `undefined` for other paths. `verifyMcpRequest(request)` returns `[error, caller]` with the user, scopes, and client name of a valid access token. `deleteUnusedMcpClients()` deletes registrations that never finished sign-in. Install `@better-auth/oauth-provider` with the version of `better-auth` that this package uses.
|
|
565
|
+
`@vite-hub/auth/mcp` makes Better Auth the OAuth 2.1 authorization server of an MCP server that the app owns, such as `/mcp`. `mcpOAuth({ resource, loginPage })` returns `jwt()`, `oauthProvider()` with open dynamic registration for native MCP clients, and a guard that bounds the registration body and its fields. `serveMcpOAuthDiscovery(request)` answers the protected resource, authorization server, and OpenID documents at the origin root, with CORS for any origin and `204` for an `OPTIONS` preflight, and returns `undefined` for other paths. `verifyMcpRequest(request)` returns `[error, caller]` with the user, scopes, and client name of a valid access token. `requireCaller(event)` from `@vite-hub/auth/server` returns `[error, caller]` for a session (`kind: "browser"`) or an access token on any route of the app (`kind: "agent"`, with `client` and `scopes`), so a route can refuse an Agent. `requireAuth()` stays session-only. `deleteUnusedMcpClients()` deletes registrations that never finished sign-in. Install `@better-auth/oauth-provider` with the version of `better-auth` that this package uses.
|
|
551
566
|
|
|
552
567
|
```ts
|
|
553
568
|
// server/auth.ts
|
|
@@ -589,7 +604,7 @@ import { ViteHubError } from "@vite-hub/runtime";
|
|
|
589
604
|
const error = new ViteHubError("AUTHENTICATION_REQUIRED", "Sign in to use this Agent.");
|
|
590
605
|
```
|
|
591
606
|
|
|
592
|
-
`error.toJSON()` includes `name`, `code`, and `message`, while omitting `cause` and stack data. If a default Better Auth request or session operation fails, `authenticated()`, `withAuth()`, and `withAuthorization()` throw the same shared error with code `AUTH_PROVIDER_OPERATION_FAILED` and safe operation details; raw provider diagnostics remain available only through `cause`. Existing ViteHub errors and structural `AbortError` objects keep their identity. Missing APIs, malformed responses, invalid Auth configuration, and invalid custom callback results use package-owned `AUTH_C####`, `AUTH_B####`, or `AUTH_R####` Nostics codes.
|
|
607
|
+
`error.toJSON()` includes `name`, `code`, and `message`, while omitting `cause` and stack data. If a default Better Auth request or session operation fails, `authenticated()`, `withAuth()`, and `withAuthorization()` throw the same shared error with code `AUTH_PROVIDER_OPERATION_FAILED` and safe operation details; raw provider diagnostics remain available only through `cause`. A Better Auth `4xx` refusal of the session read, such as an invalid key of the API Key plugin, is answered with its status, `data.code`, and headers instead: the wrappers return it, and the `require*` guards throw it as an H3 `HTTPError`. Existing ViteHub errors and structural `AbortError` objects keep their identity. Missing APIs, malformed responses, invalid Auth configuration, and invalid custom callback results use package-owned `AUTH_C####`, `AUTH_B####`, or `AUTH_R####` Nostics codes.
|
|
593
608
|
|
|
594
609
|
## Test a signed-in route
|
|
595
610
|
|
|
@@ -625,7 +640,7 @@ Opt in with `events: { store: createDatabaseAuthEventStore({ db }) }` in `define
|
|
|
625
640
|
|
|
626
641
|
The default retention is 90 days and 100,000 records, with cleanup after each append. Override `retention.maxAgeMs` or `retention.maxRecords`, or use `retention: false`. IP addresses are discarded. User agents become a coarse device class. Admin updates store field names, not secret values.
|
|
627
642
|
|
|
628
|
-
Use `listAuthEvents(filters)` and `aggregateAuthEvents({ from, to })` from `@vite-hub/auth/server`, or use the store directly. Lists use cursor pagination and one SQL query after initialization. Aggregates use one statement for a consistent snapshot and count distinct users over the whole window. `@vite-hub/auth/runtime/console` exports these readers for the Console. No Console UI is added.
|
|
643
|
+
Use `listAuthEvents(filters)` and `aggregateAuthEvents({ from, to })` from `@vite-hub/auth/server`, or use the store directly. The readers return `[error, data]`: `AUTH_EVENT_QUERY_INVALID` for invalid filters and `AUTH_EVENT_READ_FAILED` for a store failure. Lists use cursor pagination and one SQL query after initialization. Aggregates use one statement for a consistent snapshot and count distinct users over the whole window. `@vite-hub/auth/runtime/console` exports these readers for the Console. No Console UI is added.
|
|
629
644
|
|
|
630
645
|
For `vitehub auth events`, configure `events.authorize`. The read endpoint requires a session and an explicit `true` result. Give the CLI the Auth base URL with `--url`, and the session cookie through `VITEHUB_AUTH_COOKIE`.
|
|
631
646
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as RegisteredAuth, l as AuthAnonymousAuthorization, p as AuthAuthorization } from "./types-CruflEFI.js";
|
|
2
2
|
//#region src/abilities.d.ts
|
|
3
3
|
/** A 4xx status that a rule can refuse with. `403` is the default. */
|
|
4
4
|
type AbilityStatus = 400 | 401 | 402 | 403 | 404 | 405 | 409 | 410 | 422 | 423 | 429 | 451;
|
package/dist/abilities.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AbilityRefusal, c as AbilityStatus, d as GuestAbilityRule, f as defineAbilities, i as AbilityName, l as AbilityUser, m as guest, n as AbilityAuthorization, o as AbilityRule, p as deny, r as AbilityDenial, s as AbilityRules, t as AbilityArgs, u as AbilityVerdict } from "./abilities-
|
|
1
|
+
import { a as AbilityRefusal, c as AbilityStatus, d as GuestAbilityRule, f as defineAbilities, i as AbilityName, l as AbilityUser, m as guest, n as AbilityAuthorization, o as AbilityRule, p as deny, r as AbilityDenial, s as AbilityRules, t as AbilityArgs, u as AbilityVerdict } from "./abilities-CbmTAoS_.js";
|
|
2
2
|
export { AbilityArgs, AbilityAuthorization, AbilityDenial, AbilityName, AbilityRefusal, AbilityRule, AbilityRules, AbilityStatus, AbilityUser, AbilityVerdict, GuestAbilityRule, defineAbilities, deny, guest };
|
package/dist/agent.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { n as invalidAuthenticationErrorOptions, r as throwAuthenticationProviderError } from "./set-cookie-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
|
+
import { n as invalidAuthenticationErrorOptions, r as throwAuthenticationProviderError } from "./set-cookie-DmqWq6kj.js";
|
|
3
3
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as getAuthenticationSession, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-DVzjOKc7.js";
|
|
5
5
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
6
6
|
//#region src/agent.ts
|
|
7
7
|
let server;
|
|
8
|
-
const loadServer = () => server ??= import("./server.js").catch((error) => {
|
|
8
|
+
const loadServer = () => server ??= import("./internal/server.js").catch((error) => {
|
|
9
9
|
server = void 0;
|
|
10
10
|
throw error;
|
|
11
11
|
});
|
|
@@ -58,7 +58,7 @@ async function defaultAuthenticatedSource(context) {
|
|
|
58
58
|
if (!context.request) return void 0;
|
|
59
59
|
const { useAuth } = await loadServer();
|
|
60
60
|
const auth = useAuth(context.request);
|
|
61
|
-
const { session, setCookies } = await getAuthenticationSession(auth, {
|
|
61
|
+
const { refusal, session, setCookies } = await getAuthenticationSession(auth, {
|
|
62
62
|
headers: context.request.headers,
|
|
63
63
|
query: {
|
|
64
64
|
disableCookieCache: true,
|
|
@@ -66,6 +66,7 @@ async function defaultAuthenticatedSource(context) {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
prepareSessionCookies(context.request, setCookies);
|
|
69
|
+
if (refusal) throw authenticationRefusalError(refusal);
|
|
69
70
|
return session;
|
|
70
71
|
}
|
|
71
72
|
function readProviderField(read) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
|
+
import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-DmqWq6kj.js";
|
|
3
3
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
4
4
|
import { n as authRequestEvent, t as authCloudflareEnv } from "./request-z6DHHmrb.js";
|
|
5
|
-
import { a as readMembers, c as createAccessPolicyPlugin, d as createAdminClaimPlugin, f as readAdminClaim, g as readAdmins, h as createAdminsPlugin, n as createMembersGate, o as withMemberScopes, t as assertMembersSessionStore } from "./members-
|
|
5
|
+
import { a as readMembers, c as createAccessPolicyPlugin, d as createAdminClaimPlugin, f as readAdminClaim, g as readAdmins, h as createAdminsPlugin, n as createMembersGate, o as withMemberScopes, t as assertMembersSessionStore } from "./members-DdlsS8kJ.js";
|
|
6
6
|
import { i as resetAuth, n as getAuthRuntimeState, t as authProcessMemoryDatabase } from "./runtime-state-ojQCzKOc.js";
|
|
7
|
-
import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-
|
|
7
|
+
import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-DCfuicoo.js";
|
|
8
8
|
import { i as resolveAuthMountPath } from "./application-path-DuTpfGFj.js";
|
|
9
|
-
import { t as normalizeAuthBasePath } from "./shared-
|
|
10
|
-
import { o as authMemoryDatabaseError, r as authDatabaseName, t as assertAuthDatabaseIdStrategy } from "./database-options-
|
|
11
|
-
import { t as assertAuthDatabaseNames } from "./database-schema-options-
|
|
12
|
-
import { a as
|
|
9
|
+
import { t as normalizeAuthBasePath } from "./shared-DRtfuFsV.js";
|
|
10
|
+
import { o as authMemoryDatabaseError, r as authDatabaseName, t as assertAuthDatabaseIdStrategy } from "./database-options-DpOVjUti.js";
|
|
11
|
+
import { t as assertAuthDatabaseNames } from "./database-schema-options-Sk-1Bvyu.js";
|
|
12
|
+
import { a as validateDeleteAccount, i as createDeleteAccount, o as validateAuthEvents, r as validateAuthAccessPolicy, s as applyAuthPreset, t as assertNoRuntimeOption } from "./definition-BCaLA9kW.js";
|
|
13
13
|
import { n as viteHubPageToolsResetCookie, r as viteHubSessionMarkerCookie } from "./page-tools-shared-l4eyj53D.js";
|
|
14
14
|
import { resolvePublicUrl } from "@vite-hub/runtime";
|
|
15
15
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
@@ -19,10 +19,10 @@ import { getCookies } from "better-auth/cookies";
|
|
|
19
19
|
import { getAuthTables } from "better-auth/db";
|
|
20
20
|
import { APIError as APIError$1, betterAuth, isRequestLike, resolveBaseURL } from "better-auth";
|
|
21
21
|
import { memoryAdapter } from "better-auth/adapters/memory";
|
|
22
|
+
import definitionForApp, { getAuthApp } from "#vitehub/auth/definition";
|
|
22
23
|
import { getViteHubTestMode } from "@vite-hub/runtime/internal/test-mode";
|
|
23
24
|
import { isWebContainer } from "@vite-hub/web-container/env";
|
|
24
25
|
import { hkdfSync } from "node:crypto";
|
|
25
|
-
import discoveredDefinition from "#vitehub/auth/definition";
|
|
26
26
|
//#region ../internal/src/runtime/request-origin.ts
|
|
27
27
|
function firstHeaderValue(headers, name) {
|
|
28
28
|
return headers.get(name)?.split(",", 1)[0]?.trim() || void 0;
|
|
@@ -802,7 +802,8 @@ function readProviderEnvironment(options, event) {
|
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
804
|
function stripViteHubOptions(definition, options, environment) {
|
|
805
|
-
|
|
805
|
+
validateDeleteAccount(options);
|
|
806
|
+
const { access, adminClaim: _adminClaim, console: _console, database, deleteAccount, events, route: _route, secondaryStorage, ...rest } = applyAuthPreset(options);
|
|
806
807
|
if (isAuthDatabasePlacement(database)) throw authErrorDiagnostics.AUTH_C0061({ message: "Auth `database` must be a Better Auth adapter, such as `authDatabase()`. `true` and `{ name }` do not create storage, so users and sessions would stay in memory." });
|
|
807
808
|
if (isAuthSecondaryStoragePlacement(secondaryStorage)) throw authErrorDiagnostics.AUTH_C0062({ message: "Auth `secondaryStorage` must be a Better Auth adapter. `true` and `{ store }` do not create storage." });
|
|
808
809
|
const memory = database === "memory";
|
|
@@ -830,8 +831,10 @@ function stripViteHubOptions(definition, options, environment) {
|
|
|
830
831
|
const membersGate = members.length ? createMembersGate(members, admins, declaredPlugins) : void 0;
|
|
831
832
|
const adminsPlugin = admins.length ? createAdminsPlugin(admins, declaredPlugins) : void 0;
|
|
832
833
|
const adminClaimPlugin = adminClaim ? createAdminClaimPlugin(adminClaim, declaredPlugins) : void 0;
|
|
834
|
+
const accountDeletion = deleteAccount ? createDeleteAccount(deleteAccount, definition === definitionForApp ? getAuthApp() : void 0) : void 0;
|
|
833
835
|
const plugins = [
|
|
834
836
|
...declaredPlugins,
|
|
837
|
+
...accountDeletion ? [accountDeletion.plugin] : [],
|
|
835
838
|
...impersonation ? [createImpersonationPlugin()] : [],
|
|
836
839
|
...adminsPlugin ? [adminsPlugin] : [],
|
|
837
840
|
...adminClaimPlugin ? [adminClaimPlugin] : [],
|
|
@@ -852,6 +855,10 @@ function stripViteHubOptions(definition, options, environment) {
|
|
|
852
855
|
...rest,
|
|
853
856
|
...storage,
|
|
854
857
|
...sessionRefresh,
|
|
858
|
+
...accountDeletion ? { user: {
|
|
859
|
+
...rest.user,
|
|
860
|
+
deleteUser: accountDeletion.deleteUser
|
|
861
|
+
} } : {},
|
|
855
862
|
...membersGate ? { socialProviders: withMemberScopes(members, rest.socialProviders) } : {},
|
|
856
863
|
...adminClaimPlugin ? { verification: {
|
|
857
864
|
...rest.verification,
|
|
@@ -1100,8 +1107,8 @@ function envResolverFor(definition) {
|
|
|
1100
1107
|
return getAuthRuntimeState().envResolvers?.get(definition) ?? getAuthRuntimeState().envResolver;
|
|
1101
1108
|
}
|
|
1102
1109
|
function resolveDefaultDefinition() {
|
|
1103
|
-
if (!
|
|
1104
|
-
return
|
|
1110
|
+
if (!definitionForApp) throw authErrorDiagnostics.AUTH_R0005({ message: "[vitehub] No Auth Definition was discovered. Add `server/auth.ts` or `server.auth.ts`." });
|
|
1111
|
+
return definitionForApp;
|
|
1105
1112
|
}
|
|
1106
1113
|
function createBetterAuthOptions(definition) {
|
|
1107
1114
|
return resolveAuthOptions(definition, { env: envResolverFor(definition) }).providerOptions;
|
|
@@ -1165,4 +1172,4 @@ function authForRequest(request, event, definition = resolveDefaultDefinition())
|
|
|
1165
1172
|
}));
|
|
1166
1173
|
}
|
|
1167
1174
|
//#endregion
|
|
1168
|
-
export { requestProvider as a, resolveAuthOptions as c,
|
|
1175
|
+
export { requestProvider as a, resolveAuthOptions as c, setRequestClientAddress as d, withClientAddress as f, getAuthForDefinition as i, trustsProxyHeaders as l, forwardedRequestOrigin as m, createBetterAuthOptions as n, resolveDefaultDefinition as o, runWithAuthEvent as p, envResolverFor as r, withSessionMarker as s, authForRequest as t, eventClientAddress as u };
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
2
|
import { n as adminClaimVariable, r as createAdminClaimCode, t as adminClaimHash } from "./admin-claim-code-CDipqeAU.js";
|
|
3
3
|
//#region src/cli.ts
|
|
4
4
|
const usage = "vitehub auth events --url <auth-base-url> [--type <type>] [--user <id>] [--actor <actor>] [--from <ISO>] [--to <ISO>] [--cursor <cursor>] [--limit <1-200>] [--aggregate]";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as AuthConsoleActivity, K as AuthConsoleActivityQuery, Nt as AuthEventStore, X as AuthConsoleDescription, _t as AuthConsoleSession, at as AuthConsoleHostUserInput, bt as AuthConsoleUserDetail, ct as AuthConsoleMutation, dt as AuthConsoleOrganizationDetail, et as AuthConsoleField, ft as AuthConsoleOverview, ht as AuthConsoleQuery, it as AuthConsoleHostSession, lt as AuthConsoleOptions, q as AuthConsoleAgent, rt as AuthConsoleHostOptions, st as AuthConsoleList, ut as AuthConsoleOrganization, vt as AuthConsoleSessionUser, yt as AuthConsoleUser } from "./types-CruflEFI.js";
|
|
2
2
|
import { Result } from "@vite-hub/runtime";
|
|
3
3
|
import { AuthContext, BetterAuthOptions, DBAdapter } from "better-auth";
|
|
4
4
|
//#region src/console-runtime.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as adminClaimVariable } from "./admin-claim-code-CDipqeAU.js";
|
|
2
|
-
import { m as adminsVariable, p as adminsPluginId, r as membersVariable, s as accessPolicyPluginId, u as adminClaimPluginId } from "./members-
|
|
2
|
+
import { m as adminsVariable, p as adminsPluginId, r as membersVariable, s as accessPolicyPluginId, u as adminClaimPluginId } from "./members-DdlsS8kJ.js";
|
|
3
3
|
import { r as isAuthProcessMemoryDatabase } from "./runtime-state-ojQCzKOc.js";
|
|
4
|
-
import { r as parseAuthEventList } from "./events-
|
|
4
|
+
import { r as parseAuthEventList } from "./events-DCfuicoo.js";
|
|
5
5
|
import { n as authConsoleEventGroups, t as authConsoleActionNames } from "./console-types-CmmnKGMx.js";
|
|
6
6
|
import { defineErrors } from "@vite-hub/runtime";
|
|
7
7
|
import { createAuthEndpoint } from "better-auth/api";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { i as describeAuthConsoleFields, n as AuthConsoleErrorCode, r as createAuthConsole, t as AuthConsole } from "./console-runtime-
|
|
1
|
+
import { $ as AuthConsoleEventUser, Ct as authConsoleEventGroups, G as AuthConsoleActivity, J as AuthConsoleCapability, K as AuthConsoleActivityQuery, Q as AuthConsoleEventGroup, St as authConsoleActionNames, W as AuthConsoleAction, X as AuthConsoleDescription, Y as AuthConsoleColumn, Z as AuthConsoleEvent, _t as AuthConsoleSession, at as AuthConsoleHostUserInput, bt as AuthConsoleUserDetail, ct as AuthConsoleMutation, dt as AuthConsoleOrganizationDetail, et as AuthConsoleField, ft as AuthConsoleOverview, gt as AuthConsoleRoles, ht as AuthConsoleQuery, it as AuthConsoleHostSession, lt as AuthConsoleOptions, mt as AuthConsolePolicy, nt as AuthConsoleFieldType, ot as AuthConsoleImpersonation, pt as AuthConsolePage, q as AuthConsoleAgent, rt as AuthConsoleHostOptions, st as AuthConsoleList, tt as AuthConsoleFieldPolicy, ut as AuthConsoleOrganization, vt as AuthConsoleSessionUser, xt as AuthConsoleValue, yt as AuthConsoleUser } from "./types-CruflEFI.js";
|
|
2
|
+
import { i as describeAuthConsoleFields, n as AuthConsoleErrorCode, r as createAuthConsole, t as AuthConsole } from "./console-runtime-D2ai-Et5.js";
|
|
3
3
|
export { AuthConsole, type AuthConsoleAction, type AuthConsoleActivity, type AuthConsoleActivityQuery, type AuthConsoleAgent, type AuthConsoleCapability, type AuthConsoleColumn, type AuthConsoleDescription, AuthConsoleErrorCode, type AuthConsoleEvent, type AuthConsoleEventGroup, type AuthConsoleEventUser, type AuthConsoleField, type AuthConsoleFieldPolicy, type AuthConsoleFieldType, type AuthConsoleHostOptions, type AuthConsoleHostSession, type AuthConsoleHostUserInput, type AuthConsoleImpersonation, type AuthConsoleList, type AuthConsoleMutation, type AuthConsoleOptions, type AuthConsoleOrganization, type AuthConsoleOrganizationDetail, type AuthConsoleOverview, type AuthConsolePage, type AuthConsolePolicy, type AuthConsoleQuery, type AuthConsoleRoles, type AuthConsoleSession, type AuthConsoleSessionUser, type AuthConsoleUser, type AuthConsoleUserDetail, type AuthConsoleValue, type authConsoleActionNames, type authConsoleEventGroups, createAuthConsole, describeAuthConsoleFields };
|
package/dist/console-runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as describeAuthConsoleFields, t as createAuthConsole } from "./console-runtime-
|
|
1
|
+
import { n as describeAuthConsoleFields, t as createAuthConsole } from "./console-runtime-_LrpyCYY.js";
|
|
2
2
|
export { createAuthConsole, describeAuthConsoleFields };
|
package/dist/console.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as AuthConsoleEventUser, Ct as authConsoleEventGroups, G as AuthConsoleActivity, J as AuthConsoleCapability, K as AuthConsoleActivityQuery, Q as AuthConsoleEventGroup, St as authConsoleActionNames, W as AuthConsoleAction, X as AuthConsoleDescription, Y as AuthConsoleColumn, Z as AuthConsoleEvent, _t as AuthConsoleSession, at as AuthConsoleHostUserInput, bt as AuthConsoleUserDetail, ct as AuthConsoleMutation, dt as AuthConsoleOrganizationDetail, et as AuthConsoleField, ft as AuthConsoleOverview, gt as AuthConsoleRoles, ht as AuthConsoleQuery, it as AuthConsoleHostSession, lt as AuthConsoleOptions, mt as AuthConsolePolicy, nt as AuthConsoleFieldType, ot as AuthConsoleImpersonation, pt as AuthConsolePage, q as AuthConsoleAgent, rt as AuthConsoleHostOptions, st as AuthConsoleList, tt as AuthConsoleFieldPolicy, ut as AuthConsoleOrganization, vt as AuthConsoleSessionUser, xt as AuthConsoleValue, yt as AuthConsoleUser } from "./types-CruflEFI.js";
|
|
2
2
|
//#region ../internal/src/console.d.ts
|
|
3
3
|
/** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
|
|
4
4
|
interface ViteHubConsoleDefinitionCatalogView {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
2
|
//#region src/database-options.ts
|
|
3
3
|
/** Reads the adapter's target without loading Better Auth or the Database runtime. */
|
|
4
4
|
function authDatabaseName(database) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as authDatabaseSchemaError } from "./database-options-
|
|
1
|
+
import { a as authDatabaseSchemaError } from "./database-options-DpOVjUti.js";
|
|
2
2
|
import { getAuthTables } from "better-auth/db";
|
|
3
3
|
//#region src/database-schema-options.ts
|
|
4
4
|
/** Better Auth reads each table by its key and each column by its field key, so the options must not rename them. */
|
package/dist/database.d.ts
CHANGED
package/dist/database.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { a as authDatabaseSchemaError, t as assertAuthDatabaseIdStrategy } from "./database-options-
|
|
3
|
-
import { t as assertAuthDatabaseNames } from "./database-schema-options-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
|
+
import { a as authDatabaseSchemaError, t as assertAuthDatabaseIdStrategy } from "./database-options-DpOVjUti.js";
|
|
3
|
+
import { t as assertAuthDatabaseNames } from "./database-schema-options-Sk-1Bvyu.js";
|
|
4
4
|
import { getAuthTables } from "better-auth/db";
|
|
5
5
|
import { getTableColumns, is, isTable } from "drizzle-orm";
|
|
6
6
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|