@megacorp-ai/auth-react 0.1.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.
@@ -0,0 +1,1607 @@
1
+ import * as better_auth_react from 'better-auth/react';
2
+ import * as better_auth_plugins_access from 'better-auth/plugins/access';
3
+ import * as better_auth_client_plugins from 'better-auth/client/plugins';
4
+ import * as zod_v4_core from 'zod/v4/core';
5
+ import * as zod from 'zod';
6
+ import * as better_call from 'better-call';
7
+ import * as better_auth from 'better-auth';
8
+ import * as better_auth_plugins_email_otp from 'better-auth/plugins/email-otp';
9
+ import * as _better_fetch_fetch from '@better-fetch/fetch';
10
+ import * as react from 'react';
11
+
12
+ interface CreateAuthClientOptions {
13
+ /** Origin of the API server. Omit when the app is served from the same origin. */
14
+ baseURL?: string;
15
+ }
16
+ /** Better Auth React client with the email-OTP and admin plugins. Cookies are sent automatically (same origin). */
17
+ declare function createAuthClient(opts?: CreateAuthClientOptions): better_auth_react.ReactAuthClient<{
18
+ basePath: string;
19
+ plugins: ({
20
+ id: "email-otp";
21
+ version: string;
22
+ $InferServerPlugin: ReturnType<(options: better_auth_plugins_email_otp.EmailOTPOptions) => {
23
+ id: "email-otp";
24
+ version: string;
25
+ init(ctx: better_auth.AuthContext): {
26
+ options: {
27
+ emailVerification: {
28
+ sendVerificationEmail(data: {
29
+ user: better_auth.User;
30
+ url: string;
31
+ token: string;
32
+ }, request: Request | undefined): Promise<void>;
33
+ };
34
+ };
35
+ } | undefined;
36
+ endpoints: {
37
+ sendVerificationOTP: better_call.StrictEndpoint<"/email-otp/send-verification-otp", {
38
+ method: "POST";
39
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>>[];
40
+ body: zod.ZodObject<{
41
+ email: zod.ZodString;
42
+ type: zod.ZodEnum<{
43
+ "sign-in": "sign-in";
44
+ "change-email": "change-email";
45
+ "email-verification": "email-verification";
46
+ "forget-password": "forget-password";
47
+ }>;
48
+ }, zod_v4_core.$strip>;
49
+ metadata: {
50
+ openapi: {
51
+ operationId: string;
52
+ description: string;
53
+ responses: {
54
+ 200: {
55
+ description: string;
56
+ content: {
57
+ "application/json": {
58
+ schema: {
59
+ type: "object";
60
+ properties: {
61
+ success: {
62
+ type: string;
63
+ };
64
+ };
65
+ };
66
+ };
67
+ };
68
+ };
69
+ };
70
+ };
71
+ };
72
+ }, {
73
+ success: boolean;
74
+ }>;
75
+ createVerificationOTP: better_call.StrictEndpoint<string, {
76
+ method: "POST";
77
+ body: zod.ZodObject<{
78
+ email: zod.ZodString;
79
+ type: zod.ZodEnum<{
80
+ "sign-in": "sign-in";
81
+ "change-email": "change-email";
82
+ "email-verification": "email-verification";
83
+ "forget-password": "forget-password";
84
+ }>;
85
+ }, zod_v4_core.$strip>;
86
+ metadata: {
87
+ openapi: {
88
+ operationId: string;
89
+ description: string;
90
+ responses: {
91
+ 200: {
92
+ description: string;
93
+ content: {
94
+ "application/json": {
95
+ schema: {
96
+ type: "string";
97
+ };
98
+ };
99
+ };
100
+ };
101
+ };
102
+ };
103
+ };
104
+ }, string>;
105
+ getVerificationOTP: better_call.StrictEndpoint<string, {
106
+ method: "GET";
107
+ query: zod.ZodObject<{
108
+ email: zod.ZodString;
109
+ type: zod.ZodEnum<{
110
+ "sign-in": "sign-in";
111
+ "change-email": "change-email";
112
+ "email-verification": "email-verification";
113
+ "forget-password": "forget-password";
114
+ }>;
115
+ }, zod_v4_core.$strip>;
116
+ metadata: {
117
+ openapi: {
118
+ operationId: string;
119
+ description: string;
120
+ responses: {
121
+ "200": {
122
+ description: string;
123
+ content: {
124
+ "application/json": {
125
+ schema: {
126
+ type: "object";
127
+ properties: {
128
+ otp: {
129
+ type: string;
130
+ nullable: boolean;
131
+ description: string;
132
+ };
133
+ };
134
+ required: string[];
135
+ };
136
+ };
137
+ };
138
+ };
139
+ };
140
+ };
141
+ };
142
+ }, {
143
+ otp: null;
144
+ } | {
145
+ otp: string;
146
+ }>;
147
+ checkVerificationOTP: better_call.StrictEndpoint<"/email-otp/check-verification-otp", {
148
+ method: "POST";
149
+ body: zod.ZodObject<{
150
+ email: zod.ZodString;
151
+ type: zod.ZodEnum<{
152
+ "sign-in": "sign-in";
153
+ "change-email": "change-email";
154
+ "email-verification": "email-verification";
155
+ "forget-password": "forget-password";
156
+ }>;
157
+ otp: zod.ZodString;
158
+ }, zod_v4_core.$strip>;
159
+ metadata: {
160
+ openapi: {
161
+ operationId: string;
162
+ description: string;
163
+ responses: {
164
+ 200: {
165
+ description: string;
166
+ content: {
167
+ "application/json": {
168
+ schema: {
169
+ type: "object";
170
+ properties: {
171
+ success: {
172
+ type: string;
173
+ };
174
+ };
175
+ };
176
+ };
177
+ };
178
+ };
179
+ };
180
+ };
181
+ };
182
+ }, {
183
+ success: boolean;
184
+ }>;
185
+ verifyEmailOTP: better_call.StrictEndpoint<"/email-otp/verify-email", {
186
+ method: "POST";
187
+ body: zod.ZodObject<{
188
+ email: zod.ZodString;
189
+ otp: zod.ZodString;
190
+ }, zod_v4_core.$strip>;
191
+ metadata: {
192
+ openapi: {
193
+ description: string;
194
+ responses: {
195
+ 200: {
196
+ description: string;
197
+ content: {
198
+ "application/json": {
199
+ schema: {
200
+ type: "object";
201
+ properties: {
202
+ status: {
203
+ type: string;
204
+ description: string;
205
+ enum: boolean[];
206
+ };
207
+ token: {
208
+ type: string;
209
+ nullable: boolean;
210
+ description: string;
211
+ };
212
+ user: {
213
+ $ref: string;
214
+ };
215
+ };
216
+ required: string[];
217
+ };
218
+ };
219
+ };
220
+ };
221
+ };
222
+ };
223
+ };
224
+ }, {
225
+ status: boolean;
226
+ token: string;
227
+ user: {
228
+ id: string;
229
+ createdAt: Date;
230
+ updatedAt: Date;
231
+ email: string;
232
+ emailVerified: boolean;
233
+ name: string;
234
+ image?: string | null | undefined;
235
+ } & Record<string, any>;
236
+ } | {
237
+ status: boolean;
238
+ token: null;
239
+ user: {
240
+ id: string;
241
+ createdAt: Date;
242
+ updatedAt: Date;
243
+ email: string;
244
+ emailVerified: boolean;
245
+ name: string;
246
+ image?: string | null | undefined;
247
+ } & Record<string, any>;
248
+ }>;
249
+ signInEmailOTP: better_call.StrictEndpoint<"/sign-in/email-otp", {
250
+ method: "POST";
251
+ body: zod.ZodIntersection<zod.ZodObject<{
252
+ email: zod.ZodString;
253
+ otp: zod.ZodString;
254
+ name: zod.ZodOptional<zod.ZodString>;
255
+ image: zod.ZodOptional<zod.ZodString>;
256
+ }, zod_v4_core.$strip>, zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
257
+ metadata: {
258
+ openapi: {
259
+ operationId: string;
260
+ description: string;
261
+ responses: {
262
+ 200: {
263
+ description: string;
264
+ content: {
265
+ "application/json": {
266
+ schema: {
267
+ type: "object";
268
+ properties: {
269
+ token: {
270
+ type: string;
271
+ description: string;
272
+ };
273
+ user: {
274
+ $ref: string;
275
+ };
276
+ };
277
+ required: string[];
278
+ };
279
+ };
280
+ };
281
+ };
282
+ };
283
+ };
284
+ };
285
+ }, {
286
+ token: string;
287
+ user: {
288
+ id: string;
289
+ createdAt: Date;
290
+ updatedAt: Date;
291
+ email: string;
292
+ emailVerified: boolean;
293
+ name: string;
294
+ image?: string | null | undefined;
295
+ };
296
+ }>;
297
+ requestPasswordResetEmailOTP: better_call.StrictEndpoint<"/email-otp/request-password-reset", {
298
+ method: "POST";
299
+ body: zod.ZodObject<{
300
+ email: zod.ZodString;
301
+ }, zod_v4_core.$strip>;
302
+ metadata: {
303
+ openapi: {
304
+ operationId: string;
305
+ description: string;
306
+ responses: {
307
+ 200: {
308
+ description: string;
309
+ content: {
310
+ "application/json": {
311
+ schema: {
312
+ type: "object";
313
+ properties: {
314
+ success: {
315
+ type: string;
316
+ description: string;
317
+ };
318
+ };
319
+ };
320
+ };
321
+ };
322
+ };
323
+ };
324
+ };
325
+ };
326
+ }, {
327
+ success: boolean;
328
+ }>;
329
+ forgetPasswordEmailOTP: better_call.StrictEndpoint<"/forget-password/email-otp", {
330
+ method: "POST";
331
+ body: zod.ZodObject<{
332
+ email: zod.ZodString;
333
+ }, zod_v4_core.$strip>;
334
+ metadata: {
335
+ openapi: {
336
+ operationId: string;
337
+ description: string;
338
+ responses: {
339
+ 200: {
340
+ description: string;
341
+ content: {
342
+ "application/json": {
343
+ schema: {
344
+ type: "object";
345
+ properties: {
346
+ success: {
347
+ type: string;
348
+ description: string;
349
+ };
350
+ };
351
+ };
352
+ };
353
+ };
354
+ };
355
+ };
356
+ };
357
+ };
358
+ }, {
359
+ success: boolean;
360
+ }>;
361
+ resetPasswordEmailOTP: better_call.StrictEndpoint<"/email-otp/reset-password", {
362
+ method: "POST";
363
+ body: zod.ZodObject<{
364
+ email: zod.ZodString;
365
+ otp: zod.ZodString;
366
+ password: zod.ZodString;
367
+ }, zod_v4_core.$strip>;
368
+ metadata: {
369
+ openapi: {
370
+ operationId: string;
371
+ description: string;
372
+ responses: {
373
+ 200: {
374
+ description: string;
375
+ content: {
376
+ "application/json": {
377
+ schema: {
378
+ type: "object";
379
+ properties: {
380
+ success: {
381
+ type: string;
382
+ };
383
+ };
384
+ };
385
+ };
386
+ };
387
+ };
388
+ };
389
+ };
390
+ };
391
+ }, {
392
+ success: boolean;
393
+ }>;
394
+ requestEmailChangeEmailOTP: better_call.StrictEndpoint<"/email-otp/request-email-change", {
395
+ method: "POST";
396
+ body: zod.ZodObject<{
397
+ newEmail: zod.ZodString;
398
+ otp: zod.ZodOptional<zod.ZodString>;
399
+ }, zod_v4_core.$strip>;
400
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
401
+ session: {
402
+ session: Record<string, any> & {
403
+ id: string;
404
+ createdAt: Date;
405
+ updatedAt: Date;
406
+ userId: string;
407
+ expiresAt: Date;
408
+ token: string;
409
+ ipAddress?: string | null | undefined;
410
+ userAgent?: string | null | undefined;
411
+ };
412
+ user: Record<string, any> & {
413
+ id: string;
414
+ createdAt: Date;
415
+ updatedAt: Date;
416
+ email: string;
417
+ emailVerified: boolean;
418
+ name: string;
419
+ image?: string | null | undefined;
420
+ };
421
+ };
422
+ }>>[];
423
+ metadata: {
424
+ openapi: {
425
+ operationId: string;
426
+ description: string;
427
+ responses: {
428
+ 200: {
429
+ description: string;
430
+ content: {
431
+ "application/json": {
432
+ schema: {
433
+ type: "object";
434
+ properties: {
435
+ success: {
436
+ type: string;
437
+ };
438
+ };
439
+ };
440
+ };
441
+ };
442
+ };
443
+ };
444
+ };
445
+ };
446
+ }, {
447
+ success: boolean;
448
+ }>;
449
+ changeEmailEmailOTP: better_call.StrictEndpoint<"/email-otp/change-email", {
450
+ method: "POST";
451
+ body: zod.ZodObject<{
452
+ newEmail: zod.ZodString;
453
+ otp: zod.ZodString;
454
+ }, zod_v4_core.$strip>;
455
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
456
+ session: {
457
+ session: Record<string, any> & {
458
+ id: string;
459
+ createdAt: Date;
460
+ updatedAt: Date;
461
+ userId: string;
462
+ expiresAt: Date;
463
+ token: string;
464
+ ipAddress?: string | null | undefined;
465
+ userAgent?: string | null | undefined;
466
+ };
467
+ user: Record<string, any> & {
468
+ id: string;
469
+ createdAt: Date;
470
+ updatedAt: Date;
471
+ email: string;
472
+ emailVerified: boolean;
473
+ name: string;
474
+ image?: string | null | undefined;
475
+ };
476
+ };
477
+ }>>[];
478
+ metadata: {
479
+ openapi: {
480
+ operationId: string;
481
+ description: string;
482
+ responses: {
483
+ 200: {
484
+ description: string;
485
+ content: {
486
+ "application/json": {
487
+ schema: {
488
+ type: "object";
489
+ properties: {
490
+ success: {
491
+ type: string;
492
+ };
493
+ };
494
+ };
495
+ };
496
+ };
497
+ };
498
+ };
499
+ };
500
+ };
501
+ }, {
502
+ success: boolean;
503
+ }>;
504
+ };
505
+ hooks: {
506
+ after: {
507
+ matcher(context: better_auth.HookEndpointContext): boolean;
508
+ handler: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>>;
509
+ }[];
510
+ };
511
+ rateLimit: ({
512
+ pathMatcher(path: string): path is "/email-otp/send-verification-otp";
513
+ window: number;
514
+ max: number;
515
+ } | {
516
+ pathMatcher(path: string): path is "/email-otp/check-verification-otp";
517
+ window: number;
518
+ max: number;
519
+ } | {
520
+ pathMatcher(path: string): path is "/email-otp/verify-email";
521
+ window: number;
522
+ max: number;
523
+ } | {
524
+ pathMatcher(path: string): path is "/sign-in/email-otp";
525
+ window: number;
526
+ max: number;
527
+ } | {
528
+ pathMatcher(path: string): path is "/email-otp/request-password-reset";
529
+ window: number;
530
+ max: number;
531
+ } | {
532
+ pathMatcher(path: string): path is "/email-otp/reset-password";
533
+ window: number;
534
+ max: number;
535
+ } | {
536
+ pathMatcher(path: string): path is "/forget-password/email-otp";
537
+ window: number;
538
+ max: number;
539
+ } | {
540
+ pathMatcher(path: string): path is "/email-otp/request-email-change";
541
+ window: number;
542
+ max: number;
543
+ } | {
544
+ pathMatcher(path: string): path is "/email-otp/change-email";
545
+ window: number;
546
+ max: number;
547
+ })[];
548
+ options: better_auth_plugins_email_otp.EmailOTPOptions;
549
+ $ERROR_CODES: {
550
+ OTP_EXPIRED: better_auth.RawError<"OTP_EXPIRED">;
551
+ INVALID_OTP: better_auth.RawError<"INVALID_OTP">;
552
+ TOO_MANY_ATTEMPTS: better_auth.RawError<"TOO_MANY_ATTEMPTS">;
553
+ };
554
+ }>;
555
+ atomListeners: {
556
+ matcher: (path: string) => path is "/email-otp/verify-email" | "/sign-in/email-otp" | "/email-otp/request-email-change";
557
+ signal: "$sessionSignal";
558
+ }[];
559
+ $ERROR_CODES: {
560
+ OTP_EXPIRED: better_auth.RawError<"OTP_EXPIRED">;
561
+ INVALID_OTP: better_auth.RawError<"INVALID_OTP">;
562
+ TOO_MANY_ATTEMPTS: better_auth.RawError<"TOO_MANY_ATTEMPTS">;
563
+ };
564
+ } | {
565
+ id: "admin-client";
566
+ version: string;
567
+ $InferServerPlugin: {
568
+ id: "admin";
569
+ version: string;
570
+ init(): {
571
+ options: {
572
+ databaseHooks: {
573
+ user: {
574
+ create: {
575
+ before(user: {
576
+ id: string;
577
+ createdAt: Date;
578
+ updatedAt: Date;
579
+ email: string;
580
+ emailVerified: boolean;
581
+ name: string;
582
+ image?: string | null | undefined;
583
+ } & Record<string, unknown>): Promise<{
584
+ data: {
585
+ id: string;
586
+ createdAt: Date;
587
+ updatedAt: Date;
588
+ email: string;
589
+ emailVerified: boolean;
590
+ name: string;
591
+ image?: string | null | undefined;
592
+ role: string;
593
+ };
594
+ }>;
595
+ };
596
+ };
597
+ session: {
598
+ create: {
599
+ before(session: {
600
+ id: string;
601
+ createdAt: Date;
602
+ updatedAt: Date;
603
+ userId: string;
604
+ expiresAt: Date;
605
+ token: string;
606
+ ipAddress?: string | null | undefined;
607
+ userAgent?: string | null | undefined;
608
+ } & Record<string, unknown>, ctx: better_auth.GenericEndpointContext | null): Promise<void>;
609
+ };
610
+ };
611
+ };
612
+ };
613
+ };
614
+ hooks: {
615
+ after: {
616
+ matcher(context: better_auth.HookEndpointContext): boolean;
617
+ handler: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<better_auth_client_plugins.SessionWithImpersonatedBy[] | undefined>>;
618
+ }[];
619
+ };
620
+ endpoints: {
621
+ setRole: better_call.StrictEndpoint<"/admin/set-role", {
622
+ method: "POST";
623
+ body: zod.ZodObject<{
624
+ userId: zod.ZodCoercedString<unknown>;
625
+ role: zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodString>]>;
626
+ }, zod_v4_core.$strip>;
627
+ requireHeaders: true;
628
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
629
+ session: {
630
+ user: better_auth_client_plugins.UserWithRole;
631
+ session: {
632
+ id: string;
633
+ createdAt: Date;
634
+ updatedAt: Date;
635
+ userId: string;
636
+ expiresAt: Date;
637
+ token: string;
638
+ ipAddress?: string | null | undefined;
639
+ userAgent?: string | null | undefined;
640
+ };
641
+ };
642
+ }>>[];
643
+ metadata: {
644
+ openapi: {
645
+ operationId: string;
646
+ summary: string;
647
+ description: string;
648
+ responses: {
649
+ 200: {
650
+ description: string;
651
+ content: {
652
+ "application/json": {
653
+ schema: {
654
+ type: "object";
655
+ properties: {
656
+ user: {
657
+ $ref: string;
658
+ };
659
+ };
660
+ };
661
+ };
662
+ };
663
+ };
664
+ };
665
+ };
666
+ $Infer: {
667
+ body: {
668
+ userId: string;
669
+ role: "user" | "admin" | ("user" | "admin")[];
670
+ };
671
+ };
672
+ };
673
+ }, {
674
+ user: better_auth_client_plugins.UserWithRole;
675
+ }>;
676
+ getUser: better_call.StrictEndpoint<"/admin/get-user", {
677
+ method: "GET";
678
+ query: zod.ZodObject<{
679
+ id: zod.ZodString;
680
+ }, zod_v4_core.$strip>;
681
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
682
+ session: {
683
+ user: better_auth_client_plugins.UserWithRole;
684
+ session: {
685
+ id: string;
686
+ createdAt: Date;
687
+ updatedAt: Date;
688
+ userId: string;
689
+ expiresAt: Date;
690
+ token: string;
691
+ ipAddress?: string | null | undefined;
692
+ userAgent?: string | null | undefined;
693
+ };
694
+ };
695
+ }>>[];
696
+ metadata: {
697
+ openapi: {
698
+ operationId: string;
699
+ summary: string;
700
+ description: string;
701
+ responses: {
702
+ 200: {
703
+ description: string;
704
+ content: {
705
+ "application/json": {
706
+ schema: {
707
+ type: "object";
708
+ properties: {
709
+ user: {
710
+ $ref: string;
711
+ };
712
+ };
713
+ };
714
+ };
715
+ };
716
+ };
717
+ };
718
+ };
719
+ };
720
+ }, better_auth_client_plugins.UserWithRole>;
721
+ createUser: better_call.StrictEndpoint<"/admin/create-user", {
722
+ method: "POST";
723
+ body: zod.ZodObject<{
724
+ email: zod.ZodString;
725
+ password: zod.ZodOptional<zod.ZodString>;
726
+ name: zod.ZodString;
727
+ role: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodString, zod.ZodArray<zod.ZodString>]>>;
728
+ data: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
729
+ }, zod_v4_core.$strip>;
730
+ metadata: {
731
+ openapi: {
732
+ operationId: string;
733
+ summary: string;
734
+ description: string;
735
+ responses: {
736
+ 200: {
737
+ description: string;
738
+ content: {
739
+ "application/json": {
740
+ schema: {
741
+ type: "object";
742
+ properties: {
743
+ user: {
744
+ $ref: string;
745
+ };
746
+ };
747
+ };
748
+ };
749
+ };
750
+ };
751
+ };
752
+ };
753
+ $Infer: {
754
+ body: {
755
+ email: string;
756
+ password?: string | undefined;
757
+ name: string;
758
+ role?: "user" | "admin" | ("user" | "admin")[] | undefined;
759
+ data?: Record<string, any> | undefined;
760
+ };
761
+ };
762
+ };
763
+ }, {
764
+ user: better_auth_client_plugins.UserWithRole;
765
+ }>;
766
+ adminUpdateUser: better_call.StrictEndpoint<"/admin/update-user", {
767
+ method: "POST";
768
+ body: zod.ZodObject<{
769
+ userId: zod.ZodCoercedString<unknown>;
770
+ data: zod.ZodRecord<zod.ZodAny, zod.ZodAny>;
771
+ }, zod_v4_core.$strip>;
772
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
773
+ session: {
774
+ user: better_auth_client_plugins.UserWithRole;
775
+ session: {
776
+ id: string;
777
+ createdAt: Date;
778
+ updatedAt: Date;
779
+ userId: string;
780
+ expiresAt: Date;
781
+ token: string;
782
+ ipAddress?: string | null | undefined;
783
+ userAgent?: string | null | undefined;
784
+ };
785
+ };
786
+ }>>[];
787
+ metadata: {
788
+ openapi: {
789
+ operationId: string;
790
+ summary: string;
791
+ description: string;
792
+ responses: {
793
+ 200: {
794
+ description: string;
795
+ content: {
796
+ "application/json": {
797
+ schema: {
798
+ type: "object";
799
+ properties: {
800
+ user: {
801
+ $ref: string;
802
+ };
803
+ };
804
+ };
805
+ };
806
+ };
807
+ };
808
+ };
809
+ };
810
+ };
811
+ }, better_auth_client_plugins.UserWithRole>;
812
+ listUsers: better_call.StrictEndpoint<"/admin/list-users", {
813
+ method: "GET";
814
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
815
+ session: {
816
+ user: better_auth_client_plugins.UserWithRole;
817
+ session: {
818
+ id: string;
819
+ createdAt: Date;
820
+ updatedAt: Date;
821
+ userId: string;
822
+ expiresAt: Date;
823
+ token: string;
824
+ ipAddress?: string | null | undefined;
825
+ userAgent?: string | null | undefined;
826
+ };
827
+ };
828
+ }>>[];
829
+ query: zod.ZodObject<{
830
+ searchValue: zod.ZodOptional<zod.ZodString>;
831
+ searchField: zod.ZodOptional<zod.ZodEnum<{
832
+ email: "email";
833
+ name: "name";
834
+ }>>;
835
+ searchOperator: zod.ZodOptional<zod.ZodEnum<{
836
+ contains: "contains";
837
+ starts_with: "starts_with";
838
+ ends_with: "ends_with";
839
+ }>>;
840
+ limit: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>>;
841
+ offset: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>>;
842
+ sortBy: zod.ZodOptional<zod.ZodString>;
843
+ sortDirection: zod.ZodOptional<zod.ZodEnum<{
844
+ asc: "asc";
845
+ desc: "desc";
846
+ }>>;
847
+ filterField: zod.ZodOptional<zod.ZodString>;
848
+ filterValue: zod.ZodOptional<zod.ZodUnion<[zod.ZodUnion<[zod.ZodUnion<[zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, zod.ZodBoolean]>, zod.ZodArray<zod.ZodString>]>, zod.ZodArray<zod.ZodNumber>]>>;
849
+ filterOperator: zod.ZodOptional<zod.ZodEnum<{
850
+ eq: "eq";
851
+ ne: "ne";
852
+ gt: "gt";
853
+ gte: "gte";
854
+ lt: "lt";
855
+ lte: "lte";
856
+ in: "in";
857
+ not_in: "not_in";
858
+ contains: "contains";
859
+ starts_with: "starts_with";
860
+ ends_with: "ends_with";
861
+ }>>;
862
+ }, zod_v4_core.$strip>;
863
+ metadata: {
864
+ openapi: {
865
+ operationId: string;
866
+ summary: string;
867
+ description: string;
868
+ responses: {
869
+ 200: {
870
+ description: string;
871
+ content: {
872
+ "application/json": {
873
+ schema: {
874
+ type: "object";
875
+ properties: {
876
+ users: {
877
+ type: string;
878
+ items: {
879
+ $ref: string;
880
+ };
881
+ };
882
+ total: {
883
+ type: string;
884
+ };
885
+ limit: {
886
+ type: string;
887
+ };
888
+ offset: {
889
+ type: string;
890
+ };
891
+ };
892
+ required: string[];
893
+ };
894
+ };
895
+ };
896
+ };
897
+ };
898
+ };
899
+ };
900
+ }, {
901
+ users: better_auth_client_plugins.UserWithRole[];
902
+ total: number;
903
+ }>;
904
+ listUserSessions: better_call.StrictEndpoint<"/admin/list-user-sessions", {
905
+ method: "POST";
906
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
907
+ session: {
908
+ user: better_auth_client_plugins.UserWithRole;
909
+ session: {
910
+ id: string;
911
+ createdAt: Date;
912
+ updatedAt: Date;
913
+ userId: string;
914
+ expiresAt: Date;
915
+ token: string;
916
+ ipAddress?: string | null | undefined;
917
+ userAgent?: string | null | undefined;
918
+ };
919
+ };
920
+ }>>[];
921
+ body: zod.ZodObject<{
922
+ userId: zod.ZodCoercedString<unknown>;
923
+ }, zod_v4_core.$strip>;
924
+ metadata: {
925
+ openapi: {
926
+ operationId: string;
927
+ summary: string;
928
+ description: string;
929
+ responses: {
930
+ 200: {
931
+ description: string;
932
+ content: {
933
+ "application/json": {
934
+ schema: {
935
+ type: "object";
936
+ properties: {
937
+ sessions: {
938
+ type: string;
939
+ items: {
940
+ $ref: string;
941
+ };
942
+ };
943
+ };
944
+ };
945
+ };
946
+ };
947
+ };
948
+ };
949
+ };
950
+ };
951
+ }, {
952
+ sessions: better_auth_client_plugins.SessionWithImpersonatedBy[];
953
+ }>;
954
+ unbanUser: better_call.StrictEndpoint<"/admin/unban-user", {
955
+ method: "POST";
956
+ body: zod.ZodObject<{
957
+ userId: zod.ZodCoercedString<unknown>;
958
+ }, zod_v4_core.$strip>;
959
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
960
+ session: {
961
+ user: better_auth_client_plugins.UserWithRole;
962
+ session: {
963
+ id: string;
964
+ createdAt: Date;
965
+ updatedAt: Date;
966
+ userId: string;
967
+ expiresAt: Date;
968
+ token: string;
969
+ ipAddress?: string | null | undefined;
970
+ userAgent?: string | null | undefined;
971
+ };
972
+ };
973
+ }>>[];
974
+ metadata: {
975
+ openapi: {
976
+ operationId: string;
977
+ summary: string;
978
+ description: string;
979
+ responses: {
980
+ 200: {
981
+ description: string;
982
+ content: {
983
+ "application/json": {
984
+ schema: {
985
+ type: "object";
986
+ properties: {
987
+ user: {
988
+ $ref: string;
989
+ };
990
+ };
991
+ };
992
+ };
993
+ };
994
+ };
995
+ };
996
+ };
997
+ };
998
+ }, {
999
+ user: better_auth_client_plugins.UserWithRole;
1000
+ }>;
1001
+ banUser: better_call.StrictEndpoint<"/admin/ban-user", {
1002
+ method: "POST";
1003
+ body: zod.ZodObject<{
1004
+ userId: zod.ZodCoercedString<unknown>;
1005
+ banReason: zod.ZodOptional<zod.ZodString>;
1006
+ banExpiresIn: zod.ZodOptional<zod.ZodNumber>;
1007
+ }, zod_v4_core.$strip>;
1008
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
1009
+ session: {
1010
+ user: better_auth_client_plugins.UserWithRole;
1011
+ session: {
1012
+ id: string;
1013
+ createdAt: Date;
1014
+ updatedAt: Date;
1015
+ userId: string;
1016
+ expiresAt: Date;
1017
+ token: string;
1018
+ ipAddress?: string | null | undefined;
1019
+ userAgent?: string | null | undefined;
1020
+ };
1021
+ };
1022
+ }>>[];
1023
+ metadata: {
1024
+ openapi: {
1025
+ operationId: string;
1026
+ summary: string;
1027
+ description: string;
1028
+ responses: {
1029
+ 200: {
1030
+ description: string;
1031
+ content: {
1032
+ "application/json": {
1033
+ schema: {
1034
+ type: "object";
1035
+ properties: {
1036
+ user: {
1037
+ $ref: string;
1038
+ };
1039
+ };
1040
+ };
1041
+ };
1042
+ };
1043
+ };
1044
+ };
1045
+ };
1046
+ };
1047
+ }, {
1048
+ user: better_auth_client_plugins.UserWithRole;
1049
+ }>;
1050
+ impersonateUser: better_call.StrictEndpoint<"/admin/impersonate-user", {
1051
+ method: "POST";
1052
+ body: zod.ZodObject<{
1053
+ userId: zod.ZodCoercedString<unknown>;
1054
+ }, zod_v4_core.$strip>;
1055
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
1056
+ session: {
1057
+ user: better_auth_client_plugins.UserWithRole;
1058
+ session: {
1059
+ id: string;
1060
+ createdAt: Date;
1061
+ updatedAt: Date;
1062
+ userId: string;
1063
+ expiresAt: Date;
1064
+ token: string;
1065
+ ipAddress?: string | null | undefined;
1066
+ userAgent?: string | null | undefined;
1067
+ };
1068
+ };
1069
+ }>>[];
1070
+ metadata: {
1071
+ openapi: {
1072
+ operationId: string;
1073
+ summary: string;
1074
+ description: string;
1075
+ responses: {
1076
+ 200: {
1077
+ description: string;
1078
+ content: {
1079
+ "application/json": {
1080
+ schema: {
1081
+ type: "object";
1082
+ properties: {
1083
+ session: {
1084
+ $ref: string;
1085
+ };
1086
+ user: {
1087
+ $ref: string;
1088
+ };
1089
+ };
1090
+ };
1091
+ };
1092
+ };
1093
+ };
1094
+ };
1095
+ };
1096
+ };
1097
+ }, {
1098
+ session: {
1099
+ id: string;
1100
+ createdAt: Date;
1101
+ updatedAt: Date;
1102
+ userId: string;
1103
+ expiresAt: Date;
1104
+ token: string;
1105
+ ipAddress?: string | null | undefined;
1106
+ userAgent?: string | null | undefined;
1107
+ };
1108
+ user: better_auth_client_plugins.UserWithRole;
1109
+ }>;
1110
+ stopImpersonating: better_call.StrictEndpoint<"/admin/stop-impersonating", {
1111
+ method: "POST";
1112
+ requireHeaders: true;
1113
+ }, {
1114
+ session: {
1115
+ id: string;
1116
+ createdAt: Date;
1117
+ updatedAt: Date;
1118
+ userId: string;
1119
+ expiresAt: Date;
1120
+ token: string;
1121
+ ipAddress?: string | null | undefined;
1122
+ userAgent?: string | null | undefined;
1123
+ } & Record<string, any>;
1124
+ user: {
1125
+ id: string;
1126
+ createdAt: Date;
1127
+ updatedAt: Date;
1128
+ email: string;
1129
+ emailVerified: boolean;
1130
+ name: string;
1131
+ image?: string | null | undefined;
1132
+ } & Record<string, any>;
1133
+ }>;
1134
+ revokeUserSession: better_call.StrictEndpoint<"/admin/revoke-user-session", {
1135
+ method: "POST";
1136
+ body: zod.ZodObject<{
1137
+ sessionToken: zod.ZodString;
1138
+ }, zod_v4_core.$strip>;
1139
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
1140
+ session: {
1141
+ user: better_auth_client_plugins.UserWithRole;
1142
+ session: {
1143
+ id: string;
1144
+ createdAt: Date;
1145
+ updatedAt: Date;
1146
+ userId: string;
1147
+ expiresAt: Date;
1148
+ token: string;
1149
+ ipAddress?: string | null | undefined;
1150
+ userAgent?: string | null | undefined;
1151
+ };
1152
+ };
1153
+ }>>[];
1154
+ metadata: {
1155
+ openapi: {
1156
+ operationId: string;
1157
+ summary: string;
1158
+ description: string;
1159
+ responses: {
1160
+ 200: {
1161
+ description: string;
1162
+ content: {
1163
+ "application/json": {
1164
+ schema: {
1165
+ type: "object";
1166
+ properties: {
1167
+ success: {
1168
+ type: string;
1169
+ };
1170
+ };
1171
+ };
1172
+ };
1173
+ };
1174
+ };
1175
+ };
1176
+ };
1177
+ };
1178
+ }, {
1179
+ success: boolean;
1180
+ }>;
1181
+ revokeUserSessions: better_call.StrictEndpoint<"/admin/revoke-user-sessions", {
1182
+ method: "POST";
1183
+ body: zod.ZodObject<{
1184
+ userId: zod.ZodCoercedString<unknown>;
1185
+ }, zod_v4_core.$strip>;
1186
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
1187
+ session: {
1188
+ user: better_auth_client_plugins.UserWithRole;
1189
+ session: {
1190
+ id: string;
1191
+ createdAt: Date;
1192
+ updatedAt: Date;
1193
+ userId: string;
1194
+ expiresAt: Date;
1195
+ token: string;
1196
+ ipAddress?: string | null | undefined;
1197
+ userAgent?: string | null | undefined;
1198
+ };
1199
+ };
1200
+ }>>[];
1201
+ metadata: {
1202
+ openapi: {
1203
+ operationId: string;
1204
+ summary: string;
1205
+ description: string;
1206
+ responses: {
1207
+ 200: {
1208
+ description: string;
1209
+ content: {
1210
+ "application/json": {
1211
+ schema: {
1212
+ type: "object";
1213
+ properties: {
1214
+ success: {
1215
+ type: string;
1216
+ };
1217
+ };
1218
+ };
1219
+ };
1220
+ };
1221
+ };
1222
+ };
1223
+ };
1224
+ };
1225
+ }, {
1226
+ success: boolean;
1227
+ }>;
1228
+ removeUser: better_call.StrictEndpoint<"/admin/remove-user", {
1229
+ method: "POST";
1230
+ body: zod.ZodObject<{
1231
+ userId: zod.ZodCoercedString<unknown>;
1232
+ }, zod_v4_core.$strip>;
1233
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
1234
+ session: {
1235
+ user: better_auth_client_plugins.UserWithRole;
1236
+ session: {
1237
+ id: string;
1238
+ createdAt: Date;
1239
+ updatedAt: Date;
1240
+ userId: string;
1241
+ expiresAt: Date;
1242
+ token: string;
1243
+ ipAddress?: string | null | undefined;
1244
+ userAgent?: string | null | undefined;
1245
+ };
1246
+ };
1247
+ }>>[];
1248
+ metadata: {
1249
+ openapi: {
1250
+ operationId: string;
1251
+ summary: string;
1252
+ description: string;
1253
+ responses: {
1254
+ 200: {
1255
+ description: string;
1256
+ content: {
1257
+ "application/json": {
1258
+ schema: {
1259
+ type: "object";
1260
+ properties: {
1261
+ success: {
1262
+ type: string;
1263
+ };
1264
+ };
1265
+ };
1266
+ };
1267
+ };
1268
+ };
1269
+ };
1270
+ };
1271
+ };
1272
+ }, {
1273
+ success: boolean;
1274
+ }>;
1275
+ setUserPassword: better_call.StrictEndpoint<"/admin/set-user-password", {
1276
+ method: "POST";
1277
+ body: zod.ZodObject<{
1278
+ newPassword: zod.ZodString;
1279
+ userId: zod.ZodCoercedString<unknown>;
1280
+ }, zod_v4_core.$strip>;
1281
+ use: better_call.Middleware<better_call.MiddlewareOptions, (inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
1282
+ session: {
1283
+ user: better_auth_client_plugins.UserWithRole;
1284
+ session: {
1285
+ id: string;
1286
+ createdAt: Date;
1287
+ updatedAt: Date;
1288
+ userId: string;
1289
+ expiresAt: Date;
1290
+ token: string;
1291
+ ipAddress?: string | null | undefined;
1292
+ userAgent?: string | null | undefined;
1293
+ };
1294
+ };
1295
+ }>>[];
1296
+ metadata: {
1297
+ openapi: {
1298
+ operationId: string;
1299
+ summary: string;
1300
+ description: string;
1301
+ responses: {
1302
+ 200: {
1303
+ description: string;
1304
+ content: {
1305
+ "application/json": {
1306
+ schema: {
1307
+ type: "object";
1308
+ properties: {
1309
+ status: {
1310
+ type: string;
1311
+ };
1312
+ };
1313
+ };
1314
+ };
1315
+ };
1316
+ };
1317
+ };
1318
+ };
1319
+ };
1320
+ }, {
1321
+ status: boolean;
1322
+ }>;
1323
+ userHasPermission: better_call.StrictEndpoint<"/admin/has-permission", {
1324
+ method: "POST";
1325
+ body: zod.ZodIntersection<zod.ZodObject<{
1326
+ userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
1327
+ role: zod.ZodOptional<zod.ZodString>;
1328
+ }, zod_v4_core.$strip>, zod.ZodXor<readonly [zod.ZodObject<{
1329
+ permission: zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>;
1330
+ }, zod_v4_core.$strip>, zod.ZodObject<{
1331
+ permissions: zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>;
1332
+ }, zod_v4_core.$strip>]>>;
1333
+ metadata: {
1334
+ openapi: {
1335
+ description: string;
1336
+ requestBody: {
1337
+ content: {
1338
+ "application/json": {
1339
+ schema: {
1340
+ type: "object";
1341
+ properties: {
1342
+ permissions: {
1343
+ type: string;
1344
+ description: string;
1345
+ };
1346
+ };
1347
+ required: string[];
1348
+ };
1349
+ };
1350
+ };
1351
+ };
1352
+ responses: {
1353
+ "200": {
1354
+ description: string;
1355
+ content: {
1356
+ "application/json": {
1357
+ schema: {
1358
+ type: "object";
1359
+ properties: {
1360
+ error: {
1361
+ type: string;
1362
+ };
1363
+ success: {
1364
+ type: string;
1365
+ };
1366
+ };
1367
+ required: string[];
1368
+ };
1369
+ };
1370
+ };
1371
+ };
1372
+ };
1373
+ };
1374
+ $Infer: {
1375
+ body: {
1376
+ permissions: {
1377
+ readonly user?: ("create" | "list" | "set-role" | "ban" | "impersonate" | "impersonate-admins" | "delete" | "set-password" | "set-email" | "get" | "update")[] | undefined;
1378
+ readonly session?: ("list" | "delete" | "revoke")[] | undefined;
1379
+ };
1380
+ } & {
1381
+ userId?: string | undefined;
1382
+ role?: "user" | "admin" | undefined;
1383
+ };
1384
+ };
1385
+ };
1386
+ }, {
1387
+ error: null;
1388
+ success: boolean;
1389
+ }>;
1390
+ };
1391
+ $ERROR_CODES: {
1392
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: better_auth.RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
1393
+ FAILED_TO_CREATE_USER: better_auth.RawError<"FAILED_TO_CREATE_USER">;
1394
+ USER_ALREADY_EXISTS: better_auth.RawError<"USER_ALREADY_EXISTS">;
1395
+ YOU_CANNOT_BAN_YOURSELF: better_auth.RawError<"YOU_CANNOT_BAN_YOURSELF">;
1396
+ YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
1397
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
1398
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS">;
1399
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS">;
1400
+ YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS">;
1401
+ YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS">;
1402
+ YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS">;
1403
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS">;
1404
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD">;
1405
+ BANNED_USER: better_auth.RawError<"BANNED_USER">;
1406
+ YOU_ARE_NOT_ALLOWED_TO_GET_USER: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_USER">;
1407
+ NO_DATA_TO_UPDATE: better_auth.RawError<"NO_DATA_TO_UPDATE">;
1408
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS">;
1409
+ YOU_CANNOT_REMOVE_YOURSELF: better_auth.RawError<"YOU_CANNOT_REMOVE_YOURSELF">;
1410
+ YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE">;
1411
+ YOU_CANNOT_IMPERSONATE_ADMINS: better_auth.RawError<"YOU_CANNOT_IMPERSONATE_ADMINS">;
1412
+ INVALID_ROLE_TYPE: better_auth.RawError<"INVALID_ROLE_TYPE">;
1413
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL">;
1414
+ PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: better_auth.RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
1415
+ };
1416
+ schema: {
1417
+ user: {
1418
+ fields: {
1419
+ role: {
1420
+ type: "string";
1421
+ required: false;
1422
+ input: false;
1423
+ };
1424
+ banned: {
1425
+ type: "boolean";
1426
+ defaultValue: false;
1427
+ required: false;
1428
+ input: false;
1429
+ };
1430
+ banReason: {
1431
+ type: "string";
1432
+ required: false;
1433
+ input: false;
1434
+ };
1435
+ banExpires: {
1436
+ type: "date";
1437
+ required: false;
1438
+ input: false;
1439
+ };
1440
+ };
1441
+ };
1442
+ session: {
1443
+ fields: {
1444
+ impersonatedBy: {
1445
+ type: "string";
1446
+ required: false;
1447
+ input: false;
1448
+ };
1449
+ };
1450
+ };
1451
+ };
1452
+ options: NoInfer<{
1453
+ ac: better_auth_plugins_access.AccessControl<{
1454
+ readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
1455
+ readonly session: readonly ["list", "revoke", "delete"];
1456
+ }>;
1457
+ roles: {
1458
+ admin: better_auth_plugins_access.Role;
1459
+ user: better_auth_plugins_access.Role;
1460
+ };
1461
+ }>;
1462
+ };
1463
+ getActions: () => {
1464
+ admin: {
1465
+ checkRolePermission: <R extends "user" | "admin">(data: {
1466
+ permissions: {
1467
+ readonly user?: ("create" | "list" | "set-role" | "ban" | "impersonate" | "impersonate-admins" | "delete" | "set-password" | "set-email" | "get" | "update")[] | undefined;
1468
+ readonly session?: ("list" | "delete" | "revoke")[] | undefined;
1469
+ };
1470
+ } & {
1471
+ role: R;
1472
+ }) => boolean;
1473
+ };
1474
+ };
1475
+ pathMethods: {
1476
+ "/admin/list-users": "GET";
1477
+ "/admin/impersonate-user": "POST";
1478
+ "/admin/stop-impersonating": "POST";
1479
+ };
1480
+ atomListeners: {
1481
+ matcher: (path: string) => path is "/admin/impersonate-user" | "/admin/stop-impersonating";
1482
+ signal: "$sessionSignal";
1483
+ }[];
1484
+ $ERROR_CODES: {
1485
+ USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: better_auth.RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
1486
+ FAILED_TO_CREATE_USER: better_auth.RawError<"FAILED_TO_CREATE_USER">;
1487
+ USER_ALREADY_EXISTS: better_auth.RawError<"USER_ALREADY_EXISTS">;
1488
+ YOU_CANNOT_BAN_YOURSELF: better_auth.RawError<"YOU_CANNOT_BAN_YOURSELF">;
1489
+ YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
1490
+ YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
1491
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS">;
1492
+ YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS">;
1493
+ YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS">;
1494
+ YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS">;
1495
+ YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS">;
1496
+ YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS">;
1497
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD">;
1498
+ BANNED_USER: better_auth.RawError<"BANNED_USER">;
1499
+ YOU_ARE_NOT_ALLOWED_TO_GET_USER: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_GET_USER">;
1500
+ NO_DATA_TO_UPDATE: better_auth.RawError<"NO_DATA_TO_UPDATE">;
1501
+ YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS">;
1502
+ YOU_CANNOT_REMOVE_YOURSELF: better_auth.RawError<"YOU_CANNOT_REMOVE_YOURSELF">;
1503
+ YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE">;
1504
+ YOU_CANNOT_IMPERSONATE_ADMINS: better_auth.RawError<"YOU_CANNOT_IMPERSONATE_ADMINS">;
1505
+ INVALID_ROLE_TYPE: better_auth.RawError<"INVALID_ROLE_TYPE">;
1506
+ YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL: better_auth.RawError<"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL">;
1507
+ PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER: better_auth.RawError<"PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER">;
1508
+ };
1509
+ })[];
1510
+ baseURL?: string | undefined;
1511
+ }>;
1512
+ type AuthClient = ReturnType<typeof createAuthClient>;
1513
+
1514
+ type Role = "megacorp_admin" | "customer_admin" | "member";
1515
+ interface SessionUser {
1516
+ id: string;
1517
+ email: string;
1518
+ name: string;
1519
+ role?: string | null;
1520
+ banned?: boolean | null;
1521
+ }
1522
+ interface SessionData {
1523
+ user: SessionUser;
1524
+ session: {
1525
+ id: string;
1526
+ expiresAt: Date;
1527
+ impersonatedBy?: string | null;
1528
+ };
1529
+ }
1530
+ /** Wraps better-auth's useSession with a stable, typed shape. */
1531
+ declare function useSession(client: AuthClient): {
1532
+ data: SessionData | null;
1533
+ user: SessionUser | null;
1534
+ isPending: boolean;
1535
+ error: _better_fetch_fetch.BetterFetchError | null;
1536
+ refetch: (queryParams?: {
1537
+ query?: better_auth.SessionQueryParams;
1538
+ } | undefined) => Promise<void>;
1539
+ signOut: () => Promise<{
1540
+ data: {
1541
+ success: boolean;
1542
+ url: string | undefined;
1543
+ redirect: boolean | undefined;
1544
+ };
1545
+ error: null;
1546
+ } | {
1547
+ data: null;
1548
+ error: {
1549
+ code?: string | undefined | undefined;
1550
+ message?: string | undefined | undefined;
1551
+ status: number;
1552
+ statusText: string;
1553
+ };
1554
+ }>;
1555
+ };
1556
+ declare function parseRoles(role: string | null | undefined): Role[];
1557
+ /** Role helpers for the signed-in user. */
1558
+ declare function useRole(client: AuthClient): {
1559
+ roles: Role[];
1560
+ isPending: boolean;
1561
+ hasRole: (...allowed: Role[]) => boolean;
1562
+ isMegacorpAdmin: boolean;
1563
+ isCustomerAdmin: boolean;
1564
+ canInvite: boolean;
1565
+ };
1566
+
1567
+ interface SignInClassNames {
1568
+ root?: string;
1569
+ form?: string;
1570
+ label?: string;
1571
+ input?: string;
1572
+ button?: string;
1573
+ secondaryButton?: string;
1574
+ error?: string;
1575
+ hint?: string;
1576
+ }
1577
+ interface SignInProps {
1578
+ client: AuthClient;
1579
+ /** Prefill the email (invite links pass ?email=). */
1580
+ initialEmail?: string;
1581
+ onSignedIn?: () => void;
1582
+ classNames?: SignInClassNames;
1583
+ labels?: Partial<typeof defaultLabels>;
1584
+ }
1585
+ declare const defaultLabels: {
1586
+ email: string;
1587
+ sendCode: string;
1588
+ code: string;
1589
+ verify: string;
1590
+ resend: string;
1591
+ changeEmail: string;
1592
+ sent: string;
1593
+ unknownEmail: string;
1594
+ };
1595
+ /** Unstyled two-step email OTP sign-in. Pass classNames to style. */
1596
+ declare function SignIn({ client, initialEmail, onSignedIn, classNames: c, labels: l }: SignInProps): react.JSX.Element;
1597
+
1598
+ interface ImpersonationBannerProps {
1599
+ client: AuthClient;
1600
+ className?: string;
1601
+ buttonClassName?: string;
1602
+ onStopped?: () => void;
1603
+ }
1604
+ /** Renders only while the current session is an admin impersonation. */
1605
+ declare function ImpersonationBanner({ client, className, buttonClassName, onStopped }: ImpersonationBannerProps): react.JSX.Element | null;
1606
+
1607
+ export { type AuthClient, type CreateAuthClientOptions, ImpersonationBanner, type ImpersonationBannerProps, type Role, type SessionData, type SessionUser, SignIn, type SignInClassNames, type SignInProps, createAuthClient, parseRoles, useRole, useSession };