prompt-security-gateway
v0.1.1
Published
A middleware firewall for LLM/GenAI apps
Downloads
4
Maintainers
Readme
Prompt Security Gateway (PSG)
🚧 A middleware firewall for LLM/GenAI apps.
Features
- 🔑 Detects jailbreaks, secrets, PII, finance leaks, IP terms
- ⚖️ Severity-based actions: block, redact, log
- 🛡️ Works on inputs & outputs (middleware + post-process)
- 🔌 Extendable via plugins
- 🧑🤝🧑 Multi-tenant & role-based access
- 📊 Helper functions for rules
Install
npm install prompt-security-gateway
const { createPSG } = require("prompt-security-gateway");
const psg = createPSG({
onBlock: (reason, payload) => console.warn("🚨", reason, payload),
rules: [
{ id: "health_0", regex: /\bpatient\s+id:\s*\d+/i, category: "healthcare", severity: "high" }
]
});
// Express middleware
app.post("/chat", psg.middleware(), async (req, res) => {
const { prompt } = req.body;
// call your LLM here
const result = await llm(prompt);
res.json({ result: await psg.postProcess(result) });
});