@stokr/components-library 3.0.76 → 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 (123) hide show
  1. package/README.md +177 -177
  2. package/dist/components/Input/InputPassword.js +3 -5
  3. package/dist/components/Input/OtpInput.js +1 -3
  4. package/dist/components/MenuNav/MenuNav.styles.js +1 -2
  5. package/dist/components/Modal/Modal.js +6 -3
  6. package/dist/components/Modal/Modal.styles.js +2 -3
  7. package/dist/components/Modal/SuccessModal/SuccessModal.js +6 -3
  8. package/dist/components/Newsletter/Newsletter.js +1 -3
  9. package/dist/components/NotificationCounter/NotificationCounter.styles.js +1 -2
  10. package/dist/components/SmartLink/SmartLink.js +0 -2
  11. package/dist/components/StepController/StepController.js +3 -5
  12. package/dist/components/StepController/StepController.styles.js +102 -1
  13. package/dist/components/StepController/StepControllerProgress.js +1 -1
  14. package/dist/components/Switch/Switch.js +1 -3
  15. package/dist/components/ToDoList/ToDoListTask.js +15 -3
  16. package/dist/components/taxId/register-taxid.js +7 -5
  17. package/dist/index.js +67 -141
  18. package/dist/manifest.json +25 -25
  19. package/dist/robots.txt +3 -3
  20. package/dist/runtime-config.js +5 -71
  21. package/dist/static/fonts/icomoon/icomoon.eot +0 -0
  22. package/dist/static/fonts/icomoon/icomoon.svg +52 -52
  23. package/dist/static/fonts/icomoon/icomoon.ttf +0 -0
  24. package/dist/static/fonts/icomoon/icomoon.woff +0 -0
  25. package/dist/static/fonts/icomoon/selection.json +0 -0
  26. package/dist/static/fonts/icomoon/style.css +0 -0
  27. package/dist/static/images/Glassess.svg +5 -5
  28. package/dist/static/images/add-folder-icon.svg +4 -4
  29. package/dist/static/images/arrow-down-black.svg +21 -21
  30. package/dist/static/images/check-icon.svg +3 -3
  31. package/dist/static/images/checkmark-circle-icon.svg +3 -3
  32. package/dist/static/images/close-circle-icon.svg +2 -2
  33. package/dist/static/images/copy_icon.svg +4 -4
  34. package/dist/static/images/cross-icon.svg +3 -3
  35. package/dist/static/images/currency/eth.svg +10 -10
  36. package/dist/static/images/currency/eth_logo.svg +8 -8
  37. package/dist/static/images/currency/eur.svg +4 -4
  38. package/dist/static/images/currency/eur.svg.js +1 -1
  39. package/dist/static/images/currency/usd.svg +4 -4
  40. package/dist/static/images/currency/usd.svg.js +1 -1
  41. package/dist/static/images/currency/usdc-logo.svg +5 -5
  42. package/dist/static/images/doc-icon.svg +3 -3
  43. package/dist/static/images/download_icon.svg +3 -3
  44. package/dist/static/images/external-link-icon.svg +3 -3
  45. package/dist/static/images/filter-icon.svg +6 -6
  46. package/dist/static/images/globe.svg +15 -15
  47. package/dist/static/images/mangopay.svg +20 -20
  48. package/dist/static/images/numbers/number_eight.svg +3 -3
  49. package/dist/static/images/numbers/number_five.svg +4 -4
  50. package/dist/static/images/numbers/number_four.svg +3 -3
  51. package/dist/static/images/numbers/number_nine.svg +4 -4
  52. package/dist/static/images/numbers/number_one.svg +4 -4
  53. package/dist/static/images/numbers/number_seven.svg +4 -4
  54. package/dist/static/images/numbers/number_six.svg +4 -4
  55. package/dist/static/images/numbers/number_three.svg +3 -3
  56. package/dist/static/images/numbers/number_two.svg +4 -4
  57. package/dist/static/images/numbers/number_zero.svg +3 -3
  58. package/dist/static/images/plus-icon.svg +4 -4
  59. package/dist/static/images/prof-inv.svg +3 -3
  60. package/dist/static/images/search-icon.svg +3 -3
  61. package/dist/static/images/transfer-icon.svg +10 -10
  62. package/dist/static/images/trash.svg +16 -16
  63. package/dist/static/images/upload.svg +5 -5
  64. package/dist/static/images/warning-filled.svg +3 -3
  65. package/dist/styles/global.js +1 -2
  66. package/dist/utils/check-todo-status.js +1 -2
  67. package/package.json +137 -143
  68. package/dist/api/authenticationApi.js +0 -13
  69. package/dist/auth/index.js +0 -34
  70. package/dist/components/2FA/Connect2FA.js +0 -58
  71. package/dist/components/2FA/EnterCode.js +0 -74
  72. package/dist/components/2FA/InstallAuthApp.js +0 -68
  73. package/dist/components/2FA/ResetCode.js +0 -34
  74. package/dist/components/2FA/Sucess2FA.js +0 -63
  75. package/dist/components/2FA/disable-2fa-flow.js +0 -104
  76. package/dist/components/2FA/enable-2fa-flow.js +0 -167
  77. package/dist/components/2FA/login-with-otp-flow.js +0 -262
  78. package/dist/components/2FA/main-flow.js +0 -273
  79. package/dist/components/Footer/Footer.js +0 -69
  80. package/dist/components/Footer/Footer.styles.js +0 -277
  81. package/dist/components/Footer/FooterLayout.js +0 -150
  82. package/dist/components/Footer/FooterMenu.js +0 -107
  83. package/dist/components/Footer/FooterMenu.styles.js +0 -334
  84. package/dist/components/ForgotPasswordModal/ForgotPasswordModal.js +0 -121
  85. package/dist/components/Header/Header.js +0 -441
  86. package/dist/components/Header/Header.styles.js +0 -568
  87. package/dist/components/Layout/Layout.js +0 -76
  88. package/dist/components/LoginModal/LoginModal.js +0 -165
  89. package/dist/components/MainMenu/DynamicMainMenu.js +0 -38
  90. package/dist/components/MainMenu/MainMenu.js +0 -220
  91. package/dist/components/MainMenu/MainMenu.styles.js +0 -362
  92. package/dist/components/Modal/NewVentureModal/NewVentureModal.js +0 -273
  93. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.js +0 -74
  94. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.styles.js +0 -20
  95. package/dist/components/RegisterModal/RegisterModal.js +0 -278
  96. package/dist/components/ResetConfirmModal/ResetConfirmModal.js +0 -40
  97. package/dist/components/ResetConfirmModal/ResetConfirmModal.styles.js +0 -41
  98. package/dist/components/ResetPasswordModal/ResetPasswordModal.js +0 -145
  99. package/dist/components/StepsProgress/StepIndicator.js +0 -40
  100. package/dist/components/StepsProgress/StepIndicator.styles.js +0 -69
  101. package/dist/components/StepsProgress/StepsProgress.js +0 -67
  102. package/dist/components/StepsProgress/StepsProgress.styles.js +0 -105
  103. package/dist/components/TermsModal/TermsModal.js +0 -145
  104. package/dist/components/TermsModal/_styles.js +0 -313
  105. package/dist/components/VerifyEmailModal/VerifyEmailModal.js +0 -122
  106. package/dist/components/headerHo/HeaderHo.js +0 -707
  107. package/dist/config.js +0 -33
  108. package/dist/context/Auth.js +0 -423
  109. package/dist/context/AuthContext.js +0 -1016
  110. package/dist/firebase-config.js +0 -56
  111. package/dist/hooks/useNewVentureForm.js +0 -235
  112. package/dist/static/images/background3.png.js +0 -4
  113. package/dist/static/images/google_auth.png.js +0 -4
  114. package/dist/static/images/iso27001-black.svg.js +0 -4
  115. package/dist/static/images/mangopay.svg.js +0 -4
  116. package/dist/static/images/social/Facebook_Logo.png.js +0 -4
  117. package/dist/static/images/social/LI-In-Bug.png.js +0 -4
  118. package/dist/static/images/social/Telegram-Logo.png.js +0 -4
  119. package/dist/static/images/social/X-logo-black.png.js +0 -4
  120. package/dist/static/images/social/youtube_social_circle_red.png.js +0 -4
  121. package/dist/utils/show-account-locked-modal.js +0 -23
  122. package/dist/utils/user-identity.js +0 -10
  123. package/dist/utils/withRouter.js +0 -26
@@ -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
- };
@@ -1,262 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import PropTypes from "prop-types";
3
- import stdin_default$2 from "./EnterCode.js";
4
- import stdin_default$3 from "./ResetCode.js";
5
- import { Layout } from "../Layout/Layout.js";
6
- import { useNavigate } from "react-router-dom";
7
- import stdin_default$1 from "../LoginModal/LoginModal.js";
8
- import { AuthContext } from "../../context/AuthContext.js";
9
- import background from "../../static/images/background3.png.js";
10
- import { hasLoggedInSession } from "../../utils/user-identity.js";
11
- import { authenticationApi } from "../../api/authenticationApi.js";
12
- import { getConfig, getPlatformURL } from "../../runtime-config.js";
13
- import { useContext, useRef, useState, useEffect } from "react";
14
- import stdin_default$4 from "../ForgotPasswordModal/ForgotPasswordModal.js";
15
- import { isAccountLockedError, showAccountLockedModal } from "../../utils/show-account-locked-modal.js";
16
- import { navigateToHref } from "../../routing/navigate-app.js";
17
- const closedModalsState = {
18
- login: false,
19
- enter2fa: false,
20
- forgot: false,
21
- resetCode: false
22
- };
23
- const LoginWithOTP = ({ withBackground, useRelativePathForMenu = false, onLoginSuccess }) => {
24
- const navigate = useNavigate();
25
- const { user, loginUser, getUser, waitingFor2fa, firebaseError, loginUserWithTotp, reset2faFlow, logoutUser } = useContext(AuthContext);
26
- const loginSuccessHandledRef = useRef(false);
27
- const [isModalOpen, setIsModalOpen] = useState({
28
- login: true,
29
- enter2fa: false,
30
- forgot: false,
31
- resetCode: false
32
- });
33
- const [isActionLoading, setIsActionLoading] = useState();
34
- const [popupError, setPopupError] = useState({
35
- popup: void 0,
36
- message: void 0
37
- });
38
- const [popupSuccess, setPopupSuccess] = useState({
39
- popup: void 0,
40
- message: void 0
41
- });
42
- const switchOpenModal = (prevModalId, nextModalId) => {
43
- setIsModalOpen((prev) => ({
44
- ...prev,
45
- [prevModalId]: false,
46
- [nextModalId]: true
47
- }));
48
- };
49
- useEffect(() => {
50
- if (waitingFor2fa) {
51
- setIsModalOpen((prev) => ({
52
- ...prev,
53
- login: false,
54
- enter2fa: true
55
- }));
56
- }
57
- }, [waitingFor2fa]);
58
- useEffect(() => {
59
- if (!hasLoggedInSession(user) || waitingFor2fa) {
60
- loginSuccessHandledRef.current = false;
61
- return;
62
- }
63
- setIsModalOpen(closedModalsState);
64
- if (onLoginSuccess && !loginSuccessHandledRef.current) {
65
- loginSuccessHandledRef.current = true;
66
- onLoginSuccess(user);
67
- }
68
- }, [user, waitingFor2fa, onLoginSuccess]);
69
- const handleSetPopupSuccess = (popup, message) => {
70
- setPopupSuccess({ popup, message });
71
- };
72
- const clearPopupSuccess = () => {
73
- setPopupSuccess({
74
- popup: void 0,
75
- message: void 0
76
- });
77
- };
78
- const handleSetPopupError = (popup, message) => {
79
- setPopupError({ popup, message });
80
- };
81
- const clearPopupError = () => {
82
- setPopupError({
83
- popup: void 0,
84
- message: void 0
85
- });
86
- };
87
- const backgroundProp = `url(${background}) left top no-repeat`;
88
- return /* @__PURE__ */ jsxs(Layout, { noHeader: true, noFooter: true, useRelativePathForMenu, children: [
89
- /* @__PURE__ */ jsx(
90
- stdin_default$1,
91
- {
92
- isActionLoading,
93
- popupError,
94
- background: withBackground && backgroundProp,
95
- isModalOpen: isModalOpen.login,
96
- onModalClose: () => {
97
- navigateToHref(navigate, getPlatformURL());
98
- },
99
- onModalSwitch: () => {
100
- navigateToHref(navigate, getConfig("registerUrl"));
101
- },
102
- onForgotPassword: () => {
103
- switchOpenModal("login", "forgot");
104
- clearPopupError();
105
- setIsActionLoading(void 0);
106
- },
107
- logoutUser,
108
- onFormSend: async ({ email, password }) => {
109
- clearPopupError();
110
- setIsActionLoading("login");
111
- try {
112
- if (password.length > 128) {
113
- handleSetPopupError("login", "Your password cannot exceed 128 characters");
114
- return;
115
- }
116
- await loginUser(email, password);
117
- await getUser();
118
- clearPopupError();
119
- } catch (error) {
120
- const errorMessage = error?.message;
121
- if (error?.code === "auth/multi-factor-auth-required") {
122
- clearPopupError();
123
- return;
124
- }
125
- if (isAccountLockedError(error)) {
126
- clearPopupError();
127
- setIsModalOpen((prev) => ({
128
- ...prev,
129
- login: false
130
- }));
131
- await showAccountLockedModal({
132
- background: withBackground ? backgroundProp : void 0
133
- });
134
- setIsModalOpen((prev) => ({
135
- ...prev,
136
- login: true
137
- }));
138
- return;
139
- }
140
- if (errorMessage) {
141
- handleSetPopupError("login", errorMessage);
142
- } else {
143
- handleSetPopupError("login", "Oops. Something's not right there. Try again?");
144
- }
145
- } finally {
146
- setIsActionLoading(void 0);
147
- }
148
- }
149
- }
150
- ),
151
- /* @__PURE__ */ jsx(
152
- stdin_default$2,
153
- {
154
- isModal: true,
155
- isActionLoading,
156
- popupError,
157
- isModalOpen: isModalOpen.enter2fa,
158
- background: withBackground && backgroundProp,
159
- onModalClose: () => {
160
- reset2faFlow();
161
- switchOpenModal("enter2fa", "login");
162
- clearPopupError();
163
- setIsActionLoading(void 0);
164
- },
165
- onModalSwitch: () => {
166
- switchOpenModal("enter2fa", "resetCode");
167
- clearPopupError();
168
- setIsActionLoading(void 0);
169
- },
170
- onFormSend: async ({ otpInput }) => {
171
- setIsActionLoading("enter2fa");
172
- try {
173
- await loginUserWithTotp(otpInput, firebaseError);
174
- await getUser();
175
- clearPopupError();
176
- setIsModalOpen(closedModalsState);
177
- } catch (error) {
178
- if (error?.code === "auth/invalid-verification-code") {
179
- handleSetPopupError("enter2fa", "The verification code is not correct. Try again?");
180
- } else if (error?.code === "auth/code-expired") {
181
- handleSetPopupError("enter2fa", "Time out. Please restart the flow and log in again");
182
- } else {
183
- handleSetPopupError("enter2fa", error?.message);
184
- }
185
- } finally {
186
- setIsActionLoading(void 0);
187
- }
188
- }
189
- }
190
- ),
191
- /* @__PURE__ */ jsx(
192
- stdin_default$3,
193
- {
194
- isModalOpen: isModalOpen.resetCode,
195
- background: withBackground && backgroundProp,
196
- onModalClose: () => {
197
- switchOpenModal("resetCode", "login");
198
- clearPopupError();
199
- setIsActionLoading(void 0);
200
- },
201
- onModalSwitch: () => {
202
- switchOpenModal("resetCode", "enter2fa");
203
- }
204
- }
205
- ),
206
- /* @__PURE__ */ jsx(
207
- stdin_default$4,
208
- {
209
- isActionLoading,
210
- popupError,
211
- background: withBackground && backgroundProp,
212
- popupSuccess,
213
- isModalOpen: isModalOpen.forgot,
214
- onModalClose: () => {
215
- switchOpenModal("forgot", "login");
216
- clearPopupError();
217
- clearPopupSuccess();
218
- setIsActionLoading(void 0);
219
- },
220
- onModalSwitch: () => {
221
- switchOpenModal("forgot", "login");
222
- clearPopupError();
223
- clearPopupSuccess();
224
- setIsActionLoading(void 0);
225
- },
226
- onFormSend: async ({ email }) => {
227
- clearPopupError();
228
- setIsActionLoading("forgot");
229
- try {
230
- await authenticationApi.post("forgotPass", {
231
- email
232
- });
233
- handleSetPopupSuccess(
234
- "forgot",
235
- `We sent a message to ${email} (you might need to check your junk or spam folder) — tap the link inside to create a new password.`
236
- );
237
- setIsActionLoading(void 0);
238
- } catch (error) {
239
- let errorMessage = `Too many requests. Please try again later.`;
240
- console.log(error?.response);
241
- if (error?.response?.status === 429) {
242
- errorMessage = error.response.data?.message;
243
- }
244
- handleSetPopupError("forgot", errorMessage);
245
- setIsActionLoading(void 0);
246
- }
247
- }
248
- }
249
- )
250
- ] });
251
- };
252
- LoginWithOTP.propTypes = {
253
- withBackground: PropTypes.bool,
254
- useRelativePathForMenu: PropTypes.bool,
255
- /** Called once when login (and optional 2FA) completes and the user session is ready. */
256
- onLoginSuccess: PropTypes.func
257
- };
258
- var stdin_default = LoginWithOTP;
259
- export {
260
- LoginWithOTP,
261
- stdin_default as default
262
- };