feat: marca Uriel Jareth Consulting, API segura para agentes, aprobacion humana y webhooks HMAC

This commit is contained in:
urieljareth
2026-11-25 00:55:18 -06:00
parent 75180b0fe4
commit 0d4f19f35d
111 changed files with 7167 additions and 1272 deletions
+12 -2
View File
@@ -1,8 +1,15 @@
import { NextRequest, NextResponse } from "next/server";
import { prisma } from "@/lib/db";
import { applyHeaders, requireActor } from "@/lib/agent-auth";
export async function GET() {
export async function GET(request: NextRequest) {
try {
const auth = await requireActor(request, {
scopes: ["catalogo:leer"],
recursoTipo: "paquete",
});
if (!auth.ok) return auth.response;
const paquetes = await prisma.paquete.findMany({
where: { activo: true },
include: {
@@ -18,7 +25,7 @@ export async function GET() {
},
orderBy: { createdAt: "asc" },
});
return NextResponse.json(paquetes);
return applyHeaders(NextResponse.json(paquetes), auth.rateLimitHeaders);
} catch (error: unknown) {
const msg = error instanceof Error ? error.message : "Error interno";
return NextResponse.json({ error: msg }, { status: 500 });
@@ -27,6 +34,9 @@ export async function GET() {
export async function POST(request: NextRequest) {
try {
const auth = await requireActor(request, { staffOnly: true, recursoTipo: "paquete" });
if (!auth.ok) return auth.response;
const body = await request.json();
const paquete = await prisma.paquete.create({
data: {