@netacea/f5 5.2.0 → 5.2.1

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";function e(t){return e="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},e(t)}function t(t,n,i){return n=a(n),function(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)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}(t)}(t,r()?Reflect.construct(n,i||[],a(t).constructor):n.apply(t,i))}function r(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(r=function(){return!!e})()}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return r};var t,r={},a=Object.prototype,n=a.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},s=c.iterator||"@@iterator",u=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,r){return e[t]=r}}function l(e,t,r,a){var n=t&&t.prototype instanceof k?t:k,i=Object.create(n.prototype),c=new _(a||[]);return o(i,"_invoke",{value:N(e,r,c)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var d="suspendedStart",v="suspendedYield",y="executing",m="completed",g={};function k(){}function b(){}function x(){}var C={};p(C,s,(function(){return this}));var w=Object.getPrototypeOf,S=w&&w(w(j([])));S&&S!==a&&n.call(S,s)&&(C=S);var A=x.prototype=k.prototype=Object.create(C);function I(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function E(t,r){function a(i,o,c,s){var u=f(t[i],t,o);if("throw"!==u.type){var h=u.arg,p=h.value;return p&&"object"==e(p)&&n.call(p,"__await")?r.resolve(p.__await).then((function(e){a("next",e,c,s)}),(function(e){a("throw",e,c,s)})):r.resolve(p).then((function(e){h.value=e,c(h)}),(function(e){return a("throw",e,c,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){a(e,t,r,n)}))}return i=i?i.then(n,n):n()}})}function N(e,r,a){var n=d;return function(i,o){if(n===y)throw Error("Generator is already running");if(n===m){if("throw"===i)throw o;return{value:t,done:!0}}for(a.method=i,a.arg=o;;){var c=a.delegate;if(c){var s=P(c,a);if(s){if(s===g)continue;return s}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(n===d)throw n=m,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n=y;var u=f(e,r,a);if("normal"===u.type){if(n=a.done?m:v,u.arg===g)continue;return{value:u.arg,done:a.done}}"throw"===u.type&&(n=m,a.method="throw",a.arg=u.arg)}}}function P(e,r){var a=r.method,n=e.iterator[a];if(n===t)return r.delegate=null,"throw"===a&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==a&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+a+"' method")),g;var i=f(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function O(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function j(r){if(r||""===r){var a=r[s];if(a)return a.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,o=function e(){for(;++i<r.length;)if(n.call(r,i))return e.value=r[i],e.done=!1,e;return e.value=t,e.done=!0,e};return o.next=o}}throw new TypeError(e(r)+" is not iterable")}return b.prototype=x,o(A,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:b,configurable:!0}),b.displayName=p(x,h,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,p(e,h,"GeneratorFunction")),e.prototype=Object.create(A),e},r.awrap=function(e){return{__await:e}},I(E.prototype),p(E.prototype,u,(function(){return this})),r.AsyncIterator=E,r.async=function(e,t,a,n,i){void 0===i&&(i=Promise);var o=new E(l(e,t,a,n),i);return r.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(A),p(A,h,"Generator"),p(A,s,(function(){return this})),p(A,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var a in t)r.push(a);return r.reverse(),function e(){for(;r.length;){var a=r.pop();if(a in t)return e.value=a,e.done=!1,e}return e.done=!0,e}},r.values=j,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(a,n){return c.type="throw",c.arg=e,r.next=a,n&&(r.method="next",r.arg=t),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(s){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,g):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),g},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),T(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var a=r.completion;if("throw"===a.type){var n=a.arg;T(r)}return n}}throw Error("illegal catch attempt")},delegateYield:function(e,r,a){return this.delegate={iterator:j(e),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=t),g}},r}function o(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(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 c(e,t,r,a,n,i,o){try{var c=e[i](o),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(a,n)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(a,n){var i=e.apply(t,r);function o(e){c(i,a,n,o,s,"next",e)}function s(e){c(i,a,n,o,s,"throw",e)}o(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,v(a.key),a)}}function p(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return(t=v(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var a=t[Symbol.toPrimitive];if(void 0!==a){var n=a.call(t,r||"default");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function y(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=g(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,n=function(){};return{s:n,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:n}}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,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(c)throw i}}}}function m(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 a,n,i,o,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(a=i.call(r)).done)&&(c.push(a.value),c.length!==t);s=!0);}catch(e){u=!0,n=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw n}}return c}}(e,t)||g(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 g(e,t){if(e){if("string"==typeof e)return k(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)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}var b=require("crypto"),x=require("buffer"),C=require("https"),w=require("querystring"),S=require("aws4");function A(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var I,E,N,P=A(b),O=A(C),T=A(w);!function(e){e.ORIGIN="ORIGIN",e.HTTP="HTTP",e.KINESIS="KINESIS",e.NATIVE="NATIVE"}(I||(I={})),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"}(N||(N={}));var _=3e3;var j="_/@#/",K={none:"",block:"block",captcha:"captcha",allow:"allow",captchaPass:"captchapass"},M={0:K.none,1:K.block,2:K.none,3:K.block,4:K.none,5:K.block},H={1:K.captcha,2:K.captchaPass,3:K.captcha,4:K.allow,5:K.captcha,6:K.allow,7:K.captcha,a:K.captcha,b:K.captchaPass,c:K.captcha,d:K.allow,e:K.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:"sev_",6:"organisation_",7:"asn_",8:"country_",9:"combination_",b:"headerFP_"},mitigateMap:{0:"",1:"blocked",2:"allow",3:"hardblocked",4:"flagged",5:"monetised"},mitigationTypes:K,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"}}),R="ignored",V="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),D=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;function B(e){if(void 0!==e){var t=e.match(D);if(null!=t){var r=m(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 q(e,t,r,a){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"000";void 0===t&&(t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V,r=b.randomBytes(e-1),a=Array.from(r).map((function(e){return t[e%t.length]})).join("");return"c".concat(a)}());var i=[r,t,G(e+"|"+String(r),a),n].join(j),o=G(i,a);return"".concat(o).concat(j).concat(i)}function G(e,t){var r=b.createHmac("sha256",t);return r.update(e),x.Buffer.from(r.digest("hex")).toString("base64")}function U(e,t,r){var a={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 a;var n=B(e);if(void 0!==n){var i=[n.expiry,n.userId,n.ipHash,n.mitigationType].join(j),o=Math.floor(Date.now()/1e3),c=parseInt(n.expiry)<o,s=["1","3","5","a","c","e"].includes(n.captcha),u="3"===n.mitigate,h=s||u,p=G(t+"|"+n.expiry,r),l=n.ipHash===p;return{mitata:n,requiresReissue:c||!l,isExpired:c,shouldExpire:h,isSameIP:l,isPrimaryHashValid:n.signature===G(i,r),match:n.match,mitigate:n.mitigate,captcha:n.captcha,userId:n.userId}}return a}function F(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 z(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof e&&(e=e.join("; ")),""===e?"":X(e.split(";"),t).join("; ")}function X(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return X(e.reverse()).reverse();var t,r=new Set,a=[],n=y(e);try{for(n.s();!(t=n.n()).done;){var i=t.value;if(""!==(i=i.trimStart()).trim()){var o=i.split("=")[0].toUpperCase();r.has(o)||(r.add(o),a.push(i))}}}catch(e){n.e(e)}finally{n.f()}return a}function J(e){var t,r,a=z([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(a)}var W={cookie:{attributes:Object.freeze({__proto__:null,configureCookiesDomain:function(e,t){var r=e=z(null!=e?e:"",!0),a=t=z(null!=t?t:"",!0);if(void 0!==e&&void 0!==t){var n=F(e,"Domain"),i=F(t,"Domain");void 0!==n&&void 0!==i?a=t.replace(i,n):void 0!==n&&void 0===i?a=t+(""!==t?"; Domain=".concat(n):"Domain=".concat(n)):void 0===n&&void 0!==i&&(r=e+(""!==e?"; Domain=".concat(i):"Domain=".concat(i)))}else if(void 0!==e&&void 0===t){var o=F(e,"Domain");void 0!==o&&(a="Domain=".concat(o))}else if(void 0===e&&void 0!==t){var c=F(t,"Domain");void 0!==c&&(r="Domain=".concat(c))}return{cookieAttributes:""!==r?r:void 0,captchaCookieAttributes:""!==a?a:void 0}},extractAndRemoveCookieAttr:function(e,t){var r=F(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:F,removeDuplicateAttrs:z}),netaceaSession:Object.freeze({__proto__:null,createNetaceaCaptchaSetCookieString:function(e){var t;return J(f(f({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitatacaptcha"}))},createNetaceaSetCookieString:function(e){var t;return J(f(f({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitata"}))},createSetCookieString:J})}},Y=function(){function e(t,r){u(this,e),this.crypto=t,this.TextEncoder=r}return p(e,[{key:"hashString",value:(r=s(i().mark((function e(t,r){var a,n,c,s,u,h,p=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(a=p.length>2&&void 0!==p[2]&&p[2])?o(r).sort():o(r),c=(new this.TextEncoder).encode(n.join(",")),e.next=1,this.crypto.subtle.digest(t,c);case 1:return s=e.sent,u=Array.from(new Uint8Array(s)),h=u.map((function(e){return e.toString(16).padStart(2,"0")})).join("").substring(0,12),e.abrupt("return","h"+(a?"s":"")+"_".concat(r.length,"_").concat(h));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"hashHeaders",value:(t=s(i().mark((function t(r){var a,n,o,c=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=c.length>1&&void 0!==c[1]&&c[1],0!==(n=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",n,a);case 2:return t.abrupt("return",t.sent);case 3:return t.prev=3,o=t.catch(1),console.error(o),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 $(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Z(e){var t=(e+"===".slice(0,(4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/");return Buffer.from(t,"base64")}var Q="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0";function ee(e,t){var r=b.randomBytes(12),a=b.createCipheriv("aes-256-gcm",t,r),n=Buffer.from(Q,"ascii");a.setAAD(n);var i=a.update(e,"utf8");i=Buffer.concat([i,a.final()]);var o=a.getAuthTag();return[Q,"",$(r),$(i),$(o)].join(".")}function te(e,t){var r=e.split(".");if(5!==r.length)throw new Error("JWE should have 5 parts, got ".concat(r.length));var a=m(r,5),n=a[0],i=a[1],o=a[2],c=a[3],s=a[4];if(n!==Q)throw new Error("Incorrect JWE header");if(""!==i)throw new Error("Expected empty encrypted key for direct encryption");var u=Z(o),h=Z(c),p=Z(s);if(12!==u.length)throw new Error("IV must be ".concat(12," bytes, got ").concat(u.length));if(16!==p.length)throw new Error("Auth tag must be ".concat(16," bytes, got ").concat(p.length));var l=b.createDecipheriv("aes-256-gcm",t,u),f=Buffer.from(n,"ascii");l.setAAD(f),l.setAuthTag(p);var d=l.update(h);return(d=Buffer.concat([d,l.final()])).toString("utf8")}var re={},ae={},ne={},ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.API_VERSION=ie.REGION=ie.PAYLOAD_TYPE=ie.STATE=void 0,ie.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},ie.PAYLOAD_TYPE="string",ie.REGION="eu-west-1",ie.API_VERSION="2013-12-02",Object.defineProperty(ne,"__esModule",{value:!0}),ne.signRequest=void 0;var oe=S,ce=ie;function se(e,t){for(var r=[],a=0;a<e.length;a+=t){var n=e.slice(a,a+t);r.push({Data:Buffer.from(JSON.stringify(n)).toString("base64"),PartitionKey:Date.now().toString()})}return r}ne.signRequest=function(e,t,r){var a=e.accessKeyId,n=e.secretAccessKey,i={Records:se(t,r),PartitionKey:Date.now().toString(),StreamName:e.streamName};return oe.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:ce.REGION},{accessKeyId:a,secretAccessKey:n})},Object.defineProperty(ae,"__esModule",{value:!0});var ue=ne;function he(e){return pe.apply(this,arguments)}function pe(){return(pe=s(i().mark((function e(t){return i().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 le=function(){return p((function e(t){var r=t.kinesisStreamName,a=t.kinesisAccessKey,n=t.kinesisSecretKey,i=t.maxLogAgeSeconds,o=t.logBatchSize,c=t.rampUpBatchSize,s=t.maxAwaitTimePerIngestCallMs;u(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.kinesisStreamName=r,this.kinesisAccessKey=a,this.kinesisSecretKey=n,this.maxAwaitTimePerIngestCallMs=s,void 0!==i&&i<this.maxLogAgeSeconds&&i>0&&(this.maxLogAgeSeconds=i),void 0!==o&&(this.maxLogBatchSize=o),this.logBatchSize=!0===c?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=s(i().mark((function e(t){var r,a,n,c;return i().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=o(this.logCache),this.logCache=[],e.prev=2,a=(0,ue.signRequest)({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},r,this.logBatchSize),e.next=3,t({headers:a.headers,host:"https://".concat(a.hostname),method:a.method,path:a.path,body:a.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,c=e.catch(2),(n=this.logCache).push.apply(n,o(r)),console.error(c);case 5:case"end":return e.stop()}}),e,this,[[2,4]])}))),function(e){return t.apply(this,arguments)})},{key:"ingest",value:(e=s(i().mark((function e(t,r){var a,n,o=this;return i().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(a=[]).push(this.putToKinesis(r)),void 0!==this.maxAwaitTimePerIngestCallMs&&a.push(he(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(a);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,n=he(1e3*this.maxLogAgeSeconds).then(s(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,o.putToKinesis(r);case 1:o.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,r){return e.apply(this,arguments)})}]);var e,t}();ae.default=le,Object.defineProperty(re,"__esModule",{value:!0});var fe,de=ae,ve=re.default=de.default,ye={subtle:{digest:(fe=s(i().mark((function e(t,r){var a,n,o,c,s;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(a={"SHA-256":"sha256","SHA-1":"sha1","SHA-384":"sha384","SHA-512":"sha512"}[t])&&void 0!==a?a:t.toLowerCase().replace("-",""),o=r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),c=new Uint8Array(o),s=P.createHash(n).update(c).digest(),e.abrupt("return",s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return fe.apply(this,arguments)})}},me=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,ge=/^\/[a-zA-Z0-9/]*$/;function ke(e,t,r){return void 0!==r&&""!==r&&(function(e){var t=e,r=t.indexOf("//");if(-1!==r){var a=(t=t.substring(r+2)).indexOf("/");if(-1===a)return"/";t=t.substring(a)}var n=t.indexOf("?");return-1!==n&&(t=t.substring(0,n)),t}(e)===r&&"get"===t.toLowerCase())}function be(e){var t=function(e,t){var r=e.indexOf("?");if(-1!==r)for(var a=e.substring(r+1).split("&"),n=0;n<a.length;n++){var i=a[n].split("=");if(i[0]===t)return void 0!==i[1]?decodeURIComponent(i[1]):void 0}}(e,"trackingId");return void 0!==t&&me.test(t)?t:null}function xe(e){if(void 0===e)return"text/html";var t=e.toLowerCase(),r=t.includes("text/html")||t.includes("application/html"),a=t.includes("application/json");return!r&&a?"application/json":"text/html"}function Ce(e,t,r){if(void 0===e||""===e)return"";var a;try{a=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}(a))return"";var n=r+"?trackingId="+a.trackingId,i="https://"+t+n;return JSON.stringify({captchaRelativeURL:n,captchaAbsoluteURL:i})}var we=W.cookie.attributes.configureCookiesDomain,Se=W.cookie.netaceaSession,Ae=Se.createNetaceaSetCookieString,Ie=Se.createNetaceaCaptchaSetCookieString,Ee=function(){return p((function e(t){var r,a,n=t.apiKey,i=t.secretKey,o=t.timeout,c=void 0===o?3e3:o,s=t.mitigationServiceUrl,h=void 0===s?"https://mitigations.netacea.net":s,p=t.ingestServiceUrl,l=void 0===p?"https://ingest.netacea.net":p,v=t.mitigationType,y=void 0===v?E.INGEST:v,m=t.captchaSiteKey,g=t.captchaSecretKey,k=t.ingestType,b=void 0===k?I.HTTP:k,x=t.kinesis,C=t.mitataCookieExpirySeconds,w=t.netaceaCookieExpirySeconds,S=t.netaceaCookieName,A=t.netaceaCaptchaCookieName,N=t.netaceaCookieAttributes,P=t.netaceaCaptchaCookieAttributes;if(u(this,e),d(this,"mitataCookieExpirySeconds",void 0),d(this,"apiKey",void 0),d(this,"secretKey",void 0),d(this,"mitigationServiceUrl",void 0),d(this,"ingestServiceUrl",void 0),d(this,"timeout",void 0),d(this,"captchaSiteKey",void 0),d(this,"captchaSecretKey",void 0),d(this,"ingestType",void 0),d(this,"kinesis",void 0),d(this,"mitigationType",void 0),d(this,"encryptedCookies",[]),d(this,"netaceaCookieName",void 0),d(this,"netaceaCaptchaCookieName",void 0),d(this,"netaceaCookieAttributes",void 0),d(this,"netaceaCaptchaCookieAttributes",void 0),null==n)throw new Error("apiKey is a required parameter");this.apiKey=n,this.secretKey=i,this.mitigationServiceUrl=h,this.ingestServiceUrl=l,this.mitigationType=y,this.ingestType=null!=b?b:I.HTTP,this.ingestType===I.KINESIS&&(void 0===x?console.warn("NETACEA WARN: no kinesis args provided, when ingestType is ".concat(this.ingestType)):this.kinesis=new ve(f(f({},x),{},{apiKey:this.apiKey}))),void 0===m&&void 0===g||(this.captchaSiteKey=m,this.captchaSecretKey=g),this.timeout=function(e){return e<=0?_:e}(c),this.netaceaCookieName=Pe(S,"_mitata"),this.netaceaCaptchaCookieName=Pe(A,"_mitatacaptcha"),this.encryptedCookies=[this.netaceaCookieName,this.netaceaCaptchaCookieName],this.mitataCookieExpirySeconds=function(e,t){return void 0===t?e===E.INGEST?3600:60:t}(y,null!=w?w:C);var O=we(null!=N?N:"",null!=P?P:"");this.netaceaCookieAttributes=null!==(r=O.cookieAttributes)&&void 0!==r?r:"",this.netaceaCaptchaCookieAttributes=null!==(a=O.captchaCookieAttributes)&&void 0!==a?a:""}),[{key:"runMitigation",value:(C=s(i().mark((function e(t){var r,a,n,o,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,o=this.mitigationType,e.next=o===E.MITIGATE?1:o===E.INJECT?3:o===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,c=e.catch(0),console.error("Netacea FAILOPEN Error:",c),r=t,a=this.isUrlCaptchaPost(r.url,r.method),n=this.mitigationType===E.MITIGATE,e.abrupt("return",{injectHeaders:{"x-netacea-captcha":"0","x-netacea-match":"0","x-netacea-mitigate":"0"},sessionStatus:n&&a?"error_open":""});case 10:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(e){return C.apply(this,arguments)})},{key:"readCookie",value:(x=s(i().mark((function e(t,r){var a,n,o,c,s,u,h;return i().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:a="".concat(t,"="),n=y(r),e.prev=4,n.s();case 5:if((o=n.n()).done){e.next=11;break}if(c=o.value,!(s=c.split(";")[0].trimStart()).startsWith(a)){e.next=10;break}if(u=s.slice(a.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,h=e.catch(4),n.e(h);case 13:return e.prev=13,n.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=s(i().mark((function e(t){var r,a,n,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.constructWebLog(t),this.ingestType!==I.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(f(f({},r),{},{apiKey:this.apiKey}),this.makeRequest.bind(this));case 2:e.next=4;break;case 3:e.prev=3,o=e.catch(1),console.error("NETACEA Error: ",o.message);case 4:e.next=7;break;case 5:return a={"X-Netacea-API-Key":this.apiKey,"content-type":"application/json"},e.next=6,this.makeIngestApiCall(a,r);case 6:if(200===(n=e.sent).status){e.next=7;break}throw this.APIError(n);case 7:case"end":return e.stop()}}),e,this,[[1,3]])}))),function(e){return b.apply(this,arguments)})},{key:"makeIngestApiCall",value:(k=s(i().mark((function e(t,r){return i().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,a=e.status,n=e.method,i=e.path,o=e.protocol,c=e.referer,s=e.bytesSent,u=e.requestTime,h=e.mitataCookie,p=e.sessionStatus,l=e.integrationType,f=e.integrationVersion,d=e.headerFingerprint,v=(new Date).toUTCString();return{Request:"".concat(n," ").concat(i," ").concat(o),TimeLocal:v,RealIp:t,UserAgent:r,Status:a,RequestTime:null==u?void 0:u.toString(),BytesSent:null==s?void 0:s.toString(),Referer:""===c?"-":c,NetaceaUserIdCookie:null!=h?h:"",NetaceaMitigationApplied:null!=p?p:"",IntegrationType:null!=l?l:"",IntegrationVersion:null!=f?f:"",HeaderHash:null!=d?d:""}}},{key:"constructWebLog",value:function(e){return e.bytesSent=""===e.bytesSent?"0":e.bytesSent,this.constructV1WebLog(e)}},{key:"check",value:(g=s(i().mark((function e(t,r,a,n,o,c){var s,u,h,p,l,f,d,v,y,m,g,k;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.secretKey){e.next=1;break}throw new Error("Secret key is required to mitigate");case 1:if((v=U(t,r,this.secretKey)).isPrimaryHashValid&&!v.requiresReissue){e.next=4;break}return e.next=2,this.makeMitigateAPICall(null===(y=v.mitata)||void 0===y?void 0:y.userId,r,a,n,o,c);case 2:return g=e.sent,s=g.status,u=g.match,h=g.mitigate,p=g.captcha,l=g.body,e.next=3,this.createMitata(r,null===(m=v.mitata)||void 0===m?void 0:m.userId,u,h,p,g.mitataMaxAge);case 3:k=e.sent,f=[k],d=g.eventId,e.next=5;break;case 4:s=-1,u=v.match,h=v.mitigate,p=v.captcha,l=void 0,f=[];case 5:return e.abrupt("return",this.composeResult(l,f,s,u,h,p,!1,d));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n,i){return g.apply(this,arguments)})},{key:"createMitata",value:(m=s(i().mark((function e(t,r,a,n,o){var c,s,u,h,p,l,f,d,v=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=v.length>5&&void 0!==v[5]?v[5]:86400,s=v.length>6&&void 0!==v[6]?v[6]:void 0,u=["1","3","5"].includes(o),h="3"===n,p=u||h?-60:this.mitataCookieExpirySeconds,l=null!=s?s:Math.floor(Date.now()/1e3)+p,void 0!==this.secretKey){e.next=1;break}throw new Error("Cannot build cookie without secret key.");case 1:return f=[a,n,o].join(""),d=q(t,r,l,this.secretKey,f),e.abrupt("return",Ae({cookieName:this.netaceaCookieName,cookieValue:d,maxAgeAttribute:String(c),otherAttributes:this.netaceaCookieAttributes}));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return m.apply(this,arguments)})},{key:"processCaptcha",value:(v=s(i().mark((function e(t,r,a,n,o){var c,s,u,h,p,l,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.makeCaptchaAPICall(t,r,a,n,o);case 1:return c=e.sent,s=c.status,u=c.match,h=c.mitigate,p=c.captcha,l=c.body,f=c.setCookie,e.abrupt("return",this.composeResult(l,f,s,u,h,p,!0));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return v.apply(this,arguments)})},{key:"getMitataCaptchaFromHeaders",value:(l=s(i().mark((function e(t){var r,a,n;return i().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 a=parseInt(t[L.netaceaHeaders.mitataCaptchaExpiry]),e.next=2,this.encryptCookieValue(r);case 2:return n=e.sent,e.abrupt("return",Ie({cookieName:this.netaceaCaptchaCookieName,cookieValue:n,maxAgeAttribute:String(isNaN(a)?86400:a),otherAttributes:this.netaceaCaptchaCookieAttributes}));case 3:return e.abrupt("return",void 0);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"makeCaptchaAPICall",value:(h=s(i().mark((function e(t,r,a,n,o){var c,s,u,h;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":a,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},void 0!==(s=B(t))&&(c["X-Netacea-UserId"]=s.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),u={},"string"==typeof o&&""!==o&&(u.headerFP=o),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/AtaVerifyCaptcha",headers:c,method:"POST",body:n,timeout:this.timeout,params:u});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,null==s?void 0:s.userId,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return h.apply(this,arguments)})},{key:"getApiCallResponseFromResponse",value:(c=s(i().mark((function e(t,r,a){var n,o,c,s,u,h,p,l,f,d,v,y,m,g,k;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(200===t.status){e.next=1;break}throw this.APIError(t);case 1:return p=null!==(n=null===(o=t.headers[L.netaceaHeaders.match])||void 0===o?void 0:o.toString())&&void 0!==n?n:"0",l=null!==(c=null===(s=t.headers[L.netaceaHeaders.mitigate])||void 0===s?void 0:s.toString())&&void 0!==c?c:"0",f=null!==(u=null===(h=t.headers[L.netaceaHeaders.captcha])||void 0===h?void 0:h.toString())&&void 0!==u?u:"0",d=parseInt(t.headers[L.netaceaHeaders.mitataExpiry]),isNaN(d)&&(d=86400),e.next=2,this.createMitata(a,r,p,l,f);case 2:return v=e.sent,e.next=3,this.getMitataCaptchaFromHeaders(t.headers);case 3:return y=e.sent,m=[v,y].filter((function(e){return void 0!==e})),g=t.body,k=t.headers[L.netaceaHeaders.eventId],e.abrupt("return",{status:t.status,match:p,mitigate:l,captcha:f,setCookie:m,body:g,eventId:k,mitataMaxAge:d});case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"buildCookieHeader",value:function(e){var t="",r="";for(var a in e){var n=e[a];void 0!==n&&(t="".concat(t).concat(r).concat(a,"=").concat(n),r="; ")}return t}},{key:"makeMitigateAPICall",value:(o=s(i().mark((function e(t,r,a,n,o,c){var s,u,h;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":a,cookie:this.buildCookieHeader({_mitatacaptcha:n})},void 0!==t&&(s["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(s["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,s["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),void 0!==c&&(s["X-Netacea-Captcha-Content-Type"]=c),u={},"string"==typeof o&&""!==o&&(u.headerFP=o),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/",headers:s,method:"GET",timeout:this.timeout,params:u});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,t,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n,i){return o.apply(this,arguments)})},{key:"composeResult",value:function(e,t,r,a,n,i,o,c){var s=this.findBestMitigation(a,n,i,o),u={body:e,apiCallStatus:r,setCookie:t,sessionStatus:s.sessionStatus,mitigation:s.mitigation,mitigated:[L.mitigationTypes.block,L.mitigationTypes.captcha,L.mitigationTypes.captchaPass].includes(s.mitigation)};if(this.mitigationType===E.INJECT){var h={"x-netacea-match":s.parts.match.toString(),"x-netacea-mitigate":s.parts.mitigate.toString(),"x-netacea-captcha":s.parts.captcha.toString()};void 0!==c&&(h["x-netacea-event-id"]=c),u.injectHeaders=h}return u}},{key:"findBestMitigation",value:function(e,t,r,a){var n,i,o="unknown";a||("2"===r?r="4":"3"===r&&(r="5"));var c=null!==(n=L.matchMap[e])&&void 0!==n?n:o+"_";c+=null!==(i=L.mitigateMap[t])&&void 0!==i?i:o;var s=L.bestMitigationMap[t];if("0"!==r){var u;c+=","+(null!==(u=L.captchaMap[r])&&void 0!==u?u:o);var h=L.bestMitigationCaptchaMap[r];void 0!==h&&(s=h)}return this.mitigationType===E.INJECT&&(s=L.mitigationTypes.none),{sessionStatus:c,mitigation:s,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:(n=s(i().mark((function e(t,r,a){var n,o,c,s,u,h,p;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isUrlCaptchaPost(t.url,t.method)){e.next=2;break}return o=this,c=t.mitata,s=t.clientIp,u=t.userAgent,e.next=1,t.getBodyFn();case 1:h=e.sent,p=r,n=o.processCaptcha.call(o,c,s,u,h,p),e.next=3;break;case 2:n=this.check(t.mitata,t.clientIp,t.userAgent,t.mitataCaptcha,r,a);case 3:return e.next=4,n;case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"setIngestOnlyMitataCookie",value:(a=s(i().mark((function e(t){var r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.createMitata(R,t,"0","0","0",86400);case 1:return r=e.sent,e.abrupt("return",{sessionStatus:"",setCookie:[r]});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"processIngest",value:(r=s(i().mark((function e(t){var r,a,n,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.secretKey){e.next=1;break}throw new Error("Secret key is required for ingest");case 1:return r=this.getCookieHeader(t),e.next=2,this.readCookie(this.netaceaCookieName,r);case 2:if(a=e.sent,(n=U(a,R,this.secretKey)).isPrimaryHashValid){e.next=4;break}return e.next=3,this.setIngestOnlyMitataCookie(void 0);case 3:case 5:return e.abrupt("return",e.sent);case 4:if(!n.requiresReissue){e.next=6;break}return e.next=5,this.setIngestOnlyMitataCookie(null===(o=n.mitata)||void 0===o?void 0:o.userId);case 6:return e.abrupt("return",{sessionStatus:"",setCookie:[]});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"encryptCookieValue",value:(t=s(i().mark((function e(t){return i().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=s(i().mark((function e(t){return i().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,a,n,o,c,h,l,v,m,g,k,b,x,C}(),Ne=function(){function e(r){var a,n,i,o,c;u(this,e),d(c=t(this,e,[r]),"httpsAgent",void 0),d(c,"mitataCookieName",void 0),d(c,"mitataCaptchaCookieName",void 0),d(c,"hashGenerator",void 0),d(c,"debugMode",void 0),d(c,"encryptionEnabled",!1),d(c,"encryptionKeyBuffer",void 0),d(c,"mitigationHeaders",["cookie","user-agent","accept","host"]),d(c,"netaceaCaptchaPath",void 0),d(c,"captchaHost",void 0),c.httpsAgent=new O.Agent({timeout:c.timeout,keepAlive:!0,maxSockets:null!==(a=r.maxSockets)&&void 0!==a?a:25}),c.mitataCookieName=null!==(n=r.netaceaCookieName)&&void 0!==n?n:"_mitata",c.mitataCaptchaCookieName=null!==(i=r.netaceaCaptchaCookieName)&&void 0!==i?i:"_mitatacaptcha";var s=function(){return p((function e(){u(this,e)}),[{key:"encode",value:function(e){return new Uint8Array(Buffer.from(e,"utf8"))}}])}();if(c.hashGenerator=new Y(ye,s),c.debugMode=null!==(o=r.debugMode)&&void 0!==o&&o,c.netaceaCaptchaPath=function(e){if(null!=e&&""!==e)return"/"!==e[0]&&(e="/"+e),ge.test(e)?e:void 0}(r.netaceaCaptchaPath),c.captchaHost=r.captchaHost,void 0!==r.cookieEncryptionKey){var h=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=Z(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);h.valid&&void 0!==h.keyBuffer?(c.encryptionKeyBuffer=h.keyBuffer,c.encryptionEnabled=!0):console.warn("NETACEA WARN: Invalid cookieEncryptionKey - ".concat(h.error,". Cookies will not be encrypted."))}return c}return function(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&&n(e,t)}(e,Ee),p(e,[{key:"computeHeaderFingerprint",value:(b=s(i().mark((function e(t){var r;return i().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 b.apply(this,arguments)})},{key:"handleGetCaptchaRequest",value:(k=s(i().mark((function e(t,r,a,n,o,c,s){var u,h,p,l,f,d,v,y,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=be(c),h=xe(o),p={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":t,"user-agent":r,cookie:void 0!==a?"_mitatacaptcha="+a:"","X-Netacea-Captcha-Content-Type":h},void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(p["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,p["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),l={netaceaHeaders:"request-id"},"string"==typeof n&&""!==n&&(l.headerFP=n),null!==u&&(l.trackingId=u),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/captcha",headers:p,method:"GET",timeout:this.timeout,params:l});case 1:if(200===(f=e.sent).status){e.next=2;break}throw this.APIError(f);case 2:return d=f.body,"application/json"===h&&void 0!==this.netaceaCaptchaPath&&void 0!==d&&(m=null!==(v=null!==(y=this.captchaHost)&&void 0!==y?y:s)&&void 0!==v?v:"",d=Ce(d,m,this.netaceaCaptchaPath)),e.abrupt("return",{body:d,apiCallStatus:f.status,setCookie:[],sessionStatus:",captcha_serve",mitigation:"captcha",mitigated:!0});case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n,i,o){return k.apply(this,arguments)})},{key:"encryptCookieValue",value:(g=s(i().mark((function e(t){return i().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",ee(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"decryptCookieValue",value:(v=s(i().mark((function e(t){return i().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(5===(r=t).split(".").length&&r.includes("..")){e.next=2;break}throw new Error("Cookie is not JWE encrypted");case 2:return e.abrupt("return",te(t,this.encryptionKeyBuffer));case 3:case"end":return e.stop()}var r}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"createMitata",value:(f=s(i().mark((function e(t,r,a,n,o){var c,s,u,h,p,l,f,d,v,y=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=y.length>5&&void 0!==y[5]?y[5]:86400,s=y.length>6&&void 0!==y[6]?y[6]:void 0,u=["1","3","5"].includes(o),h="3"===n,p=u||h?-60:this.mitataCookieExpirySeconds,l=null!=s?s:Math.floor(Date.now()/1e3)+p,void 0!==this.secretKey){e.next=1;break}throw new Error("Cannot build cookie without secret key.");case 1:return f=[a,n,o].join(""),d=q(t,r,l,this.secretKey,f),e.next=2,this.encryptCookieValue(d);case 2:return v=e.sent,e.abrupt("return",Ae({cookieName:this.netaceaCookieName,cookieValue:v,maxAgeAttribute:String(c),otherAttributes:this.netaceaCookieAttributes}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return f.apply(this,arguments)})},{key:"getInjectHeaders",value:function(e){if(this.mitigationType===E.INJECT){var t=e;if(void 0!==t.injectHeaders){var r={},a=t.injectHeaders;return r["x-netacea-match"]=a["x-netacea-match"],r["x-netacea-mitigate"]=a["x-netacea-mitigate"],r["x-netacea-captcha"]=a["x-netacea-captcha"],void 0!==a["x-netacea-event-id"]&&(r["x-netacea-event-id"]=a["x-netacea-event-id"]),this.encodeHeadersAsKeyValueList(r)}}return[]}},{key:"registerPolicyHandler",value:function(e){var t=this;e.addMethod("getMitigationHeaderPolicy",(function(e,r){var a=t.mitigationHeaders.join(",");console.info('level=info component=f5 handler=getMitigationHeaderPolicy policy="'.concat(a,'"')),r.reply(a)}))}},{key:"encodeHeadersAsKeyValueList",value:function(e){for(var t=[],r=0,a=Object.entries(e);r<a.length;r++){var n=m(a[r],2),i=n[0],o=n[1];if(Array.isArray(o)){var c,s=y(o);try{for(s.s();!(c=s.n()).done;){var u=c.value;t.push(i,Buffer.from(u).toString("base64"))}}catch(e){s.e(e)}finally{s.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=s(i().mark((function e(r,a){var n,o,c,s,u,h,p,l,f,d,v,y,g,k,b,x,C,w,S,A,I,E,N,P,O,T,_,j,K,M;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=r.params(),s=m(c,3),u=s[0],h=s[1],p=s[2],l=t.getArrayValueOrDefault(c,3,void 0),f=t.getArrayValueOrDefault(c,4,void 0),d=t.getArrayValueOrDefault(c,5,void 0),v=t.parseHeaderValues(d),y=null!==(n=v.cookie)&&void 0!==n?n:null,g=null!==(o=v["user-agent"])&&void 0!==o?o:"",k=v.accept,e.prev=1,e.next=2,t.computeHeaderFingerprint(f);case 2:return x=e.sent,t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=header_fingerprint method="'.concat(h,'" path="').concat(p,'" headers="').concat(null!=f?f:"",'" header_count=').concat(null!==(C=null==f?void 0:f.split(",").length)&&void 0!==C?C:0,' fingerprint="').concat(x,'"')),e.next=3,t.getMitataCookies(y);case 3:return w=e.sent,S=m(w,2),A=S[0],I=S[1],t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=mitigation_request headerFP="'.concat(x,'"')),e.next=4,t.runMitigation({ip:u,method:h,url:p,mitataCaptchaCookie:I,mitataCookie:A,userAgent:g,body:l,headerFingerprint:x,acceptHeader:k,hostHeader:v.host});case 4:if(E=e.sent,N="",(ke(p,h,t.netaceaCaptchaPath)||void 0!==t.netaceaCaptchaPath&&"captcha"===(null==E||null===(b=E.response)||void 0===b?void 0:b.mitigation))&&(N="application/json"===xe(k)?"application/json":"text/html; charset=UTF-8"),"error_open"!==(null==E?void 0:E.sessionStatus)){e.next=5;break}return a.reply(["",500,"error_open",!0,"",x,[],[]]),e.abrupt("return");case 5:if(void 0!==E){e.next=6;break}return a.reply(["",0,"",!1,"",x,[],[]]),e.abrupt("return");case 6:P="",O=0,T=!1,_=t.getValueOrDefault(A,""),void 0!==E.setCookie&&E.setCookie.length>0&&void 0!==(j=E.setCookie.find((function(e){return e.includes("".concat(t.netaceaCookieName,"="))})))&&(_=j.split(";")[0].replace("".concat(t.netaceaCookieName,"="),"")),void 0!==E.response&&(O=t.getValueOrDefault(E.response.apiCallStatus,0),P=t.getValueOrDefault(E.response.body,"Forbidden"),T=t.getValueOrDefault(E.response.mitigated,T)),K={},void 0!==E.setCookie&&E.setCookie.length>0&&(K["Set-Cookie"]=E.setCookie),""!==N&&(K["Content-Type"]=N),a.reply([P,O,t.getValueOrDefault(E.sessionStatus,""),T,t.getValueOrDefault(_,""),x,t.getInjectHeaders(E),t.encodeHeadersAsKeyValueList(K)]),e.next=8;break;case 7:e.prev=7,M=e.catch(1),console.error("Could not reach Netacea mitigation API: ",M.message),a.reply(["",0,"",!1,"","",[],[]]);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(","),a=0;a<this.mitigationHeaders.length&&a<r.length;a++)t[this.mitigationHeaders[a].toLowerCase()]=Buffer.from(r[a],"base64").toString("utf8");return t}},{key:"getValueOrDefault",value:function(e,t){return null!=e?e:t}},{key:"getArrayValueOrDefault",value:function(e,t,r){var a;return null!==(a=e[t])&&void 0!==a?a:r}},{key:"getMitataCookies",value:(l=s(i().mark((function e(t){var r,a,n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null==t?void 0:t.split("; "),a=this.getCookie(this.mitataCookieName,r),n=this.getCookie(this.mitataCaptchaCookieName,r),void 0===a){e.next=4;break}return e.prev=1,e.next=2,this.decryptCookieValue(a);case 2:a=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),a=void 0;case 4:if(void 0===n){e.next=8;break}return e.prev=5,e.next=6,this.decryptCookieValue(n);case 6:n=e.sent,e.next=8;break;case 7:e.prev=7,e.catch(5),n=void 0;case 8:return e.abrupt("return",[a,n]);case 9:case"end":return e.stop()}}),e,this,[[1,3],[5,7]])}))),function(e){return l.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=s(i().mark((function e(r,a){var n,o,c,s,u,h,p,l,f,d,v,y,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=r.params(),c=t.getArrayValueOrDefault(o,0,""),s=t.getArrayValueOrDefault(o,1,""),u=t.getArrayValueOrDefault(o,2,"-1"),h=t.getArrayValueOrDefault(o,3,""),p=t.getArrayValueOrDefault(o,4,""),l=t.getArrayValueOrDefault(o,5,""),f=t.getArrayValueOrDefault(o,6,""),d=t.getArrayValueOrDefault(o,7,"0"),v=t.getArrayValueOrDefault(o,8,"0"),n=t.getArrayValueOrDefault(o,9,""),y=t.getArrayValueOrDefault(o,10,""),m=t.getArrayValueOrDefault(o,11,""),t.debugMode&&console.info('level=debug component=f5 handler=ingest event=ingest_request ingestType="'.concat(t.ingestType,'" headerFingerprint="').concat(m,'"')),void 0===n){e.next=4;break}return e.prev=1,e.next=2,t.decryptCookieValue(n);case 2:n=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),n=void 0;case 4:t.ingest({ip:c,userAgent:s,status:u,method:h,path:p,protocol:l,referer:f,bytesSent:d,requestTime:v,mitataCookie:n,sessionStatus:y,headerFingerprint:m}).catch((function(e){console.error("Could not reach Netacea ingest API: "+e.message)})),a.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:(h=s(i().mark((function e(t){var r=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e,a){t.host=t.host.replace("https://","");var n=t.path;if(void 0!==t.params){var i=t.params instanceof URLSearchParams?t.params.toString():T.stringify(t.params);""!==i&&(n+=(n.includes("?")?"&":"?")+i)}for(var o=O.request({agent:r.httpsAgent,host:t.host,path:n,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 a;e({headers:t.headers,status:null!==(a=t.statusCode)&&void 0!==a?a:0,body:""===r?void 0:r})}))})),c=0,s=["error","abort","timeout"];c<s.length;c++){var u=s[c];o.on(u,(function(e){a(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 h.apply(this,arguments)})},{key:"mitigate",value:(c=s(i().mark((function e(t){var r,a,n,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,a={sessionStatus:r.sessionStatus,setCookie:r.setCookie},r.mitigated&&(a.response={body:null!==(n=r.body)&&void 0!==n?n:"Forbidden",status:403,apiCallStatus:null!==(o=r.apiCallStatus)&&void 0!==o?o:-1,mitigation:r.mitigation,mitigated:r.mitigated}),e.abrupt("return",a);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"inject",value:(o=s(i().mark((function e(t){var r;return i().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 o.apply(this,arguments)})},{key:"getMitigationResponse",value:(a=s(i().mark((function e(t){var r,a,n,o,c,u,h,p,l,f,d,v,y,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.ip,a=t.userAgent,n=t.url,o=t.method,c=t.mitataCookie,u=t.mitataCaptchaCookie,h=t.body,p=t.headerFingerprint,l=t.acceptHeader,f=t.hostHeader,!ke(n,o,this.netaceaCaptchaPath)){e.next=2;break}return e.next=1,this.handleGetCaptchaRequest(r,a,u,null!=p?p:"",l,n,f);case 1:return e.abrupt("return",e.sent);case 2:return d=void 0!==this.netaceaCaptchaPath?xe(l):void 0,e.next=3,this.processMitigateRequest({clientIp:r,getBodyFn:function(){var e=s(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,Promise.resolve(h);case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),method:o,mitata:c,mitataCaptcha:u,url:n,userAgent:a},p,d);case 3:return v=e.sent,"application/json"===d&&void 0!==this.netaceaCaptchaPath&&void 0!==v.body&&"captcha"===v.mitigation&&(v.body=Ce(v.body,null!==(y=null!==(m=this.captchaHost)&&void 0!==m?m:f)&&void 0!==y?y:"",this.netaceaCaptchaPath)),e.abrupt("return",v);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"ingest",value:(r=s(i().mark((function e(t){var r,a,n,o,c,s,u,h,p,l,f,d;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ip,a=t.userAgent,n=t.status,o=t.method,c=t.path,s=t.protocol,u=t.referer,h=t.bytesSent,p=t.requestTime,l=t.mitataCookie,f=t.sessionStatus,d=t.headerFingerprint,e.next=1,this.callIngest({ip:r,userAgent:a,status:n,method:o,bytesSent:h,path:c,protocol:s,referer:u,requestTime:p,mitataCookie:l,sessionStatus:f,headerFingerprint:d,integrationType:"@netacea/f5".replace("@netacea/",""),integrationVersion:"5.2.0"});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,a,o,c,h,l,f,v,g,k,b}();function Pe(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t}module.exports=Ne;
1
+ "use strict";function e(t){return e="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},e(t)}function t(t,n,i){return n=a(n),function(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)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}(t)}(t,r()?Reflect.construct(n,i||[],a(t).constructor):n.apply(t,i))}function r(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(r=function(){return!!e})()}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return r};var t,r={},a=Object.prototype,n=a.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},s=c.iterator||"@@iterator",u=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,r){return e[t]=r}}function l(e,t,r,a){var n=t&&t.prototype instanceof k?t:k,i=Object.create(n.prototype),c=new _(a||[]);return o(i,"_invoke",{value:N(e,r,c)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var d="suspendedStart",v="suspendedYield",y="executing",m="completed",g={};function k(){}function b(){}function x(){}var C={};p(C,s,(function(){return this}));var w=Object.getPrototypeOf,S=w&&w(w(j([])));S&&S!==a&&n.call(S,s)&&(C=S);var A=x.prototype=k.prototype=Object.create(C);function I(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function E(t,r){function a(i,o,c,s){var u=f(t[i],t,o);if("throw"!==u.type){var h=u.arg,p=h.value;return p&&"object"==e(p)&&n.call(p,"__await")?r.resolve(p.__await).then((function(e){a("next",e,c,s)}),(function(e){a("throw",e,c,s)})):r.resolve(p).then((function(e){h.value=e,c(h)}),(function(e){return a("throw",e,c,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){a(e,t,r,n)}))}return i=i?i.then(n,n):n()}})}function N(e,r,a){var n=d;return function(i,o){if(n===y)throw Error("Generator is already running");if(n===m){if("throw"===i)throw o;return{value:t,done:!0}}for(a.method=i,a.arg=o;;){var c=a.delegate;if(c){var s=P(c,a);if(s){if(s===g)continue;return s}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(n===d)throw n=m,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n=y;var u=f(e,r,a);if("normal"===u.type){if(n=a.done?m:v,u.arg===g)continue;return{value:u.arg,done:a.done}}"throw"===u.type&&(n=m,a.method="throw",a.arg=u.arg)}}}function P(e,r){var a=r.method,n=e.iterator[a];if(n===t)return r.delegate=null,"throw"===a&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==a&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+a+"' method")),g;var i=f(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function O(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function j(r){if(r||""===r){var a=r[s];if(a)return a.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,o=function e(){for(;++i<r.length;)if(n.call(r,i))return e.value=r[i],e.done=!1,e;return e.value=t,e.done=!0,e};return o.next=o}}throw new TypeError(e(r)+" is not iterable")}return b.prototype=x,o(A,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:b,configurable:!0}),b.displayName=p(x,h,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,p(e,h,"GeneratorFunction")),e.prototype=Object.create(A),e},r.awrap=function(e){return{__await:e}},I(E.prototype),p(E.prototype,u,(function(){return this})),r.AsyncIterator=E,r.async=function(e,t,a,n,i){void 0===i&&(i=Promise);var o=new E(l(e,t,a,n),i);return r.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(A),p(A,h,"Generator"),p(A,s,(function(){return this})),p(A,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var a in t)r.push(a);return r.reverse(),function e(){for(;r.length;){var a=r.pop();if(a in t)return e.value=a,e.done=!1,e}return e.done=!0,e}},r.values=j,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(a,n){return c.type="throw",c.arg=e,r.next=a,n&&(r.method="next",r.arg=t),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(s){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,g):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),g},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),T(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var a=r.completion;if("throw"===a.type){var n=a.arg;T(r)}return n}}throw Error("illegal catch attempt")},delegateYield:function(e,r,a){return this.delegate={iterator:j(e),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=t),g}},r}function o(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(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 c(e,t,r,a,n,i,o){try{var c=e[i](o),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(a,n)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(a,n){var i=e.apply(t,r);function o(e){c(i,a,n,o,s,"next",e)}function s(e){c(i,a,n,o,s,"throw",e)}o(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,v(a.key),a)}}function p(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return(t=v(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var a=t[Symbol.toPrimitive];if(void 0!==a){var n=a.call(t,r||"default");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function y(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=g(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,n=function(){};return{s:n,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:n}}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,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(c)throw i}}}}function m(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 a,n,i,o,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(a=i.call(r)).done)&&(c.push(a.value),c.length!==t);s=!0);}catch(e){u=!0,n=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw n}}return c}}(e,t)||g(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 g(e,t){if(e){if("string"==typeof e)return k(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)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}var b=require("crypto"),x=require("buffer"),C=require("https"),w=require("querystring"),S=require("aws4");function A(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var I,E,N,P=A(b),O=A(C),T=A(w);!function(e){e.ORIGIN="ORIGIN",e.HTTP="HTTP",e.KINESIS="KINESIS",e.NATIVE="NATIVE"}(I||(I={})),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"}(N||(N={}));var _=3e3;var j="_/@#/",K={none:"",block:"block",captcha:"captcha",allow:"allow",captchaPass:"captchapass"},M={0:K.none,1:K.block,2:K.none,3:K.block,4:K.none,5:K.block},H={1:K.captcha,2:K.captchaPass,3:K.captcha,4:K.allow,5:K.captcha,6:K.allow,7:K.captcha,a:K.captcha,b:K.captchaPass,c:K.captcha,d:K.allow,e:K.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:"sev_",6:"organisation_",7:"asn_",8:"country_",9:"combination_",b:"headerFP_"},mitigateMap:{0:"",1:"blocked",2:"allow",3:"hardblocked",4:"flagged",5:"monetised"},mitigationTypes:K,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"}}),R="ignored",V="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),D=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;function B(e){if(void 0!==e){var t=e.match(D);if(null!=t){var r=m(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 q(e,t,r,a){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"000";void 0===t&&(t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V,r=b.randomBytes(e-1),a=Array.from(r).map((function(e){return t[e%t.length]})).join("");return"c".concat(a)}());var i=[r,t,G(e+"|"+String(r),a),n].join(j),o=G(i,a);return"".concat(o).concat(j).concat(i)}function G(e,t){var r=b.createHmac("sha256",t);return r.update(e),x.Buffer.from(r.digest("hex")).toString("base64")}function U(e,t,r){var a={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 a;var n=B(e);if(void 0!==n){var i=[n.expiry,n.userId,n.ipHash,n.mitigationType].join(j),o=Math.floor(Date.now()/1e3),c=parseInt(n.expiry)<o,s=["1","3","5","a","c","e"].includes(n.captcha),u="3"===n.mitigate,h=s||u,p=G(t+"|"+n.expiry,r),l=n.ipHash===p;return{mitata:n,requiresReissue:c||!l,isExpired:c,shouldExpire:h,isSameIP:l,isPrimaryHashValid:n.signature===G(i,r),match:n.match,mitigate:n.mitigate,captcha:n.captcha,userId:n.userId}}return a}function F(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 z(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof e&&(e=e.join("; ")),""===e?"":X(e.split(";"),t).join("; ")}function X(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return X(e.reverse()).reverse();var t,r=new Set,a=[],n=y(e);try{for(n.s();!(t=n.n()).done;){var i=t.value;if(""!==(i=i.trimStart()).trim()){var o=i.split("=")[0].toUpperCase();r.has(o)||(r.add(o),a.push(i))}}}catch(e){n.e(e)}finally{n.f()}return a}function J(e){var t,r,a=z([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(a)}var W={cookie:{attributes:Object.freeze({__proto__:null,configureCookiesDomain:function(e,t){var r=e=z(null!=e?e:"",!0),a=t=z(null!=t?t:"",!0);if(void 0!==e&&void 0!==t){var n=F(e,"Domain"),i=F(t,"Domain");void 0!==n&&void 0!==i?a=t.replace(i,n):void 0!==n&&void 0===i?a=t+(""!==t?"; Domain=".concat(n):"Domain=".concat(n)):void 0===n&&void 0!==i&&(r=e+(""!==e?"; Domain=".concat(i):"Domain=".concat(i)))}else if(void 0!==e&&void 0===t){var o=F(e,"Domain");void 0!==o&&(a="Domain=".concat(o))}else if(void 0===e&&void 0!==t){var c=F(t,"Domain");void 0!==c&&(r="Domain=".concat(c))}return{cookieAttributes:""!==r?r:void 0,captchaCookieAttributes:""!==a?a:void 0}},extractAndRemoveCookieAttr:function(e,t){var r=F(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:F,removeDuplicateAttrs:z}),netaceaSession:Object.freeze({__proto__:null,createNetaceaCaptchaSetCookieString:function(e){var t;return J(f(f({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitatacaptcha"}))},createNetaceaSetCookieString:function(e){var t;return J(f(f({},e),{},{cookieName:null!==(t=e.cookieName)&&void 0!==t?t:"_mitata"}))},createSetCookieString:J})}},Y=function(){function e(t,r){u(this,e),this.crypto=t,this.TextEncoder=r}return p(e,[{key:"hashString",value:(r=s(i().mark((function e(t,r){var a,n,c,s,u,h,p=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(a=p.length>2&&void 0!==p[2]&&p[2])?o(r).sort():o(r),c=(new this.TextEncoder).encode(n.join(",")),e.next=1,this.crypto.subtle.digest(t,c);case 1:return s=e.sent,u=Array.from(new Uint8Array(s)),h=u.map((function(e){return e.toString(16).padStart(2,"0")})).join("").substring(0,12),e.abrupt("return","h"+(a?"s":"")+"_".concat(r.length,"_").concat(h));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"hashHeaders",value:(t=s(i().mark((function t(r){var a,n,o,c=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=c.length>1&&void 0!==c[1]&&c[1],0!==(n=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",n,a);case 2:return t.abrupt("return",t.sent);case 3:return t.prev=3,o=t.catch(1),console.error(o),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 $(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Z(e){var t=(e+"===".slice(0,(4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/");return Buffer.from(t,"base64")}var Q="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0";function ee(e,t){var r=b.randomBytes(12),a=b.createCipheriv("aes-256-gcm",t,r),n=Buffer.from(Q,"ascii");a.setAAD(n);var i=a.update(e,"utf8");i=Buffer.concat([i,a.final()]);var o=a.getAuthTag();return[Q,"",$(r),$(i),$(o)].join(".")}function te(e,t){var r=e.split(".");if(5!==r.length)throw new Error("JWE should have 5 parts, got ".concat(r.length));var a=m(r,5),n=a[0],i=a[1],o=a[2],c=a[3],s=a[4];if(n!==Q)throw new Error("Incorrect JWE header");if(""!==i)throw new Error("Expected empty encrypted key for direct encryption");var u=Z(o),h=Z(c),p=Z(s);if(12!==u.length)throw new Error("IV must be ".concat(12," bytes, got ").concat(u.length));if(16!==p.length)throw new Error("Auth tag must be ".concat(16," bytes, got ").concat(p.length));var l=b.createDecipheriv("aes-256-gcm",t,u),f=Buffer.from(n,"ascii");l.setAAD(f),l.setAuthTag(p);var d=l.update(h);return(d=Buffer.concat([d,l.final()])).toString("utf8")}var re={},ae={},ne={},ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.API_VERSION=ie.REGION=ie.PAYLOAD_TYPE=ie.STATE=void 0,ie.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},ie.PAYLOAD_TYPE="string",ie.REGION="eu-west-1",ie.API_VERSION="2013-12-02",Object.defineProperty(ne,"__esModule",{value:!0}),ne.signRequest=void 0;var oe=S,ce=ie;function se(e,t){for(var r=[],a=0;a<e.length;a+=t){var n=e.slice(a,a+t);r.push({Data:Buffer.from(JSON.stringify(n)).toString("base64"),PartitionKey:Date.now().toString()})}return r}ne.signRequest=function(e,t,r){var a=e.accessKeyId,n=e.secretAccessKey,i={Records:se(t,r),PartitionKey:Date.now().toString(),StreamName:e.streamName};return oe.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:ce.REGION},{accessKeyId:a,secretAccessKey:n})},Object.defineProperty(ae,"__esModule",{value:!0});var ue=ne;function he(e){return pe.apply(this,arguments)}function pe(){return(pe=s(i().mark((function e(t){return i().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 le=function(){return p((function e(t){var r=t.kinesisStreamName,a=t.kinesisAccessKey,n=t.kinesisSecretKey,i=t.maxLogAgeSeconds,o=t.logBatchSize,c=t.rampUpBatchSize,s=t.maxAwaitTimePerIngestCallMs;u(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.kinesisStreamName=r,this.kinesisAccessKey=a,this.kinesisSecretKey=n,this.maxAwaitTimePerIngestCallMs=s,void 0!==i&&i<this.maxLogAgeSeconds&&i>0&&(this.maxLogAgeSeconds=i),void 0!==o&&(this.maxLogBatchSize=o),this.logBatchSize=!0===c?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=s(i().mark((function e(t){var r,a,n,c;return i().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=o(this.logCache),this.logCache=[],e.prev=2,a=(0,ue.signRequest)({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},r,this.logBatchSize),e.next=3,t({headers:a.headers,host:"https://".concat(a.hostname),method:a.method,path:a.path,body:a.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,c=e.catch(2),(n=this.logCache).push.apply(n,o(r)),console.error(c);case 5:case"end":return e.stop()}}),e,this,[[2,4]])}))),function(e){return t.apply(this,arguments)})},{key:"ingest",value:(e=s(i().mark((function e(t,r){var a,n,o=this;return i().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(a=[]).push(this.putToKinesis(r)),void 0!==this.maxAwaitTimePerIngestCallMs&&a.push(he(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(a);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,n=he(1e3*this.maxLogAgeSeconds).then(s(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,o.putToKinesis(r);case 1:o.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,r){return e.apply(this,arguments)})}]);var e,t}();ae.default=le,Object.defineProperty(re,"__esModule",{value:!0});var fe,de=ae,ve=re.default=de.default,ye={subtle:{digest:(fe=s(i().mark((function e(t,r){var a,n,o,c,s;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(a={"SHA-256":"sha256","SHA-1":"sha1","SHA-384":"sha384","SHA-512":"sha512"}[t])&&void 0!==a?a:t.toLowerCase().replace("-",""),o=r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),c=new Uint8Array(o),s=P.createHash(n).update(c).digest(),e.abrupt("return",s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return fe.apply(this,arguments)})}},me=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,ge=/^\/[a-zA-Z0-9/]*$/;function ke(e,t,r){return void 0!==r&&""!==r&&(function(e){var t=e,r=t.indexOf("//");if(-1!==r){var a=(t=t.substring(r+2)).indexOf("/");if(-1===a)return"/";t=t.substring(a)}var n=t.indexOf("?");return-1!==n&&(t=t.substring(0,n)),t}(e)===r&&"get"===t.toLowerCase())}function be(e){var t=function(e,t){var r=e.indexOf("?");if(-1!==r)for(var a=e.substring(r+1).split("&"),n=0;n<a.length;n++){var i=a[n].split("=");if(i[0]===t)return void 0!==i[1]?decodeURIComponent(i[1]):void 0}}(e,"trackingId");return void 0!==t&&me.test(t)?t:null}function xe(e){if(void 0===e)return"text/html";var t=e.toLowerCase(),r=t.includes("text/html")||t.includes("application/html"),a=t.includes("application/json");return!r&&a?"application/json":"text/html"}function Ce(e,t,r){if(void 0===e||""===e)return"";var a;try{a=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}(a))return"";var n=r+"?trackingId="+a.trackingId,i="https://"+t+n;return JSON.stringify({captchaRelativeURL:n,captchaAbsoluteURL:i})}var we=W.cookie.attributes.configureCookiesDomain,Se=W.cookie.netaceaSession,Ae=Se.createNetaceaSetCookieString,Ie=Se.createNetaceaCaptchaSetCookieString,Ee=function(){return p((function e(t){var r,a,n=t.apiKey,i=t.secretKey,o=t.timeout,c=void 0===o?3e3:o,s=t.mitigationServiceUrl,h=void 0===s?"https://mitigations.netacea.net":s,p=t.ingestServiceUrl,l=void 0===p?"https://ingest.netacea.net":p,v=t.mitigationType,y=void 0===v?E.INGEST:v,m=t.captchaSiteKey,g=t.captchaSecretKey,k=t.ingestType,b=void 0===k?I.HTTP:k,x=t.kinesis,C=t.mitataCookieExpirySeconds,w=t.netaceaCookieExpirySeconds,S=t.netaceaCookieName,A=t.netaceaCaptchaCookieName,N=t.netaceaCookieAttributes,P=t.netaceaCaptchaCookieAttributes;if(u(this,e),d(this,"mitataCookieExpirySeconds",void 0),d(this,"apiKey",void 0),d(this,"secretKey",void 0),d(this,"mitigationServiceUrl",void 0),d(this,"ingestServiceUrl",void 0),d(this,"timeout",void 0),d(this,"captchaSiteKey",void 0),d(this,"captchaSecretKey",void 0),d(this,"ingestType",void 0),d(this,"kinesis",void 0),d(this,"mitigationType",void 0),d(this,"encryptedCookies",[]),d(this,"netaceaCookieName",void 0),d(this,"netaceaCaptchaCookieName",void 0),d(this,"netaceaCookieAttributes",void 0),d(this,"netaceaCaptchaCookieAttributes",void 0),null==n)throw new Error("apiKey is a required parameter");this.apiKey=n,this.secretKey=i,this.mitigationServiceUrl=h,this.ingestServiceUrl=l,this.mitigationType=y,this.ingestType=null!=b?b:I.HTTP,this.ingestType===I.KINESIS&&(void 0===x?console.warn("NETACEA WARN: no kinesis args provided, when ingestType is ".concat(this.ingestType)):this.kinesis=new ve(f(f({},x),{},{apiKey:this.apiKey}))),void 0===m&&void 0===g||(this.captchaSiteKey=m,this.captchaSecretKey=g),this.timeout=function(e){return e<=0?_:e}(c),this.netaceaCookieName=Pe(S,"_mitata"),this.netaceaCaptchaCookieName=Pe(A,"_mitatacaptcha"),this.encryptedCookies=[this.netaceaCookieName,this.netaceaCaptchaCookieName],this.mitataCookieExpirySeconds=function(e,t){return void 0===t?e===E.INGEST?3600:60:t}(y,null!=w?w:C);var O=we(null!=N?N:"",null!=P?P:"");this.netaceaCookieAttributes=null!==(r=O.cookieAttributes)&&void 0!==r?r:"",this.netaceaCaptchaCookieAttributes=null!==(a=O.captchaCookieAttributes)&&void 0!==a?a:""}),[{key:"runMitigation",value:(C=s(i().mark((function e(t){var r,a,n,o,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,o=this.mitigationType,e.next=o===E.MITIGATE?1:o===E.INJECT?3:o===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,c=e.catch(0),console.error("Netacea FAILOPEN Error:",c),r=t,a=this.isUrlCaptchaPost(r.url,r.method),n=this.mitigationType===E.MITIGATE,e.abrupt("return",{injectHeaders:{"x-netacea-captcha":"0","x-netacea-match":"0","x-netacea-mitigate":"0"},sessionStatus:n&&a?"error_open":""});case 10:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(e){return C.apply(this,arguments)})},{key:"readCookie",value:(x=s(i().mark((function e(t,r){var a,n,o,c,s,u,h;return i().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:a="".concat(t,"="),n=y(r),e.prev=4,n.s();case 5:if((o=n.n()).done){e.next=11;break}if(c=o.value,!(s=c.split(";")[0].trimStart()).startsWith(a)){e.next=10;break}if(u=s.slice(a.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,h=e.catch(4),n.e(h);case 13:return e.prev=13,n.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=s(i().mark((function e(t){var r,a,n,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.constructWebLog(t),this.ingestType!==I.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(f(f({},r),{},{apiKey:this.apiKey}),this.makeRequest.bind(this));case 2:e.next=4;break;case 3:e.prev=3,o=e.catch(1),console.error("NETACEA Error: ",o.message);case 4:e.next=7;break;case 5:return a={"X-Netacea-API-Key":this.apiKey,"content-type":"application/json"},e.next=6,this.makeIngestApiCall(a,r);case 6:if(200===(n=e.sent).status){e.next=7;break}throw this.APIError(n);case 7:case"end":return e.stop()}}),e,this,[[1,3]])}))),function(e){return b.apply(this,arguments)})},{key:"makeIngestApiCall",value:(k=s(i().mark((function e(t,r){return i().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,a=e.status,n=e.method,i=e.path,o=e.protocol,c=e.referer,s=e.bytesSent,u=e.requestTime,h=e.mitataCookie,p=e.sessionStatus,l=e.integrationType,f=e.integrationVersion,d=e.headerFingerprint,v=(new Date).toUTCString();return{Request:"".concat(n," ").concat(i," ").concat(o),TimeLocal:v,RealIp:t,UserAgent:r,Status:a,RequestTime:null==u?void 0:u.toString(),BytesSent:null==s?void 0:s.toString(),Referer:""===c?"-":c,NetaceaUserIdCookie:null!=h?h:"",NetaceaMitigationApplied:null!=p?p:"",IntegrationType:null!=l?l:"",IntegrationVersion:null!=f?f:"",HeaderHash:null!=d?d:""}}},{key:"constructWebLog",value:function(e){return e.bytesSent=""===e.bytesSent?"0":e.bytesSent,this.constructV1WebLog(e)}},{key:"check",value:(g=s(i().mark((function e(t,r,a,n,o,c){var s,u,h,p,l,f,d,v,y,m,g,k;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.secretKey){e.next=1;break}throw new Error("Secret key is required to mitigate");case 1:if((v=U(t,r,this.secretKey)).isPrimaryHashValid&&!v.requiresReissue){e.next=4;break}return e.next=2,this.makeMitigateAPICall(null===(y=v.mitata)||void 0===y?void 0:y.userId,r,a,n,o,c);case 2:return g=e.sent,s=g.status,u=g.match,h=g.mitigate,p=g.captcha,l=g.body,e.next=3,this.createMitata(r,null===(m=v.mitata)||void 0===m?void 0:m.userId,u,h,p,g.mitataMaxAge);case 3:k=e.sent,f=[k],d=g.eventId,e.next=5;break;case 4:s=-1,u=v.match,h=v.mitigate,p=v.captcha,l=void 0,f=[];case 5:return e.abrupt("return",this.composeResult(l,f,s,u,h,p,!1,d));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n,i){return g.apply(this,arguments)})},{key:"createMitata",value:(m=s(i().mark((function e(t,r,a,n,o){var c,s,u,h,p,l,f,d,v=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=v.length>5&&void 0!==v[5]?v[5]:86400,s=v.length>6&&void 0!==v[6]?v[6]:void 0,u=["1","3","5"].includes(o),h="3"===n,p=u||h?-60:this.mitataCookieExpirySeconds,l=null!=s?s:Math.floor(Date.now()/1e3)+p,void 0!==this.secretKey){e.next=1;break}throw new Error("Cannot build cookie without secret key.");case 1:return f=[a,n,o].join(""),d=q(t,r,l,this.secretKey,f),e.abrupt("return",Ae({cookieName:this.netaceaCookieName,cookieValue:d,maxAgeAttribute:String(c),otherAttributes:this.netaceaCookieAttributes}));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return m.apply(this,arguments)})},{key:"processCaptcha",value:(v=s(i().mark((function e(t,r,a,n,o){var c,s,u,h,p,l,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.makeCaptchaAPICall(t,r,a,n,o);case 1:return c=e.sent,s=c.status,u=c.match,h=c.mitigate,p=c.captcha,l=c.body,f=c.setCookie,e.abrupt("return",this.composeResult(l,f,s,u,h,p,!0));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return v.apply(this,arguments)})},{key:"getMitataCaptchaFromHeaders",value:(l=s(i().mark((function e(t){var r,a,n;return i().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 a=parseInt(t[L.netaceaHeaders.mitataCaptchaExpiry]),e.next=2,this.encryptCookieValue(r);case 2:return n=e.sent,e.abrupt("return",Ie({cookieName:this.netaceaCaptchaCookieName,cookieValue:n,maxAgeAttribute:String(isNaN(a)?86400:a),otherAttributes:this.netaceaCaptchaCookieAttributes}));case 3:return e.abrupt("return",void 0);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"makeCaptchaAPICall",value:(h=s(i().mark((function e(t,r,a,n,o){var c,s,u,h;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":a,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},void 0!==(s=B(t))&&(c["X-Netacea-UserId"]=s.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),u={},"string"==typeof o&&""!==o&&(u.headerFP=o),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/AtaVerifyCaptcha",headers:c,method:"POST",body:n,timeout:this.timeout,params:u});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,null==s?void 0:s.userId,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return h.apply(this,arguments)})},{key:"getApiCallResponseFromResponse",value:(c=s(i().mark((function e(t,r,a){var n,o,c,s,u,h,p,l,f,d,v,y,m,g,k;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(200===t.status){e.next=1;break}throw this.APIError(t);case 1:return p=null!==(n=null===(o=t.headers[L.netaceaHeaders.match])||void 0===o?void 0:o.toString())&&void 0!==n?n:"0",l=null!==(c=null===(s=t.headers[L.netaceaHeaders.mitigate])||void 0===s?void 0:s.toString())&&void 0!==c?c:"0",f=null!==(u=null===(h=t.headers[L.netaceaHeaders.captcha])||void 0===h?void 0:h.toString())&&void 0!==u?u:"0",d=parseInt(t.headers[L.netaceaHeaders.mitataExpiry]),isNaN(d)&&(d=86400),e.next=2,this.createMitata(a,r,p,l,f);case 2:return v=e.sent,e.next=3,this.getMitataCaptchaFromHeaders(t.headers);case 3:return y=e.sent,m=[v,y].filter((function(e){return void 0!==e})),g=t.body,k=t.headers[L.netaceaHeaders.eventId],e.abrupt("return",{status:t.status,match:p,mitigate:l,captcha:f,setCookie:m,body:g,eventId:k,mitataMaxAge:d});case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"buildCookieHeader",value:function(e){var t="",r="";for(var a in e){var n=e[a];void 0!==n&&(t="".concat(t).concat(r).concat(a,"=").concat(n),r="; ")}return t}},{key:"makeMitigateAPICall",value:(o=s(i().mark((function e(t,r,a,n,o,c){var s,u,h;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":a,cookie:this.buildCookieHeader({_mitatacaptcha:n})},void 0!==t&&(s["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(s["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,s["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),void 0!==c&&(s["X-Netacea-Captcha-Content-Type"]=c),u={},"string"==typeof o&&""!==o&&(u.headerFP=o),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/",headers:s,method:"GET",timeout:this.timeout,params:u});case 1:return h=e.sent,e.next=2,this.getApiCallResponseFromResponse(h,t,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n,i){return o.apply(this,arguments)})},{key:"composeResult",value:function(e,t,r,a,n,i,o,c){var s=this.findBestMitigation(a,n,i,o),u={body:e,apiCallStatus:r,setCookie:t,sessionStatus:s.sessionStatus,mitigation:s.mitigation,mitigated:[L.mitigationTypes.block,L.mitigationTypes.captcha,L.mitigationTypes.captchaPass].includes(s.mitigation)};if(this.mitigationType===E.INJECT){var h={"x-netacea-match":s.parts.match.toString(),"x-netacea-mitigate":s.parts.mitigate.toString(),"x-netacea-captcha":s.parts.captcha.toString()};void 0!==c&&(h["x-netacea-event-id"]=c),u.injectHeaders=h}return u}},{key:"findBestMitigation",value:function(e,t,r,a){var n,i,o="unknown";a||("2"===r?r="4":"3"===r&&(r="5"));var c=null!==(n=L.matchMap[e])&&void 0!==n?n:o+"_";c+=null!==(i=L.mitigateMap[t])&&void 0!==i?i:o;var s=L.bestMitigationMap[t];if("0"!==r){var u;c+=","+(null!==(u=L.captchaMap[r])&&void 0!==u?u:o);var h=L.bestMitigationCaptchaMap[r];void 0!==h&&(s=h)}return this.mitigationType===E.INJECT&&(s=L.mitigationTypes.none),{sessionStatus:c,mitigation:s,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:(n=s(i().mark((function e(t,r,a){var n,o,c,s,u,h,p;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isUrlCaptchaPost(t.url,t.method)){e.next=2;break}return o=this,c=t.mitata,s=t.clientIp,u=t.userAgent,e.next=1,t.getBodyFn();case 1:h=e.sent,p=r,n=o.processCaptcha.call(o,c,s,u,h,p),e.next=3;break;case 2:n=this.check(t.mitata,t.clientIp,t.userAgent,t.mitataCaptcha,r,a);case 3:return e.next=4,n;case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"setIngestOnlyMitataCookie",value:(a=s(i().mark((function e(t){var r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.createMitata(R,t,"0","0","0",86400);case 1:return r=e.sent,e.abrupt("return",{sessionStatus:"",setCookie:[r]});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"processIngest",value:(r=s(i().mark((function e(t){var r,a,n,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.secretKey){e.next=1;break}throw new Error("Secret key is required for ingest");case 1:return r=this.getCookieHeader(t),e.next=2,this.readCookie(this.netaceaCookieName,r);case 2:if(a=e.sent,(n=U(a,R,this.secretKey)).isPrimaryHashValid){e.next=4;break}return e.next=3,this.setIngestOnlyMitataCookie(void 0);case 3:case 5:return e.abrupt("return",e.sent);case 4:if(!n.requiresReissue){e.next=6;break}return e.next=5,this.setIngestOnlyMitataCookie(null===(o=n.mitata)||void 0===o?void 0:o.userId);case 6:return e.abrupt("return",{sessionStatus:"",setCookie:[]});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"encryptCookieValue",value:(t=s(i().mark((function e(t){return i().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=s(i().mark((function e(t){return i().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,a,n,o,c,h,l,v,m,g,k,b,x,C}(),Ne=function(){function e(r){var a,n,i,o,c;u(this,e),d(c=t(this,e,[r]),"httpsAgent",void 0),d(c,"mitataCookieName",void 0),d(c,"mitataCaptchaCookieName",void 0),d(c,"hashGenerator",void 0),d(c,"debugMode",void 0),d(c,"encryptionEnabled",!1),d(c,"encryptionKeyBuffer",void 0),d(c,"mitigationHeaders",["cookie","user-agent","accept","host"]),d(c,"netaceaCaptchaPath",void 0),d(c,"captchaHost",void 0),c.httpsAgent=new O.Agent({timeout:c.timeout,keepAlive:!0,maxSockets:null!==(a=r.maxSockets)&&void 0!==a?a:25}),c.mitataCookieName=null!==(n=r.netaceaCookieName)&&void 0!==n?n:"_mitata",c.mitataCaptchaCookieName=null!==(i=r.netaceaCaptchaCookieName)&&void 0!==i?i:"_mitatacaptcha";var s=function(){return p((function e(){u(this,e)}),[{key:"encode",value:function(e){return new Uint8Array(Buffer.from(e,"utf8"))}}])}();if(c.hashGenerator=new Y(ye,s),c.debugMode=null!==(o=r.debugMode)&&void 0!==o&&o,c.netaceaCaptchaPath=function(e){if(null!=e&&""!==e)return"/"!==e[0]&&(e="/"+e),ge.test(e)?e:void 0}(r.netaceaCaptchaPath),c.captchaHost=r.captchaHost,void 0!==r.cookieEncryptionKey){var h=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=Z(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);h.valid&&void 0!==h.keyBuffer?(c.encryptionKeyBuffer=h.keyBuffer,c.encryptionEnabled=!0):console.warn("NETACEA WARN: Invalid cookieEncryptionKey - ".concat(h.error,". Cookies will not be encrypted."))}return c}return function(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&&n(e,t)}(e,Ee),p(e,[{key:"computeHeaderFingerprint",value:(b=s(i().mark((function e(t){var r;return i().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 b.apply(this,arguments)})},{key:"handleGetCaptchaRequest",value:(k=s(i().mark((function e(t,r,a,n,o,c,s){var u,h,p,l,f,d,v,y,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=be(c),h=xe(o),p={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":t,"user-agent":r,cookie:void 0!==a?"_mitatacaptcha="+a:"","X-Netacea-Captcha-Content-Type":h},void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(p["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,p["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),l={netaceaHeaders:"request-id"},"string"==typeof n&&""!==n&&(l.headerFP=n),null!==u&&(l.trackingId=u),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/captcha",headers:p,method:"GET",timeout:this.timeout,params:l});case 1:if(200===(f=e.sent).status){e.next=2;break}throw this.APIError(f);case 2:return d=f.body,"application/json"===h&&void 0!==this.netaceaCaptchaPath&&void 0!==d&&(m=null!==(v=null!==(y=this.captchaHost)&&void 0!==y?y:s)&&void 0!==v?v:"",d=Ce(d,m,this.netaceaCaptchaPath)),e.abrupt("return",{body:d,apiCallStatus:f.status,setCookie:[],sessionStatus:",captcha_serve",mitigation:"captcha",mitigated:!0});case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n,i,o){return k.apply(this,arguments)})},{key:"encryptCookieValue",value:(g=s(i().mark((function e(t){return i().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",ee(t,this.encryptionKeyBuffer));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"decryptCookieValue",value:(v=s(i().mark((function e(t){return i().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(5===(r=t).split(".").length&&r.includes("..")){e.next=2;break}throw new Error("Cookie is not JWE encrypted");case 2:return e.abrupt("return",te(t,this.encryptionKeyBuffer));case 3:case"end":return e.stop()}var r}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"createMitata",value:(f=s(i().mark((function e(t,r,a,n,o){var c,s,u,h,p,l,f,d,v,y=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=y.length>5&&void 0!==y[5]?y[5]:86400,s=y.length>6&&void 0!==y[6]?y[6]:void 0,u=["1","3","5"].includes(o),h="3"===n,p=u||h?-60:this.mitataCookieExpirySeconds,l=null!=s?s:Math.floor(Date.now()/1e3)+p,void 0!==this.secretKey){e.next=1;break}throw new Error("Cannot build cookie without secret key.");case 1:return f=[a,n,o].join(""),d=q(t,r,l,this.secretKey,f),e.next=2,this.encryptCookieValue(d);case 2:return v=e.sent,e.abrupt("return",Ae({cookieName:this.netaceaCookieName,cookieValue:v,maxAgeAttribute:String(c),otherAttributes:this.netaceaCookieAttributes}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return f.apply(this,arguments)})},{key:"getInjectHeaders",value:function(e){if(this.mitigationType===E.INJECT){var t=e;if(void 0!==t.injectHeaders){var r={},a=t.injectHeaders;return r["x-netacea-match"]=a["x-netacea-match"],r["x-netacea-mitigate"]=a["x-netacea-mitigate"],r["x-netacea-captcha"]=a["x-netacea-captcha"],void 0!==a["x-netacea-event-id"]&&(r["x-netacea-event-id"]=a["x-netacea-event-id"]),this.encodeHeadersAsKeyValueList(r)}}return[]}},{key:"registerPolicyHandler",value:function(e){var t=this;e.addMethod("getMitigationHeaderPolicy",(function(e,r){var a=t.mitigationHeaders.join(",");console.info('level=info component=f5 handler=getMitigationHeaderPolicy policy="'.concat(a,'"')),r.reply(a)}))}},{key:"encodeHeadersAsKeyValueList",value:function(e){for(var t=[],r=0,a=Object.entries(e);r<a.length;r++){var n=m(a[r],2),i=n[0],o=n[1];if(Array.isArray(o)){var c,s=y(o);try{for(s.s();!(c=s.n()).done;){var u=c.value;t.push(i,Buffer.from(u).toString("base64"))}}catch(e){s.e(e)}finally{s.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=s(i().mark((function e(r,a){var n,o,c,s,u,h,p,l,f,d,v,y,g,k,b,x,C,w,S,A,I,E,N,P,O,T,_,j,K,M;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=r.params(),s=m(c,3),u=s[0],h=s[1],p=s[2],l=t.getArrayValueOrDefault(c,3,void 0),f=t.getArrayValueOrDefault(c,4,void 0),d=t.getArrayValueOrDefault(c,5,void 0),v=t.parseHeaderValues(d),y=null!==(n=v.cookie)&&void 0!==n?n:null,g=null!==(o=v["user-agent"])&&void 0!==o?o:"",k=v.accept,e.prev=1,e.next=2,t.computeHeaderFingerprint(f);case 2:return x=e.sent,t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=header_fingerprint method="'.concat(h,'" path="').concat(p,'" headers="').concat(null!=f?f:"",'" header_count=').concat(null!==(C=null==f?void 0:f.split(",").length)&&void 0!==C?C:0,' fingerprint="').concat(x,'"')),e.next=3,t.getMitataCookies(y);case 3:return w=e.sent,S=m(w,2),A=S[0],I=S[1],t.debugMode&&console.info('level=debug component=f5 handler=handleRequest event=mitigation_request headerFP="'.concat(x,'"')),e.next=4,t.runMitigation({ip:u,method:h,url:p,mitataCaptchaCookie:I,mitataCookie:A,userAgent:g,body:l,headerFingerprint:x,acceptHeader:k,hostHeader:v.host});case 4:if(E=e.sent,N="",(ke(p,h,t.netaceaCaptchaPath)||void 0!==t.netaceaCaptchaPath&&"captcha"===(null==E||null===(b=E.response)||void 0===b?void 0:b.mitigation))&&(N="application/json"===xe(k)?"application/json":"text/html; charset=UTF-8"),"error_open"!==(null==E?void 0:E.sessionStatus)){e.next=5;break}return a.reply(["",500,"error_open",!0,"",x,[],[]]),e.abrupt("return");case 5:if(void 0!==E){e.next=6;break}return a.reply(["",0,"",!1,"",x,[],[]]),e.abrupt("return");case 6:P="",O=0,T=!1,_=t.getValueOrDefault(A,""),void 0!==E.setCookie&&E.setCookie.length>0&&void 0!==(j=E.setCookie.find((function(e){return e.includes("".concat(t.netaceaCookieName,"="))})))&&(_=j.split(";")[0].replace("".concat(t.netaceaCookieName,"="),"")),void 0!==E.response&&(O=t.getValueOrDefault(E.response.apiCallStatus,0),P=t.getValueOrDefault(E.response.body,"Forbidden"),T=t.getValueOrDefault(E.response.mitigated,T)),K={},void 0!==E.setCookie&&E.setCookie.length>0&&(K["Set-Cookie"]=E.setCookie),""!==N&&(K["Content-Type"]=N),a.reply([P,O,t.getValueOrDefault(E.sessionStatus,""),T,t.getValueOrDefault(_,""),x,t.getInjectHeaders(E),t.encodeHeadersAsKeyValueList(K)]),e.next=8;break;case 7:e.prev=7,M=e.catch(1),console.error("Could not reach Netacea mitigation API: ",M.message),a.reply(["",0,"",!1,"","",[],[]]);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(","),a=0;a<this.mitigationHeaders.length&&a<r.length;a++)t[this.mitigationHeaders[a].toLowerCase()]=Buffer.from(r[a],"base64").toString("utf8");return t}},{key:"getValueOrDefault",value:function(e,t){return null!=e?e:t}},{key:"getArrayValueOrDefault",value:function(e,t,r){var a;return null!==(a=e[t])&&void 0!==a?a:r}},{key:"getMitataCookies",value:(l=s(i().mark((function e(t){var r,a,n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null==t?void 0:t.split("; "),a=this.getCookie(this.mitataCookieName,r),n=this.getCookie(this.mitataCaptchaCookieName,r),void 0===a){e.next=4;break}return e.prev=1,e.next=2,this.decryptCookieValue(a);case 2:a=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),a=void 0;case 4:if(void 0===n){e.next=8;break}return e.prev=5,e.next=6,this.decryptCookieValue(n);case 6:n=e.sent,e.next=8;break;case 7:e.prev=7,e.catch(5),n=void 0;case 8:return e.abrupt("return",[a,n]);case 9:case"end":return e.stop()}}),e,this,[[1,3],[5,7]])}))),function(e){return l.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=s(i().mark((function e(r,a){var n,o,c,s,u,h,p,l,f,d,v,y,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=r.params(),c=t.getArrayValueOrDefault(o,0,""),s=t.getArrayValueOrDefault(o,1,""),u=t.getArrayValueOrDefault(o,2,"-1"),h=t.getArrayValueOrDefault(o,3,""),p=t.getArrayValueOrDefault(o,4,""),l=t.getArrayValueOrDefault(o,5,""),f=t.getArrayValueOrDefault(o,6,""),d=t.getArrayValueOrDefault(o,7,"0"),v=t.getArrayValueOrDefault(o,8,"0"),n=t.getArrayValueOrDefault(o,9,""),y=t.getArrayValueOrDefault(o,10,""),m=t.getArrayValueOrDefault(o,11,""),t.debugMode&&console.info('level=debug component=f5 handler=ingest event=ingest_request ingestType="'.concat(t.ingestType,'" headerFingerprint="').concat(m,'"')),void 0===n){e.next=4;break}return e.prev=1,e.next=2,t.decryptCookieValue(n);case 2:n=e.sent,e.next=4;break;case 3:e.prev=3,e.catch(1),n=void 0;case 4:t.ingest({ip:c,userAgent:s,status:u,method:h,path:p,protocol:l,referer:f,bytesSent:d,requestTime:v,mitataCookie:n,sessionStatus:y,headerFingerprint:m}).catch((function(e){console.error("Could not reach Netacea ingest API: "+e.message)})),a.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:(h=s(i().mark((function e(t){var r=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e,a){t.host=t.host.replace("https://","");var n=t.path;if(void 0!==t.params){var i=t.params instanceof URLSearchParams?t.params.toString():T.stringify(t.params);""!==i&&(n+=(n.includes("?")?"&":"?")+i)}for(var o=O.request({agent:r.httpsAgent,host:t.host,path:n,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 a;e({headers:t.headers,status:null!==(a=t.statusCode)&&void 0!==a?a:0,body:""===r?void 0:r})}))})),c=0,s=["error","abort","timeout"];c<s.length;c++){var u=s[c];o.on(u,(function(e){a(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 h.apply(this,arguments)})},{key:"mitigate",value:(c=s(i().mark((function e(t){var r,a,n,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,a={sessionStatus:r.sessionStatus,setCookie:r.setCookie},r.mitigated&&(a.response={body:null!==(n=r.body)&&void 0!==n?n:"Forbidden",status:403,apiCallStatus:null!==(o=r.apiCallStatus)&&void 0!==o?o:-1,mitigation:r.mitigation,mitigated:r.mitigated}),e.abrupt("return",a);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"inject",value:(o=s(i().mark((function e(t){var r;return i().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 o.apply(this,arguments)})},{key:"getMitigationResponse",value:(a=s(i().mark((function e(t){var r,a,n,o,c,u,h,p,l,f,d,v,y,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.ip,a=t.userAgent,n=t.url,o=t.method,c=t.mitataCookie,u=t.mitataCaptchaCookie,h=t.body,p=t.headerFingerprint,l=t.acceptHeader,f=t.hostHeader,!ke(n,o,this.netaceaCaptchaPath)){e.next=2;break}return e.next=1,this.handleGetCaptchaRequest(r,a,u,null!=p?p:"",l,n,f);case 1:return e.abrupt("return",e.sent);case 2:return d=void 0!==this.netaceaCaptchaPath?xe(l):void 0,e.next=3,this.processMitigateRequest({clientIp:r,getBodyFn:function(){var e=s(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,Promise.resolve(h);case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),method:o,mitata:c,mitataCaptcha:u,url:n,userAgent:a},p,d);case 3:return v=e.sent,"application/json"===d&&void 0!==this.netaceaCaptchaPath&&void 0!==v.body&&"captcha"===v.mitigation&&(v.body=Ce(v.body,null!==(y=null!==(m=this.captchaHost)&&void 0!==m?m:f)&&void 0!==y?y:"",this.netaceaCaptchaPath)),e.abrupt("return",v);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"ingest",value:(r=s(i().mark((function e(t){var r,a,n,o,c,s,u,h,p,l,f,d;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ip,a=t.userAgent,n=t.status,o=t.method,c=t.path,s=t.protocol,u=t.referer,h=t.bytesSent,p=t.requestTime,l=t.mitataCookie,f=t.sessionStatus,d=t.headerFingerprint,e.next=1,this.callIngest({ip:r,userAgent:a,status:n,method:o,bytesSent:h,path:c,protocol:s,referer:u,requestTime:p,mitataCookie:l,sessionStatus:f,headerFingerprint:d,integrationType:"@netacea/f5".replace("@netacea/",""),integrationVersion:"5.2.1"});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,a,o,c,h,l,f,v,g,k,b}();function Pe(e,t){return"string"==typeof e&&""!==e?e:"number"==typeof e?e.toString():t}module.exports=Ne;
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netacea/f5",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
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": "de85196f95e1aa31ef7d25d8bb6da41ce98b85e4"
24
+ "gitHead": "e8c9ab347e5d16c4f6a1877b3eb31f1d7f7997bf"
25
25
  }