diff --git a/demo/redirect-flow-example/package-lock.json b/demo/redirect-flow-example/package-lock.json index 31dcb1ba..12059871 100644 --- a/demo/redirect-flow-example/package-lock.json +++ b/demo/redirect-flow-example/package-lock.json @@ -15,7 +15,7 @@ "@types/node": "^16.18.48", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", - "@web3auth/mpc-core-kit": "file://../../", + "@web3auth/mpc-core-kit": "file:../..", "browserify-zlib": "^0.2.0", "copy-webpack-plugin": "^11.0.0", "html-webpack-plugin": "^5.5.3", @@ -46,12 +46,12 @@ }, "../..": { "name": "@web3auth/mpc-core-kit", - "version": "2.1.0", + "version": "2.3.0", "license": "ISC", "dependencies": { "@metamask/swappable-obj-proxy": "^2.1.0", "@tkey-mpc/common-types": "^9.1.0", - "@tkey-mpc/core": "^9.1.1", + "@tkey-mpc/core": "file:tkey-mpc-core-9.1.1.tgz", "@tkey-mpc/service-provider-torus": "^9.1.0", "@tkey-mpc/share-serialization": "^9.1.0", "@tkey-mpc/storage-layer-torus": "^9.1.0", @@ -62,6 +62,7 @@ "@toruslabs/fnd-base": "^13.1.1", "@toruslabs/metadata-helpers": "^5.x", "@toruslabs/openlogin-session-manager": "^3.0.0", + "@toruslabs/openlogin-utils": "^8.0.0", "@toruslabs/torus.js": "^12.1.0", "@toruslabs/tss-client": "^2.1.0", "@toruslabs/tss-lib": "^2.0.0", diff --git a/demo/redirect-flow-example/package.json b/demo/redirect-flow-example/package.json index 635a1c18..6c7f6ff6 100644 --- a/demo/redirect-flow-example/package.json +++ b/demo/redirect-flow-example/package.json @@ -10,7 +10,7 @@ "@types/node": "^16.18.48", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", - "@web3auth/mpc-core-kit": "file://../../", + "@web3auth/mpc-core-kit": "file:../..", "browserify-zlib": "^0.2.0", "copy-webpack-plugin": "^11.0.0", "html-webpack-plugin": "^5.5.3", diff --git a/package-lock.json b/package-lock.json index 9b54d0c2..cabcd7d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@toruslabs/eccrypto": "4.0.0", "@toruslabs/fetch-node-details": "^13.3.0", "@toruslabs/fnd-base": "^13.3.0", + "@toruslabs/http-helpers": "6.1.1", "@toruslabs/metadata-helpers": "^5.x", "@toruslabs/openlogin-session-manager": "^3.1.1", "@toruslabs/openlogin-utils": "^8.1.0", @@ -1899,74 +1900,6 @@ "node": ">=10.0.0" } }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.1.tgz", - "integrity": "sha512-m55cpeupQ2DbuRGQMMZDzbv9J9PgVelPjlcmM5kxHnrBdBx6REaEd7LamYV7Dm8N7rCyR/XwU6rVP8ploKtIkA==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "aix" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.1.tgz", - "integrity": "sha512-4j0+G27/2ZXGWR5okcJi7pQYhmkVgb4D7UKwxcqrjhvp5TKWx3cUjgB1CGj1mfdmJBQ9VnUGgUhign+FPF2Zgw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.1.tgz", - "integrity": "sha512-hCnXNF0HM6AjowP+Zou0ZJMWWa1VkD77BXe959zERgGJBBxB+sV+J9f/rcjeg2c5bsukD/n17RKWXGFCO5dD5A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.1.tgz", - "integrity": "sha512-MSfZMBoAsnhpS+2yMFYIQUPs8Z19ajwfuaSZx+tSl09xrHZCjbeXXMsUF/0oq7ojxYEpsSo4c0SfjxOYXRbpaA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, "node_modules/@esbuild/darwin-arm64": { "version": "0.20.1", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.1.tgz", @@ -1984,312 +1917,6 @@ "node": ">=12" } }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.1.tgz", - "integrity": "sha512-pFIfj7U2w5sMp52wTY1XVOdoxw+GDwy9FsK3OFz4BpMAjvZVs0dT1VXs8aQm22nhwoIWUmIRaE+4xow8xfIDZA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.1.tgz", - "integrity": "sha512-UyW1WZvHDuM4xDz0jWun4qtQFauNdXjXOtIy7SYdf7pbxSWWVlqhnR/T2TpX6LX5NI62spt0a3ldIIEkPM6RHw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.1.tgz", - "integrity": "sha512-itPwCw5C+Jh/c624vcDd9kRCCZVpzpQn8dtwoYIt2TJF3S9xJLiRohnnNrKwREvcZYx0n8sCSbvGH349XkcQeg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.1.tgz", - "integrity": "sha512-LojC28v3+IhIbfQ+Vu4Ut5n3wKcgTu6POKIHN9Wpt0HnfgUGlBuyDDQR4jWZUZFyYLiz4RBBBmfU6sNfn6RhLw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.1.tgz", - "integrity": "sha512-cX8WdlF6Cnvw/DO9/X7XLH2J6CkBnz7Twjpk56cshk9sjYVcuh4sXQBy5bmTwzBjNVZze2yaV1vtcJS04LbN8w==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.1.tgz", - "integrity": "sha512-4H/sQCy1mnnGkUt/xszaLlYJVTz3W9ep52xEefGtd6yXDQbz/5fZE5dFLUgsPdbUOQANcVUa5iO6g3nyy5BJiw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.1.tgz", - "integrity": "sha512-c0jgtB+sRHCciVXlyjDcWb2FUuzlGVRwGXgI+3WqKOIuoo8AmZAddzeOHeYLtD+dmtHw3B4Xo9wAUdjlfW5yYA==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.1.tgz", - "integrity": "sha512-TgFyCfIxSujyuqdZKDZ3yTwWiGv+KnlOeXXitCQ+trDODJ+ZtGOzLkSWngynP0HZnTsDyBbPy7GWVXWaEl6lhA==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.1.tgz", - "integrity": "sha512-b+yuD1IUeL+Y93PmFZDZFIElwbmFfIKLKlYI8M6tRyzE6u7oEP7onGk0vZRh8wfVGC2dZoy0EqX1V8qok4qHaw==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.1.tgz", - "integrity": "sha512-wpDlpE0oRKZwX+GfomcALcouqjjV8MIX8DyTrxfyCfXxoKQSDm45CZr9fanJ4F6ckD4yDEPT98SrjvLwIqUCgg==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.1.tgz", - "integrity": "sha512-5BepC2Au80EohQ2dBpyTquqGCES7++p7G+7lXe1bAIvMdXm4YYcEfZtQrP4gaoZ96Wv1Ute61CEHFU7h4FMueQ==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.1.tgz", - "integrity": "sha512-5gRPk7pKuaIB+tmH+yKd2aQTRpqlf1E4f/mC+tawIm/CGJemZcHZpp2ic8oD83nKgUPMEd0fNanrnFljiruuyA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.1.tgz", - "integrity": "sha512-4fL68JdrLV2nVW2AaWZBv3XEm3Ae3NZn/7qy2KGAt3dexAgSVT+Hc97JKSZnqezgMlv9x6KV0ZkZY7UO5cNLCg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.1.tgz", - "integrity": "sha512-GhRuXlvRE+twf2ES+8REbeCb/zeikNqwD3+6S5y5/x+DYbAQUNl0HNBs4RQJqrechS4v4MruEr8ZtAin/hK5iw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.1.tgz", - "integrity": "sha512-ZnWEyCM0G1Ex6JtsygvC3KUUrlDXqOihw8RicRuQAzw+c4f1D66YlPNNV3rkjVW90zXVsHwZYWbJh3v+oQFM9Q==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.1.tgz", - "integrity": "sha512-QZ6gXue0vVQY2Oon9WyLFCdSuYbXSoxaZrPuJ4c20j6ICedfsDilNPYfHLlMH7vGfU5DQR0czHLmJvH4Nzis/A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.1.tgz", - "integrity": "sha512-HzcJa1NcSWTAU0MJIxOho8JftNp9YALui3o+Ny7hCh0v5f90nprly1U3Sj1Ldj/CvKKdvvFsCRvDkpsEMp4DNw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.20.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.1.tgz", - "integrity": "sha512-0MBh53o6XtI6ctDnRMeQ+xoCN8kD2qI1rY1KgF/xdWQwoFeKou7puvDfV8/Wv4Ctx2rRpET/gGdz3YlNtNACSA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">=12" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -3951,6 +3578,28 @@ "@babel/runtime": "7.x" } }, + "node_modules/@tkey-mpc/common-types/node_modules/@toruslabs/http-helpers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", + "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", + "dependencies": { + "lodash.merge": "^4.6.2", + "loglevel": "^1.8.1" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "peerDependencies": { + "@babel/runtime": "^7.x", + "@sentry/types": "^7.x" + }, + "peerDependenciesMeta": { + "@sentry/types": { + "optional": true + } + } + }, "node_modules/@tkey-mpc/common-types/node_modules/@toruslabs/torus.js": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@toruslabs/torus.js/-/torus.js-11.0.6.tgz", @@ -3995,6 +3644,28 @@ "@babel/runtime": "7.x" } }, + "node_modules/@tkey-mpc/core/node_modules/@toruslabs/http-helpers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", + "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", + "dependencies": { + "lodash.merge": "^4.6.2", + "loglevel": "^1.8.1" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "peerDependencies": { + "@babel/runtime": "^7.x", + "@sentry/types": "^7.x" + }, + "peerDependenciesMeta": { + "@sentry/types": { + "optional": true + } + } + }, "node_modules/@tkey-mpc/core/node_modules/@toruslabs/torus.js": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@toruslabs/torus.js/-/torus.js-11.0.6.tgz", @@ -4054,6 +3725,28 @@ "@babel/runtime": "7.x" } }, + "node_modules/@tkey-mpc/service-provider-torus/node_modules/@toruslabs/http-helpers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", + "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", + "dependencies": { + "lodash.merge": "^4.6.2", + "loglevel": "^1.8.1" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "peerDependencies": { + "@babel/runtime": "^7.x", + "@sentry/types": "^7.x" + }, + "peerDependenciesMeta": { + "@sentry/types": { + "optional": true + } + } + }, "node_modules/@tkey-mpc/service-provider-torus/node_modules/@toruslabs/torus.js": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@toruslabs/torus.js/-/torus.js-11.0.6.tgz", @@ -4351,28 +4044,6 @@ "@babel/runtime": "7.x" } }, - "node_modules/@toruslabs/base-session-manager/node_modules/@toruslabs/http-helpers": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-6.1.1.tgz", - "integrity": "sha512-bJYOaltRzklzObhRdutT1wau17vXyrCCBKJOeN46F1t99MUXi5udQNeErFOcr9qBsvrq2q67eVBkU5XOeBMX5A==", - "dependencies": { - "lodash.merge": "^4.6.2", - "loglevel": "^1.9.1" - }, - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "^7.x", - "@sentry/types": "^7.x" - }, - "peerDependenciesMeta": { - "@sentry/types": { - "optional": true - } - } - }, "node_modules/@toruslabs/broadcast-channel": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/@toruslabs/broadcast-channel/-/broadcast-channel-8.0.0.tgz", @@ -4406,9 +4077,9 @@ } }, "node_modules/@toruslabs/constants": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/@toruslabs/constants/-/constants-13.3.0.tgz", - "integrity": "sha512-i/fX5DeEUj4EoQmFT8YdO8bwN7Na83zZq6RrSmOpRmVA0F7MMbUsxhsvAp/kOmceg0lU1ZHQTTJRmh7OTExaIw==", + "version": "13.4.0", + "resolved": "https://registry.npmjs.org/@toruslabs/constants/-/constants-13.4.0.tgz", + "integrity": "sha512-CjmnMQ5Oj0bqSBGkhv7Xm3LciGJDHwe4AJ1LF6mijlP+QcCnUM5I6kVp60j7zZ/r0DT7nIEiuHHHczGpCZor0A==", "engines": { "node": ">=18.x", "npm": ">=9.x" @@ -4792,12 +4463,12 @@ "dev": true }, "node_modules/@toruslabs/fetch-node-details": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/@toruslabs/fetch-node-details/-/fetch-node-details-13.3.0.tgz", - "integrity": "sha512-UXU2ZnJ954ZvyWYbN0n5rXrIYkNjipTuXsNyLCtWgNU5zkf1ODGE6uNeEbA3LbdUCQj6r9GPIY9hQgKYyzjlhw==", + "version": "13.4.0", + "resolved": "https://registry.npmjs.org/@toruslabs/fetch-node-details/-/fetch-node-details-13.4.0.tgz", + "integrity": "sha512-WTfI47Q5sldlz4nh8kNPI95PXm3hjm3IEDnYRY3rlcCrs9sVwdQItKf4D0i5s9sRmwLIpG3po+IpEcdO82CIuA==", "dependencies": { - "@toruslabs/constants": "^13.3.0", - "@toruslabs/fnd-base": "^13.3.0", + "@toruslabs/constants": "^13.4.0", + "@toruslabs/fnd-base": "^13.4.0", "@toruslabs/http-helpers": "^6.1.1", "loglevel": "^1.9.1" }, @@ -4832,11 +4503,11 @@ } }, "node_modules/@toruslabs/fnd-base": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/@toruslabs/fnd-base/-/fnd-base-13.3.0.tgz", - "integrity": "sha512-sxIO+Seg6f3SxwZ++W92b2nY7KvA/atfrixuu9tz1JTQD6IMKQqq0MtYvsm8A4+e1CMrFetCeL9KQv3HeITH8w==", + "version": "13.4.0", + "resolved": "https://registry.npmjs.org/@toruslabs/fnd-base/-/fnd-base-13.4.0.tgz", + "integrity": "sha512-Fc3uFj5ZfDmR4uWAMRyLVvBsSLXJWBHQoHOsucVqvxXpNeLSrFEQIxqlXsgjRfQPOSKtpljSl1MaXibhb5/hfA==", "dependencies": { - "@toruslabs/constants": "^13.3.0" + "@toruslabs/constants": "^13.4.0" }, "engines": { "node": ">=18.x", @@ -4847,12 +4518,12 @@ } }, "node_modules/@toruslabs/http-helpers": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", - "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-6.1.1.tgz", + "integrity": "sha512-bJYOaltRzklzObhRdutT1wau17vXyrCCBKJOeN46F1t99MUXi5udQNeErFOcr9qBsvrq2q67eVBkU5XOeBMX5A==", "dependencies": { "lodash.merge": "^4.6.2", - "loglevel": "^1.8.1" + "loglevel": "^1.9.1" }, "engines": { "node": ">=18.x", @@ -4887,28 +4558,6 @@ "@babel/runtime": "7.x" } }, - "node_modules/@toruslabs/metadata-helpers/node_modules/@toruslabs/http-helpers": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-6.1.1.tgz", - "integrity": "sha512-bJYOaltRzklzObhRdutT1wau17vXyrCCBKJOeN46F1t99MUXi5udQNeErFOcr9qBsvrq2q67eVBkU5XOeBMX5A==", - "dependencies": { - "lodash.merge": "^4.6.2", - "loglevel": "^1.9.1" - }, - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "^7.x", - "@sentry/types": "^7.x" - }, - "peerDependenciesMeta": { - "@sentry/types": { - "optional": true - } - } - }, "node_modules/@toruslabs/openlogin": { "version": "6.2.11", "resolved": "https://registry.npmjs.org/@toruslabs/openlogin/-/openlogin-6.2.11.tgz", @@ -5106,6 +4755,28 @@ "@babel/runtime": "7.x" } }, + "node_modules/@toruslabs/secure-pub-sub/node_modules/@toruslabs/http-helpers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", + "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", + "dependencies": { + "lodash.merge": "^4.6.2", + "loglevel": "^1.8.1" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "peerDependencies": { + "@babel/runtime": "^7.x", + "@sentry/types": "^7.x" + }, + "peerDependenciesMeta": { + "@sentry/types": { + "optional": true + } + } + }, "node_modules/@toruslabs/torus-scripts": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@toruslabs/torus-scripts/-/torus-scripts-5.3.1.tgz", @@ -5200,10 +4871,32 @@ "@babel/runtime": "7.x" } }, + "node_modules/@toruslabs/torus.js/node_modules/@toruslabs/http-helpers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", + "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", + "dependencies": { + "lodash.merge": "^4.6.2", + "loglevel": "^1.8.1" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "peerDependencies": { + "@babel/runtime": "^7.x", + "@sentry/types": "^7.x" + }, + "peerDependenciesMeta": { + "@sentry/types": { + "optional": true + } + } + }, "node_modules/@toruslabs/tss-client": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@toruslabs/tss-client/-/tss-client-2.3.2.tgz", - "integrity": "sha512-oAb05DH+IUlI/cn/APwwhd9855/YhpfOArDr+f0SLXZgI+NnXNzSwR5JwzMjYJyiR4QEZRgo2oLdH+xLWKBpyA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@toruslabs/tss-client/-/tss-client-2.3.3.tgz", + "integrity": "sha512-vWye8ax24TSpmLCw1eSsKFesr1MOZ+lsfJ/Z2+eHMVOt/Zq5WnqbYBOiU3yA8h80IrZEcvdP+5LiHH5pH8SEKw==", "dependencies": { "@toruslabs/eccrypto": "^4.0.0", "@toruslabs/tss-lib": "^2.3.0", @@ -5370,9 +5063,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "20.12.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.8.tgz", - "integrity": "sha512-NU0rJLJnshZWdE/097cdCBbyW1h4hEg0xpovcoAQYHl8dnEyp/NAOiE45pvc+Bd1Dt+2r94v2eGFpQJ4R7g+2w==", + "version": "20.12.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.10.tgz", + "integrity": "sha512-Eem5pH9pmWBHoGAT8Dr5fdc5rYA+4NAovdM4EktRPVAAiJhmWWfQrA0cFhAbOsQdSfIHjAud6YdkbL69+zSKjw==", "dependencies": { "undici-types": "~5.26.4" } @@ -5920,28 +5613,6 @@ "npm": ">=9.x" } }, - "node_modules/@web3auth/base-provider/node_modules/@toruslabs/http-helpers": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-6.0.0.tgz", - "integrity": "sha512-/KrISB9fGV2TM+5Z+0CGj24d/G08kqbB+kodO3nbwNcS0a55dpy+RiB0naF3H1gbEt4Ah5YH8qCDyAZ+zcR2FQ==", - "dependencies": { - "lodash.merge": "^4.6.2", - "loglevel": "^1.8.1" - }, - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "^7.x", - "@sentry/types": "^7.x" - }, - "peerDependenciesMeta": { - "@sentry/types": { - "optional": true - } - } - }, "node_modules/@web3auth/base-provider/node_modules/@toruslabs/openlogin-jrpc": { "version": "6.2.11", "resolved": "https://registry.npmjs.org/@toruslabs/openlogin-jrpc/-/openlogin-jrpc-6.2.11.tgz", @@ -5995,28 +5666,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@web3auth/base/node_modules/@toruslabs/http-helpers": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-6.0.0.tgz", - "integrity": "sha512-/KrISB9fGV2TM+5Z+0CGj24d/G08kqbB+kodO3nbwNcS0a55dpy+RiB0naF3H1gbEt4Ah5YH8qCDyAZ+zcR2FQ==", - "dependencies": { - "lodash.merge": "^4.6.2", - "loglevel": "^1.8.1" - }, - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "^7.x", - "@sentry/types": "^7.x" - }, - "peerDependenciesMeta": { - "@sentry/types": { - "optional": true - } - } - }, "node_modules/@web3auth/base/node_modules/@toruslabs/openlogin-jrpc": { "version": "6.2.11", "resolved": "https://registry.npmjs.org/@toruslabs/openlogin-jrpc/-/openlogin-jrpc-6.2.11.tgz", diff --git a/package.json b/package.json index d45e2a2f..e1c1a162 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@web3auth/base-provider": "^7.0.1", "bn.js": "^5.2.1", "bowser": "^2.11.0", - "elliptic": "^6.5.5" + "elliptic": "^6.5.5", + "@toruslabs/http-helpers": "6.1.1" }, "devDependencies": { "@babel/register": "^7.23.7", @@ -93,13 +94,13 @@ }, "overrides": { "@tkey-mpc/storage-layer-torus": { - "@toruslabs/http-helpers": "^6.0.0" + "@toruslabs/http-helpers": "^6.1.1" }, "@toruslabs/base-session-manager": { - "@toruslabs/http-helpers": "^6.0.0" + "@toruslabs/http-helpers": "^6.1.1" }, "@toruslabs/customauth": { - "@toruslabs/http-helpers": "^6.0.0" + "@toruslabs/http-helpers": "^6.1.1" } }, "lint-staged": { diff --git a/src/mpcCoreKit.ts b/src/mpcCoreKit.ts index f6e88801..558c92c7 100644 --- a/src/mpcCoreKit.ts +++ b/src/mpcCoreKit.ts @@ -589,17 +589,18 @@ export class Web3AuthMPCCoreKit implements ICoreKit { } await this.inputFactorKey(new BN(deviceFactorKey, "hex")); + // only recovery factor = true + let backupFactorKey = ""; + if (recoveryFactor) { + backupFactorKey = await this.createFactor({ shareType: TssShareType.RECOVERY, ...enableMFAParams }); + } + const hashedFactorPub = getPubKeyPoint(hashedFactorKey); await this.deleteFactor(hashedFactorPub, hashedFactorKey); await this.deleteMetadataShareBackup(hashedFactorKey); - // only recovery factor = true - if (recoveryFactor) { - const backupFactorKey = await this.createFactor({ shareType: TssShareType.RECOVERY, ...enableMFAParams }); - return backupFactorKey; - } // update to undefined for next major release - return ""; + return backupFactorKey; } catch (err: unknown) { log.error("error enabling MFA", err); throw new Error((err as Error).message); @@ -940,9 +941,10 @@ export class Web3AuthMPCCoreKit implements ICoreKit { if (!this.options.manualSync) await this.commitChanges(); } else { if (importTssKey) throw new Error("Cannot import tss key for existing user"); - await this.tKey.initialize({ neverInitializeNewKey: true }); const hashedFactorKey = getHashedPrivateKey(this.state.oAuthKey, this.options.hashedFactorNonce); - if ((await this.checkIfFactorKeyValid(hashedFactorKey)) && !this.options.disableHashedFactorKey) { + const isHashedFactorKeyValid = await this.checkIfFactorKeyValid(hashedFactorKey); + await this.tKey.initialize({ neverInitializeNewKey: true }); + if (isHashedFactorKeyValid && !this.options.disableHashedFactorKey) { // Initialize tkey with existing hashed share if available. const factorKeyMetadata: ShareStore = await this.getFactorKeyMetadata(hashedFactorKey); try { @@ -1012,6 +1014,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit { } } catch (err) { log.error("error trying to authorize session", err); + throw err; } } @@ -1027,6 +1030,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit { if (!oAuthKey || !factorKey || !tssShare || !tssPubKey || !userInfo) { throw new Error("User not logged in"); } + const payload: SessionData = { oAuthKey, factorKey: factorKey?.toString("hex"), @@ -1046,7 +1050,8 @@ export class Web3AuthMPCCoreKit implements ICoreKit { private async isMetadataPresent(privateKey: string) { const privateKeyBN = new BN(privateKey, "hex"); const metadata = await this.tKey?.storageLayer.getMetadata<{ message: string }>({ privKey: privateKeyBN }); - if (metadata && Object.keys(metadata).length > 0 && metadata.message !== "KEY_NOT_FOUND") { + + if (metadata && Object.keys(metadata).length > 0 && metadata.message !== "KEY_NOT_FOUND" && metadata.message !== "SHARE_DELETED") { return true; } return false; @@ -1068,6 +1073,9 @@ export class Web3AuthMPCCoreKit implements ICoreKit { if (!factorKeyMetadata || factorKeyMetadata.message === "KEY_NOT_FOUND") { throw new Error("no metadata for your factor key, reset your account"); } + if (factorKeyMetadata.message === "SHARE_DELETED") { + throw new Error("no metadata for your factor key, deleted."); + } return ShareStore.fromJSON(factorKeyMetadata); } @@ -1088,6 +1096,13 @@ export class Web3AuthMPCCoreKit implements ICoreKit { if (!this.state.factorKey) { throw new Error("factorKey not present"); } + // validate the current factor key + // current factor might be deleted from other instnaces, + // so it's better to validate it before we creating any shares + const factorKeyMetadata = await this.tKey?.storageLayer.getMetadata({ privKey: this.getCurrentFactorKey().factorKey }); + if (factorKeyMetadata?.message === SHARE_DELETED) { + throw new Error("Current factorKey is not valid"); + } if (VALID_SHARE_INDICES.indexOf(newFactorTSSIndex) === -1) { throw new Error(`invalid new share index: must be one of ${VALID_SHARE_INDICES}`); } diff --git a/tests/factors.spec.ts b/tests/factors.spec.ts index 14d43eb2..ba145897 100644 --- a/tests/factors.spec.ts +++ b/tests/factors.spec.ts @@ -39,7 +39,7 @@ export const FactorManipulationTest = async ( await coreKitInstance.logout(); }); - await t.test("should able to create factor", async function () { + await t.test("should be able to create factor", async function () { const coreKitInstance = await newInstance(); coreKitInstance.setTssWalletIndex(1); @@ -60,6 +60,11 @@ export const FactorManipulationTest = async ( throw new Error("should not reach here"); } catch {} + // sync + if (testVariable.manualSync) { + await coreKitInstance.commitChanges(); + } + // create factor const factorKey1 = await coreKitInstance.createFactor({ shareType: TssShareType.DEVICE, @@ -141,6 +146,9 @@ export const FactorManipulationTest = async ( await t.test("enable MFA", async function () { const instance = await newInstance(); + if (testVariable.manualSync) { + await instance.commitChanges(); + } instance.setTssWalletIndex(1); const recoverFactor = await instance.enableMFA({}); @@ -184,7 +192,7 @@ const variable: FactorTestVariable[] = [ { types: TssShareType.RECOVERY, manualSync: false, asyncStorage: new AsyncMemoryStorage() }, ]; -const email = "testmail102"; +const email = "testmail08_manipulate_factor"; variable.forEach(async (testVariable) => { const newCoreKitLogInInstance = async (ignoreError: boolean) => { const instance = new Web3AuthMPCCoreKit({