diff --git a/package-lock.json b/package-lock.json index 8e6191e7..335c5a74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,22 +10,22 @@ "license": "ISC", "dependencies": { "@tkey/common-types": "^15.1.0", - "@tkey/core": "^15.1.0", + "@tkey/core": "^15.2.0-alpha.0", "@tkey/share-serialization": "^15.1.0", "@tkey/storage-layer-torus": "^15.1.0", - "@tkey/tss": "^15.1.0", + "@tkey/tss": "^15.2.0-alpha.0", "@toruslabs/constants": "^14.0.0", "@toruslabs/customauth": "^20.3.0", "@toruslabs/elliptic-wrapper": "^0.1.0", "@toruslabs/fetch-node-details": "^14.0.1", "@toruslabs/fnd-base": "^14.0.0", "@toruslabs/metadata-helpers": "^6.0.0", - "@toruslabs/openlogin-utils": "^8.2.1", "@toruslabs/session-manager": "^3.1.0", "@toruslabs/torus.js": "^15.1.0", "@toruslabs/tss-client": "^3.1.0", "@toruslabs/tss-frost-client": "0.3.1", "@toruslabs/tss-frost-common": "^1.0.1", + "@web3auth/auth": "^9.4.1", "bn.js": "^5.2.1", "bowser": "^2.11.0", "elliptic": "^6.5.7", @@ -2557,6 +2557,31 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@ethereumjs/rlp": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-5.0.2.tgz", + "integrity": "sha512-DziebCdg4JpGlEqEdGgXmjqcFoJi+JGulUXwEjsZGAscAQ7MyD/7LE/GVCP29vEQxKc7AAwjT3A2ywHp2xfoCA==", + "license": "MPL-2.0", + "bin": { + "rlp": "bin/rlp.cjs" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@ethereumjs/util": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-9.1.0.tgz", + "integrity": "sha512-XBEKsYqLGXLah9PNJbgdkigthkG7TAGvlD/sH12beMXEyHDyigfcbdvHhmLyDWgDyOJn4QwiQUaF7yeuhnjdog==", + "license": "MPL-2.0", + "dependencies": { + "@ethereumjs/rlp": "^5.0.2", + "ethereum-cryptography": "^2.2.1" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -3004,6 +3029,22 @@ "node": ">= 8" } }, + "node_modules/@nx/nx-linux-x64-gnu": { + "version": "19.8.10", + "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-gnu/-/nx-linux-x64-gnu-19.8.10.tgz", + "integrity": "sha512-Soxogm5eql+bj4SIY8uFQGJAh/ODsFhiztaA+NxkYnRJOrLIWw+gprHDpyTUi2y4erSj1lHu+DiIZQ43cHq2fw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@octokit/auth-token": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", @@ -3483,7 +3524,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -3662,10 +3702,9 @@ } }, "node_modules/@tkey/core": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/@tkey/core/-/core-15.1.0.tgz", - "integrity": "sha512-JaFprczHR8fBEw1LrwKs87ASgpZagxQ9VZ6lAfAAI8jEh1yhz8djh9l2wzJbaFuLEOQskh7GoxpKfgB+YtBSmw==", - "license": "MIT", + "version": "15.2.0-alpha.0", + "resolved": "https://registry.npmjs.org/@tkey/core/-/core-15.2.0-alpha.0.tgz", + "integrity": "sha512-uBrh0RpGBME+8ZK4y1IKQYFy9j0K6pW+14Zrp1pSAgSJRNMrTypvROReBAxgHQkMWA4AdvBH9xXxaYxjc7octA==", "dependencies": { "@tkey/common-types": "^15.1.0", "@toruslabs/eccrypto": "^5.0.4", @@ -3763,15 +3802,15 @@ } }, "node_modules/@tkey/tss": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/@tkey/tss/-/tss-15.1.0.tgz", - "integrity": "sha512-UcbJbWscIL83Zh1/i6M+X/xhN4EOimGV8JoWZ3D23Ji2pHPo8BgveUZA9i1DK4Y3YqqZ9aS8PvhSHt+KVnNluw==", - "license": "ISC", + "version": "15.2.0-alpha.0", + "resolved": "https://registry.npmjs.org/@tkey/tss/-/tss-15.2.0-alpha.0.tgz", + "integrity": "sha512-Cc+Pl4XaqVr+l3/wVIv2nRmKWrAhqh8frm11dz8iqZgS6tks81mjJyZ0XHAoxiuMp+Rdkj3DqkDqjgAVUtU5Yw==", "dependencies": { "@tkey/common-types": "^15.1.0", - "@tkey/core": "^15.1.0", + "@tkey/core": "^15.2.0-alpha.0", "@tkey/service-provider-torus": "^15.1.0", "@toruslabs/customauth": "^20.3.0", + "@toruslabs/http-helpers": "^7.0.0", "@toruslabs/rss-client": "^2.0.1", "@toruslabs/torus.js": "^15.1.0", "@types/bn.js": "^5.1.5", @@ -4212,6 +4251,16 @@ "@babel/runtime": "7.x" } }, + "node_modules/@toruslabs/ffjavascript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/ffjavascript/-/ffjavascript-4.0.0.tgz", + "integrity": "sha512-sGPKK0xZ7KDLOsVc8/rCb83iCT1xD12+yfl3eoVNppr4vMcPJcXGwqpw4r1nP3Ln10UHvTCduxjUr3axdoxOSw==", + "license": "GPL-3.0", + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + } + }, "node_modules/@toruslabs/fnd-base": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/@toruslabs/fnd-base/-/fnd-base-14.0.0.tgz", @@ -4271,15 +4320,18 @@ "@babel/runtime": "7.x" } }, - "node_modules/@toruslabs/openlogin-utils": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/@toruslabs/openlogin-utils/-/openlogin-utils-8.2.1.tgz", - "integrity": "sha512-NSOtj61NZe7w9qbd92cYwMlE/1UwPGtDH02NfUjoEEc3p1yD5U2cLZjdSwsnAgjGNgRqVomXpND4hii12lI/ew==", - "license": "ISC", + "node_modules/@toruslabs/rss-client": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@toruslabs/rss-client/-/rss-client-2.0.1.tgz", + "integrity": "sha512-EBqAX7LK8ZBy4fiGTGQhI3wVvLvfUyfwREbNkfAxP/iwevgCA2EKLXGWtVsvJj/wXF8HkfjqOcorVeHwP2vvWw==", + "license": "MIT", "dependencies": { - "@toruslabs/constants": "^13.2.0", - "base64url": "^3.0.1", - "color": "^4.2.3" + "@toruslabs/eccrypto": "^5.0.4", + "@toruslabs/http-helpers": "^7.0.0", + "bn.js": "^5.2.1", + "elliptic": "^6.5.7", + "fetch": "^1.1.0", + "loglevel": "^1.9.2" }, "engines": { "node": ">=18.x", @@ -4289,31 +4341,17 @@ "@babel/runtime": "7.x" } }, - "node_modules/@toruslabs/openlogin-utils/node_modules/@toruslabs/constants": { - "version": "13.4.0", - "resolved": "https://registry.npmjs.org/@toruslabs/constants/-/constants-13.4.0.tgz", - "integrity": "sha512-CjmnMQ5Oj0bqSBGkhv7Xm3LciGJDHwe4AJ1LF6mijlP+QcCnUM5I6kVp60j7zZ/r0DT7nIEiuHHHczGpCZor0A==", - "license": "MIT", - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "7.x" - } - }, - "node_modules/@toruslabs/rss-client": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@toruslabs/rss-client/-/rss-client-2.0.1.tgz", - "integrity": "sha512-EBqAX7LK8ZBy4fiGTGQhI3wVvLvfUyfwREbNkfAxP/iwevgCA2EKLXGWtVsvJj/wXF8HkfjqOcorVeHwP2vvWw==", + "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==", "license": "MIT", "dependencies": { - "@toruslabs/eccrypto": "^5.0.4", + "@toruslabs/eccrypto": "^5.0.0", "@toruslabs/http-helpers": "^7.0.0", - "bn.js": "^5.2.1", - "elliptic": "^6.5.7", - "fetch": "^1.1.0", - "loglevel": "^1.9.2" + "@toruslabs/metadata-helpers": "^6.0.0", + "loglevel": "^1.9.1", + "socket.io-client": "^4.7.5" }, "engines": { "node": ">=18.x", @@ -4354,6 +4392,28 @@ "linux" ] }, + "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==", + "license": "MIT", + "dependencies": { + "assert": "^2.1.0", + "bip39": "^3.1.0", + "bn.js": "^5.2.1", + "elliptic": "~6.5.5", + "enc-utils": "^3.0.0", + "ethereum-cryptography": "^2.2.0", + "hash.js": "^1.1.7" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "peerDependencies": { + "@babel/runtime": "7.x" + } + }, "node_modules/@toruslabs/torus-scripts": { "version": "6.1.2", "resolved": "https://registry.npmjs.org/@toruslabs/torus-scripts/-/torus-scripts-6.1.2.tgz", @@ -4518,6 +4578,12 @@ "integrity": "sha512-uDsM7f6NiVvNKVOfTUK+CucZUy1TjvTSYvk5LL8t2i/izWzNbBg4NO9qAFws3Kp9Kt1hG0xo8FkWzh3+oJ82xA==", "dev": true }, + "node_modules/@toruslabs/tweetnacl-js": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@toruslabs/tweetnacl-js/-/tweetnacl-js-1.0.4.tgz", + "integrity": "sha512-h8fVemW5pstsKbm/fTx+y61dZkh5Pepy/92lsyKp83KErf96jT+w4LGx4nEgeAVrdYQDTLg2tO7vu/boEb23Iw==", + "license": "Unlicense" + }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -4962,6 +5028,74 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "license": "ISC" }, + "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==", + "license": "MIT", + "dependencies": { + "@ethereumjs/util": "^9.1.0", + "@toruslabs/constants": "^14.0.0", + "@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/tweetnacl-js": "^1.0.4", + "base64url": "^3.0.1", + "bip39": "^3.1.0", + "bn.js": "^5.2.1", + "bowser": "^2.11.0", + "color": "^4.2.3", + "enc-utils": "^3.0.0", + "end-of-stream": "^1.4.4", + "events": "^3.3.0", + "fast-safe-stringify": "^2.1.1", + "json-stable-stringify": "^1.1.1", + "loglevel": "^1.9.1", + "once": "^1.4.0", + "pump": "^3.0.0", + "readable-stream": "^4.5.2", + "ts-custom-error": "^3.3.1", + "typed-emitter": "^2.1.0" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "optionalDependencies": { + "@nx/nx-linux-x64-gnu": "^19.6.3", + "@rollup/rollup-linux-x64-gnu": "^4.21.1" + }, + "peerDependencies": { + "@babel/runtime": "7.x" + } + }, + "node_modules/@web3auth/auth/node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@web3auth/auth/node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", @@ -5184,6 +5318,18 @@ "dev": true, "license": "Apache-2.0" }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/acorn": { "version": "8.12.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", @@ -5540,7 +5686,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz", "integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==", - "dev": true, "license": "MIT", "dependencies": { "call-bind": "^1.0.2", @@ -5799,7 +5944,6 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, "funding": [ { "type": "github", @@ -5855,6 +5999,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/bip39": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", + "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "license": "ISC", + "dependencies": { + "@noble/hashes": "^1.2.0" + } + }, "node_modules/biskviit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/biskviit/-/biskviit-1.0.1.tgz", @@ -6219,7 +6372,6 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "dev": true, "funding": [ { "type": "github", @@ -7468,6 +7620,16 @@ "dev": true, "license": "MIT" }, + "node_modules/enc-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/enc-utils/-/enc-utils-3.0.0.tgz", + "integrity": "sha512-e57t/Z2HzWOLwOp7DZcV0VMEY8t7ptWwsxyp6kM2b2zrk6JqIpXxzkruHAMiBsy5wg9jp/183GdiRXCvBtzsYg==", + "license": "MIT", + "dependencies": { + "is-typedarray": "1.0.0", + "typedarray-to-buffer": "3.1.5" + } + }, "node_modules/encoding": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", @@ -7477,6 +7639,15 @@ "iconv-lite": "~0.4.13" } }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/engine.io-client": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz", @@ -8569,6 +8740,15 @@ "@scure/bip39": "1.3.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", @@ -8579,7 +8759,6 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.8.x" @@ -8687,6 +8866,12 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "license": "MIT" }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "license": "MIT" + }, "node_modules/fast-uri": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", @@ -9772,7 +9957,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, "funding": [ { "type": "github", @@ -10229,7 +10413,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dev": true, "license": "MIT", "dependencies": { "call-bind": "^1.0.2", @@ -10447,7 +10630,6 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", - "dev": true, "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" @@ -10560,7 +10742,6 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", - "dev": true, "license": "MIT", "dependencies": { "call-bind": "^1.0.0", @@ -10767,7 +10948,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", - "dev": true, "license": "MIT" }, "node_modules/is-unicode-supported": { @@ -12330,7 +12510,6 @@ "version": "1.1.6", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz", "integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==", - "dev": true, "license": "MIT", "dependencies": { "call-bind": "^1.0.7", @@ -13235,7 +13414,6 @@ "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.6.0" @@ -13327,6 +13505,16 @@ "dev": true, "license": "MIT" }, + "node_modules/pump": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", + "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -14323,7 +14511,7 @@ "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "dev": true, + "devOptional": true, "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" @@ -14351,7 +14539,6 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, "funding": [ { "type": "github", @@ -15604,11 +15791,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/typed-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz", + "integrity": "sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==", + "license": "MIT", + "optionalDependencies": { + "rxjs": "*" + } + }, "node_modules/typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, "license": "MIT", "dependencies": { "is-typedarray": "^1.0.0" @@ -15873,7 +16068,6 @@ "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", - "dev": true, "license": "MIT", "dependencies": { "inherits": "^2.0.3", diff --git a/package.json b/package.json index 7a6cb85f..fe7c7e47 100644 --- a/package.json +++ b/package.json @@ -44,10 +44,10 @@ }, "dependencies": { "@tkey/common-types": "^15.1.0", - "@tkey/core": "^15.1.0", + "@tkey/core": "^15.2.0-alpha.0", "@tkey/share-serialization": "^15.1.0", "@tkey/storage-layer-torus": "^15.1.0", - "@tkey/tss": "^15.1.0", + "@tkey/tss": "^15.2.0-alpha.0", "@toruslabs/constants": "^14.0.0", "@toruslabs/customauth": "^20.3.0", "@toruslabs/elliptic-wrapper": "^0.1.0", @@ -55,11 +55,11 @@ "@toruslabs/fnd-base": "^14.0.0", "@toruslabs/metadata-helpers": "^6.0.0", "@toruslabs/session-manager": "^3.1.0", - "@toruslabs/openlogin-utils": "^8.2.1", "@toruslabs/torus.js": "^15.1.0", "@toruslabs/tss-client": "^3.1.0", "@toruslabs/tss-frost-client": "0.3.1", "@toruslabs/tss-frost-common": "^1.0.1", + "@web3auth/auth": "^9.4.1", "bn.js": "^5.2.1", "bowser": "^2.11.0", "elliptic": "^6.5.7", diff --git a/src/interfaces.ts b/src/interfaces.ts index b87c23a0..b3071656 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -1,4 +1,4 @@ -import { KeyType, Point as TkeyPoint, ShareDescriptionMap } from "@tkey/common-types"; +import { BNString, KeyType, Point as TkeyPoint, ShareDescriptionMap } from "@tkey/common-types"; import { TKeyTSS } from "@tkey/tss"; import type { AGGREGATE_VERIFIER_TYPE, @@ -92,7 +92,7 @@ export interface EnableMFAParams { /** * A BN used for encrypting your Device/ Recovery TSS Key Share. You can generate it using `generateFactorKey()` function or use an existing one. */ - factorKey?: BN; + factorKey?: BNString; /** * Setting the Description of Share - Security Questions, Device Share, Seed Phrase, Password Share, Social Share, Other. Default is Other. */ @@ -229,7 +229,7 @@ export interface ICoreKit { * Share. You can generate it using `generateFactorKey()` function or use an * existing one. */ - inputFactorKey(factorKey: BN): Promise; + inputFactorKey(factorKey: BNString): Promise; /** * Returns the current Factor Key and TssShareType in MPC Core Kit State @@ -266,6 +266,16 @@ export interface ICoreKit { */ getKeyDetails(): MPCKeyDetails; + /** + * Get specific general domain's metadata which is used by plugin or modules. + */ + getGeneralStoreDomain(domain: string): T; + + /** + * Set specific general domain's metadata which is used by plugin or modules. + */ + setGeneralStoreDomain(domain: string, value: T): void; + /** * Commit the changes made to the user's account when in manual sync mode. */ diff --git a/src/mpcCoreKit.ts b/src/mpcCoreKit.ts index b509543e..5438db8e 100644 --- a/src/mpcCoreKit.ts +++ b/src/mpcCoreKit.ts @@ -1,6 +1,5 @@ import { BNString, KeyType, Point, secp256k1, SHARE_DELETED, ShareStore, StringifiedType } from "@tkey/common-types"; import { CoreError } from "@tkey/core"; -import { ShareSerializationModule } from "@tkey/share-serialization"; import { TorusStorageLayer } from "@tkey/storage-layer-torus"; import { factorKeyCurve, getPubKeyPoint, lagrangeInterpolation, TKeyTSS, TSSTorusServiceProvider } from "@tkey/tss"; import { KEY_TYPE, SIGNER_MAP } from "@toruslabs/constants"; @@ -112,7 +111,10 @@ export class Web3AuthMPCCoreKit implements ICoreKit { if (options.enableLogging) { log.enableAll(); this.enableLogging = true; - } else log.setLevel("error"); + } else { + log.setLevel("error"); + options.enableLogging = false; + } if (typeof options.manualSync !== "boolean") options.manualSync = false; if (!options.web3AuthNetwork) options.web3AuthNetwork = WEB3AUTH_NETWORK.MAINNET; // if sessionTime is not provided, it is defaulted to 86400 @@ -197,6 +199,56 @@ export class Web3AuthMPCCoreKit implements ICoreKit { return this.keyType === KeyType.ed25519 && this.options.useClientGeneratedTSSKey === undefined ? true : !!this.options.useClientGeneratedTSSKey; } + static async fromJSON(value: StringifiedType, options: Web3AuthOptions): Promise { + const coreKit = new Web3AuthMPCCoreKit(options); + const { state, serviceProvider, storageLayer, keyType, atomicCallStackCounter, ready, sessionId, tkey } = value; + coreKit.torusSp = TSSTorusServiceProvider.fromJSON(serviceProvider); + coreKit.storageLayer = TorusStorageLayer.fromJSON(storageLayer); + + coreKit.tkey = await TKeyTSS.fromJSON(tkey, { + serviceProvider: coreKit.torusSp, + storageLayer: coreKit.storageLayer, + enableLogging: options.enableLogging, + tssKeyType: options.tssLib.keyType as KeyType, + }); + await coreKit.tkey.reconstructKey(); + + if (state.factorKey) state.factorKey = new BN(state.factorKey, "hex"); + if (state.tssPubKey) state.tssPubKey = Buffer.from(state.tssPubKey, "hex"); + coreKit.state = state; + coreKit.sessionManager.sessionId = sessionId; + coreKit.atomicCallStackCounter = atomicCallStackCounter; + coreKit.ready = ready; + + if (coreKit._keyType !== keyType) { + throw CoreKitError.invalidConfig(); + } + + // will be derived from option during constructor + // sessionManager + // enableLogging + // private _tssLib: TssLibType; + // private wasmLib: DKLSWasmLib | FrostWasmLib; + // private _keyType: KeyType; + return coreKit; + } + + public toJSON(): StringifiedType { + const factorKey = this.state.factorKey ? this.state.factorKey.toString("hex") : undefined; + const tssPubKey = this.state.tssPubKey ? this.state.tssPubKey.toString("hex") : undefined; + return { + state: { ...this.state, factorKey, tssPubKey }, + options: this.options, + serviceProvider: this.torusSp.toJSON(), + storageLayer: this.storageLayer.toJSON(), + tkey: this.tKey.toJSON(), + keyType: this.keyType, + sessionId: this.sessionManager.sessionId, + atomicCallStackCounter: this.atomicCallStackCounter, + ready: this.ready, + }; + } + // RecoverTssKey only valid for user that enable MFA where user has 2 type shares : // TssShareType.DEVICE and TssShareType.RECOVERY // if the factors key provided is the same type recovery will not works @@ -256,16 +308,11 @@ export class Web3AuthMPCCoreKit implements ICoreKit { enableLogging: this.enableLogging, }); - const shareSerializationModule = new ShareSerializationModule(); - this.tkey = new TKeyTSS({ enableLogging: this.enableLogging, serviceProvider: this.torusSp, storageLayer: this.storageLayer, manualSync: this.options.manualSync, - modules: { - shareSerialization: shareSerializationModule, - }, tssKeyType: this.keyType, }); @@ -473,19 +520,20 @@ export class Web3AuthMPCCoreKit implements ICoreKit { } } - public async inputFactorKey(factorKey: BN): Promise { + public async inputFactorKey(factorKey: BNString): Promise { + const factorKeyBN = new BN(factorKey, "hex"); this.checkReady(); try { // input tkey device share when required share > 0 ( or not reconstructed ) // assumption tkey shares will not changed if (!this.tKey.secp256k1Key) { - const factorKeyMetadata = await this.getFactorKeyMetadata(factorKey); + const factorKeyMetadata = await this.getFactorKeyMetadata(factorKeyBN); await this.tKey.inputShareStoreSafe(factorKeyMetadata, true); } // Finalize initialization. await this.tKey.reconstructKey(); - await this.finalizeTkey(factorKey); + await this.finalizeTkey(factorKeyBN); } catch (err: unknown) { log.error("login error", err); if (err instanceof CoreError) { @@ -590,6 +638,9 @@ export class Web3AuthMPCCoreKit implements ICoreKit { const { shareType } = createFactorParams; let { factorKey, shareDescription, additionalMetadata } = createFactorParams; + if (typeof factorKey === "string") { + factorKey = new BN(factorKey, "hex"); + } if (!VALID_SHARE_INDICES.includes(shareType)) { throw CoreKitError.newShareIndexInvalid(`Invalid share type provided (${shareType}). Valid share types are ${VALID_SHARE_INDICES}.`); @@ -938,6 +989,19 @@ export class Web3AuthMPCCoreKit implements ICoreKit { this.state = { ...this.state, ...newState }; } + public getGeneralStoreDomain(domain: string): T { + return this.tkey.metadata.getGeneralStoreDomain(domain) as T; + } + + public setGeneralStoreDomain(domain: string, value: T): void { + // should we add check for root flag before allow to mutate metadata? + this.tkey.metadata.setGeneralStoreDomain(domain, value); + } + + public getmetadataKey(): string | undefined { + return this.tkey?.secp256k1Key.toString(16); + } + protected async atomicSync(f: () => Promise): Promise { this.atomicCallStackCounter += 1; diff --git a/src/utils.ts b/src/utils.ts index 16139d1e..e2ff6627 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,8 +2,8 @@ import { KeyType, Point, Point as TkeyPoint, secp256k1 } from "@tkey/common-type import { generatePrivateBN } from "@tkey/core"; import { factorKeyCurve } from "@tkey/tss"; import { EllipticCurve } from "@toruslabs/elliptic-wrapper"; -import { safeatob } from "@toruslabs/openlogin-utils"; import { keccak256 } from "@toruslabs/torus.js"; +import { safeatob } from "@web3auth/auth"; import BN from "bn.js"; import { eddsa as EDDSA } from "elliptic"; import loglevel from "loglevel"; diff --git a/tests/ed25519.spec.ts b/tests/ed25519.spec.ts index 208beb5a..d9b723e0 100644 --- a/tests/ed25519.spec.ts +++ b/tests/ed25519.spec.ts @@ -144,6 +144,7 @@ variable.forEach((testVariable) => { const msgBuffer = Buffer.from(msg); const signature = ed25519().makeSignature((await coreKitInstance.sign(msgBuffer)).toString("hex")); + msgBuffer.slice(1,2); const valid = ed25519().verify(msgBuffer, signature, coreKitInstance.getPubKeyEd25519()); assert(valid); }); diff --git a/tests/serialize.spec.ts b/tests/serialize.spec.ts new file mode 100644 index 00000000..3e55083f --- /dev/null +++ b/tests/serialize.spec.ts @@ -0,0 +1,24 @@ +import { describe, it } from "node:test"; +import { defaultTestOptions, newCoreKitLogInInstance } from "./setup"; +import { AsyncStorage, MemoryStorage, WEB3AUTH_NETWORK, Web3AuthMPCCoreKit } from "src"; +import { deepEqual, deepStrictEqual, equal, strictEqual } from "node:assert"; + + +describe('serialize deserialze mpc corekit', () => { + it('serialize', async () => { + const localMemoryStorage = new MemoryStorage(); + const instance = await newCoreKitLogInInstance({ + network: WEB3AUTH_NETWORK.DEVNET, + manualSync: true, + email: "a@b.com", + storageInstance: localMemoryStorage, + }) + const options = defaultTestOptions({ network: WEB3AUTH_NETWORK.DEVNET, manualSync: true, storageInstance: localMemoryStorage }); + const serialized = JSON.stringify(instance); + console.log(serialized) + const deserialized = await Web3AuthMPCCoreKit.fromJSON(JSON.parse(serialized), options); + + + + }); +}); diff --git a/tests/setup.ts b/tests/setup.ts index ed768178..ed97b602 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -4,7 +4,7 @@ import BN from "bn.js"; import jwt, { Algorithm } from "jsonwebtoken"; import { tssLib as tssLibDKLS } from "@toruslabs/tss-dkls-lib"; -import { IAsyncStorage, IStorage, parseToken, TssLib, WEB3AUTH_NETWORK_TYPE, Web3AuthMPCCoreKit } from "../src"; +import { IAsyncStorage, IStorage, parseToken, TssLibType, WEB3AUTH_NETWORK_TYPE, Web3AuthMPCCoreKit, Web3AuthOptions } from "../src"; export const mockLogin2 = async (email: string) => { const req = new Request("https://li6lnimoyrwgn2iuqtgdwlrwvq0upwtr.lambda-url.eu-west-1.on.aws/", { @@ -84,6 +84,23 @@ export const mockLogin = async (email?: string) => { }; export type LoginFunc = (email: string) => Promise<{ idToken: string, parsedToken: any }>; +export const defaultTestOptions = (params: { + network: WEB3AUTH_NETWORK_TYPE; + manualSync: boolean; + storageInstance: IStorage | IAsyncStorage; + tssLib?: TssLibType; +}) : Web3AuthOptions => { + const { network, manualSync, storageInstance, tssLib } = params; + return { + web3AuthClientId: "torus-key-test", + web3AuthNetwork: network, + baseUrl: "http://localhost:3000", + uxMode: "nodejs", + tssLib: tssLib || tssLibDKLS, + storage: storageInstance, + manualSync, + } +} export const newCoreKitLogInInstance = async ({ network, @@ -97,7 +114,7 @@ export const newCoreKitLogInInstance = async ({ manualSync: boolean; email: string; storageInstance: IStorage | IAsyncStorage; - tssLib?: TssLib; + tssLib?: TssLibType; importTssKey?: string; login?: LoginFunc; }) => {