@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/dist/hooks.d.cts CHANGED
@@ -37,27 +37,7 @@ declare class Auth {
37
37
  declare enum OAuthConnectionProvider {
38
38
  GITHUB = "github"
39
39
  }
40
- /**
41
- * Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
42
- * * `email` - Email
43
- * * `phone` - Phone
44
- */
45
- declare enum OTPRequestRequestChannel {
46
- EMAIL = "email",
47
- PHONE = "phone"
48
- }
49
40
 
50
- /**
51
- * Request to disconnect OAuth provider.
52
- *
53
- * Request model (no read-only fields).
54
- */
55
- interface OAuthDisconnectRequestRequest$1 {
56
- /** OAuth provider to disconnect
57
-
58
- * `github` - GitHub */
59
- provider: OAuthConnectionProvider;
60
- }
61
41
  /**
62
42
  * Response with OAuth authorization URL.
63
43
  *
@@ -69,17 +49,6 @@ interface OAuthAuthorizeResponse$1 {
69
49
  /** State token for CSRF protection. Store this and verify on callback. */
70
50
  state: string;
71
51
  }
72
- /**
73
- * Request to start OAuth flow.
74
- *
75
- * Request model (no read-only fields).
76
- */
77
- interface OAuthAuthorizeRequestRequest$1 {
78
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
79
- redirect_uri?: string;
80
- /** Optional source URL for registration tracking */
81
- source_url?: string;
82
- }
83
52
  /**
84
53
  * Response with JWT tokens after OAuth authentication. When 2FA is required: -
85
54
  * requires_2fa: True - session_id: UUID of 2FA verification session -
@@ -107,13 +76,15 @@ interface OAuthTokenResponse$1 {
107
76
  should_prompt_2fa?: boolean;
108
77
  }
109
78
  /**
110
- * Response with available OAuth providers.
79
+ * Request to start OAuth flow.
111
80
  *
112
- * Response model (includes read-only fields).
81
+ * Request model (no read-only fields).
113
82
  */
114
- interface OAuthProvidersResponse {
115
- /** List of available OAuth providers */
116
- providers: Array<Record<string, any>>;
83
+ interface OAuthAuthorizeRequestRequest$1 {
84
+ /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
85
+ redirect_uri?: string;
86
+ /** Optional source URL for registration tracking */
87
+ source_url?: string;
117
88
  }
118
89
  /**
119
90
  * Request to complete OAuth flow (callback handler).
@@ -128,6 +99,26 @@ interface OAuthCallbackRequestRequest$1 {
128
99
  /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
129
100
  redirect_uri?: string;
130
101
  }
102
+ /**
103
+ * Request to disconnect OAuth provider.
104
+ *
105
+ * Request model (no read-only fields).
106
+ */
107
+ interface OAuthDisconnectRequestRequest$1 {
108
+ /** OAuth provider to disconnect
109
+
110
+ * `github` - GitHub */
111
+ provider: OAuthConnectionProvider;
112
+ }
113
+ /**
114
+ * Response with available OAuth providers.
115
+ *
116
+ * Response model (includes read-only fields).
117
+ */
118
+ interface OAuthProvidersResponse {
119
+ /** List of available OAuth providers */
120
+ providers: Array<Record<string, any>>;
121
+ }
131
122
 
132
123
  /**
133
124
  * API endpoints for Oauth.
@@ -174,7 +165,7 @@ declare class Oauth {
174
165
  *
175
166
  * Request model (no read-only fields).
176
167
  */
177
- interface UserProfileUpdateRequest$1 {
168
+ interface PatchedUserProfileUpdateRequest$1 {
178
169
  first_name?: string;
179
170
  last_name?: string;
180
171
  company?: string;
@@ -190,6 +181,19 @@ interface CfgAccountsProfileAvatarCreateRequest$1 {
190
181
  /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
191
182
  avatar: File | Blob;
192
183
  }
184
+ /**
185
+ * Serializer for updating user profile.
186
+ *
187
+ * Request model (no read-only fields).
188
+ */
189
+ interface UserProfileUpdateRequest$1 {
190
+ first_name?: string;
191
+ last_name?: string;
192
+ company?: string;
193
+ phone?: string;
194
+ position?: string;
195
+ language?: string;
196
+ }
193
197
  /**
194
198
  * Serializer for user details.
195
199
  *
@@ -220,19 +224,6 @@ interface User$2 {
220
224
  unanswered_messages_count: number;
221
225
  centrifugo: CentrifugoToken$1 | null;
222
226
  }
223
- /**
224
- * Serializer for updating user profile.
225
- *
226
- * Request model (no read-only fields).
227
- */
228
- interface PatchedUserProfileUpdateRequest$1 {
229
- first_name?: string;
230
- last_name?: string;
231
- company?: string;
232
- phone?: string;
233
- position?: string;
234
- language?: string;
235
- }
236
227
  /**
237
228
  * Response serializer for account deletion.
238
229
  *
@@ -323,16 +314,32 @@ declare class UserProfile {
323
314
  * Request model (no read-only fields).
324
315
  */
325
316
  interface OTPRequestRequest$1 {
326
- /** Email address or phone number for OTP delivery */
317
+ /** Email address for OTP delivery */
327
318
  identifier: string;
328
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
329
-
330
- * `email` - Email
331
- * `phone` - Phone */
332
- channel?: OTPRequestRequestChannel;
333
319
  /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
334
320
  source_url?: string;
335
321
  }
322
+ /**
323
+ * Serializer for OTP verification.
324
+ *
325
+ * Request model (no read-only fields).
326
+ */
327
+ interface OTPVerifyRequest$1 {
328
+ /** Email address used for OTP request */
329
+ identifier: string;
330
+ otp: string;
331
+ /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
332
+ source_url?: string;
333
+ }
334
+ /**
335
+ * OTP request response.
336
+ *
337
+ * Response model (includes read-only fields).
338
+ */
339
+ interface OTPRequestResponse$1 {
340
+ /** Success message */
341
+ message: string;
342
+ }
336
343
  /**
337
344
  * OTP verification response. When 2FA is required: - requires_2fa: True -
338
345
  * session_id: UUID of 2FA verification session - refresh/access/user: null
@@ -354,32 +361,6 @@ interface OTPVerifyResponse$1 {
354
361
  /** Whether user should be prompted to enable 2FA */
355
362
  should_prompt_2fa?: boolean;
356
363
  }
357
- /**
358
- * OTP request response.
359
- *
360
- * Response model (includes read-only fields).
361
- */
362
- interface OTPRequestResponse$1 {
363
- /** Success message */
364
- message: string;
365
- }
366
- /**
367
- * Serializer for OTP verification.
368
- *
369
- * Request model (no read-only fields).
370
- */
371
- interface OTPVerifyRequest$1 {
372
- /** Email address or phone number used for OTP request */
373
- identifier: string;
374
- otp: string;
375
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
376
-
377
- * `email` - Email
378
- * `phone` - Phone */
379
- channel?: OTPRequestRequestChannel;
380
- /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
381
- source_url?: string;
382
- }
383
364
  /**
384
365
  * Serializer for user details.
385
366
  *
@@ -433,7 +414,7 @@ declare class Accounts {
433
414
  private client;
434
415
  constructor(client: any);
435
416
  /**
436
- * Request OTP code to email or phone.
417
+ * Request OTP code to email.
437
418
  */
438
419
  otpRequestCreate(data: OTPRequestRequest$1): Promise<OTPRequestResponse$1>;
439
420
  /**
@@ -712,7 +693,6 @@ type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
712
693
  */
713
694
  declare const OTPRequestRequestSchema: z.ZodObject<{
714
695
  identifier: z.ZodString;
715
- channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
716
696
  source_url: z.ZodOptional<z.ZodString>;
717
697
  }, z.core.$strip>;
718
698
  /**
@@ -751,7 +731,6 @@ type OTPRequestResponse = z.infer<typeof OTPRequestResponseSchema>;
751
731
  declare const OTPVerifyRequestSchema: z.ZodObject<{
752
732
  identifier: z.ZodString;
753
733
  otp: z.ZodString;
754
- channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
755
734
  source_url: z.ZodOptional<z.ZodString>;
756
735
  }, z.core.$strip>;
757
736
  /**
package/dist/hooks.d.ts CHANGED
@@ -37,27 +37,7 @@ declare class Auth {
37
37
  declare enum OAuthConnectionProvider {
38
38
  GITHUB = "github"
39
39
  }
40
- /**
41
- * Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
42
- * * `email` - Email
43
- * * `phone` - Phone
44
- */
45
- declare enum OTPRequestRequestChannel {
46
- EMAIL = "email",
47
- PHONE = "phone"
48
- }
49
40
 
50
- /**
51
- * Request to disconnect OAuth provider.
52
- *
53
- * Request model (no read-only fields).
54
- */
55
- interface OAuthDisconnectRequestRequest$1 {
56
- /** OAuth provider to disconnect
57
-
58
- * `github` - GitHub */
59
- provider: OAuthConnectionProvider;
60
- }
61
41
  /**
62
42
  * Response with OAuth authorization URL.
63
43
  *
@@ -69,17 +49,6 @@ interface OAuthAuthorizeResponse$1 {
69
49
  /** State token for CSRF protection. Store this and verify on callback. */
70
50
  state: string;
71
51
  }
72
- /**
73
- * Request to start OAuth flow.
74
- *
75
- * Request model (no read-only fields).
76
- */
77
- interface OAuthAuthorizeRequestRequest$1 {
78
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
79
- redirect_uri?: string;
80
- /** Optional source URL for registration tracking */
81
- source_url?: string;
82
- }
83
52
  /**
84
53
  * Response with JWT tokens after OAuth authentication. When 2FA is required: -
85
54
  * requires_2fa: True - session_id: UUID of 2FA verification session -
@@ -107,13 +76,15 @@ interface OAuthTokenResponse$1 {
107
76
  should_prompt_2fa?: boolean;
108
77
  }
109
78
  /**
110
- * Response with available OAuth providers.
79
+ * Request to start OAuth flow.
111
80
  *
112
- * Response model (includes read-only fields).
81
+ * Request model (no read-only fields).
113
82
  */
114
- interface OAuthProvidersResponse {
115
- /** List of available OAuth providers */
116
- providers: Array<Record<string, any>>;
83
+ interface OAuthAuthorizeRequestRequest$1 {
84
+ /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
85
+ redirect_uri?: string;
86
+ /** Optional source URL for registration tracking */
87
+ source_url?: string;
117
88
  }
118
89
  /**
119
90
  * Request to complete OAuth flow (callback handler).
@@ -128,6 +99,26 @@ interface OAuthCallbackRequestRequest$1 {
128
99
  /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
129
100
  redirect_uri?: string;
130
101
  }
102
+ /**
103
+ * Request to disconnect OAuth provider.
104
+ *
105
+ * Request model (no read-only fields).
106
+ */
107
+ interface OAuthDisconnectRequestRequest$1 {
108
+ /** OAuth provider to disconnect
109
+
110
+ * `github` - GitHub */
111
+ provider: OAuthConnectionProvider;
112
+ }
113
+ /**
114
+ * Response with available OAuth providers.
115
+ *
116
+ * Response model (includes read-only fields).
117
+ */
118
+ interface OAuthProvidersResponse {
119
+ /** List of available OAuth providers */
120
+ providers: Array<Record<string, any>>;
121
+ }
131
122
 
132
123
  /**
133
124
  * API endpoints for Oauth.
@@ -174,7 +165,7 @@ declare class Oauth {
174
165
  *
175
166
  * Request model (no read-only fields).
176
167
  */
177
- interface UserProfileUpdateRequest$1 {
168
+ interface PatchedUserProfileUpdateRequest$1 {
178
169
  first_name?: string;
179
170
  last_name?: string;
180
171
  company?: string;
@@ -190,6 +181,19 @@ interface CfgAccountsProfileAvatarCreateRequest$1 {
190
181
  /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
191
182
  avatar: File | Blob;
192
183
  }
184
+ /**
185
+ * Serializer for updating user profile.
186
+ *
187
+ * Request model (no read-only fields).
188
+ */
189
+ interface UserProfileUpdateRequest$1 {
190
+ first_name?: string;
191
+ last_name?: string;
192
+ company?: string;
193
+ phone?: string;
194
+ position?: string;
195
+ language?: string;
196
+ }
193
197
  /**
194
198
  * Serializer for user details.
195
199
  *
@@ -220,19 +224,6 @@ interface User$2 {
220
224
  unanswered_messages_count: number;
221
225
  centrifugo: CentrifugoToken$1 | null;
222
226
  }
223
- /**
224
- * Serializer for updating user profile.
225
- *
226
- * Request model (no read-only fields).
227
- */
228
- interface PatchedUserProfileUpdateRequest$1 {
229
- first_name?: string;
230
- last_name?: string;
231
- company?: string;
232
- phone?: string;
233
- position?: string;
234
- language?: string;
235
- }
236
227
  /**
237
228
  * Response serializer for account deletion.
238
229
  *
@@ -323,16 +314,32 @@ declare class UserProfile {
323
314
  * Request model (no read-only fields).
324
315
  */
325
316
  interface OTPRequestRequest$1 {
326
- /** Email address or phone number for OTP delivery */
317
+ /** Email address for OTP delivery */
327
318
  identifier: string;
328
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
329
-
330
- * `email` - Email
331
- * `phone` - Phone */
332
- channel?: OTPRequestRequestChannel;
333
319
  /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
334
320
  source_url?: string;
335
321
  }
322
+ /**
323
+ * Serializer for OTP verification.
324
+ *
325
+ * Request model (no read-only fields).
326
+ */
327
+ interface OTPVerifyRequest$1 {
328
+ /** Email address used for OTP request */
329
+ identifier: string;
330
+ otp: string;
331
+ /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
332
+ source_url?: string;
333
+ }
334
+ /**
335
+ * OTP request response.
336
+ *
337
+ * Response model (includes read-only fields).
338
+ */
339
+ interface OTPRequestResponse$1 {
340
+ /** Success message */
341
+ message: string;
342
+ }
336
343
  /**
337
344
  * OTP verification response. When 2FA is required: - requires_2fa: True -
338
345
  * session_id: UUID of 2FA verification session - refresh/access/user: null
@@ -354,32 +361,6 @@ interface OTPVerifyResponse$1 {
354
361
  /** Whether user should be prompted to enable 2FA */
355
362
  should_prompt_2fa?: boolean;
356
363
  }
357
- /**
358
- * OTP request response.
359
- *
360
- * Response model (includes read-only fields).
361
- */
362
- interface OTPRequestResponse$1 {
363
- /** Success message */
364
- message: string;
365
- }
366
- /**
367
- * Serializer for OTP verification.
368
- *
369
- * Request model (no read-only fields).
370
- */
371
- interface OTPVerifyRequest$1 {
372
- /** Email address or phone number used for OTP request */
373
- identifier: string;
374
- otp: string;
375
- /** Delivery channel: 'email' or 'phone'. Auto-detected if not provided.
376
-
377
- * `email` - Email
378
- * `phone` - Phone */
379
- channel?: OTPRequestRequestChannel;
380
- /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
381
- source_url?: string;
382
- }
383
364
  /**
384
365
  * Serializer for user details.
385
366
  *
@@ -433,7 +414,7 @@ declare class Accounts {
433
414
  private client;
434
415
  constructor(client: any);
435
416
  /**
436
- * Request OTP code to email or phone.
417
+ * Request OTP code to email.
437
418
  */
438
419
  otpRequestCreate(data: OTPRequestRequest$1): Promise<OTPRequestResponse$1>;
439
420
  /**
@@ -712,7 +693,6 @@ type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
712
693
  */
713
694
  declare const OTPRequestRequestSchema: z.ZodObject<{
714
695
  identifier: z.ZodString;
715
- channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
716
696
  source_url: z.ZodOptional<z.ZodString>;
717
697
  }, z.core.$strip>;
718
698
  /**
@@ -751,7 +731,6 @@ type OTPRequestResponse = z.infer<typeof OTPRequestResponseSchema>;
751
731
  declare const OTPVerifyRequestSchema: z.ZodObject<{
752
732
  identifier: z.ZodString;
753
733
  otp: z.ZodString;
754
- channel: z.ZodOptional<z.ZodEnum<typeof OTPRequestRequestChannel>>;
755
734
  source_url: z.ZodOptional<z.ZodString>;
756
735
  }, z.core.$strip>;
757
736
  /**
package/dist/hooks.mjs CHANGED
@@ -181,7 +181,7 @@ var Accounts = class {
181
181
  this.client = client;
182
182
  }
183
183
  /**
184
- * Request OTP code to email or phone.
184
+ * Request OTP code to email.
185
185
  */
186
186
  async otpRequestCreate(data) {
187
187
  const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
@@ -826,11 +826,6 @@ var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
826
826
  OAuthConnectionProvider2["GITHUB"] = "github";
827
827
  return OAuthConnectionProvider2;
828
828
  })(OAuthConnectionProvider || {});
829
- var OTPRequestRequestChannel = /* @__PURE__ */ ((OTPRequestRequestChannel2) => {
830
- OTPRequestRequestChannel2["EMAIL"] = "email";
831
- OTPRequestRequestChannel2["PHONE"] = "phone";
832
- return OTPRequestRequestChannel2;
833
- })(OTPRequestRequestChannel || {});
834
829
 
835
830
  // src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts
836
831
  import { z as z2 } from "zod";
@@ -924,14 +919,15 @@ var OAuthTokenResponseSchema = z12.object({
924
919
  // src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
925
920
  import { z as z13 } from "zod";
926
921
  var OTPErrorResponseSchema = z13.object({
927
- error: z13.string()
922
+ error: z13.string(),
923
+ error_code: z13.string().nullable().optional(),
924
+ retry_after: z13.number().int().nullable().optional()
928
925
  });
929
926
 
930
927
  // src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
931
928
  import { z as z14 } from "zod";
932
929
  var OTPRequestRequestSchema = z14.object({
933
930
  identifier: z14.string().min(1),
934
- channel: z14.nativeEnum(OTPRequestRequestChannel).optional(),
935
931
  source_url: z14.string().optional()
936
932
  });
937
933
 
@@ -946,7 +942,6 @@ import { z as z16 } from "zod";
946
942
  var OTPVerifyRequestSchema = z16.object({
947
943
  identifier: z16.string().min(1),
948
944
  otp: z16.string().min(6).max(6),
949
- channel: z16.nativeEnum(OTPRequestRequestChannel).optional(),
950
945
  source_url: z16.string().optional()
951
946
  });
952
947