@aientrophy/sdk 0.3.1 → 0.3.2
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.
- package/dist/{anti-debug-CRuvY4WC.js → anti-debug-CZyDVzB-.js} +22 -0
- package/dist/anti-debug-u8v02mI_.cjs +1 -0
- package/dist/{console-aIpHQlgP.cjs → console-C5WWu7ZB.cjs} +1 -1
- package/dist/{console-DbZZ4Ctg.js → console-ZtBun_Tc.js} +1 -1
- package/dist/core.js +1 -1
- package/dist/npm/index.cjs.js +1 -1
- package/dist/npm/index.es.js +2 -2
- package/dist/sri-hashes.json +2 -2
- package/dist/types/protection/anti-debug.d.ts +6 -0
- package/package.json +1 -1
- package/dist/anti-debug-CYwG4s7P.cjs +0 -1
- package/dist/index.d.ts +0 -21
|
@@ -33,6 +33,7 @@ class AntiDebug {
|
|
|
33
33
|
static preventDevTools() {
|
|
34
34
|
this.intervalId = setInterval(() => {
|
|
35
35
|
this.debuggerCheck();
|
|
36
|
+
this.devtoolsCloseCheck();
|
|
36
37
|
}, this.checkInterval);
|
|
37
38
|
}
|
|
38
39
|
static debuggerCheck() {
|
|
@@ -50,6 +51,27 @@ class AntiDebug {
|
|
|
50
51
|
})();
|
|
51
52
|
})();
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Detect DevTools open via timing attack and close/redirect.
|
|
56
|
+
* When debugger statement is hit with DevTools open, execution pauses,
|
|
57
|
+
* causing measurable delay. If delay > threshold, DevTools is open.
|
|
58
|
+
*/
|
|
59
|
+
static devtoolsCloseCheck() {
|
|
60
|
+
if (navigator.maxTouchPoints > 0 || /Mobile|Android|iPhone|iPad/i.test(navigator.userAgent)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const threshold = 100;
|
|
64
|
+
const start = performance.now();
|
|
65
|
+
(function() {
|
|
66
|
+
}).constructor("debugger")();
|
|
67
|
+
const elapsed = performance.now() - start;
|
|
68
|
+
if (elapsed > threshold) {
|
|
69
|
+
try {
|
|
70
|
+
document.body.innerHTML = '<div style="display:flex;align-items:center;justify-content:center;height:100vh;font-family:sans-serif;background:#111;color:#fff"><div style="text-align:center"><h2 style="margin-bottom:12px">⚠ 보안 경고</h2><p style="color:#999">개발자 도구가 감지되었습니다.<br>페이지를 계속 이용하려면 개발자 도구를 닫아주세요.</p></div></div>';
|
|
71
|
+
} catch (_) {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
53
75
|
static disableConsole() {
|
|
54
76
|
const noop = () => {
|
|
55
77
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__publicField=(e,t,o)=>((e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o)(e,"symbol"!=typeof t?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _originalConsole={};class AntiDebug{static start(){this.saveConsole(),this.disableConsole(),this.preventDevTools()}static stop(){this.intervalId&&clearInterval(this.intervalId)}static getOriginalConsole(){return _originalConsole}static saveConsole(){const e=["log","debug","info","warn","error","table","trace","dir","clear"];try{const t=window.console;if(!t)return;for(const o of e)"function"==typeof t[o]&&(_originalConsole[o]=t[o].bind(t))}catch(t){}}static preventDevTools(){this.intervalId=setInterval(()=>{this.debuggerCheck(),this.devtoolsCloseCheck()},this.checkInterval)}static debuggerCheck(){!function(){try{(function(){}).constructor("debugger")()}catch(e){}}()}static devtoolsCloseCheck(){if(navigator.maxTouchPoints>0||/Mobile|Android|iPhone|iPad/i.test(navigator.userAgent))return;const e=performance.now();(function(){}).constructor("debugger")();if(performance.now()-e>100)try{document.body.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100vh;font-family:sans-serif;background:#111;color:#fff"><div style="text-align:center"><h2 style="margin-bottom:12px">⚠ 보안 경고</h2><p style="color:#999">개발자 도구가 감지되었습니다.<br>페이지를 계속 이용하려면 개발자 도구를 닫아주세요.</p></div></div>'}catch(t){}}static disableConsole(){const e=()=>{},t=["log","debug","info","warn","error","table","trace","dir"];try{const o=window.console;if(!o)return;for(const n of t)o[n]&&(o[n]=e)}catch(o){}}}__publicField(AntiDebug,"checkInterval",1e3),__publicField(AntiDebug,"intervalId"),exports.AntiDebug=AntiDebug;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__publicField=(t,e,i)=>((t,e,i)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const antiDebug=require("./anti-debug-
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__publicField=(t,e,i)=>((t,e,i)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const antiDebug=require("./anti-debug-u8v02mI_.cjs");exports.ConsoleDetector=class{constructor(t){__publicField(this,"onDetect"),__publicField(this,"intervals",[]),__publicField(this,"detected",!1),this.onDetect=t}start(){this.startGetterTrap(),this.startSizeDetection()}stop(){for(const t of this.intervals)clearInterval(t);this.intervals=[]}triggerDetect(){this.detected||(this.detected=!0,this.onDetect(),setTimeout(()=>{this.detected=!1},5e3))}startGetterTrap(){const t=antiDebug.AntiDebug.getOriginalConsole(),e=t.log,i=t.clear;if(!e)return;const r=document.createElement("div");Object.defineProperty(r,"id",{get:()=>(this.triggerDetect(),"")});const n=/./;n.toString=()=>(this.triggerDetect(),"");const s=setInterval(()=>{try{e(r),e(n),i&&i()}catch(t){}},1500);this.intervals.push(s)}startSizeDetection(){if(navigator.maxTouchPoints>0||/Mobile|Android|iPhone|iPad/i.test(navigator.userAgent))return;const t=setInterval(()=>{const t=window.outerWidth-window.innerWidth>160,e=window.outerHeight-window.innerHeight>160;(t||e)&&this.triggerDetect()},2e3);this.intervals.push(t)}};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { AntiDebug } from "./anti-debug-
|
|
4
|
+
import { AntiDebug } from "./anti-debug-CZyDVzB-.js";
|
|
5
5
|
class ConsoleDetector {
|
|
6
6
|
constructor(onDetect) {
|
|
7
7
|
__publicField(this, "onDetect");
|
package/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SecuritySDKCore={})}(this,function(t){"use strict";var e=Object.defineProperty,s=(t,s,i)=>((t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i)(t,"symbol"!=typeof s?s+"":s,i);const i="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqbBCvDqyUtfhgI/Lo5pDtn1phwA6qczAyp8N1ZgQ68OTxgbJUGiXV6N67p15bBdME1R4va51P2Czq2IbRby/N+GHTciTaXvmusV8IjnIOGtKlGxWCuKIPrCS+rGjGA2j1irxBbNpqItltFxjhxBGOzsyQAF6LNIz5IKA7sC6cSH8zUyLuFrV96udc801Zc4nCJG64ZljNbDvlVbJJZ6ex5OLLS6AnrVAXpjEDR/MI/I8JvAPe/psHj6EpXgvKrBYMBOH3jzQRzMFoR79jXyGNgPjdy0A+f6RVuEG8H5sUXKeyy+cFvaT+pm6h+t6RPED11tCOwQxYZ2pExhhPxDGeQIDAQAB";class n{static async init(){if(!this.sessionKey)try{await this.initECDH()}catch(t){await this.initRSA()}}static async initECDH(){const t=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"]),e=await window.crypto.subtle.exportKey("raw",t.publicKey);this.ecdhPublicKeyBase64=this.arrayBufferToBase64(e);const s=(window.__securitySDKEndpoint||"").replace(/\/events$/,""),i=await fetch(`${s}/key-exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientPublicKey:this.ecdhPublicKeyBase64})});if(!i.ok)throw new Error("Key exchange failed");const{serverPublicKey:n,salt:a}=await i.json(),r=this.base64ToArrayBuffer(n),o=await window.crypto.subtle.importKey("raw",r,{name:"ECDH",namedCurve:"P-256"},!1,[]),c=await window.crypto.subtle.deriveBits({name:"ECDH",public:o},t.privateKey,256),l=await window.crypto.subtle.importKey("raw",c,"HKDF",!1,["deriveKey"]),h=this.base64ToArrayBuffer(a);this.sessionKey=await window.crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:h,info:(new TextEncoder).encode("aientrophy-session-enc")},l,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),this.protocolVersion=2}static async initRSA(){this.sessionKey=await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);const t=await this.importRSAPublicKey(i),e=await window.crypto.subtle.exportKey("raw",this.sessionKey),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},t,e);this.encryptedSessionKey=this.arrayBufferToBase64(s),this.protocolVersion=1}static async encrypt(t){this.sessionKey||await this.init();const e=JSON.stringify(t),s=(new TextEncoder).encode(e),i=window.crypto.getRandomValues(new Uint8Array(12)),n=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:i},this.sessionKey,s),a=new Uint8Array(n),r=a.slice(0,a.length-16),o=a.slice(a.length-16),c={ek:2===this.protocolVersion?this.ecdhPublicKeyBase64:this.encryptedSessionKey,d:this.arrayBufferToBase64(r.buffer),iv:this.arrayBufferToBase64(i.buffer),tag:this.arrayBufferToBase64(o.buffer)};return 2===this.protocolVersion&&(c.v=2),c}static async decrypt(t){if(!this.sessionKey)throw new Error("Session key not initialized");const e=this.base64ToArrayBuffer(t.d),s=this.base64ToArrayBuffer(t.iv),i=this.base64ToArrayBuffer(t.tag),n=new Uint8Array(e.byteLength+i.byteLength);n.set(new Uint8Array(e),0),n.set(new Uint8Array(i),e.byteLength);const a=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:s},this.sessionKey,n),r=(new TextDecoder).decode(a);return JSON.parse(r)}static setEndpoint(t){window.__securitySDKEndpoint=t}static async importRSAPublicKey(t){const e=window.atob(t),s=this.str2ab(e);return await window.crypto.subtle.importKey("spki",s,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"])}static str2ab(t){const e=new ArrayBuffer(t.length),s=new Uint8Array(e);for(let i=0,n=t.length;i<n;i++)s[i]=t.charCodeAt(i);return e}static arrayBufferToBase64(t){let e="";const s=new Uint8Array(t),i=s.byteLength;for(let n=0;n<i;n++)e+=String.fromCharCode(s[n]);return window.btoa(e)}static base64ToArrayBuffer(t){const e=window.atob(t),s=e.length,i=new Uint8Array(s);for(let n=0;n<s;n++)i[n]=e.charCodeAt(n);return i.buffer}}s(n,"sessionKey",null),s(n,"ecdhPublicKeyBase64",null),s(n,"encryptedSessionKey",null),s(n,"protocolVersion",2);const a=new Set(["rapid_click","honeypot_triggered","devtools_open","invisible_interaction","integrity_violation","dom_mutation","behavior_metrics","behavior_analysis","input_metrics","keystroke_dynamics","environmental_integrity","init_signals","automation_detected","cross_context_mismatch","headless_probe"]);class r{constructor(){s(this,"handlers",new Map),s(this,"configCallbacks",{})}setConfigCallbacks(t){this.configCallbacks=t}on(t,e){this.addHandler(t,e,!1)}once(t,e){this.addHandler(t,e,!0)}off(t,e){const s=this.handlers.get(t);if(!s)return;const i=s.filter(t=>t.handler!==e);0===i.length?this.handlers.delete(t):this.handlers.set(t,i)}emit(t,...e){this.callHandlers(t,e);const s=t.indexOf(":");if(-1!==s){const i=t.substring(0,s);this.callHandlers(i,e)}this.callConfigCallback(t,e)}emitChallenge(t){return new Promise(e=>{let s=!1;const i=t=>{s||(s=!0,e(t))},n=this.handlers.has("challenge")&&this.handlers.get("challenge").length>0,a=!!this.configCallbacks.onChallenge;n||a?(this.callHandlers("challenge",[t,i]),this.configCallbacks.onChallenge&&this.safeCall(this.configCallbacks.onChallenge,[t,i]),setTimeout(()=>{s||(s=!0,e(!1))},5e3)):e(!1)})}addHandler(t,e,s){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push({handler:e,once:s})}callHandlers(t,e){const s=this.handlers.get(t);if(!s||0===s.length)return;const i=[];for(let n=0;n<s.length;n++)this.safeCall(s[n].handler,e),s[n].once&&i.push(n);for(let n=i.length-1;n>=0;n--)s.splice(i[n],1);0===s.length&&this.handlers.delete(t)}callConfigCallback(t,e){if(t.startsWith("threat:")||"threat"===t)return void(t.startsWith("threat:")&&this.configCallbacks.onThreatDetected&&this.safeCall(this.configCallbacks.onThreatDetected,e));const s={ready:"onReady",error:"onError",block:"onBlock",allow:"onAllow"}[t];s&&this.configCallbacks[s]&&this.safeCall(this.configCallbacks[s],e)}safeCall(t,e){try{t(...e)}catch(s){}}}class o{constructor(){s(this,"endpoint",""),s(this,"clientKey",""),s(this,"encryptionRequired",!1),s(this,"currentNonce",""),s(this,"buffer",[]),s(this,"batchSize",20),s(this,"flushInterval",5e3),s(this,"intervalId"),s(this,"responseHandler",null),s(this,"callbackManager",null),s(this,"flushing",!1),s(this,"pendingFlush",!1),s(this,"backoffMs",0),s(this,"maxBackoffMs",6e4),s(this,"_lastBackoffStart",0),this.startFlushInterval()}setConfig(t){var e,s;this.endpoint=t.endpoint,this.clientKey=t.clientKey,this.encryptionRequired=(null==(e=t.serverConfig)?void 0:e.encryptionRequired)??!1,this.currentNonce=(null==(s=t.serverConfig)?void 0:s.initialNonce)??"",n.setEndpoint(t.endpoint)}setResponseHandler(t){this.responseHandler=t}setCallbackManager(t){this.callbackManager=t}send(t,e={}){const s=Date.now();if(this.buffer.push({type:t,data:e,timestamp:s}),this.callbackManager)if(a.has(t)){const i={type:t,data:e,timestamp:s};this.callbackManager.emit(`threat:${t}`,i)}else this.callbackManager.emit(`data:${t}`,{type:t,data:e,timestamp:s});this.buffer.length>=this.batchSize&&this.flush()}async flush(){if(0===this.buffer.length||!this.endpoint)return;if(this.backoffMs>0){const t=Date.now();if(this._lastBackoffStart||(this._lastBackoffStart=t),t-this._lastBackoffStart<this.backoffMs)return;this._lastBackoffStart=0}if(this.flushing)return void(this.pendingFlush=!0);this.flushing=!0;const t=this.buffer;this.buffer=[];try{let i;if(this.encryptionRequired){const e=await n.encrypt(t);i=JSON.stringify(e)}else i=JSON.stringify(t);const a={"Content-Type":"application/json","x-client-key":this.clientKey};this.currentNonce&&(a["x-request-nonce"]=this.currentNonce,this.currentNonce="");try{const s=await fetch(this.endpoint,{method:"POST",body:i,headers:a,keepalive:!0});if(429===s.status)return this.buffer=t.concat(this.buffer).slice(0,500),this.backoffMs=0===this.backoffMs?5e3:Math.min(2*this.backoffMs,this.maxBackoffMs),void(this._lastBackoffStart=Date.now());if(this.backoffMs=0,s.ok&&this.callbackManager&&this.callbackManager.emit("allow",{action:"allow"}),s.ok)try{const t=await s.json();let e=t;this.encryptionRequired&&(e=await n.decrypt(t)),(null==e?void 0:e.nonce)&&(this.currentNonce=e.nonce),this.responseHandler&&this.responseHandler(e)}catch(e){}}catch(s){this.callbackManager&&this.callbackManager.emit("error",{code:"NETWORK_ERROR",message:"Failed to send security events"})}}catch(e){this.callbackManager&&this.callbackManager.emit("error",{code:"PAYLOAD_ERROR",message:"Failed to prepare security payload"})}finally{this.flushing=!1,this.pendingFlush&&(this.pendingFlush=!1,this.flush())}}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.flush()}startFlushInterval(){this.intervalId=setInterval(()=>{this.flush()},this.flushInterval)}}class c{constructor(t){s(this,"transmitter"),s(this,"isCollecting",!1),this.transmitter=t}start(){this.isCollecting||(this.isCollecting=!0)}stop(){this.isCollecting=!1}}class l{constructor(t){s(this,"transmitter"),s(this,"clickHistory",[]),s(this,"THRESHOLD_COUNT",3),s(this,"THRESHOLD_TIME",500),this.transmitter=t,this.init()}init(){document.addEventListener("click",t=>this.handleClick(t),!0)}handleClick(t){const e=Date.now();if(this.clickHistory.push(e),this.clickHistory=this.clickHistory.filter(t=>e-t<=this.THRESHOLD_TIME),this.clickHistory.length>=this.THRESHOLD_COUNT){const s=t.target,i={tagName:s.tagName,id:s.id,className:s.className,x:t.clientX,y:t.clientY};this.transmitter.send("rapid_click",{count:this.clickHistory.length,duration:this.THRESHOLD_TIME,target:i,timestamp:e}),this.clickHistory=[]}}}class h{constructor(t){s(this,"transmitter"),s(this,"element",null),this.transmitter=t}start(){this.element=document.createElement("input"),this.element.type="text";const t=["website","email_confirm","url","homepage","fax_number","address_line_2"],e=t[Math.floor(Math.random()*t.length)],s=Math.random().toString(36).substr(2,5);this.element.id="hp-"+Math.random().toString(36).substr(2,9),this.element.name=`${e}-${s}`,this.element.autocomplete="off",Object.assign(this.element.style,{position:"absolute",opacity:"0",top:"0",left:"-9999px",height:"1px",width:"1px",zIndex:"-1",border:"none"}),this.element.tabIndex=-1,this.element.setAttribute("aria-hidden","true"),this.element.setAttribute("role","presentation");const i=t=>{var e;this.transmitter.send("honeypot_triggered",{eventType:t.type,value:null==(e=this.element)?void 0:e.value,timestamp:Date.now()})};this.element.addEventListener("input",i),this.element.addEventListener("focus",i),this.element.addEventListener("click",i),document.body.appendChild(this.element)}stop(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class d{constructor(t,e){s(this,"transmitter"),s(this,"wasmService"),s(this,"buffer",[]),s(this,"BUFFER_SIZE",50),s(this,"SAMPLE_INTERVAL",100),s(this,"SEND_COOLDOWN",5e3),s(this,"lastSampleTime",0),s(this,"lastSendTime",0),s(this,"handleMouseMove",t=>{const e=Date.now();e-this.lastSampleTime<this.SAMPLE_INTERVAL||(this.lastSampleTime=e,this.buffer.push({x:t.clientX,y:t.clientY,time:e}),this.buffer.length>this.BUFFER_SIZE&&this.buffer.shift(),this.buffer.length>=this.BUFFER_SIZE&&e-this.lastSendTime>=this.SEND_COOLDOWN&&(this.analyze(),this.lastSendTime=e))}),this.transmitter=t,this.wasmService=e}start(){"undefined"!=typeof document&&document.addEventListener("mousemove",this.handleMouseMove)}stop(){"undefined"!=typeof document&&document.removeEventListener("mousemove",this.handleMouseMove)}analyze(){if(this.buffer.length<20)return;const t=this.wasmService.calculateEntropy(this.buffer),e=this.calculateSpeedVariance(),s=this.buffer.map(t=>({x:t.x,y:t.y,t:t.time}));this.transmitter.send("behavior_metrics",{entropy:t,speedVariance:e,sampleSize:this.buffer.length,timestamp:Date.now(),rawTrajectory:s})}calculateSpeedVariance(){const t=[];for(let s=1;s<this.buffer.length;s++){const e=this.buffer[s-1],i=this.buffer[s],n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2)),a=i.time-e.time;a>0&&t.push(n/a)}if(t.length<2)return 1;const e=t.reduce((t,e)=>t+e,0)/t.length;return t.reduce((t,s)=>t+Math.pow(s-e,2),0)/t.length}}class u{constructor(t){s(this,"lastInteractionTime",0),s(this,"lastInteractionType","none"),s(this,"transmitter"),s(this,"isMobile",!1),s(this,"keyPressTimes",new Map),s(this,"lastKeyUpTime",0),s(this,"flightTimes",[]),s(this,"dwellTimes",[]),s(this,"suspiciousFocusCount",0),s(this,"suspiciousFocusResetTimer",null),s(this,"rawKeystrokes",[]),this.transmitter=t,this.isMobile=this.detectMobile()}start(){this.initListeners()}detectMobile(){return"undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0)}initListeners(){if("undefined"==typeof document)return;["mousedown","keydown","touchstart","touchend"].forEach(t=>{document.addEventListener(t,t=>{this.lastInteractionTime=Date.now(),this.lastInteractionType=t.type},{passive:!0,capture:!0})}),document.addEventListener("focus",t=>{const e=t.target;"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName||(this.checkFocusIntegrity(),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[],this.lastKeyUpTime=0)},{capture:!0}),document.addEventListener("keydown",t=>{const e=t.target;if("INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName)return;const s=Date.now();if(this.keyPressTimes.set(t.code,s),this.rawKeystrokes.push({code:t.code,t:s,type:"down"}),this.lastKeyUpTime>0){const t=s-this.lastKeyUpTime;t<2e3&&this.flightTimes.push(t)}},{passive:!0,capture:!0}),document.addEventListener("keyup",t=>{const e=t.target;if("INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName)return;const s=Date.now();this.lastKeyUpTime=s,this.rawKeystrokes.push({code:t.code,t:s,type:"up"});const i=this.keyPressTimes.get(t.code);if(i){const e=s-i;this.dwellTimes.push(e),this.keyPressTimes.delete(t.code)}this.flightTimes.length>=10&&this.reportKeystrokeDynamics(e)},{passive:!0,capture:!0}),document.addEventListener("blur",t=>{const e=t.target;("INPUT"===e.tagName||"TEXTAREA"===e.tagName)&&this.flightTimes.length>0&&this.reportKeystrokeDynamics(e)},{capture:!0})}checkFocusIntegrity(){const t=Date.now(),e=t-this.lastInteractionTime;performance.now()<5e3||(e>200?(this.suspiciousFocusCount++,clearTimeout(this.suspiciousFocusResetTimer),this.suspiciousFocusResetTimer=setTimeout(()=>{this.suspiciousFocusCount=0},3e3),this.transmitter.send("behavior_metrics",{type:"suspicious_focus",timeSinceInteraction:e,lastInteraction:this.lastInteractionType,consecutiveCount:this.suspiciousFocusCount,timestamp:t})):this.suspiciousFocusCount=0)}reportKeystrokeDynamics(t){const e=this.average(this.flightTimes),s=this.variance(this.flightTimes,e),i=this.average(this.dwellTimes),n=this.variance(this.dwellTimes,i);this.transmitter.send("input_metrics",{element:t.id||t.tagName,flight:{avg:e,variance:s,samples:this.flightTimes.length},dwell:{avg:i,variance:n},isMobile:this.isMobile,timestamp:Date.now(),rawKeystrokes:[...this.rawKeystrokes]}),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[]}average(t){return 0===t.length?0:t.reduce((t,e)=>t+e,0)/t.length}variance(t,e){return 0===t.length?0:t.reduce((t,s)=>t+Math.pow(s-e,2),0)/t.length}}class m{constructor(){s(this,"wasmModule",null),s(this,"memory",null),s(this,"instance",null)}async load(t){try{const e=await fetch(`${t}/sdk/core.wasm`);if(!e.ok)throw new Error(`HTTP ${e.status}`);const s={env:{abort:()=>{}}};if(WebAssembly.instantiateStreaming){const t=await WebAssembly.instantiateStreaming(e,s);this.instance=t.instance}else{const t=await e.arrayBuffer(),i=await WebAssembly.instantiate(t,s);this.instance=i.instance}this.wasmModule=this.instance.exports,this.memory=this.wasmModule.memory}catch(e){}}isLoaded(){return!!this.instance}calculateEntropy(t){if(!this.instance||!this.wasmModule)return 0;const e=2*t.length,s=8*e;try{const i=this.wasmModule.__new(s,0),n=new Float64Array(this.memory.buffer,i,e);for(let e=0;e<t.length;e++)n[2*e]=t[e].x,n[2*e+1]=t[e].y;return this.wasmModule.calculateEntropy(i,e)}catch(i){return 0}}simpleHash(t){if(!this.instance||!this.wasmModule)return 0;try{const e=(new TextEncoder).encode(t),s=e.length,i=this.wasmModule.__new(s,0);return new Uint8Array(this.memory.buffer,i,s).set(e),this.wasmModule.simpleHash(i,s)}catch(e){return 0}}}class p{constructor(t,e){s(this,"transmitter"),s(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof document||setTimeout(async()=>{const t=await this.generateFingerprint(),e=this.collectWebGLFingerprint(),s=this.collectAudioFingerprint();this.transmitter.send("fingerprint_collected",{hash:t,webgl:e,audio:s}),this.hasRun=!0},500)}async generateFingerprint(){try{const t=document.createElement("canvas"),e=t.getContext("2d");if(!e)return"unknown";e.textBaseline="top",e.font='14px "Arial"',e.textBaseline="alphabetic",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("aientrophy Security 😃",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("aientrophy Security 😃",4,17),e.globalCompositeOperation="multiply",e.fillStyle="rgb(255,0,255)",e.beginPath(),e.arc(50,50,50,0,2*Math.PI,!0),e.closePath(),e.fill(),e.fillStyle="rgb(0,255,255)",e.beginPath(),e.arc(100,50,50,0,2*Math.PI,!0),e.closePath(),e.fill(),e.fillStyle="rgb(255,255,0)",e.beginPath(),e.arc(75,100,50,0,2*Math.PI,!0),e.closePath(),e.fill();const s=t.toDataURL();return await this.sha256(s)}catch(t){return"error"}}async sha256(t){const e=(new TextEncoder).encode(t),s=await window.crypto.subtle.digest("SHA-256",e),i=new Uint8Array(s);return Array.from(i).map(t=>t.toString(16).padStart(2,"0")).join("")}collectWebGLFingerprint(){try{const t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return{available:!1};const s=e,i={available:!0},n=s.getExtension("WEBGL_debug_renderer_info");return n&&(i.renderer=s.getParameter(n.UNMASKED_RENDERER_WEBGL),i.vendor=s.getParameter(n.UNMASKED_VENDOR_WEBGL)),i.maxTextureSize=s.getParameter(s.MAX_TEXTURE_SIZE),i.maxViewportDims=Array.from(s.getParameter(s.MAX_VIEWPORT_DIMS)),i.maxRenderbufferSize=s.getParameter(s.MAX_RENDERBUFFER_SIZE),i.maxVertexAttribs=s.getParameter(s.MAX_VERTEX_ATTRIBS),i.extensions=(s.getSupportedExtensions()||[]).length,i}catch(t){return{available:!1,error:!0}}}collectAudioFingerprint(){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return{available:!1};const e=new t,s={available:!0,sampleRate:e.sampleRate,state:e.state,maxChannels:e.destination.maxChannelCount};return e.close(),s}catch(t){return{available:!1}}}}class g{constructor(t){s(this,"originalFetch"),s(this,"endpoint"),s(this,"callbackManager",null),s(this,"challengeInProgress",null),this.endpoint=t,this.originalFetch=window.fetch.bind(window)}setCallbackManager(t){this.callbackManager=t}start(){window.fetch=async(t,e)=>{var s;const i=await this.originalFetch(t,e);if(403===i.status){const a=i.clone();try{const n=await a.json();if("challenge"===n.action&&"captcha"===(null==(s=n.metadata)?void 0:s.type)){const s={action:"challenge",score:n.score,metadata:n.metadata};if(this.callbackManager){if(await this.callbackManager.emitChallenge(s))return this.originalFetch(t,e)}this.challengeInProgress||(this.challengeInProgress=this.showCaptchaModal().finally(()=>{this.challengeInProgress=null}));return await this.challengeInProgress?this.originalFetch(t,e):i}"block"===n.action&&this.callbackManager&&this.callbackManager.emit("block",{action:"block",score:n.score,metadata:n.metadata})}catch(n){}}return i}}async showCaptchaModal(){return new Promise(t=>{const e=document.createElement("div");e.id="sec-sdk-challenge-host",e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100vw",e.style.height="100vh",e.style.zIndex="999999",e.style.backgroundColor="rgba(0,0,0,0.5)",e.style.display="flex",e.style.justifyContent="center",e.style.alignItems="center";const s=e.attachShadow({mode:"open"}),i=document.createElement("div");i.style.background="white",i.style.padding="20px",i.style.borderRadius="8px",i.style.boxShadow="0 4px 12px rgba(0,0,0,0.2)",i.style.textAlign="center",i.style.fontFamily="system-ui, sans-serif";const n=document.createElement("h3");n.textContent="Security Check",n.style.margin="0 0 16px 0";const a=document.createElement("p");a.textContent="Unusual activity detected. Please verify you are human.",a.style.marginBottom="16px",a.style.fontSize="14px",a.style.color="#666";const r=document.createElement("div");r.innerHTML="Loading...",r.style.marginBottom="16px";const o=document.createElement("input");o.type="text",o.placeholder="Enter details",o.style.padding="8px",o.style.marginRight="8px",o.style.border="1px solid #ddd",o.style.borderRadius="4px";const c=document.createElement("button");c.textContent="Verify",c.style.padding="8px 16px",c.style.background="#007bff",c.style.color="white",c.style.border="none",c.style.borderRadius="4px",c.style.cursor="pointer";const l=document.createElement("p");l.style.color="red",l.style.fontSize="12px",l.style.display="none",i.appendChild(n),i.appendChild(a),i.appendChild(r),i.appendChild(o),i.appendChild(c),i.appendChild(l),s.appendChild(i),document.body.appendChild(e);let h="";const d=async()=>{try{const t=await this.originalFetch(`${this.endpoint}/challenge`),e=await t.json();h=e.id,r.innerHTML=e.svg}catch(t){r.textContent="Error loading CAPTCHA"}},u=async()=>{l.style.display="none",c.textContent="Verifying...";try{const s=o.value,i=await this.originalFetch(`${this.endpoint}/challenge/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:h,answer:s})});(await i.json()).success?(document.body.removeChild(e),t(!0)):(l.textContent="Incorrect, try again.",l.style.display="block",c.textContent="Verify",o.value="",d())}catch(s){l.textContent="System error.",l.style.display="block",c.textContent="Verify"}};c.onclick=u,o.onkeydown=t=>{"Enter"===t.key&&u()},d()})}}class f{constructor(t){s(this,"transmitter"),s(this,"eventsToWatch",["click","mousedown","keydown","touchstart","focus"]),s(this,"handleEvent",t=>{const e=t.target;if(!(e&&e instanceof HTMLElement))return;if(e===document.body||e===document.documentElement)return;const s=this.checkVisibility(e,t);if(s){const i=e.getBoundingClientRect();this.transmitter.send("invisible_interaction",{type:t.type,target:e.tagName,id:e.id,reason:s,timestamp:Date.now(),isTrusted:t.isTrusted,coordinates:{x:t instanceof MouseEvent?t.clientX:0,y:t instanceof MouseEvent?t.clientY:0},viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{x:window.scrollX,y:window.scrollY},docDim:{width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight},elementRect:{top:i.top,left:i.left,width:i.width,height:i.height}})}}),this.transmitter=t}start(){this.eventsToWatch.forEach(t=>{document.addEventListener(t,this.handleEvent,{capture:!0,passive:!0})})}stop(){this.eventsToWatch.forEach(t=>{document.removeEventListener(t,this.handleEvent,{capture:!0})})}checkVisibility(t,e){var s,i;const n=window.getComputedStyle(t);if("none"===n.display)return"display:none";if("hidden"===n.visibility)return"visibility:hidden";if("0"===n.opacity)return"opacity:0";const a=t.getBoundingClientRect();if(a.width<=0||a.height<=0)return"zero_size";const r=a.right<0||a.left>window.innerWidth,o=a.bottom<0||a.top>window.innerHeight;if(r||o)return"off_screen";if(e instanceof MouseEvent||e instanceof TouchEvent){let n,a;if(e instanceof MouseEvent?(n=e.clientX,a=e.clientY):(n=(null==(s=e.touches[0])?void 0:s.clientX)||0,a=(null==(i=e.touches[0])?void 0:i.clientY)||0),n>=0&&n<=window.innerWidth&&a>=0&&a<=window.innerHeight){const s=document.elementFromPoint(n,a);if(s&&s!==t&&!t.contains(s)&&!s.contains(t)&&0===n&&0===a&&e.isTrusted)return null}}return null}}class y{constructor(t){s(this,"transmitter"),s(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(setTimeout(()=>this.detect(),1500),this.hasRun=!0)}detect(){var t,e;const s={};let i=0;!0===navigator.webdriver&&(s.webdriver=!0,i+=40);try{this.detectCDP()&&(s.cdp=!0,i+=50)}catch(c){}const n=this.detectAutomationGlobals();n.length>0&&(s.automationGlobals=n,i+=30);const a=this.checkWebGL();a.suspicious&&(s.webgl=a,i+=25);const r=this.checkInconsistencies();r.length>0&&(s.inconsistencies=r,i+=15);const o=this.checkHeadless();o.score>0&&(s.headless=o.flags,i+=o.score),i>0&&this.transmitter.send("automation_detected",{signals:s,score:i,timestamp:Date.now()}),this.transmitter.send("init_signals",{webdriver:!!navigator.webdriver,plugins:(null==(t=navigator.plugins)?void 0:t.length)??0,languages:(null==(e=navigator.languages)?void 0:e.length)??0,platform:navigator.platform,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory,maxTouchPoints:navigator.maxTouchPoints,webglRenderer:a.renderer,webglVendor:a.vendor,timestamp:Date.now()})}detectCDP(){let t=!1;const e=console.debug;return console.debug=e,t}detectAutomationGlobals(){const t=[],e=[["selenium",()=>!!window._selenium],["selenium_unwrapped",()=>!!document.__selenium_unwrapped],["driver_evaluate",()=>!!document.__driver_evaluate],["webdriver_evaluate",()=>!!document.__webdriver_evaluate],["driver_unwrapped",()=>!!document.__driver_unwrapped],["fxdriver",()=>!!document.__fxdriver_evaluate],["playwright",()=>!!window.__playwright],["playwright_binding",()=>!!window.__playwright__binding__],["pwInitScripts",()=>!!window.__pwInitScripts],["puppeteer",()=>!!window.__puppeteer_evaluation_script__],["phantom",()=>!!window.callPhantom||!!window._phantom],["nightmare",()=>!!window.__nightmare],["cdc",()=>Object.keys(document).some(t=>t.startsWith("cdc_")||t.startsWith("$cdc_"))]];for(const[i,n]of e)try{n()&&t.push(i)}catch(s){}return t}checkWebGL(){try{const t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return{suspicious:!1,renderer:"unavailable",vendor:"unavailable"};const s=e.getExtension("WEBGL_debug_renderer_info");if(!s)return{suspicious:!1,renderer:"no_debug_info",vendor:"no_debug_info"};const i=e.getParameter(s.UNMASKED_RENDERER_WEBGL)||"",n=e.getParameter(s.UNMASKED_VENDOR_WEBGL)||"";return{suspicious:/SwiftShader/i.test(i)||/Mesa OffScreen/i.test(i)||/llvmpipe/i.test(i),renderer:i,vendor:n}}catch(t){return{suspicious:!1,renderer:"error",vendor:"error"}}}checkInconsistencies(){const t=[];try{const e=navigator.userAgent,s=navigator.platform;/Windows/.test(e)&&/Mac/.test(s)&&t.push("ua_platform_mismatch_win_mac"),/Macintosh/.test(e)&&/Win/.test(s)&&t.push("ua_platform_mismatch_mac_win"),/Mobile|Android|iPhone/.test(e)&&0===navigator.maxTouchPoints&&t.push("mobile_ua_no_touch"),/Chrome/.test(e)&&navigator.plugins&&0===navigator.plugins.length&&t.push("chrome_no_plugins"),navigator.languages&&0!==navigator.languages.length||t.push("no_languages")}catch(e){}return t}checkHeadless(){const t=[];let e=0;try{if(/HeadlessChrome/.test(navigator.userAgent)&&(t.push("headless_ua"),e+=40),/Chrome/.test(navigator.userAgent)&&!window.chrome&&(t.push("chrome_ua_no_chrome_obj"),e+=15),window.screen&&800===window.screen.width&&600===window.screen.height&&(t.push("default_screen_size"),e+=10),"Notification"in window){"denied"===window.Notification.permission&&navigator.userAgent.includes("Chrome")&&(t.push("notification_denied_default"),e+=5)}const s=navigator.connection;s&&0===s.rtt&&(t.push("zero_rtt"),e+=10)}catch(s){}return{score:e,flags:t}}}class w{constructor(t){s(this,"transmitter"),s(this,"sessionStart",0),s(this,"pageTransitions",[]),s(this,"interactionTimestamps",[]),s(this,"lastPageUrl",""),s(this,"formStartTimes",new Map),s(this,"reportInterval",null),this.transmitter=t}start(){if("undefined"==typeof window)return;this.sessionStart=Date.now(),this.lastPageUrl=window.location.href;["mousedown","keydown","touchstart","scroll"].forEach(t=>{document.addEventListener(t,()=>{this.interactionTimestamps.push(Date.now()),this.interactionTimestamps.length>500&&this.interactionTimestamps.shift()},{passive:!0,capture:!0})}),this.observeNavigation(),this.observeForms(),this.reportInterval=setInterval(()=>this.report(),15e3)}observeNavigation(){const t=history.pushState,e=history.replaceState,s=this;history.pushState=function(e,i,n){t.call(this,e,i,n),s.onPageTransition()},history.replaceState=function(t,i,n){e.call(this,t,i,n),s.onPageTransition()},window.addEventListener("popstate",()=>this.onPageTransition())}onPageTransition(){const t=Date.now(),e=window.location.href;e!==this.lastPageUrl&&(this.pageTransitions.push(t),this.lastPageUrl=e)}observeForms(){document.addEventListener("focus",t=>{const e=t.target;if("INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName){const t=e.closest("form"),s=(null==t?void 0:t.id)||(null==t?void 0:t.action)||"anonymous_form";this.formStartTimes.has(s)||this.formStartTimes.set(s,Date.now())}},{capture:!0}),document.addEventListener("submit",t=>{const e=t.target,s=e.id||e.action||"anonymous_form",i=this.formStartTimes.get(s);if(i){const t=Date.now()-i;this.transmitter.send("session_metrics",{type:"form_completion",formId:s,duration:t,timestamp:Date.now()}),this.formStartTimes.delete(s)}},{capture:!0})}report(){const t=Date.now(),e=t-this.sessionStart;if(this.interactionTimestamps.length<10)return;const s=this.calculateIntervals(this.interactionTimestamps),i=this.analyzeTimingDistribution(s),n=this.analyzePageTransitions();this.transmitter.send("session_metrics",{type:"session_analysis",sessionDuration:e,totalInteractions:this.interactionTimestamps.length,pageTransitions:this.pageTransitions.length,timing:i,pages:n,timestamp:t})}calculateIntervals(t){const e=[];for(let s=1;s<t.length;s++)e.push(t[s]-t[s-1]);return e}analyzeTimingDistribution(t){if(t.length<5)return{samples:t.length};const e=t.reduce((t,e)=>t+e,0)/t.length,s=t.reduce((t,s)=>t+Math.pow(s-e,2),0)/t.length,i=Math.sqrt(s),n=e>0?i/e:0,a=this.shannonEntropy(t,50),r=this.autocorrelation(t);return{mean:Math.round(e),stdDev:Math.round(i),cv:parseFloat(n.toFixed(4)),entropy:parseFloat(a.toFixed(4)),autocorrelation:parseFloat(r.toFixed(4)),samples:t.length}}analyzePageTransitions(){if(this.pageTransitions.length<2)return{count:this.pageTransitions.length};const t=this.calculateIntervals(this.pageTransitions),e=t.reduce((t,e)=>t+e,0)/t.length,s=t.reduce((t,s)=>t+Math.pow(s-e,2),0)/t.length,i=e>0?Math.sqrt(s)/e:0;return{count:this.pageTransitions.length,avgInterval:Math.round(e),cv:parseFloat(i.toFixed(4))}}shannonEntropy(t,e){const s=new Map;for(const a of t){const t=Math.floor(a/e);s.set(t,(s.get(t)||0)+1)}const i=t.length;let n=0;for(const a of s.values()){const t=a/i;t>0&&(n-=t*Math.log2(t))}return n}autocorrelation(t){if(t.length<3)return 0;const e=t.reduce((t,e)=>t+e,0)/t.length;let s=0,i=0;for(let n=0;n<t.length-1;n++)s+=(t[n]-e)*(t[n+1]-e);for(let n=0;n<t.length;n++)i+=Math.pow(t[n]-e,2);return 0===i?0:s/i}}class v{constructor(t){s(this,"transmitter"),s(this,"tabTimestamps",[]),s(this,"shiftTabCount",0),s(this,"tabCount",0),s(this,"isShiftDown",!1),s(this,"BURST_THRESHOLD_MS",80),s(this,"reportInterval",null),s(this,"REPORT_INTERVAL_MS",1e4),s(this,"MIN_TABS_TO_REPORT",5),s(this,"TAB_TRIGGER_COUNT",20),s(this,"onKeyDown",t=>{if("Shift"!==t.key){if("Tab"===t.key){const t=Date.now();this.isShiftDown?this.shiftTabCount++:(this.tabCount++,this.tabTimestamps.push(t),this.tabTimestamps.length>100&&this.tabTimestamps.shift()),this.tabCount+this.shiftTabCount>=this.TAB_TRIGGER_COUNT&&this.report()}}else this.isShiftDown=!0}),s(this,"onKeyUp",t=>{"Shift"===t.key&&(this.isShiftDown=!1)}),this.transmitter=t}start(){"undefined"!=typeof document&&(document.addEventListener("keydown",this.onKeyDown,{passive:!0,capture:!0}),document.addEventListener("keyup",this.onKeyUp,{passive:!0,capture:!0}),this.reportInterval=setInterval(()=>this.report(),this.REPORT_INTERVAL_MS))}stop(){"undefined"!=typeof document&&(document.removeEventListener("keydown",this.onKeyDown,{capture:!0}),document.removeEventListener("keyup",this.onKeyUp,{capture:!0}),this.reportInterval&&(clearInterval(this.reportInterval),this.reportInterval=null),this.report())}report(){const t=this.tabCount+this.shiftTabCount;if(t<this.MIN_TABS_TO_REPORT)return;const e=this.calculateIntervals(this.tabTimestamps);if(e.length<3)return void this.resetBuffers();const s=this.analyzeIntervals(e),i=this.analyzeBursts(e),n=t>0?this.shiftTabCount/t:0;this.transmitter.send("tab_navigation_metrics",{tabCount:this.tabCount,shiftTabCount:this.shiftTabCount,shiftTabRatio:parseFloat(n.toFixed(4)),intervals:s,bursts:i,timestamp:Date.now()}),this.resetBuffers()}resetBuffers(){this.tabTimestamps=[],this.tabCount=0,this.shiftTabCount=0}calculateIntervals(t){const e=[];for(let s=1;s<t.length;s++){const i=t[s]-t[s-1];i<5e3&&e.push(i)}return e}analyzeIntervals(t){if(0===t.length)return{avg:0,variance:0,cv:0,min:0,samples:0};const e=t.reduce((t,e)=>t+e,0)/t.length,s=t.reduce((t,s)=>t+Math.pow(s-e,2),0)/t.length,i=Math.sqrt(s),n=e>0?i/e:0,a=Math.min(...t);return{avg:parseFloat(e.toFixed(2)),variance:parseFloat(s.toFixed(2)),cv:parseFloat(n.toFixed(4)),min:a,samples:t.length}}analyzeBursts(t){let e=0,s=0,i=0,n=0,a=0;for(const r of t)r<this.BURST_THRESHOLD_MS?(s++,n+=r,a++):(s>=3&&(e++,i+=s),s=0);return s>=3&&(e++,i+=s),{count:e,avgLength:e>0?parseFloat((i/e).toFixed(1)):0,avgInterval:a>0?parseFloat((n/a).toFixed(2)):0}}}class b{constructor(t){s(this,"transmitter"),s(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){try{const t=this.analyzeGPU(),e=this.analyzeHardware(),s=this.analyzeScreen(),i=await this.analyzeMedia(),n=this.benchmarkCanvas();let a=0;"virtual_gpu"!==t.category&&"software_render"!==t.category&&"cloud_gpu"!==t.category||(a+=2),e.cores<=2&&a++,null!==e.memory&&e.memory<=2&&a++,24===e.colorDepth&&a++,1===e.pixelRatio&&a++,s.noTaskbar&&a++,s.isVMResolution&&a++,0===i.cameras&&0===i.microphones&&a++,i.hasBluetooth||i.hasUSB||a++,n.canvasRenderTime>50&&a++;const{classification:r,confidence:o}=this.classify(t,e,a);this.transmitter.send("cloud_environment",{classification:r,confidence:o,signals:{gpu:{renderer:t.renderer,vendor:t.vendor,category:t.category},hardware:e,screen:s,media:i,performance:n},vmIndicatorCount:a,timestamp:Date.now()})}catch(t){}}analyzeGPU(){try{const t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return{renderer:"unavailable",vendor:"unavailable",category:"unknown"};const s=e.getExtension("WEBGL_debug_renderer_info");if(!s)return{renderer:"no_debug_info",vendor:"no_debug_info",category:"unknown"};const i=e.getParameter(s.UNMASKED_RENDERER_WEBGL)||"",n=e.getParameter(s.UNMASKED_VENDOR_WEBGL)||"";return{renderer:i,vendor:n,category:this.categorizeGPU(i,n)}}catch(t){return{renderer:"error",vendor:"error",category:"unknown"}}}categorizeGPU(t,e){const s=t.toLowerCase(),i=e.toLowerCase();return/swiftshader|llvmpipe|mesa offscreen|softpipe/.test(s)?"software_render":/svga3d|svga|vmware/.test(s)||/virtualbox/.test(s)||/parallels/.test(s)||/qxl|virtio|red hat|spice/.test(s)||/hyper-v|microsoft basic render/i.test(s)||/citrix/.test(s)?"virtual_gpu":/amazon|elastic|aws/.test(s)||/amazon|elastic|aws/.test(i)||/google cloud|gce/.test(s)||/google cloud|gce/.test(i)||/azure/.test(s)||/azure/.test(i)?"cloud_gpu":"physical"}analyzeHardware(){return{cores:navigator.hardwareConcurrency||0,memory:navigator.deviceMemory??null,colorDepth:screen.colorDepth,pixelRatio:window.devicePixelRatio||1}}analyzeScreen(){const t=screen.width,e=screen.height,s=screen.availHeight,i=e===s&&e===window.innerHeight,n=[[800,600],[1024,768],[1280,1024],[1280,800],[1920,1080]].some(([s,i])=>t===s&&e===i&&!(1920===s&&1080===i));return{width:t,height:e,availHeight:s,noTaskbar:i,isVMResolution:n}}async analyzeMedia(){let t=-1,e=-1;try{if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices){const s=await navigator.mediaDevices.enumerateDevices();t=s.filter(t=>"videoinput"===t.kind).length,e=s.filter(t=>"audioinput"===t.kind).length}}catch(a){}const s=!!navigator.bluetooth,i=!!navigator.usb;let n=null;try{if(navigator.getBattery){const t=await navigator.getBattery();n=!(t.charging&&1===t.level&&0===t.chargingTime)}}catch(a){}return{cameras:t,microphones:e,hasBluetooth:s,hasUSB:i,hasBattery:n}}benchmarkCanvas(){try{const t=document.createElement("canvas");t.width=200,t.height=200;const e=t.getContext("2d");if(!e)return{canvasRenderTime:-1};const s=performance.now();for(let n=0;n<500;n++)e.fillStyle=`rgb(${n%256},${3*n%256},${7*n%256})`,e.fillRect(13*n%200,7*n%200,10,10);e.getImageData(0,0,1,1);const i=performance.now()-s;return{canvasRenderTime:Math.round(100*i)/100}}catch(t){return{canvasRenderTime:-1}}}classify(t,e,s){return"virtual_gpu"===t.category?24===e.colorDepth?{classification:"rdp_likely",confidence:.85}:{classification:"vm_detected",confidence:.95}:"cloud_gpu"===t.category?{classification:"cloud_likely",confidence:.9}:"software_render"===t.category?{classification:"vm_detected",confidence:.9}:s>=5?{classification:"vm_likely",confidence:.8}:s>=3?{classification:"vm_likely",confidence:.6}:{classification:"physical",confidence:1-.1*s}}}class _{constructor(t){s(this,"transmitter"),s(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2500))}async detect(){var t,e;const s={};let i=0;const n={webdriver:!!navigator.webdriver,languages:(null==(t=navigator.languages)?void 0:t.join(","))||"",platform:navigator.platform||"",hardwareConcurrency:navigator.hardwareConcurrency||0,userAgent:navigator.userAgent||"",pluginsLength:(null==(e=navigator.plugins)?void 0:e.length)??0},a=this.checkIframe(n);a.score>0&&(s.iframe=a.mismatches,i+=a.score);try{const t=await this.checkWorker(n);t.score>0&&(s.worker=t.mismatches,i+=t.score)}catch(r){}i>0&&this.transmitter.send("cross_context_mismatch",{signals:s,score:i,timestamp:Date.now()})}checkIframe(t){var e,s;const i=[];let n=0;try{const a=document.createElement("iframe");a.style.display="none",a.sandbox="allow-same-origin",document.body.appendChild(a);const r=a.contentWindow;if(!r)return document.body.removeChild(a),{score:0,mismatches:[]};const o=r.navigator;o.webdriver!==navigator.webdriver&&(i.push("webdriver_mismatch"),n+=40),navigator.webdriver||!0!==o.webdriver||(i.push("webdriver_spoofed_in_main"),n+=30);((null==(e=o.languages)?void 0:e.join(","))||"")!==t.languages&&(i.push("languages_mismatch"),n+=15),o.platform!==t.platform&&(i.push("platform_mismatch"),n+=15);((null==(s=o.plugins)?void 0:s.length)??0)!==t.pluginsLength&&(i.push("plugins_mismatch"),n+=10),document.body.removeChild(a)}catch(a){}return{score:n,mismatches:i}}checkWorker(t){return new Promise(e=>{try{const s=new Blob(["\n self.onmessage = function() {\n var nav = self.navigator;\n self.postMessage({\n webdriver: !!nav.webdriver,\n languages: (nav.languages || []).join(','),\n platform: nav.platform || '',\n hardwareConcurrency: nav.hardwareConcurrency || 0,\n userAgent: nav.userAgent || ''\n });\n };\n "],{type:"application/javascript"}),i=URL.createObjectURL(s),n=new Worker(i),a=setTimeout(()=>{n.terminate(),URL.revokeObjectURL(i),e({score:0,mismatches:[]})},3e3);n.onmessage=s=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(i);const r=s.data,o=[];let c=0;r.webdriver!==t.webdriver&&(o.push("worker_webdriver_mismatch"),c+=35),r.languages!==t.languages&&(o.push("worker_languages_mismatch"),c+=15),r.platform!==t.platform&&(o.push("worker_platform_mismatch"),c+=15),r.hardwareConcurrency!==t.hardwareConcurrency&&(o.push("worker_concurrency_mismatch"),c+=10),r.userAgent!==t.userAgent&&(o.push("worker_ua_mismatch"),c+=20),e({score:c,mismatches:o})},n.onerror=()=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(i),e({score:0,mismatches:[]})},n.postMessage("check")}catch(s){e({score:0,mismatches:[]})}})}}class T{constructor(t){s(this,"transmitter"),s(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){const t={};let e=0;const s=await this.checkBrokenImage();s.suspicious&&(t.brokenImage=s,e+=25);const i=await this.checkClientHints();i.suspicious&&(t.clientHints=i,e+=20);const n=this.checkCDPMouseSignature();n.suspicious&&(t.cdpMouse=n,e+=30);const a=this.checkHairlineSupport();a.suspicious&&(t.hairline=a,e+=10);const r=this.checkExtraFrameworks();r.length>0&&(t.extraFrameworks=r,e+=20);(await this.checkWorkerCDP()).suspicious&&(t.workerCDP=!0,e+=35),e>0&&this.transmitter.send("headless_probe",{signals:t,score:e,timestamp:Date.now()})}checkBrokenImage(){return new Promise(t=>{try{const e=document.createElement("img");e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==___invalid";const s=setTimeout(()=>{t({suspicious:!1,width:-1,height:-1})},2e3);e.onerror=()=>{clearTimeout(s);const i=e.width,n=e.height;t({suspicious:0===i&&0===n,width:i,height:n})},e.onload=()=>{clearTimeout(s),t({suspicious:!1,width:e.width,height:e.height})},e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e),setTimeout(()=>{try{document.body.removeChild(e)}catch(t){}},100)}catch(e){t({suspicious:!1,width:-1,height:-1})}})}async checkClientHints(){const t=[];try{const e=navigator.userAgentData;if(!e)return{suspicious:!1,mismatches:[]};const s=navigator.userAgent,i=(e.brands||[]).map(t=>t.brand);/Chrome\/\d/.test(s)&&!i.some(t=>/Chromium|Google Chrome|Chrome/.test(t))&&t.push("ua_chrome_no_brand"),e.platform&&(/Windows/.test(s)&&"Windows"!==e.platform&&t.push("ua_windows_brand_mismatch"),/Macintosh/.test(s)&&"macOS"!==e.platform&&t.push("ua_mac_brand_mismatch"),/Linux/.test(s)&&!/Linux|Android|ChromeOS/.test(e.platform)&&t.push("ua_linux_brand_mismatch")),/Mobile/.test(s)&&!1===e.mobile&&t.push("ua_mobile_brand_mismatch")}catch(e){}return{suspicious:t.length>0,mismatches:t}}checkCDPMouseSignature(){let t=0,e=0,s=!1;try{const i=[],n=s=>{i.push(s),e++,0===s.movementX&&0===s.movementY&&t++};document.addEventListener("mousemove",n,{passive:!0}),setTimeout(()=>{document.removeEventListener("mousemove",n)},5e3),e>10&&t/e>.9&&(s=!0)}catch(i){}return{suspicious:s,zeroMovementCount:t,totalEvents:e}}checkHairlineSupport(){try{const t=document.createElement("div");t.style.border=".5px solid transparent",t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);const e=t.offsetHeight;return document.body.removeChild(t),{suspicious:0===e,offsetHeight:e}}catch(t){return{suspicious:!1,offsetHeight:-1}}}checkExtraFrameworks(){const t=[];try{const s=window.external;if(s&&"function"==typeof s.toString)try{const e=s.toString();/Sequentum/i.test(e)&&t.push("sequentum")}catch(e){}const i=["__webdriver_script_fn","__webdriver_script_func","__webdriver_evaluate","__selenium_evaluate","__fxdriver_evaluate","__driver_evaluate","__webdriver_unwrapped","__selenium_unwrapped","__fxdriver_unwrapped","__driver_unwrapped","_Selenium_IDE_Recorder","_selenium","calledSelenium","_WEBDRIVER_ELEM_CACHE","ChromeDriverw","driver-hierarchical","__$webdriverAsyncExecutor","__lastWatirAlert","__lastWatirConfirm","__lastWatirPrompt","_WEBDRIVER_ELEM_CACHE","webdriver","_phantom","__nightmare","_selenium"];for(const e of i)(e in document||e in window)&&t.push(`global_${e}`);const n=Object.getOwnPropertyNames(navigator);for(const e of n)/webdriver|selenium|puppeteer|playwright|phantom/i.test(e)&&t.push(`nav_${e}`)}catch(e){}return t}checkWorkerCDP(){return new Promise(t=>{try{const e=new Blob(["\n self.onmessage = function() {\n var detected = false;\n try {\n var marker = {};\n Object.defineProperty(marker, 'stack', {\n get: function() { detected = true; return ''; }\n });\n console.debug(marker);\n } catch(e) {}\n self.postMessage({ cdp: detected });\n };\n "],{type:"application/javascript"}),s=URL.createObjectURL(e),i=new Worker(s),n=setTimeout(()=>{i.terminate(),URL.revokeObjectURL(s),t({suspicious:!1})},3e3);i.onmessage=e=>{clearTimeout(n),i.terminate(),URL.revokeObjectURL(s),t({suspicious:!0===e.data.cdp})},i.onerror=()=>{clearTimeout(n),i.terminate(),URL.revokeObjectURL(s),t({suspicious:!1})},i.postMessage("check")}catch(e){t({suspicious:!1})}})}}const k="__aie_token";class C{constructor(t){s(this,"config"),s(this,"renewTimer",null),s(this,"verified",!1),this.config=t}async start(){const t=this.getToken();if(t&&!this.isExpired(t))return this.verified=!0,this.scheduleRenewal(t),this.revealContent(),this.config.debug,!0;this.hideContent();const e=await this.solveChallenge();return e?(this.verified=!0,this.revealContent()):this.config.insertHoneypot&&this.insertHoneypotData(),e}isVerified(){return this.verified}stop(){this.renewTimer&&(clearTimeout(this.renewTimer),this.renewTimer=null)}async solveChallenge(){try{const t=await fetch(`${this.config.apiBase}/crawl-protect/challenge`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId}});if(!t.ok)return!1;const{id:e,challenges:s}=await t.json(),i=[];for(const c of s)if("math"===c.type){const t="add"===c.op?c.a+c.b:c.a*c.b;i.push(String(t))}else if("crypto"===c.type){const t=await this.sha256(c.nonce);i.push(t.slice(0,8))}const n=i.join(":"),a=await this.getFingerprint(),r=await fetch(`${this.config.apiBase}/crawl-protect/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId},body:JSON.stringify({id:e,solution:n,fingerprint:a}),credentials:"include"});if(!r.ok)return!1;const o=await r.json();return!(!o.success||!o.token)&&(this.setToken(o.token),this.scheduleRenewal(o.token),this.config.debug,!0)}catch(t){return this.config.debug,!1}}hideContent(){var t;if(null==(t=this.config.protectSelectors)?void 0:t.length)for(const e of this.config.protectSelectors){document.querySelectorAll(e).forEach(t=>{t.dataset.aieOrigDisplay=t.style.display,t.style.display="none"})}}revealContent(){var t;if(null==(t=this.config.protectSelectors)?void 0:t.length)for(const e of this.config.protectSelectors){document.querySelectorAll(e).forEach(t=>{t.style.display=t.dataset.aieOrigDisplay||"",delete t.dataset.aieOrigDisplay})}}insertHoneypotData(){const t=document.createElement("div");t.style.cssText="position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;",t.setAttribute("aria-hidden","true"),t.innerHTML='\n <span class="price" data-aie-honeypot="1">₩999,999,999</span>\n <span class="stock" data-aie-honeypot="1">재고: 0개</span>\n <a href="mailto:honeypot@aientrophy.com" data-aie-honeypot="1">contact</a>\n ',document.body.appendChild(t)}getToken(){const t=document.cookie.match(new RegExp(`(?:^|; )${k}=([^;]*)`));return t?decodeURIComponent(t[1]):null}setToken(t){const e=new Date(Date.now()+18e5).toUTCString();document.cookie=`${k}=${encodeURIComponent(t)};path=/;expires=${e};SameSite=None;Secure`}isExpired(t){try{const[e]=t.split("."),s=JSON.parse(atob(e.replace(/-/g,"+").replace(/_/g,"/")));return Date.now()>s.exp}catch{return!0}}scheduleRenewal(t){try{const[e]=t.split("."),s=JSON.parse(atob(e.replace(/-/g,"+").replace(/_/g,"/"))),i=s.exp-3e5-Date.now();i>0&&(this.renewTimer=setTimeout(()=>this.solveChallenge(),i))}catch{}}async sha256(t){const e=new TextEncoder,s=await crypto.subtle.digest("SHA-256",e.encode(t));return Array.from(new Uint8Array(s)).map(t=>t.toString(16).padStart(2,"0")).join("")}async getFingerprint(){const t=[navigator.userAgent,navigator.language,screen.width+"x"+screen.height,Intl.DateTimeFormat().resolvedOptions().timeZone];return this.sha256(t.join("|"))}}const E=new class{constructor(){s(this,"transmitter"),s(this,"behaviorCollector"),s(this,"rapidClickDetector"),s(this,"honeypot"),s(this,"mouseTracker"),s(this,"canvasFingerprinter"),s(this,"inputTracker"),s(this,"challengeHandler"),s(this,"invisibleInteraction"),s(this,"automationDetector"),s(this,"sessionAnalyzer"),s(this,"tabNavigationAnalyzer"),s(this,"cloudEnvironmentDetector"),s(this,"crossContextDetector"),s(this,"headlessProbeDetector"),s(this,"crawlProtect",null),s(this,"initialized",!1),s(this,"wasmService"),s(this,"callbackManager"),this.transmitter=new o,this.wasmService=new m,this.callbackManager=new r,this.transmitter.setCallbackManager(this.callbackManager),this.behaviorCollector=new c(this.transmitter),this.rapidClickDetector=new l(this.transmitter),this.honeypot=new h(this.transmitter),this.mouseTracker=new d(this.transmitter,this.wasmService),this.canvasFingerprinter=new p(this.transmitter,this.wasmService),this.inputTracker=new u(this.transmitter),this.invisibleInteraction=new f(this.transmitter),this.automationDetector=new y(this.transmitter),this.sessionAnalyzer=new w(this.transmitter),this.tabNavigationAnalyzer=new v(this.transmitter),this.cloudEnvironmentDetector=new b(this.transmitter),this.crossContextDetector=new _(this.transmitter),this.headlessProbeDetector=new T(this.transmitter)}async init(t){var e,s;if(this.initialized)return;t.callbacks&&this.callbackManager.setConfigCallbacks(t.callbacks);const i=t.endpoint.replace(/\/events$/,"");try{await this.wasmService.load(i),this.startDetectors(),this.transmitter.setConfig(t),this.challengeHandler=new g(i),this.challengeHandler.setCallbackManager(this.callbackManager),!1!==(null==(e=t.serverConfig)?void 0:e.captchaEnabled)&&this.challengeHandler.start();((null==(s=t.serverConfig)?void 0:s.devtoolsDetection)??!t.debug)&&Promise.resolve().then(()=>M).then(({AntiDebug:t})=>{t.start(),Promise.resolve().then(()=>x).then(({ConsoleDetector:t})=>{new t(()=>{this.transmitter.send("devtools_open",{detected:!0})}).start()})}),t.crawlProtect&&(this.crawlProtect=new C({apiBase:i,clientId:t.clientKey,protectSelectors:t.crawlProtect.protectSelectors,insertHoneypot:t.crawlProtect.insertHoneypot,debug:t.debug}),this.crawlProtect.start().catch(e=>{t.debug})),this.initialized=!0,t.debug,this.callbackManager.emit("ready")}catch(n){this.callbackManager.emit("error",{code:"INIT_ERROR",message:"SecuritySDK initialization failed",details:null==n?void 0:n.message})}}on(t,e){this.callbackManager.on(t,e)}off(t,e){this.callbackManager.off(t,e)}once(t,e){this.callbackManager.once(t,e)}startDetectors(){this.behaviorCollector.start(),this.honeypot.start(),this.mouseTracker.start(),this.canvasFingerprinter.start(),this.inputTracker.start(),this.invisibleInteraction.start(),this.automationDetector.start(),this.sessionAnalyzer.start(),this.tabNavigationAnalyzer.start(),this.cloudEnvironmentDetector.start(),this.crossContextDetector.start(),this.headlessProbeDetector.start()}};"undefined"!=typeof window&&(window.SecuritySDK=E);const S={};class A{static start(){this.saveConsole(),this.disableConsole(),this.preventDevTools()}static stop(){this.intervalId&&clearInterval(this.intervalId)}static getOriginalConsole(){return S}static saveConsole(){const t=["log","debug","info","warn","error","table","trace","dir","clear"];try{const e=window.console;if(!e)return;for(const s of t)"function"==typeof e[s]&&(S[s]=e[s].bind(e))}catch(e){}}static preventDevTools(){this.intervalId=setInterval(()=>{this.debuggerCheck()},this.checkInterval)}static debuggerCheck(){!function(){try{(function(){}).constructor("debugger")()}catch(t){}}()}static disableConsole(){const t=()=>{},e=["log","debug","info","warn","error","table","trace","dir"];try{const s=window.console;if(!s)return;for(const i of e)s[i]&&(s[i]=t)}catch(s){}}}s(A,"checkInterval",1e3),s(A,"intervalId");const M=Object.freeze(Object.defineProperty({__proto__:null,AntiDebug:A},Symbol.toStringTag,{value:"Module"}));const x=Object.freeze(Object.defineProperty({__proto__:null,ConsoleDetector:class{constructor(t){s(this,"onDetect"),s(this,"intervals",[]),s(this,"detected",!1),this.onDetect=t}start(){this.startGetterTrap(),this.startSizeDetection()}stop(){for(const t of this.intervals)clearInterval(t);this.intervals=[]}triggerDetect(){this.detected||(this.detected=!0,this.onDetect(),setTimeout(()=>{this.detected=!1},5e3))}startGetterTrap(){const t=A.getOriginalConsole(),e=t.log,s=t.clear;if(!e)return;const i=document.createElement("div");Object.defineProperty(i,"id",{get:()=>(this.triggerDetect(),"")});const n=/./;n.toString=()=>(this.triggerDetect(),"");const a=setInterval(()=>{try{e(i),e(n),s&&s()}catch(t){}},1500);this.intervals.push(a)}startSizeDetection(){if(navigator.maxTouchPoints>0||/Mobile|Android|iPhone|iPad/i.test(navigator.userAgent))return;const t=setInterval(()=>{const t=window.outerWidth-window.innerWidth>160,e=window.outerHeight-window.innerHeight>160;(t||e)&&this.triggerDetect()},2e3);this.intervals.push(t)}}},Symbol.toStringTag,{value:"Module"}));t.securitySDK=E,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SecuritySDKCore={})}(this,function(t){"use strict";var e=Object.defineProperty,i=(t,i,s)=>((t,i,s)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s)(t,"symbol"!=typeof i?i+"":i,s);const s="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqbBCvDqyUtfhgI/Lo5pDtn1phwA6qczAyp8N1ZgQ68OTxgbJUGiXV6N67p15bBdME1R4va51P2Czq2IbRby/N+GHTciTaXvmusV8IjnIOGtKlGxWCuKIPrCS+rGjGA2j1irxBbNpqItltFxjhxBGOzsyQAF6LNIz5IKA7sC6cSH8zUyLuFrV96udc801Zc4nCJG64ZljNbDvlVbJJZ6ex5OLLS6AnrVAXpjEDR/MI/I8JvAPe/psHj6EpXgvKrBYMBOH3jzQRzMFoR79jXyGNgPjdy0A+f6RVuEG8H5sUXKeyy+cFvaT+pm6h+t6RPED11tCOwQxYZ2pExhhPxDGeQIDAQAB";class n{static async init(){if(!this.sessionKey)try{await this.initECDH()}catch(t){await this.initRSA()}}static async initECDH(){const t=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"]),e=await window.crypto.subtle.exportKey("raw",t.publicKey);this.ecdhPublicKeyBase64=this.arrayBufferToBase64(e);const i=(window.__securitySDKEndpoint||"").replace(/\/events$/,""),s=await fetch(`${i}/key-exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientPublicKey:this.ecdhPublicKeyBase64})});if(!s.ok)throw new Error("Key exchange failed");const{serverPublicKey:n,salt:a}=await s.json(),r=this.base64ToArrayBuffer(n),o=await window.crypto.subtle.importKey("raw",r,{name:"ECDH",namedCurve:"P-256"},!1,[]),c=await window.crypto.subtle.deriveBits({name:"ECDH",public:o},t.privateKey,256),l=await window.crypto.subtle.importKey("raw",c,"HKDF",!1,["deriveKey"]),h=this.base64ToArrayBuffer(a);this.sessionKey=await window.crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:h,info:(new TextEncoder).encode("aientrophy-session-enc")},l,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),this.protocolVersion=2}static async initRSA(){this.sessionKey=await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);const t=await this.importRSAPublicKey(s),e=await window.crypto.subtle.exportKey("raw",this.sessionKey),i=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},t,e);this.encryptedSessionKey=this.arrayBufferToBase64(i),this.protocolVersion=1}static async encrypt(t){this.sessionKey||await this.init();const e=JSON.stringify(t),i=(new TextEncoder).encode(e),s=window.crypto.getRandomValues(new Uint8Array(12)),n=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},this.sessionKey,i),a=new Uint8Array(n),r=a.slice(0,a.length-16),o=a.slice(a.length-16),c={ek:2===this.protocolVersion?this.ecdhPublicKeyBase64:this.encryptedSessionKey,d:this.arrayBufferToBase64(r.buffer),iv:this.arrayBufferToBase64(s.buffer),tag:this.arrayBufferToBase64(o.buffer)};return 2===this.protocolVersion&&(c.v=2),c}static async decrypt(t){if(!this.sessionKey)throw new Error("Session key not initialized");const e=this.base64ToArrayBuffer(t.d),i=this.base64ToArrayBuffer(t.iv),s=this.base64ToArrayBuffer(t.tag),n=new Uint8Array(e.byteLength+s.byteLength);n.set(new Uint8Array(e),0),n.set(new Uint8Array(s),e.byteLength);const a=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:i},this.sessionKey,n),r=(new TextDecoder).decode(a);return JSON.parse(r)}static setEndpoint(t){window.__securitySDKEndpoint=t}static async importRSAPublicKey(t){const e=window.atob(t),i=this.str2ab(e);return await window.crypto.subtle.importKey("spki",i,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"])}static str2ab(t){const e=new ArrayBuffer(t.length),i=new Uint8Array(e);for(let s=0,n=t.length;s<n;s++)i[s]=t.charCodeAt(s);return e}static arrayBufferToBase64(t){let e="";const i=new Uint8Array(t),s=i.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(i[n]);return window.btoa(e)}static base64ToArrayBuffer(t){const e=window.atob(t),i=e.length,s=new Uint8Array(i);for(let n=0;n<i;n++)s[n]=e.charCodeAt(n);return s.buffer}}i(n,"sessionKey",null),i(n,"ecdhPublicKeyBase64",null),i(n,"encryptedSessionKey",null),i(n,"protocolVersion",2);const a=new Set(["rapid_click","honeypot_triggered","devtools_open","invisible_interaction","integrity_violation","dom_mutation","behavior_metrics","behavior_analysis","input_metrics","keystroke_dynamics","environmental_integrity","init_signals","automation_detected","cross_context_mismatch","headless_probe"]);class r{constructor(){i(this,"handlers",new Map),i(this,"configCallbacks",{})}setConfigCallbacks(t){this.configCallbacks=t}on(t,e){this.addHandler(t,e,!1)}once(t,e){this.addHandler(t,e,!0)}off(t,e){const i=this.handlers.get(t);if(!i)return;const s=i.filter(t=>t.handler!==e);0===s.length?this.handlers.delete(t):this.handlers.set(t,s)}emit(t,...e){this.callHandlers(t,e);const i=t.indexOf(":");if(-1!==i){const s=t.substring(0,i);this.callHandlers(s,e)}this.callConfigCallback(t,e)}emitChallenge(t){return new Promise(e=>{let i=!1;const s=t=>{i||(i=!0,e(t))},n=this.handlers.has("challenge")&&this.handlers.get("challenge").length>0,a=!!this.configCallbacks.onChallenge;n||a?(this.callHandlers("challenge",[t,s]),this.configCallbacks.onChallenge&&this.safeCall(this.configCallbacks.onChallenge,[t,s]),setTimeout(()=>{i||(i=!0,e(!1))},5e3)):e(!1)})}addHandler(t,e,i){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push({handler:e,once:i})}callHandlers(t,e){const i=this.handlers.get(t);if(!i||0===i.length)return;const s=[];for(let n=0;n<i.length;n++)this.safeCall(i[n].handler,e),i[n].once&&s.push(n);for(let n=s.length-1;n>=0;n--)i.splice(s[n],1);0===i.length&&this.handlers.delete(t)}callConfigCallback(t,e){if(t.startsWith("threat:")||"threat"===t)return void(t.startsWith("threat:")&&this.configCallbacks.onThreatDetected&&this.safeCall(this.configCallbacks.onThreatDetected,e));const i={ready:"onReady",error:"onError",block:"onBlock",allow:"onAllow"}[t];i&&this.configCallbacks[i]&&this.safeCall(this.configCallbacks[i],e)}safeCall(t,e){try{t(...e)}catch(i){}}}class o{constructor(){i(this,"endpoint",""),i(this,"clientKey",""),i(this,"encryptionRequired",!1),i(this,"currentNonce",""),i(this,"buffer",[]),i(this,"batchSize",20),i(this,"flushInterval",5e3),i(this,"intervalId"),i(this,"responseHandler",null),i(this,"callbackManager",null),i(this,"flushing",!1),i(this,"pendingFlush",!1),i(this,"backoffMs",0),i(this,"maxBackoffMs",6e4),i(this,"_lastBackoffStart",0),this.startFlushInterval()}setConfig(t){var e,i;this.endpoint=t.endpoint,this.clientKey=t.clientKey,this.encryptionRequired=(null==(e=t.serverConfig)?void 0:e.encryptionRequired)??!1,this.currentNonce=(null==(i=t.serverConfig)?void 0:i.initialNonce)??"",n.setEndpoint(t.endpoint)}setResponseHandler(t){this.responseHandler=t}setCallbackManager(t){this.callbackManager=t}send(t,e={}){const i=Date.now();if(this.buffer.push({type:t,data:e,timestamp:i}),this.callbackManager)if(a.has(t)){const s={type:t,data:e,timestamp:i};this.callbackManager.emit(`threat:${t}`,s)}else this.callbackManager.emit(`data:${t}`,{type:t,data:e,timestamp:i});this.buffer.length>=this.batchSize&&this.flush()}async flush(){if(0===this.buffer.length||!this.endpoint)return;if(this.backoffMs>0){const t=Date.now();if(this._lastBackoffStart||(this._lastBackoffStart=t),t-this._lastBackoffStart<this.backoffMs)return;this._lastBackoffStart=0}if(this.flushing)return void(this.pendingFlush=!0);this.flushing=!0;const t=this.buffer;this.buffer=[];try{let s;if(this.encryptionRequired){const e=await n.encrypt(t);s=JSON.stringify(e)}else s=JSON.stringify(t);const a={"Content-Type":"application/json","x-client-key":this.clientKey};this.currentNonce&&(a["x-request-nonce"]=this.currentNonce,this.currentNonce="");try{const i=await fetch(this.endpoint,{method:"POST",body:s,headers:a,keepalive:!0});if(429===i.status)return this.buffer=t.concat(this.buffer).slice(0,500),this.backoffMs=0===this.backoffMs?5e3:Math.min(2*this.backoffMs,this.maxBackoffMs),void(this._lastBackoffStart=Date.now());if(this.backoffMs=0,i.ok&&this.callbackManager&&this.callbackManager.emit("allow",{action:"allow"}),i.ok)try{const t=await i.json();let e=t;this.encryptionRequired&&(e=await n.decrypt(t)),(null==e?void 0:e.nonce)&&(this.currentNonce=e.nonce),this.responseHandler&&this.responseHandler(e)}catch(e){}}catch(i){this.callbackManager&&this.callbackManager.emit("error",{code:"NETWORK_ERROR",message:"Failed to send security events"})}}catch(e){this.callbackManager&&this.callbackManager.emit("error",{code:"PAYLOAD_ERROR",message:"Failed to prepare security payload"})}finally{this.flushing=!1,this.pendingFlush&&(this.pendingFlush=!1,this.flush())}}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.flush()}startFlushInterval(){this.intervalId=setInterval(()=>{this.flush()},this.flushInterval)}}class c{constructor(t){i(this,"transmitter"),i(this,"isCollecting",!1),this.transmitter=t}start(){this.isCollecting||(this.isCollecting=!0)}stop(){this.isCollecting=!1}}class l{constructor(t){i(this,"transmitter"),i(this,"clickHistory",[]),i(this,"THRESHOLD_COUNT",3),i(this,"THRESHOLD_TIME",500),this.transmitter=t,this.init()}init(){document.addEventListener("click",t=>this.handleClick(t),!0)}handleClick(t){const e=Date.now();if(this.clickHistory.push(e),this.clickHistory=this.clickHistory.filter(t=>e-t<=this.THRESHOLD_TIME),this.clickHistory.length>=this.THRESHOLD_COUNT){const i=t.target,s={tagName:i.tagName,id:i.id,className:i.className,x:t.clientX,y:t.clientY};this.transmitter.send("rapid_click",{count:this.clickHistory.length,duration:this.THRESHOLD_TIME,target:s,timestamp:e}),this.clickHistory=[]}}}class h{constructor(t){i(this,"transmitter"),i(this,"element",null),this.transmitter=t}start(){this.element=document.createElement("input"),this.element.type="text";const t=["website","email_confirm","url","homepage","fax_number","address_line_2"],e=t[Math.floor(Math.random()*t.length)],i=Math.random().toString(36).substr(2,5);this.element.id="hp-"+Math.random().toString(36).substr(2,9),this.element.name=`${e}-${i}`,this.element.autocomplete="off",Object.assign(this.element.style,{position:"absolute",opacity:"0",top:"0",left:"-9999px",height:"1px",width:"1px",zIndex:"-1",border:"none"}),this.element.tabIndex=-1,this.element.setAttribute("aria-hidden","true"),this.element.setAttribute("role","presentation");const s=t=>{var e;this.transmitter.send("honeypot_triggered",{eventType:t.type,value:null==(e=this.element)?void 0:e.value,timestamp:Date.now()})};this.element.addEventListener("input",s),this.element.addEventListener("focus",s),this.element.addEventListener("click",s),document.body.appendChild(this.element)}stop(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class d{constructor(t,e){i(this,"transmitter"),i(this,"wasmService"),i(this,"buffer",[]),i(this,"BUFFER_SIZE",50),i(this,"SAMPLE_INTERVAL",100),i(this,"SEND_COOLDOWN",5e3),i(this,"lastSampleTime",0),i(this,"lastSendTime",0),i(this,"handleMouseMove",t=>{const e=Date.now();e-this.lastSampleTime<this.SAMPLE_INTERVAL||(this.lastSampleTime=e,this.buffer.push({x:t.clientX,y:t.clientY,time:e}),this.buffer.length>this.BUFFER_SIZE&&this.buffer.shift(),this.buffer.length>=this.BUFFER_SIZE&&e-this.lastSendTime>=this.SEND_COOLDOWN&&(this.analyze(),this.lastSendTime=e))}),this.transmitter=t,this.wasmService=e}start(){"undefined"!=typeof document&&document.addEventListener("mousemove",this.handleMouseMove)}stop(){"undefined"!=typeof document&&document.removeEventListener("mousemove",this.handleMouseMove)}analyze(){if(this.buffer.length<20)return;const t=this.wasmService.calculateEntropy(this.buffer),e=this.calculateSpeedVariance(),i=this.buffer.map(t=>({x:t.x,y:t.y,t:t.time}));this.transmitter.send("behavior_metrics",{entropy:t,speedVariance:e,sampleSize:this.buffer.length,timestamp:Date.now(),rawTrajectory:i})}calculateSpeedVariance(){const t=[];for(let i=1;i<this.buffer.length;i++){const e=this.buffer[i-1],s=this.buffer[i],n=Math.sqrt(Math.pow(s.x-e.x,2)+Math.pow(s.y-e.y,2)),a=s.time-e.time;a>0&&t.push(n/a)}if(t.length<2)return 1;const e=t.reduce((t,e)=>t+e,0)/t.length;return t.reduce((t,i)=>t+Math.pow(i-e,2),0)/t.length}}class u{constructor(t){i(this,"lastInteractionTime",0),i(this,"lastInteractionType","none"),i(this,"transmitter"),i(this,"isMobile",!1),i(this,"keyPressTimes",new Map),i(this,"lastKeyUpTime",0),i(this,"flightTimes",[]),i(this,"dwellTimes",[]),i(this,"suspiciousFocusCount",0),i(this,"suspiciousFocusResetTimer",null),i(this,"rawKeystrokes",[]),this.transmitter=t,this.isMobile=this.detectMobile()}start(){this.initListeners()}detectMobile(){return"undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0)}initListeners(){if("undefined"==typeof document)return;["mousedown","keydown","touchstart","touchend"].forEach(t=>{document.addEventListener(t,t=>{this.lastInteractionTime=Date.now(),this.lastInteractionType=t.type},{passive:!0,capture:!0})}),document.addEventListener("focus",t=>{const e=t.target;"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName||(this.checkFocusIntegrity(),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[],this.lastKeyUpTime=0)},{capture:!0}),document.addEventListener("keydown",t=>{const e=t.target;if("INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName)return;const i=Date.now();if(this.keyPressTimes.set(t.code,i),this.rawKeystrokes.push({code:t.code,t:i,type:"down"}),this.lastKeyUpTime>0){const t=i-this.lastKeyUpTime;t<2e3&&this.flightTimes.push(t)}},{passive:!0,capture:!0}),document.addEventListener("keyup",t=>{const e=t.target;if("INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName)return;const i=Date.now();this.lastKeyUpTime=i,this.rawKeystrokes.push({code:t.code,t:i,type:"up"});const s=this.keyPressTimes.get(t.code);if(s){const e=i-s;this.dwellTimes.push(e),this.keyPressTimes.delete(t.code)}this.flightTimes.length>=10&&this.reportKeystrokeDynamics(e)},{passive:!0,capture:!0}),document.addEventListener("blur",t=>{const e=t.target;("INPUT"===e.tagName||"TEXTAREA"===e.tagName)&&this.flightTimes.length>0&&this.reportKeystrokeDynamics(e)},{capture:!0})}checkFocusIntegrity(){const t=Date.now(),e=t-this.lastInteractionTime;performance.now()<5e3||(e>200?(this.suspiciousFocusCount++,clearTimeout(this.suspiciousFocusResetTimer),this.suspiciousFocusResetTimer=setTimeout(()=>{this.suspiciousFocusCount=0},3e3),this.transmitter.send("behavior_metrics",{type:"suspicious_focus",timeSinceInteraction:e,lastInteraction:this.lastInteractionType,consecutiveCount:this.suspiciousFocusCount,timestamp:t})):this.suspiciousFocusCount=0)}reportKeystrokeDynamics(t){const e=this.average(this.flightTimes),i=this.variance(this.flightTimes,e),s=this.average(this.dwellTimes),n=this.variance(this.dwellTimes,s);this.transmitter.send("input_metrics",{element:t.id||t.tagName,flight:{avg:e,variance:i,samples:this.flightTimes.length},dwell:{avg:s,variance:n},isMobile:this.isMobile,timestamp:Date.now(),rawKeystrokes:[...this.rawKeystrokes]}),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[]}average(t){return 0===t.length?0:t.reduce((t,e)=>t+e,0)/t.length}variance(t,e){return 0===t.length?0:t.reduce((t,i)=>t+Math.pow(i-e,2),0)/t.length}}class m{constructor(){i(this,"wasmModule",null),i(this,"memory",null),i(this,"instance",null)}async load(t){try{const e=await fetch(`${t}/sdk/core.wasm`);if(!e.ok)throw new Error(`HTTP ${e.status}`);const i={env:{abort:()=>{}}};if(WebAssembly.instantiateStreaming){const t=await WebAssembly.instantiateStreaming(e,i);this.instance=t.instance}else{const t=await e.arrayBuffer(),s=await WebAssembly.instantiate(t,i);this.instance=s.instance}this.wasmModule=this.instance.exports,this.memory=this.wasmModule.memory}catch(e){}}isLoaded(){return!!this.instance}calculateEntropy(t){if(!this.instance||!this.wasmModule)return 0;const e=2*t.length,i=8*e;try{const s=this.wasmModule.__new(i,0),n=new Float64Array(this.memory.buffer,s,e);for(let e=0;e<t.length;e++)n[2*e]=t[e].x,n[2*e+1]=t[e].y;return this.wasmModule.calculateEntropy(s,e)}catch(s){return 0}}simpleHash(t){if(!this.instance||!this.wasmModule)return 0;try{const e=(new TextEncoder).encode(t),i=e.length,s=this.wasmModule.__new(i,0);return new Uint8Array(this.memory.buffer,s,i).set(e),this.wasmModule.simpleHash(s,i)}catch(e){return 0}}}class p{constructor(t,e){i(this,"transmitter"),i(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof document||setTimeout(async()=>{const t=await this.generateFingerprint(),e=this.collectWebGLFingerprint(),i=this.collectAudioFingerprint();this.transmitter.send("fingerprint_collected",{hash:t,webgl:e,audio:i}),this.hasRun=!0},500)}async generateFingerprint(){try{const t=document.createElement("canvas"),e=t.getContext("2d");if(!e)return"unknown";e.textBaseline="top",e.font='14px "Arial"',e.textBaseline="alphabetic",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("aientrophy Security 😃",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("aientrophy Security 😃",4,17),e.globalCompositeOperation="multiply",e.fillStyle="rgb(255,0,255)",e.beginPath(),e.arc(50,50,50,0,2*Math.PI,!0),e.closePath(),e.fill(),e.fillStyle="rgb(0,255,255)",e.beginPath(),e.arc(100,50,50,0,2*Math.PI,!0),e.closePath(),e.fill(),e.fillStyle="rgb(255,255,0)",e.beginPath(),e.arc(75,100,50,0,2*Math.PI,!0),e.closePath(),e.fill();const i=t.toDataURL();return await this.sha256(i)}catch(t){return"error"}}async sha256(t){const e=(new TextEncoder).encode(t),i=await window.crypto.subtle.digest("SHA-256",e),s=new Uint8Array(i);return Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join("")}collectWebGLFingerprint(){try{const t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return{available:!1};const i=e,s={available:!0},n=i.getExtension("WEBGL_debug_renderer_info");return n&&(s.renderer=i.getParameter(n.UNMASKED_RENDERER_WEBGL),s.vendor=i.getParameter(n.UNMASKED_VENDOR_WEBGL)),s.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),s.maxViewportDims=Array.from(i.getParameter(i.MAX_VIEWPORT_DIMS)),s.maxRenderbufferSize=i.getParameter(i.MAX_RENDERBUFFER_SIZE),s.maxVertexAttribs=i.getParameter(i.MAX_VERTEX_ATTRIBS),s.extensions=(i.getSupportedExtensions()||[]).length,s}catch(t){return{available:!1,error:!0}}}collectAudioFingerprint(){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return{available:!1};const e=new t,i={available:!0,sampleRate:e.sampleRate,state:e.state,maxChannels:e.destination.maxChannelCount};return e.close(),i}catch(t){return{available:!1}}}}class g{constructor(t){i(this,"originalFetch"),i(this,"endpoint"),i(this,"callbackManager",null),i(this,"challengeInProgress",null),this.endpoint=t,this.originalFetch=window.fetch.bind(window)}setCallbackManager(t){this.callbackManager=t}start(){window.fetch=async(t,e)=>{var i;const s=await this.originalFetch(t,e);if(403===s.status){const a=s.clone();try{const n=await a.json();if("challenge"===n.action&&"captcha"===(null==(i=n.metadata)?void 0:i.type)){const i={action:"challenge",score:n.score,metadata:n.metadata};if(this.callbackManager){if(await this.callbackManager.emitChallenge(i))return this.originalFetch(t,e)}this.challengeInProgress||(this.challengeInProgress=this.showCaptchaModal().finally(()=>{this.challengeInProgress=null}));return await this.challengeInProgress?this.originalFetch(t,e):s}"block"===n.action&&this.callbackManager&&this.callbackManager.emit("block",{action:"block",score:n.score,metadata:n.metadata})}catch(n){}}return s}}async showCaptchaModal(){return new Promise(t=>{const e=document.createElement("div");e.id="sec-sdk-challenge-host",e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100vw",e.style.height="100vh",e.style.zIndex="999999",e.style.backgroundColor="rgba(0,0,0,0.5)",e.style.display="flex",e.style.justifyContent="center",e.style.alignItems="center";const i=e.attachShadow({mode:"open"}),s=document.createElement("div");s.style.background="white",s.style.padding="20px",s.style.borderRadius="8px",s.style.boxShadow="0 4px 12px rgba(0,0,0,0.2)",s.style.textAlign="center",s.style.fontFamily="system-ui, sans-serif";const n=document.createElement("h3");n.textContent="Security Check",n.style.margin="0 0 16px 0";const a=document.createElement("p");a.textContent="Unusual activity detected. Please verify you are human.",a.style.marginBottom="16px",a.style.fontSize="14px",a.style.color="#666";const r=document.createElement("div");r.innerHTML="Loading...",r.style.marginBottom="16px";const o=document.createElement("input");o.type="text",o.placeholder="Enter details",o.style.padding="8px",o.style.marginRight="8px",o.style.border="1px solid #ddd",o.style.borderRadius="4px";const c=document.createElement("button");c.textContent="Verify",c.style.padding="8px 16px",c.style.background="#007bff",c.style.color="white",c.style.border="none",c.style.borderRadius="4px",c.style.cursor="pointer";const l=document.createElement("p");l.style.color="red",l.style.fontSize="12px",l.style.display="none",s.appendChild(n),s.appendChild(a),s.appendChild(r),s.appendChild(o),s.appendChild(c),s.appendChild(l),i.appendChild(s),document.body.appendChild(e);let h="";const d=async()=>{try{const t=await this.originalFetch(`${this.endpoint}/challenge`),e=await t.json();h=e.id,r.innerHTML=e.svg}catch(t){r.textContent="Error loading CAPTCHA"}},u=async()=>{l.style.display="none",c.textContent="Verifying...";try{const i=o.value,s=await this.originalFetch(`${this.endpoint}/challenge/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:h,answer:i})});(await s.json()).success?(document.body.removeChild(e),t(!0)):(l.textContent="Incorrect, try again.",l.style.display="block",c.textContent="Verify",o.value="",d())}catch(i){l.textContent="System error.",l.style.display="block",c.textContent="Verify"}};c.onclick=u,o.onkeydown=t=>{"Enter"===t.key&&u()},d()})}}class f{constructor(t){i(this,"transmitter"),i(this,"eventsToWatch",["click","mousedown","keydown","touchstart","focus"]),i(this,"handleEvent",t=>{const e=t.target;if(!(e&&e instanceof HTMLElement))return;if(e===document.body||e===document.documentElement)return;const i=this.checkVisibility(e,t);if(i){const s=e.getBoundingClientRect();this.transmitter.send("invisible_interaction",{type:t.type,target:e.tagName,id:e.id,reason:i,timestamp:Date.now(),isTrusted:t.isTrusted,coordinates:{x:t instanceof MouseEvent?t.clientX:0,y:t instanceof MouseEvent?t.clientY:0},viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{x:window.scrollX,y:window.scrollY},docDim:{width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight},elementRect:{top:s.top,left:s.left,width:s.width,height:s.height}})}}),this.transmitter=t}start(){this.eventsToWatch.forEach(t=>{document.addEventListener(t,this.handleEvent,{capture:!0,passive:!0})})}stop(){this.eventsToWatch.forEach(t=>{document.removeEventListener(t,this.handleEvent,{capture:!0})})}checkVisibility(t,e){var i,s;const n=window.getComputedStyle(t);if("none"===n.display)return"display:none";if("hidden"===n.visibility)return"visibility:hidden";if("0"===n.opacity)return"opacity:0";const a=t.getBoundingClientRect();if(a.width<=0||a.height<=0)return"zero_size";const r=a.right<0||a.left>window.innerWidth,o=a.bottom<0||a.top>window.innerHeight;if(r||o)return"off_screen";if(e instanceof MouseEvent||e instanceof TouchEvent){let n,a;if(e instanceof MouseEvent?(n=e.clientX,a=e.clientY):(n=(null==(i=e.touches[0])?void 0:i.clientX)||0,a=(null==(s=e.touches[0])?void 0:s.clientY)||0),n>=0&&n<=window.innerWidth&&a>=0&&a<=window.innerHeight){const i=document.elementFromPoint(n,a);if(i&&i!==t&&!t.contains(i)&&!i.contains(t)&&0===n&&0===a&&e.isTrusted)return null}}return null}}class y{constructor(t){i(this,"transmitter"),i(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(setTimeout(()=>this.detect(),1500),this.hasRun=!0)}detect(){var t,e;const i={};let s=0;!0===navigator.webdriver&&(i.webdriver=!0,s+=40);try{this.detectCDP()&&(i.cdp=!0,s+=50)}catch(c){}const n=this.detectAutomationGlobals();n.length>0&&(i.automationGlobals=n,s+=30);const a=this.checkWebGL();a.suspicious&&(i.webgl=a,s+=25);const r=this.checkInconsistencies();r.length>0&&(i.inconsistencies=r,s+=15);const o=this.checkHeadless();o.score>0&&(i.headless=o.flags,s+=o.score),s>0&&this.transmitter.send("automation_detected",{signals:i,score:s,timestamp:Date.now()}),this.transmitter.send("init_signals",{webdriver:!!navigator.webdriver,plugins:(null==(t=navigator.plugins)?void 0:t.length)??0,languages:(null==(e=navigator.languages)?void 0:e.length)??0,platform:navigator.platform,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory,maxTouchPoints:navigator.maxTouchPoints,webglRenderer:a.renderer,webglVendor:a.vendor,timestamp:Date.now()})}detectCDP(){let t=!1;const e=console.debug;return console.debug=e,t}detectAutomationGlobals(){const t=[],e=[["selenium",()=>!!window._selenium],["selenium_unwrapped",()=>!!document.__selenium_unwrapped],["driver_evaluate",()=>!!document.__driver_evaluate],["webdriver_evaluate",()=>!!document.__webdriver_evaluate],["driver_unwrapped",()=>!!document.__driver_unwrapped],["fxdriver",()=>!!document.__fxdriver_evaluate],["playwright",()=>!!window.__playwright],["playwright_binding",()=>!!window.__playwright__binding__],["pwInitScripts",()=>!!window.__pwInitScripts],["puppeteer",()=>!!window.__puppeteer_evaluation_script__],["phantom",()=>!!window.callPhantom||!!window._phantom],["nightmare",()=>!!window.__nightmare],["cdc",()=>Object.keys(document).some(t=>t.startsWith("cdc_")||t.startsWith("$cdc_"))]];for(const[s,n]of e)try{n()&&t.push(s)}catch(i){}return t}checkWebGL(){try{const t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return{suspicious:!1,renderer:"unavailable",vendor:"unavailable"};const i=e.getExtension("WEBGL_debug_renderer_info");if(!i)return{suspicious:!1,renderer:"no_debug_info",vendor:"no_debug_info"};const s=e.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",n=e.getParameter(i.UNMASKED_VENDOR_WEBGL)||"";return{suspicious:/SwiftShader/i.test(s)||/Mesa OffScreen/i.test(s)||/llvmpipe/i.test(s),renderer:s,vendor:n}}catch(t){return{suspicious:!1,renderer:"error",vendor:"error"}}}checkInconsistencies(){const t=[];try{const e=navigator.userAgent,i=navigator.platform;/Windows/.test(e)&&/Mac/.test(i)&&t.push("ua_platform_mismatch_win_mac"),/Macintosh/.test(e)&&/Win/.test(i)&&t.push("ua_platform_mismatch_mac_win"),/Mobile|Android|iPhone/.test(e)&&0===navigator.maxTouchPoints&&t.push("mobile_ua_no_touch"),/Chrome/.test(e)&&navigator.plugins&&0===navigator.plugins.length&&t.push("chrome_no_plugins"),navigator.languages&&0!==navigator.languages.length||t.push("no_languages")}catch(e){}return t}checkHeadless(){const t=[];let e=0;try{if(/HeadlessChrome/.test(navigator.userAgent)&&(t.push("headless_ua"),e+=40),/Chrome/.test(navigator.userAgent)&&!window.chrome&&(t.push("chrome_ua_no_chrome_obj"),e+=15),window.screen&&800===window.screen.width&&600===window.screen.height&&(t.push("default_screen_size"),e+=10),"Notification"in window){"denied"===window.Notification.permission&&navigator.userAgent.includes("Chrome")&&(t.push("notification_denied_default"),e+=5)}const i=navigator.connection;i&&0===i.rtt&&(t.push("zero_rtt"),e+=10)}catch(i){}return{score:e,flags:t}}}class w{constructor(t){i(this,"transmitter"),i(this,"sessionStart",0),i(this,"pageTransitions",[]),i(this,"interactionTimestamps",[]),i(this,"lastPageUrl",""),i(this,"formStartTimes",new Map),i(this,"reportInterval",null),this.transmitter=t}start(){if("undefined"==typeof window)return;this.sessionStart=Date.now(),this.lastPageUrl=window.location.href;["mousedown","keydown","touchstart","scroll"].forEach(t=>{document.addEventListener(t,()=>{this.interactionTimestamps.push(Date.now()),this.interactionTimestamps.length>500&&this.interactionTimestamps.shift()},{passive:!0,capture:!0})}),this.observeNavigation(),this.observeForms(),this.reportInterval=setInterval(()=>this.report(),15e3)}observeNavigation(){const t=history.pushState,e=history.replaceState,i=this;history.pushState=function(e,s,n){t.call(this,e,s,n),i.onPageTransition()},history.replaceState=function(t,s,n){e.call(this,t,s,n),i.onPageTransition()},window.addEventListener("popstate",()=>this.onPageTransition())}onPageTransition(){const t=Date.now(),e=window.location.href;e!==this.lastPageUrl&&(this.pageTransitions.push(t),this.lastPageUrl=e)}observeForms(){document.addEventListener("focus",t=>{const e=t.target;if("INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName){const t=e.closest("form"),i=(null==t?void 0:t.id)||(null==t?void 0:t.action)||"anonymous_form";this.formStartTimes.has(i)||this.formStartTimes.set(i,Date.now())}},{capture:!0}),document.addEventListener("submit",t=>{const e=t.target,i=e.id||e.action||"anonymous_form",s=this.formStartTimes.get(i);if(s){const t=Date.now()-s;this.transmitter.send("session_metrics",{type:"form_completion",formId:i,duration:t,timestamp:Date.now()}),this.formStartTimes.delete(i)}},{capture:!0})}report(){const t=Date.now(),e=t-this.sessionStart;if(this.interactionTimestamps.length<10)return;const i=this.calculateIntervals(this.interactionTimestamps),s=this.analyzeTimingDistribution(i),n=this.analyzePageTransitions();this.transmitter.send("session_metrics",{type:"session_analysis",sessionDuration:e,totalInteractions:this.interactionTimestamps.length,pageTransitions:this.pageTransitions.length,timing:s,pages:n,timestamp:t})}calculateIntervals(t){const e=[];for(let i=1;i<t.length;i++)e.push(t[i]-t[i-1]);return e}analyzeTimingDistribution(t){if(t.length<5)return{samples:t.length};const e=t.reduce((t,e)=>t+e,0)/t.length,i=t.reduce((t,i)=>t+Math.pow(i-e,2),0)/t.length,s=Math.sqrt(i),n=e>0?s/e:0,a=this.shannonEntropy(t,50),r=this.autocorrelation(t);return{mean:Math.round(e),stdDev:Math.round(s),cv:parseFloat(n.toFixed(4)),entropy:parseFloat(a.toFixed(4)),autocorrelation:parseFloat(r.toFixed(4)),samples:t.length}}analyzePageTransitions(){if(this.pageTransitions.length<2)return{count:this.pageTransitions.length};const t=this.calculateIntervals(this.pageTransitions),e=t.reduce((t,e)=>t+e,0)/t.length,i=t.reduce((t,i)=>t+Math.pow(i-e,2),0)/t.length,s=e>0?Math.sqrt(i)/e:0;return{count:this.pageTransitions.length,avgInterval:Math.round(e),cv:parseFloat(s.toFixed(4))}}shannonEntropy(t,e){const i=new Map;for(const a of t){const t=Math.floor(a/e);i.set(t,(i.get(t)||0)+1)}const s=t.length;let n=0;for(const a of i.values()){const t=a/s;t>0&&(n-=t*Math.log2(t))}return n}autocorrelation(t){if(t.length<3)return 0;const e=t.reduce((t,e)=>t+e,0)/t.length;let i=0,s=0;for(let n=0;n<t.length-1;n++)i+=(t[n]-e)*(t[n+1]-e);for(let n=0;n<t.length;n++)s+=Math.pow(t[n]-e,2);return 0===s?0:i/s}}class v{constructor(t){i(this,"transmitter"),i(this,"tabTimestamps",[]),i(this,"shiftTabCount",0),i(this,"tabCount",0),i(this,"isShiftDown",!1),i(this,"BURST_THRESHOLD_MS",80),i(this,"reportInterval",null),i(this,"REPORT_INTERVAL_MS",1e4),i(this,"MIN_TABS_TO_REPORT",5),i(this,"TAB_TRIGGER_COUNT",20),i(this,"onKeyDown",t=>{if("Shift"!==t.key){if("Tab"===t.key){const t=Date.now();this.isShiftDown?this.shiftTabCount++:(this.tabCount++,this.tabTimestamps.push(t),this.tabTimestamps.length>100&&this.tabTimestamps.shift()),this.tabCount+this.shiftTabCount>=this.TAB_TRIGGER_COUNT&&this.report()}}else this.isShiftDown=!0}),i(this,"onKeyUp",t=>{"Shift"===t.key&&(this.isShiftDown=!1)}),this.transmitter=t}start(){"undefined"!=typeof document&&(document.addEventListener("keydown",this.onKeyDown,{passive:!0,capture:!0}),document.addEventListener("keyup",this.onKeyUp,{passive:!0,capture:!0}),this.reportInterval=setInterval(()=>this.report(),this.REPORT_INTERVAL_MS))}stop(){"undefined"!=typeof document&&(document.removeEventListener("keydown",this.onKeyDown,{capture:!0}),document.removeEventListener("keyup",this.onKeyUp,{capture:!0}),this.reportInterval&&(clearInterval(this.reportInterval),this.reportInterval=null),this.report())}report(){const t=this.tabCount+this.shiftTabCount;if(t<this.MIN_TABS_TO_REPORT)return;const e=this.calculateIntervals(this.tabTimestamps);if(e.length<3)return void this.resetBuffers();const i=this.analyzeIntervals(e),s=this.analyzeBursts(e),n=t>0?this.shiftTabCount/t:0;this.transmitter.send("tab_navigation_metrics",{tabCount:this.tabCount,shiftTabCount:this.shiftTabCount,shiftTabRatio:parseFloat(n.toFixed(4)),intervals:i,bursts:s,timestamp:Date.now()}),this.resetBuffers()}resetBuffers(){this.tabTimestamps=[],this.tabCount=0,this.shiftTabCount=0}calculateIntervals(t){const e=[];for(let i=1;i<t.length;i++){const s=t[i]-t[i-1];s<5e3&&e.push(s)}return e}analyzeIntervals(t){if(0===t.length)return{avg:0,variance:0,cv:0,min:0,samples:0};const e=t.reduce((t,e)=>t+e,0)/t.length,i=t.reduce((t,i)=>t+Math.pow(i-e,2),0)/t.length,s=Math.sqrt(i),n=e>0?s/e:0,a=Math.min(...t);return{avg:parseFloat(e.toFixed(2)),variance:parseFloat(i.toFixed(2)),cv:parseFloat(n.toFixed(4)),min:a,samples:t.length}}analyzeBursts(t){let e=0,i=0,s=0,n=0,a=0;for(const r of t)r<this.BURST_THRESHOLD_MS?(i++,n+=r,a++):(i>=3&&(e++,s+=i),i=0);return i>=3&&(e++,s+=i),{count:e,avgLength:e>0?parseFloat((s/e).toFixed(1)):0,avgInterval:a>0?parseFloat((n/a).toFixed(2)):0}}}class b{constructor(t){i(this,"transmitter"),i(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){try{const t=this.analyzeGPU(),e=this.analyzeHardware(),i=this.analyzeScreen(),s=await this.analyzeMedia(),n=this.benchmarkCanvas();let a=0;"virtual_gpu"!==t.category&&"software_render"!==t.category&&"cloud_gpu"!==t.category||(a+=2),e.cores<=2&&a++,null!==e.memory&&e.memory<=2&&a++,24===e.colorDepth&&a++,1===e.pixelRatio&&a++,i.noTaskbar&&a++,i.isVMResolution&&a++,0===s.cameras&&0===s.microphones&&a++,s.hasBluetooth||s.hasUSB||a++,n.canvasRenderTime>50&&a++;const{classification:r,confidence:o}=this.classify(t,e,a);this.transmitter.send("cloud_environment",{classification:r,confidence:o,signals:{gpu:{renderer:t.renderer,vendor:t.vendor,category:t.category},hardware:e,screen:i,media:s,performance:n},vmIndicatorCount:a,timestamp:Date.now()})}catch(t){}}analyzeGPU(){try{const t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return{renderer:"unavailable",vendor:"unavailable",category:"unknown"};const i=e.getExtension("WEBGL_debug_renderer_info");if(!i)return{renderer:"no_debug_info",vendor:"no_debug_info",category:"unknown"};const s=e.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",n=e.getParameter(i.UNMASKED_VENDOR_WEBGL)||"";return{renderer:s,vendor:n,category:this.categorizeGPU(s,n)}}catch(t){return{renderer:"error",vendor:"error",category:"unknown"}}}categorizeGPU(t,e){const i=t.toLowerCase(),s=e.toLowerCase();return/swiftshader|llvmpipe|mesa offscreen|softpipe/.test(i)?"software_render":/svga3d|svga|vmware/.test(i)||/virtualbox/.test(i)||/parallels/.test(i)||/qxl|virtio|red hat|spice/.test(i)||/hyper-v|microsoft basic render/i.test(i)||/citrix/.test(i)?"virtual_gpu":/amazon|elastic|aws/.test(i)||/amazon|elastic|aws/.test(s)||/google cloud|gce/.test(i)||/google cloud|gce/.test(s)||/azure/.test(i)||/azure/.test(s)?"cloud_gpu":"physical"}analyzeHardware(){return{cores:navigator.hardwareConcurrency||0,memory:navigator.deviceMemory??null,colorDepth:screen.colorDepth,pixelRatio:window.devicePixelRatio||1}}analyzeScreen(){const t=screen.width,e=screen.height,i=screen.availHeight,s=e===i&&e===window.innerHeight,n=[[800,600],[1024,768],[1280,1024],[1280,800],[1920,1080]].some(([i,s])=>t===i&&e===s&&!(1920===i&&1080===s));return{width:t,height:e,availHeight:i,noTaskbar:s,isVMResolution:n}}async analyzeMedia(){let t=-1,e=-1;try{if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices){const i=await navigator.mediaDevices.enumerateDevices();t=i.filter(t=>"videoinput"===t.kind).length,e=i.filter(t=>"audioinput"===t.kind).length}}catch(a){}const i=!!navigator.bluetooth,s=!!navigator.usb;let n=null;try{if(navigator.getBattery){const t=await navigator.getBattery();n=!(t.charging&&1===t.level&&0===t.chargingTime)}}catch(a){}return{cameras:t,microphones:e,hasBluetooth:i,hasUSB:s,hasBattery:n}}benchmarkCanvas(){try{const t=document.createElement("canvas");t.width=200,t.height=200;const e=t.getContext("2d");if(!e)return{canvasRenderTime:-1};const i=performance.now();for(let n=0;n<500;n++)e.fillStyle=`rgb(${n%256},${3*n%256},${7*n%256})`,e.fillRect(13*n%200,7*n%200,10,10);e.getImageData(0,0,1,1);const s=performance.now()-i;return{canvasRenderTime:Math.round(100*s)/100}}catch(t){return{canvasRenderTime:-1}}}classify(t,e,i){return"virtual_gpu"===t.category?24===e.colorDepth?{classification:"rdp_likely",confidence:.85}:{classification:"vm_detected",confidence:.95}:"cloud_gpu"===t.category?{classification:"cloud_likely",confidence:.9}:"software_render"===t.category?{classification:"vm_detected",confidence:.9}:i>=5?{classification:"vm_likely",confidence:.8}:i>=3?{classification:"vm_likely",confidence:.6}:{classification:"physical",confidence:1-.1*i}}}class _{constructor(t){i(this,"transmitter"),i(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2500))}async detect(){var t,e;const i={};let s=0;const n={webdriver:!!navigator.webdriver,languages:(null==(t=navigator.languages)?void 0:t.join(","))||"",platform:navigator.platform||"",hardwareConcurrency:navigator.hardwareConcurrency||0,userAgent:navigator.userAgent||"",pluginsLength:(null==(e=navigator.plugins)?void 0:e.length)??0},a=this.checkIframe(n);a.score>0&&(i.iframe=a.mismatches,s+=a.score);try{const t=await this.checkWorker(n);t.score>0&&(i.worker=t.mismatches,s+=t.score)}catch(r){}s>0&&this.transmitter.send("cross_context_mismatch",{signals:i,score:s,timestamp:Date.now()})}checkIframe(t){var e,i;const s=[];let n=0;try{const a=document.createElement("iframe");a.style.display="none",a.sandbox="allow-same-origin",document.body.appendChild(a);const r=a.contentWindow;if(!r)return document.body.removeChild(a),{score:0,mismatches:[]};const o=r.navigator;o.webdriver!==navigator.webdriver&&(s.push("webdriver_mismatch"),n+=40),navigator.webdriver||!0!==o.webdriver||(s.push("webdriver_spoofed_in_main"),n+=30);((null==(e=o.languages)?void 0:e.join(","))||"")!==t.languages&&(s.push("languages_mismatch"),n+=15),o.platform!==t.platform&&(s.push("platform_mismatch"),n+=15);((null==(i=o.plugins)?void 0:i.length)??0)!==t.pluginsLength&&(s.push("plugins_mismatch"),n+=10),document.body.removeChild(a)}catch(a){}return{score:n,mismatches:s}}checkWorker(t){return new Promise(e=>{try{const i=new Blob(["\n self.onmessage = function() {\n var nav = self.navigator;\n self.postMessage({\n webdriver: !!nav.webdriver,\n languages: (nav.languages || []).join(','),\n platform: nav.platform || '',\n hardwareConcurrency: nav.hardwareConcurrency || 0,\n userAgent: nav.userAgent || ''\n });\n };\n "],{type:"application/javascript"}),s=URL.createObjectURL(i),n=new Worker(s),a=setTimeout(()=>{n.terminate(),URL.revokeObjectURL(s),e({score:0,mismatches:[]})},3e3);n.onmessage=i=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(s);const r=i.data,o=[];let c=0;r.webdriver!==t.webdriver&&(o.push("worker_webdriver_mismatch"),c+=35),r.languages!==t.languages&&(o.push("worker_languages_mismatch"),c+=15),r.platform!==t.platform&&(o.push("worker_platform_mismatch"),c+=15),r.hardwareConcurrency!==t.hardwareConcurrency&&(o.push("worker_concurrency_mismatch"),c+=10),r.userAgent!==t.userAgent&&(o.push("worker_ua_mismatch"),c+=20),e({score:c,mismatches:o})},n.onerror=()=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(s),e({score:0,mismatches:[]})},n.postMessage("check")}catch(i){e({score:0,mismatches:[]})}})}}class T{constructor(t){i(this,"transmitter"),i(this,"hasRun",!1),this.transmitter=t}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){const t={};let e=0;const i=await this.checkBrokenImage();i.suspicious&&(t.brokenImage=i,e+=25);const s=await this.checkClientHints();s.suspicious&&(t.clientHints=s,e+=20);const n=this.checkCDPMouseSignature();n.suspicious&&(t.cdpMouse=n,e+=30);const a=this.checkHairlineSupport();a.suspicious&&(t.hairline=a,e+=10);const r=this.checkExtraFrameworks();r.length>0&&(t.extraFrameworks=r,e+=20);(await this.checkWorkerCDP()).suspicious&&(t.workerCDP=!0,e+=35),e>0&&this.transmitter.send("headless_probe",{signals:t,score:e,timestamp:Date.now()})}checkBrokenImage(){return new Promise(t=>{try{const e=document.createElement("img");e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==___invalid";const i=setTimeout(()=>{t({suspicious:!1,width:-1,height:-1})},2e3);e.onerror=()=>{clearTimeout(i);const s=e.width,n=e.height;t({suspicious:0===s&&0===n,width:s,height:n})},e.onload=()=>{clearTimeout(i),t({suspicious:!1,width:e.width,height:e.height})},e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e),setTimeout(()=>{try{document.body.removeChild(e)}catch(t){}},100)}catch(e){t({suspicious:!1,width:-1,height:-1})}})}async checkClientHints(){const t=[];try{const e=navigator.userAgentData;if(!e)return{suspicious:!1,mismatches:[]};const i=navigator.userAgent,s=(e.brands||[]).map(t=>t.brand);/Chrome\/\d/.test(i)&&!s.some(t=>/Chromium|Google Chrome|Chrome/.test(t))&&t.push("ua_chrome_no_brand"),e.platform&&(/Windows/.test(i)&&"Windows"!==e.platform&&t.push("ua_windows_brand_mismatch"),/Macintosh/.test(i)&&"macOS"!==e.platform&&t.push("ua_mac_brand_mismatch"),/Linux/.test(i)&&!/Linux|Android|ChromeOS/.test(e.platform)&&t.push("ua_linux_brand_mismatch")),/Mobile/.test(i)&&!1===e.mobile&&t.push("ua_mobile_brand_mismatch")}catch(e){}return{suspicious:t.length>0,mismatches:t}}checkCDPMouseSignature(){let t=0,e=0,i=!1;try{const s=[],n=i=>{s.push(i),e++,0===i.movementX&&0===i.movementY&&t++};document.addEventListener("mousemove",n,{passive:!0}),setTimeout(()=>{document.removeEventListener("mousemove",n)},5e3),e>10&&t/e>.9&&(i=!0)}catch(s){}return{suspicious:i,zeroMovementCount:t,totalEvents:e}}checkHairlineSupport(){try{const t=document.createElement("div");t.style.border=".5px solid transparent",t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);const e=t.offsetHeight;return document.body.removeChild(t),{suspicious:0===e,offsetHeight:e}}catch(t){return{suspicious:!1,offsetHeight:-1}}}checkExtraFrameworks(){const t=[];try{const i=window.external;if(i&&"function"==typeof i.toString)try{const e=i.toString();/Sequentum/i.test(e)&&t.push("sequentum")}catch(e){}const s=["__webdriver_script_fn","__webdriver_script_func","__webdriver_evaluate","__selenium_evaluate","__fxdriver_evaluate","__driver_evaluate","__webdriver_unwrapped","__selenium_unwrapped","__fxdriver_unwrapped","__driver_unwrapped","_Selenium_IDE_Recorder","_selenium","calledSelenium","_WEBDRIVER_ELEM_CACHE","ChromeDriverw","driver-hierarchical","__$webdriverAsyncExecutor","__lastWatirAlert","__lastWatirConfirm","__lastWatirPrompt","_WEBDRIVER_ELEM_CACHE","webdriver","_phantom","__nightmare","_selenium"];for(const e of s)(e in document||e in window)&&t.push(`global_${e}`);const n=Object.getOwnPropertyNames(navigator);for(const e of n)/webdriver|selenium|puppeteer|playwright|phantom/i.test(e)&&t.push(`nav_${e}`)}catch(e){}return t}checkWorkerCDP(){return new Promise(t=>{try{const e=new Blob(["\n self.onmessage = function() {\n var detected = false;\n try {\n var marker = {};\n Object.defineProperty(marker, 'stack', {\n get: function() { detected = true; return ''; }\n });\n console.debug(marker);\n } catch(e) {}\n self.postMessage({ cdp: detected });\n };\n "],{type:"application/javascript"}),i=URL.createObjectURL(e),s=new Worker(i),n=setTimeout(()=>{s.terminate(),URL.revokeObjectURL(i),t({suspicious:!1})},3e3);s.onmessage=e=>{clearTimeout(n),s.terminate(),URL.revokeObjectURL(i),t({suspicious:!0===e.data.cdp})},s.onerror=()=>{clearTimeout(n),s.terminate(),URL.revokeObjectURL(i),t({suspicious:!1})},s.postMessage("check")}catch(e){t({suspicious:!1})}})}}const k="__aie_token";class C{constructor(t){i(this,"config"),i(this,"renewTimer",null),i(this,"verified",!1),this.config=t}async start(){const t=this.getToken();if(t&&!this.isExpired(t))return this.verified=!0,this.scheduleRenewal(t),this.revealContent(),this.config.debug,!0;this.hideContent();const e=await this.solveChallenge();return e?(this.verified=!0,this.revealContent()):this.config.insertHoneypot&&this.insertHoneypotData(),e}isVerified(){return this.verified}stop(){this.renewTimer&&(clearTimeout(this.renewTimer),this.renewTimer=null)}async solveChallenge(){try{const t=await fetch(`${this.config.apiBase}/crawl-protect/challenge`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId}});if(!t.ok)return!1;const{id:e,challenges:i}=await t.json(),s=[];for(const c of i)if("math"===c.type){const t="add"===c.op?c.a+c.b:c.a*c.b;s.push(String(t))}else if("crypto"===c.type){const t=await this.sha256(c.nonce);s.push(t.slice(0,8))}const n=s.join(":"),a=await this.getFingerprint(),r=await fetch(`${this.config.apiBase}/crawl-protect/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId},body:JSON.stringify({id:e,solution:n,fingerprint:a}),credentials:"include"});if(!r.ok)return!1;const o=await r.json();return!(!o.success||!o.token)&&(this.setToken(o.token),this.scheduleRenewal(o.token),this.config.debug,!0)}catch(t){return this.config.debug,!1}}hideContent(){var t;if(null==(t=this.config.protectSelectors)?void 0:t.length)for(const e of this.config.protectSelectors){document.querySelectorAll(e).forEach(t=>{t.dataset.aieOrigDisplay=t.style.display,t.style.display="none"})}}revealContent(){var t;if(null==(t=this.config.protectSelectors)?void 0:t.length)for(const e of this.config.protectSelectors){document.querySelectorAll(e).forEach(t=>{t.style.display=t.dataset.aieOrigDisplay||"",delete t.dataset.aieOrigDisplay})}}insertHoneypotData(){const t=document.createElement("div");t.style.cssText="position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;",t.setAttribute("aria-hidden","true"),t.innerHTML='\n <span class="price" data-aie-honeypot="1">₩999,999,999</span>\n <span class="stock" data-aie-honeypot="1">재고: 0개</span>\n <a href="mailto:honeypot@aientrophy.com" data-aie-honeypot="1">contact</a>\n ',document.body.appendChild(t)}getToken(){const t=document.cookie.match(new RegExp(`(?:^|; )${k}=([^;]*)`));return t?decodeURIComponent(t[1]):null}setToken(t){const e=new Date(Date.now()+18e5).toUTCString();document.cookie=`${k}=${encodeURIComponent(t)};path=/;expires=${e};SameSite=None;Secure`}isExpired(t){try{const[e]=t.split("."),i=JSON.parse(atob(e.replace(/-/g,"+").replace(/_/g,"/")));return Date.now()>i.exp}catch{return!0}}scheduleRenewal(t){try{const[e]=t.split("."),i=JSON.parse(atob(e.replace(/-/g,"+").replace(/_/g,"/"))),s=i.exp-3e5-Date.now();s>0&&(this.renewTimer=setTimeout(()=>this.solveChallenge(),s))}catch{}}async sha256(t){const e=new TextEncoder,i=await crypto.subtle.digest("SHA-256",e.encode(t));return Array.from(new Uint8Array(i)).map(t=>t.toString(16).padStart(2,"0")).join("")}async getFingerprint(){const t=[navigator.userAgent,navigator.language,screen.width+"x"+screen.height,Intl.DateTimeFormat().resolvedOptions().timeZone];return this.sha256(t.join("|"))}}const E=new class{constructor(){i(this,"transmitter"),i(this,"behaviorCollector"),i(this,"rapidClickDetector"),i(this,"honeypot"),i(this,"mouseTracker"),i(this,"canvasFingerprinter"),i(this,"inputTracker"),i(this,"challengeHandler"),i(this,"invisibleInteraction"),i(this,"automationDetector"),i(this,"sessionAnalyzer"),i(this,"tabNavigationAnalyzer"),i(this,"cloudEnvironmentDetector"),i(this,"crossContextDetector"),i(this,"headlessProbeDetector"),i(this,"crawlProtect",null),i(this,"initialized",!1),i(this,"wasmService"),i(this,"callbackManager"),this.transmitter=new o,this.wasmService=new m,this.callbackManager=new r,this.transmitter.setCallbackManager(this.callbackManager),this.behaviorCollector=new c(this.transmitter),this.rapidClickDetector=new l(this.transmitter),this.honeypot=new h(this.transmitter),this.mouseTracker=new d(this.transmitter,this.wasmService),this.canvasFingerprinter=new p(this.transmitter,this.wasmService),this.inputTracker=new u(this.transmitter),this.invisibleInteraction=new f(this.transmitter),this.automationDetector=new y(this.transmitter),this.sessionAnalyzer=new w(this.transmitter),this.tabNavigationAnalyzer=new v(this.transmitter),this.cloudEnvironmentDetector=new b(this.transmitter),this.crossContextDetector=new _(this.transmitter),this.headlessProbeDetector=new T(this.transmitter)}async init(t){var e,i;if(this.initialized)return;t.callbacks&&this.callbackManager.setConfigCallbacks(t.callbacks);const s=t.endpoint.replace(/\/events$/,"");try{await this.wasmService.load(s),this.startDetectors(),this.transmitter.setConfig(t),this.challengeHandler=new g(s),this.challengeHandler.setCallbackManager(this.callbackManager),!1!==(null==(e=t.serverConfig)?void 0:e.captchaEnabled)&&this.challengeHandler.start();((null==(i=t.serverConfig)?void 0:i.devtoolsDetection)??!t.debug)&&Promise.resolve().then(()=>x).then(({AntiDebug:t})=>{t.start(),Promise.resolve().then(()=>M).then(({ConsoleDetector:t})=>{new t(()=>{this.transmitter.send("devtools_open",{detected:!0})}).start()})}),t.crawlProtect&&(this.crawlProtect=new C({apiBase:s,clientId:t.clientKey,protectSelectors:t.crawlProtect.protectSelectors,insertHoneypot:t.crawlProtect.insertHoneypot,debug:t.debug}),this.crawlProtect.start().catch(e=>{t.debug})),this.initialized=!0,t.debug,this.callbackManager.emit("ready")}catch(n){this.callbackManager.emit("error",{code:"INIT_ERROR",message:"SecuritySDK initialization failed",details:null==n?void 0:n.message})}}on(t,e){this.callbackManager.on(t,e)}off(t,e){this.callbackManager.off(t,e)}once(t,e){this.callbackManager.once(t,e)}startDetectors(){this.behaviorCollector.start(),this.honeypot.start(),this.mouseTracker.start(),this.canvasFingerprinter.start(),this.inputTracker.start(),this.invisibleInteraction.start(),this.automationDetector.start(),this.sessionAnalyzer.start(),this.tabNavigationAnalyzer.start(),this.cloudEnvironmentDetector.start(),this.crossContextDetector.start(),this.headlessProbeDetector.start()}};"undefined"!=typeof window&&(window.SecuritySDK=E);const S={};class A{static start(){this.saveConsole(),this.disableConsole(),this.preventDevTools()}static stop(){this.intervalId&&clearInterval(this.intervalId)}static getOriginalConsole(){return S}static saveConsole(){const t=["log","debug","info","warn","error","table","trace","dir","clear"];try{const e=window.console;if(!e)return;for(const i of t)"function"==typeof e[i]&&(S[i]=e[i].bind(e))}catch(e){}}static preventDevTools(){this.intervalId=setInterval(()=>{this.debuggerCheck(),this.devtoolsCloseCheck()},this.checkInterval)}static debuggerCheck(){!function(){try{(function(){}).constructor("debugger")()}catch(t){}}()}static devtoolsCloseCheck(){if(navigator.maxTouchPoints>0||/Mobile|Android|iPhone|iPad/i.test(navigator.userAgent))return;const t=performance.now();(function(){}).constructor("debugger")();if(performance.now()-t>100)try{document.body.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100vh;font-family:sans-serif;background:#111;color:#fff"><div style="text-align:center"><h2 style="margin-bottom:12px">⚠ 보안 경고</h2><p style="color:#999">개발자 도구가 감지되었습니다.<br>페이지를 계속 이용하려면 개발자 도구를 닫아주세요.</p></div></div>'}catch(e){}}static disableConsole(){const t=()=>{},e=["log","debug","info","warn","error","table","trace","dir"];try{const i=window.console;if(!i)return;for(const s of e)i[s]&&(i[s]=t)}catch(i){}}}i(A,"checkInterval",1e3),i(A,"intervalId");const x=Object.freeze(Object.defineProperty({__proto__:null,AntiDebug:A},Symbol.toStringTag,{value:"Module"}));const M=Object.freeze(Object.defineProperty({__proto__:null,ConsoleDetector:class{constructor(t){i(this,"onDetect"),i(this,"intervals",[]),i(this,"detected",!1),this.onDetect=t}start(){this.startGetterTrap(),this.startSizeDetection()}stop(){for(const t of this.intervals)clearInterval(t);this.intervals=[]}triggerDetect(){this.detected||(this.detected=!0,this.onDetect(),setTimeout(()=>{this.detected=!1},5e3))}startGetterTrap(){const t=A.getOriginalConsole(),e=t.log,i=t.clear;if(!e)return;const s=document.createElement("div");Object.defineProperty(s,"id",{get:()=>(this.triggerDetect(),"")});const n=/./;n.toString=()=>(this.triggerDetect(),"");const a=setInterval(()=>{try{e(s),e(n),i&&i()}catch(t){}},1500);this.intervals.push(a)}startSizeDetection(){if(navigator.maxTouchPoints>0||/Mobile|Android|iPhone|iPad/i.test(navigator.userAgent))return;const t=setInterval(()=>{const t=window.outerWidth-window.innerWidth>160,e=window.outerHeight-window.innerHeight>160;(t||e)&&this.triggerDetect()},2e3);this.intervals.push(t)}}},Symbol.toStringTag,{value:"Module"}));t.securitySDK=E,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
package/dist/npm/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__publicField=(e,t,i)=>((e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const CONFIG_RSA_PUBLIC_KEY="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqbBCvDqyUtfhgI/Lo5pDtn1phwA6qczAyp8N1ZgQ68OTxgbJUGiXV6N67p15bBdME1R4va51P2Czq2IbRby/N+GHTciTaXvmusV8IjnIOGtKlGxWCuKIPrCS+rGjGA2j1irxBbNpqItltFxjhxBGOzsyQAF6LNIz5IKA7sC6cSH8zUyLuFrV96udc801Zc4nCJG64ZljNbDvlVbJJZ6ex5OLLS6AnrVAXpjEDR/MI/I8JvAPe/psHj6EpXgvKrBYMBOH3jzQRzMFoR79jXyGNgPjdy0A+f6RVuEG8H5sUXKeyy+cFvaT+pm6h+t6RPED11tCOwQxYZ2pExhhPxDGeQIDAQAB";class CryptoUtils{static async init(){if(!this.sessionKey)try{await this.initECDH()}catch(e){await this.initRSA()}}static async initECDH(){const e=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"]),t=await window.crypto.subtle.exportKey("raw",e.publicKey);this.ecdhPublicKeyBase64=this.arrayBufferToBase64(t);const i=(window.__securitySDKEndpoint||"").replace(/\/events$/,""),s=await fetch(`${i}/key-exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientPublicKey:this.ecdhPublicKeyBase64})});if(!s.ok)throw new Error("Key exchange failed");const{serverPublicKey:n,salt:a}=await s.json(),r=this.base64ToArrayBuffer(n),o=await window.crypto.subtle.importKey("raw",r,{name:"ECDH",namedCurve:"P-256"},!1,[]),c=await window.crypto.subtle.deriveBits({name:"ECDH",public:o},e.privateKey,256),l=await window.crypto.subtle.importKey("raw",c,"HKDF",!1,["deriveKey"]),h=this.base64ToArrayBuffer(a);this.sessionKey=await window.crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:h,info:(new TextEncoder).encode("aientrophy-session-enc")},l,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),this.protocolVersion=2}static async initRSA(){this.sessionKey=await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);const e=await this.importRSAPublicKey(CONFIG_RSA_PUBLIC_KEY),t=await window.crypto.subtle.exportKey("raw",this.sessionKey),i=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},e,t);this.encryptedSessionKey=this.arrayBufferToBase64(i),this.protocolVersion=1}static async encrypt(e){this.sessionKey||await this.init();const t=JSON.stringify(e),i=(new TextEncoder).encode(t),s=window.crypto.getRandomValues(new Uint8Array(12)),n=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},this.sessionKey,i),a=new Uint8Array(n),r=a.slice(0,a.length-16),o=a.slice(a.length-16),c={ek:2===this.protocolVersion?this.ecdhPublicKeyBase64:this.encryptedSessionKey,d:this.arrayBufferToBase64(r.buffer),iv:this.arrayBufferToBase64(s.buffer),tag:this.arrayBufferToBase64(o.buffer)};return 2===this.protocolVersion&&(c.v=2),c}static async decrypt(e){if(!this.sessionKey)throw new Error("Session key not initialized");const t=this.base64ToArrayBuffer(e.d),i=this.base64ToArrayBuffer(e.iv),s=this.base64ToArrayBuffer(e.tag),n=new Uint8Array(t.byteLength+s.byteLength);n.set(new Uint8Array(t),0),n.set(new Uint8Array(s),t.byteLength);const a=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:i},this.sessionKey,n),r=(new TextDecoder).decode(a);return JSON.parse(r)}static setEndpoint(e){window.__securitySDKEndpoint=e}static async importRSAPublicKey(e){const t=window.atob(e),i=this.str2ab(t);return await window.crypto.subtle.importKey("spki",i,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"])}static str2ab(e){const t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0,n=e.length;s<n;s++)i[s]=e.charCodeAt(s);return t}static arrayBufferToBase64(e){let t="";const i=new Uint8Array(e),s=i.byteLength;for(let n=0;n<s;n++)t+=String.fromCharCode(i[n]);return window.btoa(t)}static base64ToArrayBuffer(e){const t=window.atob(e),i=t.length,s=new Uint8Array(i);for(let n=0;n<i;n++)s[n]=t.charCodeAt(n);return s.buffer}}__publicField(CryptoUtils,"sessionKey",null),__publicField(CryptoUtils,"ecdhPublicKeyBase64",null),__publicField(CryptoUtils,"encryptedSessionKey",null),__publicField(CryptoUtils,"protocolVersion",2);const THREAT_EVENTS=new Set(["rapid_click","honeypot_triggered","devtools_open","invisible_interaction","integrity_violation","dom_mutation","behavior_metrics","behavior_analysis","input_metrics","keystroke_dynamics","environmental_integrity","init_signals","automation_detected","cross_context_mismatch","headless_probe"]);class CallbackManager{constructor(){__publicField(this,"handlers",new Map),__publicField(this,"configCallbacks",{})}setConfigCallbacks(e){this.configCallbacks=e}on(e,t){this.addHandler(e,t,!1)}once(e,t){this.addHandler(e,t,!0)}off(e,t){const i=this.handlers.get(e);if(!i)return;const s=i.filter(e=>e.handler!==t);0===s.length?this.handlers.delete(e):this.handlers.set(e,s)}emit(e,...t){this.callHandlers(e,t);const i=e.indexOf(":");if(-1!==i){const s=e.substring(0,i);this.callHandlers(s,t)}this.callConfigCallback(e,t)}emitChallenge(e){return new Promise(t=>{let i=!1;const s=e=>{i||(i=!0,t(e))},n=this.handlers.has("challenge")&&this.handlers.get("challenge").length>0,a=!!this.configCallbacks.onChallenge;n||a?(this.callHandlers("challenge",[e,s]),this.configCallbacks.onChallenge&&this.safeCall(this.configCallbacks.onChallenge,[e,s]),setTimeout(()=>{i||(i=!0,t(!1))},5e3)):t(!1)})}addHandler(e,t,i){this.handlers.has(e)||this.handlers.set(e,[]),this.handlers.get(e).push({handler:t,once:i})}callHandlers(e,t){const i=this.handlers.get(e);if(!i||0===i.length)return;const s=[];for(let n=0;n<i.length;n++)this.safeCall(i[n].handler,t),i[n].once&&s.push(n);for(let n=s.length-1;n>=0;n--)i.splice(s[n],1);0===i.length&&this.handlers.delete(e)}callConfigCallback(e,t){if(e.startsWith("threat:")||"threat"===e)return void(e.startsWith("threat:")&&this.configCallbacks.onThreatDetected&&this.safeCall(this.configCallbacks.onThreatDetected,t));const i={ready:"onReady",error:"onError",block:"onBlock",allow:"onAllow"}[e];i&&this.configCallbacks[i]&&this.safeCall(this.configCallbacks[i],t)}safeCall(e,t){try{e(...t)}catch(i){}}}class Transmitter{constructor(){__publicField(this,"endpoint",""),__publicField(this,"clientKey",""),__publicField(this,"encryptionRequired",!1),__publicField(this,"currentNonce",""),__publicField(this,"buffer",[]),__publicField(this,"batchSize",20),__publicField(this,"flushInterval",5e3),__publicField(this,"intervalId"),__publicField(this,"responseHandler",null),__publicField(this,"callbackManager",null),__publicField(this,"flushing",!1),__publicField(this,"pendingFlush",!1),__publicField(this,"backoffMs",0),__publicField(this,"maxBackoffMs",6e4),__publicField(this,"_lastBackoffStart",0),this.startFlushInterval()}setConfig(e){var t,i;this.endpoint=e.endpoint,this.clientKey=e.clientKey,this.encryptionRequired=(null==(t=e.serverConfig)?void 0:t.encryptionRequired)??!1,this.currentNonce=(null==(i=e.serverConfig)?void 0:i.initialNonce)??"",CryptoUtils.setEndpoint(e.endpoint)}setResponseHandler(e){this.responseHandler=e}setCallbackManager(e){this.callbackManager=e}send(e,t={}){const i=Date.now();if(this.buffer.push({type:e,data:t,timestamp:i}),this.callbackManager)if(THREAT_EVENTS.has(e)){const s={type:e,data:t,timestamp:i};this.callbackManager.emit(`threat:${e}`,s)}else this.callbackManager.emit(`data:${e}`,{type:e,data:t,timestamp:i});this.buffer.length>=this.batchSize&&this.flush()}async flush(){if(0===this.buffer.length||!this.endpoint)return;if(this.backoffMs>0){const e=Date.now();if(this._lastBackoffStart||(this._lastBackoffStart=e),e-this._lastBackoffStart<this.backoffMs)return;this._lastBackoffStart=0}if(this.flushing)return void(this.pendingFlush=!0);this.flushing=!0;const e=this.buffer;this.buffer=[];try{let s;if(this.encryptionRequired){const t=await CryptoUtils.encrypt(e);s=JSON.stringify(t)}else s=JSON.stringify(e);const n={"Content-Type":"application/json","x-client-key":this.clientKey};this.currentNonce&&(n["x-request-nonce"]=this.currentNonce,this.currentNonce="");try{const i=await fetch(this.endpoint,{method:"POST",body:s,headers:n,keepalive:!0});if(429===i.status)return this.buffer=e.concat(this.buffer).slice(0,500),this.backoffMs=0===this.backoffMs?5e3:Math.min(2*this.backoffMs,this.maxBackoffMs),void(this._lastBackoffStart=Date.now());if(this.backoffMs=0,i.ok&&this.callbackManager&&this.callbackManager.emit("allow",{action:"allow"}),i.ok)try{const e=await i.json();let t=e;this.encryptionRequired&&(t=await CryptoUtils.decrypt(e)),(null==t?void 0:t.nonce)&&(this.currentNonce=t.nonce),this.responseHandler&&this.responseHandler(t)}catch(t){}}catch(i){this.callbackManager&&this.callbackManager.emit("error",{code:"NETWORK_ERROR",message:"Failed to send security events"})}}catch(t){this.callbackManager&&this.callbackManager.emit("error",{code:"PAYLOAD_ERROR",message:"Failed to prepare security payload"})}finally{this.flushing=!1,this.pendingFlush&&(this.pendingFlush=!1,this.flush())}}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.flush()}startFlushInterval(){this.intervalId=setInterval(()=>{this.flush()},this.flushInterval)}}class BehaviorCollector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"isCollecting",!1),this.transmitter=e}start(){this.isCollecting||(this.isCollecting=!0)}stop(){this.isCollecting=!1}}class RapidClickDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"clickHistory",[]),__publicField(this,"THRESHOLD_COUNT",3),__publicField(this,"THRESHOLD_TIME",500),this.transmitter=e,this.init()}init(){document.addEventListener("click",e=>this.handleClick(e),!0)}handleClick(e){const t=Date.now();if(this.clickHistory.push(t),this.clickHistory=this.clickHistory.filter(e=>t-e<=this.THRESHOLD_TIME),this.clickHistory.length>=this.THRESHOLD_COUNT){const i=e.target,s={tagName:i.tagName,id:i.id,className:i.className,x:e.clientX,y:e.clientY};this.transmitter.send("rapid_click",{count:this.clickHistory.length,duration:this.THRESHOLD_TIME,target:s,timestamp:t}),this.clickHistory=[]}}}class Honeypot{constructor(e){__publicField(this,"transmitter"),__publicField(this,"element",null),this.transmitter=e}start(){this.element=document.createElement("input"),this.element.type="text";const e=["website","email_confirm","url","homepage","fax_number","address_line_2"],t=e[Math.floor(Math.random()*e.length)],i=Math.random().toString(36).substr(2,5);this.element.id="hp-"+Math.random().toString(36).substr(2,9),this.element.name=`${t}-${i}`,this.element.autocomplete="off",Object.assign(this.element.style,{position:"absolute",opacity:"0",top:"0",left:"-9999px",height:"1px",width:"1px",zIndex:"-1",border:"none"}),this.element.tabIndex=-1,this.element.setAttribute("aria-hidden","true"),this.element.setAttribute("role","presentation");const s=e=>{var t;this.transmitter.send("honeypot_triggered",{eventType:e.type,value:null==(t=this.element)?void 0:t.value,timestamp:Date.now()})};this.element.addEventListener("input",s),this.element.addEventListener("focus",s),this.element.addEventListener("click",s),document.body.appendChild(this.element)}stop(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class MouseTracker{constructor(e,t){__publicField(this,"transmitter"),__publicField(this,"wasmService"),__publicField(this,"buffer",[]),__publicField(this,"BUFFER_SIZE",50),__publicField(this,"SAMPLE_INTERVAL",100),__publicField(this,"SEND_COOLDOWN",5e3),__publicField(this,"lastSampleTime",0),__publicField(this,"lastSendTime",0),__publicField(this,"handleMouseMove",e=>{const t=Date.now();t-this.lastSampleTime<this.SAMPLE_INTERVAL||(this.lastSampleTime=t,this.buffer.push({x:e.clientX,y:e.clientY,time:t}),this.buffer.length>this.BUFFER_SIZE&&this.buffer.shift(),this.buffer.length>=this.BUFFER_SIZE&&t-this.lastSendTime>=this.SEND_COOLDOWN&&(this.analyze(),this.lastSendTime=t))}),this.transmitter=e,this.wasmService=t}start(){"undefined"!=typeof document&&document.addEventListener("mousemove",this.handleMouseMove)}stop(){"undefined"!=typeof document&&document.removeEventListener("mousemove",this.handleMouseMove)}analyze(){if(this.buffer.length<20)return;const e=this.wasmService.calculateEntropy(this.buffer),t=this.calculateSpeedVariance(),i=this.buffer.map(e=>({x:e.x,y:e.y,t:e.time}));this.transmitter.send("behavior_metrics",{entropy:e,speedVariance:t,sampleSize:this.buffer.length,timestamp:Date.now(),rawTrajectory:i})}calculateSpeedVariance(){const e=[];for(let i=1;i<this.buffer.length;i++){const t=this.buffer[i-1],s=this.buffer[i],n=Math.sqrt(Math.pow(s.x-t.x,2)+Math.pow(s.y-t.y,2)),a=s.time-t.time;a>0&&e.push(n/a)}if(e.length<2)return 1;const t=e.reduce((e,t)=>e+t,0)/e.length;return e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length}}class InputTracker{constructor(e){__publicField(this,"lastInteractionTime",0),__publicField(this,"lastInteractionType","none"),__publicField(this,"transmitter"),__publicField(this,"isMobile",!1),__publicField(this,"keyPressTimes",new Map),__publicField(this,"lastKeyUpTime",0),__publicField(this,"flightTimes",[]),__publicField(this,"dwellTimes",[]),__publicField(this,"suspiciousFocusCount",0),__publicField(this,"suspiciousFocusResetTimer",null),__publicField(this,"rawKeystrokes",[]),this.transmitter=e,this.isMobile=this.detectMobile()}start(){this.initListeners()}detectMobile(){return"undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0)}initListeners(){if("undefined"==typeof document)return;["mousedown","keydown","touchstart","touchend"].forEach(e=>{document.addEventListener(e,e=>{this.lastInteractionTime=Date.now(),this.lastInteractionType=e.type},{passive:!0,capture:!0})}),document.addEventListener("focus",e=>{const t=e.target;"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName||(this.checkFocusIntegrity(),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[],this.lastKeyUpTime=0)},{capture:!0}),document.addEventListener("keydown",e=>{const t=e.target;if("INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName)return;const i=Date.now();if(this.keyPressTimes.set(e.code,i),this.rawKeystrokes.push({code:e.code,t:i,type:"down"}),this.lastKeyUpTime>0){const e=i-this.lastKeyUpTime;e<2e3&&this.flightTimes.push(e)}},{passive:!0,capture:!0}),document.addEventListener("keyup",e=>{const t=e.target;if("INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName)return;const i=Date.now();this.lastKeyUpTime=i,this.rawKeystrokes.push({code:e.code,t:i,type:"up"});const s=this.keyPressTimes.get(e.code);if(s){const t=i-s;this.dwellTimes.push(t),this.keyPressTimes.delete(e.code)}this.flightTimes.length>=10&&this.reportKeystrokeDynamics(t)},{passive:!0,capture:!0}),document.addEventListener("blur",e=>{const t=e.target;("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&this.flightTimes.length>0&&this.reportKeystrokeDynamics(t)},{capture:!0})}checkFocusIntegrity(){const e=Date.now(),t=e-this.lastInteractionTime;performance.now()<5e3||(t>200?(this.suspiciousFocusCount++,clearTimeout(this.suspiciousFocusResetTimer),this.suspiciousFocusResetTimer=setTimeout(()=>{this.suspiciousFocusCount=0},3e3),this.transmitter.send("behavior_metrics",{type:"suspicious_focus",timeSinceInteraction:t,lastInteraction:this.lastInteractionType,consecutiveCount:this.suspiciousFocusCount,timestamp:e})):this.suspiciousFocusCount=0)}reportKeystrokeDynamics(e){const t=this.average(this.flightTimes),i=this.variance(this.flightTimes,t),s=this.average(this.dwellTimes),n=this.variance(this.dwellTimes,s);this.transmitter.send("input_metrics",{element:e.id||e.tagName,flight:{avg:t,variance:i,samples:this.flightTimes.length},dwell:{avg:s,variance:n},isMobile:this.isMobile,timestamp:Date.now(),rawKeystrokes:[...this.rawKeystrokes]}),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[]}average(e){return 0===e.length?0:e.reduce((e,t)=>e+t,0)/e.length}variance(e,t){return 0===e.length?0:e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length}}class WasmService{constructor(){__publicField(this,"wasmModule",null),__publicField(this,"memory",null),__publicField(this,"instance",null)}async load(e){try{const t=await fetch(`${e}/sdk/core.wasm`);if(!t.ok)throw new Error(`HTTP ${t.status}`);const i={env:{abort:()=>{}}};if(WebAssembly.instantiateStreaming){const e=await WebAssembly.instantiateStreaming(t,i);this.instance=e.instance}else{const e=await t.arrayBuffer(),s=await WebAssembly.instantiate(e,i);this.instance=s.instance}this.wasmModule=this.instance.exports,this.memory=this.wasmModule.memory}catch(t){}}isLoaded(){return!!this.instance}calculateEntropy(e){if(!this.instance||!this.wasmModule)return 0;const t=2*e.length,i=8*t;try{const s=this.wasmModule.__new(i,0),n=new Float64Array(this.memory.buffer,s,t);for(let t=0;t<e.length;t++)n[2*t]=e[t].x,n[2*t+1]=e[t].y;return this.wasmModule.calculateEntropy(s,t)}catch(s){return 0}}simpleHash(e){if(!this.instance||!this.wasmModule)return 0;try{const t=(new TextEncoder).encode(e),i=t.length,s=this.wasmModule.__new(i,0);return new Uint8Array(this.memory.buffer,s,i).set(t),this.wasmModule.simpleHash(s,i)}catch(t){return 0}}}class CanvasFingerprinter{constructor(e,t){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof document||setTimeout(async()=>{const e=await this.generateFingerprint(),t=this.collectWebGLFingerprint(),i=this.collectAudioFingerprint();this.transmitter.send("fingerprint_collected",{hash:e,webgl:t,audio:i}),this.hasRun=!0},500)}async generateFingerprint(){try{const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return"unknown";t.textBaseline="top",t.font='14px "Arial"',t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText("aientrophy Security 😃",2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText("aientrophy Security 😃",4,17),t.globalCompositeOperation="multiply",t.fillStyle="rgb(255,0,255)",t.beginPath(),t.arc(50,50,50,0,2*Math.PI,!0),t.closePath(),t.fill(),t.fillStyle="rgb(0,255,255)",t.beginPath(),t.arc(100,50,50,0,2*Math.PI,!0),t.closePath(),t.fill(),t.fillStyle="rgb(255,255,0)",t.beginPath(),t.arc(75,100,50,0,2*Math.PI,!0),t.closePath(),t.fill();const i=e.toDataURL();return await this.sha256(i)}catch(e){return"error"}}async sha256(e){const t=(new TextEncoder).encode(e),i=await window.crypto.subtle.digest("SHA-256",t),s=new Uint8Array(i);return Array.from(s).map(e=>e.toString(16).padStart(2,"0")).join("")}collectWebGLFingerprint(){try{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{available:!1};const i=t,s={available:!0},n=i.getExtension("WEBGL_debug_renderer_info");return n&&(s.renderer=i.getParameter(n.UNMASKED_RENDERER_WEBGL),s.vendor=i.getParameter(n.UNMASKED_VENDOR_WEBGL)),s.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),s.maxViewportDims=Array.from(i.getParameter(i.MAX_VIEWPORT_DIMS)),s.maxRenderbufferSize=i.getParameter(i.MAX_RENDERBUFFER_SIZE),s.maxVertexAttribs=i.getParameter(i.MAX_VERTEX_ATTRIBS),s.extensions=(i.getSupportedExtensions()||[]).length,s}catch(e){return{available:!1,error:!0}}}collectAudioFingerprint(){try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return{available:!1};const t=new e,i={available:!0,sampleRate:t.sampleRate,state:t.state,maxChannels:t.destination.maxChannelCount};return t.close(),i}catch(e){return{available:!1}}}}class ChallengeHandler{constructor(e){__publicField(this,"originalFetch"),__publicField(this,"endpoint"),__publicField(this,"callbackManager",null),__publicField(this,"challengeInProgress",null),this.endpoint=e,this.originalFetch=window.fetch.bind(window)}setCallbackManager(e){this.callbackManager=e}start(){window.fetch=async(e,t)=>{var i;const s=await this.originalFetch(e,t);if(403===s.status){const a=s.clone();try{const n=await a.json();if("challenge"===n.action&&"captcha"===(null==(i=n.metadata)?void 0:i.type)){const i={action:"challenge",score:n.score,metadata:n.metadata};if(this.callbackManager){if(await this.callbackManager.emitChallenge(i))return this.originalFetch(e,t)}this.challengeInProgress||(this.challengeInProgress=this.showCaptchaModal().finally(()=>{this.challengeInProgress=null}));return await this.challengeInProgress?this.originalFetch(e,t):s}"block"===n.action&&this.callbackManager&&this.callbackManager.emit("block",{action:"block",score:n.score,metadata:n.metadata})}catch(n){}}return s}}async showCaptchaModal(){return new Promise(e=>{const t=document.createElement("div");t.id="sec-sdk-challenge-host",t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100vw",t.style.height="100vh",t.style.zIndex="999999",t.style.backgroundColor="rgba(0,0,0,0.5)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";const i=t.attachShadow({mode:"open"}),s=document.createElement("div");s.style.background="white",s.style.padding="20px",s.style.borderRadius="8px",s.style.boxShadow="0 4px 12px rgba(0,0,0,0.2)",s.style.textAlign="center",s.style.fontFamily="system-ui, sans-serif";const n=document.createElement("h3");n.textContent="Security Check",n.style.margin="0 0 16px 0";const a=document.createElement("p");a.textContent="Unusual activity detected. Please verify you are human.",a.style.marginBottom="16px",a.style.fontSize="14px",a.style.color="#666";const r=document.createElement("div");r.innerHTML="Loading...",r.style.marginBottom="16px";const o=document.createElement("input");o.type="text",o.placeholder="Enter details",o.style.padding="8px",o.style.marginRight="8px",o.style.border="1px solid #ddd",o.style.borderRadius="4px";const c=document.createElement("button");c.textContent="Verify",c.style.padding="8px 16px",c.style.background="#007bff",c.style.color="white",c.style.border="none",c.style.borderRadius="4px",c.style.cursor="pointer";const l=document.createElement("p");l.style.color="red",l.style.fontSize="12px",l.style.display="none",s.appendChild(n),s.appendChild(a),s.appendChild(r),s.appendChild(o),s.appendChild(c),s.appendChild(l),i.appendChild(s),document.body.appendChild(t);let h="";const u=async()=>{try{const e=await this.originalFetch(`${this.endpoint}/challenge`),t=await e.json();h=t.id,r.innerHTML=t.svg}catch(e){r.textContent="Error loading CAPTCHA"}},d=async()=>{l.style.display="none",c.textContent="Verifying...";try{const i=o.value,s=await this.originalFetch(`${this.endpoint}/challenge/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:h,answer:i})});(await s.json()).success?(document.body.removeChild(t),e(!0)):(l.textContent="Incorrect, try again.",l.style.display="block",c.textContent="Verify",o.value="",u())}catch(i){l.textContent="System error.",l.style.display="block",c.textContent="Verify"}};c.onclick=d,o.onkeydown=e=>{"Enter"===e.key&&d()},u()})}}class InvisibleInteraction{constructor(e){__publicField(this,"transmitter"),__publicField(this,"eventsToWatch",["click","mousedown","keydown","touchstart","focus"]),__publicField(this,"handleEvent",e=>{const t=e.target;if(!(t&&t instanceof HTMLElement))return;if(t===document.body||t===document.documentElement)return;const i=this.checkVisibility(t,e);if(i){const s=t.getBoundingClientRect();this.transmitter.send("invisible_interaction",{type:e.type,target:t.tagName,id:t.id,reason:i,timestamp:Date.now(),isTrusted:e.isTrusted,coordinates:{x:e instanceof MouseEvent?e.clientX:0,y:e instanceof MouseEvent?e.clientY:0},viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{x:window.scrollX,y:window.scrollY},docDim:{width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight},elementRect:{top:s.top,left:s.left,width:s.width,height:s.height}})}}),this.transmitter=e}start(){this.eventsToWatch.forEach(e=>{document.addEventListener(e,this.handleEvent,{capture:!0,passive:!0})})}stop(){this.eventsToWatch.forEach(e=>{document.removeEventListener(e,this.handleEvent,{capture:!0})})}checkVisibility(e,t){var i,s;const n=window.getComputedStyle(e);if("none"===n.display)return"display:none";if("hidden"===n.visibility)return"visibility:hidden";if("0"===n.opacity)return"opacity:0";const a=e.getBoundingClientRect();if(a.width<=0||a.height<=0)return"zero_size";const r=a.right<0||a.left>window.innerWidth,o=a.bottom<0||a.top>window.innerHeight;if(r||o)return"off_screen";if(t instanceof MouseEvent||t instanceof TouchEvent){let n,a;if(t instanceof MouseEvent?(n=t.clientX,a=t.clientY):(n=(null==(i=t.touches[0])?void 0:i.clientX)||0,a=(null==(s=t.touches[0])?void 0:s.clientY)||0),n>=0&&n<=window.innerWidth&&a>=0&&a<=window.innerHeight){const i=document.elementFromPoint(n,a);if(i&&i!==e&&!e.contains(i)&&!i.contains(e)&&0===n&&0===a&&t.isTrusted)return null}}return null}}class AutomationDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(setTimeout(()=>this.detect(),1500),this.hasRun=!0)}detect(){var e,t;const i={};let s=0;!0===navigator.webdriver&&(i.webdriver=!0,s+=40);try{this.detectCDP()&&(i.cdp=!0,s+=50)}catch(c){}const n=this.detectAutomationGlobals();n.length>0&&(i.automationGlobals=n,s+=30);const a=this.checkWebGL();a.suspicious&&(i.webgl=a,s+=25);const r=this.checkInconsistencies();r.length>0&&(i.inconsistencies=r,s+=15);const o=this.checkHeadless();o.score>0&&(i.headless=o.flags,s+=o.score),s>0&&this.transmitter.send("automation_detected",{signals:i,score:s,timestamp:Date.now()}),this.transmitter.send("init_signals",{webdriver:!!navigator.webdriver,plugins:(null==(e=navigator.plugins)?void 0:e.length)??0,languages:(null==(t=navigator.languages)?void 0:t.length)??0,platform:navigator.platform,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory,maxTouchPoints:navigator.maxTouchPoints,webglRenderer:a.renderer,webglVendor:a.vendor,timestamp:Date.now()})}detectCDP(){const e=console.debug;return console.debug=e,!1}detectAutomationGlobals(){const e=[],t=[["selenium",()=>!!window._selenium],["selenium_unwrapped",()=>!!document.__selenium_unwrapped],["driver_evaluate",()=>!!document.__driver_evaluate],["webdriver_evaluate",()=>!!document.__webdriver_evaluate],["driver_unwrapped",()=>!!document.__driver_unwrapped],["fxdriver",()=>!!document.__fxdriver_evaluate],["playwright",()=>!!window.__playwright],["playwright_binding",()=>!!window.__playwright__binding__],["pwInitScripts",()=>!!window.__pwInitScripts],["puppeteer",()=>!!window.__puppeteer_evaluation_script__],["phantom",()=>!!window.callPhantom||!!window._phantom],["nightmare",()=>!!window.__nightmare],["cdc",()=>Object.keys(document).some(e=>e.startsWith("cdc_")||e.startsWith("$cdc_"))]];for(const[s,n]of t)try{n()&&e.push(s)}catch(i){}return e}checkWebGL(){try{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{suspicious:!1,renderer:"unavailable",vendor:"unavailable"};const i=t.getExtension("WEBGL_debug_renderer_info");if(!i)return{suspicious:!1,renderer:"no_debug_info",vendor:"no_debug_info"};const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",n=t.getParameter(i.UNMASKED_VENDOR_WEBGL)||"";return{suspicious:/SwiftShader/i.test(s)||/Mesa OffScreen/i.test(s)||/llvmpipe/i.test(s),renderer:s,vendor:n}}catch(e){return{suspicious:!1,renderer:"error",vendor:"error"}}}checkInconsistencies(){const e=[];try{const t=navigator.userAgent,i=navigator.platform;/Windows/.test(t)&&/Mac/.test(i)&&e.push("ua_platform_mismatch_win_mac"),/Macintosh/.test(t)&&/Win/.test(i)&&e.push("ua_platform_mismatch_mac_win"),/Mobile|Android|iPhone/.test(t)&&0===navigator.maxTouchPoints&&e.push("mobile_ua_no_touch"),/Chrome/.test(t)&&navigator.plugins&&0===navigator.plugins.length&&e.push("chrome_no_plugins"),navigator.languages&&0!==navigator.languages.length||e.push("no_languages")}catch(t){}return e}checkHeadless(){const e=[];let t=0;try{if(/HeadlessChrome/.test(navigator.userAgent)&&(e.push("headless_ua"),t+=40),/Chrome/.test(navigator.userAgent)&&!window.chrome&&(e.push("chrome_ua_no_chrome_obj"),t+=15),window.screen&&800===window.screen.width&&600===window.screen.height&&(e.push("default_screen_size"),t+=10),"Notification"in window){"denied"===window.Notification.permission&&navigator.userAgent.includes("Chrome")&&(e.push("notification_denied_default"),t+=5)}const i=navigator.connection;i&&0===i.rtt&&(e.push("zero_rtt"),t+=10)}catch(i){}return{score:t,flags:e}}}class SessionAnalyzer{constructor(e){__publicField(this,"transmitter"),__publicField(this,"sessionStart",0),__publicField(this,"pageTransitions",[]),__publicField(this,"interactionTimestamps",[]),__publicField(this,"lastPageUrl",""),__publicField(this,"formStartTimes",new Map),__publicField(this,"reportInterval",null),this.transmitter=e}start(){if("undefined"==typeof window)return;this.sessionStart=Date.now(),this.lastPageUrl=window.location.href;["mousedown","keydown","touchstart","scroll"].forEach(e=>{document.addEventListener(e,()=>{this.interactionTimestamps.push(Date.now()),this.interactionTimestamps.length>500&&this.interactionTimestamps.shift()},{passive:!0,capture:!0})}),this.observeNavigation(),this.observeForms(),this.reportInterval=setInterval(()=>this.report(),15e3)}observeNavigation(){const e=history.pushState,t=history.replaceState,i=this;history.pushState=function(t,s,n){e.call(this,t,s,n),i.onPageTransition()},history.replaceState=function(e,s,n){t.call(this,e,s,n),i.onPageTransition()},window.addEventListener("popstate",()=>this.onPageTransition())}onPageTransition(){const e=Date.now(),t=window.location.href;t!==this.lastPageUrl&&(this.pageTransitions.push(e),this.lastPageUrl=t)}observeForms(){document.addEventListener("focus",e=>{const t=e.target;if("INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName){const e=t.closest("form"),i=(null==e?void 0:e.id)||(null==e?void 0:e.action)||"anonymous_form";this.formStartTimes.has(i)||this.formStartTimes.set(i,Date.now())}},{capture:!0}),document.addEventListener("submit",e=>{const t=e.target,i=t.id||t.action||"anonymous_form",s=this.formStartTimes.get(i);if(s){const e=Date.now()-s;this.transmitter.send("session_metrics",{type:"form_completion",formId:i,duration:e,timestamp:Date.now()}),this.formStartTimes.delete(i)}},{capture:!0})}report(){const e=Date.now(),t=e-this.sessionStart;if(this.interactionTimestamps.length<10)return;const i=this.calculateIntervals(this.interactionTimestamps),s=this.analyzeTimingDistribution(i),n=this.analyzePageTransitions();this.transmitter.send("session_metrics",{type:"session_analysis",sessionDuration:t,totalInteractions:this.interactionTimestamps.length,pageTransitions:this.pageTransitions.length,timing:s,pages:n,timestamp:e})}calculateIntervals(e){const t=[];for(let i=1;i<e.length;i++)t.push(e[i]-e[i-1]);return t}analyzeTimingDistribution(e){if(e.length<5)return{samples:e.length};const t=e.reduce((e,t)=>e+t,0)/e.length,i=e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length,s=Math.sqrt(i),n=t>0?s/t:0,a=this.shannonEntropy(e,50),r=this.autocorrelation(e);return{mean:Math.round(t),stdDev:Math.round(s),cv:parseFloat(n.toFixed(4)),entropy:parseFloat(a.toFixed(4)),autocorrelation:parseFloat(r.toFixed(4)),samples:e.length}}analyzePageTransitions(){if(this.pageTransitions.length<2)return{count:this.pageTransitions.length};const e=this.calculateIntervals(this.pageTransitions),t=e.reduce((e,t)=>e+t,0)/e.length,i=e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length,s=t>0?Math.sqrt(i)/t:0;return{count:this.pageTransitions.length,avgInterval:Math.round(t),cv:parseFloat(s.toFixed(4))}}shannonEntropy(e,t){const i=new Map;for(const a of e){const e=Math.floor(a/t);i.set(e,(i.get(e)||0)+1)}const s=e.length;let n=0;for(const a of i.values()){const e=a/s;e>0&&(n-=e*Math.log2(e))}return n}autocorrelation(e){if(e.length<3)return 0;const t=e.reduce((e,t)=>e+t,0)/e.length;let i=0,s=0;for(let n=0;n<e.length-1;n++)i+=(e[n]-t)*(e[n+1]-t);for(let n=0;n<e.length;n++)s+=Math.pow(e[n]-t,2);return 0===s?0:i/s}}class TabNavigationAnalyzer{constructor(e){__publicField(this,"transmitter"),__publicField(this,"tabTimestamps",[]),__publicField(this,"shiftTabCount",0),__publicField(this,"tabCount",0),__publicField(this,"isShiftDown",!1),__publicField(this,"BURST_THRESHOLD_MS",80),__publicField(this,"reportInterval",null),__publicField(this,"REPORT_INTERVAL_MS",1e4),__publicField(this,"MIN_TABS_TO_REPORT",5),__publicField(this,"TAB_TRIGGER_COUNT",20),__publicField(this,"onKeyDown",e=>{if("Shift"!==e.key){if("Tab"===e.key){const e=Date.now();this.isShiftDown?this.shiftTabCount++:(this.tabCount++,this.tabTimestamps.push(e),this.tabTimestamps.length>100&&this.tabTimestamps.shift()),this.tabCount+this.shiftTabCount>=this.TAB_TRIGGER_COUNT&&this.report()}}else this.isShiftDown=!0}),__publicField(this,"onKeyUp",e=>{"Shift"===e.key&&(this.isShiftDown=!1)}),this.transmitter=e}start(){"undefined"!=typeof document&&(document.addEventListener("keydown",this.onKeyDown,{passive:!0,capture:!0}),document.addEventListener("keyup",this.onKeyUp,{passive:!0,capture:!0}),this.reportInterval=setInterval(()=>this.report(),this.REPORT_INTERVAL_MS))}stop(){"undefined"!=typeof document&&(document.removeEventListener("keydown",this.onKeyDown,{capture:!0}),document.removeEventListener("keyup",this.onKeyUp,{capture:!0}),this.reportInterval&&(clearInterval(this.reportInterval),this.reportInterval=null),this.report())}report(){const e=this.tabCount+this.shiftTabCount;if(e<this.MIN_TABS_TO_REPORT)return;const t=this.calculateIntervals(this.tabTimestamps);if(t.length<3)return void this.resetBuffers();const i=this.analyzeIntervals(t),s=this.analyzeBursts(t),n=e>0?this.shiftTabCount/e:0;this.transmitter.send("tab_navigation_metrics",{tabCount:this.tabCount,shiftTabCount:this.shiftTabCount,shiftTabRatio:parseFloat(n.toFixed(4)),intervals:i,bursts:s,timestamp:Date.now()}),this.resetBuffers()}resetBuffers(){this.tabTimestamps=[],this.tabCount=0,this.shiftTabCount=0}calculateIntervals(e){const t=[];for(let i=1;i<e.length;i++){const s=e[i]-e[i-1];s<5e3&&t.push(s)}return t}analyzeIntervals(e){if(0===e.length)return{avg:0,variance:0,cv:0,min:0,samples:0};const t=e.reduce((e,t)=>e+t,0)/e.length,i=e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length,s=Math.sqrt(i),n=t>0?s/t:0,a=Math.min(...e);return{avg:parseFloat(t.toFixed(2)),variance:parseFloat(i.toFixed(2)),cv:parseFloat(n.toFixed(4)),min:a,samples:e.length}}analyzeBursts(e){let t=0,i=0,s=0,n=0,a=0;for(const r of e)r<this.BURST_THRESHOLD_MS?(i++,n+=r,a++):(i>=3&&(t++,s+=i),i=0);return i>=3&&(t++,s+=i),{count:t,avgLength:t>0?parseFloat((s/t).toFixed(1)):0,avgInterval:a>0?parseFloat((n/a).toFixed(2)):0}}}class CloudEnvironmentDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){try{const e=this.analyzeGPU(),t=this.analyzeHardware(),i=this.analyzeScreen(),s=await this.analyzeMedia(),n=this.benchmarkCanvas();let a=0;"virtual_gpu"!==e.category&&"software_render"!==e.category&&"cloud_gpu"!==e.category||(a+=2),t.cores<=2&&a++,null!==t.memory&&t.memory<=2&&a++,24===t.colorDepth&&a++,1===t.pixelRatio&&a++,i.noTaskbar&&a++,i.isVMResolution&&a++,0===s.cameras&&0===s.microphones&&a++,s.hasBluetooth||s.hasUSB||a++,n.canvasRenderTime>50&&a++;const{classification:r,confidence:o}=this.classify(e,t,a);this.transmitter.send("cloud_environment",{classification:r,confidence:o,signals:{gpu:{renderer:e.renderer,vendor:e.vendor,category:e.category},hardware:t,screen:i,media:s,performance:n},vmIndicatorCount:a,timestamp:Date.now()})}catch(e){}}analyzeGPU(){try{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{renderer:"unavailable",vendor:"unavailable",category:"unknown"};const i=t.getExtension("WEBGL_debug_renderer_info");if(!i)return{renderer:"no_debug_info",vendor:"no_debug_info",category:"unknown"};const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",n=t.getParameter(i.UNMASKED_VENDOR_WEBGL)||"";return{renderer:s,vendor:n,category:this.categorizeGPU(s,n)}}catch(e){return{renderer:"error",vendor:"error",category:"unknown"}}}categorizeGPU(e,t){const i=e.toLowerCase(),s=t.toLowerCase();return/swiftshader|llvmpipe|mesa offscreen|softpipe/.test(i)?"software_render":/svga3d|svga|vmware/.test(i)||/virtualbox/.test(i)||/parallels/.test(i)||/qxl|virtio|red hat|spice/.test(i)||/hyper-v|microsoft basic render/i.test(i)||/citrix/.test(i)?"virtual_gpu":/amazon|elastic|aws/.test(i)||/amazon|elastic|aws/.test(s)||/google cloud|gce/.test(i)||/google cloud|gce/.test(s)||/azure/.test(i)||/azure/.test(s)?"cloud_gpu":"physical"}analyzeHardware(){return{cores:navigator.hardwareConcurrency||0,memory:navigator.deviceMemory??null,colorDepth:screen.colorDepth,pixelRatio:window.devicePixelRatio||1}}analyzeScreen(){const e=screen.width,t=screen.height,i=screen.availHeight,s=t===i&&t===window.innerHeight,n=[[800,600],[1024,768],[1280,1024],[1280,800],[1920,1080]].some(([i,s])=>e===i&&t===s&&!(1920===i&&1080===s));return{width:e,height:t,availHeight:i,noTaskbar:s,isVMResolution:n}}async analyzeMedia(){let e=-1,t=-1;try{if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices){const i=await navigator.mediaDevices.enumerateDevices();e=i.filter(e=>"videoinput"===e.kind).length,t=i.filter(e=>"audioinput"===e.kind).length}}catch(a){}const i=!!navigator.bluetooth,s=!!navigator.usb;let n=null;try{if(navigator.getBattery){const e=await navigator.getBattery();n=!(e.charging&&1===e.level&&0===e.chargingTime)}}catch(a){}return{cameras:e,microphones:t,hasBluetooth:i,hasUSB:s,hasBattery:n}}benchmarkCanvas(){try{const e=document.createElement("canvas");e.width=200,e.height=200;const t=e.getContext("2d");if(!t)return{canvasRenderTime:-1};const i=performance.now();for(let n=0;n<500;n++)t.fillStyle=`rgb(${n%256},${3*n%256},${7*n%256})`,t.fillRect(13*n%200,7*n%200,10,10);t.getImageData(0,0,1,1);const s=performance.now()-i;return{canvasRenderTime:Math.round(100*s)/100}}catch(e){return{canvasRenderTime:-1}}}classify(e,t,i){return"virtual_gpu"===e.category?24===t.colorDepth?{classification:"rdp_likely",confidence:.85}:{classification:"vm_detected",confidence:.95}:"cloud_gpu"===e.category?{classification:"cloud_likely",confidence:.9}:"software_render"===e.category?{classification:"vm_detected",confidence:.9}:i>=5?{classification:"vm_likely",confidence:.8}:i>=3?{classification:"vm_likely",confidence:.6}:{classification:"physical",confidence:1-.1*i}}}class CrossContextDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2500))}async detect(){var e,t;const i={};let s=0;const n={webdriver:!!navigator.webdriver,languages:(null==(e=navigator.languages)?void 0:e.join(","))||"",platform:navigator.platform||"",hardwareConcurrency:navigator.hardwareConcurrency||0,userAgent:navigator.userAgent||"",pluginsLength:(null==(t=navigator.plugins)?void 0:t.length)??0},a=this.checkIframe(n);a.score>0&&(i.iframe=a.mismatches,s+=a.score);try{const e=await this.checkWorker(n);e.score>0&&(i.worker=e.mismatches,s+=e.score)}catch(r){}s>0&&this.transmitter.send("cross_context_mismatch",{signals:i,score:s,timestamp:Date.now()})}checkIframe(e){var t,i;const s=[];let n=0;try{const a=document.createElement("iframe");a.style.display="none",a.sandbox="allow-same-origin",document.body.appendChild(a);const r=a.contentWindow;if(!r)return document.body.removeChild(a),{score:0,mismatches:[]};const o=r.navigator;o.webdriver!==navigator.webdriver&&(s.push("webdriver_mismatch"),n+=40),navigator.webdriver||!0!==o.webdriver||(s.push("webdriver_spoofed_in_main"),n+=30);((null==(t=o.languages)?void 0:t.join(","))||"")!==e.languages&&(s.push("languages_mismatch"),n+=15),o.platform!==e.platform&&(s.push("platform_mismatch"),n+=15);((null==(i=o.plugins)?void 0:i.length)??0)!==e.pluginsLength&&(s.push("plugins_mismatch"),n+=10),document.body.removeChild(a)}catch(a){}return{score:n,mismatches:s}}checkWorker(e){return new Promise(t=>{try{const i=new Blob(["\n self.onmessage = function() {\n var nav = self.navigator;\n self.postMessage({\n webdriver: !!nav.webdriver,\n languages: (nav.languages || []).join(','),\n platform: nav.platform || '',\n hardwareConcurrency: nav.hardwareConcurrency || 0,\n userAgent: nav.userAgent || ''\n });\n };\n "],{type:"application/javascript"}),s=URL.createObjectURL(i),n=new Worker(s),a=setTimeout(()=>{n.terminate(),URL.revokeObjectURL(s),t({score:0,mismatches:[]})},3e3);n.onmessage=i=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(s);const r=i.data,o=[];let c=0;r.webdriver!==e.webdriver&&(o.push("worker_webdriver_mismatch"),c+=35),r.languages!==e.languages&&(o.push("worker_languages_mismatch"),c+=15),r.platform!==e.platform&&(o.push("worker_platform_mismatch"),c+=15),r.hardwareConcurrency!==e.hardwareConcurrency&&(o.push("worker_concurrency_mismatch"),c+=10),r.userAgent!==e.userAgent&&(o.push("worker_ua_mismatch"),c+=20),t({score:c,mismatches:o})},n.onerror=()=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(s),t({score:0,mismatches:[]})},n.postMessage("check")}catch(i){t({score:0,mismatches:[]})}})}}class HeadlessProbeDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){const e={};let t=0;const i=await this.checkBrokenImage();i.suspicious&&(e.brokenImage=i,t+=25);const s=await this.checkClientHints();s.suspicious&&(e.clientHints=s,t+=20);const n=this.checkCDPMouseSignature();n.suspicious&&(e.cdpMouse=n,t+=30);const a=this.checkHairlineSupport();a.suspicious&&(e.hairline=a,t+=10);const r=this.checkExtraFrameworks();r.length>0&&(e.extraFrameworks=r,t+=20);(await this.checkWorkerCDP()).suspicious&&(e.workerCDP=!0,t+=35),t>0&&this.transmitter.send("headless_probe",{signals:e,score:t,timestamp:Date.now()})}checkBrokenImage(){return new Promise(e=>{try{const t=document.createElement("img");t.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==___invalid";const i=setTimeout(()=>{e({suspicious:!1,width:-1,height:-1})},2e3);t.onerror=()=>{clearTimeout(i);const s=t.width,n=t.height;e({suspicious:0===s&&0===n,width:s,height:n})},t.onload=()=>{clearTimeout(i),e({suspicious:!1,width:t.width,height:t.height})},t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),setTimeout(()=>{try{document.body.removeChild(t)}catch(e){}},100)}catch(t){e({suspicious:!1,width:-1,height:-1})}})}async checkClientHints(){const e=[];try{const t=navigator.userAgentData;if(!t)return{suspicious:!1,mismatches:[]};const i=navigator.userAgent,s=(t.brands||[]).map(e=>e.brand);/Chrome\/\d/.test(i)&&!s.some(e=>/Chromium|Google Chrome|Chrome/.test(e))&&e.push("ua_chrome_no_brand"),t.platform&&(/Windows/.test(i)&&"Windows"!==t.platform&&e.push("ua_windows_brand_mismatch"),/Macintosh/.test(i)&&"macOS"!==t.platform&&e.push("ua_mac_brand_mismatch"),/Linux/.test(i)&&!/Linux|Android|ChromeOS/.test(t.platform)&&e.push("ua_linux_brand_mismatch")),/Mobile/.test(i)&&!1===t.mobile&&e.push("ua_mobile_brand_mismatch")}catch(t){}return{suspicious:e.length>0,mismatches:e}}checkCDPMouseSignature(){let e=0,t=0,i=!1;try{const s=[],n=i=>{s.push(i),t++,0===i.movementX&&0===i.movementY&&e++};document.addEventListener("mousemove",n,{passive:!0}),setTimeout(()=>{document.removeEventListener("mousemove",n)},5e3),t>10&&e/t>.9&&(i=!0)}catch(s){}return{suspicious:i,zeroMovementCount:e,totalEvents:t}}checkHairlineSupport(){try{const e=document.createElement("div");e.style.border=".5px solid transparent",e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e);const t=e.offsetHeight;return document.body.removeChild(e),{suspicious:0===t,offsetHeight:t}}catch(e){return{suspicious:!1,offsetHeight:-1}}}checkExtraFrameworks(){const e=[];try{const i=window.external;if(i&&"function"==typeof i.toString)try{const t=i.toString();/Sequentum/i.test(t)&&e.push("sequentum")}catch(t){}const s=["__webdriver_script_fn","__webdriver_script_func","__webdriver_evaluate","__selenium_evaluate","__fxdriver_evaluate","__driver_evaluate","__webdriver_unwrapped","__selenium_unwrapped","__fxdriver_unwrapped","__driver_unwrapped","_Selenium_IDE_Recorder","_selenium","calledSelenium","_WEBDRIVER_ELEM_CACHE","ChromeDriverw","driver-hierarchical","__$webdriverAsyncExecutor","__lastWatirAlert","__lastWatirConfirm","__lastWatirPrompt","_WEBDRIVER_ELEM_CACHE","webdriver","_phantom","__nightmare","_selenium"];for(const t of s)(t in document||t in window)&&e.push(`global_${t}`);const n=Object.getOwnPropertyNames(navigator);for(const t of n)/webdriver|selenium|puppeteer|playwright|phantom/i.test(t)&&e.push(`nav_${t}`)}catch(t){}return e}checkWorkerCDP(){return new Promise(e=>{try{const t=new Blob(["\n self.onmessage = function() {\n var detected = false;\n try {\n var marker = {};\n Object.defineProperty(marker, 'stack', {\n get: function() { detected = true; return ''; }\n });\n console.debug(marker);\n } catch(e) {}\n self.postMessage({ cdp: detected });\n };\n "],{type:"application/javascript"}),i=URL.createObjectURL(t),s=new Worker(i),n=setTimeout(()=>{s.terminate(),URL.revokeObjectURL(i),e({suspicious:!1})},3e3);s.onmessage=t=>{clearTimeout(n),s.terminate(),URL.revokeObjectURL(i),e({suspicious:!0===t.data.cdp})},s.onerror=()=>{clearTimeout(n),s.terminate(),URL.revokeObjectURL(i),e({suspicious:!1})},s.postMessage("check")}catch(t){e({suspicious:!1})}})}}class CrawlProtect{constructor(e){__publicField(this,"config"),__publicField(this,"renewTimer",null),__publicField(this,"verified",!1),this.config=e}async start(){const e=this.getToken();if(e&&!this.isExpired(e))return this.verified=!0,this.scheduleRenewal(e),this.revealContent(),this.config.debug,!0;this.hideContent();const t=await this.solveChallenge();return t?(this.verified=!0,this.revealContent()):this.config.insertHoneypot&&this.insertHoneypotData(),t}isVerified(){return this.verified}stop(){this.renewTimer&&(clearTimeout(this.renewTimer),this.renewTimer=null)}async solveChallenge(){try{const e=await fetch(`${this.config.apiBase}/crawl-protect/challenge`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId}});if(!e.ok)return!1;const{id:t,challenges:i}=await e.json(),s=[];for(const c of i)if("math"===c.type){const e="add"===c.op?c.a+c.b:c.a*c.b;s.push(String(e))}else if("crypto"===c.type){const e=await this.sha256(c.nonce);s.push(e.slice(0,8))}const n=s.join(":"),a=await this.getFingerprint(),r=await fetch(`${this.config.apiBase}/crawl-protect/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId},body:JSON.stringify({id:t,solution:n,fingerprint:a}),credentials:"include"});if(!r.ok)return!1;const o=await r.json();return!(!o.success||!o.token)&&(this.setToken(o.token),this.scheduleRenewal(o.token),this.config.debug,!0)}catch(e){return this.config.debug,!1}}hideContent(){var e;if(null==(e=this.config.protectSelectors)?void 0:e.length)for(const t of this.config.protectSelectors){document.querySelectorAll(t).forEach(e=>{e.dataset.aieOrigDisplay=e.style.display,e.style.display="none"})}}revealContent(){var e;if(null==(e=this.config.protectSelectors)?void 0:e.length)for(const t of this.config.protectSelectors){document.querySelectorAll(t).forEach(e=>{e.style.display=e.dataset.aieOrigDisplay||"",delete e.dataset.aieOrigDisplay})}}insertHoneypotData(){const e=document.createElement("div");e.style.cssText="position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;",e.setAttribute("aria-hidden","true"),e.innerHTML='\n <span class="price" data-aie-honeypot="1">₩999,999,999</span>\n <span class="stock" data-aie-honeypot="1">재고: 0개</span>\n <a href="mailto:honeypot@aientrophy.com" data-aie-honeypot="1">contact</a>\n ',document.body.appendChild(e)}getToken(){const e=document.cookie.match(new RegExp("(?:^|; )__aie_token=([^;]*)"));return e?decodeURIComponent(e[1]):null}setToken(e){const t=new Date(Date.now()+18e5).toUTCString();document.cookie=`__aie_token=${encodeURIComponent(e)};path=/;expires=${t};SameSite=None;Secure`}isExpired(e){try{const[t]=e.split("."),i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));return Date.now()>i.exp}catch{return!0}}scheduleRenewal(e){try{const[t]=e.split("."),i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/"))),s=i.exp-3e5-Date.now();s>0&&(this.renewTimer=setTimeout(()=>this.solveChallenge(),s))}catch{}}async sha256(e){const t=new TextEncoder,i=await crypto.subtle.digest("SHA-256",t.encode(e));return Array.from(new Uint8Array(i)).map(e=>e.toString(16).padStart(2,"0")).join("")}async getFingerprint(){const e=[navigator.userAgent,navigator.language,screen.width+"x"+screen.height,Intl.DateTimeFormat().resolvedOptions().timeZone];return this.sha256(e.join("|"))}}const securitySDK=new class{constructor(){__publicField(this,"transmitter"),__publicField(this,"behaviorCollector"),__publicField(this,"rapidClickDetector"),__publicField(this,"honeypot"),__publicField(this,"mouseTracker"),__publicField(this,"canvasFingerprinter"),__publicField(this,"inputTracker"),__publicField(this,"challengeHandler"),__publicField(this,"invisibleInteraction"),__publicField(this,"automationDetector"),__publicField(this,"sessionAnalyzer"),__publicField(this,"tabNavigationAnalyzer"),__publicField(this,"cloudEnvironmentDetector"),__publicField(this,"crossContextDetector"),__publicField(this,"headlessProbeDetector"),__publicField(this,"crawlProtect",null),__publicField(this,"initialized",!1),__publicField(this,"wasmService"),__publicField(this,"callbackManager"),this.transmitter=new Transmitter,this.wasmService=new WasmService,this.callbackManager=new CallbackManager,this.transmitter.setCallbackManager(this.callbackManager),this.behaviorCollector=new BehaviorCollector(this.transmitter),this.rapidClickDetector=new RapidClickDetector(this.transmitter),this.honeypot=new Honeypot(this.transmitter),this.mouseTracker=new MouseTracker(this.transmitter,this.wasmService),this.canvasFingerprinter=new CanvasFingerprinter(this.transmitter,this.wasmService),this.inputTracker=new InputTracker(this.transmitter),this.invisibleInteraction=new InvisibleInteraction(this.transmitter),this.automationDetector=new AutomationDetector(this.transmitter),this.sessionAnalyzer=new SessionAnalyzer(this.transmitter),this.tabNavigationAnalyzer=new TabNavigationAnalyzer(this.transmitter),this.cloudEnvironmentDetector=new CloudEnvironmentDetector(this.transmitter),this.crossContextDetector=new CrossContextDetector(this.transmitter),this.headlessProbeDetector=new HeadlessProbeDetector(this.transmitter)}async init(e){var t,i;if(this.initialized)return;e.callbacks&&this.callbackManager.setConfigCallbacks(e.callbacks);const s=e.endpoint.replace(/\/events$/,"");try{await this.wasmService.load(s),this.startDetectors(),this.transmitter.setConfig(e),this.challengeHandler=new ChallengeHandler(s),this.challengeHandler.setCallbackManager(this.callbackManager),!1!==(null==(t=e.serverConfig)?void 0:t.captchaEnabled)&&this.challengeHandler.start();((null==(i=e.serverConfig)?void 0:i.devtoolsDetection)??!e.debug)&&Promise.resolve().then(()=>require("../anti-debug-CYwG4s7P.cjs")).then(({AntiDebug:e})=>{e.start(),Promise.resolve().then(()=>require("../console-aIpHQlgP.cjs")).then(({ConsoleDetector:e})=>{new e(()=>{this.transmitter.send("devtools_open",{detected:!0})}).start()})}),e.crawlProtect&&(this.crawlProtect=new CrawlProtect({apiBase:s,clientId:e.clientKey,protectSelectors:e.crawlProtect.protectSelectors,insertHoneypot:e.crawlProtect.insertHoneypot,debug:e.debug}),this.crawlProtect.start().catch(t=>{e.debug})),this.initialized=!0,e.debug,this.callbackManager.emit("ready")}catch(n){this.callbackManager.emit("error",{code:"INIT_ERROR",message:"SecuritySDK initialization failed",details:null==n?void 0:n.message})}}on(e,t){this.callbackManager.on(e,t)}off(e,t){this.callbackManager.off(e,t)}once(e,t){this.callbackManager.once(e,t)}startDetectors(){this.behaviorCollector.start(),this.honeypot.start(),this.mouseTracker.start(),this.canvasFingerprinter.start(),this.inputTracker.start(),this.invisibleInteraction.start(),this.automationDetector.start(),this.sessionAnalyzer.start(),this.tabNavigationAnalyzer.start(),this.cloudEnvironmentDetector.start(),this.crossContextDetector.start(),this.headlessProbeDetector.start()}};"undefined"!=typeof window&&(window.SecuritySDK=securitySDK);exports.Aientrophy=class{constructor(e){__publicField(this,"config"),this.config=e}async protect(){const e=this.config.endpoint||"https://api.aientrophy.com/api/v1/events";let t={};try{const s=e.replace(/\/events$/,""),n=await fetch(`${s}/sdk/payload?clientKey=${encodeURIComponent(this.config.clientKey)}`);if(n.ok){t=(await n.json()).config||{}}if(t.nonceValidation)try{const e=await fetch(`${s}/sdk/nonce?clientKey=${encodeURIComponent(this.config.clientKey)}`);if(e.ok){const i=await e.json();i.nonce&&(t.initialNonce=i.nonce)}}catch(i){this.config.debug}}catch(i){this.config.debug}await securitySDK.init({endpoint:e,clientKey:this.config.clientKey,debug:this.config.debug,callbacks:this.config.callbacks,crawlProtect:this.config.crawlProtect,serverConfig:t})}on(e,t){securitySDK.on(e,t)}off(e,t){securitySDK.off(e,t)}once(e,t){securitySDK.once(e,t)}};
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__publicField=(e,t,i)=>((e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const CONFIG_RSA_PUBLIC_KEY="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqbBCvDqyUtfhgI/Lo5pDtn1phwA6qczAyp8N1ZgQ68OTxgbJUGiXV6N67p15bBdME1R4va51P2Czq2IbRby/N+GHTciTaXvmusV8IjnIOGtKlGxWCuKIPrCS+rGjGA2j1irxBbNpqItltFxjhxBGOzsyQAF6LNIz5IKA7sC6cSH8zUyLuFrV96udc801Zc4nCJG64ZljNbDvlVbJJZ6ex5OLLS6AnrVAXpjEDR/MI/I8JvAPe/psHj6EpXgvKrBYMBOH3jzQRzMFoR79jXyGNgPjdy0A+f6RVuEG8H5sUXKeyy+cFvaT+pm6h+t6RPED11tCOwQxYZ2pExhhPxDGeQIDAQAB";class CryptoUtils{static async init(){if(!this.sessionKey)try{await this.initECDH()}catch(e){await this.initRSA()}}static async initECDH(){const e=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"]),t=await window.crypto.subtle.exportKey("raw",e.publicKey);this.ecdhPublicKeyBase64=this.arrayBufferToBase64(t);const i=(window.__securitySDKEndpoint||"").replace(/\/events$/,""),s=await fetch(`${i}/key-exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientPublicKey:this.ecdhPublicKeyBase64})});if(!s.ok)throw new Error("Key exchange failed");const{serverPublicKey:n,salt:a}=await s.json(),r=this.base64ToArrayBuffer(n),o=await window.crypto.subtle.importKey("raw",r,{name:"ECDH",namedCurve:"P-256"},!1,[]),c=await window.crypto.subtle.deriveBits({name:"ECDH",public:o},e.privateKey,256),l=await window.crypto.subtle.importKey("raw",c,"HKDF",!1,["deriveKey"]),h=this.base64ToArrayBuffer(a);this.sessionKey=await window.crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:h,info:(new TextEncoder).encode("aientrophy-session-enc")},l,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),this.protocolVersion=2}static async initRSA(){this.sessionKey=await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);const e=await this.importRSAPublicKey(CONFIG_RSA_PUBLIC_KEY),t=await window.crypto.subtle.exportKey("raw",this.sessionKey),i=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},e,t);this.encryptedSessionKey=this.arrayBufferToBase64(i),this.protocolVersion=1}static async encrypt(e){this.sessionKey||await this.init();const t=JSON.stringify(e),i=(new TextEncoder).encode(t),s=window.crypto.getRandomValues(new Uint8Array(12)),n=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},this.sessionKey,i),a=new Uint8Array(n),r=a.slice(0,a.length-16),o=a.slice(a.length-16),c={ek:2===this.protocolVersion?this.ecdhPublicKeyBase64:this.encryptedSessionKey,d:this.arrayBufferToBase64(r.buffer),iv:this.arrayBufferToBase64(s.buffer),tag:this.arrayBufferToBase64(o.buffer)};return 2===this.protocolVersion&&(c.v=2),c}static async decrypt(e){if(!this.sessionKey)throw new Error("Session key not initialized");const t=this.base64ToArrayBuffer(e.d),i=this.base64ToArrayBuffer(e.iv),s=this.base64ToArrayBuffer(e.tag),n=new Uint8Array(t.byteLength+s.byteLength);n.set(new Uint8Array(t),0),n.set(new Uint8Array(s),t.byteLength);const a=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:i},this.sessionKey,n),r=(new TextDecoder).decode(a);return JSON.parse(r)}static setEndpoint(e){window.__securitySDKEndpoint=e}static async importRSAPublicKey(e){const t=window.atob(e),i=this.str2ab(t);return await window.crypto.subtle.importKey("spki",i,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"])}static str2ab(e){const t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0,n=e.length;s<n;s++)i[s]=e.charCodeAt(s);return t}static arrayBufferToBase64(e){let t="";const i=new Uint8Array(e),s=i.byteLength;for(let n=0;n<s;n++)t+=String.fromCharCode(i[n]);return window.btoa(t)}static base64ToArrayBuffer(e){const t=window.atob(e),i=t.length,s=new Uint8Array(i);for(let n=0;n<i;n++)s[n]=t.charCodeAt(n);return s.buffer}}__publicField(CryptoUtils,"sessionKey",null),__publicField(CryptoUtils,"ecdhPublicKeyBase64",null),__publicField(CryptoUtils,"encryptedSessionKey",null),__publicField(CryptoUtils,"protocolVersion",2);const THREAT_EVENTS=new Set(["rapid_click","honeypot_triggered","devtools_open","invisible_interaction","integrity_violation","dom_mutation","behavior_metrics","behavior_analysis","input_metrics","keystroke_dynamics","environmental_integrity","init_signals","automation_detected","cross_context_mismatch","headless_probe"]);class CallbackManager{constructor(){__publicField(this,"handlers",new Map),__publicField(this,"configCallbacks",{})}setConfigCallbacks(e){this.configCallbacks=e}on(e,t){this.addHandler(e,t,!1)}once(e,t){this.addHandler(e,t,!0)}off(e,t){const i=this.handlers.get(e);if(!i)return;const s=i.filter(e=>e.handler!==t);0===s.length?this.handlers.delete(e):this.handlers.set(e,s)}emit(e,...t){this.callHandlers(e,t);const i=e.indexOf(":");if(-1!==i){const s=e.substring(0,i);this.callHandlers(s,t)}this.callConfigCallback(e,t)}emitChallenge(e){return new Promise(t=>{let i=!1;const s=e=>{i||(i=!0,t(e))},n=this.handlers.has("challenge")&&this.handlers.get("challenge").length>0,a=!!this.configCallbacks.onChallenge;n||a?(this.callHandlers("challenge",[e,s]),this.configCallbacks.onChallenge&&this.safeCall(this.configCallbacks.onChallenge,[e,s]),setTimeout(()=>{i||(i=!0,t(!1))},5e3)):t(!1)})}addHandler(e,t,i){this.handlers.has(e)||this.handlers.set(e,[]),this.handlers.get(e).push({handler:t,once:i})}callHandlers(e,t){const i=this.handlers.get(e);if(!i||0===i.length)return;const s=[];for(let n=0;n<i.length;n++)this.safeCall(i[n].handler,t),i[n].once&&s.push(n);for(let n=s.length-1;n>=0;n--)i.splice(s[n],1);0===i.length&&this.handlers.delete(e)}callConfigCallback(e,t){if(e.startsWith("threat:")||"threat"===e)return void(e.startsWith("threat:")&&this.configCallbacks.onThreatDetected&&this.safeCall(this.configCallbacks.onThreatDetected,t));const i={ready:"onReady",error:"onError",block:"onBlock",allow:"onAllow"}[e];i&&this.configCallbacks[i]&&this.safeCall(this.configCallbacks[i],t)}safeCall(e,t){try{e(...t)}catch(i){}}}class Transmitter{constructor(){__publicField(this,"endpoint",""),__publicField(this,"clientKey",""),__publicField(this,"encryptionRequired",!1),__publicField(this,"currentNonce",""),__publicField(this,"buffer",[]),__publicField(this,"batchSize",20),__publicField(this,"flushInterval",5e3),__publicField(this,"intervalId"),__publicField(this,"responseHandler",null),__publicField(this,"callbackManager",null),__publicField(this,"flushing",!1),__publicField(this,"pendingFlush",!1),__publicField(this,"backoffMs",0),__publicField(this,"maxBackoffMs",6e4),__publicField(this,"_lastBackoffStart",0),this.startFlushInterval()}setConfig(e){var t,i;this.endpoint=e.endpoint,this.clientKey=e.clientKey,this.encryptionRequired=(null==(t=e.serverConfig)?void 0:t.encryptionRequired)??!1,this.currentNonce=(null==(i=e.serverConfig)?void 0:i.initialNonce)??"",CryptoUtils.setEndpoint(e.endpoint)}setResponseHandler(e){this.responseHandler=e}setCallbackManager(e){this.callbackManager=e}send(e,t={}){const i=Date.now();if(this.buffer.push({type:e,data:t,timestamp:i}),this.callbackManager)if(THREAT_EVENTS.has(e)){const s={type:e,data:t,timestamp:i};this.callbackManager.emit(`threat:${e}`,s)}else this.callbackManager.emit(`data:${e}`,{type:e,data:t,timestamp:i});this.buffer.length>=this.batchSize&&this.flush()}async flush(){if(0===this.buffer.length||!this.endpoint)return;if(this.backoffMs>0){const e=Date.now();if(this._lastBackoffStart||(this._lastBackoffStart=e),e-this._lastBackoffStart<this.backoffMs)return;this._lastBackoffStart=0}if(this.flushing)return void(this.pendingFlush=!0);this.flushing=!0;const e=this.buffer;this.buffer=[];try{let s;if(this.encryptionRequired){const t=await CryptoUtils.encrypt(e);s=JSON.stringify(t)}else s=JSON.stringify(e);const n={"Content-Type":"application/json","x-client-key":this.clientKey};this.currentNonce&&(n["x-request-nonce"]=this.currentNonce,this.currentNonce="");try{const i=await fetch(this.endpoint,{method:"POST",body:s,headers:n,keepalive:!0});if(429===i.status)return this.buffer=e.concat(this.buffer).slice(0,500),this.backoffMs=0===this.backoffMs?5e3:Math.min(2*this.backoffMs,this.maxBackoffMs),void(this._lastBackoffStart=Date.now());if(this.backoffMs=0,i.ok&&this.callbackManager&&this.callbackManager.emit("allow",{action:"allow"}),i.ok)try{const e=await i.json();let t=e;this.encryptionRequired&&(t=await CryptoUtils.decrypt(e)),(null==t?void 0:t.nonce)&&(this.currentNonce=t.nonce),this.responseHandler&&this.responseHandler(t)}catch(t){}}catch(i){this.callbackManager&&this.callbackManager.emit("error",{code:"NETWORK_ERROR",message:"Failed to send security events"})}}catch(t){this.callbackManager&&this.callbackManager.emit("error",{code:"PAYLOAD_ERROR",message:"Failed to prepare security payload"})}finally{this.flushing=!1,this.pendingFlush&&(this.pendingFlush=!1,this.flush())}}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.flush()}startFlushInterval(){this.intervalId=setInterval(()=>{this.flush()},this.flushInterval)}}class BehaviorCollector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"isCollecting",!1),this.transmitter=e}start(){this.isCollecting||(this.isCollecting=!0)}stop(){this.isCollecting=!1}}class RapidClickDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"clickHistory",[]),__publicField(this,"THRESHOLD_COUNT",3),__publicField(this,"THRESHOLD_TIME",500),this.transmitter=e,this.init()}init(){document.addEventListener("click",e=>this.handleClick(e),!0)}handleClick(e){const t=Date.now();if(this.clickHistory.push(t),this.clickHistory=this.clickHistory.filter(e=>t-e<=this.THRESHOLD_TIME),this.clickHistory.length>=this.THRESHOLD_COUNT){const i=e.target,s={tagName:i.tagName,id:i.id,className:i.className,x:e.clientX,y:e.clientY};this.transmitter.send("rapid_click",{count:this.clickHistory.length,duration:this.THRESHOLD_TIME,target:s,timestamp:t}),this.clickHistory=[]}}}class Honeypot{constructor(e){__publicField(this,"transmitter"),__publicField(this,"element",null),this.transmitter=e}start(){this.element=document.createElement("input"),this.element.type="text";const e=["website","email_confirm","url","homepage","fax_number","address_line_2"],t=e[Math.floor(Math.random()*e.length)],i=Math.random().toString(36).substr(2,5);this.element.id="hp-"+Math.random().toString(36).substr(2,9),this.element.name=`${t}-${i}`,this.element.autocomplete="off",Object.assign(this.element.style,{position:"absolute",opacity:"0",top:"0",left:"-9999px",height:"1px",width:"1px",zIndex:"-1",border:"none"}),this.element.tabIndex=-1,this.element.setAttribute("aria-hidden","true"),this.element.setAttribute("role","presentation");const s=e=>{var t;this.transmitter.send("honeypot_triggered",{eventType:e.type,value:null==(t=this.element)?void 0:t.value,timestamp:Date.now()})};this.element.addEventListener("input",s),this.element.addEventListener("focus",s),this.element.addEventListener("click",s),document.body.appendChild(this.element)}stop(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class MouseTracker{constructor(e,t){__publicField(this,"transmitter"),__publicField(this,"wasmService"),__publicField(this,"buffer",[]),__publicField(this,"BUFFER_SIZE",50),__publicField(this,"SAMPLE_INTERVAL",100),__publicField(this,"SEND_COOLDOWN",5e3),__publicField(this,"lastSampleTime",0),__publicField(this,"lastSendTime",0),__publicField(this,"handleMouseMove",e=>{const t=Date.now();t-this.lastSampleTime<this.SAMPLE_INTERVAL||(this.lastSampleTime=t,this.buffer.push({x:e.clientX,y:e.clientY,time:t}),this.buffer.length>this.BUFFER_SIZE&&this.buffer.shift(),this.buffer.length>=this.BUFFER_SIZE&&t-this.lastSendTime>=this.SEND_COOLDOWN&&(this.analyze(),this.lastSendTime=t))}),this.transmitter=e,this.wasmService=t}start(){"undefined"!=typeof document&&document.addEventListener("mousemove",this.handleMouseMove)}stop(){"undefined"!=typeof document&&document.removeEventListener("mousemove",this.handleMouseMove)}analyze(){if(this.buffer.length<20)return;const e=this.wasmService.calculateEntropy(this.buffer),t=this.calculateSpeedVariance(),i=this.buffer.map(e=>({x:e.x,y:e.y,t:e.time}));this.transmitter.send("behavior_metrics",{entropy:e,speedVariance:t,sampleSize:this.buffer.length,timestamp:Date.now(),rawTrajectory:i})}calculateSpeedVariance(){const e=[];for(let i=1;i<this.buffer.length;i++){const t=this.buffer[i-1],s=this.buffer[i],n=Math.sqrt(Math.pow(s.x-t.x,2)+Math.pow(s.y-t.y,2)),a=s.time-t.time;a>0&&e.push(n/a)}if(e.length<2)return 1;const t=e.reduce((e,t)=>e+t,0)/e.length;return e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length}}class InputTracker{constructor(e){__publicField(this,"lastInteractionTime",0),__publicField(this,"lastInteractionType","none"),__publicField(this,"transmitter"),__publicField(this,"isMobile",!1),__publicField(this,"keyPressTimes",new Map),__publicField(this,"lastKeyUpTime",0),__publicField(this,"flightTimes",[]),__publicField(this,"dwellTimes",[]),__publicField(this,"suspiciousFocusCount",0),__publicField(this,"suspiciousFocusResetTimer",null),__publicField(this,"rawKeystrokes",[]),this.transmitter=e,this.isMobile=this.detectMobile()}start(){this.initListeners()}detectMobile(){return"undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0)}initListeners(){if("undefined"==typeof document)return;["mousedown","keydown","touchstart","touchend"].forEach(e=>{document.addEventListener(e,e=>{this.lastInteractionTime=Date.now(),this.lastInteractionType=e.type},{passive:!0,capture:!0})}),document.addEventListener("focus",e=>{const t=e.target;"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName||(this.checkFocusIntegrity(),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[],this.lastKeyUpTime=0)},{capture:!0}),document.addEventListener("keydown",e=>{const t=e.target;if("INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName)return;const i=Date.now();if(this.keyPressTimes.set(e.code,i),this.rawKeystrokes.push({code:e.code,t:i,type:"down"}),this.lastKeyUpTime>0){const e=i-this.lastKeyUpTime;e<2e3&&this.flightTimes.push(e)}},{passive:!0,capture:!0}),document.addEventListener("keyup",e=>{const t=e.target;if("INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName)return;const i=Date.now();this.lastKeyUpTime=i,this.rawKeystrokes.push({code:e.code,t:i,type:"up"});const s=this.keyPressTimes.get(e.code);if(s){const t=i-s;this.dwellTimes.push(t),this.keyPressTimes.delete(e.code)}this.flightTimes.length>=10&&this.reportKeystrokeDynamics(t)},{passive:!0,capture:!0}),document.addEventListener("blur",e=>{const t=e.target;("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&this.flightTimes.length>0&&this.reportKeystrokeDynamics(t)},{capture:!0})}checkFocusIntegrity(){const e=Date.now(),t=e-this.lastInteractionTime;performance.now()<5e3||(t>200?(this.suspiciousFocusCount++,clearTimeout(this.suspiciousFocusResetTimer),this.suspiciousFocusResetTimer=setTimeout(()=>{this.suspiciousFocusCount=0},3e3),this.transmitter.send("behavior_metrics",{type:"suspicious_focus",timeSinceInteraction:t,lastInteraction:this.lastInteractionType,consecutiveCount:this.suspiciousFocusCount,timestamp:e})):this.suspiciousFocusCount=0)}reportKeystrokeDynamics(e){const t=this.average(this.flightTimes),i=this.variance(this.flightTimes,t),s=this.average(this.dwellTimes),n=this.variance(this.dwellTimes,s);this.transmitter.send("input_metrics",{element:e.id||e.tagName,flight:{avg:t,variance:i,samples:this.flightTimes.length},dwell:{avg:s,variance:n},isMobile:this.isMobile,timestamp:Date.now(),rawKeystrokes:[...this.rawKeystrokes]}),this.flightTimes=[],this.dwellTimes=[],this.rawKeystrokes=[]}average(e){return 0===e.length?0:e.reduce((e,t)=>e+t,0)/e.length}variance(e,t){return 0===e.length?0:e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length}}class WasmService{constructor(){__publicField(this,"wasmModule",null),__publicField(this,"memory",null),__publicField(this,"instance",null)}async load(e){try{const t=await fetch(`${e}/sdk/core.wasm`);if(!t.ok)throw new Error(`HTTP ${t.status}`);const i={env:{abort:()=>{}}};if(WebAssembly.instantiateStreaming){const e=await WebAssembly.instantiateStreaming(t,i);this.instance=e.instance}else{const e=await t.arrayBuffer(),s=await WebAssembly.instantiate(e,i);this.instance=s.instance}this.wasmModule=this.instance.exports,this.memory=this.wasmModule.memory}catch(t){}}isLoaded(){return!!this.instance}calculateEntropy(e){if(!this.instance||!this.wasmModule)return 0;const t=2*e.length,i=8*t;try{const s=this.wasmModule.__new(i,0),n=new Float64Array(this.memory.buffer,s,t);for(let t=0;t<e.length;t++)n[2*t]=e[t].x,n[2*t+1]=e[t].y;return this.wasmModule.calculateEntropy(s,t)}catch(s){return 0}}simpleHash(e){if(!this.instance||!this.wasmModule)return 0;try{const t=(new TextEncoder).encode(e),i=t.length,s=this.wasmModule.__new(i,0);return new Uint8Array(this.memory.buffer,s,i).set(t),this.wasmModule.simpleHash(s,i)}catch(t){return 0}}}class CanvasFingerprinter{constructor(e,t){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof document||setTimeout(async()=>{const e=await this.generateFingerprint(),t=this.collectWebGLFingerprint(),i=this.collectAudioFingerprint();this.transmitter.send("fingerprint_collected",{hash:e,webgl:t,audio:i}),this.hasRun=!0},500)}async generateFingerprint(){try{const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return"unknown";t.textBaseline="top",t.font='14px "Arial"',t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText("aientrophy Security 😃",2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText("aientrophy Security 😃",4,17),t.globalCompositeOperation="multiply",t.fillStyle="rgb(255,0,255)",t.beginPath(),t.arc(50,50,50,0,2*Math.PI,!0),t.closePath(),t.fill(),t.fillStyle="rgb(0,255,255)",t.beginPath(),t.arc(100,50,50,0,2*Math.PI,!0),t.closePath(),t.fill(),t.fillStyle="rgb(255,255,0)",t.beginPath(),t.arc(75,100,50,0,2*Math.PI,!0),t.closePath(),t.fill();const i=e.toDataURL();return await this.sha256(i)}catch(e){return"error"}}async sha256(e){const t=(new TextEncoder).encode(e),i=await window.crypto.subtle.digest("SHA-256",t),s=new Uint8Array(i);return Array.from(s).map(e=>e.toString(16).padStart(2,"0")).join("")}collectWebGLFingerprint(){try{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{available:!1};const i=t,s={available:!0},n=i.getExtension("WEBGL_debug_renderer_info");return n&&(s.renderer=i.getParameter(n.UNMASKED_RENDERER_WEBGL),s.vendor=i.getParameter(n.UNMASKED_VENDOR_WEBGL)),s.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),s.maxViewportDims=Array.from(i.getParameter(i.MAX_VIEWPORT_DIMS)),s.maxRenderbufferSize=i.getParameter(i.MAX_RENDERBUFFER_SIZE),s.maxVertexAttribs=i.getParameter(i.MAX_VERTEX_ATTRIBS),s.extensions=(i.getSupportedExtensions()||[]).length,s}catch(e){return{available:!1,error:!0}}}collectAudioFingerprint(){try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return{available:!1};const t=new e,i={available:!0,sampleRate:t.sampleRate,state:t.state,maxChannels:t.destination.maxChannelCount};return t.close(),i}catch(e){return{available:!1}}}}class ChallengeHandler{constructor(e){__publicField(this,"originalFetch"),__publicField(this,"endpoint"),__publicField(this,"callbackManager",null),__publicField(this,"challengeInProgress",null),this.endpoint=e,this.originalFetch=window.fetch.bind(window)}setCallbackManager(e){this.callbackManager=e}start(){window.fetch=async(e,t)=>{var i;const s=await this.originalFetch(e,t);if(403===s.status){const a=s.clone();try{const n=await a.json();if("challenge"===n.action&&"captcha"===(null==(i=n.metadata)?void 0:i.type)){const i={action:"challenge",score:n.score,metadata:n.metadata};if(this.callbackManager){if(await this.callbackManager.emitChallenge(i))return this.originalFetch(e,t)}this.challengeInProgress||(this.challengeInProgress=this.showCaptchaModal().finally(()=>{this.challengeInProgress=null}));return await this.challengeInProgress?this.originalFetch(e,t):s}"block"===n.action&&this.callbackManager&&this.callbackManager.emit("block",{action:"block",score:n.score,metadata:n.metadata})}catch(n){}}return s}}async showCaptchaModal(){return new Promise(e=>{const t=document.createElement("div");t.id="sec-sdk-challenge-host",t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100vw",t.style.height="100vh",t.style.zIndex="999999",t.style.backgroundColor="rgba(0,0,0,0.5)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";const i=t.attachShadow({mode:"open"}),s=document.createElement("div");s.style.background="white",s.style.padding="20px",s.style.borderRadius="8px",s.style.boxShadow="0 4px 12px rgba(0,0,0,0.2)",s.style.textAlign="center",s.style.fontFamily="system-ui, sans-serif";const n=document.createElement("h3");n.textContent="Security Check",n.style.margin="0 0 16px 0";const a=document.createElement("p");a.textContent="Unusual activity detected. Please verify you are human.",a.style.marginBottom="16px",a.style.fontSize="14px",a.style.color="#666";const r=document.createElement("div");r.innerHTML="Loading...",r.style.marginBottom="16px";const o=document.createElement("input");o.type="text",o.placeholder="Enter details",o.style.padding="8px",o.style.marginRight="8px",o.style.border="1px solid #ddd",o.style.borderRadius="4px";const c=document.createElement("button");c.textContent="Verify",c.style.padding="8px 16px",c.style.background="#007bff",c.style.color="white",c.style.border="none",c.style.borderRadius="4px",c.style.cursor="pointer";const l=document.createElement("p");l.style.color="red",l.style.fontSize="12px",l.style.display="none",s.appendChild(n),s.appendChild(a),s.appendChild(r),s.appendChild(o),s.appendChild(c),s.appendChild(l),i.appendChild(s),document.body.appendChild(t);let h="";const u=async()=>{try{const e=await this.originalFetch(`${this.endpoint}/challenge`),t=await e.json();h=t.id,r.innerHTML=t.svg}catch(e){r.textContent="Error loading CAPTCHA"}},d=async()=>{l.style.display="none",c.textContent="Verifying...";try{const i=o.value,s=await this.originalFetch(`${this.endpoint}/challenge/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:h,answer:i})});(await s.json()).success?(document.body.removeChild(t),e(!0)):(l.textContent="Incorrect, try again.",l.style.display="block",c.textContent="Verify",o.value="",u())}catch(i){l.textContent="System error.",l.style.display="block",c.textContent="Verify"}};c.onclick=d,o.onkeydown=e=>{"Enter"===e.key&&d()},u()})}}class InvisibleInteraction{constructor(e){__publicField(this,"transmitter"),__publicField(this,"eventsToWatch",["click","mousedown","keydown","touchstart","focus"]),__publicField(this,"handleEvent",e=>{const t=e.target;if(!(t&&t instanceof HTMLElement))return;if(t===document.body||t===document.documentElement)return;const i=this.checkVisibility(t,e);if(i){const s=t.getBoundingClientRect();this.transmitter.send("invisible_interaction",{type:e.type,target:t.tagName,id:t.id,reason:i,timestamp:Date.now(),isTrusted:e.isTrusted,coordinates:{x:e instanceof MouseEvent?e.clientX:0,y:e instanceof MouseEvent?e.clientY:0},viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{x:window.scrollX,y:window.scrollY},docDim:{width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight},elementRect:{top:s.top,left:s.left,width:s.width,height:s.height}})}}),this.transmitter=e}start(){this.eventsToWatch.forEach(e=>{document.addEventListener(e,this.handleEvent,{capture:!0,passive:!0})})}stop(){this.eventsToWatch.forEach(e=>{document.removeEventListener(e,this.handleEvent,{capture:!0})})}checkVisibility(e,t){var i,s;const n=window.getComputedStyle(e);if("none"===n.display)return"display:none";if("hidden"===n.visibility)return"visibility:hidden";if("0"===n.opacity)return"opacity:0";const a=e.getBoundingClientRect();if(a.width<=0||a.height<=0)return"zero_size";const r=a.right<0||a.left>window.innerWidth,o=a.bottom<0||a.top>window.innerHeight;if(r||o)return"off_screen";if(t instanceof MouseEvent||t instanceof TouchEvent){let n,a;if(t instanceof MouseEvent?(n=t.clientX,a=t.clientY):(n=(null==(i=t.touches[0])?void 0:i.clientX)||0,a=(null==(s=t.touches[0])?void 0:s.clientY)||0),n>=0&&n<=window.innerWidth&&a>=0&&a<=window.innerHeight){const i=document.elementFromPoint(n,a);if(i&&i!==e&&!e.contains(i)&&!i.contains(e)&&0===n&&0===a&&t.isTrusted)return null}}return null}}class AutomationDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(setTimeout(()=>this.detect(),1500),this.hasRun=!0)}detect(){var e,t;const i={};let s=0;!0===navigator.webdriver&&(i.webdriver=!0,s+=40);try{this.detectCDP()&&(i.cdp=!0,s+=50)}catch(c){}const n=this.detectAutomationGlobals();n.length>0&&(i.automationGlobals=n,s+=30);const a=this.checkWebGL();a.suspicious&&(i.webgl=a,s+=25);const r=this.checkInconsistencies();r.length>0&&(i.inconsistencies=r,s+=15);const o=this.checkHeadless();o.score>0&&(i.headless=o.flags,s+=o.score),s>0&&this.transmitter.send("automation_detected",{signals:i,score:s,timestamp:Date.now()}),this.transmitter.send("init_signals",{webdriver:!!navigator.webdriver,plugins:(null==(e=navigator.plugins)?void 0:e.length)??0,languages:(null==(t=navigator.languages)?void 0:t.length)??0,platform:navigator.platform,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:navigator.deviceMemory,maxTouchPoints:navigator.maxTouchPoints,webglRenderer:a.renderer,webglVendor:a.vendor,timestamp:Date.now()})}detectCDP(){const e=console.debug;return console.debug=e,!1}detectAutomationGlobals(){const e=[],t=[["selenium",()=>!!window._selenium],["selenium_unwrapped",()=>!!document.__selenium_unwrapped],["driver_evaluate",()=>!!document.__driver_evaluate],["webdriver_evaluate",()=>!!document.__webdriver_evaluate],["driver_unwrapped",()=>!!document.__driver_unwrapped],["fxdriver",()=>!!document.__fxdriver_evaluate],["playwright",()=>!!window.__playwright],["playwright_binding",()=>!!window.__playwright__binding__],["pwInitScripts",()=>!!window.__pwInitScripts],["puppeteer",()=>!!window.__puppeteer_evaluation_script__],["phantom",()=>!!window.callPhantom||!!window._phantom],["nightmare",()=>!!window.__nightmare],["cdc",()=>Object.keys(document).some(e=>e.startsWith("cdc_")||e.startsWith("$cdc_"))]];for(const[s,n]of t)try{n()&&e.push(s)}catch(i){}return e}checkWebGL(){try{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{suspicious:!1,renderer:"unavailable",vendor:"unavailable"};const i=t.getExtension("WEBGL_debug_renderer_info");if(!i)return{suspicious:!1,renderer:"no_debug_info",vendor:"no_debug_info"};const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",n=t.getParameter(i.UNMASKED_VENDOR_WEBGL)||"";return{suspicious:/SwiftShader/i.test(s)||/Mesa OffScreen/i.test(s)||/llvmpipe/i.test(s),renderer:s,vendor:n}}catch(e){return{suspicious:!1,renderer:"error",vendor:"error"}}}checkInconsistencies(){const e=[];try{const t=navigator.userAgent,i=navigator.platform;/Windows/.test(t)&&/Mac/.test(i)&&e.push("ua_platform_mismatch_win_mac"),/Macintosh/.test(t)&&/Win/.test(i)&&e.push("ua_platform_mismatch_mac_win"),/Mobile|Android|iPhone/.test(t)&&0===navigator.maxTouchPoints&&e.push("mobile_ua_no_touch"),/Chrome/.test(t)&&navigator.plugins&&0===navigator.plugins.length&&e.push("chrome_no_plugins"),navigator.languages&&0!==navigator.languages.length||e.push("no_languages")}catch(t){}return e}checkHeadless(){const e=[];let t=0;try{if(/HeadlessChrome/.test(navigator.userAgent)&&(e.push("headless_ua"),t+=40),/Chrome/.test(navigator.userAgent)&&!window.chrome&&(e.push("chrome_ua_no_chrome_obj"),t+=15),window.screen&&800===window.screen.width&&600===window.screen.height&&(e.push("default_screen_size"),t+=10),"Notification"in window){"denied"===window.Notification.permission&&navigator.userAgent.includes("Chrome")&&(e.push("notification_denied_default"),t+=5)}const i=navigator.connection;i&&0===i.rtt&&(e.push("zero_rtt"),t+=10)}catch(i){}return{score:t,flags:e}}}class SessionAnalyzer{constructor(e){__publicField(this,"transmitter"),__publicField(this,"sessionStart",0),__publicField(this,"pageTransitions",[]),__publicField(this,"interactionTimestamps",[]),__publicField(this,"lastPageUrl",""),__publicField(this,"formStartTimes",new Map),__publicField(this,"reportInterval",null),this.transmitter=e}start(){if("undefined"==typeof window)return;this.sessionStart=Date.now(),this.lastPageUrl=window.location.href;["mousedown","keydown","touchstart","scroll"].forEach(e=>{document.addEventListener(e,()=>{this.interactionTimestamps.push(Date.now()),this.interactionTimestamps.length>500&&this.interactionTimestamps.shift()},{passive:!0,capture:!0})}),this.observeNavigation(),this.observeForms(),this.reportInterval=setInterval(()=>this.report(),15e3)}observeNavigation(){const e=history.pushState,t=history.replaceState,i=this;history.pushState=function(t,s,n){e.call(this,t,s,n),i.onPageTransition()},history.replaceState=function(e,s,n){t.call(this,e,s,n),i.onPageTransition()},window.addEventListener("popstate",()=>this.onPageTransition())}onPageTransition(){const e=Date.now(),t=window.location.href;t!==this.lastPageUrl&&(this.pageTransitions.push(e),this.lastPageUrl=t)}observeForms(){document.addEventListener("focus",e=>{const t=e.target;if("INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName){const e=t.closest("form"),i=(null==e?void 0:e.id)||(null==e?void 0:e.action)||"anonymous_form";this.formStartTimes.has(i)||this.formStartTimes.set(i,Date.now())}},{capture:!0}),document.addEventListener("submit",e=>{const t=e.target,i=t.id||t.action||"anonymous_form",s=this.formStartTimes.get(i);if(s){const e=Date.now()-s;this.transmitter.send("session_metrics",{type:"form_completion",formId:i,duration:e,timestamp:Date.now()}),this.formStartTimes.delete(i)}},{capture:!0})}report(){const e=Date.now(),t=e-this.sessionStart;if(this.interactionTimestamps.length<10)return;const i=this.calculateIntervals(this.interactionTimestamps),s=this.analyzeTimingDistribution(i),n=this.analyzePageTransitions();this.transmitter.send("session_metrics",{type:"session_analysis",sessionDuration:t,totalInteractions:this.interactionTimestamps.length,pageTransitions:this.pageTransitions.length,timing:s,pages:n,timestamp:e})}calculateIntervals(e){const t=[];for(let i=1;i<e.length;i++)t.push(e[i]-e[i-1]);return t}analyzeTimingDistribution(e){if(e.length<5)return{samples:e.length};const t=e.reduce((e,t)=>e+t,0)/e.length,i=e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length,s=Math.sqrt(i),n=t>0?s/t:0,a=this.shannonEntropy(e,50),r=this.autocorrelation(e);return{mean:Math.round(t),stdDev:Math.round(s),cv:parseFloat(n.toFixed(4)),entropy:parseFloat(a.toFixed(4)),autocorrelation:parseFloat(r.toFixed(4)),samples:e.length}}analyzePageTransitions(){if(this.pageTransitions.length<2)return{count:this.pageTransitions.length};const e=this.calculateIntervals(this.pageTransitions),t=e.reduce((e,t)=>e+t,0)/e.length,i=e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length,s=t>0?Math.sqrt(i)/t:0;return{count:this.pageTransitions.length,avgInterval:Math.round(t),cv:parseFloat(s.toFixed(4))}}shannonEntropy(e,t){const i=new Map;for(const a of e){const e=Math.floor(a/t);i.set(e,(i.get(e)||0)+1)}const s=e.length;let n=0;for(const a of i.values()){const e=a/s;e>0&&(n-=e*Math.log2(e))}return n}autocorrelation(e){if(e.length<3)return 0;const t=e.reduce((e,t)=>e+t,0)/e.length;let i=0,s=0;for(let n=0;n<e.length-1;n++)i+=(e[n]-t)*(e[n+1]-t);for(let n=0;n<e.length;n++)s+=Math.pow(e[n]-t,2);return 0===s?0:i/s}}class TabNavigationAnalyzer{constructor(e){__publicField(this,"transmitter"),__publicField(this,"tabTimestamps",[]),__publicField(this,"shiftTabCount",0),__publicField(this,"tabCount",0),__publicField(this,"isShiftDown",!1),__publicField(this,"BURST_THRESHOLD_MS",80),__publicField(this,"reportInterval",null),__publicField(this,"REPORT_INTERVAL_MS",1e4),__publicField(this,"MIN_TABS_TO_REPORT",5),__publicField(this,"TAB_TRIGGER_COUNT",20),__publicField(this,"onKeyDown",e=>{if("Shift"!==e.key){if("Tab"===e.key){const e=Date.now();this.isShiftDown?this.shiftTabCount++:(this.tabCount++,this.tabTimestamps.push(e),this.tabTimestamps.length>100&&this.tabTimestamps.shift()),this.tabCount+this.shiftTabCount>=this.TAB_TRIGGER_COUNT&&this.report()}}else this.isShiftDown=!0}),__publicField(this,"onKeyUp",e=>{"Shift"===e.key&&(this.isShiftDown=!1)}),this.transmitter=e}start(){"undefined"!=typeof document&&(document.addEventListener("keydown",this.onKeyDown,{passive:!0,capture:!0}),document.addEventListener("keyup",this.onKeyUp,{passive:!0,capture:!0}),this.reportInterval=setInterval(()=>this.report(),this.REPORT_INTERVAL_MS))}stop(){"undefined"!=typeof document&&(document.removeEventListener("keydown",this.onKeyDown,{capture:!0}),document.removeEventListener("keyup",this.onKeyUp,{capture:!0}),this.reportInterval&&(clearInterval(this.reportInterval),this.reportInterval=null),this.report())}report(){const e=this.tabCount+this.shiftTabCount;if(e<this.MIN_TABS_TO_REPORT)return;const t=this.calculateIntervals(this.tabTimestamps);if(t.length<3)return void this.resetBuffers();const i=this.analyzeIntervals(t),s=this.analyzeBursts(t),n=e>0?this.shiftTabCount/e:0;this.transmitter.send("tab_navigation_metrics",{tabCount:this.tabCount,shiftTabCount:this.shiftTabCount,shiftTabRatio:parseFloat(n.toFixed(4)),intervals:i,bursts:s,timestamp:Date.now()}),this.resetBuffers()}resetBuffers(){this.tabTimestamps=[],this.tabCount=0,this.shiftTabCount=0}calculateIntervals(e){const t=[];for(let i=1;i<e.length;i++){const s=e[i]-e[i-1];s<5e3&&t.push(s)}return t}analyzeIntervals(e){if(0===e.length)return{avg:0,variance:0,cv:0,min:0,samples:0};const t=e.reduce((e,t)=>e+t,0)/e.length,i=e.reduce((e,i)=>e+Math.pow(i-t,2),0)/e.length,s=Math.sqrt(i),n=t>0?s/t:0,a=Math.min(...e);return{avg:parseFloat(t.toFixed(2)),variance:parseFloat(i.toFixed(2)),cv:parseFloat(n.toFixed(4)),min:a,samples:e.length}}analyzeBursts(e){let t=0,i=0,s=0,n=0,a=0;for(const r of e)r<this.BURST_THRESHOLD_MS?(i++,n+=r,a++):(i>=3&&(t++,s+=i),i=0);return i>=3&&(t++,s+=i),{count:t,avgLength:t>0?parseFloat((s/t).toFixed(1)):0,avgInterval:a>0?parseFloat((n/a).toFixed(2)):0}}}class CloudEnvironmentDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){try{const e=this.analyzeGPU(),t=this.analyzeHardware(),i=this.analyzeScreen(),s=await this.analyzeMedia(),n=this.benchmarkCanvas();let a=0;"virtual_gpu"!==e.category&&"software_render"!==e.category&&"cloud_gpu"!==e.category||(a+=2),t.cores<=2&&a++,null!==t.memory&&t.memory<=2&&a++,24===t.colorDepth&&a++,1===t.pixelRatio&&a++,i.noTaskbar&&a++,i.isVMResolution&&a++,0===s.cameras&&0===s.microphones&&a++,s.hasBluetooth||s.hasUSB||a++,n.canvasRenderTime>50&&a++;const{classification:r,confidence:o}=this.classify(e,t,a);this.transmitter.send("cloud_environment",{classification:r,confidence:o,signals:{gpu:{renderer:e.renderer,vendor:e.vendor,category:e.category},hardware:t,screen:i,media:s,performance:n},vmIndicatorCount:a,timestamp:Date.now()})}catch(e){}}analyzeGPU(){try{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{renderer:"unavailable",vendor:"unavailable",category:"unknown"};const i=t.getExtension("WEBGL_debug_renderer_info");if(!i)return{renderer:"no_debug_info",vendor:"no_debug_info",category:"unknown"};const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL)||"",n=t.getParameter(i.UNMASKED_VENDOR_WEBGL)||"";return{renderer:s,vendor:n,category:this.categorizeGPU(s,n)}}catch(e){return{renderer:"error",vendor:"error",category:"unknown"}}}categorizeGPU(e,t){const i=e.toLowerCase(),s=t.toLowerCase();return/swiftshader|llvmpipe|mesa offscreen|softpipe/.test(i)?"software_render":/svga3d|svga|vmware/.test(i)||/virtualbox/.test(i)||/parallels/.test(i)||/qxl|virtio|red hat|spice/.test(i)||/hyper-v|microsoft basic render/i.test(i)||/citrix/.test(i)?"virtual_gpu":/amazon|elastic|aws/.test(i)||/amazon|elastic|aws/.test(s)||/google cloud|gce/.test(i)||/google cloud|gce/.test(s)||/azure/.test(i)||/azure/.test(s)?"cloud_gpu":"physical"}analyzeHardware(){return{cores:navigator.hardwareConcurrency||0,memory:navigator.deviceMemory??null,colorDepth:screen.colorDepth,pixelRatio:window.devicePixelRatio||1}}analyzeScreen(){const e=screen.width,t=screen.height,i=screen.availHeight,s=t===i&&t===window.innerHeight,n=[[800,600],[1024,768],[1280,1024],[1280,800],[1920,1080]].some(([i,s])=>e===i&&t===s&&!(1920===i&&1080===s));return{width:e,height:t,availHeight:i,noTaskbar:s,isVMResolution:n}}async analyzeMedia(){let e=-1,t=-1;try{if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices){const i=await navigator.mediaDevices.enumerateDevices();e=i.filter(e=>"videoinput"===e.kind).length,t=i.filter(e=>"audioinput"===e.kind).length}}catch(a){}const i=!!navigator.bluetooth,s=!!navigator.usb;let n=null;try{if(navigator.getBattery){const e=await navigator.getBattery();n=!(e.charging&&1===e.level&&0===e.chargingTime)}}catch(a){}return{cameras:e,microphones:t,hasBluetooth:i,hasUSB:s,hasBattery:n}}benchmarkCanvas(){try{const e=document.createElement("canvas");e.width=200,e.height=200;const t=e.getContext("2d");if(!t)return{canvasRenderTime:-1};const i=performance.now();for(let n=0;n<500;n++)t.fillStyle=`rgb(${n%256},${3*n%256},${7*n%256})`,t.fillRect(13*n%200,7*n%200,10,10);t.getImageData(0,0,1,1);const s=performance.now()-i;return{canvasRenderTime:Math.round(100*s)/100}}catch(e){return{canvasRenderTime:-1}}}classify(e,t,i){return"virtual_gpu"===e.category?24===t.colorDepth?{classification:"rdp_likely",confidence:.85}:{classification:"vm_detected",confidence:.95}:"cloud_gpu"===e.category?{classification:"cloud_likely",confidence:.9}:"software_render"===e.category?{classification:"vm_detected",confidence:.9}:i>=5?{classification:"vm_likely",confidence:.8}:i>=3?{classification:"vm_likely",confidence:.6}:{classification:"physical",confidence:1-.1*i}}}class CrossContextDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2500))}async detect(){var e,t;const i={};let s=0;const n={webdriver:!!navigator.webdriver,languages:(null==(e=navigator.languages)?void 0:e.join(","))||"",platform:navigator.platform||"",hardwareConcurrency:navigator.hardwareConcurrency||0,userAgent:navigator.userAgent||"",pluginsLength:(null==(t=navigator.plugins)?void 0:t.length)??0},a=this.checkIframe(n);a.score>0&&(i.iframe=a.mismatches,s+=a.score);try{const e=await this.checkWorker(n);e.score>0&&(i.worker=e.mismatches,s+=e.score)}catch(r){}s>0&&this.transmitter.send("cross_context_mismatch",{signals:i,score:s,timestamp:Date.now()})}checkIframe(e){var t,i;const s=[];let n=0;try{const a=document.createElement("iframe");a.style.display="none",a.sandbox="allow-same-origin",document.body.appendChild(a);const r=a.contentWindow;if(!r)return document.body.removeChild(a),{score:0,mismatches:[]};const o=r.navigator;o.webdriver!==navigator.webdriver&&(s.push("webdriver_mismatch"),n+=40),navigator.webdriver||!0!==o.webdriver||(s.push("webdriver_spoofed_in_main"),n+=30);((null==(t=o.languages)?void 0:t.join(","))||"")!==e.languages&&(s.push("languages_mismatch"),n+=15),o.platform!==e.platform&&(s.push("platform_mismatch"),n+=15);((null==(i=o.plugins)?void 0:i.length)??0)!==e.pluginsLength&&(s.push("plugins_mismatch"),n+=10),document.body.removeChild(a)}catch(a){}return{score:n,mismatches:s}}checkWorker(e){return new Promise(t=>{try{const i=new Blob(["\n self.onmessage = function() {\n var nav = self.navigator;\n self.postMessage({\n webdriver: !!nav.webdriver,\n languages: (nav.languages || []).join(','),\n platform: nav.platform || '',\n hardwareConcurrency: nav.hardwareConcurrency || 0,\n userAgent: nav.userAgent || ''\n });\n };\n "],{type:"application/javascript"}),s=URL.createObjectURL(i),n=new Worker(s),a=setTimeout(()=>{n.terminate(),URL.revokeObjectURL(s),t({score:0,mismatches:[]})},3e3);n.onmessage=i=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(s);const r=i.data,o=[];let c=0;r.webdriver!==e.webdriver&&(o.push("worker_webdriver_mismatch"),c+=35),r.languages!==e.languages&&(o.push("worker_languages_mismatch"),c+=15),r.platform!==e.platform&&(o.push("worker_platform_mismatch"),c+=15),r.hardwareConcurrency!==e.hardwareConcurrency&&(o.push("worker_concurrency_mismatch"),c+=10),r.userAgent!==e.userAgent&&(o.push("worker_ua_mismatch"),c+=20),t({score:c,mismatches:o})},n.onerror=()=>{clearTimeout(a),n.terminate(),URL.revokeObjectURL(s),t({score:0,mismatches:[]})},n.postMessage("check")}catch(i){t({score:0,mismatches:[]})}})}}class HeadlessProbeDetector{constructor(e){__publicField(this,"transmitter"),__publicField(this,"hasRun",!1),this.transmitter=e}start(){this.hasRun||"undefined"==typeof window||(this.hasRun=!0,setTimeout(()=>this.detect(),2e3))}async detect(){const e={};let t=0;const i=await this.checkBrokenImage();i.suspicious&&(e.brokenImage=i,t+=25);const s=await this.checkClientHints();s.suspicious&&(e.clientHints=s,t+=20);const n=this.checkCDPMouseSignature();n.suspicious&&(e.cdpMouse=n,t+=30);const a=this.checkHairlineSupport();a.suspicious&&(e.hairline=a,t+=10);const r=this.checkExtraFrameworks();r.length>0&&(e.extraFrameworks=r,t+=20);(await this.checkWorkerCDP()).suspicious&&(e.workerCDP=!0,t+=35),t>0&&this.transmitter.send("headless_probe",{signals:e,score:t,timestamp:Date.now()})}checkBrokenImage(){return new Promise(e=>{try{const t=document.createElement("img");t.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==___invalid";const i=setTimeout(()=>{e({suspicious:!1,width:-1,height:-1})},2e3);t.onerror=()=>{clearTimeout(i);const s=t.width,n=t.height;e({suspicious:0===s&&0===n,width:s,height:n})},t.onload=()=>{clearTimeout(i),e({suspicious:!1,width:t.width,height:t.height})},t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),setTimeout(()=>{try{document.body.removeChild(t)}catch(e){}},100)}catch(t){e({suspicious:!1,width:-1,height:-1})}})}async checkClientHints(){const e=[];try{const t=navigator.userAgentData;if(!t)return{suspicious:!1,mismatches:[]};const i=navigator.userAgent,s=(t.brands||[]).map(e=>e.brand);/Chrome\/\d/.test(i)&&!s.some(e=>/Chromium|Google Chrome|Chrome/.test(e))&&e.push("ua_chrome_no_brand"),t.platform&&(/Windows/.test(i)&&"Windows"!==t.platform&&e.push("ua_windows_brand_mismatch"),/Macintosh/.test(i)&&"macOS"!==t.platform&&e.push("ua_mac_brand_mismatch"),/Linux/.test(i)&&!/Linux|Android|ChromeOS/.test(t.platform)&&e.push("ua_linux_brand_mismatch")),/Mobile/.test(i)&&!1===t.mobile&&e.push("ua_mobile_brand_mismatch")}catch(t){}return{suspicious:e.length>0,mismatches:e}}checkCDPMouseSignature(){let e=0,t=0,i=!1;try{const s=[],n=i=>{s.push(i),t++,0===i.movementX&&0===i.movementY&&e++};document.addEventListener("mousemove",n,{passive:!0}),setTimeout(()=>{document.removeEventListener("mousemove",n)},5e3),t>10&&e/t>.9&&(i=!0)}catch(s){}return{suspicious:i,zeroMovementCount:e,totalEvents:t}}checkHairlineSupport(){try{const e=document.createElement("div");e.style.border=".5px solid transparent",e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e);const t=e.offsetHeight;return document.body.removeChild(e),{suspicious:0===t,offsetHeight:t}}catch(e){return{suspicious:!1,offsetHeight:-1}}}checkExtraFrameworks(){const e=[];try{const i=window.external;if(i&&"function"==typeof i.toString)try{const t=i.toString();/Sequentum/i.test(t)&&e.push("sequentum")}catch(t){}const s=["__webdriver_script_fn","__webdriver_script_func","__webdriver_evaluate","__selenium_evaluate","__fxdriver_evaluate","__driver_evaluate","__webdriver_unwrapped","__selenium_unwrapped","__fxdriver_unwrapped","__driver_unwrapped","_Selenium_IDE_Recorder","_selenium","calledSelenium","_WEBDRIVER_ELEM_CACHE","ChromeDriverw","driver-hierarchical","__$webdriverAsyncExecutor","__lastWatirAlert","__lastWatirConfirm","__lastWatirPrompt","_WEBDRIVER_ELEM_CACHE","webdriver","_phantom","__nightmare","_selenium"];for(const t of s)(t in document||t in window)&&e.push(`global_${t}`);const n=Object.getOwnPropertyNames(navigator);for(const t of n)/webdriver|selenium|puppeteer|playwright|phantom/i.test(t)&&e.push(`nav_${t}`)}catch(t){}return e}checkWorkerCDP(){return new Promise(e=>{try{const t=new Blob(["\n self.onmessage = function() {\n var detected = false;\n try {\n var marker = {};\n Object.defineProperty(marker, 'stack', {\n get: function() { detected = true; return ''; }\n });\n console.debug(marker);\n } catch(e) {}\n self.postMessage({ cdp: detected });\n };\n "],{type:"application/javascript"}),i=URL.createObjectURL(t),s=new Worker(i),n=setTimeout(()=>{s.terminate(),URL.revokeObjectURL(i),e({suspicious:!1})},3e3);s.onmessage=t=>{clearTimeout(n),s.terminate(),URL.revokeObjectURL(i),e({suspicious:!0===t.data.cdp})},s.onerror=()=>{clearTimeout(n),s.terminate(),URL.revokeObjectURL(i),e({suspicious:!1})},s.postMessage("check")}catch(t){e({suspicious:!1})}})}}class CrawlProtect{constructor(e){__publicField(this,"config"),__publicField(this,"renewTimer",null),__publicField(this,"verified",!1),this.config=e}async start(){const e=this.getToken();if(e&&!this.isExpired(e))return this.verified=!0,this.scheduleRenewal(e),this.revealContent(),this.config.debug,!0;this.hideContent();const t=await this.solveChallenge();return t?(this.verified=!0,this.revealContent()):this.config.insertHoneypot&&this.insertHoneypotData(),t}isVerified(){return this.verified}stop(){this.renewTimer&&(clearTimeout(this.renewTimer),this.renewTimer=null)}async solveChallenge(){try{const e=await fetch(`${this.config.apiBase}/crawl-protect/challenge`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId}});if(!e.ok)return!1;const{id:t,challenges:i}=await e.json(),s=[];for(const c of i)if("math"===c.type){const e="add"===c.op?c.a+c.b:c.a*c.b;s.push(String(e))}else if("crypto"===c.type){const e=await this.sha256(c.nonce);s.push(e.slice(0,8))}const n=s.join(":"),a=await this.getFingerprint(),r=await fetch(`${this.config.apiBase}/crawl-protect/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.config.clientId},body:JSON.stringify({id:t,solution:n,fingerprint:a}),credentials:"include"});if(!r.ok)return!1;const o=await r.json();return!(!o.success||!o.token)&&(this.setToken(o.token),this.scheduleRenewal(o.token),this.config.debug,!0)}catch(e){return this.config.debug,!1}}hideContent(){var e;if(null==(e=this.config.protectSelectors)?void 0:e.length)for(const t of this.config.protectSelectors){document.querySelectorAll(t).forEach(e=>{e.dataset.aieOrigDisplay=e.style.display,e.style.display="none"})}}revealContent(){var e;if(null==(e=this.config.protectSelectors)?void 0:e.length)for(const t of this.config.protectSelectors){document.querySelectorAll(t).forEach(e=>{e.style.display=e.dataset.aieOrigDisplay||"",delete e.dataset.aieOrigDisplay})}}insertHoneypotData(){const e=document.createElement("div");e.style.cssText="position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;",e.setAttribute("aria-hidden","true"),e.innerHTML='\n <span class="price" data-aie-honeypot="1">₩999,999,999</span>\n <span class="stock" data-aie-honeypot="1">재고: 0개</span>\n <a href="mailto:honeypot@aientrophy.com" data-aie-honeypot="1">contact</a>\n ',document.body.appendChild(e)}getToken(){const e=document.cookie.match(new RegExp("(?:^|; )__aie_token=([^;]*)"));return e?decodeURIComponent(e[1]):null}setToken(e){const t=new Date(Date.now()+18e5).toUTCString();document.cookie=`__aie_token=${encodeURIComponent(e)};path=/;expires=${t};SameSite=None;Secure`}isExpired(e){try{const[t]=e.split("."),i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));return Date.now()>i.exp}catch{return!0}}scheduleRenewal(e){try{const[t]=e.split("."),i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/"))),s=i.exp-3e5-Date.now();s>0&&(this.renewTimer=setTimeout(()=>this.solveChallenge(),s))}catch{}}async sha256(e){const t=new TextEncoder,i=await crypto.subtle.digest("SHA-256",t.encode(e));return Array.from(new Uint8Array(i)).map(e=>e.toString(16).padStart(2,"0")).join("")}async getFingerprint(){const e=[navigator.userAgent,navigator.language,screen.width+"x"+screen.height,Intl.DateTimeFormat().resolvedOptions().timeZone];return this.sha256(e.join("|"))}}const securitySDK=new class{constructor(){__publicField(this,"transmitter"),__publicField(this,"behaviorCollector"),__publicField(this,"rapidClickDetector"),__publicField(this,"honeypot"),__publicField(this,"mouseTracker"),__publicField(this,"canvasFingerprinter"),__publicField(this,"inputTracker"),__publicField(this,"challengeHandler"),__publicField(this,"invisibleInteraction"),__publicField(this,"automationDetector"),__publicField(this,"sessionAnalyzer"),__publicField(this,"tabNavigationAnalyzer"),__publicField(this,"cloudEnvironmentDetector"),__publicField(this,"crossContextDetector"),__publicField(this,"headlessProbeDetector"),__publicField(this,"crawlProtect",null),__publicField(this,"initialized",!1),__publicField(this,"wasmService"),__publicField(this,"callbackManager"),this.transmitter=new Transmitter,this.wasmService=new WasmService,this.callbackManager=new CallbackManager,this.transmitter.setCallbackManager(this.callbackManager),this.behaviorCollector=new BehaviorCollector(this.transmitter),this.rapidClickDetector=new RapidClickDetector(this.transmitter),this.honeypot=new Honeypot(this.transmitter),this.mouseTracker=new MouseTracker(this.transmitter,this.wasmService),this.canvasFingerprinter=new CanvasFingerprinter(this.transmitter,this.wasmService),this.inputTracker=new InputTracker(this.transmitter),this.invisibleInteraction=new InvisibleInteraction(this.transmitter),this.automationDetector=new AutomationDetector(this.transmitter),this.sessionAnalyzer=new SessionAnalyzer(this.transmitter),this.tabNavigationAnalyzer=new TabNavigationAnalyzer(this.transmitter),this.cloudEnvironmentDetector=new CloudEnvironmentDetector(this.transmitter),this.crossContextDetector=new CrossContextDetector(this.transmitter),this.headlessProbeDetector=new HeadlessProbeDetector(this.transmitter)}async init(e){var t,i;if(this.initialized)return;e.callbacks&&this.callbackManager.setConfigCallbacks(e.callbacks);const s=e.endpoint.replace(/\/events$/,"");try{await this.wasmService.load(s),this.startDetectors(),this.transmitter.setConfig(e),this.challengeHandler=new ChallengeHandler(s),this.challengeHandler.setCallbackManager(this.callbackManager),!1!==(null==(t=e.serverConfig)?void 0:t.captchaEnabled)&&this.challengeHandler.start();((null==(i=e.serverConfig)?void 0:i.devtoolsDetection)??!e.debug)&&Promise.resolve().then(()=>require("../anti-debug-u8v02mI_.cjs")).then(({AntiDebug:e})=>{e.start(),Promise.resolve().then(()=>require("../console-C5WWu7ZB.cjs")).then(({ConsoleDetector:e})=>{new e(()=>{this.transmitter.send("devtools_open",{detected:!0})}).start()})}),e.crawlProtect&&(this.crawlProtect=new CrawlProtect({apiBase:s,clientId:e.clientKey,protectSelectors:e.crawlProtect.protectSelectors,insertHoneypot:e.crawlProtect.insertHoneypot,debug:e.debug}),this.crawlProtect.start().catch(t=>{e.debug})),this.initialized=!0,e.debug,this.callbackManager.emit("ready")}catch(n){this.callbackManager.emit("error",{code:"INIT_ERROR",message:"SecuritySDK initialization failed",details:null==n?void 0:n.message})}}on(e,t){this.callbackManager.on(e,t)}off(e,t){this.callbackManager.off(e,t)}once(e,t){this.callbackManager.once(e,t)}startDetectors(){this.behaviorCollector.start(),this.honeypot.start(),this.mouseTracker.start(),this.canvasFingerprinter.start(),this.inputTracker.start(),this.invisibleInteraction.start(),this.automationDetector.start(),this.sessionAnalyzer.start(),this.tabNavigationAnalyzer.start(),this.cloudEnvironmentDetector.start(),this.crossContextDetector.start(),this.headlessProbeDetector.start()}};"undefined"!=typeof window&&(window.SecuritySDK=securitySDK);exports.Aientrophy=class{constructor(e){__publicField(this,"config"),this.config=e}async protect(){const e=this.config.endpoint||"https://api.aientrophy.com/api/v1/events";let t={};try{const s=e.replace(/\/events$/,""),n=await fetch(`${s}/sdk/payload?clientKey=${encodeURIComponent(this.config.clientKey)}`);if(n.ok){t=(await n.json()).config||{}}if(t.nonceValidation)try{const e=await fetch(`${s}/sdk/nonce?clientKey=${encodeURIComponent(this.config.clientKey)}`);if(e.ok){const i=await e.json();i.nonce&&(t.initialNonce=i.nonce)}}catch(i){this.config.debug}}catch(i){this.config.debug}await securitySDK.init({endpoint:e,clientKey:this.config.clientKey,debug:this.config.debug,callbacks:this.config.callbacks,crawlProtect:this.config.crawlProtect,serverConfig:t})}on(e,t){securitySDK.on(e,t)}off(e,t){securitySDK.off(e,t)}once(e,t){securitySDK.once(e,t)}};
|
package/dist/npm/index.es.js
CHANGED
|
@@ -2583,9 +2583,9 @@ class SecuritySDK {
|
|
|
2583
2583
|
}
|
|
2584
2584
|
const devtoolsEnabled = ((_b = config.serverConfig) == null ? void 0 : _b.devtoolsDetection) ?? !config.debug;
|
|
2585
2585
|
if (devtoolsEnabled) {
|
|
2586
|
-
import("../anti-debug-
|
|
2586
|
+
import("../anti-debug-CZyDVzB-.js").then(({ AntiDebug }) => {
|
|
2587
2587
|
AntiDebug.start();
|
|
2588
|
-
import("../console-
|
|
2588
|
+
import("../console-ZtBun_Tc.js").then(({ ConsoleDetector }) => {
|
|
2589
2589
|
new ConsoleDetector(() => {
|
|
2590
2590
|
this.transmitter.send("devtools_open", { detected: true });
|
|
2591
2591
|
}).start();
|
package/dist/sri-hashes.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generated": "2026-03-
|
|
2
|
+
"generated": "2026-03-20T06:49:58.845Z",
|
|
3
3
|
"algorithm": "sha384",
|
|
4
4
|
"hashes": {
|
|
5
|
-
"core.js": "sha384-
|
|
5
|
+
"core.js": "sha384-OXNYfgR4iw/yVw/bRHk3qEqB0VelDN5EubTQZe/ZwozBEik8XFZntt45EFIcBD7M",
|
|
6
6
|
"core.wasm": "sha384-fPJjZg5frGy3uptl1c6t4ekPOoQRQPquQVQEbrMf09T7mCur5iJVX4gGqkRfu93q",
|
|
7
7
|
"loader.js": "sha384-0v1eaWmQUDG7Xzh8ujnAFroO2azUb0n547CCqAL1opB0WUltJC8WMyV8e1XoKf2R"
|
|
8
8
|
}
|
|
@@ -8,5 +8,11 @@ export declare class AntiDebug {
|
|
|
8
8
|
private static saveConsole;
|
|
9
9
|
private static preventDevTools;
|
|
10
10
|
private static debuggerCheck;
|
|
11
|
+
/**
|
|
12
|
+
* Detect DevTools open via timing attack and close/redirect.
|
|
13
|
+
* When debugger statement is hit with DevTools open, execution pauses,
|
|
14
|
+
* causing measurable delay. If delay > threshold, DevTools is open.
|
|
15
|
+
*/
|
|
16
|
+
private static devtoolsCloseCheck;
|
|
11
17
|
private static disableConsole;
|
|
12
18
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__publicField=(e,t,o)=>((e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o)(e,"symbol"!=typeof t?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _originalConsole={};class AntiDebug{static start(){this.saveConsole(),this.disableConsole(),this.preventDevTools()}static stop(){this.intervalId&&clearInterval(this.intervalId)}static getOriginalConsole(){return _originalConsole}static saveConsole(){const e=["log","debug","info","warn","error","table","trace","dir","clear"];try{const t=window.console;if(!t)return;for(const o of e)"function"==typeof t[o]&&(_originalConsole[o]=t[o].bind(t))}catch(t){}}static preventDevTools(){this.intervalId=setInterval(()=>{this.debuggerCheck()},this.checkInterval)}static debuggerCheck(){!function(){try{(function(){}).constructor("debugger")()}catch(e){}}()}static disableConsole(){const e=()=>{},t=["log","debug","info","warn","error","table","trace","dir"];try{const o=window.console;if(!o)return;for(const i of t)o[i]&&(o[i]=e)}catch(o){}}}__publicField(AntiDebug,"checkInterval",1e3),__publicField(AntiDebug,"intervalId"),exports.AntiDebug=AntiDebug;
|
package/dist/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface CrawlProtectConfig {
|
|
2
|
-
protectSelectors?: string[];
|
|
3
|
-
insertHoneypot?: boolean;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface AientropyConfig {
|
|
7
|
-
clientKey: string;
|
|
8
|
-
endpoint?: string;
|
|
9
|
-
debug?: boolean;
|
|
10
|
-
crawlProtect?: CrawlProtectConfig;
|
|
11
|
-
callbacks?: Record<string, (...args: any[]) => void>;
|
|
12
|
-
serverConfig?: Record<string, any>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export declare class Aientrophy {
|
|
16
|
-
constructor(config: AientropyConfig);
|
|
17
|
-
protect(): void;
|
|
18
|
-
on(event: string, handler: (...args: any[]) => void): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default Aientrophy;
|