@getpara/react-sdk 1.7.1 → 1.9.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 (160) hide show
  1. package/dist/index.js +6 -6659
  2. package/dist/modal/ParaModal.js +364 -0
  3. package/dist/modal/components/Account/Account.js +77 -0
  4. package/dist/modal/components/AddFunds/AddFunds.js +220 -0
  5. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +72 -0
  6. package/dist/modal/components/AddFunds/AddFundsDone.js +43 -0
  7. package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
  8. package/dist/modal/components/AddFunds/index.js +4 -0
  9. package/dist/modal/components/AuthInput/AuthInput.js +283 -0
  10. package/dist/modal/components/AuthInput/countryCodes.js +42 -0
  11. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
  12. package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
  13. package/dist/modal/components/AuthMainStep/AuthMainStep.js +37 -0
  14. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +113 -0
  15. package/dist/modal/components/AuthOptions/AuthOptions.js +33 -0
  16. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
  17. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
  18. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
  19. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +44 -0
  20. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +3 -1
  21. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +55 -0
  22. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +93 -0
  23. package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
  24. package/dist/modal/components/Body/Body.js +308 -0
  25. package/dist/modal/components/ChainSwitch/ChainSwitch.js +94 -0
  26. package/dist/modal/components/ChainSwitch/config.js +17 -0
  27. package/dist/modal/components/Controls/Controls.js +74 -0
  28. package/dist/modal/components/Controls/Selects.js +234 -0
  29. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +140 -0
  30. package/dist/modal/components/ExternalWalletStep/config.js +17 -0
  31. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +96 -0
  32. package/dist/modal/components/ExternalWallets/ExternalWallets.js +172 -0
  33. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +124 -0
  34. package/dist/modal/components/Footer/Footer.js +93 -0
  35. package/dist/modal/components/Header/Header.js +43 -0
  36. package/dist/modal/components/Header/hooks/useStepTitle.js +50 -0
  37. package/dist/modal/components/Hero/Hero.js +116 -0
  38. package/dist/modal/components/IFrameStep/IFrameStep.js +55 -0
  39. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +28 -0
  40. package/dist/modal/components/ModalContent/ModalContent.js +324 -0
  41. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
  42. package/dist/modal/components/OAuth/OAuth.js +153 -0
  43. package/dist/modal/components/OAuth/TelegramOAuthStep.js +139 -0
  44. package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
  45. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
  46. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +101 -0
  47. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +141 -0
  48. package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
  49. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +24 -0
  50. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +159 -0
  51. package/dist/modal/components/Waiting/Waiting.js +17 -0
  52. package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
  53. package/dist/modal/components/WalletCard/WalletCard.js +127 -0
  54. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +52 -0
  55. package/dist/modal/components/common.d.ts +6 -6
  56. package/dist/modal/components/common.js +96 -0
  57. package/dist/modal/components/index.js +2 -0
  58. package/dist/modal/constants/constants.d.ts +1 -1
  59. package/dist/modal/constants/constants.js +112 -0
  60. package/dist/modal/constants/defaults.js +10 -0
  61. package/dist/modal/constants/oAuthLogos.js +24 -0
  62. package/dist/modal/hooks/useActiveWallet.js +15 -0
  63. package/dist/modal/hooks/useCreateAccount.d.ts +3 -1
  64. package/dist/modal/hooks/useCreateAccount.js +77 -0
  65. package/dist/modal/hooks/useEmbeddedExternalConnection.js +54 -0
  66. package/dist/modal/hooks/useGoBack.js +42 -0
  67. package/dist/modal/hooks/useSetLoginURLs.js +49 -0
  68. package/dist/modal/hooks/useWalletBalance.d.ts +4 -0
  69. package/dist/modal/hooks/useWalletBalance.js +47 -0
  70. package/dist/modal/index.js +33 -0
  71. package/dist/modal/providers/CosmosExternalWalletContextStub.js +38 -0
  72. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +2 -0
  73. package/dist/modal/providers/EvmExternalWalletContextStub.js +55 -0
  74. package/dist/modal/providers/ExternalWalletContext.d.ts +3 -0
  75. package/dist/modal/providers/ExternalWalletContext.js +394 -0
  76. package/dist/modal/providers/SolanaExternalWalletContextStub.js +32 -0
  77. package/dist/modal/stores/externalWalletProvider/actions.js +10 -0
  78. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +21 -0
  79. package/dist/modal/stores/index.js +4 -0
  80. package/dist/modal/stores/modal/actions.js +70 -0
  81. package/dist/modal/stores/modal/useModalStore.js +65 -0
  82. package/dist/modal/stores/theme/actions.js +28 -0
  83. package/dist/modal/stores/theme/useThemeStore.js +21 -0
  84. package/dist/modal/stores/userInfo/actions.js +30 -0
  85. package/dist/modal/stores/userInfo/useUserInfoStore.js +17 -0
  86. package/dist/modal/types/commonTypes.js +1 -0
  87. package/dist/modal/types/externalWallets.js +32 -0
  88. package/dist/modal/types/modalProps.d.ts +4 -0
  89. package/dist/modal/types/modalProps.js +12 -0
  90. package/dist/modal/utils/authLayoutHelpers.js +8 -0
  91. package/dist/modal/utils/getMailtoLink.js +10 -0
  92. package/dist/modal/utils/getTileButtonFlex.js +20 -0
  93. package/dist/modal/utils/openPopup.js +60 -0
  94. package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
  95. package/dist/modal/utils/steps.js +232 -0
  96. package/dist/modal/utils/stringFormatters.d.ts +1 -0
  97. package/dist/modal/utils/stringFormatters.js +19 -0
  98. package/dist/modal/utils/validateOnRampConfig.js +32 -0
  99. package/dist/package.json +3 -1
  100. package/dist/provider/ParaProvider.js +22 -0
  101. package/dist/provider/actions/checkIfUserExists.js +21 -0
  102. package/dist/provider/actions/createUser.js +26 -0
  103. package/dist/provider/actions/getAccount.js +22 -0
  104. package/dist/provider/actions/getWallet.js +14 -0
  105. package/dist/provider/actions/getWalletBalance.d.ts +2 -0
  106. package/dist/provider/actions/getWalletBalance.js +14 -0
  107. package/dist/provider/actions/initiateLogin.js +20 -0
  108. package/dist/provider/actions/keepSessionAlive.js +20 -0
  109. package/dist/provider/actions/logout.js +17 -0
  110. package/dist/provider/actions/signMessage.js +20 -0
  111. package/dist/provider/actions/signTransaction.js +20 -0
  112. package/dist/provider/actions/waitForAccountCreation.js +21 -0
  113. package/dist/provider/actions/waitForLoginAndSetup.js +24 -0
  114. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +21 -0
  115. package/dist/provider/hooks/index.js +4 -0
  116. package/dist/provider/hooks/mutations/index.js +24 -0
  117. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
  118. package/dist/provider/hooks/mutations/useCreateUser.js +20 -0
  119. package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
  120. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +20 -0
  121. package/dist/provider/hooks/mutations/useLogout.js +30 -0
  122. package/dist/provider/hooks/mutations/useSignMessage.js +39 -0
  123. package/dist/provider/hooks/mutations/useSignTransaction.js +39 -0
  124. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
  125. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
  126. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
  127. package/dist/provider/hooks/queries/index.d.ts +1 -0
  128. package/dist/provider/hooks/queries/index.js +10 -0
  129. package/dist/provider/hooks/queries/useAccount.js +21 -0
  130. package/dist/provider/hooks/queries/useWallet.js +22 -0
  131. package/dist/provider/hooks/queries/useWalletBalance.d.ts +7 -0
  132. package/dist/provider/hooks/queries/useWalletBalance.js +26 -0
  133. package/dist/provider/hooks/utils/index.js +10 -0
  134. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
  135. package/dist/provider/hooks/utils/useClient.js +10 -0
  136. package/dist/provider/hooks/utils/useEventListeners.js +105 -0
  137. package/dist/provider/hooks/utils/useInternalClient.js +10 -0
  138. package/dist/provider/hooks/utils/useModal.js +17 -0
  139. package/dist/provider/hooks/utils/useWalletState.js +33 -0
  140. package/dist/provider/index.js +8 -0
  141. package/dist/provider/stores/getters.js +13 -0
  142. package/dist/provider/stores/slices/client.js +9 -0
  143. package/dist/provider/stores/slices/index.js +4 -0
  144. package/dist/provider/stores/slices/modal.js +9 -0
  145. package/dist/provider/stores/slices/wallet.js +13 -0
  146. package/dist/provider/stores/types.d.ts +2 -0
  147. package/dist/provider/stores/types.js +1 -0
  148. package/dist/provider/stores/useStore.js +27 -0
  149. package/dist/provider/types/provider.js +1 -0
  150. package/dist/provider/types/query.js +1 -0
  151. package/dist/provider/types/utils.js +1 -0
  152. package/dist/provider/utils/constants.js +11 -0
  153. package/dist/provider/utils/renameMutations.js +16 -0
  154. package/package.json +5 -5
  155. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  156. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  157. package/dist/chunk-MMUBH76A.js.br +0 -0
  158. package/dist/chunk-MMUBH76A.js.gz +0 -0
  159. package/dist/index.js.br +0 -0
  160. package/dist/index.js.gz +0 -0
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import {
3
+ __spreadValues
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { CpslButton, CpslDivider, CpslIcon } from "@getpara/react-components";
7
+ import { useMemo } from "react";
8
+ import { useModalStore, useUserInfoStore } from "../../stores/index.js";
9
+ import { ModalStep } from "../../utils/steps.js";
10
+ import { Heading, StepContainer, InnerStepContainer } from "../common.js";
11
+ import { openPopup } from "../../utils/openPopup.js";
12
+ import styled from "styled-components";
13
+ import { AuthMethod } from "@getpara/web-sdk";
14
+ import { formatBiometricHints, KnownDevices, UserIdentifier } from "@getpara/react-common";
15
+ const BiometricLoginStep = () => {
16
+ const refs = useModalStore((state) => state.refs);
17
+ const supportedAuthMethods = useModalStore((state) => state.supportedAuthMethods);
18
+ const passwordUrlForLogin = useModalStore((state) => state.passwordUrlForLogin);
19
+ const webAuthURLForLogin = useModalStore((state) => state.webAuthURLForLogin);
20
+ const setStep = useModalStore((state) => state.setStep);
21
+ const biometricLocationHints = useModalStore((state) => state.biometricLocationHints);
22
+ const authInfo = useUserInfoStore((state) => state.getAuthInfo());
23
+ const passkeysSupported = useModalStore((state) => state.isPasskeySupported);
24
+ const formattedHints = useMemo(() => formatBiometricHints(biometricLocationHints), [biometricLocationHints]);
25
+ const handlePasskeyClick = () => {
26
+ refs.popupWindow.current = openPopup({
27
+ url: webAuthURLForLogin,
28
+ target: "ParaPasskey",
29
+ type: "LOGIN_PASSKEY",
30
+ current: refs.popupWindow.current
31
+ });
32
+ setStep(ModalStep.AWAITING_BIOMETRIC_LOGIN);
33
+ };
34
+ const handlePasswordClick = () => {
35
+ refs.popupWindow.current = openPopup({
36
+ url: passwordUrlForLogin,
37
+ target: "ParaPassword",
38
+ type: "LOGIN_PASSWORD",
39
+ current: refs.popupWindow.current
40
+ });
41
+ setStep(ModalStep.AWAITING_PASSWORD_LOGIN);
42
+ };
43
+ function shouldShowWelcomeBack() {
44
+ return !(biometricLocationHints == null ? void 0 : biometricLocationHints.length) || passkeysSupported && formattedHints.isOnKnownDevice || (supportedAuthMethods == null ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSWORD);
45
+ }
46
+ return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
47
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
48
+ shouldShowWelcomeBack() && /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Welcome back," }),
49
+ /* @__PURE__ */ jsx(UserIdentifier, __spreadValues({}, authInfo))
50
+ ] }),
51
+ /* @__PURE__ */ jsxs(MainContainer, { children: [
52
+ (supportedAuthMethods == null ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSWORD) && passwordUrlForLogin && /* @__PURE__ */ jsx(PasswordOnly, { handlePasswordClick }),
53
+ (supportedAuthMethods == null ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSKEY) && webAuthURLForLogin && /* @__PURE__ */ jsx(
54
+ BiometricOnly,
55
+ {
56
+ handlePasskeyClick,
57
+ formattedHints,
58
+ shortLoginLink: webAuthURLForLogin,
59
+ passkeysSupported,
60
+ biometricLocationHints
61
+ }
62
+ )
63
+ ] })
64
+ ] });
65
+ };
66
+ const PasswordOnly = ({ handlePasswordClick }) => {
67
+ return /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: handlePasswordClick, children: "Login" });
68
+ };
69
+ const BiometricOnly = ({
70
+ handlePasskeyClick,
71
+ formattedHints,
72
+ shortLoginLink,
73
+ passkeysSupported,
74
+ biometricLocationHints = []
75
+ }) => {
76
+ const [hasHints, isOnKnownDevice] = [biometricLocationHints.length > 0, formattedHints.isOnKnownDevice];
77
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
78
+ (hasHints && !isOnKnownDevice || !passkeysSupported) && /* @__PURE__ */ jsx(KnownDevices, { hints: formattedHints, link: shortLoginLink }),
79
+ passkeysSupported && /* @__PURE__ */ jsxs(Fragment, { children: [
80
+ hasHints && !isOnKnownDevice && /* @__PURE__ */ jsx(CpslDivider, { children: "or" }),
81
+ /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: handlePasskeyClick, children: !hasHints || isOnKnownDevice ? /* @__PURE__ */ jsxs(Fragment, { children: [
82
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "key" }),
83
+ "Login with passkey"
84
+ ] }) : "Continue anyway" })
85
+ ] })
86
+ ] });
87
+ };
88
+ const MainContainer = styled(InnerStepContainer)`
89
+ gap: 16px;
90
+ `;
91
+ export {
92
+ BiometricLoginStep
93
+ };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { motion } from "framer-motion";
5
+ import { useEffect, useRef, useState } from "react";
6
+ import styled from "styled-components";
7
+ const AnimatedHeightWrapper = ({ children, className }) => {
8
+ const containerRef = useRef(null);
9
+ const [height, setHeight] = useState("auto");
10
+ useEffect(() => {
11
+ if (containerRef.current) {
12
+ const resizeObserver = new ResizeObserver((entries) => {
13
+ const observedHeight = entries[0].contentRect.height;
14
+ setHeight(observedHeight);
15
+ });
16
+ resizeObserver.observe(containerRef.current);
17
+ return () => {
18
+ resizeObserver.disconnect();
19
+ };
20
+ }
21
+ }, []);
22
+ return /* @__PURE__ */ jsx(Container, { className, style: { height }, animate: { height }, transition: { duration: 0.2 }, children: /* @__PURE__ */ jsx("div", { ref: containerRef, children }) });
23
+ };
24
+ const Container = styled(motion.div)`
25
+ overflow: hidden;
26
+ `;
27
+ export {
28
+ AnimatedHeightWrapper
29
+ };
@@ -0,0 +1,308 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { styled } from "styled-components";
5
+ import { IFrameSteps, ModalStep } from "../../utils/steps.js";
6
+ import { CpslAlert, CpslIcon } from "@getpara/react-components";
7
+ import { VerificationCodeStep } from "../VerificationCodeStep/VerificationCodeStep.js";
8
+ import { ExternalWalletVerificationStep } from "../ExternalWalletVerificationStep/ExternalWalletVerificationStep.js";
9
+ import { useModalStore, useThemeStore } from "../../stores/index.js";
10
+ import { BiometricLoginStep } from "../BiometricLoginStep/BiometricLoginStep.js";
11
+ import { Setup2FAStep } from "../Setup2FAStep/Setup2FAStep.js";
12
+ import { LoginDoneStep } from "../LoginDoneStep/LoginDoneStep.js";
13
+ import { EnabledFlow } from "@getpara/web-sdk";
14
+ import { AwaitingBiometricsStep } from "../AwaitingBiometricsStep/AwaitingBiometricsStep.js";
15
+ import { AwaitingWalletCreationStep } from "../AwaitingWalletCreationStep/AwaitingWalletCreationStep.js";
16
+ import { WalletCreationDoneStep } from "../WalletCreationDoneStep/WalletCreationDoneStep.js";
17
+ import { RecoverySecretStep } from "../RecoverySecretStep/RecoverySecretStep.js";
18
+ import { TwoFactorDoneStep } from "../TwoFactorDoneStep/TwoFactorDoneStep.js";
19
+ import { BiometricCreationStep } from "../BiometricCreationStep/BiometricCreationStep.js";
20
+ import { AwaitingOAuthStep } from "../AwaitingOAuthStep/AwaitingOAuthStep.js";
21
+ import { AddFundsAwaiting, AddFundsDone, AddFunds } from "../AddFunds/index.js";
22
+ import FarcasterOAuthStep from "../OAuth/FarcasterOAuthStep.js";
23
+ import { Header } from "../Header/Header.js";
24
+ import { AuthMainStep } from "../AuthMainStep/AuthMainStep.js";
25
+ import { BODY_MOTION_VARIANTS, BODY_TRANSITION, MOBILE_SIZE } from "../../constants/constants.js";
26
+ import { Account } from "../Account/Account.js";
27
+ import { AuthOptions } from "../AuthOptions/AuthOptions.js";
28
+ import { ExternalWallets } from "../ExternalWallets/ExternalWallets.js";
29
+ import { ExternalWalletStep } from "../ExternalWalletStep/ExternalWalletStep.js";
30
+ import { Hero } from "../Hero/Hero.js";
31
+ import { AnimatedHeightWrapper } from "./AnimatedHeightWrapper.js";
32
+ import { ChainSwitch } from "../ChainSwitch/ChainSwitch.js";
33
+ import { motion, AnimatePresence } from "framer-motion";
34
+ import { Controls } from "../Controls/Controls.js";
35
+ import { useEffect, useState } from "react";
36
+ import { TelegramOAuthStep } from "../OAuth/TelegramOAuthStep.js";
37
+ import { AwaitingPasswordStep } from "../AwaitingPasswordStep/AwaitingPasswordStep.js";
38
+ import { IFrameStep } from "../IFrameStep/IFrameStep.js";
39
+ const MIN_HEIGHT = {
40
+ [ModalStep.ADD_FUNDS_AWAITING]: "680px"
41
+ };
42
+ const PADDING_TOP = {
43
+ [ModalStep.TELEGRAM_OAUTH]: "36px"
44
+ };
45
+ const PADDING_BOTTOM = {
46
+ [ModalStep.TELEGRAM_OAUTH]: "16px"
47
+ };
48
+ const Body = ({ oAuthMethods, twoFactorAuthEnabled, disableEmailLogin, disablePhoneLogin, onClose }) => {
49
+ const currentStep = useModalStore((state) => state.step);
50
+ const onRampConfig = useModalStore((state) => state.onRampConfig);
51
+ const stepDirection = useModalStore((state) => state.stepDirection);
52
+ const setStepDirection = useModalStore((state) => state.setStepDirection);
53
+ const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
54
+ const setAccountAddFundTab = useModalStore((state) => state.setAccountAddFundTab);
55
+ const appName = useThemeStore((state) => state.appName);
56
+ const embeddedModal = useThemeStore((state) => state.embeddedModal);
57
+ const [isTestModeAlert, setIsTestModeAlert] = useState(onRampConfig == null ? void 0 : onRampConfig.testMode);
58
+ const Content = () => {
59
+ switch (currentStep) {
60
+ case ModalStep.AUTH_MAIN: {
61
+ return /* @__PURE__ */ jsx(
62
+ AuthMainStep,
63
+ {
64
+ oAuthMethods,
65
+ disableEmailLogin,
66
+ disablePhoneLogin
67
+ }
68
+ );
69
+ }
70
+ case ModalStep.EX_WALLET_MORE: {
71
+ return /* @__PURE__ */ jsx(ExternalWallets, {});
72
+ }
73
+ case ModalStep.AUTH_MORE: {
74
+ return /* @__PURE__ */ jsx(
75
+ AuthOptions,
76
+ {
77
+ oAuthMethods,
78
+ disableEmailLogin,
79
+ disablePhoneLogin
80
+ }
81
+ );
82
+ }
83
+ case ModalStep.VERIFICATIONS: {
84
+ return /* @__PURE__ */ jsx(VerificationCodeStep, {});
85
+ }
86
+ case ModalStep.EXTERNAL_WALLET_VERIFICATION: {
87
+ return /* @__PURE__ */ jsx(ExternalWalletVerificationStep, {});
88
+ }
89
+ case ModalStep.BIOMETRIC_LOGIN: {
90
+ return /* @__PURE__ */ jsx(BiometricLoginStep, {});
91
+ }
92
+ case ModalStep.SETUP_2FA:
93
+ case ModalStep.VERIFY_2FA: {
94
+ return /* @__PURE__ */ jsx(Setup2FAStep, { onClose });
95
+ }
96
+ case ModalStep.LOGIN_DONE: {
97
+ return /* @__PURE__ */ jsx(LoginDoneStep, { onClose });
98
+ }
99
+ case ModalStep.AWAITING_BIOMETRIC_LOGIN:
100
+ case ModalStep.AWAITING_BIOMETRIC_CREATION: {
101
+ return /* @__PURE__ */ jsx(AwaitingBiometricsStep, {});
102
+ }
103
+ case ModalStep.AWAITING_PASSWORD_LOGIN:
104
+ case ModalStep.AWAITING_PASSWORD_CREATION: {
105
+ return /* @__PURE__ */ jsx(AwaitingPasswordStep, {});
106
+ }
107
+ case ModalStep.AWAITING_WALLET_CREATION: {
108
+ return /* @__PURE__ */ jsx(AwaitingWalletCreationStep, {});
109
+ }
110
+ case ModalStep.WALLET_CREATION_DONE: {
111
+ return /* @__PURE__ */ jsx(WalletCreationDoneStep, { twoFactorAuthEnabled, onClose });
112
+ }
113
+ case ModalStep.SECRET: {
114
+ return /* @__PURE__ */ jsx(RecoverySecretStep, {});
115
+ }
116
+ case ModalStep.TWO_FACTOR_DONE: {
117
+ return /* @__PURE__ */ jsx(TwoFactorDoneStep, { onClose });
118
+ }
119
+ case ModalStep.BIOMETRIC_CREATION: {
120
+ return /* @__PURE__ */ jsx(BiometricCreationStep, { twoFactorAuthEnabled });
121
+ }
122
+ case ModalStep.AWAITING_OAUTH: {
123
+ return /* @__PURE__ */ jsx(AwaitingOAuthStep, {});
124
+ }
125
+ case ModalStep.FARCASTER_OAUTH: {
126
+ return /* @__PURE__ */ jsx(FarcasterOAuthStep, {});
127
+ }
128
+ case ModalStep.TELEGRAM_OAUTH: {
129
+ return /* @__PURE__ */ jsx(TelegramOAuthStep, {});
130
+ }
131
+ case ModalStep.ADD_FUNDS_BUY:
132
+ case ModalStep.ADD_FUNDS_RECEIVE:
133
+ case ModalStep.ADD_FUNDS_WITHDRAW: {
134
+ return /* @__PURE__ */ jsx(AddFunds, {});
135
+ }
136
+ case ModalStep.ADD_FUNDS_AWAITING: {
137
+ return /* @__PURE__ */ jsx(AddFundsAwaiting, {});
138
+ }
139
+ case ModalStep.ADD_FUNDS_SUCCESS: {
140
+ return /* @__PURE__ */ jsx(AddFundsDone, { isSuccess: true, onClose });
141
+ }
142
+ case ModalStep.ADD_FUNDS_FAILURE: {
143
+ return /* @__PURE__ */ jsx(AddFundsDone, { onClose });
144
+ }
145
+ case ModalStep.ACCOUNT_MAIN: {
146
+ return /* @__PURE__ */ jsx(Account, { onClose });
147
+ }
148
+ case ModalStep.EX_WALLET_SELECTED: {
149
+ return /* @__PURE__ */ jsx(ExternalWalletStep, {});
150
+ }
151
+ case ModalStep.CHAIN_SWITCH: {
152
+ return /* @__PURE__ */ jsx(ChainSwitch, {});
153
+ }
154
+ default: {
155
+ if (IFrameSteps.includes(currentStep)) {
156
+ return null;
157
+ }
158
+ }
159
+ }
160
+ };
161
+ useEffect(() => {
162
+ if (!isTestModeAlert && (onRampConfig == null ? void 0 : onRampConfig.testMode)) {
163
+ setIsTestModeAlert(true);
164
+ }
165
+ }, [onRampConfig == null ? void 0 : onRampConfig.testMode]);
166
+ useEffect(() => {
167
+ switch (currentStep) {
168
+ case ModalStep.ADD_FUNDS_BUY:
169
+ setAccountAddFundTab(EnabledFlow.BUY);
170
+ break;
171
+ case ModalStep.ADD_FUNDS_RECEIVE:
172
+ setAccountAddFundTab(EnabledFlow.RECEIVE);
173
+ break;
174
+ case ModalStep.ADD_FUNDS_WITHDRAW:
175
+ setAccountAddFundTab(EnabledFlow.WITHDRAW);
176
+ break;
177
+ default:
178
+ break;
179
+ }
180
+ }, [currentStep]);
181
+ return /* @__PURE__ */ jsxs(Container, { slot: "body", "data-testid": "modal-content", children: [
182
+ !embeddedModal && /* @__PURE__ */ jsxs(Fragment, { children: [
183
+ /* @__PURE__ */ jsx(Controls, { onClose }),
184
+ /* @__PURE__ */ jsx(Header, {})
185
+ ] }),
186
+ /* @__PURE__ */ jsxs(AnimatedWrapper, { children: [
187
+ /* @__PURE__ */ jsx(
188
+ AnimatePresence,
189
+ {
190
+ mode: "popLayout",
191
+ initial: false,
192
+ onExitComplete: () => {
193
+ setStepDirection(1);
194
+ },
195
+ custom: stepDirection,
196
+ children: /* @__PURE__ */ jsxs(
197
+ BodyContainer,
198
+ {
199
+ custom: stepDirection,
200
+ variants: BODY_MOTION_VARIANTS,
201
+ initial: "enter",
202
+ animate: "center",
203
+ exit: "exit",
204
+ transition: BODY_TRANSITION,
205
+ children: [
206
+ /* @__PURE__ */ jsx(Hero, {}),
207
+ /* @__PURE__ */ jsxs(
208
+ InnerContainer,
209
+ {
210
+ $embeddedModal: embeddedModal,
211
+ $step: currentStep,
212
+ $isIFrameStep: IFrameSteps.includes(currentStep),
213
+ children: [
214
+ Content(),
215
+ (onRampConfig == null ? void 0 : onRampConfig.testMode) && [
216
+ ModalStep.ADD_FUNDS_BUY,
217
+ ModalStep.ADD_FUNDS_WITHDRAW,
218
+ ModalStep.ADD_FUNDS_AWAITING,
219
+ ModalStep.ADD_FUNDS_FAILURE,
220
+ ModalStep.ADD_FUNDS_SUCCESS
221
+ ].includes(currentStep) && isTestModeAlert && accountAddFundTab !== EnabledFlow.RECEIVE && /* @__PURE__ */ jsx(TestModeAlert, { children: /* @__PURE__ */ jsxs("div", { style: { fontSize: "14px" }, children: [
222
+ "This Para Modal is configured to run on-ramp services in ",
223
+ /* @__PURE__ */ jsx("b", { children: "test mode" }),
224
+ " only, for development purposes. If you are a user of ",
225
+ appName,
226
+ ", please contact support.",
227
+ /* @__PURE__ */ jsx(CloseButton, { onClick: () => setIsTestModeAlert(false), children: /* @__PURE__ */ jsx(CloseX, { icon: "x" }) })
228
+ ] }) })
229
+ ]
230
+ }
231
+ )
232
+ ]
233
+ },
234
+ ["ADD_FUNDS_BUY", "ADD_FUNDS_RECEIVE", "ADD_FUNDS_WITHDRAW"].includes(currentStep) ? "ADD_FUNDS" : currentStep
235
+ )
236
+ }
237
+ ),
238
+ /* @__PURE__ */ jsx(IFrameStep, {})
239
+ ] })
240
+ ] });
241
+ };
242
+ const Container = styled.div`
243
+ position: relative;
244
+ `;
245
+ const AnimatedWrapper = styled(AnimatedHeightWrapper)`
246
+ margin-top: -16px;
247
+ `;
248
+ const BodyContainer = styled(motion.div)`
249
+ position: relative;
250
+ display: flex;
251
+ flex-direction: column;
252
+ gap: 24px;
253
+ will-change: auto !important;
254
+ `;
255
+ const InnerContainer = styled.div`
256
+ z-index: 1;
257
+ flex: 1;
258
+ display: flex;
259
+ flex-direction: column;
260
+ justify-content: flex-start;
261
+ gap: 24px;
262
+ padding: ${({ $embeddedModal, $step, $isIFrameStep }) => {
263
+ var _a, _b;
264
+ return $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : `${(_a = PADDING_TOP[$step]) != null ? _a : "72px"} 72px ${(_b = PADDING_BOTTOM[$step]) != null ? _b : "32px"}`;
265
+ }};
266
+ min-height: ${({ $step }) => {
267
+ var _a;
268
+ return (_a = MIN_HEIGHT[$step]) != null ? _a : "auto";
269
+ }};
270
+ height: ${({ $step }) => {
271
+ var _a;
272
+ return (_a = MIN_HEIGHT[$step]) != null ? _a : "auto";
273
+ }};
274
+
275
+ @media (max-width: ${MOBILE_SIZE}px) {
276
+ padding: ${({ $embeddedModal, $step, $isIFrameStep }) => {
277
+ var _a;
278
+ return $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : `${(_a = PADDING_TOP[$step]) != null ? _a : "72px"} 16px 0px`;
279
+ }};
280
+ }
281
+
282
+ cpsl-auth-modal.force-mobile-media & {
283
+ padding: 72px 16px 0px;
284
+ }
285
+ `;
286
+ const TestModeAlert = styled(CpslAlert)`
287
+ --container-padding-end: 40px;
288
+ position: absolute;
289
+ bottom: 16px;
290
+ left: 16px;
291
+ right: 16px;
292
+ z-index: 1000;
293
+ `;
294
+ const CloseButton = styled.button`
295
+ background-color: transparent;
296
+ border: none;
297
+ padding: 4px;
298
+ cursor: pointer;
299
+ position: absolute;
300
+ top: 0;
301
+ right: 0;
302
+ `;
303
+ const CloseX = styled(CpslIcon)`
304
+ --icon-color: var(--cpsl-color-foreground-0);
305
+ `;
306
+ export {
307
+ Body
308
+ };
@@ -0,0 +1,94 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
7
+ import { CenteredText, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
8
+ import { useEffect, useMemo } from "react";
9
+ import { useModalStore } from "../../stores/index.js";
10
+ import styled from "styled-components";
11
+ import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
12
+ import { useCopyToClipboard } from "@getpara/react-common";
13
+ import { ModalStep } from "../../utils/steps.js";
14
+ import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
15
+ import { NETWORK_NOT_SUPPORTED_ERROR } from "../../constants/constants.js";
16
+ import { WalletType } from "@getpara/web-sdk";
17
+ const ChainSwitch = () => {
18
+ const [isCopied, copy] = useCopyToClipboard();
19
+ const externalWalletError = useModalStore((state) => state.externalWalletError);
20
+ const setStep = useModalStore((state) => state.setStep);
21
+ const setStepDirection = useModalStore((state) => state.setStepDirection);
22
+ const { switchChain, wallet, qrUri, chainIdSwitchingTo, walletDisplayHelpers } = useExternalWallets();
23
+ useEffect(() => {
24
+ if ((wallet == null ? void 0 : wallet.type) === WalletType.COSMOS) {
25
+ routeMobileExternalWallet(qrUri);
26
+ }
27
+ }, [qrUri, wallet]);
28
+ useEffect(() => {
29
+ if (!wallet) {
30
+ setStepDirection(-1);
31
+ setStep(ModalStep.ACCOUNT_MAIN);
32
+ }
33
+ }, [wallet]);
34
+ const handleTryAgainClick = () => __async(void 0, null, function* () {
35
+ if (chainIdSwitchingTo) {
36
+ yield switchChain(chainIdSwitchingTo);
37
+ }
38
+ });
39
+ const handleCopy = () => {
40
+ copy(qrUri);
41
+ };
42
+ const Content = useMemo(() => {
43
+ var _a;
44
+ if (!wallet) {
45
+ return null;
46
+ }
47
+ const { isCosmosMobileWallet } = walletDisplayHelpers;
48
+ if (isCosmosMobileWallet) {
49
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
50
+ /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device to switch networks" }),
51
+ /* @__PURE__ */ jsx(QRContainer, { children: !qrUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }),
52
+ /* @__PURE__ */ jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [
53
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
54
+ isCopied ? "Copied" : "Copy Link"
55
+ ] })
56
+ ] }) });
57
+ }
58
+ return /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
59
+ !(externalWalletError == null ? void 0 : externalWalletError.length) ? /* @__PURE__ */ jsx(CenteredText, { color: "contrast", weight: "semiBold", children: `Confirm the request to change networks in your ${wallet.name} wallet.` }) : /* @__PURE__ */ jsxs(Fragment, { children: [
60
+ /* @__PURE__ */ jsxs(ErrorContainer, { children: [
61
+ /* @__PURE__ */ jsx(ErrorIcon, { icon: "alertCircle" }),
62
+ /* @__PURE__ */ jsx(CenteredText, { weight: "semiBold", color: "error", children: externalWalletError[0] })
63
+ ] }),
64
+ externalWalletError[1] && /* @__PURE__ */ jsx(CenteredText, { color: "secondary", weight: "medium", children: externalWalletError[1] })
65
+ ] }),
66
+ ((_a = externalWalletError == null ? void 0 : externalWalletError[0]) == null ? void 0 : _a.toLowerCase()) !== NETWORK_NOT_SUPPORTED_ERROR && /* @__PURE__ */ jsxs(CpslButton, { variant: "secondary", onClick: handleTryAgainClick, children: [
67
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "refresh" }),
68
+ "Try Again"
69
+ ] })
70
+ ] });
71
+ }, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
72
+ if (!wallet) {
73
+ return null;
74
+ }
75
+ return /* @__PURE__ */ jsx(Container, { children: Content });
76
+ };
77
+ const Container = styled(StepContainer)`
78
+ flex: 1;
79
+ justify-content: space-between;
80
+ `;
81
+ const ErrorContainer = styled.div`
82
+ display: flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ gap: 4px;
86
+ `;
87
+ const ErrorIcon = styled(CpslIcon)`
88
+ --height: 16px;
89
+ --width: 16px;
90
+ --icon-color: var(--cpsl-color-text-error);
91
+ `;
92
+ export {
93
+ ChainSwitch
94
+ };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ var TabValue = /* @__PURE__ */ ((TabValue2) => {
4
+ TabValue2["extension"] = "extension";
5
+ TabValue2["mobile"] = "mobile";
6
+ TabValue2["web"] = "web";
7
+ return TabValue2;
8
+ })(TabValue || {});
9
+ const TABS = {
10
+ extension: { label: "Extension", value: "extension" /* extension */, icon: "puzzlePiece" },
11
+ mobile: { label: "Mobile", value: "mobile" /* mobile */, icon: "phone" },
12
+ web: { label: "Web", value: "web" /* web */, icon: "globe" }
13
+ };
14
+ export {
15
+ TABS,
16
+ TabValue
17
+ };
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslIcon } from "@getpara/react-components";
5
+ import { styled } from "styled-components";
6
+ import { useModalStore } from "../../stores/index.js";
7
+ import { useThemeStore } from "../../stores/theme/useThemeStore.js";
8
+ import { useGoBack } from "../../hooks/useGoBack.js";
9
+ import { AccountSelect, ChainSelect } from "./Selects.js";
10
+ import { ModalStep } from "../../utils/steps.js";
11
+ import { HeaderButton } from "@getpara/react-common";
12
+ const Controls = ({ onClose }) => {
13
+ const bareModal = useThemeStore((state) => state.bareModal);
14
+ const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
15
+ const step = useModalStore((state) => state.step);
16
+ const isFullyLoggedIn = useModalStore((state) => state.isFullyLoggedIn);
17
+ const goBack = useGoBack();
18
+ const shouldShowSelects = [
19
+ ModalStep.ACCOUNT_MAIN,
20
+ ModalStep.CHAIN_SWITCH,
21
+ ModalStep.ADD_FUNDS_BUY,
22
+ ModalStep.ADD_FUNDS_RECEIVE,
23
+ ModalStep.ADD_FUNDS_WITHDRAW
24
+ ].includes(step);
25
+ const handleBackClick = () => {
26
+ goBack();
27
+ };
28
+ return /* @__PURE__ */ jsxs(Container, { children: [
29
+ /* @__PURE__ */ jsx(
30
+ BackButton,
31
+ {
32
+ variant: "ghost",
33
+ style: {
34
+ visibility: hasPreviousStep ? "visible" : "hidden"
35
+ },
36
+ onClick: handleBackClick,
37
+ children: /* @__PURE__ */ jsx(CpslIcon, { icon: "arrow" })
38
+ }
39
+ ),
40
+ /* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects && isFullyLoggedIn && /* @__PURE__ */ jsxs(Fragment, { children: [
41
+ /* @__PURE__ */ jsx(ChainSelect, {}),
42
+ /* @__PURE__ */ jsx(AccountSelect, {})
43
+ ] }) }),
44
+ /* @__PURE__ */ jsx(CloseButton, { bareModal, variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx(CpslIcon, { icon: "close" }) })
45
+ ] });
46
+ };
47
+ const Container = styled.div`
48
+ position: absolute;
49
+ width: 100%;
50
+ top: 16px;
51
+
52
+ z-index: 3;
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: space-between;
56
+ gap: 8px;
57
+ `;
58
+ const MiddleContainer = styled.div`
59
+ flex: 1;
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: center;
63
+ gap: 4px;
64
+ `;
65
+ const CloseButton = styled(HeaderButton)`
66
+ transform: rotate(180deg);
67
+ visibility: ${({ bareModal }) => bareModal ? "hidden" : "visible"};
68
+ `;
69
+ const BackButton = styled(HeaderButton)`
70
+ transform: rotate(180deg);
71
+ `;
72
+ export {
73
+ Controls
74
+ };