@vite-hub/auth 0.5.1 → 0.6.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 (72) hide show
  1. package/README.md +2 -2
  2. package/dist/{abilities-3L1Y5Pnw.d.ts → abilities-BYOcyQ9B.d.ts} +1 -1
  3. package/dist/abilities.d.ts +1 -1
  4. package/dist/{ability-error-BHhPkrZd.js → ability-error-D3-u8k1A.js} +1 -1
  5. package/dist/{access-pages-BwImVHN_.js → access-pages-9aKr6z-k.js} +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/{auth-instance-_J7R9Qs1.js → auth-instance-BWiRS9QZ.js} +73 -82
  8. package/dist/cli.js +1 -1
  9. package/dist/client-request-BzMKtfCY.js +52 -0
  10. package/dist/{console-runtime-vc3JQEuq.js → console-runtime-CaIXVtB_.js} +7 -206
  11. package/dist/console-runtime-DMH1I2fl.d.ts +32 -0
  12. package/dist/console-runtime.d.ts +3 -3
  13. package/dist/console-runtime.js +1 -1
  14. package/dist/{console-types-51lkf0lk.js → console-types-NrX5TWl3.js} +2 -1
  15. package/dist/console.d.ts +3 -3
  16. package/dist/console.js +1 -1
  17. package/dist/{database-options-DQ-8qYMl.js → database-options-B87hDU4j.js} +1 -1
  18. package/dist/{database-schema-options-CkSeU9V3.js → database-schema-options-peXHNLkJ.js} +1 -1
  19. package/dist/database.d.ts +2 -2
  20. package/dist/database.js +5 -5
  21. package/dist/{definition-MDGMNKrK.js → definition-BypPLIbI.js} +3 -3
  22. package/dist/{error-diagnostics-BssJr_2t.js → error-diagnostics-CUPwukgE.js} +1 -1
  23. package/dist/{events-DZqMiae_.js → events-BXU1_9mc.js} +2 -1
  24. package/dist/forward-sign-ins-BWXPPTRz.js +4 -0
  25. package/dist/forward.d.ts +24 -0
  26. package/dist/forward.js +42 -4
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +3 -3
  29. package/dist/internal/server.d.ts +2 -2
  30. package/dist/internal/server.js +4 -4
  31. package/dist/mcp-token-CmQbXbTu.d.ts +125 -0
  32. package/dist/{mcp-token--KuLYEub.js → mcp-token-CuqdbBy8.js} +45 -18
  33. package/dist/mcp.d.ts +2 -111
  34. package/dist/mcp.js +5 -3
  35. package/dist/{members-D3_Q5XJb.js → members-CwPIx10t.js} +3 -3
  36. package/dist/{nitro-kit-Bg4xUZAI.js → nitro-kit-BumWIKa5.js} +1 -1
  37. package/dist/nuxt.d.ts +1 -1
  38. package/dist/nuxt.js +3 -3
  39. package/dist/{own-access-C22hSIuF.d.ts → own-access-BNcxKrDl.d.ts} +1 -1
  40. package/dist/{own-access-DQgqxTbI.js → own-access-CYsakJiH.js} +1 -1
  41. package/dist/presets.js +1 -1
  42. package/dist/runtime/client-request-plugin.d.ts +1 -0
  43. package/dist/runtime/client-request-plugin.js +18 -0
  44. package/dist/runtime/console.d.ts +1 -1
  45. package/dist/runtime/console.js +2 -2
  46. package/dist/runtime/empty-abilities.d.ts +1 -1
  47. package/dist/runtime/empty-definition.d.ts +1 -1
  48. package/dist/runtime/server.d.ts +2 -2
  49. package/dist/runtime/server.js +3 -3
  50. package/dist/runtime-state-C0Rd1W4m.js +15 -0
  51. package/dist/schema.d.ts +1 -1
  52. package/dist/schema.js +1 -1
  53. package/dist/{server-DCsgxFPP.d.ts → server-BHniJi2m.d.ts} +2 -2
  54. package/dist/{server-CFWlYQJb.d.ts → server-C4Kni3Vj.d.ts} +13 -8
  55. package/dist/{server-D4Hi4TBI.js → server-Iru6jcnW.js} +13 -12
  56. package/dist/server.d.ts +3 -2
  57. package/dist/server.js +2 -2
  58. package/dist/{session-cookies-1FMcMnRh.js → session-cookies-fR6Pv4kD.js} +2 -2
  59. package/dist/{set-cookie-DkqM1kvj.js → set-cookie-DVfi-nJX.js} +1 -1
  60. package/dist/{table-specs-jw0jjU6l.js → table-specs-CCSY4tiS.js} +17 -14
  61. package/dist/{table-specs-BLm_Zlss.d.ts → table-specs-P4LvbOlX.d.ts} +28 -21
  62. package/dist/test.d.ts +1 -1
  63. package/dist/test.js +2 -2
  64. package/dist/{types-BHSgxyvV.d.ts → types-DmH31d2t.d.ts} +8 -21
  65. package/dist/{vite-D1xC9n1O.js → vite-CpWhT1Wi.js} +93 -27
  66. package/dist/vite.d.ts +1 -1
  67. package/dist/vite.js +1 -1
  68. package/dist/vue.d.ts +2 -2
  69. package/dist/vue.js +1 -1
  70. package/package.json +8 -8
  71. package/dist/console-runtime-BP1ZKJB0.d.ts +0 -71
  72. package/dist/runtime-state-DtKUfxKq.js +0 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/auth",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "Better Auth-powered authentication primitives and Vite integration for ViteHub.",
5
5
  "keywords": [
6
6
  "auth",
@@ -144,9 +144,9 @@
144
144
  "dependencies": {
145
145
  "@noble/hashes": "^2.4.0",
146
146
  "@types/node": "^24.19.2",
147
- "@vite-hub/env": "0.5.1",
148
- "@vite-hub/runtime": "0.5.1",
149
- "@vite-hub/web-container": "0.5.1",
147
+ "@vite-hub/env": "0.6.1",
148
+ "@vite-hub/runtime": "0.6.1",
149
+ "@vite-hub/web-container": "0.6.1",
150
150
  "better-auth": "^1.7.27",
151
151
  "h3": "^2.0.8",
152
152
  "nostics": "1.4.0",
@@ -165,8 +165,8 @@
165
165
  "@types/json-schema": "^7.0.15",
166
166
  "@types/mdast": "^4.0.4",
167
167
  "@types/node": "^24.19.2",
168
- "@vite-hub/agent": "0.5.1",
169
- "@vite-hub/database": "0.5.1",
168
+ "@vite-hub/agent": "0.6.1",
169
+ "@vite-hub/database": "0.6.1",
170
170
  "@vite-hub/internal": "0.0.1",
171
171
  "bun-types": "^1.4.5",
172
172
  "evlog": "2.37.1",
@@ -189,8 +189,8 @@
189
189
  "@better-auth/oauth-provider": "^1.7.27",
190
190
  "@types/json-schema": "^7.0.15",
191
191
  "@types/mdast": "^4.0.4",
192
- "@vite-hub/agent": "0.5.1",
193
- "@vite-hub/database": "0.5.1",
192
+ "@vite-hub/agent": "0.6.1",
193
+ "@vite-hub/database": "0.6.1",
194
194
  "nitro": "3.0.261102-rc || ^3.0.261103-rc",
195
195
  "vite": ">=8.0.0",
196
196
  "vue": "^3.5.0",
@@ -1,71 +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-BHSgxyvV.js";
2
- import { Result } from "@vite-hub/runtime";
3
- import { AuthContext, BetterAuthOptions, DBAdapter } from "better-auth";
4
- interface AuthConsole {
5
- describe(request?: Request): Promise<Result<AuthConsoleDescription, AuthConsoleErrorCode>>;
6
- overview(): Promise<Result<AuthConsoleOverview, AuthConsoleErrorCode>>;
7
- activity(query?: AuthConsoleActivityQuery): Promise<Result<AuthConsoleActivity, AuthConsoleErrorCode>>;
8
- users(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleUser>, AuthConsoleErrorCode>>;
9
- /** With `request`, the impersonation target check also counts the `impersonate-admins` permission of its session. */
10
- user(id: string, request?: Request): Promise<Result<AuthConsoleUserDetail, AuthConsoleErrorCode>>;
11
- sessions(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleSession>, AuthConsoleErrorCode>>;
12
- organizations(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleOrganization>, AuthConsoleErrorCode>>;
13
- organization(id: string, query?: AuthConsoleQuery): Promise<Result<AuthConsoleOrganizationDetail, AuthConsoleErrorCode>>;
14
- agents(query?: AuthConsoleQuery): Promise<Result<AuthConsoleList<AuthConsoleAgent>, AuthConsoleErrorCode>>;
15
- execute(input: AuthConsoleMutation, request: Request): Promise<Result<Response, AuthConsoleErrorCode>>;
16
- /** End the impersonation of the request's app session and restore the administrator's session cookies. */
17
- stopImpersonating(request: Request): Promise<Result<Response, AuthConsoleErrorCode>>;
18
- /** The app session of the request's cookies, read from the database, or `null` without one. */
19
- session(request: Request): Promise<Result<AuthConsoleSessionUser | null, AuthConsoleErrorCode>>;
20
- /**
21
- * Keep a one-time value in Better Auth's verification table until `expiresAt`. Hosts use it for values that must
22
- * work once on every instance, such as Console tickets. Needs a database adapter.
23
- */
24
- saveVerification(identifier: string, value: string, expiresAt: Date): Promise<Result<void, AuthConsoleErrorCode>>;
25
- /** Take a value that `saveVerification()` kept. Of two calls at the same time, one gets it. `null` when it is gone or expired. */
26
- consumeVerification(identifier: string): Promise<Result<string | null, AuthConsoleErrorCode>>;
27
- /** 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. */
28
- listVerifications(prefix: string): Promise<Result<{
29
- identifier: string;
30
- value: string;
31
- expiresAt: Date;
32
- }[], AuthConsoleErrorCode>>;
33
- /** Delete a kept value. Deleting a value that is gone does nothing. */
34
- deleteVerification(identifier: string): Promise<Result<void, AuthConsoleErrorCode>>;
35
- /**
36
- * The user that a host signs in without a password, such as a Console member or a guest that a member invited, with
37
- * `roles` added to the comma-separated `user.role`. With `email`, an existing user with that verified email keeps
38
- * their account and gets the roles, and an unverified one is refused; without it, a new user gets a placeholder email.
39
- * Needs a database and a `user.role` field that users cannot set: `authDatabase()` and `admin()` add one. Better Auth
40
- * runs the app's `databaseHooks.user.create` for a new user.
41
- */
42
- hostUser(input: AuthConsoleHostUserInput): Promise<Result<{
43
- id: string;
44
- roles: string[];
45
- }, AuthConsoleErrorCode>>;
46
- /**
47
- * Check the Auth configuration without writing: a database and a `user.role` field that users cannot set and that
48
- * sessions return. `hostUser()` and `hostSession()` still check the account and session when the link is redeemed.
49
- */
50
- checkHost(): Promise<Result<void, AuthConsoleErrorCode>>;
51
- /** Start a Better Auth session for a user, and return the `Set-Cookie` headers that sign the browser in. */
52
- hostSession(userId: string, request: Request): Promise<Result<Headers, AuthConsoleErrorCode>>;
53
- /** Live sessions matching `roles`, newest first. `guest` matches only users created as guests by the host. */
54
- hostSessions(roles: readonly string[]): Promise<Result<AuthConsoleHostSession[], AuthConsoleErrorCode>>;
55
- /** End one session and delete its user only if the host created it as a guest. */
56
- revokeHostSession(id: string): Promise<Result<{
57
- removedUser: boolean;
58
- }, AuthConsoleErrorCode>>;
59
- }
60
- type ConsoleAdapter = Pick<DBAdapter, "findMany" | "findOne" | "count">;
61
- type AuthConsoleErrorCode = "AUTH_CONSOLE_INVALID_REQUEST" | "AUTH_CONSOLE_FORBIDDEN" | "AUTH_CONSOLE_NOT_FOUND" | "AUTH_CONSOLE_UNAVAILABLE" | "AUTH_CONSOLE_PROVIDER_FAILED";
62
- /** Only additional fields that Better Auth allows in output reach the Console. */
63
- declare function describeAuthConsoleFields(options: BetterAuthOptions, policy?: AuthConsoleOptions): AuthConsoleField[];
64
- declare function createAuthConsole(auth: {
65
- api: object;
66
- $context: Promise<{
67
- adapter: ConsoleAdapter;
68
- options: BetterAuthOptions;
69
- } & Partial<Pick<AuthContext, "authCookies" | "internalAdapter" | "secret" | "sessionConfig">>>;
70
- }, policy?: AuthConsoleOptions, events?: AuthEventStore, host?: AuthConsoleHostOptions): AuthConsole;
71
- export { describeAuthConsoleFields as i, AuthConsoleErrorCode as n, createAuthConsole as r, AuthConsole as t };
@@ -1,24 +0,0 @@
1
- // 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
- export { resetAuth as i, getAuthRuntimeState as n, isAuthProcessMemoryDatabase as r, authProcessMemoryDatabase as t };