@vite-hub/auth 0.8.0 → 0.9.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.
Files changed (70) hide show
  1. package/README.md +1 -1
  2. package/dist/{abilities-IOwpkcz4.d.ts → abilities-6LE7VSdN.d.ts} +1 -1
  3. package/dist/abilities.d.ts +1 -1
  4. package/dist/{ability-error-DgR91Jwc.js → ability-error-Ccm5Iy4F.js} +1 -1
  5. package/dist/{access-pages-C69nwa99.js → access-pages-lQGfRvfL.js} +1 -4
  6. package/dist/{admin-claim-code-C3X_U43x.js → admin-claim-code-CMa0eRRm.js} +0 -1
  7. package/dist/agent.js +3 -3
  8. package/dist/{application-path-zKi7NrvK.js → application-path-LMc_ptL9.js} +0 -2
  9. package/dist/{auth-instance-WeEK1zDd.js → auth-instance-0PTsOttV.js} +10 -48
  10. package/dist/bun-sqlite.d.ts +0 -2
  11. package/dist/cli.js +2 -2
  12. package/dist/{client-extension-BgUlm6hy.d.ts → client-extension-BVBVUqa1.d.ts} +1 -1
  13. package/dist/{console-runtime-Dk3j4Jmz.js → console-runtime-BlOx9hWC.js} +3 -19
  14. package/dist/{console-runtime-C71weVrt.d.ts → console-runtime-D2FUATXQ.d.ts} +1 -1
  15. package/dist/console-runtime.d.ts +2 -2
  16. package/dist/console-runtime.js +1 -1
  17. package/dist/console.d.ts +1 -1
  18. package/dist/{database-options-Cms7BI3c.js → database-options-CPhnGap9.js} +1 -1
  19. package/dist/{database-schema-options-IlHEeUBK.js → database-schema-options-BQyynyhw.js} +1 -1
  20. package/dist/database.d.ts +1 -1
  21. package/dist/database.js +15 -9
  22. package/dist/{definition-EpeI5LUG.js → definition-CvmvHaQT.js} +4 -12
  23. package/dist/{error-diagnostics-DZHuHXPP.js → error-diagnostics-BpQy1iIO.js} +2 -3
  24. package/dist/{events-Cm7Iwq47.js → events-aP_Rz_gx.js} +1 -1
  25. package/dist/{extension-mCx4TrsO.js → extension-B35v_o1u.js} +1 -1
  26. package/dist/{extension-BWmjJhoN.d.ts → extension-C2giF7w2.d.ts} +1 -1
  27. package/dist/forward.d.ts +0 -5
  28. package/dist/forward.js +1 -1
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +3 -3
  31. package/dist/internal/server.d.ts +2 -2
  32. package/dist/internal/server.js +4 -4
  33. package/dist/{mcp-config-Bbr8kQxm.js → mcp-config-DYlTXmr6.js} +1 -1
  34. package/dist/{mcp-token-BleQZK6H.js → mcp-token-i-8NMulH.js} +3 -4
  35. package/dist/mcp.d.ts +0 -5
  36. package/dist/mcp.js +2 -4
  37. package/dist/{members-7OMdqha_.js → members-USm08YwK.js} +4 -6
  38. package/dist/nuxt.d.ts +1 -1
  39. package/dist/nuxt.js +3 -55
  40. package/dist/{own-access-CGiai2L3.d.ts → own-access-B7VRd92K.d.ts} +1 -1
  41. package/dist/presets.js +1 -1
  42. package/dist/{request-Dpq7GO8B.js → request-CdlcvqVc.js} +0 -1
  43. package/dist/runtime/console.d.ts +1 -1
  44. package/dist/runtime/console.js +2 -2
  45. package/dist/runtime/empty-abilities.d.ts +1 -1
  46. package/dist/runtime/empty-client.d.ts +1 -1
  47. package/dist/runtime/empty-definition.d.ts +1 -1
  48. package/dist/runtime/server.d.ts +3 -3
  49. package/dist/runtime/server.js +4 -4
  50. package/dist/runtime/vue-nuxt.js +2 -18
  51. package/dist/schema.d.ts +1 -4
  52. package/dist/schema.js +19 -3
  53. package/dist/{server-DyP1v-sZ.d.ts → server-4_EXgXFn.d.ts} +4 -6
  54. package/dist/{server-5t-HA7I1.js → server-CZR2dVVp.js} +13 -47
  55. package/dist/{server-mmp8EfcE.d.ts → server-DAIBBKbR.d.ts} +3 -3
  56. package/dist/server.d.ts +1 -1
  57. package/dist/server.js +3 -3
  58. package/dist/{session-cookies-BNtY3hMp.js → session-cookies-CfXdF1yd.js} +3 -19
  59. package/dist/{set-cookie-Bva-P-_C.js → set-cookie-BYZslovs.js} +1 -1
  60. package/dist/{table-specs-Bm7QJCbu.js → table-specs-Cvjc_Ccs.js} +28 -2
  61. package/dist/{table-specs-BxKeFD_y.d.ts → table-specs-VYAy_jJ7.d.ts} +0 -2
  62. package/dist/test.d.ts +1 -1
  63. package/dist/test.js +2 -2
  64. package/dist/{types-CnO5bHEF.d.ts → types-DakualFJ.d.ts} +1 -3
  65. package/dist/{vite-7I1bJvqA.js → vite-DVvWaN3D.js} +21 -71
  66. package/dist/vite.d.ts +3 -5
  67. package/dist/vite.js +1 -1
  68. package/dist/vue.d.ts +3 -34
  69. package/dist/vue.js +4 -65
  70. package/package.json +9 -8
@@ -1,19 +1,19 @@
1
- import { t as createAuthConsole } from "./console-runtime-Dk3j4Jmz.js";
1
+ import { t as createAuthConsole } from "./console-runtime-BlOx9hWC.js";
2
2
  import { t as isRecord } from "./object-CAK6UYR5.js";
3
- import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-zKi7NrvK.js";
4
- import { o as normalizeAuthBasePath } from "./access-pages-C69nwa99.js";
3
+ import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-LMc_ptL9.js";
4
+ import { o as normalizeAuthBasePath } from "./access-pages-lQGfRvfL.js";
5
5
  import { t as hasRole } from "./roles-BGi8CyBG.js";
6
- import { n as authRequestEvent, r as unwrapAuthRequest } from "./request-Dpq7GO8B.js";
7
- import { a as clientRequestOrigin, r as mcpOAuthResources, t as isJwsToken } from "./mcp-config-Bbr8kQxm.js";
8
- import { _ as setAuthResponseOutcome, a as getAuthForDefinition, c as withSessionMarker, d as withEndpointRateLimits, f as eventClientAddress, g as setAuthOutcome, h as runWithAuthEvent, l as resolveAuthOptions, m as withClientAddress, n as createBetterAuthOptions, o as requestProvider, p as setRequestClientAddress, r as envResolverFor, s as resolveDefaultDefinition, t as authForRequest, u as trustsProxyHeaders } from "./auth-instance-WeEK1zDd.js";
9
- import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-BNtY3hMp.js";
6
+ import { n as authRequestEvent, r as unwrapAuthRequest } from "./request-CdlcvqVc.js";
7
+ import { a as clientRequestOrigin, r as mcpOAuthResources, t as isJwsToken } from "./mcp-config-DYlTXmr6.js";
8
+ import { _ as setAuthResponseOutcome, a as getAuthForDefinition, c as withSessionMarker, d as withEndpointRateLimits, f as eventClientAddress, g as setAuthOutcome, h as runWithAuthEvent, l as resolveAuthOptions, m as withClientAddress, n as createBetterAuthOptions, o as requestProvider, p as setRequestClientAddress, r as envResolverFor, s as resolveDefaultDefinition, t as authForRequest, u as trustsProxyHeaders } from "./auth-instance-0PTsOttV.js";
9
+ import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-CfXdF1yd.js";
10
10
  import { t as getAuthRuntimeState } from "./runtime-state-C0Rd1W4m.js";
11
- import { t as readSetCookies } from "./set-cookie-Bva-P-_C.js";
11
+ import { t as readSetCookies } from "./set-cookie-BYZslovs.js";
12
12
  import { createAuthAccessRouteMatcher } from "./runtime/server.js";
13
- import { n as checkAbility, t as AbilityError } from "./ability-error-DgR91Jwc.js";
14
- import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-Cm7Iwq47.js";
15
- import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
16
- import { g as findAccessPolicyPlugin, i as notMemberError } from "./members-7OMdqha_.js";
13
+ import { n as checkAbility, t as AbilityError } from "./ability-error-Ccm5Iy4F.js";
14
+ import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-aP_Rz_gx.js";
15
+ import { t as authErrorDiagnostics } from "./error-diagnostics-BpQy1iIO.js";
16
+ import { g as findAccessPolicyPlugin, i as notMemberError } from "./members-USm08YwK.js";
17
17
  import { defineErrors, toResultError } from "@vite-hub/runtime";
18
18
  import { HTTPError } from "nitro/h3";
19
19
  import { isRequest } from "@vite-hub/runtime/internal/response";
@@ -31,7 +31,6 @@ const callerErrors = /*#__PURE__*/ defineErrors({
31
31
  });
32
32
  const signedOutError = () => callerErrors.AUTH_SIGNED_OUT();
33
33
  // src/internal/server.ts
34
- /** The provider sign-in of `access`, which returns to `afterSignIn`. A sign-in page has none: the page signs in. */
35
34
  function providerSignIn(options) {
36
35
  const access = options.access;
37
36
  const signIn = access?.signIn;
@@ -40,10 +39,6 @@ function providerSignIn(options) {
40
39
  callbackURL: `${resolveAuthMountPath("/")}${(appPath(access?.afterSignIn ?? "/") ?? "/").slice(1)}`
41
40
  } : void 0;
42
41
  }
43
- /**
44
- * The Headers init of a host request. A Headers-like object without `Symbol.iterator`, from another
45
- * Fetch implementation, gives its fields through `entries()`, not through its own properties.
46
- */
47
42
  function headersInit(headers) {
48
43
  const value = headers;
49
44
  if (typeof value !== "object" || value === null || typeof Reflect.get(value, Symbol.iterator) === "function") return headers;
@@ -94,10 +89,6 @@ function handleAuthRequest(definition, input, event = authRequestEvent(input)) {
94
89
  return response;
95
90
  });
96
91
  }
97
- /**
98
- * With a provider in `access.signIn`, the Auth route also answers `GET <basePath>/sign-in` and `GET <basePath>/sign-out`, so a link
99
- * can sign in or out and come back to `?redirect=`. Better Auth has no GET endpoint at these paths.
100
- */
101
92
  function handleSignInRoute(auth, options, request, address) {
102
93
  const signIn = providerSignIn(options);
103
94
  if (!signIn || request.method !== "GET") return;
@@ -150,10 +141,6 @@ function textResponse(text, status) {
150
141
  status
151
142
  });
152
143
  }
153
- /**
154
- * A path of this app, such as `/docs?tab=a`, URL-encoded for a `Location` header, or `null` for another value.
155
- * `//host` and `/\\host` open another site, so they are not paths.
156
- */
157
144
  function appPath(value) {
158
145
  if (!value.startsWith("/") || /^\/[/\\]/.test(value) || /[\u0000-\u001F\u007F]/.test(value)) return null;
159
146
  const url = new URL(value, "http://app.invalid");
@@ -252,10 +239,6 @@ function refusal(response, code) {
252
239
  refusalCodes.set(response, code);
253
240
  return response;
254
241
  }
255
- /**
256
- * A refusal in H3's JSON error format, the same body that `requireAuth()` and H3 errors send. The phrase also goes on
257
- * the status line.
258
- */
259
242
  function createRefusalResponse(code) {
260
243
  const status = code === "SIGNED_OUT" ? 401 : 403;
261
244
  const statusText = code === "SIGNED_OUT" ? "Unauthorized" : "Forbidden";
@@ -269,10 +252,6 @@ function createRefusalResponse(code) {
269
252
  statusText
270
253
  }), code);
271
254
  }
272
- /**
273
- * A text 403 for an HTML request. The phrase on the status line is also the `statusText` of the error that the inline
274
- * guards throw.
275
- */
276
255
  function createTextRefusalResponse(text, code) {
277
256
  return refusal(new Response(text, {
278
257
  headers: { "content-type": "text/plain; charset=utf-8" },
@@ -280,7 +259,6 @@ function createTextRefusalResponse(text, code) {
280
259
  statusText: "Forbidden"
281
260
  }), code);
282
261
  }
283
- /** Better Auth's refusal of the credentials of the request, such as an invalid key of the API Key plugin. */
284
262
  function createProviderRefusalResponse(provider) {
285
263
  const response = authenticationRefusalResponse(provider);
286
264
  if (provider.code) refusalCodes.set(response, provider.code);
@@ -385,10 +363,6 @@ function logRefusal(input, response) {
385
363
  });
386
364
  }
387
365
  const nativeResponseClone = Object.getOwnPropertyDescriptor(Response.prototype, "clone")?.value;
388
- /**
389
- * A Response of this runtime with an own `then` would be assimilated as a thenable by the host that awaits it.
390
- * Send a native clone instead, so the rejection still reaches the client as a Response.
391
- */
392
366
  function sendableRuntimeResponse(value, request) {
393
367
  if (!Object.prototype.hasOwnProperty.call(value, "then")) return value;
394
368
  try {
@@ -397,9 +371,6 @@ function sendableRuntimeResponse(value, request) {
397
371
  return createForbiddenResponse(request);
398
372
  }
399
373
  }
400
- /**
401
- * Only `true` grants access. A Response of this runtime is sent as the rejection. Every other value gets `deny()`, `403` by default.
402
- */
403
374
  async function runAccessAuthorize(authorize, context, deny = () => createForbiddenResponse(context.request)) {
404
375
  const result = authorize(context);
405
376
  if (isRuntimeResponse(result)) return { response: sendableRuntimeResponse(result, context.request) };
@@ -504,11 +475,6 @@ function withAuthorization(authorize, handler, definition) {
504
475
  return sendSessionCookies(input, await handler(input, authorization));
505
476
  };
506
477
  }
507
- /**
508
- * The `HTTPError` that an inline guard throws for a rejection `Response`. It keeps the status and headers, such as
509
- * `location` and `set-cookie` of a sign-in redirect. JSON object fields stay in the error body; other JSON values
510
- * become `data`. Text becomes the error message, with H3's JSON content type.
511
- */
512
478
  async function rejectionError(response, code = refusalCodes.get(response)) {
513
479
  const headers = new Headers(response.headers);
514
480
  headers.delete("content-length");
@@ -591,7 +557,7 @@ async function readCaller(event, definition) {
591
557
  const auth = authForRequest(request, authRequestEvent(event), definition);
592
558
  const { options } = await auth.$context;
593
559
  if (isJwsToken(token) && mcpOAuthResources(options.plugins).length) {
594
- const { verifyAppAccessToken } = await import("./mcp-token-BleQZK6H.js").then((n) => n.a);
560
+ const { verifyAppAccessToken } = await import("./mcp-token-i-8NMulH.js").then((n) => n.a);
595
561
  const url = new URL(request.url);
596
562
  const [error, caller] = await verifyAppAccessToken(token, clientRequestOrigin(request, trustsProxyHeaders(options)), url, auth);
597
563
  if (error) return [error, void 0];
@@ -1,6 +1,6 @@
1
- import "./extension-BWmjJhoN.js";
2
- import "./own-access-CGiai2L3.js";
3
- import { E as AuthRequestInput, U as ResolvedAuthAccessRoute, _ as AuthDefinition } from "./types-CnO5bHEF.js";
1
+ import "./extension-C2giF7w2.js";
2
+ import "./own-access-B7VRd92K.js";
3
+ import { E as AuthRequestInput, U as ResolvedAuthAccessRoute, _ as AuthDefinition } from "./types-DakualFJ.js";
4
4
  import { AccessAuthorizationContext, ViteHubContext } from "@vite-hub/runtime";
5
5
  type AuthRuntimeEnvResolver = (event?: ViteHubContext) => Record<string, unknown>;
6
6
  type AuthAccessIdentityResolver = (request: Request, event: AuthRequestInput, hasSession: boolean) => Promise<AccessAuthorizationContext<unknown, false>["user"] | Response | undefined>;
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { A as withAuthorization, B as AuthCallerUser, C as requireAuthorization, D as useAuth, I as AuthCaller, L as AuthCallerError, O as withAnonymousAuthorization, R as AuthCallerErrorCode, T as signOut, V as AuthMemberErrorCode, _ as handleAuth, a as authMiddleware, b as requireAbility, c as checkAuthMember, f as createAuthHandler, g as getAuthEvents, h as getAuthConsoleForRequest, k as withAuth, o as authRoute, r as aggregateAuthEvents, s as can, t as AuthEventReadErrorCode, w as requireCaller, x as requireAuth, y as listAuthEvents, z as AuthCallerResult } from "./server-DyP1v-sZ.js";
2
+ import { A as withAuthorization, B as AuthCallerUser, C as requireAuthorization, D as useAuth, I as AuthCaller, L as AuthCallerError, O as withAnonymousAuthorization, R as AuthCallerErrorCode, T as signOut, V as AuthMemberErrorCode, _ as handleAuth, a as authMiddleware, b as requireAbility, c as checkAuthMember, f as createAuthHandler, g as getAuthEvents, h as getAuthConsoleForRequest, k as withAuth, o as authRoute, r as aggregateAuthEvents, s as can, t as AuthEventReadErrorCode, w as requireCaller, x as requireAuth, y as listAuthEvents, z as AuthCallerResult } from "./server-4_EXgXFn.js";
3
3
  import { a as McpTokenInvalidData, o as McpTokenInvalidError, s as McpTokenInvalidReason } from "./mcp-token-CxpopXmK.js";
4
4
  import { n as AbilityErrorData, t as AbilityError } from "./ability-error-C1c30O6E.js";
5
5
  import { AuthContext } from "better-auth";
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
- import { g as findAccessPolicyPlugin } from "./members-7OMdqha_.js";
2
- import { t as AbilityError } from "./ability-error-DgR91Jwc.js";
3
- import { C as signOut, D as withAuth, E as withAnonymousAuthorization, O as withAuthorization, S as requireCaller, T as useAuth, _ as listAuthEvents, a as can, h as handleAuth, i as authRoute, m as getAuthEvents, o as checkAuthMember, p as getAuthConsoleForRequest, r as authMiddleware, t as aggregateAuthEvents, u as createAuthHandler, v as requireAbility, x as requireAuthorization, y as requireAuth } from "./server-5t-HA7I1.js";
1
+ import { g as findAccessPolicyPlugin } from "./members-USm08YwK.js";
2
+ import { t as AbilityError } from "./ability-error-Ccm5Iy4F.js";
3
+ import { C as signOut, D as withAuth, E as withAnonymousAuthorization, O as withAuthorization, S as requireCaller, T as useAuth, _ as listAuthEvents, a as can, h as handleAuth, i as authRoute, m as getAuthEvents, o as checkAuthMember, p as getAuthConsoleForRequest, r as authMiddleware, t as aggregateAuthEvents, u as createAuthHandler, v as requireAbility, x as requireAuthorization, y as requireAuth } from "./server-CZR2dVVp.js";
4
4
  // src/server.ts
5
5
  /** Whether the resolved Auth context applies `VITEHUB_MEMBERS`. */
6
6
  function hasAuthMembers(context) {
@@ -1,7 +1,7 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
2
- import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-Bva-P-_C.js";
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-BpQy1iIO.js";
2
+ import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-BYZslovs.js";
3
3
  import { t as isRecord } from "./object-CAK6UYR5.js";
4
- import { n as authRequestEvent } from "./request-Dpq7GO8B.js";
4
+ import { n as authRequestEvent } from "./request-CdlcvqVc.js";
5
5
  import { HTTPError } from "nitro/h3";
6
6
  import { isResponse } from "@vite-hub/runtime/internal/response";
7
7
  import { getStandardContext } from "@vite-hub/runtime/internal/h3";
@@ -76,7 +76,6 @@ function readRecordProperty(value, property) {
76
76
  const nested = readProperty(value, property);
77
77
  return isRecord(nested) ? nested : void 0;
78
78
  }
79
- /** Reads the `{ headers, response }` result of `getSession({ returnHeaders: true })`. */
80
79
  function resolveAuthenticationSessionRead(value) {
81
80
  if (!isRecord(value) || !("response" in value)) return;
82
81
  const { headers, response } = value;
@@ -116,10 +115,6 @@ function isUnauthorizedApiError(error) {
116
115
  return false;
117
116
  }
118
117
  }
119
- /**
120
- * The refusal of a Better Auth `APIError` with a 4xx status, and all its headers. A `before` hook can pass headers to
121
- * the error, and better-call keeps the headers that the endpoint set before under its own key. Both reach the client.
122
- */
123
118
  function readClientApiError(error) {
124
119
  if (typeof error !== "object" || error === null) return;
125
120
  try {
@@ -231,12 +226,6 @@ function withSessionCookies(response, cookies) {
231
226
  sent.headers.set("cache-control", cacheControl);
232
227
  return sent;
233
228
  }
234
- /**
235
- * Writes the Cache-Control of a response with session cookies in the prepared response. H3 sends the prepared value
236
- * over the one of the route, so the policy starts from the value that the response would have without the guards:
237
- * a prepared value that someone else wrote, else the value of the route. `route` is `undefined` when no guard has
238
- * seen the response yet.
239
- */
240
229
  function writeCacheControl(headers, prepared, route) {
241
230
  const current = headers.get("cache-control");
242
231
  const base = prepared.cacheControl && current === prepared.cacheControl.written ? prepared.cacheControl.replaced : current;
@@ -248,10 +237,6 @@ function writeCacheControl(headers, prepared, route) {
248
237
  written
249
238
  };
250
239
  }
251
- /**
252
- * Adds `private` to Cache-Control unless it already has `private` or `no-store`. The directives for the browser cache
253
- * stay, and `public` and `s-maxage`, which let a shared cache store the response, go.
254
- */
255
240
  function privateCacheControl(value) {
256
241
  const directives = (value ?? "").split(",").map((directive) => directive.trim()).filter(Boolean);
257
242
  if (directives.some((directive) => /^(?:private|no-store)\b/i.test(directive))) return value ?? "";
@@ -261,7 +246,6 @@ function cookieName(setCookie) {
261
246
  const end = setCookie.search(/[=;]/);
262
247
  return (end < 0 ? setCookie : setCookie.slice(0, end)).trim();
263
248
  }
264
- /** Removes these exact `Set-Cookie` values, once each, and keeps the others in their order. */
265
249
  function removeSetCookies(headers, values) {
266
250
  if (values.length === 0) return;
267
251
  const remove = [...values];
@@ -1,4 +1,4 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-BpQy1iIO.js";
2
2
  import { ViteHubError, isViteHubError } from "@vite-hub/runtime";
3
3
  // src/errors.ts
4
4
  function invalidAuthenticationErrorOptions() {
@@ -1,4 +1,4 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-BpQy1iIO.js";
2
2
  /**
3
3
  * The Better Auth core tables, with the tables of the plugins that ViteHub ships: `jwt()` and `oauthProvider()` of
4
4
  * `mcpOAuth()`, `organization()`, `passkey()` from `@better-auth/passkey`, and the table of Better Auth's limiter. The
@@ -770,4 +770,30 @@ function authSchemaError(detail) {
770
770
  function authSqlName(name) {
771
771
  return name.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").toLowerCase();
772
772
  }
773
- export { resolveAuthTableSpecs as i, authSqlName as n, authTableSpecs as r, authPluginSchemas as t };
773
+ const plural = (model) => model.endsWith("s") ? model : `${model}s`;
774
+ /**
775
+ * The relations that Better Auth's relations-v2 adapter reads for `advanced.database.joins`, one for each pair of tables.
776
+ * Like the adapter, a join from `model` to `target` uses the foreign key of `target` to `model`, or the foreign key of
777
+ * `model` to `target` when `target` has none, and has no relation when there is more than one. The relation is `one` and
778
+ * named after `target` in the singular when it joins on an `id` or a unique column, and otherwise `many` and plural.
779
+ */
780
+ function authJoinRelations(tables) {
781
+ const foreignKeys = (model, target) => Object.entries(tables[model]?.fields ?? {}).filter(([, spec]) => spec.references?.model === target);
782
+ return Object.keys(tables).flatMap((model) => Object.keys(tables).flatMap((target) => {
783
+ const reverse = foreignKeys(target, model);
784
+ const [foreignKey, ...others] = reverse.length ? reverse : foreignKeys(model, target);
785
+ const reference = foreignKey?.[1].references;
786
+ if (!foreignKey || !reference || others.length) return [];
787
+ const [from, to] = reverse.length ? [reference.field, foreignKey[0]] : [foreignKey[0], reference.field];
788
+ const one = to === "id" || foreignKey[1].unique === true;
789
+ return [{
790
+ model,
791
+ key: one ? target : plural(target),
792
+ target,
793
+ many: !one,
794
+ from,
795
+ to
796
+ }];
797
+ }));
798
+ }
799
+ export { resolveAuthTableSpecs as a, authTableSpecs as i, authPluginSchemas as n, authSqlName as r, authJoinRelations as t };
@@ -797,9 +797,7 @@ type AuthSchemaPlugin = "admin" | "anonymous" | "apiKey" | "lastLoginMethod" | "
797
797
  /** The core Better Auth models. Each one takes `additionalFields`. */
798
798
  type AuthCoreModel = "user" | "session" | "account" | "verification";
799
799
  interface AuthPluginSchema {
800
- /** Columns that the plugin adds to tables of `authTableSpecs`. */
801
800
  fields?: Partial<Record<AuthTableName, Readonly<Record<string, AuthTableField>>>>;
802
- /** Tables that the plugin adds. */
803
801
  tables?: Readonly<Record<string, AuthTableSpec>>;
804
802
  }
805
803
  declare const pluginSchemas: {
package/dist/test.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as AuthDefinition } from "./types-CnO5bHEF.js";
1
+ import { _ as AuthDefinition } from "./types-DakualFJ.js";
2
2
  import { Session, User } from "better-auth";
3
3
  /** The user to sign in. Auth creates it when no user has this email. Other fields, such as `role`, go to the new user. */
4
4
  export interface SignInTestUser {
package/dist/test.js CHANGED
@@ -1,5 +1,5 @@
1
- import { s as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-WeEK1zDd.js";
2
- import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
1
+ import { s as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-0PTsOttV.js";
2
+ import { t as authErrorDiagnostics } from "./error-diagnostics-BpQy1iIO.js";
3
3
  import { testUtils } from "better-auth/plugins";
4
4
  // src/test.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { t as AuthPreset } from "./presets-C6AtiRdI.js";
2
- import { i as AuthSchemaOptions } from "./table-specs-BxKeFD_y.js";
2
+ import { i as AuthSchemaOptions } from "./table-specs-VYAy_jJ7.js";
3
3
  import { AccessAuthorizationContext, AccessAuthorize, AccessAuthorizeResult, AnonymousAccessAuthorizationContext, AnonymousAccessAuthorize, Duration } from "@vite-hub/runtime";
4
4
  import { ViteHubContext as ViteHubContext$1 } from "@vite-hub/runtime/internal/h3";
5
5
  import { Auth, BetterAuthOptions, DBAdapter, Session, User } from "better-auth";
@@ -374,7 +374,6 @@ declare const authConsoleActionNames: readonly AuthConsoleAction[];
374
374
  declare global {
375
375
  namespace ViteHub {
376
376
  interface AuthRuntimeEnv extends Record<string, unknown> {}
377
- /** Generated declarations set `definition` to the type of the app's Auth Definition. */
378
377
  interface AuthRegistry {}
379
378
  }
380
379
  }
@@ -445,7 +444,6 @@ type AuthAccessRoute = string | AuthAccessRouteConfiguration;
445
444
  type AuthAccessAuthorizationContext<TEvent = ViteHubContext$1> = AccessAuthorizationContext<TEvent, false>;
446
445
  type AuthAccessAuthorizeResult = AccessAuthorizeResult;
447
446
  type AuthAccessAuthorize<TEvent = ViteHubContext$1> = AccessAuthorize<TEvent, false>;
448
- /** The Session and user that the app's Auth Definition returns, with the fields of its plugins and `additionalFields`. */
449
447
  type RegisteredSession<TRegistry> = RegisteredAuth<TRegistry>["$Infer"]["Session"];
450
448
  type GuardSession<TSession> = TSession extends object ? Pick<TSession, Extract<keyof TSession, keyof Session>> & Partial<Omit<TSession, keyof Session>> : never;
451
449
  /**
@@ -1,12 +1,12 @@
1
1
  import { t as invariant } from "./invariant-Dj2R1eMr.js";
2
2
  import { t as createNitroServerKit } from "./nitro-kit-BumWIKa5.js";
3
3
  import { t as isRecord } from "./object-CAK6UYR5.js";
4
- import { r as resolveAccessRoutePath, t as accessRouteSyntaxError } from "./application-path-zKi7NrvK.js";
5
- import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
6
- import { n as assertAuthPages, o as normalizeAuthBasePath } from "./access-pages-C69nwa99.js";
7
- import { a as differentFieldAttributes, c as mergeFieldDeclarations, i as authExtensionKeys, n as assertUniquePluginIds, o as effectiveFieldAttributes, r as authCoreModels } from "./extension-mCx4TrsO.js";
8
- import { a as authDatabasePlacementError, n as authDatabaseAdditionalFieldsError, o as authDatabaseSchemaError, s as authMemoryDatabaseError, t as assertAuthDatabaseIdStrategy } from "./database-options-Cms7BI3c.js";
9
- import { i as resolveAuthTableSpecs, n as authSqlName } from "./table-specs-Bm7QJCbu.js";
4
+ import { r as resolveAccessRoutePath, t as accessRouteSyntaxError } from "./application-path-LMc_ptL9.js";
5
+ import { t as authErrorDiagnostics } from "./error-diagnostics-BpQy1iIO.js";
6
+ import { n as assertAuthPages, o as normalizeAuthBasePath } from "./access-pages-lQGfRvfL.js";
7
+ import { a as differentFieldAttributes, c as mergeFieldDeclarations, i as authExtensionKeys, n as assertUniquePluginIds, o as effectiveFieldAttributes, r as authCoreModels } from "./extension-B35v_o1u.js";
8
+ import { a as authDatabasePlacementError, n as authDatabaseAdditionalFieldsError, o as authDatabaseSchemaError, s as authMemoryDatabaseError, t as assertAuthDatabaseIdStrategy } from "./database-options-CPhnGap9.js";
9
+ import { a as resolveAuthTableSpecs, r as authSqlName, t as authJoinRelations } from "./table-specs-Cvjc_Ccs.js";
10
10
  import { n as resetAuth } from "./runtime-state-C0Rd1W4m.js";
11
11
  import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
12
12
  import { basename, dirname, join, parse, relative, resolve } from "node:path";
@@ -268,7 +268,6 @@ const methodOrder = [
268
268
  "GET",
269
269
  "HEAD"
270
270
  ];
271
- /** h3 applies the GET rules of a pattern to HEAD requests too. */
272
271
  function appliesTo(entry, method) {
273
272
  return !entry.method || entry.method === method || method === "HEAD" && entry.method === "GET";
274
273
  }
@@ -393,11 +392,6 @@ async function flattenPluginOptions(plugins) {
393
392
  return flattened;
394
393
  }
395
394
  // src/access-route-cache.ts
396
- /**
397
- * The rou3 pattern of the paths that the access middleware guards for a route. The middleware matches the path
398
- * literally, so the pattern escapes every character that rou3 reads as syntax. In rou3, `/**` also matches the path
399
- * itself.
400
- */
401
395
  function accessRoutePattern(route, baseURL) {
402
396
  const { path, recursive } = resolveAccessRoutePath(route, baseURL);
403
397
  const literal = path.replace(/[\\:(){}*?+]/g, "\\$&");
@@ -510,16 +504,11 @@ function objectProperties(object) {
510
504
  value: unwrapExpression(node.value)
511
505
  });
512
506
  }
513
- /** The value of a template literal without substitutions. */
514
507
  function staticTemplate(node) {
515
508
  if (node.expressions.length) return dynamic;
516
509
  return node.quasis[0]?.value.cooked ?? dynamic;
517
510
  }
518
511
  const escapePattern = /\\(u\{[^}]*\}?|u[\s\S]{0,4}|x[\s\S]{0,2}|0\d|[\s\S])/g;
519
- /**
520
- * True when a string literal has an escape that strict mode code rejects. The parser recovers from some bad escapes
521
- * and accepts legacy octal escapes, so the scanner checks them again.
522
- */
523
512
  function hasInvalidEscape(raw) {
524
513
  for (const [, escape = ""] of raw.matchAll(escapePattern)) if (escape.startsWith("u{")) {
525
514
  const code = escape.slice(2, -1);
@@ -797,7 +786,6 @@ function readAuthDatabaseImports(module) {
797
786
  }
798
787
  return names;
799
788
  }
800
- /** The plugin factories whose tables `authDatabase()` adds, by the module that exports them. */
801
789
  const authSchemaPluginImports = {
802
790
  "better-auth/plugins": {
803
791
  admin: "admin",
@@ -829,10 +817,6 @@ const typeScriptSources = {
829
817
  ".cjs": [".cts"]
830
818
  };
831
819
  const isFile = (file) => existsSync(file) && statSync(file).isFile();
832
- /**
833
- * The file of a relative import, resolved in the order Vite uses: the file itself, the TypeScript source of a `.js`
834
- * path, the path with each extension, then the `index` file of the folder.
835
- */
836
820
  function resolveLocalModule(importer, specifier) {
837
821
  const path = resolve(dirname(importer), specifier);
838
822
  if (isFile(path)) return path;
@@ -1100,9 +1084,6 @@ function readConfiguredPluginFields(definition, options, body, moduleOf, binding
1100
1084
  visit(unwrapExpression(start), options.type === "ArrowFunctionExpression" || options.type === "FunctionExpression" ? pluginFunctionScope(scope, options) : scope, readPlugin);
1101
1085
  return fields;
1102
1086
  }
1103
- /**
1104
- * The schema contributions reached from the registered plugins, including plugins returned by local helpers.
1105
- */
1106
1087
  function readDefinitionSchemaPlugins(definition, scan, options, body) {
1107
1088
  const plugins = [];
1108
1089
  const modules = /* @__PURE__ */ new Map([[definition.file, definition]]);
@@ -1173,7 +1154,6 @@ function readReturnedObject(callback) {
1173
1154
  const value = returned ? unwrapExpression(returned) : void 0;
1174
1155
  return value?.type === "ObjectExpression" ? value : void 0;
1175
1156
  }
1176
- /** The value of a top-level `const name = value`, exported or not. */
1177
1157
  function topLevelConstValue(module, name) {
1178
1158
  for (const statement of module.program.body) {
1179
1159
  const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
@@ -1181,11 +1161,6 @@ function topLevelConstValue(module, name) {
1181
1161
  for (const declarator of declaration.declarations) if (declarator.id.type === "Identifier" && declarator.id.name === name) return declarator.init ? unwrapExpression(declarator.init) : void 0;
1182
1162
  }
1183
1163
  }
1184
- /**
1185
- * The exported `defineAuth()` call: `export default defineAuth(...)`, or `export default auth` after a top-level
1186
- * `const auth: AuthDefinition<...> = defineAuth(...)`. A composite TypeScript project needs that annotation when it
1187
- * cannot write the inferred type of the Definition (TS7056), as with the Better Auth `apiKey()` plugin.
1188
- */
1189
1164
  function exportedDefineAuthCall(module) {
1190
1165
  const exported = defaultExportExpression(module);
1191
1166
  const call = exported?.type === "Identifier" ? topLevelConstValue(module, exported.name) : exported;
@@ -1234,7 +1209,6 @@ function readDefinitionObjectBody(file, scan) {
1234
1209
  }, options, returned)
1235
1210
  };
1236
1211
  }
1237
- /** Owned tables must have the same target in every request and in the build-time contribution. */
1238
1212
  function assertAuthDatabasePlacement(options, body, names) {
1239
1213
  const calls = [];
1240
1214
  walk(options, (node) => {
@@ -1332,7 +1306,6 @@ function readAuthAccessPublicConfig(body) {
1332
1306
  return route;
1333
1307
  });
1334
1308
  }
1335
- /** `access.signIn` and `access.afterSignIn`, which the Nuxt page guard reads at build time, like `basePath`. */
1336
1309
  function readAuthAccessSignInConfig(body) {
1337
1310
  const access = objectLiteral(readObjectPropertyValue(body, "access"));
1338
1311
  if (!access) return {};
@@ -1353,7 +1326,6 @@ function readAuthAccessSignInConfig(body) {
1353
1326
  }
1354
1327
  return resolved;
1355
1328
  }
1356
- /** The build reads only the first return of a callback, so access.pages in any other branch would go unguarded. */
1357
1329
  function assertOneReturnWithPages(options) {
1358
1330
  if (options.type !== "ArrowFunctionExpression" || options.body.type !== "BlockStatement") return;
1359
1331
  const returned = [];
@@ -1370,7 +1342,6 @@ function assertOneReturnWithPages(options) {
1370
1342
  };
1371
1343
  if (returned.length > 1 && returned.some(declaresPages)) throw authErrorDiagnostics.AUTH_PAGE_ROUTES_INVALID({ message: "A `defineAuth()` callback that sets access.pages must have one `return`, so that the build reads the same pages as every request." });
1372
1344
  }
1373
- /** `access.pages`, which the Nuxt module turns into route rules at build time, like `access.signIn`. */
1374
1345
  function readAuthAccessPagesConfig(body) {
1375
1346
  if (!hasObjectProperty(body, "access")) return {};
1376
1347
  const expression = readObjectPropertyValue(body, "access");
@@ -1387,7 +1358,6 @@ function readAuthAccessPagesConfig(body) {
1387
1358
  assertAuthPages(pages);
1388
1359
  return { pages };
1389
1360
  }
1390
- /** `components.prefix`, which the Nuxt module reads at build time to name `<AuthPermission>`, like `basePath`. */
1391
1361
  function readAuthComponentsConfig(body) {
1392
1362
  if (!hasObjectProperty(body, "components")) return;
1393
1363
  const components = objectLiteral(readObjectPropertyValue(body, "components"));
@@ -1397,7 +1367,6 @@ function readAuthComponentsConfig(body) {
1397
1367
  if (!prefix?.trim() || prefix !== prefix.trim()) throw authErrorDiagnostics.AUTH_COMPONENTS_INVALID();
1398
1368
  return { prefix };
1399
1369
  }
1400
- /** The `authDatabase()` call of the `database` option, or undefined for any other value. */
1401
1370
  function readAuthDatabaseCall(body, authDatabase) {
1402
1371
  const value = readObjectPropertyValue(body, "database");
1403
1372
  const expression = value && unwrapExpression(value);
@@ -1446,10 +1415,6 @@ function staticOptionFieldDeclarations(source, rootDir) {
1446
1415
  });
1447
1416
  });
1448
1417
  }
1449
- /**
1450
- * The Database that gets the Better Auth tables (the name that `authDatabase()` receives, `"default"` without one), and
1451
- * the plugins and additional fields that add tables and columns: those of the Definition, then those of each part.
1452
- */
1453
1418
  function readAuthTablesConfig(definition, extensions, rootDir) {
1454
1419
  const { authDatabase, body } = definition;
1455
1420
  const call = readAuthDatabaseCall(body, authDatabase);
@@ -1545,16 +1510,11 @@ function summarizeAuthSource(source, rootDir) {
1545
1510
  fields: [.../* @__PURE__ */ new Set([...additional, ...written])]
1546
1511
  };
1547
1512
  }
1548
- /** Reports `true`, `false`, or an object literal with only `keys`: the removed placement forms, which create no storage. */
1549
1513
  function isPlacementLiteral(expression, keys) {
1550
1514
  if (readStaticBooleanLiteral(expression) !== void 0) return true;
1551
1515
  const object = objectLiteral(expression);
1552
1516
  return object !== void 0 && readObjectEntries(object).every((entry) => keys.has(entry.key));
1553
1517
  }
1554
- /**
1555
- * `database` and `secondaryStorage` take Better Auth adapters only. A static Definition can hold only `authDatabase()` or
1556
- * `"memory"`.
1557
- */
1558
1518
  function assertAuthStorageConfig(body, callback, authDatabase) {
1559
1519
  const database = readObjectPropertyValue(body, "database");
1560
1520
  if (hasObjectProperty(body, "database") && !readAuthDatabaseCall(body, authDatabase) && staticString(database) !== "memory") {
@@ -1724,7 +1684,6 @@ const authTableNames = {
1724
1684
  function strings(value) {
1725
1685
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
1726
1686
  }
1727
- /** The snapshot of the newest migration folder, which Drizzle Kit compares the schema with. */
1728
1687
  function latestSnapshot(migrationsDir) {
1729
1688
  if (!existsSync(migrationsDir)) return;
1730
1689
  const latest = readdirSync(migrationsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && existsSync(join(migrationsDir, entry.name, "snapshot.json"))).map((entry) => entry.name).sort().at(-1);
@@ -1804,30 +1763,34 @@ const authSchemaSpecifiers = ["@vite-hub/auth/schema", "vite-hub/auth/schema"];
1804
1763
  function authSchemaModule(config) {
1805
1764
  return resolve(config.projectRoot, generatedAuthSchema);
1806
1765
  }
1807
- /**
1808
- * A module that builds the Auth tables with the plugins and additional fields of the Definition, and keeps the SQLite
1809
- * tables that the Database has already as `existing` describes them. It imports the package module by file, because
1810
- * the package specifier resolves to this module.
1811
- */
1766
+ const columnAccess = (name) => /^[A-Za-z_$][\w$]*$/.test(name) ? `.${name}` : `[${JSON.stringify(name)}]`;
1767
+ function renderAuthRelations(schema) {
1768
+ const specs = resolveAuthTableSpecs(schema);
1769
+ const relations = {};
1770
+ for (const { model, key, target, many, from, to } of authJoinRelations(specs)) {
1771
+ if (Object.hasOwn(specs[model]?.fields ?? {}, key)) continue;
1772
+ (relations[model] ??= []).push(` ${key}: r.${many ? "many" : "one"}.${target}({ from: r.${model}${columnAccess(from)}, to: r.${target}${columnAccess(to)} }),`);
1773
+ }
1774
+ return `r => ({\n${Object.entries(relations).map(([model, entries]) => ` ${model}: {\n${entries.join("\n")}\n },`).join("\n")}\n})`;
1775
+ }
1812
1776
  function renderAuthSchemaModule(file, schema, existing) {
1813
1777
  const options = JSON.stringify(schema);
1778
+ const relations = renderAuthRelations(schema);
1814
1779
  const packageModule = JSON.stringify(createImportPath(file, ownModule(import.meta.url, "schema")).replaceAll("\\", "/"));
1815
1780
  return [
1816
1781
  "// Generated by the Auth Vite plugin from the plugins and additional fields of the Auth Definition, and from the Auth",
1817
1782
  "// tables of the latest migration of the Database.",
1783
+ "import { defineRelationsPart } from \"drizzle-orm\"",
1818
1784
  `import { createAuthPostgresSchema, createAuthSqliteSchema } from ${packageModule}`,
1819
1785
  "",
1820
1786
  `export * from ${packageModule}`,
1821
1787
  `export const authSqliteSchema = createAuthSqliteSchema(${options}${existing ? `, ${JSON.stringify(existing)}` : ""})`,
1822
1788
  `export const authPostgresSchema = createAuthPostgresSchema(${options})`,
1789
+ `export const authSqliteRelations = defineRelationsPart(authSqliteSchema, ${relations})`,
1790
+ `export const authPostgresRelations = defineRelationsPart(authPostgresSchema, ${relations})`,
1823
1791
  ""
1824
1792
  ].join("\n");
1825
1793
  }
1826
- /**
1827
- * The dialect and the migrations folder of the Database that gets the Auth tables, read from its Definition without
1828
- * running it. Without a Database Definition, the Database integration adds the implicit `default` Database, which uses
1829
- * SQLite unless another contribution needs Postgres.
1830
- */
1831
1794
  async function readTargetDatabase(context, database) {
1832
1795
  const { discoverDatabaseDefinitions, getDefaultMigrationsDir, readDatabaseDefinitionDialect } = await import("@vite-hub/database/config");
1833
1796
  const { collectDatabaseContributions } = await import("@vite-hub/database/vite");
@@ -1850,7 +1813,6 @@ async function readTargetDatabase(context, database) {
1850
1813
  migrationsDir: resolve(context.rootDir, getDefaultMigrationsDir(context.rootDir, target, serverDirs))
1851
1814
  };
1852
1815
  }
1853
- /** Lists each file of the resolved source list, with the plugins and fields it adds, as serializable inspection summaries. */
1854
1816
  function inspectAuthDefinitions(options) {
1855
1817
  if (!options.config) return summarizeDefinitions(options.projectRoot, discoverAuthDefinitions(options.rootDir, { serverDirs: options.serverDirs }), "server-auth");
1856
1818
  const summary = (source, kind) => ({
@@ -1918,11 +1880,9 @@ async function writeNuxtAuthDefinition(root, config) {
1918
1880
  }));
1919
1881
  return file;
1920
1882
  }
1921
- /** Private Auth entries of the distribution. */
1922
1883
  function privateAuthImport(importBase, entry) {
1923
1884
  return importBase === "vite-hub/auth" ? ownModule(import.meta.url, entry) : `${importBase}/${entry}`;
1924
1885
  }
1925
- /** The rules of `shared/abilities.ts` for the server and the app, or no rules. */
1926
1886
  function renderAuthAbilitiesModule(config) {
1927
1887
  return config?.abilities ? `export { default } from ${JSON.stringify(config.abilities)}\n` : "export default {}\n";
1928
1888
  }
@@ -1939,7 +1899,6 @@ function renderAuthServerModule(options = {}) {
1939
1899
  function renderAuthRouteHandler() {
1940
1900
  return [`export { default } from ${JSON.stringify(AUTH_SERVER_ID)}`, ""].join("\n");
1941
1901
  }
1942
- /** `access.public`, and the Auth route: sign-in and the OAuth callback must work without a session. */
1943
1902
  function accessPublicRoutes(config) {
1944
1903
  return [authRoutePattern(config.basePath), ...config.access.public ?? []];
1945
1904
  }
@@ -1953,7 +1912,6 @@ function renderAuthAccessMiddlewareHandler(config, importBase = authPackageName)
1953
1912
  ""
1954
1913
  ].join("\n");
1955
1914
  }
1956
- /** A relative `import()` type specifier that resolves under NodeNext and bundler resolution: `auth.ts` becomes `auth.js`. */
1957
1915
  function typeImportSpecifier(from, file) {
1958
1916
  const path = relative(from, file).replaceAll("\\", "/").replace(/\.([cm]?)ts$/, ".$1js");
1959
1917
  return path.startsWith(".") ? path : `./${path}`;
@@ -2007,13 +1965,6 @@ function renderAuthAmbientTypes(options = { serverEnv: false }) {
2007
1965
  ""
2008
1966
  ].join("\n") : "export {}\n";
2009
1967
  }
2010
- /**
2011
- * The declaration of the virtual module. It stays out of a file with imports, which would make it an augmentation of
2012
- * a module that must already resolve. When only the bundler resolves `#vitehub/auth/server`, the tsconfig would not
2013
- * find it and the types of everything that imports the Auth handlers would be `any`. An `export ... from` in this
2014
- * block must name a package: TypeScript drops one with a file path (TS2439), and the private entry of `vite-hub` is a
2015
- * file path. A `typeof import()` type takes any path.
2016
- */
2017
1968
  function renderAuthServerTypes(importBase = authPackageName) {
2018
1969
  const serverImport = `${importBase}/server`;
2019
1970
  return [
@@ -2056,13 +2007,11 @@ function authRoutePattern(route) {
2056
2007
  }
2057
2008
  const authApplicationBaseURLName = "__VITEHUB_AUTH_APP_BASE_URL__";
2058
2009
  const authDevName = "__VITEHUB_AUTH_DEV__";
2059
- /** Return Nitro `baseURL` when the host serves the app below a path, such as Nuxt `app.baseURL`. */
2060
2010
  function nitroApplicationBaseURL(value) {
2061
2011
  const nitro = cloneNitroConfig(value);
2062
2012
  const baseURL = typeof nitro.baseURL === "string" ? nitro.baseURL : "/";
2063
2013
  return baseURL.split("/").some(Boolean) ? baseURL : void 0;
2064
2014
  }
2065
- /** Fails a production build, not the first sign-in. `nuxt prepare` also creates Nitro, but it does not build. */
2066
2015
  const memoryDatabaseGuard = {
2067
2016
  name: memoryDatabaseGuardName,
2068
2017
  setup(nitro) {
@@ -2172,6 +2121,7 @@ function hubAuth(options, internalOptions = {}) {
2172
2121
  module: schemaModule,
2173
2122
  export: dialect === "postgresql" ? "authPostgresSchema" : "authSqliteSchema"
2174
2123
  },
2124
+ relations: dialect === "postgresql" ? "authPostgresRelations" : "authSqliteRelations",
2175
2125
  tables,
2176
2126
  reason: "Stores the Better Auth users, sessions, accounts, and verifications, the tables and columns of the plugins and additional fields that the Auth Definition adds, and the Console MCP OAuth clients and tokens of authDatabase()."
2177
2127
  }];