@vite-hub/auth 0.5.0 → 0.6.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 (92) hide show
  1. package/README.md +3 -3
  2. package/dist/{abilities-9jC7iuN0.d.ts → abilities-D3XlrYDw.d.ts} +1 -3
  3. package/dist/abilities.d.ts +1 -1
  4. package/dist/abilities.js +1 -2
  5. package/dist/{ability-error-DUWJ6Q1W.d.ts → ability-error-C1c30O6E.d.ts} +0 -4
  6. package/dist/{ability-error-DmnUGicq.js → ability-error-D3-u8k1A.js} +3 -5
  7. package/dist/{access-pages-FNQTyGRD.js → access-pages-9aKr6z-k.js} +3 -5
  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-zYMjldPG.js → auth-instance-BpI9Ps8A.js} +88 -91
  13. package/dist/{cli-NCtitmny.d.ts → cli-C5pAfY4x.d.ts} +0 -6
  14. package/dist/cli.d.ts +2 -4
  15. package/dist/cli.js +3 -4
  16. package/dist/{console-runtime-CuXRDhGy.js → console-runtime-CaIXVtB_.js} +10 -211
  17. package/dist/console-runtime-DAjLTLrN.d.ts +32 -0
  18. package/dist/console-runtime.d.ts +3 -3
  19. package/dist/console-runtime.js +1 -2
  20. package/dist/{console-types-CmmnKGMx.js → console-types-NrX5TWl3.js} +3 -3
  21. package/dist/console.d.ts +3 -7
  22. package/dist/console.js +2 -3
  23. package/dist/{database-options-CcjUG-us.js → database-options-B87hDU4j.js} +2 -3
  24. package/dist/{database-schema-options-CTKCAfqW.js → database-schema-options-peXHNLkJ.js} +2 -3
  25. package/dist/database.d.ts +2 -4
  26. package/dist/database.js +6 -7
  27. package/dist/{definition-BFT9T6In.js → definition-BypPLIbI.js} +11 -17
  28. package/dist/{error-diagnostics-uEbxSY2G.js → error-diagnostics-CUPwukgE.js} +2 -3
  29. package/dist/{events-DJmO9a9I.js → events-BXU1_9mc.js} +5 -6
  30. package/dist/forward-sign-ins-BWXPPTRz.js +4 -0
  31. package/dist/forward.d.ts +25 -3
  32. package/dist/forward.js +43 -6
  33. package/dist/index.d.ts +3 -7
  34. package/dist/index.js +3 -3
  35. package/dist/internal/server.d.ts +3 -3
  36. package/dist/internal/server.js +4 -4
  37. package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
  38. package/dist/{mcp-config-DRRlCAWN.js → mcp-config-C7srUMIZ.js} +2 -3
  39. package/dist/mcp-token-CmQbXbTu.d.ts +125 -0
  40. package/dist/{mcp-token-BhonlK9C.js → mcp-token-DzGivm7f.js} +47 -33
  41. package/dist/mcp.d.ts +2 -115
  42. package/dist/mcp.js +5 -6
  43. package/dist/{members-Cl3hFRjk.js → members-CwPIx10t.js} +10 -14
  44. package/dist/{nitro-kit-32CVgbWS.js → nitro-kit-BumWIKa5.js} +3 -4
  45. package/dist/{nuxt-bridge-Cl988STZ.js → nuxt-bridge-pRyfYD5c.js} +1 -2
  46. package/dist/nuxt.d.ts +1 -7
  47. package/dist/nuxt.js +6 -9
  48. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  49. package/dist/{own-access-C8pwo_Kn.js → own-access-CYsakJiH.js} +3 -4
  50. package/dist/{own-access-CdgEICjO.d.ts → own-access-Dt-I5-PT.d.ts} +1 -3
  51. package/dist/{page-tools-shared-l4eyj53D.js → page-tools-shared-CtoKaNQZ.js} +1 -2
  52. package/dist/{presets-CHndEv5i.d.ts → presets-C6AtiRdI.d.ts} +0 -2
  53. package/dist/presets.d.ts +1 -1
  54. package/dist/presets.js +2 -3
  55. package/dist/{request-z6DHHmrb.js → request-Dpq7GO8B.js} +2 -4
  56. package/dist/runtime/console.d.ts +1 -1
  57. package/dist/runtime/console.js +2 -2
  58. package/dist/runtime/empty-abilities.d.ts +1 -3
  59. package/dist/runtime/empty-abilities.js +1 -2
  60. package/dist/runtime/empty-client.d.ts +0 -2
  61. package/dist/runtime/empty-client.js +1 -2
  62. package/dist/runtime/empty-definition.d.ts +1 -3
  63. package/dist/runtime/empty-definition.js +1 -2
  64. package/dist/runtime/nuxt.d.ts +1 -3
  65. package/dist/runtime/nuxt.js +1 -2
  66. package/dist/runtime/server.d.ts +2 -2
  67. package/dist/runtime/server.js +6 -7
  68. package/dist/runtime/vue-nuxt.d.ts +0 -2
  69. package/dist/runtime/vue-nuxt.js +5 -6
  70. package/dist/runtime-state-C0Rd1W4m.js +15 -0
  71. package/dist/schema.d.ts +1 -5
  72. package/dist/schema.js +2 -3
  73. package/dist/{server-Ci2i6p1S.d.ts → server-Cun232hb.d.ts} +14 -17
  74. package/dist/{server-B-zNtSvm.d.ts → server-DL9MSuyj.d.ts} +2 -6
  75. package/dist/{server-CyqLFm3L.js → server-_eUOlAJ8.js} +16 -18
  76. package/dist/server.d.ts +4 -3
  77. package/dist/server.js +2 -2
  78. package/dist/{session-cookies-CZmZS5QF.js → session-cookies-fR6Pv4kD.js} +6 -8
  79. package/dist/{set-cookie-DWIyCCJO.js → set-cookie-DVfi-nJX.js} +3 -5
  80. package/dist/{table-specs-D0VLp1U4.js → table-specs-CCSY4tiS.js} +17 -15
  81. package/dist/{table-specs-BhWz_U0M.d.ts → table-specs-P4LvbOlX.d.ts} +28 -23
  82. package/dist/test.d.ts +2 -4
  83. package/dist/test.js +3 -4
  84. package/dist/{types-gl-myjZc.d.ts → types-BP9_XUr9.d.ts} +4 -30
  85. package/dist/{vite-QKjsPLwP.js → vite-Dem1i1rL.js} +111 -62
  86. package/dist/vite.d.ts +3 -14
  87. package/dist/vite.js +1 -2
  88. package/dist/vue.d.ts +3 -7
  89. package/dist/vue.js +4 -5
  90. package/package.json +32 -31
  91. package/dist/console-runtime-Dqidb3zF.d.ts +0 -73
  92. package/dist/runtime-state-ojQCzKOc.js +0 -25
@@ -1,19 +1,19 @@
1
- import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
2
- import { t as isRecord$1 } from "./object-Da1zyPCR.js";
3
- import { i as resetAuth } from "./runtime-state-ojQCzKOc.js";
4
- import { t as invariant } from "./invariant-DolT9EEx.js";
5
- import { r as resolveAccessRoutePath, t as accessRouteSyntaxError } from "./application-path-DuTpfGFj.js";
6
- import { a as normalizeAuthBasePath, n as assertAuthPages } from "./access-pages-FNQTyGRD.js";
7
- import { a as authDatabaseSchemaError, i as authDatabasePlacementError, n as authDatabaseAdditionalFieldsError, o as authMemoryDatabaseError, t as assertAuthDatabaseIdStrategy } from "./database-options-CcjUG-us.js";
8
- import { t as createNitroServerKit } from "./nitro-kit-32CVgbWS.js";
9
- import { i as resolveAuthTableSpecs, n as authSqlName } from "./table-specs-D0VLp1U4.js";
1
+ import { t as invariant } from "./invariant-Dj2R1eMr.js";
2
+ import { t as createNitroServerKit } from "./nitro-kit-BumWIKa5.js";
3
+ import { t as isRecord$1 } from "./object-CAK6UYR5.js";
4
+ import { r as resolveAccessRoutePath, t as accessRouteSyntaxError } from "./application-path-zKi7NrvK.js";
5
+ import { t as authErrorDiagnostics } from "./error-diagnostics-CUPwukgE.js";
6
+ import { a as normalizeAuthBasePath, n as assertAuthPages } from "./access-pages-9aKr6z-k.js";
7
+ import { a as authDatabaseSchemaError, i as authDatabasePlacementError, n as authDatabaseAdditionalFieldsError, o as authMemoryDatabaseError, t as assertAuthDatabaseIdStrategy } from "./database-options-B87hDU4j.js";
8
+ import { i as resolveAuthTableSpecs, n as authSqlName } from "./table-specs-CCSY4tiS.js";
9
+ import { n as resetAuth } from "./runtime-state-C0Rd1W4m.js";
10
10
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
11
11
  import { basename, dirname, join, parse, relative, resolve } from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
  import { tmpdir } from "node:os";
14
14
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
15
15
  import { parseSync } from "vite";
16
- //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
16
+ // ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
17
17
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
18
18
  function normalizeWindowsPath(input = "") {
19
19
  if (!input) return input;
@@ -110,8 +110,7 @@ const dirname$1 = function(p) {
110
110
  if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
111
111
  return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
112
112
  };
113
- //#endregion
114
- //#region ../internal/src/inspect.ts
113
+ // ../internal/src/inspect.ts
115
114
  function relativeDefinitionFile(projectRoot, file) {
116
115
  return relative$1(projectRoot, file).replaceAll("\\", "/");
117
116
  }
@@ -127,8 +126,7 @@ function summarizeDefinitions(projectRoot, definitions, fallbackSource) {
127
126
  const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
128
127
  new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
129
128
  new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
130
- //#endregion
131
- //#region ../internal/src/build/vite.ts
129
+ // ../internal/src/build/vite.ts
132
130
  const generatedViteHubFilesPattern = "**/.vitehub/**";
133
131
  const projectRootDirectoryMarkers = [
134
132
  ["server", "agents"],
@@ -238,8 +236,7 @@ function isMissingProjectMarker(error) {
238
236
  const code = error.code;
239
237
  return code === "ENOENT" || code === "ENOTDIR";
240
238
  }
241
- //#endregion
242
- //#region src/route-rule-cache.ts
239
+ // src/route-rule-cache.ts
243
240
  /** Route rules that keep one response and serve it to many visitors. */
244
241
  const cachingRuleNames = [
245
242
  "cache",
@@ -305,8 +302,7 @@ async function createCachingRouteRuleFinder(routeRules, toPattern = (path) => pa
305
302
  }
306
303
  };
307
304
  }
308
- //#endregion
309
- //#region ../internal/src/build/paths.ts
305
+ // ../internal/src/build/paths.ts
310
306
  function resolveRuntimeModule(packageDir, modulePath) {
311
307
  const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
312
308
  return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
@@ -333,16 +329,14 @@ function findPackageDir(file) {
333
329
  function ownModule(importMetaUrl, modulePath) {
334
330
  return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
335
331
  }
336
- //#endregion
337
- //#region ../internal/src/definition-catalog.ts
332
+ // ../internal/src/definition-catalog.ts
338
333
  /** `writeFileIfChangedSync` for async callers. */
339
334
  async function writeFileIfChanged(file, contents) {
340
335
  if (await readFile(file, "utf8").catch(() => void 0) === contents) return;
341
336
  await mkdir(resolve$1(file, ".."), { recursive: true });
342
337
  await writeFile(file, contents, "utf8");
343
338
  }
344
- //#endregion
345
- //#region ../internal/src/contributions.ts
339
+ // ../internal/src/contributions.ts
346
340
  function isThenable(value) {
347
341
  return typeof value.then === "function";
348
342
  }
@@ -369,8 +363,7 @@ async function flattenPluginOptions(plugins) {
369
363
  await flattenPlugins(plugins ?? [], flattened, /* @__PURE__ */ new Set());
370
364
  return flattened;
371
365
  }
372
- //#endregion
373
- //#region src/access-route-cache.ts
366
+ // src/access-route-cache.ts
374
367
  /**
375
368
  * The rou3 pattern of the paths that the access middleware guards for a route. The middleware matches the path
376
369
  * literally, so the pattern escapes every character that rou3 reads as syntax. In rou3, `/**` also matches the path
@@ -403,8 +396,7 @@ async function assertNoCachedAccessRoutes(routes, routeRules, baseURL = "/", pub
403
396
  throw authErrorDiagnostics.AUTH_B0002({ message: `[vitehub] Route rule ${JSON.stringify(cached.key)} sets \`${cached.name}\` on ${cached.method} requests to paths that the \`access.routes\` entry ${JSON.stringify(guard.route)} guards. A cached or prerendered response is made for one visitor and served to others.` });
404
397
  }
405
398
  }
406
- //#endregion
407
- //#region ../internal/src/build/ast-walk.ts
399
+ // ../internal/src/build/ast-walk.ts
408
400
  /** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
409
401
  function moduleLanguage(file) {
410
402
  if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
@@ -427,8 +419,7 @@ function walk(node, visit, parent) {
427
419
  } else if (isNode(child)) walk(child, visit, node);
428
420
  }
429
421
  }
430
- //#endregion
431
- //#region ../internal/src/build/scan-module.ts
422
+ // ../internal/src/build/scan-module.ts
432
423
  /**
433
424
  * Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
434
425
  * the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
@@ -559,8 +550,7 @@ function staticString(node) {
559
550
  const value = staticValue(node);
560
551
  return typeof value === "string" ? value : void 0;
561
552
  }
562
- //#endregion
563
- //#region src/discovery.ts
553
+ // src/discovery.ts
564
554
  const authDefinitionExtensions = [
565
555
  ".ts",
566
556
  ".mts",
@@ -633,8 +623,7 @@ function discoverAuthAbilities(rootDir, options = {}) {
633
623
  if (found.length > 1) throw authErrorDiagnostics.AUTH_C0060({ message: ["[vitehub] Only one abilities file is allowed. Found:", ...found.map((file) => ` - ${file}`)].join("\n") });
634
624
  return found[0];
635
625
  }
636
- //#endregion
637
- //#region src/config.ts
626
+ // src/config.ts
638
627
  const authDatabaseModules = /* @__PURE__ */ new Set(["@vite-hub/auth/database", "vite-hub/auth/database"]);
639
628
  function readAuthDatabaseImports(module) {
640
629
  const names = /* @__PURE__ */ new Set();
@@ -650,6 +639,7 @@ function readAuthDatabaseImports(module) {
650
639
  /** The plugin factories whose tables `authDatabase()` adds, by the module that exports them. */
651
640
  const authSchemaPluginImports = {
652
641
  "better-auth/plugins": {
642
+ admin: "admin",
653
643
  anonymous: "anonymous",
654
644
  lastLoginMethod: "lastLoginMethod",
655
645
  phoneNumber: "phoneNumber",
@@ -659,6 +649,9 @@ const authSchemaPluginImports = {
659
649
  "@better-auth/api-key": { apiKey: "apiKey" },
660
650
  "@better-auth/stripe": { stripe: "stripe" }
661
651
  };
652
+ function pluginFactoriesOf(source) {
653
+ return authSchemaPluginImports[source.startsWith("better-auth/plugins/") ? "better-auth/plugins" : source];
654
+ }
662
655
  const viteExtensions = [
663
656
  ".mjs",
664
657
  ".js",
@@ -690,6 +683,9 @@ function resolveLocalModule(importer, specifier) {
690
683
  ].find(isFile);
691
684
  }
692
685
  const nameOf = (node) => node.type === "Identifier" ? node.name : String(node.value);
686
+ function staticMemberName(member) {
687
+ return member.computed ? staticString(member.property) : member.property.type === "Identifier" ? member.property.name : void 0;
688
+ }
693
689
  function addBoundNames(pattern, names) {
694
690
  walk(pattern, (node) => {
695
691
  if (node.type === "Identifier") names.push(node.name);
@@ -705,7 +701,9 @@ function readModuleBindings(module) {
705
701
  imports: /* @__PURE__ */ new Map(),
706
702
  exports: /* @__PURE__ */ new Map(),
707
703
  exportAll: [],
708
- pluginFactories: /* @__PURE__ */ new Map()
704
+ exportAllFactories: [],
705
+ pluginFactories: /* @__PURE__ */ new Map(),
706
+ pluginNamespaces: /* @__PURE__ */ new Map()
709
707
  };
710
708
  const localFile = (specifier) => specifier.startsWith("./") || specifier.startsWith("../") ? resolveLocalModule(module.file, specifier) : void 0;
711
709
  const declare = (name, node) => bindings.declarations.set(name, [...bindings.declarations.get(name) ?? [], node]);
@@ -724,11 +722,12 @@ function readModuleBindings(module) {
724
722
  for (const statement of module.program.body) if (statement.type === "ImportDeclaration") {
725
723
  if (statement.importKind === "type") continue;
726
724
  const source = statement.source.value;
727
- const factories = authSchemaPluginImports[source.startsWith("better-auth/plugins/") ? "better-auth/plugins" : source];
725
+ const factories = pluginFactoriesOf(source);
728
726
  const file = localFile(source);
729
727
  for (const specifier of statement.specifiers) {
730
728
  if (specifier.type === "ImportSpecifier" && specifier.importKind === "type") continue;
731
729
  const imported = specifier.type === "ImportSpecifier" ? nameOf(specifier.imported) : specifier.type === "ImportDefaultSpecifier" ? "default" : "*";
730
+ if (factories && imported === "*") bindings.pluginNamespaces.set(specifier.local.name, factories);
732
731
  if (factories && Object.hasOwn(factories, imported)) bindings.pluginFactories.set(specifier.local.name, factories[imported]);
733
732
  if (file) bindings.imports.set(specifier.local.name, {
734
733
  file,
@@ -739,6 +738,7 @@ function readModuleBindings(module) {
739
738
  if (statement.exportKind === "type") continue;
740
739
  if (statement.declaration) readDeclaration(statement.declaration, true);
741
740
  const file = statement.source ? localFile(statement.source.value) : void 0;
741
+ const factories = statement.source ? pluginFactoriesOf(statement.source.value) : void 0;
742
742
  for (const specifier of statement.specifiers) {
743
743
  if (specifier.exportKind === "type") continue;
744
744
  const local = nameOf(specifier.local);
@@ -747,16 +747,19 @@ function readModuleBindings(module) {
747
747
  file,
748
748
  imported: local
749
749
  });
750
+ else bindings.exports.set(nameOf(specifier.exported), { plugin: factories && Object.hasOwn(factories, local) ? factories[local] : void 0 });
750
751
  } else bindings.exports.set(nameOf(specifier.exported), { local });
751
752
  }
752
753
  } else if (statement.type === "ExportAllDeclaration") {
753
- const file = statement.exportKind === "type" ? void 0 : localFile(statement.source.value);
754
- if (!file) continue;
755
- if (statement.exported) bindings.exports.set(nameOf(statement.exported), {
754
+ if (statement.exportKind === "type") continue;
755
+ const factories = statement.exported ? void 0 : pluginFactoriesOf(statement.source.value);
756
+ if (factories) bindings.exportAllFactories.push(factories);
757
+ const file = localFile(statement.source.value);
758
+ if (statement.exported) bindings.exports.set(nameOf(statement.exported), file ? {
756
759
  file,
757
760
  imported: "*"
758
- });
759
- else bindings.exportAll.push(file);
761
+ } : { plugin: void 0 });
762
+ else if (file) bindings.exportAll.push(file);
760
763
  } else if (statement.type === "ExportDefaultDeclaration") {
761
764
  declare("default", statement.declaration);
762
765
  bindings.exports.set("default", { local: "default" });
@@ -770,21 +773,48 @@ function readModuleBindings(module) {
770
773
  * local modules it imports. The whole module counts for the Definition. In an imported module, only the exports that
771
774
  * the importer uses count, with the declarations and imports that they use.
772
775
  */
773
- function readModuleNeeds(module, needs) {
776
+ function readModuleNeeds(module, needs, exportedFactory) {
774
777
  const bindings = readModuleBindings(module);
775
778
  const plugins = /* @__PURE__ */ new Set();
776
779
  const imports = [];
777
- const need = (file, imported) => imports.push([file, imported === "*" ? "all" : /* @__PURE__ */ new Set([imported])]);
778
- const collectCalls = (node, references) => walk(node, (child) => {
780
+ const need = (file, imported) => imports.push([file, /* @__PURE__ */ new Set([imported])]);
781
+ const needImport = ({ file, imported }) => imported === "*" ? imports.push([file, "all"]) : need(file, imported);
782
+ const calledFactory = (callee) => {
783
+ if (callee.type === "Identifier") {
784
+ const imported = bindings.imports.get(callee.name);
785
+ return bindings.pluginFactories.get(callee.name) ?? (imported && imported.imported !== "*" ? exportedFactory(imported.file, imported.imported) : void 0);
786
+ }
787
+ if (callee.type !== "MemberExpression" || callee.object.type !== "Identifier") return void 0;
788
+ const property = staticMemberName(callee);
789
+ if (property === void 0) return void 0;
790
+ const factories = bindings.pluginNamespaces.get(callee.object.name);
791
+ if (factories) return Object.hasOwn(factories, property) ? factories[property] : void 0;
792
+ const imported = bindings.imports.get(callee.object.name);
793
+ return imported?.imported === "*" ? exportedFactory(imported.file, property) : void 0;
794
+ };
795
+ const collectCalls = (node, references) => walk(node, (child, parent) => {
779
796
  if (child.type === "ImportDeclaration") return false;
780
- if (child.type === "CallExpression" && child.callee.type === "Identifier" && bindings.pluginFactories.has(child.callee.name)) plugins.add(bindings.pluginFactories.get(child.callee.name));
781
- if (child.type === "Identifier") references?.add(child.name);
797
+ const plugin = child.type === "CallExpression" ? calledFactory(child.callee) : void 0;
798
+ if (plugin) plugins.add(plugin);
799
+ if (child.type !== "Identifier") return;
800
+ if (parent?.type === "MemberExpression") {
801
+ if (parent.property === child && !parent.computed) return;
802
+ if (parent.object === child) {
803
+ const imported = bindings.imports.get(child.name);
804
+ const member = staticMemberName(parent);
805
+ if (imported?.imported === "*" && member !== void 0) {
806
+ need(imported.file, member);
807
+ return;
808
+ }
809
+ }
810
+ }
811
+ references.add(child.name);
782
812
  });
783
813
  if (needs === "all") {
784
814
  const references = /* @__PURE__ */ new Set();
785
815
  collectCalls(module.program, references);
786
- for (const [name, { file, imported }] of bindings.imports) if (references.has(name)) need(file, imported);
787
- for (const [, target] of bindings.exports) if ("file" in target) need(target.file, target.imported);
816
+ for (const [name, imported] of bindings.imports) if (references.has(name)) needImport(imported);
817
+ for (const target of bindings.exports.values()) if ("file" in target) needImport(target);
788
818
  return {
789
819
  plugins: [...plugins],
790
820
  imports
@@ -794,15 +824,15 @@ function readModuleNeeds(module, needs) {
794
824
  for (const name of needs) {
795
825
  const target = bindings.exports.get(name);
796
826
  if (!target) for (const file of bindings.exportAll) need(file, name);
797
- else if ("file" in target) need(target.file, target.imported);
798
- else locals.push(target.local);
827
+ else if ("file" in target) needImport(target);
828
+ else if ("local" in target) locals.push(target.local);
799
829
  }
800
830
  const reached = /* @__PURE__ */ new Set();
801
831
  for (let local = locals.pop(); local !== void 0; local = locals.pop()) {
802
832
  if (reached.has(local)) continue;
803
833
  reached.add(local);
804
834
  const imported = bindings.imports.get(local);
805
- if (imported) need(imported.file, imported.imported);
835
+ if (imported) needImport(imported);
806
836
  const references = /* @__PURE__ */ new Set();
807
837
  for (const declaration of bindings.declarations.get(local) ?? []) collectCalls(declaration, references);
808
838
  for (const reference of references) if (bindings.declarations.has(reference) || bindings.imports.has(reference)) locals.push(reference);
@@ -819,6 +849,32 @@ function readModuleNeeds(module, needs) {
819
849
  function readDefinitionSchemaPlugins(definition) {
820
850
  const plugins = /* @__PURE__ */ new Set();
821
851
  const modules = /* @__PURE__ */ new Map([[definition.file, definition]]);
852
+ const moduleOf = (file) => {
853
+ let module = modules.get(file);
854
+ if (!module) modules.set(file, module = scanModule(readFileSync(file, "utf8"), file));
855
+ return module;
856
+ };
857
+ const bindingsByFile = /* @__PURE__ */ new Map();
858
+ const exportedFactory = (file, name, seen = /* @__PURE__ */ new Set()) => {
859
+ const key = `${file}\0${name}`;
860
+ if (seen.has(key)) return void 0;
861
+ seen.add(key);
862
+ let bindings = bindingsByFile.get(file);
863
+ if (!bindings) bindingsByFile.set(file, bindings = readModuleBindings(moduleOf(file)));
864
+ const target = bindings.exports.get(name);
865
+ if (target && "plugin" in target) return target.plugin;
866
+ if (target && "file" in target) return exportedFactory(target.file, target.imported, seen);
867
+ if (target) {
868
+ const imported = bindings.imports.get(target.local);
869
+ return bindings.pluginFactories.get(target.local) ?? (imported && imported.imported !== "*" ? exportedFactory(imported.file, imported.imported, seen) : void 0);
870
+ }
871
+ const factories = bindings.exportAllFactories.find((item) => Object.hasOwn(item, name));
872
+ if (factories) return factories[name];
873
+ for (const exported of bindings.exportAll) {
874
+ const plugin = exportedFactory(exported, name, seen);
875
+ if (plugin) return plugin;
876
+ }
877
+ };
822
878
  const done = /* @__PURE__ */ new Map();
823
879
  const queue = [[definition.file, "all"]];
824
880
  for (let item = queue.shift(); item; item = queue.shift()) {
@@ -828,9 +884,7 @@ function readDefinitionSchemaPlugins(definition) {
828
884
  const fresh = needs === "all" ? "all" : new Set([...needs].filter((name) => !previous?.has(name)));
829
885
  if (fresh !== "all" && !fresh.size) continue;
830
886
  done.set(file, fresh === "all" ? "all" : /* @__PURE__ */ new Set([...previous ?? [], ...fresh]));
831
- let module = modules.get(file);
832
- if (!module) modules.set(file, module = scanModule(readFileSync(file, "utf8"), file));
833
- const result = readModuleNeeds(module, fresh);
887
+ const result = readModuleNeeds(moduleOf(file), fresh, exportedFactory);
834
888
  for (const plugin of result.plugins) plugins.add(plugin);
835
889
  queue.push(...result.imports);
836
890
  }
@@ -1227,8 +1281,7 @@ function resolveAuthViteConfig(options, rootDir = process.cwd(), discovery = {})
1227
1281
  ...!definitionObject.callback && !["database", "preset"].some((key) => hasObjectProperty(body, key)) ? { implicitMemory: true } : {}
1228
1282
  };
1229
1283
  }
1230
- //#endregion
1231
- //#region src/deployment-env.ts
1284
+ // src/deployment-env.ts
1232
1285
  const owners = ["auth"];
1233
1286
  /**
1234
1287
  * The variables that Auth reads on the deployed host. Better Auth signs with the first Better Auth secret that is
@@ -1272,8 +1325,7 @@ function authDeploymentEnv(config) {
1272
1325
  }
1273
1326
  ];
1274
1327
  }
1275
- //#endregion
1276
- //#region src/table-names.ts
1328
+ // src/table-names.ts
1277
1329
  /**
1278
1330
  * The schema keys of the Auth schemas and their SQL names. Its own module, so the Vite plugin lists the tables without
1279
1331
  * loading Drizzle or the schema module.
@@ -1297,8 +1349,7 @@ const authTableNames = {
1297
1349
  invitation: "invitation",
1298
1350
  passkey: "passkey"
1299
1351
  };
1300
- //#endregion
1301
- //#region src/existing-tables.ts
1352
+ // src/existing-tables.ts
1302
1353
  function isRecord(value) {
1303
1354
  return typeof value === "object" && value !== null && !Array.isArray(value);
1304
1355
  }
@@ -1360,8 +1411,7 @@ function readAuthExistingTables(migrationsDir, tableNames) {
1360
1411
  }
1361
1412
  return tables;
1362
1413
  }
1363
- //#endregion
1364
- //#region src/vite.ts
1414
+ // src/vite.ts
1365
1415
  const AUTH_ABILITIES_ID = "#vitehub/auth/abilities";
1366
1416
  const AUTH_CLIENT_ID = "#vitehub/auth/client";
1367
1417
  const AUTH_DEFINITION_ID = "#vitehub/auth/definition";
@@ -1695,7 +1745,7 @@ function hubAuth(options, internalOptions = {}) {
1695
1745
  export: dialect === "postgresql" ? "authPostgresSchema" : "authSqliteSchema"
1696
1746
  },
1697
1747
  tables,
1698
- reason: "Stores the Better Auth users, sessions, accounts, and verifications, the admin() fields, the tables and columns of the plugins and additional fields that the Auth Definition adds, and the Console MCP OAuth clients and tokens of authDatabase()."
1748
+ reason: "Stores the Better Auth users, sessions, accounts, and verifications, the tables and columns of the plugins and additional fields that the Auth Definition adds, and the Console MCP OAuth clients and tokens of authDatabase()."
1699
1749
  }];
1700
1750
  },
1701
1751
  inspect: () => {
@@ -1827,5 +1877,4 @@ function hubAuth(options, internalOptions = {}) {
1827
1877
  }
1828
1878
  };
1829
1879
  }
1830
- //#endregion
1831
1880
  export { AUTH_VITE_PLUGIN_NAME as a, writeNuxtAuthDefinition as c, cachingRuleNames as d, createCachingRouteRuleFinder as f, resolveViteHubProjectRoot as h, AUTH_SERVER_ID as i, resolveAuthViteConfig as l, resolveNuxtServerDirs as m, AUTH_CLIENT_ID as n, createAuthNitroConfig as o, methodOrder as p, AUTH_DEFINITION_ID as r, hubAuth as s, AUTH_ABILITIES_ID as t, authAbilitiesCandidates as u };
package/dist/vite.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { U as ResolvedAuthViteConfig, w as AuthOptions } from "./types-gl-myjZc.js";
3
- import { n as ViteHubCliPluginMetadata } from "./cli-NCtitmny.js";
2
+ import { U as ResolvedAuthViteConfig, w as AuthOptions } from "./types-BP9_XUr9.js";
3
+ import { n as ViteHubCliPluginMetadata } from "./cli-C5pAfY4x.js";
4
4
  import { Plugin } from "vite";
5
- //#region ../internal/src/inspect.d.ts
6
5
  interface ViteHubDefinitionField {
7
6
  label: string;
8
7
  value: string;
@@ -64,17 +63,11 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
64
63
  interface ViteHubInspectionPluginMetadata {
65
64
  inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
66
65
  }
67
- //#endregion
68
- //#region src/config.d.ts
69
66
  export declare function resolveAuthViteConfig(options?: AuthOptions, rootDir?: string, discovery?: {
70
67
  serverDirs?: string[];
71
68
  }): ResolvedAuthViteConfig | undefined;
72
- //#endregion
73
- //#region ../internal/src/deployment.d.ts
74
69
  /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
75
70
  type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
76
- //#endregion
77
- //#region ../internal/src/build/deployment-plan-output.d.ts
78
71
  /**
79
72
  * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
80
73
  * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
@@ -104,8 +97,6 @@ interface DeploymentEnvContext {
104
97
  * Return names only, never values.
105
98
  */
106
99
  type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
107
- //#endregion
108
- //#region ../internal/src/contributions.d.ts
109
100
  /** Roots that ViteHub passes to every contribution factory. */
110
101
  interface ContributionContext {
111
102
  /** Vite root. */
@@ -117,8 +108,6 @@ interface ContributionContext {
117
108
  /** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
118
109
  plugins?: readonly unknown[];
119
110
  }
120
- //#endregion
121
- //#region src/vite.d.ts
122
111
  export declare const AUTH_ABILITIES_ID = "#vitehub/auth/abilities";
123
112
  export declare const AUTH_CLIENT_ID = "#vitehub/auth/client";
124
113
  export declare const AUTH_DEFINITION_ID = "#vitehub/auth/definition";
@@ -166,4 +155,4 @@ interface InternalAuthModuleOptions {
166
155
  }
167
156
  export declare function writeNuxtAuthDefinition(root: string, config: ResolvedAuthViteConfig): Promise<string>;
168
157
  export declare function hubAuth(options?: AuthOptions, internalOptions?: InternalAuthModuleOptions): AuthVitePlugin;
169
- //#endregion
158
+ export {};
package/dist/vite.js CHANGED
@@ -1,2 +1 @@
1
- import { a as AUTH_VITE_PLUGIN_NAME, c as writeNuxtAuthDefinition, i as AUTH_SERVER_ID, l as resolveAuthViteConfig, n as AUTH_CLIENT_ID, o as createAuthNitroConfig, r as AUTH_DEFINITION_ID, s as hubAuth, t as AUTH_ABILITIES_ID } from "./vite-QKjsPLwP.js";
2
- export { AUTH_ABILITIES_ID, AUTH_CLIENT_ID, AUTH_DEFINITION_ID, AUTH_SERVER_ID, AUTH_VITE_PLUGIN_NAME, createAuthNitroConfig, hubAuth, resolveAuthViteConfig, writeNuxtAuthDefinition };
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-Dem1i1rL.js";
package/dist/vue.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { S as AuthFor, _ as AuthDefinition } from "./types-gl-myjZc.js";
3
- import { a as AbilityRefusal, i as AbilityName, t as AbilityArgs } from "./abilities-9jC7iuN0.js";
4
- import { n as AbilityErrorData } from "./ability-error-DUWJ6Q1W.js";
2
+ import { a as AbilityRefusal, i as AbilityName, t as AbilityArgs } from "./abilities-D3XlrYDw.js";
3
+ import { S as AuthFor, _ as AuthDefinition } from "./types-BP9_XUr9.js";
4
+ import { n as AbilityErrorData } from "./ability-error-C1c30O6E.js";
5
5
  import { BetterAuthClientOptions } from "better-auth";
6
6
  import { ComputedRef, VNode } from "vue";
7
7
  import { inferAdditionalFields } from "better-auth/client/plugins";
8
8
  import { BetterFetchError, VueAuthClient, VueAuthClient as VueAuthClient$1, createAuthClient as createAuthClient$1 } from "better-auth/vue";
9
- //#region src/nuxt-bridge.d.ts
10
9
  /** The members of the Nuxt app that the composables read. */
11
10
  type AuthNuxtApp = {
12
11
  runWithContext<T>(run: () => T): T;
@@ -57,8 +56,6 @@ export declare function setSessionSeedResolver(resolver: ((read: boolean) => unk
57
56
  * `undefined` outside a request.
58
57
  */
59
58
  export declare function setRequestFetchResolver(resolver: (() => RequestFetch | undefined) | undefined): void;
60
- //#endregion
61
- //#region src/vue.d.ts
62
59
  /**
63
60
  * The members of a client that the composables read. Every Better Auth Vue client has them. `VueAuthClient<any>`
64
61
  * rejects a client with a required additional field, because its `signUp.email()` needs that field.
@@ -294,5 +291,4 @@ export type AuthPermissionComponent = <const Name extends AbilityName>(props: Au
294
291
  };
295
292
  /** Render the allowed or denied slot. The default slot is shorthand for allowed. */
296
293
  export declare const AuthPermission: AuthPermissionComponent;
297
- //#endregion
298
294
  export type { RequestFetch, VueAuthClient };
package/dist/vue.js CHANGED
@@ -1,9 +1,9 @@
1
- import { i as resolveAuthMountPath } from "./application-path-DuTpfGFj.js";
2
- import { n as checkAbility, t as AbilityError } from "./ability-error-DmnUGicq.js";
3
- import { a as setRequestFetchResolver, i as setNuxtErrorFactory, n as setDefaultAuthBasePath, o as setSessionSeedResolver, r as setNuxtAppResolver, s as setSignOutHandler, t as authNuxtBridge } from "./nuxt-bridge-Cl988STZ.js";
1
+ import { n as checkAbility, t as AbilityError } from "./ability-error-D3-u8k1A.js";
2
+ import { i as resolveAuthMountPath } from "./application-path-zKi7NrvK.js";
3
+ import { a as setRequestFetchResolver, i as setNuxtErrorFactory, n as setDefaultAuthBasePath, o as setSessionSeedResolver, r as setNuxtAppResolver, s as setSignOutHandler, t as authNuxtBridge } from "./nuxt-bridge-pRyfYD5c.js";
4
4
  import abilities from "#vitehub/auth/abilities";
5
5
  import { computed, defineComponent, effectScope, getCurrentInstance, getCurrentScope, inject, onScopeDispose, onServerPrefetch, provide, shallowRef, watch } from "vue";
6
- //#region src/vue.ts
6
+ // src/vue.ts
7
7
  const LOAD = Symbol.for("vitehub.auth.client.load");
8
8
  const ON_LOAD = Symbol.for("vitehub.auth.client.on-load");
9
9
  const OPTIONS = Symbol.for("vitehub.auth.client.options");
@@ -605,5 +605,4 @@ const AuthPermission = defineComponent({
605
605
  };
606
606
  }
607
607
  });
608
- //#endregion
609
608
  export { AuthPermission, authClient, createAuthClient, defineAuthClient, loadAuthClient, onSignOut, provideAuthClient, setDefaultAuthBasePath, setNuxtAppResolver, setNuxtErrorFactory, setRequestFetchResolver, setSessionSeedResolver, setSignOutHandler, useAbility, useAuthClient, useUserSession };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/auth",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Better Auth-powered authentication primitives and Vite integration for ViteHub.",
5
5
  "keywords": [
6
6
  "auth",
@@ -142,58 +142,59 @@
142
142
  "./package.json": "./package.json"
143
143
  },
144
144
  "dependencies": {
145
- "@noble/hashes": "^2.2.0",
146
- "@types/node": "^24.19.1",
147
- "@vite-hub/env": "0.5.0",
148
- "@vite-hub/runtime": "0.5.0",
149
- "@vite-hub/web-container": "0.5.0",
150
- "better-auth": "^1.7.15",
145
+ "@noble/hashes": "^2.4.0",
146
+ "@types/node": "^24.19.2",
147
+ "@vite-hub/env": "0.6.0",
148
+ "@vite-hub/runtime": "0.6.0",
149
+ "@vite-hub/web-container": "0.6.0",
150
+ "better-auth": "^1.7.27",
151
151
  "h3": "^2.0.8",
152
152
  "nostics": "1.4.0",
153
153
  "rou3": "^1.0.0",
154
154
  "scule": "^1.3.0",
155
155
  "unrouting": "^0.3.2",
156
156
  "valibot": "^1.5.0",
157
- "vue-router": "^5.4.0"
157
+ "vue-router": "^5.5.1"
158
158
  },
159
159
  "devDependencies": {
160
- "@better-auth/api-key": "1.7.15",
161
- "@better-auth/oauth-provider": "^1.7.15",
162
- "@better-auth/passkey": "1.7.15",
163
- "@better-auth/stripe": "1.7.15",
164
- "@cloudflare/workers-types": "^5.20261016.1",
160
+ "@better-auth/api-key": "1.7.27",
161
+ "@better-auth/oauth-provider": "^1.7.27",
162
+ "@better-auth/passkey": "1.7.27",
163
+ "@better-auth/stripe": "1.7.27",
164
+ "@cloudflare/workers-types": "^5.20261123.1",
165
165
  "@types/json-schema": "^7.0.15",
166
166
  "@types/mdast": "^4.0.4",
167
- "@types/node": "^24.19.1",
168
- "@vite-hub/agent": "0.5.0",
169
- "@vite-hub/database": "0.5.0",
167
+ "@types/node": "^24.19.2",
168
+ "@vite-hub/agent": "0.6.0",
169
+ "@vite-hub/database": "0.6.0",
170
170
  "@vite-hub/internal": "0.0.1",
171
- "bun-types": "^1.4.3",
172
- "evlog": "2.33.1",
173
- "happy-dom": "20.14.5",
171
+ "bun-types": "^1.4.5",
172
+ "evlog": "2.37.1",
173
+ "happy-dom": "21.0.4",
174
174
  "miniflare": "4.20260730.0",
175
175
  "nitro": "^3.0.261103-rc",
176
176
  "publint": "^0.3.25",
177
- "stripe": "23.1.0",
177
+ "stripe": "23.2.0",
178
178
  "typescript": "^6.0.3",
179
- "undici": "8.12.2",
180
- "vite": "^8.2.2",
181
- "vite-plus": "^0.3.3",
182
- "vitest": "^4.1.11",
183
- "vue": "3.5.44",
184
- "drizzle-kit": "1.0.0-rc.5",
185
- "drizzle-orm": "1.0.0-rc.5"
179
+ "undici": "8.13.1",
180
+ "vite": "^8.3.8",
181
+ "vite-plus": "^1.7.0",
182
+ "vitest": "5.1.0",
183
+ "vue": "3.5.46",
184
+ "drizzle-kit": "1.0.0-rc.6",
185
+ "drizzle-orm": "1.0.0-rc.6",
186
+ "postgres": "^3.4.9"
186
187
  },
187
188
  "peerDependencies": {
188
- "@better-auth/oauth-provider": "^1.7.15",
189
+ "@better-auth/oauth-provider": "^1.7.27",
189
190
  "@types/json-schema": "^7.0.15",
190
191
  "@types/mdast": "^4.0.4",
191
- "@vite-hub/agent": "0.5.0",
192
- "@vite-hub/database": "0.5.0",
192
+ "@vite-hub/agent": "0.6.0",
193
+ "@vite-hub/database": "0.6.0",
193
194
  "nitro": "3.0.261102-rc || ^3.0.261103-rc",
194
195
  "vite": ">=8.0.0",
195
196
  "vue": "^3.5.0",
196
- "drizzle-orm": "1.0.0-rc.5 || ^1.0.0"
197
+ "drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0"
197
198
  },
198
199
  "peerDependenciesMeta": {
199
200
  "@better-auth/oauth-provider": {