UNPKG

@fingerprintjs/fingerprintjs-pro

Version:

Fingerprint Pro JavaScript agent

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