From 5a0aab7c50f051b0a8607bcabae380c2d5b5b145 Mon Sep 17 00:00:00 2001 From: Chris Portscheller Date: Sat, 14 Nov 2026 08:48:28 -0600 Subject: [PATCH] fix(vercel): detect ARTEX and Norma clients --- packages/webdecoy/src/clearance/gate.generated.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webdecoy/src/clearance/gate.generated.js b/packages/webdecoy/src/clearance/gate.generated.js index fb9d4f8..5b963dd 100644 --- a/packages/webdecoy/src/clearance/gate.generated.js +++ b/packages/webdecoy/src/clearance/gate.generated.js @@ -1,5 +1,5 @@ // GENERATED by WebDecoy edge/vercel-validator/scripts/bundle.mjs. DO NOT EDIT. -// Build vercel-0167e3ef2b1e. Regenerate from the validator source; gate-bundle.test.ts fails on a hand edit. +// Build vercel-20ce309dd724. Regenerate from the validator source; gate-bundle.test.ts fails on a hand edit. var S={"chat.deepseek.com":"DeepSeek","chat.openai.com":"ChatGPT","chatgpt.com":"ChatGPT","claude.ai":"Claude","copilot.microsoft.com":"Copilot","deepseek.com":"DeepSeek","gemini.google.com":"Gemini","grok.com":"Grok","kagi.com":"Kagi","meta.ai":"Meta AI","perplexity.ai":"Perplexity","phind.com":"Phind","www.deepseek.com":"DeepSeek","www.grok.com":"Grok","www.kagi.com":"Kagi","www.meta.ai":"Meta AI","www.perplexity.ai":"Perplexity","www.phind.com":"Phind","www.you.com":"You.com","you.com":"You.com"};var rt=["utm_source","ref","utm_medium"],ae=500;function nt(e,t){let r=(e??"").trim();if(r)try{return S[new URL(r).hostname.toLowerCase()]??""}catch{return""}let n;try{n=new URL(t)}catch{return""}for(let o of rt)for(let a of n.searchParams.getAll(o)){let i=ot(a);if(i)return i}return""}var ie=e=>e.replace(/[ \-_.]/g,"");function ot(e){let t=e.trim().toLowerCase();if(!t)return"";try{let n=new URL(t).hostname;n&&(t=n.toLowerCase())}catch{}if(t=t.replace(/\.$/,""),S[t])return S[t];let r=ie(t);for(let[n,o]of Object.entries(S))if(r===ie(o.toLowerCase())||r===n.replace(/^www\./,"").replace(/\./g,""))return o;return""}function se(e,t){if(e.method!=="GET")return null;let r=e.headers;if(r.get("sec-fetch-mode")!=="navigate")return null;let n=r.get("sec-fetch-dest");if(n&&n!=="document")return null;let o=nt(r.get("referer")??"",t.toString());if(!o)return null;let a=t.pathname||"/";return a.length>ae&&(a=a.slice(0,ae)),{platform:o,path:a}}var at="web-bot-auth";async function ce(e,t){let r=e.headers.get("signature-input"),n=e.headers.get("signature");if(!r&&!n)return{status:"none"};if(!r||!n)return{status:"invalid"};if(!t||t.length===0)return{status:"unknown_key"};let o,a;try{o=ft(r),a=pt(n)}catch{return{status:"invalid"}}let i=!1,s=!1;for(let c of o){if(c.params.get("tag")!==at)continue;i=!0;let f=a.get(c.label);if(!f)continue;let l=c.params.get("keyid");if(typeof l!="string")continue;let h;try{h=it(e,c)}catch{s||=t.some(p=>p.keyid===l);continue}let d=t.find(p=>{if(p.keyid!==l)return!1;try{return le(p.directory)===h}catch{return!1}});if(!d)continue;s=!0;let w=Date.now()/1e3,b=c.params.get("created"),g=c.params.get("expires");if(typeof b!="number"||typeof g!="number"||w>=g+10||w+101440*60||!c.components.some(p=>p.name==="@authority"||p.name==="@target-uri"))continue;let A;try{A=ct(e,c)}catch{continue}let u=!1;try{let p=await crypto.subtle.importKey("raw",de(d.public_key),{name:"Ed25519"},!1,["verify"]);u=await crypto.subtle.verify({name:"Ed25519"},p,f,new TextEncoder().encode(A))}catch{u=!1}if(u)return{status:"verified",name:d.name,category:d.category,keyid:l}}return s?{status:"invalid"}:i?{status:"unknown_key"}:{status:"none"}}function it(e,t){let r=e.headers.get("signature-agent");if(r===null)throw new Error("missing signature-agent");let n=t.components.find(i=>i.name.toLowerCase()==="signature-agent");if(!n)throw new Error("signature-agent is not covered");let o=r.trim(),a;if(o.startsWith('"')){if(n.keyParam!==void 0)throw new Error("legacy string cannot select a member");let i=new T(o);if(a=pe(i),i.skipSP(),!i.eof())throw new Error("trailing signature-agent data")}else{if(n.keyParam===void 0)throw new Error("dictionary member is not covered");let i=B(o).find(c=>c.key===n.keyParam),s=i?.items[0];if(!i||i.isList||i.items.length!==1||typeof s?.value!="string")throw new Error("signature-agent member is not a string");if(s.hasParams)throw new Error("signature-agent member carries parameters");a=s.value}return le(a)}var st="/.well-known/http-message-signatures-directory";function le(e){if(!/^https:\/\/[^/\\]/i.test(e))throw new Error("signature-agent must be an https URL");let t=new URL(e);if(t.protocol!=="https:"||!t.hostname||t.username||t.password)throw new Error("signature-agent must be an https URL");t.hash="";let r=t.href.includes("?"),n=t.pathname;return n==="/"&&!r&&(n=st),n=n.replace(/%[0-9a-f]{2}/gi,o=>o.toUpperCase()),`https://${H(t)}${n}`}function ct(e,t){let r=new URL(e.url),n=[];for(let o of t.components)n.push(`${lt(o)}: ${ut(e,r,o)}`);return n.push(`"@signature-params": ${t.raw.trim()}`),n.join(` `)}function lt(e){let t=`"${e.name.toLowerCase()}"`;return e.keyParam!==void 0?`${t};key="${e.keyParam}"`:t}function ut(e,t,r){let n=r.name.toLowerCase();if(n==="@authority")return H(t);if(n==="@target-uri")return`${t.protocol}//${H(t)}${t.pathname}${t.search}`;if(n==="signature-agent"){let o=e.headers.get("signature-agent");if(o===null)throw new Error("signature-agent covered but absent");return r.keyParam!==void 0?gt(o,r.keyParam):o.trim().replace(/\s+/g," ")}throw new Error(`unsupported covered component ${n}`)}function H(e){let t=e.hostname.toLowerCase(),r=e.port;return!r||e.protocol==="https:"&&r==="443"||e.protocol==="http:"&&r==="80"?t:`${t}:${r}`}function gt(e,t){let n=B(e).find(o=>o.key===t);if(!n)throw new Error(`signature-agent has no member ${t}`);return n.raw}function ft(e){return B(e).map(r=>{if(!r.isList)throw new Error(`Signature-Input member ${r.key} is not an inner list`);let n=r.items.map(o=>{if(typeof o.value!="string")throw new Error("component identifier is not a string");let a=o.params.get("key");return{name:o.value,keyParam:typeof a=="string"?a:void 0}});return{label:r.key,components:n,params:r.params,raw:r.raw}})}function pt(e){let t=B(e),r=new Map;for(let n of t){if(n.isList||n.items.length!==1)throw new Error(`Signature member ${n.key} is not a byte sequence`);let o=n.items[0].bytes;if(!o)throw new Error(`Signature member ${n.key} is not a byte sequence`);r.set(n.key,o)}return r}var T=class{constructor(t,r=0){this.s=t;this.i=r}eof(){return this.i>=this.s.length}peek(){return this.s[this.i]}skipSP(){for(;!this.eof()&&(this.peek()===" "||this.peek()===" ");)this.i++}};function B(e){let t=new T(e),r=[];for(t.skipSP();!t.eof();){let o={key:ge(t),raw:"",isList:!1,items:[],params:new Map};if(!t.eof()&&t.peek()==="="){t.i++;let a=t.i;if(!t.eof()&&t.peek()==="(")o.isList=!0,dt(t,o);else{let{value:i,params:s,hasParams:c,bytes:f}=ue(t);o.items.push({value:i,params:s,hasParams:c,...f?{bytes:f}:{}})}o.raw=e.slice(a,t.i)}else o.params=V(t),o.items.push({value:!0,params:new Map});if(r.push(o),t.skipSP(),t.eof())break;if(t.peek()!==",")throw new Error(`expected ',' at ${t.i}`);if(t.i++,t.skipSP(),t.eof())throw new Error("trailing comma")}return r}function dt(e,t){for(e.i++;;){if(e.skipSP(),e.eof())throw new Error("unterminated inner list");if(e.peek()===")"){e.i++;break}let{value:r,params:n}=ue(e);if(t.items.push({value:r,params:n}),e.eof())throw new Error("unterminated inner list");let o=e.peek();if(o!==" "&&o!==")")throw new Error(`bad inner list at ${e.i}`)}t.params=V(e)}function ue(e){let{value:t,bytes:r}=fe(e),n=!e.eof()&&e.peek()===";",o=V(e);return{value:t,params:o,hasParams:n,bytes:r}}function V(e){let t=new Map;for(;!e.eof()&&e.peek()===";";){e.i++,e.skipSP();let r=ge(e),n=!0;if(!e.eof()&&e.peek()==="="){e.i++;let o=fe(e);n=(typeof o.value=="boolean",o.value)}typeof n!="boolean"&&t.set(r,n)}return t}function ge(e){let t=e.peek();if(!t||!/[a-z*]/.test(t))throw new Error(`invalid key at ${e.i}`);let r=e.i;for(;!e.eof()&&/[a-z0-9_\-.*]/.test(e.peek());)e.i++;return e.s.slice(r,e.i)}function fe(e){let t=e.peek();if(t==='"')return{value:pe(e)};if(t===":")return{value:"",bytes:ht(e)};if(t==="?"){e.i++;let r=e.peek();if(e.i++,r==="1")return{value:!0};if(r==="0")return{value:!1};throw new Error("bad boolean")}if(t==="-"||/[0-9]/.test(t))return{value:mt(e)};if(/[a-zA-Z*]/.test(t))return{value:wt(e)};throw new Error(`invalid bare item at ${e.i}`)}function pe(e){e.i++;let t="";for(;!e.eof();){let r=e.s[e.i++];if(r==='"')return t;if(r==="\\"){let n=e.s[e.i++];if(n!=='"'&&n!=="\\")throw new Error("bad escape");t+=n}else{let n=r.charCodeAt(0);if(n<32||n>126)throw new Error("bad char in string");t+=r}}throw new Error("unterminated string")}function ht(e){e.i++;let t=e.i;for(;!e.eof()&&e.peek()!==":";)e.i++;if(e.eof())throw new Error("unterminated byte sequence");let r=e.s.slice(t,e.i);return e.i++,de(r)}function mt(e){let t=e.i;for(e.peek()==="-"&&e.i++;!e.eof()&&/[0-9]/.test(e.peek());)e.i++;if(!e.eof()&&e.peek()===".")for(e.i++;!e.eof()&&/[0-9]/.test(e.peek());)e.i++;return Number(e.s.slice(t,e.i))}function wt(e){let t=e.i;for(e.i++;!e.eof()&&/[a-zA-Z0-9!#$%&'*+\-.^_`|~:/]/.test(e.peek());)e.i++;return e.s.slice(t,e.i)}function de(e){let t=atob(e),r=new Uint8Array(new ArrayBuffer(t.length));for(let n=0;n0?Object.keys(W).find(t=>W[t]===e)??"":""}function me(e){return e=yt(e),e=_t(e),e.toLowerCase()}function yt(e){for(let t=0;t<4;t++){let r=vt(e);if(r===e)break;e=r}return e}function vt(e){if(!e.includes("%"))return e;let t="";for(let r=0;r=0&&o>=0){let a=n<<4|o;if(a<128){t+=String.fromCharCode(a),r+=2;continue}}}t+=e[r]}return t}function we(e){return e>=48&&e<=57?e-48:e>=97&&e<=102?e-97+10:e>=65&&e<=70?e-65+10:-1}function _t(e){if(e==="")return e;let t=e.length>1&&e[e.length-1]==="/",r=[];for(let o of e.split("/"))if(!(o===""||o===".")){if(o===".."){r.length>0&&r.pop();continue}r.push(o)}let n="/"+r.join("/");return t&&n!=="/"&&(n+="/"),n}function I(e,t){let r=me(e),n=me(t);if(n.endsWith("/*")){let o=n.slice(0,-2);return o===""?!0:r===o||r.startsWith(o+"/")}return r===n}function O(e){return e.endsWith("/*")?e.length-2:1<<20}function be(e,t,r){let n=new Map,o=new Set,a=[],i=[],s=new Map,c=(u,p)=>{let v=new Set(u);for(let C of p)for(let _ of s.get(C)??[])v.add(_);return v.size===0?void 0:[...v].sort()},f=(u,p,v)=>v?{pattern:u,required_trust:p,refused_behaviors:v}:{pattern:u,required_trust:p};for(let u of t){if(!I(e,u.pattern))continue;if((u.exceptions??[]).some(C=>I(e,C))){i.push(u.pattern);continue}let p=n.get(u.pattern);p===void 0&&a.push(u.pattern);let v=bt(u.min_trust);(p===void 0||v>p)&&n.set(u.pattern,v),u.mode!=="monitor"&&o.add(u.pattern);for(let C of u.refuse_behaviors??[])s.has(u.pattern)||s.set(u.pattern,new Set),s.get(u.pattern)?.add(C)}let l=[];if(a.length===0){let u="";for(let p of i)(u===""||O(p)>O(u))&&(u=p);return{covering:a,deciding_mode:"",attributed:"",required_trust:"",requirement_source:"",previews:l,excepted_by:u,refused_behaviors:[]}}a.sort((u,p)=>O(p)-O(u));let h=r==="monitor",d=a.filter(u=>o.has(u)),w=h?"monitor":"enforce";if(d.length===0){if(!h)for(let u of a)l.push(f(u,z(n.get(u)??0),c([],[u])));d=a,w="monitor"}let b=0,g="";for(let u of d){let p=n.get(u)??0;p>b&&(b=p,g=u)}let A=c([],d)??[];if(w==="enforce")for(let u of a)o.has(u)||l.push(f(u,z(Math.max(b,n.get(u)??0)),c(A,[u])));return{covering:a,deciding_mode:w,attributed:d[0],required_trust:z(b),requirement_source:g,previews:l,excepted_by:"",refused_behaviors:A}}var xt="other",At={"search engine crawler":"search","ai search":"search","ai assistant":"agent","ai crawler":"training","page preview":"link_preview","feed fetcher":"feeds","monitoring & analytics":"monitoring","search engine optimization":"seo",security:"security_testing"};function D(e){let t=e.trim().toLowerCase();return t?At[t]??xt:""}function F(e,t){let r=D(e);return r!==""&&t.includes(r)}var kt={search_engines:["search engine crawler"],ai_crawlers:["ai assistant","ai crawler","ai search"],monitoring:["monitoring & analytics"]};function ye(e,t){let r=kt[e];return r?r.every(n=>F(n,t)):!1}var Ct=I;function ve(e,t,r){return e?t?t.some(n=>Ct(r,n)):!0:!1}var Rt="x-wd-service-token",St="wd_clearance";function _e(e,t,r=[]){if(e.graded&&t&&!It(e.graded.trust,t))return{pass:!1,label:"insufficient-trust"};if(e.crawler&&r.length>0){if(e.crawler.behavior&&r.includes(e.crawler.behavior))return{pass:!1,label:"crawler-refused"};if(!e.crawler.behavior&&e.crawler.exempted)return{pass:!1,label:"missing"}}return{pass:e.pass,label:e.label}}async function Ce(e,t,r){let n=new URL(e.url).pathname,o=be(n,Bt(t),t.mode),a=o.deciding_mode||t.mode,i=await Et(e,t,r,o.covering.length>0,o.excepted_by!==""),s=i.behavior??"",c=_e(i,o.required_trust,o.refused_behaviors),f=c.label==="excepted"?o.excepted_by:c.label==="unscoped"?"":o.attributed,l=!c.pass&&a==="enforce",h=o.previews.map(d=>{let w=_e(i,d.required_trust,d.refused_behaviors??[]);return{pattern:d.pattern,refused:!w.pass&&!l?w.label:""}});return{pass:c.pass,label:c.label,pattern:f,mode:a,previews:h,behavior:c.pass?s:"",crawlerBehavior:i.crawler?.behavior??"",referral:se(e,new URL(e.url)),outsideReach:i.outsideReach??""}}async function Et(e,t,r,n,o){let a=await Pt(e,t,r);if(a.grants)return{pass:!0,label:"machine"};let i=await Tt(e,t,r,n,o);return a.outsideReach?{...i,outsideReach:a.outsideReach}:i}async function Pt(e,t,r){let n=e.headers.get(Rt);if(!n)return{grants:!1,outsideReach:""};let o=await Se(n,t.keys,r.siteKey);if(!o||o.typ!=="machine"||!o.sub)return{grants:!1,outsideReach:""};if(t.active_credentials.includes(o.sub))return{grants:!0,outsideReach:""};let a=(t.restricted_credentials??[]).find(s=>s&&s.id===o.sub);if(!a)return{grants:!1,outsideReach:""};let i=new URL(e.url).pathname;return ve(a.here,a.paths,i)?{grants:!0,outsideReach:""}:{grants:!1,outsideReach:o.sub}}async function Tt(e,t,r,n,o){let a=await r.verifiedBotCategory(e,n)||"",i=a?{behavior:D(a),exempted:!1}:void 0;if(a&&Dt(a,t)){let l=D(a);return{pass:!0,label:"verified-bot",behavior:l,crawler:{behavior:l,exempted:!0}}}let s=await ce(e,t.signed_agents);if(s.status==="verified"&&Mt(s.category,t))return{pass:!0,label:"signed-agent",behavior:Ae(s.category),crawler:{behavior:Ae(s.category),exempted:!0}};if(s.status==="invalid"&&n)return{pass:!1,label:"agent-impersonation",crawler:i};if(!n)return o?{pass:!0,label:"excepted",crawler:i}:{pass:!0,label:"unscoped",crawler:i};let c=q(e.headers.get("cookie")??"",St);if(!c)return{pass:!1,label:"missing",crawler:i};let f=await Se(c,t.keys,r.siteKey);return!f||(f.typ??"")!==""?{pass:!1,label:"invalid",crawler:i}:t.denied_fps&&t.denied_fps.includes(f.fp)?{pass:!1,label:"revoked",crawler:i}:{pass:!0,label:"valid",graded:{trust:f.trust},crawler:i}}function Bt(e){let t=new Set(e.routes),r=new Map;for(let o of e.route_exceptions??[])t.has(o.pattern)&&Array.isArray(o.except)&&r.set(o.pattern,o.except);let n=e.routes.map(o=>({pattern:o,exceptions:r.get(o)}));for(let o of e.route_min_trust??[])t.has(o.pattern)&&n.push({pattern:o.pattern,min_trust:o.min_trust,exceptions:r.get(o.pattern)});for(let o of e.monitor_routes??[])n.push({pattern:o.pattern,min_trust:o.min_trust,mode:"monitor",exceptions:o.except});for(let o of e.route_refusals??[])!Array.isArray(o.refuse_behaviors)||o.refuse_behaviors.length===0||(o.mode==="monitor"?n.push({pattern:o.pattern,mode:"monitor",refuse_behaviors:o.refuse_behaviors}):t.has(o.pattern)&&n.push({pattern:o.pattern,exceptions:r.get(o.pattern),refuse_behaviors:o.refuse_behaviors}));return n}var Ot={"attested-human":2,"human-likely":1,clean:0};function xe(e){return Ot[e??""]??0}function It(e,t){return xe(e)>=xe(t)}function Dt(e,t){let r=t.allow_behaviors;return r?F(e,r):Lt(e,t.allow)}function Mt(e,t){let r=t.allow_behaviors;return r?ye(e,r):he(e,t.allow)}function Ae(e){return e==="search_engines"?"search":e==="monitoring"?"monitoring":""}function Lt(e,t){let r=e.trim().toLowerCase();return!!(t.search_engines&&r.includes("search engine crawler")||t.ai_crawlers&&r.startsWith("ai ")||t.monitoring&&r.includes("monitoring"))}function j(e){return!e.pass&&e.mode==="enforce"&&(e.label==="missing"||e.label==="invalid")}function Re(e){return j(e)?{...e,pass:!0,label:"outage-pass"}:e}function q(e,t){for(let r of e.split(";")){let n=r.indexOf("=");if(!(n<0)&&r.slice(0,n).trim()===t)return r.slice(n+1).trim()||null}return null}async function Se(e,t,r){try{let n=e.indexOf(".");if(n<0)return null;let o=ke(e.slice(0,n)),a=ke(e.slice(n+1)),i=JSON.parse(new TextDecoder().decode(o)),s=t.find(l=>l.kid===i.kid);if(!s)return null;let c=await crypto.subtle.importKey("raw",Ut(s.public_key),{name:"Ed25519"},!1,["verify"]);return!await crypto.subtle.verify({name:"Ed25519"},c,a,o)||i.tenant!==r||Date.now()/1e3>=i.exp?null:i}catch{return null}}function ke(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4);return Ee(atob(t))}function Ut(e){return Ee(atob(e))}function Ee(e){let t=new Uint8Array(new ArrayBuffer(e.length));for(let r=0;r{let o=!1;try{let a=new AbortController,i=setTimeout(()=>a.abort(),3e3);try{let s=await n(e.replace(/\/+$/,"")+"/api/v1/clearance",{method:"POST",headers:{"content-type":"application/json","user-agent":"WebDecoy-OutageProbe/1"},body:JSON.stringify({aid:t,fp:"wd-outage-probe",scope:"",ua:"WebDecoy-OutageProbe/1"}),signal:a.signal});s.status===429?o=!0:s.status<300&&(o=typeof(await s.json())?.granted=="boolean")}finally{clearTimeout(i)}}catch{o=!1}return M={at:r,available:o},o})();try{return await E}finally{E=null}}function Pe(e){let t="";for(let r of new Uint8Array(e))t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Te(e,t){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return Pe(await crypto.subtle.sign("HMAC",r,new TextEncoder().encode(t)))}async function Be(e){return Pe(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e))).slice(0,16)}function Oe(e,t,r){return`${Nt}|${e}|${t}|${r}`}async function Gt(e,t,r,n){let o=Math.floor(n/1e3)+300;return`${o}.${await Te(e,Oe(t,o,await Be(r)))}`}async function Ie(e,t,r,n,o){if(!t||!e)return!1;let a=e.indexOf(".");if(a<=0)return!1;let i=Number(e.slice(0,a));if(!Number.isInteger(i)||i<=Math.floor(o/1e3)||i>Math.floor(o/1e3)+300)return!1;let s=await Te(t,Oe(r,i,await Be(n))),c=e.slice(a+1);if(c.length!==s.length)return!1;let f=0;for(let l=0;lnew Response(JSON.stringify(s),{status:i,headers:{"content-type":"application/json","cache-control":"no-store",...c}});if(e.method!=="POST")return o(405,{pass:!1});if(!t.sensorKey)return o(503,{pass:!1,reason:"unsupported"});if(await Kt(t.apiBase,t.siteKey,r,n))return o(409,{pass:!1,reason:"mint_available"});let a=await Gt(t.sensorKey,t.host,e.headers.get("user-agent")??"",r);return o(200,{pass:!0,expires_in:300},{"set-cookie":`${Y}=${a}; Path=/; Secure; SameSite=Lax; HttpOnly; Max-Age=300`})}var $t="wdfp1",Me=` async function wdDeviceFP() { @@ -207,4 +207,4 @@ ${Me} ${a} ${u} ${p}`,C=g.routes.get(v);C?C.count++:(g.routes.set(v,{pattern:A,verdict:a,behavior:u,crawlerBehavior:p,count:1}),g.routeBytes+=k.encode(A).length+k.encode(a).length+k.encode(u).length+k.encode(p).length+je);for(let m of Array.isArray(c)?c:[]){if(!m||typeof m.pattern!="string"||!m.pattern)continue;let y=g.previews.get(m.pattern);y||(y={evaluated:0,refused:new Map},g.previews.set(m.pattern,y),g.routeBytes+=k.encode(m.pattern).length+tr),y.evaluated++,typeof m.refused=="string"&&m.refused&&(y.refused.has(m.refused)||(g.routeBytes+=k.encode(m.refused).length+rr),y.refused.set(m.refused,(y.refused.get(m.refused)??0)+1))}typeof h=="string"&&h&&g.credentials.set(h,(g.credentials.get(h)??0)+1);let _=e?.referral;if(_&&typeof _.platform=="string"&&_.platform&&typeof _.path=="string"){let m=`${_.platform} -${_.path}`,y=g.referrals.get(m);y?y.count++:(g.referrals.set(m,{platform:_.platform,path:_.path,count:1}),g.routeBytes+=k.encode(_.platform).length+k.encode(_.path).length+je)}let R=e?.refusal;R&&typeof R.ip=="string"&&R.ip&&typeof R.path=="string"&&R.path.startsWith("/")&&(g.refusals.push({ip:R.ip,path:R.path,at:Math.floor(o/1e3),verdict:a}),g.routeBytes+=nr),g.total++,(g.total>=Qt||g.routeBytes>=er)&&(K(g,r,n),x.delete(b))}catch{}}function ur(e,t,r,n,o){try{let a=(t.bucketStart+ee)*1e3,i=Math.floor(Math.random()*sr),s=Math.max(0,Math.min(a-o+i,ir));n.waitUntil(new Promise(c=>{setTimeout(()=>{try{x.get(e)===t&&(K(t,r,n),x.delete(e))}catch{}c()},s)}))}catch{}}function K(e,t,r){try{if(e.total<=0||e.counts.size===0)return;let n={};for(let[l,h]of e.counts)n[l]=h;let o=[];for(let l of e.routes.values()){let h={pattern:l.pattern,verdict:l.verdict,count:l.count};l.behavior&&(h.behavior=l.behavior),l.crawlerBehavior&&(h.crawler_behavior=l.crawlerBehavior),o.push(h)}let a={organization_id:t.siteKey,bucket_start:e.bucketStart,mode:e.mode,counts:n,route_counts:o,report_id:crypto.randomUUID()};if(e.previews.size>0){let l=[];for(let[h,d]of e.previews){let w={};for(let[b,g]of d.refused)w[b]=g;l.push({pattern:h,evaluated:d.evaluated,additional_refusals:w})}a.previews=l}if(e.credentials.size>0){let l=[];for(let[h,d]of e.credentials)l.push({credential_id:h,outside_reach:d});a.credential_presentations=l}e.referrals.size>0&&(a.ai_referrals=[...e.referrals.values()].map(l=>({platform:l.platform,path:l.path,count:l.count}))),t.propertyId&&(a.property_id=t.propertyId),a.host=e.host,t.bundleVersion&&(a.reporter_version=t.bundleVersion);let i=!!(t.scannerId&&t.sensorKey);i&&(a.scanner_id=t.scannerId),a.capabilities=t.capabilities??Fe;let s=i?e.refusals:[],c=()=>pr(t.apiBase,JSON.stringify(a),i?t.sensorKey:void 0),f=s.length===0?c():fr(t.siteKey,s).then(l=>{a.refusals=l}).catch(()=>{}).then(c);r.waitUntil(f.then(()=>{},()=>{}))}catch{}}async function gr(e,t,r){let n=await crypto.subtle.digest("SHA-256",k.encode(`${e.toLowerCase()}|${t}|${r}`)),o="";for(let a of new Uint8Array(n))o+=a.toString(16).padStart(2,"0");return o.slice(0,or)}async function fr(e,t){let r=[];for(let n of t)r.push({k:await gr(e,n.ip,n.path),t:n.at,v:n.verdict});return r}async function pr(e,t,r){let n=new AbortController,o=setTimeout(()=>n.abort(),ar),a={"content-type":"application/json"};r&&(a["x-wd-sensor-key"]=r);try{await fetch(e.replace(/\/+$/,"")+"/api/v1/clearance/telemetry",{method:"POST",headers:a,body:t,signal:n.signal})}finally{clearTimeout(o)}}var G=["route_min_trust","route_attribution","monitor_routes","route_exceptions","bot_behaviors","credential_reach","bot_verification_rdns","crawler_behavior","ai_referrals"];var dr=[{category:"search_engines",suffixes:[".googlebot.com",".google.com",".search.msn.com",".crawl.yahoo.net",".applebot.apple.com",".yandex.com",".yandex.net",".yandex.ru",".crawl.baidu.com",".crawl.baidu.jp"]}];function hr(e,t){let r=e.toLowerCase().replace(/\.$/,"");for(let n of dr)if(t[n.category]){for(let o of n.suffixes)if(r.endsWith(o))return n.category}return null}var $=new Map,mr=36e5,wr=5e3;async function Ye(e,t,r,n){let o=$.get(e);if(o&&n-o.at=wr&&$.clear(),$.set(e,{category:a,at:n}),a}async function br(e,t,r){let n=e.replace(/\.$/,""),o=t.includes(":")?[r.resolve6(n)]:[r.resolve4(n)];try{return(await Promise.all(o)).flat().some(i=>i===t)}catch{return!1}}var Je=[["reflectionbot","Reflectionbot","reflectionbot","crawler"],["gptbot","GPTBot","gptbot","crawler"],["claudebot","ClaudeBot","claudebot","crawler"],["anthropic-ai","Anthropic","anthropic","crawler"],["claude-web","Claude-Web","claude-web","crawler"],["ccbot","CCBot","ccbot","crawler"],["google-extended","Google-Extended","google-extended","crawler"],["bytespider","ByteSpider","bytespider","crawler"],["amazonbot","Amazonbot","amazonbot","crawler"],["facebookbot","FacebookBot","facebookbot","crawler"],["meta-externalagent","Meta-ExternalAgent","meta-externalagent","crawler"],["cohere-ai","Cohere","cohere-ai","crawler"],["cohere","Cohere","cohere-ai","crawler"],["applebot-extended","Applebot-Extended","applebot-extended","crawler"],["youbot","YouBot","youbot","crawler"],["mistralbot","MistralBot","mistral","crawler"],["gemini","Gemini","gemini","crawler"],["ai2bot","AI2Bot","ai2bot","crawler"],["deepseek","DeepSeek","deepseek","crawler"],["qwen","Qwen","qwen","crawler"],["webzio","Webz.io","webzio","crawler"],["sentibot","Sentibot","sentibot","crawler"],["omgili","Omgili","omgili","crawler"],["img2dataset","img2dataset","img2dataset","crawler"],["timpibot","Timpibot","timpibot","crawler"],["velenpublicwebcrawler","VelenPublicWebCrawler","velenpublicwebcrawler","crawler"],["isscyberriskcrawler","ISSCyberRiskCrawler","isscyberriskcrawler","crawler"],["friendlycrawler","FriendlyCrawler","friendlycrawler","crawler"],["elevenlabscrawler","ElevenlabsCrawler","elevenlabscrawler","crawler"],["riverbot","RiverBot","riverbot","crawler"],["kimibot","KimiBot","kimibot","crawler"],["moonshotbot","MoonshotBot","moonshotbot","crawler"],["chatglm-spider","ChatGLM-Spider","chatglm-spider","crawler"],["duckassistbot","DuckAssistBot","duckassistbot","crawler"],["sofyabot","SofyaBot","sofyabot","crawler"],["xai-searchbot","xAI-SearchBot","xai-searchbot","crawler"],["linkupbot","LinkupBot","linkupbot","crawler"],["perplexitybot","PerplexityBot","perplexitybot","crawler"],["claude-searchbot","Claude-SearchBot","claude-searchbot","crawler"],["oai-searchbot","OAI-SearchBot","oai-searchbot","crawler"],["searchgpt","SearchGPT","searchgpt","crawler"],["phind","Phind","phind","crawler"],["kagi","Kagi","kagi","crawler"],["exasearchbot","Exa","exa","crawler"],["exabot","Exa","exa","crawler"],["shapbot","ShapBot","shapbot","crawler"],["meta-webindexer","Meta-WebIndexer","meta-webindexer","crawler"],["metaphor","Metaphor","metaphor","crawler"],["tavily","Tavily","tavily","crawler"],["bravesearch","BraveSearch","brave-search","crawler"],["neevabot","NeevaBot","neeva","crawler"],["kimi-searchbot","Kimi-SearchBot","kimi-searchbot","crawler"],["isonsearchbot","IsonSearchBot","isonsearchbot","crawler"],["keenablebot","KeenableBot","keenablebot","crawler"],["azureai-searchbot","AzureAI-SearchBot","azureai-searchbot","crawler"],["grokbot","GrokBot","grokbot","crawler"],["operator","Operator","operator","crawler"],["claude-user","Claude-User","claude-user","crawler"],["gemini-user","Gemini-User","gemini-user","crawler"],["googleagent-mariner","GoogleAgent-Mariner","googleagent-mariner","crawler"],["mariner","GoogleAgent-Mariner","googleagent-mariner","crawler"],["amazonbuyforme","AmazonBuyForMe","amazon-buyforme","crawler"],["buyforme","AmazonBuyForMe","amazon-buyforme","crawler"],["browser-use","Browser-Use","browser-use","crawler"],["stagehand","Stagehand","stagehand","crawler"],["manus-user","Manus-User","manus-user","crawler"],["multion","MultiOn","multion","crawler"],["opencode-user","OpenCode-User","opencode-user","crawler"],["iboubot","IbouBot","iboubot","crawler"],["ibou-search","IbouBot","iboubot","crawler"],["googlebot","Googlebot","googlebot","crawler"],["google-inspectiontool","Google-InspectionTool","google-inspectiontool","crawler"],["bingbot","Bingbot","bingbot","crawler"],["msnbot","MSNBot","msnbot","crawler"],["yandexbot","YandexBot","yandexbot","crawler"],["baiduspider","Baiduspider","baiduspider","crawler"],["petalbot","PetalBot","petalbot","crawler"],["duckduckbot","DuckDuckBot","duckduckbot","crawler"],["applebot","Applebot","applebot","crawler"],["sogou","Sogou Spider","sogou","crawler"],["qwantify","Qwantify","qwantify","crawler"],["qwantbot","Qwantify","qwantify","crawler"],["naver","Naver","naver","crawler"],["yeti","Naver","naver","crawler"],["seznambot","SeznamBot","seznam","crawler"],["ecosia","Ecosia","ecosia","crawler"],["mojeekbot","MojeekBot","mojeek","crawler"],["slurp","Yahoo! Slurp","yahoo-slurp","crawler"],["bravebot","Bravebot","bravebot","crawler"],["coccocbot","Coc Coc","coccocbot","crawler"],["yisouspider","YisouSpider","yisouspider","crawler"],["yepbot","YepBot","yepbot","crawler"],["ahrefsbot","AhrefsBot","ahrefsbot","crawler"],["ahrefs","AhrefsBot","ahrefsbot","crawler"],["semrushbot","SemrushBot","semrushbot","crawler"],["semrush","SemrushBot","semrushbot","crawler"],["mj12bot","MJ12bot","mj12bot","crawler"],["dotbot","DotBot","dotbot","crawler"],["rogerbot","Rogerbot","rogerbot","crawler"],["screaming frog","Screaming Frog","screaming-frog","crawler"],["sitebulb","Sitebulb","sitebulb","crawler"],["deepcrawl","DeepCrawl","deepcrawl","crawler"],["oncrawl","OnCrawl","oncrawl","crawler"],["botify","Botify","botify","crawler"],["contentking","ContentKing","contentking","crawler"],["sistrix","SISTRIX","sistrix","crawler"],["serpstat","Serpstat","serpstat","crawler"],["spyfu","SpyFu","spyfu","crawler"],["meta-externalads","meta-externalads","meta-externalads","crawler"],["dataforseobot","DataForSeoBot","dataforseobot","crawler"],["barkrowler","Barkrowler","barkrowler","crawler"],["scrunchbot","Scrunchbot","scrunchbot","crawler"],["webxtrendbot","webXtrendBot","webxtrendbot","crawler"],["serankingbacklinksbot","SERankingBacklinksBot","serankingbacklinksbot","crawler"],["awariobot","AwarioBot","awariobot","crawler"],["awariosmartbot","AwarioBot","awariobot","crawler"],["seojuice-searchbot","SEOJuice-SearchBot","seojuice-searchbot","crawler"],["trendictionbot","trendictionbot","trendictionbot","crawler"],["hubspot crawler","HubSpot Crawler","hubspot-crawler","crawler"],["nessus","Nessus","nessus","crawler"],["qualys","Qualys","qualys","crawler"],["shodan","Shodan","shodan","crawler"],["censys","Censys","censys","crawler"],["nmap","Nmap","nmap","crawler"],["zap/","OWASP ZAP","zap","crawler"],["burp","Burp Suite","burp","crawler"],["nikto","Nikto","nikto","crawler"],["nuclei","Nuclei","nuclei","crawler"],["acunetix","Acunetix","acunetix","crawler"],["netsparker","Netsparker","netsparker","crawler"],["detectify","Detectify","detectify","crawler"],["palo alto networks","Palo Alto Networks Cortex Xpanse","paloalto-xpanse","crawler"],["recordedfuture","Recorded Future Crawler","recordedfuture","crawler"],["developers.cloudflare.com/security-center","Cloudflare Security Center","cloudflare-security-center","crawler"],["virustotalcloud","VirusTotal","virustotal-cloud","crawler"],["intruder","Intruder","intruder","crawler"],["python-requests","Python-Requests","python-requests","tool"],["python-urllib","Python-urllib","python-urllib","tool"],["python/","Python","python","tool"],["scrapy","Scrapy","scrapy","tool"],["httpx","HTTPX","httpx","tool"],["aiohttp","aiohttp","aiohttp","tool"],["beautifulsoup","BeautifulSoup","beautifulsoup","tool"],["node-fetch","node-fetch","node-fetch","tool"],["axios/","Axios","axios","tool"],["got/","Got","got","tool"],["undici","Undici","undici","tool"],["go-http-client","Go-HTTP-Client","go-http-client","tool"],["colly","Colly","colly","tool"],["java/","Java","java","tool"],["okhttp","OkHttp","okhttp","tool"],["apache-httpclient","Apache-HttpClient","apache-httpclient","tool"],["jsoup","Jsoup","jsoup","tool"],["guzzlehttp","GuzzleHttp","guzzlehttp","tool"],["php/","PHP","php","tool"],["ruby","Ruby","ruby","tool"],["faraday","Faraday","faraday","tool"],["mechanize","Mechanize","mechanize","tool"],["headlesschrome","HeadlessChrome","headlesschrome","tool"],["puppeteer","Puppeteer","puppeteer","tool"],["playwright","Playwright","playwright","tool"],["selenium","Selenium","selenium","tool"],["phantomjs","PhantomJS","phantomjs","tool"],["splash","Splash","splash","tool"],["browserless","Browserless","browserless","tool"],["browserbase","Browserbase","browserbase","tool"],["ia_archiver","Internet Archive","ia-archiver","crawler"],["archive.org_bot","Archive.org","archive-org-bot","crawler"],["wayback","Wayback Machine","wayback","crawler"],["heritrix","Heritrix","heritrix","crawler"],["brozzler","Brozzler","brozzler","crawler"],["facebookexternalhit","Facebook","facebookexternalhit","crawler"],["facebot","Facebot","facebot","crawler"],["twitterbot","Twitterbot","twitterbot","crawler"],["linkedinbot","LinkedInBot","linkedinbot","crawler"],["slackbot","Slackbot","slackbot","crawler"],["telegrambot","TelegramBot","telegrambot","crawler"],["whatsapp","WhatsApp","whatsapp","crawler"],["discordbot","Discordbot","discordbot","crawler"],["pinterest","Pinterest","pinterestbot","crawler"],["tumblr","Tumblr","tumblr","crawler"],["reddit","Reddit","reddit","crawler"],["embedly","Embedly","embedly","crawler"],["iframely","Iframely","iframely","crawler"],["adsbot-google","AdsBot-Google","adsbot-google","crawler"],["stripebot","Stripebot","stripebot","crawler"],["google-read-aloud","Google-Read-Aloud","google-read-aloud","crawler"],["google-safety","Google-Safety","google-safety","crawler"],["oai-adsbot","OAI-AdsBot","oai-adsbot","crawler"],["kakaobot","KakaoBot","kakaobot","crawler"],["curl/","cURL","curl","tool"],["wget/","Wget","wget","tool"],["libwww-perl","libwww-perl","libwww-perl","tool"],["lwp-","LWP","lwp","tool"],["httrack","HTTrack","httrack","tool"],["webdecoybot","WebDecoyBot","webdecoybot","crawler"],["uptimerobot","UptimeRobot","uptimerobot","crawler"],["pingdom","Pingdom","pingdom","crawler"],["statuscake","StatusCake","statuscake","crawler"],["betteruptime","Better Uptime","better-uptime","crawler"],["datadog","Datadog Synthetics","datadog-synthetics","crawler"],["newrelic","New Relic","newrelic","crawler"],["site24x7","Site24x7","site24x7","crawler"],["freshping","Freshping","freshping","crawler"],["hetrixtools","HetrixTools","hetrixtools","crawler"],["nodeping","NodePing","nodeping","crawler"],["gtmetrix","GTmetrix","gtmetrix","crawler"],["chrome-lighthouse","Lighthouse","chrome-lighthouse","crawler"],["google page speed","Lighthouse","chrome-lighthouse","crawler"],["feedly","Feedly","feedly","crawler"],["livelapbot","LivelapBot","livelapbot","crawler"],["feedfetcher","Feedfetcher-Google","feedfetcher-google","crawler"],["newsblur","NewsBlur","newsblur","crawler"],["inoreader","Inoreader","inoreader","crawler"],["theoldreader","The Old Reader","theoldreader","crawler"],["feedbin","Feedbin","feedbin","crawler"],["miniflux","Miniflux","miniflux","crawler"],["freshrss","FreshRSS","freshrss","crawler"],["commafeed","CommaFeed","commafeed","crawler"],["diffbot","Diffbot","diffbot","crawler"],["import.io","Import.io","import-io","crawler"],["brightdata","Bright Data","bright-data","crawler"],["luminati","Bright Data","bright-data","crawler"],["brightbot","Brightbot","brightbot","crawler"],["cloudflarebrowserrenderingcrawler","Cloudflare Browser Rendering Crawler","cloudflare-crawl","crawler"],["ev-crawler","ev-crawler","ev-crawler","crawler"],["oxylabs","Oxylabs","oxylabs","crawler"],["scrapingbee","ScrapingBee","scrapingbee","crawler"],["scrapingant","ScrapingAnt","scrapingant","crawler"],["zyte","Zyte","zyte","crawler"],["scrapinghub","Zyte","zyte","crawler"],["apify","Apify","apify","crawler"],["crawlbase","Crawlbase","crawlbase","crawler"],["webscrapingapi","WebScrapingAPI","webscrapingapi","crawler"],["chatgpt-user","ChatGPT-User","chatgpt-user","crawler"],["perplexity-user","Perplexity-User","perplexity-user","crawler"],["mistralai-user","MistralAI-User","mistralai-user","crawler"],["exauser","ExaUser","exauser","crawler"],["shap-user","Shap-User","shap-user","crawler"],["meta-externalfetcher","Meta-ExternalFetcher","meta-externalfetcher","crawler"],["gemini-deep-research","Gemini-Deep-Research","gemini-deep-research","crawler"],["copilot","Microsoft Copilot","copilot","crawler"],["cortana","Cortana","cortana","crawler"],["siri","Siri","siri","crawler"],["kimi-user","Kimi-User","kimi-user","crawler"],["keenable-user","Keenable-User","keenable-user","crawler"],["elevenlabsbot","ElevenlabsBot","elevenlabsbot","crawler"],["klaviyoaibot","KlaviyoAIBot","klaviyoaibot","crawler"]];function yr(e){for(let[t,r,n,o]of Je)if(e.includes(t))return{name:r,id:n,kind:o};return null}var vr=/(?:bot|crawler|spider)(?:[/\s);,]|$)/i;function Xe(e){let t=e.toLowerCase(),r=yr(t);return r?.kind==="crawler"||!r&&vr.test(e)}var _r="Search Engine Crawler",te=1e3,xr={search_engines:!0,ai_crawlers:!0,monitoring:!0};function Ar(e){if(!e.includes(":"))return e.split(".").reverse().join(".")+".in-addr.arpa";let[t,r=""]=e.split("::"),n=t?t.split(":"):[],o=r?r.split(":"):[],a=8-n.length-o.length;return a<0?"":[...n,...Array(Math.max(0,a)).fill("0"),...o].map(s=>s.padStart(4,"0")).join("").split("").reverse().join(".")+".ip6.arpa"}function re(e,t){return Promise.race([e,new Promise((r,n)=>setTimeout(()=>n(new Error("dns timeout")),t))])}function kr(e){return{reverse:t=>re(e(Ar(t),"PTR"),te),resolve4:t=>re(e(t,"A"),te),resolve6:t=>re(e(t,"AAAA"),te)}}function Ze(e,t,r,n=typeof Deno<"u"&&Deno&&typeof Deno.resolveDns=="function"?Deno.resolveDns.bind(Deno):void 0,o=Date.now()){return!r||!e||!n||!Xe(t)?Promise.resolve(""):Ye(e,xr,kr(n),o).then(a=>a==="search_engines"?_r:"").catch(()=>"")}var Cr="https://cloudflare-dns.com/dns-query",Rr=1e3,Sr={A:1,PTR:12,AAAA:28};function Er(e=fetch){return async(t,r)=>{let n=Sr[r];if(!n)throw new Error(`unsupported record type ${r}`);let o=`${Cr}?name=${encodeURIComponent(t)}&type=${r}`,a=await e(o,{headers:{accept:"application/dns-json"},signal:AbortSignal.timeout(Rr)});if(!a.ok)throw new Error(`doh ${a.status}`);let i=await a.json();if(i.Status!==0)throw new Error(`dns status ${i.Status}`);let s=(i.Answer??[]).filter(c=>c.type===n&&typeof c.data=="string").map(c=>c.data);if(s.length===0)throw new Error("no records");return s}}function Qe(e,t,r,n=fetch){return Ze(e,t,r,Er(n))}var ne="vercel-0167e3ef2b1e";var et="https://in.webdecoy.com";function tt(e){let t=new Headers(e.headers);return t.delete(U),t.delete(Ue),t}function oe(e,t){let r=tt(e);return t&&r.set(U,t),{action:"continue",headers:r,verdict:t}}async function Pr(e,t,r){try{let n=(r.ingest??"").trim().replace(/\/+$/,"")||et,o=new URL(e.url),a=o.searchParams.get(Ne),i=N(o.hostname),s=await He({apiBase:n,siteKey:r.siteKey},i);if(a!==null)return{action:"respond",response:Ve(a,s?s.mode:"unknown",r.siteKey,G)};if(o.pathname===Q)return{action:"respond",response:await ze(e,n)};if(o.pathname===L)return{action:"respond",response:await De(e,{apiBase:n,siteKey:r.siteKey,sensorKey:r.sensorKey,host:i})};if(!s)return oe(e,null);let c=await Ce(e,s,{siteKey:r.siteKey,verifiedBotCategory:(f,l)=>Qe(t.ip,f.headers.get("user-agent")??"",l,t.fetch??fetch)});if(j(c)){let f=q(e.headers.get("cookie")??"",Y);f&&await Ie(f,r.sensorKey,i,e.headers.get("user-agent")??"",Date.now())&&(c=Re(c))}return qe({...c,refusal:c.pass?null:{ip:t.ip,path:o.pathname}},o.hostname,{siteKey:r.siteKey,apiBase:n,scannerId:r.scannerId,sensorKey:r.sensorKey,bundleVersion:ne,capabilities:G},{waitUntil:f=>t.waitUntil?.(f)},Date.now()),c.pass||c.mode!=="enforce"?oe(e,c.label):{action:"respond",response:We(e,n,r.siteKey,c.label)}}catch{try{return oe(e,null)}catch{return{action:"continue",headers:null,verdict:null}}}}export{ne as BUILD,et as DEFAULT_INGEST,G as VERCEL_VALIDATOR_CAPABILITIES,tt as cleanHeaders,Pr as runGate}; +${_.path}`,y=g.referrals.get(m);y?y.count++:(g.referrals.set(m,{platform:_.platform,path:_.path,count:1}),g.routeBytes+=k.encode(_.platform).length+k.encode(_.path).length+je)}let R=e?.refusal;R&&typeof R.ip=="string"&&R.ip&&typeof R.path=="string"&&R.path.startsWith("/")&&(g.refusals.push({ip:R.ip,path:R.path,at:Math.floor(o/1e3),verdict:a}),g.routeBytes+=nr),g.total++,(g.total>=Qt||g.routeBytes>=er)&&(K(g,r,n),x.delete(b))}catch{}}function ur(e,t,r,n,o){try{let a=(t.bucketStart+ee)*1e3,i=Math.floor(Math.random()*sr),s=Math.max(0,Math.min(a-o+i,ir));n.waitUntil(new Promise(c=>{setTimeout(()=>{try{x.get(e)===t&&(K(t,r,n),x.delete(e))}catch{}c()},s)}))}catch{}}function K(e,t,r){try{if(e.total<=0||e.counts.size===0)return;let n={};for(let[l,h]of e.counts)n[l]=h;let o=[];for(let l of e.routes.values()){let h={pattern:l.pattern,verdict:l.verdict,count:l.count};l.behavior&&(h.behavior=l.behavior),l.crawlerBehavior&&(h.crawler_behavior=l.crawlerBehavior),o.push(h)}let a={organization_id:t.siteKey,bucket_start:e.bucketStart,mode:e.mode,counts:n,route_counts:o,report_id:crypto.randomUUID()};if(e.previews.size>0){let l=[];for(let[h,d]of e.previews){let w={};for(let[b,g]of d.refused)w[b]=g;l.push({pattern:h,evaluated:d.evaluated,additional_refusals:w})}a.previews=l}if(e.credentials.size>0){let l=[];for(let[h,d]of e.credentials)l.push({credential_id:h,outside_reach:d});a.credential_presentations=l}e.referrals.size>0&&(a.ai_referrals=[...e.referrals.values()].map(l=>({platform:l.platform,path:l.path,count:l.count}))),t.propertyId&&(a.property_id=t.propertyId),a.host=e.host,t.bundleVersion&&(a.reporter_version=t.bundleVersion);let i=!!(t.scannerId&&t.sensorKey);i&&(a.scanner_id=t.scannerId),a.capabilities=t.capabilities??Fe;let s=i?e.refusals:[],c=()=>pr(t.apiBase,JSON.stringify(a),i?t.sensorKey:void 0),f=s.length===0?c():fr(t.siteKey,s).then(l=>{a.refusals=l}).catch(()=>{}).then(c);r.waitUntil(f.then(()=>{},()=>{}))}catch{}}async function gr(e,t,r){let n=await crypto.subtle.digest("SHA-256",k.encode(`${e.toLowerCase()}|${t}|${r}`)),o="";for(let a of new Uint8Array(n))o+=a.toString(16).padStart(2,"0");return o.slice(0,or)}async function fr(e,t){let r=[];for(let n of t)r.push({k:await gr(e,n.ip,n.path),t:n.at,v:n.verdict});return r}async function pr(e,t,r){let n=new AbortController,o=setTimeout(()=>n.abort(),ar),a={"content-type":"application/json"};r&&(a["x-wd-sensor-key"]=r);try{await fetch(e.replace(/\/+$/,"")+"/api/v1/clearance/telemetry",{method:"POST",headers:a,body:t,signal:n.signal})}finally{clearTimeout(o)}}var G=["route_min_trust","route_attribution","monitor_routes","route_exceptions","bot_behaviors","credential_reach","bot_verification_rdns","crawler_behavior","ai_referrals"];var dr=[{category:"search_engines",suffixes:[".googlebot.com",".google.com",".search.msn.com",".crawl.yahoo.net",".applebot.apple.com",".yandex.com",".yandex.net",".yandex.ru",".crawl.baidu.com",".crawl.baidu.jp"]}];function hr(e,t){let r=e.toLowerCase().replace(/\.$/,"");for(let n of dr)if(t[n.category]){for(let o of n.suffixes)if(r.endsWith(o))return n.category}return null}var $=new Map,mr=36e5,wr=5e3;async function Ye(e,t,r,n){let o=$.get(e);if(o&&n-o.at=wr&&$.clear(),$.set(e,{category:a,at:n}),a}async function br(e,t,r){let n=e.replace(/\.$/,""),o=t.includes(":")?[r.resolve6(n)]:[r.resolve4(n)];try{return(await Promise.all(o)).flat().some(i=>i===t)}catch{return!1}}var Je=[["reflectionbot","Reflectionbot","reflectionbot","crawler"],["gptbot","GPTBot","gptbot","crawler"],["claudebot","ClaudeBot","claudebot","crawler"],["anthropic-ai","Anthropic","anthropic","crawler"],["claude-web","Claude-Web","claude-web","crawler"],["ccbot","CCBot","ccbot","crawler"],["google-extended","Google-Extended","google-extended","crawler"],["bytespider","ByteSpider","bytespider","crawler"],["amazonbot","Amazonbot","amazonbot","crawler"],["facebookbot","FacebookBot","facebookbot","crawler"],["meta-externalagent","Meta-ExternalAgent","meta-externalagent","crawler"],["cohere-ai","Cohere","cohere-ai","crawler"],["cohere","Cohere","cohere-ai","crawler"],["applebot-extended","Applebot-Extended","applebot-extended","crawler"],["youbot","YouBot","youbot","crawler"],["mistralbot","MistralBot","mistral","crawler"],["gemini","Gemini","gemini","crawler"],["ai2bot","AI2Bot","ai2bot","crawler"],["deepseek","DeepSeek","deepseek","crawler"],["qwen","Qwen","qwen","crawler"],["webzio","Webz.io","webzio","crawler"],["sentibot","Sentibot","sentibot","crawler"],["omgili","Omgili","omgili","crawler"],["img2dataset","img2dataset","img2dataset","crawler"],["timpibot","Timpibot","timpibot","crawler"],["velenpublicwebcrawler","VelenPublicWebCrawler","velenpublicwebcrawler","crawler"],["isscyberriskcrawler","ISSCyberRiskCrawler","isscyberriskcrawler","crawler"],["friendlycrawler","FriendlyCrawler","friendlycrawler","crawler"],["elevenlabscrawler","ElevenlabsCrawler","elevenlabscrawler","crawler"],["riverbot","RiverBot","riverbot","crawler"],["kimibot","KimiBot","kimibot","crawler"],["moonshotbot","MoonshotBot","moonshotbot","crawler"],["chatglm-spider","ChatGLM-Spider","chatglm-spider","crawler"],["duckassistbot","DuckAssistBot","duckassistbot","crawler"],["sofyabot","SofyaBot","sofyabot","crawler"],["xai-searchbot","xAI-SearchBot","xai-searchbot","crawler"],["linkupbot","LinkupBot","linkupbot","crawler"],["perplexitybot","PerplexityBot","perplexitybot","crawler"],["claude-searchbot","Claude-SearchBot","claude-searchbot","crawler"],["oai-searchbot","OAI-SearchBot","oai-searchbot","crawler"],["searchgpt","SearchGPT","searchgpt","crawler"],["phind","Phind","phind","crawler"],["kagi","Kagi","kagi","crawler"],["exasearchbot","Exa","exa","crawler"],["exabot","Exa","exa","crawler"],["shapbot","ShapBot","shapbot","crawler"],["meta-webindexer","Meta-WebIndexer","meta-webindexer","crawler"],["metaphor","Metaphor","metaphor","crawler"],["tavily","Tavily","tavily","crawler"],["bravesearch","BraveSearch","brave-search","crawler"],["neevabot","NeevaBot","neeva","crawler"],["kimi-searchbot","Kimi-SearchBot","kimi-searchbot","crawler"],["isonsearchbot","IsonSearchBot","isonsearchbot","crawler"],["keenablebot","KeenableBot","keenablebot","crawler"],["azureai-searchbot","AzureAI-SearchBot","azureai-searchbot","crawler"],["grokbot","GrokBot","grokbot","crawler"],["operator","Operator","operator","crawler"],["claude-user","Claude-User","claude-user","crawler"],["gemini-user","Gemini-User","gemini-user","crawler"],["googleagent-mariner","GoogleAgent-Mariner","googleagent-mariner","crawler"],["mariner","GoogleAgent-Mariner","googleagent-mariner","crawler"],["amazonbuyforme","AmazonBuyForMe","amazon-buyforme","crawler"],["buyforme","AmazonBuyForMe","amazon-buyforme","crawler"],["browser-use","Browser-Use","browser-use","crawler"],["stagehand","Stagehand","stagehand","crawler"],["manus-user","Manus-User","manus-user","crawler"],["multion","MultiOn","multion","crawler"],["opencode-user","OpenCode-User","opencode-user","crawler"],["iboubot","IbouBot","iboubot","crawler"],["ibou-search","IbouBot","iboubot","crawler"],["googlebot","Googlebot","googlebot","crawler"],["google-inspectiontool","Google-InspectionTool","google-inspectiontool","crawler"],["bingbot","Bingbot","bingbot","crawler"],["msnbot","MSNBot","msnbot","crawler"],["yandexbot","YandexBot","yandexbot","crawler"],["baiduspider","Baiduspider","baiduspider","crawler"],["petalbot","PetalBot","petalbot","crawler"],["duckduckbot","DuckDuckBot","duckduckbot","crawler"],["applebot","Applebot","applebot","crawler"],["sogou","Sogou Spider","sogou","crawler"],["qwantify","Qwantify","qwantify","crawler"],["qwantbot","Qwantify","qwantify","crawler"],["naver","Naver","naver","crawler"],["yeti","Naver","naver","crawler"],["seznambot","SeznamBot","seznam","crawler"],["ecosia","Ecosia","ecosia","crawler"],["mojeekbot","MojeekBot","mojeek","crawler"],["slurp","Yahoo! Slurp","yahoo-slurp","crawler"],["bravebot","Bravebot","bravebot","crawler"],["coccocbot","Coc Coc","coccocbot","crawler"],["yisouspider","YisouSpider","yisouspider","crawler"],["yepbot","YepBot","yepbot","crawler"],["ahrefsbot","AhrefsBot","ahrefsbot","crawler"],["ahrefs","AhrefsBot","ahrefsbot","crawler"],["semrushbot","SemrushBot","semrushbot","crawler"],["semrush","SemrushBot","semrushbot","crawler"],["mj12bot","MJ12bot","mj12bot","crawler"],["dotbot","DotBot","dotbot","crawler"],["rogerbot","Rogerbot","rogerbot","crawler"],["screaming frog","Screaming Frog","screaming-frog","crawler"],["sitebulb","Sitebulb","sitebulb","crawler"],["deepcrawl","DeepCrawl","deepcrawl","crawler"],["oncrawl","OnCrawl","oncrawl","crawler"],["botify","Botify","botify","crawler"],["contentking","ContentKing","contentking","crawler"],["sistrix","SISTRIX","sistrix","crawler"],["serpstat","Serpstat","serpstat","crawler"],["spyfu","SpyFu","spyfu","crawler"],["meta-externalads","meta-externalads","meta-externalads","crawler"],["dataforseobot","DataForSeoBot","dataforseobot","crawler"],["barkrowler","Barkrowler","barkrowler","crawler"],["scrunchbot","Scrunchbot","scrunchbot","crawler"],["webxtrendbot","webXtrendBot","webxtrendbot","crawler"],["serankingbacklinksbot","SERankingBacklinksBot","serankingbacklinksbot","crawler"],["awariobot","AwarioBot","awariobot","crawler"],["awariosmartbot","AwarioBot","awariobot","crawler"],["seojuice-searchbot","SEOJuice-SearchBot","seojuice-searchbot","crawler"],["trendictionbot","trendictionbot","trendictionbot","crawler"],["hubspot crawler","HubSpot Crawler","hubspot-crawler","crawler"],["artex-enrich/","ARTEX","artex","tool"],["nessus","Nessus","nessus","crawler"],["qualys","Qualys","qualys","crawler"],["shodan","Shodan","shodan","crawler"],["censys","Censys","censys","crawler"],["nmap","Nmap","nmap","crawler"],["zap/","OWASP ZAP","zap","crawler"],["burp","Burp Suite","burp","crawler"],["nikto","Nikto","nikto","crawler"],["nuclei","Nuclei","nuclei","crawler"],["acunetix","Acunetix","acunetix","crawler"],["netsparker","Netsparker","netsparker","crawler"],["detectify","Detectify","detectify","crawler"],["palo alto networks","Palo Alto Networks Cortex Xpanse","paloalto-xpanse","crawler"],["recordedfuture","Recorded Future Crawler","recordedfuture","crawler"],["developers.cloudflare.com/security-center","Cloudflare Security Center","cloudflare-security-center","crawler"],["virustotalcloud","VirusTotal","virustotal-cloud","crawler"],["intruder","Intruder","intruder","crawler"],["norma/","Norma WebFetch","norma","tool"],["python-requests","Python-Requests","python-requests","tool"],["python-urllib","Python-urllib","python-urllib","tool"],["python/","Python","python","tool"],["scrapy","Scrapy","scrapy","tool"],["httpx","HTTPX","httpx","tool"],["aiohttp","aiohttp","aiohttp","tool"],["beautifulsoup","BeautifulSoup","beautifulsoup","tool"],["node-fetch","node-fetch","node-fetch","tool"],["axios/","Axios","axios","tool"],["got/","Got","got","tool"],["undici","Undici","undici","tool"],["go-http-client","Go-HTTP-Client","go-http-client","tool"],["colly","Colly","colly","tool"],["java/","Java","java","tool"],["okhttp","OkHttp","okhttp","tool"],["apache-httpclient","Apache-HttpClient","apache-httpclient","tool"],["jsoup","Jsoup","jsoup","tool"],["guzzlehttp","GuzzleHttp","guzzlehttp","tool"],["php/","PHP","php","tool"],["ruby","Ruby","ruby","tool"],["faraday","Faraday","faraday","tool"],["mechanize","Mechanize","mechanize","tool"],["headlesschrome","HeadlessChrome","headlesschrome","tool"],["puppeteer","Puppeteer","puppeteer","tool"],["playwright","Playwright","playwright","tool"],["selenium","Selenium","selenium","tool"],["phantomjs","PhantomJS","phantomjs","tool"],["splash","Splash","splash","tool"],["browserless","Browserless","browserless","tool"],["browserbase","Browserbase","browserbase","tool"],["ia_archiver","Internet Archive","ia-archiver","crawler"],["archive.org_bot","Archive.org","archive-org-bot","crawler"],["wayback","Wayback Machine","wayback","crawler"],["heritrix","Heritrix","heritrix","crawler"],["brozzler","Brozzler","brozzler","crawler"],["facebookexternalhit","Facebook","facebookexternalhit","crawler"],["facebot","Facebot","facebot","crawler"],["twitterbot","Twitterbot","twitterbot","crawler"],["linkedinbot","LinkedInBot","linkedinbot","crawler"],["slackbot","Slackbot","slackbot","crawler"],["telegrambot","TelegramBot","telegrambot","crawler"],["whatsapp","WhatsApp","whatsapp","crawler"],["discordbot","Discordbot","discordbot","crawler"],["pinterest","Pinterest","pinterestbot","crawler"],["tumblr","Tumblr","tumblr","crawler"],["reddit","Reddit","reddit","crawler"],["embedly","Embedly","embedly","crawler"],["iframely","Iframely","iframely","crawler"],["adsbot-google","AdsBot-Google","adsbot-google","crawler"],["stripebot","Stripebot","stripebot","crawler"],["google-read-aloud","Google-Read-Aloud","google-read-aloud","crawler"],["google-safety","Google-Safety","google-safety","crawler"],["oai-adsbot","OAI-AdsBot","oai-adsbot","crawler"],["kakaobot","KakaoBot","kakaobot","crawler"],["curl/","cURL","curl","tool"],["wget/","Wget","wget","tool"],["libwww-perl","libwww-perl","libwww-perl","tool"],["lwp-","LWP","lwp","tool"],["httrack","HTTrack","httrack","tool"],["webdecoybot","WebDecoyBot","webdecoybot","crawler"],["uptimerobot","UptimeRobot","uptimerobot","crawler"],["pingdom","Pingdom","pingdom","crawler"],["statuscake","StatusCake","statuscake","crawler"],["betteruptime","Better Uptime","better-uptime","crawler"],["datadog","Datadog Synthetics","datadog-synthetics","crawler"],["newrelic","New Relic","newrelic","crawler"],["site24x7","Site24x7","site24x7","crawler"],["freshping","Freshping","freshping","crawler"],["hetrixtools","HetrixTools","hetrixtools","crawler"],["nodeping","NodePing","nodeping","crawler"],["gtmetrix","GTmetrix","gtmetrix","crawler"],["chrome-lighthouse","Lighthouse","chrome-lighthouse","crawler"],["google page speed","Lighthouse","chrome-lighthouse","crawler"],["feedly","Feedly","feedly","crawler"],["livelapbot","LivelapBot","livelapbot","crawler"],["feedfetcher","Feedfetcher-Google","feedfetcher-google","crawler"],["newsblur","NewsBlur","newsblur","crawler"],["inoreader","Inoreader","inoreader","crawler"],["theoldreader","The Old Reader","theoldreader","crawler"],["feedbin","Feedbin","feedbin","crawler"],["miniflux","Miniflux","miniflux","crawler"],["freshrss","FreshRSS","freshrss","crawler"],["commafeed","CommaFeed","commafeed","crawler"],["diffbot","Diffbot","diffbot","crawler"],["import.io","Import.io","import-io","crawler"],["brightdata","Bright Data","bright-data","crawler"],["luminati","Bright Data","bright-data","crawler"],["brightbot","Brightbot","brightbot","crawler"],["cloudflarebrowserrenderingcrawler","Cloudflare Browser Rendering Crawler","cloudflare-crawl","crawler"],["ev-crawler","ev-crawler","ev-crawler","crawler"],["oxylabs","Oxylabs","oxylabs","crawler"],["scrapingbee","ScrapingBee","scrapingbee","crawler"],["scrapingant","ScrapingAnt","scrapingant","crawler"],["zyte","Zyte","zyte","crawler"],["scrapinghub","Zyte","zyte","crawler"],["apify","Apify","apify","crawler"],["crawlbase","Crawlbase","crawlbase","crawler"],["webscrapingapi","WebScrapingAPI","webscrapingapi","crawler"],["chatgpt-user","ChatGPT-User","chatgpt-user","crawler"],["perplexity-user","Perplexity-User","perplexity-user","crawler"],["mistralai-user","MistralAI-User","mistralai-user","crawler"],["exauser","ExaUser","exauser","crawler"],["shap-user","Shap-User","shap-user","crawler"],["meta-externalfetcher","Meta-ExternalFetcher","meta-externalfetcher","crawler"],["gemini-deep-research","Gemini-Deep-Research","gemini-deep-research","crawler"],["copilot","Microsoft Copilot","copilot","crawler"],["cortana","Cortana","cortana","crawler"],["siri","Siri","siri","crawler"],["kimi-user","Kimi-User","kimi-user","crawler"],["keenable-user","Keenable-User","keenable-user","crawler"],["elevenlabsbot","ElevenlabsBot","elevenlabsbot","crawler"],["klaviyoaibot","KlaviyoAIBot","klaviyoaibot","crawler"]];function yr(e){for(let[t,r,n,o]of Je)if(e.includes(t))return{name:r,id:n,kind:o};return null}var vr=/(?:bot|crawler|spider)(?:[/\s);,]|$)/i;function Xe(e){let t=e.toLowerCase(),r=yr(t);return r?.kind==="crawler"||!r&&vr.test(e)}var _r="Search Engine Crawler",te=1e3,xr={search_engines:!0,ai_crawlers:!0,monitoring:!0};function Ar(e){if(!e.includes(":"))return e.split(".").reverse().join(".")+".in-addr.arpa";let[t,r=""]=e.split("::"),n=t?t.split(":"):[],o=r?r.split(":"):[],a=8-n.length-o.length;return a<0?"":[...n,...Array(Math.max(0,a)).fill("0"),...o].map(s=>s.padStart(4,"0")).join("").split("").reverse().join(".")+".ip6.arpa"}function re(e,t){return Promise.race([e,new Promise((r,n)=>setTimeout(()=>n(new Error("dns timeout")),t))])}function kr(e){return{reverse:t=>re(e(Ar(t),"PTR"),te),resolve4:t=>re(e(t,"A"),te),resolve6:t=>re(e(t,"AAAA"),te)}}function Ze(e,t,r,n=typeof Deno<"u"&&Deno&&typeof Deno.resolveDns=="function"?Deno.resolveDns.bind(Deno):void 0,o=Date.now()){return!r||!e||!n||!Xe(t)?Promise.resolve(""):Ye(e,xr,kr(n),o).then(a=>a==="search_engines"?_r:"").catch(()=>"")}var Cr="https://cloudflare-dns.com/dns-query",Rr=1e3,Sr={A:1,PTR:12,AAAA:28};function Er(e=fetch){return async(t,r)=>{let n=Sr[r];if(!n)throw new Error(`unsupported record type ${r}`);let o=`${Cr}?name=${encodeURIComponent(t)}&type=${r}`,a=await e(o,{headers:{accept:"application/dns-json"},signal:AbortSignal.timeout(Rr)});if(!a.ok)throw new Error(`doh ${a.status}`);let i=await a.json();if(i.Status!==0)throw new Error(`dns status ${i.Status}`);let s=(i.Answer??[]).filter(c=>c.type===n&&typeof c.data=="string").map(c=>c.data);if(s.length===0)throw new Error("no records");return s}}function Qe(e,t,r,n=fetch){return Ze(e,t,r,Er(n))}var ne="vercel-20ce309dd724";var et="https://in.webdecoy.com";function tt(e){let t=new Headers(e.headers);return t.delete(U),t.delete(Ue),t}function oe(e,t){let r=tt(e);return t&&r.set(U,t),{action:"continue",headers:r,verdict:t}}async function Pr(e,t,r){try{let n=(r.ingest??"").trim().replace(/\/+$/,"")||et,o=new URL(e.url),a=o.searchParams.get(Ne),i=N(o.hostname),s=await He({apiBase:n,siteKey:r.siteKey},i);if(a!==null)return{action:"respond",response:Ve(a,s?s.mode:"unknown",r.siteKey,G)};if(o.pathname===Q)return{action:"respond",response:await ze(e,n)};if(o.pathname===L)return{action:"respond",response:await De(e,{apiBase:n,siteKey:r.siteKey,sensorKey:r.sensorKey,host:i})};if(!s)return oe(e,null);let c=await Ce(e,s,{siteKey:r.siteKey,verifiedBotCategory:(f,l)=>Qe(t.ip,f.headers.get("user-agent")??"",l,t.fetch??fetch)});if(j(c)){let f=q(e.headers.get("cookie")??"",Y);f&&await Ie(f,r.sensorKey,i,e.headers.get("user-agent")??"",Date.now())&&(c=Re(c))}return qe({...c,refusal:c.pass?null:{ip:t.ip,path:o.pathname}},o.hostname,{siteKey:r.siteKey,apiBase:n,scannerId:r.scannerId,sensorKey:r.sensorKey,bundleVersion:ne,capabilities:G},{waitUntil:f=>t.waitUntil?.(f)},Date.now()),c.pass||c.mode!=="enforce"?oe(e,c.label):{action:"respond",response:We(e,n,r.siteKey,c.label)}}catch{try{return oe(e,null)}catch{return{action:"continue",headers:null,verdict:null}}}}export{ne as BUILD,et as DEFAULT_INGEST,G as VERCEL_VALIDATOR_CAPABILITIES,tt as cleanHeaders,Pr as runGate};