Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: webauthn support
Sheen Capadngan7fbea4d9931c
diff --git a/backend/package-lock.json b/backend/package-lock.jsonindex 9f359b2237..f698149c8f 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -55,6 +55,7 @@"@peculiar/x509": "^1.12.1","@react-email/components": "0.0.36","@serdnam/pino-cloudwatch-transport": "^1.0.4",+ "@simplewebauthn/server": "^13.2.2","@sindresorhus/slugify": "1.1.0","@slack/oauth": "^3.0.2","@slack/web-api": "^7.8.0",@@ -8622,6 +8623,12 @@"resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-2.1.0.tgz","integrity": "sha512-i1BpaNDVLJdRBEKeJWkVO6tYX6DMFBuwMhSuWqLsY4ufeTKGVuV5rBsUhxPayXqnnWHgXUAmWK16H/ykO5Wj4Q=="},+ "node_modules/@hexagon/base64": {+ "version": "1.1.28",+ "resolved": "https://registry.npmjs.org/@hexagon/base64/-/base64-1.1.28.tgz",+ "integrity": "sha512-lhqDEAvWixy3bZ+UOYbPwUbBkwBq5C1LAJ/xPC8Oi+lL54oyakv/npbA0aU2hgCsx/1NUd4IBvV03+aUBWxerw==",+ "license": "MIT"+ },"node_modules/@humanwhocodes/config-array": {"version": "0.11.13","resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz",@@ -9467,6 +9474,12 @@"resolved": "https://registry.npmjs.org/@ldapjs/protocol/-/protocol-1.2.1.tgz","integrity": "sha512-O89xFDLW2gBoZWNXuXpBSM32/KealKCTb3JGtJdtUQc7RjAk8XzrRgyz02cPAwGKwKPxy0ivuC7UP9bmN87egQ=="},+ "node_modules/@levischuck/tiny-cbor": {+ "version": "0.2.11",+ "resolved": "https://registry.npmjs.org/@levischuck/tiny-cbor/-/tiny-cbor-0.2.11.tgz",+ "integrity": "sha512-llBRm4dT4Z89aRsm6u2oEZ8tfwL/2l6BwpZ7JcyieouniDECM5AqNgr/y08zalEIvW3RSK4upYyybDcmjXqAow==",+ "license": "MIT"+ },"node_modules/@lottiefiles/dotlottie-react": {"version": "0.13.3","resolved": "https://registry.npmjs.org/@lottiefiles/dotlottie-react/-/dotlottie-react-0.13.3.tgz",@@ -11038,147 +11051,160 @@"@otplib/plugin-thirty-two": "^12.0.1"}},+ "node_modules/@peculiar/asn1-android": {+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-android/-/asn1-android-2.6.0.tgz",+ "integrity": "sha512-cBRCKtYPF7vJGN76/yG8VbxRcHLPF3HnkoHhKOZeHpoVtbMYfY9ROKtH3DtYUY9m8uI1Mh47PRhHf2hSK3xcSQ==",+ "license": "MIT",+ "dependencies": {+ "@peculiar/asn1-schema": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"+ }+ },"node_modules/@peculiar/asn1-cms": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.3.8.tgz",- "integrity": "sha512-Wtk9R7yQxGaIaawHorWKP2OOOm/RZzamOmSWwaqGphIuU6TcKYih0slL6asZlSSZtVoYTrBfrddSOD/jTu9vuQ==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.6.0.tgz",+ "integrity": "sha512-2uZqP+ggSncESeUF/9Su8rWqGclEfEiz1SyU02WX5fUONFfkjzS2Z/F1Li0ofSmf4JqYXIOdCAZqIXAIBAT1OA==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "@peculiar/asn1-x509-attr": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "@peculiar/asn1-x509-attr": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-csr": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.3.8.tgz",- "integrity": "sha512-ZmAaP2hfzgIGdMLcot8gHTykzoI+X/S53x1xoGbTmratETIaAbSWMiPGvZmXRA0SNEIydpMkzYtq4fQBxN1u1w==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.6.0.tgz",+ "integrity": "sha512-BeWIu5VpTIhfRysfEp73SGbwjjoLL/JWXhJ/9mo4vXnz3tRGm+NGm3KNcRzQ9VMVqwYS2RHlolz21svzRXIHPQ==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-ecc": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.3.8.tgz",- "integrity": "sha512-Ah/Q15y3A/CtxbPibiLM/LKcMbnLTdUdLHUgdpB5f60sSvGkXzxJCu5ezGTFHogZXWNX3KSmYqilCrfdmBc6pQ==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.6.0.tgz",+ "integrity": "sha512-FF3LMGq6SfAOwUG2sKpPXblibn6XnEIKa+SryvUl5Pik+WR9rmRA3OCiwz8R3lVXnYnyRkSZsSLdml8H3UiOcw==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-pfx": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.3.8.tgz",- "integrity": "sha512-XhdnCVznMmSmgy68B9pVxiZ1XkKoE1BjO4Hv+eUGiY1pM14msLsFZ3N7K46SoITIVZLq92kKkXpGiTfRjlNLyg==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.6.0.tgz",+ "integrity": "sha512-rtUvtf+tyKGgokHHmZzeUojRZJYPxoD/jaN1+VAB4kKR7tXrnDCA/RAWXAIhMJJC+7W27IIRGe9djvxKgsldCQ==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-cms": "^2.3.8",- "@peculiar/asn1-pkcs8": "^2.3.8",- "@peculiar/asn1-rsa": "^2.3.8",- "@peculiar/asn1-schema": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-cms": "^2.6.0",+ "@peculiar/asn1-pkcs8": "^2.6.0",+ "@peculiar/asn1-rsa": "^2.6.0",+ "@peculiar/asn1-schema": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-pkcs8": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.3.8.tgz",- "integrity": "sha512-rL8k2x59v8lZiwLRqdMMmOJ30GHt6yuHISFIuuWivWjAJjnxzZBVzMTQ72sknX5MeTSSvGwPmEFk2/N8+UztFQ==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.6.0.tgz",+ "integrity": "sha512-KyQ4D8G/NrS7Fw3XCJrngxmjwO/3htnA0lL9gDICvEQ+GJ+EPFqldcJQTwPIdvx98Tua+WjkdKHSC0/Km7T+lA==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-pkcs9": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.3.8.tgz",- "integrity": "sha512-+nONq5tcK7vm3qdY7ZKoSQGQjhJYMJbwJGbXLFOhmqsFIxEWyQPHyV99+wshOjpOjg0wUSSkEEzX2hx5P6EKeQ==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.6.0.tgz",+ "integrity": "sha512-b78OQ6OciW0aqZxdzliXGYHASeCvvw5caqidbpQRYW2mBtXIX2WhofNXTEe7NyxTb0P6J62kAAWLwn0HuMF1Fw==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-cms": "^2.3.8",- "@peculiar/asn1-pfx": "^2.3.8",- "@peculiar/asn1-pkcs8": "^2.3.8",- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "@peculiar/asn1-x509-attr": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-cms": "^2.6.0",+ "@peculiar/asn1-pfx": "^2.6.0",+ "@peculiar/asn1-pkcs8": "^2.6.0",+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "@peculiar/asn1-x509-attr": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-rsa": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.3.8.tgz",- "integrity": "sha512-ES/RVEHu8VMYXgrg3gjb1m/XG0KJWnV4qyZZ7mAg7rrF3VTmRbLxO8mk+uy0Hme7geSMebp+Wvi2U6RLLEs12Q==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.6.0.tgz",+ "integrity": "sha512-Nu4C19tsrTsCp9fDrH+sdcOKoVfdfoQQ7S3VqjJU6vedR7tY3RLkQ5oguOIB3zFW33USDUuYZnPEQYySlgha4w==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-schema": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.3.8.tgz",- "integrity": "sha512-ULB1XqHKx1WBU/tTFIA+uARuRoBVZ4pNdOA878RDrRbBfBGcSzi5HBkdScC6ZbHn8z7L8gmKCgPC1LHRrP46tA==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.6.0.tgz",+ "integrity": "sha512-xNLYLBFTBKkCzEZIw842BxytQQATQv+lDTCEMZ8C196iJcJJMBUZxrhSTxLaohMyKK8QlzRNTRkUmanucnDSqg==",+ "license": "MIT","dependencies": {- "asn1js": "^3.0.5",- "pvtsutils": "^1.3.5",- "tslib": "^2.6.2"+ "asn1js": "^3.0.6",+ "pvtsutils": "^1.3.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-x509": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.3.8.tgz",- "integrity": "sha512-voKxGfDU1c6r9mKiN5ZUsZWh3Dy1BABvTM3cimf0tztNwyMJPhiXY94eRTgsMQe6ViLfT6EoXxkWVzcm3mFAFw==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.6.0.tgz",+ "integrity": "sha512-uzYbPEpoQiBoTq0/+jZtpM6Gq6zADBx+JNFP3yqRgziWBxQ/Dt/HcuvRfm9zJTPdRcBqPNdaRHTVwpyiq6iNMA==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-schema": "^2.3.8",- "asn1js": "^3.0.5",- "ipaddr.js": "^2.1.0",- "pvtsutils": "^1.3.5",- "tslib": "^2.6.2"+ "@peculiar/asn1-schema": "^2.6.0",+ "asn1js": "^3.0.6",+ "pvtsutils": "^1.3.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/asn1-x509-attr": {- "version": "2.3.8",- "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.3.8.tgz",- "integrity": "sha512-4Z8mSN95MOuX04Aku9BUyMdsMKtVQUqWnr627IheiWnwFoheUhX3R4Y2zh23M7m80r4/WG8MOAckRKc77IRv6g==",+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.6.0.tgz",+ "integrity": "sha512-MuIAXFX3/dc8gmoZBkwJWxUWOSvG4MMDntXhrOZpJVMkYX+MYc/rUAU2uJOved9iJEoiUx7//3D8oG83a78UJA==",+ "license": "MIT","dependencies": {- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "asn1js": "^3.0.5",- "tslib": "^2.6.2"- }- },- "node_modules/@peculiar/asn1-x509/node_modules/ipaddr.js": {- "version": "2.2.0",- "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz",- "integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==",- "engines": {- "node": ">= 10"+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "asn1js": "^3.0.6",+ "tslib": "^2.8.1"}},"node_modules/@peculiar/x509": {- "version": "1.12.1",- "resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-1.12.1.tgz",- "integrity": "sha512-2T9t2viNP9m20mky50igPTpn2ByhHl5NlT6wW4Tp4BejQaQ5XDNZgfsabYwYysLXhChABlgtTCpp2gM3JBZRKA==",- "dependencies": {- "@peculiar/asn1-cms": "^2.3.8",- "@peculiar/asn1-csr": "^2.3.8",- "@peculiar/asn1-ecc": "^2.3.8",- "@peculiar/asn1-pkcs9": "^2.3.8",- "@peculiar/asn1-rsa": "^2.3.8",- "@peculiar/asn1-schema": "^2.3.8",- "@peculiar/asn1-x509": "^2.3.8",- "pvtsutils": "^1.3.5",+ "version": "1.14.0",+ "resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-1.14.0.tgz",+ "integrity": "sha512-Yc4PDxN3OrxUPiXgU63c+ZRXKGE8YKF2McTciYhUHFtHVB0KMnjeFSU0qpztGhsp4P0uKix4+J2xEpIEDu8oXg==",+ "license": "MIT",+ "dependencies": {+ "@peculiar/asn1-cms": "^2.5.0",+ "@peculiar/asn1-csr": "^2.5.0",+ "@peculiar/asn1-ecc": "^2.5.0",+ "@peculiar/asn1-pkcs9": "^2.5.0",+ "@peculiar/asn1-rsa": "^2.5.0",+ "@peculiar/asn1-schema": "^2.5.0",+ "@peculiar/asn1-x509": "^2.5.0",+ "pvtsutils": "^1.3.6","reflect-metadata": "^0.2.2",- "tslib": "^2.6.2",- "tsyringe": "^4.8.0"+ "tslib": "^2.8.1",+ "tsyringe": "^4.10.0"}},"node_modules/@phc/format": {@@ -13681,6 +13707,25 @@"split2": "^4.0.0"}},+ "node_modules/@simplewebauthn/server": {+ "version": "13.2.2",+ "resolved": "https://registry.npmjs.org/@simplewebauthn/server/-/server-13.2.2.tgz",+ "integrity": "sha512-HcWLW28yTMGXpwE9VLx9J+N2KEUaELadLrkPEEI9tpI5la70xNEVEsu/C+m3u7uoq4FulLqZQhgBCzR9IZhFpA==",+ "license": "MIT",+ "dependencies": {+ "@hexagon/base64": "^1.1.27",+ "@levischuck/tiny-cbor": "^0.2.2",+ "@peculiar/asn1-android": "^2.3.10",+ "@peculiar/asn1-ecc": "^2.3.8",+ "@peculiar/asn1-rsa": "^2.3.8",+ "@peculiar/asn1-schema": "^2.3.8",+ "@peculiar/asn1-x509": "^2.3.8",+ "@peculiar/x509": "^1.13.0"+ },+ "engines": {+ "node": ">=20.0.0"+ }+ },"node_modules/@sindresorhus/slugify": {"version": "1.1.0","resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-1.1.0.tgz",@@ -17154,13 +17199,14 @@}},"node_modules/asn1js": {- "version": "3.0.5",- "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.5.tgz",- "integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==",+ "version": "3.0.6",+ "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.6.tgz",+ "integrity": "sha512-UOCGPYbl0tv8+006qks/dTgV9ajs97X2p0FAbyS2iyCRrmLSRolDaHdp+v/CLgnzHc3fVB+CwYiUmei7ndFcgA==",+ "license": "BSD-3-Clause","dependencies": {- "pvtsutils": "^1.3.2",+ "pvtsutils": "^1.3.6","pvutils": "^1.1.3",- "tslib": "^2.4.0"+ "tslib": "^2.8.1"},"engines": {"node": ">=12.0.0"@@ -29231,11 +29277,12 @@}},"node_modules/pvtsutils": {- "version": "1.3.5",- "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.5.tgz",- "integrity": "sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==",+ "version": "1.3.6",+ "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz",+ "integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==",+ "license": "MIT","dependencies": {- "tslib": "^2.6.1"+ "tslib": "^2.8.1"}},"node_modules/pvutils": {@@ -33014,9 +33061,10 @@}},"node_modules/tsyringe": {- "version": "4.8.0",- "resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.8.0.tgz",- "integrity": "sha512-YB1FG+axdxADa3ncEtRnQCFq/M0lALGLxSZeVNbTU8NqhOVc51nnv2CISTcvc1kyv6EGPtXVr0v6lWeDxiijOA==",+ "version": "4.10.0",+ "resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.10.0.tgz",+ "integrity": "sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==",+ "license": "MIT","dependencies": {"tslib": "^1.9.3"},@@ -33027,7 +33075,8 @@"node_modules/tsyringe/node_modules/tslib": {"version": "1.14.1","resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",- "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",+ "license": "0BSD"},"node_modules/ttl-set": {"version": "1.0.0",diff --git a/backend/package.json b/backend/package.jsonindex 2db395e902..dd49d2dde7 100644--- a/backend/package.json+++ b/backend/package.json@@ -184,6 +184,7 @@"@peculiar/x509": "^1.12.1","@react-email/components": "0.0.36","@serdnam/pino-cloudwatch-transport": "^1.0.4",+ "@simplewebauthn/server": "^13.2.2","@sindresorhus/slugify": "1.1.0","@slack/oauth": "^3.0.2","@slack/web-api": "^7.8.0",diff --git a/backend/src/@types/fastify.d.ts b/backend/src/@types/fastify.d.tsindex d511187d07..c1e346339f 100644--- a/backend/src/@types/fastify.d.ts+++ b/backend/src/@types/fastify.d.ts@@ -130,6 +130,7 @@ import { TTotpServiceFactory } from "@app/services/totp/totp-service";import { TUpgradePathService } from "@app/services/upgrade-path/upgrade-path-service";import { TUserDALFactory } from "@app/services/user/user-dal";import { TUserServiceFactory } from "@app/services/user/user-service";+import { TWebAuthnServiceFactory } from "@app/services/webauthn/webauthn-service";import { TUserEngagementServiceFactory } from "@app/services/user-engagement/user-engagement-service";import { TWebhookServiceFactory } from "@app/services/webhook/webhook-service";import { TWorkflowIntegrationServiceFactory } from "@app/services/workflow-integration/workflow-integration-service";@@ -321,6 +322,7 @@ declare module "fastify" {externalGroupOrgRoleMapping: TExternalGroupOrgRoleMappingServiceFactory;projectTemplate: TProjectTemplateServiceFactory;totp: TTotpServiceFactory;+ webAuthn: TWebAuthnServiceFactory;appConnection: TAppConnectionServiceFactory;secretSync: TSecretSyncServiceFactory;kmip: TKmipServiceFactory;diff --git a/backend/src/@types/knex.d.ts b/backend/src/@types/knex.d.tsindex 603df5f6ca..81c4e2994e 100644--- a/backend/src/@types/knex.d.ts+++ b/backend/src/@types/knex.d.ts@@ -571,7 +571,10 @@ import {TWebhooksUpdate,TWorkflowIntegrations,TWorkflowIntegrationsInsert,- TWorkflowIntegrationsUpdate+ TWorkflowIntegrationsUpdate,+ TWebauthnCredentials,+ TWebauthnCredentialsInsert,+ TWebauthnCredentialsUpdate} from "@app/db/schemas";import {TAccessApprovalPoliciesEnvironments,@@ -1465,5 +1468,10 @@ declare module "knex/types/tables" {TVaultExternalMigrationConfigsInsert,TVaultExternalMigrationConfigsUpdate>;+ [TableName.WebAuthnCredential]: KnexOriginal.CompositeTableType<+ TWebauthnCredentials,+ TWebauthnCredentialsInsert,+ TWebauthnCredentialsUpdate+ >;}}diff --git a/backend/src/db/migrations/20250601000000_add-webauthn-support.ts b/backend/src/db/migrations/20250601000000_add-webauthn-support.tsnew file mode 100644index 0000000000..419a6fc4e6--- /dev/null+++ b/backend/src/db/migrations/20250601000000_add-webauthn-support.ts@@ -0,0 +1,30 @@+import { Knex } from "knex";++import { TableName } from "../schemas";+import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";++export async function up(knex: Knex): Promise<void> {+ if (!(await knex.schema.hasTable(TableName.WebAuthnCredential))) {+ await knex.schema.createTable(TableName.WebAuthnCredential, (t) => {+ t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());+ t.uuid("userId").notNullable();+ t.foreign("userId").references("id").inTable(TableName.Users).onDelete("CASCADE");+ t.text("credentialId").notNullable(); // base64url encoded credential ID+ t.text("publicKey").notNullable(); // base64url encoded public key+ t.bigInteger("counter").defaultTo(0).notNullable(); // signature counter for replay protection+ t.specificType("transports", "text[]").nullable(); // transport methods+ t.string("name").nullable(); // user-friendly name+ t.timestamp("lastUsedAt").nullable();+ t.timestamps(true, true, true);+ t.unique("credentialId"); // credential IDs must be unique across all users+ t.index("userId"); // index for fast lookups by user+ });++ await createOnUpdateTrigger(knex, TableName.WebAuthnCredential);+ }+}++export async function down(knex: Knex): Promise<void> {+ await dropOnUpdateTrigger(knex, TableName.WebAuthnCredential);+ await knex.schema.dropTableIfExists(TableName.WebAuthnCredential);+}diff --git a/backend/src/db/schemas/index.ts b/backend/src/db/schemas/index.tsindex 78dcb1980c..859c03607f 100644--- a/backend/src/db/schemas/index.ts+++ b/backend/src/db/schemas/index.ts@@ -194,3 +194,4 @@ export * from "./users";export * from "./vault-external-migration-configs";export * from "./webhooks";export * from "./workflow-integrations";+export * from "./webauthn-credentials";diff --git a/backend/src/db/schemas/models.ts b/backend/src/db/schemas/models.tsindex 444a6bd97d..f73bfaebcd 100644--- a/backend/src/db/schemas/models.ts+++ b/backend/src/db/schemas/models.ts@@ -158,6 +158,7 @@ export enum TableName {InternalKms = "internal_kms",InternalKmsKeyVersion = "internal_kms_key_version",TotpConfig = "totp_configs",+ WebAuthnCredential = "webauthn_credentials",// @depreciatedKmsKeyVersion = "kms_key_versions",WorkflowIntegrations = "workflow_integrations",diff --git a/backend/src/db/schemas/webauthn-credentials.ts b/backend/src/db/schemas/webauthn-credentials.tsnew file mode 100644index 0000000000..d0b8bf64a8--- /dev/null+++ b/backend/src/db/schemas/webauthn-credentials.ts@@ -0,0 +1,25 @@+// Code generated by automation script, DO NOT EDIT.+// Automated by pulling database and generating zod schema+// To update. Just run npm run generate:schema+// Written by akhilmhdh.++import { z } from "zod";++import { TImmutableDBKeys } from "./models";++export const WebauthnCredentialsSchema = z.object({+ id: z.string().uuid(),+ userId: z.string().uuid(),+ credentialId: z.string(),+ publicKey: z.string(),+ counter: z.coerce.number().default(0),+ transports: z.string().array().nullable().optional(),+ name: z.string().nullable().optional(),+ lastUsedAt: z.date().nullable().optional(),+ createdAt: z.date(),+ updatedAt: z.date()+});++export type TWebauthnCredentials = z.infer<typeof WebauthnCredentialsSchema>;+export type TWebauthnCredentialsInsert = Omit<z.input<typeof WebauthnCredentialsSchema>, TImmutableDBKeys>;+export type TWebauthnCredentialsUpdate = Partial<Omit<z.input<typeof WebauthnCredentialsSchema>, TImmutableDBKeys>>;diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 7c2e3b326c..3a00664532 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -351,6 +351,8 @@ import { telemetryServiceFactory } from "@app/services/telemetry/telemetry-serviimport { totpConfigDALFactory } from "@app/services/totp/totp-config-dal";import { totpServiceFactory } from "@app/services/totp/totp-service";import { upgradePathServiceFactory } from "@app/services/upgrade-path/upgrade-path-service";+import { webAuthnCredentialDALFactory } from "@app/services/webauthn/webauthn-credential-dal";+import { webAuthnServiceFactory } from "@app/services/webauthn/webauthn-service";import { userDALFactory } from "@app/services/user/user-dal";import { userServiceFactory } from "@app/services/user/user-service";import { userAliasDALFactory } from "@app/services/user-alias/user-alias-dal";@@ -532,6 +534,7 @@ export const registerRoutes = async (const projectSlackConfigDAL = projectSlackConfigDALFactory(db);const workflowIntegrationDAL = workflowIntegrationDALFactory(db);const totpConfigDAL = totpConfigDALFactory(db);+ const webAuthnCredentialDAL = webAuthnCredentialDALFactory(db);const externalGroupOrgRoleMappingDAL = externalGroupOrgRoleMappingDALFactory(db);@@ -872,6 +875,12 @@ export const registerRoutes = async (kmsService});+ const webAuthnService = webAuthnServiceFactory({+ webAuthnCredentialDAL,+ userDAL,+ tokenService+ });+const loginService = authLoginServiceFactory({userDAL,smtpService,@@ -2523,6 +2532,7 @@ export const registerRoutes = async (externalGroupOrgRoleMapping: externalGroupOrgRoleMappingService,projectTemplate: projectTemplateService,totp: totpService,+ webAuthn: webAuthnService,appConnection: appConnectionService,secretSync: secretSyncService,kmip: kmipService,diff --git a/backend/src/server/routes/v1/user-router.ts b/backend/src/server/routes/v1/user-router.tsindex 40fbcf5a2b..9be6cbe4d2 100644--- a/backend/src/server/routes/v1/user-router.ts+++ b/backend/src/server/routes/v1/user-router.ts@@ -1,3 +1,4 @@+import type { AuthenticationResponseJSON, RegistrationResponseJSON } from "@simplewebauthn/server";import { z } from "zod";import { UsersSchema } from "@app/db/schemas";@@ -284,4 +285,217 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {});}});++ // WebAuthn/Passkey Routes+ server.route({+ method: "GET",+ url: "/me/webauthn",+ config: {+ rateLimit: readLimit+ },+ schema: {+ response: {+ 200: z.object({+ credentials: z.array(+ z.object({+ id: z.string(),+ credentialId: z.string(),+ name: z.string().nullable().optional(),+ transports: z.array(z.string()).nullable().optional(),+ createdAt: z.date(),+ lastUsedAt: z.date().nullable().optional()+ })+ )+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT]),+ handler: async (req) => {+ const credentials = await server.services.webAuthn.getUserWebAuthnCredentials({+ userId: req.permission.id+ });+ return { credentials };+ }+ });++ server.route({+ method: "POST",+ url: "/me/webauthn/register",+ config: {+ rateLimit: writeLimit+ },+ schema: {+ response: {+ 200: z.any() // Returns PublicKeyCredentialCreationOptionsJSON from @simplewebauthn/server+ }+ },+ onRequest: verifyAuth([AuthMode.JWT], {+ requireOrg: false+ }),+ handler: async (req) => {+ return server.services.webAuthn.generateRegistrationOptions({+ userId: req.permission.id+ });+ }+ });++ server.route({+ method: "POST",+ url: "/me/webauthn/register/verify",+ config: {+ rateLimit: writeLimit+ },+ schema: {+ body: z.object({+ registrationResponse: z+ .object({+ id: z.string(),+ rawId: z.string(),+ response: z+ .object({+ clientDataJSON: z.string(),+ attestationObject: z.string()+ })+ .passthrough(),+ clientExtensionResults: z.record(z.unknown()).optional(),+ type: z.literal("public-key")+ })+ .passthrough(),+ name: z.string().optional()+ }),+ response: {+ 200: z.object({+ credentialId: z.string(),+ name: z.string().nullable().optional()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT], {+ requireOrg: false+ }),+ handler: async (req) => {+ return server.services.webAuthn.verifyRegistrationResponse({+ userId: req.permission.id,+ registrationResponse: req.body.registrationResponse as unknown as RegistrationResponseJSON,+ name: req.body.name+ });+ }+ });++ server.route({+ method: "POST",+ url: "/me/webauthn/authenticate",+ config: {+ rateLimit: readLimit+ },+ schema: {+ response: {+ 200: z.any() // Returns PublicKeyCredentialRequestOptionsJSON from @simplewebauthn/server+ }+ },+ onRequest: verifyAuth([AuthMode.JWT], { requireOrg: false }),+ handler: async (req) => {+ return server.services.webAuthn.generateAuthenticationOptions({+ userId: req.permission.id+ });+ }+ });++ server.route({+ method: "POST",+ url: "/me/webauthn/authenticate/verify",+ config: {+ rateLimit: writeLimit+ },+ schema: {+ body: z.object({+ authenticationResponse: z+ .object({+ id: z.string(),+ rawId: z.string(),+ response: z+ .object({+ clientDataJSON: z.string(),+ authenticatorData: z.string(),+ signature: z.string()+ })+ .passthrough(),+ clientExtensionResults: z.record(z.unknown()).optional(),+ type: z.literal("public-key")+ })+ .passthrough()+ }),+ response: {+ 200: z.object({+ verified: z.boolean(),+ credentialId: z.string(),+ sessionToken: z.string()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT], { requireOrg: false }),+ handler: async (req) => {+ return server.services.webAuthn.verifyAuthenticationResponse({+ userId: req.permission.id,+ authenticationResponse: req.body.authenticationResponse as unknown as AuthenticationResponseJSON+ });+ }+ });++ server.route({+ method: "PATCH",+ url: "/me/webauthn/:credentialId",+ config: {+ rateLimit: writeLimit+ },+ schema: {+ params: z.object({+ credentialId: z.string()+ }),+ body: z.object({+ name: z.string().optional()+ }),+ response: {+ 200: z.object({+ id: z.string(),+ credentialId: z.string(),+ name: z.string().nullable().optional()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT]),+ handler: async (req) => {+ return server.services.webAuthn.updateWebAuthnCredential({+ userId: req.permission.id,+ credentialId: req.params.credentialId,+ name: req.body.name+ });+ }+ });++ server.route({+ method: "DELETE",+ url: "/me/webauthn/:credentialId",+ config: {+ rateLimit: writeLimit+ },+ schema: {+ params: z.object({+ credentialId: z.string()+ }),+ response: {+ 200: z.object({+ success: z.boolean()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT]),+ handler: async (req) => {+ await server.services.webAuthn.deleteWebAuthnCredential({+ userId: req.permission.id,+ credentialId: req.params.credentialId+ });+ return { success: true };+ }+ });};diff --git a/backend/src/server/routes/v2/mfa-router.ts b/backend/src/server/routes/v2/mfa-router.tsindex e8c2cea693..d897b517ae 100644--- a/backend/src/server/routes/v2/mfa-router.ts+++ b/backend/src/server/routes/v2/mfa-router.ts@@ -186,4 +186,37 @@ export const registerMfaRouter = async (server: FastifyZodProvider) => {return handleMfaVerification(req, res, server, req.body.recoveryCode, MfaMethod.TOTP, true);}});++ // WebAuthn MFA routes+ server.route({+ method: "GET",+ url: "/mfa/check/webauthn",+ config: {+ rateLimit: mfaRateLimit+ },+ schema: {+ response: {+ 200: z.object({+ hasPasskeys: z.boolean()+ })+ }+ },+ handler: async (req) => {+ try {+ const credentials = await server.services.webAuthn.getUserWebAuthnCredentials({+ userId: req.mfa.userId+ });++ return {+ hasPasskeys: credentials.length > 0+ };+ } catch (error) {+ if (error instanceof NotFoundError) {+ return { hasPasskeys: false };+ }++ throw error;+ }+ }+ });};diff --git a/backend/src/services/auth-token/auth-token-service.ts b/backend/src/services/auth-token/auth-token-service.tsindex fb7213109e..e63a7a86c3 100644--- a/backend/src/services/auth-token/auth-token-service.ts+++ b/backend/src/services/auth-token/auth-token-service.ts@@ -74,6 +74,13 @@ export const getTokenConfig = (tokenType: TokenType) => {const expiresAt = new Date(new Date().getTime() + 259200000);return { token, expiresAt };}+ case TokenType.TOKEN_WEBAUTHN_SESSION: {+ // generate random hex token for WebAuthn session+ const token = crypto.randomBytes(32).toString("hex");+ const triesLeft = 1;+ const expiresAt = new Date(new Date().getTime() + 60000); // 60 seconds+ return { token, triesLeft, expiresAt };+ }default: {const token = crypto.randomBytes(16).toString("hex");const expiresAt = new Date();diff --git a/backend/src/services/auth-token/auth-token-types.ts b/backend/src/services/auth-token/auth-token-types.tsindex 3255fbbbc6..0c1d715f84 100644--- a/backend/src/services/auth-token/auth-token-types.ts+++ b/backend/src/services/auth-token/auth-token-types.ts@@ -8,7 +8,8 @@ export enum TokenType {TOKEN_EMAIL_ORG_INVITATION = "organizationInvitation",TOKEN_EMAIL_PASSWORD_RESET = "passwordReset",TOKEN_EMAIL_PASSWORD_SETUP = "passwordSetup",- TOKEN_USER_UNLOCK = "userUnlock"+ TOKEN_USER_UNLOCK = "userUnlock",+ TOKEN_WEBAUTHN_SESSION = "webauthnSession"}export type TCreateTokenForUserDTO = {diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.tsindex b9c7597030..b0e0f41e7d 100644--- a/backend/src/services/auth/auth-login-service.ts+++ b/backend/src/services/auth/auth-login-service.ts@@ -757,6 +757,18 @@ export const authLoginServiceFactory = ({totp: mfaToken});}+ } else if (mfaMethod === MfaMethod.WEBAUTHN) {+ if (!mfaToken) {+ throw new BadRequestError({+ message: "WebAuthn session token is required"+ });+ }+ // Validate the one-time WebAuthn session token (passed as mfaToken)+ await tokenService.validateTokenForUser({+ type: TokenType.TOKEN_WEBAUTHN_SESSION,+ userId,+ code: mfaToken+ });}} catch (err) {const updatedUser = await processFailedMfaAttempt(userId);diff --git a/backend/src/services/auth/auth-type.ts b/backend/src/services/auth/auth-type.tsindex ef54ac0be7..e2c8656908 100644--- a/backend/src/services/auth/auth-type.ts+++ b/backend/src/services/auth/auth-type.ts@@ -93,5 +93,6 @@ export type AuthModeProviderSignUpTokenPayload = {export enum MfaMethod {EMAIL = "email",- TOTP = "totp"+ TOTP = "totp",+ WEBAUTHN = "webauthn"}diff --git a/backend/src/services/webauthn/webauthn-credential-dal.ts b/backend/src/services/webauthn/webauthn-credential-dal.tsnew file mode 100644index 0000000000..58bb4f7dd4--- /dev/null+++ b/backend/src/services/webauthn/webauthn-credential-dal.ts@@ -0,0 +1,11 @@+import { TDbClient } from "@app/db";+import { TableName } from "@app/db/schemas";+import { ormify } from "@app/lib/knex";++export type TWebAuthnCredentialDALFactory = ReturnType<typeof webAuthnCredentialDALFactory>;++export const webAuthnCredentialDALFactory = (db: TDbClient) => {+ const webAuthnCredentialDal = ormify(db, TableName.WebAuthnCredential);++ return webAuthnCredentialDal;+};diff --git a/backend/src/services/webauthn/webauthn-fns.ts b/backend/src/services/webauthn/webauthn-fns.tsnew file mode 100644index 0000000000..f3c364b146--- /dev/null+++ b/backend/src/services/webauthn/webauthn-fns.ts@@ -0,0 +1,10 @@+/**+ * Helper functions for WebAuthn operations+ */++/**+ * Verify that a credential ID belongs to a user+ */+export const verifyCredentialOwnership = (userId: string, credentialUserId: string): boolean => {+ return userId === credentialUserId;+};diff --git a/backend/src/services/webauthn/webauthn-service.ts b/backend/src/services/webauthn/webauthn-service.tsnew file mode 100644index 0000000000..5966572416--- /dev/null+++ b/backend/src/services/webauthn/webauthn-service.ts@@ -0,0 +1,402 @@+import {+ AuthenticatorTransportFuture,+ generateAuthenticationOptions,+ generateRegistrationOptions,+ VerifiedAuthenticationResponse,+ VerifiedRegistrationResponse,+ verifyAuthenticationResponse,+ verifyRegistrationResponse+} from "@simplewebauthn/server";++import { getConfig } from "@app/lib/config/env";+import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";++import { TAuthTokenServiceFactory } from "../auth-token/auth-token-service";+import { TokenType } from "../auth-token/auth-token-types";+import { TUserDALFactory } from "../user/user-dal";+import { TWebAuthnCredentialDALFactory } from "./webauthn-credential-dal";+import { verifyCredentialOwnership } from "./webauthn-fns";+import {+ TDeleteWebAuthnCredentialDTO,+ TGenerateAuthenticationOptionsDTO,+ TGenerateRegistrationOptionsDTO,+ TGetUserWebAuthnCredentialsDTO,+ TUpdateWebAuthnCredentialDTO,+ TVerifyAuthenticationResponseDTO,+ TVerifyRegistrationResponseDTO+} from "./webauthn-types";++type TWebAuthnServiceFactoryDep = {+ userDAL: TUserDALFactory;+ webAuthnCredentialDAL: TWebAuthnCredentialDALFactory;+ tokenService: TAuthTokenServiceFactory;+};++export type TWebAuthnServiceFactory = ReturnType<typeof webAuthnServiceFactory>;++// In-memory challenge storage (for development)+// TODO: In production, use Redis or database with TTL+const challengeStore = new Map<string, { challenge: string; timestamp: number }>();+const CHALLENGE_TTL = 5 * 60 * 1000; // 5 minutes++const storeChallenge = (userId: string, challenge: string) => {+ challengeStore.set(userId, { challenge, timestamp: Date.now() });++ // Cleanup expired challenges+ for (const [key, value] of challengeStore.entries()) {+ if (Date.now() - value.timestamp > CHALLENGE_TTL) {+ challengeStore.delete(key);+ }+ }+};++const getChallenge = (userId: string): string | null => {+ const stored = challengeStore.get(userId);+ if (!stored) return null;++ // Check if expired+ if (Date.now() - stored.timestamp > CHALLENGE_TTL) {+ challengeStore.delete(userId);+ return null;+ }++ return stored.challenge;+};++const clearChallenge = (userId: string) => {+ challengeStore.delete(userId);+};++export const webAuthnServiceFactory = ({+ userDAL,+ webAuthnCredentialDAL,+ tokenService+}: TWebAuthnServiceFactoryDep) => {+ const appCfg = getConfig();++ // Relying Party (RP) information - extracted from SITE_URL+ const RP_NAME = "Infisical";+ const RP_ID = new URL(appCfg.SITE_URL || "http://localhost:8080").hostname;+ const ORIGIN = appCfg.SITE_URL || "http://localhost:8080";+ /**+ * Generate registration options for a new passkey+ * This is the first step in passkey registration+ */+ const generateRegistrationOptionsForUser = async ({ userId }: TGenerateRegistrationOptionsDTO) => {+ const user = await userDAL.findById(userId);++ if (!user) {+ throw new NotFoundError({+ message: "User not found"+ });+ }++ // Get existing credentials to exclude them from registration+ const existingCredentials = await webAuthnCredentialDAL.find({ userId });++ const options = await generateRegistrationOptions({+ rpName: RP_NAME,+ rpID: RP_ID,+ userID: Buffer.from(userId, "utf-8"),+ userName: user.email || "",+ userDisplayName: user.email || "",+ attestationType: "none",+ excludeCredentials: existingCredentials.map((cred) => ({+ id: cred.credentialId,+ transports: cred.transports as AuthenticatorTransportFuture[]+ })),+ authenticatorSelection: {+ authenticatorAttachment: "platform",+ requireResidentKey: true,+ residentKey: "required",+ userVerification: "required"+ }+ });++ // Store challenge for verification+ storeChallenge(userId, options.challenge);++ return options;+ };++ /**+ * Verify registration response and store the credential+ * This is the second step in passkey registration+ */+ const verifyRegistrationResponseFromUser = async ({+ userId,+ registrationResponse,+ name+ }: TVerifyRegistrationResponseDTO) => {+ const user = await userDAL.findById(userId);++ if (!user) {+ throw new NotFoundError({+ message: "User not found"+ });+ }++ // Retrieve the stored challenge+ const expectedChallenge = getChallenge(userId);+ if (!expectedChallenge) {+ throw new BadRequestError({+ message: "Challenge not found or expired. Please try registering again."+ });+ }++ let verification: VerifiedRegistrationResponse;+ try {+ verification = await verifyRegistrationResponse({+ response: registrationResponse,+ expectedChallenge,+ expectedOrigin: ORIGIN,+ expectedRPID: RP_ID,+ requireUserVerification: true+ });+ } catch (error: unknown) {+ clearChallenge(userId);+ throw new BadRequestError({+ message: `Registration verification failed: ${error instanceof Error ? error.message : "Unknown error"}`+ });+ }++ if (!verification.verified || !verification.registrationInfo) {+ clearChallenge(userId);+ throw new BadRequestError({+ message: "Registration verification failed"+ });+ }++ const { credential: registeredCredential } = verification.registrationInfo;++ // Check if credential already exists+ const credentialIdBase64 = registeredCredential.id;+ const existingCredential = await webAuthnCredentialDAL.findOne({+ credentialId: credentialIdBase64+ });++ if (existingCredential) {+ clearChallenge(userId);+ throw new BadRequestError({+ message: "This credential has already been registered"+ });+ }++ // Store the credential+ const credential = await webAuthnCredentialDAL.create({+ userId,+ credentialId: credentialIdBase64,+ publicKey: Buffer.from(registeredCredential.publicKey).toString("base64url"),+ counter: registeredCredential.counter,+ transports: registrationResponse.response.transports || null,+ name: name || "Passkey"+ });++ // Clear the challenge+ clearChallenge(userId);++ return {+ credentialId: credential.credentialId,+ name: credential.name+ };+ };++ /**+ * Generate authentication options for passkey verification+ * This is used during login/2FA+ */+ const generateAuthenticationOptionsForUser = async ({ userId }: TGenerateAuthenticationOptionsDTO) => {+ const credentials = await webAuthnCredentialDAL.find({ userId });++ if (credentials.length === 0) {+ throw new NotFoundError({+ message: "No passkeys registered for this user"+ });+ }++ const options = await generateAuthenticationOptions({+ rpID: RP_ID,+ allowCredentials: credentials.map((cred) => ({+ id: cred.credentialId,+ transports: cred.transports as AuthenticatorTransportFuture[]+ })),+ userVerification: "required"+ });++ // Store challenge for verification+ storeChallenge(userId, options.challenge);++ return options;+ };++ /**+ * Verify authentication response+ * This is used during login/2FA to verify the user's passkey+ */+ const verifyAuthenticationResponseFromUser = async ({+ userId,+ authenticationResponse+ }: TVerifyAuthenticationResponseDTO) => {+ const credentialIdBase64 = authenticationResponse.id;++ if (!credentialIdBase64) {+ throw new BadRequestError({+ message: "Invalid authentication response"+ });+ }++ // Find the credential+ const credential = await webAuthnCredentialDAL.findOne({ credentialId: credentialIdBase64 });++ if (!credential) {+ throw new NotFoundError({+ message: "Credential not found"+ });+ }++ // Verify the credential belongs to the user+ if (!verifyCredentialOwnership(userId, credential.userId)) {+ throw new ForbiddenRequestError({+ message: "Credential does not belong to this user"+ });+ }++ // Retrieve the stored challenge+ const expectedChallenge = getChallenge(userId);+ if (!expectedChallenge) {+ throw new BadRequestError({+ message: "Challenge not found or expired. Please try authenticating again."+ });+ }++ let verification: VerifiedAuthenticationResponse;+ try {+ verification = await verifyAuthenticationResponse({+ response: authenticationResponse,+ expectedChallenge,+ expectedOrigin: ORIGIN,+ expectedRPID: RP_ID,+ credential: {+ id: credential.credentialId,+ publicKey: Buffer.from(credential.publicKey, "base64url"),+ counter: credential.counter+ },+ requireUserVerification: true+ });+ } catch (error: unknown) {+ clearChallenge(userId);+ throw new BadRequestError({+ message: `Authentication verification failed: ${error instanceof Error ? error.message : "Unknown error"}`+ });+ }++ if (!verification.verified) {+ clearChallenge(userId);+ throw new BadRequestError({+ message: "Authentication verification failed"+ });+ }++ // Update last used timestamp and counter+ await webAuthnCredentialDAL.updateById(credential.id, {+ lastUsedAt: new Date(),+ counter: verification.authenticationInfo.newCounter+ });++ // Clear the challenge+ clearChallenge(userId);++ // Generate one-time WebAuthn session token with 60-second expiration+ const sessionToken = await tokenService.createTokenForUser({+ type: TokenType.TOKEN_WEBAUTHN_SESSION,+ userId+ });++ return {+ verified: true,+ credentialId: credential.credentialId,+ sessionToken+ };+ };++ /**+ * Get all WebAuthn credentials for a user+ */+ const getUserWebAuthnCredentials = async ({ userId }: TGetUserWebAuthnCredentialsDTO) => {+ const credentials = await webAuthnCredentialDAL.find({ userId });++ // Don't return sensitive data like public keys+ return credentials.map((cred) => ({+ id: cred.id,+ credentialId: cred.credentialId,+ name: cred.name,+ transports: cred.transports,+ createdAt: cred.createdAt,+ lastUsedAt: cred.lastUsedAt+ }));+ };++ /**+ * Delete a WebAuthn credential+ */+ const deleteWebAuthnCredential = async ({ userId, credentialId }: TDeleteWebAuthnCredentialDTO) => {+ const credential = await webAuthnCredentialDAL.findOne({ credentialId });++ if (!credential) {+ throw new NotFoundError({+ message: "Credential not found"+ });+ }++ if (!verifyCredentialOwnership(userId, credential.userId)) {+ throw new ForbiddenRequestError({+ message: "Credential does not belong to this user"+ });+ }++ await webAuthnCredentialDAL.deleteById(credential.id);++ return {+ success: true+ };+ };++ /**+ * Update a WebAuthn credential (e.g., rename it)+ */+ const updateWebAuthnCredential = async ({ userId, credentialId, name }: TUpdateWebAuthnCredentialDTO) => {+ const credential = await webAuthnCredentialDAL.findOne({ credentialId });++ if (!credential) {+ throw new NotFoundError({+ message: "Credential not found"+ });+ }++ if (!verifyCredentialOwnership(userId, credential.userId)) {+ throw new ForbiddenRequestError({+ message: "Credential does not belong to this user"+ });+ }++ const updatedCredential = await webAuthnCredentialDAL.updateById(credential.id, {+ name: name || credential.name+ });++ return {+ id: updatedCredential.id,+ credentialId: updatedCredential.credentialId,+ name: updatedCredential.name+ };+ };++ return {+ generateRegistrationOptions: generateRegistrationOptionsForUser,+ verifyRegistrationResponse: verifyRegistrationResponseFromUser,+ generateAuthenticationOptions: generateAuthenticationOptionsForUser,+ verifyAuthenticationResponse: verifyAuthenticationResponseFromUser,+ getUserWebAuthnCredentials,+ deleteWebAuthnCredential,+ updateWebAuthnCredential+ };+};diff --git a/backend/src/services/webauthn/webauthn-types.ts b/backend/src/services/webauthn/webauthn-types.tsnew file mode 100644index 0000000000..aacd4eaa35--- /dev/null+++ b/backend/src/services/webauthn/webauthn-types.ts@@ -0,0 +1,35 @@+import { AuthenticationResponseJSON, RegistrationResponseJSON } from "@simplewebauthn/server";++export type TGenerateRegistrationOptionsDTO = {+ userId: string;+};++export type TVerifyRegistrationResponseDTO = {+ userId: string;+ registrationResponse: RegistrationResponseJSON;+ name?: string; // User-friendly name for the credential+};++export type TGenerateAuthenticationOptionsDTO = {+ userId: string;+};++export type TVerifyAuthenticationResponseDTO = {+ userId: string;+ authenticationResponse: AuthenticationResponseJSON;+};++export type TGetUserWebAuthnCredentialsDTO = {+ userId: string;+};++export type TDeleteWebAuthnCredentialDTO = {+ userId: string;+ credentialId: string;+};++export type TUpdateWebAuthnCredentialDTO = {+ userId: string;+ credentialId: string;+ name?: string;+};diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex 8965ce45e3..ef1b55238f 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -47,6 +47,7 @@"@radix-ui/react-tabs": "^1.1.2","@radix-ui/react-toast": "^1.2.3","@radix-ui/react-tooltip": "^1.1.5",+ "@simplewebauthn/browser": "^13.2.2","@sindresorhus/slugify": "^2.2.1","@tanstack/react-query": "^5.62.7","@tanstack/react-router": "^1.95.1",@@ -150,7 +151,8 @@"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.4.tgz","integrity": "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/@alloc/quick-lru": {"version": "5.2.0",@@ -195,7 +197,6 @@"integrity": "sha512-2BCOP7TN8M+gVDj7/ht3hsaO/B/n5oDbiAyyvnRlNOs+u1o+JWNYTQrmpuNp1/Wq2gcFrI01JAW+paEKDMx/CA==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@babel/code-frame": "^7.27.1","@babel/generator": "^7.28.3",@@ -488,7 +489,6 @@"resolved": "https://registry.npmjs.org/@casl/ability/-/ability-6.7.2.tgz","integrity": "sha512-KjKXlcjKbUz8dKw7PY56F7qlfOFgxTU6tnlJ8YrbDyWkJMIlHa6VRWzCD8RU20zbJUC1hExhOFggZjm6tf1mUw==","license": "MIT",- "peer": true,"dependencies": {"@ucast/mongo2js": "^1.3.0"},@@ -547,7 +547,6 @@"resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz","integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==","license": "MIT",- "peer": true,"dependencies": {"@dnd-kit/accessibility": "^3.1.1","@dnd-kit/utilities": "^3.2.2",@@ -1325,7 +1324,6 @@"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.7.1.tgz","integrity": "sha512-8dBIHbfsKlCk2jHQ9PoRBg2Z+4TwyE3vZICSnoDlnsHA6SiMlTwfmW6yX0lHsRmWJugkeb92sA0hZdkXJhuz+g==","license": "MIT",- "peer": true,"dependencies": {"@fortawesome/fontawesome-common-types": "6.7.1"},@@ -2016,7 +2014,6 @@"resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.1.2.tgz","integrity": "sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==","license": "MIT",- "peer": true,"dependencies": {"@octokit/auth-token": "^5.0.0","@octokit/graphql": "^8.0.0",@@ -4060,6 +4057,12 @@"dev": true,"license": "MIT"},+ "node_modules/@simplewebauthn/browser": {+ "version": "13.2.2",+ "resolved": "https://registry.npmjs.org/@simplewebauthn/browser/-/browser-13.2.2.tgz",+ "integrity": "sha512-FNW1oLQpTJyqG5kkDg5ZsotvWgmBaC6jCHR7Ej0qUNep36Wl9tj2eZu7J5rP+uhXgHaLk+QQ3lqcw2vS5MX1IA==",+ "license": "MIT"+ },"node_modules/@sindresorhus/slugify": {"version": "2.2.1","resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-2.2.1.tgz",@@ -4412,7 +4415,6 @@"integrity": "sha512-RnO1SaiCFHn666wNz2QfZEFxvmiNRqhzaMXHXxXXKt+MEP7aajlPxUSMIQpKAaJfverpovEYqjBOXDq6dDcaOQ==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@typescript-eslint/utils": "^8.13.0","eslint-visitor-keys": "^4.2.0",@@ -5038,7 +5040,6 @@"resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.95.1.tgz","integrity": "sha512-P5x4yNhcdkYsCEoYeGZP8Q9Jlxf0WXJa4G/xvbmM905seZc9FqJqvCSRvX3dWTPOXRABhl4g+8DHqfft0c/AvQ==","license": "MIT",- "peer": true,"dependencies": {"@tanstack/history": "1.95.0","@tanstack/react-store": "^0.7.0",@@ -5250,6 +5251,7 @@"integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@babel/code-frame": "^7.10.4","@babel/runtime": "^7.12.5",@@ -5270,6 +5272,7 @@"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==","dev": true,"license": "Apache-2.0",+ "peer": true,"dependencies": {"dequal": "^2.0.3"}@@ -5280,6 +5283,7 @@"integrity": "sha512-zIcONa+hVtVSSep9UT3jZ5rizo2BsxgyDYU7WFD5eICBE7no3881HGeb/QkGfsJs6JTkY1aQhT7rIPC7e+0nnA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@adobe/css-tools": "^4.4.0","aria-query": "^5.0.0",@@ -5299,7 +5303,8 @@"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz","integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/@testing-library/user-event": {"version": "14.6.1",@@ -5307,6 +5312,7 @@"integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=12","npm": ">=6"@@ -5327,7 +5333,8 @@"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz","integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/@types/babel__core": {"version": "7.20.5",@@ -5380,6 +5387,7 @@"integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@types/deep-eql": "*","assertion-error": "^2.0.1"@@ -5453,7 +5461,8 @@"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz","integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/@types/doctrine": {"version": "0.0.9",@@ -5589,7 +5598,6 @@"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.16.tgz","integrity": "sha512-oh8AMIC4Y2ciKufU8hnKgs+ufgbA/dhPTACaZPM86AbwX9QwnFtSoPWEeRUj8fge+v6kFt78BXcDhAU1SrrAsw==","license": "MIT",- "peer": true,"dependencies": {"@types/prop-types": "*","csstype": "^3.0.2"@@ -5601,7 +5609,6 @@"integrity": "sha512-P4t6saawp+b/dFrUr2cvkVsfvPguwsxtH6dNIYRllMsefqFzkZk5UIjzyDOv5g1dXIPdG4Sp1yCR4Z6RCUsG/Q==","devOptional": true,"license": "MIT",- "peer": true,"peerDependencies": {"@types/react": "^18.0.0"}@@ -5649,7 +5656,6 @@"integrity": "sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@eslint-community/regexpp": "^4.10.0","@typescript-eslint/scope-manager": "8.34.0",@@ -5690,7 +5696,6 @@"integrity": "sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@typescript-eslint/scope-manager": "8.34.0","@typescript-eslint/types": "8.34.0",@@ -5962,6 +5967,7 @@"integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@types/chai": "^5.2.2","@vitest/spy": "3.2.4",@@ -5979,6 +5985,7 @@"integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@vitest/spy": "3.2.4","estree-walker": "^3.0.3",@@ -6006,6 +6013,7 @@"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@types/estree": "^1.0.0"}@@ -6016,6 +6024,7 @@"integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"tinyrainbow": "^2.0.0"},@@ -6029,6 +6038,7 @@"integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"tinyspy": "^4.0.3"},@@ -6042,6 +6052,7 @@"integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@vitest/pretty-format": "3.2.4","loupe": "^3.1.4",@@ -6115,7 +6126,6 @@"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==","dev": true,"license": "MIT",- "peer": true,"bin": {"acorn": "bin/acorn"},@@ -6232,6 +6242,7 @@"integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==","dev": true,"license": "Apache-2.0",+ "peer": true,"engines": {"node": ">= 0.4"}@@ -6280,6 +6291,7 @@"integrity": "sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -6360,6 +6372,7 @@"integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -6447,6 +6460,7 @@"integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=12"}@@ -6457,6 +6471,7 @@"integrity": "sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"tslib": "^2.0.1"},@@ -6469,7 +6484,8 @@"resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz","integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/asynckit": {"version": "0.4.0",@@ -6519,6 +6535,7 @@"integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==","dev": true,"license": "Apache-2.0",+ "peer": true,"engines": {"node": ">= 0.4"}@@ -6620,6 +6637,7 @@"integrity": "sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"open": "^8.0.4"},@@ -6856,7 +6874,6 @@}],"license": "MIT",- "peer": true,"dependencies": {"baseline-browser-mapping": "^2.8.9","caniuse-lite": "^1.0.30001746",@@ -7038,6 +7055,7 @@"integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"assertion-error": "^2.0.1","check-error": "^2.1.1",@@ -7108,6 +7126,7 @@"integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">= 16"}@@ -7493,7 +7512,8 @@"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz","integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/cssesc": {"version": "3.0.0",@@ -7512,8 +7532,7 @@"version": "3.1.3","resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz","integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",- "license": "MIT",- "peer": true+ "license": "MIT"},"node_modules/cva": {"name": "class-variance-authority",@@ -7585,7 +7604,6 @@"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz","integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==","license": "ISC",- "peer": true,"engines": {"node": ">=12"}@@ -7639,7 +7657,8 @@"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz","integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==","dev": true,- "license": "BSD-2-Clause"+ "license": "BSD-2-Clause",+ "peer": true},"node_modules/data-view-buffer": {"version": "1.0.1",@@ -7749,6 +7768,7 @@"integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=6"}@@ -7783,6 +7803,7 @@"integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=8"}@@ -7904,7 +7925,8 @@"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz","integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/dom-helpers": {"version": "5.2.1",@@ -8114,6 +8136,7 @@"integrity": "sha512-tpxqxncxnpw3c93u8n3VOzACmRFoVmWJqbWXvX/JfKbkhBw1oslgPrUfeSt2psuqyEJFD6N/9lg5i7bsKpoq+Q==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -8197,7 +8220,6 @@"dev": true,"hasInstallScript": true,"license": "MIT",- "peer": true,"bin": {"esbuild": "bin/esbuild"},@@ -8239,6 +8261,7 @@"integrity": "sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"debug": "^4.3.4"},@@ -8275,7 +8298,6 @@"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@eslint-community/eslint-utils": "^4.2.0","@eslint-community/regexpp": "^4.6.1",@@ -8332,7 +8354,6 @@"integrity": "sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"eslint-config-airbnb-base": "^15.0.0","object.assign": "^4.1.2",@@ -8355,7 +8376,6 @@"integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"confusing-browser-globals": "^1.0.10","object.assign": "^4.1.2",@@ -8386,7 +8406,6 @@"integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==","dev": true,"license": "MIT",- "peer": true,"bin": {"eslint-config-prettier": "bin/cli.js"},@@ -8486,7 +8505,6 @@"integrity": "sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@rtsao/scc": "^1.1.0","array-includes": "^3.1.8",@@ -8616,6 +8634,7 @@"integrity": "sha512-EsTAnj9fLVr/GZleBLFbj/sSuXeWmp1eXIN60ceYnZveqEaUCyW4X+Vh4WTdUhCkW4xutXYqTXCUSyqD4rB75w==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"array-includes": "^3.1.8","array.prototype.findlast": "^1.2.5",@@ -8649,7 +8668,6 @@"integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==","dev": true,"license": "MIT",- "peer": true,"engines": {"node": ">=10"},@@ -8673,6 +8691,7 @@"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==","dev": true,"license": "Apache-2.0",+ "peer": true,"dependencies": {"esutils": "^2.0.2"},@@ -8686,6 +8705,7 @@"integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"is-core-module": "^2.13.0","path-parse": "^1.0.7",@@ -8704,6 +8724,7 @@"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==","dev": true,"license": "ISC",+ "peer": true,"bin": {"semver": "bin/semver.js"}@@ -8865,6 +8886,7 @@"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==","dev": true,"license": "BSD-2-Clause",+ "peer": true,"bin": {"esparse": "bin/esparse.js","esvalidate": "bin/esvalidate.js"@@ -9895,7 +9917,6 @@}],"license": "MIT",- "peer": true,"dependencies": {"@babel/runtime": "^7.23.2"},@@ -9989,6 +10010,7 @@"integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=8"}@@ -10265,6 +10287,7 @@"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==","dev": true,"license": "MIT",+ "peer": true,"bin": {"is-docker": "cli.js"},@@ -10586,6 +10609,7 @@"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"is-docker": "^2.0.0"},@@ -10621,6 +10645,7 @@"resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.5.tgz","integrity": "sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==","license": "MIT",+ "peer": true,"funding": {"type": "GitHub Sponsors ❤","url": "https://github.com/sponsors/dmonad"@@ -10632,6 +10657,7 @@"integrity": "sha512-x4WH0BWmrMmg4oHHl+duwubhrvczGlyuGAZu3nvrf0UXOfPu8IhZObFEr7DE/iv01YgVZrsOiRcqw2srkKEDIA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"define-data-property": "^1.1.4","es-object-atoms": "^1.0.0",@@ -10781,6 +10807,7 @@"integrity": "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"array-includes": "^3.1.6","array.prototype.flat": "^1.3.1",@@ -10815,7 +10842,8 @@"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz","integrity": "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==","dev": true,- "license": "CC0-1.0"+ "license": "CC0-1.0",+ "peer": true},"node_modules/language-tags": {"version": "1.0.9",@@ -10823,6 +10851,7 @@"integrity": "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"language-subtag-registry": "^0.3.20"},@@ -10855,6 +10884,7 @@"resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.102.tgz","integrity": "sha512-g70kydI0I1sZU0ChO8mBbhw0oUW/8U0GHzygpvEIx8k+jgOpqnTSb/E+70toYVqHxBhrERD21TwD5QcZJQ40ZQ==","license": "MIT",+ "peer": true,"dependencies": {"isomorphic.js": "^0.2.4"},@@ -11179,7 +11209,8 @@"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz","integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/lru-cache": {"version": "5.1.1",@@ -11206,6 +11237,7 @@"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==","dev": true,"license": "MIT",+ "peer": true,"bin": {"lz-string": "bin/bin.js"}@@ -11897,6 +11929,7 @@"integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=4"}@@ -12245,6 +12278,7 @@"integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"define-lazy-prop": "^2.0.0","is-docker": "^2.1.1",@@ -12514,6 +12548,7 @@"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">= 14.16"}@@ -12665,7 +12700,6 @@"integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==","dev": true,"license": "MIT",- "peer": true,"bin": {"prettier": "bin/prettier.cjs"},@@ -12782,6 +12816,7 @@"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"ansi-regex": "^5.0.1","ansi-styles": "^5.0.0",@@ -12797,6 +12832,7 @@"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=10"},@@ -12809,7 +12845,8 @@"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz","integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/prismjs": {"version": "1.30.0",@@ -13010,7 +13047,6 @@"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz","integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==","license": "MIT",- "peer": true,"dependencies": {"loose-envify": "^1.1.0"},@@ -13038,7 +13074,6 @@"resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz","integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==","license": "MIT",- "peer": true,"dependencies": {"loose-envify": "^1.1.0","object-assign": "^4.1.1",@@ -13130,7 +13165,6 @@"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz","integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==","license": "MIT",- "peer": true,"dependencies": {"loose-envify": "^1.1.0","scheduler": "^0.23.2"@@ -13181,7 +13215,6 @@"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.3.tgz","integrity": "sha512-IK18V6GVbab4TAo1/cz3kqajxbDPGofdF0w7VHdCo0Nt8PrPlOZcuuDq9YYIV1BtjcX78x0XsldbQRQnQXWXmw==","license": "MIT",- "peer": true,"engines": {"node": ">=18.0.0"},@@ -13432,6 +13465,7 @@"integrity": "sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"ast-types": "^0.16.1","esprima": "~4.0.0",@@ -13449,6 +13483,7 @@"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==","dev": true,"license": "BSD-3-Clause",+ "peer": true,"engines": {"node": ">=0.10.0"}@@ -13465,6 +13500,7 @@"integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"indent-string": "^4.0.0","strip-indent": "^3.0.0"@@ -13479,6 +13515,7 @@"integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"min-indent": "^1.0.0"},@@ -13693,7 +13730,6 @@"integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@types/estree": "1.0.8"},@@ -14204,6 +14240,7 @@"integrity": "sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -14219,6 +14256,7 @@"integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -14246,6 +14284,7 @@"integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"define-properties": "^1.1.3","es-abstract": "^1.17.5"@@ -14466,8 +14505,7 @@"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.14.tgz","integrity": "sha512-b7pCxjGO98LnxVkKjaZSDeNuljC4ueKUddjENJOADtubtdo8llTaJy7HwBMeLNSSo2N5QIAgklslK1+Ir8r6CA==","dev": true,- "license": "MIT",- "peer": true+ "license": "MIT"},"node_modules/tapable": {"version": "2.2.1",@@ -14571,6 +14609,7 @@"integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=14.0.0"}@@ -14581,6 +14620,7 @@"integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=14.0.0"}@@ -14865,7 +14905,6 @@"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==","devOptional": true,"license": "Apache-2.0",- "peer": true,"bin": {"tsc": "bin/tsc","tsserver": "bin/tsserver"@@ -15251,7 +15290,6 @@"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"esbuild": "^0.25.0","fdir": "^6.4.4",@@ -15669,6 +15707,7 @@"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=10.0.0"},@@ -15713,7 +15752,6 @@"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz","integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==","license": "ISC",- "peer": true,"bin": {"yaml": "bin.mjs"},@@ -15864,7 +15902,6 @@"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz","integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==","license": "MIT",- "peer": true,"funding": {"url": "https://github.com/sponsors/colinhacks"}diff --git a/frontend/package.json b/frontend/package.jsonindex 8009c2118a..0dbd2353f5 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -56,6 +56,7 @@"@radix-ui/react-tabs": "^1.1.2","@radix-ui/react-toast": "^1.2.3","@radix-ui/react-tooltip": "^1.1.5",+ "@simplewebauthn/browser": "^13.2.2","@sindresorhus/slugify": "^2.2.1","@tanstack/react-query": "^5.62.7","@tanstack/react-router": "^1.95.1",diff --git a/frontend/src/components/auth/Mfa.tsx b/frontend/src/components/auth/Mfa.tsxindex 4577f4ece1..363532486b 100644--- a/frontend/src/components/auth/Mfa.tsx+++ b/frontend/src/components/auth/Mfa.tsx@@ -1,5 +1,6 @@import React, { useEffect, useState } from "react";import ReactCodeInput from "react-code-input";+import { startAuthentication, startRegistration } from "@simplewebauthn/browser";import { Link, useNavigate } from "@tanstack/react-router";import { t } from "i18next";@@ -7,11 +8,23 @@ import Error from "@app/components/basic/Error";import TotpRegistration from "@app/components/mfa/TotpRegistration";import { createNotification } from "@app/components/notifications";import SecurityClient from "@app/components/utilities/SecurityClient";-import { Button, Tooltip } from "@app/components/v2";+import { Button, Input, Tooltip } from "@app/components/v2";import { isInfisicalCloud } from "@app/helpers/platform";import { useLogoutUser, useSendMfaToken } from "@app/hooks/api";-import { checkUserTotpMfa, verifyMfaToken, verifyRecoveryCode } from "@app/hooks/api/auth/queries";+import {+ checkUserTotpMfa,+ checkUserWebAuthnMfa,+ verifyMfaToken,+ verifyRecoveryCode+} from "@app/hooks/api/auth/queries";import { MfaMethod } from "@app/hooks/api/auth/types";+import { getMfaTempToken } from "@app/hooks/api/reactQuery";+import {+ useGenerateAuthenticationOptions,+ useGenerateRegistrationOptions,+ useVerifyAuthentication,+ useVerifyRegistration+} from "@app/hooks/api/webauthn";// The style for the verification code inputconst codeInputProps = {@@ -68,9 +81,17 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Propconst [isLoadingResend, setIsLoadingResend] = useState(false);const [triesLeft, setTriesLeft] = useState<number | undefined>(undefined);const [shouldShowTotpRegistration, setShouldShowTotpRegistration] = useState(false);+ const [shouldShowWebAuthnRegistration, setShouldShowWebAuthnRegistration] = useState(false);+ const [credentialName, setCredentialName] = useState("");+ const [isRegisteringPasskey, setIsRegisteringPasskey] = useState(false);const logout = useLogoutUser(true);+ const { mutateAsync: generateWebAuthnAuthenticationOptions } = useGenerateAuthenticationOptions();+ const { mutateAsync: verifyWebAuthnAuthentication } = useVerifyAuthentication();+const sendMfaToken = useSendMfaToken();+ const generateRegistrationOptions = useGenerateRegistrationOptions();+ const verifyRegistration = useVerifyRegistration();useEffect(() => {if (method === MfaMethod.TOTP) {@@ -80,8 +101,14 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: PropsetShouldShowTotpRegistration(true);}});+ } else if (method === MfaMethod.WEBAUTHN) {+ checkUserWebAuthnMfa().then((hasPasskeys) => {+ if (!hasPasskeys) {+ setShouldShowWebAuthnRegistration(true);+ }+ });}- }, []);+ }, [method]);const getExpectedCodeLength = () => {if (method === MfaMethod.EMAIL) return 6;@@ -153,6 +180,156 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop}};+ const handleWebAuthnVerification = async () => {+ setIsLoading(true);+ const mfaToken = getMfaTempToken();++ try {+ SecurityClient.setMfaToken("");++ // Get authentication options from server+ const options = await generateWebAuthnAuthenticationOptions();++ // Prompt user to authenticate with their passkey+ const authenticationResponse = await startAuthentication({ optionsJSON: options });++ // Verify with server+ const result = await verifyWebAuthnAuthentication({ authenticationResponse });++ // Use the sessionToken to verify MFA+ if (result.sessionToken) {+ SecurityClient.setMfaToken(mfaToken);+ const mfaResult = await verifyMfaToken({+ email,+ mfaCode: result.sessionToken,+ mfaMethod: MfaMethod.WEBAUTHN+ });++ SecurityClient.setMfaToken("");+ SecurityClient.setToken(mfaResult.token);++ await successCallback();+ if (closeMfa) {+ closeMfa();+ }+ }+ } catch (error: any) {+ console.error("WebAuthn verification failed:", error);++ let errorMessage = "Failed to verify passkey";+ if (error.name === "NotAllowedError") {+ errorMessage = "Passkey verification was cancelled or timed out";+ } else if (error.message) {+ errorMessage = error.message;+ }++ SecurityClient.setMfaToken(mfaToken);++ createNotification({+ text: errorMessage,+ type: "error"+ });++ if (typeof triesLeft === "number") {+ const newTriesLeft = triesLeft - 1;+ setTriesLeft(newTriesLeft);+ if (newTriesLeft <= 0) {+ createNotification({+ text: "User is temporary locked due to multiple failed login attempts. Try again later.",+ type: "error"+ });+ SecurityClient.setMfaToken("");+ SecurityClient.setToken("");+ SecurityClient.setSignupToken("");+ await logout.mutateAsync();+ navigate({ to: "/login" });+ return;+ }+ } else {+ setTriesLeft(2);+ }+ } finally {+ setIsLoading(false);+ }+ };++ const handleRegisterPasskey = async () => {+ try {+ setIsRegisteringPasskey(true);++ // Check if WebAuthn is supported+ if (+ !window.PublicKeyCredential ||+ !window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable+ ) {+ createNotification({+ text: "WebAuthn is not supported on this browser",+ type: "error"+ });+ return;+ }++ // Check if platform authenticator is available+ const available =+ await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();+ if (!available) {+ createNotification({+ text: "No passkey-compatible authenticator found on this device",+ type: "error"+ });+ return;+ }++ // Temporarily clear MFA token so the regular access token is used for registration endpoints+ const mfaToken = getMfaTempToken();+ SecurityClient.setMfaToken("");++ try {+ // Generate registration options from server (using regular user endpoint)+ const options = await generateRegistrationOptions.mutateAsync();+ const registrationResponse = await startRegistration({ optionsJSON: options });++ // Verify registration with server (using regular user endpoint)+ await verifyRegistration.mutateAsync({+ registrationResponse,+ name: credentialName || "Passkey"+ });++ createNotification({+ text: "Successfully registered passkey",+ type: "success"+ });++ setShouldShowWebAuthnRegistration(false);+ await successCallback();+ if (closeMfa) {+ closeMfa();+ }+ } finally {+ // Restore MFA token+ SecurityClient.setMfaToken(mfaToken);+ }+ } catch (error: any) {+ console.error("Failed to register passkey:", error);++ let errorMessage = "Failed to register passkey";+ if (error.name === "NotAllowedError") {+ errorMessage = "Passkey registration was cancelled or timed out";+ } else if (error.name === "InvalidStateError") {+ errorMessage = "This passkey has already been registered";+ } else if (error.message) {+ errorMessage = error.message;+ }++ createNotification({+ text: errorMessage,+ type: "error"+ });+ } finally {+ setIsRegisteringPasskey(false);+ }+ };+if (shouldShowTotpRegistration) {return (<>@@ -172,6 +349,35 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop);}+ if (shouldShowWebAuthnRegistration) {+ return (+ <>+ <div className="mb-6 text-center text-lg font-bold text-white">+ Your organization requires passkey authentication to be configured.+ </div>+ <div className="mx-auto w-max pt-4 pb-4 md:mb-16 md:px-8">+ <div className="flex max-w-lg flex-col text-bunker-200">+ <div className="mb-8">+ 1. Click the button below to register your passkey. You'll be prompted to use+ your device's biometric authentication (Touch ID, Face ID, Windows Hello, etc.).+ </div>+ <div className="mb-4">2. Optionally, give your passkey a name to identify it later</div>+ <div className="mb-4 flex flex-col gap-2">+ <Input+ onChange={(e) => setCredentialName(e.target.value)}+ value={credentialName}+ placeholder="Passkey name (optional)"+ />+ <Button onClick={handleRegisterPasskey} isLoading={isRegisteringPasskey}>+ Register Passkey+ </Button>+ </div>+ </div>+ </div>+ </>+ );+ }+return (<div className="mx-auto w-max pt-6 pb-6 md:mb-16 md:px-8">{!hideLogo && (@@ -197,83 +403,113 @@ export const Mfa = ({ successCallback, closeMfa, hideLogo, email, method }: Prop</p></div>)}- <form onSubmit={verifyMfa}>- <div className="mx-auto hidden md:block" style={{ minWidth: "600px" }}>- {method === MfaMethod.EMAIL && (- <div className="flex justify-center">- <ReactCodeInput- name=""- inputMode="tel"- type="text"- fields={6}- onChange={setMfaCode}- className="mt-6 mb-2"- {...codeInputProps}- />- </div>- )}- {method === MfaMethod.TOTP && (- <div className="mt-8 mb-6 flex justify-center">- <ReactCodeInput- key={showRecoveryCodeInput ? "recovery" : "totp"}- name=""- inputMode="tel"- type="text"- fields={showRecoveryCodeInput ? 8 : 6}- onChange={setMfaCode}- className="mb-2"- {...codeInputProps}- />- </div>- )}+ {method === MfaMethod.WEBAUTHN && (+ <div className="mb-8 text-center">+ <h2 className="mb-3 text-xl font-medium text-bunker-100">Passkey Authentication</h2>+ <p className="mx-auto max-w-md text-sm leading-relaxed text-bunker-300">+ Use your registered passkey to complete two-factor authentication+ </p></div>- <div className="mx-auto mt-4 block md:hidden" style={{ minWidth: "400px" }}>- {method === MfaMethod.EMAIL && (- <div className="flex justify-center">- <ReactCodeInput- name=""- inputMode="tel"- type="text"- fields={6}- onChange={setMfaCode}- className="mt-2 mb-2"- {...codeInputPropsPhone}- />- </div>+ )}+ {method === MfaMethod.WEBAUTHN ? (+ <>+ {typeof triesLeft === "number" && (+ <Error text={`Failed authentication. You have ${triesLeft} attempt(s) remaining.`} />)}- {method === MfaMethod.TOTP && (- <div className="mt-4 mb-6 flex justify-center">- <ReactCodeInput- key={showRecoveryCodeInput ? "recovery-mobile" : "totp-mobile"}- name=""- inputMode="tel"- type="text"- fields={showRecoveryCodeInput ? 8 : 6}- onChange={setMfaCode}- className="mb-2"- {...codeInputPropsPhone}- />- </div>+ <div className="mx-auto mt-6 flex w-full max-w-sm flex-col items-center justify-center text-center">+ <Button+ size="md"+ onClick={handleWebAuthnVerification}+ isFullWidth+ className="h-11 rounded-lg font-medium shadow-xs transition-all duration-200 hover:shadow-md"+ colorSchema="primary"+ variant="outline_bg"+ isLoading={isLoading}+ isDisabled={typeof triesLeft === "number" && triesLeft <= 0}+ >+ Authenticate with Passkey+ </Button>+ </div>+ </>+ ) : (+ <form onSubmit={verifyMfa}>+ <div className="mx-auto hidden md:block" style={{ minWidth: "600px" }}>+ {method === MfaMethod.EMAIL && (+ <div className="flex justify-center">+ <ReactCodeInput+ name=""+ inputMode="tel"+ type="text"+ fields={6}+ onChange={setMfaCode}+ className="mt-6 mb-2"+ {...codeInputProps}+ />+ </div>+ )}+ {method === MfaMethod.TOTP && (+ <div className="mt-8 mb-6 flex justify-center">+ <ReactCodeInput+ key={showRecoveryCodeInput ? "recovery" : "totp"}+ name=""+ inputMode="tel"+ type="text"+ fields={showRecoveryCodeInput ? 8 : 6}+ onChange={setMfaCode}+ className="mb-2"+ {...codeInputProps}+ />+ </div>+ )}+ </div>+ <div className="mx-auto mt-4 block md:hidden" style={{ minWidth: "400px" }}>+ {method === MfaMethod.EMAIL && (+ <div className="flex justify-center">+ <ReactCodeInput+ name=""+ inputMode="tel"+ type="text"+ fields={6}+ onChange={setMfaCode}+ className="mt-2 mb-2"+ {...codeInputPropsPhone}+ />+ </div>+ )}+ {method === MfaMethod.TOTP && (+ <div className="mt-4 mb-6 flex justify-center">+ <ReactCodeInput+ key={showRecoveryCodeInput ? "recovery-mobile" : "totp-mobile"}+ name=""+ inputMode="tel"+ type="text"+ fields={showRecoveryCodeInput ? 8 : 6}+ onChange={setMfaCode}+ className="mb-2"+ {...codeInputPropsPhone}+ />+ </div>+ )}+ </div>+ {typeof triesLeft === "number" && (+ <Error text={`Invalid code. You have ${triesLeft} attempt(s) remaining.`} />)}- </div>- {typeof triesLeft === "number" && (- <Error text={`Invalid code. You have ${triesLeft} attempt(s) remaining.`} />- )}- <div className="mx-auto mt-6 flex w-full max-w-sm flex-col items-center justify-center text-center">- <Button- size="md"- type="submit"- isFullWidth- className="h-11 rounded-lg font-medium shadow-xs transition-all duration-200 hover:shadow-md"- colorSchema="primary"- variant="outline_bg"- isLoading={isLoading}- isDisabled={!isCodeComplete || (typeof triesLeft === "number" && triesLeft <= 0)}- >- {String(t("mfa.verify"))}- </Button>- </div>- </form>+ <div className="mx-auto mt-6 flex w-full max-w-sm flex-col items-center justify-center text-center">+ <Button+ size="md"+ type="submit"+ isFullWidth+ className="h-11 rounded-lg font-medium shadow-xs transition-all duration-200 hover:shadow-md"+ colorSchema="primary"+ variant="outline_bg"+ isLoading={isLoading}+ isDisabled={!isCodeComplete || (typeof triesLeft === "number" && triesLeft <= 0)}+ >+ {String(t("mfa.verify"))}+ </Button>+ </div>+ </form>+ )}{method === MfaMethod.TOTP && (<div className="mt-6 flex flex-col items-center gap-4 text-sm"><buttondiff --git a/frontend/src/hooks/api/auth/queries.tsx b/frontend/src/hooks/api/auth/queries.tsxindex 207980017c..d806211ed0 100644--- a/frontend/src/hooks/api/auth/queries.tsx+++ b/frontend/src/hooks/api/auth/queries.tsx@@ -7,6 +7,7 @@ import { SessionStorageKeys } from "@app/const";import { organizationKeys } from "../organization/queries";import { projectKeys } from "../projects";import { setAuthToken } from "../reactQuery";+import { TGenerateAuthenticationOptionsResponse, TVerifyAuthenticationDTO } from "../webauthn";import {CompleteAccountDTO,CompleteAccountSignupDTO,@@ -331,6 +332,36 @@ export const checkUserTotpMfa = async () => {return data.isVerified;};+export const checkUserWebAuthnMfa = async () => {+ const { data } = await apiRequest.get<{ hasPasskeys: boolean }>(+ "/api/v2/auth/mfa/check/webauthn"+ );++ return data.hasPasskeys;+};++export const useMfaGenerateAuthenticationOptions = () =>+ useMutation({+ mutationFn: async () => {+ const { data } = await apiRequest.post<TGenerateAuthenticationOptionsResponse>(+ "/api/v2/auth/mfa/webauthn/authenticate"+ );+ return data;+ }+ });++export const useMfaVerifyAuthentication = () =>+ useMutation({+ mutationFn: async (dto: TVerifyAuthenticationDTO) => {+ const { data } = await apiRequest.post<{+ verified: boolean;+ credentialId: string;+ sessionToken: string;+ }>("/api/v2/auth/mfa/webauthn/verify", dto);+ return data;+ }+ });+export const useSendPasswordSetupEmail = () => {return useMutation({mutationFn: async () => {diff --git a/frontend/src/hooks/api/auth/types.ts b/frontend/src/hooks/api/auth/types.tsindex fd9d6fb5cb..7f6217414e 100644--- a/frontend/src/hooks/api/auth/types.ts+++ b/frontend/src/hooks/api/auth/types.ts@@ -148,5 +148,6 @@ export enum UserAgentType {export enum MfaMethod {EMAIL = "email",- TOTP = "totp"+ TOTP = "totp",+ WEBAUTHN = "webauthn"}diff --git a/frontend/src/hooks/api/webauthn/index.tsx b/frontend/src/hooks/api/webauthn/index.tsxnew file mode 100644index 0000000000..4bcb5b5fa9--- /dev/null+++ b/frontend/src/hooks/api/webauthn/index.tsx@@ -0,0 +1,18 @@+export {+ useDeleteWebAuthnCredential,+ useGenerateAuthenticationOptions,+ useGenerateRegistrationOptions,+ useUpdateWebAuthnCredential,+ useVerifyAuthentication,+ useVerifyRegistration+} from "./mutations";+export { useGetWebAuthnCredentials } from "./queries";+export type {+ TDeleteWebAuthnCredentialDTO,+ TGenerateAuthenticationOptionsResponse,+ TGenerateRegistrationOptionsResponse,+ TUpdateWebAuthnCredentialDTO,+ TVerifyAuthenticationDTO,+ TVerifyRegistrationDTO,+ TWebAuthnCredential+} from "./types";diff --git a/frontend/src/hooks/api/webauthn/mutations.tsx b/frontend/src/hooks/api/webauthn/mutations.tsxnew file mode 100644index 0000000000..79b379ae00--- /dev/null+++ b/frontend/src/hooks/api/webauthn/mutations.tsx@@ -0,0 +1,96 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";++import { apiRequest } from "@app/config/request";++import { webAuthnKeys } from "./queries";+import {+ TDeleteWebAuthnCredentialDTO,+ TGenerateAuthenticationOptionsResponse,+ TGenerateRegistrationOptionsResponse,+ TUpdateWebAuthnCredentialDTO,+ TVerifyAuthenticationDTO,+ TVerifyRegistrationDTO+} from "./types";++export const useGenerateRegistrationOptions = () =>+ useMutation({+ mutationFn: async () => {+ const { data } = await apiRequest.post<TGenerateRegistrationOptionsResponse>(+ "/api/v1/user/me/webauthn/register"+ );+ return data;+ }+ });++export const useVerifyRegistration = () => {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: async (dto: TVerifyRegistrationDTO) => {+ const { data } = await apiRequest.post<{ credentialId: string; name?: string | null }>(+ "/api/v1/user/me/webauthn/register/verify",+ dto+ );+ return data;+ },+ onSuccess: () => {+ queryClient.invalidateQueries({ queryKey: webAuthnKeys.credentials });+ }+ });+};++export const useGenerateAuthenticationOptions = () =>+ useMutation({+ mutationFn: async () => {+ const { data } = await apiRequest.post<TGenerateAuthenticationOptionsResponse>(+ "/api/v1/user/me/webauthn/authenticate"+ );+ return data;+ }+ });++export const useVerifyAuthentication = () =>+ useMutation({+ mutationFn: async (dto: TVerifyAuthenticationDTO) => {+ const { data } = await apiRequest.post<{+ verified: boolean;+ credentialId: string;+ sessionToken: string;+ }>("/api/v1/user/me/webauthn/authenticate/verify", dto);+ return data;+ }+ });++export const useDeleteWebAuthnCredential = () => {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: async ({ credentialId }: TDeleteWebAuthnCredentialDTO) => {+ const { data } = await apiRequest.delete<{ success: boolean }>(+ `/api/v1/user/me/webauthn/${credentialId}`+ );+ return data;+ },+ onSuccess: () => {+ queryClient.invalidateQueries({ queryKey: webAuthnKeys.credentials });+ }+ });+};++export const useUpdateWebAuthnCredential = () => {+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: async ({ credentialId, name }: TUpdateWebAuthnCredentialDTO) => {+ const { data } = await apiRequest.patch<{+ id: string;+ credentialId: string;+ name?: string | null;+ }>(`/api/v1/user/me/webauthn/${credentialId}`, { name });+ return data;+ },+ onSuccess: () => {+ queryClient.invalidateQueries({ queryKey: webAuthnKeys.credentials });+ }+ });+};diff --git a/frontend/src/hooks/api/webauthn/queries.tsx b/frontend/src/hooks/api/webauthn/queries.tsxnew file mode 100644index 0000000000..60299a3fa7--- /dev/null+++ b/frontend/src/hooks/api/webauthn/queries.tsx@@ -0,0 +1,22 @@+import { useQuery } from "@tanstack/react-query";++import { apiRequest } from "@app/config/request";++import { TWebAuthnCredential } from "./types";++export const webAuthnKeys = {+ credentials: ["webauthn-credentials"] as const,+ registrationOptions: ["webauthn-registration-options"] as const,+ authenticationOptions: ["webauthn-authentication-options"] as const+};++export const useGetWebAuthnCredentials = () =>+ useQuery({+ queryKey: webAuthnKeys.credentials,+ queryFn: async () => {+ const { data } = await apiRequest.get<{ credentials: TWebAuthnCredential[] }>(+ "/api/v1/user/me/webauthn"+ );+ return data.credentials;+ }+ });diff --git a/frontend/src/hooks/api/webauthn/types.ts b/frontend/src/hooks/api/webauthn/types.tsnew file mode 100644index 0000000000..76da73909c--- /dev/null+++ b/frontend/src/hooks/api/webauthn/types.ts@@ -0,0 +1,37 @@+import type {+ AuthenticationResponseJSON,+ PublicKeyCredentialCreationOptionsJSON,+ PublicKeyCredentialRequestOptionsJSON,+ RegistrationResponseJSON+} from "@simplewebauthn/browser";++export type TWebAuthnCredential = {+ id: string;+ credentialId: string;+ name?: string | null;+ transports?: string[] | null;+ createdAt: Date;+ lastUsedAt?: Date | null;+};++export type TGenerateRegistrationOptionsResponse = PublicKeyCredentialCreationOptionsJSON;++export type TVerifyRegistrationDTO = {+ registrationResponse: RegistrationResponseJSON;+ name?: string;+};++export type TGenerateAuthenticationOptionsResponse = PublicKeyCredentialRequestOptionsJSON;++export type TVerifyAuthenticationDTO = {+ authenticationResponse: AuthenticationResponseJSON;+};++export type TUpdateWebAuthnCredentialDTO = {+ credentialId: string;+ name?: string;+};++export type TDeleteWebAuthnCredentialDTO = {+ credentialId: string;+};diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSecurityTab/OrgGenericAuthSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSecurityTab/OrgGenericAuthSection.tsxindex 7e69223185..ea76170638 100644--- a/frontend/src/pages/organization/SettingsPage/components/OrgSecurityTab/OrgGenericAuthSection.tsx+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSecurityTab/OrgGenericAuthSection.tsx@@ -87,6 +87,9 @@ export const OrgGenericAuthSection = () => {<SelectItem value={MfaMethod.TOTP} key="mfa-method-totp">Mobile Authenticator</SelectItem>+ <SelectItem value={MfaMethod.WEBAUTHN} key="mfa-method-webauthn">+ Passkey (WebAuthn)+ </SelectItem></Select></FormControl>)}diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsxindex 74f4ed99bf..ef4fbe9551 100644--- a/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx+++ b/frontend/src/pages/user/PersonalSettingsPage/components/SecuritySection/MFASection.tsx@@ -1,4 +1,5 @@import { useEffect, useState } from "react";+import { startRegistration } from "@simplewebauthn/browser";import { useQueryClient } from "@tanstack/react-query";import QRCode from "qrcode";@@ -11,6 +12,8 @@ import {EmailServiceSetupModal,FormControl,Input,+ Modal,+ ModalContent,Select,SelectItem} from "@app/components/v2";@@ -28,6 +31,13 @@ import {useGetUserTotpRegistration} from "@app/hooks/api/users/queries";import { AuthMethod } from "@app/hooks/api/users/types";+import {+ useDeleteWebAuthnCredential,+ useGenerateRegistrationOptions,+ useGetWebAuthnCredentials,+ useUpdateWebAuthnCredential,+ useVerifyRegistration+} from "@app/hooks/api/webauthn";import { usePopUp } from "@app/hooks/usePopUp";export const MFASection = () => {@@ -46,7 +56,10 @@ export const MFASection = () => {const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp(["setUpEmail","deleteTotpConfig",- "downloadRecoveryCodes"+ "downloadRecoveryCodes",+ "deleteWebAuthnCredential",+ "renameWebAuthnCredential",+ "registerPasskey"] as const);const [shouldShowRecoveryCodes, setShouldShowRecoveryCodes] = useToggle();const { data: totpConfiguration } = useGetUserTotpConfiguration();@@ -60,6 +73,20 @@ export const MFASection = () => {const queryClient = useQueryClient();const { data: serverDetails } = useFetchServerStatus();+ // WebAuthn/Passkey hooks+ const { data: webAuthnCredentials, isPending: isWebAuthnCredentialsLoading } =+ useGetWebAuthnCredentials();+ const { mutateAsync: generateRegistrationOptions, isPending: isGeneratingOptions } =+ useGenerateRegistrationOptions();+ const { mutateAsync: verifyRegistration, isPending: isVerifyingRegistration } =+ useVerifyRegistration();+ const { mutateAsync: deleteWebAuthnCredential } = useDeleteWebAuthnCredential();+ const { mutateAsync: updateWebAuthnCredential } = useUpdateWebAuthnCredential();++ const [selectedCredentialId, setSelectedCredentialId] = useState<string>("");+ const [credentialName, setCredentialName] = useState<string>("");+ const [isRegisteringPasskey, setIsRegisteringPasskey] = useState(false);+// Update form data when user data changesuseEffect(() => {if (user) {@@ -107,6 +134,114 @@ export const MFASection = () => {});};+ const handleRegisterPasskey = async () => {+ try {+ setIsRegisteringPasskey(true);++ // Check if WebAuthn is supported+ if (+ !window.PublicKeyCredential ||+ !window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable+ ) {+ createNotification({+ text: "WebAuthn is not supported on this browser",+ type: "error"+ });+ return;+ }++ // Check if platform authenticator is available+ const available =+ await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();+ if (!available) {+ createNotification({+ text: "No passkey-compatible authenticator found on this device",+ type: "error"+ });+ return;+ }++ // Generate registration options from server+ const options = await generateRegistrationOptions();+ const registrationResponse = await startRegistration({ optionsJSON: options });++ // Verify registration with server+ await verifyRegistration({+ registrationResponse,+ name: credentialName || "Passkey"+ });++ createNotification({+ text: "Successfully registered passkey",+ type: "success"+ });++ handlePopUpClose("registerPasskey");+ setCredentialName("");+ } catch (error: any) {+ console.error("Failed to register passkey:", error);++ // Better error messages+ let errorMessage = "Failed to register passkey";+ if (error.name === "NotAllowedError") {+ errorMessage = "Passkey registration was cancelled or timed out";+ } else if (error.name === "InvalidStateError") {+ errorMessage = "This passkey has already been registered";+ } else if (error.message) {+ errorMessage = error.message;+ }++ createNotification({+ text: errorMessage,+ type: "error"+ });+ } finally {+ setIsRegisteringPasskey(false);+ }+ };++ const handleDeleteWebAuthnCredential = async () => {+ try {+ await deleteWebAuthnCredential({ credentialId: selectedCredentialId });++ createNotification({+ text: "Successfully deleted passkey",+ type: "success"+ });++ handlePopUpClose("deleteWebAuthnCredential");+ setSelectedCredentialId("");+ } catch (error: any) {+ createNotification({+ text: error.message || "Failed to delete passkey",+ type: "error"+ });+ }+ };++ const handleRenameWebAuthnCredential = async () => {+ try {+ await updateWebAuthnCredential({+ credentialId: selectedCredentialId,+ name: credentialName+ });++ createNotification({+ text: "Successfully renamed passkey",+ type: "success"+ });++ handlePopUpClose("renameWebAuthnCredential");+ setSelectedCredentialId("");+ setCredentialName("");+ } catch (error: any) {+ createNotification({+ text: error.message || "Failed to rename passkey",+ type: "error"+ });+ }+ };+const handleFormDataChange = async (field: string, value: any) => {setFormData((prev) => ({...prev,@@ -149,6 +284,19 @@ export const MFASection = () => {return;}+ // If selecting passkey as 2FA method but no passkeys registered+ if (+ formData.isMfaEnabled &&+ formData.selectedMfaMethod === MfaMethod.WEBAUTHN &&+ (!webAuthnCredentials || webAuthnCredentials.length === 0)+ ) {+ createNotification({+ text: "Please register at least one passkey before selecting it as your two-factor authentication method",+ type: "error"+ });+ return;+ }+setIsLoading(true);// If enabling 2FA with mobile authenticator, verify TOTP first@@ -210,6 +358,8 @@ export const MFASection = () => {updates.selectedMfaMethod = formData.selectedMfaMethod;}+ console.log("updates", updates, formData.selectedMfaMethod, user.selectedMfaMethod);+if (Object.keys(updates).length > 0) {await mutateAsync(updates);@@ -240,9 +390,97 @@ export const MFASection = () => {if (totpConfiguration?.isVerified) return true;return totpCode.trim().length > 0;}+ if (formData.selectedMfaMethod === MfaMethod.WEBAUTHN) return true;+return false;};+ const registerPasskeyModal = (+ <Modal+ isOpen={popUp.registerPasskey?.isOpen || false}+ onOpenChange={(isOpen) => {+ if (!isOpen) {+ handlePopUpClose("registerPasskey");+ setCredentialName("");+ }+ }}+ >+ <ModalContent title="Register New Passkey">+ <div className="space-y-4">+ <p className="text-sm text-mineshaft-300">+ Give your passkey a name to help you identify it later. After clicking+ "Register", you'll be prompted to use your device's biometric+ authentication (Touch ID, Face ID, Windows Hello, etc.).+ </p>+ <FormControl label="Passkey Name">+ <Input+ value={credentialName}+ onChange={(e) => setCredentialName(e.target.value)}+ placeholder="e.g., My MacBook Pro"+ />+ </FormControl>+ <div className="flex gap-2">+ <Button+ onClick={handleRegisterPasskey}+ isLoading={isRegisteringPasskey || isVerifyingRegistration}+ disabled={!credentialName.trim()}+ colorSchema="primary"+ >+ Register+ </Button>+ <Button+ variant="outline_bg"+ onClick={() => handlePopUpClose("registerPasskey")}+ disabled={isRegisteringPasskey || isVerifyingRegistration}+ >+ Cancel+ </Button>+ </div>+ </div>+ </ModalContent>+ </Modal>+ );++ const renamePasskeyModal = (+ <Modal+ isOpen={popUp.renameWebAuthnCredential?.isOpen || false}+ onOpenChange={(isOpen) => {+ if (!isOpen) {+ handlePopUpClose("renameWebAuthnCredential");+ setCredentialName("");+ setSelectedCredentialId("");+ }+ }}+ >+ <ModalContent title="Rename Passkey">+ <div className="space-y-4">+ <FormControl label="Passkey Name">+ <Input+ value={credentialName}+ onChange={(e) => setCredentialName(e.target.value)}+ placeholder="e.g., My MacBook Pro"+ />+ </FormControl>+ <div className="flex gap-2">+ <Button+ onClick={handleRenameWebAuthnCredential}+ disabled={!credentialName.trim()}+ colorSchema="primary"+ >+ Save+ </Button>+ <Button+ variant="outline_bg"+ onClick={() => handlePopUpClose("renameWebAuthnCredential")}+ >+ Cancel+ </Button>+ </div>+ </div>+ </ModalContent>+ </Modal>+ );+return (<><form@@ -293,6 +531,7 @@ export const MFASection = () => {><SelectItem value={MfaMethod.EMAIL}>Email</SelectItem><SelectItem value={MfaMethod.TOTP}>Mobile Authenticator</SelectItem>+ <SelectItem value={MfaMethod.WEBAUTHN}>Passkey (WebAuthn)</SelectItem></Select></FormControl></div>@@ -411,56 +650,161 @@ export const MFASection = () => {</Button></div>)}+ </div>+ )}+ </form>- {user?.isMfaEnabled && totpConfiguration?.isVerified && (- <div className="mt-8 border-t border-mineshaft-600 pt-6">- <h3 className="mb-4 text-lg font-medium text-mineshaft-100">- Mobile Authenticator Management- </h3>+ {/* Management Sections - Separate from configuration form */}+ {user && (+ <div className="mt-6 mb-6 space-y-6">+ {/* Mobile Authenticator Management - Show if configured, regardless of active method */}+ {totpConfiguration?.isVerified && (+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">+ <h3 className="mb-4 text-lg font-medium text-mineshaft-100">+ Mobile Authenticator Management+ </h3>+ <p className="mb-4 text-sm text-mineshaft-400">+ Manage your mobile authenticator configuration and recovery codes.+ </p>++ <div className="space-y-4">+ <div className="flex flex-wrap gap-2">+ <Button+ colorSchema="secondary"+ variant="outline_bg"+ onClick={setShouldShowRecoveryCodes.toggle}+ >+ {shouldShowRecoveryCodes ? "Hide recovery codes" : "Show recovery codes"}+ </Button>+ <Button+ colorSchema="secondary"+ variant="outline_bg"+ onClick={handleGenerateMoreRecoveryCodes}+ >+ Generate more codes+ </Button>+ <Button+ colorSchema="danger"+ variant="outline_bg"+ onClick={() => handlePopUpOpen("deleteTotpConfig")}+ >+ Remove Authenticator+ </Button>+ </div>- <div className="space-y-4">- <div className="flex flex-wrap gap-2">- <Button- colorSchema="secondary"- variant="outline_bg"- onClick={setShouldShowRecoveryCodes.toggle}- >- {shouldShowRecoveryCodes ? "Hide recovery codes" : "Show recovery codes"}- </Button>- <Button- colorSchema="secondary"- variant="outline_bg"- onClick={handleGenerateMoreRecoveryCodes}- >- Generate more codes- </Button>- <Button- colorSchema="danger"- variant="outline_bg"- onClick={() => handlePopUpOpen("deleteTotpConfig")}- >- Remove Authenticator- </Button>+ {shouldShowRecoveryCodes && (+ <div className="w-fit rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-4 pr-8">+ <div className="grid grid-cols-2 gap-x-6 gap-y-2 font-mono text-sm">+ {totpConfiguration.recoveryCodes.map((code, index) => (+ <div key={code} className="flex items-center text-mineshaft-200">+ <span className="w-8 text-right text-mineshaft-400">{index + 1}.</span>+ <span className="pl-2">{code}</span>+ </div>+ ))}+ </div></div>+ )}+ </div>+ </div>+ )}++ {/* Passkey Management - Always show */}+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">+ <div className="mb-4 flex items-center justify-between">+ <div>+ <h3 className="text-lg font-medium text-mineshaft-100">Passkey Management</h3>+ <p className="mt-1 text-sm text-mineshaft-400">+ Manage your passkeys. Passkeys can be used for two-factor authentication.+ </p>+ </div>+ <Button+ colorSchema="primary"+ variant="outline_bg"+ onClick={() => {+ setCredentialName("");+ handlePopUpOpen("registerPasskey");+ }}+ isLoading={isGeneratingOptions}+ >+ Add Passkey+ </Button>+ </div>- {shouldShowRecoveryCodes && (- <div className="w-fit rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-4 pr-8">- <div className="grid grid-cols-2 gap-x-6 gap-y-2 font-mono text-sm">- {totpConfiguration.recoveryCodes.map((code, index) => (- <div key={code} className="flex items-center text-mineshaft-200">- <span className="w-8 text-right text-mineshaft-400">{index + 1}.</span>- <span className="pl-2">{code}</span>+ {(() => {+ if (isWebAuthnCredentialsLoading) {+ return <ContentLoader />;+ }+ if (webAuthnCredentials && webAuthnCredentials.length > 0) {+ return (+ <div className="space-y-3">+ {webAuthnCredentials.map((credential) => (+ <div+ key={credential.id}+ className="flex items-center justify-between rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-4"+ >+ <div className="flex-1">+ <div className="flex items-center gap-2">+ <span className="text-sm font-medium text-mineshaft-100">+ {credential.name || "Unnamed Passkey"}+ </span>+ {credential.transports && credential.transports.length > 0 && (+ <span className="text-xs text-mineshaft-400">+ ({credential.transports.join(", ")})+ </span>+ )}</div>- ))}+ <div className="mt-1 text-xs text-mineshaft-400">+ Added {new Date(credential.createdAt).toLocaleDateString()}+ {credential.lastUsedAt && (+ <>+ {" "}+ · Last used {new Date(credential.lastUsedAt).toLocaleDateString()}+ </>+ )}+ </div>+ </div>+ <div className="flex gap-2">+ <Button+ size="xs"+ colorSchema="secondary"+ variant="outline_bg"+ onClick={() => {+ setSelectedCredentialId(credential.credentialId);+ setCredentialName(credential.name || "");+ handlePopUpOpen("renameWebAuthnCredential");+ }}+ >+ Rename+ </Button>+ <Button+ size="xs"+ colorSchema="danger"+ variant="outline_bg"+ onClick={() => {+ setSelectedCredentialId(credential.credentialId);+ handlePopUpOpen("deleteWebAuthnCredential");+ }}+ >+ Remove+ </Button>+ </div></div>- </div>- )}+ ))}+ </div>+ );+ }+ return (+ <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-6 text-center">+ <p className="text-sm text-mineshaft-300">+ No passkeys registered yet. Add a passkey to use it for two-factor+ authentication.+ </p></div>- </div>- )}+ );+ })()}</div>- )}- </form>+ </div>+ )}<EmailServiceSetupModalisOpen={popUp.setUpEmail?.isOpen}@@ -481,6 +825,19 @@ export const MFASection = () => {recoveryCodes={totpRegistration?.recoveryCodes || []}onDownloadComplete={() => handlePopUpClose("downloadRecoveryCodes")}/>++ {registerPasskeyModal}+ {renamePasskeyModal}++ {/* Delete Passkey Modal */}+ <DeleteActionModal+ isOpen={popUp.deleteWebAuthnCredential?.isOpen || false}+ title="Remove passkey?"+ subTitle="This action is irreversible. You'll need to register this passkey again if you want to use it in the future."+ onChange={(isOpen) => handlePopUpToggle("deleteWebAuthnCredential", isOpen)}+ deleteKey="confirm"+ onDeleteApproved={handleDeleteWebAuthnCredential}+ /></>);};