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

@commercetools/sdk-middleware-auth

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.1.0 to 2.0.0

16

CHANGELOG.md

@@ -1,5 +0,10 @@

<a name="1.1.0"></a>
# 1.1.0 (2016-12-23)
<a name="2.0.0"></a>
# 2.0.0 (2017-01-27)
### Bug Fixes
* **middleware-auth:** fix usage of cached token, no default options (#53) ([f69fadd](https://github.com/commercetools/nodejs/commit/f69fadd)), closes [#53](https://github.com/commercetools/nodejs/issues/53)
### Features

@@ -10,2 +15,9 @@

### BREAKING CHANGES
* middleware-auth: host is now a required option, no more default value
affects: @commercetools/sdk-middleware-auth

4

dist/commercetools-sdk-middleware-auth.min.js

@@ -7,3 +7,3 @@ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CommercetoolsSdkMiddlewareAuth=e():t.CommercetoolsSdkMiddlewareAuth=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.scopes=e.createAuthMiddlewareForAnonymousSessionFlow=e.createAuthMiddlewareForRefreshTokenFlow=e.createAuthMiddlewareForPasswordFlow=e.createAuthMiddlewareForClientCredentialsFlow=void 0;var i=r(5);Object.defineProperty(e,"createAuthMiddlewareForClientCredentialsFlow",{enumerable:!0,get:function(){return o(i).default}});var s=r(6);Object.defineProperty(e,"createAuthMiddlewareForPasswordFlow",{enumerable:!0,get:function(){return o(s).default}});var u=r(7);Object.defineProperty(e,"createAuthMiddlewareForRefreshTokenFlow",{enumerable:!0,get:function(){return o(u).default}});var a=r(3);Object.defineProperty(e,"createAuthMiddlewareForAnonymousSessionFlow",{enumerable:!0,get:function(){return o(a).default}});var f=r(1),h=n(f);e.scopes=h},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.MANAGE_PROJECT="manage_project",e.MANAGE_PRODUCTS="manage_products",e.VIEW_PRODUCTS="view_products",e.MANAGE_ORDERS="manage_orders",e.VIEW_ORDERS="view_orders",e.MANAGE_MY_ORDERS="manage_my_orders",e.MANAGE_CUSTOMERS="manage_customers",e.VIEW_CUSTOMERS="view_customers",e.MANAGE_MY_PROFILE="manage_my_profile",e.MANAGE_TYPES="manage_types",e.VIEW_TYPES="view_types",e.MANAGE_PAYMENTS="manage_payments",e.VIEW_PAYMENTS="view_payments",e.CREATE_ANONYMOUS_TOKEN="create_anonymous_token",e.MANAGE_SUBSCRIPTIONS="manage_subscriptions"},function(t,e,r){(function(t){/*!

*/
"use strict";function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function o(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=s.prototype):(null===t&&(t=new s(e)),t.length=e),t}function s(t,e,r){if(!(s.TYPED_ARRAY_SUPPORT||this instanceof s))return new s(t,e,r);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return h(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?p(t,e,r,n):"string"==typeof e?c(t,e,r):d(t,e)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(0>t)throw new RangeError('"size" argument must not be negative')}function f(t,e,r,n){return a(e),e>0&&void 0!==r?"string"==typeof n?i(t,e).fill(r,n):i(t,e).fill(r):i(t,e)}function h(t,e){if(a(e),t=i(t,0>e?0:0|y(e)),!s.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;++r)t[r]=0;return t}function c(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!s.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|w(e,r);t=i(t,n);var o=t.write(e,r);return o!==n&&(t=t.slice(0,o)),t}function l(t,e){var r=0>e.length?0:0|y(e.length);t=i(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(t,e,r,n){if(0>r||r>e.byteLength)throw new RangeError("'offset' is out of bounds");if(r+(n||0)>e.byteLength)throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),s.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=s.prototype):t=l(t,e),t}function d(t,e){if(s.isBuffer(e)){var r=0|y(e.length);return t=i(t,r),0===t.length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||X(e.length)?i(t,0):l(t,e);if("Buffer"===e.type&&Q(e.data))return l(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function y(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),s.alloc(+t)}function w(t,e){if(s.isBuffer(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 r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(n)return V(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if(r>>>=0,e>>>=0,e>=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),0>r&&(r=t.length+r),t.length>r){if(0>r){if(!o)return-1;r=0}}else{if(o)return-1;r=t.length-1}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:_(t,e,r,n,o);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):_(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function _(t,e,r,n,o){function i(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,u=t.length,a=e.length;if(void 0!==n&&(n=(n+"").toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(2>t.length||2>e.length)return-1;s=2,u/=2,a/=2,r/=2}var f;if(o){var h=-1;for(f=r;u>f;f++)if(i(t,f)===i(e,h===-1?0:f-h)){if(h===-1&&(h=f),f-h+1===a)return h*s}else h!==-1&&(f-=f-h),h=-1}else for(r+a>u&&(r=u-a),f=r;f>=0;f--){for(var c=!0,l=0;a>l;l++)if(i(t,f+l)!==i(e,l)){c=!1;break}if(c)return f}return-1}function A(t,e,r,n){r=+r||0;var o=t.length-r;n?(n=+n,n>o&&(n=o)):n=o;var i=e.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;n>s;++s){var u=parseInt(e.substr(2*s,2),16);if(isNaN(u))return s;t[r+s]=u}return s}function E(t,e,r,n){return K(V(e,t.length-r),t,r,n)}function R(t,e,r,n){return K(H(e),t,r,n)}function P(t,e,r,n){return R(t,e,r,n)}function T(t,e,r,n){return K(W(e),t,r,n)}function B(t,e,r,n){return K(J(e,t.length-r),t,r,n)}function S(t,e,r){return Z.fromByteArray(0===e&&r===t.length?t:t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;r>o;){var i=t[o],s=null,u=i>239?4:i>223?3:i>191?2:1;if(r>=o+u){var a,f,h,c;switch(u){case 1:128>i&&(s=i);break;case 2:a=t[o+1],128===(192&a)&&(c=(31&i)<<6|63&a,c>127&&(s=c));break;case 3:a=t[o+1],f=t[o+2],128===(192&a)&&128===(192&f)&&(c=(15&i)<<12|(63&a)<<6|63&f,c>2047&&(55296>c||c>57343)&&(s=c));break;case 4:a=t[o+1],f=t[o+2],h=t[o+3],128===(192&a)&&128===(192&f)&&128===(192&h)&&(c=(15&i)<<18|(63&a)<<12|(63&f)<<6|63&h,c>65535&&1114112>c&&(s=c))}}null===s?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=u}return O(n)}function O(t){var e=t.length;if(tt>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=tt));return r}function M(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(127&t[o]);return n}function I(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(t[o]);return n}function C(t,e,r){var n=t.length;e&&e>=0||(e=0),(!r||0>r||r>n)&&(r=n);for(var o="",i=e;r>i;++i)o+=z(t[i]);return o}function x(t,e,r){for(var n=t.slice(e,r),o="",i=0;n.length>i;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function Y(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||i>e)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);i>o;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function F(t,e,r,n){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);i>o;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function L(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return o||L(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(t,e,r,n,23,4),r+4}function k(t,e,r,n,o){return o||L(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(t,e,r,n,52,8),r+8}function q(t){if(t=G(t).replace(et,""),2>t.length)return"";for(;t.length%4!==0;)t+="=";return t}function G(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function z(t){return 16>t?"0"+t.toString(16):t.toString(16)}function V(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],s=0;n>s;++s){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(56320>r){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>r){if((e-=1)<0)break;i.push(r)}else if(2048>r){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(r>=1114112)throw Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){for(var e=[],r=0;t.length>r;++r)e.push(255&t.charCodeAt(r));return e}function J(t,e){for(var r,n,o,i=[],s=0;t.length>s&&(e-=2)>=0;++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function W(t){return Z.toByteArray(q(t))}function K(t,e,r,n){for(var o=0;n>o&&(o+r<e.length&&o<t.length);++o)e[o+r]=t[o];return o}function X(t){return t!==t}var Z=r(8),$=r(9),Q=r(10);e.Buffer=s,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:n(),e.kMaxLength=o(),s.poolSize=8192,s._augment=function(t){return t.__proto__=s.prototype,t},s.from=function(t,e,r){return u(null,t,e,r)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(t,e,r){return f(null,t,e,r)},s.allocUnsafe=function(t){return h(null,t)},s.allocUnsafeSlow=function(t){return h(null,t)},s.isBuffer=function(t){return!(null==t||!t._isBuffer)},s.compare=function(t,e){if(!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);i>o;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return n>r?-1:r>n?1:0},s.isEncoding=function(t){switch((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}},s.concat=function(t,e){if(!Q(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);var r;if(void 0===e)for(e=0,r=0;t.length>r;++r)e+=t[r].length;var n=s.allocUnsafe(e),o=0;for(r=0;t.length>r;++r){var i=t[r];if(!s.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},s.byteLength=w,s.prototype._isBuffer=!0,s.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 e=0;t>e;e+=2)v(this,e,e+1);return this},s.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 e=0;t>e;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},s.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 e=0;t>e;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},s.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?U(this,0,t):b.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},s.prototype.compare=function(t,e,r,n,o){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>e||r>t.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,u=r-e,a=Math.min(i,u),f=this.slice(n,o),h=t.slice(e,r),c=0;a>c;++c)if(f[c]!==h[c]){i=f[c],u=h[c];break}return u>i?-1:i>u?1:0},s.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1},s.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return A(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":return R(this,t,e,r);case"latin1":case"binary":return P(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(s.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=s.prototype;else{var o=e-t;n=new s(o,void 0);for(var i=0;o>i;++i)n[i]=this[i+t]}return n},s.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},s.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return e||Y(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||Y(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||Y(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,o>n||(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,o>i||(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return e||Y(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},s.prototype.readInt16LE=function(t,e){e||Y(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||Y(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){var o=Math.pow(2,8*r)-1;D(this,t,e,r,o,0)}var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},s.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){var o=Math.pow(2,8*r)-1;D(this,t,e,r,o,0)}var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=0,s=1,u=0;for(this[e]=255&t;++i<r&&(s*=256);)0>t&&0===u&&0!==this[e+i-1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)0>t&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return k(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return k(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),t.length>e||(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),n-r>t.length-e&&(n=t.length-e+r);var o,i=n-r;if(this===t&&e>r&&n>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(1e3>i||!s.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||r>this.length)throw new RangeError("Out of range index");if(e>=r)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;r>i;++i)this[i]=t;else{var u=s.isBuffer(t)?t:V(""+new s(t,n)),a=u.length;for(i=0;r-e>i;++i)this[i+e]=u[i%a]}return this};var et=/[^+\/0-9A-Za-z-_]/g}).call(e,function(){return this}())},function(t,e){"use strict";function r(){throw Error("Middleware not implemented yet")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r},function(t,e,r){(function(t){"use strict";function n(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function o(t){var e=t.host,r=void 0===e?c:e,n=t.projectKey,o=t.credentials,i=t.scopes;if(!n)throw Error("Missing required option (projectKey)");if(!o)throw Error("Missing required option (credentials)");var s=o.clientId,u=o.clientSecret;if(!s||!u)throw Error("Missing required credentials (clientId, clientSecret)");var f=h.MANAGE_PROJECT+":"+n,l=(i||[f]).join(" "),p=a(s,u),d=r+"/oauth/token",y="grant_type=client_credentials&scope="+l;return{basicAuth:p,url:d,body:y}}function i(){}function s(){}function u(){}function a(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window,o=e+":"+r;return n&&n.btoa&&"function"==typeof n.btoa?n.btoa(o):new t(o).toString("base64")}Object.defineProperty(e,"__esModule",{value:!0}),e.buildRequestForClientCredentialsFlow=o,e.buildRequestForPasswordFlow=i,e.buildRequestForRefreshTokenFlow=s,e.buildRequestForAnonymousSessionFlow=u,e.getBasicAuth=a;var f=r(1),h=n(f),c="https://auth.sphere.io"}).call(e,r(2).Buffer)},function(t,e,r){(function(t){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(e){var r={},o=[],u=!1;return function(f){return function(h,c){var l=h.headers&&h.headers.authorization||h.headers&&h.headers.Authorization;if(l){var p=l.replace("Bearer ",""),d=r[p];if(!d)return void f(h,c);if(Date.now()<d)return void f(h,c)}if(o.push({request:h,response:c}),!u){u=!0;var y=(0,a.buildRequestForClientCredentialsFlow)(e),g=y.basicAuth,w=y.url,b=y.body;fetch(w,{method:"POST",headers:{Authorization:"Basic "+g,"Content-Length":""+t.byteLength(b),"Content-Type":"application/x-www-form-urlencoded"},body:b}).then(function(t){return t.ok?t.json().then(function(t){var e=t.access_token,a=t.expires_in,h=s(a);Object.assign(r,n({},e,h)),u=!1;var c=o.slice();o=[],c.forEach(function(t){var r=i(e,t.request);f(r,t.response)})}):t.text().then(function(t){var e=void 0;try{e=JSON.parse(t)}catch(t){}var r=Error(e?e.message:t);e&&(r.body=e),c.reject(r)})}).catch(function(t){c.reject(t)})}}}}function i(t,e){return u({},e,{headers:u({},e.headers,{Authorization:"Bearer "+t})})}function s(t){return Date.now()+1e3*t-72e5}Object.defineProperty(e,"__esModule",{value:!0});var u=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=o,r(11);var a=r(4)}).call(e,r(2).Buffer)},function(t,e){"use strict";function r(){throw Error("Middleware not implemented yet")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r},function(t,e){"use strict";function r(){throw Error("Middleware not implemented yet")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r},function(t,e){"use strict";function r(t){var e=t.length;if(e%4>0)throw Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function n(t){return 3*t.length/4-r(t)}function o(t){var e,n,o,i,s,u,a=t.length;s=r(t),u=new h(3*a/4-s),o=s>0?a-4:a;var c=0;for(e=0,n=0;o>e;e+=4,n+=3)i=f[t.charCodeAt(e)]<<18|f[t.charCodeAt(e+1)]<<12|f[t.charCodeAt(e+2)]<<6|f[t.charCodeAt(e+3)],u[c++]=i>>16&255,u[c++]=i>>8&255,u[c++]=255&i;return 2===s?(i=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,u[c++]=255&i):1===s&&(i=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,u[c++]=i>>8&255,u[c++]=255&i),u}function i(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function s(t,e,r){for(var n,o=[],s=e;r>s;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(i(n));return o.join("")}function u(t){for(var e,r=t.length,n=r%3,o="",i=[],u=16383,f=0,h=r-n;h>f;f+=u)i.push(s(t,f,f+u>h?h:f+u));return 1===n?(e=t[r-1],o+=a[e>>2],o+=a[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=a[e>>10],o+=a[e>>4&63],o+=a[e<<2&63],o+="="),i.push(o),i.join("")}e.byteLength=n,e.toByteArray=o,e.fromByteArray=u;for(var a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=c.length;p>l;++l)a[l]=c[l],f[c.charCodeAt(l)]=l;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,o){var i,s,u=8*o-n-1,a=(1<<u)-1,f=a>>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;h>0;i=256*i+t[e+c],c+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===a)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,u,a,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,d=n?1:-1,y=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),e+=1>s+c?l*Math.pow(2,1-c):l/a,2>e*a||(s++,a/=2),h>s+c?1>s+c?(u=e*Math.pow(2,c-1)*Math.pow(2,o),s=0):(u=(e*a-1)*Math.pow(2,o),s+=c):(u=0,s=h));o>=8;t[r+p]=255&u,p+=d,u/=256,o-=8);for(s=s<<o|u,f+=o;f>0;t[r+p]=255&s,p+=d,s/=256,f-=8);t[r+p-d]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){r(12),t.exports=self.fetch.bind(self)},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t+=""),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t+=""),t}function n(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return w.iterable&&(e[Symbol.iterator]=function(){return e}),e}function o(t){this.map={},t instanceof o?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function i(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function s(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function u(t){var e=new FileReader,r=s(e);return e.readAsArrayBuffer(t),r}function a(t){var e=new FileReader,r=s(e);return e.readAsText(t),r}function f(t){for(var e=new Uint8Array(t),r=Array(e.length),n=0;e.length>n;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function h(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(w.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(w.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(w.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=""+t;else if(w.arrayBuffer&&w.blob&&v(t))this._bodyArrayBuffer=h(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!w.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!m(t))throw Error("unsupported BodyInit type");this._bodyArrayBuffer=h(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):w.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},w.blob&&(this.blob=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?i(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(u)}),this.text=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return a(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(f(this._bodyArrayBuffer));if(this._bodyFormData)throw Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},w.formData&&(this.formData=function(){return this.text().then(d)}),this.json=function(){return this.text().then(JSON.parse)},this}function l(t){var e=t.toUpperCase();return _.indexOf(e)>-1?e:t}function p(t,e){e=e||{};var r=e.body;if("string"==typeof t)this.url=t;else{if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new o(t.headers)),this.method=t.method,this.mode=t.mode,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new o(e.headers)),this.method=l(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function d(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function y(t){var e=new o;return t.split("\r\n").forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e}function g(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&300>this.status,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new o(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var w={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(w.arrayBuffer)var b=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=function(t){return t&&DataView.prototype.isPrototypeOf(t)},m=ArrayBuffer.isView||function(t){return t&&b.indexOf(Object.prototype.toString.call(t))>-1};o.prototype.append=function(t,n){t=e(t),n=r(n);var o=this.map[t];this.map[t]=o?o+","+n:n},o.prototype.delete=function(t){delete this.map[e(t)]},o.prototype.get=function(t){return t=e(t),this.has(t)?this.map[t]:null},o.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},o.prototype.set=function(t,n){this.map[e(t)]=r(n)},o.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},o.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),n(t)},o.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),n(t)},o.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),n(t)},w.iterable&&(o.prototype[Symbol.iterator]=o.prototype.entries);var _=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];p.prototype.clone=function(){return new p(this,{body:this._bodyInit})},c.call(p.prototype),c.call(g.prototype),g.prototype.clone=function(){return new g(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},g.error=function(){var t=new g(null,{status:0,statusText:""});return t.type="error",t};var A=[301,302,303,307,308];g.redirect=function(t,e){if(A.indexOf(e)===-1)throw new RangeError("Invalid status code");return new g(null,{status:e,headers:{location:t}})},t.Headers=o,t.Request=p,t.Response=g,t.fetch=function(t,e){return new Promise(function(r,n){var o=new p(t,e),i=new XMLHttpRequest;i.onload=function(){var t={status:i.status,statusText:i.statusText,headers:y(i.getAllResponseHeaders()||"")};t.url="responseURL"in i?i.responseURL:t.headers.get("X-Request-URL");var e="response"in i?i.response:i.responseText;r(new g(e,t));
},i.onerror=function(){n(new TypeError("Network request failed"))},i.ontimeout=function(){n(new TypeError("Network request failed"))},i.open(o.method,o.url,!0),"include"===o.credentials&&(i.withCredentials=!0),"responseType"in i&&w.blob&&(i.responseType="blob"),o.headers.forEach(function(t,e){i.setRequestHeader(e,t)}),i.send(void 0===o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)}])});
"use strict";function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function o(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=s.prototype):(null===t&&(t=new s(e)),t.length=e),t}function s(t,e,r){if(!(s.TYPED_ARRAY_SUPPORT||this instanceof s))return new s(t,e,r);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return h(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?p(t,e,r,n):"string"==typeof e?c(t,e,r):d(t,e)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(0>t)throw new RangeError('"size" argument must not be negative')}function f(t,e,r,n){return a(e),e>0&&void 0!==r?"string"==typeof n?i(t,e).fill(r,n):i(t,e).fill(r):i(t,e)}function h(t,e){if(a(e),t=i(t,0>e?0:0|y(e)),!s.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;++r)t[r]=0;return t}function c(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!s.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|w(e,r);t=i(t,n);var o=t.write(e,r);return o!==n&&(t=t.slice(0,o)),t}function l(t,e){var r=0>e.length?0:0|y(e.length);t=i(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(t,e,r,n){if(0>r||r>e.byteLength)throw new RangeError("'offset' is out of bounds");if(r+(n||0)>e.byteLength)throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),s.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=s.prototype):t=l(t,e),t}function d(t,e){if(s.isBuffer(e)){var r=0|y(e.length);return t=i(t,r),0===t.length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||X(e.length)?i(t,0):l(t,e);if("Buffer"===e.type&&Q(e.data))return l(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function y(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),s.alloc(+t)}function w(t,e){if(s.isBuffer(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 r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(n)return V(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if(r>>>=0,e>>>=0,e>=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),0>r&&(r=t.length+r),t.length>r){if(0>r){if(!o)return-1;r=0}}else{if(o)return-1;r=t.length-1}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:_(t,e,r,n,o);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):_(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function _(t,e,r,n,o){function i(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,u=t.length,a=e.length;if(void 0!==n&&(n=(n+"").toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(2>t.length||2>e.length)return-1;s=2,u/=2,a/=2,r/=2}var f;if(o){var h=-1;for(f=r;u>f;f++)if(i(t,f)===i(e,h===-1?0:f-h)){if(h===-1&&(h=f),f-h+1===a)return h*s}else h!==-1&&(f-=f-h),h=-1}else for(r+a>u&&(r=u-a),f=r;f>=0;f--){for(var c=!0,l=0;a>l;l++)if(i(t,f+l)!==i(e,l)){c=!1;break}if(c)return f}return-1}function A(t,e,r,n){r=+r||0;var o=t.length-r;n?(n=+n,n>o&&(n=o)):n=o;var i=e.length;if(i%2!==0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;n>s;++s){var u=parseInt(e.substr(2*s,2),16);if(isNaN(u))return s;t[r+s]=u}return s}function E(t,e,r,n){return W(V(e,t.length-r),t,r,n)}function R(t,e,r,n){return W(H(e),t,r,n)}function P(t,e,r,n){return R(t,e,r,n)}function T(t,e,r,n){return W(K(e),t,r,n)}function B(t,e,r,n){return W(J(e,t.length-r),t,r,n)}function S(t,e,r){return Z.fromByteArray(0===e&&r===t.length?t:t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;r>o;){var i=t[o],s=null,u=i>239?4:i>223?3:i>191?2:1;if(r>=o+u){var a,f,h,c;switch(u){case 1:128>i&&(s=i);break;case 2:a=t[o+1],128===(192&a)&&(c=(31&i)<<6|63&a,c>127&&(s=c));break;case 3:a=t[o+1],f=t[o+2],128===(192&a)&&128===(192&f)&&(c=(15&i)<<12|(63&a)<<6|63&f,c>2047&&(55296>c||c>57343)&&(s=c));break;case 4:a=t[o+1],f=t[o+2],h=t[o+3],128===(192&a)&&128===(192&f)&&128===(192&h)&&(c=(15&i)<<18|(63&a)<<12|(63&f)<<6|63&h,c>65535&&1114112>c&&(s=c))}}null===s?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=u}return O(n)}function O(t){var e=t.length;if(tt>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=tt));return r}function M(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(127&t[o]);return n}function I(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(t[o]);return n}function x(t,e,r){var n=t.length;e&&e>=0||(e=0),(!r||0>r||r>n)&&(r=n);for(var o="",i=e;r>i;++i)o+=z(t[i]);return o}function C(t,e,r){for(var n=t.slice(e,r),o="",i=0;n.length>i;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function Y(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,r,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||i>e)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function F(t,e,r,n){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);i>o;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function j(t,e,r,n){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);i>o;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function L(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return o||L(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(t,e,r,n,23,4),r+4}function k(t,e,r,n,o){return o||L(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(t,e,r,n,52,8),r+8}function q(t){if(t=G(t).replace(et,""),2>t.length)return"";for(;t.length%4!==0;)t+="=";return t}function G(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function z(t){return 16>t?"0"+t.toString(16):t.toString(16)}function V(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],s=0;n>s;++s){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(56320>r){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>r){if((e-=1)<0)break;i.push(r)}else if(2048>r){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(r>=1114112)throw Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){for(var e=[],r=0;t.length>r;++r)e.push(255&t.charCodeAt(r));return e}function J(t,e){for(var r,n,o,i=[],s=0;t.length>s&&(e-=2)>=0;++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function K(t){return Z.toByteArray(q(t))}function W(t,e,r,n){for(var o=0;n>o&&(o+r<e.length&&o<t.length);++o)e[o+r]=t[o];return o}function X(t){return t!==t}var Z=r(8),$=r(9),Q=r(10);e.Buffer=s,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:n(),e.kMaxLength=o(),s.poolSize=8192,s._augment=function(t){return t.__proto__=s.prototype,t},s.from=function(t,e,r){return u(null,t,e,r)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(t,e,r){return f(null,t,e,r)},s.allocUnsafe=function(t){return h(null,t)},s.allocUnsafeSlow=function(t){return h(null,t)},s.isBuffer=function(t){return!(null==t||!t._isBuffer)},s.compare=function(t,e){if(!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);i>o;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return n>r?-1:r>n?1:0},s.isEncoding=function(t){switch((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}},s.concat=function(t,e){if(!Q(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);var r;if(void 0===e)for(e=0,r=0;t.length>r;++r)e+=t[r].length;var n=s.allocUnsafe(e),o=0;for(r=0;t.length>r;++r){var i=t[r];if(!s.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},s.byteLength=w,s.prototype._isBuffer=!0,s.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 e=0;t>e;e+=2)v(this,e,e+1);return this},s.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 e=0;t>e;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},s.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 e=0;t>e;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},s.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?U(this,0,t):b.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},s.prototype.compare=function(t,e,r,n,o){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>e||r>t.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,u=r-e,a=Math.min(i,u),f=this.slice(n,o),h=t.slice(e,r),c=0;a>c;++c)if(f[c]!==h[c]){i=f[c],u=h[c];break}return u>i?-1:i>u?1:0},s.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1},s.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return A(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":return R(this,t,e,r);case"latin1":case"binary":return P(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(s.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=s.prototype;else{var o=e-t;n=new s(o,void 0);for(var i=0;o>i;++i)n[i]=this[i+t]}return n},s.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},s.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},s.prototype.readUInt8=function(t,e){return e||Y(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||Y(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||Y(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,o>n||(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||Y(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,o>i||(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return e||Y(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},s.prototype.readInt16LE=function(t,e){e||Y(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||Y(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||Y(t,4,this.length),$.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||Y(t,8,this.length),$.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){var o=Math.pow(2,8*r)-1;D(this,t,e,r,o,0)}var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},s.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){var o=Math.pow(2,8*r)-1;D(this,t,e,r,o,0)}var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):F(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):F(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=0,s=1,u=0;for(this[e]=255&t;++i<r&&(s*=256);)0>t&&0===u&&0!==this[e+i-1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)0>t&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):F(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):F(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return k(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return k(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),t.length>e||(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),n-r>t.length-e&&(n=t.length-e+r);var o,i=n-r;if(this===t&&e>r&&n>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(1e3>i||!s.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||r>this.length)throw new RangeError("Out of range index");if(e>=r)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;r>i;++i)this[i]=t;else{var u=s.isBuffer(t)?t:V(""+new s(t,n)),a=u.length;for(i=0;r-e>i;++i)this[i+e]=u[i%a]}return this};var et=/[^+\/0-9A-Za-z-_]/g}).call(e,function(){return this}())},function(t,e){"use strict";function r(){throw Error("Middleware not implemented yet")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r},function(t,e,r){(function(t){"use strict";function n(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function o(t){if(!t)throw Error("Missing required options");if(!t.host)throw Error("Missing required option (host)");if(!t.projectKey)throw Error("Missing required option (projectKey)");if(!t.credentials)throw Error("Missing required option (credentials)");var e=t.credentials,r=e.clientId,n=e.clientSecret;if(!r||!n)throw Error("Missing required credentials (clientId, clientSecret)");var o=h.MANAGE_PROJECT+":"+t.projectKey,i=(t.scopes||[o]).join(" "),s=a(r,n),u=t.host+"/oauth/token",f="grant_type=client_credentials&scope="+i;return{basicAuth:s,url:u,body:f}}function i(){}function s(){}function u(){}function a(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window,o=e+":"+r;return n&&n.btoa&&"function"==typeof n.btoa?n.btoa(o):new t(o).toString("base64")}Object.defineProperty(e,"__esModule",{value:!0}),e.buildRequestForClientCredentialsFlow=o,e.buildRequestForPasswordFlow=i,e.buildRequestForRefreshTokenFlow=s,e.buildRequestForAnonymousSessionFlow=u,e.getBasicAuth=a;var f=r(1),h=n(f)}).call(e,r(2).Buffer)},function(t,e,r){(function(t){"use strict";function n(e){var r=void 0,n=[],s=!1;return function(a){return function(f,h){if(f.headers&&f.headers.authorization||f.headers&&f.headers.Authorization)return void a(f,h);if(r&&r.token&&Date.now()<r.expirationTime){var c=o(r.token,f);return void a(c,h)}if(n.push({request:f,response:h}),!s){s=!0;var l=(0,u.buildRequestForClientCredentialsFlow)(e),p=l.basicAuth,d=l.url,y=l.body;fetch(d,{method:"POST",headers:{Authorization:"Basic "+p,"Content-Length":""+t.byteLength(y),"Content-Type":"application/x-www-form-urlencoded"},body:y}).then(function(t){return t.ok?t.json().then(function(t){var e=t.access_token,u=t.expires_in,f=i(u);r={token:e,expirationTime:f},s=!1;var h=n.slice();n=[],h.forEach(function(t){var r=o(e,t.request);a(r,t.response)})}):t.text().then(function(t){var e=void 0;try{e=JSON.parse(t)}catch(t){}var r=Error(e?e.message:t);e&&(r.body=e),h.reject(r)})}).catch(function(t){h.reject(t)})}}}}function o(t,e){return s({},e,{headers:s({},e.headers,{Authorization:"Bearer "+t})})}function i(t){return Date.now()+1e3*t-72e5}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=n,r(11);var u=r(4)}).call(e,r(2).Buffer)},function(t,e){"use strict";function r(){throw Error("Middleware not implemented yet")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r},function(t,e){"use strict";function r(){throw Error("Middleware not implemented yet")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r},function(t,e){"use strict";function r(t){var e=t.length;if(e%4>0)throw Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function n(t){return 3*t.length/4-r(t)}function o(t){var e,n,o,i,s,u,a=t.length;s=r(t),u=new h(3*a/4-s),o=s>0?a-4:a;var c=0;for(e=0,n=0;o>e;e+=4,n+=3)i=f[t.charCodeAt(e)]<<18|f[t.charCodeAt(e+1)]<<12|f[t.charCodeAt(e+2)]<<6|f[t.charCodeAt(e+3)],u[c++]=i>>16&255,u[c++]=i>>8&255,u[c++]=255&i;return 2===s?(i=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,u[c++]=255&i):1===s&&(i=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,u[c++]=i>>8&255,u[c++]=255&i),u}function i(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function s(t,e,r){for(var n,o=[],s=e;r>s;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(i(n));return o.join("")}function u(t){for(var e,r=t.length,n=r%3,o="",i=[],u=16383,f=0,h=r-n;h>f;f+=u)i.push(s(t,f,f+u>h?h:f+u));return 1===n?(e=t[r-1],o+=a[e>>2],o+=a[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=a[e>>10],o+=a[e>>4&63],o+=a[e<<2&63],o+="="),i.push(o),i.join("")}e.byteLength=n,e.toByteArray=o,e.fromByteArray=u;for(var a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=c.length;p>l;++l)a[l]=c[l],f[c.charCodeAt(l)]=l;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,o){var i,s,u=8*o-n-1,a=(1<<u)-1,f=a>>1,h=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;h>0;i=256*i+t[e+c],c+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===a)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,u,a,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,d=n?1:-1,y=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),e+=1>s+c?l*Math.pow(2,1-c):l/a,2>e*a||(s++,a/=2),h>s+c?1>s+c?(u=e*Math.pow(2,c-1)*Math.pow(2,o),s=0):(u=(e*a-1)*Math.pow(2,o),s+=c):(u=0,s=h));o>=8;t[r+p]=255&u,p+=d,u/=256,o-=8);for(s=s<<o|u,f+=o;f>0;t[r+p]=255&s,p+=d,s/=256,f-=8);t[r+p-d]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){r(12),t.exports=self.fetch.bind(self)},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t+=""),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t+=""),t}function n(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return w.iterable&&(e[Symbol.iterator]=function(){return e}),e}function o(t){this.map={},t instanceof o?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function i(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function s(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function u(t){var e=new FileReader,r=s(e);return e.readAsArrayBuffer(t),r}function a(t){var e=new FileReader,r=s(e);return e.readAsText(t),r}function f(t){for(var e=new Uint8Array(t),r=Array(e.length),n=0;e.length>n;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function h(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(w.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(w.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(w.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=""+t;else if(w.arrayBuffer&&w.blob&&v(t))this._bodyArrayBuffer=h(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!w.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!m(t))throw Error("unsupported BodyInit type");this._bodyArrayBuffer=h(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):w.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},w.blob&&(this.blob=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?i(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(u)}),this.text=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return a(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(f(this._bodyArrayBuffer));if(this._bodyFormData)throw Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},w.formData&&(this.formData=function(){return this.text().then(d)}),this.json=function(){return this.text().then(JSON.parse)},this}function l(t){var e=t.toUpperCase();return _.indexOf(e)>-1?e:t}function p(t,e){e=e||{};var r=e.body;if(t instanceof p){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new o(t.headers)),this.method=t.method,this.mode=t.mode,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t+"";if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new o(e.headers)),this.method=l(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function d(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function y(t){var e=new o;return t.split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e}function g(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&300>this.status,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new o(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var w={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(w.arrayBuffer)var b=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=function(t){return t&&DataView.prototype.isPrototypeOf(t)},m=ArrayBuffer.isView||function(t){return t&&b.indexOf(Object.prototype.toString.call(t))>-1};o.prototype.append=function(t,n){t=e(t),n=r(n);var o=this.map[t];this.map[t]=o?o+","+n:n},o.prototype.delete=function(t){delete this.map[e(t)]},o.prototype.get=function(t){return t=e(t),this.has(t)?this.map[t]:null},o.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},o.prototype.set=function(t,n){this.map[e(t)]=r(n)},o.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},o.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),n(t)},o.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),n(t)},o.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),n(t)},w.iterable&&(o.prototype[Symbol.iterator]=o.prototype.entries);var _=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];p.prototype.clone=function(){return new p(this,{body:this._bodyInit})},c.call(p.prototype),c.call(g.prototype),g.prototype.clone=function(){return new g(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},g.error=function(){var t=new g(null,{status:0,statusText:""});return t.type="error",t};var A=[301,302,303,307,308];g.redirect=function(t,e){if(A.indexOf(e)===-1)throw new RangeError("Invalid status code");return new g(null,{status:e,headers:{location:t}})},t.Headers=o,t.Request=p,t.Response=g,t.fetch=function(t,e){return new Promise(function(r,n){var o=new p(t,e),i=new XMLHttpRequest;i.onload=function(){var t={status:i.status,statusText:i.statusText,headers:y(i.getAllResponseHeaders()||"")};t.url="responseURL"in i?i.responseURL:t.headers.get("X-Request-URL");var e="response"in i?i.response:i.responseText;r(new g(e,t))},i.onerror=function(){n(new TypeError("Network request failed"));
},i.ontimeout=function(){n(new TypeError("Network request failed"))},i.open(o.method,o.url,!0),"include"===o.credentials&&(i.withCredentials=!0),"responseType"in i&&w.blob&&(i.responseType="blob"),o.headers.forEach(function(t,e){i.setRequestHeader(e,t)}),i.send(void 0===o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)}])});

@@ -18,23 +18,16 @@ 'use strict';

var defaultAuthHost = 'https://auth.sphere.io';
// POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
// Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
/* global window */
function buildRequestForClientCredentialsFlow(options) {
var _options$host = options.host,
host = _options$host === undefined ? defaultAuthHost : _options$host,
projectKey = options.projectKey,
credentials = options.credentials,
scopes = options.scopes;
if (!options) throw new Error('Missing required options');
if (!options.host) throw new Error('Missing required option (host)');
if (!projectKey) throw new Error('Missing required option (projectKey)');
if (!options.projectKey) throw new Error('Missing required option (projectKey)');
if (!credentials) throw new Error('Missing required option (credentials)');
if (!options.credentials) throw new Error('Missing required option (credentials)');
var clientId = credentials.clientId,
clientSecret = credentials.clientSecret;
var _options$credentials = options.credentials,
clientId = _options$credentials.clientId,
clientSecret = _options$credentials.clientSecret;

@@ -44,7 +37,7 @@

var defaultScope = authScopes.MANAGE_PROJECT + ':' + projectKey;
var scope = (scopes || [defaultScope]).join(' ');
var defaultScope = authScopes.MANAGE_PROJECT + ':' + options.projectKey;
var scope = (options.scopes || [defaultScope]).join(' ');
var basicAuth = getBasicAuth(clientId, clientSecret);
var url = host + '/oauth/token';
var url = options.host + '/oauth/token';
var body = 'grant_type=client_credentials&scope=' + scope;

@@ -55,2 +48,3 @@

/* global window */
function buildRequestForPasswordFlow() {

@@ -57,0 +51,0 @@ // TODO

@@ -9,2 +9,5 @@ 'use strict';

/* global fetch */
exports.default = createAuthMiddlewareForClientCredentialsFlow;

@@ -16,11 +19,4 @@

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/* global fetch */
function createAuthMiddlewareForClientCredentialsFlow(options) {
var cache = {
// [token]: expirationTime
};
var cache = void 0;
var pendingTasks = [];

@@ -31,25 +27,17 @@ var isFetchingToken = false;

return function (request, response) {
var currentAuthHeader = request.headers && request.headers['authorization'] || request.headers && request.headers['Authorization'];
// Check if there is already a `Authorization` header in the request.
// If so, then go directly to the next middleware.
if (request.headers && request.headers['authorization'] || request.headers && request.headers['Authorization']) {
next(request, response);
return;
}
if (currentAuthHeader) {
var token = currentAuthHeader.replace('Bearer ', '');
// Check that the token is cached and is not expired
var tokenExpirationTime = cache[token];
if (!tokenExpirationTime) {
// Token is not in cache, meaning it's not been requested from
// this middleware and was passed to the request manually.
// In this case we assume the renewal of expired tokens will be
// handled manually as well, outside of this middleare, since
// we don't know the expiration time for that token.
next(request, response);
return;
}
// Check if the cached token is still valid
if (Date.now() < tokenExpirationTime) {
// Token is valid, continue
next(request, response);
return;
}
// Token is not present or is invalid. Request a new token...
// If there was a token in the cache, and it's not expired, append
// the token in the `Authorization` header.
if (cache && cache.token && Date.now() < cache.expirationTime) {
var requestWithAuth = mergeAuthHeader(cache.token, request);
next(requestWithAuth, response);
return;
}
// Token is not present or is invalid. Request a new token...

@@ -84,3 +72,3 @@ // Keep pending tasks until a token is fetched

// Cache new token
Object.assign(cache, _defineProperty({}, token, expirationTime));
cache = { token: token, expirationTime: expirationTime };

@@ -87,0 +75,0 @@ // Dispatch all pending requests

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

"name": "@commercetools/sdk-middleware-auth",
"version": "1.1.0",
"version": "2.0.0",
"description": "Middleware for different authentication flows of commercetools platform API, to use with @commercetools/sdk-client",

@@ -10,0 +10,0 @@ "keywords": [

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