@headless-lms/adapter-auth 0.2.0 → 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.
@@ -1,10 +1,447 @@
1
- import { $strip } from "./node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js";
2
1
  import { CreateAuthOptions, Hooks } from "./types.js";
2
+ import { SessionAdmin } from "@headless-lms/core/identity";
3
3
  import { AuthHeaders, AuthOrganization, MemberWriteContext, OrgAdmin, Role, UpdateOrganizationInput } from "@headless-lms/core/organizations";
4
- import { ActiveSession, Logger, NewOrganizationInput, SessionVerifier } from "@headless-lms/core/types";
4
+ import { AccessTokenAuthorization } from "better-auth/oauth2";
5
+ import { BetterAuthOptions, BetterAuthPlugin } from "better-auth";
6
+ import { AccessGrant, AccessRequest, AccessTokenVerifier, ActiveSession, ApiKeySummary, AppAccessAdmin, ConnectedApp, CreatedApiKey, HeaderBag, Logger, NewApiKey, NewOrganizationInput, SessionVerifier } from "@headless-lms/core/types";
5
7
  import { IncomingHttpHeaders } from "node:http";
6
- import { SessionAdmin } from "@headless-lms/core/identity";
7
8
  //#region src/better-auth.d.ts
9
+ declare function buildAuthOptions(opts: CreateAuthOptions): {
10
+ baseURL: string;
11
+ secret: string;
12
+ trustedOrigins: string[];
13
+ session: {
14
+ cookieCache: {
15
+ enabled: true;
16
+ maxAge: number;
17
+ };
18
+ };
19
+ advanced: {
20
+ database: {
21
+ generateId: () => string;
22
+ };
23
+ crossSubDomainCookies: {
24
+ enabled: true;
25
+ domain: string | undefined;
26
+ };
27
+ defaultCookieAttributes: {
28
+ sameSite: "lax";
29
+ secure: boolean;
30
+ httpOnly: true;
31
+ };
32
+ };
33
+ database: (options: BetterAuthOptions) => import("better-auth").DBAdapter<BetterAuthOptions>;
34
+ emailAndPassword: {
35
+ enabled: true;
36
+ sendResetPassword: (data: {
37
+ user: {
38
+ id: string;
39
+ createdAt: Date;
40
+ updatedAt: Date;
41
+ email: string;
42
+ emailVerified: boolean;
43
+ name: string;
44
+ image?: string | null | undefined;
45
+ };
46
+ url: string;
47
+ token: string;
48
+ }, request?: Request | undefined) => Promise<void>;
49
+ onPasswordReset: (data: {
50
+ user: {
51
+ id: string;
52
+ createdAt: Date;
53
+ updatedAt: Date;
54
+ email: string;
55
+ emailVerified: boolean;
56
+ name: string;
57
+ image?: string | null | undefined;
58
+ };
59
+ }, request?: Request | undefined) => Promise<void>;
60
+ revokeSessionsOnPasswordReset: true;
61
+ };
62
+ plugins: [{
63
+ id: "magic-link";
64
+ version: string;
65
+ endpoints: {
66
+ signInMagicLink: import("better-auth").StrictEndpoint<"/sign-in/magic-link", {
67
+ method: "POST";
68
+ requireHeaders: true;
69
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
70
+ body: import("better-auth").ZodObject<{
71
+ email: import("better-auth").ZodEmail;
72
+ name: import("better-auth").ZodOptional<import("better-auth").ZodString>;
73
+ callbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
74
+ newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
75
+ errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
76
+ metadata: import("better-auth").ZodOptional<import("better-auth").ZodRecord<import("better-auth").ZodString, import("better-auth").ZodAny>>;
77
+ }, import("zod/v4/core").$strip>;
78
+ metadata: {
79
+ openapi: {
80
+ operationId: string;
81
+ description: string;
82
+ responses: {
83
+ 200: {
84
+ description: string;
85
+ content: {
86
+ "application/json": {
87
+ schema: {
88
+ type: "object";
89
+ properties: {
90
+ status: {
91
+ type: string;
92
+ };
93
+ };
94
+ };
95
+ };
96
+ };
97
+ };
98
+ };
99
+ };
100
+ };
101
+ }, {
102
+ status: boolean;
103
+ }>;
104
+ magicLinkVerify: import("better-auth").StrictEndpoint<"/magic-link/verify", {
105
+ method: "GET";
106
+ query: import("better-auth").ZodObject<{
107
+ token: import("better-auth").ZodString;
108
+ callbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
109
+ errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
110
+ newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
111
+ }, import("zod/v4/core").$strip>;
112
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
113
+ requireHeaders: true;
114
+ metadata: {
115
+ openapi: {
116
+ operationId: string;
117
+ description: string;
118
+ responses: {
119
+ 200: {
120
+ description: string;
121
+ content: {
122
+ "application/json": {
123
+ schema: {
124
+ type: "object";
125
+ properties: {
126
+ session: {
127
+ $ref: string;
128
+ };
129
+ user: {
130
+ $ref: string;
131
+ };
132
+ };
133
+ };
134
+ };
135
+ };
136
+ };
137
+ };
138
+ };
139
+ };
140
+ }, {
141
+ token: string;
142
+ user: {
143
+ id: string;
144
+ createdAt: Date;
145
+ updatedAt: Date;
146
+ email: string;
147
+ emailVerified: boolean;
148
+ name: string;
149
+ image?: string | null | undefined;
150
+ };
151
+ session: {
152
+ id: string;
153
+ createdAt: Date;
154
+ updatedAt: Date;
155
+ userId: string;
156
+ expiresAt: Date;
157
+ token: string;
158
+ ipAddress?: string | null | undefined;
159
+ userAgent?: string | null | undefined;
160
+ };
161
+ }>;
162
+ };
163
+ rateLimit: {
164
+ pathMatcher(path: string): boolean;
165
+ window: number;
166
+ max: number;
167
+ }[];
168
+ options: import("better-auth/plugins").MagicLinkOptions;
169
+ }, import("better-auth/plugins").DefaultOrganizationPlugin<{
170
+ ac: {
171
+ newRole<const TRoleStatements extends import("better-auth/plugins").Statements>(statements: import("better-auth/plugins").RoleInput<{
172
+ readonly course: readonly ["create", "read", "update", "delete"];
173
+ readonly progress: readonly ["view"];
174
+ readonly community: readonly ["moderate"];
175
+ readonly organization: readonly ["update", "delete"];
176
+ readonly member: readonly ["create", "update", "delete"];
177
+ readonly invitation: readonly ["create", "cancel"];
178
+ readonly team: readonly ["create", "update", "delete"];
179
+ readonly ac: readonly ["create", "read", "update", "delete"];
180
+ }, TRoleStatements>): import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<TRoleStatements>, {
181
+ readonly course: readonly ["create", "read", "update", "delete"];
182
+ readonly progress: readonly ["view"];
183
+ readonly community: readonly ["moderate"];
184
+ readonly organization: readonly ["update", "delete"];
185
+ readonly member: readonly ["create", "update", "delete"];
186
+ readonly invitation: readonly ["create", "cancel"];
187
+ readonly team: readonly ["create", "update", "delete"];
188
+ readonly ac: readonly ["create", "read", "update", "delete"];
189
+ }>;
190
+ statements: {
191
+ readonly course: readonly ["create", "read", "update", "delete"];
192
+ readonly progress: readonly ["view"];
193
+ readonly community: readonly ["moderate"];
194
+ readonly organization: readonly ["update", "delete"];
195
+ readonly member: readonly ["create", "update", "delete"];
196
+ readonly invitation: readonly ["create", "cancel"];
197
+ readonly team: readonly ["create", "update", "delete"];
198
+ readonly ac: readonly ["create", "read", "update", "delete"];
199
+ };
200
+ };
201
+ roles: {
202
+ owner: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
203
+ readonly course: ["create", "read", "update", "delete"];
204
+ readonly progress: ["view"];
205
+ readonly community: ["moderate"];
206
+ readonly organization: readonly ["update", "delete"];
207
+ readonly member: readonly ["create", "update", "delete"];
208
+ readonly invitation: readonly ["create", "cancel"];
209
+ readonly team: readonly ["create", "update", "delete"];
210
+ readonly ac: readonly ["create", "read", "update", "delete"];
211
+ }>, {
212
+ readonly course: readonly ["create", "read", "update", "delete"];
213
+ readonly progress: readonly ["view"];
214
+ readonly community: readonly ["moderate"];
215
+ readonly organization: readonly ["update", "delete"];
216
+ readonly member: readonly ["create", "update", "delete"];
217
+ readonly invitation: readonly ["create", "cancel"];
218
+ readonly team: readonly ["create", "update", "delete"];
219
+ readonly ac: readonly ["create", "read", "update", "delete"];
220
+ }>;
221
+ admin: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
222
+ readonly course: ["create", "read", "update", "delete"];
223
+ readonly progress: ["view"];
224
+ readonly community: ["moderate"];
225
+ readonly organization: readonly ["update"];
226
+ readonly invitation: readonly ["create", "cancel"];
227
+ readonly member: readonly ["create", "update", "delete"];
228
+ readonly team: readonly ["create", "update", "delete"];
229
+ readonly ac: readonly ["create", "read", "update", "delete"];
230
+ }>, {
231
+ readonly course: readonly ["create", "read", "update", "delete"];
232
+ readonly progress: readonly ["view"];
233
+ readonly community: readonly ["moderate"];
234
+ readonly organization: readonly ["update", "delete"];
235
+ readonly member: readonly ["create", "update", "delete"];
236
+ readonly invitation: readonly ["create", "cancel"];
237
+ readonly team: readonly ["create", "update", "delete"];
238
+ readonly ac: readonly ["create", "read", "update", "delete"];
239
+ }>;
240
+ instructor: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
241
+ readonly course: ["read", "update"];
242
+ readonly progress: ["view"];
243
+ readonly community: ["moderate"];
244
+ }>, {
245
+ readonly course: readonly ["create", "read", "update", "delete"];
246
+ readonly progress: readonly ["view"];
247
+ readonly community: readonly ["moderate"];
248
+ readonly organization: readonly ["update", "delete"];
249
+ readonly member: readonly ["create", "update", "delete"];
250
+ readonly invitation: readonly ["create", "cancel"];
251
+ readonly team: readonly ["create", "update", "delete"];
252
+ readonly ac: readonly ["create", "read", "update", "delete"];
253
+ }>;
254
+ moderator: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
255
+ readonly course: ["read"];
256
+ readonly community: ["moderate"];
257
+ }>, {
258
+ readonly course: readonly ["create", "read", "update", "delete"];
259
+ readonly progress: readonly ["view"];
260
+ readonly community: readonly ["moderate"];
261
+ readonly organization: readonly ["update", "delete"];
262
+ readonly member: readonly ["create", "update", "delete"];
263
+ readonly invitation: readonly ["create", "cancel"];
264
+ readonly team: readonly ["create", "update", "delete"];
265
+ readonly ac: readonly ["create", "read", "update", "delete"];
266
+ }>;
267
+ student: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
268
+ readonly course: ["read"];
269
+ }>, {
270
+ readonly course: readonly ["create", "read", "update", "delete"];
271
+ readonly progress: readonly ["view"];
272
+ readonly community: readonly ["moderate"];
273
+ readonly organization: readonly ["update", "delete"];
274
+ readonly member: readonly ["create", "update", "delete"];
275
+ readonly invitation: readonly ["create", "cancel"];
276
+ readonly team: readonly ["create", "update", "delete"];
277
+ readonly ac: readonly ["create", "read", "update", "delete"];
278
+ }>;
279
+ };
280
+ creatorRole: string;
281
+ organizationHooks: Hooks;
282
+ }>, BetterAuthPlugin, ...BetterAuthPlugin[], BetterAuthPlugin, {
283
+ id: "custom-session";
284
+ version: string;
285
+ hooks: {
286
+ after: {
287
+ matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
288
+ handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
289
+ user: {
290
+ id: string;
291
+ createdAt: Date;
292
+ updatedAt: Date;
293
+ email: string;
294
+ emailVerified: boolean;
295
+ name: string;
296
+ image?: string | null | undefined;
297
+ };
298
+ session: {
299
+ id: string;
300
+ createdAt: Date;
301
+ updatedAt: Date;
302
+ userId: string;
303
+ expiresAt: Date;
304
+ token: string;
305
+ ipAddress?: string | null | undefined;
306
+ userAgent?: string | null | undefined;
307
+ };
308
+ activeMemberRole: string | null;
309
+ activeOrganization: {
310
+ id: string;
311
+ name: string;
312
+ slug: string;
313
+ } | null;
314
+ organizations: {
315
+ id: string;
316
+ name: string;
317
+ slug: string;
318
+ }[];
319
+ }[] | undefined>>;
320
+ }[];
321
+ };
322
+ endpoints: {
323
+ getSession: import("better-auth").StrictEndpoint<"/get-session", {
324
+ method: "GET";
325
+ query: import("better-auth").ZodOptional<import("better-auth").ZodObject<{
326
+ disableCookieCache: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
327
+ disableRefresh: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
328
+ }, import("zod/v4/core").$strip>>;
329
+ metadata: {
330
+ CUSTOM_SESSION: boolean;
331
+ openapi: {
332
+ description: string;
333
+ responses: {
334
+ "200": {
335
+ description: string;
336
+ content: {
337
+ "application/json": {
338
+ schema: {
339
+ type: "array";
340
+ nullable: boolean;
341
+ items: {
342
+ $ref: string;
343
+ };
344
+ };
345
+ };
346
+ };
347
+ };
348
+ };
349
+ };
350
+ };
351
+ requireHeaders: true;
352
+ }, {
353
+ user: {
354
+ id: string;
355
+ createdAt: Date;
356
+ updatedAt: Date;
357
+ email: string;
358
+ emailVerified: boolean;
359
+ name: string;
360
+ image?: string | null | undefined;
361
+ };
362
+ session: {
363
+ id: string;
364
+ createdAt: Date;
365
+ updatedAt: Date;
366
+ userId: string;
367
+ expiresAt: Date;
368
+ token: string;
369
+ ipAddress?: string | null | undefined;
370
+ userAgent?: string | null | undefined;
371
+ };
372
+ activeMemberRole: string | null;
373
+ activeOrganization: {
374
+ id: string;
375
+ name: string;
376
+ slug: string;
377
+ } | null;
378
+ organizations: {
379
+ id: string;
380
+ name: string;
381
+ slug: string;
382
+ }[];
383
+ } | null>;
384
+ };
385
+ $Infer: {
386
+ Session: {
387
+ user: {
388
+ id: string;
389
+ createdAt: Date;
390
+ updatedAt: Date;
391
+ email: string;
392
+ emailVerified: boolean;
393
+ name: string;
394
+ image?: string | null | undefined;
395
+ };
396
+ session: {
397
+ id: string;
398
+ createdAt: Date;
399
+ updatedAt: Date;
400
+ userId: string;
401
+ expiresAt: Date;
402
+ token: string;
403
+ ipAddress?: string | null | undefined;
404
+ userAgent?: string | null | undefined;
405
+ };
406
+ activeMemberRole: string | null;
407
+ activeOrganization: {
408
+ id: string;
409
+ name: string;
410
+ slug: string;
411
+ } | null;
412
+ organizations: {
413
+ id: string;
414
+ name: string;
415
+ slug: string;
416
+ }[];
417
+ };
418
+ };
419
+ options: import("better-auth/plugins").CustomSessionPluginOptions | undefined;
420
+ }];
421
+ hooks: {
422
+ before: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
423
+ context: {
424
+ body: Record<string, unknown>;
425
+ };
426
+ } | undefined>>;
427
+ };
428
+ databaseHooks: {
429
+ user: {
430
+ create: {
431
+ before: (user: import("better-auth").User & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
432
+ data: import("better-auth").User;
433
+ }>;
434
+ };
435
+ };
436
+ session: {
437
+ create: {
438
+ before: ((session: import("better-auth").Session & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null) => Promise<boolean | void | {
439
+ data: import("better-auth").Session & Record<string, unknown>;
440
+ }>) | undefined;
441
+ };
442
+ };
443
+ };
444
+ };
8
445
  declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth<{
9
446
  baseURL: string;
10
447
  secret: string;
@@ -29,7 +466,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
29
466
  httpOnly: true;
30
467
  };
31
468
  };
32
- database: (options: import("better-auth").BetterAuthOptions) => import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
469
+ database: (options: BetterAuthOptions) => import("better-auth").DBAdapter<BetterAuthOptions>;
33
470
  emailAndPassword: {
34
471
  enabled: true;
35
472
  sendResetPassword: (data: {
@@ -65,7 +502,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
65
502
  signInMagicLink: import("better-auth").StrictEndpoint<"/sign-in/magic-link", {
66
503
  method: "POST";
67
504
  requireHeaders: true;
68
- use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>)[];
505
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
69
506
  body: import("better-auth").ZodObject<{
70
507
  email: import("better-auth").ZodEmail;
71
508
  name: import("better-auth").ZodOptional<import("better-auth").ZodString>;
@@ -73,7 +510,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
73
510
  newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
74
511
  errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
75
512
  metadata: import("better-auth").ZodOptional<import("better-auth").ZodRecord<import("better-auth").ZodString, import("better-auth").ZodAny>>;
76
- }, $strip>;
513
+ }, import("zod/v4/core").$strip>;
77
514
  metadata: {
78
515
  openapi: {
79
516
  operationId: string;
@@ -107,8 +544,8 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
107
544
  callbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
108
545
  errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
109
546
  newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
110
- }, $strip>;
111
- use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>)[];
547
+ }, import("zod/v4/core").$strip>;
548
+ use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>[];
112
549
  requireHeaders: true;
113
550
  metadata: {
114
551
  openapi: {
@@ -170,6 +607,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
170
607
  newRole<const TRoleStatements extends import("better-auth/plugins").Statements>(statements: import("better-auth/plugins").RoleInput<{
171
608
  readonly course: readonly ["create", "read", "update", "delete"];
172
609
  readonly progress: readonly ["view"];
610
+ readonly community: readonly ["moderate"];
173
611
  readonly organization: readonly ["update", "delete"];
174
612
  readonly member: readonly ["create", "update", "delete"];
175
613
  readonly invitation: readonly ["create", "cancel"];
@@ -178,6 +616,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
178
616
  }, TRoleStatements>): import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<TRoleStatements>, {
179
617
  readonly course: readonly ["create", "read", "update", "delete"];
180
618
  readonly progress: readonly ["view"];
619
+ readonly community: readonly ["moderate"];
181
620
  readonly organization: readonly ["update", "delete"];
182
621
  readonly member: readonly ["create", "update", "delete"];
183
622
  readonly invitation: readonly ["create", "cancel"];
@@ -187,6 +626,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
187
626
  statements: {
188
627
  readonly course: readonly ["create", "read", "update", "delete"];
189
628
  readonly progress: readonly ["view"];
629
+ readonly community: readonly ["moderate"];
190
630
  readonly organization: readonly ["update", "delete"];
191
631
  readonly member: readonly ["create", "update", "delete"];
192
632
  readonly invitation: readonly ["create", "cancel"];
@@ -198,6 +638,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
198
638
  owner: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
199
639
  readonly course: ["create", "read", "update", "delete"];
200
640
  readonly progress: ["view"];
641
+ readonly community: ["moderate"];
201
642
  readonly organization: readonly ["update", "delete"];
202
643
  readonly member: readonly ["create", "update", "delete"];
203
644
  readonly invitation: readonly ["create", "cancel"];
@@ -206,6 +647,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
206
647
  }>, {
207
648
  readonly course: readonly ["create", "read", "update", "delete"];
208
649
  readonly progress: readonly ["view"];
650
+ readonly community: readonly ["moderate"];
209
651
  readonly organization: readonly ["update", "delete"];
210
652
  readonly member: readonly ["create", "update", "delete"];
211
653
  readonly invitation: readonly ["create", "cancel"];
@@ -215,6 +657,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
215
657
  admin: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
216
658
  readonly course: ["create", "read", "update", "delete"];
217
659
  readonly progress: ["view"];
660
+ readonly community: ["moderate"];
218
661
  readonly organization: readonly ["update"];
219
662
  readonly invitation: readonly ["create", "cancel"];
220
663
  readonly member: readonly ["create", "update", "delete"];
@@ -223,6 +666,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
223
666
  }>, {
224
667
  readonly course: readonly ["create", "read", "update", "delete"];
225
668
  readonly progress: readonly ["view"];
669
+ readonly community: readonly ["moderate"];
226
670
  readonly organization: readonly ["update", "delete"];
227
671
  readonly member: readonly ["create", "update", "delete"];
228
672
  readonly invitation: readonly ["create", "cancel"];
@@ -232,9 +676,24 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
232
676
  instructor: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
233
677
  readonly course: ["read", "update"];
234
678
  readonly progress: ["view"];
679
+ readonly community: ["moderate"];
680
+ }>, {
681
+ readonly course: readonly ["create", "read", "update", "delete"];
682
+ readonly progress: readonly ["view"];
683
+ readonly community: readonly ["moderate"];
684
+ readonly organization: readonly ["update", "delete"];
685
+ readonly member: readonly ["create", "update", "delete"];
686
+ readonly invitation: readonly ["create", "cancel"];
687
+ readonly team: readonly ["create", "update", "delete"];
688
+ readonly ac: readonly ["create", "read", "update", "delete"];
689
+ }>;
690
+ moderator: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
691
+ readonly course: ["read"];
692
+ readonly community: ["moderate"];
235
693
  }>, {
236
694
  readonly course: readonly ["create", "read", "update", "delete"];
237
695
  readonly progress: readonly ["view"];
696
+ readonly community: readonly ["moderate"];
238
697
  readonly organization: readonly ["update", "delete"];
239
698
  readonly member: readonly ["create", "update", "delete"];
240
699
  readonly invitation: readonly ["create", "cancel"];
@@ -246,6 +705,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
246
705
  }>, {
247
706
  readonly course: readonly ["create", "read", "update", "delete"];
248
707
  readonly progress: readonly ["view"];
708
+ readonly community: readonly ["moderate"];
249
709
  readonly organization: readonly ["update", "delete"];
250
710
  readonly member: readonly ["create", "update", "delete"];
251
711
  readonly invitation: readonly ["create", "cancel"];
@@ -255,13 +715,13 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
255
715
  };
256
716
  creatorRole: string;
257
717
  organizationHooks: Hooks;
258
- }>, {
718
+ }>, BetterAuthPlugin, ...BetterAuthPlugin[], BetterAuthPlugin, {
259
719
  id: "custom-session";
260
720
  version: string;
261
721
  hooks: {
262
722
  after: {
263
723
  matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
264
- handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
724
+ handler: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
265
725
  user: {
266
726
  id: string;
267
727
  createdAt: Date;
@@ -292,7 +752,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
292
752
  name: string;
293
753
  slug: string;
294
754
  }[];
295
- }[] | undefined>;
755
+ }[] | undefined>>;
296
756
  }[];
297
757
  };
298
758
  endpoints: {
@@ -301,7 +761,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
301
761
  query: import("better-auth").ZodOptional<import("better-auth").ZodObject<{
302
762
  disableCookieCache: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
303
763
  disableRefresh: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
304
- }, $strip>>;
764
+ }, import("zod/v4/core").$strip>>;
305
765
  metadata: {
306
766
  CUSTOM_SESSION: boolean;
307
767
  openapi: {
@@ -394,6 +854,13 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
394
854
  };
395
855
  options: import("better-auth/plugins").CustomSessionPluginOptions | undefined;
396
856
  }];
857
+ hooks: {
858
+ before: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
859
+ context: {
860
+ body: Record<string, unknown>;
861
+ };
862
+ } | undefined>>;
863
+ };
397
864
  databaseHooks: {
398
865
  user: {
399
866
  create: {
@@ -412,11 +879,70 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
412
879
  };
413
880
  }>;
414
881
  type Auth = ReturnType<typeof createAuth>;
415
- declare class BetterAuth implements SessionVerifier, OrgAdmin, SessionAdmin {
882
+ type JSONWebKeySet = {
883
+ keys: Array<Record<string, unknown>>;
884
+ };
885
+ type PluginApiKey = {
886
+ id: string;
887
+ name: string | null;
888
+ start: string | null;
889
+ referenceId: string;
890
+ metadata: unknown;
891
+ permissions: Record<string, string[]> | null;
892
+ createdAt: Date;
893
+ lastRequest: Date | null;
894
+ };
895
+ type PluginApi = {
896
+ getJwks(): Promise<JSONWebKeySet>;
897
+ verifyApiKey(input: {
898
+ body: {
899
+ key: string;
900
+ };
901
+ }): Promise<{
902
+ valid: boolean;
903
+ key: PluginApiKey | null;
904
+ }>;
905
+ createApiKey(input: {
906
+ body: {
907
+ name: string;
908
+ userId: string;
909
+ metadata: Record<string, unknown>;
910
+ permissions: Record<string, string[]>;
911
+ };
912
+ }): Promise<PluginApiKey & {
913
+ key: string;
914
+ }>;
915
+ listApiKeys(input: {
916
+ headers: Headers;
917
+ }): Promise<{
918
+ apiKeys: PluginApiKey[];
919
+ }>;
920
+ deleteApiKey(input: {
921
+ body: {
922
+ keyId: string;
923
+ };
924
+ headers: Headers;
925
+ }): Promise<unknown>;
926
+ };
927
+ declare class BetterAuth implements SessionVerifier, OrgAdmin, SessionAdmin, AccessTokenVerifier, AppAccessAdmin {
416
928
  protected auth: Auth;
417
929
  protected logger: Logger;
418
- constructor(opts: CreateAuthOptions);
930
+ protected mcp: CreateAuthOptions["mcp"];
931
+ protected issuer: string;
932
+ protected jwksCacheKey: {};
933
+ constructor(opts: CreateAuthOptions, auth?: Auth);
934
+ protected get pluginApi(): PluginApi;
419
935
  handler(request: Request): Promise<Response>;
936
+ authorizationServerMetadata(request: Request): Promise<Response>;
937
+ verifyAccess(request: AccessRequest): Promise<AccessGrant | null>;
938
+ protected verifyAccessToken(authorization: AccessTokenAuthorization, request: AccessRequest): Promise<AccessGrant | null>;
939
+ protected verifyApiKey(key: string): Promise<AccessGrant | null>;
940
+ protected sessionUserId(headers: HeaderBag): Promise<string>;
941
+ listConnectedApps(headers: HeaderBag, orgId: string): Promise<ConnectedApp[]>;
942
+ revokeConnectedApp(headers: HeaderBag, orgId: string, clientId: string): Promise<void>;
943
+ listApiKeys(headers: HeaderBag, orgId: string): Promise<ApiKeySummary[]>;
944
+ createApiKey(input: NewApiKey): Promise<CreatedApiKey>;
945
+ deleteApiKey(headers: HeaderBag, orgId: string, keyId: string): Promise<void>;
420
946
  verify(headers: IncomingHttpHeaders): Promise<ActiveSession | null>;
421
947
  /** Stamps the org onto the caller's session row. The 5-minute cookie cache
422
948
  * still holds the pre-stamp session, so callers refresh it client-side with
@@ -433,5 +959,5 @@ declare class BetterAuth implements SessionVerifier, OrgAdmin, SessionAdmin {
433
959
  protected resolveMemberId(ctx: MemberWriteContext, userExternalId: string): Promise<string>;
434
960
  }
435
961
  //#endregion
436
- export { Auth, BetterAuth, createAuth };
962
+ export { Auth, BetterAuth, buildAuthOptions, createAuth };
437
963
  //# sourceMappingURL=better-auth.d.ts.map