UNPKG

@onslip/hawk

Version:

HTTP Hawk Authentication Scheme

1 lines 51.5 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).hawk=e()}(this,(function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})})),r}var n={},o={},i={},a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,h=!1;function f(){h=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)s[e]=t[e],u[t.charCodeAt(e)]=e;u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63}function l(t,e,r){for(var n,o,i=[],a=e;a<r;a+=3)n=(t[a]<<16)+(t[a+1]<<8)+t[a+2],i.push(s[(o=n)>>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}function p(t){var e;h||f();for(var r=t.length,n=r%3,o="",i=[],a=16383,u=0,c=r-n;u<c;u+=a)i.push(l(t,u,u+a>c?c:u+a));return 1===n?(e=t[r-1],o+=s[e>>2],o+=s[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=s[e>>10],o+=s[e>>4&63],o+=s[e<<2&63],o+="="),i.push(o),i.join("")}function d(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<<s)-1,c=u>>1,h=-7,f=r?o-1:0,l=r?-1:1,p=t[e+f];for(f+=l,i=p&(1<<-h)-1,p>>=-h,h+=s;h>0;i=256*i+t[e+f],f+=l,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=n;h>0;a=256*a+t[e+f],f+=l,h-=8);if(0===i)i=1-c;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=c}return(p?-1:1)*a*Math.pow(2,i-n)}function g(t,e,r,n,o,i){var a,s,u,c=8*i-o-1,h=(1<<c)-1,f=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+f>=1?l/u:l*Math.pow(2,1-f))*u>=2&&(a++,u/=2),a+f>=h?(s=0,a=h):a+f>=1?(s=(e*u-1)*Math.pow(2,o),a+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*g}var y={}.toString,w=Array.isArray||function(t){return"[object Array]"==y.call(t)};A.TYPED_ARRAY_SUPPORT=void 0===a.TYPED_ARRAY_SUPPORT||a.TYPED_ARRAY_SUPPORT;var m=v();function v(){return A.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function B(t,e){if(v()<e)throw new RangeError("Invalid typed array length");return A.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=A.prototype:(null===t&&(t=new A(e)),t.length=e),t}function A(t,e,r){if(!(A.TYPED_ARRAY_SUPPORT||this instanceof A))return new A(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return R(this,t)}return _(this,t,e,r)}function _(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);A.TYPED_ARRAY_SUPPORT?(t=e).__proto__=A.prototype:t=S(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!A.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|O(e,r);t=B(t,n);var o=t.write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(P(e)){var r=0|x(e.length);return 0===(t=B(t,r)).length||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||(n=e.length)!=n?B(t,0):S(t,e);if("Buffer"===e.type&&w(e.data))return S(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function E(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 R(t,e){if(E(e),t=B(t,e<0?0:0|x(e)),!A.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function S(t,e){var r=e.length<0?0:0|x(e.length);t=B(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function x(t){if(t>=v())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+v().toString(16)+" bytes");return 0|t}function P(t){return!(null==t||!t._isBuffer)}function O(t,e){if(P(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 rt(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return nt(t).length;default:if(n)return rt(t).length;e=(""+e).toLowerCase(),n=!0}}function T(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 W(this,e,r);case"utf8":case"utf-8":return D(this,e,r);case"ascii":return N(this,e,r);case"latin1":case"binary":return F(this,e,r);case"base64":return Y(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function M(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function U(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?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=A.from(e,n)),P(e))return 0===e.length?-1:k(t,e,r,n,o);if("number"==typeof e)return e&=255,A.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):k(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function k(t,e,r,n,o){var i,a=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;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var h=-1;for(i=r;i<s;i++)if(c(t,i)===c(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===u)return h*a}else-1!==h&&(i-=i-h),h=-1}else for(r+u>s&&(r=s-u),i=r;i>=0;i--){for(var f=!0,l=0;l<u;l++)if(c(t,i+l)!==c(e,l)){f=!1;break}if(f)return i}return-1}function I(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function C(t,e,r,n){return ot(rt(e,t.length-r),t,r,n)}function z(t,e,r,n){return ot(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function j(t,e,r,n){return z(t,e,r,n)}function H(t,e,r,n){return ot(nt(e),t,r,n)}function L(t,e,r,n){return ot(function(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)n=(r=t.charCodeAt(a))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function Y(t,e,r){return 0===e&&r===t.length?p(t):p(t.slice(e,r))}function D(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,a,s,u,c=t[o],h=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&c)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(h=u)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=f}return function(t){var e=t.length;if(e<=q)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=q));return r}(n)}A.poolSize=8192,A._augment=function(t){return t.__proto__=A.prototype,t},A.from=function(t,e,r){return _(null,t,e,r)},A.TYPED_ARRAY_SUPPORT&&(A.prototype.__proto__=Uint8Array.prototype,A.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&A[Symbol.species]),A.alloc=function(t,e,r){return function(t,e,r,n){return E(e),e<=0?B(t,e):void 0!==r?"string"==typeof n?B(t,e).fill(r,n):B(t,e).fill(r):B(t,e)}(null,t,e,r)},A.allocUnsafe=function(t){return R(null,t)},A.allocUnsafeSlow=function(t){return R(null,t)},A.isBuffer=it,A.compare=function(t,e){if(!P(t)||!P(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},A.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}},A.concat=function(t,e){if(!w(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return A.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=A.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(!P(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},A.byteLength=O,A.prototype._isBuffer=!0,A.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},A.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},A.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},A.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?D(this,0,t):T.apply(this,arguments)},A.prototype.equals=function(t){if(!P(t))throw new TypeError("Argument must be a Buffer");return this===t||0===A.compare(this,t)},A.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},A.prototype.compare=function(t,e,r,n,o){if(!P(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(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),c=t.slice(e,r),h=0;h<s;++h)if(u[h]!==c[h]){i=u[h],a=c[h];break}return i<a?-1:a<i?1:0},A.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},A.prototype.indexOf=function(t,e,r){return U(this,t,e,r,!0)},A.prototype.lastIndexOf=function(t,e,r){return U(this,t,e,r,!1)},A.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||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return I(this,t,e,r);case"utf8":case"utf-8":return C(this,t,e,r);case"ascii":return z(this,t,e,r);case"latin1":case"binary":return j(this,t,e,r);case"base64":return H(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},A.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var q=4096;function N(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 F(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 W(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=et(t[i]);return o}function $(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 V(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function G(t,e,r,n,o,i){if(!P(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function K(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 J(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 X(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Z(t,e,r,n,o){return o||X(t,0,r,4),g(t,e,r,n,23,4),r+4}function Q(t,e,r,n,o){return o||X(t,0,r,8),g(t,e,r,n,52,8),r+8}A.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),A.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=A.prototype;else{var o=e-t;r=new A(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},A.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},A.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},A.prototype.readUInt8=function(t,e){return e||V(t,1,this.length),this[t]},A.prototype.readUInt16LE=function(t,e){return e||V(t,2,this.length),this[t]|this[t+1]<<8},A.prototype.readUInt16BE=function(t,e){return e||V(t,2,this.length),this[t]<<8|this[t+1]},A.prototype.readUInt32LE=function(t,e){return e||V(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},A.prototype.readUInt32BE=function(t,e){return e||V(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},A.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},A.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||V(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},A.prototype.readInt8=function(t,e){return e||V(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},A.prototype.readInt16LE=function(t,e){e||V(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},A.prototype.readInt16BE=function(t,e){e||V(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},A.prototype.readInt32LE=function(t,e){return e||V(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},A.prototype.readInt32BE=function(t,e){return e||V(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},A.prototype.readFloatLE=function(t,e){return e||V(t,4,this.length),d(this,t,!0,23,4)},A.prototype.readFloatBE=function(t,e){return e||V(t,4,this.length),d(this,t,!1,23,4)},A.prototype.readDoubleLE=function(t,e){return e||V(t,8,this.length),d(this,t,!0,52,8)},A.prototype.readDoubleBE=function(t,e){return e||V(t,8,this.length),d(this,t,!1,52,8)},A.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||G(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},A.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||G(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},A.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,1,255,0),A.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},A.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,2,65535,0),A.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):K(this,t,e,!0),e+2},A.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,2,65535,0),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):K(this,t,e,!1),e+2},A.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,4,4294967295,0),A.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):J(this,t,e,!0),e+4},A.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,4,4294967295,0),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):J(this,t,e,!1),e+4},A.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);G(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<r&&(a*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a|0)-s&255;return e+r},A.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);G(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a|0)-s&255;return e+r},A.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,1,127,-128),A.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},A.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,2,32767,-32768),A.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):K(this,t,e,!0),e+2},A.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,2,32767,-32768),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):K(this,t,e,!1),e+2},A.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,4,2147483647,-2147483648),A.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):J(this,t,e,!0),e+4},A.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||G(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):J(this,t,e,!1),e+4},A.prototype.writeFloatLE=function(t,e,r){return Z(this,t,e,!0,r)},A.prototype.writeFloatBE=function(t,e,r){return Z(this,t,e,!1,r)},A.prototype.writeDoubleLE=function(t,e,r){return Q(this,t,e,!0,r)},A.prototype.writeDoubleBE=function(t,e,r){return Q(this,t,e,!1,r)},A.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),n>0&&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;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!A.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},A.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&&!A.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,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var a=P(t)?t:rt(new A(t,n).toString()),s=a.length;for(i=0;i<r-e;++i)this[i+e]=a[i%s]}return this};var tt=/[^+\/0-9A-Za-z-_]/g;function et(t){return t<16?"0"+t.toString(16):t.toString(16)}function rt(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],a=0;a<n;++a){if((r=t.charCodeAt(a))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<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 nt(t){return function(t){var e,r,n,o,i,a;h||f();var s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[s-2]?2:"="===t[s-1]?1:0,a=new c(3*s/4-i),n=i>0?s-4:s;var l=0;for(e=0,r=0;e<n;e+=4,r+=3)o=u[t.charCodeAt(e)]<<18|u[t.charCodeAt(e+1)]<<12|u[t.charCodeAt(e+2)]<<6|u[t.charCodeAt(e+3)],a[l++]=o>>16&255,a[l++]=o>>8&255,a[l++]=255&o;return 2===i?(o=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,a[l++]=255&o):1===i&&(o=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,a[l++]=o>>8&255,a[l++]=255&o),a}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(tt,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function ot(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 it(t){return null!=t&&(!!t._isBuffer||at(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&at(t.slice(0,0))}(t))}function at(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var st=r(Object.freeze({__proto__:null,Buffer:A,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),A.alloc(+t)},isBuffer:it,kMaxLength:m})),ut={},ct={exports:{}},ht=function(...t){try{return JSON.stringify(...t)}catch(t){return"[Cannot display object: "+t.message+"]"}};!function(t,e){const r=ht;t.exports=class extends Error{constructor(t){super(t.filter((t=>""!==t)).map((t=>"string"==typeof t?t:t instanceof Error?t.message:r(t))).join(" ")||"Unknown error"),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e.assert)}}}(ct,ct.exports);const ft=ct.exports;var lt=function(t,...e){if(!t){if(1===e.length&&e[0]instanceof Error)throw e[0];throw new ft(e)}};const pt=lt,dt={};dt.iterables=function(t){return t instanceof Set?"set":t instanceof Map?"map":void 0};var gt={exports:{}};!function(t,e){const r=st.Buffer,n={};e=t.exports={array:Array.prototype,buffer:r&&r.prototype,date:Date.prototype,error:Error.prototype,generic:Object.prototype,map:Map.prototype,promise:Promise.prototype,regex:RegExp.prototype,set:Set.prototype,weakMap:WeakMap.prototype,weakSet:WeakSet.prototype},n.typeMap=new Map([["[object Error]",e.error],["[object Map]",e.map],["[object Promise]",e.promise],["[object Set]",e.set],["[object WeakMap]",e.weakMap],["[object WeakSet]",e.weakSet]]),e.getInternalProto=function(t){if(Array.isArray(t))return e.array;if(r&&t instanceof r)return e.buffer;if(t instanceof Date)return e.date;if(t instanceof RegExp)return e.regex;if(t instanceof Error)return e.error;const o=Object.prototype.toString.call(t);return n.typeMap.get(o)||e.generic}}(gt,gt.exports);var yt=gt.exports,wt={keys:function(t,e={}){return!1!==e.symbols?Reflect.ownKeys(t):Object.getOwnPropertyNames(t)}};const mt=st.Buffer,bt=function(t,e,r){if(!1===e||null==e)return t;"string"==typeof(r=r||{})&&(r={separator:r});const n=Array.isArray(e);pt(!n||!r.separator,"Separator option is not valid for array-based chain");const o=n?e:e.split(r.separator||".");let i=t;for(let t=0;t<o.length;++t){let n=o[t];const a=r.iterables&&dt.iterables(i);if(Array.isArray(i)||"set"===a){const t=Number(n);Number.isInteger(t)&&(n=t<0?i.length+t:t)}if(!i||"function"==typeof i&&!1===r.functions||!a&&void 0===i[n]){pt(!r.strict||t+1===o.length,"Missing segment",n,"in reach path ",e),pt("object"==typeof i||!0===r.functions||"function"!=typeof i,"Invalid segment",n,"in reach path ",e),i=r.default;break}i=a?"set"===a?[...i][n]:i.get(n):i[n]}return i},vt=yt,Bt=wt,At={needsProtoHack:new Set([vt.set,vt.map,vt.weakSet,vt.weakMap])};var _t=At.clone=function(t,e={},r=null){if("object"!=typeof t||null===t)return t;let n=At.clone,o=r;if(e.shallow){if(!0!==e.shallow)return At.cloneWithShallow(t,e);n=t=>t}else if(o){const e=o.get(t);if(e)return e}else o=new Map;const i=vt.getInternalProto(t);if(i===vt.buffer)return mt&&mt.from(t);if(i===vt.date)return new Date(t.getTime());if(i===vt.regex)return new RegExp(t);const a=At.base(t,i,e);if(a===t)return t;if(o&&o.set(t,a),i===vt.set)for(const r of t)a.add(n(r,e,o));else if(i===vt.map)for(const[r,i]of t)a.set(r,n(i,e,o));const s=Bt.keys(t,e);for(const r of s){if("__proto__"===r)continue;if(i===vt.array&&"length"===r){a.length=t.length;continue}const s=Object.getOwnPropertyDescriptor(t,r);s?s.get||s.set?Object.defineProperty(a,r,s):s.enumerable?a[r]=n(t[r],e,o):Object.defineProperty(a,r,{enumerable:!1,writable:!0,configurable:!0,value:n(t[r],e,o)}):Object.defineProperty(a,r,{enumerable:!0,writable:!0,configurable:!0,value:n(t[r],e,o)})}return a};At.cloneWithShallow=function(t,e){const r=e.shallow;(e=Object.assign({},e)).shallow=!1;const n=new Map;for(const e of r){const r=bt(t,e);"object"!=typeof r&&"function"!=typeof r||n.set(r,r)}return At.clone(t,e,n)},At.base=function(t,e,r){if(!1===r.prototype)return At.needsProtoHack.has(e)?new e.constructor:e===vt.array?[]:{};const n=Object.getPrototypeOf(t);if(n&&n.isImmutable)return t;if(e===vt.array){const t=[];return n!==e&&Object.setPrototypeOf(t,n),t}if(At.needsProtoHack.has(e)){const t=new n.constructor;return n!==e&&Object.setPrototypeOf(t,n),t}return Object.create(n)};const Et=lt;ut.assert=lt,ut.clone=_t,ut.escapeHeaderAttribute=function(t){return Et(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(t),"Bad attribute value ("+t+")"),t.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')};const Rt=st.Buffer,St=ut;i.base64urlEncode=function(t,e){St.assert("string"==typeof t||Rt.isBuffer(t),"value must be string or buffer");return(Rt.isBuffer(t)?t:Rt.from(t,e||"binary")).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")},i.base64urlDecode=function(t,e){if("string"!=typeof t)throw new Error("Value not a string");if(!/^[\w\-]*$/.test(t))throw new Error("Invalid character");const r=Rt.from(t,"base64");return"buffer"===e?r:r.toString(e||"binary")};var xt={};!function(t){const e=ut,r={codes:new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Moved Temporarily"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Time-out"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Request Entity Too Large"],[414,"Request-URI Too Large"],[415,"Unsupported Media Type"],[416,"Requested Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a teapot"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Time-out"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]])};t.Boom=class extends Error{constructor(n,o={}){if(n instanceof Error)return t.boomify(e.clone(n),o);const{statusCode:i=500,data:a=null,ctor:s=t.Boom}=o,u=new Error(n||void 0);"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(u,s),u.data=a;const c=r.initialize(u,i);return Object.defineProperty(c,"typeof",{value:s}),o.decorate&&Object.assign(c,o.decorate),c}static[Symbol.hasInstance](e){return this===t.Boom?t.isBoom(e):this.prototype.isPrototypeOf(e)}},t.isBoom=function(t,e){return t instanceof Error&&!!t.isBoom&&(!e||t.output.statusCode===e)},t.boomify=function(t,n){return e.assert(t instanceof Error,"Cannot wrap non-Error object"),void 0!==(n=n||{}).data&&(t.data=n.data),n.decorate&&Object.assign(t,n.decorate),t.isBoom?!1===n.override||!n.statusCode&&!n.message?t:r.initialize(t,n.statusCode||t.output.statusCode,n.message):r.initialize(t,n.statusCode||500,n.message)},t.badRequest=function(e,r){return new t.Boom(e,{statusCode:400,data:r,ctor:t.badRequest})},t.unauthorized=function(r,n,o){const i=new t.Boom(r,{statusCode:401,ctor:t.unauthorized});if(!n)return i;if("string"!=typeof n)return i.output.headers["WWW-Authenticate"]=n.join(", "),i;let a=`${n}`;return(o||r)&&(i.output.payload.attributes={}),o&&("string"==typeof o?(a+=" "+e.escapeHeaderAttribute(o),i.output.payload.attributes=o):a+=" "+Object.keys(o).map((t=>{let r=o[t];return null==r&&(r=""),i.output.payload.attributes[t]=r,`${t}="${e.escapeHeaderAttribute(r.toString())}"`})).join(", ")),r?(o&&(a+=","),a+=` error="${e.escapeHeaderAttribute(r)}"`,i.output.payload.attributes.error=r):i.isMissing=!0,i.output.headers["WWW-Authenticate"]=a,i},t.internal=function(e,n,o=500){return r.serverError(e,n,o,t.internal)},r.initialize=function(t,n,o){const i=parseInt(n,10);if(e.assert(!isNaN(i)&&i>=400,"First argument must be a number (400+):",n),t.isBoom=!0,t.isServer=i>=500,t.hasOwnProperty("data")||(t.data=null),t.output={statusCode:i,payload:{},headers:{}},Object.defineProperty(t,"reformat",{value:r.reformat,configurable:!0}),o||t.message||(t.reformat(),o=t.output.payload.error),o){const r=Object.getOwnPropertyDescriptor(t,"message")||Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"message");e.assert(!r||r.configurable&&!r.get,"The error is not compatible with boom"),t.message=o+(t.message?": "+t.message:""),t.output.payload.message=t.message}return t.reformat(),t},r.reformat=function(t=!1){this.output.payload.statusCode=this.output.statusCode,this.output.payload.error=r.codes.get(this.output.statusCode)||"Unknown",500===this.output.statusCode&&!0!==t?this.output.payload.message="An internal server error occurred":this.message&&(this.output.payload.message=this.message)},r.serverError=function(e,r,n,o){return r instanceof Error&&!r.isBoom?t.boomify(r,{statusCode:n,message:e}):new t.Boom(e,{statusCode:n,data:r,ctor:o})}}(xt);var Pt={},Ot={};const Tt=st.Buffer;function Mt(t){return t instanceof Uint8Array?jt.enc.Base64.parse(btoa(String.fromCharCode.apply(null,t))):t}function Ut(t){return{update:function(e){return t.update(Mt(e)),this},digest:function(e){var r=t.finalize();return"base64"===e?r.toString(jt.enc.Base64):Tt.from(r.toString(),"hex")}}}Ot.timingSafeEqual=function(t,e){if(t.length!==e.length)throw new TypeError("Input buffers must have the same length");for(var r=t.length,n=0,o=-1;++o<r;)n|=t[o]^e[o];return 0===n},Ot.randomBytes=function(t){return crypto.getRandomValues(Tt.allocUnsafe(t))},Ot.createHmac=function(t,e){return Ut(jt.algo.HMAC.create(jt.algo[t.toUpperCase()],Mt(e)))},Ot.createHash=function(t){return Ut(jt.algo[t.toUpperCase()].create())};var kt,It,Ct,zt,jt=jt||function(t){var r={},n=r.lib={},o=function(){},i=n.Base={extend:function(t){o.prototype=this;var e=new o;return t&&e.mixIn(t),e.hasOwnProperty("init")||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(let e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=n.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var r=this.words,n=t.words,o=this.sigBytes;if(t=t.sigBytes,this.clamp(),o%4)for(let e=0;e<t;e++)r[o+e>>>2]|=(n[e>>>2]>>>24-e%4*8&255)<<24-(o+e)%4*8;else if(65535<n.length)for(e=0;e<t;e+=4)r[o+e>>>2]=n[e>>>2];else r.push.apply(r,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){return new a.init(b,t)}}),s=r.enc={},u=s.Hex={stringify:function(t){var e=t.words;t=t.sigBytes;for(var r=[],n=0;n<t;n++){var o=e[n>>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n+=2)r[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new a.init(r,e/2)}},c=s.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var r=[],n=0;n<t;n++)r.push(String.fromCharCode(e[n>>>2]>>>24-n%4*8&255));return r.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new a.init(r,e)}},h=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},f=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,o=r.sigBytes,i=this.blockSize,s=o/(4*i);if(e=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*i,o=t.min(4*e,o),e){for(var u=0;u<e;u+=i)this._doProcessBlock(n,u);u=n.splice(0,e),r.sigBytes-=o}return new a.init(u,o)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});n.Hasher=f.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new l.HMAC.init(t,r).finalize(e)}}});var l=r.algo={};return r}(Math);(()=>{var t=jt,e=(o=t.lib).WordArray,r=o.Hasher,n=[],o=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,o=r[0],i=r[1],a=r[2],s=r[3],u=r[4],c=0;80>c;c++){if(16>c)n[c]=0|t[e+c];else{var h=n[c-3]^n[c-8]^n[c-14]^n[c-16];n[c]=h<<1|h>>>31}h=(o<<5|o>>>27)+u+n[c],h=20>c?h+(1518500249+(i&a|~i&s)):40>c?h+(1859775393+(i^a^s)):60>c?h+((i&a|i&s|a&s)-1894007588):h+((i^a^s)-899497514),u=s,s=a,a=i<<30|i>>>2,i=o,o=h}r[0]=r[0]+o|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+s|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(o),t.HmacSHA1=r._createHmacHelper(o)})(),function(t){for(var e=jt,r=(o=e.lib).WordArray,n=o.Hasher,o=e.algo,i=[],a=[],s=function(t){return 4294967296*(t-(0|t))|0},u=2,c=0;64>c;){var h;t:{h=u;for(var f=t.sqrt(h),l=2;l<=f;l++)if(!(h%l)){h=!1;break t}h=!0}h&&(8>c&&(i[c]=s(t.pow(u,.5))),a[c]=s(t.pow(u,1/3)),c++),u++}var p=[];o=o.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],s=r[3],u=r[4],c=r[5],h=r[6],f=r[7],l=0;64>l;l++){if(16>l)p[l]=0|t[e+l];else{var d=p[l-15],g=p[l-2];p[l]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+p[l-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+p[l-16]}d=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&h)+a[l]+p[l],g=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&o^n&i^o&i),f=h,h=c,c=u,u=s+d|0,s=i,i=o,o=n,n=d+g|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+s|0,r[4]=r[4]+u|0,r[5]=r[5]+c|0,r[6]=r[6]+h|0,r[7]=r[7]+f|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return r[o>>>5]|=128<<24-o%32,r[14+(o+64>>>9<<4)]=t.floor(n/4294967296),r[15+(o+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(o),e.HmacSHA256=n._createHmacHelper(o)}(Math),It=(kt=jt).enc.Utf8,kt.algo.HMAC=kt.lib.Base.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=It.parse(e));var r=t.blockSize,n=4*r;e.sigBytes>n&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),a=o.words,s=i.words,u=0;u<r;u++)a[u]^=1549556828,s[u]^=909522486;o.sigBytes=i.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}}),zt=(Ct=jt).lib.WordArray,Ct.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,n=this._map;t.clamp(),t=[];for(var o=0;o<r;o+=3)for(var i=(e[o>>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a<r;a++)t.push(n.charAt(i>>>6*(3-a)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var e=t.length,r=this._map;(n=r.charAt(64))&&-1!=(n=t.indexOf(n))&&(e=n);for(var n=[],o=0,i=0;i<e;i++)if(i%4){var a=r.indexOf(t.charAt(i-1))<<i%4*2,s=r.indexOf(t.charAt(i))>>>6-i%4*2;n[o>>>2]|=(a|s)<<24-o%4*8,o++}return zt.create(n,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(t){const e=st.Buffer,r=Ot,n=xt,o={};t.randomString=function(e){return t.randomBits(6*(e+1)).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"").slice(0,e)},t.randomBits=function(t){if(!t||t<0)throw n.internal("Invalid random bits count");const e=Math.ceil(t/8);return o.random(e)},t.fixedTimeComparison=function(t,n){try{return r.timingSafeEqual(e.from(t),e.from(n))}catch(t){return!1}},o.random=function(t){try{return r.randomBytes(t)}catch(t){throw n.internal("Failed generating random bits: "+t.message)}}}(Pt);var Ht={},Lt={},Yt="9.0.2-onslip.3";!function(t){const e=xt,r={};t.version=function(){return Yt},t.limits={maxMatchLength:4096},t.parseHost=function(e,r){r=r?r.toLowerCase():"host";const n=e.headers[r];if(!n)return null;if(n.length>t.limits.maxMatchLength)return null;if(-1!==n.indexOf("/"))return null;let o;try{o=new URL("http://"+n)}catch(t){return null}return{name:o.hostname,port:o.port?o.port:e.connection&&e.connection.encrypted?443:80}},t.parseContentType=function(t){return t?t.split(";")[0].trim().toLowerCase():""},t.parseRequest=function(r,n){if(!r.headers)return r;let o;if(!(n.host&&n.port||(o=t.parseHost(r,n.hostHeaderName),o)))throw e.badRequest("Invalid Host header");return{method:r.method,url:r.url,host:n.host||o.name,port:n.port||o.port,authorization:r.headers.authorization,contentType:r.headers["content-type"]||""}};let n=Date.now;t.setTimeFunction=function(t){n=t},t.now=function(t){return n()+(t||0)},t.nowSecs=function(e){return Math.floor(t.now(e)/1e3)},r.authHeaderRegex=/^(\w+)(?:\s+(.*))?$/,r.attributeRegex=/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~]+$/,t.parseAuthorizationHeader=function(n,o){if(o=o||["id","ts","nonce","hash","ext","mac","app","dlg"],!n)throw e.unauthorized(null,"Hawk");if(n.length>t.limits.maxMatchLength)throw e.badRequest("Header length too long");const i=n.match(r.authHeaderRegex);if(!i)throw e.badRequest("Invalid header syntax");if("hawk"!==i[1].toLowerCase())throw e.unauthorized(null,"Hawk");const a=i[2];if(!a)throw e.badRequest("Invalid header syntax");const s={};let u="";if(""!==a.replace(/(\w+)="([^"\\]*)"\s*(?:,\s*|$)/g,((t,e,n)=>{if(-1!==o.indexOf(e))if(null!==n.match(r.attributeRegex)){if(!s.hasOwnProperty(e))return s[e]=n,"";u="Duplicate attribute: "+e}else u="Bad attribute value: "+e;else u="Unknown attribute: "+e})))throw e.badRequest(u||"Bad header format");return s},t.unauthorized=function(t,r){return e.unauthorized(t||null,"Hawk",r)}}(Lt),function(t){const e=Ot,r=Lt;t.headerVersion="1",t.algorithms=["sha1","sha256"],t.calculateMac=function(r,n,o){const i=t.generateNormalizedString(r,o);return e.createHmac(n.algorithm,n.key).update(i).digest("base64")},t.generateNormalizedString=function(e,r){let n=r.resource||"";if(n&&"/"!==n[0]){const t=new URL(n);n=t.pathname+(t.search||(t.href.replace(/#.*/,"").endsWith("?")?"?":""))}let o="hawk."+t.headerVersion+"."+e+"\n"+r.ts+"\n"+r.nonce+"\n"+(r.method||"").toUpperCase()+"\n"+n+"\n"+r.host.toLowerCase()+"\n"+r.port+"\n"+(r.hash||"")+"\n";return r.ext&&(o+=r.ext.replace(/\\/g,"\\\\").replace(/\n/g,"\\n")),o+="\n",r.app&&(o=o+r.app+"\n"+(r.dlg||"")+"\n"),o},t.calculatePayloadHash=function(e,r,n){const o=t.initializePayloadHash(r,n);return o.update(e||""),t.finalizePayloadHash(o)},t.initializePayloadHash=function(n,o){const i=e.createHash(n);return i.update("hawk."+t.headerVersion+".payload\n"),i.update(r.parseContentType(o)+"\n"),i},t.finalizePayloadHash=function(t){return t.update("\n"),t.digest("base64")},t.calculateTsMac=function(r,n){const o=e.createHmac(n.algorithm,n.key);return o.update("hawk."+t.headerVersion+".ts\n"+r+"\n"),o.digest("base64")},t.timestampMessage=function(e,n){const o=r.nowSecs(n);return{ts:o,tsm:t.calculateTsMac(o,e)}}}(Ht);const Dt=i,qt=xt,Nt=Pt,Ft=ut,Wt=Ht,$t=Lt,Vt={};o.authenticate=async function(t,e,r){(r=r||{}).timestampSkewSec=r.timestampSkewSec||60;const n=$t.now(r.localtimeOffsetMsec),o=$t.parseRequest(t,r),i=$t.parseAuthorizationHeader(o.authorization),a={method:o.method,host:o.host,port:o.port,resource:o.url,ts:i.ts,nonce:i.nonce,hash:i.hash,ext:i.ext,app:i.app,dlg:i.dlg,mac:i.mac,id:i.id};if(!(i.id&&i.ts&&i.nonce&&i.mac))throw qt.badRequest("Missing attributes",{decorate:{artifacts:a}});try{var s=await e(i.id)}catch(t){throw qt.boomify(t,{decorate:{artifacts:a}})}if(!s)throw Object.assign($t.unauthorized("Unknown credentials"),{artifacts:a});const u={credentials:s,artifacts:a};if(!s.key||!s.algorithm)throw new qt.Boom("Invalid credentials",{decorate:u});if(-1===Wt.algorithms.indexOf(s.algorithm))throw new qt.Boom("Unknown algorithm",{decorate:u});const c=Wt.calculateMac("header",s,a);if(!Nt.fixedTimeComparison(c,i.mac))throw Object.assign($t.unauthorized("Bad mac"),u);if(r.payload||""===r.payload){if(!i.hash)throw Object.assign($t.unauthorized("Missing required payload hash"),u);const t=Wt.calculatePayloadHash(r.payload,s.algorithm,o.contentType);if(!Nt.fixedTimeComparison(t,i.hash))throw Object.assign($t.unauthorized("Bad payload hash"),u)}if(r.nonceFunc)try{await r.nonceFunc(s.key,i.nonce,i.ts)}catch(t){throw Object.assign($t.unauthorized("Invalid nonce"),u)}if(Math.abs(1e3*i.ts-n)>1e3*r.timestampSkewSec){const t=Wt.timestampMessage(s,r.localtimeOffsetMsec);throw Object.assign($t.unauthorized("Stale timestamp",t),u)}return u},o.authenticatePayload=function(t,e,r,n){const o=Wt.calculatePayloadHash(t,e.algorithm,n);if(!Nt.fixedTimeComparison(o,r.hash))throw Object.assign($t.unauthorized("Bad payload hash"),{credentials:e,artifacts:r})},o.authenticatePayloadHash=function(t,e){if(!Nt.fixedTimeComparison(t,e.hash))throw Object.assign($t.unauthorized("Bad payload hash"),{artifacts:e})},o.header=function(t,e,r){if(r=r||{},!e||"object"!=typeof e||"object"!=typeof r)throw new qt.Boom("Invalid inputs");if(delete(e=Ft.clone(e)).mac,e.hash=r.hash,e.ext=r.ext,!t||!t.key||!t.algorithm)throw new qt.Boom("Invalid credentials");if(-1===Wt.algorithms.indexOf(t.algorithm))throw new qt.Boom("Unknown algorithm");e.hash||!r.payload&&""!==r.payload||(e.hash=Wt.calculatePayloadHash(r.payload,t.algorithm,r.contentType));let n='Hawk mac="'+Wt.calculateMac("response",t,e)+'"'+(e.hash?', hash="'+e.hash+'"':"");return null!==e.ext&&void 0!==e.ext&&""!==e.ext&&(n=n+', ext="'+Ft.escapeHeaderAttribute(e.ext)+'"'),n},Vt.bewitRegex=/^(\/.*)([\?&])bewit\=([^&$]*)(?:&(.+))?$/,o.authenticateBewit=async function(t,e,r){r=r||{};const n=$t.now(r.localtimeOffsetMsec),o=$t.parseRequest(t,r);if(o.url.length>$t.limits.maxMatchLength)throw qt.badRequest("Resource path exceeds max length");const i=o.url.match(Vt.bewitRegex);if(!i)throw $t.unauthorized();if(!i[3])throw $t.unauthorized("Empty bewit");if("GET"!==o.method&&"HEAD"!==o.method)throw $t.unauthorized("Invalid method");if(o.authorization)throw qt.badRequest("Multiple authentications");try{var a=Dt.base64urlDecode(i[3])}catch(t){throw qt.badRequest("Invalid bewit encoding")}const s=a.split("\\");if(4!==s.length)throw qt.badRequest("Invalid bewit structure");const u={id:s[0],exp:s[1],mac:s[2],ext:s[3]||""};if(!u.id||!u.exp||!u.mac)throw qt.badRequest("Missing bewit attributes");let c=i[1];i[4]&&(c=c+i[2]+i[4]);try{var h=await e(u.id)}catch(t){throw new qt.Boom(t,{decorate:{bewit:u}})}if(!h)throw Object.assign($t.unauthorized("Unknown credentials"),{bewit:u});const f={credentials:h,attributes:u};if(!h.key||!h.algorithm)throw new qt.Boom("Invalid credentials",{decorate:f});if(-1===Wt.algorithms.indexOf(h.algorithm))throw new qt.Boom("Unknown algorithm",{decorate:f});const l=Wt.calculateMac("bewit",h,{ts:u.exp,nonce:"",method:"GET",resource:c,host:o.host,port:o.port,ext:u.ext});if(!Nt.fixedTimeComparison(l,u.mac))throw Object.assign($t.unauthorized("Bad mac"),f);if(1e3*parseInt(u.exp,10)<=n)throw Object.assign($t.unauthorized("Access expired"),{bewit:u});return f},o.authenticateMessage=async function(t,e,r,n,o,i){(i=i||{}).timestampSkewSec=i.timestampSkewSec||60;const a=$t.now(i.localtimeOffsetMsec);if(!(n.id&&n.ts&&n.nonce&&n.hash&&n.mac))throw qt.badRequest("Invalid authorization");const s=await o(n.id);if(!s)throw $t.unauthorized("Unknown credentials");const u={credentials:s};if(!s.key||!s.algorithm)throw new qt.Boom("Invalid credentials",{decorate:u});if(-1===Wt.algorithms.indexOf(s.algorithm))throw new qt.Boom("Unknown algorithm",{decorate:u});const c={ts:n.ts,nonce:n.nonce,host:t,port:e,hash:n.hash},h=Wt.calculateMac("message",s,c);if(!Nt.fixedTimeComparison(h,n.mac))throw Object.assign($t.unauthorized("Bad mac"),u);const f=Wt.calculatePayloadHash(r,s.algorithm);if(!Nt.fixedTimeComparison(f,n.hash))throw Object.assign($t.unauthorized("Bad message hash"),u);if(i.nonceFunc)try{await i.nonceFunc(s.key,n.nonce,n.ts)}catch(t){throw Object.assign($t.unauthorized("Invalid nonce"),u)}if(Math.abs(1e3*n.ts-a)>1e3*i.timestampSkewSec)throw Object.assign($t.unauthorized("Stale timestamp"),u);return u};var Gt={};const Kt=i,Jt=xt,Xt=Pt,Zt=ut,Qt=Ht,te=Lt;return Gt.header=function(t,e,r){if(!t||"string"!=typeof t&&"object"!=typeof t||!e||"string"!=typeof e||!r||"object"!=typeof r)throw new Jt.Boom("Invalid argument type");const n=r.timestamp||te.nowSecs(r.localtimeOffsetMsec),o=r.credentials;if(!(o&&o.id&&o.key&&o.algorithm))throw new Jt.Boom("Invalid credentials");if(-1===Qt.algorithms.indexOf(o.algorithm))throw new Jt.Boom("Unknown algorithm");"string"==typeof t&&(t=new URL(t));const i={ts:n,nonce:r.nonce||Xt.randomString(6),method:e,resource:t.pathname+(t.search||(t.href.replace(/#.*/,"").endsWith("?")?"?":"")),host:t.hostname,port:t.port||("http:"===t.protocol?80:443),hash:r.hash,ext:r.ext,app:r.app,dlg:r.dlg};i.hash||!r.payload&&""!==r.payload||(i.hash=Qt.calculatePayloadHash(r.payload,o.algorithm,r.contentType));const a=Qt.calculateMac("header",o,i),s=null!==i.ext&&void 0!==i.ext&&""!==i.ext;let u='Hawk id="'+o.id+'", ts="'+i.ts+'", nonce="'+i.nonce+(i.hash?'", hash="'+i.hash:"")+(s?'", ext="'+Zt.escapeHeaderAttribute(i.ext):"")+'", mac="'+a+'"';return i.app&&(u=u+', app="'+i.app+(i.dlg?'", dlg="'+i.dlg:"")+'"'),{header:u,artifacts:i}},Gt.authenticate=function(t,e,r,n){n=n||{},r=Zt.clone(r);const o={headers:{}};if(t.headers["www-authenticate"]){try{var i=te.parseAuthorizationHeader(t.headers["www-authenticate"],["ts","tsm","error"])}catch(t){throw new Jt.Boom("Invalid WWW-Authenticate header")}if(o.headers["www-authenticate"]=i,i.ts){if(Qt.calculateTsMac(i.ts,e)!==i.tsm)throw new Jt.Boom("Invalid server timestamp hash",{decorate:o})}}if(!t.headers["server-authorization"]){if(n.required)throw new Jt.Boom("Missing Server-Authorization header",{decorate:o});return o}try{var a=te.parseAuthorizationHeader(t.headers["server-authorization"],["mac","ext","hash"])}catch(t){throw new Jt.Boom("Invalid Server-Authorization header",{decorate:o})}o.headers["server-authorization"]=a,r.ext=a.ext,r.hash=a.hash;if(Qt.calculateMac("response",e,r)!==a.mac)throw new Jt.Boom("Bad response mac",{decorate:o});if(null===n.payload||void 0===n.payload)return o;if(!a.hash)throw new Jt.Boom("Missing response hash attribute",{decorate:o});if(Qt.calculatePayloadHash(n.payload,e.algorithm,t.headers["content-type"])!==a.