From 9537aad44711cf2b5e5d322ada3902b2a5aa19ee Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 8 Feb 2025 16:39:58 +0800 Subject: [PATCH 1/2] fix: webauth no need to validate hostname on cli request --- app/port/webauth/WebauthController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/port/webauth/WebauthController.ts b/app/port/webauth/WebauthController.ts index d4939c7d..4f57db6a 100644 --- a/app/port/webauth/WebauthController.ts +++ b/app/port/webauth/WebauthController.ts @@ -35,8 +35,8 @@ import { genRSAKeys, decryptRSA } from '../../common/CryptoUtil'; import { getBrowserTypeForWebauthn } from '../../common/UserUtil'; const LoginRequestRule = Type.Object({ - // cli 所在机器的 hostname - hostname: Type.String({ minLength: 1, maxLength: 100 }), + // cli 所在机器的 hostname,最新版本 npm cli 已经不会上报 hostname + hostname: Type.Optional(Type.String({ minLength: 1, maxLength: 100 })), }); type LoginRequest = Static; From 1bd73529d689eaf5878dc0330644c234afb767e4 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 8 Feb 2025 16:43:59 +0800 Subject: [PATCH 2/2] f --- test/port/webauth/webauthController.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/port/webauth/webauthController.test.ts b/test/port/webauth/webauthController.test.ts index aef0720c..787cc0f9 100644 --- a/test/port/webauth/webauthController.test.ts +++ b/test/port/webauth/webauthController.test.ts @@ -26,12 +26,11 @@ describe('test/port/webauth/webauthController.test.ts', () => { assert.equal(loginSessionId.length, 36); }); - it('should check hostname', async () => { + it('should hostname is optional', async () => { const res = await app.httpRequest() .post('/-/v1/login'); - assert.equal(res.status, 422); - assert.equal(res.body.error, "[INVALID_PARAM] must have required property 'hostname'"); + assert.equal(res.status, 200); }); });