@vite-hub/auth 0.5.0 → 0.6.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 (92) hide show
  1. package/README.md +3 -3
  2. package/dist/{abilities-9jC7iuN0.d.ts → abilities-D3XlrYDw.d.ts} +1 -3
  3. package/dist/abilities.d.ts +1 -1
  4. package/dist/abilities.js +1 -2
  5. package/dist/{ability-error-DUWJ6Q1W.d.ts → ability-error-C1c30O6E.d.ts} +0 -4
  6. package/dist/{ability-error-DmnUGicq.js → ability-error-D3-u8k1A.js} +3 -5
  7. package/dist/{access-pages-FNQTyGRD.js → access-pages-9aKr6z-k.js} +3 -5
  8. package/dist/{admin-claim-code-CDipqeAU.js → admin-claim-code-C3X_U43x.js} +1 -2
  9. package/dist/agent.d.ts +1 -3
  10. package/dist/agent.js +5 -6
  11. package/dist/{application-path-DuTpfGFj.js → application-path-zKi7NrvK.js} +1 -2
  12. package/dist/{auth-instance-zYMjldPG.js → auth-instance-BpI9Ps8A.js} +88 -91
  13. package/dist/{cli-NCtitmny.d.ts → cli-C5pAfY4x.d.ts} +0 -6
  14. package/dist/cli.d.ts +2 -4
  15. package/dist/cli.js +3 -4
  16. package/dist/{console-runtime-CuXRDhGy.js → console-runtime-CaIXVtB_.js} +10 -211
  17. package/dist/console-runtime-DAjLTLrN.d.ts +32 -0
  18. package/dist/console-runtime.d.ts +3 -3
  19. package/dist/console-runtime.js +1 -2
  20. package/dist/{console-types-CmmnKGMx.js → console-types-NrX5TWl3.js} +3 -3
  21. package/dist/console.d.ts +3 -7
  22. package/dist/console.js +2 -3
  23. package/dist/{database-options-CcjUG-us.js → database-options-B87hDU4j.js} +2 -3
  24. package/dist/{database-schema-options-CTKCAfqW.js → database-schema-options-peXHNLkJ.js} +2 -3
  25. package/dist/database.d.ts +2 -4
  26. package/dist/database.js +6 -7
  27. package/dist/{definition-BFT9T6In.js → definition-BypPLIbI.js} +11 -17
  28. package/dist/{error-diagnostics-uEbxSY2G.js → error-diagnostics-CUPwukgE.js} +2 -3
  29. package/dist/{events-DJmO9a9I.js → events-BXU1_9mc.js} +5 -6
  30. package/dist/forward-sign-ins-BWXPPTRz.js +4 -0
  31. package/dist/forward.d.ts +25 -3
  32. package/dist/forward.js +43 -6
  33. package/dist/index.d.ts +3 -7
  34. package/dist/index.js +3 -3
  35. package/dist/internal/server.d.ts +3 -3
  36. package/dist/internal/server.js +4 -4
  37. package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
  38. package/dist/{mcp-config-DRRlCAWN.js → mcp-config-C7srUMIZ.js} +2 -3
  39. package/dist/mcp-token-CmQbXbTu.d.ts +125 -0
  40. package/dist/{mcp-token-BhonlK9C.js → mcp-token-DzGivm7f.js} +47 -33
  41. package/dist/mcp.d.ts +2 -115
  42. package/dist/mcp.js +5 -6
  43. package/dist/{members-Cl3hFRjk.js → members-CwPIx10t.js} +10 -14
  44. package/dist/{nitro-kit-32CVgbWS.js → nitro-kit-BumWIKa5.js} +3 -4
  45. package/dist/{nuxt-bridge-Cl988STZ.js → nuxt-bridge-pRyfYD5c.js} +1 -2
  46. package/dist/nuxt.d.ts +1 -7
  47. package/dist/nuxt.js +6 -9
  48. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  49. package/dist/{own-access-C8pwo_Kn.js → own-access-CYsakJiH.js} +3 -4
  50. package/dist/{own-access-CdgEICjO.d.ts → own-access-Dt-I5-PT.d.ts} +1 -3
  51. package/dist/{page-tools-shared-l4eyj53D.js → page-tools-shared-CtoKaNQZ.js} +1 -2
  52. package/dist/{presets-CHndEv5i.d.ts → presets-C6AtiRdI.d.ts} +0 -2
  53. package/dist/presets.d.ts +1 -1
  54. package/dist/presets.js +2 -3
  55. package/dist/{request-z6DHHmrb.js → request-Dpq7GO8B.js} +2 -4
  56. package/dist/runtime/console.d.ts +1 -1
  57. package/dist/runtime/console.js +2 -2
  58. package/dist/runtime/empty-abilities.d.ts +1 -3
  59. package/dist/runtime/empty-abilities.js +1 -2
  60. package/dist/runtime/empty-client.d.ts +0 -2
  61. package/dist/runtime/empty-client.js +1 -2
  62. package/dist/runtime/empty-definition.d.ts +1 -3
  63. package/dist/runtime/empty-definition.js +1 -2
  64. package/dist/runtime/nuxt.d.ts +1 -3
  65. package/dist/runtime/nuxt.js +1 -2
  66. package/dist/runtime/server.d.ts +2 -2
  67. package/dist/runtime/server.js +6 -7
  68. package/dist/runtime/vue-nuxt.d.ts +0 -2
  69. package/dist/runtime/vue-nuxt.js +5 -6
  70. package/dist/runtime-state-C0Rd1W4m.js +15 -0
  71. package/dist/schema.d.ts +1 -5
  72. package/dist/schema.js +2 -3
  73. package/dist/{server-Ci2i6p1S.d.ts → server-Cun232hb.d.ts} +14 -17
  74. package/dist/{server-B-zNtSvm.d.ts → server-DL9MSuyj.d.ts} +2 -6
  75. package/dist/{server-CyqLFm3L.js → server-_eUOlAJ8.js} +16 -18
  76. package/dist/server.d.ts +4 -3
  77. package/dist/server.js +2 -2
  78. package/dist/{session-cookies-CZmZS5QF.js → session-cookies-fR6Pv4kD.js} +6 -8
  79. package/dist/{set-cookie-DWIyCCJO.js → set-cookie-DVfi-nJX.js} +3 -5
  80. package/dist/{table-specs-D0VLp1U4.js → table-specs-CCSY4tiS.js} +17 -15
  81. package/dist/{table-specs-BhWz_U0M.d.ts → table-specs-P4LvbOlX.d.ts} +28 -23
  82. package/dist/test.d.ts +2 -4
  83. package/dist/test.js +3 -4
  84. package/dist/{types-gl-myjZc.d.ts → types-BP9_XUr9.d.ts} +4 -30
  85. package/dist/{vite-QKjsPLwP.js → vite-Dem1i1rL.js} +111 -62
  86. package/dist/vite.d.ts +3 -14
  87. package/dist/vite.js +1 -2
  88. package/dist/vue.d.ts +3 -7
  89. package/dist/vue.js +4 -5
  90. package/package.json +32 -31
  91. package/dist/console-runtime-Dqidb3zF.d.ts +0 -73
  92. package/dist/runtime-state-ojQCzKOc.js +0 -25
@@ -1,24 +1,24 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
2
- import { t as readSetCookies } from "./set-cookie-DWIyCCJO.js";
3
- import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-CZmZS5QF.js";
4
- import { n as authRequestEvent, r as unwrapAuthRequest } from "./request-z6DHHmrb.js";
5
- import { t as createAuthConsole } from "./console-runtime-CuXRDhGy.js";
6
- import { i as notMemberError, l as findAccessPolicyPlugin } from "./members-Cl3hFRjk.js";
7
- import { n as getAuthRuntimeState } from "./runtime-state-ojQCzKOc.js";
8
- import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-DJmO9a9I.js";
9
- import { _ as forwardedRequestOrigin, a as getAuthForDefinition, c as withSessionMarker, d as eventClientAddress, f as setRequestClientAddress, g as setAuthResponseOutcome, h as setAuthOutcome, l as resolveAuthOptions, m as runWithAuthEvent, n as createBetterAuthOptions, o as requestProvider, p as withClientAddress, r as envResolverFor, s as resolveDefaultDefinition, t as authForRequest, u as trustsProxyHeaders } from "./auth-instance-zYMjldPG.js";
10
- import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-DuTpfGFj.js";
11
- import { a as normalizeAuthBasePath } from "./access-pages-FNQTyGRD.js";
1
+ import { t as createAuthConsole } from "./console-runtime-CaIXVtB_.js";
2
+ import { _ as forwardedRequestOrigin, a as getAuthForDefinition, c as withSessionMarker, d as eventClientAddress, f as setRequestClientAddress, g as setAuthResponseOutcome, h as setAuthOutcome, l as resolveAuthOptions, m as runWithAuthEvent, n as createBetterAuthOptions, o as requestProvider, p as withClientAddress, r as envResolverFor, s as resolveDefaultDefinition, t as authForRequest, u as trustsProxyHeaders } from "./auth-instance-BpI9Ps8A.js";
3
+ import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-zKi7NrvK.js";
4
+ import { a as normalizeAuthBasePath } from "./access-pages-9aKr6z-k.js";
5
+ import { n as authRequestEvent, r as unwrapAuthRequest } from "./request-Dpq7GO8B.js";
6
+ import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-fR6Pv4kD.js";
7
+ import { t as getAuthRuntimeState } from "./runtime-state-C0Rd1W4m.js";
8
+ import { t as readSetCookies } from "./set-cookie-DVfi-nJX.js";
12
9
  import { createAuthAccessRouteMatcher } from "./runtime/server.js";
13
- import { n as checkAbility, t as AbilityError } from "./ability-error-DmnUGicq.js";
14
- import { n as mcpOAuthResources, t as isJwsToken } from "./mcp-config-DRRlCAWN.js";
10
+ import { n as checkAbility, t as AbilityError } from "./ability-error-D3-u8k1A.js";
11
+ import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-BXU1_9mc.js";
12
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
13
+ import { i as notMemberError, l as findAccessPolicyPlugin } from "./members-CwPIx10t.js";
14
+ import { n as mcpOAuthResources, t as isJwsToken } from "./mcp-config-C7srUMIZ.js";
15
15
  import { defineErrors, toResultError } from "@vite-hub/runtime";
16
16
  import { HTTPError } from "nitro/h3";
17
17
  import { parseUserOutput } from "better-auth/db";
18
18
  import abilities from "#vitehub/auth/abilities";
19
19
  import { isRuntimeResponse } from "@vite-hub/runtime/internal/runtime-type";
20
20
  import { betterAuth } from "better-auth";
21
- //#region src/caller.ts
21
+ // src/caller.ts
22
22
  const callerErrors = /*#__PURE__*/ defineErrors({
23
23
  docs: "https://vitehub.dev/docs/auth/diagnostics",
24
24
  codes: { AUTH_SIGNED_OUT: {
@@ -27,8 +27,7 @@ const callerErrors = /*#__PURE__*/ defineErrors({
27
27
  } }
28
28
  });
29
29
  const signedOutError = () => callerErrors.AUTH_SIGNED_OUT();
30
- //#endregion
31
- //#region src/internal/server.ts
30
+ // src/internal/server.ts
32
31
  function hasHappyDomRequestState(value) {
33
32
  const ownSymbols = Object.getOwnPropertySymbols(value);
34
33
  const prototypeSymbols = Object.getOwnPropertySymbols(Object.getPrototypeOf(value) ?? {});
@@ -848,7 +847,7 @@ async function readCaller(event, definition) {
848
847
  const auth = authForRequest(request, authRequestEvent(event), definition);
849
848
  const { options } = await auth.$context;
850
849
  if (isJwsToken(token) && mcpOAuthResources(options.plugins).length) {
851
- const { verifyAppAccessToken } = await import("./mcp-token-BhonlK9C.js").then((n) => n.i);
850
+ const { verifyAppAccessToken } = await import("./mcp-token-DzGivm7f.js").then((n) => n.a);
852
851
  const url = new URL(request.url);
853
852
  const [error, caller] = await verifyAppAccessToken(token, trustsProxyHeaders(options) ? forwardedRequestOrigin(request) : url.origin, url.pathname, auth);
854
853
  if (error) return [error, void 0];
@@ -996,5 +995,4 @@ function getAuthConsoleForRequest(request, event, host) {
996
995
  });
997
996
  return createAuthConsole(requestProvider(definition, resolved), resolved.options.console, resolved.options.events ? resolved.options.events.store : void 0, host);
998
997
  }
999
- //#endregion
1000
998
  export { toAuthRequest as C, withAuthorization as D, withAuth as E, signOut as S, withAnonymousAuthorization as T, requireAbility as _, checkAuthMember as a, requireAuthorization as b, createAuthForRequest as c, getAuth as d, getAuthConsoleForRequest as f, listAuthEvents as g, handleAuthRequest as h, can as i, createAuthHandler as l, handleAuth as m, assertAuthOrigin as n, createAuth as o, getAuthEvents as p, authRoute as r, createAuthAccessHandler as s, aggregateAuthEvents as t, createAuthRequestRuntimeOptions as u, requireAuth as v, useAuth as w, requireCaller as x, requireAuthAccessRoutes as y };
package/dist/server.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, F as AuthCallerErrorCode, I as AuthCallerUser, L as AuthMemberErrorCode, O as withAuth, P as AuthCaller, S as requireAuthorization, a as authRoute, b as requireAuth, d as createAuthHandler, g as handleAuth, h as getAuthEvents, k as withAuthorization, m as getAuthConsoleForRequest, o as can, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, v as listAuthEvents, w as signOut, y as requireAbility } from "./server-Ci2i6p1S.js";
3
- import { n as AbilityErrorData, t as AbilityError } from "./ability-error-DUWJ6Q1W.js";
4
- export { AbilityError, type AbilityErrorData, type AuthCaller, type AuthCallerErrorCode, type AuthCallerUser, type AuthEventReadErrorCode, type AuthMemberErrorCode, aggregateAuthEvents, can, checkAuthMember, createAuthHandler, authRoute as default, getAuthConsoleForRequest, getAuthEvents, handleAuth, listAuthEvents, requireAbility, requireAuth, requireAuthorization, requireCaller, signOut, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
2
+ import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, F as AuthCallerError, I as AuthCallerErrorCode, L as AuthCallerResult, O as withAuth, P as AuthCaller, R as AuthCallerUser, S as requireAuthorization, a as authRoute, b as requireAuth, d as createAuthHandler, g as handleAuth, h as getAuthEvents, k as withAuthorization, m as getAuthConsoleForRequest, o as can, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, v as listAuthEvents, w as signOut, y as requireAbility, z as AuthMemberErrorCode } from "./server-Cun232hb.js";
3
+ import { a as McpTokenInvalidData, o as McpTokenInvalidError, s as McpTokenInvalidReason } from "./mcp-token-CmQbXbTu.js";
4
+ import { n as AbilityErrorData, t as AbilityError } from "./ability-error-C1c30O6E.js";
5
+ export { AbilityError, type AbilityErrorData, type AuthCaller, type AuthCallerError, type AuthCallerErrorCode, type AuthCallerResult, type AuthCallerUser, type AuthEventReadErrorCode, type AuthMemberErrorCode, type McpTokenInvalidData, type McpTokenInvalidError, type McpTokenInvalidReason, aggregateAuthEvents, can, checkAuthMember, createAuthHandler, authRoute as default, getAuthConsoleForRequest, getAuthEvents, handleAuth, listAuthEvents, requireAbility, requireAuth, requireAuthorization, requireCaller, signOut, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
package/dist/server.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as AbilityError } from "./ability-error-DmnUGicq.js";
2
- import { D as withAuthorization, E as withAuth, S as signOut, T as withAnonymousAuthorization, _ as requireAbility, a as checkAuthMember, b as requireAuthorization, f as getAuthConsoleForRequest, g as listAuthEvents, i as can, l as createAuthHandler, m as handleAuth, p as getAuthEvents, r as authRoute, t as aggregateAuthEvents, v as requireAuth, w as useAuth, x as requireCaller } from "./server-CyqLFm3L.js";
1
+ import { t as AbilityError } from "./ability-error-D3-u8k1A.js";
2
+ import { D as withAuthorization, E as withAuth, S as signOut, T as withAnonymousAuthorization, _ as requireAbility, a as checkAuthMember, b as requireAuthorization, f as getAuthConsoleForRequest, g as listAuthEvents, i as can, l as createAuthHandler, m as handleAuth, p as getAuthEvents, r as authRoute, t as aggregateAuthEvents, v as requireAuth, w as useAuth, x as requireCaller } from "./server-_eUOlAJ8.js";
3
3
  export { AbilityError, aggregateAuthEvents, can, checkAuthMember, createAuthHandler, authRoute as default, getAuthConsoleForRequest, getAuthEvents, handleAuth, listAuthEvents, requireAbility, requireAuth, requireAuthorization, requireCaller, signOut, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
@@ -1,10 +1,10 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
2
- import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-DWIyCCJO.js";
3
- import { t as isRecord } from "./object-Da1zyPCR.js";
4
- import { n as authRequestEvent } from "./request-z6DHHmrb.js";
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
2
+ import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-DVfi-nJX.js";
3
+ import { t as isRecord } from "./object-CAK6UYR5.js";
4
+ import { n as authRequestEvent } from "./request-Dpq7GO8B.js";
5
5
  import { HTTPError } from "nitro/h3";
6
6
  import { getStandardContext } from "@vite-hub/runtime/internal/h3";
7
- //#region src/session.ts
7
+ // src/session.ts
8
8
  const apiErrorHeaders = Symbol.for("better-call:api-error-headers");
9
9
  async function getAuthenticationSession(auth, input) {
10
10
  const [api, getSession] = await readProvider(() => {
@@ -151,8 +151,7 @@ function readClientApiError(error) {
151
151
  function readProperty(value, property) {
152
152
  return value[property];
153
153
  }
154
- //#endregion
155
- //#region src/session-cookies.ts
154
+ // src/session-cookies.ts
156
155
  const preparedSessionCookies = /* @__PURE__ */ new WeakMap();
157
156
  /**
158
157
  * Puts the cookies that Better Auth set while it read the session in the prepared response of the request: the renewed
@@ -287,5 +286,4 @@ function isResponseLike(value) {
287
286
  return false;
288
287
  }
289
288
  }
290
- //#endregion
291
289
  export { getAuthenticationSession as a, authenticationRefusalResponse as i, sendSessionCookies as n, authenticationRefusalError as r, prepareSessionCookies as t };
@@ -1,6 +1,6 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
2
2
  import { ViteHubError, isViteHubError } from "@vite-hub/runtime";
3
- //#region src/errors.ts
3
+ // src/errors.ts
4
4
  function invalidAuthenticationErrorOptions() {
5
5
  throw authErrorDiagnostics.AUTH_R0004({ message: "[vitehub] Invalid authentication error options." });
6
6
  }
@@ -26,8 +26,7 @@ function isAuthenticationAbortError(error) {
26
26
  return false;
27
27
  }
28
28
  }
29
- //#endregion
30
- //#region src/set-cookie.ts
29
+ // src/set-cookie.ts
31
30
  /** Read separate cookies even when a Fetch runtime exposes only a combined field. */
32
31
  function readSetCookies(headers) {
33
32
  return typeof headers.getSetCookie === "function" ? headers.getSetCookie() : splitCombinedSetCookie(headers.get("set-cookie"));
@@ -86,5 +85,4 @@ function isKnownCookieAttribute(cookie, hasBoundaryWhitespace) {
86
85
  if (lastSemicolon >= 0 && cookie.slice(lastSemicolon + 1).includes(",") && !/^expires\s*=/i.test(lastAttribute)) return false;
87
86
  return hasBoundaryWhitespace || !lastAttribute.includes("=");
88
87
  }
89
- //#endregion
90
88
  export { invalidAuthenticationErrorOptions as n, throwAuthenticationProviderError as r, readSetCookies as t };
@@ -1,9 +1,8 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
2
2
  /**
3
- * The Better Auth core tables, with the fields of the plugins that ViteHub ships: `admin()` (`user.role`, bans, and
4
- * `session.impersonatedBy`), the `jwt()` and `oauthProvider()` tables of `mcpOAuth()`, the tables of
5
- * `organization()` and of `passkey()` from `@better-auth/passkey`, and the table of Better Auth's limiter. A test checks this
6
- * list against Better Auth's own `getAuthTables()`, so a Better Auth upgrade that changes a table fails it.
3
+ * The Better Auth core tables, with the tables of the plugins that ViteHub ships: `jwt()` and `oauthProvider()` of
4
+ * `mcpOAuth()`, `organization()`, `passkey()` from `@better-auth/passkey`, and the table of Better Auth's limiter. The
5
+ * fields of `admin()` are in `authPluginSchemas`. A test checks this list against Better Auth's own `getAuthTables()`, so a Better Auth upgrade that changes a table fails it.
7
6
  */
8
7
  const authTableSpecs = {
9
8
  user: { fields: {
@@ -32,14 +31,7 @@ const authTableSpecs = {
32
31
  required: true,
33
32
  defaultValue: "now",
34
33
  onUpdate: true
35
- },
36
- role: { type: "string" },
37
- banned: {
38
- type: "boolean",
39
- defaultValue: false
40
- },
41
- banReason: { type: "string" },
42
- banExpires: { type: "date" }
34
+ }
43
35
  } },
44
36
  session: { fields: {
45
37
  expiresAt: {
@@ -73,7 +65,6 @@ const authTableSpecs = {
73
65
  onDelete: "cascade"
74
66
  }
75
67
  },
76
- impersonatedBy: { type: "string" },
77
68
  activeOrganizationId: { type: "string" }
78
69
  } },
79
70
  account: { fields: {
@@ -575,6 +566,18 @@ const authTableSpecs = {
575
566
  * `getAuthTables()`. `apiKey()` and `stripe()` are copied from `@better-auth/api-key` and `@better-auth/stripe` 1.7.
576
567
  */
577
568
  const authPluginSchemas = {
569
+ admin: { fields: {
570
+ user: {
571
+ role: { type: "string" },
572
+ banned: {
573
+ type: "boolean",
574
+ defaultValue: false
575
+ },
576
+ banReason: { type: "string" },
577
+ banExpires: { type: "date" }
578
+ },
579
+ session: { impersonatedBy: { type: "string" } }
580
+ } },
578
581
  anonymous: { fields: { user: { isAnonymous: {
579
582
  type: "boolean",
580
583
  defaultValue: false
@@ -767,5 +770,4 @@ function authSchemaError(detail) {
767
770
  function authSqlName(name) {
768
771
  return name.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").toLowerCase();
769
772
  }
770
- //#endregion
771
773
  export { resolveAuthTableSpecs as i, authSqlName as n, authTableSpecs as r, authPluginSchemas as t };
@@ -1,4 +1,3 @@
1
- //#region src/table-specs.d.ts
2
1
  /** The keys of the Better Auth tables. Better Auth's Drizzle adapter finds each model by this key. */
3
2
  type AuthTableName = "user" | "session" | "account" | "verification" | "jwks" | "oauthClient" | "oauthResource" | "oauthClientResource" | "oauthRefreshToken" | "oauthAccessToken" | "oauthConsent" | "oauthClientAssertion" | "rateLimit" | "organization" | "member" | "invitation" | "passkey";
4
3
  type AuthFieldType = "boolean" | "date" | "json" | "number" | "number[]" | "string" | "string[]";
@@ -58,19 +57,6 @@ declare const coreTableSpecs: {
58
57
  readonly defaultValue: "now";
59
58
  readonly onUpdate: true;
60
59
  };
61
- readonly role: {
62
- readonly type: "string";
63
- };
64
- readonly banned: {
65
- readonly type: "boolean";
66
- readonly defaultValue: false;
67
- };
68
- readonly banReason: {
69
- readonly type: "string";
70
- };
71
- readonly banExpires: {
72
- readonly type: "date";
73
- };
74
60
  };
75
61
  };
76
62
  readonly session: {
@@ -110,9 +96,6 @@ declare const coreTableSpecs: {
110
96
  readonly onDelete: "cascade";
111
97
  };
112
98
  };
113
- readonly impersonatedBy: {
114
- readonly type: "string";
115
- };
116
99
  readonly activeOrganizationId: {
117
100
  readonly type: "string";
118
101
  };
@@ -804,14 +787,13 @@ declare const coreTableSpecs: {
804
787
  /** The literal type of `authTableSpecs`, which types the columns of the Auth tables. */
805
788
  type AuthCoreTableSpecs = typeof coreTableSpecs;
806
789
  /**
807
- * The Better Auth core tables, with the fields of the plugins that ViteHub ships: `admin()` (`user.role`, bans, and
808
- * `session.impersonatedBy`), the `jwt()` and `oauthProvider()` tables of `mcpOAuth()`, the tables of
809
- * `organization()` and of `passkey()` from `@better-auth/passkey`, and the table of Better Auth's limiter. A test checks this
810
- * list against Better Auth's own `getAuthTables()`, so a Better Auth upgrade that changes a table fails it.
790
+ * The Better Auth core tables, with the tables of the plugins that ViteHub ships: `jwt()` and `oauthProvider()` of
791
+ * `mcpOAuth()`, `organization()`, `passkey()` from `@better-auth/passkey`, and the table of Better Auth's limiter. The
792
+ * fields of `admin()` are in `authPluginSchemas`. A test checks this list against Better Auth's own `getAuthTables()`, so a Better Auth upgrade that changes a table fails it.
811
793
  */
812
794
  declare const authTableSpecs: Readonly<Record<AuthTableName, AuthTableSpec>>;
813
795
  /** The Better Auth plugins whose tables and columns `authDatabase()` adds when the Auth Definition imports them. */
814
- type AuthSchemaPlugin = "anonymous" | "apiKey" | "lastLoginMethod" | "phoneNumber" | "stripe" | "twoFactor" | "username";
796
+ type AuthSchemaPlugin = "admin" | "anonymous" | "apiKey" | "lastLoginMethod" | "phoneNumber" | "stripe" | "twoFactor" | "username";
815
797
  /** The core Better Auth models. Each one takes `additionalFields`. */
816
798
  type AuthCoreModel = "user" | "session" | "account" | "verification";
817
799
  interface AuthPluginSchema {
@@ -821,6 +803,30 @@ interface AuthPluginSchema {
821
803
  tables?: Readonly<Record<string, AuthTableSpec>>;
822
804
  }
823
805
  declare const pluginSchemas: {
806
+ readonly admin: {
807
+ readonly fields: {
808
+ readonly user: {
809
+ readonly role: {
810
+ readonly type: "string";
811
+ };
812
+ readonly banned: {
813
+ readonly type: "boolean";
814
+ readonly defaultValue: false;
815
+ };
816
+ readonly banReason: {
817
+ readonly type: "string";
818
+ };
819
+ readonly banExpires: {
820
+ readonly type: "date";
821
+ };
822
+ };
823
+ readonly session: {
824
+ readonly impersonatedBy: {
825
+ readonly type: "string";
826
+ };
827
+ };
828
+ };
829
+ };
824
830
  readonly anonymous: {
825
831
  readonly fields: {
826
832
  readonly user: {
@@ -1092,5 +1098,4 @@ interface AuthSchemaOptions {
1092
1098
  * A field that a table has already must have the same type and `required`.
1093
1099
  */
1094
1100
  declare function resolveAuthTableSpecs(options?: AuthSchemaOptions): Record<string, AuthTableSpec>;
1095
- //#endregion
1096
1101
  export { AuthSchemaPlugin as a, AuthTableSpec as c, resolveAuthTableSpecs as d, AuthSchemaOptions as i, authPluginSchemas as l, AuthCoreTableSpecs as n, AuthTableField as o, AuthPluginSchemas as r, AuthTableName as s, AuthCoreModel as t, authTableSpecs as u };
package/dist/test.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { _ as AuthDefinition } from "./types-gl-myjZc.js";
1
+ import { _ as AuthDefinition } from "./types-BP9_XUr9.js";
2
2
  import { Session, User } from "better-auth";
3
- //#region src/test.d.ts
4
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. */
5
4
  export interface SignInTestUser {
6
5
  email?: string;
@@ -22,5 +21,4 @@ export interface TestSignIn {
22
21
  * request. It sends no email and calls no provider. A Definition with the `stateless()` preset has no database, so it
23
22
  * fails with `AUTH_TEST_SIGN_IN_STATELESS`.
24
23
  */
25
- export declare function signIn(user?: SignInTestUser, definition?: AuthDefinition): Promise<TestSignIn>;
26
- //#endregion
24
+ export declare function signIn(user?: SignInTestUser, definition?: AuthDefinition): Promise<TestSignIn>;
package/dist/test.js CHANGED
@@ -1,7 +1,7 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
2
- import { s as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-zYMjldPG.js";
1
+ import { s as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-BpI9Ps8A.js";
2
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
3
3
  import { testUtils } from "better-auth/plugins";
4
- //#region src/test.ts
4
+ // src/test.ts
5
5
  /**
6
6
  * Signs in a user of the app's Auth Definition and returns the session cookie. It writes the user and the session to the
7
7
  * Auth database, as a real sign-in does, so `requireAuth()`, `useAuth().api.getSession()`, and abilities accept the
@@ -21,5 +21,4 @@ async function signIn(user = {}, definition = resolveDefaultDefinition()) {
21
21
  user: saved
22
22
  };
23
23
  }
24
- //#endregion
25
24
  export { signIn };
@@ -1,11 +1,10 @@
1
- import { t as AuthPreset } from "./presets-CHndEv5i.js";
2
- import { i as AuthSchemaOptions } from "./table-specs-BhWz_U0M.js";
1
+ import { t as AuthPreset } from "./presets-C6AtiRdI.js";
2
+ import { i as AuthSchemaOptions } from "./table-specs-P4LvbOlX.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";
6
6
  import { EnvDatabase } from "@vite-hub/env/database";
7
- //#region src/events.d.ts
8
- declare const authEventTypes: readonly ["user.signed_up", "user.signed_in", "user.signed_out", "sign_in.failed", "session.revoked", "user.banned", "user.unbanned", "user.role_changed", "user.updated", "user.removed", "impersonation.started", "impersonation.stopped", "oauth.consent_granted", "oauth.consent_revoked", "organization.member_added", "organization.member_removed", "organization.member_role_changed"];
7
+ declare const authEventTypes: readonly ["user.signed_up", "user.signed_in", "user.signed_out", "sign_in.failed", "session.revoked", "session.expired", "user.banned", "user.unbanned", "user.role_changed", "user.updated", "user.removed", "impersonation.started", "impersonation.stopped", "oauth.consent_granted", "oauth.consent_revoked", "organization.member_added", "organization.member_removed", "organization.member_role_changed"];
9
8
  type AuthEventType = typeof authEventTypes[number];
10
9
  type AuthEventActor = "system" | `user:${string}`;
11
10
  type AuthDevice = "desktop" | "mobile" | "tablet" | "bot" | "unknown";
@@ -86,8 +85,6 @@ declare function createDatabaseAuthEventStore(options: {
86
85
  db: EnvDatabase;
87
86
  retention?: AuthEventRetention | false;
88
87
  }): AuthEventStore;
89
- //#endregion
90
- //#region src/nuxt-types.d.ts
91
88
  /** Who may open a page: signed-in users (`user`) or signed-out visitors (`guest`). */
92
89
  type AuthPageMode = "guest" | "user";
93
90
  /**
@@ -105,8 +102,6 @@ type AuthPageMeta = boolean | AuthPageMode | {
105
102
  * removes the guard of a wider pattern from the matching pages.
106
103
  */
107
104
  type AuthPages = Record<`/${string}`, AuthPageMode | false>;
108
- //#endregion
109
- //#region src/console-types.d.ts
110
105
  type AuthConsoleValue = string | number | boolean | null | string[] | number[];
111
106
  type AuthConsoleFieldType = "string" | "number" | "boolean" | "date" | "string[]" | "number[]" | "json";
112
107
  type AuthConsoleAction = "ban" | "unban" | "remove" | "revokeSession" | "revokeSessions" | "setRole" | "editField" | "impersonate" | "revokeConsent";
@@ -282,24 +277,6 @@ interface AuthConsoleSession {
282
277
  updatedAt: string;
283
278
  }
284
279
  /** A user that a host signs in without a password, such as a Console member or an invited guest. */
285
- interface AuthConsoleHostUserInput {
286
- /** The email of an existing person. Without it, the user is new and gets a placeholder email. */
287
- email?: string;
288
- name: string;
289
- image?: string;
290
- /** Roles to add to the comma-separated `user.role` of `admin()`. */
291
- roles: readonly string[];
292
- /**
293
- * Roles that the host owns. An existing user loses those of them that `roles` does not name, so a host can take a
294
- * role back. Other roles of the user stay.
295
- */
296
- owned?: readonly string[];
297
- }
298
- /** A live session of a user that holds a host role, with the user's roles. */
299
- interface AuthConsoleHostSession extends AuthConsoleSession {
300
- roles: string[];
301
- guest: boolean;
302
- }
303
280
  interface AuthConsoleAgent {
304
281
  id: string;
305
282
  clientId: string;
@@ -383,8 +360,6 @@ type AuthConsoleMutation = {
383
360
  id: string;
384
361
  };
385
362
  declare const authConsoleActionNames: readonly AuthConsoleAction[];
386
- //#endregion
387
- //#region src/types.d.ts
388
363
  declare global {
389
364
  namespace ViteHub {
390
365
  interface AuthRuntimeEnv extends Record<string, unknown> {}
@@ -631,5 +606,4 @@ type RegisteredAuth<TRegistry = ViteHub.AuthRegistry> = TRegistry extends {
631
606
  } ? AuthFor<TDefinition> : ViteHubAuth;
632
607
  /** `false` turns Auth off. `server/auth.ts` turns it on, and `defineAuth()` holds every Auth option. */
633
608
  type AuthOptions = false;
634
- //#endregion
635
- export { AuthConsoleEventGroup as $, AuthRuntimeEnv as A, AuthEventActor as At, DiscoveredAuthDefinition as B, AuthEventsConfiguration as Bt, AuthGuardedHandler as C, authConsoleActionNames as Ct, AuthReservedOption as D, AuthPages as Dt, AuthRequestInput as E, AuthPageMode as Et, AuthSessionRefresh as F, AuthEventPage as Ft, AuthConsoleAction as G, ResolvedAuthAccessRoute as H, defaultAuthEventRetention as Ht, AuthSessionRefreshContext as I, AuthEventRetention as It, AuthConsoleAgent as J, AuthConsoleActivity as K, AuthSessionRefreshFields as L, AuthEventStore as Lt, AuthRuntimeOption as M, AuthEventCounts as Mt, AuthRuntimeOptions as N, AuthEventListInput as Nt, AuthResolvedDefinitionOptions as O, AuthDevice as Ot, AuthSessionOptions as P, AuthEventMetadata as Pt, AuthConsoleEvent as Q, AuthSignInConfiguration as R, AuthEventType as Rt, AuthFor as S, AuthConsoleValue as St, AuthRequest as T, AuthPageMeta as Tt, ResolvedAuthViteConfig as U, RegisteredAuth as V, createDatabaseAuthEventStore as Vt, ViteHubAuth as W, AuthConsoleColumn as X, AuthConsoleCapability as Y, AuthConsoleDescription as Z, AuthDefinition as _, AuthConsoleRoles as _t, AuthAccessPolicy as a, AuthConsoleHostSession as at, AuthDefinitionResolver as b, AuthConsoleUser as bt, AuthAccessRouteConfiguration as c, AuthConsoleList as ct, AuthAnonymousGuardedHandler as d, AuthConsoleOrganization as dt, AuthConsoleEventUser as et, AuthAppDatabase as f, AuthConsoleOrganizationDetail as ft, AuthComponentsOptions as g, AuthConsoleQuery as gt, AuthBetterAuthRuntimeOptions as h, AuthConsolePolicy as ht, AuthAccessConfiguration as i, AuthConsoleHostOptions as it, AuthRuntimeOnlyOptions as j, AuthEventAggregates as jt, AuthRuntimeContext as k, AuthEvent as kt, AuthAnonymousAuthorization as l, AuthConsoleMutation as lt, AuthBetterAuthOptions as m, AuthConsolePage as mt, AuthAccessAuthorize as n, AuthConsoleFieldPolicy as nt, AuthAccessPolicyContext as o, AuthConsoleHostUserInput as ot, AuthAuthorization as p, AuthConsoleOverview as pt, AuthConsoleActivityQuery as q, AuthAccessAuthorizeResult as r, AuthConsoleFieldType as rt, AuthAccessRoute as s, AuthConsoleImpersonation as st, AuthAccessAuthorizationContext as t, AuthConsoleField as tt, AuthAnonymousAuthorize as u, AuthConsoleOptions as ut, AuthDefinitionInput as v, AuthConsoleSession as vt, AuthOptions as w, authConsoleEventGroups as wt, AuthDeleteAccountOptions as x, AuthConsoleUserDetail as xt, AuthDefinitionOptions as y, AuthConsoleSessionUser as yt, AuthViteHubOptions as z, AuthEventWindow as zt };
609
+ export { AuthConsoleEventGroup as $, AuthRuntimeEnv as A, AuthEventCounts as At, DiscoveredAuthDefinition as B, defaultAuthEventRetention as Bt, AuthGuardedHandler as C, AuthPageMeta as Ct, AuthReservedOption as D, AuthEvent as Dt, AuthRequestInput as E, AuthDevice as Et, AuthSessionRefresh as F, AuthEventStore as Ft, AuthConsoleAction as G, ResolvedAuthAccessRoute as H, AuthSessionRefreshContext as I, AuthEventType as It, AuthConsoleAgent as J, AuthConsoleActivity as K, AuthSessionRefreshFields as L, AuthEventWindow as Lt, AuthRuntimeOption as M, AuthEventMetadata as Mt, AuthRuntimeOptions as N, AuthEventPage as Nt, AuthResolvedDefinitionOptions as O, AuthEventActor as Ot, AuthSessionOptions as P, AuthEventRetention as Pt, AuthConsoleEvent as Q, AuthSignInConfiguration as R, AuthEventsConfiguration as Rt, AuthFor as S, authConsoleEventGroups as St, AuthRequest as T, AuthPages as Tt, ResolvedAuthViteConfig as U, RegisteredAuth as V, ViteHubAuth as W, AuthConsoleColumn as X, AuthConsoleCapability as Y, AuthConsoleDescription as Z, AuthDefinition as _, AuthConsoleSessionUser as _t, AuthAccessPolicy as a, AuthConsoleImpersonation as at, AuthDefinitionResolver as b, AuthConsoleValue as bt, AuthAccessRouteConfiguration as c, AuthConsoleOptions as ct, AuthAnonymousGuardedHandler as d, AuthConsoleOverview as dt, AuthConsoleEventUser as et, AuthAppDatabase as f, AuthConsolePage as ft, AuthComponentsOptions as g, AuthConsoleSession as gt, AuthBetterAuthRuntimeOptions as h, AuthConsoleRoles as ht, AuthAccessConfiguration as i, AuthConsoleHostOptions as it, AuthRuntimeOnlyOptions as j, AuthEventListInput as jt, AuthRuntimeContext as k, AuthEventAggregates as kt, AuthAnonymousAuthorization as l, AuthConsoleOrganization as lt, AuthBetterAuthOptions as m, AuthConsoleQuery as mt, AuthAccessAuthorize as n, AuthConsoleFieldPolicy as nt, AuthAccessPolicyContext as o, AuthConsoleList as ot, AuthAuthorization as p, AuthConsolePolicy as pt, AuthConsoleActivityQuery as q, AuthAccessAuthorizeResult as r, AuthConsoleFieldType as rt, AuthAccessRoute as s, AuthConsoleMutation as st, AuthAccessAuthorizationContext as t, AuthConsoleField as tt, AuthAnonymousAuthorize as u, AuthConsoleOrganizationDetail as ut, AuthDefinitionInput as v, AuthConsoleUser as vt, AuthOptions as w, AuthPageMode as wt, AuthDeleteAccountOptions as x, authConsoleActionNames as xt, AuthDefinitionOptions as y, AuthConsoleUserDetail as yt, AuthViteHubOptions as z, createDatabaseAuthEventStore as zt };