@vite-hub/auth 0.6.1 → 0.8.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 (78) hide show
  1. package/README.md +86 -12
  2. package/dist/{abilities-BYOcyQ9B.d.ts → abilities-IOwpkcz4.d.ts} +1 -1
  3. package/dist/abilities.d.ts +1 -1
  4. package/dist/{ability-error-D3-u8k1A.js → ability-error-DgR91Jwc.js} +1 -1
  5. package/dist/{access-pages-9aKr6z-k.js → access-pages-C69nwa99.js} +10 -3
  6. package/dist/agent.d.ts +2 -3
  7. package/dist/agent.js +31 -12
  8. package/dist/{auth-instance-BWiRS9QZ.js → auth-instance-WeEK1zDd.js} +174 -64
  9. package/dist/{cli-C5pAfY4x.d.ts → cli-DL7uCAvz.d.ts} +15 -0
  10. package/dist/cli.d.ts +1 -1
  11. package/dist/cli.js +1 -1
  12. package/dist/client-extension-BgUlm6hy.d.ts +33 -0
  13. package/dist/client-request-B1DCz3a9.js +29 -0
  14. package/dist/{console-runtime-DMH1I2fl.d.ts → console-runtime-C71weVrt.d.ts} +1 -1
  15. package/dist/{console-runtime-CaIXVtB_.js → console-runtime-Dk3j4Jmz.js} +5 -3
  16. package/dist/console-runtime.d.ts +2 -2
  17. package/dist/console-runtime.js +1 -1
  18. package/dist/console.d.ts +1 -1
  19. package/dist/database-options-Cms7BI3c.js +36 -0
  20. package/dist/{database-schema-options-peXHNLkJ.js → database-schema-options-IlHEeUBK.js} +1 -1
  21. package/dist/database.d.ts +1 -1
  22. package/dist/database.js +13 -8
  23. package/dist/{definition-BypPLIbI.js → definition-EpeI5LUG.js} +18 -4
  24. package/dist/{error-diagnostics-CUPwukgE.js → error-diagnostics-DZHuHXPP.js} +46 -5
  25. package/dist/{events-BXU1_9mc.js → events-Cm7Iwq47.js} +1 -1
  26. package/dist/extension-BWmjJhoN.d.ts +59 -0
  27. package/dist/extension-mCx4TrsO.js +133 -0
  28. package/dist/forward.js +1 -1
  29. package/dist/index.d.ts +4 -3
  30. package/dist/index.js +5 -3
  31. package/dist/internal/server.d.ts +3 -3
  32. package/dist/internal/server.js +5 -4
  33. package/dist/{mcp-config-C7srUMIZ.js → mcp-config-Bbr8kQxm.js} +9 -1
  34. package/dist/{mcp-token-CuqdbBy8.js → mcp-token-BleQZK6H.js} +52 -11
  35. package/dist/{mcp-token-CmQbXbTu.d.ts → mcp-token-CxpopXmK.d.ts} +5 -2
  36. package/dist/mcp.d.ts +2 -2
  37. package/dist/mcp.js +27 -6
  38. package/dist/{members-CwPIx10t.js → members-7OMdqha_.js} +188 -152
  39. package/dist/nuxt.d.ts +4 -14
  40. package/dist/nuxt.js +53 -20
  41. package/dist/{own-access-BNcxKrDl.d.ts → own-access-CGiai2L3.d.ts} +1 -1
  42. package/dist/{page-tools-shared-CtoKaNQZ.js → page-tools-shared-dVJBPPTk.js} +8 -0
  43. package/dist/presets.js +1 -1
  44. package/dist/roles-BGi8CyBG.js +17 -0
  45. package/dist/runtime/client-request-plugin.d.ts +2 -1
  46. package/dist/runtime/client-request-plugin.js +8 -5
  47. package/dist/runtime/console.d.ts +1 -1
  48. package/dist/runtime/console.js +2 -2
  49. package/dist/runtime/empty-abilities.d.ts +1 -1
  50. package/dist/runtime/empty-client.d.ts +3 -0
  51. package/dist/runtime/empty-client.js +3 -1
  52. package/dist/runtime/empty-definition.d.ts +1 -1
  53. package/dist/runtime/server.d.ts +4 -3
  54. package/dist/runtime/server.js +7 -4
  55. package/dist/runtime/vue-nuxt.js +27 -11
  56. package/dist/schema.d.ts +32 -14
  57. package/dist/schema.js +21 -14
  58. package/dist/{server-Iru6jcnW.js → server-5t-HA7I1.js} +80 -328
  59. package/dist/{server-C4Kni3Vj.d.ts → server-DyP1v-sZ.d.ts} +39 -7
  60. package/dist/{server-BHniJi2m.d.ts → server-mmp8EfcE.d.ts} +4 -2
  61. package/dist/server.d.ts +6 -3
  62. package/dist/server.js +9 -3
  63. package/dist/{session-cookies-fR6Pv4kD.js → session-cookies-BNtY3hMp.js} +4 -16
  64. package/dist/{set-cookie-DVfi-nJX.js → set-cookie-Bva-P-_C.js} +1 -1
  65. package/dist/{table-specs-CCSY4tiS.js → table-specs-Bm7QJCbu.js} +1 -1
  66. package/dist/{table-specs-P4LvbOlX.d.ts → table-specs-BxKeFD_y.d.ts} +5 -0
  67. package/dist/test.d.ts +1 -1
  68. package/dist/test.js +2 -2
  69. package/dist/{types-DmH31d2t.d.ts → types-CnO5bHEF.d.ts} +40 -6
  70. package/dist/{vite-CpWhT1Wi.js → vite-7I1bJvqA.js} +686 -244
  71. package/dist/vite-CZ_Z6IR3.d.ts +28 -0
  72. package/dist/vite.d.ts +41 -6
  73. package/dist/vite.js +1 -1
  74. package/dist/vue.d.ts +4 -3
  75. package/dist/vue.js +39 -4
  76. package/package.json +9 -8
  77. package/dist/client-request-BzMKtfCY.js +0 -52
  78. package/dist/database-options-B87hDU4j.js +0 -28
@@ -0,0 +1,28 @@
1
+ import "vite";
2
+ interface NuxtLayerDirectoryConfig {
3
+ rootDir?: string;
4
+ serverDir?: string;
5
+ srcDir?: string;
6
+ }
7
+ /** The Nuxt options that locate the server directory of each layer. */
8
+ interface NuxtServerDirOptions extends NuxtLayerDirectoryConfig {
9
+ _layers?: ReadonlyArray<{
10
+ config?: NuxtLayerDirectoryConfig;
11
+ cwd?: string;
12
+ }>;
13
+ }
14
+ /**
15
+ * Server directories that ViteHub scans for Definitions. The first entry is the application.
16
+ * Later entries are Nuxt layers in Nuxt priority order.
17
+ */
18
+ declare const VITEHUB_SERVER_DIRS: "__vitehubServerDirs";
19
+ declare const VITEHUB_NUXT_AUTH_DISCOVERY: "__vitehubNuxtAuthDiscovery";
20
+ interface NuxtAuthDiscovery {
21
+ appDir: string | undefined;
22
+ layerAppDirs: string[];
23
+ layerAliases: Readonly<Record<string, string>>;
24
+ }
25
+ declare function resolveNuxtAuthDiscovery(options: NuxtServerDirOptions & {
26
+ alias?: Record<string, string>;
27
+ }): NuxtAuthDiscovery;
28
+ export { NuxtServerDirOptions as i, VITEHUB_SERVER_DIRS as n, resolveNuxtAuthDiscovery as r, VITEHUB_NUXT_AUTH_DISCOVERY as t };
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { U as ResolvedAuthViteConfig, w as AuthOptions } from "./types-DmH31d2t.js";
3
- import { n as ViteHubCliPluginMetadata } from "./cli-C5pAfY4x.js";
2
+ import { r as resolveNuxtAuthDiscovery } from "./vite-CZ_Z6IR3.js";
3
+ import { V as DiscoveredAuthDefinition, W as ResolvedAuthViteConfig, w as AuthOptions } from "./types-CnO5bHEF.js";
4
+ import { n as ViteHubCliPluginMetadata } from "./cli-DL7uCAvz.js";
4
5
  import { Plugin } from "vite";
5
6
  interface ViteHubDefinitionField {
6
7
  label: string;
@@ -63,9 +64,21 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
63
64
  interface ViteHubInspectionPluginMetadata {
64
65
  inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
65
66
  }
66
- export declare function resolveAuthViteConfig(options?: AuthOptions, rootDir?: string, discovery?: {
67
- serverDirs?: string[];
68
- }): ResolvedAuthViteConfig | undefined;
67
+ type LayerRootsByAlias = Readonly<Record<string, string>>;
68
+ /**
69
+ * Whether the Auth Definition of the project keeps users in the app Database with `authDatabase()`. ViteHub turns the
70
+ * Database on for it, as it does for Connections.
71
+ */
72
+ interface AuthDiscovery {
73
+ projectRoot?: string;
74
+ serverDirs?: readonly string[];
75
+ layerAliases?: LayerRootsByAlias;
76
+ }
77
+ export declare function usesAuthDatabase(project: AuthDiscovery & {
78
+ projectRoot: string;
79
+ viteRoot?: string;
80
+ }): boolean;
81
+ export declare function resolveAuthViteConfig(options?: AuthOptions, rootDir?: string, discovery?: AuthDiscovery): ResolvedAuthViteConfig | undefined;
69
82
  /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
70
83
  type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
71
84
  /**
@@ -108,6 +121,21 @@ interface ContributionContext {
108
121
  /** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
109
122
  plugins?: readonly unknown[];
110
123
  }
124
+ /**
125
+ * The parts of the Auth Definition, `server/auth.extend.ts`: the file of the application first, then the files of
126
+ * Nuxt layers in priority order.
127
+ */
128
+ export declare function discoverAuthExtensions(rootDir: string, options?: {
129
+ serverDirs?: readonly string[];
130
+ }): string[];
131
+ export declare function discoverProjectAuthDefinition(project: {
132
+ projectRoot: string;
133
+ viteRoot?: string;
134
+ serverDirs?: readonly string[];
135
+ }): {
136
+ definition: DiscoveredAuthDefinition;
137
+ rootDir: string;
138
+ } | undefined;
111
139
  export declare const AUTH_ABILITIES_ID = "#vitehub/auth/abilities";
112
140
  export declare const AUTH_CLIENT_ID = "#vitehub/auth/client";
113
141
  export declare const AUTH_DEFINITION_ID = "#vitehub/auth/definition";
@@ -130,7 +158,7 @@ export interface AuthDatabaseContribution {
130
158
  name: "auth";
131
159
  database: string;
132
160
  dialect: "postgresql" | "sqlite";
133
- /** The schema module of the package, or a generated module when the Definition adds plugins or fields. */
161
+ /** The generated module of the Auth tables, with the plugins and additional fields of the Definition. */
134
162
  definition: {
135
163
  module: string;
136
164
  export: "authPostgresSchema" | "authSqliteSchema";
@@ -145,13 +173,20 @@ export type AuthVitePlugin = Plugin & {
145
173
  databases: (context: AuthDatabaseContributionContext) => Promise<AuthDatabaseContribution[]>;
146
174
  };
147
175
  };
176
+ /** The specifiers of the Auth tables. Each host resolves them to the generated module, so an app imports the tables that Auth adds. */
177
+ export declare const authSchemaSpecifiers: readonly ["@vite-hub/auth/schema", "vite-hub/auth/schema"];
178
+ /** The generated module of the Auth tables, which `authSchemaSpecifiers` resolve to when the Definition uses `authDatabase()`. */
179
+ export declare function authSchemaModule(config: Pick<ResolvedAuthViteConfig, "projectRoot">): string;
148
180
  export declare function createAuthNitroConfig(plugin: AuthVitePlugin, options: {
149
181
  nitro: Record<string, unknown>;
150
182
  projectRoot: string;
151
183
  serverDirs?: string[];
184
+ nuxtDiscovery?: ReturnType<typeof resolveNuxtAuthDiscovery>;
152
185
  }): Record<string, unknown>;
153
186
  interface InternalAuthModuleOptions {
187
+ databaseDisabled?: boolean;
154
188
  importBase?: string;
189
+ layerAliases?: Readonly<Record<string, string>>;
155
190
  }
156
191
  export declare function writeNuxtAuthDefinition(root: string, config: ResolvedAuthViteConfig): Promise<string>;
157
192
  export declare function hubAuth(options?: AuthOptions, internalOptions?: InternalAuthModuleOptions): AuthVitePlugin;
package/dist/vite.js CHANGED
@@ -1 +1 @@
1
- export { t as AUTH_ABILITIES_ID, n as AUTH_CLIENT_ID, r as AUTH_DEFINITION_ID, i as AUTH_SERVER_ID, a as AUTH_VITE_PLUGIN_NAME, o as createAuthNitroConfig, s as hubAuth, l as resolveAuthViteConfig, c as writeNuxtAuthDefinition } from "./vite-CpWhT1Wi.js";
1
+ export { t as AUTH_ABILITIES_ID, n as AUTH_CLIENT_ID, r as AUTH_DEFINITION_ID, i as AUTH_SERVER_ID, a as AUTH_VITE_PLUGIN_NAME, o as authSchemaModule, s as authSchemaSpecifiers, c as createAuthNitroConfig, m as discoverAuthExtensions, h as discoverProjectAuthDefinition, l as hubAuth, d as resolveAuthViteConfig, f as usesAuthDatabase, u as writeNuxtAuthDefinition } from "./vite-7I1bJvqA.js";
package/dist/vue.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { a as AbilityRefusal, i as AbilityName, t as AbilityArgs } from "./abilities-BYOcyQ9B.js";
3
- import { S as AuthFor, _ as AuthDefinition } from "./types-DmH31d2t.js";
2
+ import { a as AbilityRefusal, i as AbilityName, t as AbilityArgs } from "./abilities-IOwpkcz4.js";
3
+ import { S as AuthFor, _ as AuthDefinition } from "./types-CnO5bHEF.js";
4
+ import { a as extendAuthClient, i as ExtendedAuthClientOptions, n as AuthClientExtensionOptions, t as AuthClientExtension } from "./client-extension-BgUlm6hy.js";
4
5
  import { n as AbilityErrorData } from "./ability-error-C1c30O6E.js";
5
6
  import { BetterAuthClientOptions } from "better-auth";
6
7
  import { ComputedRef, VNode } from "vue";
@@ -291,4 +292,4 @@ export type AuthPermissionComponent = <const Name extends AbilityName>(props: Au
291
292
  };
292
293
  /** Render the allowed or denied slot. The default slot is shorthand for allowed. */
293
294
  export declare const AuthPermission: AuthPermissionComponent;
294
- export type { RequestFetch, VueAuthClient };
295
+ export { type AuthClientExtension, type AuthClientExtensionOptions, type ExtendedAuthClientOptions, type RequestFetch, type VueAuthClient, extendAuthClient };
package/dist/vue.js CHANGED
@@ -1,8 +1,43 @@
1
- import { n as checkAbility, t as AbilityError } from "./ability-error-D3-u8k1A.js";
1
+ import { n as checkAbility, t as AbilityError } from "./ability-error-DgR91Jwc.js";
2
+ import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
3
+ import { n as assertUniquePluginIds } from "./extension-mCx4TrsO.js";
2
4
  import { i as resolveAuthMountPath } from "./application-path-zKi7NrvK.js";
3
5
  import { a as setRequestFetchResolver, i as setNuxtErrorFactory, n as setDefaultAuthBasePath, o as setSessionSeedResolver, r as setNuxtAppResolver, s as setSignOutHandler, t as authNuxtBridge } from "./nuxt-bridge-pRyfYD5c.js";
4
6
  import abilities from "#vitehub/auth/abilities";
5
7
  import { computed, defineComponent, effectScope, getCurrentInstance, getCurrentScope, inject, onScopeDispose, onServerPrefetch, provide, shallowRef, watch } from "vue";
8
+ // src/client-extension.ts
9
+ /**
10
+ * A part of the Auth client options: Better Auth client plugins that a Nuxt layer, or the app, adds to the options of
11
+ * `auth.client.ts`. Export it as the default export of `auth.client.extend.ts`, which is in `app/` in a Nuxt app.
12
+ */
13
+ function extendAuthClient(options) {
14
+ const option = Object.keys(options).find((key) => key !== "plugins");
15
+ if (option) throw authErrorDiagnostics.AUTH_EXTENSION_OPTION_INVALID({
16
+ file: "`extendAuthClient()`",
17
+ option
18
+ });
19
+ return { extension: options };
20
+ }
21
+ const pluginIds = (options) => (options?.plugins ?? []).map((plugin) => plugin.id);
22
+ /** The client options with the plugins of their parts: the options first, then each part in the order of `extensions`. */
23
+ function applyAuthClientExtensions(options, extensions = []) {
24
+ if (!extensions.length) return options;
25
+ const sources = [{
26
+ file: "auth.client.ts",
27
+ options
28
+ }, ...extensions.map(({ file, extension }) => ({
29
+ file,
30
+ options: extension.extension
31
+ }))];
32
+ assertUniquePluginIds(sources.map((source) => ({
33
+ file: source.file,
34
+ ids: pluginIds(source.options)
35
+ })));
36
+ return {
37
+ ...options,
38
+ plugins: sources.flatMap((source) => source.options?.plugins ?? [])
39
+ };
40
+ }
6
41
  // src/vue.ts
7
42
  const LOAD = Symbol.for("vitehub.auth.client.load");
8
43
  const ON_LOAD = Symbol.for("vitehub.auth.client.on-load");
@@ -402,8 +437,8 @@ function defineAuthClient(options) {
402
437
  * Auth Definition's `basePath` below the `app.baseURL` of the page, also when `NUXT_APP_BASE_URL` sets it at runtime.
403
438
  */
404
439
  const authClient = createLazyAuthClient(async () => {
405
- const { default: options } = await import("#vitehub/auth/client");
406
- return withDefaultBasePath(options);
440
+ const { default: options, extensions } = await import("#vitehub/auth/client");
441
+ return withDefaultBasePath(applyAuthClientExtensions(options, extensions));
407
442
  });
408
443
  /** Provide the app's configured client to Auth composables and `<AuthPermission>` in descendant components. */
409
444
  function provideAuthClient(client) {
@@ -605,4 +640,4 @@ const AuthPermission = defineComponent({
605
640
  };
606
641
  }
607
642
  });
608
- export { AuthPermission, authClient, createAuthClient, defineAuthClient, loadAuthClient, onSignOut, provideAuthClient, setDefaultAuthBasePath, setNuxtAppResolver, setNuxtErrorFactory, setRequestFetchResolver, setSessionSeedResolver, setSignOutHandler, useAbility, useAuthClient, useUserSession };
643
+ export { AuthPermission, authClient, createAuthClient, defineAuthClient, extendAuthClient, loadAuthClient, onSignOut, provideAuthClient, setDefaultAuthBasePath, setNuxtAppResolver, setNuxtErrorFactory, setRequestFetchResolver, setSessionSeedResolver, setSignOutHandler, useAbility, useAuthClient, useUserSession };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/auth",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "Better Auth-powered authentication primitives and Vite integration for ViteHub.",
5
5
  "keywords": [
6
6
  "auth",
@@ -144,10 +144,11 @@
144
144
  "dependencies": {
145
145
  "@noble/hashes": "^2.4.0",
146
146
  "@types/node": "^24.19.2",
147
- "@vite-hub/env": "0.6.1",
148
- "@vite-hub/runtime": "0.6.1",
149
- "@vite-hub/web-container": "0.6.1",
147
+ "@vite-hub/env": "0.8.0",
148
+ "@vite-hub/runtime": "0.8.0",
149
+ "@vite-hub/web-container": "0.8.0",
150
150
  "better-auth": "^1.7.27",
151
+ "better-auth-rou3": "npm:rou3@0.9.2",
151
152
  "h3": "^2.0.8",
152
153
  "nostics": "1.4.0",
153
154
  "rou3": "^1.0.0",
@@ -165,8 +166,8 @@
165
166
  "@types/json-schema": "^7.0.15",
166
167
  "@types/mdast": "^4.0.4",
167
168
  "@types/node": "^24.19.2",
168
- "@vite-hub/agent": "0.6.1",
169
- "@vite-hub/database": "0.6.1",
169
+ "@vite-hub/agent": "0.8.0",
170
+ "@vite-hub/database": "0.8.0",
170
171
  "@vite-hub/internal": "0.0.1",
171
172
  "bun-types": "^1.4.5",
172
173
  "evlog": "2.37.1",
@@ -189,8 +190,8 @@
189
190
  "@better-auth/oauth-provider": "^1.7.27",
190
191
  "@types/json-schema": "^7.0.15",
191
192
  "@types/mdast": "^4.0.4",
192
- "@vite-hub/agent": "0.6.1",
193
- "@vite-hub/database": "0.6.1",
193
+ "@vite-hub/agent": "0.8.0",
194
+ "@vite-hub/database": "0.8.0",
194
195
  "nitro": "3.0.261102-rc || ^3.0.261103-rc",
195
196
  "vite": ">=8.0.0",
196
197
  "vue": "^3.5.0",
@@ -1,52 +0,0 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- // ../internal/src/runtime/request-origin.ts
3
- function firstHeaderValue(headers, name) {
4
- return headers.get(name)?.split(",", 1)[0]?.trim() || void 0;
5
- }
6
- /**
7
- * The origin that the client used for `request`. A TLS-terminating proxy sends the client scheme in
8
- * `X-Forwarded-Proto` and the client host in `X-Forwarded-Host`. Each proxy appends its value, so the first value wins.
9
- * Without these headers, or with values that are not valid, the result is the origin of `request.url`.
10
- */
11
- function forwardedRequestOrigin(request) {
12
- const url = new URL(request.url);
13
- const forwardedProtocol = firstHeaderValue(request.headers, "x-forwarded-proto")?.toLowerCase();
14
- const protocol = forwardedProtocol === "http" || forwardedProtocol === "https" ? forwardedProtocol : url.protocol.slice(0, -1);
15
- const host = firstHeaderValue(request.headers, "x-forwarded-host") ?? url.host;
16
- if (/[\u0000-\u001F\s/\\?#@]/.test(host)) return url.origin;
17
- try {
18
- return new URL(`${protocol}://${host}`).origin;
19
- } catch {
20
- return url.origin;
21
- }
22
- }
23
- // src/client-request.ts
24
- const storageKey = Symbol.for("vitehub.auth.client-request");
25
- const runtimeGlobal = globalThis;
26
- const clientRequests = runtimeGlobal[storageKey] ||= new AsyncLocalStorage();
27
- function isRelativeInProcessRequest(request, client) {
28
- const url = new URL(request.url);
29
- if (url.protocol !== "http:") return false;
30
- if (url.host === "localhost") return true;
31
- const clientUrl = new URL(client.url);
32
- url.protocol = clientUrl.protocol;
33
- return url.host === clientUrl.host;
34
- }
35
- function runWithClientRequest(request, next) {
36
- const client = clientRequests.getStore();
37
- return client && isRelativeInProcessRequest(request, client) ? next() : clientRequests.run(request, next);
38
- }
39
- /**
40
- * Nitro builds a relative request that the server sends to itself, such as a Nuxt `useFetch()` during server rendering
41
- * or `serverFetch("/api/...")`, at `http://localhost` or `http://<forwarded Host>`, so the URL of that request does not
42
- * show the origin of the page.
43
- */
44
- function clientRequest(request) {
45
- const client = clientRequests.getStore();
46
- return client && isRelativeInProcessRequest(request, client) ? client : request;
47
- }
48
- function clientRequestOrigin(request, trustProxyHeaders = false) {
49
- const client = clientRequest(request);
50
- return trustProxyHeaders ? forwardedRequestOrigin(client) : new URL(client.url).origin;
51
- }
52
- export { forwardedRequestOrigin as i, clientRequestOrigin as n, runWithClientRequest as r, clientRequest as t };
@@ -1,28 +0,0 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
2
- // src/database-options.ts
3
- /** Reads the adapter's target without loading Better Auth or the Database runtime. */
4
- function authDatabaseName(database) {
5
- if (typeof database !== "function") return;
6
- const name = Reflect.get(database, "vitehubDatabase");
7
- return typeof name === "string" ? name : void 0;
8
- }
9
- /** The owned schema has text IDs and references, with no database-generated default. */
10
- function assertAuthDatabaseIdStrategy(generateId) {
11
- if (generateId === "serial" || generateId === "uuid" || generateId === false) throw authErrorDiagnostics.AUTH_C0053({ message: "`authDatabase()` owns tables with text IDs. Use Better Auth's default ID generator or a custom function returning strings; `advanced.database.generateId` cannot be `serial`, `uuid`, or `false`. Use another Better Auth adapter to own a different ID schema." });
12
- }
13
- /** The Auth Vite plugin reads `additionalFields` from the Definition to add their columns, so they must be static. */
14
- function authDatabaseAdditionalFieldsError(detail) {
15
- return authErrorDiagnostics.AUTH_C0055({ message: `\`authDatabase()\` adds a column for each additional field, but ${detail}.` });
16
- }
17
- /** The Better Auth options need a table, a column, or a name that the Database of `authDatabase()` does not have. */
18
- function authDatabaseSchemaError(detail) {
19
- return authErrorDiagnostics.AUTH_C0056({ message: `\`authDatabase()\` cannot store the Better Auth options: ${detail}.` });
20
- }
21
- function authDatabasePlacementError() {
22
- return authErrorDiagnostics.AUTH_C0054({ message: "`authDatabase()` needs one statically invariant Database: call it inline as `defineAuth()`'s `database`, in an object or a callback's single unconditional returned object. Do not select it in branches." });
23
- }
24
- /** Outside a development server, Auth keeps users in memory only when the Definition asks for it. */
25
- function authMemoryDatabaseError() {
26
- return authErrorDiagnostics.AUTH_C0063({ message: "`defineAuth()` has no `database` or `preset`. Auth keeps users and sessions in memory only on a development server, because a restart or a second instance loses them." });
27
- }
28
- export { authDatabaseSchemaError as a, authDatabasePlacementError as i, authDatabaseAdditionalFieldsError as n, authMemoryDatabaseError as o, authDatabaseName as r, assertAuthDatabaseIdStrategy as t };