From 313fc3f76171d7f7e23af16e53780cd1897fe486 Mon Sep 17 00:00:00 2001 From: Piyush Gupta Date: Thu, 4 Dec 2025 02:16:58 +0530 Subject: [PATCH] fix: provider -> configuration --- .../external-kms-endpoints.ts | 33 +++++++++---------- frontend/src/hooks/api/kms/mutations.tsx | 4 +-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/backend/src/ee/routes/v1/external-kms-routers/external-kms-endpoints.ts b/backend/src/ee/routes/v1/external-kms-routers/external-kms-endpoints.ts index 049523324..a8a418c0a 100644 --- a/backend/src/ee/routes/v1/external-kms-routers/external-kms-endpoints.ts +++ b/backend/src/ee/routes/v1/external-kms-routers/external-kms-endpoints.ts @@ -9,6 +9,7 @@ import { TExternalKmsInputSchema, TExternalKmsInputUpdateSchema } from "@app/ee/services/external-kms/providers/model"; +import { BadRequestError } from "@app/lib/errors"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { AuthMode } from "@app/services/auth/auth-type"; @@ -75,7 +76,9 @@ export const registerExternalKmsEndpoints = < // Validate that the KMS is of the expected provider type if (externalKms.external.provider !== provider) { - throw new Error(`KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}`); + throw new BadRequestError({ + message: `KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}` + }); } await server.services.auditLog.createAuditLog({ @@ -104,7 +107,7 @@ export const registerExternalKmsEndpoints = < body: z.object({ name: z.string().min(1).trim().toLowerCase(), description: z.string().trim().optional(), - provider: createSchema + configuration: createSchema }), response: { 200: z.object({ @@ -114,19 +117,15 @@ export const registerExternalKmsEndpoints = < }, onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), handler: async (req) => { - const { - name, - description, - provider: providerInputs - } = req.body as { + const { name, description, configuration } = req.body as { name: string; description?: string; - provider: T["inputs"]; + configuration: T["inputs"]; }; const providerInput = { type: provider, - inputs: providerInputs + inputs: configuration } as TExternalKmsInputSchema; const externalKms = await server.services.externalKms.create({ @@ -170,7 +169,7 @@ export const registerExternalKmsEndpoints = < body: z.object({ name: z.string().min(1).trim().toLowerCase().optional(), description: z.string().trim().optional(), - provider: updateSchema + configuration: updateSchema }), response: { 200: z.object({ @@ -180,19 +179,15 @@ export const registerExternalKmsEndpoints = < }, onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), handler: async (req) => { - const { - name, - description, - provider: providerInputs - } = req.body as { + const { name, description, configuration } = req.body as { name?: string; description?: string; - provider: Partial; + configuration: Partial; }; const providerInput = { type: provider, - inputs: providerInputs + inputs: configuration } as TExternalKmsInputUpdateSchema; const externalKms = await server.services.externalKms.updateById({ @@ -252,7 +247,9 @@ export const registerExternalKmsEndpoints = < // Validate that the KMS is of the expected provider type if (externalKms.external.provider !== provider) { - throw new Error(`KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}`); + throw new BadRequestError({ + message: `KMS provider mismatch. Expected ${provider}, got ${externalKms.external.provider}` + }); } await server.services.auditLog.createAuditLog({ diff --git a/frontend/src/hooks/api/kms/mutations.tsx b/frontend/src/hooks/api/kms/mutations.tsx index c911c8f97..fada7ea9f 100644 --- a/frontend/src/hooks/api/kms/mutations.tsx +++ b/frontend/src/hooks/api/kms/mutations.tsx @@ -20,7 +20,7 @@ export const useAddExternalKms = (orgId: string) => { const { data } = await apiRequest.post(`/api/v1/external-kms/${providerPath}`, { name, description, - provider: provider.inputs + configuration: provider.inputs }); return data; @@ -46,7 +46,7 @@ export const useUpdateExternalKms = (orgId: string) => { const { data } = await apiRequest.patch(`/api/v1/external-kms/${providerPath}/${kmsId}`, { name, description, - provider: provider.inputs + configuration: provider.inputs }); return data;