@rolder/kit 3.0.0-alpha.100 → 3.0.0-alpha.102

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