@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,73 +0,0 @@
1
- import { J as AuthConsoleAgent, K as AuthConsoleActivity, Lt as AuthEventStore, Z as AuthConsoleDescription, at as AuthConsoleHostSession, bt as AuthConsoleUser, ct as AuthConsoleList, dt as AuthConsoleOrganization, ft as AuthConsoleOrganizationDetail, gt as AuthConsoleQuery, it as AuthConsoleHostOptions, lt as AuthConsoleMutation, ot as AuthConsoleHostUserInput, pt as AuthConsoleOverview, q as AuthConsoleActivityQuery, tt as AuthConsoleField, ut as AuthConsoleOptions, vt as AuthConsoleSession, xt as AuthConsoleUserDetail, yt as AuthConsoleSessionUser } from "./types-gl-myjZc.js";
2
- import { Result } from "@vite-hub/runtime";
3
- import { AuthContext, BetterAuthOptions, DBAdapter } from "better-auth";
4
- //#region src/console-runtime.d.ts
5
- interface AuthConsole {
6
- describe(request?: Request): Promise<Result<AuthConsoleDescription, AuthConsoleErrorCode>>;
7
- overview(): Promise<Result<AuthConsoleOverview, AuthConsoleErrorCode>>;
8
- activity(query?: AuthConsoleActivityQuery): Promise<Result<AuthConsoleActivity, AuthConsoleErrorCode>>;
9
- users(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleUser>, AuthConsoleErrorCode>>;
10
- /** With `request`, the impersonation target check also counts the `impersonate-admins` permission of its session. */
11
- user(id: string, request?: Request): Promise<Result<AuthConsoleUserDetail, AuthConsoleErrorCode>>;
12
- sessions(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleSession>, AuthConsoleErrorCode>>;
13
- organizations(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleOrganization>, AuthConsoleErrorCode>>;
14
- organization(id: string, query?: AuthConsoleQuery): Promise<Result<AuthConsoleOrganizationDetail, AuthConsoleErrorCode>>;
15
- agents(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleAgent>, AuthConsoleErrorCode>>;
16
- execute(input: AuthConsoleMutation, request: Request): Promise<Result<Response, AuthConsoleErrorCode>>;
17
- /** End the impersonation of the request's app session and restore the administrator's session cookies. */
18
- stopImpersonating(request: Request): Promise<Result<Response, AuthConsoleErrorCode>>;
19
- /** The app session of the request's cookies, read from the database, or `null` without one. */
20
- session(request: Request): Promise<Result<AuthConsoleSessionUser | null, AuthConsoleErrorCode>>;
21
- /**
22
- * Keep a one-time value in Better Auth's verification table until `expiresAt`. Hosts use it for values that must
23
- * work once on every instance, such as Console tickets. Needs a database adapter.
24
- */
25
- saveVerification(identifier: string, value: string, expiresAt: Date): Promise<Result<void, AuthConsoleErrorCode>>;
26
- /** Take a value that `saveVerification()` kept. Of two calls at the same time, one gets it. `null` when it is gone or expired. */
27
- consumeVerification(identifier: string): Promise<Result<string | null, AuthConsoleErrorCode>>;
28
- /** The live values whose identifier starts with `prefix`, at most 1,000. Hosts use it for values that a person lists, such as Console invites. */
29
- listVerifications(prefix: string): Promise<Result<{
30
- identifier: string;
31
- value: string;
32
- expiresAt: Date;
33
- }[], AuthConsoleErrorCode>>;
34
- /** Delete a kept value. Deleting a value that is gone does nothing. */
35
- deleteVerification(identifier: string): Promise<Result<void, AuthConsoleErrorCode>>;
36
- /**
37
- * The user that a host signs in without a password, such as a Console member or a guest that a member invited, with
38
- * `roles` added to the comma-separated `user.role`. With `email`, an existing user with that verified email keeps
39
- * their account and gets the roles, and an unverified one is refused; without it, a new user gets a placeholder email.
40
- * Needs a database and a `user.role` field that users cannot set: `authDatabase()` and `admin()` add one. Better Auth
41
- * runs the app's `databaseHooks.user.create` for a new user.
42
- */
43
- hostUser(input: AuthConsoleHostUserInput): Promise<Result<{
44
- id: string;
45
- roles: string[];
46
- }, AuthConsoleErrorCode>>;
47
- /**
48
- * Check the Auth configuration without writing: a database and a `user.role` field that users cannot set and that
49
- * sessions return. `hostUser()` and `hostSession()` still check the account and session when the link is redeemed.
50
- */
51
- checkHost(): Promise<Result<void, AuthConsoleErrorCode>>;
52
- /** Start a Better Auth session for a user, and return the `Set-Cookie` headers that sign the browser in. */
53
- hostSession(userId: string, request: Request): Promise<Result<Headers, AuthConsoleErrorCode>>;
54
- /** Live sessions matching `roles`, newest first. `guest` matches only users created as guests by the host. */
55
- hostSessions(roles: readonly string[]): Promise<Result<AuthConsoleHostSession[], AuthConsoleErrorCode>>;
56
- /** End one session and delete its user only if the host created it as a guest. */
57
- revokeHostSession(id: string): Promise<Result<{
58
- removedUser: boolean;
59
- }, AuthConsoleErrorCode>>;
60
- }
61
- type ConsoleAdapter = Pick<DBAdapter, "findMany" | "findOne" | "count">;
62
- type AuthConsoleErrorCode = "AUTH_CONSOLE_INVALID_REQUEST" | "AUTH_CONSOLE_FORBIDDEN" | "AUTH_CONSOLE_NOT_FOUND" | "AUTH_CONSOLE_UNAVAILABLE" | "AUTH_CONSOLE_PROVIDER_FAILED";
63
- /** Only additional fields that Better Auth allows in output reach the Console. */
64
- declare function describeAuthConsoleFields(options: BetterAuthOptions, policy?: AuthConsoleOptions): AuthConsoleField[];
65
- declare function createAuthConsole(auth: {
66
- api: object;
67
- $context: Promise<{
68
- adapter: ConsoleAdapter;
69
- options: BetterAuthOptions;
70
- } & Partial<Pick<AuthContext, "authCookies" | "internalAdapter" | "secret" | "sessionConfig">>>;
71
- }, policy?: AuthConsoleOptions, events?: AuthEventStore, host?: AuthConsoleHostOptions): AuthConsole;
72
- //#endregion
73
- export { describeAuthConsoleFields as i, AuthConsoleErrorCode as n, createAuthConsole as r, AuthConsole as t };
@@ -1,25 +0,0 @@
1
- //#region src/runtime-state.ts
2
- const authRuntimeStateKey = Symbol.for("vitehub.auth.runtime");
3
- /**
4
- * Marks the database that Auth adds to a Definition without one. It keeps rows in the memory of one process, so a value
5
- * that another instance must see, such as a one-time ticket, cannot live there.
6
- */
7
- const authProcessMemoryDatabase = Symbol.for("vitehub.auth.processMemoryDatabase");
8
- /** Whether a Better Auth `database` option is the process memory database that Auth adds. */
9
- function isAuthProcessMemoryDatabase(database) {
10
- return database instanceof Object && Reflect.get(database, authProcessMemoryDatabase) === true;
11
- }
12
- function getAuthRuntimeState() {
13
- const globalScope = globalThis;
14
- globalScope[authRuntimeStateKey] ??= {};
15
- globalScope[authRuntimeStateKey].envResolvers ??= /* @__PURE__ */ new WeakMap();
16
- return globalScope[authRuntimeStateKey];
17
- }
18
- function resetAuth() {
19
- const state = getAuthRuntimeState();
20
- state.auth = void 0;
21
- state.definition = void 0;
22
- state.providers = void 0;
23
- }
24
- //#endregion
25
- export { resetAuth as i, getAuthRuntimeState as n, isAuthProcessMemoryDatabase as r, authProcessMemoryDatabase as t };