@sumsub/fisherman
Version:
The Sumsub Fisherman is a powerful tool that helps developers integrate fraud detection capabilities into their applications. With Fisherman, you can easily identify and prevent fraudulent activities within your system, providing a safer and more secure e
2 lines (1 loc) • 20.6 kB
JavaScript
(function(R,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("fingerprintjs2"),require("detectincognitojs")):typeof define=="function"&&define.amd?define(["exports","fingerprintjs2","detectincognitojs"],O):(R=typeof globalThis<"u"?globalThis:R||self,O(R.SumsubFisherman={},R.Fingerprint2,R.detectIncognito))})(this,function(R,O,Be){"use strict";function le(){return Date.now()}function qe(){return new Date().toISOString()}const $e="crypto"in window&&"randomUUID"in window.crypto;function je(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Ke(){return $e?crypto.randomUUID():je()}const Ve={type:"InvalidToken",message:"Token is invalid, make sure you generate a new one each time, because the old ones are invalidated upon usage"},fe={type:"NoToken",message:"Authentication token is required to send requests"},Ge={type:"UpdateTokenRetriesLimitReached",message:"Token renewal failed after multiple attempts (limit reached). Request aborted to prevent infinite retry loop."},He={type:"NetworkError",message:"Failed to connect to the server. Possible network or CORS configuration issue."},pe={type:"FpDisabled",message:"You are trying to use FP, which is not enabled for you."},We={type:"FpClientTimeout",message:"Device visitorId calc timeout"},Ce={type:"FpRateLimit",message:"FP request rate limit is exceeded"},V=0;async function G({payload:e,token:t,url:n,onload:i}){try{const r=await fetch(n,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json","X-Client-Id":"fisherman",...t?{"X-Access-Token":t}:{}}});return i(r.status,e),r.status}catch{return i(V,e),V}}const Xe=2e3,Ye=3,Je=atob("aHR0cHM6Ly9jb2NrcGl0LnN1bXN1Yi5jb20="),ge=`/resources/bhv/evts/${Math.random().toString(36).substring(0,8)}`,ve="/resources/di/req";let E,J,Ee,b,I,H,W,z=ge,Q=ve,P=0,Z="info";function ze(e){E=e,k(E.token)}function Qe(e){e&&(z=e)}function Ze(e){e&&(Q=e)}function et(e){Z=e??"info"}function tt(){ye(),Ee=void 0,k(void 0),J=void 0,z=ge,Q=ve,P=0,H=!1,Z="info"}async function x(e,t){return await rt(nt(e,{fpRequestId:t==null?void 0:t.fpRequestId,fpVisitorId:t==null?void 0:t.fpVisitorId,fpSimulation:t==null?void 0:t.fpSimulation},t==null?void 0:t.behavioralDataEnabled))}function nt(e,t={},n=!0){e.capturedAt=qe();const i=Ke(),r="deviceFingerprint"in e||!n,o={id:i,predecessorEventId:J,deviceSessionId:Ee,...t,[r?"initData":"interactionData"]:e};return J=i,o}async function rt(e,t){I===void 0&&(I=[]),!H&&e.initData?(H=!0,I.unshift(e)):I.push(e),H&&(W||(W=setTimeout(it,Xe)))}function ye(){clearTimeout(W),I=void 0,W=void 0}async function it(){if(I!=null&&I.length&&b){const e=[...I];ye(),await Re(e)}}function F(){return E.baseUrl!==void 0?E.baseUrl:Je}async function ot(){if(E.accessTokenUpdateHandler){const e=await E.accessTokenUpdateHandler();k(e)}}async function Re(e){b?await G({payload:e,token:b,url:`${F()}${z}`,onload:(t,n)=>we(t,()=>Re(n))}):g(fe)}async function C(e){b?await G({payload:e,token:b,url:`${F()}${Q}`,onload:(t,n)=>we(t,()=>C(n))}):g(fe)}async function we(e,t){if(e===401||e===V){let n=P>=Ye;!n&&E.accessTokenUpdateHandler?(P++,_("TokenRefreshRetry",`attempt=${P}`),await ot(),await t()):k(void 0);let i;e===V?i=He:n?i=Ge:i=Ve,g(i)}else e===200&&(P=0)}function _(e,t){Z!=="debug"||!E||E.disabledErrorLogging||G({payload:{errorType:"fishermanDebug",errorName:e,message:t},token:b,url:`${F()}/resources/serviceLogger/warn`,onload:()=>{}})}function g(e){const t={errorType:"fishermanError",errorName:e.type,message:e.message};E.disabledErrorLogging||G({payload:t,token:b,url:`${F()}/resources/serviceLogger/warn`,onload:()=>{}}),E.onError&&E.onError(e)}function k(e){b=e}const he="focus";let M,ee=0;function at(){M=()=>{ee++,x({event:"focus",count:ee})},window.addEventListener(he,M)}function ct(){M&&(window.removeEventListener(he,M),M=void 0),ee=0}function st(e){if(e.target instanceof Element){const t=e.target,n=t.getAttribute("type"),i=n?`[${n}]`:"",r=t.id?`#${t.id}`:"";return`${t.tagName}${i}${r}`}}const ut=["Alt","Control","Meta","Shift","Enter","Tab","ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","Backspace","Delete","Escape"];function dt(e){if(ut.includes(e))return e}function me(e){return e instanceof Element}const D=typeof window.WeakMap=="function"?new WeakMap:void 0;function lt(e){return D==null?void 0:D.get(e)}function ft(e,t){D==null||D.set(e,t)}const pt=["type","autocomplete","autofocus","placeholder","aria-label"];function gt(e){const t=e.parentNode,n=e.tagName;if(t){const i=Array.from(t.childNodes).filter(r=>me(r)&&n===r.tagName);if(i.length>1){const r=i.indexOf(e);if(r>-1)return`:nth-of-type(${r+1})`}}return""}function vt(e){const t=e.id?`#${e.id}`:"",n=gt(e),i=pt.map(r=>{if(e.hasAttribute(r)){const o=e.getAttribute(r);return`[${o?`${r}="${o}"`:r}]`}}).filter(Boolean).join("");return e.tagName+t+n+i}function Et(e){const t=[e];let n=e;for(;n.parentElement;){const r=n.parentElement;t.push(r),n=r}const i=t.reverse().map(vt).join(" > ");return O.x64hash128(i,31)}function yt(e){if(me(e.target)){const t=e.target;let n=lt(t);return n||(n=Et(t),ft(t,n)),n}}const Ie=["keydown","keyup"],Te=["mousemove","mousedown"],Oe=["paste","focusin","change",...Te,...Ie];let w,h;function be(){w=new Map,h=[]}function Rt(e){let t;return e.type==="change"&&(h&&(h==null?void 0:h.length)>0&&(t=h),be()),t}function wt({key:e}){w&&w.get(e)===void 0&&w.set(e,le())}function ht({key:e}){const t=w==null?void 0:w.get(e);if(w&&t){h===void 0&&(h=[]),w.delete(e);const n={start:t,end:le()},i=dt(e);i&&(n.key=i),h.push(n)}}function te(e){const t=e.type;if(t==="keydown"?wt(e):t==="keyup"&&ht(e),!Ie.includes(t)){const n={event:t,trusted:e.isTrusted,el:st(e),elUid:yt(e),cadence:Rt(e)};x(n)}Te.includes(t)&&document.removeEventListener(t,te)}function mt(){be(),Oe.forEach(e=>document.addEventListener(e,te))}function It(){Oe.forEach(e=>document.removeEventListener(e,te)),w=void 0,h=void 0}const _e="deviceorientation";let U;function Tt(e){const t=e.alpha!==null?e.alpha:0,n=e.beta!==null?e.beta:0,i=e.gamma!==null?e.gamma:0,r=Math.abs(n)>Math.abs(i)?"portrait":"landscape";return{alpha:t,beta:n,gamma:i,orientation:r}}async function Ot(){if(!U){const e="DeviceOrientationEvent"in window;return e&&(U=t=>{x({event:"orientation",orientation:Tt(t)}),Se()},window.addEventListener(_e,U)),{supported:e}}}function Se(){U&&(window.removeEventListener(_e,U),U=void 0)}const bt="not available",_t=["userAgent","webdriver","language","colorDepth","deviceMemory","pixelRatio","hardwareConcurrency","timezoneOffset","timezone","sessionStorage","localStorage","indexedDb","openDatabase","platform","doNotTrack","plugins","canvas","webgl","webglVendorAndRenderer","adBlock","hasLiedOs","hasLiedBrowser","touchSupport","fonts","audio"],ne=200,St=(e,t)=>{switch(e){case"touchSupport":return Ut(t);case"plugins":return Dt(t);case"webgl":case"canvas":return Lt(t);default:return Nt(t)}},Nt=e=>typeof e=="string"?Ne(e):Array.isArray(e)?At(e):e,Ne=e=>e.length>ne?Ae(e):e,At=e=>((e==null?void 0:e.length)>ne&&e.splice(0,ne),e.map(t=>typeof t=="string"?Ne(t):t)),Dt=e=>{if(Array.isArray(e)&&e.length>0)return e.map(t=>Array.isArray(t)?t[0]:"")},Ut=e=>{if((e==null?void 0:e.length)===3)try{return{maxTouchPoints:Number(e[0]),touchEvent:!!e[1],touchStart:!!e[2]}}catch{return}},Ae=e=>O.x64hash128(e,31),Lt=e=>{if(e)return Ae(e.toString())},Pt=500;async function De(e){const t=await Ft(),n=[];t.forEach(({key:i,value:r})=>{if(n.push(r),_t.includes(i)&&r!==bt){const o=St(i,r);o!==void 0&&(e[i]=o)}}),e.deviceFingerprint=O.x64hash128(n.join(""),31)}async function xt(e){return new Promise((t,n)=>{typeof window.requestIdleCallback=="function"?requestIdleCallback(async()=>{try{t(await De(e))}catch(i){n(i)}}):setTimeout(async()=>{try{t(await De(e))}catch(i){n(i)}},Pt)})}function Ft(){return new Promise(e=>O.get(e))}function B(){return navigator instanceof window.Navigator}async function kt(e){var t;return!!(B()&&typeof((t=navigator.permissions)==null?void 0:t.query)=="function"&&(await navigator.permissions.query({name:e})).state==="granted")}async function Mt(){return new Promise(e=>{navigator.geolocation.getCurrentPosition(t=>{const n=t.coords.latitude,i=t.coords.longitude;e(`${n}:${i}`)},()=>{e("unknown")})})}async function Bt(){const e=await kt("geolocation"),t={permissionGranted:e};return B()&&e&&navigator.geolocation&&(t.location=await Mt()),t}async function qt(){if(B()&&"getBattery"in navigator&&typeof navigator.getBattery=="function"){const e=await navigator.getBattery();if(e)return{level:e.level,charging:e.charging}}}async function $t(){var e;if(B()&&typeof((e=navigator.mediaDevices)==null?void 0:e.enumerateDevices)=="function")return(await navigator.mediaDevices.enumerateDevices()).map(({kind:n,label:i,deviceId:r,groupId:o})=>({kind:n,label:i||void 0,deviceId:r||void 0,groupId:o||void 0}))}function jt(){let e;try{throw"a"}catch(t){try{t.toSource(),e=!0}catch{e=!1}}return e}const Kt="notDetected";async function Vt(){try{return await Be()}catch{return{browserName:Kt}}}async function Gt(){var l;const e={},{width:t,height:n,availWidth:i,availHeight:r}=window.screen;e.width=t,e.height=n,e.availableWidth=i,e.availableHeight=r;try{await xt(e)}catch(c){g({type:"FpInitError",message:c.message})}const o=await Vt();if(e.browser=o.browserName,e.incognito=o.isPrivate,B()&&"userAgentData"in navigator){const c=navigator.userAgentData;e.mobile=c==null?void 0:c.mobile}(l=navigator.languages)!=null&&l.length&&(e.languages=[...navigator.languages]),e.geolocation=await Bt();const a=await qt();a&&(e.battery=a);const s=await $t();s&&(e.mediaDevices=s);const d=await Ot();d&&(e.orientation=d),e.oscpu=navigator.oscpu,e.productSub=navigator.productSub,e.evalLength=eval.toString().length,e.errFirefox=jt(),await x(e)}const Ue="navigate";let q,re;function Ht(){var t,n;typeof((t=window.navigation)==null?void 0:t.addEventListener)=="function"&&(q=()=>{const i=Ct();i!==re&&(re=i,x({event:"urlchanged"}))},(n=window.navigation)==null||n.addEventListener(Ue,q))}function Wt(){var e;q&&((e=window.navigation)==null||e.removeEventListener(Ue,q),q=void 0,re=void 0)}function Ct(){return window.location.href}var X=function(){return X=Object.assign||function(t){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},X.apply(this,arguments)};function Xt(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n}function Yt(e,t,n){if(n||arguments.length===2)for(var i=0,r=t.length,o;i<r;i++)(o||!(i in t))&&(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function Jt(e,t){return function(n,i){return Object.prototype.hasOwnProperty.call(n,i)}(e,t)?e[t]:void 0}function zt(e,t,n,i){var r,o=document,a="securitypolicyviolation",s=function(l){var c=new URL(e,location.href),u=l.blockedURI;u!==c.href&&u!==c.protocol.slice(0,-1)&&u!==c.origin||(r=l,d())};o.addEventListener(a,s);var d=function(){return o.removeEventListener(a,s)};return Promise.resolve().then(t).then(function(l){return d(),l},function(l){return new Promise(function(c){var u=new MessageChannel;u.port1.onmessage=function(){return c()},u.port2.postMessage(null)}).then(function(){if(d(),r)return n(r);throw l})})}var Qt={default:"endpoint"},Zt={default:"tlsEndpoint"},en="Client timeout",tn="Network connection error",nn="Network request aborted",rn="Response cannot be parsed",ie="Blocked by CSP",oe="The endpoint parameter is not a valid URL";function T(e){for(var t="",n=0;n<e.length;++n)if(n>0){var i=e[n].toLowerCase();i!==e[n]?t+=" ".concat(i):t+=e[n]}else t+=e[n].toUpperCase();return t}var on=T("WrongRegion"),an=T("SubscriptionNotActive"),cn=T("UnsupportedVersion"),sn=T("InstallationMethodRestricted"),un=T("HostnameRestricted"),dn=T("IntegrationFailed"),ln=T("NetworkRestricted"),fn=T("InvalidProxyIntegrationSecret"),pn=T("InvalidProxyIntegrationHeaders"),ae="API key required",Le="API key not found",Pe="API key expired",gn="Request cannot be parsed",vn="Request failed",En="Request failed to process",yn="Too many requests, rate limit exceeded",Rn="Not available for this origin",wn="Not available with restricted header",hn=ae,mn=Le,In=Pe,Tn="3.11.11",Y="Failed to load the JS script of the agent",ce="9319";function On(e,t){var n,i,r,o,a,s,d,l=[],c=(n=function(v){var p=Yt([],v,!0);return{current:function(){return p[0]},postpone:function(){var f=p.shift();f!==void 0&&p.push(f)},exclude:function(){p.shift()}}}(e),o=100,a=3e3,s=0,i=function(){return Math.random()*Math.min(a,o*Math.pow(2,s++))},r=new Set,[n.current(),function(v,p){var f,y=p instanceof Error?p.message:"";if(y===ie||y===oe)n.exclude(),f=0;else if(y===ce)n.exclude();else if(y===Y){var L=Date.now()-v.getTime()<50,A=n.current();A&&L&&!r.has(A)&&(r.add(A),f=0),n.postpone()}else n.postpone();var K=n.current();return K===void 0?void 0:[K,f??v.getTime()+i()-Date.now()]}]),u=c[0],S=c[1];if(u===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var N=function(v){var p=new Date,f=function(L){return l.push({url:v,startedAt:p,finishedAt:new Date,error:L})},y=t(v);return y.then(function(){return f()},f),y.catch(function(L){if(d!=null||(d=L),l.length>=5)throw d;var A=S(p,L);if(!A)throw d;var K,Hn=A[0],Wn=A[1];return(K=Wn,new Promise(function(Cn){return setTimeout(Cn,K)})).then(function(){return N(Hn)})})};return N(u).then(function(v){return[v,l]})}var xe="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",bn=xe;function _n(e){var t;e.scriptUrlPattern;var n=e.token,i=e.apiKey,r=i===void 0?n:i,o=Xt(e,["scriptUrlPattern","token","apiKey"]),a=(t=Jt(e,"scriptUrlPattern"))!==null&&t!==void 0?t:xe,s=function(){var c=[],u=function(){c.push({time:new Date,state:document.visibilityState})},S=function(N,v,p,f){return N.addEventListener(v,p,f),function(){return N.removeEventListener(v,p,f)}}(document,"visibilitychange",u);return u(),[c,S]}(),d=s[0],l=s[1];return Promise.resolve().then(function(){if(!r||typeof r!="string")throw new Error(ae);var c=function(u,S){return(Array.isArray(u)?u:[u]).map(function(N){return function(v,p){var f=encodeURIComponent;return v.replace(/<[^<>]+>/g,function(y){return y==="<version>"?"3":y==="<apiKey>"?f(p):y==="<loaderVersion>"?f(Tn):y})}(String(N),S)})}(a,r);return On(c,Sn)}).catch(function(c){throw l(),function(u){return u instanceof Error&&u.message===ce?new Error(Y):u}(c)}).then(function(c){var u=c[0],S=c[1];return l(),u.load(X(X({},o),{ldi:{attempts:S,visibilityStates:d}}))})}function Sn(e){return zt(e,function(){return function(t){return new Promise(function(n,i){if(function(s){if(URL.prototype)try{return new URL(s,location.href),!1}catch(d){if(d instanceof Error&&d.name==="TypeError")return!0;throw d}}(t))throw new Error(oe);var r=document.createElement("script"),o=function(){var s;return(s=r.parentNode)===null||s===void 0?void 0:s.removeChild(r)},a=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),n()},r.onerror=function(){o(),i(new Error(Y))},r.async=!0,r.src=t,a.appendChild(r)})}(e)},function(){throw new Error(ie)}).then(Nn)}function Nn(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(i,r){var o,a=(o=Object.getOwnPropertyDescriptor)===null||o===void 0?void 0:o.call(Object,i,r);a!=null&&a.configurable?delete i[r]:a&&!a.writable||(i[r]=void 0)}(e,t),typeof(n==null?void 0:n.load)!="function")throw new Error(ce);return n}var se={load:_n,defaultScriptUrlPattern:bn,ERROR_SCRIPT_LOAD_FAIL:Y,ERROR_API_KEY_EXPIRED:Pe,ERROR_API_KEY_INVALID:Le,ERROR_API_KEY_MISSING:ae,ERROR_BAD_REQUEST_FORMAT:gn,ERROR_BAD_RESPONSE_FORMAT:rn,ERROR_CLIENT_TIMEOUT:en,ERROR_CSP_BLOCK:ie,ERROR_FORBIDDEN_ENDPOINT:un,ERROR_FORBIDDEN_HEADER:wn,ERROR_FORBIDDEN_ORIGIN:Rn,ERROR_GENERAL_SERVER_FAILURE:vn,ERROR_INSTALLATION_METHOD_RESTRICTED:sn,ERROR_INTEGRATION_FAILURE:dn,ERROR_INVALID_ENDPOINT:oe,ERROR_INVALID_PROXY_INTEGRATION_HEADERS:pn,ERROR_INVALID_PROXY_INTEGRATION_SECRET:fn,ERROR_NETWORK_ABORT:nn,ERROR_NETWORK_CONNECTION:tn,ERROR_NETWORK_RESTRICTED:ln,ERROR_RATE_LIMIT:yn,ERROR_SERVER_TIMEOUT:En,ERROR_SUBSCRIPTION_NOT_ACTIVE:an,ERROR_TOKEN_EXPIRED:In,ERROR_TOKEN_INVALID:mn,ERROR_TOKEN_MISSING:hn,ERROR_UNSUPPORTED_VERSION:cn,ERROR_WRONG_REGION:on,defaultEndpoint:Qt,defaultTlsEndpoint:Zt};async function An(e,t){const n=`${t}/resources/di/info`;return fetch(n,{headers:{"Content-Type":"application/json","X-Access-Token":e,"X-Client-Id":"fisherman"}}).then(i=>{if(i.status!==204)return i.json()})}function Fe(){try{const e=typeof window<"u"&&typeof window.sessionStorage<"u";return e||g({type:"OtherFpError",message:"SessionStorage unavailable"}),e}catch{return g({type:"OtherFpError",message:"SessionStorage unavailable"}),!1}}function Dn(e){if(!Fe())return null;try{const t=window.sessionStorage.getItem(e);return t?JSON.parse(t):null}catch{return g({type:"OtherFpError",message:"Unable to parse SessionStorage response"}),null}}function Un(e,t){if(Fe())try{window.sessionStorage.setItem(e,JSON.stringify(t))}catch{g({type:"OtherFpError",message:"SessionStorage unavailable"})}}const ke="fisherman_fp_cache";function Me(e){return e?`${ke}_${e}`:ke}function Ln(e){return Dn(Me(e))}function Pn(e,t){Un(Me(t),e)}function xn(e,t){const n=Date.now(),i=t*1e3;return n-e<i}const Fn="https://fpmetrics.sumsub.com",kn="eu",Mn=(e,t)=>{const n=(t==null?void 0:t.fpRegion)||kn,i=(t==null?void 0:t.fpUrl)||Fn;if(t!=null&&t.fpWorkerUrl&&(t!=null&&t.fpWorkerScript)){const r=new URL(t==null?void 0:t.fpWorkerUrl);return r.searchParams.set("region",n),{apiKey:e,scriptUrlPattern:t==null?void 0:t.fpWorkerScript,endpoint:r.toString(),region:n}}return{apiKey:e,scriptUrlPattern:`${i}/web/v<version>/<apiKey>/loader_v<loaderVersion>.js`,endpoint:i,region:n}};let $,m,j;async function Bn(e,t){let n,i,r;try{r=await An(e,F())}catch(s){g({type:"LoadFpConfigError",message:s.message})}const o=!!(r!=null&&r.bhvEnabled);if(n=r==null?void 0:r.evRelUrl,i=r==null?void 0:r.fpReqRelUrl,j=r==null?void 0:r.cacheTtlSeconds,et(r==null?void 0:r.logLevel),r!=null&&r.fpKey)try{const s=Mn(r.fpKey,r);$=await se.load(s)}catch(s){g({type:"FpInitError",message:s.message})}t?m={enabled:!0,conf:t}:r!=null&&r.simulation&&(m=r.simulation);const a=!!(r!=null&&r.fpKey||m);return _("InitResult",`isDeviceIntelligenceEnabled=${a}`),{isDeviceIntelligenceEnabled:a,behavioralDataEnabled:o,eventsRelUrl:n,fpReqRelUrl:i}}async function qn(e){if(_("CollectFingerprintStarted"),m)return await $n(e);let t,n,i=j&&j>0;if(i){const r=Ln(e==null?void 0:e.deviceBindingId);if(r){if(xn(r.timestamp,j))return $?(_("CacheHit",`requestId=${r.requestId}`),await C({fpRequestId:r.requestId,deviceBindingId:e==null?void 0:e.deviceBindingId})):g(pe),{visitorId:r.visitorId};_("CacheExpired")}else _("CacheMiss")}if($){let r;try{r=await $.get({timeout:3e4,linkedId:e==null?void 0:e.linkedId})}catch(o){let a;switch(o.message){case se.ERROR_CLIENT_TIMEOUT:a=We;break;case se.ERROR_RATE_LIMIT:a=Ce;break;default:a={type:"OtherFpError",message:o.message}}g(a)}t=r==null?void 0:r.visitorId,n=r==null?void 0:r.requestId,_("FpResult",`visitorId=${t??"undefined"} requestId=${n??"undefined"}`),await C({fpRequestId:n,deviceBindingId:e==null?void 0:e.deviceBindingId}),i&&r&&Pn({visitorId:t,requestId:n,timestamp:Date.now()},e==null?void 0:e.deviceBindingId)}else g(pe);return{visitorId:t}}async function $n(e){var i,r;const t={visitorId:(i=m==null?void 0:m.conf)==null?void 0:i.visitorId};if(!m)return t;const n={...m};if(!((r=n.conf)!=null&&r.requestId)){const o=`simulated-${Math.random().toString(36).substring(2,10)}`;n.conf={...n.conf,requestId:o}}try{await C({fpSimulation:n,deviceBindingId:e==null?void 0:e.deviceBindingId})}catch(o){g({type:"SimulationError",message:o.message})}return t}const jn=()=>{$=void 0,m=void 0,j=void 0};let ue,de=!1;async function Kn(e){let t=!1;if(!ue){ue=!0,ze(e);const n=await Bn(e.token,e.simulationConfig);t=n.isDeviceIntelligenceEnabled,de=n.behavioralDataEnabled,Qe(n.eventsRelUrl),Ze(n.fpReqRelUrl),de&&(await Gt(),at(),Ht(),mt())}return{isDeviceIntelligenceEnabled:t,async fingerprint(n){return qn(n)}}}function Vn(){Se(),ct(),Wt(),It(),tt(),jn(),ue=!1,de=!1}function Gn(e){k(e)}R.destroy=Vn,R.init=Kn,R.updateAccessToken=Gn,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});