@vite-hub/auth 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -6
- package/dist/{abilities-CfvuGrBv.d.ts → abilities-6LE7VSdN.d.ts} +1 -1
- package/dist/abilities.d.ts +1 -1
- package/dist/{ability-error-OKoyOwPM.js → ability-error-Ccm5Iy4F.js} +1 -1
- package/dist/{access-pages-Bej95blM.js → access-pages-lQGfRvfL.js} +1 -4
- package/dist/{admin-claim-code-C3X_U43x.js → admin-claim-code-CMa0eRRm.js} +0 -1
- package/dist/agent.js +11 -11
- package/dist/{application-path-zKi7NrvK.js → application-path-LMc_ptL9.js} +0 -2
- package/dist/{auth-instance-5RSiFTDC.js → auth-instance-0PTsOttV.js} +41 -57
- package/dist/bun-sqlite.d.ts +0 -2
- package/dist/cli.js +2 -2
- package/dist/client-extension-BVBVUqa1.d.ts +33 -0
- package/dist/client-request-B1DCz3a9.js +29 -0
- package/dist/{console-runtime-Bg_PAl7e.js → console-runtime-BlOx9hWC.js} +3 -19
- package/dist/{console-runtime-XcplYv4R.d.ts → console-runtime-D2FUATXQ.d.ts} +1 -1
- package/dist/console-runtime.d.ts +2 -2
- package/dist/console-runtime.js +1 -1
- package/dist/console.d.ts +1 -1
- package/dist/database-options-CPhnGap9.js +36 -0
- package/dist/{database-schema-options-CCQsNhjc.js → database-schema-options-BQyynyhw.js} +1 -1
- package/dist/database.d.ts +1 -1
- package/dist/database.js +22 -11
- package/dist/{definition-DeEeqTLC.js → definition-CvmvHaQT.js} +4 -12
- package/dist/{error-diagnostics-DkzL9ltR.js → error-diagnostics-BpQy1iIO.js} +35 -4
- package/dist/{events-BUaoHFoC.js → events-aP_Rz_gx.js} +1 -1
- package/dist/extension-B35v_o1u.js +133 -0
- package/dist/extension-C2giF7w2.d.ts +59 -0
- package/dist/forward.d.ts +0 -5
- package/dist/forward.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/dist/internal/server.d.ts +3 -3
- package/dist/internal/server.js +5 -5
- package/dist/{mcp-config-C7srUMIZ.js → mcp-config-DYlTXmr6.js} +9 -1
- package/dist/{mcp-token-DG1jmw4o.d.ts → mcp-token-CxpopXmK.d.ts} +4 -2
- package/dist/{mcp-token-DgveSGEl.js → mcp-token-i-8NMulH.js} +28 -6
- package/dist/mcp.d.ts +2 -7
- package/dist/mcp.js +26 -7
- package/dist/{members-CRlYyxVk.js → members-USm08YwK.js} +4 -6
- package/dist/nuxt.d.ts +4 -14
- package/dist/nuxt.js +29 -61
- package/dist/{own-access-BvVUjaeL.d.ts → own-access-B7VRd92K.d.ts} +1 -1
- package/dist/presets.js +1 -1
- package/dist/{request-Dpq7GO8B.js → request-CdlcvqVc.js} +0 -1
- package/dist/runtime/client-request-plugin.d.ts +2 -1
- package/dist/runtime/client-request-plugin.js +8 -5
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/empty-abilities.d.ts +1 -1
- package/dist/runtime/empty-client.d.ts +3 -0
- package/dist/runtime/empty-client.js +3 -1
- package/dist/runtime/empty-definition.d.ts +1 -1
- package/dist/runtime/server.d.ts +4 -3
- package/dist/runtime/server.js +5 -4
- package/dist/runtime/vue-nuxt.js +2 -18
- package/dist/schema.d.ts +32 -17
- package/dist/schema.js +39 -16
- package/dist/{server-1G_BbfBD.d.ts → server-4_EXgXFn.d.ts} +25 -8
- package/dist/{server-iQNOXyfS.js → server-CZR2dVVp.js} +43 -352
- package/dist/{server-B8kTFrHP.d.ts → server-DAIBBKbR.d.ts} +3 -2
- package/dist/server.d.ts +3 -3
- package/dist/server.js +4 -4
- package/dist/{session-cookies-DN0svCKj.js → session-cookies-CfXdF1yd.js} +5 -33
- package/dist/{set-cookie-CMB3t4NF.js → set-cookie-BYZslovs.js} +1 -1
- package/dist/{table-specs-C3-bLOSF.js → table-specs-Cvjc_Ccs.js} +28 -2
- package/dist/{table-specs-P4LvbOlX.d.ts → table-specs-VYAy_jJ7.d.ts} +5 -2
- package/dist/test.d.ts +1 -1
- package/dist/test.js +2 -2
- package/dist/{types-BmRGse4l.d.ts → types-DakualFJ.d.ts} +20 -4
- package/dist/vite-CZ_Z6IR3.d.ts +28 -0
- package/dist/{vite-GRzej8Cs.js → vite-DVvWaN3D.js} +652 -301
- package/dist/vite.d.ts +35 -17
- package/dist/vite.js +1 -1
- package/dist/vue.d.ts +4 -34
- package/dist/vue.js +40 -66
- package/package.json +9 -8
- package/dist/client-request-BzMKtfCY.js +0 -52
- package/dist/database-options-DE9lMwu1.js +0 -28
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import {
|
|
2
|
+
import { r as resolveNuxtAuthDiscovery } from "./vite-CZ_Z6IR3.js";
|
|
3
|
+
import { V as DiscoveredAuthDefinition, W as ResolvedAuthViteConfig, w as AuthOptions } from "./types-DakualFJ.js";
|
|
3
4
|
import { n as ViteHubCliPluginMetadata } from "./cli-DL7uCAvz.js";
|
|
4
5
|
import { Plugin } from "vite";
|
|
5
6
|
interface ViteHubDefinitionField {
|
|
@@ -63,23 +64,17 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
|
|
|
63
64
|
interface ViteHubInspectionPluginMetadata {
|
|
64
65
|
inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
viteRoot?: string;
|
|
69
|
-
serverDirs?: readonly string[];
|
|
70
|
-
}): {
|
|
71
|
-
definition: DiscoveredAuthDefinition;
|
|
72
|
-
rootDir: string;
|
|
73
|
-
} | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* Whether the Auth Definition of the project keeps users in the app Database with `authDatabase()`. ViteHub turns the
|
|
76
|
-
* Database on for it, as it does for Connections.
|
|
77
|
-
*/
|
|
78
|
-
export declare function usesAuthDatabase(project: Parameters<typeof discoverProjectAuthDefinition>[0]): boolean;
|
|
79
|
-
export declare function resolveAuthViteConfig(options?: AuthOptions, rootDir?: string, discovery?: {
|
|
67
|
+
type LayerRootsByAlias = Readonly<Record<string, string>>;
|
|
68
|
+
interface AuthDiscovery {
|
|
80
69
|
projectRoot?: string;
|
|
81
70
|
serverDirs?: readonly string[];
|
|
82
|
-
|
|
71
|
+
layerAliases?: LayerRootsByAlias;
|
|
72
|
+
}
|
|
73
|
+
export declare function usesAuthDatabase(project: AuthDiscovery & {
|
|
74
|
+
projectRoot: string;
|
|
75
|
+
viteRoot?: string;
|
|
76
|
+
}): boolean;
|
|
77
|
+
export declare function resolveAuthViteConfig(options?: AuthOptions, rootDir?: string, discovery?: AuthDiscovery): ResolvedAuthViteConfig | undefined;
|
|
83
78
|
/** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
|
|
84
79
|
type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
|
|
85
80
|
/**
|
|
@@ -122,6 +117,21 @@ interface ContributionContext {
|
|
|
122
117
|
/** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
|
|
123
118
|
plugins?: readonly unknown[];
|
|
124
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* The parts of the Auth Definition, `server/auth.extend.ts`: the file of the application first, then the files of
|
|
122
|
+
* Nuxt layers in priority order.
|
|
123
|
+
*/
|
|
124
|
+
export declare function discoverAuthExtensions(rootDir: string, options?: {
|
|
125
|
+
serverDirs?: readonly string[];
|
|
126
|
+
}): string[];
|
|
127
|
+
export declare function discoverProjectAuthDefinition(project: {
|
|
128
|
+
projectRoot: string;
|
|
129
|
+
viteRoot?: string;
|
|
130
|
+
serverDirs?: readonly string[];
|
|
131
|
+
}): {
|
|
132
|
+
definition: DiscoveredAuthDefinition;
|
|
133
|
+
rootDir: string;
|
|
134
|
+
} | undefined;
|
|
125
135
|
export declare const AUTH_ABILITIES_ID = "#vitehub/auth/abilities";
|
|
126
136
|
export declare const AUTH_CLIENT_ID = "#vitehub/auth/client";
|
|
127
137
|
export declare const AUTH_DEFINITION_ID = "#vitehub/auth/definition";
|
|
@@ -144,11 +154,13 @@ export interface AuthDatabaseContribution {
|
|
|
144
154
|
name: "auth";
|
|
145
155
|
database: string;
|
|
146
156
|
dialect: "postgresql" | "sqlite";
|
|
147
|
-
/** The
|
|
157
|
+
/** The generated module of the Auth tables, with the plugins and additional fields of the Definition. */
|
|
148
158
|
definition: {
|
|
149
159
|
module: string;
|
|
150
160
|
export: "authPostgresSchema" | "authSqliteSchema";
|
|
151
161
|
};
|
|
162
|
+
/** The export of `definition.module` with the Drizzle relations of the Auth tables. */
|
|
163
|
+
relations: "authPostgresRelations" | "authSqliteRelations";
|
|
152
164
|
/** The schema keys and SQL names of the tables, so the Database lists them without loading the schema module. */
|
|
153
165
|
tables: Readonly<Record<string, string>>;
|
|
154
166
|
reason: string;
|
|
@@ -159,14 +171,20 @@ export type AuthVitePlugin = Plugin & {
|
|
|
159
171
|
databases: (context: AuthDatabaseContributionContext) => Promise<AuthDatabaseContribution[]>;
|
|
160
172
|
};
|
|
161
173
|
};
|
|
174
|
+
/** The specifiers of the Auth tables. Each host resolves them to the generated module, so an app imports the tables that Auth adds. */
|
|
175
|
+
export declare const authSchemaSpecifiers: readonly ["@vite-hub/auth/schema", "vite-hub/auth/schema"];
|
|
176
|
+
/** The generated module of the Auth tables, which `authSchemaSpecifiers` resolve to when the Definition uses `authDatabase()`. */
|
|
177
|
+
export declare function authSchemaModule(config: Pick<ResolvedAuthViteConfig, "projectRoot">): string;
|
|
162
178
|
export declare function createAuthNitroConfig(plugin: AuthVitePlugin, options: {
|
|
163
179
|
nitro: Record<string, unknown>;
|
|
164
180
|
projectRoot: string;
|
|
165
181
|
serverDirs?: string[];
|
|
182
|
+
nuxtDiscovery?: ReturnType<typeof resolveNuxtAuthDiscovery>;
|
|
166
183
|
}): Record<string, unknown>;
|
|
167
184
|
interface InternalAuthModuleOptions {
|
|
168
185
|
databaseDisabled?: boolean;
|
|
169
186
|
importBase?: string;
|
|
187
|
+
layerAliases?: Readonly<Record<string, string>>;
|
|
170
188
|
}
|
|
171
189
|
export declare function writeNuxtAuthDefinition(root: string, config: ResolvedAuthViteConfig): Promise<string>;
|
|
172
190
|
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,
|
|
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-DVvWaN3D.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-
|
|
3
|
-
import { S as AuthFor, _ as AuthDefinition } from "./types-
|
|
2
|
+
import { a as AbilityRefusal, i as AbilityName, t as AbilityArgs } from "./abilities-6LE7VSdN.js";
|
|
3
|
+
import { S as AuthFor, _ as AuthDefinition } from "./types-DakualFJ.js";
|
|
4
|
+
import { a as extendAuthClient, i as ExtendedAuthClientOptions, n as AuthClientExtensionOptions, t as AuthClientExtension } from "./client-extension-BVBVUqa1.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";
|
|
@@ -56,10 +57,6 @@ export declare function setSessionSeedResolver(resolver: ((read: boolean) => unk
|
|
|
56
57
|
* `undefined` outside a request.
|
|
57
58
|
*/
|
|
58
59
|
export declare function setRequestFetchResolver(resolver: (() => RequestFetch | undefined) | undefined): void;
|
|
59
|
-
/**
|
|
60
|
-
* The members of a client that the composables read. Every Better Auth Vue client has them. `VueAuthClient<any>`
|
|
61
|
-
* rejects a client with a required additional field, because its `signUp.email()` needs that field.
|
|
62
|
-
*/
|
|
63
60
|
type AuthClientLike = Pick<VueAuthClient$1<{}>, "$fetch" | "getSession"> & {
|
|
64
61
|
$Infer: {
|
|
65
62
|
Session: {
|
|
@@ -98,22 +95,15 @@ export declare function loadAuthClient<Client extends AuthClientLike>(client: Cl
|
|
|
98
95
|
export declare function defineAuthClient<Option extends BetterAuthClientOptions>(options: Option): Option;
|
|
99
96
|
declare global {
|
|
100
97
|
namespace ViteHub {
|
|
101
|
-
/** Generated declarations set `client` to the type of the options in the app's `auth.client.ts`. */
|
|
102
98
|
interface AuthRegistry {}
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
|
-
/** The client options that generated declarations register from the app's `auth.client.ts`. Without one, none. */
|
|
106
101
|
type RegisteredClientOptions<TRegistry> = TRegistry extends {
|
|
107
102
|
client: infer TOptions;
|
|
108
103
|
} ? 0 extends 1 & TOptions ? {} : TOptions extends BetterAuthClientOptions ? TOptions : {} : {};
|
|
109
|
-
/** The fields that a server plugin's `schema` adds to one table. A plugin without a `schema`, such as `bearer()`, adds none. */
|
|
110
104
|
type ServerPluginTableFields<TSchema, TTable extends "session" | "user"> = TSchema extends { [Key in TTable]: {
|
|
111
105
|
fields: infer TFields extends Record<string, unknown>;
|
|
112
106
|
}; } ? TFields : {};
|
|
113
|
-
/**
|
|
114
|
-
* The endpoints of a server plugin that change the session response, such as the `getSession` of `customSession()`.
|
|
115
|
-
* Better Auth marks them with `CUSTOM_SESSION`. The client keeps no other plugin endpoint.
|
|
116
|
-
*/
|
|
117
107
|
type ServerPluginSessionEndpoints<TEndpoints> = { [Key in keyof TEndpoints as TEndpoints[Key] extends {
|
|
118
108
|
options: {
|
|
119
109
|
metadata: {
|
|
@@ -121,10 +111,6 @@ type ServerPluginSessionEndpoints<TEndpoints> = { [Key in keyof TEndpoints as TE
|
|
|
121
111
|
};
|
|
122
112
|
};
|
|
123
113
|
} ? Key : never]: TEndpoints[Key]; };
|
|
124
|
-
/**
|
|
125
|
-
* A type-only client plugin with the user and session fields of one server plugin, such as the `role` of `admin()`,
|
|
126
|
-
* and the session response of `customSession()`. It keeps only these, so every server plugin gives a valid client plugin.
|
|
127
|
-
*/
|
|
128
114
|
type ServerPluginFields<TPlugin> = TPlugin extends {
|
|
129
115
|
id: infer Id extends string;
|
|
130
116
|
schema?: infer Schema;
|
|
@@ -143,10 +129,6 @@ type ServerPluginFields<TPlugin> = TPlugin extends {
|
|
|
143
129
|
};
|
|
144
130
|
};
|
|
145
131
|
} : never;
|
|
146
|
-
/**
|
|
147
|
-
* Client options with type-only plugins: Better Auth's `inferAdditionalFields()` for `user.additionalFields` and
|
|
148
|
-
* `session.additionalFields`, and the fields of each server plugin.
|
|
149
|
-
*/
|
|
150
132
|
type ServerFieldsClientOptions<TAuth extends {
|
|
151
133
|
options: {
|
|
152
134
|
plugins?: readonly unknown[];
|
|
@@ -154,11 +136,9 @@ type ServerFieldsClientOptions<TAuth extends {
|
|
|
154
136
|
}> = {
|
|
155
137
|
plugins: Array<ReturnType<typeof inferAdditionalFields<TAuth>> | ServerPluginFields<NonNullable<TAuth["options"]["plugins"]>[number]>>;
|
|
156
138
|
};
|
|
157
|
-
/** The plugins of client options, such as the `adminClient()` of `auth.client.ts`. */
|
|
158
139
|
type ClientOptionsPlugins<TOptions> = TOptions extends {
|
|
159
140
|
plugins?: infer TPlugins;
|
|
160
141
|
} ? TPlugins extends readonly (infer TPlugin)[] ? TPlugin : never : never;
|
|
161
|
-
/** The type-only plugins with the fields of the registered Auth Definition and its server plugins. Without one, none. */
|
|
162
142
|
type RegisteredServerFieldsPlugins<TRegistry> = TRegistry extends {
|
|
163
143
|
definition: infer TDefinition extends AuthDefinition;
|
|
164
144
|
} ? 0 extends 1 & TDefinition ? never : ServerFieldsClientOptions<AuthFor<TDefinition>>["plugins"][number] : never;
|
|
@@ -170,23 +150,14 @@ type RegisteredServerFieldsPlugins<TRegistry> = TRegistry extends {
|
|
|
170
150
|
export type RegisteredAuthClient<TRegistry = ViteHub.AuthRegistry> = ServerFieldsClient<Omit<RegisteredClientOptions<TRegistry>, "plugins"> & {
|
|
171
151
|
plugins: Array<ClientOptionsPlugins<RegisteredClientOptions<TRegistry>> | RegisteredServerFieldsPlugins<TRegistry>>;
|
|
172
152
|
}>;
|
|
173
|
-
/** A client that Better Auth cannot type with these options keeps the plain fields, so `user` never becomes `never`. */
|
|
174
153
|
type ServerFieldsClient<TOptions> = TOptions extends BetterAuthClientOptions ? VueAuthClient$1<TOptions> : VueAuthClient$1<{}>;
|
|
175
|
-
/**
|
|
176
|
-
* The client that the composables and the Nuxt page guard share. On first use, it loads `better-auth/vue` and the app's
|
|
177
|
-
* `auth.client.ts` together, and the options of that file replace the defaults. In Nuxt, the default `basePath` is the
|
|
178
|
-
* Auth Definition's `basePath` below the `app.baseURL` of the page, also when `NUXT_APP_BASE_URL` sets it at runtime.
|
|
179
|
-
*/
|
|
180
154
|
export declare const authClient: RegisteredAuthClient;
|
|
181
155
|
/** Provide the app's configured client to Auth composables and `<AuthPermission>` in descendant components. */
|
|
182
156
|
export declare function provideAuthClient(client: AuthClientLike): void;
|
|
183
157
|
export declare function useAuthClient(): typeof authClient;
|
|
184
158
|
type ClientSession<Client extends AuthClientLike> = Client["$Infer"]["Session"];
|
|
185
|
-
/** Better Auth's `signOut()` of `Client`. */
|
|
186
159
|
type ClientSignOut<Client extends AuthClientLike> = Extract<Client["signOut"], (...args: never) => unknown>;
|
|
187
|
-
/** The parameters of Better Auth's `signOut()` of `Client`. */
|
|
188
160
|
type SignOutParameters<Client extends AuthClientLike> = Parameters<ClientSignOut<Client>>;
|
|
189
|
-
/** The result of Better Auth's `signOut()` of `Client`. */
|
|
190
161
|
type SignOutResult<Client extends AuthClientLike> = ReturnType<ClientSignOut<Client>>;
|
|
191
162
|
/** The options of `signOut()` from `useUserSession()`: the options of Better Auth's `signOut()`, and `redirectTo`. */
|
|
192
163
|
export type SignOutOptions<Client extends AuthClientLike = typeof authClient> = NonNullable<SignOutParameters<Client>[0]> & {
|
|
@@ -268,7 +239,6 @@ export interface Ability {
|
|
|
268
239
|
* await authorize("posts.edit", loadedPost)
|
|
269
240
|
*/
|
|
270
241
|
export declare function useAbility(client?: AuthClientLike): Ability;
|
|
271
|
-
/** The rule arguments use the same tuple as the server check. */
|
|
272
242
|
type PermissionArguments<Args extends unknown[]> = [] extends Args ? {
|
|
273
243
|
args?: Args;
|
|
274
244
|
} : {
|
|
@@ -291,4 +261,4 @@ export type AuthPermissionComponent = <const Name extends AbilityName>(props: Au
|
|
|
291
261
|
};
|
|
292
262
|
/** Render the allowed or denied slot. The default slot is shorthand for allowed. */
|
|
293
263
|
export declare const AuthPermission: AuthPermissionComponent;
|
|
294
|
-
export type
|
|
264
|
+
export { type AuthClientExtension, type AuthClientExtensionOptions, type ExtendedAuthClientOptions, type RequestFetch, type VueAuthClient, extendAuthClient };
|
package/dist/vue.js
CHANGED
|
@@ -1,15 +1,49 @@
|
|
|
1
|
-
import { n as checkAbility, t as AbilityError } from "./ability-error-
|
|
2
|
-
import {
|
|
1
|
+
import { n as checkAbility, t as AbilityError } from "./ability-error-Ccm5Iy4F.js";
|
|
2
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-BpQy1iIO.js";
|
|
3
|
+
import { n as assertUniquePluginIds } from "./extension-B35v_o1u.js";
|
|
4
|
+
import { i as resolveAuthMountPath } from "./application-path-LMc_ptL9.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");
|
|
9
44
|
const OPTIONS = Symbol.for("vitehub.auth.client.options");
|
|
10
45
|
const authClientKey = Symbol("vitehub.auth.client");
|
|
11
46
|
const signOutListeners = /* @__PURE__ */ new Set();
|
|
12
|
-
/** The state of a client hook, such as `useSession()`, before Better Auth's client has loaded. */
|
|
13
47
|
const pendingState = (refetch) => ({
|
|
14
48
|
data: null,
|
|
15
49
|
error: null,
|
|
@@ -30,20 +64,12 @@ const pendingState = (refetch) => ({
|
|
|
30
64
|
* During Nuxt server rendering, a call such as `listSessions()` reaches the app in-process with the visitor's cookie.
|
|
31
65
|
*/
|
|
32
66
|
const createAuthClient = (options) => createLazyAuthClient(() => withDefaultBasePath(options), () => options);
|
|
33
|
-
/**
|
|
34
|
-
* The options with ViteHub's default `basePath` when they set none: in Nuxt, the Auth Definition's `basePath` below
|
|
35
|
-
* `app.baseURL`. Read when Better Auth loads, after the Nuxt module set it.
|
|
36
|
-
*/
|
|
37
67
|
function withDefaultBasePath(options) {
|
|
38
68
|
return {
|
|
39
69
|
basePath: authNuxtBridge.defaultBasePath ?? resolveAuthMountPath("/api/auth"),
|
|
40
70
|
...options
|
|
41
71
|
};
|
|
42
72
|
}
|
|
43
|
-
/**
|
|
44
|
-
* The client of `createAuthClient()`. It runs `resolveOptions` when it loads Better Auth. `knownOptions` returns the
|
|
45
|
-
* options known before the load, such as `sessionOptions`, without loading anything.
|
|
46
|
-
*/
|
|
47
73
|
function createLazyAuthClient(resolveOptions, knownOptions = () => void 0) {
|
|
48
74
|
let loaded;
|
|
49
75
|
let betterAuth;
|
|
@@ -62,11 +88,6 @@ function createLazyAuthClient(resolveOptions, knownOptions = () => void 0) {
|
|
|
62
88
|
else onLoad.add(run);
|
|
63
89
|
};
|
|
64
90
|
const requestClients = /* @__PURE__ */ new WeakMap();
|
|
65
|
-
/**
|
|
66
|
-
* Better Auth's client for a call. On the server, during a request, it calls the app in-process with the visitor's
|
|
67
|
-
* cookie. A client with its own `baseURL` or `customFetchImpl` keeps them. Call it before the caller's first `await`,
|
|
68
|
-
* because only the caller's frame knows the request.
|
|
69
|
-
*/
|
|
70
91
|
function loadForCall() {
|
|
71
92
|
const request = "window" in globalThis ? void 0 : authNuxtBridge.requestFetchResolver?.();
|
|
72
93
|
if (!request) return load();
|
|
@@ -135,18 +156,11 @@ function createLazyAuthClient(resolveOptions, knownOptions = () => void 0) {
|
|
|
135
156
|
function isPendingWithoutData(value) {
|
|
136
157
|
return typeof value === "object" && value !== null && Reflect.get(value, "isPending") === true && !Reflect.get(value, "data");
|
|
137
158
|
}
|
|
138
|
-
/** Run `run` in the scope the hook was called in, so its watchers stop with the component that called it. */
|
|
139
159
|
function runIn(scope, run) {
|
|
140
160
|
return scope ? scope.run(run) : run();
|
|
141
161
|
}
|
|
142
|
-
/** The owner of the stores in the browser: one page has one session per client. */
|
|
143
162
|
const browserOwner = {};
|
|
144
163
|
const stores = /* @__PURE__ */ new WeakMap();
|
|
145
|
-
/**
|
|
146
|
-
* The session store of `client` for the current app. The browser has one store per client. The server has one per
|
|
147
|
-
* request, through the request's Nuxt app or Vue app, so two requests never share a session. On the server, a call
|
|
148
|
-
* outside an app, such as at module scope, gets a store of its own.
|
|
149
|
-
*/
|
|
150
164
|
function sessionStore(client) {
|
|
151
165
|
const browser = "window" in globalThis;
|
|
152
166
|
const app = browser ? void 0 : authNuxtBridge.nuxtAppResolver?.();
|
|
@@ -187,7 +201,6 @@ function createSessionStore(client, app, initialRead) {
|
|
|
187
201
|
async function refetch(query) {
|
|
188
202
|
await read(query);
|
|
189
203
|
}
|
|
190
|
-
/** Settles the state with the server's session. A promise of it, such as a read still in flight, is the read. */
|
|
191
204
|
function seed(read) {
|
|
192
205
|
if (seeded) return;
|
|
193
206
|
const value = authNuxtBridge.sessionSeedResolver?.(read);
|
|
@@ -205,17 +218,12 @@ function createSessionStore(client, app, initialRead) {
|
|
|
205
218
|
function serverRead() {
|
|
206
219
|
return !browser && state.value.isPending ? serverReading : void 0;
|
|
207
220
|
}
|
|
208
|
-
/** Makes `read` the read that callers share, until it ends or `clear()` runs. */
|
|
209
221
|
function share(read) {
|
|
210
222
|
const shared = read.finally(() => {
|
|
211
223
|
if (reading === shared) reading = void 0;
|
|
212
224
|
});
|
|
213
225
|
return shared;
|
|
214
226
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Follows Better Auth's session atom with one watcher. It runs when Better Auth loads, before the first call of the
|
|
217
|
-
* client runs, so the session signal of that call, such as after `signOut()`, reaches the state.
|
|
218
|
-
*/
|
|
219
227
|
function connect(loaded) {
|
|
220
228
|
if (atom) return atom;
|
|
221
229
|
stopWaking?.();
|
|
@@ -242,11 +250,6 @@ function createSessionStore(client, app, initialRead) {
|
|
|
242
250
|
});
|
|
243
251
|
return atom;
|
|
244
252
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Waits for the session signal of a client that loaded before the store, such as one from `loadAuthClient()`, and then
|
|
247
|
-
* follows its session atom. Better Auth sends the signal after a call that changes the session, such as a sign-in.
|
|
248
|
-
* Waiting costs no read.
|
|
249
|
-
*/
|
|
250
253
|
function followSignal(loaded) {
|
|
251
254
|
const signal = storeAtom(loaded, "$sessionSignal");
|
|
252
255
|
if (!signal) {
|
|
@@ -255,7 +258,6 @@ function createSessionStore(client, app, initialRead) {
|
|
|
255
258
|
}
|
|
256
259
|
stopSignal = signal.listen(() => void connect(loaded));
|
|
257
260
|
}
|
|
258
|
-
/** Loads Better Auth in the browser and follows its session atom. */
|
|
259
261
|
async function follow() {
|
|
260
262
|
return atom ?? connect(await loadAuthClient(client));
|
|
261
263
|
}
|
|
@@ -320,15 +322,10 @@ function createSessionStore(client, app, initialRead) {
|
|
|
320
322
|
scope
|
|
321
323
|
};
|
|
322
324
|
}
|
|
323
|
-
/**
|
|
324
|
-
* An atom of Better Auth's `$store` of a loaded client, such as `session` or `$sessionSignal`. Better Auth answers
|
|
325
|
-
* `$store` and `atoms` with path proxies, and a missing atom with a function.
|
|
326
|
-
*/
|
|
327
325
|
function storeAtom(loaded, name) {
|
|
328
326
|
const value = Reflect.get(Object(Reflect.get(Object(Reflect.get(loaded, "$store")), "atoms")), name);
|
|
329
327
|
return typeof value === "object" && value !== null ? value : void 0;
|
|
330
328
|
}
|
|
331
|
-
/** Sets Better Auth's session atom of `loaded` to no session, settled. */
|
|
332
329
|
function clearAtom(loaded) {
|
|
333
330
|
const session = storeAtom(loaded, "session");
|
|
334
331
|
session?.set({
|
|
@@ -339,17 +336,8 @@ function clearAtom(loaded) {
|
|
|
339
336
|
isRefetching: false
|
|
340
337
|
});
|
|
341
338
|
}
|
|
342
|
-
/** The longest delay that `setTimeout()` keeps. It runs a longer delay at once. */
|
|
343
339
|
const maxTimerDelay = 2 ** 31 - 1;
|
|
344
|
-
/** Better Auth's channel to other tabs: a tab writes this `localStorage` key when it signs out or updates the user or session. */
|
|
345
340
|
const sessionChannelKey = "better-auth.message";
|
|
346
|
-
/**
|
|
347
|
-
* Calls `wake` at the moments when Better Auth reads the session again: the tab shows again (unless
|
|
348
|
-
* `refetchOnWindowFocus` is `false`), the network comes back, another tab changes the session, `refetchInterval`
|
|
349
|
-
* passes, or the session expires. Like Better Auth, it waits while the browser is offline, unless `refetchWhenOffline`
|
|
350
|
-
* is `true`: Better Auth could not load then, and the `online` event wakes it later. Returns a function that removes
|
|
351
|
-
* the listeners.
|
|
352
|
-
*/
|
|
353
341
|
function wakeWhenSessionCanChange(options, seed, wake) {
|
|
354
342
|
const stops = [];
|
|
355
343
|
const { document: page, navigator, window } = globalThis;
|
|
@@ -396,14 +384,9 @@ async function loadAuthClient(client) {
|
|
|
396
384
|
function defineAuthClient(options) {
|
|
397
385
|
return options;
|
|
398
386
|
}
|
|
399
|
-
/**
|
|
400
|
-
* The client that the composables and the Nuxt page guard share. On first use, it loads `better-auth/vue` and the app's
|
|
401
|
-
* `auth.client.ts` together, and the options of that file replace the defaults. In Nuxt, the default `basePath` is the
|
|
402
|
-
* Auth Definition's `basePath` below the `app.baseURL` of the page, also when `NUXT_APP_BASE_URL` sets it at runtime.
|
|
403
|
-
*/
|
|
404
387
|
const authClient = createLazyAuthClient(async () => {
|
|
405
|
-
const { default: options } = await import("#vitehub/auth/client");
|
|
406
|
-
return withDefaultBasePath(options);
|
|
388
|
+
const { default: options, extensions } = await import("#vitehub/auth/client");
|
|
389
|
+
return withDefaultBasePath(applyAuthClientExtensions(options, extensions));
|
|
407
390
|
});
|
|
408
391
|
/** Provide the app's configured client to Auth composables and `<AuthPermission>` in descendant components. */
|
|
409
392
|
function provideAuthClient(client) {
|
|
@@ -415,7 +398,6 @@ function useAuthClient() {
|
|
|
415
398
|
const nuxtApp = authNuxtBridge.nuxtAppResolver?.() || instance?.appContext.config.globalProperties.$nuxt;
|
|
416
399
|
return client ?? nuxtApp?.$vitehubAuthClient ?? authClient;
|
|
417
400
|
}
|
|
418
|
-
/** The session state of `client`, which `useUserSession()`, `useAbility()`, and the page guard share. */
|
|
419
401
|
function sessionState(client = useAuthClient()) {
|
|
420
402
|
return sessionStore(client).state;
|
|
421
403
|
}
|
|
@@ -468,7 +450,6 @@ function onSignOut(listener) {
|
|
|
468
450
|
signOutListeners.delete(listener);
|
|
469
451
|
};
|
|
470
452
|
}
|
|
471
|
-
/** `value` when it is an object, else an empty one, to spread fetch options that a caller may leave out. */
|
|
472
453
|
function record(value) {
|
|
473
454
|
return typeof value === "object" && value !== null ? { ...value } : {};
|
|
474
455
|
}
|
|
@@ -522,17 +503,10 @@ async function signOut(client, store, options = {}, fetchOptions = []) {
|
|
|
522
503
|
else if (redirectTo) location?.assign(redirectTo);
|
|
523
504
|
return result;
|
|
524
505
|
}
|
|
525
|
-
/** The refusal of a rule for the visitor: `undefined` while the session is unknown, `null` when the rule allows. */
|
|
526
506
|
function abilityRefusal(state, name, args) {
|
|
527
507
|
if (state.isPending) return void 0;
|
|
528
508
|
return checkAbility(abilities, state.data?.user ?? null, name, args);
|
|
529
509
|
}
|
|
530
|
-
/**
|
|
531
|
-
* The user that `authorize()` checks. The server uses the session it read for the request. While Nuxt hydrates, the
|
|
532
|
-
* browser uses the same session, so it decides as the server did. Otherwise the browser asks the client of
|
|
533
|
-
* `useAbility()`, because a sign-in or sign-out in the tab makes the server's session old. In Nuxt, that is the client of
|
|
534
|
-
* the page guard, at the configured Auth `basePath` below `app.baseURL`.
|
|
535
|
-
*/
|
|
536
510
|
async function authorizedUser(client, state) {
|
|
537
511
|
const known = !state.value.isPending;
|
|
538
512
|
if (!("window" in globalThis) || known && authNuxtBridge.nuxtAppResolver?.()?.isHydrating) return state.value.data?.user ?? null;
|
|
@@ -605,4 +579,4 @@ const AuthPermission = defineComponent({
|
|
|
605
579
|
};
|
|
606
580
|
}
|
|
607
581
|
});
|
|
608
|
-
export { AuthPermission, authClient, createAuthClient, defineAuthClient, loadAuthClient, onSignOut, provideAuthClient, setDefaultAuthBasePath, setNuxtAppResolver, setNuxtErrorFactory, setRequestFetchResolver, setSessionSeedResolver, setSignOutHandler, useAbility, useAuthClient, useUserSession };
|
|
582
|
+
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.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Better Auth-powered authentication primitives and Vite integration for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -142,11 +142,12 @@
|
|
|
142
142
|
"./package.json": "./package.json"
|
|
143
143
|
},
|
|
144
144
|
"dependencies": {
|
|
145
|
+
"@better-auth/drizzle-adapter": "1.7.27",
|
|
145
146
|
"@noble/hashes": "^2.4.0",
|
|
146
147
|
"@types/node": "^24.19.2",
|
|
147
|
-
"@vite-hub/env": "0.
|
|
148
|
-
"@vite-hub/runtime": "0.
|
|
149
|
-
"@vite-hub/web-container": "0.
|
|
148
|
+
"@vite-hub/env": "0.9.0",
|
|
149
|
+
"@vite-hub/runtime": "0.9.0",
|
|
150
|
+
"@vite-hub/web-container": "0.9.0",
|
|
150
151
|
"better-auth": "^1.7.27",
|
|
151
152
|
"better-auth-rou3": "npm:rou3@0.9.2",
|
|
152
153
|
"h3": "^2.0.8",
|
|
@@ -166,8 +167,8 @@
|
|
|
166
167
|
"@types/json-schema": "^7.0.15",
|
|
167
168
|
"@types/mdast": "^4.0.4",
|
|
168
169
|
"@types/node": "^24.19.2",
|
|
169
|
-
"@vite-hub/agent": "0.
|
|
170
|
-
"@vite-hub/database": "0.
|
|
170
|
+
"@vite-hub/agent": "0.9.0",
|
|
171
|
+
"@vite-hub/database": "0.9.0",
|
|
171
172
|
"@vite-hub/internal": "0.0.1",
|
|
172
173
|
"bun-types": "^1.4.5",
|
|
173
174
|
"evlog": "2.37.1",
|
|
@@ -190,8 +191,8 @@
|
|
|
190
191
|
"@better-auth/oauth-provider": "^1.7.27",
|
|
191
192
|
"@types/json-schema": "^7.0.15",
|
|
192
193
|
"@types/mdast": "^4.0.4",
|
|
193
|
-
"@vite-hub/agent": "0.
|
|
194
|
-
"@vite-hub/database": "0.
|
|
194
|
+
"@vite-hub/agent": "0.9.0",
|
|
195
|
+
"@vite-hub/database": "0.9.0",
|
|
195
196
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
196
197
|
"vite": ">=8.0.0",
|
|
197
198
|
"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-DkzL9ltR.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 };
|