@vite-hub/auth 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +86 -12
  2. package/dist/{abilities-BYOcyQ9B.d.ts → abilities-IOwpkcz4.d.ts} +1 -1
  3. package/dist/abilities.d.ts +1 -1
  4. package/dist/{ability-error-D3-u8k1A.js → ability-error-DgR91Jwc.js} +1 -1
  5. package/dist/{access-pages-9aKr6z-k.js → access-pages-C69nwa99.js} +10 -3
  6. package/dist/agent.d.ts +2 -3
  7. package/dist/agent.js +31 -12
  8. package/dist/{auth-instance-BWiRS9QZ.js → auth-instance-WeEK1zDd.js} +174 -64
  9. package/dist/{cli-C5pAfY4x.d.ts → cli-DL7uCAvz.d.ts} +15 -0
  10. package/dist/cli.d.ts +1 -1
  11. package/dist/cli.js +1 -1
  12. package/dist/client-extension-BgUlm6hy.d.ts +33 -0
  13. package/dist/client-request-B1DCz3a9.js +29 -0
  14. package/dist/{console-runtime-DMH1I2fl.d.ts → console-runtime-C71weVrt.d.ts} +1 -1
  15. package/dist/{console-runtime-CaIXVtB_.js → console-runtime-Dk3j4Jmz.js} +5 -3
  16. package/dist/console-runtime.d.ts +2 -2
  17. package/dist/console-runtime.js +1 -1
  18. package/dist/console.d.ts +1 -1
  19. package/dist/database-options-Cms7BI3c.js +36 -0
  20. package/dist/{database-schema-options-peXHNLkJ.js → database-schema-options-IlHEeUBK.js} +1 -1
  21. package/dist/database.d.ts +1 -1
  22. package/dist/database.js +13 -8
  23. package/dist/{definition-BypPLIbI.js → definition-EpeI5LUG.js} +18 -4
  24. package/dist/{error-diagnostics-CUPwukgE.js → error-diagnostics-DZHuHXPP.js} +46 -5
  25. package/dist/{events-BXU1_9mc.js → events-Cm7Iwq47.js} +1 -1
  26. package/dist/extension-BWmjJhoN.d.ts +59 -0
  27. package/dist/extension-mCx4TrsO.js +133 -0
  28. package/dist/forward.js +1 -1
  29. package/dist/index.d.ts +4 -3
  30. package/dist/index.js +5 -3
  31. package/dist/internal/server.d.ts +3 -3
  32. package/dist/internal/server.js +5 -4
  33. package/dist/{mcp-config-C7srUMIZ.js → mcp-config-Bbr8kQxm.js} +9 -1
  34. package/dist/{mcp-token-CuqdbBy8.js → mcp-token-BleQZK6H.js} +52 -11
  35. package/dist/{mcp-token-CmQbXbTu.d.ts → mcp-token-CxpopXmK.d.ts} +5 -2
  36. package/dist/mcp.d.ts +2 -2
  37. package/dist/mcp.js +27 -6
  38. package/dist/{members-CwPIx10t.js → members-7OMdqha_.js} +188 -152
  39. package/dist/nuxt.d.ts +4 -14
  40. package/dist/nuxt.js +53 -20
  41. package/dist/{own-access-BNcxKrDl.d.ts → own-access-CGiai2L3.d.ts} +1 -1
  42. package/dist/{page-tools-shared-CtoKaNQZ.js → page-tools-shared-dVJBPPTk.js} +8 -0
  43. package/dist/presets.js +1 -1
  44. package/dist/roles-BGi8CyBG.js +17 -0
  45. package/dist/runtime/client-request-plugin.d.ts +2 -1
  46. package/dist/runtime/client-request-plugin.js +8 -5
  47. package/dist/runtime/console.d.ts +1 -1
  48. package/dist/runtime/console.js +2 -2
  49. package/dist/runtime/empty-abilities.d.ts +1 -1
  50. package/dist/runtime/empty-client.d.ts +3 -0
  51. package/dist/runtime/empty-client.js +3 -1
  52. package/dist/runtime/empty-definition.d.ts +1 -1
  53. package/dist/runtime/server.d.ts +4 -3
  54. package/dist/runtime/server.js +7 -4
  55. package/dist/runtime/vue-nuxt.js +27 -11
  56. package/dist/schema.d.ts +32 -14
  57. package/dist/schema.js +21 -14
  58. package/dist/{server-Iru6jcnW.js → server-5t-HA7I1.js} +80 -328
  59. package/dist/{server-C4Kni3Vj.d.ts → server-DyP1v-sZ.d.ts} +39 -7
  60. package/dist/{server-BHniJi2m.d.ts → server-mmp8EfcE.d.ts} +4 -2
  61. package/dist/server.d.ts +6 -3
  62. package/dist/server.js +9 -3
  63. package/dist/{session-cookies-fR6Pv4kD.js → session-cookies-BNtY3hMp.js} +4 -16
  64. package/dist/{set-cookie-DVfi-nJX.js → set-cookie-Bva-P-_C.js} +1 -1
  65. package/dist/{table-specs-CCSY4tiS.js → table-specs-Bm7QJCbu.js} +1 -1
  66. package/dist/{table-specs-P4LvbOlX.d.ts → table-specs-BxKeFD_y.d.ts} +5 -0
  67. package/dist/test.d.ts +1 -1
  68. package/dist/test.js +2 -2
  69. package/dist/{types-DmH31d2t.d.ts → types-CnO5bHEF.d.ts} +40 -6
  70. package/dist/{vite-CpWhT1Wi.js → vite-7I1bJvqA.js} +686 -244
  71. package/dist/vite-CZ_Z6IR3.d.ts +28 -0
  72. package/dist/vite.d.ts +41 -6
  73. package/dist/vite.js +1 -1
  74. package/dist/vue.d.ts +4 -3
  75. package/dist/vue.js +39 -4
  76. package/package.json +9 -8
  77. package/dist/client-request-BzMKtfCY.js +0 -52
  78. package/dist/database-options-B87hDU4j.js +0 -28
@@ -1,20 +1,22 @@
1
- import { t as createAuthConsole } from "./console-runtime-CaIXVtB_.js";
1
+ import { t as createAuthConsole } from "./console-runtime-Dk3j4Jmz.js";
2
+ import { t as isRecord } from "./object-CAK6UYR5.js";
2
3
  import { i as resolveAuthMountPath, n as canonicalAccessPath } from "./application-path-zKi7NrvK.js";
3
- import { a as normalizeAuthBasePath } from "./access-pages-9aKr6z-k.js";
4
+ import { o as normalizeAuthBasePath } from "./access-pages-C69nwa99.js";
5
+ import { t as hasRole } from "./roles-BGi8CyBG.js";
4
6
  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";
7
- import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-fR6Pv4kD.js";
7
+ import { a as clientRequestOrigin, r as mcpOAuthResources, t as isJwsToken } from "./mcp-config-Bbr8kQxm.js";
8
+ import { _ as setAuthResponseOutcome, a as getAuthForDefinition, c as withSessionMarker, d as withEndpointRateLimits, f as eventClientAddress, g as setAuthOutcome, h as runWithAuthEvent, l as resolveAuthOptions, m as withClientAddress, n as createBetterAuthOptions, o as requestProvider, p as setRequestClientAddress, r as envResolverFor, s as resolveDefaultDefinition, t as authForRequest, u as trustsProxyHeaders } from "./auth-instance-WeEK1zDd.js";
9
+ import { a as getAuthenticationSession, i as authenticationRefusalResponse, n as sendSessionCookies, r as authenticationRefusalError, t as prepareSessionCookies } from "./session-cookies-BNtY3hMp.js";
8
10
  import { t as getAuthRuntimeState } from "./runtime-state-C0Rd1W4m.js";
9
- import { t as readSetCookies } from "./set-cookie-DVfi-nJX.js";
11
+ import { t as readSetCookies } from "./set-cookie-Bva-P-_C.js";
10
12
  import { createAuthAccessRouteMatcher } from "./runtime/server.js";
11
- import { n as checkAbility, t as AbilityError } from "./ability-error-D3-u8k1A.js";
12
- import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-BXU1_9mc.js";
13
- import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
14
- import { i as notMemberError, l as findAccessPolicyPlugin } from "./members-CwPIx10t.js";
15
- import { n as mcpOAuthResources, t as isJwsToken } from "./mcp-config-C7srUMIZ.js";
13
+ import { n as checkAbility, t as AbilityError } from "./ability-error-DgR91Jwc.js";
14
+ import { i as parseAuthEventWindow, r as parseAuthEventList } from "./events-Cm7Iwq47.js";
15
+ import { t as authErrorDiagnostics } from "./error-diagnostics-DZHuHXPP.js";
16
+ import { g as findAccessPolicyPlugin, i as notMemberError } from "./members-7OMdqha_.js";
16
17
  import { defineErrors, toResultError } from "@vite-hub/runtime";
17
18
  import { HTTPError } from "nitro/h3";
19
+ import { isRequest } from "@vite-hub/runtime/internal/response";
18
20
  import { parseUserOutput } from "better-auth/db";
19
21
  import abilities from "#vitehub/auth/abilities";
20
22
  import { isRuntimeResponse } from "@vite-hub/runtime/internal/runtime-type";
@@ -29,169 +31,6 @@ const callerErrors = /*#__PURE__*/ defineErrors({
29
31
  });
30
32
  const signedOutError = () => callerErrors.AUTH_SIGNED_OUT();
31
33
  // src/internal/server.ts
32
- function hasHappyDomRequestState(value) {
33
- const ownSymbols = Object.getOwnPropertySymbols(value);
34
- const prototypeSymbols = Object.getOwnPropertySymbols(Object.getPrototypeOf(value) ?? {});
35
- return [
36
- "method",
37
- "body",
38
- "mode",
39
- "headers",
40
- "redirect",
41
- "referrerPolicy",
42
- "signal",
43
- "bodyUsed",
44
- "credentials",
45
- "aborted",
46
- "error",
47
- "contentLength",
48
- "contentType",
49
- "referrer",
50
- "url",
51
- "bodyBuffer"
52
- ].every((name) => ownSymbols.some((symbol) => symbol.description === name)) && prototypeSymbols.some((symbol) => symbol.description === "window");
53
- }
54
- function isRequestLike$1(value) {
55
- try {
56
- const isBrandCheckError = (error) => {
57
- if (typeof error !== "object" && typeof error !== "function" || error === null) return false;
58
- try {
59
- if (Object.prototype.toString.call(error) !== "[object Error]") return false;
60
- } catch {
61
- return false;
62
- }
63
- let name;
64
- let message;
65
- try {
66
- name = Reflect.get(error, "name");
67
- message = Reflect.get(error, "message");
68
- } catch {
69
- return false;
70
- }
71
- return name === "TypeError" && typeof message === "string" && /illegal invocation|invalid (this|receiver)|brand|cannot read properties of (?:null|undefined)|must be (?:an? )?instance/i.test(message);
72
- };
73
- if (Object.prototype.toString.call(value) !== "[object Request]") return false;
74
- const hasPrototypeTag = (target, tag) => {
75
- let prototype = Object.getPrototypeOf(target);
76
- while (prototype) {
77
- const descriptor = Object.getOwnPropertyDescriptor(prototype, Symbol.toStringTag);
78
- if (descriptor) {
79
- if (typeof descriptor.get === "function") return descriptor.get.call(target) === tag;
80
- return "value" in descriptor && descriptor.value === tag;
81
- }
82
- prototype = Object.getPrototypeOf(prototype);
83
- }
84
- return false;
85
- };
86
- const hasBrandedAccessor = (target, property) => {
87
- let current = Object.getPrototypeOf(target);
88
- while (current) {
89
- const descriptor = Object.getOwnPropertyDescriptor(current, property);
90
- if (descriptor) {
91
- if (typeof descriptor.get !== "function") return false;
92
- try {
93
- descriptor.get.call(Object.create(null));
94
- if (target !== value) return false;
95
- return hasHappyDomRequestState(value);
96
- } catch (error) {
97
- if (!isBrandCheckError(error)) return false;
98
- return true;
99
- }
100
- }
101
- current = Object.getPrototypeOf(current);
102
- }
103
- return false;
104
- };
105
- if (!hasPrototypeTag(value, "Request")) return false;
106
- const hasMethods = (target, methods) => methods.every((method) => {
107
- return typeof Reflect.get(target, method) === "function";
108
- });
109
- if (hasHappyDomRequestState(value)) {
110
- if (!hasMethods(value, [
111
- "clone",
112
- "arrayBuffer",
113
- "blob",
114
- "formData",
115
- "json",
116
- "text"
117
- ])) return false;
118
- if (!value.headers || !hasMethods(value.headers, [
119
- "get",
120
- "has",
121
- "set",
122
- "append",
123
- "delete",
124
- "entries",
125
- "forEach"
126
- ])) return false;
127
- if (!value.signal || typeof value.signal.aborted !== "boolean") return false;
128
- return true;
129
- }
130
- if (![
131
- "body",
132
- "bodyUsed",
133
- "headers",
134
- "method",
135
- "signal",
136
- "url"
137
- ].every((property) => hasBrandedAccessor(value, property))) return false;
138
- if (!hasMethods(value, [
139
- "clone",
140
- "arrayBuffer",
141
- "blob",
142
- "formData",
143
- "json",
144
- "text"
145
- ])) return false;
146
- if (!value.headers || Object.prototype.toString.call(value.headers) !== "[object Headers]" || !hasPrototypeTag(value.headers, "Headers") || !hasMethods(value.headers, [
147
- "get",
148
- "has",
149
- "set",
150
- "append",
151
- "delete",
152
- "entries",
153
- "forEach"
154
- ])) return false;
155
- if ([
156
- "get",
157
- "has",
158
- "set",
159
- "append",
160
- "delete",
161
- "entries",
162
- "forEach"
163
- ].some((method) => Object.prototype.hasOwnProperty.call(value.headers, method))) return false;
164
- const headersGet = Reflect.get(value.headers, "get");
165
- if (typeof headersGet !== "function") return false;
166
- try {
167
- headersGet.call(Object.create(null), "");
168
- return false;
169
- } catch (error) {
170
- if (!isBrandCheckError(error)) return false;
171
- }
172
- if (!value.signal || Object.prototype.toString.call(value.signal) !== "[object AbortSignal]" || !hasPrototypeTag(value.signal, "AbortSignal") || typeof value.signal.aborted !== "boolean") return false;
173
- if (Object.prototype.hasOwnProperty.call(value.signal, "aborted")) return false;
174
- return true;
175
- } catch {
176
- return false;
177
- }
178
- }
179
- function isAbortSignalLike(value) {
180
- if (!value || typeof value !== "object" && typeof value !== "function") return false;
181
- try {
182
- let prototype = Object.getPrototypeOf(value);
183
- const seen = /* @__PURE__ */ new Set();
184
- while (prototype && !seen.has(prototype)) {
185
- seen.add(prototype);
186
- const descriptor = Object.getOwnPropertyDescriptor(prototype, "aborted");
187
- if (descriptor?.get) return typeof Reflect.apply(descriptor.get, value, []) === "boolean";
188
- prototype = Object.getPrototypeOf(prototype);
189
- }
190
- } catch {
191
- return false;
192
- }
193
- return false;
194
- }
195
34
  /** The provider sign-in of `access`, which returns to `afterSignIn`. A sign-in page has none: the page signs in. */
196
35
  function providerSignIn(options) {
197
36
  const access = options.access;
@@ -213,10 +52,10 @@ function headersInit(headers) {
213
52
  return Array.from(Reflect.apply(entries, value, []));
214
53
  }
215
54
  function toRequest(request) {
216
- if (request instanceof Request || isRequestLike$1(request)) return request;
55
+ if (isRequest(request)) return request;
217
56
  const init = { method: request.method };
218
57
  init.headers = new Headers(headersInit(request.headers));
219
- if (isAbortSignalLike(request.signal)) init.signal = request.signal;
58
+ if (request.signal instanceof AbortSignal) init.signal = request.signal;
220
59
  if (request.body) {
221
60
  init.body = request.body;
222
61
  init.duplex = "half";
@@ -231,14 +70,14 @@ function createAuthRequestRuntimeOptions(definition, request, event) {
231
70
  }).requestRuntimeOptions;
232
71
  }
233
72
  function createAuth(definition) {
234
- return withSessionMarker(withClientAddress(betterAuth(createBetterAuthOptions(definition))));
73
+ return withSessionMarker(withEndpointRateLimits(withClientAddress(betterAuth(createBetterAuthOptions(definition)))));
235
74
  }
236
75
  function createAuthForRequest(definition, request, event) {
237
- return withSessionMarker(withClientAddress(betterAuth(resolveAuthOptions(definition, {
76
+ return withSessionMarker(withEndpointRateLimits(withClientAddress(betterAuth(resolveAuthOptions(definition, {
238
77
  request,
239
78
  event,
240
79
  env: envResolverFor(definition)
241
- }).providerOptions)));
80
+ }).providerOptions))));
242
81
  }
243
82
  function handleAuthRequest(definition, input, event = authRequestEvent(input)) {
244
83
  const request = unwrapAuthRequest(input);
@@ -488,14 +327,21 @@ async function createSignInResponse(auth, options, signIn, address) {
488
327
  });
489
328
  }
490
329
  const sessionReads = /* @__PURE__ */ new WeakMap();
491
- async function readSession(input, auth, headers) {
492
- const { refusal, session, setCookies } = await getAuthenticationSession(auth, { headers });
330
+ async function readSession(input, auth, headers, query) {
331
+ const { refusal, session, setCookies } = await getAuthenticationSession(auth, query ? {
332
+ headers,
333
+ query
334
+ } : { headers });
493
335
  prepareSessionCookies(input, setCookies);
494
336
  return {
495
337
  refusal,
496
338
  session
497
339
  };
498
340
  }
341
+ function cachesSessions(options) {
342
+ const session = options.session;
343
+ return options.preset === void 0 && isRecord(session) && isRecord(session.cookieCache) && session.cookieCache.enabled === true;
344
+ }
499
345
  async function readRequestSession(input, definition) {
500
346
  const request = unwrapAuthRequest(input);
501
347
  const event = authRequestEvent(input);
@@ -551,167 +397,39 @@ function sendableRuntimeResponse(value, request) {
551
397
  return createForbiddenResponse(request);
552
398
  }
553
399
  }
554
- const nativePromiseThen = Object.getOwnPropertyDescriptor(Promise.prototype, "then")?.value;
555
- const nativePromiseResolve = Promise.resolve;
556
- function hasNativePromiseBrand(value) {
557
- if (!nativePromiseThen) return false;
558
- try {
559
- let prototype = Object.getPrototypeOf(value);
560
- const seen = /* @__PURE__ */ new Set();
561
- while (prototype && !seen.has(prototype)) {
562
- seen.add(prototype);
563
- if (Object.prototype.hasOwnProperty.call(prototype, "then") && Object.getOwnPropertyDescriptor(prototype, "then")?.value === nativePromiseThen) return true;
564
- prototype = Object.getPrototypeOf(prototype);
565
- }
566
- const valueDescriptor = Object.getOwnPropertyDescriptor(value, "constructor");
567
- let valueOverridden = false;
568
- try {
569
- if (!valueDescriptor || valueDescriptor.configurable) {
570
- Object.defineProperty(value, "constructor", {
571
- configurable: true,
572
- writable: true,
573
- value: Promise
574
- });
575
- valueOverridden = true;
576
- } else if ("value" in valueDescriptor && valueDescriptor.writable) {
577
- Object.defineProperty(value, "constructor", { value: Promise });
578
- valueOverridden = true;
579
- }
580
- } catch {}
581
- let probe;
582
- try {
583
- probe = Reflect.apply(nativePromiseThen, value, [() => void 0, () => void 0]);
584
- } finally {
585
- if (valueOverridden) {
586
- if (valueDescriptor) Object.defineProperty(value, "constructor", valueDescriptor);
587
- else Reflect.deleteProperty(value, "constructor");
588
- }
589
- }
590
- if (probe && (typeof probe === "object" || typeof probe === "function")) {
591
- const descriptor = Object.getOwnPropertyDescriptor(probe, "constructor");
592
- let overridden = false;
593
- try {
594
- if (!descriptor || descriptor.configurable) {
595
- Object.defineProperty(probe, "constructor", {
596
- configurable: true,
597
- writable: true,
598
- value: Promise
599
- });
600
- overridden = true;
601
- } else if ("value" in descriptor && descriptor.writable) {
602
- Object.defineProperty(probe, "constructor", { value: Promise });
603
- overridden = true;
604
- }
605
- const cleanup = Reflect.apply(nativePromiseThen, probe, [() => void 0, () => void 0]);
606
- if (cleanup && (typeof cleanup === "object" || typeof cleanup === "function")) {
607
- const cleanupDescriptor = Object.getOwnPropertyDescriptor(cleanup, "constructor");
608
- let cleanupOverridden = false;
609
- try {
610
- if (!cleanupDescriptor || cleanupDescriptor.configurable) {
611
- Object.defineProperty(cleanup, "constructor", {
612
- configurable: true,
613
- writable: true,
614
- value: Promise
615
- });
616
- cleanupOverridden = true;
617
- } else if ("value" in cleanupDescriptor && cleanupDescriptor.writable) {
618
- Object.defineProperty(cleanup, "constructor", { value: Promise });
619
- cleanupOverridden = true;
620
- }
621
- const cleanupResult = Reflect.apply(nativePromiseThen, cleanup, [() => void 0, () => void 0]);
622
- if (cleanupResult && (typeof cleanupResult === "object" || typeof cleanupResult === "function")) Reflect.apply(nativePromiseThen, cleanupResult, [() => void 0, () => void 0]);
623
- } finally {
624
- if (cleanupOverridden) {
625
- if (cleanupDescriptor) Object.defineProperty(cleanup, "constructor", cleanupDescriptor);
626
- else Reflect.deleteProperty(cleanup, "constructor");
627
- }
628
- }
629
- }
630
- } finally {
631
- if (overridden) {
632
- if (descriptor) Object.defineProperty(probe, "constructor", descriptor);
633
- else Reflect.deleteProperty(probe, "constructor");
634
- }
635
- }
636
- }
637
- return true;
638
- } catch {
639
- return false;
640
- }
641
- }
642
400
  /**
643
401
  * Only `true` grants access. A Response of this runtime is sent as the rejection. Every other value gets `deny()`, `403` by default.
644
402
  */
645
403
  async function runAccessAuthorize(authorize, context, deny = () => createForbiddenResponse(context.request)) {
646
404
  const result = authorize(context);
647
405
  if (isRuntimeResponse(result)) return { response: sendableRuntimeResponse(result, context.request) };
648
- let resolved;
649
- if (result !== null && (typeof result === "object" || typeof result === "function") && hasNativePromiseBrand(result)) {
650
- let nativePromise;
651
- let constructorDescriptor;
652
- let speciesDescriptor;
653
- let speciesOverridden = false;
654
- let constructorOverridden = false;
655
- try {
656
- constructorDescriptor = Object.getOwnPropertyDescriptor(result, "constructor");
657
- if (!constructorDescriptor || constructorDescriptor.configurable) {
658
- Object.defineProperty(result, "constructor", {
659
- configurable: true,
660
- writable: true,
661
- value: Promise
662
- });
663
- constructorOverridden = true;
664
- } else if (typeof constructorDescriptor.value === "function") {
665
- speciesDescriptor = Object.getOwnPropertyDescriptor(constructorDescriptor.value, Symbol.species);
666
- if (!speciesDescriptor || speciesDescriptor.configurable) {
667
- Object.defineProperty(constructorDescriptor.value, Symbol.species, {
668
- configurable: true,
669
- value: Promise
670
- });
671
- speciesOverridden = true;
672
- } else if ("value" in constructorDescriptor && constructorDescriptor.writable) {
673
- Object.defineProperty(result, "constructor", { value: Promise });
674
- constructorOverridden = true;
675
- }
676
- }
677
- nativePromise = new Promise((resolve, reject) => {
678
- Promise.prototype.then.call(result, resolve, reject);
679
- });
680
- } catch (error) {
681
- try {
682
- nativePromise = Reflect.apply(nativePromiseResolve, Promise, [result]);
683
- } catch {
684
- nativePromise = Promise.reject(error);
685
- }
686
- } finally {
687
- if (constructorOverridden) {
688
- if (constructorDescriptor) Object.defineProperty(result, "constructor", constructorDescriptor);
689
- else Reflect.deleteProperty(result, "constructor");
690
- }
691
- if (speciesOverridden && constructorDescriptor && typeof constructorDescriptor.value === "function") {
692
- if (speciesDescriptor) Object.defineProperty(constructorDescriptor.value, Symbol.species, speciesDescriptor);
693
- else Reflect.deleteProperty(constructorDescriptor.value, Symbol.species);
694
- }
695
- }
696
- resolved = nativePromise ? await nativePromise : void 0;
697
- } else resolved = result !== null && (typeof result === "object" || typeof result === "function") ? await result : result;
406
+ const resolved = await result;
698
407
  if (resolved === true) return {};
699
408
  if (isRuntimeResponse(resolved)) return { response: sendableRuntimeResponse(resolved, context.request) };
700
409
  return { response: deny() };
701
410
  }
702
- async function checkAuthRequest(input, definition, routeIndexes, requiredAuthorizeRouteIndexes = [], redirectToSignIn = true, resolveIdentity, signInURLs) {
411
+ async function checkAuthRequest(input, definition, routeIndexes, requiredAuthorizeRouteIndexes = [], redirectToSignIn = true, resolveIdentity, signInURLs, requiredRoleRouteIndexes = []) {
703
412
  const { auth, event, options, refusal: providerRefusal, request, session } = await readRequestSession(input, definition);
704
413
  if (providerRefusal) return reject(input, createProviderRefusalResponse(providerRefusal));
705
414
  const identity = await resolveIdentity?.(toRequest(request), input, Boolean(session));
706
415
  if (isRuntimeResponse(identity)) return reject(input, identity);
707
416
  if (identity || session) {
708
- const authorization = checkedAuthorization(request, identity ? {} : session.session, identity ?? session.user);
417
+ let authorization = checkedAuthorization(request, identity ? {} : session.session, identity ?? session.user);
709
418
  if (routeIndexes === void 0) return { authorization };
710
419
  const requiredAuthorizeRoutes = new Set(requiredAuthorizeRouteIndexes);
420
+ const requiredRoleRoutes = new Set(requiredRoleRouteIndexes);
711
421
  const routes = authAccessRoutes(options, routeIndexes);
422
+ if (!identity && cachesSessions(options) && routes.some((route) => typeof route === "object" && route.role !== void 0)) {
423
+ const stored = await readSession(input, auth, request.headers, { disableCookieCache: true });
424
+ if (stored.refusal) return reject(input, createProviderRefusalResponse(stored.refusal));
425
+ if (!stored.session) return reject(input, createRefusalResponse("SIGNED_OUT"));
426
+ authorization = checkedAuthorization(request, stored.session.session, stored.session.user);
427
+ }
712
428
  for (const [index, route] of routes.entries()) {
713
429
  const authorize = typeof route === "object" && route !== null ? route.authorize : void 0;
714
- if (!authorize && requiredAuthorizeRoutes.has(routeIndexes[index])) return reject(input, createForbiddenResponse(request));
430
+ const role = typeof route === "object" && route !== null ? route.role : void 0;
431
+ if (!authorize && requiredAuthorizeRoutes.has(routeIndexes[index]) || role === void 0 && requiredRoleRoutes.has(routeIndexes[index])) return reject(input, createForbiddenResponse(request));
432
+ if (role !== void 0 && !hasRole(authorization.user, role)) return reject(input, createForbiddenResponse(request));
715
433
  if (!authorize) continue;
716
434
  const rejection = await runAccessAuthorize(authorize, {
717
435
  ...authorization,
@@ -828,6 +546,31 @@ function requireAuthorization(event, authorize, definition) {
828
546
  if (authorize !== true && typeof authorize !== "function") throw authErrorDiagnostics.AUTH_R0014({ message: "[vitehub] `authorize` must be true or a function." });
829
547
  return requireCheck(event, checkAuthorizeRequest(event, authorize, definition ?? resolveDefaultDefinition()));
830
548
  }
549
+ /**
550
+ * Route middleware that checks access before H3 applies `validate.query` and `validate.headers`.
551
+ * Put it in `middleware` of `defineHandler()` or `defineValidatedHandler()`.
552
+ * It returns nothing when the check passes, so the route answers with its handler.
553
+ * Without `authorize`, it rejects like `requireAuth()`. With `authorize`, it rejects like `requireAuthorization()`.
554
+ * For path parameters, call H3's `getValidatedRouterParams(event, schema)` in the handler after checking access.
555
+ *
556
+ * ```ts [server/api/inbox.get.ts]
557
+ * export default defineValidatedHandler({
558
+ * middleware: [authMiddleware()],
559
+ * validate: { query: v.object({ view: v.picklist(["open", "archived"]) }) },
560
+ * handler: async (event) => {
561
+ * const { user } = await requireAuth(event)
562
+ * return listInbox(user.id, event.url.searchParams.get("view"))
563
+ * },
564
+ * })
565
+ * ```
566
+ */
567
+ function authMiddleware(authorize) {
568
+ if (authorize !== void 0 && authorize !== true && typeof authorize !== "function") throw authErrorDiagnostics.AUTH_R0014({ message: "[vitehub] `authorize` must be true or a function." });
569
+ return async (event) => {
570
+ if (authorize === void 0) await requireAuth(event);
571
+ else await requireAuthorization(event, authorize);
572
+ };
573
+ }
831
574
  const callerReads = /* @__PURE__ */ new WeakMap();
832
575
  function requireCaller(event, definition = resolveDefaultDefinition()) {
833
576
  const request = unwrapAuthRequest(event);
@@ -848,9 +591,9 @@ async function readCaller(event, definition) {
848
591
  const auth = authForRequest(request, authRequestEvent(event), definition);
849
592
  const { options } = await auth.$context;
850
593
  if (isJwsToken(token) && mcpOAuthResources(options.plugins).length) {
851
- const { verifyAppAccessToken } = await import("./mcp-token-CuqdbBy8.js").then((n) => n.a);
594
+ const { verifyAppAccessToken } = await import("./mcp-token-BleQZK6H.js").then((n) => n.a);
852
595
  const url = new URL(request.url);
853
- const [error, caller] = await verifyAppAccessToken(token, clientRequestOrigin(request, trustsProxyHeaders(options)), url.pathname, auth);
596
+ const [error, caller] = await verifyAppAccessToken(token, clientRequestOrigin(request, trustsProxyHeaders(options)), url, auth);
854
597
  if (error) return [error, void 0];
855
598
  return [void 0, Object.freeze({
856
599
  client: {
@@ -914,13 +657,17 @@ async function can(event, name, ...args) {
914
657
  }
915
658
  const reusableAccessChecks = /* @__PURE__ */ new WeakMap();
916
659
  async function checkAuthAccessRequest(input, definition, routeIndexes, requiredAuthorizeRouteIndexes, options = {}) {
917
- const key = JSON.stringify([routeIndexes, requiredAuthorizeRouteIndexes]);
660
+ const key = JSON.stringify([
661
+ routeIndexes,
662
+ requiredAuthorizeRouteIndexes,
663
+ options.requiredRoleRouteIndexes ?? []
664
+ ]);
918
665
  const request = unwrapAuthRequest(input);
919
666
  let definitions = reusableAccessChecks.get(request);
920
667
  let accepted = definitions?.get(definition);
921
668
  const reusable = accepted?.get(key);
922
669
  if (reusable === true || options.reuse && reusable === false) return;
923
- const { response } = await checkAuthRequest(input, definition, routeIndexes, requiredAuthorizeRouteIndexes, options.redirectToSignIn !== false, getAuthRuntimeState().accessIdentityResolvers?.get(new URL(request.url).pathname), options.signIn);
670
+ const { response } = await checkAuthRequest(input, definition, routeIndexes, requiredAuthorizeRouteIndexes, options.redirectToSignIn !== false, getAuthRuntimeState().accessIdentityResolvers?.get(new URL(request.url).pathname), options.signIn, options.requiredRoleRouteIndexes);
924
671
  if (response) return sendSessionCookies(input, response);
925
672
  if (options.reuse || options.remember) {
926
673
  if (!definitions) reusableAccessChecks.set(request, definitions = /* @__PURE__ */ new WeakMap());
@@ -934,12 +681,17 @@ function createAuthAccessHandler(routes, definition, publicRoutes = []) {
934
681
  return async (input) => {
935
682
  const matched = match(input);
936
683
  if (matched.length === 0) return;
937
- return await checkAuthAccessRequest(input, definition ?? resolveDefaultDefinition(), matched.map((rule) => rule.index), matched.filter((rule) => rule.authorize).map((rule) => rule.index), { remember: true });
684
+ return await checkAuthAccessRequest(input, definition ?? resolveDefaultDefinition(), matched.map((rule) => rule.index), matched.filter((rule) => rule.authorize).map((rule) => rule.index), {
685
+ remember: true,
686
+ requiredRoleRouteIndexes: matched.filter((rule) => rule.role).map((rule) => rule.index)
687
+ });
938
688
  };
939
689
  }
940
690
  async function requireAuthAccessRoutes(input, routeIndexes, definition = resolveDefaultDefinition(), requiredAuthorizeRouteIndexes = [], options = {}) {
941
691
  if (!Array.isArray(routeIndexes) || routeIndexes.length === 0 || routeIndexes.some((routeIndex) => !Number.isSafeInteger(routeIndex) || routeIndex < 0)) throw authErrorDiagnostics.AUTH_R0009({ message: "[vitehub] Auth access route indexes must be a non-empty array of non-negative integers." });
942
692
  if (!Array.isArray(requiredAuthorizeRouteIndexes) || requiredAuthorizeRouteIndexes.some((routeIndex) => !Number.isSafeInteger(routeIndex) || routeIndex < 0)) throw authErrorDiagnostics.AUTH_R0010({ message: "[vitehub] Required Auth authorize route indexes must be an array of non-negative integers." });
693
+ const roleIndexes = options.requiredRoleRouteIndexes;
694
+ if (roleIndexes !== void 0 && (!Array.isArray(roleIndexes) || roleIndexes.some((routeIndex) => !Number.isSafeInteger(routeIndex) || routeIndex < 0))) throw authErrorDiagnostics.AUTH_R0010({ message: "[vitehub] Required Auth role route indexes must be an array of non-negative integers." });
943
695
  return await checkAuthAccessRequest(input, definition, routeIndexes, requiredAuthorizeRouteIndexes, options);
944
696
  }
945
697
  /**
@@ -996,4 +748,4 @@ function getAuthConsoleForRequest(request, event, host) {
996
748
  });
997
749
  return createAuthConsole(requestProvider(definition, resolved), resolved.options.console, resolved.options.events ? resolved.options.events.store : void 0, host);
998
750
  }
999
- 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 };
751
+ export { signOut as C, withAuth as D, withAnonymousAuthorization as E, withAuthorization as O, requireCaller as S, useAuth as T, listAuthEvents as _, can as a, requireAuthAccessRoutes as b, createAuthAccessHandler as c, createAuthRequestRuntimeOptions as d, getAuth as f, handleAuthRequest as g, handleAuth as h, authRoute as i, createAuthForRequest as l, getAuthEvents as m, assertAuthOrigin as n, checkAuthMember as o, getAuthConsoleForRequest as p, authMiddleware as r, createAuth as s, aggregateAuthEvents as t, createAuthHandler as u, requireAbility as v, toAuthRequest as w, requireAuthorization as x, requireAuth as y };
@@ -1,8 +1,8 @@
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
- import { o as McpTokenInvalidError } from "./mcp-token-CmQbXbTu.js";
5
- import "./server-BHniJi2m.js";
1
+ import { t as AuthConsole } from "./console-runtime-C71weVrt.js";
2
+ import { Bt as AuthEventWindow, C as AuthGuardedHandler, E as AuthRequestInput, G as ViteHubAuth, H as RegisteredAuth, It as AuthEventPage, Mt as AuthEventAggregates, N as AuthRuntimeOptions, Pt as AuthEventListInput, R as AuthSignInConfiguration, Rt as AuthEventStore, S as AuthFor, T as AuthRequest, U as ResolvedAuthAccessRoute, _ as AuthDefinition, at as AuthConsoleHostOptions, d as AuthAnonymousGuardedHandler, h as AuthBetterAuthRuntimeOptions, p as AuthAuthorization, u as AuthAnonymousAuthorize } from "./types-CnO5bHEF.js";
3
+ import { i as AbilityName, n as AbilityAuthorization, t as AbilityArgs } from "./abilities-IOwpkcz4.js";
4
+ import { o as McpTokenInvalidError } from "./mcp-token-CxpopXmK.js";
5
+ import "./server-mmp8EfcE.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";
@@ -44,6 +44,15 @@ declare function getAuthForDefinition<TDefinition extends AuthDefinition>(defini
44
44
  * `useAuth(event)`. The Console reads it through `@vite-hub/auth/runtime/console`.
45
45
  */
46
46
  declare function authForRequest(request: Pick<Request, "headers" | "url">, event?: ViteHubContext, definition?: AuthDefinition): RegisteredAuth;
47
+ /**
48
+ * The last step of a guard that sees the outcome of the request: a refusal, or the value or Response of the route.
49
+ *
50
+ * A plain Fetch host sends only this Response, so the session cookies move from the prepared response to a copy of
51
+ * it, once, also for a Response of another Fetch implementation, such as `undici`. H3 adds the prepared response to
52
+ * the outcome itself. In both, a cookie that the Response sets itself wins over the session cookie of the same name,
53
+ * and the Cache-Control of the route becomes `private`, unless it already has `private` or `no-store`.
54
+ */
55
+ declare function sendSessionCookies<T>(input: AuthRequestInput, outcome: T): T | Response;
47
56
  /** Where Better Auth returns after one sign-in that a guard starts. */
48
57
  type AuthSignInURLs = Pick<AuthProviderSignIn, "callbackURL" | "errorCallbackURL">;
49
58
  /** A provider sign-in with the page that Better Auth returns to. */
@@ -135,9 +144,30 @@ declare function requireAuth(event: AuthRequestInput, definition: AuthDefinition
135
144
  */
136
145
  declare function requireAuthorization<TInput extends AuthRequestInput>(event: TInput, authorize: AccessAuthorizeOption<TInput & ViteHubContext>, definition?: undefined): Promise<AuthAuthorization>;
137
146
  declare function requireAuthorization<TInput extends AuthRequestInput>(event: TInput, authorize: AccessAuthorizeOption<TInput & ViteHubContext, false>, definition: AuthDefinition | undefined): Promise<CoreAuthorization>;
147
+ /**
148
+ * Route middleware that checks access before H3 applies `validate.query` and `validate.headers`.
149
+ * Put it in `middleware` of `defineHandler()` or `defineValidatedHandler()`.
150
+ * It returns nothing when the check passes, so the route answers with its handler.
151
+ * Without `authorize`, it rejects like `requireAuth()`. With `authorize`, it rejects like `requireAuthorization()`.
152
+ * For path parameters, call H3's `getValidatedRouterParams(event, schema)` in the handler after checking access.
153
+ *
154
+ * ```ts [server/api/inbox.get.ts]
155
+ * export default defineValidatedHandler({
156
+ * middleware: [authMiddleware()],
157
+ * validate: { query: v.object({ view: v.picklist(["open", "archived"]) }) },
158
+ * handler: async (event) => {
159
+ * const { user } = await requireAuth(event)
160
+ * return listInbox(user.id, event.url.searchParams.get("view"))
161
+ * },
162
+ * })
163
+ * ```
164
+ */
165
+ declare function authMiddleware<TInput extends AuthRequestInput>(authorize?: AccessAuthorizeOption<TInput & ViteHubContext>): (event: TInput) => Promise<void>;
138
166
  /**
139
167
  * Return who calls: a person with an Auth Session (`kind: "browser"`), or an Agent with an MCP access token of
140
- * `mcpOAuth()` (`kind: "agent"`), checked like `verifyMcpRequest()` for any `mcpOAuth()` resource of the origin. Like
168
+ * `mcpOAuth()` (`kind: "agent"`), checked like `verifyMcpRequest()`. The longest matching resource path wins. At that
169
+ * path, the query must match exactly unless a resource has no query. On other paths, or when the origin has just one
170
+ * resource, the token must name the first resource of the origin. Like
141
171
  * `verifyMcpRequest()`, it accepts `jwt()` and an `oauthProvider()` with `resources` that the app adds without
142
172
  * `mcpOAuth()`. A bearer token that is not a JWT, such as a session token of `bearer()`, is read as a session.
143
173
  * Returns `AUTH_SIGNED_OUT` without either, and `AUTH_MCP_TOKEN_INVALID` for a JWT bearer token that fails a check.
@@ -174,6 +204,8 @@ declare function can<const Name extends AbilityName>(event: AuthRequestInput, na
174
204
  declare function createAuthAccessHandler(routes: readonly ResolvedAuthAccessRoute[], definition?: AuthDefinition, publicRoutes?: readonly string[]): (input: AuthRequestInput) => Promise<Response | undefined>;
175
205
  declare function requireAuthAccessRoutes(input: AuthRequestInput, routeIndexes: number[], definition?: AuthDefinition, requiredAuthorizeRouteIndexes?: number[], options?: {
176
206
  redirectToSignIn?: boolean;
207
+ /** The indexes of the matched routes that have `role`. A runtime Definition without that role refuses. */
208
+ requiredRoleRouteIndexes?: number[];
177
209
  /** Where Better Auth returns after this sign-in, replacing `access.signIn.callbackURL` and `errorCallbackURL`. */
178
210
  signIn?: AuthSignInURLs;
179
211
  /** Reuse successful checks of these exact rules and Definition on this request, including in app Auth middleware. */
@@ -199,4 +231,4 @@ declare function aggregateAuthEvents(window: AuthEventWindow, definition?: AuthD
199
231
  * `host.impersonation` lets the Console start impersonation. It is off by default.
200
232
  */
201
233
  declare function getAuthConsoleForRequest(request: Request, event?: ViteHubContext, host?: AuthConsoleHostOptions): AuthConsole;
202
- export { authForRequest as A, requireCaller as C, withAnonymousAuthorization as D, useAuth as E, AuthCallerError as F, AuthCallerErrorCode as I, AuthCallerResult as L, findVerifiedAuthUserId as M, getAuthForDefinition as N, withAuth as O, AuthCaller as P, AuthCallerUser as R, 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, AuthMemberErrorCode as z };
234
+ export { withAuthorization as A, AuthCallerUser as B, requireAuthorization as C, useAuth as D, toAuthRequest as E, getAuthForDefinition as F, AuthCaller as I, AuthCallerError as L, authForRequest as M, createBetterAuthOptions as N, withAnonymousAuthorization as O, findVerifiedAuthUserId as P, AuthCallerErrorCode as R, requireAuthAccessRoutes as S, signOut as T, AuthMemberErrorCode as V, handleAuth as _, authMiddleware as a, requireAbility as b, checkAuthMember as c, createAuthForRequest as d, createAuthHandler as f, getAuthEvents as g, getAuthConsoleForRequest as h, assertAuthOrigin as i, sendSessionCookies as j, withAuth as k, createAuth as l, getAuth as m, AuthSignOutOptions as n, authRoute as o, createAuthRequestRuntimeOptions as p, aggregateAuthEvents as r, can as s, AuthEventReadErrorCode as t, createAuthAccessHandler as u, handleAuthRequest as v, requireCaller as w, requireAuth as x, listAuthEvents as y, AuthCallerResult as z };
@@ -1,5 +1,6 @@
1
- import "./own-access-BNcxKrDl.js";
2
- import { E as AuthRequestInput, H as ResolvedAuthAccessRoute, _ as AuthDefinition } from "./types-DmH31d2t.js";
1
+ import "./extension-BWmjJhoN.js";
2
+ import "./own-access-CGiai2L3.js";
3
+ import { E as AuthRequestInput, U as ResolvedAuthAccessRoute, _ as AuthDefinition } from "./types-CnO5bHEF.js";
3
4
  import { AccessAuthorizationContext, ViteHubContext } from "@vite-hub/runtime";
4
5
  type AuthRuntimeEnvResolver = (event?: ViteHubContext) => Record<string, unknown>;
5
6
  type AuthAccessIdentityResolver = (request: Request, event: AuthRequestInput, hasSession: boolean) => Promise<AccessAuthorizationContext<unknown, false>["user"] | Response | undefined>;
@@ -19,6 +20,7 @@ declare function setAuthAccessIdentityResolver(path: string, resolver: AuthAcces
19
20
  interface AuthAccessRouteMatch {
20
21
  index: number;
21
22
  authorize: boolean;
23
+ role: boolean;
22
24
  }
23
25
  /**
24
26
  * Return a function that lists the access routes that match a request, in Definition order. A request to a path of
package/dist/server.d.ts CHANGED
@@ -1,5 +1,8 @@
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-C4Kni3Vj.js";
3
- import { a as McpTokenInvalidData, o as McpTokenInvalidError, s as McpTokenInvalidReason } from "./mcp-token-CmQbXbTu.js";
2
+ import { A as withAuthorization, B as AuthCallerUser, C as requireAuthorization, D as useAuth, I as AuthCaller, L as AuthCallerError, O as withAnonymousAuthorization, R as AuthCallerErrorCode, T as signOut, V as AuthMemberErrorCode, _ as handleAuth, a as authMiddleware, b as requireAbility, c as checkAuthMember, f as createAuthHandler, g as getAuthEvents, h as getAuthConsoleForRequest, k as withAuth, o as authRoute, r as aggregateAuthEvents, s as can, t as AuthEventReadErrorCode, w as requireCaller, x as requireAuth, y as listAuthEvents, z as AuthCallerResult } from "./server-DyP1v-sZ.js";
3
+ import { a as McpTokenInvalidData, o as McpTokenInvalidError, s as McpTokenInvalidReason } from "./mcp-token-CxpopXmK.js";
4
4
  import { n as AbilityErrorData, t as AbilityError } from "./ability-error-C1c30O6E.js";
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 };
5
+ import { AuthContext } from "better-auth";
6
+ /** Whether the resolved Auth context applies `VITEHUB_MEMBERS`. */
7
+ export declare function hasAuthMembers(context: Pick<AuthContext, "options">): boolean;
8
+ 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, authMiddleware, can, checkAuthMember, createAuthHandler, authRoute as default, getAuthConsoleForRequest, getAuthEvents, handleAuth, listAuthEvents, requireAbility, requireAuth, requireAuthorization, requireCaller, signOut, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };