@stokr/components-library 3.0.77 → 3.1.0-alpha.1

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 (74) hide show
  1. package/dist/components/Input/InputPassword.js +3 -5
  2. package/dist/components/Input/OtpInput.js +1 -3
  3. package/dist/components/MenuNav/MenuNav.styles.js +1 -2
  4. package/dist/components/Modal/Modal.styles.js +2 -3
  5. package/dist/components/Newsletter/Newsletter.js +1 -3
  6. package/dist/components/NotificationCounter/NotificationCounter.styles.js +1 -2
  7. package/dist/components/SmartLink/SmartLink.js +0 -2
  8. package/dist/components/StepController/StepController.js +3 -5
  9. package/dist/components/StepController/StepController.styles.js +102 -1
  10. package/dist/components/StepController/StepControllerProgress.js +1 -1
  11. package/dist/components/Switch/Switch.js +1 -3
  12. package/dist/components/ToDoList/ToDoListTask.js +15 -3
  13. package/dist/components/taxId/register-taxid.js +7 -5
  14. package/dist/index.js +67 -141
  15. package/dist/runtime-config.js +4 -70
  16. package/dist/styles/global.js +1 -2
  17. package/dist/utils/check-todo-status.js +1 -2
  18. package/package.json +8 -14
  19. package/dist/api/authenticationApi.js +0 -13
  20. package/dist/auth/index.js +0 -34
  21. package/dist/components/2FA/Connect2FA.js +0 -58
  22. package/dist/components/2FA/EnterCode.js +0 -74
  23. package/dist/components/2FA/InstallAuthApp.js +0 -68
  24. package/dist/components/2FA/ResetCode.js +0 -34
  25. package/dist/components/2FA/Sucess2FA.js +0 -63
  26. package/dist/components/2FA/disable-2fa-flow.js +0 -104
  27. package/dist/components/2FA/enable-2fa-flow.js +0 -167
  28. package/dist/components/2FA/login-with-otp-flow.js +0 -262
  29. package/dist/components/2FA/main-flow.js +0 -273
  30. package/dist/components/Footer/Footer.js +0 -69
  31. package/dist/components/Footer/Footer.styles.js +0 -277
  32. package/dist/components/Footer/FooterLayout.js +0 -150
  33. package/dist/components/Footer/FooterMenu.js +0 -107
  34. package/dist/components/Footer/FooterMenu.styles.js +0 -334
  35. package/dist/components/ForgotPasswordModal/ForgotPasswordModal.js +0 -121
  36. package/dist/components/Header/Header.js +0 -441
  37. package/dist/components/Header/Header.styles.js +0 -568
  38. package/dist/components/Layout/Layout.js +0 -76
  39. package/dist/components/LoginModal/LoginModal.js +0 -165
  40. package/dist/components/MainMenu/DynamicMainMenu.js +0 -38
  41. package/dist/components/MainMenu/MainMenu.js +0 -220
  42. package/dist/components/MainMenu/MainMenu.styles.js +0 -362
  43. package/dist/components/Modal/NewVentureModal/NewVentureModal.js +0 -273
  44. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.js +0 -74
  45. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.styles.js +0 -20
  46. package/dist/components/RegisterModal/RegisterModal.js +0 -278
  47. package/dist/components/ResetConfirmModal/ResetConfirmModal.js +0 -40
  48. package/dist/components/ResetConfirmModal/ResetConfirmModal.styles.js +0 -41
  49. package/dist/components/ResetPasswordModal/ResetPasswordModal.js +0 -145
  50. package/dist/components/StepsProgress/StepIndicator.js +0 -40
  51. package/dist/components/StepsProgress/StepIndicator.styles.js +0 -69
  52. package/dist/components/StepsProgress/StepsProgress.js +0 -67
  53. package/dist/components/StepsProgress/StepsProgress.styles.js +0 -105
  54. package/dist/components/TermsModal/TermsModal.js +0 -145
  55. package/dist/components/TermsModal/_styles.js +0 -313
  56. package/dist/components/VerifyEmailModal/VerifyEmailModal.js +0 -122
  57. package/dist/components/headerHo/HeaderHo.js +0 -707
  58. package/dist/config.js +0 -33
  59. package/dist/context/Auth.js +0 -423
  60. package/dist/context/AuthContext.js +0 -1016
  61. package/dist/firebase-config.js +0 -56
  62. package/dist/hooks/useNewVentureForm.js +0 -235
  63. package/dist/static/images/background3.png.js +0 -4
  64. package/dist/static/images/google_auth.png.js +0 -4
  65. package/dist/static/images/iso27001-black.svg.js +0 -4
  66. package/dist/static/images/mangopay.svg.js +0 -4
  67. package/dist/static/images/social/Facebook_Logo.png.js +0 -4
  68. package/dist/static/images/social/LI-In-Bug.png.js +0 -4
  69. package/dist/static/images/social/Telegram-Logo.png.js +0 -4
  70. package/dist/static/images/social/X-logo-black.png.js +0 -4
  71. package/dist/static/images/social/youtube_social_circle_red.png.js +0 -4
  72. package/dist/utils/show-account-locked-modal.js +0 -23
  73. package/dist/utils/user-identity.js +0 -10
  74. package/dist/utils/withRouter.js +0 -26
@@ -1,13 +0,0 @@
1
- import axiosInstance from "../model/axios.js";
2
- const authenticationApi = {
3
- /**
4
- * @param {string} pathSegment — appended to `auth/` (e.g. `forgotPass` → `POST auth/forgotPass`)
5
- * @param {Record<string, unknown>} body
6
- */
7
- post(pathSegment, body) {
8
- return axiosInstance.post(`auth/${pathSegment}`, body);
9
- }
10
- };
11
- export {
12
- authenticationApi
13
- };
@@ -1,34 +0,0 @@
1
- import { configure } from "../config.js";
2
- import { Auth, DEFAULT_TOKEN_EXPIRY_MS } from "../context/Auth.js";
3
- import { AuthConsumer, AuthContext, AuthProvider } from "../context/AuthContext.js";
4
- import { LoadingDots, StokrLoader, StokrLoaderBox } from "../components/StokrLoader/StokrLoader.js";
5
- import { default as default2 } from "../components/2FA/Connect2FA.js";
6
- import { default as default3 } from "../components/2FA/enable-2fa-flow.js";
7
- import { default as default4 } from "../components/2FA/EnterCode.js";
8
- import { default as default5 } from "../components/2FA/InstallAuthApp.js";
9
- import { default as default6 } from "../components/2FA/login-with-otp-flow.js";
10
- import { default as default7 } from "../components/2FA/main-flow.js";
11
- import { default as default8 } from "../components/2FA/ResetCode.js";
12
- import { default as default9 } from "../components/2FA/Sucess2FA.js";
13
- import { getConfig, resetRuntimeConfig } from "../runtime-config.js";
14
- export {
15
- Auth,
16
- AuthConsumer,
17
- AuthContext,
18
- AuthProvider,
19
- default2 as Connect2FA,
20
- DEFAULT_TOKEN_EXPIRY_MS,
21
- default3 as Enable2FAFlow,
22
- default4 as EnterCode,
23
- default5 as InstallAuthApp,
24
- LoadingDots,
25
- default6 as LoginWithOTPFlow,
26
- default7 as Main2FAFlow,
27
- default8 as ResetCode,
28
- StokrLoader,
29
- StokrLoaderBox,
30
- default9 as Sucess2FA,
31
- configure,
32
- getConfig,
33
- resetRuntimeConfig
34
- };
@@ -1,58 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import "react";
3
- import { sizes } from "../../styles/rwd.js";
4
- import { Text } from "../Text/Text.styles.js";
5
- import stdin_default$2 from "../Button/Button.styles.js";
6
- import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
7
- import { ModalWrapper, ModalInner } from "../Modal/Modal.styles.js";
8
- import { QRCodeSVG } from "qrcode.react";
9
- import { Row, Column } from "../Grid/Grid.styles.js";
10
- import stdin_default$1 from "../CryptoAddress/CryptoAddress.js";
11
- import { useMobileView } from "../../utils/customHooks.js";
12
- const Connect2FA = (props) => {
13
- const { changeStep, totpData } = props;
14
- const isMobile = useMobileView(sizes.Mobile);
15
- return /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsxs(Row, { children: [
16
- /* @__PURE__ */ jsxs(Column, { part: 8, children: [
17
- /* @__PURE__ */ jsx(ModalInner, { modalTop: true, children: /* @__PURE__ */ jsxs(Text, { children: [
18
- /* @__PURE__ */ jsx("h3", { children: "Activate log in 2FA" }),
19
- /* @__PURE__ */ jsx("p", { children: "1. Open your authenticator app" }),
20
- /* @__PURE__ */ jsx("p", { children: isMobile ? "2. Copy the set up key" : "2. Scan the QR code or copy the set up key" })
21
- ] }) }),
22
- /* @__PURE__ */ jsx(ModalInner, { modalBot: true })
23
- ] }),
24
- /* @__PURE__ */ jsx(Column, { part: 8, children: /* @__PURE__ */ jsxs(ModalInner, { children: [
25
- totpData && /* @__PURE__ */ jsxs(ComponentWrapper, { center: true, noPaddingHorizontal: true, children: [
26
- !isMobile && /* @__PURE__ */ jsx(QRCodeSVG, { size: 180, value: totpData?.totpUri }),
27
- /* @__PURE__ */ jsx(
28
- stdin_default$1,
29
- {
30
- data: {
31
- value: totpData.totpSecret?.secretKey,
32
- tooltip: true
33
- },
34
- fontSize: 11,
35
- wrapperStyle: { paddingRight: 0 },
36
- dataBoxStyle: { width: "100%", whiteSpace: "nowrap" }
37
- }
38
- )
39
- ] }),
40
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingTop: true, noPaddingBottom: true, center: true, noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(
41
- stdin_default$2,
42
- {
43
- minWidth: "150px",
44
- id: "enable-2fa-connect-continue-btn",
45
- "data-cy": "enable-2fa-connect-continue",
46
- onClick: changeStep,
47
- fluid: true,
48
- children: "Continue"
49
- }
50
- ) })
51
- ] }) })
52
- ] }) });
53
- };
54
- var stdin_default = Connect2FA;
55
- export {
56
- Connect2FA,
57
- stdin_default as default
58
- };
@@ -1,74 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import "react";
3
- import { Formik } from "formik";
4
- import { Modal } from "../Modal/Modal.js";
5
- import stdin_default$1 from "../Form/Form.js";
6
- import { Text } from "../Text/Text.styles.js";
7
- import stdin_default$3 from "../Button/Button.styles.js";
8
- import { Row, Column } from "../Grid/Grid.styles.js";
9
- import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
10
- import stdin_default$2 from "../Input/OtpInput.js";
11
- import { ModalInner, ModalLinkWrap, ModalLink } from "../Modal/Modal.styles.js";
12
- import { FormField, FormError } from "../Form/Form.styles.js";
13
- const Wrapper = ({ isModal, children, isModalOpen, onModalClose, background }) => isModal ? /* @__PURE__ */ jsx(Modal, { isOpen: isModalOpen, onClose: onModalClose, background, children }) : /* @__PURE__ */ jsx(Fragment, { children });
14
- const EnterCode = (props) => {
15
- const { popupError = {}, onFormSend, onModalSwitch, isModal, isActionLoading } = props;
16
- return /* @__PURE__ */ jsx(Wrapper, { isModal, ...props, children: /* @__PURE__ */ jsxs(Row, { children: [
17
- /* @__PURE__ */ jsxs(Column, { part: 8, children: [
18
- /* @__PURE__ */ jsx(ModalInner, { modalTop: true, children: /* @__PURE__ */ jsxs(Text, { children: [
19
- /* @__PURE__ */ jsx("h3", { children: "TWO-FACTOR AUTHENTICATION" }),
20
- /* @__PURE__ */ jsx("p", { children: "Enter the verification code from your authenticator application." })
21
- ] }) }),
22
- /* @__PURE__ */ jsx(ModalInner, { modalBot: true, children: onModalSwitch && /* @__PURE__ */ jsx(ModalLinkWrap, { children: /* @__PURE__ */ jsx(ModalLink, { type: "button", as: "button", "data-cy": "2fa-enter-code-lost-device", onClick: onModalSwitch, children: "Lost access to your device?" }) }) })
23
- ] }),
24
- /* @__PURE__ */ jsx(Column, { part: 8, children: /* @__PURE__ */ jsx(ModalInner, { children: /* @__PURE__ */ jsx(
25
- Formik,
26
- {
27
- initialValues: { otpInput: "" },
28
- onSubmit: (values) => {
29
- onFormSend(values);
30
- },
31
- children: ({ values, errors, touched, setFieldValue, setFieldTouched }) => {
32
- const submitDisabled = !touched.otpInput || !values.otpInput || isActionLoading === "enter2fa";
33
- return /* @__PURE__ */ jsxs(stdin_default$1, { children: [
34
- /* @__PURE__ */ jsx(ComponentWrapper, { noPadding: true, children: /* @__PURE__ */ jsxs(FormField, { children: [
35
- /* @__PURE__ */ jsx(
36
- stdin_default$2,
37
- {
38
- id: "otp-input",
39
- name: "otpInput",
40
- numInputs: 6,
41
- dataCyPrefix: "2fa-enter-code-otp",
42
- value: values.otpInput,
43
- onChange: (e) => {
44
- setFieldValue("otpInput", e);
45
- setFieldTouched("otpInput");
46
- },
47
- label: "2FA code"
48
- }
49
- ),
50
- /* @__PURE__ */ jsx(FormError, { show: errors.otpInput && touched.otpInput, children: errors.otpInput })
51
- ] }) }),
52
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingBottom: true, noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(
53
- stdin_default$3,
54
- {
55
- type: "submit",
56
- id: "2fa-enter-code-btn",
57
- "data-cy": "2fa-enter-code-submit",
58
- fluid: true,
59
- disabled: submitDisabled,
60
- children: "Continue"
61
- }
62
- ) }),
63
- /* @__PURE__ */ jsx(ComponentWrapper, { paddingVeticalHalf: true, noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(FormError, { show: popupError?.popup === "enter2fa", children: popupError.message }) })
64
- ] });
65
- }
66
- }
67
- ) }) })
68
- ] }) });
69
- };
70
- var stdin_default = EnterCode;
71
- export {
72
- EnterCode,
73
- stdin_default as default
74
- };
@@ -1,68 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import "react";
3
- import { Text } from "../Text/Text.styles.js";
4
- import stdin_default$1 from "../Button/Button.styles.js";
5
- import { Row, Column } from "../Grid/Grid.styles.js";
6
- import { ModalWrapper, ModalInner } from "../Modal/Modal.styles.js";
7
- import GoogleAuthLogo from "../../static/images/google_auth.png.js";
8
- import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
9
- const InstallAuthApp = (props) => {
10
- const { changeStep } = props;
11
- return /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsxs(Row, { children: [
12
- /* @__PURE__ */ jsxs(Column, { part: 8, children: [
13
- /* @__PURE__ */ jsx(ModalInner, { modalTop: true, children: /* @__PURE__ */ jsxs(Text, { children: [
14
- /* @__PURE__ */ jsx("h3", { children: "Install 2FA APP" }),
15
- /* @__PURE__ */ jsx("p", { children: "Download and install a 2FA app on your device. We recommend using Google Authenticator" })
16
- ] }) }),
17
- /* @__PURE__ */ jsx(ModalInner, { modalBot: true })
18
- ] }),
19
- /* @__PURE__ */ jsx(Column, { part: 8, children: /* @__PURE__ */ jsxs(ModalInner, { children: [
20
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingTop: true, noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(Text, { small: true, children: /* @__PURE__ */ jsx("p", { children: "Click 'Continue' if you already have an app installed." }) }) }),
21
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingHorizontal: true, center: true, children: /* @__PURE__ */ jsxs(
22
- stdin_default$1,
23
- {
24
- minWidth: "150px",
25
- id: "enable-2fa-download-app-btn",
26
- "data-cy": "enable-2fa-download-auth-app",
27
- fluid: true,
28
- onClick: () => {
29
- window.open("https://onelink.to/ev63j9", "_blank");
30
- },
31
- secondary: true,
32
- children: [
33
- "DOWNLOAD THE APP",
34
- " ",
35
- /* @__PURE__ */ jsx(
36
- "img",
37
- {
38
- src: GoogleAuthLogo,
39
- width: 20,
40
- style: {
41
- verticalAlign: "middle",
42
- marginLeft: "6px",
43
- marginTop: "-3px"
44
- },
45
- alt: "google auth logo"
46
- }
47
- )
48
- ]
49
- }
50
- ) }),
51
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingHorizontal: true, noPaddingTop: true, center: true, children: /* @__PURE__ */ jsx(
52
- stdin_default$1,
53
- {
54
- minWidth: "150px",
55
- id: "enable-2fa-install-app-continue-btn",
56
- "data-cy": "enable-2fa-install-app-continue",
57
- onClick: changeStep,
58
- fluid: true,
59
- children: "Continue"
60
- }
61
- ) })
62
- ] }) })
63
- ] }) });
64
- };
65
- var stdin_default = InstallAuthApp;
66
- export {
67
- stdin_default as default
68
- };
@@ -1,34 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import "react";
3
- import { Text } from "../Text/Text.styles.js";
4
- import { Row, Column } from "../Grid/Grid.styles.js";
5
- import { Modal } from "../Modal/Modal.js";
6
- import { ModalInner, ModalLinkWrap, ModalLink } from "../Modal/Modal.styles.js";
7
- const ResetCode = (props) => {
8
- const { onModalSwitch, onModalClose, background, isModalOpen } = props;
9
- return /* @__PURE__ */ jsx(Modal, { isOpen: isModalOpen, onClose: onModalClose, background, children: /* @__PURE__ */ jsxs(Row, { children: [
10
- /* @__PURE__ */ jsxs(Column, { part: 8, children: [
11
- /* @__PURE__ */ jsx(ModalInner, { modalTop: true, children: /* @__PURE__ */ jsxs(Text, { children: [
12
- /* @__PURE__ */ jsx("h3", { children: "AUTHENTICATION DEVICE UNAVAILABLE" }),
13
- /* @__PURE__ */ jsx("p", { children: "Please contact our support team to reset your two-factor authentication." })
14
- ] }) }),
15
- /* @__PURE__ */ jsx(ModalInner, { modalBot: true, children: /* @__PURE__ */ jsx(ModalLinkWrap, { children: /* @__PURE__ */ jsx(ModalLink, { type: "button", as: "button", "data-cy": "2fa-reset-code-back-to-enter-code", onClick: onModalSwitch, children: "Return to log in" }) }) })
16
- ] }),
17
- /* @__PURE__ */ jsx(Column, { part: 8, children: /* @__PURE__ */ jsx(ModalInner, { children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(
18
- "a",
19
- {
20
- href: "https://stokr.zendesk.com/hc/en-us/requests/new",
21
- target: "_blank",
22
- rel: "noreferrer",
23
- "data-cy": "2fa-reset-code-contact-support",
24
- style: { textDecoration: "underline" },
25
- children: "Contact us to reset your two-factor authentication."
26
- }
27
- ) }) }) }) })
28
- ] }) });
29
- };
30
- var stdin_default = ResetCode;
31
- export {
32
- ResetCode,
33
- stdin_default as default
34
- };
@@ -1,63 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import "react";
3
- import PropTypes from "prop-types";
4
- import { Text } from "../Text/Text.styles.js";
5
- import stdin_default$1 from "../Button/Button.styles.js";
6
- import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
7
- import { Row, Column } from "../Grid/Grid.styles.js";
8
- import { ModalWrapper, ModalInner } from "../Modal/Modal.styles.js";
9
- const Sucess2FA = ({
10
- onClick = () => {
11
- },
12
- titleText = "Success!",
13
- subTitleLeft = "",
14
- textRight = "",
15
- buttonText = "Continue",
16
- /** DOM id for the primary action button — override per screen (verify email, enable/disable 2FA, etc.) */
17
- continueButtonId = "success-flow-continue-btn",
18
- /** Playwright / analytics-friendly selector for the primary button */
19
- continueButtonDataCy = "success-flow-continue"
20
- }) => {
21
- return /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsxs(Row, { children: [
22
- /* @__PURE__ */ jsxs(Column, { part: 8, children: [
23
- /* @__PURE__ */ jsx(ModalInner, { modalTop: true, children: /* @__PURE__ */ jsxs(Text, { children: [
24
- /* @__PURE__ */ jsxs("h3", { children: [
25
- titleText,
26
- " "
27
- ] }),
28
- /* @__PURE__ */ jsx("p", { children: subTitleLeft })
29
- ] }) }),
30
- /* @__PURE__ */ jsx(ModalInner, { modalBot: true })
31
- ] }),
32
- /* @__PURE__ */ jsx(Column, { part: 8, children: /* @__PURE__ */ jsxs(ModalInner, { children: [
33
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingVertical: true, noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx("p", { children: textRight }) }) }),
34
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(
35
- stdin_default$1,
36
- {
37
- id: continueButtonId,
38
- minWidth: "240px",
39
- "data-cy": continueButtonDataCy,
40
- onClick: () => {
41
- onClick();
42
- },
43
- fluid: true,
44
- children: buttonText
45
- }
46
- ) })
47
- ] }) })
48
- ] }) });
49
- };
50
- Sucess2FA.propTypes = {
51
- onClick: PropTypes.func.isRequired,
52
- titleText: PropTypes.string,
53
- subTitleLeft: PropTypes.string,
54
- textRight: PropTypes.string,
55
- buttonText: PropTypes.string,
56
- continueButtonId: PropTypes.string,
57
- continueButtonDataCy: PropTypes.string
58
- };
59
- var stdin_default = Sucess2FA;
60
- export {
61
- Sucess2FA,
62
- stdin_default as default
63
- };
@@ -1,104 +0,0 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { useContext, useState, useEffect } from "react";
3
- import { AuthContext } from "../../context/AuthContext.js";
4
- import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
5
- import { Modal } from "../Modal/Modal.js";
6
- import { ModalInner, ModalWrapper } from "../Modal/Modal.styles.js";
7
- import { Text } from "../Text/Text.styles.js";
8
- import stdin_default$2 from "../Button/Button.styles.js";
9
- import { Row, Column } from "../Grid/Grid.styles.js";
10
- import stdin_default$1 from "./Sucess2FA.js";
11
- import fetchData from "../../api/fetchData.js";
12
- const Disable2FA = ({ showFlow, setShowFlow, onSuccess, onRequiresRecentLoginError }) => {
13
- const { unenrollUser2FA, refreshIdToken } = useContext(AuthContext);
14
- const [isModalOpen, setIsModalOpen] = useState({
15
- confirmDisable: false,
16
- sucess: false
17
- });
18
- const refreshToken = async () => {
19
- try {
20
- refreshIdToken();
21
- } catch (error) {
22
- console.log("🚀 ~ error in refreshToken:", error);
23
- }
24
- };
25
- useEffect(() => {
26
- if (showFlow) {
27
- refreshToken();
28
- setIsModalOpen({
29
- ...isModalOpen,
30
- confirmDisable: true
31
- });
32
- }
33
- }, [showFlow]);
34
- const handleDisableClick = async () => {
35
- try {
36
- await unenrollUser2FA();
37
- setIsModalOpen({
38
- ...isModalOpen,
39
- sucess: true
40
- });
41
- try {
42
- await fetchData("auth/disable-2fa-email");
43
- } catch (error) {
44
- console.log("🚀 ~ error while sending email:", error);
45
- }
46
- } catch (error) {
47
- console.log("🚀 ~ file: disable-2fa-flow.js ~ error:", error);
48
- if (error.code === "auth/requires-recent-login") {
49
- onRequiresRecentLoginError?.();
50
- }
51
- }
52
- };
53
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
54
- Modal,
55
- {
56
- isOpen: isModalOpen.confirmDisable,
57
- onClose: () => {
58
- setShowFlow(false);
59
- },
60
- children: /* @__PURE__ */ jsx(ModalInner, { noPadding: true, children: isModalOpen.sucess ? /* @__PURE__ */ jsx(
61
- stdin_default$1,
62
- {
63
- continueButtonId: "disable-2fa-success-continue-btn",
64
- continueButtonDataCy: "disable-2fa-success-continue",
65
- onClick: () => {
66
- setShowFlow(false);
67
- onSuccess?.();
68
- },
69
- subTitleLeft: "Your log in 2FA authentication is removed",
70
- textRight: "You will not be asked for your 2FA code next time you log in."
71
- }
72
- ) : /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsxs(Row, { children: [
73
- /* @__PURE__ */ jsxs(Column, { part: 8, children: [
74
- /* @__PURE__ */ jsx(ModalInner, { modalTop: true, children: /* @__PURE__ */ jsxs(Text, { children: [
75
- /* @__PURE__ */ jsx("h3", { children: "Remove your log in 2FA authentication? " }),
76
- /* @__PURE__ */ jsx("p", { children: "We recommend you to keep 2FA authentication and protect your account with an additional layer of security" })
77
- ] }) }),
78
- /* @__PURE__ */ jsx(ModalInner, { modalBot: true })
79
- ] }),
80
- /* @__PURE__ */ jsx(Column, { part: 8, children: /* @__PURE__ */ jsxs(ModalInner, { children: [
81
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingVertical: true, noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx("p", { children: "Do you want to remove your log in 2FA authentication?" }) }) }),
82
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingHorizontal: true, children: /* @__PURE__ */ jsx(
83
- stdin_default$2,
84
- {
85
- secondary: true,
86
- style: { marginRight: 20 },
87
- id: "disable-2fa-confirm-no-btn",
88
- "data-cy": "disable-2fa-confirm-no",
89
- onClick: () => setShowFlow(false),
90
- fluid: true,
91
- children: "NO"
92
- }
93
- ) }),
94
- /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingHorizontal: true, noPaddingTop: true, children: /* @__PURE__ */ jsx(stdin_default$2, { id: "disable-2fa-confirm-yes-btn", "data-cy": "disable-2fa-confirm-yes", onClick: handleDisableClick, fluid: true, children: "Yes" }) })
95
- ] }) })
96
- ] }) }) })
97
- }
98
- ) });
99
- };
100
- var stdin_default = Disable2FA;
101
- export {
102
- Disable2FA,
103
- stdin_default as default
104
- };
@@ -1,167 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useContext, useState, useRef, useLayoutEffect, useEffect } from "react";
3
- import { Modal } from "../Modal/Modal.js";
4
- import stdin_default$2 from "../StepController/StepController.js";
5
- import { StepControllerProvider, StepControllerConsumer } from "../StepController/StepControllerContext.js";
6
- import stdin_default$3 from "./InstallAuthApp.js";
7
- import stdin_default$4 from "./Connect2FA.js";
8
- import stdin_default$5 from "./EnterCode.js";
9
- import { AuthContext } from "../../context/AuthContext.js";
10
- import stdin_default$1 from "./Sucess2FA.js";
11
- import fetchData from "../../api/fetchData.js";
12
- import { getFirebaseAuth } from "../../firebase-config.js";
13
- import { ModalInner, ModalBack } from "../Modal/Modal.styles.js";
14
- const stepsNames = ["app", "connect", "enter-code"];
15
- const Enable2FAFlow = ({ showFlow, setShowFlow, onSuccess, totpData, onRequiresRecentLoginError }) => {
16
- const { user, firebaseUser, enrollUserToTotp, refreshIdToken } = useContext(AuthContext);
17
- const [showSuccess, setshowSuccess] = useState(false);
18
- const [flowKey, setFlowKey] = useState(0);
19
- const prevShowFlowRef = useRef(showFlow);
20
- const isFirstMountRef = useRef(true);
21
- const [popupError, setpopupError] = useState({
22
- popup: void 0,
23
- message: void 0
24
- });
25
- useLayoutEffect(() => {
26
- if (isFirstMountRef.current) {
27
- isFirstMountRef.current = false;
28
- prevShowFlowRef.current = showFlow;
29
- return;
30
- }
31
- if (showFlow && !prevShowFlowRef.current) {
32
- setFlowKey((key) => key + 1);
33
- setshowSuccess(false);
34
- setpopupError({ popup: void 0, message: void 0 });
35
- }
36
- prevShowFlowRef.current = showFlow;
37
- }, [showFlow]);
38
- const refreshToken = async () => {
39
- try {
40
- refreshIdToken();
41
- } catch (error) {
42
- console.log("🚀 ~ error in refreshToken:", error);
43
- }
44
- };
45
- useEffect(() => {
46
- if (user) {
47
- refreshToken();
48
- }
49
- }, [user]);
50
- const onSubmit = async (data) => {
51
- if (!data) return console.log("not enough data");
52
- const mfaUser = firebaseUser || getFirebaseAuth()?.currentUser || user;
53
- if (!mfaUser) {
54
- setpopupError({
55
- popup: "enter2fa",
56
- message: "Unable to complete 2FA setup. Please log in again and retry."
57
- });
58
- return;
59
- }
60
- try {
61
- await enrollUserToTotp(mfaUser, totpData.totpSecret, data.otpInput, user?.displayName || mfaUser?.displayName);
62
- setshowSuccess(true);
63
- try {
64
- await fetchData("auth/enable-2fa-email");
65
- } catch (error) {
66
- console.log("🚀 ~ error while sending email:", error);
67
- }
68
- } catch (error) {
69
- console.log("🚀 ~ file: enable-2fa-flow.js:60 ~ error:", error);
70
- if (error.code === "auth/invalid-verification-code") {
71
- setpopupError({
72
- popup: "enter2fa",
73
- message: "That’s not the right 2FA code. Try again"
74
- });
75
- return { otpInput: "Invalid code" };
76
- } else if (error.code === "auth/requires-recent-login") {
77
- onRequiresRecentLoginError?.();
78
- } else {
79
- setpopupError({
80
- popup: "enter2fa",
81
- message: `${error?.message ? error?.message : "Something went wrong. Try again?"}`
82
- });
83
- }
84
- }
85
- };
86
- const onBackButtonClick = (stepController, prevStepIndex) => {
87
- stepController.changeStep(stepsNames[prevStepIndex], prevStepIndex);
88
- };
89
- return /* @__PURE__ */ jsx(Modal, { isOpen: showFlow, onClose: () => setShowFlow(false), children: /* @__PURE__ */ jsx(ModalInner, { noPadding: true, children: showSuccess ? /* @__PURE__ */ jsx(
90
- stdin_default$1,
91
- {
92
- continueButtonId: "enable-2fa-success-continue-btn",
93
- continueButtonDataCy: "enable-2fa-success-continue",
94
- onClick: () => {
95
- if (onSuccess) onSuccess();
96
- setshowSuccess(false);
97
- setShowFlow(false);
98
- },
99
- subTitleLeft: "Your log in 2FA authentication is now set",
100
- textRight: "You will now be asked for your 2FA code next time you log in."
101
- }
102
- ) : /* @__PURE__ */ jsx(StepControllerProvider, { initialStep: stepsNames[0], children: /* @__PURE__ */ jsx(StepControllerConsumer, { children: (stepController) => {
103
- const prevStepIndex = stepController.activeStepIndex - 1;
104
- return /* @__PURE__ */ jsxs(Fragment, { children: [
105
- /* @__PURE__ */ jsx(
106
- ModalBack,
107
- {
108
- onClick: () => onBackButtonClick(stepController, prevStepIndex),
109
- hide: stepController.activeStepIndex === 0
110
- }
111
- ),
112
- /* @__PURE__ */ jsxs(
113
- stdin_default$2,
114
- {
115
- stepsProgressList: [
116
- {
117
- id: "app",
118
- dataCy: "enable-2fa-progress-app",
119
- handleClick: () => {
120
- stepController.changeStep("app", 0);
121
- }
122
- },
123
- {
124
- id: "connect",
125
- dataCy: "enable-2fa-progress-connect",
126
- handleClick: () => {
127
- stepController.changeStep("connect", 1);
128
- }
129
- },
130
- {
131
- id: "enter-code",
132
- dataCy: "enable-2fa-progress-enter-code",
133
- handleClick: () => stepController.changeStep("enter-code", 2)
134
- }
135
- ],
136
- ...stepController,
137
- children: [
138
- /* @__PURE__ */ jsx(stdin_default$3, { id: "app", changeStep: () => stepController.changeStep("connect", 1, 0) }),
139
- /* @__PURE__ */ jsx(
140
- stdin_default$4,
141
- {
142
- id: "connect",
143
- changeStep: () => stepController.changeStep("enter-code", 2, 1),
144
- totpData,
145
- user
146
- }
147
- ),
148
- /* @__PURE__ */ jsx(
149
- stdin_default$5,
150
- {
151
- id: "enter-code",
152
- changeStep: () => {
153
- },
154
- popupError,
155
- onFormSend: onSubmit
156
- }
157
- )
158
- ]
159
- }
160
- )
161
- ] });
162
- } }) }, flowKey) }) });
163
- };
164
- var stdin_default = Enable2FAFlow;
165
- export {
166
- stdin_default as default
167
- };