@getpara/react-sdk-lite 2.0.0-alpha.67 → 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 (29) hide show
  1. package/dist/modal/components/Account/AccountWalletSelect.js +15 -2
  2. package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -3
  3. package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +2 -2
  4. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +2 -1
  5. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +36 -29
  6. package/dist/modal/components/ExternalWallets/ExternalWallets.js +2 -2
  7. package/dist/modal/components/IFrameStep/IFrameStep.js +8 -6
  8. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
  9. package/dist/modal/components/OAuth/TelegramOAuthStep.js +6 -5
  10. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +17 -4
  11. package/dist/modal/hooks/useFarcasterLogin.js +8 -1
  12. package/dist/modal/hooks/useTelegramLogin.js +4 -0
  13. package/dist/modal/stores/modal/useModalStore.d.ts +1 -0
  14. package/dist/modal/stores/modal/useModalStore.js +2 -1
  15. package/dist/modal/utils/openPopup.d.ts +1 -1
  16. package/dist/modal/utils/openPopup.js +3 -1
  17. package/dist/modal/utils/stringFormatters.js +10 -1
  18. package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
  19. package/dist/modal/utils/validatePortalOrigin.js +14 -0
  20. package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +3 -3
  21. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +6 -0
  22. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +16 -28
  23. package/dist/provider/hooks/utils/useEventListeners.js +2 -0
  24. package/dist/provider/providers/AuthProvider.js +73 -34
  25. package/dist/provider/providers/ExternalWalletProvider.d.ts +7 -1
  26. package/dist/provider/providers/ExternalWalletProvider.js +240 -27
  27. package/package.json +8 -8
  28. package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
  29. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
@@ -4,7 +4,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { useEffect, useMemo, useRef } from "react";
5
5
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
6
6
  import { useDropdownPosition } from "../AuthInput/hooks/useDropdownPosition.js";
7
- import { getExternalWalletIcon, safeStyled, useCopyToClipboard } from "@getpara/react-common";
7
+ import { getExternalWalletIcon, MOBILE_SIZE, safeStyled, useCopyToClipboard } 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
  import { truncateAddress } from "@getpara/web-sdk";
@@ -92,7 +92,7 @@ const AccountWalletSelect = () => {
92
92
  anchorElId: "addressInputContainer",
93
93
  dropdownMaxHeight,
94
94
  $width: dropdownWidth != null ? dropdownWidth : 0,
95
- $top: (mobileAnchor != null ? mobileAnchor : 0) + 16 + 1,
95
+ $top: (mobileAnchor != null ? mobileAnchor : 0) + 184 + 1,
96
96
  selectedItemVariant: "bodyXS",
97
97
  icon: isMultiWallet ? "chevronUp" : null,
98
98
  disabled: !isMultiWallet,
@@ -108,6 +108,7 @@ const AccountWalletSelect = () => {
108
108
  ) }) });
109
109
  };
110
110
  const Container = safeStyled.div`
111
+ flex: 0;
111
112
  display: flex;
112
113
  flex-direction: column;
113
114
  gap: 8px;
@@ -145,6 +146,18 @@ const Select = safeStyled(CpslSelect)`
145
146
  min-width: ${({ $width }) => `${$width - 2}px`};
146
147
  }
147
148
 
149
+ &::part(popover) {
150
+ /* 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 */
151
+ @media (max-width: ${MOBILE_SIZE}px) {
152
+ top: ${({ $top }) => $top ? `${$top}px` : "0px"};
153
+ bottom: 16px;
154
+ }
155
+ cpsl-auth-modal.force-mobile-media & {
156
+ top: ${({ $top }) => $top ? `${$top}px` : "0px"};
157
+ bottom: 16px;
158
+ }
159
+ }
160
+
148
161
  &::part(icon) {
149
162
  --icon-color: var(--cpsl-color-text-primary);
150
163
  }
@@ -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
  });
@@ -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");
@@ -56,6 +56,7 @@ interface ModalState {
56
56
  telegramIFrame: MutableRefObject<HTMLIFrameElement | null>;
57
57
  wasSignedIn: MutableRefObject<boolean | null>;
58
58
  initialFarcasterConnected: MutableRefObject<boolean | null>;
59
+ iFrame: MutableRefObject<HTMLIFrameElement | null>;
59
60
  };
60
61
  isPasskeySupported: boolean;
61
62
  accountLinkOptions: SupportedAccountLinks;
@@ -44,7 +44,8 @@ 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
51
  accountLinkOptions: [...LINKED_ACCOUNT_TYPES],
@@ -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");
@@ -3,7 +3,16 @@ import "../../chunk-MMUBH76A.js";
3
3
  import { getNetworkName } from "@getpara/react-common";
4
4
  import { format } from "date-fns";
5
5
  const formatNetworkList = (networks) => {
6
- return networks.length === 1 ? getNetworkName(networks[0]) : `${networks.map((id) => getNetworkName(id)).slice(0, -1).join(", ")}${networks.length > 2 ? "," : ""} and ${getNetworkName(networks[networks.length - 1])}`;
6
+ if (networks.length === 0) {
7
+ return "";
8
+ }
9
+ if (networks.length === 1) {
10
+ return getNetworkName(networks[0]);
11
+ }
12
+ const networkNames = networks.map((id) => getNetworkName(id));
13
+ const allButLast = networkNames.slice(0, -1);
14
+ const last = networkNames[networkNames.length - 1];
15
+ return `${allButLast.join(", ")}${networks.length > 2 ? "," : ""} and ${last}`;
7
16
  };
8
17
  const formatWalletCreatedDate = (date) => `${format(new Date(date), "M/d/y")}`;
9
18
  const camelToSnakeCase = (str) => str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
@@ -0,0 +1,2 @@
1
+ import { Ctx } from '@getpara/web-sdk';
2
+ export declare const validatePortalOrigin: (event: MessageEvent, paraCtx: Ctx) => boolean;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import "../../chunk-MMUBH76A.js";
3
+ import { getPortalBaseURL } from "@getpara/web-sdk";
4
+ const validatePortalOrigin = (event, paraCtx) => {
5
+ const portalBase = getPortalBaseURL(paraCtx);
6
+ const portalLocalBase = getPortalBaseURL(paraCtx, true);
7
+ if (event.origin !== portalBase && event.origin !== portalLocalBase) {
8
+ return false;
9
+ }
10
+ return true;
11
+ };
12
+ export {
13
+ validatePortalOrigin
14
+ };
@@ -22,7 +22,7 @@ export declare const useAddAuthMethod: ({ openPopup }?: {
22
22
  data: string | undefined;
23
23
  isSuccess: boolean;
24
24
  variables: void | {
25
- authMethod?: Exclude<import("@getpara/web-sdk").TAuthMethod, "BASIC_LOGIN"> | undefined;
25
+ authMethod?: import("@getpara/web-sdk").TAuthMethod | undefined;
26
26
  } | undefined;
27
27
  isError: boolean;
28
28
  isIdle: boolean;
@@ -34,9 +34,9 @@ export declare const useAddAuthMethod: ({ openPopup }?: {
34
34
  isPaused: boolean;
35
35
  submittedAt: number;
36
36
  addAuthMethod: import("@tanstack/react-query").UseMutateFunction<string, Error, void | {
37
- authMethod?: Exclude<import("@getpara/web-sdk").TAuthMethod, "BASIC_LOGIN"> | undefined;
37
+ authMethod?: import("@getpara/web-sdk").TAuthMethod | undefined;
38
38
  }, unknown>;
39
39
  addAuthMethodAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, void | {
40
- authMethod?: Exclude<import("@getpara/web-sdk").TAuthMethod, "BASIC_LOGIN"> | undefined;
40
+ authMethod?: import("@getpara/web-sdk").TAuthMethod | undefined;
41
41
  }, unknown>;
42
42
  };
@@ -23,6 +23,8 @@ export declare const useLoginExternalWallet: () => {
23
23
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
24
24
  useShortUrls?: boolean | undefined;
25
25
  externalWallet: import("@getpara/web-sdk").ExternalWalletInfo | import("@getpara/web-sdk").ExternalWalletInfo[];
26
+ chainId?: string | undefined;
27
+ uri?: string | undefined;
26
28
  } | undefined;
27
29
  isError: boolean;
28
30
  isIdle: boolean;
@@ -37,10 +39,14 @@ export declare const useLoginExternalWallet: () => {
37
39
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
38
40
  useShortUrls?: boolean | undefined;
39
41
  externalWallet: import("@getpara/web-sdk").ExternalWalletInfo | import("@getpara/web-sdk").ExternalWalletInfo[];
42
+ chainId?: string | undefined;
43
+ uri?: string | undefined;
40
44
  }, unknown>;
41
45
  loginExternalWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateVerifyOrLogin>, Error, {
42
46
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
43
47
  useShortUrls?: boolean | undefined;
44
48
  externalWallet: import("@getpara/web-sdk").ExternalWalletInfo | import("@getpara/web-sdk").ExternalWalletInfo[];
49
+ chainId?: string | undefined;
50
+ uri?: string | undefined;
45
51
  }, unknown>;
46
52
  };