@djangocfg/api 2.1.56 → 2.1.58

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 (75) hide show
  1. package/README.md +125 -9
  2. package/dist/auth.cjs +1865 -402
  3. package/dist/auth.cjs.map +1 -1
  4. package/dist/auth.d.cts +352 -76
  5. package/dist/auth.d.ts +352 -76
  6. package/dist/auth.mjs +1867 -404
  7. package/dist/auth.mjs.map +1 -1
  8. package/dist/clients.cjs +1637 -137
  9. package/dist/clients.cjs.map +1 -1
  10. package/dist/clients.d.cts +1394 -282
  11. package/dist/clients.d.ts +1394 -282
  12. package/dist/clients.mjs +1637 -137
  13. package/dist/clients.mjs.map +1 -1
  14. package/dist/hooks.cjs +24 -11
  15. package/dist/hooks.cjs.map +1 -1
  16. package/dist/hooks.d.cts +88 -21
  17. package/dist/hooks.d.ts +88 -21
  18. package/dist/hooks.mjs +24 -11
  19. package/dist/hooks.mjs.map +1 -1
  20. package/dist/index.cjs +38 -17
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +94 -21
  23. package/dist/index.d.ts +94 -21
  24. package/dist/index.mjs +38 -17
  25. package/dist/index.mjs.map +1 -1
  26. package/package.json +3 -3
  27. package/src/auth/context/AccountsContext.tsx +8 -1
  28. package/src/auth/context/AuthContext.tsx +31 -8
  29. package/src/auth/context/types.ts +8 -1
  30. package/src/auth/hooks/index.ts +29 -5
  31. package/src/auth/hooks/useAuthForm.ts +292 -226
  32. package/src/auth/hooks/useAuthFormState.ts +60 -0
  33. package/src/auth/hooks/useAuthValidation.ts +77 -0
  34. package/src/auth/hooks/useGithubAuth.ts +26 -5
  35. package/src/auth/hooks/useTwoFactor.ts +239 -0
  36. package/src/auth/hooks/useTwoFactorSetup.ts +213 -0
  37. package/src/auth/index.ts +3 -0
  38. package/src/auth/types/form.ts +194 -0
  39. package/src/auth/types/index.ts +28 -0
  40. package/src/clients.ts +10 -0
  41. package/src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +26 -3
  42. package/src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts +26 -3
  43. package/src/generated/cfg_accounts/accounts/client.ts +4 -1
  44. package/src/generated/cfg_accounts/accounts/models.ts +15 -6
  45. package/src/generated/cfg_accounts/accounts__oauth/models.ts +16 -7
  46. package/src/generated/cfg_accounts/client.ts +5 -2
  47. package/src/generated/cfg_accounts/http.ts +8 -2
  48. package/src/generated/cfg_accounts/schema.json +47 -19
  49. package/src/generated/cfg_centrifugo/client.ts +5 -2
  50. package/src/generated/cfg_centrifugo/http.ts +8 -2
  51. package/src/generated/cfg_totp/CLAUDE.md +12 -12
  52. package/src/generated/cfg_totp/_utils/fetchers/index.ts +3 -3
  53. package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_management.ts → totp__totp_management.ts} +3 -3
  54. package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_setup.ts → totp__totp_setup.ts} +3 -3
  55. package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_verification.ts → totp__totp_verification.ts} +3 -3
  56. package/src/generated/cfg_totp/_utils/hooks/index.ts +3 -3
  57. package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_management.ts → totp__totp_management.ts} +2 -2
  58. package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_setup.ts → totp__totp_setup.ts} +2 -2
  59. package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_verification.ts → totp__totp_verification.ts} +2 -2
  60. package/src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +1 -1
  61. package/src/generated/cfg_totp/client.ts +14 -11
  62. package/src/generated/cfg_totp/http.ts +8 -2
  63. package/src/generated/cfg_totp/index.ts +16 -16
  64. package/src/generated/cfg_totp/schema.json +8 -7
  65. package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/client.ts +2 -2
  66. package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/models.ts +1 -1
  67. package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/client.ts +4 -4
  68. package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/client.ts +2 -2
  69. package/src/generated/cfg_webpush/client.ts +5 -2
  70. package/src/generated/cfg_webpush/http.ts +8 -2
  71. /package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/index.ts +0 -0
  72. /package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/index.ts +0 -0
  73. /package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/models.ts +0 -0
  74. /package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/index.ts +0 -0
  75. /package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/models.ts +0 -0
package/dist/hooks.cjs CHANGED
@@ -218,7 +218,10 @@ var Accounts = class {
218
218
  return response;
219
219
  }
220
220
  /**
221
- * Verify OTP code and return JWT tokens.
221
+ * Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
222
+ * enabled: - Returns requires_2fa=True with session_id - Client must
223
+ * complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
224
+ * Returns JWT tokens and user data directly
222
225
  */
223
226
  async otpVerifyCreate(data) {
224
227
  const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
@@ -232,7 +235,7 @@ var FetchAdapter = class {
232
235
  __name(this, "FetchAdapter");
233
236
  }
234
237
  async request(request) {
235
- const { method, url, headers, body, params, formData } = request;
238
+ const { method, url, headers, body, params, formData, binaryBody } = request;
236
239
  let finalUrl = url;
237
240
  if (params) {
238
241
  const searchParams = new URLSearchParams();
@@ -250,6 +253,9 @@ var FetchAdapter = class {
250
253
  let requestBody;
251
254
  if (formData) {
252
255
  requestBody = formData;
256
+ } else if (binaryBody) {
257
+ finalHeaders["Content-Type"] = "application/octet-stream";
258
+ requestBody = binaryBody;
253
259
  } else if (body) {
254
260
  finalHeaders["Content-Type"] = "application/json";
255
261
  requestBody = JSON.stringify(body);
@@ -649,7 +655,7 @@ var APIClient = class {
649
655
  const headers = {
650
656
  ...options?.headers || {}
651
657
  };
652
- if (!options?.formData && !headers["Content-Type"]) {
658
+ if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
653
659
  headers["Content-Type"] = "application/json";
654
660
  }
655
661
  if (this.logger) {
@@ -668,7 +674,8 @@ var APIClient = class {
668
674
  headers,
669
675
  params: options?.params,
670
676
  body: options?.body,
671
- formData: options?.formData
677
+ formData: options?.formData,
678
+ binaryBody: options?.binaryBody
672
679
  });
673
680
  const duration = Date.now() - startTime;
674
681
  if (response.status >= 400) {
@@ -915,11 +922,14 @@ var OAuthProvidersResponseSchema = import_zod9.z.object({
915
922
  // src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
916
923
  var import_zod10 = require("zod");
917
924
  var OAuthTokenResponseSchema = import_zod10.z.object({
918
- access: import_zod10.z.string(),
919
- refresh: import_zod10.z.string(),
920
- user: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.any()),
925
+ requires_2fa: import_zod10.z.boolean().optional(),
926
+ session_id: import_zod10.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
927
+ access: import_zod10.z.string().nullable().optional(),
928
+ refresh: import_zod10.z.string().nullable().optional(),
929
+ user: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.any()).nullable().optional(),
921
930
  is_new_user: import_zod10.z.boolean(),
922
- is_new_connection: import_zod10.z.boolean()
931
+ is_new_connection: import_zod10.z.boolean(),
932
+ should_prompt_2fa: import_zod10.z.boolean().optional()
923
933
  });
924
934
 
925
935
  // src/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
@@ -978,9 +988,12 @@ var UserSchema = import_zod15.z.object({
978
988
 
979
989
  // src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
980
990
  var OTPVerifyResponseSchema = import_zod16.z.object({
981
- refresh: import_zod16.z.string(),
982
- access: import_zod16.z.string(),
983
- user: UserSchema
991
+ requires_2fa: import_zod16.z.boolean().optional(),
992
+ session_id: import_zod16.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
993
+ refresh: import_zod16.z.string().nullable().optional(),
994
+ access: import_zod16.z.string().nullable().optional(),
995
+ user: UserSchema.nullable().optional(),
996
+ should_prompt_2fa: import_zod16.z.boolean().optional()
984
997
  });
985
998
 
986
999
  // src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts