import type { Request } from "express"; import { forbidden } from "../errors.js"; export function assertBoard(req: Request) { if (req.actor.type !== "board") { throw forbidden("Board access required"); } } export function assertCompanyAccess(req: Request, companyId: string) { if (req.actor.type === "agent" && req.actor.companyId !== companyId) { throw forbidden("Agent key cannot access another company"); } } export function getActorInfo(req: Request) { if (req.actor.type === "agent") { return { actorType: "agent" as const, actorId: req.actor.agentId ?? "unknown-agent", agentId: req.actor.agentId ?? null, }; } return { actorType: "user" as const, actorId: req.actor.userId ?? "board", agentId: null, }; }