@getpara/react-sdk 1.2.0 → 1.3.0
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/MoonPayEmbed-GAWXP6V7.js +2 -0
- package/dist/MoonPayEmbed-GAWXP6V7.js.br +0 -0
- package/dist/MoonPayEmbed-GAWXP6V7.js.gz +0 -0
- package/dist/index.js +675 -5
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/package.json +8 -7
- package/dist/modal/ParaModal.js +0 -281
- package/dist/modal/components/Account/Account.js +0 -60
- package/dist/modal/components/AddFunds/AddFunds.js +0 -147
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
- package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
- package/dist/modal/components/AddFunds/index.js +0 -3
- package/dist/modal/components/AuthInput/AuthInput.js +0 -221
- package/dist/modal/components/AuthInput/countryCodes.js +0 -40
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
- package/dist/modal/components/Body/Body.js +0 -232
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
- package/dist/modal/components/ChainSwitch/config.js +0 -11
- package/dist/modal/components/Controls/Controls.js +0 -54
- package/dist/modal/components/Controls/Selects.js +0 -159
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
- package/dist/modal/components/ExternalWalletStep/config.js +0 -11
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
- package/dist/modal/components/Footer/Footer.js +0 -71
- package/dist/modal/components/Header/Header.js +0 -24
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
- package/dist/modal/components/Hero/Hero.js +0 -119
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
- package/dist/modal/components/ModalContent/ModalContent.js +0 -282
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
- package/dist/modal/components/OAuth/OAuth.js +0 -125
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
- package/dist/modal/components/Waiting/Waiting.js +0 -6
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
- package/dist/modal/components/WalletCard/WalletCard.js +0 -93
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
- package/dist/modal/components/common.js +0 -67
- package/dist/modal/components/index.js +0 -1
- package/dist/modal/constants/constants.js +0 -93
- package/dist/modal/constants/defaults.js +0 -5
- package/dist/modal/constants/oAuthLogos.js +0 -18
- package/dist/modal/hooks/useActiveWallet.js +0 -11
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
- package/dist/modal/hooks/useGoBack.js +0 -34
- package/dist/modal/index.js +0 -9
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
- package/dist/modal/providers/ExternalWalletContext.js +0 -253
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
- package/dist/modal/stores/index.js +0 -3
- package/dist/modal/stores/modal/actions.js +0 -64
- package/dist/modal/stores/modal/useModalStore.js +0 -41
- package/dist/modal/stores/para/actions.js +0 -5
- package/dist/modal/stores/para/useParaStore.js +0 -3
- package/dist/modal/stores/theme/actions.js +0 -24
- package/dist/modal/stores/theme/useThemeStore.js +0 -14
- package/dist/modal/stores/userInfo/actions.js +0 -34
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
- package/dist/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -21
- package/dist/modal/types/modalProps.js +0 -7
- package/dist/modal/utils/authLayoutHelpers.js +0 -2
- package/dist/modal/utils/getMailtoLink.js +0 -5
- package/dist/modal/utils/getTileButtonFlex.js +0 -15
- package/dist/modal/utils/isPasskeySupported.js +0 -10
- package/dist/modal/utils/openPopup.js +0 -55
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
- package/dist/modal/utils/steps.js +0 -215
- package/dist/modal/utils/stringFormatters.js +0 -12
- package/dist/modal/utils/validateOnRampConfig.js +0 -26
- package/dist/provider/ParaProvider.js +0 -17
- package/dist/provider/actions/checkIfUserExists.js +0 -26
- package/dist/provider/actions/createUser.js +0 -30
- package/dist/provider/actions/getAccount.js +0 -24
- package/dist/provider/actions/getWallet.js +0 -16
- package/dist/provider/actions/initiateLogin.js +0 -23
- package/dist/provider/actions/keepSessionAlive.js +0 -23
- package/dist/provider/actions/logout.js +0 -20
- package/dist/provider/actions/signMessage.js +0 -23
- package/dist/provider/actions/signTransaction.js +0 -23
- package/dist/provider/actions/waitForAccountCreation.js +0 -24
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
- package/dist/provider/hooks/index.js +0 -3
- package/dist/provider/hooks/mutations/index.js +0 -10
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
- package/dist/provider/hooks/mutations/useLogout.js +0 -33
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- package/dist/provider/hooks/queries/index.js +0 -2
- package/dist/provider/hooks/queries/useAccount.js +0 -23
- package/dist/provider/hooks/queries/useWallet.js +0 -24
- package/dist/provider/hooks/utils/index.js +0 -3
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
- package/dist/provider/hooks/utils/useClient.js +0 -8
- package/dist/provider/hooks/utils/useEventListeners.js +0 -87
- package/dist/provider/hooks/utils/useInternalClient.js +0 -9
- package/dist/provider/hooks/utils/useModal.js +0 -15
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -3
- package/dist/provider/stores/getters.js +0 -5
- package/dist/provider/stores/slices/client.js +0 -4
- package/dist/provider/stores/slices/index.js +0 -3
- package/dist/provider/stores/slices/modal.js +0 -4
- package/dist/provider/stores/slices/wallet.js +0 -6
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -14
- package/dist/provider/types/provider.js +0 -1
- package/dist/provider/types/query.js +0 -1
- package/dist/provider/types/utils.js +0 -1
- package/dist/provider/utils/renameMutations.js +0 -19
- /package/dist/{modal/css → css}/modal.css +0 -0
- /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { useModalStore } from '../../../stores/modal/useModalStore.js';
|
|
3
|
-
import { ModalStep } from '../../../utils/steps.js';
|
|
4
|
-
import { useExternalWallets } from '../../../providers/ExternalWalletContext.js';
|
|
5
|
-
import { useThemeStore } from '../../../stores/index.js';
|
|
6
|
-
export const useStepTitle = () => {
|
|
7
|
-
const hideWallets = useThemeStore(state => state.hideWallets);
|
|
8
|
-
const isLogin = useModalStore(state => state.isLogin());
|
|
9
|
-
const currentStep = useModalStore(state => state.step);
|
|
10
|
-
const { chainId } = useExternalWallets();
|
|
11
|
-
const titles = useMemo(() => ({
|
|
12
|
-
[ModalStep.AUTH_MAIN]: '',
|
|
13
|
-
[ModalStep.AUTH_MORE]: 'Sign Up or Log In',
|
|
14
|
-
[ModalStep.EX_WALLET_MORE]: 'Connect Wallet',
|
|
15
|
-
[ModalStep.VERIFICATIONS]: 'Sign Up',
|
|
16
|
-
[ModalStep.AWAITING_OAUTH]: isLogin ? 'Login' : 'Sign Up',
|
|
17
|
-
[ModalStep.FARCASTER_OAUTH]: isLogin ? 'Login' : 'Sign Up',
|
|
18
|
-
[ModalStep.BIOMETRIC_CREATION]: 'Sign Up',
|
|
19
|
-
[ModalStep.PASSWORD_CREATION]: 'Sign Up',
|
|
20
|
-
[ModalStep.AWAITING_BIOMETRIC_CREATION]: 'Sign Up',
|
|
21
|
-
[ModalStep.AWAITING_WALLET_CREATION]: isLogin ? 'Login' : 'Sign Up',
|
|
22
|
-
[ModalStep.AWAITING_PASSWORD_CREATION]: 'Sign Up',
|
|
23
|
-
[ModalStep.WALLET_CREATION_DONE]: hideWallets ? 'Account Created' : 'Wallet Created',
|
|
24
|
-
[ModalStep.SECRET]: isLogin ? 'Login' : 'Sign Up',
|
|
25
|
-
[ModalStep.BIOMETRIC_LOGIN]: 'Login',
|
|
26
|
-
[ModalStep.AWAITING_PASSWORD_LOGIN]: 'Login',
|
|
27
|
-
[ModalStep.AWAITING_BIOMETRIC_LOGIN]: 'Login',
|
|
28
|
-
[ModalStep.LOGIN_DONE]: '',
|
|
29
|
-
[ModalStep.SETUP_2FA]: '2FA',
|
|
30
|
-
[ModalStep.VERIFY_2FA]: '2FA',
|
|
31
|
-
[ModalStep.TWO_FACTOR_DONE]: '2FA',
|
|
32
|
-
[ModalStep.ADD_FUNDS_BUY]: '',
|
|
33
|
-
[ModalStep.ADD_FUNDS_RECEIVE]: '',
|
|
34
|
-
[ModalStep.ADD_FUNDS_WITHDRAW]: '',
|
|
35
|
-
[ModalStep.ADD_FUNDS_AWAITING]: '',
|
|
36
|
-
[ModalStep.ADD_FUNDS_SUCCESS]: '',
|
|
37
|
-
[ModalStep.ADD_FUNDS_FAILURE]: '',
|
|
38
|
-
[ModalStep.ACCOUNT_MAIN]: '',
|
|
39
|
-
[ModalStep.CHAIN_SWITCH]: '',
|
|
40
|
-
}), [isLogin, chainId, hideWallets]);
|
|
41
|
-
return { title: titles[currentStep] };
|
|
42
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { CpslHero, CpslIcon, CpslIdenticon } from '@getpara/react-components';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
5
|
-
import { useModalStore } from '../../stores/index.js';
|
|
6
|
-
import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
|
|
7
|
-
import { NETWORK_NOT_SUPPORTED_ERROR } from '../../constants/constants.js';
|
|
8
|
-
import { useEffect, useState } from 'react';
|
|
9
|
-
import { isMobile } from '@getpara/web-sdk';
|
|
10
|
-
import { useActiveWallet } from '../../hooks/useActiveWallet.js';
|
|
11
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
12
|
-
const getStepConfig = ({ externalWalletError, }) => {
|
|
13
|
-
var _a;
|
|
14
|
-
return ({
|
|
15
|
-
[ModalStep.EX_WALLET_SELECTED]: {
|
|
16
|
-
variant: 'externalWalletConnection',
|
|
17
|
-
topOffset: 40,
|
|
18
|
-
spacerHeight: 158,
|
|
19
|
-
hideFadeOut: true,
|
|
20
|
-
},
|
|
21
|
-
[ModalStep.CHAIN_SWITCH]: {
|
|
22
|
-
variant: ((_a = externalWalletError === null || externalWalletError === void 0 ? void 0 : externalWalletError[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === NETWORK_NOT_SUPPORTED_ERROR ? 'failed' : 'externalWalletConnection',
|
|
23
|
-
topOffset: 20,
|
|
24
|
-
spacerHeight: 158,
|
|
25
|
-
hideFadeOut: true,
|
|
26
|
-
},
|
|
27
|
-
[ModalStep.ACCOUNT_MAIN]: {
|
|
28
|
-
variant: 'customContent',
|
|
29
|
-
topOffset: 0,
|
|
30
|
-
spacerHeight: 104,
|
|
31
|
-
hideFadeOut: true,
|
|
32
|
-
},
|
|
33
|
-
[ModalStep.FARCASTER_OAUTH]: {
|
|
34
|
-
variant: 'externalWalletConnection',
|
|
35
|
-
topOffset: 40,
|
|
36
|
-
spacerHeight: 158,
|
|
37
|
-
hideFadeOut: true,
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
export const Hero = () => {
|
|
42
|
-
const para = useInternalClient();
|
|
43
|
-
const { wallet: connector, walletDisplayHelpers, avatar } = useExternalWallets();
|
|
44
|
-
const step = useModalStore(state => state.step);
|
|
45
|
-
const externalWalletError = useModalStore(state => state.externalWalletError);
|
|
46
|
-
const activeWallet = useActiveWallet();
|
|
47
|
-
const [currentStep, setCurrentStep] = useState(step);
|
|
48
|
-
const stepConfig = getStepConfig({
|
|
49
|
-
externalWalletError,
|
|
50
|
-
})[currentStep];
|
|
51
|
-
// Watching the step here to make the animation in/out of the hero look correct
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const prevStepConfig = getStepConfig({
|
|
54
|
-
externalWalletError,
|
|
55
|
-
})[currentStep];
|
|
56
|
-
const newStepConfig = getStepConfig({
|
|
57
|
-
externalWalletError,
|
|
58
|
-
})[step];
|
|
59
|
-
const delay = newStepConfig && prevStepConfig ? 0 : newStepConfig && !prevStepConfig ? 0 : 200;
|
|
60
|
-
setTimeout(() => {
|
|
61
|
-
setCurrentStep(step);
|
|
62
|
-
}, delay);
|
|
63
|
-
}, [step]);
|
|
64
|
-
const isExternalStep = currentStep === ModalStep.EX_WALLET_SELECTED;
|
|
65
|
-
const isChainSwitchStep = currentStep === ModalStep.CHAIN_SWITCH;
|
|
66
|
-
const isAccountStep = currentStep === ModalStep.ACCOUNT_MAIN;
|
|
67
|
-
const isFarcasterStep = currentStep === ModalStep.FARCASTER_OAUTH;
|
|
68
|
-
const { showExtension, isCosmosMobileWallet } = walletDisplayHelpers;
|
|
69
|
-
// Hide if:
|
|
70
|
-
// 1. On a step with no hero config
|
|
71
|
-
// 2. On the external wallet step and not showing the extension connection screen
|
|
72
|
-
// 3. On the network switch step on web for Cosmos mobile connectors
|
|
73
|
-
// 4. On the farcaster step on desktop
|
|
74
|
-
const shouldHide = !stepConfig ||
|
|
75
|
-
(!isMobile() && isExternalStep && !showExtension) ||
|
|
76
|
-
(!isMobile() && isChainSwitchStep && isCosmosMobileWallet) ||
|
|
77
|
-
(!isMobile() && isFarcasterStep);
|
|
78
|
-
const { variant, topOffset, spacerHeight, hideFadeOut } = stepConfig !== null && stepConfig !== void 0 ? stepConfig : {};
|
|
79
|
-
return (_jsxs(_Fragment, { children: [_jsx(Container, { "$top": -45 + topOffset, children: shouldHide ? null : (_jsxs(StyledHero, { "$isAccount": isAccountStep, hideFadeOut: hideFadeOut, variant: variant, height: 480, withDefaultTheme: true, children: [(isExternalStep || isChainSwitchStep) && _jsx(WalletLogo, { slot: "connectionLeft", src: connector === null || connector === void 0 ? void 0 : connector.iconUrl }), isFarcasterStep && _jsx(WalletLogo, { slot: "connectionLeft", icon: "farcasterBrand" }), isAccountStep &&
|
|
80
|
-
(avatar ? (_jsx(Avatar, { slot: "image", src: avatar })) : activeWallet ? (_jsx(IconAvatar, { slot: "image", size: "100%", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) })) : null)] })) }), !shouldHide && _jsx(Spacer, { "$height": spacerHeight })] }));
|
|
81
|
-
};
|
|
82
|
-
const Container = styled.div `
|
|
83
|
-
display: flex;
|
|
84
|
-
position: absolute;
|
|
85
|
-
justify-content: center;
|
|
86
|
-
align-items: center;
|
|
87
|
-
width: 100%;
|
|
88
|
-
|
|
89
|
-
top: ${({ $top }) => `${$top}px`};
|
|
90
|
-
`;
|
|
91
|
-
const Spacer = styled.div `
|
|
92
|
-
height: ${({ $height }) => `${$height}px`};
|
|
93
|
-
`;
|
|
94
|
-
const WalletLogo = styled(CpslIcon) `
|
|
95
|
-
--height: 60px;
|
|
96
|
-
--width: 60px;
|
|
97
|
-
`;
|
|
98
|
-
const Avatar = styled.img `
|
|
99
|
-
width: 100%;
|
|
100
|
-
height: 100%;
|
|
101
|
-
object-fit: contain;
|
|
102
|
-
`;
|
|
103
|
-
const IconAvatar = styled(CpslIdenticon) `
|
|
104
|
-
border-radius: 1000px;
|
|
105
|
-
`;
|
|
106
|
-
const StyledHero = styled(CpslHero) `
|
|
107
|
-
${({ $isAccount }) => $isAccount &&
|
|
108
|
-
`
|
|
109
|
-
--ring-3-size: 560px;
|
|
110
|
-
--ring-2-size: 402px;
|
|
111
|
-
--ring-1-size: 228px;
|
|
112
|
-
--ring-0-size: 104px;
|
|
113
|
-
|
|
114
|
-
--default-theme-ring-3-opacity: 0.02;
|
|
115
|
-
--default-theme-ring-2-opacity: 0.04;
|
|
116
|
-
--default-theme-ring-1-opacity: 0.06;
|
|
117
|
-
--default-theme-ring-0-opacity: 0.1;
|
|
118
|
-
`}
|
|
119
|
-
`;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useModalStore, useThemeStore } from '../../stores/index.js';
|
|
3
|
-
import { IFrameSteps } from '../../utils/steps.js';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { SpinnerContainer } from '@getpara/react-common';
|
|
6
|
-
import { CpslSpinner } from '@getpara/react-components';
|
|
7
|
-
import { MOBILE_SIZE } from '../../constants/constants.js';
|
|
8
|
-
export const IFrameStep = () => {
|
|
9
|
-
const iFrameUrl = useModalStore(state => state.iFrameUrl);
|
|
10
|
-
const setIsReady = useModalStore(state => state.setIsIFrameReady);
|
|
11
|
-
const isReady = useModalStore(state => state.isIFrameReady);
|
|
12
|
-
const currentStep = useModalStore(state => state.step);
|
|
13
|
-
const embeddedModal = useThemeStore(state => state.embeddedModal);
|
|
14
|
-
return (_jsxs(OuterContainer, { "$isVisible": IFrameSteps.includes(currentStep), "$embeddedModal": embeddedModal, children: [_jsx(Container, { "$isReady": isReady, children: _jsx("iframe", { src: iFrameUrl, onLoad: () => {
|
|
15
|
-
setIsReady(true);
|
|
16
|
-
} }) }), !isReady && (_jsx(SpinnerContainer, { style: { width: '100%', height: '100%', flex: 1 }, children: _jsx(CpslSpinner, { size: 100 }) }))] }));
|
|
17
|
-
};
|
|
18
|
-
const OuterContainer = styled.div `
|
|
19
|
-
height: ${({ $isVisible }) => ($isVisible ? '100%' : '0px')};
|
|
20
|
-
width: ${({ $isVisible }) => ($isVisible ? '100%' : '0px')};
|
|
21
|
-
flex: ${({ $isVisible }) => ($isVisible ? 1 : 'auto')};
|
|
22
|
-
padding: ${({ $embeddedModal, $isVisible }) => (!$isVisible ? '0px' : $embeddedModal ? '12px 0px 0px' : '72px 72px 32px')};
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
|
|
27
|
-
@media (max-width: ${MOBILE_SIZE}px) {
|
|
28
|
-
padding: ${({ $embeddedModal, $isVisible }) => !$isVisible ? '0px' : $embeddedModal ? '12px 0px 0px' : '72px 16px 0px'};
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
const Container = styled.div `
|
|
32
|
-
height: 100%;
|
|
33
|
-
width: 100%;
|
|
34
|
-
display: ${({ $isReady }) => ($isReady ? 'block' : 'none')};
|
|
35
|
-
|
|
36
|
-
& > iframe {
|
|
37
|
-
height: 360px;
|
|
38
|
-
width: 100%;
|
|
39
|
-
border: none;
|
|
40
|
-
}
|
|
41
|
-
`;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import { Heading, HeroIcon, StepContainer } from '../common.js';
|
|
4
|
-
import { ExternalWalletCard, WalletCard, WalletCards } from '../WalletCard/WalletCard.js';
|
|
5
|
-
import { useThemeStore } from '../../stores/index.js';
|
|
6
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
7
|
-
export const LoginDoneStep = ({ onClose }) => {
|
|
8
|
-
var _a;
|
|
9
|
-
const para = useInternalClient();
|
|
10
|
-
const hideWallets = useThemeStore(state => state.hideWallets);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
setTimeout(() => {
|
|
13
|
-
onClose();
|
|
14
|
-
}, 1600);
|
|
15
|
-
}, []);
|
|
16
|
-
return (_jsxs(StepContainer, { children: [_jsx(HeroIcon, { icon: "checkCircleFilled" }), _jsx(Heading, { variant: "headingS", weight: "bold", children: "Connected" }), !hideWallets && (_jsx(WalletCards, { children: para.isUsingExternalWallet() ? (_jsx(ExternalWalletCard, { address: (_a = para.currentExternalWalletAddresses) === null || _a === void 0 ? void 0 : _a[0] })) : (para.currentWalletIdsArray.map(([id, type]) => {
|
|
17
|
-
return _jsx(WalletCard, { id: id, type: type }, `${id}-${type}`);
|
|
18
|
-
})) }))] }));
|
|
19
|
-
};
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
12
|
-
import { entityToWallet, OnRampProvider, OnRampAsset, Network, EnabledFlow, } from '@getpara/web-sdk';
|
|
13
|
-
import { useModalStore, useUserInfoStore } from '../../stores/index.js';
|
|
14
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
15
|
-
import { Body } from '../Body/Body.js';
|
|
16
|
-
import { Footer } from '../Footer/Footer.js';
|
|
17
|
-
import { DEFAULTS } from '../../constants/defaults.js';
|
|
18
|
-
import { useGoBack } from '../../hooks/useGoBack.js';
|
|
19
|
-
import { openPopup } from '../../utils/openPopup.js';
|
|
20
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
21
|
-
import { useEmbeddedExternalConnection } from '../../hooks/useEmbeddedExternalConnection.js';
|
|
22
|
-
function isRampConfig(config) {
|
|
23
|
-
return 'hostApiKey' in config;
|
|
24
|
-
}
|
|
25
|
-
const AssetNetworks = {
|
|
26
|
-
[OnRampAsset.SOLANA]: Network.SOLANA,
|
|
27
|
-
[OnRampAsset.ATOM]: Network.COSMOS,
|
|
28
|
-
[OnRampAsset.CELO]: Network.CELO,
|
|
29
|
-
[OnRampAsset.POLYGON]: Network.POLYGON,
|
|
30
|
-
};
|
|
31
|
-
const AssetMap = {
|
|
32
|
-
SOLANA: OnRampAsset.SOLANA,
|
|
33
|
-
SOL: OnRampAsset.SOLANA,
|
|
34
|
-
ATOM: OnRampAsset.ATOM,
|
|
35
|
-
CELO: OnRampAsset.CELO,
|
|
36
|
-
POLYGON: OnRampAsset.POLYGON,
|
|
37
|
-
MATIC: OnRampAsset.POLYGON,
|
|
38
|
-
USDC: OnRampAsset.USDC,
|
|
39
|
-
ETH: OnRampAsset.ETHEREUM,
|
|
40
|
-
ETHEREUM: OnRampAsset.ETHEREUM,
|
|
41
|
-
};
|
|
42
|
-
export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFactorAuthEnabled = false, recoverySecretStepEnabled = false, oAuthMethods, disableEmailLogin, disablePhoneLogin, onClose, onRampTestMode, loginTransitionOverride, createWalletOverride, }, ref) => {
|
|
43
|
-
const para = useInternalClient();
|
|
44
|
-
const currentStep = useModalStore(state => state.step);
|
|
45
|
-
const webAuthURLForLogin = useModalStore(state => state.webAuthURLForLogin);
|
|
46
|
-
const webAuthURLForCreate = useModalStore(state => state.webAuthURLForCreate);
|
|
47
|
-
const passwordUrlForLogin = useModalStore(state => state.passwordUrlForLogin);
|
|
48
|
-
const isLogin = useModalStore(state => state.isLogin());
|
|
49
|
-
const popupWindow = useModalStore(state => state.popupWindow);
|
|
50
|
-
const onRampConfig = useModalStore(state => state.onRampConfig);
|
|
51
|
-
const setStep = useModalStore(state => state.setStep);
|
|
52
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
53
|
-
const setWebAuthURLForLogin = useModalStore(state => state.setWebAuthURLForLogin);
|
|
54
|
-
const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
|
|
55
|
-
const setPopupWindow = useModalStore(state => state.setPopupWindow);
|
|
56
|
-
const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
|
|
57
|
-
const setPasswordUrlForLogin = useModalStore(state => state.setPasswordUrlForLogin);
|
|
58
|
-
const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
|
|
59
|
-
const setOnRampConfig = useModalStore(state => state.setOnRampConfig);
|
|
60
|
-
const accountAddFundTab = useModalStore(state => state.accountAddFundTab);
|
|
61
|
-
const setAccountAddFundTab = useModalStore(state => state.setAccountAddFundTab);
|
|
62
|
-
const setRecoveryShare = useUserInfoStore(state => state.setRecoveryShare);
|
|
63
|
-
const goBack = useGoBack();
|
|
64
|
-
const loginTimeout = useRef();
|
|
65
|
-
const createAccountTimeout = useRef();
|
|
66
|
-
const [walletCreationInProgress, setWalletCreationInProgress] = useState(false);
|
|
67
|
-
const connectEmbeddedToExternalConnectors = useEmbeddedExternalConnection();
|
|
68
|
-
useImperativeHandle(ref, () => {
|
|
69
|
-
return {
|
|
70
|
-
handleModalClose() {
|
|
71
|
-
handleClose();
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}, []);
|
|
75
|
-
const is2FASetup = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
-
if (!twoFactorAuthEnabled) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
const { isSetup } = yield para.check2FAStatus();
|
|
81
|
-
return isSetup;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
console.error('An error occurred while checking 2FA:', error);
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
function awaitLoginTransition() {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
// TODO: migrate to useWaitForLoginAndSetup hook once we force the use of the CapsuleProvider
|
|
91
|
-
const { isComplete, isError, needsWallet } = yield para.waitForLoginAndSetup({ popupWindow });
|
|
92
|
-
setPopupWindow(undefined);
|
|
93
|
-
if (isError) {
|
|
94
|
-
goBack();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (isComplete) {
|
|
98
|
-
setWebAuthURLForLogin('');
|
|
99
|
-
setPasswordUrlForLogin('');
|
|
100
|
-
setSupportedAuthMethods(new Set());
|
|
101
|
-
setBiometricLocationHints();
|
|
102
|
-
if (needsWallet) {
|
|
103
|
-
setStep(ModalStep.AWAITING_WALLET_CREATION);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
yield connectEmbeddedToExternalConnectors();
|
|
107
|
-
if (yield is2FASetup()) {
|
|
108
|
-
setStep(ModalStep.LOGIN_DONE);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
setStep(ModalStep.SETUP_2FA);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function awaitWalletCreationTransition() {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
// TODO: migrate to useWaitForAccountCreation hook once we force the use of the ParaProvider
|
|
120
|
-
const isComplete = yield para.waitForAccountCreation();
|
|
121
|
-
if (isComplete) {
|
|
122
|
-
setWebAuthURLForCreate('');
|
|
123
|
-
setIFrameUrl('');
|
|
124
|
-
setStep(ModalStep.AWAITING_WALLET_CREATION);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
// generate/claim wallet once we know it's account creation
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (currentStep !== ModalStep.AWAITING_WALLET_CREATION || walletCreationInProgress) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
function genWallet() {
|
|
134
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
setWalletCreationInProgress(true);
|
|
136
|
-
let recoverySecret, walletIds;
|
|
137
|
-
if (!createWalletOverride) {
|
|
138
|
-
// TODO: migrate to useWaitForPasskeyAndCreateWallet hook once we force the use of the ParaProvider
|
|
139
|
-
const created = yield para.waitForPasskeyAndCreateWallet();
|
|
140
|
-
recoverySecret = created.recoverySecret;
|
|
141
|
-
walletIds = created.walletIds;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
const created = yield createWalletOverride(para);
|
|
145
|
-
const fetchedWallets = (yield para.fetchWallets()).filter(wallet => !!wallet.address);
|
|
146
|
-
const newWallets = {};
|
|
147
|
-
for (const wallet of fetchedWallets) {
|
|
148
|
-
newWallets[wallet.id] = Object.assign(Object.assign({}, entityToWallet(wallet)), { signer: '' });
|
|
149
|
-
}
|
|
150
|
-
para.setWallets(newWallets);
|
|
151
|
-
recoverySecret = created.recoverySecret;
|
|
152
|
-
walletIds = created.walletIds;
|
|
153
|
-
}
|
|
154
|
-
yield para.setCurrentWalletIds(walletIds);
|
|
155
|
-
if (recoverySecretStepEnabled) {
|
|
156
|
-
setRecoveryShare(recoverySecret);
|
|
157
|
-
}
|
|
158
|
-
setWalletCreationInProgress(false);
|
|
159
|
-
if (!recoverySecret || !recoverySecretStepEnabled) {
|
|
160
|
-
setStep(ModalStep.WALLET_CREATION_DONE);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
setStep(ModalStep.SECRET);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
genWallet();
|
|
168
|
-
}, [isLogin, currentStep]);
|
|
169
|
-
function createAccountWithPassword() {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
setStep(ModalStep.PASSWORD_CREATION);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
function createAccountWithPasskey() {
|
|
175
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
clearTimeout(createAccountTimeout.current);
|
|
177
|
-
createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
|
|
178
|
-
openPopup(webAuthURLForCreate, 'ParaPasskey', 'CREATE_PASSKEY');
|
|
179
|
-
setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
// wait for login auth to do post login setup
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
if (webAuthURLForLogin || passwordUrlForLogin) {
|
|
185
|
-
if (loginTransitionOverride) {
|
|
186
|
-
function loginOverride() {
|
|
187
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
yield loginTransitionOverride(para);
|
|
189
|
-
setWebAuthURLForLogin('');
|
|
190
|
-
setPasswordUrlForLogin('');
|
|
191
|
-
setBiometricLocationHints();
|
|
192
|
-
yield connectEmbeddedToExternalConnectors();
|
|
193
|
-
if (yield is2FASetup()) {
|
|
194
|
-
setStep(ModalStep.LOGIN_DONE);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
setStep(ModalStep.SETUP_2FA);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
loginOverride();
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
loginTimeout.current = window.setTimeout(awaitLoginTransition, DEFAULTS.LOGGIN_POLLING_DELAY_MS);
|
|
205
|
-
}
|
|
206
|
-
return () => {
|
|
207
|
-
window.clearTimeout(loginTimeout.current);
|
|
208
|
-
para.exitLogin();
|
|
209
|
-
};
|
|
210
|
-
}, [webAuthURLForLogin, passwordUrlForLogin, popupWindow]);
|
|
211
|
-
const handleClose = () => {
|
|
212
|
-
onClose();
|
|
213
|
-
};
|
|
214
|
-
useEffect(() => {
|
|
215
|
-
if (![ModalStep.BIOMETRIC_CREATION, ModalStep.AWAITING_BIOMETRIC_CREATION].includes(currentStep)) {
|
|
216
|
-
para.exitAccountCreation();
|
|
217
|
-
}
|
|
218
|
-
if (![ModalStep.BIOMETRIC_LOGIN, ModalStep.AWAITING_BIOMETRIC_LOGIN].includes(currentStep)) {
|
|
219
|
-
para.exitLogin();
|
|
220
|
-
}
|
|
221
|
-
if (![ModalStep.AWAITING_OAUTH, ModalStep.FARCASTER_OAUTH].includes(currentStep)) {
|
|
222
|
-
para.exitOAuth();
|
|
223
|
-
}
|
|
224
|
-
if (currentStep === ModalStep.PASSWORD_CREATION) {
|
|
225
|
-
clearTimeout(createAccountTimeout.current);
|
|
226
|
-
createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
|
|
227
|
-
}
|
|
228
|
-
}, [currentStep]);
|
|
229
|
-
useEffect(() => {
|
|
230
|
-
if (!onRampConfig) {
|
|
231
|
-
para.ctx.client
|
|
232
|
-
.getOnRampConfig()
|
|
233
|
-
.then(res => {
|
|
234
|
-
var _a, _b;
|
|
235
|
-
let newOnRampConfig;
|
|
236
|
-
if (!!propsOnRampConfig) {
|
|
237
|
-
const { enabledFlows, network, asset, providers, testMode } = propsOnRampConfig;
|
|
238
|
-
const rampConfig = providers.find(config => isRampConfig(config));
|
|
239
|
-
newOnRampConfig = {
|
|
240
|
-
isBuyEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.BUY),
|
|
241
|
-
isReceiveEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.RECEIVE),
|
|
242
|
-
isWithdrawEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.WITHDRAW),
|
|
243
|
-
allowedAssets: network
|
|
244
|
-
? { [Network[network]]: asset ? [AssetMap[asset]] : true }
|
|
245
|
-
: asset
|
|
246
|
-
? { [(_a = AssetNetworks[AssetMap[asset]]) !== null && _a !== void 0 ? _a : Network.ETHEREUM]: [AssetMap[asset]] }
|
|
247
|
-
: res.allowedAssets,
|
|
248
|
-
assetInfo: res.assetInfo,
|
|
249
|
-
providers: providers.map(({ id }) => OnRampProvider[id]),
|
|
250
|
-
rampApiKey: (_b = rampConfig === null || rampConfig === void 0 ? void 0 : rampConfig.hostApiKey) !== null && _b !== void 0 ? _b : res.rampApiKey,
|
|
251
|
-
testMode: testMode !== null && testMode !== void 0 ? testMode : onRampTestMode,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
newOnRampConfig = Object.assign(Object.assign({}, res), { testMode: onRampTestMode });
|
|
256
|
-
}
|
|
257
|
-
setOnRampConfig(newOnRampConfig);
|
|
258
|
-
if (!accountAddFundTab) {
|
|
259
|
-
setAccountAddFundTab(newOnRampConfig.isBuyEnabled
|
|
260
|
-
? EnabledFlow.BUY
|
|
261
|
-
: newOnRampConfig.isReceiveEnabled
|
|
262
|
-
? EnabledFlow.RECEIVE
|
|
263
|
-
: newOnRampConfig.isWithdrawEnabled
|
|
264
|
-
? EnabledFlow.WITHDRAW
|
|
265
|
-
: undefined);
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
.catch();
|
|
269
|
-
}
|
|
270
|
-
}, []);
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
if (!!onRampConfig) {
|
|
273
|
-
setOnRampConfig(Object.assign(Object.assign({}, onRampConfig), { testMode: onRampTestMode }));
|
|
274
|
-
}
|
|
275
|
-
}, [onRampTestMode]);
|
|
276
|
-
useEffect(() => {
|
|
277
|
-
return () => {
|
|
278
|
-
para.exitLoops();
|
|
279
|
-
};
|
|
280
|
-
}, []);
|
|
281
|
-
return (_jsxs(_Fragment, { children: [_jsx(Body, { oAuthMethods: oAuthMethods, twoFactorAuthEnabled: twoFactorAuthEnabled, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin, onClose: handleClose, createAccountWithPasskey: createAccountWithPasskey, createAccountWithPassword: createAccountWithPassword }), _jsx(Footer, {})] }));
|
|
282
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
import { useEffect, useState } from 'react';
|
|
12
|
-
import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from '@getpara/react-components';
|
|
13
|
-
import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
|
|
14
|
-
import { useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
|
|
15
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
16
|
-
import { AuthMethod, isMobile } from '@getpara/web-sdk';
|
|
17
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
18
|
-
const FarcasterOAuthStep = () => {
|
|
19
|
-
const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
|
|
20
|
-
const setStep = useModalStore(state => state.setStep);
|
|
21
|
-
const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
|
|
22
|
-
const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
|
|
23
|
-
const setIsIFrameReady = useModalStore(state => state.setIsIFrameReady);
|
|
24
|
-
const isIFrameReady = useModalStore(state => state.isIFrameReady);
|
|
25
|
-
const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
|
|
26
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
27
|
-
const para = useInternalClient();
|
|
28
|
-
const setFlow = useModalStore(state => state.setFlow);
|
|
29
|
-
const farcasterConnectUri = useModalStore(state => state.farcasterConnectUri);
|
|
30
|
-
const setFarcasterConnectUri = useModalStore(state => state.setFarcasterConnectUri);
|
|
31
|
-
const theme = useThemeStore(state => state.theme);
|
|
32
|
-
const [shouldRouteToStep, setShouldRouteToStep] = useState();
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (!!shouldRouteToStep && isIFrameReady) {
|
|
35
|
-
// Using a small timeout here to fully ensure the iframe is loaded before triggering any animation
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
setStep(shouldRouteToStep);
|
|
38
|
-
}, 200);
|
|
39
|
-
}
|
|
40
|
-
}, [shouldRouteToStep, isIFrameReady]);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (farcasterConnectUri) {
|
|
43
|
-
const pollStatus = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
const { userExists, username, pfpUrl } = yield para.waitForFarcasterStatus();
|
|
45
|
-
setAuthInfo({ farcasterUsername: username, pfpUrl });
|
|
46
|
-
if (userExists) {
|
|
47
|
-
const supportedAuthMethods = yield para.initiateUserLoginV2({ farcasterUsername: username });
|
|
48
|
-
if (supportedAuthMethods.size > 0) {
|
|
49
|
-
setSupportedAuthMethods(supportedAuthMethods);
|
|
50
|
-
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
|
|
51
|
-
? yield para.getUserBiometricLocationHints()
|
|
52
|
-
: [];
|
|
53
|
-
setFlow('login');
|
|
54
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
55
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
|
|
60
|
-
setIsIFrameReady(false);
|
|
61
|
-
setFlow('signUp');
|
|
62
|
-
const supportsPasskey = supportedCreateAuthMethods.has(AuthMethod.PASSKEY);
|
|
63
|
-
if (supportsPasskey) {
|
|
64
|
-
setWebAuthURLForCreate(yield para.shortenLoginLink(yield para.getSetUpBiometricsURL({ authType: 'farcaster' })));
|
|
65
|
-
setStep(ModalStep.BIOMETRIC_CREATION);
|
|
66
|
-
}
|
|
67
|
-
if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD)) {
|
|
68
|
-
setIFrameUrl(yield para.shortenLoginLink(yield para.getSetupPasswordURL({ authType: 'farcaster', theme })));
|
|
69
|
-
setShouldRouteToStep(supportsPasskey ? ModalStep.BIOMETRIC_CREATION : ModalStep.PASSWORD_CREATION);
|
|
70
|
-
}
|
|
71
|
-
return;
|
|
72
|
-
});
|
|
73
|
-
pollStatus();
|
|
74
|
-
return () => {
|
|
75
|
-
setFarcasterConnectUri(undefined);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}, [farcasterConnectUri]);
|
|
79
|
-
return (_jsx(StepContainer, { "$wide": true, children: isMobile() ? (_jsxs(InnerStepContainer, { children: [_jsx(CpslText, { weight: "medium", color: "secondary", children: `Don’t have Farcaster` }), _jsxs(CpslButton, { as: "a", href: 'https://link.warpcast.com/download-qr', target: "_blank", variant: "secondary", children: [_jsx(CpslIcon, { slot: "start", icon: "linkExternal" }), `Get Farcaster`] })] })) : (_jsxs(_Fragment, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: "Sign in using Farcaster" }), _jsxs(InnerStepContainer, { children: [_jsx(CenteredText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan the QR code with your phone's camera to proceed." }), _jsx(QRContainer, { children: !farcasterConnectUri ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: farcasterConnectUri }) })] })] })) }));
|
|
80
|
-
};
|
|
81
|
-
export default FarcasterOAuthStep;
|