@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/README.md CHANGED
@@ -98,7 +98,7 @@ Complete authentication system with OTP, OAuth, and Two-Factor Authentication (2
98
98
  ### Authentication Flow
99
99
 
100
100
  ```
101
- 1. User enters email/phone → OTP sent
101
+ 1. User enters email → OTP sent
102
102
  2. User enters OTP code → Verify
103
103
  ├── If 2FA enabled → Show TOTP verification
104
104
  │ └── User enters 6-digit TOTP → Verify
@@ -164,9 +164,9 @@ export function UserProfile() {
164
164
  user, // UserProfile | null
165
165
  isAuthenticated, // boolean
166
166
  isLoading, // boolean
167
- requestOTP, // (identifier, channel, sourceUrl?) => Promise<{ success, message }>
168
- verifyOTP, // (identifier, otp, channel, sourceUrl?, redirectUrl?) => Promise<{ success, message, user? }>
169
- logout, // () => Promise<void>
167
+ requestOTP, // (identifier, sourceUrl?) => Promise<{ success, message }>
168
+ verifyOTP, // (identifier, otp, sourceUrl?, redirectUrl?) => Promise<{ success, message, user? }>
169
+ logout, // () => void
170
170
  } = useAuth();
171
171
 
172
172
  if (isLoading) return <div>Loading...</div>;
@@ -215,17 +215,17 @@ import { useAuthForm } from '@djangocfg/api/auth';
215
215
  export function OTPLoginForm() {
216
216
  const {
217
217
  // State
218
- identifier, // Email or phone number
219
- channel, // 'email' | 'phone'
218
+ identifier, // Email address
220
219
  otp, // 6-digit OTP code
221
220
  step, // 'identifier' | 'otp' | '2fa' | '2fa-setup' | 'success'
222
221
  isLoading,
223
222
  error,
224
223
  acceptedTerms,
224
+ isRateLimited, // boolean - true when rate limited
225
+ rateLimitLabel, // string - formatted countdown e.g. "1:30" or "45s"
225
226
 
226
227
  // Setters
227
228
  setIdentifier,
228
- setChannel,
229
229
  setOtp,
230
230
  setAcceptedTerms,
231
231
 
@@ -236,12 +236,11 @@ export function OTPLoginForm() {
236
236
  handleBackToIdentifier, // Go back to step 1
237
237
 
238
238
  // Utilities
239
- detectChannelFromIdentifier,
240
239
  validateIdentifier,
241
240
  } = useAuthForm({
242
241
  sourceUrl: window.location.origin,
243
242
  requireTermsAcceptance: false, // Set true if terms/privacy links provided
244
- onIdentifierSuccess: (identifier, channel) => {
243
+ onIdentifierSuccess: (identifier) => {
245
244
  console.log('OTP sent to', identifier);
246
245
  },
247
246
  onOTPSuccess: () => {
@@ -225,7 +225,7 @@ var Accounts = class {
225
225
  this.client = client;
226
226
  }
227
227
  /**
228
- * Request OTP code to email or phone.
228
+ * Request OTP code to email.
229
229
  */
230
230
  async otpRequestCreate(data) {
231
231
  const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
@@ -870,11 +870,6 @@ var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
870
870
  OAuthConnectionProvider2["GITHUB"] = "github";
871
871
  return OAuthConnectionProvider2;
872
872
  })(OAuthConnectionProvider || {});
873
- var OTPRequestRequestChannel = /* @__PURE__ */ ((OTPRequestRequestChannel2) => {
874
- OTPRequestRequestChannel2["EMAIL"] = "email";
875
- OTPRequestRequestChannel2["PHONE"] = "phone";
876
- return OTPRequestRequestChannel2;
877
- })(OTPRequestRequestChannel || {});
878
873
 
879
874
  // src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts
880
875
  var import_zod = require("zod");
@@ -968,14 +963,15 @@ var OAuthTokenResponseSchema = import_zod11.z.object({
968
963
  // src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
969
964
  var import_zod12 = require("zod");
970
965
  var OTPErrorResponseSchema = import_zod12.z.object({
971
- error: import_zod12.z.string()
966
+ error: import_zod12.z.string(),
967
+ error_code: import_zod12.z.string().nullable().optional(),
968
+ retry_after: import_zod12.z.number().int().nullable().optional()
972
969
  });
973
970
 
974
971
  // src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
975
972
  var import_zod13 = require("zod");
976
973
  var OTPRequestRequestSchema = import_zod13.z.object({
977
974
  identifier: import_zod13.z.string().min(1),
978
- channel: import_zod13.z.nativeEnum(OTPRequestRequestChannel).optional(),
979
975
  source_url: import_zod13.z.string().optional()
980
976
  });
981
977
 
@@ -990,7 +986,6 @@ var import_zod15 = require("zod");
990
986
  var OTPVerifyRequestSchema = import_zod15.z.object({
991
987
  identifier: import_zod15.z.string().min(1),
992
988
  otp: import_zod15.z.string().min(6).max(6),
993
- channel: import_zod15.z.nativeEnum(OTPRequestRequestChannel).optional(),
994
989
  source_url: import_zod15.z.string().optional()
995
990
  });
996
991