@headless-lms/adapter-auth 0.1.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,14 +466,34 @@ 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: {
36
- user: import("better-auth").User;
473
+ user: {
474
+ id: string;
475
+ createdAt: Date;
476
+ updatedAt: Date;
477
+ email: string;
478
+ emailVerified: boolean;
479
+ name: string;
480
+ image?: string | null | undefined;
481
+ };
37
482
  url: string;
38
483
  token: string;
39
- }, request?: Request) => Promise<void>;
484
+ }, request?: Request | undefined) => Promise<void>;
485
+ onPasswordReset: (data: {
486
+ user: {
487
+ id: string;
488
+ createdAt: Date;
489
+ updatedAt: Date;
490
+ email: string;
491
+ emailVerified: boolean;
492
+ name: string;
493
+ image?: string | null | undefined;
494
+ };
495
+ }, request?: Request | undefined) => Promise<void>;
496
+ revokeSessionsOnPasswordReset: true;
40
497
  };
41
498
  plugins: [{
42
499
  id: "magic-link";
@@ -45,7 +502,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
45
502
  signInMagicLink: import("better-auth").StrictEndpoint<"/sign-in/magic-link", {
46
503
  method: "POST";
47
504
  requireHeaders: true;
48
- 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>>[];
49
506
  body: import("better-auth").ZodObject<{
50
507
  email: import("better-auth").ZodEmail;
51
508
  name: import("better-auth").ZodOptional<import("better-auth").ZodString>;
@@ -53,7 +510,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
53
510
  newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
54
511
  errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
55
512
  metadata: import("better-auth").ZodOptional<import("better-auth").ZodRecord<import("better-auth").ZodString, import("better-auth").ZodAny>>;
56
- }, $strip>;
513
+ }, import("zod/v4/core").$strip>;
57
514
  metadata: {
58
515
  openapi: {
59
516
  operationId: string;
@@ -87,8 +544,8 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
87
544
  callbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
88
545
  errorCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
89
546
  newUserCallbackURL: import("better-auth").ZodOptional<import("better-auth").ZodString>;
90
- }, $strip>;
91
- 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>>[];
92
549
  requireHeaders: true;
93
550
  metadata: {
94
551
  openapi: {
@@ -150,6 +607,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
150
607
  newRole<const TRoleStatements extends import("better-auth/plugins").Statements>(statements: import("better-auth/plugins").RoleInput<{
151
608
  readonly course: readonly ["create", "read", "update", "delete"];
152
609
  readonly progress: readonly ["view"];
610
+ readonly community: readonly ["moderate"];
153
611
  readonly organization: readonly ["update", "delete"];
154
612
  readonly member: readonly ["create", "update", "delete"];
155
613
  readonly invitation: readonly ["create", "cancel"];
@@ -158,6 +616,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
158
616
  }, TRoleStatements>): import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<TRoleStatements>, {
159
617
  readonly course: readonly ["create", "read", "update", "delete"];
160
618
  readonly progress: readonly ["view"];
619
+ readonly community: readonly ["moderate"];
161
620
  readonly organization: readonly ["update", "delete"];
162
621
  readonly member: readonly ["create", "update", "delete"];
163
622
  readonly invitation: readonly ["create", "cancel"];
@@ -167,6 +626,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
167
626
  statements: {
168
627
  readonly course: readonly ["create", "read", "update", "delete"];
169
628
  readonly progress: readonly ["view"];
629
+ readonly community: readonly ["moderate"];
170
630
  readonly organization: readonly ["update", "delete"];
171
631
  readonly member: readonly ["create", "update", "delete"];
172
632
  readonly invitation: readonly ["create", "cancel"];
@@ -178,6 +638,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
178
638
  owner: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
179
639
  readonly course: ["create", "read", "update", "delete"];
180
640
  readonly progress: ["view"];
641
+ readonly community: ["moderate"];
181
642
  readonly organization: readonly ["update", "delete"];
182
643
  readonly member: readonly ["create", "update", "delete"];
183
644
  readonly invitation: readonly ["create", "cancel"];
@@ -186,6 +647,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
186
647
  }>, {
187
648
  readonly course: readonly ["create", "read", "update", "delete"];
188
649
  readonly progress: readonly ["view"];
650
+ readonly community: readonly ["moderate"];
189
651
  readonly organization: readonly ["update", "delete"];
190
652
  readonly member: readonly ["create", "update", "delete"];
191
653
  readonly invitation: readonly ["create", "cancel"];
@@ -195,6 +657,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
195
657
  admin: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
196
658
  readonly course: ["create", "read", "update", "delete"];
197
659
  readonly progress: ["view"];
660
+ readonly community: ["moderate"];
198
661
  readonly organization: readonly ["update"];
199
662
  readonly invitation: readonly ["create", "cancel"];
200
663
  readonly member: readonly ["create", "update", "delete"];
@@ -203,6 +666,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
203
666
  }>, {
204
667
  readonly course: readonly ["create", "read", "update", "delete"];
205
668
  readonly progress: readonly ["view"];
669
+ readonly community: readonly ["moderate"];
206
670
  readonly organization: readonly ["update", "delete"];
207
671
  readonly member: readonly ["create", "update", "delete"];
208
672
  readonly invitation: readonly ["create", "cancel"];
@@ -212,9 +676,24 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
212
676
  instructor: import("better-auth/plugins").Role<import("better-auth/plugins").ExactRoleStatements<{
213
677
  readonly course: ["read", "update"];
214
678
  readonly progress: ["view"];
679
+ readonly community: ["moderate"];
215
680
  }>, {
216
681
  readonly course: readonly ["create", "read", "update", "delete"];
217
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"];
693
+ }>, {
694
+ readonly course: readonly ["create", "read", "update", "delete"];
695
+ readonly progress: readonly ["view"];
696
+ readonly community: readonly ["moderate"];
218
697
  readonly organization: readonly ["update", "delete"];
219
698
  readonly member: readonly ["create", "update", "delete"];
220
699
  readonly invitation: readonly ["create", "cancel"];
@@ -226,6 +705,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
226
705
  }>, {
227
706
  readonly course: readonly ["create", "read", "update", "delete"];
228
707
  readonly progress: readonly ["view"];
708
+ readonly community: readonly ["moderate"];
229
709
  readonly organization: readonly ["update", "delete"];
230
710
  readonly member: readonly ["create", "update", "delete"];
231
711
  readonly invitation: readonly ["create", "cancel"];
@@ -235,13 +715,13 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
235
715
  };
236
716
  creatorRole: string;
237
717
  organizationHooks: Hooks;
238
- }>, {
718
+ }>, BetterAuthPlugin, ...BetterAuthPlugin[], BetterAuthPlugin, {
239
719
  id: "custom-session";
240
720
  version: string;
241
721
  hooks: {
242
722
  after: {
243
723
  matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
244
- 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<{
245
725
  user: {
246
726
  id: string;
247
727
  createdAt: Date;
@@ -272,7 +752,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
272
752
  name: string;
273
753
  slug: string;
274
754
  }[];
275
- }[] | undefined>;
755
+ }[] | undefined>>;
276
756
  }[];
277
757
  };
278
758
  endpoints: {
@@ -281,7 +761,7 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
281
761
  query: import("better-auth").ZodOptional<import("better-auth").ZodObject<{
282
762
  disableCookieCache: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
283
763
  disableRefresh: import("better-auth").ZodOptional<import("better-auth").ZodCoercedBoolean<unknown>>;
284
- }, $strip>>;
764
+ }, import("zod/v4/core").$strip>>;
285
765
  metadata: {
286
766
  CUSTOM_SESSION: boolean;
287
767
  openapi: {
@@ -374,6 +854,13 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
374
854
  };
375
855
  options: import("better-auth/plugins").CustomSessionPluginOptions | undefined;
376
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
+ };
377
864
  databaseHooks: {
378
865
  user: {
379
866
  create: {
@@ -392,11 +879,70 @@ declare function createAuth(opts: CreateAuthOptions): import("better-auth").Auth
392
879
  };
393
880
  }>;
394
881
  type Auth = ReturnType<typeof createAuth>;
395
- 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 {
396
928
  protected auth: Auth;
397
929
  protected logger: Logger;
398
- 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;
399
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>;
400
946
  verify(headers: IncomingHttpHeaders): Promise<ActiveSession | null>;
401
947
  /** Stamps the org onto the caller's session row. The 5-minute cookie cache
402
948
  * still holds the pre-stamp session, so callers refresh it client-side with
@@ -413,5 +959,5 @@ declare class BetterAuth implements SessionVerifier, OrgAdmin, SessionAdmin {
413
959
  protected resolveMemberId(ctx: MemberWriteContext, userExternalId: string): Promise<string>;
414
960
  }
415
961
  //#endregion
416
- export { Auth, BetterAuth, createAuth };
962
+ export { Auth, BetterAuth, buildAuthOptions, createAuth };
417
963
  //# sourceMappingURL=better-auth.d.ts.map