@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
@@ -14,14 +14,15 @@ export declare const VERIFY_NEW_ACCOUNT_KEY = "VERIFY_NEW_ACCOUNT";
14
14
  * await verifyNewAccountAsync({ ...params });
15
15
  */
16
16
  export declare const useVerifyNewAccount: () => {
17
- status: "error" | "idle" | "pending" | "success";
17
+ status: "idle" | "pending" | "error" | "success";
18
+ error: Error | null;
18
19
  data: {
20
+ userId: string;
21
+ externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
19
22
  username?: string | undefined;
20
23
  displayName?: string | undefined;
21
24
  pfpUrl?: string | undefined;
22
- externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
23
25
  auth: import("@getpara/shared").PrimaryAuth;
24
- userId: string;
25
26
  stage: "signup";
26
27
  isPasskeySupported: boolean;
27
28
  passkeyUrl?: string | undefined;
@@ -38,7 +39,6 @@ export declare const useVerifyNewAccount: () => {
38
39
  useShortUrls?: boolean | undefined;
39
40
  verificationCode: string;
40
41
  } | undefined;
41
- error: Error | null;
42
42
  isError: boolean;
43
43
  isIdle: boolean;
44
44
  isPending: boolean;
@@ -49,12 +49,12 @@ export declare const useVerifyNewAccount: () => {
49
49
  isPaused: boolean;
50
50
  submittedAt: number;
51
51
  verifyNewAccount: import("@tanstack/react-query").UseMutateFunction<{
52
+ userId: string;
53
+ externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
52
54
  username?: string | undefined;
53
55
  displayName?: string | undefined;
54
56
  pfpUrl?: string | undefined;
55
- externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
56
57
  auth: import("@getpara/shared").PrimaryAuth;
57
- userId: string;
58
58
  stage: "signup";
59
59
  isPasskeySupported: boolean;
60
60
  passkeyUrl?: string | undefined;
@@ -70,12 +70,12 @@ export declare const useVerifyNewAccount: () => {
70
70
  verificationCode: string;
71
71
  }, unknown>;
72
72
  verifyNewAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
73
+ userId: string;
74
+ externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
73
75
  username?: string | undefined;
74
76
  displayName?: string | undefined;
75
77
  pfpUrl?: string | undefined;
76
- externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
77
78
  auth: import("@getpara/shared").PrimaryAuth;
78
- userId: string;
79
79
  stage: "signup";
80
80
  isPasskeySupported: boolean;
81
81
  passkeyUrl?: string | undefined;
@@ -15,7 +15,8 @@ export declare const VERIFY_OAUTH_KEY = "VERIFY_OAUTH";
15
15
  * await verifyOAuthAsync({ ...params });
16
16
  */
17
17
  export declare const useVerifyOAuth: () => {
18
- status: "error" | "idle" | "pending" | "success";
18
+ status: "idle" | "pending" | "error" | "success";
19
+ error: Error | null;
19
20
  data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
21
  isSuccess: boolean;
21
22
  variables: {
@@ -29,7 +30,6 @@ export declare const useVerifyOAuth: () => {
29
30
  onOAuthUrl?: ((url: string) => void) | undefined;
30
31
  onOAuthPopup?: ((popup: Window) => void) | undefined;
31
32
  } | undefined;
32
- error: Error | null;
33
33
  isError: boolean;
34
34
  isIdle: boolean;
35
35
  isPending: boolean;
@@ -15,7 +15,8 @@ export declare const VERIFY_TELEGRAM_KEY = "VERIFY_TELEGRAM";
15
15
  * await verifyTelegramAsync({ ...params });
16
16
  */
17
17
  export declare const useVerifyTelegram: () => {
18
- status: "error" | "idle" | "pending" | "success";
18
+ status: "idle" | "pending" | "error" | "success";
19
+ error: Error | null;
19
20
  data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
21
  isSuccess: boolean;
21
22
  variables: {
@@ -24,7 +25,6 @@ export declare const useVerifyTelegram: () => {
24
25
  telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
25
26
  serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
26
27
  } | undefined;
27
- error: Error | null;
28
28
  isError: boolean;
29
29
  isIdle: boolean;
30
30
  isPending: boolean;
@@ -14,7 +14,8 @@ export declare const WAIT_FOR_LOG_IN_KEY = "WAIT_FOR_LOG_IN";
14
14
  * await waitForLoginAsync({ ...params });
15
15
  */
16
16
  export declare const useWaitForLogin: () => {
17
- status: "error" | "idle" | "pending" | "success";
17
+ status: "idle" | "pending" | "error" | "success";
18
+ error: Error | null;
18
19
  data: {
19
20
  needsWallet?: boolean | undefined;
20
21
  partnerId?: string | undefined;
@@ -26,7 +27,6 @@ export declare const useWaitForLogin: () => {
26
27
  skipSessionRefresh?: boolean | undefined;
27
28
  isCanceled?: (() => boolean) | undefined;
28
29
  } | undefined;
29
- error: Error | null;
30
30
  isError: boolean;
31
31
  isIdle: boolean;
32
32
  isPending: boolean;
@@ -14,7 +14,8 @@ export declare const WAIT_FOR_SIGN_UP_KEY = "WAIT_FOR_SIGN_UP";
14
14
  * await waitForSignupAsync({ ...params });
15
15
  */
16
16
  export declare const useWaitForSignup: () => {
17
- status: "error" | "idle" | "pending" | "success";
17
+ status: "idle" | "pending" | "error" | "success";
18
+ error: Error | null;
18
19
  data: true | undefined;
19
20
  isSuccess: boolean;
20
21
  variables: void | {
@@ -22,7 +23,6 @@ export declare const useWaitForSignup: () => {
22
23
  onCancel?: (() => void) | undefined;
23
24
  isCanceled?: (() => boolean) | undefined;
24
25
  } | undefined;
25
- error: Error | null;
26
26
  isError: boolean;
27
27
  isIdle: boolean;
28
28
  isPending: boolean;
@@ -14,7 +14,8 @@ export declare const WAIT_FOR_WALLET_CREATION_KEY = "WAIT_FOR_WALLET_CREATION";
14
14
  * await waitForWalletCreationAsync({ ...params });
15
15
  */
16
16
  export declare const useWaitForWalletCreation: () => {
17
- status: "error" | "idle" | "pending" | "success";
17
+ status: "idle" | "pending" | "error" | "success";
18
+ error: Error | null;
18
19
  data: {
19
20
  walletIds: import("@getpara/web-sdk").CurrentWalletIds;
20
21
  recoverySecret?: string | undefined;
@@ -25,7 +26,6 @@ export declare const useWaitForWalletCreation: () => {
25
26
  onCancel?: (() => void) | undefined;
26
27
  isCanceled?: (() => boolean) | undefined;
27
28
  } | undefined;
28
- error: Error | null;
29
29
  isError: boolean;
30
30
  isIdle: boolean;
31
31
  isPending: boolean;
@@ -123,6 +123,7 @@ const useEventListeners = ({
123
123
  });
124
124
  }, [queryClient, refs.balancesInvalidationTime]);
125
125
  useEffect(() => {
126
+ if (typeof window === "undefined") return;
126
127
  window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
127
128
  window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
128
129
  window.addEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
@@ -136,6 +137,7 @@ const useEventListeners = ({
136
137
  window.addEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
137
138
  window.addEventListener(ParaEvent.ASSET_TRANSFERRED, assetTransferListener);
138
139
  return () => {
140
+ if (typeof window === "undefined") return;
139
141
  window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
140
142
  window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
141
143
  window.removeEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
@@ -5,7 +5,7 @@ import { TWalletType } from '@getpara/web-sdk';
5
5
  export declare const useWalletState: () => {
6
6
  selectedWallet: {
7
7
  id: string | undefined;
8
- type: "EVM" | "SOLANA" | "COSMOS" | undefined;
8
+ type: "SOLANA" | "COSMOS" | "EVM" | undefined;
9
9
  };
10
10
  setSelectedWallet: ({ id, type }: {
11
11
  id?: string;
@@ -188,7 +188,7 @@ const AccountLinkProvider = ({ children }) => {
188
188
  setLinkAccountError(e.message);
189
189
  } finally {
190
190
  if (linkWallet.type === "EVM" || linkWallet.type === "SOLANA") {
191
- yield disconnectBase(providerId, linkWallet.type);
191
+ yield disconnectBase(providerId, linkWallet.type, { disconnectType: "ACCOUNT_LINKING" });
192
192
  }
193
193
  }
194
194
  }
@@ -318,7 +318,8 @@ const AccountLinkProvider = ({ children }) => {
318
318
  try {
319
319
  yield disconnectBase(
320
320
  accountLinkInProgress.externalWallet.providerId,
321
- accountLinkInProgress.externalWallet.type
321
+ accountLinkInProgress.externalWallet.type,
322
+ { disconnectType: "ACCOUNT_LINKING" }
322
323
  );
323
324
  } catch (error) {
324
325
  }
@@ -5,8 +5,8 @@ import {
5
5
  __spreadValues
6
6
  } from "../../chunk-MMUBH76A.js";
7
7
  import { jsx } from "react/jsx-runtime";
8
- import { useUserAgent } from "@getpara/react-common";
9
- import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
8
+ import { openMobileUrl, useUserAgent } from "@getpara/react-common";
9
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
10
10
  import { useModalStore } from "../../modal/stores/index.js";
11
11
  import { ModalStep } from "../../modal/utils/steps.js";
12
12
  import {
@@ -29,15 +29,15 @@ import { openPopup } from "../../modal/utils/openPopup.js";
29
29
  import {
30
30
  AuthMethod,
31
31
  entityToWallet,
32
- getPortalBaseURL
32
+ isMobile
33
33
  } from "@getpara/web-sdk";
34
34
  import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
35
35
  import { useGoBack } from "../../modal/hooks/useGoBack.js";
36
36
  import { isExternalWallet } from "@getpara/user-management-client";
37
- import { routeMobileExternalWallet } from "../../modal/utils/routeMobileExternalWallet.js";
38
37
  import { useStore } from "../stores/useStore.js";
39
38
  import { useFormattedBiometricHints } from "../hooks/utils/useFormattedBiometricHints.js";
40
39
  import { useQueryClient } from "@tanstack/react-query";
40
+ import { validatePortalOrigin } from "../../modal/utils/validatePortalOrigin.js";
41
41
  const AuthContext = createContext({
42
42
  signUpOrLogIn: () => {
43
43
  },
@@ -127,6 +127,7 @@ function AuthProvider({
127
127
  const { data: biometricHints } = useFormattedBiometricHints();
128
128
  const [switchWalletsUrl, setSwitchWalletsUrl] = useState(void 0);
129
129
  const [isSwitchWalletsPending, setIsSwitchWalletsPending] = useState(mutateIsSwitchWalletsPending);
130
+ const messageHandlerRef = useRef(null);
130
131
  const goBackIfPopupClosedOnSteps = (steps) => {
131
132
  var _a;
132
133
  if (((_a = refs.popupWindow.current) == null ? void 0 : _a.closed) && (!refs.currentStep.current || steps.includes(refs.currentStep.current))) {
@@ -139,11 +140,12 @@ function AuthProvider({
139
140
  return !!stepNow && !steps.includes(stepNow);
140
141
  };
141
142
  const setupListener = () => {
142
- window.addEventListener("message", function handleMessage(event) {
143
+ if (messageHandlerRef.current) {
144
+ window.removeEventListener("message", messageHandlerRef.current);
145
+ }
146
+ const handleMessage = (event) => {
143
147
  var _a;
144
- const portalBase = getPortalBaseURL(para.ctx);
145
- const portalLocalBase = getPortalBaseURL(para.ctx, true);
146
- if (!event.origin.startsWith(portalBase) && !event.origin.startsWith(portalLocalBase)) {
148
+ if (!validatePortalOrigin(event, para.ctx)) {
147
149
  return;
148
150
  }
149
151
  if (((_a = event.data) == null ? void 0 : _a.type) === "CLOSE_WINDOW") {
@@ -154,8 +156,11 @@ function AuthProvider({
154
156
  setStep(ModalStep.AWAITING_ACCOUNT);
155
157
  }
156
158
  window.removeEventListener("message", handleMessage);
159
+ messageHandlerRef.current = null;
157
160
  }
158
- });
161
+ };
162
+ messageHandlerRef.current = handleMessage;
163
+ window.addEventListener("message", handleMessage);
159
164
  };
160
165
  const pollSignup = () => {
161
166
  if (typeof window !== "undefined") {
@@ -215,12 +220,14 @@ function AuthProvider({
215
220
  if (refs.currentStep.current !== ModalStep.AWAITING_BIOMETRIC_CREATION) {
216
221
  setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
217
222
  }
218
- refs.popupWindow.current = openPopup({
219
- url: authState.passkeyUrl,
220
- target: "ParaPasskey",
221
- type: "CREATE_PASSKEY",
222
- current: refs.popupWindow.current
223
- });
223
+ if (typeof window !== "undefined") {
224
+ refs.popupWindow.current = openPopup({
225
+ url: authState.passkeyUrl,
226
+ target: "ParaPasskey",
227
+ type: "CREATE_PASSKEY",
228
+ current: refs.popupWindow.current
229
+ });
230
+ }
224
231
  break;
225
232
  case AuthMethod.PASSWORD:
226
233
  setupListener();
@@ -264,13 +271,14 @@ function AuthProvider({
264
271
  [isIFrameReady]
265
272
  );
266
273
  const login = (authState) => {
267
- if (authState.isWalletSelectionNeeded || authState.passkeyUrl) {
268
- setStep(ModalStep.BIOMETRIC_LOGIN);
269
- } else {
274
+ const hasPasskey = !!authState.passkeyUrl;
275
+ if (!hasPasskey) {
270
276
  setupListener();
271
277
  setIFrameUrl(authState.passwordUrl || authState.pinUrl);
272
278
  setIsIFrameReady(false);
273
279
  setStep(ModalStep.EMBEDDED_PASSWORD_LOGIN);
280
+ } else {
281
+ setStep(ModalStep.BIOMETRIC_LOGIN);
274
282
  }
275
283
  pollLogin();
276
284
  };
@@ -341,23 +349,49 @@ function AuthProvider({
341
349
  loginOverride();
342
350
  return;
343
351
  }
344
- refs.popupWindow.current = openPopup({
345
- url: isPIN ? authState.pinUrl : isPassword ? authState.passwordUrl : authState.passkeyUrl,
346
- target: isPIN ? "ParaPIN" : isPassword ? "ParaPassword" : "ParaPasskey",
347
- type: isPIN ? "LOGIN_PASSWORD" : isPassword ? "LOGIN_PASSWORD" : "LOGIN_PASSKEY",
348
- current: refs.popupWindow.current
349
- });
352
+ if (typeof window !== "undefined") {
353
+ refs.popupWindow.current = openPopup({
354
+ url: isPIN ? authState.pinUrl : isPassword ? authState.passwordUrl : authState.passkeyUrl,
355
+ target: isPIN ? "ParaPIN" : isPassword ? "ParaPassword" : "ParaPasskey",
356
+ type: isPIN ? "LOGIN_PASSWORD" : isPassword ? "LOGIN_PASSWORD" : "LOGIN_PASSKEY",
357
+ current: refs.popupWindow.current
358
+ });
359
+ }
350
360
  setStep(isPassword || isPIN ? ModalStep.AWAITING_PASSWORD_LOGIN : ModalStep.AWAITING_BIOMETRIC_LOGIN);
351
361
  },
352
362
  [loginState, biometricHints]
353
363
  );
354
364
  const onNewAuthState = (authState) => __async(this, null, function* () {
355
- refs.popupWindow.current = null;
365
+ var _a, _b, _c;
356
366
  setAuthState(authState);
357
367
  switch (authState.stage) {
358
368
  case "verify":
359
- if (isExternalWallet(authState.auth) && authState.signatureVerificationMessage) {
360
- setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
369
+ if (isExternalWallet(authState.auth)) {
370
+ if (authState.loginUrl && ((_a = authState.externalWallet) == null ? void 0 : _a.withFullParaAuth)) {
371
+ let isBasicLogin = false;
372
+ if (authState.nextStage === "login") {
373
+ isBasicLogin = authState.loginAuthMethods.includes(AuthMethod.BASIC_LOGIN);
374
+ } else {
375
+ isBasicLogin = authState.signupAuthMethods.includes(AuthMethod.BASIC_LOGIN);
376
+ }
377
+ if (authState.nextStage === "login") {
378
+ setFlow("login");
379
+ isBasicLogin && pollLogin();
380
+ } else {
381
+ setFlow("signup");
382
+ isBasicLogin && pollSignup();
383
+ }
384
+ if (!isMobile() && refs.popupWindow.current) {
385
+ refs.popupWindow.current.location.href = authState.loginUrl;
386
+ setStep(ModalStep.AWAITING_ACCOUNT);
387
+ } else {
388
+ setIFrameUrl(authState.loginUrl);
389
+ setStep(ModalStep.OTP);
390
+ setupListener();
391
+ }
392
+ } else {
393
+ setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
394
+ }
361
395
  } else {
362
396
  if (authState.nextStage === "login") {
363
397
  setFlow("login");
@@ -398,12 +432,14 @@ function AuthProvider({
398
432
  }
399
433
  break;
400
434
  case "done":
401
- if (authState.isNewUser) {
402
- pollSignup();
403
- setFlow("signup");
404
- } else {
405
- pollLogin();
406
- setFlow("login");
435
+ if (!((_b = authState.externalWallet) == null ? void 0 : _b.withFullParaAuth) && !((_c = authState.externalWallet) == null ? void 0 : _c.withVerification)) {
436
+ if (authState.isNewUser) {
437
+ pollSignup();
438
+ setFlow("signup");
439
+ } else {
440
+ pollLogin();
441
+ setFlow("login");
442
+ }
407
443
  }
408
444
  if (!authState.isWalletSelectionNeeded) {
409
445
  setStep(ModalStep.AWAITING_ACCOUNT);
@@ -463,7 +499,7 @@ function AuthProvider({
463
499
  isCanceled: () => refs.currentStep.current !== ModalStep.FARCASTER_OAUTH,
464
500
  onConnectUri: (connectUri) => {
465
501
  setFarcasterConnectUri(connectUri);
466
- routeMobileExternalWallet(connectUri);
502
+ openMobileUrl(connectUri);
467
503
  },
468
504
  useShortUrls: true,
469
505
  serverAuthState
@@ -722,6 +758,9 @@ function AuthProvider({
722
758
  return () => {
723
759
  var _a;
724
760
  window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
761
+ if (messageHandlerRef.current) {
762
+ window.removeEventListener("message", messageHandlerRef.current);
763
+ }
725
764
  };
726
765
  }, []);
727
766
  return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
@@ -1,6 +1,6 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { TWalletType } from '@getpara/web-sdk';
3
- import { BalanceManagement, ChainManagement, CommonWallet, ExternalWalletContextType } from '@getpara/react-common';
3
+ import { BalanceManagement, ChainManagement, CommonWallet, DisconnectBaseOptions, ExternalWalletContextType, MutationStatus } from '@getpara/react-common';
4
4
  import { ExternalWalletInfo, VerifyExternalWalletParams } from '@getpara/web-sdk';
5
5
  import { CosmosSignResult } from '@getpara/cosmos-wallet-connectors';
6
6
  export declare const useWalletDisplayHelpers: (wallet: CommonWallet | undefined) => {
@@ -33,11 +33,14 @@ export declare const defaultExternalWallet: {
33
33
  isSigningMessage: boolean;
34
34
  getWalletBalance: () => Promise<undefined>;
35
35
  requestInfo: (_: string) => Promise<ExternalWalletInfo>;
36
- disconnectBase: (_: string, __: TWalletType) => Promise<void>;
36
+ disconnectBase: (_: string, __: TWalletType, ___?: DisconnectBaseOptions) => Promise<void>;
37
37
  connectFarcasterMiniApp: () => Promise<void>;
38
38
  verificationStage: undefined;
39
+ evmDisconnectStatus: string;
40
+ solanaDisconnectStatus: string;
41
+ cosmosDisconnectStatus: string;
39
42
  };
40
- type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 'signVerificationMessage' | 'requestInfo' | 'disconnectBase'> & ChainManagement<string, void> & BalanceManagement & {
43
+ type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 'disconnectStatus' | 'signVerificationMessage' | 'requestInfo' | 'disconnectBase'> & ChainManagement<string, void> & BalanceManagement & {
41
44
  wallet?: CommonWallet;
42
45
  qrUri?: string;
43
46
  chainIdSwitchingTo?: string;
@@ -48,7 +51,13 @@ type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 's
48
51
  };
49
52
  username?: string;
50
53
  avatar?: string;
51
- connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
54
+ connectExternalWallet: (_: {
55
+ wallet: CommonWallet;
56
+ isMobile?: boolean;
57
+ isManualWalletConnect?: boolean;
58
+ isResetAfterManualWalletConnect?: boolean;
59
+ isRetryConnection?: boolean;
60
+ }) => Promise<void>;
52
61
  addAdditionalExternalWallet: (wallet: CommonWallet) => Promise<void>;
53
62
  disconnectExternalWallet: () => Promise<void>;
54
63
  setChainIdSwitchingTo: (chainId?: string) => void;
@@ -56,9 +65,12 @@ type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 's
56
65
  isSigningMessage: boolean;
57
66
  verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
58
67
  requestInfo: (_: string, __: TWalletType) => Promise<ExternalWalletInfo>;
59
- disconnectBase: (_: string, __: TWalletType) => Promise<void>;
68
+ disconnectBase: (_: string, __: TWalletType, ___?: DisconnectBaseOptions) => Promise<void>;
60
69
  connectFarcasterMiniApp: () => Promise<void>;
61
70
  verificationStage?: 'verifying' | 'switchingChain';
71
+ evmDisconnectStatus: MutationStatus;
72
+ solanaDisconnectStatus: MutationStatus;
73
+ cosmosDisconnectStatus: MutationStatus;
62
74
  };
63
75
  export declare const ExternalWalletContext: import("react").Context<Value>;
64
76
  export declare function ExternalWalletProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;