@djangocfg/api 2.1.227 → 2.1.228

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 (56) 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 +218 -219
  15. package/dist/clients.d.ts +218 -219
  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 +70 -91
  21. package/dist/hooks.d.ts +70 -91
  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 +116 -106
  27. package/dist/index.d.ts +116 -106
  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 +25 -26
  36. package/src/_api/generated/cfg_accounts/accounts__auth/models.ts +5 -5
  37. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +42 -42
  38. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +23 -23
  39. package/src/_api/generated/cfg_accounts/enums.ts +0 -10
  40. package/src/_api/generated/cfg_accounts/schema.json +31 -25
  41. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/models.ts +57 -57
  42. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/models.ts +24 -24
  43. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_testing/models.ts +14 -14
  44. package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +14 -14
  45. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +10 -10
  46. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
  47. package/src/auth/context/AccountsContext.tsx +6 -2
  48. package/src/auth/context/AuthContext.tsx +32 -39
  49. package/src/auth/context/types.ts +5 -9
  50. package/src/auth/hooks/index.ts +1 -1
  51. package/src/auth/hooks/useAuthForm.ts +42 -75
  52. package/src/auth/hooks/useAuthFormState.ts +35 -6
  53. package/src/auth/hooks/useAuthValidation.ts +5 -65
  54. package/src/auth/hooks/useTwoFactor.ts +17 -2
  55. package/src/auth/types/form.ts +25 -70
  56. 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.228",
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.228",
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,46 @@
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
+ * Typed error response for OTP operations. error_code values: -
17
+ * invalid_identifier — malformed email - cooldown — too soon after last
18
+ * request (retry_after = seconds) - hourly_limit — hourly quota exceeded
19
+ * (retry_after = seconds until reset) - daily_limit — daily quota exceeded
20
+ * (retry_after = seconds until reset) - rate_limited — IP-level rate limit hit
21
+ * (no retry_after) - user_creation_failed — internal error creating account -
22
+ * send_failed — transport error (email / SMS) - internal_error — unexpected
23
+ * server error
24
24
  *
25
25
  * Response model (includes read-only fields).
26
26
  */
27
27
  export interface OTPErrorResponse {
28
- /** Error message */
28
+ /** Human-readable error message */
29
29
  error: string;
30
+ /** Machine-readable error code */
31
+ error_code?: string | null;
32
+ /** Seconds until the client may retry (present only for rate-limit errors) */
33
+ retry_after?: number | null;
34
+ }
35
+
36
+ /**
37
+ * OTP request response.
38
+ *
39
+ * Response model (includes read-only fields).
40
+ */
41
+ export interface OTPRequestResponse {
42
+ /** Success message */
43
+ message: string;
30
44
  }
31
45
 
32
46
  /**
@@ -51,30 +65,15 @@ export interface OTPVerifyResponse {
51
65
  should_prompt_2fa?: boolean;
52
66
  }
53
67
 
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
68
  /**
65
69
  * Serializer for OTP verification.
66
70
  *
67
71
  * Request model (no read-only fields).
68
72
  */
69
73
  export interface OTPVerifyRequest {
70
- /** Email address or phone number used for OTP request */
74
+ /** Email address used for OTP request */
71
75
  identifier: string;
72
76
  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
77
  /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
79
78
  source_url?: string;
80
79
  }
@@ -2,18 +2,18 @@
2
2
  // Auto-generated by DjangoCFG - see CLAUDE.md
3
3
  /**
4
4
  *
5
- * Response model (includes read-only fields).
5
+ * Request model (no read-only fields).
6
6
  */
7
- export interface TokenRefresh {
8
- access: string;
7
+ export interface TokenRefreshRequest {
9
8
  refresh: string;
10
9
  }
11
10
 
12
11
  /**
13
12
  *
14
- * Request model (no read-only fields).
13
+ * Response model (includes read-only fields).
15
14
  */
16
- export interface TokenRefreshRequest {
15
+ export interface TokenRefresh {
16
+ access: string;
17
17
  refresh: string;
18
18
  }
19
19
 
@@ -2,6 +2,16 @@
2
2
  // Auto-generated by DjangoCFG - see CLAUDE.md
3
3
  import * as Enums from "../enums";
4
4
 
5
+ /**
6
+ * Response with available OAuth providers.
7
+ *
8
+ * Response model (includes read-only fields).
9
+ */
10
+ export interface OAuthProvidersResponse {
11
+ /** List of available OAuth providers */
12
+ providers: Array<Record<string, any>>;
13
+ }
14
+
5
15
  /**
6
16
  * Request to disconnect OAuth provider.
7
17
  *
@@ -15,15 +25,15 @@ export interface OAuthDisconnectRequestRequest {
15
25
  }
16
26
 
17
27
  /**
18
- * Response with OAuth authorization URL.
28
+ * Error response for OAuth endpoints.
19
29
  *
20
30
  * Response model (includes read-only fields).
21
31
  */
22
- export interface OAuthAuthorizeResponse {
23
- /** Full URL to redirect user to OAuth provider */
24
- authorization_url: string;
25
- /** State token for CSRF protection. Store this and verify on callback. */
26
- state: string;
32
+ export interface OAuthError {
33
+ /** Error code */
34
+ error: string;
35
+ /** Human-readable error description */
36
+ error_description?: string;
27
37
  }
28
38
 
29
39
  /**
@@ -38,6 +48,32 @@ export interface OAuthAuthorizeRequestRequest {
38
48
  source_url?: string;
39
49
  }
40
50
 
51
+ /**
52
+ * Request to complete OAuth flow (callback handler).
53
+ *
54
+ * Request model (no read-only fields).
55
+ */
56
+ export interface OAuthCallbackRequestRequest {
57
+ /** Authorization code from OAuth provider callback */
58
+ code: string;
59
+ /** State token for CSRF verification (from authorize response) */
60
+ state: string;
61
+ /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
62
+ redirect_uri?: string;
63
+ }
64
+
65
+ /**
66
+ * Response with OAuth authorization URL.
67
+ *
68
+ * Response model (includes read-only fields).
69
+ */
70
+ export interface OAuthAuthorizeResponse {
71
+ /** Full URL to redirect user to OAuth provider */
72
+ authorization_url: string;
73
+ /** State token for CSRF protection. Store this and verify on callback. */
74
+ state: string;
75
+ }
76
+
41
77
  /**
42
78
  * Response with JWT tokens after OAuth authentication. When 2FA is required: -
43
79
  * requires_2fa: True - session_id: UUID of 2FA verification session -
@@ -65,30 +101,6 @@ export interface OAuthTokenResponse {
65
101
  should_prompt_2fa?: boolean;
66
102
  }
67
103
 
68
- /**
69
- * Response with available OAuth providers.
70
- *
71
- * Response model (includes read-only fields).
72
- */
73
- export interface OAuthProvidersResponse {
74
- /** List of available OAuth providers */
75
- providers: Array<Record<string, any>>;
76
- }
77
-
78
- /**
79
- * Request to complete OAuth flow (callback handler).
80
- *
81
- * Request model (no read-only fields).
82
- */
83
- export interface OAuthCallbackRequestRequest {
84
- /** Authorization code from OAuth provider callback */
85
- code: string;
86
- /** State token for CSRF verification (from authorize response) */
87
- state: string;
88
- /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
89
- redirect_uri?: string;
90
- }
91
-
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
-
@@ -1,5 +1,17 @@
1
1
  // @ts-nocheck
2
2
  // Auto-generated by DjangoCFG - see CLAUDE.md
3
+ /**
4
+ * Response serializer for account deletion.
5
+ *
6
+ * Response model (includes read-only fields).
7
+ */
8
+ export interface AccountDeleteResponse {
9
+ /** Whether the account was successfully deleted */
10
+ success: boolean;
11
+ /** Human-readable message about the deletion */
12
+ message: string;
13
+ }
14
+
3
15
  /**
4
16
  * Serializer for updating user profile.
5
17
  *
@@ -15,12 +27,17 @@ export interface UserProfileUpdateRequest {
15
27
  }
16
28
 
17
29
  /**
30
+ * Serializer for updating user profile.
18
31
  *
19
32
  * Request model (no read-only fields).
20
33
  */
21
- export interface CfgAccountsProfileAvatarCreateRequest {
22
- /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
23
- avatar: File | Blob;
34
+ export interface PatchedUserProfileUpdateRequest {
35
+ first_name?: string;
36
+ last_name?: string;
37
+ company?: string;
38
+ phone?: string;
39
+ position?: string;
40
+ language?: string;
24
41
  }
25
42
 
26
43
  /**
@@ -55,29 +72,12 @@ export interface User {
55
72
  }
56
73
 
57
74
  /**
58
- * Serializer for updating user profile.
59
75
  *
60
76
  * Request model (no read-only fields).
61
77
  */
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
- /**
72
- * Response serializer for account deletion.
73
- *
74
- * Response model (includes read-only fields).
75
- */
76
- export interface AccountDeleteResponse {
77
- /** Whether the account was successfully deleted */
78
- success: boolean;
79
- /** Human-readable message about the deletion */
80
- message: string;
78
+ export interface CfgAccountsProfileAvatarCreateRequest {
79
+ /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
80
+ avatar: File | Blob;
81
81
  }
82
82
 
83
83
  /**
@@ -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",