insomnia-plugin-auth0
Version:
Seamless store and refresh Auth0 tokens that can be automatically injected into requests, depending on configured urls/methods.
5 lines • 1.9 MB
JavaScript
var vk=Object.create;var Wc=Object.defineProperty,xk=Object.defineProperties,Ek=Object.getOwnPropertyDescriptor,Sk=Object.getOwnPropertyDescriptors,Ck=Object.getOwnPropertyNames,f3=Object.getOwnPropertySymbols,Tk=Object.getPrototypeOf,d3=Object.prototype.hasOwnProperty,_k=Object.prototype.propertyIsEnumerable;var r0=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),wk=t=>{throw TypeError(t)};var n0=(t,e,i)=>e in t?Wc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,fs=(t,e)=>{for(var i in e||(e={}))d3.call(e,i)&&n0(t,i,e[i]);if(f3)for(var i of f3(e))_k.call(e,i)&&n0(t,i,e[i]);return t},Kc=(t,e)=>xk(t,Sk(e));var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ak=(t,e)=>{for(var i in e)Wc(t,i,{get:e[i],enumerable:!0})},mp=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ck(e))!d3.call(t,r)&&r!==i&&Wc(t,r,{get:()=>e[r],enumerable:!(s=Ek(e,r))||s.enumerable});return t},h3=(t,e,i)=>(mp(t,e,"default"),i&&mp(i,e,"default")),gp=(t,e,i)=>(i=t!=null?vk(Tk(t)):{},mp(e||!t||!t.__esModule?Wc(i,"default",{value:t,enumerable:!0}):i,t)),Ik=t=>mp(Wc({},"__esModule",{value:!0}),t);var vo=(t,e,i)=>n0(t,typeof e!="symbol"?e+"":e,i);var me=(t,e,i)=>new Promise((s,r)=>{var n=c=>{try{o(i.next(c))}catch(u){r(u)}},a=c=>{try{o(i.throw(c))}catch(u){r(u)}},o=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,a);o((i=i.apply(t,e)).next())}),Pk=function(t,e){this[0]=t,this[1]=e};var a0=t=>{var e=t[r0("asyncIterator")],i=!1,s,r={};return e==null?(e=t[r0("iterator")](),s=n=>r[n]=a=>e[n](a)):(e=e.call(t),s=n=>r[n]=a=>{if(i){if(i=!1,n==="throw")throw a;return a}return i=!0,{done:!1,value:new Pk(new Promise(o=>{var c=e[n](a);c instanceof Object||wk("Object expected"),o(c)}),1)}}),r[r0("iterator")]=()=>r,s("next"),"throw"in e?s("throw"):r.throw=n=>{throw n},"return"in e&&s("return"),r};var A3=j(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});function Ws(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(i[s[r]]=t[s[r]]);return i}var ta=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function y0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function b0(t,e){return e={exports:{}},t(e,e.exports),e.exports}var ea=b0(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function r(){var n=this;this.locked=new Map,this.addToLocked=function(a,o){var c=n.locked.get(a);c===void 0?o===void 0?n.locked.set(a,[]):n.locked.set(a,[o]):o!==void 0&&(c.unshift(o),n.locked.set(a,c))},this.isLocked=function(a){return n.locked.has(a)},this.lock=function(a){return new Promise(function(o,c){n.isLocked(a)?n.addToLocked(a,o):(n.addToLocked(a),o())})},this.unlock=function(a){var o=n.locked.get(a);if(o===void 0||o.length===0){n.locked.delete(a);return}var c=o.pop();n.locked.set(a,o),c!==void 0&&setTimeout(c,0)}}return r.getInstance=function(){return r.instance===void 0&&(r.instance=new r),r.instance},r}();function s(){return i.getInstance()}e.default=s});y0(ea);var Nk=b0(function(t,e){var i=ta&&ta.__awaiter||function(p,f,d,m){return new(d||(d=Promise))(function(h,y){function E(v){try{g(m.next(v))}catch(S){y(S)}}function x(v){try{g(m.throw(v))}catch(S){y(S)}}function g(v){v.done?h(v.value):new d(function(S){S(v.value)}).then(E,x)}g((m=m.apply(p,f||[])).next())})},s=ta&&ta.__generator||function(p,f){var d={label:0,sent:function(){if(y[0]&1)throw y[1];return y[1]},trys:[],ops:[]},m,h,y,E;return E={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(E[Symbol.iterator]=function(){return this}),E;function x(v){return function(S){return g([v,S])}}function g(v){if(m)throw new TypeError("Generator is already executing.");for(;d;)try{if(m=1,h&&(y=v[0]&2?h.return:v[0]?h.throw||((y=h.return)&&y.call(h),0):h.next)&&!(y=y.call(h,v[1])).done)return y;switch(h=0,y&&(v=[v[0]&2,y.value]),v[0]){case 0:case 1:y=v;break;case 4:return d.label++,{value:v[1],done:!1};case 5:d.label++,h=v[1],v=[0];continue;case 7:v=d.ops.pop(),d.trys.pop();continue;default:if(y=d.trys,!(y=y.length>0&&y[y.length-1])&&(v[0]===6||v[0]===2)){d=0;continue}if(v[0]===3&&(!y||v[1]>y[0]&&v[1]<y[3])){d.label=v[1];break}if(v[0]===6&&d.label<y[1]){d.label=y[1],y=v;break}if(y&&d.label<y[2]){d.label=y[2],d.ops.push(v);break}y[2]&&d.ops.pop(),d.trys.pop();continue}v=f.call(p,d)}catch(S){v=[6,S],h=0}finally{m=y=0}if(v[0]&5)throw v[1];return{value:v[0]?v[1]:void 0,done:!0}}},r=ta;Object.defineProperty(e,"__esModule",{value:!0});var n="browser-tabs-lock-key",a={key:function(p){return i(r,void 0,void 0,function(){return s(this,function(f){throw new Error("Unsupported")})})},getItem:function(p){return i(r,void 0,void 0,function(){return s(this,function(f){throw new Error("Unsupported")})})},clear:function(){return i(r,void 0,void 0,function(){return s(this,function(p){return[2,window.localStorage.clear()]})})},removeItem:function(p){return i(r,void 0,void 0,function(){return s(this,function(f){throw new Error("Unsupported")})})},setItem:function(p,f){return i(r,void 0,void 0,function(){return s(this,function(d){throw new Error("Unsupported")})})},keySync:function(p){return window.localStorage.key(p)},getItemSync:function(p){return window.localStorage.getItem(p)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(p){return window.localStorage.removeItem(p)},setItemSync:function(p,f){return window.localStorage.setItem(p,f)}};function o(p){return new Promise(function(f){return setTimeout(f,p)})}function c(p){for(var f="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",d="",m=0;m<p;m++){var h=Math.floor(Math.random()*f.length);d+=f[h]}return d}function u(){return Date.now().toString()+c(15)}var l=function(){function p(f){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=u(),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=f,p.waiters===void 0&&(p.waiters=[])}return p.prototype.acquireLock=function(f,d){return d===void 0&&(d=5e3),i(this,void 0,void 0,function(){var m,h,y,E,x,g,v,S;return s(this,function(P){switch(P.label){case 0:m=Date.now()+c(4),h=Date.now()+d,y=n+"-"+f,E=this.storageHandler===void 0?a:this.storageHandler,P.label=1;case 1:return Date.now()<h?[4,o(30)]:[3,8];case 2:return P.sent(),x=E.getItemSync(y),x!==null?[3,5]:(g=this.id+"-"+f+"-"+m,[4,o(Math.floor(Math.random()*25))]);case 3:return P.sent(),E.setItemSync(y,JSON.stringify({id:this.id,iat:m,timeoutKey:g,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,o(30)];case 4:return P.sent(),v=E.getItemSync(y),v!==null&&(S=JSON.parse(v),S.id===this.id&&S.iat===m)?(this.acquiredIatSet.add(m),this.refreshLockWhileAcquired(y,m),[2,!0]):[3,7];case 5:return p.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(h)];case 6:P.sent(),P.label=7;case 7:return m=Date.now()+c(4),[3,1];case 8:return[2,!1]}})})},p.prototype.refreshLockWhileAcquired=function(f,d){return i(this,void 0,void 0,function(){var m=this;return s(this,function(h){return setTimeout(function(){return i(m,void 0,void 0,function(){var y,E,x;return s(this,function(g){switch(g.label){case 0:return[4,ea.default().lock(d)];case 1:if(g.sent(),!this.acquiredIatSet.has(d))return ea.default().unlock(d),[2];if(y=this.storageHandler===void 0?a:this.storageHandler,E=y.getItemSync(f),E!==null)x=JSON.parse(E),x.timeRefreshed=Date.now(),y.setItemSync(f,JSON.stringify(x)),ea.default().unlock(d);else return ea.default().unlock(d),[2];return this.refreshLockWhileAcquired(f,d),[2]}})})},1e3),[2]})})},p.prototype.waitForSomethingToChange=function(f){return i(this,void 0,void 0,function(){return s(this,function(d){switch(d.label){case 0:return[4,new Promise(function(m){var h=!1,y=Date.now(),E=50,x=!1;function g(){if(x||(window.removeEventListener("storage",g),p.removeFromWaiting(g),clearTimeout(v),x=!0),!h){h=!0;var S=E-(Date.now()-y);S>0?setTimeout(m,S):m(null)}}window.addEventListener("storage",g),p.addToWaiting(g);var v=setTimeout(g,Math.max(0,f-Date.now()))})];case 1:return d.sent(),[2]}})})},p.addToWaiting=function(f){this.removeFromWaiting(f),p.waiters!==void 0&&p.waiters.push(f)},p.removeFromWaiting=function(f){p.waiters!==void 0&&(p.waiters=p.waiters.filter(function(d){return d!==f}))},p.notifyWaiters=function(){if(p.waiters!==void 0){var f=p.waiters.slice();f.forEach(function(d){return d()})}},p.prototype.releaseLock=function(f){return i(this,void 0,void 0,function(){return s(this,function(d){switch(d.label){case 0:return[4,this.releaseLock__private__(f)];case 1:return[2,d.sent()]}})})},p.prototype.releaseLock__private__=function(f){return i(this,void 0,void 0,function(){var d,m,h,y;return s(this,function(E){switch(E.label){case 0:return d=this.storageHandler===void 0?a:this.storageHandler,m=n+"-"+f,h=d.getItemSync(m),h===null?[2]:(y=JSON.parse(h),y.id!==this.id?[3,2]:[4,ea.default().lock(y.iat)]);case 1:E.sent(),this.acquiredIatSet.delete(y.iat),d.removeItemSync(m),ea.default().unlock(y.iat),p.notifyWaiters(),E.label=2;case 2:return[2]}})})},p.lockCorrector=function(f){for(var d=Date.now()-5e3,m=f,h=[],y=0;;){var E=m.keySync(y);if(E===null)break;h.push(E),y++}for(var x=!1,g=0;g<h.length;g++){var v=h[g];if(v.includes(n)){var S=m.getItemSync(v);if(S!==null){var P=JSON.parse(S);(P.timeRefreshed===void 0&&P.timeAcquired<d||P.timeRefreshed!==void 0&&P.timeRefreshed<d)&&(m.removeItemSync(v),x=!0)}}}x&&p.notifyWaiters()},p.waiters=void 0,p}();e.default=l}),Ok=y0(Nk),kk="2.2.0",Tp=60,Rk={timeoutInSeconds:Tp},Mk=3,Lk=2,S3=1e4,m3="memory",Dk="Missing Refresh Token",Fk="invalid refresh token",Bk="openid profile email",jk=1,C3={name:"auth0-spa-js",version:kk},T3=()=>Date.now(),li=class t extends Error{constructor(e,i){super(i),this.error=e,this.error_description=i,Object.setPrototypeOf(this,t.prototype)}static fromPayload({error:e,error_description:i}){return new t(e,i)}},yp=class t extends li{constructor(e,i,s,r=null){super(e,i),this.state=s,this.appState=r,Object.setPrototypeOf(this,t.prototype)}},Eo=class t extends li{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,t.prototype)}},bp=class t extends Eo{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,t.prototype)}},vp=class t extends li{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,t.prototype)}},xp=class t extends li{constructor(e,i,s){super(e,i),this.mfa_token=s,Object.setPrototypeOf(this,t.prototype)}},Qc=class t extends li{constructor(e,i){super("missing_refresh_token",`Missing Refresh Token (audience: '${g3(e,["default"])}', scope: '${g3(i)}')`),this.audience=e,this.scope=i,Object.setPrototypeOf(this,t.prototype)}};function g3(t,e=[]){return t&&!e.includes(t)?t:""}var Uk=t=>{t.indexOf("#")>-1&&(t=t.substring(0,t.indexOf("#")));let e=new URLSearchParams(t);return{state:e.get("state"),code:e.get("code")||void 0,error:e.get("error")||void 0,error_description:e.get("error_description")||void 0}},Vk=(t,e,i=Tp)=>new Promise((s,r)=>{let n=window.document.createElement("iframe");n.setAttribute("width","0"),n.setAttribute("height","0"),n.style.display="none";let a=()=>{window.document.body.contains(n)&&(window.document.body.removeChild(n),window.removeEventListener("message",o,!1))},o,c=setTimeout(()=>{r(new Eo),a()},i*1e3);o=function(u){if(u.origin!=e||!u.data||u.data.type!=="authorization_response")return;let l=u.source;l&&l.close(),u.data.response.error?r(li.fromPayload(u.data.response)):s(u.data.response),clearTimeout(c),window.removeEventListener("message",o,!1),setTimeout(a,Lk*1e3)},window.addEventListener("message",o,!1),window.document.body.appendChild(n),n.setAttribute("src",t)}),$k=t=>{let s=window.screenX+(window.innerWidth-400)/2,r=window.screenY+(window.innerHeight-600)/2;return window.open(t,"auth0:authorize:popup",`left=${s},top=${r},width=400,height=600,resizable,scrollbars=yes,status=1`)},Hk=t=>new Promise((e,i)=>{let s,r=setInterval(()=>{t.popup&&t.popup.closed&&(clearInterval(r),clearTimeout(n),window.removeEventListener("message",s,!1),i(new vp(t.popup)))},1e3),n=setTimeout(()=>{clearInterval(r),i(new bp(t.popup)),window.removeEventListener("message",s,!1)},(t.timeoutInSeconds||Tp)*1e3);s=function(a){if(!(!a.data||a.data.type!=="authorization_response")){if(clearTimeout(n),clearInterval(r),window.removeEventListener("message",s,!1),t.popup.close(),a.data.response.error)return i(li.fromPayload(a.data.response));e(a.data.response)}},window.addEventListener("message",s)}),Ep=()=>window.crypto,o0=()=>{let t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.",e="";return Array.from(Ep().getRandomValues(new Uint8Array(43))).forEach(s=>e+=t[s%t.length]),e},y3=t=>btoa(t),qk=t=>Object.keys(t).filter(e=>typeof t[e]!="undefined").reduce((e,i)=>Object.assign(Object.assign({},e),{[i]:t[i]}),{}),f0=t=>{var{clientId:e}=t,i=Ws(t,["clientId"]);return new URLSearchParams(qk(Object.assign({client_id:e},i))).toString()},zk=t=>me(null,null,function*(){return yield Ep().subtle.digest({name:"SHA-256"},new TextEncoder().encode(t))}),Xk=t=>{let e={"+":"-","/":"_","=":""};return t.replace(/[+/=]/g,i=>e[i])},Gk=t=>decodeURIComponent(atob(t).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),b3=t=>Gk(t.replace(/_/g,"/").replace(/-/g,"+")),Wk=t=>{let e=new Uint8Array(t);return Xk(window.btoa(String.fromCharCode(...Array.from(e))))},Kk=()=>{if(!Ep())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(typeof Ep().subtle=="undefined")throw new Error(`
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
`)},Jk=t=>/^https?:\/\//.test(t)?t:`https://${t}`,Yk=(t,e)=>t?t.startsWith("https://")?t:`https://${t}/`:`${e}/`,Zk=t=>typeof t!="string"?t:parseInt(t,10)||void 0,Qk=(t,e)=>new Promise(function(i,s){let r=new MessageChannel;r.port1.onmessage=function(n){n.data.error?s(new Error(n.data.error)):i(n.data),r.port1.close()},e.postMessage(t,[r.port2])}),eR=()=>new AbortController,tR=(t,e)=>me(null,null,function*(){let i=yield fetch(t,e);return{ok:i.ok,json:yield i.json()}}),iR=(t,e,i)=>me(null,null,function*(){let s=eR();e.signal=s.signal;let r;return Promise.race([tR(t,e),new Promise((n,a)=>{r=setTimeout(()=>{s.abort(),a(new Error("Timeout when executing 'fetch'"))},i)})]).finally(()=>{clearTimeout(r)})}),sR=(t,e,i,s,r,n,a)=>me(null,null,function*(){return Qk({auth:{audience:e,scope:i},timeout:r,fetchUrl:t,fetchOptions:s,useFormData:a},n)}),rR=(o,c,u,l,p,f,...d)=>me(null,[o,c,u,l,p,f,...d],function*(t,e,i,s,r,n,a=S3){return r?sR(t,e,i,s,a,r,n):iR(t,s,a)});function nR(t,e,i,s,r,n,a){return me(this,null,function*(){let o=null,c;for(let m=0;m<Mk;m++)try{c=yield rR(t,i,s,r,n,a,e),o=null;break}catch(h){o=h}if(o)throw o;let u=c.json,{error:l,error_description:p}=u,f=Ws(u,["error","error_description"]),{ok:d}=c;if(!d){let m=p||`HTTP error. Unable to fetch ${t}`;throw l==="mfa_required"?new xp(l,m,f.mfa_token):l==="missing_refresh_token"?new Qc(i,s):new li(l||"request_error",m)}return f})}function aR(t,e){return me(this,null,function*(){var{baseUrl:i,timeout:s,audience:r,scope:n,auth0Client:a,useFormData:o}=t,c=Ws(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);let u=o?f0(c):JSON.stringify(c);return yield nR(`${i}/oauth/token`,s,r||"default",n,{method:"POST",body:u,headers:{"Content-Type":o?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||C3))}},e,o)})}var oR=t=>Array.from(new Set(t)),Yc=(...t)=>oR(t.filter(Boolean).join(" ").trim().split(/\s+/)).join(" "),eu="@@auth0spajs@@",Zc="@@user@@",Ks=class t{constructor(e,i=eu,s){this.prefix=i,this.suffix=s,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(e){let[i,s,r,n]=e.split("::");return new t({clientId:s,scope:n,audience:r},i)}static fromCacheEntry(e){let{scope:i,audience:s,client_id:r}=e;return new t({scope:i,audience:s,clientId:r})}},Sp=class{set(e,i){localStorage.setItem(e,JSON.stringify(i))}get(e){let i=window.localStorage.getItem(e);if(i)try{return JSON.parse(i)}catch(s){return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(eu))}},tu=class{constructor(){this.enclosedCache=function(){let e={};return{set(i,s){e[i]=s},get(i){let s=e[i];if(s)return s},remove(i){delete e[i]},allKeys(){return Object.keys(e)}}}()}},cR=0,d0=class{constructor(e,i,s){this.cache=e,this.keyManifest=i,this.nowProvider=s||T3}setIdToken(e,i,s){return me(this,null,function*(){var r;let n=this.getIdTokenCacheKey(e);yield this.cache.set(n,{id_token:i,decodedToken:s}),yield(r=this.keyManifest)===null||r===void 0?void 0:r.add(n)})}getIdToken(e){return me(this,null,function*(){let i=yield this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!i&&e.scope&&e.audience){let s=yield this.get(e);return!s||!s.id_token||!s.decodedToken?void 0:{id_token:s.id_token,decodedToken:s.decodedToken}}if(i)return{id_token:i.id_token,decodedToken:i.decodedToken}})}get(s){return me(this,arguments,function*(e,i=cR){var r;let n=yield this.cache.get(e.toKey());if(!n){let c=yield this.getCacheKeys();if(!c)return;let u=this.matchExistingCacheKey(e,c);u&&(n=yield this.cache.get(u))}if(!n)return;let a=yield this.nowProvider(),o=Math.floor(a/1e3);if(n.expiresAt-i<o){if(n.body.refresh_token)return n.body={refresh_token:n.body.refresh_token},yield this.cache.set(e.toKey(),n),n.body;yield this.cache.remove(e.toKey()),yield(r=this.keyManifest)===null||r===void 0?void 0:r.remove(e.toKey());return}return n.body})}set(e){return me(this,null,function*(){var i;let s=new Ks({clientId:e.client_id,scope:e.scope,audience:e.audience}),r=yield this.wrapCacheEntry(e);yield this.cache.set(s.toKey(),r),yield(i=this.keyManifest)===null||i===void 0?void 0:i.add(s.toKey())})}clear(e){return me(this,null,function*(){var i;let s=yield this.getCacheKeys();s&&(yield s.filter(r=>e?r.includes(e):!0).reduce((r,n)=>me(this,null,function*(){yield r,yield this.cache.remove(n)}),Promise.resolve()),yield(i=this.keyManifest)===null||i===void 0?void 0:i.clear())})}wrapCacheEntry(e){return me(this,null,function*(){let i=yield this.nowProvider(),s=Math.floor(i/1e3)+e.expires_in;return{body:e,expiresAt:s}})}getCacheKeys(){return me(this,null,function*(){var e;if(this.keyManifest)return(e=yield this.keyManifest.get())===null||e===void 0?void 0:e.keys;if(this.cache.allKeys)return this.cache.allKeys()})}getIdTokenCacheKey(e){return new Ks({clientId:e},eu,Zc).toKey()}matchExistingCacheKey(e,i){return i.filter(s=>{var r;let n=Ks.fromKey(s),a=new Set(n.scope&&n.scope.split(" ")),o=((r=e.scope)===null||r===void 0?void 0:r.split(" "))||[],c=n.scope&&o.reduce((u,l)=>u&&a.has(l),!0);return n.prefix===eu&&n.clientId===e.clientId&&n.audience===e.audience&&c})[0]}},uR="a0.spajs.txs",h0=class{constructor(e,i,s){this.storage=e,this.clientId=i,this.cookieDomain=s,this.storageKey=`${uR}.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}},Jc=t=>typeof t=="number",lR=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"],pR=t=>{let e=t.split("."),[i,s,r]=e;if(e.length!==3||!i||!s||!r)throw new Error("ID token could not be decoded");let n=JSON.parse(b3(s)),a={__raw:t},o={};return Object.keys(n).forEach(c=>{a[c]=n[c],lR.includes(c)||(o[c]=n[c])}),{encoded:{header:i,payload:s,signature:r},header:JSON.parse(b3(i)),claims:a,user:o}},fR=t=>{if(!t.id_token)throw new Error("ID token is required but missing");let e=pR(t.id_token);if(!e.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(e.claims.iss!==t.iss)throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);if(!e.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if(e.header.alg!=="RS256")throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!e.claims.aud||!(typeof e.claims.aud=="string"||Array.isArray(e.claims.aud)))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(e.claims.aud)){if(!e.claims.aud.includes(t.aud))throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);if(e.claims.aud.length>1){if(!e.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(e.claims.azp!==t.aud)throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`)}}else if(e.claims.aud!==t.aud)throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);if(t.nonce){if(!e.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(e.claims.nonce!==t.nonce)throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`)}if(t.max_age&&!Jc(e.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(e.claims.exp==null||!Jc(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Jc(e.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");let i=t.leeway||60,s=new Date(t.now||Date.now()),r=new Date(0);if(r.setUTCSeconds(e.claims.exp+i),s>r)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${s}) is after expiration time (${r})`);if(e.claims.nbf!=null&&Jc(e.claims.nbf)){let n=new Date(0);if(n.setUTCSeconds(e.claims.nbf-i),s<n)throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${s}) is before ${n}`)}if(e.claims.auth_time!=null&&Jc(e.claims.auth_time)){let n=new Date(0);if(n.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+i),s>n)throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${s}) is after last auth at ${n}`)}if(t.organization){let n=t.organization.trim();if(n.startsWith("org_")){let a=n;if(e.claims.org_id){if(a!==e.claims.org_id)throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`)}else throw new Error("Organization ID (org_id) claim must be a string present in the ID token")}else{let a=n.toLowerCase();if(e.claims.org_name){if(a!==e.claims.org_name)throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`)}else throw new Error("Organization Name (org_name) claim must be a string present in the ID token")}}return e},ia=b0(function(t,e){var i=ta&&ta.__assign||function(){return i=Object.assign||function(p){for(var f,d=1,m=arguments.length;d<m;d++){f=arguments[d];for(var h in f)Object.prototype.hasOwnProperty.call(f,h)&&(p[h]=f[h])}return p},i.apply(this,arguments)};e.__esModule=!0;function s(p,f){if(!f)return"";var d="; "+p;return f===!0?d:d+"="+f}function r(p){if(typeof p.expires=="number"){var f=new Date;f.setMilliseconds(f.getMilliseconds()+p.expires*864e5),p.expires=f}return s("Expires",p.expires?p.expires.toUTCString():"")+s("Domain",p.domain)+s("Path",p.path)+s("Secure",p.secure)+s("SameSite",p.sameSite)}function n(p,f,d){return encodeURIComponent(p).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(f).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+r(d)}e.encode=n;function a(p){for(var f={},d=p?p.split("; "):[],m=/(%[\dA-F]{2})+/gi,h=0;h<d.length;h++){var y=d[h].split("="),E=y.slice(1).join("=");E.charAt(0)==='"'&&(E=E.slice(1,-1));try{var x=y[0].replace(m,decodeURIComponent);f[x]=E.replace(m,decodeURIComponent)}catch(g){}}return f}e.parse=a;function o(){return a(document.cookie)}e.getAll=o;function c(p){return o()[p]}e.get=c;function u(p,f,d){document.cookie=n(p,f,i({path:"/"},d))}e.set=u;function l(p,f){u(p,"",i(i({},f),{expires:-1}))}e.remove=l});y0(ia);ia.encode;ia.parse;ia.getAll;var dR=ia.get,_3=ia.set,w3=ia.remove,xo={get(t){let e=dR(t);if(typeof e!="undefined")return JSON.parse(e)},save(t,e,i){let s={};window.location.protocol==="https:"&&(s={secure:!0,sameSite:"none"}),i!=null&&i.daysUntilExpire&&(s.expires=i.daysUntilExpire),i!=null&&i.cookieDomain&&(s.domain=i.cookieDomain),_3(t,JSON.stringify(e),s)},remove(t,e){let i={};e!=null&&e.cookieDomain&&(i.domain=e.cookieDomain),w3(t,i)}},c0="_legacy_",hR={get(t){let e=xo.get(t);return e||xo.get(`${c0}${t}`)},save(t,e,i){let s={};window.location.protocol==="https:"&&(s={secure:!0}),i!=null&&i.daysUntilExpire&&(s.expires=i.daysUntilExpire),i!=null&&i.cookieDomain&&(s.domain=i.cookieDomain),_3(`${c0}${t}`,JSON.stringify(e),s),xo.save(t,e,i)},remove(t,e){let i={};e!=null&&e.cookieDomain&&(i.domain=e.cookieDomain),w3(t,i),xo.remove(t,e),xo.remove(`${c0}${t}`,e)}},mR={get(t){if(typeof sessionStorage=="undefined")return;let e=sessionStorage.getItem(t);if(e!=null)return JSON.parse(e)},save(t,e){sessionStorage.setItem(t,JSON.stringify(e))},remove(t){sessionStorage.removeItem(t)}};function gR(t,e){var i=atob(t);if(e){for(var s=new Uint8Array(i.length),r=0,n=i.length;r<n;++r)s[r]=i.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(s.buffer))}return i}function yR(t,e,i){var s=e===void 0?null:e,r=i===void 0?!1:i,n=gR(t,r),a=n.indexOf(`
`,10)+1,o=n.substring(a)+(s?"//# sourceMappingURL="+s:""),c=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(c)}function bR(t,e,i){var s;return function(n){return s=s||yR(t,e,i),new Worker(s,n)}}var vR=bR("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKSB7CiAgICAidXNlIHN0cmljdCI7CiAgICBjbGFzcyBHZW5lcmljRXJyb3IgZXh0ZW5kcyB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fdG9rZW4iKSB7CiAgICAgICAgICAgICAgICBjb25zdCByZWZyZXNoVG9rZW4gPSBnZXRSZWZyZXNoVG9rZW4oYXVkaWVuY2UsIHNjb3BlKTsKICAgICAgICAgICAgICAgIGlmICghcmVmcmVzaFRva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IE1pc3NpbmdSZWZyZXNoVG9rZW5FcnJvcihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmV0Y2hPcHRpb25zLmJvZHkgPSB1c2VGb3JtRGF0YSA/IGNyZWF0ZVF1ZXJ5UGFyYW1zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKSA6IEpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgYm9keSksIHsKICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiByZWZyZXNoVG9rZW4KICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgYWJvcnRDb250cm9sbGVyOwogICAgICAgICAgICBpZiAodHlwZW9mIEFib3J0Q29udHJvbGxlciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcjsKICAgICAgICAgICAgICAgIGZldGNoT3B0aW9ucy5zaWduYWwgPSBhYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCByZXNwb25zZTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgUHJvbWlzZS5yYWNlKFsgd2FpdCh0aW1lb3V0KSwgZmV0Y2goZmV0Y2hVcmwsIE9iamVjdC5hc3NpZ24oe30sIGZldGNoT3B0aW9ucykpIF0pOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICAgICAgICAgIGlmIChhYm9ydENvbnRyb2xsZXIpIGFib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgcG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgZXJyb3I6ICJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCciCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBqc29uID0gYXdhaXQgcmVzcG9uc2UuanNvbigpOwogICAgICAgICAgICBpZiAoanNvbi5yZWZyZXNoX3Rva2VuKSB7CiAgICAgICAgICAgICAgICBzZXRSZWZyZXNoVG9rZW4oanNvbi5yZWZyZXNoX3Rva2VuLCBhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICAgICAgZGVsZXRlIGpzb24ucmVmcmVzaF90b2tlbjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRlbGV0ZVJlZnJlc2hUb2tlbihhdWRpZW5jZSwgc2NvcGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcnQucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgb2s6IHJlc3BvbnNlLm9rLAogICAgICAgICAgICAgICAganNvbjoganNvbgogICAgICAgICAgICB9KTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBwb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgIG9rOiBmYWxzZSwKICAgICAgICAgICAgICAgIGpzb246IHsKICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3IuZXJyb3IsCiAgICAgICAgICAgICAgICAgICAgZXJyb3JfZGVzY3JpcHRpb246IGVycm9yLm1lc3NhZ2UKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgfQogICAgfTsKICAgIHsKICAgICAgICBhZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgbWVzc2FnZUhhbmRsZXIpOwogICAgfQp9KSgpOwoK",null,!1),u0={},xR=(t,e)=>{let i=u0[e];return i||(i=t().finally(()=>{delete u0[e],i=null}),u0[e]=i),i},ER=(t,e=3)=>me(null,null,function*(){for(let i=0;i<e;i++)if(yield t())return!0;return!1}),m0=class{constructor(e,i){this.cache=e,this.clientId=i,this.manifestKey=this.createManifestKeyFrom(this.clientId)}add(e){return me(this,null,function*(){var i;let s=new Set(((i=yield this.cache.get(this.manifestKey))===null||i===void 0?void 0:i.keys)||[]);s.add(e),yield this.cache.set(this.manifestKey,{keys:[...s]})})}remove(e){return me(this,null,function*(){let i=yield this.cache.get(this.manifestKey);if(i){let s=new Set(i.keys);return s.delete(e),s.size>0?yield this.cache.set(this.manifestKey,{keys:[...s]}):yield this.cache.remove(this.manifestKey)}})}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`${eu}::${e}`}},l0="auth0.lock.getTokenSilently",SR=t=>`auth0.${t}.organization_hint`,v3="auth0.is.authenticated",CR=t=>`auth0.${t}.is.authenticated`,TR={memory:()=>new tu().enclosedCache,localstorage:()=>new Sp},x3=t=>TR[t],_R=(t,e,i,s,r,n,a,o)=>Object.assign(Object.assign(Object.assign({client_id:t.clientId},t.authorizationParams),i),{scope:Yc(e,i.scope),response_type:"code",response_mode:o||"query",state:s,nonce:r,redirect_uri:a||t.authorizationParams.redirect_uri,code_challenge:n,code_challenge_method:"S256"}),E3=t=>{let{openUrl:e,onRedirect:i}=t,s=Ws(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},s),{openUrl:e===!1||e?e:i})},p0=new Ok,Cp=class{constructor(e){this.userCache=new tu().enclosedCache,this.defaultOptions={authorizationParams:{scope:Bk},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=()=>me(this,null,function*(){yield p0.releaseLock(l0),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}),this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window!="undefined"&&Kk(),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`.");let i,s;if(e.cache)s=e.cache;else{if(i=e.cacheLocation||m3,!x3(i))throw new Error(`Invalid cache location "${i}"`);s=x3(i)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?e.httpTimeoutInSeconds*1e3:S3,this.cookieStorage=e.legacySameSiteCookie===!1?xo:hR,this.orgHintCookieName=SR(this.options.clientId),this.isAuthenticatedCookieName=CR(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||jk;let r=e.useCookiesForTransactions?this.cookieStorage:mR;this.scope=Yc("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new h0(r,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||T3,this.cacheManager=new d0(s,s.allKeys?void 0:new m0(s,this.options.clientId),this.nowProvider),this.domainUrl=Jk(this.options.domain),this.tokenIssuer=Yk(this.options.issuer,this.domainUrl),typeof window!="undefined"&&window.Worker&&this.options.useRefreshTokens&&i===m3&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new vR)}_url(e){let i=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||C3)));return`${this.domainUrl}${e}&auth0Client=${i}`}_authorizeUrl(e){return this._url(`/authorize?${f0(e)}`)}_verifyIdToken(e,i,s){return me(this,null,function*(){let r=yield this.nowProvider();return fR({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:i,organization:s,leeway:this.options.leeway,max_age:Zk(this.options.authorizationParams.max_age),now:r})})}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_prepareAuthorizeUrl(e,i,s){return me(this,null,function*(){let r=y3(o0()),n=y3(o0()),a=o0(),o=yield zk(a),c=Wk(o),u=_R(this.options,this.scope,e,r,n,c,e.redirect_uri||this.options.authorizationParams.redirect_uri||s,i==null?void 0:i.response_mode),l=this._authorizeUrl(u);return{nonce:n,code_verifier:a,scope:u.scope,audience:u.audience||"default",redirect_uri:u.redirect_uri,state:r,url:l}})}loginWithPopup(e,i){return me(this,null,function*(){var s;if(e=e||{},i=i||{},!i.popup&&(i.popup=$k(""),!i.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");let r=yield this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);i.popup.location.href=r.url;let n=yield Hk(Object.assign(Object.assign({},i),{timeoutInSeconds:i.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||Tp}));if(r.state!==n.state)throw new li("state_mismatch","Invalid state");let a=((s=e.authorizationParams)===null||s===void 0?void 0:s.organization)||this.options.authorizationParams.organization;yield this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:"authorization_code",code:n.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a})})}getUser(){return me(this,null,function*(){var e;let i=yield this._getIdTokenFromCache();return(e=i==null?void 0:i.decodedToken)===null||e===void 0?void 0:e.user})}getIdTokenClaims(){return me(this,null,function*(){var e;let i=yield this._getIdTokenFromCache();return(e=i==null?void 0:i.decodedToken)===null||e===void 0?void 0:e.claims})}loginWithRedirect(){return me(this,arguments,function*(e={}){var i;let s=E3(e),{openUrl:r,fragment:n,appState:a}=s,o=Ws(s,["openUrl","fragment","appState"]),c=((i=o.authorizationParams)===null||i===void 0?void 0:i.organization)||this.options.authorizationParams.organization,u=yield this._prepareAuthorizeUrl(o.authorizationParams||{}),{url:l}=u,p=Ws(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},p),{appState:a}),c&&{organization:c}));let f=n?`${l}#${n}`:l;r?yield r(f):window.location.assign(f)})}handleRedirectCallback(){return me(this,arguments,function*(e=window.location.href){let i=e.split("?").slice(1);if(i.length===0)throw new Error("There are no query params available for parsing.");let{state:s,code:r,error:n,error_description:a}=Uk(i.join("")),o=this.transactionManager.get();if(!o)throw new li("missing_transaction","Invalid state");if(this.transactionManager.remove(),n)throw new yp(n,a||n,s,o.appState);if(!o.code_verifier||o.state&&o.state!==s)throw new li("state_mismatch","Invalid state");let c=o.organization,u=o.nonce,l=o.redirect_uri;return yield this._requestToken(Object.assign({audience:o.audience,scope:o.scope,code_verifier:o.code_verifier,grant_type:"authorization_code",code:r},l?{redirect_uri:l}:{}),{nonceIn:u,organization:c}),{appState:o.appState}})}checkSession(e){return me(this,null,function*(){if(!this.cookieStorage.get(this.isAuthenticatedCookieName))if(this.cookieStorage.get(v3))this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(v3);else return;try{yield this.getTokenSilently(e)}catch(i){}})}getTokenSilently(){return me(this,arguments,function*(e={}){var i;let s=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Yc(this.scope,(i=e.authorizationParams)===null||i===void 0?void 0:i.scope)})}),r=yield xR(()=>this._getTokenSilently(s),`${this.options.clientId}::${s.authorizationParams.audience}::${s.authorizationParams.scope}`);return e.detailedResponse?r:r==null?void 0:r.access_token})}_getTokenSilently(e){return me(this,null,function*(){let{cacheMode:i}=e,s=Ws(e,["cacheMode"]);if(i!=="off"){let r=yield this._getEntryFromCache({scope:s.authorizationParams.scope,audience:s.authorizationParams.audience||"default",clientId:this.options.clientId});if(r)return r}if(i!=="cache-only")if(yield ER(()=>p0.acquireLock(l0,5e3),10))try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),i!=="off"){let u=yield this._getEntryFromCache({scope:s.authorizationParams.scope,audience:s.authorizationParams.audience||"default",clientId:this.options.clientId});if(u)return u}let r=this.options.useRefreshTokens?yield this._getTokenUsingRefreshToken(s):yield this._getTokenFromIFrame(s),{id_token:n,access_token:a,oauthTokenScope:o,expires_in:c}=r;return Object.assign(Object.assign({id_token:n,access_token:a},o?{scope:o}:null),{expires_in:c})}finally{yield p0.releaseLock(l0),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}else throw new Eo})}getTokenWithPopup(){return me(this,arguments,function*(e={},i={}){var s;let r=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Yc(this.scope,(s=e.authorizationParams)===null||s===void 0?void 0:s.scope)})});return i=Object.assign(Object.assign({},Rk),i),yield this.loginWithPopup(r,i),(yield this.cacheManager.get(new Ks({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token})}isAuthenticated(){return me(this,null,function*(){return!!(yield this.getUser())})}_buildLogoutUrl(e){e.clientId!==null?e.clientId=e.clientId||this.options.clientId:delete e.clientId;let i=e.logoutParams||{},{federated:s}=i,r=Ws(i,["federated"]),n=s?"&federated":"";return this._url(`/v2/logout?${f0(Object.assign({clientId:e.clientId},r))}`)+n}logout(){return me(this,arguments,function*(e={}){let i=E3(e),{openUrl:s}=i,r=Ws(i,["openUrl"]);e.clientId===null?yield this.cacheManager.clear():yield this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(Zc);let n=this._buildLogoutUrl(r);s?yield s(n):s!==!1&&window.location.assign(n)})}_getTokenFromIFrame(e){return me(this,null,function*(){let i=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),s=this.cookieStorage.get(this.orgHintCookieName);s&&!i.organization&&(i.organization=s);let{url:r,state:n,nonce:a,code_verifier:o,redirect_uri:c,scope:u,audience:l}=yield this._prepareAuthorizeUrl(i,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new li("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");let p=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,f=yield Vk(r,this.domainUrl,p);if(n!==f.state)throw new li("state_mismatch","Invalid state");let d=yield this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:o,code:f.code,grant_type:"authorization_code",redirect_uri:c,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:i.organization});return Object.assign(Object.assign({},d),{scope:u,oauthTokenScope:d.scope,audience:l})}catch(p){throw p.error==="login_required"&&this.logout({openUrl:!1}),p}})}_getTokenUsingRefreshToken(e){return me(this,null,function*(){let i=yield this.cacheManager.get(new Ks({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||"default",clientId:this.options.clientId}));if((!i||!i.refresh_token)&&!this.worker){if(this.options.useRefreshTokensFallback)return yield this._getTokenFromIFrame(e);throw new Qc(e.authorizationParams.audience||"default",e.authorizationParams.scope)}let s=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof e.timeoutInSeconds=="number"?e.timeoutInSeconds*1e3:null;try{let n=yield this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:i&&i.refresh_token,redirect_uri:s}),r&&{timeout:r}));return Object.assign(Object.assign({},n),{scope:e.authorizationParams.scope,oauthTokenScope:n.scope,audience:e.authorizationParams.audience||"default"})}catch(n){if((n.message.indexOf(Dk)>-1||n.message&&n.message.indexOf(Fk)>-1)&&this.options.useRefreshTokensFallback)return yield this._getTokenFromIFrame(e);throw n}})}_saveEntryInCache(e){return me(this,null,function*(){let{id_token:i,decodedToken:s}=e,r=Ws(e,["id_token","decodedToken"]);this.userCache.set(Zc,{id_token:i,decodedToken:s}),yield this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),yield this.cacheManager.set(r)})}_getIdTokenFromCache(){return me(this,null,function*(){let e=this.options.authorizationParams.audience||"default",i=yield this.cacheManager.getIdToken(new Ks({clientId:this.options.clientId,audience:e,scope:this.scope})),s=this.userCache.get(Zc);return i&&i.id_token===(s==null?void 0:s.id_token)?s:(this.userCache.set(Zc,i),i)})}_getEntryFromCache(r){return me(this,arguments,function*({scope:e,audience:i,clientId:s}){let n=yield this.cacheManager.get(new Ks({scope:e,audience:i,clientId:s}),60);if(n&&n.access_token){let{access_token:a,oauthTokenScope:o,expires_in:c}=n,u=yield this._getIdTokenFromCache();return u&&Object.assign(Object.assign({id_token:u.id_token,access_token:a},o?{scope:o}:null),{expires_in:c})}})}_requestToken(e,i){return me(this,null,function*(){let{nonceIn:s,organization:r}=i||{},n=yield aR(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},e),this.worker),a=yield this._verifyIdToken(n.id_token,s,r);return yield this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},n),{decodedToken:a,scope:e.scope,audience:e.audience||"default"}),n.scope?{oauthTokenScope:n.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(r||a.claims.org_id),Object.assign(Object.assign({},n),{decodedToken:a})})}exchangeToken(e){return me(this,null,function*(){return this._requestToken({grant_type:"urn:ietf:params:oauth:grant-type:token-exchange",subject_token:e.subject_token,subject_token_type:e.subject_token_type,scope:Yc(e.scope,this.scope),audience:this.options.authorizationParams.audience})})}},g0=class{};function wR(t){return me(this,null,function*(){let e=new Cp(t);return yield e.checkSession(),e})}At.Auth0Client=Cp;At.AuthenticationError=yp;At.CacheKey=Ks;At.GenericError=li;At.InMemoryCache=tu;At.LocalStorageCache=Sp;At.MfaRequiredError=xp;At.MissingRefreshTokenError=Qc;At.PopupCancelledError=vp;At.PopupTimeoutError=bp;At.TimeoutError=Eo;At.User=g0;At.createAuth0Client=wR});var Ap=j((Wne,O3)=>{var AR=require("path").relative;O3.exports=kR;var IR=process.cwd();function P3(t,e){for(var i=t.split(/[ ,]+/),s=String(e).toLowerCase(),r=0;r<i.length;r++){var n=i[r];if(n&&(n==="*"||n.toLowerCase()===s))return!0}return!1}function PR(t,e,i){var s=Object.getOwnPropertyDescriptor(t,e),r=s.value;return s.get=function(){return r},s.writable&&(s.set=function(a){return r=a}),delete s.value,delete s.writable,Object.defineProperty(t,e,s),s}function NR(t){for(var e="",i=0;i<t;i++)e+=", arg"+i;return e.substr(2)}function OR(t){var e=this.name+": "+this.namespace;this.message&&(e+=" deprecated "+this.message);for(var i=0;i<t.length;i++)e+=`
at `+t[i].toString();return e}function kR(t){if(!t)throw new TypeError("argument namespace is require