Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@commercetools/sdk-middleware-http

Package Overview
Dependencies
Maintainers
15
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools/sdk-middleware-http - npm Package Compare versions

Comparing version 6.0.11 to 6.1.0

24

dist/sdk-middleware-http.cjs.js

@@ -291,2 +291,4 @@ 'use strict';

maxDelay = _ref2$retryConfig$max2 === void 0 ? Infinity : _ref2$retryConfig$max2,
_ref2$retryConfig$ret2 = _ref2$retryConfig.retryOnAbort,
retryOnAbort = _ref2$retryConfig$ret2 === void 0 ? false : _ref2$retryConfig$ret2,
fetcher = _ref2.fetch,

@@ -311,4 +313,2 @@ _abortController = _ref2.abortController,

var abortController;
if (timeout || getAbortController || _abortController) // eslint-disable-next-line
abortController = (getAbortController ? getAbortController() : null) || _abortController || new AbortController();
var url = host.replace(/\/$/, '') + request.uri;

@@ -337,4 +337,9 @@ var body = typeof request.body === 'string' || Buffer.isBuffer(request.body) ? request.body : // NOTE: `stringify` of `null` gives the String('null')

if (abortController) {
fetchOptions.signal = abortController.signal;
if (!retryOnAbort) {
if (timeout || getAbortController || _abortController) // eslint-disable-next-line
abortController = (getAbortController ? getAbortController() : null) || _abortController || new AbortController();
if (abortController) {
fetchOptions.signal = abortController.signal;
}
}

@@ -349,3 +354,12 @@

function executeFetch() {
// Kick off timer for abortController directly before fetch.
if (retryOnAbort) {
if (timeout || getAbortController || _abortController) // eslint-disable-next-line
abortController = (getAbortController ? getAbortController() : null) || _abortController || new AbortController();
if (abortController) {
fetchOptions.signal = abortController.signal;
}
} // Kick off timer for abortController directly before fetch.
var timer;

@@ -352,0 +366,0 @@ if (timeout) timer = setTimeout(function () {

@@ -287,2 +287,4 @@ function _typeof(obj) {

maxDelay = _ref2$retryConfig$max2 === void 0 ? Infinity : _ref2$retryConfig$max2,
_ref2$retryConfig$ret2 = _ref2$retryConfig.retryOnAbort,
retryOnAbort = _ref2$retryConfig$ret2 === void 0 ? false : _ref2$retryConfig$ret2,
fetcher = _ref2.fetch,

@@ -307,4 +309,2 @@ _abortController = _ref2.abortController,

var abortController;
if (timeout || getAbortController || _abortController) // eslint-disable-next-line
abortController = (getAbortController ? getAbortController() : null) || _abortController || new AbortController();
var url = host.replace(/\/$/, '') + request.uri;

@@ -333,4 +333,9 @@ var body = typeof request.body === 'string' || Buffer.isBuffer(request.body) ? request.body : // NOTE: `stringify` of `null` gives the String('null')

if (abortController) {
fetchOptions.signal = abortController.signal;
if (!retryOnAbort) {
if (timeout || getAbortController || _abortController) // eslint-disable-next-line
abortController = (getAbortController ? getAbortController() : null) || _abortController || new AbortController();
if (abortController) {
fetchOptions.signal = abortController.signal;
}
}

@@ -345,3 +350,12 @@

function executeFetch() {
// Kick off timer for abortController directly before fetch.
if (retryOnAbort) {
if (timeout || getAbortController || _abortController) // eslint-disable-next-line
abortController = (getAbortController ? getAbortController() : null) || _abortController || new AbortController();
if (abortController) {
fetchOptions.signal = abortController.signal;
}
} // Kick off timer for abortController directly before fetch.
var timer;

@@ -348,0 +362,0 @@ if (timeout) timer = setTimeout(function () {

@@ -1,1 +0,1 @@

!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).CommercetoolsSdkMiddlewareHttp={})}(this,function(t){"use strict";var r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,c=!1;function l(){c=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)s[r]=t[r],f[t.charCodeAt(r)]=r;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63}function p(t,r,e){for(var n,o,i=[],a=r;a<e;a+=3)n=(t[a]<<16)+(t[a+1]<<8)+t[a+2],i.push(s[(o=n)>>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}function u(t){var r;c||l();for(var e=t.length,n=e%3,o="",i=[],a=0,u=e-n;a<u;a+=16383)i.push(p(t,a,u<a+16383?u:a+16383));return 1==n?(r=t[e-1],o+=s[r>>2],o+=s[r<<4&63],o+="=="):2==n&&(r=(t[e-2]<<8)+t[e-1],o+=s[r>>10],o+=s[r>>4&63],o+=s[r<<2&63],o+="="),i.push(o),i.join("")}function e(t,r,e,n,o){var i,a,u=8*o-n-1,s=(1<<u)-1,f=s>>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0<h;i=256*i+t[r+c],c+=l,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=n;0<h;a=256*a+t[r+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===s)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)}function i(t,r,e,n,o,i){var a,u,s,f=8*i-o-1,h=(1<<f)-1,c=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,g=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,a=h):(a=Math.floor(Math.log(r)/Math.LN2),r*(s=Math.pow(2,-a))<1&&(a--,s*=2),2<=(r+=1<=a+c?l/s:l*Math.pow(2,1-c))*s&&(a++,s/=2),h<=a+c?(u=0,a=h):1<=a+c?(u=(r*s-1)*Math.pow(2,o),a+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),a=0));8<=o;t[e+p]=255&u,p+=g,u/=256,o-=8);for(a=a<<o|u,f+=o;0<f;t[e+p]=255&a,p+=g,a/=256,f-=8);t[e+p-g]|=128*y}var n={}.toString,a=Array.isArray||function(t){return"[object Array]"==n.call(t)};function o(){return R.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function g(t,r){if(o()<r)throw new RangeError("Invalid typed array length");return R.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=R.prototype:(null===t&&(t=new R(r)),t.length=r),t}function R(t,r,e){if(!(R.TYPED_ARRAY_SUPPORT||this instanceof R))return new R(t,r,e);if("number"!=typeof t)return y(this,t,r,e);if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return w(this,t)}function y(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n);R.TYPED_ARRAY_SUPPORT?(t=r).__proto__=R.prototype:t=v(t,r);return t}(t,r,e,n):"string"==typeof r?function(t,r,e){"string"==typeof e&&""!==e||(e="utf8");if(!R.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|m(r,e),o=(t=g(t,n)).write(r,e);o!==n&&(t=t.slice(0,o));return t}(t,r,e):function(t,r){if(E(r)){var e=0|b(r.length);return 0===(t=g(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||function(t){return t!=t}(r.length)?g(t,0):v(t,r);if("Buffer"===r.type&&a(r.data))return v(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function d(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function w(t,r){if(d(r),t=g(t,r<0?0:0|b(r)),!R.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function v(t,r){var e=r.length<0?0:0|b(r.length);t=g(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function b(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function E(t){return null!=t&&t._isBuffer}function m(t,r){if(E(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return N(t).length;default:if(n)return k(t).length;r=(""+r).toLowerCase(),n=!0}}function A(t,r,e){var n,o,i,a=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":return function(t,r,e){var n=t.length;(!r||r<0)&&(r=0);(!e||e<0||n<e)&&(e=n);for(var o="",i=r;i<e;++i)o+=function(t){return t<16?"0"+t.toString(16):t.toString(16)}(t[i]);return o}(this,r,e);case"utf8":case"utf-8":return U(this,r,e);case"ascii":return function(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(127&t[o]);return n}(this,r,e);case"latin1":case"binary":return function(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}(this,r,e);case"base64":return n=this,i=e,0===(o=r)&&i===n.length?u(n):u(n.slice(o,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}(this,r,e);default:if(a)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),a=!0}}function _(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function P(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647<e?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=R.from(r,n)),E(r))return 0===r.length?-1:T(t,r,e,n,o);if("number"==typeof r)return r&=255,R.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):T(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function T(t,r,e,n,o){var i=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=i=2,u/=2,e/=2}function s(t,r){return 1===i?t[r]:t.readUInt16BE(r*i)}if(o)for(var f=-1,h=e;h<a;h++)if(s(t,h)===s(r,-1===f?0:h-f)){if(-1===f&&(f=h),h-f+1===u)return f*i}else-1!==f&&(h-=h-f),f=-1;else for(a<e+u&&(e=a-u),h=e;0<=h;h--){for(var c=!0,l=0;l<u;l++)if(s(t,h+l)!==s(r,l)){c=!1;break}if(c)return h}return-1}function O(t,r,e,n){return z(function(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}(r),t,e,n)}function S(t,r,e,n){return z(function(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function U(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i,a,u,s,f=t[o],h=null,c=239<f?4:223<f?3:191<f?2:1;if(o+c<=e)switch(c){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&127<(s=(31&f)<<6|63&i)&&(h=s);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&2047<(s=(15&f)<<12|(63&i)<<6|63&a)&&(s<55296||57343<s)&&(h=s);break;case 4:i=t[o+1],a=t[o+2],u=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&u)&&65535<(s=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&u)&&s<1114112&&(h=s)}null===h?(h=65533,c=1):65535<h&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=C)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=C));return e}(n)}R.TYPED_ARRAY_SUPPORT=void 0===r.TYPED_ARRAY_SUPPORT||r.TYPED_ARRAY_SUPPORT,R.poolSize=8192,R._augment=function(t){return t.__proto__=R.prototype,t},R.from=function(t,r,e){return y(null,t,r,e)},R.TYPED_ARRAY_SUPPORT&&(R.prototype.__proto__=Uint8Array.prototype,R.__proto__=Uint8Array),R.alloc=function(t,r,e){return n=null,i=r,a=e,d(o=t),!(o<=0)&&void 0!==i?"string"==typeof a?g(n,o).fill(i,a):g(n,o).fill(i):g(n,o);var n,o,i,a},R.allocUnsafe=function(t){return w(null,t)},R.allocUnsafeSlow=function(t){return w(null,t)},R.isBuffer=q,R.compare=function(t,r){if(!E(t)||!E(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,o=0,i=Math.min(e,n);o<i;++o)if(t[o]!==r[o]){e=t[o],n=r[o];break}return e<n?-1:n<e?1:0},R.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},R.concat=function(t,r){if(!a(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return R.alloc(0);if(void 0===r)for(o=r=0;o<t.length;++o)r+=t[o].length;for(var e=R.allocUnsafe(r),n=0,o=0;o<t.length;++o){var i=t[o];if(!E(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(e,n),n+=i.length}return e},R.byteLength=m,R.prototype._isBuffer=!0,R.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)_(this,r,r+1);return this},R.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)_(this,r,r+3),_(this,r+1,r+2);return this},R.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)_(this,r,r+7),_(this,r+1,r+6),_(this,r+2,r+5),_(this,r+3,r+4);return this},R.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?U(this,0,t):A.apply(this,arguments)},R.prototype.equals=function(t){if(!E(t))throw new TypeError("Argument must be a Buffer");return this===t||0===R.compare(this,t)},R.prototype.inspect=function(){var t="";return 0<this.length&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),50<this.length&&(t+=" ... ")),"<Buffer "+t+">"},R.prototype.compare=function(t,r,e,n,o){if(!E(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(e>>>=0)-(r>>>=0),u=Math.min(i,a),s=this.slice(n,o),f=t.slice(r,e),h=0;h<u;++h)if(s[h]!==f[h]){i=s[h],a=f[h];break}return i<a?-1:a<i?1:0},R.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},R.prototype.indexOf=function(t,r,e){return P(this,t,r,e,!0)},R.prototype.lastIndexOf=function(t,r,e){return P(this,t,r,e,!1)},R.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(e)?(e|=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||o<e)&&(e=o),0<t.length&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var i,a,u,s,f,h,c=!1;;)switch(n){case"hex":return function(t,r,e,n){e=Number(e)||0;var o=t.length-e;(!n||o<(n=Number(n)))&&(n=o);var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");i/2<n&&(n=i/2);for(var a=0;a<n;++a){var u=parseInt(r.substr(2*a,2),16);if(isNaN(u))return a;t[e+a]=u}return a}(this,t,r,e);case"utf8":case"utf-8":return f=r,h=e,z(k(t,(s=this).length-f),s,f,h);case"ascii":return O(this,t,r,e);case"latin1":case"binary":return O(this,t,r,e);case"base64":return i=this,a=r,u=e,z(N(t),i,a,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r,e);default:if(c)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),c=!0}},R.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,r,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(e<t+r)throw new RangeError("Trying to access beyond buffer length")}function Y(t,r,e,n,o,i){if(!E(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(o<r||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function I(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function M(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>8*(n?o:3-o)&255}function D(t,r,e,n){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function L(t,r,e,n,o){return o||D(t,0,e,4),i(t,r,e,n,23,4),e+4}function x(t,r,e,n,o){return o||D(t,0,e,8),i(t,r,e,n,52,8),e+8}R.prototype.slice=function(t,r){var e=this.length;if((t=~~t)<0?(t+=e)<0&&(t=0):e<t&&(t=e),(r=void 0===r?e:~~r)<0?(r+=e)<0&&(r=0):e<r&&(r=e),r<t&&(r=t),R.TYPED_ARRAY_SUPPORT)(o=this.subarray(t,r)).__proto__=R.prototype;else for(var n=r-t,o=new R(n,void 0),i=0;i<n;++i)o[i]=this[i+t];return o},R.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n},R.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=this[t+--r],o=1;0<r&&(o*=256);)n+=this[t+--r]*o;return n},R.prototype.readUInt8=function(t,r){return r||B(t,1,this.length),this[t]},R.prototype.readUInt16LE=function(t,r){return r||B(t,2,this.length),this[t]|this[t+1]<<8},R.prototype.readUInt16BE=function(t,r){return r||B(t,2,this.length),this[t]<<8|this[t+1]},R.prototype.readUInt32LE=function(t,r){return r||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},R.prototype.readUInt32BE=function(t,r){return r||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},R.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return(o*=128)<=n&&(n-=Math.pow(2,8*r)),n},R.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0<n&&(o*=256);)i+=this[t+--n]*o;return(o*=128)<=i&&(i-=Math.pow(2,8*r)),i},R.prototype.readInt8=function(t,r){return r||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},R.prototype.readInt16LE=function(t,r){r||B(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},R.prototype.readInt16BE=function(t,r){r||B(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},R.prototype.readInt32LE=function(t,r){return r||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},R.prototype.readInt32BE=function(t,r){return r||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},R.prototype.readFloatLE=function(t,r){return r||B(t,4,this.length),e(this,t,!0,23,4)},R.prototype.readFloatBE=function(t,r){return r||B(t,4,this.length),e(this,t,!1,23,4)},R.prototype.readDoubleLE=function(t,r){return r||B(t,8,this.length),e(this,t,!0,52,8)},R.prototype.readDoubleBE=function(t,r){return r||B(t,8,this.length),e(this,t,!1,52,8)},R.prototype.writeUIntLE=function(t,r,e,n){t=+t,r|=0,e|=0,n||Y(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i<e&&(o*=256);)this[r+i]=t/o&255;return r+e},R.prototype.writeUIntBE=function(t,r,e,n){t=+t,r|=0,e|=0,n||Y(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},R.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,1,255,0),R.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},R.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,65535,0),R.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):I(this,t,r,!0),r+2},R.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,65535,0),R.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):I(this,t,r,!1),r+2},R.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,4294967295,0),R.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):M(this,t,r,!0),r+4},R.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,4294967295,0),R.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):M(this,t,r,!1),r+4},R.prototype.writeIntLE=function(t,r,e,n){var o;t=+t,r|=0,n||Y(this,t,r,e,(o=Math.pow(2,8*e-1))-1,-o);var i=0,a=1,u=0;for(this[r]=255&t;++i<e&&(a*=256);)t<0&&0===u&&0!==this[r+i-1]&&(u=1),this[r+i]=(t/a>>0)-u&255;return r+e},R.prototype.writeIntBE=function(t,r,e,n){var o;t=+t,r|=0,n||Y(this,t,r,e,(o=Math.pow(2,8*e-1))-1,-o);var i=e-1,a=1,u=0;for(this[r+i]=255&t;0<=--i&&(a*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/a>>0)-u&255;return r+e},R.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,1,127,-128),R.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},R.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,32767,-32768),R.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):I(this,t,r,!0),r+2},R.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,32767,-32768),R.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):I(this,t,r,!1),r+2},R.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,2147483647,-2147483648),R.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):M(this,t,r,!0),r+4},R.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),R.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):M(this,t,r,!1),r+4},R.prototype.writeFloatLE=function(t,r,e){return L(this,t,r,!0,e)},R.prototype.writeFloatBE=function(t,r,e){return L(this,t,r,!1,e)},R.prototype.writeDoubleLE=function(t,r,e){return x(this,t,r,!0,e)},R.prototype.writeDoubleBE=function(t,r,e){return x(this,t,r,!1,e)},R.prototype.copy=function(t,r,e,n){if(e=e||0,n||0===n||(n=this.length),r>=t.length&&(r=t.length),r=r||0,0<n&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var o,i=n-e;if(this===t&&e<r&&r<n)for(o=i-1;0<=o;--o)t[o+r]=this[o+e];else if(i<1e3||!R.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+r]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),r);return i},R.prototype.fill=function(t,r,e,n){if("string"==typeof t){var o;if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1!==t.length||(o=t.charCodeAt(0))<256&&(t=o),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!R.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;if(r>>>=0,e=void 0===e?this.length:e>>>0,"number"==typeof(t=t||0))for(u=r;u<e;++u)this[u]=t;else for(var i=E(t)?t:k(new R(t,n).toString()),a=i.length,u=0;u<e-r;++u)this[u+r]=i[u%a];return this};var j=/[^+\/0-9A-Za-z-_]/g;function k(t,r){var e;r=r||1/0;for(var n=t.length,o=null,i=[],a=0;a<n;++a){if(55295<(e=t.charCodeAt(a))&&e<57344){if(!o){if(56319<e){-1<(r-=3)&&i.push(239,191,189);continue}if(a+1===n){-1<(r-=3)&&i.push(239,191,189);continue}o=e;continue}if(e<56320){-1<(r-=3)&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&-1<(r-=3)&&i.push(239,191,189);if(o=null,e<128){if(--r<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function N(t){return function(t){var r,e,n,o;c||l();var i=t.length;if(0<i%4)throw new Error("Invalid string. Length must be a multiple of 4");n="="===t[i-2]?2:"="===t[i-1]?1:0,o=new h(3*i/4-n),r=0<n?i-4:i;for(var a=0,u=0;u<r;u+=4,0)e=f[t.charCodeAt(u)]<<18|f[t.charCodeAt(u+1)]<<12|f[t.charCodeAt(u+2)]<<6|f[t.charCodeAt(u+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2==n?(e=f[t.charCodeAt(u)]<<2|f[t.charCodeAt(u+1)]>>4,o[a++]=255&e):1==n&&(e=f[t.charCodeAt(u)]<<10|f[t.charCodeAt(u+1)]<<4|f[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(function(t){var r;if((t=((r=t).trim?r.trim():r.replace(/^\s+|\s+$/g,"")).replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function q(t){return null!=t&&(!!t._isBuffer||F(t)||"function"==typeof(r=t).readFloatLE&&"function"==typeof r.slice&&F(r.slice(0,0)));var r}function F(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function H(t){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function J(r,t){var e,n=Object.keys(r);return Object.getOwnPropertySymbols&&(e=Object.getOwnPropertySymbols(r),t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),n.push.apply(n,e)),n}function V(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?J(Object(i),!0).forEach(function(t){var r,e,n;r=o,n=i[e=t],e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):J(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function Z(t,r){if(null==t)return{};var e,n=function(t,r){if(null==t)return{};for(var e,n={},o=Object.keys(t),i=0;i<o.length;i++)e=o[i],0<=r.indexOf(e)||(n[e]=t[e]);return n}(t,r);if(Object.getOwnPropertySymbols)for(var o=Object.getOwnPropertySymbols(t),i=0;i<o.length;i++)e=o[i],0<=r.indexOf(e)||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e]);return n}function $(t,r){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.status=this.statusCode=this.code=t,this.message=r,Object.assign(this,e),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function G(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,0].concat(r))}function K(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this].concat(r))}function Q(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,400].concat(r))}function W(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,401].concat(r))}function X(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,403].concat(r))}function tt(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,404].concat(r))}function rt(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,409].concat(r))}function et(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,500].concat(r))}function nt(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,503].concat(r))}function ot(t){switch(t){case 0:return G;case 400:return Q;case 401:return W;case 403:return X;case 404:return tt;case 409:return rt;case 500:return et;case 503:return nt;default:return}}var it=Object.freeze({__proto__:null,NetworkError:G,HttpError:K,BadRequest:Q,Unauthorized:W,Forbidden:X,NotFound:tt,ConcurrentModification:rt,InternalServerError:et,ServiceUnavailable:nt,default:ot});function at(t){if(t.raw)return t.raw();if(!t.forEach)return{};var e={};return t.forEach(function(t,r){e[r]=t}),e}function ut(t,r,e,n,o){return n&&0!==t?Math.min(Math.round((Math.random()+1)*r*Math.pow(2,t)),o):r}function st(t,r){r&&(t.headers.authorization&&(t.headers.authorization="Bearer ********"),t.headers.Authorization&&(t.headers.Authorization="Bearer ********"))}t.createHttpMiddleware=function(t){var o,h=t.host,c=t.credentialsMode,l=t.includeResponseHeaders,p=t.includeOriginalRequest,r=t.maskSensitiveHeaderData,g=void 0===r||r,y=t.enableRetry,d=t.timeout,e=t.retryConfig,n=(e=void 0===e?{}:e).maxRetries,w=void 0===n?10:n,i=e.backoff,v=void 0===i||i,a=e.retryDelay,b=void 0===a?200:a,u=e.maxDelay,E=void 0===u?1/0:u,s=t.fetch,m=t.abortController,A=t.getAbortController;if(!s&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(d&&!A&&!m&&"undefined"==typeof AbortController)throw new Error("`AbortController` is not available. Please pass in `getAbortController` as an option or have AbortController globally available when using timeout.");return o=s||fetch,function(f){return function(i,a){var r;(d||A||m)&&(r=(A?A():null)||m||new AbortController);var e=h.replace(/\/$/,"")+i.uri,t="string"==typeof i.body||q(i.body)?i.body:JSON.stringify(i.body||void 0),n=V({},i.headers);Object.prototype.hasOwnProperty.call(n,"Content-Type")||(n["Content-Type"]="application/json"),t&&(n["Content-Length"]=R.byteLength(t).toString());var u={method:i.method,headers:n};c&&(u.credentials=c),r&&(u.signal=r.signal),t&&(u.body=t);var s=0;!function n(){var t;d&&(t=setTimeout(function(){r.abort()},d)),o(e,u).then(function(o){return o.ok?"HEAD"===u.method?void f(i,V(V({},a),{},{statusCode:o.status})):void o.text().then(function(r){var e;try{e=0<r.length?JSON.parse(r):{}}catch(t){if(y&&s<w)return setTimeout(n,ut(s,b,0,v,E)),void(s+=1);e=r}var t=V(V({},a),{},{body:e,statusCode:o.status});l&&(t.headers=at(o.headers)),p&&(t.request=V({},u),st(t.request,g)),f(i,t)}):503===o.status&&y&&s<w?(setTimeout(n,ut(s,b,0,v,E)),void(s+=1)):void o.text().then(function(t){var r;try{r=JSON.parse(t)}catch(e){r=t}var e=function(t){var r=t.statusCode,e=t.message,n=Z(t,["statusCode","message"]),o=e||"Unexpected non-JSON error response";404===r&&(o="URI not found: ".concat(n.originalRequest.uri));var i=ot(r);return i?new i(o,n):new K(r,o,n)}(V({statusCode:o.status,originalRequest:i,retryCount:s,headers:at(o.headers)},"object"===H(r)?{message:r.message,body:r}:{message:r,body:r}));st(e.originalRequest,g);var n=V(V({},a),{},{error:e,statusCode:o.status});f(i,n)})},function(t){if(y&&s<w)return setTimeout(n,ut(s,b,0,v,E)),void(s+=1);var r=new G(t.message,{originalRequest:i,retryCount:s});st(r.originalRequest,g),f(i,V(V({},a),{},{error:r,statusCode:0}))}).finally(function(){clearTimeout(t)})}()}}},t.errors=it,t.getErrorByCode=ot,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).CommercetoolsSdkMiddlewareHttp={})}(this,function(t){"use strict";var r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,c=!1;function l(){c=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)s[r]=t[r],f[t.charCodeAt(r)]=r;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63}function p(t,r,e){for(var n,o,i=[],a=r;a<e;a+=3)n=(t[a]<<16)+(t[a+1]<<8)+t[a+2],i.push(s[(o=n)>>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}function u(t){var r;c||l();for(var e=t.length,n=e%3,o="",i=[],a=0,u=e-n;a<u;a+=16383)i.push(p(t,a,u<a+16383?u:a+16383));return 1==n?(r=t[e-1],o+=s[r>>2],o+=s[r<<4&63],o+="=="):2==n&&(r=(t[e-2]<<8)+t[e-1],o+=s[r>>10],o+=s[r>>4&63],o+=s[r<<2&63],o+="="),i.push(o),i.join("")}function e(t,r,e,n,o){var i,a,u=8*o-n-1,s=(1<<u)-1,f=s>>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;0<h;i=256*i+t[r+c],c+=l,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=n;0<h;a=256*a+t[r+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===s)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)}function i(t,r,e,n,o,i){var a,u,s,f=8*i-o-1,h=(1<<f)-1,c=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,g=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,a=h):(a=Math.floor(Math.log(r)/Math.LN2),r*(s=Math.pow(2,-a))<1&&(a--,s*=2),2<=(r+=1<=a+c?l/s:l*Math.pow(2,1-c))*s&&(a++,s/=2),h<=a+c?(u=0,a=h):1<=a+c?(u=(r*s-1)*Math.pow(2,o),a+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),a=0));8<=o;t[e+p]=255&u,p+=g,u/=256,o-=8);for(a=a<<o|u,f+=o;0<f;t[e+p]=255&a,p+=g,a/=256,f-=8);t[e+p-g]|=128*y}var n={}.toString,a=Array.isArray||function(t){return"[object Array]"==n.call(t)};function o(){return _.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function g(t,r){if(o()<r)throw new RangeError("Invalid typed array length");return _.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=_.prototype:(null===t&&(t=new _(r)),t.length=r),t}function _(t,r,e){if(!(_.TYPED_ARRAY_SUPPORT||this instanceof _))return new _(t,r,e);if("number"!=typeof t)return y(this,t,r,e);if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return w(this,t)}function y(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n);_.TYPED_ARRAY_SUPPORT?(t=r).__proto__=_.prototype:t=v(t,r);return t}(t,r,e,n):"string"==typeof r?function(t,r,e){"string"==typeof e&&""!==e||(e="utf8");if(!_.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|E(r,e),o=(t=g(t,n)).write(r,e);o!==n&&(t=t.slice(0,o));return t}(t,r,e):function(t,r){if(A(r)){var e=0|b(r.length);return 0===(t=g(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||function(t){return t!=t}(r.length)?g(t,0):v(t,r);if("Buffer"===r.type&&a(r.data))return v(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function d(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function w(t,r){if(d(r),t=g(t,r<0?0:0|b(r)),!_.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function v(t,r){var e=r.length<0?0:0|b(r.length);t=g(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function b(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function A(t){return null!=t&&t._isBuffer}function E(t,r){if(A(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return N(t).length;default:if(n)return k(t).length;r=(""+r).toLowerCase(),n=!0}}function m(t,r,e){var n,o,i,a=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":return function(t,r,e){var n=t.length;(!r||r<0)&&(r=0);(!e||e<0||n<e)&&(e=n);for(var o="",i=r;i<e;++i)o+=function(t){return t<16?"0"+t.toString(16):t.toString(16)}(t[i]);return o}(this,r,e);case"utf8":case"utf-8":return U(this,r,e);case"ascii":return function(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(127&t[o]);return n}(this,r,e);case"latin1":case"binary":return function(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}(this,r,e);case"base64":return n=this,i=e,0===(o=r)&&i===n.length?u(n):u(n.slice(o,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}(this,r,e);default:if(a)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),a=!0}}function R(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function P(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):2147483647<e?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=_.from(r,n)),A(r))return 0===r.length?-1:T(t,r,e,n,o);if("number"==typeof r)return r&=255,_.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):T(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function T(t,r,e,n,o){var i=1,a=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a/=i=2,u/=2,e/=2}function s(t,r){return 1===i?t[r]:t.readUInt16BE(r*i)}if(o)for(var f=-1,h=e;h<a;h++)if(s(t,h)===s(r,-1===f?0:h-f)){if(-1===f&&(f=h),h-f+1===u)return f*i}else-1!==f&&(h-=h-f),f=-1;else for(a<e+u&&(e=a-u),h=e;0<=h;h--){for(var c=!0,l=0;l<u;l++)if(s(t,h+l)!==s(r,l)){c=!1;break}if(c)return h}return-1}function O(t,r,e,n){return z(function(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}(r),t,e,n)}function S(t,r,e,n){return z(function(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function U(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i,a,u,s,f=t[o],h=null,c=239<f?4:223<f?3:191<f?2:1;if(o+c<=e)switch(c){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&127<(s=(31&f)<<6|63&i)&&(h=s);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&2047<(s=(15&f)<<12|(63&i)<<6|63&a)&&(s<55296||57343<s)&&(h=s);break;case 4:i=t[o+1],a=t[o+2],u=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&u)&&65535<(s=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&u)&&s<1114112&&(h=s)}null===h?(h=65533,c=1):65535<h&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=C)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=C));return e}(n)}_.TYPED_ARRAY_SUPPORT=void 0===r.TYPED_ARRAY_SUPPORT||r.TYPED_ARRAY_SUPPORT,_.poolSize=8192,_._augment=function(t){return t.__proto__=_.prototype,t},_.from=function(t,r,e){return y(null,t,r,e)},_.TYPED_ARRAY_SUPPORT&&(_.prototype.__proto__=Uint8Array.prototype,_.__proto__=Uint8Array),_.alloc=function(t,r,e){return n=null,i=r,a=e,d(o=t),!(o<=0)&&void 0!==i?"string"==typeof a?g(n,o).fill(i,a):g(n,o).fill(i):g(n,o);var n,o,i,a},_.allocUnsafe=function(t){return w(null,t)},_.allocUnsafeSlow=function(t){return w(null,t)},_.isBuffer=q,_.compare=function(t,r){if(!A(t)||!A(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,o=0,i=Math.min(e,n);o<i;++o)if(t[o]!==r[o]){e=t[o],n=r[o];break}return e<n?-1:n<e?1:0},_.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},_.concat=function(t,r){if(!a(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return _.alloc(0);if(void 0===r)for(o=r=0;o<t.length;++o)r+=t[o].length;for(var e=_.allocUnsafe(r),n=0,o=0;o<t.length;++o){var i=t[o];if(!A(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(e,n),n+=i.length}return e},_.byteLength=E,_.prototype._isBuffer=!0,_.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)R(this,r,r+1);return this},_.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)R(this,r,r+3),R(this,r+1,r+2);return this},_.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)R(this,r,r+7),R(this,r+1,r+6),R(this,r+2,r+5),R(this,r+3,r+4);return this},_.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?U(this,0,t):m.apply(this,arguments)},_.prototype.equals=function(t){if(!A(t))throw new TypeError("Argument must be a Buffer");return this===t||0===_.compare(this,t)},_.prototype.inspect=function(){var t="";return 0<this.length&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),50<this.length&&(t+=" ... ")),"<Buffer "+t+">"},_.prototype.compare=function(t,r,e,n,o){if(!A(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&e<=r)return 0;if(o<=n)return-1;if(e<=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(e>>>=0)-(r>>>=0),u=Math.min(i,a),s=this.slice(n,o),f=t.slice(r,e),h=0;h<u;++h)if(s[h]!==f[h]){i=s[h],a=f[h];break}return i<a?-1:a<i?1:0},_.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},_.prototype.indexOf=function(t,r,e){return P(this,t,r,e,!0)},_.prototype.lastIndexOf=function(t,r,e){return P(this,t,r,e,!1)},_.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(e)?(e|=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||o<e)&&(e=o),0<t.length&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var i,a,u,s,f,h,c=!1;;)switch(n){case"hex":return function(t,r,e,n){e=Number(e)||0;var o=t.length-e;(!n||o<(n=Number(n)))&&(n=o);var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");i/2<n&&(n=i/2);for(var a=0;a<n;++a){var u=parseInt(r.substr(2*a,2),16);if(isNaN(u))return a;t[e+a]=u}return a}(this,t,r,e);case"utf8":case"utf-8":return f=r,h=e,z(k(t,(s=this).length-f),s,f,h);case"ascii":return O(this,t,r,e);case"latin1":case"binary":return O(this,t,r,e);case"base64":return i=this,a=r,u=e,z(N(t),i,a,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r,e);default:if(c)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),c=!0}},_.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,r,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(e<t+r)throw new RangeError("Trying to access beyond buffer length")}function Y(t,r,e,n,o,i){if(!A(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(o<r||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function I(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function M(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>8*(n?o:3-o)&255}function D(t,r,e,n){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function L(t,r,e,n,o){return o||D(t,0,e,4),i(t,r,e,n,23,4),e+4}function x(t,r,e,n,o){return o||D(t,0,e,8),i(t,r,e,n,52,8),e+8}_.prototype.slice=function(t,r){var e=this.length;if((t=~~t)<0?(t+=e)<0&&(t=0):e<t&&(t=e),(r=void 0===r?e:~~r)<0?(r+=e)<0&&(r=0):e<r&&(r=e),r<t&&(r=t),_.TYPED_ARRAY_SUPPORT)(o=this.subarray(t,r)).__proto__=_.prototype;else for(var n=r-t,o=new _(n,void 0),i=0;i<n;++i)o[i]=this[i+t];return o},_.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n},_.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=this[t+--r],o=1;0<r&&(o*=256);)n+=this[t+--r]*o;return n},_.prototype.readUInt8=function(t,r){return r||B(t,1,this.length),this[t]},_.prototype.readUInt16LE=function(t,r){return r||B(t,2,this.length),this[t]|this[t+1]<<8},_.prototype.readUInt16BE=function(t,r){return r||B(t,2,this.length),this[t]<<8|this[t+1]},_.prototype.readUInt32LE=function(t,r){return r||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},_.prototype.readUInt32BE=function(t,r){return r||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},_.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return(o*=128)<=n&&(n-=Math.pow(2,8*r)),n},_.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||B(t,r,this.length);for(var n=r,o=1,i=this[t+--n];0<n&&(o*=256);)i+=this[t+--n]*o;return(o*=128)<=i&&(i-=Math.pow(2,8*r)),i},_.prototype.readInt8=function(t,r){return r||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},_.prototype.readInt16LE=function(t,r){r||B(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},_.prototype.readInt16BE=function(t,r){r||B(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},_.prototype.readInt32LE=function(t,r){return r||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},_.prototype.readInt32BE=function(t,r){return r||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},_.prototype.readFloatLE=function(t,r){return r||B(t,4,this.length),e(this,t,!0,23,4)},_.prototype.readFloatBE=function(t,r){return r||B(t,4,this.length),e(this,t,!1,23,4)},_.prototype.readDoubleLE=function(t,r){return r||B(t,8,this.length),e(this,t,!0,52,8)},_.prototype.readDoubleBE=function(t,r){return r||B(t,8,this.length),e(this,t,!1,52,8)},_.prototype.writeUIntLE=function(t,r,e,n){t=+t,r|=0,e|=0,n||Y(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i<e&&(o*=256);)this[r+i]=t/o&255;return r+e},_.prototype.writeUIntBE=function(t,r,e,n){t=+t,r|=0,e|=0,n||Y(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;0<=--o&&(i*=256);)this[r+o]=t/i&255;return r+e},_.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,1,255,0),_.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},_.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,65535,0),_.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):I(this,t,r,!0),r+2},_.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,65535,0),_.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):I(this,t,r,!1),r+2},_.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,4294967295,0),_.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):M(this,t,r,!0),r+4},_.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,4294967295,0),_.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):M(this,t,r,!1),r+4},_.prototype.writeIntLE=function(t,r,e,n){var o;t=+t,r|=0,n||Y(this,t,r,e,(o=Math.pow(2,8*e-1))-1,-o);var i=0,a=1,u=0;for(this[r]=255&t;++i<e&&(a*=256);)t<0&&0===u&&0!==this[r+i-1]&&(u=1),this[r+i]=(t/a>>0)-u&255;return r+e},_.prototype.writeIntBE=function(t,r,e,n){var o;t=+t,r|=0,n||Y(this,t,r,e,(o=Math.pow(2,8*e-1))-1,-o);var i=e-1,a=1,u=0;for(this[r+i]=255&t;0<=--i&&(a*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/a>>0)-u&255;return r+e},_.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,1,127,-128),_.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},_.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,32767,-32768),_.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):I(this,t,r,!0),r+2},_.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,2,32767,-32768),_.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):I(this,t,r,!1),r+2},_.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,2147483647,-2147483648),_.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):M(this,t,r,!0),r+4},_.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||Y(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),_.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):M(this,t,r,!1),r+4},_.prototype.writeFloatLE=function(t,r,e){return L(this,t,r,!0,e)},_.prototype.writeFloatBE=function(t,r,e){return L(this,t,r,!1,e)},_.prototype.writeDoubleLE=function(t,r,e){return x(this,t,r,!0,e)},_.prototype.writeDoubleBE=function(t,r,e){return x(this,t,r,!1,e)},_.prototype.copy=function(t,r,e,n){if(e=e||0,n||0===n||(n=this.length),r>=t.length&&(r=t.length),r=r||0,0<n&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var o,i=n-e;if(this===t&&e<r&&r<n)for(o=i-1;0<=o;--o)t[o+r]=this[o+e];else if(i<1e3||!_.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+r]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),r);return i},_.prototype.fill=function(t,r,e,n){if("string"==typeof t){var o;if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1!==t.length||(o=t.charCodeAt(0))<256&&(t=o),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!_.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;if(r>>>=0,e=void 0===e?this.length:e>>>0,"number"==typeof(t=t||0))for(u=r;u<e;++u)this[u]=t;else for(var i=A(t)?t:k(new _(t,n).toString()),a=i.length,u=0;u<e-r;++u)this[u+r]=i[u%a];return this};var j=/[^+\/0-9A-Za-z-_]/g;function k(t,r){var e;r=r||1/0;for(var n=t.length,o=null,i=[],a=0;a<n;++a){if(55295<(e=t.charCodeAt(a))&&e<57344){if(!o){if(56319<e){-1<(r-=3)&&i.push(239,191,189);continue}if(a+1===n){-1<(r-=3)&&i.push(239,191,189);continue}o=e;continue}if(e<56320){-1<(r-=3)&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&-1<(r-=3)&&i.push(239,191,189);if(o=null,e<128){if(--r<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function N(t){return function(t){var r,e,n,o;c||l();var i=t.length;if(0<i%4)throw new Error("Invalid string. Length must be a multiple of 4");n="="===t[i-2]?2:"="===t[i-1]?1:0,o=new h(3*i/4-n),r=0<n?i-4:i;for(var a=0,u=0;u<r;u+=4,0)e=f[t.charCodeAt(u)]<<18|f[t.charCodeAt(u+1)]<<12|f[t.charCodeAt(u+2)]<<6|f[t.charCodeAt(u+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2==n?(e=f[t.charCodeAt(u)]<<2|f[t.charCodeAt(u+1)]>>4,o[a++]=255&e):1==n&&(e=f[t.charCodeAt(u)]<<10|f[t.charCodeAt(u+1)]<<4|f[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(function(t){var r;if((t=((r=t).trim?r.trim():r.replace(/^\s+|\s+$/g,"")).replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function q(t){return null!=t&&(!!t._isBuffer||F(t)||"function"==typeof(r=t).readFloatLE&&"function"==typeof r.slice&&F(r.slice(0,0)));var r}function F(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function H(t){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function J(r,t){var e,n=Object.keys(r);return Object.getOwnPropertySymbols&&(e=Object.getOwnPropertySymbols(r),t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),n.push.apply(n,e)),n}function V(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?J(Object(i),!0).forEach(function(t){var r,e,n;r=o,n=i[e=t],e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):J(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function Z(t,r){if(null==t)return{};var e,n=function(t,r){if(null==t)return{};for(var e,n={},o=Object.keys(t),i=0;i<o.length;i++)e=o[i],0<=r.indexOf(e)||(n[e]=t[e]);return n}(t,r);if(Object.getOwnPropertySymbols)for(var o=Object.getOwnPropertySymbols(t),i=0;i<o.length;i++)e=o[i],0<=r.indexOf(e)||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e]);return n}function $(t,r){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.status=this.statusCode=this.code=t,this.message=r,Object.assign(this,e),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function G(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,0].concat(r))}function K(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this].concat(r))}function Q(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,400].concat(r))}function W(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,401].concat(r))}function X(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,403].concat(r))}function tt(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,404].concat(r))}function rt(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,409].concat(r))}function et(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,500].concat(r))}function nt(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];$.call.apply($,[this,503].concat(r))}function ot(t){switch(t){case 0:return G;case 400:return Q;case 401:return W;case 403:return X;case 404:return tt;case 409:return rt;case 500:return et;case 503:return nt;default:return}}var it=Object.freeze({__proto__:null,NetworkError:G,HttpError:K,BadRequest:Q,Unauthorized:W,Forbidden:X,NotFound:tt,ConcurrentModification:rt,InternalServerError:et,ServiceUnavailable:nt,default:ot});function at(t){if(t.raw)return t.raw();if(!t.forEach)return{};var e={};return t.forEach(function(t,r){e[r]=t}),e}function ut(t,r,e,n,o){return n&&0!==t?Math.min(Math.round((Math.random()+1)*r*Math.pow(2,t)),o):r}function st(t,r){r&&(t.headers.authorization&&(t.headers.authorization="Bearer ********"),t.headers.Authorization&&(t.headers.Authorization="Bearer ********"))}t.createHttpMiddleware=function(t){var o,h=t.host,c=t.credentialsMode,l=t.includeResponseHeaders,p=t.includeOriginalRequest,r=t.maskSensitiveHeaderData,g=void 0===r||r,y=t.enableRetry,d=t.timeout,e=t.retryConfig,n=(e=void 0===e?{}:e).maxRetries,w=void 0===n?10:n,i=e.backoff,v=void 0===i||i,a=e.retryDelay,b=void 0===a?200:a,u=e.maxDelay,A=void 0===u?1/0:u,s=e.retryOnAbort,E=void 0!==s&&s,f=t.fetch,m=t.abortController,R=t.getAbortController;if(!f&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");if(d&&!R&&!m&&"undefined"==typeof AbortController)throw new Error("`AbortController` is not available. Please pass in `getAbortController` as an option or have AbortController globally available when using timeout.");return o=f||fetch,function(f){return function(i,a){var r,e=h.replace(/\/$/,"")+i.uri,t="string"==typeof i.body||q(i.body)?i.body:JSON.stringify(i.body||void 0),n=V({},i.headers);Object.prototype.hasOwnProperty.call(n,"Content-Type")||(n["Content-Type"]="application/json"),t&&(n["Content-Length"]=_.byteLength(t).toString());var u={method:i.method,headers:n};c&&(u.credentials=c),E||((d||R||m)&&(r=(R?R():null)||m||new AbortController),r&&(u.signal=r.signal)),t&&(u.body=t);var s=0;!function n(){var t;E&&((d||R||m)&&(r=(R?R():null)||m||new AbortController),r&&(u.signal=r.signal)),d&&(t=setTimeout(function(){r.abort()},d)),o(e,u).then(function(o){return o.ok?"HEAD"===u.method?void f(i,V(V({},a),{},{statusCode:o.status})):void o.text().then(function(r){var e;try{e=0<r.length?JSON.parse(r):{}}catch(t){if(y&&s<w)return setTimeout(n,ut(s,b,0,v,A)),void(s+=1);e=r}var t=V(V({},a),{},{body:e,statusCode:o.status});l&&(t.headers=at(o.headers)),p&&(t.request=V({},u),st(t.request,g)),f(i,t)}):503===o.status&&y&&s<w?(setTimeout(n,ut(s,b,0,v,A)),void(s+=1)):void o.text().then(function(t){var r;try{r=JSON.parse(t)}catch(e){r=t}var e=function(t){var r=t.statusCode,e=t.message,n=Z(t,["statusCode","message"]),o=e||"Unexpected non-JSON error response";404===r&&(o="URI not found: ".concat(n.originalRequest.uri));var i=ot(r);return i?new i(o,n):new K(r,o,n)}(V({statusCode:o.status,originalRequest:i,retryCount:s,headers:at(o.headers)},"object"===H(r)?{message:r.message,body:r}:{message:r,body:r}));st(e.originalRequest,g);var n=V(V({},a),{},{error:e,statusCode:o.status});f(i,n)})},function(t){if(y&&s<w)return setTimeout(n,ut(s,b,0,v,A)),void(s+=1);var r=new G(t.message,{originalRequest:i,retryCount:s});st(r.originalRequest,g),f(i,V(V({},a),{},{error:r,statusCode:0}))}).finally(function(){clearTimeout(t)})}()}}},t.errors=it,t.getErrorByCode=ot,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -7,3 +7,3 @@ {

"name": "@commercetools/sdk-middleware-http",
"version": "6.0.11",
"version": "6.1.0",
"description": "Middleware for http requests, to use with @commercetools/sdk-client",

@@ -39,4 +39,3 @@ "keywords": [

"node-fetch": "2.6.1"
},
"gitHead": "8a8423936c7eb6ec58fd07664ec5954a43b84ae8"
}
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc