@quickcheck/device-intel-sdk 1.0.3 → 1.0.4
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/index.d.mts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/umd/umd.global.js +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavioral biometrics collector — keystroke dynamics + mouse patterns.
|
|
3
|
+
*
|
|
4
|
+
* Captures timing patterns that are unique to each person's motor behavior:
|
|
5
|
+
* - Keystroke dwell time (how long a key is held)
|
|
6
|
+
* - Keystroke flight time (time between releasing one key and pressing the next)
|
|
7
|
+
* - Mouse velocity and acceleration patterns
|
|
8
|
+
*
|
|
9
|
+
* These biometrics survive device changes: the same person types similarly
|
|
10
|
+
* on any keyboard. Conversely, different people using the SAME device have
|
|
11
|
+
* different patterns — enabling detection of account sharing or session
|
|
12
|
+
* hijacking even when the device fingerprint matches.
|
|
13
|
+
*
|
|
14
|
+
* Privacy: only aggregate statistics are sent (means, stds, counts).
|
|
15
|
+
* No raw keystroke content or mouse coordinates are captured.
|
|
16
|
+
*
|
|
17
|
+
* Academic basis: Monrose & Rubin 1997, Zheng et al. 2011.
|
|
18
|
+
*/
|
|
19
|
+
interface BehavioralSummary {
|
|
20
|
+
keystroke_dwell_mean_ms: number;
|
|
21
|
+
keystroke_dwell_std_ms: number;
|
|
22
|
+
keystroke_flight_mean_ms: number;
|
|
23
|
+
keystroke_flight_std_ms: number;
|
|
24
|
+
mouse_velocity_mean: number;
|
|
25
|
+
mouse_velocity_std: number;
|
|
26
|
+
mouse_acceleration_mean: number;
|
|
27
|
+
total_keystrokes: number;
|
|
28
|
+
total_mouse_events: number;
|
|
29
|
+
session_duration_ms: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
1
32
|
/**
|
|
2
33
|
* QuickCheck Device Intelligence SDK — TypeScript types.
|
|
3
34
|
*
|
|
@@ -177,6 +208,8 @@ interface DeviceIntelPayload {
|
|
|
177
208
|
* commercial device-identity products (FingerprintJS Pro, etc.).
|
|
178
209
|
*/
|
|
179
210
|
advanced?: AdvancedSignals | null;
|
|
211
|
+
/** Behavioral biometrics: keystroke + mouse dynamics summary (v1.0.4+) */
|
|
212
|
+
behavioral?: BehavioralSummary | null;
|
|
180
213
|
}
|
|
181
214
|
interface RiskInfo {
|
|
182
215
|
score: number;
|
|
@@ -258,6 +291,7 @@ declare class QuickCheckDeviceIntel {
|
|
|
258
291
|
private deviceSignals;
|
|
259
292
|
private privacySignals;
|
|
260
293
|
private advancedSignals;
|
|
294
|
+
private behavioralCollector;
|
|
261
295
|
private initialized;
|
|
262
296
|
private sessionUuid;
|
|
263
297
|
private geoWatchId;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavioral biometrics collector — keystroke dynamics + mouse patterns.
|
|
3
|
+
*
|
|
4
|
+
* Captures timing patterns that are unique to each person's motor behavior:
|
|
5
|
+
* - Keystroke dwell time (how long a key is held)
|
|
6
|
+
* - Keystroke flight time (time between releasing one key and pressing the next)
|
|
7
|
+
* - Mouse velocity and acceleration patterns
|
|
8
|
+
*
|
|
9
|
+
* These biometrics survive device changes: the same person types similarly
|
|
10
|
+
* on any keyboard. Conversely, different people using the SAME device have
|
|
11
|
+
* different patterns — enabling detection of account sharing or session
|
|
12
|
+
* hijacking even when the device fingerprint matches.
|
|
13
|
+
*
|
|
14
|
+
* Privacy: only aggregate statistics are sent (means, stds, counts).
|
|
15
|
+
* No raw keystroke content or mouse coordinates are captured.
|
|
16
|
+
*
|
|
17
|
+
* Academic basis: Monrose & Rubin 1997, Zheng et al. 2011.
|
|
18
|
+
*/
|
|
19
|
+
interface BehavioralSummary {
|
|
20
|
+
keystroke_dwell_mean_ms: number;
|
|
21
|
+
keystroke_dwell_std_ms: number;
|
|
22
|
+
keystroke_flight_mean_ms: number;
|
|
23
|
+
keystroke_flight_std_ms: number;
|
|
24
|
+
mouse_velocity_mean: number;
|
|
25
|
+
mouse_velocity_std: number;
|
|
26
|
+
mouse_acceleration_mean: number;
|
|
27
|
+
total_keystrokes: number;
|
|
28
|
+
total_mouse_events: number;
|
|
29
|
+
session_duration_ms: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
1
32
|
/**
|
|
2
33
|
* QuickCheck Device Intelligence SDK — TypeScript types.
|
|
3
34
|
*
|
|
@@ -177,6 +208,8 @@ interface DeviceIntelPayload {
|
|
|
177
208
|
* commercial device-identity products (FingerprintJS Pro, etc.).
|
|
178
209
|
*/
|
|
179
210
|
advanced?: AdvancedSignals | null;
|
|
211
|
+
/** Behavioral biometrics: keystroke + mouse dynamics summary (v1.0.4+) */
|
|
212
|
+
behavioral?: BehavioralSummary | null;
|
|
180
213
|
}
|
|
181
214
|
interface RiskInfo {
|
|
182
215
|
score: number;
|
|
@@ -258,6 +291,7 @@ declare class QuickCheckDeviceIntel {
|
|
|
258
291
|
private deviceSignals;
|
|
259
292
|
private privacySignals;
|
|
260
293
|
private advancedSignals;
|
|
294
|
+
private behavioralCollector;
|
|
261
295
|
private initialized;
|
|
262
296
|
private sessionUuid;
|
|
263
297
|
private geoWatchId;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var G=Object.create;var m=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var n in e)m(t,n,{get:e[n],enumerable:!0})},w=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of U(e))!M.call(t,o)&&o!==n&&m(t,o,{get:()=>e[o],enumerable:!(i=T(e,o))||i.enumerable});return t};var H=(t,e,n)=>(n=t!=null?G(L(t)):{},w(e||!t||!t.__esModule?m(n,"default",{value:t,enumerable:!0}):n,t)),O=t=>w(m({},"__esModule",{value:!0}),t);var te={};N(te,{QCApiClient:()=>p,QuickCheckDeviceIntel:()=>f,QuickCheckError:()=>g,SDK_VERSION:()=>_});module.exports=O(te);var g=class extends Error{constructor(n,i,o,r){super(n);this.code=i;this.status=o;this.details=r;this.name="QuickCheckError"}};var W="https://api.quickcheck.com.pa",$="/api/v1/sdk/device-intel/assess";function K(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let t=Math.random().toString(36).slice(2);return`${Date.now().toString(36)}-${t}`}var p=class{constructor(e){if(!e.apiKey)throw new g("apiKey is required","MISSING_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??W).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let n=`${this.apiUrl}${$}`,i=new AbortController,o=setTimeout(()=>i.abort(),this.timeout),r=K(),c=new Date().toISOString(),s;try{s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-QC-SDK-Key":this.apiKey,"X-QC-SDK-Platform":e.platform,"X-QC-Nonce":r,"X-QC-Timestamp":c},body:JSON.stringify(e),signal:i.signal})}catch(u){throw clearTimeout(o),u.name==="AbortError"?new g(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new g(`Network error: ${u.message}`,"NETWORK_ERROR",void 0,u)}clearTimeout(o);let a;try{a=await s.json()}catch{throw new g(`Invalid JSON response (status ${s.status})`,"INVALID_RESPONSE",s.status)}if(!s.ok){let u=typeof a=="object"&&a!==null&&"detail"in a?String(a.detail):`HTTP ${s.status}`,l=s.status===401?"UNAUTHORIZED":s.status===403?"FORBIDDEN":s.status===429?"RATE_LIMITED":"HTTP_ERROR";throw new g(u,l,s.status,a)}return a}};function S(){let t=typeof navigator<"u"?navigator:{},e=typeof window<"u"?window.screen:null,n=e?`${e.width}x${e.height}`:null,i=null,o=null;try{i=new Date().getTimezoneOffset(),o=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}let r=(t.userAgent||"").toLowerCase(),c="desktop";/mobi|iphone|ipod|android/.test(r)?c="mobile":/ipad|tablet/.test(r)&&(c="tablet");let s="Unknown",a=null;if(/windows nt/.test(r)){s="Windows";let l=r.match(/windows nt ([\d.]+)/);a=l?l[1]:null}else if(/mac os x/.test(r)){s="macOS";let l=r.match(/mac os x ([\d_.]+)/);a=l?l[1].replace(/_/g,"."):null}else if(/android/.test(r)){s="Android";let l=r.match(/android ([\d.]+)/);a=l?l[1]:null}else if(/iphone|ipad|ipod/.test(r)){s="iOS";let l=r.match(/os ([\d_]+) like mac/);a=l?l[1].replace(/_/g,"."):null}else/linux/.test(r)&&(s="Linux");let u=t.deviceMemory??null;return{type:c,os_name:s,os_version:a,screen_resolution:n,language:t.language??null,languages:t.languages?Array.from(t.languages):[],timezone_offset:i,timezone_name:o,hardware_concurrency:t.hardwareConcurrency??null,device_memory_gb:u,touch_support:typeof window<"u"&&("ontouchstart"in window||(t.maxTouchPoints??0)>0)}}async function x(){try{let e=await(await import("@thumbmarkjs/thumbmarkjs")).getFingerprint();return typeof e=="string"?e:e&&typeof e.thumbmark=="string"?e.thumbmark:I()}catch{return I()}}function I(){let e=[typeof navigator<"u"?navigator.userAgent:"",typeof navigator<"u"?navigator.language:"",typeof screen<"u"?`${screen.width}x${screen.height}`:"",typeof screen<"u"?String(screen.colorDepth):"",String(new Date().getTimezoneOffset()),typeof navigator<"u"?String(navigator.hardwareConcurrency??""):""].join("|"),n=0;for(let i=0;i<e.length;i++)n=(n<<5)-n+e.charCodeAt(i),n|=0;return"qc_fb_"+Math.abs(n).toString(16).padStart(8,"0")}async function C(t=1e4){return typeof navigator>"u"||!navigator.geolocation?null:new Promise(e=>{let n=setTimeout(()=>e(null),t);navigator.geolocation.getCurrentPosition(i=>{clearTimeout(n),e({latitude:i.coords.latitude,longitude:i.coords.longitude,accuracy_m:Math.round(i.coords.accuracy),source:"gps"})},()=>{clearTimeout(n),e(null)},{enableHighAccuracy:!1,timeout:t,maximumAge:6e4})})}function E(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function y(t=3e3){let e={ipv4:null,ipv6:null,all_v4:[],all_v6:[],method:"webrtc_stun"};return typeof RTCPeerConnection>"u"?e:new Promise(n=>{let i=new Set,o=new Set,r=!1,c=()=>{if(!r){r=!0;try{a.close()}catch{}e.all_v4=[...i],e.all_v6=[...o],e.ipv4=e.all_v4[0]??null,e.ipv6=e.all_v6[0]??null,n(e)}},s=setTimeout(c,t),a;try{a=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]}),a.createDataChannel("ip-discovery"),a.onicecandidate=u=>{if(!u.candidate){clearTimeout(s),c();return}let l=u.candidate.candidate;if(!l.includes("srflx"))return;let b=l.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/);if(b){let d=b[1];!d.startsWith("10.")&&!d.startsWith("192.168.")&&!d.startsWith("172.16.")&&!d.startsWith("172.17.")&&!d.startsWith("172.18.")&&!d.startsWith("172.19.")&&!d.startsWith("172.2")&&!d.startsWith("172.30.")&&!d.startsWith("172.31.")&&!d.startsWith("127.")&&i.add(d)}let h=l.match(/([a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})/i);h&&!h[1].startsWith("fe80")&&o.add(h[1])},a.createOffer().then(u=>a.setLocalDescription(u)).catch(()=>{clearTimeout(s),c()})}catch{clearTimeout(s),n(e)}})}async function R(t=2e3){let e=await y(t);return[...e.all_v4,...e.all_v6]}async function P(){let t=V(),e=z(),n=await F(),i=await R(1500);return{is_incognito:n,webgl_renderer:t,canvas_hash:e,local_ips:i}}function V(){try{let t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return null;let n=e.getExtension("WEBGL_debug_renderer_info");return n?e.getParameter(n.UNMASKED_RENDERER_WEBGL):null}catch{return null}}function z(){try{let t=document.createElement("canvas");t.width=220,t.height=60;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="14px Arial",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("QuickCheck Device Intelligence",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("QuickCheck Device Intelligence",4,17);let n=t.toDataURL(),i=0;for(let o=0;o<n.length;o++){let r=n.charCodeAt(o);i=(i<<5)-i+r,i|=0}return i.toString(16)}catch{return null}}async function F(){try{let t=navigator;if(t.storage?.estimate){let{quota:e}=await t.storage.estimate();if(typeof e=="number")return e<120*1024*1024}}catch{}return null}function Q(){try{return{acos04:Math.acos(.4),asin04:Math.asin(.4),atan04:Math.atan(.4),atanh04:Math.atanh(.4),cbrt100:Math.cbrt(100),cosh1:Math.cosh(1),expm11:Math.expm1(1),log1p10:Math.log1p(10),sinh1:Math.sinh(1),tanh1:Math.tanh(1),pow1_1e100:Math.pow(1.1,100)}}catch{return{}}}async function q(){try{let t=document.createElement("canvas");t.width=200,t.height=40;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="18px sans-serif",e.fillText("\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}\u{1F1F5}\u{1F1E6}\u{1F44D}\u{1F3FD}\u{1FAE1}",2,2);let n=t.toDataURL();return J(n)}catch{return null}}function B(){try{if(!("speechSynthesis"in window))return{count:0,fingerprint:null};let t=window.speechSynthesis.getVoices();if(!t||t.length===0)return{count:0,fingerprint:null};let e=t.map(n=>`${n.name}|${n.lang}|${n.localService?"L":"R"}`).sort().join(",");return{count:t.length,fingerprint:v(e)}}catch{return{count:0,fingerprint:null}}}async function j(){let t={audioinput:0,audiooutput:0,videoinput:0};try{if(!navigator.mediaDevices?.enumerateDevices)return t;let e=await navigator.mediaDevices.enumerateDevices();for(let n of e)n.kind==="audioinput"?t.audioinput++:n.kind==="audiooutput"?t.audiooutput++:n.kind==="videoinput"&&t.videoinput++}catch{}return t}function X(){try{let t=new Intl.DateTimeFormat().resolvedOptions();return`${t.locale}|${t.calendar}|${t.numberingSystem}|${t.hourCycle??"-"}|${t.timeZone}`}catch{return null}}async function Y(){try{let t=navigator.keyboard;if(!t?.getLayoutMap)return null;let e=await t.getLayoutMap(),n=[];for(let[i,o]of e.entries())n.push(`${i}=${o}`);return v(n.sort().join("|"))}catch{return null}}function Z(){let t={vendor:null,renderer:null,extensions:[],shaderPrecision:null};try{let e=document.createElement("canvas"),n=e.getContext("webgl")||e.getContext("experimental-webgl");if(!n)return t;let i=n.getExtension("WEBGL_debug_renderer_info");i&&(t.vendor=n.getParameter(i.UNMASKED_VENDOR_WEBGL),t.renderer=n.getParameter(i.UNMASKED_RENDERER_WEBGL)),t.extensions=n.getSupportedExtensions()??[];let o=n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT),r=n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT);o&&r&&(t.shaderPrecision=`v:${o.rangeMin}/${o.rangeMax}/${o.precision};f:${r.rangeMin}/${r.rangeMax}/${r.precision}`)}catch{}return t}function v(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}async function J(t){try{let e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),i=new Uint8Array(n),o="";for(let r=0;r<16;r++)o+=i[r].toString(16).padStart(2,"0");return o}catch{return v(t)}}async function ee(){try{let t=navigator.userAgentData;if(!t?.getHighEntropyValues)return null;let e=await t.getHighEntropyValues(["platform","platformVersion","architecture","bitness","model","fullVersionList","wow64"]);return{platform:e.platform,platformVersion:e.platformVersion,architecture:e.architecture,bitness:e.bitness,model:e.model,fullVersionList:e.fullVersionList,mobile:t.mobile,wow64:e.wow64}}catch{return null}}async function k(){let[t,e,n,i]=await Promise.all([q(),j(),Y(),ee()]);return{math_constants:Q(),emoji_hash:t,speech_voices:B(),media_devices:e,intl_signature:X(),keyboard_layout_hash:n,webgl_advanced:Z(),client_hints:i}}var _="1.0.0",D="qcdi_session_uuid",A="qcdi_previous_page",f=class{constructor(e){this.deviceSignals=null;this.privacySignals=null;this.advancedSignals=null;this.initialized=!1;this.sessionUuid="";this.geoWatchId=null;this.geoHistory=[];this.lastGeoLat=null;this.lastGeoLon=null;this.clientIpv4=null;this.clientIpv6=null;this.config={apiKey:e.apiKey,apiUrl:e.apiUrl??"https://api.quickcheck.com.pa",autoCollect:e.autoCollect??!0,requestGeolocation:e.requestGeolocation??!1,continuousGeolocation:e.continuousGeolocation??!1,timeout:e.timeout??5e3,onError:e.onError??(n=>console.error("[QCDI]",n)),debug:e.debug??!1},this.client=new p({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,timeout:this.config.timeout}),this.sessionUuid=this.resolveSessionUuid(),this.config.autoCollect&&this.initialize()}resolveSessionUuid(){try{let e=sessionStorage.getItem(D);if(e)return e;let n=this.generateUuid();return sessionStorage.setItem(D,n),n}catch{return this.generateUuid()}}generateUuid(){let e="0123456789abcdef",n="qcdis-";for(let i=0;i<32;i++)n+=e[Math.floor(Math.random()*16)],(i===7||i===11||i===15||i===19)&&(n+="-");return n}async initialize(){if(!this.initialized){this.config.debug&&console.log("[QCDI] Initializing...");try{let e=await x(),n=S();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...n},this.privacySignals=await P(),this.advancedSignals=await k();let i=await y(2e3);this.clientIpv4=i.ipv4,this.clientIpv6=i.ipv6,this.initialized=!0,this.config.continuousGeolocation&&this.config.requestGeolocation&&this.startContinuousGeolocation(),this.config.debug&&console.log("[QCDI] Initialized",{fingerprint:e,session_uuid:this.sessionUuid,ipv4:this.clientIpv4,ipv6:this.clientIpv6})}catch(e){this.config.onError(e)}}}startContinuousGeolocation(){typeof navigator>"u"||!navigator.geolocation||this.geoWatchId===null&&(this.geoWatchId=navigator.geolocation.watchPosition(e=>{let{latitude:n,longitude:i,accuracy:o}=e.coords;this.lastGeoLat!==null&&this.lastGeoLon!==null&&this.haversineMeters(this.lastGeoLat,this.lastGeoLon,n,i)<50||(this.lastGeoLat=n,this.lastGeoLon=i,this.geoHistory.push({latitude:n,longitude:i,accuracy_m:Math.round(o),timestamp:new Date().toISOString()}),this.geoHistory.length>100&&(this.geoHistory=this.geoHistory.slice(-100)))},e=>{this.config.debug&&console.warn("[QCDI] Geo watch error:",e)},{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e4}))}haversineMeters(e,n,i,o){let c=l=>l*Math.PI/180,s=c(i-e),a=c(o-n),u=Math.sin(s/2)**2+Math.cos(c(e))*Math.cos(c(i))*Math.sin(a/2)**2;return 2*6371e3*Math.asin(Math.sqrt(u))}getPreviousPageUrl(){try{if(typeof document<"u"&&document.referrer)return document.referrer.slice(0,500)}catch{}return null}getFlowFromUrl(){try{let e=sessionStorage.getItem(A);return typeof window<"u"&&sessionStorage.setItem(A,window.location.href.slice(0,500)),e}catch{return null}}async assess(e){if(await this.initialize(),!this.deviceSignals)throw new Error("Device signals not collected. Call initialize() first.");let n=null;this.config.continuousGeolocation&&this.lastGeoLat!==null?n={latitude:this.lastGeoLat,longitude:this.lastGeoLon,accuracy_m:null,source:"gps"}:this.config.requestGeolocation&&(n=await C());let i={sdk_version:_,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:E(),privacy:this.privacySignals,geolocation:n,advanced:this.advancedSignals,context:{external_user_id:e.externalUserId??null,external_session_id:e.externalSessionId??null,declared_country:e.declaredCountry??null,person_name:e.personName??null,person_document_id:e.personDocumentId??null,custom_fields:e.customFields??{},previous_page_url:this.getPreviousPageUrl(),flow_from_url:this.getFlowFromUrl(),session_uuid:this.sessionUuid,geolocation_history:this.geoHistory.slice(),client_ipv4:this.clientIpv4,client_ipv6:this.clientIpv6,app_session_id:e.appSessionId??null}};this.config.debug&&console.log("[QCDI] Assessing",i);try{let o=await this.client.assess(i);return this.config.debug&&console.log("[QCDI] Result",o),o}catch(o){throw this.config.onError(o),o}}async refresh(){this.initialized=!1,await this.initialize()}destroy(){this.geoWatchId!==null&&typeof navigator<"u"&&navigator.geolocation.clearWatch(this.geoWatchId),this.geoWatchId=null,this.geoHistory=[],this.deviceSignals=null,this.privacySignals=null,this.initialized=!1}};0&&(module.exports={QCApiClient,QuickCheckDeviceIntel,QuickCheckError,SDK_VERSION});
|
|
1
|
+
"use strict";var G=Object.create;var h=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var O=(n,e)=>{for(var t in e)h(n,t,{get:e[t],enumerable:!0})},I=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of N(e))!H.call(n,i)&&i!==t&&h(n,i,{get:()=>e[i],enumerable:!(o=U(e,i))||o.enumerable});return n};var W=(n,e,t)=>(t=n!=null?G(K(n)):{},I(e||!n||!n.__esModule?h(t,"default",{value:n,enumerable:!0}):t,n)),$=n=>I(h({},"__esModule",{value:!0}),n);var ie={};O(ie,{QCApiClient:()=>g,QuickCheckDeviceIntel:()=>y,QuickCheckError:()=>d,SDK_VERSION:()=>S});module.exports=$(ie);var d=class extends Error{constructor(t,o,i,r){super(t);this.code=o;this.status=i;this.details=r;this.name="QuickCheckError"}};var V="https://api.quickcheck.com.pa",z="/api/v1/sdk/device-intel/assess";function F(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let n=Math.random().toString(36).slice(2);return`${Date.now().toString(36)}-${n}`}var g=class{constructor(e){if(!e.apiKey)throw new d("apiKey is required","MISSING_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??V).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let t=`${this.apiUrl}${z}`,o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),r=F(),c=new Date().toISOString(),s;try{s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-QC-SDK-Key":this.apiKey,"X-QC-SDK-Platform":e.platform,"X-QC-Nonce":r,"X-QC-Timestamp":c},body:JSON.stringify(e),signal:o.signal})}catch(u){throw clearTimeout(i),u.name==="AbortError"?new d(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new d(`Network error: ${u.message}`,"NETWORK_ERROR",void 0,u)}clearTimeout(i);let a;try{a=await s.json()}catch{throw new d(`Invalid JSON response (status ${s.status})`,"INVALID_RESPONSE",s.status)}if(!s.ok){let u=typeof a=="object"&&a!==null&&"detail"in a?String(a.detail):`HTTP ${s.status}`,l=s.status===401?"UNAUTHORIZED":s.status===403?"FORBIDDEN":s.status===429?"RATE_LIMITED":"HTTP_ERROR";throw new d(u,l,s.status,a)}return a}};function x(){let n=typeof navigator<"u"?navigator:{},e=typeof window<"u"?window.screen:null,t=e?`${e.width}x${e.height}`:null,o=null,i=null;try{o=new Date().getTimezoneOffset(),i=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}let r=(n.userAgent||"").toLowerCase(),c="desktop";/mobi|iphone|ipod|android/.test(r)?c="mobile":/ipad|tablet/.test(r)&&(c="tablet");let s="Unknown",a=null;if(/windows nt/.test(r)){s="Windows";let l=r.match(/windows nt ([\d.]+)/);a=l?l[1]:null}else if(/mac os x/.test(r)){s="macOS";let l=r.match(/mac os x ([\d_.]+)/);a=l?l[1].replace(/_/g,"."):null}else if(/android/.test(r)){s="Android";let l=r.match(/android ([\d.]+)/);a=l?l[1]:null}else if(/iphone|ipad|ipod/.test(r)){s="iOS";let l=r.match(/os ([\d_]+) like mac/);a=l?l[1].replace(/_/g,"."):null}else/linux/.test(r)&&(s="Linux");let u=n.deviceMemory??null;return{type:c,os_name:s,os_version:a,screen_resolution:t,language:n.language??null,languages:n.languages?Array.from(n.languages):[],timezone_offset:o,timezone_name:i,hardware_concurrency:n.hardwareConcurrency??null,device_memory_gb:u,touch_support:typeof window<"u"&&("ontouchstart"in window||(n.maxTouchPoints??0)>0)}}async function C(){try{let e=await(await import("@thumbmarkjs/thumbmarkjs")).getFingerprint();return typeof e=="string"?e:e&&typeof e.thumbmark=="string"?e.thumbmark:E()}catch{return E()}}function E(){let e=[typeof navigator<"u"?navigator.userAgent:"",typeof navigator<"u"?navigator.language:"",typeof screen<"u"?`${screen.width}x${screen.height}`:"",typeof screen<"u"?String(screen.colorDepth):"",String(new Date().getTimezoneOffset()),typeof navigator<"u"?String(navigator.hardwareConcurrency??""):""].join("|"),t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return"qc_fb_"+Math.abs(t).toString(16).padStart(8,"0")}async function A(n=1e4){return typeof navigator>"u"||!navigator.geolocation?null:new Promise(e=>{let t=setTimeout(()=>e(null),n);navigator.geolocation.getCurrentPosition(o=>{clearTimeout(t),e({latitude:o.coords.latitude,longitude:o.coords.longitude,accuracy_m:Math.round(o.coords.accuracy),source:"gps"})},()=>{clearTimeout(t),e(null)},{enableHighAccuracy:!1,timeout:n,maximumAge:6e4})})}function R(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function _(n=3e3){let e={ipv4:null,ipv6:null,all_v4:[],all_v6:[],method:"webrtc_stun"};return typeof RTCPeerConnection>"u"?e:new Promise(t=>{let o=new Set,i=new Set,r=!1,c=()=>{if(!r){r=!0;try{a.close()}catch{}e.all_v4=[...o],e.all_v6=[...i],e.ipv4=e.all_v4[0]??null,e.ipv6=e.all_v6[0]??null,t(e)}},s=setTimeout(c,n),a;try{a=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]}),a.createDataChannel("ip-discovery"),a.onicecandidate=u=>{if(!u.candidate){clearTimeout(s),c();return}let l=u.candidate.candidate;if(!l.includes("srflx"))return;let k=l.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/);if(k){let m=k[1];!m.startsWith("10.")&&!m.startsWith("192.168.")&&!m.startsWith("172.16.")&&!m.startsWith("172.17.")&&!m.startsWith("172.18.")&&!m.startsWith("172.19.")&&!m.startsWith("172.2")&&!m.startsWith("172.30.")&&!m.startsWith("172.31.")&&!m.startsWith("127.")&&o.add(m)}let v=l.match(/([a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})/i);v&&!v[1].startsWith("fe80")&&i.add(v[1])},a.createOffer().then(u=>a.setLocalDescription(u)).catch(()=>{clearTimeout(s),c()})}catch{clearTimeout(s),t(e)}})}async function D(n=2e3){let e=await _(n);return[...e.all_v4,...e.all_v6]}async function P(){let n=Q(),e=q(),t=await B(),o=await D(1500);return{is_incognito:t,webgl_renderer:n,canvas_hash:e,local_ips:o}}function Q(){try{let n=document.createElement("canvas"),e=n.getContext("webgl")||n.getContext("experimental-webgl");if(!e)return null;let t=e.getExtension("WEBGL_debug_renderer_info");return t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):null}catch{return null}}function q(){try{let n=document.createElement("canvas");n.width=220,n.height=60;let e=n.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="14px Arial",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("QuickCheck Device Intelligence",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("QuickCheck Device Intelligence",4,17);let t=n.toDataURL(),o=0;for(let i=0;i<t.length;i++){let r=t.charCodeAt(i);o=(o<<5)-o+r,o|=0}return o.toString(16)}catch{return null}}async function B(){try{let n=navigator;if(n.storage?.estimate){let{quota:e}=await n.storage.estimate();if(typeof e=="number")return e<120*1024*1024}}catch{}return null}function j(){try{return{acos04:Math.acos(.4),asin04:Math.asin(.4),atan04:Math.atan(.4),atanh04:Math.atanh(.4),cbrt100:Math.cbrt(100),cosh1:Math.cosh(1),expm11:Math.expm1(1),log1p10:Math.log1p(10),sinh1:Math.sinh(1),tanh1:Math.tanh(1),pow1_1e100:Math.pow(1.1,100)}}catch{return{}}}async function X(){try{let n=document.createElement("canvas");n.width=200,n.height=40;let e=n.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="18px sans-serif",e.fillText("\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}\u{1F1F5}\u{1F1E6}\u{1F44D}\u{1F3FD}\u{1FAE1}",2,2);let t=n.toDataURL();return ne(t)}catch{return null}}function Y(){try{if(!("speechSynthesis"in window))return{count:0,fingerprint:null};let n=window.speechSynthesis.getVoices();if(!n||n.length===0)return{count:0,fingerprint:null};let e=n.map(t=>`${t.name}|${t.lang}|${t.localService?"L":"R"}`).sort().join(",");return{count:n.length,fingerprint:b(e)}}catch{return{count:0,fingerprint:null}}}async function Z(){let n={audioinput:0,audiooutput:0,videoinput:0};try{if(!navigator.mediaDevices?.enumerateDevices)return n;let e=await navigator.mediaDevices.enumerateDevices();for(let t of e)t.kind==="audioinput"?n.audioinput++:t.kind==="audiooutput"?n.audiooutput++:t.kind==="videoinput"&&n.videoinput++}catch{}return n}function J(){try{let n=new Intl.DateTimeFormat().resolvedOptions();return`${n.locale}|${n.calendar}|${n.numberingSystem}|${n.hourCycle??"-"}|${n.timeZone}`}catch{return null}}async function ee(){try{let n=navigator.keyboard;if(!n?.getLayoutMap)return null;let e=await n.getLayoutMap(),t=[];for(let[o,i]of e.entries())t.push(`${o}=${i}`);return b(t.sort().join("|"))}catch{return null}}function te(){let n={vendor:null,renderer:null,extensions:[],shaderPrecision:null};try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return n;let o=t.getExtension("WEBGL_debug_renderer_info");o&&(n.vendor=t.getParameter(o.UNMASKED_VENDOR_WEBGL),n.renderer=t.getParameter(o.UNMASKED_RENDERER_WEBGL)),n.extensions=t.getSupportedExtensions()??[];let i=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT),r=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);i&&r&&(n.shaderPrecision=`v:${i.rangeMin}/${i.rangeMax}/${i.precision};f:${r.rangeMin}/${r.rangeMax}/${r.precision}`)}catch{}return n}function b(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}async function ne(n){try{let e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e),o=new Uint8Array(t),i="";for(let r=0;r<16;r++)i+=o[r].toString(16).padStart(2,"0");return i}catch{return b(n)}}async function oe(){try{let n=navigator.userAgentData;if(!n?.getHighEntropyValues)return null;let e=await n.getHighEntropyValues(["platform","platformVersion","architecture","bitness","model","fullVersionList","wow64"]);return{platform:e.platform,platformVersion:e.platformVersion,architecture:e.architecture,bitness:e.bitness,model:e.model,fullVersionList:e.fullVersionList,mobile:n.mobile,wow64:e.wow64}}catch{return null}}async function M(){let[n,e,t,o]=await Promise.all([X(),Z(),ee(),oe()]);return{math_constants:j(),emoji_hash:n,speech_voices:Y(),media_devices:e,intl_signature:J(),keyboard_layout_hash:t,webgl_advanced:te(),client_hints:o}}var f=class{constructor(){this.keyEvents=[];this.mouseSamples=[];this.startTime=0;this.active=!1;this.mouseThrottleMs=50;this.lastMouseSample=0;this.onKeyDown=e=>{this.active&&this.keyEvents.push({code:e.code,downAt:performance.now()})};this.onKeyUp=e=>{if(!this.active)return;let t=[...this.keyEvents].reverse().find(o=>o.code===e.code&&!o.upAt);t&&(t.upAt=performance.now())};this.onMouseMove=e=>{if(!this.active)return;let t=performance.now();t-this.lastMouseSample<this.mouseThrottleMs||(this.lastMouseSample=t,this.mouseSamples.push({x:e.clientX,y:e.clientY,t}))}}start(){this.active||(this.active=!0,this.startTime=performance.now(),this.keyEvents=[],this.mouseSamples=[],document.addEventListener("keydown",this.onKeyDown,{passive:!0}),document.addEventListener("keyup",this.onKeyUp,{passive:!0}),document.addEventListener("mousemove",this.onMouseMove,{passive:!0}))}stop(){this.active=!1,document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mousemove",this.onMouseMove);let e=performance.now()-this.startTime;return{...this.computeKeystrokeMetrics(),...this.computeMouseMetrics(),total_keystrokes:this.keyEvents.filter(t=>t.upAt).length,total_mouse_events:this.mouseSamples.length,session_duration_ms:Math.round(e)}}computeKeystrokeMetrics(){let e=this.keyEvents.filter(i=>i.upAt);if(e.length<3)return{keystroke_dwell_mean_ms:0,keystroke_dwell_std_ms:0,keystroke_flight_mean_ms:0,keystroke_flight_std_ms:0};let t=e.map(i=>i.upAt-i.downAt),o=[];for(let i=1;i<e.length;i++){let r=e[i].downAt-(e[i-1].upAt??e[i-1].downAt);r>0&&r<2e3&&o.push(r)}return{keystroke_dwell_mean_ms:p(t),keystroke_dwell_std_ms:w(t),keystroke_flight_mean_ms:o.length>0?p(o):0,keystroke_flight_std_ms:o.length>0?w(o):0}}computeMouseMetrics(){if(this.mouseSamples.length<5)return{mouse_velocity_mean:0,mouse_velocity_std:0,mouse_acceleration_mean:0};let e=[];for(let o=1;o<this.mouseSamples.length;o++){let i=this.mouseSamples[o].x-this.mouseSamples[o-1].x,r=this.mouseSamples[o].y-this.mouseSamples[o-1].y,c=this.mouseSamples[o].t-this.mouseSamples[o-1].t;c>0&&e.push(Math.sqrt(i*i+r*r)/c)}let t=[];for(let o=1;o<e.length;o++){let i=this.mouseSamples[o+1].t-this.mouseSamples[o].t;i>0&&t.push(Math.abs(e[o]-e[o-1])/i)}return{mouse_velocity_mean:e.length>0?p(e):0,mouse_velocity_std:e.length>0?w(e):0,mouse_acceleration_mean:t.length>0?p(t):0}}};function p(n){return n.length===0?0:n.reduce((e,t)=>e+t,0)/n.length}function w(n){if(n.length<2)return 0;let e=p(n),t=n.reduce((o,i)=>o+(i-e)**2,0)/(n.length-1);return Math.sqrt(t)}var S="1.0.0",T="qcdi_session_uuid",L="qcdi_previous_page",y=class{constructor(e){this.deviceSignals=null;this.privacySignals=null;this.advancedSignals=null;this.behavioralCollector=null;this.initialized=!1;this.sessionUuid="";this.geoWatchId=null;this.geoHistory=[];this.lastGeoLat=null;this.lastGeoLon=null;this.clientIpv4=null;this.clientIpv6=null;this.config={apiKey:e.apiKey,apiUrl:e.apiUrl??"https://api.quickcheck.com.pa",autoCollect:e.autoCollect??!0,requestGeolocation:e.requestGeolocation??!1,continuousGeolocation:e.continuousGeolocation??!1,timeout:e.timeout??5e3,onError:e.onError??(t=>console.error("[QCDI]",t)),debug:e.debug??!1},this.client=new g({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,timeout:this.config.timeout}),this.sessionUuid=this.resolveSessionUuid(),this.config.autoCollect&&this.initialize()}resolveSessionUuid(){try{let e=sessionStorage.getItem(T);if(e)return e;let t=this.generateUuid();return sessionStorage.setItem(T,t),t}catch{return this.generateUuid()}}generateUuid(){let e="0123456789abcdef",t="qcdis-";for(let o=0;o<32;o++)t+=e[Math.floor(Math.random()*16)],(o===7||o===11||o===15||o===19)&&(t+="-");return t}async initialize(){if(!this.initialized){this.config.debug&&console.log("[QCDI] Initializing...");try{let e=await C(),t=x();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...t},this.privacySignals=await P(),this.advancedSignals=await M();let o=await _(2e3);this.clientIpv4=o.ipv4,this.clientIpv6=o.ipv6,this.initialized=!0,this.behavioralCollector=new f,this.behavioralCollector.start(),this.config.continuousGeolocation&&this.config.requestGeolocation&&this.startContinuousGeolocation(),this.config.debug&&console.log("[QCDI] Initialized",{fingerprint:e,session_uuid:this.sessionUuid,ipv4:this.clientIpv4,ipv6:this.clientIpv6})}catch(e){this.config.onError(e)}}}startContinuousGeolocation(){typeof navigator>"u"||!navigator.geolocation||this.geoWatchId===null&&(this.geoWatchId=navigator.geolocation.watchPosition(e=>{let{latitude:t,longitude:o,accuracy:i}=e.coords;this.lastGeoLat!==null&&this.lastGeoLon!==null&&this.haversineMeters(this.lastGeoLat,this.lastGeoLon,t,o)<50||(this.lastGeoLat=t,this.lastGeoLon=o,this.geoHistory.push({latitude:t,longitude:o,accuracy_m:Math.round(i),timestamp:new Date().toISOString()}),this.geoHistory.length>100&&(this.geoHistory=this.geoHistory.slice(-100)))},e=>{this.config.debug&&console.warn("[QCDI] Geo watch error:",e)},{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e4}))}haversineMeters(e,t,o,i){let c=l=>l*Math.PI/180,s=c(o-e),a=c(i-t),u=Math.sin(s/2)**2+Math.cos(c(e))*Math.cos(c(o))*Math.sin(a/2)**2;return 2*6371e3*Math.asin(Math.sqrt(u))}getPreviousPageUrl(){try{if(typeof document<"u"&&document.referrer)return document.referrer.slice(0,500)}catch{}return null}getFlowFromUrl(){try{let e=sessionStorage.getItem(L);return typeof window<"u"&&sessionStorage.setItem(L,window.location.href.slice(0,500)),e}catch{return null}}async assess(e){if(await this.initialize(),!this.deviceSignals)throw new Error("Device signals not collected. Call initialize() first.");let t=null;this.config.continuousGeolocation&&this.lastGeoLat!==null?t={latitude:this.lastGeoLat,longitude:this.lastGeoLon,accuracy_m:null,source:"gps"}:this.config.requestGeolocation&&(t=await A());let o={sdk_version:S,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:R(),privacy:this.privacySignals,geolocation:t,advanced:this.advancedSignals,behavioral:this.behavioralCollector?this.behavioralCollector.stop():null,context:{external_user_id:e.externalUserId??null,external_session_id:e.externalSessionId??null,declared_country:e.declaredCountry??null,person_name:e.personName??null,person_document_id:e.personDocumentId??null,custom_fields:e.customFields??{},previous_page_url:this.getPreviousPageUrl(),flow_from_url:this.getFlowFromUrl(),session_uuid:this.sessionUuid,geolocation_history:this.geoHistory.slice(),client_ipv4:this.clientIpv4,client_ipv6:this.clientIpv6,app_session_id:e.appSessionId??null}};this.config.debug&&console.log("[QCDI] Assessing",o);try{let i=await this.client.assess(o);return this.config.debug&&console.log("[QCDI] Result",i),i}catch(i){throw this.config.onError(i),i}}async refresh(){this.initialized=!1,await this.initialize()}destroy(){this.geoWatchId!==null&&typeof navigator<"u"&&navigator.geolocation.clearWatch(this.geoWatchId),this.geoWatchId=null,this.geoHistory=[],this.deviceSignals=null,this.privacySignals=null,this.initialized=!1}};0&&(module.exports={QCApiClient,QuickCheckDeviceIntel,QuickCheckError,SDK_VERSION});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=class extends Error{constructor(n,i,o,r){super(n);this.code=i;this.status=o;this.details=r;this.name="QuickCheckError"}};var D="https://api.quickcheck.com.pa",A="/api/v1/sdk/device-intel/assess";function G(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let t=Math.random().toString(36).slice(2);return`${Date.now().toString(36)}-${t}`}var p=class{constructor(e){if(!e.apiKey)throw new g("apiKey is required","MISSING_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??D).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let n=`${this.apiUrl}${A}`,i=new AbortController,o=setTimeout(()=>i.abort(),this.timeout),r=G(),c=new Date().toISOString(),s;try{s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-QC-SDK-Key":this.apiKey,"X-QC-SDK-Platform":e.platform,"X-QC-Nonce":r,"X-QC-Timestamp":c},body:JSON.stringify(e),signal:i.signal})}catch(u){throw clearTimeout(o),u.name==="AbortError"?new g(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new g(`Network error: ${u.message}`,"NETWORK_ERROR",void 0,u)}clearTimeout(o);let a;try{a=await s.json()}catch{throw new g(`Invalid JSON response (status ${s.status})`,"INVALID_RESPONSE",s.status)}if(!s.ok){let u=typeof a=="object"&&a!==null&&"detail"in a?String(a.detail):`HTTP ${s.status}`,l=s.status===401?"UNAUTHORIZED":s.status===403?"FORBIDDEN":s.status===429?"RATE_LIMITED":"HTTP_ERROR";throw new g(u,l,s.status,a)}return a}};function _(){let t=typeof navigator<"u"?navigator:{},e=typeof window<"u"?window.screen:null,n=e?`${e.width}x${e.height}`:null,i=null,o=null;try{i=new Date().getTimezoneOffset(),o=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}let r=(t.userAgent||"").toLowerCase(),c="desktop";/mobi|iphone|ipod|android/.test(r)?c="mobile":/ipad|tablet/.test(r)&&(c="tablet");let s="Unknown",a=null;if(/windows nt/.test(r)){s="Windows";let l=r.match(/windows nt ([\d.]+)/);a=l?l[1]:null}else if(/mac os x/.test(r)){s="macOS";let l=r.match(/mac os x ([\d_.]+)/);a=l?l[1].replace(/_/g,"."):null}else if(/android/.test(r)){s="Android";let l=r.match(/android ([\d.]+)/);a=l?l[1]:null}else if(/iphone|ipad|ipod/.test(r)){s="iOS";let l=r.match(/os ([\d_]+) like mac/);a=l?l[1].replace(/_/g,"."):null}else/linux/.test(r)&&(s="Linux");let u=t.deviceMemory??null;return{type:c,os_name:s,os_version:a,screen_resolution:n,language:t.language??null,languages:t.languages?Array.from(t.languages):[],timezone_offset:i,timezone_name:o,hardware_concurrency:t.hardwareConcurrency??null,device_memory_gb:u,touch_support:typeof window<"u"&&("ontouchstart"in window||(t.maxTouchPoints??0)>0)}}async function w(){try{let e=await(await import("@thumbmarkjs/thumbmarkjs")).getFingerprint();return typeof e=="string"?e:e&&typeof e.thumbmark=="string"?e.thumbmark:b()}catch{return b()}}function b(){let e=[typeof navigator<"u"?navigator.userAgent:"",typeof navigator<"u"?navigator.language:"",typeof screen<"u"?`${screen.width}x${screen.height}`:"",typeof screen<"u"?String(screen.colorDepth):"",String(new Date().getTimezoneOffset()),typeof navigator<"u"?String(navigator.hardwareConcurrency??""):""].join("|"),n=0;for(let i=0;i<e.length;i++)n=(n<<5)-n+e.charCodeAt(i),n|=0;return"qc_fb_"+Math.abs(n).toString(16).padStart(8,"0")}async function S(t=1e4){return typeof navigator>"u"||!navigator.geolocation?null:new Promise(e=>{let n=setTimeout(()=>e(null),t);navigator.geolocation.getCurrentPosition(i=>{clearTimeout(n),e({latitude:i.coords.latitude,longitude:i.coords.longitude,accuracy_m:Math.round(i.coords.accuracy),source:"gps"})},()=>{clearTimeout(n),e(null)},{enableHighAccuracy:!1,timeout:t,maximumAge:6e4})})}function I(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function f(t=3e3){let e={ipv4:null,ipv6:null,all_v4:[],all_v6:[],method:"webrtc_stun"};return typeof RTCPeerConnection>"u"?e:new Promise(n=>{let i=new Set,o=new Set,r=!1,c=()=>{if(!r){r=!0;try{a.close()}catch{}e.all_v4=[...i],e.all_v6=[...o],e.ipv4=e.all_v4[0]??null,e.ipv6=e.all_v6[0]??null,n(e)}},s=setTimeout(c,t),a;try{a=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]}),a.createDataChannel("ip-discovery"),a.onicecandidate=u=>{if(!u.candidate){clearTimeout(s),c();return}let l=u.candidate.candidate;if(!l.includes("srflx"))return;let v=l.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/);if(v){let d=v[1];!d.startsWith("10.")&&!d.startsWith("192.168.")&&!d.startsWith("172.16.")&&!d.startsWith("172.17.")&&!d.startsWith("172.18.")&&!d.startsWith("172.19.")&&!d.startsWith("172.2")&&!d.startsWith("172.30.")&&!d.startsWith("172.31.")&&!d.startsWith("127.")&&i.add(d)}let m=l.match(/([a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})/i);m&&!m[1].startsWith("fe80")&&o.add(m[1])},a.createOffer().then(u=>a.setLocalDescription(u)).catch(()=>{clearTimeout(s),c()})}catch{clearTimeout(s),n(e)}})}async function x(t=2e3){let e=await f(t);return[...e.all_v4,...e.all_v6]}async function C(){let t=T(),e=U(),n=await L(),i=await x(1500);return{is_incognito:n,webgl_renderer:t,canvas_hash:e,local_ips:i}}function T(){try{let t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return null;let n=e.getExtension("WEBGL_debug_renderer_info");return n?e.getParameter(n.UNMASKED_RENDERER_WEBGL):null}catch{return null}}function U(){try{let t=document.createElement("canvas");t.width=220,t.height=60;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="14px Arial",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("QuickCheck Device Intelligence",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("QuickCheck Device Intelligence",4,17);let n=t.toDataURL(),i=0;for(let o=0;o<n.length;o++){let r=n.charCodeAt(o);i=(i<<5)-i+r,i|=0}return i.toString(16)}catch{return null}}async function L(){try{let t=navigator;if(t.storage?.estimate){let{quota:e}=await t.storage.estimate();if(typeof e=="number")return e<120*1024*1024}}catch{}return null}function M(){try{return{acos04:Math.acos(.4),asin04:Math.asin(.4),atan04:Math.atan(.4),atanh04:Math.atanh(.4),cbrt100:Math.cbrt(100),cosh1:Math.cosh(1),expm11:Math.expm1(1),log1p10:Math.log1p(10),sinh1:Math.sinh(1),tanh1:Math.tanh(1),pow1_1e100:Math.pow(1.1,100)}}catch{return{}}}async function N(){try{let t=document.createElement("canvas");t.width=200,t.height=40;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="18px sans-serif",e.fillText("\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}\u{1F1F5}\u{1F1E6}\u{1F44D}\u{1F3FD}\u{1FAE1}",2,2);let n=t.toDataURL();return V(n)}catch{return null}}function H(){try{if(!("speechSynthesis"in window))return{count:0,fingerprint:null};let t=window.speechSynthesis.getVoices();if(!t||t.length===0)return{count:0,fingerprint:null};let e=t.map(n=>`${n.name}|${n.lang}|${n.localService?"L":"R"}`).sort().join(",");return{count:t.length,fingerprint:h(e)}}catch{return{count:0,fingerprint:null}}}async function O(){let t={audioinput:0,audiooutput:0,videoinput:0};try{if(!navigator.mediaDevices?.enumerateDevices)return t;let e=await navigator.mediaDevices.enumerateDevices();for(let n of e)n.kind==="audioinput"?t.audioinput++:n.kind==="audiooutput"?t.audiooutput++:n.kind==="videoinput"&&t.videoinput++}catch{}return t}function W(){try{let t=new Intl.DateTimeFormat().resolvedOptions();return`${t.locale}|${t.calendar}|${t.numberingSystem}|${t.hourCycle??"-"}|${t.timeZone}`}catch{return null}}async function $(){try{let t=navigator.keyboard;if(!t?.getLayoutMap)return null;let e=await t.getLayoutMap(),n=[];for(let[i,o]of e.entries())n.push(`${i}=${o}`);return h(n.sort().join("|"))}catch{return null}}function K(){let t={vendor:null,renderer:null,extensions:[],shaderPrecision:null};try{let e=document.createElement("canvas"),n=e.getContext("webgl")||e.getContext("experimental-webgl");if(!n)return t;let i=n.getExtension("WEBGL_debug_renderer_info");i&&(t.vendor=n.getParameter(i.UNMASKED_VENDOR_WEBGL),t.renderer=n.getParameter(i.UNMASKED_RENDERER_WEBGL)),t.extensions=n.getSupportedExtensions()??[];let o=n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT),r=n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT);o&&r&&(t.shaderPrecision=`v:${o.rangeMin}/${o.rangeMax}/${o.precision};f:${r.rangeMin}/${r.rangeMax}/${r.precision}`)}catch{}return t}function h(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}async function V(t){try{let e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),i=new Uint8Array(n),o="";for(let r=0;r<16;r++)o+=i[r].toString(16).padStart(2,"0");return o}catch{return h(t)}}async function z(){try{let t=navigator.userAgentData;if(!t?.getHighEntropyValues)return null;let e=await t.getHighEntropyValues(["platform","platformVersion","architecture","bitness","model","fullVersionList","wow64"]);return{platform:e.platform,platformVersion:e.platformVersion,architecture:e.architecture,bitness:e.bitness,model:e.model,fullVersionList:e.fullVersionList,mobile:t.mobile,wow64:e.wow64}}catch{return null}}async function E(){let[t,e,n,i]=await Promise.all([N(),O(),$(),z()]);return{math_constants:M(),emoji_hash:t,speech_voices:H(),media_devices:e,intl_signature:W(),keyboard_layout_hash:n,webgl_advanced:K(),client_hints:i}}var k="1.0.0",R="qcdi_session_uuid",P="qcdi_previous_page",y=class{constructor(e){this.deviceSignals=null;this.privacySignals=null;this.advancedSignals=null;this.initialized=!1;this.sessionUuid="";this.geoWatchId=null;this.geoHistory=[];this.lastGeoLat=null;this.lastGeoLon=null;this.clientIpv4=null;this.clientIpv6=null;this.config={apiKey:e.apiKey,apiUrl:e.apiUrl??"https://api.quickcheck.com.pa",autoCollect:e.autoCollect??!0,requestGeolocation:e.requestGeolocation??!1,continuousGeolocation:e.continuousGeolocation??!1,timeout:e.timeout??5e3,onError:e.onError??(n=>console.error("[QCDI]",n)),debug:e.debug??!1},this.client=new p({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,timeout:this.config.timeout}),this.sessionUuid=this.resolveSessionUuid(),this.config.autoCollect&&this.initialize()}resolveSessionUuid(){try{let e=sessionStorage.getItem(R);if(e)return e;let n=this.generateUuid();return sessionStorage.setItem(R,n),n}catch{return this.generateUuid()}}generateUuid(){let e="0123456789abcdef",n="qcdis-";for(let i=0;i<32;i++)n+=e[Math.floor(Math.random()*16)],(i===7||i===11||i===15||i===19)&&(n+="-");return n}async initialize(){if(!this.initialized){this.config.debug&&console.log("[QCDI] Initializing...");try{let e=await w(),n=_();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...n},this.privacySignals=await C(),this.advancedSignals=await E();let i=await f(2e3);this.clientIpv4=i.ipv4,this.clientIpv6=i.ipv6,this.initialized=!0,this.config.continuousGeolocation&&this.config.requestGeolocation&&this.startContinuousGeolocation(),this.config.debug&&console.log("[QCDI] Initialized",{fingerprint:e,session_uuid:this.sessionUuid,ipv4:this.clientIpv4,ipv6:this.clientIpv6})}catch(e){this.config.onError(e)}}}startContinuousGeolocation(){typeof navigator>"u"||!navigator.geolocation||this.geoWatchId===null&&(this.geoWatchId=navigator.geolocation.watchPosition(e=>{let{latitude:n,longitude:i,accuracy:o}=e.coords;this.lastGeoLat!==null&&this.lastGeoLon!==null&&this.haversineMeters(this.lastGeoLat,this.lastGeoLon,n,i)<50||(this.lastGeoLat=n,this.lastGeoLon=i,this.geoHistory.push({latitude:n,longitude:i,accuracy_m:Math.round(o),timestamp:new Date().toISOString()}),this.geoHistory.length>100&&(this.geoHistory=this.geoHistory.slice(-100)))},e=>{this.config.debug&&console.warn("[QCDI] Geo watch error:",e)},{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e4}))}haversineMeters(e,n,i,o){let c=l=>l*Math.PI/180,s=c(i-e),a=c(o-n),u=Math.sin(s/2)**2+Math.cos(c(e))*Math.cos(c(i))*Math.sin(a/2)**2;return 2*6371e3*Math.asin(Math.sqrt(u))}getPreviousPageUrl(){try{if(typeof document<"u"&&document.referrer)return document.referrer.slice(0,500)}catch{}return null}getFlowFromUrl(){try{let e=sessionStorage.getItem(P);return typeof window<"u"&&sessionStorage.setItem(P,window.location.href.slice(0,500)),e}catch{return null}}async assess(e){if(await this.initialize(),!this.deviceSignals)throw new Error("Device signals not collected. Call initialize() first.");let n=null;this.config.continuousGeolocation&&this.lastGeoLat!==null?n={latitude:this.lastGeoLat,longitude:this.lastGeoLon,accuracy_m:null,source:"gps"}:this.config.requestGeolocation&&(n=await S());let i={sdk_version:k,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:I(),privacy:this.privacySignals,geolocation:n,advanced:this.advancedSignals,context:{external_user_id:e.externalUserId??null,external_session_id:e.externalSessionId??null,declared_country:e.declaredCountry??null,person_name:e.personName??null,person_document_id:e.personDocumentId??null,custom_fields:e.customFields??{},previous_page_url:this.getPreviousPageUrl(),flow_from_url:this.getFlowFromUrl(),session_uuid:this.sessionUuid,geolocation_history:this.geoHistory.slice(),client_ipv4:this.clientIpv4,client_ipv6:this.clientIpv6,app_session_id:e.appSessionId??null}};this.config.debug&&console.log("[QCDI] Assessing",i);try{let o=await this.client.assess(i);return this.config.debug&&console.log("[QCDI] Result",o),o}catch(o){throw this.config.onError(o),o}}async refresh(){this.initialized=!1,await this.initialize()}destroy(){this.geoWatchId!==null&&typeof navigator<"u"&&navigator.geolocation.clearWatch(this.geoWatchId),this.geoWatchId=null,this.geoHistory=[],this.deviceSignals=null,this.privacySignals=null,this.initialized=!1}};export{p as QCApiClient,y as QuickCheckDeviceIntel,g as QuickCheckError,k as SDK_VERSION};
|
|
1
|
+
var d=class extends Error{constructor(t,o,i,r){super(t);this.code=o;this.status=i;this.details=r;this.name="QuickCheckError"}};var T="https://api.quickcheck.com.pa",L="/api/v1/sdk/device-intel/assess";function G(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let n=Math.random().toString(36).slice(2);return`${Date.now().toString(36)}-${n}`}var g=class{constructor(e){if(!e.apiKey)throw new d("apiKey is required","MISSING_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??T).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let t=`${this.apiUrl}${L}`,o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),r=G(),c=new Date().toISOString(),s;try{s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-QC-SDK-Key":this.apiKey,"X-QC-SDK-Platform":e.platform,"X-QC-Nonce":r,"X-QC-Timestamp":c},body:JSON.stringify(e),signal:o.signal})}catch(u){throw clearTimeout(i),u.name==="AbortError"?new d(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new d(`Network error: ${u.message}`,"NETWORK_ERROR",void 0,u)}clearTimeout(i);let a;try{a=await s.json()}catch{throw new d(`Invalid JSON response (status ${s.status})`,"INVALID_RESPONSE",s.status)}if(!s.ok){let u=typeof a=="object"&&a!==null&&"detail"in a?String(a.detail):`HTTP ${s.status}`,l=s.status===401?"UNAUTHORIZED":s.status===403?"FORBIDDEN":s.status===429?"RATE_LIMITED":"HTTP_ERROR";throw new d(u,l,s.status,a)}return a}};function S(){let n=typeof navigator<"u"?navigator:{},e=typeof window<"u"?window.screen:null,t=e?`${e.width}x${e.height}`:null,o=null,i=null;try{o=new Date().getTimezoneOffset(),i=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}let r=(n.userAgent||"").toLowerCase(),c="desktop";/mobi|iphone|ipod|android/.test(r)?c="mobile":/ipad|tablet/.test(r)&&(c="tablet");let s="Unknown",a=null;if(/windows nt/.test(r)){s="Windows";let l=r.match(/windows nt ([\d.]+)/);a=l?l[1]:null}else if(/mac os x/.test(r)){s="macOS";let l=r.match(/mac os x ([\d_.]+)/);a=l?l[1].replace(/_/g,"."):null}else if(/android/.test(r)){s="Android";let l=r.match(/android ([\d.]+)/);a=l?l[1]:null}else if(/iphone|ipad|ipod/.test(r)){s="iOS";let l=r.match(/os ([\d_]+) like mac/);a=l?l[1].replace(/_/g,"."):null}else/linux/.test(r)&&(s="Linux");let u=n.deviceMemory??null;return{type:c,os_name:s,os_version:a,screen_resolution:t,language:n.language??null,languages:n.languages?Array.from(n.languages):[],timezone_offset:o,timezone_name:i,hardware_concurrency:n.hardwareConcurrency??null,device_memory_gb:u,touch_support:typeof window<"u"&&("ontouchstart"in window||(n.maxTouchPoints??0)>0)}}async function I(){try{let e=await(await import("@thumbmarkjs/thumbmarkjs")).getFingerprint();return typeof e=="string"?e:e&&typeof e.thumbmark=="string"?e.thumbmark:k()}catch{return k()}}function k(){let e=[typeof navigator<"u"?navigator.userAgent:"",typeof navigator<"u"?navigator.language:"",typeof screen<"u"?`${screen.width}x${screen.height}`:"",typeof screen<"u"?String(screen.colorDepth):"",String(new Date().getTimezoneOffset()),typeof navigator<"u"?String(navigator.hardwareConcurrency??""):""].join("|"),t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return"qc_fb_"+Math.abs(t).toString(16).padStart(8,"0")}async function x(n=1e4){return typeof navigator>"u"||!navigator.geolocation?null:new Promise(e=>{let t=setTimeout(()=>e(null),n);navigator.geolocation.getCurrentPosition(o=>{clearTimeout(t),e({latitude:o.coords.latitude,longitude:o.coords.longitude,accuracy_m:Math.round(o.coords.accuracy),source:"gps"})},()=>{clearTimeout(t),e(null)},{enableHighAccuracy:!1,timeout:n,maximumAge:6e4})})}function E(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function y(n=3e3){let e={ipv4:null,ipv6:null,all_v4:[],all_v6:[],method:"webrtc_stun"};return typeof RTCPeerConnection>"u"?e:new Promise(t=>{let o=new Set,i=new Set,r=!1,c=()=>{if(!r){r=!0;try{a.close()}catch{}e.all_v4=[...o],e.all_v6=[...i],e.ipv4=e.all_v4[0]??null,e.ipv6=e.all_v6[0]??null,t(e)}},s=setTimeout(c,n),a;try{a=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]}),a.createDataChannel("ip-discovery"),a.onicecandidate=u=>{if(!u.candidate){clearTimeout(s),c();return}let l=u.candidate.candidate;if(!l.includes("srflx"))return;let w=l.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/);if(w){let m=w[1];!m.startsWith("10.")&&!m.startsWith("192.168.")&&!m.startsWith("172.16.")&&!m.startsWith("172.17.")&&!m.startsWith("172.18.")&&!m.startsWith("172.19.")&&!m.startsWith("172.2")&&!m.startsWith("172.30.")&&!m.startsWith("172.31.")&&!m.startsWith("127.")&&o.add(m)}let f=l.match(/([a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})/i);f&&!f[1].startsWith("fe80")&&i.add(f[1])},a.createOffer().then(u=>a.setLocalDescription(u)).catch(()=>{clearTimeout(s),c()})}catch{clearTimeout(s),t(e)}})}async function C(n=2e3){let e=await y(n);return[...e.all_v4,...e.all_v6]}async function A(){let n=U(),e=N(),t=await K(),o=await C(1500);return{is_incognito:t,webgl_renderer:n,canvas_hash:e,local_ips:o}}function U(){try{let n=document.createElement("canvas"),e=n.getContext("webgl")||n.getContext("experimental-webgl");if(!e)return null;let t=e.getExtension("WEBGL_debug_renderer_info");return t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):null}catch{return null}}function N(){try{let n=document.createElement("canvas");n.width=220,n.height=60;let e=n.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="14px Arial",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("QuickCheck Device Intelligence",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("QuickCheck Device Intelligence",4,17);let t=n.toDataURL(),o=0;for(let i=0;i<t.length;i++){let r=t.charCodeAt(i);o=(o<<5)-o+r,o|=0}return o.toString(16)}catch{return null}}async function K(){try{let n=navigator;if(n.storage?.estimate){let{quota:e}=await n.storage.estimate();if(typeof e=="number")return e<120*1024*1024}}catch{}return null}function H(){try{return{acos04:Math.acos(.4),asin04:Math.asin(.4),atan04:Math.atan(.4),atanh04:Math.atanh(.4),cbrt100:Math.cbrt(100),cosh1:Math.cosh(1),expm11:Math.expm1(1),log1p10:Math.log1p(10),sinh1:Math.sinh(1),tanh1:Math.tanh(1),pow1_1e100:Math.pow(1.1,100)}}catch{return{}}}async function O(){try{let n=document.createElement("canvas");n.width=200,n.height=40;let e=n.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="18px sans-serif",e.fillText("\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}\u{1F1F5}\u{1F1E6}\u{1F44D}\u{1F3FD}\u{1FAE1}",2,2);let t=n.toDataURL();return Q(t)}catch{return null}}function W(){try{if(!("speechSynthesis"in window))return{count:0,fingerprint:null};let n=window.speechSynthesis.getVoices();if(!n||n.length===0)return{count:0,fingerprint:null};let e=n.map(t=>`${t.name}|${t.lang}|${t.localService?"L":"R"}`).sort().join(",");return{count:n.length,fingerprint:v(e)}}catch{return{count:0,fingerprint:null}}}async function $(){let n={audioinput:0,audiooutput:0,videoinput:0};try{if(!navigator.mediaDevices?.enumerateDevices)return n;let e=await navigator.mediaDevices.enumerateDevices();for(let t of e)t.kind==="audioinput"?n.audioinput++:t.kind==="audiooutput"?n.audiooutput++:t.kind==="videoinput"&&n.videoinput++}catch{}return n}function V(){try{let n=new Intl.DateTimeFormat().resolvedOptions();return`${n.locale}|${n.calendar}|${n.numberingSystem}|${n.hourCycle??"-"}|${n.timeZone}`}catch{return null}}async function z(){try{let n=navigator.keyboard;if(!n?.getLayoutMap)return null;let e=await n.getLayoutMap(),t=[];for(let[o,i]of e.entries())t.push(`${o}=${i}`);return v(t.sort().join("|"))}catch{return null}}function F(){let n={vendor:null,renderer:null,extensions:[],shaderPrecision:null};try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return n;let o=t.getExtension("WEBGL_debug_renderer_info");o&&(n.vendor=t.getParameter(o.UNMASKED_VENDOR_WEBGL),n.renderer=t.getParameter(o.UNMASKED_RENDERER_WEBGL)),n.extensions=t.getSupportedExtensions()??[];let i=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT),r=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);i&&r&&(n.shaderPrecision=`v:${i.rangeMin}/${i.rangeMax}/${i.precision};f:${r.rangeMin}/${r.rangeMax}/${r.precision}`)}catch{}return n}function v(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}async function Q(n){try{let e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e),o=new Uint8Array(t),i="";for(let r=0;r<16;r++)i+=o[r].toString(16).padStart(2,"0");return i}catch{return v(n)}}async function q(){try{let n=navigator.userAgentData;if(!n?.getHighEntropyValues)return null;let e=await n.getHighEntropyValues(["platform","platformVersion","architecture","bitness","model","fullVersionList","wow64"]);return{platform:e.platform,platformVersion:e.platformVersion,architecture:e.architecture,bitness:e.bitness,model:e.model,fullVersionList:e.fullVersionList,mobile:n.mobile,wow64:e.wow64}}catch{return null}}async function R(){let[n,e,t,o]=await Promise.all([O(),$(),z(),q()]);return{math_constants:H(),emoji_hash:n,speech_voices:W(),media_devices:e,intl_signature:V(),keyboard_layout_hash:t,webgl_advanced:F(),client_hints:o}}var h=class{constructor(){this.keyEvents=[];this.mouseSamples=[];this.startTime=0;this.active=!1;this.mouseThrottleMs=50;this.lastMouseSample=0;this.onKeyDown=e=>{this.active&&this.keyEvents.push({code:e.code,downAt:performance.now()})};this.onKeyUp=e=>{if(!this.active)return;let t=[...this.keyEvents].reverse().find(o=>o.code===e.code&&!o.upAt);t&&(t.upAt=performance.now())};this.onMouseMove=e=>{if(!this.active)return;let t=performance.now();t-this.lastMouseSample<this.mouseThrottleMs||(this.lastMouseSample=t,this.mouseSamples.push({x:e.clientX,y:e.clientY,t}))}}start(){this.active||(this.active=!0,this.startTime=performance.now(),this.keyEvents=[],this.mouseSamples=[],document.addEventListener("keydown",this.onKeyDown,{passive:!0}),document.addEventListener("keyup",this.onKeyUp,{passive:!0}),document.addEventListener("mousemove",this.onMouseMove,{passive:!0}))}stop(){this.active=!1,document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mousemove",this.onMouseMove);let e=performance.now()-this.startTime;return{...this.computeKeystrokeMetrics(),...this.computeMouseMetrics(),total_keystrokes:this.keyEvents.filter(t=>t.upAt).length,total_mouse_events:this.mouseSamples.length,session_duration_ms:Math.round(e)}}computeKeystrokeMetrics(){let e=this.keyEvents.filter(i=>i.upAt);if(e.length<3)return{keystroke_dwell_mean_ms:0,keystroke_dwell_std_ms:0,keystroke_flight_mean_ms:0,keystroke_flight_std_ms:0};let t=e.map(i=>i.upAt-i.downAt),o=[];for(let i=1;i<e.length;i++){let r=e[i].downAt-(e[i-1].upAt??e[i-1].downAt);r>0&&r<2e3&&o.push(r)}return{keystroke_dwell_mean_ms:p(t),keystroke_dwell_std_ms:_(t),keystroke_flight_mean_ms:o.length>0?p(o):0,keystroke_flight_std_ms:o.length>0?_(o):0}}computeMouseMetrics(){if(this.mouseSamples.length<5)return{mouse_velocity_mean:0,mouse_velocity_std:0,mouse_acceleration_mean:0};let e=[];for(let o=1;o<this.mouseSamples.length;o++){let i=this.mouseSamples[o].x-this.mouseSamples[o-1].x,r=this.mouseSamples[o].y-this.mouseSamples[o-1].y,c=this.mouseSamples[o].t-this.mouseSamples[o-1].t;c>0&&e.push(Math.sqrt(i*i+r*r)/c)}let t=[];for(let o=1;o<e.length;o++){let i=this.mouseSamples[o+1].t-this.mouseSamples[o].t;i>0&&t.push(Math.abs(e[o]-e[o-1])/i)}return{mouse_velocity_mean:e.length>0?p(e):0,mouse_velocity_std:e.length>0?_(e):0,mouse_acceleration_mean:t.length>0?p(t):0}}};function p(n){return n.length===0?0:n.reduce((e,t)=>e+t,0)/n.length}function _(n){if(n.length<2)return 0;let e=p(n),t=n.reduce((o,i)=>o+(i-e)**2,0)/(n.length-1);return Math.sqrt(t)}var M="1.0.0",D="qcdi_session_uuid",P="qcdi_previous_page",b=class{constructor(e){this.deviceSignals=null;this.privacySignals=null;this.advancedSignals=null;this.behavioralCollector=null;this.initialized=!1;this.sessionUuid="";this.geoWatchId=null;this.geoHistory=[];this.lastGeoLat=null;this.lastGeoLon=null;this.clientIpv4=null;this.clientIpv6=null;this.config={apiKey:e.apiKey,apiUrl:e.apiUrl??"https://api.quickcheck.com.pa",autoCollect:e.autoCollect??!0,requestGeolocation:e.requestGeolocation??!1,continuousGeolocation:e.continuousGeolocation??!1,timeout:e.timeout??5e3,onError:e.onError??(t=>console.error("[QCDI]",t)),debug:e.debug??!1},this.client=new g({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,timeout:this.config.timeout}),this.sessionUuid=this.resolveSessionUuid(),this.config.autoCollect&&this.initialize()}resolveSessionUuid(){try{let e=sessionStorage.getItem(D);if(e)return e;let t=this.generateUuid();return sessionStorage.setItem(D,t),t}catch{return this.generateUuid()}}generateUuid(){let e="0123456789abcdef",t="qcdis-";for(let o=0;o<32;o++)t+=e[Math.floor(Math.random()*16)],(o===7||o===11||o===15||o===19)&&(t+="-");return t}async initialize(){if(!this.initialized){this.config.debug&&console.log("[QCDI] Initializing...");try{let e=await I(),t=S();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...t},this.privacySignals=await A(),this.advancedSignals=await R();let o=await y(2e3);this.clientIpv4=o.ipv4,this.clientIpv6=o.ipv6,this.initialized=!0,this.behavioralCollector=new h,this.behavioralCollector.start(),this.config.continuousGeolocation&&this.config.requestGeolocation&&this.startContinuousGeolocation(),this.config.debug&&console.log("[QCDI] Initialized",{fingerprint:e,session_uuid:this.sessionUuid,ipv4:this.clientIpv4,ipv6:this.clientIpv6})}catch(e){this.config.onError(e)}}}startContinuousGeolocation(){typeof navigator>"u"||!navigator.geolocation||this.geoWatchId===null&&(this.geoWatchId=navigator.geolocation.watchPosition(e=>{let{latitude:t,longitude:o,accuracy:i}=e.coords;this.lastGeoLat!==null&&this.lastGeoLon!==null&&this.haversineMeters(this.lastGeoLat,this.lastGeoLon,t,o)<50||(this.lastGeoLat=t,this.lastGeoLon=o,this.geoHistory.push({latitude:t,longitude:o,accuracy_m:Math.round(i),timestamp:new Date().toISOString()}),this.geoHistory.length>100&&(this.geoHistory=this.geoHistory.slice(-100)))},e=>{this.config.debug&&console.warn("[QCDI] Geo watch error:",e)},{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e4}))}haversineMeters(e,t,o,i){let c=l=>l*Math.PI/180,s=c(o-e),a=c(i-t),u=Math.sin(s/2)**2+Math.cos(c(e))*Math.cos(c(o))*Math.sin(a/2)**2;return 2*6371e3*Math.asin(Math.sqrt(u))}getPreviousPageUrl(){try{if(typeof document<"u"&&document.referrer)return document.referrer.slice(0,500)}catch{}return null}getFlowFromUrl(){try{let e=sessionStorage.getItem(P);return typeof window<"u"&&sessionStorage.setItem(P,window.location.href.slice(0,500)),e}catch{return null}}async assess(e){if(await this.initialize(),!this.deviceSignals)throw new Error("Device signals not collected. Call initialize() first.");let t=null;this.config.continuousGeolocation&&this.lastGeoLat!==null?t={latitude:this.lastGeoLat,longitude:this.lastGeoLon,accuracy_m:null,source:"gps"}:this.config.requestGeolocation&&(t=await x());let o={sdk_version:M,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:E(),privacy:this.privacySignals,geolocation:t,advanced:this.advancedSignals,behavioral:this.behavioralCollector?this.behavioralCollector.stop():null,context:{external_user_id:e.externalUserId??null,external_session_id:e.externalSessionId??null,declared_country:e.declaredCountry??null,person_name:e.personName??null,person_document_id:e.personDocumentId??null,custom_fields:e.customFields??{},previous_page_url:this.getPreviousPageUrl(),flow_from_url:this.getFlowFromUrl(),session_uuid:this.sessionUuid,geolocation_history:this.geoHistory.slice(),client_ipv4:this.clientIpv4,client_ipv6:this.clientIpv6,app_session_id:e.appSessionId??null}};this.config.debug&&console.log("[QCDI] Assessing",o);try{let i=await this.client.assess(o);return this.config.debug&&console.log("[QCDI] Result",i),i}catch(i){throw this.config.onError(i),i}}async refresh(){this.initialized=!1,await this.initialize()}destroy(){this.geoWatchId!==null&&typeof navigator<"u"&&navigator.geolocation.clearWatch(this.geoWatchId),this.geoWatchId=null,this.geoHistory=[],this.deviceSignals=null,this.privacySignals=null,this.initialized=!1}};export{g as QCApiClient,b as QuickCheckDeviceIntel,d as QuickCheckError,M as SDK_VERSION};
|
package/dist/umd/umd.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var QuickCheck=(()=>{var k=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var se=(t,e)=>()=>(t&&(e=t(t=0)),e);var U=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:!0})},le=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ie(e))!ae.call(t,i)&&i!==r&&k(t,i,{get:()=>e[i],enumerable:!(o=oe(e,i))||o.enumerable});return t};var ce=t=>le(k({},"__esModule",{value:!0}),t);var z={};U(z,{getFingerprint:()=>ve,getFingerprintData:()=>V,getFingerprintPerformance:()=>ye,getVersion:()=>pe,includeComponent:()=>y,setOption:()=>fe});function w(t,e,r,o){return new(r||(r=Promise))((function(i,a){function n(l){try{u(o.next(l))}catch(s){a(s)}}function c(l){try{u(o.throw(l))}catch(s){a(s)}}function u(l){var s;l.done?i(l.value):(s=l.value,s instanceof r?s:new r((function(f){f(s)}))).then(n,c)}u((o=o.apply(t,e||[])).next())}))}function b(t,e){var r,o,i,a,n={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(l){return(function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(r=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,o=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!((i=i.length>0&&i[i.length-1])||s[0]!==6&&s[0]!==2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1],i=s;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(s);break}i[2]&&n.ops.pop(),n.trys.pop();continue}s=e.call(t,n)}catch(f){s=[6,f],o=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}})([u,l])}}}function fe(t,e){if(!["include","exclude","permissions_to_check","retries","timeout","logging"].includes(t))throw new Error("Unknown option "+t);if(["include","exclude","permissions_to_check"].includes(t)&&(!Array.isArray(e)||!e.every((function(r){return typeof r=="string"}))))throw new Error("The value of the include, exclude and permissions_to_check must be an array of strings");if(["retries","timeout"].includes(t)&&typeof e!="number")throw new Error("The value of retries must be a number");g[t]=e}function A(t){return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),(t^=t>>>16)>>>0}function v(t,e){return t<<e|t>>>32-e}function D(t,e){var r;if(e===void 0&&(e=0),e=e?0|e:0,typeof t=="string"&&(r=t,t=new TextEncoder().encode(r).buffer),!(t instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");var o=new Uint32Array([e,e,e,e]);(function(a,n){for(var c=a.byteLength/16|0,u=new Uint32Array(a,0,4*c),l=0;l<c;l++){var s=u.subarray(4*l,4*(l+1));s[0]=Math.imul(s[0],h[0]),s[0]=v(s[0],15),s[0]=Math.imul(s[0],h[1]),n[0]=n[0]^s[0],n[0]=v(n[0],19),n[0]=n[0]+n[1],n[0]=Math.imul(n[0],5)+1444728091,s[1]=Math.imul(s[1],h[1]),s[1]=v(s[1],16),s[1]=Math.imul(s[1],h[2]),n[1]=n[1]^s[1],n[1]=v(n[1],17),n[1]=n[1]+n[2],n[1]=Math.imul(n[1],5)+197830471,s[2]=Math.imul(s[2],h[2]),s[2]=v(s[2],17),s[2]=Math.imul(s[2],h[3]),n[2]=n[2]^s[2],n[2]=v(n[2],15),n[2]=n[2]+n[3],n[2]=Math.imul(n[2],5)+2530024501,s[3]=Math.imul(s[3],h[3]),s[3]=v(s[3],18),s[3]=Math.imul(s[3],h[0]),n[3]=n[3]^s[3],n[3]=v(n[3],13),n[3]=n[3]+n[0],n[3]=Math.imul(n[3],5)+850148119}})(t,o),(function(a,n){var c=a.byteLength/16|0,u=a.byteLength%16,l=new Uint32Array(4),s=new Uint8Array(a,16*c,u);switch(u){case 15:l[3]=l[3]^s[14]<<16;case 14:l[3]=l[3]^s[13]<<8;case 13:l[3]=l[3]^s[12],l[3]=Math.imul(l[3],h[3]),l[3]=v(l[3],18),l[3]=Math.imul(l[3],h[0]),n[3]=n[3]^l[3];case 12:l[2]=l[2]^s[11]<<24;case 11:l[2]=l[2]^s[10]<<16;case 10:l[2]=l[2]^s[9]<<8;case 9:l[2]=l[2]^s[8],l[2]=Math.imul(l[2],h[2]),l[2]=v(l[2],17),l[2]=Math.imul(l[2],h[3]),n[2]=n[2]^l[2];case 8:l[1]=l[1]^s[7]<<24;case 7:l[1]=l[1]^s[6]<<16;case 6:l[1]=l[1]^s[5]<<8;case 5:l[1]=l[1]^s[4],l[1]=Math.imul(l[1],h[1]),l[1]=v(l[1],16),l[1]=Math.imul(l[1],h[2]),n[1]=n[1]^l[1];case 4:l[0]=l[0]^s[3]<<24;case 3:l[0]=l[0]^s[2]<<16;case 2:l[0]=l[0]^s[1]<<8;case 1:l[0]=l[0]^s[0],l[0]=Math.imul(l[0],h[0]),l[0]=v(l[0],15),l[0]=Math.imul(l[0],h[1]),n[0]=n[0]^l[0]}})(t,o),(function(a,n){n[0]=n[0]^a.byteLength,n[1]=n[1]^a.byteLength,n[2]=n[2]^a.byteLength,n[3]=n[3]^a.byteLength,n[0]=n[0]+n[1]|0,n[0]=n[0]+n[2]|0,n[0]=n[0]+n[3]|0,n[1]=n[1]+n[0]|0,n[2]=n[2]+n[0]|0,n[3]=n[3]+n[0]|0,n[0]=A(n[0]),n[1]=A(n[1]),n[2]=A(n[2]),n[3]=A(n[3]),n[0]=n[0]+n[1]|0,n[0]=n[0]+n[2]|0,n[0]=n[0]+n[3]|0,n[1]=n[1]+n[0]|0,n[2]=n[2]+n[0]|0,n[3]=n[3]+n[0]|0})(t,o);var i=new Uint8Array(o.buffer);return Array.from(i).map((function(a){return a.toString(16).padStart(2,"0")})).join("")}function H(t,e){return new Promise((function(r){setTimeout((function(){return r(e)}),t)}))}function me(t,e,r){return Promise.all(t.map((function(o){var i=performance.now();return Promise.race([o.then((function(a){return{value:a,elapsed:performance.now()-i}})),H(e,r).then((function(a){return{value:a,elapsed:performance.now()-i}}))])})))}function he(t,e,r){return Promise.all(t.map((function(o){return Promise.race([o,H(e,r)])})))}function pe(){return"0.20.5"}function V(){return w(this,void 0,void 0,(function(){var t,e,r,o,i;return b(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),t=B(),e=Object.keys(t),[4,he(Object.values(t),g?.timeout||1e3,F)];case 1:return r=a.sent(),o=r.filter((function(n){return n!==void 0})),i={},o.forEach((function(n,c){i[e[c]]=n})),[2,j(i,g.exclude||[],g.include||[],"")];case 2:throw a.sent();case 3:return[2]}}))}))}function j(t,e,r,o){o===void 0&&(o="");for(var i={},a=function(l,s){var f=o+l+".";if(typeof s!="object"||Array.isArray(s)){var S=e.some((function(C){return f.startsWith(C)})),m=r.some((function(C){return f.startsWith(C)}));S&&!m||(i[l]=s)}else{var E=j(s,e,r,f);Object.keys(E).length>0&&(i[l]=E)}},n=0,c=Object.entries(t);n<c.length;n++){var u=c[n];a(u[0],u[1])}return i}function ve(t){return w(this,void 0,void 0,(function(){var e,r;return b(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,V()];case 1:return e=o.sent(),r=D(JSON.stringify(e)),Math.random()<1e-5&&g.logging&&(function(i,a){w(this,void 0,void 0,(function(){var n,c;return b(this,(function(u){switch(u.label){case 0:if(n="https://logging.thumbmarkjs.com/v1/log",c={thumbmark:i,components:a,version:"0.20.5"},sessionStorage.getItem("_tmjs_l"))return[3,4];sessionStorage.setItem("_tmjs_l","1"),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:case 3:return u.sent(),[3,4];case 4:return[2]}}))}))})(r,e),t?[2,{hash:r.toString(),data:e}]:[2,r.toString()];case 2:throw o.sent();case 3:return[2]}}))}))}function ye(){return w(this,void 0,void 0,(function(){var t,e,r,o;return b(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=B(),e=Object.keys(t),[4,me(Object.values(t),g?.timeout||1e3,F)];case 1:return r=i.sent(),o={elapsed:{}},r.forEach((function(a,n){o[e[n]]=a.value,o.elapsed[e[n]]=a.elapsed})),[2,o];case 2:throw i.sent();case 3:return[2]}}))}))}function I(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};for(var t=navigator.userAgent,e={edg:"Edge",opr:"Opera",samsung:"SamsungBrowser"},r=0,o=[/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/,/(?<name>samsung).*Version\/(?<version>\d+(?:\.\d+)?)/i,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/];r<o.length;r++){var i=o[r],a=t.match(i);if(a&&a.groups)return{name:e[a.groups.name.toLowerCase()]||a.groups.name,version:a.groups.version}}return{name:"unknown",version:"unknown"}}function we(t){for(var e=0,r=0;r<t.length;++r)e+=Math.abs(t[r]);return e}function K(t,e,r){for(var o=[],i=0;i<t[0].data.length;i++){for(var a=[],n=0;n<t.length;n++)a.push(t[n].data[i]);o.push(_e(a))}var c=new Uint8ClampedArray(o);return new ImageData(c,e,r)}function _e(t){if(t.length===0)return 0;for(var e={},r=0,o=t;r<o.length;r++)e[a=o[r]]=(e[a]||0)+1;var i=t[0];for(var a in e)e[a]>e[i]&&(i=parseInt(a,10));return i}function O(t,e){if(!t)throw new Error("Canvas context not supported");return t.font,t.font="72px ".concat(e),t.measureText("WwMmLli0Oo").width}function Pe(){var t,e=document.createElement("canvas"),r=(t=e.getContext("webgl"))!==null&&t!==void 0?t:e.getContext("experimental-webgl");if(r&&"getParameter"in r)try{var o=(r.getParameter(r.VENDOR)||"").toString(),i=(r.getParameter(r.RENDERER)||"").toString(),a={vendor:o,renderer:i,version:(r.getParameter(r.VERSION)||"").toString(),shadingLanguageVersion:(r.getParameter(r.SHADING_LANGUAGE_VERSION)||"").toString()};if(!i.length||!o.length){var n=r.getExtension("WEBGL_debug_renderer_info");if(n){var c=(r.getParameter(n.UNMASKED_VENDOR_WEBGL)||"").toString(),u=(r.getParameter(n.UNMASKED_RENDERER_WEBGL)||"").toString();c&&(a.vendorUnmasked=c),u&&(a.rendererUnmasked=u)}}return a}catch{}return"undefined"}function Ce(){var t=new Float32Array(1),e=new Uint8Array(t.buffer);return t[0]=1/0,t[0]=t[0]-t[0],e[3]}function Me(t,e){var r={};return e.forEach((function(o){var i=(function(a){if(a.length===0)return null;var n={};a.forEach((function(l){var s=String(l);n[s]=(n[s]||0)+1}));var c=a[0],u=1;return Object.keys(n).forEach((function(l){n[l]>u&&(c=l,u=n[l])})),c})(t.map((function(a){return o in a?a[o]:void 0})).filter((function(a){return a!==void 0})));i&&(r[o]=i)})),r}function Ae(){var t=[],e={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(e).forEach((function(r){e[r].forEach((function(o){matchMedia("(".concat(r,": ").concat(o,")")).matches&&t.push("".concat(r,": ").concat(o))}))})),t}function ke(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{for(var t=window.ApplePaySession.supportsVersion,e=15;e>0;e--)if(t(e))return e}catch{return 0}return 0}var g,W,F,y,B,h,be,$,N,Se,xe,R,Ee,Ie,p,Re,d,x,q=se(()=>{"use strict";g={exclude:[],include:[],logging:!0,timeout:1e3};W={},F={timeout:"true"},y=function(t,e){typeof window<"u"&&(W[t]=e)},B=function(){return Object.fromEntries(Object.entries(W).filter((function(t){var e,r=t[0];return!(!((e=g?.exclude)===null||e===void 0)&&e.includes(r))})).filter((function(t){var e,r,o,i,a=t[0];return!((e=g?.include)===null||e===void 0)&&e.some((function(n){return n.includes(".")}))?(r=g?.include)===null||r===void 0?void 0:r.some((function(n){return n.startsWith(a)})):((o=g?.include)===null||o===void 0?void 0:o.length)===0||((i=g?.include)===null||i===void 0?void 0:i.includes(a))})).map((function(t){return[t[0],(0,t[1])()]})))};h=new Uint32Array([597399067,2869860233,951274213,2716044179]);be=I();["SamsungBrowser","Safari"].includes(be.name)||y("audio",(function(){return w(this,void 0,void 0,(function(){return b(this,(function(t){return[2,new Promise((function(e,r){try{var o=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),i=o.createBufferSource(),a=o.createOscillator();a.frequency.value=1e3;var n,c=o.createDynamicsCompressor();c.threshold.value=-50,c.knee.value=40,c.ratio.value=12,c.attack.value=0,c.release.value=.2,a.connect(c),c.connect(o.destination),a.start(),o.oncomplete=function(u){n=u.renderedBuffer.getChannelData(0),e({sampleHash:we(n),oscillator:a.type,maxChannels:o.destination.maxChannelCount,channelCountMode:i.channelCountMode})},o.startRendering()}catch(u){console.error("Error creating audio fingerprint:",u),r(u)}}))]}))}))}));$=I(),N=$.name.toLowerCase(),Se=$.version.split(".")[0]||"0",xe=parseInt(Se,10);N==="firefox"||N==="safari"&&xe===17||y("canvas",(function(){return document.createElement("canvas").getContext("2d"),new Promise((function(t){var e=Array.from({length:3},(function(){return(function(){var r=document.createElement("canvas"),o=r.getContext("2d");if(!o)return new ImageData(1,1);r.width=280,r.height=20;var i=o.createLinearGradient(0,0,r.width,r.height);i.addColorStop(0,"red"),i.addColorStop(.16666666666666666,"orange"),i.addColorStop(.3333333333333333,"yellow"),i.addColorStop(.5,"green"),i.addColorStop(.6666666666666666,"blue"),i.addColorStop(.8333333333333334,"indigo"),i.addColorStop(1,"violet"),o.fillStyle=i,o.fillRect(0,0,r.width,r.height);var a="Random Text WMwmil10Oo";return o.font="23.123px Arial",o.fillStyle="black",o.fillText(a,-5,15),o.fillStyle="rgba(0, 0, 255, 0.5)",o.fillText(a,-3.3,17.7),o.beginPath(),o.moveTo(0,0),o.lineTo(2*r.width/7,r.height),o.strokeStyle="white",o.lineWidth=2,o.stroke(),o.getImageData(0,0,r.width,r.height)})()}));t({commonImageDataHash:D(K(e,280,20).data.toString()).toString()})}))}));Ee=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],Ie=["monospace","sans-serif","serif"];I().name!="Firefox"&&y("fonts",(function(){var t=this;return new Promise((function(e,r){try{(function(o){var i;w(this,void 0,void 0,(function(){var a,n,c;return b(this,(function(u){switch(u.label){case 0:return document.body?[3,2]:[4,(l=50,new Promise((function(f){return setTimeout(f,l,s)})))];case 1:return u.sent(),[3,0];case 2:if((a=document.createElement("iframe")).setAttribute("frameBorder","0"),(n=a.style).setProperty("position","fixed"),n.setProperty("display","block","important"),n.setProperty("visibility","visible"),n.setProperty("border","0"),n.setProperty("opacity","0"),a.src="about:blank",document.body.appendChild(a),!(c=a.contentDocument||((i=a.contentWindow)===null||i===void 0?void 0:i.document)))throw new Error("Iframe document is not accessible");return o({iframe:c}),setTimeout((function(){document.body.removeChild(a)}),0),[2]}var l,s}))}))})((function(o){var i=o.iframe;return w(t,void 0,void 0,(function(){var a,n,c,u;return b(this,(function(l){return a=i.createElement("canvas"),n=a.getContext("2d"),c=Ie.map((function(s){return O(n,s)})),u={},Ee.forEach((function(s){var f=O(n,s);c.includes(f)||(u[s]=f)})),e(u),[2]}))}))}))}catch{r({error:"unsupported"})}}))})),y("hardware",(function(){return new Promise((function(t,e){var r=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,o=window.performance&&window.performance.memory?window.performance.memory:0;t({videocard:Pe(),architecture:Ce(),deviceMemory:r.toString()||"undefined",jsHeapSizeLimit:o.jsHeapSizeLimit||0})}))})),y("locales",(function(){return new Promise((function(t){t({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))})),y("permissions",(function(){return w(this,void 0,void 0,(function(){var t;return b(this,(function(e){return R=g?.permissions_to_check||["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"],t=Array.from({length:g?.retries||3},(function(){return(function(){return w(this,void 0,void 0,(function(){var r,o,i,a,n;return b(this,(function(c){switch(c.label){case 0:r={},o=0,i=R,c.label=1;case 1:if(!(o<i.length))return[3,6];a=i[o],c.label=2;case 2:return c.trys.push([2,4,,5]),[4,navigator.permissions.query({name:a})];case 3:return n=c.sent(),r[a]=n.state.toString(),[3,5];case 4:return c.sent(),[3,5];case 5:return o++,[3,1];case 6:return[2,r]}}))}))})()})),[2,Promise.all(t).then((function(r){return Me(r,R)}))]}))}))})),y("plugins",(function(){var t=[];if(navigator.plugins)for(var e=0;e<navigator.plugins.length;e++){var r=navigator.plugins[e];t.push([r.name,r.filename,r.description].join("|"))}return new Promise((function(o){o({plugins:t})}))})),y("screen",(function(){return new Promise((function(t){t({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:Ae()})}))})),y("system",(function(){return new Promise((function(t){var e=I();t({platform:window.navigator.platform,cookieEnabled:window.navigator.cookieEnabled,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:e.name,version:e.version},applePayVersion:ke()})}))}));Re=I().name!=="SamsungBrowser"?1:3,d=null;y("webgl",(function(){return w(this,void 0,void 0,(function(){var t;return b(this,(function(e){typeof document<"u"&&((p=document.createElement("canvas")).width=200,p.height=100,d=p.getContext("webgl"));try{if(!d)throw new Error("WebGL not supported");return t=Array.from({length:Re},(function(){return(function(){try{if(!d)throw new Error("WebGL not supported");var r=`
|
|
1
|
+
"use strict";var QuickCheck=(()=>{var D=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var ue=(t,e)=>()=>(t&&(e=t(t=0)),e);var O=(t,e)=>{for(var n in e)D(t,n,{get:e[n],enumerable:!0})},de=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of le(e))!ce.call(t,i)&&i!==n&&D(t,i,{get:()=>e[i],enumerable:!(o=se(e,i))||o.enumerable});return t};var me=t=>de(D({},"__esModule",{value:!0}),t);var Y={};O(Y,{getFingerprint:()=>be,getFingerprintData:()=>$,getFingerprintPerformance:()=>we,getVersion:()=>_e,includeComponent:()=>y,setOption:()=>pe});function _(t,e,n,o){return new(n||(n=Promise))((function(i,a){function r(l){try{u(o.next(l))}catch(s){a(s)}}function c(l){try{u(o.throw(l))}catch(s){a(s)}}function u(l){var s;l.done?i(l.value):(s=l.value,s instanceof n?s:new n((function(h){h(s)}))).then(r,c)}u((o=o.apply(t,e||[])).next())}))}function b(t,e){var n,o,i,a,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(l){return(function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(r=0)),r;)try{if(n=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,o=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!((i=i.length>0&&i[i.length-1])||s[0]!==6&&s[0]!==2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1],i=s;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(s);break}i[2]&&r.ops.pop(),r.trys.pop();continue}s=e.call(t,r)}catch(h){s=[6,h],o=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}})([u,l])}}}function pe(t,e){if(!["include","exclude","permissions_to_check","retries","timeout","logging"].includes(t))throw new Error("Unknown option "+t);if(["include","exclude","permissions_to_check"].includes(t)&&(!Array.isArray(e)||!e.every((function(n){return typeof n=="string"}))))throw new Error("The value of the include, exclude and permissions_to_check must be an array of strings");if(["retries","timeout"].includes(t)&&typeof e!="number")throw new Error("The value of retries must be a number");m[t]=e}function C(t){return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),(t^=t>>>16)>>>0}function v(t,e){return t<<e|t>>>32-e}function L(t,e){var n;if(e===void 0&&(e=0),e=e?0|e:0,typeof t=="string"&&(n=t,t=new TextEncoder().encode(n).buffer),!(t instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");var o=new Uint32Array([e,e,e,e]);(function(a,r){for(var c=a.byteLength/16|0,u=new Uint32Array(a,0,4*c),l=0;l<c;l++){var s=u.subarray(4*l,4*(l+1));s[0]=Math.imul(s[0],g[0]),s[0]=v(s[0],15),s[0]=Math.imul(s[0],g[1]),r[0]=r[0]^s[0],r[0]=v(r[0],19),r[0]=r[0]+r[1],r[0]=Math.imul(r[0],5)+1444728091,s[1]=Math.imul(s[1],g[1]),s[1]=v(s[1],16),s[1]=Math.imul(s[1],g[2]),r[1]=r[1]^s[1],r[1]=v(r[1],17),r[1]=r[1]+r[2],r[1]=Math.imul(r[1],5)+197830471,s[2]=Math.imul(s[2],g[2]),s[2]=v(s[2],17),s[2]=Math.imul(s[2],g[3]),r[2]=r[2]^s[2],r[2]=v(r[2],15),r[2]=r[2]+r[3],r[2]=Math.imul(r[2],5)+2530024501,s[3]=Math.imul(s[3],g[3]),s[3]=v(s[3],18),s[3]=Math.imul(s[3],g[0]),r[3]=r[3]^s[3],r[3]=v(r[3],13),r[3]=r[3]+r[0],r[3]=Math.imul(r[3],5)+850148119}})(t,o),(function(a,r){var c=a.byteLength/16|0,u=a.byteLength%16,l=new Uint32Array(4),s=new Uint8Array(a,16*c,u);switch(u){case 15:l[3]=l[3]^s[14]<<16;case 14:l[3]=l[3]^s[13]<<8;case 13:l[3]=l[3]^s[12],l[3]=Math.imul(l[3],g[3]),l[3]=v(l[3],18),l[3]=Math.imul(l[3],g[0]),r[3]=r[3]^l[3];case 12:l[2]=l[2]^s[11]<<24;case 11:l[2]=l[2]^s[10]<<16;case 10:l[2]=l[2]^s[9]<<8;case 9:l[2]=l[2]^s[8],l[2]=Math.imul(l[2],g[2]),l[2]=v(l[2],17),l[2]=Math.imul(l[2],g[3]),r[2]=r[2]^l[2];case 8:l[1]=l[1]^s[7]<<24;case 7:l[1]=l[1]^s[6]<<16;case 6:l[1]=l[1]^s[5]<<8;case 5:l[1]=l[1]^s[4],l[1]=Math.imul(l[1],g[1]),l[1]=v(l[1],16),l[1]=Math.imul(l[1],g[2]),r[1]=r[1]^l[1];case 4:l[0]=l[0]^s[3]<<24;case 3:l[0]=l[0]^s[2]<<16;case 2:l[0]=l[0]^s[1]<<8;case 1:l[0]=l[0]^s[0],l[0]=Math.imul(l[0],g[0]),l[0]=v(l[0],15),l[0]=Math.imul(l[0],g[1]),r[0]=r[0]^l[0]}})(t,o),(function(a,r){r[0]=r[0]^a.byteLength,r[1]=r[1]^a.byteLength,r[2]=r[2]^a.byteLength,r[3]=r[3]^a.byteLength,r[0]=r[0]+r[1]|0,r[0]=r[0]+r[2]|0,r[0]=r[0]+r[3]|0,r[1]=r[1]+r[0]|0,r[2]=r[2]+r[0]|0,r[3]=r[3]+r[0]|0,r[0]=C(r[0]),r[1]=C(r[1]),r[2]=C(r[2]),r[3]=C(r[3]),r[0]=r[0]+r[1]|0,r[0]=r[0]+r[2]|0,r[0]=r[0]+r[3]|0,r[1]=r[1]+r[0]|0,r[2]=r[2]+r[0]|0,r[3]=r[3]+r[0]|0})(t,o);var i=new Uint8Array(o.buffer);return Array.from(i).map((function(a){return a.toString(16).padStart(2,"0")})).join("")}function j(t,e){return new Promise((function(n){setTimeout((function(){return n(e)}),t)}))}function ve(t,e,n){return Promise.all(t.map((function(o){var i=performance.now();return Promise.race([o.then((function(a){return{value:a,elapsed:performance.now()-i}})),j(e,n).then((function(a){return{value:a,elapsed:performance.now()-i}}))])})))}function ye(t,e,n){return Promise.all(t.map((function(o){return Promise.race([o,j(e,n)])})))}function _e(){return"0.20.5"}function $(){return _(this,void 0,void 0,(function(){var t,e,n,o,i;return b(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),t=V(),e=Object.keys(t),[4,ye(Object.values(t),m?.timeout||1e3,K)];case 1:return n=a.sent(),o=n.filter((function(r){return r!==void 0})),i={},o.forEach((function(r,c){i[e[c]]=r})),[2,z(i,m.exclude||[],m.include||[],"")];case 2:throw a.sent();case 3:return[2]}}))}))}function z(t,e,n,o){o===void 0&&(o="");for(var i={},a=function(l,s){var h=o+l+".";if(typeof s!="object"||Array.isArray(s)){var S=e.some((function(P){return h.startsWith(P)})),f=n.some((function(P){return h.startsWith(P)}));S&&!f||(i[l]=s)}else{var x=z(s,e,n,h);Object.keys(x).length>0&&(i[l]=x)}},r=0,c=Object.entries(t);r<c.length;r++){var u=c[r];a(u[0],u[1])}return i}function be(t){return _(this,void 0,void 0,(function(){var e,n;return b(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,$()];case 1:return e=o.sent(),n=L(JSON.stringify(e)),Math.random()<1e-5&&m.logging&&(function(i,a){_(this,void 0,void 0,(function(){var r,c;return b(this,(function(u){switch(u.label){case 0:if(r="https://logging.thumbmarkjs.com/v1/log",c={thumbmark:i,components:a,version:"0.20.5"},sessionStorage.getItem("_tmjs_l"))return[3,4];sessionStorage.setItem("_tmjs_l","1"),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:case 3:return u.sent(),[3,4];case 4:return[2]}}))}))})(n,e),t?[2,{hash:n.toString(),data:e}]:[2,n.toString()];case 2:throw o.sent();case 3:return[2]}}))}))}function we(){return _(this,void 0,void 0,(function(){var t,e,n,o;return b(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=V(),e=Object.keys(t),[4,ve(Object.values(t),m?.timeout||1e3,K)];case 1:return n=i.sent(),o={elapsed:{}},n.forEach((function(a,r){o[e[r]]=a.value,o.elapsed[e[r]]=a.elapsed})),[2,o];case 2:throw i.sent();case 3:return[2]}}))}))}function k(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};for(var t=navigator.userAgent,e={edg:"Edge",opr:"Opera",samsung:"SamsungBrowser"},n=0,o=[/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/,/(?<name>samsung).*Version\/(?<version>\d+(?:\.\d+)?)/i,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/];n<o.length;n++){var i=o[n],a=t.match(i);if(a&&a.groups)return{name:e[a.groups.name.toLowerCase()]||a.groups.name,version:a.groups.version}}return{name:"unknown",version:"unknown"}}function Se(t){for(var e=0,n=0;n<t.length;++n)e+=Math.abs(t[n]);return e}function q(t,e,n){for(var o=[],i=0;i<t[0].data.length;i++){for(var a=[],r=0;r<t.length;r++)a.push(t[r].data[i]);o.push(xe(a))}var c=new Uint8ClampedArray(o);return new ImageData(c,e,n)}function xe(t){if(t.length===0)return 0;for(var e={},n=0,o=t;n<o.length;n++)e[a=o[n]]=(e[a]||0)+1;var i=t[0];for(var a in e)e[a]>e[i]&&(i=parseInt(a,10));return i}function F(t,e){if(!t)throw new Error("Canvas context not supported");return t.font,t.font="72px ".concat(e),t.measureText("WwMmLli0Oo").width}function Ae(){var t,e=document.createElement("canvas"),n=(t=e.getContext("webgl"))!==null&&t!==void 0?t:e.getContext("experimental-webgl");if(n&&"getParameter"in n)try{var o=(n.getParameter(n.VENDOR)||"").toString(),i=(n.getParameter(n.RENDERER)||"").toString(),a={vendor:o,renderer:i,version:(n.getParameter(n.VERSION)||"").toString(),shadingLanguageVersion:(n.getParameter(n.SHADING_LANGUAGE_VERSION)||"").toString()};if(!i.length||!o.length){var r=n.getExtension("WEBGL_debug_renderer_info");if(r){var c=(n.getParameter(r.UNMASKED_VENDOR_WEBGL)||"").toString(),u=(n.getParameter(r.UNMASKED_RENDERER_WEBGL)||"").toString();c&&(a.vendorUnmasked=c),u&&(a.rendererUnmasked=u)}}return a}catch{}return"undefined"}function Ce(){var t=new Float32Array(1),e=new Uint8Array(t.buffer);return t[0]=1/0,t[0]=t[0]-t[0],e[3]}function Re(t,e){var n={};return e.forEach((function(o){var i=(function(a){if(a.length===0)return null;var r={};a.forEach((function(l){var s=String(l);r[s]=(r[s]||0)+1}));var c=a[0],u=1;return Object.keys(r).forEach((function(l){r[l]>u&&(c=l,u=r[l])})),c})(t.map((function(a){return o in a?a[o]:void 0})).filter((function(a){return a!==void 0})));i&&(n[o]=i)})),n}function De(){var t=[],e={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(e).forEach((function(n){e[n].forEach((function(o){matchMedia("(".concat(n,": ").concat(o,")")).matches&&t.push("".concat(n,": ").concat(o))}))})),t}function Te(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{for(var t=window.ApplePaySession.supportsVersion,e=15;e>0;e--)if(t(e))return e}catch{return 0}return 0}var m,H,K,y,V,g,Ee,Q,W,ke,Me,T,Ie,Pe,p,Le,d,E,X=ue(()=>{"use strict";m={exclude:[],include:[],logging:!0,timeout:1e3};H={},K={timeout:"true"},y=function(t,e){typeof window<"u"&&(H[t]=e)},V=function(){return Object.fromEntries(Object.entries(H).filter((function(t){var e,n=t[0];return!(!((e=m?.exclude)===null||e===void 0)&&e.includes(n))})).filter((function(t){var e,n,o,i,a=t[0];return!((e=m?.include)===null||e===void 0)&&e.some((function(r){return r.includes(".")}))?(n=m?.include)===null||n===void 0?void 0:n.some((function(r){return r.startsWith(a)})):((o=m?.include)===null||o===void 0?void 0:o.length)===0||((i=m?.include)===null||i===void 0?void 0:i.includes(a))})).map((function(t){return[t[0],(0,t[1])()]})))};g=new Uint32Array([597399067,2869860233,951274213,2716044179]);Ee=k();["SamsungBrowser","Safari"].includes(Ee.name)||y("audio",(function(){return _(this,void 0,void 0,(function(){return b(this,(function(t){return[2,new Promise((function(e,n){try{var o=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),i=o.createBufferSource(),a=o.createOscillator();a.frequency.value=1e3;var r,c=o.createDynamicsCompressor();c.threshold.value=-50,c.knee.value=40,c.ratio.value=12,c.attack.value=0,c.release.value=.2,a.connect(c),c.connect(o.destination),a.start(),o.oncomplete=function(u){r=u.renderedBuffer.getChannelData(0),e({sampleHash:Se(r),oscillator:a.type,maxChannels:o.destination.maxChannelCount,channelCountMode:i.channelCountMode})},o.startRendering()}catch(u){console.error("Error creating audio fingerprint:",u),n(u)}}))]}))}))}));Q=k(),W=Q.name.toLowerCase(),ke=Q.version.split(".")[0]||"0",Me=parseInt(ke,10);W==="firefox"||W==="safari"&&Me===17||y("canvas",(function(){return document.createElement("canvas").getContext("2d"),new Promise((function(t){var e=Array.from({length:3},(function(){return(function(){var n=document.createElement("canvas"),o=n.getContext("2d");if(!o)return new ImageData(1,1);n.width=280,n.height=20;var i=o.createLinearGradient(0,0,n.width,n.height);i.addColorStop(0,"red"),i.addColorStop(.16666666666666666,"orange"),i.addColorStop(.3333333333333333,"yellow"),i.addColorStop(.5,"green"),i.addColorStop(.6666666666666666,"blue"),i.addColorStop(.8333333333333334,"indigo"),i.addColorStop(1,"violet"),o.fillStyle=i,o.fillRect(0,0,n.width,n.height);var a="Random Text WMwmil10Oo";return o.font="23.123px Arial",o.fillStyle="black",o.fillText(a,-5,15),o.fillStyle="rgba(0, 0, 255, 0.5)",o.fillText(a,-3.3,17.7),o.beginPath(),o.moveTo(0,0),o.lineTo(2*n.width/7,n.height),o.strokeStyle="white",o.lineWidth=2,o.stroke(),o.getImageData(0,0,n.width,n.height)})()}));t({commonImageDataHash:L(q(e,280,20).data.toString()).toString()})}))}));Ie=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],Pe=["monospace","sans-serif","serif"];k().name!="Firefox"&&y("fonts",(function(){var t=this;return new Promise((function(e,n){try{(function(o){var i;_(this,void 0,void 0,(function(){var a,r,c;return b(this,(function(u){switch(u.label){case 0:return document.body?[3,2]:[4,(l=50,new Promise((function(h){return setTimeout(h,l,s)})))];case 1:return u.sent(),[3,0];case 2:if((a=document.createElement("iframe")).setAttribute("frameBorder","0"),(r=a.style).setProperty("position","fixed"),r.setProperty("display","block","important"),r.setProperty("visibility","visible"),r.setProperty("border","0"),r.setProperty("opacity","0"),a.src="about:blank",document.body.appendChild(a),!(c=a.contentDocument||((i=a.contentWindow)===null||i===void 0?void 0:i.document)))throw new Error("Iframe document is not accessible");return o({iframe:c}),setTimeout((function(){document.body.removeChild(a)}),0),[2]}var l,s}))}))})((function(o){var i=o.iframe;return _(t,void 0,void 0,(function(){var a,r,c,u;return b(this,(function(l){return a=i.createElement("canvas"),r=a.getContext("2d"),c=Pe.map((function(s){return F(r,s)})),u={},Ie.forEach((function(s){var h=F(r,s);c.includes(h)||(u[s]=h)})),e(u),[2]}))}))}))}catch{n({error:"unsupported"})}}))})),y("hardware",(function(){return new Promise((function(t,e){var n=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,o=window.performance&&window.performance.memory?window.performance.memory:0;t({videocard:Ae(),architecture:Ce(),deviceMemory:n.toString()||"undefined",jsHeapSizeLimit:o.jsHeapSizeLimit||0})}))})),y("locales",(function(){return new Promise((function(t){t({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))})),y("permissions",(function(){return _(this,void 0,void 0,(function(){var t;return b(this,(function(e){return T=m?.permissions_to_check||["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"],t=Array.from({length:m?.retries||3},(function(){return(function(){return _(this,void 0,void 0,(function(){var n,o,i,a,r;return b(this,(function(c){switch(c.label){case 0:n={},o=0,i=T,c.label=1;case 1:if(!(o<i.length))return[3,6];a=i[o],c.label=2;case 2:return c.trys.push([2,4,,5]),[4,navigator.permissions.query({name:a})];case 3:return r=c.sent(),n[a]=r.state.toString(),[3,5];case 4:return c.sent(),[3,5];case 5:return o++,[3,1];case 6:return[2,n]}}))}))})()})),[2,Promise.all(t).then((function(n){return Re(n,T)}))]}))}))})),y("plugins",(function(){var t=[];if(navigator.plugins)for(var e=0;e<navigator.plugins.length;e++){var n=navigator.plugins[e];t.push([n.name,n.filename,n.description].join("|"))}return new Promise((function(o){o({plugins:t})}))})),y("screen",(function(){return new Promise((function(t){t({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:De()})}))})),y("system",(function(){return new Promise((function(t){var e=k();t({platform:window.navigator.platform,cookieEnabled:window.navigator.cookieEnabled,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:e.name,version:e.version},applePayVersion:Te()})}))}));Le=k().name!=="SamsungBrowser"?1:3,d=null;y("webgl",(function(){return _(this,void 0,void 0,(function(){var t;return b(this,(function(e){typeof document<"u"&&((p=document.createElement("canvas")).width=200,p.height=100,d=p.getContext("webgl"));try{if(!d)throw new Error("WebGL not supported");return t=Array.from({length:Le},(function(){return(function(){try{if(!d)throw new Error("WebGL not supported");var n=`
|
|
2
2
|
attribute vec2 position;
|
|
3
3
|
void main() {
|
|
4
4
|
gl_Position = vec4(position, 0.0, 1.0);
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
void main() {
|
|
9
9
|
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
10
10
|
}
|
|
11
|
-
`,i=d.createShader(d.VERTEX_SHADER),a=d.createShader(d.FRAGMENT_SHADER);if(!i||!a)throw new Error("Failed to create shaders");if(d.shaderSource(i,r),d.shaderSource(a,o),d.compileShader(i),!d.getShaderParameter(i,d.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+d.getShaderInfoLog(i));if(d.compileShader(a),!d.getShaderParameter(a,d.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+d.getShaderInfoLog(a));var n=d.createProgram();if(!n)throw new Error("Failed to create shader program");if(d.attachShader(n,i),d.attachShader(n,a),d.linkProgram(n),!d.getProgramParameter(n,d.LINK_STATUS))throw new Error("Shader program linking failed: "+d.getProgramInfoLog(n));d.useProgram(n);for(var c=137,u=new Float32Array(4*c),l=2*Math.PI/c,s=0;s<c;s++){var f=s*l;u[4*s]=0,u[4*s+1]=0,u[4*s+2]=Math.cos(f)*(p.width/2),u[4*s+3]=Math.sin(f)*(p.height/2)}var S=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,S),d.bufferData(d.ARRAY_BUFFER,u,d.STATIC_DRAW);var m=d.getAttribLocation(n,"position");d.enableVertexAttribArray(m),d.vertexAttribPointer(m,2,d.FLOAT,!1,0,0),d.viewport(0,0,p.width,p.height),d.clearColor(0,0,0,1),d.clear(d.COLOR_BUFFER_BIT),d.drawArrays(d.LINES,0,2*c);var E=new Uint8ClampedArray(p.width*p.height*4);return d.readPixels(0,0,p.width,p.height,d.RGBA,d.UNSIGNED_BYTE,E),new ImageData(E,p.width,p.height)}catch{return new ImageData(1,1)}finally{d&&(d.bindBuffer(d.ARRAY_BUFFER,null),d.useProgram(null),d.viewport(0,0,d.drawingBufferWidth,d.drawingBufferHeight),d.clearColor(0,0,0,0))}})()})),[2,{commonImageHash:D(K(t,p.width,p.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]}))}))}));x=function(t,e,r,o){for(var i=(r-e)/o,a=0,n=0;n<o;n++)a+=t(e+(n+.5)*i);return a*i};y("math",(function(){return w(void 0,void 0,void 0,(function(){return b(this,(function(t){return[2,{acos:Math.acos(.5),asin:x(Math.asin,-1,1,97),atan:x(Math.atan,-1,1,97),cos:x(Math.cos,0,Math.PI,97),cosh:Math.cosh(9/7),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:x(Math.sin,-Math.PI,Math.PI,97),sinh:x(Math.sinh,-9/7,7/9,97),sqrt:Math.sqrt(2),tan:x(Math.tan,0,2*Math.PI,97),tanh:x(Math.tanh,-9/7,7/9,97)}]}))}))}))});var $e={};U($e,{QuickCheckDeviceIntel:()=>P,default:()=>Ke});var _=class extends Error{constructor(r,o,i,a){super(r);this.code=o;this.status=i;this.details=a;this.name="QuickCheckError"}};var ue="https://api.quickcheck.com.pa",de="/api/v1/sdk/device-intel/assess";function ge(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let t=Math.random().toString(36).slice(2);return`${Date.now().toString(36)}-${t}`}var M=class{constructor(e){if(!e.apiKey)throw new _("apiKey is required","MISSING_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??ue).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let r=`${this.apiUrl}${de}`,o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),a=ge(),n=new Date().toISOString(),c;try{c=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-QC-SDK-Key":this.apiKey,"X-QC-SDK-Platform":e.platform,"X-QC-Nonce":a,"X-QC-Timestamp":n},body:JSON.stringify(e),signal:o.signal})}catch(l){throw clearTimeout(i),l.name==="AbortError"?new _(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new _(`Network error: ${l.message}`,"NETWORK_ERROR",void 0,l)}clearTimeout(i);let u;try{u=await c.json()}catch{throw new _(`Invalid JSON response (status ${c.status})`,"INVALID_RESPONSE",c.status)}if(!c.ok){let l=typeof u=="object"&&u!==null&&"detail"in u?String(u.detail):`HTTP ${c.status}`,s=c.status===401?"UNAUTHORIZED":c.status===403?"FORBIDDEN":c.status===429?"RATE_LIMITED":"HTTP_ERROR";throw new _(l,s,c.status,u)}return u}};function G(){let t=typeof navigator<"u"?navigator:{},e=typeof window<"u"?window.screen:null,r=e?`${e.width}x${e.height}`:null,o=null,i=null;try{o=new Date().getTimezoneOffset(),i=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}let a=(t.userAgent||"").toLowerCase(),n="desktop";/mobi|iphone|ipod|android/.test(a)?n="mobile":/ipad|tablet/.test(a)&&(n="tablet");let c="Unknown",u=null;if(/windows nt/.test(a)){c="Windows";let s=a.match(/windows nt ([\d.]+)/);u=s?s[1]:null}else if(/mac os x/.test(a)){c="macOS";let s=a.match(/mac os x ([\d_.]+)/);u=s?s[1].replace(/_/g,"."):null}else if(/android/.test(a)){c="Android";let s=a.match(/android ([\d.]+)/);u=s?s[1]:null}else if(/iphone|ipad|ipod/.test(a)){c="iOS";let s=a.match(/os ([\d_]+) like mac/);u=s?s[1].replace(/_/g,"."):null}else/linux/.test(a)&&(c="Linux");let l=t.deviceMemory??null;return{type:n,os_name:c,os_version:u,screen_resolution:r,language:t.language??null,languages:t.languages?Array.from(t.languages):[],timezone_offset:o,timezone_name:i,hardware_concurrency:t.hardwareConcurrency??null,device_memory_gb:l,touch_support:typeof window<"u"&&("ontouchstart"in window||(t.maxTouchPoints??0)>0)}}async function Y(){try{let e=await(await Promise.resolve().then(()=>(q(),z))).getFingerprint();return typeof e=="string"?e:e&&typeof e.thumbmark=="string"?e.thumbmark:Q()}catch{return Q()}}function Q(){let e=[typeof navigator<"u"?navigator.userAgent:"",typeof navigator<"u"?navigator.language:"",typeof screen<"u"?`${screen.width}x${screen.height}`:"",typeof screen<"u"?String(screen.colorDepth):"",String(new Date().getTimezoneOffset()),typeof navigator<"u"?String(navigator.hardwareConcurrency??""):""].join("|"),r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o),r|=0;return"qc_fb_"+Math.abs(r).toString(16).padStart(8,"0")}async function X(t=1e4){return typeof navigator>"u"||!navigator.geolocation?null:new Promise(e=>{let r=setTimeout(()=>e(null),t);navigator.geolocation.getCurrentPosition(o=>{clearTimeout(r),e({latitude:o.coords.latitude,longitude:o.coords.longitude,accuracy_m:Math.round(o.coords.accuracy),source:"gps"})},()=>{clearTimeout(r),e(null)},{enableHighAccuracy:!1,timeout:t,maximumAge:6e4})})}function J(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function T(t=3e3){let e={ipv4:null,ipv6:null,all_v4:[],all_v6:[],method:"webrtc_stun"};return typeof RTCPeerConnection>"u"?e:new Promise(r=>{let o=new Set,i=new Set,a=!1,n=()=>{if(!a){a=!0;try{u.close()}catch{}e.all_v4=[...o],e.all_v6=[...i],e.ipv4=e.all_v4[0]??null,e.ipv6=e.all_v6[0]??null,r(e)}},c=setTimeout(n,t),u;try{u=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]}),u.createDataChannel("ip-discovery"),u.onicecandidate=l=>{if(!l.candidate){clearTimeout(c),n();return}let s=l.candidate.candidate;if(!s.includes("srflx"))return;let f=s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/);if(f){let m=f[1];!m.startsWith("10.")&&!m.startsWith("192.168.")&&!m.startsWith("172.16.")&&!m.startsWith("172.17.")&&!m.startsWith("172.18.")&&!m.startsWith("172.19.")&&!m.startsWith("172.2")&&!m.startsWith("172.30.")&&!m.startsWith("172.31.")&&!m.startsWith("127.")&&o.add(m)}let S=s.match(/([a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})/i);S&&!S[1].startsWith("fe80")&&i.add(S[1])},u.createOffer().then(l=>u.setLocalDescription(l)).catch(()=>{clearTimeout(c),n()})}catch{clearTimeout(c),r(e)}})}async function Z(t=2e3){let e=await T(t);return[...e.all_v4,...e.all_v6]}async function ee(){let t=De(),e=Te(),r=await Le(),o=await Z(1500);return{is_incognito:r,webgl_renderer:t,canvas_hash:e,local_ips:o}}function De(){try{let t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return null;let r=e.getExtension("WEBGL_debug_renderer_info");return r?e.getParameter(r.UNMASKED_RENDERER_WEBGL):null}catch{return null}}function Te(){try{let t=document.createElement("canvas");t.width=220,t.height=60;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="14px Arial",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("QuickCheck Device Intelligence",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("QuickCheck Device Intelligence",4,17);let r=t.toDataURL(),o=0;for(let i=0;i<r.length;i++){let a=r.charCodeAt(i);o=(o<<5)-o+a,o|=0}return o.toString(16)}catch{return null}}async function Le(){try{let t=navigator;if(t.storage?.estimate){let{quota:e}=await t.storage.estimate();if(typeof e=="number")return e<120*1024*1024}}catch{}return null}function Ue(){try{return{acos04:Math.acos(.4),asin04:Math.asin(.4),atan04:Math.atan(.4),atanh04:Math.atanh(.4),cbrt100:Math.cbrt(100),cosh1:Math.cosh(1),expm11:Math.expm1(1),log1p10:Math.log1p(10),sinh1:Math.sinh(1),tanh1:Math.tanh(1),pow1_1e100:Math.pow(1.1,100)}}catch{return{}}}async function Ge(){try{let t=document.createElement("canvas");t.width=200,t.height=40;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="18px sans-serif",e.fillText("\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}\u{1F1F5}\u{1F1E6}\u{1F44D}\u{1F3FD}\u{1FAE1}",2,2);let r=t.toDataURL();return He(r)}catch{return null}}function Ne(){try{if(!("speechSynthesis"in window))return{count:0,fingerprint:null};let t=window.speechSynthesis.getVoices();if(!t||t.length===0)return{count:0,fingerprint:null};let e=t.map(r=>`${r.name}|${r.lang}|${r.localService?"L":"R"}`).sort().join(",");return{count:t.length,fingerprint:L(e)}}catch{return{count:0,fingerprint:null}}}async function Oe(){let t={audioinput:0,audiooutput:0,videoinput:0};try{if(!navigator.mediaDevices?.enumerateDevices)return t;let e=await navigator.mediaDevices.enumerateDevices();for(let r of e)r.kind==="audioinput"?t.audioinput++:r.kind==="audiooutput"?t.audiooutput++:r.kind==="videoinput"&&t.videoinput++}catch{}return t}function We(){try{let t=new Intl.DateTimeFormat().resolvedOptions();return`${t.locale}|${t.calendar}|${t.numberingSystem}|${t.hourCycle??"-"}|${t.timeZone}`}catch{return null}}async function Fe(){try{let t=navigator.keyboard;if(!t?.getLayoutMap)return null;let e=await t.getLayoutMap(),r=[];for(let[o,i]of e.entries())r.push(`${o}=${i}`);return L(r.sort().join("|"))}catch{return null}}function Be(){let t={vendor:null,renderer:null,extensions:[],shaderPrecision:null};try{let e=document.createElement("canvas"),r=e.getContext("webgl")||e.getContext("experimental-webgl");if(!r)return t;let o=r.getExtension("WEBGL_debug_renderer_info");o&&(t.vendor=r.getParameter(o.UNMASKED_VENDOR_WEBGL),t.renderer=r.getParameter(o.UNMASKED_RENDERER_WEBGL)),t.extensions=r.getSupportedExtensions()??[];let i=r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT),a=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);i&&a&&(t.shaderPrecision=`v:${i.rangeMin}/${i.rangeMax}/${i.precision};f:${a.rangeMin}/${a.rangeMax}/${a.precision}`)}catch{}return t}function L(t){let e=2166136261;for(let r=0;r<t.length;r++)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}async function He(t){try{let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e),o=new Uint8Array(r),i="";for(let a=0;a<16;a++)i+=o[a].toString(16).padStart(2,"0");return i}catch{return L(t)}}async function Ve(){try{let t=navigator.userAgentData;if(!t?.getHighEntropyValues)return null;let e=await t.getHighEntropyValues(["platform","platformVersion","architecture","bitness","model","fullVersionList","wow64"]);return{platform:e.platform,platformVersion:e.platformVersion,architecture:e.architecture,bitness:e.bitness,model:e.model,fullVersionList:e.fullVersionList,mobile:t.mobile,wow64:e.wow64}}catch{return null}}async function te(){let[t,e,r,o]=await Promise.all([Ge(),Oe(),Fe(),Ve()]);return{math_constants:Ue(),emoji_hash:t,speech_voices:Ne(),media_devices:e,intl_signature:We(),keyboard_layout_hash:r,webgl_advanced:Be(),client_hints:o}}var je="1.0.0",ne="qcdi_session_uuid",re="qcdi_previous_page",P=class{constructor(e){this.deviceSignals=null;this.privacySignals=null;this.advancedSignals=null;this.initialized=!1;this.sessionUuid="";this.geoWatchId=null;this.geoHistory=[];this.lastGeoLat=null;this.lastGeoLon=null;this.clientIpv4=null;this.clientIpv6=null;this.config={apiKey:e.apiKey,apiUrl:e.apiUrl??"https://api.quickcheck.com.pa",autoCollect:e.autoCollect??!0,requestGeolocation:e.requestGeolocation??!1,continuousGeolocation:e.continuousGeolocation??!1,timeout:e.timeout??5e3,onError:e.onError??(r=>console.error("[QCDI]",r)),debug:e.debug??!1},this.client=new M({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,timeout:this.config.timeout}),this.sessionUuid=this.resolveSessionUuid(),this.config.autoCollect&&this.initialize()}resolveSessionUuid(){try{let e=sessionStorage.getItem(ne);if(e)return e;let r=this.generateUuid();return sessionStorage.setItem(ne,r),r}catch{return this.generateUuid()}}generateUuid(){let e="0123456789abcdef",r="qcdis-";for(let o=0;o<32;o++)r+=e[Math.floor(Math.random()*16)],(o===7||o===11||o===15||o===19)&&(r+="-");return r}async initialize(){if(!this.initialized){this.config.debug&&console.log("[QCDI] Initializing...");try{let e=await Y(),r=G();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...r},this.privacySignals=await ee(),this.advancedSignals=await te();let o=await T(2e3);this.clientIpv4=o.ipv4,this.clientIpv6=o.ipv6,this.initialized=!0,this.config.continuousGeolocation&&this.config.requestGeolocation&&this.startContinuousGeolocation(),this.config.debug&&console.log("[QCDI] Initialized",{fingerprint:e,session_uuid:this.sessionUuid,ipv4:this.clientIpv4,ipv6:this.clientIpv6})}catch(e){this.config.onError(e)}}}startContinuousGeolocation(){typeof navigator>"u"||!navigator.geolocation||this.geoWatchId===null&&(this.geoWatchId=navigator.geolocation.watchPosition(e=>{let{latitude:r,longitude:o,accuracy:i}=e.coords;this.lastGeoLat!==null&&this.lastGeoLon!==null&&this.haversineMeters(this.lastGeoLat,this.lastGeoLon,r,o)<50||(this.lastGeoLat=r,this.lastGeoLon=o,this.geoHistory.push({latitude:r,longitude:o,accuracy_m:Math.round(i),timestamp:new Date().toISOString()}),this.geoHistory.length>100&&(this.geoHistory=this.geoHistory.slice(-100)))},e=>{this.config.debug&&console.warn("[QCDI] Geo watch error:",e)},{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e4}))}haversineMeters(e,r,o,i){let n=s=>s*Math.PI/180,c=n(o-e),u=n(i-r),l=Math.sin(c/2)**2+Math.cos(n(e))*Math.cos(n(o))*Math.sin(u/2)**2;return 2*6371e3*Math.asin(Math.sqrt(l))}getPreviousPageUrl(){try{if(typeof document<"u"&&document.referrer)return document.referrer.slice(0,500)}catch{}return null}getFlowFromUrl(){try{let e=sessionStorage.getItem(re);return typeof window<"u"&&sessionStorage.setItem(re,window.location.href.slice(0,500)),e}catch{return null}}async assess(e){if(await this.initialize(),!this.deviceSignals)throw new Error("Device signals not collected. Call initialize() first.");let r=null;this.config.continuousGeolocation&&this.lastGeoLat!==null?r={latitude:this.lastGeoLat,longitude:this.lastGeoLon,accuracy_m:null,source:"gps"}:this.config.requestGeolocation&&(r=await X());let o={sdk_version:je,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:J(),privacy:this.privacySignals,geolocation:r,advanced:this.advancedSignals,context:{external_user_id:e.externalUserId??null,external_session_id:e.externalSessionId??null,declared_country:e.declaredCountry??null,person_name:e.personName??null,person_document_id:e.personDocumentId??null,custom_fields:e.customFields??{},previous_page_url:this.getPreviousPageUrl(),flow_from_url:this.getFlowFromUrl(),session_uuid:this.sessionUuid,geolocation_history:this.geoHistory.slice(),client_ipv4:this.clientIpv4,client_ipv6:this.clientIpv6,app_session_id:e.appSessionId??null}};this.config.debug&&console.log("[QCDI] Assessing",o);try{let i=await this.client.assess(o);return this.config.debug&&console.log("[QCDI] Result",i),i}catch(i){throw this.config.onError(i),i}}async refresh(){this.initialized=!1,await this.initialize()}destroy(){this.geoWatchId!==null&&typeof navigator<"u"&&navigator.geolocation.clearWatch(this.geoWatchId),this.geoWatchId=null,this.geoHistory=[],this.deviceSignals=null,this.privacySignals=null,this.initialized=!1}};var Ke=P;return ce($e);})();
|
|
11
|
+
`,i=d.createShader(d.VERTEX_SHADER),a=d.createShader(d.FRAGMENT_SHADER);if(!i||!a)throw new Error("Failed to create shaders");if(d.shaderSource(i,n),d.shaderSource(a,o),d.compileShader(i),!d.getShaderParameter(i,d.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+d.getShaderInfoLog(i));if(d.compileShader(a),!d.getShaderParameter(a,d.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+d.getShaderInfoLog(a));var r=d.createProgram();if(!r)throw new Error("Failed to create shader program");if(d.attachShader(r,i),d.attachShader(r,a),d.linkProgram(r),!d.getProgramParameter(r,d.LINK_STATUS))throw new Error("Shader program linking failed: "+d.getProgramInfoLog(r));d.useProgram(r);for(var c=137,u=new Float32Array(4*c),l=2*Math.PI/c,s=0;s<c;s++){var h=s*l;u[4*s]=0,u[4*s+1]=0,u[4*s+2]=Math.cos(h)*(p.width/2),u[4*s+3]=Math.sin(h)*(p.height/2)}var S=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,S),d.bufferData(d.ARRAY_BUFFER,u,d.STATIC_DRAW);var f=d.getAttribLocation(r,"position");d.enableVertexAttribArray(f),d.vertexAttribPointer(f,2,d.FLOAT,!1,0,0),d.viewport(0,0,p.width,p.height),d.clearColor(0,0,0,1),d.clear(d.COLOR_BUFFER_BIT),d.drawArrays(d.LINES,0,2*c);var x=new Uint8ClampedArray(p.width*p.height*4);return d.readPixels(0,0,p.width,p.height,d.RGBA,d.UNSIGNED_BYTE,x),new ImageData(x,p.width,p.height)}catch{return new ImageData(1,1)}finally{d&&(d.bindBuffer(d.ARRAY_BUFFER,null),d.useProgram(null),d.viewport(0,0,d.drawingBufferWidth,d.drawingBufferHeight),d.clearColor(0,0,0,0))}})()})),[2,{commonImageHash:L(q(t,p.width,p.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]}))}))}));E=function(t,e,n,o){for(var i=(n-e)/o,a=0,r=0;r<o;r++)a+=t(e+(r+.5)*i);return a*i};y("math",(function(){return _(void 0,void 0,void 0,(function(){return b(this,(function(t){return[2,{acos:Math.acos(.5),asin:E(Math.asin,-1,1,97),atan:E(Math.atan,-1,1,97),cos:E(Math.cos,0,Math.PI,97),cosh:Math.cosh(9/7),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:E(Math.sin,-Math.PI,Math.PI,97),sinh:E(Math.sinh,-9/7,7/9,97),sqrt:Math.sqrt(2),tan:E(Math.tan,0,2*Math.PI,97),tanh:E(Math.tanh,-9/7,7/9,97)}]}))}))}))});var Qe={};O(Qe,{QuickCheckDeviceIntel:()=>I,default:()=>qe});var w=class extends Error{constructor(n,o,i,a){super(n);this.code=o;this.status=i;this.details=a;this.name="QuickCheckError"}};var he="https://api.quickcheck.com.pa",fe="/api/v1/sdk/device-intel/assess";function ge(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let t=Math.random().toString(36).slice(2);return`${Date.now().toString(36)}-${t}`}var A=class{constructor(e){if(!e.apiKey)throw new w("apiKey is required","MISSING_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??he).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let n=`${this.apiUrl}${fe}`,o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),a=ge(),r=new Date().toISOString(),c;try{c=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-QC-SDK-Key":this.apiKey,"X-QC-SDK-Platform":e.platform,"X-QC-Nonce":a,"X-QC-Timestamp":r},body:JSON.stringify(e),signal:o.signal})}catch(l){throw clearTimeout(i),l.name==="AbortError"?new w(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new w(`Network error: ${l.message}`,"NETWORK_ERROR",void 0,l)}clearTimeout(i);let u;try{u=await c.json()}catch{throw new w(`Invalid JSON response (status ${c.status})`,"INVALID_RESPONSE",c.status)}if(!c.ok){let l=typeof u=="object"&&u!==null&&"detail"in u?String(u.detail):`HTTP ${c.status}`,s=c.status===401?"UNAUTHORIZED":c.status===403?"FORBIDDEN":c.status===429?"RATE_LIMITED":"HTTP_ERROR";throw new w(l,s,c.status,u)}return u}};function B(){let t=typeof navigator<"u"?navigator:{},e=typeof window<"u"?window.screen:null,n=e?`${e.width}x${e.height}`:null,o=null,i=null;try{o=new Date().getTimezoneOffset(),i=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}let a=(t.userAgent||"").toLowerCase(),r="desktop";/mobi|iphone|ipod|android/.test(a)?r="mobile":/ipad|tablet/.test(a)&&(r="tablet");let c="Unknown",u=null;if(/windows nt/.test(a)){c="Windows";let s=a.match(/windows nt ([\d.]+)/);u=s?s[1]:null}else if(/mac os x/.test(a)){c="macOS";let s=a.match(/mac os x ([\d_.]+)/);u=s?s[1].replace(/_/g,"."):null}else if(/android/.test(a)){c="Android";let s=a.match(/android ([\d.]+)/);u=s?s[1]:null}else if(/iphone|ipad|ipod/.test(a)){c="iOS";let s=a.match(/os ([\d_]+) like mac/);u=s?s[1].replace(/_/g,"."):null}else/linux/.test(a)&&(c="Linux");let l=t.deviceMemory??null;return{type:r,os_name:c,os_version:u,screen_resolution:n,language:t.language??null,languages:t.languages?Array.from(t.languages):[],timezone_offset:o,timezone_name:i,hardware_concurrency:t.hardwareConcurrency??null,device_memory_gb:l,touch_support:typeof window<"u"&&("ontouchstart"in window||(t.maxTouchPoints??0)>0)}}async function Z(){try{let e=await(await Promise.resolve().then(()=>(X(),Y))).getFingerprint();return typeof e=="string"?e:e&&typeof e.thumbmark=="string"?e.thumbmark:J()}catch{return J()}}function J(){let e=[typeof navigator<"u"?navigator.userAgent:"",typeof navigator<"u"?navigator.language:"",typeof screen<"u"?`${screen.width}x${screen.height}`:"",typeof screen<"u"?String(screen.colorDepth):"",String(new Date().getTimezoneOffset()),typeof navigator<"u"?String(navigator.hardwareConcurrency??""):""].join("|"),n=0;for(let o=0;o<e.length;o++)n=(n<<5)-n+e.charCodeAt(o),n|=0;return"qc_fb_"+Math.abs(n).toString(16).padStart(8,"0")}async function ee(t=1e4){return typeof navigator>"u"||!navigator.geolocation?null:new Promise(e=>{let n=setTimeout(()=>e(null),t);navigator.geolocation.getCurrentPosition(o=>{clearTimeout(n),e({latitude:o.coords.latitude,longitude:o.coords.longitude,accuracy_m:Math.round(o.coords.accuracy),source:"gps"})},()=>{clearTimeout(n),e(null)},{enableHighAccuracy:!1,timeout:t,maximumAge:6e4})})}function te(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function U(t=3e3){let e={ipv4:null,ipv6:null,all_v4:[],all_v6:[],method:"webrtc_stun"};return typeof RTCPeerConnection>"u"?e:new Promise(n=>{let o=new Set,i=new Set,a=!1,r=()=>{if(!a){a=!0;try{u.close()}catch{}e.all_v4=[...o],e.all_v6=[...i],e.ipv4=e.all_v4[0]??null,e.ipv6=e.all_v6[0]??null,n(e)}},c=setTimeout(r,t),u;try{u=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]}),u.createDataChannel("ip-discovery"),u.onicecandidate=l=>{if(!l.candidate){clearTimeout(c),r();return}let s=l.candidate.candidate;if(!s.includes("srflx"))return;let h=s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/);if(h){let f=h[1];!f.startsWith("10.")&&!f.startsWith("192.168.")&&!f.startsWith("172.16.")&&!f.startsWith("172.17.")&&!f.startsWith("172.18.")&&!f.startsWith("172.19.")&&!f.startsWith("172.2")&&!f.startsWith("172.30.")&&!f.startsWith("172.31.")&&!f.startsWith("127.")&&o.add(f)}let S=s.match(/([a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})/i);S&&!S[1].startsWith("fe80")&&i.add(S[1])},u.createOffer().then(l=>u.setLocalDescription(l)).catch(()=>{clearTimeout(c),r()})}catch{clearTimeout(c),n(e)}})}async function ne(t=2e3){let e=await U(t);return[...e.all_v4,...e.all_v6]}async function re(){let t=Ue(),e=Ge(),n=await Ne(),o=await ne(1500);return{is_incognito:n,webgl_renderer:t,canvas_hash:e,local_ips:o}}function Ue(){try{let t=document.createElement("canvas"),e=t.getContext("webgl")||t.getContext("experimental-webgl");if(!e)return null;let n=e.getExtension("WEBGL_debug_renderer_info");return n?e.getParameter(n.UNMASKED_RENDERER_WEBGL):null}catch{return null}}function Ge(){try{let t=document.createElement("canvas");t.width=220,t.height=60;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="14px Arial",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText("QuickCheck Device Intelligence",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("QuickCheck Device Intelligence",4,17);let n=t.toDataURL(),o=0;for(let i=0;i<n.length;i++){let a=n.charCodeAt(i);o=(o<<5)-o+a,o|=0}return o.toString(16)}catch{return null}}async function Ne(){try{let t=navigator;if(t.storage?.estimate){let{quota:e}=await t.storage.estimate();if(typeof e=="number")return e<120*1024*1024}}catch{}return null}function Oe(){try{return{acos04:Math.acos(.4),asin04:Math.asin(.4),atan04:Math.atan(.4),atanh04:Math.atanh(.4),cbrt100:Math.cbrt(100),cosh1:Math.cosh(1),expm11:Math.expm1(1),log1p10:Math.log1p(10),sinh1:Math.sinh(1),tanh1:Math.tanh(1),pow1_1e100:Math.pow(1.1,100)}}catch{return{}}}async function Be(){try{let t=document.createElement("canvas");t.width=200,t.height=40;let e=t.getContext("2d");if(!e)return null;e.textBaseline="top",e.font="18px sans-serif",e.fillText("\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}\u{1F1F5}\u{1F1E6}\u{1F44D}\u{1F3FD}\u{1FAE1}",2,2);let n=t.toDataURL();return je(n)}catch{return null}}function We(){try{if(!("speechSynthesis"in window))return{count:0,fingerprint:null};let t=window.speechSynthesis.getVoices();if(!t||t.length===0)return{count:0,fingerprint:null};let e=t.map(n=>`${n.name}|${n.lang}|${n.localService?"L":"R"}`).sort().join(",");return{count:t.length,fingerprint:G(e)}}catch{return{count:0,fingerprint:null}}}async function Fe(){let t={audioinput:0,audiooutput:0,videoinput:0};try{if(!navigator.mediaDevices?.enumerateDevices)return t;let e=await navigator.mediaDevices.enumerateDevices();for(let n of e)n.kind==="audioinput"?t.audioinput++:n.kind==="audiooutput"?t.audiooutput++:n.kind==="videoinput"&&t.videoinput++}catch{}return t}function He(){try{let t=new Intl.DateTimeFormat().resolvedOptions();return`${t.locale}|${t.calendar}|${t.numberingSystem}|${t.hourCycle??"-"}|${t.timeZone}`}catch{return null}}async function Ke(){try{let t=navigator.keyboard;if(!t?.getLayoutMap)return null;let e=await t.getLayoutMap(),n=[];for(let[o,i]of e.entries())n.push(`${o}=${i}`);return G(n.sort().join("|"))}catch{return null}}function Ve(){let t={vendor:null,renderer:null,extensions:[],shaderPrecision:null};try{let e=document.createElement("canvas"),n=e.getContext("webgl")||e.getContext("experimental-webgl");if(!n)return t;let o=n.getExtension("WEBGL_debug_renderer_info");o&&(t.vendor=n.getParameter(o.UNMASKED_VENDOR_WEBGL),t.renderer=n.getParameter(o.UNMASKED_RENDERER_WEBGL)),t.extensions=n.getSupportedExtensions()??[];let i=n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT),a=n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT);i&&a&&(t.shaderPrecision=`v:${i.rangeMin}/${i.rangeMax}/${i.precision};f:${a.rangeMin}/${a.rangeMax}/${a.precision}`)}catch{}return t}function G(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}async function je(t){try{let e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),o=new Uint8Array(n),i="";for(let a=0;a<16;a++)i+=o[a].toString(16).padStart(2,"0");return i}catch{return G(t)}}async function $e(){try{let t=navigator.userAgentData;if(!t?.getHighEntropyValues)return null;let e=await t.getHighEntropyValues(["platform","platformVersion","architecture","bitness","model","fullVersionList","wow64"]);return{platform:e.platform,platformVersion:e.platformVersion,architecture:e.architecture,bitness:e.bitness,model:e.model,fullVersionList:e.fullVersionList,mobile:t.mobile,wow64:e.wow64}}catch{return null}}async function oe(){let[t,e,n,o]=await Promise.all([Be(),Fe(),Ke(),$e()]);return{math_constants:Oe(),emoji_hash:t,speech_voices:We(),media_devices:e,intl_signature:He(),keyboard_layout_hash:n,webgl_advanced:Ve(),client_hints:o}}var R=class{constructor(){this.keyEvents=[];this.mouseSamples=[];this.startTime=0;this.active=!1;this.mouseThrottleMs=50;this.lastMouseSample=0;this.onKeyDown=e=>{this.active&&this.keyEvents.push({code:e.code,downAt:performance.now()})};this.onKeyUp=e=>{if(!this.active)return;let n=[...this.keyEvents].reverse().find(o=>o.code===e.code&&!o.upAt);n&&(n.upAt=performance.now())};this.onMouseMove=e=>{if(!this.active)return;let n=performance.now();n-this.lastMouseSample<this.mouseThrottleMs||(this.lastMouseSample=n,this.mouseSamples.push({x:e.clientX,y:e.clientY,t:n}))}}start(){this.active||(this.active=!0,this.startTime=performance.now(),this.keyEvents=[],this.mouseSamples=[],document.addEventListener("keydown",this.onKeyDown,{passive:!0}),document.addEventListener("keyup",this.onKeyUp,{passive:!0}),document.addEventListener("mousemove",this.onMouseMove,{passive:!0}))}stop(){this.active=!1,document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mousemove",this.onMouseMove);let e=performance.now()-this.startTime;return{...this.computeKeystrokeMetrics(),...this.computeMouseMetrics(),total_keystrokes:this.keyEvents.filter(n=>n.upAt).length,total_mouse_events:this.mouseSamples.length,session_duration_ms:Math.round(e)}}computeKeystrokeMetrics(){let e=this.keyEvents.filter(i=>i.upAt);if(e.length<3)return{keystroke_dwell_mean_ms:0,keystroke_dwell_std_ms:0,keystroke_flight_mean_ms:0,keystroke_flight_std_ms:0};let n=e.map(i=>i.upAt-i.downAt),o=[];for(let i=1;i<e.length;i++){let a=e[i].downAt-(e[i-1].upAt??e[i-1].downAt);a>0&&a<2e3&&o.push(a)}return{keystroke_dwell_mean_ms:M(n),keystroke_dwell_std_ms:N(n),keystroke_flight_mean_ms:o.length>0?M(o):0,keystroke_flight_std_ms:o.length>0?N(o):0}}computeMouseMetrics(){if(this.mouseSamples.length<5)return{mouse_velocity_mean:0,mouse_velocity_std:0,mouse_acceleration_mean:0};let e=[];for(let o=1;o<this.mouseSamples.length;o++){let i=this.mouseSamples[o].x-this.mouseSamples[o-1].x,a=this.mouseSamples[o].y-this.mouseSamples[o-1].y,r=this.mouseSamples[o].t-this.mouseSamples[o-1].t;r>0&&e.push(Math.sqrt(i*i+a*a)/r)}let n=[];for(let o=1;o<e.length;o++){let i=this.mouseSamples[o+1].t-this.mouseSamples[o].t;i>0&&n.push(Math.abs(e[o]-e[o-1])/i)}return{mouse_velocity_mean:e.length>0?M(e):0,mouse_velocity_std:e.length>0?N(e):0,mouse_acceleration_mean:n.length>0?M(n):0}}};function M(t){return t.length===0?0:t.reduce((e,n)=>e+n,0)/t.length}function N(t){if(t.length<2)return 0;let e=M(t),n=t.reduce((o,i)=>o+(i-e)**2,0)/(t.length-1);return Math.sqrt(n)}var ze="1.0.0",ie="qcdi_session_uuid",ae="qcdi_previous_page",I=class{constructor(e){this.deviceSignals=null;this.privacySignals=null;this.advancedSignals=null;this.behavioralCollector=null;this.initialized=!1;this.sessionUuid="";this.geoWatchId=null;this.geoHistory=[];this.lastGeoLat=null;this.lastGeoLon=null;this.clientIpv4=null;this.clientIpv6=null;this.config={apiKey:e.apiKey,apiUrl:e.apiUrl??"https://api.quickcheck.com.pa",autoCollect:e.autoCollect??!0,requestGeolocation:e.requestGeolocation??!1,continuousGeolocation:e.continuousGeolocation??!1,timeout:e.timeout??5e3,onError:e.onError??(n=>console.error("[QCDI]",n)),debug:e.debug??!1},this.client=new A({apiKey:this.config.apiKey,apiUrl:this.config.apiUrl,timeout:this.config.timeout}),this.sessionUuid=this.resolveSessionUuid(),this.config.autoCollect&&this.initialize()}resolveSessionUuid(){try{let e=sessionStorage.getItem(ie);if(e)return e;let n=this.generateUuid();return sessionStorage.setItem(ie,n),n}catch{return this.generateUuid()}}generateUuid(){let e="0123456789abcdef",n="qcdis-";for(let o=0;o<32;o++)n+=e[Math.floor(Math.random()*16)],(o===7||o===11||o===15||o===19)&&(n+="-");return n}async initialize(){if(!this.initialized){this.config.debug&&console.log("[QCDI] Initializing...");try{let e=await Z(),n=B();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...n},this.privacySignals=await re(),this.advancedSignals=await oe();let o=await U(2e3);this.clientIpv4=o.ipv4,this.clientIpv6=o.ipv6,this.initialized=!0,this.behavioralCollector=new R,this.behavioralCollector.start(),this.config.continuousGeolocation&&this.config.requestGeolocation&&this.startContinuousGeolocation(),this.config.debug&&console.log("[QCDI] Initialized",{fingerprint:e,session_uuid:this.sessionUuid,ipv4:this.clientIpv4,ipv6:this.clientIpv6})}catch(e){this.config.onError(e)}}}startContinuousGeolocation(){typeof navigator>"u"||!navigator.geolocation||this.geoWatchId===null&&(this.geoWatchId=navigator.geolocation.watchPosition(e=>{let{latitude:n,longitude:o,accuracy:i}=e.coords;this.lastGeoLat!==null&&this.lastGeoLon!==null&&this.haversineMeters(this.lastGeoLat,this.lastGeoLon,n,o)<50||(this.lastGeoLat=n,this.lastGeoLon=o,this.geoHistory.push({latitude:n,longitude:o,accuracy_m:Math.round(i),timestamp:new Date().toISOString()}),this.geoHistory.length>100&&(this.geoHistory=this.geoHistory.slice(-100)))},e=>{this.config.debug&&console.warn("[QCDI] Geo watch error:",e)},{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e4}))}haversineMeters(e,n,o,i){let r=s=>s*Math.PI/180,c=r(o-e),u=r(i-n),l=Math.sin(c/2)**2+Math.cos(r(e))*Math.cos(r(o))*Math.sin(u/2)**2;return 2*6371e3*Math.asin(Math.sqrt(l))}getPreviousPageUrl(){try{if(typeof document<"u"&&document.referrer)return document.referrer.slice(0,500)}catch{}return null}getFlowFromUrl(){try{let e=sessionStorage.getItem(ae);return typeof window<"u"&&sessionStorage.setItem(ae,window.location.href.slice(0,500)),e}catch{return null}}async assess(e){if(await this.initialize(),!this.deviceSignals)throw new Error("Device signals not collected. Call initialize() first.");let n=null;this.config.continuousGeolocation&&this.lastGeoLat!==null?n={latitude:this.lastGeoLat,longitude:this.lastGeoLon,accuracy_m:null,source:"gps"}:this.config.requestGeolocation&&(n=await ee());let o={sdk_version:ze,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:te(),privacy:this.privacySignals,geolocation:n,advanced:this.advancedSignals,behavioral:this.behavioralCollector?this.behavioralCollector.stop():null,context:{external_user_id:e.externalUserId??null,external_session_id:e.externalSessionId??null,declared_country:e.declaredCountry??null,person_name:e.personName??null,person_document_id:e.personDocumentId??null,custom_fields:e.customFields??{},previous_page_url:this.getPreviousPageUrl(),flow_from_url:this.getFlowFromUrl(),session_uuid:this.sessionUuid,geolocation_history:this.geoHistory.slice(),client_ipv4:this.clientIpv4,client_ipv6:this.clientIpv6,app_session_id:e.appSessionId??null}};this.config.debug&&console.log("[QCDI] Assessing",o);try{let i=await this.client.assess(o);return this.config.debug&&console.log("[QCDI] Result",i),i}catch(i){throw this.config.onError(i),i}}async refresh(){this.initialized=!1,await this.initialize()}destroy(){this.geoWatchId!==null&&typeof navigator<"u"&&navigator.geolocation.clearWatch(this.geoWatchId),this.geoWatchId=null,this.geoHistory=[],this.deviceSignals=null,this.privacySignals=null,this.initialized=!1}};var qe=I;return me(Qe);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quickcheck/device-intel-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "QuickCheck Device Intelligence SDK — Device fingerprinting, IP intelligence, and real-time risk scoring for AML/KYC compliance (Article 14).",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "QuickCheck",
|