diff --git a/demo/react-app-no-modal/package-lock.json b/demo/react-app-no-modal/package-lock.json index 3fde705ac..33b969ad8 100644 --- a/demo/react-app-no-modal/package-lock.json +++ b/demo/react-app-no-modal/package-lock.json @@ -44,11 +44,11 @@ }, "../../packages/adapters/coinbase-adapter": { "name": "@web3auth/coinbase-adapter", - "version": "8.0.1", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.1" + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" }, "devDependencies": { "@coinbase/wallet-sdk": "^3.7.2" @@ -64,12 +64,12 @@ }, "../../packages/adapters/metamask-adapter": { "name": "@web3auth/metamask-adapter", - "version": "8.0.1", + "version": "8.5.0", "license": "ISC", "dependencies": { "@metamask/detect-provider": "^2.0.0", - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.1" + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -81,13 +81,13 @@ }, "../../packages/adapters/openlogin-adapter": { "name": "@web3auth/openlogin-adapter", - "version": "8.0.1", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-utils": "^7.0.4", - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.1", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-utils": "^8.1.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "lodash.merge": "^4.6.2" }, "devDependencies": { @@ -103,13 +103,13 @@ }, "../../packages/adapters/phantom-adapter": { "name": "@web3auth/phantom-adapter", - "version": "8.0.1", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.1", - "@web3auth/base-solana-adapter": "^8.0.1", - "@web3auth/solana-provider": "^8.0.1", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/base-solana-adapter": "^8.5.0", + "@web3auth/solana-provider": "^8.5.0", "bn.js": "^5.2.1" }, "engines": { @@ -123,12 +123,12 @@ }, "../../packages/adapters/torus-evm-adapter": { "name": "@web3auth/torus-evm-adapter", - "version": "8.0.1", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/torus-embed": "^4.1.3", - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.1" + "@toruslabs/torus-embed": "^5.0.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -140,14 +140,14 @@ }, "../../packages/base": { "name": "@web3auth/base", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/constants": "^13.2.0", - "@toruslabs/http-helpers": "^6.0.0", - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-jrpc": "^7.0.0", - "@toruslabs/openlogin-utils": "^7.0.4", + "@toruslabs/constants": "^13.4.0", + "@toruslabs/http-helpers": "^6.1.1", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@toruslabs/openlogin-utils": "^8.1.0", "jwt-decode": "^4.0.0", "loglevel": "^1.9.1", "ts-custom-error": "^3.3.1" @@ -162,21 +162,20 @@ }, "../../packages/no-modal": { "name": "@web3auth/no-modal", - "version": "8.0.1", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-jrpc": "^7.0.0", - "@toruslabs/openlogin-utils": "^7.0.4", - "@web3auth/base": "file:../base", - "@web3auth/base-plugin": "^8.0.1", - "@web3auth/base-provider": "^8.0.1", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@toruslabs/openlogin-utils": "^8.1.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "lodash.clonedeep": "^4.5.0", "lodash.merge": "^4.6.2" }, "devDependencies": { - "@web3auth/openlogin-adapter": "^8.0.1", - "@web3auth/wallet-connect-v2-adapter": "^8.0.1" + "@web3auth/openlogin-adapter": "^8.5.0", + "@web3auth/wallet-connect-v2-adapter": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -25020,11 +25019,11 @@ "@web3auth/base": { "version": "file:../../packages/base", "requires": { - "@toruslabs/constants": "^13.2.0", - "@toruslabs/http-helpers": "^6.0.0", - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-jrpc": "^7.0.0", - "@toruslabs/openlogin-utils": "^7.0.4", + "@toruslabs/constants": "^13.4.0", + "@toruslabs/http-helpers": "^6.1.1", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@toruslabs/openlogin-utils": "^8.1.0", "jwt-decode": "^4.0.0", "loglevel": "^1.9.1", "ts-custom-error": "^3.3.1" @@ -25034,29 +25033,28 @@ "version": "file:../../packages/adapters/coinbase-adapter", "requires": { "@coinbase/wallet-sdk": "^3.7.2", - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.1" + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" } }, "@web3auth/metamask-adapter": { "version": "file:../../packages/adapters/metamask-adapter", "requires": { "@metamask/detect-provider": "^2.0.0", - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.1" + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" } }, "@web3auth/no-modal": { "version": "file:../../packages/no-modal", "requires": { - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-jrpc": "^7.0.0", - "@toruslabs/openlogin-utils": "^7.0.4", - "@web3auth/base": "file:../base", - "@web3auth/base-plugin": "^8.0.1", - "@web3auth/base-provider": "^8.0.1", - "@web3auth/openlogin-adapter": "^8.0.1", - "@web3auth/wallet-connect-v2-adapter": "^8.0.1", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@toruslabs/openlogin-utils": "^8.1.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/openlogin-adapter": "^8.5.0", + "@web3auth/wallet-connect-v2-adapter": "^8.5.0", "lodash.clonedeep": "^4.5.0", "lodash.merge": "^4.6.2" } @@ -25064,30 +25062,30 @@ "@web3auth/openlogin-adapter": { "version": "file:../../packages/adapters/openlogin-adapter", "requires": { - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-utils": "^7.0.4", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-utils": "^8.1.0", "@types/lodash.merge": "^4.6.9", - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.1", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "lodash.merge": "^4.6.2" } }, "@web3auth/phantom-adapter": { "version": "file:../../packages/adapters/phantom-adapter", "requires": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.1", - "@web3auth/base-solana-adapter": "^8.0.1", - "@web3auth/solana-provider": "^8.0.1", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/base-solana-adapter": "^8.5.0", + "@web3auth/solana-provider": "^8.5.0", "bn.js": "^5.2.1" } }, "@web3auth/torus-evm-adapter": { "version": "file:../../packages/adapters/torus-evm-adapter", "requires": { - "@toruslabs/torus-embed": "^4.1.3", - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.1" + "@toruslabs/torus-embed": "^5.0.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" } }, "@webassemblyjs/ast": { diff --git a/demo/react-app/package-lock.json b/demo/react-app/package-lock.json index b5c9dd062..4a756a6db 100644 --- a/demo/react-app/package-lock.json +++ b/demo/react-app/package-lock.json @@ -37,13 +37,13 @@ }, "../../packages/adapters/openlogin-adapter": { "name": "@web3auth/openlogin-adapter", - "version": "8.4.0", + "version": "8.5.0", "license": "ISC", "dependencies": { "@toruslabs/openlogin": "^8.1.0", "@toruslabs/openlogin-utils": "^8.1.0", - "@web3auth/base": "^8.4.0", - "@web3auth/base-provider": "^8.4.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "lodash.merge": "^4.6.2" }, "devDependencies": { @@ -59,10 +59,10 @@ }, "../../packages/base": { "name": "@web3auth/base", - "version": "8.4.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/constants": "^13.3.0", + "@toruslabs/constants": "^13.4.0", "@toruslabs/http-helpers": "^6.1.1", "@toruslabs/openlogin": "^8.1.0", "@toruslabs/openlogin-jrpc": "^8.1.1", @@ -81,14 +81,14 @@ }, "../../packages/modal": { "name": "@web3auth/modal", - "version": "8.4.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.4.0", - "@web3auth/base-provider": "^8.4.0", - "@web3auth/no-modal": "^8.4.0", - "@web3auth/openlogin-adapter": "^8.4.0", - "@web3auth/ui": "^8.4.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/no-modal": "^8.5.0", + "@web3auth/openlogin-adapter": "^8.5.0", + "@web3auth/ui": "^8.5.0", "lodash.clonedeep": "^4.5.0", "lodash.merge": "^4.6.2" }, @@ -96,7 +96,7 @@ "@svgr/webpack": "^8.1.0", "@toruslabs/isomorphic-style-loader": "^5.3.3", "@toruslabs/openlogin-utils": "^8.1.0", - "@web3auth/wallet-connect-v2-adapter": "^8.4.0", + "@web3auth/wallet-connect-v2-adapter": "^8.5.0", "css-loader": "^7.1.1", "postcss-prefix-selector": "^1.16.1", "style-loader": "^4.0.0", @@ -118,45 +118,43 @@ }, "../../packages/plugins/wallet-services-plugin": { "name": "@web3auth/wallet-services-plugin", - "version": "8.4.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/ethereum-controllers": "^5.5.7", "@toruslabs/openlogin-jrpc": "^8.1.1", - "@web3auth/base": "^8.4.0", - "@web3auth/no-modal": "^8.4.0", - "@web3auth/ws-embed": "^1.2.0", + "@web3auth/base": "^8.5.0", + "@web3auth/no-modal": "^8.5.0", + "@web3auth/ws-embed": "^2.0.0", "loglevel": "^1.9.1" }, "devDependencies": { "@metamask/rpc-errors": "^6.2.1", - "@web3auth/openlogin-adapter": "^8.4.0" + "@toruslabs/ethereum-controllers": "^5.6.1", + "@toruslabs/openlogin-utils": "^8.1.2" }, "engines": { "node": ">=18.x", "npm": ">=9.x" }, "peerDependencies": { - "@babel/runtime": "^7.x", - "@web3auth/openlogin-adapter": "^8.x" + "@babel/runtime": "^7.x" } }, "../../packages/providers/ethereum-provider": { "name": "@web3auth/ethereum-provider", - "version": "8.4.0", + "version": "8.5.0", "license": "ISC", "dependencies": { "@ethereumjs/common": "^4.3.0", "@ethereumjs/tx": "^5.3.0", "@ethereumjs/util": "^9.0.3", - "@metamask/eth-sig-util": "^7.0.1", + "@metamask/eth-sig-util": "^7.0.2", "@metamask/rpc-errors": "^6.2.1", - "@toruslabs/base-controllers": "^5.5.5", + "@toruslabs/base-controllers": "^5.6.0", "@toruslabs/http-helpers": "^6.1.1", "@toruslabs/openlogin-jrpc": "^8.1.1", - "@walletconnect/utils": "^2.12.2", - "@web3auth/base": "^8.4.0", - "@web3auth/base-provider": "^8.4.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "assert": "^2.1.0", "bignumber.js": "^9.1.2", "bn.js": "^5.2.1", @@ -177,22 +175,22 @@ }, "../../packages/providers/solana-provider": { "name": "@web3auth/solana-provider", - "version": "8.4.0", + "version": "8.5.0", "license": "ISC", "dependencies": { "@metamask/rpc-errors": "^6.2.1", - "@toruslabs/base-controllers": "^5.5.5", + "@toruslabs/base-controllers": "^5.6.0", "@toruslabs/openlogin-ed25519": "^8.1.0", "@toruslabs/openlogin-jrpc": "^8.1.1", "@toruslabs/tweetnacl-js": "^1.0.4", - "@web3auth/base": "^8.4.0", - "@web3auth/base-provider": "^8.4.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "bn.js": "^5.2.1", "bs58": "^5.0.0", "json-rpc-random-id": "^1.0.1" }, "devDependencies": { - "@solana/web3.js": "^1.91.7", + "@solana/web3.js": "^1.91.8", "@solflare-wallet/sdk": "^1.4.2", "@types/bn.js": "^5.1.5", "@types/bs58": "^4.0.4", diff --git a/demo/react-app/src/App.tsx b/demo/react-app/src/App.tsx index b59d9ceb5..c5a7fa420 100644 --- a/demo/react-app/src/App.tsx +++ b/demo/react-app/src/App.tsx @@ -16,7 +16,7 @@ function App() { const savedNetwork = window.localStorage.getItem(STORAGE_KEY.WEB3AUTH_NETWORK) as WEB3AUTH_NETWORK_TYPE; const savedChain = window.localStorage.getItem(STORAGE_KEY.BLOCKCHAIN) as CHAIN_CONFIG_TYPE; const [web3AuthNetwork, setWeb3AuthNetwork] = useState(savedNetwork || "sapphire_mainnet"); - const [chain, setChain] = useState(savedChain || "polygon-mumbai"); + const [chain, setChain] = useState(savedChain || "polygon-amoy"); const networkChangeHandler = (network: WEB3AUTH_NETWORK_TYPE) => { window.localStorage.setItem(STORAGE_KEY.WEB3AUTH_NETWORK, network); diff --git a/demo/vue-app/package-lock.json b/demo/vue-app/package-lock.json index bb7b720be..731fa4682 100644 --- a/demo/vue-app/package-lock.json +++ b/demo/vue-app/package-lock.json @@ -62,11 +62,11 @@ }, "../../packages/adapters/base-evm-adapter": { "name": "@web3auth/base-evm-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/base-controllers": "^5.5.0", - "@web3auth/base": "^8.0.0" + "@toruslabs/base-controllers": "^5.6.0", + "@web3auth/base": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -78,11 +78,11 @@ }, "../../packages/adapters/base-solana-adapter": { "name": "@web3auth/base-solana-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/base-controllers": "^5.5.0", - "@web3auth/base": "^8.0.0", + "@toruslabs/base-controllers": "^5.6.0", + "@web3auth/base": "^8.5.0", "bs58": "^5.0.0" }, "devDependencies": { @@ -98,12 +98,12 @@ }, "../../packages/adapters/metamask-adapter": { "name": "@web3auth/metamask-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { "@metamask/detect-provider": "^2.0.0", - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.0" + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -115,13 +115,13 @@ }, "../../packages/adapters/openlogin-adapter": { "name": "@web3auth/openlogin-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-utils": "^7.0.4", - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-utils": "^8.1.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "lodash.merge": "^4.6.2" }, "devDependencies": { @@ -153,13 +153,13 @@ }, "../../packages/adapters/phantom-adapter": { "name": "@web3auth/phantom-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", - "@web3auth/base-solana-adapter": "^8.0.0", - "@web3auth/solana-provider": "^8.0.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/base-solana-adapter": "^8.5.0", + "@web3auth/solana-provider": "^8.5.0", "bn.js": "^5.2.1" }, "engines": { @@ -173,13 +173,13 @@ }, "../../packages/adapters/slope-adapter": { "name": "@web3auth/slope-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", - "@web3auth/base-solana-adapter": "^8.0.0", - "@web3auth/solana-provider": "^8.0.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/base-solana-adapter": "^8.5.0", + "@web3auth/solana-provider": "^8.5.0", "bn.js": "^5.2.1" }, "engines": { @@ -193,17 +193,17 @@ }, "../../packages/adapters/solflare-adapter": { "name": "@web3auth/solflare-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", - "@web3auth/base-solana-adapter": "^8.0.0", - "@web3auth/solana-provider": "^8.0.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/base-solana-adapter": "^8.5.0", + "@web3auth/solana-provider": "^8.5.0", "bn.js": "^5.2.1" }, "devDependencies": { - "@solana/web3.js": "^1.90.0", + "@solana/web3.js": "^1.91.8", "@solflare-wallet/sdk": "^1.4.2" }, "engines": { @@ -218,12 +218,12 @@ }, "../../packages/adapters/torus-evm-adapter": { "name": "@web3auth/torus-evm-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/torus-embed": "^4.1.3", - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.0" + "@toruslabs/torus-embed": "^5.0.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -235,14 +235,14 @@ }, "../../packages/adapters/torus-solana-adapter": { "name": "@web3auth/torus-solana-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/solana-embed": "^2.0.0", - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", - "@web3auth/base-solana-adapter": "^8.0.0", - "@web3auth/solana-provider": "^8.0.0" + "@toruslabs/solana-embed": "^2.1.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/base-solana-adapter": "^8.5.0", + "@web3auth/solana-provider": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -256,19 +256,22 @@ "../../packages/adapters/wallet-connect-v1-adapter": {}, "../../packages/adapters/wallet-connect-v2-adapter": { "name": "@web3auth/wallet-connect-v2-adapter", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-evm-adapter": "^8.0.0", - "@web3auth/ethereum-provider": "^8.0.0", + "@metamask/rpc-errors": "^6.2.1", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@web3auth/base": "^8.5.0", + "@web3auth/base-evm-adapter": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/ethereum-provider": "^8.5.0", "lodash.merge": "^4.6.2" }, "devDependencies": { "@types/lodash.merge": "^4.6.9", - "@walletconnect/sign-client": "^2.11.1", - "@walletconnect/types": "^2.11.1", - "@walletconnect/utils": "^2.11.1" + "@walletconnect/sign-client": "^2.12.2", + "@walletconnect/types": "^2.12.2", + "@walletconnect/utils": "^2.12.2" }, "engines": { "node": ">=18.x", @@ -283,13 +286,14 @@ }, "../../packages/base": { "name": "@web3auth/base", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/http-helpers": "^6.0.0", - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-jrpc": "^7.0.0", - "@toruslabs/openlogin-utils": "^7.0.4", + "@toruslabs/constants": "^13.4.0", + "@toruslabs/http-helpers": "^6.1.1", + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@toruslabs/openlogin-utils": "^8.1.0", "jwt-decode": "^4.0.0", "loglevel": "^1.9.1", "ts-custom-error": "^3.3.1" @@ -354,23 +358,25 @@ }, "../../packages/modal": { "name": "@web3auth/modal", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", - "@web3auth/no-modal": "^8.0.0", - "@web3auth/openlogin-adapter": "^8.0.0", - "@web3auth/ui": "^8.0.0" + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "@web3auth/no-modal": "^8.5.0", + "@web3auth/openlogin-adapter": "^8.5.0", + "@web3auth/ui": "^8.5.0", + "lodash.clonedeep": "^4.5.0", + "lodash.merge": "^4.6.2" }, "devDependencies": { "@svgr/webpack": "^8.1.0", "@toruslabs/isomorphic-style-loader": "^5.3.3", - "@toruslabs/openlogin-utils": "^7.0.4", - "@web3auth/wallet-connect-v2-adapter": "^8.0.0", - "css-loader": "^6.10.0", - "postcss-prefix-selector": "^1.16.0", - "style-loader": "^3.3.4", + "@toruslabs/openlogin-utils": "^8.1.0", + "@web3auth/wallet-connect-v2-adapter": "^8.5.0", + "css-loader": "^7.1.1", + "postcss-prefix-selector": "^1.16.1", + "style-loader": "^4.0.0", "url-loader": "^4.1.1" }, "engines": { @@ -406,19 +412,20 @@ }, "../../packages/no-modal": { "name": "@web3auth/no-modal", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/openlogin": "^7.0.4", - "@toruslabs/openlogin-jrpc": "^7.0.0", - "@toruslabs/openlogin-utils": "^7.0.4", - "@web3auth/base": "^8.0.0", - "@web3auth/base-plugin": "^8.0.0", - "@web3auth/base-provider": "^8.0.0" + "@toruslabs/openlogin": "^8.1.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@toruslabs/openlogin-utils": "^8.1.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", + "lodash.clonedeep": "^4.5.0", + "lodash.merge": "^4.6.2" }, "devDependencies": { - "@web3auth/openlogin-adapter": "^8.0.0", - "@web3auth/wallet-connect-v2-adapter": "^8.0.0" + "@web3auth/openlogin-adapter": "^8.5.0", + "@web3auth/wallet-connect-v2-adapter": "^8.5.0" }, "engines": { "node": ">=18.x", @@ -490,17 +497,17 @@ }, "../../packages/plugins/solana-wallet-connector-plugin": { "name": "@web3auth/solana-wallet-connector-plugin", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/solana-embed": "^2.0.0", - "@web3auth/base": "^8.0.0", - "@web3auth/base-plugin": "^8.0.0", - "@web3auth/no-modal": "^8.0.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@toruslabs/solana-embed": "^2.1.0", + "@web3auth/base": "^8.5.0", + "@web3auth/no-modal": "^8.5.0", "loglevel": "^1.9.1" }, "devDependencies": { - "@metamask/rpc-errors": "^6.1.0" + "@metamask/rpc-errors": "^6.2.1" }, "engines": { "node": ">=18.x", @@ -514,20 +521,19 @@ "../../packages/plugins/wallet-services-connector-plugin": {}, "../../packages/providers/ethereum-provider": { "name": "@web3auth/ethereum-provider", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@ethereumjs/common": "^4.2.0", - "@ethereumjs/tx": "^5.2.1", - "@ethereumjs/util": "^9.0.2", - "@metamask/eth-sig-util": "^7.0.1", - "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.5.0", - "@toruslabs/http-helpers": "^6.0.0", - "@toruslabs/openlogin-jrpc": "^7.0.0", - "@walletconnect/utils": "^2.11.1", - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", + "@ethereumjs/common": "^4.3.0", + "@ethereumjs/tx": "^5.3.0", + "@ethereumjs/util": "^9.0.3", + "@metamask/eth-sig-util": "^7.0.2", + "@metamask/rpc-errors": "^6.2.1", + "@toruslabs/base-controllers": "^5.6.0", + "@toruslabs/http-helpers": "^6.1.1", + "@toruslabs/openlogin-jrpc": "^8.1.1", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "assert": "^2.1.0", "bignumber.js": "^9.1.2", "bn.js": "^5.2.1", @@ -536,7 +542,7 @@ "devDependencies": { "@types/bn.js": "^5.1.5", "@types/json-rpc-random-id": "^1.0.3", - "@walletconnect/types": "^2.11.1" + "@walletconnect/types": "^2.12.2" }, "engines": { "node": ">=18.x", @@ -582,22 +588,22 @@ }, "../../packages/providers/solana-provider": { "name": "@web3auth/solana-provider", - "version": "8.0.0", + "version": "8.5.0", "license": "ISC", "dependencies": { - "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.5.0", - "@toruslabs/openlogin-ed25519": "^7.0.0", - "@toruslabs/openlogin-jrpc": "^7.0.0", + "@metamask/rpc-errors": "^6.2.1", + "@toruslabs/base-controllers": "^5.6.0", + "@toruslabs/openlogin-ed25519": "^8.1.0", + "@toruslabs/openlogin-jrpc": "^8.1.1", "@toruslabs/tweetnacl-js": "^1.0.4", - "@web3auth/base": "^8.0.0", - "@web3auth/base-provider": "^8.0.0", + "@web3auth/base": "^8.5.0", + "@web3auth/base-provider": "^8.5.0", "bn.js": "^5.2.1", "bs58": "^5.0.0", "json-rpc-random-id": "^1.0.1" }, "devDependencies": { - "@solana/web3.js": "^1.90.0", + "@solana/web3.js": "^1.91.8", "@solflare-wallet/sdk": "^1.4.2", "@types/bn.js": "^5.1.5", "@types/bs58": "^4.0.4", diff --git a/package-lock.json b/package-lock.json index 646c6c94b..ac9f8edb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5775,9 +5775,9 @@ } }, "node_modules/@toruslabs/openlogin-utils": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@toruslabs/openlogin-utils/-/openlogin-utils-8.1.0.tgz", - "integrity": "sha512-Dwr+h2ijnaF24psfXW/r6CguKko8DpvwsHuzjj12N/NNWbzPOL13I8kLl7FR89oD5mnyzttd2RlmaP5rmAwJsQ==", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@toruslabs/openlogin-utils/-/openlogin-utils-8.1.2.tgz", + "integrity": "sha512-UpSb/ubgmu6N8O0wq06ZnUP3NOju8ZBMbVQK/CmbCP2Tba3S5eqvLaHE+7/FBWFeb+szEYX4FTgshEviUvlHjg==", "dependencies": { "@toruslabs/constants": "^13.2.0", "base64url": "^3.0.1", @@ -30789,7 +30789,6 @@ "version": "8.5.0", "license": "ISC", "dependencies": { - "@toruslabs/ethereum-controllers": "^5.6.1", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.5.0", "@web3auth/no-modal": "^8.5.0", @@ -30798,7 +30797,8 @@ }, "devDependencies": { "@metamask/rpc-errors": "^6.2.1", - "@web3auth/openlogin-adapter": "^8.5.0" + "@toruslabs/ethereum-controllers": "^5.6.1", + "@toruslabs/openlogin-utils": "^8.1.2" }, "engines": { "node": ">=18.x", diff --git a/packages/base/src/core/IWeb3Auth.ts b/packages/base/src/core/IWeb3Auth.ts index b83da5d00..48f7d37a6 100644 --- a/packages/base/src/core/IWeb3Auth.ts +++ b/packages/base/src/core/IWeb3Auth.ts @@ -63,15 +63,25 @@ export interface IWeb3AuthCoreOptions { privateKeyProvider?: IBaseProvider; } -export interface IWeb3Auth extends SafeEventEmitter { +export interface IWeb3AuthCore extends SafeEventEmitter { readonly coreOptions: IWeb3AuthCoreOptions; - connected: boolean; connectedAdapterName: string | null; status: ADAPTER_STATUS_TYPE; - cachedAdapter: string | null; provider: IProvider | null; - walletAdapters: Record>; init(): Promise; + logout(options?: { cleanup: boolean }): Promise; + getUserInfo(): Promise>; + authenticateUser(): Promise; + addChain(chainConfig: CustomChainConfig): Promise; + switchChain(params: { chainId: string }): Promise; + addPlugin(plugin: IPlugin): void; + getPlugin(pluginName: string): IPlugin | null; +} + +export interface IWeb3Auth extends IWeb3AuthCore { + connected: boolean; + cachedAdapter: string | null; + walletAdapters: Record>; getAdapter(adapterName: WALLET_ADAPTER_TYPE): IAdapter | null; configureAdapter(adapter: IAdapter): IWeb3Auth; /** @@ -79,14 +89,7 @@ export interface IWeb3Auth extends SafeEventEmitter { * @param walletName - Key of the walletAdapter to use. */ connectTo(walletName: WALLET_ADAPTER_TYPE, loginParams?: T): Promise; - logout(options?: { cleanup: boolean }): Promise; - getUserInfo(): Promise>; - authenticateUser(): Promise; - addChain(chainConfig: CustomChainConfig): Promise; - switchChain(params: { chainId: string }): Promise; enableMFA(params: T): Promise; - addPlugin(plugin: IPlugin): void; - getPlugin(pluginName: string): IPlugin | null; } export type Web3AuthNoModalOptions = IWeb3AuthCoreOptions; diff --git a/packages/base/src/plugin/IPlugin.ts b/packages/base/src/plugin/IPlugin.ts index 14e8af6e4..b7e747f5b 100644 --- a/packages/base/src/plugin/IPlugin.ts +++ b/packages/base/src/plugin/IPlugin.ts @@ -1,8 +1,8 @@ import { type SafeEventEmitter } from "@toruslabs/openlogin-jrpc"; +import { WhiteLabelData } from "@toruslabs/openlogin-utils"; -import { IProvider, UserInfo } from "../adapter"; import { CHAIN_NAMESPACES } from "../chain/IChainInterface"; -import { type IWeb3Auth } from "../core/IWeb3Auth"; +import { type IWeb3AuthCore } from "../core/IWeb3Auth"; import { WALLET_ADAPTER_TYPE } from "../wallet"; export const PLUGIN_NAMESPACES = { @@ -39,13 +39,17 @@ export const WALLET_PLUGINS = { ...SOLANA_PLUGINS, } as const; +export interface PluginConnectParams { + sessionId: string; + sessionNamespace?: string; +} + export interface IPlugin extends SafeEventEmitter { name: string; status: PLUGIN_STATUS_TYPE; SUPPORTED_ADAPTERS: WALLET_ADAPTER_TYPE[]; pluginNamespace: PluginNamespace; - initWithProvider(provider: IProvider, userInfo: UserInfo): Promise; - initWithWeb3Auth(web3auth: IWeb3Auth): Promise; - connect(): Promise; + initWithWeb3Auth(web3auth: IWeb3AuthCore, whiteLabel?: WhiteLabelData): Promise; + connect(params: PluginConnectParams): Promise; disconnect(): Promise; } diff --git a/packages/base/src/wallet/index.ts b/packages/base/src/wallet/index.ts index a81338719..e4d8db829 100644 --- a/packages/base/src/wallet/index.ts +++ b/packages/base/src/wallet/index.ts @@ -1,6 +1,7 @@ export const MULTI_CHAIN_ADAPTERS = { OPENLOGIN: "openlogin", WALLET_CONNECT_V2: "wallet-connect-v2", + SFA: "sfa", }; export const SOLANA_ADAPTERS = { @@ -30,6 +31,7 @@ export type MULTI_CHAIN_ADAPTER_TYPE = (typeof MULTI_CHAIN_ADAPTERS)[keyof typeo export const ADAPTER_NAMES = { [MULTI_CHAIN_ADAPTERS.OPENLOGIN]: "OpenLogin", [MULTI_CHAIN_ADAPTERS.WALLET_CONNECT_V2]: "Wallet Connect v2", + [MULTI_CHAIN_ADAPTERS.SFA]: "SFA", [SOLANA_ADAPTERS.TORUS_SOLANA]: "Torus", [SOLANA_ADAPTERS.PHANTOM]: "Phantom", [SOLANA_ADAPTERS.SOLFLARE]: "Solflare", diff --git a/packages/no-modal/src/noModal.ts b/packages/no-modal/src/noModal.ts index 7e4b5e56a..11a6c77a1 100644 --- a/packages/no-modal/src/noModal.ts +++ b/packages/no-modal/src/noModal.ts @@ -299,14 +299,15 @@ export class Web3AuthNoModal extends SafeEventEmitter implements IWeb3Auth { this.connectedAdapterName = data.adapter; this.cacheWallet(data.adapter); log.debug("connected", this.status, this.connectedAdapterName); - Object.values(this.plugins).map(async (plugin) => { try { if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) { return; } - await plugin.initWithWeb3Auth(this); - await plugin.connect(); + const { openloginInstance } = this.walletAdapters[this.connectedAdapterName] as OpenloginAdapter; + const { options, sessionId, sessionNamespace } = openloginInstance || {}; + await plugin.initWithWeb3Auth(this, options.whiteLabel); + await plugin.connect({ sessionId, sessionNamespace }); } catch (error: unknown) { // swallow error if connector adapter doesn't supports this plugin. if ((error as Web3AuthError).code === 5211) { diff --git a/packages/plugins/solana-wallet-connector-plugin/src/errors.ts b/packages/plugins/solana-wallet-connector-plugin/src/errors.ts index d74d0f478..6ed561e4e 100644 --- a/packages/plugins/solana-wallet-connector-plugin/src/errors.ts +++ b/packages/plugins/solana-wallet-connector-plugin/src/errors.ts @@ -10,6 +10,7 @@ export class SolanaWalletPluginError extends Web3AuthError { 5215: "UserInfo is required.", 5216: "Plugin is already initialized", 5217: "Torus wallet instance is not set.", + 5222: "Invalid session inside wallet services. Please report this issue.", }; public constructor(code: number, message?: string) { @@ -63,4 +64,8 @@ export class SolanaWalletPluginError extends Web3AuthError { public static invalidParams(extraMessage = ""): IWeb3AuthError { return SolanaWalletPluginError.fromCode(5220, extraMessage); } + + public static invalidSession(extraMessage = ""): IWeb3AuthError { + return SolanaWalletPluginError.fromCode(5222, extraMessage); + } } diff --git a/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts b/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts index ac2d48503..15bf5725a 100644 --- a/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts +++ b/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts @@ -1,15 +1,17 @@ import type { JsonRpcError } from "@metamask/rpc-errors"; import { SafeEventEmitter } from "@toruslabs/openlogin-jrpc"; +import { type WhiteLabelData } from "@toruslabs/openlogin-utils"; import TorusEmbed, { NetworkInterface, PAYMENT_PROVIDER_TYPE, PaymentParams, TorusCtorArgs, TorusParams } from "@toruslabs/solana-embed"; import { ADAPTER_EVENTS, CustomChainConfig, IPlugin, - IWeb3Auth, + IWeb3AuthCore, PLUGIN_EVENTS, PLUGIN_NAMESPACES, PLUGIN_STATUS, PLUGIN_STATUS_TYPE, + PluginConnectParams, SafeEventEmitterProvider, SOLANA_PLUGINS, UserInfo, @@ -29,7 +31,7 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl public status: PLUGIN_STATUS_TYPE = PLUGIN_STATUS.DISCONNECTED; - readonly SUPPORTED_ADAPTERS = [WALLET_ADAPTERS.OPENLOGIN]; + readonly SUPPORTED_ADAPTERS = [WALLET_ADAPTERS.OPENLOGIN, WALLET_ADAPTERS.SFA]; readonly pluginNamespace = PLUGIN_NAMESPACES.SOLANA; @@ -37,7 +39,7 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl private provider: SafeEventEmitterProvider | null = null; - private web3auth: IWeb3Auth | null = null; + private web3auth: IWeb3AuthCore | null = null; private userInfo: UserInfo | null = null; @@ -48,24 +50,18 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl constructor(options: { torusWalletOpts?: TorusCtorArgs; walletInitOptions: Partial }) { super(); const { torusWalletOpts = {}, walletInitOptions } = options; - // const whiteLabel = walletInitOptions?.whiteLabel; - - // if (!whiteLabel) throw new Error("whiteLabel is required"); - // const { logoDark, logoLight } = whiteLabel; - // if (!logoDark || !logoLight) throw new Error("logoDark and logoLight are required in whiteLabel config"); - this.torusWalletInstance = new TorusEmbed(torusWalletOpts); - this.walletInitOptions = walletInitOptions; + this.walletInitOptions = walletInitOptions || {}; } get proxyProvider(): SafeEventEmitterProvider | null { return this.torusWalletInstance.isLoggedIn ? (this.torusWalletInstance.provider as unknown as SafeEventEmitterProvider) : null; } - async initWithWeb3Auth(web3auth: IWeb3Auth): Promise { + async initWithWeb3Auth(web3auth: IWeb3AuthCore, whiteLabel: WhiteLabelData): Promise { if (this.isInitialized) return; if (!web3auth) throw SolanaWalletPluginError.web3authRequired(); - if (web3auth.provider && web3auth.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) throw SolanaWalletPluginError.unsupportedAdapter(); + if (web3auth.provider && !this.SUPPORTED_ADAPTERS.includes(web3auth.connectedAdapterName)) throw SolanaWalletPluginError.unsupportedAdapter(); if (web3auth.coreOptions.chainConfig.chainNamespace !== this.pluginNamespace) throw SolanaWalletPluginError.unsupportedChainNamespace(); // Not connected yet to openlogin if (web3auth.provider) { @@ -73,6 +69,8 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl this.userInfo = (await web3auth.getUserInfo()) as UserInfo; } this.web3auth = web3auth; + const { logoDark, logoLight } = whiteLabel || {}; + if (!logoDark || !logoLight) throw new Error("logoDark and logoLight are required in whiteLabel config"); this.subscribeToWeb3AuthNoModalEvents(web3auth); const connectedChainConfig = web3auth.coreOptions.chainConfig as CustomChainConfig; @@ -84,6 +82,16 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl await this.torusWalletInstance.init({ ...(this.walletInitOptions || {}), + whiteLabel: { + ...whiteLabel, + logoDark: whiteLabel?.logoDark, + logoLight: whiteLabel?.logoLight, + ...(this.walletInitOptions.whiteLabel || {}), + theme: { + isDark: whiteLabel.mode === "dark", + colors: {}, + }, + }, network: { ...connectedChainConfig, blockExplorerUrl: connectedChainConfig.blockExplorerUrl, @@ -99,23 +107,8 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl this.status = PLUGIN_STATUS.READY; } - async initWithProvider(provider: SafeEventEmitterProvider, userInfo: UserInfo): Promise { - if (this.isInitialized) return; - - if (!userInfo) throw SolanaWalletPluginError.userInfoRequired(); - if (!provider) throw SolanaWalletPluginError.providerRequired(); - - this.provider = provider; - this.userInfo = userInfo; - await this.torusWalletInstance.init(this.walletInitOptions || {}); - this.isInitialized = true; - this.emit(PLUGIN_EVENTS.READY); - this.status = PLUGIN_STATUS.READY; - } - - async connect(): Promise { + async connect(_: PluginConnectParams): Promise { // if web3auth is being used and connected to unsupported adapter throw error - if (this.web3auth && this.web3auth.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) throw SolanaWalletPluginError.unsupportedAdapter(); if (!this.isInitialized) throw SolanaWalletPluginError.notInitialized(); this.emit(PLUGIN_EVENTS.CONNECTING); this.status = PLUGIN_STATUS.CONNECTING; @@ -195,12 +188,8 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl }); } - private subscribeToWeb3AuthNoModalEvents(web3Auth: IWeb3Auth) { + private subscribeToWeb3AuthNoModalEvents(web3Auth: IWeb3AuthCore) { web3Auth.on(ADAPTER_EVENTS.CONNECTED, async () => { - if (web3Auth.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) { - log.warn(`${web3Auth.connectedAdapterName} is not compatible with torus wallet connector plugin`); - return; - } this.provider = web3Auth.provider; this.userInfo = (await web3Auth.getUserInfo()) as Omit; if (!this.provider) throw SolanaWalletPluginError.web3AuthNotConnected(); @@ -247,17 +236,9 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl private async setSelectedAddress(address: string): Promise { if (!this.torusWalletInstance.isLoggedIn || !this.userInfo) throw SolanaWalletPluginError.web3AuthNotConnected(); - const [sessionConfig, torusWalletSessionConfig] = await Promise.all([this.sessionConfig(), this.torusWalletSessionConfig()]); + const [, torusWalletSessionConfig] = await Promise.all([this.sessionConfig(), this.torusWalletSessionConfig()]); if (address !== torusWalletSessionConfig.accounts?.[0]) { - await this.torusWalletInstance.loginWithPrivateKey({ - privateKey: sessionConfig.privateKey, - userInfo: { - ...this.userInfo, - email: this.userInfo?.email as string, - name: this.userInfo?.name as string, - profileImage: this.userInfo?.profileImage as string, - }, - }); + throw SolanaWalletPluginError.invalidSession(); } } diff --git a/packages/plugins/wallet-services-plugin/package.json b/packages/plugins/wallet-services-plugin/package.json index 2a66146f6..1e393352e 100644 --- a/packages/plugins/wallet-services-plugin/package.json +++ b/packages/plugins/wallet-services-plugin/package.json @@ -31,10 +31,10 @@ ], "devDependencies": { "@metamask/rpc-errors": "^6.2.1", - "@web3auth/openlogin-adapter": "^8.5.0" + "@toruslabs/openlogin-utils": "^8.1.2", + "@toruslabs/ethereum-controllers": "^5.6.1" }, "dependencies": { - "@toruslabs/ethereum-controllers": "^5.6.1", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.5.0", "@web3auth/no-modal": "^8.5.0", diff --git a/packages/plugins/wallet-services-plugin/src/errors.ts b/packages/plugins/wallet-services-plugin/src/errors.ts index 555b724bb..251573bc3 100644 --- a/packages/plugins/wallet-services-plugin/src/errors.ts +++ b/packages/plugins/wallet-services-plugin/src/errors.ts @@ -10,6 +10,8 @@ export class WalletServicesPluginError extends Web3AuthError { 5216: "Plugin is already initialized", 5218: "Unsupported chain namespace.", 5219: "Plugin network different than web3auth instance network.", + 5221: "Web3Auth is not initialized", + 5222: "Invalid session inside wallet services. Please report this issue.", }; public constructor(code: number, message?: string) { @@ -59,4 +61,12 @@ export class WalletServicesPluginError extends Web3AuthError { public static invalidParams(extraMessage = ""): IWeb3AuthError { return WalletServicesPluginError.fromCode(5220, extraMessage); } + + public static web3authNotInitialized(extraMessage = ""): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5221, extraMessage); + } + + public static invalidSession(extraMessage = ""): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5222, extraMessage); + } } diff --git a/packages/plugins/wallet-services-plugin/src/plugin.ts b/packages/plugins/wallet-services-plugin/src/plugin.ts index 0538da650..66f962935 100644 --- a/packages/plugins/wallet-services-plugin/src/plugin.ts +++ b/packages/plugins/wallet-services-plugin/src/plugin.ts @@ -1,20 +1,21 @@ import type { EthereumProviderConfig } from "@toruslabs/ethereum-controllers"; import { SafeEventEmitter } from "@toruslabs/openlogin-jrpc"; +import { type WhiteLabelData } from "@toruslabs/openlogin-utils"; import { ADAPTER_EVENTS, ADAPTER_STATUS, CustomChainConfig, EVM_PLUGINS, IPlugin, - IWeb3Auth, + IWeb3AuthCore, PLUGIN_EVENTS, PLUGIN_NAMESPACES, PLUGIN_STATUS, PLUGIN_STATUS_TYPE, + PluginConnectParams, SafeEventEmitterProvider, WALLET_ADAPTERS, } from "@web3auth/base"; -import type { OpenloginAdapter } from "@web3auth/openlogin-adapter"; import WsEmbed, { CtorArgs, WsEmbedParams } from "@web3auth/ws-embed"; import log from "loglevel"; @@ -25,7 +26,7 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { public status: PLUGIN_STATUS_TYPE = PLUGIN_STATUS.DISCONNECTED; - readonly SUPPORTED_ADAPTERS = [WALLET_ADAPTERS.OPENLOGIN]; + readonly SUPPORTED_ADAPTERS = [WALLET_ADAPTERS.OPENLOGIN, WALLET_ADAPTERS.SFA]; readonly pluginNamespace = PLUGIN_NAMESPACES.EIP155; @@ -33,7 +34,7 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { private provider: SafeEventEmitterProvider | null = null; - private web3auth: IWeb3Auth | null = null; + private web3auth: IWeb3AuthCore | null = null; private isInitialized = false; @@ -53,19 +54,22 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { return this.wsEmbedInstance.provider ? (this.wsEmbedInstance.provider as unknown as SafeEventEmitterProvider) : null; } - async initWithWeb3Auth(web3auth: IWeb3Auth): Promise { + async initWithWeb3Auth(web3auth: IWeb3AuthCore, whiteLabel?: WhiteLabelData): Promise { if (this.isInitialized) return; if (!web3auth) throw WalletServicesPluginError.web3authRequired(); - if (web3auth.provider && web3auth.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) throw WalletServicesPluginError.unsupportedAdapter(); + if (web3auth.provider && !this.SUPPORTED_ADAPTERS.includes(web3auth.connectedAdapterName)) throw WalletServicesPluginError.notInitialized(); if (web3auth.coreOptions.chainConfig.chainNamespace !== this.pluginNamespace) throw WalletServicesPluginError.unsupportedChainNamespace(); // Not connected yet to openlogin if (web3auth.provider) { this.provider = web3auth.provider; } this.web3auth = web3auth; - // get whitelabel from openlogin adapter - const { options } = (this.web3auth.walletAdapters[this.web3auth.connectedAdapterName] as OpenloginAdapter).openloginInstance || {}; - const { logoDark, logoLight } = options.whiteLabel || {}; + const mergedWhitelabelSettings = { + ...whiteLabel, + ...(this.walletInitOptions.whiteLabel || {}), + }; + + const { logoDark, logoLight } = mergedWhitelabelSettings || {}; if (!logoDark || !logoLight) throw new Error("logoDark and logoLight are required in whiteLabel config"); this.wsEmbedInstance.web3AuthClientId = this.web3auth.coreOptions.clientId; @@ -81,12 +85,8 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { await this.wsEmbedInstance.init({ ...this.walletInitOptions, chainConfig: connectedChainConfig as EthereumProviderConfig, - buildEnv: options?.buildEnv, enableLogging: this.web3auth.coreOptions?.enableLogging, - whiteLabel: { - ...options.whiteLabel, - ...(this.walletInitOptions.whiteLabel || {}), - }, + whiteLabel: mergedWhitelabelSettings, }); this.isInitialized = true; this.status = PLUGIN_STATUS.READY; @@ -97,25 +97,21 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { throw new Error("Method not implemented."); } - async connect(): Promise { + async connect({ sessionId, sessionNamespace }: PluginConnectParams): Promise { // if web3auth is being used and connected to unsupported adapter throw error - if (this.web3auth && this.web3auth.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) throw WalletServicesPluginError.unsupportedAdapter(); if (!this.isInitialized) throw WalletServicesPluginError.notInitialized(); this.emit(PLUGIN_EVENTS.CONNECTING); this.status = PLUGIN_STATUS.CONNECTING; - const { connectedAdapterName } = this.web3auth; + if (!this.provider) { + if (this.web3auth?.provider) { + this.provider = this.web3auth.provider; + } + } - // Not connected yet to openlogin - let sessionId: string | null = null; - let sessionNamespace: string = ""; - if (this.web3auth?.provider) { - const { openloginInstance } = this.web3auth.walletAdapters[connectedAdapterName] as OpenloginAdapter; - sessionId = openloginInstance.sessionId; - sessionNamespace = (this.web3auth.walletAdapters[connectedAdapterName] as OpenloginAdapter).openloginInstance.sessionNamespace; - } else if (this.web3auth) { + if (this.web3auth.status !== ADAPTER_STATUS.CONNECTED) { throw WalletServicesPluginError.web3AuthNotConnected(); - } else { + } else if (!this.web3auth.provider) { throw WalletServicesPluginError.providerRequired(); } @@ -157,7 +153,6 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { async disconnect(): Promise { // if web3auth is being used and connected to unsupported adapter throw error - if (this.web3auth?.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) throw WalletServicesPluginError.unsupportedAdapter(); if (this.wsEmbedInstance.isLoggedIn) { await this.wsEmbedInstance.logout(); this.emit(PLUGIN_EVENTS.DISCONNECTED); @@ -192,13 +187,9 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { }); } - private subscribeToWeb3AuthNoModalEvents(web3Auth: IWeb3Auth) { + private subscribeToWeb3AuthNoModalEvents(web3Auth: IWeb3AuthCore) { web3Auth.on(ADAPTER_EVENTS.CONNECTED, async () => { - if (web3Auth.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) { - log.warn(`${web3Auth.connectedAdapterName} is not compatible with wallet services connector plugin`); - return; - } - this.provider = web3Auth.walletAdapters[WALLET_ADAPTERS.OPENLOGIN].provider; + this.provider = web3Auth.provider; if (!this.provider) throw WalletServicesPluginError.web3AuthNotConnected(); this.subscribeToProviderEvents(this.provider); }); @@ -239,15 +230,10 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { } private async setSelectedAddress(address: string): Promise { - if (!this.web3auth.connected) throw WalletServicesPluginError.web3AuthNotConnected(); + if (this.web3auth.status !== ADAPTER_STATUS.CONNECTED) throw WalletServicesPluginError.web3AuthNotConnected(); const walletServicesSessionConfig = await this.walletServicesSessionConfig(); if (address !== walletServicesSessionConfig.accounts?.[0]) { - const { sessionId, sessionNamespace } = (this.web3auth.walletAdapters[this.web3auth.connectedAdapterName] as OpenloginAdapter) - .openloginInstance; - await this.wsEmbedInstance.loginWithSessionId({ - sessionId, - sessionNamespace, - }); + throw WalletServicesPluginError.invalidSession(); } }