fix(mcp): harden MCP route security and code quality
- Sanitize error messages to prevent leaking internal details - Add isError flag to tool-not-found and no-caller responses - Guard against undefined procedure before invocation - Clear auth rate limit on successful authentication - Move setInterval timers to globalThis to prevent dev hot-reload leaks - Add try/catch + logging to OAuth token exchange - Deduplicate auth error responses with helper function - Replace ternary operators with lookup tables in UI - Remove console.error monkey-patch for trpc-to-mcp warnings - Use lookup table for media request answer actions
This commit is contained in:
8 files changed
+176
-146
No files matched your search
@@ -141,12 +141,12 @@ export const mediaRequestsRouter = createTRPCRouter({
|
||||
const integrationInstance = await createIntegrationAsync(integration);
|
||||
const innerHandler = mediaRequestListRequestHandler.handler(integration, {});
|
||||
|
||||
if (input.answer === "approve") {
|
||||
await integrationInstance.approveRequestAsync(input.requestId);
|
||||
await innerHandler.invalidateAsync();
|
||||
return;
|
||||
}
|
||||
await integrationInstance.declineRequestAsync(input.requestId);
|
||||
const answerActions = {
|
||||
approve: (id: number) => integrationInstance.approveRequestAsync(id),
|
||||
decline: (id: number) => integrationInstance.declineRequestAsync(id),
|
||||
} as const;
|
||||
|
||||
await answerActions[input.answer](input.requestId);
|
||||
await innerHandler.invalidateAsync();
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user