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