refactor(security): unify gateway scope authorization flows

This commit is contained in:
Peter Steinberger
2026-02-19 15:06:28 +01:00
parent f4b288b8f7
commit 2777d8ad93
14 changed files with 202 additions and 86 deletions

View File

@@ -19,6 +19,8 @@ export type ActionGate<T extends Record<string, boolean | undefined>> = (
defaultValue?: boolean,
) => boolean;
export const OWNER_ONLY_TOOL_ERROR = "Tool restricted to owner senders.";
export class ToolInputError extends Error {
readonly status = 400;
@@ -208,6 +210,12 @@ export function jsonResult(payload: unknown): AgentToolResult<unknown> {
};
}
export function assertOwnerSender(senderIsOwner?: boolean): void {
if (senderIsOwner === false) {
throw new Error(OWNER_ONLY_TOOL_ERROR);
}
}
export async function imageResult(params: {
label: string;
path: string;