jsonwebtoken.js 47.7 KB
Newer Older
VK1688's avatar
VK1688 已提交
1
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var buffer=_interopDefault(require("buffer")),stream=_interopDefault(require("stream")),util=_interopDefault(require("util")),crypto=_interopDefault(require("crypto"));function createCommonjsModule(e,r){return e(r={exports:{}},r.exports),r.exports}var safeBuffer=createCommonjsModule((function(e,r){var t=buffer.Buffer;function n(e,r){for(var t in e)r[t]=e[t]}function o(e,r,n){return t(e,r,n)}t.from&&t.alloc&&t.allocUnsafe&&t.allocUnsafeSlow?e.exports=buffer:(n(buffer,r),r.Buffer=o),o.prototype=Object.create(t.prototype),n(t,o),o.from=function(e,r,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return t(e,r,n)},o.alloc=function(e,r,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=t(e);return void 0!==r?"string"==typeof n?o.fill(r,n):o.fill(r):o.fill(0),o},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return t(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(e)}})),safeBuffer_1=safeBuffer.Buffer,Buffer$1=safeBuffer.Buffer;function DataStream(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=Buffer$1.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=Buffer$1.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}util.inherits(DataStream,stream),DataStream.prototype.write=function(e){this.buffer=Buffer$1.concat([this.buffer,Buffer$1.from(e)]),this.emit("data",e)},DataStream.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1};var dataStream=DataStream,Buffer$2=buffer.Buffer,SlowBuffer=buffer.SlowBuffer,bufferEqualConstantTime=bufferEq;function bufferEq(e,r){if(!Buffer$2.isBuffer(e)||!Buffer$2.isBuffer(r))return!1;if(e.length!==r.length)return!1;for(var t=0,n=0;n<e.length;n++)t|=e[n]^r[n];return 0===t}bufferEq.install=function(){Buffer$2.prototype.equal=SlowBuffer.prototype.equal=function(e){return bufferEq(this,e)}};var origBufEqual=Buffer$2.prototype.equal,origSlowBufEqual=SlowBuffer.prototype.equal;function getParamSize(e){return(e/8|0)+(e%8==0?0:1)}bufferEq.restore=function(){Buffer$2.prototype.equal=origBufEqual,SlowBuffer.prototype.equal=origSlowBufEqual};var paramBytesForAlg={ES256:getParamSize(256),ES384:getParamSize(384),ES512:getParamSize(521)};function getParamBytesForAlg(e){var r=paramBytesForAlg[e];if(r)return r;throw new Error('Unknown algorithm "'+e+'"')}var paramBytesForAlg_1=getParamBytesForAlg,Buffer$3=safeBuffer.Buffer,MAX_OCTET=128,CLASS_UNIVERSAL=0,PRIMITIVE_BIT=32,TAG_SEQ=16,TAG_INT=2,ENCODED_TAG_SEQ=TAG_SEQ|PRIMITIVE_BIT|CLASS_UNIVERSAL<<6,ENCODED_TAG_INT=TAG_INT|CLASS_UNIVERSAL<<6;function base64Url(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function signatureAsBuffer(e){if(Buffer$3.isBuffer(e))return e;if("string"==typeof e)return Buffer$3.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function derToJose(e,r){e=signatureAsBuffer(e);var t=paramBytesForAlg_1(r),n=t+1,o=e.length,i=0;if(e[i++]!==ENCODED_TAG_SEQ)throw new Error('Could not find expected "seq"');var s=e[i++];if(s===(1|MAX_OCTET)&&(s=e[i++]),o-i<s)throw new Error('"seq" specified length of "'+s+'", only "'+(o-i)+'" remaining');if(e[i++]!==ENCODED_TAG_INT)throw new Error('Could not find expected "int" for "r"');var a=e[i++];if(o-i-2<a)throw new Error('"r" specified length of "'+a+'", only "'+(o-i-2)+'" available');if(n<a)throw new Error('"r" specified length of "'+a+'", max of "'+n+'" is acceptable');var u=i;if(i+=a,e[i++]!==ENCODED_TAG_INT)throw new Error('Could not find expected "int" for "s"');var c=e[i++];if(o-i!==c)throw new Error('"s" specified length of "'+c+'", expected "'+(o-i)+'"');if(n<c)throw new Error('"s" specified length of "'+c+'", max of "'+n+'" is acceptable');var f=i;if((i+=c)!==o)throw new Error('Expected to consume entire buffer, but "'+(o-i)+'" bytes remain');var l=t-a,p=t-c,m=Buffer$3.allocUnsafe(l+a+p+c);for(i=0;i<l;++i)m[i]=0;e.copy(m,i,u+Math.max(-l,0),u+a);for(var h=i=t;i<h+p;++i)m[i]=0;return e.copy(m,i,f+Math.max(-p,0),f+c),m=base64Url(m=m.toString("base64"))}function countPadding(e,r,t){for(var n=0;r+n<t&&0===e[r+n];)++n;return e[r+n]>=MAX_OCTET&&--n,n}function joseToDer(e,r){e=signatureAsBuffer(e);var t=paramBytesForAlg_1(r),n=e.length;if(n!==2*t)throw new TypeError('"'+r+'" signatures must be "'+2*t+'" bytes, saw "'+n+'"');var o=countPadding(e,0,t),i=countPadding(e,t,e.length),s=t-o,a=t-i,u=2+s+1+1+a,c=u<MAX_OCTET,f=Buffer$3.allocUnsafe((c?2:3)+u),l=0;return f[l++]=ENCODED_TAG_SEQ,c?f[l++]=u:(f[l++]=1|MAX_OCTET,f[l++]=255&u),f[l++]=ENCODED_TAG_INT,f[l++]=s,o<0?(f[l++]=0,l+=e.copy(f,l,0,t)):l+=e.copy(f,l,o,t),f[l++]=ENCODED_TAG_INT,f[l++]=a,i<0?(f[l++]=0,e.copy(f,l,t)):e.copy(f,l,t+i),f}var ecdsaSigFormatter={derToJose:derToJose,joseToDer:joseToDer},Buffer$4=safeBuffer.Buffer,MSG_INVALID_ALGORITHM='"%s" is not a valid algorithm.\n  Supported algorithms are:\n  "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',MSG_INVALID_SECRET="secret must be a string or buffer",MSG_INVALID_VERIFIER_KEY="key must be a string or a buffer",MSG_INVALID_SIGNER_KEY="key must be a string, a buffer or an object",supportsKeyObjects="function"==typeof crypto.createPublicKey;function checkIsPublicKey(e){if(!Buffer$4.isBuffer(e)&&"string"!=typeof e){if(!supportsKeyObjects)throw typeError(MSG_INVALID_VERIFIER_KEY);if("object"!=typeof e)throw typeError(MSG_INVALID_VERIFIER_KEY);if("string"!=typeof e.type)throw typeError(MSG_INVALID_VERIFIER_KEY);if("string"!=typeof e.asymmetricKeyType)throw typeError(MSG_INVALID_VERIFIER_KEY);if("function"!=typeof e.export)throw typeError(MSG_INVALID_VERIFIER_KEY)}}function checkIsPrivateKey(e){if(!Buffer$4.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw typeError(MSG_INVALID_SIGNER_KEY)}function checkIsSecretKey(e){if(!Buffer$4.isBuffer(e)){if("string"==typeof e)return e;if(!supportsKeyObjects)throw typeError(MSG_INVALID_SECRET);if("object"!=typeof e)throw typeError(MSG_INVALID_SECRET);if("secret"!==e.type)throw typeError(MSG_INVALID_SECRET);if("function"!=typeof e.export)throw typeError(MSG_INVALID_SECRET)}}function fromBase64(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function toBase64(e){var r=4-(e=e.toString()).length%4;if(4!==r)for(var t=0;t<r;++t)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function typeError(e){var r=[].slice.call(arguments,1),t=util.format.bind(util,e).apply(null,r);return new TypeError(t)}function bufferOrString(e){return Buffer$4.isBuffer(e)||"string"==typeof e}function normalizeInput(e){return bufferOrString(e)||(e=JSON.stringify(e)),e}function createHmacSigner(e){return function(r,t){checkIsSecretKey(t),r=normalizeInput(r);var n=crypto.createHmac("sha"+e,t);return fromBase64((n.update(r),n.digest("base64")))}}function createHmacVerifier(e){return function(r,t,n){var o=createHmacSigner(e)(r,n);return bufferEqualConstantTime(Buffer$4.from(t),Buffer$4.from(o))}}function createKeySigner(e){return function(r,t){checkIsPrivateKey(t),r=normalizeInput(r);var n=crypto.createSign("RSA-SHA"+e);return fromBase64((n.update(r),n.sign(t,"base64")))}}function createKeyVerifier(e){return function(r,t,n){checkIsPublicKey(n),r=normalizeInput(r),t=toBase64(t);var o=crypto.createVerify("RSA-SHA"+e);return o.update(r),o.verify(n,t,"base64")}}function createPSSKeySigner(e){return function(r,t){checkIsPrivateKey(t),r=normalizeInput(r);var n=crypto.createSign("RSA-SHA"+e);return fromBase64((n.update(r),n.sign({key:t,padding:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function createPSSKeyVerifier(e){return function(r,t,n){checkIsPublicKey(n),r=normalizeInput(r),t=toBase64(t);var o=crypto.createVerify("RSA-SHA"+e);return o.update(r),o.verify({key:n,padding:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST},t,"base64")}}function createECDSASigner(e){var r=createKeySigner(e);return function(){var t=r.apply(null,arguments);return t=ecdsaSigFormatter.derToJose(t,"ES"+e)}}function createECDSAVerifer(e){var r=createKeyVerifier(e);return function(t,n,o){return n=ecdsaSigFormatter.joseToDer(n,"ES"+e).toString("base64"),r(t,n,o)}}function createNoneSigner(){return function(){return""}}function createNoneVerifier(){return function(e,r){return""===r}}supportsKeyObjects&&(MSG_INVALID_VERIFIER_KEY+=" or a KeyObject",MSG_INVALID_SECRET+="or a KeyObject");var jwa=function(e){var r={hs:createHmacSigner,rs:createKeySigner,ps:createPSSKeySigner,es:createECDSASigner,none:createNoneSigner},t={hs:createHmacVerifier,rs:createKeyVerifier,ps:createPSSKeyVerifier,es:createECDSAVerifer,none:createNoneVerifier},n=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!n)throw typeError(MSG_INVALID_ALGORITHM,e);var o=(n[1]||n[3]).toLowerCase(),i=n[2];return{sign:r[o](i),verify:t[o](i)}},Buffer$5=buffer.Buffer,tostring=function(e){return"string"==typeof e?e:"number"==typeof e||Buffer$5.isBuffer(e)?e.toString():JSON.stringify(e)},Buffer$6=safeBuffer.Buffer;function base64url(e,r){return Buffer$6.from(e,r).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function jwsSecuredInput(e,r,t){t=t||"utf8";var n=base64url(tostring(e),"binary"),o=base64url(tostring(r),t);return util.format("%s.%s",n,o)}function jwsSign(e){var r=e.header,t=e.payload,n=e.secret||e.privateKey,o=e.encoding,i=jwa(r.alg),s=jwsSecuredInput(r,t,o),a=i.sign(s,n);return util.format("%s.%s",s,a)}function SignStream(e){var r=e.secret||e.privateKey||e.key,t=new dataStream(r);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=t,this.payload=new dataStream(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}util.inherits(SignStream,stream),SignStream.prototype.sign=function(){try{var e=jwsSign({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},SignStream.sign=jwsSign;var signStream=SignStream,Buffer$7=safeBuffer.Buffer,JWS_REGEX=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function isObject(e){return"[object Object]"===Object.prototype.toString.call(e)}function safeJsonParse(e){if(isObject(e))return e;try{return JSON.parse(e)}catch(e){return}}function headerFromJWS(e){var r=e.split(".",1)[0];return safeJsonParse(Buffer$7.from(r,"base64").toString("binary"))}function securedInputFromJWS(e){return e.split(".",2).join(".")}function signatureFromJWS(e){return e.split(".")[2]}function payloadFromJWS(e,r){r=r||"utf8";var t=e.split(".")[1];return Buffer$7.from(t,"base64").toString(r)}function isValidJws(e){return JWS_REGEX.test(e)&&!!headerFromJWS(e)}function jwsVerify(e,r,t){if(!r){var n=new Error("Missing algorithm parameter for jws.verify");throw n.code="MISSING_ALGORITHM",n}var o=signatureFromJWS(e=tostring(e)),i=securedInputFromJWS(e);return jwa(r).verify(i,o,t)}function jwsDecode(e,r){if(r=r||{},!isValidJws(e=tostring(e)))return null;var t=headerFromJWS(e);if(!t)return null;var n=payloadFromJWS(e);return("JWT"===t.typ||r.json)&&(n=JSON.parse(n,r.encoding)),{header:t,payload:n,signature:signatureFromJWS(e)}}function VerifyStream(e){var r=(e=e||{}).secret||e.publicKey||e.key,t=new dataStream(r);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=t,this.signature=new dataStream(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}util.inherits(VerifyStream,stream),VerifyStream.prototype.verify=function(){try{var e=jwsVerify(this.signature.buffer,this.algorithm,this.key.buffer),r=jwsDecode(this.signature.buffer,this.encoding);return this.emit("done",e,r),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},VerifyStream.decode=jwsDecode,VerifyStream.isValid=isValidJws,VerifyStream.verify=jwsVerify;var verifyStream=VerifyStream,ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],ALGORITHMS_1=ALGORITHMS,sign=signStream.sign,verify=verifyStream.verify,decode=verifyStream.decode,isValid=verifyStream.isValid,createSign=function(e){return new signStream(e)},createVerify=function(e){return new verifyStream(e)},jws={ALGORITHMS:ALGORITHMS_1,sign:sign,verify:verify,decode:decode,isValid:isValid,createSign:createSign,createVerify:createVerify},decode$1=function(e,r){r=r||{};var t=jws.decode(e,r);if(!t)return null;var n=t.payload;if("string"==typeof n)try{var o=JSON.parse(n);null!==o&&"object"==typeof o&&(n=o)}catch(e){}return!0===r.complete?{header:t.header,payload:n,signature:t.signature}:n},JsonWebTokenError=function(e,r){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,r&&(this.inner=r)};JsonWebTokenError.prototype=Object.create(Error.prototype),JsonWebTokenError.prototype.constructor=JsonWebTokenError;var JsonWebTokenError_1=JsonWebTokenError,NotBeforeError=function(e,r){JsonWebTokenError_1.call(this,e),this.name="NotBeforeError",this.date=r};NotBeforeError.prototype=Object.create(JsonWebTokenError_1.prototype),NotBeforeError.prototype.constructor=NotBeforeError;var NotBeforeError_1=NotBeforeError,TokenExpiredError=function(e,r){JsonWebTokenError_1.call(this,e),this.name="TokenExpiredError",this.expiredAt=r};TokenExpiredError.prototype=Object.create(JsonWebTokenError_1.prototype),TokenExpiredError.prototype.constructor=TokenExpiredError;var TokenExpiredError_1=TokenExpiredError,s=1e3,m=60*s,h=60*m,d=24*h,w=7*d,y=365.25*d,ms=function(e,r){r=r||{};var t=typeof e;if("string"===t&&e.length>0)return parse(e);if("number"===t&&isFinite(e))return r.long?fmtLong(e):fmtShort(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse(e){if(!((e=String(e)).length>100)){var r=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(r){var t=parseFloat(r[1]);switch((r[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return t*y;case"weeks":case"week":case"w":return t*w;case"days":case"day":case"d":return t*d;case"hours":case"hour":case"hrs":case"hr":case"h":return t*h;case"minutes":case"minute":case"mins":case"min":case"m":return t*m;case"seconds":case"second":case"secs":case"sec":case"s":return t*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function fmtShort(e){var r=Math.abs(e);return r>=d?Math.round(e/d)+"d":r>=h?Math.round(e/h)+"h":r>=m?Math.round(e/m)+"m":r>=s?Math.round(e/s)+"s":e+"ms"}function fmtLong(e){var r=Math.abs(e);return r>=d?plural(e,r,d,"day"):r>=h?plural(e,r,h,"hour"):r>=m?plural(e,r,m,"minute"):r>=s?plural(e,r,s,"second"):e+" ms"}function plural(e,r,t,n){var o=r>=1.5*t;return Math.round(e/t)+" "+n+(o?"s":"")}var timespan=function(e,r){var t=r||Math.floor(Date.now()/1e3);if("string"==typeof e){var n=ms(e);if(void 0===n)return;return Math.floor(t+n/1e3)}return"number"==typeof e?t+e:void 0},semver=createCommonjsModule((function(e,r){var t;r=e.exports=Y,t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},r.SEMVER_SPEC_VERSION="2.0.0";var n=Number.MAX_SAFE_INTEGER||9007199254740991,o=r.re=[],i=r.safeRe=[],s=r.src=[],a=0,u=[["\\s",1],["\\d",256],["[a-zA-Z0-9-]",250]];function c(e){for(var r=0;r<u.length;r++){var t=u[r][0],n=u[r][1];e=e.split(t+"*").join(t+"{0,"+n+"}").split(t+"+").join(t+"{1,"+n+"}")}return e}var f=a++;s[f]="0|[1-9]\\d*";var l=a++;s[l]="\\d+";var p=a++;s[p]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var m=a++;s[m]="("+s[f]+")\\.("+s[f]+")\\.("+s[f]+")";var h=a++;s[h]="("+s[l]+")\\.("+s[l]+")\\.("+s[l]+")";var d=a++;s[d]="(?:"+s[f]+"|"+s[p]+")";var v=a++;s[v]="(?:"+s[l]+"|"+s[p]+")";var g=a++;s[g]="(?:-("+s[d]+"(?:\\."+s[d]+")*))";var y=a++;s[y]="(?:-?("+s[v]+"(?:\\."+s[v]+")*))";var b=a++;s[b]="[a-zA-Z0-9-]+";var S=a++;s[S]="(?:\\+("+s[b]+"(?:\\."+s[b]+")*))";var E=a++,w="v?"+s[m]+s[g]+"?"+s[S]+"?";s[E]="^"+w+"$";var _="[v=\\s]*"+s[h]+s[y]+"?"+s[S]+"?",j=a++;s[j]="^"+_+"$";var T=a++;s[T]="((?:<|>)?=?)";var I=a++;s[I]=s[l]+"|x|X|\\*";var $=a++;s[$]=s[f]+"|x|X|\\*";var A=a++;s[A]="[v=\\s]*("+s[$]+")(?:\\.("+s[$]+")(?:\\.("+s[$]+")(?:"+s[g]+")?"+s[S]+"?)?)?";var N=a++;s[N]="[v=\\s]*("+s[I]+")(?:\\.("+s[I]+")(?:\\.("+s[I]+")(?:"+s[y]+")?"+s[S]+"?)?)?";var B=a++;s[B]="^"+s[T]+"\\s*"+s[A]+"$";var O=a++;s[O]="^"+s[T]+"\\s*"+s[N]+"$";var k=a++;s[k]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var P=a++;s[P]="(?:~>?)";var R=a++;s[R]="(\\s*)"+s[P]+"\\s+",o[R]=new RegExp(s[R],"g"),i[R]=new RegExp(c(s[R]),"g");var x=a++;s[x]="^"+s[P]+s[A]+"$";var V=a++;s[V]="^"+s[P]+s[N]+"$";var L=a++;s[L]="(?:\\^)";var D=a++;s[D]="(\\s*)"+s[L]+"\\s+",o[D]=new RegExp(s[D],"g"),i[D]=new RegExp(c(s[D]),"g");var G=a++;s[G]="^"+s[L]+s[A]+"$";var M=a++;s[M]="^"+s[L]+s[N]+"$";var J=a++;s[J]="^"+s[T]+"\\s*("+_+")$|^$";var F=a++;s[F]="^"+s[T]+"\\s*("+w+")$|^$";var K=a++;s[K]="(\\s*)"+s[T]+"\\s*("+_+"|"+s[A]+")",o[K]=new RegExp(s[K],"g"),i[K]=new RegExp(c(s[K]),"g");var C=a++;s[C]="^\\s*("+s[A]+")\\s+-\\s+("+s[A]+")\\s*$";var W=a++;s[W]="^\\s*("+s[N]+")\\s+-\\s+("+s[N]+")\\s*$";var H=a++;s[H]="(<|>)?=?\\s*\\*";for(var q=0;q<35;q++)t(q,s[q]),o[q]||(o[q]=new RegExp(s[q]),i[q]=new RegExp(c(s[q])));function U(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof Y)return e;if("string"!=typeof e)return null;if(e.length>256)return null;if(!(r.loose?i[j]:i[E]).test(e))return null;try{return new Y(e,r)}catch(e){return null}}function Y(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof Y){if(e.loose===r.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>256)throw new TypeError("version is longer than 256 characters");if(!(this instanceof Y))return new Y(e,r);t("SemVer",e,r),this.options=r,this.loose=!!r.loose;var o=e.trim().match(r.loose?i[j]:i[E]);if(!o)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+o[1],this.minor=+o[2],this.patch=+o[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");o[4]?this.prerelease=o[4].split(".").map((function(e){if(/^[0-9]+$/.test(e)){var r=+e;if(r>=0&&r<n)return r}return e})):this.prerelease=[],this.build=o[5]?o[5].split("."):[],this.format()}r.parse=U,r.valid=function(e,r){var t=U(e,r);return t?t.version:null},r.clean=function(e,r){var t=U(e.trim().replace(/^[=v]+/,""),r);return t?t.version:null},r.SemVer=Y,Y.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},Y.prototype.toString=function(){return this.version},Y.prototype.compare=function(e){return t("SemVer.compare",this.version,this.options,e),e instanceof Y||(e=new Y(e,this.options)),this.compareMain(e)||this.comparePre(e)},Y.prototype.compareMain=function(e){return e instanceof Y||(e=new Y(e,this.options)),z(this.major,e.major)||z(this.minor,e.minor)||z(this.patch,e.patch)},Y.prototype.comparePre=function(e){if(e instanceof Y||(e=new Y(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;var r=0;do{var n=this.prerelease[r],o=e.prerelease[r];if(t("prerelease compare",r,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return z(n,o)}while(++r)},Y.prototype.inc=function(e,r){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r),this.inc("pre",r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",r),this.inc("pre",r);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var t=this.prerelease.length;--t>=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},r.inc=function(e,r,t,n){"string"==typeof t&&(n=t,t=void 0);try{return new Y(e,t).inc(r,n).version}catch(e){return null}},r.diff=function(e,r){if(re(e,r))return null;var t=U(e),n=U(r),o="";if(t.prerelease.length||n.prerelease.length){o="pre";var i="prerelease"}for(var s in t)if(("major"===s||"minor"===s||"patch"===s)&&t[s]!==n[s])return o+s;return i},r.compareIdentifiers=z;var X=/^[0-9]+$/;function z(e,r){var t=X.test(e),n=X.test(r);return t&&n&&(e=+e,r=+r),e===r?0:t&&!n?-1:n&&!t?1:e<r?-1:1}function Z(e,r,t){return new Y(e,t).compare(new Y(r,t))}function Q(e,r,t){return Z(e,r,t)>0}function ee(e,r,t){return Z(e,r,t)<0}function re(e,r,t){return 0===Z(e,r,t)}function te(e,r,t){return 0!==Z(e,r,t)}function ne(e,r,t){return Z(e,r,t)>=0}function oe(e,r,t){return Z(e,r,t)<=0}function ie(e,r,t,n){switch(r){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),e===t;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),e!==t;case"":case"=":case"==":return re(e,t,n);case"!=":return te(e,t,n);case">":return Q(e,t,n);case">=":return ne(e,t,n);case"<":return ee(e,t,n);case"<=":return oe(e,t,n);default:throw new TypeError("Invalid operator: "+r)}}function se(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof se){if(e.loose===!!r.loose)return e;e=e.value}if(!(this instanceof se))return new se(e,r);e=e.trim().split(/\s+/).join(" "),t("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===ae?this.value="":this.value=this.operator+this.semver.version,t("comp",this)}r.rcompareIdentifiers=function(e,r){return z(r,e)},r.major=function(e,r){return new Y(e,r).major},r.minor=function(e,r){return new Y(e,r).minor},r.patch=function(e,r){return new Y(e,r).patch},r.compare=Z,r.compareLoose=function(e,r){return Z(e,r,!0)},r.rcompare=function(e,r,t){return Z(r,e,t)},r.sort=function(e,t){return e.sort((function(e,n){return r.compare(e,n,t)}))},r.rsort=function(e,t){return e.sort((function(e,n){return r.rcompare(e,n,t)}))},r.gt=Q,r.lt=ee,r.eq=re,r.neq=te,r.gte=ne,r.lte=oe,r.cmp=ie,r.Comparator=se;var ae={};function ue(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof ue)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new ue(e.raw,r);if(e instanceof se)return new ue(e.value,r);if(!(this instanceof ue))return new ue(e,r);if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map((function(e){return this.parseRange(e.trim())}),this).filter((function(e){return e.length})),!this.set.length)throw new TypeError("Invalid SemVer Range: "+this.raw);this.format()}function ce(e){return!e||"x"===e.toLowerCase()||"*"===e}function fe(e,r,t,n,o,i,s,a,u,c,f,l,p){return((r=ce(t)?"":ce(n)?">="+t+".0.0":ce(o)?">="+t+"."+n+".0":">="+r)+" "+(a=ce(u)?"":ce(c)?"<"+(+u+1)+".0.0":ce(f)?"<"+u+"."+(+c+1)+".0":l?"<="+u+"."+c+"."+f+"-"+l:"<="+a)).trim()}function le(e,r,n){for(var o=0;o<e.length;o++)if(!e[o].test(r))return!1;if(r.prerelease.length&&!n.includePrerelease){for(o=0;o<e.length;o++)if(t(e[o].semver),e[o].semver!==ae&&e[o].semver.prerelease.length>0){var i=e[o].semver;if(i.major===r.major&&i.minor===r.minor&&i.patch===r.patch)return!0}return!1}return!0}function pe(e,r,t){try{r=new ue(r,t)}catch(e){return!1}return r.test(e)}function me(e,r,t,n){var o,i,s,a,u;switch(e=new Y(e,n),r=new ue(r,n),t){case">":o=Q,i=oe,s=ee,a=">",u=">=";break;case"<":o=ee,i=ne,s=Q,a="<",u="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(pe(e,r,n))return!1;for(var c=0;c<r.set.length;++c){var f=r.set[c],l=null,p=null;if(f.forEach((function(e){e.semver===ae&&(e=new se(">=0.0.0")),l=l||e,p=p||e,o(e.semver,l.semver,n)?l=e:s(e.semver,p.semver,n)&&(p=e)})),l.operator===a||l.operator===u)return!1;if((!p.operator||p.operator===a)&&i(e,p.semver))return!1;if(p.operator===u&&s(e,p.semver))return!1}return!0}se.prototype.parse=function(e){var r=this.options.loose?i[J]:i[F],t=e.match(r);if(!t)throw new TypeError("Invalid comparator: "+e);this.operator=t[1],"="===this.operator&&(this.operator=""),t[2]?this.semver=new Y(t[2],this.options.loose):this.semver=ae},se.prototype.toString=function(){return this.value},se.prototype.test=function(e){return t("Comparator.test",e,this.options.loose),this.semver===ae||("string"==typeof e&&(e=new Y(e,this.options)),ie(e,this.operator,this.semver,this.options))},se.prototype.intersects=function(e,r){if(!(e instanceof se))throw new TypeError("a Comparator is required");var t;if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),""===this.operator)return t=new ue(e.value,r),pe(this.value,t,r);if(""===e.operator)return t=new ue(this.value,r),pe(e.semver,t,r);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),o=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),i=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=ie(this.semver,"<",e.semver,r)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),u=ie(this.semver,">",e.semver,r)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||o||i&&s||a||u},r.Range=ue,ue.prototype.format=function(){return this.range=this.set.map((function(e){return e.join(" ").trim()})).join("||").trim(),this.range},ue.prototype.toString=function(){return this.range},ue.prototype.parseRange=function(e){var r=this.options.loose,n=r?i[W]:i[C];e=e.replace(n,fe),t("hyphen replace",e),e=e.replace(i[K],"$1$2$3"),t("comparator trim",e,i[K]),e=(e=e.replace(i[R],"$1~")).replace(i[D],"$1^");var o=r?i[J]:i[F],s=e.split(" ").map((function(e){return function(e,r){return t("comp",e,r),e=function(e,r){return e.trim().split(/\s+/).map((function(e){return function(e,r){t("caret",e,r);var n=r.loose?i[M]:i[G];return e.replace(n,(function(r,n,o,i,s){var a;return t("caret",e,r,n,o,i,s),ce(n)?a="":ce(o)?a=">="+n+".0.0 <"+(+n+1)+".0.0":ce(i)?a="0"===n?">="+n+"."+o+".0 <"+n+"."+(+o+1)+".0":">="+n+"."+o+".0 <"+(+n+1)+".0.0":s?(t("replaceCaret pr",s),a="0"===n?"0"===o?">="+n+"."+o+"."+i+"-"+s+" <"+n+"."+o+"."+(+i+1):">="+n+"."+o+"."+i+"-"+s+" <"+n+"."+(+o+1)+".0":">="+n+"."+o+"."+i+"-"+s+" <"+(+n+1)+".0.0"):(t("no pr"),a="0"===n?"0"===o?">="+n+"."+o+"."+i+" <"+n+"."+o+"."+(+i+1):">="+n+"."+o+"."+i+" <"+n+"."+(+o+1)+".0":">="+n+"."+o+"."+i+" <"+(+n+1)+".0.0"),t("caret return",a),a}))}(e,r)})).join(" ")}(e,r),t("caret",e),e=function(e,r){return e.trim().split(/\s+/).map((function(e){return function(e,r){var n=r.loose?i[V]:i[x];return e.replace(n,(function(r,n,o,i,s){var a;return t("tilde",e,r,n,o,i,s),ce(n)?a="":ce(o)?a=">="+n+".0.0 <"+(+n+1)+".0.0":ce(i)?a=">="+n+"."+o+".0 <"+n+"."+(+o+1)+".0":s?(t("replaceTilde pr",s),a=">="+n+"."+o+"."+i+"-"+s+" <"+n+"."+(+o+1)+".0"):a=">="+n+"."+o+"."+i+" <"+n+"."+(+o+1)+".0",t("tilde return",a),a}))}(e,r)})).join(" ")}(e,r),t("tildes",e),e=function(e,r){return t("replaceXRanges",e,r),e.split(/\s+/).map((function(e){return function(e,r){e=e.trim();var n=r.loose?i[O]:i[B];return e.replace(n,(function(r,n,o,i,s,a){t("xRange",e,r,n,o,i,s,a);var u=ce(o),c=u||ce(i),f=c||ce(s);return"="===n&&f&&(n=""),u?r=">"===n||"<"===n?"<0.0.0":"*":n&&f?(c&&(i=0),s=0,">"===n?(n=">=",c?(o=+o+1,i=0,s=0):(i=+i+1,s=0)):"<="===n&&(n="<",c?o=+o+1:i=+i+1),r=n+o+"."+i+"."+s):c?r=">="+o+".0.0 <"+(+o+1)+".0.0":f&&(r=">="+o+"."+i+".0 <"+o+"."+(+i+1)+".0"),t("xRange return",r),r}))}(e,r)})).join(" ")}(e,r),t("xrange",e),e=function(e,r){return t("replaceStars",e,r),e.trim().replace(i[H],"")}(e,r),t("stars",e),e}(e,this.options)}),this).join(" ").split(/\s+/);return this.options.loose&&(s=s.filter((function(e){return!!e.match(o)}))),s=s.map((function(e){return new se(e,this.options)}),this)},ue.prototype.intersects=function(e,r){if(!(e instanceof ue))throw new TypeError("a Range is required");return this.set.some((function(t){return t.every((function(t){return e.set.some((function(e){return e.every((function(e){return t.intersects(e,r)}))}))}))}))},r.toComparators=function(e,r){return new ue(e,r).set.map((function(e){return e.map((function(e){return e.value})).join(" ").trim().split(" ")}))},ue.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new Y(e,this.options));for(var r=0;r<this.set.length;r++)if(le(this.set[r],e,this.options))return!0;return!1},r.satisfies=pe,r.maxSatisfying=function(e,r,t){var n=null,o=null;try{var i=new ue(r,t)}catch(e){return null}return e.forEach((function(e){i.test(e)&&(n&&-1!==o.compare(e)||(o=new Y(n=e,t)))})),n},r.minSatisfying=function(e,r,t){var n=null,o=null;try{var i=new ue(r,t)}catch(e){return null}return e.forEach((function(e){i.test(e)&&(n&&1!==o.compare(e)||(o=new Y(n=e,t)))})),n},r.minVersion=function(e,r){e=new ue(e,r);var t=new Y("0.0.0");if(e.test(t))return t;if(t=new Y("0.0.0-0"),e.test(t))return t;t=null;for(var n=0;n<e.set.length;++n){e.set[n].forEach((function(e){var r=new Y(e.semver.version);switch(e.operator){case">":0===r.prerelease.length?r.patch++:r.prerelease.push(0),r.raw=r.format();case"":case">=":t&&!Q(t,r)||(t=r);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+e.operator)}}))}if(t&&e.test(t))return t;return null},r.validRange=function(e,r){try{return new ue(e,r).range||"*"}catch(e){return null}},r.ltr=function(e,r,t){return me(e,r,"<",t)},r.gtr=function(e,r,t){return me(e,r,">",t)},r.outside=me,r.prerelease=function(e,r){var t=U(e,r);return t&&t.prerelease.length?t.prerelease:null},r.intersects=function(e,r,t){return e=new ue(e,t),r=new ue(r,t),e.intersects(r)},r.coerce=function(e){if(e instanceof Y)return e;if("string"!=typeof e)return null;var r=e.match(i[k]);if(null==r)return null;return U(r[1]+"."+(r[2]||"0")+"."+(r[3]||"0"))}})),semver_1=semver.SEMVER_SPEC_VERSION,semver_2=semver.re,semver_3=semver.safeRe,semver_4=semver.src,semver_5=semver.parse,semver_6=semver.valid,semver_7=semver.clean,semver_8=semver.SemVer,semver_9=semver.inc,semver_10=semver.diff,semver_11=semver.compareIdentifiers,semver_12=semver.rcompareIdentifiers,semver_13=semver.major,semver_14=semver.minor,semver_15=semver.patch,semver_16=semver.compare,semver_17=semver.compareLoose,semver_18=semver.rcompare,semver_19=semver.sort,semver_20=semver.rsort,semver_21=semver.gt,semver_22=semver.lt,semver_23=semver.eq,semver_24=semver.neq,semver_25=semver.gte,semver_26=semver.lte,semver_27=semver.cmp,semver_28=semver.Comparator,semver_29=semver.Range,semver_30=semver.toComparators,semver_31=semver.satisfies,semver_32=semver.maxSatisfying,semver_33=semver.minSatisfying,semver_34=semver.minVersion,semver_35=semver.validRange,semver_36=semver.ltr,semver_37=semver.gtr,semver_38=semver.outside,semver_39=semver.prerelease,semver_40=semver.intersects,semver_41=semver.coerce,psSupported=semver.satisfies(process.version,"^6.12.0 || >=8.0.0"),PUB_KEY_ALGS=["RS256","RS384","RS512","ES256","ES384","ES512"],RSA_KEY_ALGS=["RS256","RS384","RS512"],HS_ALGS=["HS256","HS384","HS512"];psSupported&&(PUB_KEY_ALGS.splice(3,0,"PS256","PS384","PS512"),RSA_KEY_ALGS.splice(3,0,"PS256","PS384","PS512"));var verify$1=function(e,r,t,n){var o;if("function"!=typeof t||n||(n=t,t={}),t||(t={}),t=Object.assign({},t),o=n||function(e,r){if(e)throw e;return r},t.clockTimestamp&&"number"!=typeof t.clockTimestamp)return o(new JsonWebTokenError_1("clockTimestamp must be a number"));if(void 0!==t.nonce&&("string"!=typeof t.nonce||""===t.nonce.trim()))return o(new JsonWebTokenError_1("nonce must be a non-empty string"));var i=t.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return o(new JsonWebTokenError_1("jwt must be provided"));if("string"!=typeof e)return o(new JsonWebTokenError_1("jwt must be a string"));var s,a=e.split(".");if(3!==a.length)return o(new JsonWebTokenError_1("jwt malformed"));try{s=decode$1(e,{complete:!0})}catch(e){return o(e)}if(!s)return o(new JsonWebTokenError_1("invalid token"));var u,c=s.header;if("function"==typeof r){if(!n)return o(new JsonWebTokenError_1("verify must be called asynchronous if secret or public key is provided as a callback"));u=r}else u=function(e,t){return t(null,r)};return u(c,(function(r,n){if(r)return o(new JsonWebTokenError_1("error in secret or public key callback: "+r.message));var u,f=""!==a[2].trim();if(!f&&n)return o(new JsonWebTokenError_1("jwt signature is required"));if(f&&!n)return o(new JsonWebTokenError_1("secret or public key must be provided"));if(f||t.algorithms||(t.algorithms=["none"]),t.algorithms||(t.algorithms=~n.toString().indexOf("BEGIN CERTIFICATE")||~n.toString().indexOf("BEGIN PUBLIC KEY")?PUB_KEY_ALGS:~n.toString().indexOf("BEGIN RSA PUBLIC KEY")?RSA_KEY_ALGS:HS_ALGS),!~t.algorithms.indexOf(s.header.alg))return o(new JsonWebTokenError_1("invalid algorithm"));try{u=jws.verify(e,s.header.alg,n)}catch(e){return o(e)}if(!u)return o(new JsonWebTokenError_1("invalid signature"));var l=s.payload;if(void 0!==l.nbf&&!t.ignoreNotBefore){if("number"!=typeof l.nbf)return o(new JsonWebTokenError_1("invalid nbf value"));if(l.nbf>i+(t.clockTolerance||0))return o(new NotBeforeError_1("jwt not active",new Date(1e3*l.nbf)))}if(void 0!==l.exp&&!t.ignoreExpiration){if("number"!=typeof l.exp)return o(new JsonWebTokenError_1("invalid exp value"));if(i>=l.exp+(t.clockTolerance||0))return o(new TokenExpiredError_1("jwt expired",new Date(1e3*l.exp)))}if(t.audience){var p=Array.isArray(t.audience)?t.audience:[t.audience];if(!(Array.isArray(l.aud)?l.aud:[l.aud]).some((function(e){return p.some((function(r){return r instanceof RegExp?r.test(e):r===e}))})))return o(new JsonWebTokenError_1("jwt audience invalid. expected: "+p.join(" or ")))}if(t.issuer&&("string"==typeof t.issuer&&l.iss!==t.issuer||Array.isArray(t.issuer)&&-1===t.issuer.indexOf(l.iss)))return o(new JsonWebTokenError_1("jwt issuer invalid. expected: "+t.issuer));if(t.subject&&l.sub!==t.subject)return o(new JsonWebTokenError_1("jwt subject invalid. expected: "+t.subject));if(t.jwtid&&l.jti!==t.jwtid)return o(new JsonWebTokenError_1("jwt jwtid invalid. expected: "+t.jwtid));if(t.nonce&&l.nonce!==t.nonce)return o(new JsonWebTokenError_1("jwt nonce invalid. expected: "+t.nonce));if(t.maxAge){if("number"!=typeof l.iat)return o(new JsonWebTokenError_1("iat required when maxAge is specified"));var m=timespan(t.maxAge,l.iat);if(void 0===m)return o(new JsonWebTokenError_1('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(i>=m+(t.clockTolerance||0))return o(new TokenExpiredError_1("maxAge exceeded",new Date(1e3*m)))}if(!0===t.complete){var h=s.signature;return o(null,{header:c,payload:l,signature:h})}return o(null,l)}))},INFINITY=1/0,MAX_SAFE_INTEGER=9007199254740991,MAX_INTEGER=17976931348623157e292,NAN=NaN,argsTag="[object Arguments]",funcTag="[object Function]",genTag="[object GeneratorFunction]",stringTag="[object String]",symbolTag="[object Symbol]",reTrim=/^\s+|\s+$/g,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,reIsUint=/^(?:0|[1-9]\d*)$/,freeParseInt=parseInt;function arrayMap(e,r){for(var t=-1,n=e?e.length:0,o=Array(n);++t<n;)o[t]=r(e[t],t,e);return o}function baseFindIndex(e,r,t,n){for(var o=e.length,i=t+(n?1:-1);n?i--:++i<o;)if(r(e[i],i,e))return i;return-1}function baseIndexOf(e,r,t){if(r!=r)return baseFindIndex(e,baseIsNaN,t);for(var n=t-1,o=e.length;++n<o;)if(e[n]===r)return n;return-1}function baseIsNaN(e){return e!=e}function baseTimes(e,r){for(var t=-1,n=Array(e);++t<e;)n[t]=r(t);return n}function baseValues(e,r){return arrayMap(r,(function(r){return e[r]}))}function overArg(e,r){return function(t){return e(r(t))}}var objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,objectToString=objectProto.toString,propertyIsEnumerable=objectProto.propertyIsEnumerable,nativeKeys=overArg(Object.keys,Object),nativeMax=Math.max;function arrayLikeKeys(e,r){var t=isArray(e)||isArguments(e)?baseTimes(e.length,String):[],n=t.length,o=!!n;for(var i in e)!r&&!hasOwnProperty.call(e,i)||o&&("length"==i||isIndex(i,n))||t.push(i);return t}function baseKeys(e){if(!isPrototype(e))return nativeKeys(e);var r=[];for(var t in Object(e))hasOwnProperty.call(e,t)&&"constructor"!=t&&r.push(t);return r}function isIndex(e,r){return!!(r=null==r?MAX_SAFE_INTEGER:r)&&("number"==typeof e||reIsUint.test(e))&&e>-1&&e%1==0&&e<r}function isPrototype(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||objectProto)}function includes(e,r,t,n){e=isArrayLike(e)?e:values(e),t=t&&!n?toInteger(t):0;var o=e.length;return t<0&&(t=nativeMax(o+t,0)),isString(e)?t<=o&&e.indexOf(r,t)>-1:!!o&&baseIndexOf(e,r,t)>-1}function isArguments(e){return isArrayLikeObject(e)&&hasOwnProperty.call(e,"callee")&&(!propertyIsEnumerable.call(e,"callee")||objectToString.call(e)==argsTag)}var isArray=Array.isArray;function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function isFunction(e){var r=isObject$1(e)?objectToString.call(e):"";return r==funcTag||r==genTag}function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isObject$1(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}function isObjectLike(e){return!!e&&"object"==typeof e}function isString(e){return"string"==typeof e||!isArray(e)&&isObjectLike(e)&&objectToString.call(e)==stringTag}function isSymbol(e){return"symbol"==typeof e||isObjectLike(e)&&objectToString.call(e)==symbolTag}function toFinite(e){return e?(e=toNumber(e))===INFINITY||e===-INFINITY?(e<0?-1:1)*MAX_INTEGER:e==e?e:0:0===e?e:0}function toInteger(e){var r=toFinite(e),t=r%1;return r==r?t?r-t:r:0}function toNumber(e){if("number"==typeof e)return e;if(isSymbol(e))return NAN;if(isObject$1(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=isObject$1(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(reTrim,"");var t=reIsBinary.test(e);return t||reIsOctal.test(e)?freeParseInt(e.slice(2),t?2:8):reIsBadHex.test(e)?NAN:+e}function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}function values(e){return e?baseValues(e,keys(e)):[]}var lodash_includes=includes,boolTag="[object Boolean]",objectProto$1=Object.prototype,objectToString$1=objectProto$1.toString;function isBoolean(e){return!0===e||!1===e||isObjectLike$1(e)&&objectToString$1.call(e)==boolTag}function isObjectLike$1(e){return!!e&&"object"==typeof e}var lodash_isboolean=isBoolean,INFINITY$1=1/0,MAX_INTEGER$1=17976931348623157e292,NAN$1=NaN,symbolTag$1="[object Symbol]",reTrim$1=/^\s+|\s+$/g,reIsBadHex$1=/^[-+]0x[0-9a-f]+$/i,reIsBinary$1=/^0b[01]+$/i,reIsOctal$1=/^0o[0-7]+$/i,freeParseInt$1=parseInt,objectProto$2=Object.prototype,objectToString$2=objectProto$2.toString;function isInteger(e){return"number"==typeof e&&e==toInteger$1(e)}function isObject$2(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}function isObjectLike$2(e){return!!e&&"object"==typeof e}function isSymbol$1(e){return"symbol"==typeof e||isObjectLike$2(e)&&objectToString$2.call(e)==symbolTag$1}function toFinite$1(e){return e?(e=toNumber$1(e))===INFINITY$1||e===-INFINITY$1?(e<0?-1:1)*MAX_INTEGER$1:e==e?e:0:0===e?e:0}function toInteger$1(e){var r=toFinite$1(e),t=r%1;return r==r?t?r-t:r:0}function toNumber$1(e){if("number"==typeof e)return e;if(isSymbol$1(e))return NAN$1;if(isObject$2(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=isObject$2(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(reTrim$1,"");var t=reIsBinary$1.test(e);return t||reIsOctal$1.test(e)?freeParseInt$1(e.slice(2),t?2:8):reIsBadHex$1.test(e)?NAN$1:+e}var lodash_isinteger=isInteger,numberTag="[object Number]",objectProto$3=Object.prototype,objectToString$3=objectProto$3.toString;function isObjectLike$3(e){return!!e&&"object"==typeof e}function isNumber(e){return"number"==typeof e||isObjectLike$3(e)&&objectToString$3.call(e)==numberTag}var lodash_isnumber=isNumber,objectTag="[object Object]";function isHostObject(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}function overArg$1(e,r){return function(t){return e(r(t))}}var funcProto=Function.prototype,objectProto$4=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$1=objectProto$4.hasOwnProperty,objectCtorString=funcToString.call(Object),objectToString$4=objectProto$4.toString,getPrototype=overArg$1(Object.getPrototypeOf,Object);function isObjectLike$4(e){return!!e&&"object"==typeof e}function isPlainObject(e){if(!isObjectLike$4(e)||objectToString$4.call(e)!=objectTag||isHostObject(e))return!1;var r=getPrototype(e);if(null===r)return!0;var t=hasOwnProperty$1.call(r,"constructor")&&r.constructor;return"function"==typeof t&&t instanceof t&&funcToString.call(t)==objectCtorString}var lodash_isplainobject=isPlainObject,stringTag$1="[object String]",objectProto$5=Object.prototype,objectToString$5=objectProto$5.toString,isArray$1=Array.isArray;function isObjectLike$5(e){return!!e&&"object"==typeof e}function isString$1(e){return"string"==typeof e||!isArray$1(e)&&isObjectLike$5(e)&&objectToString$5.call(e)==stringTag$1}var lodash_isstring=isString$1,FUNC_ERROR_TEXT="Expected a function",INFINITY$2=1/0,MAX_INTEGER$2=17976931348623157e292,NAN$2=NaN,symbolTag$2="[object Symbol]",reTrim$2=/^\s+|\s+$/g,reIsBadHex$2=/^[-+]0x[0-9a-f]+$/i,reIsBinary$2=/^0b[01]+$/i,reIsOctal$2=/^0o[0-7]+$/i,freeParseInt$2=parseInt,objectProto$6=Object.prototype,objectToString$6=objectProto$6.toString;function before(e,r){var t;if("function"!=typeof r)throw new TypeError(FUNC_ERROR_TEXT);return e=toInteger$2(e),function(){return--e>0&&(t=r.apply(this,arguments)),e<=1&&(r=void 0),t}}function once(e){return before(2,e)}function isObject$3(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}function isObjectLike$6(e){return!!e&&"object"==typeof e}function isSymbol$2(e){return"symbol"==typeof e||isObjectLike$6(e)&&objectToString$6.call(e)==symbolTag$2}function toFinite$2(e){return e?(e=toNumber$2(e))===INFINITY$2||e===-INFINITY$2?(e<0?-1:1)*MAX_INTEGER$2:e==e?e:0:0===e?e:0}function toInteger$2(e){var r=toFinite$2(e),t=r%1;return r==r?t?r-t:r:0}function toNumber$2(e){if("number"==typeof e)return e;if(isSymbol$2(e))return NAN$2;if(isObject$3(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=isObject$3(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(reTrim$2,"");var t=reIsBinary$2.test(e);return t||reIsOctal$2.test(e)?freeParseInt$2(e.slice(2),t?2:8):reIsBadHex$2.test(e)?NAN$2:+e}var lodash_once=once,SUPPORTED_ALGS=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];psSupported&&SUPPORTED_ALGS.splice(3,0,"PS256","PS384","PS512");var sign_options_schema={expiresIn:{isValid:function(e){return lodash_isinteger(e)||lodash_isstring(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return lodash_isinteger(e)||lodash_isstring(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return lodash_isstring(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:lodash_includes.bind(null,SUPPORTED_ALGS),message:'"algorithm" must be a valid string enum value'},header:{isValid:lodash_isplainobject,message:'"header" must be an object'},encoding:{isValid:lodash_isstring,message:'"encoding" must be a string'},issuer:{isValid:lodash_isstring,message:'"issuer" must be a string'},subject:{isValid:lodash_isstring,message:'"subject" must be a string'},jwtid:{isValid:lodash_isstring,message:'"jwtid" must be a string'},noTimestamp:{isValid:lodash_isboolean,message:'"noTimestamp" must be a boolean'},keyid:{isValid:lodash_isstring,message:'"keyid" must be a string'},mutatePayload:{isValid:lodash_isboolean,message:'"mutatePayload" must be a boolean'}},registered_claims_schema={iat:{isValid:lodash_isnumber,message:'"iat" should be a number of seconds'},exp:{isValid:lodash_isnumber,message:'"exp" should be a number of seconds'},nbf:{isValid:lodash_isnumber,message:'"nbf" should be a number of seconds'}};function validate(e,r,t,n){if(!lodash_isplainobject(t))throw new Error('Expected "'+n+'" to be a plain object.');Object.keys(t).forEach((function(o){var i=e[o];if(i){if(!i.isValid(t[o]))throw new Error(i.message)}else if(!r)throw new Error('"'+o+'" is not allowed in "'+n+'"')}))}function validateOptions(e){return validate(sign_options_schema,!1,e,"options")}function validatePayload(e){return validate(registered_claims_schema,!0,e,"payload")}var options_to_payload={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},options_for_objects=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"],sign$1=function(e,r,t,n){"function"==typeof t?(n=t,t={}):t=t||{};var o="object"==typeof e&&!Buffer.isBuffer(e),i=Object.assign({alg:t.algorithm||"HS256",typ:o?"JWT":void 0,kid:t.keyid},t.header);function s(e){if(n)return n(e);throw e}if(!r&&"none"!==t.algorithm)return s(new Error("secretOrPrivateKey must have a value"));if(void 0===e)return s(new Error("payload is required"));if(o){try{validatePayload(e)}catch(e){return s(e)}t.mutatePayload||(e=Object.assign({},e))}else{var a=options_for_objects.filter((function(e){return void 0!==t[e]}));if(a.length>0)return s(new Error("invalid "+a.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==t.expiresIn)return s(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==t.notBefore)return s(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{validateOptions(t)}catch(e){return s(e)}var u=e.iat||Math.floor(Date.now()/1e3);if(t.noTimestamp?delete e.iat:o&&(e.iat=u),void 0!==t.notBefore){try{e.nbf=timespan(t.notBefore,u)}catch(e){return s(e)}if(void 0===e.nbf)return s(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==t.expiresIn&&"object"==typeof e){try{e.exp=timespan(t.expiresIn,u)}catch(e){return s(e)}if(void 0===e.exp)return s(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(options_to_payload).forEach((function(r){var n=options_to_payload[r];if(void 0!==t[r]){if(void 0!==e[n])return s(new Error('Bad "options.'+r+'" option. The payload already has an "'+n+'" property.'));e[n]=t[r]}}));var c=t.encoding||"utf8";if("function"!=typeof n)return jws.sign({header:i,payload:e,secret:r,encoding:c});n=n&&lodash_once(n),jws.createSign({header:i,privateKey:r,payload:e,encoding:c}).once("error",n).once("done",(function(e){n(null,e)}))},jsonwebtoken={decode:decode$1,verify:verify$1,sign:sign$1,JsonWebTokenError:JsonWebTokenError_1,NotBeforeError:NotBeforeError_1,TokenExpiredError:TokenExpiredError_1},src=jsonwebtoken;module.exports=src;