@vite-hub/auth 0.4.1 → 0.5.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 +32 -8
- package/dist/{abilities-CbmTAoS_.d.ts → abilities-3L1Y5Pnw.d.ts} +2 -4
- package/dist/abilities.d.ts +1 -1
- package/dist/abilities.js +1 -2
- package/dist/{ability-error-IeZQBr_-.js → ability-error-BHhPkrZd.js} +3 -5
- package/dist/{ability-error-DcgChwCN.d.ts → ability-error-C1c30O6E.d.ts} +1 -5
- package/dist/access-pages-BwImVHN_.js +94 -0
- package/dist/{admin-claim-code-CDipqeAU.js → admin-claim-code-C3X_U43x.js} +1 -2
- package/dist/agent.d.ts +1 -3
- package/dist/agent.js +5 -6
- package/dist/{application-path-DuTpfGFj.js → application-path-zKi7NrvK.js} +1 -2
- package/dist/{auth-instance-CmDogt4D.js → auth-instance-_J7R9Qs1.js} +239 -50
- package/dist/{cli-ubYJpAL_.d.ts → cli-C5pAfY4x.d.ts} +1 -6
- package/dist/cli.d.ts +2 -4
- package/dist/cli.js +3 -4
- package/dist/{console-runtime-D2ai-Et5.d.ts → console-runtime-BP1ZKJB0.d.ts} +13 -13
- package/dist/{console-runtime-_LrpyCYY.js → console-runtime-vc3JQEuq.js} +72 -40
- package/dist/console-runtime.d.ts +2 -2
- package/dist/console-runtime.js +1 -2
- package/dist/{console-types-CmmnKGMx.js → console-types-51lkf0lk.js} +1 -2
- package/dist/console.d.ts +1 -5
- package/dist/console.js +2 -3
- package/dist/{database-options-DpOVjUti.js → database-options-DQ-8qYMl.js} +2 -3
- package/dist/{database-schema-options-Sk-1Bvyu.js → database-schema-options-CkSeU9V3.js} +2 -3
- package/dist/database.d.ts +1 -3
- package/dist/database.js +5 -6
- package/dist/{definition-BCaLA9kW.js → definition-MDGMNKrK.js} +20 -18
- package/dist/{error-diagnostics-Dymr-S_n.js → error-diagnostics-BssJr_2t.js} +9 -4
- package/dist/{events-DCfuicoo.js → events-DZqMiae_.js} +4 -6
- package/dist/forward.d.ts +1 -3
- package/dist/forward.js +2 -3
- package/dist/index.d.ts +4 -7
- package/dist/index.js +4 -3
- package/dist/internal/server.d.ts +4 -4
- package/dist/internal/server.js +5 -5
- package/dist/{invariant-D8_xBqmZ.js → invariant-Dj2R1eMr.js} +2 -3
- package/dist/{mcp-config-DRRlCAWN.js → mcp-config-C7srUMIZ.js} +2 -3
- package/dist/{mcp-token-CpxLyl_p.js → mcp-token--KuLYEub.js} +7 -18
- package/dist/mcp.d.ts +0 -4
- package/dist/mcp.js +4 -5
- package/dist/{members-DdlsS8kJ.js → members-D3_Q5XJb.js} +10 -14
- package/dist/nitro-kit-Bg4xUZAI.js +43 -0
- package/dist/{nuxt-bridge-Cl988STZ.js → nuxt-bridge-pRyfYD5c.js} +1 -2
- package/dist/nuxt.d.ts +31 -24
- package/dist/nuxt.js +336 -18
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/own-access-C22hSIuF.d.ts +18 -0
- package/dist/own-access-DQgqxTbI.js +30 -0
- package/dist/{page-tools-shared-l4eyj53D.js → page-tools-shared-CtoKaNQZ.js} +1 -2
- package/dist/{presets-CHndEv5i.d.ts → presets-C6AtiRdI.d.ts} +0 -2
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +2 -3
- package/dist/{request-z6DHHmrb.js → request-Dpq7GO8B.js} +2 -4
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/empty-abilities.d.ts +1 -3
- package/dist/runtime/empty-abilities.js +1 -2
- package/dist/runtime/empty-client.d.ts +0 -2
- package/dist/runtime/empty-client.js +1 -2
- package/dist/runtime/empty-definition.d.ts +1 -3
- package/dist/runtime/empty-definition.js +1 -2
- package/dist/runtime/nuxt.d.ts +1 -3
- package/dist/runtime/nuxt.js +1 -2
- package/dist/runtime/server.d.ts +3 -2
- package/dist/runtime/server.js +27 -19
- package/dist/runtime/vue-nuxt.d.ts +0 -2
- package/dist/runtime/vue-nuxt.js +74 -33
- package/dist/{runtime-state-ojQCzKOc.js → runtime-state-DtKUfxKq.js} +1 -2
- package/dist/schema.d.ts +71 -23
- package/dist/schema.js +6 -5
- package/dist/{server-BM-RSf1T.d.ts → server-CFWlYQJb.d.ts} +7 -14
- package/dist/{server-BG_MFd4q.js → server-D4Hi4TBI.js} +51 -33
- package/dist/{server-C8TlOrSy.d.ts → server-DCsgxFPP.d.ts} +9 -14
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/{session-cookies-DVzjOKc7.js → session-cookies-1FMcMnRh.js} +6 -8
- package/dist/{set-cookie-DmqWq6kj.js → set-cookie-DkqM1kvj.js} +3 -5
- package/dist/{table-specs-DbXyaXWs.d.ts → table-specs-BLm_Zlss.d.ts} +255 -3
- package/dist/{table-specs-CURphR3n.js → table-specs-jw0jjU6l.js} +43 -44
- package/dist/test.d.ts +2 -4
- package/dist/test.js +3 -4
- package/dist/{types-CruflEFI.d.ts → types-BHSgxyvV.d.ts} +50 -11
- package/dist/{vite-Dy0Xhq4H.js → vite-D1xC9n1O.js} +365 -152
- package/dist/vite.d.ts +7 -14
- package/dist/vite.js +1 -2
- package/dist/vue.d.ts +17 -72
- package/dist/vue.js +25 -73
- package/package.json +35 -30
- package/dist/shared-DRtfuFsV.js +0 -12
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as getAuthRuntimeState } from "./runtime-state-
|
|
8
|
-
import {
|
|
9
|
-
import { a as requestProvider, c as resolveAuthOptions, d as setRequestClientAddress, f as withClientAddress, i as getAuthForDefinition, l as trustsProxyHeaders, m as forwardedRequestOrigin, n as createBetterAuthOptions, o as resolveDefaultDefinition, p as runWithAuthEvent, r as envResolverFor, s as withSessionMarker, t as authForRequest, u as eventClientAddress } from "./auth-instance-CmDogt4D.js";
|
|
10
|
-
import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-DuTpfGFj.js";
|
|
11
|
-
import { t as normalizeAuthBasePath } from "./shared-DRtfuFsV.js";
|
|
1
|
+
import { t as createAuthConsole } from "./console-runtime-vc3JQEuq.js";
|
|
2
|
+
import { _ as forwardedRequestOrigin, a as getAuthForDefinition, c as withSessionMarker, d as eventClientAddress, f as setRequestClientAddress, g as setAuthResponseOutcome, h as setAuthOutcome, l as resolveAuthOptions, m as runWithAuthEvent, n as createBetterAuthOptions, o as requestProvider, p as withClientAddress, r as envResolverFor, s as resolveDefaultDefinition, t as authForRequest, u as trustsProxyHeaders } from "./auth-instance-_J7R9Qs1.js";
|
|
3
|
+
import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-zKi7NrvK.js";
|
|
4
|
+
import { a as normalizeAuthBasePath } from "./access-pages-BwImVHN_.js";
|
|
5
|
+
import { n as authRequestEvent, r as unwrapAuthRequest } from "./request-Dpq7GO8B.js";
|
|
6
|
+
import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-1FMcMnRh.js";
|
|
7
|
+
import { n as getAuthRuntimeState } from "./runtime-state-DtKUfxKq.js";
|
|
8
|
+
import { t as readSetCookies } from "./set-cookie-DkqM1kvj.js";
|
|
12
9
|
import { createAuthAccessRouteMatcher } from "./runtime/server.js";
|
|
13
|
-
import { n as checkAbility, t as AbilityError } from "./ability-error-
|
|
14
|
-
import {
|
|
10
|
+
import { n as checkAbility, t as AbilityError } from "./ability-error-BHhPkrZd.js";
|
|
11
|
+
import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-DZqMiae_.js";
|
|
12
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-BssJr_2t.js";
|
|
13
|
+
import { i as notMemberError, l as findAccessPolicyPlugin } from "./members-D3_Q5XJb.js";
|
|
14
|
+
import { n as mcpOAuthResources, t as isJwsToken } from "./mcp-config-C7srUMIZ.js";
|
|
15
15
|
import { defineErrors, toResultError } from "@vite-hub/runtime";
|
|
16
16
|
import { HTTPError } from "nitro/h3";
|
|
17
17
|
import { parseUserOutput } from "better-auth/db";
|
|
18
18
|
import abilities from "#vitehub/auth/abilities";
|
|
19
19
|
import { isRuntimeResponse } from "@vite-hub/runtime/internal/runtime-type";
|
|
20
20
|
import { betterAuth } from "better-auth";
|
|
21
|
-
|
|
21
|
+
// src/caller.ts
|
|
22
22
|
const callerErrors = /*#__PURE__*/ defineErrors({
|
|
23
23
|
docs: "https://vitehub.dev/docs/auth/diagnostics",
|
|
24
24
|
codes: { AUTH_SIGNED_OUT: {
|
|
@@ -27,8 +27,7 @@ const callerErrors = /*#__PURE__*/ defineErrors({
|
|
|
27
27
|
} }
|
|
28
28
|
});
|
|
29
29
|
const signedOutError = () => callerErrors.AUTH_SIGNED_OUT();
|
|
30
|
-
|
|
31
|
-
//#region src/internal/server.ts
|
|
30
|
+
// src/internal/server.ts
|
|
32
31
|
function hasHappyDomRequestState(value) {
|
|
33
32
|
const ownSymbols = Object.getOwnPropertySymbols(value);
|
|
34
33
|
const prototypeSymbols = Object.getOwnPropertySymbols(Object.getPrototypeOf(value) ?? {});
|
|
@@ -249,7 +248,11 @@ function handleAuthRequest(definition, input, event = authRequestEvent(input)) {
|
|
|
249
248
|
env: envResolverFor(definition)
|
|
250
249
|
});
|
|
251
250
|
const auth = requestProvider(definition, resolved);
|
|
252
|
-
return runWithAuthEvent(event, () =>
|
|
251
|
+
return runWithAuthEvent(event, async () => {
|
|
252
|
+
const response = await (handleSignInRoute(auth, resolved.options, request, address) ?? auth.handler(setRequestClientAddress(toRequest(request), address)));
|
|
253
|
+
await setAuthResponseOutcome(event, response);
|
|
254
|
+
return response;
|
|
255
|
+
});
|
|
253
256
|
}
|
|
254
257
|
/**
|
|
255
258
|
* With a provider in `access.signIn`, the Auth route also answers `GET <basePath>/sign-in` and `GET <basePath>/sign-out`, so a link
|
|
@@ -522,9 +525,18 @@ function checkedAuthorization(request, session, user) {
|
|
|
522
525
|
user
|
|
523
526
|
});
|
|
524
527
|
}
|
|
525
|
-
function reject(response) {
|
|
528
|
+
function reject(input, response) {
|
|
529
|
+
logRefusal(input, response);
|
|
526
530
|
return { response };
|
|
527
531
|
}
|
|
532
|
+
function logRefusal(input, response) {
|
|
533
|
+
const code = refusalCodes.get(response);
|
|
534
|
+
setAuthOutcome(input, {
|
|
535
|
+
outcome: "refused",
|
|
536
|
+
status: response.status,
|
|
537
|
+
...code ? { code } : {}
|
|
538
|
+
});
|
|
539
|
+
}
|
|
528
540
|
const nativeResponseClone = Object.getOwnPropertyDescriptor(Response.prototype, "clone")?.value;
|
|
529
541
|
/**
|
|
530
542
|
* A Response of this runtime with an own `then` would be assimilated as a thenable by the host that awaits it.
|
|
@@ -688,9 +700,9 @@ async function runAccessAuthorize(authorize, context, deny = () => createForbidd
|
|
|
688
700
|
}
|
|
689
701
|
async function checkAuthRequest(input, definition, routeIndexes, requiredAuthorizeRouteIndexes = [], redirectToSignIn = true, resolveIdentity, signInURLs) {
|
|
690
702
|
const { auth, event, options, refusal: providerRefusal, request, session } = await readRequestSession(input, definition);
|
|
691
|
-
if (providerRefusal) return reject(createProviderRefusalResponse(providerRefusal));
|
|
703
|
+
if (providerRefusal) return reject(input, createProviderRefusalResponse(providerRefusal));
|
|
692
704
|
const identity = await resolveIdentity?.(toRequest(request), input, Boolean(session));
|
|
693
|
-
if (isRuntimeResponse(identity)) return reject(identity);
|
|
705
|
+
if (isRuntimeResponse(identity)) return reject(input, identity);
|
|
694
706
|
if (identity || session) {
|
|
695
707
|
const authorization = checkedAuthorization(request, identity ? {} : session.session, identity ?? session.user);
|
|
696
708
|
if (routeIndexes === void 0) return { authorization };
|
|
@@ -698,43 +710,47 @@ async function checkAuthRequest(input, definition, routeIndexes, requiredAuthori
|
|
|
698
710
|
const routes = authAccessRoutes(options, routeIndexes);
|
|
699
711
|
for (const [index, route] of routes.entries()) {
|
|
700
712
|
const authorize = typeof route === "object" && route !== null ? route.authorize : void 0;
|
|
701
|
-
if (!authorize && requiredAuthorizeRoutes.has(routeIndexes[index])) return reject(createForbiddenResponse(request));
|
|
713
|
+
if (!authorize && requiredAuthorizeRoutes.has(routeIndexes[index])) return reject(input, createForbiddenResponse(request));
|
|
702
714
|
if (!authorize) continue;
|
|
703
715
|
const rejection = await runAccessAuthorize(authorize, {
|
|
704
716
|
...authorization,
|
|
705
717
|
event
|
|
706
718
|
});
|
|
707
|
-
if (rejection.response) return reject(rejection.response);
|
|
719
|
+
if (rejection.response) return reject(input, rejection.response);
|
|
708
720
|
}
|
|
709
721
|
return { authorization };
|
|
710
722
|
}
|
|
711
|
-
if (!wantsHtml(request)) return reject(createRefusalResponse("SIGNED_OUT"));
|
|
712
|
-
if (!redirectToSignIn) return reject(createRefusalResponse("SIGNED_OUT"));
|
|
713
|
-
if (new URL(request.url).searchParams.has("auth_error")) return reject(createTextRefusalResponse("Unauthorized.", "SIGNED_OUT"));
|
|
723
|
+
if (!wantsHtml(request)) return reject(input, createRefusalResponse("SIGNED_OUT"));
|
|
724
|
+
if (!redirectToSignIn) return reject(input, createRefusalResponse("SIGNED_OUT"));
|
|
725
|
+
if (new URL(request.url).searchParams.has("auth_error")) return reject(input, createTextRefusalResponse("Unauthorized.", "SIGNED_OUT"));
|
|
714
726
|
const signIn = providerSignIn(options);
|
|
715
|
-
return reject(signIn ? await createSignInResponse(auth, options, {
|
|
727
|
+
return reject(input, signIn ? await createSignInResponse(auth, options, {
|
|
716
728
|
...signIn,
|
|
717
729
|
...signInURLs
|
|
718
730
|
}, eventClientAddress(event)) : createRefusalResponse("SIGNED_OUT"));
|
|
719
731
|
}
|
|
720
732
|
async function checkAuthorizeRequest(input, authorize, definition) {
|
|
721
733
|
const { refusal: providerRefusal, request, session } = await readRequestSession(input, definition);
|
|
722
|
-
if (providerRefusal) return reject(createProviderRefusalResponse(providerRefusal));
|
|
723
|
-
if (!session) return reject(createRefusalResponse("SIGNED_OUT"));
|
|
734
|
+
if (providerRefusal) return reject(input, createProviderRefusalResponse(providerRefusal));
|
|
735
|
+
if (!session) return reject(input, createRefusalResponse("SIGNED_OUT"));
|
|
724
736
|
const authorization = checkedAuthorization(request, session.session, session.user);
|
|
725
737
|
if (authorize === true) return { authorization };
|
|
726
738
|
const rejection = await runAccessAuthorize(authorize, {
|
|
727
739
|
...authorization,
|
|
728
740
|
event: authRequestEvent(input)
|
|
729
741
|
});
|
|
730
|
-
return rejection.response ? reject(rejection.response) : { authorization };
|
|
742
|
+
return rejection.response ? reject(input, rejection.response) : { authorization };
|
|
731
743
|
}
|
|
732
744
|
function withAnonymousAuthorization(authorize, handler, definition) {
|
|
733
745
|
if (typeof authorize !== "function") throw authErrorDiagnostics.AUTH_R0014({ message: "[vitehub] `authorize` must be a function." });
|
|
734
746
|
if (typeof handler !== "function") throw authErrorDiagnostics.AUTH_R0015({ message: "[vitehub] withAnonymousAuthorization() requires a handler function." });
|
|
735
747
|
return async (input) => {
|
|
736
748
|
const { refusal: providerRefusal, request, session } = await readRequestSession(input, definition ?? resolveDefaultDefinition());
|
|
737
|
-
if (providerRefusal)
|
|
749
|
+
if (providerRefusal) {
|
|
750
|
+
const response = createProviderRefusalResponse(providerRefusal);
|
|
751
|
+
logRefusal(input, response);
|
|
752
|
+
return sendSessionCookies(input, response);
|
|
753
|
+
}
|
|
738
754
|
const authorization = session ? checkedAuthorization(request, session.session, session.user) : Object.freeze({
|
|
739
755
|
request,
|
|
740
756
|
session: null,
|
|
@@ -745,7 +761,10 @@ function withAnonymousAuthorization(authorize, handler, definition) {
|
|
|
745
761
|
...authorization,
|
|
746
762
|
event: authRequestEvent(input)
|
|
747
763
|
}, deny);
|
|
748
|
-
if (rejection.response)
|
|
764
|
+
if (rejection.response) {
|
|
765
|
+
logRefusal(input, rejection.response);
|
|
766
|
+
return sendSessionCookies(input, rejection.response);
|
|
767
|
+
}
|
|
749
768
|
return sendSessionCookies(input, await handler(input, authorization));
|
|
750
769
|
};
|
|
751
770
|
}
|
|
@@ -828,7 +847,7 @@ async function readCaller(event, definition) {
|
|
|
828
847
|
const auth = authForRequest(request, authRequestEvent(event), definition);
|
|
829
848
|
const { options } = await auth.$context;
|
|
830
849
|
if (isJwsToken(token) && mcpOAuthResources(options.plugins).length) {
|
|
831
|
-
const { verifyAppAccessToken } = await import("./mcp-token
|
|
850
|
+
const { verifyAppAccessToken } = await import("./mcp-token--KuLYEub.js").then((n) => n.i);
|
|
832
851
|
const url = new URL(request.url);
|
|
833
852
|
const [error, caller] = await verifyAppAccessToken(token, trustsProxyHeaders(options) ? forwardedRequestOrigin(request) : url.origin, url.pathname, auth);
|
|
834
853
|
if (error) return [error, void 0];
|
|
@@ -976,5 +995,4 @@ function getAuthConsoleForRequest(request, event, host) {
|
|
|
976
995
|
});
|
|
977
996
|
return createAuthConsole(requestProvider(definition, resolved), resolved.options.console, resolved.options.events ? resolved.options.events.store : void 0, host);
|
|
978
997
|
}
|
|
979
|
-
//#endregion
|
|
980
998
|
export { toAuthRequest as C, withAuthorization as D, withAuth as E, signOut as S, withAnonymousAuthorization as T, requireAbility as _, checkAuthMember as a, requireAuthorization as b, createAuthForRequest as c, getAuth as d, getAuthConsoleForRequest as f, listAuthEvents as g, handleAuthRequest as h, can as i, createAuthHandler as l, handleAuth as m, assertAuthOrigin as n, createAuth as o, getAuthEvents as p, authRoute as r, createAuthAccessHandler as s, aggregateAuthEvents as t, createAuthRequestRuntimeOptions as u, requireAuth as v, useAuth as w, requireCaller as x, requireAuthAccessRoutes as y };
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./own-access-C22hSIuF.js";
|
|
2
|
+
import { E as AuthRequestInput, H as ResolvedAuthAccessRoute, _ as AuthDefinition } from "./types-BHSgxyvV.js";
|
|
2
3
|
import { AccessAuthorizationContext, ViteHubContext } from "@vite-hub/runtime";
|
|
3
|
-
//#region src/runtime-state.d.ts
|
|
4
4
|
type AuthRuntimeEnvResolver = (event?: ViteHubContext) => Record<string, unknown>;
|
|
5
5
|
type AuthAccessIdentityResolver = (request: Request, event: AuthRequestInput, hasSession: boolean) => Promise<AccessAuthorizationContext<unknown, false>["user"] | Response | undefined>;
|
|
6
6
|
declare function resetAuth(): void;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/runtime/server.d.ts
|
|
9
7
|
declare function setAuthRuntimeEnvResolver(resolver: AuthRuntimeEnvResolver | undefined, definition?: AuthDefinition): void;
|
|
8
|
+
/**
|
|
9
|
+
* Stops the server when `access.pages` of the Auth Definition differs from the map that the Nuxt build read, for
|
|
10
|
+
* example when `access` is a variable: the build guards only the pages that it reads. A Definition callback returns its
|
|
11
|
+
* options when Auth resolves them, so the check runs on each result.
|
|
12
|
+
*/
|
|
13
|
+
declare function checkBuiltAuthPages(definition: AuthDefinition, built: Readonly<Record<string, unknown>>): void;
|
|
10
14
|
/**
|
|
11
15
|
* Let a trusted server integration authenticate one exact mounted path without a browser session.
|
|
12
16
|
* Resolved users still pass every matching Auth access route's authorize callback, with an empty session.
|
|
13
17
|
*/
|
|
14
18
|
declare function setAuthAccessIdentityResolver(path: string, resolver: AuthAccessIdentityResolver | undefined): void;
|
|
15
|
-
/**
|
|
16
|
-
* The Nitro route `meta` of a handler that checks its own access, such as the ViteHub Console route. The access routes
|
|
17
|
-
* leave a request to the handler that Nitro routed it to when that handler has this meta, whatever its path and method.
|
|
18
|
-
* The exception follows the dispatch, so an app route file on the same path keeps the access routes.
|
|
19
|
-
*/
|
|
20
|
-
declare const authAccessHandlerMeta: Readonly<{
|
|
21
|
-
vitehubAuthAccess: "handler";
|
|
22
|
-
}>;
|
|
23
19
|
interface AuthAccessRouteMatch {
|
|
24
20
|
index: number;
|
|
25
21
|
authorize: boolean;
|
|
@@ -37,5 +33,4 @@ type AuthAccessHandler = (input: AuthRequestInput) => Promise<Response | undefin
|
|
|
37
33
|
declare function createLazyAuthAccessHandler(routes: readonly ResolvedAuthAccessRoute[], load: () => Promise<{
|
|
38
34
|
createAuthAccessHandler: (routes: readonly ResolvedAuthAccessRoute[], definition?: undefined, publicRoutes?: readonly string[]) => AuthAccessHandler;
|
|
39
35
|
}>, publicRoutes?: readonly string[]): AuthAccessHandler;
|
|
40
|
-
|
|
41
|
-
export { setAuthAccessIdentityResolver as a, createLazyAuthAccessHandler as i, authAccessHandlerMeta as n, setAuthRuntimeEnvResolver as o, createAuthAccessRouteMatcher as r, resetAuth as s, AuthAccessRouteMatch as t };
|
|
36
|
+
export { setAuthAccessIdentityResolver as a, createLazyAuthAccessHandler as i, checkBuiltAuthPages as n, setAuthRuntimeEnvResolver as o, createAuthAccessRouteMatcher as r, resetAuth as s, AuthAccessRouteMatch as t };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, F as
|
|
3
|
-
import { n as AbilityErrorData, t as AbilityError } from "./ability-error-
|
|
2
|
+
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, F as AuthCallerErrorCode, I as AuthCallerUser, L as AuthMemberErrorCode, O as withAuth, P as AuthCaller, S as requireAuthorization, a as authRoute, b as requireAuth, d as createAuthHandler, g as handleAuth, h as getAuthEvents, k as withAuthorization, m as getAuthConsoleForRequest, o as can, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, v as listAuthEvents, w as signOut, y as requireAbility } from "./server-CFWlYQJb.js";
|
|
3
|
+
import { n as AbilityErrorData, t as AbilityError } from "./ability-error-C1c30O6E.js";
|
|
4
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 { 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-
|
|
1
|
+
import { t as AbilityError } from "./ability-error-BHhPkrZd.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-D4Hi4TBI.js";
|
|
3
3
|
export { AbilityError, aggregateAuthEvents, can, checkAuthMember, createAuthHandler, authRoute as default, getAuthConsoleForRequest, getAuthEvents, handleAuth, listAuthEvents, requireAbility, requireAuth, requireAuthorization, requireCaller, signOut, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-
|
|
3
|
-
import { t as isRecord } from "./object-
|
|
4
|
-
import { n as authRequestEvent } from "./request-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-BssJr_2t.js";
|
|
2
|
+
import { r as throwAuthenticationProviderError, t as readSetCookies } from "./set-cookie-DkqM1kvj.js";
|
|
3
|
+
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
4
|
+
import { n as authRequestEvent } from "./request-Dpq7GO8B.js";
|
|
5
5
|
import { HTTPError } from "nitro/h3";
|
|
6
6
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
7
|
-
|
|
7
|
+
// src/session.ts
|
|
8
8
|
const apiErrorHeaders = Symbol.for("better-call:api-error-headers");
|
|
9
9
|
async function getAuthenticationSession(auth, input) {
|
|
10
10
|
const [api, getSession] = await readProvider(() => {
|
|
@@ -151,8 +151,7 @@ function readClientApiError(error) {
|
|
|
151
151
|
function readProperty(value, property) {
|
|
152
152
|
return value[property];
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
//#region src/session-cookies.ts
|
|
154
|
+
// src/session-cookies.ts
|
|
156
155
|
const preparedSessionCookies = /* @__PURE__ */ new WeakMap();
|
|
157
156
|
/**
|
|
158
157
|
* Puts the cookies that Better Auth set while it read the session in the prepared response of the request: the renewed
|
|
@@ -287,5 +286,4 @@ function isResponseLike(value) {
|
|
|
287
286
|
return false;
|
|
288
287
|
}
|
|
289
288
|
}
|
|
290
|
-
//#endregion
|
|
291
289
|
export { getAuthenticationSession as a, authenticationRefusalResponse as i, sendSessionCookies as n, authenticationRefusalError as r, prepareSessionCookies as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-BssJr_2t.js";
|
|
2
2
|
import { ViteHubError, isViteHubError } from "@vite-hub/runtime";
|
|
3
|
-
|
|
3
|
+
// src/errors.ts
|
|
4
4
|
function invalidAuthenticationErrorOptions() {
|
|
5
5
|
throw authErrorDiagnostics.AUTH_R0004({ message: "[vitehub] Invalid authentication error options." });
|
|
6
6
|
}
|
|
@@ -26,8 +26,7 @@ function isAuthenticationAbortError(error) {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
//#region src/set-cookie.ts
|
|
29
|
+
// src/set-cookie.ts
|
|
31
30
|
/** Read separate cookies even when a Fetch runtime exposes only a combined field. */
|
|
32
31
|
function readSetCookies(headers) {
|
|
33
32
|
return typeof headers.getSetCookie === "function" ? headers.getSetCookie() : splitCombinedSetCookie(headers.get("set-cookie"));
|
|
@@ -86,5 +85,4 @@ function isKnownCookieAttribute(cookie, hasBoundaryWhitespace) {
|
|
|
86
85
|
if (lastSemicolon >= 0 && cookie.slice(lastSemicolon + 1).includes(",") && !/^expires\s*=/i.test(lastAttribute)) return false;
|
|
87
86
|
return hasBoundaryWhitespace || !lastAttribute.includes("=");
|
|
88
87
|
}
|
|
89
|
-
//#endregion
|
|
90
88
|
export { invalidAuthenticationErrorOptions as n, throwAuthenticationProviderError as r, readSetCookies as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/table-specs.d.ts
|
|
2
1
|
/** The keys of the Better Auth tables. Better Auth's Drizzle adapter finds each model by this key. */
|
|
3
2
|
type AuthTableName = "user" | "session" | "account" | "verification" | "jwks" | "oauthClient" | "oauthResource" | "oauthClientResource" | "oauthRefreshToken" | "oauthAccessToken" | "oauthConsent" | "oauthClientAssertion" | "rateLimit" | "organization" | "member" | "invitation" | "passkey";
|
|
4
3
|
type AuthFieldType = "boolean" | "date" | "json" | "number" | "number[]" | "string" | "string[]";
|
|
@@ -820,6 +819,260 @@ interface AuthPluginSchema {
|
|
|
820
819
|
/** Tables that the plugin adds. */
|
|
821
820
|
tables?: Readonly<Record<string, AuthTableSpec>>;
|
|
822
821
|
}
|
|
822
|
+
declare const pluginSchemas: {
|
|
823
|
+
readonly anonymous: {
|
|
824
|
+
readonly fields: {
|
|
825
|
+
readonly user: {
|
|
826
|
+
readonly isAnonymous: {
|
|
827
|
+
readonly type: "boolean";
|
|
828
|
+
readonly defaultValue: false;
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
};
|
|
832
|
+
};
|
|
833
|
+
readonly apiKey: {
|
|
834
|
+
readonly tables: {
|
|
835
|
+
readonly apikey: {
|
|
836
|
+
readonly fields: {
|
|
837
|
+
readonly configId: {
|
|
838
|
+
readonly type: "string";
|
|
839
|
+
readonly required: true;
|
|
840
|
+
readonly index: true;
|
|
841
|
+
readonly defaultValue: "default";
|
|
842
|
+
};
|
|
843
|
+
readonly name: {
|
|
844
|
+
readonly type: "string";
|
|
845
|
+
};
|
|
846
|
+
readonly start: {
|
|
847
|
+
readonly type: "string";
|
|
848
|
+
};
|
|
849
|
+
readonly referenceId: {
|
|
850
|
+
readonly type: "string";
|
|
851
|
+
readonly required: true;
|
|
852
|
+
readonly index: true;
|
|
853
|
+
};
|
|
854
|
+
readonly prefix: {
|
|
855
|
+
readonly type: "string";
|
|
856
|
+
};
|
|
857
|
+
readonly key: {
|
|
858
|
+
readonly type: "string";
|
|
859
|
+
readonly required: true;
|
|
860
|
+
readonly index: true;
|
|
861
|
+
};
|
|
862
|
+
readonly refillInterval: {
|
|
863
|
+
readonly type: "number";
|
|
864
|
+
readonly bigint: true;
|
|
865
|
+
};
|
|
866
|
+
readonly refillAmount: {
|
|
867
|
+
readonly type: "number";
|
|
868
|
+
};
|
|
869
|
+
readonly lastRefillAt: {
|
|
870
|
+
readonly type: "date";
|
|
871
|
+
};
|
|
872
|
+
readonly enabled: {
|
|
873
|
+
readonly type: "boolean";
|
|
874
|
+
readonly defaultValue: true;
|
|
875
|
+
};
|
|
876
|
+
readonly rateLimitEnabled: {
|
|
877
|
+
readonly type: "boolean";
|
|
878
|
+
readonly defaultValue: true;
|
|
879
|
+
};
|
|
880
|
+
readonly rateLimitTimeWindow: {
|
|
881
|
+
readonly type: "number";
|
|
882
|
+
readonly bigint: true;
|
|
883
|
+
readonly defaultValue: 86_400_000;
|
|
884
|
+
};
|
|
885
|
+
readonly rateLimitMax: {
|
|
886
|
+
readonly type: "number";
|
|
887
|
+
readonly defaultValue: 10;
|
|
888
|
+
};
|
|
889
|
+
readonly requestCount: {
|
|
890
|
+
readonly type: "number";
|
|
891
|
+
readonly defaultValue: 0;
|
|
892
|
+
};
|
|
893
|
+
readonly remaining: {
|
|
894
|
+
readonly type: "number";
|
|
895
|
+
};
|
|
896
|
+
readonly lastRequest: {
|
|
897
|
+
readonly type: "date";
|
|
898
|
+
};
|
|
899
|
+
readonly expiresAt: {
|
|
900
|
+
readonly type: "date";
|
|
901
|
+
};
|
|
902
|
+
readonly createdAt: {
|
|
903
|
+
readonly type: "date";
|
|
904
|
+
readonly required: true;
|
|
905
|
+
};
|
|
906
|
+
readonly updatedAt: {
|
|
907
|
+
readonly type: "date";
|
|
908
|
+
readonly required: true;
|
|
909
|
+
};
|
|
910
|
+
readonly permissions: {
|
|
911
|
+
readonly type: "string";
|
|
912
|
+
};
|
|
913
|
+
readonly metadata: {
|
|
914
|
+
readonly type: "string";
|
|
915
|
+
};
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
};
|
|
919
|
+
};
|
|
920
|
+
readonly lastLoginMethod: {
|
|
921
|
+
readonly fields: {
|
|
922
|
+
readonly user: {
|
|
923
|
+
readonly lastLoginMethod: {
|
|
924
|
+
readonly type: "string";
|
|
925
|
+
};
|
|
926
|
+
};
|
|
927
|
+
};
|
|
928
|
+
};
|
|
929
|
+
readonly phoneNumber: {
|
|
930
|
+
readonly fields: {
|
|
931
|
+
readonly user: {
|
|
932
|
+
readonly phoneNumber: {
|
|
933
|
+
readonly type: "string";
|
|
934
|
+
readonly unique: true;
|
|
935
|
+
};
|
|
936
|
+
readonly phoneNumberVerified: {
|
|
937
|
+
readonly type: "boolean";
|
|
938
|
+
};
|
|
939
|
+
};
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
readonly stripe: {
|
|
943
|
+
readonly fields: {
|
|
944
|
+
readonly user: {
|
|
945
|
+
readonly stripeCustomerId: {
|
|
946
|
+
readonly type: "string";
|
|
947
|
+
};
|
|
948
|
+
};
|
|
949
|
+
readonly organization: {
|
|
950
|
+
readonly stripeCustomerId: {
|
|
951
|
+
readonly type: "string";
|
|
952
|
+
};
|
|
953
|
+
};
|
|
954
|
+
};
|
|
955
|
+
readonly tables: {
|
|
956
|
+
readonly subscription: {
|
|
957
|
+
readonly fields: {
|
|
958
|
+
readonly plan: {
|
|
959
|
+
readonly type: "string";
|
|
960
|
+
readonly required: true;
|
|
961
|
+
};
|
|
962
|
+
readonly referenceId: {
|
|
963
|
+
readonly type: "string";
|
|
964
|
+
readonly required: true;
|
|
965
|
+
};
|
|
966
|
+
readonly stripeCustomerId: {
|
|
967
|
+
readonly type: "string";
|
|
968
|
+
};
|
|
969
|
+
readonly stripeSubscriptionId: {
|
|
970
|
+
readonly type: "string";
|
|
971
|
+
};
|
|
972
|
+
readonly status: {
|
|
973
|
+
readonly type: "string";
|
|
974
|
+
readonly defaultValue: "incomplete";
|
|
975
|
+
};
|
|
976
|
+
readonly periodStart: {
|
|
977
|
+
readonly type: "date";
|
|
978
|
+
};
|
|
979
|
+
readonly periodEnd: {
|
|
980
|
+
readonly type: "date";
|
|
981
|
+
};
|
|
982
|
+
readonly trialStart: {
|
|
983
|
+
readonly type: "date";
|
|
984
|
+
};
|
|
985
|
+
readonly trialEnd: {
|
|
986
|
+
readonly type: "date";
|
|
987
|
+
};
|
|
988
|
+
readonly cancelAtPeriodEnd: {
|
|
989
|
+
readonly type: "boolean";
|
|
990
|
+
readonly defaultValue: false;
|
|
991
|
+
};
|
|
992
|
+
readonly cancelAt: {
|
|
993
|
+
readonly type: "date";
|
|
994
|
+
};
|
|
995
|
+
readonly canceledAt: {
|
|
996
|
+
readonly type: "date";
|
|
997
|
+
};
|
|
998
|
+
readonly endedAt: {
|
|
999
|
+
readonly type: "date";
|
|
1000
|
+
};
|
|
1001
|
+
readonly seats: {
|
|
1002
|
+
readonly type: "number";
|
|
1003
|
+
};
|
|
1004
|
+
readonly billingInterval: {
|
|
1005
|
+
readonly type: "string";
|
|
1006
|
+
};
|
|
1007
|
+
readonly stripeScheduleId: {
|
|
1008
|
+
readonly type: "string";
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
};
|
|
1014
|
+
readonly twoFactor: {
|
|
1015
|
+
readonly fields: {
|
|
1016
|
+
readonly user: {
|
|
1017
|
+
readonly twoFactorEnabled: {
|
|
1018
|
+
readonly type: "boolean";
|
|
1019
|
+
readonly defaultValue: false;
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
};
|
|
1023
|
+
readonly tables: {
|
|
1024
|
+
readonly twoFactor: {
|
|
1025
|
+
readonly fields: {
|
|
1026
|
+
readonly secret: {
|
|
1027
|
+
readonly type: "string";
|
|
1028
|
+
readonly required: true;
|
|
1029
|
+
readonly index: true;
|
|
1030
|
+
};
|
|
1031
|
+
readonly backupCodes: {
|
|
1032
|
+
readonly type: "string";
|
|
1033
|
+
readonly required: true;
|
|
1034
|
+
};
|
|
1035
|
+
readonly userId: {
|
|
1036
|
+
readonly type: "string";
|
|
1037
|
+
readonly required: true;
|
|
1038
|
+
readonly index: true;
|
|
1039
|
+
readonly references: {
|
|
1040
|
+
readonly model: "user";
|
|
1041
|
+
readonly field: "id";
|
|
1042
|
+
readonly onDelete: "cascade";
|
|
1043
|
+
};
|
|
1044
|
+
};
|
|
1045
|
+
readonly verified: {
|
|
1046
|
+
readonly type: "boolean";
|
|
1047
|
+
readonly defaultValue: true;
|
|
1048
|
+
};
|
|
1049
|
+
readonly failedVerificationCount: {
|
|
1050
|
+
readonly type: "number";
|
|
1051
|
+
readonly defaultValue: 0;
|
|
1052
|
+
};
|
|
1053
|
+
readonly lockedUntil: {
|
|
1054
|
+
readonly type: "date";
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
};
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
readonly username: {
|
|
1061
|
+
readonly fields: {
|
|
1062
|
+
readonly user: {
|
|
1063
|
+
readonly username: {
|
|
1064
|
+
readonly type: "string";
|
|
1065
|
+
readonly unique: true;
|
|
1066
|
+
};
|
|
1067
|
+
readonly displayUsername: {
|
|
1068
|
+
readonly type: "string";
|
|
1069
|
+
};
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
/** The literal type of `authPluginSchemas`, which types the plugin tables and columns. */
|
|
1075
|
+
type AuthPluginSchemas = typeof pluginSchemas;
|
|
823
1076
|
/**
|
|
824
1077
|
* The tables and columns of each plugin of `AuthSchemaPlugin`, with all of its options on: a column or table that the
|
|
825
1078
|
* options turn off stays empty. A test checks the plugins of `better-auth/plugins` against Better Auth's own
|
|
@@ -838,5 +1091,4 @@ interface AuthSchemaOptions {
|
|
|
838
1091
|
* A field that a table has already must have the same type and `required`.
|
|
839
1092
|
*/
|
|
840
1093
|
declare function resolveAuthTableSpecs(options?: AuthSchemaOptions): Record<string, AuthTableSpec>;
|
|
841
|
-
|
|
842
|
-
export { AuthTableField as a, authPluginSchemas as c, AuthSchemaPlugin as i, authTableSpecs as l, AuthCoreTableSpecs as n, AuthTableName as o, AuthSchemaOptions as r, AuthTableSpec as s, AuthCoreModel as t, resolveAuthTableSpecs as u };
|
|
1094
|
+
export { AuthSchemaPlugin as a, AuthTableSpec as c, resolveAuthTableSpecs as d, AuthSchemaOptions as i, authPluginSchemas as l, AuthCoreTableSpecs as n, AuthTableField as o, AuthPluginSchemas as r, AuthTableName as s, AuthCoreModel as t, authTableSpecs as u };
|