@vite-hub/auth 0.3.1 → 0.4.1
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 +49 -34
- package/dist/{abilities-DfAnFYwG.d.ts → abilities-CbmTAoS_.d.ts} +1 -1
- package/dist/abilities.d.ts +1 -1
- package/dist/{ability-error-CqgBrBfR.js → ability-error-IeZQBr_-.js} +1 -1
- package/dist/agent.js +6 -5
- package/dist/{auth-instance-CR6b1W80.js → auth-instance-CmDogt4D.js} +20 -13
- package/dist/cli.js +1 -1
- package/dist/{console-runtime-DTopBP-x.d.ts → console-runtime-D2ai-Et5.d.ts} +1 -1
- package/dist/{console-runtime-J9_Vx9pT.js → console-runtime-_LrpyCYY.js} +2 -2
- 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-BRNef9oy.js → database-options-DpOVjUti.js} +1 -1
- package/dist/{database-schema-options-ENuRMduM.js → database-schema-options-Sk-1Bvyu.js} +1 -1
- package/dist/database.d.ts +1 -1
- package/dist/database.js +3 -3
- package/dist/{definition-CqQMcDEK.js → definition-BCaLA9kW.js} +146 -8
- package/dist/{error-diagnostics-C8XtVz0i.js → error-diagnostics-Dymr-S_n.js} +40 -4
- package/dist/{events-ByzenEVj.js → events-DCfuicoo.js} +6 -14
- package/dist/forward.js +1 -1
- package/dist/index.d.ts +3 -8
- package/dist/index.js +3 -3
- package/dist/internal/server.d.ts +3 -3
- package/dist/internal/server.js +6 -858
- package/dist/mcp-config-DRRlCAWN.js +18 -0
- package/dist/mcp-token-CpxLyl_p.js +222 -0
- package/dist/mcp.d.ts +96 -85
- package/dist/mcp.js +3 -184
- package/dist/{members-D9lfaEO_.js → members-DdlsS8kJ.js} +5 -5
- package/dist/nuxt.d.ts +15 -2
- package/dist/nuxt.js +9 -12
- package/dist/{presets-BGZi6Dfu.d.ts → presets-CHndEv5i.d.ts} +3 -4
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +3 -13
- 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-definition.d.ts +2 -1
- package/dist/runtime/empty-definition.js +2 -1
- package/dist/runtime/nuxt.js +2 -2
- package/dist/runtime/server.d.ts +1 -1
- package/dist/runtime/vue-nuxt.js +15 -7
- package/dist/schema.js +1 -1
- package/dist/server-BG_MFd4q.js +980 -0
- package/dist/{server-C0qnKN2W.d.ts → server-BM-RSf1T.d.ts} +76 -15
- package/dist/{server-bQGzVQ--.d.ts → server-C8TlOrSy.d.ts} +3 -3
- package/dist/server.d.ts +2 -2
- package/dist/server.js +3 -3
- package/dist/{session-cookies-BbH3UR2m.js → session-cookies-DVzjOKc7.js} +69 -5
- package/dist/{set-cookie-C8NOhdRE.js → set-cookie-DmqWq6kj.js} +1 -1
- package/dist/{shared-BwcdRGxD.js → shared-DRtfuFsV.js} +1 -1
- package/dist/{table-specs-8gq_FCaq.js → table-specs-CURphR3n.js} +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +2 -2
- package/dist/{types-CNaeH2Fd.d.ts → types-CruflEFI.d.ts} +62 -43
- package/dist/{vite-CV400XXY.js → vite-Dy0Xhq4H.js} +195 -149
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +2 -2
- package/dist/vue.d.ts +4 -19
- package/dist/vue.js +6 -9
- package/package.json +9 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import { i as AbilityName, n as AbilityAuthorization, t as AbilityArgs } from "./abilities-
|
|
3
|
-
import { t as AuthConsole } from "./console-runtime-
|
|
4
|
-
import "./server-
|
|
1
|
+
import { B as RegisteredAuth, Dt as AuthEventAggregates, Ft as AuthEventWindow, L as AuthSignInConfiguration, M as AuthRuntimeOptions, Nt as AuthEventStore, S as AuthGuardedHandler, T as AuthRequestInput, U as ViteHubAuth, V as ResolvedAuthAccessRoute, d as AuthAnonymousGuardedHandler, g as AuthDefinition, h as AuthBetterAuthRuntimeOptions, jt as AuthEventPage, kt as AuthEventListInput, p as AuthAuthorization, rt as AuthConsoleHostOptions, u as AuthAnonymousAuthorize, w as AuthRequest, x as AuthFor } from "./types-CruflEFI.js";
|
|
2
|
+
import { i as AbilityName, n as AbilityAuthorization, t as AbilityArgs } from "./abilities-CbmTAoS_.js";
|
|
3
|
+
import { t as AuthConsole } from "./console-runtime-D2ai-Et5.js";
|
|
4
|
+
import "./server-C8TlOrSy.js";
|
|
5
5
|
import "./ability-error-DcgChwCN.js";
|
|
6
6
|
import { AccessAuthorizeOption, Result, ViteHubContext } from "@vite-hub/runtime";
|
|
7
7
|
import { APIError } from "better-auth/api";
|
|
@@ -10,6 +10,31 @@ import { AuthContext, BetterAuthOptions, BetterAuthPlugin, User } from "better-a
|
|
|
10
10
|
/** Why `checkAuthMember()` did not let a user in. */
|
|
11
11
|
type AuthMemberErrorCode = "AUTH_NOT_MEMBER" | "AUTH_GITHUB_UNAVAILABLE";
|
|
12
12
|
//#endregion
|
|
13
|
+
//#region src/caller.d.ts
|
|
14
|
+
/** The Auth user of a caller, with the fields of the app's plugins, such as `role` of `admin()`. */
|
|
15
|
+
type AuthCallerUser = User & Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Who calls a route, as `requireCaller()` returns it: a person in the browser with an Auth Session, or an Agent with
|
|
18
|
+
* an MCP access token that the person approved. Check `kind` before an action that only the person may do.
|
|
19
|
+
*/
|
|
20
|
+
type AuthCaller<TRegistry = ViteHub.AuthRegistry> = {
|
|
21
|
+
kind: "browser";
|
|
22
|
+
user: AuthCallerUser;
|
|
23
|
+
session: AuthAuthorization<TRegistry>["session"];
|
|
24
|
+
} | {
|
|
25
|
+
kind: "agent";
|
|
26
|
+
/** The person who approved the MCP client, read again for each request. */
|
|
27
|
+
user: AuthCallerUser;
|
|
28
|
+
/** The OAuth client and the name it registered, such as "Claude Code". */
|
|
29
|
+
client: {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
/** The scopes that the person approved. */
|
|
34
|
+
scopes: string[];
|
|
35
|
+
};
|
|
36
|
+
type AuthCallerErrorCode = "AUTH_MCP_TOKEN_INVALID" | "AUTH_SIGNED_OUT";
|
|
37
|
+
//#endregion
|
|
13
38
|
//#region src/auth-instance.d.ts
|
|
14
39
|
declare function createBetterAuthOptions(definition: AuthDefinition): AuthBetterAuthRuntimeOptions;
|
|
15
40
|
declare function getAuthForDefinition<TDefinition extends AuthDefinition>(definition: TDefinition): AuthFor<TDefinition>;
|
|
@@ -21,7 +46,11 @@ declare function authForRequest(request: Pick<Request, "headers" | "url">, event
|
|
|
21
46
|
//#endregion
|
|
22
47
|
//#region src/internal/server.d.ts
|
|
23
48
|
/** Where Better Auth returns after one sign-in that a guard starts. */
|
|
24
|
-
type AuthSignInURLs = Pick<
|
|
49
|
+
type AuthSignInURLs = Pick<AuthProviderSignIn, "callbackURL" | "errorCallbackURL">;
|
|
50
|
+
/** A provider sign-in with the page that Better Auth returns to. */
|
|
51
|
+
type AuthProviderSignIn = AuthSignInConfiguration & {
|
|
52
|
+
callbackURL?: string;
|
|
53
|
+
};
|
|
25
54
|
declare function createAuthRequestRuntimeOptions(definition: AuthDefinition, request: Pick<Request, "headers" | "url">, event?: ViteHubContext): AuthRuntimeOptions;
|
|
26
55
|
declare function createAuth(definition: AuthDefinition): ViteHubAuth;
|
|
27
56
|
declare function createAuthForRequest(definition: AuthDefinition, request: Pick<Request, "headers" | "url">, event?: ViteHubContext): ViteHubAuth;
|
|
@@ -32,6 +61,7 @@ declare function toAuthRequest(input: AuthRequestInput): AuthRequest;
|
|
|
32
61
|
declare function createAuthHandler(definition: AuthDefinition): (request: Request, host?: {
|
|
33
62
|
clientAddress?: string;
|
|
34
63
|
}) => Promise<Response>;
|
|
64
|
+
/** The Better Auth instance of the app's Auth Definition, for sibling packages. Apps call `useAuth()`. */
|
|
35
65
|
declare function getAuth(): RegisteredAuth;
|
|
36
66
|
/**
|
|
37
67
|
* Checks `VITEHUB_MEMBERS` for a user, with the rules of sign-in, for code that has a user id but no session, such as
|
|
@@ -45,8 +75,11 @@ declare function checkAuthMember(userId: string, event?: AuthRequestInput): Prom
|
|
|
45
75
|
* Return the Better Auth instance of the app's Auth Definition for a request event or a Web `Request`.
|
|
46
76
|
* The generated types give it the endpoints and fields of the Definition's plugins, so `useAuth(event).api.banUser`
|
|
47
77
|
* type-checks when `server/auth.ts` uses `admin()`.
|
|
78
|
+
*
|
|
79
|
+
* Pass the event in a route. The instance then reads the request's host and Cloudflare bindings. Leave it out only
|
|
80
|
+
* where no request exists, such as in a Schedule or a Queue job.
|
|
48
81
|
*/
|
|
49
|
-
declare function useAuth(event
|
|
82
|
+
declare function useAuth(event?: AuthRequestInput): RegisteredAuth;
|
|
50
83
|
declare function assertAuthOrigin(request: Pick<Request, "headers" | "url">, event?: ViteHubContext): Promise<RegisteredAuth>;
|
|
51
84
|
declare function handleAuth(input: AuthRequestInput): Promise<Response>;
|
|
52
85
|
/** The options of `signOut()`. */
|
|
@@ -62,23 +95,27 @@ interface AuthSignOutOptions {
|
|
|
62
95
|
* `redirectTo` is not a path of the app.
|
|
63
96
|
*/
|
|
64
97
|
declare function signOut(input: AuthRequestInput, options?: AuthSignOutOptions): Promise<Response>;
|
|
98
|
+
type CoreAuthorization = AuthAuthorization<unknown>;
|
|
65
99
|
/**
|
|
66
100
|
* Like `withAuthorization()`, but a signed-out caller also reaches `authorize`, with `session` and `user` set to `null`.
|
|
67
101
|
* Use it for resources that a signed-out caller can open, such as files shared by public link.
|
|
68
102
|
* `false` returns `401` for a signed-out caller and `403` for a signed-in one. It never redirects to sign-in.
|
|
69
103
|
*/
|
|
70
|
-
declare function withAnonymousAuthorization<TInput extends AuthRequestInput, TResult>(authorize: AuthAnonymousAuthorize<TInput & ViteHubContext>, handler: AuthAnonymousGuardedHandler<TInput, TResult>, definition?:
|
|
104
|
+
declare function withAnonymousAuthorization<TInput extends AuthRequestInput, TResult>(authorize: AuthAnonymousAuthorize<TInput & ViteHubContext>, handler: AuthAnonymousGuardedHandler<TInput, TResult>, definition?: undefined): (input: TInput) => Promise<TResult | Response>;
|
|
105
|
+
declare function withAnonymousAuthorization<TInput extends AuthRequestInput, TResult>(authorize: AuthAnonymousAuthorize<TInput & ViteHubContext, false>, handler: AuthAnonymousGuardedHandler<TInput, TResult, unknown>, definition: AuthDefinition | undefined): (input: TInput) => Promise<TResult | Response>;
|
|
71
106
|
/**
|
|
72
107
|
* Wraps a server handler so it runs only with a signed-in Auth Session.
|
|
73
108
|
* The handler receives the checked `authorization`. Otherwise the wrapper returns `401`, or starts `access.signIn` for HTML requests.
|
|
74
109
|
*/
|
|
75
|
-
declare function withAuth<TInput extends AuthRequestInput, TResult>(handler: AuthGuardedHandler<TInput, TResult>, definition?:
|
|
110
|
+
declare function withAuth<TInput extends AuthRequestInput, TResult>(handler: AuthGuardedHandler<TInput, TResult>, definition?: undefined): (input: TInput) => Promise<TResult | Response>;
|
|
111
|
+
declare function withAuth<TInput extends AuthRequestInput, TResult>(handler: AuthGuardedHandler<TInput, TResult, unknown>, definition: AuthDefinition | undefined): (input: TInput) => Promise<TResult | Response>;
|
|
76
112
|
/**
|
|
77
113
|
* Wraps a resource handler, such as a Blob serve route or a Collection, so it runs only after `authorize` accepts the request.
|
|
78
114
|
* Returns `401` without a session, `403` when `authorize` returns `false`, and a custom `Response` as-is.
|
|
79
115
|
* It never redirects to sign-in, so image and fetch requests receive a status code.
|
|
80
116
|
*/
|
|
81
|
-
declare function withAuthorization<TInput extends AuthRequestInput, TResult>(authorize: AccessAuthorizeOption<TInput & ViteHubContext>, handler: AuthGuardedHandler<TInput, TResult>, definition?:
|
|
117
|
+
declare function withAuthorization<TInput extends AuthRequestInput, TResult>(authorize: AccessAuthorizeOption<TInput & ViteHubContext>, handler: AuthGuardedHandler<TInput, TResult>, definition?: undefined): (input: TInput) => Promise<TResult | Response>;
|
|
118
|
+
declare function withAuthorization<TInput extends AuthRequestInput, TResult>(authorize: AccessAuthorizeOption<TInput & ViteHubContext, false>, handler: AuthGuardedHandler<TInput, TResult, unknown>, definition: AuthDefinition | undefined): (input: TInput) => Promise<TResult | Response>;
|
|
82
119
|
/**
|
|
83
120
|
* Return the checked request, Session, and user of a signed-in caller, or throw an `HTTPError`.
|
|
84
121
|
* It rejects like `withAuth()`: `401`, or the `access.signIn` redirect for an HTML request.
|
|
@@ -90,13 +127,34 @@ declare function withAuthorization<TInput extends AuthRequestInput, TResult>(aut
|
|
|
90
127
|
* })
|
|
91
128
|
* ```
|
|
92
129
|
*/
|
|
93
|
-
declare function requireAuth(event: AuthRequestInput, definition?:
|
|
130
|
+
declare function requireAuth(event: AuthRequestInput, definition?: undefined): Promise<AuthAuthorization>;
|
|
131
|
+
declare function requireAuth(event: AuthRequestInput, definition: AuthDefinition | undefined): Promise<CoreAuthorization>;
|
|
94
132
|
/**
|
|
95
133
|
* Return the checked request, Session, and user after `authorize` accepts the request, or throw an `HTTPError`.
|
|
96
134
|
* It rejects like `withAuthorization()`: `401` without a session, `403` when `authorize` returns `false`, or the
|
|
97
135
|
* status and headers of the callback's `Response`. It never redirects to sign-in.
|
|
98
136
|
*/
|
|
99
|
-
declare function requireAuthorization<TInput extends AuthRequestInput>(event: TInput, authorize: AccessAuthorizeOption<TInput & ViteHubContext>, definition?:
|
|
137
|
+
declare function requireAuthorization<TInput extends AuthRequestInput>(event: TInput, authorize: AccessAuthorizeOption<TInput & ViteHubContext>, definition?: undefined): Promise<AuthAuthorization>;
|
|
138
|
+
declare function requireAuthorization<TInput extends AuthRequestInput>(event: TInput, authorize: AccessAuthorizeOption<TInput & ViteHubContext, false>, definition: AuthDefinition | undefined): Promise<CoreAuthorization>;
|
|
139
|
+
/**
|
|
140
|
+
* Return who calls: a person with an Auth Session (`kind: "browser"`), or an Agent with an MCP access token of
|
|
141
|
+
* `mcpOAuth()` (`kind: "agent"`), checked like `verifyMcpRequest()` for any `mcpOAuth()` resource of the origin. Like
|
|
142
|
+
* `verifyMcpRequest()`, it accepts `jwt()` and an `oauthProvider()` with `resources` that the app adds without
|
|
143
|
+
* `mcpOAuth()`. A bearer token that is not a JWT, such as a session token of `bearer()`, is read as a session.
|
|
144
|
+
* Returns `AUTH_SIGNED_OUT` without either, and `AUTH_MCP_TOKEN_INVALID` for a JWT bearer token that fails a check.
|
|
145
|
+
* `requireAuth()` stays session-only.
|
|
146
|
+
*
|
|
147
|
+
* ```ts [server/api/notes.delete.ts]
|
|
148
|
+
* export default defineHandler(async (event) => {
|
|
149
|
+
* const [error, caller] = await requireCaller(event)
|
|
150
|
+
* if (error) throw new HTTPError({ status: 401, message: error.why })
|
|
151
|
+
* if (caller.kind !== "browser") throw new HTTPError({ status: 403, message: "Only the person can delete notes." })
|
|
152
|
+
* return deleteNotes(caller.user.id)
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
declare function requireCaller(event: AuthRequestInput, definition?: undefined): Promise<Result<AuthCaller, AuthCallerErrorCode>>;
|
|
157
|
+
declare function requireCaller(event: AuthRequestInput, definition: AuthDefinition | undefined): Promise<Result<AuthCaller<unknown>, AuthCallerErrorCode>>;
|
|
100
158
|
/**
|
|
101
159
|
* Checks a rule from `shared/abilities.ts` for the caller of a request. Returns the checked request, session, and user.
|
|
102
160
|
* Throws an `AbilityError` when the rule refuses: `401` for a signed-out caller, else `403` or the status of `deny()`.
|
|
@@ -129,15 +187,18 @@ declare function requireAuthAccessRoutes(input: AuthRequestInput, routeIndexes:
|
|
|
129
187
|
declare const authRoute: {
|
|
130
188
|
fetch(request: Request): Promise<Response>;
|
|
131
189
|
};
|
|
132
|
-
declare const auth: RegisteredAuth;
|
|
133
190
|
/** Read the configured log from server code. Apply access checks before returning it to a caller. */
|
|
134
191
|
declare function getAuthEvents(definition?: AuthDefinition, request?: Pick<Request, "headers" | "url">): AuthEventStore | undefined;
|
|
135
|
-
|
|
136
|
-
|
|
192
|
+
/** Why `listAuthEvents()` or `aggregateAuthEvents()` returned an error. */
|
|
193
|
+
type AuthEventReadErrorCode = "AUTH_EVENT_QUERY_INVALID" | "AUTH_EVENT_READ_FAILED";
|
|
194
|
+
/** Read one page of the Auth event log. Invalid filters and store failures return `[error, undefined]`. */
|
|
195
|
+
declare function listAuthEvents(input?: AuthEventListInput, definition?: AuthDefinition): Promise<Result<AuthEventPage, AuthEventReadErrorCode>>;
|
|
196
|
+
/** Count the Auth events of a window. An invalid window and store failures return `[error, undefined]`. */
|
|
197
|
+
declare function aggregateAuthEvents(window: AuthEventWindow, definition?: AuthDefinition): Promise<Result<AuthEventAggregates, AuthEventReadErrorCode>>;
|
|
137
198
|
/**
|
|
138
199
|
* Resolve the primary Definition once, with the same request context for the provider and Console policy.
|
|
139
200
|
* `host.impersonation` lets the Console start impersonation. It is off by default.
|
|
140
201
|
*/
|
|
141
202
|
declare function getAuthConsoleForRequest(request: Request, event?: ViteHubContext, host?: AuthConsoleHostOptions): AuthConsole;
|
|
142
203
|
//#endregion
|
|
143
|
-
export {
|
|
204
|
+
export { authForRequest as A, requireCaller as C, withAnonymousAuthorization as D, useAuth as E, AuthCallerUser as F, AuthMemberErrorCode as I, getAuthForDefinition as M, AuthCaller as N, withAuth as O, AuthCallerErrorCode as P, requireAuthorization as S, toAuthRequest as T, handleAuthRequest as _, authRoute as a, requireAuth as b, createAuth as c, createAuthHandler as d, createAuthRequestRuntimeOptions as f, handleAuth as g, getAuthEvents as h, assertAuthOrigin as i, createBetterAuthOptions as j, withAuthorization as k, createAuthAccessHandler as l, getAuthConsoleForRequest as m, AuthSignOutOptions as n, can as o, getAuth as p, aggregateAuthEvents as r, checkAuthMember as s, AuthEventReadErrorCode as t, createAuthForRequest as u, listAuthEvents as v, signOut as w, requireAuthAccessRoutes as x, requireAbility as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ViteHubContext } from "@vite-hub/runtime";
|
|
1
|
+
import { T as AuthRequestInput, V as ResolvedAuthAccessRoute, g as AuthDefinition } from "./types-CruflEFI.js";
|
|
2
|
+
import { AccessAuthorizationContext, ViteHubContext } from "@vite-hub/runtime";
|
|
3
3
|
//#region src/runtime-state.d.ts
|
|
4
4
|
type AuthRuntimeEnvResolver = (event?: ViteHubContext) => Record<string, unknown>;
|
|
5
|
-
type AuthAccessIdentityResolver = (request: Request, event: AuthRequestInput, hasSession: boolean) => Promise<
|
|
5
|
+
type AuthAccessIdentityResolver = (request: Request, event: AuthRequestInput, hasSession: boolean) => Promise<AccessAuthorizationContext<unknown, false>["user"] | Response | undefined>;
|
|
6
6
|
declare function resetAuth(): void;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/runtime/server.d.ts
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import { C as
|
|
2
|
+
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, F as AuthCallerUser, I as AuthMemberErrorCode, N as AuthCaller, O as withAuth, P as AuthCallerErrorCode, S as requireAuthorization, a as authRoute, b as requireAuth, d as createAuthHandler, g as handleAuth, h as getAuthEvents, k as withAuthorization, m as getAuthConsoleForRequest, o as can, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, v as listAuthEvents, w as signOut, y as requireAbility } from "./server-BM-RSf1T.js";
|
|
3
3
|
import { n as AbilityErrorData, t as AbilityError } from "./ability-error-DcgChwCN.js";
|
|
4
|
-
export { AbilityError, type AbilityErrorData, type AuthMemberErrorCode, aggregateAuthEvents,
|
|
4
|
+
export { AbilityError, type AbilityErrorData, type AuthCaller, type AuthCallerErrorCode, type AuthCallerUser, type AuthEventReadErrorCode, type AuthMemberErrorCode, aggregateAuthEvents, can, checkAuthMember, createAuthHandler, authRoute as default, getAuthConsoleForRequest, getAuthEvents, handleAuth, listAuthEvents, requireAbility, requireAuth, requireAuthorization, requireCaller, signOut, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
|
package/dist/server.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as AbilityError } from "./ability-error-
|
|
2
|
-
import
|
|
3
|
-
export { AbilityError, aggregateAuthEvents,
|
|
1
|
+
import { t as AbilityError } from "./ability-error-IeZQBr_-.js";
|
|
2
|
+
import { D as withAuthorization, E as withAuth, S as signOut, T as withAnonymousAuthorization, _ as requireAbility, a as checkAuthMember, b as requireAuthorization, f as getAuthConsoleForRequest, g as listAuthEvents, i as can, l as createAuthHandler, m as handleAuth, p as getAuthEvents, r as authRoute, t as aggregateAuthEvents, v as requireAuth, w as useAuth, x as requireCaller } from "./server-BG_MFd4q.js";
|
|
3
|
+
export { AbilityError, aggregateAuthEvents, can, checkAuthMember, createAuthHandler, authRoute as default, getAuthConsoleForRequest, getAuthEvents, handleAuth, listAuthEvents, requireAbility, requireAuth, requireAuthorization, requireCaller, signOut, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
|
+
import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-DmqWq6kj.js";
|
|
3
3
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
4
4
|
import { n as authRequestEvent } from "./request-z6DHHmrb.js";
|
|
5
|
+
import { HTTPError } from "nitro/h3";
|
|
5
6
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
6
7
|
//#region src/session.ts
|
|
7
8
|
const apiErrorHeaders = Symbol.for("better-call:api-error-headers");
|
|
@@ -11,6 +12,7 @@ async function getAuthenticationSession(auth, input) {
|
|
|
11
12
|
return [api, api && readProperty(api, "getSession")];
|
|
12
13
|
});
|
|
13
14
|
if (typeof getSession !== "function") throw authErrorDiagnostics.AUTH_R0011({ message: "Better Auth did not expose api.getSession()." });
|
|
15
|
+
let refusal;
|
|
14
16
|
const value = await readProvider(async () => {
|
|
15
17
|
try {
|
|
16
18
|
return await Reflect.apply(getSession, api, [{
|
|
@@ -25,12 +27,41 @@ async function getAuthenticationSession(auth, input) {
|
|
|
25
27
|
response: null
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
const client = readClientApiError(cause);
|
|
31
|
+
if (!client) throw cause;
|
|
32
|
+
refusal = client.refusal;
|
|
33
|
+
return {
|
|
34
|
+
headers: client.headers,
|
|
35
|
+
response: null
|
|
36
|
+
};
|
|
29
37
|
}
|
|
30
38
|
});
|
|
31
39
|
const read = await readProvider(() => resolveAuthenticationSessionRead(value));
|
|
32
40
|
if (!read) throw authErrorDiagnostics.AUTH_R0012({ message: "Better Auth returned an invalid session response." });
|
|
33
|
-
return
|
|
41
|
+
return refusal ? {
|
|
42
|
+
...read,
|
|
43
|
+
refusal
|
|
44
|
+
} : read;
|
|
45
|
+
}
|
|
46
|
+
/** The H3 error format of a refusal, as the guards answer their own refusals. */
|
|
47
|
+
function authenticationRefusalResponse(refusal) {
|
|
48
|
+
return Response.json({
|
|
49
|
+
status: refusal.status,
|
|
50
|
+
message: refusal.message,
|
|
51
|
+
data: refusal.code ? { code: refusal.code } : void 0
|
|
52
|
+
}, {
|
|
53
|
+
headers: refusal.headers,
|
|
54
|
+
status: refusal.status
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** The `HTTPError` of a refusal, for a caller that throws. */
|
|
58
|
+
function authenticationRefusalError(refusal) {
|
|
59
|
+
return new HTTPError({
|
|
60
|
+
data: refusal.code ? { code: refusal.code } : void 0,
|
|
61
|
+
headers: refusal.headers,
|
|
62
|
+
message: refusal.message,
|
|
63
|
+
status: refusal.status
|
|
64
|
+
});
|
|
34
65
|
}
|
|
35
66
|
async function readProvider(read) {
|
|
36
67
|
try {
|
|
@@ -84,6 +115,39 @@ function isUnauthorizedApiError(error) {
|
|
|
84
115
|
return false;
|
|
85
116
|
}
|
|
86
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* The refusal of a Better Auth `APIError` with a 4xx status, and all its headers. A `before` hook can pass headers to
|
|
120
|
+
* the error, and better-call keeps the headers that the endpoint set before under its own key. Both reach the client.
|
|
121
|
+
*/
|
|
122
|
+
function readClientApiError(error) {
|
|
123
|
+
if (typeof error !== "object" || error === null) return;
|
|
124
|
+
try {
|
|
125
|
+
if (Reflect.get(error, "name") !== "APIError") return;
|
|
126
|
+
const status = Reflect.get(error, "statusCode");
|
|
127
|
+
if (typeof status !== "number" || !Number.isInteger(status) || status < 400 || status > 499) return;
|
|
128
|
+
const body = Reflect.get(error, "body");
|
|
129
|
+
const headers = new Headers();
|
|
130
|
+
for (const source of [Reflect.get(error, apiErrorHeaders), Reflect.get(error, "headers")]) {
|
|
131
|
+
if (!(source instanceof Headers) && !isRecord(source)) continue;
|
|
132
|
+
const incoming = new Headers(source instanceof Headers ? source : Object.entries(source).filter((entry) => typeof entry[1] === "string"));
|
|
133
|
+
for (const cookie of incoming.getSetCookie()) if (!headers.getSetCookie().includes(cookie)) headers.append("set-cookie", cookie);
|
|
134
|
+
for (const [name, value] of incoming) if (name !== "set-cookie" && !headers.has(name)) headers.set(name, value);
|
|
135
|
+
}
|
|
136
|
+
const refusalHeaders = new Headers(headers);
|
|
137
|
+
refusalHeaders.delete("set-cookie");
|
|
138
|
+
return {
|
|
139
|
+
headers,
|
|
140
|
+
refusal: {
|
|
141
|
+
code: isRecord(body) && typeof body.code === "string" ? body.code : void 0,
|
|
142
|
+
headers: refusalHeaders,
|
|
143
|
+
message: isRecord(body) && typeof body.message === "string" ? body.message : void 0,
|
|
144
|
+
status
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
} catch {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
87
151
|
function readProperty(value, property) {
|
|
88
152
|
return value[property];
|
|
89
153
|
}
|
|
@@ -224,4 +288,4 @@ function isResponseLike(value) {
|
|
|
224
288
|
}
|
|
225
289
|
}
|
|
226
290
|
//#endregion
|
|
227
|
-
export { sendSessionCookies as n,
|
|
291
|
+
export { getAuthenticationSession as a, authenticationRefusalResponse as i, sendSessionCookies as n, authenticationRefusalError as r, prepareSessionCookies as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
2
|
import { ViteHubError, isViteHubError } from "@vite-hub/runtime";
|
|
3
3
|
//#region src/errors.ts
|
|
4
4
|
function invalidAuthenticationErrorOptions() {
|
package/dist/test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as AuthDefinition } from "./types-
|
|
1
|
+
import { g as AuthDefinition } from "./types-CruflEFI.js";
|
|
2
2
|
import { Session, User } from "better-auth";
|
|
3
3
|
//#region src/test.d.ts
|
|
4
4
|
/** The user to sign in. Auth creates it when no user has this email. Other fields, such as `role`, go to the new user. */
|
package/dist/test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { o as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
|
|
2
|
+
import { o as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-CmDogt4D.js";
|
|
3
3
|
import { testUtils } from "better-auth/plugins";
|
|
4
4
|
//#region src/test.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as AuthPreset } from "./presets-CHndEv5i.js";
|
|
2
2
|
import { r as AuthSchemaOptions } from "./table-specs-DbXyaXWs.js";
|
|
3
|
-
import { AccessAuthorizationContext, AccessAuthorize, AccessAuthorizeResult, AnonymousAccessAuthorizationContext, AnonymousAccessAuthorize } from "@vite-hub/runtime";
|
|
3
|
+
import { AccessAuthorizationContext, AccessAuthorize, AccessAuthorizeResult, AnonymousAccessAuthorizationContext, AnonymousAccessAuthorize, Duration } from "@vite-hub/runtime";
|
|
4
4
|
import { ViteHubContext as ViteHubContext$1 } from "@vite-hub/runtime/internal/h3";
|
|
5
5
|
import { Auth, BetterAuthOptions, DBAdapter, Session, User } from "better-auth";
|
|
6
6
|
import { EnvDatabase } from "@vite-hub/env/database";
|
|
@@ -87,26 +87,6 @@ declare function createDatabaseAuthEventStore(options: {
|
|
|
87
87
|
retention?: AuthEventRetention | false;
|
|
88
88
|
}): AuthEventStore;
|
|
89
89
|
//#endregion
|
|
90
|
-
//#region src/nuxt-types.d.ts
|
|
91
|
-
/** Who may open a page: signed-in users (`user`) or signed-out visitors (`guest`). */
|
|
92
|
-
type AuthPageMode = "guest" | "user";
|
|
93
|
-
/**
|
|
94
|
-
* The `auth` key of `definePageMeta()` in Nuxt. `'user'` or `true` sends visitors without a session to the login
|
|
95
|
-
* page. `'guest'` sends signed-in users away, for example from the login page. `false` turns the guard off.
|
|
96
|
-
*/
|
|
97
|
-
type AuthPageMeta = boolean | AuthPageMode | {
|
|
98
|
-
only?: AuthPageMode;
|
|
99
|
-
/** Where to send the visitor instead of the configured redirect. */
|
|
100
|
-
redirectTo?: string;
|
|
101
|
-
};
|
|
102
|
-
/** Where the Nuxt page guard sends visitors. */
|
|
103
|
-
interface AuthRedirects {
|
|
104
|
-
/** The login page for `auth: 'user'` pages. The guard adds `?redirect=<the page>`. Default `/login`. */
|
|
105
|
-
login?: string;
|
|
106
|
-
/** Where signed-in users go from `auth: 'guest'` pages. Default `/`. */
|
|
107
|
-
guest?: string;
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
90
|
//#region src/console-types.d.ts
|
|
111
91
|
type AuthConsoleValue = string | number | boolean | null | string[] | number[];
|
|
112
92
|
type AuthConsoleFieldType = "string" | "number" | "boolean" | "date" | "string[]" | "number[]" | "json";
|
|
@@ -393,10 +373,18 @@ declare global {
|
|
|
393
373
|
}
|
|
394
374
|
}
|
|
395
375
|
type AuthRuntimeOption = "baseURL" | "secret" | "secrets";
|
|
396
|
-
type AuthReservedOption = AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "basePath" | "database" | "preset" | "route" | "runtime" | "secondaryStorage";
|
|
376
|
+
type AuthReservedOption = AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "basePath" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage";
|
|
397
377
|
type AuthBetterAuthOptions = Omit<BetterAuthOptions, AuthReservedOption | "session"> & {
|
|
398
378
|
session?: AuthSessionOptions;
|
|
399
379
|
};
|
|
380
|
+
/**
|
|
381
|
+
* Better Auth `user.deleteUser` options without `enabled`. `beforeDelete` runs first: delete the app's own rows of the
|
|
382
|
+
* user there, or throw an `APIError` to keep the account.
|
|
383
|
+
*/
|
|
384
|
+
type AuthDeleteAccountOptions = Omit<NonNullable<NonNullable<BetterAuthOptions["user"]>["deleteUser"]>, "enabled"> & {
|
|
385
|
+
/** Database-backed `apiKey()` configuration IDs that reference users, never organizations. Use `"default"` for the unnamed configuration. */
|
|
386
|
+
userApiKeyConfigIds?: readonly string[];
|
|
387
|
+
};
|
|
400
388
|
/** Session fields to write when a refresh extends the session. */
|
|
401
389
|
type AuthSessionRefreshFields = Partial<Session> & Record<string, unknown>;
|
|
402
390
|
interface AuthSessionRefreshContext {
|
|
@@ -424,10 +412,12 @@ interface AuthRuntimeContext<TEnv extends Record<string, unknown> = AuthRuntimeE
|
|
|
424
412
|
type AuthRuntimeOptions = Partial<Omit<BetterAuthOptions, "basePath" | "database">> & {
|
|
425
413
|
/** A Better Auth adapter, or `"memory"` to keep users and sessions in the memory of one server process. */
|
|
426
414
|
database?: BetterAuthOptions["database"] | "memory";
|
|
415
|
+
deleteAccount?: true | AuthDeleteAccountOptions;
|
|
427
416
|
events?: AuthEventsConfiguration | false;
|
|
428
417
|
};
|
|
418
|
+
/** A provider sign-in that the Auth route starts at `GET <basePath>/sign-in`. */
|
|
429
419
|
interface AuthSignInConfiguration {
|
|
430
|
-
|
|
420
|
+
/** Where Better Auth sends the visitor when the provider sign-in fails. */
|
|
431
421
|
errorCallbackURL?: string;
|
|
432
422
|
provider: string;
|
|
433
423
|
requestSignUp?: boolean;
|
|
@@ -439,23 +429,31 @@ interface AuthAccessRouteConfiguration {
|
|
|
439
429
|
route: string;
|
|
440
430
|
}
|
|
441
431
|
type AuthAccessRoute = string | AuthAccessRouteConfiguration;
|
|
442
|
-
type AuthAccessAuthorizationContext<TEvent = ViteHubContext$1> = AccessAuthorizationContext<TEvent>;
|
|
432
|
+
type AuthAccessAuthorizationContext<TEvent = ViteHubContext$1> = AccessAuthorizationContext<TEvent, false>;
|
|
443
433
|
type AuthAccessAuthorizeResult = AccessAuthorizeResult;
|
|
444
|
-
type AuthAccessAuthorize<TEvent = ViteHubContext$1> = AccessAuthorize<TEvent>;
|
|
445
|
-
/** The
|
|
446
|
-
type
|
|
447
|
-
|
|
448
|
-
|
|
434
|
+
type AuthAccessAuthorize<TEvent = ViteHubContext$1> = AccessAuthorize<TEvent, false>;
|
|
435
|
+
/** The Session and user that the app's Auth Definition returns, with the fields of its plugins and `additionalFields`. */
|
|
436
|
+
type RegisteredSession<TRegistry> = RegisteredAuth<TRegistry>["$Infer"]["Session"];
|
|
437
|
+
type GuardSession<TSession> = Pick<TSession, Extract<keyof TSession, keyof Session>> & Partial<Omit<TSession, keyof Session>>;
|
|
438
|
+
/**
|
|
439
|
+
* The checked request, Session, and user that a guarded handler receives. Only Auth guards create it.
|
|
440
|
+
* Guards using the default Definition read plugin and custom fields from the generated Auth registry.
|
|
441
|
+
*/
|
|
442
|
+
type AuthAuthorization<TRegistry = ViteHub.AuthRegistry> = Readonly<{
|
|
443
|
+
request: AuthAccessAuthorizationContext["request"];
|
|
444
|
+
/** API-key sessions can omit plugin and custom fields. The admin plugin sets `impersonatedBy` for impersonation. */
|
|
445
|
+
session: GuardSession<RegisteredSession<TRegistry>["session"]> & {
|
|
449
446
|
impersonatedBy?: string | null;
|
|
450
447
|
};
|
|
448
|
+
user: RegisteredSession<TRegistry>["user"];
|
|
451
449
|
}>;
|
|
452
450
|
/** A server handler that runs only after an Auth guard accepts the request. */
|
|
453
|
-
type AuthGuardedHandler<TInput, TResult> = (input: TInput, authorization: AuthAuthorization) => TResult | Promise<TResult>;
|
|
451
|
+
type AuthGuardedHandler<TInput, TResult, TRegistry = ViteHub.AuthRegistry> = (input: TInput, authorization: AuthAuthorization<TRegistry>) => TResult | Promise<TResult>;
|
|
454
452
|
/** The checked request of a signed-out caller that `withAnonymousAuthorization()` accepted. */
|
|
455
453
|
type AuthAnonymousAuthorization = Readonly<Omit<AnonymousAccessAuthorizationContext, "event">>;
|
|
456
|
-
type AuthAnonymousAuthorize<TEvent = ViteHubContext$1> = AnonymousAccessAuthorize<TEvent>;
|
|
454
|
+
type AuthAnonymousAuthorize<TEvent = ViteHubContext$1, TRegistered extends boolean = true> = AnonymousAccessAuthorize<TEvent, TRegistered>;
|
|
457
455
|
/** A server handler that runs after `authorize` accepts a signed-in or signed-out caller. */
|
|
458
|
-
type AuthAnonymousGuardedHandler<TInput, TResult> = (input: TInput, authorization: AuthAuthorization | AuthAnonymousAuthorization) => TResult | Promise<TResult>;
|
|
456
|
+
type AuthAnonymousGuardedHandler<TInput, TResult, TRegistry = ViteHub.AuthRegistry> = (input: TInput, authorization: AuthAuthorization<TRegistry> | AuthAnonymousAuthorization) => TResult | Promise<TResult>;
|
|
459
457
|
/** What `access.policy.allow` gets: the user, and the provider access tokens of the user's accounts. */
|
|
460
458
|
interface AuthAccessPolicyContext {
|
|
461
459
|
user: User & Record<string, unknown>;
|
|
@@ -469,15 +467,25 @@ interface AuthAccessPolicy {
|
|
|
469
467
|
* request fails and the session stays.
|
|
470
468
|
*/
|
|
471
469
|
allow: (context: AuthAccessPolicyContext) => boolean | Promise<boolean>;
|
|
472
|
-
/**
|
|
473
|
-
recheck?:
|
|
470
|
+
/** How long an allowed answer holds for one session or one MCP user, such as `"5m"`. `"0s"` asks on each request. Default: `"5m"`. */
|
|
471
|
+
recheck?: Duration;
|
|
474
472
|
}
|
|
475
473
|
interface AuthAccessConfiguration {
|
|
476
474
|
routes?: AuthAccessRoute[];
|
|
477
475
|
/** Paths that no access route guards, in the same form as `routes`. With `routes: ['/**']`, these are the only paths a signed-out visitor reaches. */
|
|
478
476
|
public?: string[];
|
|
479
477
|
policy?: AuthAccessPolicy;
|
|
480
|
-
|
|
478
|
+
/**
|
|
479
|
+
* Where a signed-out visitor signs in: the path of a sign-in page, such as `"/login"`, or a provider, such as
|
|
480
|
+
* `{ provider: "github" }`, that the Auth route starts. The Nuxt page guard sends visitors there, with
|
|
481
|
+
* `?redirect=<the page>`. Default: `"/login"`.
|
|
482
|
+
*/
|
|
483
|
+
signIn?: string | AuthSignInConfiguration;
|
|
484
|
+
/**
|
|
485
|
+
* Where a visitor goes after a provider sign-in without `?redirect=`, and where the Nuxt page guard sends a signed-in
|
|
486
|
+
* user from an `auth: 'guest'` page. Default: `"/"`.
|
|
487
|
+
*/
|
|
488
|
+
afterSignIn?: string;
|
|
481
489
|
}
|
|
482
490
|
/** The Better Auth adapter of `authDatabase()`. `vitehubDatabase` names the app Database that holds the Auth tables. */
|
|
483
491
|
type AuthAppDatabase = ((options: BetterAuthOptions) => DBAdapter<BetterAuthOptions>) & {
|
|
@@ -486,6 +494,12 @@ type AuthAppDatabase = ((options: BetterAuthOptions) => DBAdapter<BetterAuthOpti
|
|
|
486
494
|
interface AuthViteHubOptions {
|
|
487
495
|
/** Ignore `VITEHUB_ADMIN_CLAIM` for this Auth Definition. Independent Console Auth sets this to `false`. */
|
|
488
496
|
adminClaim?: false;
|
|
497
|
+
/**
|
|
498
|
+
* Let users delete their account with Better Auth `deleteUser()`. Auth also deletes the rows of the user in ViteHub
|
|
499
|
+
* Server Primitives, such as their comments and form submissions. Pass options to run `beforeDelete` for the app's
|
|
500
|
+
* own rows.
|
|
501
|
+
*/
|
|
502
|
+
deleteAccount?: true | AuthDeleteAccountOptions;
|
|
489
503
|
/** Opt in to durable auth events with an explicit store. */
|
|
490
504
|
events?: AuthEventsConfiguration | false;
|
|
491
505
|
console?: AuthConsoleOptions;
|
|
@@ -530,6 +544,14 @@ interface ResolvedAuthViteConfig {
|
|
|
530
544
|
routes: ResolvedAuthAccessRoute[];
|
|
531
545
|
/** Paths that the access middleware leaves to the handler. Set only when the Definition lists some. */
|
|
532
546
|
public?: string[];
|
|
547
|
+
/** `access.signIn`: a sign-in page, or a provider that the Auth route starts. Set only when the Definition has it. */
|
|
548
|
+
signIn?: {
|
|
549
|
+
page: string;
|
|
550
|
+
} | {
|
|
551
|
+
provider: true;
|
|
552
|
+
};
|
|
553
|
+
/** `access.afterSignIn`. Set only when the Definition has it. */
|
|
554
|
+
afterSignIn?: string;
|
|
533
555
|
};
|
|
534
556
|
basePath: string;
|
|
535
557
|
/**
|
|
@@ -546,7 +568,7 @@ interface ResolvedAuthViteConfig {
|
|
|
546
568
|
rootDir: string;
|
|
547
569
|
route: false | string;
|
|
548
570
|
}
|
|
549
|
-
type AuthBetterAuthRuntimeOptions<TOptions extends AuthDefinitionInput = AuthDefinitionInput> = (TOptions extends AuthDefinitionResolver<infer TResolved> ? Omit<TResolved, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "database" | "preset" | "route" | "runtime" | "secondaryStorage"> : Omit<TOptions, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "database" | "preset" | "route" | "runtime" | "secondaryStorage">) & AuthRuntimeOptions & BetterAuthOptions;
|
|
571
|
+
type AuthBetterAuthRuntimeOptions<TOptions extends AuthDefinitionInput = AuthDefinitionInput> = (TOptions extends AuthDefinitionResolver<infer TResolved> ? Omit<TResolved, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage"> : Omit<TOptions, AuthRuntimeOption | "events" | "console" | "access" | "adminClaim" | "database" | "deleteAccount" | "preset" | "route" | "runtime" | "secondaryStorage">) & AuthRuntimeOptions & BetterAuthOptions;
|
|
550
572
|
type AuthRequest = Pick<Request, "body" | "headers" | "method" | "signal" | "url">;
|
|
551
573
|
/**
|
|
552
574
|
* A Web Request, or a request event with Standard Context properties, such as an H3 2 event in a ViteHub app.
|
|
@@ -560,10 +582,7 @@ type AuthFor<TDefinition extends AuthDefinition> = ViteHubAuth<Extract<Omit<TDef
|
|
|
560
582
|
type RegisteredAuth<TRegistry = ViteHub.AuthRegistry> = TRegistry extends {
|
|
561
583
|
definition: infer TDefinition extends AuthDefinition;
|
|
562
584
|
} ? AuthFor<TDefinition> : ViteHubAuth;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
redirects?: AuthRedirects;
|
|
566
|
-
}
|
|
567
|
-
type AuthOptions = false | AuthObjectOptions;
|
|
585
|
+
/** `false` turns Auth off. `server/auth.ts` turns it on, and `defineAuth()` holds every Auth option. */
|
|
586
|
+
type AuthOptions = false;
|
|
568
587
|
//#endregion
|
|
569
|
-
export {
|
|
588
|
+
export { AuthConsoleEventUser as $, AuthRuntimeOnlyOptions as A, AuthEventMetadata as At, RegisteredAuth as B, AuthOptions as C, authConsoleEventGroups as Ct, AuthResolvedDefinitionOptions as D, AuthEventAggregates as Dt, AuthReservedOption as E, AuthEventActor as Et, AuthSessionRefreshContext as F, AuthEventWindow as Ft, AuthConsoleActivity as G, ResolvedAuthViteConfig as H, AuthSessionRefreshFields as I, AuthEventsConfiguration as It, AuthConsoleCapability as J, AuthConsoleActivityQuery as K, AuthSignInConfiguration as L, createDatabaseAuthEventStore as Lt, AuthRuntimeOptions as M, AuthEventRetention as Mt, AuthSessionOptions as N, AuthEventStore as Nt, AuthRuntimeContext as O, AuthEventCounts as Ot, AuthSessionRefresh as P, AuthEventType as Pt, AuthConsoleEventGroup as Q, AuthViteHubOptions as R, defaultAuthEventRetention as Rt, AuthGuardedHandler as S, authConsoleActionNames as St, AuthRequestInput as T, AuthEvent as Tt, ViteHubAuth as U, ResolvedAuthAccessRoute as V, AuthConsoleAction as W, AuthConsoleDescription as X, AuthConsoleColumn as Y, AuthConsoleEvent as Z, AuthDefinitionInput as _, AuthConsoleSession as _t, AuthAccessPolicy as a, AuthConsoleHostUserInput as at, AuthDeleteAccountOptions as b, AuthConsoleUserDetail as bt, AuthAccessRouteConfiguration as c, AuthConsoleMutation as ct, AuthAnonymousGuardedHandler as d, AuthConsoleOrganizationDetail as dt, AuthConsoleField as et, AuthAppDatabase as f, AuthConsoleOverview as ft, AuthDefinition as g, AuthConsoleRoles as gt, AuthBetterAuthRuntimeOptions as h, AuthConsoleQuery as ht, AuthAccessConfiguration as i, AuthConsoleHostSession as it, AuthRuntimeOption as j, AuthEventPage as jt, AuthRuntimeEnv as k, AuthEventListInput as kt, AuthAnonymousAuthorization as l, AuthConsoleOptions as lt, AuthBetterAuthOptions as m, AuthConsolePolicy as mt, AuthAccessAuthorize as n, AuthConsoleFieldType as nt, AuthAccessPolicyContext as o, AuthConsoleImpersonation as ot, AuthAuthorization as p, AuthConsolePage as pt, AuthConsoleAgent as q, AuthAccessAuthorizeResult as r, AuthConsoleHostOptions as rt, AuthAccessRoute as s, AuthConsoleList as st, AuthAccessAuthorizationContext as t, AuthConsoleFieldPolicy as tt, AuthAnonymousAuthorize as u, AuthConsoleOrganization as ut, AuthDefinitionOptions as v, AuthConsoleSessionUser as vt, AuthRequest as w, AuthDevice as wt, AuthFor as x, AuthConsoleValue as xt, AuthDefinitionResolver as y, AuthConsoleUser as yt, DiscoveredAuthDefinition as z };
|