@web3auth/modal 10.0.0-alpha.2 → 10.0.0-beta.1
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/config.js +3 -57
- package/dist/lib.cjs/packages/modal/src/index.js +1 -5
- package/dist/lib.cjs/packages/modal/src/modalManager.js +286 -189
- package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +2 -2
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +27 -38
- 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 +62 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +28 -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 +452 -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 +229 -0
- package/dist/lib.cjs/packages/modal/src/ui/config.js +10 -0
- 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 +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +38 -2
- package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +7 -10
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +69 -43
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +105 -20
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +1 -12
- package/dist/lib.cjs/types/config.d.ts +1 -5
- package/dist/lib.cjs/types/interface.d.ts +2 -6
- package/dist/lib.cjs/types/modalManager.d.ts +11 -4
- package/dist/lib.cjs/types/react/interfaces.d.ts +1 -6
- 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 +116 -15
- package/dist/lib.cjs/types/ui/loginModal.d.ts +9 -7
- package/dist/lib.cjs/types/ui/utils.d.ts +16 -3
- package/dist/lib.cjs/types/vue/interfaces.d.ts +1 -6
- package/dist/lib.esm/node_modules/style-inject/dist/style-inject.es.js +1 -1
- package/dist/lib.esm/packages/modal/src/config.js +4 -54
- package/dist/lib.esm/packages/modal/src/index.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +299 -195
- package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +1 -12
- 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 +60 -0
- package/dist/lib.esm/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +28 -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 +462 -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 +231 -0
- package/dist/lib.esm/packages/modal/src/ui/config.js +9 -2
- 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 +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +38 -3
- package/dist/lib.esm/packages/modal/src/ui/interfaces.js +8 -9
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +70 -44
- package/dist/lib.esm/packages/modal/src/ui/utils.js +104 -22
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +1 -12
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +8 -8
- package/package.json +14 -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 -274
- 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 -244
- 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 -148
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +0 -152
- 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 -276
- 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 -243
- 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 -146
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +0 -151
- 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
|
@@ -1,46 +1,107 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import { Web3AuthNoModal, cloneDeep,
|
|
3
|
+
import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, log, CONNECTOR_STATUS, CONNECTOR_EVENTS, WalletInitializationError, fetchProjectConfig, fetchWalletRegistry, CONNECTOR_CATEGORY, CONNECTOR_NAMES } from '@web3auth/no-modal';
|
|
4
4
|
import deepmerge from 'deepmerge';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { defaultConnectorsModalConfig, walletRegistryUrl } from './config.js';
|
|
6
|
+
import { AUTH_PROVIDERS_NAMES, AUTH_PROVIDERS, capitalizeFirstLetter } from './ui/config.js';
|
|
7
7
|
import { LOGIN_MODAL_EVENTS } from './ui/interfaces.js';
|
|
8
8
|
import { LoginModal } from './ui/loginModal.js';
|
|
9
|
-
import { getUserLanguage
|
|
9
|
+
import { getUserLanguage } from './ui/utils.js';
|
|
10
10
|
|
|
11
11
|
class Web3Auth extends Web3AuthNoModal {
|
|
12
12
|
constructor(options) {
|
|
13
13
|
super(options);
|
|
14
14
|
_defineProperty(this, "loginModal", void 0);
|
|
15
15
|
_defineProperty(this, "options", void 0);
|
|
16
|
-
_defineProperty(this, "modalConfig", cloneDeep(
|
|
16
|
+
_defineProperty(this, "modalConfig", cloneDeep(defaultConnectorsModalConfig));
|
|
17
|
+
_defineProperty(this, "onInitExternalWallets", async params => {
|
|
18
|
+
if (params.externalWalletsInitialized) return;
|
|
19
|
+
// initialize WC connector only as other external wallets are initialized in initModal
|
|
20
|
+
await this.initExternalConnectors(this.connectors.filter(x => x.name === WALLET_CONNECTORS.WALLET_CONNECT_V2), {
|
|
21
|
+
externalWalletsInitialized: true,
|
|
22
|
+
externalWalletsVisibility: true
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "onSocialLogin", async params => {
|
|
26
|
+
try {
|
|
27
|
+
await this.connectTo(params.connector, params.loginParams);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(this, "onExternalWalletLogin", async params => {
|
|
33
|
+
try {
|
|
34
|
+
await this.connectTo(params.connector, params.loginParams);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
_defineProperty(this, "onModalVisibility", async visibility => {
|
|
40
|
+
log.debug("is login modal visible", visibility);
|
|
41
|
+
this.emit(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
|
|
42
|
+
const wcConnector = this.getConnector(WALLET_CONNECTORS.WALLET_CONNECT_V2);
|
|
43
|
+
if (wcConnector) {
|
|
44
|
+
const walletConnectStatus = wcConnector === null || wcConnector === void 0 ? void 0 : wcConnector.status;
|
|
45
|
+
log.debug("trying refreshing wc session", visibility, walletConnectStatus);
|
|
46
|
+
if (visibility && (walletConnectStatus === CONNECTOR_STATUS.READY || walletConnectStatus === CONNECTOR_STATUS.CONNECTING)) {
|
|
47
|
+
log.debug("refreshing wc session");
|
|
48
|
+
|
|
49
|
+
// refreshing session for wallet connect whenever modal is opened.
|
|
50
|
+
try {
|
|
51
|
+
const initialChain = this.getInitialChainIdForConnector(wcConnector);
|
|
52
|
+
wcConnector.connect({
|
|
53
|
+
chainId: initialChain.chainId
|
|
54
|
+
});
|
|
55
|
+
} catch (error) {
|
|
56
|
+
log.error(`Error while disconnecting to wallet connect in core`, error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!visibility && this.status === CONNECTOR_STATUS.CONNECTED && (walletConnectStatus === CONNECTOR_STATUS.READY || walletConnectStatus === CONNECTOR_STATUS.CONNECTING)) {
|
|
60
|
+
log.debug("this stops wc connector from trying to reconnect once proposal expires");
|
|
61
|
+
wcConnector.status = CONNECTOR_STATUS.READY;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
17
65
|
this.options = _objectSpread({}, options);
|
|
18
66
|
if (!this.options.uiConfig) this.options.uiConfig = {};
|
|
67
|
+
if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
|
|
68
|
+
log.info("modalConfig", this.modalConfig);
|
|
19
69
|
}
|
|
20
|
-
|
|
21
|
-
super.checkInitRequirements();
|
|
22
|
-
this.modalConfig = modalConfig;
|
|
23
|
-
}
|
|
24
|
-
async initModal(params) {
|
|
70
|
+
async initModal() {
|
|
25
71
|
var _this$coreOptions$cha;
|
|
26
72
|
super.checkInitRequirements();
|
|
27
|
-
super.initCachedConnectorAndChainId();
|
|
28
73
|
// get project config and wallet registry
|
|
29
74
|
const {
|
|
30
75
|
projectConfig,
|
|
31
76
|
walletRegistry
|
|
32
|
-
} = await this.getProjectAndWalletConfig(
|
|
77
|
+
} = await this.getProjectAndWalletConfig();
|
|
33
78
|
this.options.uiConfig = deepmerge(cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
|
|
34
79
|
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
35
80
|
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
|
|
81
|
+
this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig || {});
|
|
82
|
+
|
|
83
|
+
// init config
|
|
84
|
+
super.initAccountAbstractionConfig(projectConfig);
|
|
85
|
+
super.initChainsConfig(projectConfig);
|
|
86
|
+
super.initCachedConnectorAndChainId();
|
|
36
87
|
|
|
37
88
|
// init login modal
|
|
89
|
+
const {
|
|
90
|
+
filteredWalletRegistry,
|
|
91
|
+
disabledExternalWallets
|
|
92
|
+
} = this.filterWalletRegistry(walletRegistry, projectConfig);
|
|
38
93
|
this.loginModal = new LoginModal(_objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
|
|
39
94
|
connectorListener: this,
|
|
95
|
+
web3authClientId: this.options.clientId,
|
|
96
|
+
web3authNetwork: this.options.web3AuthNetwork,
|
|
40
97
|
chainNamespaces: [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])],
|
|
41
|
-
walletRegistry
|
|
42
|
-
})
|
|
43
|
-
|
|
98
|
+
walletRegistry: filteredWalletRegistry
|
|
99
|
+
}), {
|
|
100
|
+
onInitExternalWallets: this.onInitExternalWallets,
|
|
101
|
+
onSocialLogin: this.onSocialLogin,
|
|
102
|
+
onExternalWalletLogin: this.onExternalWalletLogin,
|
|
103
|
+
onModalVisibility: this.onModalVisibility
|
|
104
|
+
});
|
|
44
105
|
await this.loginModal.initModal();
|
|
45
106
|
|
|
46
107
|
// setup common JRPC provider
|
|
@@ -52,7 +113,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
52
113
|
}) => this.initConnectors({
|
|
53
114
|
connectors: newConnectors,
|
|
54
115
|
projectConfig,
|
|
55
|
-
|
|
116
|
+
disabledExternalWallets
|
|
56
117
|
}));
|
|
57
118
|
await this.loadConnectors({
|
|
58
119
|
projectConfig
|
|
@@ -67,37 +128,83 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
67
128
|
if (this.connectedConnectorName && this.status === CONNECTOR_STATUS.CONNECTED && this.provider) return this.provider;
|
|
68
129
|
this.loginModal.open();
|
|
69
130
|
return new Promise((resolve, reject) => {
|
|
70
|
-
|
|
131
|
+
// remove all listeners when promise is resolved or rejected.
|
|
132
|
+
// this is to prevent memory leaks if user clicks connect button multiple times.
|
|
133
|
+
const handleConnected = () => {
|
|
134
|
+
this.removeListener(CONNECTOR_EVENTS.ERRORED, handleError);
|
|
135
|
+
this.removeListener(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
|
|
71
136
|
return resolve(this.provider);
|
|
72
|
-
}
|
|
73
|
-
|
|
137
|
+
};
|
|
138
|
+
const handleError = err => {
|
|
139
|
+
this.removeListener(CONNECTOR_EVENTS.CONNECTED, handleConnected);
|
|
140
|
+
this.removeListener(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
|
|
74
141
|
return reject(err);
|
|
75
|
-
}
|
|
76
|
-
|
|
142
|
+
};
|
|
143
|
+
const handleVisibility = visibility => {
|
|
77
144
|
// modal is closed but user is not connected to any wallet.
|
|
78
145
|
if (!visibility && this.status !== CONNECTOR_STATUS.CONNECTED) {
|
|
146
|
+
this.removeListener(CONNECTOR_EVENTS.CONNECTED, handleConnected);
|
|
147
|
+
this.removeListener(CONNECTOR_EVENTS.ERRORED, handleError);
|
|
79
148
|
return reject(new Error("User closed the modal"));
|
|
80
149
|
}
|
|
81
|
-
}
|
|
150
|
+
};
|
|
151
|
+
this.once(CONNECTOR_EVENTS.CONNECTED, handleConnected);
|
|
152
|
+
this.once(CONNECTOR_EVENTS.ERRORED, handleError);
|
|
153
|
+
this.once(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
|
|
82
154
|
});
|
|
83
155
|
}
|
|
84
|
-
|
|
156
|
+
filterWalletRegistry(walletRegistry, projectConfig) {
|
|
157
|
+
const {
|
|
158
|
+
disableAllRecommendedWallets,
|
|
159
|
+
disableAllOtherWallets,
|
|
160
|
+
disabledWallets
|
|
161
|
+
} = projectConfig.externalWalletAuth || {};
|
|
162
|
+
|
|
163
|
+
// add disabled wallets to set
|
|
164
|
+
const disabledExternalWallets = new Set(disabledWallets || []);
|
|
165
|
+
if (disableAllRecommendedWallets) {
|
|
166
|
+
Object.keys(walletRegistry.default).forEach(wallet => disabledExternalWallets.add(wallet));
|
|
167
|
+
}
|
|
168
|
+
if (disableAllOtherWallets) {
|
|
169
|
+
Object.keys(walletRegistry.others).forEach(wallet => disabledExternalWallets.add(wallet));
|
|
170
|
+
}
|
|
171
|
+
// always show MetaMask, force enable it
|
|
172
|
+
disabledExternalWallets.delete(WALLET_CONNECTORS.METAMASK);
|
|
173
|
+
|
|
174
|
+
// remove wallets that are disabled in project config from wallet registry
|
|
175
|
+
const filteredWalletRegistry = cloneDeep(walletRegistry);
|
|
176
|
+
disabledExternalWallets.forEach(wallet => {
|
|
177
|
+
delete filteredWalletRegistry.default[wallet];
|
|
178
|
+
delete filteredWalletRegistry.others[wallet];
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
disabledExternalWallets,
|
|
182
|
+
filteredWalletRegistry
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async getProjectAndWalletConfig() {
|
|
186
|
+
var _this$modalConfig;
|
|
85
187
|
// get project config
|
|
86
188
|
let projectConfig;
|
|
87
189
|
try {
|
|
88
190
|
var _this$options$account;
|
|
89
|
-
projectConfig = await fetchProjectConfig(
|
|
191
|
+
projectConfig = await fetchProjectConfig({
|
|
192
|
+
clientId: this.options.clientId,
|
|
193
|
+
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
194
|
+
aaProvider: (_this$options$account = this.options.accountAbstractionConfig) === null || _this$options$account === void 0 ? void 0 : _this$options$account.smartAccountType,
|
|
195
|
+
authBuildEnv: this.options.authBuildEnv
|
|
196
|
+
});
|
|
90
197
|
} catch (e) {
|
|
91
198
|
log.error("Failed to fetch project configurations", e);
|
|
92
199
|
throw WalletInitializationError.notReady("failed to fetch project configurations", e);
|
|
93
200
|
}
|
|
94
|
-
|
|
95
201
|
// get wallet registry
|
|
96
202
|
let walletRegistry = {
|
|
97
203
|
others: {},
|
|
98
204
|
default: {}
|
|
99
205
|
};
|
|
100
|
-
|
|
206
|
+
const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
|
|
207
|
+
if (isExternalWalletEnabled && !((_this$modalConfig = this.modalConfig) !== null && _this$modalConfig !== void 0 && _this$modalConfig.hideWalletDiscovery)) {
|
|
101
208
|
try {
|
|
102
209
|
walletRegistry = await fetchWalletRegistry(walletRegistryUrl);
|
|
103
210
|
} catch (e) {
|
|
@@ -112,25 +219,41 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
112
219
|
async initConnectors({
|
|
113
220
|
connectors,
|
|
114
221
|
projectConfig,
|
|
115
|
-
|
|
222
|
+
disabledExternalWallets
|
|
116
223
|
}) {
|
|
117
224
|
// filter connectors based on config
|
|
118
|
-
const filteredConnectorNames = await this.filterConnectors(
|
|
225
|
+
const filteredConnectorNames = await this.filterConnectors({
|
|
226
|
+
projectConfig,
|
|
227
|
+
disabledExternalWallets
|
|
228
|
+
});
|
|
119
229
|
|
|
120
230
|
// initialize connectors based on availability
|
|
121
231
|
const {
|
|
122
232
|
hasInAppConnectors,
|
|
123
233
|
hasExternalConnectors
|
|
124
|
-
} = await this.checkConnectorAvailability(filteredConnectorNames
|
|
234
|
+
} = await this.checkConnectorAvailability(filteredConnectorNames);
|
|
235
|
+
const filteredConnectors = connectors.filter(x => filteredConnectorNames.includes(x.name));
|
|
125
236
|
if (hasInAppConnectors) {
|
|
126
|
-
await this.initInAppAndCachedConnectors(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
237
|
+
await this.initInAppAndCachedConnectors(filteredConnectors);
|
|
238
|
+
}
|
|
239
|
+
if (hasExternalConnectors) {
|
|
240
|
+
if (hasInAppConnectors) {
|
|
241
|
+
// show connect button if both in-app and external wallets are available
|
|
242
|
+
this.loginModal.initExternalWalletContainer();
|
|
243
|
+
// initialize installed external wallets (except WC), don't mark external wallets as fully initialized
|
|
244
|
+
this.initExternalConnectors(filteredConnectors.filter(x => x.type === CONNECTOR_CATEGORY.EXTERNAL && x.name !== WALLET_CONNECTORS.WALLET_CONNECT_V2), {
|
|
245
|
+
externalWalletsInitialized: false,
|
|
246
|
+
showExternalWalletsOnly: false,
|
|
247
|
+
externalWalletsVisibility: false
|
|
248
|
+
});
|
|
249
|
+
} else {
|
|
250
|
+
// if no in app wallet is available then initialize all external wallets in modal
|
|
251
|
+
await this.initExternalConnectors(filteredConnectors.filter(x => x.type === CONNECTOR_CATEGORY.EXTERNAL), {
|
|
252
|
+
externalWalletsInitialized: true,
|
|
253
|
+
showExternalWalletsOnly: true,
|
|
254
|
+
externalWalletsVisibility: true
|
|
255
|
+
});
|
|
256
|
+
}
|
|
134
257
|
}
|
|
135
258
|
|
|
136
259
|
// emit ready event if connector is ready
|
|
@@ -139,122 +262,152 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
139
262
|
this.emit(CONNECTOR_EVENTS.READY);
|
|
140
263
|
}
|
|
141
264
|
}
|
|
142
|
-
async filterConnectors(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
265
|
+
async filterConnectors({
|
|
266
|
+
projectConfig,
|
|
267
|
+
disabledExternalWallets
|
|
268
|
+
}) {
|
|
269
|
+
var _this$modalConfig2;
|
|
270
|
+
// Auth connector config: populate this with the default config for auth connectors.
|
|
271
|
+
const loginMethods = {};
|
|
272
|
+
const embedWalletConfigMap = new Map();
|
|
273
|
+
for (const authConnectionConfig of projectConfig.embeddedWalletAuth || []) {
|
|
274
|
+
const {
|
|
275
|
+
isDefault,
|
|
276
|
+
authConnection,
|
|
277
|
+
groupedAuthConnectionId,
|
|
278
|
+
authConnectionId
|
|
279
|
+
} = authConnectionConfig;
|
|
280
|
+
if (isDefault) {
|
|
281
|
+
loginMethods[authConnection] = {
|
|
282
|
+
name: AUTH_PROVIDERS_NAMES[authConnection],
|
|
283
|
+
authConnection: authConnection,
|
|
284
|
+
authConnectionId: authConnectionId,
|
|
285
|
+
groupedAuthConnectionId: groupedAuthConnectionId,
|
|
286
|
+
extraLoginOptions: authConnectionConfig.jwtParameters,
|
|
287
|
+
isDefault: true,
|
|
288
|
+
showOnModal: true,
|
|
289
|
+
showOnDesktop: true,
|
|
290
|
+
showOnMobile: true
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
embedWalletConfigMap.set(groupedAuthConnectionId || authConnectionId, authConnectionConfig);
|
|
294
|
+
}
|
|
295
|
+
const dashboardConnectorConfig = {
|
|
296
|
+
[WALLET_CONNECTORS.AUTH]: {
|
|
297
|
+
label: WALLET_CONNECTORS.AUTH,
|
|
298
|
+
loginMethods
|
|
169
299
|
}
|
|
170
|
-
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
// populate the user config data with the dashboard config.
|
|
303
|
+
if ((_this$modalConfig2 = this.modalConfig) !== null && _this$modalConfig2 !== void 0 && (_this$modalConfig2 = _this$modalConfig2.connectors) !== null && _this$modalConfig2 !== void 0 && _this$modalConfig2[WALLET_CONNECTORS.AUTH]) {
|
|
304
|
+
if (!this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods) this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods = {};
|
|
171
305
|
}
|
|
306
|
+
const authProviders = new Set(AUTH_PROVIDERS);
|
|
307
|
+
Object.keys(this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods).forEach(key => {
|
|
308
|
+
const userConfig = this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods[key];
|
|
309
|
+
const {
|
|
310
|
+
authConnectionId,
|
|
311
|
+
groupedAuthConnectionId
|
|
312
|
+
} = userConfig;
|
|
313
|
+
if (!authProviders.has(key)) {
|
|
314
|
+
throw WalletInitializationError.invalidParams(`Invalid auth connection: ${key}`);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// only throw error if one of them is defined in the config.
|
|
318
|
+
if (groupedAuthConnectionId || authConnectionId) {
|
|
319
|
+
if (!embedWalletConfigMap.has(groupedAuthConnectionId || authConnectionId)) throw WalletInitializationError.invalidParams(`Invalid auth connection config, authConnection: ${key}. Missing AuthConnectionConfig from the dashboard.`);
|
|
320
|
+
const configFromDashboard = embedWalletConfigMap.get(groupedAuthConnectionId || authConnectionId);
|
|
321
|
+
this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods[key] = {
|
|
322
|
+
authConnection: configFromDashboard.authConnection,
|
|
323
|
+
authConnectionId: configFromDashboard.authConnectionId,
|
|
324
|
+
groupedAuthConnectionId: configFromDashboard.groupedAuthConnectionId,
|
|
325
|
+
isDefault: configFromDashboard.isDefault || false,
|
|
326
|
+
extraLoginOptions: _objectSpread(_objectSpread({}, configFromDashboard.jwtParameters), userConfig.extraLoginOptions)
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
this.modalConfig.connectors = deepmerge(dashboardConnectorConfig, cloneDeep(this.modalConfig.connectors || {}));
|
|
172
331
|
|
|
173
332
|
// merge default connectors with the custom configured connectors.
|
|
174
333
|
const allConnectorNames = [...new Set([...Object.keys(this.modalConfig.connectors || {}), ...this.connectors.map(connector => connector.name)])];
|
|
175
|
-
const
|
|
176
|
-
var _this$
|
|
334
|
+
const connectorNames = allConnectorNames.map(connectorName => {
|
|
335
|
+
var _this$modalConfig3, _this$modalConfig$con, _this$modalConfig$con2;
|
|
177
336
|
// start with the default config of connector.
|
|
178
|
-
|
|
337
|
+
const defaultConnectorConfig = {
|
|
179
338
|
label: CONNECTOR_NAMES[connectorName] || connectorName.split("-").map(capitalizeFirstLetter).join(" "),
|
|
180
339
|
showOnModal: true,
|
|
181
340
|
showOnMobile: true,
|
|
182
341
|
showOnDesktop: true
|
|
183
342
|
};
|
|
184
|
-
|
|
185
|
-
if ((_params2 = params) !== null && _params2 !== void 0 && (_params2 = _params2.modalConfig) !== null && _params2 !== void 0 && _params2[connectorName]) {
|
|
186
|
-
connectorConfig = _objectSpread(_objectSpread({}, connectorConfig), params.modalConfig[connectorName]);
|
|
187
|
-
}
|
|
188
|
-
this.modalConfig.connectors[connectorName] = connectorConfig;
|
|
343
|
+
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]) || {});
|
|
189
344
|
|
|
190
345
|
// check if connector is configured/added by user and exist in connectors map.
|
|
191
346
|
const connector = this.getConnector(connectorName);
|
|
192
|
-
log.debug("connector config", connectorName, (_this$modalConfig$
|
|
347
|
+
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);
|
|
193
348
|
|
|
194
|
-
// if connector is
|
|
195
|
-
|
|
196
|
-
if (!connector
|
|
197
|
-
throw WalletInitializationError.invalidParams(`Connector ${connectorName} is not configured`);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return connectorName;
|
|
349
|
+
// check if connector is configured/added by user and exist in connectors map.
|
|
350
|
+
const connectorConfig = (_this$modalConfig$con2 = this.modalConfig.connectors) === null || _this$modalConfig$con2 === void 0 ? void 0 : _this$modalConfig$con2[connectorName];
|
|
351
|
+
if (!connector) {
|
|
352
|
+
if (connectorConfig.showOnModal) throw WalletInitializationError.invalidParams(`Connector ${connectorName} is not configured`);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// skip connector if it is hidden by user
|
|
357
|
+
if (!connectorConfig.showOnModal) return;
|
|
358
|
+
|
|
359
|
+
// skip external connector if external wallets are disabled except for MetaMask
|
|
360
|
+
const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
|
|
361
|
+
if (connector.type === CONNECTOR_CATEGORY.EXTERNAL && connector.name !== WALLET_CONNECTORS.METAMASK) {
|
|
362
|
+
if (!isExternalWalletEnabled) return;
|
|
363
|
+
if (disabledExternalWallets.has(connectorName)) return;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// skip WC connector if external wallets are disabled or hideWalletDiscovery is true
|
|
367
|
+
if (connectorName === WALLET_CONNECTORS.WALLET_CONNECT_V2) {
|
|
368
|
+
var _this$modalConfig4;
|
|
369
|
+
if (!isExternalWalletEnabled) return;
|
|
370
|
+
if ((_this$modalConfig4 = this.modalConfig) !== null && _this$modalConfig4 !== void 0 && _this$modalConfig4.hideWalletDiscovery) return;
|
|
217
371
|
}
|
|
372
|
+
this.modalConfig.connectors[connectorName] = connectorConfig;
|
|
373
|
+
return connectorName;
|
|
218
374
|
});
|
|
219
|
-
const connectorNames = await Promise.all(connectorConfigurationPromises);
|
|
375
|
+
// const connectorNames = await Promise.all(connectorConfigurationPromises);
|
|
220
376
|
return connectorNames.filter(name => name !== undefined);
|
|
221
377
|
}
|
|
222
|
-
async checkConnectorAvailability(connectorNames
|
|
378
|
+
async checkConnectorAvailability(connectorNames) {
|
|
223
379
|
// currently all default in app and external wallets can be hidden or shown based on config.
|
|
224
380
|
// check if in app connectors are available
|
|
225
381
|
const hasInAppConnectors = this.connectors.some(connector => {
|
|
226
|
-
var _this$modalConfig$
|
|
382
|
+
var _this$modalConfig$con3, _this$modalConfig$con4;
|
|
227
383
|
if (connector.type !== CONNECTOR_CATEGORY.IN_APP) return false;
|
|
228
|
-
if (((_this$modalConfig$
|
|
229
|
-
if (!((_this$modalConfig$
|
|
230
|
-
|
|
231
|
-
if (Object.values(mergedLoginMethods).some(method => method.showOnModal)) return true;
|
|
384
|
+
if (((_this$modalConfig$con3 = this.modalConfig.connectors) === null || _this$modalConfig$con3 === void 0 || (_this$modalConfig$con3 = _this$modalConfig$con3[connector.name]) === null || _this$modalConfig$con3 === void 0 ? void 0 : _this$modalConfig$con3.showOnModal) !== true) return false;
|
|
385
|
+
if (!((_this$modalConfig$con4 = this.modalConfig.connectors) !== null && _this$modalConfig$con4 !== void 0 && (_this$modalConfig$con4 = _this$modalConfig$con4[connector.name]) !== null && _this$modalConfig$con4 !== void 0 && _this$modalConfig$con4.loginMethods)) return true;
|
|
386
|
+
if (Object.values(this.modalConfig.connectors[connector.name].loginMethods).some(method => method.showOnModal)) return true;
|
|
232
387
|
return false;
|
|
233
388
|
});
|
|
234
389
|
log.debug(hasInAppConnectors, this.connectors, connectorNames, "hasInAppWallets");
|
|
235
390
|
|
|
236
391
|
// check if external connectors are available
|
|
237
392
|
const hasExternalConnectors = connectorNames.some(connectorName => {
|
|
238
|
-
var _this$getConnector, _this$modalConfig$
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return ((_this$getConnector = this.getConnector(connectorName)) === null || _this$getConnector === void 0 ? void 0 : _this$getConnector.type) === CONNECTOR_CATEGORY.EXTERNAL && ((_this$modalConfig$con10 = this.modalConfig.connectors) === null || _this$modalConfig$con10 === void 0 ? void 0 : _this$modalConfig$con10[connectorName].showOnModal);
|
|
393
|
+
var _this$getConnector, _this$modalConfig$con5;
|
|
394
|
+
if (connectorName === WALLET_CONNECTORS.WALLET_CONNECT_V2) return true;
|
|
395
|
+
return ((_this$getConnector = this.getConnector(connectorName)) === null || _this$getConnector === void 0 ? void 0 : _this$getConnector.type) === CONNECTOR_CATEGORY.EXTERNAL && ((_this$modalConfig$con5 = this.modalConfig.connectors) === null || _this$modalConfig$con5 === void 0 ? void 0 : _this$modalConfig$con5[connectorName].showOnModal);
|
|
242
396
|
});
|
|
243
397
|
return {
|
|
244
398
|
hasInAppConnectors,
|
|
245
399
|
hasExternalConnectors
|
|
246
400
|
};
|
|
247
401
|
}
|
|
248
|
-
async initInAppAndCachedConnectors(connectors
|
|
249
|
-
await Promise.all(
|
|
250
|
-
const
|
|
251
|
-
if (!connector) return;
|
|
402
|
+
async initInAppAndCachedConnectors(connectors) {
|
|
403
|
+
await Promise.all(connectors.map(async connector => {
|
|
404
|
+
const connectorName = connector.name;
|
|
252
405
|
try {
|
|
253
406
|
// skip if connector is already initialized
|
|
254
407
|
if (connector.status !== CONNECTOR_STATUS.NOT_READY) return;
|
|
255
408
|
|
|
256
409
|
// only initialize a external connectors here if it is a cached connector.
|
|
257
|
-
if (this.cachedConnector !== connectorName && connector.type === CONNECTOR_CATEGORY.EXTERNAL) return;
|
|
410
|
+
if (this.cachedConnector !== connectorName && connectorName !== WALLET_CONNECTORS.METAMASK && connector.type === CONNECTOR_CATEGORY.EXTERNAL) return;
|
|
258
411
|
|
|
259
412
|
// in-app wallets or cached wallet (being connected or already connected) are initialized first.
|
|
260
413
|
// if connector is configured then only initialize in app or cached connector.
|
|
@@ -269,9 +422,9 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
269
422
|
// note: not adding cachedWallet to modal if it is external wallet.
|
|
270
423
|
// adding it later if no in-app wallets are available.
|
|
271
424
|
if (connector.type === CONNECTOR_CATEGORY.IN_APP) {
|
|
272
|
-
var
|
|
425
|
+
var _this$modalConfig$con6, _this$options$uiConfi, _this$options$uiConfi2, _this$options$uiConfi3;
|
|
273
426
|
log.info("connectorInitResults", connectorName);
|
|
274
|
-
const loginMethods =
|
|
427
|
+
const loginMethods = ((_this$modalConfig$con6 = this.modalConfig.connectors[connectorName]) === null || _this$modalConfig$con6 === void 0 ? void 0 : _this$modalConfig$con6.loginMethods) || {};
|
|
275
428
|
this.loginModal.addSocialLogins(connectorName, loginMethods, ((_this$options$uiConfi = this.options.uiConfig) === null || _this$options$uiConfi === void 0 ? void 0 : _this$options$uiConfi.loginMethodsOrder) || AUTH_PROVIDERS, _objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
|
|
276
429
|
loginGridCol: ((_this$options$uiConfi2 = this.options.uiConfig) === null || _this$options$uiConfi2 === void 0 ? void 0 : _this$options$uiConfi2.loginGridCol) || 3,
|
|
277
430
|
primaryButton: ((_this$options$uiConfi3 = this.options.uiConfig) === null || _this$options$uiConfi3 === void 0 ? void 0 : _this$options$uiConfi3.primaryButton) || "socialLogin"
|
|
@@ -282,101 +435,52 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
282
435
|
}
|
|
283
436
|
}));
|
|
284
437
|
}
|
|
285
|
-
async initExternalConnectors(
|
|
286
|
-
if (externalWalletsInitialized) return;
|
|
438
|
+
async initExternalConnectors(externalConnectors, options) {
|
|
287
439
|
const connectorsConfig = {};
|
|
288
440
|
// we do it like this because we don't want one slow connector to delay the load of the entire external wallet section.
|
|
289
|
-
|
|
441
|
+
externalConnectors.forEach(async connector => {
|
|
290
442
|
const connectorName = connector.name;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
this.subscribeToConnectorEvents(connector);
|
|
443
|
+
log.debug("init external wallet", this.cachedConnector, connectorName, connector.status);
|
|
444
|
+
if (connector.status === CONNECTOR_STATUS.NOT_READY) {
|
|
294
445
|
// we are not initializing cached connector here as it is already being initialized in initModal before.
|
|
295
|
-
if (this.cachedConnector === connectorName)
|
|
296
|
-
|
|
446
|
+
if (this.cachedConnector === connectorName) return;
|
|
447
|
+
try {
|
|
448
|
+
this.subscribeToConnectorEvents(connector);
|
|
449
|
+
const initialChain = this.getInitialChainIdForConnector(connector);
|
|
450
|
+
await connector.init({
|
|
451
|
+
autoConnect: this.cachedConnector === connectorName,
|
|
452
|
+
chainId: initialChain.chainId
|
|
453
|
+
});
|
|
454
|
+
const connectorModalConfig = this.modalConfig.connectors[connectorName];
|
|
455
|
+
connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
|
|
456
|
+
isInjected: connector.isInjected,
|
|
457
|
+
icon: connector.icon
|
|
458
|
+
});
|
|
459
|
+
this.loginModal.addWalletLogins(connectorsConfig, {
|
|
460
|
+
showExternalWalletsOnly: !!options.showExternalWalletsOnly,
|
|
461
|
+
externalWalletsVisibility: !!options.externalWalletsVisibility,
|
|
462
|
+
externalWalletsInitialized: !!options.externalWalletsInitialized
|
|
463
|
+
});
|
|
464
|
+
} catch (error) {
|
|
465
|
+
log.error(error, "error while initializing connector", connectorName);
|
|
297
466
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const initialChain = this.getInitialChainIdForConnector(connector);
|
|
301
|
-
await connector.init({
|
|
302
|
-
autoConnect: this.cachedConnector === connectorName,
|
|
303
|
-
chainId: initialChain.chainId
|
|
304
|
-
});
|
|
305
|
-
const connectorModalConfig = this.modalConfig.connectors[connectorName];
|
|
306
|
-
connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
|
|
307
|
-
isInjected: connector.isInjected
|
|
308
|
-
});
|
|
309
|
-
this.loginModal.addWalletLogins(connectorsConfig, {
|
|
310
|
-
showExternalWalletsOnly: !!(options !== null && options !== void 0 && options.showExternalWalletsOnly)
|
|
311
|
-
});
|
|
312
|
-
} catch (error) {
|
|
313
|
-
log.error(error, "error while initializing connector", connectorName);
|
|
314
|
-
}
|
|
315
|
-
} else if (connector.status === CONNECTOR_STATUS.READY || connector.status === CONNECTOR_STATUS.CONNECTING) {
|
|
467
|
+
} else {
|
|
468
|
+
if (connector.status === CONNECTOR_STATUS.READY || connector.status === CONNECTOR_STATUS.CONNECTING) {
|
|
316
469
|
// we use connecting status for wallet connect
|
|
317
470
|
const connectorModalConfig = this.modalConfig.connectors[connectorName];
|
|
318
471
|
connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
|
|
319
|
-
isInjected: connector.isInjected
|
|
472
|
+
isInjected: connector.isInjected,
|
|
473
|
+
icon: connector.icon
|
|
320
474
|
});
|
|
321
475
|
this.loginModal.addWalletLogins(connectorsConfig, {
|
|
322
|
-
showExternalWalletsOnly: !!
|
|
476
|
+
showExternalWalletsOnly: !!options.showExternalWalletsOnly,
|
|
477
|
+
externalWalletsVisibility: !!options.externalWalletsVisibility,
|
|
478
|
+
externalWalletsInitialized: !!options.externalWalletsInitialized
|
|
323
479
|
});
|
|
324
480
|
}
|
|
325
481
|
}
|
|
326
482
|
});
|
|
327
483
|
}
|
|
328
|
-
subscribeToLoginModalEvents() {
|
|
329
|
-
this.loginModal.on(LOGIN_MODAL_EVENTS.EXTERNAL_WALLET_LOGIN, async params => {
|
|
330
|
-
try {
|
|
331
|
-
await this.connectTo(params.connector);
|
|
332
|
-
} catch (error) {
|
|
333
|
-
log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
this.loginModal.on(LOGIN_MODAL_EVENTS.SOCIAL_LOGIN, async params => {
|
|
337
|
-
try {
|
|
338
|
-
await this.connectTo(params.connector, params.loginParams);
|
|
339
|
-
} catch (error) {
|
|
340
|
-
log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
this.loginModal.on(LOGIN_MODAL_EVENTS.INIT_EXTERNAL_WALLETS, async params => {
|
|
344
|
-
await this.initExternalConnectors(this.connectors, params.externalWalletsInitialized);
|
|
345
|
-
});
|
|
346
|
-
this.loginModal.on(LOGIN_MODAL_EVENTS.DISCONNECT, async () => {
|
|
347
|
-
try {
|
|
348
|
-
await this.logout();
|
|
349
|
-
} catch (error) {
|
|
350
|
-
log.error(`Error while disconnecting`, error);
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
this.loginModal.on(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, async visibility => {
|
|
354
|
-
log.debug("is login modal visible", visibility);
|
|
355
|
-
this.emit(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
|
|
356
|
-
const wcConnector = this.getConnector(WALLET_CONNECTORS.WALLET_CONNECT_V2);
|
|
357
|
-
if (wcConnector) {
|
|
358
|
-
const walletConnectStatus = wcConnector === null || wcConnector === void 0 ? void 0 : wcConnector.status;
|
|
359
|
-
log.debug("trying refreshing wc session", visibility, walletConnectStatus);
|
|
360
|
-
if (visibility && (walletConnectStatus === CONNECTOR_STATUS.READY || walletConnectStatus === CONNECTOR_STATUS.CONNECTING)) {
|
|
361
|
-
log.debug("refreshing wc session");
|
|
362
|
-
|
|
363
|
-
// refreshing session for wallet connect whenever modal is opened.
|
|
364
|
-
try {
|
|
365
|
-
const initialChain = this.getInitialChainIdForConnector(wcConnector);
|
|
366
|
-
wcConnector.connect({
|
|
367
|
-
chainId: initialChain.chainId
|
|
368
|
-
});
|
|
369
|
-
} catch (error) {
|
|
370
|
-
log.error(`Error while disconnecting to wallet connect in core`, error);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
if (!visibility && this.status === CONNECTOR_STATUS.CONNECTED && (walletConnectStatus === CONNECTOR_STATUS.READY || walletConnectStatus === CONNECTOR_STATUS.CONNECTING)) {
|
|
374
|
-
log.debug("this stops wc connector from trying to reconnect once proposal expires");
|
|
375
|
-
wcConnector.status = CONNECTOR_STATUS.READY;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
484
|
}
|
|
381
485
|
|
|
382
486
|
export { Web3Auth };
|