@promptshield/sanitizer
Advanced tools
+2
-2
@@ -1,2 +0,2 @@ | ||
| "use strict";var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var F=(t,r)=>{for(var o in r)u(t,o,{get:r[o],enumerable:!0})},f=(t,r,o,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of E(r))!h.call(t,a)&&a!==o&&u(t,a,{get:()=>r[a],enumerable:!(i=g(r,a))||i.enumerable});return t};var R=t=>f(u({},"__esModule",{value:!0}),t);var C={};F(C,{applyFixes:()=>x,sanitize:()=>d,sanitizeStrict:()=>k});module.exports=R(C);var l=require("@promptshield/core"),x=(t,r)=>{if(!r.length)return{text:t,fixed:[],skipped:[]};let o=[...r].sort((e,n)=>n.range.start.index-e.range.start.index),i=[],a=[],s=t;for(let e of o){let n=e.range.start.index,c=e.range.end.index,p=e.offendingText;if(!(n<0||!p))switch(e.category){case l.ThreatCategory.Invisible:case l.ThreatCategory.Trojan:s=s.slice(0,n)+s.slice(c),i.push(e);break;case l.ThreatCategory.Smuggling:e.readableLabel?.startsWith("[Hidden Comment]")||e.readableLabel?.startsWith("[Empty Link]")?(s=s.slice(0,n)+s.slice(c),i.push(e)):e.readableLabel?.startsWith("[Hidden HTML]")?(s=s.slice(0,n)+p.replace(/<(details|template)\b[^>]{0,2000}>/gi,"").replace(/<\/(details|template)>/gi,"")+s.slice(c),i.push(e)):e.readableLabel?.startsWith("[Base64]: ")||e.readableLabel?.startsWith("[HEX]: ")?(s=s.slice(0,n)+(e.decodedPayload??"")+s.slice(c),i.push(e)):a.push(e);break;case l.ThreatCategory.Injection:a.push(e);break;case l.ThreatCategory.Normalization:s=s.slice(0,n)+p.normalize("NFKC")+s.slice(c),i.push(e);break;default:a.push(e)}}return{text:s,fixed:i,skipped:a}};var b=/\uFEFF/g,m=/([\u200B-\u200D\u2060\u00AD\u3164\uFFA0]|[\u{E0000}-\u{E007F}])/gu,T=/[\uFE00-\uFE0F]/g,I=/<!--[\s\S]*?-->/g,L=/\[\]\([^)]*\)/g,N=/[\u00A0\u2000-\u200A\u202F\u205F\u3000\uFF01-\uFF5E]/g,_=/\r\n?/g,A=t=>t.normalize("NFKC"),d=t=>t.replace(_,` | ||
| `).replace(b,"").replace(m,"").replace(T,"").replace(I,"").replace(L,"").replace(N,A),k=t=>d(t).normalize("NFKC");0&&(module.exports={applyFixes,sanitize,sanitizeStrict}); | ||
| "use strict";var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var F=(t,s)=>{for(var a in s)u(t,a,{get:s[a],enumerable:!0})},x=(t,s,a,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of E(s))!h.call(t,i)&&i!==a&&u(t,i,{get:()=>s[i],enumerable:!(n=g(s,i))||n.enumerable});return t};var f=t=>x(u({},"__esModule",{value:!0}),t);var C={};F(C,{applyFixes:()=>R,sanitize:()=>d,sanitizeStrict:()=>k});module.exports=f(C);var l=require("@promptshield/core"),R=(t,s)=>{if(!s.length)return{text:t,fixed:[],skipped:[]};let a=[...s].sort((e,o)=>o.range.start.index-e.range.start.index),n=[],i=[],r=t;for(let e of a){let o=e.range.start.index,c=e.range.end.index,p=e.offendingText;if(!(o<0||!p))switch(e.category){case l.ThreatCategory.Invisible:case l.ThreatCategory.Trojan:r=r.slice(0,o)+r.slice(c),n.push(e);break;case l.ThreatCategory.Smuggling:e.readableLabel?.startsWith("[Hidden Comment]")||e.readableLabel?.startsWith("[Empty Link]")?(r=r.slice(0,o)+r.slice(c),n.push(e)):e.readableLabel?.startsWith("[Hidden HTML]")?(r=r.slice(0,o)+p.replace(/<(details|template)\b[^>]{0,2000}>/gi,"").replace(/<\/(details|template)>/gi,"")+r.slice(c),n.push(e)):e.readableLabel?.startsWith("[Base64]: ")||e.readableLabel?.startsWith("[HEX]: ")?(r=r.slice(0,o)+(e.decodedPayload??"")+r.slice(c),n.push(e)):i.push(e);break;case l.ThreatCategory.Injection:i.push(e);break;case l.ThreatCategory.Normalization:r=r.slice(0,o)+p.normalize("NFKC")+r.slice(c),n.push(e);break;default:i.push(e)}}return{text:r,fixed:n,skipped:i}};var T=/\uFEFF/g,b=/([\u200B-\u200D\u2060\u00AD\u3164\uFFA0]|[\u{E0000}-\u{E007F}])/gu,m=/[\uFE00-\uFE0F]/g,I=/<!--[\s\S]*?-->/g,L=/\[\]\([^)]*\)/g,N=/[\u00A0\u2000-\u200A\u202F\u205F\u3000\uFF01-\uFF5E]/g,_=/\r\n?/g,A=t=>t.normalize("NFKC"),d=t=>{let s,a=t.replace(_,` | ||
| `).replace(T,"");do s=a,a=a.replace(b,"").replace(m,"").replace(I,"").replace(L,"");while(a!==s);return a.replace(N,A).replace("<!--","").replace("-->","")},k=t=>d(t).normalize("NFKC");0&&(module.exports={applyFixes,sanitize,sanitizeStrict}); |
+2
-2
@@ -1,2 +0,2 @@ | ||
| import{a as g}from"./chunk-E4AHFVE2.mjs";var e=/\uFEFF/g,t=/([\u200B-\u200D\u2060\u00AD\u3164\uFFA0]|[\u{E0000}-\u{E007F}])/gu,n=/[\uFE00-\uFE0F]/g,r=/<!--[\s\S]*?-->/g,u=/\[\]\([^)]*\)/g,o=/[\u00A0\u2000-\u200A\u202F\u205F\u3000\uFF01-\uFF5E]/g,s=/\r\n?/g,c=E=>E.normalize("NFKC"),F=E=>E.replace(s,` | ||
| `).replace(e,"").replace(t,"").replace(n,"").replace(r,"").replace(u,"").replace(o,c),i=E=>F(E).normalize("NFKC");export{g as applyFixes,F as sanitize,i as sanitizeStrict}; | ||
| import{a as l}from"./chunk-E4AHFVE2.mjs";var E=/\uFEFF/g,n=/([\u200B-\u200D\u2060\u00AD\u3164\uFFA0]|[\u{E0000}-\u{E007F}])/gu,u=/[\uFE00-\uFE0F]/g,c=/<!--[\s\S]*?-->/g,o=/\[\]\([^)]*\)/g,s=/[\u00A0\u2000-\u200A\u202F\u205F\u3000\uFF01-\uFF5E]/g,F=/\r\n?/g,i=e=>e.normalize("NFKC"),g=e=>{let t,r=e.replace(F,` | ||
| `).replace(E,"");do t=r,r=r.replace(n,"").replace(u,"").replace(c,"").replace(o,"");while(r!==t);return r.replace(s,i).replace("<!--","").replace("-->","")},a=e=>g(e).normalize("NFKC");export{l as applyFixes,g as sanitize,a as sanitizeStrict}; |
+1
-1
@@ -5,3 +5,3 @@ { | ||
| "private": false, | ||
| "version": "0.0.2", | ||
| "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.", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18666
0.86%4
-20%