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

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 (183) hide show
  1. package/dist/cli/cli.mjs +1 -6
  2. package/dist/index.js +11 -6499
  3. package/dist/modal/ParaModal.js +262 -0
  4. package/dist/modal/components/Account/Account.js +139 -0
  5. package/dist/modal/components/AddFunds/AddFunds.d.ts +0 -2
  6. package/dist/modal/components/AddFunds/AddFunds.js +69 -0
  7. package/dist/modal/components/AddFunds/AddFundsAsset.d.ts +1 -0
  8. package/dist/modal/components/AddFunds/AddFundsAsset.js +125 -0
  9. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +78 -0
  10. package/dist/modal/components/AddFunds/AddFundsContext.d.ts +31 -0
  11. package/dist/modal/components/AddFunds/AddFundsContext.js +160 -0
  12. package/dist/modal/components/AddFunds/AddFundsDone.js +49 -0
  13. package/dist/modal/components/AddFunds/AddFundsProvider.d.ts +1 -0
  14. package/dist/modal/components/AddFunds/AddFundsProvider.js +109 -0
  15. package/dist/modal/components/AddFunds/AddFundsReceive.d.ts +1 -0
  16. package/dist/modal/components/AddFunds/AddFundsReceive.js +83 -0
  17. package/dist/modal/components/AddFunds/AddFundsSettings.d.ts +1 -0
  18. package/dist/modal/components/AddFunds/AddFundsSettings.js +237 -0
  19. package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
  20. package/dist/modal/components/AddFunds/common.d.ts +19 -0
  21. package/dist/modal/components/AddFunds/common.js +24 -0
  22. package/dist/modal/components/AddFunds/index.js +4 -0
  23. package/dist/modal/components/AuthInput/AuthInput.js +262 -0
  24. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
  25. package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
  26. package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
  27. package/dist/modal/components/AuthMainStep/AuthMainStep.js +50 -0
  28. package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
  29. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +157 -0
  30. package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
  31. package/dist/modal/components/AuthOptions/AuthOptions.js +67 -0
  32. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
  33. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
  34. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
  35. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
  36. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +49 -0
  37. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +63 -0
  38. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +55 -0
  39. package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
  40. package/dist/modal/components/Body/Body.d.ts +4 -3
  41. package/dist/modal/components/Body/Body.js +327 -0
  42. package/dist/modal/components/ChainSwitch/ChainSwitch.js +95 -0
  43. package/dist/modal/components/ChainSwitch/config.js +17 -0
  44. package/dist/modal/components/Controls/Controls.js +77 -0
  45. package/dist/modal/components/Controls/Selects.js +189 -0
  46. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +144 -0
  47. package/dist/modal/components/ExternalWalletStep/config.js +17 -0
  48. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +34 -0
  49. package/dist/modal/components/ExternalWallets/ExternalWallets.js +173 -0
  50. package/dist/modal/components/Footer/Footer.js +95 -0
  51. package/dist/modal/components/Header/Header.js +43 -0
  52. package/dist/modal/components/Header/hooks/useStepTitle.js +54 -0
  53. package/dist/modal/components/Hero/Hero.js +116 -0
  54. package/dist/modal/components/IFrameStep/IFrameStep.js +59 -0
  55. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +31 -0
  56. package/dist/modal/components/ModalContent/ModalContent.js +95 -0
  57. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +27 -0
  58. package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
  59. package/dist/modal/components/OAuth/OAuth.js +79 -0
  60. package/dist/modal/components/OAuth/TelegramOAuthStep.js +90 -0
  61. package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
  62. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
  63. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +107 -0
  64. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +132 -0
  65. package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
  66. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +27 -0
  67. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +143 -0
  68. package/dist/modal/components/Waiting/Waiting.js +17 -0
  69. package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
  70. package/dist/modal/components/WalletCard/WalletCard.d.ts +3 -3
  71. package/dist/modal/components/WalletCard/WalletCard.js +128 -0
  72. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +73 -0
  73. package/dist/modal/components/common.d.ts +32 -13
  74. package/dist/modal/components/common.js +175 -0
  75. package/dist/modal/components/index.js +2 -0
  76. package/dist/modal/constants/constants.d.ts +9 -2
  77. package/dist/modal/constants/constants.js +138 -0
  78. package/dist/modal/constants/defaults.js +10 -0
  79. package/dist/modal/constants/oAuthLogos.d.ts +3 -3
  80. package/dist/modal/constants/oAuthLogos.js +24 -0
  81. package/dist/modal/hooks/useGoBack.js +43 -0
  82. package/dist/modal/index.d.ts +1 -2
  83. package/dist/modal/index.js +29 -0
  84. package/dist/modal/stores/index.js +2 -0
  85. package/dist/modal/stores/modal/actions.js +133 -0
  86. package/dist/modal/stores/modal/useModalStore.d.ts +12 -4
  87. package/dist/modal/stores/modal/useModalStore.js +68 -0
  88. package/dist/modal/types/commonTypes.d.ts +0 -47
  89. package/dist/modal/types/commonTypes.js +1 -0
  90. package/dist/modal/types/externalWallets.d.ts +2 -0
  91. package/dist/modal/types/externalWallets.js +32 -0
  92. package/dist/modal/types/modalProps.d.ts +10 -2
  93. package/dist/modal/types/modalProps.js +12 -0
  94. package/dist/modal/utils/authInputHelpers.d.ts +7 -0
  95. package/dist/modal/utils/authInputHelpers.js +38 -0
  96. package/dist/modal/utils/authLayoutHelpers.js +8 -0
  97. package/dist/modal/utils/countryCodes.js +45 -0
  98. package/dist/modal/utils/getMailtoLink.js +10 -0
  99. package/dist/modal/utils/getTileButtonFlex.js +20 -0
  100. package/dist/modal/utils/isPasskeySupported.js +15 -0
  101. package/dist/modal/utils/openPopup.js +60 -0
  102. package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
  103. package/dist/modal/utils/steps.d.ts +6 -0
  104. package/dist/modal/utils/steps.js +247 -0
  105. package/dist/modal/utils/stringFormatters.d.ts +1 -0
  106. package/dist/modal/utils/stringFormatters.js +19 -0
  107. package/dist/modal/utils/validateOnRampConfig.js +32 -0
  108. package/dist/package.json +6 -0
  109. package/dist/provider/ParaProvider.js +83 -0
  110. package/dist/provider/actions/getAccount.d.ts +8 -1
  111. package/dist/provider/actions/getAccount.js +51 -0
  112. package/dist/provider/actions/getWallet.d.ts +2 -2
  113. package/dist/provider/actions/getWallet.js +14 -0
  114. package/dist/provider/actions/index.d.ts +2 -0
  115. package/dist/provider/actions/index.js +59 -0
  116. package/dist/provider/actions/utils.js +15 -0
  117. package/dist/provider/components/CosmosWalletWrapper.js +34 -0
  118. package/dist/provider/components/EvmWalletWrapper.js +34 -0
  119. package/dist/provider/components/ExternalWalletWrapper.js +139 -0
  120. package/dist/provider/components/SolanaWalletWrapper.js +36 -0
  121. package/dist/provider/external/getParaCosmosConnector.js +22 -0
  122. package/dist/provider/external/getParaEvmConnector.js +22 -0
  123. package/dist/provider/external/getParaSolanaConnector.js +22 -0
  124. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
  125. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
  126. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
  127. package/dist/provider/hooks/index.js +4 -0
  128. package/dist/provider/hooks/mutations/index.d.ts +1 -0
  129. package/dist/provider/hooks/mutations/index.js +61 -0
  130. package/dist/provider/hooks/mutations/utils.js +22 -0
  131. package/dist/provider/hooks/queries/index.d.ts +1 -0
  132. package/dist/provider/hooks/queries/index.js +10 -0
  133. package/dist/provider/hooks/queries/useAccount.js +21 -0
  134. package/dist/provider/hooks/queries/useWallet.js +22 -0
  135. package/dist/provider/hooks/queries/useWalletBalance.d.ts +6 -0
  136. package/dist/provider/hooks/queries/useWalletBalance.js +55 -0
  137. package/dist/provider/hooks/utils/index.js +10 -0
  138. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
  139. package/dist/provider/hooks/utils/useClient.js +10 -0
  140. package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
  141. package/dist/provider/hooks/utils/useEventListeners.js +147 -0
  142. package/dist/provider/hooks/utils/useInternalClient.js +10 -0
  143. package/dist/provider/hooks/utils/useModal.js +17 -0
  144. package/dist/provider/hooks/utils/useWalletState.d.ts +3 -3
  145. package/dist/provider/hooks/utils/useWalletState.js +48 -0
  146. package/dist/provider/index.js +9 -0
  147. package/dist/provider/providers/AuthProvider.d.ts +10 -6
  148. package/dist/provider/providers/AuthProvider.js +498 -0
  149. package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
  150. package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
  151. package/dist/provider/providers/ExternalWalletProvider.d.ts +5 -2
  152. package/dist/provider/providers/ExternalWalletProvider.js +428 -0
  153. package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
  154. package/dist/provider/stores/getters.d.ts +1 -1
  155. package/dist/provider/stores/getters.js +13 -0
  156. package/dist/provider/stores/setters.js +7 -0
  157. package/dist/provider/stores/slices/client.js +9 -0
  158. package/dist/provider/stores/slices/config.js +9 -0
  159. package/dist/provider/stores/slices/externalWallets.js +40 -0
  160. package/dist/provider/stores/slices/index.js +5 -0
  161. package/dist/provider/stores/slices/modal.js +16 -0
  162. package/dist/provider/stores/slices/wallet.js +13 -0
  163. package/dist/provider/stores/types.d.ts +7 -4
  164. package/dist/provider/stores/types.js +1 -0
  165. package/dist/provider/stores/useStore.js +28 -0
  166. package/dist/provider/types/externalWalletProviders.d.ts +2 -2
  167. package/dist/provider/types/externalWalletProviders.js +1 -0
  168. package/dist/provider/types/provider.d.ts +9 -3
  169. package/dist/provider/types/provider.js +1 -0
  170. package/dist/provider/types/query.js +1 -0
  171. package/dist/provider/types/utils.js +1 -0
  172. package/dist/provider/utils/constants.d.ts +5 -0
  173. package/dist/provider/utils/constants.js +10 -0
  174. package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
  175. package/dist/provider/utils/renameMutations.js +18 -0
  176. package/package.json +18 -16
  177. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  178. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  179. package/dist/chunk-MMUBH76A.js.br +0 -0
  180. package/dist/chunk-MMUBH76A.js.gz +0 -0
  181. package/dist/index.js.br +0 -0
  182. package/dist/index.js.gz +0 -0
  183. /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { useState } from "react";
7
+ import { ON_RAMP_PROVIDERS } from "../../constants/constants.js";
8
+ import styled from "styled-components";
9
+ import { CpslButton, CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
10
+ import { motion } from "framer-motion";
11
+ const OnRampProviderButton = ({ config, index, onClick: _onClick }) => {
12
+ const [isLoading, setIsLoading] = useState(false);
13
+ const provider = config.providers[index];
14
+ const { feeLower, feeUpper, name, icon, backgroundColors } = ON_RAMP_PROVIDERS[provider];
15
+ const feeString = `Fee ${feeLower}% - ${feeUpper}%`;
16
+ const onClick = () => __async(void 0, null, function* () {
17
+ setIsLoading(true);
18
+ yield _onClick();
19
+ setIsLoading(false);
20
+ });
21
+ return /* @__PURE__ */ jsx(StyledButton, { $gradientColors: backgroundColors, fullWidth: true, onClick, children: /* @__PURE__ */ jsxs(Container, { $backgroundColor: backgroundColors[1], children: [
22
+ /* @__PURE__ */ jsx(IconContainer, { children: /* @__PURE__ */ jsx(CpslIcon, { icon }) }),
23
+ /* @__PURE__ */ jsxs(ProviderInfoContainer, { children: [
24
+ /* @__PURE__ */ jsx(Text, { variant: "bodyL", weight: "medium", children: name }),
25
+ /* @__PURE__ */ jsx(ProviderInfoInnerContainer, { children: /* @__PURE__ */ jsx(Text, { variant: "bodyXS", weight: "medium", children: feeString }) })
26
+ ] }),
27
+ isLoading ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsx(Chevron, { icon: "chevronUp" })
28
+ ] }) });
29
+ };
30
+ const StyledButton = styled(CpslButton)`
31
+ width: 100%;
32
+ --button-primary-background-color: ${({ $gradientColors }) => `linear-gradient(90deg, ${$gradientColors[0]} 0%, ${$gradientColors[1]} 100%)`};
33
+ --button-primary-hover-background-color: ${({ $gradientColors }) => `linear-gradient(90deg, ${$gradientColors[0]} 0%, ${$gradientColors[0]} 100%)`};
34
+ --button-primary-active-background-color: ${({ $gradientColors }) => `linear-gradient(90deg, ${$gradientColors[0]} 0%, ${$gradientColors[0]} 100%)`};
35
+ `;
36
+ const Container = styled(motion.div)`
37
+ display: flex;
38
+ gap: 8px;
39
+ flex: 1;
40
+ align-items: center;
41
+
42
+ & cpsl-spinner {
43
+ --background-color: ${({ $backgroundColor }) => `${$backgroundColor}`};
44
+ }
45
+ `;
46
+ const ProviderInfoContainer = styled.div`
47
+ flex: 1;
48
+ display: flex;
49
+ flex-direction: column;
50
+ align-items: start;
51
+ gap: 2px;
52
+ `;
53
+ const ProviderInfoInnerContainer = styled.div`
54
+ display: flex;
55
+ gap: 16px;
56
+ `;
57
+ const IconContainer = styled.span`
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ background-color: #fff;
62
+ border-radius: 100%;
63
+ height: 48px;
64
+ width: 48px;
65
+ `;
66
+ const Text = styled(CpslText)`
67
+ &::part(text-element) {
68
+ color: #fff;
69
+ }
70
+ `;
71
+ const Chevron = styled(CpslIcon)`
72
+ transform: rotate(90deg);
73
+ --icon-color: #fff;
74
+ `;
75
+ export {
76
+ OnRampProviderButton
77
+ };
@@ -0,0 +1,107 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { CpslButton, CpslText } from "@getpara/react-components";
7
+ import { useModalStore } from "../../stores/index.js";
8
+ import { ModalStep } from "../../utils/steps.js";
9
+ import { Heading, InnerStepContainer, StepContainer, StyledCpslTileButton } from "../common.js";
10
+ import { styled } from "styled-components";
11
+ import { useCopyToClipboard } from "@getpara/react-common";
12
+ import { getMailtoLink } from "../../utils/getMailtoLink.js";
13
+ import { useState } from "react";
14
+ import { useStore } from "../../../provider/stores/useStore.js";
15
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
16
+ const SaveRecoverySecret = ({
17
+ email,
18
+ value,
19
+ onComplete
20
+ }) => {
21
+ const [isSecretSaved, setIsSecretSaved] = useState(false);
22
+ const [isCopied, copy] = useCopyToClipboard();
23
+ const onCopy = () => {
24
+ copy(value);
25
+ setIsSecretSaved(true);
26
+ };
27
+ const onDownload = () => {
28
+ const element = document.createElement("a");
29
+ const file = new Blob([value], { type: "text/plain" });
30
+ element.href = URL.createObjectURL(file);
31
+ element.download = "recovery.txt";
32
+ document.body.appendChild(element);
33
+ element.click();
34
+ setIsSecretSaved(true);
35
+ };
36
+ const onEmail = () => {
37
+ typeof window !== "undefined" && window.open(getMailtoLink(email, value), "_self");
38
+ setIsSecretSaved(true);
39
+ };
40
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
41
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
42
+ /* @__PURE__ */ jsx(Heading, { variant: "headingXS", weight: "semiBold", children: "Save your Recovery Secret" }),
43
+ /* @__PURE__ */ jsxs(ButtonContainer, { children: [
44
+ /* @__PURE__ */ jsx(ActionButton, { icon: "download", onClick: onDownload, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Download" }) }),
45
+ /* @__PURE__ */ jsx(ActionButton, { icon: isCopied ? "check" : "copy", onClick: onCopy, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isCopied ? "Copied!" : "Copy" }) }),
46
+ /* @__PURE__ */ jsx(ActionButton, { icon: "send", onClick: onEmail, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Email" }) })
47
+ ] })
48
+ ] }),
49
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: onComplete, disabled: !isSecretSaved, children: !isSecretSaved ? "Choose an option above to continue" : "I\u2019ve saved my recovery secret" }) })
50
+ ] });
51
+ };
52
+ const RecoverySecretStep = () => {
53
+ const para = useInternalClient();
54
+ const hideWallets = useStore((state) => {
55
+ var _a;
56
+ return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
57
+ });
58
+ const setStep = useModalStore((state) => state.setStep);
59
+ const authInfo = para.authInfo;
60
+ const recoveryShare = useModalStore((state) => state.recoveryShare);
61
+ const backupDecryptionKey = JSON.parse(recoveryShare || "{}").backupDecryptionKey;
62
+ const onComplete = () => __async(void 0, null, function* () {
63
+ setStep(ModalStep.WALLET_CREATION_DONE);
64
+ });
65
+ return /* @__PURE__ */ jsxs(StepContainer, { children: [
66
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
67
+ /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: hideWallets ? "Don't lose access" : "Don't lose your wallet" }),
68
+ /* @__PURE__ */ jsxs(InlineText, { variant: "bodyS", color: "secondary", weight: "medium", children: [
69
+ "Your",
70
+ " ",
71
+ /* @__PURE__ */ jsx(InlineText, { variant: "bodyS", weight: "medium", children: "Recovery Secret" }),
72
+ " ",
73
+ "ensures you will be able to regain access to your ",
74
+ hideWallets ? "account" : "wallet",
75
+ " if you lose your Passkey or Password."
76
+ ] })
77
+ ] }),
78
+ /* @__PURE__ */ jsx(
79
+ SaveRecoverySecret,
80
+ {
81
+ email: (authInfo == null ? void 0 : authInfo.authType) === "email" ? authInfo.identifier : void 0,
82
+ value: backupDecryptionKey,
83
+ onComplete
84
+ }
85
+ )
86
+ ] });
87
+ };
88
+ const ActionButton = styled(StyledCpslTileButton)`
89
+ flex: 1;
90
+
91
+ --button-icon-color: var(--cpsl-color-text-primary);
92
+ `;
93
+ const ButtonContainer = styled.div`
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: center;
97
+ gap: 8px;
98
+ width: 100%;
99
+ `;
100
+ const InlineText = styled(CpslText)`
101
+ text-align: center;
102
+ display: inline-block;
103
+ `;
104
+ export {
105
+ RecoverySecretStep,
106
+ SaveRecoverySecret
107
+ };
@@ -0,0 +1,132 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import {
7
+ CpslButton,
8
+ CpslCodeInput,
9
+ CpslDivider,
10
+ CpslIcon,
11
+ CpslQrCode,
12
+ CpslSpinner,
13
+ CpslText
14
+ } from "@getpara/react-components";
15
+ import { useEffect, useRef, useState } from "react";
16
+ import { useModalStore } from "../../stores/index.js";
17
+ import { Heading, QRContainer, FilledDisabledInput, StepContainer, InnerStepContainer } from "../common.js";
18
+ import { ModalStep } from "../../utils/steps.js";
19
+ import { styled } from "styled-components";
20
+ import { useCopyToClipboard } from "@getpara/react-common";
21
+ import { useEnable2fa } from "../../../provider/index.js";
22
+ const Setup2FAStep = ({ onClose }) => {
23
+ const isLogin = useModalStore((state) => state.isLogin());
24
+ const setStep = useModalStore((state) => state.setStep);
25
+ const twoFactorStatus = useModalStore((state) => state.twoFactorStatus);
26
+ const { enable2fa, isPending } = useEnable2fa();
27
+ const isVerifying = useModalStore((state) => state.step === ModalStep.VERIFY_2FA);
28
+ const [copied, copy] = useCopyToClipboard();
29
+ const inputRef = useRef(null);
30
+ const [code, setCode] = useState("");
31
+ const [codeError, setCodeError] = useState("");
32
+ const params = (twoFactorStatus == null ? void 0 : twoFactorStatus.uri) ? new URL(twoFactorStatus.uri).searchParams : void 0;
33
+ const secret = params == null ? void 0 : params.get("secret");
34
+ useEffect(() => {
35
+ setTimeout(() => {
36
+ var _a, _b, _c, _d;
37
+ (_d = (_c = (_b = (_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelectorAll("input")) == null ? void 0 : _c[0]) == null ? void 0 : _d.focus();
38
+ }, 10);
39
+ }, [isVerifying]);
40
+ useEffect(() => {
41
+ if (code.length === 6) {
42
+ handleSubmitCode();
43
+ }
44
+ }, [code]);
45
+ const handleNext = () => {
46
+ setStep(ModalStep.VERIFY_2FA);
47
+ };
48
+ const handleSkip = () => {
49
+ if (isLogin) {
50
+ setStep(ModalStep.LOGIN_DONE);
51
+ } else {
52
+ onClose();
53
+ }
54
+ };
55
+ const handleCodeInput = (e) => {
56
+ if (codeError) {
57
+ setCodeError("");
58
+ }
59
+ setCode(e.detail.value.trim());
60
+ };
61
+ const handleSubmitCode = () => __async(void 0, null, function* () {
62
+ if (code.length === 6 && /^\d+$/.test(code)) {
63
+ enable2fa(
64
+ { verificationCode: code },
65
+ {
66
+ onSuccess: () => {
67
+ setStep(ModalStep.TWO_FACTOR_DONE);
68
+ },
69
+ onError: () => {
70
+ setCodeError("Incorrect Code");
71
+ }
72
+ }
73
+ );
74
+ } else {
75
+ setCodeError("Incorrect Code");
76
+ }
77
+ });
78
+ const handleCopy = () => {
79
+ if (secret) {
80
+ copy(secret);
81
+ }
82
+ };
83
+ return /* @__PURE__ */ jsxs(StepContainer, { children: [
84
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
85
+ /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Turn on Two-Factor authentication" }),
86
+ isVerifying && /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Please enter the code from your authenticator app." })
87
+ ] }),
88
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: isVerifying ? /* @__PURE__ */ jsx(Fragment, { children: isPending ? /* @__PURE__ */ jsx(CpslSpinner, {}) : /* @__PURE__ */ jsx(
89
+ "form",
90
+ {
91
+ onSubmit: (e) => __async(void 0, null, function* () {
92
+ e.preventDefault();
93
+ yield handleSubmitCode();
94
+ }),
95
+ children: /* @__PURE__ */ jsx(
96
+ StyledCodeInput,
97
+ {
98
+ ref: inputRef,
99
+ code,
100
+ onCpslInput: handleCodeInput,
101
+ errorText: codeError,
102
+ length: 6,
103
+ onKeyDown: (e) => __async(void 0, null, function* () {
104
+ return e.key === "Enter" && (yield handleSubmitCode());
105
+ })
106
+ }
107
+ )
108
+ }
109
+ ) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
110
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan with your preferred authenticator app." }),
111
+ /* @__PURE__ */ jsx(QRContainer, { children: !(twoFactorStatus == null ? void 0 : twoFactorStatus.uri) ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: twoFactorStatus.uri }) })
112
+ ] }) }),
113
+ !isVerifying && /* @__PURE__ */ jsxs(Fragment, { children: [
114
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslDivider, { children: "or enter the code manually" }) }),
115
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(FilledDisabledInput, { disabled: true, value: secret != null ? secret : "", noAutoDisable: true, children: /* @__PURE__ */ jsx(CpslButton, { slot: "end", variant: "ghost", onClick: handleCopy, children: /* @__PURE__ */ jsx(CpslIcon, { icon: copied ? "check" : "copy" }) }) }) }),
116
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
117
+ /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: handleNext, children: "Continue" }),
118
+ /* @__PURE__ */ jsx(SkipButton, { variant: "ghost", onClick: handleSkip, children: "Skip" })
119
+ ] })
120
+ ] })
121
+ ] });
122
+ };
123
+ const StyledCodeInput = styled(CpslCodeInput)`
124
+ align-self: center;
125
+ `;
126
+ const SkipButton = styled(CpslButton)`
127
+ margin-top: 8px;
128
+ text-decoration: underline;
129
+ `;
130
+ export {
131
+ Setup2FAStep
132
+ };
@@ -0,0 +1,88 @@
1
+ "use client";
2
+ import {
3
+ __objRest,
4
+ __spreadProps,
5
+ __spreadValues
6
+ } from "../../../chunk-MMUBH76A.js";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import React from "react";
9
+ const STRIPE_PUBLISHABLE_KEY = "pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz";
10
+ const STRIPE_PUBLISHABLE_KEY_TEST = "pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS";
11
+ const CryptoElementsContext = React.createContext({ onramp: null });
12
+ CryptoElementsContext.displayName = "CryptoElementsContext";
13
+ const CryptoElements = ({ stripeOnramp, children }) => {
14
+ const [ctx, setContext] = React.useState(() => ({
15
+ onramp: null
16
+ }));
17
+ React.useEffect(() => {
18
+ let isMounted = true;
19
+ Promise.resolve(stripeOnramp).then((onramp) => {
20
+ if (onramp && isMounted) {
21
+ setContext((ctx2) => ctx2.onramp ? ctx2 : { onramp });
22
+ }
23
+ });
24
+ return () => {
25
+ isMounted = false;
26
+ };
27
+ }, [stripeOnramp]);
28
+ return /* @__PURE__ */ jsx(CryptoElementsContext.Provider, { value: ctx, children });
29
+ };
30
+ const useStripeOnramp = () => {
31
+ const context = React.useContext(CryptoElementsContext);
32
+ return context == null ? void 0 : context.onramp;
33
+ };
34
+ const useOnrampSessionListener = (type, session, callback) => {
35
+ React.useEffect(() => {
36
+ if (session && callback) {
37
+ const listener = (e) => callback(e.payload);
38
+ session.addEventListener(type, listener);
39
+ return () => {
40
+ session.removeEventListener(type, listener);
41
+ };
42
+ }
43
+ return () => {
44
+ };
45
+ }, [session, callback, type]);
46
+ };
47
+ const OnrampElement = (_a) => {
48
+ var _b = _a, {
49
+ clientSecret,
50
+ appearance,
51
+ onReady = () => {
52
+ },
53
+ onSessionChange
54
+ } = _b, props = __objRest(_b, [
55
+ "clientSecret",
56
+ "appearance",
57
+ "onReady",
58
+ "onSessionChange"
59
+ ]);
60
+ const stripeOnramp = useStripeOnramp();
61
+ const onrampElementRef = React.useRef(null);
62
+ const [session, setSession] = React.useState();
63
+ const appearanceJSON = JSON.stringify(appearance);
64
+ React.useEffect(() => {
65
+ const containerRef = onrampElementRef.current;
66
+ if (containerRef) {
67
+ containerRef.innerHTML = "";
68
+ if (clientSecret && stripeOnramp) {
69
+ setSession(
70
+ stripeOnramp.createSession({
71
+ clientSecret,
72
+ appearance: { theme: appearance }
73
+ }).mount(containerRef)
74
+ );
75
+ }
76
+ }
77
+ }, [appearanceJSON, clientSecret, stripeOnramp]);
78
+ useOnrampSessionListener("onramp_ui_loaded", session, onReady);
79
+ useOnrampSessionListener("onramp_session_updated", session, onSessionChange);
80
+ return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, props), { ref: onrampElementRef }));
81
+ };
82
+ export {
83
+ CryptoElements,
84
+ OnrampElement,
85
+ STRIPE_PUBLISHABLE_KEY,
86
+ STRIPE_PUBLISHABLE_KEY_TEST,
87
+ useStripeOnramp
88
+ };
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslButton, CpslText } from "@getpara/react-components";
5
+ import { Heading, StepContainer, InnerStepContainer, HeroIcon } from "../common.js";
6
+ import { useStore } from "../../../provider/stores/useStore.js";
7
+ const TwoFactorDoneStep = ({ onClose }) => {
8
+ const hideWallets = useStore((state) => {
9
+ var _a;
10
+ return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
11
+ });
12
+ return /* @__PURE__ */ jsxs(StepContainer, { children: [
13
+ /* @__PURE__ */ jsx(HeroIcon, { icon: "checkCircleFilled" }),
14
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
15
+ /* @__PURE__ */ jsx(Heading, { variant: "headingXS", weight: "semiBold", children: "Success" }),
16
+ /* @__PURE__ */ jsxs(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: [
17
+ "Your ",
18
+ hideWallets ? "account" : "wallet",
19
+ " is now protected by 2FA"
20
+ ] })
21
+ ] }),
22
+ /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: onClose, children: "Done" })
23
+ ] });
24
+ };
25
+ export {
26
+ TwoFactorDoneStep
27
+ };
@@ -0,0 +1,143 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { CpslCodeInput, CpslSpinner, CpslText } from "@getpara/react-components";
7
+ import { useEffect, useRef, useState } from "react";
8
+ import { styled } from "styled-components";
9
+ import { Heading, InnerStepContainer, StepContainer } from "../common.js";
10
+ import { displayPhoneNumber } from "@getpara/core-sdk";
11
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
12
+ import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
13
+ import { useResendVerificationCode } from "../../../provider/index.js";
14
+ const VerificationCodeStep = () => {
15
+ const para = useInternalClient();
16
+ const authInfo = para.authInfo;
17
+ const { verifyNewAccount, isVerifyNewAccountPending, verifyNewAccountError } = useAuthActions();
18
+ const { resendVerificationCode } = useResendVerificationCode();
19
+ const inputRef = useRef(null);
20
+ const [code, setCode] = useState("");
21
+ const [isPending, setIsPending] = useState(false);
22
+ const [codeError, setCodeError] = useState(null);
23
+ const [resendDisabled, setResendDisabled] = useState(false);
24
+ const isEmail = (authInfo == null ? void 0 : authInfo.authType) === "email";
25
+ useEffect(() => {
26
+ setTimeout(() => {
27
+ var _a, _b, _c, _d;
28
+ (_d = (_c = (_b = (_a = inputRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelectorAll("input")) == null ? void 0 : _c[0]) == null ? void 0 : _d.focus();
29
+ }, 10);
30
+ }, []);
31
+ useEffect(() => {
32
+ setCodeError(null);
33
+ if (code.length === 6) {
34
+ handleSubmitCode();
35
+ }
36
+ }, [code]);
37
+ useEffect(() => {
38
+ if (isVerifyNewAccountPending) {
39
+ setIsPending(isVerifyNewAccountPending);
40
+ }
41
+ }, [isVerifyNewAccountPending]);
42
+ const handleResendClick = () => __async(void 0, null, function* () {
43
+ if (!resendDisabled) {
44
+ setResendDisabled(true);
45
+ resendVerificationCode(void 0, {
46
+ onSettled: () => {
47
+ setTimeout(() => {
48
+ setResendDisabled(false);
49
+ }, 3e3);
50
+ }
51
+ });
52
+ }
53
+ });
54
+ const handleCodeInput = (e) => {
55
+ setCode(e.detail.value.trim());
56
+ };
57
+ const handleSubmitCode = () => __async(void 0, null, function* () {
58
+ if (code.length === 6 && /^\d+$/.test(code)) {
59
+ verifyNewAccount(code);
60
+ } else {
61
+ setCodeError("Incorrect code.");
62
+ }
63
+ });
64
+ useEffect(() => {
65
+ if (!!verifyNewAccountError) {
66
+ setIsPending(false);
67
+ const status = verifyNewAccountError.status;
68
+ switch (status) {
69
+ case 429:
70
+ setCodeError("Too many incorrect attempts. Please try again in 10 minutes.");
71
+ break;
72
+ default:
73
+ setCodeError("Incorrect code.");
74
+ break;
75
+ }
76
+ }
77
+ }, [verifyNewAccountError]);
78
+ return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
79
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
80
+ /* @__PURE__ */ jsxs(Heading, { variant: "headingS", weight: "bold", children: [
81
+ "Verify ",
82
+ isEmail ? "Email" : "Phone Number"
83
+ ] }),
84
+ /* @__PURE__ */ jsxs(InlineText, { variant: "bodyS", color: "secondary", children: [
85
+ "Please enter the code we sent to",
86
+ " ",
87
+ /* @__PURE__ */ jsx(InlineText, { variant: "bodyS", children: (authInfo == null ? void 0 : authInfo.authType) === "phone" ? displayPhoneNumber(authInfo.identifier) : authInfo.identifier })
88
+ ] })
89
+ ] }),
90
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: isPending ? /* @__PURE__ */ jsx(CpslSpinner, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
91
+ /* @__PURE__ */ jsx(
92
+ "form",
93
+ {
94
+ onSubmit: (e) => __async(void 0, null, function* () {
95
+ e.preventDefault();
96
+ yield handleSubmitCode();
97
+ }),
98
+ children: /* @__PURE__ */ jsx(
99
+ StyledCodeInput,
100
+ {
101
+ ref: inputRef,
102
+ length: 6,
103
+ type: "number",
104
+ code,
105
+ onCpslInput: handleCodeInput,
106
+ errorText: codeError || "",
107
+ onKeyDown: (e) => __async(void 0, null, function* () {
108
+ return e.key === "Enter" && (yield handleSubmitCode());
109
+ })
110
+ }
111
+ )
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsxs(InlineText, { variant: "bodyS", color: "secondary", children: [
115
+ "Didn\u2019t receive a code?",
116
+ " ",
117
+ /* @__PURE__ */ jsx(
118
+ ClickableText,
119
+ {
120
+ variant: "bodyS",
121
+ style: { cursor: resendDisabled ? "default" : "pointer" },
122
+ onClick: handleResendClick,
123
+ children: resendDisabled ? "Resent!" : "Resend."
124
+ }
125
+ )
126
+ ] })
127
+ ] }) })
128
+ ] });
129
+ };
130
+ const StyledCodeInput = styled(CpslCodeInput)`
131
+ align-self: center;
132
+ `;
133
+ const InlineText = styled(CpslText)`
134
+ text-align: center;
135
+ display: inline-block;
136
+ `;
137
+ const ClickableText = styled(InlineText)`
138
+ cursor: pointer;
139
+ display: inline-block;
140
+ `;
141
+ export {
142
+ VerificationCodeStep
143
+ };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslSpinner, CpslText } from "@getpara/react-components";
5
+ import { Heading, SpinnerContainer, StepContainer, InnerStepContainer } from "../common.js";
6
+ const Waiting = ({ heading, subheading }) => {
7
+ return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
8
+ /* @__PURE__ */ jsx(SpinnerContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) }),
9
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
10
+ /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: heading }),
11
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: subheading })
12
+ ] })
13
+ ] });
14
+ };
15
+ export {
16
+ Waiting
17
+ };
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import styled from "styled-components";
5
+ import { CpslIcon, CpslText } from "@getpara/react-components";
6
+ const PartnerIcon = ({ partner }) => {
7
+ const { logoUrl, displayName, backgroundColor, foregroundColor } = partner;
8
+ if (logoUrl) {
9
+ return /* @__PURE__ */ jsx(Icon, { src: logoUrl });
10
+ }
11
+ return /* @__PURE__ */ jsx(Container, { $backgroundColor: backgroundColor, children: /* @__PURE__ */ jsx(Text, { variant: "bodyXS", $color: foregroundColor, children: displayName[0] }) });
12
+ };
13
+ const Container = styled.div`
14
+ width: 14px;
15
+ height: 14px;
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ background-color: ${({ $backgroundColor }) => `${$backgroundColor != null ? $backgroundColor : "var(--cpsl-color-contrast)"}`};
20
+ border-radius: 100%;
21
+ `;
22
+ const Text = styled(CpslText)`
23
+ &::part(text-element) {
24
+ line-height: 100%;
25
+ color: ${({ $color }) => `${$color != null ? $color : "var(--cpsl-color-foreground-0)"}`};
26
+ }
27
+ `;
28
+ const Icon = styled(CpslIcon)`
29
+ --height: 14px;
30
+ --width: 14px;
31
+ `;
32
+ export {
33
+ PartnerIcon
34
+ };
@@ -1,15 +1,15 @@
1
- import { WalletType } from '@getpara/web-sdk';
1
+ import { TWalletType } from '@getpara/web-sdk';
2
2
  export declare const ExternalWalletCard: ({ address, showAddFunds }: Pick<SharedWalletCardProps, "address" | "showAddFunds">) => import("react/jsx-runtime").JSX.Element | null;
3
3
  interface WalletCardProps {
4
4
  id: string;
5
- type: WalletType;
5
+ type: TWalletType;
6
6
  showAddFunds?: boolean;
7
7
  }
8
8
  export declare const WalletCard: ({ id, type, showAddFunds }: WalletCardProps) => import("react/jsx-runtime").JSX.Element | null;
9
9
  interface SharedWalletCardProps {
10
10
  address: string;
11
11
  id?: string;
12
- type?: WalletType;
12
+ type?: TWalletType;
13
13
  name?: string;
14
14
  identiconHash: string;
15
15
  showAddFunds?: boolean;