From 39b001d4186769c2434e9567bba72ca12a2df820 Mon Sep 17 00:00:00 2001 From: hieu-w Date: Mon, 2 Sep 2024 23:19:43 +0700 Subject: [PATCH 1/2] Vue Demo: update deps, make passkeys zero weight in validation --- examples/vue-example/package-lock.json | 52 +++++++++++++------------- examples/vue-example/src/App.vue | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/vue-example/package-lock.json b/examples/vue-example/package-lock.json index 90ebb64f..df8f6dfe 100644 --- a/examples/vue-example/package-lock.json +++ b/examples/vue-example/package-lock.json @@ -45,17 +45,16 @@ } }, "../..": { - "version": "8.0.0", + "name": "@web3auth/auth", + "version": "9.3.0", "license": "MIT", "dependencies": { - "@ethereumjs/util": "^9.0.3", - "@metamask/rpc-errors": "^6.3.1", + "@ethereumjs/util": "^9.1.0", "@toruslabs/constants": "^14.0.0", - "@toruslabs/eccrypto": "^5.0.4", - "@toruslabs/ffjavascript": "^3.0.0", + "@toruslabs/ffjavascript": "^4.0.0", "@toruslabs/metadata-helpers": "^6.0.0", "@toruslabs/secure-pub-sub": "^1.0.0", - "@toruslabs/session-manager": "^1.0.0", + "@toruslabs/session-manager": "^2.0.0", "@toruslabs/starkware-crypto": "^4.0.0", "@toruslabs/tweetnacl-js": "^1.0.4", "base64url": "^3.0.1", @@ -63,28 +62,29 @@ "bn.js": "^5.2.1", "bowser": "^2.11.0", "color": "^4.2.3", - "elliptic": "^6.5.6", "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", - "ts-node": "^10.9.2" + "typed-emitter": "^2.1.0" }, "devDependencies": { "@babel/register": "^7.24.6", - "@babel/runtime": "^7.25.0", + "@babel/runtime": "^7.25.4", "@rollup/plugin-replace": "^5.0.7", - "@toruslabs/config": "^2.1.0", - "@toruslabs/eslint-config-typescript": "^3.3.1", - "@toruslabs/torus-scripts": "^6.0.1", + "@toruslabs/config": "^2.2.0", + "@toruslabs/eslint-config-typescript": "^3.3.3", + "@toruslabs/torus-scripts": "^6.1.2", "@types/color": "^3.0.6", "@types/elliptic": "^6.4.18", "@types/end-of-stream": "^1.4.4", + "@types/json-stable-stringify": "^1.0.36", "@types/mocha": "^10.0.7", "@types/node": "^20", "@types/once": "^1.4.4", @@ -92,17 +92,17 @@ "@types/readable-stream": "^4.0.15", "cross-env": "^7.0.3", "eslint": "^8.56.0", - "husky": "^9.1.4", - "jsdom": "^24.1.1", + "husky": "^9.1.5", + "jsdom": "^25.0.0", "jsdom-global": "^3.0.2", - "lint-staged": "^15.2.7", - "mocha": "^10.7.0", + "lint-staged": "^15.2.9", + "mocha": "^10.7.3", "prettier": "^3.3.3", "rimraf": "^6.0.1", "tsconfig-paths": "^4.2.0", "tsconfig-paths-webpack-plugin": "^4.1.0", - "tslib": "^2.6.3", - "tsx": "^4.16.2", + "tslib": "^2.7.0", + "tsx": "^4.19.0", "typescript": "^5.5.4" }, "engines": { @@ -110,8 +110,8 @@ "npm": ">=9.x" }, "optionalDependencies": { - "@nx/nx-linux-x64-gnu": "^19.5.3", - "@rollup/rollup-linux-x64-gnu": "^4.19.1" + "@nx/nx-linux-x64-gnu": "^19.6.3", + "@rollup/rollup-linux-x64-gnu": "^4.21.1" }, "peerDependencies": { "@babel/runtime": "7.x" @@ -3963,9 +3963,9 @@ "integrity": "sha512-orzA81VqLyIGUEA77YkVA1D+N+nNfl2isJVjjmOyrlxuooZ19ynb+dOlaDTqd/idKRS9lDCSBmtzM+kyCsMnkA==" }, "node_modules/elliptic": { - "version": "6.5.6", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.6.tgz", - "integrity": "sha512-mpzdtpeCLuS3BmE3pO3Cpp5bbjlOPY2Q0PgoF+Od1XZrHLYI28Xe3ossCmYCQt11FQKEYd9+PF8jymTvtWJSHQ==", + "version": "6.5.7", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", + "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", @@ -6528,9 +6528,9 @@ "integrity": "sha512-/0LLxhzP0tfiR5hcQebtudP56gUurs2CLkGarnCiB/OqEyUFQ6U3paQi/tgLv0hBJYt2rnr9MNpxz4fiiugstg==" }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" diff --git a/examples/vue-example/src/App.vue b/examples/vue-example/src/App.vue index 096a3006..d25e282e 100644 --- a/examples/vue-example/src/App.vue +++ b/examples/vue-example/src/App.vue @@ -640,7 +640,7 @@ const isValidForm = computed(() => { const isValidMFASelection = computed(() => { if (selectedMFAFactors.value?.length && !selectedMandatoryMFAFactors.value.length) return false; - if (selectedMandatoryMFAFactors.value.every((x) => x === MFA_FACTOR.DEVICE)) return false; + if (selectedMandatoryMFAFactors.value.every((x) => x === MFA_FACTOR.DEVICE || x === MFA_FACTOR.PASSKEYS )) return false; return true; }); From f0d65e5f577001369b781c425218ac42788a682b Mon Sep 17 00:00:00 2001 From: hieu-w Date: Mon, 2 Sep 2024 23:33:06 +0700 Subject: [PATCH 2/2] Vue demo: Refactoring foreach to reduce. --- examples/vue-example/src/App.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/vue-example/src/App.vue b/examples/vue-example/src/App.vue index d25e282e..4446f81a 100644 --- a/examples/vue-example/src/App.vue +++ b/examples/vue-example/src/App.vue @@ -626,12 +626,16 @@ const allMFAFactors = Object.values(MFA_FACTOR); const mfaSettings = computed(() => { if (!selectedMFAFactors.value?.length) return {}; - const mfaSettings: Record = {}; - allMFAFactors.forEach((factor) => { - mfaSettings[factor] = { enable: selectedMFAFactors.value.includes(factor), mandatory: selectedMandatoryMFAFactors.value.includes(factor) }; - }); - console.log("mfaSettings", mfaSettings); - return mfaSettings; + const newMfaSettings = allMFAFactors.reduce( + (acc, factor) => { + acc[factor] = { enable: selectedMFAFactors.value.includes(factor), mandatory: selectedMandatoryMFAFactors.value.includes(factor) }; + return acc; + }, + {} as Record + ); + + console.log("newMfaSettings", newMfaSettings); + return newMfaSettings; }); const isValidForm = computed(() => {