@djangocfg/api 2.1.264 → 2.1.266

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.
package/dist/auth.d.cts CHANGED
@@ -723,24 +723,6 @@ interface UseTwoFactorStatusReturn {
723
723
  /** Clear error */
724
724
  clearError: () => void;
725
725
  }
726
- /**
727
- * Hook for checking and managing 2FA status.
728
- *
729
- * @example
730
- * ```tsx
731
- * const { has2FAEnabled, devices, fetchStatus, disable2FA, isLoading } = useTwoFactorStatus();
732
- *
733
- * useEffect(() => {
734
- * fetchStatus();
735
- * }, [fetchStatus]);
736
- *
737
- * if (has2FAEnabled) {
738
- * // Show disable button
739
- * } else {
740
- * // Show enable button
741
- * }
742
- * ```
743
- */
744
726
  declare const useTwoFactorStatus: () => UseTwoFactorStatusReturn;
745
727
 
746
728
  interface AuthRedirectOptions {
package/dist/auth.d.ts CHANGED
@@ -723,24 +723,6 @@ interface UseTwoFactorStatusReturn {
723
723
  /** Clear error */
724
724
  clearError: () => void;
725
725
  }
726
- /**
727
- * Hook for checking and managing 2FA status.
728
- *
729
- * @example
730
- * ```tsx
731
- * const { has2FAEnabled, devices, fetchStatus, disable2FA, isLoading } = useTwoFactorStatus();
732
- *
733
- * useEffect(() => {
734
- * fetchStatus();
735
- * }, [fetchStatus]);
736
- *
737
- * if (has2FAEnabled) {
738
- * // Show disable button
739
- * } else {
740
- * // Show enable button
741
- * }
742
- * ```
743
- */
744
726
  declare const useTwoFactorStatus: () => UseTwoFactorStatusReturn;
745
727
 
746
728
  interface AuthRedirectOptions {
package/dist/auth.mjs CHANGED
@@ -4411,6 +4411,17 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
4411
4411
 
4412
4412
  // src/auth/hooks/useTwoFactorStatus.ts
4413
4413
  import { useCallback as useCallback8, useState as useState6 } from "react";
4414
+ function extractErrorMessage(err, fallback) {
4415
+ if (err instanceof APIError3) {
4416
+ const body = err.response;
4417
+ if (typeof body?.error === "string") return body.error;
4418
+ if (typeof body?.detail === "string") return body.detail;
4419
+ return err.message;
4420
+ }
4421
+ if (err instanceof Error) return err.message;
4422
+ return fallback;
4423
+ }
4424
+ __name(extractErrorMessage, "extractErrorMessage");
4414
4425
  var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
4415
4426
  const [isLoading, setIsLoading] = useState6(false);
4416
4427
  const [error, setError] = useState6(null);
@@ -4436,7 +4447,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
4436
4447
  setHas2FAEnabled(response.has_2fa_enabled);
4437
4448
  authLogger.info("2FA status:", response.has_2fa_enabled ? "enabled" : "disabled");
4438
4449
  } catch (err) {
4439
- const errorMessage = err instanceof Error ? err.message : "Failed to fetch 2FA status";
4450
+ const errorMessage = extractErrorMessage(err, "Failed to fetch 2FA status");
4440
4451
  authLogger.error("Failed to fetch 2FA status:", err);
4441
4452
  setError(errorMessage);
4442
4453
  } finally {
@@ -4458,7 +4469,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
4458
4469
  authLogger.info("2FA disabled successfully");
4459
4470
  return true;
4460
4471
  } catch (err) {
4461
- const errorMessage = err instanceof Error ? err.message : "Invalid verification code";
4472
+ const errorMessage = extractErrorMessage(err, "Invalid verification code");
4462
4473
  authLogger.error("Failed to disable 2FA:", err);
4463
4474
  setError(errorMessage);
4464
4475
  return false;