@netacea/f5 5.8.4 → 5.8.5
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/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e,n,a){return n=r(n),function(e,t){if(t&&("object"==o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,t()?Reflect.construct(n,a||[],r(e).constructor):n.apply(e,a))}function t(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(t=function(){return!!e})()}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function n(){n=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,a){var o=RegExp(e,n);return t.set(o,a||t.get(e)),i(o,r.prototype)}function s(e,r){var n=t.get(r);return Object.keys(n).reduce((function(t,r){var a=n[r];if("number"==typeof a)t[r]=e[a];else{for(var i=0;void 0===e[a[i]]&&i+1<a.length;)i++;t[r]=e[a[i]]}return t}),Object.create(null))}return a(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);if(r){r.groups=s(r,this);var n=r.indices;n&&(n.groups=s(n,this))}return r},r.prototype[Symbol.replace]=function(r,n){if("string"==typeof n){var a=t.get(this);return e[Symbol.replace].call(this,r,n.replace(/\$<([^>]+)(>|$)/g,(function(e,t,r){if(""===r)return e;var n=a[t];return Array.isArray(n)?"$"+n.join("$"):"number"==typeof n?"$"+n:""})))}if("function"==typeof n){var i=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=o(e[e.length-1])&&(e=[].slice.call(e)).push(s(e,i)),n.apply(this,e)}))}return e[Symbol.replace].call(this,r,n)},n.apply(this,arguments)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function s(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */s=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var i=t&&t.prototype instanceof k?t:k,o=Object.create(i.prototype),s=new T(n||[]);return a(o,"_invoke",{value:N(e,r,s)}),o}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var f="suspendedStart",v="suspendedYield",y="executing",g="completed",m={};function k(){}function b(){}function x(){}var S={};h(S,c,(function(){return this}));var C=Object.getPrototypeOf,w=C&&C(C(K([])));w&&w!==r&&n.call(w,c)&&(S=w);var I=x.prototype=k.prototype=Object.create(S);function A(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(a,i,s,c){var u=d(e[a],e,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==o(h)&&n.call(h,"__await")?t.resolve(h.__await).then((function(e){r("next",e,s,c)}),(function(e){r("throw",e,s,c)})):t.resolve(h).then((function(e){l.value=e,s(l)}),(function(e){return r("throw",e,s,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function N(t,r,n){var a=f;return function(i,o){if(a===y)throw Error("Generator is already running");if(a===g){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=E(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===f)throw a=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=y;var u=d(t,r,n);if("normal"===u.type){if(a=n.done?g:v,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=g,n.method="throw",n.arg=u.arg)}}}function E(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,E(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=d(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function K(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(o(t)+" is not iterable")}return b.prototype=x,a(I,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=h(x,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,h(e,l,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},A(O.prototype),h(O.prototype,u,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new O(p(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},A(I),h(I,l,"Generator"),h(I,c,(function(){return this})),h(I,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=K,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(_),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;_(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:K(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function c(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function l(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){u(i,n,a,o,s,"next",e)}function s(e){u(i,n,a,o,s,"throw",e)}o(void 0)}))}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,g(n.key),n)}}function d(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e,t,r){return(t=g(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e){var t=function(e,t){if("object"!=o(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==o(t)?t:t+""}function m(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=b(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw i}}}}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,s=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){if(e){if("string"==typeof e)return x(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var S=require("crypto"),C=require("buffer"),w=require("https"),I=require("querystring"),A=require("aws4");function O(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var N,E,P,_=O(S),T=O(w),K=O(I);!function(e){e.ORIGIN="ORIGIN",e.HTTP="HTTP",e.KINESIS="KINESIS",e.NATIVE="NATIVE"}(N||(N={})),function(e){e.MITIGATE="MITIGATE",e.INJECT="INJECT",e.INGEST="INGEST"}(E||(E={})),function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session"}(P||(P={}));var R=3e3;var j="_/@#/",V={none:"",block:"block",captcha:"captcha",allow:"allow",captchaPass:"captchapass"},M={0:V.none,1:V.block,2:V.none,3:V.block,4:V.none,5:V.block},H={1:V.captcha,2:V.captchaPass,3:V.captcha,4:V.allow,5:V.captcha,6:V.allow,7:V.captcha,a:V.captcha,b:V.captchaPass,c:V.captcha,d:V.allow,e:V.captcha},L=Object.freeze({__proto__:null,COOKIEDELIMITER:j,bestMitigationCaptchaMap:H,bestMitigationMap:M,captchaMap:{0:"",1:"captcha_serve",2:"captcha_pass",3:"captcha_fail",4:"captcha_cookiepass",5:"captcha_cookiefail",6:"checkpoint_signal",7:"checkpoint_post",a:"checkpoint_serve",b:"checkpoint_pass",c:"checkpoint_fail",d:"checkpoint_cookiepass",e:"checkpoint_cookiefail"},captchaStatusCodes:{"":0,captchaServe:1,captchaPass:2,captchaFail:3,captchaCookiePass:4,captchaCookieFail:5,checkpointSignal:6,checkpointPost:7,checkpointServe:"a",checkpointPass:"b",checkpointFail:"c",checkpointCookiePass:"d",checkpointCookieFail:"e"},matchMap:{0:"",1:"ua_",2:"ip_",3:"visitor_",4:"datacenter_",5:"customer_session_",6:"organisation_",7:"asn_",8:"country_",9:"combination_",b:"headerFP_",c:"vendorFamily_",d:"vendorName_",e:"vendor_",f:"vendorCrawlerClassification_"},mitigateMap:{0:"",1:"blocked",2:"allow",3:"hardblocked",4:"flagged",5:"monetised"},mitigationTypes:V,netaceaCookieV3KeyMap:{clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},netaceaCookieV3OptionalKeyMap:{checkAllPostRequests:"fCAPR"},netaceaHeaders:{match:"x-netacea-match",mitigate:"x-netacea-mitigate",captcha:"x-netacea-captcha",mitata:"x-netacea-mitata-value",mitataExpiry:"x-netacea-mitata-expiry",mitataCaptcha:"x-netacea-mitatacaptcha-value",mitataCaptchaExpiry:"x-netacea-mitatacaptcha-expiry",eventId:"x-netacea-event-id"},netaceaSettingsMap:{checkAllPostRequests:"checkAllPostRequests"}}),D="ignored",B="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),F=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;function q(e){if(void 0!==e){var t=e.match(F);if(null!=t){var r=k(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:B,r=S.randomBytes(e-1),n=Array.from(r).map((function(e){return t[e%t.length]})).join("");return"c".concat(n)}function G(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"000";void 0===t&&(t=z());var i=[r,t,U(e+"|"+String(r),n),a].join(j),o=U(i,n);return"".concat(o).concat(j).concat(i)}function U(e,t){var r=S.createHmac("sha256",t);return r.update(e),C.Buffer.from(r.digest("hex")).toString("base64")}function J(e,t,r){var n={mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0"};if("string"!=typeof e||""===e)return n;var a=q(e);if(void 0!==a){var i=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(j),o=Math.floor(Date.now()/1e3),s=parseInt(a.expiry)<o,c=["1","3","5","a","c","e"].includes(a.captcha),u="3"===a.mitigate,l=c||u,h=U(t+"|"+a.expiry,r),p=a.ipHash===h;return{mitata:a,requiresReissue:s||!p,isExpired:s,shouldExpire:l,isSameIP:p,isPrimaryHashValid:a.signature===U(i,r),match:a.match,mitigate:a.mitigate,captcha:a.captcha,userId:a.userId}}return n}function X(e,t){var r=e.split(";").map((function(e){return e.trim()})).filter((function(e){return e.toLowerCase().startsWith(t.toLowerCase())}))[0];return void 0!==r&&r.length>0?null==r?void 0:r.replace("".concat(t,"="),""):void 0}function W(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof e&&(e=e.join("; ")),""===e?"":$(e.split(";"),t).join("; ")}function $(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return $(e.reverse()).reverse();var t,r=new Set,n=[],a=m(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;if(""!==(i=i.trimStart()).trim()){var o=i.split("=")[0].toUpperCase();r.has(o)||(r.add(o),n.push(i))}}}catch(e){a.e(e)}finally{a.f()}return n}function Y(e){var t,r,n=W([null!==(t=e.otherAttributes)&&void 0!==t?t:"","Max-Age=".concat(null!==(r=e.maxAgeAttribute)&&void 0!==r?r:86400),"Path=/"].join("; "));return"".concat(e.cookieName,"=").concat(e.cookieValue,"; ").concat(n)}var Q={cookie:{attributes:Object.freeze({__proto__:null,configureCookiesDomain:function(e,t){var r=e=W(null!=e?e:"",!0),n=t=W(null!=t?t:"",!0);if(void 0!==e&&void 0!==t){var a=X(e,"Domain"),i=X(t,"Domain");void 0!==a&&void 0!==i?n=t.replace(i,a):void 0!==a&&void 0===i?n=t+(""!==t?"; Domain=".concat(a):"Domain=".concat(a)):void 0===a&&void 0!==i&&(r=e+(""!==e?"; Domain=".concat(i):"Domain=".concat(i)))}else if(void 0!==e&&void 0===t){var o=X(e,"Domain");void 0!==o&&(n="Domain=".concat(o))}else if(void 0===e&&void 0!==t){var s=X(t,"Domain");void 0!==s&&(r="Domain=".concat(s))}return{cookieAttributes:""!==r?r:void 0,captchaCookieAttributes:""!==n?n:void 0}},extractAndRemoveCookieAttr:function(e,t){var r=X(e,t);return void 0!==r?{extractedAttribute:r,cookieAttributes:e.replace(/ /g,"").replace("".concat(t,"=").concat(r),"").split(";").filter((function(e){return e.length>0})).join("; ")}:{extractedAttribute:void 0,cookieAttributes:e}},extractCookieAttr:X,removeDuplicateAttrs:W}),netaceaSession:Object.freeze({__proto__:null,createNetaceaCaptchaSetCookieString:function(e){var t;return Y(v(v({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitatacaptcha"}))},createNetaceaSetCookieString:function(e){var t;return Y(v(v({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitata"}))},createSetCookieString:Y})}},Z=function(){function e(t,r){h(this,e),this.crypto=t,this.TextEncoder=r}return d(e,[{key:"hashString",value:(r=l(s().mark((function e(t,r){var n,a,i,o,u,l,h=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=(n=h.length>2&&void 0!==h[2]&&h[2])?c(r).sort():c(r),i=(new this.TextEncoder).encode(a.join(",")),e.next=1,this.crypto.subtle.digest(t,i);case 1:return o=e.sent,u=Array.from(new Uint8Array(o)),l=u.map((function(e){return e.toString(16).padStart(2,"0")})).join("").substring(0,12),e.abrupt("return","h"+(n?"s":"")+"_".concat(r.length,"_").concat(l));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"hashHeaders",value:(t=l(s().mark((function t(r){var n,a,i,o=arguments;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>1&&void 0!==o[1]&&o[1],0!==(a=e.filterHeaderNames(r)).length){t.next=1;break}return t.abrupt("return","");case 1:return t.prev=1,t.next=2,this.hashString("SHA-256",a,n);case 2:return t.abrupt("return",t.sent);case 3:return t.prev=3,i=t.catch(1),console.error(i),t.abrupt("return","");case 4:case"end":return t.stop()}}),t,this,[[1,3]])}))),function(e){return t.apply(this,arguments)})}],[{key:"filterHeaderNames",value:function(e){return e.filter((function(e){var t=e.toLowerCase();return!["","cookie","referer"].includes(t)&&null===t.match(/^(x-netacea-|cloudfront-)/i)}))}}]);var t,r}();function ee(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function te(e){var t=(e+"===".slice(0,(4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/");return Buffer.from(t,"base64")}var re="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0";function ne(e){return 5===e.split(".").length&&e.includes("..")}function ae(e,t){var r=S.randomBytes(12),n=S.createCipheriv("aes-256-gcm",t,r),a=Buffer.from(re,"ascii");n.setAAD(a);var i=n.update(e,"utf8");i=Buffer.concat([i,n.final()]);var o=n.getAuthTag();return[re,"",ee(r),ee(i),ee(o)].join(".")}function ie(e,t){var r=e.split(".");if(5!==r.length)throw new Error("JWE should have 5 parts, got ".concat(r.length));var n=k(r,5),a=n[0],i=n[1],o=n[2],s=n[3],c=n[4];if(a!==re)throw new Error("Incorrect JWE header");if(""!==i)throw new Error("Expected empty encrypted key for direct encryption");var u=te(o),l=te(s),h=te(c);if(12!==u.length)throw new Error("IV must be ".concat(12," bytes, got ").concat(u.length));if(16!==h.length)throw new Error("Auth tag must be ".concat(16," bytes, got ").concat(h.length));var p=S.createDecipheriv("aes-256-gcm",t,u),d=Buffer.from(a,"ascii");p.setAAD(d),p.setAuthTag(h);var f=p.update(l);return(f=Buffer.concat([f,p.final()])).toString("utf8")}var oe,se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ce={},ue={};Object.defineProperty(ue,"__esModule",{value:!0}),ue.NetaceaCookieV3IssueReason=void 0,function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session",e.UNKNOWN="unknown"}(oe||(ue.NetaceaCookieV3IssueReason=oe={}));var le={},he={},pe={};Object.defineProperty(pe,"__esModule",{value:!0}),pe.netaceaCookieV3OptionalKeyMap=pe.netaceaCookieV3KeyMap=pe.COOKIEDELIMITER=void 0,pe.COOKIEDELIMITER="_/@#/",pe.netaceaCookieV3KeyMap={clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},pe.netaceaCookieV3OptionalKeyMap={checkAllPostRequests:"fCAPR"},Object.defineProperty(he,"__esModule",{value:!0}),he.defaultInvalidResponse=he.matchNetaceaCookieV3=he.checkNetaceaCookieV3=he.objectIsNetaceaCookieV3=he.cookieIsNetaceaV3Format=he.createNetaceaCookieV3=void 0;var de=ue,fe=pe;function ve(e){if(void 0!==e&&""!==e){var t,r=e.split("&"),n={clientIP:"",userId:"",cookieId:"",gracePeriod:0,match:"0",mitigate:"0",captcha:"0",issueTimestamp:0,issueReason:"",checkAllPostRequests:void 0},a=m(r);try{var i=function(){var e,r=k(t.value.split("="),2),a=r[0],i=r[1],o=decodeURIComponent(i),s=Object.keys(fe.netaceaCookieV3KeyMap).find((function(e){return fe.netaceaCookieV3KeyMap[e]===a}));void 0===s&&(s=Object.keys(fe.netaceaCookieV3OptionalKeyMap).find((function(e){return fe.netaceaCookieV3OptionalKeyMap[e]===a}))),void 0!==(e=void 0!==s&&["match","mitigate","captcha"].includes(s)?""===o?void 0:o:""===o?void 0:Number(o))&&"string"!=typeof e&&isNaN(e)&&(e=o),n[s]=e};for(a.s();!(t=a.n()).done;)i()}catch(e){a.e(e)}finally{a.f()}return n}}function ye(){return{mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0",issueReason:de.NetaceaCookieV3IssueReason.NO_SESSION}}he.createNetaceaCookieV3=function(e){return Object.entries(e).filter((function(e){var t=k(e,2);t[0];return void 0!==t[1]})).map((function(e){var t=k(e,2),r=t[0],n=t[1];return r in fe.netaceaCookieV3OptionalKeyMap?"".concat(fe.netaceaCookieV3OptionalKeyMap[r],"=").concat(encodeURIComponent(n)):"".concat(fe.netaceaCookieV3KeyMap[r],"=").concat(encodeURIComponent(n))})).join("&")},he.cookieIsNetaceaV3Format=function(e){if(void 0===e||""===e)return!1;var t=e.split("&").map((function(e){return e.split("=")[0]})).filter((function(e){return!Object.values(fe.netaceaCookieV3OptionalKeyMap).includes(e)}));return 0!==t.length&&t.every((function(e){return Object.values(fe.netaceaCookieV3KeyMap).includes(e)}))},he.objectIsNetaceaCookieV3=function(e){if("object"!==o(e)||null===e)return!1;for(var t=0,r=Object.keys(fe.netaceaCookieV3KeyMap);t<r.length;t++){var n=r[t];if(!(n in e))return!1;if(void 0===e[n])return!1}return!0},he.checkNetaceaCookieV3=function(e,t){if(void 0===e||""===e)return ye();var r;try{r=ve(e)}catch(e){return ye()}if(void 0!==r){var n=Math.floor(Date.now()/1e3),a=r.issueTimestamp+r.gracePeriod<n,i=t===r.clientIP,o=["1","3","5","a","c","e"].includes(r.captcha),s="3"===r.mitigate;return{mitata:r,requiresReissue:a||!i,isExpired:a,shouldExpire:o||s,isSameIP:i,isPrimaryHashValid:!0,match:r.match,mitigate:r.mitigate,captcha:r.captcha,issueReason:r.issueReason}}return ye()},he.matchNetaceaCookieV3=ve,he.defaultInvalidResponse=ye;var ge={};Object.defineProperty(ge,"__esModule",{value:!0}),ge.AbstractCookieFactory=void 0;var me=ue,ke=he,be=pe,xe="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),Se=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i,Ce=function(){return d((function e(t){h(this,e),this.config=t}),[{key:"isEncrypted",value:function(e){return 5===e.split(".").length}},{key:"createCookieValue",value:(n=l(s().mark((function e(t){var r,n,a,i,o;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this.config.cookieEncryptionKey){e.next=2;break}return a=(0,ke.createNetaceaCookieV3)({clientIP:t.clientIP,userId:null!==(r=t.userId)&&void 0!==r?r:"",match:t.match,mitigate:t.mitigate,captcha:t.captcha,gracePeriod:t.gracePeriod,cookieId:t.cookieId,issueTimestamp:Math.floor(Date.now()/1e3),issueReason:null!==(n=t.issueReason)&&void 0!==n?n:me.NetaceaCookieV3IssueReason.NO_SESSION,checkAllPostRequests:t.checkAllPostRequests}),e.next=1,this.encrypt(a);case 1:case 4:return e.abrupt("return",e.sent);case 2:if(void 0!==this.config.secretKey){e.next=3;break}throw new Error("Cannot build cookie without secret key.");case 3:return i=[t.match,t.mitigate,t.captcha].join(""),o=Math.floor(Date.now()/1e3)+t.gracePeriod,e.next=4,this.buildMitataCookie(t.clientIP,t.userId,o,this.config.secretKey,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"retrieveCookieInfo",value:(r=l(s().mark((function e(t,r){var n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t&&""!==t){e.next=1;break}return e.abrupt("return",(0,ke.defaultInvalidResponse)());case 1:if(a=t,!this.isEncrypted(t)){e.next=3;break}return e.next=2,this.decrypt(t);case 2:a=e.sent;case 3:if(!(0,ke.cookieIsNetaceaV3Format)(a)){e.next=4;break}return e.abrupt("return",(0,ke.checkNetaceaCookieV3)(a,r));case 4:return e.next=5,this.checkMitataCookie(a,r,null!==(n=this.config.secretKey)&&void 0!==n?n:"");case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"buildMitataCookie",value:(t=l(s().mark((function e(t,r,n,a,i){var o,c,u,l;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=null!=r?r:this.generateUserId(),e.next=1,this.hash("".concat(t,"|").concat(String(n)),a);case 1:return c=e.sent,u=[n,o,c,i].join(be.COOKIEDELIMITER),e.next=2,this.hash(u,a);case 2:return l=e.sent,e.abrupt("return","".concat(l).concat(be.COOKIEDELIMITER).concat(u));case 3:case"end":return e.stop()}}),e,this)}))),function(e,r,n,a,i){return t.apply(this,arguments)})},{key:"checkMitataCookie",value:(e=l(s().mark((function e(t,r,n){var a,i,o,c,u,l,h,p,d,f,v;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(a=we(t))){e.next=1;break}return e.abrupt("return",(0,ke.defaultInvalidResponse)());case 1:return i=Math.floor(Date.now()/1e3),o=parseInt(a.expiry)<i,c=["1","3","5"].includes(a.captcha),u="3"===a.mitigate,l=c||u,e.next=2,this.hash("".concat(r,"|").concat(a.expiry),n);case 2:return h=e.sent,p=h===a.ipHash,d=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(be.COOKIEDELIMITER),e.next=3,this.hash(d,n);case 3:return f=e.sent,v=f===a.signature,e.abrupt("return",{mitata:a,requiresReissue:o||!p,isExpired:o,shouldExpire:l,isSameIP:p,isPrimaryHashValid:v,match:a.match,mitigate:a.mitigate,captcha:a.captcha,issueReason:me.NetaceaCookieV3IssueReason.NO_SESSION});case 4:case"end":return e.stop()}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"generateUserId",value:function(){var e=new Uint16Array((arguments.length>0&&void 0!==arguments[0]?arguments[0]:16)-1);this.getRandomValues(e);var t=Array.from(e).map((function(e){return xe[e%xe.length]})).join("");return"c".concat(t)}}]);var e,t,r,n}();function we(e){var t=e.match(Se);if(null!==t){var r=k(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}ge.AbstractCookieFactory=Ce,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NetaceaCookieV3IssueReason=e.COOKIEDELIMITER=e.netaceaCookieV3OptionalKeyMap=e.netaceaCookieV3KeyMap=e.AbstractCookieFactory=e.defaultInvalidResponse=e.objectIsNetaceaCookieV3=e.cookieIsNetaceaV3Format=e.matchNetaceaCookieV3=e.checkNetaceaCookieV3=e.createNetaceaCookieV3=void 0;var t=he;Object.defineProperty(e,"createNetaceaCookieV3",{enumerable:!0,get:function(){return t.createNetaceaCookieV3}}),Object.defineProperty(e,"checkNetaceaCookieV3",{enumerable:!0,get:function(){return t.checkNetaceaCookieV3}}),Object.defineProperty(e,"matchNetaceaCookieV3",{enumerable:!0,get:function(){return t.matchNetaceaCookieV3}}),Object.defineProperty(e,"cookieIsNetaceaV3Format",{enumerable:!0,get:function(){return t.cookieIsNetaceaV3Format}}),Object.defineProperty(e,"objectIsNetaceaCookieV3",{enumerable:!0,get:function(){return t.objectIsNetaceaCookieV3}}),Object.defineProperty(e,"defaultInvalidResponse",{enumerable:!0,get:function(){return t.defaultInvalidResponse}});var r=ge;Object.defineProperty(e,"AbstractCookieFactory",{enumerable:!0,get:function(){return r.AbstractCookieFactory}});var n=pe;Object.defineProperty(e,"netaceaCookieV3KeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3KeyMap}}),Object.defineProperty(e,"netaceaCookieV3OptionalKeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3OptionalKeyMap}}),Object.defineProperty(e,"COOKIEDELIMITER",{enumerable:!0,get:function(){return n.COOKIEDELIMITER}});var a=ue;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return a.NetaceaCookieV3IssueReason}})}(le);var Ie={};Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.validateRedirectLocation=void 0,Ie.validateRedirectLocation=function(e){if(""!==(e=null!=e?e:""))try{return new URL(e).toString()}catch(t){if(/^https?:\/\//i.test(e))return;return e.startsWith("/")?e:"/".concat(e)}};var Ae={},Oe={};function Ne(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a,i=n[r];if("cookie"===i||"Cookie"===i){var o=null!==(a=e[i])&&void 0!==a?a:"",s=Pe("string"==typeof o?o:o.join("; "),t);if(void 0!==s)return s}}}function Ee(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i,o=a[n];if("cookie"===o||"Cookie"===o){var s=null!==(i=e[o])&&void 0!==i?i:"",u="string"==typeof s?s:s.join("; ");r.push.apply(r,c(_e(u,t)))}}return r}function Pe(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).find((function(e){return e.startsWith(r)}))}function _e(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).filter((function(e){return e.startsWith(r)}))}Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.findAllInCookieString=Oe.findFirstInCookieString=Oe.findAllInHeaders=Oe.findFirstInHeaders=Oe.findOnlyValueInHeaders=Oe.findAllValuesInHeaders=Oe.findFirstValueInHeaders=void 0,Oe.findFirstValueInHeaders=function(e,t){var r=Ne(e,t);if(void 0!==r)return r.slice(t.length+1)},Oe.findAllValuesInHeaders=function(e,t){return Ee(e,t).map((function(e){return e.slice(t.length+1)}))},Oe.findOnlyValueInHeaders=function(e,t){var r,n=Ee(e,t);if(n.length>1)throw new Error("Found more than one cookie with name ".concat(t));return null===(r=n[0])||void 0===r?void 0:r.slice(t.length+1)},Oe.findFirstInHeaders=Ne,Oe.findAllInHeaders=Ee,Oe.findFirstInCookieString=Pe,Oe.findAllInCookieString=_e;var Te={};function Ke(e){return"set-cookie"===e||"Set-Cookie"===e}function Re(e,t){var r=t+"=";return e.startsWith(r)}function je(e,t){if(!Re(e,t))throw new Error("Cookie '".concat(t,"' not found in '").concat(e,"'"));return e.slice(t.length+1).split(";")[0]}function Ve(e,t){var r,n=null!==(r=e[t])&&void 0!==r?r:[];return"string"==typeof n?[n]:n}function Me(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a=n[r];if(Ke(a)){var i=He(Ve(e,a),t);if(void 0!==i)return i}}}function He(e,t){return e.map((function(e){return e.trimStart()})).find((function(e){return Re(e,t)}))}function Le(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i=a[n];if(Ke(i)){var o=Ve(e,i);r.push.apply(r,c(De(o,t)))}}return r}function De(e,t){return e.map((function(e){return e.trimStart()})).filter((function(e){return Re(e,t)}))}Object.defineProperty(Te,"__esModule",{value:!0}),Te.findAllInSetCookieStrings=Te.findAllInHeaders=Te.findValueInSetCookieStrings=Te.findFirstInSetCookieStrings=Te.findFirstInHeaders=Te.findOnlyValueInHeaders=Te.findFirstValueInHeaders=Te.parseValueFromString=void 0,Te.parseValueFromString=je,Te.findFirstValueInHeaders=function(e,t){var r=Me(e,t);return void 0!==r?je(r,t):void 0},Te.findOnlyValueInHeaders=function(e,t){var r=Le(e,t);if(r.length>1)throw new Error("Found more than one set-cookie with name ".concat(t));return void 0!==r[0]?je(r[0],t):void 0},Te.findFirstInHeaders=Me,Te.findFirstInSetCookieStrings=He,Te.findValueInSetCookieStrings=function(e,t){var r=He(e,t);if(void 0!==r)return je(r,t)},Te.findAllInHeaders=Le,Te.findAllInSetCookieStrings=De;var Be=se&&se.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Fe=se&&se.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),qe=se&&se.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&Be(t,e,r);return Fe(t,e),t};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.setCookie=Ae.cookie=void 0,Ae.cookie=qe(Oe),Ae.setCookie=qe(Te);var ze={},Ge={},Ue={};Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.KINESIS_URL=Ue.API_VERSION=Ue.REGION=Ue.PAYLOAD_TYPE=Ue.STATE=void 0,Ue.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},Ue.PAYLOAD_TYPE="string",Ue.REGION="eu-west-1",Ue.API_VERSION="2013-12-02",Ue.KINESIS_URL="https://kinesis.eu-west-1.amazonaws.com";var Je={};function Xe(){return(Xe=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e){setTimeout(e,t)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}Object.defineProperty(Je,"__esModule",{value:!0}),Je.headersToRecord=Je.increaseBatchSize=Je.handleFailedLogs=Je.batchArrayForKinesis=Je.sleep=void 0,Je.sleep=function(e){return Xe.apply(this,arguments)},Je.batchArrayForKinesis=function(e,t,r){for(var n=[],a=0;a<e.length;a+=t){var i=e.slice(a,a+t);n.push({Data:r.from(JSON.stringify(i)).toString("base64"),PartitionKey:Date.now().toString()})}return n},Je.handleFailedLogs=function(e,t,r){var n=2*r,a=[].concat(c(e),c(t)),i=a.length-n;return i>0&&(console.error("Netacea Error :: failed to send ".concat(i," log(s) to Kinesis ingest.")),a.splice(0,i)),a},Je.increaseBatchSize=function(e,t){return e!==t?Math.min(t,2*e):e},Je.headersToRecord=function(e){var t={};return e.forEach((function(e,r){t[r]=e})),t},Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.WebStandardKinesis=void 0;var We=Ue,$e=Je,Ye=function(){return d((function e(t){var r=t.deps,n=t.kinesisIngestArgs;if(h(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,void 0===n.kinesisAccessKey)throw new Error("kinesisAccessKey is required for kinesis ingest");if(void 0===n.kinesisSecretKey)throw new Error("kinesisSecretKey is required for kinesis ingest");this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(r=l(s().mark((function e(){var t,r,n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.logCache.length){e.next=1;break}return e.abrupt("return");case 1:return t=c(this.logCache),this.logCache=[],e.prev=2,r=new this.deps.AwsClient({accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey}),e.next=3,this.signRequest(r,{streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize);case 3:return n=e.sent,e.next=4,this.deps.makeRequest({headers:(0,$e.headersToRecord)(n.headers),host:We.KINESIS_URL,method:"POST",path:"/",body:n.body});case 4:this.logBatchSize=(0,$e.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.next=6;break;case 5:e.prev=5,e.catch(2),this.logCache=(0,$e.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:case"end":return e.stop()}}),e,this,[[2,5]])}))),function(){return r.apply(this,arguments)})},{key:"ingest",value:(t=l(s().mark((function e(t){var r,n,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.next=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,$e.sleep)(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(r);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,n=(0,$e.sleep)(1e3*this.maxLogAgeSeconds).then(l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:case"end":return e.stop()}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.next=3;break}return e.next=3,n;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"signRequest",value:(e=l(s().mark((function e(t,r,n,a){var i,o;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={Records:(0,$e.batchArrayForKinesis)(n,a,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:r.streamName},e.next=1,t.sign(We.KINESIS_URL,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"}});case 1:return o=e.sent,e.abrupt("return",o);case 2:case"end":return e.stop()}}),e,this)}))),function(t,r,n,a){return e.apply(this,arguments)})}]);var e,t,r}();Ge.WebStandardKinesis=Ye;var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.Kinesis=void 0;var Ze=Ue,et=Je,tt=function(){return d((function e(t){var r=t.deps,n=t.kinesisIngestArgs;h(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=l(s().mark((function e(){var t,r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.logCache.length){e.next=1;break}return e.abrupt("return");case 1:if(t=c(this.logCache),this.logCache=[],e.prev=2,"POST"===(a=this.signRequest({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize)).method){e.next=3;break}throw new Error("Unexpected method. Expected POST but got ".concat(a.method));case 3:return e.next=4,this.deps.makeRequest({headers:null!==(r=a.headers)&&void 0!==r?r:{},host:"https://".concat(a.hostname),method:a.method,path:null!==(n=a.path)&&void 0!==n?n:"/",body:a.body});case 4:this.logBatchSize=(0,et.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.next=6;break;case 5:e.prev=5,e.catch(2),this.logCache=(0,et.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:case"end":return e.stop()}}),e,this,[[2,5]])}))),function(){return t.apply(this,arguments)})},{key:"ingest",value:(e=l(s().mark((function e(t){var r,n,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.next=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,et.sleep)(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(r);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,n=(0,et.sleep)(1e3*this.maxLogAgeSeconds).then(l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:case"end":return e.stop()}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.next=3;break}return e.next=3,n;case 3:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"signRequest",value:function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:(0,et.batchArrayForKinesis)(t,r,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:e.streamName};return this.deps.aws4.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:Ze.REGION},{accessKeyId:n,secretAccessKey:a})}}]);var e,t}();Qe.Kinesis=tt,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Kinesis=e.WebStandardKinesis=void 0;var t=Ge;Object.defineProperty(e,"WebStandardKinesis",{enumerable:!0,get:function(){return t.WebStandardKinesis}});var r=Qe;Object.defineProperty(e,"Kinesis",{enumerable:!0,get:function(){return r.Kinesis}})}(ze);var rt={};function nt(e,t){var r=null;if("number"==typeof e)r=e;else if("string"==typeof e){var n=parseFloat(e);isNaN(n)||(r=n)}if(null===r){if("number"!=typeof t.defaultValue)return t.defaultValue;r=t.defaultValue}return void 0!==t.minValue&&(r=Math.max(t.minValue,r)),void 0!==t.maxValue&&(r=Math.min(t.maxValue,r)),r}Object.defineProperty(rt,"__esModule",{value:!0}),rt.parseHttpHeaderName=rt.stringOrDefault=rt.parseIntOrDefault=rt.parseNumberOrDefault=void 0,rt.parseNumberOrDefault=nt,rt.parseIntOrDefault=function(e,t){var r=nt(e,t);return"number"==typeof r?Math.floor(r):r},rt.stringOrDefault=function(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t},rt.parseHttpHeaderName=function(e){if("string"==typeof e){return/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(e)?e:void 0}};var at={};Object.defineProperty(at,"__esModule",{value:!0}),at.searchParamsFromRecord=void 0,at.searchParamsFromRecord=function(e){for(var t=new URLSearchParams,r=0,n=Object.entries(e);r<n.length;r++){var a=k(n[r],2),i=a[0],o=a[1];t.append(i,o)}return t};var it={},ot={};Object.defineProperty(ot,"__esModule",{value:!0}),ot.JweFactory=void 0;var st=function(){return d((function e(t){h(this,e),this.jose=t}),[{key:"encrypt",value:(t=l(s().mark((function e(t,r){var n,a,i,o,c=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>2&&void 0!==c[2]?c[2]:"A128CBC-HS256",a=this.jose.base64url.decode(r),i=(new TextEncoder).encode(t),e.next=1,new this.jose.CompactEncrypt(i).setProtectedHeader({alg:"dir",enc:n}).encrypt(a);case 1:return o=e.sent,e.abrupt("return",o);case 2:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"decrypt",value:(e=l(s().mark((function e(t,r){var n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.jose.base64url.decode(r),e.next=1,this.jose.compactDecrypt(t,n,{keyManagementAlgorithms:["dir"],contentEncryptionAlgorithms:["A256GCM","A128CBC-HS256"]});case 1:return a=e.sent,i=a.plaintext,e.abrupt("return",(new TextDecoder).decode(i));case 2:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}],[{key:"isJweEncrypted",value:function(e){return 5===e.split(".").length&&e.includes("..")}}]);var e,t}();ot.JweFactory=st;var ct=se&&se.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),ut=se&&se.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),lt=se&&se.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&ct(t,e,r);return ut(t,e),t};Object.defineProperty(it,"__esModule",{value:!0}),it.jwe=void 0,it.jwe=lt(ot);var ht,pt={};var dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.RequestView=dt.AbstractRequestView=void 0;var ft=rt,vt=function(){return d((function e(){h(this,e)}),[{key:"contentLength",get:function(){var e;return(0,ft.parseIntOrDefault)(null===(e=this.readHeader("content-length"))||void 0===e?void 0:e[0],{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"userAgent",get:function(){var e,t;return null!==(e=null===(t=this.readHeader("user-agent"))||void 0===t?void 0:t[0])&&void 0!==e?e:""}},{key:"contentType",get:function(){var e;return null===(e=this.readHeader("content-type"))||void 0===e?void 0:e[0]}},{key:"xForwardedFor",get:function(){var e;return null===(e=this.readHeader("x-forwarded-for"))||void 0===e?void 0:e[0]}},{key:"referer",get:function(){var e;return null===(e=this.readHeader("referer"))||void 0===e?void 0:e[0]}},{key:"accept",get:function(){var e;return null===(e=this.readHeader("accept"))||void 0===e?void 0:e[0]}},{key:"host",get:function(){var e;return null===(e=this.readHeader("host"))||void 0===e?void 0:e[0]}},{key:"getHttpMessageSignatureFields",value:(e=l(s().mark((function e(){var t,r,n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(t=this.readJoinedHeader("Signature"))){e.next=1;break}r=void 0,e.next=3;break;case 1:return e.next=2,this.sha256Hash(t);case 2:r=e.sent.toLowerCase().slice(0,12);case 3:return n=r,a=this.readJoinedHeader("Signature-Input"),i=this.readJoinedHeader("Signature-Agent"),e.abrupt("return",{httpMsgSigSha256:n,httpMsgSigInput:a,httpMsgSigAgent:i});case 4:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"readJoinedHeader",value:function(e){var t=this.readHeader(e).join(",");return""!==t?t:void 0}}]);var e}();dt.AbstractRequestView=vt;var yt=function(){function t(r,n){var a;return h(this,t),(a=e(this,t)).request=r,a.sha256Digest=n,a}return a(t,vt),d(t,[{key:"method",get:function(){return this.request.method}},{key:"url",get:function(){return new URL(this.request.url)}},{key:"getBody",value:(n=l(s().mark((function e(){var t,r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this._body){e.next=5;break}return e.next=1,this.request.clone().text();case 1:if(n=t=e.sent,!(r=null!==n)){e.next=2;break}r=void 0!==t;case 2:if(!r){e.next=3;break}a=t,e.next=4;break;case 3:a="";case 4:this._body=a;case 5:return e.abrupt("return",this._body);case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"readHeader",value:function(e){var t,r=null!==(t=this.request.headers.get(e))&&void 0!==t?t:void 0;return void 0!==r?[r]:[]}},{key:"sha256Hash",value:(r=l(s().mark((function e(t){var r,n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(new TextEncoder).encode(t),e.next=1,this.sha256Digest.digest("SHA-256",r);case 1:return n=e.sent,e.abrupt("return",Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})}]);var r,n}();dt.RequestView=yt;var gt={};Object.defineProperty(gt,"__esModule",{value:!0}),gt.ProtectorApiResponseView=gt.AbstractProtectorApiResponseView=void 0;var mt=rt,kt=function(){return d((function e(){h(this,e)}),[{key:"redirectHost",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-host"))||void 0===e?void 0:e[0]}},{key:"redirectLocation",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-location"))||void 0===e?void 0:e[0]}},{key:"redirectStatus",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0]}},{key:"redirectStatusCode",get:function(){var e,t=null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0];if(void 0!==t){var r=(0,mt.parseIntOrDefault)(t,{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER});return r>=300&&r<400?r:void 0}}},{key:"eventId",get:function(){var e;return null===(e=this.readHeader("x-netacea-event-id"))||void 0===e?void 0:e[0]}},{key:"sessionCookieMaxAge",get:function(){var e;return(0,mt.parseIntOrDefault)(null===(e=this.readHeader("x-netacea-mitata-expiry"))||void 0===e?void 0:e[0],{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"captchaCookieMaxAge",get:function(){var e,t=null===(e=this.readHeader("x-netacea-mitatacaptcha-expiry"))||void 0===e?void 0:e[0];return(0,mt.parseIntOrDefault)(t,{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"getProtectorCodes",value:function(e){var t,r,n,a,i,o,s,c,u;return{match:null!==(t=null!==(r=null===(n=this.readHeader("x-netacea-match"))||void 0===n?void 0:n[0])&&void 0!==r?r:null==e?void 0:e.match)&&void 0!==t?t:"0",mitigate:null!==(a=null!==(i=null===(o=this.readHeader("x-netacea-mitigate"))||void 0===o?void 0:o[0])&&void 0!==i?i:null==e?void 0:e.mitigate)&&void 0!==a?a:"0",captcha:null!==(s=null!==(c=null===(u=this.readHeader("x-netacea-captcha"))||void 0===u?void 0:u[0])&&void 0!==c?c:null==e?void 0:e.captcha)&&void 0!==s?s:"0"}}},{key:"getMonetisationRedirectLocation",value:function(e,t){var r=this.redirectLocation;if(void 0!==r)return r;var n=this.redirectHost;if(void 0!==n){var a=new URL("https://".concat(n));return a.pathname=e,a.search=t,a.toString()}}},{key:"getMonetisationRedirect",value:function(e,t){var r,n=this.getMonetisationRedirectLocation(e,t);if(void 0!==n)return{location:n,statusCode:null!==(r=this.redirectStatusCode)&&void 0!==r?r:303}}},{key:"getCaptchaJson",value:(e=l(s().mark((function e(t,r){var n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getBody();case 1:if(n=e.sent,void 0===(a=this.eventId)&&"string"==typeof n&&(i=JSON.parse(n),a=Ct(i)),void 0!==a){e.next=2;break}throw new Error("Could not resolve Tracking ID for captcha event.");case 2:return e.abrupt("return",St(t,r,a));case 3:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e}();gt.AbstractProtectorApiResponseView=kt;var bt,xt=function(){function t(r){var n;return h(this,t),(n=e(this,t)).response=r,n}return a(t,kt),d(t,[{key:"status",get:function(){return this.response.status}},{key:"getBody",value:(r=l(s().mark((function e(){var t,r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this._body){e.next=5;break}return e.next=1,this.response.clone().text();case 1:if(n=t=e.sent,!(r=null!==n)){e.next=2;break}r=void 0!==t;case 2:if(!r){e.next=3;break}a=t,e.next=4;break;case 3:a="";case 4:this._body=a;case 5:return e.abrupt("return",this._body);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"readHeader",value:function(e){var t;if("set-cookie"===(e=e.toLowerCase()))return this.response.headers.getSetCookie();var r=null!==(t=this.response.headers.get(e))&&void 0!==t?t:void 0;return void 0!==r?[r]:[]}}]);var r}();function St(e,t,r){var n="".concat(e,"?trackingId=").concat(r),a=void 0!==t?"https://".concat(t).concat(n):void 0;return JSON.stringify({captchaRelativeURL:n,captchaAbsoluteURL:a})}function Ct(e){if(null==e||"object"!==o(e))throw new Error("Response body is not a valid object!");var t=e.trackingId;if("string"!=typeof t||0===t.length)throw new Error("Response body does not contain a valid trackingId!");return t}function wt(){return bt||(bt=1,function(e){var t=se&&se.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=se&&se.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=se&&se.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&t(n,e,a);return r(n,e),n},i=se&&se.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.graphql=e.webcrypto=e.url=e.parsing=e.ingest=e.headers=e.configValidation=e.cookie=e.NetaceaCookieV3IssueReason=void 0;var s=ue;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return s.NetaceaCookieV3IssueReason}}),e.cookie=a(le),e.configValidation=a(Ie),e.headers=a(Ae),e.ingest=a(ze),e.parsing=a(rt),e.url=a(at),e.webcrypto=a(it),e.graphql=a(function(){if(ht)return pt;ht=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.truncateLongFields=pt.parseGraphQl=pt.parseGraphQlRequestBody=pt.getGraphQLParserConfig=void 0;var e=wt();function t(e,t){var r,n,a=e.parserRegex;return null!==(r=null===(n=t.match(a))||void 0===n?void 0:n.groups)&&void 0!==r?r:{}}function r(e,t){for(var r,n,a=e.maxValueLength,i=0,o=Object.keys(t);i<o.length;i++){var s=o[i],c=t[s];t[s]=(n=a,(r=c).length<=n?r:r.slice(0,n)+"…")}return t}return pt.getGraphQLParserConfig=function(t){var r={includePaths:[],maxParsableBytes:e.parsing.parseIntOrDefault(null==t?void 0:t.maxParsableBytes,{defaultValue:1e6,minValue:1e3}),maxValueLength:e.parsing.parseIntOrDefault(null==t?void 0:t.maxValueLength,{defaultValue:256,minValue:8}),parserRegex:n(/^\s*(query|mutation|subscription)\s+([_A-Za-z][_0-9A-Za-z]+)?/,{OpType:1,OpName:2})};if(Array.isArray(null==t?void 0:t.includePaths)){var a,i=m(t.includePaths);try{for(i.s();!(a=i.n()).done;){var s=a.value;"string"==typeof s&&r.includePaths.push(s)}}catch(e){i.e(e)}finally{i.f()}}try{if((null==t?void 0:t.parserRegex)instanceof RegExp)r.parserRegex=null==t?void 0:t.parserRegex;else if("object"===o(null==t?void 0:t.parserRegex)){var c=null==t?void 0:t.parserRegex,u=c.regex,l=c.flags;"string"==typeof u&&(r.parserRegex=new RegExp(u,l))}}catch(e){}return r},pt.parseGraphQlRequestBody=function(e,n){var a,i;if(""===n)throw new Error("Netacea Error: Empty GraphQL body received");var s=JSON.parse(n);if("object"!==o(s))throw new Error("Netacea Error: Invalid GraphQL JSON");var c=v({},t(e,null!==(a=null==s?void 0:s.query)&&void 0!==a?a:"")),u=(null!==(i=null==s?void 0:s.operationName)&&void 0!==i?i:"").trim();return""!==u&&(c.OpName=u),r(e,c)},pt.parseGraphQl=t,pt.truncateLongFields=r,pt}()),i(dt,e),i(gt,e)}(ce)),ce}gt.ProtectorApiResponseView=xt;var It=wt(),At=function(){function t(r,n){var a;return h(this,t),y(a=e(this,t,[void 0===n?v(v({},r),{},{cookieEncryptionKey:void 0}):r]),"encryptionKeyBuffer",void 0),a.encryptionKeyBuffer=n,a}return a(t,It.cookie.AbstractCookieFactory),d(t,[{key:"encrypt",value:(i=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.encryptionKeyBuffer){e.next=1;break}throw new Error("F5CookieFactory.encrypt called without a configured encryption key");case 1:return e.abrupt("return",ae(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"decrypt",value:(n=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.encryptionKeyBuffer){e.next=1;break}throw new Error("F5CookieFactory.decrypt called without a configured encryption key");case 1:return e.abrupt("return",ie(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"hash",value:(r=l(s().mark((function e(t,r){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=S.createHmac("sha256",r)).update(t),e.abrupt("return",C.Buffer.from(n.digest("hex")).toString("base64"));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})},{key:"getRandomValues",value:function(e){return crypto.getRandomValues(e)}},{key:"isEncrypted",value:function(e){return ne(e)}}]);var r,n,i}(),Ot={},Nt={},Et={},Pt={};Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.API_VERSION=Pt.REGION=Pt.PAYLOAD_TYPE=Pt.STATE=void 0,Pt.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},Pt.PAYLOAD_TYPE="string",Pt.REGION="eu-west-1",Pt.API_VERSION="2013-12-02",Object.defineProperty(Et,"__esModule",{value:!0}),Et.signRequest=void 0;var _t=A,Tt=Pt;function Kt(e,t){for(var r=[],n=0;n<e.length;n+=t){var a=e.slice(n,n+t);r.push({Data:Buffer.from(JSON.stringify(a)).toString("base64"),PartitionKey:Date.now().toString()})}return r}Et.signRequest=function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:Kt(t,r),PartitionKey:Date.now().toString(),StreamName:e.streamName};return _t.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:Tt.REGION},{accessKeyId:n,secretAccessKey:a})},Object.defineProperty(Nt,"__esModule",{value:!0});var Rt=Et;function jt(e){return Vt.apply(this,arguments)}function Vt(){return(Vt=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e){setTimeout(e,t)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Mt=function(){return d((function e(t){var r=t.kinesisStreamName,n=t.kinesisAccessKey,a=t.kinesisSecretKey,i=t.maxLogAgeSeconds,o=t.logBatchSize,s=t.rampUpBatchSize,c=t.maxAwaitTimePerIngestCallMs;h(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.kinesisStreamName=r,this.kinesisAccessKey=n,this.kinesisSecretKey=a,this.maxAwaitTimePerIngestCallMs=c,void 0!==i&&i<this.maxLogAgeSeconds&&i>0&&(this.maxLogAgeSeconds=i),void 0!==o&&(this.maxLogBatchSize=o),this.logBatchSize=!0===s?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=l(s().mark((function e(t){var r,n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.logCache.length){e.next=1;break}return e.abrupt("return");case 1:return r=c(this.logCache),this.logCache=[],e.prev=2,n=(0,Rt.signRequest)({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},r,this.logBatchSize),e.next=3,t({headers:n.headers,host:"https://".concat(n.hostname),method:n.method,path:n.path,body:n.body});case 3:this.logBatchSize!==this.maxLogBatchSize&&(this.logBatchSize=Math.min(this.maxLogBatchSize,2*this.logBatchSize)),e.next=5;break;case 4:e.prev=4,i=e.catch(2),(a=this.logCache).push.apply(a,c(r)),console.error(i);case 5:case"end":return e.stop()}}),e,this,[[2,4]])}))),function(e){return t.apply(this,arguments)})},{key:"ingest",value:(e=l(s().mark((function e(t,r){var n,a,i=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.next=2;break}return(n=[]).push(this.putToKinesis(r)),void 0!==this.maxAwaitTimePerIngestCallMs&&n.push(jt(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(n);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,a=jt(1e3*this.maxLogAgeSeconds).then(l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,i.putToKinesis(r);case 1:i.intervalSet=!1;case 2:case"end":return e.stop()}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.next=3;break}return e.next=3,a;case 3:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t}();Nt.default=Mt,Object.defineProperty(Ot,"__esModule",{value:!0});var Ht,Lt=Nt,Dt=Ot.default=Lt.default,Bt={subtle:{digest:(Ht=l(s().mark((function e(t,r){var n,a,i,o,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=null!==(n={"SHA-256":"sha256","SHA-1":"sha1","SHA-384":"sha384","SHA-512":"sha512"}[t])&&void 0!==n?n:t.toLowerCase().replace("-",""),i=r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),o=new Uint8Array(i),c=_.createHash(a).update(o).digest(),e.abrupt("return",c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return Ht.apply(this,arguments)})}},Ft=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,qt=/^\/[a-zA-Z0-9/]*$/;function zt(e,t,r){return void 0!==r&&""!==r&&(function(e){var t=e,r=t.indexOf("//");if(-1!==r){var n=(t=t.substring(r+2)).indexOf("/");if(-1===n)return"/";t=t.substring(n)}var a=t.indexOf("?");return-1!==a&&(t=t.substring(0,a)),t}(e)===r&&"get"===t.toLowerCase())}function Gt(e){var t=function(e,t){var r=e.indexOf("?");if(-1!==r)for(var n=e.substring(r+1).split("&"),a=0;a<n.length;a++){var i=n[a].split("=");if(i[0]===t)return void 0!==i[1]?decodeURIComponent(i[1]):void 0}}(e,"trackingId");return void 0!==t&&Ft.test(t)?t:null}function Ut(e){if(void 0===e)return"text/html";var t=e.toLowerCase(),r=t.includes("text/html")||t.includes("application/html"),n=t.includes("application/json");return!r&&n?"application/json":"text/html"}function Jt(e,t,r){if(void 0===e||""===e)return"";var n;try{n=JSON.parse(e)}catch(e){return""}if(!function(e){if(null==e)return!1;var t=e;return void 0!==t.captchaSiteKey&&void 0!==t.trackingId&&void 0!==t.captchaURL}(n))return"";var a=r+"?trackingId="+n.trackingId,i="https://"+t+a;return JSON.stringify({captchaRelativeURL:a,captchaAbsoluteURL:i})}var Xt=Q.cookie.attributes.configureCookiesDomain,Wt=Q.cookie.netaceaSession,$t=Wt.createNetaceaSetCookieString,Yt=Wt.createNetaceaCaptchaSetCookieString,Qt=function(){return d((function e(t){var r,n,a=t.apiKey,i=t.secretKey,o=t.timeout,s=void 0===o?3e3:o,c=t.mitigationServiceUrl,u=void 0===c?"https://mitigations.netacea.net":c,l=t.ingestServiceUrl,p=void 0===l?"https://ingest.netacea.net":l,d=t.mitigationType,f=void 0===d?E.INGEST:d,g=t.captchaSiteKey,m=t.captchaSecretKey,k=t.ingestType,b=void 0===k?N.HTTP:k,x=t.kinesis,S=t.mitataCookieExpirySeconds,C=t.netaceaCookieExpirySeconds,w=t.netaceaCookieName,I=t.netaceaCaptchaCookieName,A=t.netaceaCookieAttributes,O=t.netaceaCaptchaCookieAttributes;if(h(this,e),y(this,"mitataCookieExpirySeconds",void 0),y(this,"apiKey",void 0),y(this,"secretKey",void 0),y(this,"mitigationServiceUrl",void 0),y(this,"ingestServiceUrl",void 0),y(this,"timeout",void 0),y(this,"captchaSiteKey",void 0),y(this,"captchaSecretKey",void 0),y(this,"ingestType",void 0),y(this,"kinesis",void 0),y(this,"mitigationType",void 0),y(this,"encryptedCookies",[]),y(this,"netaceaCookieName",void 0),y(this,"netaceaCaptchaCookieName",void 0),y(this,"netaceaCookieAttributes",void 0),y(this,"netaceaCaptchaCookieAttributes",void 0),y(this,"cookieFactory",void 0),null==a)throw new Error("apiKey is a required parameter");this.apiKey=a,this.secretKey=i,this.mitigationServiceUrl=u,this.ingestServiceUrl=p,this.mitigationType=f,this.ingestType=null!=b?b:N.HTTP,this.ingestType===N.KINESIS&&(void 0===x?console.warn("NETACEA WARN: no kinesis args provided, when ingestType is ".concat(this.ingestType)):this.kinesis=new Dt(v(v({},x),{},{apiKey:this.apiKey}))),void 0===g&&void 0===m||(this.captchaSiteKey=g,this.captchaSecretKey=m),this.timeout=function(e){return e<=0?R:e}(s),this.netaceaCookieName=tr(w,"_mitata"),this.netaceaCaptchaCookieName=tr(I,"_mitatacaptcha"),this.encryptedCookies=[this.netaceaCookieName,this.netaceaCaptchaCookieName],this.mitataCookieExpirySeconds=function(e,t){return void 0===t?e===E.INGEST?3600:60:t}(f,null!=C?C:S);var P=Xt(null!=A?A:"",null!=O?O:"");this.netaceaCookieAttributes=null!==(r=P.cookieAttributes)&&void 0!==r?r:"",this.netaceaCaptchaCookieAttributes=null!==(n=P.captchaCookieAttributes)&&void 0!==n?n:""}),[{key:"runMitigation",value:(S=l(s().mark((function e(t){var r,n,a,i,o;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,i=this.mitigationType,e.next=i===E.MITIGATE?1:i===E.INJECT?3:i===E.INGEST?5:7;break;case 1:return e.next=2,this.mitigate(t);case 2:case 4:case 6:return e.abrupt("return",e.sent);case 3:return e.next=4,this.inject(t);case 5:return e.next=6,this.processIngest(t);case 7:throw new Error("Netacea Error: Mitigation type ".concat(this.mitigationType," not recognised"));case 8:e.next=10;break;case 9:return e.prev=9,o=e.catch(0),console.error("Netacea FAILOPEN Error:",o),r=t,n=this.isUrlCaptchaPost(r.url,r.method),a=this.mitigationType===E.MITIGATE,e.abrupt("return",{injectHeaders:{"x-netacea-captcha":"0","x-netacea-match":"0","x-netacea-mitigate":"0"},sessionStatus:a&&n?"error_open":""});case 10:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(e){return S.apply(this,arguments)})},{key:"readCookie",value:(x=l(s().mark((function e(t,r){var n,a,i,o,c,u,l;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=r){e.next=1;break}return e.abrupt("return",void 0);case 1:if("string"!=typeof r){e.next=3;break}return e.next=2,this.readCookie(t,r.split(";"));case 2:return e.abrupt("return",e.sent);case 3:n="".concat(t,"="),a=m(r),e.prev=4,a.s();case 5:if((i=a.n()).done){e.next=11;break}if(o=i.value,!(c=o.split(";")[0].trimStart()).startsWith(n)){e.next=10;break}if(u=c.slice(n.length),!this.encryptedCookies.includes(t)){e.next=9;break}return e.prev=6,e.next=7,this.decryptCookieValue(u);case 7:return e.abrupt("return",e.sent);case 8:return e.prev=8,e.catch(6),e.abrupt("return",void 0);case 9:return e.abrupt("return",u);case 10:e.next=5;break;case 11:e.next=13;break;case 12:e.prev=12,l=e.catch(4),a.e(l);case 13:return e.prev=13,a.f(),e.finish(13);case 14:return e.abrupt("return",void 0);case 15:case"end":return e.stop()}}),e,this,[[4,12,13,14],[6,8]])}))),function(e,t){return x.apply(this,arguments)})},{key:"callIngest",value:(b=l(s().mark((function e(t){var r,n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.constructWebLog(t),this.ingestType!==N.KINESIS){e.next=5;break}if(void 0!==this.kinesis){e.next=1;break}return console.error("Netacea Error: Unable to log as Kinesis has not been defined."),e.abrupt("return");case 1:return e.prev=1,e.next=2,this.kinesis.ingest(v(v({},r),{},{apiKey:this.apiKey}),this.makeRequest.bind(this));case 2:e.next=4;break;case 3:e.prev=3,i=e.catch(1),console.error("NETACEA Error: ",i.message);case 4:e.next=7;break;case 5:return n={"X-Netacea-API-Key":this.apiKey,"content-type":"application/json"},e.next=6,this.makeIngestApiCall(n,r);case 6:if(200===(a=e.sent).status){e.next=7;break}throw this.APIError(a);case 7:case"end":return e.stop()}}),e,this,[[1,3]])}))),function(e){return b.apply(this,arguments)})},{key:"makeIngestApiCall",value:(k=l(s().mark((function e(t,r){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.makeRequest({host:this.ingestServiceUrl,method:"POST",path:"/",headers:t,body:JSON.stringify(r),timeout:this.timeout});case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"constructV1WebLog",value:function(e){var t=e.ip,r=e.userAgent,n=e.status,a=e.method,i=e.path,o=e.protocol,s=e.referer,c=e.bytesSent,u=e.requestTime,l=e.mitataCookie,h=e.sessionStatus,p=e.integrationType,d=e.integrationVersion,f=e.headerFingerprint,v=(new Date).toUTCString();return{Request:"".concat(a," ").concat(i," ").concat(o),TimeLocal:v,RealIp:t,UserAgent:r,Status:n,RequestTime:null==u?void 0:u.toString(),BytesSent:null==c?void 0:c.toString(),Referer:""===s?"-":s,NetaceaUserIdCookie:null!=l?l:"",NetaceaMitigationApplied:null!=h?h:"",IntegrationType:null!=p?p:"",IntegrationVersion:null!=d?d:"",HeaderHash:null!=f?f:""}}},{key:"constructWebLog",value:function(e){return e.bytesSent=""===e.bytesSent?"0":e.bytesSent,this.constructV1WebLog(e)}},{key:"check",value:(g=l(s().mark((function e(t,r,n,a,i,o,c){var u,l,h,p,d,f,y,g,m,k,b,x,S,C,w;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this.cookieFactory){e.next=2;break}return e.next=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:C=e.sent,e.next=3;break;case 2:C=J(t,r,null!==(u=this.secretKey)&&void 0!==u?u:"");case 3:if((k=C).isPrimaryHashValid&&!k.requiresReissue){e.next=6;break}return b=void 0!==k.mitata?k.mitata.userId:void 0,x=er(k),e.next=4,this.makeMitigateAPICall(b,r,n,a,i,o,x);case 4:return S=e.sent,l=S.status,h=S.match,p=S.mitigate,d=S.captcha,f=S.body,e.next=5,this.createMitata(r,b,h,p,d,S.mitataMaxAge,void 0,x);case 5:w=e.sent,y=[w],g=S.eventId,"5"===p&&void 0!==c&&(m=this.computeMonetisationRedirect(c,S.redirectHost,S.redirectLocation,S.redirectStatus)),e.next=7;break;case 6:l=-1,h=k.match,p=k.mitigate,d=k.captcha,f=void 0,y=[];case 7:return e.abrupt("return",v(v({},this.composeResult(f,y,l,h,p,d,!1,g)),{},{redirect:m}));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a,i,o){return g.apply(this,arguments)})},{key:"computeMonetisationRedirect",value:function(e,t,r,n){var a=void 0!==n?parseInt(n,10):NaN,i=!isNaN(a)&&a>=300&&a<400?a:303;if(void 0!==r)return{location:r,statusCode:i};if(void 0!==t){var o=e.replace(/^https?:\/\/[^/]+/,"");return{location:"https://".concat(t).concat(""!==o?o:"/"),statusCode:i}}}},{key:"createMitata",value:(f=l(s().mark((function e(t,r,n,a,i){var o,c,u,l,h,p,d,f,v,y,g=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=g.length>5&&void 0!==g[5]?g[5]:86400,c=g.length>6&&void 0!==g[6]?g[6]:void 0,u=g.length>7&&void 0!==g[7]?g[7]:P.NO_SESSION,l=["1","3","5"].includes(i),h="3"===a,p="5"===a,d=l||h||p?-60:this.mitataCookieExpirySeconds,void 0===this.cookieFactory){e.next=2;break}return e.next=1,this.cookieFactory.createCookieValue({clientIP:t,userId:r,match:n,mitigate:a,captcha:i,gracePeriod:d,cookieId:z(),issueReason:u});case 1:f=e.sent,e.next=4;break;case 2:if(void 0!==this.secretKey){e.next=3;break}throw new Error("Cannot build cookie without secret key.");case 3:v=null!=c?c:Math.floor(Date.now()/1e3)+d,y=[n,a,i].join(""),f=G(t,r,v,this.secretKey,y);case 4:return e.abrupt("return",$t({cookieName:this.netaceaCookieName,cookieValue:f,maxAgeAttribute:String(o),otherAttributes:this.netaceaCookieAttributes}));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return f.apply(this,arguments)})},{key:"processCaptcha",value:(p=l(s().mark((function e(t,r,n,a,i){var o,c,u,l,h,p,d,f,v,y;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this.cookieFactory){e.next=2;break}return e.next=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:y=e.sent,e.next=3;break;case 2:y=J(t,r,null!==(o=this.secretKey)&&void 0!==o?o:"");case 3:return c=er(y),e.next=4,this.makeCaptchaAPICall(t,r,n,a,i,c);case 4:return u=e.sent,l=u.status,h=u.match,p=u.mitigate,d=u.captcha,f=u.body,v=u.setCookie,e.abrupt("return",this.composeResult(f,v,l,h,p,d,!0));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return p.apply(this,arguments)})},{key:"getMitataCaptchaFromHeaders",value:(u=l(s().mark((function e(t){var r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Object.prototype.hasOwnProperty.call(t,L.netaceaHeaders.mitataCaptcha)){e.next=3;break}if(r=t[L.netaceaHeaders.mitataCaptcha],Array.isArray(r)&&(r=r[0]),null!=r&&""!==r){e.next=1;break}return e.abrupt("return",void 0);case 1:return n=parseInt(t[L.netaceaHeaders.mitataCaptchaExpiry]),e.next=2,this.encryptCookieValue(r);case 2:return a=e.sent,e.abrupt("return",Yt({cookieName:this.netaceaCaptchaCookieName,cookieValue:a,maxAgeAttribute:String(isNaN(n)?86400:n),otherAttributes:this.netaceaCaptchaCookieAttributes}));case 3:return e.abrupt("return",void 0);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"makeCaptchaAPICall",value:(c=l(s().mark((function e(t,r,n,a,i){var o,c,u,l,h,p=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=p.length>5&&void 0!==p[5]?p[5]:P.NO_SESSION,c={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},void 0!==(u=q(t))&&(c["X-Netacea-UserId"]=u.userId),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(c["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,c["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),l={},"string"==typeof i&&""!==i&&(l.headerFP=i),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/AtaVerifyCaptcha",headers:c,method:"POST",body:a,timeout:this.timeout,params:l});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,null==u?void 0:u.userId,r,o);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return c.apply(this,arguments)})},{key:"getApiCallResponseFromResponse",value:(o=l(s().mark((function e(t,r,n){var a,i,o,c,u,l,h,p,d,f,v,y,g,m,k,b,x,S,C,w,I,A,O=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f=O.length>3&&void 0!==O[3]?O[3]:P.NO_SESSION,200===t.status){e.next=1;break}throw this.APIError(t);case 1:return v=null!==(a=null===(i=t.headers[L.netaceaHeaders.match])||void 0===i?void 0:i.toString())&&void 0!==a?a:"0",y=null!==(o=null===(c=t.headers[L.netaceaHeaders.mitigate])||void 0===c?void 0:c.toString())&&void 0!==o?o:"0",g=null!==(u=null===(l=t.headers[L.netaceaHeaders.captcha])||void 0===l?void 0:l.toString())&&void 0!==u?u:"0",m=parseInt(t.headers[L.netaceaHeaders.mitataExpiry]),isNaN(m)&&(m=86400),e.next=2,this.createMitata(n,r,v,y,g,86400,void 0,f);case 2:return k=e.sent,e.next=3,this.getMitataCaptchaFromHeaders(t.headers);case 3:return b=e.sent,x=[k,b].filter((function(e){return void 0!==e})),S=t.body,C=t.headers[L.netaceaHeaders.eventId],w=null===(h=t.headers["x-netacea-redirect-host"])||void 0===h?void 0:h.toString(),I=null===(p=t.headers["x-netacea-redirect-location"])||void 0===p?void 0:p.toString(),A=null===(d=t.headers["x-netacea-redirect-status"])||void 0===d?void 0:d.toString(),e.abrupt("return",{status:t.status,match:v,mitigate:y,captcha:g,setCookie:x,body:S,eventId:C,mitataMaxAge:m,redirectHost:w,redirectLocation:I,redirectStatus:A});case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"buildCookieHeader",value:function(e){var t="",r="";for(var n in e){var a=e[n];void 0!==a&&(t="".concat(t).concat(r).concat(n,"=").concat(a),r="; ")}return t}},{key:"makeMitigateAPICall",value:(i=l(s().mark((function e(t,r,n,a,i,o){var c,u,l,h,p=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=p.length>6&&void 0!==p[6]?p[6]:P.NO_SESSION,u={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,cookie:this.buildCookieHeader({_mitatacaptcha:a})},void 0!==t&&(u["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(u["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,u["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),void 0!==o&&(u["X-Netacea-Captcha-Content-Type"]=o),l={},"string"==typeof i&&""!==i&&(l.headerFP=i),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/",headers:u,method:"GET",timeout:this.timeout,params:l});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,t,r,c);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a,o){return i.apply(this,arguments)})},{key:"composeResult",value:function(e,t,r,n,a,i,o,s){var c=this.findBestMitigation(n,a,i,o),u={body:e,apiCallStatus:r,setCookie:t,sessionStatus:c.sessionStatus,mitigation:c.mitigation,mitigated:[L.mitigationTypes.block,L.mitigationTypes.captcha,L.mitigationTypes.captchaPass].includes(c.mitigation)};if(this.mitigationType===E.INJECT){var l={"x-netacea-match":c.parts.match.toString(),"x-netacea-mitigate":c.parts.mitigate.toString(),"x-netacea-captcha":c.parts.captcha.toString()};void 0!==s&&(l["x-netacea-event-id"]=s),u.injectHeaders=l}return u}},{key:"findBestMitigation",value:function(e,t,r,n){var a,i,o="unknown";n||("2"===r?r="4":"3"===r&&(r="5"));var s=null!==(a=L.matchMap[e])&&void 0!==a?a:o+"_";s+=null!==(i=L.mitigateMap[t])&&void 0!==i?i:o;var c=L.bestMitigationMap[t];if("0"!==r){var u;s+=","+(null!==(u=L.captchaMap[r])&&void 0!==u?u:o);var l=L.bestMitigationCaptchaMap[r];void 0!==l&&(c=l)}return this.mitigationType===E.INJECT&&(c=L.mitigationTypes.none),{sessionStatus:s,mitigation:c,parts:{match:e,mitigate:t,captcha:r}}}},{key:"APIError",value:function(e){var t="Unknown error";switch(e.status){case 403:t="Invalid credentials";break;case 500:t="Server error";break;case 502:t="Bad Gateway";break;case 503:t="Service Unavailable";break;case 400:t="Invalid request"}return new Error("Error reaching Netacea API (".concat(t,"), status: ").concat(e.status))}},{key:"isUrlCaptchaPost",value:function(e,t){return e.includes("/AtaVerifyCaptcha")&&"post"===t.toLowerCase()}},{key:"processMitigateRequest",value:(a=l(s().mark((function e(t,r,n){var a,i,o,c,u,l,h;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isUrlCaptchaPost(t.url,t.method)){e.next=2;break}return i=this,o=t.mitata,c=t.clientIp,u=t.userAgent,e.next=1,t.getBodyFn();case 1:l=e.sent,h=r,a=i.processCaptcha.call(i,o,c,u,l,h),e.next=3;break;case 2:a=this.check(t.mitata,t.clientIp,t.userAgent,t.mitataCaptcha,r,n,t.url);case 3:return e.next=4,a;case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"setIngestOnlyMitataCookie",value:(n=l(s().mark((function e(t){var r,n,a=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:P.NO_SESSION,e.next=1,this.createMitata(D,t,"0","0","0",86400,void 0,r);case 1:return n=e.sent,e.abrupt("return",{sessionStatus:"",setCookie:[n]});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"processIngest",value:(r=l(s().mark((function e(t){var r,n,a,i,o,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.getCookieHeader(t),e.next=1,this.readCookie(this.netaceaCookieName,n);case 1:if(a=e.sent,void 0===this.cookieFactory){e.next=3;break}return e.next=2,this.cookieFactory.retrieveCookieInfo(a,D);case 2:c=e.sent,e.next=4;break;case 3:c=J(a,D,null!==(r=this.secretKey)&&void 0!==r?r:"");case 4:if((i=c).isPrimaryHashValid){e.next=6;break}return e.next=5,this.setIngestOnlyMitataCookie(void 0,er(i));case 5:return e.abrupt("return",e.sent);case 6:if(!i.requiresReissue){e.next=8;break}return o=void 0!==i.mitata?i.mitata.userId:void 0,e.next=7,this.setIngestOnlyMitataCookie(o,er(i));case 7:return e.abrupt("return",e.sent);case 8:return e.abrupt("return",{sessionStatus:"",setCookie:[]});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"encryptCookieValue",value:(t=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"decryptCookieValue",value:(e=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,r,n,a,i,o,c,u,p,f,g,k,b,x,S}(),Zt=function(){function t(r){var n,a,i,o,s;h(this,t),y(s=e(this,t,[r]),"httpsAgent",void 0),y(s,"mitataCookieName",void 0),y(s,"mitataCaptchaCookieName",void 0),y(s,"hashGenerator",void 0),y(s,"debugMode",void 0),y(s,"encryptionEnabled",!1),y(s,"encryptionKeyBuffer",void 0),y(s,"mitigationHeaders",["cookie","user-agent","accept","host"]),y(s,"netaceaCaptchaPath",void 0),y(s,"captchaHost",void 0),y(s,"enableCaptchaContentNegotiation",void 0),s.httpsAgent=new T.Agent({timeout:s.timeout,keepAlive:!0,maxSockets:null!==(n=r.maxSockets)&&void 0!==n?n:25}),s.mitataCookieName=null!==(a=r.netaceaCookieName)&&void 0!==a?a:"_mitata",s.mitataCaptchaCookieName=null!==(i=r.netaceaCaptchaCookieName)&&void 0!==i?i:"_mitatacaptcha";var c=function(){return d((function e(){h(this,e)}),[{key:"encode",value:function(e){return new Uint8Array(Buffer.from(e,"utf8"))}}])}();if(s.hashGenerator=new Z(Bt,c),s.debugMode=null!==(o=r.debugMode)&&void 0!==o&&o,s.netaceaCaptchaPath=function(e){if(null!=e&&""!==e)return"/"!==e[0]&&(e="/"+e),qt.test(e)?e:void 0}(r.netaceaCaptchaPath),s.captchaHost=r.captchaHost,s.enableCaptchaContentNegotiation=!0===r.enableCaptchaContentNegotiation,void 0!==r.cookieEncryptionKey){var u=function(e){if(null==e||""===e)return{valid:!1,error:"key is empty"};if(!/^[A-Za-z0-9_-]+$/.test(e))return{valid:!1,error:"key contains invalid base64url characters"};var t;try{t=te(e)}catch(e){return{valid:!1,error:"key is not valid base64url"}}return 32!==t.length?{valid:!1,error:"key must be ".concat(32," bytes (256 bits), got ").concat(t.length," bytes")}:{valid:!0,keyBuffer:t}}(r.cookieEncryptionKey);u.valid&&void 0!==u.keyBuffer?(s.encryptionKeyBuffer=u.keyBuffer,s.encryptionEnabled=!0):console.warn("NETACEA WARN: Invalid cookieEncryptionKey - ".concat(u.error,". Cookies will not be encrypted."))}return s.cookieFactory=new At({cookieEncryptionKey:r.cookieEncryptionKey,secretKey:r.secretKey,expirySeconds:s.mitataCookieExpirySeconds},s.encryptionEnabled&&void 0!==s.encryptionKeyBuffer?s.encryptionKeyBuffer:void 0),s}return a(t,Qt),d(t,[{key:"computeHeaderFingerprint",value:(g=l(s().mark((function e(t){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t&&""!==t){e.next=1;break}return e.abrupt("return","");case 1:return r=t.split(","),e.next=2,this.hashGenerator.hashHeaders(r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"handleGetCaptchaRequest",value:(v=l(s().mark((function e(t,r,n,a,i,o,c){var u,l,h,p,d,f,v,y,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=Gt(o),l=this.enableCaptchaContentNegotiation?Ut(i):"text/html",h={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":t,"user-agent":r,cookie:void 0!==n?"_mitatacaptcha="+n:"","X-Netacea-Captcha-Content-Type":l},void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(h["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,h["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),p={netaceaHeaders:"request-id"},"string"==typeof a&&""!==a&&(p.headerFP=a),null!==u&&(p.trackingId=u),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/captcha",headers:h,method:"GET",timeout:this.timeout,params:p});case 1:if(200===(d=e.sent).status){e.next=2;break}throw this.APIError(d);case 2:return f=d.body,"application/json"===l&&void 0!==this.netaceaCaptchaPath&&void 0!==f&&(g=null!==(v=null!==(y=this.captchaHost)&&void 0!==y?y:c)&&void 0!==v?v:"",f=Jt(f,g,this.netaceaCaptchaPath)),e.abrupt("return",{body:f,apiCallStatus:d.status,setCookie:[],sessionStatus:",captcha_serve",mitigation:"captcha",mitigated:!0});case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a,i,o){return v.apply(this,arguments)})},{key:"encryptCookieValue",value:(f=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.next=1;break}return e.abrupt("return",t);case 1:return e.abrupt("return",ae(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"decryptCookieValue",value:(p=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.next=1;break}return e.abrupt("return",t);case 1:if(ne(t)){e.next=2;break}throw new Error("Cookie is not JWE encrypted");case 2:return e.abrupt("return",ie(t,this.encryptionKeyBuffer));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getInjectHeaders",value:function(e){if(this.mitigationType===E.INJECT){var t=e;if(void 0!==t.injectHeaders){var r={},n=t.injectHeaders;return r["x-netacea-match"]=n["x-netacea-match"],r["x-netacea-mitigate"]=n["x-netacea-mitigate"],r["x-netacea-captcha"]=n["x-netacea-captcha"],void 0!==n["x-netacea-event-id"]&&(r["x-netacea-event-id"]=n["x-netacea-event-id"]),this.encodeHeadersAsKeyValueList(r)}}return[]}},{key:"registerPolicyHandler",value:function(e){var t=this;e.addMethod("getMitigationHeaderPolicy",(function(e,r){var n=t.mitigationHeaders.join(",");console.info('level=info component=f5 handler=getMitigationHeaderPolicy policy="'.concat(n,'"')),r.reply(n)}))}},{key:"encodeHeadersAsKeyValueList",value:function(e){for(var t=[],r=0,n=Object.entries(e);r<n.length;r++){var a=k(n[r],2),i=a[0],o=a[1];if(Array.isArray(o)){var s,c=m(o);try{for(c.s();!(s=c.n()).done;){var u=s.value;t.push(i,Buffer.from(u).toString("base64"))}}catch(e){c.e(e)}finally{c.f()}}else t.push(i,Buffer.from(o).toString("base64"))}return t}},{key:"registerMitigateHandler",value:function(e){var t=this;e.addMethod("handleRequest",function(){var e=l(s().mark((function e(r,n){var a,i,o,c,u,l,h,p,d,f,v,y,g,m,b,x,S,C,w,I,A,O,N,E,P,_,T,K,R,j,V,M,H;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.params(),c=k(o,3),u=c[0],l=c[1],h=c[2],p=t.getArrayValueOrDefault(o,3,void 0),d=t.getArrayValueOrDefault(o,4,void 0),f=t.getArrayValueOrDefault(o,5,void 0),v=t.parseHeaderValues(f),y=null!==(a=v.cookie)&&void 0!==a?a:null,g=null!==(i=v["user-agent"])&&void 0!==i?i:"",m=v.accept,e.prev=1,e.next=2,t.computeHeaderFingerprint(d);case 2:return S=e.sent,t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=header_fingerprint method="'.concat(l,'" path="').concat(h,'" headers="').concat(null!=d?d:"",'" header_count=').concat(null!==(C=null==d?void 0:d.split(",").length)&&void 0!==C?C:0,' fingerprint="').concat(S,'"')),e.next=3,t.getMitataCookies(y);case 3:return w=e.sent,I=k(w,2),A=I[0],O=I[1],t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=mitigation_request headerFP="'.concat(S,'"')),e.next=4,t.runMitigation({ip:u,method:l,url:h,mitataCaptchaCookie:O,mitataCookie:A,userAgent:g,body:p,headerFingerprint:S,acceptHeader:m,hostHeader:v.host});case 4:if(N=e.sent,E="",(zt(h,l,t.netaceaCaptchaPath)||void 0!==t.netaceaCaptchaPath&&"captcha"===(null==N||null===(b=N.response)||void 0===b?void 0:b.mitigation))&&(E=t.enableCaptchaContentNegotiation&&"application/json"===Ut(m)?"application/json":"text/html; charset=UTF-8"),"error_open"!==(null==N?void 0:N.sessionStatus)){e.next=5;break}return n.reply(["",500,"error_open",!0,"",S,[],[],500]),e.abrupt("return");case 5:if(void 0!==N){e.next=6;break}return n.reply(["",0,"",!1,"",S,[],[],0]),e.abrupt("return");case 6:P="",_=0,T=!1,K=0,R=t.getValueOrDefault(A,""),void 0!==N.setCookie&&N.setCookie.length>0&&void 0!==(j=N.setCookie.find((function(e){return e.includes("".concat(t.netaceaCookieName,"="))})))&&(R=j.split(";")[0].replace("".concat(t.netaceaCookieName,"="),"")),void 0!==N.response&&(_=t.getValueOrDefault(N.response.apiCallStatus,0),P=t.getValueOrDefault(N.response.body,"Forbidden"),T=t.getValueOrDefault(N.response.mitigated,T),K=t.getValueOrDefault(N.response.status,403)),V={},void 0!==N.setCookie&&N.setCookie.length>0&&(V["Set-Cookie"]=N.setCookie),""!==E&&(V["Content-Type"]=E),void 0!==(M=null===(x=N.response)||void 0===x?void 0:x.redirect)&&(V.Location=M.location),n.reply([P,_,t.getValueOrDefault(N.sessionStatus,""),T,t.getValueOrDefault(R,""),S,t.getInjectHeaders(N),t.encodeHeadersAsKeyValueList(V),K]),e.next=8;break;case 7:e.prev=7,H=e.catch(1),console.error("Could not reach Netacea mitigation API: ",H.message),n.reply(["",0,"",!1,"","",[],[],0]);case 8:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"parseHeaderValues",value:function(e){var t={};if(void 0===e||""===e)return t;for(var r=e.split(","),n=0;n<this.mitigationHeaders.length&&n<r.length;n++)t[this.mitigationHeaders[n].toLowerCase()]=Buffer.from(r[n],"base64").toString("utf8");return t}},{key:"getValueOrDefault",value:function(e,t){return null!=e?e:t}},{key:"getArrayValueOrDefault",value:function(e,t,r){var n;return null!==(n=e[t])&&void 0!==n?n:r}},{key:"getMitataCookies",value:(u=l(s().mark((function e(t){var r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null==t?void 0:t.split("; "),n=this.getCookie(this.mitataCookieName,r),a=this.getCookie(this.mitataCaptchaCookieName,r),void 0===n){e.next=4;break}return e.prev=1,e.next=2,this.decryptCookieValue(n);case 2:n=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),n=void 0;case 4:if(void 0===a){e.next=8;break}return e.prev=5,e.next=6,this.decryptCookieValue(a);case 6:a=e.sent,e.next=8;break;case 7:e.prev=7,e.catch(5),a=void 0;case 8:return e.abrupt("return",[n,a]);case 9:case"end":return e.stop()}}),e,this,[[1,3],[5,7]])}))),function(e){return u.apply(this,arguments)})},{key:"getCookie",value:function(e,t){var r;return null==t||null===(r=t.find((function(t){return t.includes("".concat(e,"="))})))||void 0===r?void 0:r.replace("".concat(e,"="),"")}},{key:"registerIngestHandler",value:function(e){var t=this;e.addMethod("ingest",function(){var e=l(s().mark((function e(r,n){var a,i,o,c,u,l,h,p,d,f,v,y,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.params(),o=t.getArrayValueOrDefault(i,0,""),c=t.getArrayValueOrDefault(i,1,""),u=t.getArrayValueOrDefault(i,2,"-1"),l=t.getArrayValueOrDefault(i,3,""),h=t.getArrayValueOrDefault(i,4,""),p=t.getArrayValueOrDefault(i,5,""),d=t.getArrayValueOrDefault(i,6,""),f=t.getArrayValueOrDefault(i,7,"0"),v=t.getArrayValueOrDefault(i,8,"0"),a=t.getArrayValueOrDefault(i,9,""),y=t.getArrayValueOrDefault(i,10,""),g=t.getArrayValueOrDefault(i,11,""),t.debugMode&&console.info('level=debug component=f5 handler=ingest event=ingest_request ingestType="'.concat(t.ingestType,'" headerFingerprint="').concat(g,'"')),void 0===a){e.next=4;break}return e.prev=1,e.next=2,t.decryptCookieValue(a);case 2:a=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),a=void 0;case 4:t.ingest({ip:o,userAgent:c,status:u,method:l,path:h,protocol:p,referer:d,bytesSent:f,requestTime:v,mitataCookie:a,sessionStatus:y,headerFingerprint:g}).catch((function(e){console.error("Could not reach Netacea ingest API: "+e.message)})),n.reply("done");case 5:case"end":return e.stop()}}),e,null,[[1,3]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"makeRequest",value:(c=l(s().mark((function e(t){var r=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e,n){t.host=t.host.replace("https://","");var a=t.path;if(void 0!==t.params){var i=t.params instanceof URLSearchParams?t.params.toString():K.stringify(t.params);""!==i&&(a+=(a.includes("?")?"&":"?")+i)}for(var o=T.request({agent:r.httpsAgent,host:t.host,path:a,headers:t.headers,method:t.method,body:t.body},(function(t){var r="";t.on("data",(function(e){r+=e})),t.on("end",(function(){var n;e({headers:t.headers,status:null!==(n=t.statusCode)&&void 0!==n?n:0,body:""===r?void 0:r})}))})),s=0,c=["error","abort","timeout"];s<c.length;s++){var u=c[s];o.on(u,(function(e){n(e),o.destroyed||o.destroy()}))}"post"===t.method.toLowerCase()&&o.write(t.body),o.end()}));case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)}))),function(e){return c.apply(this,arguments)})},{key:"mitigate",value:(o=l(s().mark((function e(t){var r,n,a,i,o,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,n={sessionStatus:r.sessionStatus,setCookie:r.setCookie},r.mitigated&&(n.response={body:null!==(a=r.body)&&void 0!==a?a:"Forbidden",status:null!==(i=null===(o=r.redirect)||void 0===o?void 0:o.statusCode)&&void 0!==i?i:r.sessionStatus.includes("monetised")?402:403,apiCallStatus:null!==(c=r.apiCallStatus)&&void 0!==c?c:-1,mitigation:r.mitigation,mitigated:r.mitigated,redirect:r.redirect}),e.abrupt("return",n);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"inject",value:(i=l(s().mark((function e(t){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,e.abrupt("return",{injectHeaders:r.injectHeaders,sessionStatus:r.sessionStatus,setCookie:r.setCookie});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getMitigationResponse",value:(n=l(s().mark((function e(t){var r,n,a,i,o,c,u,h,p,d,f,v,y,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.ip,n=t.userAgent,a=t.url,i=t.method,o=t.mitataCookie,c=t.mitataCaptchaCookie,u=t.body,h=t.headerFingerprint,p=t.acceptHeader,d=t.hostHeader,!zt(a,i,this.netaceaCaptchaPath)){e.next=2;break}return e.next=1,this.handleGetCaptchaRequest(r,n,c,null!=h?h:"",p,a,d);case 1:return e.abrupt("return",e.sent);case 2:return f=this.enableCaptchaContentNegotiation&&void 0!==this.netaceaCaptchaPath?Ut(p):void 0,e.next=3,this.processMitigateRequest({clientIp:r,getBodyFn:function(){var e=l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,Promise.resolve(u);case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),method:i,mitata:o,mitataCaptcha:c,url:a,userAgent:n},h,f);case 3:return v=e.sent,"application/json"===f&&void 0!==this.netaceaCaptchaPath&&void 0!==v.body&&"captcha"===v.mitigation&&(v.body=Jt(v.body,null!==(y=null!==(g=this.captchaHost)&&void 0!==g?g:d)&&void 0!==y?y:"",this.netaceaCaptchaPath)),e.abrupt("return",v);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"ingest",value:(r=l(s().mark((function e(t){var r,n,a,i,o,c,u,l,h,p,d,f;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ip,n=t.userAgent,a=t.status,i=t.method,o=t.path,c=t.protocol,u=t.referer,l=t.bytesSent,h=t.requestTime,p=t.mitataCookie,d=t.sessionStatus,f=t.headerFingerprint,e.next=1,this.callIngest({ip:r,userAgent:n,status:a,method:i,bytesSent:l,path:o,protocol:c,referer:u,requestTime:h,mitataCookie:p,sessionStatus:d,headerFingerprint:f,integrationType:"@netacea/f5".replace("@netacea/",""),integrationVersion:"5.8.4"});case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getCookieHeader",value:function(e){if(void 0!==e.mitataCookie)return"".concat(this.mitataCookieName,"=").concat(e.mitataCookie)}}]);var r,n,i,o,c,u,p,f,v,g}();function er(e){return e.isPrimaryHashValid?e.isSameIP?e.isExpired?P.EXPIRED_SESSION:P.NO_SESSION:P.IP_CHANGE:P.NO_SESSION}function tr(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t}module.exports=Zt;
|
|
1
|
+
"use strict";function e(e,n,a){return n=r(n),function(e,t){if(t&&("object"==o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,t()?Reflect.construct(n,a||[],r(e).constructor):n.apply(e,a))}function t(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(t=function(){return!!e})()}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function n(){n=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,a){var o=RegExp(e,n);return t.set(o,a||t.get(e)),i(o,r.prototype)}function s(e,r){var n=t.get(r);return Object.keys(n).reduce((function(t,r){var a=n[r];if("number"==typeof a)t[r]=e[a];else{for(var i=0;void 0===e[a[i]]&&i+1<a.length;)i++;t[r]=e[a[i]]}return t}),Object.create(null))}return a(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);if(r){r.groups=s(r,this);var n=r.indices;n&&(n.groups=s(n,this))}return r},r.prototype[Symbol.replace]=function(r,n){if("string"==typeof n){var a=t.get(this);return e[Symbol.replace].call(this,r,n.replace(/\$<([^>]+)(>|$)/g,(function(e,t,r){if(""===r)return e;var n=a[t];return Array.isArray(n)?"$"+n.join("$"):"number"==typeof n?"$"+n:""})))}if("function"==typeof n){var i=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=o(e[e.length-1])&&(e=[].slice.call(e)).push(s(e,i)),n.apply(this,e)}))}return e[Symbol.replace].call(this,r,n)},n.apply(this,arguments)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function s(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */s=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var i=t&&t.prototype instanceof k?t:k,o=Object.create(i.prototype),s=new T(n||[]);return a(o,"_invoke",{value:N(e,r,s)}),o}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var f="suspendedStart",v="suspendedYield",y="executing",g="completed",m={};function k(){}function b(){}function x(){}var S={};h(S,c,(function(){return this}));var C=Object.getPrototypeOf,w=C&&C(C(K([])));w&&w!==r&&n.call(w,c)&&(S=w);var I=x.prototype=k.prototype=Object.create(S);function A(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(a,i,s,c){var u=d(e[a],e,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==o(h)&&n.call(h,"__await")?t.resolve(h.__await).then((function(e){r("next",e,s,c)}),(function(e){r("throw",e,s,c)})):t.resolve(h).then((function(e){l.value=e,s(l)}),(function(e){return r("throw",e,s,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function N(t,r,n){var a=f;return function(i,o){if(a===y)throw Error("Generator is already running");if(a===g){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=E(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===f)throw a=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=y;var u=d(t,r,n);if("normal"===u.type){if(a=n.done?g:v,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=g,n.method="throw",n.arg=u.arg)}}}function E(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,E(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=d(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function K(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(o(t)+" is not iterable")}return b.prototype=x,a(I,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=h(x,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,h(e,l,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},A(O.prototype),h(O.prototype,u,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new O(p(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},A(I),h(I,l,"Generator"),h(I,c,(function(){return this})),h(I,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=K,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(_),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;_(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:K(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function c(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function l(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){u(i,n,a,o,s,"next",e)}function s(e){u(i,n,a,o,s,"throw",e)}o(void 0)}))}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,g(n.key),n)}}function d(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e,t,r){return(t=g(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e){var t=function(e,t){if("object"!=o(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==o(t)?t:t+""}function m(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=b(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw i}}}}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,s=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){if(e){if("string"==typeof e)return x(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var S=require("crypto"),C=require("buffer"),w=require("https"),I=require("querystring"),A=require("aws4");function O(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var N,E,P,_=O(S),T=O(w),K=O(I);!function(e){e.ORIGIN="ORIGIN",e.HTTP="HTTP",e.KINESIS="KINESIS",e.NATIVE="NATIVE"}(N||(N={})),function(e){e.MITIGATE="MITIGATE",e.INJECT="INJECT",e.INGEST="INGEST"}(E||(E={})),function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session"}(P||(P={}));var R=3e3;var j="_/@#/",V={none:"",block:"block",captcha:"captcha",allow:"allow",captchaPass:"captchapass"},M={0:V.none,1:V.block,2:V.none,3:V.block,4:V.none,5:V.block},H={1:V.captcha,2:V.captchaPass,3:V.captcha,4:V.allow,5:V.captcha,6:V.allow,7:V.captcha,a:V.captcha,b:V.captchaPass,c:V.captcha,d:V.allow,e:V.captcha},L=Object.freeze({__proto__:null,COOKIEDELIMITER:j,bestMitigationCaptchaMap:H,bestMitigationMap:M,captchaMap:{0:"",1:"captcha_serve",2:"captcha_pass",3:"captcha_fail",4:"captcha_cookiepass",5:"captcha_cookiefail",6:"checkpoint_signal",7:"checkpoint_post",a:"checkpoint_serve",b:"checkpoint_pass",c:"checkpoint_fail",d:"checkpoint_cookiepass",e:"checkpoint_cookiefail"},captchaStatusCodes:{"":0,captchaServe:1,captchaPass:2,captchaFail:3,captchaCookiePass:4,captchaCookieFail:5,checkpointSignal:6,checkpointPost:7,checkpointServe:"a",checkpointPass:"b",checkpointFail:"c",checkpointCookiePass:"d",checkpointCookieFail:"e"},matchMap:{0:"",1:"ua_",2:"ip_",3:"visitor_",4:"datacenter_",5:"customer_session_",6:"organisation_",7:"asn_",8:"country_",9:"combination_",b:"headerFP_",c:"vendorFamily_",d:"vendorName_",e:"vendor_",f:"vendorCrawlerClassification_"},mitigateMap:{0:"",1:"blocked",2:"allow",3:"hardblocked",4:"flagged",5:"monetised"},mitigationTypes:V,netaceaCookieV3KeyMap:{clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},netaceaCookieV3OptionalKeyMap:{checkAllPostRequests:"fCAPR"},netaceaHeaders:{match:"x-netacea-match",mitigate:"x-netacea-mitigate",captcha:"x-netacea-captcha",mitata:"x-netacea-mitata-value",mitataExpiry:"x-netacea-mitata-expiry",mitataCaptcha:"x-netacea-mitatacaptcha-value",mitataCaptchaExpiry:"x-netacea-mitatacaptcha-expiry",eventId:"x-netacea-event-id"},netaceaSettingsMap:{checkAllPostRequests:"checkAllPostRequests"}}),D="ignored",B="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),F=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;function q(e){if(void 0!==e){var t=e.match(F);if(null!=t){var r=k(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:B,r=S.randomBytes(e-1),n=Array.from(r).map((function(e){return t[e%t.length]})).join("");return"c".concat(n)}function G(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"000";void 0===t&&(t=z());var i=[r,t,U(e+"|"+String(r),n),a].join(j),o=U(i,n);return"".concat(o).concat(j).concat(i)}function U(e,t){var r=S.createHmac("sha256",t);return r.update(e),C.Buffer.from(r.digest("hex")).toString("base64")}function J(e,t,r){var n={mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0"};if("string"!=typeof e||""===e)return n;var a=q(e);if(void 0!==a){var i=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(j),o=Math.floor(Date.now()/1e3),s=parseInt(a.expiry)<o,c=["1","3","5","a","c","e"].includes(a.captcha),u="3"===a.mitigate,l=c||u,h=U(t+"|"+a.expiry,r),p=a.ipHash===h;return{mitata:a,requiresReissue:s||!p,isExpired:s,shouldExpire:l,isSameIP:p,isPrimaryHashValid:a.signature===U(i,r),match:a.match,mitigate:a.mitigate,captcha:a.captcha,userId:a.userId}}return n}function X(e,t){var r=e.split(";").map((function(e){return e.trim()})).filter((function(e){return e.toLowerCase().startsWith(t.toLowerCase())}))[0];return void 0!==r&&r.length>0?null==r?void 0:r.replace("".concat(t,"="),""):void 0}function W(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof e&&(e=e.join("; ")),""===e?"":$(e.split(";"),t).join("; ")}function $(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return $(e.reverse()).reverse();var t,r=new Set,n=[],a=m(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;if(""!==(i=i.trimStart()).trim()){var o=i.split("=")[0].toUpperCase();r.has(o)||(r.add(o),n.push(i))}}}catch(e){a.e(e)}finally{a.f()}return n}function Y(e){var t,r,n=W([null!==(t=e.otherAttributes)&&void 0!==t?t:"","Max-Age=".concat(null!==(r=e.maxAgeAttribute)&&void 0!==r?r:86400),"Path=/"].join("; "));return"".concat(e.cookieName,"=").concat(e.cookieValue,"; ").concat(n)}var Q={cookie:{attributes:Object.freeze({__proto__:null,configureCookiesDomain:function(e,t){var r=e=W(null!=e?e:"",!0),n=t=W(null!=t?t:"",!0);if(void 0!==e&&void 0!==t){var a=X(e,"Domain"),i=X(t,"Domain");void 0!==a&&void 0!==i?n=t.replace(i,a):void 0!==a&&void 0===i?n=t+(""!==t?"; Domain=".concat(a):"Domain=".concat(a)):void 0===a&&void 0!==i&&(r=e+(""!==e?"; Domain=".concat(i):"Domain=".concat(i)))}else if(void 0!==e&&void 0===t){var o=X(e,"Domain");void 0!==o&&(n="Domain=".concat(o))}else if(void 0===e&&void 0!==t){var s=X(t,"Domain");void 0!==s&&(r="Domain=".concat(s))}return{cookieAttributes:""!==r?r:void 0,captchaCookieAttributes:""!==n?n:void 0}},extractAndRemoveCookieAttr:function(e,t){var r=X(e,t);return void 0!==r?{extractedAttribute:r,cookieAttributes:e.replace(/ /g,"").replace("".concat(t,"=").concat(r),"").split(";").filter((function(e){return e.length>0})).join("; ")}:{extractedAttribute:void 0,cookieAttributes:e}},extractCookieAttr:X,removeDuplicateAttrs:W}),netaceaSession:Object.freeze({__proto__:null,createNetaceaCaptchaSetCookieString:function(e){var t;return Y(v(v({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitatacaptcha"}))},createNetaceaSetCookieString:function(e){var t;return Y(v(v({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitata"}))},createSetCookieString:Y})}},Z=function(){function e(t,r){h(this,e),this.crypto=t,this.TextEncoder=r}return d(e,[{key:"hashString",value:(r=l(s().mark((function e(t,r){var n,a,i,o,u,l,h=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=(n=h.length>2&&void 0!==h[2]&&h[2])?c(r).sort():c(r),i=(new this.TextEncoder).encode(a.join(",")),e.next=1,this.crypto.subtle.digest(t,i);case 1:return o=e.sent,u=Array.from(new Uint8Array(o)),l=u.map((function(e){return e.toString(16).padStart(2,"0")})).join("").substring(0,12),e.abrupt("return","h"+(n?"s":"")+"_".concat(r.length,"_").concat(l));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"hashHeaders",value:(t=l(s().mark((function t(r){var n,a,i,o=arguments;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>1&&void 0!==o[1]&&o[1],0!==(a=e.filterHeaderNames(r)).length){t.next=1;break}return t.abrupt("return","");case 1:return t.prev=1,t.next=2,this.hashString("SHA-256",a,n);case 2:return t.abrupt("return",t.sent);case 3:return t.prev=3,i=t.catch(1),console.error(i),t.abrupt("return","");case 4:case"end":return t.stop()}}),t,this,[[1,3]])}))),function(e){return t.apply(this,arguments)})}],[{key:"filterHeaderNames",value:function(e){return e.filter((function(e){var t=e.toLowerCase();return!["","cookie","referer"].includes(t)&&null===t.match(/^(x-netacea-|cloudfront-)/i)}))}}]);var t,r}();function ee(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function te(e){var t=(e+"===".slice(0,(4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/");return Buffer.from(t,"base64")}var re="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0";function ne(e){return 5===e.split(".").length&&e.includes("..")}function ae(e,t){var r=S.randomBytes(12),n=S.createCipheriv("aes-256-gcm",t,r),a=Buffer.from(re,"ascii");n.setAAD(a);var i=n.update(e,"utf8");i=Buffer.concat([i,n.final()]);var o=n.getAuthTag();return[re,"",ee(r),ee(i),ee(o)].join(".")}function ie(e,t){var r=e.split(".");if(5!==r.length)throw new Error("JWE should have 5 parts, got ".concat(r.length));var n=k(r,5),a=n[0],i=n[1],o=n[2],s=n[3],c=n[4];if(a!==re)throw new Error("Incorrect JWE header");if(""!==i)throw new Error("Expected empty encrypted key for direct encryption");var u=te(o),l=te(s),h=te(c);if(12!==u.length)throw new Error("IV must be ".concat(12," bytes, got ").concat(u.length));if(16!==h.length)throw new Error("Auth tag must be ".concat(16," bytes, got ").concat(h.length));var p=S.createDecipheriv("aes-256-gcm",t,u),d=Buffer.from(a,"ascii");p.setAAD(d),p.setAuthTag(h);var f=p.update(l);return(f=Buffer.concat([f,p.final()])).toString("utf8")}var oe,se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ce={},ue={};Object.defineProperty(ue,"__esModule",{value:!0}),ue.NetaceaCookieV3IssueReason=void 0,function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session",e.UNKNOWN="unknown"}(oe||(ue.NetaceaCookieV3IssueReason=oe={}));var le={},he={},pe={};Object.defineProperty(pe,"__esModule",{value:!0}),pe.netaceaCookieV3OptionalKeyMap=pe.netaceaCookieV3KeyMap=pe.COOKIEDELIMITER=void 0,pe.COOKIEDELIMITER="_/@#/",pe.netaceaCookieV3KeyMap={clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},pe.netaceaCookieV3OptionalKeyMap={checkAllPostRequests:"fCAPR"},Object.defineProperty(he,"__esModule",{value:!0}),he.defaultInvalidResponse=he.matchNetaceaCookieV3=he.checkNetaceaCookieV3=he.objectIsNetaceaCookieV3=he.cookieIsNetaceaV3Format=he.createNetaceaCookieV3=void 0;var de=ue,fe=pe;function ve(e){if(void 0!==e&&""!==e){var t,r=e.split("&"),n={clientIP:"",userId:"",cookieId:"",gracePeriod:0,match:"0",mitigate:"0",captcha:"0",issueTimestamp:0,issueReason:"",checkAllPostRequests:void 0},a=m(r);try{var i=function(){var e,r=k(t.value.split("="),2),a=r[0],i=r[1],o=decodeURIComponent(i),s=Object.keys(fe.netaceaCookieV3KeyMap).find((function(e){return fe.netaceaCookieV3KeyMap[e]===a}));void 0===s&&(s=Object.keys(fe.netaceaCookieV3OptionalKeyMap).find((function(e){return fe.netaceaCookieV3OptionalKeyMap[e]===a}))),void 0!==(e=void 0!==s&&["match","mitigate","captcha"].includes(s)?""===o?void 0:o:""===o?void 0:Number(o))&&"string"!=typeof e&&isNaN(e)&&(e=o),n[s]=e};for(a.s();!(t=a.n()).done;)i()}catch(e){a.e(e)}finally{a.f()}return n}}function ye(){return{mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0",issueReason:de.NetaceaCookieV3IssueReason.NO_SESSION}}he.createNetaceaCookieV3=function(e){return Object.entries(e).filter((function(e){var t=k(e,2);t[0];return void 0!==t[1]})).map((function(e){var t=k(e,2),r=t[0],n=t[1];return r in fe.netaceaCookieV3OptionalKeyMap?"".concat(fe.netaceaCookieV3OptionalKeyMap[r],"=").concat(encodeURIComponent(n)):"".concat(fe.netaceaCookieV3KeyMap[r],"=").concat(encodeURIComponent(n))})).join("&")},he.cookieIsNetaceaV3Format=function(e){if(void 0===e||""===e)return!1;var t=e.split("&").map((function(e){return e.split("=")[0]})).filter((function(e){return!Object.values(fe.netaceaCookieV3OptionalKeyMap).includes(e)}));return 0!==t.length&&t.every((function(e){return Object.values(fe.netaceaCookieV3KeyMap).includes(e)}))},he.objectIsNetaceaCookieV3=function(e){if("object"!==o(e)||null===e)return!1;for(var t=0,r=Object.keys(fe.netaceaCookieV3KeyMap);t<r.length;t++){var n=r[t];if(!(n in e))return!1;if(void 0===e[n])return!1}return!0},he.checkNetaceaCookieV3=function(e,t){if(void 0===e||""===e)return ye();var r;try{r=ve(e)}catch(e){return ye()}if(void 0!==r){var n=Math.floor(Date.now()/1e3),a=r.issueTimestamp+r.gracePeriod<n,i=t===r.clientIP,o=["1","3","5","a","c","e"].includes(r.captcha),s="3"===r.mitigate;return{mitata:r,requiresReissue:a||!i,isExpired:a,shouldExpire:o||s,isSameIP:i,isPrimaryHashValid:!0,match:r.match,mitigate:r.mitigate,captcha:r.captcha,issueReason:r.issueReason}}return ye()},he.matchNetaceaCookieV3=ve,he.defaultInvalidResponse=ye;var ge={};Object.defineProperty(ge,"__esModule",{value:!0}),ge.AbstractCookieFactory=void 0;var me=ue,ke=he,be=pe,xe="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),Se=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i,Ce=function(){return d((function e(t){h(this,e),this.config=t}),[{key:"isEncrypted",value:function(e){return 5===e.split(".").length}},{key:"createCookieValue",value:(n=l(s().mark((function e(t){var r,n,a,i,o;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this.config.cookieEncryptionKey){e.next=2;break}return a=(0,ke.createNetaceaCookieV3)({clientIP:t.clientIP,userId:null!==(r=t.userId)&&void 0!==r?r:"",match:t.match,mitigate:t.mitigate,captcha:t.captcha,gracePeriod:t.gracePeriod,cookieId:t.cookieId,issueTimestamp:Math.floor(Date.now()/1e3),issueReason:null!==(n=t.issueReason)&&void 0!==n?n:me.NetaceaCookieV3IssueReason.NO_SESSION,checkAllPostRequests:t.checkAllPostRequests}),e.next=1,this.encrypt(a);case 1:case 4:return e.abrupt("return",e.sent);case 2:if(void 0!==this.config.secretKey){e.next=3;break}throw new Error("Cannot build cookie without secret key.");case 3:return i=[t.match,t.mitigate,t.captcha].join(""),o=Math.floor(Date.now()/1e3)+t.gracePeriod,e.next=4,this.buildMitataCookie(t.clientIP,t.userId,o,this.config.secretKey,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"retrieveCookieInfo",value:(r=l(s().mark((function e(t,r){var n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t&&""!==t){e.next=1;break}return e.abrupt("return",(0,ke.defaultInvalidResponse)());case 1:if(a=t,!this.isEncrypted(t)){e.next=3;break}return e.next=2,this.decrypt(t);case 2:a=e.sent;case 3:if(!(0,ke.cookieIsNetaceaV3Format)(a)){e.next=4;break}return e.abrupt("return",(0,ke.checkNetaceaCookieV3)(a,r));case 4:return e.next=5,this.checkMitataCookie(a,r,null!==(n=this.config.secretKey)&&void 0!==n?n:"");case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"buildMitataCookie",value:(t=l(s().mark((function e(t,r,n,a,i){var o,c,u,l;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=null!=r?r:this.generateUserId(),e.next=1,this.hash("".concat(t,"|").concat(String(n)),a);case 1:return c=e.sent,u=[n,o,c,i].join(be.COOKIEDELIMITER),e.next=2,this.hash(u,a);case 2:return l=e.sent,e.abrupt("return","".concat(l).concat(be.COOKIEDELIMITER).concat(u));case 3:case"end":return e.stop()}}),e,this)}))),function(e,r,n,a,i){return t.apply(this,arguments)})},{key:"checkMitataCookie",value:(e=l(s().mark((function e(t,r,n){var a,i,o,c,u,l,h,p,d,f,v;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(a=we(t))){e.next=1;break}return e.abrupt("return",(0,ke.defaultInvalidResponse)());case 1:return i=Math.floor(Date.now()/1e3),o=parseInt(a.expiry)<i,c=["1","3","5"].includes(a.captcha),u="3"===a.mitigate,l=c||u,e.next=2,this.hash("".concat(r,"|").concat(a.expiry),n);case 2:return h=e.sent,p=h===a.ipHash,d=[a.expiry,a.userId,a.ipHash,a.mitigationType].join(be.COOKIEDELIMITER),e.next=3,this.hash(d,n);case 3:return f=e.sent,v=f===a.signature,e.abrupt("return",{mitata:a,requiresReissue:o||!p,isExpired:o,shouldExpire:l,isSameIP:p,isPrimaryHashValid:v,match:a.match,mitigate:a.mitigate,captcha:a.captcha,issueReason:me.NetaceaCookieV3IssueReason.NO_SESSION});case 4:case"end":return e.stop()}}),e,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"generateUserId",value:function(){var e=new Uint16Array((arguments.length>0&&void 0!==arguments[0]?arguments[0]:16)-1);this.getRandomValues(e);var t=Array.from(e).map((function(e){return xe[e%xe.length]})).join("");return"c".concat(t)}}]);var e,t,r,n}();function we(e){var t=e.match(Se);if(null!==t){var r=k(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}ge.AbstractCookieFactory=Ce,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.NetaceaCookieV3IssueReason=e.COOKIEDELIMITER=e.netaceaCookieV3OptionalKeyMap=e.netaceaCookieV3KeyMap=e.AbstractCookieFactory=e.defaultInvalidResponse=e.objectIsNetaceaCookieV3=e.cookieIsNetaceaV3Format=e.matchNetaceaCookieV3=e.checkNetaceaCookieV3=e.createNetaceaCookieV3=void 0;var t=he;Object.defineProperty(e,"createNetaceaCookieV3",{enumerable:!0,get:function(){return t.createNetaceaCookieV3}}),Object.defineProperty(e,"checkNetaceaCookieV3",{enumerable:!0,get:function(){return t.checkNetaceaCookieV3}}),Object.defineProperty(e,"matchNetaceaCookieV3",{enumerable:!0,get:function(){return t.matchNetaceaCookieV3}}),Object.defineProperty(e,"cookieIsNetaceaV3Format",{enumerable:!0,get:function(){return t.cookieIsNetaceaV3Format}}),Object.defineProperty(e,"objectIsNetaceaCookieV3",{enumerable:!0,get:function(){return t.objectIsNetaceaCookieV3}}),Object.defineProperty(e,"defaultInvalidResponse",{enumerable:!0,get:function(){return t.defaultInvalidResponse}});var r=ge;Object.defineProperty(e,"AbstractCookieFactory",{enumerable:!0,get:function(){return r.AbstractCookieFactory}});var n=pe;Object.defineProperty(e,"netaceaCookieV3KeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3KeyMap}}),Object.defineProperty(e,"netaceaCookieV3OptionalKeyMap",{enumerable:!0,get:function(){return n.netaceaCookieV3OptionalKeyMap}}),Object.defineProperty(e,"COOKIEDELIMITER",{enumerable:!0,get:function(){return n.COOKIEDELIMITER}});var a=ue;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return a.NetaceaCookieV3IssueReason}})}(le);var Ie={};Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.validateRedirectLocation=void 0,Ie.validateRedirectLocation=function(e){if(""!==(e=null!=e?e:""))try{return new URL(e).toString()}catch(t){if(/^https?:\/\//i.test(e))return;return e.startsWith("/")?e:"/".concat(e)}};var Ae={},Oe={};function Ne(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a,i=n[r];if("cookie"===i||"Cookie"===i){var o=null!==(a=e[i])&&void 0!==a?a:"",s=Pe("string"==typeof o?o:o.join("; "),t);if(void 0!==s)return s}}}function Ee(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i,o=a[n];if("cookie"===o||"Cookie"===o){var s=null!==(i=e[o])&&void 0!==i?i:"",u="string"==typeof s?s:s.join("; ");r.push.apply(r,c(_e(u,t)))}}return r}function Pe(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).find((function(e){return e.startsWith(r)}))}function _e(e,t){var r=t+"=";return e.split(";").map((function(e){return e.trimStart()})).filter((function(e){return e.startsWith(r)}))}Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.findAllInCookieString=Oe.findFirstInCookieString=Oe.findAllInHeaders=Oe.findFirstInHeaders=Oe.findOnlyValueInHeaders=Oe.findAllValuesInHeaders=Oe.findFirstValueInHeaders=void 0,Oe.findFirstValueInHeaders=function(e,t){var r=Ne(e,t);if(void 0!==r)return r.slice(t.length+1)},Oe.findAllValuesInHeaders=function(e,t){return Ee(e,t).map((function(e){return e.slice(t.length+1)}))},Oe.findOnlyValueInHeaders=function(e,t){var r,n=Ee(e,t);if(n.length>1)throw new Error("Found more than one cookie with name ".concat(t));return null===(r=n[0])||void 0===r?void 0:r.slice(t.length+1)},Oe.findFirstInHeaders=Ne,Oe.findAllInHeaders=Ee,Oe.findFirstInCookieString=Pe,Oe.findAllInCookieString=_e;var Te={};function Ke(e){return"set-cookie"===e||"Set-Cookie"===e}function Re(e,t){var r=t+"=";return e.startsWith(r)}function je(e,t){if(!Re(e,t))throw new Error("Cookie '".concat(t,"' not found in '").concat(e,"'"));return e.slice(t.length+1).split(";")[0]}function Ve(e,t){var r,n=null!==(r=e[t])&&void 0!==r?r:[];return"string"==typeof n?[n]:n}function Me(e,t){for(var r=0,n=Object.keys(e);r<n.length;r++){var a=n[r];if(Ke(a)){var i=He(Ve(e,a),t);if(void 0!==i)return i}}}function He(e,t){return e.map((function(e){return e.trimStart()})).find((function(e){return Re(e,t)}))}function Le(e,t){for(var r=[],n=0,a=Object.keys(e);n<a.length;n++){var i=a[n];if(Ke(i)){var o=Ve(e,i);r.push.apply(r,c(De(o,t)))}}return r}function De(e,t){return e.map((function(e){return e.trimStart()})).filter((function(e){return Re(e,t)}))}Object.defineProperty(Te,"__esModule",{value:!0}),Te.findAllInSetCookieStrings=Te.findAllInHeaders=Te.findValueInSetCookieStrings=Te.findFirstInSetCookieStrings=Te.findFirstInHeaders=Te.findOnlyValueInHeaders=Te.findFirstValueInHeaders=Te.parseValueFromString=void 0,Te.parseValueFromString=je,Te.findFirstValueInHeaders=function(e,t){var r=Me(e,t);return void 0!==r?je(r,t):void 0},Te.findOnlyValueInHeaders=function(e,t){var r=Le(e,t);if(r.length>1)throw new Error("Found more than one set-cookie with name ".concat(t));return void 0!==r[0]?je(r[0],t):void 0},Te.findFirstInHeaders=Me,Te.findFirstInSetCookieStrings=He,Te.findValueInSetCookieStrings=function(e,t){var r=He(e,t);if(void 0!==r)return je(r,t)},Te.findAllInHeaders=Le,Te.findAllInSetCookieStrings=De;var Be=se&&se.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Fe=se&&se.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),qe=se&&se.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&Be(t,e,r);return Fe(t,e),t};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.setCookie=Ae.cookie=void 0,Ae.cookie=qe(Oe),Ae.setCookie=qe(Te);var ze={},Ge={},Ue={};Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.KINESIS_URL=Ue.API_VERSION=Ue.REGION=Ue.PAYLOAD_TYPE=Ue.STATE=void 0,Ue.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},Ue.PAYLOAD_TYPE="string",Ue.REGION="eu-west-1",Ue.API_VERSION="2013-12-02",Ue.KINESIS_URL="https://kinesis.eu-west-1.amazonaws.com";var Je={};function Xe(){return(Xe=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e){setTimeout(e,t)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}Object.defineProperty(Je,"__esModule",{value:!0}),Je.headersToRecord=Je.increaseBatchSize=Je.handleFailedLogs=Je.batchArrayForKinesis=Je.sleep=void 0,Je.sleep=function(e){return Xe.apply(this,arguments)},Je.batchArrayForKinesis=function(e,t,r){for(var n=[],a=0;a<e.length;a+=t){var i=e.slice(a,a+t);n.push({Data:r.from(JSON.stringify(i)).toString("base64"),PartitionKey:Date.now().toString()})}return n},Je.handleFailedLogs=function(e,t,r){var n=2*r,a=[].concat(c(e),c(t)),i=a.length-n;return i>0&&(console.error("Netacea Error :: failed to send ".concat(i," log(s) to Kinesis ingest.")),a.splice(0,i)),a},Je.increaseBatchSize=function(e,t){return e!==t?Math.min(t,2*e):e},Je.headersToRecord=function(e){var t={};return e.forEach((function(e,r){t[r]=e})),t},Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.WebStandardKinesis=void 0;var We=Ue,$e=Je,Ye=function(){return d((function e(t){var r=t.deps,n=t.kinesisIngestArgs;if(h(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,void 0===n.kinesisAccessKey)throw new Error("kinesisAccessKey is required for kinesis ingest");if(void 0===n.kinesisSecretKey)throw new Error("kinesisSecretKey is required for kinesis ingest");this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(r=l(s().mark((function e(){var t,r,n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.logCache.length){e.next=1;break}return e.abrupt("return");case 1:return t=c(this.logCache),this.logCache=[],e.prev=2,r=new this.deps.AwsClient({accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey}),e.next=3,this.signRequest(r,{streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize);case 3:return n=e.sent,e.next=4,this.deps.makeRequest({headers:(0,$e.headersToRecord)(n.headers),host:We.KINESIS_URL,method:"POST",path:"/",body:n.body});case 4:this.logBatchSize=(0,$e.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.next=6;break;case 5:e.prev=5,e.catch(2),this.logCache=(0,$e.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:case"end":return e.stop()}}),e,this,[[2,5]])}))),function(){return r.apply(this,arguments)})},{key:"ingest",value:(t=l(s().mark((function e(t){var r,n,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.next=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,$e.sleep)(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(r);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,n=(0,$e.sleep)(1e3*this.maxLogAgeSeconds).then(l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:case"end":return e.stop()}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.next=3;break}return e.next=3,n;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"signRequest",value:(e=l(s().mark((function e(t,r,n,a){var i,o;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={Records:(0,$e.batchArrayForKinesis)(n,a,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:r.streamName},e.next=1,t.sign(We.KINESIS_URL,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"}});case 1:return o=e.sent,e.abrupt("return",o);case 2:case"end":return e.stop()}}),e,this)}))),function(t,r,n,a){return e.apply(this,arguments)})}]);var e,t,r}();Ge.WebStandardKinesis=Ye;var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.Kinesis=void 0;var Ze=Ue,et=Je,tt=function(){return d((function e(t){var r=t.deps,n=t.kinesisIngestArgs;h(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.deps=r,this.kinesisStreamName=n.kinesisStreamName,this.kinesisAccessKey=n.kinesisAccessKey,this.kinesisSecretKey=n.kinesisSecretKey,this.maxAwaitTimePerIngestCallMs=n.maxAwaitTimePerIngestCallMs,void 0!==n.maxLogAgeSeconds&&n.maxLogAgeSeconds<this.maxLogAgeSeconds&&n.maxLogAgeSeconds>0&&(this.maxLogAgeSeconds=n.maxLogAgeSeconds),void 0!==n.logBatchSize&&(this.maxLogBatchSize=n.logBatchSize),this.logBatchSize=!0===n.rampUpBatchSize?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=l(s().mark((function e(){var t,r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.logCache.length){e.next=1;break}return e.abrupt("return");case 1:if(t=c(this.logCache),this.logCache=[],e.prev=2,"POST"===(a=this.signRequest({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},t,this.logBatchSize)).method){e.next=3;break}throw new Error("Unexpected method. Expected POST but got ".concat(a.method));case 3:return e.next=4,this.deps.makeRequest({headers:null!==(r=a.headers)&&void 0!==r?r:{},host:"https://".concat(a.hostname),method:a.method,path:null!==(n=a.path)&&void 0!==n?n:"/",body:a.body});case 4:this.logBatchSize=(0,et.increaseBatchSize)(this.logBatchSize,this.maxLogBatchSize),e.next=6;break;case 5:e.prev=5,e.catch(2),this.logCache=(0,et.handleFailedLogs)(this.logCache,t,this.maxLogBatchSize);case 6:case"end":return e.stop()}}),e,this,[[2,5]])}))),function(){return t.apply(this,arguments)})},{key:"ingest",value:(e=l(s().mark((function e(t){var r,n,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.next=2;break}return(r=[]).push(this.putToKinesis()),void 0!==this.maxAwaitTimePerIngestCallMs&&r.push((0,et.sleep)(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(r);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,n=(0,et.sleep)(1e3*this.maxLogAgeSeconds).then(l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,a.putToKinesis();case 1:a.intervalSet=!1;case 2:case"end":return e.stop()}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.next=3;break}return e.next=3,n;case 3:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"signRequest",value:function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:(0,et.batchArrayForKinesis)(t,r,this.deps.Buffer),PartitionKey:Date.now().toString(),StreamName:e.streamName};return this.deps.aws4.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:Ze.REGION},{accessKeyId:n,secretAccessKey:a})}}]);var e,t}();Qe.Kinesis=tt,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Kinesis=e.WebStandardKinesis=void 0;var t=Ge;Object.defineProperty(e,"WebStandardKinesis",{enumerable:!0,get:function(){return t.WebStandardKinesis}});var r=Qe;Object.defineProperty(e,"Kinesis",{enumerable:!0,get:function(){return r.Kinesis}})}(ze);var rt={};function nt(e,t){var r=null;if("number"==typeof e)r=e;else if("string"==typeof e){var n=parseFloat(e);isNaN(n)||(r=n)}if(null===r){if("number"!=typeof t.defaultValue)return t.defaultValue;r=t.defaultValue}return void 0!==t.minValue&&(r=Math.max(t.minValue,r)),void 0!==t.maxValue&&(r=Math.min(t.maxValue,r)),r}Object.defineProperty(rt,"__esModule",{value:!0}),rt.parseHttpHeaderName=rt.stringOrDefault=rt.parseIntOrDefault=rt.parseNumberOrDefault=void 0,rt.parseNumberOrDefault=nt,rt.parseIntOrDefault=function(e,t){var r=nt(e,t);return"number"==typeof r?Math.floor(r):r},rt.stringOrDefault=function(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t},rt.parseHttpHeaderName=function(e){if("string"==typeof e){return/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(e)?e:void 0}};var at={};Object.defineProperty(at,"__esModule",{value:!0}),at.searchParamsFromRecord=void 0,at.searchParamsFromRecord=function(e){for(var t=new URLSearchParams,r=0,n=Object.entries(e);r<n.length;r++){var a=k(n[r],2),i=a[0],o=a[1];t.append(i,o)}return t};var it={},ot={};Object.defineProperty(ot,"__esModule",{value:!0}),ot.JweFactory=void 0;var st=function(){return d((function e(t){h(this,e),this.jose=t}),[{key:"encrypt",value:(t=l(s().mark((function e(t,r){var n,a,i,o,c=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>2&&void 0!==c[2]?c[2]:"A128CBC-HS256",a=this.jose.base64url.decode(r),i=(new TextEncoder).encode(t),e.next=1,new this.jose.CompactEncrypt(i).setProtectedHeader({alg:"dir",enc:n}).encrypt(a);case 1:return o=e.sent,e.abrupt("return",o);case 2:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"decrypt",value:(e=l(s().mark((function e(t,r){var n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.jose.base64url.decode(r),e.next=1,this.jose.compactDecrypt(t,n,{keyManagementAlgorithms:["dir"],contentEncryptionAlgorithms:["A256GCM","A128CBC-HS256"]});case 1:return a=e.sent,i=a.plaintext,e.abrupt("return",(new TextDecoder).decode(i));case 2:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}],[{key:"isJweEncrypted",value:function(e){return 5===e.split(".").length&&e.includes("..")}}]);var e,t}();ot.JweFactory=st;var ct=se&&se.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),ut=se&&se.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),lt=se&&se.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&ct(t,e,r);return ut(t,e),t};Object.defineProperty(it,"__esModule",{value:!0}),it.jwe=void 0,it.jwe=lt(ot);var ht,pt={};var dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.RequestView=dt.AbstractRequestView=void 0;var ft=rt,vt=function(){return d((function e(){h(this,e)}),[{key:"contentLength",get:function(){var e;return(0,ft.parseIntOrDefault)(null===(e=this.readHeader("content-length"))||void 0===e?void 0:e[0],{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"userAgent",get:function(){var e,t;return null!==(e=null===(t=this.readHeader("user-agent"))||void 0===t?void 0:t[0])&&void 0!==e?e:""}},{key:"contentType",get:function(){var e;return null===(e=this.readHeader("content-type"))||void 0===e?void 0:e[0]}},{key:"xForwardedFor",get:function(){var e;return null===(e=this.readHeader("x-forwarded-for"))||void 0===e?void 0:e[0]}},{key:"referer",get:function(){var e;return null===(e=this.readHeader("referer"))||void 0===e?void 0:e[0]}},{key:"accept",get:function(){var e;return null===(e=this.readHeader("accept"))||void 0===e?void 0:e[0]}},{key:"host",get:function(){var e;return null===(e=this.readHeader("host"))||void 0===e?void 0:e[0]}},{key:"getHttpMessageSignatureFields",value:(e=l(s().mark((function e(){var t,r,n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(t=this.readJoinedHeader("Signature"))){e.next=1;break}r=void 0,e.next=3;break;case 1:return e.next=2,this.sha256Hash(t);case 2:r=e.sent.toLowerCase().slice(0,12);case 3:return n=r,a=this.readJoinedHeader("Signature-Input"),i=this.readJoinedHeader("Signature-Agent"),e.abrupt("return",{httpMsgSigSha256:n,httpMsgSigInput:a,httpMsgSigAgent:i});case 4:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"readJoinedHeader",value:function(e){var t=this.readHeader(e).join(",");return""!==t?t:void 0}}]);var e}();dt.AbstractRequestView=vt;var yt=function(){function t(r,n){var a;return h(this,t),(a=e(this,t)).request=r,a.sha256Digest=n,a}return a(t,vt),d(t,[{key:"method",get:function(){return this.request.method}},{key:"url",get:function(){return new URL(this.request.url)}},{key:"getBody",value:(n=l(s().mark((function e(){var t,r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this._body){e.next=5;break}return e.next=1,this.request.clone().text();case 1:if(n=t=e.sent,!(r=null!==n)){e.next=2;break}r=void 0!==t;case 2:if(!r){e.next=3;break}a=t,e.next=4;break;case 3:a="";case 4:this._body=a;case 5:return e.abrupt("return",this._body);case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"readHeader",value:function(e){var t,r=null!==(t=this.request.headers.get(e))&&void 0!==t?t:void 0;return void 0!==r?[r]:[]}},{key:"sha256Hash",value:(r=l(s().mark((function e(t){var r,n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(new TextEncoder).encode(t),e.next=1,this.sha256Digest.digest("SHA-256",r);case 1:return n=e.sent,e.abrupt("return",Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})}]);var r,n}();dt.RequestView=yt;var gt={};Object.defineProperty(gt,"__esModule",{value:!0}),gt.ProtectorApiResponseView=gt.AbstractProtectorApiResponseView=void 0;var mt=rt,kt=function(){return d((function e(){h(this,e)}),[{key:"redirectHost",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-host"))||void 0===e?void 0:e[0]}},{key:"redirectLocation",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-location"))||void 0===e?void 0:e[0]}},{key:"redirectStatus",get:function(){var e;return null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0]}},{key:"redirectStatusCode",get:function(){var e,t=null===(e=this.readHeader("x-netacea-redirect-status"))||void 0===e?void 0:e[0];if(void 0!==t){var r=(0,mt.parseIntOrDefault)(t,{defaultValue:0,minValue:0,maxValue:Number.MAX_SAFE_INTEGER});return r>=300&&r<400?r:void 0}}},{key:"eventId",get:function(){var e;return null===(e=this.readHeader("x-netacea-event-id"))||void 0===e?void 0:e[0]}},{key:"sessionCookieMaxAge",get:function(){var e;return(0,mt.parseIntOrDefault)(null===(e=this.readHeader("x-netacea-mitata-expiry"))||void 0===e?void 0:e[0],{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"captchaCookieMaxAge",get:function(){var e,t=null===(e=this.readHeader("x-netacea-mitatacaptcha-expiry"))||void 0===e?void 0:e[0];return(0,mt.parseIntOrDefault)(t,{defaultValue:86400,minValue:0,maxValue:Number.MAX_SAFE_INTEGER})}},{key:"getProtectorCodes",value:function(e){var t,r,n,a,i,o,s,c,u;return{match:null!==(t=null!==(r=null===(n=this.readHeader("x-netacea-match"))||void 0===n?void 0:n[0])&&void 0!==r?r:null==e?void 0:e.match)&&void 0!==t?t:"0",mitigate:null!==(a=null!==(i=null===(o=this.readHeader("x-netacea-mitigate"))||void 0===o?void 0:o[0])&&void 0!==i?i:null==e?void 0:e.mitigate)&&void 0!==a?a:"0",captcha:null!==(s=null!==(c=null===(u=this.readHeader("x-netacea-captcha"))||void 0===u?void 0:u[0])&&void 0!==c?c:null==e?void 0:e.captcha)&&void 0!==s?s:"0"}}},{key:"getMonetisationRedirectLocation",value:function(e,t){var r=this.redirectLocation;if(void 0!==r)return r;var n=this.redirectHost;if(void 0!==n){var a=new URL("https://".concat(n));return a.pathname=e,a.search=t,a.toString()}}},{key:"getMonetisationRedirect",value:function(e,t){var r,n=this.getMonetisationRedirectLocation(e,t);if(void 0!==n)return{location:n,statusCode:null!==(r=this.redirectStatusCode)&&void 0!==r?r:303}}},{key:"getCaptchaJson",value:(e=l(s().mark((function e(t,r){var n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getBody();case 1:if(n=e.sent,void 0===(a=this.eventId)&&"string"==typeof n&&(i=JSON.parse(n),a=Ct(i)),void 0!==a){e.next=2;break}throw new Error("Could not resolve Tracking ID for captcha event.");case 2:return e.abrupt("return",St(t,r,a));case 3:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e}();gt.AbstractProtectorApiResponseView=kt;var bt,xt=function(){function t(r){var n;return h(this,t),(n=e(this,t)).response=r,n}return a(t,kt),d(t,[{key:"status",get:function(){return this.response.status}},{key:"getBody",value:(r=l(s().mark((function e(){var t,r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this._body){e.next=5;break}return e.next=1,this.response.clone().text();case 1:if(n=t=e.sent,!(r=null!==n)){e.next=2;break}r=void 0!==t;case 2:if(!r){e.next=3;break}a=t,e.next=4;break;case 3:a="";case 4:this._body=a;case 5:return e.abrupt("return",this._body);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"readHeader",value:function(e){var t;if("set-cookie"===(e=e.toLowerCase()))return this.response.headers.getSetCookie();var r=null!==(t=this.response.headers.get(e))&&void 0!==t?t:void 0;return void 0!==r?[r]:[]}}]);var r}();function St(e,t,r){var n="".concat(e,"?trackingId=").concat(r),a=void 0!==t?"https://".concat(t).concat(n):void 0;return JSON.stringify({captchaRelativeURL:n,captchaAbsoluteURL:a})}function Ct(e){if(null==e||"object"!==o(e))throw new Error("Response body is not a valid object!");var t=e.trackingId;if("string"!=typeof t||0===t.length)throw new Error("Response body does not contain a valid trackingId!");return t}function wt(){return bt||(bt=1,function(e){var t=se&&se.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=se&&se.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=se&&se.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&t(n,e,a);return r(n,e),n},i=se&&se.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.graphql=e.webcrypto=e.url=e.parsing=e.ingest=e.headers=e.configValidation=e.cookie=e.NetaceaCookieV3IssueReason=void 0;var s=ue;Object.defineProperty(e,"NetaceaCookieV3IssueReason",{enumerable:!0,get:function(){return s.NetaceaCookieV3IssueReason}}),e.cookie=a(le),e.configValidation=a(Ie),e.headers=a(Ae),e.ingest=a(ze),e.parsing=a(rt),e.url=a(at),e.webcrypto=a(it),e.graphql=a(function(){if(ht)return pt;ht=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.truncateLongFields=pt.parseGraphQl=pt.parseGraphQlRequestBody=pt.getGraphQLParserConfig=void 0;var e=wt();function t(e,t){var r,n,a=e.parserRegex;return null!==(r=null===(n=t.match(a))||void 0===n?void 0:n.groups)&&void 0!==r?r:{}}function r(e,t){for(var r,n,a=e.maxValueLength,i=0,o=Object.keys(t);i<o.length;i++){var s=o[i],c=t[s];t[s]=(n=a,(r=c).length<=n?r:r.slice(0,n)+"…")}return t}return pt.getGraphQLParserConfig=function(t){var r={includePaths:[],maxParsableBytes:e.parsing.parseIntOrDefault(null==t?void 0:t.maxParsableBytes,{defaultValue:1e6,minValue:1e3}),maxValueLength:e.parsing.parseIntOrDefault(null==t?void 0:t.maxValueLength,{defaultValue:256,minValue:8}),parserRegex:n(/^\s*(query|mutation|subscription)\s+([_A-Za-z][_0-9A-Za-z]+)?/,{OpType:1,OpName:2})};if(Array.isArray(null==t?void 0:t.includePaths)){var a,i=m(t.includePaths);try{for(i.s();!(a=i.n()).done;){var s=a.value;"string"==typeof s&&r.includePaths.push(s)}}catch(e){i.e(e)}finally{i.f()}}try{if((null==t?void 0:t.parserRegex)instanceof RegExp)r.parserRegex=null==t?void 0:t.parserRegex;else if("object"===o(null==t?void 0:t.parserRegex)){var c=null==t?void 0:t.parserRegex,u=c.regex,l=c.flags;"string"==typeof u&&(r.parserRegex=new RegExp(u,l))}}catch(e){}return r},pt.parseGraphQlRequestBody=function(e,n){var a,i;if(""===n)throw new Error("Netacea Error: Empty GraphQL body received");var s=JSON.parse(n);if("object"!==o(s))throw new Error("Netacea Error: Invalid GraphQL JSON");var c=v({},t(e,null!==(a=null==s?void 0:s.query)&&void 0!==a?a:"")),u=(null!==(i=null==s?void 0:s.operationName)&&void 0!==i?i:"").trim();return""!==u&&(c.OpName=u),r(e,c)},pt.parseGraphQl=t,pt.truncateLongFields=r,pt}()),i(dt,e),i(gt,e)}(ce)),ce}gt.ProtectorApiResponseView=xt;var It=wt(),At=function(){function t(r,n){var a;return h(this,t),y(a=e(this,t,[void 0===n?v(v({},r),{},{cookieEncryptionKey:void 0}):r]),"encryptionKeyBuffer",void 0),a.encryptionKeyBuffer=n,a}return a(t,It.cookie.AbstractCookieFactory),d(t,[{key:"encrypt",value:(i=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.encryptionKeyBuffer){e.next=1;break}throw new Error("F5CookieFactory.encrypt called without a configured encryption key");case 1:return e.abrupt("return",ae(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"decrypt",value:(n=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.encryptionKeyBuffer){e.next=1;break}throw new Error("F5CookieFactory.decrypt called without a configured encryption key");case 1:return e.abrupt("return",ie(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"hash",value:(r=l(s().mark((function e(t,r){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=S.createHmac("sha256",r)).update(t),e.abrupt("return",C.Buffer.from(n.digest("hex")).toString("base64"));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})},{key:"getRandomValues",value:function(e){return crypto.getRandomValues(e)}},{key:"isEncrypted",value:function(e){return ne(e)}}]);var r,n,i}(),Ot={},Nt={},Et={},Pt={};Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.API_VERSION=Pt.REGION=Pt.PAYLOAD_TYPE=Pt.STATE=void 0,Pt.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},Pt.PAYLOAD_TYPE="string",Pt.REGION="eu-west-1",Pt.API_VERSION="2013-12-02",Object.defineProperty(Et,"__esModule",{value:!0}),Et.signRequest=void 0;var _t=A,Tt=Pt;function Kt(e,t){for(var r=[],n=0;n<e.length;n+=t){var a=e.slice(n,n+t);r.push({Data:Buffer.from(JSON.stringify(a)).toString("base64"),PartitionKey:Date.now().toString()})}return r}Et.signRequest=function(e,t,r){var n=e.accessKeyId,a=e.secretAccessKey,i={Records:Kt(t,r),PartitionKey:Date.now().toString(),StreamName:e.streamName};return _t.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:Tt.REGION},{accessKeyId:n,secretAccessKey:a})},Object.defineProperty(Nt,"__esModule",{value:!0});var Rt=Et;function jt(e){return Vt.apply(this,arguments)}function Vt(){return(Vt=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e){setTimeout(e,t)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Mt=function(){return d((function e(t){var r=t.kinesisStreamName,n=t.kinesisAccessKey,a=t.kinesisSecretKey,i=t.maxLogAgeSeconds,o=t.logBatchSize,s=t.rampUpBatchSize,c=t.maxAwaitTimePerIngestCallMs;h(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.kinesisStreamName=r,this.kinesisAccessKey=n,this.kinesisSecretKey=a,this.maxAwaitTimePerIngestCallMs=c,void 0!==i&&i<this.maxLogAgeSeconds&&i>0&&(this.maxLogAgeSeconds=i),void 0!==o&&(this.maxLogBatchSize=o),this.logBatchSize=!0===s?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=l(s().mark((function e(t){var r,n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.logCache.length){e.next=1;break}return e.abrupt("return");case 1:return r=c(this.logCache),this.logCache=[],e.prev=2,n=(0,Rt.signRequest)({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},r,this.logBatchSize),e.next=3,t({headers:n.headers,host:"https://".concat(n.hostname),method:n.method,path:n.path,body:n.body});case 3:this.logBatchSize!==this.maxLogBatchSize&&(this.logBatchSize=Math.min(this.maxLogBatchSize,2*this.logBatchSize)),e.next=5;break;case 4:e.prev=4,i=e.catch(2),(a=this.logCache).push.apply(a,c(r)),console.error(i);case 5:case"end":return e.stop()}}),e,this,[[2,4]])}))),function(e){return t.apply(this,arguments)})},{key:"ingest",value:(e=l(s().mark((function e(t,r){var n,a,i=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.next=2;break}return(n=[]).push(this.putToKinesis(r)),void 0!==this.maxAwaitTimePerIngestCallMs&&n.push(jt(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(n);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,a=jt(1e3*this.maxLogAgeSeconds).then(l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,i.putToKinesis(r);case 1:i.intervalSet=!1;case 2:case"end":return e.stop()}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.next=3;break}return e.next=3,a;case 3:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t}();Nt.default=Mt,Object.defineProperty(Ot,"__esModule",{value:!0});var Ht,Lt=Nt,Dt=Ot.default=Lt.default,Bt={subtle:{digest:(Ht=l(s().mark((function e(t,r){var n,a,i,o,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=null!==(n={"SHA-256":"sha256","SHA-1":"sha1","SHA-384":"sha384","SHA-512":"sha512"}[t])&&void 0!==n?n:t.toLowerCase().replace("-",""),i=r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),o=new Uint8Array(i),c=_.createHash(a).update(o).digest(),e.abrupt("return",c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return Ht.apply(this,arguments)})}},Ft=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,qt=/^\/[a-zA-Z0-9/]*$/;function zt(e,t,r){return void 0!==r&&""!==r&&(function(e){var t=e,r=t.indexOf("//");if(-1!==r){var n=(t=t.substring(r+2)).indexOf("/");if(-1===n)return"/";t=t.substring(n)}var a=t.indexOf("?");return-1!==a&&(t=t.substring(0,a)),t}(e)===r&&"get"===t.toLowerCase())}function Gt(e){var t=function(e,t){var r=e.indexOf("?");if(-1!==r)for(var n=e.substring(r+1).split("&"),a=0;a<n.length;a++){var i=n[a].split("=");if(i[0]===t)return void 0!==i[1]?decodeURIComponent(i[1]):void 0}}(e,"trackingId");return void 0!==t&&Ft.test(t)?t:null}function Ut(e){if(void 0===e)return"text/html";var t=e.toLowerCase(),r=t.includes("text/html")||t.includes("application/html"),n=t.includes("application/json");return!r&&n?"application/json":"text/html"}function Jt(e,t,r){if(void 0===e||""===e)return"";var n;try{n=JSON.parse(e)}catch(e){return""}if(!function(e){if(null==e)return!1;var t=e;return void 0!==t.captchaSiteKey&&void 0!==t.trackingId&&void 0!==t.captchaURL}(n))return"";var a=r+"?trackingId="+n.trackingId,i="https://"+t+a;return JSON.stringify({captchaRelativeURL:a,captchaAbsoluteURL:i})}var Xt=Q.cookie.attributes.configureCookiesDomain,Wt=Q.cookie.netaceaSession,$t=Wt.createNetaceaSetCookieString,Yt=Wt.createNetaceaCaptchaSetCookieString,Qt=function(){return d((function e(t){var r,n,a=t.apiKey,i=t.secretKey,o=t.timeout,s=void 0===o?3e3:o,c=t.mitigationServiceUrl,u=void 0===c?"https://mitigations.netacea.net":c,l=t.ingestServiceUrl,p=void 0===l?"https://ingest.netacea.net":l,d=t.mitigationType,f=void 0===d?E.INGEST:d,g=t.captchaSiteKey,m=t.captchaSecretKey,k=t.ingestType,b=void 0===k?N.HTTP:k,x=t.kinesis,S=t.mitataCookieExpirySeconds,C=t.netaceaCookieExpirySeconds,w=t.netaceaCookieName,I=t.netaceaCaptchaCookieName,A=t.netaceaCookieAttributes,O=t.netaceaCaptchaCookieAttributes;if(h(this,e),y(this,"mitataCookieExpirySeconds",void 0),y(this,"apiKey",void 0),y(this,"secretKey",void 0),y(this,"mitigationServiceUrl",void 0),y(this,"ingestServiceUrl",void 0),y(this,"timeout",void 0),y(this,"captchaSiteKey",void 0),y(this,"captchaSecretKey",void 0),y(this,"ingestType",void 0),y(this,"kinesis",void 0),y(this,"mitigationType",void 0),y(this,"encryptedCookies",[]),y(this,"netaceaCookieName",void 0),y(this,"netaceaCaptchaCookieName",void 0),y(this,"netaceaCookieAttributes",void 0),y(this,"netaceaCaptchaCookieAttributes",void 0),y(this,"cookieFactory",void 0),null==a)throw new Error("apiKey is a required parameter");this.apiKey=a,this.secretKey=i,this.mitigationServiceUrl=u,this.ingestServiceUrl=p,this.mitigationType=f,this.ingestType=null!=b?b:N.HTTP,this.ingestType===N.KINESIS&&(void 0===x?console.warn("NETACEA WARN: no kinesis args provided, when ingestType is ".concat(this.ingestType)):this.kinesis=new Dt(v(v({},x),{},{apiKey:this.apiKey}))),void 0===g&&void 0===m||(this.captchaSiteKey=g,this.captchaSecretKey=m),this.timeout=function(e){return e<=0?R:e}(s),this.netaceaCookieName=tr(w,"_mitata"),this.netaceaCaptchaCookieName=tr(I,"_mitatacaptcha"),this.encryptedCookies=[this.netaceaCookieName,this.netaceaCaptchaCookieName],this.mitataCookieExpirySeconds=function(e,t){return void 0===t?e===E.INGEST?3600:60:t}(f,null!=C?C:S);var P=Xt(null!=A?A:"",null!=O?O:"");this.netaceaCookieAttributes=null!==(r=P.cookieAttributes)&&void 0!==r?r:"",this.netaceaCaptchaCookieAttributes=null!==(n=P.captchaCookieAttributes)&&void 0!==n?n:""}),[{key:"runMitigation",value:(S=l(s().mark((function e(t){var r,n,a,i,o;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,i=this.mitigationType,e.next=i===E.MITIGATE?1:i===E.INJECT?3:i===E.INGEST?5:7;break;case 1:return e.next=2,this.mitigate(t);case 2:case 4:case 6:return e.abrupt("return",e.sent);case 3:return e.next=4,this.inject(t);case 5:return e.next=6,this.processIngest(t);case 7:throw new Error("Netacea Error: Mitigation type ".concat(this.mitigationType," not recognised"));case 8:e.next=10;break;case 9:return e.prev=9,o=e.catch(0),console.error("Netacea FAILOPEN Error:",o),r=t,n=this.isUrlCaptchaPost(r.url,r.method),a=this.mitigationType===E.MITIGATE,e.abrupt("return",{injectHeaders:{"x-netacea-captcha":"0","x-netacea-match":"0","x-netacea-mitigate":"0"},sessionStatus:a&&n?"error_open":""});case 10:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(e){return S.apply(this,arguments)})},{key:"readCookie",value:(x=l(s().mark((function e(t,r){var n,a,i,o,c,u,l;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=r){e.next=1;break}return e.abrupt("return",void 0);case 1:if("string"!=typeof r){e.next=3;break}return e.next=2,this.readCookie(t,r.split(";"));case 2:return e.abrupt("return",e.sent);case 3:n="".concat(t,"="),a=m(r),e.prev=4,a.s();case 5:if((i=a.n()).done){e.next=11;break}if(o=i.value,!(c=o.split(";")[0].trimStart()).startsWith(n)){e.next=10;break}if(u=c.slice(n.length),!this.encryptedCookies.includes(t)){e.next=9;break}return e.prev=6,e.next=7,this.decryptCookieValue(u);case 7:return e.abrupt("return",e.sent);case 8:return e.prev=8,e.catch(6),e.abrupt("return",void 0);case 9:return e.abrupt("return",u);case 10:e.next=5;break;case 11:e.next=13;break;case 12:e.prev=12,l=e.catch(4),a.e(l);case 13:return e.prev=13,a.f(),e.finish(13);case 14:return e.abrupt("return",void 0);case 15:case"end":return e.stop()}}),e,this,[[4,12,13,14],[6,8]])}))),function(e,t){return x.apply(this,arguments)})},{key:"callIngest",value:(b=l(s().mark((function e(t){var r,n,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.constructWebLog(t),this.ingestType!==N.KINESIS){e.next=5;break}if(void 0!==this.kinesis){e.next=1;break}return console.error("Netacea Error: Unable to log as Kinesis has not been defined."),e.abrupt("return");case 1:return e.prev=1,e.next=2,this.kinesis.ingest(v(v({},r),{},{apiKey:this.apiKey}),this.makeRequest.bind(this));case 2:e.next=4;break;case 3:e.prev=3,i=e.catch(1),console.error("NETACEA Error: ",i.message);case 4:e.next=7;break;case 5:return n={"X-Netacea-API-Key":this.apiKey,"content-type":"application/json"},e.next=6,this.makeIngestApiCall(n,r);case 6:if(200===(a=e.sent).status){e.next=7;break}throw this.APIError(a);case 7:case"end":return e.stop()}}),e,this,[[1,3]])}))),function(e){return b.apply(this,arguments)})},{key:"makeIngestApiCall",value:(k=l(s().mark((function e(t,r){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.makeRequest({host:this.ingestServiceUrl,method:"POST",path:"/",headers:t,body:JSON.stringify(r),timeout:this.timeout});case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"constructV1WebLog",value:function(e){var t=e.ip,r=e.userAgent,n=e.status,a=e.method,i=e.path,o=e.protocol,s=e.referer,c=e.bytesSent,u=e.requestTime,l=e.mitataCookie,h=e.sessionStatus,p=e.integrationType,d=e.integrationVersion,f=e.headerFingerprint,v=(new Date).toUTCString();return{Request:"".concat(a," ").concat(i," ").concat(o),TimeLocal:v,RealIp:t,UserAgent:r,Status:n,RequestTime:null==u?void 0:u.toString(),BytesSent:null==c?void 0:c.toString(),Referer:""===s?"-":s,NetaceaUserIdCookie:null!=l?l:"",NetaceaMitigationApplied:null!=h?h:"",IntegrationType:null!=p?p:"",IntegrationVersion:null!=d?d:"",HeaderHash:null!=f?f:""}}},{key:"constructWebLog",value:function(e){return e.bytesSent=""===e.bytesSent?"0":e.bytesSent,this.constructV1WebLog(e)}},{key:"check",value:(g=l(s().mark((function e(t,r,n,a,i,o,c){var u,l,h,p,d,f,y,g,m,k,b,x,S,C,w;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this.cookieFactory){e.next=2;break}return e.next=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:C=e.sent,e.next=3;break;case 2:C=J(t,r,null!==(u=this.secretKey)&&void 0!==u?u:"");case 3:if((k=C).isPrimaryHashValid&&!k.requiresReissue){e.next=6;break}return b=void 0!==k.mitata?k.mitata.userId:void 0,x=er(k),e.next=4,this.makeMitigateAPICall(b,r,n,a,i,o,x);case 4:return S=e.sent,l=S.status,h=S.match,p=S.mitigate,d=S.captcha,f=S.body,e.next=5,this.createMitata(r,b,h,p,d,S.mitataMaxAge,void 0,x);case 5:w=e.sent,y=[w],g=S.eventId,"5"===p&&void 0!==c&&(m=this.computeMonetisationRedirect(c,S.redirectHost,S.redirectLocation,S.redirectStatus)),e.next=7;break;case 6:l=-1,h=k.match,p=k.mitigate,d=k.captcha,f=void 0,y=[];case 7:return e.abrupt("return",v(v({},this.composeResult(f,y,l,h,p,d,!1,g)),{},{redirect:m}));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a,i,o){return g.apply(this,arguments)})},{key:"computeMonetisationRedirect",value:function(e,t,r,n){var a=void 0!==n?parseInt(n,10):NaN,i=!isNaN(a)&&a>=300&&a<400?a:303;if(void 0!==r)return{location:r,statusCode:i};if(void 0!==t){var o=e.replace(/^https?:\/\/[^/]+/,"");return{location:"https://".concat(t).concat(""!==o?o:"/"),statusCode:i}}}},{key:"createMitata",value:(f=l(s().mark((function e(t,r,n,a,i){var o,c,u,l,h,p,d,f,v,y,g=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=g.length>5&&void 0!==g[5]?g[5]:86400,c=g.length>6&&void 0!==g[6]?g[6]:void 0,u=g.length>7&&void 0!==g[7]?g[7]:P.NO_SESSION,l=["1","3","5"].includes(i),h="3"===a,p="5"===a,d=l||h||p?-60:this.mitataCookieExpirySeconds,void 0===this.cookieFactory){e.next=2;break}return e.next=1,this.cookieFactory.createCookieValue({clientIP:t,userId:r,match:n,mitigate:a,captcha:i,gracePeriod:d,cookieId:z(),issueReason:u});case 1:f=e.sent,e.next=4;break;case 2:if(void 0!==this.secretKey){e.next=3;break}throw new Error("Cannot build cookie without secret key.");case 3:v=null!=c?c:Math.floor(Date.now()/1e3)+d,y=[n,a,i].join(""),f=G(t,r,v,this.secretKey,y);case 4:return e.abrupt("return",$t({cookieName:this.netaceaCookieName,cookieValue:f,maxAgeAttribute:String(o),otherAttributes:this.netaceaCookieAttributes}));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return f.apply(this,arguments)})},{key:"processCaptcha",value:(p=l(s().mark((function e(t,r,n,a,i){var o,c,u,l,h,p,d,f,v,y;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this.cookieFactory){e.next=2;break}return e.next=1,this.cookieFactory.retrieveCookieInfo(t,r);case 1:y=e.sent,e.next=3;break;case 2:y=J(t,r,null!==(o=this.secretKey)&&void 0!==o?o:"");case 3:return c=er(y),e.next=4,this.makeCaptchaAPICall(t,r,n,a,i,c);case 4:return u=e.sent,l=u.status,h=u.match,p=u.mitigate,d=u.captcha,f=u.body,v=u.setCookie,e.abrupt("return",this.composeResult(f,v,l,h,p,d,!0));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return p.apply(this,arguments)})},{key:"getMitataCaptchaFromHeaders",value:(u=l(s().mark((function e(t){var r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Object.prototype.hasOwnProperty.call(t,L.netaceaHeaders.mitataCaptcha)){e.next=3;break}if(r=t[L.netaceaHeaders.mitataCaptcha],Array.isArray(r)&&(r=r[0]),null!=r&&""!==r){e.next=1;break}return e.abrupt("return",void 0);case 1:return n=parseInt(t[L.netaceaHeaders.mitataCaptchaExpiry]),e.next=2,this.encryptCookieValue(r);case 2:return a=e.sent,e.abrupt("return",Yt({cookieName:this.netaceaCaptchaCookieName,cookieValue:a,maxAgeAttribute:String(isNaN(n)?86400:n),otherAttributes:this.netaceaCaptchaCookieAttributes}));case 3:return e.abrupt("return",void 0);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"makeCaptchaAPICall",value:(c=l(s().mark((function e(t,r,n,a,i){var o,c,u,l,h,p=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=p.length>5&&void 0!==p[5]?p[5]:P.NO_SESSION,c={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},void 0!==(u=q(t))&&(c["X-Netacea-UserId"]=u.userId),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(c["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,c["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),l={},"string"==typeof i&&""!==i&&(l.headerFP=i),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/AtaVerifyCaptcha",headers:c,method:"POST",body:a,timeout:this.timeout,params:l});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,null==u?void 0:u.userId,r,o);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return c.apply(this,arguments)})},{key:"getApiCallResponseFromResponse",value:(o=l(s().mark((function e(t,r,n){var a,i,o,c,u,l,h,p,d,f,v,y,g,m,k,b,x,S,C,w,I,A,O=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f=O.length>3&&void 0!==O[3]?O[3]:P.NO_SESSION,200===t.status){e.next=1;break}throw this.APIError(t);case 1:return v=null!==(a=null===(i=t.headers[L.netaceaHeaders.match])||void 0===i?void 0:i.toString())&&void 0!==a?a:"0",y=null!==(o=null===(c=t.headers[L.netaceaHeaders.mitigate])||void 0===c?void 0:c.toString())&&void 0!==o?o:"0",g=null!==(u=null===(l=t.headers[L.netaceaHeaders.captcha])||void 0===l?void 0:l.toString())&&void 0!==u?u:"0",m=parseInt(t.headers[L.netaceaHeaders.mitataExpiry]),isNaN(m)&&(m=86400),e.next=2,this.createMitata(n,r,v,y,g,86400,void 0,f);case 2:return k=e.sent,e.next=3,this.getMitataCaptchaFromHeaders(t.headers);case 3:return b=e.sent,x=[k,b].filter((function(e){return void 0!==e})),S=t.body,C=t.headers[L.netaceaHeaders.eventId],w=null===(h=t.headers["x-netacea-redirect-host"])||void 0===h?void 0:h.toString(),I=null===(p=t.headers["x-netacea-redirect-location"])||void 0===p?void 0:p.toString(),A=null===(d=t.headers["x-netacea-redirect-status"])||void 0===d?void 0:d.toString(),e.abrupt("return",{status:t.status,match:v,mitigate:y,captcha:g,setCookie:x,body:S,eventId:C,mitataMaxAge:m,redirectHost:w,redirectLocation:I,redirectStatus:A});case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"buildCookieHeader",value:function(e){var t="",r="";for(var n in e){var a=e[n];void 0!==a&&(t="".concat(t).concat(r).concat(n,"=").concat(a),r="; ")}return t}},{key:"makeMitigateAPICall",value:(i=l(s().mark((function e(t,r,n,a,i,o){var c,u,l,h,p=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=p.length>6&&void 0!==p[6]?p[6]:P.NO_SESSION,u={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":n,cookie:this.buildCookieHeader({_mitatacaptcha:a})},void 0!==t&&(u["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(u["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,u["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),void 0!==o&&(u["X-Netacea-Captcha-Content-Type"]=o),l={},"string"==typeof i&&""!==i&&(l.headerFP=i),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/",headers:u,method:"GET",timeout:this.timeout,params:l});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,t,r,c);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a,o){return i.apply(this,arguments)})},{key:"composeResult",value:function(e,t,r,n,a,i,o,s){var c=this.findBestMitigation(n,a,i,o),u={body:e,apiCallStatus:r,setCookie:t,sessionStatus:c.sessionStatus,mitigation:c.mitigation,mitigated:[L.mitigationTypes.block,L.mitigationTypes.captcha,L.mitigationTypes.captchaPass].includes(c.mitigation)};if(this.mitigationType===E.INJECT){var l={"x-netacea-match":c.parts.match.toString(),"x-netacea-mitigate":c.parts.mitigate.toString(),"x-netacea-captcha":c.parts.captcha.toString()};void 0!==s&&(l["x-netacea-event-id"]=s),u.injectHeaders=l}return u}},{key:"findBestMitigation",value:function(e,t,r,n){var a,i,o="unknown";n||("2"===r?r="4":"3"===r&&(r="5"));var s=null!==(a=L.matchMap[e])&&void 0!==a?a:o+"_";s+=null!==(i=L.mitigateMap[t])&&void 0!==i?i:o;var c=L.bestMitigationMap[t];if("0"!==r){var u;s+=","+(null!==(u=L.captchaMap[r])&&void 0!==u?u:o);var l=L.bestMitigationCaptchaMap[r];void 0!==l&&(c=l)}return this.mitigationType===E.INJECT&&(c=L.mitigationTypes.none),{sessionStatus:s,mitigation:c,parts:{match:e,mitigate:t,captcha:r}}}},{key:"APIError",value:function(e){var t="Unknown error";switch(e.status){case 403:t="Invalid credentials";break;case 500:t="Server error";break;case 502:t="Bad Gateway";break;case 503:t="Service Unavailable";break;case 400:t="Invalid request"}return new Error("Error reaching Netacea API (".concat(t,"), status: ").concat(e.status))}},{key:"isUrlCaptchaPost",value:function(e,t){return e.includes("/AtaVerifyCaptcha")&&"post"===t.toLowerCase()}},{key:"processMitigateRequest",value:(a=l(s().mark((function e(t,r,n){var a,i,o,c,u,l,h;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isUrlCaptchaPost(t.url,t.method)){e.next=2;break}return i=this,o=t.mitata,c=t.clientIp,u=t.userAgent,e.next=1,t.getBodyFn();case 1:l=e.sent,h=r,a=i.processCaptcha.call(i,o,c,u,l,h),e.next=3;break;case 2:a=this.check(t.mitata,t.clientIp,t.userAgent,t.mitataCaptcha,r,n,t.url);case 3:return e.next=4,a;case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"setIngestOnlyMitataCookie",value:(n=l(s().mark((function e(t){var r,n,a=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:P.NO_SESSION,e.next=1,this.createMitata(D,t,"0","0","0",86400,void 0,r);case 1:return n=e.sent,e.abrupt("return",{sessionStatus:"",setCookie:[n]});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"processIngest",value:(r=l(s().mark((function e(t){var r,n,a,i,o,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.getCookieHeader(t),e.next=1,this.readCookie(this.netaceaCookieName,n);case 1:if(a=e.sent,void 0===this.cookieFactory){e.next=3;break}return e.next=2,this.cookieFactory.retrieveCookieInfo(a,D);case 2:c=e.sent,e.next=4;break;case 3:c=J(a,D,null!==(r=this.secretKey)&&void 0!==r?r:"");case 4:if((i=c).isPrimaryHashValid){e.next=6;break}return e.next=5,this.setIngestOnlyMitataCookie(void 0,er(i));case 5:return e.abrupt("return",e.sent);case 6:if(!i.requiresReissue){e.next=8;break}return o=void 0!==i.mitata?i.mitata.userId:void 0,e.next=7,this.setIngestOnlyMitataCookie(o,er(i));case 7:return e.abrupt("return",e.sent);case 8:return e.abrupt("return",{sessionStatus:"",setCookie:[]});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"encryptCookieValue",value:(t=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"decryptCookieValue",value:(e=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,r,n,a,i,o,c,u,p,f,g,k,b,x,S}(),Zt=function(){function t(r){var n,a,i,o,s;h(this,t),y(s=e(this,t,[r]),"httpsAgent",void 0),y(s,"mitataCookieName",void 0),y(s,"mitataCaptchaCookieName",void 0),y(s,"hashGenerator",void 0),y(s,"debugMode",void 0),y(s,"encryptionEnabled",!1),y(s,"encryptionKeyBuffer",void 0),y(s,"mitigationHeaders",["cookie","user-agent","accept","host"]),y(s,"netaceaCaptchaPath",void 0),y(s,"captchaHost",void 0),y(s,"enableCaptchaContentNegotiation",void 0),s.httpsAgent=new T.Agent({timeout:s.timeout,keepAlive:!0,maxSockets:null!==(n=r.maxSockets)&&void 0!==n?n:25}),s.mitataCookieName=null!==(a=r.netaceaCookieName)&&void 0!==a?a:"_mitata",s.mitataCaptchaCookieName=null!==(i=r.netaceaCaptchaCookieName)&&void 0!==i?i:"_mitatacaptcha";var c=function(){return d((function e(){h(this,e)}),[{key:"encode",value:function(e){return new Uint8Array(Buffer.from(e,"utf8"))}}])}();if(s.hashGenerator=new Z(Bt,c),s.debugMode=null!==(o=r.debugMode)&&void 0!==o&&o,s.netaceaCaptchaPath=function(e){if(null!=e&&""!==e)return"/"!==e[0]&&(e="/"+e),qt.test(e)?e:void 0}(r.netaceaCaptchaPath),s.captchaHost=r.captchaHost,s.enableCaptchaContentNegotiation=!0===r.enableCaptchaContentNegotiation,void 0!==r.cookieEncryptionKey){var u=function(e){if(null==e||""===e)return{valid:!1,error:"key is empty"};if(!/^[A-Za-z0-9_-]+$/.test(e))return{valid:!1,error:"key contains invalid base64url characters"};var t;try{t=te(e)}catch(e){return{valid:!1,error:"key is not valid base64url"}}return 32!==t.length?{valid:!1,error:"key must be ".concat(32," bytes (256 bits), got ").concat(t.length," bytes")}:{valid:!0,keyBuffer:t}}(r.cookieEncryptionKey);u.valid&&void 0!==u.keyBuffer?(s.encryptionKeyBuffer=u.keyBuffer,s.encryptionEnabled=!0):console.warn("NETACEA WARN: Invalid cookieEncryptionKey - ".concat(u.error,". Cookies will not be encrypted."))}return s.cookieFactory=new At({cookieEncryptionKey:r.cookieEncryptionKey,secretKey:r.secretKey,expirySeconds:s.mitataCookieExpirySeconds},s.encryptionEnabled&&void 0!==s.encryptionKeyBuffer?s.encryptionKeyBuffer:void 0),s}return a(t,Qt),d(t,[{key:"computeHeaderFingerprint",value:(g=l(s().mark((function e(t){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t&&""!==t){e.next=1;break}return e.abrupt("return","");case 1:return r=t.split(","),e.next=2,this.hashGenerator.hashHeaders(r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"handleGetCaptchaRequest",value:(v=l(s().mark((function e(t,r,n,a,i,o,c){var u,l,h,p,d,f,v,y,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=Gt(o),l=this.enableCaptchaContentNegotiation?Ut(i):"text/html",h={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":t,"user-agent":r,cookie:void 0!==n?"_mitatacaptcha="+n:"","X-Netacea-Captcha-Content-Type":l},void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(h["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,h["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),p={netaceaHeaders:"request-id"},"string"==typeof a&&""!==a&&(p.headerFP=a),null!==u&&(p.trackingId=u),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/captcha",headers:h,method:"GET",timeout:this.timeout,params:p});case 1:if(200===(d=e.sent).status){e.next=2;break}throw this.APIError(d);case 2:return f=d.body,"application/json"===l&&void 0!==this.netaceaCaptchaPath&&void 0!==f&&(g=null!==(v=null!==(y=this.captchaHost)&&void 0!==y?y:c)&&void 0!==v?v:"",f=Jt(f,g,this.netaceaCaptchaPath)),e.abrupt("return",{body:f,apiCallStatus:d.status,setCookie:[],sessionStatus:",captcha_serve",mitigation:"captcha",mitigated:!0});case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a,i,o){return v.apply(this,arguments)})},{key:"encryptCookieValue",value:(f=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.next=1;break}return e.abrupt("return",t);case 1:return e.abrupt("return",ae(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"decryptCookieValue",value:(p=l(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.encryptionEnabled&&void 0!==this.encryptionKeyBuffer){e.next=1;break}return e.abrupt("return",t);case 1:if(ne(t)){e.next=2;break}throw new Error("Cookie is not JWE encrypted");case 2:return e.abrupt("return",ie(t,this.encryptionKeyBuffer));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getInjectHeaders",value:function(e){if(this.mitigationType===E.INJECT){var t=e;if(void 0!==t.injectHeaders){var r={},n=t.injectHeaders;return r["x-netacea-match"]=n["x-netacea-match"],r["x-netacea-mitigate"]=n["x-netacea-mitigate"],r["x-netacea-captcha"]=n["x-netacea-captcha"],void 0!==n["x-netacea-event-id"]&&(r["x-netacea-event-id"]=n["x-netacea-event-id"]),this.encodeHeadersAsKeyValueList(r)}}return[]}},{key:"registerPolicyHandler",value:function(e){var t=this;e.addMethod("getMitigationHeaderPolicy",(function(e,r){var n=t.mitigationHeaders.join(",");console.info('level=info component=f5 handler=getMitigationHeaderPolicy policy="'.concat(n,'"')),r.reply(n)}))}},{key:"encodeHeadersAsKeyValueList",value:function(e){for(var t=[],r=0,n=Object.entries(e);r<n.length;r++){var a=k(n[r],2),i=a[0],o=a[1];if(Array.isArray(o)){var s,c=m(o);try{for(c.s();!(s=c.n()).done;){var u=s.value;t.push(i,Buffer.from(u).toString("base64"))}}catch(e){c.e(e)}finally{c.f()}}else t.push(i,Buffer.from(o).toString("base64"))}return t}},{key:"registerMitigateHandler",value:function(e){var t=this;e.addMethod("handleRequest",function(){var e=l(s().mark((function e(r,n){var a,i,o,c,u,l,h,p,d,f,v,y,g,m,b,x,S,C,w,I,A,O,N,E,P,_,T,K,R,j,V,M,H;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.params(),c=k(o,3),u=c[0],l=c[1],h=c[2],p=t.getArrayValueOrDefault(o,3,void 0),d=t.getArrayValueOrDefault(o,4,void 0),f=t.getArrayValueOrDefault(o,5,void 0),v=t.parseHeaderValues(f),y=null!==(a=v.cookie)&&void 0!==a?a:null,g=null!==(i=v["user-agent"])&&void 0!==i?i:"",m=v.accept,e.prev=1,e.next=2,t.computeHeaderFingerprint(d);case 2:return S=e.sent,t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=header_fingerprint method="'.concat(l,'" path="').concat(h,'" headers="').concat(null!=d?d:"",'" header_count=').concat(null!==(C=null==d?void 0:d.split(",").length)&&void 0!==C?C:0,' fingerprint="').concat(S,'"')),e.next=3,t.getMitataCookies(y);case 3:return w=e.sent,I=k(w,2),A=I[0],O=I[1],t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=mitigation_request headerFP="'.concat(S,'"')),e.next=4,t.runMitigation({ip:u,method:l,url:h,mitataCaptchaCookie:O,mitataCookie:A,userAgent:g,body:p,headerFingerprint:S,acceptHeader:m,hostHeader:v.host});case 4:if(N=e.sent,E="",(zt(h,l,t.netaceaCaptchaPath)||void 0!==t.netaceaCaptchaPath&&"captcha"===(null==N||null===(b=N.response)||void 0===b?void 0:b.mitigation))&&(E=t.enableCaptchaContentNegotiation&&"application/json"===Ut(m)?"application/json":"text/html; charset=UTF-8"),"error_open"!==(null==N?void 0:N.sessionStatus)){e.next=5;break}return n.reply(["",500,"error_open",!0,"",S,[],[],500]),e.abrupt("return");case 5:if(void 0!==N){e.next=6;break}return n.reply(["",0,"",!1,"",S,[],[],0]),e.abrupt("return");case 6:P="",_=0,T=!1,K=0,R=t.getValueOrDefault(A,""),void 0!==N.setCookie&&N.setCookie.length>0&&void 0!==(j=N.setCookie.find((function(e){return e.includes("".concat(t.netaceaCookieName,"="))})))&&(R=j.split(";")[0].replace("".concat(t.netaceaCookieName,"="),"")),void 0!==N.response&&(_=t.getValueOrDefault(N.response.apiCallStatus,0),P=t.getValueOrDefault(N.response.body,"Forbidden"),T=t.getValueOrDefault(N.response.mitigated,T),K=t.getValueOrDefault(N.response.status,403)),V={},void 0!==N.setCookie&&N.setCookie.length>0&&(V["Set-Cookie"]=N.setCookie),""!==E&&(V["Content-Type"]=E),void 0!==(M=null===(x=N.response)||void 0===x?void 0:x.redirect)&&(V.Location=M.location),n.reply([P,_,t.getValueOrDefault(N.sessionStatus,""),T,t.getValueOrDefault(R,""),S,t.getInjectHeaders(N),t.encodeHeadersAsKeyValueList(V),K]),e.next=8;break;case 7:e.prev=7,H=e.catch(1),console.error("Could not reach Netacea mitigation API: ",H.message),n.reply(["",0,"",!1,"","",[],[],0]);case 8:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"parseHeaderValues",value:function(e){var t={};if(void 0===e||""===e)return t;for(var r=e.split(","),n=0;n<this.mitigationHeaders.length&&n<r.length;n++)t[this.mitigationHeaders[n].toLowerCase()]=Buffer.from(r[n],"base64").toString("utf8");return t}},{key:"getValueOrDefault",value:function(e,t){return null!=e?e:t}},{key:"getArrayValueOrDefault",value:function(e,t,r){var n;return null!==(n=e[t])&&void 0!==n?n:r}},{key:"getMitataCookies",value:(u=l(s().mark((function e(t){var r,n,a;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null==t?void 0:t.split("; "),n=this.getCookie(this.mitataCookieName,r),a=this.getCookie(this.mitataCaptchaCookieName,r),void 0===n){e.next=4;break}return e.prev=1,e.next=2,this.decryptCookieValue(n);case 2:n=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),n=void 0;case 4:if(void 0===a){e.next=8;break}return e.prev=5,e.next=6,this.decryptCookieValue(a);case 6:a=e.sent,e.next=8;break;case 7:e.prev=7,e.catch(5),a=void 0;case 8:return e.abrupt("return",[n,a]);case 9:case"end":return e.stop()}}),e,this,[[1,3],[5,7]])}))),function(e){return u.apply(this,arguments)})},{key:"getCookie",value:function(e,t){var r;return null==t||null===(r=t.find((function(t){return t.includes("".concat(e,"="))})))||void 0===r?void 0:r.replace("".concat(e,"="),"")}},{key:"registerIngestHandler",value:function(e){var t=this;e.addMethod("ingest",function(){var e=l(s().mark((function e(r,n){var a,i,o,c,u,l,h,p,d,f,v,y,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.params(),o=t.getArrayValueOrDefault(i,0,""),c=t.getArrayValueOrDefault(i,1,""),u=t.getArrayValueOrDefault(i,2,"-1"),l=t.getArrayValueOrDefault(i,3,""),h=t.getArrayValueOrDefault(i,4,""),p=t.getArrayValueOrDefault(i,5,""),d=t.getArrayValueOrDefault(i,6,""),f=t.getArrayValueOrDefault(i,7,"0"),v=t.getArrayValueOrDefault(i,8,"0"),a=t.getArrayValueOrDefault(i,9,""),y=t.getArrayValueOrDefault(i,10,""),g=t.getArrayValueOrDefault(i,11,""),t.debugMode&&console.info('level=debug component=f5 handler=ingest event=ingest_request ingestType="'.concat(t.ingestType,'" headerFingerprint="').concat(g,'"')),void 0===a){e.next=4;break}return e.prev=1,e.next=2,t.decryptCookieValue(a);case 2:a=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),a=void 0;case 4:t.ingest({ip:o,userAgent:c,status:u,method:l,path:h,protocol:p,referer:d,bytesSent:f,requestTime:v,mitataCookie:a,sessionStatus:y,headerFingerprint:g}).catch((function(e){console.error("Could not reach Netacea ingest API: "+e.message)})),n.reply("done");case 5:case"end":return e.stop()}}),e,null,[[1,3]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"makeRequest",value:(c=l(s().mark((function e(t){var r=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e,n){t.host=t.host.replace("https://","");var a=t.path;if(void 0!==t.params){var i=t.params instanceof URLSearchParams?t.params.toString():K.stringify(t.params);""!==i&&(a+=(a.includes("?")?"&":"?")+i)}for(var o=T.request({agent:r.httpsAgent,host:t.host,path:a,headers:t.headers,method:t.method,body:t.body},(function(t){var r="";t.on("data",(function(e){r+=e})),t.on("end",(function(){var n;e({headers:t.headers,status:null!==(n=t.statusCode)&&void 0!==n?n:0,body:""===r?void 0:r})}))})),s=0,c=["error","abort","timeout"];s<c.length;s++){var u=c[s];o.on(u,(function(e){n(e),o.destroyed||o.destroy()}))}"post"===t.method.toLowerCase()&&o.write(t.body),o.end()}));case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)}))),function(e){return c.apply(this,arguments)})},{key:"mitigate",value:(o=l(s().mark((function e(t){var r,n,a,i,o,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,n={sessionStatus:r.sessionStatus,setCookie:r.setCookie},r.mitigated&&(n.response={body:null!==(a=r.body)&&void 0!==a?a:"Forbidden",status:null!==(i=null===(o=r.redirect)||void 0===o?void 0:o.statusCode)&&void 0!==i?i:r.sessionStatus.includes("monetised")?402:403,apiCallStatus:null!==(c=r.apiCallStatus)&&void 0!==c?c:-1,mitigation:r.mitigation,mitigated:r.mitigated,redirect:r.redirect}),e.abrupt("return",n);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"inject",value:(i=l(s().mark((function e(t){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,e.abrupt("return",{injectHeaders:r.injectHeaders,sessionStatus:r.sessionStatus,setCookie:r.setCookie});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getMitigationResponse",value:(n=l(s().mark((function e(t){var r,n,a,i,o,c,u,h,p,d,f,v,y,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.ip,n=t.userAgent,a=t.url,i=t.method,o=t.mitataCookie,c=t.mitataCaptchaCookie,u=t.body,h=t.headerFingerprint,p=t.acceptHeader,d=t.hostHeader,!zt(a,i,this.netaceaCaptchaPath)){e.next=2;break}return e.next=1,this.handleGetCaptchaRequest(r,n,c,null!=h?h:"",p,a,d);case 1:return e.abrupt("return",e.sent);case 2:return f=this.enableCaptchaContentNegotiation&&void 0!==this.netaceaCaptchaPath?Ut(p):void 0,e.next=3,this.processMitigateRequest({clientIp:r,getBodyFn:function(){var e=l(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,Promise.resolve(u);case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),method:i,mitata:o,mitataCaptcha:c,url:a,userAgent:n},h,f);case 3:return v=e.sent,"application/json"===f&&void 0!==this.netaceaCaptchaPath&&void 0!==v.body&&"captcha"===v.mitigation&&(v.body=Jt(v.body,null!==(y=null!==(g=this.captchaHost)&&void 0!==g?g:d)&&void 0!==y?y:"",this.netaceaCaptchaPath)),e.abrupt("return",v);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"ingest",value:(r=l(s().mark((function e(t){var r,n,a,i,o,c,u,l,h,p,d,f;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ip,n=t.userAgent,a=t.status,i=t.method,o=t.path,c=t.protocol,u=t.referer,l=t.bytesSent,h=t.requestTime,p=t.mitataCookie,d=t.sessionStatus,f=t.headerFingerprint,e.next=1,this.callIngest({ip:r,userAgent:n,status:a,method:i,bytesSent:l,path:o,protocol:c,referer:u,requestTime:h,mitataCookie:p,sessionStatus:d,headerFingerprint:f,integrationType:"@netacea/f5".replace("@netacea/",""),integrationVersion:"5.8.5"});case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getCookieHeader",value:function(e){if(void 0!==e.mitataCookie)return"".concat(this.mitataCookieName,"=").concat(e.mitataCookie)}}]);var r,n,i,o,c,u,p,f,v,g}();function er(e){return e.isPrimaryHashValid?e.isSameIP?e.isExpired?P.EXPIRED_SESSION:P.NO_SESSION:P.IP_CHANGE:P.NO_SESSION}function tr(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t}module.exports=Zt;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netacea/f5",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.5",
|
|
4
4
|
"description": "Netacea F5 CDN integration",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/index.js",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"aws4": "^1.13.2",
|
|
22
22
|
"f5-nodejs": "^1.0.0"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "fc5ba97ca51697f98d1a51d1e0f26c69ae81fdc9"
|
|
25
25
|
}
|