Socket
Socket
Sign inDemoInstall

@commercetools/sdk-auth

Package Overview
Dependencies
2
Maintainers
14
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.6 to 3.0.7

LICENSE

2

dist/sdk-auth.cjs.js

@@ -508,3 +508,3 @@ 'use strict';

if (response.expires_in) {
return _objectSpread2({}, response, {
return _objectSpread2(_objectSpread2({}, response), {}, {
// add a new property with expiration time in unixTimestamp format

@@ -511,0 +511,0 @@ expires_at: SdkAuth._calculateExpirationTime(response.expires_in)

@@ -502,3 +502,3 @@ import defaultsDeep from 'lodash.defaultsdeep';

if (response.expires_in) {
return _objectSpread2({}, response, {
return _objectSpread2(_objectSpread2({}, response), {}, {
// add a new property with expiration time in unixTimestamp format

@@ -505,0 +505,0 @@ expires_at: SdkAuth._calculateExpirationTime(response.expires_in)

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("lodash.defaultsdeep")):"function"==typeof define&&define.amd?define(["exports","lodash.defaultsdeep"],e):e((t=t||self).CommercetoolsSdkAuth={},t.defaultsDeep)}(this,function(t,n){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,c=!1;function l(){c=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)a[e]=t[e],f[t.charCodeAt(e)]=e;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63}function p(t,e,r){for(var n,o,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(a[(o=n)>>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}function o(t){var e;c||l();for(var r=t.length,n=r%3,o="",i=[],s=0,u=r-n;s<u;s+=16383)i.push(p(t,s,u<s+16383?u:s+16383));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("")}function r(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;0<h;i=256*i+t[e+c],c+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;0<h;s=256*s+t[e+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)}function i(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,g=n?1:-1,d=e<0||0===e&&1/e<0?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),2<=(e+=1<=s+c?l/a:l*Math.pow(2,1-c))*a&&(s++,a/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(e*a-1)*Math.pow(2,o),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&u,p+=g,u/=256,o-=8);for(s=s<<o|u,f+=o;0<f;t[r+p]=255&s,p+=g,s/=256,f-=8);t[r+p-g]|=128*d}var s={}.toString,u=Array.isArray||function(t){return"[object Array]"==s.call(t)};function g(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function d(t,e){if(g()<e)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=y.prototype:(null===t&&(t=new y(e)),t.length=e),t}function y(t,e,r){if(!(y.TYPED_ARRAY_SUPPORT||this instanceof y))return new y(t,e,r);if("number"!=typeof t)return w(this,t,e,r);if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return _(this,t)}function w(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?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);y.TYPED_ARRAY_SUPPORT?(t=e).__proto__=y.prototype:t=b(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!y.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|E(e,r),o=(t=d(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(R(e)){var r=0|k(e.length);return 0===(t=d(t,r)).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||function(t){return t!=t}(e.length)?d(t,0):b(t,e);if("Buffer"===e.type&&u(e.data))return b(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function v(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 _(t,e){if(v(e),t=d(t,e<0?0:0|k(e)),!y.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function b(t,e){var r=e.length<0?0:0|k(e.length);t=d(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function k(t){if(t>=g())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+g().toString(16)+" bytes");return 0|t}function R(t){return null!=t&&t._isBuffer}function E(t,e){if(R(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 H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return J(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function T(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=y.from(e,n)),R(e))return 0===e.length?-1:A(t,e,r,n,o);if("number"==typeof e)return e&=255,y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):A(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function A(t,e,r,n,o){var i,s=1,u=t.length,a=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;u/=s=2,a/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i<u;i++)if(f(t,i)===f(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===a)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(u<r+a&&(r=u-a),i=r;0<=i;i--){for(var c=!0,l=0;l<a;l++)if(f(t,i+l)!==f(e,l)){c=!1;break}if(c)return i}return-1}function P(t,e,r,n){r=Number(r)||0;var o=t.length-r;(!n||o<(n=Number(n)))&&(n=o);var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");i/2<n&&(n=i/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(isNaN(u))return s;t[r+s]=u}return s}function I(t,e,r,n){return V(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return V(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?o(t):o(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,u,a,f=t[o],h=null,c=239<f?4:223<f?3:191<f?2:1;if(o+c<=r)switch(c){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&127<(a=(31&f)<<6|63&i)&&(h=a);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&2047<(a=(15&f)<<12|(63&i)<<6|63&s)&&(a<55296||57343<a)&&(h=a);break;case 4:i=t[o+1],s=t[o+2],u=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&u)&&65535<(a=(15&f)<<18|(63&i)<<12|(63&s)<<6|63&u)&&a<1114112&&(h=a)}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 e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=C));return r}(n)}y.TYPED_ARRAY_SUPPORT=void 0===e.TYPED_ARRAY_SUPPORT||e.TYPED_ARRAY_SUPPORT,y.poolSize=8192,y._augment=function(t){return t.__proto__=y.prototype,t},y.from=function(t,e,r){return w(null,t,e,r)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array),y.alloc=function(t,e,r){return n=null,i=e,s=r,v(o=t),o<=0||void 0===i?d(n,o):"string"==typeof s?d(n,o).fill(i,s):d(n,o).fill(i);var n,o,i,s},y.allocUnsafe=function(t){return _(null,t)},y.allocUnsafeSlow=function(t){return _(null,t)},y.isBuffer=function(t){return null!=t&&(!!t._isBuffer||Z(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Z(t.slice(0,0))}(t))},y.compare=function(t,e){if(!R(t)||!R(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);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},y.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}},y.concat=function(t,e){if(!u(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return y.alloc(0);var r;if(void 0===e)for(r=e=0;r<t.length;++r)e+=t[r].length;var n=y.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(!R(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},y.byteLength=E,y.prototype._isBuffer=!0,y.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;e<t;e+=2)m(this,e,e+1);return this},y.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;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},y.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;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},y.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?S(this,0,t):function(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":return j(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return Y(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},y.prototype.equals=function(t){if(!R(t))throw new TypeError("Argument must be a Buffer");return this===t||0===y.compare(this,t)},y.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+">"},y.prototype.compare=function(t,e,r,n,o){if(!R(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),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(i,s),a=this.slice(n,o),f=t.slice(e,r),h=0;h<u;++h)if(a[h]!==f[h]){i=a[h],s=f[h];break}return i<s?-1:s<i?1:0},y.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},y.prototype.indexOf=function(t,e,r){return T(this,t,e,r,!0)},y.prototype.lastIndexOf=function(t,e,r){return T(this,t,e,r,!1)},y.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 new 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||o<r)&&(r=o),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var i,s,u,a,f,h,c=!1;;)switch(n){case"hex":return P(this,t,e,r);case"utf8":case"utf-8":return f=e,h=r,V(H(t,(a=this).length-f),a,f,h);case"ascii":return I(this,t,e,r);case"latin1":case"binary":return I(this,t,e,r);case"base64":return i=this,s=e,u=r,V(J(t),i,s,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,e,r);default:if(c)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),c=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function Y(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function j(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||n<r)&&(r=n);for(var o="",i=e;i<r;++i)o+=z(t[i]);return o}function M(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function L(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function F(t,e,r,n,o,i){if(!R(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(o<e||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function D(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function q(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return o||q(t,0,r,4),i(t,e,r,n,23,4),r+4}function W(t,e,r,n,o){return o||q(t,0,r,8),i(t,e,r,n,52,8),r+8}y.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):n<t&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):n<e&&(e=n),e<t&&(e=t),y.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=y.prototype;else{var o=e-t;r=new y(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},y.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||L(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},y.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||L(t,e,this.length);for(var n=this[t+--e],o=1;0<e&&(o*=256);)n+=this[t+--e]*o;return n},y.prototype.readUInt8=function(t,e){return e||L(t,1,this.length),this[t]},y.prototype.readUInt16LE=function(t,e){return e||L(t,2,this.length),this[t]|this[t+1]<<8},y.prototype.readUInt16BE=function(t,e){return e||L(t,2,this.length),this[t]<<8|this[t+1]},y.prototype.readUInt32LE=function(t,e){return e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},y.prototype.readUInt32BE=function(t,e){return e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},y.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||L(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)<=n&&(n-=Math.pow(2,8*e)),n},y.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||L(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0<n&&(o*=256);)i+=this[t+--n]*o;return(o*=128)<=i&&(i-=Math.pow(2,8*e)),i},y.prototype.readInt8=function(t,e){return e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},y.prototype.readInt16LE=function(t,e){e||L(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},y.prototype.readInt16BE=function(t,e){e||L(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},y.prototype.readInt32LE=function(t,e){return e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},y.prototype.readInt32BE=function(t,e){return e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},y.prototype.readFloatLE=function(t,e){return e||L(t,4,this.length),r(this,t,!0,23,4)},y.prototype.readFloatBE=function(t,e){return e||L(t,4,this.length),r(this,t,!1,23,4)},y.prototype.readDoubleLE=function(t,e){return e||L(t,8,this.length),r(this,t,!0,52,8)},y.prototype.readDoubleBE=function(t,e){return e||L(t,8,this.length),r(this,t,!1,52,8)},y.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||F(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},y.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||F(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},y.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,1,255,0),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},y.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):x(this,t,e,!0),e+2},y.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):x(this,t,e,!1),e+2},y.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):D(this,t,e,!0),e+4},y.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},y.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);F(this,t,e,r,o-1,-o)}var i=0,s=1,u=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===u&&0!==this[e+i-1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},y.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);F(this,t,e,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},y.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,1,127,-128),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},y.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):x(this,t,e,!0),e+2},y.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):x(this,t,e,!1),e+2},y.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):D(this,t,e,!0),e+4},y.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},y.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},y.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},y.prototype.writeDoubleLE=function(t,e,r){return W(this,t,e,!0,r)},y.prototype.writeDoubleBE=function(t,e,r){return W(this,t,e,!1,r)},y.prototype.copy=function(t,e,r,n){if(r=r||0,n||0===n||(n=this.length),e>=t.length&&(e=t.length),e=e||0,0<n&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;0<=o;--o)t[o+e]=this[o+r];else if(i<1e3||!y.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},y.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);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!y.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(t=t||0))for(i=e;i<r;++i)this[i]=t;else{var s=R(t)?t:H(new y(t,n).toString()),u=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%u]}return this};var K=/[^+\/0-9A-Za-z-_]/g;function z(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if(55295<(r=t.charCodeAt(s))&&r<57344){if(!o){if(56319<r){-1<(e-=3)&&i.push(239,191,189);continue}if(s+1===n){-1<(e-=3)&&i.push(239,191,189);continue}o=r;continue}if(r<56320){-1<(e-=3)&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&-1<(e-=3)&&i.push(239,191,189);if(o=null,r<128){if(--e<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new 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 J(t){return function(t){var e,r,n,o,i;c||l();var s=t.length;if(0<s%4)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[s-2]?2:"="===t[s-1]?1:0,i=new h(3*s/4-o),r=0<o?s-4:s;var u=0;for(e=0;e<r;e+=4,0)n=f[t.charCodeAt(e)]<<18|f[t.charCodeAt(e+1)]<<12|f[t.charCodeAt(e+2)]<<6|f[t.charCodeAt(e+3)],i[u++]=n>>16&255,i[u++]=n>>8&255,i[u++]=255&n;return 2==o?(n=f[t.charCodeAt(e)]<<2|f[t.charCodeAt(e+1)]>>4,i[u++]=255&n):1==o&&(n=f[t.charCodeAt(e)]<<10|f[t.charCodeAt(e+1)]<<4|f[t.charCodeAt(e+2)]>>2,i[u++]=n>>8&255,i[u++]=255&n),i}(function(t){var e;if((t=((e=t).trim?e.trim():e.replace(/^\s+|\s+$/g,"")).replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function V(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function Z(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function $(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function G(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Q(t,e,r){return e&&G(t.prototype,e),r&&G(t,r),t}function X(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function tt(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?X(Object(i),!0).forEach(function(t){var e,r,n;e=o,n=i[r=t],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):X(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function et(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],0<=e.indexOf(r)||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],0<=e.indexOf(r)||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function rt(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.status=this.statusCode=this.code=t,this.message=e,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function nt(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,0].concat(e))}function ot(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,400].concat(e))}function it(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,401].concat(e))}function st(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,403].concat(e))}function ut(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,404].concat(e))}function at(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,409].concat(e))}function ft(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,500].concat(e))}function ht(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,503].concat(e))}function ct(t){switch(t){case 0:return nt;case 400:return ot;case 401:return it;case 403:return st;case 404:return ut;case 409:return at;case 500:return ft;case 503:return ht;default:return}}var lt="manage_project",pt=function(){function d(t){$(this,d),d._checkRequiredConfiguration(t),this.config=t,this.fetcher=d._getFetcher(t.fetch),this.ANONYMOUS_FLOW_URI="/oauth/--projectKey--/anonymous/token",this.CUSTOMER_PASSWORD_FLOW_URI="/oauth/--projectKey--/customers/token",this.BASE_AUTH_FLOW_URI="/oauth/token",this.INTROSPECT_URI="/oauth/introspect"}return Q(d,[{key:"_process",value:function(e){return this._performRequest(e).then(function(t){return d._handleResponse(e.uri,t)})}},{key:"_performRequest",value:function(t){var e=t.uri,r=t.body,n=t.basicAuth,o=t.authType,i={method:"POST",headers:t.headers||{Authorization:"".concat(o||"Basic"," ").concat(n),"Content-Length":y.byteLength(r).toString(),"Content-Type":"application/x-www-form-urlencoded"},body:r};return this.fetcher.call(null,e,i)}},{key:"_getRequestConfig",value:function(t){var e=0<arguments.length&&void 0!==t?t:{},r=n({},e,this.config);return e.scopes&&(r.scopes=e.scopes),r}},{key:"anonymousFlow",value:function(t,e){var r=0<arguments.length&&void 0!==t?t:"",n=1<arguments.length&&void 0!==e?e:{},o=this._getRequestConfig(n),i=d._buildRequest(o,d._enrichUriWithProjectKey(this.ANONYMOUS_FLOW_URI,o.projectKey));return r&&(i.body+="&anonymous_id=".concat(r)),this._process(i)}},{key:"clientCredentialsFlow",value:function(t){var e=0<arguments.length&&void 0!==t?t:{},r=this._getRequestConfig(e),n=d._buildRequest(r,this.BASE_AUTH_FLOW_URI);return this._process(n)}},{key:"_passwordFlow",value:function(t,e,r){var n=t||{},o=n.username,i=n.password,s=d._buildRequest(e,r,"password");return s.body=d._appendUserCredentialsToBody(s.body,o,i),this._process(s)}},{key:"customerPasswordFlow",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{},n=this._getRequestConfig(r),o=d._enrichUriWithProjectKey(this.CUSTOMER_PASSWORD_FLOW_URI,n.projectKey);return this._passwordFlow(t,n,o)}},{key:"clientPasswordFlow",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{},n=this._getRequestConfig(r);return this._passwordFlow(t,n,this.BASE_AUTH_FLOW_URI)}},{key:"refreshTokenFlow",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{};if(!t)throw new Error("Missing required token value");var n=this._getRequestConfig(r),o=d._buildRequest(n,this.BASE_AUTH_FLOW_URI,"refresh_token");return o.body+="&refresh_token=".concat(encodeURIComponent(t)),this._process(o)}},{key:"introspectToken",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{},n=this._getRequestConfig(r);if(!t)throw new Error("Missing required token value");var o=d._buildRequest(n,this.INTROSPECT_URI);return o.body="token=".concat(encodeURIComponent(t)),this._process(o)}},{key:"customFlow",value:function(t){var e=t.credentials,r=t.host,n=t.uri,o=t.body,i=t.token,s=t.authType,u=t.headers,a=this._getRequestConfig({host:r,token:i,authType:s,headers:u}),f=d._buildRequest(a,n);return f.body=o||"",e&&(f.body=d._appendUserCredentialsToBody(f.body,e.username,e.password)),this._process(f)}}],[{key:"_getFetcher",value:function(t){if(!t&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");return t||fetch}},{key:"_checkRequiredConfiguration",value:function(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.credentials)throw new Error("Missing required option (credentials)");var e=t.credentials,r=e.clientId,n=e.clientSecret;if(!r||!n)throw new Error("Missing required credentials (clientId, clientSecret)")}},{key:"_encodeClientCredentials",value:function(t){var e=t.clientId,r=t.clientSecret;return y.from("".concat(e,":").concat(r)).toString("base64")}},{key:"_getScopes",value:function(t,e){return t?t.join(" "):[lt,e].filter(Boolean).join(":")}},{key:"_buildRequest",value:function(t,e,r){var n=2<arguments.length&&void 0!==r?r:"client_credentials",o=t.projectKey,i=t.credentials,s=t.host,u=t.disableRefreshToken,a=t.scopes,f=t.headers,h=d._getScopes(a,o),c=s.replace(/\/$/,"")+e,l=t.token||d._encodeClientCredentials(i),p=t.authType||"Basic",g="grant_type=".concat(n);return"refresh_token"!==n&&(g+="&scope=".concat(h)),!0===u&&(g+="&refresh_token=false"),{basicAuth:l,authType:p,uri:c,body:g,headers:f}}},{key:"_createResponseError",value:function(t,e,r){var n=t.message,o=void 0===n?"Unexpected non-JSON error response":n,i=et(t,["message"]),s=404===r?"URI not found: ".concat(e):o,u=ct(r);return new(u=u||ct(0))(s,i)}},{key:"_parseResponseJson",value:function(t){return t.json().catch(function(){return{statusCode:t.status}})}},{key:"_isErrorResponse",value:function(t){return!t.status||400<=t.status}},{key:"_calculateExpirationTime",value:function(t){return Date.now()+1e3*t}},{key:"_enrichTokenResponse",value:function(t){return t.expires_in?tt({},t,{expires_at:d._calculateExpirationTime(t.expires_in)}):t}},{key:"_handleResponse",value:function(e,r){return d._parseResponseJson(r).then(function(t){if(d._isErrorResponse(r))throw d._createResponseError(t,e,r.status);return d._enrichTokenResponse(t)})}},{key:"_appendUserCredentialsToBody",value:function(t,e,r){if(!e||!r)throw new Error("Missing required user credentials (username, password)");return[t,"username=".concat(encodeURIComponent(e)),"password=".concat(encodeURIComponent(r))].filter(Boolean).join("&")}},{key:"_enrichUriWithProjectKey",value:function(t,e){if(!e)throw new Error("Missing required option (projectKey)");return t.replace("--projectKey--",e)}}]),d}(),gt=function(){function s(t){var e=t.sdkAuth,r=t.fetchTokenInfo,n=t.onTokenInfoChanged,o=t.onTokenInfoRefreshed,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if($(this,s),!e)throw new Error('Property "sdkAuth" was not provided');i&&s._validateTokenInfo(i),this.onTokenInfoChanged=n,this.onTokenInfoRefreshed=o,this.fetchTokenInfo=r,this.sdkAuth=e,this.tokenInfo=i,this.fetchTokenInfoPromise=null,this.refreshTokenFlowPromise=null}return Q(s,[{key:"_performFetchTokenInfo",value:function(){var e=this;return this.fetchTokenInfo?this.fetchTokenInfoPromise?this.fetchTokenInfoPromise:(this.fetchTokenInfoPromise=Promise.resolve(this.fetchTokenInfo(this.sdkAuth)),this.fetchTokenInfoPromise.then(function(t){return e.fetchTokenInfoPromise=null,t})):Promise.reject(new Error('Method "fetchTokenInfo" was not provided'))}},{key:"_performRefreshTokenFlow",value:function(t){var e=this;return this.refreshTokenFlowPromise?this.refreshTokenFlowPromise:(this.refreshTokenFlowPromise=this.sdkAuth.refreshTokenFlow(t),this.refreshTokenFlowPromise.then(function(t){return e.refreshTokenFlowPromise=null,t}))}},{key:"_refreshToken",value:function(r){var n,o=this;return null!=r&&r.refresh_token||this.fetchTokenInfo?(null!=r&&r.refresh_token?this._performRefreshTokenFlow(r.refresh_token):this._performFetchTokenInfo()).then(function(t){var e;return n=t,null!=r&&r.refresh_token&&(n.refresh_token=r.refresh_token),null===(e=o.onTokenInfoRefreshed)||void 0===e?void 0:e.call(o,n,r)}).then(function(){return o.setTokenInfo(n)}):Promise.reject(new Error('Property "refresh_token" and "fetchTokenInfo" method are missing'))}},{key:"invalidateTokenInfo",value:function(){this.tokenInfo=null}},{key:"getTokenInfo",value:function(){return this.tokenInfo&&!s._isTokenExpired(this.tokenInfo)?Promise.resolve(this.tokenInfo):this._refreshToken(this.tokenInfo)}},{key:"setTokenInfo",value:function(t){var e;return s._validateTokenInfo(t),this.tokenInfo=t,Promise.resolve(null===(e=this.onTokenInfoChanged)||void 0===e?void 0:e.call(this,t)).then(function(){return t})}},{key:"getAccessToken",value:function(){return this.getTokenInfo().then(function(t){return t.access_token})}}],[{key:"_validateTokenInfo",value:function(t){if(!t.access_token&&!t.refresh_token)throw new Error('At least one of "access_token" or "refresh_token" properties has to be provided')}},{key:"_isTokenExpired",value:function(t){return!(t&&t.access_token&&t.expires_at)||Date.now()>=(t.expires_at||0)-72e5}}]),s}();t.TokenProvider=gt,t.default=pt,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("lodash.defaultsdeep")):"function"==typeof define&&define.amd?define(["exports","lodash.defaultsdeep"],e):e((t=t||self).CommercetoolsSdkAuth={},t.defaultsDeep)}(this,function(t,n){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,c=!1;function l(){c=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)a[e]=t[e],f[t.charCodeAt(e)]=e;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63}function p(t,e,r){for(var n,o,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(a[(o=n)>>18&63]+a[o>>12&63]+a[o>>6&63]+a[63&o]);return i.join("")}function o(t){var e;c||l();for(var r=t.length,n=r%3,o="",i=[],s=0,u=r-n;s<u;s+=16383)i.push(p(t,s,u<s+16383?u:s+16383));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("")}function r(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;0<h;i=256*i+t[e+c],c+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;0<h;s=256*s+t[e+c],c+=l,h-=8);if(0===i)i=1-f;else{if(i===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)}function i(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,g=n?1:-1,d=e<0||0===e&&1/e<0?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),2<=(e+=1<=s+c?l/a:l*Math.pow(2,1-c))*a&&(s++,a/=2),h<=s+c?(u=0,s=h):1<=s+c?(u=(e*a-1)*Math.pow(2,o),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[r+p]=255&u,p+=g,u/=256,o-=8);for(s=s<<o|u,f+=o;0<f;t[r+p]=255&s,p+=g,s/=256,f-=8);t[r+p-g]|=128*d}var s={}.toString,u=Array.isArray||function(t){return"[object Array]"==s.call(t)};function g(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function d(t,e){if(g()<e)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=y.prototype:(null===t&&(t=new y(e)),t.length=e),t}function y(t,e,r){if(!(y.TYPED_ARRAY_SUPPORT||this instanceof y))return new y(t,e,r);if("number"!=typeof t)return w(this,t,e,r);if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return _(this,t)}function w(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?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);y.TYPED_ARRAY_SUPPORT?(t=e).__proto__=y.prototype:t=b(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!y.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|E(e,r),o=(t=d(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(R(e)){var r=0|k(e.length);return 0===(t=d(t,r)).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||function(t){return t!=t}(e.length)?d(t,0):b(t,e);if("Buffer"===e.type&&u(e.data))return b(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function v(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 _(t,e){if(v(e),t=d(t,e<0?0:0|k(e)),!y.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function b(t,e){var r=e.length<0?0:0|k(e.length);t=d(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function k(t){if(t>=g())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+g().toString(16)+" bytes");return 0|t}function R(t){return null!=t&&t._isBuffer}function E(t,e){if(R(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 H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return J(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function T(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=y.from(e,n)),R(e))return 0===e.length?-1:A(t,e,r,n,o);if("number"==typeof e)return e&=255,y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):A(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function A(t,e,r,n,o){var i=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=i=2,u/=2,r/=2}function a(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o)for(var f=-1,h=r;h<s;h++)if(a(t,h)===a(e,-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(s<r+u&&(r=s-u),h=r;0<=h;h--){for(var c=!0,l=0;l<u;l++)if(a(t,h+l)!==a(e,l)){c=!1;break}if(c)return h}return-1}function P(t,e,r,n){r=Number(r)||0;var o=t.length-r;(!n||o<(n=Number(n)))&&(n=o);var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");i/2<n&&(n=i/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(isNaN(u))return s;t[r+s]=u}return s}function I(t,e,r,n){return V(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return V(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?o(t):o(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,u,a,f=t[o],h=null,c=239<f?4:223<f?3:191<f?2:1;if(o+c<=r)switch(c){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&127<(a=(31&f)<<6|63&i)&&(h=a);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&2047<(a=(15&f)<<12|(63&i)<<6|63&s)&&(a<55296||57343<a)&&(h=a);break;case 4:i=t[o+1],s=t[o+2],u=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&u)&&65535<(a=(15&f)<<18|(63&i)<<12|(63&s)<<6|63&u)&&a<1114112&&(h=a)}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 e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=C));return r}(n)}y.TYPED_ARRAY_SUPPORT=void 0===e.TYPED_ARRAY_SUPPORT||e.TYPED_ARRAY_SUPPORT,y.poolSize=8192,y._augment=function(t){return t.__proto__=y.prototype,t},y.from=function(t,e,r){return w(null,t,e,r)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array),y.alloc=function(t,e,r){return n=null,i=e,s=r,v(o=t),o<=0||void 0===i?d(n,o):"string"==typeof s?d(n,o).fill(i,s):d(n,o).fill(i);var n,o,i,s},y.allocUnsafe=function(t){return _(null,t)},y.allocUnsafeSlow=function(t){return _(null,t)},y.isBuffer=function(t){return null!=t&&(!!t._isBuffer||Z(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Z(t.slice(0,0))}(t))},y.compare=function(t,e){if(!R(t)||!R(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);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},y.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}},y.concat=function(t,e){if(!u(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return y.alloc(0);if(void 0===e)for(o=e=0;o<t.length;++o)e+=t[o].length;for(var r=y.allocUnsafe(e),n=0,o=0;o<t.length;++o){var i=t[o];if(!R(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,n),n+=i.length}return r},y.byteLength=E,y.prototype._isBuffer=!0,y.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;e<t;e+=2)m(this,e,e+1);return this},y.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;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},y.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;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},y.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?S(this,0,t):function(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":return j(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return Y(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},y.prototype.equals=function(t){if(!R(t))throw new TypeError("Argument must be a Buffer");return this===t||0===y.compare(this,t)},y.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+">"},y.prototype.compare=function(t,e,r,n,o){if(!R(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),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(i,s),a=this.slice(n,o),f=t.slice(e,r),h=0;h<u;++h)if(a[h]!==f[h]){i=a[h],s=f[h];break}return i<s?-1:s<i?1:0},y.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},y.prototype.indexOf=function(t,e,r){return T(this,t,e,r,!0)},y.prototype.lastIndexOf=function(t,e,r){return T(this,t,e,r,!1)},y.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 new 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||o<r)&&(r=o),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var i,s,u,a,f,h,c=!1;;)switch(n){case"hex":return P(this,t,e,r);case"utf8":case"utf-8":return f=e,h=r,V(H(t,(a=this).length-f),a,f,h);case"ascii":return I(this,t,e,r);case"latin1":case"binary":return I(this,t,e,r);case"base64":return i=this,s=e,u=r,V(J(t),i,s,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,e,r);default:if(c)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),c=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function B(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function Y(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function j(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||n<r)&&(r=n);for(var o="",i=e;i<r;++i)o+=z(t[i]);return o}function M(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function L(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function F(t,e,r,n,o,i){if(!R(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(o<e||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function D(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function q(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return o||q(t,0,r,4),i(t,e,r,n,23,4),r+4}function W(t,e,r,n,o){return o||q(t,0,r,8),i(t,e,r,n,52,8),r+8}y.prototype.slice=function(t,e){var r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),e<t&&(e=t),y.TYPED_ARRAY_SUPPORT)(o=this.subarray(t,e)).__proto__=y.prototype;else for(var n=e-t,o=new y(n,void 0),i=0;i<n;++i)o[i]=this[i+t];return o},y.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||L(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},y.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||L(t,e,this.length);for(var n=this[t+--e],o=1;0<e&&(o*=256);)n+=this[t+--e]*o;return n},y.prototype.readUInt8=function(t,e){return e||L(t,1,this.length),this[t]},y.prototype.readUInt16LE=function(t,e){return e||L(t,2,this.length),this[t]|this[t+1]<<8},y.prototype.readUInt16BE=function(t,e){return e||L(t,2,this.length),this[t]<<8|this[t+1]},y.prototype.readUInt32LE=function(t,e){return e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},y.prototype.readUInt32BE=function(t,e){return e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},y.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||L(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)<=n&&(n-=Math.pow(2,8*e)),n},y.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||L(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0<n&&(o*=256);)i+=this[t+--n]*o;return(o*=128)<=i&&(i-=Math.pow(2,8*e)),i},y.prototype.readInt8=function(t,e){return e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},y.prototype.readInt16LE=function(t,e){e||L(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},y.prototype.readInt16BE=function(t,e){e||L(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},y.prototype.readInt32LE=function(t,e){return e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},y.prototype.readInt32BE=function(t,e){return e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},y.prototype.readFloatLE=function(t,e){return e||L(t,4,this.length),r(this,t,!0,23,4)},y.prototype.readFloatBE=function(t,e){return e||L(t,4,this.length),r(this,t,!1,23,4)},y.prototype.readDoubleLE=function(t,e){return e||L(t,8,this.length),r(this,t,!0,52,8)},y.prototype.readDoubleBE=function(t,e){return e||L(t,8,this.length),r(this,t,!1,52,8)},y.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||F(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},y.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||F(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},y.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,1,255,0),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},y.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):x(this,t,e,!0),e+2},y.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):x(this,t,e,!1),e+2},y.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):D(this,t,e,!0),e+4},y.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},y.prototype.writeIntLE=function(t,e,r,n){var o;t=+t,e|=0,n||F(this,t,e,r,(o=Math.pow(2,8*r-1))-1,-o);var i=0,s=1,u=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===u&&0!==this[e+i-1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},y.prototype.writeIntBE=function(t,e,r,n){var o;t=+t,e|=0,n||F(this,t,e,r,(o=Math.pow(2,8*r-1))-1,-o);var i=r-1,s=1,u=0;for(this[e+i]=255&t;0<=--i&&(s*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s>>0)-u&255;return e+r},y.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,1,127,-128),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},y.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):x(this,t,e,!0),e+2},y.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):x(this,t,e,!1),e+2},y.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):D(this,t,e,!0),e+4},y.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),y.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},y.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},y.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},y.prototype.writeDoubleLE=function(t,e,r){return W(this,t,e,!0,r)},y.prototype.writeDoubleBE=function(t,e,r){return W(this,t,e,!1,r)},y.prototype.copy=function(t,e,r,n){if(r=r||0,n||0===n||(n=this.length),e>=t.length&&(e=t.length),e=e||0,0<n&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;0<=o;--o)t[o+e]=this[o+r];else if(i<1e3||!y.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},y.prototype.fill=function(t,e,r,n){if("string"==typeof t){var o;if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=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&&!y.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;if(e>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(t=t||0))for(u=e;u<r;++u)this[u]=t;else for(var i=R(t)?t:H(new y(t,n).toString()),s=i.length,u=0;u<r-e;++u)this[u+e]=i[u%s];return this};var K=/[^+\/0-9A-Za-z-_]/g;function z(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if(55295<(r=t.charCodeAt(s))&&r<57344){if(!o){if(56319<r){-1<(e-=3)&&i.push(239,191,189);continue}if(s+1===n){-1<(e-=3)&&i.push(239,191,189);continue}o=r;continue}if(r<56320){-1<(e-=3)&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&-1<(e-=3)&&i.push(239,191,189);if(o=null,r<128){if(--e<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new 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 J(t){return function(t){var e,r,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),e=0<n?i-4:i;for(var s=0,u=0;u<e;u+=4,0)r=f[t.charCodeAt(u)]<<18|f[t.charCodeAt(u+1)]<<12|f[t.charCodeAt(u+2)]<<6|f[t.charCodeAt(u+3)],o[s++]=r>>16&255,o[s++]=r>>8&255,o[s++]=255&r;return 2==n?(r=f[t.charCodeAt(u)]<<2|f[t.charCodeAt(u+1)]>>4,o[s++]=255&r):1==n&&(r=f[t.charCodeAt(u)]<<10|f[t.charCodeAt(u+1)]<<4|f[t.charCodeAt(u+2)]>>2,o[s++]=r>>8&255,o[s++]=255&r),o}(function(t){var e;if((t=((e=t).trim?e.trim():e.replace(/^\s+|\s+$/g,"")).replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function V(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function Z(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function $(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function G(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Q(t,e,r){return e&&G(t.prototype,e),r&&G(t,r),t}function X(e,t){var r,n=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)),n}function tt(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?X(Object(i),!0).forEach(function(t){var e,r,n;e=o,n=i[r=t],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):X(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function et(t,e){if(null==t)return{};var r,n=function(t,e){if(null==t)return{};for(var r,n={},o=Object.keys(t),i=0;i<o.length;i++)r=o[i],0<=e.indexOf(r)||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols)for(var o=Object.getOwnPropertySymbols(t),i=0;i<o.length;i++)r=o[i],0<=e.indexOf(r)||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r]);return n}function rt(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.status=this.statusCode=this.code=t,this.message=e,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function nt(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,0].concat(e))}function ot(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,400].concat(e))}function it(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,401].concat(e))}function st(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,403].concat(e))}function ut(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,404].concat(e))}function at(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,409].concat(e))}function ft(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,500].concat(e))}function ht(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];rt.call.apply(rt,[this,503].concat(e))}function ct(t){switch(t){case 0:return nt;case 400:return ot;case 401:return it;case 403:return st;case 404:return ut;case 409:return at;case 500:return ft;case 503:return ht;default:return}}var lt="manage_project",pt=function(){function d(t){$(this,d),d._checkRequiredConfiguration(t),this.config=t,this.fetcher=d._getFetcher(t.fetch),this.ANONYMOUS_FLOW_URI="/oauth/--projectKey--/anonymous/token",this.CUSTOMER_PASSWORD_FLOW_URI="/oauth/--projectKey--/customers/token",this.BASE_AUTH_FLOW_URI="/oauth/token",this.INTROSPECT_URI="/oauth/introspect"}return Q(d,[{key:"_process",value:function(e){return this._performRequest(e).then(function(t){return d._handleResponse(e.uri,t)})}},{key:"_performRequest",value:function(t){var e=t.uri,r=t.body,n=t.basicAuth,o=t.authType,i={method:"POST",headers:t.headers||{Authorization:"".concat(o||"Basic"," ").concat(n),"Content-Length":y.byteLength(r).toString(),"Content-Type":"application/x-www-form-urlencoded"},body:r};return this.fetcher.call(null,e,i)}},{key:"_getRequestConfig",value:function(t){var e=0<arguments.length&&void 0!==t?t:{},r=n({},e,this.config);return e.scopes&&(r.scopes=e.scopes),r}},{key:"anonymousFlow",value:function(t,e){var r=0<arguments.length&&void 0!==t?t:"",n=1<arguments.length&&void 0!==e?e:{},o=this._getRequestConfig(n),i=d._buildRequest(o,d._enrichUriWithProjectKey(this.ANONYMOUS_FLOW_URI,o.projectKey));return r&&(i.body+="&anonymous_id=".concat(r)),this._process(i)}},{key:"clientCredentialsFlow",value:function(t){var e=0<arguments.length&&void 0!==t?t:{},r=this._getRequestConfig(e),n=d._buildRequest(r,this.BASE_AUTH_FLOW_URI);return this._process(n)}},{key:"_passwordFlow",value:function(t,e,r){var n=t||{},o=n.username,i=n.password,s=d._buildRequest(e,r,"password");return s.body=d._appendUserCredentialsToBody(s.body,o,i),this._process(s)}},{key:"customerPasswordFlow",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{},n=this._getRequestConfig(r),o=d._enrichUriWithProjectKey(this.CUSTOMER_PASSWORD_FLOW_URI,n.projectKey);return this._passwordFlow(t,n,o)}},{key:"clientPasswordFlow",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{},n=this._getRequestConfig(r);return this._passwordFlow(t,n,this.BASE_AUTH_FLOW_URI)}},{key:"refreshTokenFlow",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{};if(!t)throw new Error("Missing required token value");var n=this._getRequestConfig(r),o=d._buildRequest(n,this.BASE_AUTH_FLOW_URI,"refresh_token");return o.body+="&refresh_token=".concat(encodeURIComponent(t)),this._process(o)}},{key:"introspectToken",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:{},n=this._getRequestConfig(r);if(!t)throw new Error("Missing required token value");var o=d._buildRequest(n,this.INTROSPECT_URI);return o.body="token=".concat(encodeURIComponent(t)),this._process(o)}},{key:"customFlow",value:function(t){var e=t.credentials,r=t.host,n=t.uri,o=t.body,i=t.token,s=t.authType,u=t.headers,a=this._getRequestConfig({host:r,token:i,authType:s,headers:u}),f=d._buildRequest(a,n);return f.body=o||"",e&&(f.body=d._appendUserCredentialsToBody(f.body,e.username,e.password)),this._process(f)}}],[{key:"_getFetcher",value:function(t){if(!t&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");return t||fetch}},{key:"_checkRequiredConfiguration",value:function(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.credentials)throw new Error("Missing required option (credentials)");var e=t.credentials,r=e.clientId,n=e.clientSecret;if(!r||!n)throw new Error("Missing required credentials (clientId, clientSecret)")}},{key:"_encodeClientCredentials",value:function(t){var e=t.clientId,r=t.clientSecret;return y.from("".concat(e,":").concat(r)).toString("base64")}},{key:"_getScopes",value:function(t,e){return t?t.join(" "):[lt,e].filter(Boolean).join(":")}},{key:"_buildRequest",value:function(t,e,r){var n=2<arguments.length&&void 0!==r?r:"client_credentials",o=t.projectKey,i=t.credentials,s=t.host,u=t.disableRefreshToken,a=t.scopes,f=t.headers,h=d._getScopes(a,o),c=s.replace(/\/$/,"")+e,l=t.token||d._encodeClientCredentials(i),p=t.authType||"Basic",g="grant_type=".concat(n);return"refresh_token"!==n&&(g+="&scope=".concat(h)),!0===u&&(g+="&refresh_token=false"),{basicAuth:l,authType:p,uri:c,body:g,headers:f}}},{key:"_createResponseError",value:function(t,e,r){var n=t.message,o=void 0===n?"Unexpected non-JSON error response":n,i=et(t,["message"]),s=404===r?"URI not found: ".concat(e):o;return new(ct(r)||ct(0))(s,i)}},{key:"_parseResponseJson",value:function(t){return t.json().catch(function(){return{statusCode:t.status}})}},{key:"_isErrorResponse",value:function(t){return!t.status||400<=t.status}},{key:"_calculateExpirationTime",value:function(t){return Date.now()+1e3*t}},{key:"_enrichTokenResponse",value:function(t){return t.expires_in?tt(tt({},t),{},{expires_at:d._calculateExpirationTime(t.expires_in)}):t}},{key:"_handleResponse",value:function(e,r){return d._parseResponseJson(r).then(function(t){if(d._isErrorResponse(r))throw d._createResponseError(t,e,r.status);return d._enrichTokenResponse(t)})}},{key:"_appendUserCredentialsToBody",value:function(t,e,r){if(!e||!r)throw new Error("Missing required user credentials (username, password)");return[t,"username=".concat(encodeURIComponent(e)),"password=".concat(encodeURIComponent(r))].filter(Boolean).join("&")}},{key:"_enrichUriWithProjectKey",value:function(t,e){if(!e)throw new Error("Missing required option (projectKey)");return t.replace("--projectKey--",e)}}]),d}(),gt=function(){function s(t){var e=t.sdkAuth,r=t.fetchTokenInfo,n=t.onTokenInfoChanged,o=t.onTokenInfoRefreshed,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if($(this,s),!e)throw new Error('Property "sdkAuth" was not provided');i&&s._validateTokenInfo(i),this.onTokenInfoChanged=n,this.onTokenInfoRefreshed=o,this.fetchTokenInfo=r,this.sdkAuth=e,this.tokenInfo=i,this.fetchTokenInfoPromise=null,this.refreshTokenFlowPromise=null}return Q(s,[{key:"_performFetchTokenInfo",value:function(){var e=this;return this.fetchTokenInfo?this.fetchTokenInfoPromise?this.fetchTokenInfoPromise:(this.fetchTokenInfoPromise=Promise.resolve(this.fetchTokenInfo(this.sdkAuth)),this.fetchTokenInfoPromise.then(function(t){return e.fetchTokenInfoPromise=null,t})):Promise.reject(new Error('Method "fetchTokenInfo" was not provided'))}},{key:"_performRefreshTokenFlow",value:function(t){var e=this;return this.refreshTokenFlowPromise?this.refreshTokenFlowPromise:(this.refreshTokenFlowPromise=this.sdkAuth.refreshTokenFlow(t),this.refreshTokenFlowPromise.then(function(t){return e.refreshTokenFlowPromise=null,t}))}},{key:"_refreshToken",value:function(r){var n,o=this;return null!=r&&r.refresh_token||this.fetchTokenInfo?(null!=r&&r.refresh_token?this._performRefreshTokenFlow(r.refresh_token):this._performFetchTokenInfo()).then(function(t){var e;return n=t,null!=r&&r.refresh_token&&(n.refresh_token=r.refresh_token),null===(e=o.onTokenInfoRefreshed)||void 0===e?void 0:e.call(o,n,r)}).then(function(){return o.setTokenInfo(n)}):Promise.reject(new Error('Property "refresh_token" and "fetchTokenInfo" method are missing'))}},{key:"invalidateTokenInfo",value:function(){this.tokenInfo=null}},{key:"getTokenInfo",value:function(){return this.tokenInfo&&!s._isTokenExpired(this.tokenInfo)?Promise.resolve(this.tokenInfo):this._refreshToken(this.tokenInfo)}},{key:"setTokenInfo",value:function(t){var e;return s._validateTokenInfo(t),this.tokenInfo=t,Promise.resolve(null===(e=this.onTokenInfoChanged)||void 0===e?void 0:e.call(this,t)).then(function(){return t})}},{key:"getAccessToken",value:function(){return this.getTokenInfo().then(function(t){return t.access_token})}}],[{key:"_validateTokenInfo",value:function(t){if(!t.access_token&&!t.refresh_token)throw new Error('At least one of "access_token" or "refresh_token" properties has to be provided')}},{key:"_isTokenExpired",value:function(t){return!(t&&t.access_token&&t.expires_at)||Date.now()>=(t.expires_at||0)-72e5}}]),s}();t.TokenProvider=gt,t.default=pt,Object.defineProperty(t,"__esModule",{value:!0})});

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

"name": "@commercetools/sdk-auth",
"version": "3.0.6",
"version": "3.0.7",
"description": "Auth module for different authentication flows of commercetools platform API",

@@ -36,9 +36,10 @@ "keywords": [

"dependencies": {
"@commercetools/sdk-middleware-http": "^6.0.6",
"@commercetools/sdk-middleware-http": "^6.0.7",
"lodash.defaultsdeep": "^4.6.0"
},
"devDependencies": {
"nock": "12.0.2",
"nock": "12.0.3",
"node-fetch": "2.6.0"
}
},
"gitHead": "015a7a95bf67793d0cef452f592ff3ea6818aef3"
}

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc