@podosoft/podokit-api-client 0.7.0 → 0.8.1

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.
package/README.md CHANGED
@@ -6,8 +6,10 @@ through this single entry point — never with a raw `fetch`.
6
6
  - `client.auth` — the [better-auth](https://better-auth.com) client (email/password,
7
7
  sessions, the `signupApproved` user field, and the admin plugin: `listUsers`,
8
8
  `updateUser`, `banUser`, `setRole`, `listUserSessions`, …).
9
- - `client.get/post/put/patch/del` — the app's REST endpoints, parsing the standard
10
- error envelope and throwing `ApiError` on failure.
9
+ - `client.get/post/put/patch/del` — the app's JSON REST endpoints, parsing the
10
+ standard error envelope and throwing `ApiError` on failure.
11
+ - `client.postForm` — multipart uploads with the browser-managed boundary and the
12
+ same credentials and error handling.
11
13
 
12
14
  ```ts
13
15
  import { createApiClient } from "@podosoft/podokit-api-client";
@@ -20,6 +22,11 @@ await api.auth.signIn.email({ email, password });
20
22
  // Server-side (SSR): point at the internal backend and forward cookies
21
23
  const api = createApiClient({ baseUrl: process.env.BACKEND_INTERNAL_URL, fetch });
22
24
  const session = await api.auth.getSession();
25
+
26
+ // Multipart upload
27
+ const form = new FormData();
28
+ form.set("file", imageFile);
29
+ await api.postForm("/account/profile-image", form);
23
30
  ```
24
31
 
25
32
  ## Options
@@ -35,3 +42,5 @@ const session = await api.auth.getSession();
35
42
  Errors are thrown as `ApiError` (`code`, `message`, `statusCode`, `details`).
36
43
  `PUBLIC_SIGNUP_DISABLED` and `SIGNUP_APPROVAL_REQUIRED` are re-exported for
37
44
  provider-independent registration-policy handling.
45
+ The profile-image policy, response type, and stable validation error codes are
46
+ also re-exported so account UIs can display the exact limits enforced by the API.
package/dist/index.d.ts CHANGED
@@ -20,7 +20,8 @@ export interface ApiClientOptions {
20
20
  */
21
21
  export type { Capabilities } from "@podosoft/podokit-contracts";
22
22
  /** Stable authentication policy error codes re-exported for browser clients. */
23
- export { PUBLIC_SIGNUP_DISABLED, SIGNUP_APPROVAL_REQUIRED, } from "@podosoft/podokit-contracts";
23
+ export { PROFILE_IMAGE_DIMENSIONS_INVALID, PROFILE_IMAGE_NOT_FOUND, PROFILE_IMAGE_POLICY, PROFILE_IMAGE_REQUIRED, PROFILE_IMAGE_TOO_LARGE, PROFILE_IMAGE_TYPE_INVALID, PUBLIC_SIGNUP_DISABLED, SIGNUP_APPROVAL_REQUIRED, } from "@podosoft/podokit-contracts";
24
+ export type { ProfileImageMimeType, ProfileImageResponse, } from "@podosoft/podokit-contracts";
24
25
  /** Error thrown when the API returns the standard error envelope or a non-2xx status. */
25
26
  export declare class ApiError extends Error {
26
27
  readonly code: string;
@@ -34,8 +35,10 @@ export declare class ApiError extends Error {
34
35
  *
35
36
  * - `client.auth` is the better-auth client (email/password, sessions, and the
36
37
  * admin plugin: `client.auth.admin.listUsers()`, `banUser`, `setRole`, ...).
37
- * - `client.get/post/put/patch/del` call the app's REST endpoints and parse the
38
- * standard error envelope, throwing {@link ApiError} on failure.
38
+ * - `client.get/post/put/patch/del` call the app's JSON REST endpoints and parse
39
+ * the standard error envelope, throwing {@link ApiError} on failure.
40
+ * - `client.postForm` sends multipart `FormData` without overriding the browser's
41
+ * boundary-aware content type.
39
42
  */
40
43
  export declare function createApiClient(options?: ApiClientOptions): {
41
44
  /** The better-auth client (auth + admin plugin), created on first access. */
@@ -94,7 +97,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
94
97
  hooks: {
95
98
  after: {
96
99
  matcher(context: import("better-auth").HookEndpointContext): boolean;
97
- handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<import("better-auth/client/plugins").SessionWithImpersonatedBy[] | undefined>;
100
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<import("better-auth/client/plugins").SessionWithImpersonatedBy[] | undefined>>;
98
101
  }[];
99
102
  };
100
103
  endpoints: {
@@ -105,7 +108,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
105
108
  role: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
106
109
  }, import("zod/v4/core").$strip>;
107
110
  requireHeaders: true;
108
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
111
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
109
112
  session: {
110
113
  user: import("better-auth/client/plugins").UserWithRole;
111
114
  session: {
@@ -119,7 +122,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
119
122
  userAgent?: string | null | undefined;
120
123
  };
121
124
  };
122
- }>)[];
125
+ }>>[];
123
126
  metadata: {
124
127
  openapi: {
125
128
  operationId: string;
@@ -158,7 +161,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
158
161
  query: import("zod").ZodObject<{
159
162
  id: import("zod").ZodString;
160
163
  }, import("zod/v4/core").$strip>;
161
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
164
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
162
165
  session: {
163
166
  user: import("better-auth/client/plugins").UserWithRole;
164
167
  session: {
@@ -172,7 +175,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
172
175
  userAgent?: string | null | undefined;
173
176
  };
174
177
  };
175
- }>)[];
178
+ }>>[];
176
179
  metadata: {
177
180
  openapi: {
178
181
  operationId: string;
@@ -249,7 +252,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
249
252
  userId: import("zod").ZodCoercedString<unknown>;
250
253
  data: import("zod").ZodRecord<import("zod").ZodAny, import("zod").ZodAny>;
251
254
  }, import("zod/v4/core").$strip>;
252
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
255
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
253
256
  session: {
254
257
  user: import("better-auth/client/plugins").UserWithRole;
255
258
  session: {
@@ -263,7 +266,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
263
266
  userAgent?: string | null | undefined;
264
267
  };
265
268
  };
266
- }>)[];
269
+ }>>[];
267
270
  metadata: {
268
271
  openapi: {
269
272
  operationId: string;
@@ -291,7 +294,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
291
294
  }, import("better-auth/client/plugins").UserWithRole>;
292
295
  listUsers: import("better-call").StrictEndpoint<"/admin/list-users", {
293
296
  method: "GET";
294
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
297
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
295
298
  session: {
296
299
  user: import("better-auth/client/plugins").UserWithRole;
297
300
  session: {
@@ -305,7 +308,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
305
308
  userAgent?: string | null | undefined;
306
309
  };
307
310
  };
308
- }>)[];
311
+ }>>[];
309
312
  query: import("zod").ZodObject<{
310
313
  searchValue: import("zod").ZodOptional<import("zod").ZodString>;
311
314
  searchField: import("zod").ZodOptional<import("zod").ZodEnum<{
@@ -383,7 +386,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
383
386
  }>;
384
387
  listUserSessions: import("better-call").StrictEndpoint<"/admin/list-user-sessions", {
385
388
  method: "POST";
386
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
389
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
387
390
  session: {
388
391
  user: import("better-auth/client/plugins").UserWithRole;
389
392
  session: {
@@ -397,7 +400,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
397
400
  userAgent?: string | null | undefined;
398
401
  };
399
402
  };
400
- }>)[];
403
+ }>>[];
401
404
  body: import("zod").ZodObject<{
402
405
  userId: import("zod").ZodCoercedString<unknown>;
403
406
  }, import("zod/v4/core").$strip>;
@@ -436,7 +439,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
436
439
  body: import("zod").ZodObject<{
437
440
  userId: import("zod").ZodCoercedString<unknown>;
438
441
  }, import("zod/v4/core").$strip>;
439
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
442
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
440
443
  session: {
441
444
  user: import("better-auth/client/plugins").UserWithRole;
442
445
  session: {
@@ -450,7 +453,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
450
453
  userAgent?: string | null | undefined;
451
454
  };
452
455
  };
453
- }>)[];
456
+ }>>[];
454
457
  metadata: {
455
458
  openapi: {
456
459
  operationId: string;
@@ -485,7 +488,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
485
488
  banReason: import("zod").ZodOptional<import("zod").ZodString>;
486
489
  banExpiresIn: import("zod").ZodOptional<import("zod").ZodNumber>;
487
490
  }, import("zod/v4/core").$strip>;
488
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
491
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
489
492
  session: {
490
493
  user: import("better-auth/client/plugins").UserWithRole;
491
494
  session: {
@@ -499,7 +502,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
499
502
  userAgent?: string | null | undefined;
500
503
  };
501
504
  };
502
- }>)[];
505
+ }>>[];
503
506
  metadata: {
504
507
  openapi: {
505
508
  operationId: string;
@@ -532,7 +535,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
532
535
  body: import("zod").ZodObject<{
533
536
  userId: import("zod").ZodCoercedString<unknown>;
534
537
  }, import("zod/v4/core").$strip>;
535
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
538
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
536
539
  session: {
537
540
  user: import("better-auth/client/plugins").UserWithRole;
538
541
  session: {
@@ -546,7 +549,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
546
549
  userAgent?: string | null | undefined;
547
550
  };
548
551
  };
549
- }>)[];
552
+ }>>[];
550
553
  metadata: {
551
554
  openapi: {
552
555
  operationId: string;
@@ -616,7 +619,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
616
619
  body: import("zod").ZodObject<{
617
620
  sessionToken: import("zod").ZodString;
618
621
  }, import("zod/v4/core").$strip>;
619
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
622
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
620
623
  session: {
621
624
  user: import("better-auth/client/plugins").UserWithRole;
622
625
  session: {
@@ -630,7 +633,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
630
633
  userAgent?: string | null | undefined;
631
634
  };
632
635
  };
633
- }>)[];
636
+ }>>[];
634
637
  metadata: {
635
638
  openapi: {
636
639
  operationId: string;
@@ -663,7 +666,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
663
666
  body: import("zod").ZodObject<{
664
667
  userId: import("zod").ZodCoercedString<unknown>;
665
668
  }, import("zod/v4/core").$strip>;
666
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
669
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
667
670
  session: {
668
671
  user: import("better-auth/client/plugins").UserWithRole;
669
672
  session: {
@@ -677,7 +680,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
677
680
  userAgent?: string | null | undefined;
678
681
  };
679
682
  };
680
- }>)[];
683
+ }>>[];
681
684
  metadata: {
682
685
  openapi: {
683
686
  operationId: string;
@@ -710,7 +713,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
710
713
  body: import("zod").ZodObject<{
711
714
  userId: import("zod").ZodCoercedString<unknown>;
712
715
  }, import("zod/v4/core").$strip>;
713
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
716
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
714
717
  session: {
715
718
  user: import("better-auth/client/plugins").UserWithRole;
716
719
  session: {
@@ -724,7 +727,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
724
727
  userAgent?: string | null | undefined;
725
728
  };
726
729
  };
727
- }>)[];
730
+ }>>[];
728
731
  metadata: {
729
732
  openapi: {
730
733
  operationId: string;
@@ -758,7 +761,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
758
761
  newPassword: import("zod").ZodString;
759
762
  userId: import("zod").ZodCoercedString<unknown>;
760
763
  }, import("zod/v4/core").$strip>;
761
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
764
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
762
765
  session: {
763
766
  user: import("better-auth/client/plugins").UserWithRole;
764
767
  session: {
@@ -772,7 +775,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
772
775
  userAgent?: string | null | undefined;
773
776
  };
774
777
  };
775
- }>)[];
778
+ }>>[];
776
779
  metadata: {
777
780
  openapi: {
778
781
  operationId: string;
@@ -997,12 +1000,20 @@ export declare function createApiClient(options?: ApiClientOptions): {
997
1000
  method: "POST";
998
1001
  body: import("zod").ZodObject<{
999
1002
  password: import("zod").ZodOptional<import("zod").ZodString>;
1003
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
1004
+ otp: "otp";
1005
+ totp: "totp";
1006
+ }>>;
1000
1007
  issuer: import("zod").ZodOptional<import("zod").ZodString>;
1001
1008
  }, import("zod/v4/core").$strip> | import("zod").ZodObject<{
1002
1009
  password: import("zod").ZodString;
1010
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
1011
+ otp: "otp";
1012
+ totp: "totp";
1013
+ }>>;
1003
1014
  issuer: import("zod").ZodOptional<import("zod").ZodString>;
1004
1015
  }, import("zod/v4/core").$strip>;
1005
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1016
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1006
1017
  session: {
1007
1018
  session: Record<string, any> & {
1008
1019
  id: string;
@@ -1024,7 +1035,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1024
1035
  image?: string | null | undefined;
1025
1036
  };
1026
1037
  };
1027
- }>)[];
1038
+ }>>[];
1028
1039
  metadata: {
1029
1040
  openapi: {
1030
1041
  summary: string;
@@ -1037,6 +1048,11 @@ export declare function createApiClient(options?: ApiClientOptions): {
1037
1048
  schema: {
1038
1049
  type: "object";
1039
1050
  properties: {
1051
+ method: {
1052
+ type: string;
1053
+ enum: string[];
1054
+ description: string;
1055
+ };
1040
1056
  totpURI: {
1041
1057
  type: string;
1042
1058
  description: string;
@@ -1049,6 +1065,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1049
1065
  description: string;
1050
1066
  };
1051
1067
  };
1068
+ required: string[];
1052
1069
  };
1053
1070
  };
1054
1071
  };
@@ -1057,6 +1074,9 @@ export declare function createApiClient(options?: ApiClientOptions): {
1057
1074
  };
1058
1075
  };
1059
1076
  }, {
1077
+ method: "otp";
1078
+ } | {
1079
+ method: "totp";
1060
1080
  totpURI: string;
1061
1081
  backupCodes: string[];
1062
1082
  }>;
@@ -1067,7 +1087,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1067
1087
  }, import("zod/v4/core").$strip> | import("zod").ZodObject<{
1068
1088
  password: import("zod").ZodString;
1069
1089
  }, import("zod/v4/core").$strip>;
1070
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1090
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1071
1091
  session: {
1072
1092
  session: Record<string, any> & {
1073
1093
  id: string;
@@ -1089,7 +1109,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1089
1109
  image?: string | null | undefined;
1090
1110
  };
1091
1111
  };
1092
- }>)[];
1112
+ }>>[];
1093
1113
  metadata: {
1094
1114
  openapi: {
1095
1115
  summary: string;
@@ -1234,7 +1254,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1234
1254
  }, import("zod/v4/core").$strip> | import("zod").ZodObject<{
1235
1255
  password: import("zod").ZodString;
1236
1256
  }, import("zod/v4/core").$strip>;
1237
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1257
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1238
1258
  session: {
1239
1259
  session: Record<string, any> & {
1240
1260
  id: string;
@@ -1256,7 +1276,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1256
1276
  image?: string | null | undefined;
1257
1277
  };
1258
1278
  };
1259
- }>)[];
1279
+ }>>[];
1260
1280
  metadata: {
1261
1281
  openapi: {
1262
1282
  description: string;
@@ -1455,7 +1475,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1455
1475
  }>;
1456
1476
  getTOTPURI: import("better-call").StrictEndpoint<"/two-factor/get-totp-uri", {
1457
1477
  method: "POST";
1458
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1478
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1459
1479
  session: {
1460
1480
  session: Record<string, any> & {
1461
1481
  id: string;
@@ -1477,7 +1497,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1477
1497
  image?: string | null | undefined;
1478
1498
  };
1479
1499
  };
1480
- }>)[];
1500
+ }>>[];
1481
1501
  body: import("zod").ZodObject<{
1482
1502
  password: import("zod").ZodOptional<import("zod").ZodString>;
1483
1503
  }, import("zod/v4/core").$strip> | import("zod").ZodObject<{
@@ -1558,10 +1578,10 @@ export declare function createApiClient(options?: ApiClientOptions): {
1558
1578
  hooks: {
1559
1579
  after: {
1560
1580
  matcher(context: import("better-auth").HookEndpointContext): boolean;
1561
- handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1581
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1562
1582
  twoFactorRedirect: boolean;
1563
1583
  twoFactorMethods: string[];
1564
- } | undefined>;
1584
+ } | undefined>>;
1565
1585
  }[];
1566
1586
  };
1567
1587
  schema: {
@@ -1627,8 +1647,10 @@ export declare function createApiClient(options?: ApiClientOptions): {
1627
1647
  }[];
1628
1648
  $ERROR_CODES: {
1629
1649
  OTP_NOT_ENABLED: import("better-auth").RawError<"OTP_NOT_ENABLED">;
1650
+ OTP_NOT_CONFIGURED: import("better-auth").RawError<"OTP_NOT_CONFIGURED">;
1630
1651
  OTP_HAS_EXPIRED: import("better-auth").RawError<"OTP_HAS_EXPIRED">;
1631
1652
  TOTP_NOT_ENABLED: import("better-auth").RawError<"TOTP_NOT_ENABLED">;
1653
+ TOTP_NOT_CONFIGURED: import("better-auth").RawError<"TOTP_NOT_CONFIGURED">;
1632
1654
  TWO_FACTOR_NOT_ENABLED: import("better-auth").RawError<"TWO_FACTOR_NOT_ENABLED">;
1633
1655
  BACKUP_CODES_NOT_ENABLED: import("better-auth").RawError<"BACKUP_CODES_NOT_ENABLED">;
1634
1656
  INVALID_BACKUP_CODE: import("better-auth").RawError<"INVALID_BACKUP_CODE">;
@@ -1661,8 +1683,10 @@ export declare function createApiClient(options?: ApiClientOptions): {
1661
1683
  }[];
1662
1684
  $ERROR_CODES: {
1663
1685
  OTP_NOT_ENABLED: import("better-auth").RawError<"OTP_NOT_ENABLED">;
1686
+ OTP_NOT_CONFIGURED: import("better-auth").RawError<"OTP_NOT_CONFIGURED">;
1664
1687
  OTP_HAS_EXPIRED: import("better-auth").RawError<"OTP_HAS_EXPIRED">;
1665
1688
  TOTP_NOT_ENABLED: import("better-auth").RawError<"TOTP_NOT_ENABLED">;
1689
+ TOTP_NOT_CONFIGURED: import("better-auth").RawError<"TOTP_NOT_CONFIGURED">;
1666
1690
  TWO_FACTOR_NOT_ENABLED: import("better-auth").RawError<"TWO_FACTOR_NOT_ENABLED">;
1667
1691
  BACKUP_CODES_NOT_ENABLED: import("better-auth").RawError<"BACKUP_CODES_NOT_ENABLED">;
1668
1692
  INVALID_BACKUP_CODE: import("better-auth").RawError<"INVALID_BACKUP_CODE">;
@@ -1681,6 +1705,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1681
1705
  signInMagicLink: import("better-call").StrictEndpoint<"/sign-in/magic-link", {
1682
1706
  method: "POST";
1683
1707
  requireHeaders: true;
1708
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>[];
1684
1709
  body: import("zod").ZodObject<{
1685
1710
  email: import("zod").ZodEmail;
1686
1711
  name: import("zod").ZodOptional<import("zod").ZodString>;
@@ -1723,7 +1748,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1723
1748
  errorCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
1724
1749
  newUserCallbackURL: import("zod").ZodOptional<import("zod").ZodString>;
1725
1750
  }, import("zod/v4/core").$strip>;
1726
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
1751
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>[];
1727
1752
  requireHeaders: true;
1728
1753
  metadata: {
1729
1754
  openapi: {
@@ -1801,6 +1826,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
1801
1826
  endpoints: {
1802
1827
  sendVerificationOTP: import("better-call").StrictEndpoint<"/email-otp/send-verification-otp", {
1803
1828
  method: "POST";
1829
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>[];
1804
1830
  body: import("zod").ZodObject<{
1805
1831
  email: import("zod").ZodString;
1806
1832
  type: import("zod").ZodEnum<{
@@ -2161,7 +2187,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2161
2187
  newEmail: import("zod").ZodString;
2162
2188
  otp: import("zod").ZodOptional<import("zod").ZodString>;
2163
2189
  }, import("zod/v4/core").$strip>;
2164
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
2190
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
2165
2191
  session: {
2166
2192
  session: Record<string, any> & {
2167
2193
  id: string;
@@ -2183,7 +2209,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2183
2209
  image?: string | null | undefined;
2184
2210
  };
2185
2211
  };
2186
- }>)[];
2212
+ }>>[];
2187
2213
  metadata: {
2188
2214
  openapi: {
2189
2215
  operationId: string;
@@ -2216,7 +2242,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2216
2242
  newEmail: import("zod").ZodString;
2217
2243
  otp: import("zod").ZodString;
2218
2244
  }, import("zod/v4/core").$strip>;
2219
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
2245
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
2220
2246
  session: {
2221
2247
  session: Record<string, any> & {
2222
2248
  id: string;
@@ -2238,7 +2264,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2238
2264
  image?: string | null | undefined;
2239
2265
  };
2240
2266
  };
2241
- }>)[];
2267
+ }>>[];
2242
2268
  metadata: {
2243
2269
  openapi: {
2244
2270
  operationId: string;
@@ -2269,7 +2295,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2269
2295
  hooks: {
2270
2296
  after: {
2271
2297
  matcher(context: import("better-auth").HookEndpointContext): boolean;
2272
- handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
2298
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
2273
2299
  }[];
2274
2300
  };
2275
2301
  rateLimit: ({
@@ -2328,7 +2354,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2328
2354
  } | {
2329
2355
  id: "username";
2330
2356
  version: string;
2331
- $InferServerPlugin: ReturnType<(options?: import("better-auth/plugins/username").UsernameOptions | undefined) => {
2357
+ $InferServerPlugin: {
2332
2358
  id: "username";
2333
2359
  version: string;
2334
2360
  init(ctx: import("better-auth").AuthContext): {
@@ -2346,8 +2372,8 @@ export declare function createApiClient(options?: ApiClientOptions): {
2346
2372
  image?: string | null | undefined;
2347
2373
  } & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null): Promise<{
2348
2374
  data: {
2375
+ displayUsername?: string | undefined;
2349
2376
  username: string;
2350
- displayUsername: string;
2351
2377
  id: string;
2352
2378
  createdAt: Date;
2353
2379
  updatedAt: Date;
@@ -2520,7 +2546,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2520
2546
  hooks: {
2521
2547
  before: {
2522
2548
  matcher(context: import("better-auth").HookEndpointContext): boolean;
2523
- handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
2549
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
2524
2550
  }[];
2525
2551
  };
2526
2552
  options: import("better-auth/plugins/username").UsernameOptions | undefined;
@@ -2533,8 +2559,9 @@ export declare function createApiClient(options?: ApiClientOptions): {
2533
2559
  USERNAME_TOO_LONG: import("better-auth").RawError<"USERNAME_TOO_LONG">;
2534
2560
  INVALID_USERNAME: import("better-auth").RawError<"INVALID_USERNAME">;
2535
2561
  INVALID_DISPLAY_USERNAME: import("better-auth").RawError<"INVALID_DISPLAY_USERNAME">;
2562
+ USERNAME_IS_IMMUTABLE: import("better-auth").RawError<"USERNAME_IS_IMMUTABLE">;
2536
2563
  };
2537
- }>;
2564
+ };
2538
2565
  atomListeners: {
2539
2566
  matcher: (path: string) => path is "/sign-in/username";
2540
2567
  signal: "$sessionSignal";
@@ -2548,6 +2575,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2548
2575
  USERNAME_TOO_LONG: import("better-auth").RawError<"USERNAME_TOO_LONG">;
2549
2576
  INVALID_USERNAME: import("better-auth").RawError<"INVALID_USERNAME">;
2550
2577
  INVALID_DISPLAY_USERNAME: import("better-auth").RawError<"INVALID_DISPLAY_USERNAME">;
2578
+ USERNAME_IS_IMMUTABLE: import("better-auth").RawError<"USERNAME_IS_IMMUTABLE">;
2551
2579
  };
2552
2580
  } | {
2553
2581
  id: "multi-session";
@@ -2577,9 +2605,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2577
2605
  email: string;
2578
2606
  emailVerified: boolean;
2579
2607
  name: string;
2580
- image
2581
- /** Error thrown when the API returns the standard error envelope or a non-2xx status. */
2582
- ? /** Error thrown when the API returns the standard error envelope or a non-2xx status. */: string | null | undefined;
2608
+ image?: string | null | undefined;
2583
2609
  };
2584
2610
  }[]>;
2585
2611
  setActiveSession: import("better-call").StrictEndpoint<"/multi-session/set-active", {
@@ -2637,7 +2663,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2637
2663
  sessionToken: import("zod").ZodString;
2638
2664
  }, import("zod/v4/core").$strip>;
2639
2665
  requireHeaders: true;
2640
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
2666
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
2641
2667
  session: {
2642
2668
  session: Record<string, any> & {
2643
2669
  id: string;
@@ -2659,7 +2685,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2659
2685
  image?: string | null | undefined;
2660
2686
  };
2661
2687
  };
2662
- }>)[];
2688
+ }>>[];
2663
2689
  metadata: {
2664
2690
  openapi: {
2665
2691
  description: string;
@@ -2689,7 +2715,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2689
2715
  hooks: {
2690
2716
  after: {
2691
2717
  matcher: (context: import("better-auth").HookEndpointContext) => boolean;
2692
- handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
2718
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
2693
2719
  }[];
2694
2720
  };
2695
2721
  options: import("better-auth/plugins/multi-session").MultiSessionConfig | undefined;
@@ -2743,7 +2769,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
2743
2769
  hooks: {
2744
2770
  before: {
2745
2771
  matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
2746
- handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<never>;
2772
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<never>>;
2747
2773
  }[];
2748
2774
  };
2749
2775
  endpoints: {
@@ -2818,6 +2844,18 @@ export declare function createApiClient(options?: ApiClientOptions): {
2818
2844
  }, {
2819
2845
  message: string;
2820
2846
  }>;
2847
+ consumePhoneNumberOTP: import("better-call").StrictEndpoint<string, {
2848
+ method: "POST";
2849
+ body: import("zod").ZodObject<{
2850
+ phoneNumber: import("zod").ZodString;
2851
+ code: import("zod").ZodString;
2852
+ }, import("zod/v4/core").$strip>;
2853
+ metadata: {
2854
+ readonly scope: "server";
2855
+ };
2856
+ }, {
2857
+ status: boolean;
2858
+ }>;
2821
2859
  verifyPhoneNumber: import("better-call").StrictEndpoint<"/phone-number/verify", {
2822
2860
  method: "POST";
2823
2861
  body: import("zod").ZodIntersection<import("zod").ZodObject<{
@@ -3098,7 +3136,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3098
3136
  hooks: {
3099
3137
  before: {
3100
3138
  matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
3101
- handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3139
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3102
3140
  user: {
3103
3141
  id: string;
3104
3142
  createdAt: Date;
@@ -3119,10 +3157,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3119
3157
  expiresAt: Date;
3120
3158
  };
3121
3159
  } | {
3122
- context: import("better-call").MiddlewareContext<import("better-call").MiddlewareOptions, {
3123
- returned?: unknown | undefined;
3124
- responseHeaders?: Headers | undefined;
3125
- } & import("better-auth").PluginContext<import("better-auth").BetterAuthOptions> & import("better-auth").InfoContext & {
3160
+ context: import("better-call").MiddlewareContext<import("better-call").MiddlewareOptions, import("better-auth").PluginContext<import("better-auth").BetterAuthOptions> & import("better-auth").InfoContext & {
3126
3161
  options: import("better-auth").BetterAuthOptions;
3127
3162
  trustedOrigins: string[];
3128
3163
  trustedProviders: string[];
@@ -3214,6 +3249,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3214
3249
  updateAge: number;
3215
3250
  expiresIn: number;
3216
3251
  freshAge: number;
3252
+ cookieCacheSigner?: import("better-auth").CookieCacheSigner | undefined;
3217
3253
  cookieRefreshCache: false | {
3218
3254
  enabled: true;
3219
3255
  updateAge: number;
@@ -3247,8 +3283,11 @@ export declare function createApiClient(options?: ApiClientOptions): {
3247
3283
  skipCSRFCheck: boolean;
3248
3284
  runInBackground: (promise: Promise<unknown>) => void;
3249
3285
  runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("better-auth").Awaitable<unknown>;
3286
+ } & {
3287
+ returned?: unknown | undefined;
3288
+ responseHeaders?: Headers | undefined;
3250
3289
  }>;
3251
- }>;
3290
+ }>>;
3252
3291
  }[];
3253
3292
  };
3254
3293
  endpoints: {
@@ -3463,7 +3502,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3463
3502
  configId: import("zod").ZodOptional<import("zod").ZodString>;
3464
3503
  id: import("zod").ZodString;
3465
3504
  }, import("zod/v4/core").$strip>;
3466
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3505
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3467
3506
  session: {
3468
3507
  session: Record<string, any> & {
3469
3508
  id: string;
@@ -3485,7 +3524,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3485
3524
  image?: string | null | undefined;
3486
3525
  };
3487
3526
  };
3488
- }>)[];
3527
+ }>>[];
3489
3528
  metadata: {
3490
3529
  openapi: {
3491
3530
  description: string;
@@ -3800,7 +3839,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3800
3839
  configId: import("zod").ZodOptional<import("zod").ZodString>;
3801
3840
  keyId: import("zod").ZodString;
3802
3841
  }, import("zod/v4/core").$strip>;
3803
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3842
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3804
3843
  session: {
3805
3844
  session: Record<string, any> & {
3806
3845
  id: string;
@@ -3822,7 +3861,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3822
3861
  image?: string | null | undefined;
3823
3862
  };
3824
3863
  };
3825
- }>)[];
3864
+ }>>[];
3826
3865
  metadata: {
3827
3866
  openapi: {
3828
3867
  description: string;
@@ -3868,7 +3907,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3868
3907
  }>;
3869
3908
  listApiKeys: import("better-call").StrictEndpoint<"/api-key/list", {
3870
3909
  method: "GET";
3871
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3910
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
3872
3911
  session: {
3873
3912
  session: Record<string, any> & {
3874
3913
  id: string;
@@ -3890,7 +3929,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
3890
3929
  image?: string | null | undefined;
3891
3930
  };
3892
3931
  };
3893
- }>)[];
3932
+ }>>[];
3894
3933
  query: import("zod").ZodOptional<import("zod").ZodObject<{
3895
3934
  configId: import("zod").ZodOptional<import("zod").ZodString>;
3896
3935
  organizationId: import("zod").ZodOptional<import("zod").ZodString>;
@@ -4254,7 +4293,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4254
4293
  endpoints: {
4255
4294
  generatePasskeyRegistrationOptions: import("better-call").StrictEndpoint<"/passkey/generate-register-options", {
4256
4295
  method: "GET";
4257
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4296
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4258
4297
  session: {
4259
4298
  session: Record<string, any> & {
4260
4299
  id: string;
@@ -4276,7 +4315,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4276
4315
  image?: string | null | undefined;
4277
4316
  };
4278
4317
  };
4279
- }>)[];
4318
+ }>>[];
4280
4319
  query: import("zod").ZodOptional<import("zod").ZodObject<{
4281
4320
  authenticatorAttachment: import("zod").ZodOptional<import("zod").ZodEnum<{
4282
4321
  platform: "platform";
@@ -4289,15 +4328,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4289
4328
  openapi: {
4290
4329
  operationId: string;
4291
4330
  description: string;
4292
- parameters: {
4293
- name: string;
4294
- in: "query";
4295
- required: false;
4296
- description: string;
4297
- schema: {
4298
- type: "string";
4299
- };
4300
- }[];
4331
+ parameters: import("better-call").OpenAPIParameter[];
4301
4332
  responses: {
4302
4333
  200: {
4303
4334
  description: string;
@@ -4499,8 +4530,9 @@ export declare function createApiClient(options?: ApiClientOptions): {
4499
4530
  body: import("zod").ZodObject<{
4500
4531
  response: import("zod").ZodAny;
4501
4532
  name: import("zod").ZodOptional<import("zod").ZodString>;
4533
+ createSession: import("zod").ZodOptional<import("zod").ZodBoolean>;
4502
4534
  }, import("zod/v4/core").$strip>;
4503
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4535
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4504
4536
  session: {
4505
4537
  session: Record<string, any> & {
4506
4538
  id: string;
@@ -4522,7 +4554,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4522
4554
  image?: string | null | undefined;
4523
4555
  };
4524
4556
  };
4525
- }>)[];
4557
+ }>>[];
4526
4558
  metadata: {
4527
4559
  openapi: {
4528
4560
  operationId: string;
@@ -4533,7 +4565,20 @@ export declare function createApiClient(options?: ApiClientOptions): {
4533
4565
  content: {
4534
4566
  "application/json": {
4535
4567
  schema: {
4536
- $ref: string;
4568
+ readonly type: "object";
4569
+ readonly allOf: readonly [{
4570
+ readonly $ref: "#/components/schemas/Passkey";
4571
+ }, {
4572
+ readonly type: "object";
4573
+ readonly properties: {
4574
+ readonly session: {
4575
+ readonly $ref: "#/components/schemas/Session";
4576
+ };
4577
+ readonly user: {
4578
+ readonly $ref: "#/components/schemas/User";
4579
+ };
4580
+ };
4581
+ }];
4537
4582
  };
4538
4583
  };
4539
4584
  };
@@ -4604,7 +4649,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4604
4649
  }>;
4605
4650
  listPasskeys: import("better-call").StrictEndpoint<"/passkey/list-user-passkeys", {
4606
4651
  method: "GET";
4607
- use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4652
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4608
4653
  session: {
4609
4654
  session: Record<string, any> & {
4610
4655
  id: string;
@@ -4626,7 +4671,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4626
4671
  image?: string | null | undefined;
4627
4672
  };
4628
4673
  };
4629
- }>)[];
4674
+ }>>[];
4630
4675
  metadata: {
4631
4676
  openapi: {
4632
4677
  description: string;
@@ -4655,7 +4700,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4655
4700
  body: import("zod").ZodObject<{
4656
4701
  id: import("zod").ZodString;
4657
4702
  }, import("zod/v4/core").$strip>;
4658
- use: (((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4703
+ use: (import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4659
4704
  session: {
4660
4705
  session: Record<string, any> & {
4661
4706
  id: string;
@@ -4677,9 +4722,9 @@ export declare function createApiClient(options?: ApiClientOptions): {
4677
4722
  image?: string | null | undefined;
4678
4723
  };
4679
4724
  };
4680
- }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4725
+ }>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4681
4726
  verifiedResource: {};
4682
- }>))[];
4727
+ }>>)[];
4683
4728
  metadata: {
4684
4729
  openapi: {
4685
4730
  description: string;
@@ -4713,7 +4758,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4713
4758
  id: import("zod").ZodString;
4714
4759
  name: import("zod").ZodString;
4715
4760
  }, import("zod/v4/core").$strip>;
4716
- use: (((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4761
+ use: (import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4717
4762
  session: {
4718
4763
  session: Record<string, any> & {
4719
4764
  id: string;
@@ -4735,9 +4780,9 @@ export declare function createApiClient(options?: ApiClientOptions): {
4735
4780
  image?: string | null | undefined;
4736
4781
  };
4737
4782
  };
4738
- }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4783
+ }>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
4739
4784
  verifiedResource: {};
4740
- }>))[];
4785
+ }>>)[];
4741
4786
  metadata: {
4742
4787
  openapi: {
4743
4788
  description: string;
@@ -4824,6 +4869,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4824
4869
  PASSKEY_NOT_FOUND: import("better-auth").RawError<"PASSKEY_NOT_FOUND">;
4825
4870
  AUTHENTICATION_FAILED: import("better-auth").RawError<"AUTHENTICATION_FAILED">;
4826
4871
  UNABLE_TO_CREATE_SESSION: import("better-auth").RawError<"UNABLE_TO_CREATE_SESSION">;
4872
+ USER_NOT_FOUND: import("better-auth").RawError<"USER_NOT_FOUND">;
4827
4873
  FAILED_TO_UPDATE_PASSKEY: import("better-auth").RawError<"FAILED_TO_UPDATE_PASSKEY">;
4828
4874
  PREVIOUSLY_REGISTERED: import("better-auth").RawError<"PREVIOUSLY_REGISTERED">;
4829
4875
  REGISTRATION_CANCELLED: import("better-auth").RawError<"REGISTRATION_CANCELLED">;
@@ -4892,6 +4938,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4892
4938
  name?: string;
4893
4939
  authenticatorAttachment?: "platform" | "cross-platform";
4894
4940
  context?: string | null;
4941
+ createSession?: boolean;
4895
4942
  extensions?: import("@simplewebauthn/server").AuthenticationExtensionsClientInputs;
4896
4943
  useAutoRegister?: boolean;
4897
4944
  returnWebAuthnResponse?: boolean;
@@ -4903,14 +4950,20 @@ export declare function createApiClient(options?: ApiClientOptions): {
4903
4950
  statusText: string;
4904
4951
  };
4905
4952
  } | {
4906
- data: import("@better-auth/passkey/client").Passkey;
4953
+ data: import("@better-auth/passkey/client").Passkey & {
4954
+ session?: import("better-auth").Session;
4955
+ user?: import("better-auth").User;
4956
+ };
4907
4957
  error: null;
4908
4958
  } | {
4909
4959
  webauthn: {
4910
4960
  response: import("@simplewebauthn/server").RegistrationResponseJSON;
4911
4961
  clientExtensionResults: import("@simplewebauthn/server").AuthenticationExtensionsClientOutputs;
4912
4962
  };
4913
- data: import("@better-auth/passkey/client").Passkey;
4963
+ data: import("@better-auth/passkey/client").Passkey & {
4964
+ session?: import("better-auth").Session;
4965
+ user?: import("better-auth").User;
4966
+ };
4914
4967
  error: null;
4915
4968
  } | {
4916
4969
  data: null;
@@ -4948,6 +5001,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
4948
5001
  PASSKEY_NOT_FOUND: import("better-auth").RawError<"PASSKEY_NOT_FOUND">;
4949
5002
  AUTHENTICATION_FAILED: import("better-auth").RawError<"AUTHENTICATION_FAILED">;
4950
5003
  UNABLE_TO_CREATE_SESSION: import("better-auth").RawError<"UNABLE_TO_CREATE_SESSION">;
5004
+ USER_NOT_FOUND: import("better-auth").RawError<"USER_NOT_FOUND">;
4951
5005
  FAILED_TO_UPDATE_PASSKEY: import("better-auth").RawError<"FAILED_TO_UPDATE_PASSKEY">;
4952
5006
  PREVIOUSLY_REGISTERED: import("better-auth").RawError<"PREVIOUSLY_REGISTERED">;
4953
5007
  REGISTRATION_CANCELLED: import("better-auth").RawError<"REGISTRATION_CANCELLED">;
@@ -5266,6 +5320,7 @@ export declare function createApiClient(options?: ApiClientOptions): {
5266
5320
  put: <T>(path: string, body?: unknown) => Promise<T>;
5267
5321
  patch: <T>(path: string, body?: unknown) => Promise<T>;
5268
5322
  del: <T>(path: string) => Promise<T>;
5323
+ postForm: <T>(path: string, body: FormData) => Promise<T>;
5269
5324
  };
5270
5325
  /** The client returned by {@link createApiClient}. */
5271
5326
  export type ApiClient = ReturnType<typeof createApiClient>;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { adminClient, twoFactorClient, magicLinkClient, emailOTPClient, username
3
3
  import { apiKeyClient } from "@better-auth/api-key/client";
4
4
  import { passkeyClient } from "@better-auth/passkey/client";
5
5
  /** Stable authentication policy error codes re-exported for browser clients. */
6
- export { PUBLIC_SIGNUP_DISABLED, SIGNUP_APPROVAL_REQUIRED, } from "@podosoft/podokit-contracts";
6
+ export { PROFILE_IMAGE_DIMENSIONS_INVALID, PROFILE_IMAGE_NOT_FOUND, PROFILE_IMAGE_POLICY, PROFILE_IMAGE_REQUIRED, PROFILE_IMAGE_TOO_LARGE, PROFILE_IMAGE_TYPE_INVALID, PUBLIC_SIGNUP_DISABLED, SIGNUP_APPROVAL_REQUIRED, } from "@podosoft/podokit-contracts";
7
7
  /** Error thrown when the API returns the standard error envelope or a non-2xx status. */
8
8
  export class ApiError extends Error {
9
9
  code;
@@ -33,8 +33,10 @@ function toApiError(data, response) {
33
33
  *
34
34
  * - `client.auth` is the better-auth client (email/password, sessions, and the
35
35
  * admin plugin: `client.auth.admin.listUsers()`, `banUser`, `setRole`, ...).
36
- * - `client.get/post/put/patch/del` call the app's REST endpoints and parse the
37
- * standard error envelope, throwing {@link ApiError} on failure.
36
+ * - `client.get/post/put/patch/del` call the app's JSON REST endpoints and parse
37
+ * the standard error envelope, throwing {@link ApiError} on failure.
38
+ * - `client.postForm` sends multipart `FormData` without overriding the browser's
39
+ * boundary-aware content type.
38
40
  */
39
41
  export function createApiClient(options = {}) {
40
42
  const baseUrl = options.baseUrl ?? "";
@@ -91,6 +93,19 @@ export function createApiClient(options = {}) {
91
93
  }
92
94
  return data;
93
95
  }
96
+ async function formRequest(method, path, body) {
97
+ const response = await doFetch(`${baseUrl}${apiBasePath}${path}`, {
98
+ method,
99
+ credentials,
100
+ body,
101
+ });
102
+ const text = await response.text();
103
+ const data = text ? JSON.parse(text) : undefined;
104
+ if (!response.ok) {
105
+ throw toApiError(data, response);
106
+ }
107
+ return data;
108
+ }
94
109
  return {
95
110
  /** The better-auth client (auth + admin plugin), created on first access. */
96
111
  get auth() {
@@ -103,5 +118,6 @@ export function createApiClient(options = {}) {
103
118
  put: (path, body) => request("PUT", path, body),
104
119
  patch: (path, body) => request("PATCH", path, body),
105
120
  del: (path) => request("DELETE", path),
121
+ postForm: (path, body) => formRequest("POST", path, body),
106
122
  };
107
123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podosoft/podokit-api-client",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "Typed API client for PodoKit backends: better-auth (auth + admin) plus a standard error-envelope request layer.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -29,10 +29,10 @@
29
29
  "provenance": true
30
30
  },
31
31
  "dependencies": {
32
- "@podosoft/podokit-contracts": "^0.3.0",
33
- "better-auth": "^1.6.23",
34
- "@better-auth/api-key": "^1.6.23",
35
- "@better-auth/passkey": "^1.6.23"
32
+ "@podosoft/podokit-contracts": "^0.4.0",
33
+ "better-auth": "^1.7.1",
34
+ "@better-auth/api-key": "^1.7.1",
35
+ "@better-auth/passkey": "^1.7.1"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsc -p tsconfig.json",