@fingerprintjs/fingerprintjs-pro
Version:
Fingerprint Pro JavaScript agent
6 lines (4 loc) • 6.99 kB
JavaScript
/**
* Fingerprint Pro v3.11.13 - 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,R="securitypolicyviolation",a=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(R,a);var u=function(){return i.removeEventListener(R,a)};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"},R={default:"tlsEndpoint"},a="Client timeout",u="Network connection error",c="Network request aborted",E="Response cannot be parsed",s="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"),O=/*#__PURE__*/f("UnsupportedVersion"),p=/*#__PURE__*/f("InstallationMethodRestricted"),v=/*#__PURE__*/f("HostnameRestricted"),I=/*#__PURE__*/f("IntegrationFailed"),h=/*#__PURE__*/f("NetworkRestricted"),N=/*#__PURE__*/f("InvalidProxyIntegrationSecret"),T=/*#__PURE__*/f("InvalidProxyIntegrationHeaders"),m=/*#__PURE__*/f("ProxyIntegrationSecretEnvironmentMismatch"),w="API key required",A="API key not found",P="API key expired",S="Request cannot be parsed",y="Request failed",D="Request failed to process",g="Too many requests, rate limit exceeded",L="Not available for this origin",C="Not available with restricted header",U=w,b=A,M=P,K="3.11.13",V="Failed to load the JS script of the agent",k="9319";function B(t,n){var r,o,i,R,a,u,c,E=[],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),R=100,a=3e3,u=0,o=function(){return Math.random()*Math.min(a,R*Math.pow(2,u++))},i=new Set,[r.current(),function(e,t){var n,R=t instanceof Error?t.message:"";if(R===s||R===l)r.exclude(),n=0;else if(R===k)r.exclude();else if(R===V){var a=Date.now()-e.getTime()<50,u=r.current();u&&a&&!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 O=function(e){var t=new Date,r=function(n){return E.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),E.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 O(o)}))}))};return O(d).then((function(e){return[e,E]}))}var F="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",G=F;function x(e){var o;e.scriptUrlPattern;var i=e.token,R=e.apiKey,a=void 0===R?i:R,u=t(e,["scriptUrlPattern","token","apiKey"]),c=null!==(o=r(e,"scriptUrlPattern"))&&void 0!==o?o:F,E=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]}(),s=E[0],l=E[1];return Promise.resolve().then((function(){if(!a||"string"!=typeof a)throw new Error(w);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,a);return B(e,j)})).catch((function(e){throw l(),function(e){if(e instanceof Error&&e.message===k)return new Error(V);return e}(e)})).then((function(e){var t=e[0],r=e[1];return l(),t.load(n(n({},u),{ldi:{attempts:r,visibilityStates:s}}))}))}function j(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(V))},r.async=!0,r.src=e,i.appendChild(r)}))}(e)}),(function(){throw new Error(s)})).then(q)}function q(){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(k);return n}var H={load:x,defaultScriptUrlPattern:G,ERROR_SCRIPT_LOAD_FAIL:V,ERROR_API_KEY_EXPIRED:P,ERROR_API_KEY_INVALID:A,ERROR_API_KEY_MISSING:w,ERROR_BAD_REQUEST_FORMAT:S,ERROR_BAD_RESPONSE_FORMAT:E,ERROR_CLIENT_TIMEOUT:a,ERROR_CSP_BLOCK:s,ERROR_FORBIDDEN_ENDPOINT:v,ERROR_FORBIDDEN_HEADER:C,ERROR_FORBIDDEN_ORIGIN:L,ERROR_GENERAL_SERVER_FAILURE:y,ERROR_INSTALLATION_METHOD_RESTRICTED:p,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_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH:m,ERROR_RATE_LIMIT:g,ERROR_SERVER_TIMEOUT:D,ERROR_SUBSCRIPTION_NOT_ACTIVE:_,ERROR_TOKEN_EXPIRED:M,ERROR_TOKEN_INVALID:b,ERROR_TOKEN_MISSING:U,ERROR_UNSUPPORTED_VERSION:O,ERROR_WRONG_REGION:d,defaultEndpoint:i,defaultTlsEndpoint:R};export{P as ERROR_API_KEY_EXPIRED,A as ERROR_API_KEY_INVALID,w as ERROR_API_KEY_MISSING,S as ERROR_BAD_REQUEST_FORMAT,E as ERROR_BAD_RESPONSE_FORMAT,a as ERROR_CLIENT_TIMEOUT,s as ERROR_CSP_BLOCK,v as ERROR_FORBIDDEN_ENDPOINT,C as ERROR_FORBIDDEN_HEADER,L as ERROR_FORBIDDEN_ORIGIN,y as ERROR_GENERAL_SERVER_FAILURE,p 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,m as ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH,g as ERROR_RATE_LIMIT,V as ERROR_SCRIPT_LOAD_FAIL,D as ERROR_SERVER_TIMEOUT,_ as ERROR_SUBSCRIPTION_NOT_ACTIVE,M as ERROR_TOKEN_EXPIRED,b as ERROR_TOKEN_INVALID,U as ERROR_TOKEN_MISSING,O as ERROR_UNSUPPORTED_VERSION,d as ERROR_WRONG_REGION,H as default,i as defaultEndpoint,G as defaultScriptUrlPattern,R as defaultTlsEndpoint,x as load};