@getpara/react-sdk 1.8.0 → 2.0.0-alpha.3

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 (248) hide show
  1. package/dist/{modal/components/AddFunds/MoonPayEmbed.js → MoonPayEmbed-Q2HP2BFI.js} +3 -1
  2. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  3. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  4. package/dist/chunk-MMUBH76A.js.br +0 -0
  5. package/dist/chunk-MMUBH76A.js.gz +0 -0
  6. package/dist/cli/cli.mjs +40 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +6499 -6
  9. package/dist/index.js.br +0 -0
  10. package/dist/index.js.gz +0 -0
  11. package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
  12. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
  13. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -1
  14. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
  15. package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
  16. package/dist/modal/components/Controls/Selects.d.ts +1 -1
  17. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
  18. package/dist/modal/components/Footer/Footer.d.ts +1 -1
  19. package/dist/modal/components/WalletCard/WalletCard.d.ts +2 -2
  20. package/dist/modal/components/common.d.ts +7 -7
  21. package/dist/modal/constants/constants.d.ts +1 -1
  22. package/dist/modal/index.d.ts +0 -2
  23. package/dist/modal/stores/index.d.ts +0 -2
  24. package/dist/modal/stores/modal/useModalStore.d.ts +22 -20
  25. package/dist/modal/types/commonTypes.d.ts +4 -9
  26. package/dist/modal/types/externalWallets.d.ts +0 -2
  27. package/dist/modal/types/modalProps.d.ts +1 -33
  28. package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
  29. package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
  30. package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
  31. package/dist/modal/utils/openPopup.d.ts +2 -2
  32. package/dist/modal/utils/stringFormatters.d.ts +0 -1
  33. package/dist/provider/ParaProvider.d.ts +3 -1
  34. package/dist/provider/actions/getAccount.d.ts +19 -7
  35. package/dist/provider/actions/getWallet.d.ts +1 -1
  36. package/dist/provider/actions/index.d.ts +25 -0
  37. package/dist/provider/actions/utils.d.ts +3 -0
  38. package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
  39. package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
  40. package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
  41. package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
  42. package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
  43. package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
  44. package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
  45. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
  46. package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
  47. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
  48. package/dist/provider/hooks/mutations/index.d.ts +25 -10
  49. package/dist/provider/hooks/mutations/utils.d.ts +4 -0
  50. package/dist/provider/hooks/queries/index.d.ts +0 -1
  51. package/dist/provider/hooks/queries/useAccount.d.ts +1 -6
  52. package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
  53. package/dist/provider/hooks/utils/useWalletState.d.ts +3 -2
  54. package/dist/provider/index.d.ts +1 -0
  55. package/dist/provider/providers/AuthProvider.d.ts +31 -0
  56. package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
  57. package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
  58. package/dist/provider/providers/ExternalWalletProvider.d.ts +73 -0
  59. package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
  60. package/dist/provider/stores/getters.d.ts +3 -3
  61. package/dist/provider/stores/setters.d.ts +1 -0
  62. package/dist/provider/stores/slices/config.d.ts +3 -0
  63. package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
  64. package/dist/provider/stores/slices/index.d.ts +1 -0
  65. package/dist/provider/stores/types.d.ts +46 -3
  66. package/dist/provider/types/externalWalletProviders.d.ts +12 -0
  67. package/dist/provider/types/provider.d.ts +119 -16
  68. package/dist/provider/types/utils.d.ts +16 -0
  69. package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
  70. package/dist/provider/utils/renameMutations.d.ts +3 -0
  71. package/package.json +19 -7
  72. package/dist/modal/ParaModal.js +0 -362
  73. package/dist/modal/components/Account/Account.js +0 -77
  74. package/dist/modal/components/AddFunds/AddFunds.js +0 -220
  75. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -72
  76. package/dist/modal/components/AddFunds/AddFundsDone.js +0 -43
  77. package/dist/modal/components/AddFunds/index.js +0 -4
  78. package/dist/modal/components/AuthInput/AuthInput.js +0 -283
  79. package/dist/modal/components/AuthInput/countryCodes.js +0 -42
  80. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -33
  81. package/dist/modal/components/AuthInput/phoneMasks.js +0 -253
  82. package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -37
  83. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -113
  84. package/dist/modal/components/AuthOptions/AuthOptions.js +0 -33
  85. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
  86. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -10
  87. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -18
  88. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -44
  89. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -55
  90. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -93
  91. package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -29
  92. package/dist/modal/components/Body/Body.js +0 -308
  93. package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -94
  94. package/dist/modal/components/ChainSwitch/config.js +0 -17
  95. package/dist/modal/components/Controls/Controls.js +0 -74
  96. package/dist/modal/components/Controls/Selects.js +0 -234
  97. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -140
  98. package/dist/modal/components/ExternalWalletStep/config.js +0 -17
  99. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +0 -96
  100. package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -172
  101. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
  102. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
  103. package/dist/modal/components/Footer/Footer.js +0 -93
  104. package/dist/modal/components/Header/Header.js +0 -43
  105. package/dist/modal/components/Header/hooks/useStepTitle.js +0 -50
  106. package/dist/modal/components/Hero/Hero.js +0 -116
  107. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -55
  108. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -28
  109. package/dist/modal/components/ModalContent/ModalContent.js +0 -324
  110. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
  111. package/dist/modal/components/OAuth/OAuth.js +0 -153
  112. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -139
  113. package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -23
  114. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -77
  115. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -101
  116. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -141
  117. package/dist/modal/components/StripeComponents/StripeComponents.js +0 -88
  118. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -24
  119. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -159
  120. package/dist/modal/components/Waiting/Waiting.js +0 -17
  121. package/dist/modal/components/WalletCard/PartnerIcon.js +0 -34
  122. package/dist/modal/components/WalletCard/WalletCard.js +0 -127
  123. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -52
  124. package/dist/modal/components/common.js +0 -96
  125. package/dist/modal/components/index.js +0 -2
  126. package/dist/modal/constants/constants.js +0 -111
  127. package/dist/modal/constants/defaults.js +0 -10
  128. package/dist/modal/constants/oAuthLogos.js +0 -24
  129. package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
  130. package/dist/modal/hooks/useActiveWallet.js +0 -15
  131. package/dist/modal/hooks/useCreateAccount.d.ts +0 -4
  132. package/dist/modal/hooks/useCreateAccount.js +0 -72
  133. package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
  134. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
  135. package/dist/modal/hooks/useGoBack.js +0 -42
  136. package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
  137. package/dist/modal/hooks/useSetLoginURLs.js +0 -49
  138. package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
  139. package/dist/modal/hooks/useWalletBalance.js +0 -47
  140. package/dist/modal/index.js +0 -33
  141. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
  142. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
  143. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
  144. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
  145. package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
  146. package/dist/modal/providers/ExternalWalletContext.js +0 -394
  147. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
  148. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
  149. package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
  150. package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
  151. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
  152. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
  153. package/dist/modal/stores/index.js +0 -4
  154. package/dist/modal/stores/modal/actions.js +0 -70
  155. package/dist/modal/stores/modal/useModalStore.js +0 -65
  156. package/dist/modal/stores/theme/actions.d.ts +0 -3
  157. package/dist/modal/stores/theme/actions.js +0 -28
  158. package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
  159. package/dist/modal/stores/theme/useThemeStore.js +0 -21
  160. package/dist/modal/stores/userInfo/actions.d.ts +0 -3
  161. package/dist/modal/stores/userInfo/actions.js +0 -30
  162. package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
  163. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
  164. package/dist/modal/types/commonTypes.js +0 -1
  165. package/dist/modal/types/externalWallets.js +0 -32
  166. package/dist/modal/types/modalProps.js +0 -12
  167. package/dist/modal/utils/authLayoutHelpers.js +0 -8
  168. package/dist/modal/utils/getMailtoLink.js +0 -10
  169. package/dist/modal/utils/getTileButtonFlex.js +0 -20
  170. package/dist/modal/utils/openPopup.js +0 -60
  171. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
  172. package/dist/modal/utils/steps.js +0 -232
  173. package/dist/modal/utils/stringFormatters.js +0 -19
  174. package/dist/modal/utils/validateOnRampConfig.js +0 -32
  175. package/dist/package.json +0 -6
  176. package/dist/provider/ParaProvider.js +0 -22
  177. package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
  178. package/dist/provider/actions/checkIfUserExists.js +0 -21
  179. package/dist/provider/actions/createUser.d.ts +0 -12
  180. package/dist/provider/actions/createUser.js +0 -26
  181. package/dist/provider/actions/getAccount.js +0 -22
  182. package/dist/provider/actions/getWallet.js +0 -14
  183. package/dist/provider/actions/getWalletBalance.d.ts +0 -2
  184. package/dist/provider/actions/getWalletBalance.js +0 -14
  185. package/dist/provider/actions/initiateLogin.d.ts +0 -4
  186. package/dist/provider/actions/initiateLogin.js +0 -20
  187. package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
  188. package/dist/provider/actions/keepSessionAlive.js +0 -20
  189. package/dist/provider/actions/logout.d.ts +0 -2
  190. package/dist/provider/actions/logout.js +0 -17
  191. package/dist/provider/actions/signMessage.d.ts +0 -8
  192. package/dist/provider/actions/signMessage.js +0 -20
  193. package/dist/provider/actions/signTransaction.d.ts +0 -8
  194. package/dist/provider/actions/signTransaction.js +0 -20
  195. package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
  196. package/dist/provider/actions/waitForAccountCreation.js +0 -21
  197. package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
  198. package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
  199. package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
  200. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
  201. package/dist/provider/hooks/index.js +0 -4
  202. package/dist/provider/hooks/mutations/index.js +0 -24
  203. package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
  204. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  205. package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
  206. package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
  207. package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
  208. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  209. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
  210. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
  211. package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
  212. package/dist/provider/hooks/mutations/useLogout.js +0 -30
  213. package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
  214. package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
  215. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
  216. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
  217. package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
  218. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  219. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
  220. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  221. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
  222. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  223. package/dist/provider/hooks/queries/index.js +0 -10
  224. package/dist/provider/hooks/queries/useAccount.js +0 -21
  225. package/dist/provider/hooks/queries/useWallet.js +0 -22
  226. package/dist/provider/hooks/queries/useWalletBalance.d.ts +0 -7
  227. package/dist/provider/hooks/queries/useWalletBalance.js +0 -26
  228. package/dist/provider/hooks/utils/index.js +0 -10
  229. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -74
  230. package/dist/provider/hooks/utils/useClient.js +0 -10
  231. package/dist/provider/hooks/utils/useEventListeners.js +0 -105
  232. package/dist/provider/hooks/utils/useInternalClient.js +0 -10
  233. package/dist/provider/hooks/utils/useModal.js +0 -17
  234. package/dist/provider/hooks/utils/useWalletState.js +0 -33
  235. package/dist/provider/index.js +0 -8
  236. package/dist/provider/stores/getters.js +0 -13
  237. package/dist/provider/stores/slices/client.js +0 -9
  238. package/dist/provider/stores/slices/index.js +0 -4
  239. package/dist/provider/stores/slices/modal.js +0 -9
  240. package/dist/provider/stores/slices/wallet.js +0 -13
  241. package/dist/provider/stores/types.js +0 -1
  242. package/dist/provider/stores/useStore.js +0 -27
  243. package/dist/provider/types/provider.js +0 -1
  244. package/dist/provider/types/query.js +0 -1
  245. package/dist/provider/types/utils.js +0 -1
  246. package/dist/provider/utils/constants.d.ts +0 -5
  247. package/dist/provider/utils/constants.js +0 -11
  248. package/dist/provider/utils/renameMutations.js +0 -16
@@ -1,324 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "../../../chunk-MMUBH76A.js";
7
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
- import { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from "react";
9
- import {
10
- entityToWallet,
11
- OnRampProvider,
12
- OnRampAsset,
13
- Network,
14
- EnabledFlow
15
- } from "@getpara/web-sdk";
16
- import { useModalStore, useUserInfoStore } from "../../stores/index.js";
17
- import { ModalStep } from "../../utils/steps.js";
18
- import { Body } from "../Body/Body.js";
19
- import { Footer } from "../Footer/Footer.js";
20
- import { DEFAULTS } from "../../constants/defaults.js";
21
- import { useGoBack } from "../../hooks/useGoBack.js";
22
- import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
23
- import { useEmbeddedExternalConnection } from "../../hooks/useEmbeddedExternalConnection.js";
24
- import { useCreateAccount } from "../../hooks/useCreateAccount.js";
25
- import { formatBiometricHints } from "@getpara/react-common";
26
- import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
27
- function isRampConfig(config) {
28
- return "hostApiKey" in config;
29
- }
30
- const AssetNetworks = {
31
- [OnRampAsset.SOLANA]: Network.SOLANA,
32
- [OnRampAsset.ATOM]: Network.COSMOS,
33
- [OnRampAsset.CELO]: Network.CELO,
34
- [OnRampAsset.POLYGON]: Network.POLYGON
35
- };
36
- const AssetMap = {
37
- SOLANA: OnRampAsset.SOLANA,
38
- SOL: OnRampAsset.SOLANA,
39
- ATOM: OnRampAsset.ATOM,
40
- CELO: OnRampAsset.CELO,
41
- POLYGON: OnRampAsset.POLYGON,
42
- MATIC: OnRampAsset.POLYGON,
43
- USDC: OnRampAsset.USDC,
44
- ETH: OnRampAsset.ETHEREUM,
45
- ETHEREUM: OnRampAsset.ETHEREUM
46
- };
47
- const ModalContent = forwardRef(
48
- ({
49
- onRampConfig: propsOnRampConfig,
50
- twoFactorAuthEnabled = false,
51
- recoverySecretStepEnabled = false,
52
- oAuthMethods,
53
- disableEmailLogin,
54
- disablePhoneLogin,
55
- onClose,
56
- onRampTestMode,
57
- loginTransitionOverride,
58
- createWalletOverride
59
- }, ref) => {
60
- var _a;
61
- const para = useInternalClient();
62
- const refs = useModalStore((state) => state.refs);
63
- const currentStep = useModalStore((state) => state.step);
64
- const webAuthURLForLogin = useModalStore((state) => state.webAuthURLForLogin);
65
- const passwordUrlForLogin = useModalStore((state) => state.passwordUrlForLogin);
66
- const isLogin = useModalStore((state) => state.isLogin());
67
- const onRampConfig = useModalStore((state) => state.onRampConfig);
68
- const setStep = useModalStore((state) => state.setStep);
69
- const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
70
- const setWebAuthURLForLogin = useModalStore((state) => state.setWebAuthURLForLogin);
71
- const setPasswordUrlForLogin = useModalStore((state) => state.setPasswordUrlForLogin);
72
- const setSupportedAuthMethods = useModalStore((state) => state.setSupportedAuthMethods);
73
- const setOnRampConfig = useModalStore((state) => state.setOnRampConfig);
74
- const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
75
- const setAccountAddFundTab = useModalStore((state) => state.setAccountAddFundTab);
76
- const setRecoveryShare = useUserInfoStore((state) => state.setRecoveryShare);
77
- const authStepRoute = useModalStore((state) => state.authStepRoute);
78
- const isIFrameReady = useModalStore((state) => state.isIFrameReady);
79
- const goBack = useGoBack();
80
- const createAccount = useCreateAccount();
81
- const biometricLocationHints = useModalStore((state) => {
82
- var _a2;
83
- return (_a2 = state.biometricLocationHints) != null ? _a2 : [];
84
- });
85
- const formattedHints = useMemo(() => formatBiometricHints(biometricLocationHints), [biometricLocationHints]);
86
- const passkeysSupported = useModalStore((state) => state.isPasskeySupported);
87
- const [hasHints, isOnKnownDevice] = [(biometricLocationHints == null ? void 0 : biometricLocationHints.length) > 0, (_a = formattedHints == null ? void 0 : formattedHints.isOnKnownDevice) != null ? _a : false];
88
- const { disconnectExternalWallet } = useExternalWallets();
89
- const [walletCreationInProgress, setWalletCreationInProgress] = useState(false);
90
- const connectEmbeddedToExternalConnectors = useEmbeddedExternalConnection();
91
- useEffect(() => {
92
- if (!!authStepRoute && isIFrameReady) {
93
- setTimeout(() => {
94
- setStep(authStepRoute);
95
- }, 200);
96
- }
97
- }, [authStepRoute, isIFrameReady]);
98
- useImperativeHandle(ref, () => {
99
- return {
100
- handleModalClose() {
101
- handleClose();
102
- }
103
- };
104
- }, []);
105
- const is2FASetup = () => __async(void 0, null, function* () {
106
- if (!twoFactorAuthEnabled) {
107
- return true;
108
- }
109
- try {
110
- const { isSetup } = yield para.check2FAStatus();
111
- return isSetup;
112
- } catch (error) {
113
- console.error("An error occurred while checking 2FA:", error);
114
- return false;
115
- }
116
- });
117
- function awaitLoginTransition() {
118
- return __async(this, null, function* () {
119
- const { isComplete, isError, needsWallet } = yield para.waitForLoginAndSetup({
120
- popupWindow: refs.popupWindow.current
121
- });
122
- if (isError) {
123
- [ModalStep.AWAITING_BIOMETRIC_LOGIN, ModalStep.AWAITING_PASSWORD_LOGIN].includes(refs.currentStep.current) && goBack();
124
- return;
125
- }
126
- if (isComplete) {
127
- setWebAuthURLForLogin("");
128
- setPasswordUrlForLogin("");
129
- setSupportedAuthMethods(/* @__PURE__ */ new Set());
130
- setBiometricLocationHints();
131
- if (needsWallet) {
132
- setStep(ModalStep.AWAITING_WALLET_CREATION);
133
- } else {
134
- yield connectEmbeddedToExternalConnectors();
135
- if (yield is2FASetup()) {
136
- setStep(ModalStep.LOGIN_DONE);
137
- } else {
138
- setStep(ModalStep.SETUP_2FA);
139
- }
140
- }
141
- }
142
- });
143
- }
144
- useEffect(() => {
145
- if (currentStep !== ModalStep.AWAITING_WALLET_CREATION || walletCreationInProgress) {
146
- return;
147
- }
148
- function genWallet() {
149
- return __async(this, null, function* () {
150
- setWalletCreationInProgress(true);
151
- let recoverySecret, walletIds;
152
- if (!createWalletOverride) {
153
- const created = yield para.waitForPasskeyAndCreateWallet();
154
- recoverySecret = created.recoverySecret;
155
- walletIds = created.walletIds;
156
- } else {
157
- const created = yield createWalletOverride(para);
158
- const fetchedWallets = (yield para.fetchWallets()).filter((wallet) => !!wallet.address);
159
- const newWallets = {};
160
- for (const wallet of fetchedWallets) {
161
- newWallets[wallet.id] = __spreadProps(__spreadValues({}, entityToWallet(wallet)), {
162
- signer: ""
163
- });
164
- }
165
- para.setWallets(newWallets);
166
- recoverySecret = created.recoverySecret;
167
- walletIds = created.walletIds;
168
- }
169
- yield para.setCurrentWalletIds(walletIds);
170
- yield connectEmbeddedToExternalConnectors();
171
- if (recoverySecretStepEnabled) {
172
- setRecoveryShare(recoverySecret);
173
- }
174
- setWalletCreationInProgress(false);
175
- if (!recoverySecret || !recoverySecretStepEnabled) {
176
- setStep(ModalStep.WALLET_CREATION_DONE);
177
- } else {
178
- setStep(ModalStep.SECRET);
179
- }
180
- });
181
- }
182
- genWallet();
183
- }, [isLogin, currentStep]);
184
- useEffect(() => {
185
- const isAwaitingLogin = [
186
- ModalStep.AWAITING_PASSWORD_LOGIN,
187
- ModalStep.AWAITING_BIOMETRIC_LOGIN,
188
- ModalStep.BIOMETRIC_LOGIN
189
- ].includes(currentStep);
190
- const isUnknownDeviceWithHints = hasHints && !isOnKnownDevice;
191
- const isPasskeyUnsupported = !passkeysSupported;
192
- const hasLoginURLs = !!webAuthURLForLogin || !!passwordUrlForLogin;
193
- const userNeedsToLogin = isAwaitingLogin || isUnknownDeviceWithHints || isPasskeyUnsupported;
194
- if (userNeedsToLogin && hasLoginURLs) {
195
- if (loginTransitionOverride) {
196
- function loginOverride() {
197
- return __async(this, null, function* () {
198
- yield loginTransitionOverride(para);
199
- setWebAuthURLForLogin("");
200
- setPasswordUrlForLogin("");
201
- setBiometricLocationHints();
202
- yield connectEmbeddedToExternalConnectors();
203
- if (yield is2FASetup()) {
204
- setStep(ModalStep.LOGIN_DONE);
205
- } else {
206
- setStep(ModalStep.SETUP_2FA);
207
- }
208
- });
209
- }
210
- loginOverride();
211
- return;
212
- }
213
- if (typeof window !== "undefined") {
214
- refs.poll.current = {
215
- action: "login",
216
- timeout: window.setTimeout(awaitLoginTransition, DEFAULTS.LOGGIN_POLLING_DELAY_MS)
217
- };
218
- }
219
- return () => {
220
- var _a2;
221
- if (typeof window !== "undefined" && !!refs.poll.current) {
222
- window.clearTimeout((_a2 = refs.poll.current) == null ? void 0 : _a2.timeout);
223
- }
224
- para.exitLogin();
225
- };
226
- }
227
- }, [currentStep, webAuthURLForLogin, passwordUrlForLogin]);
228
- const handleClose = () => {
229
- onClose();
230
- if (currentStep === ModalStep.EXTERNAL_WALLET_VERIFICATION && para.isExternalWalletAuth) {
231
- disconnectExternalWallet();
232
- }
233
- };
234
- useEffect(() => {
235
- var _a2, _b, _c;
236
- refs.currentStep.current = currentStep;
237
- let resetPoll = false;
238
- if (![ModalStep.AWAITING_BIOMETRIC_CREATION, ModalStep.PASSWORD_CREATION].includes(currentStep)) {
239
- para.exitAccountCreation();
240
- resetPoll = ["createPassword", "createPasskey"].includes((_a2 = refs.poll.current) == null ? void 0 : _a2.action);
241
- }
242
- if (![ModalStep.AWAITING_PASSWORD_LOGIN, ModalStep.AWAITING_BIOMETRIC_LOGIN, ModalStep.BIOMETRIC_LOGIN].includes(
243
- currentStep
244
- )) {
245
- para.exitLogin();
246
- resetPoll = ((_b = refs.poll.current) == null ? void 0 : _b.action) === "login";
247
- }
248
- if (![ModalStep.AWAITING_OAUTH, ModalStep.FARCASTER_OAUTH].includes(currentStep)) {
249
- para.exitOAuth();
250
- }
251
- if (currentStep === ModalStep.PASSWORD_CREATION) {
252
- createAccount.withPassword();
253
- }
254
- if (resetPoll && typeof window !== "undefined") {
255
- window.clearTimeout((_c = refs.poll.current) == null ? void 0 : _c.timeout);
256
- refs.poll.current = void 0;
257
- }
258
- }, [currentStep]);
259
- useEffect(() => {
260
- if (!onRampConfig) {
261
- para.ctx.client.getOnRampConfig().then((res) => {
262
- var _a2, _b;
263
- let newOnRampConfig;
264
- if (!!propsOnRampConfig) {
265
- const { enabledFlows, network, asset, providers, testMode } = propsOnRampConfig;
266
- const rampConfig = providers.find((config) => isRampConfig(config));
267
- newOnRampConfig = {
268
- isBuyEnabled: !enabledFlows || enabledFlows.some((str) => EnabledFlow[str] === EnabledFlow.BUY),
269
- isReceiveEnabled: !enabledFlows || enabledFlows.some((str) => EnabledFlow[str] === EnabledFlow.RECEIVE),
270
- isWithdrawEnabled: !enabledFlows || enabledFlows.some((str) => EnabledFlow[str] === EnabledFlow.WITHDRAW),
271
- allowedAssets: network ? { [Network[network]]: asset ? [AssetMap[asset]] : true } : asset ? { [(_a2 = AssetNetworks[AssetMap[asset]]) != null ? _a2 : Network.ETHEREUM]: [AssetMap[asset]] } : res.allowedAssets,
272
- assetInfo: res.assetInfo,
273
- providers: providers.map(({ id }) => OnRampProvider[id]),
274
- rampApiKey: (_b = rampConfig == null ? void 0 : rampConfig.hostApiKey) != null ? _b : res.rampApiKey,
275
- testMode: testMode != null ? testMode : onRampTestMode
276
- };
277
- } else {
278
- newOnRampConfig = __spreadProps(__spreadValues({}, res), { testMode: onRampTestMode });
279
- }
280
- setOnRampConfig(newOnRampConfig);
281
- if (!accountAddFundTab) {
282
- setAccountAddFundTab(
283
- newOnRampConfig.isBuyEnabled ? EnabledFlow.BUY : newOnRampConfig.isReceiveEnabled ? EnabledFlow.RECEIVE : newOnRampConfig.isWithdrawEnabled ? EnabledFlow.WITHDRAW : void 0
284
- );
285
- }
286
- }).catch();
287
- }
288
- }, []);
289
- useEffect(() => {
290
- if (!!onRampConfig) {
291
- setOnRampConfig(__spreadProps(__spreadValues({}, onRampConfig), { testMode: onRampTestMode }));
292
- }
293
- }, [onRampTestMode]);
294
- useEffect(() => {
295
- const init = () => __async(void 0, null, function* () {
296
- if (!(yield para.isFullyLoggedIn())) {
297
- yield disconnectExternalWallet();
298
- }
299
- });
300
- init();
301
- return () => {
302
- var _a2;
303
- window.clearTimeout((_a2 = refs.poll.current) == null ? void 0 : _a2.timeout);
304
- para.exitLoops();
305
- };
306
- }, []);
307
- return /* @__PURE__ */ jsxs(Fragment, { children: [
308
- /* @__PURE__ */ jsx(
309
- Body,
310
- {
311
- oAuthMethods,
312
- twoFactorAuthEnabled,
313
- disableEmailLogin,
314
- disablePhoneLogin,
315
- onClose: handleClose
316
- }
317
- ),
318
- /* @__PURE__ */ jsx(Footer, {})
319
- ] });
320
- }
321
- );
322
- export {
323
- ModalContent
324
- };
@@ -1,81 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { useEffect } from "react";
7
- import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
8
- import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
9
- import { useModalStore, useThemeStore, useUserInfoStore } from "../../stores/index.js";
10
- import { ModalStep } from "../../utils/steps.js";
11
- import { AuthMethod, isMobile } from "@getpara/web-sdk";
12
- import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
13
- import { useSetLoginURLs } from "../../hooks/useSetLoginURLs.js";
14
- const FarcasterOAuthStep = () => {
15
- const setAuthInfo = useUserInfoStore((state) => state.setAuthInfo);
16
- const setStep = useModalStore((state) => state.setStep);
17
- const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
18
- const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
19
- const setIsIFrameReady = useModalStore((state) => state.setIsIFrameReady);
20
- const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
21
- const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
22
- const para = useInternalClient();
23
- const setFlow = useModalStore((state) => state.setFlow);
24
- const farcasterConnectUri = useModalStore((state) => state.farcasterConnectUri);
25
- const setFarcasterConnectUri = useModalStore((state) => state.setFarcasterConnectUri);
26
- const theme = useThemeStore((state) => state.theme);
27
- const setLoginURLs = useSetLoginURLs();
28
- useEffect(() => {
29
- if (farcasterConnectUri) {
30
- const pollStatus = () => __async(void 0, null, function* () {
31
- const { userExists, username, pfpUrl } = yield para.waitForFarcasterStatus();
32
- setAuthInfo({ farcasterUsername: username, pfpUrl });
33
- if (userExists) {
34
- const supportedAuthMethods = yield para.initiateUserLoginV2({ farcasterUsername: username });
35
- if (supportedAuthMethods.size > 0) {
36
- const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY) ? yield para.getUserBiometricLocationHints() : [];
37
- yield setLoginURLs({ supportedAuthMethods, authType: "farcaster", displayName: username, pfpUrl });
38
- setFlow("login");
39
- setStep(ModalStep.BIOMETRIC_LOGIN);
40
- setBiometricLocationHints(biometricLocationHints);
41
- return;
42
- }
43
- }
44
- const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
45
- setIsIFrameReady(false);
46
- setFlow("signUp");
47
- const supportsPasskey = supportedCreateAuthMethods.has(AuthMethod.PASSKEY);
48
- if (supportsPasskey) {
49
- setWebAuthURLForCreate(yield para.shortenLoginLink(yield para.getSetUpBiometricsURL({ authType: "farcaster" })));
50
- setStep(ModalStep.BIOMETRIC_CREATION);
51
- }
52
- if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD)) {
53
- setIFrameUrl(yield para.shortenLoginLink(yield para.getSetupPasswordURL({ authType: "farcaster", theme })));
54
- setAuthStepRoute(supportsPasskey ? ModalStep.BIOMETRIC_CREATION : ModalStep.PASSWORD_CREATION);
55
- }
56
- return;
57
- });
58
- pollStatus();
59
- return () => {
60
- setFarcasterConnectUri(void 0);
61
- };
62
- }
63
- }, [farcasterConnectUri]);
64
- return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: isMobile() ? /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
65
- /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "secondary", children: `Don\u2019t have Farcaster` }),
66
- /* @__PURE__ */ jsxs(CpslButton, { as: "a", href: "https://link.warpcast.com/download-qr", target: "_blank", variant: "secondary", children: [
67
- /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "linkExternal" }),
68
- `Get Farcaster`
69
- ] })
70
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
71
- /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Sign in using Farcaster" }),
72
- /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
73
- /* @__PURE__ */ jsx(CenteredText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan the QR code with your phone's camera to proceed." }),
74
- /* @__PURE__ */ jsx(QRContainer, { children: !farcasterConnectUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: farcasterConnectUri }) })
75
- ] })
76
- ] }) });
77
- };
78
- var FarcasterOAuthStep_default = FarcasterOAuthStep;
79
- export {
80
- FarcasterOAuthStep_default as default
81
- };
@@ -1,153 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- import { AuthMethod, OAuthMethod } from "@getpara/web-sdk";
7
- import { styled } from "styled-components";
8
- import { useModalStore, useUserInfoStore } from "../../stores/index.js";
9
- import { ModalStep } from "../../utils/steps.js";
10
- import { openPopup } from "../../utils/openPopup.js";
11
- import { useThemeStore } from "../../stores/theme/useThemeStore.js";
12
- import { getTileButtonFlex } from "../../utils/getTileButtonFlex.js";
13
- import { StyledCpslTileButton } from "../common.js";
14
- import { brandedOAuthLogos, oAuthLogos } from "../../constants/oAuthLogos.js";
15
- import { useEffect } from "react";
16
- import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
17
- import { useGoBack } from "../../hooks/useGoBack.js";
18
- import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
19
- import { useSetLoginURLs } from "../../hooks/useSetLoginURLs.js";
20
- const HAS_MORE_LENGTH = 3;
21
- const OAuth = ({ methods }) => {
22
- const goBack = useGoBack();
23
- const oAuthLogoVariant = useThemeStore((state) => state.oAuthLogoVariant);
24
- const isDark = useThemeStore((state) => state.isDark);
25
- const para = useInternalClient();
26
- const refs = useModalStore((state) => state.refs);
27
- const setFlow = useModalStore((state) => state.setFlow);
28
- const setStep = useModalStore((state) => state.setStep);
29
- const setAuthInfo = useUserInfoStore((state) => state.setAuthInfo);
30
- const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
31
- const setFarcasterConnectUri = useModalStore((state) => state.setFarcasterConnectUri);
32
- const farcasterConnectUri = useModalStore((state) => state.farcasterConnectUri);
33
- const showAll = useModalStore((state) => state.step === ModalStep.AUTH_MORE);
34
- const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
35
- const setIsIFrameReady = useModalStore((state) => state.setIsIFrameReady);
36
- const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
37
- const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
38
- const theme = useThemeStore((state) => state.theme);
39
- const setLoginURLs = useSetLoginURLs();
40
- useEffect(() => {
41
- const initializeFarcaster = () => __async(void 0, null, function* () {
42
- if (!methods.includes(OAuthMethod.FARCASTER)) {
43
- return;
44
- }
45
- const connectUri = yield para.getFarcasterConnectURL();
46
- setFarcasterConnectUri(connectUri);
47
- });
48
- initializeFarcaster();
49
- }, []);
50
- const hasMore = methods.length > HAS_MORE_LENGTH;
51
- const methodsToShow = showAll || !hasMore ? methods : methods.slice(0, HAS_MORE_LENGTH - 1);
52
- const handleShowAll = () => {
53
- setStep(ModalStep.AUTH_MORE);
54
- };
55
- const handleMethodClick = (method) => () => __async(void 0, null, function* () {
56
- switch (method) {
57
- case OAuthMethod.FARCASTER:
58
- if (!farcasterConnectUri) {
59
- return;
60
- }
61
- routeMobileExternalWallet(farcasterConnectUri);
62
- setStep(ModalStep.FARCASTER_OAUTH);
63
- break;
64
- case OAuthMethod.TELEGRAM:
65
- setStep(ModalStep.TELEGRAM_OAUTH);
66
- break;
67
- default:
68
- setStep(ModalStep.AWAITING_OAUTH);
69
- const oAuthURL = yield para.getOAuthURL({ method });
70
- refs.popupWindow.current = openPopup({
71
- url: oAuthURL,
72
- target: `${method}AuthPopup`,
73
- type: "OAUTH",
74
- current: refs.popupWindow.current
75
- });
76
- const { email, isError, userExists } = yield para.waitForOAuth({ popupWindow: refs.popupWindow.current });
77
- refs.popupWindow.current = void 0;
78
- if ((isError || !email) && refs.currentStep.current === ModalStep.AWAITING_OAUTH) {
79
- goBack();
80
- return;
81
- }
82
- setAuthInfo({ email });
83
- if (userExists) {
84
- const supportedAuthMethods = yield para.initiateUserLoginV2({ email });
85
- if (supportedAuthMethods.size > 0) {
86
- const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY) ? yield para.getUserBiometricLocationHints() : [];
87
- yield setLoginURLs({ supportedAuthMethods, authType: "email" });
88
- setFlow("login");
89
- setStep(ModalStep.BIOMETRIC_LOGIN);
90
- setBiometricLocationHints(biometricLocationHints);
91
- return;
92
- }
93
- }
94
- const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
95
- setIsIFrameReady(false);
96
- setFlow("signUp");
97
- const supportsPasskey = supportedCreateAuthMethods.has(AuthMethod.PASSKEY);
98
- const supportsPassword = supportedCreateAuthMethods.has(AuthMethod.PASSWORD);
99
- if (supportsPasskey) {
100
- setWebAuthURLForCreate(yield para.shortenLoginLink(yield para.getSetUpBiometricsURL({ authType: "email" })));
101
- if (!supportsPassword) {
102
- setStep(ModalStep.BIOMETRIC_CREATION);
103
- return;
104
- }
105
- }
106
- if (supportsPassword) {
107
- setIFrameUrl(yield para.shortenLoginLink(yield para.getSetupPasswordURL({ authType: "email", theme })));
108
- }
109
- setAuthStepRoute(supportsPasskey ? ModalStep.BIOMETRIC_CREATION : ModalStep.PASSWORD_CREATION);
110
- break;
111
- }
112
- });
113
- const useBrandedLogos = oAuthLogoVariant === "default";
114
- const useDarkLogos = useBrandedLogos ? isDark : oAuthLogoVariant !== "dark";
115
- const showMoreButton = !showAll && hasMore;
116
- return /* @__PURE__ */ jsxs(OAuthContainer, { children: [
117
- methodsToShow.map((method, index) => /* @__PURE__ */ jsx(
118
- OAuthButton,
119
- {
120
- $isDark: useDarkLogos,
121
- icon: useBrandedLogos ? brandedOAuthLogos[method] : oAuthLogos[method],
122
- onClick: handleMethodClick(method),
123
- $index: index,
124
- $totalItems: showMoreButton ? HAS_MORE_LENGTH : methodsToShow.length
125
- },
126
- method
127
- )),
128
- showMoreButton && /* @__PURE__ */ jsx(
129
- OAuthButton,
130
- {
131
- $isDark: useDarkLogos,
132
- icon: "moreLoginOptions",
133
- onClick: handleShowAll,
134
- $index: HAS_MORE_LENGTH - 1,
135
- $totalItems: HAS_MORE_LENGTH
136
- }
137
- )
138
- ] });
139
- };
140
- const OAuthContainer = styled.div`
141
- display: flex;
142
- justify-content: center;
143
- gap: 8px;
144
- flex-wrap: wrap;
145
- `;
146
- const OAuthButton = styled(StyledCpslTileButton)`
147
- flex: ${({ $index, $totalItems }) => getTileButtonFlex($index, $totalItems)};
148
-
149
- --button-icon-color: ${({ $isDark }) => $isDark ? "white" : "black"};
150
- `;
151
- export {
152
- OAuth
153
- };