From d3c256217424b23cdee5eb653595b889b3a57397 Mon Sep 17 00:00:00 2001 From: Archit Date: Mon, 5 Feb 2024 16:52:27 +0530 Subject: [PATCH 1/2] Remove signing challenges --- packages/base/src/adapter/utils.ts | 60 ------------------------------ packages/base/src/constants.ts | 1 - 2 files changed, 61 deletions(-) delete mode 100644 packages/base/src/constants.ts diff --git a/packages/base/src/adapter/utils.ts b/packages/base/src/adapter/utils.ts index c2981ccb5..af7317c7a 100644 --- a/packages/base/src/adapter/utils.ts +++ b/packages/base/src/adapter/utils.ts @@ -1,10 +1,5 @@ -import { post } from "@toruslabs/http-helpers"; -import { OPENLOGIN_NETWORK_TYPE } from "@toruslabs/openlogin-utils"; import { jwtDecode } from "jwt-decode"; -import { ChainNamespaceType } from "../chain/IChainInterface"; -import { authServer } from "../constants"; -import log from "../loglevel"; import { storageAvailable } from "../utils"; export const checkIfTokenIsExpired = (token: string) => { @@ -18,61 +13,6 @@ export const checkIfTokenIsExpired = (token: string) => { return false; }; -export const signChallenge = async (payload: Record, chainNamespace: ChainNamespaceType): Promise => { - const t = chainNamespace === "solana" ? "sip99" : "eip191"; - const header = { - t, - }; - - const network = chainNamespace === "solana" ? "solana" : "ethereum"; - const data = { - payload, - header, - network, - }; - const res = await post<{ success: boolean; challenge: string }>(`${authServer}/siww/get`, data); - if (!res.success) { - throw new Error("Failed to authenticate user, Please reach out to Web3Auth Support team"); - } - - return res.challenge; -}; - -export const verifySignedChallenge = async ( - chainNamespace: ChainNamespaceType, - signedMessage: string, - challenge: string, - issuer: string, - sessionTime: number, - clientId?: string, - web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE -): Promise => { - const t = chainNamespace === "solana" ? "sip99" : "eip191"; - const sigData = { - signature: { - s: signedMessage, - t, - }, - message: challenge, - issuer, - audience: typeof window.location !== "undefined" ? window.location.hostname : "com://reactnative", - timeout: sessionTime, - }; - - const idTokenRes = await post<{ success: boolean; token: string; error?: string }>(`${authServer}/siww/verify`, sigData, { - headers: { - client_id: clientId, - wallet_provider: issuer, - web3auth_network: web3AuthNetwork, - }, - }); - if (!idTokenRes.success) { - log.error("Failed to authenticate user, ,message verification failed", idTokenRes.error); - throw new Error("Failed to authenticate user, ,message verification failed"); - } - return idTokenRes.token; -}; - export const getSavedToken = (userAddress: string, issuer: string) => { if (storageAvailable("localStorage")) { return localStorage.getItem(`${userAddress.toLowerCase()}_${issuer}`); diff --git a/packages/base/src/constants.ts b/packages/base/src/constants.ts deleted file mode 100644 index 1e3f46790..000000000 --- a/packages/base/src/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const authServer = "https://authjs.web3auth.io"; From 1b95cac7a13cb1dfd871b1867b73ef3315a6834b Mon Sep 17 00:00:00 2001 From: Archit Date: Mon, 5 Feb 2024 19:51:19 +0530 Subject: [PATCH 2/2] fix build --- package-lock.json | 34 ++++++++++--------- .../adapters/base-evm-adapter/package.json | 1 + .../base-evm-adapter/src/baseEvmAdapter.ts | 3 +- .../adapters/base-solana-adapter/package.json | 1 + .../src/baseSolanaAdapter.ts | 3 +- packages/base/src/index.ts | 1 - packages/providers/base-provider/package.json | 2 +- .../providers/ethereum-provider/package.json | 2 +- .../providers/solana-provider/package.json | 2 +- packages/providers/xrpl-provider/package.json | 2 +- packages/ui/package.json | 4 +-- 11 files changed, 28 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index ef8ea7eee..a2f583cd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5382,9 +5382,9 @@ "dev": true }, "node_modules/@toruslabs/base-controllers": { - "version": "5.3.7", - "resolved": "https://registry.npmjs.org/@toruslabs/base-controllers/-/base-controllers-5.3.7.tgz", - "integrity": "sha512-6xHseiUn/tlO9U/qs5FacruYeWVzkFJL+KG5N9gGBGQcYEGfyNH2rOwolTQvX3WlQuauf8Xk9JQ58P2NRH26dQ==", + "version": "5.3.9", + "resolved": "https://registry.npmjs.org/@toruslabs/base-controllers/-/base-controllers-5.3.9.tgz", + "integrity": "sha512-4Gq7/UAslR+CnjkqILe2bfpQm0Rcl43M7SZqH6TOFQI+eD9dGydL8SDZwSB2510fDQXQY85YExHD7OMxvXYVUg==", "dependencies": { "@ethereumjs/util": "^9.0.1", "@metamask/rpc-errors": "^6.1.0", @@ -6382,9 +6382,9 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.2.52", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.52.tgz", - "integrity": "sha512-E/YjWh3tH+qsLKaUzgpZb5AY0ChVa+ZJzF7ogehVILrFpdQk6nC/WXOv0bfFEABbXbgNxLBGU7IIZByPKb6eBw==", + "version": "18.2.53", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.53.tgz", + "integrity": "sha512-52IHsMDT8qATp9B9zoOyobW8W3/0QhaJQTw1HwRj0UY2yBpCAQ7+S/CqHYQ8niAm3p4ji+rWUQ9UCib0GxQ60w==", "dev": true, "dependencies": { "@types/prop-types": "*", @@ -23787,11 +23787,11 @@ } }, "node_modules/react-i18next": { - "version": "14.0.1", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-14.0.1.tgz", - "integrity": "sha512-TMV8hFismBmpMdIehoFHin/okfvgjFhp723RYgIqB4XyhDobVMyukyM3Z8wtTRmajyFMZrBl/OaaXF2P6WjUAw==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-14.0.3.tgz", + "integrity": "sha512-Zav2EEnrQNmCawnzj0l7xitj7jipC7kBNG3o6Cl75NwGndvdp/wu3LSVwJpyAc3eSWMwRFYZ5uNi43CtFUDf/g==", "dependencies": { - "@babel/runtime": "^7.22.5", + "@babel/runtime": "^7.23.9", "html-parse-stringify": "^3.0.1" }, "peerDependencies": { @@ -30339,6 +30339,7 @@ "version": "8.0.0-alpha.8", "license": "ISC", "dependencies": { + "@toruslabs/base-controllers": "^5.3.9", "@web3auth/base": "^8.0.0-alpha.8" }, "engines": { @@ -30354,6 +30355,7 @@ "version": "8.0.0-alpha.8", "license": "ISC", "dependencies": { + "@toruslabs/base-controllers": "^5.3.9", "@web3auth/base": "^8.0.0-alpha.8", "bs58": "^5.0.0" }, @@ -30746,7 +30748,7 @@ "license": "ISC", "dependencies": { "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/openlogin-jrpc": "^6.2.9", "@web3auth/base": "^8.0.0-alpha.8", "json-rpc-random-id": "^1.0.1" @@ -30772,7 +30774,7 @@ "@ethereumjs/util": "^9.0.1", "@metamask/eth-sig-util": "^7.0.1", "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/http-helpers": "^6.0.0", "@toruslabs/openlogin-jrpc": "^6.2.9", "@walletconnect/utils": "^2.11.0", @@ -30802,7 +30804,7 @@ "license": "ISC", "dependencies": { "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/openlogin-ed25519": "^6.0.0", "@toruslabs/openlogin-jrpc": "^6.2.9", "@toruslabs/tweetnacl-js": "^1.0.4", @@ -30834,7 +30836,7 @@ "license": "ISC", "dependencies": { "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/openlogin-jrpc": "^6.2.9", "@web3auth/base": "^8.0.0-alpha.8", "@web3auth/base-provider": "^8.0.0-alpha.8", @@ -30866,7 +30868,7 @@ "i18next": "^23.8.2", "lodash.clonedeep": "^4.5.0", "lodash.merge": "^4.6.2", - "react-i18next": "^14.0.1", + "react-i18next": "^14.0.3", "react-qrcode-logo": "^2.9.0" }, "devDependencies": { @@ -30879,7 +30881,7 @@ "@toruslabs/isomorphic-style-loader": "^5.3.3", "@types/lodash.clonedeep": "^4.5.9", "@types/lodash.merge": "^4.6.9", - "@types/react": "^18.2.52", + "@types/react": "^18.2.53", "@types/react-dom": "^18.2.18", "autoprefixer": "^10.4.17", "css-loader": "^6.10.0", diff --git a/packages/adapters/base-evm-adapter/package.json b/packages/adapters/base-evm-adapter/package.json index d5dd9eef9..9d0d430db 100644 --- a/packages/adapters/base-evm-adapter/package.json +++ b/packages/adapters/base-evm-adapter/package.json @@ -19,6 +19,7 @@ "pre-commit": "lint-staged --cwd ." }, "dependencies": { + "@toruslabs/base-controllers": "^5.3.9", "@web3auth/base": "^8.0.0-alpha.8" }, "files": [ diff --git a/packages/adapters/base-evm-adapter/src/baseEvmAdapter.ts b/packages/adapters/base-evm-adapter/src/baseEvmAdapter.ts index 5bf17ccb2..22ea38a3c 100644 --- a/packages/adapters/base-evm-adapter/src/baseEvmAdapter.ts +++ b/packages/adapters/base-evm-adapter/src/baseEvmAdapter.ts @@ -1,3 +1,4 @@ +import { signChallenge, verifySignedChallenge } from "@toruslabs/base-controllers"; import { ADAPTER_EVENTS, ADAPTER_STATUS, @@ -9,9 +10,7 @@ import { getChainConfig, getSavedToken, saveToken, - signChallenge, UserAuthInfo, - verifySignedChallenge, WalletLoginError, } from "@web3auth/base"; diff --git a/packages/adapters/base-solana-adapter/package.json b/packages/adapters/base-solana-adapter/package.json index dae57603f..82a61fb8f 100644 --- a/packages/adapters/base-solana-adapter/package.json +++ b/packages/adapters/base-solana-adapter/package.json @@ -19,6 +19,7 @@ "pre-commit": "lint-staged --cwd ." }, "dependencies": { + "@toruslabs/base-controllers": "^5.3.9", "@web3auth/base": "^8.0.0-alpha.8", "bs58": "^5.0.0" }, diff --git a/packages/adapters/base-solana-adapter/src/baseSolanaAdapter.ts b/packages/adapters/base-solana-adapter/src/baseSolanaAdapter.ts index 36709ee20..d0b5df203 100644 --- a/packages/adapters/base-solana-adapter/src/baseSolanaAdapter.ts +++ b/packages/adapters/base-solana-adapter/src/baseSolanaAdapter.ts @@ -1,3 +1,4 @@ +import { signChallenge, verifySignedChallenge } from "@toruslabs/base-controllers"; import { ADAPTER_EVENTS, ADAPTER_STATUS, @@ -9,9 +10,7 @@ import { getChainConfig, getSavedToken, saveToken, - signChallenge, UserAuthInfo, - verifySignedChallenge, WalletLoginError, } from "@web3auth/base"; import bs58 from "bs58"; diff --git a/packages/base/src/index.ts b/packages/base/src/index.ts index 83546a86d..fe501b0da 100644 --- a/packages/base/src/index.ts +++ b/packages/base/src/index.ts @@ -1,7 +1,6 @@ export * from "./adapter"; export * from "./chain/config"; export * from "./chain/IChainInterface"; -export * from "./constants"; export * from "./core/IWeb3Auth"; export * from "./errors"; export { default as log } from "./loglevel"; diff --git a/packages/providers/base-provider/package.json b/packages/providers/base-provider/package.json index 01ecf98ee..845276974 100644 --- a/packages/providers/base-provider/package.json +++ b/packages/providers/base-provider/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/openlogin-jrpc": "^6.2.9", "@web3auth/base": "^8.0.0-alpha.8", "json-rpc-random-id": "^1.0.1" diff --git a/packages/providers/ethereum-provider/package.json b/packages/providers/ethereum-provider/package.json index 53eaf174a..0e1445bed 100644 --- a/packages/providers/ethereum-provider/package.json +++ b/packages/providers/ethereum-provider/package.json @@ -24,7 +24,7 @@ "@ethereumjs/util": "^9.0.1", "@metamask/eth-sig-util": "^7.0.1", "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/http-helpers": "^6.0.0", "@toruslabs/openlogin-jrpc": "^6.2.9", "@walletconnect/utils": "^2.11.0", diff --git a/packages/providers/solana-provider/package.json b/packages/providers/solana-provider/package.json index b39a01ec7..7da9c58ee 100644 --- a/packages/providers/solana-provider/package.json +++ b/packages/providers/solana-provider/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/openlogin-ed25519": "^6.0.0", "@toruslabs/openlogin-jrpc": "^6.2.9", "@toruslabs/tweetnacl-js": "^1.0.4", diff --git a/packages/providers/xrpl-provider/package.json b/packages/providers/xrpl-provider/package.json index 6cacf8254..62d7bb0e2 100644 --- a/packages/providers/xrpl-provider/package.json +++ b/packages/providers/xrpl-provider/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@metamask/rpc-errors": "^6.1.0", - "@toruslabs/base-controllers": "^5.3.7", + "@toruslabs/base-controllers": "^5.3.9", "@toruslabs/openlogin-jrpc": "^6.2.9", "@web3auth/base": "^8.0.0-alpha.8", "@web3auth/base-provider": "^8.0.0-alpha.8", diff --git a/packages/ui/package.json b/packages/ui/package.json index 05d3e032b..eb6e018cc 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -47,7 +47,7 @@ "@toruslabs/isomorphic-style-loader": "^5.3.3", "@types/lodash.clonedeep": "^4.5.9", "@types/lodash.merge": "^4.6.9", - "@types/react": "^18.2.52", + "@types/react": "^18.2.53", "@types/react-dom": "^18.2.18", "autoprefixer": "^10.4.17", "css-loader": "^6.10.0", @@ -74,7 +74,7 @@ "i18next": "^23.8.2", "lodash.clonedeep": "^4.5.0", "lodash.merge": "^4.6.2", - "react-i18next": "^14.0.1", + "react-i18next": "^14.0.3", "react-qrcode-logo": "^2.9.0" }, "lint-staged": {