@getpara/react-sdk-lite 2.0.0-alpha.66 → 2.0.0-alpha.68

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 (71) hide show
  1. package/dist/modal/components/Account/AccountProfile.js +12 -172
  2. package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
  3. package/dist/modal/components/Account/AccountProfileEntry.js +220 -0
  4. package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
  5. package/dist/modal/components/Account/AccountWallet.js +133 -0
  6. package/dist/modal/components/Account/AccountWalletSelect.js +15 -2
  7. package/dist/modal/components/Body/Body.js +4 -0
  8. package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -3
  9. package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +2 -2
  10. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +2 -1
  11. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +36 -29
  12. package/dist/modal/components/ExternalWallets/ExternalWallets.js +2 -2
  13. package/dist/modal/components/Header/hooks/useStepTitle.js +50 -45
  14. package/dist/modal/components/IFrameStep/IFrameStep.js +8 -6
  15. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +6 -5
  17. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +17 -4
  18. package/dist/modal/hooks/useFarcasterLogin.js +8 -1
  19. package/dist/modal/hooks/useTelegramLogin.js +4 -0
  20. package/dist/modal/stores/modal/actions.js +2 -1
  21. package/dist/modal/stores/modal/useModalStore.d.ts +4 -0
  22. package/dist/modal/stores/modal/useModalStore.js +4 -2
  23. package/dist/modal/utils/openPopup.d.ts +1 -1
  24. package/dist/modal/utils/openPopup.js +3 -1
  25. package/dist/modal/utils/steps.d.ts +3 -1
  26. package/dist/modal/utils/steps.js +4 -0
  27. package/dist/modal/utils/stringFormatters.js +10 -1
  28. package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
  29. package/dist/modal/utils/validatePortalOrigin.js +14 -0
  30. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
  31. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
  32. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
  33. package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +5 -5
  34. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
  35. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
  36. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +2 -2
  37. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
  38. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
  39. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
  40. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
  41. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
  42. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
  43. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
  44. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +8 -2
  45. package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
  46. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
  47. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
  48. package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
  49. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
  50. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
  51. package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +2 -2
  52. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
  53. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
  54. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +18 -30
  55. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +2 -2
  56. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +8 -8
  57. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
  58. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +2 -2
  59. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
  60. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
  61. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
  62. package/dist/provider/hooks/utils/useEventListeners.js +2 -0
  63. package/dist/provider/hooks/utils/useWalletState.d.ts +1 -1
  64. package/dist/provider/providers/AccountLinkProvider.js +3 -2
  65. package/dist/provider/providers/AuthProvider.js +73 -34
  66. package/dist/provider/providers/ExternalWalletProvider.d.ts +17 -5
  67. package/dist/provider/providers/ExternalWalletProvider.js +275 -38
  68. package/dist/provider/stores/getters.d.ts +1 -1
  69. package/package.json +8 -8
  70. package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
  71. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
@@ -7,9 +7,14 @@ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpar
7
7
  import { HeroAccountTypeIcon, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
8
8
  import { useEffect, useMemo } from "react";
9
9
  import { useModalStore } from "../../stores/index.js";
10
- import { HeroSpinner, safeStyled, NETWORK_NOT_SUPPORTED_ERROR, useCopyToClipboard } from "@getpara/react-common";
10
+ import {
11
+ HeroSpinner,
12
+ safeStyled,
13
+ NETWORK_NOT_SUPPORTED_ERROR,
14
+ useCopyToClipboard,
15
+ openMobileUrl
16
+ } from "@getpara/react-common";
11
17
  import { ModalStep } from "../../utils/steps.js";
12
- import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
13
18
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
14
19
  const ChainSwitch = () => {
15
20
  const [isCopied, copy] = useCopyToClipboard();
@@ -19,7 +24,7 @@ const ChainSwitch = () => {
19
24
  const { switchChain, wallet, qrUri, chainIdSwitchingTo, walletDisplayHelpers } = useExternalWallets();
20
25
  useEffect(() => {
21
26
  if ((wallet == null ? void 0 : wallet.type) === "COSMOS") {
22
- routeMobileExternalWallet(qrUri);
27
+ openMobileUrl(qrUri);
23
28
  }
24
29
  }, [qrUri, wallet]);
25
30
  useEffect(() => {
@@ -42,9 +42,9 @@ const ExternalWalletNetworkSelectStep = ({ type = "CONNECT" }) => {
42
42
  setSelectedExternalWallet({ id: wallet.id, type: wallet.type });
43
43
  setStep(ModalStep.EX_WALLET_SELECTED);
44
44
  if (wallet.installed || wallet.internalId === "FARCASTER") {
45
- connectExternalWallet(wallet);
45
+ connectExternalWallet({ wallet });
46
46
  } else if (wallet.isMobile) {
47
- connectExternalWallet(wallet, true);
47
+ connectExternalWallet({ wallet, isMobile: true });
48
48
  }
49
49
  break;
50
50
  }
@@ -1,8 +1,9 @@
1
1
  import { CommonWallet } from '@getpara/react-common';
2
- export declare const ExternalWalletMobileConnect: ({ wallet, qrUri: propsQrUri, onConnectWc, isSelfFetching, }: {
2
+ export declare const ExternalWalletMobileConnect: ({ wallet, onConnectWc, onRetryClick, }: {
3
3
  wallet: CommonWallet;
4
4
  qrUri?: string;
5
5
  onConnectWc: (_: CommonWallet) => Promise<void>;
6
+ onRetryClick?: () => Promise<void>;
6
7
  isSelfFetching?: boolean;
7
8
  }) => import("react/jsx-runtime").JSX.Element;
8
9
  export declare const ExternalWalletStep: ({ isAddingWallets }: {
@@ -5,49 +5,56 @@ import {
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
7
7
  import { CenteredText, HeroAccountTypeIcon, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
8
- import { useCallback, useEffect, useMemo, useState } from "react";
8
+ import { useCallback, useEffect, useMemo } from "react";
9
9
  import { useModalStore } from "../../stores/index.js";
10
- import { HeroSpinner, safeStyled } from "@getpara/react-common";
10
+ import { HeroSpinner, openMobileUrl, safeStyled } from "@getpara/react-common";
11
11
  import { useCopyToClipboard } from "@getpara/react-common";
12
12
  import { ModalStep } from "../../utils/steps.js";
13
13
  import { isMobile, isTablet } from "@getpara/web-sdk";
14
- import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
15
14
  import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
16
15
  import { useStore } from "../../../provider/stores/useStore.js";
16
+ const isSolanaWalletInAppBrowser = (wallet) => {
17
+ var _a;
18
+ switch (wallet) {
19
+ case "PHANTOM":
20
+ return !!((_a = window == null ? void 0 : window.phantom) == null ? void 0 : _a.solana);
21
+ case "SOLFLARE":
22
+ return !!(window == null ? void 0 : window.solflare);
23
+ case "BACKPACK":
24
+ return !!(window == null ? void 0 : window.backpack);
25
+ case "GLOW":
26
+ return !!(window == null ? void 0 : window.glowSolana);
27
+ default:
28
+ break;
29
+ }
30
+ };
17
31
  const ExternalWalletMobileConnect = ({
18
32
  wallet,
19
- qrUri: propsQrUri,
20
33
  onConnectWc,
21
- isSelfFetching = false
34
+ onRetryClick
22
35
  }) => {
23
36
  var _a, _b;
24
37
  const externalWalletError = useModalStore((state) => state.externalWalletError);
25
38
  const [isCopied, copy] = useCopyToClipboard();
26
39
  const appName = useStore((state) => state.appName);
27
- const [qrUri, setQrUri] = useState(isSelfFetching ? void 0 : propsQrUri);
28
40
  const isWalletConnect = wallet.id === "WalletConnect";
41
+ const { qrUri } = useExternalWallets();
29
42
  const handleCopy = () => {
30
43
  if (qrUri) {
31
44
  copy(qrUri);
32
45
  }
33
46
  };
34
- useEffect(() => {
35
- const fetchQrUri = () => {
36
- var _a2;
37
- if (!isSelfFetching) {
38
- return;
39
- }
40
- (_a2 = wallet.getQrUri) == null ? void 0 : _a2.call(wallet).then(setQrUri).catch();
41
- };
42
- fetchQrUri();
43
- }, [wallet, isSelfFetching]);
44
- useEffect(() => {
45
- setQrUri(propsQrUri);
46
- }, [propsQrUri]);
47
47
  const isError = !!(externalWalletError == null ? void 0 : externalWalletError[0]);
48
+ const handleRetryClick = () => __async(void 0, null, function* () {
49
+ if (isError && onRetryClick) {
50
+ yield onRetryClick();
51
+ } else {
52
+ yield openMobileUrl(qrUri);
53
+ }
54
+ });
48
55
  if (wallet.type === "SOLANA" || isMobile() && !isTablet()) {
49
56
  return /* @__PURE__ */ jsxs(Fragment, { children: [
50
- wallet.type === "SOLANA" && qrUri && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(
57
+ wallet.type === "SOLANA" && !!qrUri && !isSolanaWalletInAppBrowser(wallet.internalId) && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(
51
58
  HeroSpinner,
52
59
  {
53
60
  icon: /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: wallet.internalId, src: wallet ? wallet.iconUrl : void 0 }),
@@ -61,12 +68,12 @@ const ExternalWalletMobileConnect = ({
61
68
  HeroSpinner,
62
69
  {
63
70
  icon: /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: wallet.internalId, src: wallet ? wallet.iconUrl : void 0 }),
64
- status: isError ? "error" : "pending",
65
- text: isError ? externalWalletError[0] : `Confirm connection request in the ${wallet.name} app.`,
71
+ status: wallet.type === "SOLANA" && !isSolanaWalletInAppBrowser(wallet.internalId) ? "idle" : isError ? "error" : "pending",
72
+ text: wallet.type === "SOLANA" && (!isSolanaWalletInAppBrowser(wallet.internalId) || wallet.hasIosSafariExtension) ? "" : isError ? externalWalletError[0] : `Confirm connection request in the ${wallet.name} app.`,
66
73
  secondaryText: externalWalletError == null ? void 0 : externalWalletError[1]
67
74
  }
68
75
  ),
69
- wallet.type === "SOLANA" && qrUri && !wallet.hasIosSafariExtension || wallet.type !== "SOLANA" ? /* @__PURE__ */ jsx(CpslButton, { onClick: () => routeMobileExternalWallet(qrUri), fullWidth: true, children: "Connect Wallet" }) : /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: wallet.hasIosSafariExtension ? `Please install and use the ${wallet.name} extension for iOS Safari.` : `Please navigate to ${appName} in the ${wallet.name} wallet.` }),
76
+ wallet.type === "SOLANA" && isSolanaWalletInAppBrowser(wallet.internalId) && !wallet.hasIosSafariExtension || wallet.type !== "SOLANA" ? /* @__PURE__ */ jsx(CpslButton, { onClick: handleRetryClick, fullWidth: true, children: isError ? "Retry" : "Connect Wallet" }) : /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: wallet.hasIosSafariExtension ? `Please install and use the ${wallet.name} extension for iOS Safari.` : `Please navigate to ${appName} in the ${wallet.name} wallet.` }),
70
77
  !wallet.hasIosSafariExtension && /* @__PURE__ */ jsx(Link, { href: (_a = wallet.downloadUrl) != null ? _a : "", target: "_blank", children: /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", children: [
71
78
  `Get ${wallet.name}`,
72
79
  /* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
@@ -96,21 +103,18 @@ const ExternalWalletStep = ({ isAddingWallets = false }) => {
96
103
  const setStep = useModalStore((state) => state.setStep);
97
104
  const { connectExternalWallet, addAdditionalExternalWallet, wallet, qrUri, walletDisplayHelpers } = useExternalWallets();
98
105
  const handleConnect = useCallback(
99
- (wallet2, isWc = false) => __async(void 0, null, function* () {
106
+ (wallet2, isWc = false, isRetryConnection = false) => __async(void 0, null, function* () {
100
107
  if (isAddingWallets) {
101
108
  yield addAdditionalExternalWallet(wallet2);
102
109
  } else {
103
- yield isWc ? connectExternalWallet(wallet2, true, true) : connectExternalWallet(wallet2);
110
+ yield isWc ? connectExternalWallet({ wallet: wallet2, isMobile: true, isManualWalletConnect: true }) : connectExternalWallet({ wallet: wallet2, isMobile: wallet2.isMobile, isRetryConnection });
104
111
  }
105
112
  }),
106
113
  [isAddingWallets, addAdditionalExternalWallet, connectExternalWallet]
107
114
  );
108
- useEffect(() => {
109
- routeMobileExternalWallet(qrUri);
110
- }, [qrUri]);
111
115
  const handleTryAgainClick = () => __async(void 0, null, function* () {
112
116
  if (wallet) {
113
- yield handleConnect(wallet);
117
+ yield handleConnect(wallet, false, true);
114
118
  }
115
119
  });
116
120
  const Content = useMemo(() => {
@@ -165,6 +169,9 @@ Please choose another wallet or continue on desktop.` }) });
165
169
  qrUri,
166
170
  onConnectWc: (w) => __async(void 0, null, function* () {
167
171
  yield handleConnect(w, true);
172
+ }),
173
+ onRetryClick: () => __async(void 0, null, function* () {
174
+ yield connectExternalWallet({ wallet, isMobile: true, isRetryConnection: true });
168
175
  })
169
176
  }
170
177
  );
@@ -50,9 +50,9 @@ const ExternalWallets = ({ isAddingWallets = false }) => {
50
50
  }
51
51
  } else {
52
52
  if (wallet.installed) {
53
- connectExternalWallet(wallet);
53
+ connectExternalWallet({ wallet });
54
54
  } else if (wallet.isMobile) {
55
- connectExternalWallet(wallet, true);
55
+ connectExternalWallet({ wallet, isMobile: true });
56
56
  }
57
57
  }
58
58
  });
@@ -22,6 +22,7 @@ const useStepTitle = () => {
22
22
  const isLogin = useModalStore((state) => state.isLogin());
23
23
  const currentStep = useModalStore((state) => state.step);
24
24
  const authLayout = useModalStore((state) => state.authLayout) || [];
25
+ const profileWallet = useModalStore((state) => state.profileWallet);
25
26
  const { data: activeWallet } = useWallet();
26
27
  const [isAuthFirst, isAuthCondensed, isExternalFirst, isExternalCondensed, isBothCondensed] = [
27
28
  (_a = authLayout[0]) == null ? void 0 : _a.includes("AUTH"),
@@ -34,51 +35,55 @@ const useStepTitle = () => {
34
35
  const { chainId } = useExternalWallets();
35
36
  const { isEnabled: isAccountLinkingEnabled } = useAccountLinking();
36
37
  const titles = useMemo(
37
- () => ({
38
- [ModalStep.AUTH_MAIN]: authStepTitle,
39
- [ModalStep.AUTH_MORE]: signUpOrLogInTitle,
40
- [ModalStep.AUTH_GUEST_SIGNUP]: "Complete Account Setup",
41
- [ModalStep.EX_WALLET_MORE]: connectWalletTitle,
42
- [ModalStep.ADD_EX_WALLET_MORE]: "Add Wallet",
43
- [ModalStep.VERIFICATIONS]: "Sign Up",
44
- [ModalStep.AWAITING_OAUTH]: signUpOrLogInTitle,
45
- [ModalStep.FARCASTER_OAUTH]: signUpOrLogInTitle,
46
- [ModalStep.TELEGRAM_OAUTH]: signUpOrLogInTitle,
47
- [ModalStep.BIOMETRIC_CREATION]: "Sign Up",
48
- [ModalStep.PASSWORD_CREATION]: "Sign Up",
49
- [ModalStep.AWAITING_BIOMETRIC_CREATION]: "Sign Up",
50
- [ModalStep.AWAITING_WALLET_CREATION]: isLogin ? "Login" : "Sign Up",
51
- [ModalStep.AWAITING_PASSWORD_CREATION]: "Sign Up",
52
- [ModalStep.WALLET_CREATION_DONE]: hideWallets ? "Account Created" : "Wallet Created",
53
- [ModalStep.SECRET]: isLogin ? "Login" : "Sign Up",
54
- [ModalStep.BIOMETRIC_LOGIN]: "Login",
55
- [ModalStep.EMBEDDED_PASSWORD_LOGIN]: "Login",
56
- [ModalStep.AWAITING_PASSWORD_LOGIN]: "Login",
57
- [ModalStep.AWAITING_BIOMETRIC_LOGIN]: "Login",
58
- [ModalStep.LOGIN_DONE]: "",
59
- [ModalStep.SETUP_2FA]: "2FA",
60
- [ModalStep.VERIFY_2FA]: "2FA",
61
- [ModalStep.TWO_FACTOR_DONE]: "2FA",
62
- [ModalStep.ADD_FUNDS_BUY]: "Add Funds",
63
- [ModalStep.ADD_FUNDS_RECEIVE]: "Add Funds",
64
- [ModalStep.ADD_FUNDS_WITHDRAW]: "Withdraw",
65
- [ModalStep.ADD_FUNDS_AWAITING]: "Add Funds",
66
- [ModalStep.ADD_FUNDS_SUCCESS]: "Add Funds",
67
- [ModalStep.ADD_FUNDS_FAILURE]: "Add Funds",
68
- [ModalStep.ACCOUNT_MAIN]: "",
69
- [ModalStep.CHAIN_SWITCH]: "",
70
- [ModalStep.ACCOUNT_PROFILE]: isAccountLinkingEnabled ? "Profile" : "Settings",
71
- [ModalStep.ACCOUNT_PROFILE_LIST]: "Link Account",
72
- [ModalStep.ACCOUNT_PROFILE_ADD]: "Link Account",
73
- [ModalStep.ACCOUNT_PROFILE_REMOVE]: "Unlink Account",
74
- [ModalStep.EX_WALLET_SELECTED]: "Connect Wallet",
75
- [ModalStep.EX_WALLET_NETWORK_SELECT]: "Select Network",
76
- [ModalStep.ADD_EX_WALLET_NETWORK_SELECT]: "Select Network",
77
- [ModalStep.LINK_EX_WALLET_NETWORK_SELECT]: "Select Network",
78
- [ModalStep.ADD_EX_WALLET_SELECTED]: "Add Wallet",
79
- [ModalStep.EXTERNAL_WALLET_VERIFICATION]: "Verify Wallet",
80
- [ModalStep.AWAITING_ACCOUNT]: isLogin ? "Login" : "Sign Up"
81
- }),
38
+ () => {
39
+ var _a2;
40
+ return {
41
+ [ModalStep.AUTH_MAIN]: authStepTitle,
42
+ [ModalStep.AUTH_MORE]: signUpOrLogInTitle,
43
+ [ModalStep.AUTH_GUEST_SIGNUP]: "Complete Account Setup",
44
+ [ModalStep.EX_WALLET_MORE]: connectWalletTitle,
45
+ [ModalStep.ADD_EX_WALLET_MORE]: "Add Wallet",
46
+ [ModalStep.VERIFICATIONS]: "Sign Up",
47
+ [ModalStep.AWAITING_OAUTH]: signUpOrLogInTitle,
48
+ [ModalStep.FARCASTER_OAUTH]: signUpOrLogInTitle,
49
+ [ModalStep.TELEGRAM_OAUTH]: signUpOrLogInTitle,
50
+ [ModalStep.BIOMETRIC_CREATION]: "Sign Up",
51
+ [ModalStep.PASSWORD_CREATION]: "Sign Up",
52
+ [ModalStep.AWAITING_BIOMETRIC_CREATION]: "Sign Up",
53
+ [ModalStep.AWAITING_WALLET_CREATION]: isLogin ? "Login" : "Sign Up",
54
+ [ModalStep.AWAITING_PASSWORD_CREATION]: "Sign Up",
55
+ [ModalStep.WALLET_CREATION_DONE]: hideWallets ? "Account Created" : "Wallet Created",
56
+ [ModalStep.SECRET]: isLogin ? "Login" : "Sign Up",
57
+ [ModalStep.BIOMETRIC_LOGIN]: "Login",
58
+ [ModalStep.EMBEDDED_PASSWORD_LOGIN]: "Login",
59
+ [ModalStep.AWAITING_PASSWORD_LOGIN]: "Login",
60
+ [ModalStep.AWAITING_BIOMETRIC_LOGIN]: "Login",
61
+ [ModalStep.LOGIN_DONE]: "",
62
+ [ModalStep.SETUP_2FA]: "2FA",
63
+ [ModalStep.VERIFY_2FA]: "2FA",
64
+ [ModalStep.TWO_FACTOR_DONE]: "2FA",
65
+ [ModalStep.ADD_FUNDS_BUY]: "Add Funds",
66
+ [ModalStep.ADD_FUNDS_RECEIVE]: "Add Funds",
67
+ [ModalStep.ADD_FUNDS_WITHDRAW]: "Withdraw",
68
+ [ModalStep.ADD_FUNDS_AWAITING]: "Add Funds",
69
+ [ModalStep.ADD_FUNDS_SUCCESS]: "Add Funds",
70
+ [ModalStep.ADD_FUNDS_FAILURE]: "Add Funds",
71
+ [ModalStep.ACCOUNT_MAIN]: "",
72
+ [ModalStep.CHAIN_SWITCH]: "",
73
+ [ModalStep.ACCOUNT_PROFILE]: isAccountLinkingEnabled ? "Profile" : "Settings",
74
+ [ModalStep.ACCOUNT_PROFILE_LIST]: "Link Account",
75
+ [ModalStep.ACCOUNT_PROFILE_ADD]: "Link Account",
76
+ [ModalStep.ACCOUNT_PROFILE_REMOVE]: "Unlink Account",
77
+ [ModalStep.EX_WALLET_SELECTED]: "Connect Wallet",
78
+ [ModalStep.EX_WALLET_NETWORK_SELECT]: "Select Network",
79
+ [ModalStep.ADD_EX_WALLET_NETWORK_SELECT]: "Select Network",
80
+ [ModalStep.LINK_EX_WALLET_NETWORK_SELECT]: "Select Network",
81
+ [ModalStep.ADD_EX_WALLET_SELECTED]: "Add Wallet",
82
+ [ModalStep.EXTERNAL_WALLET_VERIFICATION]: "Verify Wallet",
83
+ [ModalStep.AWAITING_ACCOUNT]: isLogin ? "Login" : "Sign Up",
84
+ [ModalStep.ACCOUNT_WALLET]: (_a2 = profileWallet == null ? void 0 : profileWallet.displayName) != null ? _a2 : "Wallet Settings"
85
+ };
86
+ },
82
87
  [isLogin, chainId, hideWallets, authStepTitle]
83
88
  );
84
89
  const title = useMemo(() => {
@@ -7,14 +7,15 @@ import { IFrameSteps } from "../../utils/steps.js";
7
7
  import { safeStyled } from "@getpara/react-common";
8
8
  import { SpinnerContainer, MOBILE_SIZE } from "@getpara/react-common";
9
9
  import { CpslSpinner } from "@getpara/react-components";
10
- import { getPortalBaseURL } from "@getpara/web-sdk";
11
10
  import { useStore } from "../../../provider/stores/useStore.js";
12
11
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
12
+ import { validatePortalOrigin } from "../../utils/validatePortalOrigin.js";
13
13
  const IFrameStep = () => {
14
14
  const iFrameUrl = useModalStore((state) => state.iFrameUrl);
15
15
  const setIsReady = useModalStore((state) => state.setIsIFrameReady);
16
16
  const isReady = useModalStore((state) => state.isIFrameReady);
17
17
  const currentStep = useModalStore((state) => state.step);
18
+ const refs = useModalStore((state) => state.refs);
18
19
  const embeddedModal = useStore((state) => {
19
20
  var _a;
20
21
  return (_a = state.modalConfig) == null ? void 0 : _a.embeddedModal;
@@ -31,8 +32,7 @@ const IFrameStep = () => {
31
32
  if (!iFrameUrl) {
32
33
  return;
33
34
  }
34
- const portalBase = getPortalBaseURL(para.ctx);
35
- if (!event.origin.startsWith(portalBase)) {
35
+ if (!validatePortalOrigin(event, para.ctx)) {
36
36
  return;
37
37
  }
38
38
  if (event.data) {
@@ -42,11 +42,13 @@ const IFrameStep = () => {
42
42
  }
43
43
  }
44
44
  };
45
- window.addEventListener("message", handleMessage);
46
- return () => window.removeEventListener("message", handleMessage);
45
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
46
+ return () => {
47
+ typeof window !== "undefined" && window.removeEventListener("message", handleMessage);
48
+ };
47
49
  }, [setIsReady, iFrameUrl]);
48
50
  return /* @__PURE__ */ jsxs(OuterContainer, { $isVisible: IFrameSteps.includes(currentStep), $embeddedModal: !!embeddedModal, $isReady: !!isReady, children: [
49
- /* @__PURE__ */ jsx(Container, { $isReady: !!isReady, $height: height, children: /* @__PURE__ */ jsx("iframe", { src: iFrameUrl }) }),
51
+ /* @__PURE__ */ jsx(Container, { $isReady: !!isReady, $height: height, children: /* @__PURE__ */ jsx("iframe", { src: iFrameUrl, ref: refs.iFrame }) }),
50
52
  !isReady && /* @__PURE__ */ jsx(SpinnerContainer, { style: { width: "100%", height: "100%", flex: 1, position: "absolute" }, children: /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) })
51
53
  ] });
52
54
  };
@@ -5,8 +5,8 @@ import { CpslSpinner } from "@getpara/react-components";
5
5
  import { useFarcasterLogin } from "../../hooks/useFarcasterLogin.js";
6
6
  import { safeStyled } from "@getpara/react-common";
7
7
  import { useEffect, useState } from "react";
8
- import { getPortalBaseURL } from "@getpara/web-sdk";
9
8
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
9
+ import { validatePortalOrigin } from "../../utils/validatePortalOrigin.js";
10
10
  function FarcasterOAuthStep() {
11
11
  const { url, isLoaded, setIsLoaded } = useFarcasterLogin({
12
12
  isActive: true
@@ -18,8 +18,7 @@ function FarcasterOAuthStep() {
18
18
  if (!url) {
19
19
  return;
20
20
  }
21
- const portalBase = getPortalBaseURL(para.ctx);
22
- if (!event.origin.startsWith(portalBase)) {
21
+ if (!validatePortalOrigin(event, para.ctx)) {
23
22
  return;
24
23
  }
25
24
  if (event.data) {
@@ -28,8 +27,10 @@ function FarcasterOAuthStep() {
28
27
  }
29
28
  }
30
29
  };
31
- window.addEventListener("message", handleMessage);
32
- return () => window.removeEventListener("message", handleMessage);
30
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
31
+ return () => {
32
+ typeof window !== "undefined" && window.removeEventListener("message", handleMessage);
33
+ };
33
34
  }, [url]);
34
35
  return /* @__PURE__ */ jsxs(Container, { children: [
35
36
  url && /* @__PURE__ */ jsx(IFrame, { style: { display: isLoaded ? "block" : "none", height }, src: url, onLoad: () => setIsLoaded(true) }),
@@ -7,8 +7,8 @@ import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
7
7
  import { useEffect, useState } from "react";
8
8
  import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
9
9
  import { useModalStore } from "../../stores/index.js";
10
- import { getPortalBaseURL } from "@getpara/web-sdk";
11
10
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
11
+ import { validatePortalOrigin } from "../../utils/validatePortalOrigin.js";
12
12
  function TelegramOAuthStep() {
13
13
  const { verifyTelegramStatus, verifyTelegram } = useAuthActions();
14
14
  const { url, isLoaded, setIsLoaded } = useTelegramLogin({
@@ -25,8 +25,7 @@ function TelegramOAuthStep() {
25
25
  if (!url) {
26
26
  return;
27
27
  }
28
- const portalBase = getPortalBaseURL(para.ctx, true);
29
- if (!event.origin.startsWith(portalBase)) {
28
+ if (!validatePortalOrigin(event, para.ctx)) {
30
29
  return;
31
30
  }
32
31
  if (event.data) {
@@ -35,8 +34,10 @@ function TelegramOAuthStep() {
35
34
  }
36
35
  }
37
36
  };
38
- window.addEventListener("message", handleMessage);
39
- return () => window.removeEventListener("message", handleMessage);
37
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
38
+ return () => {
39
+ typeof window !== "undefined" && window.removeEventListener("message", handleMessage);
40
+ };
40
41
  }, [url]);
41
42
  return /* @__PURE__ */ jsxs(Container, { children: [
42
43
  url && /* @__PURE__ */ jsx(
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { useEffect, useRef } from "react";
5
5
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
6
6
  import { useDropdownPosition } from "../AuthInput/hooks/useDropdownPosition.js";
7
- import { safeStyled, useCopyToClipboard, WalletTypeIcon as WalletTypeIconBase } from "@getpara/react-common";
7
+ import { MOBILE_SIZE, safeStyled, useCopyToClipboard, WalletTypeIcon as WalletTypeIconBase } from "@getpara/react-common";
8
8
  import { useAccount, useWallet, useWalletState } from "../../../provider/index.js";
9
9
  import { CpslButton, CpslIcon, CpslSelect, CpslSelectItem, CpslText } from "@getpara/react-components";
10
10
  const getValue = (id, type) => {
@@ -61,7 +61,7 @@ const WalletSelectOld = () => {
61
61
  }, [activeWallet, availableWallets, dropdownMaxHeight]);
62
62
  return /* @__PURE__ */ jsxs(Container, { children: [
63
63
  isMultiWallet && /* @__PURE__ */ jsx(CpslText, { variant: "bodyM", color: "secondary", weight: "semiBold", children: "Select Wallet" }),
64
- /* @__PURE__ */ jsx(SelectContainer, { ref: containerRef, id: "addressInputContainer", children: /* @__PURE__ */ jsxs(
64
+ /* @__PURE__ */ jsx(SelectContainer, { ref: containerRef, id: "addressInputContainerOld", children: /* @__PURE__ */ jsxs(
65
65
  Select,
66
66
  {
67
67
  selectedValue: getValue(activeWallet == null ? void 0 : activeWallet.id, activeWallet == null ? void 0 : activeWallet.type),
@@ -71,10 +71,10 @@ const WalletSelectOld = () => {
71
71
  },
72
72
  showFormattedSelectedItem: true,
73
73
  placeholder: "Choose wallet...",
74
- anchorElId: "addressInputContainer",
74
+ anchorElId: "addressInputContainerOld",
75
75
  dropdownMaxHeight,
76
76
  $width: dropdownWidth != null ? dropdownWidth : 0,
77
- $top: (mobileAnchor != null ? mobileAnchor : 0) + 16 + 1,
77
+ $top: (mobileAnchor != null ? mobileAnchor : 0) + 220 + 1,
78
78
  selectedItemVariant: "bodyXS",
79
79
  icon: isMultiWallet ? "chevronUp" : null,
80
80
  disabled: !isMultiWallet,
@@ -114,7 +114,20 @@ const Select = safeStyled(CpslSelect)`
114
114
 
115
115
  &::part(dropdown) {
116
116
  min-width: ${({ $width }) => `${$width - 2}px`};
117
+ }
118
+
119
+ &::part(popover) {
120
+ /* Have to adjust the top of the popover here since we're using a transform on the modal which causes fixed position items to not be relative to the viewport */
121
+ @media (max-width: ${MOBILE_SIZE}px) {
122
+ top: ${({ $top }) => $top ? `${$top}px` : "0px"};
123
+ bottom: 16px;
124
+ }
125
+ cpsl-auth-modal.force-mobile-media & {
126
+ top: ${({ $top }) => $top ? `${$top}px` : "0px"};
127
+ bottom: 16px;
128
+ }
117
129
  }
130
+
118
131
 
119
132
  &::part(icon) {
120
133
  --icon-color: var(--cpsl-color-text-primary);
@@ -6,6 +6,7 @@ import { useEffect, useState } from "react";
6
6
  import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
7
7
  import { useModalStore } from "../stores/index.js";
8
8
  import { useAuthActions } from "../../provider/providers/AuthProvider.js";
9
+ import { validatePortalOrigin } from "../utils/validatePortalOrigin.js";
9
10
  const useFarcasterLogin = ({
10
11
  isActive = false
11
12
  } = {}) => {
@@ -29,8 +30,12 @@ const useFarcasterLogin = ({
29
30
  }
30
31
  }, [isActive, url]);
31
32
  useEffect(() => {
33
+ if (typeof window === "undefined") return;
32
34
  const updateState = (event) => __async(void 0, null, function* () {
33
35
  var _a, _b;
36
+ if (!validatePortalOrigin(event, para.ctx)) {
37
+ return;
38
+ }
34
39
  switch (event.data.type) {
35
40
  case "FARCASTER_LOGIN":
36
41
  setMsgStatus("pending");
@@ -55,7 +60,9 @@ const useFarcasterLogin = ({
55
60
  window == null ? void 0 : window.addEventListener("message", updateState, false);
56
61
  }
57
62
  return () => {
58
- window == null ? void 0 : window.removeEventListener("message", updateState, false);
63
+ if (typeof window !== "undefined") {
64
+ window.removeEventListener("message", updateState, false);
65
+ }
59
66
  };
60
67
  }, [isActive]);
61
68
  return {
@@ -5,6 +5,7 @@ import {
5
5
  import { useEffect, useState } from "react";
6
6
  import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
7
7
  import { useModalStore } from "../stores/index.js";
8
+ import { validatePortalOrigin } from "../utils/validatePortalOrigin.js";
8
9
  const useTelegramLogin = ({
9
10
  isActive = false,
10
11
  onSubmit,
@@ -34,6 +35,9 @@ const useTelegramLogin = ({
34
35
  useEffect(() => {
35
36
  const updateState = (event) => __async(void 0, null, function* () {
36
37
  var _a, _b;
38
+ if (!validatePortalOrigin(event, para.ctx)) {
39
+ return;
40
+ }
37
41
  switch (event.data.type) {
38
42
  case "TELEGRAM_LOGIN":
39
43
  setMsgStatus("pending");
@@ -137,7 +137,8 @@ const getActions = (set, get) => ({
137
137
  },
138
138
  setAuthStepRoute: (authStepRoute) => set({ authStepRoute }),
139
139
  setIsPasskeySupported: (isPasskeySupported) => set({ isPasskeySupported }),
140
- setAccountLinkOptions: (accountLinkOptions) => set({ accountLinkOptions })
140
+ setAccountLinkOptions: (accountLinkOptions) => set({ accountLinkOptions }),
141
+ setProfileWallet: (profileWallet) => set({ profileWallet })
141
142
  });
142
143
  export {
143
144
  getActions
@@ -1,3 +1,4 @@
1
+ import { AvailableWallet } from '@getpara/core-sdk';
1
2
  import { ModalStep } from '../../utils/steps.js';
2
3
  import { AuthStateLogin, AuthStateSignup, AuthState, AuthStateVerify, OnRampConfig as OnRampConfigBase, OnRampPurchase, TWalletType, Setup2faResponse, SupportedAccountLinks } from '@getpara/web-sdk';
3
4
  import { Tab as AddFundsTabType } from '../../components/AddFunds/AddFundsContext.js';
@@ -55,9 +56,11 @@ interface ModalState {
55
56
  telegramIFrame: MutableRefObject<HTMLIFrameElement | null>;
56
57
  wasSignedIn: MutableRefObject<boolean | null>;
57
58
  initialFarcasterConnected: MutableRefObject<boolean | null>;
59
+ iFrame: MutableRefObject<HTMLIFrameElement | null>;
58
60
  };
59
61
  isPasskeySupported: boolean;
60
62
  accountLinkOptions: SupportedAccountLinks;
63
+ profileWallet?: AvailableWallet;
61
64
  }
62
65
  export interface ModalActions {
63
66
  resetState: () => void;
@@ -96,6 +99,7 @@ export interface ModalActions {
96
99
  setAuthStepRoute: (_?: ModalStep) => void;
97
100
  setIsPasskeySupported: (_: boolean) => void;
98
101
  setAccountLinkOptions: (_: SupportedAccountLinks) => void;
102
+ setProfileWallet: (_?: AvailableWallet) => void;
99
103
  }
100
104
  export type ModalStore = ModalState & ModalActions;
101
105
  export declare const DEFAULT_MODAL_STATE: Omit<ModalState, 'step' | 'onRampConfig'>;
@@ -44,10 +44,12 @@ const DEFAULT_MODAL_STATE = {
44
44
  currentStep: createRef(),
45
45
  telegramIFrame: createRef(),
46
46
  wasSignedIn: createRef(),
47
- initialFarcasterConnected: createRef()
47
+ initialFarcasterConnected: createRef(),
48
+ iFrame: createRef()
48
49
  },
49
50
  isPasskeySupported: true,
50
- accountLinkOptions: [...LINKED_ACCOUNT_TYPES]
51
+ accountLinkOptions: [...LINKED_ACCOUNT_TYPES],
52
+ profileWallet: void 0
51
53
  };
52
54
  const useModalStore = create()(
53
55
  persist(
@@ -1,6 +1,6 @@
1
1
  export declare function openPopup({ url, target, type, current, }: {
2
2
  url: string;
3
3
  target: string;
4
- type: 'OAUTH' | 'LOGIN_PASSKEY' | 'CREATE_PASSKEY' | 'TRANSACTION_REVIEW' | 'CREATE_PASSWORD' | 'LOGIN_PASSWORD' | 'SWITCH_WALLETS' | 'ADD_CREDENTIAL';
4
+ type: 'OAUTH' | 'LOGIN_PASSKEY' | 'CREATE_PASSKEY' | 'TRANSACTION_REVIEW' | 'CREATE_PASSWORD' | 'LOGIN_PASSWORD' | 'SWITCH_WALLETS' | 'ADD_CREDENTIAL' | 'LOGIN_EXTERNAL_WALLET';
5
5
  current?: Window | null;
6
6
  }): Window | null;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import "../../chunk-MMUBH76A.js";
3
+ import { isMobile } from "@getpara/web-sdk";
3
4
  function openPopup({
4
5
  url,
5
6
  target,
@@ -36,6 +37,7 @@ function openPopup({
36
37
  }
37
38
  case "OAUTH":
38
39
  case "ADD_CREDENTIAL":
40
+ case "LOGIN_EXTERNAL_WALLET":
39
41
  default: {
40
42
  popUpHeight = 768;
41
43
  break;
@@ -49,7 +51,7 @@ function openPopup({
49
51
  const top = (height - popUpHeight) / 2 + dualScreenTop;
50
52
  const windowFeatures = `toolbar=no, menubar=no, width=${popUpWidth},
51
53
  height=${popUpHeight}, top=${top}, left=${left}`;
52
- let popupWindow = window.open(url, target, windowFeatures);
54
+ let popupWindow = window.open(url, isMobile() ? "_blank" : target, windowFeatures);
53
55
  if (!popupWindow) {
54
56
  setTimeout(() => {
55
57
  popupWindow = window.open(url, "_blank");
@@ -1,4 +1,4 @@
1
- import { EnabledFlow } from '@getpara/web-sdk';
1
+ import { EnabledFlow } from '@getpara/core-sdk/src/types/config.js';
2
2
  export declare enum ModalStep {
3
3
  AUTH_MAIN = "AUTH_MAIN",
4
4
  AUTH_MORE = "AUTH_MORE",
@@ -39,6 +39,7 @@ export declare enum ModalStep {
39
39
  ACCOUNT_PROFILE_ADD = "ACCOUNT_PROFILE_ADD",
40
40
  ACCOUNT_PROFILE_LIST = "ACCOUNT_PROFILE_LIST",
41
41
  ACCOUNT_PROFILE_REMOVE = "ACCOUNT_PROFILE_REMOVE",
42
+ ACCOUNT_WALLET = "ACCOUNT_WALLET",
42
43
  AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
43
44
  SWITCH_WALLETS = "SWITCH_WALLETS",
44
45
  SWITCH_WALLETS_IFRAME = "SWITCH_WALLETS_IFRAME",
@@ -65,6 +66,7 @@ declare enum AccountStep {
65
66
  ACCOUNT_PROFILE_ADD = "ACCOUNT_PROFILE_ADD",
66
67
  ACCOUNT_PROFILE_LIST = "ACCOUNT_PROFILE_LIST",
67
68
  ACCOUNT_PROFILE_REMOVE = "ACCOUNT_PROFILE_REMOVE",
69
+ ACCOUNT_WALLET = "ACCOUNT_WALLET",
68
70
  SWITCH_WALLETS = "SWITCH_WALLETS",
69
71
  SWITCH_WALLETS_IFRAME = "SWITCH_WALLETS_IFRAME",
70
72
  EXTERNAL_WALLET_VERIFICATION = "EXTERNAL_WALLET_VERIFICATION",