@vite-hub/auth 0.4.0 → 0.5.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.
- package/README.md +31 -7
- package/dist/{abilities-CbmTAoS_.d.ts → abilities-9jC7iuN0.d.ts} +2 -2
- package/dist/abilities.d.ts +1 -1
- package/dist/{ability-error-DcgChwCN.d.ts → ability-error-DUWJ6Q1W.d.ts} +1 -1
- package/dist/{ability-error-IeZQBr_-.js → ability-error-DmnUGicq.js} +1 -1
- package/dist/access-pages-FNQTyGRD.js +96 -0
- package/dist/agent.js +3 -3
- package/dist/{auth-instance-CmDogt4D.js → auth-instance-zYMjldPG.js} +227 -25
- package/dist/{cli-ubYJpAL_.d.ts → cli-NCtitmny.d.ts} +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/{console-runtime-_LrpyCYY.js → console-runtime-CuXRDhGy.js} +67 -33
- package/dist/{console-runtime-D2ai-Et5.d.ts → console-runtime-Dqidb3zF.d.ts} +13 -11
- package/dist/console-runtime.d.ts +2 -2
- package/dist/console-runtime.js +1 -1
- package/dist/console.d.ts +1 -1
- package/dist/{database-options-DpOVjUti.js → database-options-CcjUG-us.js} +1 -1
- package/dist/{database-schema-options-Sk-1Bvyu.js → database-schema-options-CTKCAfqW.js} +1 -1
- package/dist/database.d.ts +1 -1
- package/dist/database.js +4 -4
- package/dist/{definition-BCaLA9kW.js → definition-BFT9T6In.js} +12 -4
- package/dist/{error-diagnostics-Dymr-S_n.js → error-diagnostics-uEbxSY2G.js} +8 -2
- package/dist/{events-DCfuicoo.js → events-DJmO9a9I.js} +1 -1
- package/dist/forward.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -3
- package/dist/internal/server.d.ts +4 -4
- package/dist/internal/server.js +4 -4
- package/dist/{invariant-D8_xBqmZ.js → invariant-DolT9EEx.js} +1 -1
- package/dist/{mcp-token-CpxLyl_p.js → mcp-token-BhonlK9C.js} +2 -2
- package/dist/mcp.js +1 -1
- package/dist/{members-DdlsS8kJ.js → members-Cl3hFRjk.js} +3 -3
- package/dist/nitro-kit-32CVgbWS.js +44 -0
- package/dist/nuxt.d.ts +32 -19
- package/dist/nuxt.js +337 -16
- package/dist/own-access-C8pwo_Kn.js +31 -0
- package/dist/own-access-CdgEICjO.d.ts +20 -0
- package/dist/presets.js +1 -1
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/empty-abilities.d.ts +1 -1
- package/dist/runtime/empty-definition.d.ts +1 -1
- package/dist/runtime/server.d.ts +3 -2
- package/dist/runtime/server.js +23 -14
- package/dist/runtime/vue-nuxt.js +70 -28
- package/dist/schema.d.ts +71 -19
- package/dist/schema.js +5 -3
- package/dist/{server-C8TlOrSy.d.ts → server-B-zNtSvm.d.ts} +9 -10
- package/dist/{server-BM-RSf1T.d.ts → server-Ci2i6p1S.d.ts} +7 -6
- package/dist/{server-BG_MFd4q.js → server-CyqLFm3L.js} +45 -25
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/{session-cookies-DVzjOKc7.js → session-cookies-CZmZS5QF.js} +2 -2
- package/dist/{set-cookie-DmqWq6kj.js → set-cookie-DWIyCCJO.js} +1 -1
- package/dist/{table-specs-DbXyaXWs.d.ts → table-specs-BhWz_U0M.d.ts} +255 -1
- package/dist/{table-specs-CURphR3n.js → table-specs-D0VLp1U4.js} +43 -43
- package/dist/test.d.ts +1 -1
- package/dist/test.js +2 -2
- package/dist/{types-CruflEFI.d.ts → types-gl-myjZc.d.ts} +51 -4
- package/dist/{vite-Dy0Xhq4H.js → vite-QKjsPLwP.js} +349 -120
- package/dist/vite.d.ts +6 -2
- package/dist/vite.js +1 -1
- package/dist/vue.d.ts +17 -68
- package/dist/vue.js +22 -69
- package/package.json +13 -9
- package/dist/shared-DRtfuFsV.js +0 -12
|
@@ -3,6 +3,7 @@ import "nostics";
|
|
|
3
3
|
interface HostCliRunResult {
|
|
4
4
|
exitCode: number | null;
|
|
5
5
|
stdout: string;
|
|
6
|
+
stderr?: string;
|
|
6
7
|
}
|
|
7
8
|
/** Runs a host CLI with an argument array and no shell, and returns its stdout. */
|
|
8
9
|
type HostCliRun = (command: string, args: readonly string[], options: {
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ViteHubCliContributor } from "./cli-
|
|
1
|
+
import { t as ViteHubCliContributor } from "./cli-NCtitmny.js";
|
|
2
2
|
//#region src/cli.d.ts
|
|
3
3
|
/** Read the app-owned, session-protected endpoint. No local or remote database credentials are needed. */
|
|
4
4
|
export declare function createAuthCliContributor(options?: {
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
|
|
2
2
|
import { n as adminClaimVariable, r as createAdminClaimCode, t as adminClaimHash } from "./admin-claim-code-CDipqeAU.js";
|
|
3
3
|
//#region src/cli.ts
|
|
4
4
|
const usage = "vitehub auth events --url <auth-base-url> [--type <type>] [--user <id>] [--actor <actor>] [--from <ISO>] [--to <ISO>] [--cursor <cursor>] [--limit <1-200>] [--aggregate]";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { n as adminClaimVariable } from "./admin-claim-code-CDipqeAU.js";
|
|
2
|
-
import { m as adminsVariable, p as adminsPluginId, r as membersVariable, s as accessPolicyPluginId, u as adminClaimPluginId } from "./members-
|
|
2
|
+
import { m as adminsVariable, p as adminsPluginId, r as membersVariable, s as accessPolicyPluginId, u as adminClaimPluginId } from "./members-Cl3hFRjk.js";
|
|
3
3
|
import { r as isAuthProcessMemoryDatabase } from "./runtime-state-ojQCzKOc.js";
|
|
4
|
-
import { r as parseAuthEventList } from "./events-
|
|
4
|
+
import { r as parseAuthEventList } from "./events-DJmO9a9I.js";
|
|
5
5
|
import { n as authConsoleEventGroups, t as authConsoleActionNames } from "./console-types-CmmnKGMx.js";
|
|
6
6
|
import { defineErrors } from "@vite-hub/runtime";
|
|
7
7
|
import { createAuthEndpoint } from "better-auth/api";
|
|
8
8
|
import { setSessionCookie } from "better-auth/cookies";
|
|
9
|
+
import { getAuthTables } from "better-auth/db";
|
|
9
10
|
import { defineGrant } from "@vite-hub/runtime/internal/grant";
|
|
10
11
|
//#region ../internal/src/runtime/user-agent.ts
|
|
11
12
|
/** A short device label of a browser, such as `Chrome · macOS`, for lists of sessions. It never shows the user agent itself. */
|
|
@@ -14,6 +15,7 @@ function userAgentDevice(userAgent) {
|
|
|
14
15
|
}
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/console-runtime.ts
|
|
18
|
+
const hostGuestProvider = "vitehub-site-guest";
|
|
17
19
|
const string = (value) => typeof value === "string" ? value : "";
|
|
18
20
|
const date = (value) => {
|
|
19
21
|
const parsed = value instanceof Date ? value : new Date(typeof value === "string" || typeof value === "number" ? value : NaN);
|
|
@@ -101,8 +103,8 @@ const errors = defineErrors({
|
|
|
101
103
|
fix: "Refresh the list and check the Auth Definition's plugins."
|
|
102
104
|
},
|
|
103
105
|
AUTH_CONSOLE_UNAVAILABLE: {
|
|
104
|
-
why: ({ detail }) => detail ?? "Auth does not have the database or plugin API
|
|
105
|
-
fix: "
|
|
106
|
+
why: ({ detail }) => detail ?? "Auth does not have the database, the `user.role` field, or the Better Auth plugin API that this operation needs.",
|
|
107
|
+
fix: "Set `database: authDatabase()` from `vite-hub/auth/database`, which also adds the `user.role` field that Site access needs. With your own adapter and schema, add a nullable `role` text column to the `user` table, apply the migration, and declare the field with `user: { additionalFields: { role: { type: \"string\", required: false, input: false } } }`. For a plugin operation, add the plugin. With a custom schema, add the plugin fields to your schema and apply the database migration before using the plugin. The default `admin()` fields are `user.role`, `user.banned`, `user.banReason`, `user.banExpires`, and `session.impersonatedBy`."
|
|
106
108
|
},
|
|
107
109
|
AUTH_CONSOLE_PROVIDER_FAILED: {
|
|
108
110
|
why: "Better Auth or an app column reader could not complete the operation.",
|
|
@@ -976,11 +978,14 @@ function createAuthConsole(auth, policy = {}, events, host = {}) {
|
|
|
976
978
|
if (!ctx.options.database || isAuthProcessMemoryDatabase(ctx.options.database) || !ctx.internalAdapter) throw authConsoleError(409, "One-time values need a Better Auth database adapter that every instance of the app shares.");
|
|
977
979
|
return ctx.internalAdapter;
|
|
978
980
|
}
|
|
979
|
-
/** The Better Auth context for host users and sessions: `
|
|
981
|
+
/** The Better Auth context for host users and sessions: the `user.role` field keeps the roles, a database keeps the rest. */
|
|
980
982
|
async function hostContext() {
|
|
981
983
|
const ctx = await context();
|
|
982
984
|
if (!ctx.options.database || !ctx.internalAdapter || !ctx.authCookies || !ctx.secret || !ctx.sessionConfig) throw authConsoleError(409, "Signing a browser in from the Console needs a Better Auth database.");
|
|
983
|
-
|
|
985
|
+
const role = getAuthTables(ctx.options).user?.fields.role;
|
|
986
|
+
if (!role) throw authConsoleError(409, "Site access keeps permissions as roles in the `role` field of the Better Auth user, and your user table has no such field. Use `authDatabase()`, which adds it. With your own schema, add a nullable `role` text column to the `user` table, apply the migration, and declare the field in `defineAuth()`: `user: { additionalFields: { role: { type: \"string\", required: false, input: false } } }`.");
|
|
987
|
+
if (role.input !== false) throw authConsoleError(409, "Site access keeps permissions as roles in `user.role`, and your `role` field lets users set it when they sign up or update their profile. Set `input: false` on the `role` field of `user.additionalFields` in `defineAuth()`.");
|
|
988
|
+
if (role.returned === false) throw authConsoleError(409, "Site access needs `user.role` in the session so page tools can read its grants. Remove `returned: false` from your `role` field.");
|
|
984
989
|
return {
|
|
985
990
|
...ctx,
|
|
986
991
|
internalAdapter: ctx.internalAdapter,
|
|
@@ -989,6 +994,22 @@ function createAuthConsole(auth, policy = {}, events, host = {}) {
|
|
|
989
994
|
sessionConfig: ctx.sessionConfig
|
|
990
995
|
};
|
|
991
996
|
}
|
|
997
|
+
async function isHostGuest(userId) {
|
|
998
|
+
return Boolean(await find("account", [
|
|
999
|
+
{
|
|
1000
|
+
field: "providerId",
|
|
1001
|
+
value: hostGuestProvider
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
field: "accountId",
|
|
1005
|
+
value: userId
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
field: "userId",
|
|
1009
|
+
value: userId
|
|
1010
|
+
}
|
|
1011
|
+
]));
|
|
1012
|
+
}
|
|
992
1013
|
async function hostUser(input) {
|
|
993
1014
|
const ctx = await hostContext();
|
|
994
1015
|
const email = input.email?.trim().toLowerCase();
|
|
@@ -1005,14 +1026,20 @@ function createAuthConsole(auth, policy = {}, events, host = {}) {
|
|
|
1005
1026
|
};
|
|
1006
1027
|
}
|
|
1007
1028
|
const roles = [...new Set(input.roles)];
|
|
1029
|
+
const user = await ctx.internalAdapter.createUser({
|
|
1030
|
+
email: email || `guest-${crypto.randomUUID()}@guests.invalid`,
|
|
1031
|
+
emailVerified: Boolean(email),
|
|
1032
|
+
name: input.name,
|
|
1033
|
+
...input.image ? { image: input.image } : {},
|
|
1034
|
+
role: roles.join(",")
|
|
1035
|
+
}, { method: "admin" });
|
|
1036
|
+
if (!email && !await ctx.internalAdapter.createAccount({
|
|
1037
|
+
providerId: hostGuestProvider,
|
|
1038
|
+
accountId: user.id,
|
|
1039
|
+
userId: user.id
|
|
1040
|
+
})) throw authConsoleError(409, "Better Auth did not store the Site access guest account.");
|
|
1008
1041
|
return {
|
|
1009
|
-
id:
|
|
1010
|
-
email: email || `guest-${crypto.randomUUID()}@guests.invalid`,
|
|
1011
|
-
emailVerified: Boolean(email),
|
|
1012
|
-
name: input.name,
|
|
1013
|
-
...input.image ? { image: input.image } : {},
|
|
1014
|
-
role: roles.join(",")
|
|
1015
|
-
}, { method: "admin" })).id,
|
|
1042
|
+
id: user.id,
|
|
1016
1043
|
roles
|
|
1017
1044
|
};
|
|
1018
1045
|
}
|
|
@@ -1045,15 +1072,22 @@ function createAuthConsole(auth, policy = {}, events, host = {}) {
|
|
|
1045
1072
|
limit: 1e3
|
|
1046
1073
|
});
|
|
1047
1074
|
const now = Date.now();
|
|
1048
|
-
return (await Promise.all(holders.filter((user) => roleList(user.role).some((role) => roles.includes(role))).map(async (user) =>
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1075
|
+
return (await Promise.all(holders.filter((user) => roleList(user.role).some((role) => roles.includes(role))).map(async (user) => {
|
|
1076
|
+
const userId = string(user.id);
|
|
1077
|
+
const userRoles = roleList(user.role);
|
|
1078
|
+
const guest = await isHostGuest(userId);
|
|
1079
|
+
if (!userRoles.some((role) => roles.includes(role) && (role !== "guest" || guest))) return [];
|
|
1080
|
+
return (await storedSessions(userId)).filter((session) => new Date(date(session.expiresAt)).getTime() > now).map((session) => ({
|
|
1081
|
+
id: string(session.id),
|
|
1082
|
+
user: userSummary(user),
|
|
1083
|
+
roles: userRoles,
|
|
1084
|
+
guest,
|
|
1085
|
+
device: userAgentDevice(string(session.userAgent)),
|
|
1086
|
+
createdAt: date(session.createdAt),
|
|
1087
|
+
updatedAt: date(session.updatedAt),
|
|
1088
|
+
expiresAt: date(session.expiresAt)
|
|
1089
|
+
}));
|
|
1090
|
+
}))).flat().sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
1057
1091
|
}
|
|
1058
1092
|
async function stopImpersonating(request) {
|
|
1059
1093
|
if (host.bearer) throw authConsoleError(403, "Impersonation needs the browser's app session.");
|
|
@@ -1127,24 +1161,24 @@ function createAuthConsole(auth, policy = {}, events, host = {}) {
|
|
|
1127
1161
|
await (await verifications()).deleteVerificationByIdentifier(identifier);
|
|
1128
1162
|
}),
|
|
1129
1163
|
hostUser: (input) => result(() => hostUser(input)),
|
|
1164
|
+
checkHost: () => result(async () => {
|
|
1165
|
+
await hostContext();
|
|
1166
|
+
}),
|
|
1130
1167
|
hostSession: (userId, request) => result(() => hostSession(userId, request)),
|
|
1131
1168
|
hostSessions: (roles) => result(() => hostSessions(roles)),
|
|
1132
1169
|
revokeHostSession: (id) => result(async () => {
|
|
1133
1170
|
const ctx = await hostContext();
|
|
1134
1171
|
const session = await hostSessionById(id);
|
|
1135
1172
|
if (!session) throw authConsoleError(404, "No session has this id. It ended, or someone revoked it.");
|
|
1173
|
+
const userId = string(session.userId);
|
|
1174
|
+
const guest = await isHostGuest(userId);
|
|
1136
1175
|
await ctx.internalAdapter.deleteSession(string(session.token));
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
removeHostUser: (userId) => result(async () => {
|
|
1144
|
-
const ctx = await hostContext();
|
|
1145
|
-
await ctx.internalAdapter.deleteUserSessions(userId);
|
|
1146
|
-
await ctx.internalAdapter.deleteAccounts(userId);
|
|
1147
|
-
await ctx.internalAdapter.deleteUser(userId);
|
|
1176
|
+
if (guest) {
|
|
1177
|
+
await ctx.internalAdapter.deleteUserSessions(userId);
|
|
1178
|
+
await ctx.internalAdapter.deleteAccounts(userId);
|
|
1179
|
+
await ctx.internalAdapter.deleteUser(userId);
|
|
1180
|
+
}
|
|
1181
|
+
return { removedUser: guest };
|
|
1148
1182
|
})
|
|
1149
1183
|
};
|
|
1150
1184
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
2
|
import { Result } from "@vite-hub/runtime";
|
|
3
3
|
import { AuthContext, BetterAuthOptions, DBAdapter } from "better-auth";
|
|
4
4
|
//#region src/console-runtime.d.ts
|
|
@@ -35,26 +35,28 @@ interface AuthConsole {
|
|
|
35
35
|
deleteVerification(identifier: string): Promise<Result<void, AuthConsoleErrorCode>>;
|
|
36
36
|
/**
|
|
37
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
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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
42
|
*/
|
|
43
43
|
hostUser(input: AuthConsoleHostUserInput): Promise<Result<{
|
|
44
44
|
id: string;
|
|
45
45
|
roles: string[];
|
|
46
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>>;
|
|
47
52
|
/** Start a Better Auth session for a user, and return the `Set-Cookie` headers that sign the browser in. */
|
|
48
53
|
hostSession(userId: string, request: Request): Promise<Result<Headers, AuthConsoleErrorCode>>;
|
|
49
|
-
/**
|
|
54
|
+
/** Live sessions matching `roles`, newest first. `guest` matches only users created as guests by the host. */
|
|
50
55
|
hostSessions(roles: readonly string[]): Promise<Result<AuthConsoleHostSession[], AuthConsoleErrorCode>>;
|
|
51
|
-
/** End one session
|
|
56
|
+
/** End one session and delete its user only if the host created it as a guest. */
|
|
52
57
|
revokeHostSession(id: string): Promise<Result<{
|
|
53
|
-
|
|
54
|
-
roles: string[];
|
|
58
|
+
removedUser: boolean;
|
|
55
59
|
}, AuthConsoleErrorCode>>;
|
|
56
|
-
/** Delete a user with their sessions and accounts. */
|
|
57
|
-
removeHostUser(userId: string): Promise<Result<void, AuthConsoleErrorCode>>;
|
|
58
60
|
}
|
|
59
61
|
type ConsoleAdapter = Pick<DBAdapter, "findMany" | "findOne" | "count">;
|
|
60
62
|
type AuthConsoleErrorCode = "AUTH_CONSOLE_INVALID_REQUEST" | "AUTH_CONSOLE_FORBIDDEN" | "AUTH_CONSOLE_NOT_FOUND" | "AUTH_CONSOLE_UNAVAILABLE" | "AUTH_CONSOLE_PROVIDER_FAILED";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { i as describeAuthConsoleFields, n as AuthConsoleErrorCode, r as createAuthConsole, t as AuthConsole } from "./console-runtime-
|
|
1
|
+
import { $ as AuthConsoleEventGroup, Ct as authConsoleActionNames, G as AuthConsoleAction, J as AuthConsoleAgent, K as AuthConsoleActivity, Q as AuthConsoleEvent, St as AuthConsoleValue, X as AuthConsoleColumn, Y as AuthConsoleCapability, Z as AuthConsoleDescription, _t as AuthConsoleRoles, at as AuthConsoleHostSession, bt as AuthConsoleUser, ct as AuthConsoleList, dt as AuthConsoleOrganization, et as AuthConsoleEventUser, ft as AuthConsoleOrganizationDetail, gt as AuthConsoleQuery, ht as AuthConsolePolicy, it as AuthConsoleHostOptions, lt as AuthConsoleMutation, mt as AuthConsolePage, nt as AuthConsoleFieldPolicy, ot as AuthConsoleHostUserInput, pt as AuthConsoleOverview, q as AuthConsoleActivityQuery, rt as AuthConsoleFieldType, st as AuthConsoleImpersonation, tt as AuthConsoleField, ut as AuthConsoleOptions, vt as AuthConsoleSession, wt as authConsoleEventGroups, xt as AuthConsoleUserDetail, yt as AuthConsoleSessionUser } from "./types-gl-myjZc.js";
|
|
2
|
+
import { i as describeAuthConsoleFields, n as AuthConsoleErrorCode, r as createAuthConsole, t as AuthConsole } from "./console-runtime-Dqidb3zF.js";
|
|
3
3
|
export { AuthConsole, type AuthConsoleAction, type AuthConsoleActivity, type AuthConsoleActivityQuery, type AuthConsoleAgent, type AuthConsoleCapability, type AuthConsoleColumn, type AuthConsoleDescription, AuthConsoleErrorCode, type AuthConsoleEvent, type AuthConsoleEventGroup, type AuthConsoleEventUser, type AuthConsoleField, type AuthConsoleFieldPolicy, type AuthConsoleFieldType, type AuthConsoleHostOptions, type AuthConsoleHostSession, type AuthConsoleHostUserInput, type AuthConsoleImpersonation, type AuthConsoleList, type AuthConsoleMutation, type AuthConsoleOptions, type AuthConsoleOrganization, type AuthConsoleOrganizationDetail, type AuthConsoleOverview, type AuthConsolePage, type AuthConsolePolicy, type AuthConsoleQuery, type AuthConsoleRoles, type AuthConsoleSession, type AuthConsoleSessionUser, type AuthConsoleUser, type AuthConsoleUserDetail, type AuthConsoleValue, type authConsoleActionNames, type authConsoleEventGroups, createAuthConsole, describeAuthConsoleFields };
|
package/dist/console-runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as describeAuthConsoleFields, t as createAuthConsole } from "./console-runtime-
|
|
1
|
+
import { n as describeAuthConsoleFields, t as createAuthConsole } from "./console-runtime-CuXRDhGy.js";
|
|
2
2
|
export { createAuthConsole, describeAuthConsoleFields };
|
package/dist/console.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as AuthConsoleEventGroup, Ct as authConsoleActionNames, G as AuthConsoleAction, J as AuthConsoleAgent, K as AuthConsoleActivity, Q as AuthConsoleEvent, St as AuthConsoleValue, X as AuthConsoleColumn, Y as AuthConsoleCapability, Z as AuthConsoleDescription, _t as AuthConsoleRoles, at as AuthConsoleHostSession, bt as AuthConsoleUser, ct as AuthConsoleList, dt as AuthConsoleOrganization, et as AuthConsoleEventUser, ft as AuthConsoleOrganizationDetail, gt as AuthConsoleQuery, ht as AuthConsolePolicy, it as AuthConsoleHostOptions, lt as AuthConsoleMutation, mt as AuthConsolePage, nt as AuthConsoleFieldPolicy, ot as AuthConsoleHostUserInput, pt as AuthConsoleOverview, q as AuthConsoleActivityQuery, rt as AuthConsoleFieldType, st as AuthConsoleImpersonation, tt as AuthConsoleField, ut as AuthConsoleOptions, vt as AuthConsoleSession, wt as authConsoleEventGroups, xt as AuthConsoleUserDetail, yt as AuthConsoleSessionUser } from "./types-gl-myjZc.js";
|
|
2
2
|
//#region ../internal/src/console.d.ts
|
|
3
3
|
/** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
|
|
4
4
|
interface ViteHubConsoleDefinitionCatalogView {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
|
|
2
2
|
//#region src/database-options.ts
|
|
3
3
|
/** Reads the adapter's target without loading Better Auth or the Database runtime. */
|
|
4
4
|
function authDatabaseName(database) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as authDatabaseSchemaError } from "./database-options-
|
|
1
|
+
import { a as authDatabaseSchemaError } from "./database-options-CcjUG-us.js";
|
|
2
2
|
import { getAuthTables } from "better-auth/db";
|
|
3
3
|
//#region src/database-schema-options.ts
|
|
4
4
|
/** Better Auth reads each table by its key and each column by its field key, so the options must not rename them. */
|
package/dist/database.d.ts
CHANGED
package/dist/database.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { a as authDatabaseSchemaError, t as assertAuthDatabaseIdStrategy } from "./database-options-
|
|
3
|
-
import { t as assertAuthDatabaseNames } from "./database-schema-options-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
|
|
2
|
+
import { a as authDatabaseSchemaError, t as assertAuthDatabaseIdStrategy } from "./database-options-CcjUG-us.js";
|
|
3
|
+
import { t as assertAuthDatabaseNames } from "./database-schema-options-CTKCAfqW.js";
|
|
4
4
|
import { getAuthTables } from "better-auth/db";
|
|
5
5
|
import { getTableColumns, is, isTable } from "drizzle-orm";
|
|
6
6
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
@@ -12,7 +12,7 @@ import { PgAsyncDatabase } from "drizzle-orm/pg-core";
|
|
|
12
12
|
* tables of the Database, before the adapter opens it.
|
|
13
13
|
*/
|
|
14
14
|
function assertAuthDatabaseSchema(options, schema, database) {
|
|
15
|
-
const fix = "Call the plugin in `server/auth.ts
|
|
15
|
+
const fix = "Call the plugin in `server/auth.ts`, or in a file that it imports with a relative path, and write `additionalFields` inline in `server/auth.ts`, so that the Auth Vite plugin adds the columns. Then run `vitehub database generate` and apply the migration";
|
|
16
16
|
for (const [model, table] of Object.entries(getAuthTables(options))) {
|
|
17
17
|
const drizzleTable = Object.hasOwn(schema, model) ? schema[model] : void 0;
|
|
18
18
|
if (!isTable(drizzleTable)) throw authDatabaseSchemaError(`the ${JSON.stringify(database)} Database has no \`${model}\` table. ${fix}`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
|
|
2
2
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
3
3
|
import { t as accessRouteSyntaxError } from "./application-path-DuTpfGFj.js";
|
|
4
|
-
import {
|
|
5
|
-
import { r as authDatabaseName } from "./database-options-
|
|
4
|
+
import { a as normalizeAuthBasePath, n as assertAuthPages } from "./access-pages-FNQTyGRD.js";
|
|
5
|
+
import { r as authDatabaseName } from "./database-options-CcjUG-us.js";
|
|
6
6
|
import { parseDuration } from "@vite-hub/runtime";
|
|
7
7
|
//#region src/stateless-user-id.ts
|
|
8
8
|
const pendingUserIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -374,6 +374,13 @@ function validateAuthAccess(value) {
|
|
|
374
374
|
validateAuthAccessPolicy(access.policy);
|
|
375
375
|
validateAuthSignIn(access.signIn);
|
|
376
376
|
if (typeof access.afterSignIn !== "undefined" && !isAppPath(access.afterSignIn)) throw authErrorDiagnostics.AUTH_AFTER_SIGN_IN_INVALID();
|
|
377
|
+
if (typeof access.pages !== "undefined") assertAuthPages(access.pages);
|
|
378
|
+
}
|
|
379
|
+
function validateAuthComponents(value) {
|
|
380
|
+
if (typeof value === "undefined") return;
|
|
381
|
+
if (!isRecord(value) || Object.keys(value).some((key) => key !== "prefix")) throw authErrorDiagnostics.AUTH_COMPONENTS_INVALID();
|
|
382
|
+
const prefix = value.prefix;
|
|
383
|
+
if (typeof prefix !== "undefined" && (typeof prefix !== "string" || !prefix.trim() || prefix !== prefix.trim())) throw authErrorDiagnostics.AUTH_COMPONENTS_INVALID();
|
|
377
384
|
}
|
|
378
385
|
/** A path of the app: one `/`, then no `/` or `\`, so it cannot name another site. */
|
|
379
386
|
function isAppPath(value) {
|
|
@@ -411,8 +418,9 @@ function defineAuthOptions(options) {
|
|
|
411
418
|
validateAuthDatabase(viteHubOptions.database);
|
|
412
419
|
validateAuthSecondaryStorage(viteHubOptions.secondaryStorage);
|
|
413
420
|
validateAuthAccess(viteHubOptions.access);
|
|
421
|
+
validateAuthComponents(viteHubOptions.components);
|
|
414
422
|
applyAuthPreset(options);
|
|
415
423
|
return { options };
|
|
416
424
|
}
|
|
417
425
|
//#endregion
|
|
418
|
-
export {
|
|
426
|
+
export { createDeleteAccount as a, applyAuthPreset as c, validateAuthComponents as i, defineAuth as n, validateDeleteAccount as o, validateAuthAccessPolicy as r, validateAuthEvents as s, assertNoRuntimeOption as t };
|
|
@@ -57,6 +57,11 @@ const authErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
57
57
|
why: "`defineAuth()` access.afterSignIn must be an inline path of the app that starts with one `/`.",
|
|
58
58
|
fix: "Set `access.afterSignIn` to a string literal path, for example `afterSignIn: '/dashboard'`. The Nuxt page guard reads it at build time."
|
|
59
59
|
},
|
|
60
|
+
AUTH_COMPONENTS_INVALID: {
|
|
61
|
+
why: "`defineAuth()` components must be an inline object with only `prefix`, an inline non-empty string.",
|
|
62
|
+
fix: "Write `components: { prefix: 'Custom' }` in `defineAuth()` to register `<CustomAuthPermission>`, or remove `components`. The Nuxt module reads the prefix at build time, so it cannot use a variable or an expression."
|
|
63
|
+
},
|
|
64
|
+
AUTH_PAGE_ROUTES_INVALID: withFix("Write `access.pages` inline in `defineAuth()`, and do not use a spread or a computed key in `access`. Start each key with `/` and use only static segments, `:name`, and a last `**`. Keep one key for the same pages, and set each value to `'user'`, `'guest'`, or `false`, for example `pages: { '/dashboard/**': 'user', '/login': 'guest' }`. For an optional segment, add one key with the segment and one key without it."),
|
|
60
65
|
AUTH_REDIRECTS_MOVED: {
|
|
61
66
|
why: "`vitehub({ auth })` takes only `true` or `false`. The `redirects` option moved to the Auth Definition.",
|
|
62
67
|
fix: "Remove the object from `auth` in `vitehub()`. In `server/auth.ts`, set `access: { signIn: '/login', afterSignIn: '/' }`: `redirects.login` is now `signIn`, and `redirects.guest` is now `afterSignIn`. `vitehub migrate` moves them."
|
|
@@ -84,7 +89,7 @@ const authErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
84
89
|
AUTH_C0012: withFix("Write `access.routes` as an array literal in `defineAuth()`, for example `access: { routes: ['/admin/**'] }`. The Vite plugin reads it at build time."),
|
|
85
90
|
AUTH_C0014: withFix("Set `database: authDatabase()` with `import { authDatabase } from 'vite-hub/auth/database'`, or `authDatabase('auth')` for the Named Database `auth`. Return another Better Auth adapter from the Definition callback. Set `database: \"memory\"` to keep sessions in the memory of one server process."),
|
|
86
91
|
AUTH_C0017: withFix("Remove `secondaryStorage` from the static options. Return a Better Auth `secondaryStorage` adapter, an object with `get`, `set`, and `delete`, from the Definition callback."),
|
|
87
|
-
AUTH_C0019: withFix("Pass an object literal to `defineAuth()` in `server/auth.ts`, or a callback that returns one, for example `export default defineAuth({ basePath: '/auth' })`. Do not pass a variable."),
|
|
92
|
+
AUTH_C0019: withFix("Pass an object literal to `defineAuth()` in `server/auth.ts`, or a callback that returns one, for example `export default defineAuth({ basePath: '/auth' })`. Do not pass a variable. Export the call, or a top-level `const` that holds it."),
|
|
88
93
|
AUTH_C0021: withFix("Set `database: authDatabase()` with `import { authDatabase } from 'vite-hub/auth/database'`, or `authDatabase('auth')` for the Named Database `auth`. Return another Better Auth adapter from the Definition callback. Set `database: \"memory\"` to keep sessions in the memory of one server process."),
|
|
89
94
|
AUTH_C0024: withFix("Remove `secondaryStorage` from the static options. Return a Better Auth `secondaryStorage` adapter, an object with `get`, `set`, and `delete`, from the Definition callback."),
|
|
90
95
|
AUTH_C0026: withFix("Set the option to a non-empty string, for example `provider: 'github'` or `method: 'GET'`."),
|
|
@@ -117,7 +122,7 @@ const authErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
117
122
|
AUTH_C0053: withFix("Remove `advanced.database.generateId`, or set it to a function that returns strings. Use another Better Auth adapter for numeric or UUID IDs."),
|
|
118
123
|
AUTH_C0054: withFix("Call `authDatabase()` inline as `database` in the object of `defineAuth()`, or in the one object that its callback returns. Do not select it in a branch."),
|
|
119
124
|
AUTH_C0055: withFix("Write `additionalFields` inline in `server/auth.ts`, with a literal `type` for each field, for example `user: { additionalFields: { login: { type: 'string', required: false } } }`."),
|
|
120
|
-
AUTH_C0056: withFix("Remove the `modelName` or `fieldName` change. For a plugin that adds a table or a column, call it in `server/auth.ts` so that the Auth Vite plugin adds its tables, or add its tables to the Database Definition. Then run `vitehub database generate`."),
|
|
125
|
+
AUTH_C0056: withFix("Remove the `modelName` or `fieldName` change. For a plugin that adds a table or a column, call it in `server/auth.ts` or in a file that `server/auth.ts` imports with a relative path, so that the Auth Vite plugin adds its tables, or add its tables to the Database Definition. Then run `vitehub database generate`."),
|
|
121
126
|
AUTH_C0057: withFix("Unset `VITEHUB_ADMIN_EMAILS`. List each admin's social account in `VITEHUB_ADMINS`, for example `VITEHUB_ADMINS=github:22072217`."),
|
|
122
127
|
AUTH_C0058: withFix("Write each `VITEHUB_ADMINS` entry as `<provider>:<account id>`, for example `github:22072217`. Run `gh api users/<login> --jq .id` to get a GitHub account id. For an app with only email sign-in, remove `VITEHUB_ADMINS`, then run `vitehub auth claim`."),
|
|
123
128
|
AUTH_C0059: withFix("Run `vitehub auth claim` and set `VITEHUB_ADMIN_CLAIM` to the `sha256:` value that it prints. Do not set the code itself."),
|
|
@@ -135,6 +140,7 @@ const authErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
135
140
|
AUTH_C0068: withFix("Write each access route as a literal path, without percent-encoded pattern syntax or `.` and `..` segments. To guard a path and every path below it, end the route with `/**`, for example `/api/users/**` in place of `/api/users/:id` or `/api/admin/*`. Check the parameter in the handler."),
|
|
136
141
|
AUTH_B0001: withFix("Set `env.projectRoot` of `@vite-hub/auth/nuxt` to the `projectRoot` of the `hubEnv()` plugin, or remove `env.projectRoot`."),
|
|
137
142
|
AUTH_B0002: withFix("Remove `swr`, `cache`, `isr`, `prerender`, or `static` from the route rule that the message names. Or add a rule for the guarded path that turns the cache off, for example `routeRules: { '/dashboard/**': { cache: false, prerender: false } }`. If the page is public, remove the route from `access.routes`."),
|
|
143
|
+
AUTH_GUARDED_PAGE_CACHED: withFix("Remove `swr`, `cache`, `isr`, `prerender`, or `static` from the route rule that the message names. Or add a route rule that turns the cache off on the guarded pages and their payloads, for example `routeRules: { '/dashboard/**': { cache: false, prerender: false } }`. To keep the cache, add `ssr: false` to that route rule, so the page guard runs only in the browser. If the page is public, remove its page guard. To cache one public path beside a guarded page, add a public page with that static path, for example `pages/users/public.vue` with `definePageMeta({ auth: false })`, and use that exact path as the route rule key, for example `'/users/public': { swr: 60 }`."),
|
|
138
144
|
AUTH_R0005: withFix("Add `server/auth.ts` with `export default defineAuth({})`. For a Nuxt layer, add it to the app."),
|
|
139
145
|
AUTH_R0006: withFix("Send the `Origin` header with the request. Browsers send it. A server-side caller must set it, for example `headers: { origin: 'https://app.example.com' }`."),
|
|
140
146
|
AUTH_R0007: withFix("Add the origin to Better Auth's `trustedOrigins` in the Auth Definition, for example `trustedOrigins: ['https://app.example.com']`. Or send the request from the app origin."),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
|
|
2
2
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
3
3
|
import { defineErrors } from "@vite-hub/runtime";
|
|
4
4
|
import { sql } from "drizzle-orm";
|
package/dist/forward.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
|
|
2
2
|
import { createAuthMiddleware } from "better-auth/api";
|
|
3
3
|
import { applySetCookies, deleteSessionCookie, setSessionCookie } from "better-auth/cookies";
|
|
4
4
|
import { handleOAuthUserInfo, setTokenUtil } from "better-auth/oauth2";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference path="./host-declarations.d.ts" />
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as AuthRuntimeEnv, At as AuthEventActor, B as DiscoveredAuthDefinition, Bt as AuthEventsConfiguration, C as AuthGuardedHandler, D as AuthReservedOption, F as AuthSessionRefresh, Ft as AuthEventPage, Ht as defaultAuthEventRetention, I as AuthSessionRefreshContext, It as AuthEventRetention, L as AuthSessionRefreshFields, Lt as AuthEventStore, M as AuthRuntimeOption, Mt as AuthEventCounts, N as AuthRuntimeOptions, Nt as AuthEventListInput, O as AuthResolvedDefinitionOptions, Ot as AuthDevice, P as AuthSessionOptions, Pt as AuthEventMetadata, R as AuthSignInConfiguration, Rt as AuthEventType, S as AuthFor, T as AuthRequest, U as ResolvedAuthViteConfig, V as RegisteredAuth, Vt as createDatabaseAuthEventStore, W as ViteHubAuth, X as AuthConsoleColumn, _ as AuthDefinition, _t as AuthConsoleRoles, a as AuthAccessPolicy, b as AuthDefinitionResolver, c as AuthAccessRouteConfiguration, d as AuthAnonymousGuardedHandler, g as AuthComponentsOptions, h as AuthBetterAuthRuntimeOptions, ht as AuthConsolePolicy, i as AuthAccessConfiguration, j as AuthRuntimeOnlyOptions, jt as AuthEventAggregates, k as AuthRuntimeContext, kt as AuthEvent, l as AuthAnonymousAuthorization, m as AuthBetterAuthOptions, n as AuthAccessAuthorize, nt as AuthConsoleFieldPolicy, o as AuthAccessPolicyContext, p as AuthAuthorization, r as AuthAccessAuthorizeResult, s as AuthAccessRoute, t as AuthAccessAuthorizationContext, u as AuthAnonymousAuthorize, ut as AuthConsoleOptions, v as AuthDefinitionInput, w as AuthOptions, x as AuthDeleteAccountOptions, y as AuthDefinitionOptions, z as AuthViteHubOptions, zt as AuthEventWindow } from "./types-gl-myjZc.js";
|
|
3
3
|
import { n as AuthStatelessPreset, r as AuthStatelessPresetOptions, t as AuthPreset } from "./presets-CHndEv5i.js";
|
|
4
|
+
import { n as checksOwnAccess } from "./own-access-CdgEICjO.js";
|
|
4
5
|
import { Result } from "@vite-hub/runtime";
|
|
5
6
|
//#region src/definition.d.ts
|
|
6
7
|
export declare function defineAuth<const TOptions extends AuthResolvedDefinitionOptions>(options: AuthDefinitionResolver<TOptions>): AuthDefinition<AuthDefinitionResolver<TOptions>>;
|
|
@@ -21,4 +22,4 @@ type GitHubOrgMemberErrorCode = "AUTH_GITHUB_NOT_ORG_MEMBER" | "AUTH_GITHUB_ORG_
|
|
|
21
22
|
*/
|
|
22
23
|
export declare function checkGitHubOrgMember(accessToken: string | null | undefined, org: string, options?: GitHubOrgMemberOptions): Promise<Result<void, GitHubOrgMemberErrorCode>>;
|
|
23
24
|
//#endregion
|
|
24
|
-
export { type AuthAccessAuthorizationContext, type AuthAccessAuthorize, type AuthAccessAuthorizeResult, type AuthAccessConfiguration, type AuthAccessPolicy, type AuthAccessPolicyContext, type AuthAccessRoute, type AuthAccessRouteConfiguration, type AuthAnonymousAuthorization, type AuthAnonymousAuthorize, type AuthAnonymousGuardedHandler, type AuthAuthorization, type AuthBetterAuthOptions, type AuthBetterAuthRuntimeOptions, type AuthConsoleColumn, type AuthConsoleFieldPolicy, type AuthConsoleOptions, type AuthConsolePolicy, type AuthConsoleRoles, type AuthDefinition, type AuthDefinitionInput, type AuthDefinitionOptions, type AuthDefinitionResolver, type AuthDeleteAccountOptions, type AuthDevice, type AuthEvent, type AuthEventActor, type AuthEventAggregates, type AuthEventCounts, type AuthEventListInput, type AuthEventMetadata, type AuthEventPage, type AuthEventRetention, type AuthEventStore, type AuthEventType, type AuthEventWindow, type AuthEventsConfiguration, type AuthFor, type AuthGuardedHandler, type AuthOptions, type AuthPreset, type AuthRequest, type AuthReservedOption, type AuthResolvedDefinitionOptions, type AuthRuntimeContext, type AuthRuntimeEnv, type AuthRuntimeOnlyOptions, type AuthRuntimeOption, type AuthRuntimeOptions, type AuthSessionOptions, type AuthSessionRefresh, type AuthSessionRefreshContext, type AuthSessionRefreshFields, type AuthSignInConfiguration, type AuthStatelessPreset, type AuthStatelessPresetOptions, type AuthViteHubOptions, type DiscoveredAuthDefinition, type GitHubOrgMemberErrorCode, type GitHubOrgMemberOptions, type RegisteredAuth, type ResolvedAuthViteConfig, type ViteHubAuth, createDatabaseAuthEventStore, defaultAuthEventRetention };
|
|
25
|
+
export { type AuthAccessAuthorizationContext, type AuthAccessAuthorize, type AuthAccessAuthorizeResult, type AuthAccessConfiguration, type AuthAccessPolicy, type AuthAccessPolicyContext, type AuthAccessRoute, type AuthAccessRouteConfiguration, type AuthAnonymousAuthorization, type AuthAnonymousAuthorize, type AuthAnonymousGuardedHandler, type AuthAuthorization, type AuthBetterAuthOptions, type AuthBetterAuthRuntimeOptions, type AuthComponentsOptions, type AuthConsoleColumn, type AuthConsoleFieldPolicy, type AuthConsoleOptions, type AuthConsolePolicy, type AuthConsoleRoles, type AuthDefinition, type AuthDefinitionInput, type AuthDefinitionOptions, type AuthDefinitionResolver, type AuthDeleteAccountOptions, type AuthDevice, type AuthEvent, type AuthEventActor, type AuthEventAggregates, type AuthEventCounts, type AuthEventListInput, type AuthEventMetadata, type AuthEventPage, type AuthEventRetention, type AuthEventStore, type AuthEventType, type AuthEventWindow, type AuthEventsConfiguration, type AuthFor, type AuthGuardedHandler, type AuthOptions, type AuthPreset, type AuthRequest, type AuthReservedOption, type AuthResolvedDefinitionOptions, type AuthRuntimeContext, type AuthRuntimeEnv, type AuthRuntimeOnlyOptions, type AuthRuntimeOption, type AuthRuntimeOptions, type AuthSessionOptions, type AuthSessionRefresh, type AuthSessionRefreshContext, type AuthSessionRefreshFields, type AuthSignInConfiguration, type AuthStatelessPreset, type AuthStatelessPresetOptions, type AuthViteHubOptions, type DiscoveredAuthDefinition, type GitHubOrgMemberErrorCode, type GitHubOrgMemberOptions, type RegisteredAuth, type ResolvedAuthViteConfig, type ViteHubAuth, checksOwnAccess, createDatabaseAuthEventStore, defaultAuthEventRetention };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { a as checkGitHubOrgMember, n as defaultAuthEventRetention, t as createDatabaseAuthEventStore } from "./events-
|
|
2
|
-
import { n as defineAuth } from "./definition-
|
|
3
|
-
|
|
1
|
+
import { a as checkGitHubOrgMember, n as defaultAuthEventRetention, t as createDatabaseAuthEventStore } from "./events-DJmO9a9I.js";
|
|
2
|
+
import { n as defineAuth } from "./definition-BFT9T6In.js";
|
|
3
|
+
import { n as checksOwnAccess } from "./own-access-C8pwo_Kn.js";
|
|
4
|
+
export { checkGitHubOrgMember, checksOwnAccess, createDatabaseAuthEventStore, defaultAuthEventRetention, defineAuth };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="../host-declarations.d.ts" />
|
|
2
|
-
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, M as getAuthForDefinition, O as withAuth, S as requireAuthorization, T as toAuthRequest, _ 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 assertAuthOrigin, j as createBetterAuthOptions, k as withAuthorization, l as createAuthAccessHandler, m as getAuthConsoleForRequest, n as AuthSignOutOptions, o as can, p as getAuth, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, u as createAuthForRequest, v as listAuthEvents, w as signOut, x as requireAuthAccessRoutes, y as requireAbility } from "../server-
|
|
3
|
-
import { a as setAuthAccessIdentityResolver, o as setAuthRuntimeEnvResolver, s as resetAuth } from "../server-
|
|
4
|
-
import { n as AbilityErrorData, t as AbilityError } from "../ability-error-
|
|
5
|
-
export { AbilityError, type AbilityErrorData, AuthEventReadErrorCode, AuthSignOutOptions, 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 };
|
|
2
|
+
import { C as requireCaller, D as withAnonymousAuthorization, E as useAuth, M as findVerifiedAuthUserId, N as getAuthForDefinition, O as withAuth, S as requireAuthorization, T as toAuthRequest, _ 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 assertAuthOrigin, j as createBetterAuthOptions, k as withAuthorization, l as createAuthAccessHandler, m as getAuthConsoleForRequest, n as AuthSignOutOptions, o as can, p as getAuth, r as aggregateAuthEvents, s as checkAuthMember, t as AuthEventReadErrorCode, u as createAuthForRequest, v as listAuthEvents, w as signOut, x as requireAuthAccessRoutes, y as requireAbility } from "../server-Ci2i6p1S.js";
|
|
3
|
+
import { a as setAuthAccessIdentityResolver, o as setAuthRuntimeEnvResolver, s as resetAuth } from "../server-B-zNtSvm.js";
|
|
4
|
+
import { n as AbilityErrorData, t as AbilityError } from "../ability-error-DUWJ6Q1W.js";
|
|
5
|
+
export { AbilityError, type AbilityErrorData, AuthEventReadErrorCode, AuthSignOutOptions, 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 };
|
package/dist/internal/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as resetAuth } from "../runtime-state-ojQCzKOc.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as getAuthForDefinition, i as findVerifiedAuthUserId, n as createBetterAuthOptions } from "../auth-instance-zYMjldPG.js";
|
|
3
3
|
import { setAuthAccessIdentityResolver, setAuthRuntimeEnvResolver } from "../runtime/server.js";
|
|
4
|
-
import { t as AbilityError } from "../ability-error-
|
|
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-
|
|
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-DmnUGicq.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-CyqLFm3L.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,6 +1,6 @@
|
|
|
1
1
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
2
|
-
import { l as findAccessPolicyPlugin } from "./members-
|
|
3
|
-
import { t as authForRequest } from "./auth-instance-
|
|
2
|
+
import { l as findAccessPolicyPlugin } from "./members-Cl3hFRjk.js";
|
|
3
|
+
import { t as authForRequest } from "./auth-instance-zYMjldPG.js";
|
|
4
4
|
import { n as mcpOAuthResources } from "./mcp-config-DRRlCAWN.js";
|
|
5
5
|
import { defineErrors } from "@vite-hub/runtime";
|
|
6
6
|
import { verifyJwsAccessToken } from "better-auth/oauth2";
|
package/dist/mcp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as pathOf, n as baseScopes, o as stateOf, r as deleteUnusedMcpClients, s as verifyMcpRequest, t as appAuth } from "./mcp-token-
|
|
1
|
+
import { a as pathOf, n as baseScopes, o as stateOf, r as deleteUnusedMcpClients, s as verifyMcpRequest, t as appAuth } from "./mcp-token-BhonlK9C.js";
|
|
2
2
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
3
3
|
import { r as mcpRegistrationPluginId } from "./mcp-config-DRRlCAWN.js";
|
|
4
4
|
import { APIError, createAuthMiddleware } from "better-auth/api";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as authErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-uEbxSY2G.js";
|
|
2
2
|
import { t as authCloudflareEnv } from "./request-z6DHHmrb.js";
|
|
3
3
|
import { n as adminClaimVariable, t as adminClaimHash } from "./admin-claim-code-CDipqeAU.js";
|
|
4
4
|
import { n as getAuthRuntimeState } from "./runtime-state-ojQCzKOc.js";
|
|
5
|
-
import { t as invariant } from "./invariant-
|
|
6
|
-
import { a as checkGitHubOrgMember } from "./events-
|
|
5
|
+
import { t as invariant } from "./invariant-DolT9EEx.js";
|
|
6
|
+
import { a as checkGitHubOrgMember } from "./events-DJmO9a9I.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";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { n as isRecordOrFunction } from "./object-Da1zyPCR.js";
|
|
2
|
+
//#region ../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
|
+
//#endregion
|
|
44
|
+
export { ownAccessHandlerMeta as n, ownAccessRouteMeta as r, createNitroServerKit as t };
|