{"_id":"@aegis-sdk/express","_rev":"4-9703657c81ecfc12e96bc17696ea619e","name":"@aegis-sdk/express","dist-tags":{"latest":"0.5.0"},"versions":{"0.1.0":{"name":"@aegis-sdk/express","version":"0.1.0","license":"MIT","_id":"@aegis-sdk/express@0.1.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"homepage":"https://github.com/aegis-sdk/aegis#readme","bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"dist":{"shasum":"12b8925712c61bdcf300bd49b4ebeed4e22acbba","tarball":"https://registry.npmjs.org/@aegis-sdk/express/-/express-0.1.0.tgz","fileCount":8,"integrity":"sha512-l7DEVrOAdpSq/KOgVZsAKTTwCEB0k1sn1pIzialp0Fht2cLkhTxdlpu4GUmolpM//ZuSvpi41yX32hCjQWK1Sw==","signatures":[{"sig":"MEQCIHsaMXGGvF+z4vvOKjKFfo7ysyJPHbh3payf7SbATIFqAiAWjtRwjv3hVgIyS2AXcGmikLDimvlBF6HUIVpfG5wqGA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54918},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-express-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"msjoshlopez","email":"josh@memberstack.com"},"_resolved":"/tmp/d2d8fa2acd123fc74f7e7c4a7d950408/aegis-sdk-express-0.1.0.tgz","_integrity":"sha512-l7DEVrOAdpSq/KOgVZsAKTTwCEB0k1sn1pIzialp0Fht2cLkhTxdlpu4GUmolpM//ZuSvpi41yX32hCjQWK1Sw==","repository":{"url":"git+https://github.com/aegis-sdk/aegis.git","type":"git","directory":"packages/express"},"_npmVersion":"10.9.4","description":"Express middleware adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.1.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/express":"^5.0.0"},"peerDependencies":{"express":">=4.0.0","@aegis-sdk/core":"0.1.0"},"_npmOperationalInternal":{"tmp":"tmp/express_0.1.0_1771370516012_0.07327952705900387","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@aegis-sdk/express","version":"0.2.0","license":"MIT","_id":"@aegis-sdk/express@0.2.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"homepage":"https://github.com/aegis-sdk/aegis#readme","bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"dist":{"shasum":"0f5fb1057fa8b9cf0c5ee9ddbdeb608a93ec7d58","tarball":"https://registry.npmjs.org/@aegis-sdk/express/-/express-0.2.0.tgz","fileCount":8,"integrity":"sha512-AJpzKaEov+oQrsumxdCRrP9J0aSwydUx6xPQB9ir2xMoLpVAs/YQJIXIR52gkTMSvrz/maZflVNUq3T5oYlHVA==","signatures":[{"sig":"MEQCICx+x4xgCdUmpfhmcpeQl3650yBjYNH4f4BUaCYKgjaVAiBHJVr06dZRSBwH+MLk2/XZbpz3PYH7EDVJJxTWP6fghg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54918},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-express-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"msjoshlopez","email":"josh@memberstack.com"},"_resolved":"/tmp/ce3eeb83773cd9017ab7910cf3f31cd5/aegis-sdk-express-0.2.0.tgz","_integrity":"sha512-AJpzKaEov+oQrsumxdCRrP9J0aSwydUx6xPQB9ir2xMoLpVAs/YQJIXIR52gkTMSvrz/maZflVNUq3T5oYlHVA==","repository":{"url":"git+https://github.com/aegis-sdk/aegis.git","type":"git","directory":"packages/express"},"_npmVersion":"10.9.4","description":"Express middleware adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.2.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/express":"^5.0.0"},"peerDependencies":{"express":">=4.0.0","@aegis-sdk/core":"0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/express_0.2.0_1771372100012_0.7531991799189597","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@aegis-sdk/express","version":"0.3.0","license":"MIT","_id":"@aegis-sdk/express@0.3.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"homepage":"https://github.com/aegis-sdk/aegis#readme","bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"dist":{"shasum":"35db7c8b802c518ab64b8a33bf47a546e5b19f15","tarball":"https://registry.npmjs.org/@aegis-sdk/express/-/express-0.3.0.tgz","fileCount":8,"integrity":"sha512-lxvYuUL+dmFCLKiVYzY9vyNbZxejfMZkzi3RPcieEy1ON0IVu12KEhsL4SPccE9hurFk3PIXH0t3D3P9zgEqBw==","signatures":[{"sig":"MEUCIQD/MeDEqxiUEYOpkNMZ5GKqarS7WggCZo8WfevE2SHY7wIgKF+lc1dsbgvNSF0Ftiovdsbyy2AZIpgMJd0eILnpnQE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54918},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-express-0.3.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"msjoshlopez","email":"josh@memberstack.com"},"_resolved":"/tmp/160e797361b984c6df0fa7e499b1b853/aegis-sdk-express-0.3.0.tgz","_integrity":"sha512-lxvYuUL+dmFCLKiVYzY9vyNbZxejfMZkzi3RPcieEy1ON0IVu12KEhsL4SPccE9hurFk3PIXH0t3D3P9zgEqBw==","repository":{"url":"git+https://github.com/aegis-sdk/aegis.git","type":"git","directory":"packages/express"},"_npmVersion":"10.9.4","description":"Express middleware adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.3.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/express":"^5.0.0"},"peerDependencies":{"express":">=4.0.0","@aegis-sdk/core":"0.3.0"},"_npmOperationalInternal":{"tmp":"tmp/express_0.3.0_1771394272540_0.3553520182714627","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@aegis-sdk/express","version":"0.5.0","description":"Express middleware adapter for Aegis prompt injection defense","license":"MIT","type":"module","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","peerDependencies":{"express":">=4.0.0","@aegis-sdk/core":"0.5.0"},"dependencies":{"@aegis-sdk/core":"0.5.0"},"devDependencies":{"@types/express":"^5.0.0"},"repository":{"type":"git","url":"git+https://github.com/aegis-sdk/aegis.git","directory":"packages/express"},"engines":{"node":">=18.0.0"},"sideEffects":false,"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@aegis-sdk/express@0.5.0","bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"homepage":"https://github.com/aegis-sdk/aegis#readme","_integrity":"sha512-2oUp548kbaeG8O0ZYL+AjoZ8ypAuESj+0+94XnlyOGnT++BuF6UCAmylE7Nm7H/EUmW0cu/P0HDF84ohzyLeew==","_resolved":"/tmp/cfb7160af8c098408d9e51c23d6cdda6/aegis-sdk-express-0.5.0.tgz","_from":"file:aegis-sdk-express-0.5.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-2oUp548kbaeG8O0ZYL+AjoZ8ypAuESj+0+94XnlyOGnT++BuF6UCAmylE7Nm7H/EUmW0cu/P0HDF84ohzyLeew==","shasum":"0fd26882bf80f98f2dd6d64034d516a0a7d34fe2","tarball":"https://registry.npmjs.org/@aegis-sdk/express/-/express-0.5.0.tgz","fileCount":9,"unpackedSize":57351,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCaOWPkB2MWp3/rAfv4pIfa8eEyTB0DDG7yIybXX7GVlgIhANXam0/SND8pCXLoG2NhyCWNKPwryMGx2N7i2ZpZ6Nun"}]},"_npmUser":{"name":"msjoshlopez","email":"josh@memberstack.com"},"directories":{},"maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/express_0.5.0_1771972389620_0.6606016051105268"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-17T23:21:55.907Z","modified":"2026-02-24T22:33:09.905Z","0.1.0":"2026-02-17T23:21:56.159Z","0.2.0":"2026-02-17T23:48:20.147Z","0.3.0":"2026-02-18T05:57:52.687Z","0.5.0":"2026-02-24T22:33:09.766Z"},"bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"license":"MIT","homepage":"https://github.com/aegis-sdk/aegis#readme","repository":{"type":"git","url":"git+https://github.com/aegis-sdk/aegis.git","directory":"packages/express"},"description":"Express middleware adapter for Aegis prompt injection defense","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"readme":"# @aegis-sdk/express\n\nExpress middleware for scanning LLM chat messages against prompt injection attacks.\n\nPart of the [Aegis.js](https://github.com/aegis-sdk/Aegis) prompt injection defense toolkit.\n\n## Installation\n\n```bash\nnpm install @aegis-sdk/express @aegis-sdk/core\n```\n\n## Quick Start\n\n```ts\nimport express from 'express';\nimport { aegisMiddleware } from '@aegis-sdk/express';\n\nconst app = express();\napp.use(express.json());\n\napp.post('/api/chat', aegisMiddleware({ policy: 'strict' }), (req, res) => {\n  const { messages, instance } = req.aegis; // scanned messages\n  // pass messages to your LLM\n  res.json({ reply: '...' });\n});\n\napp.listen(3000);\n```\n\n## API\n\n### `aegisMiddleware(options?)`\n\nCreates Express middleware that reads `req.body.messages`, runs them through `aegis.guardInput()`, and attaches the safe messages to `req.aegis`. Returns 403 with violation details if input is blocked.\n\nAccepts either an `AegisConfig` directly or an `AegisMiddlewareOptions` object:\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `aegis` | `AegisConfig \\| Aegis` | `{}` | Aegis configuration or pre-constructed instance |\n| `messagesProperty` | `string` | `\"messages\"` | Property on `req.body` to read messages from |\n| `scanStrategy` | `ScanStrategy` | `\"last-user\"` | Which messages to scan |\n| `onBlocked` | `(req, res, error) => boolean` | -- | Custom error handler. Return `true` to take over the response |\n\n### `aegisStreamTransform(configOrInstance?)`\n\nReturns a `TransformStream<string, string>` that monitors LLM output tokens for injection payloads, PII leaks, and canary token leaks.\n\n```ts\nconst transform = aegisStreamTransform(aegis);\nconst monitoredStream = llmStream.pipeThrough(transform);\n```\n\n### `guardMessages(aegis, messages, options?)`\n\nScans messages directly without using the middleware. Useful for WebSocket handlers or custom middleware chains. Throws `AegisInputBlocked` if input is blocked.\n\n```ts\nimport { Aegis } from '@aegis-sdk/core';\nimport { guardMessages } from '@aegis-sdk/express';\n\nconst aegis = new Aegis({ policy: 'strict' });\nconst safe = await guardMessages(aegis, messages);\n```\n\n### Re-exports\n\n`Aegis`, `AegisInputBlocked`, `AegisSessionQuarantined`, `AegisSessionTerminated`, and all core types are re-exported for convenience.\n\n## Learn More\n\n- [Documentation](https://aegis-sdk.github.io/Aegis/)\n- [GitHub](https://github.com/aegis-sdk/Aegis)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}