UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

52 lines (51 loc) 1.96 kB
import { jsx as n } from "react/jsx-runtime"; import { useGetTwoFactorEnrollmentStatus as i } from "../../../synapse-queries/auth/useTwoFactorEnrollment.js"; import { useSynapseContext as u } from "../../../utils/context/SynapseContext.js"; import { getEndpoint as s, BackendDestinationEnum as c } from "../../../utils/functions/getEndpoint.js"; import { Typography as m } from "@mui/material"; import { TWO_FACTOR_DOCS_LINK as d } from "../../Authentication/TwoFactorEnrollmentForm.js"; import { RequirementItemStatus as r } from "../AccessApprovalCheckMark.js"; import f from "./RequirementItem.js"; const l = `${s( c.PORTAL_ENDPOINT )}TwoFactorAuth:Enroll`; function p(t, e, o) { return t ? e ? r.LOADING : o === "ENABLED" ? r.COMPLETE : r.LOCKED : r.LOCKED; } function _() { const { isAuthenticated: t } = u(), { data: e, isLoading: o } = i({ enabled: t, // If required, we send the user to a new tab to complete 2FA enrollment // Refetch on window focus so the enrollment state is immediately updated when they return to this tab refetchOnWindowFocus: !0, // Refetch won't happen unless staleTime is less than the amount of time since last fetch. 5sec seems reasonable staleTime: 5e3 }), a = e?.status === "DISABLED" ? [ { variant: "outlined", href: l, target: "_blank", rel: "noopener noreferrer", children: "Activate 2FA (opens a new tab)" }, { variant: "text", href: d, target: "_blank", rel: "noopener noreferrer", children: "2FA Documentation" } ] : void 0; return /* @__PURE__ */ n( f, { status: p(t, o, e?.status), actions: a, children: /* @__PURE__ */ n(m, { variant: "body1", children: "You must have Two-factor Authentication (2FA) active on your Synapse account in order to download the requested files" }) } ); } export { _ as default }; //# sourceMappingURL=TwoFactorAuthEnabledRequirement.js.map