@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,244 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
+
var core = require('@wagmi/core');
|
|
5
|
+
var vue$1 = require('@wagmi/vue');
|
|
6
|
+
var connectors = require('@wagmi/vue/connectors');
|
|
7
|
+
var auth = require('@web3auth/auth');
|
|
8
|
+
var viem = require('viem');
|
|
9
|
+
var vue = require('vue');
|
|
10
|
+
var baseControllers = require('@toruslabs/base-controllers');
|
|
11
|
+
require('@babel/runtime/helpers/defineProperty');
|
|
12
|
+
var index = require('../../base/errors/index.js');
|
|
13
|
+
require('../../base/wallet/index.js');
|
|
14
|
+
require('../../base/connector/constants.js');
|
|
15
|
+
require('jwt-decode');
|
|
16
|
+
var loglevel = require('../../base/loglevel.js');
|
|
17
|
+
require('../../base/plugin/errors.js');
|
|
18
|
+
require('../../base/plugin/IPlugin.js');
|
|
19
|
+
require('@toruslabs/constants');
|
|
20
|
+
require('@toruslabs/http-helpers');
|
|
21
|
+
var useWeb3Auth = require('../composables/useWeb3Auth.js');
|
|
22
|
+
var useWeb3AuthDisconnect = require('../composables/useWeb3AuthDisconnect.js');
|
|
23
|
+
var constants = require('./constants.js');
|
|
24
|
+
|
|
25
|
+
const WEB3AUTH_CONNECTOR_ID = "web3auth";
|
|
26
|
+
// Helper to initialize connectors for the given wallets
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
async function setupConnector(provider, config) {
|
|
29
|
+
let connector = config.connectors.find(c => c.id === WEB3AUTH_CONNECTOR_ID);
|
|
30
|
+
if (connector) return connector;
|
|
31
|
+
// Create new connector if not already existing
|
|
32
|
+
connector = connectors.injected({
|
|
33
|
+
target: {
|
|
34
|
+
provider: provider,
|
|
35
|
+
id: WEB3AUTH_CONNECTOR_ID,
|
|
36
|
+
name: "Web3Auth"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const result = config._internal.connectors.setup(connector);
|
|
40
|
+
config._internal.connectors.setState(current => [...current, result]);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
// Helper to connect a wallet and update wagmi state
|
|
44
|
+
async function connectWeb3AuthWithWagmi(connector, config) {
|
|
45
|
+
var _config$storage, _config$storage2;
|
|
46
|
+
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)]);
|
|
47
|
+
let chainId = await connector.getChainId();
|
|
48
|
+
if (!config.chains.find(c => c.id === chainId)) {
|
|
49
|
+
chainId = config.chains[0].id;
|
|
50
|
+
}
|
|
51
|
+
const accounts = await connector.getAccounts();
|
|
52
|
+
const connections = new Map([[connector.uid, {
|
|
53
|
+
accounts: [accounts[0]],
|
|
54
|
+
chainId,
|
|
55
|
+
connector
|
|
56
|
+
}]]);
|
|
57
|
+
config.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
58
|
+
chainId,
|
|
59
|
+
connections,
|
|
60
|
+
current: connector.uid,
|
|
61
|
+
status: "connected"
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
async function disconnectWeb3AuthFromWagmi(config) {
|
|
65
|
+
config._internal.connectors.setState(prev => prev.filter(c => c.id !== WEB3AUTH_CONNECTOR_ID));
|
|
66
|
+
config.setState(state => _objectSpread(_objectSpread({}, state), {}, {
|
|
67
|
+
chainId: state.chainId,
|
|
68
|
+
connections: new Map(),
|
|
69
|
+
current: undefined,
|
|
70
|
+
status: "disconnected"
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
const Web3AuthWagmiProvider = vue.defineComponent({
|
|
74
|
+
name: "Web3AuthWagmiProvider",
|
|
75
|
+
setup() {
|
|
76
|
+
const {
|
|
77
|
+
isConnected,
|
|
78
|
+
provider
|
|
79
|
+
} = useWeb3Auth.useWeb3Auth();
|
|
80
|
+
const {
|
|
81
|
+
disconnect
|
|
82
|
+
} = useWeb3AuthDisconnect.useWeb3AuthDisconnect();
|
|
83
|
+
const wagmiConfig = vue$1.useConfig();
|
|
84
|
+
const {
|
|
85
|
+
reconnect
|
|
86
|
+
} = vue$1.useReconnect();
|
|
87
|
+
vue$1.useAccountEffect({
|
|
88
|
+
onDisconnect: async () => {
|
|
89
|
+
loglevel.log.info("Disconnected from wagmi");
|
|
90
|
+
if (isConnected.value) await disconnect();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
vue.watch(isConnected, async newIsConnected => {
|
|
94
|
+
if (newIsConnected && provider.value) {
|
|
95
|
+
const connector = await setupConnector(provider.value, wagmiConfig);
|
|
96
|
+
if (!connector) {
|
|
97
|
+
throw new Error("Failed to setup connector");
|
|
98
|
+
}
|
|
99
|
+
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
100
|
+
reconnect();
|
|
101
|
+
} else if (!newIsConnected) {
|
|
102
|
+
if (wagmiConfig.state.status === "connected") {
|
|
103
|
+
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
immediate: true
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
render() {
|
|
111
|
+
var _this$$slots$default;
|
|
112
|
+
return vue.h((_this$$slots$default = this.$slots.default) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : "");
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const Web3AuthWagmiInnerProvider = vue.defineComponent({
|
|
116
|
+
name: "Web3AuthWagmiInnerProvider",
|
|
117
|
+
props: {
|
|
118
|
+
config: {
|
|
119
|
+
type: Object,
|
|
120
|
+
required: false
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
setup(props) {
|
|
124
|
+
const {
|
|
125
|
+
config
|
|
126
|
+
} = props;
|
|
127
|
+
vue.provide(vue$1.configKey, config);
|
|
128
|
+
},
|
|
129
|
+
render() {
|
|
130
|
+
var _this$$slots$default2;
|
|
131
|
+
return vue.h(Web3AuthWagmiProvider, {}, (_this$$slots$default2 = this.$slots.default) !== null && _this$$slots$default2 !== void 0 ? _this$$slots$default2 : "");
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const WagmiProvider = vue.defineComponent({
|
|
135
|
+
name: "WagmiProvider",
|
|
136
|
+
props: {
|
|
137
|
+
config: {
|
|
138
|
+
type: Object,
|
|
139
|
+
required: false
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
setup(props) {
|
|
143
|
+
const {
|
|
144
|
+
config
|
|
145
|
+
} = props;
|
|
146
|
+
const {
|
|
147
|
+
web3Auth,
|
|
148
|
+
isInitialized
|
|
149
|
+
} = useWeb3Auth.useWeb3Auth();
|
|
150
|
+
const finalConfig = vue.shallowRef(constants.defaultWagmiConfig);
|
|
151
|
+
const configKey = vue.ref(auth.randomId());
|
|
152
|
+
const defineWagmiConfig = () => {
|
|
153
|
+
var _web3Auth$value;
|
|
154
|
+
const configParams = _objectSpread(_objectSpread({
|
|
155
|
+
ssr: true
|
|
156
|
+
}, config), {}, {
|
|
157
|
+
chains: undefined,
|
|
158
|
+
connectors: [],
|
|
159
|
+
transports: {},
|
|
160
|
+
multiInjectedProviderDiscovery: false,
|
|
161
|
+
client: undefined
|
|
162
|
+
});
|
|
163
|
+
const wagmiChains = [];
|
|
164
|
+
if (isInitialized.value && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.coreOptions) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chains) {
|
|
165
|
+
var _web3Auth$value$curre;
|
|
166
|
+
const defaultChainId = (_web3Auth$value$curre = web3Auth.value.currentChain) === null || _web3Auth$value$curre === void 0 ? void 0 : _web3Auth$value$curre.chainId;
|
|
167
|
+
const chains = web3Auth.value.coreOptions.chains.filter(chain => chain.chainNamespace === baseControllers.CHAIN_NAMESPACES.EIP155);
|
|
168
|
+
if (chains.length === 0) throw index.WalletInitializationError.invalidParams("No valid chains found in web3auth config for wagmi.");
|
|
169
|
+
chains.forEach(chain => {
|
|
170
|
+
const wagmiChain = viem.defineChain({
|
|
171
|
+
id: Number.parseInt(chain.chainId, 16),
|
|
172
|
+
// id in number form
|
|
173
|
+
name: chain.displayName,
|
|
174
|
+
rpcUrls: {
|
|
175
|
+
default: {
|
|
176
|
+
http: [chain.rpcTarget],
|
|
177
|
+
webSocket: [chain.wsTarget]
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
blockExplorers: chain.blockExplorerUrl ? {
|
|
181
|
+
default: {
|
|
182
|
+
name: "explorer",
|
|
183
|
+
// TODO: correct name if chain config has it
|
|
184
|
+
url: chain.blockExplorerUrl
|
|
185
|
+
}
|
|
186
|
+
} : undefined,
|
|
187
|
+
nativeCurrency: {
|
|
188
|
+
name: chain.tickerName,
|
|
189
|
+
symbol: chain.ticker,
|
|
190
|
+
decimals: chain.decimals || 18
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
if (defaultChainId === chain.chainId) {
|
|
194
|
+
wagmiChains.unshift(wagmiChain);
|
|
195
|
+
} else {
|
|
196
|
+
wagmiChains.push(wagmiChain);
|
|
197
|
+
}
|
|
198
|
+
configParams.transports[wagmiChain.id] = chain.wsTarget ? viem.webSocket(chain.wsTarget) : viem.http(chain.rpcTarget);
|
|
199
|
+
});
|
|
200
|
+
configParams.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
|
|
201
|
+
}
|
|
202
|
+
return vue$1.createConfig(configParams);
|
|
203
|
+
};
|
|
204
|
+
const hydrateWagmiConfig = () => {
|
|
205
|
+
if (finalConfig.value) {
|
|
206
|
+
core.hydrate(finalConfig.value, _objectSpread({
|
|
207
|
+
reconnectOnMount: false
|
|
208
|
+
}, props.config));
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
vue.watch(isInitialized, newIsInitialized => {
|
|
212
|
+
if (newIsInitialized && !finalConfig.value) {
|
|
213
|
+
finalConfig.value = defineWagmiConfig();
|
|
214
|
+
hydrateWagmiConfig();
|
|
215
|
+
configKey.value = auth.randomId();
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
immediate: true
|
|
219
|
+
});
|
|
220
|
+
if (!isInitialized.value) {
|
|
221
|
+
hydrateWagmiConfig();
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
finalConfig,
|
|
225
|
+
configKey
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
render() {
|
|
229
|
+
if (!this.finalConfig) return null;
|
|
230
|
+
return vue.h(Web3AuthWagmiInnerProvider,
|
|
231
|
+
// This key is used to remount the provider when the config changes.
|
|
232
|
+
{
|
|
233
|
+
config: this.finalConfig,
|
|
234
|
+
key: this.configKey
|
|
235
|
+
}, {
|
|
236
|
+
default: () => {
|
|
237
|
+
var _this$$slots$default3, _this$$slots;
|
|
238
|
+
return (_this$$slots$default3 = (_this$$slots = this.$slots).default) === null || _this$$slots$default3 === void 0 ? void 0 : _this$$slots$default3.call(_this$$slots);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
exports.WagmiProvider = WagmiProvider;
|
|
@@ -14,14 +14,19 @@ class BaseConnector extends SafeEventEmitter {
|
|
|
14
14
|
_defineProperty(this, "icon", void 0);
|
|
15
15
|
_defineProperty(this, "coreOptions", void 0);
|
|
16
16
|
_defineProperty(this, "rehydrated", false);
|
|
17
|
+
_defineProperty(this, "connectorNamespace", void 0);
|
|
18
|
+
_defineProperty(this, "type", void 0);
|
|
19
|
+
_defineProperty(this, "name", void 0);
|
|
20
|
+
_defineProperty(this, "status", void 0);
|
|
17
21
|
this.coreOptions = options.coreOptions;
|
|
18
22
|
}
|
|
19
23
|
get connnected() {
|
|
20
24
|
return this.status === CONNECTOR_STATUS.CONNECTED;
|
|
21
25
|
}
|
|
22
26
|
checkConnectionRequirements() {
|
|
23
|
-
// we reconnect without killing existing
|
|
27
|
+
// we reconnect without killing existing Wallet Connect or Metamask Connect session on calling connect again.
|
|
24
28
|
if (this.name === WALLET_CONNECTORS.WALLET_CONNECT_V2 && this.status === CONNECTOR_STATUS.CONNECTING) return;
|
|
29
|
+
if (this.name === WALLET_CONNECTORS.METAMASK && !this.isInjected && this.status === CONNECTOR_STATUS.CONNECTING) return;
|
|
25
30
|
if (this.status === CONNECTOR_STATUS.CONNECTING) throw WalletInitializationError.notReady("Already connecting");
|
|
26
31
|
if (this.status === CONNECTOR_STATUS.CONNECTED) throw WalletLoginError.connectionError("Already connected");
|
|
27
32
|
if (this.status !== CONNECTOR_STATUS.READY) throw WalletLoginError.connectionError("Wallet connector is not ready yet, Please wait for init function to resolve before calling connect/connectTo function");
|
|
@@ -12,7 +12,9 @@ const CONNECTOR_STATUS = {
|
|
|
12
12
|
const CONNECTOR_EVENTS = _objectSpread(_objectSpread({}, CONNECTOR_STATUS), {}, {
|
|
13
13
|
CONNECTOR_DATA_UPDATED: "connector_data_updated",
|
|
14
14
|
CACHE_CLEAR: "cache_clear",
|
|
15
|
-
CONNECTORS_UPDATED: "connectors_updated"
|
|
15
|
+
CONNECTORS_UPDATED: "connectors_updated",
|
|
16
|
+
MFA_ENABLED: "mfa_enabled",
|
|
17
|
+
REHYDRATION_ERROR: "rehydration_error"
|
|
16
18
|
});
|
|
17
19
|
const CONNECTOR_CATEGORY = {
|
|
18
20
|
EXTERNAL: "external",
|
|
@@ -11,5 +11,10 @@ const WIDGET_TYPE = {
|
|
|
11
11
|
MODAL: "modal",
|
|
12
12
|
EMBED: "embed"
|
|
13
13
|
};
|
|
14
|
+
const WEB3AUTH_STATE_STORAGE_KEY = "Web3Auth-state";
|
|
15
|
+
const LOGIN_MODE = {
|
|
16
|
+
MODAL: "modal",
|
|
17
|
+
NO_MODAL: "no-modal"
|
|
18
|
+
};
|
|
14
19
|
|
|
15
|
-
export { MODAL_SIGN_IN_METHODS, SMART_ACCOUNT_WALLET_SCOPE, WIDGET_TYPE };
|
|
20
|
+
export { LOGIN_MODE, MODAL_SIGN_IN_METHODS, SMART_ACCOUNT_WALLET_SCOPE, WEB3AUTH_STATE_STORAGE_KEY, WIDGET_TYPE };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WEB3AUTH_STATE_STORAGE_KEY } from './constants.js';
|
|
2
|
+
import { deserialize } from './deserialize.js';
|
|
3
|
+
|
|
4
|
+
const cookieStorage = options => ({
|
|
5
|
+
getItem(key) {
|
|
6
|
+
if (typeof window === "undefined") return null;
|
|
7
|
+
const value = parseCookie(document.cookie, key);
|
|
8
|
+
return value !== null && value !== void 0 ? value : null;
|
|
9
|
+
},
|
|
10
|
+
setItem(key, value) {
|
|
11
|
+
if (typeof window === "undefined") return;
|
|
12
|
+
let cookieString = `${key}=${value};path=/;samesite=Lax`;
|
|
13
|
+
if (options !== null && options !== void 0 && options.expiry && typeof options.expiry === "number") cookieString += `; expires=${new Date(Date.now() + options.expiry).toUTCString()}`;
|
|
14
|
+
if (process.env.NODE_ENV === "production") cookieString += "; secure";
|
|
15
|
+
document.cookie = cookieString;
|
|
16
|
+
},
|
|
17
|
+
removeItem(key) {
|
|
18
|
+
if (typeof window === "undefined") return;
|
|
19
|
+
document.cookie = `${key}=;max-age=-1;path=/`;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
function cookieToWeb3AuthState(cookie) {
|
|
23
|
+
if (!cookie) return undefined;
|
|
24
|
+
const parsed = parseCookie(cookie, WEB3AUTH_STATE_STORAGE_KEY);
|
|
25
|
+
if (!parsed) return undefined;
|
|
26
|
+
return deserialize(parsed);
|
|
27
|
+
}
|
|
28
|
+
function parseCookie(cookie, key) {
|
|
29
|
+
const keyValue = cookie.split("; ").find(x => x.startsWith(`${key}=`));
|
|
30
|
+
if (!keyValue) return undefined;
|
|
31
|
+
return keyValue.substring(key.length + 1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { cookieStorage, cookieToWeb3AuthState, parseCookie };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function deserialize(value, reviver) {
|
|
2
|
+
return JSON.parse(value, (key, value_) => {
|
|
3
|
+
var _value, _value2, _reviver;
|
|
4
|
+
let value = value_;
|
|
5
|
+
if (((_value = value) === null || _value === void 0 ? void 0 : _value.__type) === "bigint") value = BigInt(value.value);
|
|
6
|
+
if (((_value2 = value) === null || _value2 === void 0 ? void 0 : _value2.__type) === "Map") value = new Map(value.value);
|
|
7
|
+
return (_reviver = void 0 ) !== null && _reviver !== void 0 ? _reviver : value;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { deserialize };
|
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import { CustomError } from 'ts-custom-error';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const index = args.findIndex(arg => arg instanceof Error);
|
|
7
|
-
const msgIndex = args.findIndex(arg => typeof arg === "string");
|
|
8
|
-
const apiErrorIdx = args.findIndex(arg => arg && typeof arg === "object" && "status" in arg && "type" in arg);
|
|
9
|
-
let err;
|
|
10
|
-
if (apiErrorIdx !== -1) {
|
|
11
|
-
const apiError = args[apiErrorIdx];
|
|
12
|
-
err = new Error(`${apiError.status} ${apiError.type.toString()} ${apiError.statusText}`);
|
|
13
|
-
} else if (index !== -1) {
|
|
14
|
-
err = args.splice(index, 1)[0];
|
|
15
|
-
} else if (msgIndex !== -1) {
|
|
16
|
-
err = new Error(args.splice(msgIndex, 1)[0]);
|
|
17
|
-
} else {
|
|
18
|
-
err = new Error("Unknown error");
|
|
19
|
-
}
|
|
20
|
-
return [err, args];
|
|
21
|
-
}
|
|
4
|
+
// @flow
|
|
5
|
+
|
|
22
6
|
class Web3AuthError extends CustomError {
|
|
23
7
|
constructor(code, message, cause) {
|
|
24
8
|
// takes care of stack and proto
|
|
@@ -39,7 +23,7 @@ class Web3AuthError extends CustomError {
|
|
|
39
23
|
name: this.name,
|
|
40
24
|
code: this.code,
|
|
41
25
|
message: this.message,
|
|
42
|
-
cause:
|
|
26
|
+
cause: this.cause
|
|
43
27
|
};
|
|
44
28
|
}
|
|
45
29
|
toString() {
|
|
@@ -50,6 +34,7 @@ class WalletInitializationError extends Web3AuthError {
|
|
|
50
34
|
constructor(code, message, cause) {
|
|
51
35
|
// takes care of stack and proto
|
|
52
36
|
super(code, message, cause);
|
|
37
|
+
|
|
53
38
|
// Set name explicitly as minification can mangle class names
|
|
54
39
|
Object.defineProperty(this, "name", {
|
|
55
40
|
value: "WalletInitializationError"
|
|
@@ -58,6 +43,7 @@ class WalletInitializationError extends Web3AuthError {
|
|
|
58
43
|
static fromCode(code, extraMessage = "", cause) {
|
|
59
44
|
return new WalletInitializationError(code, `${WalletInitializationError.messages[code]}, ${extraMessage}`, cause);
|
|
60
45
|
}
|
|
46
|
+
|
|
61
47
|
// Custom methods
|
|
62
48
|
static notFound(extraMessage = "", cause) {
|
|
63
49
|
return WalletInitializationError.fromCode(5001, extraMessage, cause);
|
|
@@ -96,6 +82,7 @@ class WalletInitializationError extends Web3AuthError {
|
|
|
96
82
|
return WalletInitializationError.fromCode(5013, extraMessage, cause);
|
|
97
83
|
}
|
|
98
84
|
}
|
|
85
|
+
|
|
99
86
|
/**
|
|
100
87
|
* wallet login errors
|
|
101
88
|
*/
|
|
@@ -118,6 +105,7 @@ class WalletLoginError extends Web3AuthError {
|
|
|
118
105
|
constructor(code, message, cause) {
|
|
119
106
|
// takes care of stack and proto
|
|
120
107
|
super(code, message, cause);
|
|
108
|
+
|
|
121
109
|
// Set name explicitly as minification can mangle class names
|
|
122
110
|
Object.defineProperty(this, "name", {
|
|
123
111
|
value: "WalletLoginError"
|
|
@@ -147,7 +135,7 @@ class WalletLoginError extends Web3AuthError {
|
|
|
147
135
|
static unsupportedOperation(extraMessage = "", cause) {
|
|
148
136
|
return WalletLoginError.fromCode(5117, extraMessage, cause);
|
|
149
137
|
}
|
|
150
|
-
static
|
|
138
|
+
static sfaKeyNotFound(extraMessage = "", cause) {
|
|
151
139
|
return WalletLoginError.fromCode(5118, extraMessage, cause);
|
|
152
140
|
}
|
|
153
141
|
static userNotLoggedIn(extraMessage = "", cause) {
|
|
@@ -163,13 +151,14 @@ _defineProperty(WalletLoginError, "messages", {
|
|
|
163
151
|
5115: "User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa",
|
|
164
152
|
5116: "Chain config has not been added. Please add the chain config before calling switchChain",
|
|
165
153
|
5117: "Unsupported operation",
|
|
166
|
-
5118: "
|
|
154
|
+
5118: "useSFAKey flag is enabled but SFA key is not available",
|
|
167
155
|
5119: "User not logged in."
|
|
168
156
|
});
|
|
169
157
|
class WalletOperationsError extends Web3AuthError {
|
|
170
158
|
constructor(code, message, cause) {
|
|
171
159
|
// takes care of stack and proto
|
|
172
160
|
super(code, message, cause);
|
|
161
|
+
|
|
173
162
|
// Set name explicitly as minification can mangle class names
|
|
174
163
|
Object.defineProperty(this, "name", {
|
|
175
164
|
value: "WalletOperationsError"
|
|
@@ -178,6 +167,7 @@ class WalletOperationsError extends Web3AuthError {
|
|
|
178
167
|
static fromCode(code, extraMessage = "", cause) {
|
|
179
168
|
return new WalletOperationsError(code, `${WalletOperationsError.messages[code]}, ${extraMessage}`, cause);
|
|
180
169
|
}
|
|
170
|
+
|
|
181
171
|
// Custom methods
|
|
182
172
|
static chainIDNotAllowed(extraMessage = "", cause) {
|
|
183
173
|
return WalletOperationsError.fromCode(5201, extraMessage, cause);
|
|
@@ -198,6 +188,7 @@ class WalletProviderError extends Web3AuthError {
|
|
|
198
188
|
constructor(code, message, cause) {
|
|
199
189
|
// takes care of stack and proto
|
|
200
190
|
super(code, message, cause);
|
|
191
|
+
|
|
201
192
|
// Set name explicitly as minification can mangle class names
|
|
202
193
|
Object.defineProperty(this, "name", {
|
|
203
194
|
value: "WalletProviderError"
|
|
@@ -206,6 +197,7 @@ class WalletProviderError extends Web3AuthError {
|
|
|
206
197
|
static fromCode(code, extraMessage = "", cause) {
|
|
207
198
|
return new WalletOperationsError(code, `${WalletProviderError.messages[code]}, ${extraMessage}`, cause);
|
|
208
199
|
}
|
|
200
|
+
|
|
209
201
|
// Custom methods
|
|
210
202
|
static invalidRequestArgs(extraMessage = "", cause) {
|
|
211
203
|
return WalletOperationsError.fromCode(5301, extraMessage, cause);
|
|
@@ -224,4 +216,4 @@ _defineProperty(WalletProviderError, "messages", {
|
|
|
224
216
|
5303: "'args.params' must be an object or array if provided."
|
|
225
217
|
});
|
|
226
218
|
|
|
227
|
-
export { WalletInitializationError, WalletLoginError, WalletOperationsError, WalletProviderError, Web3AuthError
|
|
219
|
+
export { WalletInitializationError, WalletLoginError, WalletOperationsError, WalletProviderError, Web3AuthError };
|
|
@@ -5,6 +5,7 @@ class WalletServicesPluginError extends Web3AuthError {
|
|
|
5
5
|
constructor(code, message, cause) {
|
|
6
6
|
// takes care of stack and proto
|
|
7
7
|
super(code, message, cause);
|
|
8
|
+
|
|
8
9
|
// Set name explicitly as minification can mangle class names
|
|
9
10
|
Object.defineProperty(this, "name", {
|
|
10
11
|
value: "WalletServicesPluginError"
|
|
@@ -67,6 +68,7 @@ class NFTCheckoutPluginError extends Web3AuthError {
|
|
|
67
68
|
constructor(code, message, cause) {
|
|
68
69
|
// takes care of stack and proto
|
|
69
70
|
super(code, message, cause);
|
|
71
|
+
|
|
70
72
|
// Set name explicitly as minification can mangle class names
|
|
71
73
|
Object.defineProperty(this, "name", {
|
|
72
74
|
value: "NFTCheckoutPluginError"
|
|
@@ -2,18 +2,16 @@ import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
|
2
2
|
export { cloneDeep } from '@toruslabs/base-controllers';
|
|
3
3
|
import { SIGNER_MAP } from '@toruslabs/constants';
|
|
4
4
|
import { get } from '@toruslabs/http-helpers';
|
|
5
|
-
import '@
|
|
6
|
-
import { WEB3AUTH_NETWORK } from '@web3auth/auth';
|
|
7
|
-
import './errors/index.js';
|
|
8
|
-
import './wallet/index.js';
|
|
9
|
-
import './connector/constants.js';
|
|
10
|
-
import 'jwt-decode';
|
|
5
|
+
import { WEB3AUTH_NETWORK, BUILD_ENV } from '@web3auth/auth';
|
|
11
6
|
|
|
12
7
|
const isHexStrict = hex => {
|
|
13
8
|
return (typeof hex === "string" || typeof hex === "number") && /^(-)?0x[0-9a-f]*$/i.test(hex);
|
|
14
9
|
};
|
|
15
|
-
const signerHost = web3AuthNetwork => {
|
|
16
|
-
|
|
10
|
+
const signerHost = (web3AuthNetwork = WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, authBuildEnv = BUILD_ENV.PRODUCTION) => {
|
|
11
|
+
if (authBuildEnv === BUILD_ENV.TESTING || authBuildEnv === BUILD_ENV.DEVELOPMENT) {
|
|
12
|
+
return "https://test-signer.web3auth.io";
|
|
13
|
+
}
|
|
14
|
+
return SIGNER_MAP[web3AuthNetwork];
|
|
17
15
|
};
|
|
18
16
|
const fetchProjectConfig = async ({
|
|
19
17
|
clientId,
|
|
@@ -21,9 +19,7 @@ const fetchProjectConfig = async ({
|
|
|
21
19
|
aaProvider,
|
|
22
20
|
authBuildEnv
|
|
23
21
|
}) => {
|
|
24
|
-
|
|
25
|
-
// TODO: remove this before production
|
|
26
|
-
const url = new URL("https://test-signer.web3auth.io/api/v2/configuration");
|
|
22
|
+
const url = new URL(`${signerHost(web3AuthNetwork, authBuildEnv)}/api/v2/configuration`);
|
|
27
23
|
url.searchParams.append("project_id", clientId);
|
|
28
24
|
url.searchParams.append("network", web3AuthNetwork);
|
|
29
25
|
if (authBuildEnv) url.searchParams.append("build_env", authBuildEnv);
|
|
@@ -35,17 +31,22 @@ const fetchWalletRegistry = async url => {
|
|
|
35
31
|
const res = await get(url || "https://assets.web3auth.io/v1/wallet-registry.json");
|
|
36
32
|
return res;
|
|
37
33
|
};
|
|
34
|
+
|
|
38
35
|
// Normalize wallet name to a standard format, used for external wallets that are auto-detected by MIPD (EIP-6963 and Wallet Standard)
|
|
39
36
|
const normalizeWalletName = name => {
|
|
40
37
|
let normalizedName = name.toLowerCase();
|
|
41
38
|
// remove decriptive part after | e.g. "Crypto.com | Defi Wallet" => "Crypto.com"
|
|
42
39
|
normalizedName = normalizedName.split("|")[0];
|
|
40
|
+
|
|
43
41
|
// replace - with space e.g. "Trust - Wallet" => "Trust Wallet"
|
|
44
42
|
normalizedName = normalizedName.replace(/-/g, " ");
|
|
43
|
+
|
|
45
44
|
// replace multiple spaces with single space
|
|
46
45
|
normalizedName = normalizedName.replace(/\s+/g, " ");
|
|
46
|
+
|
|
47
47
|
// remove trailing "wallet" e.g. "Trust Wallet" => "Trust", "GateWallet" => "Gate"
|
|
48
48
|
normalizedName = normalizedName.replace(/wallet$/i, "").trim();
|
|
49
|
+
|
|
49
50
|
// replace space with -
|
|
50
51
|
normalizedName = normalizedName.replace(/\s/g, "-");
|
|
51
52
|
return normalizedName;
|
|
@@ -66,6 +67,21 @@ const fromWagmiChain = chain => {
|
|
|
66
67
|
wsTarget: (_chain$rpcUrls$defaul = chain.rpcUrls.default.webSocket) === null || _chain$rpcUrls$defaul === void 0 ? void 0 : _chain$rpcUrls$defaul[0]
|
|
67
68
|
};
|
|
68
69
|
};
|
|
70
|
+
function withAbort(fn, signal, onAbort) {
|
|
71
|
+
if (!signal) return fn();
|
|
72
|
+
if (signal.aborted) return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
const abort = () => {
|
|
75
|
+
onAbort === null || onAbort === void 0 || onAbort();
|
|
76
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
77
|
+
};
|
|
78
|
+
signal.addEventListener("abort", abort);
|
|
79
|
+
return Promise.resolve().then(() => fn()).then(resolve, reject).finally(() => {
|
|
80
|
+
signal.removeEventListener("abort", abort);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
69
85
|
const fromViemChain = fromWagmiChain;
|
|
70
86
|
|
|
71
|
-
export { fetchProjectConfig, fetchWalletRegistry, fromViemChain, fromWagmiChain, isHexStrict, normalizeWalletName, signerHost };
|
|
87
|
+
export { fetchProjectConfig, fetchWalletRegistry, fromViemChain, fromWagmiChain, isBrowser, isHexStrict, normalizeWalletName, signerHost, withAbort };
|
|
@@ -3,18 +3,16 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
3
3
|
const MULTI_CHAIN_CONNECTORS = {
|
|
4
4
|
AUTH: "auth",
|
|
5
5
|
WALLET_CONNECT_V2: "wallet-connect-v2",
|
|
6
|
-
|
|
6
|
+
METAMASK: "metamask"
|
|
7
7
|
};
|
|
8
8
|
const SOLANA_CONNECTORS = _objectSpread({}, MULTI_CHAIN_CONNECTORS);
|
|
9
9
|
const EVM_CONNECTORS = _objectSpread({
|
|
10
|
-
COINBASE: "coinbase"
|
|
11
|
-
METAMASK: "metamask"
|
|
10
|
+
COINBASE: "coinbase"
|
|
12
11
|
}, MULTI_CHAIN_CONNECTORS);
|
|
13
12
|
const WALLET_CONNECTORS = _objectSpread(_objectSpread({}, EVM_CONNECTORS), SOLANA_CONNECTORS);
|
|
14
13
|
const CONNECTOR_NAMES = {
|
|
15
14
|
[MULTI_CHAIN_CONNECTORS.AUTH]: "Auth",
|
|
16
15
|
[MULTI_CHAIN_CONNECTORS.WALLET_CONNECT_V2]: "Wallet Connect v2",
|
|
17
|
-
[MULTI_CHAIN_CONNECTORS.SFA]: "SFA",
|
|
18
16
|
[EVM_CONNECTORS.COINBASE]: "Coinbase Smart Wallet",
|
|
19
17
|
[EVM_CONNECTORS.METAMASK]: "MetaMask"
|
|
20
18
|
};
|