@getpara/react-sdk 2.0.0-alpha.19 → 2.0.0-alpha.21

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 (88) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -5
  3. package/dist/modal/ParaModal.js +15 -5
  4. package/dist/modal/components/Account/Account.js +14 -8
  5. package/dist/modal/components/Account/AccountProfile.d.ts +1 -0
  6. package/dist/modal/components/Account/AccountProfile.js +170 -0
  7. package/dist/modal/components/Account/AccountProfileLink.d.ts +1 -0
  8. package/dist/modal/components/Account/AccountProfileLink.js +205 -0
  9. package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +1 -0
  10. package/dist/modal/components/Account/AccountProfileLinkOptions.js +98 -0
  11. package/dist/modal/components/Account/AccountProfileUnlink.d.ts +1 -0
  12. package/dist/modal/components/Account/AccountProfileUnlink.js +47 -0
  13. package/dist/modal/components/AuthInput/AuthInput.d.ts +17 -3
  14. package/dist/modal/components/AuthInput/AuthInput.js +116 -101
  15. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +2 -2
  16. package/dist/modal/components/AuthOptions/AuthOptions.js +26 -1
  17. package/dist/modal/components/Body/Body.js +21 -2
  18. package/dist/modal/components/Controls/Selects.js +3 -19
  19. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +7 -0
  20. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +75 -44
  21. package/dist/modal/components/Header/hooks/useStepTitle.js +7 -1
  22. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -0
  23. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -2
  24. package/dist/modal/components/OAuth/OAuth.js +2 -2
  25. package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +7 -0
  26. package/dist/modal/components/OAuth/TelegramOAuthStep.js +36 -52
  27. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +12 -1
  28. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +40 -23
  29. package/dist/modal/components/common.d.ts +18 -1
  30. package/dist/modal/components/common.js +86 -0
  31. package/dist/modal/constants/constants.d.ts +1 -1
  32. package/dist/modal/constants/constants.js +1 -1
  33. package/dist/modal/constants/oAuthLogos.d.ts +15 -6
  34. package/dist/modal/constants/oAuthLogos.js +148 -19
  35. package/dist/modal/hooks/useTelegramLogin.d.ts +12 -0
  36. package/dist/modal/hooks/useTelegramLogin.js +65 -0
  37. package/dist/modal/stores/modal/actions.js +6 -1
  38. package/dist/modal/stores/modal/useModalStore.d.ts +4 -3
  39. package/dist/modal/stores/modal/useModalStore.js +7 -2
  40. package/dist/modal/types/modalProps.d.ts +6 -1
  41. package/dist/modal/utils/authInputHelpers.d.ts +3 -5
  42. package/dist/modal/utils/authInputHelpers.js +23 -20
  43. package/dist/modal/utils/getWalletDisplayName.d.ts +5 -0
  44. package/dist/modal/utils/getWalletDisplayName.js +22 -0
  45. package/dist/modal/utils/steps.d.ts +10 -2
  46. package/dist/modal/utils/steps.js +18 -2
  47. package/dist/provider/ParaProvider.js +6 -5
  48. package/dist/provider/actions/index.d.ts +19 -0
  49. package/dist/provider/actions/index.js +47 -29
  50. package/dist/provider/actions/utils.d.ts +3 -2
  51. package/dist/provider/actions/utils.js +25 -6
  52. package/dist/provider/components/CosmosWalletWrapper.js +2 -2
  53. package/dist/provider/components/EvmWalletWrapper.js +2 -2
  54. package/dist/provider/components/ExternalWalletWrapper.js +2 -1
  55. package/dist/provider/components/SolanaWalletWrapper.js +2 -2
  56. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +0 -10
  57. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +2 -12
  58. package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +0 -1
  59. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +2 -15
  60. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +0 -6
  61. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +2 -8
  62. package/dist/provider/hooks/mutations/core.d.ts +27 -0
  63. package/dist/provider/hooks/mutations/core.js +66 -0
  64. package/dist/provider/hooks/mutations/index.d.ts +3 -28
  65. package/dist/provider/hooks/mutations/index.js +4 -60
  66. package/dist/provider/hooks/mutations/useLinkAccount.d.ts +9 -0
  67. package/dist/provider/hooks/mutations/useLinkAccount.js +18 -0
  68. package/dist/provider/hooks/mutations/utils.d.ts +11 -4
  69. package/dist/provider/hooks/mutations/utils.js +35 -4
  70. package/dist/provider/hooks/queries/core.d.ts +2 -0
  71. package/dist/provider/hooks/queries/core.js +13 -0
  72. package/dist/provider/hooks/queries/index.d.ts +1 -0
  73. package/dist/provider/hooks/queries/index.js +1 -0
  74. package/dist/provider/hooks/queries/utils.d.ts +4 -0
  75. package/dist/provider/hooks/queries/utils.js +24 -0
  76. package/dist/provider/hooks/utils/useModal.d.ts +4 -1
  77. package/dist/provider/hooks/utils/useModal.js +12 -2
  78. package/dist/provider/providers/AccountLinkProvider.d.ts +42 -0
  79. package/dist/provider/providers/AccountLinkProvider.js +443 -0
  80. package/dist/provider/providers/AuthProvider.d.ts +3 -1
  81. package/dist/provider/providers/AuthProvider.js +8 -5
  82. package/dist/provider/providers/ExternalWalletProvider.d.ts +18 -35
  83. package/dist/provider/providers/ExternalWalletProvider.js +169 -39
  84. package/dist/provider/stores/slices/modal.js +3 -1
  85. package/dist/provider/stores/types.d.ts +2 -1
  86. package/dist/provider/types/utils.d.ts +25 -6
  87. package/dist/provider/utils/renameMutations.d.ts +2 -2
  88. package/package.json +8 -8
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './modal/index.js';
2
2
  export * from './provider/index.js';
3
3
  export * from '@getpara/web-sdk';
4
- export { ExternalWallet, EvmWallet, SolanaWallet, CosmosWallet } from '@getpara/react-common';
5
4
  export type { Theme } from '@getpara/react-components';
6
5
  import ParaWeb from '@getpara/web-sdk';
7
6
  export default ParaWeb;
package/dist/index.js CHANGED
@@ -3,13 +3,8 @@ import "./chunk-MMUBH76A.js";
3
3
  export * from "./modal/index.js";
4
4
  export * from "./provider/index.js";
5
5
  export * from "@getpara/web-sdk";
6
- import { ExternalWallet, EvmWallet, SolanaWallet, CosmosWallet } from "@getpara/react-common";
7
6
  import ParaWeb from "@getpara/web-sdk";
8
7
  var src_default = ParaWeb;
9
8
  export {
10
- CosmosWallet,
11
- EvmWallet,
12
- ExternalWallet,
13
- SolanaWallet,
14
9
  src_default as default
15
10
  };
@@ -22,11 +22,12 @@ import { useExternalWallets } from "../provider/providers/ExternalWalletProvider
22
22
  import { useStore } from "../provider/stores/useStore.js";
23
23
  import parsePhoneNumberFromString from "libphonenumber-js";
24
24
  import { useAuthActions } from "../provider/providers/AuthProvider.js";
25
- import { validateAuth } from "./utils/authInputHelpers.js";
25
+ import { validateInput } from "./utils/authInputHelpers.js";
26
26
  import { SDK_VERSION } from "./constants/constants.js";
27
27
  defineCustomElements();
28
28
  const ParaModal = forwardRef((props, ref) => {
29
29
  const storedModalConfig = useStore((state) => state.modalConfig);
30
+ const openedToStep = useStore((state) => state.openedToStep);
30
31
  const modalContentRef = useRef(null);
31
32
  const refs = useModalStore((state) => state.refs);
32
33
  const flow = useModalStore((state) => state.flow);
@@ -52,6 +53,7 @@ const ParaModal = forwardRef((props, ref) => {
52
53
  const [isInit, setIsInit] = useState(false);
53
54
  const externalWallets = useStore((state) => state.externalWallets);
54
55
  const providerProps = useStore((state) => state.providerProps);
56
+ const setAccountLinkOptions = useModalStore((state) => state.setAccountLinkOptions);
55
57
  const _a = __spreadValues(__spreadValues({}, storedModalConfig), props), {
56
58
  isOpen: configIsOpen,
57
59
  theme,
@@ -66,7 +68,8 @@ const ParaModal = forwardRef((props, ref) => {
66
68
  embeddedModal,
67
69
  onModalStepChange,
68
70
  onClose,
69
- defaultAuthIdentifier
71
+ defaultAuthIdentifier,
72
+ supportedAccountLinks: propsSupportedAccountLinks
70
73
  } = _a, rest = __objRest(_a, [
71
74
  "isOpen",
72
75
  "theme",
@@ -81,7 +84,8 @@ const ParaModal = forwardRef((props, ref) => {
81
84
  "embeddedModal",
82
85
  "onModalStepChange",
83
86
  "onClose",
84
- "defaultAuthIdentifier"
87
+ "defaultAuthIdentifier",
88
+ "supportedAccountLinks"
85
89
  ]);
86
90
  useEffect(() => {
87
91
  const trackAnalytics = () => __async(void 0, null, function* () {
@@ -140,7 +144,9 @@ const ParaModal = forwardRef((props, ref) => {
140
144
  break;
141
145
  case isAccount:
142
146
  setFlow("account");
143
- setStep(ModalStep.ACCOUNT_MAIN);
147
+ if (!openedToStep.current) {
148
+ setStep(ModalStep.ACCOUNT_MAIN);
149
+ }
144
150
  break;
145
151
  default:
146
152
  if (currentStep !== ModalStep.AUTH_MAIN && currentStep !== ModalStep.SECRET) {
@@ -155,7 +161,7 @@ const ParaModal = forwardRef((props, ref) => {
155
161
  if (defaultAuthIdentifier && ((_a2 = para.authInfo) == null ? void 0 : _a2.identifier) !== defaultAuthIdentifier) {
156
162
  const number = parsePhoneNumberFromString(defaultAuthIdentifier);
157
163
  try {
158
- const auth = validateAuth(
164
+ const auth = validateInput(
159
165
  number ? number.nationalNumber : defaultAuthIdentifier,
160
166
  (number == null ? void 0 : number.countryCallingCode) ? `+${number == null ? void 0 : number.countryCallingCode}` : void 0,
161
167
  number ? "phone" : "email"
@@ -211,6 +217,9 @@ const ParaModal = forwardRef((props, ref) => {
211
217
  setStep(ModalStep.AUTH_MAIN);
212
218
  }
213
219
  }, [bareModal, flow, account]);
220
+ useEffect(() => {
221
+ setAccountLinkOptions(propsSupportedAccountLinks != null ? propsSupportedAccountLinks : para == null ? void 0 : para.supportedAccountLinks);
222
+ }, [propsSupportedAccountLinks, para == null ? void 0 : para.supportedAccountLinks]);
214
223
  const handleClose = () => {
215
224
  closeModal();
216
225
  onClose == null ? void 0 : onClose();
@@ -219,6 +228,7 @@ const ParaModal = forwardRef((props, ref) => {
219
228
  setIsModalMounted(true);
220
229
  };
221
230
  const handleModalExited = () => __async(void 0, null, function* () {
231
+ openedToStep.current = null;
222
232
  setIsModalMounted(false);
223
233
  if (RESET_TO_AUTH_STEPS.includes(currentStep)) {
224
234
  resetModalState();
@@ -15,6 +15,7 @@ import { useStore } from "../../../provider/stores/useStore.js";
15
15
  import { formatBalanceString } from "../../utils/stringFormatters.js";
16
16
  import { useAccount, useWalletBalance } from "../../../provider/index.js";
17
17
  import { EnabledFlow } from "@getpara/web-sdk";
18
+ import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
18
19
  const Account = ({ onClose }) => {
19
20
  const onRampConfig = useModalStore((state) => state.onRampConfig);
20
21
  const setStep = useModalStore((state) => state.setStep);
@@ -29,22 +30,24 @@ const Account = ({ onClose }) => {
29
30
  const para = useInternalClient();
30
31
  const { data: account } = useAccount();
31
32
  const { data: balance, isLoading: isBalanceLoading } = useWalletBalance();
33
+ const { isEnabled } = useAccountLinking();
32
34
  const [isDisconnecting, setIsDisconnecting] = useState(false);
33
35
  const isGuestMode = (account == null ? void 0 : account.isConnected) && account.isGuestMode;
34
36
  const cantBuyAndWithdraw = (para.externalWalletConnectionType === "CONNECTION_ONLY" || para.externalWalletConnectionType === "VERIFICATION") && !para.userId;
35
37
  const isOnRampLoaded = !!onRampConfig;
36
38
  const handleBuyClick = () => {
37
39
  if (isGuestMode) {
38
- setGuestAddFundsTab(EnabledFlow.BUY);
39
- setStep(ModalStep.AUTH_GUEST_SIGNUP);
40
+ if (onRampConfig == null ? void 0 : onRampConfig.isReceiveEnabled) {
41
+ setStep(ModalStep.ADD_FUNDS_RECEIVE);
42
+ } else {
43
+ setGuestAddFundsTab(EnabledFlow.BUY);
44
+ setStep(ModalStep.AUTH_GUEST_SIGNUP);
45
+ }
40
46
  } else {
41
47
  setOnRampStep(OnRampStep.SETTINGS);
42
48
  setStep(ModalStep.ADD_FUNDS_BUY);
43
49
  }
44
50
  };
45
- const handleReceiveClick = () => {
46
- setStep(ModalStep.ADD_FUNDS_RECEIVE);
47
- };
48
51
  const handleSellClick = () => {
49
52
  if (isGuestMode) {
50
53
  setGuestAddFundsTab(EnabledFlow.WITHDRAW);
@@ -54,6 +57,9 @@ const Account = ({ onClose }) => {
54
57
  setStep(ModalStep.ADD_FUNDS_WITHDRAW);
55
58
  }
56
59
  };
60
+ const handleProfileClick = () => {
61
+ setStep(ModalStep.ACCOUNT_PROFILE);
62
+ };
57
63
  const handleDisconnectClick = () => __async(void 0, null, function* () {
58
64
  setIsDisconnecting(true);
59
65
  yield para.logout();
@@ -89,9 +95,9 @@ const Account = ({ onClose }) => {
89
95
  )
90
96
  ] }),
91
97
  /* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
92
- onRampConfig.isBuyEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Buy Crypto" }) }),
93
- onRampConfig.isReceiveEnabled && /* @__PURE__ */ jsx(OptionButton, { icon: "qrCode02", onClick: handleReceiveClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
94
- onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) })
98
+ onRampConfig.isBuyEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "creditCard", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Receive" }) }),
99
+ onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleBrokenDownLeft", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
100
+ /* @__PURE__ */ jsx(OptionButton, { icon: "user", onClick: handleProfileClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
95
101
  ] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) }),
96
102
  !isGuestMode && /* @__PURE__ */ jsx(DisconnectButton, { variant: "destructive", fullWidth: true, onClick: handleDisconnectClick, disabled: isDisconnecting, children: isDisconnecting ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
97
103
  hideWallets ? "Logout" : "Disconnect Wallet",
@@ -0,0 +1 @@
1
+ export declare const AccountProfile: () => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ import {
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "../../../chunk-MMUBH76A.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import styled from "styled-components";
8
+ import { AccountTypeIcon, GradientScroll, StepContainer } from "../common.js";
9
+ import { CpslButton, CpslIcon, CpslIdenticon, CpslText } from "@getpara/react-components";
10
+ import { useAccount, useClient } from "../../../provider/index.js";
11
+ import { useLinkedAccounts } from "../../../provider/hooks/index.js";
12
+ import { getWalletDisplayName } from "../../utils/getWalletDisplayName.js";
13
+ import { truncateAddress } from "@getpara/web-sdk";
14
+ import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
15
+ import { safeStyled, useCopyToClipboard } from "@getpara/react-common";
16
+ import { getAccountTypeName } from "../../constants/oAuthLogos.js";
17
+ const Entry = ({
18
+ identifier,
19
+ icon,
20
+ name,
21
+ address,
22
+ addressShort,
23
+ onUnlink
24
+ }) => {
25
+ const [isCopied, copy] = useCopyToClipboard();
26
+ return /* @__PURE__ */ jsxs(EntryContainer, { children: [
27
+ icon,
28
+ /* @__PURE__ */ jsx(EntryDisplayName, { variant: "bodyM", color: "contrast", children: name }),
29
+ /* @__PURE__ */ jsx(EntryFlex, { children: address ? /* @__PURE__ */ jsxs(EntryAddress, { children: [
30
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", children: addressShort != null ? addressShort : address }),
31
+ /* @__PURE__ */ jsx(
32
+ CpslButton,
33
+ {
34
+ size: "small",
35
+ variant: "ghost",
36
+ onClick: (e) => {
37
+ e.stopPropagation();
38
+ e.preventDefault();
39
+ copy(address);
40
+ },
41
+ children: /* @__PURE__ */ jsx(CopyIcon, { id: "ignore-click", slot: "start", isCopied, icon: isCopied ? "check" : "copy" })
42
+ }
43
+ )
44
+ ] }) : null }),
45
+ onUnlink && /* @__PURE__ */ jsx(EntryUnlink, { href: "#", onClick: onUnlink, children: "Unlink" })
46
+ ] }, address != null ? address : identifier);
47
+ };
48
+ const AccountProfile = () => {
49
+ var _a, _b, _c, _d, _e;
50
+ const para = useClient();
51
+ const { data: account } = useAccount();
52
+ const { data: linkedAccounts } = useLinkedAccounts();
53
+ const { isEnabled, linkAccount, unlinkAccount } = useAccountLinking();
54
+ if (!para) {
55
+ return null;
56
+ }
57
+ const externalWallet = account == null ? void 0 : account.externalWallet;
58
+ return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
59
+ /* @__PURE__ */ jsxs(Section, { children: [
60
+ /* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Connected Wallets" }),
61
+ /* @__PURE__ */ jsx(Content, { children: externalWallet ? /* @__PURE__ */ jsx(
62
+ Entry,
63
+ {
64
+ icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: externalWallet.providerId, size: "24px" }),
65
+ name: (_b = (_a = externalWallet.ensName) != null ? _a : getAccountTypeName(externalWallet.providerId)) != null ? _b : "",
66
+ address: (_c = externalWallet.addressBech32) != null ? _c : externalWallet.address,
67
+ addressShort: truncateAddress((_d = externalWallet.addressBech32) != null ? _d : externalWallet.address, externalWallet.type, {
68
+ prefix: para.cosmosPrefix
69
+ })
70
+ },
71
+ externalWallet.address
72
+ ) : (_e = account == null ? void 0 : account.wallets) == null ? void 0 : _e.map((wallet) => {
73
+ var _a2;
74
+ return /* @__PURE__ */ jsx(
75
+ Entry,
76
+ {
77
+ icon: wallet.isExternal ? /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: (_a2 = wallet.externalProviderId) != null ? _a2 : "EXTERNAL_WALLET", size: "24px" }) : /* @__PURE__ */ jsx(CpslIdenticon, { hash: para.getIdenticonHash(wallet.id, wallet.type), size: "24px", arcWidth: "40%" }),
78
+ name: getWalletDisplayName(para, wallet),
79
+ address: wallet.address,
80
+ addressShort: truncateAddress(wallet.address, wallet.type)
81
+ },
82
+ wallet.address
83
+ );
84
+ }) })
85
+ ] }),
86
+ isEnabled && /* @__PURE__ */ jsxs(Section, { children: [
87
+ /* @__PURE__ */ jsx(Title, { variant: "bodyS", color: "secondary", children: "Linked Accounts" }),
88
+ /* @__PURE__ */ jsxs(Content, { children: [
89
+ /* @__PURE__ */ jsx(GradientScroll, { gap: "12px", height: "360px", children: [
90
+ ...((linkedAccounts == null ? void 0 : linkedAccounts.primary) || []).map((p) => __spreadProps(__spreadValues({}, p), { isPrimary: true })),
91
+ ...(linkedAccounts == null ? void 0 : linkedAccounts.linked) || []
92
+ ].map((linkedAccount) => {
93
+ var _a2, _b2, _c2, _d2, _e2;
94
+ const { identifier, displayName, type, isPrimary = false, externalWallet: externalWallet2 } = linkedAccount;
95
+ return /* @__PURE__ */ jsx(
96
+ Entry,
97
+ {
98
+ icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: (_a2 = externalWallet2 == null ? void 0 : externalWallet2.providerId) != null ? _a2 : type, size: "24px" }),
99
+ name: externalWallet2 ? (_c2 = (_b2 = externalWallet2.ensName) != null ? _b2 : getAccountTypeName(externalWallet2.providerId)) != null ? _c2 : "" : displayName != null ? displayName : identifier,
100
+ address: (_d2 = externalWallet2 == null ? void 0 : externalWallet2.addressBech32) != null ? _d2 : externalWallet2 == null ? void 0 : externalWallet2.address,
101
+ addressShort: externalWallet2 ? truncateAddress((_e2 = externalWallet2.addressBech32) != null ? _e2 : externalWallet2.address, externalWallet2.type, {
102
+ prefix: para.cosmosPrefix
103
+ }) : void 0,
104
+ onUnlink: isPrimary ? void 0 : (e) => {
105
+ e.preventDefault();
106
+ unlinkAccount(linkedAccount);
107
+ }
108
+ },
109
+ identifier
110
+ );
111
+ }) }),
112
+ /* @__PURE__ */ jsxs(CpslButton, { fullWidth: true, variant: "tertiary", onClick: () => linkAccount(void 0), children: [
113
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "userPlus", slot: "start" }),
114
+ "Link an account"
115
+ ] })
116
+ ] })
117
+ ] })
118
+ ] });
119
+ };
120
+ const Section = styled.div`
121
+ display: flex;
122
+ flex-direction: column;
123
+ align-items: flex-start;
124
+ justify-content: center;
125
+ gap: 16px;
126
+ width: 100%;
127
+ `;
128
+ const Content = styled(Section)``;
129
+ const Title = styled(CpslText)``;
130
+ const EntryContainer = safeStyled.div`
131
+ position: relative;
132
+ width: 100%;
133
+ display: flex;
134
+ gap: 8px;
135
+ align-items: center;
136
+ `;
137
+ const EntryDisplayName = safeStyled(CpslText)``;
138
+ const EntryFlex = safeStyled.div`
139
+ flex: 1;
140
+ `;
141
+ const EntryAddress = safeStyled.div`
142
+ display: flex;
143
+ gap: 8px;
144
+ align-items: center;
145
+ `;
146
+ const CopyIcon = safeStyled(CpslIcon)`
147
+ --width: 16px;
148
+ --height: 16px;
149
+ --icon-color: ${({ isCopied }) => isCopied ? "var(--cpsl-color-utility-green) !important" : "var(--cpsl-color-text-secondary)"};
150
+
151
+ &:hover {
152
+ --icon-color: var(--cpsl-color-text-contrast);
153
+ }
154
+ `;
155
+ const EntryUnlink = styled.a`
156
+ color: var(--cpsl-color-utility-red);
157
+ position: absolute;
158
+ right: 0;
159
+ text-decoration: none;
160
+ font-size: 14px;
161
+ font-weight: 500;
162
+ font-family: var(--cpsl-font-family);
163
+
164
+ &:hover {
165
+ text-decoration: underline;
166
+ }
167
+ `;
168
+ export {
169
+ AccountProfile
170
+ };
@@ -0,0 +1 @@
1
+ export declare function AccountProfileLink(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,205 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { HeroSpinner } from "@getpara/react-common";
7
+ import { CpslButton, CpslIcon } from "@getpara/react-components";
8
+ import { useEffect, useMemo } from "react";
9
+ import { HeroAccountTypeIcon, HeroSuccessIcon } from "../common.js";
10
+ import { VerificationCode } from "../VerificationCodeStep/VerificationCodeStep.js";
11
+ import { extractAuthInfo } from "@getpara/user-management-client";
12
+ import { FarcasterConnectQR } from "../OAuth/FarcasterOAuthStep.js";
13
+ import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
14
+ import { TelegramIFrame } from "../OAuth/TelegramOAuthStep.js";
15
+ import { AuthInput } from "../AuthInput/AuthInput.js";
16
+ import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
17
+ import { useWalletDisplayHelpers, useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
18
+ import { ExternalWalletMobileConnect } from "../ExternalWalletStep/ExternalWalletStep.js";
19
+ import { useResendVerificationCode } from "../../../provider/index.js";
20
+ import { AccountLinkError } from "@getpara/web-sdk";
21
+ function AccountProfileLink() {
22
+ var _a, _b;
23
+ const {
24
+ accountLinkInProgress,
25
+ verifyEmailOrPhoneLink,
26
+ linkAccountStatus,
27
+ linkAccountError,
28
+ verifyTelegramLink,
29
+ linkAccount,
30
+ isLinkAccountPending,
31
+ resetMutations
32
+ } = useAccountLinking(), { wallets } = useExternalWallets(), { mutate: resendVerificationCode } = useResendVerificationCode(), accountLinkType = accountLinkInProgress == null ? void 0 : accountLinkInProgress.type, externalWalletType = (_b = accountLinkInProgress == null ? void 0 : accountLinkInProgress.pendingWalletType) != null ? _b : (_a = accountLinkInProgress == null ? void 0 : accountLinkInProgress.externalWallet) == null ? void 0 : _a.providerId, accountLinkIcon = externalWalletType != null ? externalWalletType : accountLinkType, isTelegram = accountLinkType === "TELEGRAM", {
33
+ url,
34
+ status: telegramStatus,
35
+ isLoaded,
36
+ setIsLoaded
37
+ } = useTelegramLogin(
38
+ isTelegram ? { isActive: isTelegram, status: linkAccountStatus, onSubmit: verifyTelegramLink } : { isActive: false }
39
+ ), status = (accountLinkInProgress == null ? void 0 : accountLinkInProgress.isComplete) ? "success" : isTelegram ? telegramStatus : linkAccountStatus, commonWallet = useMemo(() => {
40
+ const wallet = wallets.find((w) => w.internalId === externalWalletType);
41
+ return wallet;
42
+ }, [wallets]), walletDisplayHelpers = useWalletDisplayHelpers(commonWallet);
43
+ const { upper, lower } = useMemo(() => {
44
+ let upper2 = null, lower2 = null;
45
+ let message;
46
+ switch (status) {
47
+ case "pending":
48
+ message = externalWalletType ? "Confirm wallet connection" : "Confirm login request";
49
+ break;
50
+ case "success":
51
+ message = "Account linked";
52
+ break;
53
+ case "error":
54
+ switch (linkAccountError) {
55
+ case AccountLinkError.Conflict:
56
+ message = "Account already linked";
57
+ break;
58
+ default:
59
+ message = (accountLinkInProgress == null ? void 0 : accountLinkInProgress.type) === "EXTERNAL_WALLET" ? "Connection failed" : "Login failed";
60
+ break;
61
+ }
62
+ break;
63
+ default:
64
+ message = null;
65
+ }
66
+ const heroSpinner = /* @__PURE__ */ jsx(
67
+ HeroSpinner,
68
+ {
69
+ status,
70
+ icon: status === "success" ? /* @__PURE__ */ jsx(HeroSuccessIcon, {}) : /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: accountLinkIcon }),
71
+ text: message
72
+ }
73
+ );
74
+ const onTryAgain = externalWalletType ? () => linkAccount({ externalWallet: externalWalletType }) : accountLinkType && accountLinkType !== "EXTERNAL_WALLET" ? () => linkAccount({ type: accountLinkType }) : void 0;
75
+ const tryAgain = onTryAgain ? /* @__PURE__ */ jsxs(CpslButton, { variant: "secondary", fullWidth: true, onClick: onTryAgain, children: [
76
+ /* @__PURE__ */ jsx(CpslIcon, { icon: "refresh", slot: "start" }),
77
+ "Try Again"
78
+ ] }) : null;
79
+ if (!accountLinkInProgress) {
80
+ return { upper: upper2, lower: lower2 };
81
+ }
82
+ switch (true) {
83
+ // Email or phone input
84
+ case (!accountLinkInProgress.identifier && (accountLinkInProgress.type === "EMAIL" || accountLinkInProgress.type === "PHONE")):
85
+ upper2 = heroSpinner;
86
+ lower2 = /* @__PURE__ */ jsx(
87
+ AuthInput,
88
+ {
89
+ disableEmailLogin: accountLinkInProgress.type !== "EMAIL",
90
+ disablePhoneLogin: accountLinkInProgress.type !== "PHONE",
91
+ onSubmit: (auth) => {
92
+ try {
93
+ linkAccount({
94
+ auth
95
+ });
96
+ } catch (e) {
97
+ throw e;
98
+ }
99
+ },
100
+ error: linkAccountError === "CONFLICT" ? "Account already linked" : void 0,
101
+ isSubmitting: isLinkAccountPending,
102
+ disableSubmitButton: true,
103
+ children: ({ isSubmitting, onSubmit, isPending }) => {
104
+ return /* @__PURE__ */ jsxs(CpslButton, { variant: "primary", onClick: onSubmit, disabled: isPending || isSubmitting, fullWidth: true, children: [
105
+ "Link ",
106
+ accountLinkType === "EMAIL" ? "Email Address" : "Phone Number"
107
+ ] });
108
+ }
109
+ }
110
+ );
111
+ break;
112
+ // Verify email or phone code
113
+ case ((accountLinkType === "EMAIL" || accountLinkType === "PHONE") && (accountLinkInProgress == null ? void 0 : accountLinkInProgress.identifier) && status !== "success"):
114
+ {
115
+ const authInfo = extractAuthInfo(
116
+ accountLinkType === "EMAIL" ? { email: accountLinkInProgress.identifier } : { phone: accountLinkInProgress.identifier },
117
+ { isRequired: true }
118
+ );
119
+ lower2 = /* @__PURE__ */ jsx(
120
+ VerificationCode,
121
+ {
122
+ authInfo,
123
+ onSubmit: verifyEmailOrPhoneLink,
124
+ onResend: () => {
125
+ resendVerificationCode({ type: "LINK_ACCOUNT" });
126
+ },
127
+ status: linkAccountStatus,
128
+ error: linkAccountError
129
+ }
130
+ );
131
+ }
132
+ break;
133
+ // Farcaster Connect QR
134
+ case (accountLinkType === "FARCASTER" && status !== "success"):
135
+ lower2 = /* @__PURE__ */ jsx(FarcasterConnectQR, {});
136
+ break;
137
+ // OAuth, External Wallet, Telegram
138
+ default:
139
+ upper2 = heroSpinner;
140
+ switch (true) {
141
+ case accountLinkType === "EXTERNAL_WALLET":
142
+ {
143
+ if (commonWallet && walletDisplayHelpers.showMobile) {
144
+ upper2 = status === "success" || status === "error" ? heroSpinner : /* @__PURE__ */ jsx(
145
+ ExternalWalletMobileConnect,
146
+ {
147
+ wallet: commonWallet,
148
+ isSelfFetching: true,
149
+ onConnectWc: (w) => __async(this, null, function* () {
150
+ yield linkAccount({ externalWallet: w.internalId });
151
+ })
152
+ }
153
+ );
154
+ }
155
+ lower2 = linkAccountError ? tryAgain : null;
156
+ }
157
+ break;
158
+ case accountLinkType === "TELEGRAM":
159
+ lower2 = /* @__PURE__ */ jsx(
160
+ TelegramIFrame,
161
+ {
162
+ url,
163
+ isLoaded,
164
+ setIsLoaded,
165
+ isVisible: status === "error" || status === "idle"
166
+ }
167
+ );
168
+ break;
169
+ case (status === "error" && !!accountLinkInProgress):
170
+ lower2 = tryAgain;
171
+ break;
172
+ }
173
+ break;
174
+ }
175
+ return {
176
+ upper: upper2,
177
+ lower: lower2
178
+ };
179
+ }, [
180
+ linkAccountError,
181
+ accountLinkType,
182
+ accountLinkInProgress,
183
+ telegramStatus,
184
+ url,
185
+ isLoaded,
186
+ linkAccount,
187
+ status,
188
+ isTelegram,
189
+ externalWalletType,
190
+ commonWallet,
191
+ walletDisplayHelpers.showMobile
192
+ ]);
193
+ useEffect(() => {
194
+ return () => {
195
+ resetMutations();
196
+ };
197
+ }, []);
198
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
199
+ upper,
200
+ lower
201
+ ] });
202
+ }
203
+ export {
204
+ AccountProfileLink
205
+ };
@@ -0,0 +1 @@
1
+ export declare function AccountProfileLinkOptions(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,98 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { AuthInput } from "../AuthInput/AuthInput.js";
5
+ import { AccountTypeIcon, GradientScroll, StepContainer } from "../common.js";
6
+ import styled from "styled-components";
7
+ import { CpslButton, CpslDivider, CpslText } from "@getpara/react-components";
8
+ import { getAccountTypeName } from "../../constants/oAuthLogos.js";
9
+ import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
10
+ import { useAccountLinking } from "../../../provider/providers/AccountLinkProvider.js";
11
+ import { useEffect, useMemo } from "react";
12
+ import { EXTERNAL_WALLET_TYPES } from "@getpara/web-sdk";
13
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
14
+ function isExternalWallet(str) {
15
+ return EXTERNAL_WALLET_TYPES.includes(str);
16
+ }
17
+ function AccountProfileLinkOptions() {
18
+ const para = useInternalClient();
19
+ const { accountLinkOptions, linkAccount, isLinkAccountPending, linkAccountError, setLinkAccountError, resetMutations } = useAccountLinking();
20
+ const { wallet: connectedWallet, wallets } = useExternalWallets();
21
+ const [isEmail, isPhone, externalWalletIndex, isOptions] = [
22
+ accountLinkOptions.includes("EMAIL"),
23
+ accountLinkOptions.includes("PHONE"),
24
+ accountLinkOptions.indexOf("EXTERNAL_WALLET"),
25
+ (accountLinkOptions || []).filter((o) => o !== "EMAIL" && o !== "PHONE").length > 0
26
+ ];
27
+ const options = useMemo(() => {
28
+ const baseOptions = externalWalletIndex >= 0 ? [
29
+ ...accountLinkOptions.slice(0, externalWalletIndex),
30
+ ...EXTERNAL_WALLET_TYPES,
31
+ ...accountLinkOptions.slice(externalWalletIndex + 1)
32
+ ] : accountLinkOptions;
33
+ return baseOptions.filter((option) => {
34
+ if (!isExternalWallet(option) || (connectedWallet == null ? void 0 : connectedWallet.internalId) !== option && wallets.some(
35
+ ({ type, internalId, installed, isMobile }) => (installed || isMobile) && (para == null ? void 0 : para.supportedWalletTypes.some((obj) => obj.type === type)) && internalId === option
36
+ )) {
37
+ return true;
38
+ }
39
+ return false;
40
+ });
41
+ }, [accountLinkOptions, externalWalletIndex, wallets]);
42
+ useEffect(() => {
43
+ resetMutations();
44
+ setLinkAccountError(null);
45
+ }, []);
46
+ return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsxs(Content, { children: [
47
+ (isEmail || isPhone) && /* @__PURE__ */ jsxs(Fragment, { children: [
48
+ /* @__PURE__ */ jsx(
49
+ AuthInput,
50
+ {
51
+ disableEmailLogin: !isEmail,
52
+ disablePhoneLogin: !isPhone,
53
+ onSubmit: (auth) => {
54
+ linkAccount({
55
+ auth
56
+ });
57
+ },
58
+ error: linkAccountError ? linkAccountError === "CONFLICT" ? "Account already linked" : "An unknown error occurred" : void 0,
59
+ isSubmitting: isLinkAccountPending
60
+ }
61
+ ),
62
+ isOptions && /* @__PURE__ */ jsx(CpslDivider, { children: "or" })
63
+ ] }),
64
+ isOptions && /* @__PURE__ */ jsx(GradientScroll, { height: "320px", children: options.filter((option) => option !== "EMAIL" && option !== "PHONE").map((option) => {
65
+ const isWallet = isExternalWallet(option);
66
+ return /* @__PURE__ */ jsxs(
67
+ Option,
68
+ {
69
+ fullWidth: true,
70
+ variant: "tertiary",
71
+ onClick: () => linkAccount(isWallet ? { externalWallet: option } : { type: option }),
72
+ children: [
73
+ /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: option, size: "24px" }),
74
+ /* @__PURE__ */ jsx(CpslText, { color: "contrast", variant: "bodyM", children: getAccountTypeName(option) })
75
+ ]
76
+ },
77
+ option
78
+ );
79
+ }) })
80
+ ] }) });
81
+ }
82
+ const Content = styled.div`
83
+ display: flex;
84
+ flex-direction: column;
85
+ align-items: flex-start;
86
+ gap: 8px;
87
+ width: 100%;
88
+ `;
89
+ const Option = styled(CpslButton)`
90
+ --button-justify-content: flex-start;
91
+
92
+ height: 48px;
93
+ display: flex;
94
+ align-items: flex-start;
95
+ `;
96
+ export {
97
+ AccountProfileLinkOptions
98
+ };
@@ -0,0 +1 @@
1
+ export declare function AccountProfileUnlink(): import("react/jsx-runtime").JSX.Element;