@web3auth/modal 10.0.0-beta.0 → 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/node_modules/style-inject/dist/style-inject.es.js +1 -1
- 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 +278 -174
- package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +9 -3
- package/dist/lib.cjs/packages/modal/src/react/context/WalletServicesInnerContext.js +72 -0
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +51 -107
- 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 +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 +76 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +208 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +65 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +29 -30
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +49 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +148 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +99 -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 +50 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Image/Image.js +90 -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 +527 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +119 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +122 -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 +509 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +137 -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 +242 -0
- package/dist/lib.cjs/packages/modal/src/ui/config.js +13 -1
- package/dist/lib.cjs/packages/modal/src/ui/constants.js +48 -0
- package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +29 -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 +121 -0
- package/dist/lib.cjs/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +57 -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 +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +41 -5
- package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +7 -10
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +99 -62
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +123 -5
- 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 +11 -4
- 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/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 +25 -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 +8 -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 +11 -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 +5 -2
- package/dist/lib.cjs/types/ui/constants.d.ts +17 -0
- package/dist/lib.cjs/types/ui/context/RootContext.d.ts +27 -0
- package/dist/lib.cjs/types/ui/handlers/AbstractHandler.d.ts +21 -0
- package/dist/lib.cjs/types/ui/handlers/EmailPasswordlessHandler.d.ts +10 -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 +127 -18
- package/dist/lib.cjs/types/ui/loginModal.d.ts +10 -8
- package/dist/lib.cjs/types/ui/utils.d.ts +18 -3
- 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/node_modules/style-inject/dist/style-inject.es.js +1 -1
- 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 +291 -178
- 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 +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 +74 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +206 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +63 -0
- package/dist/lib.esm/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +29 -31
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +47 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +146 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +97 -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 +48 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Image/Image.js +88 -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 +531 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +118 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +120 -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 +520 -0
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +135 -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 +245 -0
- package/dist/lib.esm/packages/modal/src/ui/config.js +11 -3
- package/dist/lib.esm/packages/modal/src/ui/constants.js +40 -0
- package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +27 -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 +119 -0
- package/dist/lib.esm/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +55 -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 +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +41 -6
- package/dist/lib.esm/packages/modal/src/ui/interfaces.js +8 -9
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +100 -63
- package/dist/lib.esm/packages/modal/src/ui/utils.js +121 -7
- 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 +8 -34
- package/package.json +70 -19
- package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/assets/x-dark.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/assets/x-light.svg.js +0 -7
- package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +0 -108
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/styles.css.js +0 -8
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -44
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -67
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -43
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -46
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -167
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +0 -279
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer.js +0 -20
- package/dist/lib.cjs/packages/modal/src/ui/components/Header.js +0 -81
- package/dist/lib.cjs/packages/modal/src/ui/components/Icon.js +0 -73
- package/dist/lib.cjs/packages/modal/src/ui/components/Image.js +0 -51
- package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +0 -59
- package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +0 -278
- package/dist/lib.cjs/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -30
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -150
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +0 -153
- package/dist/lib.cjs/packages/modal/src/ui/components/WalletConnect.js +0 -84
- package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +0 -8
- package/dist/lib.cjs/types/react/context/index.d.ts +0 -1
- package/dist/lib.cjs/types/ui/components/AdapterLoader.d.ts +0 -11
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletButton.d.ts +0 -7
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletChainNamespace.d.ts +0 -9
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletConnect.d.ts +0 -9
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletDetails.d.ts +0 -10
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletHeader.d.ts +0 -8
- package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletInstall.d.ts +0 -8
- package/dist/lib.cjs/types/ui/components/ExternalWallets.d.ts +0 -15
- package/dist/lib.cjs/types/ui/components/Footer.d.ts +0 -1
- package/dist/lib.cjs/types/ui/components/Header.d.ts +0 -8
- package/dist/lib.cjs/types/ui/components/Icon.d.ts +0 -9
- package/dist/lib.cjs/types/ui/components/Loader.d.ts +0 -10
- package/dist/lib.cjs/types/ui/components/SelfCustodyViaWeb3Auth.d.ts +0 -1
- package/dist/lib.cjs/types/ui/components/SocialLoginPasswordless.d.ts +0 -14
- package/dist/lib.cjs/types/ui/components/SocialLogins.d.ts +0 -10
- package/dist/lib.cjs/types/ui/components/WalletConnect.d.ts +0 -8
- package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/assets/x-dark.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/assets/x-light.svg.js +0 -5
- package/dist/lib.esm/packages/modal/src/ui/components/AdapterLoader.js +0 -106
- package/dist/lib.esm/packages/modal/src/ui/components/Button/styles.css.js +0 -6
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -42
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -65
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -44
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -44
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -165
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +0 -281
- package/dist/lib.esm/packages/modal/src/ui/components/Footer.js +0 -18
- package/dist/lib.esm/packages/modal/src/ui/components/Header.js +0 -79
- package/dist/lib.esm/packages/modal/src/ui/components/Icon.js +0 -71
- package/dist/lib.esm/packages/modal/src/ui/components/Image.js +0 -49
- package/dist/lib.esm/packages/modal/src/ui/components/Loader.js +0 -57
- package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +0 -277
- package/dist/lib.esm/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -28
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -148
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +0 -152
- package/dist/lib.esm/packages/modal/src/ui/components/WalletConnect.js +0 -82
- package/dist/lib.esm/packages/modal/src/ui/css/web3auth.css.js +0 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CONNECTOR_EVENTS, Web3AuthContextKey, CONNECTOR_STATUS, WalletInitializationError
|
|
1
|
+
import { CONNECTOR_EVENTS, Web3AuthContextKey, CONNECTOR_STATUS, WalletInitializationError } from '@web3auth/no-modal';
|
|
2
2
|
import { defineComponent, h, shallowRef, ref, watch, provide } from 'vue';
|
|
3
3
|
import { Web3Auth } from '../modalManager.js';
|
|
4
|
+
import { WalletServicesInnerProvider } from './WalletServicesInnerProvider.js';
|
|
4
5
|
|
|
5
6
|
const Web3AuthProvider = defineComponent({
|
|
6
7
|
name: "Web3AuthProvider",
|
|
@@ -13,69 +14,31 @@ const Web3AuthProvider = defineComponent({
|
|
|
13
14
|
setup(props) {
|
|
14
15
|
const web3Auth = shallowRef(null);
|
|
15
16
|
const provider = ref(null);
|
|
16
|
-
const userInfo = ref(null);
|
|
17
17
|
const isMFAEnabled = ref(false);
|
|
18
18
|
const status = ref(null);
|
|
19
19
|
const isInitializing = ref(false);
|
|
20
20
|
const initError = ref(null);
|
|
21
21
|
const isInitialized = ref(false);
|
|
22
|
-
const isConnecting = ref(false);
|
|
23
|
-
const connectError = ref(null);
|
|
24
22
|
const isConnected = ref(false);
|
|
25
23
|
const getPlugin = name => {
|
|
26
24
|
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
27
25
|
return web3Auth.value.getPlugin(name);
|
|
28
26
|
};
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
if (!isConnected.value) throw WalletLoginError.notConnectedError();
|
|
32
|
-
await web3Auth.value.enableMFA(loginParams);
|
|
33
|
-
const localUserInfo = await web3Auth.value.getUserInfo();
|
|
34
|
-
userInfo.value = localUserInfo;
|
|
35
|
-
isMFAEnabled.value = localUserInfo.isMfaEnabled || false;
|
|
36
|
-
};
|
|
37
|
-
const manageMFA = async loginParams => {
|
|
38
|
-
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
39
|
-
if (!isConnected.value) throw WalletLoginError.notConnectedError();
|
|
40
|
-
await web3Auth.value.manageMFA(loginParams);
|
|
41
|
-
};
|
|
42
|
-
const logout = async (logoutParams = {
|
|
43
|
-
cleanup: false
|
|
44
|
-
}) => {
|
|
45
|
-
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
46
|
-
if (!isConnected.value) throw WalletLoginError.notConnectedError();
|
|
47
|
-
await web3Auth.value.logout(logoutParams);
|
|
48
|
-
};
|
|
49
|
-
const connect = async () => {
|
|
50
|
-
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
51
|
-
try {
|
|
52
|
-
connectError.value = null;
|
|
53
|
-
isConnecting.value = true;
|
|
54
|
-
const localProvider = await web3Auth.value.connect();
|
|
55
|
-
return localProvider;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
connectError.value = error;
|
|
58
|
-
return null;
|
|
59
|
-
} finally {
|
|
60
|
-
isConnecting.value = false;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const authenticateUser = async () => {
|
|
64
|
-
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
65
|
-
return web3Auth.value.authenticateUser();
|
|
27
|
+
const setIsMFAEnabled = isMfaEnabled => {
|
|
28
|
+
isMFAEnabled.value = isMfaEnabled;
|
|
66
29
|
};
|
|
67
|
-
|
|
68
|
-
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
69
|
-
return web3Auth.value.switchChain(chainParams);
|
|
70
|
-
};
|
|
71
|
-
watch(() => props.config, newConfig => {
|
|
30
|
+
watch(() => props.config, (newConfig, _, onInvalidate) => {
|
|
72
31
|
const resetHookState = () => {
|
|
73
32
|
provider.value = null;
|
|
74
|
-
userInfo.value = null;
|
|
75
33
|
isMFAEnabled.value = false;
|
|
76
34
|
isConnected.value = false;
|
|
77
35
|
status.value = null;
|
|
78
36
|
};
|
|
37
|
+
onInvalidate(() => {
|
|
38
|
+
if (web3Auth.value) {
|
|
39
|
+
web3Auth.value.cleanup();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
79
42
|
resetHookState();
|
|
80
43
|
const {
|
|
81
44
|
web3AuthOptions
|
|
@@ -85,12 +48,20 @@ const Web3AuthProvider = defineComponent({
|
|
|
85
48
|
}, {
|
|
86
49
|
immediate: true
|
|
87
50
|
});
|
|
88
|
-
watch(web3Auth, async newWeb3Auth => {
|
|
51
|
+
watch(web3Auth, async (newWeb3Auth, _, onInvalidate) => {
|
|
52
|
+
const controller = new AbortController();
|
|
53
|
+
|
|
54
|
+
// Invalidate the controller here before calling any async methods.
|
|
55
|
+
onInvalidate(() => {
|
|
56
|
+
controller.abort();
|
|
57
|
+
});
|
|
89
58
|
if (newWeb3Auth) {
|
|
90
59
|
try {
|
|
91
60
|
initError.value = null;
|
|
92
61
|
isInitializing.value = true;
|
|
93
|
-
await newWeb3Auth.
|
|
62
|
+
await newWeb3Auth.init({
|
|
63
|
+
signal: controller.signal
|
|
64
|
+
});
|
|
94
65
|
} catch (error) {
|
|
95
66
|
initError.value = error;
|
|
96
67
|
} finally {
|
|
@@ -100,22 +71,6 @@ const Web3AuthProvider = defineComponent({
|
|
|
100
71
|
}, {
|
|
101
72
|
immediate: true
|
|
102
73
|
});
|
|
103
|
-
watch(isConnected, newIsConnected => {
|
|
104
|
-
if (web3Auth.value) {
|
|
105
|
-
const addState = async web3AuthInstance => {
|
|
106
|
-
provider.value = web3AuthInstance.provider;
|
|
107
|
-
const userState = await web3AuthInstance.getUserInfo();
|
|
108
|
-
userInfo.value = userState;
|
|
109
|
-
isMFAEnabled.value = (userState === null || userState === void 0 ? void 0 : userState.isMfaEnabled) || false;
|
|
110
|
-
};
|
|
111
|
-
const resetState = () => {
|
|
112
|
-
provider.value = null;
|
|
113
|
-
userInfo.value = null;
|
|
114
|
-
isMFAEnabled.value = false;
|
|
115
|
-
};
|
|
116
|
-
if (newIsConnected) addState(web3Auth.value);else resetState();
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
74
|
watch(web3Auth, (newWeb3Auth, prevWeb3Auth) => {
|
|
120
75
|
const notReadyListener = () => {
|
|
121
76
|
status.value = web3Auth.value.status;
|
|
@@ -128,19 +83,29 @@ const Web3AuthProvider = defineComponent({
|
|
|
128
83
|
status.value = web3Auth.value.status;
|
|
129
84
|
// we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
|
|
130
85
|
if (web3Auth.value.status === CONNECTOR_STATUS.CONNECTED) {
|
|
131
|
-
isInitialized.value = true;
|
|
86
|
+
if (!isInitialized.value) isInitialized.value = true;
|
|
132
87
|
isConnected.value = true;
|
|
88
|
+
provider.value = newWeb3Auth.provider;
|
|
133
89
|
}
|
|
134
90
|
};
|
|
135
91
|
const disconnectedListener = () => {
|
|
136
92
|
status.value = web3Auth.value.status;
|
|
137
93
|
isConnected.value = false;
|
|
94
|
+
provider.value = null;
|
|
95
|
+
isMFAEnabled.value = false;
|
|
138
96
|
};
|
|
139
97
|
const connectingListener = () => {
|
|
140
98
|
status.value = web3Auth.value.status;
|
|
141
99
|
};
|
|
142
100
|
const errorListener = () => {
|
|
143
|
-
status.value =
|
|
101
|
+
status.value = web3Auth.value.status;
|
|
102
|
+
if (isConnected.value) {
|
|
103
|
+
isConnected.value = false;
|
|
104
|
+
provider.value = null;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const mfaEnabledListener = () => {
|
|
108
|
+
isMFAEnabled.value = true;
|
|
144
109
|
};
|
|
145
110
|
|
|
146
111
|
// unregister previous listeners
|
|
@@ -151,6 +116,8 @@ const Web3AuthProvider = defineComponent({
|
|
|
151
116
|
prevWeb3Auth.off(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
152
117
|
prevWeb3Auth.off(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
153
118
|
prevWeb3Auth.off(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
119
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
120
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
154
121
|
}
|
|
155
122
|
if (newWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
|
|
156
123
|
status.value = newWeb3Auth.status;
|
|
@@ -161,6 +128,8 @@ const Web3AuthProvider = defineComponent({
|
|
|
161
128
|
newWeb3Auth.on(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
162
129
|
newWeb3Auth.on(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
163
130
|
newWeb3Auth.on(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
131
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
132
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
164
133
|
}
|
|
165
134
|
}, {
|
|
166
135
|
immediate: true
|
|
@@ -170,25 +139,17 @@ const Web3AuthProvider = defineComponent({
|
|
|
170
139
|
isConnected,
|
|
171
140
|
isInitialized,
|
|
172
141
|
provider,
|
|
173
|
-
userInfo,
|
|
174
|
-
isMFAEnabled,
|
|
175
142
|
status,
|
|
176
|
-
getPlugin,
|
|
177
|
-
connect,
|
|
178
|
-
enableMFA,
|
|
179
|
-
manageMFA,
|
|
180
|
-
logout,
|
|
181
|
-
authenticateUser,
|
|
182
|
-
switchChain,
|
|
183
143
|
isInitializing,
|
|
184
|
-
isConnecting,
|
|
185
144
|
initError,
|
|
186
|
-
|
|
145
|
+
isMFAEnabled,
|
|
146
|
+
getPlugin,
|
|
147
|
+
setIsMFAEnabled
|
|
187
148
|
});
|
|
188
149
|
},
|
|
189
150
|
render() {
|
|
190
151
|
var _this$$slots$default;
|
|
191
|
-
return h((_this$$slots$default = this.$slots.default) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : "");
|
|
152
|
+
return h(WalletServicesInnerProvider, {}, (_this$$slots$default = this.$slots.default) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : "");
|
|
192
153
|
}
|
|
193
154
|
});
|
|
194
155
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletServicesPluginError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
4
|
+
|
|
5
|
+
const useCheckout = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showCheckout = async showCheckoutParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showCheckout(showCheckoutParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showCheckout
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useCheckout };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
4
|
+
|
|
5
|
+
const useEnableMFA = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const enableMFA = async () => {
|
|
12
|
+
try {
|
|
13
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
|
+
error.value = null;
|
|
15
|
+
loading.value = true;
|
|
16
|
+
await web3Auth.value.enableMFA();
|
|
17
|
+
} catch (err) {
|
|
18
|
+
error.value = err;
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
enableMFA
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useEnableMFA };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
3
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
4
|
+
|
|
5
|
+
const useIdentityToken = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth,
|
|
8
|
+
isConnected
|
|
9
|
+
} = useWeb3AuthInner();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const token = ref(null);
|
|
13
|
+
const authenticateUser = async () => {
|
|
14
|
+
try {
|
|
15
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
16
|
+
error.value = null;
|
|
17
|
+
loading.value = true;
|
|
18
|
+
const result = await web3Auth.value.authenticateUser();
|
|
19
|
+
if (result !== null && result !== void 0 && result.idToken) {
|
|
20
|
+
token.value = result.idToken;
|
|
21
|
+
}
|
|
22
|
+
return result === null || result === void 0 ? void 0 : result.idToken;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
error.value = err;
|
|
25
|
+
} finally {
|
|
26
|
+
loading.value = false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
watch(isConnected, newIsConnected => {
|
|
30
|
+
if (!newIsConnected && token.value) {
|
|
31
|
+
token.value = null;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
loading,
|
|
36
|
+
error,
|
|
37
|
+
token,
|
|
38
|
+
authenticateUser
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { useIdentityToken };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
4
|
+
|
|
5
|
+
const useManageMFA = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const manageMFA = async () => {
|
|
12
|
+
try {
|
|
13
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
|
+
error.value = null;
|
|
15
|
+
loading.value = true;
|
|
16
|
+
await web3Auth.value.enableMFA();
|
|
17
|
+
} catch (err) {
|
|
18
|
+
error.value = err;
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
manageMFA
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useManageMFA };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletServicesPluginError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
4
|
+
|
|
5
|
+
const useSwap = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showSwap = async showSwapParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showSwap(showSwapParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showSwap
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useSwap };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
4
|
+
|
|
5
|
+
const useSwitchChain = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const switchChain = async chainParams => {
|
|
12
|
+
try {
|
|
13
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
|
+
error.value = null;
|
|
15
|
+
loading.value = true;
|
|
16
|
+
await web3Auth.value.switchChain(chainParams);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
error.value = err;
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
switchChain
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useSwitchChain };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletServicesPluginError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
4
|
+
|
|
5
|
+
const useWalletConnectScanner = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showWalletConnectScanner = async showWalletConnectScannerParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showWalletConnectScanner(showWalletConnectScannerParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showWalletConnectScanner
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useWalletConnectScanner };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { WalletServicesContextKey } from '@web3auth/no-modal/vue';
|
|
3
|
+
import { inject } from 'vue';
|
|
4
|
+
|
|
5
|
+
const useWalletServicesPlugin = () => {
|
|
6
|
+
const context = inject(WalletServicesContextKey);
|
|
7
|
+
if (!context) throw WalletInitializationError.fromCode(1000, "usage of useWalletServicesPlugin not wrapped in `WalletServicesContextProvider`.");
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useWalletServicesPlugin };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WalletServicesPluginError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
4
|
+
|
|
5
|
+
const useWalletUI = () => {
|
|
6
|
+
const {
|
|
7
|
+
plugin,
|
|
8
|
+
ready
|
|
9
|
+
} = useWalletServicesPlugin();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const showWalletUI = async showWalletUiParams => {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
error.value = null;
|
|
15
|
+
try {
|
|
16
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
17
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
18
|
+
await plugin.value.showWalletUi(showWalletUiParams);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
error.value = err;
|
|
21
|
+
} finally {
|
|
22
|
+
loading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
showWalletUI
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useWalletUI };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { inject } from 'vue';
|
|
1
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
2
|
|
|
4
3
|
const useWeb3Auth = () => {
|
|
5
|
-
const context =
|
|
6
|
-
if (!context) throw WalletInitializationError.fromCode(1000, "usage of `useWeb3Auth` not wrapped in `Web3AuthProvider`.");
|
|
4
|
+
const context = useWeb3AuthInner();
|
|
7
5
|
return context;
|
|
8
6
|
};
|
|
9
7
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
3
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
4
|
+
|
|
5
|
+
const useWeb3AuthConnect = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth,
|
|
8
|
+
isConnected
|
|
9
|
+
} = useWeb3AuthInner();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const connectorName = ref(null);
|
|
13
|
+
watch(isConnected, newVal => {
|
|
14
|
+
if (!newVal && connectorName.value) {
|
|
15
|
+
connectorName.value = null;
|
|
16
|
+
}
|
|
17
|
+
if (newVal && !connectorName.value) {
|
|
18
|
+
var _web3Auth$value;
|
|
19
|
+
connectorName.value = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.connectedConnectorName;
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
immediate: true
|
|
23
|
+
});
|
|
24
|
+
const connect = async () => {
|
|
25
|
+
try {
|
|
26
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
27
|
+
error.value = null;
|
|
28
|
+
loading.value = true;
|
|
29
|
+
const localProvider = await web3Auth.value.connect();
|
|
30
|
+
connectorName.value = web3Auth.value.connectedConnectorName;
|
|
31
|
+
return localProvider;
|
|
32
|
+
} catch (err) {
|
|
33
|
+
error.value = err;
|
|
34
|
+
return null;
|
|
35
|
+
} finally {
|
|
36
|
+
loading.value = false;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const connectTo = async (connectorType, loginParams) => {
|
|
40
|
+
try {
|
|
41
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
42
|
+
error.value = null;
|
|
43
|
+
loading.value = true;
|
|
44
|
+
const localProvider = await web3Auth.value.connectTo(connectorType, loginParams);
|
|
45
|
+
connectorName.value = web3Auth.value.connectedConnectorName;
|
|
46
|
+
return localProvider;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
error.value = err;
|
|
49
|
+
return null;
|
|
50
|
+
} finally {
|
|
51
|
+
loading.value = false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
isConnected,
|
|
56
|
+
loading,
|
|
57
|
+
error,
|
|
58
|
+
connectorName,
|
|
59
|
+
connect,
|
|
60
|
+
connectTo
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { useWeb3AuthConnect };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
4
|
+
|
|
5
|
+
const useWeb3AuthDisconnect = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const error = ref(null);
|
|
11
|
+
const disconnect = async options => {
|
|
12
|
+
try {
|
|
13
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
|
+
error.value = null;
|
|
15
|
+
loading.value = true;
|
|
16
|
+
await web3Auth.value.logout(options);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
error.value = err;
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
disconnect
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useWeb3AuthDisconnect };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Web3AuthContextKey, WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { inject } from 'vue';
|
|
3
|
+
|
|
4
|
+
const useWeb3AuthInner = () => {
|
|
5
|
+
const context = inject(Web3AuthContextKey);
|
|
6
|
+
if (!context) throw WalletInitializationError.fromCode(1000, "usage of `useWeb3Auth` not wrapped in `Web3AuthProvider`.");
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { useWeb3AuthInner };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
3
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
4
|
+
|
|
5
|
+
const useWeb3AuthUser = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth,
|
|
8
|
+
isConnected,
|
|
9
|
+
isMFAEnabled,
|
|
10
|
+
setIsMFAEnabled
|
|
11
|
+
} = useWeb3AuthInner();
|
|
12
|
+
const loading = ref(false);
|
|
13
|
+
const error = ref(null);
|
|
14
|
+
const userInfo = ref(null);
|
|
15
|
+
const getUserInfo = async () => {
|
|
16
|
+
try {
|
|
17
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
18
|
+
error.value = null;
|
|
19
|
+
loading.value = true;
|
|
20
|
+
const result = await web3Auth.value.getUserInfo();
|
|
21
|
+
userInfo.value = result;
|
|
22
|
+
return result;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
error.value = err;
|
|
25
|
+
} finally {
|
|
26
|
+
loading.value = false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
watch(isConnected, async newIsConnected => {
|
|
30
|
+
if (newIsConnected && !userInfo.value) {
|
|
31
|
+
const result = await getUserInfo();
|
|
32
|
+
userInfo.value = result;
|
|
33
|
+
setIsMFAEnabled((result === null || result === void 0 ? void 0 : result.isMfaEnabled) || false);
|
|
34
|
+
}
|
|
35
|
+
if (!newIsConnected && userInfo.value) {
|
|
36
|
+
userInfo.value = null;
|
|
37
|
+
setIsMFAEnabled(false);
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
immediate: true
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
loading,
|
|
44
|
+
error,
|
|
45
|
+
userInfo,
|
|
46
|
+
isMFAEnabled,
|
|
47
|
+
getUserInfo
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { useWeb3AuthUser };
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
export { useCheckout } from './composables/useCheckout.js';
|
|
2
|
+
export { useEnableMFA } from './composables/useEnableMFA.js';
|
|
3
|
+
export { useIdentityToken } from './composables/useIdentityToken.js';
|
|
4
|
+
export { useManageMFA } from './composables/useManageMFA.js';
|
|
5
|
+
export { useSwap } from './composables/useSwap.js';
|
|
6
|
+
export { useSwitchChain } from './composables/useSwitchChain.js';
|
|
7
|
+
export { useWalletConnectScanner } from './composables/useWalletConnectScanner.js';
|
|
8
|
+
export { useWalletServicesPlugin } from './composables/useWalletServicesPlugin.js';
|
|
9
|
+
export { useWalletUI } from './composables/useWalletUI.js';
|
|
1
10
|
export { useWeb3Auth } from './composables/useWeb3Auth.js';
|
|
11
|
+
export { useWeb3AuthConnect } from './composables/useWeb3AuthConnect.js';
|
|
12
|
+
export { useWeb3AuthDisconnect } from './composables/useWeb3AuthDisconnect.js';
|
|
13
|
+
export { useWeb3AuthUser } from './composables/useWeb3AuthUser.js';
|
|
2
14
|
export { Web3AuthProvider } from './Web3AuthProvider.js';
|