@ymys/directus-extension-sso 2.1.10 → 2.2.12

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -3
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,3 +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={},c={exports:{}};
2
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
3
- !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)}}(c,c.exports);var u=c.exports,l=u.Buffer,f=n;function p(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=l.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=l.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}i.inherits(p,f),p.prototype.write=function(e){this.buffer=l.concat([this.buffer,l.from(e)]),this.emit("data",e)},p.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1};var h=p;function m(e){return(e/8|0)+(e%8==0?0:1)}var d={ES256:m(256),ES384:m(384),ES512:m(521)};var E=function(e){var r=d[e];if(r)return r;throw new Error('Unknown algorithm "'+e+'"')},y=u.Buffer,g=E,v=128;function w(e){if(y.isBuffer(e))return e;if("string"==typeof e)return y.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function b(e,r,t){for(var n=0;r+n<t&&0===e[r+n];)++n;return e[r+n]>=v&&--n,n}var S,$,I={derToJose:function(e,r){e=w(e);var t=g(r),n=t+1,i=e.length,o=0;if(48!==e[o++])throw new Error('Could not find expected "seq"');var s=e[o++];if(129===s&&(s=e[o++]),i-o<s)throw new Error('"seq" specified length of "'+s+'", only "'+(i-o)+'" remaining');if(2!==e[o++])throw new Error('Could not find expected "int" for "r"');var a=e[o++];if(i-o-2<a)throw new Error('"r" specified length of "'+a+'", only "'+(i-o-2)+'" available');if(n<a)throw new Error('"r" specified length of "'+a+'", max of "'+n+'" is acceptable');var c=o;if(o+=a,2!==e[o++])throw new Error('Could not find expected "int" for "s"');var u=e[o++];if(i-o!==u)throw new Error('"s" specified length of "'+u+'", expected "'+(i-o)+'"');if(n<u)throw new Error('"s" specified length of "'+u+'", max of "'+n+'" is acceptable');var l=o;if((o+=u)!==i)throw new Error('Expected to consume entire buffer, but "'+(i-o)+'" bytes remain');var f=t-a,p=t-u,h=y.allocUnsafe(f+a+p+u);for(o=0;o<f;++o)h[o]=0;e.copy(h,o,c+Math.max(-f,0),c+a);for(var m=o=t;o<m+p;++o)h[o]=0;return e.copy(h,o,l+Math.max(-p,0),l+u),h=(h=h.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,r){e=w(e);var t=g(r),n=e.length;if(n!==2*t)throw new TypeError('"'+r+'" signatures must be "'+2*t+'" bytes, saw "'+n+'"');var i=b(e,0,t),o=b(e,t,e.length),s=t-i,a=t-o,c=2+s+1+1+a,u=c<v,l=y.allocUnsafe((u?2:3)+c),f=0;return l[f++]=48,u?l[f++]=c:(l[f++]=129,l[f++]=255&c),l[f++]=2,l[f++]=s,i<0?(l[f++]=0,f+=e.copy(l,f,0,t)):f+=e.copy(l,f,i,t),l[f++]=2,l[f++]=a,o<0?(l[f++]=0,e.copy(l,f,t)):e.copy(l,f,t+o),l}};var R,A=u.Buffer,O=o,L=I,T=i,N="secret must be a string or buffer",j="key must be a string or a buffer",P="function"==typeof O.createPublicKey;function k(e){if(!A.isBuffer(e)&&"string"!=typeof e){if(!P)throw M(j);if("object"!=typeof e)throw M(j);if("string"!=typeof e.type)throw M(j);if("string"!=typeof e.asymmetricKeyType)throw M(j);if("function"!=typeof e.export)throw M(j)}}function _(e){if(!A.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw M("key must be a string, a buffer or an object")}function C(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function x(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 M(e){var r=[].slice.call(arguments,1),t=T.format.bind(T,e).apply(null,r);return new TypeError(t)}function D(e){var r;return r=e,A.isBuffer(r)||"string"==typeof r||(e=JSON.stringify(e)),e}function B(e){return function(r,t){!function(e){if(!A.isBuffer(e)){if("string"==typeof e)return e;if(!P)throw M(N);if("object"!=typeof e)throw M(N);if("secret"!==e.type)throw M(N);if("function"!=typeof e.export)throw M(N)}}(t),r=D(r);var n=O.createHmac("sha"+e,t);return C((n.update(r),n.digest("base64")))}}P&&(j+=" or a KeyObject",N+="or a KeyObject");var F="timingSafeEqual"in O?function(e,r){return e.byteLength===r.byteLength&&O.timingSafeEqual(e,r)}:function(e,r){return R||(R=function(){if($)return S;$=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}S=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},S}()),R(e,r)};function K(e){return function(r,t,n){var i=B(e)(r,n);return F(A.from(t),A.from(i))}}function G(e){return function(r,t){_(t),r=D(r);var n=O.createSign("RSA-SHA"+e);return C((n.update(r),n.sign(t,"base64")))}}function U(e){return function(r,t,n){k(n),r=D(r),t=x(t);var i=O.createVerify("RSA-SHA"+e);return i.update(r),i.verify(n,t,"base64")}}function H(e){return function(r,t){_(t),r=D(r);var n=O.createSign("RSA-SHA"+e);return C((n.update(r),n.sign({key:t,padding:O.constants.RSA_PKCS1_PSS_PADDING,saltLength:O.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function V(e){return function(r,t,n){k(n),r=D(r),t=x(t);var i=O.createVerify("RSA-SHA"+e);return i.update(r),i.verify({key:n,padding:O.constants.RSA_PKCS1_PSS_PADDING,saltLength:O.constants.RSA_PSS_SALTLEN_DIGEST},t,"base64")}}function q(e){var r=G(e);return function(){var t=r.apply(null,arguments);return t=L.derToJose(t,"ES"+e)}}function X(e){var r=U(e);return function(t,n,i){return n=L.joseToDer(n,"ES"+e).toString("base64"),r(t,n,i)}}function z(){return function(){return""}}function W(){return function(e,r){return""===r}}var J=function(e){var r={hs:B,rs:G,ps:H,es:q,none:z},t={hs:K,rs:U,ps:V,es:X,none:W},n=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!n)throw M('"%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)}},Y=t.Buffer,Z=function(e){return"string"==typeof e?e:"number"==typeof e||Y.isBuffer(e)?e.toString():JSON.stringify(e)},Q=u.Buffer,ee=h,re=J,te=n,ne=Z,ie=i;function oe(e,r){return Q.from(e,r).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function se(e){var r=e.header,t=e.payload,n=e.secret||e.privateKey,i=e.encoding,o=re(r.alg),s=function(e,r,t){t=t||"utf8";var n=oe(ne(e),"binary"),i=oe(ne(r),t);return ie.format("%s.%s",n,i)}(r,t,i),a=o.sign(s,n);return ie.format("%s.%s",s,a)}function ae(e){var r=e.secret;if(r=null==(r=null==r?e.privateKey:r)?e.key:r,!0===/^hs/i.test(e.header.alg)&&null==r)throw new TypeError("secret must be a string or buffer or a KeyObject");var t=new ee(r);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=t,this.payload=new ee(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))}ie.inherits(ae,te),ae.prototype.sign=function(){try{var e=se({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")}},ae.sign=se;var ce=ae,ue=u.Buffer,le=h,fe=J,pe=n,he=Z,me=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function de(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}function Ee(e){var r=e.split(".",1)[0];return de(ue.from(r,"base64").toString("binary"))}function ye(e){return e.split(".")[2]}function ge(e){return me.test(e)&&!!Ee(e)}function ve(e,r,t){if(!r){var n=new Error("Missing algorithm parameter for jws.verify");throw n.code="MISSING_ALGORITHM",n}var i=ye(e=he(e)),o=function(e){return e.split(".",2).join(".")}(e);return fe(r).verify(o,i,t)}function we(e,r){if(r=r||{},!ge(e=he(e)))return null;var t=Ee(e);if(!t)return null;var n=function(e,r){r=r||"utf8";var t=e.split(".")[1];return ue.from(t,"base64").toString(r)}(e);return("JWT"===t.typ||r.json)&&(n=JSON.parse(n,r.encoding)),{header:t,payload:n,signature:ye(e)}}function be(e){var r=(e=e||{}).secret;if(r=null==(r=null==r?e.publicKey:r)?e.key:r,!0===/^hs/i.test(e.algorithm)&&null==r)throw new TypeError("secret must be a string or buffer or a KeyObject");var t=new le(r);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=t,this.signature=new le(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))}i.inherits(be,pe),be.prototype.verify=function(){try{var e=ve(this.signature.buffer,this.algorithm,this.key.buffer),r=we(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")}},be.decode=we,be.isValid=ge,be.verify=ve;var Se=ce,$e=be;a.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],a.sign=Se.sign,a.verify=$e.verify,a.decode=$e.decode,a.isValid=$e.isValid,a.createSign=function(e){return new Se(e)},a.createVerify=function(e){return new $e(e)};var Ie=a,Re=function(e,r){r=r||{};var t=Ie.decode(e,r);if(!t)return null;var n=t.payload;if("string"==typeof n)try{var i=JSON.parse(n);null!==i&&"object"==typeof i&&(n=i)}catch(e){}return!0===r.complete?{header:t.header,payload:n,signature:t.signature}:n},Ae=function(e,r){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,r&&(this.inner=r)};(Ae.prototype=Object.create(Error.prototype)).constructor=Ae;var Oe=Ae,Le=Oe,Te=function(e,r){Le.call(this,e),this.name="NotBeforeError",this.date=r};(Te.prototype=Object.create(Le.prototype)).constructor=Te;var Ne=Te,je=Oe,Pe=function(e,r){je.call(this,e),this.name="TokenExpiredError",this.expiredAt=r};(Pe.prototype=Object.create(je.prototype)).constructor=Pe;var ke=Pe,_e=1e3,Ce=60*_e,xe=60*Ce,Me=24*xe,De=7*Me,Be=365.25*Me;function Fe(e,r,t,n){var i=r>=1.5*t;return Math.round(e/t)+" "+n+(i?"s":"")}var Ke=function(e,r){r=r||{};var t=typeof e;if("string"===t&&e.length>0)return function(e){if((e=String(e)).length>100)return;var r=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!r)return;var t=parseFloat(r[1]);switch((r[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return t*Be;case"weeks":case"week":case"w":return t*De;case"days":case"day":case"d":return t*Me;case"hours":case"hour":case"hrs":case"hr":case"h":return t*xe;case"minutes":case"minute":case"mins":case"min":case"m":return t*Ce;case"seconds":case"second":case"secs":case"sec":case"s":return t*_e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}(e);if("number"===t&&isFinite(e))return r.long?function(e){var r=Math.abs(e);if(r>=Me)return Fe(e,r,Me,"day");if(r>=xe)return Fe(e,r,xe,"hour");if(r>=Ce)return Fe(e,r,Ce,"minute");if(r>=_e)return Fe(e,r,_e,"second");return e+" ms"}(e):function(e){var r=Math.abs(e);if(r>=Me)return Math.round(e/Me)+"d";if(r>=xe)return Math.round(e/xe)+"h";if(r>=Ce)return Math.round(e/Ce)+"m";if(r>=_e)return Math.round(e/_e)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},Ge=function(e,r){var t=r||Math.floor(Date.now()/1e3);if("string"==typeof e){var n=Ke(e);if(void 0===n)return;return Math.floor(t+n/1e3)}return"number"==typeof e?t+e:void 0},Ue={exports:{}};var He={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||9007199254740991,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};var Ve="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};!function(e,r){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=He,o=Ve,s=(r=e.exports={}).re=[],a=r.safeRe=[],c=r.src=[],u=r.safeSrc=[],l=r.t={};let f=0;const p="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[p,n]],m=(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,c[i]=r,u[i]=n,s[i]=new RegExp(r,t?"g":void 0),a[i]=new RegExp(n,t?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),m("MAINVERSION",`(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${c[l.PRERELEASEIDENTIFIER]}(?:\\.${c[l.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${c[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[l.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${p}+`),m("BUILD",`(?:\\+(${c[l.BUILDIDENTIFIER]}(?:\\.${c[l.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${c[l.MAINVERSION]}${c[l.PRERELEASE]}?${c[l.BUILD]}?`),m("FULL",`^${c[l.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${c[l.MAINVERSIONLOOSE]}${c[l.PRERELEASELOOSE]}?${c[l.BUILD]}?`),m("LOOSE",`^${c[l.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${c[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${c[l.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:${c[l.PRERELEASE]})?${c[l.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:${c[l.PRERELEASELOOSE]})?${c[l.BUILD]}?)?)?`),m("XRANGE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),m("COERCE",`${c[l.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",c[l.COERCEPLAIN]+`(?:${c[l.PRERELEASE]})?`+`(?:${c[l.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",c[l.COERCE],!0),m("COERCERTLFULL",c[l.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${c[l.LONETILDE]}\\s+`,!0),r.tildeTrimReplace="$1~",m("TILDE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${c[l.LONECARET]}\\s+`,!0),r.caretTrimReplace="$1^",m("CARET",`^${c[l.LONECARET]}${c[l.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${c[l.LONECARET]}${c[l.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${c[l.GTLT]}\\s*(${c[l.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]}|${c[l.XRANGEPLAIN]})`,!0),r.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${c[l.XRANGEPLAIN]})\\s+-\\s+(${c[l.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${c[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[l.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Ue,Ue.exports);var qe=Ue.exports;const Xe=Object.freeze({loose:!0}),ze=Object.freeze({});var We=e=>e?"object"!=typeof e?Xe:e:ze;const Je=/^[0-9]+$/,Ye=(e,r)=>{if("number"==typeof e&&"number"==typeof r)return e===r?0:e<r?-1:1;const t=Je.test(e),n=Je.test(r);return t&&n&&(e=+e,r=+r),e===r?0:t&&!n?-1:n&&!t?1:e<r?-1:1};var Ze={compareIdentifiers:Ye,rcompareIdentifiers:(e,r)=>Ye(r,e)};const Qe=Ve,{MAX_LENGTH:er,MAX_SAFE_INTEGER:rr}=He,{safeRe:tr,t:nr}=qe,ir=We,{compareIdentifiers:or}=Ze;var sr=class e{constructor(r,t){if(t=ir(t),r instanceof e){if(r.loose===!!t.loose&&r.includePrerelease===!!t.includePrerelease)return r;r=r.version}else if("string"!=typeof r)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof r}".`);if(r.length>er)throw new TypeError(`version is longer than ${er} characters`);Qe("SemVer",r,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=r.trim().match(t.loose?tr[nr.LOOSE]:tr[nr.FULL]);if(!n)throw new TypeError(`Invalid Version: ${r}`);if(this.raw=r,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>rr||this.major<0)throw new TypeError("Invalid major version");if(this.minor>rr||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>rr||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const r=+e;if(r>=0&&r<rr)return r}return e}):this.prerelease=[],this.build=n[5]?n[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(Qe("SemVer.compare",this.version,this.options,r),!(r instanceof e)){if("string"==typeof r&&r===this.version)return 0;r=new e(r,this.options)}return r.version===this.version?0:this.compareMain(r)||this.comparePre(r)}compareMain(r){return r instanceof e||(r=new e(r,this.options)),this.major<r.major?-1:this.major>r.major?1:this.minor<r.minor?-1:this.minor>r.minor?1:this.patch<r.patch?-1:this.patch>r.patch?1:0}comparePre(r){if(r instanceof e||(r=new e(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 e=this.prerelease[t],n=r.prerelease[t];if(Qe("prerelease compare",t,e,n),void 0===e&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===e)return-1;if(e!==n)return or(e,n)}while(++t)}compareBuild(r){r instanceof e||(r=new e(r,this.options));let t=0;do{const e=this.build[t],n=r.build[t];if(Qe("build compare",t,e,n),void 0===e&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===e)return-1;if(e!==n)return or(e,n)}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?tr[nr.PRERELEASELOOSE]:tr[nr.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===or(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}};const ar=sr;var cr=(e,r,t=!1)=>{if(e instanceof ar)return e;try{return new ar(e,r)}catch(e){if(!t)return null;throw e}};const ur=cr;var lr=(e,r)=>{const t=ur(e,r);return t?t.version:null};const fr=cr;var pr=(e,r)=>{const t=fr(e.trim().replace(/^[=v]+/,""),r);return t?t.version:null};const hr=sr;var mr=(e,r,t,n,i)=>{"string"==typeof t&&(i=n,n=t,t=void 0);try{return new hr(e instanceof hr?e.version:e,t).inc(r,n,i).version}catch(e){return null}};const dr=cr;var Er=(e,r)=>{const t=dr(e,null,!0),n=dr(r,null,!0),i=t.compare(n);if(0===i)return null;const o=i>0,s=o?t:n,a=o?n:t,c=!!s.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(0===a.compareMain(s))return a.minor&&!a.patch?"minor":"patch"}const u=c?"pre":"";return t.major!==n.major?u+"major":t.minor!==n.minor?u+"minor":t.patch!==n.patch?u+"patch":"prerelease"};const yr=sr;var gr=(e,r)=>new yr(e,r).major;const vr=sr;var wr=(e,r)=>new vr(e,r).minor;const br=sr;var Sr=(e,r)=>new br(e,r).patch;const $r=cr;var Ir=(e,r)=>{const t=$r(e,r);return t&&t.prerelease.length?t.prerelease:null};const Rr=sr;var Ar=(e,r,t)=>new Rr(e,t).compare(new Rr(r,t));const Or=Ar;var Lr=(e,r,t)=>Or(r,e,t);const Tr=Ar;var Nr=(e,r)=>Tr(e,r,!0);const jr=sr;var Pr=(e,r,t)=>{const n=new jr(e,t),i=new jr(r,t);return n.compare(i)||n.compareBuild(i)};const kr=Pr;var _r=(e,r)=>e.sort((e,t)=>kr(e,t,r));const Cr=Pr;var xr=(e,r)=>e.sort((e,t)=>Cr(t,e,r));const Mr=Ar;var Dr=(e,r,t)=>Mr(e,r,t)>0;const Br=Ar;var Fr=(e,r,t)=>Br(e,r,t)<0;const Kr=Ar;var Gr=(e,r,t)=>0===Kr(e,r,t);const Ur=Ar;var Hr=(e,r,t)=>0!==Ur(e,r,t);const Vr=Ar;var qr=(e,r,t)=>Vr(e,r,t)>=0;const Xr=Ar;var zr=(e,r,t)=>Xr(e,r,t)<=0;const Wr=Gr,Jr=Hr,Yr=Dr,Zr=qr,Qr=Fr,et=zr;var rt=(e,r,t,n)=>{switch(r){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),e===t;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),e!==t;case"":case"=":case"==":return Wr(e,t,n);case"!=":return Jr(e,t,n);case">":return Yr(e,t,n);case">=":return Zr(e,t,n);case"<":return Qr(e,t,n);case"<=":return et(e,t,n);default:throw new TypeError(`Invalid operator: ${r}`)}};const tt=sr,nt=cr,{safeRe:it,t:ot}=qe;var st=(e,r)=>{if(e instanceof tt)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let t=null;if((r=r||{}).rtl){const n=r.includePrerelease?it[ot.COERCERTLFULL]:it[ot.COERCERTL];let i;for(;(i=n.exec(e))&&(!t||t.index+t[0].length!==e.length);)t&&i.index+i[0].length===t.index+t[0].length||(t=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}else t=e.match(r.includePrerelease?it[ot.COERCEFULL]:it[ot.COERCE]);if(null===t)return null;const n=t[2],i=t[3]||"0",o=t[4]||"0",s=r.includePrerelease&&t[5]?`-${t[5]}`:"",a=r.includePrerelease&&t[6]?`+${t[6]}`:"";return nt(`${n}.${i}.${o}${s}${a}`,r)};var at,ct,ut,lt,ft=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}};function pt(){if(ct)return at;ct=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=>!m(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&&d(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,d=s?a[c.HYPHENRANGELOOSE]:a[c.HYPHENRANGE];e=e.replace(d,O(this.options.includePrerelease)),o("hyphen replace",e),e=e.replace(a[c.COMPARATORTRIM],u),o("comparator trim",e),e=e.replace(a[c.TILDETRIM],l),o("tilde trim",e),e=e.replace(a[c.CARETTRIM],f),o("caret trim",e);let E=e.split(" ").map(e=>y(e,this.options)).join(" ").split(/\s+/).map(e=>A(e,this.options));s&&(E=E.filter(e=>(o("loose invalid filter",e,this.options),!!e.match(a[c.COMPARATORLOOSE])))),o("range list",E);const g=new Map,v=E.map(e=>new i(e,this.options));for(const e of v){if(m(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}}at=r;const t=new ft,n=We,i=ht(),o=Ve,s=sr,{safeRe:a,t:c,comparatorTrimReplace:u,tildeTrimReplace:l,caretTrimReplace:f}=qe,{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:h}=He,m=e=>"<0.0.0-0"===e.value,d=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[c.BUILD],""),o("comp",e,r),e=b(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[c.TILDELOOSE]:a[c.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})},b=(e,r)=>e.trim().split(/\s+/).map(e=>S(e,r)).join(" "),S=(e,r)=>{o("caret",e,r);const t=r.loose?a[c.CARETLOOSE]:a[c.CARET],n=r.includePrerelease?"-0":"";return e.replace(t,(r,t,i,s,a)=>{let c;return o("caret",e,r,t,i,s,a),g(t)?c="":g(i)?c=`>=${t}.0.0${n} <${+t+1}.0.0-0`:g(s)?c="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),c="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"),c="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",c),c})},$=(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[c.XRANGELOOSE]:a[c.XRANGE];return e.replace(t,(t,n,i,s,a,c)=>{o("xRange",e,t,n,i,s,a,c);const u=g(i),l=u||g(s),f=l||g(a),p=f;return"="===n&&p&&(n=""),c=r.includePrerelease?"-0":"",u?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&&(c="-0"),t=`${n+i}.${s}.${a}${c}`):l?t=`>=${i}.0.0${c} <${+i+1}.0.0-0`:f&&(t=`>=${i}.${s}.0${c} <${i}.${+s+1}.0-0`),o("xRange return",t),t})},R=(e,r)=>(o("replaceStars",e,r),e.trim().replace(a[c.STAR],"")),A=(e,r)=>(o("replaceGTE0",e,r),e.trim().replace(a[r.includePrerelease?c.GTE0PRE:c.GTE0],"")),O=e=>(r,t,n,i,o,s,a,c,u,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":""}`} ${c=g(u)?"":g(l)?`<${+u+1}.0.0-0`:g(f)?`<${u}.${+l+1}.0-0`:p?`<=${u}.${l}.${f}-${p}`:e?`<${u}.${l}.${+f+1}-0`:`<=${c}`}`.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 at}function ht(){if(lt)return ut;lt=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 c(e.value,n).test(this.value):""===e.operator?""===e.value||new c(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(">")))))))}}ut=r;const t=We,{safeRe:n,t:i}=qe,o=rt,s=Ve,a=sr,c=pt();return ut}const mt=pt();var dt=(e,r,t)=>{try{r=new mt(r,t)}catch(e){return!1}return r.test(e)};const Et=pt();var yt=(e,r)=>new Et(e,r).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" "));const gt=sr,vt=pt();var wt=(e,r,t)=>{let n=null,i=null,o=null;try{o=new vt(r,t)}catch(e){return null}return e.forEach(e=>{o.test(e)&&(n&&-1!==i.compare(e)||(n=e,i=new gt(n,t)))}),n};const bt=sr,St=pt();var $t=(e,r,t)=>{let n=null,i=null,o=null;try{o=new St(r,t)}catch(e){return null}return e.forEach(e=>{o.test(e)&&(n&&1!==i.compare(e)||(n=e,i=new bt(n,t)))}),n};const It=sr,Rt=pt(),At=Dr;var Ot=(e,r)=>{e=new Rt(e,r);let t=new It("0.0.0");if(e.test(t))return t;if(t=new It("0.0.0-0"),e.test(t))return t;t=null;for(let r=0;r<e.set.length;++r){const n=e.set[r];let i=null;n.forEach(e=>{const r=new It(e.semver.version);switch(e.operator){case">":0===r.prerelease.length?r.patch++:r.prerelease.push(0),r.raw=r.format();case"":case">=":i&&!At(r,i)||(i=r);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}}),!i||t&&!At(t,i)||(t=i)}return t&&e.test(t)?t:null};const Lt=pt();var Tt=(e,r)=>{try{return new Lt(e,r).range||"*"}catch(e){return null}};const Nt=sr,jt=ht(),{ANY:Pt}=jt,kt=pt(),_t=dt,Ct=Dr,xt=Fr,Mt=zr,Dt=qr;var Bt=(e,r,t,n)=>{let i,o,s,a,c;switch(e=new Nt(e,n),r=new kt(r,n),t){case">":i=Ct,o=Mt,s=xt,a=">",c=">=";break;case"<":i=xt,o=Dt,s=Ct,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(_t(e,r,n))return!1;for(let t=0;t<r.set.length;++t){const u=r.set[t];let l=null,f=null;if(u.forEach(e=>{e.semver===Pt&&(e=new jt(">=0.0.0")),l=l||e,f=f||e,i(e.semver,l.semver,n)?l=e:s(e.semver,f.semver,n)&&(f=e)}),l.operator===a||l.operator===c)return!1;if((!f.operator||f.operator===a)&&o(e,f.semver))return!1;if(f.operator===c&&s(e,f.semver))return!1}return!0};const Ft=Bt;var Kt=(e,r,t)=>Ft(e,r,">",t);const Gt=Bt;var Ut=(e,r,t)=>Gt(e,r,"<",t);const Ht=pt();var Vt=(e,r,t)=>(e=new Ht(e,t),r=new Ht(r,t),e.intersects(r,t));const qt=dt,Xt=Ar;const zt=pt(),Wt=ht(),{ANY:Jt}=Wt,Yt=dt,Zt=Ar,Qt=[new Wt(">=0.0.0-0")],en=[new Wt(">=0.0.0")],rn=(e,r,t)=>{if(e===r)return!0;if(1===e.length&&e[0].semver===Jt){if(1===r.length&&r[0].semver===Jt)return!0;e=t.includePrerelease?Qt:en}if(1===r.length&&r[0].semver===Jt){if(t.includePrerelease)return!0;r=en}const n=new Set;let i,o,s,a,c,u,l;for(const r of e)">"===r.operator||">="===r.operator?i=tn(i,r,t):"<"===r.operator||"<="===r.operator?o=nn(o,r,t):n.add(r.semver);if(n.size>1)return null;if(i&&o){if(s=Zt(i.semver,o.semver,t),s>0)return null;if(0===s&&(">="!==i.operator||"<="!==o.operator))return null}for(const e of n){if(i&&!Yt(e,String(i),t))return null;if(o&&!Yt(e,String(o),t))return null;for(const n of r)if(!Yt(e,String(n),t))return!1;return!0}let f=!(!o||t.includePrerelease||!o.semver.prerelease.length)&&o.semver,p=!(!i||t.includePrerelease||!i.semver.prerelease.length)&&i.semver;f&&1===f.prerelease.length&&"<"===o.operator&&0===f.prerelease[0]&&(f=!1);for(const e of r){if(l=l||">"===e.operator||">="===e.operator,u=u||"<"===e.operator||"<="===e.operator,i)if(p&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===p.major&&e.semver.minor===p.minor&&e.semver.patch===p.patch&&(p=!1),">"===e.operator||">="===e.operator){if(a=tn(i,e,t),a===e&&a!==i)return!1}else if(">="===i.operator&&!Yt(i.semver,String(e),t))return!1;if(o)if(f&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===f.major&&e.semver.minor===f.minor&&e.semver.patch===f.patch&&(f=!1),"<"===e.operator||"<="===e.operator){if(c=nn(o,e,t),c===e&&c!==o)return!1}else if("<="===o.operator&&!Yt(o.semver,String(e),t))return!1;if(!e.operator&&(o||i)&&0!==s)return!1}return!(i&&u&&!o&&0!==s)&&(!(o&&l&&!i&&0!==s)&&(!p&&!f))},tn=(e,r,t)=>{if(!e)return r;const n=Zt(e.semver,r.semver,t);return n>0?e:n<0||">"===r.operator&&">="===e.operator?r:e},nn=(e,r,t)=>{if(!e)return r;const n=Zt(e.semver,r.semver,t);return n<0?e:n>0||"<"===r.operator&&"<="===e.operator?r:e};var on=(e,r,t={})=>{if(e===r)return!0;e=new zt(e,t),r=new zt(r,t);let n=!1;e:for(const i of e.set){for(const e of r.set){const r=rn(i,e,t);if(n=n||null!==r,r)continue e}if(n)return!1}return!0};const sn=qe,an=He,cn=sr,un=Ze,ln=(e,r,t)=>{const n=[];let i=null,o=null;const s=e.sort((e,r)=>Xt(e,r,t));for(const e of s){qt(e,r,t)?(o=e,i||(i=e)):(o&&n.push([i,o]),o=null,i=null)}i&&n.push([i,null]);const a=[];for(const[e,r]of n)e===r?a.push(e):r||e!==s[0]?r?e===s[0]?a.push(`<=${r}`):a.push(`${e} - ${r}`):a.push(`>=${e}`):a.push("*");const c=a.join(" || "),u="string"==typeof r.raw?r.raw:String(r);return c.length<u.length?c:r};var fn={parse:cr,valid:lr,clean:pr,inc:mr,diff:Er,major:gr,minor:wr,patch:Sr,prerelease:Ir,compare:Ar,rcompare:Lr,compareLoose:Nr,compareBuild:Pr,sort:_r,rsort:xr,gt:Dr,lt:Fr,eq:Gr,neq:Hr,gte:qr,lte:zr,cmp:rt,coerce:st,Comparator:ht(),Range:pt(),satisfies:dt,toComparators:yt,maxSatisfying:wt,minSatisfying:$t,minVersion:Ot,validRange:Tt,outside:Bt,gtr:Kt,ltr:Ut,intersects:Vt,simplifyRange:ln,subset:on,SemVer:cn,re:sn.re,src:sn.src,tokens:sn.t,SEMVER_SPEC_VERSION:an.SEMVER_SPEC_VERSION,RELEASE_TYPES:an.RELEASE_TYPES,compareIdentifiers:un.compareIdentifiers,rcompareIdentifiers:un.rcompareIdentifiers};var pn=fn.satisfies(process.version,">=15.7.0");var hn=fn.satisfies(process.version,">=16.9.0");const mn=pn,dn=hn,En={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},yn={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};var gn=function(e,r){if(!e||!r)return;const t=r.asymmetricKeyType;if(!t)return;const n=En[t];if(!n)throw new Error(`Unknown key type "${t}".`);if(!n.includes(e))throw new Error(`"alg" parameter for "${t}" key type must be one of: ${n.join(", ")}.`);if(mn)switch(t){case"ec":const t=r.asymmetricKeyDetails.namedCurve,n=yn[e];if(t!==n)throw new Error(`"alg" parameter "${e}" requires curve "${n}".`);break;case"rsa-pss":if(dn){const t=parseInt(e.slice(-3),10),{hashAlgorithm:n,mgf1HashAlgorithm:i,saltLength:o}=r.asymmetricKeyDetails;if(n!==`sha${t}`||i!==n)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${e}.`);if(void 0!==o&&o>t>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${e}.`)}}},vn=fn.satisfies(process.version,"^6.12.0 || >=8.0.0");const wn=Oe,bn=Ne,Sn=ke,$n=Re,In=Ge,Rn=gn,An=vn,On=a,{KeyObject:Ln,createSecretKey:Tn,createPublicKey:Nn}=o,jn=["RS256","RS384","RS512"],Pn=["ES256","ES384","ES512"],kn=["RS256","RS384","RS512"],_n=["HS256","HS384","HS512"];An&&(jn.splice(jn.length,0,"PS256","PS384","PS512"),kn.splice(kn.length,0,"PS256","PS384","PS512"));var Cn=1/0,xn=9007199254740991,Mn=17976931348623157e292,Dn=NaN,Bn="[object Arguments]",Fn="[object Function]",Kn="[object GeneratorFunction]",Gn="[object String]",Un="[object Symbol]",Hn=/^\s+|\s+$/g,Vn=/^[-+]0x[0-9a-f]+$/i,qn=/^0b[01]+$/i,Xn=/^0o[0-7]+$/i,zn=/^(?:0|[1-9]\d*)$/,Wn=parseInt;function Jn(e){return e!=e}function Yn(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 Zn,Qn,ei=Object.prototype,ri=ei.hasOwnProperty,ti=ei.toString,ni=ei.propertyIsEnumerable,ii=(Zn=Object.keys,Qn=Object,function(e){return Zn(Qn(e))}),oi=Math.max;function si(e,r){var t=ui(e)||function(e){return function(e){return pi(e)&&li(e)}(e)&&ri.call(e,"callee")&&(!ni.call(e,"callee")||ti.call(e)==Bn)}(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,i=!!n;for(var o in e)!r&&!ri.call(e,o)||i&&("length"==o||ci(o,n))||t.push(o);return t}function ai(e){if(t=(r=e)&&r.constructor,n="function"==typeof t&&t.prototype||ei,r!==n)return ii(e);var r,t,n,i=[];for(var o in Object(e))ri.call(e,o)&&"constructor"!=o&&i.push(o);return i}function ci(e,r){return!!(r=null==r?xn:r)&&("number"==typeof e||zn.test(e))&&e>-1&&e%1==0&&e<r}var ui=Array.isArray;function li(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=xn}(e.length)&&!function(e){var r=fi(e)?ti.call(e):"";return r==Fn||r==Kn}(e)}function fi(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}function pi(e){return!!e&&"object"==typeof e}var hi=function(e,r,t,n){var i;e=li(e)?e:(i=e)?Yn(i,function(e){return li(e)?si(e):ai(e)}(i)):[],t=t&&!n?function(e){var r=function(e){if(!e)return 0===e?e:0;if(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||pi(e)&&ti.call(e)==Un}(e))return Dn;if(fi(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=fi(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Hn,"");var t=qn.test(e);return t||Xn.test(e)?Wn(e.slice(2),t?2:8):Vn.test(e)?Dn:+e}(e),e===Cn||e===-1/0){return(e<0?-1:1)*Mn}return e==e?e:0}(e),t=r%1;return r==r?t?r-t:r:0}(t):0;var o=e.length;return t<0&&(t=oi(o+t,0)),function(e){return"string"==typeof e||!ui(e)&&pi(e)&&ti.call(e)==Gn}(e)?t<=o&&e.indexOf(r,t)>-1:!!o&&function(e,r,t){if(r!=r)return function(e,r,t,n){for(var i=e.length,o=t+(n?1:-1);n?o--:++o<i;)if(r(e[o],o,e))return o;return-1}(e,Jn,t);for(var n=t-1,i=e.length;++n<i;)if(e[n]===r)return n;return-1}(e,r,t)>-1},mi=Object.prototype.toString;var di=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==mi.call(e)},Ei=1/0,yi=17976931348623157e292,gi=NaN,vi="[object Symbol]",wi=/^\s+|\s+$/g,bi=/^[-+]0x[0-9a-f]+$/i,Si=/^0b[01]+$/i,$i=/^0o[0-7]+$/i,Ii=parseInt,Ri=Object.prototype.toString;function Ai(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}var Oi=function(e){return"number"==typeof e&&e==function(e){var r=function(e){if(!e)return 0===e?e:0;if(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Ri.call(e)==vi}(e))return gi;if(Ai(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=Ai(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(wi,"");var t=Si.test(e);return t||$i.test(e)?Ii(e.slice(2),t?2:8):bi.test(e)?gi:+e}(e),e===Ei||e===-1/0){return(e<0?-1:1)*yi}return e==e?e:0}(e),t=r%1;return r==r?t?r-t:r:0}(e)},Li=Object.prototype.toString;var Ti=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==Li.call(e)};var Ni=Function.prototype,ji=Object.prototype,Pi=Ni.toString,ki=ji.hasOwnProperty,_i=Pi.call(Object),Ci=ji.toString,xi=function(e,r){return function(t){return e(r(t))}}(Object.getPrototypeOf,Object);var Mi=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=Ci.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=xi(e);if(null===r)return!0;var t=ki.call(r,"constructor")&&r.constructor;return"function"==typeof t&&t instanceof t&&Pi.call(t)==_i},Di=Object.prototype.toString,Bi=Array.isArray;var Fi=function(e){return"string"==typeof e||!Bi(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==Di.call(e)},Ki=1/0,Gi=17976931348623157e292,Ui=NaN,Hi="[object Symbol]",Vi=/^\s+|\s+$/g,qi=/^[-+]0x[0-9a-f]+$/i,Xi=/^0b[01]+$/i,zi=/^0o[0-7]+$/i,Wi=parseInt,Ji=Object.prototype.toString;function Yi(e,r){var t;if("function"!=typeof r)throw new TypeError("Expected a function");return e=function(e){var r=function(e){if(!e)return 0===e?e:0;if(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Ji.call(e)==Hi}(e))return Ui;if(Zi(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=Zi(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Vi,"");var t=Xi.test(e);return t||zi.test(e)?Wi(e.slice(2),t?2:8):qi.test(e)?Ui:+e}(e),e===Ki||e===-1/0){return(e<0?-1:1)*Gi}return e==e?e:0}(e),t=r%1;return r==r?t?r-t:r:0}(e),function(){return--e>0&&(t=r.apply(this,arguments)),e<=1&&(r=void 0),t}}function Zi(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}var Qi=function(e){return Yi(2,e)};const eo=Ge,ro=vn,to=gn,no=a,io=hi,oo=di,so=Oi,ao=Ti,co=Mi,uo=Fi,lo=Qi,{KeyObject:fo,createSecretKey:po,createPrivateKey:ho}=o,mo=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];ro&&mo.splice(3,0,"PS256","PS384","PS512");const Eo={expiresIn:{isValid:function(e){return so(e)||uo(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return so(e)||uo(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return uo(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:io.bind(null,mo),message:'"algorithm" must be a valid string enum value'},header:{isValid:co,message:'"header" must be an object'},encoding:{isValid:uo,message:'"encoding" must be a string'},issuer:{isValid:uo,message:'"issuer" must be a string'},subject:{isValid:uo,message:'"subject" must be a string'},jwtid:{isValid:uo,message:'"jwtid" must be a string'},noTimestamp:{isValid:oo,message:'"noTimestamp" must be a boolean'},keyid:{isValid:uo,message:'"keyid" must be a string'},mutatePayload:{isValid:oo,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:oo,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:oo,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},yo={iat:{isValid:ao,message:'"iat" should be a number of seconds'},exp:{isValid:ao,message:'"exp" should be a number of seconds'},nbf:{isValid:ao,message:'"nbf" should be a number of seconds'}};function go(e,r,t,n){if(!co(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 vo={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},wo=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];var bo={decode:Re,verify:function(e,r,t,n){let i;if("function"!=typeof t||n||(n=t,t={}),t||(t={}),t=Object.assign({},t),i=n||function(e,r){if(e)throw e;return r},t.clockTimestamp&&"number"!=typeof t.clockTimestamp)return i(new wn("clockTimestamp must be a number"));if(void 0!==t.nonce&&("string"!=typeof t.nonce||""===t.nonce.trim()))return i(new wn("nonce must be a non-empty string"));if(void 0!==t.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof t.allowInvalidAsymmetricKeyTypes)return i(new wn("allowInvalidAsymmetricKeyTypes must be a boolean"));const o=t.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return i(new wn("jwt must be provided"));if("string"!=typeof e)return i(new wn("jwt must be a string"));const s=e.split(".");if(3!==s.length)return i(new wn("jwt malformed"));let a;try{a=$n(e,{complete:!0})}catch(e){return i(e)}if(!a)return i(new wn("invalid token"));const c=a.header;let u;if("function"==typeof r){if(!n)return i(new wn("verify must be called asynchronous if secret or public key is provided as a callback"));u=r}else u=function(e,t){return t(null,r)};return u(c,function(r,n){if(r)return i(new wn("error in secret or public key callback: "+r.message));const u=""!==s[2].trim();if(!u&&n)return i(new wn("jwt signature is required"));if(u&&!n)return i(new wn("secret or public key must be provided"));if(!u&&!t.algorithms)return i(new wn('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=n&&!(n instanceof Ln))try{n=Nn(n)}catch(e){try{n=Tn("string"==typeof n?Buffer.from(n):n)}catch(e){return i(new wn("secretOrPublicKey is not valid key material"))}}if(t.algorithms||("secret"===n.type?t.algorithms=_n:["rsa","rsa-pss"].includes(n.asymmetricKeyType)?t.algorithms=kn:"ec"===n.asymmetricKeyType?t.algorithms=Pn:t.algorithms=jn),-1===t.algorithms.indexOf(a.header.alg))return i(new wn("invalid algorithm"));if(c.alg.startsWith("HS")&&"secret"!==n.type)return i(new wn(`secretOrPublicKey must be a symmetric key when using ${c.alg}`));if(/^(?:RS|PS|ES)/.test(c.alg)&&"public"!==n.type)return i(new wn(`secretOrPublicKey must be an asymmetric key when using ${c.alg}`));if(!t.allowInvalidAsymmetricKeyTypes)try{Rn(c.alg,n)}catch(e){return i(e)}let l;try{l=On.verify(e,a.header.alg,n)}catch(e){return i(e)}if(!l)return i(new wn("invalid signature"));const f=a.payload;if(void 0!==f.nbf&&!t.ignoreNotBefore){if("number"!=typeof f.nbf)return i(new wn("invalid nbf value"));if(f.nbf>o+(t.clockTolerance||0))return i(new bn("jwt not active",new Date(1e3*f.nbf)))}if(void 0!==f.exp&&!t.ignoreExpiration){if("number"!=typeof f.exp)return i(new wn("invalid exp value"));if(o>=f.exp+(t.clockTolerance||0))return i(new Sn("jwt expired",new Date(1e3*f.exp)))}if(t.audience){const e=Array.isArray(t.audience)?t.audience:[t.audience];if(!(Array.isArray(f.aud)?f.aud:[f.aud]).some(function(r){return e.some(function(e){return e instanceof RegExp?e.test(r):e===r})}))return i(new wn("jwt audience invalid. expected: "+e.join(" or ")))}if(t.issuer){if("string"==typeof t.issuer&&f.iss!==t.issuer||Array.isArray(t.issuer)&&-1===t.issuer.indexOf(f.iss))return i(new wn("jwt issuer invalid. expected: "+t.issuer))}if(t.subject&&f.sub!==t.subject)return i(new wn("jwt subject invalid. expected: "+t.subject));if(t.jwtid&&f.jti!==t.jwtid)return i(new wn("jwt jwtid invalid. expected: "+t.jwtid));if(t.nonce&&f.nonce!==t.nonce)return i(new wn("jwt nonce invalid. expected: "+t.nonce));if(t.maxAge){if("number"!=typeof f.iat)return i(new wn("iat required when maxAge is specified"));const e=In(t.maxAge,f.iat);if(void 0===e)return i(new wn('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(o>=e+(t.clockTolerance||0))return i(new Sn("maxAge exceeded",new Date(1e3*e)))}if(!0===t.complete){const e=a.signature;return i(null,{header:c,payload:f,signature:e})}return i(null,f)})},sign:function(e,r,t,n){"function"==typeof t?(n=t,t={}):t=t||{};const i="object"==typeof e&&!Buffer.isBuffer(e),o=Object.assign({alg:t.algorithm||"HS256",typ:i?"JWT":void 0,kid:t.keyid},t.header);function s(e){if(n)return n(e);throw e}if(!r&&"none"!==t.algorithm)return s(new Error("secretOrPrivateKey must have a value"));if(null!=r&&!(r instanceof fo))try{r=ho(r)}catch(e){try{r=po("string"==typeof r?Buffer.from(r):r)}catch(e){return s(new Error("secretOrPrivateKey is not valid key material"))}}if(o.alg.startsWith("HS")&&"secret"!==r.type)return s(new Error(`secretOrPrivateKey must be a symmetric key when using ${o.alg}`));if(/^(?:RS|PS|ES)/.test(o.alg)){if("private"!==r.type)return s(new Error(`secretOrPrivateKey must be an asymmetric key when using ${o.alg}`));if(!t.allowInsecureKeySizes&&!o.alg.startsWith("ES")&&void 0!==r.asymmetricKeyDetails&&r.asymmetricKeyDetails.modulusLength<2048)return s(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${o.alg}`))}if(void 0===e)return s(new Error("payload is required"));if(i){try{!function(e){go(yo,!0,e,"payload")}(e)}catch(e){return s(e)}t.mutatePayload||(e=Object.assign({},e))}else{const r=wo.filter(function(e){return void 0!==t[e]});if(r.length>0)return s(new Error("invalid "+r.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==t.expiresIn)return s(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==t.notBefore)return s(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){go(Eo,!1,e,"options")}(t)}catch(e){return s(e)}if(!t.allowInvalidAsymmetricKeyTypes)try{to(o.alg,r)}catch(e){return s(e)}const a=e.iat||Math.floor(Date.now()/1e3);if(t.noTimestamp?delete e.iat:i&&(e.iat=a),void 0!==t.notBefore){try{e.nbf=eo(t.notBefore,a)}catch(e){return s(e)}if(void 0===e.nbf)return s(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==t.expiresIn&&"object"==typeof e){try{e.exp=eo(t.expiresIn,a)}catch(e){return s(e)}if(void 0===e.exp)return s(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(vo).forEach(function(r){const n=vo[r];if(void 0!==t[r]){if(void 0!==e[n])return s(new Error('Bad "options.'+r+'" option. The payload already has an "'+n+'" property.'));e[n]=t[r]}});const c=t.encoding||"utf8";if("function"!=typeof n){let n=no.sign({header:o,payload:e,secret:r,encoding:c});if(!t.allowInsecureKeySizes&&/^(?:RS|PS)/.test(o.alg)&&n.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${o.alg}`);return n}n=n&&lo(n),no.createSign({header:o,privateKey:r,payload:e,encoding:c}).once("error",n).once("done",function(e){if(!t.allowInsecureKeySizes&&/^(?:RS|PS)/.test(o.alg)&&e.length<256)return n(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${o.alg}`));n(null,e)})},JsonWebTokenError:Oe,NotBeforeError:Ne,TokenExpiredError:ke},So=s(bo);const $o=e(import.meta.url),{version:Io}=$o("../package.json");var Ro={id:"sso",handler:(e,t)=>{const{env:n,logger:i,services:o,database:s,getSchema:a}=t,c=n.KEYCLOAK_URL||"http://keycloak:8080",u=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",m=Array.isArray(h)?h.map(e=>String(e).trim()):String(h).split(",").map(e=>e.trim()),d=m[0],E=n.MOBILE_APP_CALLBACK_PATH||"/auth/callback",y=n.GOOGLE_CALLBACK_PATH||"/auth/callback/google",g=n.KEYCLOAK_CLIENT_ID||"admin-cli",v=n.COOKIE_DOMAIN||null,w="false"!==n.COOKIE_SECURE,b=n.COOKIE_SAME_SITE||"lax",S=n.SESSION_COOKIE_NAME||"directus_session_token",$=n.REFRESH_TOKEN_COOKIE_NAME||"directus_refresh_token",I=n.DEFAULT_ROLE_ID||null,R="directus_session_token",A=n.FCM_PROJECT_ID||null,O=n.FCM_CLIENT_EMAIL||null,L=n.FCM_PRIVATE_KEY?n.FCM_PRIVATE_KEY.replace(/\\n/g,"\n"):null,T=n.FCM_WEBHOOK_SECRET||null;function N(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 j(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 P(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 k(e){const r=e.cookies[$];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 _(e){const r=e.query.app_scheme;return r&&m.includes(r)?r:(r&&i.warn(`⚠️ Warning: App requested scheme '${r}', but it is not in .env. Falling back to '${d}'`),d)}i.info("🚀 Mobile Auth & FCM Proxy Extension loaded"),i.info("📱 Allowed Mobile App Schemes: "+m.join(", ")),A&&L?i.info("🔔 FCM Module: ENABLED for project "+A):i.warn("⚠️ FCM Module: DISABLED (Missing Credentials in .env)"),e.get("/health",(e,r)=>{r.json({status:"ok",service:"directus-extension-sso",version:Io,allowed_schemes:m,fcm_enabled:!!A})}),e.get("/mobile-callback",async(e,r)=>{const t=N(e);try{let n=null;if(S!==R&&(n=await j(e,S)),n||(n=await j(e,R)),n||(n=await P(e)),n||(n=await k(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,c=i;if(t){r.cookie(S,i,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),S!==R&&r.cookie(R,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";return r.redirect(t)}const u=_(e),l=`${u}://${(e.query.app_path||E).replace(/^\/+/,"")}?access_token=${c}&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=N(e);try{let n=null;if(e.query.access_token){n={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 ${n.token}`}});if(e.ok){const r=await e.json();n.userData=r.data}else n=null}catch(e){n=null}}if(n||S===R||(n=await j(e,S)),n||(n=await j(e,R)),n||(n=await P(e)),n||(n=await k(e)),!n)return r.send("<html><body><h2>Authentication Failed</h2></body></html>");const{token:o,userData:s}=n,a=s.id,c=s.email,u=o;if(t){r.cookie(S,o,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),S!==R&&r.cookie(R,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";return r.send(`<html><head><meta http-equiv="refresh" content="2;url=${t}"></head><body>Login Successful!</body></html>`)}const l=_(e),f=e.query.app_path||y,h=new URL(`${l}://${f.replace(/^\/+/,"")}`);return h.searchParams.set("access_token",u),h.searchParams.set("user_id",a),h.searchParams.set("email",c||""),h.searchParams.set("provider","google"),i.info("🚀 Performing direct 302 redirect to app: "+h.toString()),r.redirect(302,h.toString())}catch(e){r.status(500).send(`<html><body><h2>Error</h2><p>${e.message}</p></body></html>`)}}),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 o=null;try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${n}`}});if(e.ok){o=(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(o)try{const e=await async function(){try{const e=await fetch(`${c}/realms/master/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"password",client_id:g,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}}();if(e){const r=await async function(e,r){try{const t=await fetch(`${c}/admin/realms/${u}/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}}(e,o);r&&await async function(e,r){try{const t=await fetch(`${c}/admin/realms/${u}/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}}(e,r)}}catch(e){}r.json({success:!0,message:"Logged out successfully"})}catch(e){r.status(500).json({error:e.message})}}),e.post("/apple-token",async(e,t)=>{const{identityToken:c,firstName:u,lastName:l}=e.body;if(i.info("🍎 Apple token exchange request received"),!c)return t.status(400).json({error:"identityToken is required",message:"Apple identityToken must be provided in the request body"});try{const e="com.forumbandung.app",i=async t=>{const[n,i,o]=t.split("."),s=JSON.parse(Buffer.from(n,"base64").toString()),a=JSON.parse(Buffer.from(i,"base64").toString());if("https://appleid.apple.com"!==a.iss)throw new Error("Invalid issuer");const c=[e.toLowerCase(),"host.exp.exponent"],u=a.aud.toLowerCase();if(!c.includes(u))throw new Error("Invalid audience");if(a.exp<Math.floor(Date.now()/1e3))throw new Error("Token expired");const l=await fetch("https://appleid.apple.com/auth/keys"),{keys:f}=await l.json(),p=f.find(e=>e.kid===s.kid);if(!p)throw new Error("Apple public key not found");const h=r.createPublicKey({key:p,format:"jwk"}),m=r.createVerify("RSA-SHA256");m.update(`${n}.${i}`);if(!m.verify(h,o,"base64url"))throw new Error("Invalid signature");return a},f=await i(c),{email:p,sub:h}=f;if(!p)throw new Error("Apple token did not contain an email");const{UsersService:m}=o,d=new m({schema:await a(),knex:s}),E=await d.readByQuery({filter:{email:{_eq:p}}});let y,g;E.length>0?(g=E[0],y=g.id,g.external_identifier||await d.updateOne(y,{external_identifier:h,provider:"apple"})):(y=await d.createOne({email:p,first_name:u||"Apple User",last_name:l||"",role:I,status:"active",provider:"apple",external_identifier:h}),g=await d.readOne(y));const v={id:y,role:g.role||I,app_access:!0,admin_access:!1},w=So.sign(v,n.SECRET,{expiresIn:"7d",issuer:"directus"}),b={id:y,type:"refresh"},S=So.sign(b,n.SECRET,{expiresIn:"30d",issuer:"directus"});t.json({success:!0,data:{access_token:w,refresh_token:S,expires:604800,user:g},user_id:y,email:p,provider:"apple"})}catch(e){t.status(500).json({error:e.message,message:"Failed to verify Apple token"})}}),e.get("/bridge",async(e,r)=>{const{token:t,redirect_uri:n,redirect:i}=e.query,o=t,s=n||i||"/";if(!o)return r.status(400).json({error:"Token required",message:"No access token provided"});try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${o}`}});if(!e.ok)return r.status(401).json({error:"Invalid token"});await e.json();return r.cookie(S,o,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),S!==R&&r.cookie(R,o,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),r.redirect(s)}catch(e){r.status(500).json({error:"Bridge failure",message:e.message})}}),e.post("/send-fcm",async(e,t)=>{const n=e.headers["x-fcm-secret"];if(T&&n!==T)return i.warn("🚨 Percobaan akses FCM Endpoint ditolak (Secret tidak cocok/hilang)"),t.status(401).json({error:"Unauthorized. Cek header x-fcm-secret."});if(!A||!O||!L)return t.status(500).json({error:"Kredensial FCM belum diatur di .env server."});const{tokens:o,title:s,body:a,metadata:c}=e.body;if(!o||!Array.isArray(o)||0===o.length)return t.status(400).json({error:'Payload harus memiliki array "tokens".'});try{const e=await async function(){const e=Math.floor(Date.now()/1e3),t={iss:O,scope:"https://www.googleapis.com/auth/firebase.messaging",aud:"https://oauth2.googleapis.com/token",exp:e+3600,iat:e},n=e=>Buffer.from(JSON.stringify(e)).toString("base64url"),i=`${n({alg:"RS256",typ:"JWT"})}.${n(t)}`,o=r.createSign("RSA-SHA256");o.update(i);const s=`${i}.${o.sign(L,"base64url")}`,a=await fetch("https://oauth2.googleapis.com/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=${s}`});if(!a.ok)throw new Error("Gagal mendapatkan token Google OAuth");return(await a.json()).access_token}(),n=[];for(const r of o){const t={message:{token:r,notification:{title:s||"Notifikasi Baru",body:a||"Anda menerima pesan."},data:{routing_info:c?JSON.stringify(c):"{}"}}},i=await fetch(`https://fcm.googleapis.com/v1/projects/${A}/messages:send`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await i.json();n.push({token:r,status:i.status,response:o})}i.info(`✅ Berhasil mengirim ${n.length} notifikasi FCM.`),t.json({success:!0,sent_count:n.length,details:n})}catch(e){i.error("❌ Error mengirim notifikasi FCM:",e),t.status(500).json({error:e.message})}})}};export{Ro 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,f,l,p,h,m,d,E,y,g,v,w,b,S,$,I,R,O,A,L,T,N,j,P,k,_,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 F(){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 K(){if(h)return p;h=1;var e=B().Buffer,r=function(){if(l)return f;function e(e){return(e/8|0)+(e%8==0?0:1)}l=1;var r={ES256:e(256),ES384:e(384),ES512:e(521)};return f=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 f=t[u++];if(a-u-2<f)throw new Error('"r" specified length of "'+f+'", only "'+(a-u-2)+'" available');if(s<f)throw new Error('"r" specified length of "'+f+'", max of "'+s+'" is acceptable');var l=u;if(u+=f,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 m=o-f,d=o-p,E=e.allocUnsafe(m+f+d+p);for(u=0;u<m;++u)E[u]=0;t.copy(E,u,l+Math.max(-m,0),l+f);for(var y=u=o;u<y+d;++u)E[u]=0;return t.copy(E,u,h+Math.max(-d,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),f=i(o,a,o.length),l=a-c,p=a-f,h=2+l+1+1+p,m=h<t,d=e.allocUnsafe((m?2:3)+h),E=0;return d[E++]=48,m?d[E++]=h:(d[E++]=129,d[E++]=255&h),d[E++]=2,d[E++]=l,c<0?(d[E++]=0,E+=o.copy(d,E,0,a)):E+=o.copy(d,E,c,a),d[E++]=2,d[E++]=p,f<0?(d[E++]=0,o.copy(d,E,a)):o.copy(d,E,a+f),d}}}function G(){if(y)return E;y=1;var e,r=B().Buffer,n=o,s=K(),a=i,u="secret must be a string or buffer",c="key must be a string or a buffer",f="function"==typeof n.createPublicKey;function l(e){if(!r.isBuffer(e)&&"string"!=typeof e){if(!f)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 b(e){return function(t,i){!function(e){if(!r.isBuffer(e)){if("string"==typeof e)return e;if(!f)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")))}}f&&(c+=" or a KeyObject",u+="or a KeyObject");var S="timingSafeEqual"in n?function(e,r){return e.byteLength===r.byteLength&&n.timingSafeEqual(e,r)}:function(r,n){return e||(e=function(){if(d)return m;d=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}m=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},m}()),e(r,n)};function $(e){return function(t,n,i){var o=b(e)(t,i);return S(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){l(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){l(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:b,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 H(){if(b)return w;b=1;var e=B().Buffer,r=F(),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),f=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),l=c.sign(f,i);return a.format("%s.%s",f,l)}function f(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(f,o),f.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")}},f.sign=c,w=f}function V(){if($)return S;$=1;var e=B().Buffer,r=F(),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 f(e){return e.split(".")[2]}function l(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=f(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||{},!l(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:f(r)}}function m(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(m,o),m.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")}},m.decode=h,m.isValid=l,m.verify=p,S=m}function q(){if(I)return D;I=1;var e=H(),r=V();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=q();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(P)return j;P=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 k;_=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 k=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,fe,le,pe,he,me,de,Ee,ye,ge,ve,we,be,Se,$e,Ie,Re,Oe,Ae,Le,Te,Ne,je,Pe,ke,_e,Ce,xe,De,Me,Be,Fe,Ke,Ge,Ue,He,Ve,qe,Xe,ze,We,Ye,Je,Ze,Qe,er,rr,tr,nr,ir,or,sr,ar,ur,cr,fr,lr,pr,hr,mr,dr,Er,yr,gr,vr,wr,br,Sr,$r,Ir,Rr,Or,Ar,Lr,Tr,Nr,jr,Pr,kr,_r,Cr,xr,Dr,Mr,Br,Fr,Kr,Gr,Ur,Hr,Vr,qr,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 ft(){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 lt(){return ne||(ne=1,function(e,r){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=ct(),o=ft(),s=(r=e.exports={}).re=[],a=r.safeRe=[],u=r.src=[],c=r.safeSrc=[],f=r.t={};let l=0;const p="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[p,n]],m=(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=l++;o(e,i,r),f[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)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),m("MAINVERSION",`(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\.${u[f.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${p}+`),m("BUILD",`(?:\\+(${u[f.BUILDIDENTIFIER]}(?:\\.${u[f.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),m("FULL",`^${u[f.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),m("LOOSE",`^${u[f.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${u[f.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),m("XRANGE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),m("COERCE",`${u[f.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",u[f.COERCE],!0),m("COERCERTLFULL",u[f.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${u[f.LONETILDE]}\\s+`,!0),r.tildeTrimReplace="$1~",m("TILDE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${u[f.LONECARET]}\\s+`,!0),r.caretTrimReplace="$1^",m("CARET",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${u[f.GTLT]}\\s*(${u[f.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),r.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${u[f.XRANGEPLAIN]})\\s+-\\s+(${u[f.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${u[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[f.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("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 mt(){if(ce)return ue;ce=1;const e=ft(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:t}=ct(),{safeRe:n,t:i}=lt(),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 dt(){if(le)return fe;le=1;const e=mt();return fe=(r,t,n=!1)=>{if(r instanceof e)return r;try{return new e(r,t)}catch(e){if(!n)return null;throw e}},fe}function Et(){if(Te)return Le;Te=1;const e=mt();return Le=(r,t,n)=>new e(r,n).compare(new e(t,n))}function yt(){if(Ce)return _e;Ce=1;const e=mt();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(Ke)return Fe;Ke=1;const e=Et();return Fe=(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(Ve)return He;Ve=1;const e=Et();return He=(r,t,n)=>0===e(r,t,n)}function bt(){if(Xe)return qe;Xe=1;const e=Et();return qe=(r,t,n)=>0!==e(r,t,n)}function St(){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=bt(),t=gt(),n=St(),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=>!m(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&&d(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,d=s?a[u.HYPHENRANGELOOSE]:a[u.HYPHENRANGE];e=e.replace(d,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],f),o("tilde trim",e),e=e.replace(a[u.CARETTRIM],l),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(m(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=ft(),s=mt(),{safeRe:a,t:u,comparatorTrimReplace:c,tildeTrimReplace:f,caretTrimReplace:l}=lt(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:h}=ct(),m=e=>"<0.0.0-0"===e.value,d=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=b(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})},b=(e,r)=>e.trim().split(/\s+/).map(e=>S(e,r)).join(" "),S=(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),f=c||g(s),l=f||g(a),p=l;return"="===n&&p&&(n=""),u=r.includePrerelease?"-0":"",c?t=">"===n||"<"===n?"<0.0.0-0":"*":n&&p?(f&&(s=0),a=0,">"===n?(n=">=",f?(i=+i+1,s=0,a=0):(s=+s+1,a=0)):"<="===n&&(n="<",f?i=+i+1:s=+s+1),"<"===n&&(u="-0"),t=`${n+i}.${s}.${a}${u}`):f?t=`>=${i}.0.0${u} <${+i+1}.0.0-0`:l&&(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,f,l,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(f)?`<${+c+1}.0.0-0`:g(l)?`<${c}.${+f+1}.0-0`:p?`<=${c}.${f}.${l}-${p}`:e?`<${c}.${f}.${+l+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}=lt(),o=It(),s=ft(),a=mt(),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(br)return wr;br=1;const e=mt(),r=Ot(),{ANY:t}=r,n=Rt(),i=At(),o=gt(),s=vt(),a=$t(),u=St();return wr=(c,f,l,p)=>{let h,m,d,E,y;switch(c=new e(c,p),f=new n(f,p),l){case">":h=o,m=a,d=s,E=">",y=">=";break;case"<":h=s,m=u,d=o,E="<",y="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(c,f,p))return!1;for(let e=0;e<f.set.length;++e){const n=f.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:d(e.semver,o.semver,p)&&(o=e)}),i.operator===E||i.operator===y)return!1;if((!o.operator||o.operator===E)&&m(c,o.semver))return!1;if(o.operator===y&&d(c,o.semver))return!1}return!0},wr}function Nt(){if(kr)return Pr;kr=1;const e=lt(),r=ct(),t=mt(),n=ht(),i=dt(),o=function(){if(he)return pe;he=1;const e=dt();return pe=(r,t)=>{const n=e(r,t);return n?n.version:null},pe}(),s=function(){if(de)return me;de=1;const e=dt();return me=(r,t)=>{const n=e(r.trim().replace(/^[=v]+/,""),t);return n?n.version:null},me}(),a=function(){if(ye)return Ee;ye=1;const e=mt();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=dt();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 f=c?"pre":"";return n.major!==i.major?f+"major":n.minor!==i.minor?f+"minor":n.patch!==i.patch?f+"patch":"prerelease"}}(),c=function(){if(be)return we;be=1;const e=mt();return we=(r,t)=>new e(r,t).major}(),f=function(){if($e)return Se;$e=1;const e=mt();return Se=(r,t)=>new e(r,t).minor}(),l=function(){if(Re)return Ie;Re=1;const e=mt();return Ie=(r,t)=>new e(r,t).patch}(),p=function(){if(Ae)return Oe;Ae=1;const e=dt();return Oe=(r,t)=>{const n=e(r,t);return n&&n.prerelease.length?n.prerelease:null},Oe}(),h=Et(),m=function(){if(je)return Ne;je=1;const e=Et();return Ne=(r,t,n)=>e(t,r,n)}(),d=function(){if(ke)return Pe;ke=1;const e=Et();return Pe=(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(),b=wt(),S=bt(),$=St(),I=$t(),R=It(),O=function(){if(rr)return er;rr=1;const e=mt(),r=dt(),{safeRe:t,t:n}=lt();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",f=o.includePrerelease&&s[5]?`-${s[5]}`:"",l=o.includePrerelease&&s[6]?`+${s[6]}`:"";return r(`${a}.${u}.${c}${f}${l}`,o)},er}(),A=Ot(),L=Rt(),T=At(),N=function(){if(lr)return fr;lr=1;const e=Rt();return fr=(r,t)=>new e(r,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" ")),fr}(),j=function(){if(hr)return pr;hr=1;const e=mt(),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}(),P=function(){if(dr)return mr;dr=1;const e=mt(),r=Rt();return mr=(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},mr}(),k=function(){if(yr)return Er;yr=1;const e=mt(),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 Sr;$r=1;const e=Tt();return Sr=(r,t,n)=>e(r,t,">",n),Sr}(),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 f=c.join(" || "),l="string"==typeof n.raw?n.raw:String(n);return f.length<l.length?f:n},Lr}(),F=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 f=new Set;let l,p,h,m,d,E,y;for(const r of e)">"===r.operator||">="===r.operator?l=u(l,r,a):"<"===r.operator||"<="===r.operator?p=c(p,r,a):f.add(r.semver);if(f.size>1)return null;if(l&&p){if(h=i(l.semver,p.semver,a),h>0)return null;if(0===h&&(">="!==l.operator||"<="!==p.operator))return null}for(const e of f){if(l&&!n(e,String(l),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=!(!l||a.includePrerelease||!l.semver.prerelease.length)&&l.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,l)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(m=u(l,e,a),m===e&&m!==l)return!1}else if(">="===l.operator&&!n(l.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(d=c(p,e,a),d===e&&d!==p)return!1}else if("<="===p.operator&&!n(p.semver,String(e),a))return!1;if(!e.operator&&(p||l)&&0!==h)return!1}return!(l&&E&&!p&&0!==h||p&&y&&!l&&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 Pr={parse:i,valid:o,clean:s,inc:a,diff:u,major:c,minor:f,patch:l,prerelease:p,compare:h,rcompare:m,compareLoose:d,compareBuild:E,sort:y,rsort:g,gt:v,lt:w,eq:b,neq:S,gte:$,lte:I,cmp:R,coerce:O,Comparator:A,Range:L,satisfies:T,toComparators:N,maxSatisfying:j,minSatisfying:P,minVersion:k,validRange:_,outside:C,gtr:x,ltr:D,intersects:M,simplifyRange:B,subset:F,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 Pt(){if(Kr)return Fr;Kr=1;var e=Nt();return Fr=e.satisfies(process.version,"^6.12.0 || >=8.0.0")}function kt(){if(Ur)return Gr;Ur=1;const e=z(),r=W(),t=Y(),n=X(),i=Z(),s=jt(),a=Pt(),u=q(),{KeyObject:c,createSecretKey:f,createPublicKey:l}=o,p=["RS256","RS384","RS512"],h=["ES256","ES384","ES512"],m=["RS256","RS384","RS512"],d=["HS256","HS384","HS512"];return a&&(p.splice(p.length,0,"PS256","PS384","PS512"),m.splice(m.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 b;try{b=n(o,{complete:!0})}catch(e){return g(e)}if(!b)return g(new e("invalid token"));const S=b.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 $(S,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=l(a)}catch(r){try{a=f("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=d:["rsa","rsa-pss"].includes(a.asymmetricKeyType)?E.algorithms=m:"ec"===a.asymmetricKeyType?E.algorithms=h:E.algorithms=p),-1===E.algorithms.indexOf(b.header.alg))return g(new e("invalid algorithm"));if(S.alg.startsWith("HS")&&"secret"!==a.type)return g(new e(`secretOrPublicKey must be a symmetric key when using ${S.alg}`));if(/^(?:RS|PS|ES)/.test(S.alg)&&"public"!==a.type)return g(new e(`secretOrPublicKey must be an asymmetric key when using ${S.alg}`));if(!E.allowInvalidAsymmetricKeyTypes)try{s(S.alg,a)}catch(e){return g(e)}let $;try{$=u.verify(o,b.header.alg,a)}catch(e){return g(e)}if(!$)return g(new e("invalid signature"));const I=b.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=b.signature;return g(null,{header:S,payload:I,signature:e})}return g(null,I)})},Gr}function _t(){if(Vr)return Hr;Vr=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,f=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,p=/^0o[0-7]+$/i,h=/^(?:0|[1-9]\d*)$/,m=parseInt;function d(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,b=v.toString,S=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")&&(!S.call(e,"callee")||b.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)?b.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 Hr=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)&&b.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=l.test(e);return t||p.test(e)?m(e.slice(2),t?2:8):f.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)&&b.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,d,t);for(var n=t-1,i=e.length;++n<i;)if(e[n]===r)return n;return-1}(r,i,o)>-1},Hr}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 f(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}return zr=function(l){return"number"==typeof l&&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 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 f(f,p){var h;if("function"!=typeof p)throw new TypeError("Expected a function");return 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(){return--f>0&&(h=p.apply(this,arguments)),f<=1&&(p=void 0),h}}function l(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}return tt=function(e){return f(2,e)}}function Dt(){if(ot)return it;ot=1;const e=Z(),r=Pt(),t=jt(),n=q(),i=_t(),s=function(){if(Xr)return qr;Xr=1;var e=Object.prototype.toString;return qr=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}}(),f=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)}}(),l=xt(),{KeyObject:p,createSecretKey:h,createPrivateKey:m}=o,d=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];r&&d.splice(3,0,"PS256","PS384","PS512");const E={expiresIn:{isValid:function(e){return a(e)||f(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return a(e)||f(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return f(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:i.bind(null,d),message:'"algorithm" must be a valid string enum value'},header:{isValid:c,message:'"header" must be an object'},encoding:{isValid:f,message:'"encoding" must be a string'},issuer:{isValid:f,message:'"issuer" must be a string'},subject:{isValid:f,message:'"subject" must be a string'},jwtid:{isValid:f,message:'"jwtid" must be a string'},noTimestamp:{isValid:s,message:'"noTimestamp" must be a boolean'},keyid:{isValid:f,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=m(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 f=r.iat||Math.floor(Date.now()/1e3);if(o.noTimestamp?delete r.iat:a&&(r.iat=f),void 0!==o.notBefore){try{r.nbf=e(o.notBefore,f)}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,f)}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 d=o.encoding||"utf8";if("function"!=typeof s){let e=n.sign({header:u,payload:r,secret:i,encoding:d});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&&l(s),n.createSign({header:u,privateKey:i,payload:r,encoding:d}).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:kt(),sign:Dt(),JsonWebTokenError:z(),NotBeforeError:W(),TokenExpiredError:Y()}));const Bt=e(import.meta.url),{version:Ft}=Bt("../package.json");var Kt={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",f=n.KEYCLOAK_ADMIN_USER||"admin",l=n.KEYCLOAK_ADMIN_PASSWORD||"admin",p=n.PUBLIC_URL||"http://localhost:8055",h=n.MOBILE_APP_SCHEME||"finsnapp",m=Array.isArray(h)?h.map(e=>String(e).trim()):String(h).split(",").map(e=>e.trim()),d=m[0],E=n.MOBILE_APP_CALLBACK_PATH||"/auth/callback",y=n.GOOGLE_CALLBACK_PATH||"/auth/callback/google",g=n.KEYCLOAK_CLIENT_ID||"admin-cli",v=n.COOKIE_DOMAIN||null,w="false"!==n.COOKIE_SECURE,b=n.COOKIE_SAME_SITE||"lax",S=n.SESSION_COOKIE_NAME||"directus_session_token",$=n.REFRESH_TOKEN_COOKIE_NAME||"directus_refresh_token",I=n.DEFAULT_ROLE_ID||null,R="directus_session_token",O=n.FCM_PROJECT_ID||null;function A(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 L(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 T(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 N(e){const r=e.cookies[$];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 j(e){const r=e.query.app_scheme;return r&&m.includes(r)?r:(r&&i.warn(`⚠️ Warning: App requested scheme '${r}', but it is not in .env. Falling back to '${d}'`),d)}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: "+m.join(", ")),e.get("/health",(e,r)=>{r.json({status:"ok",service:"directus-extension-sso",version:Ft,allowed_schemes:m,fcm_enabled:!!O})}),e.get("/mobile-callback",async(e,r)=>{const t=A(e);try{let n=null;if(S!==R&&(n=await L(e,S)),n||(n=await L(e,R)),n||(n=await T(e)),n||(n=await N(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(S,i,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),S!==R&&r.cookie(R,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";return r.redirect(t)}const c=j(e),f=`${c}://${(e.query.app_path||E).replace(/^\/+/,"")}?access_token=${u}&user_id=${s}&email=${encodeURIComponent(a||"")}`;return r.setHeader("Location",f),r.status(302).send(`<html><head><meta http-equiv="refresh" content="0;url=${f}"></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=A(e);try{let n=null;if(e.query.access_token){n={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 ${n.token}`}});if(e.ok){const r=await e.json();n.userData=r.data}else n=null}catch(e){n=null}}if(n||S===R||(n=await L(e,S)),n||(n=await L(e,R)),n||(n=await T(e)),n||(n=await N(e)),!n)return r.send("<html><body><h2>Authentication Failed</h2></body></html>");const{token:o,userData:s}=n,a=s.id,u=s.email,c=o;if(t){r.cookie(S,o,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),S!==R&&r.cookie(R,"",{maxAge:0,path:"/"});let t=e.query.redirect_uri||e.query.redirect||"/";return r.send(`<html><head><meta http-equiv="refresh" content="2;url=${t}"></head><body>Login Successful!</body></html>`)}const f=j(e),l=e.query.app_path||y,h=new URL(`${f}://${l.replace(/^\/+/,"")}`);return h.searchParams.set("access_token",c),h.searchParams.set("user_id",a),h.searchParams.set("email",u||""),h.searchParams.set("provider","google"),i.info("🚀 Performing direct 302 redirect to app: "+h.toString()),r.redirect(302,h.toString())}catch(e){r.status(500).send(`<html><body><h2>Error</h2><p>${e.message}</p></body></html>`)}}),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 o=null;try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${n}`}});if(e.ok){o=(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(o)try{const e=await async function(){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:g,username:f,password:l}).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}}();if(e){const r=await async function(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}}(e,o);r&&await async function(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}}(e,r)}}catch(e){}r.json({success:!0,message:"Logged out successfully"})}catch(e){r.status(500).json({error:e.message})}}),e.post("/apple-token",async(e,t)=>{const{identityToken:u,firstName:c,lastName:f}=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=n.APPLE_CLIENT_ID||"com.forumbandung.app",i=async t=>{const[n,i,o]=t.split("."),s=JSON.parse(Buffer.from(n,"base64").toString()),a=JSON.parse(Buffer.from(i,"base64").toString());if("https://appleid.apple.com"!==a.iss)throw new Error("Invalid issuer");const u=[e.toLowerCase(),"host.exp.exponent"],c=a.aud.toLowerCase();if(!u.includes(c))throw new Error("Invalid audience");if(a.exp<Math.floor(Date.now()/1e3))throw new Error("Token expired");const f=await fetch("https://appleid.apple.com/auth/keys"),{keys:l}=await f.json(),p=l.find(e=>e.kid===s.kid);if(!p)throw new Error("Apple public key not found");const h=r.createPublicKey({key:p,format:"jwk"}),m=r.createVerify("RSA-SHA256");m.update(`${n}.${i}`);if(!m.verify(h,o,"base64url"))throw new Error("Invalid signature");return a},l=await i(u),{email:p,sub:h}=l;if(!p)throw new Error("Apple token did not contain an email");const{UsersService:m}=o,d=new m({schema:await a(),knex:s}),E=await d.readByQuery({filter:{email:{_eq:p}}});let y,g;E.length>0?(g=E[0],y=g.id,g.external_identifier||await d.updateOne(y,{external_identifier:h,provider:"apple"})):(y=await d.createOne({email:p,first_name:c||"Apple User",last_name:f||"",role:I,status:"active",provider:"apple",external_identifier:h}),g=await d.readOne(y));const v={id:y,role:g.role||I,app_access:!0,admin_access:!1},w=Mt.sign(v,n.SECRET,{expiresIn:"7d",issuer:"directus"}),b={id:y,type:"refresh"},S=Mt.sign(b,n.SECRET,{expiresIn:"30d",issuer:"directus"});t.json({success:!0,data:{access_token:w,refresh_token:S,expires:604800,user:g},user_id:y,email:p,provider:"apple"})}catch(e){t.status(500).json({error:e.message,message:"Failed to verify Apple token"})}}),e.get("/bridge",async(e,r)=>{const{token:t,redirect_uri:n,redirect:i}=e.query,o=t,s=n||i||"/";if(!o)return r.status(400).json({error:"Token required",message:"No access token provided"});try{const e=await fetch(`${p}/users/me`,{headers:{Authorization:`Bearer ${o}`}});if(!e.ok)return r.status(401).json({error:"Invalid token"});await e.json();return r.cookie(S,o,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),S!==R&&r.cookie(R,o,{httpOnly:!0,secure:w,domain:v,sameSite:b,maxAge:6048e5,path:"/"}),r.redirect(s)}catch(e){r.status(500).json({error:"Bridge failure",message:e.message})}})}};export{Kt as default};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ymys/directus-extension-sso",
3
- "description": "Mobile OAuth proxy endpoints for Directus + Keycloak + Google",
3
+ "description": "Mobile OAuth proxy endpoints for Directus + Keycloak + Google + Apple",
4
4
  "icon": "smartphone",
5
- "version": "2.1.10",
5
+ "version": "2.2.12",
6
6
  "keywords": [
7
7
  "directus",
8
8
  "directus-extension",
9
- "directus-extension-endpoint",
9
+ "directus-extension-bundle",
10
10
  "sso",
11
11
  "keycloak",
12
12
  "google",
@@ -51,6 +51,6 @@
51
51
  "jsonwebtoken": "^9.0.3"
52
52
  },
53
53
  "devDependencies": {
54
- "@directus/extensions-sdk": "^12.0.2"
54
+ "@directus/extensions-sdk": "^17.1.4"
55
55
  }
56
56
  }