diff --git a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx index 6157ac36..73d12ec2 100644 --- a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx +++ b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx @@ -13,7 +13,7 @@ import { makeEthereumSigner, } from "@web3auth/mpc-core-kit"; import { tssLib } from "@toruslabs/tss-dkls-lib"; -import { EthereumSigningProvider } from '@web3auth/ethereum-mpc-provider'; +import { EthereumSigningProvider } from "@web3auth/ethereum-mpc-provider"; import { CHAIN_NAMESPACES } from "@web3auth/base"; // IMP END - Quick Start @@ -47,7 +47,7 @@ const coreKitInstance = new Web3AuthMPCCoreKit({ storage: window.localStorage, manualSync: true, // This is the recommended approach tssLib: tssLib, - uxMode: 'popup', + uxMode: "popup", }); // Setup provider for EVM Chain @@ -78,7 +78,9 @@ function App() { useEffect(() => { const init = async () => { // IMP START - SDK Initialization - await coreKitInstance.init(); + if (coreKitInstance.status === COREKIT_STATUS.NOT_INITIALIZED) { + await coreKitInstance.init(); + } // IMP END - SDK Initialization setCoreKitStatus(coreKitInstance.status); @@ -89,17 +91,16 @@ function App() { const login = async () => { try { if (!coreKitInstance) { - throw new Error('initiated to login'); + throw new Error("initiated to login"); } // IMP START - Login const verifierConfig = { subVerifierDetails: { - typeOfLogin: 'google', - verifier: 'w3a-google-demo', - clientId: - '519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com', - } + typeOfLogin: "google", + verifier: "w3a-google-demo", + clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com", + }, } as SubVerifierDetailsParams; await coreKitInstance.loginWithOAuth(verifierConfig); @@ -117,11 +118,10 @@ function App() { // IMP END - Recover MFA Enabled Account setCoreKitStatus(coreKitInstance.status); - } catch (error: unknown) { uiConsole(error); } - } + }; // IMP START - Recover MFA Enabled Account const inputBackupFactorKey = async () => { @@ -144,8 +144,8 @@ function App() { }; // IMP END - Recover MFA Enabled Account - // IMP START - Export Social Account Factor - const getSocialMFAFactorKey = async (): Promise => { + // IMP START - Export Social Account Factor + const getSocialMFAFactorKey = async (): Promise => { try { // Create a temporary instance of the MPC Core Kit, used to create an encryption key for the Social Factor const tempCoreKitInstance = new Web3AuthMPCCoreKit({ @@ -157,20 +157,19 @@ function App() { await tempCoreKitInstance.init(); - // Login using Firebase Email Password - const auth = getAuth(app); - const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); - uiConsole(res); - const idToken = await res.user.getIdToken(true); - const userInfo = parseToken(idToken); - - // Use the Web3Auth SFA SDK to generate an account using the Social Factor - await tempCoreKitInstance.loginWithJWT({ - verifier: "w3a-firebase-demo", - verifierId: userInfo.sub, - idToken, - }); - + // Login using Firebase Email Password + const auth = getAuth(app); + const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); + uiConsole(res); + const idToken = await res.user.getIdToken(true); + const userInfo = parseToken(idToken); + + // Use the Web3Auth SFA SDK to generate an account using the Social Factor + await tempCoreKitInstance.loginWithJWT({ + verifier: "w3a-firebase-demo", + verifierId: userInfo.sub, + idToken, + }); // Get the private key using the Social Factor, which can be used as a factor key for the MPC Core Kit const factorKey = await tempCoreKitInstance.state.postBoxKey; @@ -183,7 +182,7 @@ function App() { return ""; } }; - // IMP END - Export Social Account Factor + // IMP END - Export Social Account Factor // IMP START - Enable Multi Factor Authentication const enableMFA = async () => { @@ -202,7 +201,9 @@ function App() { await coreKitInstance.commitChanges(); } - uiConsole("MFA enabled, device factor stored in local store, deleted hashed cloud key, your backup factor key is associated with the firebase email password account in the app"); + uiConsole( + "MFA enabled, device factor stored in local store, deleted hashed cloud key, your backup factor key is associated with the firebase email password account in the app" + ); } catch (e) { uiConsole(e); } @@ -431,7 +432,6 @@ function App() { - ); diff --git a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package-lock.json b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package-lock.json index 018a4e51..576a64cc 100644 --- a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package-lock.json +++ b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package-lock.json @@ -12,9 +12,8 @@ "@types/node": "^18.11.18", "@types/react": "^18.0.26", "@types/react-dom": "^18.0.10", - "@web3auth/ethereum-mpc-provider": "^9.3.0", - "@web3auth/mpc-core-kit": "3.2.4", - "@web3auth/single-factor-auth": "^9.2.0", + "@web3auth/ethereum-mpc-provider": "^9.4.4", + "@web3auth/mpc-core-kit": "3.2.6", "bn.js": "^5.2.1", "firebase": "^10.11.1", "react": "^18.2.0", @@ -3642,9 +3641,9 @@ } }, "node_modules/@nx/nx-linux-x64-gnu": { - "version": "19.8.2", - "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-gnu/-/nx-linux-x64-gnu-19.8.2.tgz", - "integrity": "sha512-3h4dmIi5Muym18dsiiXQBygPlSAHZNe3PaYo8mLsUsvuAt2ye0XUDcAlHWXOt/FeuVDG1NEGI05vZJvbIIGikQ==", + "version": "20.1.3", + "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-gnu/-/nx-linux-x64-gnu-20.1.3.tgz", + "integrity": "sha512-RKNm7RnTgCSl2HstDb/qMKO9r8o81EUe+UZB5fgjNR89PB757iHUX30kM0xbkiRZui1vIkMAvWcNsidxBnGGfg==", "cpu": [ "x64" ], @@ -3846,9 +3845,9 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==" }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.22.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.5.tgz", - "integrity": "sha512-N0jPPhHjGShcB9/XXZQWuWBKZQnC1F36Ce3sDqWpujsGjDz/CQtOL9LgTrJ+rJC8MJeesMWrMWVLKKNR/tMOCA==", + "version": "4.27.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.27.4.tgz", + "integrity": "sha512-Ni8mMtfo+o/G7DVtweXXV/Ol2TFf63KYjTtoZ5f078AUgJTmaIJnj4JFU7TK/9SVWTaSJGxPi5zMDgK4w+Ez7Q==", "cpu": [ "x64" ], @@ -4290,15 +4289,15 @@ } }, "node_modules/@toruslabs/base-controllers": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/@toruslabs/base-controllers/-/base-controllers-6.2.3.tgz", - "integrity": "sha512-j0oQ2itDBE0rSzkyMJR099ACZVdwDOQ6lTbTLTwp6aW9ogLRUUHE8SV/vDFsHV/A5DjOax9KlLB4e42hSkvuQA==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/@toruslabs/base-controllers/-/base-controllers-6.3.1.tgz", + "integrity": "sha512-7kqaoXL32xJnrGEb8Rd5V/WLjTovzKjRMg/Tw3NFYz5lxVLVf+ydK83hgAWp7fYRRjnUyZZ5aHyIbagTkj1NVQ==", "license": "ISC", "dependencies": { "@ethereumjs/util": "^9.1.0", "@toruslabs/broadcast-channel": "^11.0.0", "@toruslabs/http-helpers": "^7.0.0", - "@web3auth/auth": "^9.3.3", + "@web3auth/auth": "^9.5.2", "async-mutex": "^0.5.0", "bignumber.js": "^9.1.2", "bowser": "^2.11.0", @@ -4358,9 +4357,9 @@ } }, "node_modules/@toruslabs/constants": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/constants/-/constants-14.0.0.tgz", - "integrity": "sha512-c0lrqxxiR0FL+XdtbX+77PWTeB8izFUrnPwkF2pjjfXlMJLukAWPLhALpmZmqlGmJApT8kJbMN7be2LurAGa1g==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@toruslabs/constants/-/constants-14.1.1.tgz", + "integrity": "sha512-+/ur6lXjMto4FdJR5Y6HqFiEX/8hea9usgwt99neV3IT46auC5NyVdiG6qmohuy67ThLt7IMCIyuJY78eC875g==", "license": "MIT", "engines": { "node": ">=18.x", @@ -4825,11 +4824,12 @@ } }, "node_modules/@toruslabs/secure-pub-sub": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/secure-pub-sub/-/secure-pub-sub-1.0.0.tgz", - "integrity": "sha512-Xv8SExIJ4/DBw5QHcSN+EGPMddZ2du4NcI9jztLde1K/0Hfnurqw6CcAniU6zpKVRVCRwjiauYCNYIRPBi2M4g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@toruslabs/secure-pub-sub/-/secure-pub-sub-1.1.0.tgz", + "integrity": "sha512-OFN0Zsa37+c9aStHd4wzau+IYPY+gve9fBPDuPSIuS06cz/bov39DvCP0LaTQUKxK4eQMZENcPu6PeyBvQYQQA==", "license": "MIT", "dependencies": { + "@toruslabs/constants": "^14.1.1", "@toruslabs/eccrypto": "^5.0.0", "@toruslabs/http-helpers": "^7.0.0", "@toruslabs/metadata-helpers": "^6.0.0", @@ -4845,11 +4845,12 @@ } }, "node_modules/@toruslabs/session-manager": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@toruslabs/session-manager/-/session-manager-3.1.0.tgz", - "integrity": "sha512-VTaYjTTGTqpUm14YWRsSmY0Tt5z7evC0aOdVW7Ahw/jzyb1witNL4Va2+7XzunziEkLJS3luH+LkziHx67jyQg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@toruslabs/session-manager/-/session-manager-3.2.0.tgz", + "integrity": "sha512-t+EGFZhn8pxZ5Gjhxr99qNmK20zZD/RYEMRROBuwsETyy/QU17H6dKhqIb306GjmwUPkz2VKKTtJcOg9Ifijuw==", "license": "MIT", "dependencies": { + "@toruslabs/constants": "^14.1.1", "@toruslabs/eccrypto": "^5.0.4", "@toruslabs/http-helpers": "^7.0.0", "@toruslabs/metadata-helpers": "^6.0.0" @@ -4859,21 +4860,21 @@ "npm": ">=9.x" }, "optionalDependencies": { - "@rollup/rollup-linux-x64-gnu": "^4.22.4" + "@rollup/rollup-linux-x64-gnu": "^4.24.4" } }, "node_modules/@toruslabs/starkware-crypto": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/starkware-crypto/-/starkware-crypto-4.0.0.tgz", - "integrity": "sha512-oEvcwEulCkLbOfRq3Rz3wS1DgSYV5oCh4N4YNWYDQhz1WoQe3S87hJlVUPvRQHHqhp9vBM0qDUVi0Ez7ibYhMA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@toruslabs/starkware-crypto/-/starkware-crypto-4.0.1.tgz", + "integrity": "sha512-AhnXUscFN2+oLeQuOEbi8vvrQnxUKnE0USWpg7eFHmqUBV8kg6+PAFiWsvJ01+GMQPTMKhKZHyMysxW5AFHc6Q==", "license": "MIT", "dependencies": { "assert": "^2.1.0", "bip39": "^3.1.0", "bn.js": "^5.2.1", - "elliptic": "~6.5.5", + "elliptic": "^6.6.1", "enc-utils": "^3.0.0", - "ethereum-cryptography": "^2.2.0", + "ethereum-cryptography": "^2.2.1", "hash.js": "^1.1.7" }, "engines": { @@ -5575,18 +5576,18 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" }, "node_modules/@web3auth/auth": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/@web3auth/auth/-/auth-9.4.1.tgz", - "integrity": "sha512-V5JNBc7VeHDmP+9VN4obAIav/NbkyZXEVJ3rD9C4SdbO/ZF3Hc+G8SdVPymJlR2JrBCsuPJiFsUatBl1hx+FSg==", + "version": "9.5.3", + "resolved": "https://registry.npmjs.org/@web3auth/auth/-/auth-9.5.3.tgz", + "integrity": "sha512-774DFBzuq/mO9y5Zf0ICdK9pZ/YgYgnRVo3CYiayuknA4/wTxosK+xvhlcP6fGRKVgoaYa6bP+gBGmqoFCGUzQ==", "license": "MIT", "dependencies": { "@ethereumjs/util": "^9.1.0", - "@toruslabs/constants": "^14.0.0", + "@toruslabs/constants": "^14.1.1", "@toruslabs/ffjavascript": "^4.0.0", "@toruslabs/metadata-helpers": "^6.0.0", - "@toruslabs/secure-pub-sub": "^1.0.0", - "@toruslabs/session-manager": "^3.0.0", - "@toruslabs/starkware-crypto": "^4.0.0", + "@toruslabs/secure-pub-sub": "^1.1.0", + "@toruslabs/session-manager": "^3.2.0", + "@toruslabs/starkware-crypto": "^4.0.1", "@toruslabs/tweetnacl-js": "^1.0.4", "base64url": "^3.0.1", "bip39": "^3.1.0", @@ -5598,9 +5599,9 @@ "events": "^3.3.0", "fast-safe-stringify": "^2.1.1", "json-stable-stringify": "^1.1.1", - "loglevel": "^1.9.1", + "loglevel": "^1.9.2", "once": "^1.4.0", - "pump": "^3.0.0", + "pump": "^3.0.2", "readable-stream": "^4.5.2", "ts-custom-error": "^3.3.1", "typed-emitter": "^2.1.0" @@ -5610,8 +5611,8 @@ "npm": ">=9.x" }, "optionalDependencies": { - "@nx/nx-linux-x64-gnu": "^19.6.3", - "@rollup/rollup-linux-x64-gnu": "^4.21.1" + "@nx/nx-linux-x64-gnu": "^20.1.2", + "@rollup/rollup-linux-x64-gnu": "^4.27.3" }, "peerDependencies": { "@babel/runtime": "7.x" @@ -5634,15 +5635,15 @@ } }, "node_modules/@web3auth/base": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@web3auth/base/-/base-9.3.0.tgz", - "integrity": "sha512-S1X3i83T7HWr+pF+qBG6nAh49bhE/91LzQxQqSTMQ3f0NGdaMWtuQK3QewyO+G71+9+yrhIS0vggnXyAgY9NaA==", + "version": "9.4.4", + "resolved": "https://registry.npmjs.org/@web3auth/base/-/base-9.4.4.tgz", + "integrity": "sha512-tL5TxPzuJyIyoQBAKm7k1lWsdp2/i+FWShQiQJKf131FgE50akGzL/a/eCXf04qrggR5BEzEVDUz3DNwfprojQ==", "license": "ISC", "dependencies": { - "@toruslabs/base-controllers": "^6.2.2", - "@toruslabs/constants": "^14.0.0", + "@toruslabs/base-controllers": "^6.3.1", + "@toruslabs/constants": "^14.1.1", "@toruslabs/http-helpers": "^7.0.0", - "@web3auth/auth": "^9.4.1", + "@web3auth/auth": "^9.5.3", "jwt-decode": "^4.0.0", "loglevel": "^1.9.2", "ts-custom-error": "^3.3.1" @@ -5656,14 +5657,14 @@ } }, "node_modules/@web3auth/base-provider": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@web3auth/base-provider/-/base-provider-9.3.0.tgz", - "integrity": "sha512-WiBpeVvyzmrjLQ8XNZMTWdtukDivuEvX8nOwT5FjyWBow5f06GViDRIRhB1D/M8n3xtsID8O/7qb8Gr6lw48zw==", + "version": "9.4.4", + "resolved": "https://registry.npmjs.org/@web3auth/base-provider/-/base-provider-9.4.4.tgz", + "integrity": "sha512-eG+dNEfZOFWYbUBBYu7G5xmxtxS8wLqD6VE1sA4AqKXgTFKmDvijjeeWH/q7fUX5KA7bPMqMV5U22FPaeAMMwQ==", "license": "ISC", "dependencies": { - "@toruslabs/base-controllers": "^6.2.2", - "@web3auth/auth": "^9.4.1", - "@web3auth/base": "^9.3.0", + "@toruslabs/base-controllers": "^6.3.1", + "@web3auth/auth": "^9.5.3", + "@web3auth/base": "^9.4.4", "json-rpc-random-id": "^1.0.1" }, "engines": { @@ -5675,17 +5676,17 @@ } }, "node_modules/@web3auth/ethereum-mpc-provider": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@web3auth/ethereum-mpc-provider/-/ethereum-mpc-provider-9.3.0.tgz", - "integrity": "sha512-QshYFjPcXUzIkVMSWKy2LRhMDSTvjV4AED4cnYIm3QibXVYvvUfwRO4eUixZ5uSqn8/0EPhLsiBCpaNw3sAghA==", + "version": "9.4.4", + "resolved": "https://registry.npmjs.org/@web3auth/ethereum-mpc-provider/-/ethereum-mpc-provider-9.4.4.tgz", + "integrity": "sha512-fImmpuK73mIS0pP8DFQ/ZwPyBNjD5xEjWMmy/WCIMibdwqPDkzAObxBqiQs2p4qaAxlGn4/E0fIoRY4fwpebfA==", "license": "ISC", "dependencies": { "@ethereumjs/util": "^9.1.0", - "@toruslabs/base-controllers": "^6.2.2", - "@web3auth/auth": "^9.4.1", - "@web3auth/base": "^9.3.0", - "@web3auth/base-provider": "^9.3.0", - "@web3auth/ethereum-provider": "^9.3.0", + "@toruslabs/base-controllers": "^6.3.1", + "@web3auth/auth": "^9.5.3", + "@web3auth/base": "^9.4.4", + "@web3auth/base-provider": "^9.4.4", + "@web3auth/ethereum-provider": "^9.4.4", "ethers": "^6.13.4" }, "engines": { @@ -5697,18 +5698,18 @@ } }, "node_modules/@web3auth/ethereum-provider": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@web3auth/ethereum-provider/-/ethereum-provider-9.3.0.tgz", - "integrity": "sha512-Qe9PAupSJqJEgkSruyusMB0Pu2mVw3JiieaRF4ixTrBnX1V2+wLdYLmQSYl+KBJ3m7ZsQO+omzFaDdZLyFPkew==", + "version": "9.4.4", + "resolved": "https://registry.npmjs.org/@web3auth/ethereum-provider/-/ethereum-provider-9.4.4.tgz", + "integrity": "sha512-+vQ5I9cC63DI0/UGz3VgqIV0VlqaZG1Kp71Ir2hghSdFr33mxYq90wD2h8vKZ09d/N+LoK69YiSeNqqFEemsuw==", "license": "ISC", "dependencies": { "@ethereumjs/util": "^9.1.0", - "@toruslabs/base-controllers": "^6.2.2", + "@toruslabs/base-controllers": "^6.3.1", "@toruslabs/eccrypto": "^5.0.4", "@toruslabs/http-helpers": "^7.0.0", - "@web3auth/auth": "^9.4.1", - "@web3auth/base": "^9.3.0", - "@web3auth/base-provider": "^9.3.0", + "@web3auth/auth": "^9.5.3", + "@web3auth/base": "^9.4.4", + "@web3auth/base-provider": "^9.4.4", "assert": "^2.1.0", "bignumber.js": "^9.1.2", "bn.js": "^5.2.1", @@ -5724,9 +5725,9 @@ } }, "node_modules/@web3auth/mpc-core-kit": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@web3auth/mpc-core-kit/-/mpc-core-kit-3.2.4.tgz", - "integrity": "sha512-KnumSerC0Otmu4a8BzQLli5I/f8ChnYap0Mwy8z/jxC68AilS9g5VIwz/RFm+SEbMZp/bk4JffaPPDndWld3Ug==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/@web3auth/mpc-core-kit/-/mpc-core-kit-3.2.6.tgz", + "integrity": "sha512-PI5Q7alORU5cRYeiQD5eqadvj6Cg/MCCVapUmPAgtksi+GRP3mzrZY9gf3YT9r+nSCyrG4Lh9vPYeJWRJEh+kw==", "license": "ISC", "dependencies": { "@tkey/common-types": "^15.1.0", @@ -5768,52 +5769,6 @@ } } }, - "node_modules/@web3auth/single-factor-auth": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/@web3auth/single-factor-auth/-/single-factor-auth-9.2.0.tgz", - "integrity": "sha512-slJAR0w9gOnAvFaT/gqoKxYsOCuEgVRiXN0GkaGgE/m/jYwczn92QzmR9qfn4S0I9Lt+jGPj2+rURMK0nkDaMg==", - "license": "ISC", - "dependencies": { - "@toruslabs/base-controllers": "^6.1.2", - "@toruslabs/constants": "^14.0.0", - "@toruslabs/fetch-node-details": "^14.0.1", - "@toruslabs/session-manager": "^3.0.0", - "@toruslabs/torus.js": "^14.0.2", - "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.0", - "bs58": "^5.0.0" - }, - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "^7.x" - } - }, - "node_modules/@web3auth/single-factor-auth/node_modules/@toruslabs/torus.js": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/@toruslabs/torus.js/-/torus.js-14.0.2.tgz", - "integrity": "sha512-+I3ftH6V/65SyEbltSJHMFVfumHaDphyr5r0tK1+ZZzNzsIJhiQxzIjODyKxlCmxANtl2Z0IVV4NQbZ7j5agjg==", - "license": "MIT", - "dependencies": { - "@toruslabs/constants": "^14.0.0", - "@toruslabs/eccrypto": "^5.0.4", - "@toruslabs/http-helpers": "^7.0.0", - "bn.js": "^5.2.1", - "elliptic": "^6.5.5", - "ethereum-cryptography": "^2.2.1", - "json-stable-stringify": "^1.1.1", - "loglevel": "^1.9.1" - }, - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "7.x" - } - }, "node_modules/@webassemblyjs/ast": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", @@ -6747,12 +6702,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, - "node_modules/base-x": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz", - "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==", - "license": "MIT" - }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -7008,15 +6957,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/bs58": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", - "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", - "license": "MIT", - "dependencies": { - "base-x": "^4.0.0" - } - }, "node_modules/bser": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", @@ -8575,9 +8515,9 @@ "integrity": "sha512-0JnipX0scPUlwsptQVCZggoCpREv+IrVD3h0ZG+sldmK9L27tSV3QjV8+QdaA4qQTzDf3PluNS45YYJky1oASw==" }, "node_modules/elliptic": { - "version": "6.5.7", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", - "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", + "version": "6.6.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.1.tgz", + "integrity": "sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==", "license": "MIT", "dependencies": { "bn.js": "^4.11.9", diff --git a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package.json b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package.json index a720f91e..24aff2b2 100644 --- a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package.json +++ b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/package.json @@ -8,8 +8,8 @@ "@types/react": "^18.0.26", "@types/react-dom": "^18.0.10", "@toruslabs/tss-dkls-lib": "^4.1.0", - "@web3auth/ethereum-mpc-provider": "^9.3.0", - "@web3auth/mpc-core-kit": "3.2.4", + "@web3auth/ethereum-mpc-provider": "^9.4.4", + "@web3auth/mpc-core-kit": "3.2.6", "bn.js": "^5.2.1", "firebase": "^10.11.1", "react": "^18.2.0", @@ -62,4 +62,4 @@ "eject": "react-scripts eject", "lint": "react-scripts lint" } -} +} \ No newline at end of file diff --git a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx index 1fe4b094..d68a02ec 100644 --- a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx +++ b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx @@ -12,7 +12,7 @@ import { mnemonicToKey, makeEthereumSigner, } from "@web3auth/mpc-core-kit"; -import { EthereumSigningProvider } from '@web3auth/ethereum-mpc-provider'; +import { EthereumSigningProvider } from "@web3auth/ethereum-mpc-provider"; import { CHAIN_NAMESPACES } from "@web3auth/base"; // Optional, only for social second factor recovery @@ -46,7 +46,7 @@ const coreKitInstance = new Web3AuthMPCCoreKit({ web3AuthClientId, web3AuthNetwork: WEB3AUTH_NETWORK.MAINNET, manualSync: true, // This is the recommended approach - uxMode: 'redirect', + uxMode: "redirect", storage: window.localStorage, tssLib, }); @@ -78,9 +78,9 @@ function App() { useEffect(() => { const init = async () => { - // IMP START - SDK Initialization - await coreKitInstance.init(); - // IMP END - SDK Initialization + if (coreKitInstance.status === COREKIT_STATUS.NOT_INITIALIZED) { + await coreKitInstance.init(); + } setCoreKitStatus(coreKitInstance.status); }; @@ -96,11 +96,10 @@ function App() { // IMP START - Login const verifierConfig = { subVerifierDetails: { - typeOfLogin: 'google', - verifier: 'w3a-google-demo', - clientId: - '519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com', - } + typeOfLogin: "google", + verifier: "w3a-google-demo", + clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com", + }, } as SubVerifierDetailsParams; await coreKitInstance.loginWithOAuth(verifierConfig); @@ -156,20 +155,19 @@ function App() { await tempCoreKitInstance.init(); - // Login using Firebase Email Password - const auth = getAuth(app); - const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); - uiConsole(res); - const idToken = await res.user.getIdToken(true); - const userInfo = parseToken(idToken); - - // Use the Web3Auth SFA SDK to generate an account using the Social Factor - await tempCoreKitInstance.loginWithJWT({ - verifier: "w3a-firebase-demo", - verifierId: userInfo.sub, - idToken, - }); - + // Login using Firebase Email Password + const auth = getAuth(app); + const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); + uiConsole(res); + const idToken = await res.user.getIdToken(true); + const userInfo = parseToken(idToken); + + // Use the Web3Auth SFA SDK to generate an account using the Social Factor + await tempCoreKitInstance.loginWithJWT({ + verifier: "w3a-firebase-demo", + verifierId: userInfo.sub, + idToken, + }); // Get the private key using the Social Factor, which can be used as a factor key for the MPC Core Kit const factorKey = await tempCoreKitInstance.state.postBoxKey; @@ -201,7 +199,9 @@ function App() { await coreKitInstance.commitChanges(); } - uiConsole("MFA enabled, device factor stored in local store, deleted hashed cloud key, your backup factor key is associated with the firebase email password account in the app"); + uiConsole( + "MFA enabled, device factor stored in local store, deleted hashed cloud key, your backup factor key is associated with the firebase email password account in the app" + ); } catch (e) { uiConsole(e); } @@ -430,7 +430,6 @@ function App() { - ); diff --git a/mpc-core-kit-web/mpc-core-kit-aggregate-verifier-example/src/App.tsx b/mpc-core-kit-web/mpc-core-kit-aggregate-verifier-example/src/App.tsx index 41a7daa9..5d000fdc 100644 --- a/mpc-core-kit-web/mpc-core-kit-aggregate-verifier-example/src/App.tsx +++ b/mpc-core-kit-web/mpc-core-kit-aggregate-verifier-example/src/App.tsx @@ -11,7 +11,7 @@ import { mnemonicToKey, makeEthereumSigner, } from "@web3auth/mpc-core-kit"; -import { EthereumSigningProvider } from '@web3auth/ethereum-mpc-provider'; +import { EthereumSigningProvider } from "@web3auth/ethereum-mpc-provider"; import { CHAIN_NAMESPACES, IProvider } from "@web3auth/base"; // IMP END - Quick Start import { BN } from "bn.js"; @@ -45,7 +45,7 @@ const coreKitInstance = new Web3AuthMPCCoreKit({ web3AuthNetwork: WEB3AUTH_NETWORK.MAINNET, storage: window.localStorage, manualSync: true, // This is the recommended approach - tssLib: tssLib + tssLib: tssLib, }); // Setup evmProvider for EVM Chain @@ -61,7 +61,9 @@ function App() { useEffect(() => { const init = async () => { // IMP START - SDK Initialization - await coreKitInstance.init(); + if (coreKitInstance.status === COREKIT_STATUS.NOT_INITIALIZED) { + await coreKitInstance.init(); + } // IMP END - SDK Initialization setCoreKitStatus(coreKitInstance.status); @@ -72,7 +74,7 @@ function App() { const loginWithGoogle = async () => { try { if (!coreKitInstance) { - throw new Error('initiated to login'); + throw new Error("initiated to login"); } // IMP START - Login @@ -85,7 +87,7 @@ function App() { clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com", jwtParams: { verifierIdField: "email", - } + }, }, ], } as AggregateVerifierLoginParams; @@ -105,16 +107,15 @@ function App() { // IMP END - Recover MFA Enabled Account setCoreKitStatus(coreKitInstance.status); - } catch (error: unknown) { uiConsole(error); } - } + }; const loginWithAuth0GitHub = async () => { try { if (!coreKitInstance) { - throw new Error('initiated to login'); + throw new Error("initiated to login"); } // IMP START - Login @@ -129,7 +130,7 @@ function App() { connection: "github", domain: "https://web3auth.au.auth0.com", verifierIdField: "email", - } + }, }, ], } as AggregateVerifierLoginParams; @@ -149,16 +150,15 @@ function App() { // IMP END - Recover MFA Enabled Account setCoreKitStatus(coreKitInstance.status); - } catch (error: unknown) { uiConsole(error); } - } + }; const loginWithAuth0EmailPasswordless = async () => { try { if (!coreKitInstance) { - throw new Error('initiated to login'); + throw new Error("initiated to login"); } // IMP START - Login @@ -173,7 +173,7 @@ function App() { // connection: "passwordless", domain: "https://web3auth.au.auth0.com", verifierIdField: "email", - } + }, }, ], } as AggregateVerifierLoginParams; @@ -193,11 +193,10 @@ function App() { // IMP END - Recover MFA Enabled Account setCoreKitStatus(coreKitInstance.status); - } catch (error: unknown) { uiConsole(error); } - } + }; // IMP START - Recover MFA Enabled Account const inputBackupFactorKey = async () => { @@ -239,7 +238,9 @@ function App() { await coreKitInstance.commitChanges(); } - uiConsole("MFA enabled, device factor stored in local store, deleted hashed cloud key, your backup factor key is associated with the firebase email password account in the app"); + uiConsole( + "MFA enabled, device factor stored in local store, deleted hashed cloud key, your backup factor key is associated with the firebase email password account in the app" + ); } catch (e) { uiConsole(e); } @@ -514,7 +515,6 @@ function App() { - ); @@ -546,4 +546,4 @@ function App() { ); } -export default App; \ No newline at end of file +export default App; diff --git a/mpc-core-kit-web/quick-starts/mpc-core-kit-angular-quick-start/src/app/app.component.ts b/mpc-core-kit-web/quick-starts/mpc-core-kit-angular-quick-start/src/app/app.component.ts index 1bf2a9a7..c9453755 100644 --- a/mpc-core-kit-web/quick-starts/mpc-core-kit-angular-quick-start/src/app/app.component.ts +++ b/mpc-core-kit-web/quick-starts/mpc-core-kit-angular-quick-start/src/app/app.component.ts @@ -1,4 +1,5 @@ import { Component } from "@angular/core"; +import { Point, secp256k1 } from "@tkey/common-types"; import { tssLib } from "@toruslabs/tss-dkls-lib"; // IMP START - Quick Start import { ADAPTER_EVENTS, CHAIN_NAMESPACES } from "@web3auth/base"; @@ -21,7 +22,6 @@ import { BN } from "bn.js"; // IMP START - Auth Provider Login // Firebase libraries for custom authentication import { initializeApp } from "firebase/app"; -import { Point, secp256k1 } from "@tkey/common-types"; import { getAuth, GoogleAuthProvider, signInWithEmailAndPassword, signInWithPopup, UserCredential } from "firebase/auth"; // IMP END - Auth Provider Login @@ -110,7 +110,9 @@ export class AppComponent { const init = async () => { try { // IMP START - SDK Initialization - await coreKitInstance.init(); + if (coreKitInstance.status === COREKIT_STATUS.NOT_INITIALIZED) { + await coreKitInstance.init(); + } // IMP END - SDK Initialization this.coreKitStatus = coreKitInstance.status; @@ -197,7 +199,7 @@ export class AppComponent { // IMP END - Recover MFA Enabled Account // IMP START - Export Social Account Factor - getSocialMFAFactorKey = async (): Promise => { + getSocialMFAFactorKey = async (): Promise => { try { // Create a temporary instance of the MPC Core Kit, used to create an encryption key for the Social Factor const tempCoreKitInstance = new Web3AuthMPCCoreKit({ @@ -209,20 +211,19 @@ export class AppComponent { await tempCoreKitInstance.init(); - // Login using Firebase Email Password - const auth = getAuth(this.app); - const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); - this.uiConsole(res); - const idToken = await res.user.getIdToken(true); - const userInfo = parseToken(idToken); - - // Use the Web3Auth SFA SDK to generate an account using the Social Factor - await tempCoreKitInstance.loginWithJWT({ - verifier, - verifierId: userInfo.sub, - idToken, - }); - + // Login using Firebase Email Password + const auth = getAuth(this.app); + const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); + this.uiConsole(res); + const idToken = await res.user.getIdToken(true); + const userInfo = parseToken(idToken); + + // Use the Web3Auth SFA SDK to generate an account using the Social Factor + await tempCoreKitInstance.loginWithJWT({ + verifier, + verifierId: userInfo.sub, + idToken, + }); // Get the private key using the Social Factor, which can be used as a factor key for the MPC Core Kit const factorKey = await tempCoreKitInstance.state.postBoxKey; @@ -245,7 +246,7 @@ export class AppComponent { try { const factorKey = new BN(await this.getSocialMFAFactorKey(), "hex"); this.uiConsole("Using the Social Factor Key to Enable MFA, please wait..."); - await coreKitInstance.enableMFA({factorKey, shareDescription: FactorKeyTypeShareDescription.SocialShare }); + await coreKitInstance.enableMFA({ factorKey, shareDescription: FactorKeyTypeShareDescription.SocialShare }); if (coreKitInstance.status === COREKIT_STATUS.LOGGED_IN) { await coreKitInstance.commitChanges(); diff --git a/mpc-core-kit-web/quick-starts/mpc-core-kit-nextjs-quick-start/app/page.tsx b/mpc-core-kit-web/quick-starts/mpc-core-kit-nextjs-quick-start/app/page.tsx index e3a98fd2..22210f40 100644 --- a/mpc-core-kit-web/quick-starts/mpc-core-kit-nextjs-quick-start/app/page.tsx +++ b/mpc-core-kit-web/quick-starts/mpc-core-kit-nextjs-quick-start/app/page.tsx @@ -96,7 +96,9 @@ function App() { useEffect(() => { const init = async () => { // IMP START - SDK Initialization - await coreKitInstance.init(); + if (coreKitInstance.status === COREKIT_STATUS.NOT_INITIALIZED) { + await coreKitInstance.init(); + } // IMP END - SDK Initialization setCoreKitStatus(coreKitInstance.status); @@ -190,20 +192,19 @@ function App() { await tempCoreKitInstance.init(); - // Login using Firebase Email Password - const auth = getAuth(app); - const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); - uiConsole(res); - const idToken = await res.user.getIdToken(true); - const userInfo = parseToken(idToken); - - // Use the Web3Auth SFA SDK to generate an account using the Social Factor - await tempCoreKitInstance.loginWithJWT({ - verifier, - verifierId: userInfo.sub, - idToken, - }); - + // Login using Firebase Email Password + const auth = getAuth(app); + const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); + uiConsole(res); + const idToken = await res.user.getIdToken(true); + const userInfo = parseToken(idToken); + + // Use the Web3Auth SFA SDK to generate an account using the Social Factor + await tempCoreKitInstance.loginWithJWT({ + verifier, + verifierId: userInfo.sub, + idToken, + }); // Get the private key using the Social Factor, which can be used as a factor key for the MPC Core Kit const factorKey = await tempCoreKitInstance.state.postBoxKey; @@ -226,7 +227,7 @@ function App() { try { const factorKey = new BN(await getSocialMFAFactorKey(), "hex"); uiConsole("Using the Social Factor Key to Enable MFA, please wait..."); - await coreKitInstance.enableMFA({factorKey, shareDescription: FactorKeyTypeShareDescription.SocialShare }); + await coreKitInstance.enableMFA({ factorKey, shareDescription: FactorKeyTypeShareDescription.SocialShare }); if (coreKitInstance.status === COREKIT_STATUS.LOGGED_IN) { await coreKitInstance.commitChanges(); diff --git a/mpc-core-kit-web/quick-starts/mpc-core-kit-react-quick-start/src/App.tsx b/mpc-core-kit-web/quick-starts/mpc-core-kit-react-quick-start/src/App.tsx index cc8f1d29..7853ef4f 100644 --- a/mpc-core-kit-web/quick-starts/mpc-core-kit-react-quick-start/src/App.tsx +++ b/mpc-core-kit-web/quick-starts/mpc-core-kit-react-quick-start/src/App.tsx @@ -1,5 +1,3 @@ - - import "./App.css"; import { tssLib } from "@toruslabs/tss-dkls-lib"; /* eslint-disable @typescript-eslint/no-use-before-define */ @@ -98,7 +96,9 @@ function App() { useEffect(() => { const init = async () => { // IMP START - SDK Initialization - await coreKitInstance.init(); + if (coreKitInstance.status === COREKIT_STATUS.NOT_INITIALIZED) { + await coreKitInstance.init(); + } // IMP END - SDK Initialization setCoreKitStatus(coreKitInstance.status); @@ -192,20 +192,19 @@ function App() { await tempCoreKitInstance.init(); - // Login using Firebase Email Password - const auth = getAuth(app); - const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); - uiConsole(res); - const idToken = await res.user.getIdToken(true); - const userInfo = parseToken(idToken); - - // Use the Web3Auth SFA SDK to generate an account using the Social Factor - await tempCoreKitInstance.loginWithJWT({ - verifier, - verifierId: userInfo.sub, - idToken, - }); - + // Login using Firebase Email Password + const auth = getAuth(app); + const res = await signInWithEmailAndPassword(auth, "custom+jwt@firebase.login", "Testing@123"); + uiConsole(res); + const idToken = await res.user.getIdToken(true); + const userInfo = parseToken(idToken); + + // Use the Web3Auth SFA SDK to generate an account using the Social Factor + await tempCoreKitInstance.loginWithJWT({ + verifier, + verifierId: userInfo.sub, + idToken, + }); // Get the private key using the Social Factor, which can be used as a factor key for the MPC Core Kit const factorKey = await tempCoreKitInstance.state.postBoxKey; @@ -228,7 +227,7 @@ function App() { try { const factorKey = new BN(await getSocialMFAFactorKey(), "hex"); uiConsole("Using the Social Factor Key to Enable MFA, please wait..."); - await coreKitInstance.enableMFA({factorKey, shareDescription: FactorKeyTypeShareDescription.SocialShare }); + await coreKitInstance.enableMFA({ factorKey, shareDescription: FactorKeyTypeShareDescription.SocialShare }); if (coreKitInstance.status === COREKIT_STATUS.LOGGED_IN) { await coreKitInstance.commitChanges(); diff --git a/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue b/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue index a6b6cf5d..0c8c00cf 100644 --- a/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue +++ b/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue @@ -2,8 +2,7 @@