@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
package/README.md CHANGED
@@ -14,7 +14,7 @@ Most applications install `vite-hub`, `@vite-hub/auth`, and `better-auth`, and e
14
14
  ## Install
15
15
 
16
16
  ```sh
17
- pnpm add @vite-hub/auth better-auth drizzle-orm@1.0.0-rc.5 nitro
17
+ pnpm add @vite-hub/auth better-auth drizzle-orm@1.0.0-rc.6 nitro
18
18
  pnpm add -D vite
19
19
  ```
20
20
 
@@ -72,9 +72,9 @@ export default defineAuth({
72
72
  });
73
73
  ```
74
74
 
75
- `authDatabase(name = "default")` is a Better Auth adapter for a `@vite-hub/database` Database. It uses the Drizzle client of each request and picks the SQLite or Postgres provider from it. The Auth Vite plugin reads the call from the Definition, so write it inline, in the object or in the object that the callback returns. The plugin then contributes the Better Auth tables to that Database through `vitehub.databases`: the core tables, the `admin()` fields, the `jwks` and `oauth*` tables that `mcpOAuth()` needs, the `organization`, `member`, and `invitation` tables and `session.activeOrganizationId` for `organization()`, the `passkey` table for `passkey()` from `@better-auth/passkey`, and the `rate_limit` table where Better Auth's limiter keeps its counters, in the dialect of the target Database (`@vite-hub/auth/schema` exports `authSqliteSchema` and `authPostgresSchema`). `vitehub database generate` writes their migration, and `vitehub inspect definitions --kind database` lists them. Without the tables, the adapter fails with `AUTH_R0019`.
75
+ `authDatabase(name = "default")` is a Better Auth adapter for a `@vite-hub/database` Database. It uses the Drizzle client of each request and picks the SQLite or Postgres provider from it. The Auth Vite plugin reads the call from the Definition, so write it inline, in the object or in the object that the callback returns. The plugin then contributes the Better Auth tables to that Database through `vitehub.databases`: the core tables, the `admin()` fields when the Definition calls `admin()`, the `jwks` and `oauth*` tables that `mcpOAuth()` needs, the `organization`, `member`, and `invitation` tables and `session.activeOrganizationId` for `organization()`, the `passkey` table for `passkey()` from `@better-auth/passkey`, and the `rate_limit` table where Better Auth's limiter keeps its counters, in the dialect of the target Database (`@vite-hub/auth/schema` exports `authSqliteSchema` and `authPostgresSchema`). `vitehub database generate` writes their migration, and `vitehub inspect definitions --kind database` lists them. Without the tables, the adapter fails with `AUTH_R0019`.
76
76
 
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, or a file that it imports with a relative path, 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.
77
+ The plugin also adds a column for each `additionalFields` entry of `user`, `session`, `account`, and `verification`, and the tables and columns of `admin()`, `twoFactor()`, `username()`, `anonymous()`, `phoneNumber()`, `lastLoginMethod()`, `apiKey()` from `@better-auth/api-key`, and `stripe()` from `@better-auth/stripe` when the Definition module, or a file that it imports with a relative path, 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
79
  Use `useDatabase().schema` to query the generated plugin tables and your `additionalFields`. The generated SQLite column types also reflect the migration snapshot's nullability and defaults. Use `authSqliteSchema` and `authPostgresSchema` for foreign keys to core tables such as `user` and `organization`.
80
80
 
@@ -1,5 +1,4 @@
1
- import { V as RegisteredAuth, l as AuthAnonymousAuthorization, p as AuthAuthorization } from "./types-gl-myjZc.js";
2
- //#region src/abilities.d.ts
1
+ import { V as RegisteredAuth, l as AuthAnonymousAuthorization, p as AuthAuthorization } from "./types-BP9_XUr9.js";
3
2
  /** A 4xx status that a rule can refuse with. `403` is the default. */
4
3
  type AbilityStatus = 400 | 401 | 402 | 403 | 404 | 405 | 409 | 410 | 422 | 423 | 429 | 451;
5
4
  declare const abilityDenial: unique symbol;
@@ -89,5 +88,4 @@ type AbilityRefusal<Name extends string = AbilityName> = (Name extends keyof Reg
89
88
  type AbilityAuthorization<Name extends string> = Name extends keyof RegisteredAbilities ? RegisteredAbilities[Name] extends {
90
89
  guest: true;
91
90
  } ? AuthAuthorization | AuthAnonymousAuthorization : AuthAuthorization : AuthAuthorization;
92
- //#endregion
93
91
  export { AbilityRefusal as a, AbilityStatus as c, GuestAbilityRule as d, defineAbilities as f, AbilityName as i, AbilityUser as l, guest as m, AbilityAuthorization as n, AbilityRule as o, deny as p, AbilityDenial as r, AbilityRules as s, AbilityArgs as t, AbilityVerdict as u };
@@ -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-9jC7iuN0.js";
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-D3XlrYDw.js";
2
2
  export { AbilityArgs, AbilityAuthorization, AbilityDenial, AbilityName, AbilityRefusal, AbilityRule, AbilityRules, AbilityStatus, AbilityUser, AbilityVerdict, GuestAbilityRule, defineAbilities, deny, guest };
package/dist/abilities.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/abilities.ts
1
+ // src/abilities.ts
2
2
  /**
3
3
  * Defines the app's rules in `shared/abilities.ts`. The server and the app run the same rules.
4
4
  *
@@ -39,5 +39,4 @@ function guest(rule) {
39
39
  Object.defineProperty(open, "guest", { value: true });
40
40
  return open;
41
41
  }
42
- //#endregion
43
42
  export { defineAbilities, deny, guest };
@@ -1,13 +1,10 @@
1
1
  import { HTTPError } from "nitro/h3";
2
- //#region src/ability-check.d.ts
3
2
  /** Why a rule refused: the HTTP status, and the code and details for the page. */
4
3
  interface AbilityCheckRefusal {
5
4
  status: number;
6
5
  code?: string;
7
6
  details?: unknown;
8
7
  }
9
- //#endregion
10
- //#region src/ability-error.d.ts
11
8
  /** The code and details of a refusal, as the error body's `data` and the `#denied` slot of `<AuthPermission>` carry them. */
12
9
  interface AbilityErrorData {
13
10
  code?: string;
@@ -30,5 +27,4 @@ declare class AbilityError extends HTTPError<AbilityErrorData> {
30
27
  data: AbilityErrorData;
31
28
  };
32
29
  }
33
- //#endregion
34
30
  export { AbilityErrorData as n, AbilityError 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 { HTTPError } from "nitro/h3";
3
- //#region src/ability-check.ts
3
+ // src/ability-check.ts
4
4
  const signedOut = Object.freeze({
5
5
  status: 401,
6
6
  code: "signed-out"
@@ -39,8 +39,7 @@ function toRefusal(verdict, name) {
39
39
  }
40
40
  return { status: 403 };
41
41
  }
42
- //#endregion
43
- //#region src/ability-error.ts
42
+ // src/ability-error.ts
44
43
  const statusTexts = {
45
44
  400: "Bad Request",
46
45
  401: "Unauthorized",
@@ -87,5 +86,4 @@ var AbilityError = class extends HTTPError {
87
86
  };
88
87
  }
89
88
  };
90
- //#endregion
91
89
  export { checkAbility as n, AbilityError as t };
@@ -1,5 +1,5 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
2
- //#region src/shared.ts
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
2
+ // src/shared.ts
3
3
  const defaultAuthBasePath = "/api/auth";
4
4
  function normalizeAuthBasePath(value) {
5
5
  const path = value?.trim() || defaultAuthBasePath;
@@ -8,8 +8,7 @@ function normalizeAuthBasePath(value) {
8
8
  if (!normalized) throw authErrorDiagnostics.AUTH_R0013({ message: "`defineAuth()` basePath must resolve to a non-empty path." });
9
9
  return normalized;
10
10
  }
11
- //#endregion
12
- //#region src/access-pages.ts
11
+ // src/access-pages.ts
13
12
  /**
14
13
  * Normalizes a path as Nuxt does before it matches route rules: it decodes percent-encoding and, unless the router is
15
14
  * case sensitive, folds each UTF-16 code unit to the lower case of its upper case. That is how a Vue Router path regular
@@ -92,5 +91,4 @@ function assertAuthPages(pages) {
92
91
  shapes.set(shape, path);
93
92
  }
94
93
  }
95
- //#endregion
96
94
  export { normalizeAuthBasePath as a, normalizePagePath as i, assertAuthPages as n, createAccessPageMatcher as r, accessPageBeats as t };
@@ -1,4 +1,4 @@
1
- //#region src/admin-claim-code.ts
1
+ // src/admin-claim-code.ts
2
2
  /** The variable with the SHA-256 of a one-time claim code, written by `vitehub auth claim`. */
3
3
  const adminClaimVariable = "VITEHUB_ADMIN_CLAIM";
4
4
  /** Crockford Base32 without I, L, O, and U, so a person can read the code aloud without mistakes. */
@@ -18,5 +18,4 @@ async function adminClaimHash(code) {
18
18
  const normalized = code.toUpperCase().replace(/[^0-9A-Z]/g, "");
19
19
  return `sha256:${[...new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(normalized)))].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
20
20
  }
21
- //#endregion
22
21
  export { adminClaimVariable as n, createAdminClaimCode as r, adminClaimHash as t };
package/dist/agent.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
2
  import { AgentInvoker, AgentInvokerOptions, AgentInvokerResolveContext, AgentRuntimeConfig, MaybePromise } from "@vite-hub/agent";
3
- //#region src/agent.d.ts
4
3
  export interface AuthenticatedUser {
5
4
  email?: string | null;
6
5
  id: string;
@@ -49,5 +48,4 @@ export interface AgentAuth {
49
48
  user(invoker: AgentInvoker | null | undefined): Promise<AuthenticatedUser | null>;
50
49
  }
51
50
  export declare const agentAuth: AgentAuth;
52
- export declare function authenticated<TRuntimeConfig extends AgentRuntimeConfig = AgentRuntimeConfig, CALL_OPTIONS = unknown, TUser extends AuthenticatedUser = AuthenticatedUser, TSession extends AuthenticatedSessionData = AuthenticatedSessionData>(options?: AuthenticatedOptions<TRuntimeConfig, CALL_OPTIONS, TUser, TSession>): AgentInvokerOptions<TRuntimeConfig, CALL_OPTIONS>;
53
- //#endregion
51
+ export declare function authenticated<TRuntimeConfig extends AgentRuntimeConfig = AgentRuntimeConfig, CALL_OPTIONS = unknown, TUser extends AuthenticatedUser = AuthenticatedUser, TSession extends AuthenticatedSessionData = AuthenticatedSessionData>(options?: AuthenticatedOptions<TRuntimeConfig, CALL_OPTIONS, TUser, TSession>): AgentInvokerOptions<TRuntimeConfig, CALL_OPTIONS>;
package/dist/agent.js CHANGED
@@ -1,9 +1,9 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
2
- import { n as invalidAuthenticationErrorOptions, r as throwAuthenticationProviderError } from "./set-cookie-DWIyCCJO.js";
3
- import { t as isRecord } from "./object-Da1zyPCR.js";
4
- import { a as getAuthenticationSession, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-CZmZS5QF.js";
1
+ import { n as invalidAuthenticationErrorOptions, r as throwAuthenticationProviderError } from "./set-cookie-DVfi-nJX.js";
2
+ import { a as getAuthenticationSession, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-fR6Pv4kD.js";
3
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
4
+ import { t as isRecord } from "./object-CAK6UYR5.js";
5
5
  import { ViteHubError } from "@vite-hub/runtime";
6
- //#region src/agent.ts
6
+ // src/agent.ts
7
7
  let server;
8
8
  const loadServer = () => server ??= import("./internal/server.js").catch((error) => {
9
9
  server = void 0;
@@ -108,5 +108,4 @@ function normalizeMeta(value) {
108
108
  function readString(value) {
109
109
  return typeof value === "string" && value.length > 0 ? value : void 0;
110
110
  }
111
- //#endregion
112
111
  export { agentAuth, authenticated };
@@ -1,4 +1,4 @@
1
- //#region src/application-path.ts
1
+ // src/application-path.ts
2
2
  /**
3
3
  * Prefix an application path with a base URL, such as Nitro `baseURL`. A path that already starts with the base path is
4
4
  * returned unchanged, so a caller such as Console Auth that mounts its own paths below the base path is not prefixed
@@ -58,5 +58,4 @@ function resolveAccessRoutePath(route, baseURL = authApplicationBaseURL()) {
58
58
  recursive
59
59
  };
60
60
  }
61
- //#endregion
62
61
  export { resolveAuthMountPath as i, canonicalAccessPath as n, resolveAccessRoutePath as r, accessRouteSyntaxError as t };
@@ -1,16 +1,17 @@
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, 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-Cl3hFRjk.js";
6
- import { i as resetAuth, n as getAuthRuntimeState, r as isAuthProcessMemoryDatabase, t as authProcessMemoryDatabase } from "./runtime-state-ojQCzKOc.js";
7
- import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-DJmO9a9I.js";
8
- import { i as resolveAuthMountPath } from "./application-path-DuTpfGFj.js";
9
- import { a as normalizeAuthBasePath } from "./access-pages-FNQTyGRD.js";
10
- import { o as authMemoryDatabaseError, r as authDatabaseName, t as assertAuthDatabaseIdStrategy } from "./database-options-CcjUG-us.js";
11
- import { t as assertAuthDatabaseNames } from "./database-schema-options-CTKCAfqW.js";
12
- import { a as createDeleteAccount, c as applyAuthPreset, i as validateAuthComponents, o as validateDeleteAccount, r as validateAuthAccessPolicy, s as validateAuthEvents, t as assertNoRuntimeOption } from "./definition-BFT9T6In.js";
13
- import { n as viteHubPageToolsResetCookie, r as viteHubSessionMarkerCookie } from "./page-tools-shared-l4eyj53D.js";
1
+ import { t as isRecord } from "./object-CAK6UYR5.js";
2
+ import { i as resolveAuthMountPath } from "./application-path-zKi7NrvK.js";
3
+ 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-CwPIx10t.js";
4
+ import { o as authMemoryDatabaseError, r as authDatabaseName, t as assertAuthDatabaseIdStrategy } from "./database-options-B87hDU4j.js";
5
+ import { t as assertAuthDatabaseNames } from "./database-schema-options-peXHNLkJ.js";
6
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
7
+ import { a as createDeleteAccount, c as applyAuthPreset, i as validateAuthComponents, o as validateDeleteAccount, r as validateAuthAccessPolicy, s as validateAuthEvents, t as assertNoRuntimeOption } from "./definition-BypPLIbI.js";
8
+ import { n as authRequestEvent, t as authCloudflareEnv } from "./request-Dpq7GO8B.js";
9
+ import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-BXU1_9mc.js";
10
+ import { t as forwardSignIns } from "./forward-sign-ins-BWXPPTRz.js";
11
+ import { n as resetAuth, t as getAuthRuntimeState } from "./runtime-state-C0Rd1W4m.js";
12
+ import { a as normalizeAuthBasePath } from "./access-pages-9aKr6z-k.js";
13
+ import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-DVfi-nJX.js";
14
+ import { n as viteHubPageToolsResetCookie, r as viteHubSessionMarkerCookie } from "./page-tools-shared-CtoKaNQZ.js";
14
15
  import { resolvePublicUrl } from "@vite-hub/runtime";
15
16
  import { getStandardContext } from "@vite-hub/runtime/internal/h3";
16
17
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -23,7 +24,7 @@ import definitionForApp, { getAuthApp } from "#vitehub/auth/definition";
23
24
  import { getViteHubTestMode } from "@vite-hub/runtime/internal/test-mode";
24
25
  import { isWebContainer } from "@vite-hub/web-container/env";
25
26
  import { hkdfSync } from "node:crypto";
26
- //#region ../internal/src/runtime/request-origin.ts
27
+ // ../internal/src/runtime/request-origin.ts
27
28
  function firstHeaderValue(headers, name) {
28
29
  return headers.get(name)?.split(",", 1)[0]?.trim() || void 0;
29
30
  }
@@ -44,8 +45,7 @@ function forwardedRequestOrigin(request) {
44
45
  return url.origin;
45
46
  }
46
47
  }
47
- //#endregion
48
- //#region src/password.ts
48
+ // src/password.ts
49
49
  const scryptOptions = {
50
50
  N: 16384,
51
51
  r: 16,
@@ -106,8 +106,7 @@ function readViteHubSecret(env) {
106
106
  return typeof value === "string" && value ? value : void 0;
107
107
  }
108
108
  Object.freeze({ prefix: "sha256=" });
109
- //#endregion
110
- //#region src/secret.ts
109
+ // src/secret.ts
111
110
  /** The `deriveSecret()` purpose of the Better Auth secret. `vitehub secret derive vitehub:auth` prints it. */
112
111
  const authSecretPurpose = "vitehub:auth";
113
112
  const betterAuthSecretNames = [
@@ -139,8 +138,7 @@ function deriveAuthSecret(event) {
139
138
  };
140
139
  return derived.secret;
141
140
  }
142
- //#endregion
143
- //#region ../internal/src/runtime/request-log.ts
141
+ // ../internal/src/runtime/request-log.ts
144
142
  function isRequestLog(value) {
145
143
  return value !== null && typeof value === "object" && typeof Reflect.get(value, "set") === "function" && typeof Reflect.get(value, "warn") === "function" && typeof Reflect.get(value, "error") === "function";
146
144
  }
@@ -156,8 +154,7 @@ function requestLog(input) {
156
154
  const log = contextLog(input !== null && typeof input === "object" ? Reflect.get(input, "req") : void 0) ?? contextLog(input);
157
155
  return isRequestLog(log) ? log : void 0;
158
156
  }
159
- //#endregion
160
- //#region src/request-log.ts
157
+ // src/request-log.ts
161
158
  const authHandlerEvent = new AsyncLocalStorage();
162
159
  const recorded = /* @__PURE__ */ new WeakSet();
163
160
  /** Run a Better Auth handler with the request event that endpoints, hooks, and the logger get. */
@@ -184,15 +181,12 @@ function setAuthOutcome(request, outcome) {
184
181
  }
185
182
  /**
186
183
  * Sets `auth` from a Better Auth response when no endpoint set it, such as a refusal of Better Auth's rate limit or
187
- * origin check. The code comes from Better Auth's JSON error body.
184
+ * origin check. The code comes from the JSON error body: Better Auth's `code`, else an OAuth `error` such as `invalid_grant`.
188
185
  */
189
186
  async function setAuthResponseOutcome(request, response) {
190
187
  if (response.status < 400 || recorded.has(request) || !requestLog(request)) return;
191
188
  let code;
192
- if (response.headers.get("content-type")?.includes("json")) {
193
- const body = await response.clone().json().catch(() => void 0);
194
- code = errorCode(body !== null && typeof body === "object" ? Reflect.get(body, "code") : void 0);
195
- }
189
+ if (response.headers.get("content-type")?.includes("json")) code = bodyCode(await response.clone().json().catch(() => void 0));
196
190
  setAuthOutcome(request, {
197
191
  outcome: "failure",
198
192
  status: response.status,
@@ -202,6 +196,10 @@ async function setAuthResponseOutcome(request, response) {
202
196
  function errorCode(value) {
203
197
  return typeof value === "string" && /^[\w.-]{1,100}$/.test(value) ? value : void 0;
204
198
  }
199
+ function bodyCode(body) {
200
+ if (body === null || typeof body !== "object") return void 0;
201
+ return errorCode(Reflect.get(body, "code")) ?? errorCode(Reflect.get(body, "error"));
202
+ }
205
203
  const signInPath = /^\/(?:sign-in|sign-up|callback|oauth2\/callback|magic-link\/verify|passkey\/verify-authentication|siwe\/verify|two-factor\/verify-|email-otp\/verify-email)/;
206
204
  function provider(ctx) {
207
205
  const path = ctx.path ?? "";
@@ -236,7 +234,7 @@ async function endpointOutcome(ctx, createdUserId) {
236
234
  const returned = Reflect.get(ctx.context, "returned");
237
235
  const redirect = isAPIError(returned) && returned.status === "FOUND";
238
236
  if (isAPIError(returned) && !redirect) {
239
- const code = errorCode(returned.body?.code);
237
+ const code = bodyCode(returned.body);
240
238
  return {
241
239
  ...fields,
242
240
  outcome: "failure",
@@ -310,8 +308,7 @@ function withRequestLogger(logger) {
310
308
  }
311
309
  };
312
310
  }
313
- //#endregion
314
- //#region src/event-plugin.ts
311
+ // src/event-plugin.ts
315
312
  function record(value) {
316
313
  return value !== null && typeof value === "object" ? value : {};
317
314
  }
@@ -319,6 +316,7 @@ function identifier(value) {
319
316
  return typeof value === "string" && value.length > 0 && value.length <= 256 ? value : void 0;
320
317
  }
321
318
  function actor(ctx, fallback) {
319
+ if (fallback === null) return "system";
322
320
  const session = ctx?.context.session;
323
321
  const id = identifier(session?.session.impersonatedBy) ?? session?.user.id ?? fallback;
324
322
  return id ? `user:${id}` : "system";
@@ -358,6 +356,9 @@ function createAuthEventsPlugin(options) {
358
356
  const wrappedAdapters = /* @__PURE__ */ new WeakSet();
359
357
  const createdSessions = /* @__PURE__ */ new WeakSet();
360
358
  const recordedSessions = /* @__PURE__ */ new WeakSet();
359
+ const forwardSessions = /* @__PURE__ */ new WeakSet();
360
+ const forwardedByRequest = /* @__PURE__ */ new WeakMap();
361
+ const expiredLookups = /* @__PURE__ */ new WeakMap();
361
362
  async function append(type, userId, ctx, metadata = {}, fallback) {
362
363
  const event = {
363
364
  id: crypto.randomUUID(),
@@ -402,8 +403,11 @@ function createAuthEventsPlugin(options) {
402
403
  await task;
403
404
  }
404
405
  async function deleted(session, ctx) {
405
- const type = ctx?.path === "/sign-out" ? "user.signed_out" : ctx?.path === "/admin/stop-impersonating" ? "impersonation.stopped" : "session.revoked";
406
- await append(type, session.userId, ctx, { sessionId: session.id }, identifier(session.impersonatedBy) ?? (type === "user.signed_out" ? session.userId : void 0));
406
+ if (ctx && forwardedByRequest.get(ctx.context)?.id === session.id) forwardedByRequest.delete(ctx.context);
407
+ const expired = typeof session.token === "string" && ctx?.context !== void 0 && expiredLookups.get(ctx.context)?.has(session.token) === true;
408
+ const type = ctx?.path === "/sign-out" ? "user.signed_out" : ctx?.path === "/admin/stop-impersonating" ? "impersonation.stopped" : expired ? "session.expired" : "session.revoked";
409
+ const fallback = type === "session.expired" ? null : identifier(session.impersonatedBy) ?? (type === "user.signed_out" ? session.userId : void 0);
410
+ await append(type, session.userId, ctx, { sessionId: session.id }, fallback);
407
411
  }
408
412
  return {
409
413
  id: "vitehub-auth-events",
@@ -428,6 +432,7 @@ function createAuthEventsPlugin(options) {
428
432
  if (id && userId && session.token === key) await deleted({
429
433
  id,
430
434
  userId,
435
+ token: key,
431
436
  impersonatedBy: session.impersonatedBy
432
437
  }, deletionContext.getStore() ?? null);
433
438
  }
@@ -440,7 +445,7 @@ function createAuthEventsPlugin(options) {
440
445
  init: () => ({ options: { databaseHooks: {
441
446
  user: {
442
447
  create: { async after(user, ctx) {
443
- await append("user.signed_up", user.id, ctx, { method: method(ctx) }, !ctx || ctx.path?.startsWith("/admin/") ? void 0 : user.id);
448
+ await append("user.signed_up", user.id, ctx, { method: forwardSignIns.getStore() ? "forward" : method(ctx) }, !ctx || ctx.path?.startsWith("/admin/") ? void 0 : user.id);
444
449
  } },
445
450
  update: { async after(user, ctx) {
446
451
  const path = ctx?.path;
@@ -462,6 +467,10 @@ function createAuthEventsPlugin(options) {
462
467
  session: {
463
468
  create: { async after(session, ctx) {
464
469
  createdSessions.add(session);
470
+ if (forwardSignIns.getStore()) {
471
+ forwardSessions.add(session);
472
+ if (ctx) forwardedByRequest.set(ctx.context, session);
473
+ }
465
474
  if (session.impersonatedBy || ctx?.path === "/admin/impersonate-user") {
466
475
  if (await append("impersonation.started", session.userId, ctx, { sessionId: session.id }, identifier(session.impersonatedBy))) return;
467
476
  await ctx?.context.internalAdapter.deleteSession(session.token);
@@ -469,11 +478,14 @@ function createAuthEventsPlugin(options) {
469
478
  code: "IMPERSONATION_NOT_RECORDED",
470
479
  message: "Impersonation did not start because the auth event log could not record it."
471
480
  });
472
- } else if (!ctx) await append("user.signed_in", session.userId, ctx, {
473
- method: method(ctx),
474
- device: "unknown",
475
- sessionId: session.id
476
- });
481
+ } else if (!ctx) {
482
+ recordedSessions.add(session);
483
+ await append("user.signed_in", session.userId, ctx, {
484
+ method: forwardSessions.has(session) ? "forward" : method(ctx),
485
+ device: "unknown",
486
+ sessionId: session.id
487
+ });
488
+ }
477
489
  } },
478
490
  delete: { async after(session, ctx) {
479
491
  await deleted(session, ctx);
@@ -484,19 +496,30 @@ function createAuthEventsPlugin(options) {
484
496
  before: [{
485
497
  matcher: () => true,
486
498
  handler: createAuthMiddleware(async (ctx) => {
487
- if (ctx.path?.startsWith("/two-factor/verify-") && !await getSessionFromCtx(ctx, { disableRefresh: true })) {
488
- const cookie = ctx.context.createAuthCookie("two_factor");
489
- const token = await ctx.getSignedCookie(cookie.name, ctx.context.secret);
490
- if (token && await ctx.context.internalAdapter.findVerificationValue(token)) challenges.add(ctx.context);
491
- }
492
- if (!ctx.context.options.secondaryStorage || ctx.context.options.session?.storeSessionInDatabase) return;
493
499
  const adapter = ctx.context.internalAdapter;
500
+ const findSession = async (...args) => {
501
+ const found = await adapter.findSession(...args);
502
+ if (found && new Date(found.session.expiresAt).getTime() <= Date.now() && await ctx.getSignedCookie(ctx.context.authCookies.sessionToken.name, ctx.context.secret) === found.session.token) {
503
+ const tokens = expiredLookups.get(ctx.context) ?? /* @__PURE__ */ new Set();
504
+ expiredLookups.set(ctx.context, tokens.add(found.session.token));
505
+ }
506
+ return found;
507
+ };
508
+ const storageOnly = ctx.context.options.secondaryStorage && !ctx.context.options.session?.storeSessionInDatabase;
494
509
  ctx.context.internalAdapter = {
495
510
  ...adapter,
496
- deleteSession: (token) => deletionContext.run(ctx, () => adapter.deleteSession(token)),
497
- deleteSessions: (tokens) => deletionContext.run(ctx, () => adapter.deleteSessions(tokens)),
498
- deleteUserSessions: (userId) => deletionContext.run(ctx, () => adapter.deleteUserSessions(userId))
511
+ findSession,
512
+ ...storageOnly ? {
513
+ deleteSession: (token) => deletionContext.run(ctx, () => adapter.deleteSession(token)),
514
+ deleteSessions: (tokens) => deletionContext.run(ctx, () => adapter.deleteSessions(tokens)),
515
+ deleteUserSessions: (userId) => deletionContext.run(ctx, () => adapter.deleteUserSessions(userId))
516
+ } : {}
499
517
  };
518
+ if (ctx.path?.startsWith("/two-factor/verify-") && !await getSessionFromCtx(ctx, { disableRefresh: true })) {
519
+ const cookie = ctx.context.createAuthCookie("two_factor");
520
+ const token = await ctx.getSignedCookie(cookie.name, ctx.context.secret);
521
+ if (token && await adapter.findVerificationValue(token)) challenges.add(ctx.context);
522
+ }
500
523
  })
501
524
  }, {
502
525
  matcher: (ctx) => Boolean(ctx.path?.startsWith("/oauth2/")),
@@ -537,16 +560,18 @@ function createAuthEventsPlugin(options) {
537
560
  const path = ctx.path ?? "";
538
561
  const outcome = outcomes.get(ctx.context);
539
562
  const value = record(outcome);
540
- const signedIn = ctx.context.newSession;
541
- if (signedIn && createdSessions.has(signedIn.session) && !signedIn.session.impersonatedBy && path !== "/admin/impersonate-user" && !recordedSessions.has(signedIn.session)) {
542
- recordedSessions.add(signedIn.session);
543
- await append("user.signed_in", signedIn.user.id, ctx, {
544
- method: method(ctx),
563
+ const signedIn = ctx.context.newSession?.session;
564
+ const forwarded = forwardedByRequest.get(ctx.context);
565
+ for (const session of [forwarded, signedIn]) {
566
+ if (!session || !createdSessions.has(session) || session.impersonatedBy || path === "/admin/impersonate-user" || recordedSessions.has(session)) continue;
567
+ recordedSessions.add(session);
568
+ await append("user.signed_in", session.userId, ctx, {
569
+ method: forwardSessions.has(session) ? "forward" : method(ctx),
545
570
  device: authEventDevice(ctx.headers?.get("user-agent") ?? ctx.request?.headers.get("user-agent")),
546
- sessionId: signedIn.session.id
547
- }, signedIn.user.id);
571
+ sessionId: session.id
572
+ }, session.userId);
548
573
  }
549
- if (!signedIn && outcome instanceof APIError$1 && (path.startsWith("/sign-in/") || path === "/magic-link/verify" || path === "/passkey/verify-authentication" || path === "/siwe/verify" || challenges.has(ctx.context))) await append("sign_in.failed", null, ctx, { method: method(ctx) });
574
+ if ((!signedIn || forwardSessions.has(signedIn)) && outcome instanceof APIError$1 && (path.startsWith("/sign-in/") || path === "/magic-link/verify" || path === "/passkey/verify-authentication" || path === "/siwe/verify" || challenges.has(ctx.context))) await append("sign_in.failed", null, ctx, { method: method(ctx) });
550
575
  if (outcome instanceof APIError$1) return;
551
576
  if (path === "/admin/set-user-password") {
552
577
  const userId = identifier(record(ctx.body).userId);
@@ -609,8 +634,7 @@ function createAuthEventsPlugin(options) {
609
634
  }) } : {}
610
635
  };
611
636
  }
612
- //#endregion
613
- //#region src/impersonation-plugin.ts
637
+ // src/impersonation-plugin.ts
614
638
  /**
615
639
  * Better Auth endpoints that create a credential which outlives an impersonation session, change how the user signs
616
640
  * in, or start another impersonation: OAuth, MCP, and device grants, API keys, passkeys, passwords, email and phone
@@ -711,8 +735,7 @@ function createImpersonationPlugin() {
711
735
  }] }
712
736
  };
713
737
  }
714
- //#endregion
715
- //#region src/client-address.ts
738
+ // src/client-address.ts
716
739
  /**
717
740
  * Better Auth reads the client IP for its rate limiter and for `session.ipAddress` only from request headers. Auth puts
718
741
  * the address that the host reports in this header and removes any value that a client sends, at every entry of the
@@ -800,8 +823,7 @@ function withClientAddress(auth) {
800
823
  fetch: addressedHandler
801
824
  });
802
825
  }
803
- //#endregion
804
- //#region src/session-refresh.ts
826
+ // src/session-refresh.ts
805
827
  /**
806
828
  * Runs `session.onRefresh` from the Better Auth `session.update.before` database hook.
807
829
  * Better Auth calls `updateSession(token, { expiresAt, updatedAt })` when a stored session
@@ -835,8 +857,7 @@ function createSessionRefreshPlugin(onRefresh) {
835
857
  } } } } } })
836
858
  };
837
859
  }
838
- //#endregion
839
- //#region src/options-key.ts
860
+ // src/options-key.ts
840
861
  const valueIds = /* @__PURE__ */ new WeakMap();
841
862
  let nextValueId = 0;
842
863
  function identityKey(value) {
@@ -884,25 +905,7 @@ function optionsKey(value) {
884
905
  const parts = [];
885
906
  return writeKey(value, parts, /* @__PURE__ */ new Set()) ? parts.join("") : void 0;
886
907
  }
887
- //#endregion
888
- //#region src/site-roles.ts
889
- /**
890
- * The `user.role` field of Better Auth's `admin()` plugin, without its endpoints. Site access keeps the roles it gives in
891
- * this field, and Comments and the Console page tool read them from the session user. Users cannot set it.
892
- *
893
- * Auth adds it without `admin()` only where Auth owns the user table, `authDatabase()` and the memory database, because
894
- * Better Auth refuses every request when a declared field has no column.
895
- */
896
- const siteRolesPlugin = {
897
- id: "vitehub-site-roles",
898
- schema: { user: { fields: { role: {
899
- type: "string",
900
- required: false,
901
- input: false
902
- } } } }
903
- };
904
- //#endregion
905
- //#region src/runtime-options.ts
908
+ // src/runtime-options.ts
906
909
  /** `true` or `{ name, dedicated }`: the removed placement form, which is not a Better Auth adapter. */
907
910
  function isAuthDatabasePlacement(value) {
908
911
  return typeof value === "boolean" || isRecord(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => key === "dedicated" || key === "name");
@@ -920,11 +923,10 @@ function sharedMemoryDatabase(definition) {
920
923
  const databases = getViteHubTestMode()?.backend("auth", () => /* @__PURE__ */ new WeakMap(), resetAuth) ?? (state.memoryDatabases ??= /* @__PURE__ */ new WeakMap());
921
924
  const tables = databases.get(definition) ?? {};
922
925
  databases.set(definition, tables);
923
- const database = (options) => {
926
+ return (options) => {
924
927
  for (const { modelName } of Object.values(getAuthTables(options))) tables[modelName] ??= [];
925
928
  return memoryAdapter(tables)(options);
926
929
  };
927
- return Object.assign(database, { [authProcessMemoryDatabase]: true });
928
930
  }
929
931
  /**
930
932
  * True on a development server. The Auth Vite plugin sets `__VITEHUB_AUTH_DEV__` in the server bundle: `true` for
@@ -1014,7 +1016,6 @@ function stripViteHubOptions(definition, options, environment) {
1014
1016
  if (policy && !storage.database && !storage.secondaryStorage) throw authErrorDiagnostics.AUTH_C0066({ message: "`defineAuth()` access.policy needs a Better Auth `database` or `secondaryStorage` adapter. A session that lives only in a cookie cannot be ended." });
1015
1017
  const declaredPlugins = sessionRefresh.plugins ?? rest.plugins ?? [];
1016
1018
  const impersonation = declaredPlugins.some((plugin) => plugin.id === "admin");
1017
- const siteRoles = !impersonation && !Object.hasOwn(rest.user?.additionalFields ?? {}, "role") && !declaredPlugins.some((plugin) => Object.hasOwn(plugin.schema?.user?.fields ?? {}, "role")) && (authDatabaseName(database) !== void 0 || isAuthProcessMemoryDatabase(storage.database));
1018
1019
  const { admins, adminClaim, members } = environment;
1019
1020
  assertMembersSessionStore(members, Boolean(storage.database || storage.secondaryStorage));
1020
1021
  const membersGate = members.length ? createMembersGate(members, admins, declaredPlugins) : void 0;
@@ -1025,7 +1026,6 @@ function stripViteHubOptions(definition, options, environment) {
1025
1026
  ...declaredPlugins,
1026
1027
  ...accountDeletion ? [accountDeletion.plugin] : [],
1027
1028
  ...impersonation ? [createImpersonationPlugin()] : [],
1028
- ...siteRoles ? [siteRolesPlugin] : [],
1029
1029
  ...adminsPlugin ? [adminsPlugin] : [],
1030
1030
  ...adminClaimPlugin ? [adminClaimPlugin] : [],
1031
1031
  ...policy || membersGate ? [createAccessPolicyPlugin({
@@ -1177,8 +1177,7 @@ function resolveAuthOptions(definition, input = {}) {
1177
1177
  requestRuntimeOptions
1178
1178
  };
1179
1179
  }
1180
- //#endregion
1181
- //#region src/session-marker.ts
1180
+ // src/session-marker.ts
1182
1181
  /**
1183
1182
  * Name of the cookie that tells browser code a session exists. It holds `1`, never a secret, and it is not HttpOnly,
1184
1183
  * so a page script can skip a session request for a visitor who never signed in. It does not prove a session:
@@ -1290,8 +1289,7 @@ function withSessionMarker(auth) {
1290
1289
  fetch: markedHandler
1291
1290
  });
1292
1291
  }
1293
- //#endregion
1294
- //#region src/auth-instance.ts
1292
+ // src/auth-instance.ts
1295
1293
  function hasRequestRuntimeOptions(definition) {
1296
1294
  return typeof definition.options === "function" || trustsProxyHeaders(definition.options);
1297
1295
  }
@@ -1373,5 +1371,4 @@ function authForRequest(request, event, definition = resolveDefaultDefinition())
1373
1371
  env: envResolverFor(definition)
1374
1372
  }));
1375
1373
  }
1376
- //#endregion
1377
1374
  export { forwardedRequestOrigin as _, getAuthForDefinition as a, withSessionMarker as c, eventClientAddress as d, setRequestClientAddress as f, setAuthResponseOutcome as g, setAuthOutcome as h, findVerifiedAuthUserId as i, resolveAuthOptions as l, runWithAuthEvent as m, createBetterAuthOptions as n, requestProvider as o, withClientAddress as p, envResolverFor as r, resolveDefaultDefinition as s, authForRequest as t, trustsProxyHeaders as u };
@@ -1,5 +1,4 @@
1
1
  import "nostics";
2
- //#region ../internal/src/host-credentials.d.ts
3
2
  interface HostCliRunResult {
4
3
  exitCode: number | null;
5
4
  stdout: string;
@@ -11,8 +10,6 @@ type HostCliRun = (command: string, args: readonly string[], options: {
11
10
  env: NodeJS.ProcessEnv;
12
11
  signal?: AbortSignal;
13
12
  }) => Promise<HostCliRunResult>;
14
- //#endregion
15
- //#region ../internal/src/provision.d.ts
16
13
  type ProvisionProvider = "cloudflare" | "vercel";
17
14
  interface ProvisionLogger {
18
15
  log: (message: string) => void;
@@ -64,8 +61,6 @@ interface ProvisionStep {
64
61
  /** Describes the Provision State this step records. Runs without network access, also without credentials. */
65
62
  recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
66
63
  }
67
- //#endregion
68
- //#region ../internal/src/cli.d.ts
69
64
  interface ViteHubCliStreams {
70
65
  stderr: {
71
66
  write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
@@ -160,5 +155,4 @@ interface ViteHubCliPluginMetadata {
160
155
  cli?: ViteHubCliContributor | ViteHubCliContributorFactory;
161
156
  }
162
157
  type StdoutWriteCallback = (error?: Error | null) => void;
163
- //#endregion
164
158
  export { ViteHubCliPluginMetadata as n, ViteHubCliContributor as t };
package/dist/cli.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { t as ViteHubCliContributor } from "./cli-NCtitmny.js";
2
- //#region src/cli.d.ts
1
+ import { t as ViteHubCliContributor } from "./cli-C5pAfY4x.js";
3
2
  /** Read the app-owned, session-protected endpoint. No local or remote database credentials are needed. */
4
3
  export declare function createAuthCliContributor(options?: {
5
4
  fetch?: typeof fetch;
6
- }): ViteHubCliContributor;
7
- //#endregion
5
+ }): ViteHubCliContributor;