@getpara/react-sdk-lite 2.0.0-dev.6 → 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.
@@ -168,7 +168,6 @@ const ParaModal = forwardRef((props, ref) => {
168
168
  yield disconnectExternalWallet();
169
169
  setSelectedWallet({ id: void 0, type: void 0 });
170
170
  }
171
- yield para.logout();
172
171
  if (shouldAutoLogin) {
173
172
  if (defaultAuthIdentifier && ((_a2 = para.authInfo) == null ? void 0 : _a2.identifier) !== defaultAuthIdentifier) {
174
173
  const number = parsePhoneNumberFromString(defaultAuthIdentifier);
@@ -5,7 +5,15 @@ import { useModalStore } from "../../stores/index.js";
5
5
  import { Waiting } from "../Waiting/Waiting.js";
6
6
  const AwaitingAccountStep = () => {
7
7
  const isLogin = useModalStore((state) => state.isLogin());
8
- return /* @__PURE__ */ jsx(Waiting, { heading: isLogin ? "Logging you in..." : "Creating your account..." });
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
+ );
9
17
  };
10
18
  export {
11
19
  AwaitingAccountStep
@@ -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",
@@ -2,31 +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
17
  onSubmit: verifyTelegram,
17
18
  isLinking: false
18
19
  });
19
- 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]);
20
41
  return /* @__PURE__ */ jsxs(Container, { children: [
21
- /* @__PURE__ */ jsx(HeroContainer, { children: /* @__PURE__ */ jsx(
22
- HeroSpinner,
42
+ url && /* @__PURE__ */ jsx(
43
+ IFrame,
23
44
  {
24
- icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: "TELEGRAM", size: "48px" }),
25
- status: isPending ? "pending" : isError ? "error" : "idle",
26
- 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)
27
49
  }
28
- ) }),
29
- /* @__PURE__ */ jsx(TelegramIFrame, { url, isLoaded, setIsLoaded, isVisible: isLoaded })
50
+ ),
51
+ (!url || !isLoaded) && /* @__PURE__ */ jsx(CpslSpinner, {})
30
52
  ] });
31
53
  }
32
54
  function TelegramIFrame({
@@ -57,13 +79,6 @@ const Container = safeStyled.div`
57
79
  justify-content: center;
58
80
  width: 100%;
59
81
  `;
60
- const HeroContainer = safeStyled.div`
61
- display: flex;
62
- flex-direction: column;
63
- align-items: center;
64
- gap: 16px;
65
- flex: 1;
66
- `;
67
82
  const IFrame = safeStyled.iframe`
68
83
  width: 100%;
69
84
  height: 52px;
@@ -1,6 +1,6 @@
1
1
  import { BiometricHints } from '@getpara/react-common';
2
2
  import { PropsWithChildren } from 'react';
3
- import { AuthMethod, CoreMethodParams, AuthState, AuthStateSignup, AuthStateLogin } from '@getpara/web-sdk';
3
+ import { AuthMethod, CoreMethodParams, AuthState, AuthStateSignup, AuthStateLogin, AuthStateVerify } from '@getpara/web-sdk';
4
4
  import { ParaModalProps } from '../../modal/types/modalProps.js';
5
5
  import { VerifiedAuth, VerifyThirdPartyAuth } from '@getpara/user-management-client';
6
6
  import { MutationStatus } from '@tanstack/react-query';
@@ -18,6 +18,7 @@ type Value = {
18
18
  onNewAuthState: (_: AuthState) => void;
19
19
  presentSignupUi: (_: AuthMethod, __: AuthStateSignup) => void;
20
20
  presentLoginUi: (_: AuthMethod, __: AuthStateLogin) => void;
21
+ presentVerifyUi: (_: AuthMethod, __: AuthStateVerify) => void;
21
22
  isSetup2faPending: boolean;
22
23
  createGuestWallets: () => void;
23
24
  isCreateGuestWalletsPending: boolean;
@@ -59,6 +59,8 @@ const AuthContext = createContext({
59
59
  },
60
60
  presentLoginUi: () => {
61
61
  },
62
+ presentVerifyUi: () => {
63
+ },
62
64
  createGuestWallets: () => {
63
65
  },
64
66
  isCreateGuestWalletsPending: false,
@@ -128,7 +130,8 @@ function AuthProvider({
128
130
  window.addEventListener("message", function handleMessage(event) {
129
131
  var _a;
130
132
  const portalBase = getPortalBaseURL(para.ctx);
131
- if (!event.origin.startsWith(portalBase)) {
133
+ const portalLocalBase = getPortalBaseURL(para.ctx, true);
134
+ if (!event.origin.startsWith(portalBase) && !event.origin.startsWith(portalLocalBase)) {
132
135
  return;
133
136
  }
134
137
  if (((_a = event.data) == null ? void 0 : _a.type) === "CLOSE_WINDOW") {
@@ -272,7 +275,9 @@ function AuthProvider({
272
275
  ModalStep.AWAITING_BIOMETRIC_LOGIN,
273
276
  ModalStep.AWAITING_PASSWORD_LOGIN,
274
277
  ModalStep.AWAITING_ACCOUNT,
275
- ModalStep.OTP
278
+ ModalStep.OTP,
279
+ ModalStep.FARCASTER_OAUTH,
280
+ ModalStep.TELEGRAM_OAUTH
276
281
  ]),
277
282
  onPoll: () => {
278
283
  goBackIfPopupClosedOnSteps([
@@ -385,7 +390,9 @@ function AuthProvider({
385
390
  pollLogin();
386
391
  setFlow("login");
387
392
  }
388
- setStep(ModalStep.AWAITING_ACCOUNT);
393
+ if (!authState.isWalletSelectionNeeded) {
394
+ setStep(ModalStep.AWAITING_ACCOUNT);
395
+ }
389
396
  break;
390
397
  }
391
398
  });
@@ -431,7 +438,11 @@ function AuthProvider({
431
438
  );
432
439
  });
433
440
  const verifyFarcaster = (serverAuthState) => __async(this, null, function* () {
434
- setStep(ModalStep.FARCASTER_OAUTH);
441
+ if (!serverAuthState) {
442
+ setStep(ModalStep.FARCASTER_OAUTH);
443
+ } else {
444
+ setupListener();
445
+ }
435
446
  mutateVerifyFarcaster(
436
447
  {
437
448
  isCanceled: () => refs.currentStep.current !== ModalStep.FARCASTER_OAUTH,
@@ -453,6 +464,9 @@ function AuthProvider({
453
464
  );
454
465
  });
455
466
  const verifyTelegram = (serverAuthState) => __async(this, null, function* () {
467
+ if (serverAuthState) {
468
+ setupListener();
469
+ }
456
470
  mutateVerifyTelegram(
457
471
  {
458
472
  serverAuthState,
@@ -547,6 +561,7 @@ function AuthProvider({
547
561
  () => ({
548
562
  presentSignupUi,
549
563
  presentLoginUi,
564
+ presentVerifyUi,
550
565
  signUpOrLogIn,
551
566
  isSignUpOrLogInPending,
552
567
  verifyNewAccount,
@@ -567,6 +582,7 @@ function AuthProvider({
567
582
  [
568
583
  presentSignupUi,
569
584
  presentLoginUi,
585
+ presentVerifyUi,
570
586
  signUpOrLogIn,
571
587
  isSignUpOrLogInPending,
572
588
  verifyNewAccount,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk-lite",
3
- "version": "2.0.0-dev.6",
3
+ "version": "2.0.0-dev.7",
4
4
  "bin": {
5
5
  "setup-para": "dist/cli/cli.mjs"
6
6
  },
7
7
  "dependencies": {
8
- "@getpara/react-common": "2.0.0-dev.6",
9
- "@getpara/react-components": "2.0.0-dev.6",
10
- "@getpara/web-sdk": "2.0.0-dev.6",
8
+ "@getpara/react-common": "2.0.0-dev.7",
9
+ "@getpara/react-components": "2.0.0-dev.7",
10
+ "@getpara/web-sdk": "2.0.0-dev.7",
11
11
  "date-fns": "^3.6.0",
12
12
  "framer-motion": "^11.3.31",
13
13
  "libphonenumber-js": "^1.11.7",
@@ -16,9 +16,9 @@
16
16
  "zustand-sync-tabs": "^0.2.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@getpara/cosmos-wallet-connectors": "2.0.0-dev.6",
20
- "@getpara/evm-wallet-connectors": "2.0.0-dev.6",
21
- "@getpara/solana-wallet-connectors": "2.0.0-dev.6",
19
+ "@getpara/cosmos-wallet-connectors": "2.0.0-dev.7",
20
+ "@getpara/evm-wallet-connectors": "2.0.0-dev.7",
21
+ "@getpara/solana-wallet-connectors": "2.0.0-dev.7",
22
22
  "@tanstack/react-query": "^5.74.0",
23
23
  "@testing-library/dom": "^10.4.0",
24
24
  "@testing-library/react": "^16.3.0",
@@ -38,7 +38,7 @@
38
38
  "package.json",
39
39
  "styles.css"
40
40
  ],
41
- "gitHead": "c2125e37c73a19f11978031f5aa2eab39b978c56",
41
+ "gitHead": "225cd3693edaab4dac81df7285956d2616e5717f",
42
42
  "main": "dist/index.js",
43
43
  "peerDependencies": {
44
44
  "@tanstack/react-query": ">=5.0.0",