fix(security): centralize WhatsApp outbound auth and return 403 tool auth errors

This commit is contained in:
Peter Steinberger
2026-02-21 14:30:53 +01:00
parent f64d5ddf60
commit 10b8839a82
6 changed files with 165 additions and 39 deletions

View File

@@ -24,7 +24,7 @@ export type ActionGate<T extends Record<string, boolean | undefined>> = (
export const OWNER_ONLY_TOOL_ERROR = "Tool restricted to owner senders.";
export class ToolInputError extends Error {
readonly status = 400;
readonly status: number = 400;
constructor(message: string) {
super(message);
@@ -32,6 +32,15 @@ export class ToolInputError extends Error {
}
}
export class ToolAuthorizationError extends ToolInputError {
override readonly status = 403;
constructor(message: string) {
super(message);
this.name = "ToolAuthorizationError";
}
}
export function createActionGate<T extends Record<string, boolean | undefined>>(
actions: T | undefined,
): ActionGate<T> {