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