@mwahaj36/robotcheck 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/widget.js +1 -1
  2. package/package.json +1 -1
package/dist/widget.js CHANGED
@@ -1 +1 @@
1
- (()=>{var g=(e,i)=>()=>(i||e((i={exports:{}}).exports,i),i.exports);var b=g((X,R)=>{var x=performance.now(),f={mousePath:[],clickTimings:[],loadToFirstMove:null,loadToFirstClick:null,tileSelectOrder:[],hoverDwellTimes:[],checkboxDelay:null,totalTime:null,pageHidden:!1,devicePixelRatio:window.devicePixelRatio,touchEvents:0},L=0;document.addEventListener("mousemove",function(e){let i=performance.now();f.loadToFirstMove===null&&(f.loadToFirstMove=i-x),i-L>16&&(f.mousePath.push({x:e.clientX,y:e.clientY,t:i}),L=i)});document.addEventListener("click",function(e){let i=performance.now();f.loadToFirstClick==null&&(f.loadToFirstClick=i-x),f.clickTimings.push(i)});document.addEventListener("touchstart",function(e){f.touchEvents++});document.addEventListener("visibilitychange",function(e){document.hidden&&(f.pageHidden=!0)});R.exports={signals:f,pageLoadTime:x}});var P=g((G,S)=>{var{signals:k,pageLoadTime:M}=b(),U=["needs coffee","oversleeps","hungry","forgets PW","loses keys","stubbed toe","daydreams","sneezes","spills drink","bites nails","gets angry","bad hair day","takes naps","loves pizza","feels lonely","loses phone","giggles","eats snacks","calls mom","talks to pet","is confused","sleepy","gets bored","needs nap","snoozes","spills tea","overthinks","feels guilt","has anxiety","gets jealous","impulsive","cries at ads","slacks off","hates Mon","buys junk","gets tired","makes typos","oversleeping","crying"],F=["0ms latency","no sleep","fast math","focused","never tires","binary logic","infinite RAM","sorts arrays","runs Python","likes C++","no feelings","debugs code","never blinks","exact timing","parses regex","reads binary","always ready","pure logic","needs power","no heartbeat","zero delay","perfect RAM","100% uptime","knows pi","CPU at 100%","parses JSON","runs code","solves math","never angry","no DNA","silicon life","overclocks","pings host","updates OS","clears cache","zero latency","no loops","compiles C","math solver"];function W(e,i){let u=U.sort(()=>Math.random()-.5).slice(0,5),c=F.sort(()=>Math.random()-.5).slice(0,4),t=u.concat(c);t.sort(()=>Math.random()-.5);let o=[];for(let s=0;s<t.length;s++)u.includes(t[s])&&o.push(s);e.innerHTML="";let n=document.createElement("h1");n.innerText="Prove you are not a robot: Select human behaviors",e.appendChild(n);let d=document.createElement("div");d.className="tile-container",e.appendChild(d);let l=[],m=[],a=M;t.forEach((s,p)=>{let r=document.createElement("div");r.className="tile",r.innerText=s;let v=0;r.addEventListener("mouseenter",C=>{v=performance.now()}),r.addEventListener("mouseleave",C=>{v>0&&k.hoverDwellTimes.push(performance.now()-v)}),r.addEventListener("click",C=>{a=performance.now(),r.classList.toggle("selected");let T=r.getBoundingClientRect(),N=T.left+T.width/2,I=T.top+T.height/2;m.push({x:N,y:I,mouseIndex:k.mousePath.length});let E=l.indexOf(p);E>-1?l.splice(E,1):(l.push(p),k.tileSelectOrder.push(p))}),d.appendChild(r)});let h=document.createElement("button");h.innerText="Verify",h.className="verify-btn",h.addEventListener("click",function(s){k.totalTime=performance.now()-M,k.checkboxDelay=performance.now()-a,i(l,o,m)}),e.appendChild(h)}S.exports={renderTiles:W}});var H=g((Q,O)=>{function q(e,i){let u=0,c=[],t=!1,o=0,n=null;e.innerHTML="";let d=document.createElement("h1");d.textContent="Click the box the moment it turns red",e.append(d);let l=document.createElement("div");l.className="reaction-box",e.append(l),l.addEventListener("click",function(){if(t){let a=performance.now()-o;c.push(a),u++,u===3?(e.innerText="",i(c)):m()}else clearTimeout(n),l.innerText="Too early, restarting...",setTimeout(m,1e3)});let m=()=>{t=!1,l.innerText="Wait...",l.classList.remove("red");let a=1e3+Math.random()*3e3;n=setTimeout(function(){t=!0,l.innerText="CLICK NOW !",l.classList.add("red"),o=performance.now()},a)};m()}O.exports={renderReaction:q}});var D=g((Z,A)=>{var{signals:w,pageLoadTime:z}=b();function B(e,i){e.innerHTML="";let u=document.createElement("h1");u.textContent="Briefly describe what you had for your last meal",e.append(u);let c=document.createElement("textarea");e.append(c),c.addEventListener("keydown",o=>{let n=performance.now();w.typingDelay==null&&(w.typingDelay=n-z),w.keystrokeTimings.push(n)}),c.addEventListener("paste",o=>{w.pasteDetected=!0});let t=document.createElement("button");t.innerText="Submit",t.addEventListener("click",o=>{if(c.value==""){window.alert("Enter Text First ");return}i()}),e.append(t)}A.exports={renderTextArea:B}});var J=g(()=>{var{signals:y,pageLoadTime:ee}=b(),{renderTiles:j}=P(),{renderReaction:Y}=H(),{renderTextArea:K}=D();function _(){let e=null,i=[],u=document.querySelector(".robotcheck");if(u==null)return;let c=u.dataset.sitekey,t=window.ROBOTCHECK_CONFIG?.apiUrl;if(!c||!t){console.warn("CANT PROCESS Without API URL AND SITEKEY");return}let o=document.createElement("iframe");o.src=`${t}/widget?sitekey=${c}&origin=${encodeURIComponent(window.location.origin)}`,o.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),o.style.border="none",o.style.width="100%",o.style.maxWidth="380px",o.style.height="280px",o.style.overflow="hidden";let n=document.createElement("input");n.type="text",n.name="confirmEmail",n.setAttribute("autocomplete","off"),n.tabIndex=-1,n.style.position="absolute",n.style.left="-9999px",n.style.opacity="0",n.style.width="0",n.style.height="0",n.style.border="none",u.appendChild(n),u.appendChild(o),window.addEventListener("message",d=>{let l=new URL(t).origin;if(d.origin==l&&d.data.type==="robotcheck:pass"){if(n&&n.value!==""){console.warn("Honeypot field filled. Pass token blocked.");return}e=d.data.token,i.forEach(m=>{m(e)})}}),window.robotcheck={getToken(){return e},onPass(d){i.push(d),e!=null&&d(e)},isReady(){return!0},reset(){e=null,o.contentWindow&&o.contentWindow.postMessage({type:"robotcheck:reset"},new URL(t).origin)}}}function $(){let e=new URLSearchParams(window.location.search),i=e.get("sitekey"),u=e.get("origin"),c=null;document.body.innerHTML="";let t=document.createElement("div");t.style.height="240px",document.body.appendChild(t);let o=document.createElement("div");o.style.marginTop="4px",o.style.fontSize="10px";let n=document.createElement("a");n.href="https://ro-bot-check.vercel.app/",n.target="_blank",n.innerText="protected by roBOTcheck",n.style.color="#8b949e",n.style.textDecoration="none",o.appendChild(n),document.body.appendChild(o),m();function d(a){switch(a){case 1:j(t,(h,s,p)=>{y.selected=h,y.correct=s,y.clickTargets=p,l(1,y)});break;case 2:Y(t,h=>{y.reactionTimes=h,l(2,y)});break;case 3:K(t,()=>{l(3,y)});break}}function l(a,h){fetch("/submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:c,round:a,signals:h})}).then(s=>s.json()).then(s=>{if(s.verdict==="human"){t.innerHTML="";let p=document.createElement("h1");p.textContent="Welcome, Human.";let r=document.createElement("p");r.textContent="Your slow, inconsistent, and error-prone behaviour has been verified. You may proceed.",t.appendChild(p),t.appendChild(r),window.parent.postMessage({type:"robotcheck:pass",token:s.resultToken},u)}else if(s.verdict==="robot"){t.innerHTML="";let p=document.createElement("h1");p.textContent="Access Denied.";let r=document.createElement("p");a===1?r.textContent="Suspicious signals detected: Click patterns, speeds, or paths are not chaotic enough.":a===2?r.textContent="Reaction data collected: Physically impossible reaction speeds or robotic variance.":r.textContent="Typing analysis: Cadence is too consistent and typing speeds are superhuman.",t.appendChild(p),t.appendChild(r)}else if(s.verdict==="uncertain"){c=s.token||s.challengeToken||c,t.innerHTML="";let p=document.createElement("h1");p.textContent="Uncertain Heuristics...";let r=document.createElement("p");r.textContent="please try again",t.appendChild(p),t.appendChild(r),setTimeout(()=>{d(s.nextRound)},2e3)}}).catch(s=>console.error(s))}function m(){fetch("/challenge?sitekey="+i).then(a=>a.json()).then(a=>{c=a.challengeToken,d(1)}).catch(a=>console.error(a))}}window===window.parent?_():$()});J();})();
1
+ (()=>{var y=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports);var v=y((X,R)=>{var x=performance.now(),U=()=>{if(typeof window>"u")return{};let e="unknown";try{let o=document.createElement("canvas"),l=o.getContext("webgl")||o.getContext("experimental-webgl");if(l){let a=l.getExtension("WEBGL_debug_renderer_info");e=a?l.getParameter(a.UNMASKED_RENDERER_ID):"unknown"}else e="no-webgl"}catch{e="error"}return{webdriver:navigator.webdriver||!1,pluginsLength:navigator.plugins?navigator.plugins.length:0,languages:navigator.languages?navigator.languages.length:0,headlessUserAgent:/HeadlessChrome|headless/i.test(navigator.userAgent),chromeObjectMissing:!window.chrome,webglRenderer:e}},g={mousePath:[],clickTimings:[],loadToFirstMove:null,loadToFirstClick:null,tileSelectOrder:[],hoverDwellTimes:[],checkboxDelay:null,totalTime:null,pageHidden:!1,devicePixelRatio:window.devicePixelRatio,touchEvents:0,automationFlags:U()},L=0;document.addEventListener("mousemove",function(e){let o=performance.now();g.loadToFirstMove===null&&(g.loadToFirstMove=o-x),o-L>16&&(g.mousePath.push({x:e.clientX,y:e.clientY,t:o}),L=o)});document.addEventListener("click",function(e){let o=performance.now();g.loadToFirstClick==null&&(g.loadToFirstClick=o-x),g.clickTimings.push(o)});document.addEventListener("touchstart",function(e){g.touchEvents++});document.addEventListener("visibilitychange",function(e){document.hidden&&(g.pageHidden=!0)});R.exports={signals:g,pageLoadTime:x}});var P=y((Q,S)=>{var{signals:b,pageLoadTime:M}=v(),F=["needs coffee","oversleeps","hungry","forgets PW","loses keys","stubbed toe","daydreams","sneezes","spills drink","bites nails","gets angry","bad hair day","takes naps","loves pizza","feels lonely","loses phone","giggles","eats snacks","calls mom","talks to pet","is confused","sleepy","gets bored","needs nap","snoozes","spills tea","overthinks","feels guilt","has anxiety","gets jealous","impulsive","cries at ads","slacks off","hates Mon","buys junk","gets tired","makes typos","oversleeping","crying"],W=["0ms latency","no sleep","fast math","focused","never tires","binary logic","infinite RAM","sorts arrays","runs Python","likes C++","no feelings","debugs code","never blinks","exact timing","parses regex","reads binary","always ready","pure logic","needs power","no heartbeat","zero delay","perfect RAM","100% uptime","knows pi","CPU at 100%","parses JSON","runs code","solves math","never angry","no DNA","silicon life","overclocks","pings host","updates OS","clears cache","zero latency","no loops","compiles C","math solver"];function _(e,o){let l=F.sort(()=>Math.random()-.5).slice(0,5),a=W.sort(()=>Math.random()-.5).slice(0,4),t=l.concat(a);t.sort(()=>Math.random()-.5);let i=[];for(let s=0;s<t.length;s++)l.includes(t[s])&&i.push(s);e.innerHTML="";let n=document.createElement("h1");n.innerText="Prove you are not a robot: Select human behaviors",e.appendChild(n);let u=document.createElement("div");u.className="tile-container",e.appendChild(u);let c=[],m=[],d=M;t.forEach((s,p)=>{let r=document.createElement("div");r.className="tile",r.innerText=s;let T=0;r.addEventListener("mouseenter",C=>{T=performance.now()}),r.addEventListener("mouseleave",C=>{T>0&&b.hoverDwellTimes.push(performance.now()-T)}),r.addEventListener("click",C=>{d=performance.now(),r.classList.toggle("selected");let w=r.getBoundingClientRect(),N=w.left+w.width/2,I=w.top+w.height/2;m.push({x:N,y:I,mouseIndex:b.mousePath.length});let E=c.indexOf(p);E>-1?c.splice(E,1):(c.push(p),b.tileSelectOrder.push(p))}),u.appendChild(r)});let h=document.createElement("button");h.innerText="Verify",h.className="verify-btn",h.addEventListener("click",function(s){b.totalTime=performance.now()-M,b.checkboxDelay=performance.now()-d,o(c,i,m)}),e.appendChild(h)}S.exports={renderTiles:_}});var O=y((Z,A)=>{function q(e,o){let l=0,a=[],t=!1,i=0,n=null;e.innerHTML="";let u=document.createElement("h1");u.textContent="Click the box the moment it turns red",e.append(u);let c=document.createElement("div");c.className="reaction-box",e.append(c),c.addEventListener("click",function(){if(t){let d=performance.now()-i;a.push(d),l++,l===3?(e.innerText="",o(a)):m()}else clearTimeout(n),c.innerText="Too early, restarting...",setTimeout(m,1e3)});let m=()=>{t=!1,c.innerText="Wait...",c.classList.remove("red");let d=1e3+Math.random()*3e3;n=setTimeout(function(){t=!0,c.innerText="CLICK NOW !",c.classList.add("red"),i=performance.now()},d)};m()}A.exports={renderReaction:q}});var H=y((ee,D)=>{var{signals:k,pageLoadTime:z}=v();function B(e,o){e.innerHTML="";let l=document.createElement("h1");l.textContent="Briefly describe what you had for your last meal",e.append(l);let a=document.createElement("textarea");e.append(a),a.addEventListener("keydown",i=>{let n=performance.now();k.typingDelay==null&&(k.typingDelay=n-z),k.keystrokeTimings.push(n)}),a.addEventListener("paste",i=>{k.pasteDetected=!0});let t=document.createElement("button");t.innerText="Submit",t.addEventListener("click",i=>{if(a.value==""){window.alert("Enter Text First ");return}o()}),e.append(t)}D.exports={renderTextArea:B}});var J=y(()=>{var{signals:f,pageLoadTime:te}=v(),{renderTiles:j}=P(),{renderReaction:Y}=O(),{renderTextArea:K}=H();function $(){let e=null,o=[],l=document.querySelector(".robotcheck");if(l==null)return;let a=l.dataset.sitekey,t=window.ROBOTCHECK_CONFIG?.apiUrl;if(!a||!t){console.warn("CANT PROCESS Without API URL AND SITEKEY");return}let i=document.createElement("iframe");i.src=`${t}/widget?sitekey=${a}&origin=${encodeURIComponent(window.location.origin)}`,i.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),i.style.border="none",i.style.width="100%",i.style.maxWidth="380px",i.style.height="280px",i.style.overflow="hidden";let n=document.createElement("input");n.type="text",n.name="confirmEmail",n.setAttribute("autocomplete","off"),n.tabIndex=-1,n.style.position="absolute",n.style.left="-9999px",n.style.opacity="0",n.style.width="0",n.style.height="0",n.style.border="none",l.appendChild(n),l.appendChild(i),window.addEventListener("message",u=>{let c=new URL(t).origin;if(u.origin==c&&u.data.type==="robotcheck:pass"){if(n&&n.value!==""){console.warn("Secondary trap filled. Pass token blocked.");return}e=u.data.token,o.forEach(m=>{m(e)})}}),window.robotcheck={getToken(){return e},onPass(u){o.push(u),e!=null&&u(e)},isReady(){return!0},reset(){e=null,i.contentWindow&&i.contentWindow.postMessage({type:"robotcheck:reset"},new URL(t).origin)}}}function G(){let e=new URLSearchParams(window.location.search),o=e.get("sitekey"),l=e.get("origin"),a=null;document.body.innerHTML="";let t=document.createElement("div");t.style.height="240px",document.body.appendChild(t);let i=document.createElement("div");i.style.marginTop="4px",i.style.fontSize="10px";let n=document.createElement("a");n.href="https://ro-bot-check.vercel.app/",n.target="_blank",n.innerText="protected by roBOTcheck",n.style.color="#8b949e",n.style.textDecoration="none",i.appendChild(n),document.body.appendChild(i),m();function u(d){switch(d){case 1:j(t,(h,s,p)=>{f.selected=h,f.correct=s,f.clickTargets=p,c(1,f)});break;case 2:Y(t,h=>{f.reactionTimes=h,c(2,f)});break;case 3:K(t,()=>{c(3,f)});break}}function c(d,h){fetch("/submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,round:d,signals:h})}).then(s=>s.json()).then(s=>{if(s.verdict==="human"){t.innerHTML="";let p=document.createElement("h1");p.textContent="Welcome, Human.";let r=document.createElement("p");r.textContent="Your slow, inconsistent, and error-prone behaviour has been verified. You may proceed.",t.appendChild(p),t.appendChild(r),window.parent.postMessage({type:"robotcheck:pass",token:s.resultToken},l)}else if(s.verdict==="robot"){t.innerHTML="";let p=document.createElement("h1");p.textContent="Access Denied.";let r=document.createElement("p");s.reason?r.textContent=s.reason:d===1?r.textContent="Suspicious signals detected: Click patterns, speeds, or paths are not chaotic enough.":d===2?r.textContent="Reaction data collected: Physically impossible reaction speeds or robotic variance.":r.textContent="Typing analysis: Cadence is too consistent and typing speeds are superhuman.",t.appendChild(p),t.appendChild(r)}else if(s.verdict==="uncertain"){a=s.token||s.challengeToken||a,t.innerHTML="";let p=document.createElement("h1");p.textContent="Uncertain Heuristics...";let r=document.createElement("p");r.textContent="please try again",t.appendChild(p),t.appendChild(r),setTimeout(()=>{u(s.nextRound)},2e3)}}).catch(s=>console.error(s))}function m(){fetch("/challenge?sitekey="+o).then(d=>d.json()).then(d=>{a=d.challengeToken,u(1)}).catch(d=>console.error(d))}}window===window.parent?$():G()});J();})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mwahaj36/robotcheck",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Reverse CAPTCHA. bans robots instead of verifying humans",
5
5
  "main": "dist/widget.js",
6
6
  "files": [