@web3auth/modal 10.0.0-beta.1 → 10.0.0-beta.11
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/README.md +2 -2
- package/dist/lib.cjs/packages/modal/src/config.js +3 -3
- package/dist/lib.cjs/packages/modal/src/index.js +1 -0
- package/dist/lib.cjs/packages/modal/src/modalManager.js +125 -75
- package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +8 -2
- package/dist/lib.cjs/packages/modal/src/react/context/WalletServicesInnerContext.js +72 -0
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +40 -96
- package/dist/lib.cjs/packages/modal/src/react/hooks/useCheckout.js +34 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useEnableMFA.js +30 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useIdentityToken.js +42 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useManageMFA.js +30 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useSwap.js +34 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useSwitchChain.js +32 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWalletConnectScanner.js +34 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWalletServicesPlugin.js +13 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWalletUI.js +34 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3Auth.js +21 -8
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthConnect.js +63 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthInner.js +15 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthUser.js +50 -0
- package/dist/lib.cjs/packages/modal/src/react/index.js +24 -3
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignMessage.js +37 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSignTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSolanaWallet.js +43 -0
- package/dist/lib.cjs/packages/modal/src/react/solana/index.js +13 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/index.js +7 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +195 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +3 -3
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +12 -4
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +27 -21
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +7 -4
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js +3 -2
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +13 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +14 -8
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +6 -9
- package/dist/lib.cjs/packages/modal/src/ui/components/Image/Image.js +5 -4
- package/dist/lib.cjs/packages/modal/src/ui/components/Loader/Loader.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +80 -42
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +10 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/Modal/Modal.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +3 -3
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +185 -128
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +15 -34
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +16 -3
- package/dist/lib.cjs/packages/modal/src/ui/config.js +2 -1
- package/dist/lib.cjs/packages/modal/src/ui/constants.js +30 -0
- package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +12 -3
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/handlers/AbstractHandler.js +6 -2
- package/dist/lib.cjs/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +7 -4
- package/dist/lib.cjs/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +2 -2
- package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +32 -31
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +31 -19
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +16 -4
- package/dist/lib.cjs/packages/modal/src/vue/WalletServicesInnerProvider.js +70 -0
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +38 -78
- package/dist/lib.cjs/packages/modal/src/vue/composables/useCheckout.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useEnableMFA.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useIdentityToken.js +44 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useManageMFA.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useSwap.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useSwitchChain.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletConnectScanner.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletServicesPlugin.js +13 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletUI.js +34 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3Auth.js +2 -4
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +66 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthDisconnect.js +32 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthInner.js +12 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthUser.js +53 -0
- package/dist/lib.cjs/packages/modal/src/vue/index.js +24 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignMessage.js +38 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignTransaction.js +36 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSolanaWallet.js +53 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/index.js +13 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/index.js +7 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +233 -0
- package/dist/lib.cjs/types/config.d.ts +1 -0
- package/dist/lib.cjs/types/interface.d.ts +2 -3
- package/dist/lib.cjs/types/modalManager.d.ts +7 -3
- package/dist/lib.cjs/types/react/Web3AuthProvider.d.ts +1 -1
- package/dist/lib.cjs/types/react/context/WalletServicesInnerContext.d.ts +6 -0
- package/dist/lib.cjs/types/react/hooks/index.d.ts +13 -1
- package/dist/lib.cjs/types/react/hooks/useCheckout.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useEnableMFA.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useIdentityToken.d.ts +13 -0
- package/dist/lib.cjs/types/react/hooks/useManageMFA.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useSwap.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useSwitchChain.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/useWalletConnectScanner.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useWalletServicesPlugin.d.ts +2 -0
- package/dist/lib.cjs/types/react/hooks/useWalletUI.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3Auth.d.ts +2 -1
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthConnect.d.ts +10 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthDisconnect.d.ts +9 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthInner.d.ts +2 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthUser.d.ts +9 -0
- package/dist/lib.cjs/types/react/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/interfaces.d.ts +7 -2
- package/dist/lib.cjs/types/react/solana/hooks/index.d.ts +4 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignAndSendTransaction.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignMessage.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignTransaction.d.ts +13 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSolanaWallet.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/react/wagmi/index.d.ts +2 -0
- package/dist/lib.cjs/types/react/wagmi/interface.d.ts +4 -0
- package/dist/lib.cjs/types/react/wagmi/provider.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +1 -0
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.type.d.ts +3 -4
- package/dist/lib.cjs/types/ui/components/Login/Login.type.d.ts +2 -2
- package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.type.d.ts +3 -2
- package/dist/lib.cjs/types/ui/config.d.ts +1 -1
- package/dist/lib.cjs/types/ui/constants.d.ts +4 -0
- package/dist/lib.cjs/types/ui/context/RootContext.d.ts +12 -3
- package/dist/lib.cjs/types/ui/handlers/AbstractHandler.d.ts +3 -2
- package/dist/lib.cjs/types/ui/handlers/EmailPasswordlessHandler.d.ts +3 -1
- package/dist/lib.cjs/types/ui/interfaces.d.ts +15 -7
- package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -1
- package/dist/lib.cjs/types/ui/utils.d.ts +2 -2
- package/dist/lib.cjs/types/vue/WalletServicesInnerProvider.d.ts +1 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +12 -0
- package/dist/lib.cjs/types/vue/composables/useCheckout.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useEnableMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useIdentityToken.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useManageMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useSwap.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useSwitchChain.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWalletConnectScanner.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWalletServicesPlugin.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWalletUI.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3Auth.d.ts +3 -2
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +11 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthDisconnect.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthInner.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthUser.d.ts +10 -0
- package/dist/lib.cjs/types/vue/interfaces.d.ts +10 -18
- package/dist/lib.cjs/types/vue/solana/composables/index.d.ts +4 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignAndSendTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignMessage.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSolanaWallet.d.ts +9 -0
- package/dist/lib.cjs/types/vue/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/vue/wagmi/index.d.ts +2 -0
- package/dist/lib.cjs/types/vue/wagmi/interface.d.ts +4 -0
- package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +17 -0
- package/dist/lib.esm/packages/modal/src/config.js +3 -4
- package/dist/lib.esm/packages/modal/src/index.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +136 -76
- package/dist/lib.esm/packages/modal/src/react/Web3AuthProvider.js +9 -3
- package/dist/lib.esm/packages/modal/src/react/context/WalletServicesInnerContext.js +69 -0
- package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +42 -98
- package/dist/lib.esm/packages/modal/src/react/hooks/useCheckout.js +32 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useEnableMFA.js +28 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useIdentityToken.js +40 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useManageMFA.js +28 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useSwap.js +32 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useSwitchChain.js +30 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWalletConnectScanner.js +32 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWalletServicesPlugin.js +11 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWalletUI.js +32 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3Auth.js +21 -8
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthConnect.js +61 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthDisconnect.js +28 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthInner.js +13 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthUser.js +48 -0
- package/dist/lib.esm/packages/modal/src/react/index.js +12 -1
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignAndSendTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignMessage.js +35 -0
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSignTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSolanaWallet.js +41 -0
- package/dist/lib.esm/packages/modal/src/react/solana/index.js +4 -0
- package/dist/lib.esm/packages/modal/src/react/wagmi/constants.js +14 -0
- package/dist/lib.esm/packages/modal/src/react/wagmi/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +194 -0
- package/dist/lib.esm/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +3 -3
- package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +14 -6
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +27 -21
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +7 -4
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js +3 -2
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +13 -5
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +15 -9
- package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +6 -9
- package/dist/lib.esm/packages/modal/src/ui/components/Image/Image.js +5 -4
- package/dist/lib.esm/packages/modal/src/ui/components/Loader/Loader.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +84 -42
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +12 -9
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +11 -6
- package/dist/lib.esm/packages/modal/src/ui/components/Modal/Modal.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +3 -3
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +189 -131
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +16 -35
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +18 -4
- package/dist/lib.esm/packages/modal/src/ui/config.js +2 -1
- package/dist/lib.esm/packages/modal/src/ui/constants.js +28 -1
- package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +12 -3
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/handlers/AbstractHandler.js +5 -1
- package/dist/lib.esm/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +7 -4
- package/dist/lib.esm/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +2 -2
- package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +32 -31
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +33 -21
- package/dist/lib.esm/packages/modal/src/ui/utils.js +16 -4
- package/dist/lib.esm/packages/modal/src/vue/WalletServicesInnerProvider.js +69 -0
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +40 -79
- package/dist/lib.esm/packages/modal/src/vue/composables/useCheckout.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useEnableMFA.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useIdentityToken.js +42 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useManageMFA.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useSwap.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useSwitchChain.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletConnectScanner.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletServicesPlugin.js +11 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletUI.js +32 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3Auth.js +2 -4
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +64 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthInner.js +10 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthUser.js +51 -0
- package/dist/lib.esm/packages/modal/src/vue/index.js +12 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignMessage.js +36 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignTransaction.js +34 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSolanaWallet.js +51 -0
- package/dist/lib.esm/packages/modal/src/vue/solana/index.js +4 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/constants.js +14 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +234 -0
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +0 -26
- package/package.json +67 -19
- package/dist/lib.cjs/types/react/context/index.d.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import {
|
|
3
|
+
import { serializeError } from '@web3auth/auth';
|
|
4
|
+
import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, LOGIN_MODE, log, CONNECTOR_STATUS, withAbort, CONNECTOR_EVENTS, WalletInitializationError, fetchProjectConfig, fetchWalletRegistry, CONNECTOR_CATEGORY, CONNECTOR_NAMES, CONNECTOR_NAMESPACES } from '@web3auth/no-modal';
|
|
4
5
|
import deepmerge from 'deepmerge';
|
|
5
6
|
import { defaultConnectorsModalConfig, walletRegistryUrl } from './config.js';
|
|
6
7
|
import { AUTH_PROVIDERS_NAMES, AUTH_PROVIDERS, capitalizeFirstLetter } from './ui/config.js';
|
|
@@ -9,8 +10,8 @@ import { LoginModal } from './ui/loginModal.js';
|
|
|
9
10
|
import { getUserLanguage } from './ui/utils.js';
|
|
10
11
|
|
|
11
12
|
class Web3Auth extends Web3AuthNoModal {
|
|
12
|
-
constructor(options) {
|
|
13
|
-
super(options);
|
|
13
|
+
constructor(options, initialState) {
|
|
14
|
+
super(options, initialState);
|
|
14
15
|
_defineProperty(this, "loginModal", void 0);
|
|
15
16
|
_defineProperty(this, "options", void 0);
|
|
16
17
|
_defineProperty(this, "modalConfig", cloneDeep(defaultConnectorsModalConfig));
|
|
@@ -24,14 +25,14 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
24
25
|
});
|
|
25
26
|
_defineProperty(this, "onSocialLogin", async params => {
|
|
26
27
|
try {
|
|
27
|
-
await this.connectTo(
|
|
28
|
+
await this.connectTo(WALLET_CONNECTORS.AUTH, params.loginParams, LOGIN_MODE.MODAL);
|
|
28
29
|
} catch (error) {
|
|
29
30
|
log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
_defineProperty(this, "onExternalWalletLogin", async params => {
|
|
33
34
|
try {
|
|
34
|
-
await this.connectTo(params.connector, params.loginParams);
|
|
35
|
+
await this.connectTo(params.connector, params.loginParams, LOGIN_MODE.MODAL);
|
|
35
36
|
} catch (error) {
|
|
36
37
|
log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
37
38
|
}
|
|
@@ -39,6 +40,8 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
39
40
|
_defineProperty(this, "onModalVisibility", async visibility => {
|
|
40
41
|
log.debug("is login modal visible", visibility);
|
|
41
42
|
this.emit(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
|
|
43
|
+
|
|
44
|
+
// handle WC session refresh
|
|
42
45
|
const wcConnector = this.getConnector(WALLET_CONNECTORS.WALLET_CONNECT_V2);
|
|
43
46
|
if (wcConnector) {
|
|
44
47
|
const walletConnectStatus = wcConnector === null || wcConnector === void 0 ? void 0 : wcConnector.status;
|
|
@@ -61,26 +64,53 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
61
64
|
wcConnector.status = CONNECTOR_STATUS.READY;
|
|
62
65
|
}
|
|
63
66
|
}
|
|
67
|
+
|
|
68
|
+
// handle MM session refresh if MM is not injected
|
|
69
|
+
const metamaskConnector = this.getConnector(WALLET_CONNECTORS.METAMASK);
|
|
70
|
+
if (metamaskConnector && !metamaskConnector.isInjected) {
|
|
71
|
+
const status = metamaskConnector === null || metamaskConnector === void 0 ? void 0 : metamaskConnector.status;
|
|
72
|
+
log.debug("trying refreshing MM session", visibility, status);
|
|
73
|
+
if (visibility && (status === CONNECTOR_STATUS.READY || status === CONNECTOR_STATUS.CONNECTING)) {
|
|
74
|
+
log.debug("refreshing MM session");
|
|
75
|
+
|
|
76
|
+
// refreshing session for MM whenever modal is opened.
|
|
77
|
+
try {
|
|
78
|
+
const initialChain = this.getInitialChainIdForConnector(metamaskConnector);
|
|
79
|
+
metamaskConnector.connect({
|
|
80
|
+
chainId: initialChain.chainId
|
|
81
|
+
});
|
|
82
|
+
} catch (error) {
|
|
83
|
+
log.error(`Error while connecting to MM`, error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!visibility && this.status === CONNECTOR_STATUS.CONNECTED && (status === CONNECTOR_STATUS.READY || status === CONNECTOR_STATUS.CONNECTING)) {
|
|
87
|
+
log.debug("this stops MM connector from trying to reconnect once proposal expires");
|
|
88
|
+
metamaskConnector.status = CONNECTOR_STATUS.READY;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
_defineProperty(this, "getChainNamespaces", () => {
|
|
93
|
+
var _this$coreOptions$cha;
|
|
94
|
+
return [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])];
|
|
64
95
|
});
|
|
65
96
|
this.options = _objectSpread({}, options);
|
|
66
97
|
if (!this.options.uiConfig) this.options.uiConfig = {};
|
|
67
98
|
if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
|
|
68
99
|
log.info("modalConfig", this.modalConfig);
|
|
69
100
|
}
|
|
70
|
-
async
|
|
71
|
-
|
|
101
|
+
async init(options) {
|
|
102
|
+
const {
|
|
103
|
+
signal
|
|
104
|
+
} = options || {};
|
|
72
105
|
super.checkInitRequirements();
|
|
73
106
|
// get project config and wallet registry
|
|
74
107
|
const {
|
|
75
108
|
projectConfig,
|
|
76
109
|
walletRegistry
|
|
77
110
|
} = await this.getProjectAndWalletConfig();
|
|
78
|
-
this.options.uiConfig = deepmerge(cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
|
|
79
|
-
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
80
|
-
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
|
|
81
|
-
this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig || {});
|
|
82
111
|
|
|
83
112
|
// init config
|
|
113
|
+
this.initUIConfig(projectConfig);
|
|
84
114
|
super.initAccountAbstractionConfig(projectConfig);
|
|
85
115
|
super.initChainsConfig(projectConfig);
|
|
86
116
|
super.initCachedConnectorAndChainId();
|
|
@@ -94,7 +124,8 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
94
124
|
connectorListener: this,
|
|
95
125
|
web3authClientId: this.options.clientId,
|
|
96
126
|
web3authNetwork: this.options.web3AuthNetwork,
|
|
97
|
-
|
|
127
|
+
authBuildEnv: this.options.authBuildEnv,
|
|
128
|
+
chainNamespaces: this.getChainNamespaces(),
|
|
98
129
|
walletRegistry: filteredWalletRegistry
|
|
99
130
|
}), {
|
|
100
131
|
onInitExternalWallets: this.onInitExternalWallets,
|
|
@@ -102,25 +133,35 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
102
133
|
onExternalWalletLogin: this.onExternalWalletLogin,
|
|
103
134
|
onModalVisibility: this.onModalVisibility
|
|
104
135
|
});
|
|
105
|
-
await this.loginModal.initModal();
|
|
136
|
+
await withAbort(() => this.loginModal.initModal(), signal);
|
|
106
137
|
|
|
107
138
|
// setup common JRPC provider
|
|
108
|
-
await this.setupCommonJRPCProvider();
|
|
139
|
+
await withAbort(() => this.setupCommonJRPCProvider(), signal);
|
|
109
140
|
|
|
110
141
|
// initialize connectors
|
|
111
142
|
this.on(CONNECTOR_EVENTS.CONNECTORS_UPDATED, ({
|
|
112
143
|
connectors: newConnectors
|
|
113
|
-
}) =>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
144
|
+
}) => {
|
|
145
|
+
const onAbortHandler = () => {
|
|
146
|
+
var _this$connectors;
|
|
147
|
+
log.debug("init aborted");
|
|
148
|
+
if (((_this$connectors = this.connectors) === null || _this$connectors === void 0 ? void 0 : _this$connectors.length) > 0) {
|
|
149
|
+
super.cleanup();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
withAbort(() => this.initConnectors({
|
|
153
|
+
connectors: newConnectors,
|
|
154
|
+
projectConfig,
|
|
155
|
+
disabledExternalWallets
|
|
156
|
+
}), signal, onAbortHandler);
|
|
120
157
|
});
|
|
158
|
+
await withAbort(() => super.loadConnectors({
|
|
159
|
+
projectConfig,
|
|
160
|
+
modalMode: true
|
|
161
|
+
}), signal);
|
|
121
162
|
|
|
122
163
|
// initialize plugins
|
|
123
|
-
await
|
|
164
|
+
await withAbort(() => super.initPlugins(), signal);
|
|
124
165
|
}
|
|
125
166
|
async connect() {
|
|
126
167
|
if (!this.loginModal) throw WalletInitializationError.notReady("Login modal is not initialized");
|
|
@@ -183,32 +224,33 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
183
224
|
};
|
|
184
225
|
}
|
|
185
226
|
async getProjectAndWalletConfig() {
|
|
186
|
-
var _this$modalConfig;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
throw WalletInitializationError.notReady("failed to fetch project configurations", e);
|
|
227
|
+
var _this$options$account, _this$modalConfig;
|
|
228
|
+
const [projectConfigResult, walletRegistryResult] = await Promise.allSettled([fetchProjectConfig({
|
|
229
|
+
clientId: this.options.clientId,
|
|
230
|
+
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
231
|
+
aaProvider: (_this$options$account = this.options.accountAbstractionConfig) === null || _this$options$account === void 0 ? void 0 : _this$options$account.smartAccountType,
|
|
232
|
+
authBuildEnv: this.options.authBuildEnv
|
|
233
|
+
}), fetchWalletRegistry(walletRegistryUrl)]);
|
|
234
|
+
|
|
235
|
+
// handle project config result
|
|
236
|
+
if (projectConfigResult.status === "rejected") {
|
|
237
|
+
const error = await serializeError(projectConfigResult.reason);
|
|
238
|
+
log.error("Failed to fetch project configurations", error);
|
|
239
|
+
throw WalletInitializationError.notReady("failed to fetch project configurations", error);
|
|
200
240
|
}
|
|
201
|
-
|
|
241
|
+
const projectConfig = projectConfigResult.value;
|
|
242
|
+
|
|
243
|
+
// handle wallet registry result
|
|
202
244
|
let walletRegistry = {
|
|
203
245
|
others: {},
|
|
204
246
|
default: {}
|
|
205
247
|
};
|
|
206
248
|
const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
|
|
207
249
|
if (isExternalWalletEnabled && !((_this$modalConfig = this.modalConfig) !== null && _this$modalConfig !== void 0 && _this$modalConfig.hideWalletDiscovery)) {
|
|
208
|
-
|
|
209
|
-
walletRegistry =
|
|
210
|
-
}
|
|
211
|
-
log.error("Failed to fetch wallet registry",
|
|
250
|
+
if (walletRegistryResult.status === "fulfilled") {
|
|
251
|
+
walletRegistry = walletRegistryResult.value;
|
|
252
|
+
} else {
|
|
253
|
+
log.error("Failed to fetch wallet registry", walletRegistryResult.reason);
|
|
212
254
|
}
|
|
213
255
|
}
|
|
214
256
|
return {
|
|
@@ -216,6 +258,26 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
216
258
|
walletRegistry
|
|
217
259
|
};
|
|
218
260
|
}
|
|
261
|
+
initUIConfig(projectConfig) {
|
|
262
|
+
this.options.uiConfig = deepmerge(cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
|
|
263
|
+
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
264
|
+
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
|
|
265
|
+
this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
|
|
266
|
+
arrayMerge: (_, sourceArray) => sourceArray
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// merge login methods order from project config and user config, with user config taking precedence
|
|
270
|
+
const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
|
|
271
|
+
const mergedAuthConnections = [...(this.options.uiConfig.loginMethodsOrder || []), ...defaultAuthConnections];
|
|
272
|
+
const loginMethodsOrder = [];
|
|
273
|
+
const authConnectionSet = new Set();
|
|
274
|
+
for (const authConnection of mergedAuthConnections) {
|
|
275
|
+
if (authConnectionSet.has(authConnection)) continue;
|
|
276
|
+
authConnectionSet.add(authConnection);
|
|
277
|
+
loginMethodsOrder.push(authConnection);
|
|
278
|
+
}
|
|
279
|
+
this.options.uiConfig.loginMethodsOrder = loginMethodsOrder;
|
|
280
|
+
}
|
|
219
281
|
async initConnectors({
|
|
220
282
|
connectors,
|
|
221
283
|
projectConfig,
|
|
@@ -285,9 +347,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
285
347
|
groupedAuthConnectionId: groupedAuthConnectionId,
|
|
286
348
|
extraLoginOptions: authConnectionConfig.jwtParameters,
|
|
287
349
|
isDefault: true,
|
|
288
|
-
showOnModal: true
|
|
289
|
-
showOnDesktop: true,
|
|
290
|
-
showOnMobile: true
|
|
350
|
+
showOnModal: true
|
|
291
351
|
};
|
|
292
352
|
}
|
|
293
353
|
embedWalletConfigMap.set(groupedAuthConnectionId || authConnectionId, authConnectionConfig);
|
|
@@ -336,9 +396,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
336
396
|
// start with the default config of connector.
|
|
337
397
|
const defaultConnectorConfig = {
|
|
338
398
|
label: CONNECTOR_NAMES[connectorName] || connectorName.split("-").map(capitalizeFirstLetter).join(" "),
|
|
339
|
-
showOnModal: true
|
|
340
|
-
showOnMobile: true,
|
|
341
|
-
showOnDesktop: true
|
|
399
|
+
showOnModal: true
|
|
342
400
|
};
|
|
343
401
|
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]) || {});
|
|
344
402
|
|
|
@@ -392,7 +450,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
392
450
|
const hasExternalConnectors = connectorNames.some(connectorName => {
|
|
393
451
|
var _this$getConnector, _this$modalConfig$con5;
|
|
394
452
|
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
|
|
453
|
+
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 || (_this$modalConfig$con5 = _this$modalConfig$con5[connectorName]) === null || _this$modalConfig$con5 === void 0 ? void 0 : _this$modalConfig$con5.showOnModal);
|
|
396
454
|
});
|
|
397
455
|
return {
|
|
398
456
|
hasInAppConnectors,
|
|
@@ -407,7 +465,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
407
465
|
if (connector.status !== CONNECTOR_STATUS.NOT_READY) return;
|
|
408
466
|
|
|
409
467
|
// only initialize a external connectors here if it is a cached connector.
|
|
410
|
-
if (this.cachedConnector !== connectorName &&
|
|
468
|
+
if (this.cachedConnector !== connectorName && connector.type === CONNECTOR_CATEGORY.EXTERNAL) return;
|
|
411
469
|
|
|
412
470
|
// in-app wallets or cached wallet (being connected or already connected) are initialized first.
|
|
413
471
|
// if connector is configured then only initialize in app or cached connector.
|
|
@@ -437,13 +495,24 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
437
495
|
}
|
|
438
496
|
async initExternalConnectors(externalConnectors, options) {
|
|
439
497
|
const connectorsConfig = {};
|
|
498
|
+
const connectorChainNamespaceMap = {};
|
|
499
|
+
|
|
440
500
|
// we do it like this because we don't want one slow connector to delay the load of the entire external wallet section.
|
|
441
501
|
externalConnectors.forEach(async connector => {
|
|
442
502
|
const connectorName = connector.name;
|
|
443
503
|
log.debug("init external wallet", this.cachedConnector, connectorName, connector.status);
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
504
|
+
|
|
505
|
+
// a wallet can support multiple chain namespaces e.g. Phantom has EvmInjected connector and WalletStandard connector.
|
|
506
|
+
if (!connectorChainNamespaceMap[connectorName]) connectorChainNamespaceMap[connectorName] = new Set();
|
|
507
|
+
if (connector.connectorNamespace === CONNECTOR_NAMESPACES.MULTICHAIN) {
|
|
508
|
+
this.getChainNamespaces().forEach(x => connectorChainNamespaceMap[connectorName].add(x));
|
|
509
|
+
} else {
|
|
510
|
+
connectorChainNamespaceMap[connectorName].add(connector.connectorNamespace);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// initialize connectors
|
|
514
|
+
// skip initializing cached connector here as it is already being initialized in initModal before.
|
|
515
|
+
if (connector.status === CONNECTOR_STATUS.NOT_READY && this.cachedConnector !== connectorName) {
|
|
447
516
|
try {
|
|
448
517
|
this.subscribeToConnectorEvents(connector);
|
|
449
518
|
const initialChain = this.getInitialChainIdForConnector(connector);
|
|
@@ -451,33 +520,24 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
451
520
|
autoConnect: this.cachedConnector === connectorName,
|
|
452
521
|
chainId: initialChain.chainId
|
|
453
522
|
});
|
|
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
523
|
} catch (error) {
|
|
465
524
|
log.error(error, "error while initializing connector", connectorName);
|
|
466
525
|
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// update connector config
|
|
529
|
+
if ([CONNECTOR_STATUS.NOT_READY, CONNECTOR_STATUS.READY, CONNECTOR_STATUS.CONNECTING].includes(connector.status)) {
|
|
530
|
+
const connectorModalConfig = this.modalConfig.connectors[connectorName];
|
|
531
|
+
connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
|
|
532
|
+
isInjected: connector.isInjected,
|
|
533
|
+
icon: connector.icon,
|
|
534
|
+
chainNamespaces: Array.from(connectorChainNamespaceMap[connectorName])
|
|
535
|
+
});
|
|
536
|
+
this.loginModal.addWalletLogins(connectorsConfig, {
|
|
537
|
+
showExternalWalletsOnly: !!options.showExternalWalletsOnly,
|
|
538
|
+
externalWalletsVisibility: !!options.externalWalletsVisibility,
|
|
539
|
+
externalWalletsInitialized: !!options.externalWalletsInitialized
|
|
540
|
+
});
|
|
481
541
|
}
|
|
482
542
|
});
|
|
483
543
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WalletServicesContextProvider } from './context/WalletServicesInnerContext.js';
|
|
3
|
+
import { Web3AuthInnerProvider, Web3AuthInnerContext } from './context/Web3AuthInnerContext.js';
|
|
3
4
|
|
|
4
5
|
function Web3AuthProvider({
|
|
5
6
|
config,
|
|
7
|
+
initialState,
|
|
6
8
|
children
|
|
7
9
|
}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
const pluginChild = /*#__PURE__*/createElement(WalletServicesContextProvider, {
|
|
11
|
+
context: Web3AuthInnerContext
|
|
10
12
|
}, children);
|
|
13
|
+
return /*#__PURE__*/createElement(Web3AuthInnerProvider, {
|
|
14
|
+
config,
|
|
15
|
+
initialState
|
|
16
|
+
}, pluginChild);
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
export { Web3AuthProvider };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { EVM_PLUGINS, CONNECTOR_STATUS, PLUGIN_EVENTS } from '@web3auth/no-modal';
|
|
2
|
+
import { createContext, useContext, useState, useEffect, useMemo, createElement } from 'react';
|
|
3
|
+
|
|
4
|
+
const WalletServicesContext = /*#__PURE__*/createContext(null);
|
|
5
|
+
function WalletServicesContextProvider({
|
|
6
|
+
children,
|
|
7
|
+
context
|
|
8
|
+
}) {
|
|
9
|
+
const web3AuthContext = useContext(context);
|
|
10
|
+
const {
|
|
11
|
+
getPlugin,
|
|
12
|
+
isInitialized,
|
|
13
|
+
isConnected
|
|
14
|
+
} = web3AuthContext;
|
|
15
|
+
const [ready, setReady] = useState(false);
|
|
16
|
+
const [connecting, setConnecting] = useState(false);
|
|
17
|
+
const [walletServicesPlugin, setWalletServicesPlugin] = useState(null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (isInitialized) {
|
|
20
|
+
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
|
|
21
|
+
setWalletServicesPlugin(plugin);
|
|
22
|
+
}
|
|
23
|
+
}, [isInitialized, getPlugin]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (isConnected) {
|
|
26
|
+
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
|
|
27
|
+
setWalletServicesPlugin(plugin);
|
|
28
|
+
// when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
|
|
29
|
+
if ((plugin === null || plugin === void 0 ? void 0 : plugin.status) === CONNECTOR_STATUS.CONNECTED) setReady(true);
|
|
30
|
+
}
|
|
31
|
+
}, [isConnected, getPlugin, walletServicesPlugin]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const connectedListener = () => {
|
|
34
|
+
setReady(true);
|
|
35
|
+
setConnecting(false);
|
|
36
|
+
};
|
|
37
|
+
const disconnectedListener = () => {
|
|
38
|
+
setReady(false);
|
|
39
|
+
setConnecting(false);
|
|
40
|
+
};
|
|
41
|
+
const connectingListener = () => {
|
|
42
|
+
setConnecting(true);
|
|
43
|
+
};
|
|
44
|
+
if (walletServicesPlugin) {
|
|
45
|
+
walletServicesPlugin.on(PLUGIN_EVENTS.CONNECTED, connectedListener);
|
|
46
|
+
walletServicesPlugin.on(PLUGIN_EVENTS.DISCONNECTED, disconnectedListener);
|
|
47
|
+
walletServicesPlugin.on(PLUGIN_EVENTS.CONNECTING, connectingListener);
|
|
48
|
+
}
|
|
49
|
+
return () => {
|
|
50
|
+
if (walletServicesPlugin) {
|
|
51
|
+
walletServicesPlugin.off(PLUGIN_EVENTS.CONNECTED, connectedListener);
|
|
52
|
+
walletServicesPlugin.off(PLUGIN_EVENTS.DISCONNECTED, disconnectedListener);
|
|
53
|
+
walletServicesPlugin.off(PLUGIN_EVENTS.CONNECTING, connectingListener);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, [walletServicesPlugin]);
|
|
57
|
+
const value = useMemo(() => {
|
|
58
|
+
return {
|
|
59
|
+
plugin: walletServicesPlugin,
|
|
60
|
+
ready,
|
|
61
|
+
connecting
|
|
62
|
+
};
|
|
63
|
+
}, [walletServicesPlugin, ready, connecting]);
|
|
64
|
+
return /*#__PURE__*/createElement(WalletServicesContext.Provider, {
|
|
65
|
+
value
|
|
66
|
+
}, children);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { WalletServicesContext, WalletServicesContextProvider };
|
|
@@ -1,91 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createContext, useState, useCallback, useEffect,
|
|
1
|
+
import { CONNECTOR_STATUS, WalletInitializationError, CONNECTOR_EVENTS } from '@web3auth/no-modal';
|
|
2
|
+
import { createContext, useState, useMemo, useCallback, useEffect, createElement } from 'react';
|
|
3
3
|
import { Web3Auth } from '../../modalManager.js';
|
|
4
4
|
|
|
5
5
|
const Web3AuthInnerContext = /*#__PURE__*/createContext(null);
|
|
6
6
|
function Web3AuthInnerProvider(params) {
|
|
7
7
|
const {
|
|
8
8
|
children,
|
|
9
|
-
config
|
|
9
|
+
config,
|
|
10
|
+
initialState
|
|
10
11
|
} = params;
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const {
|
|
13
|
+
web3AuthOptions
|
|
14
|
+
} = config;
|
|
13
15
|
const [isInitializing, setIsInitializing] = useState(false);
|
|
14
16
|
const [initError, setInitError] = useState(null);
|
|
15
|
-
const [connectError, setConnectError] = useState(null);
|
|
16
|
-
const [isConnected, setIsConnected] = useState(false);
|
|
17
17
|
const [provider, setProvider] = useState(null);
|
|
18
|
-
const [userInfo, setUserInfo] = useState(null);
|
|
19
|
-
const [isMFAEnabled, setIsMFAEnabled] = useState(false);
|
|
20
18
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
21
|
-
const [
|
|
19
|
+
const [isMFAEnabled, setIsMFAEnabled] = useState(false);
|
|
20
|
+
const web3Auth = useMemo(() => {
|
|
21
|
+
setProvider(null);
|
|
22
|
+
return new Web3Auth(web3AuthOptions, initialState);
|
|
23
|
+
}, [web3AuthOptions, initialState]);
|
|
24
|
+
const [isConnected, setIsConnected] = useState(web3Auth.status === CONNECTOR_STATUS.CONNECTED);
|
|
25
|
+
const [status, setStatus] = useState(web3Auth.status);
|
|
22
26
|
const getPlugin = useCallback(name => {
|
|
23
27
|
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
24
28
|
return web3Auth.getPlugin(name);
|
|
25
29
|
}, [web3Auth]);
|
|
26
|
-
const enableMFA = useCallback(async loginParams => {
|
|
27
|
-
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
28
|
-
if (!isConnected) throw WalletLoginError.notConnectedError();
|
|
29
|
-
await web3Auth.enableMFA(loginParams);
|
|
30
|
-
const localUserInfo = await web3Auth.getUserInfo();
|
|
31
|
-
setUserInfo(localUserInfo);
|
|
32
|
-
setIsMFAEnabled(localUserInfo.isMfaEnabled || false);
|
|
33
|
-
}, [web3Auth, isConnected]);
|
|
34
|
-
const manageMFA = useCallback(async loginParams => {
|
|
35
|
-
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
36
|
-
if (!isConnected) throw WalletLoginError.notConnectedError();
|
|
37
|
-
await web3Auth.manageMFA(loginParams);
|
|
38
|
-
}, [web3Auth, isConnected]);
|
|
39
|
-
const logout = useCallback(async (logoutParams = {
|
|
40
|
-
cleanup: false
|
|
41
|
-
}) => {
|
|
42
|
-
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
43
|
-
if (!isConnected) throw WalletLoginError.notConnectedError();
|
|
44
|
-
await web3Auth.logout(logoutParams);
|
|
45
|
-
}, [web3Auth, isConnected]);
|
|
46
|
-
const connect = useCallback(async () => {
|
|
47
|
-
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
48
|
-
try {
|
|
49
|
-
setConnectError(null);
|
|
50
|
-
setIsConnecting(true);
|
|
51
|
-
const localProvider = await web3Auth.connect();
|
|
52
|
-
return localProvider;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
setConnectError(error);
|
|
55
|
-
throw error;
|
|
56
|
-
} finally {
|
|
57
|
-
setIsConnecting(false);
|
|
58
|
-
}
|
|
59
|
-
}, [web3Auth]);
|
|
60
|
-
const authenticateUser = useCallback(async () => {
|
|
61
|
-
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
62
|
-
return web3Auth.authenticateUser();
|
|
63
|
-
}, [web3Auth]);
|
|
64
|
-
const switchChain = useCallback(chainParams => {
|
|
65
|
-
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
66
|
-
return web3Auth.switchChain(chainParams);
|
|
67
|
-
}, [web3Auth]);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
const resetHookState = () => {
|
|
70
|
-
setProvider(null);
|
|
71
|
-
setUserInfo(null);
|
|
72
|
-
setIsMFAEnabled(false);
|
|
73
|
-
setIsConnected(false);
|
|
74
|
-
setStatus(null);
|
|
75
|
-
};
|
|
76
|
-
resetHookState();
|
|
77
|
-
const {
|
|
78
|
-
web3AuthOptions
|
|
79
|
-
} = config;
|
|
80
|
-
const web3AuthInstance = new Web3Auth(web3AuthOptions);
|
|
81
|
-
setWeb3Auth(web3AuthInstance);
|
|
82
|
-
}, [config]);
|
|
83
30
|
useEffect(() => {
|
|
31
|
+
const controller = new AbortController();
|
|
84
32
|
async function init() {
|
|
85
33
|
try {
|
|
86
34
|
setInitError(null);
|
|
87
35
|
setIsInitializing(true);
|
|
88
|
-
await web3Auth.
|
|
36
|
+
await web3Auth.init({
|
|
37
|
+
signal: controller.signal
|
|
38
|
+
});
|
|
89
39
|
} catch (error) {
|
|
90
40
|
setInitError(error);
|
|
91
41
|
} finally {
|
|
@@ -93,46 +43,43 @@ function Web3AuthInnerProvider(params) {
|
|
|
93
43
|
}
|
|
94
44
|
}
|
|
95
45
|
if (web3Auth) init();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const addState = async () => {
|
|
99
|
-
setProvider(web3Auth.provider);
|
|
100
|
-
const userState = await web3Auth.getUserInfo();
|
|
101
|
-
setUserInfo(userState);
|
|
102
|
-
setIsMFAEnabled((userState === null || userState === void 0 ? void 0 : userState.isMfaEnabled) || false);
|
|
103
|
-
};
|
|
104
|
-
const resetState = () => {
|
|
105
|
-
setProvider(null);
|
|
106
|
-
setUserInfo(null);
|
|
107
|
-
setIsMFAEnabled(false);
|
|
46
|
+
return () => {
|
|
47
|
+
controller.abort();
|
|
108
48
|
};
|
|
109
|
-
|
|
110
|
-
if (isConnected) addState();else resetState();
|
|
111
|
-
}
|
|
112
|
-
}, [web3Auth, isConnected]);
|
|
49
|
+
}, [web3Auth, config]);
|
|
113
50
|
useEffect(() => {
|
|
114
51
|
const notReadyListener = () => setStatus(web3Auth.status);
|
|
115
52
|
const readyListener = () => {
|
|
116
53
|
setStatus(web3Auth.status);
|
|
117
54
|
setIsInitialized(true);
|
|
118
55
|
};
|
|
119
|
-
const connectedListener =
|
|
56
|
+
const connectedListener = data => {
|
|
120
57
|
setStatus(web3Auth.status);
|
|
121
58
|
// we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
|
|
122
59
|
if (web3Auth.status === CONNECTOR_STATUS.CONNECTED) {
|
|
123
60
|
setIsInitialized(true);
|
|
124
61
|
setIsConnected(true);
|
|
62
|
+
setProvider(data.provider);
|
|
125
63
|
}
|
|
126
64
|
};
|
|
127
65
|
const disconnectedListener = () => {
|
|
128
66
|
setStatus(web3Auth.status);
|
|
129
67
|
setIsConnected(false);
|
|
68
|
+
setProvider(null);
|
|
130
69
|
};
|
|
131
70
|
const connectingListener = () => {
|
|
132
71
|
setStatus(web3Auth.status);
|
|
133
72
|
};
|
|
134
73
|
const errorListener = () => {
|
|
135
|
-
setStatus(
|
|
74
|
+
setStatus(web3Auth.status);
|
|
75
|
+
};
|
|
76
|
+
const rehydrationErrorListener = () => {
|
|
77
|
+
setStatus(web3Auth.status);
|
|
78
|
+
setIsConnected(false);
|
|
79
|
+
setProvider(null);
|
|
80
|
+
};
|
|
81
|
+
const mfaEnabledListener = isMFAEnabled => {
|
|
82
|
+
if (typeof isMFAEnabled === "boolean") setIsMFAEnabled(isMFAEnabled);
|
|
136
83
|
};
|
|
137
84
|
if (web3Auth) {
|
|
138
85
|
// web3Auth is initialized here.
|
|
@@ -143,6 +90,8 @@ function Web3AuthInnerProvider(params) {
|
|
|
143
90
|
web3Auth.on(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
144
91
|
web3Auth.on(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
145
92
|
web3Auth.on(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
93
|
+
web3Auth.on(CONNECTOR_EVENTS.REHYDRATION_ERROR, rehydrationErrorListener);
|
|
94
|
+
web3Auth.on(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
146
95
|
}
|
|
147
96
|
return () => {
|
|
148
97
|
if (web3Auth) {
|
|
@@ -152,6 +101,9 @@ function Web3AuthInnerProvider(params) {
|
|
|
152
101
|
web3Auth.off(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
153
102
|
web3Auth.off(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
154
103
|
web3Auth.off(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
104
|
+
web3Auth.off(CONNECTOR_EVENTS.REHYDRATION_ERROR, rehydrationErrorListener);
|
|
105
|
+
web3Auth.off(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
106
|
+
web3Auth.cleanup();
|
|
155
107
|
}
|
|
156
108
|
};
|
|
157
109
|
}, [web3Auth]);
|
|
@@ -161,22 +113,14 @@ function Web3AuthInnerProvider(params) {
|
|
|
161
113
|
isConnected,
|
|
162
114
|
isInitialized,
|
|
163
115
|
provider,
|
|
164
|
-
userInfo,
|
|
165
|
-
isMFAEnabled,
|
|
166
116
|
status,
|
|
167
|
-
connect,
|
|
168
|
-
enableMFA,
|
|
169
|
-
manageMFA,
|
|
170
|
-
logout,
|
|
171
|
-
authenticateUser,
|
|
172
|
-
switchChain,
|
|
173
|
-
getPlugin,
|
|
174
117
|
isInitializing,
|
|
175
|
-
isConnecting,
|
|
176
118
|
initError,
|
|
177
|
-
|
|
119
|
+
isMFAEnabled,
|
|
120
|
+
getPlugin,
|
|
121
|
+
setIsMFAEnabled
|
|
178
122
|
};
|
|
179
|
-
}, [web3Auth, isConnected,
|
|
123
|
+
}, [web3Auth, isConnected, isMFAEnabled, setIsMFAEnabled, isInitialized, provider, status, getPlugin, isInitializing, initError]);
|
|
180
124
|
return /*#__PURE__*/createElement(Web3AuthInnerContext.Provider, {
|
|
181
125
|
value
|
|
182
126
|
}, children);
|