@fingerprintjs/fingerprintjs-pro
Version:
Fingerprint Pro JavaScript agent
6 lines (4 loc) • 6.81 kB
JavaScript
/**
* Fingerprint Pro v3.11.8 - Copyright (c) FingerprintJS, Inc, 2025 (https://fingerprint.com)
*/
import{__spreadArray as e,__rest as t,__assign as n}from"tslib";function r(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}function o(e,t,n,r){var o,i=document,a="securitypolicyviolation",R=function(t){var n=new URL(e,location.href),r=t.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=t,u())};i.addEventListener(a,R);var u=function(){return i.removeEventListener(a,R)};return null==r||r.then(u,u),Promise.resolve().then(t).then((function(e){return u(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(u(),o)return n(o);throw e}))}))}var i={default:"endpoint"},a={default:"tlsEndpoint"},R="Client timeout",u="Network connection error",c="Network request aborted",s="Response cannot be parsed",E="Blocked by CSP",l="The endpoint parameter is not a valid URL";function f(e){for(var t="",n=0;n<e.length;++n)if(n>0){var r=e[n].toLowerCase();r!==e[n]?t+=" ".concat(r):t+=e[n]}else t+=e[n].toUpperCase();return t}var d=/*#__PURE__*/f("WrongRegion"),_=/*#__PURE__*/f("SubscriptionNotActive"),p=/*#__PURE__*/f("UnsupportedVersion"),O=/*#__PURE__*/f("InstallationMethodRestricted"),v=/*#__PURE__*/f("HostnameRestricted"),I=/*#__PURE__*/f("IntegrationFailed"),h=/*#__PURE__*/f("NetworkRestricted"),N=/*#__PURE__*/f("InvalidProxyIntegrationSecret"),T=/*#__PURE__*/f("InvalidProxyIntegrationHeaders"),m="API key required",w="API key not found",A="API key expired",P="Request cannot be parsed",y="Request failed",D="Request failed to process",S="Too many requests, rate limit exceeded",g="Not available for this origin",L="Not available with restricted header",U=m,C=w,b=A,K="3.11.8",M="Failed to load the JS script of the agent",V="9319";function k(t,n){var r,o,i,a,R,u,c,s=[],f=(r=function(t){var n=e([],t,!0);return{current:function(){return n[0]},postpone:function(){var e=n.shift();void 0!==e&&n.push(e)},exclude:function(){n.shift()}}}(t),a=100,R=3e3,u=0,o=function(){return Math.random()*Math.min(R,a*Math.pow(2,u++))},i=new Set,[r.current(),function(e,t){var n,a=t instanceof Error?t.message:"";if(a===E||a===l)r.exclude(),n=0;else if(a===V)r.exclude();else if(a===M){var R=Date.now()-e.getTime()<50,u=r.current();u&&R&&!i.has(u)&&(i.add(u),n=0),r.postpone()}else r.postpone();var c=r.current();return void 0===c?void 0:[c,null!=n?n:e.getTime()+o()-Date.now()]}]),d=f[0],_=f[1];if(void 0===d)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var p=function(e){var t=new Date,r=function(n){return s.push({url:e,startedAt:t,finishedAt:new Date,error:n})},o=n(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=c||(c=e),s.length>=5)throw c;var n=_(t,e);if(!n)throw c;var r,o=n[0],i=n[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return p(o)}))}))};return p(d).then((function(e){return[e,s]}))}var B="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",F=B;function G(e){var o;e.scriptUrlPattern;var i=e.token,a=e.apiKey,R=void 0===a?i:a,u=t(e,["scriptUrlPattern","token","apiKey"]),c=null!==(o=r(e,"scriptUrlPattern"))&&void 0!==o?o:B,s=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,r){return e.addEventListener(t,n,r),function(){return e.removeEventListener(t,n,r)}}(document,"visibilitychange",t);return t(),[e,n]}(),E=s[0],l=s[1];return Promise.resolve().then((function(){if(!R||"string"!=typeof R)throw new Error(m);var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n(K):e}))}(String(e),t)}))}(c,R);return k(e,x)})).catch((function(e){throw l(),function(e){if(e instanceof Error&&e.message===V)return new Error(M);return e}(e)})).then((function(e){var t=e[0],r=e[1];return l(),t.load(n(n({},u),{ldi:{attempts:r,visibilityStates:E}}))}))}function x(e){return o(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(e))throw new Error(l);var r=document.createElement("script"),o=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),t()},r.onerror=function(){o(),n(new Error(M))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}),(function(){throw new Error(E)})).then(j)}function j(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==r?void 0:r.configurable)?delete e[t]:r&&!r.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(V);return n}var q={load:G,defaultScriptUrlPattern:F,ERROR_SCRIPT_LOAD_FAIL:M,ERROR_API_KEY_EXPIRED:A,ERROR_API_KEY_INVALID:w,ERROR_API_KEY_MISSING:m,ERROR_BAD_REQUEST_FORMAT:P,ERROR_BAD_RESPONSE_FORMAT:s,ERROR_CLIENT_TIMEOUT:R,ERROR_CSP_BLOCK:E,ERROR_FORBIDDEN_ENDPOINT:v,ERROR_FORBIDDEN_HEADER:L,ERROR_FORBIDDEN_ORIGIN:g,ERROR_GENERAL_SERVER_FAILURE:y,ERROR_INSTALLATION_METHOD_RESTRICTED:O,ERROR_INTEGRATION_FAILURE:I,ERROR_INVALID_ENDPOINT:l,ERROR_INVALID_PROXY_INTEGRATION_HEADERS:T,ERROR_INVALID_PROXY_INTEGRATION_SECRET:N,ERROR_NETWORK_ABORT:c,ERROR_NETWORK_CONNECTION:u,ERROR_NETWORK_RESTRICTED:h,ERROR_RATE_LIMIT:S,ERROR_SERVER_TIMEOUT:D,ERROR_SUBSCRIPTION_NOT_ACTIVE:_,ERROR_TOKEN_EXPIRED:b,ERROR_TOKEN_INVALID:C,ERROR_TOKEN_MISSING:U,ERROR_UNSUPPORTED_VERSION:p,ERROR_WRONG_REGION:d,defaultEndpoint:i,defaultTlsEndpoint:a};export{A as ERROR_API_KEY_EXPIRED,w as ERROR_API_KEY_INVALID,m as ERROR_API_KEY_MISSING,P as ERROR_BAD_REQUEST_FORMAT,s as ERROR_BAD_RESPONSE_FORMAT,R as ERROR_CLIENT_TIMEOUT,E as ERROR_CSP_BLOCK,v as ERROR_FORBIDDEN_ENDPOINT,L as ERROR_FORBIDDEN_HEADER,g as ERROR_FORBIDDEN_ORIGIN,y as ERROR_GENERAL_SERVER_FAILURE,O as ERROR_INSTALLATION_METHOD_RESTRICTED,I as ERROR_INTEGRATION_FAILURE,l as ERROR_INVALID_ENDPOINT,T as ERROR_INVALID_PROXY_INTEGRATION_HEADERS,N as ERROR_INVALID_PROXY_INTEGRATION_SECRET,c as ERROR_NETWORK_ABORT,u as ERROR_NETWORK_CONNECTION,h as ERROR_NETWORK_RESTRICTED,S as ERROR_RATE_LIMIT,M as ERROR_SCRIPT_LOAD_FAIL,D as ERROR_SERVER_TIMEOUT,_ as ERROR_SUBSCRIPTION_NOT_ACTIVE,b as ERROR_TOKEN_EXPIRED,C as ERROR_TOKEN_INVALID,U as ERROR_TOKEN_MISSING,p as ERROR_UNSUPPORTED_VERSION,d as ERROR_WRONG_REGION,q as default,i as defaultEndpoint,F as defaultScriptUrlPattern,a as defaultTlsEndpoint,G as load};