@vite-hub/auth 0.6.0 → 0.6.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/dist/{abilities-D3XlrYDw.d.ts → abilities-BYOcyQ9B.d.ts} +1 -1
- package/dist/abilities.d.ts +1 -1
- package/dist/{auth-instance-BpI9Ps8A.js → auth-instance-BWiRS9QZ.js} +9 -28
- package/dist/client-request-BzMKtfCY.js +52 -0
- package/dist/{console-runtime-DAjLTLrN.d.ts → console-runtime-DMH1I2fl.d.ts} +1 -1
- package/dist/console-runtime.d.ts +2 -2
- package/dist/console.d.ts +1 -1
- package/dist/database.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/internal/server.d.ts +2 -2
- package/dist/internal/server.js +2 -2
- package/dist/{mcp-token-DzGivm7f.js → mcp-token-CuqdbBy8.js} +4 -2
- package/dist/mcp.js +4 -2
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +1 -1
- package/dist/{own-access-Dt-I5-PT.d.ts → own-access-BNcxKrDl.d.ts} +1 -1
- package/dist/runtime/client-request-plugin.d.ts +1 -0
- package/dist/runtime/client-request-plugin.js +18 -0
- 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 +1 -1
- package/dist/runtime/server.d.ts +2 -2
- package/dist/{server-DL9MSuyj.d.ts → server-BHniJi2m.d.ts} +2 -2
- package/dist/{server-Cun232hb.d.ts → server-C4Kni3Vj.d.ts} +4 -4
- package/dist/{server-_eUOlAJ8.js → server-Iru6jcnW.js} +4 -3
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-BP9_XUr9.d.ts → types-DmH31d2t.d.ts} +5 -0
- package/dist/{vite-Dem1i1rL.js → vite-CpWhT1Wi.js} +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/vue.d.ts +2 -2
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V as RegisteredAuth, l as AuthAnonymousAuthorization, p as AuthAuthorization } from "./types-
|
|
1
|
+
import { V as RegisteredAuth, l as AuthAnonymousAuthorization, p as AuthAuthorization } from "./types-DmH31d2t.js";
|
|
2
2
|
/** A 4xx status that a rule can refuse with. `403` is the default. */
|
|
3
3
|
type AbilityStatus = 400 | 401 | 402 | 403 | 404 | 405 | 409 | 410 | 422 | 423 | 429 | 451;
|
|
4
4
|
declare const abilityDenial: unique symbol;
|
package/dist/abilities.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AbilityRefusal, c as AbilityStatus, d as GuestAbilityRule, f as defineAbilities, i as AbilityName, l as AbilityUser, m as guest, n as AbilityAuthorization, o as AbilityRule, p as deny, r as AbilityDenial, s as AbilityRules, t as AbilityArgs, u as AbilityVerdict } from "./abilities-
|
|
1
|
+
import { a as AbilityRefusal, c as AbilityStatus, d as GuestAbilityRule, f as defineAbilities, i as AbilityName, l as AbilityUser, m as guest, n as AbilityAuthorization, o as AbilityRule, p as deny, r as AbilityDenial, s as AbilityRules, t as AbilityArgs, u as AbilityVerdict } from "./abilities-BYOcyQ9B.js";
|
|
2
2
|
export { AbilityArgs, AbilityAuthorization, AbilityDenial, AbilityName, AbilityRefusal, AbilityRule, AbilityRules, AbilityStatus, AbilityUser, AbilityVerdict, GuestAbilityRule, defineAbilities, deny, guest };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as forwardedRequestOrigin, t as clientRequest } from "./client-request-BzMKtfCY.js";
|
|
1
2
|
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
2
3
|
import { i as resolveAuthMountPath } from "./application-path-zKi7NrvK.js";
|
|
3
4
|
import { a as readMembers, c as createAccessPolicyPlugin, d as createAdminClaimPlugin, f as readAdminClaim, g as readAdmins, h as createAdminsPlugin, n as createMembersGate, o as withMemberScopes, t as assertMembersSessionStore } from "./members-CwPIx10t.js";
|
|
@@ -24,27 +25,6 @@ import definitionForApp, { getAuthApp } from "#vitehub/auth/definition";
|
|
|
24
25
|
import { getViteHubTestMode } from "@vite-hub/runtime/internal/test-mode";
|
|
25
26
|
import { isWebContainer } from "@vite-hub/web-container/env";
|
|
26
27
|
import { hkdfSync } from "node:crypto";
|
|
27
|
-
// ../internal/src/runtime/request-origin.ts
|
|
28
|
-
function firstHeaderValue(headers, name) {
|
|
29
|
-
return headers.get(name)?.split(",", 1)[0]?.trim() || void 0;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The origin that the client used for `request`. A TLS-terminating proxy sends the client scheme in
|
|
33
|
-
* `X-Forwarded-Proto` and the client host in `X-Forwarded-Host`. Each proxy appends its value, so the first value wins.
|
|
34
|
-
* Without these headers, or with values that are not valid, the result is the origin of `request.url`.
|
|
35
|
-
*/
|
|
36
|
-
function forwardedRequestOrigin(request) {
|
|
37
|
-
const url = new URL(request.url);
|
|
38
|
-
const forwardedProtocol = firstHeaderValue(request.headers, "x-forwarded-proto")?.toLowerCase();
|
|
39
|
-
const protocol = forwardedProtocol === "http" || forwardedProtocol === "https" ? forwardedProtocol : url.protocol.slice(0, -1);
|
|
40
|
-
const host = firstHeaderValue(request.headers, "x-forwarded-host") ?? url.host;
|
|
41
|
-
if (/[\u0000-\u001F\s/\\?#@]/.test(host)) return url.origin;
|
|
42
|
-
try {
|
|
43
|
-
return new URL(`${protocol}://${host}`).origin;
|
|
44
|
-
} catch {
|
|
45
|
-
return url.origin;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
28
|
// src/password.ts
|
|
49
29
|
const scryptOptions = {
|
|
50
30
|
N: 16384,
|
|
@@ -1104,8 +1084,9 @@ function resolveAuthOptions(definition, input = {}) {
|
|
|
1104
1084
|
const callback = typeof definition.options === "function";
|
|
1105
1085
|
const usesContext = !request || callback;
|
|
1106
1086
|
const env = usesContext ? input.env?.(input.event) ?? {} : {};
|
|
1107
|
-
const
|
|
1108
|
-
const
|
|
1087
|
+
const client = request && clientRequest(request);
|
|
1088
|
+
const clientUrlOrigin = client ? new URL(client.url).origin : void 0;
|
|
1089
|
+
const proxiedOrigin = client ? forwardedRequestOrigin(client) : void 0;
|
|
1109
1090
|
const resolveAt = (origin) => {
|
|
1110
1091
|
const context = {
|
|
1111
1092
|
env,
|
|
@@ -1119,8 +1100,8 @@ function resolveAuthOptions(definition, input = {}) {
|
|
|
1119
1100
|
trusted: trustsProxyHeaders(declared)
|
|
1120
1101
|
};
|
|
1121
1102
|
};
|
|
1122
|
-
let resolved = resolveAt(
|
|
1123
|
-
if (request && callback && resolved.trusted && proxiedOrigin !==
|
|
1103
|
+
let resolved = resolveAt(clientUrlOrigin);
|
|
1104
|
+
if (request && callback && resolved.trusted && proxiedOrigin !== clientUrlOrigin) {
|
|
1124
1105
|
const forwarded = resolveAt(proxiedOrigin);
|
|
1125
1106
|
resolved = forwarded.trusted ? forwarded : {
|
|
1126
1107
|
trusted: false,
|
|
@@ -1135,8 +1116,8 @@ function resolveAuthOptions(definition, input = {}) {
|
|
|
1135
1116
|
}
|
|
1136
1117
|
const { declared, trusted } = resolved;
|
|
1137
1118
|
let requestRuntimeOptions = callback ? declared : {};
|
|
1138
|
-
if (
|
|
1139
|
-
const requestOrigin = trusted && proxiedOrigin ? proxiedOrigin :
|
|
1119
|
+
if (client) {
|
|
1120
|
+
const requestOrigin = trusted && proxiedOrigin ? proxiedOrigin : client.url;
|
|
1140
1121
|
const baseURL = requestRuntimeOptions.baseURL || resolvePublicUrl({ request: { url: requestOrigin } });
|
|
1141
1122
|
if (!baseURL) throw authErrorDiagnostics.AUTH_R0022({ message: `[vitehub] The request host ${new URL(requestOrigin).host} is not an origin of vitehub({ publicUrl }), so Auth has no base URL.` });
|
|
1142
1123
|
requestRuntimeOptions = {
|
|
@@ -1371,4 +1352,4 @@ function authForRequest(request, event, definition = resolveDefaultDefinition())
|
|
|
1371
1352
|
env: envResolverFor(definition)
|
|
1372
1353
|
}));
|
|
1373
1354
|
}
|
|
1374
|
-
export {
|
|
1355
|
+
export { getAuthForDefinition as a, withSessionMarker as c, eventClientAddress as d, setRequestClientAddress as f, setAuthResponseOutcome as g, setAuthOutcome as h, findVerifiedAuthUserId as i, resolveAuthOptions as l, runWithAuthEvent as m, createBetterAuthOptions as n, requestProvider as o, withClientAddress as p, envResolverFor as r, resolveDefaultDefinition as s, authForRequest as t, trustsProxyHeaders as u };
|
|
@@ -0,0 +1,52 @@
|
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { Ft as AuthEventStore, J as AuthConsoleAgent, K as AuthConsoleActivity, Z as AuthConsoleDescription, _t as AuthConsoleSessionUser, ct as AuthConsoleOptions, dt as AuthConsoleOverview, gt as AuthConsoleSession, it as AuthConsoleHostOptions, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, ot as AuthConsoleList, q as AuthConsoleActivityQuery, st as AuthConsoleMutation, tt as AuthConsoleField, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, yt as AuthConsoleUserDetail } from "./types-
|
|
1
|
+
import { Ft as AuthEventStore, J as AuthConsoleAgent, K as AuthConsoleActivity, Z as AuthConsoleDescription, _t as AuthConsoleSessionUser, ct as AuthConsoleOptions, dt as AuthConsoleOverview, gt as AuthConsoleSession, it as AuthConsoleHostOptions, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, ot as AuthConsoleList, q as AuthConsoleActivityQuery, st as AuthConsoleMutation, tt as AuthConsoleField, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, yt as AuthConsoleUserDetail } from "./types-DmH31d2t.js";
|
|
2
2
|
import { Result } from "@vite-hub/runtime";
|
|
3
3
|
import { AuthContext, BetterAuthOptions, DBAdapter } from "better-auth";
|
|
4
4
|
interface AuthConsole {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as AuthConsoleEventGroup, G as AuthConsoleAction, J as AuthConsoleAgent, K as AuthConsoleActivity, Q as AuthConsoleEvent, St as authConsoleEventGroups, X as AuthConsoleColumn, Y as AuthConsoleCapability, Z as AuthConsoleDescription, _t as AuthConsoleSessionUser, at as AuthConsoleImpersonation, bt as AuthConsoleValue, ct as AuthConsoleOptions, dt as AuthConsoleOverview, et as AuthConsoleEventUser, ft as AuthConsolePage, gt as AuthConsoleSession, ht as AuthConsoleRoles, it as AuthConsoleHostOptions, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, nt as AuthConsoleFieldPolicy, ot as AuthConsoleList, pt as AuthConsolePolicy, q as AuthConsoleActivityQuery, rt as AuthConsoleFieldType, st as AuthConsoleMutation, tt as AuthConsoleField, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, xt as authConsoleActionNames, yt as AuthConsoleUserDetail } from "./types-
|
|
2
|
-
import { i as describeAuthConsoleFields, n as AuthConsoleErrorCode, r as createAuthConsole, t as AuthConsole } from "./console-runtime-
|
|
1
|
+
import { $ as AuthConsoleEventGroup, G as AuthConsoleAction, J as AuthConsoleAgent, K as AuthConsoleActivity, Q as AuthConsoleEvent, St as authConsoleEventGroups, X as AuthConsoleColumn, Y as AuthConsoleCapability, Z as AuthConsoleDescription, _t as AuthConsoleSessionUser, at as AuthConsoleImpersonation, bt as AuthConsoleValue, ct as AuthConsoleOptions, dt as AuthConsoleOverview, et as AuthConsoleEventUser, ft as AuthConsolePage, gt as AuthConsoleSession, ht as AuthConsoleRoles, it as AuthConsoleHostOptions, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, nt as AuthConsoleFieldPolicy, ot as AuthConsoleList, pt as AuthConsolePolicy, q as AuthConsoleActivityQuery, rt as AuthConsoleFieldType, st as AuthConsoleMutation, tt as AuthConsoleField, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, xt as authConsoleActionNames, yt as AuthConsoleUserDetail } from "./types-DmH31d2t.js";
|
|
2
|
+
import { i as describeAuthConsoleFields, n as AuthConsoleErrorCode, r as createAuthConsole, t as AuthConsole } from "./console-runtime-DMH1I2fl.js";
|
|
3
3
|
export { AuthConsole, type AuthConsoleAction, type AuthConsoleActivity, type AuthConsoleActivityQuery, type AuthConsoleAgent, type AuthConsoleCapability, type AuthConsoleColumn, type AuthConsoleDescription, AuthConsoleErrorCode, type AuthConsoleEvent, type AuthConsoleEventGroup, type AuthConsoleEventUser, type AuthConsoleField, type AuthConsoleFieldPolicy, type AuthConsoleFieldType, type AuthConsoleHostOptions, type AuthConsoleImpersonation, type AuthConsoleList, type AuthConsoleMutation, type AuthConsoleOptions, type AuthConsoleOrganization, type AuthConsoleOrganizationDetail, type AuthConsoleOverview, type AuthConsolePage, type AuthConsolePolicy, type AuthConsoleQuery, type AuthConsoleRoles, type AuthConsoleSession, type AuthConsoleSessionUser, type AuthConsoleUser, type AuthConsoleUserDetail, type AuthConsoleValue, type authConsoleActionNames, type authConsoleEventGroups, createAuthConsole, describeAuthConsoleFields };
|
package/dist/console.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as AuthConsoleEventGroup, G as AuthConsoleAction, J as AuthConsoleAgent, K as AuthConsoleActivity, Q as AuthConsoleEvent, St as authConsoleEventGroups, X as AuthConsoleColumn, Y as AuthConsoleCapability, Z as AuthConsoleDescription, _t as AuthConsoleSessionUser, at as AuthConsoleImpersonation, bt as AuthConsoleValue, ct as AuthConsoleOptions, dt as AuthConsoleOverview, et as AuthConsoleEventUser, ft as AuthConsolePage, gt as AuthConsoleSession, ht as AuthConsoleRoles, it as AuthConsoleHostOptions, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, nt as AuthConsoleFieldPolicy, ot as AuthConsoleList, pt as AuthConsolePolicy, q as AuthConsoleActivityQuery, rt as AuthConsoleFieldType, st as AuthConsoleMutation, tt as AuthConsoleField, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, xt as authConsoleActionNames, yt as AuthConsoleUserDetail } from "./types-
|
|
1
|
+
import { $ as AuthConsoleEventGroup, G as AuthConsoleAction, J as AuthConsoleAgent, K as AuthConsoleActivity, Q as AuthConsoleEvent, St as authConsoleEventGroups, X as AuthConsoleColumn, Y as AuthConsoleCapability, Z as AuthConsoleDescription, _t as AuthConsoleSessionUser, at as AuthConsoleImpersonation, bt as AuthConsoleValue, ct as AuthConsoleOptions, dt as AuthConsoleOverview, et as AuthConsoleEventUser, ft as AuthConsolePage, gt as AuthConsoleSession, ht as AuthConsoleRoles, it as AuthConsoleHostOptions, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, nt as AuthConsoleFieldPolicy, ot as AuthConsoleList, pt as AuthConsolePolicy, q as AuthConsoleActivityQuery, rt as AuthConsoleFieldType, st as AuthConsoleMutation, tt as AuthConsoleField, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, xt as authConsoleActionNames, yt as AuthConsoleUserDetail } from "./types-DmH31d2t.js";
|
|
2
2
|
/** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
|
|
3
3
|
interface ViteHubConsoleDefinitionCatalogView {
|
|
4
4
|
kind: "definition-catalog";
|
package/dist/database.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as AuthAppDatabase } from "./types-
|
|
1
|
+
import { f as AuthAppDatabase } from "./types-DmH31d2t.js";
|
|
2
2
|
/**
|
|
3
3
|
* The Better Auth `database` adapter for the app Database `name` (default `"default"`). Pass it inline as the
|
|
4
4
|
* `database` of `defineAuth()`. Auth then adds the Better Auth tables, the fields of `admin()` when the Definition calls it, the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import { A as AuthRuntimeEnv, At as AuthEventCounts, B as DiscoveredAuthDefinition, Bt as defaultAuthEventRetention, C as AuthGuardedHandler, D as AuthReservedOption, Dt as AuthEvent, Et as AuthDevice, F as AuthSessionRefresh, Ft as AuthEventStore, I as AuthSessionRefreshContext, It as AuthEventType, L as AuthSessionRefreshFields, Lt as AuthEventWindow, M as AuthRuntimeOption, Mt as AuthEventMetadata, N as AuthRuntimeOptions, Nt as AuthEventPage, O as AuthResolvedDefinitionOptions, Ot as AuthEventActor, P as AuthSessionOptions, Pt as AuthEventRetention, R as AuthSignInConfiguration, Rt as AuthEventsConfiguration, S as AuthFor, T as AuthRequest, U as ResolvedAuthViteConfig, V as RegisteredAuth, W as ViteHubAuth, X as AuthConsoleColumn, _ as AuthDefinition, a as AuthAccessPolicy, b as AuthDefinitionResolver, c as AuthAccessRouteConfiguration, ct as AuthConsoleOptions, d as AuthAnonymousGuardedHandler, g as AuthComponentsOptions, h as AuthBetterAuthRuntimeOptions, ht as AuthConsoleRoles, i as AuthAccessConfiguration, j as AuthRuntimeOnlyOptions, jt as AuthEventListInput, k as AuthRuntimeContext, kt as AuthEventAggregates, l as AuthAnonymousAuthorization, m as AuthBetterAuthOptions, n as AuthAccessAuthorize, nt as AuthConsoleFieldPolicy, o as AuthAccessPolicyContext, p as AuthAuthorization, pt as AuthConsolePolicy, r as AuthAccessAuthorizeResult, s as AuthAccessRoute, t as AuthAccessAuthorizationContext, u as AuthAnonymousAuthorize, v as AuthDefinitionInput, w as AuthOptions, x as AuthDeleteAccountOptions, y as AuthDefinitionOptions, z as AuthViteHubOptions, zt as createDatabaseAuthEventStore } from "./types-
|
|
3
|
-
import { n as checksOwnAccess } from "./own-access-
|
|
2
|
+
import { A as AuthRuntimeEnv, At as AuthEventCounts, B as DiscoveredAuthDefinition, Bt as defaultAuthEventRetention, C as AuthGuardedHandler, D as AuthReservedOption, Dt as AuthEvent, Et as AuthDevice, F as AuthSessionRefresh, Ft as AuthEventStore, I as AuthSessionRefreshContext, It as AuthEventType, L as AuthSessionRefreshFields, Lt as AuthEventWindow, M as AuthRuntimeOption, Mt as AuthEventMetadata, N as AuthRuntimeOptions, Nt as AuthEventPage, O as AuthResolvedDefinitionOptions, Ot as AuthEventActor, P as AuthSessionOptions, Pt as AuthEventRetention, R as AuthSignInConfiguration, Rt as AuthEventsConfiguration, S as AuthFor, T as AuthRequest, U as ResolvedAuthViteConfig, V as RegisteredAuth, W as ViteHubAuth, X as AuthConsoleColumn, _ as AuthDefinition, a as AuthAccessPolicy, b as AuthDefinitionResolver, c as AuthAccessRouteConfiguration, ct as AuthConsoleOptions, d as AuthAnonymousGuardedHandler, g as AuthComponentsOptions, h as AuthBetterAuthRuntimeOptions, ht as AuthConsoleRoles, i as AuthAccessConfiguration, j as AuthRuntimeOnlyOptions, jt as AuthEventListInput, k as AuthRuntimeContext, kt as AuthEventAggregates, l as AuthAnonymousAuthorization, m as AuthBetterAuthOptions, n as AuthAccessAuthorize, nt as AuthConsoleFieldPolicy, o as AuthAccessPolicyContext, p as AuthAuthorization, pt as AuthConsolePolicy, r as AuthAccessAuthorizeResult, s as AuthAccessRoute, t as AuthAccessAuthorizationContext, u as AuthAnonymousAuthorize, v as AuthDefinitionInput, w as AuthOptions, x as AuthDeleteAccountOptions, y as AuthDefinitionOptions, z as AuthViteHubOptions, zt as createDatabaseAuthEventStore } from "./types-DmH31d2t.js";
|
|
3
|
+
import { n as checksOwnAccess } from "./own-access-BNcxKrDl.js";
|
|
4
4
|
import { n as AuthStatelessPreset, r as AuthStatelessPresetOptions, t as AuthPreset } from "./presets-C6AtiRdI.js";
|
|
5
5
|
import { Result } from "@vite-hub/runtime";
|
|
6
6
|
export declare function defineAuth<const TOptions extends AuthResolvedDefinitionOptions>(options: AuthDefinitionResolver<TOptions>): AuthDefinition<AuthDefinitionResolver<TOptions>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="../host-declarations.d.ts" />
|
|
2
|
-
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, M as findVerifiedAuthUserId, N as getAuthForDefinition, O as withAuth, S as requireAuthorization, T as toAuthRequest, _ as handleAuthRequest, a as authRoute, b as requireAuth, c as createAuth, d as createAuthHandler, f as createAuthRequestRuntimeOptions, g as handleAuth, h as getAuthEvents, i as assertAuthOrigin, j as createBetterAuthOptions, k as withAuthorization, l as createAuthAccessHandler, m as getAuthConsoleForRequest, n as AuthSignOutOptions, o as can, p as getAuth, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, u as createAuthForRequest, v as listAuthEvents, w as signOut, x as requireAuthAccessRoutes, y as requireAbility } from "../server-
|
|
3
|
-
import { a as setAuthAccessIdentityResolver, o as setAuthRuntimeEnvResolver, s as resetAuth } from "../server-
|
|
2
|
+
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, M as findVerifiedAuthUserId, N as getAuthForDefinition, O as withAuth, S as requireAuthorization, T as toAuthRequest, _ as handleAuthRequest, a as authRoute, b as requireAuth, c as createAuth, d as createAuthHandler, f as createAuthRequestRuntimeOptions, g as handleAuth, h as getAuthEvents, i as assertAuthOrigin, j as createBetterAuthOptions, k as withAuthorization, l as createAuthAccessHandler, m as getAuthConsoleForRequest, n as AuthSignOutOptions, o as can, p as getAuth, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, u as createAuthForRequest, v as listAuthEvents, w as signOut, x as requireAuthAccessRoutes, y as requireAbility } from "../server-C4Kni3Vj.js";
|
|
3
|
+
import { a as setAuthAccessIdentityResolver, o as setAuthRuntimeEnvResolver, s as resetAuth } from "../server-BHniJi2m.js";
|
|
4
4
|
import { n as AbilityErrorData, t as AbilityError } from "../ability-error-C1c30O6E.js";
|
|
5
5
|
export { AbilityError, type AbilityErrorData, AuthEventReadErrorCode, AuthSignOutOptions, aggregateAuthEvents, assertAuthOrigin, can, checkAuthMember, createAuth, createAuthAccessHandler, createAuthForRequest, createAuthHandler, createAuthRequestRuntimeOptions, createBetterAuthOptions, authRoute as default, findVerifiedAuthUserId, getAuth, getAuthConsoleForRequest, getAuthEvents, getAuthForDefinition, handleAuth, handleAuthRequest, listAuthEvents, requireAbility, requireAuth, requireAuthAccessRoutes, requireAuthorization, requireCaller, resetAuth, setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver, signOut, toAuthRequest, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
|
package/dist/internal/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as resetAuth } from "../runtime-state-C0Rd1W4m.js";
|
|
2
|
-
import { a as getAuthForDefinition, i as findVerifiedAuthUserId, n as createBetterAuthOptions } from "../auth-instance-
|
|
2
|
+
import { a as getAuthForDefinition, i as findVerifiedAuthUserId, n as createBetterAuthOptions } from "../auth-instance-BWiRS9QZ.js";
|
|
3
3
|
import { setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver } from "../runtime/server.js";
|
|
4
4
|
import { t as AbilityError } from "../ability-error-D3-u8k1A.js";
|
|
5
|
-
import { C as toAuthRequest, D as withAuthorization, E as withAuth, S as signOut, T as withAnonymousAuthorization, _ as requireAbility, a as checkAuthMember, b as requireAuthorization, c as createAuthForRequest, d as getAuth, f as getAuthConsoleForRequest, g as listAuthEvents, h as handleAuthRequest, i as can, l as createAuthHandler, m as handleAuth, n as assertAuthOrigin, o as createAuth, p as getAuthEvents, r as authRoute, s as createAuthAccessHandler, t as aggregateAuthEvents, u as createAuthRequestRuntimeOptions, v as requireAuth, w as useAuth, x as requireCaller, y as requireAuthAccessRoutes } from "../server-
|
|
5
|
+
import { C as toAuthRequest, D as withAuthorization, E as withAuth, S as signOut, T as withAnonymousAuthorization, _ as requireAbility, a as checkAuthMember, b as requireAuthorization, c as createAuthForRequest, d as getAuth, f as getAuthConsoleForRequest, g as listAuthEvents, h as handleAuthRequest, i as can, l as createAuthHandler, m as handleAuth, n as assertAuthOrigin, o as createAuth, p as getAuthEvents, r as authRoute, s as createAuthAccessHandler, t as aggregateAuthEvents, u as createAuthRequestRuntimeOptions, v as requireAuth, w as useAuth, x as requireCaller, y as requireAuthAccessRoutes } from "../server-Iru6jcnW.js";
|
|
6
6
|
export { AbilityError, aggregateAuthEvents, assertAuthOrigin, can, checkAuthMember, createAuth, createAuthAccessHandler, createAuthForRequest, createAuthHandler, createAuthRequestRuntimeOptions, createBetterAuthOptions, authRoute as default, findVerifiedAuthUserId, getAuth, getAuthConsoleForRequest, getAuthEvents, getAuthForDefinition, handleAuth, handleAuthRequest, listAuthEvents, requireAbility, requireAuth, requireAuthAccessRoutes, requireAuthorization, requireCaller, resetAuth, setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver, signOut, toAuthRequest, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { l as findAccessPolicyPlugin } from "./members-CwPIx10t.js";
|
|
2
|
-
import { t as authForRequest } from "./auth-instance-
|
|
2
|
+
import { t as authForRequest } from "./auth-instance-BWiRS9QZ.js";
|
|
3
|
+
import { n as clientRequestOrigin } from "./client-request-BzMKtfCY.js";
|
|
3
4
|
import { n as mcpOAuthResources } from "./mcp-config-C7srUMIZ.js";
|
|
4
5
|
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
5
6
|
import { defineErrors } from "@vite-hub/runtime";
|
|
@@ -105,7 +106,8 @@ async function verifyMcpRequest(request, options = {}) {
|
|
|
105
106
|
const auth = options.auth ?? appAuth(request);
|
|
106
107
|
const state = await stateOf(auth);
|
|
107
108
|
const url = new URL(request.url);
|
|
108
|
-
|
|
109
|
+
const origin = clientRequestOrigin(request);
|
|
110
|
+
return await verifyToken(token, auth, state, options.resource ?? state.resources.find((entry) => new URL(entry).origin === origin && pathOf(entry) === url.pathname.replace(/\/+$/, "")), url.pathname);
|
|
109
111
|
}
|
|
110
112
|
/** The token of an `Authorization: Bearer` header. */
|
|
111
113
|
const bearerToken = (headers) => /^Bearer\s+(\S+)$/i.exec(headers.get("authorization") ?? "")?.[1];
|
package/dist/mcp.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
2
|
+
import { n as clientRequestOrigin } from "./client-request-BzMKtfCY.js";
|
|
2
3
|
import { r as mcpRegistrationPluginId } from "./mcp-config-C7srUMIZ.js";
|
|
3
|
-
import { c as verifyMcpRequest, i as mcpTokenInvalidReasons, n as baseScopes, o as pathOf, r as deleteUnusedMcpClients, s as stateOf, t as appAuth } from "./mcp-token-
|
|
4
|
+
import { c as verifyMcpRequest, i as mcpTokenInvalidReasons, n as baseScopes, o as pathOf, r as deleteUnusedMcpClients, s as stateOf, t as appAuth } from "./mcp-token-CuqdbBy8.js";
|
|
4
5
|
import { APIError, createAuthMiddleware } from "better-auth/api";
|
|
5
6
|
import { oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata } from "@better-auth/oauth-provider";
|
|
6
7
|
import { jwt } from "better-auth/plugins";
|
|
@@ -149,7 +150,8 @@ async function serveMcpOAuthDiscovery(request, options = {}) {
|
|
|
149
150
|
return answer;
|
|
150
151
|
}
|
|
151
152
|
async function discoveryDocument(request, document, options) {
|
|
152
|
-
const {
|
|
153
|
+
const { pathname } = new URL(request.url);
|
|
154
|
+
const origin = clientRequestOrigin(request);
|
|
153
155
|
const suffix = pathname.slice(`/.well-known/${document}`.length).replace(/\/+$/, "");
|
|
154
156
|
const auth = options.auth ?? appAuth(request);
|
|
155
157
|
const state = await stateOf(auth);
|
package/dist/nuxt.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import { Ct as AuthPageMeta, Tt as AuthPages, w as AuthOptions, wt as AuthPageMode } from "./types-
|
|
2
|
+
import { Ct as AuthPageMeta, Tt as AuthPages, w as AuthOptions, wt as AuthPageMode } from "./types-DmH31d2t.js";
|
|
3
3
|
import "vite";
|
|
4
4
|
interface NuxtLayerDirectoryConfig {
|
|
5
5
|
rootDir?: string;
|
package/dist/nuxt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as writeNuxtAuthDefinition, d as cachingRuleNames, f as createCachingRouteRuleFinder, h as resolveViteHubProjectRoot, l as resolveAuthViteConfig, m as resolveNuxtServerDirs, o as createAuthNitroConfig, p as methodOrder, s as hubAuth, u as authAbilitiesCandidates } from "./vite-
|
|
1
|
+
import { c as writeNuxtAuthDefinition, d as cachingRuleNames, f as createCachingRouteRuleFinder, h as resolveViteHubProjectRoot, l as resolveAuthViteConfig, m as resolveNuxtServerDirs, o as createAuthNitroConfig, p as methodOrder, s as hubAuth, u as authAbilitiesCandidates } from "./vite-CpWhT1Wi.js";
|
|
2
2
|
import { i as normalizePagePath, r as createAccessPageMatcher, t as accessPageBeats } from "./access-pages-9aKr6z-k.js";
|
|
3
3
|
import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
|
|
4
4
|
import { realpathSync } from "node:fs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as AuthRequestInput } from "./types-
|
|
1
|
+
import { E as AuthRequestInput } from "./types-DmH31d2t.js";
|
|
2
2
|
/**
|
|
3
3
|
* The Nitro route `meta` of a handler that checks its own access, such as the ViteHub Console route. The access routes
|
|
4
4
|
* leave a request to the handler that Nitro routed it to when that handler has this meta, whatever its path and method.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function authClientRequestPlugin(nitroApp: unknown): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { t as isRecord } from "../object-CAK6UYR5.js";
|
|
2
|
+
import { r as runWithClientRequest } from "../client-request-BzMKtfCY.js";
|
|
3
|
+
// src/runtime/client-request-plugin.ts
|
|
4
|
+
function isRequest(value) {
|
|
5
|
+
return isRecord(value) && typeof value.url === "string" && value.headers instanceof Headers;
|
|
6
|
+
}
|
|
7
|
+
function authClientRequestPlugin(nitroApp) {
|
|
8
|
+
if (!isRecord(nitroApp)) return;
|
|
9
|
+
const h3 = nitroApp.h3;
|
|
10
|
+
const owner = isRecord(h3) && h3.fetch instanceof Function ? h3 : nitroApp;
|
|
11
|
+
const fetch = owner.fetch;
|
|
12
|
+
if (!(fetch instanceof Function)) return;
|
|
13
|
+
owner.fetch = (request, ...rest) => {
|
|
14
|
+
const call = () => Reflect.apply(fetch, owner, [request, ...rest]);
|
|
15
|
+
return isRequest(request) ? runWithClientRequest(request, call) : call();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export { authClientRequestPlugin as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "../server.js";
|
|
2
|
-
import { A as authForRequest, r as aggregateAuthEvents, v as listAuthEvents } from "../server-
|
|
2
|
+
import { A as authForRequest, r as aggregateAuthEvents, v as listAuthEvents } from "../server-C4Kni3Vj.js";
|
|
3
3
|
export { aggregateAuthEvents, authForRequest, listAuthEvents };
|
package/dist/runtime/console.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as listAuthEvents, t as aggregateAuthEvents } from "../server-
|
|
2
|
-
import { t as authForRequest } from "../auth-instance-
|
|
1
|
+
import { g as listAuthEvents, t as aggregateAuthEvents } from "../server-Iru6jcnW.js";
|
|
2
|
+
import { t as authForRequest } from "../auth-instance-BWiRS9QZ.js";
|
|
3
3
|
import "../server.js";
|
|
4
4
|
export { aggregateAuthEvents, authForRequest, listAuthEvents };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as AuthDefinition } from "../types-
|
|
1
|
+
import { _ as AuthDefinition } from "../types-DmH31d2t.js";
|
|
2
2
|
declare const definition: AuthDefinition | undefined;
|
|
3
3
|
export declare function getAuthApp(): object | undefined;
|
|
4
4
|
export { definition as default };
|
package/dist/runtime/server.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as authAccessHandlerMeta } from "../own-access-
|
|
2
|
-
import { a as setAuthAccessIdentityResolver, i as createLazyAuthAccessHandler, n as checkBuiltAuthPages, o as setAuthRuntimeEnvResolver, r as createAuthAccessRouteMatcher, t as AuthAccessRouteMatch } from "../server-
|
|
1
|
+
import { t as authAccessHandlerMeta } from "../own-access-BNcxKrDl.js";
|
|
2
|
+
import { a as setAuthAccessIdentityResolver, i as createLazyAuthAccessHandler, n as checkBuiltAuthPages, o as setAuthRuntimeEnvResolver, r as createAuthAccessRouteMatcher, t as AuthAccessRouteMatch } from "../server-BHniJi2m.js";
|
|
3
3
|
export { AuthAccessRouteMatch, authAccessHandlerMeta, checkBuiltAuthPages, createAuthAccessRouteMatcher, createLazyAuthAccessHandler, setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./own-access-
|
|
2
|
-
import { E as AuthRequestInput, H as ResolvedAuthAccessRoute, _ as AuthDefinition } from "./types-
|
|
1
|
+
import "./own-access-BNcxKrDl.js";
|
|
2
|
+
import { E as AuthRequestInput, H as ResolvedAuthAccessRoute, _ as AuthDefinition } from "./types-DmH31d2t.js";
|
|
3
3
|
import { AccessAuthorizationContext, ViteHubContext } from "@vite-hub/runtime";
|
|
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>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as AuthConsole } from "./console-runtime-
|
|
2
|
-
import { C as AuthGuardedHandler, E as AuthRequestInput, Ft as AuthEventStore, H as ResolvedAuthAccessRoute, Lt as AuthEventWindow, N as AuthRuntimeOptions, Nt as AuthEventPage, R as AuthSignInConfiguration, S as AuthFor, T as AuthRequest, V as RegisteredAuth, W as ViteHubAuth, _ as AuthDefinition, d as AuthAnonymousGuardedHandler, h as AuthBetterAuthRuntimeOptions, it as AuthConsoleHostOptions, jt as AuthEventListInput, kt as AuthEventAggregates, p as AuthAuthorization, u as AuthAnonymousAuthorize } from "./types-
|
|
3
|
-
import { i as AbilityName, n as AbilityAuthorization, t as AbilityArgs } from "./abilities-
|
|
1
|
+
import { t as AuthConsole } from "./console-runtime-DMH1I2fl.js";
|
|
2
|
+
import { C as AuthGuardedHandler, E as AuthRequestInput, Ft as AuthEventStore, H as ResolvedAuthAccessRoute, Lt as AuthEventWindow, N as AuthRuntimeOptions, Nt as AuthEventPage, R as AuthSignInConfiguration, S as AuthFor, T as AuthRequest, V as RegisteredAuth, W as ViteHubAuth, _ as AuthDefinition, d as AuthAnonymousGuardedHandler, h as AuthBetterAuthRuntimeOptions, it as AuthConsoleHostOptions, jt as AuthEventListInput, kt as AuthEventAggregates, p as AuthAuthorization, u as AuthAnonymousAuthorize } from "./types-DmH31d2t.js";
|
|
3
|
+
import { i as AbilityName, n as AbilityAuthorization, t as AbilityArgs } from "./abilities-BYOcyQ9B.js";
|
|
4
4
|
import { o as McpTokenInvalidError } from "./mcp-token-CmQbXbTu.js";
|
|
5
|
-
import "./server-
|
|
5
|
+
import "./server-BHniJi2m.js";
|
|
6
6
|
import "./ability-error-C1c30O6E.js";
|
|
7
7
|
import { AccessAuthorizeOption, Result, ResultError, ViteHubContext } from "@vite-hub/runtime";
|
|
8
8
|
import { APIError } from "better-auth/api";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as createAuthConsole } from "./console-runtime-CaIXVtB_.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-BpI9Ps8A.js";
|
|
3
2
|
import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-zKi7NrvK.js";
|
|
4
3
|
import { a as normalizeAuthBasePath } from "./access-pages-9aKr6z-k.js";
|
|
5
4
|
import { n as authRequestEvent, r as unwrapAuthRequest } from "./request-Dpq7GO8B.js";
|
|
5
|
+
import { n as clientRequestOrigin } from "./client-request-BzMKtfCY.js";
|
|
6
|
+
import { 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-BWiRS9QZ.js";
|
|
6
7
|
import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-fR6Pv4kD.js";
|
|
7
8
|
import { t as getAuthRuntimeState } from "./runtime-state-C0Rd1W4m.js";
|
|
8
9
|
import { t as readSetCookies } from "./set-cookie-DVfi-nJX.js";
|
|
@@ -847,9 +848,9 @@ async function readCaller(event, definition) {
|
|
|
847
848
|
const auth = authForRequest(request, authRequestEvent(event), definition);
|
|
848
849
|
const { options } = await auth.$context;
|
|
849
850
|
if (isJwsToken(token) && mcpOAuthResources(options.plugins).length) {
|
|
850
|
-
const { verifyAppAccessToken } = await import("./mcp-token-
|
|
851
|
+
const { verifyAppAccessToken } = await import("./mcp-token-CuqdbBy8.js").then((n) => n.a);
|
|
851
852
|
const url = new URL(request.url);
|
|
852
|
-
const [error, caller] = await verifyAppAccessToken(token, trustsProxyHeaders(options)
|
|
853
|
+
const [error, caller] = await verifyAppAccessToken(token, clientRequestOrigin(request, trustsProxyHeaders(options)), url.pathname, auth);
|
|
853
854
|
if (error) return [error, void 0];
|
|
854
855
|
return [void 0, Object.freeze({
|
|
855
856
|
client: {
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, F as AuthCallerError, I as AuthCallerErrorCode, L as AuthCallerResult, O as withAuth, P as AuthCaller, R as AuthCallerUser, 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, z as AuthMemberErrorCode } from "./server-
|
|
2
|
+
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, F as AuthCallerError, I as AuthCallerErrorCode, L as AuthCallerResult, O as withAuth, P as AuthCaller, R as AuthCallerUser, 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, z as AuthMemberErrorCode } from "./server-C4Kni3Vj.js";
|
|
3
3
|
import { a as McpTokenInvalidData, o as McpTokenInvalidError, s as McpTokenInvalidReason } from "./mcp-token-CmQbXbTu.js";
|
|
4
4
|
import { n as AbilityErrorData, t as AbilityError } from "./ability-error-C1c30O6E.js";
|
|
5
5
|
export { AbilityError, type AbilityErrorData, type AuthCaller, type AuthCallerError, type AuthCallerErrorCode, type AuthCallerResult, type AuthCallerUser, type AuthEventReadErrorCode, type AuthMemberErrorCode, type McpTokenInvalidData, type McpTokenInvalidError, type McpTokenInvalidReason, 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
1
|
import { t as AbilityError } from "./ability-error-D3-u8k1A.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-
|
|
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-Iru6jcnW.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 };
|
package/dist/test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as AuthDefinition } from "./types-
|
|
1
|
+
import { _ as AuthDefinition } from "./types-DmH31d2t.js";
|
|
2
2
|
import { Session, User } from "better-auth";
|
|
3
3
|
/** The user to sign in. Auth creates it when no user has this email. Other fields, such as `role`, go to the new user. */
|
|
4
4
|
export interface SignInTestUser {
|
package/dist/test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-
|
|
1
|
+
import { s as resolveDefaultDefinition, t as authForRequest } from "./auth-instance-BWiRS9QZ.js";
|
|
2
2
|
import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
|
|
3
3
|
import { testUtils } from "better-auth/plugins";
|
|
4
4
|
// src/test.ts
|
|
@@ -401,7 +401,12 @@ type AuthSessionOptions = NonNullable<BetterAuthOptions["session"]> & {
|
|
|
401
401
|
interface AuthRuntimeEnv extends ViteHub.AuthRuntimeEnv {}
|
|
402
402
|
interface AuthRuntimeContext<TEnv extends Record<string, unknown> = AuthRuntimeEnv> {
|
|
403
403
|
env: TEnv;
|
|
404
|
+
/**
|
|
405
|
+
* The request that Auth serves. A request that the server sends to itself during server rendering has the URL
|
|
406
|
+
* `http://localhost/...`, so read the origin from `requestOrigin`.
|
|
407
|
+
*/
|
|
404
408
|
request?: Pick<Request, "headers" | "url">;
|
|
409
|
+
/** The origin of the request that the client sent, or `http://localhost` outside a request. */
|
|
405
410
|
requestOrigin: string;
|
|
406
411
|
}
|
|
407
412
|
type AuthRuntimeOptions = Partial<Omit<BetterAuthOptions, "basePath" | "database">> & {
|
|
@@ -1674,6 +1674,7 @@ function mergeNitroAuthHandler(value, config, dev) {
|
|
|
1674
1674
|
middleware: true,
|
|
1675
1675
|
route: "/**"
|
|
1676
1676
|
}] : []];
|
|
1677
|
+
kit.addPlugin(ownModule(import.meta.url, "runtime/client-request-plugin"), "start");
|
|
1677
1678
|
for (const handler of authHandlers) kit.addHandler(handler);
|
|
1678
1679
|
const merged = kit.config;
|
|
1679
1680
|
const guards = /* @__PURE__ */ new Set([cachedAccessRouteGuardName, memoryDatabaseGuardName]);
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import { U as ResolvedAuthViteConfig, w as AuthOptions } from "./types-
|
|
2
|
+
import { U as ResolvedAuthViteConfig, w as AuthOptions } from "./types-DmH31d2t.js";
|
|
3
3
|
import { n as ViteHubCliPluginMetadata } from "./cli-C5pAfY4x.js";
|
|
4
4
|
import { Plugin } from "vite";
|
|
5
5
|
interface ViteHubDefinitionField {
|
package/dist/vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as AUTH_ABILITIES_ID, n as AUTH_CLIENT_ID, r as AUTH_DEFINITION_ID, i as AUTH_SERVER_ID, a as AUTH_VITE_PLUGIN_NAME, o as createAuthNitroConfig, s as hubAuth, l as resolveAuthViteConfig, c as writeNuxtAuthDefinition } from "./vite-
|
|
1
|
+
export { t as AUTH_ABILITIES_ID, n as AUTH_CLIENT_ID, r as AUTH_DEFINITION_ID, i as AUTH_SERVER_ID, a as AUTH_VITE_PLUGIN_NAME, o as createAuthNitroConfig, s as hubAuth, l as resolveAuthViteConfig, c as writeNuxtAuthDefinition } from "./vite-CpWhT1Wi.js";
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-BYOcyQ9B.js";
|
|
3
|
+
import { S as AuthFor, _ as AuthDefinition } from "./types-DmH31d2t.js";
|
|
4
4
|
import { n as AbilityErrorData } from "./ability-error-C1c30O6E.js";
|
|
5
5
|
import { BetterAuthClientOptions } from "better-auth";
|
|
6
6
|
import { ComputedRef, VNode } from "vue";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/auth",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Better Auth-powered authentication primitives and Vite integration for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -144,9 +144,9 @@
|
|
|
144
144
|
"dependencies": {
|
|
145
145
|
"@noble/hashes": "^2.4.0",
|
|
146
146
|
"@types/node": "^24.19.2",
|
|
147
|
-
"@vite-hub/env": "0.6.
|
|
148
|
-
"@vite-hub/runtime": "0.6.
|
|
149
|
-
"@vite-hub/web-container": "0.6.
|
|
147
|
+
"@vite-hub/env": "0.6.1",
|
|
148
|
+
"@vite-hub/runtime": "0.6.1",
|
|
149
|
+
"@vite-hub/web-container": "0.6.1",
|
|
150
150
|
"better-auth": "^1.7.27",
|
|
151
151
|
"h3": "^2.0.8",
|
|
152
152
|
"nostics": "1.4.0",
|
|
@@ -165,8 +165,8 @@
|
|
|
165
165
|
"@types/json-schema": "^7.0.15",
|
|
166
166
|
"@types/mdast": "^4.0.4",
|
|
167
167
|
"@types/node": "^24.19.2",
|
|
168
|
-
"@vite-hub/agent": "0.6.
|
|
169
|
-
"@vite-hub/database": "0.6.
|
|
168
|
+
"@vite-hub/agent": "0.6.1",
|
|
169
|
+
"@vite-hub/database": "0.6.1",
|
|
170
170
|
"@vite-hub/internal": "0.0.1",
|
|
171
171
|
"bun-types": "^1.4.5",
|
|
172
172
|
"evlog": "2.37.1",
|
|
@@ -189,8 +189,8 @@
|
|
|
189
189
|
"@better-auth/oauth-provider": "^1.7.27",
|
|
190
190
|
"@types/json-schema": "^7.0.15",
|
|
191
191
|
"@types/mdast": "^4.0.4",
|
|
192
|
-
"@vite-hub/agent": "0.6.
|
|
193
|
-
"@vite-hub/database": "0.6.
|
|
192
|
+
"@vite-hub/agent": "0.6.1",
|
|
193
|
+
"@vite-hub/database": "0.6.1",
|
|
194
194
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
195
195
|
"vite": ">=8.0.0",
|
|
196
196
|
"vue": "^3.5.0",
|