@stokr/components-library 2.3.58-beta.6 → 2.3.58-beta.7
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/api/StokrWeb3.js +3 -3
- package/dist/api/auth.js +16 -53
- package/dist/api/fetchData.js +26 -66
- package/dist/api/fetchDataPublic.js +20 -57
- package/dist/components/2FA/Connect2FA.js +10 -11
- package/dist/components/2FA/EnterCode.js +32 -30
- package/dist/components/2FA/EnterCode.stories.js +4 -8
- package/dist/components/2FA/InstallAuthApp.js +8 -9
- package/dist/components/2FA/ResetCode.js +11 -12
- package/dist/components/2FA/Sucess2FA.js +12 -16
- package/dist/components/2FA/disable-2fa-flow.js +53 -104
- package/dist/components/2FA/disable-2fa-flow.stories.js +4 -8
- package/dist/components/2FA/enable-2fa-flow.js +73 -144
- package/dist/components/2FA/enable-2fa-flow.stories.js +4 -8
- package/dist/components/2FA/index.js +9 -9
- package/dist/components/2FA/login-with-otp-flow.js +126 -206
- package/dist/components/2FA/login-with-otp-flow.stories.js +4 -8
- package/dist/components/2FA/main-flow.js +70 -144
- package/dist/components/2FA/main-flow.stories.js +4 -8
- package/dist/components/AccountBalance/AccountBalance.js +14 -13
- package/dist/components/AccountBalance/AccountBalance.stories.js +6 -12
- package/dist/components/AccountBalance/AccountBalance.styles.js +9 -17
- package/dist/components/AdminDashboard/Table/ReactTable.js +77 -84
- package/dist/components/AdminDashboard/Table/ReactTable.stories.js +87 -63
- package/dist/components/AdminDashboard/Table/ReactTableWrapper.js +24 -30
- package/dist/components/AdminDashboard/Table/Table.js +88 -123
- package/dist/components/AdminDashboard/Table/Table.styles.js +28 -90
- package/dist/components/AgreementItem/AgreementItem.js +10 -11
- package/dist/components/AgreementItem/AgreementItem.stories.js +5 -10
- package/dist/components/AgreementItem/AgreementItem.styles.js +8 -12
- package/dist/components/AnalyticGraphs/Analytic.js +504 -743
- package/dist/components/AnalyticGraphs/Analytic.styles.js +14 -26
- package/dist/components/BackButton/BackButton.js +9 -10
- package/dist/components/BackButton/BackButton.stories.js +4 -8
- package/dist/components/BackButton/BackButton.styles.js +13 -51
- package/dist/components/Background/Background.js +12 -11
- package/dist/components/Background/Background.stories.js +8 -14
- package/dist/components/Background/Background.styles.js +17 -33
- package/dist/components/BarChart/BarChart.js +138 -181
- package/dist/components/BarChart/BarChart.stories.js +5 -10
- package/dist/components/BarChart/BarChart.styles.js +8 -15
- package/dist/components/BarChartLegend/BarChartLegend.js +40 -67
- package/dist/components/BarChartLegend/BarChartLegend.styles.js +5 -10
- package/dist/components/BasicTable/BasicTable.js +12 -13
- package/dist/components/BasicTable/BasicTable.stories.js +5 -10
- package/dist/components/BasicTable/BasicTable.styles.js +11 -27
- package/dist/components/BlogPost/BlogPost.js +34 -53
- package/dist/components/BlogPost/BlogPost.stories.js +33 -46
- package/dist/components/BlogPost/BlogPost.styles.js +67 -59
- package/dist/components/Button/Button-stoDetails.js +150 -129
- package/dist/components/Button/Button.stories.js +27 -44
- package/dist/components/Button/Button.styles.js +24 -62
- package/dist/components/Button/GlareButton.js +61 -89
- package/dist/components/Button/GlareButton.stories.js +19 -29
- package/dist/components/ButtonContainer/ButtonContainer.styles.js +5 -10
- package/dist/components/CapitalRaisedSummary/CapitalRaisedSummery.stories.js +4 -8
- package/dist/components/CapitalRaisedSummary/CaptialRaisedSummary.js +9 -10
- package/dist/components/CapitalRaisedSummary/CaptialRaisedSummary.styles.js +8 -17
- package/dist/components/Card/Card.styles.js +14 -41
- package/dist/components/ChartBox/ChartBox.js +5 -8
- package/dist/components/ChartBox/ChartBox.stories.js +3 -6
- package/dist/components/ChartBox/ChartBox.styles.js +8 -14
- package/dist/components/ChartBox/ChartBoxDistribution.js +5 -8
- package/dist/components/ChartBox/ChartBoxDistribution.stories.js +3 -6
- package/dist/components/ChartLegend/ChartLegend.js +30 -46
- package/dist/components/ChartLegend/ChartLegend.stories.js +22 -28
- package/dist/components/ChartLegend/ChartLegend.styles.js +16 -41
- package/dist/components/Checkbox/Checkbox.js +32 -32
- package/dist/components/Checkbox/Checkbox.stories.js +5 -10
- package/dist/components/Checkbox/Checkbox.styles.js +10 -23
- package/dist/components/Checklist/ChecklistCard.js +33 -35
- package/dist/components/Checklist/ChecklistCard.stories.js +77 -100
- package/dist/components/Checklist/ChecklistCard.styles.js +12 -15
- package/dist/components/Chips/Chip.js +14 -13
- package/dist/components/Chips/Chip.stories.js +10 -19
- package/dist/components/Chips/Chip.styles.js +14 -14
- package/dist/components/Chips/ChipWrapper.js +23 -41
- package/dist/components/Chips/ChipsWrapper.stories.js +9 -17
- package/dist/components/ComponentScroll/ComponentScroll.js +25 -34
- package/dist/components/ComponentScroll/ComponentScroll.stories.js +16 -23
- package/dist/components/ComponentScroll/ComponentScroll.styles.js +22 -47
- package/dist/components/ComponentWrapper/ComponentWrapper.styles.js +7 -61
- package/dist/components/CryptoAddress/ComponentWrap.js +10 -11
- package/dist/components/CryptoAddress/CryptoAddress.js +51 -68
- package/dist/components/CryptoAddress/CryptoAddress.stories.js +7 -13
- package/dist/components/CryptoAddress/CryptoAddress.styles.js +55 -124
- package/dist/components/CryptoAddress/RadioWrap.js +9 -10
- package/dist/components/CryptoAddressDetails/CryptoAddressDetails.js +24 -25
- package/dist/components/CryptoAddressDetails/CryptoAddressDetails.stories.js +5 -10
- package/dist/components/CryptoAddressDetails/CryptoAddressDetails.styles.js +12 -42
- package/dist/components/CryptoAddressWrapper/CryptoAddressWrapper.js +10 -9
- package/dist/components/CryptoAddressWrapper/CryptoAddressWrapper.styles.js +16 -27
- package/dist/components/DonutChart/DonutChart.js +101 -130
- package/dist/components/DonutChart/DonutChart.stories.js +4 -8
- package/dist/components/DonutChart/DonutChart.styles.js +15 -27
- package/dist/components/DoubleButton/DoubleButton.styles.js +8 -8
- package/dist/components/ErrorMessage/ErrorMessage.styles.js +3 -5
- package/dist/components/FAQ/FAQ.js +29 -45
- package/dist/components/FAQ/FAQ.stories.js +4 -9
- package/dist/components/FAQ/FAQ.styles.js +23 -39
- package/dist/components/Footer/Footer.js +9 -10
- package/dist/components/Footer/Footer.stories.js +6 -12
- package/dist/components/Footer/Footer.styles.js +22 -46
- package/dist/components/Footer/FooterLayout.js +16 -20
- package/dist/components/Footer/FooterLayout.stories.js +4 -8
- package/dist/components/Footer/FooterMenu.js +61 -83
- package/dist/components/Footer/FooterMenu.stories.js +4 -8
- package/dist/components/Footer/FooterMenu.styles.js +16 -39
- package/dist/components/Footer/index.js +4 -4
- package/dist/components/ForgotPasswordModal/ForgotPasswordModal.js +92 -114
- package/dist/components/ForgotPasswordModal/ForgotPasswordModal.stories.js +4 -8
- package/dist/components/Form/Form.js +15 -14
- package/dist/components/Form/Form.stories.js +4 -8
- package/dist/components/Form/Form.styles.js +16 -36
- package/dist/components/FullscreenCard/FullscreenCard.styles.js +7 -12
- package/dist/components/Grid/Grid.styles.js +17 -68
- package/dist/components/Header/Header.js +98 -163
- package/dist/components/Header/Header.stories.js +17 -28
- package/dist/components/Header/Header.styles.js +61 -124
- package/dist/components/HeroBlock/HeroVideoBlock.js +20 -25
- package/dist/components/Icon/Icon.style.js +10 -22
- package/dist/components/Icon/Icon2.js +11 -13
- package/dist/components/InfoIcon/InfoIcon.js +18 -17
- package/dist/components/InfoIcon/InfoIcon.stories.js +5 -10
- package/dist/components/InfoIcon/InfoIcon.styles.js +5 -21
- package/dist/components/InfoPanel/InfoPanel.js +26 -48
- package/dist/components/Input/DatePickerInput.js +21 -33
- package/dist/components/Input/DatePickerInput.stories.js +5 -10
- package/dist/components/Input/DatePickerInput.styles.js +5 -19
- package/dist/components/Input/Input.js +43 -51
- package/dist/components/Input/Input.stories.js +9 -16
- package/dist/components/Input/Input.styles.js +8 -43
- package/dist/components/Input/InputPassword.js +30 -50
- package/dist/components/Input/InputPassword.stories.js +6 -12
- package/dist/components/Input/InputPassword.styles.js +30 -57
- package/dist/components/Input/InputUsername.js +83 -102
- package/dist/components/Input/InputWithButton.js +20 -19
- package/dist/components/Input/InputWithButton.stories.js +5 -9
- package/dist/components/Input/InputWithButton.styles.js +7 -19
- package/dist/components/Input/OtpInput.js +27 -42
- package/dist/components/Input/OtpInput.stories.js +5 -11
- package/dist/components/Input/RangeInput.js +29 -25
- package/dist/components/Input/RangeInput.stories.js +4 -8
- package/dist/components/Input/RangeInput.styles.js +15 -42
- package/dist/components/Input/Select.js +68 -89
- package/dist/components/Input/Select.stories.js +6 -12
- package/dist/components/Input/Select.styles.js +12 -32
- package/dist/components/InvestCalculator/InvestCalculator.js +245 -243
- package/dist/components/InvestCalculator/InvestCalculator.stories.js +18 -21
- package/dist/components/InvestCalculator/InvestCalculator.styles.js +14 -33
- package/dist/components/InvestmentStat/InvestmentStat.js +11 -10
- package/dist/components/InvestmentStat/InvestmentStat.stories.js +5 -10
- package/dist/components/InvestmentStat/InvestmentStat.styles.js +12 -24
- package/dist/components/KYCFlow/BasicInfo.js +419 -460
- package/dist/components/KYCFlow/Confirmation.js +12 -17
- package/dist/components/KYCFlow/DocumentFileUpload.js +214 -227
- package/dist/components/KYCFlow/DocumentScan.js +16 -15
- package/dist/components/KYCFlow/DocumentScanUpload.js +203 -210
- package/dist/components/KYCFlow/DocumentSelect.js +87 -117
- package/dist/components/KYCFlow/DocumentSuccess.js +14 -15
- package/dist/components/KYCFlow/DocumentUpload.js +10 -11
- package/dist/components/KYCFlow/DocumentVerificationType.js +98 -128
- package/dist/components/KYCFlow/FaceScan.js +10 -11
- package/dist/components/KYCFlow/FaceScanRecognition.js +14 -13
- package/dist/components/KYCFlow/FaceScanSuccess.js +10 -13
- package/dist/components/KYCFlow/Terms.js +90 -113
- package/dist/components/KYCFlow/_styles.js +37 -86
- package/dist/components/KYCFlow/index.js +14 -14
- package/dist/components/KYCSelectBox/KYCSelectBox.styles.js +7 -19
- package/dist/components/LatestUpdate/LatestUpdate.js +12 -11
- package/dist/components/LatestUpdate/LatestUpdate.stories.js +5 -10
- package/dist/components/LatestUpdate/LatestUpdate.styles.js +15 -28
- package/dist/components/Layout/Layout-func-no-work.js +24 -24
- package/dist/components/Layout/Layout.js +47 -68
- package/dist/components/Layout/Layout.stories.js +5 -12
- package/dist/components/LearnMoreCarousel/LearnMoreCarousel.js +13 -12
- package/dist/components/LearnMoreCarousel/LearnMoreCarousel.stories.js +5 -10
- package/dist/components/LearnMoreCarousel/LearnMoreCarousel.styles.js +10 -22
- package/dist/components/LearnMorePage/LearnMore.js +134 -174
- package/dist/components/LearnMorePage/LearnMore.shared.styles.js +7 -22
- package/dist/components/LearnMorePage/LearnMore.stories.js +4 -8
- package/dist/components/LearnMorePage/LearnMore.styles.js +24 -74
- package/dist/components/LearnMorePage/LearnMoreExampleObject.js +3 -5
- package/dist/components/LearnMorePage/LearnMoreItem.js +11 -16
- package/dist/components/LearnMorePage/LearnMoreItem.stories.js +4 -8
- package/dist/components/LearnMorePage/LearnMoreItem.styles.js +18 -54
- package/dist/components/LearnMoreSection/LearnMore.js +119 -158
- package/dist/components/LearnMoreSection/LearnMore.stories.js +4 -8
- package/dist/components/LearnMoreSection/LearnMore.styles.js +15 -41
- package/dist/components/LearnMoreSection/LearnMoreItem.js +14 -15
- package/dist/components/LearnMoreSection/LearnMoreItem.stories.js +4 -8
- package/dist/components/LearnMoreSection/LearnMoreItem.styles.js +9 -23
- package/dist/components/LoginModal/LoginModal.js +35 -41
- package/dist/components/LoginModal/LoginModal.stories.js +8 -12
- package/dist/components/MainMenu/DynamicMainMenu.js +11 -14
- package/dist/components/MainMenu/MainMenu.js +157 -190
- package/dist/components/MainMenu/MainMenu.styles.js +48 -89
- package/dist/components/MatomoConnect/Matomo.js +201 -463
- package/dist/components/MenuNav/MenuNav.styles.js +5 -9
- package/dist/components/Modal/Modal.js +46 -48
- package/dist/components/Modal/Modal.stories.js +8 -16
- package/dist/components/Modal/Modal.styles.js +34 -96
- package/dist/components/Modal/NewVentureModal/NewVentureModal.js +69 -95
- package/dist/components/Modal/NewVentureModal/NewVentureModal.stories.js +22 -43
- package/dist/components/Modal/PaymentModal.js +43 -54
- package/dist/components/Modal/PaymentModal.stories.js +4 -8
- package/dist/components/MultiProgressBar/MultiProgressBar.js +19 -23
- package/dist/components/MultiProgressBar/MultiProgressBar.stories.js +6 -12
- package/dist/components/MultiProgressBar/MultiProgressBar.styles.js +9 -22
- package/dist/components/Newsletter/Newsletter.js +65 -100
- package/dist/components/Newsletter/Newsletter.stories.js +4 -8
- package/dist/components/Newsletter/Newsletter.styles.js +47 -44
- package/dist/components/NotificationContext/NotificationContext.js +93 -125
- package/dist/components/NotificationCounter/NotificationCounter.styles.js +4 -16
- package/dist/components/Number/Number.js +13 -10
- package/dist/components/Number/Number.stories.js +23 -41
- package/dist/components/Number/Number.styles.js +4 -10
- package/dist/components/PageTransition/PageTransition.js +16 -19
- package/dist/components/Pagination/Pagination.js +22 -25
- package/dist/components/Pagination/Pagination.stories.js +29 -36
- package/dist/components/Pagination/Pagination.styles.js +8 -15
- package/dist/components/Pagination/PaginationControls.js +32 -36
- package/dist/components/Pagination/PaginationControls.stories.js +33 -62
- package/dist/components/Pagination/usePagination.js +29 -37
- package/dist/components/Process/Process.stories.js +6 -12
- package/dist/components/Process/Process.styles.js +6 -16
- package/dist/components/ProfileBadge/ProfileBadge.js +12 -11
- package/dist/components/ProfileBadge/ProfileBadge.stories.js +5 -9
- package/dist/components/ProfileBadge/ProfileBadge.styles.js +13 -19
- package/dist/components/ProfileBox/ProfileBox.js +15 -17
- package/dist/components/ProfileBox/ProfileBox.stories.js +5 -9
- package/dist/components/ProfileBox/ProfileBox.styles.js +9 -21
- package/dist/components/ProfileHeader/ProfileHeader.js +163 -199
- package/dist/components/ProfileHeader/ProfileHeader.styles.js +24 -46
- package/dist/components/ProfileStat/ProfileStat.js +12 -11
- package/dist/components/ProfileStat/ProfileStat.stories.js +6 -12
- package/dist/components/ProfileStat/ProfileStat.styles.js +9 -23
- package/dist/components/ProofOfAddress/ProofOfAddress.styles.js +20 -36
- package/dist/components/QRCode/QRCode.js +30 -30
- package/dist/components/QRCode/QRCode.stories.js +14 -26
- package/dist/components/ROI/ROI.js +225 -261
- package/dist/components/ROI/ROI.styles.js +13 -25
- package/dist/components/ROI/ROIChart.js +196 -303
- package/dist/components/ROI/ROIChart.styles.js +7 -11
- package/dist/components/ROI/ROIModal.js +13 -20
- package/dist/components/ROI/ROIParkingo.js +208 -244
- package/dist/components/ROI/ROIPixelmatic.js +209 -245
- package/dist/components/ROI/ROIScenarioBox.js +9 -8
- package/dist/components/ROI/ROIScenarioBox.styles.js +10 -33
- package/dist/components/Radio/Radio.js +19 -18
- package/dist/components/Radio/Radio.stories.js +4 -8
- package/dist/components/Radio/Radio.styles.js +5 -14
- package/dist/components/RefreshButton/RefreshButton.js +6 -5
- package/dist/components/RefreshButton/RefreshButton.stories.js +5 -10
- package/dist/components/RefreshButton/RefreshButton.styles.js +9 -24
- package/dist/components/RegisterConfirmModal/RegisterConfirmModal.js +17 -18
- package/dist/components/RegisterConfirmModal/RegisterConfirmModal.stories.js +5 -9
- package/dist/components/RegisterConfirmModal/RegisterConfirmModal.styles.js +3 -4
- package/dist/components/RegisterLiquidSteps/RegisterLiquidSteps.js +46 -70
- package/dist/components/RegisterLiquidSteps/RegisterLiquidSteps.styles.js +10 -22
- package/dist/components/RegisterLiquidSteps/complete.js +4 -5
- package/dist/components/RegisterLiquidSteps/flow.js +53 -99
- package/dist/components/RegisterLiquidSteps/index.js +7 -22
- package/dist/components/RegisterLiquidSteps/register-liquid.js +62 -102
- package/dist/components/RegisterModal/RegisterModal.js +82 -118
- package/dist/components/RegisterModal/RegisterModal.stories.js +5 -9
- package/dist/components/RequestDataBox/RequestDataBox.js +9 -8
- package/dist/components/RequestDataBox/RequestDataBox.stories.js +4 -8
- package/dist/components/RequestDataBox/RequestDataBox.styles.js +7 -12
- package/dist/components/ResetConfirmModal/ResetConfirmModal.js +10 -11
- package/dist/components/ResetConfirmModal/ResetConfirmModal.styles.js +3 -4
- package/dist/components/ResetPasswordModal/ResetPasswordModal.js +29 -28
- package/dist/components/SEO/SEO.js +11 -10
- package/dist/components/SEO/SEO.stories.js +4 -8
- package/dist/components/SectionTitle/SectionTitle.styles.js +3 -5
- package/dist/components/ShareButton/ShareButton.js +132 -145
- package/dist/components/SideLine/SideLine.js +3 -6
- package/dist/components/SideLine/SideLine.stories.js +3 -6
- package/dist/components/SideLine/SideLine.styles.js +6 -12
- package/dist/components/SigningSubflow/SignSubIntro.js +9 -8
- package/dist/components/SigningSubflow/_styles.js +9 -20
- package/dist/components/SigningSubflow/index.js +5 -5
- package/dist/components/Slider/Slider.js +16 -16
- package/dist/components/Slider/Slider.stories.js +5 -10
- package/dist/components/Slider/Slider.styles.js +5 -8
- package/dist/components/SpanButton/SpanButton.styles.js +3 -6
- package/dist/components/StatusBadge/StatusBadge.styles.js +4 -10
- package/dist/components/StepController/StepController.js +49 -74
- package/dist/components/StepController/StepController.stories.js +4 -8
- package/dist/components/StepController/StepController.styles.js +6 -12
- package/dist/components/StepController/StepControllerContext.js +46 -68
- package/dist/components/StepController/StepControllerProgress.js +16 -19
- package/dist/components/StepController/StepControllerProgress.stories.js +4 -8
- package/dist/components/StepsProgress/StepsProgress.js +44 -58
- package/dist/components/StepsProgress/StepsProgress.stories.js +33 -35
- package/dist/components/StepsProgress/StepsProgress.styles.js +7 -15
- package/dist/components/StokrLoader/StokrLoader.js +20 -23
- package/dist/components/StokrLoader/media.js +5 -7
- package/dist/components/SvgIcons/AdminBadgeSvg.js +16 -19
- package/dist/components/SvgIcons/CameraSvg.js +26 -29
- package/dist/components/SvgIcons/CapsLockSvg.js +21 -24
- package/dist/components/SvgIcons/DocumentBackSvg.js +25 -28
- package/dist/components/SvgIcons/DocumentSmallSvg.js +51 -54
- package/dist/components/SvgIcons/DocumentSvg.js +28 -31
- package/dist/components/SvgIcons/Early.js +14 -17
- package/dist/components/SvgIcons/EthSvg.js +30 -33
- package/dist/components/SvgIcons/EurSvg.js +16 -19
- package/dist/components/SvgIcons/FaceScanIconSvg.js +21 -24
- package/dist/components/SvgIcons/FourSvg.js +11 -14
- package/dist/components/SvgIcons/Glassess.js +19 -22
- package/dist/components/SvgIcons/LogoSvg.js +14 -17
- package/dist/components/SvgIcons/OneSvg.js +13 -16
- package/dist/components/SvgIcons/PassportSvg.js +46 -49
- package/dist/components/SvgIcons/RefreshSvg.js +17 -20
- package/dist/components/SvgIcons/SocialFacebook.js +20 -23
- package/dist/components/SvgIcons/SocialInstagram.js +11 -14
- package/dist/components/SvgIcons/SocialLinkedIn.js +25 -28
- package/dist/components/SvgIcons/SocialMedium.js +15 -18
- package/dist/components/SvgIcons/SocialReddit.js +15 -18
- package/dist/components/SvgIcons/SocialTelegram.js +49 -52
- package/dist/components/SvgIcons/SocialTwitter.js +44 -47
- package/dist/components/SvgIcons/SocialYoutube.js +15 -18
- package/dist/components/SvgIcons/ThreeSvg.js +10 -13
- package/dist/components/SvgIcons/TwoSidedDocumentSvg.js +72 -75
- package/dist/components/SvgIcons/TwoSvg.js +13 -16
- package/dist/components/SvgIcons/UpdateDefaultSvg.js +19 -22
- package/dist/components/SvgIcons/UpdateHardSvg.js +15 -18
- package/dist/components/SvgIcons/UpdateSoftSvg.js +17 -20
- package/dist/components/SvgIcons/UploadSvg.js +24 -27
- package/dist/components/SvgIcons/VerifiedBadge.js +13 -16
- package/dist/components/SvgIcons/index.js +32 -32
- package/dist/components/Switch/Switch.js +23 -37
- package/dist/components/Switch/Switch.stories.js +8 -14
- package/dist/components/Switch/Switch.styles.js +8 -33
- package/dist/components/Tabs/Tabs.js +19 -21
- package/dist/components/Tabs/Tabs.stories.js +4 -8
- package/dist/components/Tabs/Tabs.styles.js +4 -6
- package/dist/components/TabsNav/TabNav.js +14 -13
- package/dist/components/TabsNav/TabNav.stories.js +5 -10
- package/dist/components/TabsNav/TabsNav.js +14 -14
- package/dist/components/TabsNav/TabsNav.stories.js +4 -8
- package/dist/components/TabsNav/TabsNav.styles.js +10 -25
- package/dist/components/TeamOverview/TeamOverview.js +38 -84
- package/dist/components/TeamOverview/TeamOverview.stories.js +5 -10
- package/dist/components/TeamOverview/TeamOverview.styles.js +18 -35
- package/dist/components/TermsModal/TermsModal.js +49 -79
- package/dist/components/TermsModal/TermsModal.stories.js +4 -8
- package/dist/components/TermsModal/_styles.js +35 -100
- package/dist/components/Text/Headline.js +15 -14
- package/dist/components/Text/Headline.stories.js +4 -8
- package/dist/components/Text/StyledText.js +5 -8
- package/dist/components/Text/Text.stories.js +5 -10
- package/dist/components/Text/Text.styles.js +15 -37
- package/dist/components/TextLink/TextLink.styles.js +6 -17
- package/dist/components/ToDoList/ToDoList.js +76 -85
- package/dist/components/ToDoList/ToDoList.stories.js +7 -14
- package/dist/components/ToDoList/ToDoList.styles.js +34 -43
- package/dist/components/ToDoList/ToDoListTask.js +22 -35
- package/dist/components/ToDoList/ToDoListTask.stories.js +5 -10
- package/dist/components/ToDoList/ToDoListTask.styles.js +13 -40
- package/dist/components/TransactionDetails/TransactionDetails.js +9 -19
- package/dist/components/TransactionDetails/TransactionDetails.stories.js +5 -10
- package/dist/components/TransactionDetails/TransactionDetails.styles.js +6 -15
- package/dist/components/TransactionInfo/TransactionInfo.js +18 -17
- package/dist/components/TransactionInfo/TransactionInfo.stories.js +4 -8
- package/dist/components/TransactionInfo/TransactionInfo.styles.js +10 -31
- package/dist/components/TwoFactorModal/TwoFactorModal.js +72 -94
- package/dist/components/VerifyEmailModal/VerifyEmailModal.js +49 -48
- package/dist/components/VerifyEmailModal/VerifyEmailModal.stories.js +6 -11
- package/dist/components/breakdown/Breakdown.js +38 -36
- package/dist/components/breakdown/index.js +3 -5
- package/dist/components/headerHo/HeaderHo.js +585 -769
- package/dist/components/headerHo/HeaderHo.stories.js +9 -13
- package/dist/components/headerHo/index.js +3 -5
- package/dist/components/icons/Arrow.js +43 -46
- package/dist/components/icons/Arrow.stories.js +7 -14
- package/dist/components/icons/ArrowSimple.js +32 -35
- package/dist/components/icons/ArrowSimple.stories.js +7 -14
- package/dist/components/icons/Check.js +28 -31
- package/dist/components/icons/Check.stories.js +3 -6
- package/dist/components/icons/Facebook.js +11 -14
- package/dist/components/icons/Facebook.stories.js +3 -6
- package/dist/components/icons/Info.js +40 -43
- package/dist/components/icons/Info.stories.js +3 -6
- package/dist/components/icons/Instagram.js +11 -14
- package/dist/components/icons/Instagram.stories.js +3 -6
- package/dist/components/icons/LinkIcon.js +19 -22
- package/dist/components/icons/LinkIcon.stories.js +3 -6
- package/dist/components/icons/LinkedIn.js +28 -31
- package/dist/components/icons/LinkedIn.stories.js +3 -6
- package/dist/components/icons/Medium.js +27 -30
- package/dist/components/icons/Medium.stories.js +3 -6
- package/dist/components/icons/Reddit.js +17 -20
- package/dist/components/icons/Reddit.stories.js +3 -6
- package/dist/components/icons/Share.js +47 -50
- package/dist/components/icons/Share.stories.js +3 -6
- package/dist/components/icons/Telegram.js +27 -30
- package/dist/components/icons/Telegram.stories.js +3 -6
- package/dist/components/icons/Twitter.js +11 -14
- package/dist/components/icons/Twitter.stories.js +3 -6
- package/dist/components/icons/X.js +11 -14
- package/dist/components/icons/X.stories.js +3 -6
- package/dist/components/icons/Youtube.js +11 -14
- package/dist/components/icons/Youtube.stories.js +3 -6
- package/dist/components/icons/index.js +15 -15
- package/dist/components/landing-page/List.js +3 -5
- package/dist/components/landing-page/PageContent.js +5 -7
- package/dist/components/landing-page/PageText.js +12 -16
- package/dist/components/landing-page/PageTitle.js +16 -47
- package/dist/components/logo/Logo.js +49 -71
- package/dist/components/logo/index.js +3 -5
- package/dist/components/renderToBody/index.js +3 -5
- package/dist/components/renderToBody/renderToBody.js +39 -60
- package/dist/components/taxId/TaxId.stories.js +11 -16
- package/dist/components/taxId/complete.js +9 -11
- package/dist/components/taxId/flow.js +22 -34
- package/dist/components/taxId/index.js +4 -4
- package/dist/components/taxId/register-taxid.js +54 -92
- package/dist/components/video/Video.js +69 -84
- package/dist/components/video/Video.stories.js +5 -9
- package/dist/components/video/index.js +3 -5
- package/dist/constants/globalVariables.js +10 -20
- package/dist/constants/style.js +23 -46
- package/dist/context/Auth.js +247 -340
- package/dist/context/AuthContext.js +545 -1023
- package/dist/context/Checkbox/CheckboxContext.js +65 -117
- package/dist/firebase-config.js +4 -6
- package/dist/hooks/useNewVentureForm.js +128 -193
- package/dist/hooks/useTimer.js +29 -51
- package/dist/index.js +134 -134
- package/dist/model/axios.js +4 -5
- package/dist/model/axiosPublic.js +4 -5
- package/dist/services/TimerService.js +70 -89
- package/dist/static/images/copy_icon.svg +4 -0
- package/dist/styles/colors.js +2 -4
- package/dist/styles/fonts.js +3 -4
- package/dist/styles/global.js +3 -4
- package/dist/styles/grid.js +4 -5
- package/dist/styles/reactTippy.js +3 -4
- package/dist/styles/rwd.js +12 -26
- package/dist/styles/semanticUi.js +3 -4
- package/dist/styles/spacing.js +2 -3
- package/dist/styles/theme.js +6 -9
- package/dist/utils/allowed-countries-list.js +2 -3
- package/dist/utils/analytics.js +32 -48
- package/dist/utils/check-sale-time-left.js +37 -39
- package/dist/utils/check-todo-status.js +3 -4
- package/dist/utils/checklistGenerator.js +46 -46
- package/dist/utils/copyToClipboard.js +65 -131
- package/dist/utils/countries-list.js +2 -3
- package/dist/utils/customHooks.js +40 -67
- package/dist/utils/delete-redirect-cookie-and-navigate.js +3 -3
- package/dist/utils/fix-decimals.js +4 -5
- package/dist/utils/formatCurrencyValue.js +41 -52
- package/dist/utils/get-cookie-domain.js +3 -4
- package/dist/utils/get-short-address.js +1 -3
- package/dist/utils/isUSInvestor.js +2 -4
- package/dist/utils/km_ify.js +3 -3
- package/dist/utils/lock-body.js +3 -5
- package/dist/utils/moment.js +10 -12
- package/dist/utils/redirect-url.js +2 -3
- package/dist/utils/saveAs.js +5 -5
- package/dist/utils/scrollUtils.js +33 -36
- package/dist/utils/set-redirect-cookie.js +6 -7
- package/dist/utils/withRouter.js +6 -6
- package/package.json +134 -141
|
@@ -13,42 +13,21 @@ var _avatarPlaceholder = _interopRequireDefault(require("../static/images/avatar
|
|
|
13
13
|
var _auth = require("firebase/auth");
|
|
14
14
|
var _firebaseConfig = require("../firebase-config");
|
|
15
15
|
var _fetchData = _interopRequireDefault(require("../api/fetchData"));
|
|
16
|
-
function _interopRequireDefault(
|
|
17
|
-
function
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
19
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
32
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
36
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
37
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
38
|
-
var AuthContext = /*#__PURE__*/_react.default.createContext();
|
|
39
|
-
exports.AuthContext = AuthContext;
|
|
40
|
-
var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
41
|
-
_inherits(AuthProviderClass, _Component);
|
|
42
|
-
var _super = _createSuper(AuthProviderClass);
|
|
43
|
-
function AuthProviderClass() {
|
|
20
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
const AuthContext = exports.AuthContext = /*#__PURE__*/_react.default.createContext();
|
|
24
|
+
class AuthProviderClass extends _react.Component {
|
|
25
|
+
constructor() {
|
|
44
26
|
var _this;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
50
|
-
_defineProperty(_assertThisInitialized(_this), "userRef", /*#__PURE__*/_react.default.createRef(null));
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
_this = this;
|
|
29
|
+
_defineProperty(this, "userRef", /*#__PURE__*/_react.default.createRef(null));
|
|
30
|
+
_defineProperty(this, "state", {
|
|
52
31
|
user: undefined,
|
|
53
32
|
firebaseUser: undefined,
|
|
54
33
|
isFetchingUser: false,
|
|
@@ -59,304 +38,169 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
59
38
|
verifyEmailError: null,
|
|
60
39
|
isVerifyingEmail: false
|
|
61
40
|
});
|
|
62
|
-
_defineProperty(
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
_defineProperty(this, "checkTokenIsValid", function () {
|
|
42
|
+
let redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
43
|
+
const accessToken = _Auth.default.getAccessToken();
|
|
65
44
|
if (!accessToken) {
|
|
66
45
|
_this.logoutUser(redirect);
|
|
67
46
|
}
|
|
68
47
|
return !!accessToken;
|
|
69
48
|
});
|
|
70
|
-
_defineProperty(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!customToken) {
|
|
78
|
-
_context.next = 7;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
_context.next = 4;
|
|
82
|
-
return _Auth.default.signInWithToken(customToken);
|
|
83
|
-
case 4:
|
|
84
|
-
user = _context.sent;
|
|
85
|
-
_context.next = 10;
|
|
86
|
-
break;
|
|
87
|
-
case 7:
|
|
88
|
-
_context.next = 9;
|
|
89
|
-
return _Auth.default.login(email, password);
|
|
90
|
-
case 9:
|
|
91
|
-
user = _context.sent;
|
|
92
|
-
case 10:
|
|
93
|
-
_Auth.default.setAccessToken(user.accessToken);
|
|
94
|
-
_this.setState({
|
|
95
|
-
firebaseUser: user,
|
|
96
|
-
isFetchingUser: false
|
|
97
|
-
});
|
|
98
|
-
//if you need user immediatly
|
|
99
|
-
return _context.abrupt("return", user);
|
|
100
|
-
case 15:
|
|
101
|
-
_context.prev = 15;
|
|
102
|
-
_context.t0 = _context["catch"](0);
|
|
103
|
-
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', _context.t0);
|
|
104
|
-
_context.t1 = _context.t0.code;
|
|
105
|
-
_context.next = _context.t1 === 'auth/multi-factor-auth-required' ? 21 : _context.t1 === 'auth/requires-recent-login' ? 23 : _context.t1 === 'auth/invalid-login-credentials' ? 25 : _context.t1 === 'auth/invalid-credential' ? 25 : 27;
|
|
106
|
-
break;
|
|
107
|
-
case 21:
|
|
108
|
-
_this.setState({
|
|
109
|
-
waitingFor2fa: true,
|
|
110
|
-
firebaseError: _context.t0
|
|
111
|
-
});
|
|
112
|
-
throw _context.t0;
|
|
113
|
-
case 23:
|
|
114
|
-
// The user's last sign-in time does not meet the security threshold.
|
|
115
|
-
_this.logoutUser();
|
|
116
|
-
return _context.abrupt("break", 30);
|
|
117
|
-
case 25:
|
|
118
|
-
_context.t0.message = 'The credentials are not correct. Try again?';
|
|
119
|
-
throw _context.t0;
|
|
120
|
-
case 27:
|
|
121
|
-
console.log({
|
|
122
|
-
error: _context.t0
|
|
123
|
-
}); // Handle other errors, such as wrong passwords.
|
|
124
|
-
throw _context.t0;
|
|
125
|
-
case 30:
|
|
126
|
-
case "end":
|
|
127
|
-
return _context.stop();
|
|
128
|
-
}
|
|
129
|
-
}, _callee, null, [[0, 15]]);
|
|
130
|
-
}));
|
|
131
|
-
return function (_x, _x2, _x3) {
|
|
132
|
-
return _ref.apply(this, arguments);
|
|
133
|
-
};
|
|
134
|
-
}());
|
|
135
|
-
_defineProperty(_assertThisInitialized(_this), "createUser", /*#__PURE__*/function () {
|
|
136
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(email, password) {
|
|
137
|
-
var user;
|
|
138
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
139
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
140
|
-
case 0:
|
|
141
|
-
_context2.prev = 0;
|
|
142
|
-
_context2.next = 3;
|
|
143
|
-
return _Auth.default.createUser(email, password);
|
|
144
|
-
case 3:
|
|
145
|
-
user = _context2.sent;
|
|
146
|
-
_context2.next = 10;
|
|
147
|
-
break;
|
|
148
|
-
case 6:
|
|
149
|
-
_context2.prev = 6;
|
|
150
|
-
_context2.t0 = _context2["catch"](0);
|
|
151
|
-
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', _context2.t0);
|
|
152
|
-
throw _context2.t0;
|
|
153
|
-
case 10:
|
|
154
|
-
case "end":
|
|
155
|
-
return _context2.stop();
|
|
156
|
-
}
|
|
157
|
-
}, _callee2, null, [[0, 6]]);
|
|
158
|
-
}));
|
|
159
|
-
return function (_x4, _x5) {
|
|
160
|
-
return _ref2.apply(this, arguments);
|
|
161
|
-
};
|
|
162
|
-
}());
|
|
163
|
-
_defineProperty(_assertThisInitialized(_this), "loginUserWithTotp", /*#__PURE__*/function () {
|
|
164
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(verificationCode, error) {
|
|
165
|
-
var mfaResolver, selectedIndex, otpFromAuthenticator, multiFactorAssertion, userCredential, user;
|
|
166
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
167
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
168
|
-
case 0:
|
|
169
|
-
mfaResolver = (0, _auth.getMultiFactorResolver)((0, _auth.getAuth)(), error);
|
|
170
|
-
selectedIndex = 0;
|
|
171
|
-
_context3.t0 = mfaResolver.hints[selectedIndex].factorId;
|
|
172
|
-
_context3.next = _context3.t0 === _auth.TotpMultiFactorGenerator.FACTOR_ID ? 5 : _context3.t0 === _auth.PhoneMultiFactorGenerator.FACTOR_ID ? 21 : 22;
|
|
173
|
-
break;
|
|
174
|
-
case 5:
|
|
175
|
-
otpFromAuthenticator = verificationCode; // OTP typed by the user.
|
|
176
|
-
multiFactorAssertion = _auth.TotpMultiFactorGenerator.assertionForSignIn(mfaResolver.hints[selectedIndex].uid, otpFromAuthenticator);
|
|
177
|
-
_context3.prev = 7;
|
|
178
|
-
_context3.next = 10;
|
|
179
|
-
return mfaResolver.resolveSignIn(multiFactorAssertion);
|
|
180
|
-
case 10:
|
|
181
|
-
userCredential = _context3.sent;
|
|
182
|
-
user = userCredential.user;
|
|
183
|
-
_Auth.default.setAccessToken(user.accessToken);
|
|
184
|
-
_this.setState({
|
|
185
|
-
firebaseUser: user,
|
|
186
|
-
waitingFor2fa: false
|
|
187
|
-
});
|
|
188
|
-
_context3.next = 20;
|
|
189
|
-
break;
|
|
190
|
-
case 16:
|
|
191
|
-
_context3.prev = 16;
|
|
192
|
-
_context3.t1 = _context3["catch"](7);
|
|
193
|
-
// Invalid or expired OTP.
|
|
194
|
-
console.log({
|
|
195
|
-
error: _context3.t1
|
|
196
|
-
});
|
|
197
|
-
throw _context3.t1;
|
|
198
|
-
case 20:
|
|
199
|
-
return _context3.abrupt("break", 23);
|
|
200
|
-
case 21:
|
|
201
|
-
return _context3.abrupt("break", 23);
|
|
202
|
-
case 22:
|
|
203
|
-
return _context3.abrupt("break", 23);
|
|
204
|
-
case 23:
|
|
205
|
-
case "end":
|
|
206
|
-
return _context3.stop();
|
|
207
|
-
}
|
|
208
|
-
}, _callee3, null, [[7, 16]]);
|
|
209
|
-
}));
|
|
210
|
-
return function (_x6, _x7) {
|
|
211
|
-
return _ref3.apply(this, arguments);
|
|
212
|
-
};
|
|
213
|
-
}());
|
|
214
|
-
_defineProperty(_assertThisInitialized(_this), "generateTotpSecret", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
215
|
-
var user,
|
|
216
|
-
appName,
|
|
217
|
-
multiFactorSession,
|
|
218
|
-
totpSecret,
|
|
219
|
-
totpUri,
|
|
220
|
-
_args4 = arguments;
|
|
221
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
222
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
223
|
-
case 0:
|
|
224
|
-
user = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : _firebaseConfig.auth.currentUser;
|
|
225
|
-
appName = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : 'STOKR';
|
|
226
|
-
_context4.prev = 2;
|
|
227
|
-
_context4.next = 5;
|
|
228
|
-
return (0, _auth.multiFactor)(user).getSession();
|
|
229
|
-
case 5:
|
|
230
|
-
multiFactorSession = _context4.sent;
|
|
231
|
-
_context4.next = 8;
|
|
232
|
-
return _auth.TotpMultiFactorGenerator.generateSecret(multiFactorSession);
|
|
233
|
-
case 8:
|
|
234
|
-
totpSecret = _context4.sent;
|
|
235
|
-
totpUri = totpSecret.generateQrCodeUrl(user.email, appName);
|
|
236
|
-
return _context4.abrupt("return", {
|
|
237
|
-
totpUri: totpUri,
|
|
238
|
-
totpSecret: totpSecret
|
|
239
|
-
});
|
|
240
|
-
case 13:
|
|
241
|
-
_context4.prev = 13;
|
|
242
|
-
_context4.t0 = _context4["catch"](2);
|
|
243
|
-
console.log('🚀 ~ file: AuthContext.js:51 ~ error:', _context4.t0);
|
|
244
|
-
throw _context4.t0;
|
|
245
|
-
case 17:
|
|
246
|
-
case "end":
|
|
247
|
-
return _context4.stop();
|
|
49
|
+
_defineProperty(this, "loginUser", async (email, password, customToken) => {
|
|
50
|
+
try {
|
|
51
|
+
let user;
|
|
52
|
+
if (customToken) {
|
|
53
|
+
user = await _Auth.default.signInWithToken(customToken);
|
|
54
|
+
} else {
|
|
55
|
+
user = await _Auth.default.login(email, password);
|
|
248
56
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
_context5.next = 12;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
_context5.next = 9;
|
|
272
|
-
return (0, _auth.multiFactor)(user).unenroll(userMfaEnrollment[i].uid);
|
|
273
|
-
case 9:
|
|
274
|
-
i++;
|
|
275
|
-
_context5.next = 6;
|
|
57
|
+
_Auth.default.setAccessToken(user.accessToken);
|
|
58
|
+
this.setState({
|
|
59
|
+
firebaseUser: user,
|
|
60
|
+
isFetchingUser: false
|
|
61
|
+
});
|
|
62
|
+
//if you need user immediatly
|
|
63
|
+
return user;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', error);
|
|
66
|
+
switch (error.code) {
|
|
67
|
+
case 'auth/multi-factor-auth-required':
|
|
68
|
+
this.setState({
|
|
69
|
+
waitingFor2fa: true,
|
|
70
|
+
firebaseError: error
|
|
71
|
+
});
|
|
72
|
+
throw error;
|
|
73
|
+
case 'auth/requires-recent-login':
|
|
74
|
+
// The user's last sign-in time does not meet the security threshold.
|
|
75
|
+
this.logoutUser();
|
|
276
76
|
break;
|
|
277
|
-
case
|
|
278
|
-
|
|
77
|
+
case 'auth/invalid-login-credentials':
|
|
78
|
+
case 'auth/invalid-credential':
|
|
79
|
+
error.message = 'The credentials are not correct. Try again?';
|
|
80
|
+
throw error;
|
|
81
|
+
default:
|
|
82
|
+
console.log({
|
|
83
|
+
error
|
|
84
|
+
}); // Handle other errors, such as wrong passwords.
|
|
85
|
+
throw error;
|
|
279
86
|
break;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
_defineProperty(this, "createUser", async (email, password) => {
|
|
91
|
+
try {
|
|
92
|
+
const user = await _Auth.default.createUser(email, password);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', error);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
_defineProperty(this, "loginUserWithTotp", async (verificationCode, error) => {
|
|
99
|
+
const mfaResolver = (0, _auth.getMultiFactorResolver)((0, _auth.getAuth)(), error);
|
|
100
|
+
const selectedIndex = 0;
|
|
101
|
+
switch (mfaResolver.hints[selectedIndex].factorId) {
|
|
102
|
+
case _auth.TotpMultiFactorGenerator.FACTOR_ID:
|
|
103
|
+
const otpFromAuthenticator = verificationCode; // OTP typed by the user.
|
|
104
|
+
const multiFactorAssertion = _auth.TotpMultiFactorGenerator.assertionForSignIn(mfaResolver.hints[selectedIndex].uid, otpFromAuthenticator);
|
|
105
|
+
try {
|
|
106
|
+
const userCredential = await mfaResolver.resolveSignIn(multiFactorAssertion);
|
|
107
|
+
const user = userCredential.user;
|
|
108
|
+
_Auth.default.setAccessToken(user.accessToken);
|
|
109
|
+
this.setState({
|
|
110
|
+
firebaseUser: user,
|
|
111
|
+
waitingFor2fa: false
|
|
112
|
+
});
|
|
113
|
+
} catch (error) {
|
|
114
|
+
// Invalid or expired OTP.
|
|
283
115
|
console.log({
|
|
284
|
-
error
|
|
116
|
+
error
|
|
285
117
|
});
|
|
286
|
-
throw
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case _auth.PhoneMultiFactorGenerator.FACTOR_ID:
|
|
122
|
+
// Handle SMS second factor.
|
|
123
|
+
break;
|
|
124
|
+
default:
|
|
125
|
+
// Unsupported second factor?
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
_defineProperty(this, "generateTotpSecret", async function () {
|
|
130
|
+
let user = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _firebaseConfig.auth.currentUser;
|
|
131
|
+
let appName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'STOKR';
|
|
132
|
+
try {
|
|
133
|
+
const multiFactorSession = await (0, _auth.multiFactor)(user).getSession();
|
|
134
|
+
const totpSecret = await _auth.TotpMultiFactorGenerator.generateSecret(multiFactorSession);
|
|
135
|
+
const totpUri = totpSecret.generateQrCodeUrl(user.email, appName);
|
|
136
|
+
return {
|
|
137
|
+
totpUri,
|
|
138
|
+
totpSecret
|
|
139
|
+
};
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.log('🚀 ~ file: AuthContext.js:51 ~ error:', error);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
_defineProperty(this, "unenrollUser2FA", async () => {
|
|
146
|
+
const {
|
|
147
|
+
userMfaEnrollment,
|
|
148
|
+
user
|
|
149
|
+
} = this.state;
|
|
150
|
+
if ((userMfaEnrollment === null || userMfaEnrollment === void 0 ? void 0 : userMfaEnrollment.length) === 0) {
|
|
151
|
+
console.log('User is not enrolled in 2FA');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
// Unenroll all the MFA entries in the current currentUser by uid.
|
|
156
|
+
for (let i = 0; i < userMfaEnrollment.length; i++) {
|
|
157
|
+
await (0, _auth.multiFactor)(user).unenroll(userMfaEnrollment[i].uid);
|
|
290
158
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.log({
|
|
161
|
+
error
|
|
162
|
+
});
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
_defineProperty(this, "checkMfaEnrollment", function () {
|
|
167
|
+
let user = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _firebaseConfig.auth.currentUser;
|
|
168
|
+
const checkMfaEnrollment = (0, _auth.multiFactor)(user).enrolledFactors;
|
|
296
169
|
_this.setState({
|
|
297
170
|
userMfaEnrollment: checkMfaEnrollment
|
|
298
171
|
});
|
|
299
172
|
return checkMfaEnrollment;
|
|
300
173
|
});
|
|
301
|
-
_defineProperty(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
_args7 = arguments;
|
|
332
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
333
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
334
|
-
case 0:
|
|
335
|
-
redirect = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : false;
|
|
336
|
-
(0, _auth.signOut)(_firebaseConfig.auth).then(function () {});
|
|
337
|
-
_Auth.default.logout();
|
|
338
|
-
delete _axios.default.defaults.headers.common.Authorization;
|
|
339
|
-
_this.setUser(null);
|
|
340
|
-
_this.setState({
|
|
341
|
-
firebaseUser: null,
|
|
342
|
-
firebaseError: null,
|
|
343
|
-
verifyEmailError: null,
|
|
344
|
-
userMfaEnrollment: null,
|
|
345
|
-
waitingFor2fa: false,
|
|
346
|
-
isVerifyingEmail: false,
|
|
347
|
-
avatar: _avatarPlaceholder.default,
|
|
348
|
-
isFetchingUser: false
|
|
349
|
-
});
|
|
350
|
-
if (redirect) {
|
|
351
|
-
window.location.href = "https://".concat(process.env.REACT_APP_WEBSITE_DOMAIN);
|
|
352
|
-
}
|
|
353
|
-
case 7:
|
|
354
|
-
case "end":
|
|
355
|
-
return _context7.stop();
|
|
356
|
-
}
|
|
357
|
-
}, _callee7);
|
|
358
|
-
})));
|
|
359
|
-
_defineProperty(_assertThisInitialized(_this), "patchUserObject", function (user, firebaseUser) {
|
|
174
|
+
_defineProperty(this, "enrollUserToTotp", async (user, totpSecret, verificationCode, displayName) => {
|
|
175
|
+
try {
|
|
176
|
+
// Finalize the enrollment.
|
|
177
|
+
const multiFactorAssertion = _auth.TotpMultiFactorGenerator.assertionForEnrollment(totpSecret, verificationCode);
|
|
178
|
+
await (0, _auth.multiFactor)(user).enroll(multiFactorAssertion, displayName);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
_defineProperty(this, "logoutUser", async function () {
|
|
184
|
+
let redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
185
|
+
(0, _auth.signOut)(_firebaseConfig.auth).then(() => {});
|
|
186
|
+
_Auth.default.logout();
|
|
187
|
+
delete _axios.default.defaults.headers.common.Authorization;
|
|
188
|
+
_this.setUser(null);
|
|
189
|
+
_this.setState({
|
|
190
|
+
firebaseUser: null,
|
|
191
|
+
firebaseError: null,
|
|
192
|
+
verifyEmailError: null,
|
|
193
|
+
userMfaEnrollment: null,
|
|
194
|
+
waitingFor2fa: false,
|
|
195
|
+
isVerifyingEmail: false,
|
|
196
|
+
avatar: _avatarPlaceholder.default,
|
|
197
|
+
isFetchingUser: false
|
|
198
|
+
});
|
|
199
|
+
if (redirect) {
|
|
200
|
+
window.location.href = "https://".concat(process.env.REACT_APP_WEBSITE_DOMAIN);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
_defineProperty(this, "patchUserObject", (user, firebaseUser) => {
|
|
360
204
|
if (!user || !firebaseUser) return;
|
|
361
205
|
|
|
362
206
|
//use emailVerified as source of truth for user.active
|
|
@@ -366,94 +210,67 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
366
210
|
//user object will override any properties that are the same in the firebaseUser
|
|
367
211
|
return Object.assign(firebaseUser, user);
|
|
368
212
|
});
|
|
369
|
-
_defineProperty(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
case 0:
|
|
382
|
-
accessToken = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : _Auth.default.getAccessToken();
|
|
383
|
-
if (accessToken) {
|
|
384
|
-
_context8.next = 4;
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
_this.setState({
|
|
388
|
-
isFetchingUser: false
|
|
389
|
-
});
|
|
390
|
-
return _context8.abrupt("return");
|
|
391
|
-
case 4:
|
|
392
|
-
_this.setState({
|
|
393
|
-
isFetchingUser: true
|
|
394
|
-
});
|
|
395
|
-
_axios.default.defaults.headers.common.Authorization = "Bearer ".concat(accessToken);
|
|
213
|
+
_defineProperty(this, "getUser", async function () {
|
|
214
|
+
let accessToken = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _Auth.default.getAccessToken();
|
|
215
|
+
if (!accessToken) {
|
|
216
|
+
_this.setState({
|
|
217
|
+
isFetchingUser: false
|
|
218
|
+
});
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
_this.setState({
|
|
222
|
+
isFetchingUser: true
|
|
223
|
+
});
|
|
224
|
+
_axios.default.defaults.headers.common.Authorization = "Bearer ".concat(accessToken);
|
|
396
225
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return (0, _fetchData.default)('auth/get-custom-token');
|
|
411
|
-
case 15:
|
|
412
|
-
_yield$fetchData = _context8.sent;
|
|
413
|
-
customToken = _yield$fetchData.customToken;
|
|
414
|
-
_context8.next = 19;
|
|
415
|
-
return _Auth.default.signInWithToken(customToken);
|
|
416
|
-
case 19:
|
|
417
|
-
firebaseUser = _context8.sent;
|
|
418
|
-
case 20:
|
|
419
|
-
//merge firebaseUser and our user object
|
|
420
|
-
user = _this.patchUserObject(result.user, firebaseUser); //if user is empty throw an error
|
|
421
|
-
//if user hasn't completed the signup process, redirect to welcome page on signup
|
|
422
|
-
_this.checkUserIsValid(user);
|
|
423
|
-
customValidateGetUser && customValidateGetUser(user);
|
|
424
|
-
userAvatar = "".concat(process.env.REACT_APP_PHOTO_API_URL, "/media/picture/view/").concat(user._id);
|
|
425
|
-
_this.checkUserPhoto(userAvatar);
|
|
426
|
-
_this.setUser(user);
|
|
427
|
-
_this.setState({
|
|
428
|
-
isFetchingUser: false
|
|
429
|
-
});
|
|
226
|
+
//pass this function as a prop if you need any custom logic after user/get
|
|
227
|
+
const {
|
|
228
|
+
customValidateGetUser
|
|
229
|
+
} = _this.props;
|
|
230
|
+
try {
|
|
231
|
+
const result = await _Auth.default.getUser();
|
|
232
|
+
let firebaseUser = _this.state.firebaseUser;
|
|
233
|
+
if (!firebaseUser) {
|
|
234
|
+
const {
|
|
235
|
+
customToken
|
|
236
|
+
} = await (0, _fetchData.default)('auth/get-custom-token');
|
|
237
|
+
firebaseUser = await _Auth.default.signInWithToken(customToken);
|
|
238
|
+
}
|
|
430
239
|
|
|
431
|
-
|
|
432
|
-
|
|
240
|
+
//merge firebaseUser and our user object
|
|
241
|
+
const user = _this.patchUserObject(result.user, firebaseUser);
|
|
433
242
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
243
|
+
//if user is empty throw an error
|
|
244
|
+
//if user hasn't completed the signup process, redirect to welcome page on signup
|
|
245
|
+
_this.checkUserIsValid(user);
|
|
246
|
+
customValidateGetUser && customValidateGetUser(user);
|
|
247
|
+
let userAvatar = "".concat(process.env.REACT_APP_PHOTO_API_URL, "/media/picture/view/").concat(user._id);
|
|
248
|
+
_this.checkUserPhoto(userAvatar);
|
|
249
|
+
_this.setUser(user);
|
|
250
|
+
_this.setState({
|
|
251
|
+
isFetchingUser: false
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
//redirect to home if user is on login or signup route (affects homepage only)
|
|
255
|
+
_this.replaceLocationPathName();
|
|
256
|
+
|
|
257
|
+
//if you need user info immediately after call (before setState is executed), you can use this
|
|
258
|
+
return user;
|
|
259
|
+
} catch (error) {
|
|
260
|
+
_this.setState({
|
|
261
|
+
isFetchingUser: false
|
|
262
|
+
});
|
|
263
|
+
console.log("Error in getUser: ".concat(error));
|
|
264
|
+
throw error;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
_defineProperty(this, "checkUserPhoto", avatar => {
|
|
451
268
|
try {
|
|
452
|
-
|
|
269
|
+
const http = new XMLHttpRequest();
|
|
453
270
|
http.open('HEAD', avatar, true);
|
|
454
|
-
http.onload =
|
|
271
|
+
http.onload = () => {
|
|
455
272
|
if (http.status === 200) {
|
|
456
|
-
|
|
273
|
+
this.setState({
|
|
457
274
|
avatar: avatar
|
|
458
275
|
});
|
|
459
276
|
}
|
|
@@ -463,7 +280,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
463
280
|
console.log('error: ', error);
|
|
464
281
|
}
|
|
465
282
|
});
|
|
466
|
-
_defineProperty(
|
|
283
|
+
_defineProperty(this, "checkUserIsValid", user => {
|
|
467
284
|
if (!user) {
|
|
468
285
|
throw new Error('User is not defined');
|
|
469
286
|
} else if (!(user !== null && user !== void 0 && user.emailVerified) && !window.location.href.includes('signup.')) {
|
|
@@ -475,653 +292,358 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
475
292
|
}
|
|
476
293
|
return true;
|
|
477
294
|
});
|
|
478
|
-
_defineProperty(
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
_context9.prev = 0;
|
|
486
|
-
user = _this.state.user;
|
|
487
|
-
if (!(!user || !file)) {
|
|
488
|
-
_context9.next = 4;
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
return _context9.abrupt("return");
|
|
492
|
-
case 4:
|
|
493
|
-
formData = new FormData();
|
|
494
|
-
formData.append('userId', user._id);
|
|
495
|
-
formData.append('file', file);
|
|
496
|
-
_context9.next = 9;
|
|
497
|
-
return _Auth.default.uploadPhoto(formData);
|
|
498
|
-
case 9:
|
|
499
|
-
result = _context9.sent;
|
|
500
|
-
_this.setState({
|
|
501
|
-
avatar: "".concat(process.env.REACT_APP_PHOTO_API_URL, "/media/picture/view/").concat(user._id, "?ignore=").concat(Date.now())
|
|
502
|
-
});
|
|
503
|
-
resolve(result);
|
|
504
|
-
_context9.next = 18;
|
|
505
|
-
break;
|
|
506
|
-
case 14:
|
|
507
|
-
_context9.prev = 14;
|
|
508
|
-
_context9.t0 = _context9["catch"](0);
|
|
509
|
-
console.log("Error: ".concat(_context9.t0));
|
|
510
|
-
reject(_context9.t0);
|
|
511
|
-
case 18:
|
|
512
|
-
case "end":
|
|
513
|
-
return _context9.stop();
|
|
514
|
-
}
|
|
515
|
-
}, _callee9, null, [[0, 14]]);
|
|
516
|
-
}));
|
|
517
|
-
return function (_x12, _x13) {
|
|
518
|
-
return _ref9.apply(this, arguments);
|
|
519
|
-
};
|
|
520
|
-
}());
|
|
521
|
-
});
|
|
522
|
-
_defineProperty(_assertThisInitialized(_this), "deletePhoto", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
523
|
-
var user, formData;
|
|
524
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
525
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
526
|
-
case 0:
|
|
527
|
-
user = _this.state.user;
|
|
528
|
-
if (user) {
|
|
529
|
-
_context10.next = 3;
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
return _context10.abrupt("return");
|
|
533
|
-
case 3:
|
|
534
|
-
formData = new FormData();
|
|
535
|
-
formData.append('userId', user._id);
|
|
536
|
-
_context10.next = 7;
|
|
537
|
-
return _Auth.default.deletePhoto(formData);
|
|
538
|
-
case 7:
|
|
539
|
-
_this.setState({
|
|
540
|
-
avatar: undefined
|
|
541
|
-
});
|
|
542
|
-
case 8:
|
|
543
|
-
case "end":
|
|
544
|
-
return _context10.stop();
|
|
295
|
+
_defineProperty(this, "uploadPhoto", file => new Promise(async (resolve, reject) => {
|
|
296
|
+
try {
|
|
297
|
+
const {
|
|
298
|
+
user
|
|
299
|
+
} = this.state;
|
|
300
|
+
if (!user || !file) {
|
|
301
|
+
return;
|
|
545
302
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
303
|
+
const formData = new FormData();
|
|
304
|
+
formData.append('userId', user._id);
|
|
305
|
+
formData.append('file', file);
|
|
306
|
+
const result = await _Auth.default.uploadPhoto(formData);
|
|
307
|
+
this.setState({
|
|
308
|
+
avatar: "".concat(process.env.REACT_APP_PHOTO_API_URL, "/media/picture/view/").concat(user._id, "?ignore=").concat(Date.now())
|
|
309
|
+
});
|
|
310
|
+
resolve(result);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
console.log("Error: ".concat(error));
|
|
313
|
+
reject(error);
|
|
314
|
+
}
|
|
315
|
+
}));
|
|
316
|
+
_defineProperty(this, "deletePhoto", async () => {
|
|
317
|
+
const {
|
|
318
|
+
user
|
|
319
|
+
} = this.state;
|
|
320
|
+
if (!user) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const formData = new FormData();
|
|
324
|
+
formData.append('userId', user._id);
|
|
325
|
+
await _Auth.default.deletePhoto(formData);
|
|
326
|
+
this.setState({
|
|
327
|
+
avatar: undefined
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
_defineProperty(this, "replaceLocationPathName", () => {
|
|
331
|
+
const {
|
|
332
|
+
pathname
|
|
333
|
+
} = this.props.location;
|
|
550
334
|
if (pathname === '/login' || pathname === '/signup') {
|
|
551
|
-
|
|
335
|
+
this.props.navigate('/');
|
|
552
336
|
}
|
|
553
337
|
});
|
|
554
|
-
_defineProperty(
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
user = _yield$Auth$updateUse.user;
|
|
566
|
-
firebaseUser = _this.state.firebaseUser;
|
|
567
|
-
if (firebaseUser) {
|
|
568
|
-
_context11.next = 14;
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
_context11.next = 9;
|
|
572
|
-
return (0, _fetchData.default)('auth/get-custom-token');
|
|
573
|
-
case 9:
|
|
574
|
-
_yield$fetchData2 = _context11.sent;
|
|
575
|
-
customToken = _yield$fetchData2.customToken;
|
|
576
|
-
_context11.next = 13;
|
|
577
|
-
return _Auth.default.signInWithToken(customToken);
|
|
578
|
-
case 13:
|
|
579
|
-
firebaseUser = _context11.sent;
|
|
580
|
-
case 14:
|
|
581
|
-
//merge firebaseUser and our user object
|
|
582
|
-
newUser = _this.patchUserObject(user, firebaseUser);
|
|
583
|
-
_this.setUser(newUser);
|
|
584
|
-
return _context11.abrupt("return", user);
|
|
585
|
-
case 19:
|
|
586
|
-
_context11.prev = 19;
|
|
587
|
-
_context11.t0 = _context11["catch"](0);
|
|
588
|
-
console.log("Error updating the user: ".concat(_context11.t0));
|
|
589
|
-
throw _context11.t0;
|
|
590
|
-
case 23:
|
|
591
|
-
case "end":
|
|
592
|
-
return _context11.stop();
|
|
593
|
-
}
|
|
594
|
-
}, _callee11, null, [[0, 19]]);
|
|
595
|
-
}));
|
|
596
|
-
return function (_x14) {
|
|
597
|
-
return _ref11.apply(this, arguments);
|
|
598
|
-
};
|
|
599
|
-
}());
|
|
600
|
-
_defineProperty(_assertThisInitialized(_this), "checkIfPrivateInvestor", /*#__PURE__*/function () {
|
|
601
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(project) {
|
|
602
|
-
var user,
|
|
603
|
-
returnData,
|
|
604
|
-
dataToSend,
|
|
605
|
-
isPrivateInvestor,
|
|
606
|
-
userCopy,
|
|
607
|
-
_args12 = arguments;
|
|
608
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
609
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
610
|
-
case 0:
|
|
611
|
-
user = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : _this.state.user;
|
|
612
|
-
returnData = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : false;
|
|
613
|
-
if (!(!user || !project)) {
|
|
614
|
-
_context12.next = 4;
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
return _context12.abrupt("return");
|
|
618
|
-
case 4:
|
|
619
|
-
_context12.prev = 4;
|
|
620
|
-
dataToSend = {
|
|
621
|
-
userId: user._id,
|
|
622
|
-
projectId: project._id
|
|
623
|
-
};
|
|
624
|
-
_context12.next = 8;
|
|
625
|
-
return _Auth.default.checkPrivateInvestor(dataToSend);
|
|
626
|
-
case 8:
|
|
627
|
-
isPrivateInvestor = _context12.sent;
|
|
628
|
-
userCopy = _objectSpread({}, user);
|
|
629
|
-
userCopy.isPrivateInvestor = isPrivateInvestor.isAllowed;
|
|
630
|
-
userCopy.privateInvestorStatus = isPrivateInvestor.status;
|
|
631
|
-
if (!returnData) {
|
|
632
|
-
_context12.next = 16;
|
|
633
|
-
break;
|
|
634
|
-
}
|
|
635
|
-
return _context12.abrupt("return", userCopy);
|
|
636
|
-
case 16:
|
|
637
|
-
_this.setState({
|
|
638
|
-
user: userCopy
|
|
639
|
-
});
|
|
640
|
-
case 17:
|
|
641
|
-
_context12.next = 23;
|
|
642
|
-
break;
|
|
643
|
-
case 19:
|
|
644
|
-
_context12.prev = 19;
|
|
645
|
-
_context12.t0 = _context12["catch"](4);
|
|
646
|
-
console.log('🚀 ~ error in checkPrivateInvestor', _context12.t0);
|
|
647
|
-
throw _context12.t0;
|
|
648
|
-
case 23:
|
|
649
|
-
case "end":
|
|
650
|
-
return _context12.stop();
|
|
651
|
-
}
|
|
652
|
-
}, _callee12, null, [[4, 19]]);
|
|
653
|
-
}));
|
|
654
|
-
return function (_x15) {
|
|
655
|
-
return _ref12.apply(this, arguments);
|
|
656
|
-
};
|
|
657
|
-
}());
|
|
658
|
-
_defineProperty(_assertThisInitialized(_this), "checkPrivateInvestorAll", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
659
|
-
var user,
|
|
660
|
-
returnData,
|
|
661
|
-
_yield$Auth$checkPriv,
|
|
662
|
-
list,
|
|
663
|
-
userCopy,
|
|
664
|
-
_args13 = arguments;
|
|
665
|
-
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
666
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
667
|
-
case 0:
|
|
668
|
-
user = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : _this.state.user;
|
|
669
|
-
returnData = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : false;
|
|
670
|
-
_context13.prev = 2;
|
|
671
|
-
_context13.next = 5;
|
|
672
|
-
return _Auth.default.checkPrivateInvestor();
|
|
673
|
-
case 5:
|
|
674
|
-
_yield$Auth$checkPriv = _context13.sent;
|
|
675
|
-
list = _yield$Auth$checkPriv.list;
|
|
676
|
-
if (!list) {
|
|
677
|
-
_context13.next = 15;
|
|
678
|
-
break;
|
|
679
|
-
}
|
|
680
|
-
userCopy = _objectSpread({}, user);
|
|
681
|
-
userCopy.privateInvestorProjects = list;
|
|
682
|
-
if (!returnData) {
|
|
683
|
-
_context13.next = 14;
|
|
684
|
-
break;
|
|
685
|
-
}
|
|
686
|
-
return _context13.abrupt("return", userCopy);
|
|
687
|
-
case 14:
|
|
688
|
-
_this.setState({
|
|
689
|
-
user: userCopy
|
|
690
|
-
});
|
|
691
|
-
case 15:
|
|
692
|
-
_context13.next = 21;
|
|
693
|
-
break;
|
|
694
|
-
case 17:
|
|
695
|
-
_context13.prev = 17;
|
|
696
|
-
_context13.t0 = _context13["catch"](2);
|
|
697
|
-
console.log('🚀 ~ error in checkPrivateInvestorAll', _context13.t0);
|
|
698
|
-
throw _context13.t0;
|
|
699
|
-
case 21:
|
|
700
|
-
case "end":
|
|
701
|
-
return _context13.stop();
|
|
338
|
+
_defineProperty(this, "updateUser", async data => {
|
|
339
|
+
try {
|
|
340
|
+
const {
|
|
341
|
+
user
|
|
342
|
+
} = await _Auth.default.updateUser(data);
|
|
343
|
+
let firebaseUser = this.state.firebaseUser;
|
|
344
|
+
if (!firebaseUser) {
|
|
345
|
+
const {
|
|
346
|
+
customToken
|
|
347
|
+
} = await (0, _fetchData.default)('auth/get-custom-token');
|
|
348
|
+
firebaseUser = await _Auth.default.signInWithToken(customToken);
|
|
702
349
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
case "end":
|
|
754
|
-
return _context14.stop();
|
|
755
|
-
}
|
|
756
|
-
}, _callee14, null, [[4, 18]]);
|
|
757
|
-
}));
|
|
758
|
-
return function (_x16) {
|
|
759
|
-
return _ref14.apply(this, arguments);
|
|
760
|
-
};
|
|
761
|
-
}());
|
|
762
|
-
_defineProperty(_assertThisInitialized(_this), "checkIfUserSubscribedAll", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
763
|
-
var user,
|
|
764
|
-
returnData,
|
|
765
|
-
dataToSend,
|
|
766
|
-
result,
|
|
767
|
-
userCopy,
|
|
768
|
-
_args15 = arguments;
|
|
769
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
770
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
771
|
-
case 0:
|
|
772
|
-
user = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : _this.state.user;
|
|
773
|
-
returnData = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : false;
|
|
774
|
-
if (user) {
|
|
775
|
-
_context15.next = 4;
|
|
776
|
-
break;
|
|
777
|
-
}
|
|
778
|
-
return _context15.abrupt("return");
|
|
779
|
-
case 4:
|
|
780
|
-
_context15.prev = 4;
|
|
781
|
-
dataToSend = {
|
|
782
|
-
email: user.email
|
|
783
|
-
};
|
|
784
|
-
_context15.next = 8;
|
|
785
|
-
return _Auth.default.checkIfUserSubscribed(dataToSend);
|
|
786
|
-
case 8:
|
|
787
|
-
result = _context15.sent;
|
|
788
|
-
userCopy = _objectSpread({}, user);
|
|
789
|
-
userCopy.subscribedProjects = result;
|
|
790
|
-
if (!returnData) {
|
|
791
|
-
_context15.next = 15;
|
|
792
|
-
break;
|
|
793
|
-
}
|
|
794
|
-
return _context15.abrupt("return", userCopy);
|
|
795
|
-
case 15:
|
|
350
|
+
|
|
351
|
+
//merge firebaseUser and our user object
|
|
352
|
+
const newUser = this.patchUserObject(user, firebaseUser);
|
|
353
|
+
this.setUser(newUser);
|
|
354
|
+
return user;
|
|
355
|
+
} catch (error) {
|
|
356
|
+
console.log("Error updating the user: ".concat(error));
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
_defineProperty(this, "checkIfPrivateInvestor", async function (project) {
|
|
361
|
+
let user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.state.user;
|
|
362
|
+
let returnData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
363
|
+
if (!user || !project) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
try {
|
|
367
|
+
let dataToSend = {
|
|
368
|
+
userId: user._id,
|
|
369
|
+
projectId: project._id
|
|
370
|
+
};
|
|
371
|
+
const isPrivateInvestor = await _Auth.default.checkPrivateInvestor(dataToSend);
|
|
372
|
+
const userCopy = _objectSpread({}, user);
|
|
373
|
+
userCopy.isPrivateInvestor = isPrivateInvestor.isAllowed;
|
|
374
|
+
userCopy.privateInvestorStatus = isPrivateInvestor.status;
|
|
375
|
+
if (returnData) {
|
|
376
|
+
return userCopy;
|
|
377
|
+
} else {
|
|
378
|
+
_this.setState({
|
|
379
|
+
user: userCopy
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
} catch (error) {
|
|
383
|
+
console.log('🚀 ~ error in checkPrivateInvestor', error);
|
|
384
|
+
throw error;
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
_defineProperty(this, "checkPrivateInvestorAll", async function () {
|
|
388
|
+
let user = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.user;
|
|
389
|
+
let returnData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
390
|
+
try {
|
|
391
|
+
const {
|
|
392
|
+
list
|
|
393
|
+
} = await _Auth.default.checkPrivateInvestor();
|
|
394
|
+
if (list) {
|
|
395
|
+
const userCopy = _objectSpread({}, user);
|
|
396
|
+
userCopy.privateInvestorProjects = list;
|
|
397
|
+
if (returnData) {
|
|
398
|
+
return userCopy;
|
|
399
|
+
} else {
|
|
796
400
|
_this.setState({
|
|
797
401
|
user: userCopy
|
|
798
402
|
});
|
|
799
|
-
|
|
800
|
-
_context15.next = 22;
|
|
801
|
-
break;
|
|
802
|
-
case 18:
|
|
803
|
-
_context15.prev = 18;
|
|
804
|
-
_context15.t0 = _context15["catch"](4);
|
|
805
|
-
console.log('🚀 ~ error in checkIfUserSubscribed', _context15.t0);
|
|
806
|
-
throw _context15.t0;
|
|
807
|
-
case 22:
|
|
808
|
-
case "end":
|
|
809
|
-
return _context15.stop();
|
|
403
|
+
}
|
|
810
404
|
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
405
|
+
} catch (error) {
|
|
406
|
+
console.log('🚀 ~ error in checkPrivateInvestorAll', error);
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
_defineProperty(this, "checkIfUserSubscribed", async function (project) {
|
|
411
|
+
let user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.state.user;
|
|
412
|
+
let returnData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
413
|
+
if (!user || !project) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
let dataToSend = {
|
|
418
|
+
listName: project.name,
|
|
419
|
+
email: user.email
|
|
420
|
+
};
|
|
421
|
+
const isSubscribed = await _Auth.default.checkIfUserSubscribed(dataToSend);
|
|
422
|
+
const userCopy = _objectSpread({}, user);
|
|
423
|
+
userCopy.isSubscribed = isSubscribed;
|
|
424
|
+
if (returnData) {
|
|
425
|
+
return userCopy;
|
|
426
|
+
} else {
|
|
427
|
+
_this.setState({
|
|
428
|
+
user: userCopy
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
} catch (error) {
|
|
432
|
+
console.log('🚀 ~ error in checkIfUserSubscribed', error);
|
|
433
|
+
throw error;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
_defineProperty(this, "checkIfUserSubscribedAll", async function () {
|
|
437
|
+
let user = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.user;
|
|
438
|
+
let returnData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
439
|
+
if (!user) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
try {
|
|
443
|
+
let dataToSend = {
|
|
444
|
+
email: user.email
|
|
445
|
+
};
|
|
446
|
+
const result = await _Auth.default.checkIfUserSubscribed(dataToSend);
|
|
447
|
+
const userCopy = _objectSpread({}, user);
|
|
448
|
+
userCopy.subscribedProjects = result;
|
|
449
|
+
if (returnData) {
|
|
450
|
+
return userCopy;
|
|
451
|
+
} else {
|
|
452
|
+
_this.setState({
|
|
453
|
+
user: userCopy
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
} catch (error) {
|
|
457
|
+
console.log('🚀 ~ error in checkIfUserSubscribed', error);
|
|
458
|
+
throw error;
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
_defineProperty(this, "handleVerifyEmail", async () => {
|
|
462
|
+
this.setState({
|
|
463
|
+
isVerifyingEmail: true
|
|
464
|
+
});
|
|
465
|
+
const {
|
|
466
|
+
location
|
|
467
|
+
} = this.props;
|
|
468
|
+
const query = new URLSearchParams(location.search);
|
|
469
|
+
try {
|
|
470
|
+
let oobCode = query.get('oobCode');
|
|
471
|
+
await _Auth.default.handleVerifyEmail(oobCode);
|
|
472
|
+
this.setState({
|
|
473
|
+
isVerifyingEmail: false
|
|
474
|
+
});
|
|
475
|
+
let customToken = query.get('customtoken');
|
|
476
|
+
if (customToken) {
|
|
477
|
+
this.loginUser(null, null, customToken);
|
|
478
|
+
}
|
|
479
|
+
} catch (error) {
|
|
480
|
+
switch (error === null || error === void 0 ? void 0 : error.code) {
|
|
481
|
+
case 'auth/expired-action-code':
|
|
482
|
+
error.message = 'The activation link has expired. We are sending you a new one right now.';
|
|
483
|
+
let email = query.get('email');
|
|
846
484
|
if (email) {
|
|
847
|
-
|
|
485
|
+
error.email = email;
|
|
848
486
|
//Auth.resendActivationEmail(email)
|
|
849
487
|
}
|
|
850
|
-
|
|
851
|
-
case
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
case
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
case 26:
|
|
860
|
-
console.log('🚀 ~ file: AuthContext.js:446 ~ error:', _context16.t0);
|
|
861
|
-
_this.setState({
|
|
862
|
-
verifyEmailError: _context16.t0,
|
|
863
|
-
isVerifyingEmail: false,
|
|
864
|
-
isFetchingUser: false
|
|
865
|
-
});
|
|
866
|
-
//throw error
|
|
867
|
-
case 28:
|
|
868
|
-
case "end":
|
|
869
|
-
return _context16.stop();
|
|
488
|
+
break;
|
|
489
|
+
case 'auth/invalid-action-code':
|
|
490
|
+
error.message = 'This link is invalid. Please try verifying email again.';
|
|
491
|
+
break;
|
|
492
|
+
case 'auth/user-disabled':
|
|
493
|
+
error.message = 'Your account has been disabled. Please contact our support.';
|
|
494
|
+
break;
|
|
495
|
+
default:
|
|
496
|
+
break;
|
|
870
497
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
case 17:
|
|
901
|
-
_context17.t0.message = 'Your account has been disabled. Please contact our support.';
|
|
902
|
-
return _context17.abrupt("break", 20);
|
|
903
|
-
case 19:
|
|
904
|
-
return _context17.abrupt("break", 20);
|
|
905
|
-
case 20:
|
|
906
|
-
throw _context17.t0;
|
|
907
|
-
case 21:
|
|
908
|
-
case "end":
|
|
909
|
-
return _context17.stop();
|
|
910
|
-
}
|
|
911
|
-
}, _callee17, null, [[1, 8]]);
|
|
912
|
-
}));
|
|
913
|
-
return function (_x17) {
|
|
914
|
-
return _ref17.apply(this, arguments);
|
|
915
|
-
};
|
|
916
|
-
}());
|
|
917
|
-
_defineProperty(_assertThisInitialized(_this), "sendWelcomeEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
918
|
-
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
919
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
920
|
-
case 0:
|
|
921
|
-
_context18.prev = 0;
|
|
922
|
-
_context18.next = 3;
|
|
923
|
-
return _Auth.default.sendWelcomeEmail();
|
|
924
|
-
case 3:
|
|
925
|
-
_context18.next = 8;
|
|
498
|
+
console.log('🚀 ~ file: AuthContext.js:446 ~ error:', error);
|
|
499
|
+
this.setState({
|
|
500
|
+
verifyEmailError: error,
|
|
501
|
+
isVerifyingEmail: false,
|
|
502
|
+
isFetchingUser: false
|
|
503
|
+
});
|
|
504
|
+
//throw error
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
_defineProperty(this, "handleResetPassword", async password => {
|
|
508
|
+
const {
|
|
509
|
+
location
|
|
510
|
+
} = this.props;
|
|
511
|
+
try {
|
|
512
|
+
const query = new URLSearchParams(location.search);
|
|
513
|
+
let oobCode = query.get('oobCode');
|
|
514
|
+
await _Auth.default.handleResetPassword(oobCode, password);
|
|
515
|
+
} catch (error) {
|
|
516
|
+
switch (error === null || error === void 0 ? void 0 : error.code) {
|
|
517
|
+
case 'auth/expired-action-code':
|
|
518
|
+
error.message = 'This link has expired. Please try reseting password again.';
|
|
519
|
+
break;
|
|
520
|
+
case 'auth/invalid-action-code':
|
|
521
|
+
error.message = 'This link is invalid. Please try reseting password again.';
|
|
522
|
+
break;
|
|
523
|
+
case 'auth/user-disabled':
|
|
524
|
+
error.message = 'Your account has been disabled. Please contact our support.';
|
|
525
|
+
break;
|
|
526
|
+
default:
|
|
926
527
|
break;
|
|
927
|
-
case 5:
|
|
928
|
-
_context18.prev = 5;
|
|
929
|
-
_context18.t0 = _context18["catch"](0);
|
|
930
|
-
console.log("Error sending welcome email: ".concat(_context18.t0));
|
|
931
|
-
// No need to throw error, let the app continue even if it fails
|
|
932
|
-
case 8:
|
|
933
|
-
case "end":
|
|
934
|
-
return _context18.stop();
|
|
935
528
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
return _Auth.default.validateGreenWalletId(id);
|
|
975
|
-
case 3:
|
|
976
|
-
return _context20.abrupt("return", _context20.sent);
|
|
977
|
-
case 6:
|
|
978
|
-
_context20.prev = 6;
|
|
979
|
-
_context20.t0 = _context20["catch"](0);
|
|
980
|
-
console.log("Error validating Green Wallet ID: ".concat(_context20.t0));
|
|
981
|
-
throw _context20.t0;
|
|
982
|
-
case 10:
|
|
983
|
-
case "end":
|
|
984
|
-
return _context20.stop();
|
|
985
|
-
}
|
|
986
|
-
}, _callee20, null, [[0, 6]]);
|
|
987
|
-
}));
|
|
988
|
-
return function (_x20) {
|
|
989
|
-
return _ref20.apply(this, arguments);
|
|
990
|
-
};
|
|
991
|
-
}());
|
|
992
|
-
_defineProperty(_assertThisInitialized(_this), "createWallet", /*#__PURE__*/function () {
|
|
993
|
-
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(data) {
|
|
994
|
-
var wallet;
|
|
995
|
-
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
996
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
997
|
-
case 0:
|
|
998
|
-
_context21.prev = 0;
|
|
999
|
-
_context21.next = 3;
|
|
1000
|
-
return _Auth.default.createWallet(data);
|
|
1001
|
-
case 3:
|
|
1002
|
-
wallet = _context21.sent;
|
|
1003
|
-
return _context21.abrupt("return", wallet);
|
|
1004
|
-
case 7:
|
|
1005
|
-
_context21.prev = 7;
|
|
1006
|
-
_context21.t0 = _context21["catch"](0);
|
|
1007
|
-
console.log("Error creating wallet: ".concat(_context21.t0));
|
|
1008
|
-
throw _context21.t0;
|
|
1009
|
-
case 11:
|
|
1010
|
-
case "end":
|
|
1011
|
-
return _context21.stop();
|
|
1012
|
-
}
|
|
1013
|
-
}, _callee21, null, [[0, 7]]);
|
|
1014
|
-
}));
|
|
1015
|
-
return function (_x21) {
|
|
1016
|
-
return _ref21.apply(this, arguments);
|
|
1017
|
-
};
|
|
1018
|
-
}());
|
|
1019
|
-
_defineProperty(_assertThisInitialized(_this), "setUser", function (user) {
|
|
529
|
+
throw error;
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
_defineProperty(this, "sendWelcomeEmail", async () => {
|
|
533
|
+
try {
|
|
534
|
+
await _Auth.default.sendWelcomeEmail();
|
|
535
|
+
} catch (error) {
|
|
536
|
+
console.log("Error sending welcome email: ".concat(error));
|
|
537
|
+
// No need to throw error, let the app continue even if it fails
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
_defineProperty(this, "uploaProofOfAddress", async (data, ip) => {
|
|
541
|
+
try {
|
|
542
|
+
const user = await _Auth.default.uploaProofOfAddress(data, ip);
|
|
543
|
+
this.setUser(user);
|
|
544
|
+
} catch (error) {
|
|
545
|
+
console.log("Error uploading proof of address: ".concat(error));
|
|
546
|
+
throw error;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
_defineProperty(this, "validateGreenWalletId", async id => {
|
|
550
|
+
try {
|
|
551
|
+
return await _Auth.default.validateGreenWalletId(id);
|
|
552
|
+
} catch (error) {
|
|
553
|
+
console.log("Error validating Green Wallet ID: ".concat(error));
|
|
554
|
+
throw error;
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
_defineProperty(this, "createWallet", async data => {
|
|
558
|
+
try {
|
|
559
|
+
const wallet = await _Auth.default.createWallet(data);
|
|
560
|
+
return wallet;
|
|
561
|
+
} catch (error) {
|
|
562
|
+
console.log("Error creating wallet: ".concat(error));
|
|
563
|
+
throw error;
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
_defineProperty(this, "setUser", user => {
|
|
1020
567
|
//there are a few cases where we need user object in event handlers (that don't have access to updated state)
|
|
1021
568
|
//that's why we store it in a ref
|
|
1022
|
-
|
|
1023
|
-
|
|
569
|
+
this.userRef.current = user;
|
|
570
|
+
this.setState({
|
|
1024
571
|
user: user
|
|
1025
572
|
});
|
|
1026
573
|
});
|
|
1027
|
-
_defineProperty(
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
return _Auth.default.fetchTrackingUserLastTime({
|
|
1043
|
-
filter: filterBody
|
|
1044
|
-
});
|
|
1045
|
-
case 5:
|
|
1046
|
-
response = _context22.sent;
|
|
1047
|
-
return _context22.abrupt("return", response);
|
|
1048
|
-
case 9:
|
|
1049
|
-
_context22.prev = 9;
|
|
1050
|
-
_context22.t0 = _context22["catch"](0);
|
|
1051
|
-
console.log(' error', _context22.t0);
|
|
1052
|
-
case 12:
|
|
1053
|
-
case "end":
|
|
1054
|
-
return _context22.stop();
|
|
1055
|
-
}
|
|
1056
|
-
}, _callee22, null, [[0, 9]]);
|
|
1057
|
-
}));
|
|
1058
|
-
return function (_x22, _x23, _x24) {
|
|
1059
|
-
return _ref22.apply(this, arguments);
|
|
1060
|
-
};
|
|
1061
|
-
}());
|
|
1062
|
-
return _this;
|
|
1063
|
-
}
|
|
1064
|
-
_createClass(AuthProviderClass, [{
|
|
1065
|
-
key: "componentDidMount",
|
|
1066
|
-
value: function componentDidMount() {
|
|
1067
|
-
var isActivatingUser = window.location.href.includes('verifyEmail');
|
|
1068
|
-
if (isActivatingUser) {
|
|
1069
|
-
this.handleVerifyEmail();
|
|
1070
|
-
} else if (this.state.isFetchingUser === false) {
|
|
1071
|
-
//only call getUser if we are not already calling it from another component
|
|
1072
|
-
this.getUser();
|
|
574
|
+
_defineProperty(this, "fetchLastTime", async (projectName, page, userId) => {
|
|
575
|
+
try {
|
|
576
|
+
let filterBody = {
|
|
577
|
+
projectName: projectName,
|
|
578
|
+
page: page
|
|
579
|
+
};
|
|
580
|
+
if (userId) {
|
|
581
|
+
filterBody.userId = userId;
|
|
582
|
+
}
|
|
583
|
+
let response = await _Auth.default.fetchTrackingUserLastTime({
|
|
584
|
+
filter: filterBody
|
|
585
|
+
});
|
|
586
|
+
return response;
|
|
587
|
+
} catch (error) {
|
|
588
|
+
console.log(' error', error);
|
|
1073
589
|
}
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
componentDidMount() {
|
|
593
|
+
const isActivatingUser = window.location.href.includes('verifyEmail');
|
|
594
|
+
if (isActivatingUser) {
|
|
595
|
+
this.handleVerifyEmail();
|
|
596
|
+
} else if (this.state.isFetchingUser === false) {
|
|
597
|
+
//only call getUser if we are not already calling it from another component
|
|
598
|
+
this.getUser();
|
|
1074
599
|
}
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
}(_react.Component);
|
|
600
|
+
}
|
|
601
|
+
render() {
|
|
602
|
+
const {
|
|
603
|
+
children
|
|
604
|
+
} = this.props;
|
|
605
|
+
return /*#__PURE__*/_react.default.createElement(AuthContext.Provider, {
|
|
606
|
+
value: _objectSpread(_objectSpread({}, this.state), {}, {
|
|
607
|
+
userRef: this.userRef,
|
|
608
|
+
checkUserIsValid: this.checkUserIsValid,
|
|
609
|
+
checkTokenIsValid: this.checkTokenIsValid,
|
|
610
|
+
checkUserPhoto: this.checkUserPhoto,
|
|
611
|
+
uploadPhoto: this.uploadPhoto,
|
|
612
|
+
deletePhoto: this.deletePhoto,
|
|
613
|
+
unenrollUser2FA: this.unenrollUser2FA,
|
|
614
|
+
loginUserWithTotp: this.loginUserWithTotp,
|
|
615
|
+
checkMfaEnrollment: this.checkMfaEnrollment,
|
|
616
|
+
generateTotpSecret: this.generateTotpSecret,
|
|
617
|
+
enrollUserToTotp: this.enrollUserToTotp,
|
|
618
|
+
loginUser: this.loginUser,
|
|
619
|
+
logoutUser: this.logoutUser,
|
|
620
|
+
getUser: this.getUser,
|
|
621
|
+
updateUser: this.updateUser,
|
|
622
|
+
checkIfPrivateInvestor: this.checkIfPrivateInvestor,
|
|
623
|
+
checkPrivateInvestorAll: this.checkPrivateInvestorAll,
|
|
624
|
+
checkIfUserSubscribed: this.checkIfUserSubscribed,
|
|
625
|
+
checkIfUserSubscribedAll: this.checkIfUserSubscribedAll,
|
|
626
|
+
sendWelcomeEmail: this.sendWelcomeEmail,
|
|
627
|
+
resendActivationEmail: _Auth.default.resendActivationEmail,
|
|
628
|
+
uploaProofOfAddress: this.uploaProofOfAddress,
|
|
629
|
+
validateGreenWalletId: this.validateGreenWalletId,
|
|
630
|
+
fetchLastTime: this.fetchLastTime,
|
|
631
|
+
createWallet: this.createWallet,
|
|
632
|
+
requestUpdateEmail: _Auth.default.requestUpdateEmail,
|
|
633
|
+
updatePassword: _Auth.default.updateUserPassword,
|
|
634
|
+
createUser: this.createUser,
|
|
635
|
+
updateFirebaseUser: _Auth.default.updateFirebaseUser,
|
|
636
|
+
handleResetPassword: this.handleResetPassword,
|
|
637
|
+
handleVerifyEmail: this.handleVerifyEmail,
|
|
638
|
+
setUser: this.setUser,
|
|
639
|
+
refreshIdToken: _Auth.default.refreshIdToken
|
|
640
|
+
})
|
|
641
|
+
}, children);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
1120
644
|
AuthProviderClass.propTypes = {
|
|
1121
645
|
children: _propTypes.default.node.isRequired
|
|
1122
646
|
};
|
|
1123
|
-
|
|
1124
|
-
exports.
|
|
1125
|
-
|
|
1126
|
-
//export default AuthProvider
|
|
1127
|
-
exports.AuthProvider = AuthProvider;
|
|
647
|
+
const AuthConsumer = exports.AuthConsumer = AuthContext.Consumer;
|
|
648
|
+
const AuthProvider = exports.AuthProvider = (0, _withRouter.withRouter)(AuthProviderClass);
|
|
649
|
+
//export default AuthProvider
|