@getpara/react-sdk 0.1.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.
Files changed (180) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +4 -0
  3. package/dist/modal/ParaModal.d.ts +2 -0
  4. package/dist/modal/ParaModal.js +250 -0
  5. package/dist/modal/components/Account/Account.d.ts +5 -0
  6. package/dist/modal/components/Account/Account.js +59 -0
  7. package/dist/modal/components/AddFunds/AddFunds.d.ts +3 -0
  8. package/dist/modal/components/AddFunds/AddFunds.js +146 -0
  9. package/dist/modal/components/AddFunds/AddFundsAwaiting.d.ts +1 -0
  10. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +64 -0
  11. package/dist/modal/components/AddFunds/AddFundsDone.d.ts +6 -0
  12. package/dist/modal/components/AddFunds/AddFundsDone.js +26 -0
  13. package/dist/modal/components/AddFunds/MoonPayEmbed.d.ts +2 -0
  14. package/dist/modal/components/AddFunds/MoonPayEmbed.js +2 -0
  15. package/dist/modal/components/AddFunds/index.d.ts +3 -0
  16. package/dist/modal/components/AddFunds/index.js +3 -0
  17. package/dist/modal/components/AuthInput/AuthInput.d.ts +6 -0
  18. package/dist/modal/components/AuthInput/AuthInput.js +214 -0
  19. package/dist/modal/components/AuthInput/countryCodes.d.ts +8 -0
  20. package/dist/modal/components/AuthInput/countryCodes.js +40 -0
  21. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +7 -0
  22. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +23 -0
  23. package/dist/modal/components/AuthInput/phoneMasks.d.ts +247 -0
  24. package/dist/modal/components/AuthInput/phoneMasks.js +247 -0
  25. package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +8 -0
  26. package/dist/modal/components/AuthMainStep/AuthMainStep.js +21 -0
  27. package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +8 -0
  28. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +89 -0
  29. package/dist/modal/components/AuthOptions/AuthOptions.d.ts +8 -0
  30. package/dist/modal/components/AuthOptions/AuthOptions.js +28 -0
  31. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.d.ts +1 -0
  32. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +7 -0
  33. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.d.ts +1 -0
  34. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +5 -0
  35. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.d.ts +1 -0
  36. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +7 -0
  37. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +1 -0
  38. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +18 -0
  39. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +4 -0
  40. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +17 -0
  41. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -0
  42. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +127 -0
  43. package/dist/modal/components/Body/AnimatedHeightWrapper.d.ts +6 -0
  44. package/dist/modal/components/Body/AnimatedHeightWrapper.js +26 -0
  45. package/dist/modal/components/Body/Body.d.ts +12 -0
  46. package/dist/modal/components/Body/Body.js +232 -0
  47. package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -0
  48. package/dist/modal/components/ChainSwitch/ChainSwitch.js +77 -0
  49. package/dist/modal/components/ChainSwitch/config.d.ts +7 -0
  50. package/dist/modal/components/ChainSwitch/config.js +11 -0
  51. package/dist/modal/components/Controls/Controls.d.ts +5 -0
  52. package/dist/modal/components/Controls/Controls.js +54 -0
  53. package/dist/modal/components/Controls/Selects.d.ts +2 -0
  54. package/dist/modal/components/Controls/Selects.js +157 -0
  55. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -0
  56. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +116 -0
  57. package/dist/modal/components/ExternalWalletStep/config.d.ts +7 -0
  58. package/dist/modal/components/ExternalWalletStep/config.js +11 -0
  59. package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +1 -0
  60. package/dist/modal/components/ExternalWallets/ExternalWallets.js +142 -0
  61. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +7 -0
  62. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +118 -0
  63. package/dist/modal/components/Footer/Footer.d.ts +1 -0
  64. package/dist/modal/components/Footer/Footer.js +71 -0
  65. package/dist/modal/components/Header/Header.d.ts +1 -0
  66. package/dist/modal/components/Header/Header.js +24 -0
  67. package/dist/modal/components/Header/hooks/useStepTitle.d.ts +3 -0
  68. package/dist/modal/components/Header/hooks/useStepTitle.js +42 -0
  69. package/dist/modal/components/Hero/Hero.d.ts +1 -0
  70. package/dist/modal/components/Hero/Hero.js +118 -0
  71. package/dist/modal/components/IFrameStep/IFrameStep.d.ts +1 -0
  72. package/dist/modal/components/IFrameStep/IFrameStep.js +41 -0
  73. package/dist/modal/components/LoginDoneStep/LoginDoneStep.d.ts +1 -0
  74. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +18 -0
  75. package/dist/modal/components/ModalContent/ModalContent.d.ts +10 -0
  76. package/dist/modal/components/ModalContent/ModalContent.js +276 -0
  77. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +2 -0
  78. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
  79. package/dist/modal/components/OAuth/OAuth.d.ts +6 -0
  80. package/dist/modal/components/OAuth/OAuth.js +124 -0
  81. package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +1 -0
  82. package/dist/modal/components/OAuth/TelegramOAuthStep.js +132 -0
  83. package/dist/modal/components/OnRampComponents/AddingFunds.d.ts +1 -0
  84. package/dist/modal/components/OnRampComponents/AddingFunds.js +10 -0
  85. package/dist/modal/components/OnRampComponents/OnRampProviderButton.d.ts +9 -0
  86. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +72 -0
  87. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.d.ts +6 -0
  88. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +67 -0
  89. package/dist/modal/components/Setup2FAStep/Setup2FAStep.d.ts +5 -0
  90. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +104 -0
  91. package/dist/modal/components/StripeComponents/StripeComponents.d.ts +16 -0
  92. package/dist/modal/components/StripeComponents/StripeComponents.js +78 -0
  93. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.d.ts +5 -0
  94. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +8 -0
  95. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +1 -0
  96. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +130 -0
  97. package/dist/modal/components/Waiting/Waiting.d.ts +6 -0
  98. package/dist/modal/components/Waiting/Waiting.js +6 -0
  99. package/dist/modal/components/WalletCard/PartnerIcon.d.ts +6 -0
  100. package/dist/modal/components/WalletCard/PartnerIcon.js +29 -0
  101. package/dist/modal/components/WalletCard/WalletCard.d.ts +18 -0
  102. package/dist/modal/components/WalletCard/WalletCard.js +91 -0
  103. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.d.ts +6 -0
  104. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +49 -0
  105. package/dist/modal/components/common.d.ts +19 -0
  106. package/dist/modal/components/common.js +67 -0
  107. package/dist/modal/components/index.d.ts +1 -0
  108. package/dist/modal/components/index.js +1 -0
  109. package/dist/modal/constants/constants.d.ts +32 -0
  110. package/dist/modal/constants/constants.js +93 -0
  111. package/dist/modal/constants/defaults.d.ts +5 -0
  112. package/dist/modal/constants/defaults.js +5 -0
  113. package/dist/modal/constants/oAuthLogos.d.ts +8 -0
  114. package/dist/modal/constants/oAuthLogos.js +18 -0
  115. package/dist/modal/css/modal.css +13 -0
  116. package/dist/modal/hooks/useActiveWallet.d.ts +1 -0
  117. package/dist/modal/hooks/useActiveWallet.js +9 -0
  118. package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +1 -0
  119. package/dist/modal/hooks/useEmbeddedExternalConnection.js +46 -0
  120. package/dist/modal/hooks/useGoBack.d.ts +1 -0
  121. package/dist/modal/hooks/useGoBack.js +34 -0
  122. package/dist/modal/index.d.ts +10 -0
  123. package/dist/modal/index.js +9 -0
  124. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +29 -0
  125. package/dist/modal/providers/CosmosExternalWalletContextStub.js +18 -0
  126. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +33 -0
  127. package/dist/modal/providers/EvmExternalWalletContextStub.js +22 -0
  128. package/dist/modal/providers/ExternalWalletContext.d.ts +75 -0
  129. package/dist/modal/providers/ExternalWalletContext.js +252 -0
  130. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +21 -0
  131. package/dist/modal/providers/SolanaExternalWalletContextStub.js +12 -0
  132. package/dist/modal/public/Inter-VariableFont_slnt,wght.ttf +0 -0
  133. package/dist/modal/stores/externalWalletProvider/actions.d.ts +3 -0
  134. package/dist/modal/stores/externalWalletProvider/actions.js +5 -0
  135. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +20 -0
  136. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +13 -0
  137. package/dist/modal/stores/index.d.ts +4 -0
  138. package/dist/modal/stores/index.js +4 -0
  139. package/dist/modal/stores/modal/actions.d.ts +3 -0
  140. package/dist/modal/stores/modal/actions.js +65 -0
  141. package/dist/modal/stores/modal/useModalStore.d.ts +82 -0
  142. package/dist/modal/stores/modal/useModalStore.js +41 -0
  143. package/dist/modal/stores/para/actions.d.ts +3 -0
  144. package/dist/modal/stores/para/actions.js +5 -0
  145. package/dist/modal/stores/para/useParaStore.d.ts +10 -0
  146. package/dist/modal/stores/para/useParaStore.js +3 -0
  147. package/dist/modal/stores/theme/actions.d.ts +3 -0
  148. package/dist/modal/stores/theme/actions.js +24 -0
  149. package/dist/modal/stores/theme/useThemeStore.d.ts +20 -0
  150. package/dist/modal/stores/theme/useThemeStore.js +14 -0
  151. package/dist/modal/stores/userInfo/actions.d.ts +3 -0
  152. package/dist/modal/stores/userInfo/actions.js +28 -0
  153. package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +19 -0
  154. package/dist/modal/stores/userInfo/useUserInfoStore.js +9 -0
  155. package/dist/modal/types/commonTypes.d.ts +48 -0
  156. package/dist/modal/types/commonTypes.js +1 -0
  157. package/dist/modal/types/externalWallets.d.ts +31 -0
  158. package/dist/modal/types/externalWallets.js +21 -0
  159. package/dist/modal/types/modalProps.d.ts +138 -0
  160. package/dist/modal/types/modalProps.js +7 -0
  161. package/dist/modal/utils/authLayoutHelpers.d.ts +3 -0
  162. package/dist/modal/utils/authLayoutHelpers.js +2 -0
  163. package/dist/modal/utils/getMailtoLink.d.ts +1 -0
  164. package/dist/modal/utils/getMailtoLink.js +5 -0
  165. package/dist/modal/utils/getTileButtonFlex.d.ts +1 -0
  166. package/dist/modal/utils/getTileButtonFlex.js +15 -0
  167. package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
  168. package/dist/modal/utils/isPasskeySupported.js +10 -0
  169. package/dist/modal/utils/openPopup.d.ts +1 -0
  170. package/dist/modal/utils/openPopup.js +55 -0
  171. package/dist/modal/utils/routeMobileExternalWallet.d.ts +1 -0
  172. package/dist/modal/utils/routeMobileExternalWallet.js +35 -0
  173. package/dist/modal/utils/steps.d.ts +112 -0
  174. package/dist/modal/utils/steps.js +215 -0
  175. package/dist/modal/utils/stringFormatters.d.ts +4 -0
  176. package/dist/modal/utils/stringFormatters.js +12 -0
  177. package/dist/modal/utils/validateOnRampConfig.d.ts +5 -0
  178. package/dist/modal/utils/validateOnRampConfig.js +26 -0
  179. package/package.json +51 -0
  180. package/styles.css/package.json +3 -0
@@ -0,0 +1,118 @@
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 { useParaStore, 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
+ const getStepConfig = ({ externalWalletError, }) => {
12
+ var _a;
13
+ return ({
14
+ [ModalStep.EX_WALLET_SELECTED]: {
15
+ variant: 'externalWalletConnection',
16
+ topOffset: 40,
17
+ spacerHeight: 158,
18
+ hideFadeOut: true,
19
+ },
20
+ [ModalStep.CHAIN_SWITCH]: {
21
+ 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',
22
+ topOffset: 20,
23
+ spacerHeight: 158,
24
+ hideFadeOut: true,
25
+ },
26
+ [ModalStep.ACCOUNT_MAIN]: {
27
+ variant: 'customContent',
28
+ topOffset: 0,
29
+ spacerHeight: 104,
30
+ hideFadeOut: true,
31
+ },
32
+ [ModalStep.FARCASTER_OAUTH]: {
33
+ variant: 'externalWalletConnection',
34
+ topOffset: 40,
35
+ spacerHeight: 158,
36
+ hideFadeOut: true,
37
+ },
38
+ });
39
+ };
40
+ export const Hero = () => {
41
+ const para = useParaStore(state => state.para);
42
+ const { wallet: connector, walletDisplayHelpers, avatar } = useExternalWallets();
43
+ const step = useModalStore(state => state.step);
44
+ const externalWalletError = useModalStore(state => state.externalWalletError);
45
+ const activeWallet = useActiveWallet();
46
+ const [currentStep, setCurrentStep] = useState(step);
47
+ const stepConfig = getStepConfig({
48
+ externalWalletError,
49
+ })[currentStep];
50
+ // Watching the step here to make the animation in/out of the hero look correct
51
+ useEffect(() => {
52
+ const prevStepConfig = getStepConfig({
53
+ externalWalletError,
54
+ })[currentStep];
55
+ const newStepConfig = getStepConfig({
56
+ externalWalletError,
57
+ })[step];
58
+ const delay = newStepConfig && prevStepConfig ? 0 : newStepConfig && !prevStepConfig ? 0 : 200;
59
+ setTimeout(() => {
60
+ setCurrentStep(step);
61
+ }, delay);
62
+ }, [step]);
63
+ const isExternalStep = currentStep === ModalStep.EX_WALLET_SELECTED;
64
+ const isChainSwitchStep = currentStep === ModalStep.CHAIN_SWITCH;
65
+ const isAccountStep = currentStep === ModalStep.ACCOUNT_MAIN;
66
+ const isFarcasterStep = currentStep === ModalStep.FARCASTER_OAUTH;
67
+ const { showExtension, isCosmosMobileWallet } = walletDisplayHelpers;
68
+ // Hide if:
69
+ // 1. On a step with no hero config
70
+ // 2. On the external wallet step and not showing the extension connection screen
71
+ // 3. On the network switch step on web for Cosmos mobile connectors
72
+ // 4. On the farcaster step on desktop
73
+ const shouldHide = !stepConfig ||
74
+ (!isMobile() && isExternalStep && !showExtension) ||
75
+ (!isMobile() && isChainSwitchStep && isCosmosMobileWallet) ||
76
+ (!isMobile() && isFarcasterStep);
77
+ const { variant, topOffset, spacerHeight, hideFadeOut } = stepConfig !== null && stepConfig !== void 0 ? stepConfig : {};
78
+ 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 &&
79
+ (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 })] }));
80
+ };
81
+ const Container = styled.div `
82
+ display: flex;
83
+ position: absolute;
84
+ justify-content: center;
85
+ align-items: center;
86
+ width: 100%;
87
+
88
+ top: ${({ $top }) => `${$top}px`};
89
+ `;
90
+ const Spacer = styled.div `
91
+ height: ${({ $height }) => `${$height}px`};
92
+ `;
93
+ const WalletLogo = styled(CpslIcon) `
94
+ --height: 60px;
95
+ --width: 60px;
96
+ `;
97
+ const Avatar = styled.img `
98
+ width: 100%;
99
+ height: 100%;
100
+ object-fit: contain;
101
+ `;
102
+ const IconAvatar = styled(CpslIdenticon) `
103
+ border-radius: 1000px;
104
+ `;
105
+ const StyledHero = styled(CpslHero) `
106
+ ${({ $isAccount }) => $isAccount &&
107
+ `
108
+ --ring-3-size: 560px;
109
+ --ring-2-size: 402px;
110
+ --ring-1-size: 228px;
111
+ --ring-0-size: 104px;
112
+
113
+ --default-theme-ring-3-opacity: 0.02;
114
+ --default-theme-ring-2-opacity: 0.04;
115
+ --default-theme-ring-1-opacity: 0.06;
116
+ --default-theme-ring-0-opacity: 0.1;
117
+ `}
118
+ `;
@@ -0,0 +1 @@
1
+ export declare const IFrameStep: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,41 @@
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
+ `;
@@ -0,0 +1 @@
1
+ export declare const LoginDoneStep: ({ onClose }: LoginDoneStep) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
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 { useParaStore, useThemeStore } from '../../stores/index.js';
6
+ export const LoginDoneStep = ({ onClose }) => {
7
+ var _a;
8
+ const para = useParaStore(state => state.para);
9
+ const hideWallets = useThemeStore(state => state.hideWallets);
10
+ useEffect(() => {
11
+ setTimeout(() => {
12
+ onClose();
13
+ }, 1600);
14
+ }, []);
15
+ 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]) => {
16
+ return _jsx(WalletCard, { id: id, type: type }, `${id}-${type}`);
17
+ })) }))] }));
18
+ };
@@ -0,0 +1,10 @@
1
+ import { ParaModalProps } from '../../types/modalProps.js';
2
+ type ModalContentProps = Omit<ParaModalProps, 'para' | 'isOpen' | 'theme' | 'branding' | 'onModalStepChange' | 'onExpandModalChange'>;
3
+ export type ModalContentHandle = {
4
+ /**
5
+ * Trigger the modal close handler
6
+ */
7
+ handleModalClose: () => void;
8
+ };
9
+ export declare const ModalContent: import("react").ForwardRefExoticComponent<ModalContentProps & import("react").RefAttributes<ModalContentHandle>>;
10
+ export {};
@@ -0,0 +1,276 @@
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 { useParaStore, 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 { useEmbeddedExternalConnection } from '../../hooks/useEmbeddedExternalConnection.js';
21
+ function isRampConfig(config) {
22
+ return 'hostApiKey' in config;
23
+ }
24
+ const AssetNetworks = {
25
+ [OnRampAsset.SOLANA]: Network.SOLANA,
26
+ [OnRampAsset.ATOM]: Network.COSMOS,
27
+ [OnRampAsset.CELO]: Network.CELO,
28
+ [OnRampAsset.POLYGON]: Network.POLYGON,
29
+ };
30
+ const AssetMap = {
31
+ SOLANA: OnRampAsset.SOLANA,
32
+ SOL: OnRampAsset.SOLANA,
33
+ ATOM: OnRampAsset.ATOM,
34
+ CELO: OnRampAsset.CELO,
35
+ POLYGON: OnRampAsset.POLYGON,
36
+ MATIC: OnRampAsset.POLYGON,
37
+ USDC: OnRampAsset.USDC,
38
+ ETH: OnRampAsset.ETHEREUM,
39
+ ETHEREUM: OnRampAsset.ETHEREUM,
40
+ };
41
+ export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFactorAuthEnabled = false, recoverySecretStepEnabled = false, oAuthMethods, disableEmailLogin, disablePhoneLogin, onClose, onRampTestMode, loginTransitionOverride, createWalletOverride, }, ref) => {
42
+ const para = useParaStore(state => state.para);
43
+ const currentStep = useModalStore(state => state.step);
44
+ const webAuthURLForLogin = useModalStore(state => state.webAuthURLForLogin);
45
+ const webAuthURLForCreate = useModalStore(state => state.webAuthURLForCreate);
46
+ const passwordUrlForLogin = useModalStore(state => state.passwordUrlForLogin);
47
+ const isLogin = useModalStore(state => state.isLogin());
48
+ const popupWindow = useModalStore(state => state.popupWindow);
49
+ const onRampConfig = useModalStore(state => state.onRampConfig);
50
+ const setStep = useModalStore(state => state.setStep);
51
+ const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
52
+ const setWebAuthURLForLogin = useModalStore(state => state.setWebAuthURLForLogin);
53
+ const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
54
+ const setPopupWindow = useModalStore(state => state.setPopupWindow);
55
+ const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
56
+ const setPasswordUrlForLogin = useModalStore(state => state.setPasswordUrlForLogin);
57
+ const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
58
+ const setOnRampConfig = useModalStore(state => state.setOnRampConfig);
59
+ const accountAddFundTab = useModalStore(state => state.accountAddFundTab);
60
+ const setAccountAddFundTab = useModalStore(state => state.setAccountAddFundTab);
61
+ const setRecoveryShare = useUserInfoStore(state => state.setRecoveryShare);
62
+ const goBack = useGoBack();
63
+ const loginTimeout = useRef();
64
+ const createAccountTimeout = useRef();
65
+ const [walletCreationInProgress, setWalletCreationInProgress] = useState(false);
66
+ const connectEmbeddedToExternalConnectors = useEmbeddedExternalConnection();
67
+ useImperativeHandle(ref, () => {
68
+ return {
69
+ handleModalClose() {
70
+ handleClose();
71
+ },
72
+ };
73
+ }, []);
74
+ const is2FASetup = () => __awaiter(void 0, void 0, void 0, function* () {
75
+ if (!twoFactorAuthEnabled) {
76
+ return true;
77
+ }
78
+ try {
79
+ const { isSetup } = yield para.check2FAStatus();
80
+ return isSetup;
81
+ }
82
+ catch (error) {
83
+ console.error('An error occurred while checking 2FA:', error);
84
+ return false;
85
+ }
86
+ });
87
+ function awaitLoginTransition() {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const { isComplete, isError, needsWallet } = yield para.waitForLoginAndSetup({ popupWindow });
90
+ setPopupWindow(undefined);
91
+ if (isError) {
92
+ goBack();
93
+ return;
94
+ }
95
+ if (isComplete) {
96
+ setWebAuthURLForLogin('');
97
+ setPasswordUrlForLogin('');
98
+ setSupportedAuthMethods(new Set());
99
+ setBiometricLocationHints();
100
+ if (needsWallet) {
101
+ setStep(ModalStep.AWAITING_WALLET_CREATION);
102
+ }
103
+ else {
104
+ yield connectEmbeddedToExternalConnectors();
105
+ if (yield is2FASetup()) {
106
+ setStep(ModalStep.LOGIN_DONE);
107
+ }
108
+ else {
109
+ setStep(ModalStep.SETUP_2FA);
110
+ }
111
+ }
112
+ }
113
+ });
114
+ }
115
+ function awaitWalletCreationTransition() {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ const isComplete = yield para.waitForAccountCreation();
118
+ if (isComplete) {
119
+ setWebAuthURLForCreate('');
120
+ setIFrameUrl('');
121
+ setStep(ModalStep.AWAITING_WALLET_CREATION);
122
+ }
123
+ });
124
+ }
125
+ // generate/claim wallet once we know it's account creation
126
+ useEffect(() => {
127
+ if (currentStep !== ModalStep.AWAITING_WALLET_CREATION || walletCreationInProgress) {
128
+ return;
129
+ }
130
+ function genWallet() {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ setWalletCreationInProgress(true);
133
+ let recoverySecret, walletIds;
134
+ if (!createWalletOverride) {
135
+ const created = yield para.waitForPasskeyAndCreateWallet();
136
+ recoverySecret = created.recoverySecret;
137
+ walletIds = created.walletIds;
138
+ }
139
+ else {
140
+ const created = yield createWalletOverride(para);
141
+ const fetchedWallets = (yield para.fetchWallets()).filter(wallet => !!wallet.address);
142
+ const newWallets = {};
143
+ for (const wallet of fetchedWallets) {
144
+ newWallets[wallet.id] = Object.assign(Object.assign({}, entityToWallet(wallet)), { signer: '' });
145
+ }
146
+ para.setWallets(newWallets);
147
+ recoverySecret = created.recoverySecret;
148
+ walletIds = created.walletIds;
149
+ }
150
+ yield para.setCurrentWalletIds(walletIds);
151
+ if (recoverySecretStepEnabled) {
152
+ setRecoveryShare(recoverySecret);
153
+ }
154
+ setWalletCreationInProgress(false);
155
+ if (!recoverySecret || !recoverySecretStepEnabled) {
156
+ setStep(ModalStep.WALLET_CREATION_DONE);
157
+ }
158
+ else {
159
+ setStep(ModalStep.SECRET);
160
+ }
161
+ });
162
+ }
163
+ genWallet();
164
+ }, [isLogin, currentStep]);
165
+ function createAccountWithPassword() {
166
+ return __awaiter(this, void 0, void 0, function* () {
167
+ clearTimeout(createAccountTimeout.current);
168
+ createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
169
+ setStep(ModalStep.PASSWORD_CREATION);
170
+ });
171
+ }
172
+ function createAccountWithPasskey() {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ clearTimeout(createAccountTimeout.current);
175
+ createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
176
+ openPopup(webAuthURLForCreate, 'ParaPasskey', 'CREATE_PASSKEY');
177
+ setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
178
+ });
179
+ }
180
+ // wait for login auth to do post login setup
181
+ useEffect(() => {
182
+ if (webAuthURLForLogin || passwordUrlForLogin) {
183
+ if (loginTransitionOverride) {
184
+ function loginOverride() {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ yield loginTransitionOverride(para);
187
+ setWebAuthURLForLogin('');
188
+ setPasswordUrlForLogin('');
189
+ setBiometricLocationHints();
190
+ yield connectEmbeddedToExternalConnectors();
191
+ if (yield is2FASetup()) {
192
+ setStep(ModalStep.LOGIN_DONE);
193
+ }
194
+ else {
195
+ setStep(ModalStep.SETUP_2FA);
196
+ }
197
+ });
198
+ }
199
+ loginOverride();
200
+ return;
201
+ }
202
+ loginTimeout.current = window.setTimeout(awaitLoginTransition, DEFAULTS.LOGGIN_POLLING_DELAY_MS);
203
+ }
204
+ return () => {
205
+ window.clearTimeout(loginTimeout.current);
206
+ para.exitLogin();
207
+ };
208
+ }, [webAuthURLForLogin, passwordUrlForLogin, popupWindow]);
209
+ const handleClose = () => {
210
+ onClose();
211
+ };
212
+ useEffect(() => {
213
+ if (![ModalStep.BIOMETRIC_CREATION, ModalStep.AWAITING_BIOMETRIC_CREATION].includes(currentStep)) {
214
+ para.exitAccountCreation();
215
+ }
216
+ if (![ModalStep.BIOMETRIC_LOGIN, ModalStep.AWAITING_BIOMETRIC_LOGIN].includes(currentStep)) {
217
+ para.exitLogin();
218
+ }
219
+ if (![ModalStep.AWAITING_OAUTH, ModalStep.FARCASTER_OAUTH].includes(currentStep)) {
220
+ para.exitOAuth();
221
+ }
222
+ }, [currentStep]);
223
+ useEffect(() => {
224
+ if (!onRampConfig) {
225
+ para.ctx.client
226
+ .getOnRampConfig()
227
+ .then(res => {
228
+ var _a, _b;
229
+ let newOnRampConfig;
230
+ if (!!propsOnRampConfig) {
231
+ const { enabledFlows, network, asset, providers, testMode } = propsOnRampConfig;
232
+ const rampConfig = providers.find(config => isRampConfig(config));
233
+ newOnRampConfig = {
234
+ isBuyEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.BUY),
235
+ isReceiveEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.RECEIVE),
236
+ isWithdrawEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.WITHDRAW),
237
+ allowedAssets: network
238
+ ? { [Network[network]]: asset ? [AssetMap[asset]] : true }
239
+ : asset
240
+ ? { [(_a = AssetNetworks[AssetMap[asset]]) !== null && _a !== void 0 ? _a : Network.ETHEREUM]: [AssetMap[asset]] }
241
+ : res.allowedAssets,
242
+ assetInfo: res.assetInfo,
243
+ providers: providers.map(({ id }) => OnRampProvider[id]),
244
+ rampApiKey: (_b = rampConfig === null || rampConfig === void 0 ? void 0 : rampConfig.hostApiKey) !== null && _b !== void 0 ? _b : res.rampApiKey,
245
+ testMode: testMode !== null && testMode !== void 0 ? testMode : onRampTestMode,
246
+ };
247
+ }
248
+ else {
249
+ newOnRampConfig = Object.assign(Object.assign({}, res), { testMode: onRampTestMode });
250
+ }
251
+ setOnRampConfig(newOnRampConfig);
252
+ if (!accountAddFundTab) {
253
+ setAccountAddFundTab(newOnRampConfig.isBuyEnabled
254
+ ? EnabledFlow.BUY
255
+ : newOnRampConfig.isReceiveEnabled
256
+ ? EnabledFlow.RECEIVE
257
+ : newOnRampConfig.isWithdrawEnabled
258
+ ? EnabledFlow.WITHDRAW
259
+ : undefined);
260
+ }
261
+ })
262
+ .catch();
263
+ }
264
+ }, []);
265
+ useEffect(() => {
266
+ if (!!onRampConfig) {
267
+ setOnRampConfig(Object.assign(Object.assign({}, onRampConfig), { testMode: onRampTestMode }));
268
+ }
269
+ }, [onRampTestMode]);
270
+ useEffect(() => {
271
+ return () => {
272
+ para.exitLoops();
273
+ };
274
+ }, []);
275
+ return (_jsxs(_Fragment, { children: [_jsx(Body, { oAuthMethods: oAuthMethods, twoFactorAuthEnabled: twoFactorAuthEnabled, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin, onClose: handleClose, createAccountWithPasskey: createAccountWithPasskey, createAccountWithPassword: createAccountWithPassword }), _jsx(Footer, {})] }));
276
+ });
@@ -0,0 +1,2 @@
1
+ declare const FarcasterOAuthStep: () => import("react/jsx-runtime").JSX.Element;
2
+ export default FarcasterOAuthStep;
@@ -0,0 +1,81 @@
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 { useParaStore, useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
15
+ import { ModalStep } from '../../utils/steps.js';
16
+ import { AuthMethod, isMobile } from '@getpara/web-sdk';
17
+ const FarcasterOAuthStep = () => {
18
+ const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
19
+ const setStep = useModalStore(state => state.setStep);
20
+ const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
21
+ const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
22
+ const setIsIFrameReady = useModalStore(state => state.setIsIFrameReady);
23
+ const isIFrameReady = useModalStore(state => state.isIFrameReady);
24
+ const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
25
+ const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
26
+ const para = useParaStore(state => state.para);
27
+ const setFlow = useModalStore(state => state.setFlow);
28
+ const farcasterConnectUri = useModalStore(state => state.farcasterConnectUri);
29
+ const setFarcasterConnectUri = useModalStore(state => state.setFarcasterConnectUri);
30
+ const theme = useThemeStore(state => state.theme);
31
+ const [shouldRouteToStep, setShouldRouteToStep] = useState();
32
+ useEffect(() => {
33
+ if (!!shouldRouteToStep && isIFrameReady) {
34
+ // Using a small timeout here to fully ensure the iframe is loaded before triggering any animation
35
+ setTimeout(() => {
36
+ setStep(shouldRouteToStep);
37
+ }, 200);
38
+ }
39
+ }, [shouldRouteToStep, isIFrameReady]);
40
+ useEffect(() => {
41
+ if (farcasterConnectUri) {
42
+ const pollStatus = () => __awaiter(void 0, void 0, void 0, function* () {
43
+ const { userExists, username, pfpUrl } = yield para.waitForFarcasterStatus();
44
+ setAuthInfo({ farcasterUsername: username, pfpUrl });
45
+ setStep(ModalStep.AWAITING_OAUTH);
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;
@@ -0,0 +1,6 @@
1
+ import { OAuthMethod } from '@getpara/web-sdk';
2
+ interface OAuthProps {
3
+ methods: OAuthMethod[];
4
+ }
5
+ export declare const OAuth: ({ methods }: OAuthProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};