From eb1392fea9cd29e5b386187094764256ea1efd4a Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 16 Sep 2026 00:59:45 +0200 Subject: [PATCH] feat(frontend): remove old deps (#12857) Co-authored-by: Oliver --- src/frontend/package.json | 1 - src/frontend/src/functions/auth.tsx | 13 +--- .../Settings/AccountSettings/MFASettings.tsx | 75 ++++++++++--------- src/frontend/yarn.lock | 5 -- 4 files changed, 41 insertions(+), 53 deletions(-) diff --git a/src/frontend/package.json b/src/frontend/package.json index 0cad2737e2..18cced8c3b 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -59,7 +59,6 @@ "@fullcalendar/daygrid": "^6.1.21", "@fullcalendar/interaction": "^6.1.21", "@fullcalendar/react": "6.1.21", - "@github/webauthn-json": "^2.1.1", "@lingui/core": "^5.9.2", "@lingui/react": "^5.9.2", "@mantine/carousel": "^9.2.1", diff --git a/src/frontend/src/functions/auth.tsx b/src/frontend/src/functions/auth.tsx index 5ae4c0641d..c9ef72decc 100644 --- a/src/frontend/src/functions/auth.tsx +++ b/src/frontend/src/functions/auth.tsx @@ -1,8 +1,3 @@ -import { - type CredentialRequestOptionsJSON, - get, - parseRequestOptionsFromJSON -} from '@github/webauthn-json/browser-ponyfill'; import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; import { apiUrl } from '@lib/functions/Api'; import { getBaseUrl } from '@lib/functions/Navigation'; @@ -798,11 +793,9 @@ export async function handleWebauthnLogin( } try { - const credential = await get( - parseRequestOptionsFromJSON( - webauthn_challenge as CredentialRequestOptionsJSON - ) - ); + const publicKey = + PublicKeyCredential.parseRequestOptionsFromJSON(webauthn_challenge); + const credential = await navigator.credentials.get({ publicKey }); await api .post(apiUrl(ApiEndpoints.auth_webauthn_login), { credential: credential diff --git a/src/frontend/src/pages/Index/Settings/AccountSettings/MFASettings.tsx b/src/frontend/src/pages/Index/Settings/AccountSettings/MFASettings.tsx index ce09b68e44..b381bc4797 100644 --- a/src/frontend/src/pages/Index/Settings/AccountSettings/MFASettings.tsx +++ b/src/frontend/src/pages/Index/Settings/AccountSettings/MFASettings.tsx @@ -1,4 +1,3 @@ -import { create } from '@github/webauthn-json/browser-ponyfill'; import { CopyButton } from '@lib/components/CopyButton'; import { StylishText } from '@lib/components/StylishText'; import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; @@ -761,44 +760,46 @@ export default function MFASettings() { // Register a WebAuthn credential with the provided key const registerWebauthn = useCallback((key: any) => { - create({ - publicKey: PublicKeyCredential.parseCreationOptionsFromJSON(key) - }).then((credential) => { - const credentialString: string = JSON.stringify(credential); + navigator.credentials + .create({ + publicKey: PublicKeyCredential.parseCreationOptionsFromJSON(key) + }) + .then((credential) => { + const credentialString: string = JSON.stringify(credential); - api - .post( - apiUrl(ApiEndpoints.auth_webauthn), - { - name: 'Master Key', - credential: credentialString - }, - { - timeout: 30 * 1000 - } - ) - .then((response) => { - showNotification({ - title: t`WebAuthn Registered`, - message: t`WebAuthn credential registered successfully`, - color: 'green', - icon: + api + .post( + apiUrl(ApiEndpoints.auth_webauthn), + { + name: 'Master Key', + credential: credentialString + }, + { + timeout: 30 * 1000 + } + ) + .then((response) => { + showNotification({ + title: t`WebAuthn Registered`, + message: t`WebAuthn credential registered successfully`, + color: 'green', + icon: + }); + refetch(); + }) + .catch((error) => { + const errorMsg = extractErrorMessage( + error, + t`Error registering WebAuthn credential` + ); + showNotification({ + title: t`WebAuthn Registration Failed`, + message: `${t`Failed to register WebAuthn credential`}: ${errorMsg}`, + color: 'red', + icon: + }); }); - refetch(); - }) - .catch((error) => { - const errorMsg = extractErrorMessage( - error, - t`Error registering WebAuthn credential` - ); - showNotification({ - title: t`WebAuthn Registration Failed`, - message: `${t`Failed to register WebAuthn credential`}: ${errorMsg}`, - color: 'red', - icon: - }); - }); - }); + }); }, []); // Request a WebAuthn registration challenge from the server diff --git a/src/frontend/yarn.lock b/src/frontend/yarn.lock index fd96274b0c..2c7de871ce 100644 --- a/src/frontend/yarn.lock +++ b/src/frontend/yarn.lock @@ -987,11 +987,6 @@ resolved "https://registry.yarnpkg.com/@fullcalendar/react/-/react-6.1.21.tgz#6f396ab7460d3ad9d07f4c32b1ac483b9b21120f" integrity sha512-TLpmGUd5k/PMdCh8XbeFC9PW9wuGvMms1oCxWgXyjK3EFPXAAd0PLfcvwKdyxoAS5eK1E4RJFkjMHvsYHpimcg== -"@github/webauthn-json@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@github/webauthn-json/-/webauthn-json-2.1.1.tgz#648e63fc28050917d2882cc2b27817a88cb420fc" - integrity sha512-XrftRn4z75SnaJOmZQbt7Mk+IIjqVHw+glDGOxuHwXkZBZh/MBoRS7MHjSZMDaLhT4RjN2VqiEU7EOYleuJWSQ== - "@istanbuljs/load-nyc-config@^1.0.0", "@istanbuljs/load-nyc-config@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"