@vite-hub/auth 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +32 -8
  2. package/dist/{abilities-CbmTAoS_.d.ts → abilities-3L1Y5Pnw.d.ts} +2 -4
  3. package/dist/abilities.d.ts +1 -1
  4. package/dist/abilities.js +1 -2
  5. package/dist/{ability-error-IeZQBr_-.js → ability-error-BHhPkrZd.js} +3 -5
  6. package/dist/{ability-error-DcgChwCN.d.ts → ability-error-C1c30O6E.d.ts} +1 -5
  7. package/dist/access-pages-BwImVHN_.js +94 -0
  8. package/dist/{admin-claim-code-CDipqeAU.js → admin-claim-code-C3X_U43x.js} +1 -2
  9. package/dist/agent.d.ts +1 -3
  10. package/dist/agent.js +5 -6
  11. package/dist/{application-path-DuTpfGFj.js → application-path-zKi7NrvK.js} +1 -2
  12. package/dist/{auth-instance-CmDogt4D.js → auth-instance-_J7R9Qs1.js} +239 -50
  13. package/dist/{cli-ubYJpAL_.d.ts → cli-C5pAfY4x.d.ts} +1 -6
  14. package/dist/cli.d.ts +2 -4
  15. package/dist/cli.js +3 -4
  16. package/dist/{console-runtime-D2ai-Et5.d.ts → console-runtime-BP1ZKJB0.d.ts} +13 -13
  17. package/dist/{console-runtime-_LrpyCYY.js → console-runtime-vc3JQEuq.js} +72 -40
  18. package/dist/console-runtime.d.ts +2 -2
  19. package/dist/console-runtime.js +1 -2
  20. package/dist/{console-types-CmmnKGMx.js → console-types-51lkf0lk.js} +1 -2
  21. package/dist/console.d.ts +1 -5
  22. package/dist/console.js +2 -3
  23. package/dist/{database-options-DpOVjUti.js → database-options-DQ-8qYMl.js} +2 -3
  24. package/dist/{database-schema-options-Sk-1Bvyu.js → database-schema-options-CkSeU9V3.js} +2 -3
  25. package/dist/database.d.ts +1 -3
  26. package/dist/database.js +5 -6
  27. package/dist/{definition-BCaLA9kW.js → definition-MDGMNKrK.js} +20 -18
  28. package/dist/{error-diagnostics-Dymr-S_n.js → error-diagnostics-BssJr_2t.js} +9 -4
  29. package/dist/{events-DCfuicoo.js → events-DZqMiae_.js} +4 -6
  30. package/dist/forward.d.ts +1 -3
  31. package/dist/forward.js +2 -3
  32. package/dist/index.d.ts +4 -7
  33. package/dist/index.js +4 -3
  34. package/dist/internal/server.d.ts +4 -4
  35. package/dist/internal/server.js +5 -5
  36. package/dist/{invariant-D8_xBqmZ.js → invariant-Dj2R1eMr.js} +2 -3
  37. package/dist/{mcp-config-DRRlCAWN.js → mcp-config-C7srUMIZ.js} +2 -3
  38. package/dist/{mcp-token-CpxLyl_p.js → mcp-token--KuLYEub.js} +7 -18
  39. package/dist/mcp.d.ts +0 -4
  40. package/dist/mcp.js +4 -5
  41. package/dist/{members-DdlsS8kJ.js → members-D3_Q5XJb.js} +10 -14
  42. package/dist/nitro-kit-Bg4xUZAI.js +43 -0
  43. package/dist/{nuxt-bridge-Cl988STZ.js → nuxt-bridge-pRyfYD5c.js} +1 -2
  44. package/dist/nuxt.d.ts +31 -24
  45. package/dist/nuxt.js +336 -18
  46. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  47. package/dist/own-access-C22hSIuF.d.ts +18 -0
  48. package/dist/own-access-DQgqxTbI.js +30 -0
  49. package/dist/{page-tools-shared-l4eyj53D.js → page-tools-shared-CtoKaNQZ.js} +1 -2
  50. package/dist/{presets-CHndEv5i.d.ts → presets-C6AtiRdI.d.ts} +0 -2
  51. package/dist/presets.d.ts +1 -1
  52. package/dist/presets.js +2 -3
  53. package/dist/{request-z6DHHmrb.js → request-Dpq7GO8B.js} +2 -4
  54. package/dist/runtime/console.d.ts +1 -1
  55. package/dist/runtime/console.js +2 -2
  56. package/dist/runtime/empty-abilities.d.ts +1 -3
  57. package/dist/runtime/empty-abilities.js +1 -2
  58. package/dist/runtime/empty-client.d.ts +0 -2
  59. package/dist/runtime/empty-client.js +1 -2
  60. package/dist/runtime/empty-definition.d.ts +1 -3
  61. package/dist/runtime/empty-definition.js +1 -2
  62. package/dist/runtime/nuxt.d.ts +1 -3
  63. package/dist/runtime/nuxt.js +1 -2
  64. package/dist/runtime/server.d.ts +3 -2
  65. package/dist/runtime/server.js +27 -19
  66. package/dist/runtime/vue-nuxt.d.ts +0 -2
  67. package/dist/runtime/vue-nuxt.js +74 -33
  68. package/dist/{runtime-state-ojQCzKOc.js → runtime-state-DtKUfxKq.js} +1 -2
  69. package/dist/schema.d.ts +71 -23
  70. package/dist/schema.js +6 -5
  71. package/dist/{server-BM-RSf1T.d.ts → server-CFWlYQJb.d.ts} +7 -14
  72. package/dist/{server-BG_MFd4q.js → server-D4Hi4TBI.js} +51 -33
  73. package/dist/{server-C8TlOrSy.d.ts → server-DCsgxFPP.d.ts} +9 -14
  74. package/dist/server.d.ts +2 -2
  75. package/dist/server.js +2 -2
  76. package/dist/{session-cookies-DVzjOKc7.js → session-cookies-1FMcMnRh.js} +6 -8
  77. package/dist/{set-cookie-DmqWq6kj.js → set-cookie-DkqM1kvj.js} +3 -5
  78. package/dist/{table-specs-DbXyaXWs.d.ts → table-specs-BLm_Zlss.d.ts} +255 -3
  79. package/dist/{table-specs-CURphR3n.js → table-specs-jw0jjU6l.js} +43 -44
  80. package/dist/test.d.ts +2 -4
  81. package/dist/test.js +3 -4
  82. package/dist/{types-CruflEFI.d.ts → types-BHSgxyvV.d.ts} +50 -11
  83. package/dist/{vite-Dy0Xhq4H.js → vite-D1xC9n1O.js} +365 -152
  84. package/dist/vite.d.ts +7 -14
  85. package/dist/vite.js +1 -2
  86. package/dist/vue.d.ts +17 -72
  87. package/dist/vue.js +25 -73
  88. package/package.json +35 -30
  89. package/dist/shared-DRtfuFsV.js +0 -12
@@ -1,6 +1,6 @@
1
- import { i as resetAuth } from "../runtime-state-ojQCzKOc.js";
2
- import { i as getAuthForDefinition, n as createBetterAuthOptions } from "../auth-instance-CmDogt4D.js";
1
+ import { i as resetAuth } from "../runtime-state-DtKUfxKq.js";
2
+ import { a as getAuthForDefinition, i as findVerifiedAuthUserId, n as createBetterAuthOptions } from "../auth-instance-_J7R9Qs1.js";
3
3
  import { setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver } from "../runtime/server.js";
4
- import { t as AbilityError } from "../ability-error-IeZQBr_-.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-BG_MFd4q.js";
6
- export { AbilityError, aggregateAuthEvents, assertAuthOrigin, can, checkAuthMember, createAuth, createAuthAccessHandler, createAuthForRequest, createAuthHandler, createAuthRequestRuntimeOptions, createBetterAuthOptions, authRoute as default, getAuth, getAuthConsoleForRequest, getAuthEvents, getAuthForDefinition, handleAuth, handleAuthRequest, listAuthEvents, requireAbility, requireAuth, requireAuthAccessRoutes, requireAuthorization, requireCaller, resetAuth, setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver, signOut, toAuthRequest, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };
4
+ import { t as AbilityError } from "../ability-error-BHhPkrZd.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-D4Hi4TBI.js";
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,5 @@
1
1
  import { defineDiagnostics } from "nostics";
2
- //#region ../internal/src/invariant.ts
2
+ // ../internal/src/invariant.ts
3
3
  const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
4
4
  docsBase: "https://vitehub.dev/docs/development/diagnostics",
5
5
  codes: { INTERNAL_INVARIANT_FAILED: {
@@ -18,5 +18,4 @@ function invariantError(what) {
18
18
  function invariant(condition, what) {
19
19
  if (!condition) throw invariantError(what);
20
20
  }
21
- //#endregion
22
- export { invariant as t };
21
+ export { invariantError as n, invariant as t };
@@ -1,5 +1,5 @@
1
- import { t as isRecord } from "./object-Da1zyPCR.js";
2
- //#region src/mcp-config.ts
1
+ import { t as isRecord } from "./object-CAK6UYR5.js";
2
+ // src/mcp-config.ts
3
3
  const mcpRegistrationPluginId = "vitehub-mcp-registration";
4
4
  /**
5
5
  * The resources of MCP OAuth: the Better Auth `oauthProvider()` with `resources` and JWT access tokens of `jwt()`, from
@@ -14,5 +14,4 @@ function mcpOAuthResources(plugins = []) {
14
14
  }
15
15
  /** True for a token in the JWS compact form (`header.payload.signature`), the form of an MCP OAuth access token. */
16
16
  const isJwsToken = (token) => /^[\w-]+\.[\w-]+\.[\w-]+$/.test(token);
17
- //#endregion
18
17
  export { mcpOAuthResources as n, mcpRegistrationPluginId as r, isJwsToken as t };
@@ -1,10 +1,10 @@
1
- import { t as isRecord } from "./object-Da1zyPCR.js";
2
- import { l as findAccessPolicyPlugin } from "./members-DdlsS8kJ.js";
3
- import { t as authForRequest } from "./auth-instance-CmDogt4D.js";
4
- import { n as mcpOAuthResources } from "./mcp-config-DRRlCAWN.js";
1
+ import { l as findAccessPolicyPlugin } from "./members-D3_Q5XJb.js";
2
+ import { t as authForRequest } from "./auth-instance-_J7R9Qs1.js";
3
+ import { n as mcpOAuthResources } from "./mcp-config-C7srUMIZ.js";
4
+ import { t as isRecord } from "./object-CAK6UYR5.js";
5
5
  import { defineErrors } from "@vite-hub/runtime";
6
6
  import { verifyJwsAccessToken } from "better-auth/oauth2";
7
- //#region \0rolldown/runtime.js
7
+ // \0rolldown/runtime.js
8
8
  var __defProp = Object.defineProperty;
9
9
  var __exportAll = (all, no_symbols) => {
10
10
  let target = {};
@@ -15,18 +15,8 @@ var __exportAll = (all, no_symbols) => {
15
15
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
16
  return target;
17
17
  };
18
- //#endregion
19
- //#region src/mcp-token.ts
20
- var mcp_token_exports = /* @__PURE__ */ __exportAll({
21
- appAuth: () => appAuth,
22
- baseScopes: () => baseScopes,
23
- deleteUnusedMcpClients: () => deleteUnusedMcpClients,
24
- mcpOAuthAuth: () => mcpOAuthAuth,
25
- pathOf: () => pathOf,
26
- stateOf: () => stateOf,
27
- verifyAppAccessToken: () => verifyAppAccessToken,
28
- verifyMcpRequest: () => verifyMcpRequest
29
- });
18
+ // src/mcp-token.ts
19
+ var mcp_token_exports = /* @__PURE__ */ __exportAll({ verifyAppAccessToken: () => verifyAppAccessToken });
30
20
  const mcpErrors = /*#__PURE__*/ defineErrors({
31
21
  docs: "https://vitehub.dev/docs/auth/diagnostics",
32
22
  codes: {
@@ -218,5 +208,4 @@ async function deleteUnusedMcpClients(options = {}) {
218
208
  return [mcpErrors.AUTH_MCP_CLEANUP_FAILED({ cause: error }), void 0];
219
209
  }
220
210
  }
221
- //#endregion
222
211
  export { pathOf as a, mcp_token_exports as i, baseScopes as n, stateOf as o, deleteUnusedMcpClients as r, verifyMcpRequest as s, appAuth as t };
package/dist/mcp.d.ts CHANGED
@@ -2,7 +2,6 @@ import { Result } from "@vite-hub/runtime";
2
2
  import { BetterAuthPlugin } from "better-auth";
3
3
  import { oauthProvider } from "@better-auth/oauth-provider";
4
4
  import { jwt } from "better-auth/plugins";
5
- //#region src/mcp-token.d.ts
6
5
  type McpOAuthErrorCode = "AUTH_MCP_CLEANUP_FAILED" | "AUTH_MCP_OAUTH_MISSING" | "AUTH_MCP_TOKEN_INVALID" | "AUTH_MCP_TOKEN_MISSING";
7
6
  /** What the MCP helpers read from a Better Auth instance. `useAuth()` returns one. */
8
7
  interface McpOAuthAuth {
@@ -112,8 +111,6 @@ interface DeleteUnusedMcpClientsOptions {
112
111
  export declare function deleteUnusedMcpClients(options?: DeleteUnusedMcpClientsOptions): Promise<Result<{
113
112
  deleted: number;
114
113
  }, "AUTH_MCP_CLEANUP_FAILED">>;
115
- //#endregion
116
- //#region src/mcp.d.ts
117
114
  /**
118
115
  * OAuth 2.1 sign-in for an MCP server of the app, with Better Auth as the authorization server. `mcpOAuth()` adds the
119
116
  * plugins, `serveMcpOAuthDiscovery()` answers the well-known documents at the origin root, `verifyMcpRequest()` checks the
@@ -194,5 +191,4 @@ export interface McpOAuthDiscoveryOptions {
194
191
  * ```
195
192
  */
196
193
  export declare function serveMcpOAuthDiscovery(request: Request, options?: McpOAuthDiscoveryOptions): Promise<Response | undefined>;
197
- //#endregion
198
194
  export type { DeleteUnusedMcpClientsOptions, McpCaller, McpOAuthAuth, McpOAuthErrorCode, VerifyMcpRequestOptions };
package/dist/mcp.js CHANGED
@@ -1,10 +1,10 @@
1
- import { a as pathOf, n as baseScopes, o as stateOf, r as deleteUnusedMcpClients, s as verifyMcpRequest, t as appAuth } from "./mcp-token-CpxLyl_p.js";
2
- import { t as isRecord } from "./object-Da1zyPCR.js";
3
- import { r as mcpRegistrationPluginId } from "./mcp-config-DRRlCAWN.js";
1
+ import { t as isRecord } from "./object-CAK6UYR5.js";
2
+ import { r as mcpRegistrationPluginId } from "./mcp-config-C7srUMIZ.js";
3
+ import { a as pathOf, n as baseScopes, o as stateOf, r as deleteUnusedMcpClients, s as verifyMcpRequest, t as appAuth } from "./mcp-token--KuLYEub.js";
4
4
  import { APIError, createAuthMiddleware } from "better-auth/api";
5
5
  import { oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata } from "@better-auth/oauth-provider";
6
6
  import { jwt } from "better-auth/plugins";
7
- //#region src/mcp.ts
7
+ // src/mcp.ts
8
8
  const registerPath = "/oauth2/register";
9
9
  /** Bounds RFC 7591 client metadata without restricting the private-use redirect schemes of native MCP clients. */
10
10
  function registrationProblem(body, maxBytes) {
@@ -168,5 +168,4 @@ async function discoveryDocument(request, document, options) {
168
168
  if (suffix && suffix !== pathOf(state.issuer)) return void 0;
169
169
  return (document === "oauth-authorization-server" ? oauthProviderAuthServerMetadata(auth) : oauthProviderOpenIdConfigMetadata(auth))(request);
170
170
  }
171
- //#endregion
172
171
  export { deleteUnusedMcpClients, mcpOAuth, serveMcpOAuthDiscovery, verifyMcpRequest };
@@ -1,15 +1,15 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-Dymr-S_n.js";
2
- import { t as authCloudflareEnv } from "./request-z6DHHmrb.js";
3
- import { n as adminClaimVariable, t as adminClaimHash } from "./admin-claim-code-CDipqeAU.js";
4
- import { n as getAuthRuntimeState } from "./runtime-state-ojQCzKOc.js";
5
- import { t as invariant } from "./invariant-D8_xBqmZ.js";
6
- import { a as checkGitHubOrgMember } from "./events-DCfuicoo.js";
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-BssJr_2t.js";
2
+ import { t as authCloudflareEnv } from "./request-Dpq7GO8B.js";
3
+ import { n as adminClaimVariable, t as adminClaimHash } from "./admin-claim-code-C3X_U43x.js";
4
+ import { n as getAuthRuntimeState } from "./runtime-state-DtKUfxKq.js";
5
+ import { t as invariant } from "./invariant-Dj2R1eMr.js";
6
+ import { a as checkGitHubOrgMember } from "./events-DZqMiae_.js";
7
7
  import { defineErrors, parseDuration } from "@vite-hub/runtime";
8
8
  import { APIError, createAuthEndpoint, createAuthMiddleware, getSessionFromCtx, sessionMiddleware } from "better-auth/api";
9
9
  import { createSessionStore, deleteSessionCookie, expireCookie, parseCookies } from "better-auth/cookies";
10
10
  import { createInternalAdapter } from "better-auth/db";
11
11
  import { decryptOAuthToken } from "better-auth/oauth2";
12
- //#region src/admins.ts
12
+ // src/admins.ts
13
13
  /** The variable that lists the provider accounts that get the admin role. */
14
14
  const adminsVariable = "VITEHUB_ADMINS";
15
15
  /** The id of the Better Auth plugin that gives the admin role. The Auth Console reads its `options.admins`. */
@@ -115,8 +115,7 @@ function createAdminsPlugin(admins, plugins) {
115
115
  }
116
116
  };
117
117
  }
118
- //#endregion
119
- //#region src/admin-claim.ts
118
+ // src/admin-claim.ts
120
119
  /** The id of the Better Auth plugin that turns a claim code into the admin role. */
121
120
  const adminClaimPluginId = "vitehub-admin-claim";
122
121
  /** The configured claim hash, or `undefined` when the app has no claim code. */
@@ -218,8 +217,7 @@ function createAdminClaimPlugin(hash, plugins) {
218
217
  }
219
218
  };
220
219
  }
221
- //#endregion
222
- //#region src/access-policy.ts
220
+ // src/access-policy.ts
223
221
  /** The id of the Better Auth plugin that applies `access.policy` and `VITEHUB_MEMBERS`. `verifyMcpRequest()` finds the policy by it. */
224
222
  const accessPolicyPluginId = "vitehub-access-policy";
225
223
  const defaultRecheck = "5m";
@@ -337,8 +335,7 @@ function findAccessPolicyPlugin(plugins) {
337
335
  const plugin = plugins?.find((entry) => entry.id === accessPolicyPluginId);
338
336
  return plugin && "allows" in plugin && typeof plugin.allows === "function" ? plugin : void 0;
339
337
  }
340
- //#endregion
341
- //#region src/members.ts
338
+ // src/members.ts
342
339
  const orgCacheMs = 3e5;
343
340
  /** The variable that lists who may sign up and sign in. */
344
341
  const membersVariable = "VITEHUB_MEMBERS";
@@ -529,5 +526,4 @@ function createMembersGate(members, admins, plugins) {
529
526
  })
530
527
  };
531
528
  }
532
- //#endregion
533
529
  export { readMembers as a, createAccessPolicyPlugin as c, createAdminClaimPlugin as d, readAdminClaim as f, readAdmins as g, createAdminsPlugin as h, notMemberError as i, findAccessPolicyPlugin as l, adminsVariable as m, createMembersGate as n, withMemberScopes as o, adminsPluginId as p, membersVariable as r, accessPolicyPluginId as s, assertMembersSessionStore as t, adminClaimPluginId as u };
@@ -0,0 +1,43 @@
1
+ import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
2
+ // ../internal/src/nitro-kit.ts
3
+ /**
4
+ * The route meta of a ViteHub handler that Auth access routes leave alone, such as the Console RPC. The handler takes
5
+ * only its own signed requests and one-time links, so app access rules do not apply to it.
6
+ */
7
+ const ownAccessHandlerMeta = Object.freeze({ vitehubAuthAccess: "handler" });
8
+ /**
9
+ * The route meta of a generated handler that checks access on every request, even when the app adds no rule: a required
10
+ * `authorize` policy, an explicit `access` rule, a required access token, or a signature. Auth access routes still apply
11
+ * to it, so an app rule stays in force. `checksOwnAccess(event)` of `vite-hub/auth` reads it, so app middleware can skip
12
+ * the route. A route that can run without a check, such as a browser error sink, an optional `authorize`, or a webhook
13
+ * with `secret: false`, must not use it.
14
+ */
15
+ const ownAccessRouteMeta = Object.freeze({ vitehubOwnAccess: true });
16
+ function cloneArray(value) {
17
+ return Array.isArray(value) ? [...value] : [];
18
+ }
19
+ function sameHandler(left, right) {
20
+ return left.handler === right.handler && left.route === right.route && left.method === right.method && left.middleware === right.middleware;
21
+ }
22
+ /** Create a Nitro 3 configuration builder for generated ViteHub output. */
23
+ function createNitroServerKit(value = {}) {
24
+ const config = isRecordOrFunction(value) ? { ...value } : {};
25
+ const handlers = cloneArray(config.handlers);
26
+ const plugins = cloneArray(config.plugins);
27
+ config.handlers = handlers;
28
+ config.plugins = plugins;
29
+ return {
30
+ config,
31
+ addHandler(handler, position = "end") {
32
+ if (handlers.some((candidate) => isRecordOrFunction(candidate) && sameHandler(candidate, handler))) return;
33
+ if (position === "start") handlers.unshift({ ...handler });
34
+ else handlers.push({ ...handler });
35
+ },
36
+ addPlugin(plugin, position = "end") {
37
+ if (plugins.includes(plugin)) return;
38
+ if (position === "start") plugins.unshift(plugin);
39
+ else plugins.push(plugin);
40
+ }
41
+ };
42
+ }
43
+ export { ownAccessHandlerMeta as n, ownAccessRouteMeta as r, createNitroServerKit as t };
@@ -1,4 +1,4 @@
1
- //#region src/nuxt-bridge.ts
1
+ // src/nuxt-bridge.ts
2
2
  /** The hooks that the setters below install. The composables read them. */
3
3
  const authNuxtBridge = {};
4
4
  /** Internal bridge installed by the Nuxt module, without making `#app` a dependency of the Vue entry. */
@@ -40,5 +40,4 @@ function setSessionSeedResolver(resolver) {
40
40
  function setRequestFetchResolver(resolver) {
41
41
  authNuxtBridge.requestFetchResolver = resolver;
42
42
  }
43
- //#endregion
44
43
  export { setRequestFetchResolver as a, setNuxtErrorFactory as i, setDefaultAuthBasePath as n, setSessionSeedResolver as o, setNuxtAppResolver as r, setSignOutHandler as s, authNuxtBridge as t };
package/dist/nuxt.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { C as AuthOptions } from "./types-CruflEFI.js";
2
+ import { Dt as AuthPages, Et as AuthPageMode, Tt as AuthPageMeta, w as AuthOptions } from "./types-BHSgxyvV.js";
3
3
  import "vite";
4
- //#region ../internal/src/build/paths.d.ts
5
4
  interface NuxtLayerDirectoryConfig {
6
5
  rootDir?: string;
7
6
  serverDir?: string;
@@ -14,21 +13,22 @@ interface NuxtServerDirOptions extends NuxtLayerDirectoryConfig {
14
13
  cwd?: string;
15
14
  }>;
16
15
  }
17
- //#endregion
18
- //#region src/nuxt-types.d.ts
19
- /** Who may open a page: signed-in users (`user`) or signed-out visitors (`guest`). */
20
- type AuthPageMode = "guest" | "user";
21
- /**
22
- * The `auth` key of `definePageMeta()` in Nuxt. `'user'` or `true` sends visitors without a session to the login
23
- * page. `'guest'` sends signed-in users away, for example from the login page. `false` turns the guard off.
24
- */
25
- type AuthPageMeta = boolean | AuthPageMode | {
26
- only?: AuthPageMode;
27
- /** Where to send the visitor instead of the configured redirect. */
28
- redirectTo?: string;
16
+ type VueImport = {
17
+ as?: string;
18
+ disabled?: boolean;
19
+ from: string;
20
+ name: string;
21
+ type?: boolean;
22
+ };
23
+ type NuxtVueImportContext = {
24
+ getImports: () => Promise<unknown>;
25
+ getInternalContext: () => {
26
+ addons: Array<{
27
+ name?: string;
28
+ extendImports?: (imports: VueImport[]) => void;
29
+ }>;
30
+ };
29
31
  };
30
- //#endregion
31
- //#region src/nuxt.d.ts
32
32
  export interface AuthNuxtModuleOptions {
33
33
  auth?: AuthOptions;
34
34
  env?: false | {
@@ -39,7 +39,10 @@ export interface AuthNuxtModuleOptions {
39
39
  }
40
40
  type NuxtLike = {
41
41
  callHook?: (name: "restart") => Promise<void>;
42
- hook?: (name: "nitro:config", handler: (nitroConfig: Record<string, unknown>) => Promise<void>) => void;
42
+ hook?: {
43
+ (name: "nitro:config", handler: (nitroConfig: Record<string, unknown>) => Promise<void>): void;
44
+ (name: "imports:context", handler: (context: NuxtVueImportContext) => Promise<void>): void;
45
+ };
43
46
  options: {
44
47
  dev?: boolean;
45
48
  watch?: string[];
@@ -55,19 +58,24 @@ type NuxtLike = {
55
58
  app?: {
56
59
  baseURL?: string;
57
60
  };
58
- imports?: {
59
- imports?: Array<{
60
- from: string;
61
- name: string;
62
- }>;
61
+ experimental?: {
62
+ extraPageMetaExtractionKeys?: string[];
63
63
  };
64
64
  nitro?: {
65
65
  alias?: Record<string, string>;
66
66
  plugins?: string[];
67
67
  };
68
68
  rootDir?: string;
69
+ routeRules?: Record<string, Record<string, unknown>>;
70
+ router?: {
71
+ options?: {
72
+ sensitive?: boolean;
73
+ strict?: boolean;
74
+ };
75
+ };
69
76
  serverDir?: string;
70
77
  srcDir?: string;
78
+ ssr?: boolean;
71
79
  vite?: {
72
80
  define?: Record<string, unknown>;
73
81
  plugins?: unknown[];
@@ -76,5 +84,4 @@ type NuxtLike = {
76
84
  };
77
85
  };
78
86
  export default function hubAuthNuxt(options?: AuthNuxtModuleOptions, nuxt?: NuxtLike): void;
79
- //#endregion
80
- export type { AuthPageMeta, AuthPageMode };
87
+ export type { AuthPageMeta, AuthPageMode, AuthPages };