Socket
Socket
Sign inDemoInstall

@commercetools/sdk-auth

Package Overview
Dependencies
3
Maintainers
16
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.10 to 3.0.11

8

dist/sdk-auth.cjs.js

@@ -5,6 +5,8 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var defaultsDeep = require('lodash.defaultsdeep');
var defaultsDeep = _interopDefault(require('lodash.defaultsdeep'));
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var defaultsDeep__default = /*#__PURE__*/_interopDefaultLegacy(defaultsDeep);
function _classCallCheck(instance, Constructor) {

@@ -353,3 +355,3 @@ if (!(instance instanceof Constructor)) {

var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var mergedConfig = defaultsDeep({}, config, this.config); // handle scopes array - defaultsDeep would merge arrays together
var mergedConfig = defaultsDeep__default['default']({}, config, this.config); // handle scopes array - defaultsDeep would merge arrays together
// instead of taking its first occurrence

@@ -356,0 +358,0 @@

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

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

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

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

@@ -36,3 +36,3 @@ "keywords": [

"dependencies": {
"@commercetools/sdk-middleware-http": "^6.0.9",
"@commercetools/sdk-middleware-http": "^6.0.10",
"lodash.defaultsdeep": "^4.6.0",

@@ -45,3 +45,3 @@ "qss": "2.0.3"

},
"gitHead": "aff6d994980fdce5a5c4f839c0434fb1f76ef0ca"
"gitHead": "6f932d8f58b16d44fd296d9fe917c4d117724562"
}

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