@getpara/react-sdk-lite 2.12.0 → 2.13.0

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 (306) hide show
  1. package/dist/css/modal.css +0 -3
  2. package/dist/index.d.ts +1 -0
  3. package/dist/modal/ParaModal.js +46 -98
  4. package/dist/modal/components/Body/Body.d.ts +1 -2
  5. package/dist/modal/components/Body/Body.js +119 -231
  6. package/dist/modal/components/Controls/ChainSelect.js +1 -1
  7. package/dist/modal/components/Controls/Controls.js +2 -4
  8. package/dist/modal/components/Footer/Footer.js +3 -12
  9. package/dist/modal/components/Header/Header.js +13 -14
  10. package/dist/modal/components/Header/hooks/useStepTitle.d.ts +1 -1
  11. package/dist/modal/components/Header/hooks/useStepTitle.js +88 -71
  12. package/dist/modal/components/ModalContent/ModalContent.d.ts +1 -1
  13. package/dist/modal/components/ModalContent/ModalContent.js +6 -14
  14. package/dist/modal/components/OnRampComponents/AddingFunds.js +2 -2
  15. package/dist/modal/components/WalletCard/WalletCard.js +9 -9
  16. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +7 -5
  17. package/dist/modal/components/{Account → flows/account/Account}/Account.js +30 -27
  18. package/dist/modal/components/{Account/AccountHeader.d.ts → flows/account/Account/Header.d.ts} +1 -1
  19. package/dist/modal/components/{Account/AccountHeader.js → flows/account/Account/Header.js} +8 -8
  20. package/dist/modal/components/{Account/AccountWalletSelect.d.ts → flows/account/Account/WalletSelect.d.ts} +1 -1
  21. package/dist/modal/components/{Account/AccountWalletSelect.js → flows/account/Account/WalletSelect.js} +13 -11
  22. package/dist/modal/components/flows/account/AccountFlow/AccountFlow.d.ts +12 -0
  23. package/dist/modal/components/flows/account/AccountFlow/AccountFlow.js +126 -0
  24. package/dist/modal/components/flows/account/AccountProvider/AccountContext.d.ts +11 -0
  25. package/dist/modal/components/flows/account/AccountProvider/AccountContext.js +42 -0
  26. package/dist/modal/components/flows/account/AccountProvider/AccountProvider.d.ts +4 -0
  27. package/dist/modal/components/flows/account/AccountProvider/AccountProvider.js +110 -0
  28. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFunds.js +12 -12
  29. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsAsset.js +3 -3
  30. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsAwaiting.js +7 -8
  31. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsContext.d.ts +1 -1
  32. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsContext.js +11 -11
  33. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsDone.js +8 -9
  34. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsNetwork.js +2 -2
  35. package/dist/modal/components/flows/account/AddFunds/AddFundsProvider.d.ts +1 -0
  36. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsProvider.js +13 -12
  37. package/dist/modal/components/flows/account/AddFunds/AddFundsReceive.d.ts +1 -0
  38. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsReceive.js +10 -10
  39. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsSettings.js +10 -10
  40. package/dist/modal/components/{AddFunds → flows/account/AddFunds}/MoonPayEmbed.js +1 -1
  41. package/dist/modal/components/flows/account/AddFunds/utils.d.ts +3 -0
  42. package/dist/modal/components/flows/account/AddFunds/utils.js +16 -0
  43. package/dist/modal/components/{ChainSwitch → flows/account/ChainSwitch}/ChainSwitch.js +7 -10
  44. package/dist/modal/components/{ChainSwitch → flows/account/ChainSwitch}/config.js +1 -1
  45. package/dist/modal/components/{Account → flows/account/Profile}/AccountMonitorTx.js +13 -13
  46. package/dist/modal/components/flows/account/Profile/FarcasterLink.d.ts +2 -0
  47. package/dist/modal/components/{OAuth → flows/account/Profile}/FarcasterLink.js +6 -6
  48. package/dist/modal/components/{Account/AccountProfile.d.ts → flows/account/Profile/Profile.d.ts} +1 -1
  49. package/dist/modal/components/{Account/AccountProfile.js → flows/account/Profile/Profile.js} +20 -24
  50. package/dist/modal/components/{Account/AccountProfileEntry.js → flows/account/Profile/ProfileEntry.js} +13 -15
  51. package/dist/modal/components/flows/account/Profile/ProfileLink.d.ts +1 -0
  52. package/dist/modal/components/{Account/AccountProfileLink.js → flows/account/Profile/ProfileLink.js} +19 -34
  53. package/dist/modal/components/flows/account/Profile/ProfileLinkOptions.d.ts +1 -0
  54. package/dist/modal/components/{Account/AccountProfileLinkOptions.js → flows/account/Profile/ProfileLinkOptions.js} +11 -11
  55. package/dist/modal/components/flows/account/Profile/ProfileUnlink.d.ts +1 -0
  56. package/dist/modal/components/{Account/AccountProfileUnlink.js → flows/account/Profile/ProfileUnlink.js} +6 -6
  57. package/dist/modal/{hooks/useTelegramLogin.d.ts → components/flows/account/Profile/useTelegramLink.d.ts} +1 -5
  58. package/dist/modal/{hooks/useTelegramLogin.js → components/flows/account/Profile/useTelegramLink.js} +15 -22
  59. package/dist/modal/components/{Account/AccountSend → flows/account/Send}/AssetNetwork.js +1 -1
  60. package/dist/modal/components/flows/account/Send/SendAsset.d.ts +1 -0
  61. package/dist/modal/components/{Account/AccountSend/AccountSendAsset.js → flows/account/Send/SendAsset.js} +11 -12
  62. package/dist/modal/components/flows/account/Send/SendForm.d.ts +1 -0
  63. package/dist/modal/components/{Account/AccountSend/AccountSendForm.js → flows/account/Send/SendForm.js} +15 -16
  64. package/dist/modal/components/flows/account/Send/SendNetwork.d.ts +1 -0
  65. package/dist/modal/components/{Account/AccountSend/AccountSendNetwork.js → flows/account/Send/SendNetwork.js} +9 -10
  66. package/dist/modal/components/flows/account/Send/SendNoAssets.d.ts +1 -0
  67. package/dist/modal/components/{Account/AccountSend/AccountSendNoAssets.js → flows/account/Send/SendNoAssets.js} +8 -9
  68. package/dist/modal/components/{Account/AccountSend → flows/account/Send}/context.js +5 -5
  69. package/dist/modal/components/{Account/AccountSend → flows/account/Send}/index.js +11 -11
  70. package/dist/modal/components/flows/account/SwitchWallets/SwitchWallets.d.ts +1 -0
  71. package/dist/modal/components/{SwitchWalletsStep/SwitchWalletsStep.js → flows/account/SwitchWallets/SwitchWallets.js} +4 -4
  72. package/dist/modal/components/flows/account/Wallet/Wallet.d.ts +1 -0
  73. package/dist/modal/components/{Account/AccountWallet.js → flows/account/Wallet/Wallet.js} +11 -12
  74. package/dist/modal/components/flows/auth/AuthFlow/AuthFlow.d.ts +10 -0
  75. package/dist/modal/components/flows/auth/AuthFlow/AuthFlow.js +94 -0
  76. package/dist/modal/components/flows/auth/AuthMain/AuthMain.d.ts +9 -0
  77. package/dist/modal/components/{AuthMainStep/AuthMainStep.js → flows/auth/AuthMain/AuthMain.js} +10 -21
  78. package/dist/modal/components/flows/auth/AuthMain/AuthMainContent.d.ts +9 -0
  79. package/dist/modal/components/{AuthMainStep/AuthMainStepContent.js → flows/auth/AuthMain/AuthMainContent.js} +49 -24
  80. package/dist/modal/components/flows/auth/AwaitingAccountSetup/AwaitingAccountSetup.d.ts +1 -0
  81. package/dist/modal/components/flows/auth/AwaitingAccountSetup/AwaitingAccountSetup.js +31 -0
  82. package/dist/modal/components/flows/auth/AwaitingBiometrics/AwaitingBiometrics.d.ts +1 -0
  83. package/dist/modal/components/flows/auth/AwaitingBiometrics/AwaitingBiometrics.js +21 -0
  84. package/dist/modal/components/flows/auth/AwaitingOAuth/AwaitingOAuth.d.ts +1 -0
  85. package/dist/modal/components/{AwaitingOAuthStep/AwaitingOAuthStep.js → flows/auth/AwaitingOAuth/AwaitingOAuth.js} +4 -4
  86. package/dist/modal/components/flows/auth/AwaitingPassword/AwaitingPassword.d.ts +1 -0
  87. package/dist/modal/components/flows/auth/AwaitingPassword/AwaitingPassword.js +22 -0
  88. package/dist/modal/components/flows/auth/BiometricCreation/BiometricCreation.d.ts +1 -0
  89. package/dist/modal/components/{BiometricCreationStep/BiometricCreationStep.js → flows/auth/BiometricCreation/BiometricCreation.js} +25 -22
  90. package/dist/modal/components/flows/auth/BiometricLogin/BiometricLogin.d.ts +1 -0
  91. package/dist/modal/components/flows/auth/BiometricLogin/BiometricLogin.js +72 -0
  92. package/dist/modal/components/flows/auth/LoginDone/LoginDone.d.ts +5 -0
  93. package/dist/modal/components/{LoginDoneStep/LoginDoneStep.js → flows/auth/LoginDone/LoginDone.js} +9 -13
  94. package/dist/modal/components/{OAuth → flows/auth/OAuth}/OAuth.js +15 -23
  95. package/dist/modal/components/{RecoverySecretStep → flows/auth/RecoverySecretStep}/RecoverySecretStep.js +9 -11
  96. package/dist/modal/components/flows/auth/Setup2FA/Setup2FA.d.ts +5 -0
  97. package/dist/modal/components/{Setup2FAStep/Setup2FAStep.js → flows/auth/Setup2FA/Setup2FA.js} +42 -19
  98. package/dist/modal/components/flows/auth/Verification/Verification.d.ts +1 -0
  99. package/dist/modal/components/flows/auth/Verification/Verification.js +36 -0
  100. package/dist/modal/components/flows/auth/WalletCreationDone/WalletCreationDone.d.ts +6 -0
  101. package/dist/modal/components/{WalletCreationDoneStep/WalletCreationDoneStep.js → flows/auth/WalletCreationDone/WalletCreationDone.js} +19 -46
  102. package/dist/modal/components/{AuthOptions → shared}/AuthOptions.d.ts +2 -2
  103. package/dist/modal/components/{AuthOptions → shared}/AuthOptions.js +18 -15
  104. package/dist/modal/components/{ExternalWalletStep/ExternalWalletStep.d.ts → shared/ConnectExternalWallet/ConnectExternalWallet.d.ts} +1 -1
  105. package/dist/modal/components/{ExternalWalletStep/ExternalWalletStep.js → shared/ConnectExternalWallet/ConnectExternalWallet.js} +16 -36
  106. package/dist/modal/components/{ExternalWalletStep → shared/ConnectExternalWallet}/config.js +1 -1
  107. package/dist/modal/components/{AuthInput/AuthInput.d.ts → shared/EmailOrPhone/EmailOrPhoneInput.d.ts} +4 -4
  108. package/dist/modal/components/{AuthInput/AuthInput.js → shared/EmailOrPhone/EmailOrPhoneInput.js} +14 -10
  109. package/dist/modal/components/{AuthInput → shared/EmailOrPhone}/phoneMasks.js +1 -1
  110. package/dist/modal/components/{ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts → shared/ExternalWalletNetworkSelect.d.ts} +1 -1
  111. package/dist/modal/components/{ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js → shared/ExternalWalletNetworkSelect.js} +9 -9
  112. package/dist/modal/components/{ExternalWallets → shared}/ExternalWallets.js +17 -12
  113. package/dist/modal/components/shared/IFrame.d.ts +1 -0
  114. package/dist/modal/components/shared/IFrame.js +87 -0
  115. package/dist/modal/components/{VerificationCodeStep/VerificationCodeStep.d.ts → shared/VerificationCode.d.ts} +3 -4
  116. package/dist/modal/components/{VerificationCodeStep/VerificationCodeStep.js → shared/VerificationCode.js} +4 -28
  117. package/dist/modal/components/shared/VerifyExternalWallet.d.ts +1 -0
  118. package/dist/modal/components/{ExternalWalletVerificationStep/ExternalWalletVerificationStep.js → shared/VerifyExternalWallet.js} +10 -17
  119. package/dist/modal/hooks/index.d.ts +1 -2
  120. package/dist/modal/hooks/index.js +1 -2
  121. package/dist/modal/hooks/useAuthView.d.ts +4 -0
  122. package/dist/modal/hooks/useAuthView.js +115 -0
  123. package/dist/modal/hooks/useCanbGoBack.d.ts +3 -0
  124. package/dist/modal/hooks/useCanbGoBack.js +47 -0
  125. package/dist/modal/{components/AuthInput/hooks → hooks}/useDropdownPosition.js +3 -3
  126. package/dist/modal/hooks/useGoBack.d.ts +4 -1
  127. package/dist/modal/hooks/useGoBack.js +60 -36
  128. package/dist/modal/hooks/useSendMutations.js +4 -5
  129. package/dist/modal/hooks/useTransactionMonitoring.js +8 -8
  130. package/dist/modal/index.d.ts +1 -2
  131. package/dist/modal/index.js +1 -3
  132. package/dist/modal/stores/index.d.ts +0 -1
  133. package/dist/modal/stores/index.js +0 -1
  134. package/dist/modal/types/modalProps.d.ts +18 -8
  135. package/dist/provider/ParaProviderMin.js +34 -38
  136. package/dist/provider/actions/getWallet.d.ts +1 -1
  137. package/dist/provider/actions/index.d.ts +43 -49
  138. package/dist/provider/actions/index.js +4 -0
  139. package/dist/provider/components/CosmosWalletWrapper.js +0 -3
  140. package/dist/provider/components/EvmWalletWrapper.js +0 -3
  141. package/dist/provider/components/ExternalWalletWrapper.js +8 -2
  142. package/dist/provider/hooks/mutations/index.d.ts +2 -0
  143. package/dist/provider/hooks/mutations/index.js +4 -0
  144. package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +7 -12
  145. package/dist/provider/hooks/mutations/useAuthenticateWithEmailOrPhone.d.ts +34 -0
  146. package/dist/provider/hooks/mutations/useAuthenticateWithEmailOrPhone.js +28 -0
  147. package/dist/provider/hooks/mutations/useAuthenticateWithOAuth.d.ts +34 -0
  148. package/dist/provider/hooks/mutations/useAuthenticateWithOAuth.js +28 -0
  149. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +7 -13
  150. package/dist/provider/hooks/mutations/useClaimPregenWallets.js +4 -1
  151. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +7 -6
  152. package/dist/provider/hooks/mutations/useCreateGuestWallets.js +6 -3
  153. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +7 -93
  154. package/dist/provider/hooks/mutations/useCreatePregenWallet.js +4 -1
  155. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +7 -15
  156. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +7 -15
  157. package/dist/provider/hooks/mutations/useCreateWallet.js +4 -1
  158. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +7 -27
  159. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +7 -12
  160. package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +2 -7
  161. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +7 -13
  162. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +7 -21
  163. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +6 -7
  164. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +2 -2
  165. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +7 -25
  166. package/dist/provider/hooks/mutations/useLoginExternalWallet.js +4 -1
  167. package/dist/provider/hooks/mutations/useLogout.d.ts +7 -12
  168. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +7 -13
  169. package/dist/provider/hooks/mutations/useResendVerificationCode.js +4 -1
  170. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +7 -7
  171. package/dist/provider/hooks/mutations/useSetup2fa.js +2 -2
  172. package/dist/provider/hooks/mutations/useSignMessage.d.ts +7 -31
  173. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +7 -31
  174. package/dist/provider/hooks/mutations/useSignTransaction.js +4 -1
  175. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +7 -19
  176. package/dist/provider/hooks/mutations/useSignUpOrLogIn.js +4 -1
  177. package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +7 -30
  178. package/dist/provider/hooks/mutations/useSwitchWallets.js +4 -1
  179. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +7 -15
  180. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.js +4 -1
  181. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +7 -30
  182. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +7 -19
  183. package/dist/provider/hooks/mutations/useVerifyExternalWallet.js +4 -1
  184. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +7 -31
  185. package/dist/provider/hooks/mutations/useVerifyFarcaster.js +4 -1
  186. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +7 -66
  187. package/dist/provider/hooks/mutations/useVerifyNewAccount.js +4 -1
  188. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +7 -37
  189. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +7 -22
  190. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +7 -30
  191. package/dist/provider/hooks/mutations/useWaitForLogin.js +4 -1
  192. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +7 -18
  193. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +7 -27
  194. package/dist/provider/hooks/queries/useIsFullyLoggedIn.d.ts +4 -1
  195. package/dist/provider/hooks/queries/useIsFullyLoggedIn.js +6 -1
  196. package/dist/provider/hooks/queries/useLinkedAccounts.d.ts +2 -4
  197. package/dist/provider/hooks/queries/useParaStatus.d.ts +0 -1
  198. package/dist/provider/hooks/queries/useParaStatus.js +0 -2
  199. package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
  200. package/dist/provider/hooks/utils/useEventListeners.js +0 -7
  201. package/dist/provider/hooks/utils/useFormattedBiometricHints.d.ts +1 -0
  202. package/dist/provider/hooks/utils/useFormattedBiometricHints.js +9 -5
  203. package/dist/provider/hooks/utils/useModal.d.ts +2 -2
  204. package/dist/provider/hooks/utils/useModal.js +9 -8
  205. package/dist/provider/hooks/utils/useWalletState.d.ts +3 -3
  206. package/dist/provider/hooks/utils/useWalletState.js +14 -6
  207. package/dist/provider/providers/AccountLinkProvider.js +21 -19
  208. package/dist/provider/providers/AuthProvider/AuthContext.d.ts +19 -0
  209. package/dist/provider/providers/AuthProvider/AuthContext.js +35 -0
  210. package/dist/provider/providers/AuthProvider/AuthProvider.d.ts +9 -0
  211. package/dist/provider/providers/AuthProvider/AuthProvider.js +261 -0
  212. package/dist/provider/providers/ExternalWalletProvider.d.ts +12 -4
  213. package/dist/provider/providers/ExternalWalletProvider.js +285 -283
  214. package/dist/provider/stores/getters.d.ts +1 -1
  215. package/dist/provider/stores/getters.js +5 -5
  216. package/dist/provider/stores/setters.js +2 -2
  217. package/dist/provider/stores/slices/accountFlow.d.ts +3 -0
  218. package/dist/provider/stores/slices/accountFlow.js +30 -0
  219. package/dist/provider/stores/slices/authFlow.d.ts +3 -0
  220. package/dist/provider/stores/slices/authFlow.js +63 -0
  221. package/dist/provider/stores/slices/externalWallets.js +10 -0
  222. package/dist/provider/stores/slices/index.d.ts +4 -0
  223. package/dist/provider/stores/slices/index.js +4 -0
  224. package/dist/provider/stores/slices/modal.js +8 -2
  225. package/dist/provider/stores/slices/onRamp.d.ts +3 -0
  226. package/dist/provider/stores/slices/onRamp.js +20 -0
  227. package/dist/provider/stores/slices/paraState.d.ts +3 -0
  228. package/dist/provider/stores/slices/paraState.js +9 -0
  229. package/dist/provider/stores/types.d.ts +117 -5
  230. package/dist/provider/stores/types.js +9 -0
  231. package/dist/provider/stores/useStore.d.ts +5 -3
  232. package/dist/provider/stores/useStore.js +15 -8
  233. package/package.json +8 -8
  234. package/dist/modal/components/Account/AccountProfileLink.d.ts +0 -1
  235. package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +0 -1
  236. package/dist/modal/components/Account/AccountProfileUnlink.d.ts +0 -1
  237. package/dist/modal/components/Account/AccountSend/AccountSendAsset.d.ts +0 -1
  238. package/dist/modal/components/Account/AccountSend/AccountSendForm.d.ts +0 -1
  239. package/dist/modal/components/Account/AccountSend/AccountSendNetwork.d.ts +0 -1
  240. package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.d.ts +0 -1
  241. package/dist/modal/components/Account/AccountWallet.d.ts +0 -1
  242. package/dist/modal/components/AddFunds/AddFundsProvider.d.ts +0 -1
  243. package/dist/modal/components/AddFunds/AddFundsReceive.d.ts +0 -1
  244. package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +0 -9
  245. package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +0 -9
  246. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.d.ts +0 -1
  247. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +0 -21
  248. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.d.ts +0 -1
  249. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
  250. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.d.ts +0 -1
  251. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.d.ts +0 -1
  252. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -21
  253. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +0 -5
  254. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -24
  255. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +0 -1
  256. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +0 -1
  257. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -67
  258. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.d.ts +0 -1
  259. package/dist/modal/components/Hero/Hero.d.ts +0 -1
  260. package/dist/modal/components/Hero/Hero.js +0 -118
  261. package/dist/modal/components/IFrameStep/IFrameStep.d.ts +0 -1
  262. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -83
  263. package/dist/modal/components/LoginDoneStep/LoginDoneStep.d.ts +0 -5
  264. package/dist/modal/components/OAuth/FarcasterLink.d.ts +0 -2
  265. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +0 -1
  266. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -53
  267. package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +0 -8
  268. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -91
  269. package/dist/modal/components/Setup2FAStep/Setup2FAStep.d.ts +0 -5
  270. package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.d.ts +0 -1
  271. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.d.ts +0 -5
  272. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -27
  273. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.d.ts +0 -6
  274. package/dist/modal/hooks/useFarcasterLogin.d.ts +0 -9
  275. package/dist/modal/hooks/useFarcasterLogin.js +0 -77
  276. package/dist/modal/stores/modal/actions.d.ts +0 -3
  277. package/dist/modal/stores/modal/actions.js +0 -146
  278. package/dist/modal/stores/modal/useModalStore.d.ts +0 -120
  279. package/dist/modal/stores/modal/useModalStore.js +0 -81
  280. package/dist/modal/utils/steps.d.ts +0 -162
  281. package/dist/modal/utils/steps.js +0 -335
  282. package/dist/provider/providers/AuthProvider.d.ts +0 -43
  283. package/dist/provider/providers/AuthProvider.js +0 -777
  284. /package/dist/modal/components/{Account → flows/account/Account}/Account.d.ts +0 -0
  285. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFunds.d.ts +0 -0
  286. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsAsset.d.ts +0 -0
  287. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsAwaiting.d.ts +0 -0
  288. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsDone.d.ts +0 -0
  289. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsNetwork.d.ts +0 -0
  290. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/AddFundsSettings.d.ts +0 -0
  291. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/MoonPayEmbed.d.ts +0 -0
  292. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/index.d.ts +0 -0
  293. /package/dist/modal/components/{AddFunds → flows/account/AddFunds}/index.js +0 -0
  294. /package/dist/modal/components/{ChainSwitch → flows/account/ChainSwitch}/ChainSwitch.d.ts +0 -0
  295. /package/dist/modal/components/{ChainSwitch → flows/account/ChainSwitch}/config.d.ts +0 -0
  296. /package/dist/modal/components/{Account → flows/account/Profile}/AccountMonitorTx.d.ts +0 -0
  297. /package/dist/modal/components/{Account/AccountProfileEntry.d.ts → flows/account/Profile/ProfileEntry.d.ts} +0 -0
  298. /package/dist/modal/components/{Account/AccountSend → flows/account/Send}/AssetNetwork.d.ts +0 -0
  299. /package/dist/modal/components/{Account/AccountSend → flows/account/Send}/context.d.ts +0 -0
  300. /package/dist/modal/components/{Account/AccountSend → flows/account/Send}/index.d.ts +0 -0
  301. /package/dist/modal/components/{OAuth → flows/auth/OAuth}/OAuth.d.ts +0 -0
  302. /package/dist/modal/components/{RecoverySecretStep → flows/auth/RecoverySecretStep}/RecoverySecretStep.d.ts +0 -0
  303. /package/dist/modal/components/{ExternalWalletStep → shared/ConnectExternalWallet}/config.d.ts +0 -0
  304. /package/dist/modal/components/{AuthInput → shared/EmailOrPhone}/phoneMasks.d.ts +0 -0
  305. /package/dist/modal/components/{ExternalWallets → shared}/ExternalWallets.d.ts +0 -0
  306. /package/dist/modal/{components/AuthInput/hooks → hooks}/useDropdownPosition.d.ts +0 -0
@@ -8,21 +8,23 @@ import { jsx } from "react/jsx-runtime";
8
8
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
9
9
  import { isMobile, truncateAddress } from "@getpara/web-sdk";
10
10
  import { useInternalClient } from "../hooks/utils/useInternalClient.js";
11
- import { useStore } from "../stores/useStore.js";
12
- import { ModalStep, openPopup } from "../../modal/index.js";
13
- import { useModalStore } from "../../modal/stores/index.js";
14
- import { useAccount, useModal, useParaStatus, useVerifyExternalWallet, useWalletState } from "../hooks/index.js";
11
+ import { store, useStore } from "../stores/useStore.js";
12
+ import { openPopup } from "../../modal/index.js";
13
+ import { useAccount, useModal, useParaStatus, useWaitForWalletCreation, useWalletState } from "../hooks/index.js";
15
14
  import {
16
- openMobileUrl
15
+ openMobileUrl,
16
+ useUserAgent
17
17
  } from "@getpara/react-common";
18
18
  import { ParaEvent, dispatchEvent } from "@getpara/web-sdk";
19
- import { useAuthActions } from "./AuthProvider.js";
20
- import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../hooks/queries/useIsFullyLoggedIn.js";
21
- import { useQueryClient } from "@tanstack/react-query";
19
+ import {
20
+ AuthMethod,
21
+ isExternalWallet
22
+ } from "@getpara/user-management-client";
22
23
  import { useGoBack } from "../../modal/hooks/useGoBack.js";
23
24
  import { validatePortalOrigin } from "../../modal/utils/validatePortalOrigin.js";
25
+ import { DEFAULTS } from "../../modal/constants/defaults.js";
24
26
  const useWalletDisplayHelpers = (wallet) => {
25
- const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
27
+ const isUsingMobileConnector = useStore((state) => state.isUsingMobileConnector);
26
28
  return {
27
29
  // Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
28
30
  // Also show the extension connection if on desktop for a solana wallet (no walletConnect)
@@ -49,17 +51,18 @@ const defaultExternalWallet = {
49
51
  setChainIdSwitchingTo: () => {
50
52
  },
51
53
  connectEmbeddedToExternalConnectors: () => Promise.resolve(),
52
- verifyWalletSignature: () => Promise.resolve({}),
53
54
  signMessage: () => Promise.resolve({}),
54
55
  isSigningMessage: false,
55
56
  getWalletBalance: () => Promise.resolve(void 0),
56
57
  requestInfo: (_) => Promise.resolve({}),
57
58
  disconnectBase: (_, __, ___) => Promise.resolve(),
58
59
  connectFarcasterMiniApp: () => Promise.resolve(),
60
+ switchConnection: (_) => Promise.resolve(),
59
61
  verificationStage: void 0,
60
62
  evmDisconnectStatus: "idle",
61
63
  solanaDisconnectStatus: "idle",
62
- cosmosDisconnectStatus: "idle"
64
+ cosmosDisconnectStatus: "idle",
65
+ retryVerification: () => Promise.resolve()
63
66
  };
64
67
  const ExternalWalletContext = createContext(defaultExternalWallet);
65
68
  function ExternalWalletProvider({ children }) {
@@ -83,8 +86,8 @@ function ExternalWalletProvider({ children }) {
83
86
  username: evmUsername,
84
87
  avatar: evmAvatar,
85
88
  connectParaEmbedded: evmConnectParaEmbedded,
89
+ switchConnection: evmSwitchConnection,
86
90
  signMessage: evmSignMessage,
87
- signVerificationMessage: evmSignVerificationMessage,
88
91
  getWalletBalance: evmGetWalletBalance,
89
92
  requestInfo: evmRequestInfo,
90
93
  disconnectBase: evmDisconnectBase,
@@ -96,7 +99,6 @@ function ExternalWalletProvider({ children }) {
96
99
  wallets: solanaWallets,
97
100
  disconnect: solanaDisconnect,
98
101
  signMessage: solanaSignMessage,
99
- signVerificationMessage: solanaSignVerificationMessage,
100
102
  requestInfo: solanaRequestInfo,
101
103
  disconnectBase: solanaDisconnectBase,
102
104
  farcasterStatus: solanaFarcasterStatus,
@@ -109,32 +111,37 @@ function ExternalWalletProvider({ children }) {
109
111
  chainId: cosmosChainId,
110
112
  switchChain: cosmosSwitchChain,
111
113
  connectParaEmbedded: cosmosConnectParaEmbedded,
114
+ switchConnection: cosmosSwitchConnection,
112
115
  signMessage: cosmosSignMessage,
113
- signVerificationMessage: cosmosSignVerificationMessage,
114
116
  requestInfo: cosmosRequestInfo,
115
117
  disconnectBase: cosmosDisconnectBase,
116
118
  disconnectStatus: cosmosDisconnectStatus
117
119
  } = useContext(cosmosContext);
118
- const onLoginRef = useStore((state) => state.onLoginRef);
119
- const setStep = useModalStore((state) => state.setStep);
120
- const setStepDirection = useModalStore((state) => state.setStepDirection);
121
- const setIsExternalWalletConnecting = useModalStore((state) => state.setIsExternalWalletConnecting);
122
- const isExternalWalletConnecting = useModalStore((state) => state.isExternalWalletConnecting);
123
- const selectedExternalWallet = useModalStore((state) => state.selectedExternalWallet);
124
- const setSelectedExternalWallet = useModalStore((state) => state.setSelectedExternalWallet);
125
- const setExternalWalletError = useModalStore((state) => state.setExternalWalletError);
126
- const setIsUsingMobileConnector = useModalStore((state) => state.setIsUsingMobileConnector);
127
- const refs = useModalStore((state) => state.refs);
120
+ const setIsExternalWalletConnecting = useStore((state) => state.setIsExternalWalletConnecting);
121
+ const isExternalWalletConnecting = useStore((state) => state.isExternalWalletConnecting);
122
+ const selectedExternalWallet = useStore((state) => state.selectedExternalWallet);
123
+ const setSelectedExternalWallet = useStore((state) => state.setSelectedExternalWallet);
124
+ const setExternalWalletError = useStore((state) => state.setExternalWalletError);
125
+ const setIsUsingMobileConnector = useStore((state) => state.setIsUsingMobileConnector);
126
+ const refs = useStore((state) => state.refs);
128
127
  const para = useInternalClient();
129
- const { setSelectedWallet } = useWalletState();
130
- const { onNewAuthState } = useAuthActions();
131
- const { verifyExternalWalletAsync } = useVerifyExternalWallet();
132
- const queryClient = useQueryClient();
133
- const goBack = useGoBack();
128
+ const { setSelectedWallet, selectedWallet } = useWalletState();
129
+ const setIFrameUrl = useStore((state) => state.setIFrameUrl);
130
+ const { goBack } = useGoBack();
131
+ const setAuthMethod = useStore((state) => state.setAuthMethod);
132
+ const setShowPostAuthFlow = useStore((state) => state.setShowPostAuthFlow);
133
+ const setAccountView = useStore((state) => state.setAccountView);
134
+ const userAgent = useUserAgent();
135
+ const { waitForWalletCreation } = useWaitForWalletCreation();
134
136
  const [qrUri, setQrUri] = useState();
135
137
  const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
136
138
  const [isSigningMessage, setIsSigningMessage] = useState(false);
137
139
  const popupCloseIntervalRef = useRef(null);
140
+ const verificationMessage = useRef(null);
141
+ const externalWalletInfo = useRef(null);
142
+ const verificationStatusListenerRef = useRef(null);
143
+ const verificationTriggerListenerRef = useRef(null);
144
+ const connectionRetryListenerRef = useRef(null);
138
145
  const allWallets = [...evmWallets, ...solanaWallets, ...cosmosWallets];
139
146
  let wallets = allWallets.filter(
140
147
  (w) => (w.internalId !== "FARCASTER" || (para == null ? void 0 : para.isFarcasterMiniApp)) && externalWallets.includes(w.internalId)
@@ -150,6 +157,79 @@ function ExternalWalletProvider({ children }) {
150
157
  [wallets, selectedExternalWallet]
151
158
  );
152
159
  const [walletConnectCleanup, setWalletConnectCleanup] = useState(null);
160
+ const retryVerification = () => __async(this, null, function* () {
161
+ var _a;
162
+ if ((_a = externalWalletInfo.current) == null ? void 0 : _a.withFullParaAuth) {
163
+ yield handleRetrySignVerificationMessage();
164
+ return;
165
+ }
166
+ yield para.retryVerifyExternalWallet();
167
+ });
168
+ const poll = () => {
169
+ if (typeof window !== "undefined") {
170
+ refs.poll.current = {
171
+ action: "signup",
172
+ timeout: window == null ? void 0 : window.setTimeout(() => __async(this, null, function* () {
173
+ waitForWalletCreation(
174
+ {
175
+ onPoll: () => {
176
+ const isUsingIFrame = !!store.getState().iFrameUrl;
177
+ if (isUsingIFrame) {
178
+ return;
179
+ }
180
+ const authMethod = store.getState().authMethod;
181
+ if ((!refs.popupWindow.current || refs.popupWindow.current.closed) && (authMethod !== null || authMethod !== AuthMethod.BASIC_LOGIN)) {
182
+ setAuthMethod(null);
183
+ }
184
+ }
185
+ },
186
+ {
187
+ onSettled: () => {
188
+ var _a;
189
+ window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
190
+ refs.poll.current = null;
191
+ refs.popupWindow.current = null;
192
+ }
193
+ }
194
+ );
195
+ }), DEFAULTS.POLLING_INTERVAL_MS)
196
+ };
197
+ }
198
+ };
199
+ const onNewAuthState = (authState) => __async(this, null, function* () {
200
+ var _a, _b;
201
+ switch (authState.stage) {
202
+ case "verify":
203
+ if (isExternalWallet(authState.auth)) {
204
+ if (authState.loginUrl && ((_a = authState.externalWallet) == null ? void 0 : _a.withFullParaAuth)) {
205
+ if (!isMobile() && refs.popupWindow.current) {
206
+ refs.popupWindow.current.location.href = authState.loginUrl;
207
+ } else {
208
+ setIFrameUrl(authState.loginUrl);
209
+ }
210
+ }
211
+ }
212
+ break;
213
+ case "login":
214
+ case "signup":
215
+ const hasPassword = !!authState.passwordUrl;
216
+ const hasPin = !!authState.pinUrl;
217
+ const hasExactlyOnePasswordOrPin = hasPassword && !hasPin || !hasPassword && hasPin;
218
+ const shouldUseIFrame = !authState.passkeyUrl || (userAgent == null ? void 0 : userAgent.device.type) === "mobile" && !authState.isPasskeySupported && hasExactlyOnePasswordOrPin;
219
+ if (shouldUseIFrame) {
220
+ setIFrameUrl(hasPassword ? authState.passwordUrl : authState.pinUrl);
221
+ }
222
+ setAuthMethod(null);
223
+ poll();
224
+ break;
225
+ case "done":
226
+ setShowPostAuthFlow(true);
227
+ if ((_b = authState.externalWallet) == null ? void 0 : _b.withFullParaAuth) {
228
+ poll();
229
+ }
230
+ break;
231
+ }
232
+ });
153
233
  const listenForWalletConnectUri = () => {
154
234
  setQrUri(void 0);
155
235
  if (walletConnectCleanup) {
@@ -241,12 +321,12 @@ function ExternalWalletProvider({ children }) {
241
321
  setChainIdSwitchingTo(chainId2);
242
322
  switch (walletType) {
243
323
  case "COSMOS": {
244
- setStep(ModalStep.CHAIN_SWITCH);
324
+ setAccountView("ACCOUNT_CHAIN_SWITCH");
245
325
  resp = yield cosmosSwitchChain(chainId2);
246
326
  break;
247
327
  }
248
328
  case "EVM": {
249
- setStep(ModalStep.CHAIN_SWITCH);
329
+ setAccountView("ACCOUNT_CHAIN_SWITCH");
250
330
  resp = yield evmSwitchChain(parseInt(chainId2));
251
331
  break;
252
332
  }
@@ -259,109 +339,12 @@ function ExternalWalletProvider({ children }) {
259
339
  setExternalWalletError(resp.error);
260
340
  } else {
261
341
  setChainIdSwitchingTo(void 0);
262
- setStepDirection(-1);
263
- setStep(ModalStep.ACCOUNT_MAIN);
342
+ setAccountView("ACCOUNT_MAIN");
264
343
  }
265
344
  }
266
345
  }),
267
346
  [evmSwitchChain, cosmosSwitchChain]
268
347
  );
269
- const verifyWalletSignature = useCallback(() => __async(this, null, function* () {
270
- setExternalWalletError();
271
- const wallet2 = Object.values(para.externalWallets)[0];
272
- const walletType = wallet2 == null ? void 0 : wallet2.type;
273
- let verifyExternalWalletParams;
274
- const withVerification = includeWalletVerification;
275
- const isConnectionOnly = connectionOnly;
276
- const withFullParaAuth = (wallet2 == null ? void 0 : wallet2.name) ? isWithFullAuth(wallet2) : false;
277
- const defaultWalletInfo = {
278
- withVerification,
279
- isConnectionOnly,
280
- withFullParaAuth,
281
- provider: wallet2.name,
282
- providerId: wallet2.externalProviderId,
283
- isExternal: true
284
- };
285
- switch (walletType) {
286
- case "COSMOS":
287
- {
288
- const { address, signature, error, cosmosPublicKeyHex, cosmosSigner, addressBech32 } = yield cosmosSignVerificationMessage();
289
- if (error) {
290
- setExternalWalletError([error]);
291
- return;
292
- } else if (signature && address) {
293
- verifyExternalWalletParams = {
294
- externalWallet: __spreadValues({
295
- partnerId: para.partnerId,
296
- type: "COSMOS",
297
- address,
298
- addressBech32
299
- }, defaultWalletInfo),
300
- signedMessage: signature,
301
- cosmosPublicKeyHex,
302
- cosmosSigner
303
- };
304
- }
305
- }
306
- break;
307
- case "EVM":
308
- {
309
- const { signature, error, address } = yield evmSignVerificationMessage();
310
- if (error) {
311
- setExternalWalletError([error]);
312
- return;
313
- } else if (signature && address) {
314
- verifyExternalWalletParams = {
315
- externalWallet: __spreadValues({
316
- partnerId: para.partnerId,
317
- type: "EVM",
318
- address
319
- }, defaultWalletInfo),
320
- signedMessage: signature
321
- };
322
- }
323
- }
324
- break;
325
- case "SOLANA":
326
- {
327
- const { signature, error, address } = yield solanaSignVerificationMessage();
328
- if (error) {
329
- setExternalWalletError([error]);
330
- return;
331
- } else if (signature && address) {
332
- verifyExternalWalletParams = {
333
- externalWallet: __spreadValues({
334
- partnerId: para.partnerId,
335
- type: "SOLANA",
336
- address
337
- }, defaultWalletInfo),
338
- signedMessage: signature
339
- };
340
- }
341
- }
342
- break;
343
- default:
344
- break;
345
- }
346
- if (!(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.externalWallet) || !(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.signedMessage)) {
347
- console.error("No signature or address found on the verifyWalletSignature response.");
348
- setExternalWalletError(["Signature verification failed."]);
349
- return;
350
- }
351
- try {
352
- const d = yield verifyExternalWalletAsync(verifyExternalWalletParams);
353
- yield queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
354
- if (wallet2 && isWithFullAuth(wallet2)) {
355
- onNewAuthState(d);
356
- } else {
357
- setStep(ModalStep.LOGIN_DONE);
358
- }
359
- } catch (e) {
360
- console.error("Error verifying signature:", e);
361
- setExternalWalletError(["Signature verification failed."]);
362
- }
363
- return verifyExternalWalletParams;
364
- }), [cosmosSignVerificationMessage, evmSignVerificationMessage, solanaSignVerificationMessage, wallet]);
365
348
  const signMessage = useCallback(
366
349
  (_0) => __async(this, [_0], function* ({
367
350
  message,
@@ -451,7 +434,7 @@ function ExternalWalletProvider({ children }) {
451
434
  });
452
435
  dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
453
436
  try {
454
- const externalWalletInfo = __spreadProps(__spreadValues({
437
+ const externalWalletInfo2 = __spreadProps(__spreadValues({
455
438
  partnerId: para.partnerId,
456
439
  address: walletInfo.address
457
440
  }, wallet2.type === "COSMOS" && walletInfo.addressBech32 && {
@@ -463,56 +446,70 @@ function ExternalWalletProvider({ children }) {
463
446
  providerId: walletInfo.providerId
464
447
  // Use the providerId from requestInfo
465
448
  });
466
- const linkResult = yield para.linkAccount({ externalWallet: externalWalletInfo });
449
+ const linkResult = yield para.linkAccount({ externalWallet: externalWalletInfo2 });
467
450
  if (linkResult && linkResult.externalWallet && "signatureVerificationMessage" in linkResult.externalWallet) {
468
- const verificationMessage = linkResult.externalWallet.signatureVerificationMessage;
451
+ const verificationMessage2 = linkResult.externalWallet.signatureVerificationMessage;
469
452
  const signResult = yield signMessage({
470
- message: verificationMessage,
471
- externalWallet: externalWalletInfo
453
+ message: verificationMessage2,
454
+ externalWallet: externalWalletInfo2
472
455
  });
473
456
  if (!signResult || !signResult.signature) {
474
457
  throw new Error(`Failed to sign ${wallet2.type} message: No signature returned`);
475
458
  }
476
459
  const { signature: signedMessage, cosmosPublicKeyHex, cosmosSigner } = signResult;
477
- yield para.verifyExternalWalletLink({ signedMessage, cosmosPublicKeyHex, cosmosSigner });
460
+ yield para.verifyExternalWalletLink({
461
+ signedMessage,
462
+ cosmosPublicKeyHex,
463
+ cosmosSigner
464
+ });
478
465
  } else {
479
466
  throw new Error("Unknown error linking external wallet");
480
467
  }
481
468
  } catch (e) {
482
469
  }
483
470
  yield connectEmbeddedToExternalConnectors();
484
- setStep(ModalStep.ACCOUNT_PROFILE);
471
+ setAccountView("ACCOUNT_PROFILE");
485
472
  } catch (e) {
486
473
  setExternalWalletError(["Failed to add wallet. Please try again."]);
487
474
  }
488
475
  }),
489
- [para, connectionOnly, includeWalletVerification, setStep, setExternalWalletError]
476
+ [para, connectionOnly, includeWalletVerification, setAccountView, setExternalWalletError]
490
477
  );
491
- const setupExternalWalletVerificationStatusListener = (wallet2) => {
492
- typeof window !== "undefined" && window.addEventListener("message", function handleMessage(event) {
493
- return __async(this, null, function* () {
494
- var _a, _b, _c, _d;
495
- if (!validatePortalOrigin(event, para.ctx)) {
496
- return;
497
- }
498
- if (((_a = event.data) == null ? void 0 : _a.type) === "EW_VERIFY_SUCCESS") {
499
- clearPopupWindowCloseListener();
500
- const serverAuthState = (_b = event.data) == null ? void 0 : _b.serverAuthState;
501
- if (serverAuthState && ((_c = serverAuthState.externalWallet) == null ? void 0 : _c.withFullParaAuth)) {
502
- const authState = yield para.verifyExternalWallet({ serverAuthState });
503
- onNewAuthState(authState);
504
- } else {
505
- setStep(ModalStep.LOGIN_DONE);
506
- }
507
- window.removeEventListener("message", handleMessage);
508
- }
509
- if (((_d = event.data) == null ? void 0 : _d.type) === "EW_VERIFY_RETRY") {
510
- yield handleTriggerSignMessage(wallet2, event.data.message);
511
- window.removeEventListener("message", handleMessage);
478
+ const clearVerificationStatusListener = () => {
479
+ if (verificationStatusListenerRef.current) {
480
+ window.removeEventListener("message", verificationStatusListenerRef.current);
481
+ verificationStatusListenerRef.current = null;
482
+ }
483
+ };
484
+ const setupExternalWalletVerificationStatusListener = () => {
485
+ clearVerificationStatusListener();
486
+ const handleMessage = (event) => __async(this, null, function* () {
487
+ var _a, _b, _c, _d;
488
+ if (!validatePortalOrigin(event, para.ctx)) {
489
+ return;
490
+ }
491
+ if (((_a = event.data) == null ? void 0 : _a.type) === "EW_VERIFY_SUCCESS") {
492
+ clearPopupWindowCloseListener();
493
+ const serverAuthState = (_b = event.data) == null ? void 0 : _b.serverAuthState;
494
+ if (serverAuthState && ((_c = serverAuthState.externalWallet) == null ? void 0 : _c.withFullParaAuth)) {
495
+ const authState = yield para.verifyExternalWallet({ serverAuthState });
496
+ yield onNewAuthState(authState);
512
497
  }
513
- });
498
+ clearVerificationStatusListener();
499
+ }
500
+ if (((_d = event.data) == null ? void 0 : _d.type) === "EW_VERIFY_RETRY") {
501
+ verificationMessage.current = event.data.message;
502
+ yield handleRetrySignVerificationMessage();
503
+ clearVerificationStatusListener();
504
+ }
514
505
  });
506
+ verificationStatusListenerRef.current = handleMessage;
507
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
515
508
  };
509
+ const handleRetrySignVerificationMessage = () => __async(this, null, function* () {
510
+ handlePostMessage({ type: "EW_VERIFY_RETRY" });
511
+ yield handleTriggerSignMessage();
512
+ });
516
513
  const handlePostMessage = (message) => {
517
514
  var _a;
518
515
  if (refs.popupWindow.current) {
@@ -521,70 +518,18 @@ function ExternalWalletProvider({ children }) {
521
518
  (_a = refs.iFrame.current.contentWindow) == null ? void 0 : _a.postMessage(message, "*");
522
519
  }
523
520
  };
524
- const handleTriggerSignMessage = (wallet2, message) => __async(this, null, function* () {
525
- setupExternalWalletVerificationStatusListener(wallet2);
521
+ const handleTriggerSignMessage = () => __async(this, null, function* () {
522
+ if (!verificationMessage.current || !externalWalletInfo.current) {
523
+ console.error("No verification message or external wallet info available for signing message.");
524
+ return;
525
+ }
526
+ setupExternalWalletVerificationStatusListener();
526
527
  try {
527
- const { address, signature, cosmosPublicKeyHex, cosmosSigner, addressBech32 } = yield signMessage({
528
- message,
529
- externalWallet: wallet2
528
+ const verifyExternalWalletParams = yield para.signExternalWalletVerification({
529
+ type: externalWalletInfo.current.type,
530
+ message: verificationMessage.current,
531
+ address: externalWalletInfo.current.address
530
532
  });
531
- const paraWallet = Object.values(para.externalWallets)[0];
532
- const walletType = paraWallet == null ? void 0 : paraWallet.type;
533
- let verifyExternalWalletParams;
534
- const withVerification = includeWalletVerification;
535
- const isConnectionOnly = connectionOnly;
536
- const withFullParaAuth = (paraWallet == null ? void 0 : paraWallet.name) ? isWithFullAuth(paraWallet) : false;
537
- const defaultWalletInfo = {
538
- withVerification,
539
- isConnectionOnly,
540
- withFullParaAuth,
541
- provider: paraWallet.name,
542
- providerId: paraWallet.externalProviderId,
543
- isExternal: true
544
- };
545
- switch (walletType) {
546
- case "COSMOS":
547
- {
548
- verifyExternalWalletParams = {
549
- externalWallet: __spreadValues({
550
- partnerId: para.partnerId,
551
- type: "COSMOS",
552
- address,
553
- addressBech32
554
- }, defaultWalletInfo),
555
- signedMessage: signature,
556
- cosmosPublicKeyHex,
557
- cosmosSigner
558
- };
559
- }
560
- break;
561
- case "EVM":
562
- {
563
- verifyExternalWalletParams = {
564
- externalWallet: __spreadValues({
565
- partnerId: para.partnerId,
566
- type: "EVM",
567
- address
568
- }, defaultWalletInfo),
569
- signedMessage: signature
570
- };
571
- }
572
- break;
573
- case "SOLANA":
574
- {
575
- verifyExternalWalletParams = {
576
- externalWallet: __spreadValues({
577
- partnerId: para.partnerId,
578
- type: "SOLANA",
579
- address
580
- }, defaultWalletInfo),
581
- signedMessage: signature
582
- };
583
- }
584
- break;
585
- default:
586
- break;
587
- }
588
533
  if (!(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.externalWallet) || !(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.signedMessage)) {
589
534
  console.error("No signature or address found on the verifyWalletSignature response.");
590
535
  handlePostMessage({ type: "EW_SIGN_MESSAGE_ERROR", error: "Signature verification failed." });
@@ -595,23 +540,44 @@ function ExternalWalletProvider({ children }) {
595
540
  handlePostMessage({ type: "EW_SIGN_MESSAGE_ERROR", error: error.message || "Error signing message" });
596
541
  }
597
542
  });
598
- const setupExternalWalletVerificationTriggerListener = (wallet2) => {
599
- if (!wallet2) {
543
+ const clearVerificationTriggerListener = () => {
544
+ if (verificationTriggerListenerRef.current) {
545
+ window.removeEventListener("message", verificationTriggerListenerRef.current);
546
+ verificationTriggerListenerRef.current = null;
547
+ }
548
+ };
549
+ const setupExternalWalletVerificationTriggerListener = () => {
550
+ if (!externalWalletInfo.current) {
551
+ console.error("No external wallet info available for signing message.");
600
552
  return;
601
553
  }
602
- typeof window !== "undefined" && window.addEventListener("message", function handleMessage(event) {
603
- return __async(this, null, function* () {
604
- var _a;
605
- if (!validatePortalOrigin(event, para.ctx)) {
606
- return;
607
- }
608
- if (((_a = event.data) == null ? void 0 : _a.type) === "EW_TRIGGER_SIGN_MESSAGE") {
609
- yield handleTriggerSignMessage(wallet2, event.data.message);
610
- window.removeEventListener("message", handleMessage);
611
- }
612
- });
554
+ clearVerificationTriggerListener();
555
+ const handleMessage = (event) => __async(this, null, function* () {
556
+ var _a;
557
+ if (!validatePortalOrigin(event, para.ctx)) {
558
+ return;
559
+ }
560
+ if (((_a = event.data) == null ? void 0 : _a.type) === "EW_TRIGGER_SIGN_MESSAGE") {
561
+ verificationMessage.current = event.data.message;
562
+ yield handleTriggerSignMessage();
563
+ clearVerificationTriggerListener();
564
+ }
613
565
  });
566
+ verificationTriggerListenerRef.current = handleMessage;
567
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
614
568
  };
569
+ const switchConnection = (_0) => __async(this, [_0], function* ({ type, id }) {
570
+ switch (type) {
571
+ case "EVM":
572
+ yield evmSwitchConnection == null ? void 0 : evmSwitchConnection(id);
573
+ break;
574
+ case "COSMOS":
575
+ yield cosmosSwitchConnection == null ? void 0 : cosmosSwitchConnection(id);
576
+ break;
577
+ default:
578
+ break;
579
+ }
580
+ });
615
581
  const setupPopupWindowCloseListener = () => {
616
582
  const popup = refs.popupWindow.current;
617
583
  if (!popup) return;
@@ -625,7 +591,6 @@ function ExternalWalletProvider({ children }) {
625
591
  popupCloseIntervalRef.current = null;
626
592
  }
627
593
  goBack();
628
- disconnectExternalWallet();
629
594
  }
630
595
  }, 500);
631
596
  };
@@ -642,35 +607,40 @@ function ExternalWalletProvider({ children }) {
642
607
  const handlePostConnectError = (error) => {
643
608
  handlePostMessage({ type: "EW_CONNECT_ERROR", error });
644
609
  };
645
- const handleConnectRetryMessage = (wallet2) => (event) => __async(this, null, function* () {
646
- var _a;
647
- if (!validatePortalOrigin(event, para.ctx)) {
648
- return;
649
- }
650
- if (((_a = event.data) == null ? void 0 : _a.type) === "EW_CONNECT_RETRY") {
651
- clearExternalWalletConnectionRetryListener(wallet2);
652
- yield connectExternalWallet({ wallet: wallet2, isMobileConnect: wallet2.isMobile, isRetryConnection: true });
610
+ const clearExternalWalletConnectionRetryListener = () => {
611
+ if (connectionRetryListenerRef.current) {
612
+ window.removeEventListener("message", connectionRetryListenerRef.current);
613
+ connectionRetryListenerRef.current = null;
653
614
  }
654
- });
655
- const setupExternalWalletConnectionRetryListener = (wallet2) => {
656
- typeof window !== "undefined" && window.addEventListener("message", handleConnectRetryMessage(wallet2));
657
615
  };
658
- const clearExternalWalletConnectionRetryListener = (wallet2) => {
659
- window.removeEventListener("message", handleConnectRetryMessage(wallet2));
616
+ const setupExternalWalletConnectionRetryListener = (wallet2) => {
617
+ clearExternalWalletConnectionRetryListener();
618
+ const handleMessage = (event) => __async(this, null, function* () {
619
+ var _a;
620
+ if (!validatePortalOrigin(event, para.ctx)) {
621
+ return;
622
+ }
623
+ if (((_a = event.data) == null ? void 0 : _a.type) === "EW_CONNECT_RETRY") {
624
+ clearExternalWalletConnectionRetryListener();
625
+ yield connectExternalWallet({ wallet: wallet2, isMobile: wallet2.isMobile, isRetryConnection: true });
626
+ }
627
+ });
628
+ connectionRetryListenerRef.current = handleMessage;
629
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
660
630
  };
661
631
  const connectExternalWallet = useCallback(
662
632
  (_0) => __async(this, [_0], function* ({
663
633
  wallet: wallet2,
664
634
  isManualWalletConnect,
665
- isMobileConnect,
635
+ isMobile: isMobileConnect,
666
636
  isResetAfterManualWalletConnect,
667
637
  isRetryConnection
668
638
  }) {
669
639
  if (isRetryConnection) {
670
- clearExternalWalletConnectionRetryListener(wallet2);
640
+ clearExternalWalletConnectionRetryListener();
671
641
  handlePostConnectRetry();
672
642
  }
673
- if (!isMobile() && isWithFullAuth(wallet2)) {
643
+ if (!isMobile() && isWithFullAuth(wallet2) && !isManualWalletConnect) {
674
644
  const popupUrl = yield para.constructPortalUrl("connectExternalWallet");
675
645
  if (typeof window !== void 0) {
676
646
  refs.popupWindow.current = openPopup({
@@ -682,6 +652,8 @@ function ExternalWalletProvider({ children }) {
682
652
  setupPopupWindowCloseListener();
683
653
  }
684
654
  if (isExternalWalletConnecting && isManualWalletConnect) {
655
+ clearPopupWindowCloseListener();
656
+ yield para.cancelAuthFlow();
685
657
  yield evmDisconnect();
686
658
  yield solanaDisconnect();
687
659
  yield cosmosDisconnect();
@@ -693,27 +665,31 @@ function ExternalWalletProvider({ children }) {
693
665
  setIsExternalWalletConnecting(true);
694
666
  setIsUsingMobileConnector(isMobileConnect);
695
667
  listenForWalletConnectUri();
696
- const { address, error, authState } = yield isMobileConnect ? wallet2.connectMobile(isManualWalletConnect, connectionOnly) : wallet2.connect(connectionOnly);
697
- if (error) {
698
- setExternalWalletError([error]);
699
- setIsUsingMobileConnector();
700
- handlePostConnectError(error);
701
- if (isManualWalletConnect && error === "Connection request rejected") {
702
- setExternalWalletError();
703
- yield connectExternalWallet({ wallet: wallet2, isResetAfterManualWalletConnect: true });
704
- return;
705
- }
706
- setupExternalWalletConnectionRetryListener(wallet2);
707
- } else if (address) {
708
- if (!!authState && (isWithFullAuth(wallet2) || includeWalletVerification)) {
709
- clearExternalWalletConnectionRetryListener(wallet2);
710
- onNewAuthState(authState);
711
- setupExternalWalletVerificationTriggerListener(authState.externalWallet);
712
- } else {
713
- setStep(ModalStep.LOGIN_DONE);
668
+ try {
669
+ const { address, error, authState } = yield isMobileConnect ? wallet2.connectMobile(isManualWalletConnect, connectionOnly) : wallet2.connect(connectionOnly);
670
+ if (error) {
671
+ setExternalWalletError([error]);
672
+ setIsUsingMobileConnector();
673
+ handlePostConnectError(error);
674
+ if (isManualWalletConnect && error === "Connection request rejected") {
675
+ setExternalWalletError();
676
+ yield connectExternalWallet({ wallet: wallet2, isResetAfterManualWalletConnect: true });
677
+ return;
678
+ }
679
+ setupExternalWalletConnectionRetryListener(wallet2);
680
+ } else if (address) {
681
+ if (!!authState && (isWithFullAuth(wallet2) || includeWalletVerification)) {
682
+ clearExternalWalletConnectionRetryListener();
683
+ yield onNewAuthState(authState);
684
+ externalWalletInfo.current = authState.externalWallet || null;
685
+ setupExternalWalletVerificationTriggerListener();
686
+ } else {
687
+ setShowPostAuthFlow(true);
688
+ }
714
689
  }
690
+ } finally {
691
+ setIsExternalWalletConnecting(false);
715
692
  }
716
- setIsExternalWalletConnecting(false);
717
693
  }
718
694
  }),
719
695
  [isExternalWalletConnecting, externalWalletsWithFullAuth, connectionOnly, includeWalletVerification]
@@ -855,7 +831,7 @@ function ExternalWalletProvider({ children }) {
855
831
  console.warn("Failed to connect Para EVM wallet to Wagmi:", error);
856
832
  } else {
857
833
  if (evmWallet) {
858
- setSelectedWallet({ id: evmWallet.id, type: "EVM" });
834
+ yield setSelectedWallet({ id: evmWallet.id, type: "EVM" });
859
835
  }
860
836
  }
861
837
  } catch (err) {
@@ -869,7 +845,7 @@ function ExternalWalletProvider({ children }) {
869
845
  console.warn("Failed to connect Para Cosmos wallet to Graz:", error);
870
846
  } else {
871
847
  if (cosmosWallet) {
872
- setSelectedWallet({ id: cosmosWallet.id, type: "COSMOS" });
848
+ yield setSelectedWallet({ id: cosmosWallet.id, type: "COSMOS" });
873
849
  }
874
850
  }
875
851
  } catch (err) {
@@ -878,16 +854,41 @@ function ExternalWalletProvider({ children }) {
878
854
  }
879
855
  }), [evmConnectParaEmbedded, cosmosConnectParaEmbedded]);
880
856
  useEffect(() => {
881
- onLoginRef.current = () => __async(this, null, function* () {
882
- yield connectEmbeddedToExternalConnectors();
883
- });
884
- }, [connectEmbeddedToExternalConnectors]);
885
- useEffect(() => {
886
- if (isReady && isFarcasterMiniApp && !isConnected && !(farcasterMiniAppConfig == null ? void 0 : farcasterMiniAppConfig.disableAutoConnect) && !refs.wasSignedIn.current && !refs.initialFarcasterConnected.current && !!evmFarcasterStatus && !!solanaFarcasterStatus) {
857
+ if (isReady && isFarcasterMiniApp && !isConnected && !(farcasterMiniAppConfig == null ? void 0 : farcasterMiniAppConfig.disableAutoConnect) && !refs.initialFarcasterConnected.current && !!evmFarcasterStatus && !!solanaFarcasterStatus) {
887
858
  refs.initialFarcasterConnected.current = true;
888
859
  connectFarcasterMiniApp();
889
860
  }
890
861
  }, [isReady, isConnected, isFarcasterMiniApp, farcasterMiniAppConfig, evmFarcasterStatus, solanaFarcasterStatus]);
862
+ useEffect(() => {
863
+ return () => {
864
+ clearVerificationStatusListener();
865
+ clearVerificationTriggerListener();
866
+ clearExternalWalletConnectionRetryListener();
867
+ if (popupCloseIntervalRef.current) {
868
+ clearInterval(popupCloseIntervalRef.current);
869
+ popupCloseIntervalRef.current = null;
870
+ }
871
+ };
872
+ }, []);
873
+ useEffect(() => {
874
+ return () => {
875
+ walletConnectCleanup == null ? void 0 : walletConnectCleanup();
876
+ };
877
+ }, [walletConnectCleanup]);
878
+ useEffect(() => {
879
+ const setupWalletConnection = () => __async(this, null, function* () {
880
+ if (!isConnected) {
881
+ return;
882
+ }
883
+ if (selectedWallet) {
884
+ const wallet2 = para == null ? void 0 : para.findWallet(selectedWallet.id, selectedWallet.type);
885
+ if (wallet2) {
886
+ yield switchConnection({ type: wallet2.type, id: !!wallet2.isExternal ? wallet2.name : "Para" });
887
+ }
888
+ }
889
+ });
890
+ setupWalletConnection();
891
+ }, [isConnected]);
891
892
  return /* @__PURE__ */ jsx(
892
893
  ExternalWalletContext.Provider,
893
894
  {
@@ -910,15 +911,16 @@ function ExternalWalletProvider({ children }) {
910
911
  connectEmbeddedToExternalConnectors,
911
912
  signMessage,
912
913
  isSigningMessage,
913
- verifyWalletSignature,
914
914
  getWalletBalance,
915
915
  requestInfo,
916
916
  disconnectBase,
917
917
  connectFarcasterMiniApp,
918
+ switchConnection,
918
919
  verificationStage,
919
920
  evmDisconnectStatus,
920
921
  solanaDisconnectStatus,
921
- cosmosDisconnectStatus
922
+ cosmosDisconnectStatus,
923
+ retryVerification
922
924
  }),
923
925
  [
924
926
  wallets,
@@ -935,18 +937,18 @@ function ExternalWalletProvider({ children }) {
935
937
  addAdditionalExternalWallet,
936
938
  switchChain,
937
939
  setChainIdSwitchingTo,
938
- connectEmbeddedToExternalConnectors,
939
940
  signMessage,
940
941
  isSigningMessage,
941
- verifyWalletSignature,
942
942
  getWalletBalance,
943
943
  requestInfo,
944
944
  disconnectBase,
945
945
  connectFarcasterMiniApp,
946
+ switchConnection,
946
947
  verificationStage,
947
948
  evmDisconnectStatus,
948
949
  solanaDisconnectStatus,
949
- cosmosDisconnectStatus
950
+ cosmosDisconnectStatus,
951
+ retryVerification
950
952
  ]
951
953
  ),
952
954
  children