{"_id":"@aegis-sdk/fastify","_rev":"2-42560b35f08bff6986b96e68742005f7","name":"@aegis-sdk/fastify","dist-tags":{"latest":"0.5.0"},"versions":{"0.3.0":{"name":"@aegis-sdk/fastify","version":"0.3.0","license":"MIT","_id":"@aegis-sdk/fastify@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":"fa16a7f5c2c0f58989b7fab3d47845123d61e88c","tarball":"https://registry.npmjs.org/@aegis-sdk/fastify/-/fastify-0.3.0.tgz","fileCount":8,"integrity":"sha512-tiYlJFaZPFft+EFFUyoZYuAhsSb8KbEouJphWLSKTT1Od71CpfE+4oi2k6xrcqJ2LcFhepYI0ZgLX2NeYShUqQ==","signatures":[{"sig":"MEUCIQCb5+kEkmZtbX0C8x9m26pfwHBuk2t6hMKMV0VPxQSB8QIgeMAVWJmaAJN+xA8lXC72zU0YegSjF26VnhNSMKOiwL4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":61159},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-fastify-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/66e3c48fe283862b007c69a84ca19509/aegis-sdk-fastify-0.3.0.tgz","_integrity":"sha512-tiYlJFaZPFft+EFFUyoZYuAhsSb8KbEouJphWLSKTT1Od71CpfE+4oi2k6xrcqJ2LcFhepYI0ZgLX2NeYShUqQ==","repository":{"url":"git+https://github.com/aegis-sdk/aegis.git","type":"git","directory":"packages/fastify"},"_npmVersion":"10.9.4","description":"Fastify plugin adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.3.0"},"_hasShrinkwrap":false,"peerDependencies":{"fastify":">=4.0.0","@aegis-sdk/core":"0.3.0"},"_npmOperationalInternal":{"tmp":"tmp/fastify_0.3.0_1771394273075_0.49572687476407684","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@aegis-sdk/fastify","version":"0.5.0","description":"Fastify plugin 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":{"fastify":">=4.0.0","@aegis-sdk/core":"0.5.0"},"dependencies":{"@aegis-sdk/core":"0.5.0"},"repository":{"type":"git","url":"git+https://github.com/aegis-sdk/aegis.git","directory":"packages/fastify"},"engines":{"node":">=18.0.0"},"sideEffects":false,"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@aegis-sdk/fastify@0.5.0","bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"homepage":"https://github.com/aegis-sdk/aegis#readme","_integrity":"sha512-pZdAng5jCa2VbiCz5pRScNg33e5djW2ZiUw2Ktc3EOX8LwVibzqMI0zGGTxCVb2O9uDOsCIHkU3XUqvL8OfxzQ==","_resolved":"/tmp/5442cecaa85e06bfe1e02999bdc0b1e2/aegis-sdk-fastify-0.5.0.tgz","_from":"file:aegis-sdk-fastify-0.5.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-pZdAng5jCa2VbiCz5pRScNg33e5djW2ZiUw2Ktc3EOX8LwVibzqMI0zGGTxCVb2O9uDOsCIHkU3XUqvL8OfxzQ==","shasum":"7e645fa4af617bc5705f6b9fa2e6df9e686c832e","tarball":"https://registry.npmjs.org/@aegis-sdk/fastify/-/fastify-0.5.0.tgz","fileCount":9,"unpackedSize":63543,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIA4AQyaOC2pH1iCGMPb86EWvIbKVsQHmK78SyJR+vIDzAiEAtZRavdFP1CmHfqx2S+hSiNFLLi6QWob8SCPz8QMJ1+M="}]},"_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/fastify_0.5.0_1771972389672_0.35166369600500014"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T05:57:52.960Z","modified":"2026-02-24T22:33:09.957Z","0.3.0":"2026-02-18T05:57:53.267Z","0.5.0":"2026-02-24T22:33:09.829Z"},"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/fastify"},"description":"Fastify plugin adapter for Aegis prompt injection defense","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"readme":"# @aegis-sdk/fastify\n\nFastify plugin 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/fastify @aegis-sdk/core\n```\n\n## Quick Start\n\n```ts\nimport Fastify from 'fastify';\nimport { aegisPlugin } from '@aegis-sdk/fastify';\n\nconst app = Fastify();\n\napp.register(aegisPlugin, {\n  aegis: { policy: 'strict' },\n  routes: ['/api/chat'],\n});\n\napp.post('/api/chat', async (request, reply) => {\n  const { messages, instance } = request.aegis; // scanned messages\n  // pass messages to your LLM\n  return { reply: '...' };\n});\n\napp.listen({ port: 3000 });\n```\n\n## API\n\n### `aegisPlugin`\n\nFastify plugin that registers a `preHandler` hook. The hook reads messages from the request body, runs them through `aegis.guardInput()`, and attaches the safe messages to `request.aegis`. Returns 403 with violation details if input is blocked.\n\nRegister it with `app.register(aegisPlugin, options)`:\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `aegis` | `AegisConfig \\| Aegis` | `{}` | Aegis configuration or pre-constructed instance |\n| `routes` | `(string \\| RegExp)[]` | -- | Routes to protect. If omitted, all POST requests are scanned |\n| `methods` | `string[]` | `[\"POST\"]` | HTTP methods to scan |\n| `messagesProperty` | `string` | `\"messages\"` | Property on the request body to read messages from |\n| `scanStrategy` | `ScanStrategy` | `\"last-user\"` | Which messages to scan |\n| `onBlocked` | `(request, reply, error) => unknown` | -- | Custom error handler. Return truthy to take over the response |\n\nAccess scan results in your handler via `request.aegis`, which returns `{ messages, instance, auditLog }`.\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### `guardMessages(aegis, messages, options?)`\n\nScans messages directly without using the plugin. Throws `AegisInputBlocked` if input is blocked.\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"}