@vite-hub/auth 0.1.0 → 0.3.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 +333 -49
  2. package/dist/abilities-DfAnFYwG.d.ts +93 -0
  3. package/dist/abilities.d.ts +2 -0
  4. package/dist/abilities.js +43 -0
  5. package/dist/ability-error-CqgBrBfR.js +91 -0
  6. package/dist/ability-error-DcgChwCN.d.ts +34 -0
  7. package/dist/admin-claim-code-CDipqeAU.js +22 -0
  8. package/dist/agent.d.ts +5 -5
  9. package/dist/agent.js +17 -9
  10. package/dist/application-path-DuTpfGFj.js +62 -0
  11. package/dist/auth-instance-CR6b1W80.js +1168 -0
  12. package/dist/bun-sqlite.d.ts +8 -0
  13. package/dist/cli-ubYJpAL_.d.ts +163 -0
  14. package/dist/cli.d.ts +1 -1
  15. package/dist/cli.js +47 -7
  16. package/dist/console-runtime-DTopBP-x.d.ts +71 -0
  17. package/dist/console-runtime-J9_Vx9pT.js +1166 -0
  18. package/dist/console-runtime.d.ts +3 -3
  19. package/dist/console-runtime.js +2 -819
  20. package/dist/console.d.ts +215 -3
  21. package/dist/console.js +1 -1
  22. package/dist/database-options-BRNef9oy.js +29 -0
  23. package/dist/database-schema-options-ENuRMduM.js +12 -0
  24. package/dist/database.d.ts +12 -0
  25. package/dist/database.js +45 -0
  26. package/dist/definition-CqQMcDEK.js +280 -0
  27. package/dist/error-diagnostics-C8XtVz0i.js +138 -0
  28. package/dist/{events-P7mI4IQb.js → events-ByzenEVj.js} +122 -4
  29. package/dist/forward.d.ts +50 -0
  30. package/dist/forward.js +120 -0
  31. package/dist/host-declarations.d.ts +2 -1
  32. package/dist/index.d.ts +24 -3
  33. package/dist/index.js +3 -102
  34. package/dist/internal/server.d.ts +5 -0
  35. package/dist/internal/server.js +858 -0
  36. package/dist/invariant-D8_xBqmZ.js +22 -0
  37. package/dist/mcp.d.ts +187 -0
  38. package/dist/mcp.js +353 -0
  39. package/dist/members-D9lfaEO_.js +533 -0
  40. package/dist/nuxt-bridge-Cl988STZ.js +44 -0
  41. package/dist/nuxt.d.ts +13 -5
  42. package/dist/nuxt.js +90 -13
  43. package/dist/object-Da1zyPCR.js +11 -0
  44. package/dist/page-tools-shared-l4eyj53D.js +19 -0
  45. package/dist/presets.js +1 -1
  46. package/dist/request-z6DHHmrb.js +47 -0
  47. package/dist/runtime/console.d.ts +3 -7
  48. package/dist/runtime/console.js +4 -42
  49. package/dist/runtime/empty-abilities.d.ts +5 -0
  50. package/dist/runtime/empty-abilities.js +4 -0
  51. package/dist/runtime/empty-client.d.ts +6 -0
  52. package/dist/runtime/empty-client.js +5 -0
  53. package/dist/runtime/empty-definition.d.ts +1 -1
  54. package/dist/runtime/nuxt.js +1 -1
  55. package/dist/runtime/server.d.ts +2 -0
  56. package/dist/runtime/server.js +77 -0
  57. package/dist/runtime/vue-nuxt.d.ts +3 -2
  58. package/dist/runtime/vue-nuxt.js +157 -5
  59. package/dist/runtime-state-ojQCzKOc.js +25 -0
  60. package/dist/schema.d.ts +137 -0
  61. package/dist/schema.js +147 -0
  62. package/dist/server-C0qnKN2W.d.ts +143 -0
  63. package/dist/server-bQGzVQ--.d.ts +41 -0
  64. package/dist/server.d.ts +3 -2
  65. package/dist/server.js +3 -3
  66. package/dist/session-cookies-BbH3UR2m.js +227 -0
  67. package/dist/{set-cookie-2as_DbHe.js → set-cookie-C8NOhdRE.js} +27 -12
  68. package/dist/{shared-DnpgYiLF.js → shared-BwcdRGxD.js} +2 -5
  69. package/dist/table-specs-8gq_FCaq.js +771 -0
  70. package/dist/table-specs-DbXyaXWs.d.ts +842 -0
  71. package/dist/test.d.ts +26 -0
  72. package/dist/test.js +25 -0
  73. package/dist/{events-BkmK2dFY.d.ts → types-CNaeH2Fd.d.ts} +240 -157
  74. package/dist/vite-CV400XXY.js +1556 -0
  75. package/dist/vite.d.ts +138 -20
  76. package/dist/vite.js +2 -2
  77. package/dist/vue.d.ts +330 -21
  78. package/dist/vue.js +583 -36
  79. package/package.json +84 -15
  80. package/dist/application-path-C290OAIs.js +0 -18
  81. package/dist/cli-mgXvsBtA.d.ts +0 -85
  82. package/dist/console-B7eERmGv.d.ts +0 -180
  83. package/dist/console-runtime-bZQtnX2Y.d.ts +0 -39
  84. package/dist/error-diagnostics-CL0yjHiM.js +0 -79
  85. package/dist/events-config-CjcFOhTE.js +0 -177
  86. package/dist/inspect-DPtsW8dB.d.ts +0 -36
  87. package/dist/server-B7LU19dS.js +0 -1730
  88. package/dist/server-CTD_JAww.d.ts +0 -77
  89. package/dist/vite-COWkwxsj.js +0 -990
package/dist/index.js CHANGED
@@ -1,102 +1,3 @@
1
- import { n as createDatabaseAuthEventStore, r as defaultAuthEventRetention, t as authEventTypes } from "./events-P7mI4IQb.js";
2
- import { t as authErrorDiagnostics } from "./error-diagnostics-CL0yjHiM.js";
3
- import { n as normalizeAuthBasePath } from "./shared-DnpgYiLF.js";
4
- import { n as applyAuthPreset, t as validateAuthEvents } from "./events-config-CjcFOhTE.js";
5
- //#region src/definition.ts
6
- const authRuntimeOptionNames = /* @__PURE__ */ new Set([
7
- "baseURL",
8
- "secret",
9
- "secrets"
10
- ]);
11
- const accessRouteKeys = /* @__PURE__ */ new Set([
12
- "authorize",
13
- "method",
14
- "route"
15
- ]);
16
- const databaseReferenceKeys = /* @__PURE__ */ new Set(["dedicated", "name"]);
17
- const secondaryStorageReferenceKeys = /* @__PURE__ */ new Set(["store"]);
18
- function isPlainObject(value) {
19
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
20
- }
21
- function validateNamedString(value, label) {
22
- if (typeof value !== "string" || value.trim().length === 0 || value !== value.trim()) throw authErrorDiagnostics.AUTH_C0020({ message: `\`defineAuth()\` ${label} must be a non-empty trimmed string.` });
23
- }
24
- function validateAuthDatabase(value) {
25
- if (typeof value === "undefined" || value === true) return;
26
- if (!isPlainObject(value)) throw authErrorDiagnostics.AUTH_C0021({ message: "`defineAuth()` database must be `true` or an inline object with `name`." });
27
- const unknownKey = Object.keys(value).find((key) => !databaseReferenceKeys.has(key));
28
- if (unknownKey) throw authErrorDiagnostics.AUTH_C0022({ message: `\`defineAuth()\` database does not support the "${unknownKey}" option.` });
29
- validateNamedString(Object.hasOwn(value, "name") ? value.name : void 0, "database.name");
30
- if (Object.hasOwn(value, "dedicated") && typeof value.dedicated !== "undefined" && typeof value.dedicated !== "boolean") throw authErrorDiagnostics.AUTH_C0023({ message: "`defineAuth()` database.dedicated must be a boolean." });
31
- }
32
- function validateAuthSecondaryStorage(value) {
33
- if (typeof value === "undefined" || value === true) return;
34
- if (!isPlainObject(value)) throw authErrorDiagnostics.AUTH_C0024({ message: "`defineAuth()` secondaryStorage must be `true` or an inline object with `store`." });
35
- const unknownKey = Object.keys(value).find((key) => !secondaryStorageReferenceKeys.has(key));
36
- if (unknownKey) throw authErrorDiagnostics.AUTH_C0025({ message: `\`defineAuth()\` secondaryStorage does not support the "${unknownKey}" option.` });
37
- validateNamedString(Object.hasOwn(value, "store") ? value.store : void 0, "secondaryStorage.store");
38
- }
39
- function validateStringValue(value, label) {
40
- if (typeof value !== "string" || value.trim().length === 0) throw authErrorDiagnostics.AUTH_C0026({ message: `\`defineAuth()\` ${label} must be a non-empty string.` });
41
- }
42
- function validateRouteValue(value, label) {
43
- validateStringValue(value, label);
44
- if (typeof value === "string" && !value.startsWith("/")) throw authErrorDiagnostics.AUTH_C0027({ message: `\`defineAuth()\` ${label} must start with \`/\`.` });
45
- }
46
- function validateAuthSignIn(value) {
47
- if (typeof value === "undefined") return;
48
- if (!isPlainObject(value)) throw authErrorDiagnostics.AUTH_C0028({ message: "`defineAuth()` access.signIn must be an object." });
49
- validateStringValue(value.provider, "access.signIn.provider");
50
- if (typeof value.callbackURL !== "undefined") validateStringValue(value.callbackURL, "access.signIn.callbackURL");
51
- if (typeof value.errorCallbackURL !== "undefined") validateStringValue(value.errorCallbackURL, "access.signIn.errorCallbackURL");
52
- if (typeof value.requestSignUp !== "undefined" && typeof value.requestSignUp !== "boolean") throw authErrorDiagnostics.AUTH_C0029({ message: "`defineAuth()` access.signIn.requestSignUp must be a boolean." });
53
- if (typeof value.scopes !== "undefined" && (!Array.isArray(value.scopes) || value.scopes.some((scope) => typeof scope !== "string"))) throw authErrorDiagnostics.AUTH_C0030({ message: "`defineAuth()` access.signIn.scopes must be an array of strings." });
54
- }
55
- function validateAuthAccessRoute(value, label) {
56
- if (typeof value === "string") {
57
- validateRouteValue(value, label);
58
- return;
59
- }
60
- if (!isPlainObject(value)) throw authErrorDiagnostics.AUTH_C0031({ message: `\`defineAuth()\` ${label} must be a route string or route object.` });
61
- const unknownKey = Object.keys(value).find((key) => !accessRouteKeys.has(key));
62
- if (unknownKey) throw authErrorDiagnostics.AUTH_C0032({ message: `\`defineAuth()\` ${label} does not support the "${unknownKey}" option.` });
63
- validateRouteValue(value.route, `${label}.route`);
64
- if (typeof value.authorize !== "undefined" && typeof value.authorize !== "function") throw authErrorDiagnostics.AUTH_C0033({ message: `\`defineAuth()\` ${label}.authorize must be a function.` });
65
- if (typeof value.method !== "undefined") validateStringValue(value.method, `${label}.method`);
66
- }
67
- function validateAuthAccess(value) {
68
- if (typeof value === "undefined") return;
69
- if (!isPlainObject(value)) throw authErrorDiagnostics.AUTH_C0034({ message: "`defineAuth()` access must be an object." });
70
- const access = value;
71
- if (typeof access.routes !== "undefined") {
72
- if (!Array.isArray(access.routes)) throw authErrorDiagnostics.AUTH_C0035({ message: "`defineAuth()` access.routes must be an array." });
73
- access.routes.forEach((route, index) => validateAuthAccessRoute(route, `access.routes[${index}]`));
74
- }
75
- validateAuthSignIn(access.signIn);
76
- }
77
- function defineAuth(options) {
78
- return defineAuthOptions(options);
79
- }
80
- function defineAuthOptions(options) {
81
- if (typeof options === "function") return { options };
82
- if (!isPlainObject(options)) throw authErrorDiagnostics.AUTH_C0036({ message: "`defineAuth()` expects an object or a callback." });
83
- const viteHubOptions = options;
84
- const runtimeOption = Object.keys(options).find((key) => authRuntimeOptionNames.has(key));
85
- if (runtimeOption) throw authErrorDiagnostics.AUTH_C0037({ message: `\`defineAuth()\` ${runtimeOption} is resolved at runtime and cannot be defined in the Auth Definition.` });
86
- if (typeof viteHubOptions.route !== "undefined" && viteHubOptions.route !== false) throw authErrorDiagnostics.AUTH_C0038({ message: "`defineAuth()` route can only be `false` when provided." });
87
- if (typeof viteHubOptions.runtime !== "undefined" && typeof viteHubOptions.runtime !== "function" && !isPlainObject(viteHubOptions.runtime)) throw authErrorDiagnostics.AUTH_C0039({ message: "`defineAuth()` runtime must be an object or a function." });
88
- if (typeof viteHubOptions.basePath !== "undefined") {
89
- if (typeof viteHubOptions.basePath !== "string") throw authErrorDiagnostics.AUTH_C0040({ message: "`defineAuth()` basePath must be a string." });
90
- normalizeAuthBasePath(viteHubOptions.basePath);
91
- }
92
- const session = options.session;
93
- if (isPlainObject(session) && typeof session.onRefresh !== "undefined" && typeof session.onRefresh !== "function") throw authErrorDiagnostics.AUTH_C0041({ message: "`defineAuth()` session.onRefresh must be a function." });
94
- validateAuthEvents(options.events);
95
- validateAuthDatabase(viteHubOptions.database);
96
- validateAuthSecondaryStorage(viteHubOptions.secondaryStorage);
97
- validateAuthAccess(viteHubOptions.access);
98
- applyAuthPreset(options);
99
- return { options };
100
- }
101
- //#endregion
102
- export { authEventTypes, createDatabaseAuthEventStore, defaultAuthEventRetention, defineAuth };
1
+ import { a as checkGitHubOrgMember, n as defaultAuthEventRetention, o as isGitHubOrgMember, t as createDatabaseAuthEventStore } from "./events-ByzenEVj.js";
2
+ import { n as defineAuth } from "./definition-CqQMcDEK.js";
3
+ export { checkGitHubOrgMember, createDatabaseAuthEventStore, defaultAuthEventRetention, defineAuth, isGitHubOrgMember };
@@ -0,0 +1,5 @@
1
+ /// <reference path="../host-declarations.d.ts" />
2
+ import { A as createBetterAuthOptions, C as signOut, D as withAuth, E as withAnonymousAuthorization, O as withAuthorization, S as requireAuthorization, T as useAuth, _ as handleAuthRequest, a as authRoute, b as requireAuth, c as createAuth, d as createAuthHandler, f as createAuthRequestRuntimeOptions, g as handleAuth, h as getAuthEvents, i as auth, j as getAuthForDefinition, l as createAuthAccessHandler, m as getAuthConsoleForRequest, n as aggregateAuthEvents, o as can, p as getAuth, r as assertAuthOrigin, s as checkAuthMember, t as AuthSignOutOptions, u as createAuthForRequest, v as listAuthEvents, w as toAuthRequest, x as requireAuthAccessRoutes, y as requireAbility } from "../server-C0qnKN2W.js";
3
+ import { a as setAuthAccessIdentityResolver, o as setAuthRuntimeEnvResolver, s as resetAuth } from "../server-bQGzVQ--.js";
4
+ import { n as AbilityErrorData, t as AbilityError } from "../ability-error-DcgChwCN.js";
5
+ export { AbilityError, type AbilityErrorData, AuthSignOutOptions, aggregateAuthEvents, assertAuthOrigin, auth, can, checkAuthMember, createAuth, createAuthAccessHandler, createAuthForRequest, createAuthHandler, createAuthRequestRuntimeOptions, createBetterAuthOptions, authRoute as default, getAuth, getAuthConsoleForRequest, getAuthEvents, getAuthForDefinition, handleAuth, handleAuthRequest, listAuthEvents, requireAbility, requireAuth, requireAuthAccessRoutes, requireAuthorization, resetAuth, setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver, signOut, toAuthRequest, useAuth, withAnonymousAuthorization, withAuth, withAuthorization };