trigguard-js
v0.2.0
Published
TrigGuard JS client: gateway helpers, autoguard, and Express middleware for canonical POST /decide
Maintainers
Readme
trigguard-js
JavaScript utilities for TrigGuard, including createTrigguardMiddleware for Express routes that call the canonical decision authority (POST /decide).
Express middleware
Default authority URL: https://api.trigguardai.com/decide. Only PERMIT continues to your handler; DENY, SILENCE, timeouts, and invalid responses return HTTP 403 with { "blocked": true, "reasonCode": "…" }.
import express from "express";
import { createTrigguardMiddleware } from "trigguard-js";
const app = express();
app.use(express.json());
app.post(
"/charge",
createTrigguardMiddleware({
surface: "spendCommit",
token: process.env.TRIGGUARD_TOKEN,
signals: (req) => ({ riskScore: req.body.riskScore }),
context: (req) => ({ amount: req.body.amount, origin: "api" }),
}),
(req, res) => res.json({ charged: true })
);See docs/quickstart/express.md and examples/express-spend-guard/ in this repository.
Other exports
Gateway /execute helpers (authorize, guard, …), manifest loading, and autoguard utilities remain available from the same package entry.
License
Apache-2.0
