@rolder/kit 3.0.0-alpha.101 → 3.0.0-alpha.103

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,3 +1,1243 @@
1
- import type { BetterAuthOptions, BetterAuthPlugin } from 'better-auth';
2
- export declare const defaultAuthServerPlugins: BetterAuthPlugin[];
3
- export declare const defaultAuthServerConfig: BetterAuthOptions;
1
+ import { type JwtOptions } from 'better-auth/plugins';
2
+ export declare const defaultServerPluginOptions: {
3
+ admin: {
4
+ bannedUserMessage: string;
5
+ };
6
+ jwt: {
7
+ jwks: {
8
+ keyPairConfig: {
9
+ alg: "EdDSA";
10
+ crv: "Ed25519";
11
+ };
12
+ };
13
+ jwt: {
14
+ issuer: string;
15
+ audience: string;
16
+ expirationTime: string;
17
+ definePayload: ({ user, session }: {
18
+ user: import("better-auth").User & Record<string, any>;
19
+ session: import("better-auth").Session & Record<string, any>;
20
+ }) => {
21
+ id: string;
22
+ ns: string;
23
+ db: string;
24
+ ac: string;
25
+ email: string;
26
+ name: string;
27
+ role: string;
28
+ sessionId: string;
29
+ };
30
+ };
31
+ };
32
+ };
33
+ export declare const defaultAuthServerConfig: {
34
+ baseURL: string;
35
+ secret: string | undefined;
36
+ database: (options: Parameters<import("better-auth/adapters").AdapterFactory>[0]) => import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
37
+ experimental: {
38
+ joins: boolean;
39
+ };
40
+ emailAndPassword: {
41
+ enabled: boolean;
42
+ };
43
+ plugins: ({
44
+ id: "username";
45
+ init(ctx: import("better-auth").AuthContext): {
46
+ options: {
47
+ databaseHooks: {
48
+ user: {
49
+ create: {
50
+ before(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
+ } & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null): Promise<{
59
+ data: {
60
+ displayUsername?: string | undefined;
61
+ username?: string | undefined;
62
+ id: string;
63
+ createdAt: Date;
64
+ updatedAt: Date;
65
+ email: string;
66
+ emailVerified: boolean;
67
+ name: string;
68
+ image?: string | null | undefined;
69
+ };
70
+ }>;
71
+ };
72
+ update: {
73
+ before(user: Partial<{
74
+ id: string;
75
+ createdAt: Date;
76
+ updatedAt: Date;
77
+ email: string;
78
+ emailVerified: boolean;
79
+ name: string;
80
+ image?: string | null | undefined;
81
+ }> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null): Promise<{
82
+ data: {
83
+ displayUsername?: string | undefined;
84
+ username?: string | undefined;
85
+ id?: string | undefined;
86
+ createdAt?: Date | undefined;
87
+ updatedAt?: Date | undefined;
88
+ email?: string | undefined;
89
+ emailVerified?: boolean | undefined;
90
+ name?: string | undefined;
91
+ image?: string | null | undefined;
92
+ };
93
+ }>;
94
+ };
95
+ };
96
+ };
97
+ };
98
+ };
99
+ endpoints: {
100
+ signInUsername: import("better-auth").StrictEndpoint<"/sign-in/username", {
101
+ method: "POST";
102
+ body: import("zod").ZodObject<{
103
+ username: import("zod").ZodString;
104
+ password: import("zod").ZodString;
105
+ rememberMe: import("zod").ZodOptional<import("zod").ZodBoolean>;
106
+ callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
107
+ }, import("better-auth").$strip>;
108
+ metadata: {
109
+ openapi: {
110
+ summary: string;
111
+ description: string;
112
+ responses: {
113
+ 200: {
114
+ description: string;
115
+ content: {
116
+ "application/json": {
117
+ schema: {
118
+ type: "object";
119
+ properties: {
120
+ token: {
121
+ type: string;
122
+ description: string;
123
+ };
124
+ user: {
125
+ $ref: string;
126
+ };
127
+ };
128
+ required: string[];
129
+ };
130
+ };
131
+ };
132
+ };
133
+ 422: {
134
+ description: string;
135
+ content: {
136
+ "application/json": {
137
+ schema: {
138
+ type: "object";
139
+ properties: {
140
+ message: {
141
+ type: string;
142
+ };
143
+ };
144
+ };
145
+ };
146
+ };
147
+ };
148
+ };
149
+ };
150
+ };
151
+ }, {
152
+ token: string;
153
+ user: {
154
+ id: string;
155
+ createdAt: Date;
156
+ updatedAt: Date;
157
+ email: string;
158
+ emailVerified: boolean;
159
+ name: string;
160
+ image?: string | null | undefined;
161
+ } & {
162
+ username: string;
163
+ displayUsername: string;
164
+ };
165
+ } | null>;
166
+ isUsernameAvailable: import("better-auth").StrictEndpoint<"/is-username-available", {
167
+ method: "POST";
168
+ body: import("zod").ZodObject<{
169
+ username: import("zod").ZodString;
170
+ }, import("better-auth").$strip>;
171
+ }, {
172
+ available: boolean;
173
+ }>;
174
+ };
175
+ schema: {
176
+ user: {
177
+ fields: {
178
+ username: {
179
+ type: "string";
180
+ required: false;
181
+ sortable: true;
182
+ unique: true;
183
+ returned: true;
184
+ transform: {
185
+ input(value: import("better-auth").DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
186
+ };
187
+ };
188
+ displayUsername: {
189
+ type: "string";
190
+ required: false;
191
+ transform: {
192
+ input(value: import("better-auth").DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
193
+ };
194
+ };
195
+ };
196
+ };
197
+ };
198
+ hooks: {
199
+ before: {
200
+ matcher(context: import("better-auth").HookEndpointContext): boolean;
201
+ handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>;
202
+ }[];
203
+ };
204
+ options: import("better-auth/plugins").UsernameOptions | undefined;
205
+ $ERROR_CODES: {
206
+ readonly INVALID_USERNAME_OR_PASSWORD: "Invalid username or password";
207
+ readonly EMAIL_NOT_VERIFIED: "Email not verified";
208
+ readonly UNEXPECTED_ERROR: "Unexpected error";
209
+ readonly USERNAME_IS_ALREADY_TAKEN: "Username is already taken. Please try another.";
210
+ readonly USERNAME_TOO_SHORT: "Username is too short";
211
+ readonly USERNAME_TOO_LONG: "Username is too long";
212
+ readonly INVALID_USERNAME: "Username is invalid";
213
+ readonly INVALID_DISPLAY_USERNAME: "Display username is invalid";
214
+ };
215
+ } | {
216
+ id: "admin";
217
+ init(): {
218
+ options: {
219
+ databaseHooks: {
220
+ user: {
221
+ create: {
222
+ before(user: {
223
+ id: string;
224
+ createdAt: Date;
225
+ updatedAt: Date;
226
+ email: string;
227
+ emailVerified: boolean;
228
+ name: string;
229
+ image?: string | null | undefined;
230
+ } & Record<string, unknown>): Promise<{
231
+ data: {
232
+ id: string;
233
+ createdAt: Date;
234
+ updatedAt: Date;
235
+ email: string;
236
+ emailVerified: boolean;
237
+ name: string;
238
+ image?: string | null | undefined;
239
+ role: string;
240
+ };
241
+ }>;
242
+ };
243
+ };
244
+ session: {
245
+ create: {
246
+ before(session: {
247
+ id: string;
248
+ createdAt: Date;
249
+ updatedAt: Date;
250
+ userId: string;
251
+ expiresAt: Date;
252
+ token: string;
253
+ ipAddress?: string | null | undefined;
254
+ userAgent?: string | null | undefined;
255
+ } & Record<string, unknown>, ctx: import("better-auth").GenericEndpointContext | null): Promise<void>;
256
+ };
257
+ };
258
+ };
259
+ };
260
+ };
261
+ hooks: {
262
+ after: {
263
+ matcher(context: import("better-auth").HookEndpointContext): boolean;
264
+ handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<import("better-auth/plugins").SessionWithImpersonatedBy[] | undefined>;
265
+ }[];
266
+ };
267
+ endpoints: {
268
+ setRole: import("better-auth").StrictEndpoint<"/admin/set-role", {
269
+ method: "POST";
270
+ body: import("zod").ZodObject<{
271
+ userId: import("zod").ZodCoercedString<unknown>;
272
+ role: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
273
+ }, import("better-auth").$strip>;
274
+ requireHeaders: true;
275
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
276
+ session: {
277
+ user: import("better-auth/plugins").UserWithRole;
278
+ session: import("better-auth").Session;
279
+ };
280
+ }>)[];
281
+ metadata: {
282
+ openapi: {
283
+ operationId: string;
284
+ summary: string;
285
+ description: string;
286
+ responses: {
287
+ 200: {
288
+ description: string;
289
+ content: {
290
+ "application/json": {
291
+ schema: {
292
+ type: "object";
293
+ properties: {
294
+ user: {
295
+ $ref: string;
296
+ };
297
+ };
298
+ };
299
+ };
300
+ };
301
+ };
302
+ };
303
+ };
304
+ $Infer: {
305
+ body: {
306
+ userId: string;
307
+ role: "user" | "admin" | ("user" | "admin")[];
308
+ };
309
+ };
310
+ };
311
+ }, {
312
+ user: import("better-auth/plugins").UserWithRole;
313
+ }>;
314
+ getUser: import("better-auth").StrictEndpoint<"/admin/get-user", {
315
+ method: "GET";
316
+ query: import("zod").ZodObject<{
317
+ id: import("zod").ZodString;
318
+ }, import("better-auth").$strip>;
319
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
320
+ session: {
321
+ user: import("better-auth/plugins").UserWithRole;
322
+ session: import("better-auth").Session;
323
+ };
324
+ }>)[];
325
+ metadata: {
326
+ openapi: {
327
+ operationId: string;
328
+ summary: string;
329
+ description: string;
330
+ responses: {
331
+ 200: {
332
+ description: string;
333
+ content: {
334
+ "application/json": {
335
+ schema: {
336
+ type: "object";
337
+ properties: {
338
+ user: {
339
+ $ref: string;
340
+ };
341
+ };
342
+ };
343
+ };
344
+ };
345
+ };
346
+ };
347
+ };
348
+ };
349
+ }, import("better-auth/plugins").UserWithRole>;
350
+ createUser: import("better-auth").StrictEndpoint<"/admin/create-user", {
351
+ method: "POST";
352
+ body: import("zod").ZodObject<{
353
+ email: import("zod").ZodString;
354
+ password: import("zod").ZodOptional<import("zod").ZodString>;
355
+ name: import("zod").ZodString;
356
+ role: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
357
+ data: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
358
+ }, import("better-auth").$strip>;
359
+ metadata: {
360
+ openapi: {
361
+ operationId: string;
362
+ summary: string;
363
+ description: string;
364
+ responses: {
365
+ 200: {
366
+ description: string;
367
+ content: {
368
+ "application/json": {
369
+ schema: {
370
+ type: "object";
371
+ properties: {
372
+ user: {
373
+ $ref: string;
374
+ };
375
+ };
376
+ };
377
+ };
378
+ };
379
+ };
380
+ };
381
+ };
382
+ $Infer: {
383
+ body: {
384
+ email: string;
385
+ password?: string | undefined;
386
+ name: string;
387
+ role?: "user" | "admin" | ("user" | "admin")[] | undefined;
388
+ data?: Record<string, any> | undefined;
389
+ };
390
+ };
391
+ };
392
+ }, {
393
+ user: import("better-auth/plugins").UserWithRole;
394
+ }>;
395
+ adminUpdateUser: import("better-auth").StrictEndpoint<"/admin/update-user", {
396
+ method: "POST";
397
+ body: import("zod").ZodObject<{
398
+ userId: import("zod").ZodCoercedString<unknown>;
399
+ data: import("zod").ZodRecord<import("zod").ZodAny, import("zod").ZodAny>;
400
+ }, import("better-auth").$strip>;
401
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
402
+ session: {
403
+ user: import("better-auth/plugins").UserWithRole;
404
+ session: import("better-auth").Session;
405
+ };
406
+ }>)[];
407
+ metadata: {
408
+ openapi: {
409
+ operationId: string;
410
+ summary: string;
411
+ description: string;
412
+ responses: {
413
+ 200: {
414
+ description: string;
415
+ content: {
416
+ "application/json": {
417
+ schema: {
418
+ type: "object";
419
+ properties: {
420
+ user: {
421
+ $ref: string;
422
+ };
423
+ };
424
+ };
425
+ };
426
+ };
427
+ };
428
+ };
429
+ };
430
+ };
431
+ }, import("better-auth/plugins").UserWithRole>;
432
+ listUsers: import("better-auth").StrictEndpoint<"/admin/list-users", {
433
+ method: "GET";
434
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
435
+ session: {
436
+ user: import("better-auth/plugins").UserWithRole;
437
+ session: import("better-auth").Session;
438
+ };
439
+ }>)[];
440
+ query: import("zod").ZodObject<{
441
+ searchValue: import("zod").ZodOptional<import("zod").ZodString>;
442
+ searchField: import("zod").ZodOptional<import("zod").ZodEnum<{
443
+ name: "name";
444
+ email: "email";
445
+ }>>;
446
+ searchOperator: import("zod").ZodOptional<import("zod").ZodEnum<{
447
+ contains: "contains";
448
+ starts_with: "starts_with";
449
+ ends_with: "ends_with";
450
+ }>>;
451
+ limit: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
452
+ offset: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>>;
453
+ sortBy: import("zod").ZodOptional<import("zod").ZodString>;
454
+ sortDirection: import("zod").ZodOptional<import("zod").ZodEnum<{
455
+ asc: "asc";
456
+ desc: "desc";
457
+ }>>;
458
+ filterField: import("zod").ZodOptional<import("zod").ZodString>;
459
+ filterValue: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, import("zod").ZodBoolean]>>;
460
+ filterOperator: import("zod").ZodOptional<import("zod").ZodEnum<{
461
+ eq: "eq";
462
+ ne: "ne";
463
+ lt: "lt";
464
+ lte: "lte";
465
+ gt: "gt";
466
+ gte: "gte";
467
+ contains: "contains";
468
+ }>>;
469
+ }, import("better-auth").$strip>;
470
+ metadata: {
471
+ openapi: {
472
+ operationId: string;
473
+ summary: string;
474
+ description: string;
475
+ responses: {
476
+ 200: {
477
+ description: string;
478
+ content: {
479
+ "application/json": {
480
+ schema: {
481
+ type: "object";
482
+ properties: {
483
+ users: {
484
+ type: string;
485
+ items: {
486
+ $ref: string;
487
+ };
488
+ };
489
+ total: {
490
+ type: string;
491
+ };
492
+ limit: {
493
+ type: string;
494
+ };
495
+ offset: {
496
+ type: string;
497
+ };
498
+ };
499
+ required: string[];
500
+ };
501
+ };
502
+ };
503
+ };
504
+ };
505
+ };
506
+ };
507
+ }, {
508
+ users: import("better-auth/plugins").UserWithRole[];
509
+ total: number;
510
+ limit: number | undefined;
511
+ offset: number | undefined;
512
+ } | {
513
+ users: never[];
514
+ total: number;
515
+ }>;
516
+ listUserSessions: import("better-auth").StrictEndpoint<"/admin/list-user-sessions", {
517
+ method: "POST";
518
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
519
+ session: {
520
+ user: import("better-auth/plugins").UserWithRole;
521
+ session: import("better-auth").Session;
522
+ };
523
+ }>)[];
524
+ body: import("zod").ZodObject<{
525
+ userId: import("zod").ZodCoercedString<unknown>;
526
+ }, import("better-auth").$strip>;
527
+ metadata: {
528
+ openapi: {
529
+ operationId: string;
530
+ summary: string;
531
+ description: string;
532
+ responses: {
533
+ 200: {
534
+ description: string;
535
+ content: {
536
+ "application/json": {
537
+ schema: {
538
+ type: "object";
539
+ properties: {
540
+ sessions: {
541
+ type: string;
542
+ items: {
543
+ $ref: string;
544
+ };
545
+ };
546
+ };
547
+ };
548
+ };
549
+ };
550
+ };
551
+ };
552
+ };
553
+ };
554
+ }, {
555
+ sessions: import("better-auth/plugins").SessionWithImpersonatedBy[];
556
+ }>;
557
+ unbanUser: import("better-auth").StrictEndpoint<"/admin/unban-user", {
558
+ method: "POST";
559
+ body: import("zod").ZodObject<{
560
+ userId: import("zod").ZodCoercedString<unknown>;
561
+ }, import("better-auth").$strip>;
562
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
563
+ session: {
564
+ user: import("better-auth/plugins").UserWithRole;
565
+ session: import("better-auth").Session;
566
+ };
567
+ }>)[];
568
+ metadata: {
569
+ openapi: {
570
+ operationId: string;
571
+ summary: string;
572
+ description: string;
573
+ responses: {
574
+ 200: {
575
+ description: string;
576
+ content: {
577
+ "application/json": {
578
+ schema: {
579
+ type: "object";
580
+ properties: {
581
+ user: {
582
+ $ref: string;
583
+ };
584
+ };
585
+ };
586
+ };
587
+ };
588
+ };
589
+ };
590
+ };
591
+ };
592
+ }, {
593
+ user: import("better-auth/plugins").UserWithRole;
594
+ }>;
595
+ banUser: import("better-auth").StrictEndpoint<"/admin/ban-user", {
596
+ method: "POST";
597
+ body: import("zod").ZodObject<{
598
+ userId: import("zod").ZodCoercedString<unknown>;
599
+ banReason: import("zod").ZodOptional<import("zod").ZodString>;
600
+ banExpiresIn: import("zod").ZodOptional<import("zod").ZodNumber>;
601
+ }, import("better-auth").$strip>;
602
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
603
+ session: {
604
+ user: import("better-auth/plugins").UserWithRole;
605
+ session: import("better-auth").Session;
606
+ };
607
+ }>)[];
608
+ metadata: {
609
+ openapi: {
610
+ operationId: string;
611
+ summary: string;
612
+ description: string;
613
+ responses: {
614
+ 200: {
615
+ description: string;
616
+ content: {
617
+ "application/json": {
618
+ schema: {
619
+ type: "object";
620
+ properties: {
621
+ user: {
622
+ $ref: string;
623
+ };
624
+ };
625
+ };
626
+ };
627
+ };
628
+ };
629
+ };
630
+ };
631
+ };
632
+ }, {
633
+ user: import("better-auth/plugins").UserWithRole;
634
+ }>;
635
+ impersonateUser: import("better-auth").StrictEndpoint<"/admin/impersonate-user", {
636
+ method: "POST";
637
+ body: import("zod").ZodObject<{
638
+ userId: import("zod").ZodCoercedString<unknown>;
639
+ }, import("better-auth").$strip>;
640
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
641
+ session: {
642
+ user: import("better-auth/plugins").UserWithRole;
643
+ session: import("better-auth").Session;
644
+ };
645
+ }>)[];
646
+ metadata: {
647
+ openapi: {
648
+ operationId: string;
649
+ summary: string;
650
+ description: string;
651
+ responses: {
652
+ 200: {
653
+ description: string;
654
+ content: {
655
+ "application/json": {
656
+ schema: {
657
+ type: "object";
658
+ properties: {
659
+ session: {
660
+ $ref: string;
661
+ };
662
+ user: {
663
+ $ref: string;
664
+ };
665
+ };
666
+ };
667
+ };
668
+ };
669
+ };
670
+ };
671
+ };
672
+ };
673
+ }, {
674
+ session: {
675
+ id: string;
676
+ createdAt: Date;
677
+ updatedAt: Date;
678
+ userId: string;
679
+ expiresAt: Date;
680
+ token: string;
681
+ ipAddress?: string | null | undefined;
682
+ userAgent?: string | null | undefined;
683
+ };
684
+ user: import("better-auth/plugins").UserWithRole;
685
+ }>;
686
+ stopImpersonating: import("better-auth").StrictEndpoint<"/admin/stop-impersonating", {
687
+ method: "POST";
688
+ requireHeaders: true;
689
+ }, {
690
+ session: {
691
+ id: string;
692
+ createdAt: Date;
693
+ updatedAt: Date;
694
+ userId: string;
695
+ expiresAt: Date;
696
+ token: string;
697
+ ipAddress?: string | null | undefined;
698
+ userAgent?: string | null | undefined;
699
+ } & Record<string, any>;
700
+ user: {
701
+ id: string;
702
+ createdAt: Date;
703
+ updatedAt: Date;
704
+ email: string;
705
+ emailVerified: boolean;
706
+ name: string;
707
+ image?: string | null | undefined;
708
+ } & Record<string, any>;
709
+ }>;
710
+ revokeUserSession: import("better-auth").StrictEndpoint<"/admin/revoke-user-session", {
711
+ method: "POST";
712
+ body: import("zod").ZodObject<{
713
+ sessionToken: import("zod").ZodString;
714
+ }, import("better-auth").$strip>;
715
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
716
+ session: {
717
+ user: import("better-auth/plugins").UserWithRole;
718
+ session: import("better-auth").Session;
719
+ };
720
+ }>)[];
721
+ metadata: {
722
+ openapi: {
723
+ operationId: string;
724
+ summary: string;
725
+ description: string;
726
+ responses: {
727
+ 200: {
728
+ description: string;
729
+ content: {
730
+ "application/json": {
731
+ schema: {
732
+ type: "object";
733
+ properties: {
734
+ success: {
735
+ type: string;
736
+ };
737
+ };
738
+ };
739
+ };
740
+ };
741
+ };
742
+ };
743
+ };
744
+ };
745
+ }, {
746
+ success: boolean;
747
+ }>;
748
+ revokeUserSessions: import("better-auth").StrictEndpoint<"/admin/revoke-user-sessions", {
749
+ method: "POST";
750
+ body: import("zod").ZodObject<{
751
+ userId: import("zod").ZodCoercedString<unknown>;
752
+ }, import("better-auth").$strip>;
753
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
754
+ session: {
755
+ user: import("better-auth/plugins").UserWithRole;
756
+ session: import("better-auth").Session;
757
+ };
758
+ }>)[];
759
+ metadata: {
760
+ openapi: {
761
+ operationId: string;
762
+ summary: string;
763
+ description: string;
764
+ responses: {
765
+ 200: {
766
+ description: string;
767
+ content: {
768
+ "application/json": {
769
+ schema: {
770
+ type: "object";
771
+ properties: {
772
+ success: {
773
+ type: string;
774
+ };
775
+ };
776
+ };
777
+ };
778
+ };
779
+ };
780
+ };
781
+ };
782
+ };
783
+ }, {
784
+ success: boolean;
785
+ }>;
786
+ removeUser: import("better-auth").StrictEndpoint<"/admin/remove-user", {
787
+ method: "POST";
788
+ body: import("zod").ZodObject<{
789
+ userId: import("zod").ZodCoercedString<unknown>;
790
+ }, import("better-auth").$strip>;
791
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
792
+ session: {
793
+ user: import("better-auth/plugins").UserWithRole;
794
+ session: import("better-auth").Session;
795
+ };
796
+ }>)[];
797
+ metadata: {
798
+ openapi: {
799
+ operationId: string;
800
+ summary: string;
801
+ description: string;
802
+ responses: {
803
+ 200: {
804
+ description: string;
805
+ content: {
806
+ "application/json": {
807
+ schema: {
808
+ type: "object";
809
+ properties: {
810
+ success: {
811
+ type: string;
812
+ };
813
+ };
814
+ };
815
+ };
816
+ };
817
+ };
818
+ };
819
+ };
820
+ };
821
+ }, {
822
+ success: boolean;
823
+ }>;
824
+ setUserPassword: import("better-auth").StrictEndpoint<"/admin/set-user-password", {
825
+ method: "POST";
826
+ body: import("zod").ZodObject<{
827
+ newPassword: import("zod").ZodString;
828
+ userId: import("zod").ZodCoercedString<unknown>;
829
+ }, import("better-auth").$strip>;
830
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
831
+ session: {
832
+ user: import("better-auth/plugins").UserWithRole;
833
+ session: import("better-auth").Session;
834
+ };
835
+ }>)[];
836
+ metadata: {
837
+ openapi: {
838
+ operationId: string;
839
+ summary: string;
840
+ description: string;
841
+ responses: {
842
+ 200: {
843
+ description: string;
844
+ content: {
845
+ "application/json": {
846
+ schema: {
847
+ type: "object";
848
+ properties: {
849
+ status: {
850
+ type: string;
851
+ };
852
+ };
853
+ };
854
+ };
855
+ };
856
+ };
857
+ };
858
+ };
859
+ };
860
+ }, {
861
+ status: boolean;
862
+ }>;
863
+ userHasPermission: import("better-auth").StrictEndpoint<"/admin/has-permission", {
864
+ method: "POST";
865
+ body: import("zod").ZodIntersection<import("zod").ZodObject<{
866
+ userId: import("zod").ZodOptional<import("zod").ZodCoercedString<unknown>>;
867
+ role: import("zod").ZodOptional<import("zod").ZodString>;
868
+ }, import("better-auth").$strip>, import("zod").ZodUnion<readonly [import("zod").ZodObject<{
869
+ permission: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>;
870
+ permissions: import("zod").ZodUndefined;
871
+ }, import("better-auth").$strip>, import("zod").ZodObject<{
872
+ permission: import("zod").ZodUndefined;
873
+ permissions: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>;
874
+ }, import("better-auth").$strip>]>>;
875
+ metadata: {
876
+ openapi: {
877
+ description: string;
878
+ requestBody: {
879
+ content: {
880
+ "application/json": {
881
+ schema: {
882
+ type: "object";
883
+ properties: {
884
+ permission: {
885
+ type: string;
886
+ description: string;
887
+ deprecated: boolean;
888
+ };
889
+ permissions: {
890
+ type: string;
891
+ description: string;
892
+ };
893
+ };
894
+ required: string[];
895
+ };
896
+ };
897
+ };
898
+ };
899
+ responses: {
900
+ "200": {
901
+ description: string;
902
+ content: {
903
+ "application/json": {
904
+ schema: {
905
+ type: "object";
906
+ properties: {
907
+ error: {
908
+ type: string;
909
+ };
910
+ success: {
911
+ type: string;
912
+ };
913
+ };
914
+ required: string[];
915
+ };
916
+ };
917
+ };
918
+ };
919
+ };
920
+ };
921
+ $Infer: {
922
+ body: ({
923
+ permission: {
924
+ readonly user?: ("list" | "create" | "update" | "set-role" | "ban" | "impersonate" | "delete" | "set-password" | "get")[] | undefined;
925
+ readonly session?: ("list" | "delete" | "revoke")[] | undefined;
926
+ };
927
+ permissions?: never | undefined;
928
+ } | {
929
+ permissions: {
930
+ readonly user?: ("list" | "create" | "update" | "set-role" | "ban" | "impersonate" | "delete" | "set-password" | "get")[] | undefined;
931
+ readonly session?: ("list" | "delete" | "revoke")[] | undefined;
932
+ };
933
+ permission?: never | undefined;
934
+ }) & {
935
+ userId?: string | undefined;
936
+ role?: "user" | "admin" | undefined;
937
+ };
938
+ };
939
+ };
940
+ }, {
941
+ error: null;
942
+ success: boolean;
943
+ }>;
944
+ };
945
+ $ERROR_CODES: {
946
+ readonly FAILED_TO_CREATE_USER: "Failed to create user";
947
+ readonly USER_ALREADY_EXISTS: "User already exists.";
948
+ readonly USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.";
949
+ readonly YOU_CANNOT_BAN_YOURSELF: "You cannot ban yourself";
950
+ readonly YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: "You are not allowed to change users role";
951
+ readonly YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: "You are not allowed to create users";
952
+ readonly YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: "You are not allowed to list users";
953
+ readonly YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: "You are not allowed to list users sessions";
954
+ readonly YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: "You are not allowed to ban users";
955
+ readonly YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: "You are not allowed to impersonate users";
956
+ readonly YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: "You are not allowed to revoke users sessions";
957
+ readonly YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: "You are not allowed to delete users";
958
+ readonly YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: "You are not allowed to set users password";
959
+ readonly BANNED_USER: "You have been banned from this application";
960
+ readonly YOU_ARE_NOT_ALLOWED_TO_GET_USER: "You are not allowed to get user";
961
+ readonly NO_DATA_TO_UPDATE: "No data to update";
962
+ readonly YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: "You are not allowed to update users";
963
+ readonly YOU_CANNOT_REMOVE_YOURSELF: "You cannot remove yourself";
964
+ readonly YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: "You are not allowed to set a non-existent role value";
965
+ readonly YOU_CANNOT_IMPERSONATE_ADMINS: "You cannot impersonate admins";
966
+ readonly INVALID_ROLE_TYPE: "Invalid role type";
967
+ };
968
+ schema: {
969
+ user: {
970
+ fields: {
971
+ role: {
972
+ type: "string";
973
+ required: false;
974
+ input: false;
975
+ };
976
+ banned: {
977
+ type: "boolean";
978
+ defaultValue: false;
979
+ required: false;
980
+ input: false;
981
+ };
982
+ banReason: {
983
+ type: "string";
984
+ required: false;
985
+ input: false;
986
+ };
987
+ banExpires: {
988
+ type: "date";
989
+ required: false;
990
+ input: false;
991
+ };
992
+ };
993
+ };
994
+ session: {
995
+ fields: {
996
+ impersonatedBy: {
997
+ type: "string";
998
+ required: false;
999
+ };
1000
+ };
1001
+ };
1002
+ };
1003
+ options: NoInfer<{
1004
+ bannedUserMessage: string;
1005
+ }>;
1006
+ } | {
1007
+ id: "jwt";
1008
+ options: NoInfer<{
1009
+ jwks: {
1010
+ keyPairConfig: {
1011
+ alg: "EdDSA";
1012
+ crv: "Ed25519";
1013
+ };
1014
+ };
1015
+ jwt: {
1016
+ issuer: string;
1017
+ audience: string;
1018
+ expirationTime: string;
1019
+ definePayload: ({ user, session }: {
1020
+ user: import("better-auth").User & Record<string, any>;
1021
+ session: import("better-auth").Session & Record<string, any>;
1022
+ }) => {
1023
+ id: string;
1024
+ ns: string;
1025
+ db: string;
1026
+ ac: string;
1027
+ email: string;
1028
+ name: string;
1029
+ role: string;
1030
+ sessionId: string;
1031
+ };
1032
+ };
1033
+ }>;
1034
+ endpoints: {
1035
+ getJwks: import("better-auth").StrictEndpoint<string, {
1036
+ method: "GET";
1037
+ metadata: {
1038
+ openapi: {
1039
+ operationId: string;
1040
+ description: string;
1041
+ responses: {
1042
+ "200": {
1043
+ description: string;
1044
+ content: {
1045
+ "application/json": {
1046
+ schema: {
1047
+ type: "object";
1048
+ properties: {
1049
+ keys: {
1050
+ type: string;
1051
+ description: string;
1052
+ items: {
1053
+ type: string;
1054
+ properties: {
1055
+ kid: {
1056
+ type: string;
1057
+ description: string;
1058
+ };
1059
+ kty: {
1060
+ type: string;
1061
+ description: string;
1062
+ };
1063
+ alg: {
1064
+ type: string;
1065
+ description: string;
1066
+ };
1067
+ use: {
1068
+ type: string;
1069
+ description: string;
1070
+ enum: string[];
1071
+ nullable: boolean;
1072
+ };
1073
+ n: {
1074
+ type: string;
1075
+ description: string;
1076
+ nullable: boolean;
1077
+ };
1078
+ e: {
1079
+ type: string;
1080
+ description: string;
1081
+ nullable: boolean;
1082
+ };
1083
+ crv: {
1084
+ type: string;
1085
+ description: string;
1086
+ nullable: boolean;
1087
+ };
1088
+ x: {
1089
+ type: string;
1090
+ description: string;
1091
+ nullable: boolean;
1092
+ };
1093
+ y: {
1094
+ type: string;
1095
+ description: string;
1096
+ nullable: boolean;
1097
+ };
1098
+ };
1099
+ required: string[];
1100
+ };
1101
+ };
1102
+ };
1103
+ required: string[];
1104
+ };
1105
+ };
1106
+ };
1107
+ };
1108
+ };
1109
+ };
1110
+ };
1111
+ }, import("better-auth").JSONWebKeySet>;
1112
+ getToken: import("better-auth").StrictEndpoint<"/token", {
1113
+ method: "GET";
1114
+ requireHeaders: true;
1115
+ use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
1116
+ session: {
1117
+ session: Record<string, any> & {
1118
+ id: string;
1119
+ createdAt: Date;
1120
+ updatedAt: Date;
1121
+ userId: string;
1122
+ expiresAt: Date;
1123
+ token: string;
1124
+ ipAddress?: string | null | undefined;
1125
+ userAgent?: string | null | undefined;
1126
+ };
1127
+ user: Record<string, any> & {
1128
+ id: string;
1129
+ createdAt: Date;
1130
+ updatedAt: Date;
1131
+ email: string;
1132
+ emailVerified: boolean;
1133
+ name: string;
1134
+ image?: string | null | undefined;
1135
+ };
1136
+ };
1137
+ }>)[];
1138
+ metadata: {
1139
+ openapi: {
1140
+ operationId: string;
1141
+ description: string;
1142
+ responses: {
1143
+ 200: {
1144
+ description: string;
1145
+ content: {
1146
+ "application/json": {
1147
+ schema: {
1148
+ type: "object";
1149
+ properties: {
1150
+ token: {
1151
+ type: string;
1152
+ };
1153
+ };
1154
+ };
1155
+ };
1156
+ };
1157
+ };
1158
+ };
1159
+ };
1160
+ };
1161
+ }, {
1162
+ token: string;
1163
+ }>;
1164
+ signJWT: import("better-auth").StrictEndpoint<string, {
1165
+ method: "POST";
1166
+ metadata: {
1167
+ $Infer: {
1168
+ body: {
1169
+ payload: import("better-auth").JWTPayload;
1170
+ overrideOptions?: JwtOptions | undefined;
1171
+ };
1172
+ };
1173
+ };
1174
+ body: import("zod").ZodObject<{
1175
+ payload: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>;
1176
+ overrideOptions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
1177
+ }, import("better-auth").$strip>;
1178
+ }, {
1179
+ token: string;
1180
+ }>;
1181
+ verifyJWT: import("better-auth").StrictEndpoint<string, {
1182
+ method: "POST";
1183
+ metadata: {
1184
+ $Infer: {
1185
+ body: {
1186
+ token: string;
1187
+ issuer?: string;
1188
+ };
1189
+ response: {
1190
+ payload: {
1191
+ sub: string;
1192
+ aud: string;
1193
+ [key: string]: any;
1194
+ } | null;
1195
+ };
1196
+ };
1197
+ };
1198
+ body: import("zod").ZodObject<{
1199
+ token: import("zod").ZodString;
1200
+ issuer: import("zod").ZodOptional<import("zod").ZodString>;
1201
+ }, import("better-auth").$strip>;
1202
+ }, {
1203
+ payload: (import("better-auth").JWTPayload & Required<Pick<import("better-auth").JWTPayload, "sub" | "aud">>) | null;
1204
+ }>;
1205
+ };
1206
+ hooks: {
1207
+ after: {
1208
+ matcher(context: import("better-auth").HookEndpointContext): boolean;
1209
+ handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>;
1210
+ }[];
1211
+ };
1212
+ schema: {
1213
+ jwks: {
1214
+ fields: {
1215
+ publicKey: {
1216
+ type: "string";
1217
+ required: true;
1218
+ };
1219
+ privateKey: {
1220
+ type: "string";
1221
+ required: true;
1222
+ };
1223
+ createdAt: {
1224
+ type: "date";
1225
+ required: true;
1226
+ };
1227
+ expiresAt: {
1228
+ type: "date";
1229
+ required: false;
1230
+ };
1231
+ };
1232
+ };
1233
+ };
1234
+ } | {
1235
+ id: "tanstack-start-cookies";
1236
+ hooks: {
1237
+ after: {
1238
+ matcher(ctx: import("better-auth").HookEndpointContext): true;
1239
+ handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>;
1240
+ }[];
1241
+ };
1242
+ })[];
1243
+ };
@@ -2,12 +2,11 @@ import { admin, jwt, username } from "better-auth/plugins";
2
2
  import { tanstackStartCookies } from "better-auth/tanstack-start";
3
3
  import { surrealDbAdapter } from "./surrealDbAdapter/index.js";
4
4
  const baseUrl = "/";
5
- const defaultAuthServerPlugins = [
6
- admin({
5
+ const defaultServerPluginOptions = {
6
+ admin: {
7
7
  bannedUserMessage: 'Доступ к приложению заблокирован. Обратитесь к администратору.'
8
- }),
9
- username(),
10
- jwt({
8
+ },
9
+ jwt: {
11
10
  jwks: {
12
11
  keyPairConfig: {
13
12
  alg: 'EdDSA',
@@ -29,9 +28,8 @@ const defaultAuthServerPlugins = [
29
28
  sessionId: session.id
30
29
  })
31
30
  }
32
- }),
33
- tanstackStartCookies()
34
- ];
31
+ }
32
+ };
35
33
  const defaultAuthServerConfig = {
36
34
  baseURL: baseUrl,
37
35
  secret: process.env.BETTER_AUTH_SECRET,
@@ -42,6 +40,11 @@ const defaultAuthServerConfig = {
42
40
  emailAndPassword: {
43
41
  enabled: true
44
42
  },
45
- plugins: defaultAuthServerPlugins
43
+ plugins: [
44
+ admin(defaultServerPluginOptions.admin),
45
+ username(),
46
+ jwt(defaultServerPluginOptions.jwt),
47
+ tanstackStartCookies()
48
+ ]
46
49
  };
47
- export { defaultAuthServerConfig, defaultAuthServerPlugins };
50
+ export { defaultAuthServerConfig, defaultServerPluginOptions };
@@ -1,6 +1,8 @@
1
+ export type * from 'better-auth/client/plugins';
1
2
  export * from 'better-auth/client/plugins';
2
3
  export type * from 'better-auth/minimal';
3
4
  export { betterAuth as betterAuthServer } from 'better-auth/minimal';
5
+ export type * from 'better-auth/plugins';
4
6
  export * from 'better-auth/plugins';
5
7
  export * from 'better-auth/plugins/admin/access';
6
8
  export * from 'better-auth/react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolder/kit",
3
- "version": "3.0.0-alpha.101",
3
+ "version": "3.0.0-alpha.103",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./ai": {