@getpara/react-sdk-lite 2.0.0-dev.5 → 2.0.0-dev.7

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 (40) hide show
  1. package/dist/modal/ParaModal.js +1 -1
  2. package/dist/modal/components/Account/Account.js +3 -3
  3. package/dist/modal/components/Account/AccountProfileLink.js +3 -3
  4. package/dist/modal/components/AddFunds/AddFunds.js +5 -7
  5. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.d.ts +1 -0
  6. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +20 -0
  7. package/dist/modal/components/Body/Body.js +4 -4
  8. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +20 -1
  9. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +6 -3
  10. package/dist/modal/components/Header/hooks/useStepTitle.js +2 -1
  11. package/dist/modal/components/OAuth/FarcasterLink.d.ts +2 -0
  12. package/dist/modal/components/OAuth/FarcasterLink.js +30 -0
  13. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -3
  14. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +47 -26
  15. package/dist/modal/components/OAuth/OAuth.js +2 -2
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +35 -19
  17. package/dist/modal/constants/constants.js +1 -1
  18. package/dist/modal/hooks/useFarcasterLogin.d.ts +9 -0
  19. package/dist/modal/hooks/useFarcasterLogin.js +70 -0
  20. package/dist/modal/hooks/useTelegramLogin.d.ts +4 -3
  21. package/dist/modal/hooks/useTelegramLogin.js +11 -3
  22. package/dist/modal/stores/modal/useModalStore.js +2 -1
  23. package/dist/modal/utils/steps.d.ts +6 -3
  24. package/dist/modal/utils/steps.js +14 -8
  25. package/dist/provider/ParaProviderMin.js +3 -3
  26. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +3 -3
  27. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +6 -3
  28. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +3 -3
  29. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +9 -6
  30. package/dist/provider/providers/AuthProvider.d.ts +6 -4
  31. package/dist/provider/providers/AuthProvider.js +120 -52
  32. package/dist/provider/providers/ExternalWalletProvider.d.ts +2 -0
  33. package/dist/provider/providers/ExternalWalletProvider.js +23 -4
  34. package/dist/provider/stores/useStore.js +2 -1
  35. package/dist/provider/types/provider.d.ts +1 -1
  36. package/dist/provider/utils/paraConfigTypeGuards.d.ts +1 -1
  37. package/dist/provider/utils/paraConfigTypeGuards.js +1 -1
  38. package/package.json +8 -8
  39. package/dist/modal/components/AwaitingIFrameStep/AwaitingIFrameStep.d.ts +0 -1
  40. package/dist/modal/components/AwaitingIFrameStep/AwaitingIFrameStep.js +0 -12
@@ -117,7 +117,7 @@ const ParaModal = forwardRef((props, ref) => {
117
117
  });
118
118
  trackAnalytics();
119
119
  }, []);
120
- const isOpen = configIsOpen != null ? configIsOpen : storedIsOpen;
120
+ const isOpen = bareModal || (configIsOpen != null ? configIsOpen : storedIsOpen);
121
121
  useImperativeHandle(ref, () => {
122
122
  return {
123
123
  goBack() {
@@ -32,9 +32,9 @@ const Account = () => {
32
32
  setGuestAddFundsTab(EnabledFlow.BUY);
33
33
  setStep(ModalStep.AUTH_GUEST_SIGNUP);
34
34
  }
35
- } else {
35
+ } else if ((onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) || (onRampConfig == null ? void 0 : onRampConfig.isReceiveEnabled)) {
36
36
  setOnRampStep(OnRampStep.SETTINGS);
37
- setStep(ModalStep.ADD_FUNDS_BUY);
37
+ setStep((onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) ? ModalStep.ADD_FUNDS_BUY : ModalStep.ADD_FUNDS_RECEIVE);
38
38
  }
39
39
  };
40
40
  const handleSellClick = () => {
@@ -76,7 +76,7 @@ const Account = () => {
76
76
  )
77
77
  ] }),
78
78
  /* @__PURE__ */ jsx(ButtonContainer, { children: isOnRampLoaded ? /* @__PURE__ */ jsxs(Fragment, { children: [
79
- onRampConfig.isBuyEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "plusCircle", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Add Funds" }) }),
79
+ (onRampConfig.isBuyEnabled || onRampConfig.isReceiveEnabled) && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "plusCircle", onClick: handleBuyClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Add Funds" }) }),
80
80
  onRampConfig.isWithdrawEnabled && !cantBuyAndWithdraw && /* @__PURE__ */ jsx(OptionButton, { icon: "arrowCircleDown", onClick: handleSellClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Withdraw" }) }),
81
81
  /* @__PURE__ */ jsx(OptionButton, { icon: "user01", onClick: handleProfileClick, children: /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isEnabled ? "Profile" : "Settings" }) })
82
82
  ] }) : /* @__PURE__ */ jsx(CpslSpinner, {}) })
@@ -9,7 +9,7 @@ import { useEffect, useMemo } from "react";
9
9
  import { HeroAccountTypeIcon, HeroSuccessIcon } from "../common.js";
10
10
  import { VerificationCode } from "../VerificationCodeStep/VerificationCodeStep.js";
11
11
  import { extractAuthInfo } from "@getpara/user-management-client";
12
- import { FarcasterConnectQR } from "../OAuth/FarcasterOAuthStep.js";
12
+ import { FarcasterLink } from "../OAuth/FarcasterLink.js";
13
13
  import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
14
14
  import { TelegramIFrame } from "../OAuth/TelegramOAuthStep.js";
15
15
  import { AuthInput } from "../AuthInput/AuthInput.js";
@@ -35,7 +35,7 @@ function AccountProfileLink() {
35
35
  isLoaded,
36
36
  setIsLoaded
37
37
  } = useTelegramLogin(
38
- isTelegram ? { isActive: isTelegram, status: linkAccountStatus, onSubmit: verifyTelegramLink } : { isActive: false }
38
+ isTelegram ? { isActive: isTelegram, status: linkAccountStatus, onSubmit: verifyTelegramLink, isLinking: true } : { isActive: false, isLinking: true }
39
39
  ), status = (accountLinkInProgress == null ? void 0 : accountLinkInProgress.isComplete) ? "success" : isTelegram ? telegramStatus : linkAccountStatus, commonWallet = useMemo(() => {
40
40
  const wallet = wallets.find(
41
41
  (w) => [w.name, w.internalId, w.id].includes(externalWalletProvider != null ? externalWalletProvider : "") && w.type === externalWalletType
@@ -140,7 +140,7 @@ function AccountProfileLink() {
140
140
  break;
141
141
  // Farcaster Connect QR
142
142
  case (accountLinkType === "FARCASTER" && status !== "success"):
143
- lower2 = /* @__PURE__ */ jsx(FarcasterConnectQR, {});
143
+ lower2 = /* @__PURE__ */ jsx(FarcasterLink, {});
144
144
  break;
145
145
  // OAuth, External Wallet, Telegram
146
146
  default:
@@ -30,7 +30,7 @@ const AddFunds = () => {
30
30
  ([enabledFlow, key]) => !!(onRampConfig == null ? void 0 : onRampConfig[key]) && (!isGuestMode || enabledFlow === EnabledFlow.RECEIVE)
31
31
  );
32
32
  const tab = storedTab != null ? storedTab : tabs[0][0];
33
- const isMultiFlow = (tab === EnabledFlow.BUY || tab === EnabledFlow.RECEIVE) && tabs.length > 1;
33
+ const isMultiFlow = (tab === EnabledFlow.BUY || tab === EnabledFlow.RECEIVE) && (onRampConfig == null ? void 0 : onRampConfig.isBuyEnabled) && (onRampConfig == null ? void 0 : onRampConfig.isReceiveEnabled);
34
34
  const onSetTab = (event) => {
35
35
  setModalStep(getAddFundsStep(event.detail.tab));
36
36
  };
@@ -56,12 +56,10 @@ const AddFunds = () => {
56
56
  return /* @__PURE__ */ jsx(SpinnerContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, {}) });
57
57
  }
58
58
  return /* @__PURE__ */ jsxs(StepContainer, { children: [
59
- isMultiFlow && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslTabs, { selectedTab: tab, onCpslTabsChanged: onSetTab, children: TABS.filter(([enabledFlow]) => enabledFlow === EnabledFlow.BUY || enabledFlow === EnabledFlow.RECEIVE).map(
60
- ([tab2, _, icon, title]) => /* @__PURE__ */ jsxs(CpslTab, { tab: tab2, children: [
61
- /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon }),
62
- title
63
- ] }, tab2)
64
- ) }) }),
59
+ isMultiFlow && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslTabs, { selectedTab: tab, onCpslTabsChanged: onSetTab, children: tabs.filter(([enabledFlow]) => enabledFlow !== EnabledFlow.WITHDRAW).map(([tab2, _, icon, title]) => /* @__PURE__ */ jsxs(CpslTab, { tab: tab2, children: [
60
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon }),
61
+ title
62
+ ] }, tab2)) }) }),
65
63
  (step === ModalStep.ADD_FUNDS_RECEIVE || (embedded == null ? void 0 : embedded.wallets) && embedded.wallets.length > 1) && /* @__PURE__ */ jsx(WalletSelectOld, {}),
66
64
  /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsx(AddFundsContextProvider, { "data-testid": "add-funds", tab, children: Content }) })
67
65
  ] });
@@ -0,0 +1 @@
1
+ export declare const AwaitingAccountStep: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { useModalStore } from "../../stores/index.js";
5
+ import { Waiting } from "../Waiting/Waiting.js";
6
+ const AwaitingAccountStep = () => {
7
+ const isLogin = useModalStore((state) => state.isLogin());
8
+ const verifyState = useModalStore((state) => state.getVerifyState());
9
+ const isSLOPopup = !!(verifyState == null ? void 0 : verifyState.isWalletSelectionNeeded);
10
+ return /* @__PURE__ */ jsx(
11
+ Waiting,
12
+ {
13
+ heading: isLogin ? "Logging you in..." : "Creating your account...",
14
+ subheading: isSLOPopup ? "Follow the prompts presented by your browser." : void 0
15
+ }
16
+ );
17
+ };
18
+ export {
19
+ AwaitingAccountStep
20
+ };
@@ -18,7 +18,7 @@ import { TwoFactorDoneStep } from "../TwoFactorDoneStep/TwoFactorDoneStep.js";
18
18
  import { BiometricCreationStep } from "../BiometricCreationStep/BiometricCreationStep.js";
19
19
  import { AwaitingOAuthStep } from "../AwaitingOAuthStep/AwaitingOAuthStep.js";
20
20
  import { AddFundsAwaiting, AddFundsDone, AddFunds } from "../AddFunds/index.js";
21
- import FarcasterOAuthStep from "../OAuth/FarcasterOAuthStep.js";
21
+ import { FarcasterOAuthStep } from "../OAuth/FarcasterOAuthStep.js";
22
22
  import { Header } from "../Header/Header.js";
23
23
  import { AuthMainStep } from "../AuthMainStep/AuthMainStep.js";
24
24
  import { BODY_MOTION_VARIANTS, BODY_TRANSITION, MOBILE_SIZE } from "../../constants/constants.js";
@@ -42,7 +42,7 @@ import { AccountProfileLinkOptions } from "../Account/AccountProfileLinkOptions.
42
42
  import { AccountProfileLink } from "../Account/AccountProfileLink.js";
43
43
  import { AccountProfileUnlink } from "../Account/AccountProfileUnlink.js";
44
44
  import { ExternalWalletNetworkSelectStep } from "../ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js";
45
- import { AwaitingIFrameStep } from "../AwaitingIFrameStep/AwaitingIFrameStep.js";
45
+ import { AwaitingAccountStep } from "../AwaitingAccountStep/AwaitingAccountStep.js";
46
46
  import { Footer } from "../Footer/Footer.js";
47
47
  const MIN_HEIGHT = {
48
48
  [ModalStep.ADD_FUNDS_AWAITING]: "680px"
@@ -189,8 +189,8 @@ const Body = ({
189
189
  case ModalStep.EX_WALLET_NETWORK_SELECT: {
190
190
  return /* @__PURE__ */ jsx(ExternalWalletNetworkSelectStep, {});
191
191
  }
192
- case ModalStep.AWAITING_IFRAME: {
193
- return /* @__PURE__ */ jsx(AwaitingIFrameStep, {});
192
+ case ModalStep.AWAITING_ACCOUNT: {
193
+ return /* @__PURE__ */ jsx(AwaitingAccountStep, {});
194
194
  }
195
195
  default: {
196
196
  if (IFrameSteps.includes(currentStep)) {
@@ -21,6 +21,7 @@ const ExternalWalletMobileConnect = ({
21
21
  isSelfFetching = false
22
22
  }) => {
23
23
  var _a, _b;
24
+ const externalWalletError = useModalStore((state) => state.externalWalletError);
24
25
  const [isCopied, copy] = useCopyToClipboard();
25
26
  const appName = useStore((state) => state.appName);
26
27
  const [qrUri, setQrUri] = useState(isSelfFetching ? void 0 : propsQrUri);
@@ -43,10 +44,28 @@ const ExternalWalletMobileConnect = ({
43
44
  useEffect(() => {
44
45
  setQrUri(propsQrUri);
45
46
  }, [propsQrUri]);
47
+ const isError = !!(externalWalletError == null ? void 0 : externalWalletError[0]);
46
48
  if (wallet.type === "SOLANA" || isMobile() && !isTablet()) {
47
49
  return /* @__PURE__ */ jsxs(Fragment, { children: [
48
- wallet.type === "SOLANA" && qrUri && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: `Continue in the ${wallet.name} mobile app.` }) }),
50
+ wallet.type === "SOLANA" && qrUri && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(
51
+ HeroSpinner,
52
+ {
53
+ icon: /* @__PURE__ */ jsx(HeroAccountTypeIcon, { accountType: wallet.internalId, src: wallet ? wallet.iconUrl : void 0 }),
54
+ status: isError ? "error" : "pending",
55
+ text: isError ? externalWalletError[0] : `Continue in the ${wallet.name} mobile app.`,
56
+ secondaryText: externalWalletError == null ? void 0 : externalWalletError[1]
57
+ }
58
+ ) }),
49
59
  wallet.id !== "WalletConnect" && /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
60
+ /* @__PURE__ */ jsx(
61
+ HeroSpinner,
62
+ {
63
+ 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.`,
66
+ secondaryText: externalWalletError == null ? void 0 : externalWalletError[1]
67
+ }
68
+ ),
50
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.` }),
51
70
  !wallet.hasIosSafariExtension && /* @__PURE__ */ jsx(Link, { href: (_a = wallet.downloadUrl) != null ? _a : "", target: "_blank", children: /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", children: [
52
71
  `Get ${wallet.name}`,
@@ -9,7 +9,7 @@ import { useExternalWallets } from "../../../provider/providers/ExternalWalletPr
9
9
  import { useEffect, useRef } from "react";
10
10
  const ExternalWalletVerificationStep = () => {
11
11
  const effectRan = useRef(false);
12
- const { verifyWalletSignature } = useExternalWallets();
12
+ const { verifyWalletSignature, verificationStage } = useExternalWallets();
13
13
  const externalWalletError = useModalStore((state) => state.externalWalletError);
14
14
  useEffect(() => {
15
15
  const hasRun = effectRan.current;
@@ -18,10 +18,13 @@ const ExternalWalletVerificationStep = () => {
18
18
  effectRan.current = true;
19
19
  }
20
20
  }, []);
21
+ const isVerifying = verificationStage === "verifying";
22
+ const header = isVerifying ? "Verifying Your Wallet" : "Switching Network";
23
+ const subheader = isVerifying ? "Sign the message with your wallet to complete sign up." : "Confirm the request to switch the network in your wallet.";
21
24
  return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
22
25
  /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
23
- /* @__PURE__ */ jsx(Heading, { children: "Verify Your Wallet" }),
24
- /* @__PURE__ */ jsx(InlineText, { variant: "bodyS", color: "secondary", children: "Sign the message with your wallet to complete sign up." }),
26
+ /* @__PURE__ */ jsx(Heading, { children: header }),
27
+ /* @__PURE__ */ jsx(InlineText, { variant: "bodyS", color: "secondary", children: subheader }),
25
28
  !!(externalWalletError == null ? void 0 : externalWalletError[0]) && /* @__PURE__ */ jsxs(ErrorContainer, { children: [
26
29
  /* @__PURE__ */ jsx(ErrorIcon, { icon: "alertCircle" }),
27
30
  /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: externalWalletError == null ? void 0 : externalWalletError[0] })
@@ -42,6 +42,7 @@ const useStepTitle = () => {
42
42
  [ModalStep.VERIFICATIONS]: "Sign Up",
43
43
  [ModalStep.AWAITING_OAUTH]: signUpOrLogInTitle,
44
44
  [ModalStep.FARCASTER_OAUTH]: signUpOrLogInTitle,
45
+ [ModalStep.TELEGRAM_OAUTH]: signUpOrLogInTitle,
45
46
  [ModalStep.BIOMETRIC_CREATION]: "Sign Up",
46
47
  [ModalStep.PASSWORD_CREATION]: "Sign Up",
47
48
  [ModalStep.AWAITING_BIOMETRIC_CREATION]: "Sign Up",
@@ -69,7 +70,7 @@ const useStepTitle = () => {
69
70
  [ModalStep.ACCOUNT_PROFILE_LIST]: "Link Account",
70
71
  [ModalStep.ACCOUNT_PROFILE_ADD]: "Link Account",
71
72
  [ModalStep.ACCOUNT_PROFILE_REMOVE]: "Unlink Account",
72
- [ModalStep.AWAITING_IFRAME]: isLogin ? "Login" : "Sign Up"
73
+ [ModalStep.AWAITING_ACCOUNT]: isLogin ? "Login" : "Sign Up"
73
74
  }),
74
75
  [isLogin, chainId, hideWallets, authStepTitle]
75
76
  );
@@ -0,0 +1,2 @@
1
+ export declare function FarcasterConnectQR(): import("react/jsx-runtime").JSX.Element;
2
+ export declare const FarcasterLink: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
5
+ import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
6
+ import { useModalStore } from "../../stores/index.js";
7
+ import { isMobile } from "@getpara/web-sdk";
8
+ function FarcasterConnectQR() {
9
+ const farcasterConnectUri = useModalStore((state) => state.farcasterConnectUri);
10
+ return /* @__PURE__ */ jsx(Fragment, { children: isMobile() ? /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
11
+ /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "secondary", children: `Don\u2019t have Farcaster` }),
12
+ /* @__PURE__ */ jsxs(CpslButton, { as: "a", href: "https://link.warpcast.com/download-qr", target: "_blank", variant: "secondary", children: [
13
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "linkExternal" }),
14
+ `Get Farcaster`
15
+ ] })
16
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
17
+ /* @__PURE__ */ jsx(Heading, { children: "Sign in using Farcaster" }),
18
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
19
+ /* @__PURE__ */ jsx(CenteredText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan the QR code with your phone's camera to proceed." }),
20
+ /* @__PURE__ */ jsx(QRContainer, { children: !farcasterConnectUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: farcasterConnectUri }) })
21
+ ] })
22
+ ] }) });
23
+ }
24
+ const FarcasterLink = () => {
25
+ return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsx(FarcasterConnectQR, {}) });
26
+ };
27
+ export {
28
+ FarcasterConnectQR,
29
+ FarcasterLink
30
+ };
@@ -1,3 +1 @@
1
- export declare function FarcasterConnectQR(): import("react/jsx-runtime").JSX.Element;
2
- declare const FarcasterOAuthStep: () => import("react/jsx-runtime").JSX.Element;
3
- export default FarcasterOAuthStep;
1
+ export declare function FarcasterOAuthStep(): import("react/jsx-runtime").JSX.Element;
@@ -1,31 +1,52 @@
1
1
  "use client";
2
2
  import "../../../chunk-MMUBH76A.js";
3
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
5
- import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
6
- import { useModalStore } from "../../stores/index.js";
7
- import { isMobile } from "@getpara/web-sdk";
8
- function FarcasterConnectQR() {
9
- const farcasterConnectUri = useModalStore((state) => state.farcasterConnectUri);
10
- return /* @__PURE__ */ jsx(Fragment, { children: isMobile() ? /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
11
- /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "secondary", children: `Don\u2019t have Farcaster` }),
12
- /* @__PURE__ */ jsxs(CpslButton, { as: "a", href: "https://link.warpcast.com/download-qr", target: "_blank", variant: "secondary", children: [
13
- /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "linkExternal" }),
14
- `Get Farcaster`
15
- ] })
16
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
17
- /* @__PURE__ */ jsx(Heading, { children: "Sign in using Farcaster" }),
18
- /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
19
- /* @__PURE__ */ jsx(CenteredText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan the QR code with your phone's camera to proceed." }),
20
- /* @__PURE__ */ jsx(QRContainer, { children: !farcasterConnectUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: farcasterConnectUri }) })
21
- ] })
22
- ] }) });
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslSpinner } from "@getpara/react-components";
5
+ import { useFarcasterLogin } from "../../hooks/useFarcasterLogin.js";
6
+ import { safeStyled } from "@getpara/react-common";
7
+ import { useEffect, useState } from "react";
8
+ import { getPortalBaseURL } from "@getpara/web-sdk";
9
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
10
+ function FarcasterOAuthStep() {
11
+ const { url, isLoaded, setIsLoaded } = useFarcasterLogin({
12
+ isActive: true
13
+ });
14
+ const para = useInternalClient();
15
+ const [height, setHeight] = useState(0);
16
+ useEffect(() => {
17
+ const handleMessage = (event) => {
18
+ if (!url) {
19
+ return;
20
+ }
21
+ const portalBase = getPortalBaseURL(para.ctx);
22
+ if (!event.origin.startsWith(portalBase)) {
23
+ return;
24
+ }
25
+ if (event.data) {
26
+ if (event.data.type === "HEIGHT") {
27
+ setHeight(event.data.height);
28
+ }
29
+ }
30
+ };
31
+ window.addEventListener("message", handleMessage);
32
+ return () => window.removeEventListener("message", handleMessage);
33
+ }, [url]);
34
+ return /* @__PURE__ */ jsxs(Container, { children: [
35
+ url && /* @__PURE__ */ jsx(IFrame, { style: { display: isLoaded ? "block" : "none", height }, src: url, onLoad: () => setIsLoaded(true) }),
36
+ (!url || !isLoaded) && /* @__PURE__ */ jsx(CpslSpinner, {})
37
+ ] });
23
38
  }
24
- const FarcasterOAuthStep = () => {
25
- return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsx(FarcasterConnectQR, {}) });
26
- };
27
- var FarcasterOAuthStep_default = FarcasterOAuthStep;
39
+ const Container = safeStyled.div`
40
+ display: flex;
41
+ flex-direction: column;
42
+ align-items: center;
43
+ justify-content: center;
44
+ width: 100%;
45
+ `;
46
+ const IFrame = safeStyled.iframe`
47
+ width: 100%;
48
+ border: none;
49
+ `;
28
50
  export {
29
- FarcasterConnectQR,
30
- FarcasterOAuthStep_default as default
51
+ FarcasterOAuthStep
31
52
  };
@@ -16,7 +16,7 @@ const OAuth = ({ methods }) => {
16
16
  const isDark = useStore((state) => state.isDarkTheme);
17
17
  const setStep = useModalStore((state) => state.setStep);
18
18
  const showAll = useModalStore((state) => state.step === ModalStep.AUTH_MORE || state.step === ModalStep.AUTH_GUEST_SIGNUP);
19
- const { verifyFarcaster, verifyOAuth } = useAuthActions();
19
+ const { verifyOAuth } = useAuthActions();
20
20
  const hasMore = methods.length > HAS_MORE_LENGTH;
21
21
  const methodsToShow = showAll || !hasMore ? methods : methods.slice(0, HAS_MORE_LENGTH - 1);
22
22
  const handleShowAll = () => {
@@ -25,7 +25,7 @@ const OAuth = ({ methods }) => {
25
25
  const handleMethodClick = (method) => () => __async(void 0, null, function* () {
26
26
  switch (method) {
27
27
  case "FARCASTER":
28
- verifyFarcaster();
28
+ setStep(ModalStep.FARCASTER_OAUTH);
29
29
  break;
30
30
  case "TELEGRAM":
31
31
  setStep(ModalStep.TELEGRAM_OAUTH);
@@ -2,30 +2,53 @@
2
2
  import "../../../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { safeStyled } from "@getpara/react-common";
5
- import { HeroSpinner } from "@getpara/react-common";
6
5
  import { CpslSpinner } from "@getpara/react-components";
7
6
  import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
7
+ import { useEffect, useState } from "react";
8
8
  import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
9
- import { AccountTypeIcon } from "../common.js";
10
9
  import { useModalStore } from "../../stores/index.js";
10
+ import { getPortalBaseURL } from "@getpara/web-sdk";
11
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
11
12
  function TelegramOAuthStep() {
12
13
  const { verifyTelegramStatus, verifyTelegram } = useAuthActions();
13
- const { url, status, isLoaded, setIsLoaded } = useTelegramLogin({
14
+ const { url, isLoaded, setIsLoaded } = useTelegramLogin({
14
15
  isActive: true,
15
16
  status: verifyTelegramStatus,
16
- onSubmit: verifyTelegram
17
+ onSubmit: verifyTelegram,
18
+ isLinking: false
17
19
  });
18
- const isError = status === "error", isPending = status === "pending";
20
+ const refs = useModalStore((state) => state.refs);
21
+ const para = useInternalClient();
22
+ const [height, setHeight] = useState(0);
23
+ useEffect(() => {
24
+ const handleMessage = (event) => {
25
+ if (!url) {
26
+ return;
27
+ }
28
+ const portalBase = getPortalBaseURL(para.ctx, true);
29
+ if (!event.origin.startsWith(portalBase)) {
30
+ return;
31
+ }
32
+ if (event.data) {
33
+ if (event.data.type === "HEIGHT") {
34
+ setHeight(event.data.height);
35
+ }
36
+ }
37
+ };
38
+ window.addEventListener("message", handleMessage);
39
+ return () => window.removeEventListener("message", handleMessage);
40
+ }, [url]);
19
41
  return /* @__PURE__ */ jsxs(Container, { children: [
20
- /* @__PURE__ */ jsx(HeroContainer, { children: /* @__PURE__ */ jsx(
21
- HeroSpinner,
42
+ url && /* @__PURE__ */ jsx(
43
+ IFrame,
22
44
  {
23
- icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: "TELEGRAM", size: "48px" }),
24
- status: isPending ? "pending" : isError ? "error" : "idle",
25
- text: isPending ? "Follow the on-screen prompts." : isError ? "Login Failed" : void 0
45
+ ref: refs.telegramIFrame,
46
+ style: { display: isLoaded ? "block" : "none", height },
47
+ src: url,
48
+ onLoad: () => setIsLoaded(true)
26
49
  }
27
- ) }),
28
- /* @__PURE__ */ jsx(TelegramIFrame, { url, isLoaded, setIsLoaded, isVisible: isLoaded })
50
+ ),
51
+ (!url || !isLoaded) && /* @__PURE__ */ jsx(CpslSpinner, {})
29
52
  ] });
30
53
  }
31
54
  function TelegramIFrame({
@@ -56,13 +79,6 @@ const Container = safeStyled.div`
56
79
  justify-content: center;
57
80
  width: 100%;
58
81
  `;
59
- const HeroContainer = safeStyled.div`
60
- display: flex;
61
- flex-direction: column;
62
- align-items: center;
63
- gap: 16px;
64
- flex: 1;
65
- `;
66
82
  const IFrame = safeStyled.iframe`
67
83
  width: 100%;
68
84
  height: 52px;
@@ -126,7 +126,7 @@ const BODY_MOTION_VARIANTS = {
126
126
  const BODY_TRANSITION = {
127
127
  duration: 0.2
128
128
  };
129
- const SDK_VERSION = "2.0.0-dev.5";
129
+ const SDK_VERSION = "2.0.0-alpha.50";
130
130
  export {
131
131
  BODY_MOTION_VARIANTS,
132
132
  BODY_TRANSITION,
@@ -0,0 +1,9 @@
1
+ import { MutationStatus } from '@tanstack/react-query';
2
+ export declare const useFarcasterLogin: ({ isActive, }?: {
3
+ isActive?: boolean;
4
+ }) => {
5
+ url: string | undefined;
6
+ isLoaded: boolean;
7
+ setIsLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
8
+ status: MutationStatus;
9
+ };
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../chunk-MMUBH76A.js";
5
+ import { useEffect, useState } from "react";
6
+ import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
7
+ import { useModalStore } from "../stores/index.js";
8
+ import { useAuthActions } from "../../provider/providers/AuthProvider.js";
9
+ const useFarcasterLogin = ({
10
+ isActive = false
11
+ } = {}) => {
12
+ const para = useInternalClient();
13
+ const refs = useModalStore((state) => state.refs);
14
+ const { verifyFarcasterStatus, verifyFarcaster } = useAuthActions();
15
+ const [url, setUrl] = useState();
16
+ const [isLoaded, setIsLoaded] = useState(false);
17
+ const [msgStatus, setMsgStatus] = useState("idle");
18
+ const status = msgStatus === "success" ? verifyFarcasterStatus : msgStatus;
19
+ useEffect(() => {
20
+ const setup = () => __async(void 0, null, function* () {
21
+ if (!url) {
22
+ yield para.logout();
23
+ yield para.touchSession(true);
24
+ para.constructPortalUrl("loginFarcaster").then(setUrl);
25
+ }
26
+ });
27
+ if (isActive) {
28
+ setup();
29
+ }
30
+ }, [isActive, url]);
31
+ useEffect(() => {
32
+ const updateState = (event) => __async(void 0, null, function* () {
33
+ var _a, _b;
34
+ switch (event.data.type) {
35
+ case "FARCASTER_LOGIN":
36
+ setMsgStatus("pending");
37
+ break;
38
+ case "FARCASTER_FAILED":
39
+ setMsgStatus("error");
40
+ break;
41
+ case "FARCASTER_SUCCESS":
42
+ setMsgStatus("success");
43
+ if (!!event.data.payload) {
44
+ const authObject = event.data.payload;
45
+ try {
46
+ yield verifyFarcaster(authObject);
47
+ } catch (e) {
48
+ (_b = (_a = refs.telegramIFrame.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage({ type: "FARCASTER_RETRY" }, "*");
49
+ }
50
+ }
51
+ break;
52
+ }
53
+ });
54
+ if (isActive) {
55
+ window == null ? void 0 : window.addEventListener("message", updateState, false);
56
+ }
57
+ return () => {
58
+ window == null ? void 0 : window.removeEventListener("message", updateState, false);
59
+ };
60
+ }, [isActive]);
61
+ return {
62
+ url,
63
+ isLoaded,
64
+ setIsLoaded,
65
+ status
66
+ };
67
+ };
68
+ export {
69
+ useFarcasterLogin
70
+ };
@@ -1,9 +1,10 @@
1
- import { TelegramAuthResponse } from '@getpara/user-management-client';
1
+ import { TelegramAuthResponse, VerifyThirdPartyAuth } from '@getpara/user-management-client';
2
2
  import { MutationStatus } from '@tanstack/react-query';
3
- export declare const useTelegramLogin: ({ isActive, onSubmit, status: propsStatus, }?: {
3
+ export declare const useTelegramLogin: ({ isActive, onSubmit, status: propsStatus, isLinking, }?: {
4
4
  isActive?: boolean;
5
- onSubmit?: (_: TelegramAuthResponse) => void;
5
+ onSubmit?: (_: VerifyThirdPartyAuth | TelegramAuthResponse) => void;
6
6
  status?: MutationStatus;
7
+ isLinking?: boolean;
7
8
  }) => {
8
9
  url: string | undefined;
9
10
  isLoaded: boolean;
@@ -8,7 +8,8 @@ import { useModalStore } from "../stores/index.js";
8
8
  const useTelegramLogin = ({
9
9
  isActive = false,
10
10
  onSubmit,
11
- status: propsStatus
11
+ status: propsStatus,
12
+ isLinking
12
13
  } = {}) => {
13
14
  const para = useInternalClient();
14
15
  const refs = useModalStore((state) => state.refs);
@@ -17,10 +18,17 @@ const useTelegramLogin = ({
17
18
  const [msgStatus, setMsgStatus] = useState("idle");
18
19
  const status = msgStatus === "success" ? propsStatus : msgStatus;
19
20
  useEffect(() => {
20
- if (isActive) {
21
+ const setup = () => __async(void 0, null, function* () {
21
22
  if (!url) {
22
- para.constructPortalUrl("telegramLogin").then(setUrl);
23
+ if (!isLinking) {
24
+ yield para.logout();
25
+ yield para.touchSession(true);
26
+ }
27
+ para.constructPortalUrl(!isLinking ? "telegramLoginVerify" : "telegramLogin").then(setUrl);
23
28
  }
29
+ });
30
+ if (isActive) {
31
+ setup();
24
32
  }
25
33
  }, [isActive, url]);
26
34
  useEffect(() => {
@@ -4,6 +4,7 @@ import {
4
4
  } from "../../../chunk-MMUBH76A.js";
5
5
  import { create } from "zustand";
6
6
  import { persist, createJSONStorage } from "zustand/middleware";
7
+ import { PARA_STORAGE_PREFIX } from "@getpara/core-sdk";
7
8
  import { ModalStep } from "../../utils/steps.js";
8
9
  import { getActions } from "./actions.js";
9
10
  import {
@@ -55,7 +56,7 @@ const useModalStore = create()(
55
56
  }, DEFAULT_MODAL_STATE), getActions(set, get)),
56
57
  {
57
58
  version: 1,
58
- name: "@PARA/modalState",
59
+ name: `${PARA_STORAGE_PREFIX}modalState`,
59
60
  storage: createJSONStorage(() => localStorage),
60
61
  partialize: (state) => ({
61
62
  step: state.step,
@@ -39,7 +39,8 @@ 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
- AWAITING_IFRAME = "AWAITING_IFRAME"
42
+ AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
43
+ OTP = "OTP"
43
44
  }
44
45
  export type ModalStepPropU = keyof typeof ModalStep | ModalStep;
45
46
  export type ModalStepPropL = Lowercase<ModalStepPropU>;
@@ -91,7 +92,8 @@ declare enum SignUpModalStep {
91
92
  ADD_FUNDS_AWAITING = "ADD_FUNDS_AWAITING",
92
93
  ADD_FUNDS_SUCCESS = "ADD_FUNDS_SUCCESS",
93
94
  ADD_FUNDS_FAILURE = "ADD_FUNDS_FAILURE",
94
- AWAITING_IFRAME = "AWAITING_IFRAME"
95
+ AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
96
+ OTP = "OTP"
95
97
  }
96
98
  export declare const SignUpPreviousStep: {
97
99
  [key in SignUpModalStep]: ModalStep | undefined;
@@ -125,7 +127,8 @@ declare enum LoginModalStep {
125
127
  ADD_FUNDS_AWAITING = "ADD_FUNDS_AWAITING",
126
128
  ADD_FUNDS_SUCCESS = "ADD_FUNDS_SUCCESS",
127
129
  ADD_FUNDS_FAILURE = "ADD_FUNDS_FAILURE",
128
- AWAITING_IFRAME = "AWAITING_IFRAME"
130
+ AWAITING_ACCOUNT = "AWAITING_ACCOUNT",
131
+ OTP = "OTP"
129
132
  }
130
133
  export declare const LoginPreviousStep: {
131
134
  [key in LoginModalStep]: ModalStep | undefined;