From 4a5dd437fad2a49dde8bceb4bb90451de8157aba Mon Sep 17 00:00:00 2001 From: imbytecat Date: Tue, 10 Mar 2026 15:07:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20setPgpPrivateKey=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A2=9E=E5=8A=A0=E7=A7=81=E9=92=A5=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/server/src/server/api/routers/config.router.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/server/src/server/api/routers/config.router.ts b/apps/server/src/server/api/routers/config.router.ts index 208d726..464e586 100644 --- a/apps/server/src/server/api/routers/config.router.ts +++ b/apps/server/src/server/api/routers/config.router.ts @@ -1,3 +1,5 @@ +import { validatePgpPrivateKey } from '@furtherverse/crypto' +import { ORPCError } from '@orpc/server' import { ensureUxConfig, setUxLicence, setUxPgpPrivateKey } from '@/server/ux-config' import { db } from '../middlewares' import { os } from '../server' @@ -19,6 +21,12 @@ export const setLicence = os.config.setLicence.use(db).handler(async ({ context, }) export const setPgpPrivateKey = os.config.setPgpPrivateKey.use(db).handler(async ({ context, input }) => { + await validatePgpPrivateKey(input.pgpPrivateKey).catch((error) => { + throw new ORPCError('BAD_REQUEST', { + message: `Invalid PGP private key: ${error instanceof Error ? error.message : 'unable to parse'}`, + }) + }) + const config = await setUxPgpPrivateKey(context.db, input.pgpPrivateKey) return toConfigOutput(config) })