@vite-hub/auth 0.0.4 → 0.3.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 (87) hide show
  1. package/README.md +443 -32
  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 +23 -12
  9. package/dist/agent.js +30 -8
  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 +7 -0
  15. package/dist/cli.js +108 -0
  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 -0
  19. package/dist/console-runtime.js +2 -0
  20. package/dist/console-types-CmmnKGMx.js +38 -0
  21. package/dist/console.d.ts +219 -0
  22. package/dist/console.js +15 -0
  23. package/dist/database-options-BRNef9oy.js +29 -0
  24. package/dist/database-schema-options-ENuRMduM.js +12 -0
  25. package/dist/database.d.ts +12 -0
  26. package/dist/database.js +45 -0
  27. package/dist/definition-CqQMcDEK.js +280 -0
  28. package/dist/error-diagnostics-C8XtVz0i.js +138 -0
  29. package/dist/events-ByzenEVj.js +314 -0
  30. package/dist/forward.d.ts +50 -0
  31. package/dist/forward.js +120 -0
  32. package/dist/host-declarations.d.ts +6 -1
  33. package/dist/index.d.ts +26 -5
  34. package/dist/index.js +3 -95
  35. package/dist/internal/server.d.ts +5 -0
  36. package/dist/internal/server.js +858 -0
  37. package/dist/invariant-D8_xBqmZ.js +22 -0
  38. package/dist/mcp.d.ts +187 -0
  39. package/dist/mcp.js +353 -0
  40. package/dist/members-D9lfaEO_.js +533 -0
  41. package/dist/nuxt-bridge-Cl988STZ.js +44 -0
  42. package/dist/nuxt.d.ts +36 -7
  43. package/dist/nuxt.js +116 -7
  44. package/dist/object-Da1zyPCR.js +11 -0
  45. package/dist/page-tools-shared-l4eyj53D.js +19 -0
  46. package/dist/presets-BGZi6Dfu.d.ts +25 -0
  47. package/dist/presets.d.ts +2 -0
  48. package/dist/presets.js +32 -0
  49. package/dist/request-z6DHHmrb.js +47 -0
  50. package/dist/runtime/console.d.ts +3 -0
  51. package/dist/runtime/console.js +4 -0
  52. package/dist/runtime/empty-abilities.d.ts +5 -0
  53. package/dist/runtime/empty-abilities.js +4 -0
  54. package/dist/runtime/empty-client.d.ts +6 -0
  55. package/dist/runtime/empty-client.js +5 -0
  56. package/dist/runtime/empty-definition.d.ts +1 -2
  57. package/dist/runtime/nuxt.d.ts +2 -3
  58. package/dist/runtime/nuxt.js +3 -2
  59. package/dist/runtime/server.d.ts +2 -0
  60. package/dist/runtime/server.js +77 -0
  61. package/dist/runtime/vue-nuxt.d.ts +4 -0
  62. package/dist/runtime/vue-nuxt.js +160 -0
  63. package/dist/runtime-state-ojQCzKOc.js +25 -0
  64. package/dist/schema.d.ts +137 -0
  65. package/dist/schema.js +147 -0
  66. package/dist/server-C0qnKN2W.d.ts +143 -0
  67. package/dist/server-bQGzVQ--.d.ts +41 -0
  68. package/dist/server.d.ts +3 -22
  69. package/dist/server.js +3 -2
  70. package/dist/session-cookies-BbH3UR2m.js +227 -0
  71. package/dist/set-cookie-C8NOhdRE.js +90 -0
  72. package/dist/shared-BwcdRGxD.js +12 -0
  73. package/dist/table-specs-8gq_FCaq.js +771 -0
  74. package/dist/table-specs-DbXyaXWs.d.ts +842 -0
  75. package/dist/test.d.ts +26 -0
  76. package/dist/test.js +25 -0
  77. package/dist/types-CNaeH2Fd.d.ts +569 -0
  78. package/dist/vite-CV400XXY.js +1556 -0
  79. package/dist/vite.d.ts +145 -18
  80. package/dist/vite.js +2 -2
  81. package/dist/vue.d.ts +343 -17
  82. package/dist/vue.js +640 -15
  83. package/package.json +156 -27
  84. package/dist/server-BZn8iQrB.js +0 -370
  85. package/dist/shared-QSYBHaMG.js +0 -12
  86. package/dist/types-jaRlW3D1.d.ts +0 -117
  87. package/dist/vite-Cmey8ODS.js +0 -1018
@@ -0,0 +1,314 @@
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-C8XtVz0i.js";
2
+ import { t as isRecord } from "./object-Da1zyPCR.js";
3
+ import { defineErrors } from "@vite-hub/runtime";
4
+ import { sql } from "drizzle-orm";
5
+ import * as v from "valibot";
6
+ //#region src/github.ts
7
+ const githubErrors = /*#__PURE__*/ defineErrors({
8
+ docs: "https://vitehub.dev/docs/auth/diagnostics",
9
+ codes: {
10
+ AUTH_GITHUB_ORG_REQUIRED: {
11
+ why: "`checkGitHubOrgMember()` got an empty organization login.",
12
+ fix: "Pass the login of the organization, for example `checkGitHubOrgMember(token, \"acme\")`."
13
+ },
14
+ AUTH_GITHUB_NOT_ORG_MEMBER: {
15
+ why: ({ org }) => `The GitHub user is not an active member of \`${org}\`, or the invitation is still pending.`,
16
+ fix: "Deny access. Invite the user to the organization, or ask them to accept the pending invitation."
17
+ },
18
+ AUTH_GITHUB_ORG_ACCESS_DENIED: {
19
+ why: ({ org, sso }) => sso ? `\`${org}\` uses SAML single sign-on, and the token is not authorized for it.` : `The token cannot read the memberships of \`${org}\`. It needs the \`read:org\` scope, and the organization must allow the OAuth app.`,
20
+ fix: "Ask the user to sign in with GitHub again with the `read:org` scope, and to authorize the organization's single sign-on when GitHub asks."
21
+ },
22
+ AUTH_GITHUB_TOKEN_INVALID: {
23
+ why: "GitHub rejected the access token, or there is none. It expired or was revoked.",
24
+ fix: "Ask the user to sign in with GitHub again."
25
+ },
26
+ AUTH_GITHUB_UNAVAILABLE: {
27
+ why: ({ status }) => status === void 0 ? "GitHub did not answer the membership check in time, or the request failed." : `GitHub answered the membership check with HTTP ${status}. It is down or rate limited the token.`,
28
+ fix: "Deny access for now and ask the user to try again later. Read `error.cause` for a network error."
29
+ }
30
+ }
31
+ });
32
+ const activeMemberships = /* @__PURE__ */ new Map();
33
+ async function cacheKey(accessToken, org) {
34
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${org.toLowerCase()}\n${accessToken}`));
35
+ return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
36
+ }
37
+ const orgScopes = /* @__PURE__ */ new Set([
38
+ "admin:org",
39
+ "read:org",
40
+ "write:org"
41
+ ]);
42
+ async function fetchActiveMembership(accessToken, org, timeoutMs) {
43
+ let response;
44
+ try {
45
+ response = await fetch(`https://api.github.com/user/memberships/orgs/${encodeURIComponent(org)}`, {
46
+ headers: {
47
+ accept: "application/vnd.github+json",
48
+ authorization: `Bearer ${accessToken}`,
49
+ "user-agent": "vitehub",
50
+ "x-github-api-version": "2022-11-28"
51
+ },
52
+ signal: AbortSignal.timeout(timeoutMs)
53
+ });
54
+ } catch (cause) {
55
+ return [githubErrors.AUTH_GITHUB_UNAVAILABLE({ cause }), void 0];
56
+ }
57
+ const { headers, status } = response;
58
+ if (status === 401) return [githubErrors.AUTH_GITHUB_TOKEN_INVALID(), void 0];
59
+ if (status === 429 || status >= 500 || !response.ok && (headers.get("x-ratelimit-remaining") === "0" || headers.has("retry-after"))) return [githubErrors.AUTH_GITHUB_UNAVAILABLE({ status }), void 0];
60
+ if (status === 403) {
61
+ const body = await response.json().catch(() => void 0);
62
+ if (isRecord(body) && /rate.limit/i.test(`${body.message} ${body.documentation_url}`)) return [githubErrors.AUTH_GITHUB_UNAVAILABLE({ status }), void 0];
63
+ return [githubErrors.AUTH_GITHUB_ORG_ACCESS_DENIED({
64
+ org,
65
+ sso: headers.has("x-github-sso")
66
+ }), void 0];
67
+ }
68
+ if (status === 404) {
69
+ const scopes = headers.get("x-oauth-scopes")?.split(/[\s,]+/);
70
+ return scopes && !scopes.some((scope) => orgScopes.has(scope)) ? [githubErrors.AUTH_GITHUB_ORG_ACCESS_DENIED({
71
+ org,
72
+ sso: false
73
+ }), void 0] : [githubErrors.AUTH_GITHUB_NOT_ORG_MEMBER({ org }), void 0];
74
+ }
75
+ if (!response.ok) return [githubErrors.AUTH_GITHUB_UNAVAILABLE({ status }), void 0];
76
+ let membership;
77
+ try {
78
+ membership = await response.json();
79
+ } catch (cause) {
80
+ return [githubErrors.AUTH_GITHUB_UNAVAILABLE({
81
+ cause,
82
+ status
83
+ }), void 0];
84
+ }
85
+ if (typeof membership !== "object" || membership === null || !("state" in membership)) return [githubErrors.AUTH_GITHUB_UNAVAILABLE({ status }), void 0];
86
+ return membership.state === "active" ? [void 0, void 0] : [githubErrors.AUTH_GITHUB_NOT_ORG_MEMBER({ org }), void 0];
87
+ }
88
+ /**
89
+ * Checks that the GitHub user of `accessToken` is an active member of `org`. The token needs the `read:org` scope.
90
+ * Returns `[undefined, undefined]` for an active membership, else the error that says why it could not confirm one.
91
+ */
92
+ async function checkGitHubOrgMember(accessToken, org, options = {}) {
93
+ if (!org) throw githubErrors.AUTH_GITHUB_ORG_REQUIRED();
94
+ if (!accessToken) return [githubErrors.AUTH_GITHUB_TOKEN_INVALID(), void 0];
95
+ const cacheMs = options.cacheMs ?? 0;
96
+ if (cacheMs <= 0) return await fetchActiveMembership(accessToken, org, options.timeoutMs ?? 5e3);
97
+ const key = await cacheKey(accessToken, org);
98
+ const cached = activeMemberships.get(key);
99
+ if (cached && cached.checkedAt + cacheMs > Date.now()) return [void 0, void 0];
100
+ const result = await fetchActiveMembership(accessToken, org, options.timeoutMs ?? 5e3);
101
+ if (!result[0]) {
102
+ const now = Date.now();
103
+ for (const [entry, membership] of activeMemberships) if (membership.expiresAt <= now) activeMemberships.delete(entry);
104
+ activeMemberships.set(key, {
105
+ checkedAt: now,
106
+ expiresAt: now + cacheMs
107
+ });
108
+ }
109
+ return result;
110
+ }
111
+ /**
112
+ * Returns `true` when the GitHub user of `accessToken` is an active member of `org`. The token needs the `read:org` scope.
113
+ * Every failure returns `false`. Use `checkGitHubOrgMember()` to know why.
114
+ */
115
+ async function isGitHubOrgMember(accessToken, org, options = {}) {
116
+ if (!org) return false;
117
+ const [error] = await checkGitHubOrgMember(accessToken, org, options);
118
+ return !error;
119
+ }
120
+ //#endregion
121
+ //#region src/events.ts
122
+ const authEventTypes = [
123
+ "user.signed_up",
124
+ "user.signed_in",
125
+ "user.signed_out",
126
+ "sign_in.failed",
127
+ "session.revoked",
128
+ "user.banned",
129
+ "user.unbanned",
130
+ "user.role_changed",
131
+ "user.updated",
132
+ "user.removed",
133
+ "impersonation.started",
134
+ "impersonation.stopped",
135
+ "oauth.consent_granted",
136
+ "oauth.consent_revoked",
137
+ "organization.member_added",
138
+ "organization.member_removed",
139
+ "organization.member_role_changed"
140
+ ];
141
+ const text = v.pipe(v.string(), v.minLength(1), v.maxLength(256));
142
+ const timestamp = v.pipe(v.string(), v.isoTimestamp());
143
+ const actor = v.custom((value) => typeof value === "string" && value.length <= 512 && /^(system|user:.+)$/.test(value));
144
+ const metadata = v.object({
145
+ method: v.optional(v.pipe(text, v.regex(/^[a-zA-Z0-9_.:-]+$/))),
146
+ device: v.optional(v.picklist([
147
+ "desktop",
148
+ "mobile",
149
+ "tablet",
150
+ "bot",
151
+ "unknown"
152
+ ])),
153
+ sessionId: v.optional(text),
154
+ fields: v.optional(v.pipe(v.array(v.pipe(text, v.regex(/^[a-zA-Z][a-zA-Z0-9_]*$/))), v.maxLength(100))),
155
+ role: v.optional(text),
156
+ clientId: v.optional(text),
157
+ organizationId: v.optional(text),
158
+ memberId: v.optional(text)
159
+ });
160
+ const eventSchema = v.object({
161
+ id: text,
162
+ type: v.picklist(authEventTypes),
163
+ time: timestamp,
164
+ actor,
165
+ userId: v.nullable(text),
166
+ metadata
167
+ });
168
+ const rowSchema = v.object({ payload: v.string() });
169
+ const cursorSchema = v.tuple([timestamp, text]);
170
+ const listSchema = v.object({
171
+ type: v.optional(v.union([v.picklist(authEventTypes), v.pipe(v.array(v.picklist(authEventTypes)), v.minLength(1), v.maxLength(authEventTypes.length))])),
172
+ userId: v.optional(text),
173
+ actor: v.optional(actor),
174
+ from: v.optional(timestamp),
175
+ to: v.optional(timestamp),
176
+ cursor: v.optional(v.pipe(v.string(), v.maxLength(2048))),
177
+ limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(200)))
178
+ });
179
+ function parseAuthEventList(input) {
180
+ const query = v.parse(listSchema, input);
181
+ const before = query.cursor ? v.parse(cursorSchema, JSON.parse(decodeURIComponent(query.cursor))) : void 0;
182
+ if (query.from && query.to && Date.parse(query.from) >= Date.parse(query.to)) throw authErrorDiagnostics.AUTH_EVENT_QUERY_INVALID({ problem: "order" });
183
+ return {
184
+ query,
185
+ before
186
+ };
187
+ }
188
+ function parseAuthEventWindow(window) {
189
+ const from = new Date(v.parse(timestamp, window.from)).toISOString();
190
+ const to = new Date(v.parse(timestamp, window.to)).toISOString();
191
+ if (from >= to || Date.parse(to) - Date.parse(from) > 316224e5) throw authErrorDiagnostics.AUTH_EVENT_QUERY_INVALID({ problem: "window" });
192
+ return {
193
+ from,
194
+ to
195
+ };
196
+ }
197
+ const defaultAuthEventRetention = {
198
+ maxAgeMs: 7776e6,
199
+ maxRecords: 1e5
200
+ };
201
+ /** One SQLite store contract for Node SQLite, libSQL, and Cloudflare D1 Drizzle databases. */
202
+ function createDatabaseAuthEventStore(options) {
203
+ const { db } = options;
204
+ const retention = options.retention === false ? false : {
205
+ ...defaultAuthEventRetention,
206
+ ...options.retention
207
+ };
208
+ if (retention && Object.values(retention).some((value) => !Number.isSafeInteger(value) || value < 1)) throw authErrorDiagnostics.AUTH_EVENT_RETENTION_INVALID();
209
+ let ready;
210
+ const initialize = () => ready ??= (async () => {
211
+ await db.run(sql`CREATE TABLE IF NOT EXISTS vitehub_auth_events (id TEXT PRIMARY KEY, type TEXT NOT NULL, time TEXT NOT NULL, actor TEXT NOT NULL, user_id TEXT, method TEXT, payload TEXT NOT NULL)`);
212
+ await db.run(sql`CREATE INDEX IF NOT EXISTS vitehub_auth_events_time ON vitehub_auth_events (time, id)`);
213
+ await db.run(sql`CREATE INDEX IF NOT EXISTS vitehub_auth_events_type ON vitehub_auth_events (type, time, id)`);
214
+ await db.run(sql`CREATE INDEX IF NOT EXISTS vitehub_auth_events_user ON vitehub_auth_events (user_id, time, id)`);
215
+ await db.run(sql`CREATE INDEX IF NOT EXISTS vitehub_auth_events_actor ON vitehub_auth_events (actor, time, id)`);
216
+ })().catch((error) => {
217
+ ready = void 0;
218
+ throw error;
219
+ });
220
+ const cutoff = () => new Date(Math.max(0, Date.now() - (retention ? retention.maxAgeMs : Date.now()))).toISOString();
221
+ const visible = () => retention ? sql`time >= ${cutoff()}` : sql`1 = 1`;
222
+ return {
223
+ async append(input) {
224
+ const event = v.parse(eventSchema, input);
225
+ event.time = new Date(event.time).toISOString();
226
+ await initialize();
227
+ await db.run(sql`INSERT INTO vitehub_auth_events (id, type, time, actor, user_id, method, payload) VALUES (${event.id}, ${event.type}, ${event.time}, ${event.actor}, ${event.userId}, ${event.metadata.method ?? null}, ${JSON.stringify(event)}) ON CONFLICT (id) DO NOTHING`);
228
+ if (retention) await db.run(sql`DELETE FROM vitehub_auth_events WHERE time < ${cutoff()} OR (time, id) <= (SELECT time, id FROM vitehub_auth_events ORDER BY time DESC, id DESC LIMIT 1 OFFSET ${retention.maxRecords})`);
229
+ },
230
+ async list(input = {}) {
231
+ const { query, before } = parseAuthEventList(input);
232
+ const limit = query.limit ?? 50;
233
+ await initialize();
234
+ const rows = await db.all(sql`SELECT payload FROM vitehub_auth_events WHERE ${visible()}
235
+ ${query.type ? sql`AND type IN (${sql.join((typeof query.type === "string" ? [query.type] : query.type).map((type) => sql`${type}`), sql`, `)})` : sql``}
236
+ ${query.userId ? sql`AND user_id = ${query.userId}` : sql``}
237
+ ${query.actor ? sql`AND actor = ${query.actor}` : sql``}
238
+ ${query.from ? sql`AND time >= ${new Date(query.from).toISOString()}` : sql``}
239
+ ${query.to ? sql`AND time < ${new Date(query.to).toISOString()}` : sql``}
240
+ ${before ? sql`AND (time, id) < (${before[0]}, ${before[1]})` : sql``}
241
+ ORDER BY time DESC, id DESC LIMIT ${limit + 1}`);
242
+ const events = rows.slice(0, limit).map((row) => v.parse(eventSchema, JSON.parse(v.parse(rowSchema, row).payload)));
243
+ const last = events.at(-1);
244
+ return {
245
+ events,
246
+ ...rows.length > limit && last ? { nextCursor: encodeURIComponent(JSON.stringify([last.time, last.id])) } : {}
247
+ };
248
+ },
249
+ async aggregate(window) {
250
+ const { from, to } = parseAuthEventWindow(window);
251
+ await initialize();
252
+ const where = sql`${visible()} AND time >= ${from} AND time < ${to} AND type IN ('user.signed_up', 'user.signed_in')`;
253
+ const counts = sql`SUM(CASE WHEN type = 'user.signed_up' THEN 1 ELSE 0 END) AS signUps, SUM(CASE WHEN type = 'user.signed_in' THEN 1 ELSE 0 END) AS signIns, COUNT(DISTINCT CASE WHEN type = 'user.signed_in' THEN user_id END) AS activeUsers`;
254
+ const rows = await db.all(sql`SELECT substr(time, 1, 10) AS day, ${counts}, NULL AS method, NULL AS count FROM vitehub_auth_events WHERE ${where} GROUP BY day
255
+ UNION ALL SELECT NULL AS day, ${counts}, NULL AS method, NULL AS count FROM vitehub_auth_events WHERE ${where}
256
+ UNION ALL SELECT substr(time, 1, 10) AS day, NULL AS signUps, NULL AS signIns, NULL AS activeUsers, method, COUNT(*) AS count FROM vitehub_auth_events WHERE ${where} AND type = 'user.signed_in' GROUP BY day, method`);
257
+ const methods = rows.filter((row) => row.count !== null);
258
+ const empty = () => ({
259
+ signUps: 0,
260
+ signIns: 0,
261
+ activeUsers: 0,
262
+ methods: {}
263
+ });
264
+ const days = /* @__PURE__ */ new Map();
265
+ for (let time = Date.parse(`${from.slice(0, 10)}T00:00:00.000Z`); time < Date.parse(to); time += 864e5) days.set(new Date(time).toISOString().slice(0, 10), empty());
266
+ let totals = empty();
267
+ const countSchema = v.object({
268
+ day: v.nullable(v.string()),
269
+ signUps: v.nullable(v.number()),
270
+ signIns: v.nullable(v.number()),
271
+ activeUsers: v.number()
272
+ });
273
+ for (const row of rows.filter((row) => row.count === null)) {
274
+ const item = v.parse(countSchema, row);
275
+ const value = {
276
+ signUps: item.signUps ?? 0,
277
+ signIns: item.signIns ?? 0,
278
+ activeUsers: item.activeUsers,
279
+ methods: {}
280
+ };
281
+ if (item.day) days.set(item.day, value);
282
+ else totals = value;
283
+ }
284
+ for (const row of methods) {
285
+ const item = v.parse(v.object({
286
+ day: v.string(),
287
+ method: v.nullable(v.string()),
288
+ count: v.number()
289
+ }), row);
290
+ const method = item.method ?? "unknown";
291
+ const day = days.get(item.day);
292
+ if (day) Object.defineProperty(day.methods, method, {
293
+ value: item.count,
294
+ enumerable: true,
295
+ configurable: true
296
+ });
297
+ Object.defineProperty(totals.methods, method, {
298
+ value: (Object.hasOwn(totals.methods, method) ? totals.methods[method] : 0) + item.count,
299
+ enumerable: true,
300
+ configurable: true
301
+ });
302
+ }
303
+ return {
304
+ days: [...days].map(([day, value]) => ({
305
+ day,
306
+ ...value
307
+ })),
308
+ totals
309
+ };
310
+ }
311
+ };
312
+ }
313
+ //#endregion
314
+ export { checkGitHubOrgMember as a, parseAuthEventWindow as i, defaultAuthEventRetention as n, isGitHubOrgMember as o, parseAuthEventList as r, createDatabaseAuthEventStore as t };
@@ -0,0 +1,50 @@
1
+ import { BetterAuthPlugin } from "better-auth";
2
+ //#region src/forward.d.ts
3
+ /**
4
+ * Sign-in through a trusted reverse proxy, such as oauth2-proxy, Cloudflare Access, or Tailscale Serve. The proxy
5
+ * sends the person's identity, or a credential for it, in a request header. Auth trusts the header only when `verify`
6
+ * returns an identity, and then signs that identity in as a Better Auth account.
7
+ */
8
+ /** The person that `verify` found in the header. Auth links it to a user as a Better Auth account. */
9
+ export interface ForwardedIdentity {
10
+ /** The provider of the account, such as `github` or `cloudflare-access`. */
11
+ providerId: string;
12
+ /** The person's stable id at the provider, such as the numeric GitHub user id. Never a value that can change, such as a login. */
13
+ accountId: string;
14
+ email: string;
15
+ name: string;
16
+ image?: string | null;
17
+ /** Whether the provider proved that the person owns `email`. Better Auth links an existing user by email only then. */
18
+ emailVerified: boolean;
19
+ /** A provider access token to store on the account, such as the GitHub token that oauth2-proxy forwards. */
20
+ accessToken?: string;
21
+ }
22
+ export interface ForwardAuthVerifyContext {
23
+ /** The value of the header. */
24
+ value: string;
25
+ /** All headers of the request, for a check such as a shared secret that the proxy adds. */
26
+ headers: Headers;
27
+ /** The request, when Better Auth has one. A direct `auth.api` call has only headers. */
28
+ request?: Request;
29
+ }
30
+ export interface ForwardAuthOptions {
31
+ /** The request header that the proxy sets, such as `x-auth-request-access-token` or `cf-access-jwt-assertion`. */
32
+ header: string;
33
+ /**
34
+ * Proves the header and returns the identity, or `null` to ignore the header. Anyone can send any header to a server
35
+ * that is reachable without the proxy, so check a credential: call the provider with the token, check the signature
36
+ * of a JWT, or compare a secret that only the proxy sends. Auth calls it on each Better Auth request with the header,
37
+ * so cache slow checks in it.
38
+ */
39
+ verify: (context: ForwardAuthVerifyContext) => ForwardedIdentity | null | Promise<ForwardedIdentity | null>;
40
+ }
41
+ export declare const forwardAuthPluginId = "vitehub-forward-auth";
42
+ /**
43
+ * A Better Auth plugin that signs in the identity of a trusted proxy header. On each Better Auth request with the
44
+ * header, which includes every `getSession()` call and so every ViteHub guard, it asks `verify`. When `verify` returns
45
+ * an identity, the request uses a session of that identity: the session of its cookie, a session that this process
46
+ * made for the identity before, or a new one, which also sets the session cookie on the response. When `verify` returns
47
+ * `null`, the request keeps its own session cookie, if any.
48
+ */
49
+ export declare function forwardAuth(options: ForwardAuthOptions): BetterAuthPlugin;
50
+ //#endregion
@@ -0,0 +1,120 @@
1
+ import { t as authErrorDiagnostics } from "./error-diagnostics-C8XtVz0i.js";
2
+ import { createAuthMiddleware } from "better-auth/api";
3
+ import { applySetCookies, deleteSessionCookie, setSessionCookie } from "better-auth/cookies";
4
+ import { handleOAuthUserInfo, setTokenUtil } from "better-auth/oauth2";
5
+ //#region src/forward.ts
6
+ const forwardAuthPluginId = "vitehub-forward-auth";
7
+ const nonEmpty = (value) => typeof value === "string" && value.trim().length > 0;
8
+ function assertIdentity(value) {
9
+ const field = (name) => value instanceof Object ? Reflect.get(value, name) : void 0;
10
+ if (!nonEmpty(field("providerId")) || !nonEmpty(field("accountId")) || !nonEmpty(field("email")) || typeof field("name") !== "string" || typeof field("emailVerified") !== "boolean") throw authErrorDiagnostics.AUTH_R0023({ message: "`forwardAuth()` verify returned a value that is not an identity. Return `null`, or an object with `providerId`, `accountId`, `email`, `name`, and `emailVerified`." });
11
+ }
12
+ /**
13
+ * A Better Auth plugin that signs in the identity of a trusted proxy header. On each Better Auth request with the
14
+ * header, which includes every `getSession()` call and so every ViteHub guard, it asks `verify`. When `verify` returns
15
+ * an identity, the request uses a session of that identity: the session of its cookie, a session that this process
16
+ * made for the identity before, or a new one, which also sets the session cookie on the response. When `verify` returns
17
+ * `null`, the request keeps its own session cookie, if any.
18
+ */
19
+ function forwardAuth(options) {
20
+ const header = options?.header;
21
+ if (!nonEmpty(header) || typeof options.verify !== "function") throw authErrorDiagnostics.AUTH_C0067({ message: "`forwardAuth()` needs a `header` name and a `verify` function. Auth never trusts a forwarded header without `verify`." });
22
+ const verify = options.verify;
23
+ const sessions = /* @__PURE__ */ new Map();
24
+ const signIns = /* @__PURE__ */ new Map();
25
+ return {
26
+ id: forwardAuthPluginId,
27
+ hooks: { before: [{
28
+ matcher: (context) => context.path !== "/sign-out" && nonEmpty(context.headers?.get(header)),
29
+ handler: createAuthMiddleware(async (ctx) => {
30
+ const headers = ctx.headers;
31
+ const value = headers?.get(header);
32
+ if (!headers || !value) return;
33
+ const identity = await verify({
34
+ value,
35
+ headers,
36
+ ...ctx.request ? { request: ctx.request } : {}
37
+ });
38
+ if (identity === null) return;
39
+ assertIdentity(identity);
40
+ const { internalAdapter } = ctx.context;
41
+ const { sessionToken } = ctx.context.authCookies;
42
+ const key = `${identity.providerId}\n${identity.accountId}`;
43
+ const owns = async (userId) => (await internalAdapter.findAccounts(userId)).some((account) => account.providerId === identity.providerId && account.accountId === identity.accountId);
44
+ const live = async (token) => {
45
+ const stored = await internalAdapter.findSession(token);
46
+ return stored && new Date(stored.session.expiresAt).getTime() > Date.now() ? stored : null;
47
+ };
48
+ const refreshToken = async (userId) => {
49
+ if (!identity.accessToken || ctx.context.options.account?.updateAccountOnSignIn === false) return;
50
+ const account = (await internalAdapter.findAccounts(userId)).find((account) => account.providerId === identity.providerId && account.accountId === identity.accountId);
51
+ if (account) await internalAdapter.updateAccount(account.id, { accessToken: await setTokenUtil(identity.accessToken, ctx.context) });
52
+ };
53
+ const cookieToken = await ctx.getSignedCookie(sessionToken.name, ctx.context.secret);
54
+ if (cookieToken) {
55
+ const current = await live(cookieToken);
56
+ if (current && await owns(current.session.userId)) {
57
+ await refreshToken(current.session.userId);
58
+ sessions.set(key, {
59
+ token: cookieToken,
60
+ userId: current.session.userId,
61
+ expiresAt: new Date(current.session.expiresAt).getTime()
62
+ });
63
+ return;
64
+ }
65
+ }
66
+ const previous = signIns.get(key);
67
+ let release = () => {};
68
+ const turn = new Promise((resolve) => {
69
+ release = resolve;
70
+ });
71
+ signIns.set(key, turn);
72
+ await previous;
73
+ try {
74
+ const reusable = sessions.get(key);
75
+ let session = reusable ? await live(reusable.token) : null;
76
+ if (!session || session.session.userId !== reusable?.userId) {
77
+ sessions.delete(key);
78
+ const { data } = await handleOAuthUserInfo(ctx, {
79
+ userInfo: {
80
+ id: identity.accountId,
81
+ email: identity.email,
82
+ emailVerified: identity.emailVerified,
83
+ image: identity.image ?? void 0,
84
+ name: identity.name
85
+ },
86
+ account: {
87
+ providerId: identity.providerId,
88
+ accountId: identity.accountId,
89
+ ...identity.accessToken ? { accessToken: identity.accessToken } : {}
90
+ },
91
+ overrideUserInfo: true
92
+ });
93
+ if (!data) {
94
+ deleteSessionCookie(ctx);
95
+ applySetCookies(headers, ctx.responseHeaders?.getSetCookie() ?? []);
96
+ ctx.context.session = null;
97
+ return { context: { headers } };
98
+ }
99
+ session = data;
100
+ } else await refreshToken(session.session.userId);
101
+ const now = Date.now();
102
+ for (const [entry, stored] of sessions) if (stored.expiresAt <= now) sessions.delete(entry);
103
+ sessions.set(key, {
104
+ token: session.session.token,
105
+ userId: session.session.userId,
106
+ expiresAt: new Date(session.session.expiresAt).getTime()
107
+ });
108
+ await setSessionCookie(ctx, session);
109
+ applySetCookies(headers, ctx.responseHeaders?.getSetCookie() ?? []);
110
+ } finally {
111
+ release();
112
+ if (signIns.get(key) === turn) signIns.delete(key);
113
+ }
114
+ return { context: { headers } };
115
+ })
116
+ }] }
117
+ };
118
+ }
119
+ //#endregion
120
+ export { forwardAuth, forwardAuthPluginId };
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference path="./bun-sqlite.d.ts" />
2
3
 
3
- import "bun-types/sqlite.d.ts"
4
+ export {}
4
5
 
5
6
  declare global {
6
7
  interface Timer {
@@ -11,3 +12,7 @@ declare global {
11
12
  [Symbol.toPrimitive](): number
12
13
  }
13
14
  }
15
+
16
+ declare module "#app" {
17
+ export function tryUseNuxtApp(): unknown
18
+ }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,29 @@
1
1
  /// <reference path="./host-declarations.d.ts" />
2
- import { A as AuthViteHubOptions, C as AuthRuntimeOnlyOptions, D as AuthSecondaryStorageConfiguration, E as AuthRuntimeOptionsResolver, F as ViteHubAuth, M as ResolvedAuthDatabaseConfiguration, N as ResolvedAuthSecondaryStorageConfiguration, O as AuthSecondaryStorageReference, P as ResolvedAuthViteConfig, S as AuthRuntimeEnv, T as AuthRuntimeOptions, a as AuthAccessRoute, b as AuthRuntimeConfiguration, c as AuthBetterAuthRuntimeOptions, d as AuthDefinition, f as AuthDefinitionInput, g as AuthRequest, h as AuthModuleOptions, i as AuthAccessConfiguration, j as DiscoveredAuthDefinition, k as AuthSignInConfiguration, l as AuthDatabaseConfiguration, m as AuthDefinitionResolver, n as AuthAccessAuthorize, o as AuthAccessRouteConfiguration, p as AuthDefinitionOptions, r as AuthAccessAuthorizeResult, s as AuthBetterAuthOptions, t as AuthAccessAuthorizationContext, u as AuthDatabaseReference, v as AuthReservedOption, w as AuthRuntimeOption, x as AuthRuntimeContext, y as AuthResolvedDefinitionOptions } from "./types-jaRlW3D1.js";
3
-
2
+ import { A as AuthRuntimeOption, At as AuthEventCounts, Bt as defaultAuthEventRetention, C as AuthRequest, D as AuthRuntimeContext, Dt as AuthEvent, E as AuthResolvedDefinitionOptions, Et as AuthDevice, F as AuthSessionRefreshFields, Ft as AuthEventStore, H as ViteHubAuth, I as AuthSignInConfiguration, It as AuthEventType, J as AuthConsoleColumn, L as AuthViteHubOptions, Lt as AuthEventWindow, M as AuthSessionOptions, Mt as AuthEventMetadata, N as AuthSessionRefresh, Nt as AuthEventPage, O as AuthRuntimeEnv, Ot as AuthEventActor, P as AuthSessionRefreshContext, Pt as AuthEventRetention, R as DiscoveredAuthDefinition, Rt as AuthEventsConfiguration, S as AuthOptions, T as AuthReservedOption, V as ResolvedAuthViteConfig, _ as AuthDefinitionInput, a as AuthAccessPolicy, b as AuthFor, c as AuthAccessRouteConfiguration, ct as AuthConsoleOptions, d as AuthAnonymousGuardedHandler, et as AuthConsoleFieldPolicy, g as AuthDefinition, h as AuthBetterAuthRuntimeOptions, ht as AuthConsoleRoles, i as AuthAccessConfiguration, j as AuthRuntimeOptions, jt as AuthEventListInput, k as AuthRuntimeOnlyOptions, kt as AuthEventAggregates, l as AuthAnonymousAuthorization, m as AuthBetterAuthOptions, n as AuthAccessAuthorize, o as AuthAccessPolicyContext, p as AuthAuthorization, pt as AuthConsolePolicy, r as AuthAccessAuthorizeResult, s as AuthAccessRoute, t as AuthAccessAuthorizationContext, u as AuthAnonymousAuthorize, v as AuthDefinitionOptions, x as AuthGuardedHandler, y as AuthDefinitionResolver, z as RegisteredAuth, zt as createDatabaseAuthEventStore } from "./types-CNaeH2Fd.js";
3
+ import { i as AuthStatelessPresetOptions, n as AuthPreset, r as AuthStatelessPreset, t as AuthDuration } from "./presets-BGZi6Dfu.js";
4
+ import { Result } from "@vite-hub/runtime";
4
5
  //#region src/definition.d.ts
5
- declare function defineAuth<const TOptions extends AuthBetterAuthOptions>(options: AuthDefinitionOptions<TOptions>): AuthDefinition<AuthDefinitionOptions<TOptions>>;
6
- declare function defineAuth<const TOptions extends AuthResolvedDefinitionOptions>(options: AuthDefinitionResolver<TOptions>): AuthDefinition<AuthDefinitionResolver<TOptions>>;
6
+ export declare function defineAuth<const TOptions extends AuthResolvedDefinitionOptions>(options: AuthDefinitionResolver<TOptions>): AuthDefinition<AuthDefinitionResolver<TOptions>>;
7
+ export declare function defineAuth<const TOptions extends AuthBetterAuthOptions & Pick<AuthViteHubOptions, "database" | "runtime">>(options: AuthDefinitionOptions<TOptions>): AuthDefinition<AuthDefinitionOptions<TOptions>>;
7
8
  //#endregion
8
- export { type AuthAccessAuthorizationContext, type AuthAccessAuthorize, type AuthAccessAuthorizeResult, type AuthAccessConfiguration, type AuthAccessRoute, type AuthAccessRouteConfiguration, type AuthBetterAuthOptions, type AuthBetterAuthRuntimeOptions, type AuthDatabaseConfiguration, type AuthDatabaseReference, type AuthDefinition, type AuthDefinitionInput, type AuthDefinitionOptions, type AuthDefinitionResolver, type AuthModuleOptions, type AuthRequest, type AuthReservedOption, type AuthResolvedDefinitionOptions, type AuthRuntimeConfiguration, type AuthRuntimeContext, type AuthRuntimeEnv, type AuthRuntimeOnlyOptions, type AuthRuntimeOption, type AuthRuntimeOptions, type AuthRuntimeOptionsResolver, type AuthSecondaryStorageConfiguration, type AuthSecondaryStorageReference, type AuthSignInConfiguration, type AuthViteHubOptions, type DiscoveredAuthDefinition, type ResolvedAuthDatabaseConfiguration, type ResolvedAuthSecondaryStorageConfiguration, type ResolvedAuthViteConfig, type ViteHubAuth, defineAuth };
9
+ //#region src/github.d.ts
10
+ interface GitHubOrgMemberOptions {
11
+ /** Reuse a successful check no older than this many milliseconds per token and organization. Default: no cache. */
12
+ cacheMs?: number;
13
+ /** Give up on the GitHub request after this many milliseconds. Default: 5000. */
14
+ timeoutMs?: number;
15
+ }
16
+ /** Why `checkGitHubOrgMember()` could not confirm an active membership. */
17
+ type GitHubOrgMemberErrorCode = "AUTH_GITHUB_NOT_ORG_MEMBER" | "AUTH_GITHUB_ORG_ACCESS_DENIED" | "AUTH_GITHUB_TOKEN_INVALID" | "AUTH_GITHUB_UNAVAILABLE";
18
+ /**
19
+ * Checks that the GitHub user of `accessToken` is an active member of `org`. The token needs the `read:org` scope.
20
+ * Returns `[undefined, undefined]` for an active membership, else the error that says why it could not confirm one.
21
+ */
22
+ export declare function checkGitHubOrgMember(accessToken: string | null | undefined, org: string, options?: GitHubOrgMemberOptions): Promise<Result<void, GitHubOrgMemberErrorCode>>;
23
+ /**
24
+ * Returns `true` when the GitHub user of `accessToken` is an active member of `org`. The token needs the `read:org` scope.
25
+ * Every failure returns `false`. Use `checkGitHubOrgMember()` to know why.
26
+ */
27
+ export declare function isGitHubOrgMember(accessToken: string | null | undefined, org: string, options?: GitHubOrgMemberOptions): Promise<boolean>;
28
+ //#endregion
29
+ 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 AuthDevice, type AuthDuration, 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 };
package/dist/index.js CHANGED
@@ -1,95 +1,3 @@
1
- import { n as normalizeAuthBasePath } from "./shared-QSYBHaMG.js";
2
- //#region src/definition.ts
3
- const authRuntimeOptionNames = new Set([
4
- "baseURL",
5
- "secret",
6
- "secrets"
7
- ]);
8
- const accessRouteKeys = new Set([
9
- "authorize",
10
- "method",
11
- "route"
12
- ]);
13
- const databaseReferenceKeys = new Set(["dedicated", "name"]);
14
- const secondaryStorageReferenceKeys = new Set(["store"]);
15
- function isPlainObject(value) {
16
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
17
- }
18
- function validateNamedString(value, label) {
19
- if (typeof value !== "string" || value.trim().length === 0 || value !== value.trim()) throw new TypeError(`\`defineAuth()\` ${label} must be a non-empty trimmed string.`);
20
- }
21
- function validateAuthDatabase(value) {
22
- if (typeof value === "undefined" || value === true) return;
23
- if (!isPlainObject(value)) throw new TypeError("`defineAuth()` database must be `true` or an inline object with `name`.");
24
- const unknownKey = Object.keys(value).find((key) => !databaseReferenceKeys.has(key));
25
- if (unknownKey) throw new TypeError(`\`defineAuth()\` database does not support the "${unknownKey}" option.`);
26
- validateNamedString(value.name, "database.name");
27
- if (typeof value.dedicated !== "undefined" && typeof value.dedicated !== "boolean") throw new TypeError("`defineAuth()` database.dedicated must be a boolean.");
28
- }
29
- function validateAuthSecondaryStorage(value) {
30
- if (typeof value === "undefined" || value === true) return;
31
- if (!isPlainObject(value)) throw new TypeError("`defineAuth()` secondaryStorage must be `true` or an inline object with `store`.");
32
- const unknownKey = Object.keys(value).find((key) => !secondaryStorageReferenceKeys.has(key));
33
- if (unknownKey) throw new TypeError(`\`defineAuth()\` secondaryStorage does not support the "${unknownKey}" option.`);
34
- validateNamedString(value.store, "secondaryStorage.store");
35
- }
36
- function validateStringValue(value, label) {
37
- if (typeof value !== "string" || value.trim().length === 0) throw new TypeError(`\`defineAuth()\` ${label} must be a non-empty string.`);
38
- }
39
- function validateRouteValue(value, label) {
40
- validateStringValue(value, label);
41
- if (typeof value === "string" && !value.startsWith("/")) throw new TypeError(`\`defineAuth()\` ${label} must start with \`/\`.`);
42
- }
43
- function validateAuthSignIn(value) {
44
- if (typeof value === "undefined") return;
45
- if (!isPlainObject(value)) throw new TypeError("`defineAuth()` access.signIn must be an object.");
46
- validateStringValue(value.provider, "access.signIn.provider");
47
- if (typeof value.callbackURL !== "undefined") validateStringValue(value.callbackURL, "access.signIn.callbackURL");
48
- if (typeof value.errorCallbackURL !== "undefined") validateStringValue(value.errorCallbackURL, "access.signIn.errorCallbackURL");
49
- if (typeof value.requestSignUp !== "undefined" && typeof value.requestSignUp !== "boolean") throw new TypeError("`defineAuth()` access.signIn.requestSignUp must be a boolean.");
50
- if (typeof value.scopes !== "undefined" && (!Array.isArray(value.scopes) || value.scopes.some((scope) => typeof scope !== "string"))) throw new TypeError("`defineAuth()` access.signIn.scopes must be an array of strings.");
51
- }
52
- function validateAuthAccessRoute(value, label) {
53
- if (typeof value === "string") {
54
- validateRouteValue(value, label);
55
- return;
56
- }
57
- if (!isPlainObject(value)) throw new TypeError(`\`defineAuth()\` ${label} must be a route string or route object.`);
58
- const unknownKey = Object.keys(value).find((key) => !accessRouteKeys.has(key));
59
- if (unknownKey) throw new TypeError(`\`defineAuth()\` ${label} does not support the "${unknownKey}" option.`);
60
- validateRouteValue(value.route, `${label}.route`);
61
- if (typeof value.authorize !== "undefined" && typeof value.authorize !== "function") throw new TypeError(`\`defineAuth()\` ${label}.authorize must be a function.`);
62
- if (typeof value.method !== "undefined") validateStringValue(value.method, `${label}.method`);
63
- }
64
- function validateAuthAccess(value) {
65
- if (typeof value === "undefined") return;
66
- if (!isPlainObject(value)) throw new TypeError("`defineAuth()` access must be an object.");
67
- const access = value;
68
- if (typeof access.routes !== "undefined") {
69
- if (!Array.isArray(access.routes)) throw new TypeError("`defineAuth()` access.routes must be an array.");
70
- access.routes.forEach((route, index) => validateAuthAccessRoute(route, `access.routes[${index}]`));
71
- }
72
- validateAuthSignIn(access.signIn);
73
- }
74
- function defineAuth(options) {
75
- return defineAuthOptions(options);
76
- }
77
- function defineAuthOptions(options) {
78
- if (typeof options === "function") return { options };
79
- if (!isPlainObject(options)) throw new TypeError("`defineAuth()` expects an object or a callback.");
80
- const viteHubOptions = options;
81
- const runtimeOption = Object.keys(options).find((key) => authRuntimeOptionNames.has(key));
82
- if (runtimeOption) throw new TypeError(`\`defineAuth()\` ${runtimeOption} is resolved at runtime and cannot be defined in the Auth Definition.`);
83
- if (typeof viteHubOptions.route !== "undefined" && viteHubOptions.route !== false) throw new TypeError("`defineAuth()` route can only be `false` when provided.");
84
- if (typeof viteHubOptions.runtime !== "undefined" && typeof viteHubOptions.runtime !== "function" && !isPlainObject(viteHubOptions.runtime)) throw new TypeError("`defineAuth()` runtime must be an object or a function.");
85
- if (typeof viteHubOptions.basePath !== "undefined") {
86
- if (typeof viteHubOptions.basePath !== "string") throw new TypeError("`defineAuth()` basePath must be a string.");
87
- normalizeAuthBasePath(viteHubOptions.basePath);
88
- }
89
- validateAuthDatabase(viteHubOptions.database);
90
- validateAuthSecondaryStorage(viteHubOptions.secondaryStorage);
91
- validateAuthAccess(viteHubOptions.access);
92
- return { options };
93
- }
94
- //#endregion
95
- export { 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 };