@djangocfg/api 2.1.226 → 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/dist/index.d.ts CHANGED
@@ -3,17 +3,17 @@ import { z, ZodError } from 'zod';
3
3
 
4
4
  /**
5
5
  *
6
- * Response model (includes read-only fields).
6
+ * Request model (no read-only fields).
7
7
  */
8
- interface TokenRefresh$1 {
9
- access: string;
8
+ interface TokenRefreshRequest$1 {
10
9
  refresh: string;
11
10
  }
12
11
  /**
13
12
  *
14
- * Request model (no read-only fields).
13
+ * Response model (includes read-only fields).
15
14
  */
16
- interface TokenRefreshRequest$1 {
15
+ interface TokenRefresh$1 {
16
+ access: string;
17
17
  refresh: string;
18
18
  }
19
19
 
@@ -40,24 +40,22 @@ declare class Auth {
40
40
  declare enum OAuthConnectionProvider {
41
41
  GITHUB = "github"
42
42
  }
43
- /**
44
- * Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
45
- * * `email` - Email
46
- * * `phone` - Phone
47
- */
48
- declare enum OTPRequestRequestChannel {
49
- EMAIL = "email",
50
- PHONE = "phone"
51
- }
52
43
 
53
44
  type enums_OAuthConnectionProvider = OAuthConnectionProvider;
54
45
  declare const enums_OAuthConnectionProvider: typeof OAuthConnectionProvider;
55
- type enums_OTPRequestRequestChannel = OTPRequestRequestChannel;
56
- declare const enums_OTPRequestRequestChannel: typeof OTPRequestRequestChannel;
57
46
  declare namespace enums {
58
- export { enums_OAuthConnectionProvider as OAuthConnectionProvider, enums_OTPRequestRequestChannel as OTPRequestRequestChannel };
47
+ export { enums_OAuthConnectionProvider as OAuthConnectionProvider };
59
48
  }
60
49
 
50
+ /**
51
+ * Response with available OAuth providers.
52
+ *
53
+ * Response model (includes read-only fields).
54
+ */
55
+ interface OAuthProvidersResponse$1 {
56
+ /** List of available OAuth providers */
57
+ providers: Array<Record<string, any>>;
58
+ }
61
59
  /**
62
60
  * Request to disconnect OAuth provider.
63
61
  *
@@ -70,15 +68,15 @@ interface OAuthDisconnectRequestRequest$1 {
70
68
  provider: OAuthConnectionProvider;
71
69
  }
72
70
  /**
73
- * Response with OAuth authorization URL.
71
+ * Error response for OAuth endpoints.
74
72
  *
75
73
  * Response model (includes read-only fields).
76
74
  */
77
- interface OAuthAuthorizeResponse$1 {
78
- /** Full URL to redirect user to OAuth provider */
79
- authorization_url: string;
80
- /** State token for CSRF protection. Store this and verify on callback. */
81
- state: string;
75
+ interface OAuthError$1 {
76
+ /** Error code */
77
+ error: string;
78
+ /** Human-readable error description */
79
+ error_description?: string;
82
80
  }
83
81
  /**
84
82
  * Request to start OAuth flow.
@@ -91,6 +89,30 @@ interface OAuthAuthorizeRequestRequest$1 {
91
89
  /** Optional source URL for registration tracking */
92
90
  source_url?: string;
93
91
  }
92
+ /**
93
+ * Request to complete OAuth flow (callback handler).
94
+ *
95
+ * Request model (no read-only fields).
96
+ */
97
+ interface OAuthCallbackRequestRequest$1 {
98
+ /** Authorization code from OAuth provider callback */
99
+ code: string;
100
+ /** State token for CSRF verification (from authorize response) */
101
+ state: string;
102
+ /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
103
+ redirect_uri?: string;
104
+ }
105
+ /**
106
+ * Response with OAuth authorization URL.
107
+ *
108
+ * Response model (includes read-only fields).
109
+ */
110
+ interface OAuthAuthorizeResponse$1 {
111
+ /** Full URL to redirect user to OAuth provider */
112
+ authorization_url: string;
113
+ /** State token for CSRF protection. Store this and verify on callback. */
114
+ state: string;
115
+ }
94
116
  /**
95
117
  * Response with JWT tokens after OAuth authentication. When 2FA is required: -
96
118
  * requires_2fa: True - session_id: UUID of 2FA verification session -
@@ -117,28 +139,6 @@ interface OAuthTokenResponse$1 {
117
139
  /** True if user should be prompted to enable 2FA */
118
140
  should_prompt_2fa?: boolean;
119
141
  }
120
- /**
121
- * Response with available OAuth providers.
122
- *
123
- * Response model (includes read-only fields).
124
- */
125
- interface OAuthProvidersResponse$1 {
126
- /** List of available OAuth providers */
127
- providers: Array<Record<string, any>>;
128
- }
129
- /**
130
- * Request to complete OAuth flow (callback handler).
131
- *
132
- * Request model (no read-only fields).
133
- */
134
- interface OAuthCallbackRequestRequest$1 {
135
- /** Authorization code from OAuth provider callback */
136
- code: string;
137
- /** State token for CSRF verification (from authorize response) */
138
- state: string;
139
- /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
140
- redirect_uri?: string;
141
- }
142
142
  /**
143
143
  * Serializer for OAuth connection info (user-facing).
144
144
  *
@@ -162,17 +162,6 @@ interface OAuthConnection$1 {
162
162
  /** Last time this OAuth connection was used for login */
163
163
  last_login_at: string;
164
164
  }
165
- /**
166
- * Error response for OAuth endpoints.
167
- *
168
- * Response model (includes read-only fields).
169
- */
170
- interface OAuthError$1 {
171
- /** Error code */
172
- error: string;
173
- /** Human-readable error description */
174
- error_description?: string;
175
- }
176
165
 
177
166
  declare namespace models$2 {
178
167
  export type { OAuthAuthorizeRequestRequest$1 as OAuthAuthorizeRequestRequest, OAuthAuthorizeResponse$1 as OAuthAuthorizeResponse, OAuthCallbackRequestRequest$1 as OAuthCallbackRequestRequest, OAuthConnection$1 as OAuthConnection, OAuthDisconnectRequestRequest$1 as OAuthDisconnectRequestRequest, OAuthError$1 as OAuthError, OAuthProvidersResponse$1 as OAuthProvidersResponse, OAuthTokenResponse$1 as OAuthTokenResponse };
@@ -218,6 +207,17 @@ declare class Oauth {
218
207
  accountsOauthProvidersRetrieve(): Promise<OAuthProvidersResponse$1>;
219
208
  }
220
209
 
210
+ /**
211
+ * Response serializer for account deletion.
212
+ *
213
+ * Response model (includes read-only fields).
214
+ */
215
+ interface AccountDeleteResponse$1 {
216
+ /** Whether the account was successfully deleted */
217
+ success: boolean;
218
+ /** Human-readable message about the deletion */
219
+ message: string;
220
+ }
221
221
  /**
222
222
  * Serializer for updating user profile.
223
223
  *
@@ -232,12 +232,17 @@ interface UserProfileUpdateRequest$1 {
232
232
  language?: string;
233
233
  }
234
234
  /**
235
+ * Serializer for updating user profile.
235
236
  *
236
237
  * Request model (no read-only fields).
237
238
  */
238
- interface CfgAccountsProfileAvatarCreateRequest$1 {
239
- /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
240
- avatar: File | Blob;
239
+ interface PatchedUserProfileUpdateRequest$1 {
240
+ first_name?: string;
241
+ last_name?: string;
242
+ company?: string;
243
+ phone?: string;
244
+ position?: string;
245
+ language?: string;
241
246
  }
242
247
  /**
243
248
  * Serializer for user details.
@@ -270,28 +275,12 @@ interface User$2 {
270
275
  centrifugo: CentrifugoToken$2 | null;
271
276
  }
272
277
  /**
273
- * Serializer for updating user profile.
274
278
  *
275
279
  * Request model (no read-only fields).
276
280
  */
277
- interface PatchedUserProfileUpdateRequest$1 {
278
- first_name?: string;
279
- last_name?: string;
280
- company?: string;
281
- phone?: string;
282
- position?: string;
283
- language?: string;
284
- }
285
- /**
286
- * Response serializer for account deletion.
287
- *
288
- * Response model (includes read-only fields).
289
- */
290
- interface AccountDeleteResponse$1 {
291
- /** Whether the account was successfully deleted */
292
- success: boolean;
293
- /** Human-readable message about the deletion */
294
- message: string;
281
+ interface CfgAccountsProfileAvatarCreateRequest$1 {
282
+ /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
283
+ avatar: File | Blob;
295
284
  }
296
285
  /**
297
286
  * Nested serializer for Centrifugo WebSocket connection token.
@@ -376,24 +365,39 @@ declare class UserProfile {
376
365
  * Request model (no read-only fields).
377
366
  */
378
367
  interface OTPRequestRequest$1 {
379
- /** Email address or phone number for OTP delivery */
368
+ /** Email address for OTP delivery */
380
369
  identifier: string;
381
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
382
-
383
- * `email` - Email
384
- * `phone` - Phone */
385
- channel?: OTPRequestRequestChannel;
386
370
  /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
387
371
  source_url?: string;
388
372
  }
389
373
  /**
390
- * Error response for OTP operations.
374
+ * Typed error response for OTP operations. error_code values: -
375
+ * invalid_identifier — malformed email - cooldown — too soon after last
376
+ * request (retry_after = seconds) - hourly_limit — hourly quota exceeded
377
+ * (retry_after = seconds until reset) - daily_limit — daily quota exceeded
378
+ * (retry_after = seconds until reset) - rate_limited — IP-level rate limit hit
379
+ * (no retry_after) - user_creation_failed — internal error creating account -
380
+ * send_failed — transport error (email / SMS) - internal_error — unexpected
381
+ * server error
391
382
  *
392
383
  * Response model (includes read-only fields).
393
384
  */
394
385
  interface OTPErrorResponse$1 {
395
- /** Error message */
386
+ /** Human-readable error message */
396
387
  error: string;
388
+ /** Machine-readable error code */
389
+ error_code?: string | null;
390
+ /** Seconds until the client may retry (present only for rate-limit errors) */
391
+ retry_after?: number | null;
392
+ }
393
+ /**
394
+ * OTP request response.
395
+ *
396
+ * Response model (includes read-only fields).
397
+ */
398
+ interface OTPRequestResponse$1 {
399
+ /** Success message */
400
+ message: string;
397
401
  }
398
402
  /**
399
403
  * OTP verification response. When 2FA is required: - requires_2fa: True -
@@ -416,29 +420,15 @@ interface OTPVerifyResponse$1 {
416
420
  /** Whether user should be prompted to enable 2FA */
417
421
  should_prompt_2fa?: boolean;
418
422
  }
419
- /**
420
- * OTP request response.
421
- *
422
- * Response model (includes read-only fields).
423
- */
424
- interface OTPRequestResponse$1 {
425
- /** Success message */
426
- message: string;
427
- }
428
423
  /**
429
424
  * Serializer for OTP verification.
430
425
  *
431
426
  * Request model (no read-only fields).
432
427
  */
433
428
  interface OTPVerifyRequest$1 {
434
- /** Email address or phone number used for OTP request */
429
+ /** Email address used for OTP request */
435
430
  identifier: string;
436
431
  otp: string;
437
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
438
-
439
- * `email` - Email
440
- * `phone` - Phone */
441
- channel?: OTPRequestRequestChannel;
442
432
  /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
443
433
  source_url?: string;
444
434
  }
@@ -499,7 +489,7 @@ declare class Accounts {
499
489
  private client;
500
490
  constructor(client: any);
501
491
  /**
502
- * Request OTP code to email or phone.
492
+ * Request OTP code to email.
503
493
  */
504
494
  otpRequestCreate(data: OTPRequestRequest$1): Promise<OTPRequestResponse$1>;
505
495
  /**
@@ -1135,14 +1125,36 @@ type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
1135
1125
  * Zod schema for OTPErrorResponse
1136
1126
  *
1137
1127
  * This schema provides runtime validation and type inference.
1138
- * * Error response for OTP operations.
1128
+ * * Typed error response for OTP operations.
1129
+
1130
+ error_code values:
1131
+ - invalid_identifier — malformed email
1132
+ - cooldown — too soon after last request (retry_after = seconds)
1133
+ - hourly_limit — hourly quota exceeded (retry_after = seconds until reset)
1134
+ - daily_limit — daily quota exceeded (retry_after = seconds until reset)
1135
+ - rate_limited — IP-level rate limit hit (no retry_after)
1136
+ - user_creation_failed — internal error creating account
1137
+ - send_failed — transport error (email / SMS)
1138
+ - internal_error — unexpected server error
1139
1139
  * */
1140
1140
 
1141
1141
  /**
1142
- * Error response for OTP operations.
1142
+ * Typed error response for OTP operations.
1143
+
1144
+ error_code values:
1145
+ - invalid_identifier — malformed email
1146
+ - cooldown — too soon after last request (retry_after = seconds)
1147
+ - hourly_limit — hourly quota exceeded (retry_after = seconds until reset)
1148
+ - daily_limit — daily quota exceeded (retry_after = seconds until reset)
1149
+ - rate_limited — IP-level rate limit hit (no retry_after)
1150
+ - user_creation_failed — internal error creating account
1151
+ - send_failed — transport error (email / SMS)
1152
+ - internal_error — unexpected server error
1143
1153
  */
1144
1154
  declare const OTPErrorResponseSchema: z.ZodObject<{
1145
1155
  error: z.ZodString;
1156
+ error_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1157
+ retry_after: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1146
1158
  }, z.core.$strip>;
1147
1159
  /**
1148
1160
  * Infer TypeScript type from Zod schema
@@ -1161,7 +1173,6 @@ type OTPErrorResponse = z.infer<typeof OTPErrorResponseSchema>;
1161
1173
  */
1162
1174
  declare const OTPRequestRequestSchema: z.ZodObject<{
1163
1175
  identifier: z.ZodString;
1164
- channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
1165
1176
  source_url: z.ZodOptional<z.ZodString>;
1166
1177
  }, z.core.$strip>;
1167
1178
  /**
@@ -1200,7 +1211,6 @@ type OTPRequestResponse = z.infer<typeof OTPRequestResponseSchema>;
1200
1211
  declare const OTPVerifyRequestSchema: z.ZodObject<{
1201
1212
  identifier: z.ZodString;
1202
1213
  otp: z.ZodString;
1203
- channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
1204
1214
  source_url: z.ZodOptional<z.ZodString>;
1205
1215
  }, z.core.$strip>;
1206
1216
  /**
package/dist/index.mjs CHANGED
@@ -252,7 +252,7 @@ var Accounts = class {
252
252
  this.client = client;
253
253
  }
254
254
  /**
255
- * Request OTP code to email or phone.
255
+ * Request OTP code to email.
256
256
  */
257
257
  async otpRequestCreate(data) {
258
258
  const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
@@ -985,18 +985,12 @@ var MemoryStorageAdapter = class {
985
985
  // src/_api/generated/cfg_accounts/enums.ts
986
986
  var enums_exports = {};
987
987
  __export(enums_exports, {
988
- OAuthConnectionProvider: () => OAuthConnectionProvider,
989
- OTPRequestRequestChannel: () => OTPRequestRequestChannel
988
+ OAuthConnectionProvider: () => OAuthConnectionProvider
990
989
  });
991
990
  var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
992
991
  OAuthConnectionProvider2["GITHUB"] = "github";
993
992
  return OAuthConnectionProvider2;
994
993
  })(OAuthConnectionProvider || {});
995
- var OTPRequestRequestChannel = /* @__PURE__ */ ((OTPRequestRequestChannel2) => {
996
- OTPRequestRequestChannel2["EMAIL"] = "email";
997
- OTPRequestRequestChannel2["PHONE"] = "phone";
998
- return OTPRequestRequestChannel2;
999
- })(OTPRequestRequestChannel || {});
1000
994
 
1001
995
  // src/_api/generated/cfg_accounts/_utils/schemas/index.ts
1002
996
  var schemas_exports = {};
@@ -1116,14 +1110,15 @@ var OAuthTokenResponseSchema = z11.object({
1116
1110
  // src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
1117
1111
  import { z as z12 } from "zod";
1118
1112
  var OTPErrorResponseSchema = z12.object({
1119
- error: z12.string()
1113
+ error: z12.string(),
1114
+ error_code: z12.string().nullable().optional(),
1115
+ retry_after: z12.number().int().nullable().optional()
1120
1116
  });
1121
1117
 
1122
1118
  // src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
1123
1119
  import { z as z13 } from "zod";
1124
1120
  var OTPRequestRequestSchema = z13.object({
1125
1121
  identifier: z13.string().min(1),
1126
- channel: z13.nativeEnum(OTPRequestRequestChannel).optional(),
1127
1122
  source_url: z13.string().optional()
1128
1123
  });
1129
1124
 
@@ -1138,7 +1133,6 @@ import { z as z15 } from "zod";
1138
1133
  var OTPVerifyRequestSchema = z15.object({
1139
1134
  identifier: z15.string().min(1),
1140
1135
  otp: z15.string().min(6).max(6),
1141
- channel: z15.nativeEnum(OTPRequestRequestChannel).optional(),
1142
1136
  source_url: z15.string().optional()
1143
1137
  });
1144
1138