{"_id":"@aegis-sdk/sveltekit","_rev":"2-9e459c36bce2a2b3b9d6fd8050fe8d5e","name":"@aegis-sdk/sveltekit","dist-tags":{"latest":"0.5.0"},"versions":{"0.3.0":{"name":"@aegis-sdk/sveltekit","version":"0.3.0","license":"MIT","_id":"@aegis-sdk/sveltekit@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":"e804041e4eb260128b457a75882e2942c7b57809","tarball":"https://registry.npmjs.org/@aegis-sdk/sveltekit/-/sveltekit-0.3.0.tgz","fileCount":8,"integrity":"sha512-h3+NUqybyBQktO2YqfcMCNbHrWwQHgW6TrENScTUtdEXNyX1bMQsX2IS2oyzImzak8Pg0rj31B3eWLywgPhJAw==","signatures":[{"sig":"MEYCIQC10JlalwEeNVCl8RqoSVGHUa49lf8ZV5/0T9rAqnLxegIhALXZGTAblJkKG+/wjRueN3/7i84sDgq9GhueCD8nt11g","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":62020},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-sveltekit-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/9112b96f57574c40f35537043f84c2c4/aegis-sdk-sveltekit-0.3.0.tgz","_integrity":"sha512-h3+NUqybyBQktO2YqfcMCNbHrWwQHgW6TrENScTUtdEXNyX1bMQsX2IS2oyzImzak8Pg0rj31B3eWLywgPhJAw==","repository":{"url":"git+https://github.com/aegis-sdk/aegis.git","type":"git","directory":"packages/sveltekit"},"_npmVersion":"10.9.4","description":"SvelteKit hooks and handle adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.3.0"},"_hasShrinkwrap":false,"peerDependencies":{"@sveltejs/kit":">=2.0.0","@aegis-sdk/core":"0.3.0"},"peerDependenciesMeta":{"@sveltejs/kit":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sveltekit_0.3.0_1771394278792_0.8015070299027671","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@aegis-sdk/sveltekit","version":"0.5.0","description":"SvelteKit hooks and handle 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":{"@sveltejs/kit":">=2.0.0","@aegis-sdk/core":"0.5.0"},"peerDependenciesMeta":{"@sveltejs/kit":{"optional":true}},"dependencies":{"@aegis-sdk/core":"0.5.0"},"repository":{"type":"git","url":"git+https://github.com/aegis-sdk/aegis.git","directory":"packages/sveltekit"},"engines":{"node":">=18.0.0"},"sideEffects":false,"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@aegis-sdk/sveltekit@0.5.0","bugs":{"url":"https://github.com/aegis-sdk/aegis/issues"},"homepage":"https://github.com/aegis-sdk/aegis#readme","_integrity":"sha512-FgZ/QlMPb7UVYo7nkeiV/qQeUHrIzmeLVd3GlPZ0T/KZI1Q8IiormuA/2vpuwhMlAStHic26NQt/nkinK38/kg==","_resolved":"/tmp/c55b0f90b7bdf0c6623ea1b7b4a56e03/aegis-sdk-sveltekit-0.5.0.tgz","_from":"file:aegis-sdk-sveltekit-0.5.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-FgZ/QlMPb7UVYo7nkeiV/qQeUHrIzmeLVd3GlPZ0T/KZI1Q8IiormuA/2vpuwhMlAStHic26NQt/nkinK38/kg==","shasum":"ff5d6cd3187923a2dbb685a82bd074a5e8eea9c1","tarball":"https://registry.npmjs.org/@aegis-sdk/sveltekit/-/sveltekit-0.5.0.tgz","fileCount":9,"unpackedSize":65020,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE3SpebB3k77aWAE0clWfh0Hwt7IdWqbo4siTjevGc8NAiEAikKwTBGI//Ssx6X0LL8j/hMIPoMoE6IUMr/Zh+s3Ap8="}]},"_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/sveltekit_0.5.0_1771972393700_0.8758780026093429"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T05:57:58.714Z","modified":"2026-02-24T22:33:14.001Z","0.3.0":"2026-02-18T05:57:58.935Z","0.5.0":"2026-02-24T22:33:13.871Z"},"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/sveltekit"},"description":"SvelteKit hooks and handle adapter for Aegis prompt injection defense","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"readme":"# @aegis-sdk/sveltekit\n\nSvelteKit handle hook 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/sveltekit @aegis-sdk/core\n```\n\n## Quick Start\n\n```ts\n// src/hooks.server.ts\nimport { sequence } from '@sveltejs/kit/hooks';\nimport { aegisHandle } from '@aegis-sdk/sveltekit';\n\nconst aegis = aegisHandle({\n  aegis: { policy: 'strict' },\n  routes: ['/api/chat'],\n});\n\nexport const handle = sequence(aegis);\n```\n\nThen access the scanned messages in your API route:\n\n```ts\n// src/routes/api/chat/+server.ts\nimport type { RequestHandler } from './$types';\n\nexport const POST: RequestHandler = async ({ locals }) => {\n  const { messages, instance, auditLog } = locals.aegis;\n  // messages are scanned and safe to forward to your LLM\n  return new Response(JSON.stringify({ reply: '...' }));\n};\n```\n\n## API\n\n### `aegisHandle(options?)`\n\nCreates a SvelteKit `Handle` function that scans incoming POST request bodies through `aegis.guardInput()` and attaches safe messages to `event.locals.aegis`. Returns 403 with violation details if input is blocked. Non-POST requests and routes not matching the filter are passed through without scanning.\n\nAccepts either an `AegisConfig` directly or an `AegisHandleOptions` object:\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| `messagesProperty` | `string` | `\"messages\"` | Property on the request body to read messages from |\n| `scanStrategy` | `ScanStrategy` | `\"last-user\"` | Which messages to scan |\n| `onBlocked` | `(event, error) => Response` | -- | Custom error handler. Return a `Response` to take over |\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\n// src/routes/api/chat/+server.ts\nimport { aegisStreamTransform } from '@aegis-sdk/sveltekit';\n\nexport const POST: RequestHandler = async ({ locals }) => {\n  const transform = aegisStreamTransform(locals.aegis.instance);\n  const monitoredStream = llmStream.pipeThrough(transform);\n  return new Response(monitoredStream, {\n    headers: { 'Content-Type': 'text/event-stream' },\n  });\n};\n```\n\n### `guardMessages(aegis, messages, options?)`\n\nScans messages directly without using the handle hook. Useful in form actions, WebSocket handlers, or custom server routes. 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"}