@fingerprintjs/fingerprintjs-pro
Version:
Fingerprint JavaScript agent
6 lines (4 loc) • 12.4 kB
JavaScript
/**
* Fingerprint v3.12.9 - Copyright (c) FingerprintJS, Inc, 2026 (https://fingerprint.com)
*/
;function e(e,t){return function(e,t,r){const o=()=>{throw new Error("Invalid data")},i=n(e);i.length<t.length+2&&o();for(let n=0;n<t.length;++n)Ee(i[1+n],i[0])!==t[n]&&o();const R=1+t.length,s=Ee(i[R],i[0]);i.length<R+1+s+r&&o();const c=R+1+s,a=c+r,l=new ArrayBuffer(i.length-a),E=new Uint8Array(l);for(let n=0;n<E.length;++n)E[n]=i[a+n]^i[c+n%r];return l}(e,t?W:X,$)}function t(e,t){r(e,e.len+1),e.arr[e.len++]=t}function n(e){return e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function r(e,t){if(e.arr.length<t){const n=new Uint8Array(Math.max(2*e.arr.length,t));n.set(e.arr),e.arr=n}}function o(e){return new Promise(((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(v);const r=document.createElement("script"),o=()=>{var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=()=>{o(),t()},r.onerror=()=>{o(),n(new Error(ae))},r.async=!0,r.src=e,i.appendChild(r)}))}function i(e){const t=location.hostname,n=function(){var e,t;const n=window;return["buildID"in navigator,"MozAppearance"in(null!==(t=null===(e=document.documentElement)||void 0===e?void 0:e.style)&&void 0!==t?t:{}),"onmozfullscreenchange"in n,"mozInnerScreenX"in n,"CSSMozDocumentRule"in n,"CanvasCaptureMediaStream"in n].reduce(((e,t)=>e+(t?1:0)),0)>=4}();(function(e,t){let n=e.length-("."===e.slice(-1)?1:0);do{if(n=n>0?e.lastIndexOf(".",n-1):-1,!0===t(e.slice(n+1)))return!0}while(n>=0);return!1})(t,(r=>{if(!n||!/^([^.]{1,3}\.)*[^.]+\.?$/.test(r)||r===t)return e(r)}))||e()}function R(e){var t,n;const{picked:r,rest:o}=function(e,t){const n={},r={};for(const[o,i]of Object.entries(e))t.includes(o)?n[o]=i:r[o]=i;return{picked:n,rest:r}}(e,["scriptUrlPattern","token","apiKey"]),i=r.token,R=null!==(t=r.apiKey)&&void 0!==t?t:i,s=null!==(n=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(c=e,a="scriptUrlPattern")?c[a]:void 0)&&void 0!==n?n:ue.scriptUrl;var c,a;const[l,E]=function(){const e=[],t=()=>{e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}(document,"visibilitychange",t);return t(),[e,n]}();return Promise.resolve().then((()=>{if(!R||"string"!=typeof R)throw new Error(z);const e=function(e,t){return(Array.isArray(e)?e:[e]).map((e=>function(e,t){const n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(e=>"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n(ce):e))}(String(e),t)))}(s,R);return function(e,t){const n=[],r=5,[o,i]=function(e){const t=function(e){const t=[...e];return{current:()=>t[0],postpone(){const e=t.shift();void 0!==e&&t.push(e)},exclude(){t.shift()}}}(e),n=function(e,t){let n=0;return()=>Math.random()*Math.min(t,e*Math.pow(2,n++))}(100,3e3),r=new Set;return[t.current(),(e,o)=>{let i;const R=o instanceof Error?o.message:"";if(R===g||R===v)t.exclude(),i=0;else if(R===le)t.exclude();else if(R===ae){const n=Date.now()-e.getTime()<50,o=t.current();o&&n&&!r.has(o)&&(r.add(o),i=0),t.postpone()}else t.postpone();const s=t.current();return void 0===s?void 0:[s,null!=i?i:e.getTime()+n()-Date.now()]}]}(e);let R;if(void 0===o)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=e=>{const o=new Date,c=t=>n.push({url:e,startedAt:o,finishedAt:new Date,error:t}),a=t(e);return a.then((()=>c()),c),a.catch((e=>{if(null!=R||(R=e),n.length>=r)throw R;const t=i(o,e);if(!t)throw R;const[c,a]=t;return(l=a,new Promise((e=>setTimeout(e,l)))).then((()=>s(c)));var l}))};return s(o).then((e=>[e,n]))}(e,k)})).catch((e=>{throw E(),function(e){if(e instanceof Error&&e.message===le)return new Error(ae);return e}(e)})).then((([e,t])=>(E(),e.load({...o,ldi:{attempts:t,visibilityStates:l}}))))}Object.defineProperty(exports,"__esModule",{value:!0});const s={default:"endpoint"},c={default:"tlsEndpoint"},a="_vid";function l(){const e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n;const 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(le);return n}function E(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(r>127)return(new TextEncoder).encode(e);t[n]=r}return t}const u=34,d=101,_=117,f=new Uint8Array([110,_,108,108]),O=new Uint8Array([116,114,_,d]),p=new Uint8Array([102,97,108,115,d]),I={'"':'"',"\\":"\\","\b":"b","\f":"f","\n":"n","\r":"r","\t":"t"},T=(()=>{const e=new Uint8Array(128);for(const[t,n]of Object.entries(I))e[n.charCodeAt(0)]=t.charCodeAt(0);return e})(),h="Client timeout",N="Network connection error",A="Network request aborted",w="Response cannot be parsed",g="Blocked by CSP",v="The endpoint parameter is not a valid URL",S="Handle on demand agent data error",m=j("WrongRegion"),D=j("SubscriptionNotActive"),y=j("UnsupportedVersion"),x=j("InstallationMethodRestricted"),P=j("HostnameRestricted"),C=j("IntegrationFailed"),U=j("NetworkRestricted"),L=j("InvalidProxyIntegrationSecret"),b=j("InvalidProxyIntegrationHeaders"),M=j("ProxyIntegrationSecretEnvironmentMismatch");function K({level:e,message:t}){"error"===e?console.error(t):"warning"===e?console.warn(t):console.log(t)}function V(e){return e>=48&&e<58||45===e}function G(e,t){try{document.cookie}catch(n){if(function(e){if(!(e instanceof DOMException))return!1;const t=e.message;return B.test(t)||F.test(t)||H.test(t)}(n))return t;throw n}return e()}function k(e){return function(e,t,n,r){const o=document,i="securitypolicyviolation";let R;const s=t=>{const n=new URL(e,location.href),{blockedURI:r}=t;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(R=t,c())};o.addEventListener(i,s);const c=()=>o.removeEventListener(i,s);return null==r||r.then(c,c),Promise.resolve().then(t).then((e=>(c(),e)),(e=>new Promise((e=>{const t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(null)})).then((()=>{if(c(),R)return n(R);throw e}))))}(e,(()=>o(e)),(()=>{throw new Error(g)})).then(l)}const B=/The document is sandboxed and lacks the 'allow-same-origin' flag/,F=/The operation is insecure/,H=/Forbidden in a sandboxed document without the 'allow-same-origin' flag/;function Y(e,t){r(e,e.len+t.length),e.arr.set(t,e.len),e.len+=t.length}function j(e){let t="";for(let n=0;n<e.length;++n)if(n>0){const r=e[n].toLowerCase();r!==e[n]?t+=` ${r}`:t+=e[n]}else t+=e[n].toUpperCase();return t}const X=[3,13],W=[3,14],$=9;const q=function(r,o={}){const{storageKey:R=a,do:s}=o;try{const o=function(r){const o=function(e){const t=atob(e),n=t.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=t.charCodeAt(o);return r}(r);let i=o;try{i=e(o,!1)}catch(R){}try{return function(e){const r={len:0,arr:new Uint8Array(128)},o=n(e);let i=0;const R=()=>(I(),o[i]===u?s():V(o[i])?c():h(f)?(i+=f.length,null):h(O)?(i+=O.length,!0):h(p)?(i+=p.length,!1):91===o[i]?a():123===o[i]?l():N()),s=()=>{for(r.len=0;i++,o[i]!==u;){if(92===o[i]){if(i++,o[i]===_){const e=parseInt(fe(o.subarray(i+1,i+5)),16);Y(r,E(String.fromCharCode(e))),i+=4;continue}const e=T[o[i]];if(e){t(r,e);continue}return N()}if(void 0===o[i])return N();t(r,o[i])}return i++,fe(function(e){return e.arr.subarray(0,e.len)}(r))},c=()=>{const e=i;for(;46===o[i]||o[i]===d||69===o[i]||43===o[i]||V(o[i]);)i++;return Number(fe(o.subarray(e,i)))},a=()=>{const e=[];for(i++;;){if(I(),93===o[i]){i++;break}if(e.length){if(44!==o[i])return N();i++}e.push(R())}return e},l=()=>{const e={};let t=!0;for(i++;;){if(I(),125===o[i]){i++;break}if(!t){if(44!==o[i])return N();i++,I()}if(o[i]!==u)return N();const n=s();if(I(),58!==o[i])return N();i++,Object.defineProperty(e,n,{value:R(),configurable:!0,enumerable:!0,writable:!0}),t=!1}return e},I=()=>{for(;32===o[i]||10===o[i]||13===o[i]||9===o[i];)i++},h=e=>{for(let t=0;t<e.length;t++)if(o[i+t]!==e[t])return!1;return!0},N=()=>{throw new SyntaxError("Unexpected "+(i<o.length?`byte ${i}`:"end"))},A=R();I(),void 0!==o[i]&&N();return A}(i)}catch(s){}return null}(r);null!==o?(o.visitorToken&&function(e,t){(function(e,t,n){if(i((t=>{!function(e,t){Oe(e,"",-1,t)}(e,t)})),n<0)return;i((r=>(Oe(e,t,n,r),function(e){return G((()=>{const t=`${e}=`;for(const e of document.cookie.split(";")){let n=0;for(;" "===e[n]&&n<e.length;)++n;if(e.indexOf(t)===n)return e.slice(n+t.length)}}),void 0)}(e)===t)))})(t,e,365),function(e,t){var n;try{null===(n=null===localStorage||void 0===localStorage?void 0:localStorage.setItem)||void 0===n||n.call(localStorage,e,t)}catch(r){}}(t,e)}(o.visitorToken,`${R}_t`),null==(c=o.notifications)||c.forEach(K),_e(s,(()=>({e:25,result:{response:o}})))):_e(s,(()=>({e:25,result:{error:new Error("Failed to decode response")}})))}catch(l){throw _e(s,(()=>({e:25,result:{error:l instanceof Error?l:new Error(String(l))}}))),function(e,t,n){const r=new Error(e);void 0!==t&&(r.requestId=t);void 0!==n&&(r.raw=n);return r}(S,void 0,l)}var c},z="API key required",Q="API key not found",J="API key expired",Z="Request cannot be parsed",ee="Request failed",te="Request failed to process",ne="Too many requests, rate limit exceeded",re="Not available for this origin",oe="Not available with restricted header",ie=z,Re=Q,se=J;var ce="3.12.9";const ae="Failed to load the JS script of the agent",le="9319";function Ee(e,t){return(e-t+256)%256}const ue={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"},de=ue.scriptUrl;function _e(e,t,...n){e&&async function(e,t){try{await e()}catch(n){return console.error(n),t}}((()=>{const r=t(...n);void 0!==r&&e(r)}))}function fe(e){if("function"==typeof TextDecoder){const t=(new TextDecoder).decode(e);if(t)return t}const t=n(e);return decodeURIComponent(escape(String.fromCharCode.apply(null,t)))}function Oe(e,t,n,r){G((()=>{const o=`${e}=${t}`,i=`expires=${new Date(Date.now()+24*n*60*60*1e3).toUTCString()}`,R=r?`domain=${r}`:"";document.cookie=[o,"path=/",i,R,"SameSite=Lax"].join("; ")}),void 0)}var pe={load:R,defaultScriptUrlPattern:de,ERROR_SCRIPT_LOAD_FAIL:ae,ERROR_API_KEY_EXPIRED:J,ERROR_API_KEY_INVALID:Q,ERROR_API_KEY_MISSING:z,ERROR_BAD_REQUEST_FORMAT:Z,ERROR_BAD_RESPONSE_FORMAT:w,ERROR_CLIENT_TIMEOUT:h,ERROR_CSP_BLOCK:g,ERROR_FORBIDDEN_ENDPOINT:P,ERROR_FORBIDDEN_HEADER:oe,ERROR_FORBIDDEN_ORIGIN:re,ERROR_GENERAL_SERVER_FAILURE:ee,ERROR_HANDLE_AGENT_DATA:S,ERROR_INSTALLATION_METHOD_RESTRICTED:x,ERROR_INTEGRATION_FAILURE:C,ERROR_INVALID_ENDPOINT:v,ERROR_INVALID_PROXY_INTEGRATION_HEADERS:b,ERROR_INVALID_PROXY_INTEGRATION_SECRET:L,ERROR_NETWORK_ABORT:A,ERROR_NETWORK_CONNECTION:N,ERROR_NETWORK_RESTRICTED:U,ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH:M,ERROR_RATE_LIMIT:ne,ERROR_SERVER_TIMEOUT:te,ERROR_SUBSCRIPTION_NOT_ACTIVE:D,ERROR_TOKEN_EXPIRED:se,ERROR_TOKEN_INVALID:Re,ERROR_TOKEN_MISSING:ie,ERROR_UNSUPPORTED_VERSION:y,ERROR_WRONG_REGION:m,defaultEndpoint:s,defaultTlsEndpoint:c,handleAgentData:q};exports.ERROR_API_KEY_EXPIRED=J,exports.ERROR_API_KEY_INVALID=Q,exports.ERROR_API_KEY_MISSING=z,exports.ERROR_BAD_REQUEST_FORMAT=Z,exports.ERROR_BAD_RESPONSE_FORMAT=w,exports.ERROR_CLIENT_TIMEOUT=h,exports.ERROR_CSP_BLOCK=g,exports.ERROR_FORBIDDEN_ENDPOINT=P,exports.ERROR_FORBIDDEN_HEADER=oe,exports.ERROR_FORBIDDEN_ORIGIN=re,exports.ERROR_GENERAL_SERVER_FAILURE=ee,exports.ERROR_HANDLE_AGENT_DATA=S,exports.ERROR_INSTALLATION_METHOD_RESTRICTED=x,exports.ERROR_INTEGRATION_FAILURE=C,exports.ERROR_INVALID_ENDPOINT=v,exports.ERROR_INVALID_PROXY_INTEGRATION_HEADERS=b,exports.ERROR_INVALID_PROXY_INTEGRATION_SECRET=L,exports.ERROR_NETWORK_ABORT=A,exports.ERROR_NETWORK_CONNECTION=N,exports.ERROR_NETWORK_RESTRICTED=U,exports.ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH=M,exports.ERROR_RATE_LIMIT=ne,exports.ERROR_SCRIPT_LOAD_FAIL=ae,exports.ERROR_SERVER_TIMEOUT=te,exports.ERROR_SUBSCRIPTION_NOT_ACTIVE=D,exports.ERROR_TOKEN_EXPIRED=se,exports.ERROR_TOKEN_INVALID=Re,exports.ERROR_TOKEN_MISSING=ie,exports.ERROR_UNSUPPORTED_VERSION=y,exports.ERROR_WRONG_REGION=m,exports.default=pe,exports.defaultEndpoint=s,exports.defaultScriptUrlPattern=de,exports.defaultTlsEndpoint=c,exports.handleAgentData=q,exports.load=R;