@authowl/react 0.24.2 → 0.24.4
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/index.cjs +13 -2
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +13 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5239,11 +5239,22 @@ init_FormError();
|
|
|
5239
5239
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
5240
5240
|
function MFAChallenge({ onVerified, allowTrustDevice = true }) {
|
|
5241
5241
|
const t = useT();
|
|
5242
|
+
const { config } = usePublicConfig();
|
|
5242
5243
|
const { verifyTotp, verifyBackupCode, sendOtp, verifyOtp } = useMFA();
|
|
5243
5244
|
const { pending, error, setError, run } = useSubmitAction();
|
|
5244
5245
|
const [mode, setMode] = React12.useState("totp");
|
|
5245
5246
|
const [code, setCode] = React12.useState("");
|
|
5246
5247
|
const [trustDevice, setTrustDevice] = React12.useState(false);
|
|
5248
|
+
const canTrustDevice = allowTrustDevice && (config?.mfa?.trustDevice ?? true);
|
|
5249
|
+
const canUseEmailOtp = config?.mfa?.emailOtpFallback ?? true;
|
|
5250
|
+
React12.useEffect(() => {
|
|
5251
|
+
if (!canTrustDevice) setTrustDevice(false);
|
|
5252
|
+
if (!canUseEmailOtp && mode === "otp") {
|
|
5253
|
+
setMode("totp");
|
|
5254
|
+
setCode("");
|
|
5255
|
+
setError(null);
|
|
5256
|
+
}
|
|
5257
|
+
}, [canTrustDevice, canUseEmailOtp, mode, setError]);
|
|
5247
5258
|
const switchMode = (next) => {
|
|
5248
5259
|
setMode(next);
|
|
5249
5260
|
setCode("");
|
|
@@ -5287,7 +5298,7 @@ function MFAChallenge({ onVerified, allowTrustDevice = true }) {
|
|
|
5287
5298
|
}
|
|
5288
5299
|
)
|
|
5289
5300
|
] }),
|
|
5290
|
-
mode !== "backup" &&
|
|
5301
|
+
mode !== "backup" && canTrustDevice && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "ba-consent ba-consent-centered", children: [
|
|
5291
5302
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "ba-checkbox-control", children: [
|
|
5292
5303
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "ba-checkbox", type: "checkbox", checked: trustDevice, onChange: (e) => setTrustDevice(e.target.checked) }),
|
|
5293
5304
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "ba-checkbox-visual", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "ba-checkbox-check" }) })
|
|
@@ -5298,7 +5309,7 @@ function MFAChallenge({ onVerified, allowTrustDevice = true }) {
|
|
|
5298
5309
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "ba-button", type: "submit", disabled: pending || !code, "aria-busy": pending || void 0, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Busy, { busy: pending, label: t("common.verifying"), children: t("mfa.challenge.submit") }) }),
|
|
5299
5310
|
mode !== "totp" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "ba-link-button", onClick: () => switchMode("totp"), children: t("mfa.challenge.useTotp") }),
|
|
5300
5311
|
mode !== "backup" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "ba-link-button", onClick: () => switchMode("backup"), children: t("mfa.challenge.useBackup") }),
|
|
5301
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "ba-link-button", disabled: pending, onClick: requestOtp, children: t(mode === "otp" ? "mfa.challenge.resendOtp" : "mfa.challenge.useEmailOtp") })
|
|
5312
|
+
canUseEmailOtp && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "ba-link-button", disabled: pending, onClick: requestOtp, children: t(mode === "otp" ? "mfa.challenge.resendOtp" : "mfa.challenge.useEmailOtp") })
|
|
5302
5313
|
] });
|
|
5303
5314
|
}
|
|
5304
5315
|
|
package/dist/index.d.cts
CHANGED
|
@@ -676,7 +676,10 @@ declare function MFAEnrollment({ onEnrolled, title }: MFAEnrollmentProps): React
|
|
|
676
676
|
type MFAChallengeProps = {
|
|
677
677
|
/** Called once the challenge clears and a session is issued. */
|
|
678
678
|
onVerified?: () => void | Promise<void>;
|
|
679
|
-
/**
|
|
679
|
+
/**
|
|
680
|
+
* Allow the "trust this device" option when the project's posture permits it.
|
|
681
|
+
* The server capability always wins over this presentation override.
|
|
682
|
+
*/
|
|
680
683
|
allowTrustDevice?: boolean;
|
|
681
684
|
};
|
|
682
685
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -676,7 +676,10 @@ declare function MFAEnrollment({ onEnrolled, title }: MFAEnrollmentProps): React
|
|
|
676
676
|
type MFAChallengeProps = {
|
|
677
677
|
/** Called once the challenge clears and a session is issued. */
|
|
678
678
|
onVerified?: () => void | Promise<void>;
|
|
679
|
-
/**
|
|
679
|
+
/**
|
|
680
|
+
* Allow the "trust this device" option when the project's posture permits it.
|
|
681
|
+
* The server capability always wins over this presentation override.
|
|
682
|
+
*/
|
|
680
683
|
allowTrustDevice?: boolean;
|
|
681
684
|
};
|
|
682
685
|
/**
|
package/dist/index.js
CHANGED
|
@@ -622,11 +622,22 @@ import * as React5 from "react";
|
|
|
622
622
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
623
623
|
function MFAChallenge({ onVerified, allowTrustDevice = true }) {
|
|
624
624
|
const t = useT();
|
|
625
|
+
const { config } = usePublicConfig();
|
|
625
626
|
const { verifyTotp, verifyBackupCode, sendOtp, verifyOtp } = useMFA();
|
|
626
627
|
const { pending, error, setError, run } = useSubmitAction();
|
|
627
628
|
const [mode, setMode] = React5.useState("totp");
|
|
628
629
|
const [code, setCode] = React5.useState("");
|
|
629
630
|
const [trustDevice, setTrustDevice] = React5.useState(false);
|
|
631
|
+
const canTrustDevice = allowTrustDevice && (config?.mfa?.trustDevice ?? true);
|
|
632
|
+
const canUseEmailOtp = config?.mfa?.emailOtpFallback ?? true;
|
|
633
|
+
React5.useEffect(() => {
|
|
634
|
+
if (!canTrustDevice) setTrustDevice(false);
|
|
635
|
+
if (!canUseEmailOtp && mode === "otp") {
|
|
636
|
+
setMode("totp");
|
|
637
|
+
setCode("");
|
|
638
|
+
setError(null);
|
|
639
|
+
}
|
|
640
|
+
}, [canTrustDevice, canUseEmailOtp, mode, setError]);
|
|
630
641
|
const switchMode = (next) => {
|
|
631
642
|
setMode(next);
|
|
632
643
|
setCode("");
|
|
@@ -670,7 +681,7 @@ function MFAChallenge({ onVerified, allowTrustDevice = true }) {
|
|
|
670
681
|
}
|
|
671
682
|
)
|
|
672
683
|
] }),
|
|
673
|
-
mode !== "backup" &&
|
|
684
|
+
mode !== "backup" && canTrustDevice && /* @__PURE__ */ jsxs7("label", { className: "ba-consent ba-consent-centered", children: [
|
|
674
685
|
/* @__PURE__ */ jsxs7("span", { className: "ba-checkbox-control", children: [
|
|
675
686
|
/* @__PURE__ */ jsx7("input", { className: "ba-checkbox", type: "checkbox", checked: trustDevice, onChange: (e) => setTrustDevice(e.target.checked) }),
|
|
676
687
|
/* @__PURE__ */ jsx7("span", { className: "ba-checkbox-visual", "aria-hidden": "true", children: /* @__PURE__ */ jsx7("span", { className: "ba-checkbox-check" }) })
|
|
@@ -681,7 +692,7 @@ function MFAChallenge({ onVerified, allowTrustDevice = true }) {
|
|
|
681
692
|
/* @__PURE__ */ jsx7("button", { className: "ba-button", type: "submit", disabled: pending || !code, "aria-busy": pending || void 0, children: /* @__PURE__ */ jsx7(Busy, { busy: pending, label: t("common.verifying"), children: t("mfa.challenge.submit") }) }),
|
|
682
693
|
mode !== "totp" && /* @__PURE__ */ jsx7("button", { type: "button", className: "ba-link-button", onClick: () => switchMode("totp"), children: t("mfa.challenge.useTotp") }),
|
|
683
694
|
mode !== "backup" && /* @__PURE__ */ jsx7("button", { type: "button", className: "ba-link-button", onClick: () => switchMode("backup"), children: t("mfa.challenge.useBackup") }),
|
|
684
|
-
/* @__PURE__ */ jsx7("button", { type: "button", className: "ba-link-button", disabled: pending, onClick: requestOtp, children: t(mode === "otp" ? "mfa.challenge.resendOtp" : "mfa.challenge.useEmailOtp") })
|
|
695
|
+
canUseEmailOtp && /* @__PURE__ */ jsx7("button", { type: "button", className: "ba-link-button", disabled: pending, onClick: requestOtp, children: t(mode === "otp" ? "mfa.challenge.resendOtp" : "mfa.challenge.useEmailOtp") })
|
|
685
696
|
] });
|
|
686
697
|
}
|
|
687
698
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authowl/react",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.4",
|
|
4
4
|
"description": "React provider, hooks, and drop-in components for AuthOwl, the multi-tenant auth SaaS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"LICENSE"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@authowl/core": "0.
|
|
50
|
+
"@authowl/core": "0.23.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=18",
|