@web3auth/no-modal 10.0.0-beta.1 → 10.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.cjs/base/connector/baseConnector.js +2 -1
- package/dist/lib.cjs/base/connector/constants.js +3 -1
- package/dist/lib.cjs/base/constants.js +7 -0
- package/dist/lib.cjs/base/cookie.js +38 -0
- package/dist/lib.cjs/base/deserialize.js +13 -0
- package/dist/lib.cjs/base/errors/index.js +3 -22
- package/dist/lib.cjs/base/utils.js +24 -6
- package/dist/lib.cjs/base/wallet/index.js +2 -4
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +63 -20
- package/dist/lib.cjs/connectors/coinbase-connector/coinbaseConnector.js +13 -5
- package/dist/lib.cjs/connectors/coinbase-connector/index.js +7 -0
- package/dist/lib.cjs/connectors/injected-evm-connector/injectedEvmConnector.js +7 -3
- package/dist/lib.cjs/connectors/injected-solana-connector/walletStandardConnector.js +7 -4
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +43 -15
- package/dist/lib.cjs/connectors/utils.js +10 -0
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/config.js +6 -1
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +6 -2
- package/dist/lib.cjs/index.js +13 -9
- package/dist/lib.cjs/noModal.js +190 -69
- package/dist/lib.cjs/plugins/nft-checkout-plugin/plugin.js +2 -2
- package/dist/lib.cjs/plugins/wallet-services-plugin/plugin.js +1 -1
- package/dist/lib.cjs/providers/account-abstraction-provider/index.js +5 -0
- package/dist/lib.cjs/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +29 -2
- package/dist/lib.cjs/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +25 -3
- package/dist/lib.cjs/providers/base-provider/baseProvider.js +2 -0
- package/dist/lib.cjs/providers/ethereum-mpc-provider/index.js +7 -0
- package/dist/lib.cjs/providers/xrpl-provider/index.js +9 -0
- package/dist/lib.cjs/react/Web3AuthProvider.js +19 -0
- package/dist/lib.cjs/react/{wallet-services-plugin/WalletServicesContext.js → context/WalletServicesInnerContext.js} +18 -33
- package/dist/lib.cjs/react/{no-modal → context}/Web3AuthInnerContext.js +37 -95
- package/dist/lib.cjs/react/hooks/useCheckout.js +45 -0
- package/dist/lib.cjs/react/hooks/useEnableMFA.js +30 -0
- package/dist/lib.cjs/react/hooks/useIdentityToken.js +42 -0
- package/dist/lib.cjs/react/hooks/useManageMFA.js +30 -0
- package/dist/lib.cjs/react/hooks/useSwap.js +45 -0
- package/dist/lib.cjs/react/hooks/useSwitchChain.js +32 -0
- package/dist/lib.cjs/react/hooks/useWalletConnectScanner.js +45 -0
- package/dist/lib.cjs/react/hooks/useWalletServicesPlugin.js +19 -0
- package/dist/lib.cjs/react/hooks/useWalletUI.js +45 -0
- package/dist/lib.cjs/react/hooks/useWeb3Auth.js +28 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthConnect.js +48 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.cjs/react/{no-modal/hooks/useWeb3Auth.js → hooks/useWeb3AuthInner.js} +9 -9
- package/dist/lib.cjs/react/hooks/useWeb3AuthUser.js +50 -0
- package/dist/lib.cjs/react/index.js +26 -9
- package/dist/lib.cjs/react/solana/hooks/useSignAndSendTransaction.js +35 -0
- package/dist/lib.cjs/react/solana/hooks/useSignMessage.js +36 -0
- package/dist/lib.cjs/react/solana/hooks/useSignTransaction.js +34 -0
- package/dist/lib.cjs/react/solana/hooks/useSolanaWallet.js +62 -0
- package/dist/lib.cjs/react/solana/index.js +13 -0
- package/dist/lib.cjs/react/wagmi/constants.js +16 -0
- package/dist/lib.cjs/react/wagmi/index.js +7 -0
- package/dist/lib.cjs/react/wagmi/provider.js +189 -0
- package/dist/lib.cjs/types/base/connector/baseConnector.d.ts +4 -5
- package/dist/lib.cjs/types/base/connector/constants.d.ts +2 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +18 -16
- package/dist/lib.cjs/types/base/constants.d.ts +5 -0
- package/dist/lib.cjs/types/base/cookie.d.ts +10 -0
- package/dist/lib.cjs/types/base/core/IWeb3Auth.d.ts +40 -12
- package/dist/lib.cjs/types/base/deserialize.d.ts +3 -0
- package/dist/lib.cjs/types/base/errors/index.d.ts +1 -2
- package/dist/lib.cjs/types/base/hooks/index.d.ts +3 -23
- package/dist/lib.cjs/types/base/index.d.ts +1 -0
- package/dist/lib.cjs/types/base/interfaces.d.ts +9 -4
- package/dist/lib.cjs/types/base/plugin/IPlugin.d.ts +1 -1
- package/dist/lib.cjs/types/base/utils.d.ts +3 -1
- package/dist/lib.cjs/types/base/wallet/index.d.ts +18 -17
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +5 -6
- package/dist/lib.cjs/types/connectors/auth-connector/interface.d.ts +3 -2
- package/dist/lib.cjs/types/connectors/coinbase-connector/coinbaseConnector.d.ts +1 -1
- package/dist/lib.cjs/types/connectors/index.d.ts +1 -1
- package/dist/lib.cjs/types/connectors/metamask-connector/index.d.ts +1 -1
- package/dist/lib.cjs/types/connectors/metamask-connector/metamaskConnector.d.ts +2 -2
- package/dist/lib.cjs/types/connectors/utils.d.ts +8 -0
- package/dist/lib.cjs/types/noModal.d.ts +20 -9
- package/dist/lib.cjs/types/plugins/nft-checkout-plugin/plugin.d.ts +2 -2
- package/dist/lib.cjs/types/plugins/wallet-services-plugin/plugin.d.ts +2 -2
- package/dist/lib.cjs/types/providers/account-abstraction-provider/providers/AccountAbstractionProvider.d.ts +3 -2
- package/dist/lib.cjs/types/providers/account-abstraction-provider/providers/smartAccounts/index.d.ts +1 -1
- package/dist/lib.cjs/types/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.d.ts +4 -1
- package/dist/lib.cjs/types/providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.d.ts +1 -1
- package/dist/lib.cjs/types/providers/index.d.ts +0 -2
- package/dist/lib.cjs/types/providers/solana-provider/providers/injectedProviders/base/baseInjectedProvider.d.ts +1 -1
- package/dist/lib.cjs/types/providers/xrpl-provider/providers/privateKeyProviders/xrplPrivateKeyProvider.d.ts +1 -1
- package/dist/lib.cjs/types/react/context/WalletServicesInnerContext.d.ts +6 -0
- package/dist/lib.cjs/types/react/{no-modal → context}/Web3AuthInnerContext.d.ts +1 -1
- package/dist/lib.cjs/types/react/hooks/index.d.ts +13 -0
- 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/useWalletUI.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3Auth.d.ts +3 -0
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthConnect.d.ts +9 -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 +3 -2
- package/dist/lib.cjs/types/react/interfaces.d.ts +21 -0
- package/dist/lib.cjs/types/react/solana/hooks/index.d.ts +4 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignAndSendTransaction.d.ts +9 -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 +14 -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 +1 -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/vue/WalletServicesInnerProvider.d.ts +1 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +13 -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 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +10 -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/{wallet-services-plugin/context.d.ts → context/WalletServicesContext.d.ts} +2 -2
- package/dist/lib.cjs/types/vue/context/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/index.d.ts +4 -2
- package/dist/lib.cjs/types/vue/interfaces.d.ts +30 -0
- package/dist/lib.cjs/types/vue/solana/composables/index.d.ts +4 -0
- package/dist/lib.cjs/types/vue/solana/composables/useSignAndSendTransaction.d.ts +10 -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 +10 -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.cjs/vue/{wallet-services-plugin/WalletServicesProvider.js → WalletServicesInnerProvider.js} +26 -43
- package/dist/lib.cjs/vue/{no-modal/Web3AuthProvider.js → Web3AuthProvider.js} +45 -86
- package/dist/lib.cjs/vue/composables/useCheckout.js +45 -0
- package/dist/lib.cjs/vue/composables/useEnableMFA.js +43 -0
- package/dist/lib.cjs/vue/composables/useIdentityToken.js +55 -0
- package/dist/lib.cjs/vue/composables/useManageMFA.js +43 -0
- package/dist/lib.cjs/vue/composables/useSwap.js +45 -0
- package/dist/lib.cjs/vue/composables/useSwitchChain.js +43 -0
- package/dist/lib.cjs/vue/composables/useWalletConnectScanner.js +45 -0
- package/dist/lib.cjs/vue/composables/useWalletServicesPlugin.js +12 -0
- package/dist/lib.cjs/vue/composables/useWalletUI.js +45 -0
- package/dist/lib.cjs/vue/composables/useWeb3Auth.js +28 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthConnect.js +61 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthDisconnect.js +43 -0
- package/dist/lib.cjs/vue/{no-modal/composables/useWeb3Auth.js → composables/useWeb3AuthInner.js} +9 -9
- package/dist/lib.cjs/vue/composables/useWeb3AuthUser.js +64 -0
- package/dist/lib.cjs/vue/index.js +28 -8
- package/dist/lib.cjs/vue/solana/composables/useSignAndSendTransaction.js +36 -0
- package/dist/lib.cjs/vue/solana/composables/useSignMessage.js +38 -0
- package/dist/lib.cjs/vue/solana/composables/useSignTransaction.js +36 -0
- package/dist/lib.cjs/vue/solana/composables/useSolanaWallet.js +64 -0
- package/dist/lib.cjs/vue/solana/index.js +13 -0
- package/dist/lib.cjs/vue/wagmi/constants.js +16 -0
- package/dist/lib.cjs/vue/wagmi/index.js +7 -0
- package/dist/lib.cjs/vue/wagmi/provider.js +244 -0
- package/dist/lib.esm/base/connector/baseConnector.js +6 -1
- package/dist/lib.esm/base/connector/constants.js +3 -1
- package/dist/lib.esm/base/constants.js +6 -1
- package/dist/lib.esm/base/cookie.js +34 -0
- package/dist/lib.esm/base/deserialize.js +11 -0
- package/dist/lib.esm/base/errors/index.js +14 -22
- package/dist/lib.esm/base/plugin/errors.js +2 -0
- package/dist/lib.esm/base/utils.js +28 -12
- package/dist/lib.esm/base/wallet/index.js +2 -4
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +83 -30
- package/dist/lib.esm/connectors/base-evm-connector/baseEvmConnector.js +1 -8
- package/dist/lib.esm/connectors/base-solana-connector/baseSolanaConnector.js +1 -8
- package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +16 -15
- package/dist/lib.esm/connectors/coinbase-connector/index.js +1 -0
- package/dist/lib.esm/connectors/injected-evm-connector/injectedEvmConnector.js +11 -12
- package/dist/lib.esm/connectors/injected-solana-connector/walletStandardConnector.js +13 -17
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +52 -27
- package/dist/lib.esm/connectors/utils.js +14 -1
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +8 -25
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/config.js +20 -25
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +15 -15
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Utils.js +1 -11
- package/dist/lib.esm/index.js +12 -14
- package/dist/lib.esm/noModal.js +217 -80
- package/dist/lib.esm/plugins/nft-checkout-plugin/embed.js +4 -1
- package/dist/lib.esm/plugins/nft-checkout-plugin/plugin.js +4 -10
- package/dist/lib.esm/plugins/wallet-services-plugin/plugin.js +7 -9
- package/dist/lib.esm/providers/account-abstraction-provider/index.js +2 -2
- package/dist/lib.esm/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +37 -20
- package/dist/lib.esm/providers/account-abstraction-provider/providers/utils.js +0 -10
- package/dist/lib.esm/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +26 -3
- package/dist/lib.esm/providers/base-provider/baseProvider.js +7 -9
- package/dist/lib.esm/providers/base-provider/utils.js +3 -3
- package/dist/lib.esm/providers/ethereum-mpc-provider/index.js +1 -0
- package/dist/lib.esm/providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.js +4 -17
- package/dist/lib.esm/providers/ethereum-mpc-provider/providers/signingProviders/signingUtils.js +3 -13
- package/dist/lib.esm/providers/ethereum-mpc-provider/rpc/ethRpcMiddlewares.js +1 -0
- package/dist/lib.esm/providers/ethereum-provider/providers/converter.js +1 -0
- package/dist/lib.esm/providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/formatter.js +10 -11
- package/dist/lib.esm/providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/interfaces.js +3 -3
- package/dist/lib.esm/providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/utils.js +1 -0
- package/dist/lib.esm/providers/ethereum-provider/rpc/walletMidddleware.js +8 -0
- package/dist/lib.esm/providers/solana-provider/providers/injectedProviders/base/baseInjectedProvider.js +2 -15
- package/dist/lib.esm/providers/solana-provider/providers/injectedProviders/walletStandardProvider.js +5 -12
- package/dist/lib.esm/providers/solana-provider/rpc/solanaRpcMiddlewares.js +1 -1
- package/dist/lib.esm/providers/solana-provider/solanaWallet.js +3 -0
- package/dist/lib.esm/providers/xrpl-provider/index.js +2 -0
- package/dist/lib.esm/providers/xrpl-provider/providers/privateKeyProviders/xrplPrivateKeyProvider.js +3 -14
- package/dist/lib.esm/providers/xrpl-provider/rpc/xrplRpcMiddlewares.js +1 -0
- package/dist/lib.esm/react/Web3AuthProvider.js +17 -0
- package/dist/lib.esm/react/context/WalletServicesInnerContext.js +70 -0
- package/dist/lib.esm/react/context/Web3AuthInnerContext.js +129 -0
- package/dist/lib.esm/react/hooks/useCheckout.js +32 -0
- package/dist/lib.esm/react/hooks/useEnableMFA.js +28 -0
- package/dist/lib.esm/react/hooks/useIdentityToken.js +40 -0
- package/dist/lib.esm/react/hooks/useManageMFA.js +28 -0
- package/dist/lib.esm/react/hooks/useSwap.js +32 -0
- package/dist/lib.esm/react/hooks/useSwitchChain.js +30 -0
- package/dist/lib.esm/react/hooks/useWalletConnectScanner.js +32 -0
- package/dist/lib.esm/react/hooks/useWalletServicesPlugin.js +17 -0
- package/dist/lib.esm/react/hooks/useWalletUI.js +32 -0
- package/dist/lib.esm/react/hooks/useWeb3Auth.js +26 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthConnect.js +46 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthDisconnect.js +28 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthInner.js +13 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthUser.js +48 -0
- package/dist/lib.esm/react/index.js +14 -5
- package/dist/lib.esm/react/solana/hooks/useSignAndSendTransaction.js +33 -0
- package/dist/lib.esm/react/solana/hooks/useSignMessage.js +34 -0
- package/dist/lib.esm/react/solana/hooks/useSignTransaction.js +32 -0
- package/dist/lib.esm/react/solana/hooks/useSolanaWallet.js +42 -0
- package/dist/lib.esm/react/solana/index.js +4 -0
- package/dist/lib.esm/react/wagmi/constants.js +14 -0
- package/dist/lib.esm/react/wagmi/index.js +1 -0
- package/dist/lib.esm/react/wagmi/provider.js +179 -0
- package/dist/lib.esm/vue/WalletServicesInnerProvider.js +71 -0
- package/dist/lib.esm/vue/Web3AuthProvider.js +154 -0
- package/dist/lib.esm/vue/composables/useCheckout.js +32 -0
- package/dist/lib.esm/vue/composables/useEnableMFA.js +30 -0
- package/dist/lib.esm/vue/composables/useIdentityToken.js +42 -0
- package/dist/lib.esm/vue/composables/useManageMFA.js +30 -0
- package/dist/lib.esm/vue/composables/useSwap.js +32 -0
- package/dist/lib.esm/vue/composables/useSwitchChain.js +30 -0
- package/dist/lib.esm/vue/composables/useWalletConnectScanner.js +32 -0
- package/dist/lib.esm/vue/composables/useWalletServicesPlugin.js +10 -0
- package/dist/lib.esm/vue/composables/useWalletUI.js +32 -0
- package/dist/lib.esm/vue/composables/useWeb3Auth.js +26 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthConnect.js +48 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthDisconnect.js +30 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthInner.js +11 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthUser.js +51 -0
- package/dist/lib.esm/vue/index.js +15 -5
- package/dist/lib.esm/vue/solana/composables/useSignAndSendTransaction.js +34 -0
- package/dist/lib.esm/vue/solana/composables/useSignMessage.js +36 -0
- package/dist/lib.esm/vue/solana/composables/useSignTransaction.js +34 -0
- package/dist/lib.esm/vue/solana/composables/useSolanaWallet.js +51 -0
- package/dist/lib.esm/vue/solana/index.js +4 -0
- package/dist/lib.esm/vue/wagmi/constants.js +14 -0
- package/dist/lib.esm/vue/wagmi/index.js +1 -0
- package/dist/lib.esm/vue/wagmi/provider.js +237 -0
- package/dist/noModal.umd.min.js +1 -1
- package/dist/noModal.umd.min.js.LICENSE.txt +0 -26
- package/package.json +79 -20
- package/dist/lib.cjs/react/no-modal/Web3AuthProvider.js +0 -15
- package/dist/lib.cjs/react/wallet-services-plugin/WalletServicesProvider.js +0 -16
- package/dist/lib.cjs/react/wallet-services-plugin/hooks/useWalletServicesPlugin.js +0 -26
- package/dist/lib.cjs/types/react/no-modal/hooks/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/no-modal/hooks/useWeb3Auth.d.ts +0 -2
- package/dist/lib.cjs/types/react/no-modal/index.d.ts +0 -3
- package/dist/lib.cjs/types/react/no-modal/interfaces.d.ts +0 -15
- package/dist/lib.cjs/types/react/wallet-services-plugin/WalletServicesContext.d.ts +0 -7
- package/dist/lib.cjs/types/react/wallet-services-plugin/WalletServicesProvider.d.ts +0 -7
- package/dist/lib.cjs/types/react/wallet-services-plugin/hooks/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/wallet-services-plugin/index.d.ts +0 -4
- package/dist/lib.cjs/types/react/wallet-services-plugin/interfaces.d.ts +0 -5
- package/dist/lib.cjs/types/vue/no-modal/composables/index.d.ts +0 -1
- package/dist/lib.cjs/types/vue/no-modal/composables/useWeb3Auth.d.ts +0 -2
- package/dist/lib.cjs/types/vue/no-modal/index.d.ts +0 -3
- package/dist/lib.cjs/types/vue/no-modal/interfaces.d.ts +0 -39
- package/dist/lib.cjs/types/vue/wallet-services-plugin/WalletServicesProvider.d.ts +0 -1
- package/dist/lib.cjs/types/vue/wallet-services-plugin/composables/index.d.ts +0 -1
- package/dist/lib.cjs/types/vue/wallet-services-plugin/composables/useWalletServicesPlugin.d.ts +0 -2
- package/dist/lib.cjs/types/vue/wallet-services-plugin/index.d.ts +0 -4
- package/dist/lib.cjs/types/vue/wallet-services-plugin/interfaces.d.ts +0 -13
- package/dist/lib.cjs/vue/wallet-services-plugin/composables/useWalletServicesPlugin.js +0 -24
- package/dist/lib.esm/react/no-modal/Web3AuthInnerContext.js +0 -197
- package/dist/lib.esm/react/no-modal/Web3AuthProvider.js +0 -13
- package/dist/lib.esm/react/no-modal/hooks/useWeb3Auth.js +0 -24
- package/dist/lib.esm/react/wallet-services-plugin/WalletServicesContext.js +0 -95
- package/dist/lib.esm/react/wallet-services-plugin/WalletServicesProvider.js +0 -14
- package/dist/lib.esm/react/wallet-services-plugin/hooks/useWalletServicesPlugin.js +0 -24
- package/dist/lib.esm/vue/no-modal/Web3AuthProvider.js +0 -203
- package/dist/lib.esm/vue/no-modal/composables/useWeb3Auth.js +0 -22
- package/dist/lib.esm/vue/wallet-services-plugin/WalletServicesProvider.js +0 -96
- package/dist/lib.esm/vue/wallet-services-plugin/composables/useWalletServicesPlugin.js +0 -22
- /package/dist/lib.cjs/types/react/{no-modal/Web3AuthProvider.d.ts → Web3AuthProvider.d.ts} +0 -0
- /package/dist/lib.cjs/types/react/{wallet-services-plugin/hooks → hooks}/useWalletServicesPlugin.d.ts +0 -0
- /package/dist/lib.cjs/types/vue/{no-modal/Web3AuthProvider.d.ts → Web3AuthProvider.d.ts} +0 -0
- /package/dist/lib.cjs/vue/{wallet-services-plugin/context.js → context/WalletServicesContext.js} +0 -0
- /package/dist/lib.esm/vue/{wallet-services-plugin/context.js → context/WalletServicesContext.js} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useSolanaWallet } from './useSolanaWallet.js';
|
|
3
|
+
|
|
4
|
+
const useSignAndSendTransaction = () => {
|
|
5
|
+
const {
|
|
6
|
+
solanaWallet
|
|
7
|
+
} = useSolanaWallet();
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const [data, setData] = useState(null);
|
|
11
|
+
const signAndSendTransaction = useCallback(async transaction => {
|
|
12
|
+
setLoading(true);
|
|
13
|
+
setError(null);
|
|
14
|
+
try {
|
|
15
|
+
if (!solanaWallet) throw new Error("Solana wallet not found");
|
|
16
|
+
const signature = await solanaWallet.signAndSendTransaction(transaction);
|
|
17
|
+
setData(signature);
|
|
18
|
+
return signature;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
setError(error);
|
|
21
|
+
} finally {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
}
|
|
24
|
+
}, [solanaWallet]);
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
data,
|
|
29
|
+
signAndSendTransaction
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useSignAndSendTransaction };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useSolanaWallet } from './useSolanaWallet.js';
|
|
3
|
+
|
|
4
|
+
const useSignMessage = () => {
|
|
5
|
+
const {
|
|
6
|
+
solanaWallet,
|
|
7
|
+
accounts
|
|
8
|
+
} = useSolanaWallet();
|
|
9
|
+
const [loading, setLoading] = useState(false);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
const [data, setData] = useState(null);
|
|
12
|
+
const signMessage = useCallback(async (message, from) => {
|
|
13
|
+
setLoading(true);
|
|
14
|
+
setError(null);
|
|
15
|
+
try {
|
|
16
|
+
if (!solanaWallet) throw new Error("Solana wallet not found");
|
|
17
|
+
const signature = await solanaWallet.signMessage(message, from !== null && from !== void 0 ? from : accounts === null || accounts === void 0 ? void 0 : accounts[0]);
|
|
18
|
+
setData(signature);
|
|
19
|
+
return signature;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
setError(error);
|
|
22
|
+
} finally {
|
|
23
|
+
setLoading(false);
|
|
24
|
+
}
|
|
25
|
+
}, [solanaWallet, accounts]);
|
|
26
|
+
return {
|
|
27
|
+
loading,
|
|
28
|
+
error,
|
|
29
|
+
data,
|
|
30
|
+
signMessage
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { useSignMessage };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useSolanaWallet } from './useSolanaWallet.js';
|
|
3
|
+
|
|
4
|
+
const useSignTransaction = () => {
|
|
5
|
+
const {
|
|
6
|
+
solanaWallet
|
|
7
|
+
} = useSolanaWallet();
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const [data, setData] = useState(null);
|
|
11
|
+
const signTransaction = useCallback(async transaction => {
|
|
12
|
+
setLoading(true);
|
|
13
|
+
setError(null);
|
|
14
|
+
try {
|
|
15
|
+
const signedTransaction = await solanaWallet.signTransaction(transaction);
|
|
16
|
+
setData(signedTransaction);
|
|
17
|
+
return signedTransaction;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
setError(error);
|
|
20
|
+
} finally {
|
|
21
|
+
setLoading(false);
|
|
22
|
+
}
|
|
23
|
+
}, [solanaWallet]);
|
|
24
|
+
return {
|
|
25
|
+
loading,
|
|
26
|
+
error,
|
|
27
|
+
data,
|
|
28
|
+
signTransaction
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useSignTransaction };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
3
|
+
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
4
|
+
import { useWeb3Auth } from '../../hooks/useWeb3Auth.js';
|
|
5
|
+
import { SolanaWallet } from '../../../providers/solana-provider/solanaWallet.js';
|
|
6
|
+
|
|
7
|
+
const useSolanaWallet = () => {
|
|
8
|
+
const {
|
|
9
|
+
provider,
|
|
10
|
+
web3Auth
|
|
11
|
+
} = useWeb3Auth();
|
|
12
|
+
const [accounts, setAccounts] = useState(null);
|
|
13
|
+
const solanaWallet = useMemo(() => {
|
|
14
|
+
if (!provider) return null;
|
|
15
|
+
return new SolanaWallet(provider);
|
|
16
|
+
}, [provider]);
|
|
17
|
+
const connection = useMemo(() => {
|
|
18
|
+
if (!web3Auth || !provider) return null;
|
|
19
|
+
return new Connection(web3Auth.currentChain.rpcTarget);
|
|
20
|
+
}, [web3Auth, provider]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const init = async () => {
|
|
23
|
+
var _web3Auth$currentChai;
|
|
24
|
+
if (!solanaWallet) return;
|
|
25
|
+
if (!(web3Auth !== null && web3Auth !== void 0 && (_web3Auth$currentChai = web3Auth.currentChain) !== null && _web3Auth$currentChai !== void 0 && _web3Auth$currentChai.chainNamespace) || web3Auth.currentChain.chainNamespace !== CHAIN_NAMESPACES.SOLANA) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const accounts = await solanaWallet.requestAccounts();
|
|
29
|
+
if ((accounts === null || accounts === void 0 ? void 0 : accounts.length) > 0) {
|
|
30
|
+
setAccounts(accounts);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
if (solanaWallet) init();
|
|
34
|
+
}, [solanaWallet]);
|
|
35
|
+
return {
|
|
36
|
+
solanaWallet,
|
|
37
|
+
accounts,
|
|
38
|
+
connection
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { useSolanaWallet };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useSignAndSendTransaction } from './hooks/useSignAndSendTransaction.js';
|
|
2
|
+
export { useSignMessage } from './hooks/useSignMessage.js';
|
|
3
|
+
export { useSignTransaction } from './hooks/useSignTransaction.js';
|
|
4
|
+
export { useSolanaWallet } from './hooks/useSolanaWallet.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createConfig, http } from 'wagmi';
|
|
2
|
+
import { mainnet } from 'wagmi/chains';
|
|
3
|
+
|
|
4
|
+
const defaultWagmiConfig = createConfig({
|
|
5
|
+
chains: [mainnet],
|
|
6
|
+
connectors: [],
|
|
7
|
+
// or your basic wallets
|
|
8
|
+
ssr: true,
|
|
9
|
+
transports: {
|
|
10
|
+
[mainnet.id]: http(mainnet.rpcUrls.default.http[0])
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { defaultWagmiConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WagmiProvider } from './provider.js';
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
|
+
import { useMemo, createElement, useEffect, Fragment } from 'react';
|
|
4
|
+
import { defineChain, webSocket, http } from 'viem';
|
|
5
|
+
import { createConfig, WagmiProvider as WagmiProvider$1, useConfig, useReconnect, useAccountEffect } from 'wagmi';
|
|
6
|
+
import { injected } from 'wagmi/connectors';
|
|
7
|
+
import { defaultWagmiConfig } from './constants.js';
|
|
8
|
+
import { useWeb3Auth } from '../hooks/useWeb3Auth.js';
|
|
9
|
+
import { useWeb3AuthDisconnect } from '../hooks/useWeb3AuthDisconnect.js';
|
|
10
|
+
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
11
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
12
|
+
import { log } from '../../base/loglevel.js';
|
|
13
|
+
|
|
14
|
+
const _excluded = ["children"];
|
|
15
|
+
const WEB3AUTH_CONNECTOR_ID = "web3auth";
|
|
16
|
+
|
|
17
|
+
// Helper to initialize connectors for the given wallets
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
async function setupConnector(provider, config) {
|
|
20
|
+
let connector = config.connectors.find(c => c.id === WEB3AUTH_CONNECTOR_ID);
|
|
21
|
+
if (connector) return connector;
|
|
22
|
+
|
|
23
|
+
// Create new connector if not already existing
|
|
24
|
+
connector = injected({
|
|
25
|
+
target: {
|
|
26
|
+
provider: provider,
|
|
27
|
+
id: WEB3AUTH_CONNECTOR_ID,
|
|
28
|
+
name: "Web3Auth"
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const result = config._internal.connectors.setup(connector);
|
|
32
|
+
config._internal.connectors.setState(current => [...current, result]);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Helper to connect a wallet and update wagmi state
|
|
37
|
+
async function connectWeb3AuthWithWagmi(connector, config) {
|
|
38
|
+
var _config$storage, _config$storage2;
|
|
39
|
+
await Promise.all([(_config$storage = config.storage) === null || _config$storage === void 0 ? void 0 : _config$storage.removeItem(`${connector.id}.disconnected`), (_config$storage2 = config.storage) === null || _config$storage2 === void 0 ? void 0 : _config$storage2.setItem("recentConnectorId", connector.id)]);
|
|
40
|
+
let chainId = await connector.getChainId();
|
|
41
|
+
if (!config.chains.find(c => c.id === chainId)) {
|
|
42
|
+
chainId = config.chains[0].id;
|
|
43
|
+
}
|
|
44
|
+
const accounts = await connector.getAccounts();
|
|
45
|
+
const connections = new Map([[connector.uid, {
|
|
46
|
+
accounts: [accounts[0]],
|
|
47
|
+
chainId,
|
|
48
|
+
connector
|
|
49
|
+
}]]);
|
|
50
|
+
config.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
51
|
+
chainId,
|
|
52
|
+
connections,
|
|
53
|
+
current: connector.uid,
|
|
54
|
+
status: "connected"
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
async function disconnectWeb3AuthFromWagmi(config) {
|
|
58
|
+
config._internal.connectors.setState(prev => prev.filter(c => c.id !== WEB3AUTH_CONNECTOR_ID));
|
|
59
|
+
config.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
60
|
+
chainId: state.chainId,
|
|
61
|
+
connections: new Map(),
|
|
62
|
+
current: undefined,
|
|
63
|
+
status: "disconnected"
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
function Web3AuthWagmiProvider({
|
|
67
|
+
children
|
|
68
|
+
}) {
|
|
69
|
+
const {
|
|
70
|
+
isConnected,
|
|
71
|
+
provider
|
|
72
|
+
} = useWeb3Auth();
|
|
73
|
+
const {
|
|
74
|
+
disconnect
|
|
75
|
+
} = useWeb3AuthDisconnect();
|
|
76
|
+
const wagmiConfig = useConfig();
|
|
77
|
+
const {
|
|
78
|
+
reconnect
|
|
79
|
+
} = useReconnect();
|
|
80
|
+
useAccountEffect({
|
|
81
|
+
onDisconnect: async () => {
|
|
82
|
+
log.info("Disconnected from wagmi");
|
|
83
|
+
if (isConnected) await disconnect();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
(async () => {
|
|
88
|
+
if (isConnected && provider) {
|
|
89
|
+
const connector = await setupConnector(provider, wagmiConfig);
|
|
90
|
+
if (!connector) {
|
|
91
|
+
throw new Error("Failed to setup connector");
|
|
92
|
+
}
|
|
93
|
+
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
94
|
+
reconnect();
|
|
95
|
+
} else if (!isConnected) {
|
|
96
|
+
if (wagmiConfig.state.status === "connected") {
|
|
97
|
+
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
})();
|
|
101
|
+
}, [isConnected, wagmiConfig, provider, reconnect]);
|
|
102
|
+
return createElement(Fragment, null, children);
|
|
103
|
+
}
|
|
104
|
+
function WagmiProvider(_ref) {
|
|
105
|
+
let {
|
|
106
|
+
children
|
|
107
|
+
} = _ref,
|
|
108
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
109
|
+
const {
|
|
110
|
+
config
|
|
111
|
+
} = props;
|
|
112
|
+
const {
|
|
113
|
+
web3Auth,
|
|
114
|
+
isInitialized
|
|
115
|
+
} = useWeb3Auth();
|
|
116
|
+
const finalConfig = useMemo(() => {
|
|
117
|
+
var _web3Auth$coreOptions;
|
|
118
|
+
if (!isInitialized) return defaultWagmiConfig;
|
|
119
|
+
const finalConfig = _objectSpread(_objectSpread({
|
|
120
|
+
ssr: true
|
|
121
|
+
}, config), {}, {
|
|
122
|
+
chains: undefined,
|
|
123
|
+
connectors: [],
|
|
124
|
+
transports: {},
|
|
125
|
+
multiInjectedProviderDiscovery: false,
|
|
126
|
+
client: undefined
|
|
127
|
+
});
|
|
128
|
+
const wagmiChains = [];
|
|
129
|
+
if (isInitialized && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$coreOptions = web3Auth.coreOptions) !== null && _web3Auth$coreOptions !== void 0 && _web3Auth$coreOptions.chains) {
|
|
130
|
+
var _web3Auth$currentChai;
|
|
131
|
+
const defaultChainId = (_web3Auth$currentChai = web3Auth.currentChain) === null || _web3Auth$currentChai === void 0 ? void 0 : _web3Auth$currentChai.chainId;
|
|
132
|
+
const chains = web3Auth.coreOptions.chains.filter(chain => chain.chainNamespace === CHAIN_NAMESPACES.EIP155);
|
|
133
|
+
if (chains.length === 0) throw WalletInitializationError.invalidParams("No valid chains found in web3auth config for wagmi.");
|
|
134
|
+
chains.forEach(chain => {
|
|
135
|
+
const wagmiChain = defineChain({
|
|
136
|
+
id: Number.parseInt(chain.chainId, 16),
|
|
137
|
+
// id in number form
|
|
138
|
+
name: chain.displayName,
|
|
139
|
+
rpcUrls: {
|
|
140
|
+
default: {
|
|
141
|
+
http: [chain.rpcTarget],
|
|
142
|
+
webSocket: [chain.wsTarget]
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
blockExplorers: chain.blockExplorerUrl ? {
|
|
146
|
+
default: {
|
|
147
|
+
name: "explorer",
|
|
148
|
+
// TODO: correct name if chain config has it
|
|
149
|
+
url: chain.blockExplorerUrl
|
|
150
|
+
}
|
|
151
|
+
} : undefined,
|
|
152
|
+
nativeCurrency: {
|
|
153
|
+
name: chain.tickerName,
|
|
154
|
+
symbol: chain.ticker,
|
|
155
|
+
decimals: chain.decimals || 18
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
if (defaultChainId === chain.chainId) {
|
|
159
|
+
wagmiChains.unshift(wagmiChain);
|
|
160
|
+
} else {
|
|
161
|
+
wagmiChains.push(wagmiChain);
|
|
162
|
+
}
|
|
163
|
+
finalConfig.transports[wagmiChain.id] = chain.wsTarget ? webSocket(chain.wsTarget) : http(chain.rpcTarget);
|
|
164
|
+
});
|
|
165
|
+
finalConfig.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
|
|
166
|
+
}
|
|
167
|
+
if (!finalConfig.chains) return;
|
|
168
|
+
return createConfig(finalConfig);
|
|
169
|
+
}, [config, web3Auth, isInitialized]);
|
|
170
|
+
return createElement(WagmiProvider$1, // typecast to WagmiProviderPropsBase to avoid type error
|
|
171
|
+
// as we are omitting the config prop from WagmiProviderProps
|
|
172
|
+
// and creating a new config object with the finalConfig
|
|
173
|
+
_objectSpread(_objectSpread({}, props), {}, {
|
|
174
|
+
config: finalConfig,
|
|
175
|
+
reconnectOnMount: false
|
|
176
|
+
}), createElement(Web3AuthWagmiProvider, null, children));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { WagmiProvider };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defineComponent, h, shallowRef, ref, watch, provide } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './composables/useWeb3AuthInner.js';
|
|
3
|
+
import { WalletServicesContextKey } from './context/WalletServicesContext.js';
|
|
4
|
+
import { WalletServicesPluginError } from '../base/plugin/errors.js';
|
|
5
|
+
import { EVM_PLUGINS, PLUGIN_EVENTS } from '../base/plugin/IPlugin.js';
|
|
6
|
+
import { CONNECTOR_STATUS } from '../base/connector/constants.js';
|
|
7
|
+
|
|
8
|
+
const WalletServicesInnerProvider = defineComponent({
|
|
9
|
+
name: "WalletServicesInnerProvider",
|
|
10
|
+
setup() {
|
|
11
|
+
const web3AuthContext = useWeb3AuthInner();
|
|
12
|
+
if (!web3AuthContext) throw WalletServicesPluginError.fromCode(1000, "`WalletServicesProvider` must be wrapped by `Web3AuthProvider`");
|
|
13
|
+
const {
|
|
14
|
+
getPlugin,
|
|
15
|
+
isInitialized,
|
|
16
|
+
isConnected
|
|
17
|
+
} = web3AuthContext;
|
|
18
|
+
const walletServicesPlugin = shallowRef(null);
|
|
19
|
+
const ready = ref(false);
|
|
20
|
+
const connecting = ref(false);
|
|
21
|
+
watch(isInitialized, newIsInitialized => {
|
|
22
|
+
if (newIsInitialized) {
|
|
23
|
+
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
|
|
24
|
+
walletServicesPlugin.value = plugin;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
watch(isConnected, newIsConnected => {
|
|
28
|
+
if (newIsConnected) {
|
|
29
|
+
var _walletServicesPlugin;
|
|
30
|
+
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
|
|
31
|
+
if (!walletServicesPlugin.value) walletServicesPlugin.value = plugin;
|
|
32
|
+
// when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
|
|
33
|
+
if (((_walletServicesPlugin = walletServicesPlugin.value) === null || _walletServicesPlugin === void 0 ? void 0 : _walletServicesPlugin.status) === CONNECTOR_STATUS.CONNECTED) ready.value = true;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
watch(walletServicesPlugin, (newWalletServicesPlugin, prevWalletServicesPlugin) => {
|
|
37
|
+
const connectedListener = () => {
|
|
38
|
+
ready.value = true;
|
|
39
|
+
};
|
|
40
|
+
const disconnectedListener = () => {
|
|
41
|
+
ready.value = false;
|
|
42
|
+
};
|
|
43
|
+
const connectingListener = () => {
|
|
44
|
+
connecting.value = true;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// unregister previous listeners
|
|
48
|
+
if (prevWalletServicesPlugin && newWalletServicesPlugin !== prevWalletServicesPlugin) {
|
|
49
|
+
prevWalletServicesPlugin.off(PLUGIN_EVENTS.CONNECTED, connectedListener);
|
|
50
|
+
prevWalletServicesPlugin.off(PLUGIN_EVENTS.DISCONNECTED, disconnectedListener);
|
|
51
|
+
prevWalletServicesPlugin.off(PLUGIN_EVENTS.CONNECTING, connectingListener);
|
|
52
|
+
}
|
|
53
|
+
if (newWalletServicesPlugin && newWalletServicesPlugin !== prevWalletServicesPlugin) {
|
|
54
|
+
newWalletServicesPlugin.on(PLUGIN_EVENTS.CONNECTED, connectedListener);
|
|
55
|
+
newWalletServicesPlugin.on(PLUGIN_EVENTS.DISCONNECTED, disconnectedListener);
|
|
56
|
+
newWalletServicesPlugin.on(PLUGIN_EVENTS.CONNECTING, connectingListener);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
provide(WalletServicesContextKey, {
|
|
60
|
+
plugin: walletServicesPlugin,
|
|
61
|
+
ready,
|
|
62
|
+
connecting
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
render() {
|
|
66
|
+
var _this$$slots$default;
|
|
67
|
+
return h((_this$$slots$default = this.$slots.default) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : "");
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export { WalletServicesInnerProvider };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { defineComponent, h, shallowRef, ref, watch, provide } from 'vue';
|
|
2
|
+
import { Web3AuthNoModal } from '../noModal.js';
|
|
3
|
+
import { WalletServicesInnerProvider } from './WalletServicesInnerProvider.js';
|
|
4
|
+
import { CONNECTOR_EVENTS, CONNECTOR_STATUS } from '../base/connector/constants.js';
|
|
5
|
+
import { Web3AuthContextKey } from '../base/composables/index.js';
|
|
6
|
+
import { WalletInitializationError } from '../base/errors/index.js';
|
|
7
|
+
|
|
8
|
+
const Web3AuthProvider = defineComponent({
|
|
9
|
+
name: "Web3AuthProvider",
|
|
10
|
+
props: {
|
|
11
|
+
config: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: true
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
setup(props) {
|
|
17
|
+
const web3Auth = shallowRef(null);
|
|
18
|
+
const provider = ref(null);
|
|
19
|
+
const isMFAEnabled = ref(false);
|
|
20
|
+
const status = ref(null);
|
|
21
|
+
const isInitializing = ref(false);
|
|
22
|
+
const initError = ref(null);
|
|
23
|
+
const isInitialized = ref(false);
|
|
24
|
+
const isConnected = ref(false);
|
|
25
|
+
const getPlugin = name => {
|
|
26
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
27
|
+
return web3Auth.value.getPlugin(name);
|
|
28
|
+
};
|
|
29
|
+
const setIsMFAEnabled = isMfaEnabled => {
|
|
30
|
+
isMFAEnabled.value = isMfaEnabled;
|
|
31
|
+
};
|
|
32
|
+
watch(() => props.config, (newConfig, _, onInvalidate) => {
|
|
33
|
+
const resetHookState = () => {
|
|
34
|
+
provider.value = null;
|
|
35
|
+
isMFAEnabled.value = false;
|
|
36
|
+
isConnected.value = false;
|
|
37
|
+
status.value = null;
|
|
38
|
+
};
|
|
39
|
+
onInvalidate(() => {
|
|
40
|
+
if (web3Auth.value) {
|
|
41
|
+
web3Auth.value.cleanup();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
resetHookState();
|
|
45
|
+
const {
|
|
46
|
+
web3AuthOptions
|
|
47
|
+
} = newConfig;
|
|
48
|
+
const web3AuthInstance = new Web3AuthNoModal(web3AuthOptions);
|
|
49
|
+
web3Auth.value = web3AuthInstance;
|
|
50
|
+
}, {
|
|
51
|
+
immediate: true
|
|
52
|
+
});
|
|
53
|
+
watch(web3Auth, async (newWeb3Auth, _, onInvalidate) => {
|
|
54
|
+
const controller = new AbortController();
|
|
55
|
+
|
|
56
|
+
// Invalidate the controller here before calling any async methods.
|
|
57
|
+
onInvalidate(() => {
|
|
58
|
+
controller.abort();
|
|
59
|
+
});
|
|
60
|
+
if (newWeb3Auth) {
|
|
61
|
+
try {
|
|
62
|
+
initError.value = null;
|
|
63
|
+
isInitializing.value = true;
|
|
64
|
+
await newWeb3Auth.init({
|
|
65
|
+
signal: controller.signal
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
initError.value = error;
|
|
69
|
+
} finally {
|
|
70
|
+
isInitializing.value = false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
immediate: true
|
|
75
|
+
});
|
|
76
|
+
watch(web3Auth, (newWeb3Auth, prevWeb3Auth) => {
|
|
77
|
+
const notReadyListener = () => {
|
|
78
|
+
status.value = web3Auth.value.status;
|
|
79
|
+
};
|
|
80
|
+
const readyListener = () => {
|
|
81
|
+
status.value = web3Auth.value.status;
|
|
82
|
+
isInitialized.value = true;
|
|
83
|
+
};
|
|
84
|
+
const connectedListener = () => {
|
|
85
|
+
status.value = web3Auth.value.status;
|
|
86
|
+
// we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
|
|
87
|
+
if (web3Auth.value.status === CONNECTOR_STATUS.CONNECTED) {
|
|
88
|
+
if (!isInitialized.value) isInitialized.value = true;
|
|
89
|
+
isConnected.value = true;
|
|
90
|
+
provider.value = newWeb3Auth.provider;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const disconnectedListener = () => {
|
|
94
|
+
status.value = web3Auth.value.status;
|
|
95
|
+
isConnected.value = false;
|
|
96
|
+
provider.value = null;
|
|
97
|
+
isMFAEnabled.value = false;
|
|
98
|
+
};
|
|
99
|
+
const connectingListener = () => {
|
|
100
|
+
status.value = web3Auth.value.status;
|
|
101
|
+
};
|
|
102
|
+
const errorListener = () => {
|
|
103
|
+
status.value = web3Auth.value.status;
|
|
104
|
+
};
|
|
105
|
+
const mfaEnabledListener = () => {
|
|
106
|
+
isMFAEnabled.value = true;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// unregister previous listeners
|
|
110
|
+
if (prevWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
|
|
111
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.NOT_READY, notReadyListener);
|
|
112
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.READY, readyListener);
|
|
113
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.CONNECTED, connectedListener);
|
|
114
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
115
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
116
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
117
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
118
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
119
|
+
}
|
|
120
|
+
if (newWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
|
|
121
|
+
status.value = newWeb3Auth.status;
|
|
122
|
+
// web3Auth is initialized here.
|
|
123
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.NOT_READY, notReadyListener);
|
|
124
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.READY, readyListener);
|
|
125
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.CONNECTED, connectedListener);
|
|
126
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
127
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
128
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
129
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
130
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
immediate: true
|
|
134
|
+
});
|
|
135
|
+
provide(Web3AuthContextKey, {
|
|
136
|
+
web3Auth,
|
|
137
|
+
isConnected,
|
|
138
|
+
isInitialized,
|
|
139
|
+
provider,
|
|
140
|
+
status,
|
|
141
|
+
isInitializing,
|
|
142
|
+
initError,
|
|
143
|
+
isMFAEnabled,
|
|
144
|
+
getPlugin,
|
|
145
|
+
setIsMFAEnabled
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
render() {
|
|
149
|
+
var _this$$slots$default;
|
|
150
|
+
return h(WalletServicesInnerProvider, {}, (_this$$slots$default = this.$slots.default) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : "");
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export { Web3AuthProvider };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.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 { ref } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.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 { ref, watch } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.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 };
|