From a1677687dc67f2b9a8da68ffe27b4f5d9973c07c Mon Sep 17 00:00:00 2001 From: panda Date: Fri, 2 Aug 2024 18:23:51 +0800 Subject: [PATCH] core&ui: upgrade webauthn lib (#847) --- package.json | 2 +- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/home.ts | 2 +- packages/hydrooj/src/handler/user.ts | 2 +- packages/hydrooj/src/interface.ts | 6 +++--- packages/ui-default/package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index f31b4cdb6..34a376e80 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "version": "1.0.0", "license": "AGPL-3.0-only", "devDependencies": { - "@simplewebauthn/typescript-types": "7.4.0", + "@simplewebauthn/types": "9.0.1", "@types/autocannon": "^7.12.5", "@types/chai": "^4.3.16", "@types/cross-spawn": "^6.0.6", diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 4f096384e..bf2918f5e 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -19,7 +19,7 @@ "@graphql-tools/schema": "^10.0.4", "@hydrooj/framework": "workspace:^", "@hydrooj/utils": "workspace:^", - "@simplewebauthn/server": "7.4.0", + "@simplewebauthn/server": "9.0.3", "@undefined-moe/require-resolve-hook": "^1.1.0", "adm-zip": "0.5.14", "cac": "^6.7.14", diff --git a/packages/hydrooj/src/handler/home.ts b/packages/hydrooj/src/handler/home.ts index a19aa404a..9d9ca5448 100644 --- a/packages/hydrooj/src/handler/home.ts +++ b/packages/hydrooj/src/handler/home.ts @@ -288,7 +288,7 @@ class HomeSecurityHandler extends Handler { @requireSudo @param('type', Types.Range(['cross-platform', 'platform'])) async postRegister(domainId: string, type: 'cross-platform' | 'platform') { - const options = generateRegistrationOptions({ + const options = await generateRegistrationOptions({ rpName: system.get('server.name'), rpID: this.getAuthnHost(), userID: this.user._id.toString(), diff --git a/packages/hydrooj/src/handler/user.ts b/packages/hydrooj/src/handler/user.ts index 941b55b2f..0876b81d9 100644 --- a/packages/hydrooj/src/handler/user.ts +++ b/packages/hydrooj/src/handler/user.ts @@ -131,7 +131,7 @@ class UserWebauthnHandler extends Handler { const udoc = this.user._id ? this.user : ((await user.getByEmail(domainId, uname)) || await user.getByUname(domainId, uname)); if (!udoc._id) throw new UserNotFoundError(uname || 'user'); if (!udoc.authn) throw new AuthOperationError('authn', 'disabled'); - const options = generateAuthenticationOptions({ + const options = await generateAuthenticationOptions({ allowCredentials: udoc._authenticators.map((authenticator) => ({ id: authenticator.credentialID.buffer, type: 'public-key', diff --git a/packages/hydrooj/src/interface.ts b/packages/hydrooj/src/interface.ts index 7f6e20211..316373da7 100644 --- a/packages/hydrooj/src/interface.ts +++ b/packages/hydrooj/src/interface.ts @@ -1,6 +1,6 @@ -import type { AttestationFormat } from '@simplewebauthn/server/dist/helpers/decodeAttestationObject'; -import type { AuthenticationExtensionsAuthenticatorOutputs } from '@simplewebauthn/server/dist/helpers/decodeAuthenticatorExtensions'; -import { CredentialDeviceType } from '@simplewebauthn/typescript-types'; +import type { AuthenticationExtensionsAuthenticatorOutputs } from '@simplewebauthn/server/esm/helpers/decodeAuthenticatorExtensions'; +import type { AttestationFormat } from '@simplewebauthn/server/helpers'; +import { CredentialDeviceType } from '@simplewebauthn/types'; import type fs from 'fs'; import type { Dictionary, NumericDictionary } from 'lodash'; import type { Binary, FindCursor, ObjectId } from 'mongodb'; diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index bc53cdde7..094e8b52e 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -27,7 +27,7 @@ "@hydrooj/utils": "workspace:^", "@sentry/browser": "^8.19.0", "@sentry/webpack-plugin": "^2.21.1", - "@simplewebauthn/browser": "7.4.0", + "@simplewebauthn/browser": "9.0.1", "@svgr/webpack": "^8.1.0", "@types/gulp-if": "^0.0.34", "@types/jquery": "^3.5.30",