{"_id":"@promptshield/sanitizer","_rev":"4-024da612b295e051c8f1231a689d8136","name":"@promptshield/sanitizer","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.0":{"name":"@promptshield/sanitizer","version":"0.0.0","keywords":["promptshield","prompt-security","prompt-injection","sanitizer","text-sanitization","llm-security","ai-security","unicode-security","markdown-security","invisible-characters","bom","secure-prompts","prompt-hygiene","content-sanitizer","cli-security","@promptshield/sanitizer","turbo-forge","security","prompt-injection","llm","ai"],"author":{"name":"Mayank Kumar Chaudhari","email":"https://mayankchaudhari.com"},"license":"MIT","_id":"@promptshield/sanitizer@0.0.0","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"homepage":"https://github.com/promptshield-io/promptshield/blob/main/packages/sanitizer/README.md","bugs":{"url":"https://github.com/promptshield-io/promptshield/issues"},"dist":{"shasum":"f706882133eda1fe014e80b52fadde1a2f08c7a6","tarball":"https://registry.npmjs.org/@promptshield/sanitizer/-/sanitizer-0.0.0.tgz","fileCount":12,"integrity":"sha512-npt1diFkKRLcegTxMB+bXUCi7S8z/TC0a+mcy1uvI3iGR/NvdHZ8lJNLBfZigFmUJkqd2EBzVn+QWRTJtMbu/w==","signatures":[{"sig":"MEUCIE77KJm1uolHqx3+ocf1PRPVf9drfxrI7852fcGk3Q1GAiEA3WfQ7QI2ZfQ5eW4Zl7wsOshhtLOk7n60PifsuJs2ZbQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14109},"main":"./dist/index.js","_from":"file:promptshield-sanitizer-0.0.0.tgz","forge":{"icon":"Shield","aliases":["@ghostbuster/sanitizer"]},"types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./fix":{"import":{"types":"./dist/fix.d.mts","default":"./dist/fix.mjs"},"require":{"types":"./dist/fix.d.ts","default":"./dist/fix.js"}},"./package.json":"./package.json"},"funding":[{"url":"https://github.com/sponsors/promptshield-io","type":"github"},{"url":"https://github.com/sponsors/mayank1513","type":"github"}],"private":false,"scripts":{"dev":"tsup --watch","build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"_resolved":"/tmp/64fc7895ed0099019494b30e12e6f359/promptshield-sanitizer-0.0.0.tgz","_integrity":"sha512-npt1diFkKRLcegTxMB+bXUCi7S8z/TC0a+mcy1uvI3iGR/NvdHZ8lJNLBfZigFmUJkqd2EBzVn+QWRTJtMbu/w==","repository":{"url":"git+https://github.com/promptshield-io/promptshield.git","type":"git","directory":"packages/sanitizer"},"_npmVersion":"10.9.4","description":"PromptShield sanitizer that applies safe, deterministic fixes to text based on detected prompt-injection threats such as invisible characters, markdown smuggling, and BOM artifacts.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@promptshield/core":"0.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/sanitizer_0.0.0_1771750157347_0.33426146999437445","host":"s3://npm-registry-packages-npm-production"}},"0.0.1":{"name":"@promptshield/sanitizer","version":"0.0.1","keywords":["promptshield","prompt-security","prompt-injection","sanitizer","text-sanitization","llm-security","ai-security","unicode-security","markdown-security","invisible-characters","bom","secure-prompts","prompt-hygiene","content-sanitizer","cli-security","@promptshield/sanitizer","turbo-forge","security","prompt-injection","llm","ai"],"author":{"name":"Mayank Kumar Chaudhari","email":"https://mayankchaudhari.com"},"license":"MIT","_id":"@promptshield/sanitizer@0.0.1","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"homepage":"https://github.com/promptshield-io/promptshield/blob/main/packages/sanitizer/README.md","bugs":{"url":"https://github.com/promptshield-io/promptshield/issues"},"dist":{"shasum":"fc6e8fc398fe7ebe35bdf8872a197d5619e5232a","tarball":"https://registry.npmjs.org/@promptshield/sanitizer/-/sanitizer-0.0.1.tgz","fileCount":12,"integrity":"sha512-TAQm8ucyPTj4zf1w2H1+RbePCz9ilsDK/Hw1ledsIjJMpsIDZc0dtRH3VCmX3NO+OmSw9PEI9TTQH6rlHYh0VQ==","signatures":[{"sig":"MEQCIEVTR7tsiJY5K6OvwfqVuomUMlnpch/XGuPXZpKNU4zeAiAKeOOtY5flDuYCIFNvc+swZjGw5oC0Bpr0hlfT/m/5cw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14403},"main":"./dist/index.js","_from":"file:promptshield-sanitizer-0.0.1.tgz","forge":{"icon":"Shield","aliases":["@ghostbuster/sanitizer"]},"types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./fix":{"import":{"types":"./dist/fix.d.mts","default":"./dist/fix.mjs"},"require":{"types":"./dist/fix.d.ts","default":"./dist/fix.js"}},"./package.json":"./package.json"},"funding":[{"url":"https://github.com/sponsors/promptshield-io","type":"github"},{"url":"https://github.com/sponsors/mayank1513","type":"github"}],"private":false,"scripts":{"dev":"tsup --watch","build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"_resolved":"/tmp/e91879fa3571c89ba3897becf0ff5ff3/promptshield-sanitizer-0.0.1.tgz","_integrity":"sha512-TAQm8ucyPTj4zf1w2H1+RbePCz9ilsDK/Hw1ledsIjJMpsIDZc0dtRH3VCmX3NO+OmSw9PEI9TTQH6rlHYh0VQ==","repository":{"url":"git+https://github.com/promptshield-io/promptshield.git","type":"git","directory":"packages/sanitizer"},"_npmVersion":"10.9.4","description":"PromptShield sanitizer that applies safe, deterministic fixes to text based on detected prompt-injection threats such as invisible characters, markdown smuggling, and BOM artifacts.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@promptshield/core":"0.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/sanitizer_0.0.1_1772163696703_0.5983425975043677","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@promptshield/sanitizer","version":"0.0.2","keywords":["promptshield","prompt-security","prompt-injection","sanitizer","text-sanitization","llm-security","ai-security","unicode-security","markdown-security","invisible-characters","bom","secure-prompts","prompt-hygiene","content-sanitizer","cli-security","@promptshield/sanitizer","turbo-forge","security","prompt-injection","llm","ai"],"author":{"name":"Mayank Kumar Chaudhari","email":"https://mayankchaudhari.com"},"license":"MIT","_id":"@promptshield/sanitizer@0.0.2","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"homepage":"https://github.com/promptshield-io/promptshield/blob/main/packages/sanitizer/README.md","bugs":{"url":"https://github.com/promptshield-io/promptshield/issues"},"dist":{"shasum":"500abdc46cbfa153d39db0e3d5f0dff640970234","tarball":"https://registry.npmjs.org/@promptshield/sanitizer/-/sanitizer-0.0.2.tgz","fileCount":12,"integrity":"sha512-nQ5RoYF+1ZT3TexL8qqbVz4OqWq+qX+dvZI9pv3w99rp3G93cVONjHEFGqTgI3dsYsaNg/qdRmLvcRexLqTo1Q==","signatures":[{"sig":"MEUCIQCM4HhYLIAESYLSztqnLm6HsF62YobE3fe64t8g2le11QIgF7abWasJWGEuTF1HbPROw1K2IimuULOlKGNWcUD0ATM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18506},"main":"./dist/index.js","_from":"file:promptshield-sanitizer-0.0.2.tgz","forge":{"icon":"Shield","aliases":["@ghostbuster/sanitizer"],"description":"Deterministic threat stripper"},"types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./fix":{"import":{"types":"./dist/fix.d.mts","default":"./dist/fix.mjs"},"require":{"types":"./dist/fix.d.ts","default":"./dist/fix.js"}},"./package.json":"./package.json"},"funding":[{"url":"https://github.com/sponsors/promptshield-io","type":"github"},{"url":"https://github.com/sponsors/mayank1513","type":"github"}],"private":false,"scripts":{"dev":"tsup --watch","build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"_resolved":"/tmp/d4f58113ba2e8c961ef691446285256e/promptshield-sanitizer-0.0.2.tgz","_integrity":"sha512-nQ5RoYF+1ZT3TexL8qqbVz4OqWq+qX+dvZI9pv3w99rp3G93cVONjHEFGqTgI3dsYsaNg/qdRmLvcRexLqTo1Q==","repository":{"url":"git+https://github.com/promptshield-io/promptshield.git","type":"git","directory":"packages/sanitizer"},"_npmVersion":"10.9.4","description":"PromptShield sanitizer that applies safe, deterministic fixes to text based on detected prompt-injection threats such as invisible characters, markdown smuggling, and BOM artifacts.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@promptshield/core":"1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/sanitizer_0.0.2_1773059786278_0.8648824016171115","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@promptshield/sanitizer","author":{"name":"Mayank Kumar Chaudhari","email":"https://mayankchaudhari.com"},"private":false,"version":"1.0.0","description":"PromptShield sanitizer that applies safe, deterministic fixes to text based on detected prompt-injection threats such as invisible characters, markdown smuggling, and BOM artifacts.","license":"MIT","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./fix":{"import":{"types":"./dist/fix.d.mts","default":"./dist/fix.mjs"},"require":{"types":"./dist/fix.d.ts","default":"./dist/fix.js"}},"./package.json":"./package.json"},"repository":{"type":"git","url":"git+https://github.com/promptshield-io/promptshield.git","directory":"packages/sanitizer"},"bugs":{"url":"https://github.com/promptshield-io/promptshield/issues"},"homepage":"https://github.com/promptshield-io/promptshield/blob/main/packages/sanitizer/README.md","sideEffects":false,"devDependencies":{"@types/node":"latest","tsup":"latest","typescript":"latest"},"forge":{"aliases":["@ghostbuster/sanitizer"],"icon":"Shield","description":"Deterministic threat stripper"},"funding":[{"type":"github","url":"https://github.com/sponsors/promptshield-io"},{"type":"github","url":"https://github.com/sponsors/mayank1513"}],"keywords":["promptshield","prompt-security","prompt-injection","sanitizer","text-sanitization","llm-security","ai-security","unicode-security","markdown-security","invisible-characters","bom","secure-prompts","prompt-hygiene","content-sanitizer","cli-security","@promptshield/sanitizer","turbo-forge","security","prompt-injection","llm","ai"],"dependencies":{"@promptshield/core":"1.0.0"},"scripts":{"build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","dev":"tsup --watch","typecheck":"tsc --noEmit"},"_id":"@promptshield/sanitizer@1.0.0","_integrity":"sha512-pQ6uy33l7tgt7c0dgGZFPtsWkRA1nGVqnOxg2/IpjVVhaU42WMQFI+Fyeld8bnI0vX3dLqoWdCh8ghLNZqtJcg==","_resolved":"/tmp/967c2d21b428c405591290679c92d811/promptshield-sanitizer-1.0.0.tgz","_from":"file:promptshield-sanitizer-1.0.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-pQ6uy33l7tgt7c0dgGZFPtsWkRA1nGVqnOxg2/IpjVVhaU42WMQFI+Fyeld8bnI0vX3dLqoWdCh8ghLNZqtJcg==","shasum":"9484ad69aa11b042523f1ce87ef912be5cd447b5","tarball":"https://registry.npmjs.org/@promptshield/sanitizer/-/sanitizer-1.0.0.tgz","fileCount":12,"unpackedSize":18666,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHTjQMpPQYM0zqHhlSVDbT6sMjRSpWLXOLLBSmXcWLjnAiEAhlyCQ9ihlKFIbbVB2cjkijRbKyvjoVYKDdeFYsWVY0Y="}]},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"directories":{},"maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sanitizer_1.0.0_1773067374305_0.2232935075257958"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-22T08:49:17.254Z","modified":"2026-03-09T14:42:54.588Z","0.0.0":"2026-02-22T08:49:17.499Z","0.0.1":"2026-02-27T03:41:36.861Z","0.0.2":"2026-03-09T12:36:26.426Z","1.0.0":"2026-03-09T14:42:54.442Z"},"bugs":{"url":"https://github.com/promptshield-io/promptshield/issues"},"author":{"name":"Mayank Kumar Chaudhari","email":"https://mayankchaudhari.com"},"license":"MIT","homepage":"https://github.com/promptshield-io/promptshield/blob/main/packages/sanitizer/README.md","keywords":["promptshield","prompt-security","prompt-injection","sanitizer","text-sanitization","llm-security","ai-security","unicode-security","markdown-security","invisible-characters","bom","secure-prompts","prompt-hygiene","content-sanitizer","cli-security","@promptshield/sanitizer","turbo-forge","security","prompt-injection","llm","ai"],"repository":{"type":"git","url":"git+https://github.com/promptshield-io/promptshield.git","directory":"packages/sanitizer"},"description":"PromptShield sanitizer that applies safe, deterministic fixes to text based on detected prompt-injection threats such as invisible characters, markdown smuggling, and BOM artifacts.","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"readme":"# @promptshield/sanitizer <img src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 40px\"/>\n\n<img alt=\"PromptShield Banner\" src=\"https://raw.githubusercontent.com/promptshield-io/promptshield/main/banner.gif\" />\n\n<p className=\"flex gap-2\">\n  <a href=\"https://github.com/promptshield-io/promptshield/actions/workflows/ci.yml\" rel=\"noopener noreferrer\">\n    <img alt=\"CI\" src=\"https://github.com/promptshield-io/promptshield/actions/workflows/ci.yml/badge.svg\" />\n  </a>\n  <a href=\"https://codecov.io/gh/promptshield-io/promptshield/tree/main/packages/@promptshield/sanitizer\" rel=\"noopener noreferrer\">\n    <img alt=\"codecov\" src=\"https://codecov.io/gh/promptshield-io/promptshield/graph/badge.svg?flag=@promptshield/sanitizer\" />\n  </a> \n  <a href=\"https://npmjs.com/package/@promptshield/sanitizer\" rel=\"noopener noreferrer\">\n    <img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@promptshield/sanitizer\" />\n  </a>\n  <a href=\"https://npmjs.com/package/@promptshield/sanitizer\" rel=\"noopener noreferrer\">\n    <img alt=\"npm downloads\" src=\"https://img.shields.io/npm/d18m/@promptshield/sanitizer\" />\n  </a>\n  <a href=\"https://npmjs.com/package/@promptshield/sanitizer\" rel=\"noopener noreferrer\">\n    <img alt=\"npm bundle size\" src=\"https://img.shields.io/bundlephobia/minzip/@promptshield/sanitizer\" />\n  </a>\n  <img alt=\"license\" src=\"https://img.shields.io/npm/l/@promptshield/sanitizer\" />\n</p>\n\n> **Deterministic sanitizer** for prompt hygiene. Applies safe, idempotent text transformations to remove invisible threats and normalization artifacts.\n\n---\n\n## ✨ Features\n\n- **Safe Defaults**: Removes only objectively dangerous characters (BOM, ZWSP, control chars).\n- **Idempotent**: Running it twice produces the same result.\n- **Strict Mode**: Optional NFKC normalization for aggressive cleaning.\n- **Zero-Dependency**: Lightweight and fast.\n\n---\n\n## 📦 Installation\n\n```bash\n$ pnpm add @promptshield/sanitizer\n```\n\n---\n\n## 🚀 Usage\n\n<details>\n<summary>View complete usage and exact removal rules</summary>\n\n```ts\nimport { sanitize, sanitizeStrict } from \"@promptshield/sanitizer\";\n\nconst dirty = \"Hello\\u200BWorld\"; // Contains Zero-Width Space\n\n// Safe sanitize (removes invisible chars)\nconst clean = sanitize(dirty);\nconsole.log(clean); // \"HelloWorld\"\n\n// Strict sanitize (also applies NFKC normalization)\nconst strict = sanitizeStrict(\"ℍ𝕖𝕝𝕝𝕠\");\nconsole.log(strict); // \"Hello\"\n```\n\n### What gets removed?\n\n1.  **Invisible Characters**: `\\u200B` (ZWSP), `\\u200C` (ZWNJ), `\\u200D` (ZWJ), etc.\n2.  **Byte Order Marks**: `\\uFEFF`.\n3.  **Variation Selectors**: `\\uFE00`-`\\uFE0F` (often used to break tokenizers).\n4.  **Markdown Comments**: `<!-- hidden payload -->`.\n5.  **Empty Links**: `[](javascript:...)`.\n\n</details>\n\n> 📚 **Deep Dives**: For the exact execution order of the sanitization pipeline and understanding `applyFixes`, see the [Documentation section](https://promptshield.js.org/docs/sanitizer).\n\n---\n\n## License\n\nThis library is licensed under the MIT open-source license.\n\n<hr />\n\n<p align=\"center\">with 💖 by <a href=\"https://mayankchaudhari.com\" target=\"_blank\">Mayank Kumar Chaudhari</a></p>\n","readmeFilename":"README.md"}