@web3auth/modal 10.0.0-beta.0 → 10.0.0-beta.2

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 (257) hide show
  1. package/dist/lib.cjs/node_modules/style-inject/dist/style-inject.es.js +1 -1
  2. package/dist/lib.cjs/packages/modal/src/modalManager.js +195 -140
  3. package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +2 -2
  4. package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +26 -26
  5. package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3Auth.js +2 -2
  6. package/dist/lib.cjs/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +60 -0
  7. package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.js +47 -22
  8. package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.type.js +8 -0
  9. package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +53 -0
  10. package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +68 -0
  11. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +202 -0
  12. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +65 -0
  13. package/dist/lib.cjs/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +29 -30
  14. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +49 -0
  15. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +140 -0
  16. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +93 -0
  17. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.js +55 -0
  18. package/dist/lib.cjs/packages/modal/src/ui/components/Embed/Embed.js +70 -0
  19. package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +53 -0
  20. package/dist/lib.cjs/packages/modal/src/ui/components/Image/Image.js +89 -0
  21. package/dist/lib.cjs/packages/modal/src/ui/components/Loader/Loader.js +151 -0
  22. package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +489 -0
  23. package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +116 -0
  24. package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +117 -0
  25. package/dist/lib.cjs/packages/modal/src/ui/components/LoginHint/LoginHint.js +52 -0
  26. package/dist/lib.cjs/packages/modal/src/ui/components/Modal/Modal.js +87 -0
  27. package/dist/lib.cjs/packages/modal/src/ui/components/Otp/Otp.js +190 -0
  28. package/dist/lib.cjs/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +18 -0
  29. package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +448 -0
  30. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +156 -0
  31. package/dist/lib.cjs/packages/modal/src/ui/components/Toast/Toast.js +70 -0
  32. package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +231 -0
  33. package/dist/lib.cjs/packages/modal/src/ui/config.js +12 -1
  34. package/dist/lib.cjs/packages/modal/src/ui/constants.js +18 -0
  35. package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +20 -0
  36. package/dist/lib.cjs/packages/modal/src/ui/context/ThemeContext.js +2 -2
  37. package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +8 -0
  38. package/dist/lib.cjs/packages/modal/src/ui/handlers/AbstractHandler.js +117 -0
  39. package/dist/lib.cjs/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +54 -0
  40. package/dist/lib.cjs/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +57 -0
  41. package/dist/lib.cjs/packages/modal/src/ui/handlers/factory.js +19 -0
  42. package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +37 -2
  43. package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +37 -2
  44. package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +37 -2
  45. package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +37 -2
  46. package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +37 -2
  47. package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +37 -2
  48. package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +37 -2
  49. package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +37 -2
  50. package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +37 -2
  51. package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +37 -2
  52. package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +7 -10
  53. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +69 -44
  54. package/dist/lib.cjs/packages/modal/src/ui/utils.js +107 -1
  55. package/dist/lib.cjs/types/interface.d.ts +1 -1
  56. package/dist/lib.cjs/types/modalManager.d.ts +5 -1
  57. package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.d.ts +7 -0
  58. package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.type.d.ts +7 -0
  59. package/dist/lib.cjs/types/ui/components/BottomSheet/index.d.ts +2 -0
  60. package/dist/lib.cjs/types/ui/components/Button/Button.d.ts +2 -15
  61. package/dist/lib.cjs/types/ui/components/Button/Button.type.d.ts +12 -0
  62. package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/ButtonSocial.d.ts +3 -0
  63. package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/ButtonSocial.type.d.ts +14 -0
  64. package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/index.d.ts +2 -0
  65. package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/ButtonWallet.d.ts +3 -0
  66. package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/ButtonWallet.type.d.ts +13 -0
  67. package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/index.d.ts +2 -0
  68. package/dist/lib.cjs/types/ui/components/Button/index.d.ts +1 -0
  69. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.d.ts +3 -0
  70. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +24 -0
  71. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.d.ts +3 -0
  72. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.type.d.ts +13 -0
  73. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/index.d.ts +2 -0
  74. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.d.ts +3 -0
  75. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.type.d.ts +10 -0
  76. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/index.d.ts +2 -0
  77. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.d.ts +3 -0
  78. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.type.d.ts +6 -0
  79. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/index.d.ts +2 -0
  80. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.d.ts +3 -0
  81. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.type.d.ts +19 -0
  82. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/index.d.ts +2 -0
  83. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.d.ts +3 -0
  84. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.type.d.ts +9 -0
  85. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/index.d.ts +2 -0
  86. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.d.ts +3 -0
  87. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.type.d.ts +9 -0
  88. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/index.d.ts +2 -0
  89. package/dist/lib.cjs/types/ui/components/ConnectWallet/index.d.ts +2 -0
  90. package/dist/lib.cjs/types/ui/components/Embed/Embed.d.ts +8 -0
  91. package/dist/lib.cjs/types/ui/components/Embed/Embed.type.d.ts +12 -0
  92. package/dist/lib.cjs/types/ui/components/Embed/index.d.ts +2 -0
  93. package/dist/lib.cjs/types/ui/components/Footer/Footer.d.ts +7 -0
  94. package/dist/lib.cjs/types/ui/components/Footer/Footer.type.d.ts +4 -0
  95. package/dist/lib.cjs/types/ui/components/Footer/index.d.ts +2 -0
  96. package/dist/lib.cjs/types/ui/components/Image/Image.d.ts +7 -0
  97. package/dist/lib.cjs/types/ui/components/{Image.d.ts → Image/Image.type.d.ts} +2 -1
  98. package/dist/lib.cjs/types/ui/components/Image/index.d.ts +2 -0
  99. package/dist/lib.cjs/types/ui/components/Loader/Loader.d.ts +8 -0
  100. package/dist/lib.cjs/types/ui/components/Loader/Loader.type.d.ts +12 -0
  101. package/dist/lib.cjs/types/ui/components/Loader/index.d.ts +2 -0
  102. package/dist/lib.cjs/types/ui/components/Login/Login.d.ts +3 -0
  103. package/dist/lib.cjs/types/ui/components/Login/Login.type.d.ts +29 -0
  104. package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.d.ts +8 -0
  105. package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.type.d.ts +10 -0
  106. package/dist/lib.cjs/types/ui/components/Login/LoginOtp/index.d.ts +2 -0
  107. package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/LoginPasswordLess.d.ts +3 -0
  108. package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/LoginPasswordLess.type.d.ts +13 -0
  109. package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/index.d.ts +2 -0
  110. package/dist/lib.cjs/types/ui/components/Login/index.d.ts +2 -0
  111. package/dist/lib.cjs/types/ui/components/LoginHint/LoginHint.d.ts +3 -0
  112. package/dist/lib.cjs/types/ui/components/LoginHint/LoginHint.type.d.ts +6 -0
  113. package/dist/lib.cjs/types/ui/components/LoginHint/index.d.ts +2 -0
  114. package/dist/lib.cjs/types/ui/components/Modal/Modal.d.ts +8 -0
  115. package/dist/lib.cjs/types/ui/components/Modal/Modal.type.d.ts +14 -0
  116. package/dist/lib.cjs/types/ui/components/Modal/index.d.ts +2 -0
  117. package/dist/lib.cjs/types/ui/components/Otp/Otp.d.ts +3 -0
  118. package/dist/lib.cjs/types/ui/components/Otp/Otp.type.d.ts +22 -0
  119. package/dist/lib.cjs/types/ui/components/Otp/index.d.ts +2 -0
  120. package/dist/lib.cjs/types/ui/components/PulseLoader/PulseLoader.d.ts +2 -0
  121. package/dist/lib.cjs/types/ui/components/PulseLoader/index.d.ts +1 -0
  122. package/dist/lib.cjs/types/ui/components/Root/Root.d.ts +3 -0
  123. package/dist/lib.cjs/types/ui/components/Root/Root.type.d.ts +27 -0
  124. package/dist/lib.cjs/types/ui/components/Root/index.d.ts +2 -0
  125. package/dist/lib.cjs/types/ui/components/SocialLoginList/SocialLoginList.d.ts +3 -0
  126. package/dist/lib.cjs/types/ui/components/SocialLoginList/SocialLoginList.type.d.ts +11 -0
  127. package/dist/lib.cjs/types/ui/components/SocialLoginList/index.d.ts +2 -0
  128. package/dist/lib.cjs/types/ui/components/Toast/Toast.d.ts +2 -0
  129. package/dist/lib.cjs/types/ui/components/Toast/index.d.ts +1 -0
  130. package/dist/lib.cjs/types/ui/components/Widget/Widget.d.ts +3 -0
  131. package/dist/lib.cjs/types/ui/components/{Modal.d.ts → Widget/Widget.type.d.ts} +4 -5
  132. package/dist/lib.cjs/types/ui/components/Widget/index.d.ts +1 -0
  133. package/dist/lib.cjs/types/ui/config.d.ts +4 -1
  134. package/dist/lib.cjs/types/ui/constants.d.ts +13 -0
  135. package/dist/lib.cjs/types/ui/context/RootContext.d.ts +18 -0
  136. package/dist/lib.cjs/types/ui/handlers/AbstractHandler.d.ts +20 -0
  137. package/dist/lib.cjs/types/ui/handlers/EmailPasswordlessHandler.d.ts +8 -0
  138. package/dist/lib.cjs/types/ui/handlers/SmsPasswordlessHandler.d.ts +9 -0
  139. package/dist/lib.cjs/types/ui/handlers/factory.d.ts +5 -0
  140. package/dist/lib.cjs/types/ui/interfaces.d.ts +115 -14
  141. package/dist/lib.cjs/types/ui/loginModal.d.ts +9 -7
  142. package/dist/lib.cjs/types/ui/utils.d.ts +17 -2
  143. package/dist/lib.esm/node_modules/style-inject/dist/style-inject.es.js +1 -1
  144. package/dist/lib.esm/packages/modal/src/modalManager.js +203 -145
  145. package/dist/lib.esm/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +58 -0
  146. package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.js +48 -24
  147. package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.type.js +6 -0
  148. package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +51 -0
  149. package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +66 -0
  150. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +200 -0
  151. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +63 -0
  152. package/dist/lib.esm/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +29 -31
  153. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +47 -0
  154. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +138 -0
  155. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +91 -0
  156. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.js +56 -0
  157. package/dist/lib.esm/packages/modal/src/ui/components/Embed/Embed.js +68 -0
  158. package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +51 -0
  159. package/dist/lib.esm/packages/modal/src/ui/components/Image/Image.js +87 -0
  160. package/dist/lib.esm/packages/modal/src/ui/components/Loader/Loader.js +152 -0
  161. package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +489 -0
  162. package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +115 -0
  163. package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +115 -0
  164. package/dist/lib.esm/packages/modal/src/ui/components/LoginHint/LoginHint.js +50 -0
  165. package/dist/lib.esm/packages/modal/src/ui/components/Modal/Modal.js +85 -0
  166. package/dist/lib.esm/packages/modal/src/ui/components/Otp/Otp.js +188 -0
  167. package/dist/lib.esm/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +16 -0
  168. package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +458 -0
  169. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +154 -0
  170. package/dist/lib.esm/packages/modal/src/ui/components/Toast/Toast.js +68 -0
  171. package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +233 -0
  172. package/dist/lib.esm/packages/modal/src/ui/config.js +10 -3
  173. package/dist/lib.esm/packages/modal/src/ui/constants.js +13 -0
  174. package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +18 -0
  175. package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +6 -0
  176. package/dist/lib.esm/packages/modal/src/ui/handlers/AbstractHandler.js +115 -0
  177. package/dist/lib.esm/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +52 -0
  178. package/dist/lib.esm/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +55 -0
  179. package/dist/lib.esm/packages/modal/src/ui/handlers/factory.js +17 -0
  180. package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +37 -3
  181. package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +37 -3
  182. package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +37 -3
  183. package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +37 -3
  184. package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +37 -3
  185. package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +37 -3
  186. package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +37 -3
  187. package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +37 -3
  188. package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +37 -3
  189. package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +37 -3
  190. package/dist/lib.esm/packages/modal/src/ui/interfaces.js +8 -9
  191. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +70 -45
  192. package/dist/lib.esm/packages/modal/src/ui/utils.js +105 -3
  193. package/dist/modal.umd.min.js +1 -1
  194. package/dist/modal.umd.min.js.LICENSE.txt +8 -8
  195. package/package.json +16 -11
  196. package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -7
  197. package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -7
  198. package/dist/lib.cjs/packages/modal/src/ui/assets/x-dark.svg.js +0 -7
  199. package/dist/lib.cjs/packages/modal/src/ui/assets/x-light.svg.js +0 -7
  200. package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +0 -108
  201. package/dist/lib.cjs/packages/modal/src/ui/components/Button/styles.css.js +0 -8
  202. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -44
  203. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -67
  204. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -43
  205. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -46
  206. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -167
  207. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +0 -279
  208. package/dist/lib.cjs/packages/modal/src/ui/components/Footer.js +0 -20
  209. package/dist/lib.cjs/packages/modal/src/ui/components/Header.js +0 -81
  210. package/dist/lib.cjs/packages/modal/src/ui/components/Icon.js +0 -73
  211. package/dist/lib.cjs/packages/modal/src/ui/components/Image.js +0 -51
  212. package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +0 -59
  213. package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +0 -278
  214. package/dist/lib.cjs/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -30
  215. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -150
  216. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +0 -153
  217. package/dist/lib.cjs/packages/modal/src/ui/components/WalletConnect.js +0 -84
  218. package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +0 -8
  219. package/dist/lib.cjs/types/ui/components/AdapterLoader.d.ts +0 -11
  220. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletButton.d.ts +0 -7
  221. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletChainNamespace.d.ts +0 -9
  222. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletConnect.d.ts +0 -9
  223. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletDetails.d.ts +0 -10
  224. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletHeader.d.ts +0 -8
  225. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletInstall.d.ts +0 -8
  226. package/dist/lib.cjs/types/ui/components/ExternalWallets.d.ts +0 -15
  227. package/dist/lib.cjs/types/ui/components/Footer.d.ts +0 -1
  228. package/dist/lib.cjs/types/ui/components/Header.d.ts +0 -8
  229. package/dist/lib.cjs/types/ui/components/Icon.d.ts +0 -9
  230. package/dist/lib.cjs/types/ui/components/Loader.d.ts +0 -10
  231. package/dist/lib.cjs/types/ui/components/SelfCustodyViaWeb3Auth.d.ts +0 -1
  232. package/dist/lib.cjs/types/ui/components/SocialLoginPasswordless.d.ts +0 -14
  233. package/dist/lib.cjs/types/ui/components/SocialLogins.d.ts +0 -10
  234. package/dist/lib.cjs/types/ui/components/WalletConnect.d.ts +0 -8
  235. package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -5
  236. package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -5
  237. package/dist/lib.esm/packages/modal/src/ui/assets/x-dark.svg.js +0 -5
  238. package/dist/lib.esm/packages/modal/src/ui/assets/x-light.svg.js +0 -5
  239. package/dist/lib.esm/packages/modal/src/ui/components/AdapterLoader.js +0 -106
  240. package/dist/lib.esm/packages/modal/src/ui/components/Button/styles.css.js +0 -6
  241. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -42
  242. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -65
  243. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -44
  244. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -44
  245. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -165
  246. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +0 -281
  247. package/dist/lib.esm/packages/modal/src/ui/components/Footer.js +0 -18
  248. package/dist/lib.esm/packages/modal/src/ui/components/Header.js +0 -79
  249. package/dist/lib.esm/packages/modal/src/ui/components/Icon.js +0 -71
  250. package/dist/lib.esm/packages/modal/src/ui/components/Image.js +0 -49
  251. package/dist/lib.esm/packages/modal/src/ui/components/Loader.js +0 -57
  252. package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +0 -277
  253. package/dist/lib.esm/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -28
  254. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -148
  255. package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +0 -152
  256. package/dist/lib.esm/packages/modal/src/ui/components/WalletConnect.js +0 -82
  257. package/dist/lib.esm/packages/modal/src/ui/css/web3auth.css.js +0 -6
@@ -3,7 +3,7 @@
3
3
  function styleInject(css, ref) {
4
4
  if (ref === void 0) ref = {};
5
5
  var insertAt = ref.insertAt;
6
- if (!css || typeof document === 'undefined') {
6
+ if (typeof document === 'undefined') {
7
7
  return;
8
8
  }
9
9
  var head = document.head || document.getElementsByTagName('head')[0];
@@ -16,13 +16,63 @@ class Web3Auth extends noModal.Web3AuthNoModal {
16
16
  _defineProperty(this, "loginModal", void 0);
17
17
  _defineProperty(this, "options", void 0);
18
18
  _defineProperty(this, "modalConfig", noModal.cloneDeep(config.defaultConnectorsModalConfig));
19
+ _defineProperty(this, "onInitExternalWallets", async params => {
20
+ if (params.externalWalletsInitialized) return;
21
+ // initialize WC connector only as other external wallets are initialized in initModal
22
+ await this.initExternalConnectors(this.connectors.filter(x => x.name === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2), {
23
+ externalWalletsInitialized: true,
24
+ externalWalletsVisibility: true
25
+ });
26
+ });
27
+ _defineProperty(this, "onSocialLogin", async params => {
28
+ try {
29
+ await this.connectTo(params.connector, params.loginParams);
30
+ } catch (error) {
31
+ noModal.log.error(`Error while connecting to connector: ${params.connector}`, error);
32
+ }
33
+ });
34
+ _defineProperty(this, "onExternalWalletLogin", async params => {
35
+ try {
36
+ await this.connectTo(params.connector, params.loginParams);
37
+ } catch (error) {
38
+ noModal.log.error(`Error while connecting to connector: ${params.connector}`, error);
39
+ }
40
+ });
41
+ _defineProperty(this, "onModalVisibility", async visibility => {
42
+ noModal.log.debug("is login modal visible", visibility);
43
+ this.emit(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
44
+ const wcConnector = this.getConnector(noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2);
45
+ if (wcConnector) {
46
+ const walletConnectStatus = wcConnector === null || wcConnector === void 0 ? void 0 : wcConnector.status;
47
+ noModal.log.debug("trying refreshing wc session", visibility, walletConnectStatus);
48
+ if (visibility && (walletConnectStatus === noModal.CONNECTOR_STATUS.READY || walletConnectStatus === noModal.CONNECTOR_STATUS.CONNECTING)) {
49
+ noModal.log.debug("refreshing wc session");
50
+ // refreshing session for wallet connect whenever modal is opened.
51
+ try {
52
+ const initialChain = this.getInitialChainIdForConnector(wcConnector);
53
+ wcConnector.connect({
54
+ chainId: initialChain.chainId
55
+ });
56
+ } catch (error) {
57
+ noModal.log.error(`Error while disconnecting to wallet connect in core`, error);
58
+ }
59
+ }
60
+ if (!visibility && this.status === noModal.CONNECTOR_STATUS.CONNECTED && (walletConnectStatus === noModal.CONNECTOR_STATUS.READY || walletConnectStatus === noModal.CONNECTOR_STATUS.CONNECTING)) {
61
+ noModal.log.debug("this stops wc connector from trying to reconnect once proposal expires");
62
+ wcConnector.status = noModal.CONNECTOR_STATUS.READY;
63
+ }
64
+ }
65
+ });
66
+ _defineProperty(this, "getChainNamespaces", () => {
67
+ var _this$coreOptions$cha;
68
+ return [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])];
69
+ });
19
70
  this.options = _objectSpread({}, options);
20
71
  if (!this.options.uiConfig) this.options.uiConfig = {};
21
72
  if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
22
73
  noModal.log.info("modalConfig", this.modalConfig);
23
74
  }
24
75
  async initModal() {
25
- var _this$coreOptions$cha;
26
76
  super.checkInitRequirements();
27
77
  // get project config and wallet registry
28
78
  const {
@@ -32,6 +82,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
32
82
  this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
33
83
  if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
34
84
  if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
85
+ this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig || {});
35
86
  // init config
36
87
  super.initAccountAbstractionConfig(projectConfig);
37
88
  super.initChainsConfig(projectConfig);
@@ -43,10 +94,16 @@ class Web3Auth extends noModal.Web3AuthNoModal {
43
94
  } = this.filterWalletRegistry(walletRegistry, projectConfig);
44
95
  this.loginModal = new loginModal.LoginModal(_objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
45
96
  connectorListener: this,
46
- chainNamespaces: [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])],
97
+ web3authClientId: this.options.clientId,
98
+ web3authNetwork: this.options.web3AuthNetwork,
99
+ chainNamespaces: this.getChainNamespaces(),
47
100
  walletRegistry: filteredWalletRegistry
48
- }));
49
- this.subscribeToLoginModalEvents();
101
+ }), {
102
+ onInitExternalWallets: this.onInitExternalWallets,
103
+ onSocialLogin: this.onSocialLogin,
104
+ onExternalWalletLogin: this.onExternalWalletLogin,
105
+ onModalVisibility: this.onModalVisibility
106
+ });
50
107
  await this.loginModal.initModal();
51
108
  // setup common JRPC provider
52
109
  await this.setupCommonJRPCProvider();
@@ -70,18 +127,29 @@ class Web3Auth extends noModal.Web3AuthNoModal {
70
127
  if (this.connectedConnectorName && this.status === noModal.CONNECTOR_STATUS.CONNECTED && this.provider) return this.provider;
71
128
  this.loginModal.open();
72
129
  return new Promise((resolve, reject) => {
73
- this.once(noModal.CONNECTOR_EVENTS.CONNECTED, () => {
130
+ // remove all listeners when promise is resolved or rejected.
131
+ // this is to prevent memory leaks if user clicks connect button multiple times.
132
+ const handleConnected = () => {
133
+ this.removeListener(noModal.CONNECTOR_EVENTS.ERRORED, handleError);
134
+ this.removeListener(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
74
135
  return resolve(this.provider);
75
- });
76
- this.once(noModal.CONNECTOR_EVENTS.ERRORED, err => {
136
+ };
137
+ const handleError = err => {
138
+ this.removeListener(noModal.CONNECTOR_EVENTS.CONNECTED, handleConnected);
139
+ this.removeListener(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
77
140
  return reject(err);
78
- });
79
- this.once(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility => {
141
+ };
142
+ const handleVisibility = visibility => {
80
143
  // modal is closed but user is not connected to any wallet.
81
144
  if (!visibility && this.status !== noModal.CONNECTOR_STATUS.CONNECTED) {
145
+ this.removeListener(noModal.CONNECTOR_EVENTS.CONNECTED, handleConnected);
146
+ this.removeListener(noModal.CONNECTOR_EVENTS.ERRORED, handleError);
82
147
  return reject(new Error("User closed the modal"));
83
148
  }
84
- });
149
+ };
150
+ this.once(noModal.CONNECTOR_EVENTS.CONNECTED, handleConnected);
151
+ this.once(noModal.CONNECTOR_EVENTS.ERRORED, handleError);
152
+ this.once(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
85
153
  });
86
154
  }
87
155
  filterWalletRegistry(walletRegistry, projectConfig) {
@@ -98,6 +166,8 @@ class Web3Auth extends noModal.Web3AuthNoModal {
98
166
  if (disableAllOtherWallets) {
99
167
  Object.keys(walletRegistry.others).forEach(wallet => disabledExternalWallets.add(wallet));
100
168
  }
169
+ // always show MetaMask, force enable it
170
+ disabledExternalWallets.delete(noModal.WALLET_CONNECTORS.METAMASK);
101
171
  // remove wallets that are disabled in project config from wallet registry
102
172
  const filteredWalletRegistry = noModal.cloneDeep(walletRegistry);
103
173
  disabledExternalWallets.forEach(wallet => {
@@ -115,7 +185,12 @@ class Web3Auth extends noModal.Web3AuthNoModal {
115
185
  let projectConfig;
116
186
  try {
117
187
  var _this$options$account;
118
- projectConfig = await noModal.fetchProjectConfig(this.options.clientId, this.options.web3AuthNetwork, (_this$options$account = this.options.accountAbstractionConfig) === null || _this$options$account === void 0 ? void 0 : _this$options$account.smartAccountType);
188
+ projectConfig = await noModal.fetchProjectConfig({
189
+ clientId: this.options.clientId,
190
+ web3AuthNetwork: this.options.web3AuthNetwork,
191
+ aaProvider: (_this$options$account = this.options.accountAbstractionConfig) === null || _this$options$account === void 0 ? void 0 : _this$options$account.smartAccountType,
192
+ authBuildEnv: this.options.authBuildEnv
193
+ });
119
194
  } catch (e) {
120
195
  noModal.log.error("Failed to fetch project configurations", e);
121
196
  throw noModal.WalletInitializationError.notReady("failed to fetch project configurations", e);
@@ -153,15 +228,28 @@ class Web3Auth extends noModal.Web3AuthNoModal {
153
228
  hasInAppConnectors,
154
229
  hasExternalConnectors
155
230
  } = await this.checkConnectorAvailability(filteredConnectorNames);
231
+ const filteredConnectors = connectors.filter(x => filteredConnectorNames.includes(x.name));
156
232
  if (hasInAppConnectors) {
157
- await this.initInAppAndCachedConnectors(connectors, filteredConnectorNames);
158
- // show connect button if external wallets are available
159
- if (hasExternalConnectors) this.loginModal.initExternalWalletContainer();
160
- } else if (hasExternalConnectors) {
161
- // if no in app wallet is available then initialize external wallets in modal
162
- await this.initExternalConnectors(connectors, false, {
163
- showExternalWalletsOnly: true
164
- });
233
+ await this.initInAppAndCachedConnectors(filteredConnectors);
234
+ }
235
+ if (hasExternalConnectors) {
236
+ if (hasInAppConnectors) {
237
+ // show connect button if both in-app and external wallets are available
238
+ this.loginModal.initExternalWalletContainer();
239
+ // initialize installed external wallets (except WC), don't mark external wallets as fully initialized
240
+ this.initExternalConnectors(filteredConnectors.filter(x => x.type === noModal.CONNECTOR_CATEGORY.EXTERNAL && x.name !== noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2), {
241
+ externalWalletsInitialized: false,
242
+ showExternalWalletsOnly: false,
243
+ externalWalletsVisibility: false
244
+ });
245
+ } else {
246
+ // if no in app wallet is available then initialize all external wallets in modal
247
+ await this.initExternalConnectors(filteredConnectors.filter(x => x.type === noModal.CONNECTOR_CATEGORY.EXTERNAL), {
248
+ externalWalletsInitialized: true,
249
+ showExternalWalletsOnly: true,
250
+ externalWalletsVisibility: true
251
+ });
252
+ }
165
253
  }
166
254
  // emit ready event if connector is ready
167
255
  if (this.status === noModal.CONNECTOR_STATUS.NOT_READY) {
@@ -173,25 +261,31 @@ class Web3Auth extends noModal.Web3AuthNoModal {
173
261
  projectConfig,
174
262
  disabledExternalWallets
175
263
  }) {
176
- var _this$modalConfig2, _this$modalConfig3, _projectConfig$loginM, _projectConfig$loginM2;
177
- // Auth connector config: merge code config with config from dashboard
264
+ var _this$modalConfig2;
265
+ // Auth connector config: populate this with the default config for auth connectors.
178
266
  const loginMethods = {};
267
+ const embedWalletConfigMap = new Map();
179
268
  for (const authConnectionConfig of projectConfig.embeddedWalletAuth || []) {
180
269
  const {
181
270
  isDefault,
182
- authConnectionId,
271
+ authConnection,
183
272
  groupedAuthConnectionId,
184
- authConnection
273
+ authConnectionId
185
274
  } = authConnectionConfig;
186
- // for custom auth connections, authConnectionId or groupedAuthConnectionId are required.
187
- if (!isDefault && (!authConnectionId || !groupedAuthConnectionId)) return;
188
- loginMethods[authConnection] = _objectSpread(_objectSpread({
189
- name: authConnection
190
- }, authConnectionConfig), {}, {
191
- showOnModal: true,
192
- showOnDesktop: true,
193
- showOnMobile: true
194
- });
275
+ if (isDefault) {
276
+ loginMethods[authConnection] = {
277
+ name: config$1.AUTH_PROVIDERS_NAMES[authConnection],
278
+ authConnection: authConnection,
279
+ authConnectionId: authConnectionId,
280
+ groupedAuthConnectionId: groupedAuthConnectionId,
281
+ extraLoginOptions: authConnectionConfig.jwtParameters,
282
+ isDefault: true,
283
+ showOnModal: true,
284
+ showOnDesktop: true,
285
+ showOnMobile: true
286
+ };
287
+ }
288
+ embedWalletConfigMap.set(groupedAuthConnectionId || authConnectionId, authConnectionConfig);
195
289
  }
196
290
  const dashboardConnectorConfig = {
197
291
  [noModal.WALLET_CONNECTORS.AUTH]: {
@@ -199,26 +293,38 @@ class Web3Auth extends noModal.Web3AuthNoModal {
199
293
  loginMethods
200
294
  }
201
295
  };
296
+ // populate the user config data with the dashboard config.
202
297
  if ((_this$modalConfig2 = this.modalConfig) !== null && _this$modalConfig2 !== void 0 && (_this$modalConfig2 = _this$modalConfig2.connectors) !== null && _this$modalConfig2 !== void 0 && _this$modalConfig2[noModal.WALLET_CONNECTORS.AUTH]) {
203
298
  if (!this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods) this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods = {};
204
299
  }
300
+ const authProviders = new Set(config$1.AUTH_PROVIDERS);
301
+ Object.keys(this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods).forEach(key => {
302
+ const userConfig = this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods[key];
303
+ const {
304
+ authConnectionId,
305
+ groupedAuthConnectionId
306
+ } = userConfig;
307
+ if (!authProviders.has(key)) {
308
+ throw noModal.WalletInitializationError.invalidParams(`Invalid auth connection: ${key}`);
309
+ }
310
+ // only throw error if one of them is defined in the config.
311
+ if (groupedAuthConnectionId || authConnectionId) {
312
+ if (!embedWalletConfigMap.has(groupedAuthConnectionId || authConnectionId)) throw noModal.WalletInitializationError.invalidParams(`Invalid auth connection config, authConnection: ${key}. Missing AuthConnectionConfig from the dashboard.`);
313
+ const configFromDashboard = embedWalletConfigMap.get(groupedAuthConnectionId || authConnectionId);
314
+ this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods[key] = {
315
+ authConnection: configFromDashboard.authConnection,
316
+ authConnectionId: configFromDashboard.authConnectionId,
317
+ groupedAuthConnectionId: configFromDashboard.groupedAuthConnectionId,
318
+ isDefault: configFromDashboard.isDefault || false,
319
+ extraLoginOptions: _objectSpread(_objectSpread({}, configFromDashboard.jwtParameters), userConfig.extraLoginOptions)
320
+ };
321
+ }
322
+ });
205
323
  this.modalConfig.connectors = deepmerge(dashboardConnectorConfig, noModal.cloneDeep(this.modalConfig.connectors || {}));
206
- // TODO: validate modal connector config here.!!
207
- if ((_this$modalConfig3 = this.modalConfig) !== null && _this$modalConfig3 !== void 0 && (_this$modalConfig3 = _this$modalConfig3.connectors) !== null && _this$modalConfig3 !== void 0 && (_this$modalConfig3 = _this$modalConfig3[noModal.WALLET_CONNECTORS.AUTH]) !== null && _this$modalConfig3 !== void 0 && _this$modalConfig3.loginMethods) {
208
- const authProviders = new Set(config$1.AUTH_PROVIDERS);
209
- Object.keys(this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods).forEach(key => {
210
- if (!authProviders.has(key)) {
211
- throw noModal.WalletInitializationError.invalidParams(`Invalid auth connection: ${key}`);
212
- }
213
- });
214
- }
215
- // external wallets config
216
- const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
217
- const isInstalledWalletWalletDisplayed = Boolean((_projectConfig$loginM = (_projectConfig$loginM2 = projectConfig.loginModal) === null || _projectConfig$loginM2 === void 0 ? void 0 : _projectConfig$loginM2.displayInstalledExternalWallets) !== null && _projectConfig$loginM !== void 0 ? _projectConfig$loginM : true);
218
324
  // merge default connectors with the custom configured connectors.
219
325
  const allConnectorNames = [...new Set([...Object.keys(this.modalConfig.connectors || {}), ...this.connectors.map(connector => connector.name)])];
220
326
  const connectorNames = allConnectorNames.map(connectorName => {
221
- var _this$modalConfig4, _this$modalConfig$con, _this$modalConfig$con2;
327
+ var _this$modalConfig3, _this$modalConfig$con, _this$modalConfig$con2;
222
328
  // start with the default config of connector.
223
329
  const defaultConnectorConfig = {
224
330
  label: noModal.CONNECTOR_NAMES[connectorName] || connectorName.split("-").map(config$1.capitalizeFirstLetter).join(" "),
@@ -226,7 +332,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
226
332
  showOnMobile: true,
227
333
  showOnDesktop: true
228
334
  };
229
- this.modalConfig.connectors[connectorName] = _objectSpread(_objectSpread({}, defaultConnectorConfig), ((_this$modalConfig4 = this.modalConfig) === null || _this$modalConfig4 === void 0 || (_this$modalConfig4 = _this$modalConfig4.connectors) === null || _this$modalConfig4 === void 0 ? void 0 : _this$modalConfig4[connectorName]) || {});
335
+ this.modalConfig.connectors[connectorName] = _objectSpread(_objectSpread({}, defaultConnectorConfig), ((_this$modalConfig3 = this.modalConfig) === null || _this$modalConfig3 === void 0 || (_this$modalConfig3 = _this$modalConfig3.connectors) === null || _this$modalConfig3 === void 0 ? void 0 : _this$modalConfig3[connectorName]) || {});
230
336
  // check if connector is configured/added by user and exist in connectors map.
231
337
  const connector = this.getConnector(connectorName);
232
338
  noModal.log.debug("connector config", connectorName, (_this$modalConfig$con = this.modalConfig.connectors) === null || _this$modalConfig$con === void 0 || (_this$modalConfig$con = _this$modalConfig$con[connectorName]) === null || _this$modalConfig$con === void 0 ? void 0 : _this$modalConfig$con.showOnModal, connector);
@@ -238,17 +344,17 @@ class Web3Auth extends noModal.Web3AuthNoModal {
238
344
  }
239
345
  // skip connector if it is hidden by user
240
346
  if (!connectorConfig.showOnModal) return;
241
- // skip external connector if external wallets are disabled or it is disabled or displayInstalledExternalWallets is false
242
- if (connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL) {
347
+ // skip external connector if external wallets are disabled except for MetaMask
348
+ const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
349
+ if (connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL && connector.name !== noModal.WALLET_CONNECTORS.METAMASK) {
243
350
  if (!isExternalWalletEnabled) return;
244
351
  if (disabledExternalWallets.has(connectorName)) return;
245
- if (!isInstalledWalletWalletDisplayed) return;
246
352
  }
247
353
  // skip WC connector if external wallets are disabled or hideWalletDiscovery is true
248
354
  if (connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2) {
249
- var _this$modalConfig5;
355
+ var _this$modalConfig4;
250
356
  if (!isExternalWalletEnabled) return;
251
- if ((_this$modalConfig5 = this.modalConfig) !== null && _this$modalConfig5 !== void 0 && _this$modalConfig5.hideWalletDiscovery) return;
357
+ if ((_this$modalConfig4 = this.modalConfig) !== null && _this$modalConfig4 !== void 0 && _this$modalConfig4.hideWalletDiscovery) return;
252
358
  }
253
359
  this.modalConfig.connectors[connectorName] = connectorConfig;
254
360
  return connectorName;
@@ -279,10 +385,9 @@ class Web3Auth extends noModal.Web3AuthNoModal {
279
385
  hasExternalConnectors
280
386
  };
281
387
  }
282
- async initInAppAndCachedConnectors(connectors, connectorNames) {
283
- await Promise.all(connectorNames.map(async connectorName => {
284
- const connector = connectors.find(x => x.name === connectorName);
285
- if (!connector) return;
388
+ async initInAppAndCachedConnectors(connectors) {
389
+ await Promise.all(connectors.map(async connector => {
390
+ const connectorName = connector.name;
286
391
  try {
287
392
  // skip if connector is already initialized
288
393
  if (connector.status !== noModal.CONNECTOR_STATUS.NOT_READY) return;
@@ -313,97 +418,47 @@ class Web3Auth extends noModal.Web3AuthNoModal {
313
418
  }
314
419
  }));
315
420
  }
316
- async initExternalConnectors(connectors, externalWalletsInitialized, options) {
317
- if (externalWalletsInitialized) return;
421
+ async initExternalConnectors(externalConnectors, options) {
318
422
  const connectorsConfig = {};
423
+ const connectorChainNamespaceMap = {};
319
424
  // we do it like this because we don't want one slow connector to delay the load of the entire external wallet section.
320
- connectors.forEach(async connector => {
425
+ externalConnectors.forEach(async connector => {
321
426
  const connectorName = connector.name;
322
- if ((connector === null || connector === void 0 ? void 0 : connector.type) === noModal.CONNECTOR_CATEGORY.EXTERNAL) {
323
- noModal.log.debug("init external wallet", this.cachedConnector, connectorName, connector.status);
324
- this.subscribeToConnectorEvents(connector);
325
- // we are not initializing cached connector here as it is already being initialized in initModal before.
326
- if (this.cachedConnector === connectorName) {
327
- return;
328
- }
329
- if (connector.status === noModal.CONNECTOR_STATUS.NOT_READY) {
330
- try {
331
- const initialChain = this.getInitialChainIdForConnector(connector);
332
- await connector.init({
333
- autoConnect: this.cachedConnector === connectorName,
334
- chainId: initialChain.chainId
335
- });
336
- const connectorModalConfig = this.modalConfig.connectors[connectorName];
337
- connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
338
- isInjected: connector.isInjected
339
- });
340
- this.loginModal.addWalletLogins(connectorsConfig, {
341
- showExternalWalletsOnly: !!(options !== null && options !== void 0 && options.showExternalWalletsOnly)
342
- });
343
- } catch (error) {
344
- noModal.log.error(error, "error while initializing connector", connectorName);
345
- }
346
- } else if (connector.status === noModal.CONNECTOR_STATUS.READY || connector.status === noModal.CONNECTOR_STATUS.CONNECTING) {
347
- // we use connecting status for wallet connect
348
- const connectorModalConfig = this.modalConfig.connectors[connectorName];
349
- connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
350
- isInjected: connector.isInjected
351
- });
352
- this.loginModal.addWalletLogins(connectorsConfig, {
353
- showExternalWalletsOnly: !!(options !== null && options !== void 0 && options.showExternalWalletsOnly)
427
+ noModal.log.debug("init external wallet", this.cachedConnector, connectorName, connector.status);
428
+ // a wallet can support multiple chain namespaces e.g. Phantom has EvmInjected connector and WalletStandard connector.
429
+ if (!connectorChainNamespaceMap[connectorName]) connectorChainNamespaceMap[connectorName] = new Set();
430
+ if (connector.connectorNamespace === noModal.CONNECTOR_NAMESPACES.MULTICHAIN) {
431
+ this.getChainNamespaces().forEach(x => connectorChainNamespaceMap[connectorName].add(x));
432
+ } else {
433
+ connectorChainNamespaceMap[connectorName].add(connector.connectorNamespace);
434
+ }
435
+ // initialize connectors
436
+ // skip initializing cached connector here as it is already being initialized in initModal before.
437
+ if (connector.status === noModal.CONNECTOR_STATUS.NOT_READY && this.cachedConnector !== connectorName) {
438
+ try {
439
+ this.subscribeToConnectorEvents(connector);
440
+ const initialChain = this.getInitialChainIdForConnector(connector);
441
+ await connector.init({
442
+ autoConnect: this.cachedConnector === connectorName,
443
+ chainId: initialChain.chainId
354
444
  });
445
+ } catch (error) {
446
+ noModal.log.error(error, "error while initializing connector", connectorName);
355
447
  }
356
448
  }
357
- });
358
- }
359
- subscribeToLoginModalEvents() {
360
- this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.EXTERNAL_WALLET_LOGIN, async params => {
361
- try {
362
- await this.connectTo(params.connector);
363
- } catch (error) {
364
- noModal.log.error(`Error while connecting to connector: ${params.connector}`, error);
365
- }
366
- });
367
- this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.SOCIAL_LOGIN, async params => {
368
- try {
369
- await this.connectTo(params.connector, params.loginParams);
370
- } catch (error) {
371
- noModal.log.error(`Error while connecting to connector: ${params.connector}`, error);
372
- }
373
- });
374
- this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.INIT_EXTERNAL_WALLETS, async params => {
375
- await this.initExternalConnectors(this.connectors, params.externalWalletsInitialized);
376
- });
377
- this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.DISCONNECT, async () => {
378
- try {
379
- await this.logout();
380
- } catch (error) {
381
- noModal.log.error(`Error while disconnecting`, error);
382
- }
383
- });
384
- this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, async visibility => {
385
- noModal.log.debug("is login modal visible", visibility);
386
- this.emit(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
387
- const wcConnector = this.getConnector(noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2);
388
- if (wcConnector) {
389
- const walletConnectStatus = wcConnector === null || wcConnector === void 0 ? void 0 : wcConnector.status;
390
- noModal.log.debug("trying refreshing wc session", visibility, walletConnectStatus);
391
- if (visibility && (walletConnectStatus === noModal.CONNECTOR_STATUS.READY || walletConnectStatus === noModal.CONNECTOR_STATUS.CONNECTING)) {
392
- noModal.log.debug("refreshing wc session");
393
- // refreshing session for wallet connect whenever modal is opened.
394
- try {
395
- const initialChain = this.getInitialChainIdForConnector(wcConnector);
396
- wcConnector.connect({
397
- chainId: initialChain.chainId
398
- });
399
- } catch (error) {
400
- noModal.log.error(`Error while disconnecting to wallet connect in core`, error);
401
- }
402
- }
403
- if (!visibility && this.status === noModal.CONNECTOR_STATUS.CONNECTED && (walletConnectStatus === noModal.CONNECTOR_STATUS.READY || walletConnectStatus === noModal.CONNECTOR_STATUS.CONNECTING)) {
404
- noModal.log.debug("this stops wc connector from trying to reconnect once proposal expires");
405
- wcConnector.status = noModal.CONNECTOR_STATUS.READY;
406
- }
449
+ // update connector config
450
+ if ([noModal.CONNECTOR_STATUS.NOT_READY, noModal.CONNECTOR_STATUS.READY, noModal.CONNECTOR_STATUS.CONNECTING].includes(connector.status)) {
451
+ const connectorModalConfig = this.modalConfig.connectors[connectorName];
452
+ connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
453
+ isInjected: connector.isInjected,
454
+ icon: connector.icon,
455
+ chainNamespaces: Array.from(connectorChainNamespaceMap[connectorName])
456
+ });
457
+ this.loginModal.addWalletLogins(connectorsConfig, {
458
+ showExternalWalletsOnly: !!options.showExternalWalletsOnly,
459
+ externalWalletsVisibility: !!options.externalWalletsVisibility,
460
+ externalWalletsInitialized: !!options.externalWalletsInitialized
461
+ });
407
462
  }
408
463
  });
409
464
  }
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
3
+ var react = require('react');
4
4
  var Web3AuthInnerContext = require('./context/Web3AuthInnerContext.js');
5
5
 
6
6
  function Web3AuthProvider({
7
7
  config,
8
8
  children
9
9
  }) {
10
- return /*#__PURE__*/React.createElement(Web3AuthInnerContext.Web3AuthInnerProvider, {
10
+ return /*#__PURE__*/react.createElement(Web3AuthInnerContext.Web3AuthInnerProvider, {
11
11
  config
12
12
  }, children);
13
13
  }
@@ -1,31 +1,31 @@
1
1
  'use strict';
2
2
 
3
3
  var noModal = require('@web3auth/no-modal');
4
- var React = require('react');
4
+ var react = require('react');
5
5
  var modalManager = require('../../modalManager.js');
6
6
 
7
- const Web3AuthInnerContext = /*#__PURE__*/React.createContext(null);
7
+ const Web3AuthInnerContext = /*#__PURE__*/react.createContext(null);
8
8
  function Web3AuthInnerProvider(params) {
9
9
  const {
10
10
  children,
11
11
  config
12
12
  } = params;
13
- const [web3Auth, setWeb3Auth] = React.useState(null);
14
- const [isConnecting, setIsConnecting] = React.useState(false);
15
- const [isInitializing, setIsInitializing] = React.useState(false);
16
- const [initError, setInitError] = React.useState(null);
17
- const [connectError, setConnectError] = React.useState(null);
18
- const [isConnected, setIsConnected] = React.useState(false);
19
- const [provider, setProvider] = React.useState(null);
20
- const [userInfo, setUserInfo] = React.useState(null);
21
- const [isMFAEnabled, setIsMFAEnabled] = React.useState(false);
22
- const [isInitialized, setIsInitialized] = React.useState(false);
23
- const [status, setStatus] = React.useState(null);
24
- const getPlugin = React.useCallback(name => {
13
+ const [web3Auth, setWeb3Auth] = react.useState(null);
14
+ const [isConnecting, setIsConnecting] = react.useState(false);
15
+ const [isInitializing, setIsInitializing] = react.useState(false);
16
+ const [initError, setInitError] = react.useState(null);
17
+ const [connectError, setConnectError] = react.useState(null);
18
+ const [isConnected, setIsConnected] = react.useState(false);
19
+ const [provider, setProvider] = react.useState(null);
20
+ const [userInfo, setUserInfo] = react.useState(null);
21
+ const [isMFAEnabled, setIsMFAEnabled] = react.useState(false);
22
+ const [isInitialized, setIsInitialized] = react.useState(false);
23
+ const [status, setStatus] = react.useState(null);
24
+ const getPlugin = react.useCallback(name => {
25
25
  if (!web3Auth) throw noModal.WalletInitializationError.notReady();
26
26
  return web3Auth.getPlugin(name);
27
27
  }, [web3Auth]);
28
- const enableMFA = React.useCallback(async loginParams => {
28
+ const enableMFA = react.useCallback(async loginParams => {
29
29
  if (!web3Auth) throw noModal.WalletInitializationError.notReady();
30
30
  if (!isConnected) throw noModal.WalletLoginError.notConnectedError();
31
31
  await web3Auth.enableMFA(loginParams);
@@ -33,19 +33,19 @@ function Web3AuthInnerProvider(params) {
33
33
  setUserInfo(localUserInfo);
34
34
  setIsMFAEnabled(localUserInfo.isMfaEnabled || false);
35
35
  }, [web3Auth, isConnected]);
36
- const manageMFA = React.useCallback(async loginParams => {
36
+ const manageMFA = react.useCallback(async loginParams => {
37
37
  if (!web3Auth) throw noModal.WalletInitializationError.notReady();
38
38
  if (!isConnected) throw noModal.WalletLoginError.notConnectedError();
39
39
  await web3Auth.manageMFA(loginParams);
40
40
  }, [web3Auth, isConnected]);
41
- const logout = React.useCallback(async (logoutParams = {
41
+ const logout = react.useCallback(async (logoutParams = {
42
42
  cleanup: false
43
43
  }) => {
44
44
  if (!web3Auth) throw noModal.WalletInitializationError.notReady();
45
45
  if (!isConnected) throw noModal.WalletLoginError.notConnectedError();
46
46
  await web3Auth.logout(logoutParams);
47
47
  }, [web3Auth, isConnected]);
48
- const connect = React.useCallback(async () => {
48
+ const connect = react.useCallback(async () => {
49
49
  if (!web3Auth) throw noModal.WalletInitializationError.notReady();
50
50
  try {
51
51
  setConnectError(null);
@@ -59,15 +59,15 @@ function Web3AuthInnerProvider(params) {
59
59
  setIsConnecting(false);
60
60
  }
61
61
  }, [web3Auth]);
62
- const authenticateUser = React.useCallback(async () => {
62
+ const authenticateUser = react.useCallback(async () => {
63
63
  if (!web3Auth) throw noModal.WalletInitializationError.notReady();
64
64
  return web3Auth.authenticateUser();
65
65
  }, [web3Auth]);
66
- const switchChain = React.useCallback(chainParams => {
66
+ const switchChain = react.useCallback(chainParams => {
67
67
  if (!web3Auth) throw noModal.WalletInitializationError.notReady();
68
68
  return web3Auth.switchChain(chainParams);
69
69
  }, [web3Auth]);
70
- React.useEffect(() => {
70
+ react.useEffect(() => {
71
71
  const resetHookState = () => {
72
72
  setProvider(null);
73
73
  setUserInfo(null);
@@ -82,7 +82,7 @@ function Web3AuthInnerProvider(params) {
82
82
  const web3AuthInstance = new modalManager.Web3Auth(web3AuthOptions);
83
83
  setWeb3Auth(web3AuthInstance);
84
84
  }, [config]);
85
- React.useEffect(() => {
85
+ react.useEffect(() => {
86
86
  async function init() {
87
87
  try {
88
88
  setInitError(null);
@@ -96,7 +96,7 @@ function Web3AuthInnerProvider(params) {
96
96
  }
97
97
  if (web3Auth) init();
98
98
  }, [web3Auth, config]);
99
- React.useEffect(() => {
99
+ react.useEffect(() => {
100
100
  const addState = async () => {
101
101
  setProvider(web3Auth.provider);
102
102
  const userState = await web3Auth.getUserInfo();
@@ -112,7 +112,7 @@ function Web3AuthInnerProvider(params) {
112
112
  if (isConnected) addState();else resetState();
113
113
  }
114
114
  }, [web3Auth, isConnected]);
115
- React.useEffect(() => {
115
+ react.useEffect(() => {
116
116
  const notReadyListener = () => setStatus(web3Auth.status);
117
117
  const readyListener = () => {
118
118
  setStatus(web3Auth.status);
@@ -157,7 +157,7 @@ function Web3AuthInnerProvider(params) {
157
157
  }
158
158
  };
159
159
  }, [web3Auth]);
160
- const value = React.useMemo(() => {
160
+ const value = react.useMemo(() => {
161
161
  return {
162
162
  web3Auth,
163
163
  isConnected,
@@ -179,7 +179,7 @@ function Web3AuthInnerProvider(params) {
179
179
  connectError
180
180
  };
181
181
  }, [web3Auth, isConnected, isInitialized, provider, userInfo, isMFAEnabled, status, getPlugin, connect, enableMFA, manageMFA, logout, authenticateUser, switchChain, isInitializing, isConnecting, initError, connectError]);
182
- return /*#__PURE__*/React.createElement(Web3AuthInnerContext.Provider, {
182
+ return /*#__PURE__*/react.createElement(Web3AuthInnerContext.Provider, {
183
183
  value
184
184
  }, children);
185
185
  }
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var noModal = require('@web3auth/no-modal');
4
- var React = require('react');
4
+ var react = require('react');
5
5
  var Web3AuthInnerContext = require('../context/Web3AuthInnerContext.js');
6
6
 
7
7
  const useWeb3Auth = () => {
8
- const context = React.useContext(Web3AuthInnerContext.Web3AuthInnerContext);
8
+ const context = react.useContext(Web3AuthInnerContext.Web3AuthInnerContext);
9
9
  if (!context) {
10
10
  throw noModal.WalletInitializationError.fromCode(1000, "usage of useWeb3Auth not wrapped in `Web3AuthContextProvider`.");
11
11
  }