@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.
- package/dist/lib.cjs/node_modules/style-inject/dist/style-inject.es.js +1 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +195 -140
- package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +2 -2
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +26 -26
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3Auth.js +2 -2
- package/dist/lib.cjs/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +60 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.js +47 -22
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.type.js +8 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +53 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +68 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +202 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +65 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +29 -30
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +49 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +140 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +93 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.js +55 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Embed/Embed.js +70 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +53 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Image/Image.js +89 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Loader/Loader.js +151 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +489 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +116 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +117 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/LoginHint/LoginHint.js +52 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Modal/Modal.js +87 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Otp/Otp.js +190 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +18 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +448 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +156 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Toast/Toast.js +70 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +231 -0
- package/dist/lib.cjs/packages/modal/src/ui/config.js +12 -1
- package/dist/lib.cjs/packages/modal/src/ui/constants.js +18 -0
- package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +20 -0
- package/dist/lib.cjs/packages/modal/src/ui/context/ThemeContext.js +2 -2
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +8 -0
- package/dist/lib.cjs/packages/modal/src/ui/handlers/AbstractHandler.js +117 -0
- package/dist/lib.cjs/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +54 -0
- package/dist/lib.cjs/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +57 -0
- package/dist/lib.cjs/packages/modal/src/ui/handlers/factory.js +19 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +37 -2
- package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +7 -10
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +69 -44
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +107 -1
- package/dist/lib.cjs/types/interface.d.ts +1 -1
- package/dist/lib.cjs/types/modalManager.d.ts +5 -1
- package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.type.d.ts +7 -0
- package/dist/lib.cjs/types/ui/components/BottomSheet/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Button/Button.d.ts +2 -15
- package/dist/lib.cjs/types/ui/components/Button/Button.type.d.ts +12 -0
- package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/ButtonSocial.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/ButtonSocial.type.d.ts +14 -0
- package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/ButtonWallet.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/ButtonWallet.type.d.ts +13 -0
- package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Button/index.d.ts +1 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +24 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.type.d.ts +13 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.type.d.ts +10 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.type.d.ts +6 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.type.d.ts +19 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.type.d.ts +9 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.type.d.ts +9 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Embed/Embed.d.ts +8 -0
- package/dist/lib.cjs/types/ui/components/Embed/Embed.type.d.ts +12 -0
- package/dist/lib.cjs/types/ui/components/Embed/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Footer/Footer.d.ts +7 -0
- package/dist/lib.cjs/types/ui/components/Footer/Footer.type.d.ts +4 -0
- package/dist/lib.cjs/types/ui/components/Footer/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Image/Image.d.ts +7 -0
- package/dist/lib.cjs/types/ui/components/{Image.d.ts → Image/Image.type.d.ts} +2 -1
- package/dist/lib.cjs/types/ui/components/Image/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Loader/Loader.d.ts +8 -0
- package/dist/lib.cjs/types/ui/components/Loader/Loader.type.d.ts +12 -0
- package/dist/lib.cjs/types/ui/components/Loader/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Login/Login.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/Login/Login.type.d.ts +29 -0
- package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.d.ts +8 -0
- package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.type.d.ts +10 -0
- package/dist/lib.cjs/types/ui/components/Login/LoginOtp/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/LoginPasswordLess.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/LoginPasswordLess.type.d.ts +13 -0
- package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Login/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/LoginHint/LoginHint.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/LoginHint/LoginHint.type.d.ts +6 -0
- package/dist/lib.cjs/types/ui/components/LoginHint/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Modal/Modal.d.ts +8 -0
- package/dist/lib.cjs/types/ui/components/Modal/Modal.type.d.ts +14 -0
- package/dist/lib.cjs/types/ui/components/Modal/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Otp/Otp.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/Otp/Otp.type.d.ts +22 -0
- package/dist/lib.cjs/types/ui/components/Otp/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/PulseLoader/PulseLoader.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/PulseLoader/index.d.ts +1 -0
- package/dist/lib.cjs/types/ui/components/Root/Root.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/Root/Root.type.d.ts +27 -0
- package/dist/lib.cjs/types/ui/components/Root/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/SocialLoginList/SocialLoginList.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/SocialLoginList/SocialLoginList.type.d.ts +11 -0
- package/dist/lib.cjs/types/ui/components/SocialLoginList/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Toast/Toast.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Toast/index.d.ts +1 -0
- package/dist/lib.cjs/types/ui/components/Widget/Widget.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/{Modal.d.ts → Widget/Widget.type.d.ts} +4 -5
- package/dist/lib.cjs/types/ui/components/Widget/index.d.ts +1 -0
- package/dist/lib.cjs/types/ui/config.d.ts +4 -1
- package/dist/lib.cjs/types/ui/constants.d.ts +13 -0
- package/dist/lib.cjs/types/ui/context/RootContext.d.ts +18 -0
- package/dist/lib.cjs/types/ui/handlers/AbstractHandler.d.ts +20 -0
- package/dist/lib.cjs/types/ui/handlers/EmailPasswordlessHandler.d.ts +8 -0
- package/dist/lib.cjs/types/ui/handlers/SmsPasswordlessHandler.d.ts +9 -0
- package/dist/lib.cjs/types/ui/handlers/factory.d.ts +5 -0
- package/dist/lib.cjs/types/ui/interfaces.d.ts +115 -14
- package/dist/lib.cjs/types/ui/loginModal.d.ts +9 -7
- package/dist/lib.cjs/types/ui/utils.d.ts +17 -2
- package/dist/lib.esm/node_modules/style-inject/dist/style-inject.es.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +203 -145
- package/dist/lib.esm/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +58 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.js +48 -24
- package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.type.js +6 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +51 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +66 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +200 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +63 -0
- package/dist/lib.esm/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +29 -31
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +47 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +138 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +91 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.js +56 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Embed/Embed.js +68 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +51 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Image/Image.js +87 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Loader/Loader.js +152 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +489 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +115 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +115 -0
- package/dist/lib.esm/packages/modal/src/ui/components/LoginHint/LoginHint.js +50 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Modal/Modal.js +85 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Otp/Otp.js +188 -0
- package/dist/lib.esm/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +16 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +458 -0
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +154 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Toast/Toast.js +68 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +233 -0
- package/dist/lib.esm/packages/modal/src/ui/config.js +10 -3
- package/dist/lib.esm/packages/modal/src/ui/constants.js +13 -0
- package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +18 -0
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +6 -0
- package/dist/lib.esm/packages/modal/src/ui/handlers/AbstractHandler.js +115 -0
- package/dist/lib.esm/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +52 -0
- package/dist/lib.esm/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +55 -0
- package/dist/lib.esm/packages/modal/src/ui/handlers/factory.js +17 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +37 -3
- package/dist/lib.esm/packages/modal/src/ui/interfaces.js +8 -9
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +70 -45
- package/dist/lib.esm/packages/modal/src/ui/utils.js +105 -3
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +8 -8
- package/package.json +16 -11
- package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/assets/x-dark.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/assets/x-light.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +0 -108
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/styles.css.js +0 -8
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -44
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -67
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -43
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -46
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -167
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +0 -279
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer.js +0 -20
- package/dist/lib.cjs/packages/modal/src/ui/components/Header.js +0 -81
- package/dist/lib.cjs/packages/modal/src/ui/components/Icon.js +0 -73
- package/dist/lib.cjs/packages/modal/src/ui/components/Image.js +0 -51
- package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +0 -59
- package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +0 -278
- package/dist/lib.cjs/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -30
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -150
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +0 -153
- package/dist/lib.cjs/packages/modal/src/ui/components/WalletConnect.js +0 -84
- package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +0 -8
- package/dist/lib.cjs/types/ui/components/AdapterLoader.d.ts +0 -11
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletButton.d.ts +0 -7
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletChainNamespace.d.ts +0 -9
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletConnect.d.ts +0 -9
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletDetails.d.ts +0 -10
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletHeader.d.ts +0 -8
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletInstall.d.ts +0 -8
- package/dist/lib.cjs/types/ui/components/ExternalWallets.d.ts +0 -15
- package/dist/lib.cjs/types/ui/components/Footer.d.ts +0 -1
- package/dist/lib.cjs/types/ui/components/Header.d.ts +0 -8
- package/dist/lib.cjs/types/ui/components/Icon.d.ts +0 -9
- package/dist/lib.cjs/types/ui/components/Loader.d.ts +0 -10
- package/dist/lib.cjs/types/ui/components/SelfCustodyViaWeb3Auth.d.ts +0 -1
- package/dist/lib.cjs/types/ui/components/SocialLoginPasswordless.d.ts +0 -14
- package/dist/lib.cjs/types/ui/components/SocialLogins.d.ts +0 -10
- package/dist/lib.cjs/types/ui/components/WalletConnect.d.ts +0 -8
- package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/assets/x-dark.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/assets/x-light.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/components/AdapterLoader.js +0 -106
- package/dist/lib.esm/packages/modal/src/ui/components/Button/styles.css.js +0 -6
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -42
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -65
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -44
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -44
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -165
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +0 -281
- package/dist/lib.esm/packages/modal/src/ui/components/Footer.js +0 -18
- package/dist/lib.esm/packages/modal/src/ui/components/Header.js +0 -79
- package/dist/lib.esm/packages/modal/src/ui/components/Icon.js +0 -71
- package/dist/lib.esm/packages/modal/src/ui/components/Image.js +0 -49
- package/dist/lib.esm/packages/modal/src/ui/components/Loader.js +0 -57
- package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +0 -277
- package/dist/lib.esm/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -28
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -148
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +0 -152
- package/dist/lib.esm/packages/modal/src/ui/components/WalletConnect.js +0 -82
- 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 (
|
|
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
|
-
|
|
97
|
+
web3authClientId: this.options.clientId,
|
|
98
|
+
web3authNetwork: this.options.web3AuthNetwork,
|
|
99
|
+
chainNamespaces: this.getChainNamespaces(),
|
|
47
100
|
walletRegistry: filteredWalletRegistry
|
|
48
|
-
})
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
|
177
|
-
// Auth connector config:
|
|
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
|
-
|
|
271
|
+
authConnection,
|
|
183
272
|
groupedAuthConnectionId,
|
|
184
|
-
|
|
273
|
+
authConnectionId
|
|
185
274
|
} = authConnectionConfig;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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$
|
|
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$
|
|
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
|
|
242
|
-
|
|
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$
|
|
355
|
+
var _this$modalConfig4;
|
|
250
356
|
if (!isExternalWalletEnabled) return;
|
|
251
|
-
if ((_this$
|
|
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
|
|
283
|
-
await Promise.all(
|
|
284
|
-
const
|
|
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(
|
|
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
|
-
|
|
425
|
+
externalConnectors.forEach(async connector => {
|
|
321
426
|
const connectorName = connector.name;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
|
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__*/
|
|
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
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var modalManager = require('../../modalManager.js');
|
|
6
6
|
|
|
7
|
-
const Web3AuthInnerContext = /*#__PURE__*/
|
|
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] =
|
|
14
|
-
const [isConnecting, setIsConnecting] =
|
|
15
|
-
const [isInitializing, setIsInitializing] =
|
|
16
|
-
const [initError, setInitError] =
|
|
17
|
-
const [connectError, setConnectError] =
|
|
18
|
-
const [isConnected, setIsConnected] =
|
|
19
|
-
const [provider, setProvider] =
|
|
20
|
-
const [userInfo, setUserInfo] =
|
|
21
|
-
const [isMFAEnabled, setIsMFAEnabled] =
|
|
22
|
-
const [isInitialized, setIsInitialized] =
|
|
23
|
-
const [status, setStatus] =
|
|
24
|
-
const getPlugin =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
66
|
+
const switchChain = react.useCallback(chainParams => {
|
|
67
67
|
if (!web3Auth) throw noModal.WalletInitializationError.notReady();
|
|
68
68
|
return web3Auth.switchChain(chainParams);
|
|
69
69
|
}, [web3Auth]);
|
|
70
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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__*/
|
|
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
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var Web3AuthInnerContext = require('../context/Web3AuthInnerContext.js');
|
|
6
6
|
|
|
7
7
|
const useWeb3Auth = () => {
|
|
8
|
-
const context =
|
|
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
|
}
|