@ymys/directus-extension-sso 2.4.19 → 2.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"module";import r from"node:crypto";import t from"buffer";import n from"stream";import i from"util";import o from"crypto";function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,u,c,l,f,p,h,d,m,E,y,g,v,w,S,b,$,I,R,O,A,L,T,N,j,k,P,_,C,x,D={},M={exports:{}};function B(){return a||(a=1,function(e,r){var n=t,i=n.Buffer;function o(e,r){for(var t in e)r[t]=e[t]}function s(e,r,t){return i(e,r,t)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,r),r.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,r,t){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,r,t)},s.alloc=function(e,r,t){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==r?"string"==typeof t?n.fill(r,t):n.fill(r):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}}(M,M.exports)),M.exports}function K(){if(c)return u;c=1;var e=B().Buffer,r=n;function t(r){if(this.buffer=null,this.writable=!0,this.readable=!0,!r)return this.buffer=e.alloc(0),this;if("function"==typeof r.pipe)return this.buffer=e.alloc(0),r.pipe(this),this;if(r.length||"object"==typeof r)return this.buffer=r,this.writable=!1,process.nextTick(function(){this.emit("end",r),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof r+")")}return i.inherits(t,r),t.prototype.write=function(r){this.buffer=e.concat([this.buffer,e.from(r)]),this.emit("data",r)},t.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},u=t}function F(){if(h)return p;h=1;var e=B().Buffer,r=function(){if(f)return l;function e(e){return(e/8|0)+(e%8==0?0:1)}f=1;var r={ES256:e(256),ES384:e(384),ES512:e(521)};return l=function(e){var t=r[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}}(),t=128;function n(r){if(e.isBuffer(r))return r;if("string"==typeof r)return e.from(r,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function i(e,r,n){for(var i=0;r+i<n&&0===e[r+i];)++i;return e[r+i]>=t&&--i,i}return p={derToJose:function(t,i){t=n(t);var o=r(i),s=o+1,a=t.length,u=0;if(48!==t[u++])throw new Error('Could not find expected "seq"');var c=t[u++];if(129===c&&(c=t[u++]),a-u<c)throw new Error('"seq" specified length of "'+c+'", only "'+(a-u)+'" remaining');if(2!==t[u++])throw new Error('Could not find expected "int" for "r"');var l=t[u++];if(a-u-2<l)throw new Error('"r" specified length of "'+l+'", only "'+(a-u-2)+'" available');if(s<l)throw new Error('"r" specified length of "'+l+'", max of "'+s+'" is acceptable');var f=u;if(u+=l,2!==t[u++])throw new Error('Could not find expected "int" for "s"');var p=t[u++];if(a-u!==p)throw new Error('"s" specified length of "'+p+'", expected "'+(a-u)+'"');if(s<p)throw new Error('"s" specified length of "'+p+'", max of "'+s+'" is acceptable');var h=u;if((u+=p)!==a)throw new Error('Expected to consume entire buffer, but "'+(a-u)+'" bytes remain');var d=o-l,m=o-p,E=e.allocUnsafe(d+l+m+p);for(u=0;u<d;++u)E[u]=0;t.copy(E,u,f+Math.max(-d,0),f+l);for(var y=u=o;u<y+m;++u)E[u]=0;return t.copy(E,u,h+Math.max(-m,0),h+p),E=(E=E.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(o,s){o=n(o);var a=r(s),u=o.length;if(u!==2*a)throw new TypeError('"'+s+'" signatures must be "'+2*a+'" bytes, saw "'+u+'"');var c=i(o,0,a),l=i(o,a,o.length),f=a-c,p=a-l,h=2+f+1+1+p,d=h<t,m=e.allocUnsafe((d?2:3)+h),E=0;return m[E++]=48,d?m[E++]=h:(m[E++]=129,m[E++]=255&h),m[E++]=2,m[E++]=f,c<0?(m[E++]=0,E+=o.copy(m,E,0,a)):E+=o.copy(m,E,c,a),m[E++]=2,m[E++]=p,l<0?(m[E++]=0,o.copy(m,E,a)):o.copy(m,E,a+l),m}}}function G(){if(y)return E;y=1;var e,r=B().Buffer,n=o,s=F(),a=i,u="secret must be a string or buffer",c="key must be a string or a buffer",l="function"==typeof n.createPublicKey;function f(e){if(!r.isBuffer(e)&&"string"!=typeof e){if(!l)throw v(c);if("object"!=typeof e)throw v(c);if("string"!=typeof e.type)throw v(c);if("string"!=typeof e.asymmetricKeyType)throw v(c);if("function"!=typeof e.export)throw v(c)}}function p(e){if(!r.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw v("key must be a string, a buffer or an object")}function h(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function g(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 v(e){var r=[].slice.call(arguments,1),t=a.format.bind(a,e).apply(null,r);return new TypeError(t)}function w(e){var t;return t=e,r.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function S(e){return function(t,i){!function(e){if(!r.isBuffer(e)){if("string"==typeof e)return e;if(!l)throw v(u);if("object"!=typeof e)throw v(u);if("secret"!==e.type)throw v(u);if("function"!=typeof e.export)throw v(u)}}(i),t=w(t);var o=n.createHmac("sha"+e,i);return h((o.update(t),o.digest("base64")))}}l&&(c+=" or a KeyObject",u+="or a KeyObject");var b="timingSafeEqual"in n?function(e,r){return e.byteLength===r.byteLength&&n.timingSafeEqual(e,r)}:function(r,n){return e||(e=function(){if(m)return d;m=1;var e=t.Buffer,r=t.SlowBuffer;function n(r,t){if(!e.isBuffer(r)||!e.isBuffer(t))return!1;if(r.length!==t.length)return!1;for(var n=0,i=0;i<r.length;i++)n|=r[i]^t[i];return 0===n}d=n,n.install=function(){e.prototype.equal=r.prototype.equal=function(e){return n(this,e)}};var i=e.prototype.equal,o=r.prototype.equal;return n.restore=function(){e.prototype.equal=i,r.prototype.equal=o},d}()),e(r,n)};function $(e){return function(t,n,i){var o=S(e)(t,i);return b(r.from(n),r.from(o))}}function I(e){return function(r,t){p(t),r=w(r);var i=n.createSign("RSA-SHA"+e);return h((i.update(r),i.sign(t,"base64")))}}function R(e){return function(r,t,i){f(i),r=w(r),t=g(t);var o=n.createVerify("RSA-SHA"+e);return o.update(r),o.verify(i,t,"base64")}}function O(e){return function(r,t){p(t),r=w(r);var i=n.createSign("RSA-SHA"+e);return h((i.update(r),i.sign({key:t,padding:n.constants.RSA_PKCS1_PSS_PADDING,saltLength:n.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function A(e){return function(r,t,i){f(i),r=w(r),t=g(t);var o=n.createVerify("RSA-SHA"+e);return o.update(r),o.verify({key:i,padding:n.constants.RSA_PKCS1_PSS_PADDING,saltLength:n.constants.RSA_PSS_SALTLEN_DIGEST},t,"base64")}}function L(e){var r=I(e);return function(){var t=r.apply(null,arguments);return t=s.derToJose(t,"ES"+e)}}function T(e){var r=R(e);return function(t,n,i){return n=s.joseToDer(n,"ES"+e).toString("base64"),r(t,n,i)}}function N(){return function(){return""}}function j(){return function(e,r){return""===r}}return E=function(e){var r={hs:S,rs:I,ps:O,es:L,none:N},t={hs:$,rs:R,ps:A,es:T,none:j},n=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!n)throw v('"%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".',e);var i=(n[1]||n[3]).toLowerCase(),o=n[2];return{sign:r[i](o),verify:t[i](o)}}}function U(){if(v)return g;v=1;var e=t.Buffer;return g=function(r){return"string"==typeof r?r:"number"==typeof r||e.isBuffer(r)?r.toString():JSON.stringify(r)}}function q(){if(S)return w;S=1;var e=B().Buffer,r=K(),t=G(),o=n,s=U(),a=i;function u(r,t){return e.from(r,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(e){var r=e.header,n=e.payload,i=e.secret||e.privateKey,o=e.encoding,c=t(r.alg),l=function(e,r,t){t=t||"utf8";var n=u(s(e),"binary"),i=u(s(r),t);return a.format("%s.%s",n,i)}(r,n,o),f=c.sign(l,i);return a.format("%s.%s",l,f)}function l(e){var t=e.secret;if(t=null==(t=null==t?e.privateKey:t)?e.key:t,!0===/^hs/i.test(e.header.alg)&&null==t)throw new TypeError("secret must be a string or buffer or a KeyObject");var n=new r(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new r(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))}return a.inherits(l,o),l.prototype.sign=function(){try{var e=c({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")}},l.sign=c,w=l}function H(){if($)return b;$=1;var e=B().Buffer,r=K(),t=G(),o=n,s=U(),a=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function u(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}function c(r){var t=r.split(".",1)[0];return u(e.from(t,"base64").toString("binary"))}function l(e){return e.split(".")[2]}function f(e){return a.test(e)&&!!c(e)}function p(e,r,n){if(!r){var i=new Error("Missing algorithm parameter for jws.verify");throw i.code="MISSING_ALGORITHM",i}var o=l(e=s(e)),a=function(e){return e.split(".",2).join(".")}(e);return t(r).verify(a,o,n)}function h(r,t){if(t=t||{},!f(r=s(r)))return null;var n=c(r);if(!n)return null;var i=function(r,t){t=t||"utf8";var n=r.split(".")[1];return e.from(n,"base64").toString(t)}(r);return("JWT"===n.typ||t.json)&&(i=JSON.parse(i,t.encoding)),{header:n,payload:i,signature:l(r)}}function d(e){var t=(e=e||{}).secret;if(t=null==(t=null==t?e.publicKey:t)?e.key:t,!0===/^hs/i.test(e.algorithm)&&null==t)throw new TypeError("secret must be a string or buffer or a KeyObject");var n=new r(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new r(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))}return i.inherits(d,o),d.prototype.verify=function(){try{var e=p(this.signature.buffer,this.algorithm,this.key.buffer),r=h(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")}},d.decode=h,d.isValid=f,d.verify=p,b=d}function V(){if(I)return D;I=1;var e=q(),r=H();return D.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],D.sign=e.sign,D.verify=r.verify,D.decode=r.decode,D.isValid=r.isValid,D.createSign=function(r){return new e(r)},D.createVerify=function(e){return new r(e)},D}function X(){if(O)return R;O=1;var e=V();return R=function(r,t){t=t||{};var n=e.decode(r,t);if(!n)return null;var i=n.payload;if("string"==typeof i)try{var o=JSON.parse(i);null!==o&&"object"==typeof o&&(i=o)}catch(e){}return!0===t.complete?{header:n.header,payload:i,signature:n.signature}:i},R}function z(){if(L)return A;L=1;var e=function(e,r){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,r&&(this.inner=r)};return(e.prototype=Object.create(Error.prototype)).constructor=e,A=e}function W(){if(N)return T;N=1;var e=z(),r=function(r,t){e.call(this,r),this.name="NotBeforeError",this.date=t};return(r.prototype=Object.create(e.prototype)).constructor=r,T=r}function Y(){if(k)return j;k=1;var e=z(),r=function(r,t){e.call(this,r),this.name="TokenExpiredError",this.expiredAt=t};return(r.prototype=Object.create(e.prototype)).constructor=r,j=r}function J(){if(_)return P;_=1;var e=1e3,r=60*e,t=60*r,n=24*t,i=7*n,o=365.25*n;function s(e,r,t,n){var i=r>=1.5*t;return Math.round(e/t)+" "+n+(i?"s":"")}return P=function(a,u){u=u||{};var c=typeof a;if("string"===c&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var u=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return u*o;case"weeks":case"week":case"w":return u*i;case"days":case"day":case"d":return u*n;case"hours":case"hour":case"hrs":case"hr":case"h":return u*t;case"minutes":case"minute":case"mins":case"min":case"m":return u*r;case"seconds":case"second":case"secs":case"sec":case"s":return u*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}(a);if("number"===c&&isFinite(a))return u.long?function(i){var o=Math.abs(i);if(o>=n)return s(i,o,n,"day");if(o>=t)return s(i,o,t,"hour");if(o>=r)return s(i,o,r,"minute");if(o>=e)return s(i,o,e,"second");return i+" ms"}(a):function(i){var o=Math.abs(i);if(o>=n)return Math.round(i/n)+"d";if(o>=t)return Math.round(i/t)+"h";if(o>=r)return Math.round(i/r)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}function Z(){if(x)return C;x=1;var e=J();return C=function(r,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof r){var i=e(r);if(void 0===i)return;return Math.floor(n+i/1e3)}return"number"==typeof r?n+r:void 0}}var Q,ee,re,te,ne,ie,oe,se,ae,ue,ce,le,fe,pe,he,de,me,Ee,ye,ge,ve,we,Se,be,$e,Ie,Re,Oe,Ae,Le,Te,Ne,je,ke,Pe,_e,Ce,xe,De,Me,Be,Ke,Fe,Ge,Ue,qe,He,Ve,Xe,ze,We,Ye,Je,Ze,Qe,er,rr,tr,nr,ir,or,sr,ar,ur,cr,lr,fr,pr,hr,dr,mr,Er,yr,gr,vr,wr,Sr,br,$r,Ir,Rr,Or,Ar,Lr,Tr,Nr,jr,kr,Pr,_r,Cr,xr,Dr,Mr,Br,Kr,Fr,Gr,Ur,qr,Hr,Vr,Xr,zr,Wr,Yr,Jr,Zr,Qr,et,rt,tt,nt,it,ot,st,at,ut={exports:{}};function ct(){if(ee)return Q;ee=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return Q={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}function lt(){if(te)return re;te=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return re=e}function ft(){return ne||(ne=1,function(e,r){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=ct(),o=lt(),s=(r=e.exports={}).re=[],a=r.safeRe=[],u=r.src=[],c=r.safeSrc=[],l=r.t={};let f=0;const p="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[p,n]],d=(e,r,t)=>{const n=(e=>{for(const[r,t]of h)e=e.split(`${r}*`).join(`${r}{0,${t}}`).split(`${r}+`).join(`${r}{1,${t}}`);return e})(r),i=f++;o(e,i,r),l[e]=i,u[i]=r,c[i]=n,s[i]=new RegExp(r,t?"g":void 0),a[i]=new RegExp(n,t?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),d("MAINVERSION",`(${u[l.NUMERICIDENTIFIER]})\\.(${u[l.NUMERICIDENTIFIER]})\\.(${u[l.NUMERICIDENTIFIER]})`),d("MAINVERSIONLOOSE",`(${u[l.NUMERICIDENTIFIERLOOSE]})\\.(${u[l.NUMERICIDENTIFIERLOOSE]})\\.(${u[l.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASEIDENTIFIER",`(?:${u[l.NONNUMERICIDENTIFIER]}|${u[l.NUMERICIDENTIFIER]})`),d("PRERELEASEIDENTIFIERLOOSE",`(?:${u[l.NONNUMERICIDENTIFIER]}|${u[l.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASE",`(?:-(${u[l.PRERELEASEIDENTIFIER]}(?:\\.${u[l.PRERELEASEIDENTIFIER]})*))`),d("PRERELEASELOOSE",`(?:-?(${u[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[l.PRERELEASEIDENTIFIERLOOSE]})*))`),d("BUILDIDENTIFIER",`${p}+`),d("BUILD",`(?:\\+(${u[l.BUILDIDENTIFIER]}(?:\\.${u[l.BUILDIDENTIFIER]})*))`),d("FULLPLAIN",`v?${u[l.MAINVERSION]}${u[l.PRERELEASE]}?${u[l.BUILD]}?`),d("FULL",`^${u[l.FULLPLAIN]}$`),d("LOOSEPLAIN",`[v=\\s]*${u[l.MAINVERSIONLOOSE]}${u[l.PRERELEASELOOSE]}?${u[l.BUILD]}?`),d("LOOSE",`^${u[l.LOOSEPLAIN]}$`),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE",`${u[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),d("XRANGEIDENTIFIER",`${u[l.NUMERICIDENTIFIER]}|x|X|\\*`),d("XRANGEPLAIN",`[v=\\s]*(${u[l.XRANGEIDENTIFIER]})(?:\\.(${u[l.XRANGEIDENTIFIER]})(?:\\.(${u[l.XRANGEIDENTIFIER]})(?:${u[l.PRERELEASE]})?${u[l.BUILD]}?)?)?`),d("XRANGEPLAINLOOSE",`[v=\\s]*(${u[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[l.XRANGEIDENTIFIERLOOSE]})(?:${u[l.PRERELEASELOOSE]})?${u[l.BUILD]}?)?)?`),d("XRANGE",`^${u[l.GTLT]}\\s*${u[l.XRANGEPLAIN]}$`),d("XRANGELOOSE",`^${u[l.GTLT]}\\s*${u[l.XRANGEPLAINLOOSE]}$`),d("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),d("COERCE",`${u[l.COERCEPLAIN]}(?:$|[^\\d])`),d("COERCEFULL",u[l.COERCEPLAIN]+`(?:${u[l.PRERELEASE]})?`+`(?:${u[l.BUILD]})?(?:$|[^\\d])`),d("COERCERTL",u[l.COERCE],!0),d("COERCERTLFULL",u[l.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM",`(\\s*)${u[l.LONETILDE]}\\s+`,!0),r.tildeTrimReplace="$1~",d("TILDE",`^${u[l.LONETILDE]}${u[l.XRANGEPLAIN]}$`),d("TILDELOOSE",`^${u[l.LONETILDE]}${u[l.XRANGEPLAINLOOSE]}$`),d("LONECARET","(?:\\^)"),d("CARETTRIM",`(\\s*)${u[l.LONECARET]}\\s+`,!0),r.caretTrimReplace="$1^",d("CARET",`^${u[l.LONECARET]}${u[l.XRANGEPLAIN]}$`),d("CARETLOOSE",`^${u[l.LONECARET]}${u[l.XRANGEPLAINLOOSE]}$`),d("COMPARATORLOOSE",`^${u[l.GTLT]}\\s*(${u[l.LOOSEPLAIN]})$|^$`),d("COMPARATOR",`^${u[l.GTLT]}\\s*(${u[l.FULLPLAIN]})$|^$`),d("COMPARATORTRIM",`(\\s*)${u[l.GTLT]}\\s*(${u[l.LOOSEPLAIN]}|${u[l.XRANGEPLAIN]})`,!0),r.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE",`^\\s*(${u[l.XRANGEPLAIN]})\\s+-\\s+(${u[l.XRANGEPLAIN]})\\s*$`),d("HYPHENRANGELOOSE",`^\\s*(${u[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[l.XRANGEPLAINLOOSE]})\\s*$`),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(ut,ut.exports)),ut.exports}function pt(){if(oe)return ie;oe=1;const e=Object.freeze({loose:!0}),r=Object.freeze({});return ie=t=>t?"object"!=typeof t?e:t:r}function ht(){if(ae)return se;ae=1;const e=/^[0-9]+$/,r=(r,t)=>{if("number"==typeof r&&"number"==typeof t)return r===t?0:r<t?-1:1;const n=e.test(r),i=e.test(t);return n&&i&&(r=+r,t=+t),r===t?0:n&&!i?-1:i&&!n?1:r<t?-1:1};return se={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}}function dt(){if(ce)return ue;ce=1;const e=lt(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:t}=ct(),{safeRe:n,t:i}=ft(),o=pt(),{compareIdentifiers:s}=ht();class a{constructor(s,u){if(u=o(u),s instanceof a){if(s.loose===!!u.loose&&s.includePrerelease===!!u.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>r)throw new TypeError(`version is longer than ${r} characters`);e("SemVer",s,u),this.options=u,this.loose=!!u.loose,this.includePrerelease=!!u.includePrerelease;const c=s.trim().match(u.loose?n[i.LOOSE]:n[i.FULL]);if(!c)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+c[1],this.minor=+c[2],this.patch=+c[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");c[4]?this.prerelease=c[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const r=+e;if(r>=0&&r<t)return r}return e}):this.prerelease=[],this.build=c[5]?c[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(r){if(e("SemVer.compare",this.version,this.options,r),!(r instanceof a)){if("string"==typeof r&&r===this.version)return 0;r=new a(r,this.options)}return r.version===this.version?0:this.compareMain(r)||this.comparePre(r)}compareMain(e){return e instanceof a||(e=new a(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(r){if(r instanceof a||(r=new a(r,this.options)),this.prerelease.length&&!r.prerelease.length)return-1;if(!this.prerelease.length&&r.prerelease.length)return 1;if(!this.prerelease.length&&!r.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],i=r.prerelease[t];if(e("prerelease compare",t,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++t)}compareBuild(r){r instanceof a||(r=new a(r,this.options));let t=0;do{const n=this.build[t],i=r.build[t];if(e("build compare",t,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++t)}inc(e,r,t){if(e.startsWith("pre")){if(!r&&!1===t)throw new Error("invalid increment argument: identifier is empty");if(r){const e=`-${r}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,t),this.inc("pre",r,t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",r,t),this.inc("pre",r,t);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;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":{const e=Number(t)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(r===this.prerelease.join(".")&&!1===t)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(r){let n=[r,e];!1===t&&(n=[r]),0===s(this.prerelease[0],r)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return ue=a}function mt(){if(fe)return le;fe=1;const e=dt();return le=(r,t,n=!1)=>{if(r instanceof e)return r;try{return new e(r,t)}catch(e){if(!n)return null;throw e}},le}function Et(){if(Te)return Le;Te=1;const e=dt();return Le=(r,t,n)=>new e(r,n).compare(new e(t,n))}function yt(){if(Ce)return _e;Ce=1;const e=dt();return _e=(r,t,n)=>{const i=new e(r,n),o=new e(t,n);return i.compare(o)||i.compareBuild(o)}}function gt(){if(Fe)return Ke;Fe=1;const e=Et();return Ke=(r,t,n)=>e(r,t,n)>0}function vt(){if(Ue)return Ge;Ue=1;const e=Et();return Ge=(r,t,n)=>e(r,t,n)<0}function wt(){if(He)return qe;He=1;const e=Et();return qe=(r,t,n)=>0===e(r,t,n)}function St(){if(Xe)return Ve;Xe=1;const e=Et();return Ve=(r,t,n)=>0!==e(r,t,n)}function bt(){if(We)return ze;We=1;const e=Et();return ze=(r,t,n)=>e(r,t,n)>=0}function $t(){if(Je)return Ye;Je=1;const e=Et();return Ye=(r,t,n)=>e(r,t,n)<=0}function It(){if(Qe)return Ze;Qe=1;const e=wt(),r=St(),t=gt(),n=bt(),i=vt(),o=$t();return Ze=(s,a,u,c)=>{switch(a){case"===":return"object"==typeof s&&(s=s.version),"object"==typeof u&&(u=u.version),s===u;case"!==":return"object"==typeof s&&(s=s.version),"object"==typeof u&&(u=u.version),s!==u;case"":case"=":case"==":return e(s,u,c);case"!=":return r(s,u,c);case">":return t(s,u,c);case">=":return n(s,u,c);case"<":return i(s,u,c);case"<=":return o(s,u,c);default:throw new TypeError(`Invalid operator: ${a}`)}}}function Rt(){if(or)return ir;or=1;const e=/\s+/g;class r{constructor(t,o){if(o=n(o),t instanceof r)return t.loose===!!o.loose&&t.includePrerelease===!!o.includePrerelease?t:new r(t.raw,o);if(t instanceof i)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=o,this.loose=!!o.loose,this.includePrerelease=!!o.includePrerelease,this.raw=t.trim().replace(e," "),this.set=this.raw.split("||").map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter(e=>!d(e[0])),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const r=this.set[e];for(let e=0;e<r.length;e++)e>0&&(this.formatted+=" "),this.formatted+=r[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const r=((this.options.includePrerelease&&p)|(this.options.loose&&h))+":"+e,n=t.get(r);if(n)return n;const s=this.options.loose,m=s?a[u.HYPHENRANGELOOSE]:a[u.HYPHENRANGE];e=e.replace(m,A(this.options.includePrerelease)),o("hyphen replace",e),e=e.replace(a[u.COMPARATORTRIM],c),o("comparator trim",e),e=e.replace(a[u.TILDETRIM],l),o("tilde trim",e),e=e.replace(a[u.CARETTRIM],f),o("caret trim",e);let E=e.split(" ").map(e=>y(e,this.options)).join(" ").split(/\s+/).map(e=>O(e,this.options));s&&(E=E.filter(e=>(o("loose invalid filter",e,this.options),!!e.match(a[u.COMPARATORLOOSE])))),o("range list",E);const g=new Map,v=E.map(e=>new i(e,this.options));for(const e of v){if(d(e))return[e];g.set(e.value,e)}g.size>1&&g.has("")&&g.delete("");const w=[...g.values()];return t.set(r,w),w}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Range is required");return this.set.some(r=>E(r,t)&&e.set.some(e=>E(e,t)&&r.every(r=>e.every(e=>r.intersects(e,t)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new s(e,this.options)}catch(e){return!1}for(let r=0;r<this.set.length;r++)if(L(this.set[r],e,this.options))return!0;return!1}}ir=r;const t=new(nr?tr:(nr=1,tr=class{constructor(){this.max=1e3,this.map=new Map}get(e){const r=this.map.get(e);return void 0===r?void 0:(this.map.delete(e),this.map.set(e,r),r)}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&void 0!==r){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,r)}return this}})),n=pt(),i=Ot(),o=lt(),s=dt(),{safeRe:a,t:u,comparatorTrimReplace:c,tildeTrimReplace:l,caretTrimReplace:f}=ft(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:h}=ct(),d=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,E=(e,r)=>{let t=!0;const n=e.slice();let i=n.pop();for(;t&&n.length;)t=n.every(e=>i.intersects(e,r)),i=n.pop();return t},y=(e,r)=>(e=e.replace(a[u.BUILD],""),o("comp",e,r),e=S(e,r),o("caret",e),e=v(e,r),o("tildes",e),e=$(e,r),o("xrange",e),e=R(e,r),o("stars",e),e),g=e=>!e||"x"===e.toLowerCase()||"*"===e,v=(e,r)=>e.trim().split(/\s+/).map(e=>w(e,r)).join(" "),w=(e,r)=>{const t=r.loose?a[u.TILDELOOSE]:a[u.TILDE];return e.replace(t,(r,t,n,i,s)=>{let a;return o("tilde",e,r,t,n,i,s),g(t)?a="":g(n)?a=`>=${t}.0.0 <${+t+1}.0.0-0`:g(i)?a=`>=${t}.${n}.0 <${t}.${+n+1}.0-0`:s?(o("replaceTilde pr",s),a=`>=${t}.${n}.${i}-${s} <${t}.${+n+1}.0-0`):a=`>=${t}.${n}.${i} <${t}.${+n+1}.0-0`,o("tilde return",a),a})},S=(e,r)=>e.trim().split(/\s+/).map(e=>b(e,r)).join(" "),b=(e,r)=>{o("caret",e,r);const t=r.loose?a[u.CARETLOOSE]:a[u.CARET],n=r.includePrerelease?"-0":"";return e.replace(t,(r,t,i,s,a)=>{let u;return o("caret",e,r,t,i,s,a),g(t)?u="":g(i)?u=`>=${t}.0.0${n} <${+t+1}.0.0-0`:g(s)?u="0"===t?`>=${t}.${i}.0${n} <${t}.${+i+1}.0-0`:`>=${t}.${i}.0${n} <${+t+1}.0.0-0`:a?(o("replaceCaret pr",a),u="0"===t?"0"===i?`>=${t}.${i}.${s}-${a} <${t}.${i}.${+s+1}-0`:`>=${t}.${i}.${s}-${a} <${t}.${+i+1}.0-0`:`>=${t}.${i}.${s}-${a} <${+t+1}.0.0-0`):(o("no pr"),u="0"===t?"0"===i?`>=${t}.${i}.${s}${n} <${t}.${i}.${+s+1}-0`:`>=${t}.${i}.${s}${n} <${t}.${+i+1}.0-0`:`>=${t}.${i}.${s} <${+t+1}.0.0-0`),o("caret return",u),u})},$=(e,r)=>(o("replaceXRanges",e,r),e.split(/\s+/).map(e=>I(e,r)).join(" ")),I=(e,r)=>{e=e.trim();const t=r.loose?a[u.XRANGELOOSE]:a[u.XRANGE];return e.replace(t,(t,n,i,s,a,u)=>{o("xRange",e,t,n,i,s,a,u);const c=g(i),l=c||g(s),f=l||g(a),p=f;return"="===n&&p&&(n=""),u=r.includePrerelease?"-0":"",c?t=">"===n||"<"===n?"<0.0.0-0":"*":n&&p?(l&&(s=0),a=0,">"===n?(n=">=",l?(i=+i+1,s=0,a=0):(s=+s+1,a=0)):"<="===n&&(n="<",l?i=+i+1:s=+s+1),"<"===n&&(u="-0"),t=`${n+i}.${s}.${a}${u}`):l?t=`>=${i}.0.0${u} <${+i+1}.0.0-0`:f&&(t=`>=${i}.${s}.0${u} <${i}.${+s+1}.0-0`),o("xRange return",t),t})},R=(e,r)=>(o("replaceStars",e,r),e.trim().replace(a[u.STAR],"")),O=(e,r)=>(o("replaceGTE0",e,r),e.trim().replace(a[r.includePrerelease?u.GTE0PRE:u.GTE0],"")),A=e=>(r,t,n,i,o,s,a,u,c,l,f,p)=>`${t=g(n)?"":g(i)?`>=${n}.0.0${e?"-0":""}`:g(o)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${t}`:`>=${t}${e?"-0":""}`} ${u=g(c)?"":g(l)?`<${+c+1}.0.0-0`:g(f)?`<${c}.${+l+1}.0-0`:p?`<=${c}.${l}.${f}-${p}`:e?`<${c}.${l}.${+f+1}-0`:`<=${u}`}`.trim(),L=(e,r,t)=>{for(let t=0;t<e.length;t++)if(!e[t].test(r))return!1;if(r.prerelease.length&&!t.includePrerelease){for(let t=0;t<e.length;t++)if(o(e[t].semver),e[t].semver!==i.ANY&&e[t].semver.prerelease.length>0){const n=e[t].semver;if(n.major===r.major&&n.minor===r.minor&&n.patch===r.patch)return!0}return!1}return!0};return ir}function Ot(){if(ar)return sr;ar=1;const e=Symbol("SemVer ANY");class r{static get ANY(){return e}constructor(n,i){if(i=t(i),n instanceof r){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),s("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(r){const t=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],o=r.match(t);if(!o)throw new TypeError(`Invalid comparator: ${r}`);this.operator=void 0!==o[1]?o[1]:"","="===this.operator&&(this.operator=""),o[2]?this.semver=new a(o[2],this.options.loose):this.semver=e}toString(){return this.value}test(r){if(s("Comparator.test",r,this.options.loose),this.semver===e||r===e)return!0;if("string"==typeof r)try{r=new a(r,this.options)}catch(e){return!1}return o(r,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof r))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new u(e.value,n).test(this.value):""===e.operator?""===e.value||new u(this.value,n).test(e.semver):(!(n=t(n)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!n.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&(!(!this.operator.startsWith(">")||!e.operator.startsWith(">"))||(!(!this.operator.startsWith("<")||!e.operator.startsWith("<"))||(!(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))||(!!(o(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(o(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}sr=r;const t=pt(),{safeRe:n,t:i}=ft(),o=It(),s=lt(),a=dt(),u=Rt();return sr}function At(){if(cr)return ur;cr=1;const e=Rt();return ur=(r,t,n)=>{try{t=new e(t,n)}catch(e){return!1}return t.test(r)},ur}function Lt(){if(vr)return gr;vr=1;const e=Rt();return gr=(r,t)=>{try{return new e(r,t).range||"*"}catch(e){return null}},gr}function Tt(){if(Sr)return wr;Sr=1;const e=dt(),r=Ot(),{ANY:t}=r,n=Rt(),i=At(),o=gt(),s=vt(),a=$t(),u=bt();return wr=(c,l,f,p)=>{let h,d,m,E,y;switch(c=new e(c,p),l=new n(l,p),f){case">":h=o,d=a,m=s,E=">",y=">=";break;case"<":h=s,d=u,m=o,E="<",y="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(c,l,p))return!1;for(let e=0;e<l.set.length;++e){const n=l.set[e];let i=null,o=null;if(n.forEach(e=>{e.semver===t&&(e=new r(">=0.0.0")),i=i||e,o=o||e,h(e.semver,i.semver,p)?i=e:m(e.semver,o.semver,p)&&(o=e)}),i.operator===E||i.operator===y)return!1;if((!o.operator||o.operator===E)&&d(c,o.semver))return!1;if(o.operator===y&&m(c,o.semver))return!1}return!0},wr}function Nt(){if(Pr)return kr;Pr=1;const e=ft(),r=ct(),t=dt(),n=ht(),i=mt(),o=function(){if(he)return pe;he=1;const e=mt();return pe=(r,t)=>{const n=e(r,t);return n?n.version:null},pe}(),s=function(){if(me)return de;me=1;const e=mt();return de=(r,t)=>{const n=e(r.trim().replace(/^[=v]+/,""),t);return n?n.version:null},de}(),a=function(){if(ye)return Ee;ye=1;const e=dt();return Ee=(r,t,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new e(r instanceof e?r.version:r,n).inc(t,i,o).version}catch(e){return null}},Ee}(),u=function(){if(ve)return ge;ve=1;const e=mt();return ge=(r,t)=>{const n=e(r,null,!0),i=e(t,null,!0),o=n.compare(i);if(0===o)return null;const s=o>0,a=s?n:i,u=s?i:n,c=!!a.prerelease.length;if(u.prerelease.length&&!c){if(!u.patch&&!u.minor)return"major";if(0===u.compareMain(a))return u.minor&&!u.patch?"minor":"patch"}const l=c?"pre":"";return n.major!==i.major?l+"major":n.minor!==i.minor?l+"minor":n.patch!==i.patch?l+"patch":"prerelease"}}(),c=function(){if(Se)return we;Se=1;const e=dt();return we=(r,t)=>new e(r,t).major}(),l=function(){if($e)return be;$e=1;const e=dt();return be=(r,t)=>new e(r,t).minor}(),f=function(){if(Re)return Ie;Re=1;const e=dt();return Ie=(r,t)=>new e(r,t).patch}(),p=function(){if(Ae)return Oe;Ae=1;const e=mt();return Oe=(r,t)=>{const n=e(r,t);return n&&n.prerelease.length?n.prerelease:null},Oe}(),h=Et(),d=function(){if(je)return Ne;je=1;const e=Et();return Ne=(r,t,n)=>e(t,r,n)}(),m=function(){if(Pe)return ke;Pe=1;const e=Et();return ke=(r,t)=>e(r,t,!0)}(),E=yt(),y=function(){if(De)return xe;De=1;const e=yt();return xe=(r,t)=>r.sort((r,n)=>e(r,n,t))}(),g=function(){if(Be)return Me;Be=1;const e=yt();return Me=(r,t)=>r.sort((r,n)=>e(n,r,t))}(),v=gt(),w=vt(),S=wt(),b=St(),$=bt(),I=$t(),R=It(),O=function(){if(rr)return er;rr=1;const e=dt(),r=mt(),{safeRe:t,t:n}=ft();return er=(i,o)=>{if(i instanceof e)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let s=null;if((o=o||{}).rtl){const e=o.includePrerelease?t[n.COERCERTLFULL]:t[n.COERCERTL];let r;for(;(r=e.exec(i))&&(!s||s.index+s[0].length!==i.length);)s&&r.index+r[0].length===s.index+s[0].length||(s=r),e.lastIndex=r.index+r[1].length+r[2].length;e.lastIndex=-1}else s=i.match(o.includePrerelease?t[n.COERCEFULL]:t[n.COERCE]);if(null===s)return null;const a=s[2],u=s[3]||"0",c=s[4]||"0",l=o.includePrerelease&&s[5]?`-${s[5]}`:"",f=o.includePrerelease&&s[6]?`+${s[6]}`:"";return r(`${a}.${u}.${c}${l}${f}`,o)},er}(),A=Ot(),L=Rt(),T=At(),N=function(){if(fr)return lr;fr=1;const e=Rt();return lr=(r,t)=>new e(r,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" ")),lr}(),j=function(){if(hr)return pr;hr=1;const e=dt(),r=Rt();return pr=(t,n,i)=>{let o=null,s=null,a=null;try{a=new r(n,i)}catch(e){return null}return t.forEach(r=>{a.test(r)&&(o&&-1!==s.compare(r)||(o=r,s=new e(o,i)))}),o},pr}(),k=function(){if(mr)return dr;mr=1;const e=dt(),r=Rt();return dr=(t,n,i)=>{let o=null,s=null,a=null;try{a=new r(n,i)}catch(e){return null}return t.forEach(r=>{a.test(r)&&(o&&1!==s.compare(r)||(o=r,s=new e(o,i)))}),o},dr}(),P=function(){if(yr)return Er;yr=1;const e=dt(),r=Rt(),t=gt();return Er=(n,i)=>{n=new r(n,i);let o=new e("0.0.0");if(n.test(o))return o;if(o=new e("0.0.0-0"),n.test(o))return o;o=null;for(let r=0;r<n.set.length;++r){const i=n.set[r];let s=null;i.forEach(r=>{const n=new e(r.semver.version);switch(r.operator){case">":0===n.prerelease.length?n.patch++:n.prerelease.push(0),n.raw=n.format();case"":case">=":s&&!t(n,s)||(s=n);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${r.operator}`)}}),!s||o&&!t(o,s)||(o=s)}return o&&n.test(o)?o:null},Er}(),_=Lt(),C=Tt(),x=function(){if($r)return br;$r=1;const e=Tt();return br=(r,t,n)=>e(r,t,">",n),br}(),D=function(){if(Rr)return Ir;Rr=1;const e=Tt();return Ir=(r,t,n)=>e(r,t,"<",n),Ir}(),M=function(){if(Ar)return Or;Ar=1;const e=Rt();return Or=(r,t,n)=>(r=new e(r,n),t=new e(t,n),r.intersects(t,n))}(),B=function(){if(Tr)return Lr;Tr=1;const e=At(),r=Et();return Lr=(t,n,i)=>{const o=[];let s=null,a=null;const u=t.sort((e,t)=>r(e,t,i));for(const r of u)e(r,n,i)?(a=r,s||(s=r)):(a&&o.push([s,a]),a=null,s=null);s&&o.push([s,null]);const c=[];for(const[e,r]of o)e===r?c.push(e):r||e!==u[0]?r?e===u[0]?c.push(`<=${r}`):c.push(`${e} - ${r}`):c.push(`>=${e}`):c.push("*");const l=c.join(" || "),f="string"==typeof n.raw?n.raw:String(n);return l.length<f.length?l:n},Lr}(),K=function(){if(jr)return Nr;jr=1;const e=Rt(),r=Ot(),{ANY:t}=r,n=At(),i=Et(),o=[new r(">=0.0.0-0")],s=[new r(">=0.0.0")],a=(e,r,a)=>{if(e===r)return!0;if(1===e.length&&e[0].semver===t){if(1===r.length&&r[0].semver===t)return!0;e=a.includePrerelease?o:s}if(1===r.length&&r[0].semver===t){if(a.includePrerelease)return!0;r=s}const l=new Set;let f,p,h,d,m,E,y;for(const r of e)">"===r.operator||">="===r.operator?f=u(f,r,a):"<"===r.operator||"<="===r.operator?p=c(p,r,a):l.add(r.semver);if(l.size>1)return null;if(f&&p){if(h=i(f.semver,p.semver,a),h>0)return null;if(0===h&&(">="!==f.operator||"<="!==p.operator))return null}for(const e of l){if(f&&!n(e,String(f),a))return null;if(p&&!n(e,String(p),a))return null;for(const t of r)if(!n(e,String(t),a))return!1;return!0}let g=!(!p||a.includePrerelease||!p.semver.prerelease.length)&&p.semver,v=!(!f||a.includePrerelease||!f.semver.prerelease.length)&&f.semver;g&&1===g.prerelease.length&&"<"===p.operator&&0===g.prerelease[0]&&(g=!1);for(const e of r){if(y=y||">"===e.operator||">="===e.operator,E=E||"<"===e.operator||"<="===e.operator,f)if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),">"===e.operator||">="===e.operator){if(d=u(f,e,a),d===e&&d!==f)return!1}else if(">="===f.operator&&!n(f.semver,String(e),a))return!1;if(p)if(g&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===g.major&&e.semver.minor===g.minor&&e.semver.patch===g.patch&&(g=!1),"<"===e.operator||"<="===e.operator){if(m=c(p,e,a),m===e&&m!==p)return!1}else if("<="===p.operator&&!n(p.semver,String(e),a))return!1;if(!e.operator&&(p||f)&&0!==h)return!1}return!(f&&E&&!p&&0!==h||p&&y&&!f&&0!==h||v||g)},u=(e,r,t)=>{if(!e)return r;const n=i(e.semver,r.semver,t);return n>0?e:n<0||">"===r.operator&&">="===e.operator?r:e},c=(e,r,t)=>{if(!e)return r;const n=i(e.semver,r.semver,t);return n<0?e:n>0||"<"===r.operator&&"<="===e.operator?r:e};return Nr=(r,t,n={})=>{if(r===t)return!0;r=new e(r,n),t=new e(t,n);let i=!1;e:for(const e of r.set){for(const r of t.set){const t=a(e,r,n);if(i=i||null!==t,t)continue e}if(i)return!1}return!0}}();return kr={parse:i,valid:o,clean:s,inc:a,diff:u,major:c,minor:l,patch:f,prerelease:p,compare:h,rcompare:d,compareLoose:m,compareBuild:E,sort:y,rsort:g,gt:v,lt:w,eq:S,neq:b,gte:$,lte:I,cmp:R,coerce:O,Comparator:A,Range:L,satisfies:T,toComparators:N,maxSatisfying:j,minSatisfying:k,minVersion:P,validRange:_,outside:C,gtr:x,ltr:D,intersects:M,simplifyRange:B,subset:K,SemVer:t,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}function jt(){if(Br)return Mr;Br=1;const e=function(){if(Cr)return _r;Cr=1;const e=Nt();return _r=e.satisfies(process.version,">=15.7.0")}(),r=function(){if(Dr)return xr;Dr=1;const e=Nt();return xr=e.satisfies(process.version,">=16.9.0")}(),t={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},n={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};return Mr=function(i,o){if(!i||!o)return;const s=o.asymmetricKeyType;if(!s)return;const a=t[s];if(!a)throw new Error(`Unknown key type "${s}".`);if(!a.includes(i))throw new Error(`"alg" parameter for "${s}" key type must be one of: ${a.join(", ")}.`);if(e)switch(s){case"ec":const e=o.asymmetricKeyDetails.namedCurve,t=n[i];if(e!==t)throw new Error(`"alg" parameter "${i}" requires curve "${t}".`);break;case"rsa-pss":if(r){const e=parseInt(i.slice(-3),10),{hashAlgorithm:r,mgf1HashAlgorithm:t,saltLength:n}=o.asymmetricKeyDetails;if(r!==`sha${e}`||t!==r)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${i}.`);if(void 0!==n&&n>e>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${i}.`)}}}}function kt(){if(Fr)return Kr;Fr=1;var e=Nt();return Kr=e.satisfies(process.version,"^6.12.0 || >=8.0.0")}function Pt(){if(Ur)return Gr;Ur=1;const e=z(),r=W(),t=Y(),n=X(),i=Z(),s=jt(),a=kt(),u=V(),{KeyObject:c,createSecretKey:l,createPublicKey:f}=o,p=["RS256","RS384","RS512"],h=["ES256","ES384","ES512"],d=["RS256","RS384","RS512"],m=["HS256","HS384","HS512"];return a&&(p.splice(p.length,0,"PS256","PS384","PS512"),d.splice(d.length,0,"PS256","PS384","PS512")),Gr=function(o,a,E,y){let g;if("function"!=typeof E||y||(y=E,E={}),E||(E={}),E=Object.assign({},E),g=y||function(e,r){if(e)throw e;return r},E.clockTimestamp&&"number"!=typeof E.clockTimestamp)return g(new e("clockTimestamp must be a number"));if(void 0!==E.nonce&&("string"!=typeof E.nonce||""===E.nonce.trim()))return g(new e("nonce must be a non-empty string"));if(void 0!==E.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof E.allowInvalidAsymmetricKeyTypes)return g(new e("allowInvalidAsymmetricKeyTypes must be a boolean"));const v=E.clockTimestamp||Math.floor(Date.now()/1e3);if(!o)return g(new e("jwt must be provided"));if("string"!=typeof o)return g(new e("jwt must be a string"));const w=o.split(".");if(3!==w.length)return g(new e("jwt malformed"));let S;try{S=n(o,{complete:!0})}catch(e){return g(e)}if(!S)return g(new e("invalid token"));const b=S.header;let $;if("function"==typeof a){if(!y)return g(new e("verify must be called asynchronous if secret or public key is provided as a callback"));$=a}else $=function(e,r){return r(null,a)};return $(b,function(n,a){if(n)return g(new e("error in secret or public key callback: "+n.message));const y=""!==w[2].trim();if(!y&&a)return g(new e("jwt signature is required"));if(y&&!a)return g(new e("secret or public key must be provided"));if(!y&&!E.algorithms)return g(new e('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=a&&!(a instanceof c))try{a=f(a)}catch(r){try{a=l("string"==typeof a?Buffer.from(a):a)}catch(r){return g(new e("secretOrPublicKey is not valid key material"))}}if(E.algorithms||("secret"===a.type?E.algorithms=m:["rsa","rsa-pss"].includes(a.asymmetricKeyType)?E.algorithms=d:"ec"===a.asymmetricKeyType?E.algorithms=h:E.algorithms=p),-1===E.algorithms.indexOf(S.header.alg))return g(new e("invalid algorithm"));if(b.alg.startsWith("HS")&&"secret"!==a.type)return g(new e(`secretOrPublicKey must be a symmetric key when using ${b.alg}`));if(/^(?:RS|PS|ES)/.test(b.alg)&&"public"!==a.type)return g(new e(`secretOrPublicKey must be an asymmetric key when using ${b.alg}`));if(!E.allowInvalidAsymmetricKeyTypes)try{s(b.alg,a)}catch(e){return g(e)}let $;try{$=u.verify(o,S.header.alg,a)}catch(e){return g(e)}if(!$)return g(new e("invalid signature"));const I=S.payload;if(void 0!==I.nbf&&!E.ignoreNotBefore){if("number"!=typeof I.nbf)return g(new e("invalid nbf value"));if(I.nbf>v+(E.clockTolerance||0))return g(new r("jwt not active",new Date(1e3*I.nbf)))}if(void 0!==I.exp&&!E.ignoreExpiration){if("number"!=typeof I.exp)return g(new e("invalid exp value"));if(v>=I.exp+(E.clockTolerance||0))return g(new t("jwt expired",new Date(1e3*I.exp)))}if(E.audience){const r=Array.isArray(E.audience)?E.audience:[E.audience];if(!(Array.isArray(I.aud)?I.aud:[I.aud]).some(function(e){return r.some(function(r){return r instanceof RegExp?r.test(e):r===e})}))return g(new e("jwt audience invalid. expected: "+r.join(" or ")))}if(E.issuer){if("string"==typeof E.issuer&&I.iss!==E.issuer||Array.isArray(E.issuer)&&-1===E.issuer.indexOf(I.iss))return g(new e("jwt issuer invalid. expected: "+E.issuer))}if(E.subject&&I.sub!==E.subject)return g(new e("jwt subject invalid. expected: "+E.subject));if(E.jwtid&&I.jti!==E.jwtid)return g(new e("jwt jwtid invalid. expected: "+E.jwtid));if(E.nonce&&I.nonce!==E.nonce)return g(new e("jwt nonce invalid. expected: "+E.nonce));if(E.maxAge){if("number"!=typeof I.iat)return g(new e("iat required when maxAge is specified"));const r=i(E.maxAge,I.iat);if(void 0===r)return g(new e('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(v>=r+(E.clockTolerance||0))return g(new t("maxAge exceeded",new Date(1e3*r)))}if(!0===E.complete){const e=S.signature;return g(null,{header:b,payload:I,signature:e})}return g(null,I)})},Gr}function _t(){if(Hr)return qr;Hr=1;var e=1/0,r=9007199254740991,t=17976931348623157e292,n=NaN,i="[object Arguments]",o="[object Function]",s="[object GeneratorFunction]",a="[object String]",u="[object Symbol]",c=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,p=/^0o[0-7]+$/i,h=/^(?:0|[1-9]\d*)$/,d=parseInt;function m(e){return e!=e}function E(e,r){return function(e,r){for(var t=-1,n=e?e.length:0,i=Array(n);++t<n;)i[t]=r(e[t],t,e);return i}(r,function(r){return e[r]})}var y,g,v=Object.prototype,w=v.hasOwnProperty,S=v.toString,b=v.propertyIsEnumerable,$=(y=Object.keys,g=Object,function(e){return y(g(e))}),I=Math.max;function R(e,r){var t=L(e)||function(e){return function(e){return j(e)&&T(e)}(e)&&w.call(e,"callee")&&(!b.call(e,"callee")||S.call(e)==i)}(e)?function(e,r){for(var t=-1,n=Array(e);++t<e;)n[t]=r(t);return n}(e.length,String):[],n=t.length,o=!!n;for(var s in e)!w.call(e,s)||o&&("length"==s||A(s,n))||t.push(s);return t}function O(e){if(t=(r=e)&&r.constructor,n="function"==typeof t&&t.prototype||v,r!==n)return $(e);var r,t,n,i=[];for(var o in Object(e))w.call(e,o)&&"constructor"!=o&&i.push(o);return i}function A(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||h.test(e))&&e>-1&&e%1==0&&e<t}var L=Array.isArray;function T(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}(e.length)&&!function(e){var r=N(e)?S.call(e):"";return r==o||r==s}(e)}function N(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}function j(e){return!!e&&"object"==typeof e}return qr=function(r,i,o,s){var h;r=T(r)?r:(h=r)?E(h,function(e){return T(e)?R(e):O(e)}(h)):[],o=o&&!s?function(r){var i=function(r){if(!r)return 0===r?r:0;if(r=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||j(e)&&S.call(e)==u}(e))return n;if(N(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=N(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(c,"");var t=f.test(e);return t||p.test(e)?d(e.slice(2),t?2:8):l.test(e)?n:+e}(r),r===e||r===-1/0){return(r<0?-1:1)*t}return r==r?r:0}(r),o=i%1;return i==i?o?i-o:i:0}(o):0;var y=r.length;return o<0&&(o=I(y+o,0)),function(e){return"string"==typeof e||!L(e)&&j(e)&&S.call(e)==a}(r)?o<=y&&r.indexOf(i,o)>-1:!!y&&function(e,r,t){if(r!=r)return function(e,r,t){for(var n=e.length,i=t+-1;++i<n;)if(r(e[i],i,e))return i;return-1}(e,m,t);for(var n=t-1,i=e.length;++n<i;)if(e[n]===r)return n;return-1}(r,i,o)>-1},qr}function Ct(){if(Wr)return zr;Wr=1;var e=1/0,r=17976931348623157e292,t=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,u=parseInt,c=Object.prototype.toString;function l(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}return zr=function(f){return"number"==typeof f&&f==function(f){var p=function(f){if(!f)return 0===f?f:0;if(f=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&c.call(e)==n}(e))return t;if(l(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=l(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var f=s.test(e);return f||a.test(e)?u(e.slice(2),f?2:8):o.test(e)?t:+e}(f),f===e||f===-1/0){return(f<0?-1:1)*r}return f==f?f:0}(f),h=p%1;return p==p?h?p-h:p:0}(f)}}function xt(){if(nt)return tt;nt=1;var e=1/0,r=17976931348623157e292,t=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,u=parseInt,c=Object.prototype.toString;function l(l,p){var h;if("function"!=typeof p)throw new TypeError("Expected a function");return l=function(l){var p=function(l){if(!l)return 0===l?l:0;if(l=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&c.call(e)==n}(e))return t;if(f(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=f(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var l=s.test(e);return l||a.test(e)?u(e.slice(2),l?2:8):o.test(e)?t:+e}(l),l===e||l===-1/0){return(l<0?-1:1)*r}return l==l?l:0}(l),h=p%1;return p==p?h?p-h:p:0}(l),function(){return--l>0&&(h=p.apply(this,arguments)),l<=1&&(p=void 0),h}}function f(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}return tt=function(e){return l(2,e)}}function Dt(){if(ot)return it;ot=1;const e=Z(),r=kt(),t=jt(),n=V(),i=_t(),s=function(){if(Xr)return Vr;Xr=1;var e=Object.prototype.toString;return Vr=function(r){return!0===r||!1===r||function(e){return!!e&&"object"==typeof e}(r)&&"[object Boolean]"==e.call(r)}}(),a=Ct(),u=function(){if(Jr)return Yr;Jr=1;var e=Object.prototype.toString;return Yr=function(r){return"number"==typeof r||function(e){return!!e&&"object"==typeof e}(r)&&"[object Number]"==e.call(r)}}(),c=function(){if(Qr)return Zr;Qr=1;var e,r,t=Function.prototype,n=Object.prototype,i=t.toString,o=n.hasOwnProperty,s=i.call(Object),a=n.toString,u=(e=Object.getPrototypeOf,r=Object,function(t){return e(r(t))});return Zr=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=a.call(e)||function(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}(e))return!1;var r=u(e);if(null===r)return!0;var t=o.call(r,"constructor")&&r.constructor;return"function"==typeof t&&t instanceof t&&i.call(t)==s}}(),l=function(){if(rt)return et;rt=1;var e=Object.prototype.toString,r=Array.isArray;return et=function(t){return"string"==typeof t||!r(t)&&function(e){return!!e&&"object"==typeof e}(t)&&"[object String]"==e.call(t)}}(),f=xt(),{KeyObject:p,createSecretKey:h,createPrivateKey:d}=o,m=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];r&&m.splice(3,0,"PS256","PS384","PS512");const E={expiresIn:{isValid:function(e){return a(e)||l(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return a(e)||l(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return l(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:i.bind(null,m),message:'"algorithm" must be a valid string enum value'},header:{isValid:c,message:'"header" must be an object'},encoding:{isValid:l,message:'"encoding" must be a string'},issuer:{isValid:l,message:'"issuer" must be a string'},subject:{isValid:l,message:'"subject" must be a string'},jwtid:{isValid:l,message:'"jwtid" must be a string'},noTimestamp:{isValid:s,message:'"noTimestamp" must be a boolean'},keyid:{isValid:l,message:'"keyid" must be a string'},mutatePayload:{isValid:s,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:s,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:s,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},y={iat:{isValid:u,message:'"iat" should be a number of seconds'},exp:{isValid:u,message:'"exp" should be a number of seconds'},nbf:{isValid:u,message:'"nbf" should be a number of seconds'}};function g(e,r,t,n){if(!c(t))throw new Error('Expected "'+n+'" to be a plain object.');Object.keys(t).forEach(function(i){const o=e[i];if(o){if(!o.isValid(t[i]))throw new Error(o.message)}else if(!r)throw new Error('"'+i+'" is not allowed in "'+n+'"')})}const v={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},w=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];return it=function(r,i,o,s){"function"==typeof o?(s=o,o={}):o=o||{};const a="object"==typeof r&&!Buffer.isBuffer(r),u=Object.assign({alg:o.algorithm||"HS256",typ:a?"JWT":void 0,kid:o.keyid},o.header);function c(e){if(s)return s(e);throw e}if(!i&&"none"!==o.algorithm)return c(new Error("secretOrPrivateKey must have a value"));if(null!=i&&!(i instanceof p))try{i=d(i)}catch(e){try{i=h("string"==typeof i?Buffer.from(i):i)}catch(e){return c(new Error("secretOrPrivateKey is not valid key material"))}}if(u.alg.startsWith("HS")&&"secret"!==i.type)return c(new Error(`secretOrPrivateKey must be a symmetric key when using ${u.alg}`));if(/^(?:RS|PS|ES)/.test(u.alg)){if("private"!==i.type)return c(new Error(`secretOrPrivateKey must be an asymmetric key when using ${u.alg}`));if(!o.allowInsecureKeySizes&&!u.alg.startsWith("ES")&&void 0!==i.asymmetricKeyDetails&&i.asymmetricKeyDetails.modulusLength<2048)return c(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${u.alg}`))}if(void 0===r)return c(new Error("payload is required"));if(a){try{!function(e){g(y,!0,e,"payload")}(r)}catch(e){return c(e)}o.mutatePayload||(r=Object.assign({},r))}else{const e=w.filter(function(e){return void 0!==o[e]});if(e.length>0)return c(new Error("invalid "+e.join(",")+" option for "+typeof r+" payload"))}if(void 0!==r.exp&&void 0!==o.expiresIn)return c(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==r.nbf&&void 0!==o.notBefore)return c(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){g(E,!1,e,"options")}(o)}catch(e){return c(e)}if(!o.allowInvalidAsymmetricKeyTypes)try{t(u.alg,i)}catch(e){return c(e)}const l=r.iat||Math.floor(Date.now()/1e3);if(o.noTimestamp?delete r.iat:a&&(r.iat=l),void 0!==o.notBefore){try{r.nbf=e(o.notBefore,l)}catch(e){return c(e)}if(void 0===r.nbf)return c(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==o.expiresIn&&"object"==typeof r){try{r.exp=e(o.expiresIn,l)}catch(e){return c(e)}if(void 0===r.exp)return c(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(v).forEach(function(e){const t=v[e];if(void 0!==o[e]){if(void 0!==r[t])return c(new Error('Bad "options.'+e+'" option. The payload already has an "'+t+'" property.'));r[t]=o[e]}});const m=o.encoding||"utf8";if("function"!=typeof s){let e=n.sign({header:u,payload:r,secret:i,encoding:m});if(!o.allowInsecureKeySizes&&/^(?:RS|PS)/.test(u.alg)&&e.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${u.alg}`);return e}s=s&&f(s),n.createSign({header:u,privateKey:i,payload:r,encoding:m}).once("error",s).once("done",function(e){if(!o.allowInsecureKeySizes&&/^(?:RS|PS)/.test(u.alg)&&e.length<256)return s(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${u.alg}`));s(null,e)})}}var Mt=s(at?st:(at=1,st={decode:X(),verify:Pt(),sign:Dt(),JsonWebTokenError:z(),NotBeforeError:W(),TokenExpiredError:Y()}));const Bt=e(import.meta.url),{version:Kt}=Bt("../package.json");var Ft={id:"sso",handler:(e,t)=>{const{env:n,logger:i,services:o,database:s,getSchema:a}=t,u=n.KEYCLOAK_URL||"http://keycloak:8080",c=n.KEYCLOAK_REALM||"testing",l=n.KEYCLOAK_ADMIN_USER||"admin",f=n.KEYCLOAK_ADMIN_PASSWORD||"admin",p=n.PUBLIC_URL||"http://localhost:8055",h=n.MOBILE_APP_SCHEME||"finsnapp",d=Array.isArray(h)?h.map(e=>String(e).trim()):String(h).split(",").map(e=>e.trim()),m=d[0],E=n.MOBILE_APP_CALLBACK_PATH||"/auth/callback",y=n.GOOGLE_CALLBACK_PATH||"/auth/callback/google",g=n.APPLE_CLIENT_ID||"com.forumbandung.app",v=Array.isArray(g)?g.map(e=>String(e).trim().toLowerCase()):String(g).split(",").map(e=>e.trim().toLowerCase()),w=n.KEYCLOAK_CLIENT_ID||"admin-cli",S=n.COOKIE_DOMAIN||null,b="false"!==n.COOKIE_SECURE,$=n.COOKIE_SAME_SITE||"lax",I=n.SESSION_COOKIE_NAME||"directus_session_token",R=n.REFRESH_TOKEN_COOKIE_NAME||"directus_refresh_token",O=n.DEFAULT_ROLE_ID||null,A="directus_session_token";function L(e,r="/"){if(!e||"string"!=typeof e)return r;try{if(d.some(r=>e.startsWith(`${r}://`)))return e;if(e.startsWith("/")&&!e.startsWith("//")&&!e.startsWith("/\\"))return e;const r=new URL(e),t=new URL(p).origin;if(r.origin===t)return e}catch(e){}return i.warn(`⚠️ Warning: Blocked potentially unsafe redirect URL: "${e}". Defaulting to fallback: "${r}"`),r}const T=n.FCM_PROJECT_ID||null;async function N(){try{const e=await fetch(`${u}/realms/master/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"password",client_id:w,username:l,password:f}).toString()});if(!e.ok)throw new Error("Failed to get admin token");return(await e.json()).access_token}catch(e){return i.error("Error getting admin token:",e),null}}async function j(e,r){try{const t=await fetch(`${u}/admin/realms/${c}/users?email=${encodeURIComponent(r)}`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error("Failed to get user");const n=await t.json();return n.length>0?n[0].id:null}catch(e){return i.error("Error getting user ID:",e),null}}async function k(e,r){try{const t=await fetch(`${u}/admin/realms/${c}/users/${r}/logout`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});return t.ok||204===t.status}catch(e){return i.error("Error logging out user from Keycloak:",e),!1}}function P(e){if("browser"===e.query.type)return!0;if("mobile"===e.query.type)return!1;if(e.query.app_scheme||e.query.app_path)return!1;const r=e.headers["user-agent"]||"";return/Mozilla|Chrome|Safari|Firefox|Edge|Opera/i.test(r)&&!/Mobile.*App|ReactNative|Expo/i.test(r)}async function _(e,r){const t=e.headers.cookie;if(!t)return null;const n=t.split(";").map(e=>e.trim()).filter(e=>e.startsWith(`${r}=`)).map(e=>e.substring(r.length+1));if(0===n.length)return null;for(let e=0;e<n.length;e++){const t=n[e];try{const e=await fetch(`${p}/users/me`,{headers:{Cookie:`${r}=${t}`}});if(e.ok){return{token:t,userData:(await e.json()).data}}}catch(e){}}return null}async function C(e){const r=e.headers.cookie;if(!r)return null;const t=r.split(";").map(e=>e.trim()).map(e=>{const r=e.split("=");return r.length>1?r[1]:null}).filter(e=>e&&e.startsWith("eyJ")&&e.length>50);if(0===t.length)return null;for(let e=0;e<t.length;e++){const r=t[e];try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${r}`}});if(e.ok){return{token:r,userData:(await e.json()).data}}}catch(e){}}return null}async function x(e){const r=e.cookies[R];if(!r)return null;try{const e=await fetch(`${p}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:r})});if(e.ok){const r=(await e.json()).data.access_token,t=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${r}`}});if(t.ok){return{token:r,userData:(await t.json()).data}}}}catch(e){}return null}function D(e){const r=e.query.app_scheme;return r&&d.includes(r)?r:(r&&i.warn(`⚠️ Warning: App requested scheme '${r}', but it is not in .env. Falling back to '${m}'`),m)}n.FCM_CLIENT_EMAIL,n.FCM_PRIVATE_KEY&&n.FCM_PRIVATE_KEY.replace(/\\n/g,"\n"),n.FCM_WEBHOOK_SECRET,i.info("🚀 Mobile Auth Extension loaded"),i.info("📱 Allowed Mobile App Schemes: "+d.join(", ")),e.get("/health",(e,r)=>{r.json({status:"ok",service:"directus-extension-sso",version:Kt,allowed_schemes:d,fcm_enabled:!!T})}),e.get("/mobile-callback",async(e,r)=>{const t=P(e);try{let n=null;if(I!==A&&(n=await _(e,I)),n||(n=await _(e,A)),n||(n=await C(e)),n||(n=await x(e)),!n)return r.send("<html><body><h2>Authentication Failed</h2></body></html>");const{token:i,userData:o}=n,s=o.id,a=o.email,u=i;if(t){r.cookie(I,i,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),I!==A&&r.cookie(A,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";return t=L(t,"/"),r.redirect(t)}const c=D(e),l=`${c}://${(e.query.app_path||E).replace(/^\/+/,"")}?access_token=${u}&user_id=${s}&email=${encodeURIComponent(a||"")}`;return r.setHeader("Location",l),r.status(302).send(`<html><head><meta http-equiv="refresh" content="0;url=${l}"></head><body>Redirecting...</body></html>`)}catch(e){r.status(500).send(`<html><body><h2>Error</h2><p>${e.message}</p></body></html>`)}}),e.get("/google-callback",async(e,r)=>{const t=P(e);try{let o=null;if(e.query.access_token){o={token:e.query.access_token,refresh_token:e.query.refresh_token||null,expires:e.query.expires||null};try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${o.token}`}});if(e.ok){const r=await e.json();o.userData=r.data}else o=null}catch(e){o=null}}if(o||I===A||(o=await _(e,I)),o||(o=await _(e,A)),o||(o=await C(e)),o||(o=await x(e)),!o)return r.send("<html><body><h2>Authentication Failed</h2></body></html>");const{token:s,userData:a}=o,u=a.id,c=a.email,l=s;if(t){r.cookie(I,s,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),I!==A&&r.cookie(A,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";t=L(t,"/");const i="string"!=typeof(n=t)?"":n.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";default:return e}});return r.send(`<html><head><meta http-equiv="refresh" content="2;url=${i}"></head><body>Login Successful!</body></html>`)}const f=D(e),h=e.query.app_path||y,d=new URL(`${f}://${h.replace(/^\/+/,"")}`);return d.searchParams.set("access_token",l),d.searchParams.set("user_id",u),d.searchParams.set("email",c||""),d.searchParams.set("provider","google"),i.info("🚀 Performing direct 302 redirect to app: "+d.toString()),r.redirect(302,d.toString())}catch(e){r.status(500).send(`<html><body><h2>Error</h2><p>${e.message}</p></body></html>`)}var n}),e.get("/logout-clear",(e,r)=>{const t={httpOnly:!0,secure:b,sameSite:$,path:"/"};if(r.clearCookie(I,t),I!==A&&r.clearCookie(A,t),r.clearCookie(R,t),S){const e={...t,domain:S};r.clearCookie(I,e),I!==A&&r.clearCookie(A,e),r.clearCookie(R,e)}try{r.clearCookie(I,{...t,domain:".goyong.in"}),r.clearCookie(A,{...t,domain:".goyong.in"}),r.clearCookie(R,{...t,domain:".goyong.in"})}catch(e){}let n=e.query.redirect;return n?(n=L(n,"/"),i.info(`🧹 Cleared cookies and redirecting to: ${n}`),r.redirect(n)):(i.info("🧹 Cleared cookies successfully (no redirect provided)"),r.json({success:!0,message:"Cookies cleared successfully"}))}),e.post("/mobile-logout",async(e,r)=>{try{const t=e.headers.authorization,n=t?.replace("Bearer ","");if(!n)return r.status(400).json({error:"No token provided"});let i=null;try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${n}`}});if(e.ok){i=(await e.json()).data.email}}catch(e){}try{await fetch(`${p}/auth/logout`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({refresh_token:n})})}catch(e){}if(i)try{const e=await N();if(e){const r=await j(e,i);r&&await k(e,r)}}catch(e){}r.json({success:!0,message:"Logged out successfully"})}catch(e){r.status(500).json({error:e.message})}}),e.post("/delete-account",async(e,r)=>{try{const t=e.headers.authorization,n=t?.replace("Bearer ","");if(!n)return r.status(400).json({error:"No token provided"});let u=null,c=null;try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${n}`}});if(e.ok){const r=await e.json();u=r.data.id,c=r.data.email}}catch(e){i.error("[SSO] Error verifying token during account deletion:",e)}if(!u||!c)return r.status(401).json({error:"Invalid or expired token"});i.info(`[SSO] Deleting account for user: ${u} (${c})`);let l=0;try{const e=Mt.decode(n),r=e?.session;if(r){const e=await s("directus_sessions").where("token",r).delete();l+=e,i.info(`[SSO] Deleted ${e} session(s) by token for user ${u}`)}const t=await s("directus_sessions").where("user",u).delete();l+=t,i.info(`[SSO] Deleted ${t} additional session(s) by user ID for ${u}`)}catch(e){i.error("[SSO] Error deleting sessions:",e)}try{await fetch(`${p}/auth/logout`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({})}),i.info(`[SSO] Directus /auth/logout called successfully for user ${u}`)}catch(e){i.warn("[SSO] /auth/logout call failed (non-fatal):",e.message)}const{UsersService:f}=o,h=new f({schema:await a(),knex:s}),d=`DELETED_${Date.now()}_${c}`;await h.updateOne(u,{first_name:"DELETED",last_name:"ACCOUNT",status:"suspended",email:d,external_identifier:null,provider:"default"}),i.info(`[SSO] Soft-deleted user ID ${u} → email renamed to ${d}, total sessions cleared: ${l}`);try{const e=await N();if(e){const r=await j(e,c);r&&(await k(e,r),i.info(`[SSO] Logged out user ${c} from Keycloak`))}}catch(e){i.error("[SSO] Error during Keycloak logout:",e)}return r.json({success:!0,message:"Account deleted successfully, sessions cleared.",sessions_cleared:l})}catch(e){return i.error("[SSO] Account deletion failed:",e),r.status(500).json({error:e.message,message:"Failed to delete account"})}}),e.post("/apple-token",async(e,t)=>{const{identityToken:u,firstName:c,lastName:l}=e.body;if(i.info("🍎 Apple token exchange request received"),!u)return t.status(400).json({error:"identityToken is required",message:"Apple identityToken must be provided in the request body"});try{const e=async e=>{const[t,n,i]=e.split("."),o=JSON.parse(Buffer.from(t,"base64").toString()),s=JSON.parse(Buffer.from(n,"base64").toString());if("https://appleid.apple.com"!==s.iss)throw new Error("Invalid issuer");const a=[...v,"host.exp.exponent"],u=s.aud.toLowerCase();if(!a.includes(u))throw new Error(`Invalid audience: ${u}. Allowed: ${a.join(", ")}`);if(s.exp<Math.floor(Date.now()/1e3))throw new Error("Token expired");const c=await fetch("https://appleid.apple.com/auth/keys"),{keys:l}=await c.json(),f=l.find(e=>e.kid===o.kid);if(!f)throw new Error("Apple public key not found");const p=r.createPublicKey({key:f,format:"jwk"}),h=r.createVerify("RSA-SHA256");h.update(`${t}.${n}`);if(!h.verify(p,i,"base64url"))throw new Error("Invalid signature");return s},i=await e(u),{email:f,sub:p}=i;if(!f)throw new Error("Apple token did not contain an email");const{UsersService:h}=o,d=new h({schema:await a(),knex:s});let m,E=await d.readByQuery({filter:{_and:[{external_identifier:{_eq:p}},{provider:{_eq:"apple"}}]}}),y=E.length>0?E[0]:null;y||(E=await d.readByQuery({filter:{email:{_eq:f}}}),E.length>0&&(y=E[0],await d.updateOne(y.id,{external_identifier:p,provider:"apple"}))),y?m=y.id:(m=await d.createOne({email:f,first_name:c||"Apple User",last_name:l||"",role:O,status:"active",provider:"apple",external_identifier:p}),y=await d.readOne(m));const g={id:m,role:y.role||O,app_access:!0,admin_access:!1},w=Mt.sign(g,n.SECRET,{expiresIn:"7d",issuer:"directus"}),S={id:m,type:"refresh"},b=Mt.sign(S,n.SECRET,{expiresIn:"30d",issuer:"directus"});t.json({success:!0,data:{access_token:w,refresh_token:b,expires:604800,user:y},user_id:m,email:f,provider:"apple"})}catch(e){t.status(500).json({error:e.message,message:"Failed to verify Apple token"})}}),e.post("/bridge-token",async(e,r)=>{try{const t=e.headers.authorization,i=t?.replace("Bearer ","");if(!i)return r.status(400).json({error:"No token provided"});const o=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${i}`}});if(!o.ok)return r.status(401).json({error:"Invalid token"});const s={sub:(await o.json()).data.id,purpose:"bridge"},a=Mt.sign(s,n.SECRET,{expiresIn:"60s",issuer:"directus-sso"});r.json({success:!0,bridge_token:a})}catch(e){r.status(500).json({error:e.message})}}),e.get("/bridge",async(e,r)=>{const{token:t,bridge_token:o,redirect_uri:s,redirect:a}=e.query,u=L(s||a,"/"),c="true"===n.ENABLE_LEGACY_BRIDGE;let l=null,f=null;if(o)try{const e=Mt.verify(o,n.SECRET,{issuer:"directus-sso"});if("bridge"!==e.purpose)return r.status(400).json({error:"Invalid token purpose"});l=e.sub;const t={id:l,app_access:!0,admin_access:!1};f=Mt.sign(t,n.SECRET,{expiresIn:"7d",issuer:"directus"})}catch(e){return r.status(401).json({error:"Invalid or expired bridge token",message:e.message})}else{if(!t||!c)return r.status(400).json({error:"Secure bridge token required"});i.warn("⚠️ Warning: Legacy bridge token used. This flow is vulnerable to session fixation.");try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${t}`}});if(!e.ok)return r.status(401).json({error:"Invalid token"});l=(await e.json()).data.id,f=t}catch(e){return r.status(500).json({error:"Bridge failure",message:e.message})}}return r.cookie(I,f,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),I!==A&&r.cookie(A,f,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),r.redirect(u)})}};export{Ft as default};
|
|
1
|
+
import{createRequire as e}from"module";import r from"node:crypto";import t from"buffer";import n from"stream";import i from"util";import o from"crypto";function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,u,c,l,f,p,h,d,m,E,y,g,v,w,S,b,$,I,R,O,A,L,T,N,j,k,P,_,C,x,D={},M={exports:{}};function B(){return a||(a=1,function(e,r){var n=t,i=n.Buffer;function o(e,r){for(var t in e)r[t]=e[t]}function s(e,r,t){return i(e,r,t)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,r),r.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,r,t){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,r,t)},s.alloc=function(e,r,t){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==r?"string"==typeof t?n.fill(r,t):n.fill(r):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}}(M,M.exports)),M.exports}function K(){if(c)return u;c=1;var e=B().Buffer,r=n;function t(r){if(this.buffer=null,this.writable=!0,this.readable=!0,!r)return this.buffer=e.alloc(0),this;if("function"==typeof r.pipe)return this.buffer=e.alloc(0),r.pipe(this),this;if(r.length||"object"==typeof r)return this.buffer=r,this.writable=!1,process.nextTick(function(){this.emit("end",r),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof r+")")}return i.inherits(t,r),t.prototype.write=function(r){this.buffer=e.concat([this.buffer,e.from(r)]),this.emit("data",r)},t.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},u=t}function F(){if(h)return p;h=1;var e=B().Buffer,r=function(){if(f)return l;function e(e){return(e/8|0)+(e%8==0?0:1)}f=1;var r={ES256:e(256),ES384:e(384),ES512:e(521)};return l=function(e){var t=r[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}}(),t=128;function n(r){if(e.isBuffer(r))return r;if("string"==typeof r)return e.from(r,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function i(e,r,n){for(var i=0;r+i<n&&0===e[r+i];)++i;return e[r+i]>=t&&--i,i}return p={derToJose:function(t,i){t=n(t);var o=r(i),s=o+1,a=t.length,u=0;if(48!==t[u++])throw new Error('Could not find expected "seq"');var c=t[u++];if(129===c&&(c=t[u++]),a-u<c)throw new Error('"seq" specified length of "'+c+'", only "'+(a-u)+'" remaining');if(2!==t[u++])throw new Error('Could not find expected "int" for "r"');var l=t[u++];if(a-u-2<l)throw new Error('"r" specified length of "'+l+'", only "'+(a-u-2)+'" available');if(s<l)throw new Error('"r" specified length of "'+l+'", max of "'+s+'" is acceptable');var f=u;if(u+=l,2!==t[u++])throw new Error('Could not find expected "int" for "s"');var p=t[u++];if(a-u!==p)throw new Error('"s" specified length of "'+p+'", expected "'+(a-u)+'"');if(s<p)throw new Error('"s" specified length of "'+p+'", max of "'+s+'" is acceptable');var h=u;if((u+=p)!==a)throw new Error('Expected to consume entire buffer, but "'+(a-u)+'" bytes remain');var d=o-l,m=o-p,E=e.allocUnsafe(d+l+m+p);for(u=0;u<d;++u)E[u]=0;t.copy(E,u,f+Math.max(-d,0),f+l);for(var y=u=o;u<y+m;++u)E[u]=0;return t.copy(E,u,h+Math.max(-m,0),h+p),E=(E=E.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(o,s){o=n(o);var a=r(s),u=o.length;if(u!==2*a)throw new TypeError('"'+s+'" signatures must be "'+2*a+'" bytes, saw "'+u+'"');var c=i(o,0,a),l=i(o,a,o.length),f=a-c,p=a-l,h=2+f+1+1+p,d=h<t,m=e.allocUnsafe((d?2:3)+h),E=0;return m[E++]=48,d?m[E++]=h:(m[E++]=129,m[E++]=255&h),m[E++]=2,m[E++]=f,c<0?(m[E++]=0,E+=o.copy(m,E,0,a)):E+=o.copy(m,E,c,a),m[E++]=2,m[E++]=p,l<0?(m[E++]=0,o.copy(m,E,a)):o.copy(m,E,a+l),m}}}function U(){if(y)return E;y=1;var e,r=B().Buffer,n=o,s=F(),a=i,u="secret must be a string or buffer",c="key must be a string or a buffer",l="function"==typeof n.createPublicKey;function f(e){if(!r.isBuffer(e)&&"string"!=typeof e){if(!l)throw v(c);if("object"!=typeof e)throw v(c);if("string"!=typeof e.type)throw v(c);if("string"!=typeof e.asymmetricKeyType)throw v(c);if("function"!=typeof e.export)throw v(c)}}function p(e){if(!r.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw v("key must be a string, a buffer or an object")}function h(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function g(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 v(e){var r=[].slice.call(arguments,1),t=a.format.bind(a,e).apply(null,r);return new TypeError(t)}function w(e){var t;return t=e,r.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function S(e){return function(t,i){!function(e){if(!r.isBuffer(e)){if("string"==typeof e)return e;if(!l)throw v(u);if("object"!=typeof e)throw v(u);if("secret"!==e.type)throw v(u);if("function"!=typeof e.export)throw v(u)}}(i),t=w(t);var o=n.createHmac("sha"+e,i);return h((o.update(t),o.digest("base64")))}}l&&(c+=" or a KeyObject",u+="or a KeyObject");var b="timingSafeEqual"in n?function(e,r){return e.byteLength===r.byteLength&&n.timingSafeEqual(e,r)}:function(r,n){return e||(e=function(){if(m)return d;m=1;var e=t.Buffer,r=t.SlowBuffer;function n(r,t){if(!e.isBuffer(r)||!e.isBuffer(t))return!1;if(r.length!==t.length)return!1;for(var n=0,i=0;i<r.length;i++)n|=r[i]^t[i];return 0===n}d=n,n.install=function(){e.prototype.equal=r.prototype.equal=function(e){return n(this,e)}};var i=e.prototype.equal,o=r.prototype.equal;return n.restore=function(){e.prototype.equal=i,r.prototype.equal=o},d}()),e(r,n)};function $(e){return function(t,n,i){var o=S(e)(t,i);return b(r.from(n),r.from(o))}}function I(e){return function(r,t){p(t),r=w(r);var i=n.createSign("RSA-SHA"+e);return h((i.update(r),i.sign(t,"base64")))}}function R(e){return function(r,t,i){f(i),r=w(r),t=g(t);var o=n.createVerify("RSA-SHA"+e);return o.update(r),o.verify(i,t,"base64")}}function O(e){return function(r,t){p(t),r=w(r);var i=n.createSign("RSA-SHA"+e);return h((i.update(r),i.sign({key:t,padding:n.constants.RSA_PKCS1_PSS_PADDING,saltLength:n.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function A(e){return function(r,t,i){f(i),r=w(r),t=g(t);var o=n.createVerify("RSA-SHA"+e);return o.update(r),o.verify({key:i,padding:n.constants.RSA_PKCS1_PSS_PADDING,saltLength:n.constants.RSA_PSS_SALTLEN_DIGEST},t,"base64")}}function L(e){var r=I(e);return function(){var t=r.apply(null,arguments);return t=s.derToJose(t,"ES"+e)}}function T(e){var r=R(e);return function(t,n,i){return n=s.joseToDer(n,"ES"+e).toString("base64"),r(t,n,i)}}function N(){return function(){return""}}function j(){return function(e,r){return""===r}}return E=function(e){var r={hs:S,rs:I,ps:O,es:L,none:N},t={hs:$,rs:R,ps:A,es:T,none:j},n=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!n)throw v('"%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".',e);var i=(n[1]||n[3]).toLowerCase(),o=n[2];return{sign:r[i](o),verify:t[i](o)}}}function G(){if(v)return g;v=1;var e=t.Buffer;return g=function(r){return"string"==typeof r?r:"number"==typeof r||e.isBuffer(r)?r.toString():JSON.stringify(r)}}function q(){if(S)return w;S=1;var e=B().Buffer,r=K(),t=U(),o=n,s=G(),a=i;function u(r,t){return e.from(r,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(e){var r=e.header,n=e.payload,i=e.secret||e.privateKey,o=e.encoding,c=t(r.alg),l=function(e,r,t){t=t||"utf8";var n=u(s(e),"binary"),i=u(s(r),t);return a.format("%s.%s",n,i)}(r,n,o),f=c.sign(l,i);return a.format("%s.%s",l,f)}function l(e){var t=e.secret;if(t=null==(t=null==t?e.privateKey:t)?e.key:t,!0===/^hs/i.test(e.header.alg)&&null==t)throw new TypeError("secret must be a string or buffer or a KeyObject");var n=new r(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new r(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))}return a.inherits(l,o),l.prototype.sign=function(){try{var e=c({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")}},l.sign=c,w=l}function H(){if($)return b;$=1;var e=B().Buffer,r=K(),t=U(),o=n,s=G(),a=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function u(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}function c(r){var t=r.split(".",1)[0];return u(e.from(t,"base64").toString("binary"))}function l(e){return e.split(".")[2]}function f(e){return a.test(e)&&!!c(e)}function p(e,r,n){if(!r){var i=new Error("Missing algorithm parameter for jws.verify");throw i.code="MISSING_ALGORITHM",i}var o=l(e=s(e)),a=function(e){return e.split(".",2).join(".")}(e);return t(r).verify(a,o,n)}function h(r,t){if(t=t||{},!f(r=s(r)))return null;var n=c(r);if(!n)return null;var i=function(r,t){t=t||"utf8";var n=r.split(".")[1];return e.from(n,"base64").toString(t)}(r);return("JWT"===n.typ||t.json)&&(i=JSON.parse(i,t.encoding)),{header:n,payload:i,signature:l(r)}}function d(e){var t=(e=e||{}).secret;if(t=null==(t=null==t?e.publicKey:t)?e.key:t,!0===/^hs/i.test(e.algorithm)&&null==t)throw new TypeError("secret must be a string or buffer or a KeyObject");var n=new r(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new r(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))}return i.inherits(d,o),d.prototype.verify=function(){try{var e=p(this.signature.buffer,this.algorithm,this.key.buffer),r=h(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")}},d.decode=h,d.isValid=f,d.verify=p,b=d}function V(){if(I)return D;I=1;var e=q(),r=H();return D.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],D.sign=e.sign,D.verify=r.verify,D.decode=r.decode,D.isValid=r.isValid,D.createSign=function(r){return new e(r)},D.createVerify=function(e){return new r(e)},D}function X(){if(O)return R;O=1;var e=V();return R=function(r,t){t=t||{};var n=e.decode(r,t);if(!n)return null;var i=n.payload;if("string"==typeof i)try{var o=JSON.parse(i);null!==o&&"object"==typeof o&&(i=o)}catch(e){}return!0===t.complete?{header:n.header,payload:i,signature:n.signature}:i},R}function z(){if(L)return A;L=1;var e=function(e,r){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,r&&(this.inner=r)};return(e.prototype=Object.create(Error.prototype)).constructor=e,A=e}function W(){if(N)return T;N=1;var e=z(),r=function(r,t){e.call(this,r),this.name="NotBeforeError",this.date=t};return(r.prototype=Object.create(e.prototype)).constructor=r,T=r}function Y(){if(k)return j;k=1;var e=z(),r=function(r,t){e.call(this,r),this.name="TokenExpiredError",this.expiredAt=t};return(r.prototype=Object.create(e.prototype)).constructor=r,j=r}function J(){if(_)return P;_=1;var e=1e3,r=60*e,t=60*r,n=24*t,i=7*n,o=365.25*n;function s(e,r,t,n){var i=r>=1.5*t;return Math.round(e/t)+" "+n+(i?"s":"")}return P=function(a,u){u=u||{};var c=typeof a;if("string"===c&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var u=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return u*o;case"weeks":case"week":case"w":return u*i;case"days":case"day":case"d":return u*n;case"hours":case"hour":case"hrs":case"hr":case"h":return u*t;case"minutes":case"minute":case"mins":case"min":case"m":return u*r;case"seconds":case"second":case"secs":case"sec":case"s":return u*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}(a);if("number"===c&&isFinite(a))return u.long?function(i){var o=Math.abs(i);if(o>=n)return s(i,o,n,"day");if(o>=t)return s(i,o,t,"hour");if(o>=r)return s(i,o,r,"minute");if(o>=e)return s(i,o,e,"second");return i+" ms"}(a):function(i){var o=Math.abs(i);if(o>=n)return Math.round(i/n)+"d";if(o>=t)return Math.round(i/t)+"h";if(o>=r)return Math.round(i/r)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}function Z(){if(x)return C;x=1;var e=J();return C=function(r,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof r){var i=e(r);if(void 0===i)return;return Math.floor(n+i/1e3)}return"number"==typeof r?n+r:void 0}}var Q,ee,re,te,ne,ie,oe,se,ae,ue,ce,le,fe,pe,he,de,me,Ee,ye,ge,ve,we,Se,be,$e,Ie,Re,Oe,Ae,Le,Te,Ne,je,ke,Pe,_e,Ce,xe,De,Me,Be,Ke,Fe,Ue,Ge,qe,He,Ve,Xe,ze,We,Ye,Je,Ze,Qe,er,rr,tr,nr,ir,or,sr,ar,ur,cr,lr,fr,pr,hr,dr,mr,Er,yr,gr,vr,wr,Sr,br,$r,Ir,Rr,Or,Ar,Lr,Tr,Nr,jr,kr,Pr,_r,Cr,xr,Dr,Mr,Br,Kr,Fr,Ur,Gr,qr,Hr,Vr,Xr,zr,Wr,Yr,Jr,Zr,Qr,et,rt,tt,nt,it,ot,st,at,ut={exports:{}};function ct(){if(ee)return Q;ee=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return Q={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}function lt(){if(te)return re;te=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return re=e}function ft(){return ne||(ne=1,function(e,r){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=ct(),o=lt(),s=(r=e.exports={}).re=[],a=r.safeRe=[],u=r.src=[],c=r.safeSrc=[],l=r.t={};let f=0;const p="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[p,n]],d=(e,r,t)=>{const n=(e=>{for(const[r,t]of h)e=e.split(`${r}*`).join(`${r}{0,${t}}`).split(`${r}+`).join(`${r}{1,${t}}`);return e})(r),i=f++;o(e,i,r),l[e]=i,u[i]=r,c[i]=n,s[i]=new RegExp(r,t?"g":void 0),a[i]=new RegExp(n,t?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),d("MAINVERSION",`(${u[l.NUMERICIDENTIFIER]})\\.(${u[l.NUMERICIDENTIFIER]})\\.(${u[l.NUMERICIDENTIFIER]})`),d("MAINVERSIONLOOSE",`(${u[l.NUMERICIDENTIFIERLOOSE]})\\.(${u[l.NUMERICIDENTIFIERLOOSE]})\\.(${u[l.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASEIDENTIFIER",`(?:${u[l.NONNUMERICIDENTIFIER]}|${u[l.NUMERICIDENTIFIER]})`),d("PRERELEASEIDENTIFIERLOOSE",`(?:${u[l.NONNUMERICIDENTIFIER]}|${u[l.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASE",`(?:-(${u[l.PRERELEASEIDENTIFIER]}(?:\\.${u[l.PRERELEASEIDENTIFIER]})*))`),d("PRERELEASELOOSE",`(?:-?(${u[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[l.PRERELEASEIDENTIFIERLOOSE]})*))`),d("BUILDIDENTIFIER",`${p}+`),d("BUILD",`(?:\\+(${u[l.BUILDIDENTIFIER]}(?:\\.${u[l.BUILDIDENTIFIER]})*))`),d("FULLPLAIN",`v?${u[l.MAINVERSION]}${u[l.PRERELEASE]}?${u[l.BUILD]}?`),d("FULL",`^${u[l.FULLPLAIN]}$`),d("LOOSEPLAIN",`[v=\\s]*${u[l.MAINVERSIONLOOSE]}${u[l.PRERELEASELOOSE]}?${u[l.BUILD]}?`),d("LOOSE",`^${u[l.LOOSEPLAIN]}$`),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE",`${u[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),d("XRANGEIDENTIFIER",`${u[l.NUMERICIDENTIFIER]}|x|X|\\*`),d("XRANGEPLAIN",`[v=\\s]*(${u[l.XRANGEIDENTIFIER]})(?:\\.(${u[l.XRANGEIDENTIFIER]})(?:\\.(${u[l.XRANGEIDENTIFIER]})(?:${u[l.PRERELEASE]})?${u[l.BUILD]}?)?)?`),d("XRANGEPLAINLOOSE",`[v=\\s]*(${u[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[l.XRANGEIDENTIFIERLOOSE]})(?:${u[l.PRERELEASELOOSE]})?${u[l.BUILD]}?)?)?`),d("XRANGE",`^${u[l.GTLT]}\\s*${u[l.XRANGEPLAIN]}$`),d("XRANGELOOSE",`^${u[l.GTLT]}\\s*${u[l.XRANGEPLAINLOOSE]}$`),d("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),d("COERCE",`${u[l.COERCEPLAIN]}(?:$|[^\\d])`),d("COERCEFULL",u[l.COERCEPLAIN]+`(?:${u[l.PRERELEASE]})?`+`(?:${u[l.BUILD]})?(?:$|[^\\d])`),d("COERCERTL",u[l.COERCE],!0),d("COERCERTLFULL",u[l.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM",`(\\s*)${u[l.LONETILDE]}\\s+`,!0),r.tildeTrimReplace="$1~",d("TILDE",`^${u[l.LONETILDE]}${u[l.XRANGEPLAIN]}$`),d("TILDELOOSE",`^${u[l.LONETILDE]}${u[l.XRANGEPLAINLOOSE]}$`),d("LONECARET","(?:\\^)"),d("CARETTRIM",`(\\s*)${u[l.LONECARET]}\\s+`,!0),r.caretTrimReplace="$1^",d("CARET",`^${u[l.LONECARET]}${u[l.XRANGEPLAIN]}$`),d("CARETLOOSE",`^${u[l.LONECARET]}${u[l.XRANGEPLAINLOOSE]}$`),d("COMPARATORLOOSE",`^${u[l.GTLT]}\\s*(${u[l.LOOSEPLAIN]})$|^$`),d("COMPARATOR",`^${u[l.GTLT]}\\s*(${u[l.FULLPLAIN]})$|^$`),d("COMPARATORTRIM",`(\\s*)${u[l.GTLT]}\\s*(${u[l.LOOSEPLAIN]}|${u[l.XRANGEPLAIN]})`,!0),r.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE",`^\\s*(${u[l.XRANGEPLAIN]})\\s+-\\s+(${u[l.XRANGEPLAIN]})\\s*$`),d("HYPHENRANGELOOSE",`^\\s*(${u[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[l.XRANGEPLAINLOOSE]})\\s*$`),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(ut,ut.exports)),ut.exports}function pt(){if(oe)return ie;oe=1;const e=Object.freeze({loose:!0}),r=Object.freeze({});return ie=t=>t?"object"!=typeof t?e:t:r}function ht(){if(ae)return se;ae=1;const e=/^[0-9]+$/,r=(r,t)=>{if("number"==typeof r&&"number"==typeof t)return r===t?0:r<t?-1:1;const n=e.test(r),i=e.test(t);return n&&i&&(r=+r,t=+t),r===t?0:n&&!i?-1:i&&!n?1:r<t?-1:1};return se={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}}function dt(){if(ce)return ue;ce=1;const e=lt(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:t}=ct(),{safeRe:n,t:i}=ft(),o=pt(),{compareIdentifiers:s}=ht();class a{constructor(s,u){if(u=o(u),s instanceof a){if(s.loose===!!u.loose&&s.includePrerelease===!!u.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>r)throw new TypeError(`version is longer than ${r} characters`);e("SemVer",s,u),this.options=u,this.loose=!!u.loose,this.includePrerelease=!!u.includePrerelease;const c=s.trim().match(u.loose?n[i.LOOSE]:n[i.FULL]);if(!c)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+c[1],this.minor=+c[2],this.patch=+c[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");c[4]?this.prerelease=c[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const r=+e;if(r>=0&&r<t)return r}return e}):this.prerelease=[],this.build=c[5]?c[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(r){if(e("SemVer.compare",this.version,this.options,r),!(r instanceof a)){if("string"==typeof r&&r===this.version)return 0;r=new a(r,this.options)}return r.version===this.version?0:this.compareMain(r)||this.comparePre(r)}compareMain(e){return e instanceof a||(e=new a(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(r){if(r instanceof a||(r=new a(r,this.options)),this.prerelease.length&&!r.prerelease.length)return-1;if(!this.prerelease.length&&r.prerelease.length)return 1;if(!this.prerelease.length&&!r.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],i=r.prerelease[t];if(e("prerelease compare",t,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++t)}compareBuild(r){r instanceof a||(r=new a(r,this.options));let t=0;do{const n=this.build[t],i=r.build[t];if(e("build compare",t,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++t)}inc(e,r,t){if(e.startsWith("pre")){if(!r&&!1===t)throw new Error("invalid increment argument: identifier is empty");if(r){const e=`-${r}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,t),this.inc("pre",r,t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",r,t),this.inc("pre",r,t);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;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":{const e=Number(t)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(r===this.prerelease.join(".")&&!1===t)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(r){let n=[r,e];!1===t&&(n=[r]),0===s(this.prerelease[0],r)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return ue=a}function mt(){if(fe)return le;fe=1;const e=dt();return le=(r,t,n=!1)=>{if(r instanceof e)return r;try{return new e(r,t)}catch(e){if(!n)return null;throw e}},le}function Et(){if(Te)return Le;Te=1;const e=dt();return Le=(r,t,n)=>new e(r,n).compare(new e(t,n))}function yt(){if(Ce)return _e;Ce=1;const e=dt();return _e=(r,t,n)=>{const i=new e(r,n),o=new e(t,n);return i.compare(o)||i.compareBuild(o)}}function gt(){if(Fe)return Ke;Fe=1;const e=Et();return Ke=(r,t,n)=>e(r,t,n)>0}function vt(){if(Ge)return Ue;Ge=1;const e=Et();return Ue=(r,t,n)=>e(r,t,n)<0}function wt(){if(He)return qe;He=1;const e=Et();return qe=(r,t,n)=>0===e(r,t,n)}function St(){if(Xe)return Ve;Xe=1;const e=Et();return Ve=(r,t,n)=>0!==e(r,t,n)}function bt(){if(We)return ze;We=1;const e=Et();return ze=(r,t,n)=>e(r,t,n)>=0}function $t(){if(Je)return Ye;Je=1;const e=Et();return Ye=(r,t,n)=>e(r,t,n)<=0}function It(){if(Qe)return Ze;Qe=1;const e=wt(),r=St(),t=gt(),n=bt(),i=vt(),o=$t();return Ze=(s,a,u,c)=>{switch(a){case"===":return"object"==typeof s&&(s=s.version),"object"==typeof u&&(u=u.version),s===u;case"!==":return"object"==typeof s&&(s=s.version),"object"==typeof u&&(u=u.version),s!==u;case"":case"=":case"==":return e(s,u,c);case"!=":return r(s,u,c);case">":return t(s,u,c);case">=":return n(s,u,c);case"<":return i(s,u,c);case"<=":return o(s,u,c);default:throw new TypeError(`Invalid operator: ${a}`)}}}function Rt(){if(or)return ir;or=1;const e=/\s+/g;class r{constructor(t,o){if(o=n(o),t instanceof r)return t.loose===!!o.loose&&t.includePrerelease===!!o.includePrerelease?t:new r(t.raw,o);if(t instanceof i)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=o,this.loose=!!o.loose,this.includePrerelease=!!o.includePrerelease,this.raw=t.trim().replace(e," "),this.set=this.raw.split("||").map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter(e=>!d(e[0])),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const r=this.set[e];for(let e=0;e<r.length;e++)e>0&&(this.formatted+=" "),this.formatted+=r[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const r=((this.options.includePrerelease&&p)|(this.options.loose&&h))+":"+e,n=t.get(r);if(n)return n;const s=this.options.loose,m=s?a[u.HYPHENRANGELOOSE]:a[u.HYPHENRANGE];e=e.replace(m,A(this.options.includePrerelease)),o("hyphen replace",e),e=e.replace(a[u.COMPARATORTRIM],c),o("comparator trim",e),e=e.replace(a[u.TILDETRIM],l),o("tilde trim",e),e=e.replace(a[u.CARETTRIM],f),o("caret trim",e);let E=e.split(" ").map(e=>y(e,this.options)).join(" ").split(/\s+/).map(e=>O(e,this.options));s&&(E=E.filter(e=>(o("loose invalid filter",e,this.options),!!e.match(a[u.COMPARATORLOOSE])))),o("range list",E);const g=new Map,v=E.map(e=>new i(e,this.options));for(const e of v){if(d(e))return[e];g.set(e.value,e)}g.size>1&&g.has("")&&g.delete("");const w=[...g.values()];return t.set(r,w),w}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Range is required");return this.set.some(r=>E(r,t)&&e.set.some(e=>E(e,t)&&r.every(r=>e.every(e=>r.intersects(e,t)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new s(e,this.options)}catch(e){return!1}for(let r=0;r<this.set.length;r++)if(L(this.set[r],e,this.options))return!0;return!1}}ir=r;const t=new(nr?tr:(nr=1,tr=class{constructor(){this.max=1e3,this.map=new Map}get(e){const r=this.map.get(e);return void 0===r?void 0:(this.map.delete(e),this.map.set(e,r),r)}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&void 0!==r){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,r)}return this}})),n=pt(),i=Ot(),o=lt(),s=dt(),{safeRe:a,t:u,comparatorTrimReplace:c,tildeTrimReplace:l,caretTrimReplace:f}=ft(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:h}=ct(),d=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,E=(e,r)=>{let t=!0;const n=e.slice();let i=n.pop();for(;t&&n.length;)t=n.every(e=>i.intersects(e,r)),i=n.pop();return t},y=(e,r)=>(e=e.replace(a[u.BUILD],""),o("comp",e,r),e=S(e,r),o("caret",e),e=v(e,r),o("tildes",e),e=$(e,r),o("xrange",e),e=R(e,r),o("stars",e),e),g=e=>!e||"x"===e.toLowerCase()||"*"===e,v=(e,r)=>e.trim().split(/\s+/).map(e=>w(e,r)).join(" "),w=(e,r)=>{const t=r.loose?a[u.TILDELOOSE]:a[u.TILDE];return e.replace(t,(r,t,n,i,s)=>{let a;return o("tilde",e,r,t,n,i,s),g(t)?a="":g(n)?a=`>=${t}.0.0 <${+t+1}.0.0-0`:g(i)?a=`>=${t}.${n}.0 <${t}.${+n+1}.0-0`:s?(o("replaceTilde pr",s),a=`>=${t}.${n}.${i}-${s} <${t}.${+n+1}.0-0`):a=`>=${t}.${n}.${i} <${t}.${+n+1}.0-0`,o("tilde return",a),a})},S=(e,r)=>e.trim().split(/\s+/).map(e=>b(e,r)).join(" "),b=(e,r)=>{o("caret",e,r);const t=r.loose?a[u.CARETLOOSE]:a[u.CARET],n=r.includePrerelease?"-0":"";return e.replace(t,(r,t,i,s,a)=>{let u;return o("caret",e,r,t,i,s,a),g(t)?u="":g(i)?u=`>=${t}.0.0${n} <${+t+1}.0.0-0`:g(s)?u="0"===t?`>=${t}.${i}.0${n} <${t}.${+i+1}.0-0`:`>=${t}.${i}.0${n} <${+t+1}.0.0-0`:a?(o("replaceCaret pr",a),u="0"===t?"0"===i?`>=${t}.${i}.${s}-${a} <${t}.${i}.${+s+1}-0`:`>=${t}.${i}.${s}-${a} <${t}.${+i+1}.0-0`:`>=${t}.${i}.${s}-${a} <${+t+1}.0.0-0`):(o("no pr"),u="0"===t?"0"===i?`>=${t}.${i}.${s}${n} <${t}.${i}.${+s+1}-0`:`>=${t}.${i}.${s}${n} <${t}.${+i+1}.0-0`:`>=${t}.${i}.${s} <${+t+1}.0.0-0`),o("caret return",u),u})},$=(e,r)=>(o("replaceXRanges",e,r),e.split(/\s+/).map(e=>I(e,r)).join(" ")),I=(e,r)=>{e=e.trim();const t=r.loose?a[u.XRANGELOOSE]:a[u.XRANGE];return e.replace(t,(t,n,i,s,a,u)=>{o("xRange",e,t,n,i,s,a,u);const c=g(i),l=c||g(s),f=l||g(a),p=f;return"="===n&&p&&(n=""),u=r.includePrerelease?"-0":"",c?t=">"===n||"<"===n?"<0.0.0-0":"*":n&&p?(l&&(s=0),a=0,">"===n?(n=">=",l?(i=+i+1,s=0,a=0):(s=+s+1,a=0)):"<="===n&&(n="<",l?i=+i+1:s=+s+1),"<"===n&&(u="-0"),t=`${n+i}.${s}.${a}${u}`):l?t=`>=${i}.0.0${u} <${+i+1}.0.0-0`:f&&(t=`>=${i}.${s}.0${u} <${i}.${+s+1}.0-0`),o("xRange return",t),t})},R=(e,r)=>(o("replaceStars",e,r),e.trim().replace(a[u.STAR],"")),O=(e,r)=>(o("replaceGTE0",e,r),e.trim().replace(a[r.includePrerelease?u.GTE0PRE:u.GTE0],"")),A=e=>(r,t,n,i,o,s,a,u,c,l,f,p)=>`${t=g(n)?"":g(i)?`>=${n}.0.0${e?"-0":""}`:g(o)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${t}`:`>=${t}${e?"-0":""}`} ${u=g(c)?"":g(l)?`<${+c+1}.0.0-0`:g(f)?`<${c}.${+l+1}.0-0`:p?`<=${c}.${l}.${f}-${p}`:e?`<${c}.${l}.${+f+1}-0`:`<=${u}`}`.trim(),L=(e,r,t)=>{for(let t=0;t<e.length;t++)if(!e[t].test(r))return!1;if(r.prerelease.length&&!t.includePrerelease){for(let t=0;t<e.length;t++)if(o(e[t].semver),e[t].semver!==i.ANY&&e[t].semver.prerelease.length>0){const n=e[t].semver;if(n.major===r.major&&n.minor===r.minor&&n.patch===r.patch)return!0}return!1}return!0};return ir}function Ot(){if(ar)return sr;ar=1;const e=Symbol("SemVer ANY");class r{static get ANY(){return e}constructor(n,i){if(i=t(i),n instanceof r){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),s("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(r){const t=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],o=r.match(t);if(!o)throw new TypeError(`Invalid comparator: ${r}`);this.operator=void 0!==o[1]?o[1]:"","="===this.operator&&(this.operator=""),o[2]?this.semver=new a(o[2],this.options.loose):this.semver=e}toString(){return this.value}test(r){if(s("Comparator.test",r,this.options.loose),this.semver===e||r===e)return!0;if("string"==typeof r)try{r=new a(r,this.options)}catch(e){return!1}return o(r,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof r))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new u(e.value,n).test(this.value):""===e.operator?""===e.value||new u(this.value,n).test(e.semver):(!(n=t(n)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!n.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&(!(!this.operator.startsWith(">")||!e.operator.startsWith(">"))||(!(!this.operator.startsWith("<")||!e.operator.startsWith("<"))||(!(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))||(!!(o(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(o(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}sr=r;const t=pt(),{safeRe:n,t:i}=ft(),o=It(),s=lt(),a=dt(),u=Rt();return sr}function At(){if(cr)return ur;cr=1;const e=Rt();return ur=(r,t,n)=>{try{t=new e(t,n)}catch(e){return!1}return t.test(r)},ur}function Lt(){if(vr)return gr;vr=1;const e=Rt();return gr=(r,t)=>{try{return new e(r,t).range||"*"}catch(e){return null}},gr}function Tt(){if(Sr)return wr;Sr=1;const e=dt(),r=Ot(),{ANY:t}=r,n=Rt(),i=At(),o=gt(),s=vt(),a=$t(),u=bt();return wr=(c,l,f,p)=>{let h,d,m,E,y;switch(c=new e(c,p),l=new n(l,p),f){case">":h=o,d=a,m=s,E=">",y=">=";break;case"<":h=s,d=u,m=o,E="<",y="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(c,l,p))return!1;for(let e=0;e<l.set.length;++e){const n=l.set[e];let i=null,o=null;if(n.forEach(e=>{e.semver===t&&(e=new r(">=0.0.0")),i=i||e,o=o||e,h(e.semver,i.semver,p)?i=e:m(e.semver,o.semver,p)&&(o=e)}),i.operator===E||i.operator===y)return!1;if((!o.operator||o.operator===E)&&d(c,o.semver))return!1;if(o.operator===y&&m(c,o.semver))return!1}return!0},wr}function Nt(){if(Pr)return kr;Pr=1;const e=ft(),r=ct(),t=dt(),n=ht(),i=mt(),o=function(){if(he)return pe;he=1;const e=mt();return pe=(r,t)=>{const n=e(r,t);return n?n.version:null},pe}(),s=function(){if(me)return de;me=1;const e=mt();return de=(r,t)=>{const n=e(r.trim().replace(/^[=v]+/,""),t);return n?n.version:null},de}(),a=function(){if(ye)return Ee;ye=1;const e=dt();return Ee=(r,t,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new e(r instanceof e?r.version:r,n).inc(t,i,o).version}catch(e){return null}},Ee}(),u=function(){if(ve)return ge;ve=1;const e=mt();return ge=(r,t)=>{const n=e(r,null,!0),i=e(t,null,!0),o=n.compare(i);if(0===o)return null;const s=o>0,a=s?n:i,u=s?i:n,c=!!a.prerelease.length;if(u.prerelease.length&&!c){if(!u.patch&&!u.minor)return"major";if(0===u.compareMain(a))return u.minor&&!u.patch?"minor":"patch"}const l=c?"pre":"";return n.major!==i.major?l+"major":n.minor!==i.minor?l+"minor":n.patch!==i.patch?l+"patch":"prerelease"}}(),c=function(){if(Se)return we;Se=1;const e=dt();return we=(r,t)=>new e(r,t).major}(),l=function(){if($e)return be;$e=1;const e=dt();return be=(r,t)=>new e(r,t).minor}(),f=function(){if(Re)return Ie;Re=1;const e=dt();return Ie=(r,t)=>new e(r,t).patch}(),p=function(){if(Ae)return Oe;Ae=1;const e=mt();return Oe=(r,t)=>{const n=e(r,t);return n&&n.prerelease.length?n.prerelease:null},Oe}(),h=Et(),d=function(){if(je)return Ne;je=1;const e=Et();return Ne=(r,t,n)=>e(t,r,n)}(),m=function(){if(Pe)return ke;Pe=1;const e=Et();return ke=(r,t)=>e(r,t,!0)}(),E=yt(),y=function(){if(De)return xe;De=1;const e=yt();return xe=(r,t)=>r.sort((r,n)=>e(r,n,t))}(),g=function(){if(Be)return Me;Be=1;const e=yt();return Me=(r,t)=>r.sort((r,n)=>e(n,r,t))}(),v=gt(),w=vt(),S=wt(),b=St(),$=bt(),I=$t(),R=It(),O=function(){if(rr)return er;rr=1;const e=dt(),r=mt(),{safeRe:t,t:n}=ft();return er=(i,o)=>{if(i instanceof e)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let s=null;if((o=o||{}).rtl){const e=o.includePrerelease?t[n.COERCERTLFULL]:t[n.COERCERTL];let r;for(;(r=e.exec(i))&&(!s||s.index+s[0].length!==i.length);)s&&r.index+r[0].length===s.index+s[0].length||(s=r),e.lastIndex=r.index+r[1].length+r[2].length;e.lastIndex=-1}else s=i.match(o.includePrerelease?t[n.COERCEFULL]:t[n.COERCE]);if(null===s)return null;const a=s[2],u=s[3]||"0",c=s[4]||"0",l=o.includePrerelease&&s[5]?`-${s[5]}`:"",f=o.includePrerelease&&s[6]?`+${s[6]}`:"";return r(`${a}.${u}.${c}${l}${f}`,o)},er}(),A=Ot(),L=Rt(),T=At(),N=function(){if(fr)return lr;fr=1;const e=Rt();return lr=(r,t)=>new e(r,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" ")),lr}(),j=function(){if(hr)return pr;hr=1;const e=dt(),r=Rt();return pr=(t,n,i)=>{let o=null,s=null,a=null;try{a=new r(n,i)}catch(e){return null}return t.forEach(r=>{a.test(r)&&(o&&-1!==s.compare(r)||(o=r,s=new e(o,i)))}),o},pr}(),k=function(){if(mr)return dr;mr=1;const e=dt(),r=Rt();return dr=(t,n,i)=>{let o=null,s=null,a=null;try{a=new r(n,i)}catch(e){return null}return t.forEach(r=>{a.test(r)&&(o&&1!==s.compare(r)||(o=r,s=new e(o,i)))}),o},dr}(),P=function(){if(yr)return Er;yr=1;const e=dt(),r=Rt(),t=gt();return Er=(n,i)=>{n=new r(n,i);let o=new e("0.0.0");if(n.test(o))return o;if(o=new e("0.0.0-0"),n.test(o))return o;o=null;for(let r=0;r<n.set.length;++r){const i=n.set[r];let s=null;i.forEach(r=>{const n=new e(r.semver.version);switch(r.operator){case">":0===n.prerelease.length?n.patch++:n.prerelease.push(0),n.raw=n.format();case"":case">=":s&&!t(n,s)||(s=n);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${r.operator}`)}}),!s||o&&!t(o,s)||(o=s)}return o&&n.test(o)?o:null},Er}(),_=Lt(),C=Tt(),x=function(){if($r)return br;$r=1;const e=Tt();return br=(r,t,n)=>e(r,t,">",n),br}(),D=function(){if(Rr)return Ir;Rr=1;const e=Tt();return Ir=(r,t,n)=>e(r,t,"<",n),Ir}(),M=function(){if(Ar)return Or;Ar=1;const e=Rt();return Or=(r,t,n)=>(r=new e(r,n),t=new e(t,n),r.intersects(t,n))}(),B=function(){if(Tr)return Lr;Tr=1;const e=At(),r=Et();return Lr=(t,n,i)=>{const o=[];let s=null,a=null;const u=t.sort((e,t)=>r(e,t,i));for(const r of u)e(r,n,i)?(a=r,s||(s=r)):(a&&o.push([s,a]),a=null,s=null);s&&o.push([s,null]);const c=[];for(const[e,r]of o)e===r?c.push(e):r||e!==u[0]?r?e===u[0]?c.push(`<=${r}`):c.push(`${e} - ${r}`):c.push(`>=${e}`):c.push("*");const l=c.join(" || "),f="string"==typeof n.raw?n.raw:String(n);return l.length<f.length?l:n},Lr}(),K=function(){if(jr)return Nr;jr=1;const e=Rt(),r=Ot(),{ANY:t}=r,n=At(),i=Et(),o=[new r(">=0.0.0-0")],s=[new r(">=0.0.0")],a=(e,r,a)=>{if(e===r)return!0;if(1===e.length&&e[0].semver===t){if(1===r.length&&r[0].semver===t)return!0;e=a.includePrerelease?o:s}if(1===r.length&&r[0].semver===t){if(a.includePrerelease)return!0;r=s}const l=new Set;let f,p,h,d,m,E,y;for(const r of e)">"===r.operator||">="===r.operator?f=u(f,r,a):"<"===r.operator||"<="===r.operator?p=c(p,r,a):l.add(r.semver);if(l.size>1)return null;if(f&&p){if(h=i(f.semver,p.semver,a),h>0)return null;if(0===h&&(">="!==f.operator||"<="!==p.operator))return null}for(const e of l){if(f&&!n(e,String(f),a))return null;if(p&&!n(e,String(p),a))return null;for(const t of r)if(!n(e,String(t),a))return!1;return!0}let g=!(!p||a.includePrerelease||!p.semver.prerelease.length)&&p.semver,v=!(!f||a.includePrerelease||!f.semver.prerelease.length)&&f.semver;g&&1===g.prerelease.length&&"<"===p.operator&&0===g.prerelease[0]&&(g=!1);for(const e of r){if(y=y||">"===e.operator||">="===e.operator,E=E||"<"===e.operator||"<="===e.operator,f)if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),">"===e.operator||">="===e.operator){if(d=u(f,e,a),d===e&&d!==f)return!1}else if(">="===f.operator&&!n(f.semver,String(e),a))return!1;if(p)if(g&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===g.major&&e.semver.minor===g.minor&&e.semver.patch===g.patch&&(g=!1),"<"===e.operator||"<="===e.operator){if(m=c(p,e,a),m===e&&m!==p)return!1}else if("<="===p.operator&&!n(p.semver,String(e),a))return!1;if(!e.operator&&(p||f)&&0!==h)return!1}return!(f&&E&&!p&&0!==h||p&&y&&!f&&0!==h||v||g)},u=(e,r,t)=>{if(!e)return r;const n=i(e.semver,r.semver,t);return n>0?e:n<0||">"===r.operator&&">="===e.operator?r:e},c=(e,r,t)=>{if(!e)return r;const n=i(e.semver,r.semver,t);return n<0?e:n>0||"<"===r.operator&&"<="===e.operator?r:e};return Nr=(r,t,n={})=>{if(r===t)return!0;r=new e(r,n),t=new e(t,n);let i=!1;e:for(const e of r.set){for(const r of t.set){const t=a(e,r,n);if(i=i||null!==t,t)continue e}if(i)return!1}return!0}}();return kr={parse:i,valid:o,clean:s,inc:a,diff:u,major:c,minor:l,patch:f,prerelease:p,compare:h,rcompare:d,compareLoose:m,compareBuild:E,sort:y,rsort:g,gt:v,lt:w,eq:S,neq:b,gte:$,lte:I,cmp:R,coerce:O,Comparator:A,Range:L,satisfies:T,toComparators:N,maxSatisfying:j,minSatisfying:k,minVersion:P,validRange:_,outside:C,gtr:x,ltr:D,intersects:M,simplifyRange:B,subset:K,SemVer:t,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}function jt(){if(Br)return Mr;Br=1;const e=function(){if(Cr)return _r;Cr=1;const e=Nt();return _r=e.satisfies(process.version,">=15.7.0")}(),r=function(){if(Dr)return xr;Dr=1;const e=Nt();return xr=e.satisfies(process.version,">=16.9.0")}(),t={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},n={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};return Mr=function(i,o){if(!i||!o)return;const s=o.asymmetricKeyType;if(!s)return;const a=t[s];if(!a)throw new Error(`Unknown key type "${s}".`);if(!a.includes(i))throw new Error(`"alg" parameter for "${s}" key type must be one of: ${a.join(", ")}.`);if(e)switch(s){case"ec":const e=o.asymmetricKeyDetails.namedCurve,t=n[i];if(e!==t)throw new Error(`"alg" parameter "${i}" requires curve "${t}".`);break;case"rsa-pss":if(r){const e=parseInt(i.slice(-3),10),{hashAlgorithm:r,mgf1HashAlgorithm:t,saltLength:n}=o.asymmetricKeyDetails;if(r!==`sha${e}`||t!==r)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${i}.`);if(void 0!==n&&n>e>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${i}.`)}}}}function kt(){if(Fr)return Kr;Fr=1;var e=Nt();return Kr=e.satisfies(process.version,"^6.12.0 || >=8.0.0")}function Pt(){if(Gr)return Ur;Gr=1;const e=z(),r=W(),t=Y(),n=X(),i=Z(),s=jt(),a=kt(),u=V(),{KeyObject:c,createSecretKey:l,createPublicKey:f}=o,p=["RS256","RS384","RS512"],h=["ES256","ES384","ES512"],d=["RS256","RS384","RS512"],m=["HS256","HS384","HS512"];return a&&(p.splice(p.length,0,"PS256","PS384","PS512"),d.splice(d.length,0,"PS256","PS384","PS512")),Ur=function(o,a,E,y){let g;if("function"!=typeof E||y||(y=E,E={}),E||(E={}),E=Object.assign({},E),g=y||function(e,r){if(e)throw e;return r},E.clockTimestamp&&"number"!=typeof E.clockTimestamp)return g(new e("clockTimestamp must be a number"));if(void 0!==E.nonce&&("string"!=typeof E.nonce||""===E.nonce.trim()))return g(new e("nonce must be a non-empty string"));if(void 0!==E.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof E.allowInvalidAsymmetricKeyTypes)return g(new e("allowInvalidAsymmetricKeyTypes must be a boolean"));const v=E.clockTimestamp||Math.floor(Date.now()/1e3);if(!o)return g(new e("jwt must be provided"));if("string"!=typeof o)return g(new e("jwt must be a string"));const w=o.split(".");if(3!==w.length)return g(new e("jwt malformed"));let S;try{S=n(o,{complete:!0})}catch(e){return g(e)}if(!S)return g(new e("invalid token"));const b=S.header;let $;if("function"==typeof a){if(!y)return g(new e("verify must be called asynchronous if secret or public key is provided as a callback"));$=a}else $=function(e,r){return r(null,a)};return $(b,function(n,a){if(n)return g(new e("error in secret or public key callback: "+n.message));const y=""!==w[2].trim();if(!y&&a)return g(new e("jwt signature is required"));if(y&&!a)return g(new e("secret or public key must be provided"));if(!y&&!E.algorithms)return g(new e('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=a&&!(a instanceof c))try{a=f(a)}catch(r){try{a=l("string"==typeof a?Buffer.from(a):a)}catch(r){return g(new e("secretOrPublicKey is not valid key material"))}}if(E.algorithms||("secret"===a.type?E.algorithms=m:["rsa","rsa-pss"].includes(a.asymmetricKeyType)?E.algorithms=d:"ec"===a.asymmetricKeyType?E.algorithms=h:E.algorithms=p),-1===E.algorithms.indexOf(S.header.alg))return g(new e("invalid algorithm"));if(b.alg.startsWith("HS")&&"secret"!==a.type)return g(new e(`secretOrPublicKey must be a symmetric key when using ${b.alg}`));if(/^(?:RS|PS|ES)/.test(b.alg)&&"public"!==a.type)return g(new e(`secretOrPublicKey must be an asymmetric key when using ${b.alg}`));if(!E.allowInvalidAsymmetricKeyTypes)try{s(b.alg,a)}catch(e){return g(e)}let $;try{$=u.verify(o,S.header.alg,a)}catch(e){return g(e)}if(!$)return g(new e("invalid signature"));const I=S.payload;if(void 0!==I.nbf&&!E.ignoreNotBefore){if("number"!=typeof I.nbf)return g(new e("invalid nbf value"));if(I.nbf>v+(E.clockTolerance||0))return g(new r("jwt not active",new Date(1e3*I.nbf)))}if(void 0!==I.exp&&!E.ignoreExpiration){if("number"!=typeof I.exp)return g(new e("invalid exp value"));if(v>=I.exp+(E.clockTolerance||0))return g(new t("jwt expired",new Date(1e3*I.exp)))}if(E.audience){const r=Array.isArray(E.audience)?E.audience:[E.audience];if(!(Array.isArray(I.aud)?I.aud:[I.aud]).some(function(e){return r.some(function(r){return r instanceof RegExp?r.test(e):r===e})}))return g(new e("jwt audience invalid. expected: "+r.join(" or ")))}if(E.issuer){if("string"==typeof E.issuer&&I.iss!==E.issuer||Array.isArray(E.issuer)&&-1===E.issuer.indexOf(I.iss))return g(new e("jwt issuer invalid. expected: "+E.issuer))}if(E.subject&&I.sub!==E.subject)return g(new e("jwt subject invalid. expected: "+E.subject));if(E.jwtid&&I.jti!==E.jwtid)return g(new e("jwt jwtid invalid. expected: "+E.jwtid));if(E.nonce&&I.nonce!==E.nonce)return g(new e("jwt nonce invalid. expected: "+E.nonce));if(E.maxAge){if("number"!=typeof I.iat)return g(new e("iat required when maxAge is specified"));const r=i(E.maxAge,I.iat);if(void 0===r)return g(new e('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(v>=r+(E.clockTolerance||0))return g(new t("maxAge exceeded",new Date(1e3*r)))}if(!0===E.complete){const e=S.signature;return g(null,{header:b,payload:I,signature:e})}return g(null,I)})},Ur}function _t(){if(Hr)return qr;Hr=1;var e=1/0,r=9007199254740991,t=17976931348623157e292,n=NaN,i="[object Arguments]",o="[object Function]",s="[object GeneratorFunction]",a="[object String]",u="[object Symbol]",c=/^\s+|\s+$/g,l=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,p=/^0o[0-7]+$/i,h=/^(?:0|[1-9]\d*)$/,d=parseInt;function m(e){return e!=e}function E(e,r){return function(e,r){for(var t=-1,n=e?e.length:0,i=Array(n);++t<n;)i[t]=r(e[t],t,e);return i}(r,function(r){return e[r]})}var y,g,v=Object.prototype,w=v.hasOwnProperty,S=v.toString,b=v.propertyIsEnumerable,$=(y=Object.keys,g=Object,function(e){return y(g(e))}),I=Math.max;function R(e,r){var t=L(e)||function(e){return function(e){return j(e)&&T(e)}(e)&&w.call(e,"callee")&&(!b.call(e,"callee")||S.call(e)==i)}(e)?function(e,r){for(var t=-1,n=Array(e);++t<e;)n[t]=r(t);return n}(e.length,String):[],n=t.length,o=!!n;for(var s in e)!w.call(e,s)||o&&("length"==s||A(s,n))||t.push(s);return t}function O(e){if(t=(r=e)&&r.constructor,n="function"==typeof t&&t.prototype||v,r!==n)return $(e);var r,t,n,i=[];for(var o in Object(e))w.call(e,o)&&"constructor"!=o&&i.push(o);return i}function A(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||h.test(e))&&e>-1&&e%1==0&&e<t}var L=Array.isArray;function T(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}(e.length)&&!function(e){var r=N(e)?S.call(e):"";return r==o||r==s}(e)}function N(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}function j(e){return!!e&&"object"==typeof e}return qr=function(r,i,o,s){var h;r=T(r)?r:(h=r)?E(h,function(e){return T(e)?R(e):O(e)}(h)):[],o=o&&!s?function(r){var i=function(r){if(!r)return 0===r?r:0;if(r=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||j(e)&&S.call(e)==u}(e))return n;if(N(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=N(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(c,"");var t=f.test(e);return t||p.test(e)?d(e.slice(2),t?2:8):l.test(e)?n:+e}(r),r===e||r===-1/0){return(r<0?-1:1)*t}return r==r?r:0}(r),o=i%1;return i==i?o?i-o:i:0}(o):0;var y=r.length;return o<0&&(o=I(y+o,0)),function(e){return"string"==typeof e||!L(e)&&j(e)&&S.call(e)==a}(r)?o<=y&&r.indexOf(i,o)>-1:!!y&&function(e,r,t){if(r!=r)return function(e,r,t){for(var n=e.length,i=t+-1;++i<n;)if(r(e[i],i,e))return i;return-1}(e,m,t);for(var n=t-1,i=e.length;++n<i;)if(e[n]===r)return n;return-1}(r,i,o)>-1},qr}function Ct(){if(Wr)return zr;Wr=1;var e=1/0,r=17976931348623157e292,t=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,u=parseInt,c=Object.prototype.toString;function l(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}return zr=function(f){return"number"==typeof f&&f==function(f){var p=function(f){if(!f)return 0===f?f:0;if(f=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&c.call(e)==n}(e))return t;if(l(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=l(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var f=s.test(e);return f||a.test(e)?u(e.slice(2),f?2:8):o.test(e)?t:+e}(f),f===e||f===-1/0){return(f<0?-1:1)*r}return f==f?f:0}(f),h=p%1;return p==p?h?p-h:p:0}(f)}}function xt(){if(nt)return tt;nt=1;var e=1/0,r=17976931348623157e292,t=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,u=parseInt,c=Object.prototype.toString;function l(l,p){var h;if("function"!=typeof p)throw new TypeError("Expected a function");return l=function(l){var p=function(l){if(!l)return 0===l?l:0;if(l=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&c.call(e)==n}(e))return t;if(f(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=f(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var l=s.test(e);return l||a.test(e)?u(e.slice(2),l?2:8):o.test(e)?t:+e}(l),l===e||l===-1/0){return(l<0?-1:1)*r}return l==l?l:0}(l),h=p%1;return p==p?h?p-h:p:0}(l),function(){return--l>0&&(h=p.apply(this,arguments)),l<=1&&(p=void 0),h}}function f(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}return tt=function(e){return l(2,e)}}function Dt(){if(ot)return it;ot=1;const e=Z(),r=kt(),t=jt(),n=V(),i=_t(),s=function(){if(Xr)return Vr;Xr=1;var e=Object.prototype.toString;return Vr=function(r){return!0===r||!1===r||function(e){return!!e&&"object"==typeof e}(r)&&"[object Boolean]"==e.call(r)}}(),a=Ct(),u=function(){if(Jr)return Yr;Jr=1;var e=Object.prototype.toString;return Yr=function(r){return"number"==typeof r||function(e){return!!e&&"object"==typeof e}(r)&&"[object Number]"==e.call(r)}}(),c=function(){if(Qr)return Zr;Qr=1;var e,r,t=Function.prototype,n=Object.prototype,i=t.toString,o=n.hasOwnProperty,s=i.call(Object),a=n.toString,u=(e=Object.getPrototypeOf,r=Object,function(t){return e(r(t))});return Zr=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=a.call(e)||function(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}(e))return!1;var r=u(e);if(null===r)return!0;var t=o.call(r,"constructor")&&r.constructor;return"function"==typeof t&&t instanceof t&&i.call(t)==s}}(),l=function(){if(rt)return et;rt=1;var e=Object.prototype.toString,r=Array.isArray;return et=function(t){return"string"==typeof t||!r(t)&&function(e){return!!e&&"object"==typeof e}(t)&&"[object String]"==e.call(t)}}(),f=xt(),{KeyObject:p,createSecretKey:h,createPrivateKey:d}=o,m=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];r&&m.splice(3,0,"PS256","PS384","PS512");const E={expiresIn:{isValid:function(e){return a(e)||l(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return a(e)||l(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return l(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:i.bind(null,m),message:'"algorithm" must be a valid string enum value'},header:{isValid:c,message:'"header" must be an object'},encoding:{isValid:l,message:'"encoding" must be a string'},issuer:{isValid:l,message:'"issuer" must be a string'},subject:{isValid:l,message:'"subject" must be a string'},jwtid:{isValid:l,message:'"jwtid" must be a string'},noTimestamp:{isValid:s,message:'"noTimestamp" must be a boolean'},keyid:{isValid:l,message:'"keyid" must be a string'},mutatePayload:{isValid:s,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:s,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:s,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},y={iat:{isValid:u,message:'"iat" should be a number of seconds'},exp:{isValid:u,message:'"exp" should be a number of seconds'},nbf:{isValid:u,message:'"nbf" should be a number of seconds'}};function g(e,r,t,n){if(!c(t))throw new Error('Expected "'+n+'" to be a plain object.');Object.keys(t).forEach(function(i){const o=e[i];if(o){if(!o.isValid(t[i]))throw new Error(o.message)}else if(!r)throw new Error('"'+i+'" is not allowed in "'+n+'"')})}const v={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},w=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];return it=function(r,i,o,s){"function"==typeof o?(s=o,o={}):o=o||{};const a="object"==typeof r&&!Buffer.isBuffer(r),u=Object.assign({alg:o.algorithm||"HS256",typ:a?"JWT":void 0,kid:o.keyid},o.header);function c(e){if(s)return s(e);throw e}if(!i&&"none"!==o.algorithm)return c(new Error("secretOrPrivateKey must have a value"));if(null!=i&&!(i instanceof p))try{i=d(i)}catch(e){try{i=h("string"==typeof i?Buffer.from(i):i)}catch(e){return c(new Error("secretOrPrivateKey is not valid key material"))}}if(u.alg.startsWith("HS")&&"secret"!==i.type)return c(new Error(`secretOrPrivateKey must be a symmetric key when using ${u.alg}`));if(/^(?:RS|PS|ES)/.test(u.alg)){if("private"!==i.type)return c(new Error(`secretOrPrivateKey must be an asymmetric key when using ${u.alg}`));if(!o.allowInsecureKeySizes&&!u.alg.startsWith("ES")&&void 0!==i.asymmetricKeyDetails&&i.asymmetricKeyDetails.modulusLength<2048)return c(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${u.alg}`))}if(void 0===r)return c(new Error("payload is required"));if(a){try{!function(e){g(y,!0,e,"payload")}(r)}catch(e){return c(e)}o.mutatePayload||(r=Object.assign({},r))}else{const e=w.filter(function(e){return void 0!==o[e]});if(e.length>0)return c(new Error("invalid "+e.join(",")+" option for "+typeof r+" payload"))}if(void 0!==r.exp&&void 0!==o.expiresIn)return c(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==r.nbf&&void 0!==o.notBefore)return c(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){g(E,!1,e,"options")}(o)}catch(e){return c(e)}if(!o.allowInvalidAsymmetricKeyTypes)try{t(u.alg,i)}catch(e){return c(e)}const l=r.iat||Math.floor(Date.now()/1e3);if(o.noTimestamp?delete r.iat:a&&(r.iat=l),void 0!==o.notBefore){try{r.nbf=e(o.notBefore,l)}catch(e){return c(e)}if(void 0===r.nbf)return c(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==o.expiresIn&&"object"==typeof r){try{r.exp=e(o.expiresIn,l)}catch(e){return c(e)}if(void 0===r.exp)return c(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(v).forEach(function(e){const t=v[e];if(void 0!==o[e]){if(void 0!==r[t])return c(new Error('Bad "options.'+e+'" option. The payload already has an "'+t+'" property.'));r[t]=o[e]}});const m=o.encoding||"utf8";if("function"!=typeof s){let e=n.sign({header:u,payload:r,secret:i,encoding:m});if(!o.allowInsecureKeySizes&&/^(?:RS|PS)/.test(u.alg)&&e.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${u.alg}`);return e}s=s&&f(s),n.createSign({header:u,privateKey:i,payload:r,encoding:m}).once("error",s).once("done",function(e){if(!o.allowInsecureKeySizes&&/^(?:RS|PS)/.test(u.alg)&&e.length<256)return s(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${u.alg}`));s(null,e)})}}var Mt=s(at?st:(at=1,st={decode:X(),verify:Pt(),sign:Dt(),JsonWebTokenError:z(),NotBeforeError:W(),TokenExpiredError:Y()}));const Bt=e(import.meta.url),{version:Kt}=Bt("../package.json");var Ft={id:"sso",handler:(e,t)=>{const{env:n,logger:i,services:o,database:s,getSchema:a}=t,u=n.KEYCLOAK_URL||"http://keycloak:8080",c=n.KEYCLOAK_REALM||"testing",l=n.KEYCLOAK_ADMIN_USER||"admin",f=n.KEYCLOAK_ADMIN_PASSWORD||"admin",p=n.PUBLIC_URL||"http://localhost:8055",h=n.MOBILE_APP_SCHEME||"finsnapp",d=Array.isArray(h)?h.map(e=>String(e).trim()):String(h).split(",").map(e=>e.trim()),m=d[0],E=n.MOBILE_APP_CALLBACK_PATH||"/auth/callback",y=n.GOOGLE_CALLBACK_PATH||"/auth/callback/google",g=n.APPLE_CLIENT_ID||"com.forumbandung.app",v=Array.isArray(g)?g.map(e=>String(e).trim().toLowerCase()):String(g).split(",").map(e=>e.trim().toLowerCase()),w=n.KEYCLOAK_CLIENT_ID||"admin-cli",S=n.COOKIE_DOMAIN||null,b="false"!==n.COOKIE_SECURE,$=n.COOKIE_SAME_SITE||"lax",I=n.SESSION_COOKIE_NAME||"directus_session_token",R=n.REFRESH_TOKEN_COOKIE_NAME||"directus_refresh_token",O=n.DEFAULT_ROLE_ID||null,A="directus_session_token";function L(e,r="/"){if(!e||"string"!=typeof e)return r;try{if(d.some(r=>e.startsWith(`${r}://`)))return e;if(e.startsWith("/")&&!e.startsWith("//")&&!e.startsWith("/\\"))return e;const r=new URL(e),t=new URL(p).origin;if(r.origin===t)return e}catch(e){}return i.warn(`⚠️ Warning: Blocked potentially unsafe redirect URL: "${e}". Defaulting to fallback: "${r}"`),r}const T=n.FCM_PROJECT_ID||null;async function N(){try{const e=await fetch(`${u}/realms/master/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"password",client_id:w,username:l,password:f}).toString()});if(!e.ok)throw new Error("Failed to get admin token");return(await e.json()).access_token}catch(e){return i.error("Error getting admin token:",e),null}}async function j(e,r){try{const t=await fetch(`${u}/admin/realms/${c}/users?email=${encodeURIComponent(r)}`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error("Failed to get user");const n=await t.json();return n.length>0?n[0].id:null}catch(e){return i.error("Error getting user ID:",e),null}}async function k(e,r){try{const t=await fetch(`${u}/admin/realms/${c}/users/${r}/logout`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});return t.ok||204===t.status}catch(e){return i.error("Error logging out user from Keycloak:",e),!1}}function P(e){if("browser"===e.query.type)return!0;if("mobile"===e.query.type)return!1;if(e.query.app_scheme||e.query.app_path)return!1;const r=e.headers["user-agent"]||"";return/Mozilla|Chrome|Safari|Firefox|Edge|Opera/i.test(r)&&!/Mobile.*App|ReactNative|Expo/i.test(r)}async function _(e,r){const t=e.headers.cookie;if(!t)return null;const n=t.split(";").map(e=>e.trim()).filter(e=>e.startsWith(`${r}=`)).map(e=>e.substring(r.length+1));if(0===n.length)return null;for(let e=0;e<n.length;e++){const t=n[e];try{const e=await fetch(`${p}/users/me`,{headers:{Cookie:`${r}=${t}`}});if(e.ok){return{token:t,userData:(await e.json()).data}}}catch(e){}}return null}async function C(e){const r=e.headers.cookie;if(!r)return null;const t=r.split(";").map(e=>e.trim()).map(e=>{const r=e.split("=");return r.length>1?r[1]:null}).filter(e=>e&&e.startsWith("eyJ")&&e.length>50);if(0===t.length)return null;for(let e=0;e<t.length;e++){const r=t[e];try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${r}`}});if(e.ok){return{token:r,userData:(await e.json()).data}}}catch(e){}}return null}async function x(e){const r=e.cookies[R];if(!r)return null;try{const e=await fetch(`${p}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:r})});if(e.ok){const r=(await e.json()).data.access_token,t=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${r}`}});if(t.ok){return{token:r,userData:(await t.json()).data}}}}catch(e){}return null}function D(e){const r=e.query.app_scheme;return r&&d.includes(r)?r:(r&&i.warn(`⚠️ Warning: App requested scheme '${r}', but it is not in .env. Falling back to '${m}'`),m)}n.FCM_CLIENT_EMAIL,n.FCM_PRIVATE_KEY&&n.FCM_PRIVATE_KEY.replace(/\\n/g,"\n"),n.FCM_WEBHOOK_SECRET,i.info("🚀 Mobile Auth Extension loaded"),i.info("📱 Allowed Mobile App Schemes: "+d.join(", ")),e.get("/health",(e,r)=>{r.json({status:"ok",service:"directus-extension-sso",version:Kt,allowed_schemes:d,fcm_enabled:!!T})}),e.get("/mobile-callback",async(e,r)=>{const t=P(e);try{let n=null;if(I!==A&&(n=await _(e,I)),n||(n=await _(e,A)),n||(n=await C(e)),n||(n=await x(e)),!n)return r.send("<html><body><h2>Authentication Failed</h2></body></html>");const{token:i,userData:o}=n,s=o.id,a=o.email,u=i;if(t){r.cookie(I,i,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),I!==A&&r.cookie(A,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";return t=L(t,"/"),r.redirect(t)}const c=D(e),l=`${c}://${(e.query.app_path||E).replace(/^\/+/,"")}?access_token=${u}&user_id=${s}&email=${encodeURIComponent(a||"")}`;return r.setHeader("Location",l),r.status(302).send(`<html><head><meta http-equiv="refresh" content="0;url=${l}"></head><body>Redirecting...</body></html>`)}catch(e){r.status(500).send(`<html><body><h2>Error</h2><p>${e.message}</p></body></html>`)}}),e.get("/google-callback",async(e,r)=>{const t=P(e);try{let o=null;if(e.query.access_token){o={token:e.query.access_token,refresh_token:e.query.refresh_token||null,expires:e.query.expires||null};try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${o.token}`}});if(e.ok){const r=await e.json();o.userData=r.data}else o=null}catch(e){o=null}}if(o||I===A||(o=await _(e,I)),o||(o=await _(e,A)),o||(o=await C(e)),o||(o=await x(e)),!o)return r.send("<html><body><h2>Authentication Failed</h2></body></html>");const{token:s,userData:a}=o,u=a.id,c=a.email,l=s;if(t){r.cookie(I,s,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),I!==A&&r.cookie(A,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";t=L(t,"/");const i="string"!=typeof(n=t)?"":n.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";default:return e}});return r.send(`<html><head><meta http-equiv="refresh" content="2;url=${i}"></head><body>Login Successful!</body></html>`)}const f=D(e),h=e.query.app_path||y,d=new URL(`${f}://${h.replace(/^\/+/,"")}`);return d.searchParams.set("access_token",l),d.searchParams.set("user_id",u),d.searchParams.set("email",c||""),d.searchParams.set("provider","google"),i.info("🚀 Performing direct 302 redirect to app: "+d.toString()),r.redirect(302,d.toString())}catch(e){r.status(500).send(`<html><body><h2>Error</h2><p>${e.message}</p></body></html>`)}var n}),e.get("/logout-clear",(e,r)=>{const t={httpOnly:!0,secure:b,sameSite:$,path:"/"};if(r.clearCookie(I,t),I!==A&&r.clearCookie(A,t),r.clearCookie(R,t),S){const e={...t,domain:S};r.clearCookie(I,e),I!==A&&r.clearCookie(A,e),r.clearCookie(R,e)}try{r.clearCookie(I,{...t,domain:".goyong.in"}),r.clearCookie(A,{...t,domain:".goyong.in"}),r.clearCookie(R,{...t,domain:".goyong.in"})}catch(e){}let n=e.query.redirect;return n?(n=L(n,"/"),i.info(`🧹 Cleared cookies and redirecting to: ${n}`),r.redirect(n)):(i.info("🧹 Cleared cookies successfully (no redirect provided)"),r.json({success:!0,message:"Cookies cleared successfully"}))}),e.post("/mobile-logout",async(e,r)=>{try{const t=e.headers.authorization,n=t?.replace("Bearer ","");if(!n)return r.status(400).json({error:"No token provided"});let i=null;try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${n}`}});if(e.ok){i=(await e.json()).data.email}}catch(e){}try{await fetch(`${p}/auth/logout`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({refresh_token:n})})}catch(e){}if(i)try{const e=await N();if(e){const r=await j(e,i);r&&await k(e,r)}}catch(e){}r.json({success:!0,message:"Logged out successfully"})}catch(e){r.status(500).json({error:e.message})}}),e.post("/delete-account",async(e,r)=>{try{const t=e.headers.authorization,u=t?.replace("Bearer ","");if(!u)return r.status(400).json({error:"No token provided"});let c=null,l=null;try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${u}`}});if(e.ok){const r=await e.json();c=r.data.id,l=r.data.email}}catch(e){i.error("[SSO] Error verifying token during account deletion:",e)}if(!c||!l)return r.status(401).json({error:"Invalid or expired token"});i.info(`[SSO] Deleting account for user: ${c} (${l})`);let f=!1;try{const e=await fetch(`${p}/auth/logout`,{method:"POST",headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"},body:JSON.stringify({})});f=e.ok||204===e.status,i.info(`[SSO] Directus /auth/logout → ${e.status} for user ${c}`)}catch(e){i.warn("[SSO] /auth/logout network error (non-fatal):",e.message)}let h=0;try{const e=Mt.decode(u),r=e?.session;if(r){const e=await s("directus_sessions").where("token",r).delete();h+=e,i.info(`[SSO] Deleted ${e} session(s) by token for user ${c}`)}const t=await s("directus_sessions").where("user",c).delete();h+=t,t>0&&i.info(`[SSO] Deleted ${t} additional session(s) by user ID for ${c}`)}catch(e){i.error("[SSO] Error deleting sessions:",e)}const{UsersService:d}=o,m=new d({schema:await a(),knex:s}),E=`DELETED_${Date.now()}_${l}`;await m.updateOne(c,{first_name:"DELETED",last_name:"ACCOUNT",status:"suspended",email:E,external_identifier:null,provider:"default"}),i.info(`[SSO] Soft-deleted user ${c} → ${E}, sessions cleared: ${h}, directus logout: ${f}`);if(!!(n.KEYCLOAK_URL&&n.KEYCLOAK_REALM&&n.KEYCLOAK_ADMIN_USER&&n.KEYCLOAK_ADMIN_PASSWORD))try{const e=await N();if(e){const r=await j(e,l);r&&(await k(e,r),i.info(`[SSO] Logged out user ${l} from Keycloak`))}}catch(e){i.error("[SSO] Keycloak logout error:",e)}const y=`${p}/sso/logout-clear`;return r.json({success:!0,message:"Account deleted successfully, sessions cleared.",sessions_cleared:h,browser_logout_url:y})}catch(e){return i.error("[SSO] Account deletion failed:",e),r.status(500).json({error:e.message,message:"Failed to delete account"})}}),e.post("/apple-token",async(e,t)=>{const{identityToken:u,firstName:c,lastName:l}=e.body;if(i.info("🍎 Apple token exchange request received"),!u)return t.status(400).json({error:"identityToken is required",message:"Apple identityToken must be provided in the request body"});try{const e=async e=>{const[t,n,i]=e.split("."),o=JSON.parse(Buffer.from(t,"base64").toString()),s=JSON.parse(Buffer.from(n,"base64").toString());if("https://appleid.apple.com"!==s.iss)throw new Error("Invalid issuer");const a=[...v,"host.exp.exponent"],u=s.aud.toLowerCase();if(!a.includes(u))throw new Error(`Invalid audience: ${u}. Allowed: ${a.join(", ")}`);if(s.exp<Math.floor(Date.now()/1e3))throw new Error("Token expired");const c=await fetch("https://appleid.apple.com/auth/keys"),{keys:l}=await c.json(),f=l.find(e=>e.kid===o.kid);if(!f)throw new Error("Apple public key not found");const p=r.createPublicKey({key:f,format:"jwk"}),h=r.createVerify("RSA-SHA256");h.update(`${t}.${n}`);if(!h.verify(p,i,"base64url"))throw new Error("Invalid signature");return s},i=await e(u),{email:f,sub:p}=i;if(!f)throw new Error("Apple token did not contain an email");const{UsersService:h}=o,d=new h({schema:await a(),knex:s});let m,E=await d.readByQuery({filter:{_and:[{external_identifier:{_eq:p}},{provider:{_eq:"apple"}}]}}),y=E.length>0?E[0]:null;y||(E=await d.readByQuery({filter:{email:{_eq:f}}}),E.length>0&&(y=E[0],await d.updateOne(y.id,{external_identifier:p,provider:"apple"}))),y?m=y.id:(m=await d.createOne({email:f,first_name:c||"Apple User",last_name:l||"",role:O,status:"active",provider:"apple",external_identifier:p}),y=await d.readOne(m));const g={id:m,role:y.role||O,app_access:!0,admin_access:!1},w=Mt.sign(g,n.SECRET,{expiresIn:"7d",issuer:"directus"}),S={id:m,type:"refresh"},b=Mt.sign(S,n.SECRET,{expiresIn:"30d",issuer:"directus"});t.json({success:!0,data:{access_token:w,refresh_token:b,expires:604800,user:y},user_id:m,email:f,provider:"apple"})}catch(e){t.status(500).json({error:e.message,message:"Failed to verify Apple token"})}}),e.post("/bridge-token",async(e,r)=>{try{const t=e.headers.authorization,i=t?.replace("Bearer ","");if(!i)return r.status(400).json({error:"No token provided"});const o=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${i}`}});if(!o.ok)return r.status(401).json({error:"Invalid token"});const s={sub:(await o.json()).data.id,purpose:"bridge"},a=Mt.sign(s,n.SECRET,{expiresIn:"60s",issuer:"directus-sso"});r.json({success:!0,bridge_token:a})}catch(e){r.status(500).json({error:e.message})}}),e.get("/bridge",async(e,r)=>{const{token:t,bridge_token:o,redirect_uri:s,redirect:a}=e.query,u=L(s||a,"/"),c="true"===n.ENABLE_LEGACY_BRIDGE;let l=null,f=null;if(o)try{const e=Mt.verify(o,n.SECRET,{issuer:"directus-sso"});if("bridge"!==e.purpose)return r.status(400).json({error:"Invalid token purpose"});l=e.sub;const t={id:l,app_access:!0,admin_access:!1};f=Mt.sign(t,n.SECRET,{expiresIn:"7d",issuer:"directus"})}catch(e){return r.status(401).json({error:"Invalid or expired bridge token",message:e.message})}else{if(!t||!c)return r.status(400).json({error:"Secure bridge token required"});i.warn("⚠️ Warning: Legacy bridge token used. This flow is vulnerable to session fixation.");try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${t}`}});if(!e.ok)return r.status(401).json({error:"Invalid token"});l=(await e.json()).data.id,f=t}catch(e){return r.status(500).json({error:"Bridge failure",message:e.message})}}return r.cookie(I,f,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),I!==A&&r.cookie(A,f,{httpOnly:!0,secure:b,domain:S,sameSite:$,maxAge:6048e5,path:"/"}),r.redirect(u)})}};export{Ft as default};
|
package/package.json
CHANGED