@rebilly/risk-data-collector 4.16.6 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/data-collector.js +680 -3
- package/dist/data-collector.js.map +1 -0
- package/dist/data-collector.min.js +1 -3
- package/dist/data-collector.min.js.map +1 -1
- package/package.json +7 -12
package/dist/data-collector.js
CHANGED
|
@@ -1,3 +1,680 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
t.exports=n=function(){return o},t.exports.__esModule=!0,t.exports.default=t.exports;var r,o={},i=Object.prototype,a=i.hasOwnProperty,c=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",h=s.toStringTag||"@@toStringTag";function f(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(r){f=function(t,e,n){return t[e]=n}}function p(t,e,n,r){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),a=new k(r||[]);return c(i,"_invoke",{value:T(t,n,a)}),i}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}o.wrap=p;var v="suspendedStart",R="suspendedYield",y="executing",E="completed",g={};function m(){}function O(){}function w(){}var _={};f(_,u,(function(){return this}));var I=Object.getPrototypeOf,b=I&&I(I(D([])));b&&b!==i&&a.call(b,u)&&(_=b);var S=w.prototype=m.prototype=Object.create(_);function N(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,n){function r(o,i,c,s){var u=d(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==e(h)&&a.call(h,"__await")?n.resolve(h.__await).then((function(t){r("next",t,c,s)}),(function(t){r("throw",t,c,s)})):n.resolve(h).then((function(t){l.value=t,c(l)}),(function(t){return r("throw",t,c,s)}))}s(u.arg)}var o;c(this,"_invoke",{value:function(t,e){function i(){return new n((function(n,o){r(t,e,n,o)}))}return o=o?o.then(i,i):i()}})}function T(t,e,n){var o=v;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===E){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=L(c,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var u=d(t,e,n);if("normal"===u.type){if(o=n.done?E:R,u.arg===g)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=E,n.method="throw",n.arg=u.arg)}}}function L(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,L(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=d(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function D(t){if(t||""===t){var n=t[u];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(a.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}throw new TypeError(e(t)+" is not iterable")}return O.prototype=w,c(S,"constructor",{value:w,configurable:!0}),c(w,"constructor",{value:O,configurable:!0}),O.displayName=f(w,h,"GeneratorFunction"),o.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===O||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,h,"GeneratorFunction")),t.prototype=Object.create(S),t},o.awrap=function(t){return{__await:t}},N(x.prototype),f(x.prototype,l,(function(){return this})),o.AsyncIterator=x,o.async=function(t,e,n,r,i){void 0===i&&(i=Promise);var a=new x(p(t,e,n,r),i);return o.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},N(S),f(S,h,"Generator"),f(S,u,(function(){return this})),f(S,"toString",(function(){return"[object Generator]"})),o.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},o.values=D,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return c.type="throw",c.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;P(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:D(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}},o}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),i=o(),a=i;try{regeneratorRuntime=i}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}var s=function(){return s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},s.apply(this,arguments)};function u(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var l={default:"endpoint"},h={default:"tlsEndpoint"};function f(t){for(var e="",n=0;n<t.length;++n)if(n>0){var r=t[n].toLowerCase();r!==t[n]?e+=" ".concat(r):e+=t[n]}else e+=t[n].toUpperCase();return e}var p="Client timeout",d="Network connection error",v="Network request aborted",R="Response cannot be parsed",y="Blocked by CSP",E="The endpoint parameter is not a valid URL",g=f("WrongRegion"),m=f("SubscriptionNotActive"),O=f("UnsupportedVersion"),w=f("InstallationMethodRestricted"),_=f("HostnameRestricted"),I=f("IntegrationFailed"),b="API key required",S="API key not found",N="API key expired",x="Request cannot be parsed",T="Request failed",L="Request failed to process",A="Too many requests, rate limit exceeded",P="Not available for this origin",k="Not available with restricted header",D=b,C=S,j=N,K="Failed to load the JS script of the agent",F="9319";function M(t,e){var n,r,o,i,a=[],c=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],t,!0);return{current:function(){return e[0]},postpone:function(){var t=e.shift();void 0!==t&&e.push(t)},exclude:function(){e.shift()}}}(t),100,3e3,i=0,r=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,i++))},o=new Set,[n.current(),function(t,e){var i,a=e instanceof Error?e.message:"";if(a===y||a===E)n.exclude(),i=0;else if(a===F)n.exclude();else if(a===K){var c=Date.now()-t.getTime()<50,s=n.current();s&&c&&!o.has(s)&&(o.add(s),i=0),n.postpone()}else n.postpone();var u=n.current();return void 0===u?void 0:[u,null!=i?i:t.getTime()+r()-Date.now()]}]),s=c[0],u=c[1];if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var l=function(t){var n=new Date,r=function(e){return a.push({url:t,startedAt:n,finishedAt:new Date,error:e})},o=e(t);return o.then((function(){return r()}),r),o.catch((function(t){if(a.length>=5)throw t;var e=u(n,t);if(!e)throw t;var r,o=e[0],i=e[1];return(r=i,new Promise((function(t){return setTimeout(t,r)}))).then((function(){return l(o)}))}))};return l(s).then((function(t){return[t,a]}))}var U="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",V=U;function G(t){var e;t.scriptUrlPattern;var n=t.token,r=t.apiKey,o=void 0===r?n:r,i=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(t,["scriptUrlPattern","token","apiKey"]),a=null!==(e=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:U,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,r){return t.addEventListener(e,n,r),function(){return t.removeEventListener(e,n,r)}}(document,"visibilitychange",e);return e(),[t,n]}(),u=c[0],l=c[1];return Promise.resolve().then((function(){if(!o||"string"!=typeof o)throw new Error(b);return M(function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.9.0"):t}))}(String(t),e)}))}(a,o),B)})).catch((function(t){throw l(),function(t){return t instanceof Error&&t.message===F?new Error(K):t}(t)})).then((function(t){var e=t[0],n=t[1];return l(),e.load(s(s({},i),{ldi:{attempts:n,visibilityStates:u}}))}))}function B(t){return function(t,e,n,r){var o,i=document,a="securitypolicyviolation",c=function(e){var n=new URL(t,location.href),r=e.blockedURI;r!==n.href&&r!==n.protocol.slice(0,-1)&&r!==n.origin||(o=e,s())};i.addEventListener(a,c);var s=function(){return i.removeEventListener(a,c)};return Promise.resolve().then(e).then((function(t){return s(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(s(),o)return function(){throw new Error(y)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(E);var r=document.createElement("script"),o=function(){var t;return null===(t=r.parentNode)||void 0===t?void 0:t.removeChild(r)},i=document.head||document.getElementsByTagName("head")[0];r.onload=function(){o(),e()},r.onerror=function(){o(),n(new Error(K))},r.async=!0,r.src=t,i.appendChild(r)}))}(t)})).then(q)}function q(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,r=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==r?void 0:r.configurable)?delete t[e]:r&&!r.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(F);return n}var W={load:G,defaultScriptUrlPattern:V,ERROR_SCRIPT_LOAD_FAIL:K,ERROR_API_KEY_EXPIRED:N,ERROR_API_KEY_INVALID:S,ERROR_API_KEY_MISSING:b,ERROR_BAD_REQUEST_FORMAT:x,ERROR_BAD_RESPONSE_FORMAT:R,ERROR_CLIENT_TIMEOUT:p,ERROR_CSP_BLOCK:y,ERROR_FORBIDDEN_ENDPOINT:_,ERROR_FORBIDDEN_HEADER:k,ERROR_FORBIDDEN_ORIGIN:P,ERROR_GENERAL_SERVER_FAILURE:T,ERROR_INSTALLATION_METHOD_RESTRICTED:w,ERROR_INTEGRATION_FAILURE:I,ERROR_INVALID_ENDPOINT:E,ERROR_NETWORK_ABORT:v,ERROR_NETWORK_CONNECTION:d,ERROR_RATE_LIMIT:A,ERROR_SERVER_TIMEOUT:L,ERROR_SUBSCRIPTION_NOT_ACTIVE:m,ERROR_TOKEN_EXPIRED:j,ERROR_TOKEN_INVALID:C,ERROR_TOKEN_MISSING:D,ERROR_UNSUPPORTED_VERSION:O,ERROR_WRONG_REGION:g,defaultEndpoint:l,defaultTlsEndpoint:h},J=Object.freeze({__proto__:null,ERROR_API_KEY_EXPIRED:N,ERROR_API_KEY_INVALID:S,ERROR_API_KEY_MISSING:b,ERROR_BAD_REQUEST_FORMAT:x,ERROR_BAD_RESPONSE_FORMAT:R,ERROR_CLIENT_TIMEOUT:p,ERROR_CSP_BLOCK:y,ERROR_FORBIDDEN_ENDPOINT:_,ERROR_FORBIDDEN_HEADER:k,ERROR_FORBIDDEN_ORIGIN:P,ERROR_GENERAL_SERVER_FAILURE:T,ERROR_INSTALLATION_METHOD_RESTRICTED:w,ERROR_INTEGRATION_FAILURE:I,ERROR_INVALID_ENDPOINT:E,ERROR_NETWORK_ABORT:v,ERROR_NETWORK_CONNECTION:d,ERROR_RATE_LIMIT:A,ERROR_SCRIPT_LOAD_FAIL:K,ERROR_SERVER_TIMEOUT:L,ERROR_SUBSCRIPTION_NOT_ACTIVE:m,ERROR_TOKEN_EXPIRED:j,ERROR_TOKEN_INVALID:C,ERROR_TOKEN_MISSING:D,ERROR_UNSUPPORTED_VERSION:O,ERROR_WRONG_REGION:g,default:W,defaultEndpoint:l,defaultScriptUrlPattern:V,defaultTlsEndpoint:h,load:G});const H="@fpjs@client@",Y=()=>Date.now();class ${constructor(t){var e;this.tag=t.tag||null,this.linkedId=t.linkedId||null,this.extendedResult=null!==(e=t.extendedResult)&&void 0!==e&&e}toKey(){return`${JSON.stringify(this.tag)}__${JSON.stringify(this.linkedId)}__${this.extendedResult}`}}function z(t,e){return`${e}__${t}`}function X(t,e){return t.replace(`${e}__`,"")}class Q{constructor(t=H){this.prefix=t}set(t,e){window.localStorage.setItem(z(t,this.prefix),JSON.stringify(e))}get(t){const e=window.localStorage.getItem(z(t,this.prefix));if(e)try{return JSON.parse(e)}catch(t){return}}remove(t){window.localStorage.removeItem(z(t,this.prefix))}allKeys(){return Object.keys(window.localStorage).filter((t=>t.startsWith(this.prefix))).map((t=>X(t,this.prefix)))}}class Z{constructor(t=H){this.prefix=t}set(t,e){window.sessionStorage.setItem(z(t,this.prefix),JSON.stringify(e))}get(t){const e=window.sessionStorage.getItem(z(t,this.prefix));if(e)try{return JSON.parse(e)}catch(t){return}}remove(t){window.sessionStorage.removeItem(z(t,this.prefix))}allKeys(){return Object.keys(window.sessionStorage).filter((t=>t.startsWith(this.prefix))).map((t=>X(t,this.prefix)))}}class tt{constructor(t,e=3600,n){this.cache=t,this.cacheTime=e,this.nowProvider=n||Y}get(t){return u(this,void 0,void 0,(function*(){const e=yield this.cache.get(t.toKey());if(!e)return;const n=yield this.nowProvider(),r=Math.floor(n/1e3);if(!(e.expiresAt<r))return e.body;yield this.cache.remove(t.toKey())}))}set(t,e){return u(this,void 0,void 0,(function*(){const n=yield this.wrapCacheEntry(e);yield this.cache.set(t.toKey(),n)}))}clearCache(){return u(this,void 0,void 0,(function*(){const t=yield this.cache.allKeys();yield Promise.all(t.map((t=>this.cache.remove(t))))}))}wrapCacheEntry(t){return u(this,void 0,void 0,(function*(){const e=yield this.nowProvider(),n=Math.floor(e/1e3)+this.cacheTime;return{body:t,expiresAt:n}}))}}class et{constructor(){this.enclosedCache=function(){const t={};return{set(e,n){t[e]=n},get(e){const n=t[e];if(n)return n},remove(e){delete t[e]},allKeys:()=>Object.keys(t)}}()}}class nt{set(){}get(){}remove(){}allKeys(){return[]}}var rt;!function(t){t.Memory="memory",t.LocalStorage="localstorage",t.SessionStorage="sessionstorage",t.NoCache="nocache"}(rt||(rt={}));const ot={[rt.Memory]:()=>(new et).enclosedCache,[rt.LocalStorage]:t=>new Q(t),[rt.SessionStorage]:t=>new Z(t),[rt.NoCache]:()=>new nt},it=t=>ot[t];class at{constructor(t){var e;let n;if(this.inFlightRequests=new Map,this.agentPromise=null,this.customAgent=null==t?void 0:t.customAgent,this.agent={get:()=>{throw new Error("FPJSAgent hasn't loaded yet. Make sure to call the init() method first.")}},this.loadOptions=null==t?void 0:t.loadOptions,(null==t?void 0:t.cache)&&(null==t?void 0:t.cacheLocation)&&console.warn("Both `cache` and `cacheLocation` options have been specified in the FpjsClient configuration; ignoring `cacheLocation` and using `cache`."),null==t?void 0:t.cache)n=t.cache;else{if(this.cacheLocation=(null==t?void 0:t.cacheLocation)||rt.SessionStorage,!it(this.cacheLocation))throw new Error(`Invalid cache location "${this.cacheLocation}"`);(t=>{switch(t){case rt.SessionStorage:try{window.sessionStorage.getItem("item")}catch(t){return!1}return!0;case rt.LocalStorage:try{window.localStorage.getItem("item")}catch(t){return!1}return!0;default:return!0}})(this.cacheLocation)||(this.cacheLocation=rt.Memory),n=it(this.cacheLocation)(null==t?void 0:t.cachePrefix)}if((null==t?void 0:t.cacheTimeInSeconds)&&t.cacheTimeInSeconds>86400)throw new Error("Cache time cannot exceed 86400 seconds (24 hours)");const r=null!==(e=null==t?void 0:t.cacheTimeInSeconds)&&void 0!==e?e:3600;this.cacheManager=new tt(n,r)}init(t){var e,n;return u(this,void 0,void 0,(function*(){if(!this.loadOptions&&!t)throw new TypeError("No load options provided");const r=Object.assign(Object.assign(Object.assign({},this.loadOptions),t),{integrationInfo:[...(null===(e=this.loadOptions)||void 0===e?void 0:e.integrationInfo)||[],...(null==t?void 0:t.integrationInfo)||[],"fingerprintjs-pro-spa/1.3.0"]});if(!this.agentPromise){const t=null!==(n=this.customAgent)&&void 0!==n?n:J;this.agentPromise=t.load(r).then((t=>(this.agent=t,t))).catch((t=>{throw this.agentPromise=null,t}))}return this.agentPromise}))}getVisitorData(t={},e=!1){return u(this,void 0,void 0,(function*(){const n=at.makeCacheKey(t).toKey();if(!this.inFlightRequests.has(n)){const r=this._identify(t,e).finally((()=>{this.inFlightRequests.delete(n)}));this.inFlightRequests.set(n,r)}return yield this.inFlightRequests.get(n)}))}getVisitorDataFromCache(t={}){return u(this,void 0,void 0,(function*(){const e=at.makeCacheKey(t),n=yield this.cacheManager.get(e);return n?Object.assign(Object.assign({},n),{cacheHit:!0}):void 0}))}isInCache(t={}){return u(this,void 0,void 0,(function*(){return Boolean(yield this.getVisitorDataFromCache(t))}))}clearCache(){return u(this,void 0,void 0,(function*(){yield this.cacheManager.clearCache()}))}static makeCacheKey(t){return new $(t)}_identify(t,e=!1){return u(this,void 0,void 0,(function*(){const n=at.makeCacheKey(t);if(!e){const t=yield this.cacheManager.get(n);if(t)return Object.assign(Object.assign({},t),{cacheHit:!0})}const r=yield this.agent.get(t);return yield this.cacheManager.set(n,r),Object.assign(Object.assign({},r),{cacheHit:!1})}))}}function ct(){return st.apply(this,arguments)}function st(){return(st=e(a.mark((function t(){var e,n,r,o,i,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,e="object"===("undefined"==typeof Cypress?"undefined":c(Cypress)),n="object"===("undefined"==typeof process?"undefined":c(process))&&"test"===process.env.NODE_ENV,!e&&!n){t.next=5;break}return t.abrupt("return","a-mock-visitor-id");case 5:return o="wyr92st0i7","ia1t65gn6i","db4fuswrza",i=new at({loadOptions:{apiKey:"hpFVJecm7Ni7AjSfvBIW",endpoint:["".concat(r="https://d2hwnq6cq5q3pi.cloudfront.net","/").concat(o,"/").concat("ia1t65gn6i"),l],scriptUrlPattern:["".concat(r,"/").concat(o,"/").concat("db4fuswrza","?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>"),V]}}),t.next=12,i.init();case 12:return t.next=14,i.getVisitorData();case 14:return s=t.sent,t.abrupt("return",s.visitorId);case 18:return t.prev=18,t.t0=t.catch(0),console.log(t.t0),t.abrupt("return","");case 22:case"end":return t.stop()}}),t,null,[[0,18]])})))).apply(this,arguments)}function ut(){return lt.apply(this,arguments)}function lt(){return(lt=e(a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){window.requestIdleCallback?requestIdleCallback(e(a.mark((function e(){var n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ct();case 2:n=e.sent,t(n);case 4:case"end":return e.stop()}}),e)})))):setTimeout(e(a.mark((function e(){var n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ct();case 2:n=e.sent,t(n);case 4:case"end":return e.stop()}}),e)}))),500)})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ht=function(t){var e=t.env,n=t.kountAccountId,r=t.kountSessionId,o=function(t){return"production"===t}(e)?"https://ssl.kaptcha.com":"https://tst.kaptcha.com",i=new URL("".concat(o,"/collect/sdk"));i.searchParams.append("m",n),r&&i.searchParams.append("m",r);var a=document.createElement("script");return a.setAttribute("class","kaxsdc"),a.setAttribute("data-event","load"),a.setAttribute("type","text/javascript"),a.setAttribute("src",i.href),document.body.append(a),a};function ft(t){return pt.apply(this,arguments)}function pt(){return(pt=e(a.mark((function t(e){var n,r,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.env,r=e.kountAccountId,o=e.kountSessionId,t.abrupt("return",new Promise((function(t,e){var i=ht({env:n,kountAccountId:r,kountSessionId:o});i.onload=function(){var e=new ka.ClientSDK;e.setupCallback({"collect-begin":function(e){var n=e.MercSessId;t(n)}}),e.autoLoadEvents()},i.onerror=function(){e(new Error("Error attempting to mount Kount script"))}})));case 2:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function dt(t){return vt.apply(this,arguments)}function vt(){return vt=e(a.mark((function t(e){var n,r,o,i,c,s,u,l,h,f,p,d,v,R,y,E,g,m,O,w;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.env,r=void 0===n?null:n,o=e.screen,i=e.navigator,c=e.kountAccountId,s=void 0===c?null:c,u=e.kountSessionId,l=void 0===u?null:u,h=e.getFingerprint,f=e.getFraudSessionId,d=(p=o||{}).colorDepth,v=p.height,R=p.width,E=(y=i||{}).javaEnabled,g=y.language,t.prev=3,t.next=6,h();case 6:if(m=t.sent,!s){t.next=11;break}return t.next=10,f({env:r,kountAccountId:s,kountSessionId:l});case 10:O=t.sent;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(3),console.error(t.t0);case 16:return w={riskMetadata:{fingerprint:m||null,extraData:{kountFraudSessionId:O||null},browserData:{colorDepth:d||null,isJavaEnabled:E?E.call(i):null,language:g||null,screenHeight:v||null,screenWidth:R||null,timeZoneOffset:(new Date).getTimezoneOffset()}}},t.abrupt("return",w);case 18:case"end":return t.stop()}}),t,null,[[3,13]])}))),vt.apply(this,arguments)}function Rt(){return yt.apply(this,arguments)}function yt(){return yt=e(a.mark((function t(){var e,n,r,o,i,c,s,u=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=(e=u.length>0&&void 0!==u[0]?u[0]:{}).env,r=void 0===n?null:n,o=e.kountAccountId,i=void 0===o?null:o,c=e.kountSessionId,s=void 0===c?null:c,t.abrupt("return",dt({env:r,screen:screen,navigator:navigator,kountAccountId:i,kountSessionId:s,getFingerprint:ut,getFraudSessionId:ft}));case 2:case"end":return t.stop()}}),t)}))),yt.apply(this,arguments)}export{Rt as collectData,dt as collectDataHelper};
|
|
1
|
+
var N = function() {
|
|
2
|
+
return N = Object.assign || function(e) {
|
|
3
|
+
for (var t, n = 1, i = arguments.length; n < i; n++) {
|
|
4
|
+
t = arguments[n];
|
|
5
|
+
for (var o in t)
|
|
6
|
+
Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
|
|
7
|
+
}
|
|
8
|
+
return e;
|
|
9
|
+
}, N.apply(this, arguments);
|
|
10
|
+
};
|
|
11
|
+
function de(r, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var n in r)
|
|
14
|
+
Object.prototype.hasOwnProperty.call(r, n) && e.indexOf(n) < 0 && (t[n] = r[n]);
|
|
15
|
+
if (r != null && typeof Object.getOwnPropertySymbols == "function")
|
|
16
|
+
for (var i = 0, n = Object.getOwnPropertySymbols(r); i < n.length; i++)
|
|
17
|
+
e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(r, n[i]) && (t[n[i]] = r[n[i]]);
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
function O(r, e, t, n) {
|
|
21
|
+
function i(o) {
|
|
22
|
+
return o instanceof t ? o : new t(function(a) {
|
|
23
|
+
a(o);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return new (t || (t = Promise))(function(o, a) {
|
|
27
|
+
function l(c) {
|
|
28
|
+
try {
|
|
29
|
+
d(n.next(c));
|
|
30
|
+
} catch (s) {
|
|
31
|
+
a(s);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function u(c) {
|
|
35
|
+
try {
|
|
36
|
+
d(n.throw(c));
|
|
37
|
+
} catch (s) {
|
|
38
|
+
a(s);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function d(c) {
|
|
42
|
+
c.done ? o(c.value) : i(c.value).then(l, u);
|
|
43
|
+
}
|
|
44
|
+
d((n = n.apply(r, e || [])).next());
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function he(r, e, t) {
|
|
48
|
+
if (t || arguments.length === 2)
|
|
49
|
+
for (var n = 0, i = e.length, o; n < i; n++)
|
|
50
|
+
(o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
|
|
51
|
+
return r.concat(o || Array.prototype.slice.call(e));
|
|
52
|
+
}
|
|
53
|
+
function Re(r, e) {
|
|
54
|
+
return function(t, n) {
|
|
55
|
+
return Object.prototype.hasOwnProperty.call(t, n);
|
|
56
|
+
}(r, e) ? r[e] : void 0;
|
|
57
|
+
}
|
|
58
|
+
var D = { default: "endpoint" }, M = { default: "tlsEndpoint" };
|
|
59
|
+
function I(r) {
|
|
60
|
+
for (var e = "", t = 0; t < r.length; ++t)
|
|
61
|
+
if (t > 0) {
|
|
62
|
+
var n = r[t].toLowerCase();
|
|
63
|
+
n !== r[t] ? e += " ".concat(n) : e += r[t];
|
|
64
|
+
} else
|
|
65
|
+
e += r[t].toUpperCase();
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
68
|
+
var j = "Client timeout", k = "Network connection error", x = "Network request aborted", V = "Response cannot be parsed", T = "Blocked by CSP", A = "The endpoint parameter is not a valid URL", B = /* @__PURE__ */ I("WrongRegion"), q = /* @__PURE__ */ I("SubscriptionNotActive"), G = /* @__PURE__ */ I("UnsupportedVersion"), $ = /* @__PURE__ */ I("InstallationMethodRestricted"), H = /* @__PURE__ */ I("HostnameRestricted"), W = /* @__PURE__ */ I("IntegrationFailed"), P = "API key required", b = "API key not found", C = "API key expired", J = "Request cannot be parsed", Y = "Request failed", X = "Request failed to process", z = "Too many requests, rate limit exceeded", Q = "Not available for this origin", Z = "Not available with restricted header", ee = P, te = b, ne = C, fe = "3.9.0", S = "Failed to load the JS script of the agent", L = "9319";
|
|
69
|
+
function Ee(r, e) {
|
|
70
|
+
var t, n, i, o, a, l, u = [], d = (t = function(h) {
|
|
71
|
+
var f = he([], h, !0);
|
|
72
|
+
return { current: function() {
|
|
73
|
+
return f[0];
|
|
74
|
+
}, postpone: function() {
|
|
75
|
+
var R = f.shift();
|
|
76
|
+
R !== void 0 && f.push(R);
|
|
77
|
+
}, exclude: function() {
|
|
78
|
+
f.shift();
|
|
79
|
+
} };
|
|
80
|
+
}(r), o = 100, a = 3e3, l = 0, n = function() {
|
|
81
|
+
return Math.random() * Math.min(a, o * Math.pow(2, l++));
|
|
82
|
+
}, i = /* @__PURE__ */ new Set(), [t.current(), function(h, f) {
|
|
83
|
+
var R, _ = f instanceof Error ? f.message : "";
|
|
84
|
+
if (_ === T || _ === A)
|
|
85
|
+
t.exclude(), R = 0;
|
|
86
|
+
else if (_ === L)
|
|
87
|
+
t.exclude();
|
|
88
|
+
else if (_ === S) {
|
|
89
|
+
var p = Date.now() - h.getTime() < 50, g = t.current();
|
|
90
|
+
g && p && !i.has(g) && (i.add(g), R = 0), t.postpone();
|
|
91
|
+
} else
|
|
92
|
+
t.postpone();
|
|
93
|
+
var m = t.current();
|
|
94
|
+
return m === void 0 ? void 0 : [m, R ?? h.getTime() + n() - Date.now()];
|
|
95
|
+
}]), c = d[0], s = d[1];
|
|
96
|
+
if (c === void 0)
|
|
97
|
+
return Promise.reject(new TypeError("The list of script URL patterns is empty"));
|
|
98
|
+
var E = function(h) {
|
|
99
|
+
var f = /* @__PURE__ */ new Date(), R = function(p) {
|
|
100
|
+
return u.push({ url: h, startedAt: f, finishedAt: /* @__PURE__ */ new Date(), error: p });
|
|
101
|
+
}, _ = e(h);
|
|
102
|
+
return _.then(function() {
|
|
103
|
+
return R();
|
|
104
|
+
}, R), _.catch(function(p) {
|
|
105
|
+
if (u.length >= 5)
|
|
106
|
+
throw p;
|
|
107
|
+
var g = s(f, p);
|
|
108
|
+
if (!g)
|
|
109
|
+
throw p;
|
|
110
|
+
var m, se = g[0], le = g[1];
|
|
111
|
+
return (m = le, new Promise(function(ue) {
|
|
112
|
+
return setTimeout(ue, m);
|
|
113
|
+
})).then(function() {
|
|
114
|
+
return E(se);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
return E(c).then(function(h) {
|
|
119
|
+
return [h, u];
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
var re = "https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js", K = re;
|
|
123
|
+
function ie(r) {
|
|
124
|
+
var e;
|
|
125
|
+
r.scriptUrlPattern;
|
|
126
|
+
var t = r.token, n = r.apiKey, i = n === void 0 ? t : n, o = de(r, ["scriptUrlPattern", "token", "apiKey"]), a = (e = Re(r, "scriptUrlPattern")) !== null && e !== void 0 ? e : re, l = function() {
|
|
127
|
+
var c = [], s = function() {
|
|
128
|
+
c.push({ time: /* @__PURE__ */ new Date(), state: document.visibilityState });
|
|
129
|
+
}, E = function(h, f, R, _) {
|
|
130
|
+
return h.addEventListener(f, R, _), function() {
|
|
131
|
+
return h.removeEventListener(f, R, _);
|
|
132
|
+
};
|
|
133
|
+
}(document, "visibilitychange", s);
|
|
134
|
+
return s(), [c, E];
|
|
135
|
+
}(), u = l[0], d = l[1];
|
|
136
|
+
return Promise.resolve().then(function() {
|
|
137
|
+
if (!i || typeof i != "string")
|
|
138
|
+
throw new Error(P);
|
|
139
|
+
var c = function(s, E) {
|
|
140
|
+
return (Array.isArray(s) ? s : [s]).map(function(h) {
|
|
141
|
+
return function(f, R) {
|
|
142
|
+
var _ = encodeURIComponent;
|
|
143
|
+
return f.replace(/<[^<>]+>/g, function(p) {
|
|
144
|
+
return p === "<version>" ? "3" : p === "<apiKey>" ? _(R) : p === "<loaderVersion>" ? _(fe) : p;
|
|
145
|
+
});
|
|
146
|
+
}(String(h), E);
|
|
147
|
+
});
|
|
148
|
+
}(a, i);
|
|
149
|
+
return Ee(c, _e);
|
|
150
|
+
}).catch(function(c) {
|
|
151
|
+
throw d(), function(s) {
|
|
152
|
+
return s instanceof Error && s.message === L ? new Error(S) : s;
|
|
153
|
+
}(c);
|
|
154
|
+
}).then(function(c) {
|
|
155
|
+
var s = c[0], E = c[1];
|
|
156
|
+
return d(), s.load(N(N({}, o), { ldi: { attempts: E, visibilityStates: u } }));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function _e(r) {
|
|
160
|
+
return function(e, t, n, i) {
|
|
161
|
+
var o, a = document, l = "securitypolicyviolation", u = function(c) {
|
|
162
|
+
var s = new URL(e, location.href), E = c.blockedURI;
|
|
163
|
+
E !== s.href && E !== s.protocol.slice(0, -1) && E !== s.origin || (o = c, d());
|
|
164
|
+
};
|
|
165
|
+
a.addEventListener(l, u);
|
|
166
|
+
var d = function() {
|
|
167
|
+
return a.removeEventListener(l, u);
|
|
168
|
+
};
|
|
169
|
+
return i == null || i.then(d, d), Promise.resolve().then(t).then(function(c) {
|
|
170
|
+
return d(), c;
|
|
171
|
+
}, function(c) {
|
|
172
|
+
return new Promise(function(s) {
|
|
173
|
+
return setTimeout(s);
|
|
174
|
+
}).then(function() {
|
|
175
|
+
if (d(), o)
|
|
176
|
+
return n(o);
|
|
177
|
+
throw c;
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}(r, function() {
|
|
181
|
+
return function(e) {
|
|
182
|
+
return new Promise(function(t, n) {
|
|
183
|
+
if (function(l) {
|
|
184
|
+
if (URL.prototype)
|
|
185
|
+
try {
|
|
186
|
+
return new URL(l, location.href), !1;
|
|
187
|
+
} catch (u) {
|
|
188
|
+
if (u instanceof Error && u.name === "TypeError")
|
|
189
|
+
return !0;
|
|
190
|
+
throw u;
|
|
191
|
+
}
|
|
192
|
+
}(e))
|
|
193
|
+
throw new Error(A);
|
|
194
|
+
var i = document.createElement("script"), o = function() {
|
|
195
|
+
var l;
|
|
196
|
+
return (l = i.parentNode) === null || l === void 0 ? void 0 : l.removeChild(i);
|
|
197
|
+
}, a = document.head || document.getElementsByTagName("head")[0];
|
|
198
|
+
i.onload = function() {
|
|
199
|
+
o(), t();
|
|
200
|
+
}, i.onerror = function() {
|
|
201
|
+
o(), n(new Error(S));
|
|
202
|
+
}, i.async = !0, i.src = e, a.appendChild(i);
|
|
203
|
+
});
|
|
204
|
+
}(r);
|
|
205
|
+
}, function() {
|
|
206
|
+
throw new Error(T);
|
|
207
|
+
}).then(pe);
|
|
208
|
+
}
|
|
209
|
+
function pe() {
|
|
210
|
+
var r = window, e = "__fpjs_p_l_b", t = r[e];
|
|
211
|
+
if (function(n, i) {
|
|
212
|
+
var o, a = (o = Object.getOwnPropertyDescriptor) === null || o === void 0 ? void 0 : o.call(Object, n, i);
|
|
213
|
+
a != null && a.configurable ? delete n[i] : a && !a.writable || (n[i] = void 0);
|
|
214
|
+
}(r, e), typeof (t == null ? void 0 : t.load) != "function")
|
|
215
|
+
throw new Error(L);
|
|
216
|
+
return t;
|
|
217
|
+
}
|
|
218
|
+
var Oe = { load: ie, defaultScriptUrlPattern: K, ERROR_SCRIPT_LOAD_FAIL: S, ERROR_API_KEY_EXPIRED: C, ERROR_API_KEY_INVALID: b, ERROR_API_KEY_MISSING: P, ERROR_BAD_REQUEST_FORMAT: J, ERROR_BAD_RESPONSE_FORMAT: V, ERROR_CLIENT_TIMEOUT: j, ERROR_CSP_BLOCK: T, ERROR_FORBIDDEN_ENDPOINT: H, ERROR_FORBIDDEN_HEADER: Z, ERROR_FORBIDDEN_ORIGIN: Q, ERROR_GENERAL_SERVER_FAILURE: Y, ERROR_INSTALLATION_METHOD_RESTRICTED: $, ERROR_INTEGRATION_FAILURE: W, ERROR_INVALID_ENDPOINT: A, ERROR_NETWORK_ABORT: x, ERROR_NETWORK_CONNECTION: k, ERROR_RATE_LIMIT: z, ERROR_SERVER_TIMEOUT: X, ERROR_SUBSCRIPTION_NOT_ACTIVE: q, ERROR_TOKEN_EXPIRED: ne, ERROR_TOKEN_INVALID: te, ERROR_TOKEN_MISSING: ee, ERROR_UNSUPPORTED_VERSION: G, ERROR_WRONG_REGION: B, defaultEndpoint: D, defaultTlsEndpoint: M };
|
|
219
|
+
const ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
220
|
+
__proto__: null,
|
|
221
|
+
ERROR_API_KEY_EXPIRED: C,
|
|
222
|
+
ERROR_API_KEY_INVALID: b,
|
|
223
|
+
ERROR_API_KEY_MISSING: P,
|
|
224
|
+
ERROR_BAD_REQUEST_FORMAT: J,
|
|
225
|
+
ERROR_BAD_RESPONSE_FORMAT: V,
|
|
226
|
+
ERROR_CLIENT_TIMEOUT: j,
|
|
227
|
+
ERROR_CSP_BLOCK: T,
|
|
228
|
+
ERROR_FORBIDDEN_ENDPOINT: H,
|
|
229
|
+
ERROR_FORBIDDEN_HEADER: Z,
|
|
230
|
+
ERROR_FORBIDDEN_ORIGIN: Q,
|
|
231
|
+
ERROR_GENERAL_SERVER_FAILURE: Y,
|
|
232
|
+
ERROR_INSTALLATION_METHOD_RESTRICTED: $,
|
|
233
|
+
ERROR_INTEGRATION_FAILURE: W,
|
|
234
|
+
ERROR_INVALID_ENDPOINT: A,
|
|
235
|
+
ERROR_NETWORK_ABORT: x,
|
|
236
|
+
ERROR_NETWORK_CONNECTION: k,
|
|
237
|
+
ERROR_RATE_LIMIT: z,
|
|
238
|
+
ERROR_SCRIPT_LOAD_FAIL: S,
|
|
239
|
+
ERROR_SERVER_TIMEOUT: X,
|
|
240
|
+
ERROR_SUBSCRIPTION_NOT_ACTIVE: q,
|
|
241
|
+
ERROR_TOKEN_EXPIRED: ne,
|
|
242
|
+
ERROR_TOKEN_INVALID: te,
|
|
243
|
+
ERROR_TOKEN_MISSING: ee,
|
|
244
|
+
ERROR_UNSUPPORTED_VERSION: G,
|
|
245
|
+
ERROR_WRONG_REGION: B,
|
|
246
|
+
default: Oe,
|
|
247
|
+
defaultEndpoint: D,
|
|
248
|
+
defaultScriptUrlPattern: K,
|
|
249
|
+
defaultTlsEndpoint: M,
|
|
250
|
+
load: ie
|
|
251
|
+
}, Symbol.toStringTag, { value: "Module" })), oe = "@fpjs@client@", ge = 60 * 60 * 24, ae = 60 * 60, ye = () => Date.now();
|
|
252
|
+
class Ie {
|
|
253
|
+
constructor(e) {
|
|
254
|
+
var t;
|
|
255
|
+
this.tag = e.tag || null, this.linkedId = e.linkedId || null, this.extendedResult = (t = e.extendedResult) !== null && t !== void 0 ? t : !1;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Converts this `CacheKey` instance into a string for use in a cache
|
|
259
|
+
* @returns A string representation of the key
|
|
260
|
+
*/
|
|
261
|
+
toKey() {
|
|
262
|
+
return `${JSON.stringify(this.tag)}__${JSON.stringify(this.linkedId)}__${this.extendedResult}`;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function y(r, e) {
|
|
266
|
+
return `${e}__${r}`;
|
|
267
|
+
}
|
|
268
|
+
function ce(r, e) {
|
|
269
|
+
return r.replace(`${e}__`, "");
|
|
270
|
+
}
|
|
271
|
+
class me {
|
|
272
|
+
constructor(e = oe) {
|
|
273
|
+
this.prefix = e;
|
|
274
|
+
}
|
|
275
|
+
set(e, t) {
|
|
276
|
+
window.localStorage.setItem(y(e, this.prefix), JSON.stringify(t));
|
|
277
|
+
}
|
|
278
|
+
get(e) {
|
|
279
|
+
const t = window.localStorage.getItem(y(e, this.prefix));
|
|
280
|
+
if (t)
|
|
281
|
+
try {
|
|
282
|
+
return JSON.parse(t);
|
|
283
|
+
} catch {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
remove(e) {
|
|
288
|
+
window.localStorage.removeItem(y(e, this.prefix));
|
|
289
|
+
}
|
|
290
|
+
allKeys() {
|
|
291
|
+
return Object.keys(window.localStorage).filter((e) => e.startsWith(this.prefix)).map((e) => ce(e, this.prefix));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
class we {
|
|
295
|
+
constructor(e = oe) {
|
|
296
|
+
this.prefix = e;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* It takes a key and an entry, and sets the entry in the session storage with the key
|
|
300
|
+
* @param {string} key - The key to store the entry under.
|
|
301
|
+
* @param {Cacheable} entry - The value to be stored in the cache.
|
|
302
|
+
*/
|
|
303
|
+
set(e, t) {
|
|
304
|
+
window.sessionStorage.setItem(y(e, this.prefix), JSON.stringify(t));
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* It gets the value of the key from the session storage, parses it as JSON, and returns it
|
|
308
|
+
* @param {string} key - The key to store the data under.
|
|
309
|
+
* @returns The value of the key in the sessionStorage.
|
|
310
|
+
*/
|
|
311
|
+
get(e) {
|
|
312
|
+
const t = window.sessionStorage.getItem(y(e, this.prefix));
|
|
313
|
+
if (t)
|
|
314
|
+
try {
|
|
315
|
+
return JSON.parse(t);
|
|
316
|
+
} catch {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* It removes the item from session storage with the given key
|
|
322
|
+
* @param {string} key - The key to store the value under.
|
|
323
|
+
*/
|
|
324
|
+
remove(e) {
|
|
325
|
+
window.sessionStorage.removeItem(y(e, this.prefix));
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* It returns an array of all the keys in the session storage that start with the prefix
|
|
329
|
+
* @returns An array of all the keys in the sessionStorage that start with the prefix.
|
|
330
|
+
*/
|
|
331
|
+
allKeys() {
|
|
332
|
+
return Object.keys(window.sessionStorage).filter((e) => e.startsWith(this.prefix)).map((e) => ce(e, this.prefix));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
class Se {
|
|
336
|
+
constructor(e, t = ae, n) {
|
|
337
|
+
this.cache = e, this.cacheTime = t, this.nowProvider = n || ye;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* It gets a cache entry from the cache, and if it's expired, it removes it from the cache
|
|
341
|
+
* @param cacheKey - CacheKey<TExtended>
|
|
342
|
+
* @returns A promise that resolves to a cache entry or undefined.
|
|
343
|
+
*/
|
|
344
|
+
get(e) {
|
|
345
|
+
return O(this, void 0, void 0, function* () {
|
|
346
|
+
const t = yield this.cache.get(e.toKey());
|
|
347
|
+
if (!t)
|
|
348
|
+
return;
|
|
349
|
+
const n = yield this.nowProvider(), i = Math.floor(n / 1e3);
|
|
350
|
+
if (t.expiresAt < i) {
|
|
351
|
+
yield this.cache.remove(e.toKey());
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
return t.body;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* It takes a cache key and a cache entry, wraps the cache entry, and then sets the wrapped cache entry in the cache
|
|
359
|
+
* @param cacheKey - CacheKey<TExtended>
|
|
360
|
+
* @param {CacheEntry} entry - The cache entry to be stored.
|
|
361
|
+
*/
|
|
362
|
+
set(e, t) {
|
|
363
|
+
return O(this, void 0, void 0, function* () {
|
|
364
|
+
const n = yield this.wrapCacheEntry(t);
|
|
365
|
+
yield this.cache.set(e.toKey(), n);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* It gets all the keys in the cache, and then removes them all
|
|
370
|
+
*/
|
|
371
|
+
clearCache() {
|
|
372
|
+
return O(this, void 0, void 0, function* () {
|
|
373
|
+
const e = yield this.cache.allKeys();
|
|
374
|
+
yield Promise.all(e.map((t) => this.cache.remove(t)));
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
wrapCacheEntry(e) {
|
|
378
|
+
return O(this, void 0, void 0, function* () {
|
|
379
|
+
const t = yield this.nowProvider(), n = Math.floor(t / 1e3) + this.cacheTime;
|
|
380
|
+
return {
|
|
381
|
+
body: e,
|
|
382
|
+
expiresAt: n
|
|
383
|
+
};
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
class Ne {
|
|
388
|
+
constructor() {
|
|
389
|
+
this.enclosedCache = /* @__PURE__ */ function() {
|
|
390
|
+
const e = {};
|
|
391
|
+
return {
|
|
392
|
+
set(t, n) {
|
|
393
|
+
e[t] = n;
|
|
394
|
+
},
|
|
395
|
+
get(t) {
|
|
396
|
+
const n = e[t];
|
|
397
|
+
if (n)
|
|
398
|
+
return n;
|
|
399
|
+
},
|
|
400
|
+
remove(t) {
|
|
401
|
+
delete e[t];
|
|
402
|
+
},
|
|
403
|
+
allKeys() {
|
|
404
|
+
return Object.keys(e);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
class Te {
|
|
411
|
+
set() {
|
|
412
|
+
}
|
|
413
|
+
get() {
|
|
414
|
+
}
|
|
415
|
+
remove() {
|
|
416
|
+
}
|
|
417
|
+
allKeys() {
|
|
418
|
+
return [];
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
var v;
|
|
422
|
+
(function(r) {
|
|
423
|
+
r.Memory = "memory", r.LocalStorage = "localstorage", r.SessionStorage = "sessionstorage", r.NoCache = "nocache";
|
|
424
|
+
})(v || (v = {}));
|
|
425
|
+
var Ae = "1.3.0";
|
|
426
|
+
const Pe = {
|
|
427
|
+
[v.Memory]: () => new Ne().enclosedCache,
|
|
428
|
+
[v.LocalStorage]: (r) => new me(r),
|
|
429
|
+
[v.SessionStorage]: (r) => new we(r),
|
|
430
|
+
[v.NoCache]: () => new Te()
|
|
431
|
+
}, De = (r) => {
|
|
432
|
+
switch (r) {
|
|
433
|
+
case v.SessionStorage:
|
|
434
|
+
try {
|
|
435
|
+
window.sessionStorage.getItem("item");
|
|
436
|
+
} catch {
|
|
437
|
+
return !1;
|
|
438
|
+
}
|
|
439
|
+
return !0;
|
|
440
|
+
case v.LocalStorage:
|
|
441
|
+
try {
|
|
442
|
+
window.localStorage.getItem("item");
|
|
443
|
+
} catch {
|
|
444
|
+
return !1;
|
|
445
|
+
}
|
|
446
|
+
return !0;
|
|
447
|
+
default:
|
|
448
|
+
return !0;
|
|
449
|
+
}
|
|
450
|
+
}, F = (r) => Pe[r];
|
|
451
|
+
class w {
|
|
452
|
+
constructor(e) {
|
|
453
|
+
var t;
|
|
454
|
+
this.inFlightRequests = /* @__PURE__ */ new Map(), this.agentPromise = null, this.customAgent = e == null ? void 0 : e.customAgent, this.agent = {
|
|
455
|
+
get: () => {
|
|
456
|
+
throw new Error("FPJSAgent hasn't loaded yet. Make sure to call the init() method first.");
|
|
457
|
+
}
|
|
458
|
+
}, this.loadOptions = e == null ? void 0 : e.loadOptions, e != null && e.cache && (e != null && e.cacheLocation) && console.warn("Both `cache` and `cacheLocation` options have been specified in the FpjsClient configuration; ignoring `cacheLocation` and using `cache`.");
|
|
459
|
+
let n;
|
|
460
|
+
if (e != null && e.cache)
|
|
461
|
+
n = e.cache;
|
|
462
|
+
else {
|
|
463
|
+
if (this.cacheLocation = (e == null ? void 0 : e.cacheLocation) || v.SessionStorage, !F(this.cacheLocation))
|
|
464
|
+
throw new Error(`Invalid cache location "${this.cacheLocation}"`);
|
|
465
|
+
De(this.cacheLocation) || (this.cacheLocation = v.Memory), n = F(this.cacheLocation)(e == null ? void 0 : e.cachePrefix);
|
|
466
|
+
}
|
|
467
|
+
if (e != null && e.cacheTimeInSeconds && e.cacheTimeInSeconds > ge)
|
|
468
|
+
throw new Error("Cache time cannot exceed 86400 seconds (24 hours)");
|
|
469
|
+
const i = (t = e == null ? void 0 : e.cacheTimeInSeconds) !== null && t !== void 0 ? t : ae;
|
|
470
|
+
this.cacheManager = new Se(n, i);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Loads FPJS JS agent with certain settings and stores the instance in memory
|
|
474
|
+
* [https://dev.fingerprint.com/docs/js-agent#agent-initialization]
|
|
475
|
+
*
|
|
476
|
+
* @param passedLoadOptions Additional load options to be passed to the agent, they will be merged with load options provided in the constructor.
|
|
477
|
+
*/
|
|
478
|
+
init(e) {
|
|
479
|
+
var t, n;
|
|
480
|
+
return O(this, void 0, void 0, function* () {
|
|
481
|
+
if (!this.loadOptions && !e)
|
|
482
|
+
throw new TypeError("No load options provided");
|
|
483
|
+
const i = Object.assign(Object.assign(Object.assign({}, this.loadOptions), e), { integrationInfo: [
|
|
484
|
+
...((t = this.loadOptions) === null || t === void 0 ? void 0 : t.integrationInfo) || [],
|
|
485
|
+
...(e == null ? void 0 : e.integrationInfo) || [],
|
|
486
|
+
`fingerprintjs-pro-spa/${Ae}`
|
|
487
|
+
] });
|
|
488
|
+
if (!this.agentPromise) {
|
|
489
|
+
const o = (n = this.customAgent) !== null && n !== void 0 ? n : ve;
|
|
490
|
+
this.agentPromise = o.load(i).then((a) => (this.agent = a, a)).catch((a) => {
|
|
491
|
+
throw this.agentPromise = null, a;
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return this.agentPromise;
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Returns visitor identification data based on the request options
|
|
499
|
+
* [https://dev.fingerprint.com/docs/js-agent#visitor-identification]
|
|
500
|
+
*
|
|
501
|
+
* @param options
|
|
502
|
+
* @param ignoreCache if set to true a request to the API will be made even if the data is present in cache
|
|
503
|
+
*/
|
|
504
|
+
getVisitorData(e = {}, t = !1) {
|
|
505
|
+
return O(this, void 0, void 0, function* () {
|
|
506
|
+
const i = w.makeCacheKey(e).toKey();
|
|
507
|
+
if (!this.inFlightRequests.has(i)) {
|
|
508
|
+
const o = this._identify(e, t).finally(() => {
|
|
509
|
+
this.inFlightRequests.delete(i);
|
|
510
|
+
});
|
|
511
|
+
this.inFlightRequests.set(i, o);
|
|
512
|
+
}
|
|
513
|
+
return yield this.inFlightRequests.get(i);
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Returns cached visitor data based on the request options, or undefined if the data is not present in cache
|
|
518
|
+
* */
|
|
519
|
+
getVisitorDataFromCache(e = {}) {
|
|
520
|
+
return O(this, void 0, void 0, function* () {
|
|
521
|
+
const t = w.makeCacheKey(e), n = yield this.cacheManager.get(t);
|
|
522
|
+
return n ? Object.assign(Object.assign({}, n), { cacheHit: !0 }) : void 0;
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Checks if request matching given options is present in cache
|
|
527
|
+
* */
|
|
528
|
+
isInCache(e = {}) {
|
|
529
|
+
return O(this, void 0, void 0, function* () {
|
|
530
|
+
return !!(yield this.getVisitorDataFromCache(e));
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Clears visitor data from cache regardless of the cache implementation
|
|
535
|
+
*/
|
|
536
|
+
clearCache() {
|
|
537
|
+
return O(this, void 0, void 0, function* () {
|
|
538
|
+
yield this.cacheManager.clearCache();
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Makes a CacheKey object from GetOptions
|
|
543
|
+
*/
|
|
544
|
+
static makeCacheKey(e) {
|
|
545
|
+
return new Ie(e);
|
|
546
|
+
}
|
|
547
|
+
_identify(e, t = !1) {
|
|
548
|
+
return O(this, void 0, void 0, function* () {
|
|
549
|
+
const n = w.makeCacheKey(e);
|
|
550
|
+
if (!t) {
|
|
551
|
+
const o = yield this.cacheManager.get(n);
|
|
552
|
+
if (o)
|
|
553
|
+
return Object.assign(Object.assign({}, o), { cacheHit: !0 });
|
|
554
|
+
}
|
|
555
|
+
const i = yield this.agent.get(e);
|
|
556
|
+
return yield this.cacheManager.set(n, i), Object.assign(Object.assign({}, i), { cacheHit: !1 });
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
async function U() {
|
|
561
|
+
try {
|
|
562
|
+
const r = typeof Cypress == "object", e = typeof process == "object" && process.env.NODE_ENV === "test";
|
|
563
|
+
if (r || e)
|
|
564
|
+
return "a-mock-visitor-id";
|
|
565
|
+
const t = "https://d2hwnq6cq5q3pi.cloudfront.net", n = "wyr92st0i7", i = "ia1t65gn6i", o = "db4fuswrza", a = new w({
|
|
566
|
+
loadOptions: {
|
|
567
|
+
apiKey: "hpFVJecm7Ni7AjSfvBIW",
|
|
568
|
+
endpoint: [
|
|
569
|
+
`${t}/${n}/${i}`,
|
|
570
|
+
D
|
|
571
|
+
],
|
|
572
|
+
scriptUrlPattern: [
|
|
573
|
+
`${t}/${n}/${o}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,
|
|
574
|
+
K
|
|
575
|
+
]
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
return await a.init(), (await a.getVisitorData()).visitorId;
|
|
579
|
+
} catch (r) {
|
|
580
|
+
return console.log(r), "";
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
async function be() {
|
|
584
|
+
return new Promise((r) => {
|
|
585
|
+
window.requestIdleCallback ? requestIdleCallback(async () => {
|
|
586
|
+
const e = await U();
|
|
587
|
+
r(e);
|
|
588
|
+
}) : setTimeout(async () => {
|
|
589
|
+
const e = await U();
|
|
590
|
+
r(e);
|
|
591
|
+
}, 500);
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
const Ce = "https://tst.kaptcha.com", Le = "https://ssl.kaptcha.com", Ke = (r) => r === "production", Fe = ({ env: r, kountAccountId: e, kountSessionId: t }) => {
|
|
595
|
+
const n = Ke(r) ? Le : Ce, i = new URL(`${n}/collect/sdk`);
|
|
596
|
+
i.searchParams.append("m", e), t && i.searchParams.append("m", t);
|
|
597
|
+
const o = document.createElement("script");
|
|
598
|
+
return o.setAttribute("class", "kaxsdc"), o.setAttribute("data-event", "load"), o.setAttribute("type", "text/javascript"), o.setAttribute("src", i.href), document.body.append(o), o;
|
|
599
|
+
};
|
|
600
|
+
async function Ue({
|
|
601
|
+
env: r,
|
|
602
|
+
kountAccountId: e,
|
|
603
|
+
kountSessionId: t
|
|
604
|
+
}) {
|
|
605
|
+
return new Promise((n, i) => {
|
|
606
|
+
const o = Fe({
|
|
607
|
+
env: r,
|
|
608
|
+
kountAccountId: e,
|
|
609
|
+
kountSessionId: t
|
|
610
|
+
});
|
|
611
|
+
o.onload = () => {
|
|
612
|
+
const a = new ka.ClientSDK();
|
|
613
|
+
a.setupCallback({
|
|
614
|
+
"collect-begin": (l) => {
|
|
615
|
+
const { MercSessId: u } = l;
|
|
616
|
+
n(u);
|
|
617
|
+
}
|
|
618
|
+
}), a.autoLoadEvents();
|
|
619
|
+
}, o.onerror = () => {
|
|
620
|
+
i(new Error("Error attempting to mount Kount script"));
|
|
621
|
+
};
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
async function Me({
|
|
625
|
+
env: r = null,
|
|
626
|
+
screen: e,
|
|
627
|
+
navigator: t,
|
|
628
|
+
kountAccountId: n = null,
|
|
629
|
+
kountSessionId: i = null,
|
|
630
|
+
getFingerprint: o,
|
|
631
|
+
getFraudSessionId: a
|
|
632
|
+
}) {
|
|
633
|
+
const { colorDepth: l, height: u, width: d } = e || {}, { javaEnabled: c, language: s } = t || {};
|
|
634
|
+
let E, h;
|
|
635
|
+
try {
|
|
636
|
+
E = await o(), n && (h = await a({
|
|
637
|
+
env: r,
|
|
638
|
+
kountAccountId: n,
|
|
639
|
+
kountSessionId: i
|
|
640
|
+
}));
|
|
641
|
+
} catch (R) {
|
|
642
|
+
console.error(R);
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
riskMetadata: {
|
|
646
|
+
fingerprint: E || null,
|
|
647
|
+
extraData: {
|
|
648
|
+
kountFraudSessionId: h || null
|
|
649
|
+
},
|
|
650
|
+
browserData: {
|
|
651
|
+
colorDepth: l || null,
|
|
652
|
+
isJavaEnabled: c ? c.call(t) : null,
|
|
653
|
+
language: s || null,
|
|
654
|
+
screenHeight: u || null,
|
|
655
|
+
screenWidth: d || null,
|
|
656
|
+
timeZoneOffset: (/* @__PURE__ */ new Date()).getTimezoneOffset()
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
async function je({
|
|
662
|
+
env: r = null,
|
|
663
|
+
kountAccountId: e = null,
|
|
664
|
+
kountSessionId: t = null
|
|
665
|
+
} = {}) {
|
|
666
|
+
return Me({
|
|
667
|
+
env: r,
|
|
668
|
+
screen,
|
|
669
|
+
navigator,
|
|
670
|
+
kountAccountId: e,
|
|
671
|
+
kountSessionId: t,
|
|
672
|
+
getFingerprint: be,
|
|
673
|
+
getFraudSessionId: Ue
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
export {
|
|
677
|
+
je as collectData,
|
|
678
|
+
Me as collectDataHelper
|
|
679
|
+
};
|
|
680
|
+
//# sourceMappingURL=data-collector.js.map
|