@getpara/react-sdk 1.12.0 → 2.0.0-alpha.5

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 (241) hide show
  1. package/dist/cli/cli.mjs +35 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +5 -0
  4. package/dist/modal/ParaModal.js +211 -313
  5. package/dist/modal/components/Account/Account.js +66 -12
  6. package/dist/modal/components/AddFunds/AddFunds.js +5 -6
  7. package/dist/modal/components/AddFunds/AddFundsAsset.js +15 -13
  8. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +16 -10
  9. package/dist/modal/components/AddFunds/AddFundsContext.d.ts +2 -2
  10. package/dist/modal/components/AddFunds/AddFundsContext.js +20 -14
  11. package/dist/modal/components/AddFunds/AddFundsDone.js +10 -4
  12. package/dist/modal/components/AddFunds/AddFundsProvider.js +11 -7
  13. package/dist/modal/components/AddFunds/AddFundsReceive.js +17 -13
  14. package/dist/modal/components/AddFunds/AddFundsSettings.js +10 -6
  15. package/dist/modal/components/AddFunds/common.d.ts +1 -1
  16. package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
  17. package/dist/modal/components/AuthInput/AuthInput.js +70 -91
  18. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
  19. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +4 -4
  20. package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
  21. package/dist/modal/components/AuthMainStep/AuthMainStep.js +20 -7
  22. package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
  23. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +54 -10
  24. package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
  25. package/dist/modal/components/AuthOptions/AuthOptions.js +42 -8
  26. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
  27. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +9 -4
  28. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -3
  29. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +25 -17
  30. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
  31. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +34 -72
  32. package/dist/modal/components/Body/Body.d.ts +4 -3
  33. package/dist/modal/components/Body/Body.js +27 -10
  34. package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
  35. package/dist/modal/components/ChainSwitch/ChainSwitch.js +5 -4
  36. package/dist/modal/components/Controls/Controls.js +5 -2
  37. package/dist/modal/components/Controls/Selects.d.ts +1 -1
  38. package/dist/modal/components/Controls/Selects.js +30 -25
  39. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
  40. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +10 -6
  41. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +7 -69
  42. package/dist/modal/components/ExternalWallets/ExternalWallets.js +7 -6
  43. package/dist/modal/components/Footer/Footer.d.ts +1 -1
  44. package/dist/modal/components/Footer/Footer.js +6 -4
  45. package/dist/modal/components/Header/hooks/useStepTitle.js +7 -3
  46. package/dist/modal/components/Hero/Hero.js +5 -5
  47. package/dist/modal/components/IFrameStep/IFrameStep.js +8 -4
  48. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +7 -4
  49. package/dist/modal/components/ModalContent/ModalContent.js +14 -243
  50. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -57
  51. package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
  52. package/dist/modal/components/OAuth/OAuth.js +11 -85
  53. package/dist/modal/components/OAuth/TelegramOAuthStep.js +11 -60
  54. package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
  55. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +10 -4
  56. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +23 -32
  57. package/dist/modal/components/StripeComponents/StripeComponents.js +1 -1
  58. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +5 -2
  59. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +44 -60
  60. package/dist/modal/components/WalletCard/WalletCard.d.ts +5 -5
  61. package/dist/modal/components/WalletCard/WalletCard.js +8 -7
  62. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +33 -12
  63. package/dist/modal/components/common.d.ts +5 -5
  64. package/dist/modal/components/common.js +10 -4
  65. package/dist/modal/constants/constants.d.ts +1 -1
  66. package/dist/modal/constants/oAuthLogos.d.ts +3 -3
  67. package/dist/modal/hooks/useGoBack.js +6 -5
  68. package/dist/modal/index.d.ts +0 -3
  69. package/dist/modal/index.js +1 -5
  70. package/dist/modal/stores/index.d.ts +0 -2
  71. package/dist/modal/stores/index.js +0 -2
  72. package/dist/modal/stores/modal/actions.js +69 -16
  73. package/dist/modal/stores/modal/useModalStore.d.ts +26 -22
  74. package/dist/modal/stores/modal/useModalStore.js +9 -13
  75. package/dist/modal/types/commonTypes.d.ts +0 -52
  76. package/dist/modal/types/modalProps.d.ts +8 -32
  77. package/dist/modal/utils/authInputHelpers.d.ts +7 -0
  78. package/dist/modal/utils/authInputHelpers.js +38 -0
  79. package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
  80. package/dist/modal/{components/AuthInput → utils}/countryCodes.js +6 -3
  81. package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
  82. package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
  83. package/dist/modal/utils/isPasskeySupported.js +15 -0
  84. package/dist/modal/utils/openPopup.d.ts +2 -2
  85. package/dist/modal/utils/openPopup.js +2 -2
  86. package/dist/modal/utils/steps.d.ts +6 -0
  87. package/dist/modal/utils/steps.js +15 -0
  88. package/dist/provider/ParaProvider.d.ts +3 -1
  89. package/dist/provider/ParaProvider.js +69 -8
  90. package/dist/provider/actions/getAccount.d.ts +26 -8
  91. package/dist/provider/actions/getAccount.js +42 -14
  92. package/dist/provider/actions/getWallet.d.ts +3 -3
  93. package/dist/provider/actions/index.d.ts +27 -0
  94. package/dist/provider/actions/index.js +59 -0
  95. package/dist/provider/actions/utils.d.ts +3 -0
  96. package/dist/provider/actions/utils.js +15 -0
  97. package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
  98. package/dist/provider/components/CosmosWalletWrapper.js +34 -0
  99. package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
  100. package/dist/provider/components/EvmWalletWrapper.js +34 -0
  101. package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
  102. package/dist/provider/components/ExternalWalletWrapper.js +139 -0
  103. package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
  104. package/dist/provider/components/SolanaWalletWrapper.js +36 -0
  105. package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
  106. package/dist/provider/external/getParaCosmosConnector.js +22 -0
  107. package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
  108. package/dist/provider/external/getParaEvmConnector.js +22 -0
  109. package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
  110. package/dist/provider/external/getParaSolanaConnector.js +22 -0
  111. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
  112. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
  113. package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
  114. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
  115. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
  116. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
  117. package/dist/provider/hooks/mutations/index.d.ts +26 -11
  118. package/dist/provider/hooks/mutations/index.js +52 -17
  119. package/dist/provider/hooks/mutations/utils.d.ts +4 -0
  120. package/dist/provider/hooks/mutations/utils.js +22 -0
  121. package/dist/provider/hooks/queries/useAccount.d.ts +1 -7
  122. package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
  123. package/dist/provider/hooks/queries/useWalletBalance.d.ts +1 -2
  124. package/dist/provider/hooks/queries/useWalletBalance.js +40 -11
  125. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +5 -5
  126. package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
  127. package/dist/provider/hooks/utils/useEventListeners.js +98 -56
  128. package/dist/provider/hooks/utils/useWalletState.d.ts +5 -4
  129. package/dist/provider/hooks/utils/useWalletState.js +24 -9
  130. package/dist/provider/index.d.ts +1 -0
  131. package/dist/provider/index.js +1 -0
  132. package/dist/provider/providers/AuthProvider.d.ts +35 -0
  133. package/dist/provider/providers/AuthProvider.js +498 -0
  134. package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
  135. package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
  136. package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
  137. package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
  138. package/dist/provider/providers/ExternalWalletProvider.d.ts +76 -0
  139. package/dist/{modal/providers/ExternalWalletContext.js → provider/providers/ExternalWalletProvider.js} +146 -112
  140. package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
  141. package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
  142. package/dist/provider/stores/getters.d.ts +3 -3
  143. package/dist/provider/stores/setters.d.ts +1 -0
  144. package/dist/provider/stores/setters.js +7 -0
  145. package/dist/provider/stores/slices/config.d.ts +3 -0
  146. package/dist/provider/stores/slices/config.js +9 -0
  147. package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
  148. package/dist/provider/stores/slices/externalWallets.js +40 -0
  149. package/dist/provider/stores/slices/index.d.ts +1 -0
  150. package/dist/provider/stores/slices/index.js +1 -0
  151. package/dist/provider/stores/slices/modal.js +11 -4
  152. package/dist/provider/stores/types.d.ts +50 -4
  153. package/dist/provider/stores/useStore.js +4 -3
  154. package/dist/provider/types/externalWalletProviders.d.ts +12 -0
  155. package/dist/provider/types/externalWalletProviders.js +1 -0
  156. package/dist/provider/types/provider.d.ts +126 -17
  157. package/dist/provider/types/utils.d.ts +16 -0
  158. package/dist/provider/utils/constants.js +3 -4
  159. package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
  160. package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
  161. package/dist/provider/utils/renameMutations.d.ts +3 -0
  162. package/dist/provider/utils/renameMutations.js +5 -3
  163. package/package.json +20 -8
  164. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
  165. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
  166. package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
  167. package/dist/modal/hooks/useActiveWallet.js +0 -15
  168. package/dist/modal/hooks/useCreateAccount.d.ts +0 -6
  169. package/dist/modal/hooks/useCreateAccount.js +0 -77
  170. package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
  171. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
  172. package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
  173. package/dist/modal/hooks/useSetLoginURLs.js +0 -49
  174. package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
  175. package/dist/modal/hooks/useWalletBalance.js +0 -49
  176. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
  177. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
  178. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
  179. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
  180. package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
  181. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
  182. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
  183. package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
  184. package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
  185. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
  186. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
  187. package/dist/modal/stores/theme/actions.d.ts +0 -3
  188. package/dist/modal/stores/theme/actions.js +0 -28
  189. package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
  190. package/dist/modal/stores/theme/useThemeStore.js +0 -21
  191. package/dist/modal/stores/userInfo/actions.d.ts +0 -3
  192. package/dist/modal/stores/userInfo/actions.js +0 -30
  193. package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
  194. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
  195. package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
  196. package/dist/provider/actions/checkIfUserExists.js +0 -21
  197. package/dist/provider/actions/createGuestWallets.d.ts +0 -2
  198. package/dist/provider/actions/createGuestWallets.js +0 -13
  199. package/dist/provider/actions/createUser.d.ts +0 -12
  200. package/dist/provider/actions/createUser.js +0 -26
  201. package/dist/provider/actions/getWalletBalance.d.ts +0 -2
  202. package/dist/provider/actions/getWalletBalance.js +0 -14
  203. package/dist/provider/actions/initiateLogin.d.ts +0 -4
  204. package/dist/provider/actions/initiateLogin.js +0 -20
  205. package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
  206. package/dist/provider/actions/keepSessionAlive.js +0 -20
  207. package/dist/provider/actions/logout.d.ts +0 -2
  208. package/dist/provider/actions/logout.js +0 -17
  209. package/dist/provider/actions/signMessage.d.ts +0 -8
  210. package/dist/provider/actions/signMessage.js +0 -20
  211. package/dist/provider/actions/signTransaction.d.ts +0 -8
  212. package/dist/provider/actions/signTransaction.js +0 -20
  213. package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
  214. package/dist/provider/actions/waitForAccountCreation.js +0 -21
  215. package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
  216. package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
  217. package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
  218. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
  219. package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
  220. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  221. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +0 -15
  222. package/dist/provider/hooks/mutations/useCreateGuestWallets.js +0 -23
  223. package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
  224. package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
  225. package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
  226. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  227. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
  228. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
  229. package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
  230. package/dist/provider/hooks/mutations/useLogout.js +0 -30
  231. package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
  232. package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
  233. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
  234. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
  235. package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
  236. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  237. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
  238. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  239. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
  240. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  241. /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
@@ -0,0 +1,498 @@
1
+ "use client";
2
+ import {
3
+ __async,
4
+ __spreadProps,
5
+ __spreadValues
6
+ } from "../../chunk-MMUBH76A.js";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { formatBiometricHints } from "@getpara/react-common";
9
+ import { createContext, useCallback, useContext, useEffect, useMemo } from "react";
10
+ import { useModalStore } from "../../modal/stores/index.js";
11
+ import { ModalStep } from "../../modal/utils/steps.js";
12
+ import {
13
+ useSignUpOrLogIn,
14
+ useVerifyNewAccount,
15
+ useWaitForSignup,
16
+ useWaitForLogin,
17
+ useWaitForWalletCreation,
18
+ useVerifyOAuth,
19
+ useVerifyFarcaster,
20
+ useVerifyTelegram,
21
+ useSetup2fa,
22
+ useLogout,
23
+ useCreateGuestWallets
24
+ } from "../index.js";
25
+ import { DEFAULTS } from "../../modal/constants/defaults.js";
26
+ import { openPopup } from "../../modal/utils/openPopup.js";
27
+ import {
28
+ AuthMethod,
29
+ entityToWallet
30
+ } from "@getpara/web-sdk";
31
+ import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
32
+ import { useGoBack } from "../../modal/hooks/useGoBack.js";
33
+ import { isExternalWallet } from "@getpara/user-management-client";
34
+ import { routeMobileExternalWallet } from "../../modal/utils/routeMobileExternalWallet.js";
35
+ import { useStore } from "../stores/useStore.js";
36
+ const AuthContext = createContext({
37
+ signUpOrLogIn: () => {
38
+ },
39
+ isSignUpOrLogInPending: false,
40
+ verifyNewAccount: () => {
41
+ },
42
+ isVerifyNewAccountPending: false,
43
+ verifyNewAccountError: null,
44
+ verifyOAuth: () => {
45
+ },
46
+ verifyFarcaster: () => {
47
+ },
48
+ verifyTelegram: () => {
49
+ },
50
+ onNewAuthState: () => {
51
+ },
52
+ isSetup2faPending: false,
53
+ presentSignupUi: () => {
54
+ },
55
+ presentLoginUi: () => {
56
+ },
57
+ createGuestWallets: () => {
58
+ },
59
+ isCreateGuestWalletsPending: false,
60
+ logout: () => {
61
+ }
62
+ });
63
+ function AuthProvider({
64
+ children,
65
+ is2faEnabled = false,
66
+ isRecoverySecretStepEnabled = false,
67
+ overrides = {}
68
+ }) {
69
+ const para = useInternalClient();
70
+ const onLoginRef = useStore((state) => state.onLoginRef);
71
+ const setIsOpen = useStore((state) => state.setIsOpen);
72
+ const refs = useModalStore((state) => state.refs);
73
+ const currentStep = useModalStore((state) => state.step);
74
+ const setStep = useModalStore((state) => state.setStep);
75
+ const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
76
+ const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
77
+ const iFrameUrl = useModalStore((state) => state.iFrameUrl);
78
+ const loginState = useModalStore((state) => state.getLoginState());
79
+ const signupState = useModalStore((state) => state.getSignupState());
80
+ const setAuthState = useModalStore((state) => state.setAuthState);
81
+ const setFarcasterConnectUri = useModalStore((state) => state.setFarcasterConnectUri);
82
+ const setTwoFactorStatus = useModalStore((state) => state.setTwoFactorStatus);
83
+ const setRecoveryShare = useModalStore((state) => state.setRecoveryShare);
84
+ const authStepRoute = useModalStore((state) => state.authStepRoute);
85
+ const isIFrameReady = useModalStore((state) => state.isIFrameReady);
86
+ const goBack = useGoBack();
87
+ const biometricHints = useMemo(() => {
88
+ var _a;
89
+ return formatBiometricHints((_a = loginState == null ? void 0 : loginState.biometricHints) != null ? _a : []);
90
+ }, [loginState == null ? void 0 : loginState.biometricHints]);
91
+ const { mutate: mutateSignUpOrLogIn, isPending: isSignUpOrLogInPending } = useSignUpOrLogIn();
92
+ const {
93
+ mutate: mutateVerifyNewAccount,
94
+ isPending: isVerifyNewAccountPending,
95
+ error: verifyNewAccountError
96
+ } = useVerifyNewAccount();
97
+ const { mutate: mutateVerifyOAuth } = useVerifyOAuth();
98
+ const { mutate: mutateVerifyFarcaster } = useVerifyFarcaster();
99
+ const { mutate: mutateVerifyTelegram } = useVerifyTelegram();
100
+ const { mutate: mutateWaitForLogin } = useWaitForLogin();
101
+ const { mutate: mutateWaitForSignup } = useWaitForSignup();
102
+ const { mutateAsync: mutateAsyncWaitForWalletCreation } = useWaitForWalletCreation();
103
+ const { mutate: mutateSetup2fa, isPending: isSetup2faPending } = useSetup2fa();
104
+ const { mutate: mutateCreateGuestWallets, isPending: isCreateGuestWalletsPending } = useCreateGuestWallets();
105
+ const { mutate: mutateLogout } = useLogout();
106
+ const goBackIfPopupClosedOnSteps = (steps) => {
107
+ var _a;
108
+ if (((_a = refs.popupWindow.current) == null ? void 0 : _a.closed) && (!refs.currentStep.current || steps.includes(refs.currentStep.current))) {
109
+ refs.popupWindow.current = null;
110
+ goBack();
111
+ }
112
+ };
113
+ const cancelIfExitedSteps = (steps) => {
114
+ const stepNow = refs.currentStep.current;
115
+ return !!stepNow && !steps.includes(stepNow);
116
+ };
117
+ const signup = () => {
118
+ if (typeof window !== "undefined") {
119
+ refs.poll.current = {
120
+ action: "signup",
121
+ timeout: window == null ? void 0 : window.setTimeout(() => __async(this, null, function* () {
122
+ mutateWaitForSignup(
123
+ {
124
+ isCanceled: () => cancelIfExitedSteps([
125
+ ModalStep.BIOMETRIC_CREATION,
126
+ ModalStep.AWAITING_BIOMETRIC_CREATION,
127
+ ModalStep.PASSWORD_CREATION
128
+ ]),
129
+ onPoll: () => {
130
+ goBackIfPopupClosedOnSteps([ModalStep.AWAITING_BIOMETRIC_CREATION]);
131
+ }
132
+ },
133
+ {
134
+ onSuccess: () => {
135
+ if (para.isNoWalletConfig) {
136
+ onLoginComplete({
137
+ on2faSetupOrError: () => setStep(ModalStep.LOGIN_DONE),
138
+ on2faNotSetup: () => setStep(ModalStep.SETUP_2FA)
139
+ });
140
+ } else {
141
+ createWallets();
142
+ }
143
+ },
144
+ onError: () => {
145
+ if (refs.currentStep.current && [ModalStep.AWAITING_BIOMETRIC_CREATION, ModalStep.PASSWORD_CREATION].includes(refs.currentStep.current)) {
146
+ setStep(ModalStep.BIOMETRIC_CREATION);
147
+ }
148
+ },
149
+ onSettled: () => {
150
+ var _a;
151
+ window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
152
+ refs.poll.current = null;
153
+ refs.popupWindow.current = null;
154
+ }
155
+ }
156
+ );
157
+ }), DEFAULTS.POLLING_INTERVAL_MS)
158
+ };
159
+ }
160
+ };
161
+ const presentSignupUi = useCallback(
162
+ (method, authState) => {
163
+ switch (method) {
164
+ case AuthMethod.PASSKEY:
165
+ if (refs.currentStep.current !== ModalStep.AWAITING_BIOMETRIC_CREATION) {
166
+ setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
167
+ }
168
+ refs.popupWindow.current = openPopup({
169
+ url: authState.passkeyUrl,
170
+ target: "ParaPasskey",
171
+ type: "CREATE_PASSKEY",
172
+ current: refs.popupWindow.current
173
+ });
174
+ break;
175
+ case AuthMethod.PASSWORD:
176
+ if (isIFrameReady) {
177
+ setStep(ModalStep.PASSWORD_CREATION);
178
+ } else {
179
+ setIFrameUrl(authState.passwordUrl);
180
+ setAuthStepRoute(ModalStep.PASSWORD_CREATION);
181
+ }
182
+ break;
183
+ }
184
+ },
185
+ [isIFrameReady]
186
+ );
187
+ const login = () => {
188
+ setStep(ModalStep.BIOMETRIC_LOGIN);
189
+ refs.poll.current = {
190
+ action: "login",
191
+ timeout: window == null ? void 0 : window.setTimeout(() => __async(this, null, function* () {
192
+ mutateWaitForLogin(
193
+ {
194
+ isCanceled: () => cancelIfExitedSteps([
195
+ ModalStep.BIOMETRIC_LOGIN,
196
+ ModalStep.AWAITING_BIOMETRIC_LOGIN,
197
+ ModalStep.AWAITING_PASSWORD_LOGIN
198
+ ]),
199
+ onPoll: () => {
200
+ goBackIfPopupClosedOnSteps([ModalStep.AWAITING_BIOMETRIC_LOGIN, ModalStep.AWAITING_PASSWORD_LOGIN]);
201
+ }
202
+ },
203
+ {
204
+ onSuccess: ({ needsWallet }) => {
205
+ if (needsWallet && !para.isNoWalletConfig) {
206
+ createWallets();
207
+ } else {
208
+ onLoginComplete({
209
+ on2faSetupOrError: () => setStep(ModalStep.LOGIN_DONE),
210
+ on2faNotSetup: () => setStep(ModalStep.SETUP_2FA)
211
+ });
212
+ }
213
+ },
214
+ onSettled: () => {
215
+ var _a;
216
+ window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
217
+ refs.poll.current = null;
218
+ refs.popupWindow.current = null;
219
+ }
220
+ }
221
+ );
222
+ }), DEFAULTS.LOGGIN_POLLING_DELAY_MS)
223
+ };
224
+ };
225
+ const presentLoginUi = useCallback(
226
+ (method, authState) => {
227
+ const isPasskey = method === AuthMethod.PASSKEY, isPassword = !isPasskey;
228
+ if (overrides.login) {
229
+ function loginOverride() {
230
+ return __async(this, null, function* () {
231
+ var _a, _b;
232
+ yield (_a = overrides == null ? void 0 : overrides.login) == null ? void 0 : _a.call(overrides, para);
233
+ yield (_b = onLoginRef.current) == null ? void 0 : _b.call(onLoginRef);
234
+ yield onLoginComplete();
235
+ });
236
+ }
237
+ loginOverride();
238
+ return;
239
+ }
240
+ refs.popupWindow.current = openPopup({
241
+ url: isPassword ? authState.passwordUrl : authState.passkeyUrl,
242
+ target: isPassword ? "ParaPassword" : "ParaPasskey",
243
+ type: isPassword ? "LOGIN_PASSWORD" : "LOGIN_PASSKEY",
244
+ current: refs.popupWindow.current
245
+ });
246
+ setStep(isPassword ? ModalStep.AWAITING_PASSWORD_LOGIN : ModalStep.AWAITING_BIOMETRIC_LOGIN);
247
+ },
248
+ [loginState, biometricHints]
249
+ );
250
+ const onNewAuthState = (authState) => __async(this, null, function* () {
251
+ setAuthState(authState);
252
+ switch (authState.stage) {
253
+ case "verify":
254
+ if (isExternalWallet(authState.auth) && authState.signatureVerificationMessage) {
255
+ setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
256
+ } else {
257
+ setStep(ModalStep.VERIFICATIONS);
258
+ }
259
+ break;
260
+ case "login":
261
+ login();
262
+ break;
263
+ case "signup":
264
+ {
265
+ const isPassword = !!authState.passwordUrl, isPasswordOnly = isPassword && !authState.passkeyUrl;
266
+ if (isPassword) {
267
+ setIFrameUrl(authState.passwordUrl);
268
+ }
269
+ signup();
270
+ if (isPasswordOnly) {
271
+ presentSignupUi(AuthMethod.PASSWORD, authState);
272
+ } else {
273
+ setStep(ModalStep.BIOMETRIC_CREATION);
274
+ }
275
+ }
276
+ break;
277
+ }
278
+ });
279
+ const signUpOrLogIn = (auth) => __async(this, null, function* () {
280
+ mutateSignUpOrLogIn(
281
+ { auth, useShortUrls: true },
282
+ {
283
+ onSuccess: onNewAuthState
284
+ }
285
+ );
286
+ });
287
+ const verifyNewAccount = (verificationCode) => __async(this, null, function* () {
288
+ mutateVerifyNewAccount(
289
+ { verificationCode },
290
+ {
291
+ onSuccess: onNewAuthState
292
+ }
293
+ );
294
+ });
295
+ const verifyOAuth = (method) => __async(this, null, function* () {
296
+ setStep(ModalStep.AWAITING_OAUTH);
297
+ mutateVerifyOAuth(
298
+ {
299
+ method,
300
+ isCanceled: () => {
301
+ var _a;
302
+ return ((_a = refs.popupWindow.current) == null ? void 0 : _a.closed) || cancelIfExitedSteps([ModalStep.AWAITING_OAUTH]);
303
+ },
304
+ onPoll: () => {
305
+ goBackIfPopupClosedOnSteps([ModalStep.AWAITING_OAUTH]);
306
+ },
307
+ onOAuthUrl: (oAuthUrl) => {
308
+ refs.popupWindow.current = openPopup({
309
+ url: oAuthUrl,
310
+ target: `${method}AuthPopup`,
311
+ type: "OAUTH",
312
+ current: refs.popupWindow.current
313
+ });
314
+ },
315
+ useShortUrls: true
316
+ },
317
+ {
318
+ onSuccess: onNewAuthState,
319
+ onError: () => {
320
+ goBackIfPopupClosedOnSteps([ModalStep.AWAITING_OAUTH]);
321
+ }
322
+ }
323
+ );
324
+ });
325
+ const verifyFarcaster = () => __async(this, null, function* () {
326
+ setStep(ModalStep.FARCASTER_OAUTH);
327
+ mutateVerifyFarcaster(
328
+ {
329
+ isCanceled: () => refs.currentStep.current !== ModalStep.FARCASTER_OAUTH,
330
+ onConnectUri: (connectUri) => {
331
+ setFarcasterConnectUri(connectUri);
332
+ routeMobileExternalWallet(connectUri);
333
+ },
334
+ useShortUrls: true
335
+ },
336
+ {
337
+ onSuccess: onNewAuthState,
338
+ onError: () => {
339
+ if (refs.currentStep.current === ModalStep.FARCASTER_OAUTH) {
340
+ goBack();
341
+ }
342
+ }
343
+ }
344
+ );
345
+ });
346
+ const verifyTelegram = (telegramAuthResponse) => __async(this, null, function* () {
347
+ mutateVerifyTelegram(
348
+ {
349
+ telegramAuthResponse,
350
+ useShortUrls: true
351
+ },
352
+ {
353
+ onSuccess: onNewAuthState
354
+ }
355
+ );
356
+ });
357
+ const onLoginComplete = useCallback(
358
+ (..._0) => __async(this, [..._0], function* ({
359
+ on2faSetupOrError,
360
+ on2faNotSetup
361
+ } = {}) {
362
+ var _a;
363
+ setAuthState();
364
+ yield (_a = onLoginRef.current) == null ? void 0 : _a.call(onLoginRef);
365
+ if (is2faEnabled) {
366
+ mutateSetup2fa(void 0, {
367
+ onSuccess: (status) => {
368
+ setTwoFactorStatus(status);
369
+ if (!status.isSetup && !!status.uri) {
370
+ on2faNotSetup == null ? void 0 : on2faNotSetup();
371
+ } else {
372
+ on2faSetupOrError == null ? void 0 : on2faSetupOrError();
373
+ }
374
+ },
375
+ onError: () => {
376
+ on2faSetupOrError == null ? void 0 : on2faSetupOrError();
377
+ }
378
+ });
379
+ } else {
380
+ on2faSetupOrError == null ? void 0 : on2faSetupOrError();
381
+ }
382
+ }),
383
+ [is2faEnabled]
384
+ );
385
+ const createWallets = useCallback(() => __async(this, null, function* () {
386
+ var _a;
387
+ if (refs.currentStep.current !== ModalStep.AWAITING_WALLET_CREATION) {
388
+ setStep(ModalStep.AWAITING_WALLET_CREATION);
389
+ }
390
+ let recoverySecret, walletIds;
391
+ try {
392
+ if (overrides.createWallets) {
393
+ ({ recoverySecret, walletIds } = yield (_a = overrides == null ? void 0 : overrides.createWallets) == null ? void 0 : _a.call(overrides, para));
394
+ const fetchedWallets = (yield para.fetchWallets()).filter((wallet) => !!wallet.address);
395
+ const newWallets = {};
396
+ for (const wallet of fetchedWallets) {
397
+ newWallets[wallet.id] = __spreadProps(__spreadValues({}, entityToWallet(wallet)), {
398
+ signer: ""
399
+ });
400
+ }
401
+ para.setWallets(newWallets);
402
+ } else {
403
+ ({ recoverySecret, walletIds } = yield mutateAsyncWaitForWalletCreation({
404
+ isCanceled: () => false
405
+ }));
406
+ }
407
+ if (walletIds) {
408
+ yield para.setCurrentWalletIds(walletIds);
409
+ }
410
+ if (recoverySecret && isRecoverySecretStepEnabled) {
411
+ setRecoveryShare(recoverySecret);
412
+ }
413
+ setStep(recoverySecret && isRecoverySecretStepEnabled ? ModalStep.SECRET : ModalStep.WALLET_CREATION_DONE);
414
+ onLoginComplete();
415
+ } catch (e) {
416
+ }
417
+ }), [para, isRecoverySecretStepEnabled, overrides == null ? void 0 : overrides.createWallets]);
418
+ const createGuestWallets = () => {
419
+ setIsOpen(false);
420
+ mutateCreateGuestWallets(void 0, {
421
+ onSuccess: () => {
422
+ },
423
+ onSettled: () => {
424
+ }
425
+ });
426
+ };
427
+ const logout = () => {
428
+ mutateLogout();
429
+ };
430
+ const isPasswordIFrameLoading = !!iFrameUrl && iFrameUrl === (signupState == null ? void 0 : signupState.passwordUrl) && !isIFrameReady;
431
+ const value = useMemo(
432
+ () => ({
433
+ presentSignupUi,
434
+ presentLoginUi,
435
+ signUpOrLogIn,
436
+ isSignUpOrLogInPending,
437
+ verifyNewAccount,
438
+ isVerifyNewAccountPending: isVerifyNewAccountPending || isPasswordIFrameLoading,
439
+ verifyNewAccountError,
440
+ verifyOAuth,
441
+ verifyFarcaster,
442
+ verifyTelegram,
443
+ onNewAuthState,
444
+ isSetup2faPending,
445
+ createGuestWallets,
446
+ isCreateGuestWalletsPending,
447
+ logout,
448
+ biometricHints
449
+ }),
450
+ [
451
+ presentSignupUi,
452
+ presentLoginUi,
453
+ signUpOrLogIn,
454
+ isSignUpOrLogInPending,
455
+ verifyNewAccount,
456
+ isVerifyNewAccountPending,
457
+ isPasswordIFrameLoading,
458
+ verifyNewAccountError,
459
+ verifyOAuth,
460
+ verifyFarcaster,
461
+ verifyTelegram,
462
+ onNewAuthState,
463
+ isSetup2faPending,
464
+ createGuestWallets,
465
+ isCreateGuestWalletsPending,
466
+ logout,
467
+ biometricHints
468
+ ]
469
+ );
470
+ useEffect(() => {
471
+ if (!!authStepRoute && isIFrameReady && refs.currentStep.current !== authStepRoute) {
472
+ setTimeout(() => {
473
+ setStep(authStepRoute);
474
+ }, 200);
475
+ }
476
+ }, [authStepRoute, isIFrameReady]);
477
+ useEffect(() => {
478
+ refs.currentStep.current = currentStep;
479
+ }, [currentStep]);
480
+ useEffect(() => {
481
+ if (refs.currentStep.current === ModalStep.AWAITING_GUEST_WALLET_CREATION && !isCreateGuestWalletsPending) {
482
+ setStep(ModalStep.ACCOUNT_MAIN);
483
+ }
484
+ }, [isCreateGuestWalletsPending]);
485
+ useEffect(() => {
486
+ return () => {
487
+ var _a;
488
+ window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
489
+ };
490
+ }, []);
491
+ return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
492
+ }
493
+ const useAuthActions = () => useContext(AuthContext);
494
+ export {
495
+ AuthContext,
496
+ AuthProvider,
497
+ useAuthActions
498
+ };
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { ExternalWalletProviderCommon, ParaCosmosProviderConfigNoWallets } from '../types/externalWalletProviders.js';
3
+ import { ParaCosmosProviderProps } from '@getpara/cosmos-wallet-connectors';
4
+ export declare function CosmosExternalWalletProvider({ children, isUsing, wallets: walletsFromProps, ...rest }: Omit<ParaCosmosProviderProps, 'config'> & {
5
+ config: ParaCosmosProviderConfigNoWallets;
6
+ } & PropsWithChildren & ExternalWalletProviderCommon): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
7
+ export declare const MemoizedCosmosExternalWalletProvider: import("react").MemoExoticComponent<typeof CosmosExternalWalletProvider>;
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ import {
3
+ __async,
4
+ __objRest,
5
+ __spreadProps,
6
+ __spreadValues
7
+ } from "../../chunk-MMUBH76A.js";
8
+ import { jsx } from "react/jsx-runtime";
9
+ import { memo, useEffect, useMemo } from "react";
10
+ import { useStore } from "../stores/useStore.js";
11
+ import { getParaCosmosConnector } from "../external/getParaCosmosConnector.js";
12
+ function CosmosExternalWalletProvider(_a) {
13
+ var _b = _a, {
14
+ children,
15
+ isUsing,
16
+ wallets: walletsFromProps
17
+ } = _b, rest = __objRest(_b, [
18
+ "children",
19
+ "isUsing",
20
+ "wallets"
21
+ ]);
22
+ const setCosmosContext = useStore((state) => state.setCosmosContext);
23
+ const setCosmosProvider = useStore((state) => state.setCosmosProvider);
24
+ const CosmosProvider = useStore((state) => state.CosmosProvider);
25
+ const setCosmosWallets = useStore((state) => state.setCosmosWallets);
26
+ const cosmosWallets = useStore((state) => state.cosmosWallets);
27
+ const isLoadingLib = useStore((state) => state.isLoadingCosmosLib);
28
+ const setIsLoadingLib = useStore((state) => state.setIsLoadingCosmosLib);
29
+ const filteredWallets = useMemo(
30
+ () => cosmosWallets.filter((w) => walletsFromProps.includes(w().id.toUpperCase())),
31
+ [cosmosWallets, walletsFromProps]
32
+ );
33
+ useEffect(() => {
34
+ const loadLib = () => __async(this, null, function* () {
35
+ if (CosmosProvider) {
36
+ return;
37
+ }
38
+ const { Provider, context, wallets } = yield getParaCosmosConnector();
39
+ if (Provider) {
40
+ setCosmosProvider(Provider);
41
+ }
42
+ if (wallets) {
43
+ setCosmosWallets(wallets);
44
+ }
45
+ if (context) {
46
+ setCosmosContext(context);
47
+ }
48
+ setIsLoadingLib(false);
49
+ });
50
+ loadLib();
51
+ }, []);
52
+ if (isLoadingLib) {
53
+ return null;
54
+ }
55
+ if (CosmosProvider) {
56
+ return /* @__PURE__ */ jsx(CosmosProvider, __spreadProps(__spreadValues({}, rest), { config: __spreadProps(__spreadValues({}, rest == null ? void 0 : rest.config), { wallets: filteredWallets }), children }));
57
+ } else if (isUsing) {
58
+ console.warn("@getpara/cosmos-wallet-connectors is required to use an external Cosmos wallet.");
59
+ }
60
+ return children;
61
+ }
62
+ const MemoizedCosmosExternalWalletProvider = memo(CosmosExternalWalletProvider);
63
+ export {
64
+ CosmosExternalWalletProvider,
65
+ MemoizedCosmosExternalWalletProvider
66
+ };
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { ParaEvmProviderProps } from '@getpara/evm-wallet-connectors';
3
+ import { Chain, Transport } from 'viem';
4
+ import { ExternalWalletProviderCommon, ParaEvmProviderConfigNoWallets } from '../types/externalWalletProviders.js';
5
+ export declare function EvmExternalWalletProvider<const chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>>({ children, isUsing, wallets: walletsFromProps, ...rest }: Omit<ParaEvmProviderProps<chains, transports>, 'config'> & {
6
+ config: ParaEvmProviderConfigNoWallets<chains, transports>;
7
+ } & PropsWithChildren & ExternalWalletProviderCommon): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import {
3
+ __async,
4
+ __objRest,
5
+ __spreadProps,
6
+ __spreadValues
7
+ } from "../../chunk-MMUBH76A.js";
8
+ import { jsx } from "react/jsx-runtime";
9
+ import { useEffect, useMemo } from "react";
10
+ import { getParaEvmConnector } from "../external/getParaEvmConnector.js";
11
+ import { useStore } from "../stores/useStore.js";
12
+ function EvmExternalWalletProvider(_a) {
13
+ var _b = _a, {
14
+ children,
15
+ isUsing,
16
+ wallets: walletsFromProps
17
+ } = _b, rest = __objRest(_b, [
18
+ "children",
19
+ "isUsing",
20
+ "wallets"
21
+ ]);
22
+ const setEvmContext = useStore((state) => state.setEvmContext);
23
+ const setEvmProvider = useStore((state) => state.setEvmProvider);
24
+ const EvmProvider = useStore((state) => state.EvmProvider);
25
+ const setEvmWallets = useStore((state) => state.setEvmWallets);
26
+ const evmWallets = useStore((state) => state.evmWallets);
27
+ const isLoadingLib = useStore((state) => state.isLoadingEvmLib);
28
+ const setIsLoadingLib = useStore((state) => state.setIsLoadingEvmLib);
29
+ const filteredWallets = useMemo(
30
+ () => evmWallets.filter(
31
+ (w) => {
32
+ var _a2, _b2, _c, _d;
33
+ return walletsFromProps.includes(
34
+ w({
35
+ appName: (_b2 = (_a2 = rest == null ? void 0 : rest.config) == null ? void 0 : _a2.appName) != null ? _b2 : "",
36
+ projectId: (_d = (_c = rest == null ? void 0 : rest.config) == null ? void 0 : _c.projectId) != null ? _d : ""
37
+ }).id.toUpperCase()
38
+ );
39
+ }
40
+ ),
41
+ [evmWallets, walletsFromProps]
42
+ );
43
+ useEffect(() => {
44
+ const loadLib = () => __async(this, null, function* () {
45
+ if (EvmProvider) {
46
+ return;
47
+ }
48
+ const { Provider, context, wallets } = yield getParaEvmConnector();
49
+ if (Provider) {
50
+ setEvmProvider(Provider);
51
+ }
52
+ if (wallets) {
53
+ setEvmWallets(wallets);
54
+ }
55
+ if (context) {
56
+ setEvmContext(context);
57
+ }
58
+ setIsLoadingLib(false);
59
+ });
60
+ loadLib();
61
+ }, []);
62
+ if (isLoadingLib) {
63
+ return null;
64
+ }
65
+ if (EvmProvider) {
66
+ return /* @__PURE__ */ jsx(EvmProvider, __spreadProps(__spreadValues({}, rest), { config: __spreadProps(__spreadValues({}, rest == null ? void 0 : rest.config), { wallets: filteredWallets }), children }));
67
+ } else if (isUsing) {
68
+ console.warn("@getpara/evm-wallet-connectors is required to use an external EVM wallet.");
69
+ }
70
+ return children;
71
+ }
72
+ export {
73
+ EvmExternalWalletProvider
74
+ };