@quickcheck/device-intel-sdk 1.0.2 → 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 +50 -1
- package/dist/index.d.ts +50 -1
- 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
|
*
|
|
@@ -79,6 +110,19 @@ interface NetworkInfo {
|
|
|
79
110
|
* incognito, and browser updates. Used by the server-side matcher to
|
|
80
111
|
* assign a stable visitor_id even when network identity changes.
|
|
81
112
|
*/
|
|
113
|
+
interface ClientHintsData {
|
|
114
|
+
platform?: string;
|
|
115
|
+
platformVersion?: string;
|
|
116
|
+
architecture?: string;
|
|
117
|
+
bitness?: string;
|
|
118
|
+
model?: string;
|
|
119
|
+
fullVersionList?: Array<{
|
|
120
|
+
brand: string;
|
|
121
|
+
version: string;
|
|
122
|
+
}>;
|
|
123
|
+
mobile?: boolean;
|
|
124
|
+
wow64?: boolean;
|
|
125
|
+
}
|
|
82
126
|
interface AdvancedSignals {
|
|
83
127
|
/** Math.acos(0.4), Math.sinh(1), etc. — JS engine + version fingerprint */
|
|
84
128
|
math_constants: Record<string, number>;
|
|
@@ -106,6 +150,8 @@ interface AdvancedSignals {
|
|
|
106
150
|
extensions: string[];
|
|
107
151
|
shaderPrecision: string | null;
|
|
108
152
|
};
|
|
153
|
+
/** Client Hints high-entropy (Chromium 89+ only) */
|
|
154
|
+
client_hints?: ClientHintsData | null;
|
|
109
155
|
}
|
|
110
156
|
interface PrivacyInfo {
|
|
111
157
|
is_incognito: boolean | null;
|
|
@@ -162,6 +208,8 @@ interface DeviceIntelPayload {
|
|
|
162
208
|
* commercial device-identity products (FingerprintJS Pro, etc.).
|
|
163
209
|
*/
|
|
164
210
|
advanced?: AdvancedSignals | null;
|
|
211
|
+
/** Behavioral biometrics: keystroke + mouse dynamics summary (v1.0.4+) */
|
|
212
|
+
behavioral?: BehavioralSummary | null;
|
|
165
213
|
}
|
|
166
214
|
interface RiskInfo {
|
|
167
215
|
score: number;
|
|
@@ -243,6 +291,7 @@ declare class QuickCheckDeviceIntel {
|
|
|
243
291
|
private deviceSignals;
|
|
244
292
|
private privacySignals;
|
|
245
293
|
private advancedSignals;
|
|
294
|
+
private behavioralCollector;
|
|
246
295
|
private initialized;
|
|
247
296
|
private sessionUuid;
|
|
248
297
|
private geoWatchId;
|
|
@@ -295,4 +344,4 @@ declare class QCApiClient {
|
|
|
295
344
|
assess(payload: DeviceIntelPayload): Promise<AssessmentResult>;
|
|
296
345
|
}
|
|
297
346
|
|
|
298
|
-
export { type AdvancedSignals, type AssessOptions, type AssessmentMetadata, type AssessmentResult, type CoherenceCheckResult, type ContextInfo, type DeviceInfo, type DeviceIntelPayload, type FlagsSummary, type GeoVelocitySummary, type GeolocationInfo, type IPIntelSummary, type NetworkInfo, type Platform, type PrivacyInfo, QCApiClient, type QCConfig, QuickCheckDeviceIntel, QuickCheckError, type RiskAction, type RiskInfo, type RiskLevel, SDK_VERSION, type SessionType };
|
|
347
|
+
export { type AdvancedSignals, type AssessOptions, type AssessmentMetadata, type AssessmentResult, type ClientHintsData, type CoherenceCheckResult, type ContextInfo, type DeviceInfo, type DeviceIntelPayload, type FlagsSummary, type GeoVelocitySummary, type GeolocationInfo, type IPIntelSummary, type NetworkInfo, type Platform, type PrivacyInfo, QCApiClient, type QCConfig, QuickCheckDeviceIntel, QuickCheckError, type RiskAction, type RiskInfo, type RiskLevel, SDK_VERSION, type SessionType };
|
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
|
*
|
|
@@ -79,6 +110,19 @@ interface NetworkInfo {
|
|
|
79
110
|
* incognito, and browser updates. Used by the server-side matcher to
|
|
80
111
|
* assign a stable visitor_id even when network identity changes.
|
|
81
112
|
*/
|
|
113
|
+
interface ClientHintsData {
|
|
114
|
+
platform?: string;
|
|
115
|
+
platformVersion?: string;
|
|
116
|
+
architecture?: string;
|
|
117
|
+
bitness?: string;
|
|
118
|
+
model?: string;
|
|
119
|
+
fullVersionList?: Array<{
|
|
120
|
+
brand: string;
|
|
121
|
+
version: string;
|
|
122
|
+
}>;
|
|
123
|
+
mobile?: boolean;
|
|
124
|
+
wow64?: boolean;
|
|
125
|
+
}
|
|
82
126
|
interface AdvancedSignals {
|
|
83
127
|
/** Math.acos(0.4), Math.sinh(1), etc. — JS engine + version fingerprint */
|
|
84
128
|
math_constants: Record<string, number>;
|
|
@@ -106,6 +150,8 @@ interface AdvancedSignals {
|
|
|
106
150
|
extensions: string[];
|
|
107
151
|
shaderPrecision: string | null;
|
|
108
152
|
};
|
|
153
|
+
/** Client Hints high-entropy (Chromium 89+ only) */
|
|
154
|
+
client_hints?: ClientHintsData | null;
|
|
109
155
|
}
|
|
110
156
|
interface PrivacyInfo {
|
|
111
157
|
is_incognito: boolean | null;
|
|
@@ -162,6 +208,8 @@ interface DeviceIntelPayload {
|
|
|
162
208
|
* commercial device-identity products (FingerprintJS Pro, etc.).
|
|
163
209
|
*/
|
|
164
210
|
advanced?: AdvancedSignals | null;
|
|
211
|
+
/** Behavioral biometrics: keystroke + mouse dynamics summary (v1.0.4+) */
|
|
212
|
+
behavioral?: BehavioralSummary | null;
|
|
165
213
|
}
|
|
166
214
|
interface RiskInfo {
|
|
167
215
|
score: number;
|
|
@@ -243,6 +291,7 @@ declare class QuickCheckDeviceIntel {
|
|
|
243
291
|
private deviceSignals;
|
|
244
292
|
private privacySignals;
|
|
245
293
|
private advancedSignals;
|
|
294
|
+
private behavioralCollector;
|
|
246
295
|
private initialized;
|
|
247
296
|
private sessionUuid;
|
|
248
297
|
private geoWatchId;
|
|
@@ -295,4 +344,4 @@ declare class QCApiClient {
|
|
|
295
344
|
assess(payload: DeviceIntelPayload): Promise<AssessmentResult>;
|
|
296
345
|
}
|
|
297
346
|
|
|
298
|
-
export { type AdvancedSignals, type AssessOptions, type AssessmentMetadata, type AssessmentResult, type CoherenceCheckResult, type ContextInfo, type DeviceInfo, type DeviceIntelPayload, type FlagsSummary, type GeoVelocitySummary, type GeolocationInfo, type IPIntelSummary, type NetworkInfo, type Platform, type PrivacyInfo, QCApiClient, type QCConfig, QuickCheckDeviceIntel, QuickCheckError, type RiskAction, type RiskInfo, type RiskLevel, SDK_VERSION, type SessionType };
|
|
347
|
+
export { type AdvancedSignals, type AssessOptions, type AssessmentMetadata, type AssessmentResult, type ClientHintsData, type CoherenceCheckResult, type ContextInfo, type DeviceInfo, type DeviceIntelPayload, type FlagsSummary, type GeoVelocitySummary, type GeolocationInfo, type IPIntelSummary, type NetworkInfo, type Platform, type PrivacyInfo, QCApiClient, type QCConfig, QuickCheckDeviceIntel, QuickCheckError, type RiskAction, type RiskInfo, type RiskLevel, SDK_VERSION, type SessionType };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.create;var p=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var M=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},v=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!G.call(t,i)&&i!==n&&p(t,i,{get:()=>e[i],enumerable:!(o=R(e,i))||o.enumerable});return t};var L=(t,e,n)=>(n=t!=null?P(A(t)):{},v(e||!t||!t.__esModule?p(n,"default",{value:t,enumerable:!0}):n,t)),U=t=>v(p({},"__esModule",{value:!0}),t);var X={};M(X,{QCApiClient:()=>g,QuickCheckDeviceIntel:()=>f,QuickCheckError:()=>u,SDK_VERSION:()=>y});module.exports=U(X);var u=class extends Error{constructor(n,o,i,r){super(n);this.code=o;this.status=i;this.details=r;this.name="QuickCheckError"}};var T="https://api.quickcheck.com.pa",N="/api/v1/sdk/device-intel/assess";function O(){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 g=class{constructor(e){if(!e.apiKey)throw new u("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 n=`${this.apiUrl}${N}`,o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),r=O(),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:o.signal})}catch(d){throw clearTimeout(i),d.name==="AbortError"?new u(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new u(`Network error: ${d.message}`,"NETWORK_ERROR",void 0,d)}clearTimeout(i);let a;try{a=await s.json()}catch{throw new u(`Invalid JSON response (status ${s.status})`,"INVALID_RESPONSE",s.status)}if(!s.ok){let d=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 u(d,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,o=null,i=null;try{o=new Date().getTimezoneOffset(),i=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 d=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:o,timezone_name:i,hardware_concurrency:t.hardwareConcurrency??null,device_memory_gb:d,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 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 I(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 S(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function m(t=2e3){return typeof RTCPeerConnection>"u"?[]:new Promise(e=>{let n=new Set;try{let o=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});o.createDataChannel(""),o.onicecandidate=i=>{if(!i.candidate||!i.candidate.candidate)return;let r=i.candidate.candidate.match(/(\d{1,3}(\.\d{1,3}){3})|([a-f0-9:]+:+[a-f0-9]+)/);r&&r[0]&&n.add(r[0])},o.createOffer().then(i=>o.setLocalDescription(i)).catch(()=>{}),setTimeout(()=>{try{o.close()}catch{}e(Array.from(n))},t)}catch{e([])}})}async function x(){let t=$(),e=H(),n=await K(),o=await m(1500);return{is_incognito:n,webgl_renderer:t,canvas_hash:e,local_ips:o}}function $(){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 H(){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 r=n.charCodeAt(i);o=(o<<5)-o+r,o|=0}return o.toString(16)}catch{return null}}async function K(){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 z(){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 F(){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 W(){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 Q(){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 q(){try{let t=new Intl.DateTimeFormat().resolvedOptions();return`${t.locale}|${t.calendar}|${t.numberingSystem}|${t.hourCycle??"-"}|${t.timeZone}`}catch{return null}}async function B(){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 h(n.sort().join("|"))}catch{return null}}function V(){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),r=n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT);i&&r&&(t.shaderPrecision=`v:${i.rangeMin}/${i.rangeMax}/${i.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 j(t){try{let e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),o=new Uint8Array(n),i="";for(let r=0;r<16;r++)i+=o[r].toString(16).padStart(2,"0");return i}catch{return h(t)}}async function E(){let[t,e,n]=await Promise.all([F(),Q(),B()]);return{math_constants:z(),emoji_hash:t,speech_voices:W(),media_devices:e,intl_signature:q(),keyboard_layout_hash:n,webgl_advanced:V()}}var y="1.0.0",C="qcdi_session_uuid",k="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 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(C);if(e)return e;let n=this.generateUuid();return sessionStorage.setItem(C,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 w(),n=_();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...n},this.privacySignals=await x(),this.advancedSignals=await E();let o=await m(1500);for(let i of o)i.includes(":")?this.clientIpv6||(this.clientIpv6=i):this.clientIpv4||(this.clientIpv4=i);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: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 c=l=>l*Math.PI/180,s=c(o-e),a=c(i-n),d=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(d))}getPreviousPageUrl(){try{if(typeof document<"u"&&document.referrer)return document.referrer.slice(0,500)}catch{}return null}getFlowFromUrl(){try{let e=sessionStorage.getItem(k);return typeof window<"u"&&sessionStorage.setItem(k,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 I());let o={sdk_version:y,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:S(),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",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});
|
|
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 d=class extends Error{constructor(t,o,i,r){super(t);this.code=o;this.status=i;this.details=r;this.name="QuickCheckError"}};var C="https://api.quickcheck.com.pa",k="/api/v1/sdk/device-intel/assess";function P(){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??C).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let t=`${this.apiUrl}${k}`,o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),r=P(),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 h(){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 v(){try{let e=await(await import("@thumbmarkjs/thumbmarkjs")).getFingerprint();return typeof e=="string"?e:e&&typeof e.thumbmark=="string"?e.thumbmark:y()}catch{return y()}}function y(){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 _(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 b(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function p(n=2e3){return typeof RTCPeerConnection>"u"?[]:new Promise(e=>{let t=new Set;try{let o=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});o.createDataChannel(""),o.onicecandidate=i=>{if(!i.candidate||!i.candidate.candidate)return;let r=i.candidate.candidate.match(/(\d{1,3}(\.\d{1,3}){3})|([a-f0-9:]+:+[a-f0-9]+)/);r&&r[0]&&t.add(r[0])},o.createOffer().then(i=>o.setLocalDescription(i)).catch(()=>{}),setTimeout(()=>{try{o.close()}catch{}e(Array.from(t))},n)}catch{e([])}})}async function w(){let n=R(),e=D(),t=await A(),o=await p(1500);return{is_incognito:t,webgl_renderer:n,canvas_hash:e,local_ips:o}}function R(){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 D(){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 A(){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 G(){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 M(){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 $(t)}catch{return null}}function L(){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:m(e)}}catch{return{count:0,fingerprint:null}}}async function U(){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 T(){try{let n=new Intl.DateTimeFormat().resolvedOptions();return`${n.locale}|${n.calendar}|${n.numberingSystem}|${n.hourCycle??"-"}|${n.timeZone}`}catch{return null}}async function N(){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 m(t.sort().join("|"))}catch{return null}}function O(){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 m(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 $(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 m(n)}}async function I(){let[n,e,t]=await Promise.all([M(),U(),N()]);return{math_constants:G(),emoji_hash:n,speech_voices:L(),media_devices:e,intl_signature:T(),keyboard_layout_hash:t,webgl_advanced:O()}}var E="1.0.0",S="qcdi_session_uuid",x="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??(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(S);if(e)return e;let t=this.generateUuid();return sessionStorage.setItem(S,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 v(),t=h();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...t},this.privacySignals=await w(),this.advancedSignals=await I();let o=await p(1500);for(let i of o)i.includes(":")?this.clientIpv6||(this.clientIpv6=i):this.clientIpv4||(this.clientIpv4=i);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: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(x);return typeof window<"u"&&sessionStorage.setItem(x,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 _());let o={sdk_version:E,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:b(),privacy:this.privacySignals,geolocation:t,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}};export{g as QCApiClient,f as QuickCheckDeviceIntel,d as QuickCheckError,E 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 R=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ae=(t,e)=>()=>(t&&(e=t(t=0)),e);var G=(t,e)=>{for(var n in e)R(t,n,{get:e[n],enumerable:!0})},se=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of oe(e))!ie.call(t,i)&&i!==n&&R(t,i,{get:()=>e[i],enumerable:!(o=re(e,i))||o.enumerable});return t};var le=t=>se(R({},"__esModule",{value:!0}),t);var V={};G(V,{getFingerprint:()=>pe,getFingerprintData:()=>j,getFingerprintPerformance:()=>ve,getVersion:()=>he,includeComponent:()=>v,setOption:()=>ge});function y(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(m){m(s)}))).then(r,c)}u((o=o.apply(t,e||[])).next())}))}function w(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(m){s=[6,m],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 ge(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");g[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 p(t,e){return t<<e|t>>>32-e}function T(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],f[0]),s[0]=p(s[0],15),s[0]=Math.imul(s[0],f[1]),r[0]=r[0]^s[0],r[0]=p(r[0],19),r[0]=r[0]+r[1],r[0]=Math.imul(r[0],5)+1444728091,s[1]=Math.imul(s[1],f[1]),s[1]=p(s[1],16),s[1]=Math.imul(s[1],f[2]),r[1]=r[1]^s[1],r[1]=p(r[1],17),r[1]=r[1]+r[2],r[1]=Math.imul(r[1],5)+197830471,s[2]=Math.imul(s[2],f[2]),s[2]=p(s[2],17),s[2]=Math.imul(s[2],f[3]),r[2]=r[2]^s[2],r[2]=p(r[2],15),r[2]=r[2]+r[3],r[2]=Math.imul(r[2],5)+2530024501,s[3]=Math.imul(s[3],f[3]),s[3]=p(s[3],18),s[3]=Math.imul(s[3],f[0]),r[3]=r[3]^s[3],r[3]=p(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],f[3]),l[3]=p(l[3],18),l[3]=Math.imul(l[3],f[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],f[2]),l[2]=p(l[2],17),l[2]=Math.imul(l[2],f[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],f[1]),l[1]=p(l[1],16),l[1]=Math.imul(l[1],f[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],f[0]),l[0]=p(l[0],15),l[0]=Math.imul(l[0],f[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 H(t,e){return new Promise((function(n){setTimeout((function(){return n(e)}),t)}))}function fe(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}})),H(e,n).then((function(a){return{value:a,elapsed:performance.now()-i}}))])})))}function me(t,e,n){return Promise.all(t.map((function(o){return Promise.race([o,H(e,n)])})))}function he(){return"0.20.5"}function j(){return y(this,void 0,void 0,(function(){var t,e,n,o,i;return w(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),t=W(),e=Object.keys(t),[4,me(Object.values(t),g?.timeout||1e3,B)];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,K(i,g.exclude||[],g.include||[],"")];case 2:throw a.sent();case 3:return[2]}}))}))}function K(t,e,n,o){o===void 0&&(o="");for(var i={},a=function(l,s){var m=o+l+".";if(typeof s!="object"||Array.isArray(s)){var k=e.some((function(P){return m.startsWith(P)})),I=n.some((function(P){return m.startsWith(P)}));k&&!I||(i[l]=s)}else{var S=K(s,e,n,m);Object.keys(S).length>0&&(i[l]=S)}},r=0,c=Object.entries(t);r<c.length;r++){var u=c[r];a(u[0],u[1])}return i}function pe(t){return y(this,void 0,void 0,(function(){var e,n;return w(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,j()];case 1:return e=o.sent(),n=T(JSON.stringify(e)),Math.random()<1e-5&&g.logging&&(function(i,a){y(this,void 0,void 0,(function(){var r,c;return w(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 ve(){return y(this,void 0,void 0,(function(){var t,e,n,o;return w(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=W(),e=Object.keys(t),[4,fe(Object.values(t),g?.timeout||1e3,B)];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 x(){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 ye(t){for(var e=0,n=0;n<t.length;++n)e+=Math.abs(t[n]);return e}function $(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(be(a))}var c=new Uint8ClampedArray(o);return new ImageData(c,e,n)}function be(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 N(t,e){if(!t)throw new Error("Canvas context not supported");return t.font,t.font="72px ".concat(e),t.measureText("WwMmLli0Oo").width}function Ie(){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 Pe(){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 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 Ce(){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 Ae(){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,F,B,v,W,f,we,z,O,_e,Se,D,xe,Ee,h,ke,d,_,q=ae(()=>{"use strict";g={exclude:[],include:[],logging:!0,timeout:1e3};F={},B={timeout:"true"},v=function(t,e){typeof window<"u"&&(F[t]=e)},W=function(){return Object.fromEntries(Object.entries(F).filter((function(t){var e,n=t[0];return!(!((e=g?.exclude)===null||e===void 0)&&e.includes(n))})).filter((function(t){var e,n,o,i,a=t[0];return!((e=g?.include)===null||e===void 0)&&e.some((function(r){return r.includes(".")}))?(n=g?.include)===null||n===void 0?void 0:n.some((function(r){return r.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])()]})))};f=new Uint32Array([597399067,2869860233,951274213,2716044179]);we=x();["SamsungBrowser","Safari"].includes(we.name)||v("audio",(function(){return y(this,void 0,void 0,(function(){return w(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:ye(r),oscillator:a.type,maxChannels:o.destination.maxChannelCount,channelCountMode:i.channelCountMode})},o.startRendering()}catch(u){console.error("Error creating audio fingerprint:",u),n(u)}}))]}))}))}));z=x(),O=z.name.toLowerCase(),_e=z.version.split(".")[0]||"0",Se=parseInt(_e,10);O==="firefox"||O==="safari"&&Se===17||v("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:T($(e,280,20).data.toString()).toString()})}))}));xe=["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"],Ee=["monospace","sans-serif","serif"];x().name!="Firefox"&&v("fonts",(function(){var t=this;return new Promise((function(e,n){try{(function(o){var i;y(this,void 0,void 0,(function(){var a,r,c;return w(this,(function(u){switch(u.label){case 0:return document.body?[3,2]:[4,(l=50,new Promise((function(m){return setTimeout(m,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 y(t,void 0,void 0,(function(){var a,r,c,u;return w(this,(function(l){return a=i.createElement("canvas"),r=a.getContext("2d"),c=Ee.map((function(s){return N(r,s)})),u={},xe.forEach((function(s){var m=N(r,s);c.includes(m)||(u[s]=m)})),e(u),[2]}))}))}))}catch{n({error:"unsupported"})}}))})),v("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:Ie(),architecture:Pe(),deviceMemory:n.toString()||"undefined",jsHeapSizeLimit:o.jsHeapSizeLimit||0})}))})),v("locales",(function(){return new Promise((function(t){t({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))})),v("permissions",(function(){return y(this,void 0,void 0,(function(){var t;return w(this,(function(e){return D=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 y(this,void 0,void 0,(function(){var n,o,i,a,r;return w(this,(function(c){switch(c.label){case 0:n={},o=0,i=D,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 Me(n,D)}))]}))}))})),v("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})}))})),v("screen",(function(){return new Promise((function(t){t({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:Ce()})}))})),v("system",(function(){return new Promise((function(t){var e=x();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:Ae()})}))}));ke=x().name!=="SamsungBrowser"?1:3,d=null;v("webgl",(function(){return y(this,void 0,void 0,(function(){var t;return w(this,(function(e){typeof document<"u"&&((h=document.createElement("canvas")).width=200,h.height=100,d=h.getContext("webgl"));try{if(!d)throw new Error("WebGL not supported");return t=Array.from({length:ke},(function(){return(function(){try{if(!d)throw new Error("WebGL not supported");var n=`
|
|
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,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 m=s*l;u[4*s]=0,u[4*s+1]=0,u[4*s+2]=Math.cos(m)*(h.width/2),u[4*s+3]=Math.sin(m)*(h.height/2)}var k=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,k),d.bufferData(d.ARRAY_BUFFER,u,d.STATIC_DRAW);var I=d.getAttribLocation(r,"position");d.enableVertexAttribArray(I),d.vertexAttribPointer(I,2,d.FLOAT,!1,0,0),d.viewport(0,0,h.width,h.height),d.clearColor(0,0,0,1),d.clear(d.COLOR_BUFFER_BIT),d.drawArrays(d.LINES,0,2*c);var S=new Uint8ClampedArray(h.width*h.height*4);return d.readPixels(0,0,h.width,h.height,d.RGBA,d.UNSIGNED_BYTE,S),new ImageData(S,h.width,h.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:T($(t,h.width,h.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]}))}))}));_=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};v("math",(function(){return y(void 0,void 0,void 0,(function(){return w(this,(function(t){return[2,{acos:Math.acos(.5),asin:_(Math.asin,-1,1,97),atan:_(Math.atan,-1,1,97),cos:_(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:_(Math.sin,-Math.PI,Math.PI,97),sinh:_(Math.sinh,-9/7,7/9,97),sqrt:Math.sqrt(2),tan:_(Math.tan,0,2*Math.PI,97),tanh:_(Math.tanh,-9/7,7/9,97)}]}))}))}))});var Ke={};G(Ke,{QuickCheckDeviceIntel:()=>E,default:()=>je});var b=class extends Error{constructor(n,o,i,a){super(n);this.code=o;this.status=i;this.details=a;this.name="QuickCheckError"}};var ce="https://api.quickcheck.com.pa",ue="/api/v1/sdk/device-intel/assess";function de(){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 b("apiKey is required","MISSING_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??ce).replace(/\/$/,""),this.timeout=e.timeout??5e3}async assess(e){let n=`${this.apiUrl}${ue}`,o=new AbortController,i=setTimeout(()=>o.abort(),this.timeout),a=de(),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 b(`Request timed out after ${this.timeout}ms`,"TIMEOUT"):new b(`Network error: ${l.message}`,"NETWORK_ERROR",void 0,l)}clearTimeout(i);let u;try{u=await c.json()}catch{throw new b(`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 b(l,s,c.status,u)}return u}};function U(){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 Y(){try{let e=await(await Promise.resolve().then(()=>(q(),V))).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("|"),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 X(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 J(){let e=navigator.connection;return{connection_type:e?.type??null,effective_type:e?.effectiveType??null}}async function A(t=2e3){return typeof RTCPeerConnection>"u"?[]:new Promise(e=>{let n=new Set;try{let o=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});o.createDataChannel(""),o.onicecandidate=i=>{if(!i.candidate||!i.candidate.candidate)return;let a=i.candidate.candidate.match(/(\d{1,3}(\.\d{1,3}){3})|([a-f0-9:]+:+[a-f0-9]+)/);a&&a[0]&&n.add(a[0])},o.createOffer().then(i=>o.setLocalDescription(i)).catch(()=>{}),setTimeout(()=>{try{o.close()}catch{}e(Array.from(n))},t)}catch{e([])}})}async function Z(){let t=Re(),e=De(),n=await Te(),o=await A(1500);return{is_incognito:n,webgl_renderer:t,canvas_hash:e,local_ips:o}}function Re(){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 De(){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 Te(){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 Le(){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 n=t.toDataURL();return We(n)}catch{return null}}function Ue(){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: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 n of e)n.kind==="audioinput"?t.audioinput++:n.kind==="audiooutput"?t.audiooutput++:n.kind==="videoinput"&&t.videoinput++}catch{}return t}function Ne(){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(),n=[];for(let[o,i]of e.entries())n.push(`${o}=${i}`);return L(n.sort().join("|"))}catch{return null}}function Be(){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 L(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 We(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 L(t)}}async function ee(){let[t,e,n]=await Promise.all([Ge(),Oe(),Fe()]);return{math_constants:Le(),emoji_hash:t,speech_voices:Ue(),media_devices:e,intl_signature:Ne(),keyboard_layout_hash:n,webgl_advanced:Be()}}var He="1.0.0",te="qcdi_session_uuid",ne="qcdi_previous_page",E=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 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(te);if(e)return e;let n=this.generateUuid();return sessionStorage.setItem(te,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 Y(),n=U();this.deviceSignals={fingerprint_hash:e,visitor_id:null,...n},this.privacySignals=await Z(),this.advancedSignals=await ee();let o=await A(1500);for(let i of o)i.includes(":")?this.clientIpv6||(this.clientIpv6=i):this.clientIpv4||(this.clientIpv4=i);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: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(ne);return typeof window<"u"&&sessionStorage.setItem(ne,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 X());let o={sdk_version:He,platform:"web",session_type:e.sessionType,device:this.deviceSignals,network:J(),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",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 je=E;return le(Ke);})();
|
|
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",
|