@podosoft/podokit-api-client 0.5.1 → 0.6.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
@@ -4,7 +4,8 @@ Typed API client for PodoKit backends. Every frontend talks to the backend
4
4
  through this single entry point — never with a raw `fetch`.
5
5
 
6
6
  - `client.auth` — the [better-auth](https://better-auth.com) client (email/password,
7
- sessions, and the admin plugin: `listUsers`, `banUser`, `setRole`, `listUserSessions`, …).
7
+ sessions, the `signupApproved` user field, and the admin plugin: `listUsers`,
8
+ `updateUser`, `banUser`, `setRole`, `listUserSessions`, …).
8
9
  - `client.get/post/put/patch/del` — the app's REST endpoints, parsing the standard
9
10
  error envelope and throwing `ApiError` on failure.
10
11
 
@@ -32,3 +33,5 @@ const session = await api.auth.getSession();
32
33
  | `credentials` | `include` | Send cookies with requests. |
33
34
 
34
35
  Errors are thrown as `ApiError` (`code`, `message`, `statusCode`, `details`).
36
+ `PUBLIC_SIGNUP_DISABLED` and `SIGNUP_APPROVAL_REQUIRED` are re-exported for
37
+ provider-independent registration-policy handling.
package/dist/index.d.ts CHANGED
@@ -19,6 +19,8 @@ export interface ApiClientOptions {
19
19
  * for the shape — the backend controller and every SvelteKit loader import it.
20
20
  */
21
21
  export type { Capabilities } from "@podosoft/podokit-contracts";
22
+ /** Stable authentication policy error codes re-exported for browser clients. */
23
+ export { PUBLIC_SIGNUP_DISABLED, SIGNUP_APPROVAL_REQUIRED, } from "@podosoft/podokit-contracts";
22
24
  /** Error thrown when the API returns the standard error envelope or a non-2xx status. */
23
25
  export declare class ApiError extends Error {
24
26
  readonly code: string;
@@ -2575,7 +2577,9 @@ export declare function createApiClient(options?: ApiClientOptions): {
2575
2577
  email: string;
2576
2578
  emailVerified: boolean;
2577
2579
  name: string;
2578
- image?: string | null | undefined;
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;
2579
2583
  };
2580
2584
  }[]>;
2581
2585
  setActiveSession: import("better-call").StrictEndpoint<"/multi-session/set-active", {
@@ -5227,6 +5231,28 @@ export declare function createApiClient(options?: ApiClientOptions): {
5227
5231
  ROLE_IS_ASSIGNED_TO_MEMBERS: import("better-auth").RawError<"ROLE_IS_ASSIGNED_TO_MEMBERS">;
5228
5232
  INVALID_TEAM_ID: import("better-auth").RawError<"INVALID_TEAM_ID">;
5229
5233
  };
5234
+ } | {
5235
+ id: "additional-fields-client";
5236
+ version: string;
5237
+ $InferServerPlugin: {
5238
+ id: "additional-fields-client";
5239
+ version: string;
5240
+ schema: {
5241
+ user: {
5242
+ fields: {
5243
+ signupApproved: {
5244
+ type: "boolean";
5245
+ required: false;
5246
+ defaultValue: true;
5247
+ input: false;
5248
+ };
5249
+ };
5250
+ };
5251
+ session: {
5252
+ fields: {};
5253
+ };
5254
+ };
5255
+ };
5230
5256
  })[];
5231
5257
  fetchOptions: {
5232
5258
  customFetchImpl?: typeof fetch | undefined;
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { createAuthClient } from "better-auth/client";
2
- import { adminClient, twoFactorClient, magicLinkClient, emailOTPClient, usernameClient, multiSessionClient, phoneNumberClient, organizationClient } from "better-auth/client/plugins";
2
+ import { adminClient, twoFactorClient, magicLinkClient, emailOTPClient, usernameClient, multiSessionClient, phoneNumberClient, organizationClient, inferAdditionalFields } from "better-auth/client/plugins";
3
3
  import { apiKeyClient } from "@better-auth/api-key/client";
4
4
  import { passkeyClient } from "@better-auth/passkey/client";
5
+ /** Stable authentication policy error codes re-exported for browser clients. */
6
+ export { PUBLIC_SIGNUP_DISABLED, SIGNUP_APPROVAL_REQUIRED, } from "@podosoft/podokit-contracts";
5
7
  /** Error thrown when the API returns the standard error envelope or a non-2xx status. */
6
8
  export class ApiError extends Error {
7
9
  code;
@@ -46,7 +48,23 @@ export function createApiClient(options = {}) {
46
48
  // (a bare ReturnType<typeof createAuthClient> would drop the plugin augmentation).
47
49
  const makeAuthClient = () => createAuthClient({
48
50
  baseURL: authOrigin,
49
- plugins: [adminClient(), twoFactorClient(), magicLinkClient(), emailOTPClient(), usernameClient(), multiSessionClient(), phoneNumberClient(), apiKeyClient(), passkeyClient(), organizationClient()],
51
+ plugins: [
52
+ adminClient(),
53
+ twoFactorClient(),
54
+ magicLinkClient(),
55
+ emailOTPClient(),
56
+ usernameClient(),
57
+ multiSessionClient(),
58
+ phoneNumberClient(),
59
+ apiKeyClient(),
60
+ passkeyClient(),
61
+ organizationClient(),
62
+ inferAdditionalFields({
63
+ user: {
64
+ signupApproved: { type: "boolean", required: false, defaultValue: true, input: false },
65
+ },
66
+ }),
67
+ ],
50
68
  fetchOptions: {
51
69
  credentials,
52
70
  ...(options.fetch ? { customFetchImpl: options.fetch } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podosoft/podokit-api-client",
3
- "version": "0.5.1",
3
+ "version": "0.6.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,7 +29,7 @@
29
29
  "provenance": true
30
30
  },
31
31
  "dependencies": {
32
- "@podosoft/podokit-contracts": "^0.1.0",
32
+ "@podosoft/podokit-contracts": "^0.2.1",
33
33
  "better-auth": "^1.6.23",
34
34
  "@better-auth/api-key": "^1.6.23",
35
35
  "@better-auth/passkey": "^1.6.23"