@djangocfg/api 2.1.227 → 2.1.229

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.
Files changed (55) hide show
  1. package/README.md +8 -9
  2. package/dist/auth-server.cjs +4 -9
  3. package/dist/auth-server.cjs.map +1 -1
  4. package/dist/auth-server.mjs +4 -9
  5. package/dist/auth-server.mjs.map +1 -1
  6. package/dist/auth.cjs +120 -158
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.d.cts +120 -177
  9. package/dist/auth.d.ts +120 -177
  10. package/dist/auth.mjs +149 -191
  11. package/dist/auth.mjs.map +1 -1
  12. package/dist/clients.cjs +5 -11
  13. package/dist/clients.cjs.map +1 -1
  14. package/dist/clients.d.cts +253 -254
  15. package/dist/clients.d.ts +253 -254
  16. package/dist/clients.mjs +5 -11
  17. package/dist/clients.mjs.map +1 -1
  18. package/dist/hooks.cjs +4 -9
  19. package/dist/hooks.cjs.map +1 -1
  20. package/dist/hooks.d.cts +64 -85
  21. package/dist/hooks.d.ts +64 -85
  22. package/dist/hooks.mjs +4 -9
  23. package/dist/hooks.mjs.map +1 -1
  24. package/dist/index.cjs +5 -11
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +109 -99
  27. package/dist/index.d.ts +109 -99
  28. package/dist/index.mjs +5 -11
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +2 -2
  31. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts +24 -2
  32. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +0 -2
  33. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +0 -2
  34. package/src/_api/generated/cfg_accounts/accounts/client.ts +1 -1
  35. package/src/_api/generated/cfg_accounts/accounts/models.ts +37 -38
  36. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +36 -36
  37. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +15 -15
  38. package/src/_api/generated/cfg_accounts/enums.ts +0 -10
  39. package/src/_api/generated/cfg_accounts/schema.json +31 -25
  40. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/models.ts +74 -74
  41. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/models.ts +36 -36
  42. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_testing/models.ts +22 -22
  43. package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +10 -10
  44. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +22 -22
  45. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
  46. package/src/auth/context/AccountsContext.tsx +6 -2
  47. package/src/auth/context/AuthContext.tsx +32 -39
  48. package/src/auth/context/types.ts +5 -9
  49. package/src/auth/hooks/index.ts +1 -1
  50. package/src/auth/hooks/useAuthForm.ts +42 -75
  51. package/src/auth/hooks/useAuthFormState.ts +35 -6
  52. package/src/auth/hooks/useAuthValidation.ts +5 -65
  53. package/src/auth/hooks/useTwoFactor.ts +17 -2
  54. package/src/auth/types/form.ts +25 -70
  55. package/src/auth/types/index.ts +2 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "2.1.227",
3
+ "version": "2.1.229",
4
4
  "description": "Auto-generated TypeScript API client with React hooks, SWR integration, and Zod validation for Django REST Framework backends",
5
5
  "keywords": [
6
6
  "django",
@@ -84,7 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@types/node": "^24.7.2",
86
86
  "@types/react": "^19.1.0",
87
- "@djangocfg/typescript-config": "^2.1.227",
87
+ "@djangocfg/typescript-config": "^2.1.229",
88
88
  "next": "^16.0.10",
89
89
  "react": "^19.1.0",
90
90
  "tsup": "^8.5.0",
@@ -2,15 +2,37 @@
2
2
  * Zod schema for OTPErrorResponse
3
3
  *
4
4
  * This schema provides runtime validation and type inference.
5
- * * Error response for OTP operations.
5
+ * * Typed error response for OTP operations.
6
+
7
+ error_code values:
8
+ - invalid_identifier — malformed email
9
+ - cooldown — too soon after last request (retry_after = seconds)
10
+ - hourly_limit — hourly quota exceeded (retry_after = seconds until reset)
11
+ - daily_limit — daily quota exceeded (retry_after = seconds until reset)
12
+ - rate_limited — IP-level rate limit hit (no retry_after)
13
+ - user_creation_failed — internal error creating account
14
+ - send_failed — transport error (email / SMS)
15
+ - internal_error — unexpected server error
6
16
  * */
7
17
  import { z } from 'zod'
8
18
 
9
19
  /**
10
- * Error response for OTP operations.
20
+ * Typed error response for OTP operations.
21
+
22
+ error_code values:
23
+ - invalid_identifier — malformed email
24
+ - cooldown — too soon after last request (retry_after = seconds)
25
+ - hourly_limit — hourly quota exceeded (retry_after = seconds until reset)
26
+ - daily_limit — daily quota exceeded (retry_after = seconds until reset)
27
+ - rate_limited — IP-level rate limit hit (no retry_after)
28
+ - user_creation_failed — internal error creating account
29
+ - send_failed — transport error (email / SMS)
30
+ - internal_error — unexpected server error
11
31
  */
12
32
  export const OTPErrorResponseSchema = z.object({
13
33
  error: z.string(),
34
+ error_code: z.string().nullable().optional(),
35
+ retry_after: z.number().int().nullable().optional(),
14
36
  })
15
37
 
16
38
  /**
@@ -5,14 +5,12 @@
5
5
  * * Serializer for OTP request.
6
6
  * */
7
7
  import { z } from 'zod'
8
- import * as Enums from '../../enums'
9
8
 
10
9
  /**
11
10
  * Serializer for OTP request.
12
11
  */
13
12
  export const OTPRequestRequestSchema = z.object({
14
13
  identifier: z.string().min(1),
15
- channel: z.nativeEnum(Enums.OTPRequestRequestChannel).optional(),
16
14
  source_url: z.string().optional(),
17
15
  })
18
16
 
@@ -5,7 +5,6 @@
5
5
  * * Serializer for OTP verification.
6
6
  * */
7
7
  import { z } from 'zod'
8
- import * as Enums from '../../enums'
9
8
 
10
9
  /**
11
10
  * Serializer for OTP verification.
@@ -13,7 +12,6 @@ import * as Enums from '../../enums'
13
12
  export const OTPVerifyRequestSchema = z.object({
14
13
  identifier: z.string().min(1),
15
14
  otp: z.string().min(6).max(6),
16
- channel: z.nativeEnum(Enums.OTPRequestRequestChannel).optional(),
17
15
  source_url: z.string().optional(),
18
16
  })
19
17
 
@@ -13,7 +13,7 @@ export class Accounts {
13
13
  }
14
14
 
15
15
  /**
16
- * Request OTP code to email or phone.
16
+ * Request OTP code to email.
17
17
  */
18
18
  async otpRequestCreate(data: Models.OTPRequestRequest): Promise<Models.OTPRequestResponse> {
19
19
  const response = await this.client.request('POST', "/cfg/accounts/otp/request/", { body: data });
@@ -1,32 +1,59 @@
1
1
  // @ts-nocheck
2
2
  // Auto-generated by DjangoCFG - see CLAUDE.md
3
- import * as Enums from "../enums";
4
-
5
3
  /**
6
4
  * Serializer for OTP request.
7
5
  *
8
6
  * Request model (no read-only fields).
9
7
  */
10
8
  export interface OTPRequestRequest {
11
- /** Email address or phone number for OTP delivery */
9
+ /** Email address for OTP delivery */
12
10
  identifier: string;
13
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
14
-
15
- * `email` - Email
16
- * `phone` - Phone */
17
- channel?: Enums.OTPRequestRequestChannel;
18
11
  /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
19
12
  source_url?: string;
20
13
  }
21
14
 
22
15
  /**
23
- * Error response for OTP operations.
16
+ * Serializer for OTP verification.
17
+ *
18
+ * Request model (no read-only fields).
19
+ */
20
+ export interface OTPVerifyRequest {
21
+ /** Email address used for OTP request */
22
+ identifier: string;
23
+ otp: string;
24
+ /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
25
+ source_url?: string;
26
+ }
27
+
28
+ /**
29
+ * OTP request response.
30
+ *
31
+ * Response model (includes read-only fields).
32
+ */
33
+ export interface OTPRequestResponse {
34
+ /** Success message */
35
+ message: string;
36
+ }
37
+
38
+ /**
39
+ * Typed error response for OTP operations. error_code values: -
40
+ * invalid_identifier — malformed email - cooldown — too soon after last
41
+ * request (retry_after = seconds) - hourly_limit — hourly quota exceeded
42
+ * (retry_after = seconds until reset) - daily_limit — daily quota exceeded
43
+ * (retry_after = seconds until reset) - rate_limited — IP-level rate limit hit
44
+ * (no retry_after) - user_creation_failed — internal error creating account -
45
+ * send_failed — transport error (email / SMS) - internal_error — unexpected
46
+ * server error
24
47
  *
25
48
  * Response model (includes read-only fields).
26
49
  */
27
50
  export interface OTPErrorResponse {
28
- /** Error message */
51
+ /** Human-readable error message */
29
52
  error: string;
53
+ /** Machine-readable error code */
54
+ error_code?: string | null;
55
+ /** Seconds until the client may retry (present only for rate-limit errors) */
56
+ retry_after?: number | null;
30
57
  }
31
58
 
32
59
  /**
@@ -51,34 +78,6 @@ export interface OTPVerifyResponse {
51
78
  should_prompt_2fa?: boolean;
52
79
  }
53
80
 
54
- /**
55
- * OTP request response.
56
- *
57
- * Response model (includes read-only fields).
58
- */
59
- export interface OTPRequestResponse {
60
- /** Success message */
61
- message: string;
62
- }
63
-
64
- /**
65
- * Serializer for OTP verification.
66
- *
67
- * Request model (no read-only fields).
68
- */
69
- export interface OTPVerifyRequest {
70
- /** Email address or phone number used for OTP request */
71
- identifier: string;
72
- otp: string;
73
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
74
-
75
- * `email` - Email
76
- * `phone` - Phone */
77
- channel?: Enums.OTPRequestRequestChannel;
78
- /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
79
- source_url?: string;
80
- }
81
-
82
81
  /**
83
82
  * Serializer for user details.
84
83
  *
@@ -2,18 +2,6 @@
2
2
  // Auto-generated by DjangoCFG - see CLAUDE.md
3
3
  import * as Enums from "../enums";
4
4
 
5
- /**
6
- * Request to disconnect OAuth provider.
7
- *
8
- * Request model (no read-only fields).
9
- */
10
- export interface OAuthDisconnectRequestRequest {
11
- /** OAuth provider to disconnect
12
-
13
- * `github` - GitHub */
14
- provider: Enums.OAuthConnectionProvider;
15
- }
16
-
17
5
  /**
18
6
  * Response with OAuth authorization URL.
19
7
  *
@@ -27,15 +15,15 @@ export interface OAuthAuthorizeResponse {
27
15
  }
28
16
 
29
17
  /**
30
- * Request to start OAuth flow.
18
+ * Error response for OAuth endpoints.
31
19
  *
32
- * Request model (no read-only fields).
20
+ * Response model (includes read-only fields).
33
21
  */
34
- export interface OAuthAuthorizeRequestRequest {
35
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
36
- redirect_uri?: string;
37
- /** Optional source URL for registration tracking */
38
- source_url?: string;
22
+ export interface OAuthError {
23
+ /** Error code */
24
+ error: string;
25
+ /** Human-readable error description */
26
+ error_description?: string;
39
27
  }
40
28
 
41
29
  /**
@@ -66,13 +54,15 @@ export interface OAuthTokenResponse {
66
54
  }
67
55
 
68
56
  /**
69
- * Response with available OAuth providers.
57
+ * Request to start OAuth flow.
70
58
  *
71
- * Response model (includes read-only fields).
59
+ * Request model (no read-only fields).
72
60
  */
73
- export interface OAuthProvidersResponse {
74
- /** List of available OAuth providers */
75
- providers: Array<Record<string, any>>;
61
+ export interface OAuthAuthorizeRequestRequest {
62
+ /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
63
+ redirect_uri?: string;
64
+ /** Optional source URL for registration tracking */
65
+ source_url?: string;
76
66
  }
77
67
 
78
68
  /**
@@ -89,6 +79,28 @@ export interface OAuthCallbackRequestRequest {
89
79
  redirect_uri?: string;
90
80
  }
91
81
 
82
+ /**
83
+ * Request to disconnect OAuth provider.
84
+ *
85
+ * Request model (no read-only fields).
86
+ */
87
+ export interface OAuthDisconnectRequestRequest {
88
+ /** OAuth provider to disconnect
89
+
90
+ * `github` - GitHub */
91
+ provider: Enums.OAuthConnectionProvider;
92
+ }
93
+
94
+ /**
95
+ * Response with available OAuth providers.
96
+ *
97
+ * Response model (includes read-only fields).
98
+ */
99
+ export interface OAuthProvidersResponse {
100
+ /** List of available OAuth providers */
101
+ providers: Array<Record<string, any>>;
102
+ }
103
+
92
104
  /**
93
105
  * Serializer for OAuth connection info (user-facing).
94
106
  *
@@ -113,15 +125,3 @@ export interface OAuthConnection {
113
125
  last_login_at: string;
114
126
  }
115
127
 
116
- /**
117
- * Error response for OAuth endpoints.
118
- *
119
- * Response model (includes read-only fields).
120
- */
121
- export interface OAuthError {
122
- /** Error code */
123
- error: string;
124
- /** Human-readable error description */
125
- error_description?: string;
126
- }
127
-
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Request model (no read-only fields).
7
7
  */
8
- export interface UserProfileUpdateRequest {
8
+ export interface PatchedUserProfileUpdateRequest {
9
9
  first_name?: string;
10
10
  last_name?: string;
11
11
  company?: string;
@@ -23,6 +23,20 @@ export interface CfgAccountsProfileAvatarCreateRequest {
23
23
  avatar: File | Blob;
24
24
  }
25
25
 
26
+ /**
27
+ * Serializer for updating user profile.
28
+ *
29
+ * Request model (no read-only fields).
30
+ */
31
+ export interface UserProfileUpdateRequest {
32
+ first_name?: string;
33
+ last_name?: string;
34
+ company?: string;
35
+ phone?: string;
36
+ position?: string;
37
+ language?: string;
38
+ }
39
+
26
40
  /**
27
41
  * Serializer for user details.
28
42
  *
@@ -54,20 +68,6 @@ export interface User {
54
68
  centrifugo: CentrifugoToken | null;
55
69
  }
56
70
 
57
- /**
58
- * Serializer for updating user profile.
59
- *
60
- * Request model (no read-only fields).
61
- */
62
- export interface PatchedUserProfileUpdateRequest {
63
- first_name?: string;
64
- last_name?: string;
65
- company?: string;
66
- phone?: string;
67
- position?: string;
68
- language?: string;
69
- }
70
-
71
71
  /**
72
72
  * Response serializer for account deletion.
73
73
  *
@@ -8,13 +8,3 @@ export enum OAuthConnectionProvider {
8
8
  GITHUB = "github",
9
9
  }
10
10
 
11
- /**
12
- * Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
13
- * * `email` - Email
14
- * * `phone` - Phone
15
- */
16
- export enum OTPRequestRequestChannel {
17
- EMAIL = "email",
18
- PHONE = "phone",
19
- }
20
-
@@ -258,7 +258,7 @@
258
258
  "/cfg/accounts/otp/request/": {
259
259
  "post": {
260
260
  "operationId": "cfg_accounts_otp_request_create",
261
- "description": "Request OTP code to email or phone.",
261
+ "description": "Request OTP code to email.",
262
262
  "tags": [
263
263
  "accounts"
264
264
  ],
@@ -309,6 +309,16 @@
309
309
  },
310
310
  "description": ""
311
311
  },
312
+ "429": {
313
+ "content": {
314
+ "application/json": {
315
+ "schema": {
316
+ "$ref": "#/components/schemas/OTPErrorResponse"
317
+ }
318
+ }
319
+ },
320
+ "description": ""
321
+ },
312
322
  "500": {
313
323
  "content": {
314
324
  "application/json": {
@@ -367,7 +377,7 @@
367
377
  },
368
378
  "description": ""
369
379
  },
370
- "400": {
380
+ "401": {
371
381
  "content": {
372
382
  "application/json": {
373
383
  "schema": {
@@ -377,7 +387,7 @@
377
387
  },
378
388
  "description": ""
379
389
  },
380
- "410": {
390
+ "429": {
381
391
  "content": {
382
392
  "application/json": {
383
393
  "schema": {
@@ -1204,11 +1214,25 @@
1204
1214
  },
1205
1215
  "OTPErrorResponse": {
1206
1216
  "type": "object",
1207
- "description": "Error response for OTP operations.",
1217
+ "description": "Typed error response for OTP operations.\n\nerror_code values:\n - invalid_identifier — malformed email\n - cooldown — too soon after last request (retry_after = seconds)\n - hourly_limit — hourly quota exceeded (retry_after = seconds until reset)\n - daily_limit — daily quota exceeded (retry_after = seconds until reset)\n - rate_limited — IP-level rate limit hit (no retry_after)\n - user_creation_failed — internal error creating account\n - send_failed — transport error (email / SMS)\n - internal_error — unexpected server error",
1208
1218
  "properties": {
1209
1219
  "error": {
1210
1220
  "type": "string",
1211
- "description": "Error message"
1221
+ "description": "Human-readable error message"
1222
+ },
1223
+ "error_code": {
1224
+ "type": [
1225
+ "string",
1226
+ "null"
1227
+ ],
1228
+ "description": "Machine-readable error code"
1229
+ },
1230
+ "retry_after": {
1231
+ "type": [
1232
+ "integer",
1233
+ "null"
1234
+ ],
1235
+ "description": "Seconds until the client may retry (present only for rate-limit errors)"
1212
1236
  }
1213
1237
  },
1214
1238
  "required": [
@@ -1222,16 +1246,7 @@
1222
1246
  "identifier": {
1223
1247
  "type": "string",
1224
1248
  "minLength": 1,
1225
- "description": "Email address or phone number for OTP delivery"
1226
- },
1227
- "channel": {
1228
- "enum": [
1229
- "email",
1230
- "phone"
1231
- ],
1232
- "type": "string",
1233
- "x-spec-enum-id": "17f11a3a6a4008ba",
1234
- "description": "Delivery channel: 'email' or 'phone'. Auto-detected if not provided.\n\n* `email` - Email\n* `phone` - Phone"
1249
+ "description": "Email address for OTP delivery"
1235
1250
  },
1236
1251
  "source_url": {
1237
1252
  "type": "string",
@@ -1263,22 +1278,13 @@
1263
1278
  "identifier": {
1264
1279
  "type": "string",
1265
1280
  "minLength": 1,
1266
- "description": "Email address or phone number used for OTP request"
1281
+ "description": "Email address used for OTP request"
1267
1282
  },
1268
1283
  "otp": {
1269
1284
  "type": "string",
1270
1285
  "minLength": 6,
1271
1286
  "maxLength": 6
1272
1287
  },
1273
- "channel": {
1274
- "enum": [
1275
- "email",
1276
- "phone"
1277
- ],
1278
- "type": "string",
1279
- "x-spec-enum-id": "17f11a3a6a4008ba",
1280
- "description": "Delivery channel: 'email' or 'phone'. Auto-detected if not provided.\n\n* `email` - Email\n* `phone` - Phone"
1281
- },
1282
1288
  "source_url": {
1283
1289
  "type": "string",
1284
1290
  "format": "uri",