{"_id":"@aegis-sdk/next","_rev":"3-803e462c07d6f2024288d345d99a0d6e","name":"@aegis-sdk/next","dist-tags":{"latest":"0.5.0"},"versions":{"0.2.0":{"name":"@aegis-sdk/next","version":"0.2.0","license":"MIT","_id":"@aegis-sdk/next@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":"365063848aaf7fb0343a041cc41545099cc8a015","tarball":"https://registry.npmjs.org/@aegis-sdk/next/-/next-0.2.0.tgz","fileCount":8,"integrity":"sha512-Zh66IEjbpveJR95NMlxpARP4adAiDLiFPkk/GZ/T5kinz7dfmuxfN58Bdm+zB/uN9pcHNpcb90GsV8zXkOaLQA==","signatures":[{"sig":"MEQCIHJ5XCL2BjJQYDIZaNSZkeSyhvXbRNGQjyF6t8KNQSQqAiAYLFDl12BD8pVCNSMxnApG/o8o0gBplR0F9KhvgZS+Cw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":77445},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-next-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/a0b9b99508f2113742827eeaf4cc087e/aegis-sdk-next-0.2.0.tgz","_integrity":"sha512-Zh66IEjbpveJR95NMlxpARP4adAiDLiFPkk/GZ/T5kinz7dfmuxfN58Bdm+zB/uN9pcHNpcb90GsV8zXkOaLQA==","repository":{"url":"git+https://github.com/aegis-sdk/aegis.git","type":"git","directory":"packages/next"},"_npmVersion":"10.9.4","description":"Next.js integration for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.2.0"},"_hasShrinkwrap":false,"peerDependencies":{"next":">=13.0.0","@aegis-sdk/core":"0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/next_0.2.0_1771372100332_0.07953987197326695","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@aegis-sdk/next","version":"0.3.0","license":"MIT","_id":"@aegis-sdk/next@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":"af6b194a1bdb4fd0ec6d566f015722851a3999b9","tarball":"https://registry.npmjs.org/@aegis-sdk/next/-/next-0.3.0.tgz","fileCount":8,"integrity":"sha512-60sfJ6Fgu2d5nehYbeMrQArXNio9IEXkajPvl4p4GrJCOIUBX/akN817U7UHEQhbjOoOLA84jw1TF1hVvS9q6w==","signatures":[{"sig":"MEYCIQCDc9ueKQhWUiNH/8bPoquCpAqC07/8MkeopAk10cfS2AIhAKbBstkLMFJoIkgGHc7qphHt8awE4Su5Q3F3TzlXmP49","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":77445},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-next-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/3150bbac1814df91f1740dc30a2a3db4/aegis-sdk-next-0.3.0.tgz","_integrity":"sha512-60sfJ6Fgu2d5nehYbeMrQArXNio9IEXkajPvl4p4GrJCOIUBX/akN817U7UHEQhbjOoOLA84jw1TF1hVvS9q6w==","repository":{"url":"git+https://github.com/aegis-sdk/aegis.git","type":"git","directory":"packages/next"},"_npmVersion":"10.9.4","description":"Next.js integration for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.3.0"},"_hasShrinkwrap":false,"peerDependencies":{"next":">=13.0.0","@aegis-sdk/core":"0.3.0"},"_npmOperationalInternal":{"tmp":"tmp/next_0.3.0_1771394272587_0.026362948539115694","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@aegis-sdk/next","version":"0.5.0","description":"Next.js integration 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":{"next":">=13.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/next"},"engines":{"node":">=18.0.0"},"sideEffects":false,"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@aegis-sdk/next@0.5.0","bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"homepage":"https://github.com/aegis-sdk/aegis#readme","_integrity":"sha512-SteGtGP5GuRcrTX6TPWRLrQdtifw5l5PXWuEd1FYiRBWfG/S84lUa7S4Tmywd4QswpHjy5CdqQz4YZysyARSew==","_resolved":"/tmp/6812c04b54655181d8eb8513bb1efdf9/aegis-sdk-next-0.5.0.tgz","_from":"file:aegis-sdk-next-0.5.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-SteGtGP5GuRcrTX6TPWRLrQdtifw5l5PXWuEd1FYiRBWfG/S84lUa7S4Tmywd4QswpHjy5CdqQz4YZysyARSew==","shasum":"20d42873bce67c631aa27f43a9ac90f3c5392e1f","tarball":"https://registry.npmjs.org/@aegis-sdk/next/-/next-0.5.0.tgz","fileCount":9,"unpackedSize":80447,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDu5jqvxhzESrW+paqZIopwO4ZvNidLsREEb4tKdvNOeAIhAPn+rJUsus7wQXl6bmJ4Jpx9AxXmkm9/WDB36xEaboeW"}]},"_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/next_0.5.0_1771972393507_0.5031139389304062"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-17T23:48:20.231Z","modified":"2026-02-24T22:33:13.768Z","0.2.0":"2026-02-17T23:48:20.469Z","0.3.0":"2026-02-18T05:57:52.745Z","0.5.0":"2026-02-24T22:33:13.643Z"},"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/next"},"description":"Next.js integration for Aegis prompt injection defense","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"readme":"# @aegis-sdk/next\n\nNext.js integration 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/next @aegis-sdk/core\n```\n\n## Quick Start\n\n```ts\n// app/api/chat/route.ts\nimport { Aegis } from '@aegis-sdk/core';\nimport { withAegis } from '@aegis-sdk/next';\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk/openai';\n\nconst aegis = new Aegis({ policy: 'strict' });\n\nexport const POST = withAegis(aegis, async (req, safeMessages) => {\n  const result = streamText({\n    model: openai('gpt-4o'),\n    messages: safeMessages,\n  });\n  return result.toDataStreamResponse();\n});\n```\n\n## API\n\n### `withAegis(aegisOrConfig, handler, options?)`\n\nHigher-order function that wraps a Next.js App Router route handler. Parses the request body, scans messages through `aegis.guardInput()`, and passes safe messages to your handler. Returns 403 with violation details if input is blocked.\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `messagesProperty` | `string` | `\"messages\"` | Property on the request body to read messages from |\n| `scanStrategy` | `ScanStrategy` | `\"last-user\"` | Which messages to scan |\n| `onBlocked` | `(req, error) => Response` | -- | Custom error handler. Return a `Response` to take over |\n\nYour handler receives `(req, safeMessages, { instance, auditLog })`.\n\n### `aegisMiddleware(options?)`\n\nCreates a Next.js Edge Middleware function for request-level scanning. Designed for use in `middleware.ts` at the project root.\n\n```ts\n// middleware.ts\nimport { aegisMiddleware } from '@aegis-sdk/next';\n\nconst aegisMw = aegisMiddleware({\n  aegis: { policy: 'strict' },\n  matchRoutes: ['/api/chat', '/api/ai'],\n});\n\nexport async function middleware(req: Request) {\n  return aegisMw(req);\n}\n\nexport const config = {\n  matcher: ['/api/chat/:path*', '/api/ai/:path*'],\n};\n```\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `aegis` | `AegisConfig \\| Aegis` | `{}` | Aegis configuration or pre-constructed instance |\n| `matchRoutes` | `(string \\| RegExp)[]` | -- | Route patterns to scan. If omitted, all POST requests are scanned |\n| `messagesProperty` | `string` | `\"messages\"` | Property on the request body to read messages from |\n| `scanStrategy` | `ScanStrategy` | `\"last-user\"` | Which messages to scan |\n| `onBlocked` | `(req, error) => Response` | -- | Custom error handler |\n\n### `guardMessages(aegis, messages, options?)`\n\nScans messages directly without using `withAegis` or Edge Middleware. Useful in Server Actions, custom API routes, or WebSocket handlers. 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"}