@versini/auth0-react-thin 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -179
- package/dist/auth0-context.d.ts +18 -1
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +7 -3
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +7 -3
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +30 -26
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -1
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +9 -11
- package/src/auth0-context.tsx +19 -0
- package/src/auth0-provider.tsx +9 -0
- package/src/index.tsx +1 -0
package/dist/auth0-react.js
CHANGED
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
function e(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);}return n}function t(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return "m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function n(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return "a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function o(e,t){this.v=e,this.k=t;}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function i(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function a(e){return new o(e,0)}function s(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function c(e,t){return e.get(i(e,t))}function u(e,t,n){s(e,t),t.set(e,n);}function l(e,t,n){return e.set(i(e,t),n),n}function h(e,t){s(e,t),t.add(e);}function d(e,t,n){return (t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o);}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){d(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e}function m(e,t){if(null==e)return {};var n,o,r=function(e,t){if(null==e)return {};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==t.indexOf(o))continue;n[o]=e[o];}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);}return r}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,s=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1;}else for(;!(c=(o=i.call(n)).done)&&(s.push(o.value),s.length!==t);c=!0);}catch(e){u=!0,r=e;}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw r}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return "Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(){return new g(e.apply(this,arguments))}}function g(e){var t,n;function r(t,n){try{var a=e[t](n),s=a.value,c=s instanceof o;Promise.resolve(c?s.v:s).then(function(n){if(c){var o="return"===t&&s.k?t:"next";if(!s.k||n.done)return r(o,n);n=e[o](n).value;}i(!!a.done,n);},function(e){r("throw",e);});}catch(e){i(2,e);}}function i(e,o){2===e?t.reject(o):t.resolve({value:o,done:e}),(t=t.next)?r(t.key,t.arg):n=null;}this._invoke=function(e,o){return new Promise(function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o));})},"function"!=typeof e.return&&(this.return=void 0);}"function"==typeof SuppressedError&&SuppressedError,g.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},g.prototype.next=function(e){return this._invoke("next",e)},g.prototype.throw=function(e){return this._invoke("throw",e)},g.prototype.return=function(e){return this._invoke("return",e)};const v={timeoutInSeconds:60},b=1e4,k="memory",_={name:"auth0-spa-js",version:"2.21.2"},S=()=>Date.now(),T="default";class E extends Error{constructor(e,t){super(t),this.error=e,this.error_description=t,Object.setPrototypeOf(this,E.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new E(t,n)}}class P extends E{constructor(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;super(e,t),this.state=n,this.appState=o,Object.setPrototypeOf(this,P.prototype);}}class A extends E{constructor(e,t,n,o){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(e,t),this.connection=n,this.state=o,this.appState=r,Object.setPrototypeOf(this,A.prototype);}}class R extends E{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,R.prototype);}}class I extends R{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,I.prototype);}}class x extends E{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,x.prototype);}}class C extends E{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,C.prototype);}}class O extends E{constructor(e,t,n,o){super(e,t),this.mfa_token=n,this.mfa_requirements=o,Object.setPrototypeOf(this,O.prototype);}}class j extends E{constructor(e,t){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(U(e,["default"]),"', scope: '").concat(U(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,j.prototype);}}class W extends E{constructor(e,t){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(U(e,["default"]),"', missing scope: '").concat(U(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,W.prototype);}}class K extends E{constructor(e){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=e,Object.setPrototypeOf(this,K.prototype);}}function U(e){return e&&!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).includes(e)?e:""}const L=()=>window.crypto,N=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";for(;t.length<43;){const n=L().getRandomValues(new Uint8Array(43-t.length));for(const o of n)t.length<43&&o<198&&(t+=e[o%66]);}return t},J=e=>btoa(e),D=[{key:"name",type:["string"]},{key:"version",type:["string","number"]},{key:"env",type:["object"]}],H=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object.keys(e).reduce((n,o)=>{if(t&&"env"===o)return n;const r=D.find(e=>e.key===o);return r&&r.type.includes(typeof e[o])&&(n[o]=e[o]),n},{})},M=t=>{var n=t.clientId,o=e(t,["clientId"]);return new URLSearchParams((e=>Object.keys(e).filter(t=>void 0!==e[t]).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{}))(Object.assign({client_id:n},o))).toString()},z=async e=>{const t=L().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e));return await t},Z=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),F=e=>{const t=new Uint8Array(e);return (e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))};var X="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},V={},G={};Object.defineProperty(G,"__esModule",{value:!0});var Y=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var o=e.locked.get(t);void 0===o?void 0===n?e.locked.set(t,[]):e.locked.set(t,[n]):void 0!==n&&(o.unshift(n),e.locked.set(t,o));},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,o){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n());})},this.unlock=function(t){var n=e.locked.get(t);if(void 0!==n&&0!==n.length){var o=n.pop();e.locked.set(t,n),void 0!==o&&setTimeout(o,0);}else e.locked.delete(t);};}return e.getInstance=function(){return void 0===e.instance&&(e.instance=new e),e.instance},e}();G.default=function(){return Y.getInstance()};var B=X&&X.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{c(o.next(e));}catch(e){i(e);}}function s(e){try{c(o.throw(e));}catch(e){i(e);}}function c(e){e.done?r(e.value):new n(function(t){t(e.value);}).then(a,s);}c((o=o.apply(e,t||[])).next());})},q=X&&X.__generator||function(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a);}catch(e){i=[6,e],o=0;}finally{n=r=0;}if(5&i[0])throw i[1];return {value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Q=X;Object.defineProperty(V,"__esModule",{value:!0});var $=G,ee="browser-tabs-lock-key",te={key:function(e){return B(Q,void 0,void 0,function(){return q(this,function(e){throw new Error("Unsupported")})})},getItem:function(e){return B(Q,void 0,void 0,function(){return q(this,function(e){throw new Error("Unsupported")})})},clear:function(){return B(Q,void 0,void 0,function(){return q(this,function(e){return [2,window.localStorage.clear()]})})},removeItem:function(e){return B(Q,void 0,void 0,function(){return q(this,function(e){throw new Error("Unsupported")})})},setItem:function(e,t){return B(Q,void 0,void 0,function(){return q(this,function(e){throw new Error("Unsupported")})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function ne(e){return new Promise(function(t){return setTimeout(t,e)})}function oe(e){for(var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",o=0;o<e;o++){n+=t[Math.floor(61*Math.random())];}return n}var re=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+oe(15),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=t,void 0===e.waiters&&(e.waiters=[]);}return e.prototype.acquireLock=function(t,n){return void 0===n&&(n=5e3),B(this,void 0,void 0,function(){var o,r,i,a,s,c,u;return q(this,function(l){switch(l.label){case 0:o=Date.now()+oe(4),r=Date.now()+n,i=ee+"-"+t,a=void 0===this.storageHandler?te:this.storageHandler,l.label=1;case 1:return Date.now()<r?[4,ne(30)]:[3,8];case 2:return l.sent(),null!==a.getItemSync(i)?[3,5]:(s=this.id+"-"+t+"-"+o,[4,ne(Math.floor(25*Math.random()))]);case 3:return l.sent(),a.setItemSync(i,JSON.stringify({id:this.id,iat:o,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,ne(30)];case 4:return l.sent(),null!==(c=a.getItemSync(i))&&(u=JSON.parse(c)).id===this.id&&u.iat===o?(this.acquiredIatSet.add(o),this.refreshLockWhileAcquired(i,o),[2,!0]):[3,7];case 5:return e.lockCorrector(void 0===this.storageHandler?te:this.storageHandler),[4,this.waitForSomethingToChange(r)];case 6:l.sent(),l.label=7;case 7:return o=Date.now()+oe(4),[3,1];case 8:return [2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return B(this,void 0,void 0,function(){var n=this;return q(this,function(o){return setTimeout(function(){return B(n,void 0,void 0,function(){var n,o,r;return q(this,function(i){switch(i.label){case 0:return [4,$.default().lock(t)];case 1:return i.sent(),this.acquiredIatSet.has(t)?(n=void 0===this.storageHandler?te:this.storageHandler,null===(o=n.getItemSync(e))?($.default().unlock(t),[2]):((r=JSON.parse(o)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(r)),$.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):($.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return B(this,void 0,void 0,function(){return q(this,function(n){switch(n.label){case 0:return [4,new Promise(function(n){var o=!1,r=Date.now(),i=!1;function a(){if(i||(window.removeEventListener("storage",a),e.removeFromWaiting(a),clearTimeout(s),i=!0),!o){o=!0;var t=50-(Date.now()-r);t>0?setTimeout(n,t):n(null);}}window.addEventListener("storage",a),e.addToWaiting(a);var s=setTimeout(a,Math.max(0,t-Date.now()));})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),void 0!==e.waiters&&e.waiters.push(t);},e.removeFromWaiting=function(t){void 0!==e.waiters&&(e.waiters=e.waiters.filter(function(e){return e!==t}));},e.notifyWaiters=function(){void 0!==e.waiters&&e.waiters.slice().forEach(function(e){return e()});},e.prototype.releaseLock=function(e){return B(this,void 0,void 0,function(){return q(this,function(t){switch(t.label){case 0:return [4,this.releaseLock__private__(e)];case 1:return [2,t.sent()]}})})},e.prototype.releaseLock__private__=function(t){return B(this,void 0,void 0,function(){var n,o,r,i;return q(this,function(a){switch(a.label){case 0:return n=void 0===this.storageHandler?te:this.storageHandler,o=ee+"-"+t,null===(r=n.getItemSync(o))?[2]:(i=JSON.parse(r)).id!==this.id?[3,2]:[4,$.default().lock(i.iat)];case 1:a.sent(),this.acquiredIatSet.delete(i.iat),n.removeItemSync(o),$.default().unlock(i.iat),e.notifyWaiters(),a.label=2;case 2:return [2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,o=t,r=[],i=0;;){var a=o.keySync(i);if(null===a)break;r.push(a),i++;}for(var s=!1,c=0;c<r.length;c++){var u=r[c];if(u.includes(ee)){var l=o.getItemSync(u);if(null!==l){var h=JSON.parse(l);(void 0===h.timeRefreshed&&h.timeAcquired<n||void 0!==h.timeRefreshed&&h.timeRefreshed<n)&&(o.removeItemSync(u),s=!0);}}}s&&e.notifyWaiters();},e.waiters=void 0,e}(),ie=V.default=re;class ae{async runWithLock(e,t,n){const o=new AbortController,r=setTimeout(()=>o.abort(),t);try{return await navigator.locks.request(e,{mode:"exclusive",signal:o.signal},async e=>{if(clearTimeout(r),!e)throw new Error("Lock not available");return await n()})}catch(e){if(clearTimeout(r),"AbortError"===(null==e?void 0:e.name))throw new R;throw e}}}class se{constructor(){this.activeLocks=new Set,this.lock=new ie,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear();};}async runWithLock(e,t,n){let o=!1;for(let n=0;n<10&&!o;n++)o=await this.lock.acquireLock(e,t);if(!o)throw new R;this.activeLocks.add(e),1===this.activeLocks.size&&"undefined"!=typeof window&&window.addEventListener("pagehide",this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),0===this.activeLocks.size&&"undefined"!=typeof window&&window.removeEventListener("pagehide",this.pagehideHandler);}}}function ce(){return "undefined"!=typeof navigator&&"function"==typeof(null===(e=navigator.locks)||void 0===e?void 0:e.request)?new ae:new se;var e;}let ue=null;const le=new TextEncoder,he=new TextDecoder;function de(e){return "string"==typeof e?le.encode(e):he.decode(e)}function pe(e){if("number"!=typeof e.modulusLength||e.modulusLength<2048)throw new ge(`${e.name} modulusLength must be at least 2048 bits`)}async function fe(e,t,n){if(!1===n.usages.includes("sign"))throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');const o=`${ye(de(JSON.stringify(e)))}.${ye(de(JSON.stringify(t)))}`;return `${o}.${ye(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return pe(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return pe(e.algorithm),{name:e.algorithm.name};case"Ed25519":return {name:e.algorithm.name}}throw new we}(n),n,de(o)))}`}let me;if(Uint8Array.prototype.toBase64)me=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;me=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function ye(e){return me(e)}class we extends Error{constructor(e){var t;super(null!=e?e:"operation not supported"),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}class ge extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}function ve(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){if("SHA-256"===e.algorithm.hash.name)return "PS256";throw new we("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"RSASSA-PKCS1-v1_5":return function(e){if("SHA-256"===e.algorithm.hash.name)return "RS256";throw new we("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"ECDSA":return function(e){if("P-256"===e.algorithm.namedCurve)return "ES256";throw new we("unsupported EcKeyAlgorithm namedCurve")}(e);case"Ed25519":return "Ed25519";default:throw new we("unsupported CryptoKey algorithm name")}}function be(e){return e instanceof CryptoKey}function ke(e){return be(e)&&"public"===e.type}async function _e(e,t,n,o,r,i){const a=null==e?void 0:e.privateKey,s=null==e?void 0:e.publicKey;if(!be(c=a)||"private"!==c.type)throw new TypeError('"keypair.privateKey" must be a private CryptoKey');var c;if(!ke(s))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(!0!==s.extractable)throw new TypeError('"keypair.publicKey.extractable" must be true');if("string"!=typeof t)throw new TypeError('"htu" must be a string');if("string"!=typeof n)throw new TypeError('"htm" must be a string');if(void 0!==o&&"string"!=typeof o)throw new TypeError('"nonce" must be a string or undefined');if(void 0!==r&&"string"!=typeof r)throw new TypeError('"accessToken" must be a string or undefined');if(void 0!==i&&("object"!=typeof i||null===i||Array.isArray(i)))throw new TypeError('"additional" must be an object');return fe({alg:ve(a),typ:"dpop+jwt",jwk:await Se(s)},Object.assign(Object.assign({},i),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:o,htu:t,ath:r?ye(await crypto.subtle.digest("SHA-256",de(r))):void 0}),a)}async function Se(e){const{kty:t,e:n,n:o,x:r,y:i,crv:a}=await crypto.subtle.exportKey("jwk",e);return {kty:t,crv:a,e:n,n:o,x:r,y:i}}const Te="dpop-nonce",Ee=["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:token-exchange","urn:okta:params:oauth:grant-type:webauthn","http://auth0.com/oauth/grant-type/mfa-oob","http://auth0.com/oauth/grant-type/mfa-otp","http://auth0.com/oauth/grant-type/mfa-recovery-code"];function Pe(){return async function(e,t){var n;let o;if("string"!=typeof e||0===e.length)throw new TypeError('"alg" must be a non-empty string');switch(e){case"PS256":o={name:"RSA-PSS",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":o={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"};break;case"Ed25519":o={name:"Ed25519"};break;default:throw new we}return crypto.subtle.generateKey(o,null!==(n=null==t?void 0:t.extractable)&&void 0!==n&&n,["sign","verify"])}("ES256",{extractable:!1})}function Ae(e){return async function(e){if(!ke(e))throw new TypeError('"publicKey" must be a public CryptoKey');if(!0!==e.extractable)throw new TypeError('"publicKey.extractable" must be true');const t=await Se(e);let n;switch(t.kty){case"EC":n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":n={crv:t.crv,kty:t.kty,x:t.x};break;case"RSA":n={e:t.e,kty:t.kty,n:t.n};break;default:throw new we("unsupported JWK kty")}return ye(await crypto.subtle.digest({name:"SHA-256"},de(JSON.stringify(n))))}(e.publicKey)}function Re(e){let t=e.keyPair,n=e.url,o=e.method,r=e.nonce,i=e.accessToken;const a=function(e){const t=new URL(e);return t.search="",t.hash="",t.href}(n);return _e(t,a,o,r,i)}const Ie=(e,t)=>new Promise(function(n,o){const r=new MessageChannel;r.port1.onmessage=function(e){e.data.error?o(new Error(e.data.error)):n(e.data),r.port1.close();},t.postMessage(e,[r.port2]);}),xe=(e,t,n)=>{const o=new AbortController;let r;return t.signal=o.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{r=setTimeout(()=>{o.abort(),t(new Error("Timeout when executing 'fetch'"));},n);})]).finally(()=>{clearTimeout(r);})},Ce=async function(e,t,n,o,r,i){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:b;return r?(async(e,t,n,o,r,i,a,s,c)=>Ie({type:"refresh",auth:{audience:t,scope:n},timeout:r,fetchUrl:e,fetchOptions:o,useFormData:a,useMrrt:s,skipTokenStorage:c},i))(e,t,n,o,a,r,i,arguments.length>7?arguments[7]:void 0,arguments.length>8?arguments[8]:void 0):(async(e,t,n)=>{const o=await xe(e,t,n);return {ok:o.ok,json:await o.json(),headers:(r=o.headers,[...r].reduce((e,t)=>{let n=y(t,2),o=n[0],r=n[1];return e[o]=r,e},{}))};var r;})(e,o,a)};async function Oe(t,n,o,r,i,a,s,c,u,l,h){if(u){const e=await u.generateProof({url:t,method:i.method||"GET",nonce:await u.getNonce()});i.headers=Object.assign(Object.assign({},i.headers),{dpop:e});}let d,p=null;for(let e=0;e<3;e++)try{d=await Ce(t,o,r,i,a,s,n,c,h),p=null;break}catch(e){p=e;}if(p)throw p;const f=d.json,m=f.error,y=f.error_description,w=e(f,["error","error_description"]),g=d,v=g.headers,b=g.ok;let k;if(u&&(k=v[Te],k&&await u.setNonce(k)),!b){const e=y||"HTTP error. Unable to fetch ".concat(t);if("mfa_required"===m)throw new O(m,e,w.mfa_token,w.mfa_requirements);if("missing_refresh_token"===m)throw new j(o,r);if("use_dpop_nonce"===m){if(!u||!k||l)throw new K(k);return Oe(t,n,o,r,i,a,s,c,u,!0,h)}throw new E(m||"request_error",e)}return w}async function je(t,n,o){var r=t.baseUrl,i=t.timeout,a=t.audience,s=t.scope,c=t.auth0Client,u=t.useFormData,l=t.useMrrt,h=t.dpop,d=e(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData","useMrrt","dpop"]);const p="urn:ietf:params:oauth:grant-type:token-exchange"===d.grant_type,f="urn:okta:params:oauth:grant-type:webauthn"===d.grant_type,m="refresh_token"===d.grant_type&&l,y=p||f||m,w=Object.assign(Object.assign(Object.assign({},d),y&&a&&{audience:a}),y&&s&&{scope:s}),g=f||!u,v=g?JSON.stringify(w):M(w),b=(k=d.grant_type,Ee.includes(k));var k;return await Oe("".concat(r,"/oauth/token"),i,a||T,s,{method:"POST",body:v,headers:{"Content-Type":g?"application/json":"application/x-www-form-urlencoded","Auth0-Client":btoa(JSON.stringify(H(c||_)))}},n,u,l,b?h:void 0,void 0,o)}const We=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return (o=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(o))).join(" ");var o;},Ke=(e,t,n)=>{let o;return n&&(o=e[n]),o||(o=e[T]),We(o,t)},Ue="@@auth0spajs@@",Le="@@user@@";class Ne{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ue,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,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){const t=y(e.split("::"),4),n=t[0],o=t[1],r=t[2],i=t[3];return new Ne({clientId:o,scope:i,audience:r},n)}static fromCacheEntry(e){const t=e.scope,n=e.audience,o=e.client_id;return new Ne({scope:t,audience:n,clientId:o})}}class Je{set(e,t){localStorage.setItem(e,JSON.stringify(t));}get(e){const t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(e){return}}remove(e){localStorage.removeItem(e);}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(Ue))}}class De{constructor(){this.enclosedCache=function(){let e={};return {set(t,n){e[t]=n;},get(t){const n=e[t];if(n)return n},remove(t){delete e[t];},allKeys:()=>Object.keys(e)}}();}}class He{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||S;}async setIdToken(e,t,n){var o;const r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await(null===(o=this.keyManifest)||void 0===o?void 0:o.add(r));}async getIdToken(e){const t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){const t=await this.get(e);if(!t)return;if(!t.id_token||!t.decodedToken)return;return {id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return {id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0;var r;let i=await this.cache.get(e.toKey()),a=e;if(!i){const t=await this.getCacheKeys();if(!t)return;const r=this.matchExistingCacheKey(e,t);if(r&&(i=await this.cache.get(r),a=Ne.fromKey(r)),!i&&n&&"cache-only"!==o)return this.getEntryWithRefreshToken(e,t)}if(!i)return;const s=await this.nowProvider(),c=Math.floor(s/1e3);return i.expiresAt-t<c?i.body.refresh_token?this.modifiedCachedEntry(i,a):(await this.cache.remove(a.toKey()),void await(null===(r=this.keyManifest)||void 0===r?void 0:r.remove(a.toKey()))):i.body}async modifiedCachedEntry(e,t){const n={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},o={body:n,expiresAt:e.expiresAt};return await this.cache.set(t.toKey(),o),{refresh_token:n.refresh_token,audience:n.audience,scope:n.scope}}async set(e){var t;const n=new Ne({clientId:e.client_id,scope:e.scope,audience:e.audience}),o=await this.wrapCacheEntry(e);await this.cache.set(n.toKey(),o),await(null===(t=this.keyManifest)||void 0===t?void 0:t.add(n.toKey()));}async remove(e,t,n){const o=new Ne({clientId:e,scope:n,audience:t});await this.cache.remove(o.toKey());}async stripRefreshToken(e){var t;const n=await this.getCacheKeys();if(n)for(const o of n){const n=await this.cache.get(o);(null===(t=null==n?void 0:n.body)||void 0===t?void 0:t.refresh_token)===e&&(delete n.body.refresh_token,await this.cache.set(o,n));}}async clear(e){var t;const n=await this.getCacheKeys();n&&(await n.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t);},Promise.resolve()),await(null===(t=this.keyManifest)||void 0===t?void 0:t.clear()));}async wrapCacheEntry(e){const t=await this.nowProvider();return {body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?null===(e=await this.keyManifest.get())||void 0===e?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new Ne({clientId:e},Ue,Le).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{var n;const o=Ne.fromKey(t),r=new Set(o.scope&&o.scope.split(" ")),i=(null===(n=e.scope)||void 0===n?void 0:n.split(" "))||[],a=o.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return o.prefix===Ue&&o.clientId===e.clientId&&o.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){var n;for(const o of t){const t=Ne.fromKey(o);if(t.prefix===Ue&&t.clientId===e.clientId){const e=await this.cache.get(o);if(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)return {refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}}}async getRefreshTokensByAudience(e,t){var n;const o=await this.getCacheKeys();if(!o)return [];const r=new Set;for(const i of o){const o=Ne.fromKey(i);if(o.prefix===Ue&&o.clientId===t&&o.audience===e){const e=await this.cache.get(i);(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)&&r.add(e.body.refresh_token);}}return Array.from(r)}async updateEntry(e,t){var n;const o=await this.getCacheKeys();if(o)for(const r of o){const o=await this.cache.get(r);(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.refresh_token)===e&&(o.body.refresh_token=t,await this.cache.set(r,o));}}}class Me{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey="".concat("a0.spajs.txs",".").concat(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});}}const ze=e=>"number"==typeof e,Ze=["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"],Fe=e=>{if(!e.id_token)throw new Error("ID token is required but missing");const t=(e=>{const t=e.split("."),n=y(t,3),o=n[0],r=n[1],i=n[2];if(3!==t.length||!o||!r||!i)throw new Error("ID token could not be decoded");const a=JSON.parse(Z(r)),s={__raw:e},c={};return Object.keys(a).forEach(e=>{s[e]=a[e],Ze.includes(e)||(c[e]=a[e]);}),{encoded:{header:o,payload:r,signature:i},header:JSON.parse(Z(o)),claims:s,user:c}})(e.id_token);if(!t.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(t.claims.iss!==e.iss)throw new Error('Issuer (iss) claim mismatch in the ID token; expected "'.concat(e.iss,'", found "').concat(t.claims.iss,'"'));if(!t.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if("RS256"!==t.header.alg)throw new Error('Signature algorithm of "'.concat(t.header.alg,'" is not supported. Expected the ID token to be signed with "RS256".'));if(!t.claims.aud||"string"!=typeof t.claims.aud&&!Array.isArray(t.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but was not one of "').concat(t.claims.aud.join(", "),'"'));if(t.claims.aud.length>1){if(!t.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(t.claims.azp!==e.aud)throw new Error('Authorized Party (azp) claim mismatch in the ID token; expected "'.concat(e.aud,'", found "').concat(t.claims.azp,'"'))}}else if(t.claims.aud!==e.aud)throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but found "').concat(t.claims.aud,'"'));if(e.nonce){if(!t.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(t.claims.nonce!==e.nonce)throw new Error('Nonce (nonce) claim mismatch in the ID token; expected "'.concat(e.nonce,'", found "').concat(t.claims.nonce,'"'))}if(e.max_age&&!ze(t.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(null==t.claims.exp||!ze(t.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!ze(t.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=e.leeway||60,o=new Date(e.now||Date.now()),r=new Date(0);if(r.setUTCSeconds(t.claims.exp+n),o>r)throw new Error("Expiration Time (exp) claim error in the ID token; current time (".concat(o,") is after expiration time (").concat(r,")"));if(null!=t.claims.nbf&&ze(t.claims.nbf)){const e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),o<e)throw new Error("Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (".concat(o,") is before ").concat(e))}if(null!=t.claims.auth_time&&ze(t.claims.auth_time)){const r=new Date(0);if(r.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),o>r)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 (".concat(o,") is after last auth at ").concat(r))}if(e.organization){const n=e.organization.trim();if(n.startsWith("org_")){const e=n;if(!t.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(e!==t.claims.org_id)throw new Error('Organization ID (org_id) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_id,'"'))}else {const e=n.toLowerCase();if(!t.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(e!==t.claims.org_name)throw new Error('Organization Name (org_name) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_name,'"'))}}return t};var Xe=X&&X.__assign||function(){return Xe=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Xe.apply(this,arguments)};function Ve(e,t){if(!t)return "";var n="; "+e;return !0===t?n:n+"="+t}function Ge(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if("number"==typeof e.expires){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t;}return Ve("Expires",e.expires?e.expires.toUTCString():"")+Ve("Domain",e.domain)+Ve("Path",e.path)+Ve("Secure",e.secure)+Ve("SameSite",e.sameSite)}(n)}function Ye(){return function(e){for(var t={},n=e?e.split("; "):[],o=/(%[\dA-F]{2})+/gi,r=0;r<n.length;r++){var i=n[r].split("="),a=i.slice(1).join("=");'"'===a.charAt(0)&&(a=a.slice(1,-1));try{t[i[0].replace(o,decodeURIComponent)]=a.replace(o,decodeURIComponent);}catch(e){}}return t}(document.cookie)}var Be=function(e){return Ye()[e]};function qe(e,t,n){document.cookie=Ge(e,t,Xe({path:"/"},n));}var Qe=qe;var $e=function(e,t){qe(e,"",Xe(Xe({},t),{expires:-1}));};const et={get(e){const t=Be(e);if(void 0!==t)return JSON.parse(t)},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0,sameSite:"none"}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),Qe(e,JSON.stringify(t),o);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),$e(e,n);}},tt="_legacy_",nt={get(e){const t=et.get(e);return t||et.get("".concat(tt).concat(e))},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),Qe("".concat(tt).concat(e),JSON.stringify(t),o),et.save(e,t,n);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),$e(e,n),et.remove(e,t),et.remove("".concat(tt).concat(e),t);}},ot={get(e){if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(e);return null!=t?JSON.parse(t):void 0},save(e,t){sessionStorage.setItem(e,JSON.stringify(t));},remove(e){sessionStorage.removeItem(e);}};exports.ResponseType = void 0;!function(e){e.Code="code",e.ConnectCode="connect_code";}(exports.ResponseType||(exports.ResponseType={}));class it{}function at(e,t,n){var o=void 0===t?null:t,r=function(e,t){var n=atob(e);if(t){for(var o=new Uint8Array(n.length),r=0,i=n.length;r<i;++r)o[r]=n.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(o.buffer))}return n}(e,void 0!==n&&n),i=r.indexOf("\n",10)+1,a=r.substring(i)+(o?"//# sourceMappingURL="+o:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var st,ct,ut,lt,ht=(st="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHQpeyhudWxsPT10fHx0PmUubGVuZ3RoKSYmKHQ9ZS5sZW5ndGgpO2Zvcih2YXIgcj0wLG89QXJyYXkodCk7cjx0O3IrKylvW3JdPWVbcl07cmV0dXJuIG99ZnVuY3Rpb24gdCh0LHIpe3JldHVybiBmdW5jdGlvbihlKXtpZihBcnJheS5pc0FycmF5KGUpKXJldHVybiBlfSh0KXx8ZnVuY3Rpb24oZSx0KXt2YXIgcj1udWxsPT1lP251bGw6InVuZGVmaW5lZCIhPXR5cGVvZiBTeW1ib2wmJmVbU3ltYm9sLml0ZXJhdG9yXXx8ZVsiQEBpdGVyYXRvciJdO2lmKG51bGwhPXIpe3ZhciBvLG4scyxpLGE9W10sYz0hMCxsPSExO3RyeXtpZihzPShyPXIuY2FsbChlKSkubmV4dCwwPT09dCl7aWYoT2JqZWN0KHIpIT09cilyZXR1cm47Yz0hMX1lbHNlIGZvcig7IShjPShvPXMuY2FsbChyKSkuZG9uZSkmJihhLnB1c2goby52YWx1ZSksYS5sZW5ndGghPT10KTtjPSEwKTt9Y2F0Y2goZSl7bD0hMCxuPWV9ZmluYWxseXt0cnl7aWYoIWMmJm51bGwhPXIucmV0dXJuJiYoaT1yLnJldHVybigpLE9iamVjdChpKSE9PWkpKXJldHVybn1maW5hbGx5e2lmKGwpdGhyb3cgbn19cmV0dXJuIGF9fSh0LHIpfHxmdW5jdGlvbih0LHIpe2lmKHQpe2lmKCJzdHJpbmciPT10eXBlb2YgdClyZXR1cm4gZSh0LHIpO3ZhciBvPXt9LnRvU3RyaW5nLmNhbGwodCkuc2xpY2UoOCwtMSk7cmV0dXJuIk9iamVjdCI9PT1vJiZ0LmNvbnN0cnVjdG9yJiYobz10LmNvbnN0cnVjdG9yLm5hbWUpLCJNYXAiPT09b3x8IlNldCI9PT1vP0FycmF5LmZyb20odCk6IkFyZ3VtZW50cyI9PT1vfHwvXig/OlVpfEkpbnQoPzo4fDE2fDMyKSg/OkNsYW1wZWQpP0FycmF5JC8udGVzdChvKT9lKHQscik6dm9pZCAwfX0odCxyKXx8ZnVuY3Rpb24oKXt0aHJvdyBuZXcgVHlwZUVycm9yKCJJbnZhbGlkIGF0dGVtcHQgdG8gZGVzdHJ1Y3R1cmUgbm9uLWl0ZXJhYmxlIGluc3RhbmNlLlxuSW4gb3JkZXIgdG8gYmUgaXRlcmFibGUsIG5vbi1hcnJheSBvYmplY3RzIG11c3QgaGF2ZSBhIFtTeW1ib2wuaXRlcmF0b3JdKCkgbWV0aG9kLiIpfSgpfWNsYXNzIHIgZXh0ZW5kcyBFcnJvcntjb25zdHJ1Y3RvcihlLHQpe3N1cGVyKHQpLHRoaXMuZXJyb3I9ZSx0aGlzLmVycm9yX2Rlc2NyaXB0aW9uPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsci5wcm90b3R5cGUpfXN0YXRpYyBmcm9tUGF5bG9hZChlKXtsZXQgdD1lLmVycm9yLG89ZS5lcnJvcl9kZXNjcmlwdGlvbjtyZXR1cm4gbmV3IHIodCxvKX19Y2xhc3MgbyBleHRlbmRzIHJ7Y29uc3RydWN0b3IoZSx0KXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIiwiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KG4oZSxbImRlZmF1bHQiXSksIicsIHNjb3BlOiAnIikuY29uY2F0KG4odCksIicpIikpLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsby5wcm90b3R5cGUpfX1mdW5jdGlvbiBuKGUpe3JldHVybiBlJiYhKGFyZ3VtZW50cy5sZW5ndGg+MSYmdm9pZCAwIT09YXJndW1lbnRzWzFdP2FyZ3VtZW50c1sxXTpbXSkuaW5jbHVkZXMoZSk/ZToiIn0iZnVuY3Rpb24iPT10eXBlb2YgU3VwcHJlc3NlZEVycm9yJiZTdXBwcmVzc2VkRXJyb3I7Y29uc3Qgcz1lPT57dmFyIHQ9ZS5jbGllbnRJZCxyPWZ1bmN0aW9uKGUsdCl7dmFyIHI9e307Zm9yKHZhciBvIGluIGUpT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbykmJnQuaW5kZXhPZihvKTwwJiYocltvXT1lW29dKTtpZihudWxsIT1lJiYiZnVuY3Rpb24iPT10eXBlb2YgT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyl7dmFyIG49MDtmb3Iobz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO248by5sZW5ndGg7bisrKXQuaW5kZXhPZihvW25dKTwwJiZPYmplY3QucHJvdG90eXBlLnByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoZSxvW25dKSYmKHJbb1tuXV09ZVtvW25dXSl9cmV0dXJuIHJ9KGUsWyJjbGllbnRJZCJdKTtyZXR1cm4gbmV3IFVSTFNlYXJjaFBhcmFtcygoZT0+T2JqZWN0LmtleXMoZSkuZmlsdGVyKHQ9PnZvaWQgMCE9PWVbdF0pLnJlZHVjZSgodCxyKT0+T2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHQpLHtbcl06ZVtyXX0pLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IGk9e30sYT1udWxsO2NvbnN0IGM9KGUsdCk9PiIiLmNvbmNhdChlLCJ8IikuY29uY2F0KHQpLGw9KGUsdCk9PnQuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSx1PWU9PntPYmplY3QuZW50cmllcyhpKS5mb3JFYWNoKHI9PntsZXQgbz10KHIsMiksbj1vWzBdO29bMV09PT1lJiZkZWxldGUgaVtuXX0pfSxmPWU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKChlLHQpPT57clt0XT1lfSkscn0sZD1hc3luYyBlPT57bGV0IHIsbixhPWUuZGF0YSx1PWEudGltZW91dCxkPWEuYXV0aCxoPWEuZmV0Y2hVcmwscD1hLmZldGNoT3B0aW9ucyx5PWEudXNlRm9ybURhdGEsZz1hLnVzZU1ycnQsYj1hLnNraXBUb2tlblN0b3JhZ2UsTz10KGUucG9ydHMsMSlbMF0saz17fTtjb25zdCBtPWR8fHt9LGo9bS5hdWRpZW5jZSx2PW0uc2NvcGU7dHJ5e2NvbnN0IGU9eT9mKHAuYm9keSk6SlNPTi5wYXJzZShwLmJvZHkpO2lmKCFlLnJlZnJlc2hfdG9rZW4mJiJyZWZyZXNoX3Rva2VuIj09PWUuZ3JhbnRfdHlwZSl7aWYobj0oKGUsdCk9PmlbYyhlLHQpXSkoaix2KSwhbiYmZyl7Y29uc3QgZT1pLmxhdGVzdF9yZWZyZXNoX3Rva2VuLHQ9KChlLHQpPT4hIU9iamVjdC5rZXlzKGkpLmZpbmQocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBvPWwodCxyKSxuPXIuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpLHM9ZS5zcGxpdCgiICIpLmV2ZXJ5KGU9Pm4uaW5jbHVkZXMoZSkpO3JldHVybiBvJiZzfX0pKSh2LGopO2UmJiF0JiYobj1lKX1pZighbil0aHJvdyBuZXcgbyhqLHYpO3AuYm9keT15P3MoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LGUpLHtyZWZyZXNoX3Rva2VuOm59KSk6SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LGUpLHtyZWZyZXNoX3Rva2VuOm59KSl9bGV0IGEsZDsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYoYT1uZXcgQWJvcnRDb250cm9sbGVyLHAuc2lnbmFsPWEuc2lnbmFsKTt0cnl7ZD1hd2FpdCBQcm9taXNlLnJhY2UoWyhNPXUsbmV3IFByb21pc2UoZT0+c2V0VGltZW91dChlLE0pKSksZmV0Y2goaCxPYmplY3QuYXNzaWduKHt9LHApKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIE8ucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCFkKXJldHVybiBhJiZhLmFib3J0KCksdm9pZCBPLnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO2lmKFM9ZC5oZWFkZXJzLGs9Wy4uLlNdLnJlZHVjZSgoZSxyKT0+e2xldCBvPXQociwyKSxuPW9bMF0scz1vWzFdO3JldHVybiBlW25dPXMsZX0se30pLHI9YXdhaXQgZC5qc29uKCksYilyZXR1cm4gZGVsZXRlIHIucmVmcmVzaF90b2tlbix2b2lkIE8ucG9zdE1lc3NhZ2Uoe29rOmQub2ssanNvbjpyLGhlYWRlcnM6a30pO3IucmVmcmVzaF90b2tlbj8oZyYmKGkubGF0ZXN0X3JlZnJlc2hfdG9rZW49ci5yZWZyZXNoX3Rva2VuLF89bix3PXIucmVmcmVzaF90b2tlbixPYmplY3QuZW50cmllcyhpKS5mb3JFYWNoKGU9PntsZXQgcj10KGUsMiksbz1yWzBdO3JbMV09PT1fJiYoaVtvXT13KX0pKSwoKGUsdCxyKT0+e2lbYyh0LHIpXT1lfSkoci5yZWZyZXNoX3Rva2VuLGosdiksZGVsZXRlIHIucmVmcmVzaF90b2tlbik6KChlLHQpPT57ZGVsZXRlIGlbYyhlLHQpXX0pKGosdiksTy5wb3N0TWVzc2FnZSh7b2s6ZC5vayxqc29uOnIsaGVhZGVyczprfSl9Y2F0Y2goZSl7Ty5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9LGhlYWRlcnM6a30pfXZhciBfLHcsUyxNfSxoPWFzeW5jIGU9PntsZXQgcj1lLmRhdGEsbz1yLnRpbWVvdXQsbj1yLmF1dGgsYT1yLmZldGNoVXJsLGM9ci5mZXRjaE9wdGlvbnMsZD1yLnVzZUZvcm1EYXRhLGg9dChlLnBvcnRzLDEpWzBdO2NvbnN0IHA9KG58fHt9KS5hdWRpZW5jZTt0cnl7Y29uc3QgZT0oZT0+e2NvbnN0IHI9bmV3IFNldDtyZXR1cm4gT2JqZWN0LmVudHJpZXMoaSkuZm9yRWFjaChvPT57bGV0IG49dChvLDIpLHM9blswXSxpPW5bMV07bChlLHMpJiZyLmFkZChpKX0pLEFycmF5LmZyb20ocil9KShwKTtpZigwPT09ZS5sZW5ndGgpcmV0dXJuIHZvaWQgaC5wb3N0TWVzc2FnZSh7b2s6ITB9KTtjb25zdCByPWQ/ZihjLmJvZHkpOkpTT04ucGFyc2UoYy5ib2R5KTtmb3IoY29uc3QgdCBvZiBlKXtjb25zdCBlPWQ/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3Rva2VuOnR9KSk6SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjp0fSkpO2xldCBuLGksbCxmOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihuPW5ldyBBYm9ydENvbnRyb2xsZXIsaT1uLnNpZ25hbCk7dHJ5e2Y9YXdhaXQgUHJvbWlzZS5yYWNlKFtuZXcgUHJvbWlzZShlPT57bD1zZXRUaW1lb3V0KGUsbyl9KSxmZXRjaChhLE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxjKSx7Ym9keTplLHNpZ25hbDppfSkpXSkuZmluYWxseSgoKT0+Y2xlYXJUaW1lb3V0KGwpKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBoLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZilyZXR1cm4gbiYmbi5hYm9ydCgpLHZvaWQgaC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZighZi5vayl7bGV0IGU7dHJ5e2NvbnN0IHQ9SlNPTi5wYXJzZShhd2FpdCBmLnRleHQoKSk7ZT10LmVycm9yX2Rlc2NyaXB0aW9ufWNhdGNoKGUpe31yZXR1cm4gdm9pZCBoLnBvc3RNZXNzYWdlKHtlcnJvcjplfHwiSFRUUCBlcnJvciAiLmNvbmNhdChmLnN0YXR1cyl9KX11KHQpfWgucG9zdE1lc3NhZ2Uoe29rOiEwfSl9Y2F0Y2goZSl7aC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfHwiVW5rbm93biBlcnJvciBkdXJpbmcgdG9rZW4gcmV2b2NhdGlvbiJ9KX19LHA9KGUsdCk9PntpZighYSlyZXR1cm4hMTt0cnl7Y29uc3Qgcj1uZXcgVVJMKGEpLm9yaWdpbixvPW5ldyBVUkwoZS5mZXRjaFVybCk7cmV0dXJuIG8ub3JpZ2luPT09ciYmby5wYXRobmFtZT09PXR9Y2F0Y2goZSl7cmV0dXJuITF9fTthZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixlPT57Y29uc3Qgcj1lLmRhdGEsbz10KGUucG9ydHMsMSlbMF07aWYoISgidHlwZSJpbiByKXx8ImluaXQiIT09ci50eXBlKXJldHVybiJ0eXBlImluIHImJiJjbGVhciI9PT1yLnR5cGU/KGk9e30sdm9pZChudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMH0pKSk6InR5cGUiaW4gciYmInJldm9rZSI9PT1yLnR5cGU/cChyLCIvb2F1dGgvcmV2b2tlIik/dm9pZCBoKGUpOnZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ImludmFsaWRfZmV0Y2hfdXJsIixlcnJvcl9kZXNjcmlwdGlvbjoiVW5hdXRob3JpemVkIGZldGNoIFVSTCJ9LGhlYWRlcnM6e319KSk6dm9pZCgiZmV0Y2hVcmwiaW4gciYmcChyLCIvb2F1dGgvdG9rZW4iKT9kKGUpOm51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpO2lmKG51bGw9PT1hKXRyeXtuZXcgVVJMKHIuYWxsb3dlZEJhc2VVcmwpLGE9ci5hbGxvd2VkQmFzZVVybH1jYXRjaChlKXtyZXR1cm59fSl9KCk7Cgo=",ct=null,ut=!1,function(e){return lt=lt||at(st,ct,ut),new Worker(lt,e)});const dt={};class pt{constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId);}async add(e){var t;const n=new Set((null===(t=await this.cache.get(this.manifestKey))||void 0===t?void 0:t.keys)||[]);n.add(e),await this.cache.set(this.manifestKey,{keys:[...n]});}async remove(e){const t=await this.cache.get(this.manifestKey);if(t){const n=new Set(t.keys);return n.delete(e),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return "".concat(Ue,"::").concat(e)}}const ft="auth0.is.authenticated",mt={memory:()=>(new De).enclosedCache,localstorage:()=>new Je},yt=e=>mt[e],wt=t=>{const n=t.openUrl,o=t.onRedirect,r=e(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:!1===n||n?n:o})},gt=(e,t)=>{const n=(null==t?void 0:t.split(" "))||[];return ((null==e?void 0:e.split(" "))||[]).every(e=>n.includes(e))},vt={NONCE:"nonce",KEYPAIR:"keypair"};class bt{constructor(e){this.clientId=e;}getVersion(){return 1}createDbHandle(){const e=window.indexedDB.open("auth0-spa-js",this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(vt).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result);})}async getDbHandle(){return this.dbHandle||(this.dbHandle=await this.createDbHandle()),this.dbHandle}async executeDbRequest(e,t,n){const o=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{o.onsuccess=()=>e(o.result),o.onerror=()=>t(o.error);})}buildKey(e){const t=e?"_".concat(e):"auth0";return "".concat(this.clientId,"::").concat(t)}setNonce(e,t){return this.save(vt.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(vt.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,"readwrite",e=>e.put(n,t));}findNonce(e){return this.find(vt.NONCE,this.buildKey(e))}findKeyPair(){return this.find(vt.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,"readonly",e=>e.get(t))}async deleteBy(e,t){const n=await this.executeDbRequest(e,"readonly",e=>e.getAllKeys());await Promise.all((null==n?void 0:n.filter(t).map(t=>this.executeDbRequest(e,"readwrite",e=>e.delete(t))))||[]);}deleteByClientId(e,t){return this.deleteBy(e,e=>"string"==typeof e&&e.startsWith("".concat(t,"::")))}clearNonces(){return this.deleteByClientId(vt.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(vt.KEYPAIR,this.clientId)}}class kt{constructor(e){this.storage=new bt(e);}getNonce(e){return this.storage.findNonce(e)}setNonce(e,t){return this.storage.setNonce(e,t)}async getOrGenerateKeyPair(){let e=await this.storage.findKeyPair();return e||(e=await Pe(),await this.storage.setKeyPair(e)),e}async generateProof(e){const t=await this.getOrGenerateKeyPair();return Re(Object.assign({keyPair:t},e))}async calculateThumbprint(){return Ae(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()]);}}var _t;!function(e){e.Bearer="Bearer",e.DPoP="DPoP";}(_t||(_t={}));class St{constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||("undefined"==typeof window?fetch:window.fetch.bind(window))});}isAbsoluteUrl(e){return /^(https?:)?\/\//i.test(e)}buildUrl(e,t){if(t){if(this.isAbsoluteUrl(t))return t;if(e)return "".concat(e.replace(/\/?\/$/,""),"/").concat(t.replace(/^\/+/,""))}throw new TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(e){return this.config.getAccessToken?this.config.getAccessToken(e):this.hooks.getAccessToken(e)}extractUrl(e){return "string"==typeof e?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);const n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),o=e instanceof Request?new Request(n,e):n;return new Request(o,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_t.Bearer;e.headers.set("authorization","".concat(n," ").concat(t));}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;const n=await this.hooks.getDpopNonce(),o=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set("dpop",o);}async prepareRequest(e,t){const n=await this.getAccessToken(t);let o,r;"string"==typeof n?(o=this.config.dpopNonceId?_t.DPoP:_t.Bearer,r=n):(o=n.token_type,r=n.access_token),this.setAuthorizationHeader(e,r,o),o===_t.DPoP&&await this.setDpopProofHeader(e,r);}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||"":"function"==typeof e.get?e.get(t)||"":e[t]||""}hasUseDpopNonceError(e){if(401!==e.status)return !1;const t=this.getHeader(e.headers,"www-authenticate");return t.includes("invalid_dpop_nonce")||t.includes("use_dpop_nonce")}async handleResponse(e,t){const n=this.getHeader(e.headers,Te);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new K(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,o){const r=this.buildBaseRequest(e,t);await this.prepareRequest(r,o);const i=await this.config.fetch(r);return this.handleResponse(i,n)}fetchWithAuth(e,t,n){const o={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,Object.assign(Object.assign({},o),{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,o,n)}}class Tt{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t;}async connectAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async completeAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/complete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async getFactors(){const e=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/factors"),{method:"GET"},{scope:["read:me:factors"]});return (await this._handleResponse(e)).factors}async getAuthenticationMethods(e){const t=e?"?".concat(new URLSearchParams({type:e})):"",n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods").concat(t),{method:"GET"},{scope:["read:me:authentication_methods"]});return (await this._handleResponse(n)).authentication_methods}async getAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"GET"},{scope:["read:me:authentication_methods"]});return this._handleResponse(t)}async deleteAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"DELETE"},{scope:["delete:me:authentication_methods"]});t.ok||await this._handleResponse(t);}async updateAuthenticationMethod(e,t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["update:me:authentication_methods"]});return this._handleResponse(n)}async enrollmentChallenge(e){var t;const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:authentication_methods"]}),o=await this._handleResponse(n),r=null!==(t=n.headers.get("location"))&&void 0!==t?t:"",i=decodeURIComponent(r.split("/").pop()||"");return Object.assign(Object.assign({},o),{id:i,location:r})}async enrollmentVerify(t){const n=t,o=n.location;n.type;const r=e(n,["location","type"]),i=await this.myAccountFetcher.fetchWithAuth("".concat(o,"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},{scope:["create:me:authentication_methods"]});return this._handleResponse(i)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t);}catch(n){throw new Et({type:"invalid_json",status:e.status,title:"Invalid JSON response",detail:t||String(n)})}if(e.ok)return t;throw new Et(t)}}class Et extends Error{constructor(e){let t=e.type,n=e.status,o=e.title,r=e.detail,i=e.validation_errors;super(r),this.name="MyAccountApiError",this.type=t,this.status=n,this.title=o,this.detail=r,this.validation_errors=i,Object.setPrototypeOf(this,Et.prototype);}}const Pt={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}},At="http://auth0.com/oauth/grant-type/mfa-otp",Rt="http://auth0.com/oauth/grant-type/mfa-oob",It="http://auth0.com/oauth/grant-type/mfa-recovery-code";var xt,Ct;let Ot;if("undefined"==typeof navigator||null===(xt=navigator.userAgent)||void 0===xt||null===(Ct=xt.startsWith)||void 0===Ct||!Ct.call(xt,"Mozilla/5.0 ")){const e="v3.8.6";Ot="".concat("oauth4webapi","/").concat(e);}function jt(e,t){if(null==e)return !1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch(e){return !1}}const Wt="ERR_INVALID_ARG_VALUE",Kt="ERR_INVALID_ARG_TYPE";function Ut(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}const Lt=Symbol(),Nt=Symbol(),Jt=Symbol(),Dt=Symbol(),Ht=Symbol(),Mt=Symbol(),zt=new TextEncoder,Zt=new TextDecoder;function Ft(e){return "string"==typeof e?zt.encode(e):Zt.decode(e)}let Xt,Vt;if(Uint8Array.prototype.toBase64)Xt=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;Xt=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function Gt(e){return "string"==typeof e?Vt(e):Xt(e)}Vt=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(e){throw Ut("The input to be decoded is not correctly encoded.",Wt,e)}}:e=>{try{const t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch(e){throw Ut("The input to be decoded is not correctly encoded.",Wt,e)}};class Yt extends Error{constructor(e,t){var n;super(e,t),d(this,"code",void 0),this.name=this.constructor.name,this.code=qn,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class Bt extends Error{constructor(e,t){var n;super(e,t),d(this,"code",void 0),this.name=this.constructor.name,null!=t&&t.code&&(this.code=null==t?void 0:t.code),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function qt(e,t,n){return new Bt(e,{code:t,cause:n})}function Qt(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw Ut("".concat(t," must be a CryptoKey"),Kt)}(e,t),"private"!==e.type)throw Ut("".concat(t," must be a private CryptoKey"),Wt)}function $t(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function en(e){jt(e,Headers)&&(e=Object.fromEntries(e.entries()));const t=new Headers(null!=e?e:{});if(Ot&&!t.has("user-agent")&&t.set("user-agent",Ot),t.has("authorization"))throw Ut('"options.headers" must not include the "authorization" header name',Wt);return t}function tn(e,t){if(void 0!==t){if("function"==typeof t&&(t=t(e.href)),!(t instanceof AbortSignal))throw Ut('"options.signal" must return or be an instance of AbortSignal',Kt);return t}}function nn(e){return e.includes("//")?e.replace("//","/"):e}async function on(e,t){return async function(e,t,n,o){if(!(e instanceof URL))throw Ut('"'.concat(t,'" must be an instance of URL'),Kt);gn(e,!0!==(null==o?void 0:o[Lt]));const r=n(new URL(e.href)),i=en(null==o?void 0:o.headers);return i.set("accept","application/json"),((null==o?void 0:o[Dt])||fetch)(r.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:tn(r,null==o?void 0:o.signal)})}(e,"issuerIdentifier",e=>{switch(null==t?void 0:t.algorithm){case void 0:case"oidc":!function(e,t){e.pathname=nn("".concat(e.pathname,"/").concat(t));}(e,".well-known/openid-configuration");break;case"oauth2":!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"/"===e.pathname?e.pathname=t:e.pathname=nn("".concat(t,"/").concat(n?e.pathname:e.pathname.replace(/(\/)$/,"")));}(e,".well-known/oauth-authorization-server");break;default:throw Ut('"options.algorithm" must be "oidc" (default), or "oauth2"',Wt)}return e},t)}function rn(e,t,n,o,r){try{if("number"!=typeof e||!Number.isFinite(e))throw Ut("".concat(n," must be a number"),Kt,r);if(e>0)return;if(t){if(0!==e)throw Ut("".concat(n," must be a non-negative number"),Wt,r);return}throw Ut("".concat(n," must be a positive number"),Wt,r)}catch(e){if(o)throw qt(e.message,o,r);throw e}}function an(e,t,n,o){try{if("string"!=typeof e)throw Ut("".concat(t," must be a string"),Kt,o);if(0===e.length)throw Ut("".concat(t," must not be empty"),Wt,o)}catch(e){if(n)throw qt(e.message,n,o);throw e}}function sn(e){!function(e,t){if(jn(e)!==t)throw function(e){let t='"response" content-type must be ';for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];if(o.length>2){const e=o.pop();t+="".concat(o.join(", "),", or ").concat(e);}else 2===o.length?t+="".concat(o[0]," or ").concat(o[1]):t+=o[0];return qt(t,to,e)}(e,t)}(e,"application/json");}function cn(){return Gt(crypto.getRandomValues(new Uint8Array(32)))}function un(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){switch(e.algorithm.hash.name){case"SHA-256":return "PS256";case"SHA-384":return "PS384";case"SHA-512":return "PS512";default:throw new Yt("unsupported RsaHashedKeyAlgorithm hash name",{cause:e})}}(e);case"RSASSA-PKCS1-v1_5":return function(e){switch(e.algorithm.hash.name){case"SHA-256":return "RS256";case"SHA-384":return "RS384";case"SHA-512":return "RS512";default:throw new Yt("unsupported RsaHashedKeyAlgorithm hash name",{cause:e})}}(e);case"ECDSA":return function(e){switch(e.algorithm.namedCurve){case"P-256":return "ES256";case"P-384":return "ES384";case"P-521":return "ES512";default:throw new Yt("unsupported EcKeyAlgorithm namedCurve",{cause:e})}}(e);case"Ed25519":case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return e.algorithm.name;case"EdDSA":return "Ed25519";default:throw new Yt("unsupported CryptoKey algorithm name",{cause:e})}}function ln(e){const t=null==e?void 0:e[Nt];return "number"==typeof t&&Number.isFinite(t)?t:0}function hn(e){const t=null==e?void 0:e[Jt];return "number"==typeof t&&Number.isFinite(t)&&-1!==Math.sign(t)?t:30}function dn(){return Math.floor(Date.now()/1e3)}function pn(e){if("object"!=typeof e||null===e)throw Ut('"as" must be an object',Kt);an(e.issuer,'"as.issuer"');}function fn(e){if("object"!=typeof e||null===e)throw Ut('"client" must be an object',Kt);an(e.client_id,'"client.client_id"');}function mn(e){return an(e,'"clientSecret"'),(t,n,o,r)=>{o.set("client_id",n.client_id),o.set("client_secret",e);}}function yn(e,t){const n=(i=e)instanceof CryptoKey?{key:i}:(null==i?void 0:i.key)instanceof CryptoKey?(void 0!==i.kid&&an(i.kid,'"kid"'),{key:i.key,kid:i.kid}):{},o=n.key,r=n.kid;var i;return Qt(o,'"clientPrivateKey.key"'),async(e,n,i,a)=>{var s;const c={alg:un(o),kid:r},u=function(e,t){const n=dn()+ln(t);return {jti:cn(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,n);null==t||null===(s=t[Ht])||void 0===s||s.call(t,c,u),i.set("client_id",n.client_id),i.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),i.set("client_assertion",await async function(e,t,n){if(!n.usages.includes("sign"))throw Ut('CryptoKey instances used for signing assertions must include "sign" in their "usages"',Wt);const o="".concat(Gt(Ft(JSON.stringify(e))),".").concat(Gt(Ft(JSON.stringify(t)))),r=Gt(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:po(e)};case"RSA-PSS":switch(ho(e),e.algorithm.hash.name){case"SHA-256":case"SHA-384":case"SHA-512":return {name:e.algorithm.name,saltLength:parseInt(e.algorithm.hash.name.slice(-3),10)>>3};default:throw new Yt("unsupported RSA-PSS hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":return ho(e),e.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return e.algorithm.name}throw new Yt("unsupported CryptoKey algorithm name",{cause:e})}(n),n,Ft(o)));return "".concat(o,".").concat(r)}(c,u,o));}}const wn=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch(e){return null}};function gn(e,t){if(t&&"https:"!==e.protocol)throw qt("only requests to HTTPS are allowed",oo,e);if("https:"!==e.protocol&&"http:"!==e.protocol)throw qt("only HTTP and HTTPS requests are allowed",ro,e)}function vn(e,t,n,o){let r;if("string"!=typeof e||!(r=wn(e)))throw qt("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),void 0===e?co:uo,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return gn(r,o),r}function bn(e,t,n,o){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?vn(e.mtls_endpoint_aliases[t],t,n,o):vn(e[t],t,n,o)}class kn extends Error{constructor(e,t){var n;super(e,t),d(this,"cause",void 0),d(this,"code",void 0),d(this,"error",void 0),d(this,"status",void 0),d(this,"error_description",void 0),d(this,"response",void 0),this.name=this.constructor.name,this.code=Bn,this.cause=t.cause,this.error=t.cause.error,this.status=t.response.status,this.error_description=t.cause.error_description,Object.defineProperty(this,"response",{enumerable:!1,value:t.response}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class _n extends Error{constructor(e,t){var n,o;super(e,t),d(this,"cause",void 0),d(this,"code",void 0),d(this,"error",void 0),d(this,"error_description",void 0),this.name=this.constructor.name,this.code=Qn,this.cause=t.cause,this.error=t.cause.get("error"),this.error_description=null!==(n=t.cause.get("error_description"))&&void 0!==n?n:void 0,null===(o=Error.captureStackTrace)||void 0===o||o.call(Error,this,this.constructor);}}class Sn extends Error{constructor(e,t){var n;super(e,t),d(this,"cause",void 0),d(this,"code",void 0),d(this,"response",void 0),d(this,"status",void 0),this.name=this.constructor.name,this.code=Yn,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,"response",{enumerable:!1}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}const Tn="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",En="("+Tn+')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"',Pn="("+Tn+")\\s*=\\s*("+Tn+")",An=new RegExp("^[,\\s]*("+Tn+")"),Rn=new RegExp("^[,\\s]*"+En+"[,\\s]*(.*)"),In=new RegExp("^[,\\s]*"+Pn+"[,\\s]*(.*)"),xn=new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function Cn(e,t,n){if(e.status!==t){let t;var o;if(function(e){let t;if(t=function(e){if(!jt(e,Response))throw Ut('"response" must be an instance of Response',Kt);const t=e.headers.get("www-authenticate");if(null===t)return;const n=[];let o=t;for(;o;){var r;let e=o.match(An);const t=null===(r=e)||void 0===r?void 0:r[1].toLowerCase();if(!t)return;const c=o.substring(e[0].length);if(c&&!c.match(/^[\s,]/))return;const u=c.match(/^\s+(.*)$/),l=!!u;o=u?u[1]:void 0;const h={};let d;if(l)for(;o;){let t,n;if(e=o.match(Rn)){var i=y(e,4);if(t=i[1],n=i[2],o=i[3],n.includes("\\"))try{n=JSON.parse('"'.concat(n,'"'));}catch(e){}h[t.toLowerCase()]=n;}else {if(!(e=o.match(In))){if(e=o.match(xn)){if(Object.keys(h).length)break;var a=y(e,3);d=a[1],o=a[2];break}return}var s=y(e,4);t=s[1],n=s[2],o=s[3],h[t.toLowerCase()]=n;}}else o=c||void 0;const p={scheme:t,parameters:h};d&&(p.token68=d),n.push(p);}return n.length?n:void 0}(e))throw new Sn("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}(e),t=await async function(e){if(e.status>399&&e.status<500){lo(e),sn(e);try{const t=await e.clone().json();if($t(t)&&"string"==typeof t.error&&t.error.length)return t}catch(e){}}}(e))throw await(null===(o=e.body)||void 0===o?void 0:o.cancel()),new kn("server responded with an error in the response body",{cause:t,response:e});throw qt('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),no,e)}}function On(e){if(!Mn.has(e))throw Ut('"options.DPoP" is not a valid DPoPHandle',Wt)}function jn(e){var t;return null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";")[0]}async function Wn(e,t,n,o,r,i,a){return await n(e,t,r,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((null==a?void 0:a[Dt])||fetch)(o.href,{body:r,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:tn(o,null==a?void 0:a.signal)})}async function Kn(e,t,n,o,r,i){var a;const s=bn(e,"token_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Lt]));r.set("grant_type",o);const c=en(null==i?void 0:i.headers);c.set("accept","application/json"),void 0!==(null==i?void 0:i.DPoP)&&(On(i.DPoP),await i.DPoP.addProof(s,c,"POST"));const u=await Wn(e,t,n,s,r,c,i);return null==i||null===(a=i.DPoP)||void 0===a||a.cacheNonce(u,s),u}const Un=new WeakMap,Ln=new WeakMap;function Nn(e){if(!e.id_token)return;const t=Un.get(e);if(!t)throw Ut('"ref" was already garbage collected or did not resolve from the proper sources',Wt);return t}async function Jn(e,t,n,o,r,i){if(pn(e),fn(t),!jt(n,Response))throw Ut('"response" must be an instance of Response',Kt);await Cn(n,200,"Token Endpoint"),lo(n);const a=await bo(n);if(an(a.access_token,'"response" body "access_token" property',eo,{body:a}),an(a.token_type,'"response" body "token_type" property',eo,{body:a}),a.token_type=a.token_type.toLowerCase(),void 0!==a.expires_in){let e="number"!=typeof a.expires_in?parseFloat(a.expires_in):a.expires_in;rn(e,!0,'"response" body "expires_in" property',eo,{body:a}),a.expires_in=e;}if(void 0!==a.refresh_token&&an(a.refresh_token,'"response" body "refresh_token" property',eo,{body:a}),void 0!==a.scope&&"string"!=typeof a.scope)throw qt('"response" body "scope" property must be a string',eo,{body:a});if(void 0!==a.id_token){an(a.id_token,'"response" body "id_token" property',eo,{body:a});const i=["aud","exp","iat","iss","sub"];!0===t.require_auth_time&&i.push("auth_time"),void 0!==t.default_max_age&&(rn(t.default_max_age,!0,'"client.default_max_age"'),i.push("auth_time")),null!=o&&o.length&&i.push(...o);const s=await async function(e,t,n,o,r){let i,a,s=e.split("."),c=s[0],u=s[1],l=s.length;if(5===l){if(void 0===r)throw new Yt("JWE decryption is not configured",{cause:e});var h=(e=await r(e)).split(".");c=h[0],u=h[1],l=h.length;}if(3!==l)throw qt("Invalid JWT",eo,e);try{i=JSON.parse(Ft(Gt(c)));}catch(e){throw qt("failed to parse JWT Header body as base64url encoded JSON",$n,e)}if(!$t(i))throw qt("JWT Header must be a top level object",eo,e);if(t(i),void 0!==i.crit)throw new Yt('no JWT "crit" header parameter extensions are supported',{cause:{header:i}});try{a=JSON.parse(Ft(Gt(u)));}catch(e){throw qt("failed to parse JWT Payload body as base64url encoded JSON",$n,e)}if(!$t(a))throw qt("JWT Payload must be a top level object",eo,e);const d=dn()+n;if(void 0!==a.exp){if("number"!=typeof a.exp)throw qt('unexpected JWT "exp" (expiration time) claim type',eo,{claims:a});if(a.exp<=d-o)throw qt('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',io,{claims:a,now:d,tolerance:o,claim:"exp"})}if(void 0!==a.iat&&"number"!=typeof a.iat)throw qt('unexpected JWT "iat" (issued at) claim type',eo,{claims:a});if(void 0!==a.iss&&"string"!=typeof a.iss)throw qt('unexpected JWT "iss" (issuer) claim type',eo,{claims:a});if(void 0!==a.nbf){if("number"!=typeof a.nbf)throw qt('unexpected JWT "nbf" (not before) claim type',eo,{claims:a});if(a.nbf>d+o)throw qt('unexpected JWT "nbf" (not before) claim value',io,{claims:a,now:d,tolerance:o,claim:"nbf"})}if(void 0!==a.aud&&"string"!=typeof a.aud&&!Array.isArray(a.aud))throw qt('unexpected JWT "aud" (audience) claim type',eo,{claims:a});return {header:i,claims:a,jwt:e}}(a.id_token,mo.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),ln(t),hn(t),r).then(Fn.bind(void 0,i)).then(Hn.bind(void 0,e)).then(Dn.bind(void 0,t.client_id)),c=s.claims,u=s.jwt;if(Array.isArray(c.aud)&&1!==c.aud.length){if(void 0===c.azp)throw qt('ID Token "aud" (audience) claim includes additional untrusted audiences',ao,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw qt('unexpected ID Token "azp" (authorized party) claim value',ao,{expected:t.client_id,claims:c,claim:"azp"})}void 0!==c.auth_time&&rn(c.auth_time,!0,'ID Token "auth_time" (authentication time)',eo,{claims:c}),Ln.set(n,u),Un.set(a,c);}if(void 0!==(null==i?void 0:i[a.token_type]))i[a.token_type](n,a);else if("dpop"!==a.token_type&&"bearer"!==a.token_type)throw new Yt("unsupported `token_type` value",{cause:{body:a}});return a}function Dn(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw qt('unexpected JWT "aud" (audience) claim value',ao,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw qt('unexpected JWT "aud" (audience) claim value',ao,{expected:e,claims:t.claims,claim:"aud"});return t}function Hn(e,t){var n,o;const r=null!==(n=null===(o=e[_o])||void 0===o?void 0:o.call(e,t))&&void 0!==n?n:e.issuer;if(t.claims.iss!==r)throw qt('unexpected JWT "iss" (issuer) claim value',ao,{expected:r,claims:t.claims,claim:"iss"});return t}const Mn=new WeakSet;const zn=Symbol();const Zn={aud:"audience",c_hash:"code hash",client_id:"client id",exp:"expiration time",iat:"issued at",iss:"issuer",jti:"jwt id",nonce:"nonce",s_hash:"state hash",sub:"subject",ath:"access token hash",htm:"http method",htu:"http uri",cnf:"confirmation",auth_time:"authentication time"};function Fn(e,t){for(const n of e)if(void 0===t.claims[n])throw qt('JWT "'.concat(n,'" (').concat(Zn[n],") claim missing"),eo,{claims:t.claims});return t}const Xn=Symbol(),Vn=Symbol();async function Gn(e,t,n,o){return "string"==typeof(null==o?void 0:o.expectedNonce)||"number"==typeof(null==o?void 0:o.maxAge)||null!=o&&o.requireIdToken?async function(e,t,n,o,r,i,a){const s=[];switch(o){case void 0:o=Xn;break;case Xn:break;default:an(o,'"expectedNonce" argument'),s.push("nonce");}switch(null!=r||(r=t.default_max_age),r){case void 0:r=Vn;break;case Vn:break;default:rn(r,!0,'"maxAge" argument'),s.push("auth_time");}const c=await Jn(e,t,n,s,i,a);an(c.id_token,'"response" body "id_token" property',eo,{body:c});const u=Nn(c);if(r!==Vn){const e=dn()+ln(t),n=hn(t);if(u.auth_time+r<e-n)throw qt("too much time has elapsed since the last End-User authentication",io,{claims:u,now:e,tolerance:n,claim:"auth_time"})}if(o===Xn){if(void 0!==u.nonce)throw qt('unexpected ID Token "nonce" claim value',ao,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==o)throw qt('unexpected ID Token "nonce" claim value',ao,{expected:o,claims:u,claim:"nonce"});return c}(e,t,n,o.expectedNonce,o.maxAge,o[Mt],o.recognizedTokenTypes):async function(e,t,n,o,r){const i=await Jn(e,t,n,void 0,o,r),a=Nn(i);if(a){if(void 0!==t.default_max_age){rn(t.default_max_age,!0,'"client.default_max_age"');const e=dn()+ln(t),n=hn(t);if(a.auth_time+t.default_max_age<e-n)throw qt("too much time has elapsed since the last End-User authentication",io,{claims:a,now:e,tolerance:n,claim:"auth_time"})}if(void 0!==a.nonce)throw qt('unexpected ID Token "nonce" claim value',ao,{expected:void 0,claims:a,claim:"nonce"})}return i}(e,t,n,null==o?void 0:o[Mt],null==o?void 0:o.recognizedTokenTypes)}const Yn="OAUTH_WWW_AUTHENTICATE_CHALLENGE",Bn="OAUTH_RESPONSE_BODY_ERROR",qn="OAUTH_UNSUPPORTED_OPERATION",Qn="OAUTH_AUTHORIZATION_RESPONSE_ERROR",$n="OAUTH_PARSE_ERROR",eo="OAUTH_INVALID_RESPONSE",to="OAUTH_RESPONSE_IS_NOT_JSON",no="OAUTH_RESPONSE_IS_NOT_CONFORM",oo="OAUTH_HTTP_REQUEST_FORBIDDEN",ro="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",io="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",ao="OAUTH_JWT_CLAIM_COMPARISON_FAILED",so="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED",co="OAUTH_MISSING_SERVER_METADATA",uo="OAUTH_INVALID_SERVER_METADATA";function lo(e){if(e.bodyUsed)throw Ut('"response" body has been used already',Wt)}function ho(e){const t=e.algorithm;if("number"!=typeof t.modulusLength||t.modulusLength<2048)throw new Yt("unsupported ".concat(t.name," modulusLength"),{cause:e})}function po(e){switch(e.algorithm.namedCurve){case"P-256":return "SHA-256";case"P-384":return "SHA-384";case"P-521":return "SHA-512";default:throw new Yt("unsupported ECDSA namedCurve",{cause:e})}}async function fo(e){if("POST"!==e.method)throw Ut("form_post responses are expected to use the POST method",Wt,{cause:e});if("application/x-www-form-urlencoded"!==jn(e))throw Ut("form_post responses are expected to use the application/x-www-form-urlencoded content-type",Wt,{cause:e});return async function(e){if(e.bodyUsed)throw Ut("form_post Request instances must contain a readable body",Wt,{cause:e});return e.text()}(e)}function mo(e,t,n,o){if(void 0===e)if(Array.isArray(t)){if(!t.includes(o.alg))throw qt('unexpected JWT "alg" header parameter',eo,{header:o,expected:t,reason:"authorization server metadata"})}else {if(void 0===n)throw qt('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n});if("string"==typeof n?o.alg!==n:"function"==typeof n?!n(o.alg):!n.includes(o.alg))throw qt('unexpected JWT "alg" header parameter',eo,{header:o,expected:n,reason:"default value"})}else if("string"==typeof e?o.alg!==e:!e.includes(o.alg))throw qt('unexpected JWT "alg" header parameter',eo,{header:o,expected:e,reason:"client configuration"})}function yo(e,t){const n=e.getAll(t),o=n[0];if(n.length>1)throw qt('"'.concat(t,'" parameter must be provided only once'),eo);return o}const wo=Symbol(),go=Symbol();function vo(e,t,n,o){if(pn(e),fn(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw Ut('"parameters" must be an instance of URLSearchParams, or URL',Kt);if(yo(n,"response"))throw qt('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',eo,{parameters:n});const r=yo(n,"iss"),i=yo(n,"state");if(!r&&e.authorization_response_iss_parameter_supported)throw qt('response parameter "iss" (issuer) missing',eo,{parameters:n});if(r&&r!==e.issuer)throw qt('unexpected "iss" (issuer) response parameter value',eo,{expected:e.issuer,parameters:n});switch(o){case void 0:case go:if(void 0!==i)throw qt('unexpected "state" response parameter encountered',eo,{expected:void 0,parameters:n});break;case wo:break;default:if(an(o,'"expectedState" argument'),i!==o)throw qt(void 0===i?'response parameter "state" missing':'unexpected "state" response parameter value',eo,{expected:o,parameters:n})}if(yo(n,"error"))throw new _n("authorization response from the server is an error",{cause:n});const a=yo(n,"id_token"),s=yo(n,"token");if(void 0!==a||void 0!==s)throw new Yt("implicit and hybrid flows are not supported");return c=new URLSearchParams(n),Mn.add(c),c;var c;}async function bo(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:sn;try{t=await e.json();}catch(t){throw n(e),qt('failed to parse "response" body as JSON',$n,t)}if(!$t(t))throw qt('"response" body must be a top level object',eo,{body:t});return t}const ko=Symbol(),_o=Symbol(),So=new TextEncoder,To=new TextDecoder;function Eo(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);if(o>127)throw new TypeError("non-ASCII string encountered in encode()");t[n]=o;}return t}function Po(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Ao(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof e?e:To.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=To.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/");try{return Po(t)}catch(e){throw new TypeError("The input to be decoded is not correctly encoded.")}}const Ro=function(e){return new TypeError("CryptoKey does not support this operation, its ".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"algorithm.name"," must be ").concat(e))},Io=(e,t)=>e.name===t;function xo(e,t){var n;if((n=e.hash,parseInt(n.name.slice(4),10))!==t)throw Ro("SHA-".concat(t),"algorithm.hash")}function Co(e,t,n){switch(t){case"HS256":case"HS384":case"HS512":if(!Io(e.algorithm,"HMAC"))throw Ro("HMAC");xo(e.algorithm,parseInt(t.slice(2),10));break;case"RS256":case"RS384":case"RS512":if(!Io(e.algorithm,"RSASSA-PKCS1-v1_5"))throw Ro("RSASSA-PKCS1-v1_5");xo(e.algorithm,parseInt(t.slice(2),10));break;case"PS256":case"PS384":case"PS512":if(!Io(e.algorithm,"RSA-PSS"))throw Ro("RSA-PSS");xo(e.algorithm,parseInt(t.slice(2),10));break;case"Ed25519":case"EdDSA":if(!Io(e.algorithm,"Ed25519"))throw Ro("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":if(!Io(e.algorithm,t))throw Ro(t);break;case"ES256":case"ES384":case"ES512":{if(!Io(e.algorithm,"ECDSA"))throw Ro("ECDSA");const n=function(e){switch(e){case"ES256":return "P-256";case"ES384":return "P-384";case"ES512":return "P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==n)throw Ro(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}!function(e,t){if(t&&!e.usages.includes(t))throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(t,"."))}(e,n);}function Oo(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];if((o=o.filter(Boolean)).length>2){const t=o.pop();e+="one of type ".concat(o.join(", "),", or ").concat(t,".");}else 2===o.length?e+="one of type ".concat(o[0]," or ").concat(o[1],"."):e+="of type ".concat(o[0],".");if(null==t)e+=" Received ".concat(t);else if("function"==typeof t&&t.name)e+=" Received function ".concat(t.name);else if("object"==typeof t&&null!=t){var i;null!==(i=t.constructor)&&void 0!==i&&i.name&&(e+=" Received an instance of ".concat(t.constructor.name));}return e}const jo=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return Oo("Key for the ".concat(e," algorithm must be "),t,...o)};class Wo extends Error{constructor(e,t){var n;super(e,t),d(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}d(Wo,"code","ERR_JOSE_GENERIC");class Ko extends Wo{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),d(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),d(this,"claim",void 0),d(this,"reason",void 0),d(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}d(Ko,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class Uo extends Wo{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),d(this,"code","ERR_JWT_EXPIRED"),d(this,"claim",void 0),d(this,"reason",void 0),d(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}d(Uo,"code","ERR_JWT_EXPIRED");class Lo extends Wo{constructor(){super(...arguments),d(this,"code","ERR_JOSE_ALG_NOT_ALLOWED");}}d(Lo,"code","ERR_JOSE_ALG_NOT_ALLOWED");class No extends Wo{constructor(){super(...arguments),d(this,"code","ERR_JOSE_NOT_SUPPORTED");}}d(No,"code","ERR_JOSE_NOT_SUPPORTED");d(class extends Wo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWE_DECRYPTION_FAILED");}},"code","ERR_JWE_DECRYPTION_FAILED");d(class extends Wo{constructor(){super(...arguments),d(this,"code","ERR_JWE_INVALID");}},"code","ERR_JWE_INVALID");class Jo extends Wo{constructor(){super(...arguments),d(this,"code","ERR_JWS_INVALID");}}d(Jo,"code","ERR_JWS_INVALID");class Do extends Wo{constructor(){super(...arguments),d(this,"code","ERR_JWT_INVALID");}}d(Do,"code","ERR_JWT_INVALID");d(class extends Wo{constructor(){super(...arguments),d(this,"code","ERR_JWK_INVALID");}},"code","ERR_JWK_INVALID");class Ho extends Wo{constructor(){super(...arguments),d(this,"code","ERR_JWKS_INVALID");}}d(Ho,"code","ERR_JWKS_INVALID");class Mo extends Wo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"no applicable key found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWKS_NO_MATCHING_KEY");}}d(Mo,"code","ERR_JWKS_NO_MATCHING_KEY");class zo extends Wo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"multiple matching keys found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),d(this,Symbol.asyncIterator,void 0),d(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");}}d(zo,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class Zo extends Wo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWKS_TIMEOUT");}}d(Zo,"code","ERR_JWKS_TIMEOUT");class Fo extends Wo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");}}d(Fo,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const Xo=e=>{if("CryptoKey"===(null==e?void 0:e[Symbol.toStringTag]))return !0;try{return e instanceof CryptoKey}catch(e){return !1}},Vo=e=>"KeyObject"===(null==e?void 0:e[Symbol.toStringTag]),Go=e=>Xo(e)||Vo(e);function Yo(e,t,n){try{return Ao(e)}catch(e){throw new n("Failed to base64url decode the ".concat(t))}}function Bo(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return !1;var t;if(null===Object.getPrototypeOf(e))return !0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}const qo=e=>Bo(e)&&"string"==typeof e.kty;async function Qo(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return Oo("Key must be ",e,...n)}(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:"SHA-".concat(e.slice(-3)),name:"HMAC"},!1,[n])}return Co(t,e,n),t}async function $o(e,t,n,o){const r=await Qo(e,t,"verify");!function(e,t){if(e.startsWith("RS")||e.startsWith("PS")){const n=t.algorithm.modulusLength;if("number"!=typeof n||n<2048)throw new TypeError("".concat(e," requires key modulusLength to be 2048 bits or larger"))}}(e,r);const i=function(e,t){const n="SHA-".concat(e.slice(-3));switch(e){case"HS256":case"HS384":case"HS512":return {hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return {hash:n,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return {hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return {hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return {name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return {name:e};default:throw new No("alg ".concat(e," is not supported either by JOSE or your javascript runtime"))}}(e,r.algorithm);try{return await crypto.subtle.verify(i,r,n,o)}catch(e){return !1}}const er='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function tr(e){var t,n;if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const o=function(e){let t,n;switch(e.kty){case"AKP":switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},n=e.priv?["sign"]:["verify"];break;default:throw new No(er)}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:"SHA-".concat(e.alg.slice(-3))},n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(e.alg.slice(-3))},n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(e.alg.slice(-3),10)||1)},n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new No(er)}break;case"EC":switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[e.alg]},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new No(er)}break;case"OKP":switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new No(er)}break;default:throw new No('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return {algorithm:t,keyUsages:n}}(e),r=o.algorithm,i=o.keyUsages,a=f({},e);return "AKP"!==a.kty&&delete a.alg,delete a.use,crypto.subtle.importKey("jwk",a,r,null!==(t=e.ext)&&void 0!==t?t:!e.d&&!e.priv,null!==(n=e.key_ops)&&void 0!==n?n:i)}const nr="given KeyObject instance cannot be used for this algorithm";let or;const rr=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];or||(or=new WeakMap);let r=or.get(e);if(null!=r&&r[n])return r[n];const i=await tr(f(f({},t),{},{alg:n}));return o&&Object.freeze(e),r?r[n]=i:or.set(e,{[n]:i}),i};async function ir(e,t){if(e instanceof Uint8Array)return e;if(Xo(e))return e;if(Vo(e)){if("secret"===e.type)return e.export();if("toCryptoKey"in e&&"function"==typeof e.toCryptoKey)try{return ((e,t)=>{or||(or=new WeakMap);let n=or.get(e);if(null!=n&&n[t])return n[t];const o="public"===e.type,r=!!o;let i;if("x25519"===e.asymmetricKeyType){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError(nr)}i=e.toCryptoKey(e.asymmetricKeyType,r,o?[]:["deriveBits"]);}if("ed25519"===e.asymmetricKeyType){if("EdDSA"!==t&&"Ed25519"!==t)throw new TypeError(nr);i=e.toCryptoKey(e.asymmetricKeyType,r,[o?"verify":"sign"]);}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(t!==e.asymmetricKeyType.toUpperCase())throw new TypeError(nr);i=e.toCryptoKey(e.asymmetricKeyType,r,[o?"verify":"sign"]);}if("rsa"===e.asymmetricKeyType){let n;switch(t){case"RSA-OAEP":n="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":n="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":n="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":n="SHA-512";break;default:throw new TypeError(nr)}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:n},r,o?["encrypt"]:["decrypt"]);i=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:n},r,[o?"verify":"sign"]);}if("ec"===e.asymmetricKeyType){var a;const n=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(null===(a=e.asymmetricKeyDetails)||void 0===a?void 0:a.namedCurve);if(!n)throw new TypeError(nr);const s={ES256:"P-256",ES384:"P-384",ES512:"P-521"};s[t]&&n===s[t]&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:n},r,[o?"verify":"sign"])),t.startsWith("ECDH-ES")&&(i=e.toCryptoKey({name:"ECDH",namedCurve:n},r,o?[]:["deriveBits"]));}if(!i)throw new TypeError(nr);return n?n[t]=i:or.set(e,{[t]:i}),i})(e,t)}catch(e){if(e instanceof TypeError)throw e}let n=e.export({format:"jwk"});return rr(e,n,t)}if(qo(e))return e.k?Ao(e.k):rr(e,e,t,!0);throw new Error("unreachable")}const ar=(e,t)=>{if(e.byteLength!==t.length)return !1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return !1;return !0},sr=e=>{const t=e.data[e.pos++];if(128&t){const n=127&t;let o=0;for(let t=0;t<n;t++)o=o<<8|e.data[e.pos++];return o}return t},cr=(e,t,n)=>{if(e.data[e.pos++]!==t)throw new Error(n)},ur=(e,t)=>{const n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n};const lr=e=>{const t=(e=>{cr(e,6,"Expected algorithm OID");const t=sr(e);return ur(e,t)})(e);if(ar(t,[43,101,110]))return "X25519";if(!ar(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");cr(e,6,"Expected curve OID");const n=sr(e),o=ur(e,n);for(const e of [{name:"P-256",oid:[42,134,72,206,61,3,1,7]},{name:"P-384",oid:[43,129,4,0,34]},{name:"P-521",oid:[43,129,4,0,35]}]){const t=e.name,n=e.oid;if(ar(o,n))return t}throw new Error("Unsupported named curve")},hr=async(e,t,n,o)=>{var r;let i,a;const s="spki"===e,c=()=>s?["verify"]:["sign"];switch(n){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(n.slice(-3),10)||1)},a=s?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":case"ES384":case"ES512":i={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[n]},a=c();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{const e=o.getNamedCurve(t);i="X25519"===e?{name:"X25519"}:{name:"ECDH",namedCurve:e};}catch(e){throw new No("Invalid or unsupported key format")}a=s?[]:["deriveBits"];break;case"Ed25519":case"EdDSA":i={name:"Ed25519"},a=c();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:n},a=c();break;default:throw new No('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(e,t,i,null!==(r=null==o?void 0:o.extractable)&&void 0!==r?r:!!s,a)},dr=(e,t,n)=>{var o;const r=((e,t)=>Po(e.replace(t,"")))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);let i=n;return null!=t&&null!==(o=t.startsWith)&&void 0!==o&&o.call(t,"ECDH-ES")&&(i||(i={}),i.getNamedCurve=e=>{const t={data:e,pos:0};return function(e){cr(e,48,"Invalid PKCS#8 structure"),sr(e),cr(e,2,"Expected version field");const t=sr(e);e.pos+=t,cr(e,48,"Expected algorithm identifier");sr(e);e.pos;}(t),lr(t)}),hr("pkcs8",r,t,i)};const pr=e=>null==e?void 0:e[Symbol.toStringTag],fr=(e,t,n)=>{if(void 0!==t.use){let e;switch(n){case"sign":case"verify":e="sig";break;case"encrypt":case"decrypt":e="enc";}if(t.use!==e)throw new TypeError('Invalid key for this operation, its "use" must be "'.concat(e,'" when present'))}if(void 0!==t.alg&&t.alg!==e)throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(e,'" when present'));if(Array.isArray(t.key_ops)){var o,r;let i;switch(!0){case"sign"===n||"verify"===n:case"dir"===e:case e.includes("CBC-HS"):i=n;break;case e.startsWith("PBES2"):i="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):i=!e.includes("GCM")&&e.endsWith("KW")?"encrypt"===n?"wrapKey":"unwrapKey":n;break;case"encrypt"===n&&e.startsWith("RSA"):i="wrapKey";break;case"decrypt"===n:i=e.startsWith("RSA")?"unwrapKey":"deriveBits";}if(i&&!1===(null===(o=t.key_ops)||void 0===o||null===(r=o.includes)||void 0===r?void 0:r.call(o,i)))throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(i,'" when present'))}return !0};function mr(e,t,n){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((e,t,n)=>{if(!(t instanceof Uint8Array)){if(qo(t)){if((e=>"oct"===e.kty&&"string"==typeof e.k)(t)&&fr(e,t,n))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!Go(t))throw new TypeError(jo(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==t.type)throw new TypeError("".concat(pr(t),' instances for symmetric algorithms must be of type "secret"'))}})(e,t,n);break;default:((e,t,n)=>{if(qo(t))switch(n){case"decrypt":case"sign":if((e=>"oct"!==e.kty&&("AKP"===e.kty&&"string"==typeof e.priv||"string"==typeof e.d))(t)&&fr(e,t,n))return;throw new TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if((e=>"oct"!==e.kty&&void 0===e.d&&void 0===e.priv)(t)&&fr(e,t,n))return;throw new TypeError("JSON Web Key for this operation must be a public JWK")}if(!Go(t))throw new TypeError(jo(e,t,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===t.type)throw new TypeError("".concat(pr(t),' instances for asymmetric algorithms must not be of type "secret"'));if("public"===t.type)switch(n){case"sign":throw new TypeError("".concat(pr(t),' instances for asymmetric algorithm signing must be of type "private"'));case"decrypt":throw new TypeError("".concat(pr(t),' instances for asymmetric algorithm decryption must be of type "private"'))}if("private"===t.type)switch(n){case"verify":throw new TypeError("".concat(pr(t),' instances for asymmetric algorithm verifying must be of type "public"'));case"encrypt":throw new TypeError("".concat(pr(t),' instances for asymmetric algorithm encryption must be of type "public"'))}})(e,t,n);}}var yr,wr;let gr,vr;if("undefined"==typeof navigator||null===(yr=navigator.userAgent)||void 0===yr||null===(wr=yr.startsWith)||void 0===wr||!wr.call(yr,"Mozilla/5.0 ")){const e="v6.8.4";vr="".concat("openid-client","/").concat(e),gr={"user-agent":vr};}const br=e=>kr.get(e);let kr,_r;function Sr(e){return void 0!==e?mn(e):(_r||(_r=new WeakMap),(e,t,n,o)=>{let r;return (r=_r.get(t))||(!function(e,t){if("string"!=typeof e)throw Ar("".concat(t," must be a string"),Pr);if(0===e.length)throw Ar("".concat(t," must not be empty"),Er)}(t.client_secret,'"metadata.client_secret"'),r=mn(t.client_secret),_r.set(t,r)),r(e,t,n,o)})}const Tr=Dt,Er="ERR_INVALID_ARG_VALUE",Pr="ERR_INVALID_ARG_TYPE";function Ar(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}function Rr(e){return async function(e){return an(e,"codeVerifier"),Gt(await crypto.subtle.digest("SHA-256",Ft(e)))}(e)}function Ir(){return cn()}class xr extends Error{constructor(e,t){var n;super(e,t),d(this,"code",void 0),this.name=this.constructor.name,this.code=null==t?void 0:t.code,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function Cr(e,t,n){return new xr(e,{cause:t,code:n})}function Or(e){if(e instanceof TypeError||e instanceof xr||e instanceof kn||e instanceof _n||e instanceof Sn)throw e;if(e instanceof Bt)switch(e.code){case oo:throw Cr("only requests to HTTPS are allowed",e,e.code);case ro:throw Cr("only requests to HTTP or HTTPS are allowed",e,e.code);case no:throw Cr("unexpected HTTP response status code",e.cause,e.code);case to:throw Cr("unexpected response content-type",e.cause,e.code);case $n:throw Cr("parsing error occured",e,e.code);case eo:throw Cr("invalid response encountered",e,e.code);case ao:throw Cr("unexpected JWT claim value encountered",e,e.code);case so:throw Cr("unexpected JSON attribute value encountered",e,e.code);case io:throw Cr("JWT timestamp claim value failed validation",e,e.code);default:throw Cr(e.message,e,e.code)}if(e instanceof Yt)throw Cr("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw Cr("runtime operation error",e,qn);case"NotSupportedError":throw Cr("runtime unsupported operation",e,qn);case"TimeoutError":throw Cr("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw Cr("operation aborted",e,"OAUTH_ABORT")}throw new xr("something went wrong",{cause:e})}async function jr(e,t,n,o,r){const i=await async function(e,t){var n,o;if(!(e instanceof URL))throw Ar('"server" must be an instance of URL',Pr);const r=!e.href.includes("/.well-known/"),i=null!==(n=null==t?void 0:t.timeout)&&void 0!==n?n:30,a=AbortSignal.timeout(1e3*i),s=await(r?on(e,{algorithm:null==t?void 0:t.algorithm,[Dt]:null==t?void 0:t[Tr],[Lt]:null==t||null===(o=t.execute)||void 0===o?void 0:o.includes(Hr),signal:a,headers:new Headers(gr)}):((null==t?void 0:t[Tr])||fetch)((gn(e,null==t||null===(c=t.execute)||void 0===c||!c.includes(Hr)),e.href),{headers:Object.fromEntries(new Headers(f({accept:"application/json"},gr)).entries()),body:void 0,method:"GET",redirect:"manual",signal:a})).then(e=>async function(e,t){const n=e;if(!(n instanceof URL)&&n!==ko)throw Ut('"expectedIssuerIdentifier" must be an instance of URL',Kt);if(!jt(t,Response))throw Ut('"response" must be an instance of Response',Kt);if(200!==t.status)throw qt('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',no,t);lo(t);const o=await bo(t);if(an(o.issuer,'"response" body "issuer" property',eo,{body:o}),n!==ko&&new URL(o.issuer).href!==n.href)throw qt('"response" body "issuer" property does not match the expected value',so,{expected:n.href,body:o,attribute:"issuer"});return o}(ko,e)).catch(Or);var c;r&&new URL(s.issuer).href!==e.href&&(function(e,t,n){return !("https://login.microsoftonline.com"!==e.origin||null!=n&&n.algorithm&&"oidc"!==n.algorithm||(t[Wr]=!0,0))}(e,s,t)||function(e,t){return !(!e.hostname.endsWith(".b2clogin.com")||null!=t&&t.algorithm&&"oidc"!==t.algorithm)}(e,t)||(()=>{throw new xr("discovered metadata issuer does not match the expected issuer",{code:so,cause:{expected:e.href,body:s,attribute:"issuer"}})})());return s}(e,r),a=new Kr(i,t,n,o);let s=br(a);if(null!=r&&r[Tr]&&(s.fetch=r[Tr]),null!=r&&r.timeout&&(s.timeout=r.timeout),null!=r&&r.execute)for(const e of r.execute)e(a);return a}new TextDecoder;const Wr=Symbol();class Kr{constructor(e,t,n,o){var r,i,a,s,c;if("string"!=typeof t||!t.length)throw Ar('"clientId" must be a non-empty string',Pr);if("string"==typeof n&&(n={client_secret:n}),void 0!==(null===(r=n)||void 0===r?void 0:r.client_id)&&t!==n.client_id)throw Ar('"clientId" and "metadata.client_id" must be the same',Er);const u=f(f({},structuredClone(n)),{},{client_id:t});let l;u[Nt]=null!==(i=null===(a=n)||void 0===a?void 0:a[Nt])&&void 0!==i?i:0,u[Jt]=null!==(s=null===(c=n)||void 0===c?void 0:c[Jt])&&void 0!==s?s:30,l=o||("string"==typeof u.client_secret&&u.client_secret.length?Sr(u.client_secret):(e,t,n,o)=>{n.set("client_id",t.client_id);});let h=Object.freeze(u);const d=structuredClone(e);Wr in e&&(d[_o]=t=>{let n=t.claims.tid;return e.issuer.replace("{tenantid}",n)});let p=Object.freeze(d);kr||(kr=new WeakMap),kr.set(this,{__proto__:null,as:p,c:h,auth:l,tlsOnly:!0,jwksCache:{}});}serverMetadata(){const e=structuredClone(br(this).as);return function(e){Object.defineProperties(e,function(e){return {supportsPKCE:{__proto__:null,value(){var t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"S256";return !0===(null===(t=e.code_challenge_methods_supported)||void 0===t?void 0:t.includes(n))}}}}(e));}(e),e}clientMetadata(){return structuredClone(br(this).c)}get timeout(){return br(this).timeout}set timeout(e){br(this).timeout=e;}get[Tr](){return br(this).fetch}set[Tr](e){br(this).fetch=e;}}function Ur(e){Object.defineProperties(e,function(e){let t;if(void 0!==e.expires_in){const n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime();}return {expiresIn:{__proto__:null,value(){if(t){const e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return Nn(this)}catch(e){return}}}}}(e));}async function Lr(e,t,n){var o;let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=null===(o=e.headers.get("retry-after"))||void 0===o?void 0:o.trim();if(void 0===i)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else {const e=new Date(i);if(Number.isFinite(e.getTime())){const t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3));}}if(r&&!Number.isFinite(a))throw new Bt("invalid Retry-After header value",{cause:e});a>t&&await Nr(a-t,n);}function Nr(e,t){return new Promise((n,o)=>{const r=e=>{try{t.throwIfAborted();}catch(e){return void o(e)}if(e<=0)return void n();const i=Math.min(e,5);setTimeout(()=>r(e-i),1e3*i);};r(e);})}async function Jr(e,t){Vr(e);const n=br(e),o=n.as,r=n.c,i=n.auth,a=n.fetch,s=n.tlsOnly,c=n.timeout;return async function(e,t,n,o,r){pn(e),fn(t);const i=bn(e,"backchannel_authentication_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Lt])),a=new URLSearchParams(o);a.set("client_id",t.client_id);const s=en(null==r?void 0:r.headers);return s.set("accept","application/json"),Wn(e,t,n,i,a,s,r)}(o,r,i,t,{[Dt]:a,[Lt]:!s,headers:new Headers(gr),signal:Gr(c)}).then(e=>async function(e,t,n){if(pn(e),fn(t),!jt(n,Response))throw Ut('"response" must be an instance of Response',Kt);await Cn(n,200,"Backchannel Authentication Endpoint"),lo(n);const o=await bo(n);an(o.auth_req_id,'"response" body "auth_req_id" property',eo,{body:o});let r="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return rn(r,!0,'"response" body "expires_in" property',eo,{body:o}),o.expires_in=r,void 0!==o.interval&&rn(o.interval,!1,'"response" body "interval" property',eo,{body:o}),o}(o,r,e)).catch(Or)}async function Dr(e,t,n,o){var r,i;Vr(e),n=new URLSearchParams(n);let a=null!==(r=t.interval)&&void 0!==r?r:5;const s=null!==(i=null==o?void 0:o.signal)&&void 0!==i?i:AbortSignal.timeout(1e3*t.expires_in);try{await Nr(a,s);}catch(e){Or(e);}const c=br(e),u=c.as,l=c.c,h=c.auth,d=c.fetch,p=c.tlsOnly,m=c.nonRepudiation,y=c.timeout,w=c.decrypt,g=(r,i)=>Dr(e,f(f({},t),{},{interval:r}),n,f(f({},o),{},{signal:s,flag:i})),v=function(e,t){const n=Gr(t);if(!n)return {signal:e,cleanup(){}};const o=new AbortController,r=e=>{const t=e.target;o.abort(t.reason);};return e.aborted?o.abort(e.reason):n.aborted?o.abort(n.reason):(e.addEventListener("abort",r,{once:!0}),n.addEventListener("abort",r,{once:!0})),{signal:o.signal,cleanup(){e.removeEventListener("abort",r),n.removeEventListener("abort",r);}}}(s,y),b=await async function(e,t,n,o,r){pn(e),fn(t),an(o,'"authReqId"');const i=new URLSearchParams(null==r?void 0:r.additionalParameters);return i.set("auth_req_id",o),Kn(e,t,n,"urn:openid:params:grant-type:ciba",i,r)}(u,l,h,t.auth_req_id,{[Dt]:d,[Lt]:!p,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(gr),signal:v.signal}).catch(Or).finally(v.cleanup);var k;if(503===b.status&&b.headers.has("retry-after"))return await Lr(b,a,s,!0),await(null===(k=b.body)||void 0===k?void 0:k.cancel()),g(a);const _=async function(e,t,n,o){return Jn(e,t,n,void 0,null==o?void 0:o[Mt],null==o?void 0:o.recognizedTokenTypes)}(u,l,b,{[Mt]:w});let S;try{S=await _;}catch(e){if(Yr(e,o))return g(a,Br);if(e instanceof kn)switch(e.error){case"slow_down":a+=5;case"authorization_pending":return await Lr(e.response,a,s),g(a)}Or(e);}return S.id_token&&await(null==m?void 0:m(b)),Ur(S),S}function Hr(e){br(e).tlsOnly=!1;}async function Mr(e,t,n,o,r){if(Vr(e),!((null==r?void 0:r.flag)===Br||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch(e){return !1}}(t,"Request")))throw Ar('"currentUrl" must be an instance of URL, or Request',Pr);let i,a;const s=br(e),c=s.as,u=s.c,l=s.auth,h=s.fetch,d=s.tlsOnly,p=s.jarm,m=s.hybrid,w=s.nonRepudiation,g=s.timeout,v=s.decrypt,b=s.implicit;if((null==r?void 0:r.flag)===Br)i=r.authResponse,a=r.redirectUri;else {if(!(t instanceof URL)){const e=t;switch(t=new URL(t.url),e.method){case"GET":break;case"POST":const n=new URLSearchParams(await fo(e));if(m)t.hash=n.toString();else for(const e of n.entries()){var k=y(e,2);const n=k[0],o=k[1];t.searchParams.append(n,o);}break;default:throw Ar("unexpected Request HTTP method",Er)}}switch(a=function(e){return (e=new URL(e)).search="",e.hash="",e.href}(t),!0){case!!p:i=await p(t,null==n?void 0:n.expectedState);break;case!!m:i=await m(t,null==n?void 0:n.expectedNonce,null==n?void 0:n.expectedState,null==n?void 0:n.maxAge);break;case!!b:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=vo(c,u,t.searchParams,null==n?void 0:n.expectedState);}catch(e){Or(e);}}}const _=await async function(e,t,n,o,r,i,a){if(pn(e),fn(t),!Mn.has(o))throw Ut('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',Wt);an(r,'"redirectUri"');const s=yo(o,"code");if(!s)throw qt('no authorization code in "callbackParameters"',eo);const c=new URLSearchParams(null==a?void 0:a.additionalParameters);return c.set("redirect_uri",r),c.set("code",s),i!==zn&&(an(i,'"codeVerifier"'),c.set("code_verifier",i)),Kn(e,t,n,"authorization_code",c,a)}(c,u,l,i,a,(null==n?void 0:n.pkceCodeVerifier)||zn,{additionalParameters:o,[Dt]:h,[Lt]:!d,DPoP:null==r?void 0:r.DPoP,headers:new Headers(gr),signal:Gr(g)}).catch(Or);"string"!=typeof(null==n?void 0:n.expectedNonce)&&"number"!=typeof(null==n?void 0:n.maxAge)||(n.idTokenExpected=!0);const S=Gn(c,u,_,{expectedNonce:null==n?void 0:n.expectedNonce,maxAge:null==n?void 0:n.maxAge,requireIdToken:null==n?void 0:n.idTokenExpected,[Mt]:v});let T;try{T=await S;}catch(t){if(Yr(t,r))return Mr(e,void 0,n,o,f(f({},r),{},{flag:Br,authResponse:i,redirectUri:a}));Or(t);}return T.id_token&&await(null==w?void 0:w(_)),Ur(T),T}async function zr(e,t,n,o){Vr(e),n=new URLSearchParams(n);const r=br(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,l=r.nonRepudiation,h=r.timeout,d=r.decrypt,p=await async function(e,t,n,o,r){pn(e),fn(t),an(o,'"refreshToken"');const i=new URLSearchParams(null==r?void 0:r.additionalParameters);return i.set("refresh_token",o),Kn(e,t,n,"refresh_token",i,r)}(i,a,s,t,{[Dt]:c,[Lt]:!u,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(gr),signal:Gr(h)}).catch(Or),m=async function(e,t,n,o){return Jn(e,t,n,void 0,null==o?void 0:o[Mt],null==o?void 0:o.recognizedTokenTypes)}(i,a,p,{[Mt]:d});let y;try{y=await m;}catch(r){if(Yr(r,o))return zr(e,t,n,f(f({},o),{},{flag:Br}));Or(r);}return y.id_token&&await(null==l?void 0:l(p)),Ur(y),y}async function Zr(e,t,n){Vr(e),t=new URLSearchParams(t);const o=br(e),r=o.as,i=o.c,a=o.auth,s=o.fetch,c=o.tlsOnly,u=o.timeout,l=await async function(e,t,n,o,r){return pn(e),fn(t),Kn(e,t,n,"client_credentials",new URLSearchParams(o),r)}(r,i,a,t,{[Dt]:s,[Lt]:!c,DPoP:null==n?void 0:n.DPoP,headers:new Headers(gr),signal:Gr(u)}).catch(Or),h=async function(e,t,n,o){return Jn(e,t,n,void 0,null==o?void 0:o[Mt],null==o?void 0:o.recognizedTokenTypes)}(r,i,l);let d;try{d=await h;}catch(o){if(Yr(o,n))return Zr(e,t,f(f({},n),{},{flag:Br}));Or(o);}return Ur(d),d}function Fr(e,t){Vr(e);const n=br(e),o=n.as,r=n.c,i=n.tlsOnly,a=n.hybrid,s=n.jarm,c=n.implicit,u=bn(o,"authorization_endpoint",!1,i);if((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",a?"code id_token":c?"id_token":"code"),c&&!t.has("nonce"))throw Ar("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Er);s&&t.set("response_mode","jwt");}for(const e of t.entries()){var l=y(e,2);const t=l[0],n=l[1];u.searchParams.append(t,n);}return u}async function Xr(e,t,n){Vr(e);const o=Fr(e,t),r=br(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,l=r.timeout,h=await async function(e,t,n,o,r){var i;pn(e),fn(t);const a=bn(e,"pushed_authorization_request_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Lt])),s=new URLSearchParams(o);s.set("client_id",t.client_id);const c=en(null==r?void 0:r.headers);c.set("accept","application/json"),void 0!==(null==r?void 0:r.DPoP)&&(On(r.DPoP),await r.DPoP.addProof(a,c,"POST"));const u=await Wn(e,t,n,a,s,c,r);return null==r||null===(i=r.DPoP)||void 0===i||i.cacheNonce(u,a),u}(i,a,s,o.searchParams,{[Dt]:c,[Lt]:!u,DPoP:null==n?void 0:n.DPoP,headers:new Headers(gr),signal:Gr(l)}).catch(Or),d=async function(e,t,n){if(pn(e),fn(t),!jt(n,Response))throw Ut('"response" must be an instance of Response',Kt);await Cn(n,201,"Pushed Authorization Request Endpoint"),lo(n);const o=await bo(n);an(o.request_uri,'"response" body "request_uri" property',eo,{body:o});let r="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return rn(r,!0,'"response" body "expires_in" property',eo,{body:o}),o.expires_in=r,o}(i,a,h);let p;try{p=await d;}catch(o){if(Yr(o,n))return Xr(e,t,f(f({},n),{},{flag:Br}));Or(o);}return Fr(e,{request_uri:p.request_uri})}function Vr(e){if(!(e instanceof Kr))throw Ar('"config" must be an instance of Configuration',Pr);if(Object.getPrototypeOf(e)!==Kr.prototype)throw Ar("subclassing Configuration is not allowed",Er)}function Gr(e){return e?AbortSignal.timeout(1e3*e):void 0}function Yr(e,t){return !(null==t||!t.DPoP||t.flag===Br)&&function(e){if(e instanceof Sn){const t=e.cause,n=t[0];return 1===t.length&&"dpop"===n.scheme&&"use_dpop_nonce"===n.parameters.error}return e instanceof kn&&"use_dpop_nonce"===e.error}(e)}Object.freeze(Kr.prototype);const Br=Symbol();async function qr(e,t,n,o){Vr(e);const r=br(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,l=r.timeout,h=r.decrypt,d=r.nonRepudiation,p=await async function(e,t,n,o,r,i){return pn(e),fn(t),an(o,'"grantType"'),Kn(e,t,n,o,new URLSearchParams(r),i)}(i,a,s,t,new URLSearchParams(n),{[Dt]:c,[Lt]:!u,DPoP:null==o?void 0:o.DPoP,headers:new Headers(gr),signal:Gr(l)}).catch(Or);let m;"urn:ietf:params:oauth:grant-type:token-exchange"===t&&(m={n_a:()=>{}});const y=async function(e,t,n,o){return Jn(e,t,n,void 0,null==o?void 0:o[Mt],null==o?void 0:o.recognizedTokenTypes)}(i,a,p,{[Mt]:h,recognizedTokenTypes:m});let w;try{w=await y;}catch(r){if(Yr(r,o))return qr(e,t,n,f(f({},o),{},{flag:Br}));Or(r);}return w.id_token&&await(null==d?void 0:d(p)),Ur(w),w}async function Qr(e,t,n){if(!Bo(e))throw new Jo("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new Jo('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new Jo("JWS Protected Header incorrect type");if(void 0===e.payload)throw new Jo("JWS Payload missing");if("string"!=typeof e.signature)throw new Jo("JWS Signature missing or incorrect type");if(void 0!==e.header&&!Bo(e.header))throw new Jo("JWS Unprotected Header incorrect type");let o={};if(e.protected)try{const t=Ao(e.protected);o=JSON.parse(To.decode(t));}catch(e){throw new Jo("JWS Protected Header is invalid")}if(!function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const o=t.filter(Boolean);if(0===o.length||1===o.length)return !0;let r;for(const e of o){const t=Object.keys(e);if(r&&0!==r.size)for(const e of t){if(r.has(e))return !1;r.add(e);}else r=new Set(t);}return !0}(o,e.header))throw new Jo("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r=f(f({},o),e.header),i=function(e,t,n,o,r){if(void 0!==r.crit&&void 0===(null==o?void 0:o.crit))throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!o||void 0===o.crit)return new Set;if(!Array.isArray(o.crit)||0===o.crit.length||o.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;i=void 0!==n?new Map([...Object.entries(n),...t.entries()]):t;for(const t of o.crit){if(!i.has(t))throw new No('Extension Header Parameter "'.concat(t,'" is not recognized'));if(void 0===r[t])throw new e('Extension Header Parameter "'.concat(t,'" is missing'));if(i.get(t)&&void 0===o[t])throw new e('Extension Header Parameter "'.concat(t,'" MUST be integrity protected'))}return new Set(o.crit)}(Jo,new Map([["b64",!0]]),null==n?void 0:n.crit,o,r);let a=!0;if(i.has("b64")&&(a=o.b64,"boolean"!=typeof a))throw new Jo('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const s=r.alg;if("string"!=typeof s||!s)throw new Jo('JWS "alg" (Algorithm) Header Parameter missing or invalid');const c=n&&function(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError('"'.concat(e,'" option must be an array of strings'));if(t)return new Set(t)}("algorithms",n.algorithms);if(c&&!c.has(s))throw new Lo('"alg" (Algorithm) Header Parameter value not allowed');if(a){if("string"!=typeof e.payload)throw new Jo("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new Jo("JWS Payload must be a string or an Uint8Array instance");let u=!1;"function"==typeof t&&(t=await t(o,e),u=!0),mr(s,t,"verify");const l=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const o=t.reduce((e,t)=>e+t.length,0),r=new Uint8Array(o);let i=0;for(const e of t)r.set(e,i),i+=e.length;return r}(void 0!==e.protected?Eo(e.protected):new Uint8Array,Eo("."),"string"==typeof e.payload?a?Eo(e.payload):So.encode(e.payload):e.payload),h=Yo(e.signature,"signature",Jo),d=await ir(t,s);if(!await $o(s,d,h,l))throw new Fo;let p;p=a?Yo(e.payload,"payload",Jo):"string"==typeof e.payload?So.encode(e.payload):e.payload;const m={payload:p};return void 0!==e.protected&&(m.protectedHeader=o),void 0!==e.header&&(m.unprotectedHeader=e.header),u?f(f({},m),{},{key:d}):m}const $r=86400,ei=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function ti(e){const t=ei.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const n=parseFloat(t[2]);let o;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(60*n);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(3600*n);break;case"day":case"days":case"d":o=Math.round(n*$r);break;case"week":case"weeks":case"w":o=Math.round(604800*n);break;default:o=Math.round(31557600*n);}return "-"===t[1]||"ago"===t[4]?-o:o}const ni=e=>e.includes("/")?e.toLowerCase():"application/".concat(e.toLowerCase());function oi(e,t){let n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{n=JSON.parse(To.decode(t));}catch(e){}if(!Bo(n))throw new Do("JWT Claims Set must be a top-level JSON object");const r=o.typ;if(r&&("string"!=typeof e.typ||ni(e.typ)!==ni(r)))throw new Ko('unexpected "typ" JWT header value',n,"typ","check_failed");const i=o.requiredClaims,a=void 0===i?[]:i,s=o.issuer,c=o.subject,u=o.audience,l=o.maxTokenAge,h=[...a];void 0!==l&&h.push("iat"),void 0!==u&&h.push("aud"),void 0!==c&&h.push("sub"),void 0!==s&&h.push("iss");for(const e of new Set(h.reverse()))if(!(e in n))throw new Ko('missing required "'.concat(e,'" claim'),n,e,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(n.iss))throw new Ko('unexpected "iss" claim value',n,"iss","check_failed");if(c&&n.sub!==c)throw new Ko('unexpected "sub" claim value',n,"sub","check_failed");if(u&&(d=n.aud,p="string"==typeof u?[u]:u,!("string"==typeof d?p.includes(d):Array.isArray(d)&&p.some(Set.prototype.has.bind(new Set(d))))))throw new Ko('unexpected "aud" claim value',n,"aud","check_failed");var d,p;let f;switch(typeof o.clockTolerance){case"string":f=ti(o.clockTolerance);break;case"number":f=o.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const m=o.currentDate,y=(w=m||new Date,Math.floor(w.getTime()/1e3));var w;if((void 0!==n.iat||l)&&"number"!=typeof n.iat)throw new Ko('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new Ko('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>y+f)throw new Ko('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new Ko('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=y-f)throw new Uo('"exp" claim timestamp check failed',n,"exp","check_failed")}if(l){const e=y-n.iat;if(e-f>("number"==typeof l?l:ti(l)))throw new Uo('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(e<0-f)throw new Ko('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}async function ri(e,t,n){var o;const r=await async function(e,t,n){if(e instanceof Uint8Array&&(e=To.decode(e)),"string"!=typeof e)throw new Jo("Compact JWS must be a string or Uint8Array");const o=e.split("."),r=o[0],i=o[1],a=o[2];if(3!==o.length)throw new Jo("Invalid Compact JWS");const s=await Qr({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return "function"==typeof t?f(f({},c),{},{key:s.key}):c}(e,t,n);if(null!==(o=r.protectedHeader.crit)&&void 0!==o&&o.includes("b64")&&!1===r.protectedHeader.b64)throw new Do("JWTs MUST NOT use unencoded payload");const i={payload:oi(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return "function"==typeof t?f(f({},i),{},{key:r.key}):i}function ii(e){return Bo(e)}var ai,si,ci=new WeakMap,ui=new WeakMap;class li{constructor(e){if(u(this,ci,void 0),u(this,ui,new WeakMap),!function(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(ii)}(e))throw new Ho("JSON Web Key Set malformed");l(ci,this,structuredClone(e));}jwks(){return c(ci,this)}async getKey(e,t){const n=f(f({},e),null==t?void 0:t.header),o=n.alg,r=n.kid,i=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return "RSA";case"ES":return "EC";case"Ed":return "OKP";case"ML":return "AKP";default:throw new No('Unsupported "alg" value for a JSON Web Key Set')}}(o),s=c(ci,this).keys.filter(e=>{let t=i===e.kty;if(t&&"string"==typeof r&&(t=r===e.kid),!t||"string"!=typeof e.alg&&"AKP"!==i||(t=o===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(o){case"ES256":t="P-256"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":case"EdDSA":t="Ed25519"===e.crv;}return t}),u=s[0],l=s.length;if(0===l)throw new Mo;if(1!==l){const e=new zo,t=c(ui,this);throw e[Symbol.asyncIterator]=w(function*(){for(const e of s)try{yield yield a(hi(t,e,o));}catch(e){}}),e}return hi(c(ui,this),u,o)}}async function hi(e,t,n){const o=e.get(t)||e.set(t,{}).get(t);if(void 0===o[n]){const e=await async function(e,t,n){var o;if(!Bo(e))throw new TypeError("JWK must be an object");let r;switch(null!=t||(t=e.alg),null!=r||(r=null!==(o=null==n?void 0:n.extractable)&&void 0!==o?o:e.ext),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return Ao(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new No('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return tr(f(f({},e),{},{alg:t,ext:r}));case"AKP":if("string"!=typeof e.alg||!e.alg)throw new TypeError('missing "alg" (Algorithm) Parameter value');if(void 0!==t&&t!==e.alg)throw new TypeError("JWK alg and alg option value mismatch");return tr(f(f({},e),{},{ext:r}));case"EC":case"OKP":return tr(f(f({},e),{},{alg:t,ext:r}));default:throw new No('Unsupported "kty" (Key Type) Parameter value')}}(f(f({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||"public"!==e.type)throw new Ho("JSON Web Key Set members must be public keys");o[n]=e;}return o[n]}function di(e){const t=new li(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}let pi;if("undefined"==typeof navigator||null===(ai=navigator.userAgent)||void 0===ai||null===(si=ai.startsWith)||void 0===si||!si.call(ai,"Mozilla/5.0 ")){const e="v6.2.3";pi="".concat("jose","/").concat(e);}const fi=Symbol();const mi=Symbol();var yi=new WeakMap,wi=new WeakMap,gi=new WeakMap,vi=new WeakMap,bi=new WeakMap,ki=new WeakMap,_i=new WeakMap,Si=new WeakMap,Ti=new WeakMap,Ei=new WeakMap;class Pi{constructor(e,t){if(u(this,yi,void 0),u(this,wi,void 0),u(this,gi,void 0),u(this,vi,void 0),u(this,bi,void 0),u(this,ki,void 0),u(this,_i,void 0),u(this,Si,void 0),u(this,Ti,void 0),u(this,Ei,void 0),!(e instanceof URL))throw new TypeError("url must be an instance of URL");var n,o;l(yi,this,new URL(e.href)),l(wi,this,"number"==typeof(null==t?void 0:t.timeoutDuration)?null==t?void 0:t.timeoutDuration:5e3),l(gi,this,"number"==typeof(null==t?void 0:t.cooldownDuration)?null==t?void 0:t.cooldownDuration:3e4),l(vi,this,"number"==typeof(null==t?void 0:t.cacheMaxAge)?null==t?void 0:t.cacheMaxAge:6e5),l(_i,this,new Headers(null==t?void 0:t.headers)),pi&&!c(_i,this).has("User-Agent")&&c(_i,this).set("User-Agent",pi),c(_i,this).has("accept")||(c(_i,this).set("accept","application/json"),c(_i,this).append("accept","application/jwk-set+json")),l(Si,this,null==t?void 0:t[fi]),void 0!==(null==t?void 0:t[mi])&&(l(Ei,this,null==t?void 0:t[mi]),n=null==t?void 0:t[mi],o=c(vi,this),"object"==typeof n&&null!==n&&"uat"in n&&"number"==typeof n.uat&&!(Date.now()-n.uat>=o)&&"jwks"in n&&Bo(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,Bo)&&(l(bi,this,c(Ei,this).uat),l(Ti,this,di(c(Ei,this).jwks))));}pendingFetch(){return !!c(ki,this)}coolingDown(){return "number"==typeof c(bi,this)&&Date.now()<c(bi,this)+c(gi,this)}fresh(){return "number"==typeof c(bi,this)&&Date.now()<c(bi,this)+c(vi,this)}jwks(){var e;return null===(e=c(Ti,this))||void 0===e?void 0:e.jwks()}async getKey(e,t){c(Ti,this)&&this.fresh()||await this.reload();try{return await c(Ti,this).call(this,e,t)}catch(n){if(n instanceof Mo&&!1===this.coolingDown())return await this.reload(),c(Ti,this).call(this,e,t);throw n}}async reload(){c(ki,this)&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&l(ki,this,void 0),c(ki,this)||l(ki,this,async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fetch;const r=await o(e,{method:"GET",signal:n,redirect:"manual",headers:t}).catch(e=>{if("TimeoutError"===e.name)throw new Zo;throw e});if(200!==r.status)throw new Wo("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await r.json()}catch(e){throw new Wo("Failed to parse the JSON Web Key Set HTTP response as JSON")}}(c(yi,this).href,c(_i,this),AbortSignal.timeout(c(wi,this)),c(Si,this)).then(e=>{l(Ti,this,di(e)),c(Ei,this)&&(c(Ei,this).uat=Date.now(),c(Ei,this).jwks=e),l(bi,this,Date.now()),l(ki,this,void 0);}).catch(e=>{throw l(ki,this,void 0),e})),await c(ki,this);}}const Ai=["mfaToken"],Ri=["mfaToken"];var Ii,xi,Ci,Oi,ji,Wi,Ki,Ui,Li,Ni,Ji,Di,Hi,Mi,zi,Zi,Fi,Xi,Vi,Gi,Yi,Bi,qi;function Qi(e){var t,n;if("object"!=typeof e||null===e)return {error:"unknown_error",error_description:String(e)};const o=e,r={error:null!==(t=o.error)&&void 0!==t?t:"",error_description:null!==(n=o.error_description)&&void 0!==n?n:"",message:o.message};if("mfa_required"===o.error&&o.cause){r.mfa_token="string"==typeof o.cause.mfa_token?o.cause.mfa_token:void 0;const e=o.cause.mfa_requirements;"object"==typeof e&&null!==e&&(r.mfa_requirements=e);}return r}var $i=class extends Error{constructor(e,t){super(t),d(this,"code",void 0),this.name="NotSupportedError",this.code=e;}},ea=class extends Error{constructor(e,t,n){super(t),d(this,"cause",void 0),d(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements};}},ta=class extends ea{constructor(e,t){super("token_by_code_error",e,t),this.name="TokenByCodeError";}},na=class extends ea{constructor(e,t){super("token_by_client_credentials_error",e,t),this.name="TokenByClientCredentialsError";}},oa=class extends ea{constructor(e,t){super("token_by_refresh_token_error",e,t),this.name="TokenByRefreshTokenError";}},ra=class extends ea{constructor(e,t){super("token_by_password_error",e,t),this.name="TokenByPasswordError";}},ia=class extends ea{constructor(e,t){super("token_for_connection_error",e,t),this.name="TokenForConnectionErrorCode";}},aa=class extends ea{constructor(e,t){super("token_exchange_error",e,t),this.name="TokenExchangeError";}},sa=class extends Error{constructor(e){super(e),d(this,"code","verify_logout_token_error"),this.name="VerifyLogoutTokenError";}},ca=class extends ea{constructor(e){super("backchannel_authentication_error","There was an error when trying to use Client-Initiated Backchannel Authentication.",e),d(this,"code","backchannel_authentication_error"),this.name="BackchannelAuthenticationError";}},ua=class extends ea{constructor(e){super("build_authorization_url_error","There was an error when trying to build the authorization URL.",e),this.name="BuildAuthorizationUrlError";}},la=class extends ea{constructor(e){super("build_link_user_url_error","There was an error when trying to build the Link User URL.",e),this.name="BuildLinkUserUrlError";}},ha=class extends ea{constructor(e){super("build_unlink_user_url_error","There was an error when trying to build the Unlink User URL.",e),this.name="BuildUnlinkUserUrlError";}},da=class extends Error{constructor(){super("The client secret or client assertion signing key must be provided."),d(this,"code","missing_client_auth_error"),this.name="MissingClientAuthError";}};function pa(e){return Object.entries(e).filter(e=>void 0!==y(e,2)[1]).reduce((e,t)=>f(f({},e),{},{[t[0]]:t[1]}),{})}var fa=class extends Error{constructor(e,t,n){super(t),d(this,"cause",void 0),d(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};}},ma=class extends fa{constructor(e,t){super("mfa_list_authenticators_error",e,t),this.name="MfaListAuthenticatorsError";}},ya=class extends fa{constructor(e,t){super("mfa_enrollment_error",e,t),this.name="MfaEnrollmentError";}},wa=class extends fa{constructor(e,t){super("mfa_delete_authenticator_error",e,t),this.name="MfaDeleteAuthenticatorError";}},ga=class extends fa{constructor(e,t){super("mfa_challenge_error",e,t),this.name="MfaChallengeError";}},va=class extends fa{constructor(e,t){super("mfa_verify_error",e,t),this.name="MfaVerifyError";}};function ba(e){return {id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var ka=class e{constructor(e,t,n,o,r,i,a){d(this,"accessToken",void 0),d(this,"idToken",void 0),d(this,"refreshToken",void 0),d(this,"expiresAt",void 0),d(this,"scope",void 0),d(this,"claims",void 0),d(this,"authorizationDetails",void 0),d(this,"tokenType",void 0),d(this,"issuedTokenType",void 0),d(this,"recoveryCode",void 0),d(this,"act",void 0),this.accessToken=e,this.idToken=n,this.refreshToken=o,this.expiresAt=t,this.scope=r,this.claims=i,this.authorizationDetails=a;}static fromTokenEndpointResponse(t){const n=t.id_token?t.claims():void 0,o=new e(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return o.tokenType=t.token_type,o.issuedTokenType=t.issued_token_type,o}},_a={otp:"http://auth0.com/oauth/grant-type/mfa-otp",oob:"http://auth0.com/oauth/grant-type/mfa-oob","recovery-code":"http://auth0.com/oauth/grant-type/mfa-recovery-code"},Sa=(Ii=new WeakMap,xi=new WeakMap,Ci=new WeakMap,Oi=new WeakMap,ji=new WeakMap,class{constructor(e){var t;u(this,Ii,void 0),u(this,xi,void 0),u(this,Ci,void 0),u(this,Oi,void 0),u(this,ji,void 0),l(Ii,this,"https://".concat(e.domain)),l(xi,this,e.clientId),l(Ci,this,e.clientSecret),l(Oi,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(ji,this,e.getConfiguration);}async listAuthenticators(e){const t="".concat(c(Ii,this),"/mfa/authenticators"),n=e.mfaToken,o=await c(Oi,this).call(this,t,{method:"GET",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!o.ok){let e;try{e=await o.json();}catch(e){throw new ma("Failed to list authenticators")}throw new ma(e.error_description||"Failed to list authenticators",e)}return (await o.json()).map(ba)}async enrollAuthenticator(e){const t="".concat(c(Ii,this),"/mfa/associate"),n=e.mfaToken,o=m(e,Ai),r={authenticator_types:o.authenticatorTypes};"oobChannels"in o&&(r.oob_channels=o.oobChannels),"phoneNumber"in o&&o.phoneNumber&&(r.phone_number=o.phoneNumber),"email"in o&&o.email&&(r.email=o.email);const i=await c(Oi,this).call(this,t,{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let e;try{e=await i.json();}catch(e){throw new ya("Failed to enroll authenticator")}throw new ya(e.error_description||"Failed to enroll authenticator",e)}return function(e){if("otp"===e.authenticator_type)return {authenticatorType:"otp",secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if("oob"===e.authenticator_type)return {authenticatorType:"oob",oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes};throw new Error("Unexpected authenticator type: ".concat(e.authenticator_type))}(await i.json())}async deleteAuthenticator(e){const t=e.authenticatorId,n=e.mfaToken,o="".concat(c(Ii,this),"/mfa/authenticators/").concat(encodeURIComponent(t)),r=await c(Oi,this).call(this,o,{method:"DELETE",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!r.ok){let e;try{e=await r.json();}catch(e){throw new wa("Failed to delete authenticator")}throw new wa(e.error_description||"Failed to delete authenticator",e)}}async challengeAuthenticator(e){const t="".concat(c(Ii,this),"/mfa/challenge"),n=e.mfaToken,o=m(e,Ri),r={mfa_token:n,client_id:c(xi,this),challenge_type:o.challengeType};c(Ci,this)&&(r.client_secret=c(Ci,this)),o.authenticatorId&&(r.authenticator_id=o.authenticatorId);const i=await c(Oi,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let e;try{e=await i.json();}catch(e){throw new ga("Failed to challenge authenticator")}throw new ga(e.error_description||"Failed to challenge authenticator",e)}return function(e){const t={challengeType:e.challenge_type};return void 0!==e.oob_code&&(t.oobCode=e.oob_code),void 0!==e.binding_method&&(t.bindingMethod=e.binding_method),t}(await i.json())}async verify(e){if(!c(ji,this))throw new Error("MFA verify requires a configuration provider (getConfiguration was not set)");const t=await c(ji,this).call(this),n={mfa_token:e.mfaToken};e.audience&&(n.audience=e.audience),"otp"===e.factorType?n.otp=e.otp:"oob"===e.factorType?(n.oob_code=e.oobCode,e.bindingCode&&(n.binding_code=e.bindingCode)):"recovery-code"===e.factorType&&(n.recovery_code=e.recoveryCode);try{const o=await qr(t,_a[e.factorType],n),r=ka.fromTokenEndpointResponse(o);return o.recovery_code&&(r.recoveryCode=o.recovery_code),r}catch(e){var o,r,i;if(e instanceof va)throw e;const t=e;throw new va(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!==(o=t.error)&&void 0!==o?o:"mfa_verify_error",error_description:null!==(r=null!==(i=t.error_description)&&void 0!==i?i:t.message)&&void 0!==r?r:"Failed to verify MFA challenge"})}}}),Ta=class extends Error{constructor(e,t,n){super(t),d(this,"cause",void 0),d(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};}},Ea=class extends Ta{constructor(e,t){super("passkey_register_error",e,t),this.name="PasskeyRegisterError";}},Pa=class extends Ta{constructor(e,t){super("passkey_challenge_error",e,t),this.name="PasskeyChallengeError";}},Aa=class extends Ta{constructor(e,t){super("passkey_get_token_error",e,t),this.name="PasskeyGetTokenError",this.cause=t&&{error:t.error,error_description:t.error_description,message:t.message,mfa_token:t.mfa_token,mfa_requirements:t.mfa_requirements};}};var Ra="urn:okta:params:oauth:grant-type:webauthn",Ia=(Wi=new WeakMap,Ki=new WeakMap,Ui=new WeakMap,Li=new WeakMap,Ni=new WeakSet,class{constructor(e){var t;h(this,Ni),u(this,Wi,void 0),u(this,Ki,void 0),u(this,Ui,void 0),u(this,Li,void 0),l(Wi,this,"https://".concat(e.domain)),l(Ki,this,e.clientId),l(Ui,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),l(Li,this,e.grantRequest);}async register(e){const t="".concat(c(Wi,this),"/passkey/register"),n=f(f(f(f(f(f(f(f({},e.email&&{email:e.email}),e.name&&{name:e.name}),e.phoneNumber&&{phone_number:e.phoneNumber}),e.username&&{username:e.username}),e.givenName&&{given_name:e.givenName}),e.familyName&&{family_name:e.familyName}),e.nickname&&{nickname:e.nickname}),e.picture&&{picture:e.picture}),o={client_id:c(Ki,this),user_profile:n};e.realm&&(o.realm=e.realm),e.organization&&(o.organization=e.organization),e.userMetadata&&(o.user_metadata=e.userMetadata);const r=await c(Ui,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){const e=await i(Ni,this,xa).call(this,r);throw new Ea(e.error_description||"Failed to request signup challenge",e)}const a=await r.json();return {authSession:(s=a).auth_session,authnParamsPublicKey:f({},s.authn_params_public_key)};var s;}async challenge(e){const t="".concat(c(Wi,this),"/passkey/challenge"),n={client_id:c(Ki,this)};null!=e&&e.realm&&(n.realm=e.realm),null!=e&&e.organization&&(n.organization=e.organization);const o=await c(Ui,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const e=await i(Ni,this,xa).call(this,o);throw new Pa(e.error_description||"Failed to request login challenge",e)}const r=await o.json();return {authSession:(a=r).auth_session,authnParamsPublicKey:f({},a.authn_params_public_key)};var a;}async getTokenByPasskey(e){const t=new URLSearchParams({auth_session:e.authSession,authn_response:JSON.stringify(e.credential)});e.realm&&t.append("realm",e.realm),e.scope&&t.append("scope",e.scope),e.audience&&t.append("audience",e.audience),e.organization&&t.append("organization",e.organization);try{return await c(Li,this).call(this,Ra,t)}catch(e){const t=Qi(e);throw new Aa(t.error_description||"Failed to exchange passkey credential for tokens.",t)}}});async function xa(e){try{return await e.json()}catch(t){return {error:"unknown_error",error_description:"HTTP ".concat(e.status," ").concat(e.statusText)}}}var Ca=(Ji=new WeakMap,Di=new WeakMap,Hi=new WeakMap,class{constructor(e,t){u(this,Ji,new Map),u(this,Di,void 0),u(this,Hi,void 0),l(Hi,this,Math.max(1,Math.floor(e))),l(Di,this,Math.max(0,Math.floor(t)));}get(e){const t=c(Ji,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return c(Ji,this).delete(e),c(Ji,this).set(e,t),t.value;c(Ji,this).delete(e);}}set(e,t){for(c(Ji,this).has(e)&&c(Ji,this).delete(e),c(Ji,this).set(e,{value:t,expiresAt:Date.now()+c(Di,this)});c(Ji,this).size>c(Hi,this);){const e=c(Ji,this).keys().next().value;if(void 0===e)break;c(Ji,this).delete(e);}}}),Oa=new Map;function ja(e){return {ttlMs:1e3*("number"==typeof(null==e?void 0:e.ttl)?e.ttl:600),maxEntries:"number"==typeof(null==e?void 0:e.maxEntries)&&e.maxEntries>0?e.maxEntries:100}}var Wa=class{static createDiscoveryCache(e){const t=(n=e.maxEntries,o=e.ttlMs,"".concat(n,":").concat(o));var n,o;let r=(i=t,Oa.get(i));var i;return r||(r=new Ca(e.maxEntries,e.ttlMs),Oa.set(t,r)),r}static createJwksCache(){return {}}},Ka="openid profile email offline_access",Ua=Object.freeze(new Set(["grant_type","client_id","client_secret","client_assertion","client_assertion_type","subject_token","subject_token_type","requested_token_type","actor_token","actor_token_type","audience","aud","resource","resources","resource_indicator","scope","connection","login_hint","organization","assertion"]));function La(e){if(null==e)throw new aa("subject_token is required");if("string"!=typeof e)throw new aa("subject_token must be a string");if(0===e.trim().length)throw new aa("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new aa("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new aa("subject_token must not include the 'Bearer ' prefix")}function Na(e,t){if(t)for(const o of Object.entries(t)){var n=y(o,2);const t=n[0],r=n[1];if(!Ua.has(t))if(Array.isArray(r)){if(r.length>20)throw new aa("Parameter '".concat(t,"' exceeds maximum array size of ").concat(20));r.forEach(n=>{e.append(t,n);});}else e.append(t,r);}}var Ja="urn:ietf:params:oauth:token-type:access_token";var Da=(Mi=new WeakMap,zi=new WeakMap,Zi=new WeakMap,Fi=new WeakMap,Xi=new WeakMap,Vi=new WeakMap,Gi=new WeakMap,Yi=new WeakMap,Bi=new WeakMap,qi=new WeakSet,class{constructor(e){var t,n,o,r;if(h(this,qi),u(this,Mi,void 0),u(this,zi,void 0),u(this,Zi,void 0),u(this,Fi,void 0),u(this,Xi,void 0),u(this,Vi,void 0),u(this,Gi,void 0),u(this,Yi,void 0),u(this,Bi,void 0),d(this,"mfa",void 0),d(this,"passkey",void 0),l(Fi,this,e),e.useMtls&&!e.customFetch)throw new $i("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");l(Xi,this,function(e,t){if(!1===t.enabled)return e;const n={name:t.name,version:t.version},o=btoa(JSON.stringify(n));return async(t,n)=>{const r=t instanceof Request?new Headers(t.headers):new Headers;return null!=n&&n.headers&&new Headers(n.headers).forEach((e,t)=>{r.set(t,e);}),r.set("Auth0-Client",o),e(t,f(f({},n),{},{headers:r}))}}(null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)},!1===(null==(n=e.telemetry)?void 0:n.enabled)?n:{enabled:!0,name:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:"@auth0/auth0-auth-js",version:null!==(r=null==n?void 0:n.version)&&void 0!==r?r:"1.9.1"}));const a=ja(e.discoveryCache);l(Gi,this,Wa.createDiscoveryCache(a)),l(Yi,this,new Map),l(Bi,this,Wa.createJwksCache()),this.mfa=new Sa({domain:c(Fi,this).domain,clientId:c(Fi,this).clientId,clientSecret:c(Fi,this).clientSecret,customFetch:c(Xi,this),getConfiguration:async()=>(await i(qi,this,za).call(this)).configuration}),this.passkey=new Ia({domain:c(Fi,this).domain,clientId:c(Fi,this).clientId,customFetch:c(Xi,this),grantRequest:async(e,t)=>{const n=(await i(qi,this,za).call(this)).serverMetadata,o=await i(qi,this,Ma).call(this,n);o[Tr]=function(e,t){return (n,o)=>{const r=null==o?void 0:o.body;if(t!==Ra||!(r instanceof URLSearchParams))return e(n,o);const i={};for(const e of r){var a=y(e,2);const t=a[0],n=a[1];i[t]="authn_response"===t?JSON.parse(n):n;}const s=new Headers(null==o?void 0:o.headers);return s.set("Content-Type","application/json"),e(n,f(f({},o),{},{headers:s,body:JSON.stringify(i)}))}}(c(Xi,this),e);const r=await qr(o,e,t);return ka.fromTokenEndpointResponse(r)}});}async getServerMetadata(){return (await i(qi,this,za).call(this)).serverMetadata}async buildAuthorizationUrl(e){const t=(await i(qi,this,za).call(this)).serverMetadata;if(null!=e&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new $i("par_not_supported_error","The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par");try{return await i(qi,this,Va).call(this,e)}catch(e){throw new ua(e)}}async buildLinkUserUrl(e){try{const t=await i(qi,this,Va).call(this,{authorizationParams:f(f({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:"openid link_account offline_access",id_token_hint:e.idToken})});return {linkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new la(e)}}async buildUnlinkUserUrl(e){try{const t=await i(qi,this,Va).call(this,{authorizationParams:f(f({},e.authorizationParams),{},{requested_connection:e.connection,scope:"openid unlink_account",id_token_hint:e.idToken})});return {unlinkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new ha(e)}}async backchannelAuthentication(e){const t=await i(qi,this,za).call(this),n=t.configuration,o=t.serverMetadata,r=pa(f(f({},c(Fi,this).authorizationParams),null==e?void 0:e.authorizationParams)),a=new URLSearchParams(f(f({scope:Ka},r),{},{client_id:c(Fi,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:o.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&a.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&a.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const e=await Jr(n,a),t=await Dr(n,e);return ka.fromTokenEndpointResponse(t)}catch(e){throw new ca(e)}}async initiateBackchannelAuthentication(e){const t=await i(qi,this,za).call(this),n=t.configuration,o=t.serverMetadata,r=pa(f(f({},c(Fi,this).authorizationParams),null==e?void 0:e.authorizationParams)),a=new URLSearchParams(f(f({scope:Ka},r),{},{client_id:c(Fi,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:o.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&a.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&a.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const e=await Jr(n,a);return {authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new ca(e)}}async backchannelAuthenticationGrant(e){let t=e.authReqId;const n=(await i(qi,this,za).call(this)).configuration,o=new URLSearchParams({auth_req_id:t});try{const e=await qr(n,"urn:openid:params:grant-type:ciba",o);return ka.fromTokenEndpointResponse(e)}catch(e){throw new ca(e)}}async getTokenForConnection(e){var t;if(e.refreshToken&&e.accessToken)throw new ia("Either a refresh or access token should be specified, but not both.");const n=null!==(t=e.accessToken)&&void 0!==t?t:e.refreshToken;if(!n)throw new ia("Either a refresh or access token must be specified.");try{return await this.exchangeToken({connection:e.connection,subjectToken:n,subjectTokenType:e.accessToken?Ja:"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint})}catch(e){if(e instanceof aa)throw new ia(e.message,e.cause);throw e}}async exchangeToken(e){return "connection"in e?i(qi,this,Za).call(this,e):i(qi,this,Fa).call(this,e)}async getTokenByCode(e,t){const n=(await i(qi,this,za).call(this)).configuration;try{const o=await Mr(n,e,{pkceCodeVerifier:t.codeVerifier});return ka.fromTokenEndpointResponse(o)}catch(e){throw new ta("There was an error while trying to request a token.",Qi(e))}}async getTokenByRefreshToken(e){const t=(await i(qi,this,za).call(this)).configuration,n=new URLSearchParams;e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope);try{const o=await zr(t,e.refreshToken,n);return ka.fromTokenEndpointResponse(o)}catch(e){throw new oa("The access token has expired and there was an error while trying to refresh it.",Qi(e))}}async getTokenByPassword(e){const t=(await i(qi,this,za).call(this)).configuration,n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.realm&&n.append("realm",e.realm);let o=t;if(e.auth0ForwardedFor){const n=await i(qi,this,Xa).call(this);o=new Kr(t.serverMetadata(),c(Fi,this).clientId,c(Fi,this).clientSecret,n),o[Tr]=(t,n)=>c(Xi,this).call(this,t,f(f({},n),{},{headers:f(f({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}));}try{const e=await qr(o,"password",n);return ka.fromTokenEndpointResponse(e)}catch(e){throw new ra("There was an error while trying to request a token.",Qi(e))}}async getTokenByClientCredentials(e){const t=(await i(qi,this,za).call(this)).configuration;try{const n=new URLSearchParams({audience:e.audience});e.organization&&n.append("organization",e.organization);const o=await Zr(t,n);return ka.fromTokenEndpointResponse(o)}catch(e){throw new na("There was an error while trying to request a token.",Qi(e))}}async buildLogoutUrl(e){const t=await i(qi,this,za).call(this),n=t.configuration;if(!t.serverMetadata.end_session_endpoint){const t=new URL("https://".concat(c(Fi,this).domain,"/v2/logout"));return t.searchParams.set("returnTo",e.returnTo),t.searchParams.set("client_id",c(Fi,this).clientId),t}return function(e,t){Vr(e);const n=br(e),o=n.as,r=n.c,i=bn(o,"end_session_endpoint",!1,n.tlsOnly);(t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id);for(const e of t.entries()){var a=y(e,2);const t=a[0],n=a[1];i.searchParams.append(t,n);}return i}(n,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){const t=(await i(qi,this,za).call(this)).serverMetadata,n=ja(c(Fi,this).discoveryCache),o=t.jwks_uri;c(Vi,this)||l(Vi,this,function(e,t){const n=new Pi(e,t),o=async(e,t)=>n.getKey(e,t);return Object.defineProperties(o,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),o}(new URL(o),{cacheMaxAge:n.ttlMs,[fi]:c(Xi,this),[mi]:c(Bi,this)}));const r=(await ri(e.logoutToken,c(Vi,this),{issuer:t.issuer,audience:c(Fi,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]})).payload;if(!("sid"in r)&&!("sub"in r))throw new sa('either "sid" or "sub" (or both) claims must be present');if("sid"in r&&"string"!=typeof r.sid)throw new sa('"sid" claim must be a string');if("sub"in r&&"string"!=typeof r.sub)throw new sa('"sub" claim must be a string');if("nonce"in r)throw new sa('"nonce" claim is prohibited');if(!("events"in r))throw new sa('"events" claim is missing');if("object"!=typeof r.events||null===r.events)throw new sa('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in r.events))throw new sa('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if("object"!=typeof r.events["http://schemas.openid.net/event/backchannel-logout"])throw new sa('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return {sid:r.sid,sub:r.sub}}});function Ha(){const e=c(Fi,this).domain.toLowerCase();return "".concat(e,"|mtls:").concat(c(Fi,this).useMtls?"1":"0")}async function Ma(e){const t=await i(qi,this,Xa).call(this),n=new Kr(e,c(Fi,this).clientId,c(Fi,this).clientSecret,t);return n[Tr]=c(Xi,this),n}async function za(){if(c(Mi,this)&&c(zi,this))return {configuration:c(Mi,this),serverMetadata:c(zi,this)};const e=i(qi,this,Ha).call(this),t=c(Gi,this).get(e);if(t)return l(zi,this,t.serverMetadata),l(Mi,this,await i(qi,this,Ma).call(this,t.serverMetadata)),{configuration:c(Mi,this),serverMetadata:c(zi,this)};const n=c(Yi,this).get(e);if(n){const e=await n;return l(zi,this,e.serverMetadata),l(Mi,this,await i(qi,this,Ma).call(this,e.serverMetadata)),{configuration:c(Mi,this),serverMetadata:c(zi,this)}}const o=(async()=>{const t=await i(qi,this,Xa).call(this),n=await jr(new URL("https://".concat(c(Fi,this).domain)),c(Fi,this).clientId,{use_mtls_endpoint_aliases:c(Fi,this).useMtls},t,{[Tr]:c(Xi,this)}),o=n.serverMetadata();return c(Gi,this).set(e,{serverMetadata:o}),{configuration:n,serverMetadata:o}})(),r=o.then(e=>({serverMetadata:e.serverMetadata}));r.catch(()=>{}),c(Yi,this).set(e,r);try{const e=await o,t=e.configuration,n=e.serverMetadata;l(Mi,this,t),l(zi,this,n),c(Mi,this)[Tr]=c(Xi,this);}finally{c(Yi,this).delete(e);}return {configuration:c(Mi,this),serverMetadata:c(zi,this)}}async function Za(e){var t,n;const o=(await i(qi,this,za).call(this)).configuration;if("audience"in e||"resource"in e)throw new aa("audience and resource parameters are not supported for Token Vault exchanges");La(e.subjectToken);const r=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:null!==(t=e.subjectTokenType)&&void 0!==t?t:Ja,requested_token_type:null!==(n=e.requestedTokenType)&&void 0!==n?n:"http://auth0.com/oauth/token-type/federated-connection-access-token"});e.loginHint&&r.append("login_hint",e.loginHint),e.scope&&r.append("scope",e.scope),Na(r,e.extra);try{const e=await qr(o,"urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",r);return ka.fromTokenEndpointResponse(e)}catch(t){throw new aa("Failed to exchange token for connection '".concat(e.connection,"'."),Qi(t))}}async function Fa(e){const t=(await i(qi,this,za).call(this)).configuration;if(La(e.subjectToken),void 0!==e.actorToken&&void 0===e.actorTokenType)throw new aa("actorTokenType is required when actorToken is provided");const n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.requestedTokenType&&n.append("requested_token_type",e.requestedTokenType),e.organization&&n.append("organization",e.organization),e.actorToken&&n.append("actor_token",e.actorToken),e.actorTokenType&&n.append("actor_token_type",e.actorTokenType),Na(n,e.extra);try{const r=await qr(t,"urn:ietf:params:oauth:grant-type:token-exchange",n),i=ka.fromTokenEndpointResponse(r);var o;if(e.actorToken)if(null!==(o=i.claims)&&void 0!==o&&o.act)i.act=i.claims.act;else try{i.act=function(e){if("string"!=typeof e)throw new Do("JWTs must use Compact JWS serialization, JWT must be a string");const t=e.split("."),n=t[1],o=t.length;if(5===o)throw new Do("Only JWTs using Compact JWS serialization can be decoded");if(3!==o)throw new Do("Invalid JWT");if(!n)throw new Do("JWTs must contain a payload");let r,i;try{r=Ao(n);}catch(e){throw new Do("Failed to base64url decode the payload")}try{i=JSON.parse(To.decode(r));}catch(e){throw new Do("Failed to parse the decoded payload as JSON")}if(!Bo(i))throw new Do("Invalid JWT Claims Set");return i}(r.access_token).act;}catch(e){}return i}catch(t){throw new aa("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),Qi(t))}}async function Xa(){return c(Zi,this)||l(Zi,this,(async()=>{if(!c(Fi,this).clientSecret&&!c(Fi,this).clientAssertionSigningKey&&!c(Fi,this).useMtls)throw new da;if(c(Fi,this).useMtls)return (e,t,n,o)=>{n.set("client_id",t.client_id);};let e=c(Fi,this).clientAssertionSigningKey;return !e||e instanceof CryptoKey||(e=await async function(e,t,n){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return dr(e,t,n)}(e,c(Fi,this).clientAssertionSigningAlg||"RS256")),e?function(e,t){return yn(e,t)}(e):Sr(c(Fi,this).clientSecret)})().catch(e=>{throw l(Zi,this,void 0),e})),c(Zi,this)}async function Va(e){const t=(await i(qi,this,za).call(this)).configuration,n=Ir(),o=await Rr(n),r=pa(f(f({},c(Fi,this).authorizationParams),null==e?void 0:e.authorizationParams)),a=new URLSearchParams(f(f({scope:Ka},r),{},{client_id:c(Fi,this).clientId,code_challenge:o,code_challenge_method:"S256"}));return {authorizationUrl:null!=e&&e.pushedAuthorizationRequests?await Xr(t,a):await Fr(t,a),codeVerifier:n}}class Ga extends E{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ga.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new Ga(t,n)}}class Ya extends Ga{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ya.prototype);}}class Ba extends Ga{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ba.prototype);}}class qa extends Ga{constructor(e,t){super(e,t),Object.setPrototypeOf(this,qa.prototype);}}class Qa extends Ga{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Qa.prototype);}}class $a extends Ga{constructor(e,t){super(e,t),Object.setPrototypeOf(this,$a.prototype);}}class es{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e5;this.contexts=new Map,this.ttlMs=e;}set(e,t){this.cleanup(),this.contexts.set(e,Object.assign(Object.assign({},t),{createdAt:Date.now()}));}get(e){const t=this.contexts.get(e);if(t){if(!(Date.now()-t.createdAt>this.ttlMs))return t;this.contexts.delete(e);}}remove(e){this.contexts.delete(e);}cleanup(){const e=Date.now();for(const n of this.contexts){var t=y(n,2);const o=t[0];e-t[1].createdAt>this.ttlMs&&this.contexts.delete(o);}}get size(){return this.contexts.size}}class ts{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new es;}setMFAAuthDetails(e,t,n,o){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:o});}async getAuthenticators(e){var t,n,o;const r=this.contextManager.get(e);if(!r)throw new Ya("invalid_request","MFA context not found for this MFA token");const i=null===(n=null===(t=r.mfaRequirements)||void 0===t?void 0:t.challenge)||void 0===n?void 0:n.map(e=>e.type);try{const t=await this.authJsMfaClient.listAuthenticators({mfaToken:e});return i&&0!==i.length?t.filter(e=>!!e.type&&i.includes(e.type)):t}catch(e){if(e instanceof ma)throw new Ya(null===(o=e.cause)||void 0===o?void 0:o.error,e.message);throw e}}async enroll(e){var t;const n=function(e){const t=Pt[e.factorType];return Object.assign(Object.assign(Object.assign({mfaToken:e.mfaToken,authenticatorTypes:t.authenticatorTypes},t.oobChannels&&{oobChannels:t.oobChannels}),"phoneNumber"in e&&{phoneNumber:e.phoneNumber}),"email"in e&&{email:e.email})}(e);try{return await this.authJsMfaClient.enrollAuthenticator(n)}catch(e){if(e instanceof ya)throw new Ba(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async challenge(e){var t;try{const t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){if(e instanceof ga)throw new qa(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async getEnrollmentFactors(e){const t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new $a("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");return t.mfaRequirements.enroll&&0!==t.mfaRequirements.enroll.length?t.mfaRequirements.enroll:[]}async verify(e){const t=this.contextManager.get(e.mfaToken);if(!t)throw new Qa("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");const n=function(e){return "otp"in e&&e.otp?At:"oobCode"in e&&e.oobCode?Rt:"recoveryCode"in e&&e.recoveryCode?It:void 0}(e);if(!n)throw new Qa("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");const o=t.scope,r=t.audience;try{const t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:o,audience:r,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof Qa)throw new Qa(e.error,e.error_description);throw e}}}class ns extends Error{constructor(e,t,n){super(t),this.name="PasskeyError",this.code=e,this.cause=n,Object.setPrototypeOf(this,ns.prototype);}}var os,rs;class is{constructor(e,t){os.set(this,void 0),rs.set(this,void 0),n(this,os,e,"f"),n(this,rs,t,"f");}async signup(n){if(!window.PublicKeyCredential)throw new ns("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n.scope,r=n.audience,i=e(n,["scope","audience"]),a=await t(this,os,"f").register(i),s=(c=a.authnParamsPublicKey,Object.assign(Object.assign({},c),{challenge:ss(c.challenge),user:Object.assign(Object.assign({},c.user),{id:ss(c.user.id)}),pubKeyCredParams:c.pubKeyCredParams,authenticatorSelection:c.authenticatorSelection}));var c;const u=await navigator.credentials.create({publicKey:s});if(!u)throw new ns("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");const l=function(e){var t;const n=e.response;return {id:e.id,rawId:as(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:as(n.clientDataJSON),attestationObject:as(n.attestationObject)},clientExtensionResults:e.getClientExtensionResults()}}(u);return t(this,rs,"f")._requestTokenForPasskey({authSession:a.authSession,credential:l,realm:i.realm,organization:i.organization,scope:o,audience:r})}async login(n){if(!window.PublicKeyCredential)throw new ns("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n||{},r=o.scope,i=o.audience,a=e(o,["scope","audience"]),s=await t(this,os,"f").challenge(Object.keys(a).length>0?a:void 0),c=(u=s.authnParamsPublicKey,Object.assign(Object.assign({},u),{challenge:ss(u.challenge)}));var u;const l=await navigator.credentials.get({publicKey:c});if(!l)throw new ns("passkey_cancelled","Passkey authentication was cancelled or no credential was returned.");const h=function(e){var t;const n=e.response;return {id:e.id,rawId:as(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:as(n.clientDataJSON),authenticatorData:as(n.authenticatorData),signature:as(n.signature),userHandle:n.userHandle?as(n.userHandle):void 0},clientExtensionResults:e.getClientExtensionResults()}}(l);return t(this,rs,"f")._requestTokenForPasskey({authSession:s.authSession,credential:h,realm:a.realm,organization:a.organization,scope:r,audience:i})}}function as(e){const t=new Uint8Array(e),n=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ss(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),o=atob(n),r=new Uint8Array(o.length);for(let e=0;e<o.length;e++)r[e]=o.charCodeAt(e);return r.buffer}os=new WeakMap,rs=new WeakMap;class cs{constructor(e){let t,n;if(this.userCache=(new De).enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),"undefined"!=typeof window&&(()=>{if(!L())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===L().subtle)throw new Error("\n 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.\n ")})(),this.lockManager=(ue||(ue=ce()),ue),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)n=e.cache;else {if(t=e.cacheLocation||k,!yt(t))throw new Error('Invalid cache location "'.concat(t,'"'));n=yt(t)();}var o;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:b,this.cookieStorage=!1===e.legacySameSiteCookie?et:nt,this.orgHintCookieName=(o=this.options.clientId,"auth0.".concat(o,".organization_hint")),this.isAuthenticatedCookieName=(e=>"auth0.".concat(e,".is.authenticated"))(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const r=e.useCookiesForTransactions?this.cookieStorage:ot;var i;this.scope=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];if("object"!=typeof e)return {[T]:We(t,e,...o)};let i={[T]:We(t,...o)};return Object.keys(e).forEach(n=>{const r=e[n];i[n]=We(t,r,...o);}),i}(this.options.authorizationParams.scope,"openid",this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Me(r,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||S,this.cacheManager=new He(n,n.allKeys?void 0:new pt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new kt(this.options.clientId):void 0,this.domainUrl=(i=this.options.domain,/^https?:\/\//.test(i)?i:"https://".concat(i)),this.tokenIssuer=((e,t)=>e?e.startsWith("https://")?e:"https://".concat(e,"/"):"".concat(t,"/"))(this.options.issuer,this.domainUrl);const a="".concat(this.domainUrl,"/me/"),s=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:a},detailedResponse:!0})}}));this.myAccount=new Tt(s,a),this.authJsClient=new Da({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new ts(this.authJsClient.mfa,this),this.passkey=new is(this.authJsClient.passkey,this),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&t===k&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ht,this.worker.postMessage({type:"init",allowedBaseUrl:this.domainUrl}));}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){const t=this.options.auth0Client||_,n=H(t,!0),o=encodeURIComponent(btoa(JSON.stringify(n)));return "".concat(this.domainUrl).concat(e,"&auth0Client=").concat(o)}_authorizeUrl(e){return this._url("/authorize?".concat(M(e)))}async _verifyIdToken(e,t,n){const o=await this.nowProvider();return Fe({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(r=this.options.authorizationParams.max_age,"string"!=typeof r?r:parseInt(r,10)||void 0),now:o});var 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});}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{const t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},"",t.toString()));}catch(e){}}_applySessionTransferToken(e){const t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;const n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),Object.assign(Object.assign({},e),{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){var o;const r=J(N()),i=J(N()),a=N(),s=await z(a),c=F(s),u=await(null===(o=this.dpop)||void 0===o?void 0:o.calculateThumbprint()),l=((e,t,n,o,r,i,a,s,c)=>Object.assign(Object.assign(Object.assign({client_id:e.clientId},e.authorizationParams),n),{scope:Ke(t,n.scope,n.audience),response_type:"code",response_mode:s||"query",state:o,nonce:r,redirect_uri:a||e.authorizationParams.redirect_uri,code_challenge:i,code_challenge_method:"S256",dpop_jkt:c}))(this.options,this.scope,e,r,i,c,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,null==t?void 0:t.response_mode,u),h=this._authorizeUrl(l);return {nonce:i,code_verifier:a,scope:l.scope,audience:l.audience||T,redirect_uri:l.redirect_uri,state:r,url:h}}async loginWithPopup(e,t){var n;if(e=e||{},!(t=t||{}).popup&&(t.popup=(e=>{const t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,"auth0:authorize:popup","left=".concat(t,",top=").concat(n,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(""),!t.popup))throw new C;const o=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(o,{response_mode:"web_message"},window.location.origin);t.popup.location.href=r.url;const i=await((e,t)=>new Promise((n,o)=>{let r;const i=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(i),clearTimeout(a),window.removeEventListener("message",r,!1),o(new x(e.popup)));},1e3),a=setTimeout(()=>{clearInterval(i),o(new I(e.popup)),window.removeEventListener("message",r,!1);},1e3*(e.timeoutInSeconds||60));r=function(s){if(s.origin===t&&s.data&&"authorization_response"===s.data.type){if(clearTimeout(a),clearInterval(i),window.removeEventListener("message",r,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return o(E.fromPayload(s.data.response));n(s.data.response);}},window.addEventListener("message",r);}))(Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new E("state_mismatch","Invalid state");const a=(null===(n=e.authorizationParams)||void 0===n?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a});}async getUser(){var e;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.user}async getIdTokenClaims(){var e;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.claims}async loginWithRedirect(){var t;const n=wt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),o=n.openUrl,r=n.fragment,i=n.appState,a=e(n,["openUrl","fragment","appState"]),s=(null===(t=a.authorizationParams)||void 0===t?void 0:t.organization)||this.options.authorizationParams.organization,c=this._applySessionTransferToken(a.authorizationParams||{}),u=await this._prepareAuthorizeUrl(c),l=u.url,h=e(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:i,response_type:exports.ResponseType.Code}),s&&{organization:s}));const d=r?"".concat(l,"#").concat(r):l;o?await o(d):window.location.assign(d);}async handleRedirectCallback(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.href).split("?").slice(1);if(0===e.length)throw new Error("There are no query params available for parsing.");const t=this.transactionManager.get();if(!t)throw new E("missing_transaction","Invalid state");this.transactionManager.remove();const n=(e=>{e.indexOf("#")>-1&&(e=e.substring(0,e.indexOf("#")));const t=new URLSearchParams(e);return {state:t.get("state"),code:t.get("code")||void 0,connect_code:t.get("connect_code")||void 0,error:t.get("error")||void 0,error_description:t.get("error_description")||void 0}})(e.join(""));return t.response_type===exports.ResponseType.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){const n=e.code,o=e.state,r=e.error,i=e.error_description;if(r)throw new P(r,i||r,o,t.appState);if(!t.code_verifier||t.state&&t.state!==o)throw new E("state_mismatch","Invalid state");const a=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(Object.assign({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:"authorization_code",code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:a}),{appState:t.appState,response_type:exports.ResponseType.Code}}async _handleConnectAccountRedirectCallback(e,t){const n=e.connect_code,o=e.state,r=e.error,i=e.error_description;if(r)throw new A(r,i||r,t.connection,o,t.appState);if(!n)throw new E("missing_connect_code","Missing connect code");if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===o))throw new E("state_mismatch","Invalid state");const a=await this.myAccount.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier});return Object.assign(Object.assign({},a),{appState:t.appState,response_type:exports.ResponseType.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(ft))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(ft);}try{await this.getTokenSilently(e);}catch(e){}}async getTokenSilently(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,n;const o=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ke(this.scope,null===(t=e.authorizationParams)||void 0===t?void 0:t.scope,(null===(n=e.authorizationParams)||void 0===n?void 0:n.audience)||this.options.authorizationParams.audience)})}),r=await((e,t)=>{let n=dt[t];return n||(n=e().finally(()=>{delete dt[t],n=null;}),dt[t]=n),n})(()=>this._getTokenSilently(o),"".concat(this.options.clientId,"::").concat(o.authorizationParams.audience,"::").concat(o.authorizationParams.scope));return e.detailedResponse?r:null==r?void 0:r.access_token}async _getTokenSilently(t){const n=t.cacheMode,o=e(t,["cacheMode"]);if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||T,clientId:this.options.clientId,cacheMode:n});if(e)return e}if("cache-only"===n)return;const r=(i=this.options.clientId,a=o.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(i,".").concat(a));var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||T,clientId:this.options.clientId});if(e)return e}const e=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(o):await this._getTokenFromIFrame(o),t=e.id_token,r=e.token_type,i=e.access_token,a=e.oauthTokenScope,s=e.expires_in;return Object.assign(Object.assign({id_token:t,token_type:r,access_token:i},a?{scope:a}:null),{expires_in:s})})}catch(e){if(this._isInteractiveError(e)&&"popup"===this.options.interactiveErrorHandler)return await this._handleInteractiveErrorWithPopup(o);throw e}}_isInteractiveError(e){return e instanceof O||e instanceof E&&this._isIframeMfaError(e)}_isIframeMfaError(e){return "login_required"===e.error&&"Multifactor authentication required"===e.error_description}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});const t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||T,clientId:this.options.clientId});if(!t)throw new E("interactive_handler_cache_miss","Token not found in cache after interactive authentication");return t}catch(e){throw e}}async getTokenWithPopup(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,o;const r=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ke(this.scope,null===(n=e.authorizationParams)||void 0===n?void 0:n.scope,(null===(o=e.authorizationParams)||void 0===o?void 0:o.audience)||this.options.authorizationParams.audience)})});t=Object.assign(Object.assign({},v),t),await this.loginWithPopup(r,t);return (await this.cacheManager.get(new Ne({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||T,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return !!await this.getUser()}_buildLogoutUrl(t){null!==t.clientId?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const n=t.logoutParams||{},o=n.federated,r=e(n,["federated"]),i=o?"&federated":"";return this._url("/v2/logout?".concat(M(Object.assign({clientId:t.clientId},r))))+i}async revokeRefreshToken(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.options.useRefreshTokens)return;const t=e.audience||this.options.authorizationParams.audience||T,n=await this.cacheManager.getRefreshTokensByAudience(t,this.options.clientId);await async function(e,t){let n=e.baseUrl,o=e.timeout,r=e.auth0Client,i=e.useFormData,a=e.refreshTokens,s=e.audience,c=e.client_id,u=e.onRefreshTokenRevoked;const l=o||b,h="refresh_token",d="".concat(n,"/oauth/revoke"),p={"Content-Type":i?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(H(r||_)))};if(t){const e={client_id:c,token_type_hint:h},n=i?M(e):JSON.stringify(e);try{return await Ie({type:"revoke",timeout:l,fetchUrl:d,fetchOptions:{method:"POST",body:n,headers:p},useFormData:i,auth:{audience:null!=s?s:T}},t)}catch(e){throw new E("revoke_error",e.message)}}for(const e of a){const t={client_id:c,token_type_hint:h,token:e},n=i?M(t):JSON.stringify(t),o=await xe(d,{method:"POST",body:n,headers:p},l);if(!o.ok){let e,t;try{var f=JSON.parse(await o.text());e=f.error,t=f.error_description;}catch(e){}throw new E(e||"revoke_error",t||"HTTP error ".concat(o.status))}await(null==u?void 0:u(e));}}({baseUrl:this.domainUrl,timeout:this.httpTimeoutMs,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,client_id:this.options.clientId,refreshTokens:n,audience:t,onRefreshTokenRevoked:e=>this.cacheManager.stripRefreshToken(e)},this.worker);}async logout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var n;const o=wt(t),r=o.openUrl,i=e(o,["openUrl"]);null===t.clientId?await this.cacheManager.clear():await this.cacheManager.clear(t.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(Le);try{await(null===(n=this.dpop)||void 0===n?void 0:n.clear());}catch(e){}if(this.worker)try{await Ie({type:"clear"},this.worker);}catch(e){}const a=this._buildLogoutUrl(i);r?await r(a):!1!==r&&window.location.assign(a);}async _getTokenFromIFrame(e){const t=(n=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(n));var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{const t=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);const o=await this._prepareAuthorizeUrl(t,{response_mode:"web_message"},window.location.origin),r=o.url,i=o.state,a=o.nonce,s=o.code_verifier,c=o.redirect_uri,u=o.scope,l=o.audience;if(window.crossOriginIsolated)throw new E("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const h=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;let d;try{d=new URL(this.domainUrl).origin;}catch(e){d=this.domainUrl;}const p=await function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;return new Promise((o,r)=>{const i=window.document.createElement("iframe");i.setAttribute("width","0"),i.setAttribute("height","0"),i.style.display="none";const a=()=>{window.document.body.contains(i)&&(window.document.body.removeChild(i),window.removeEventListener("message",s,!1));};let s;const c=setTimeout(()=>{r(new R),a();},1e3*n);s=function(e){if(e.origin!=t)return;if(!e.data||"authorization_response"!==e.data.type)return;const n=e.source;n&&n.close(),e.data.response.error?r(E.fromPayload(e.data.response)):o(e.data.response),clearTimeout(c),window.removeEventListener("message",s,!1),setTimeout(a,2e3);},window.addEventListener("message",s,!1),window.document.body.appendChild(i),i.setAttribute("src",e);})}(r,d,h);if(i!==p.state)throw new E("state_mismatch","Invalid state");const f=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:p.code,grant_type:"authorization_code",redirect_uri:c,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return Object.assign(Object.assign({},f),{scope:u,oauthTokenScope:f.scope,audience:l})})}catch(e){if("login_required"===e.error){e instanceof E&&this._isIframeMfaError(e)&&"popup"===this.options.interactiveErrorHandler||this.logout({openUrl:!1});}throw e}}async _getTokenUsingRefreshToken(e){const t=await this.cacheManager.get(new Ne({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||T,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(t&&t.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new j(e.authorizationParams.audience||T,e.authorizationParams.scope)}const n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,o="number"==typeof e.timeoutInSeconds?1e3*e.timeoutInSeconds:null,r=((e,t,n,o)=>{var r;if(e&&n&&o){if(t.audience!==n)return t.scope;const e=o.split(" "),i=(null===(r=t.scope)||void 0===r?void 0:r.split(" "))||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?o:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,null==t?void 0:t.audience,null==t?void 0:t.scope);try{const u=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:t&&t.refresh_token,redirect_uri:n}),o&&{timeout:o}),{scopesToRequest:r});if(u.refresh_token&&(null==t?void 0:t.refresh_token)&&await this.cacheManager.updateEntry(t.refresh_token,u.refresh_token),this.options.useMrrt){if(i=null==t?void 0:t.audience,a=null==t?void 0:t.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,i!==s||!gt(c,a)){if(!gt(r,u.scope)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope);const t=((e,t)=>{const n=(null==e?void 0:e.split(" "))||[],o=(null==t?void 0:t.split(" "))||[];return n.filter(e=>-1==o.indexOf(e)).join(",")})(r,u.scope);throw new W(e.authorizationParams.audience||"default",t)}}}return Object.assign(Object.assign({},u),{scope:e.authorizationParams.scope,oauthTokenScope:u.scope,audience:e.authorizationParams.audience||T})}catch(t){if(t.message){if(t.message.includes("user is blocked"))throw await this.logout({openUrl:!1}),t;if((t.message.includes("Missing Refresh Token")||t.message.includes("invalid refresh token"))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t}var i,a,s,c;}async _saveEntryInCache(t){const n=t.id_token,o=t.decodedToken,r=e(t,["id_token","decodedToken"]);this.userCache.set(Le,{id_token:n,decodedToken:o}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(r);}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||T,t=this.scope[e],n=await this.cacheManager.getIdToken(new Ne({clientId:this.options.clientId,audience:e,scope:t})),o=this.userCache.get(Le);return n&&n.id_token===(null==o?void 0:o.id_token)?o:(this.userCache.set(Le,n),n)}async _getEntryFromCache(e){let t=e.scope,n=e.audience,o=e.clientId,r=e.cacheMode;const i=await this.cacheManager.get(new Ne({scope:t,audience:n,clientId:o}),60,this.options.useMrrt,r);if(i&&i.access_token){const e=i.token_type,t=i.access_token,n=i.oauthTokenScope,o=i.expires_in,r=await this._getIdTokenFromCache();return r&&Object.assign(Object.assign({id_token:r.id_token,token_type:e||"Bearer",access_token:t},n?{scope:n}:null),{expires_in:o})}}_storeMfaContext(e,t,n){e instanceof O&&this.mfa.setMFAAuthDetails(e.mfa_token,t,n,e.mfa_requirements);}async _requestToken(e,t){var n,o;const r=t||{},i=r.nonceIn,a=r.organization,s=r.scopesToRequest;try{const t=await je(Object.assign(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop},e),{scope:s||e.scope}),this.worker),r=await this._verifyIdToken(t.id_token,i,a);if("authorization_code"===e.grant_type){const e=await this._getIdTokenFromCache();(null===(o=null===(n=null==e?void 0:e.decodedToken)||void 0===n?void 0:n.claims)||void 0===o?void 0:o.sub)&&e.decodedToken.claims.sub!==r.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(Le));}return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},t),{decodedToken:r,scope:e.scope,audience:e.audience||T}),t.scope?{oauthTokenScope:t.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(a||r.claims.org_id),Object.assign(Object.assign({},t),{decodedToken:r})}catch(t){throw "authorization_code"!==e.grant_type&&this._storeMfaContext(t,s||e.scope,e.audience),t}}_buildTokenExchangeParams(e){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e),{grant_type:"urn:ietf:params:oauth:grant-type:token-exchange",subject_token:e.subject_token,subject_token_type:e.subject_token_type}),e.actor_token&&{actor_token:e.actor_token}),e.actor_token_type&&{actor_token_type:e.actor_token_type}),{scope:Ke(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization})}async loginWithCustomTokenExchange(e){return this._requestToken(this._buildTokenExchangeParams(e))}async customTokenExchange(e){const t=this._buildTokenExchangeParams(e);try{const n=await je(Object.assign(Object.assign({},t),{baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,dpop:this.dpop}),this.worker,!0);return n.id_token&&await this._verifyIdToken(n.id_token,void 0,e.organization),n}catch(e){throw this._storeMfaContext(e,t.scope,t.audience),e}}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw new Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(e){return this._assertDpop(this.dpop),this.dpop.getNonce(e)}setDpopNonce(e,t){return this._assertDpop(this.dpop),this.dpop.setNonce(e,t)}generateDpopProof(e){return this._assertDpop(this.dpop),this.dpop.generateProof(e)}createFetcher(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new St(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:null==e?void 0:e.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){const t=e.openUrl,n=e.appState,o=e.connection,r=e.scopes,i=e.authorization_params,a=e.redirectUri,s=void 0===a?this.options.authorizationParams.redirect_uri||window.location.origin:a;if(!o)throw new Error("connection is required");const c=J(N()),u=N(),l=await z(u),h=F(l),d=await this.myAccount.connectAccount({connection:o,scopes:r,redirect_uri:s,state:c,code_challenge:h,code_challenge_method:"S256",authorization_params:i}),p=d.connect_uri,f=d.connect_params,m=d.auth_session;this.transactionManager.create({state:c,code_verifier:u,auth_session:m,redirect_uri:s,appState:n,connection:o,response_type:exports.ResponseType.ConnectCode});const y=new URL(p);y.searchParams.set("ticket",f.ticket),t?await t(y.toString()):window.location.assign(y);}async _requestTokenForPasskey(e){const t=e.audience||this.options.authorizationParams.audience,n=e.organization||this.options.authorizationParams.organization;return this._requestToken(Object.assign(Object.assign(Object.assign({grant_type:"urn:okta:params:oauth:grant-type:webauthn",auth_session:e.authSession,authn_response:e.credential},e.realm&&{realm:e.realm}),n&&{organization:n}),{scope:Ke(this.scope,e.scope,t),audience:t}))}async _requestTokenForMfa(t,n){const o=t.mfaToken,r=e(t,["mfaToken"]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:o}),n)}}
|
|
114
|
+
function e(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);}return n}function t(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return "m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function n(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return "a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function o(e,t){this.v=e,this.k=t;}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function i(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function a(e){return new o(e,0)}function s(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function c(e,t){return e.get(i(e,t))}function u(e,t,n){s(e,t),t.set(e,n);}function h(e,t,n){return e.set(i(e,t),n),n}function l(e,t){s(e,t),t.add(e);}function d(e,t,n){return (t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o);}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){d(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e}function m(e,t){if(null==e)return {};var n,o,r=function(e,t){if(null==e)return {};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==t.indexOf(o))continue;n[o]=e[o];}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);}return r}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,s=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1;}else for(;!(c=(o=i.call(n)).done)&&(s.push(o.value),s.length!==t);c=!0);}catch(e){u=!0,r=e;}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw r}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return "Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(){return new g(e.apply(this,arguments))}}function g(e){var t,n;function r(t,n){try{var a=e[t](n),s=a.value,c=s instanceof o;Promise.resolve(c?s.v:s).then(function(n){if(c){var o="return"===t&&s.k?t:"next";if(!s.k||n.done)return r(o,n);n=e[o](n).value;}i(!!a.done,n);},function(e){r("throw",e);});}catch(e){i(2,e);}}function i(e,o){2===e?t.reject(o):t.resolve({value:o,done:e}),(t=t.next)?r(t.key,t.arg):n=null;}this._invoke=function(e,o){return new Promise(function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o));})},"function"!=typeof e.return&&(this.return=void 0);}"function"==typeof SuppressedError&&SuppressedError,g.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},g.prototype.next=function(e){return this._invoke("next",e)},g.prototype.throw=function(e){return this._invoke("throw",e)},g.prototype.return=function(e){return this._invoke("return",e)};const v={timeoutInSeconds:60},b=1e4,k="memory",_="online_access",S={name:"auth0-spa-js",version:"2.23.0"},T=()=>Date.now(),P="default";class E extends Error{constructor(e,t){super(t),this.error=e,this.error_description=t,Object.setPrototypeOf(this,E.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new E(t,n)}}class A extends E{constructor(e,t){super("invalid_configuration","".concat(e," ").concat(t)),this.suggestion=t,Object.setPrototypeOf(this,A.prototype);}}class I extends E{constructor(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;super(e,t),this.state=n,this.appState=o,Object.setPrototypeOf(this,I.prototype);}}class x extends E{constructor(e,t,n,o){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(e,t),this.connection=n,this.state=o,this.appState=r,Object.setPrototypeOf(this,x.prototype);}}class R extends E{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,R.prototype);}}class O extends R{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,O.prototype);}}class C extends E{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,C.prototype);}}class W extends E{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,W.prototype);}}class j extends E{constructor(e,t,n,o){super(e,t),this.mfa_token=n,this.mfa_requirements=o,Object.setPrototypeOf(this,j.prototype);}}class K extends E{constructor(e,t){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(N(e,["default"]),"', scope: '").concat(N(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,K.prototype);}}class U extends E{constructor(e,t){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(N(e,["default"]),"', missing scope: '").concat(N(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,U.prototype);}}class L extends E{constructor(e){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=e,Object.setPrototypeOf(this,L.prototype);}}function N(e){return e&&!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).includes(e)?e:""}const z=()=>window.crypto,D=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";for(;t.length<43;){const n=z().getRandomValues(new Uint8Array(43-t.length));for(const o of n)t.length<43&&o<198&&(t+=e[o%66]);}return t},J=e=>btoa(e),M=[{key:"name",type:["string"]},{key:"version",type:["string","number"]},{key:"env",type:["object"]}],H=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object.keys(e).reduce((n,o)=>{if(t&&"env"===o)return n;const r=M.find(e=>e.key===o);return r&&r.type.includes(typeof e[o])&&(n[o]=e[o]),n},{})},Z=t=>{var n=t.clientId,o=e(t,["clientId"]);return new URLSearchParams((e=>Object.keys(e).filter(t=>void 0!==e[t]).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{}))(Object.assign({client_id:n},o))).toString()},F=async e=>{const t=z().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e));return await t},V=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),X=e=>{const t=new Uint8Array(e);return (e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))};var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Y={},B={};Object.defineProperty(B,"__esModule",{value:!0});var q=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var o=e.locked.get(t);void 0===o?void 0===n?e.locked.set(t,[]):e.locked.set(t,[n]):void 0!==n&&(o.unshift(n),e.locked.set(t,o));},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,o){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n());})},this.unlock=function(t){var n=e.locked.get(t);if(void 0!==n&&0!==n.length){var o=n.pop();e.locked.set(t,n),void 0!==o&&setTimeout(o,0);}else e.locked.delete(t);};}return e.getInstance=function(){return void 0===e.instance&&(e.instance=new e),e.instance},e}();B.default=function(){return q.getInstance()};var Q=G&&G.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{c(o.next(e));}catch(e){i(e);}}function s(e){try{c(o.throw(e));}catch(e){i(e);}}function c(e){e.done?r(e.value):new n(function(t){t(e.value);}).then(a,s);}c((o=o.apply(e,t||[])).next());})},$=G&&G.__generator||function(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a);}catch(e){i=[6,e],o=0;}finally{n=r=0;}if(5&i[0])throw i[1];return {value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},ee=G;Object.defineProperty(Y,"__esModule",{value:!0});var te=B,ne="browser-tabs-lock-key",oe={key:function(e){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new Error("Unsupported")})})},getItem:function(e){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new Error("Unsupported")})})},clear:function(){return Q(ee,void 0,void 0,function(){return $(this,function(e){return [2,window.localStorage.clear()]})})},removeItem:function(e){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new Error("Unsupported")})})},setItem:function(e,t){return Q(ee,void 0,void 0,function(){return $(this,function(e){throw new Error("Unsupported")})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function re(e){return new Promise(function(t){return setTimeout(t,e)})}function ie(e){for(var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",o=0;o<e;o++){n+=t[Math.floor(61*Math.random())];}return n}var ae=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+ie(15),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=t,void 0===e.waiters&&(e.waiters=[]);}return e.prototype.acquireLock=function(t,n){return void 0===n&&(n=5e3),Q(this,void 0,void 0,function(){var o,r,i,a,s,c,u;return $(this,function(h){switch(h.label){case 0:o=Date.now()+ie(4),r=Date.now()+n,i=ne+"-"+t,a=void 0===this.storageHandler?oe:this.storageHandler,h.label=1;case 1:return Date.now()<r?[4,re(30)]:[3,8];case 2:return h.sent(),null!==a.getItemSync(i)?[3,5]:(s=this.id+"-"+t+"-"+o,[4,re(Math.floor(25*Math.random()))]);case 3:return h.sent(),a.setItemSync(i,JSON.stringify({id:this.id,iat:o,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,re(30)];case 4:return h.sent(),null!==(c=a.getItemSync(i))&&(u=JSON.parse(c)).id===this.id&&u.iat===o?(this.acquiredIatSet.add(o),this.refreshLockWhileAcquired(i,o),[2,!0]):[3,7];case 5:return e.lockCorrector(void 0===this.storageHandler?oe:this.storageHandler),[4,this.waitForSomethingToChange(r)];case 6:h.sent(),h.label=7;case 7:return o=Date.now()+ie(4),[3,1];case 8:return [2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return Q(this,void 0,void 0,function(){var n=this;return $(this,function(o){return setTimeout(function(){return Q(n,void 0,void 0,function(){var n,o,r;return $(this,function(i){switch(i.label){case 0:return [4,te.default().lock(t)];case 1:return i.sent(),this.acquiredIatSet.has(t)?(n=void 0===this.storageHandler?oe:this.storageHandler,null===(o=n.getItemSync(e))?(te.default().unlock(t),[2]):((r=JSON.parse(o)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(r)),te.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):(te.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return Q(this,void 0,void 0,function(){return $(this,function(n){switch(n.label){case 0:return [4,new Promise(function(n){var o=!1,r=Date.now(),i=!1;function a(){if(i||(window.removeEventListener("storage",a),e.removeFromWaiting(a),clearTimeout(s),i=!0),!o){o=!0;var t=50-(Date.now()-r);t>0?setTimeout(n,t):n(null);}}window.addEventListener("storage",a),e.addToWaiting(a);var s=setTimeout(a,Math.max(0,t-Date.now()));})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),void 0!==e.waiters&&e.waiters.push(t);},e.removeFromWaiting=function(t){void 0!==e.waiters&&(e.waiters=e.waiters.filter(function(e){return e!==t}));},e.notifyWaiters=function(){void 0!==e.waiters&&e.waiters.slice().forEach(function(e){return e()});},e.prototype.releaseLock=function(e){return Q(this,void 0,void 0,function(){return $(this,function(t){switch(t.label){case 0:return [4,this.releaseLock__private__(e)];case 1:return [2,t.sent()]}})})},e.prototype.releaseLock__private__=function(t){return Q(this,void 0,void 0,function(){var n,o,r,i;return $(this,function(a){switch(a.label){case 0:return n=void 0===this.storageHandler?oe:this.storageHandler,o=ne+"-"+t,null===(r=n.getItemSync(o))?[2]:(i=JSON.parse(r)).id!==this.id?[3,2]:[4,te.default().lock(i.iat)];case 1:a.sent(),this.acquiredIatSet.delete(i.iat),n.removeItemSync(o),te.default().unlock(i.iat),e.notifyWaiters(),a.label=2;case 2:return [2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,o=t,r=[],i=0;;){var a=o.keySync(i);if(null===a)break;r.push(a),i++;}for(var s=!1,c=0;c<r.length;c++){var u=r[c];if(u.includes(ne)){var h=o.getItemSync(u);if(null!==h){var l=JSON.parse(h);(void 0===l.timeRefreshed&&l.timeAcquired<n||void 0!==l.timeRefreshed&&l.timeRefreshed<n)&&(o.removeItemSync(u),s=!0);}}}s&&e.notifyWaiters();},e.waiters=void 0,e}(),se=Y.default=ae;class ce{async runWithLock(e,t,n){const o=new AbortController,r=setTimeout(()=>o.abort(),t);try{return await navigator.locks.request(e,{mode:"exclusive",signal:o.signal},async e=>{if(clearTimeout(r),!e)throw new Error("Lock not available");return await n()})}catch(e){if(clearTimeout(r),"AbortError"===(null==e?void 0:e.name))throw new R;throw e}}}class ue{constructor(){this.activeLocks=new Set,this.lock=new se,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear();};}async runWithLock(e,t,n){let o=!1;for(let n=0;n<10&&!o;n++)o=await this.lock.acquireLock(e,t);if(!o)throw new R;this.activeLocks.add(e),1===this.activeLocks.size&&"undefined"!=typeof window&&window.addEventListener("pagehide",this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),0===this.activeLocks.size&&"undefined"!=typeof window&&window.removeEventListener("pagehide",this.pagehideHandler);}}}function he(){return "undefined"!=typeof navigator&&"function"==typeof(null===(e=navigator.locks)||void 0===e?void 0:e.request)?new ce:new ue;var e;}let le=null;const de=new TextEncoder,pe=new TextDecoder;function fe(e){return "string"==typeof e?de.encode(e):pe.decode(e)}function me(e){if("number"!=typeof e.modulusLength||e.modulusLength<2048)throw new be(`${e.name} modulusLength must be at least 2048 bits`)}async function ye(e,t,n){if(!1===n.usages.includes("sign"))throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');const o=`${ge(fe(JSON.stringify(e)))}.${ge(fe(JSON.stringify(t)))}`;return `${o}.${ge(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return me(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return me(e.algorithm),{name:e.algorithm.name};case"Ed25519":return {name:e.algorithm.name}}throw new ve}(n),n,fe(o)))}`}let we;if(Uint8Array.prototype.toBase64)we=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;we=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function ge(e){return we(e)}class ve extends Error{constructor(e){var t;super(null!=e?e:"operation not supported"),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}class be extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor);}}function ke(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){if("SHA-256"===e.algorithm.hash.name)return "PS256";throw new ve("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"RSASSA-PKCS1-v1_5":return function(e){if("SHA-256"===e.algorithm.hash.name)return "RS256";throw new ve("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"ECDSA":return function(e){if("P-256"===e.algorithm.namedCurve)return "ES256";throw new ve("unsupported EcKeyAlgorithm namedCurve")}(e);case"Ed25519":return "Ed25519";default:throw new ve("unsupported CryptoKey algorithm name")}}function _e(e){return e instanceof CryptoKey}function Se(e){return _e(e)&&"public"===e.type}async function Te(e,t,n,o,r,i){const a=null==e?void 0:e.privateKey,s=null==e?void 0:e.publicKey;if(!_e(c=a)||"private"!==c.type)throw new TypeError('"keypair.privateKey" must be a private CryptoKey');var c;if(!Se(s))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(!0!==s.extractable)throw new TypeError('"keypair.publicKey.extractable" must be true');if("string"!=typeof t)throw new TypeError('"htu" must be a string');if("string"!=typeof n)throw new TypeError('"htm" must be a string');if(void 0!==o&&"string"!=typeof o)throw new TypeError('"nonce" must be a string or undefined');if(void 0!==r&&"string"!=typeof r)throw new TypeError('"accessToken" must be a string or undefined');if(void 0!==i&&("object"!=typeof i||null===i||Array.isArray(i)))throw new TypeError('"additional" must be an object');return ye({alg:ke(a),typ:"dpop+jwt",jwk:await Pe(s)},Object.assign(Object.assign({},i),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:o,htu:t,ath:r?ge(await crypto.subtle.digest("SHA-256",fe(r))):void 0}),a)}async function Pe(e){const{kty:t,e:n,n:o,x:r,y:i,crv:a}=await crypto.subtle.exportKey("jwk",e);return {kty:t,crv:a,e:n,n:o,x:r,y:i}}const Ee="dpop-nonce",Ae=["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:token-exchange","urn:okta:params:oauth:grant-type:webauthn","http://auth0.com/oauth/grant-type/mfa-oob","http://auth0.com/oauth/grant-type/mfa-otp","http://auth0.com/oauth/grant-type/mfa-recovery-code"];function Ie(){return async function(e,t){var n;let o;if("string"!=typeof e||0===e.length)throw new TypeError('"alg" must be a non-empty string');switch(e){case"PS256":o={name:"RSA-PSS",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":o={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"};break;case"Ed25519":o={name:"Ed25519"};break;default:throw new ve}return crypto.subtle.generateKey(o,null!==(n=null==t?void 0:t.extractable)&&void 0!==n&&n,["sign","verify"])}("ES256",{extractable:!1})}function xe(e){return async function(e){if(!Se(e))throw new TypeError('"publicKey" must be a public CryptoKey');if(!0!==e.extractable)throw new TypeError('"publicKey.extractable" must be true');const t=await Pe(e);let n;switch(t.kty){case"EC":n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":n={crv:t.crv,kty:t.kty,x:t.x};break;case"RSA":n={e:t.e,kty:t.kty,n:t.n};break;default:throw new ve("unsupported JWK kty")}return ge(await crypto.subtle.digest({name:"SHA-256"},fe(JSON.stringify(n))))}(e.publicKey)}function Re(e){let t=e.keyPair,n=e.url,o=e.method,r=e.nonce,i=e.accessToken;const a=function(e){const t=new URL(e);return t.search="",t.hash="",t.href}(n);return Te(t,a,o,r,i)}const Oe=(e,t)=>new Promise(function(n,o){const r=new MessageChannel;r.port1.onmessage=function(e){e.data.error?o(new Error(e.data.error)):n(e.data),r.port1.close();},t.postMessage(e,[r.port2]);}),Ce=(e,t,n)=>{const o=new AbortController;let r;return t.signal=o.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{r=setTimeout(()=>{o.abort(),t(new Error("Timeout when executing 'fetch'"));},n);})]).finally(()=>{clearTimeout(r);})},We=async function(e,t,n,o,r,i){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:b;return r?(async(e,t,n,o,r,i,a,s,c,u)=>Oe({type:"refresh",auth:{audience:t,scope:n},timeout:r,fetchUrl:e,fetchOptions:o,useFormData:a,useMrrt:s,skipTokenStorage:c,preserveRefreshToken:u},i))(e,t,n,o,a,r,i,arguments.length>7?arguments[7]:void 0,arguments.length>8?arguments[8]:void 0,arguments.length>9?arguments[9]:void 0):(async(e,t,n)=>{const o=await Ce(e,t,n);return {ok:o.ok,json:await o.json(),headers:(r=o.headers,[...r].reduce((e,t)=>{let n=y(t,2),o=n[0],r=n[1];return e[o]=r,e},{}))};var r;})(e,o,a)};async function je(t,n,o,r,i,a,s,c,u,h,l,d){if(u){const e=await u.generateProof({url:t,method:i.method||"GET",nonce:await u.getNonce()});i.headers=Object.assign(Object.assign({},i.headers),{dpop:e});}let p,f=null;for(let e=0;e<3;e++)try{p=await We(t,o,r,i,a,s,n,c,l,d),f=null;break}catch(e){f=e;}if(f)throw f;const m=p.json,y=m.error,w=m.error_description,g=e(m,["error","error_description"]),v=p,b=v.headers,k=v.ok;let _;if(u&&(_=b[Ee],_&&await u.setNonce(_)),!k){const e=w||"HTTP error. Unable to fetch ".concat(t);if("mfa_required"===y)throw new j(y,e,g.mfa_token,g.mfa_requirements);if("missing_refresh_token"===y)throw new K(o,r);if("use_dpop_nonce"===y){if(!u||!_||h)throw new L(_);return je(t,n,o,r,i,a,s,c,u,!0,l,d)}throw new E(y||"request_error",e)}return g}async function Ke(t,n,o){var r=t.baseUrl,i=t.timeout,a=t.audience,s=t.scope,c=t.auth0Client,u=t.useFormData,h=t.useMrrt,l=t.dpop,d=t.preserveRefreshToken,p=e(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData","useMrrt","dpop","preserveRefreshToken"]);const f="urn:ietf:params:oauth:grant-type:token-exchange"===p.grant_type,m="urn:okta:params:oauth:grant-type:webauthn"===p.grant_type,y="refresh_token"===p.grant_type&&h,w=f||m||y,g=Object.assign(Object.assign(Object.assign({},p),w&&a&&{audience:a}),w&&s&&{scope:s}),v=m||!u,b=v?JSON.stringify(g):Z(g),k=(_=p.grant_type,Ae.includes(_));var _;return await je("".concat(r,"/oauth/token"),i,a||P,s,{method:"POST",body:b,headers:{"Content-Type":v?"application/json":"application/x-www-form-urlencoded","Auth0-Client":btoa(JSON.stringify(H(c||S)))}},n,u,h,k?l:void 0,void 0,o,d)}const Ue=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return (o=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(o))).join(" ");var o;},Le=(e,t,n)=>{let o;return n&&(o=e[n]),o||(o=e[P]),Ue(o,t)},Ne="@@auth0spajs@@",ze="@@user@@";class De{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ne,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,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){const t=y(e.split("::"),4),n=t[0],o=t[1],r=t[2],i=t[3];return new De({clientId:o,scope:i,audience:r},n)}static fromCacheEntry(e){const t=e.scope,n=e.audience,o=e.client_id;return new De({scope:t,audience:n,clientId:o})}}class Je{set(e,t){localStorage.setItem(e,JSON.stringify(t));}get(e){const t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(e){return}}remove(e){localStorage.removeItem(e);}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(Ne))}}class Me{constructor(){this.enclosedCache=function(){let e={};return {set(t,n){e[t]=n;},get(t){const n=e[t];if(n)return n},remove(t){delete e[t];},allKeys:()=>Object.keys(e)}}();}}class He{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||T;}async setIdToken(e,t,n){var o;const r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await(null===(o=this.keyManifest)||void 0===o?void 0:o.add(r));}async getIdToken(e){const t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){const t=await this.get(e);if(!t)return;if(!t.id_token||!t.decodedToken)return;return {id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return {id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0;var r;let i=await this.cache.get(e.toKey()),a=e;if(!i){const t=await this.getCacheKeys();if(!t)return;const r=this.matchExistingCacheKey(e,t);if(r&&(i=await this.cache.get(r),a=De.fromKey(r)),!i&&n&&"cache-only"!==o)return this.getEntryWithRefreshToken(e,t)}if(!i)return;const s=await this.nowProvider(),c=Math.floor(s/1e3);return i.expiresAt-t<c?i.body.refresh_token?this.modifiedCachedEntry(i,a):(await this.cache.remove(a.toKey()),void await(null===(r=this.keyManifest)||void 0===r?void 0:r.remove(a.toKey()))):i.body}async modifiedCachedEntry(e,t){const n={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},o={body:n,expiresAt:e.expiresAt};return await this.cache.set(t.toKey(),o),{refresh_token:n.refresh_token,audience:n.audience,scope:n.scope}}async set(e){var t;const n=new De({clientId:e.client_id,scope:e.scope,audience:e.audience}),o=await this.wrapCacheEntry(e);await this.cache.set(n.toKey(),o),await(null===(t=this.keyManifest)||void 0===t?void 0:t.add(n.toKey()));}async remove(e,t,n){const o=new De({clientId:e,scope:n,audience:t});await this.cache.remove(o.toKey());}async stripRefreshToken(e){var t;const n=await this.getCacheKeys();if(n)for(const o of n){const n=await this.cache.get(o);(null===(t=null==n?void 0:n.body)||void 0===t?void 0:t.refresh_token)===e&&(delete n.body.refresh_token,await this.cache.set(o,n));}}async clear(e){var t;const n=await this.getCacheKeys();n&&(await n.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t);},Promise.resolve()),await(null===(t=this.keyManifest)||void 0===t?void 0:t.clear()));}async wrapCacheEntry(e){const t=await this.nowProvider();return {body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?null===(e=await this.keyManifest.get())||void 0===e?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new De({clientId:e},Ne,ze).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{var n;const o=De.fromKey(t),r=new Set(o.scope&&o.scope.split(" ")),i=(null===(n=e.scope)||void 0===n?void 0:n.split(" "))||[],a=o.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return o.prefix===Ne&&o.clientId===e.clientId&&o.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){var n;for(const o of t){const t=De.fromKey(o);if(t.prefix===Ne&&t.clientId===e.clientId){const e=await this.cache.get(o);if(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)return {refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}}}async getRefreshTokensByAudience(e,t){var n;const o=await this.getCacheKeys();if(!o)return [];const r=new Set;for(const i of o){const o=De.fromKey(i);if(o.prefix===Ne&&o.clientId===t&&o.audience===e){const e=await this.cache.get(i);(null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.refresh_token)&&r.add(e.body.refresh_token);}}return Array.from(r)}async updateEntry(e,t){var n;const o=await this.getCacheKeys();if(o)for(const r of o){const o=await this.cache.get(r);(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.refresh_token)===e&&(o.body.refresh_token=t,await this.cache.set(r,o));}}}class Ze{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey="".concat("a0.spajs.txs",".").concat(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});}}const Fe=e=>"number"==typeof e,Ve=["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"],Xe=e=>{if(!e.id_token)throw new Error("ID token is required but missing");const t=(e=>{const t=e.split("."),n=y(t,3),o=n[0],r=n[1],i=n[2];if(3!==t.length||!o||!r||!i)throw new Error("ID token could not be decoded");const a=JSON.parse(V(r)),s={__raw:e},c={};return Object.keys(a).forEach(e=>{s[e]=a[e],Ve.includes(e)||(c[e]=a[e]);}),{encoded:{header:o,payload:r,signature:i},header:JSON.parse(V(o)),claims:s,user:c}})(e.id_token);if(!t.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(t.claims.iss!==e.iss)throw new Error('Issuer (iss) claim mismatch in the ID token; expected "'.concat(e.iss,'", found "').concat(t.claims.iss,'"'));if(!t.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if("RS256"!==t.header.alg)throw new Error('Signature algorithm of "'.concat(t.header.alg,'" is not supported. Expected the ID token to be signed with "RS256".'));if(!t.claims.aud||"string"!=typeof t.claims.aud&&!Array.isArray(t.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but was not one of "').concat(t.claims.aud.join(", "),'"'));if(t.claims.aud.length>1){if(!t.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(t.claims.azp!==e.aud)throw new Error('Authorized Party (azp) claim mismatch in the ID token; expected "'.concat(e.aud,'", found "').concat(t.claims.azp,'"'))}}else if(t.claims.aud!==e.aud)throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but found "').concat(t.claims.aud,'"'));if(e.nonce){if(!t.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(t.claims.nonce!==e.nonce)throw new Error('Nonce (nonce) claim mismatch in the ID token; expected "'.concat(e.nonce,'", found "').concat(t.claims.nonce,'"'))}if(e.max_age&&!Fe(t.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(null==t.claims.exp||!Fe(t.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Fe(t.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=e.leeway||60,o=new Date(e.now||Date.now()),r=new Date(0);if(r.setUTCSeconds(t.claims.exp+n),o>r)throw new Error("Expiration Time (exp) claim error in the ID token; current time (".concat(o,") is after expiration time (").concat(r,")"));if(null!=t.claims.nbf&&Fe(t.claims.nbf)){const e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),o<e)throw new Error("Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (".concat(o,") is before ").concat(e))}if(null!=t.claims.auth_time&&Fe(t.claims.auth_time)){const r=new Date(0);if(r.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),o>r)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 (".concat(o,") is after last auth at ").concat(r))}if(e.organization){const n=e.organization.trim();if(n.startsWith("org_")){const e=n;if(!t.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(e!==t.claims.org_id)throw new Error('Organization ID (org_id) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_id,'"'))}else {const e=n.toLowerCase();if(!t.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(e!==t.claims.org_name)throw new Error('Organization Name (org_name) claim mismatch in the ID token; expected "'.concat(e,'", found "').concat(t.claims.org_name,'"'))}}return t};var Ge=G&&G.__assign||function(){return Ge=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Ge.apply(this,arguments)};function Ye(e,t){if(!t)return "";var n="; "+e;return !0===t?n:n+"="+t}function Be(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if("number"==typeof e.expires){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t;}return Ye("Expires",e.expires?e.expires.toUTCString():"")+Ye("Domain",e.domain)+Ye("Path",e.path)+Ye("Secure",e.secure)+Ye("SameSite",e.sameSite)}(n)}function qe(){return function(e){for(var t={},n=e?e.split("; "):[],o=/(%[\dA-F]{2})+/gi,r=0;r<n.length;r++){var i=n[r].split("="),a=i.slice(1).join("=");'"'===a.charAt(0)&&(a=a.slice(1,-1));try{t[i[0].replace(o,decodeURIComponent)]=a.replace(o,decodeURIComponent);}catch(e){}}return t}(document.cookie)}var Qe=function(e){return qe()[e]};function $e(e,t,n){document.cookie=Be(e,t,Ge({path:"/"},n));}var et=$e;var tt=function(e,t){$e(e,"",Ge(Ge({},t),{expires:-1}));};const nt={get(e){const t=Qe(e);if(void 0!==t)return JSON.parse(t)},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0,sameSite:"none"}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),et(e,JSON.stringify(t),o);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),tt(e,n);}},ot="_legacy_",rt={get(e){const t=nt.get(e);return t||nt.get("".concat(ot).concat(e))},save(e,t,n){let o={};"https:"===window.location.protocol&&(o={secure:!0}),(null==n?void 0:n.daysUntilExpire)&&(o.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(o.domain=n.cookieDomain),et("".concat(ot).concat(e),JSON.stringify(t),o),nt.save(e,t,n);},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),tt(e,n),nt.remove(e,t),nt.remove("".concat(ot).concat(e),t);}},it={get(e){if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(e);return null!=t?JSON.parse(t):void 0},save(e,t){sessionStorage.setItem(e,JSON.stringify(t));},remove(e){sessionStorage.removeItem(e);}};exports.ResponseType = void 0;!function(e){e.Code="code",e.ConnectCode="connect_code";}(exports.ResponseType||(exports.ResponseType={}));class ct{}function ut(e,t,n){var o=void 0===t?null:t,r=function(e,t){var n=atob(e);if(t){for(var o=new Uint8Array(n.length),r=0,i=n.length;r<i;++r)o[r]=n.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(o.buffer))}return n}(e,void 0!==n&&n),i=r.indexOf("\n",10)+1,a=r.substring(i)+(o?"//# sourceMappingURL="+o:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var ht,lt,dt,pt,ft=(ht="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHQpeyhudWxsPT10fHx0PmUubGVuZ3RoKSYmKHQ9ZS5sZW5ndGgpO2Zvcih2YXIgcj0wLG89QXJyYXkodCk7cjx0O3IrKylvW3JdPWVbcl07cmV0dXJuIG99ZnVuY3Rpb24gdCh0LHIpe3JldHVybiBmdW5jdGlvbihlKXtpZihBcnJheS5pc0FycmF5KGUpKXJldHVybiBlfSh0KXx8ZnVuY3Rpb24oZSx0KXt2YXIgcj1udWxsPT1lP251bGw6InVuZGVmaW5lZCIhPXR5cGVvZiBTeW1ib2wmJmVbU3ltYm9sLml0ZXJhdG9yXXx8ZVsiQEBpdGVyYXRvciJdO2lmKG51bGwhPXIpe3ZhciBvLG4scyxpLGE9W10sYz0hMCxsPSExO3RyeXtpZihzPShyPXIuY2FsbChlKSkubmV4dCwwPT09dCl7aWYoT2JqZWN0KHIpIT09cilyZXR1cm47Yz0hMX1lbHNlIGZvcig7IShjPShvPXMuY2FsbChyKSkuZG9uZSkmJihhLnB1c2goby52YWx1ZSksYS5sZW5ndGghPT10KTtjPSEwKTt9Y2F0Y2goZSl7bD0hMCxuPWV9ZmluYWxseXt0cnl7aWYoIWMmJm51bGwhPXIucmV0dXJuJiYoaT1yLnJldHVybigpLE9iamVjdChpKSE9PWkpKXJldHVybn1maW5hbGx5e2lmKGwpdGhyb3cgbn19cmV0dXJuIGF9fSh0LHIpfHxmdW5jdGlvbih0LHIpe2lmKHQpe2lmKCJzdHJpbmciPT10eXBlb2YgdClyZXR1cm4gZSh0LHIpO3ZhciBvPXt9LnRvU3RyaW5nLmNhbGwodCkuc2xpY2UoOCwtMSk7cmV0dXJuIk9iamVjdCI9PT1vJiZ0LmNvbnN0cnVjdG9yJiYobz10LmNvbnN0cnVjdG9yLm5hbWUpLCJNYXAiPT09b3x8IlNldCI9PT1vP0FycmF5LmZyb20odCk6IkFyZ3VtZW50cyI9PT1vfHwvXig/OlVpfEkpbnQoPzo4fDE2fDMyKSg/OkNsYW1wZWQpP0FycmF5JC8udGVzdChvKT9lKHQscik6dm9pZCAwfX0odCxyKXx8ZnVuY3Rpb24oKXt0aHJvdyBuZXcgVHlwZUVycm9yKCJJbnZhbGlkIGF0dGVtcHQgdG8gZGVzdHJ1Y3R1cmUgbm9uLWl0ZXJhYmxlIGluc3RhbmNlLlxuSW4gb3JkZXIgdG8gYmUgaXRlcmFibGUsIG5vbi1hcnJheSBvYmplY3RzIG11c3QgaGF2ZSBhIFtTeW1ib2wuaXRlcmF0b3JdKCkgbWV0aG9kLiIpfSgpfWNsYXNzIHIgZXh0ZW5kcyBFcnJvcntjb25zdHJ1Y3RvcihlLHQpe3N1cGVyKHQpLHRoaXMuZXJyb3I9ZSx0aGlzLmVycm9yX2Rlc2NyaXB0aW9uPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsci5wcm90b3R5cGUpfXN0YXRpYyBmcm9tUGF5bG9hZChlKXtsZXQgdD1lLmVycm9yLG89ZS5lcnJvcl9kZXNjcmlwdGlvbjtyZXR1cm4gbmV3IHIodCxvKX19Y2xhc3MgbyBleHRlbmRzIHJ7Y29uc3RydWN0b3IoZSx0KXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIiwiTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyIuY29uY2F0KG4oZSxbImRlZmF1bHQiXSksIicsIHNjb3BlOiAnIikuY29uY2F0KG4odCksIicpIikpLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXQsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsby5wcm90b3R5cGUpfX1mdW5jdGlvbiBuKGUpe3JldHVybiBlJiYhKGFyZ3VtZW50cy5sZW5ndGg+MSYmdm9pZCAwIT09YXJndW1lbnRzWzFdP2FyZ3VtZW50c1sxXTpbXSkuaW5jbHVkZXMoZSk/ZToiIn0iZnVuY3Rpb24iPT10eXBlb2YgU3VwcHJlc3NlZEVycm9yJiZTdXBwcmVzc2VkRXJyb3I7Y29uc3Qgcz1lPT57dmFyIHQ9ZS5jbGllbnRJZCxyPWZ1bmN0aW9uKGUsdCl7dmFyIHI9e307Zm9yKHZhciBvIGluIGUpT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbykmJnQuaW5kZXhPZihvKTwwJiYocltvXT1lW29dKTtpZihudWxsIT1lJiYiZnVuY3Rpb24iPT10eXBlb2YgT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyl7dmFyIG49MDtmb3Iobz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO248by5sZW5ndGg7bisrKXQuaW5kZXhPZihvW25dKTwwJiZPYmplY3QucHJvdG90eXBlLnByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoZSxvW25dKSYmKHJbb1tuXV09ZVtvW25dXSl9cmV0dXJuIHJ9KGUsWyJjbGllbnRJZCJdKTtyZXR1cm4gbmV3IFVSTFNlYXJjaFBhcmFtcygoZT0+T2JqZWN0LmtleXMoZSkuZmlsdGVyKHQ9PnZvaWQgMCE9PWVbdF0pLnJlZHVjZSgodCxyKT0+T2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHQpLHtbcl06ZVtyXX0pLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IGk9e30sYT1udWxsO2NvbnN0IGM9KGUsdCk9PiIiLmNvbmNhdChlLCJ8IikuY29uY2F0KHQpLGw9KGUsdCk9PnQuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSx1PWU9PntPYmplY3QuZW50cmllcyhpKS5mb3JFYWNoKHI9PntsZXQgbz10KHIsMiksbj1vWzBdO29bMV09PT1lJiZkZWxldGUgaVtuXX0pfSxmPWU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKChlLHQpPT57clt0XT1lfSkscn0saD1hc3luYyBlPT57bGV0IHIsbixhPWUuZGF0YSx1PWEudGltZW91dCxoPWEuYXV0aCxkPWEuZmV0Y2hVcmwscD1hLmZldGNoT3B0aW9ucyx5PWEudXNlRm9ybURhdGEsZz1hLnVzZU1ycnQsYj1hLnNraXBUb2tlblN0b3JhZ2UsTz1hLnByZXNlcnZlUmVmcmVzaFRva2VuLGs9dChlLnBvcnRzLDEpWzBdLG09e307Y29uc3Qgaj1ofHx7fSx2PWouYXVkaWVuY2UsXz1qLnNjb3BlO3RyeXtjb25zdCBlPXk/ZihwLmJvZHkpOkpTT04ucGFyc2UocC5ib2R5KTtpZighZS5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1lLmdyYW50X3R5cGUpe2lmKG49KChlLHQpPT5pW2MoZSx0KV0pKHYsXyksIW4mJmcpe2NvbnN0IGU9aS5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+ISFPYmplY3Qua2V5cyhpKS5maW5kKHI9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09cil7Y29uc3Qgbz1sKHQsciksbj1yLnNwbGl0KCJ8IilbMV0uc3BsaXQoIiAiKSxzPWUuc3BsaXQoIiAiKS5ldmVyeShlPT5uLmluY2x1ZGVzKGUpKTtyZXR1cm4gbyYmc319KSkoXyx2KTtlJiYhdCYmKG49ZSl9aWYoIW4pdGhyb3cgbmV3IG8odixfKTtwLmJvZHk9eT9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpufSkpfWxldCBhLGg7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGE9bmV3IEFib3J0Q29udHJvbGxlcixwLnNpZ25hbD1hLnNpZ25hbCk7dHJ5e2g9YXdhaXQgUHJvbWlzZS5yYWNlKFsoVT11LG5ldyBQcm9taXNlKGU9PnNldFRpbWVvdXQoZSxVKSkpLGZldGNoKGQsT2JqZWN0LmFzc2lnbih7fSxwKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBrLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighaClyZXR1cm4gYSYmYS5hYm9ydCgpLHZvaWQgay5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtpZihNPWguaGVhZGVycyxtPVsuLi5NXS5yZWR1Y2UoKGUscik9PntsZXQgbz10KHIsMiksbj1vWzBdLHM9b1sxXTtyZXR1cm4gZVtuXT1zLGV9LHt9KSxyPWF3YWl0IGguanNvbigpLGIpcmV0dXJuIGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4sdm9pZCBrLnBvc3RNZXNzYWdlKHtvazpoLm9rLGpzb246cixoZWFkZXJzOm19KTtyLnJlZnJlc2hfdG9rZW4/KGcmJihpLmxhdGVzdF9yZWZyZXNoX3Rva2VuPXIucmVmcmVzaF90b2tlbix3PW4sUz1yLnJlZnJlc2hfdG9rZW4sT2JqZWN0LmVudHJpZXMoaSkuZm9yRWFjaChlPT57bGV0IHI9dChlLDIpLG89clswXTtyWzFdPT09dyYmKGlbb109Uyl9KSksKChlLHQscik9PntpW2ModCxyKV09ZX0pKHIucmVmcmVzaF90b2tlbix2LF8pLGRlbGV0ZSByLnJlZnJlc2hfdG9rZW4pOk98fCgoZSx0KT0+e2RlbGV0ZSBpW2MoZSx0KV19KSh2LF8pLGsucG9zdE1lc3NhZ2Uoe29rOmgub2ssanNvbjpyLGhlYWRlcnM6bX0pfWNhdGNoKGUpe2sucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOmUuZXJyb3IsZXJyb3JfZGVzY3JpcHRpb246ZS5tZXNzYWdlfSxoZWFkZXJzOm19KX12YXIgdyxTLE0sVX0sZD1hc3luYyBlPT57bGV0IHI9ZS5kYXRhLG89ci50aW1lb3V0LG49ci5hdXRoLGE9ci5mZXRjaFVybCxjPXIuZmV0Y2hPcHRpb25zLGg9ci51c2VGb3JtRGF0YSxkPXQoZS5wb3J0cywxKVswXTtjb25zdCBwPShufHx7fSkuYXVkaWVuY2U7dHJ5e2NvbnN0IGU9KGU9Pntjb25zdCByPW5ldyBTZXQ7cmV0dXJuIE9iamVjdC5lbnRyaWVzKGkpLmZvckVhY2gobz0+e2xldCBuPXQobywyKSxzPW5bMF0saT1uWzFdO2woZSxzKSYmci5hZGQoaSl9KSxBcnJheS5mcm9tKHIpfSkocCk7aWYoMD09PWUubGVuZ3RoKXJldHVybiB2b2lkIGQucG9zdE1lc3NhZ2Uoe29rOiEwfSk7Y29uc3Qgcj1oP2YoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7Zm9yKGNvbnN0IHQgb2YgZSl7Y29uc3QgZT1oP3MoT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LHIpLHt0b2tlbjp0fSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxyKSx7dG9rZW46dH0pKTtsZXQgbixpLGwsZjsiZnVuY3Rpb24iPT10eXBlb2YgQWJvcnRDb250cm9sbGVyJiYobj1uZXcgQWJvcnRDb250cm9sbGVyLGk9bi5zaWduYWwpO3RyeXtmPWF3YWl0IFByb21pc2UucmFjZShbbmV3IFByb21pc2UoZT0+e2w9c2V0VGltZW91dChlLG8pfSksZmV0Y2goYSxPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sYykse2JvZHk6ZSxzaWduYWw6aX0pKV0pLmZpbmFsbHkoKCk9PmNsZWFyVGltZW91dChsKSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIWYpcmV0dXJuIG4mJm4uYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7aWYoIWYub2spe2xldCBlO3RyeXtjb25zdCB0PUpTT04ucGFyc2UoYXdhaXQgZi50ZXh0KCkpO2U9dC5lcnJvcl9kZXNjcmlwdGlvbn1jYXRjaChlKXt9cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZXx8IkhUVFAgZXJyb3IgIi5jb25jYXQoZi5zdGF0dXMpfSl9dSh0KX1kLnBvc3RNZXNzYWdlKHtvazohMH0pfWNhdGNoKGUpe2QucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZXx8IlVua25vd24gZXJyb3IgZHVyaW5nIHRva2VuIHJldm9jYXRpb24ifSl9fSxwPShlLHQpPT57aWYoIWEpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChhKS5vcmlnaW4sbz1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiBvLm9yaWdpbj09PXImJm8ucGF0aG5hbWU9PT10fWNhdGNoKGUpe3JldHVybiExfX07YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZT0+e2NvbnN0IHI9ZS5kYXRhLG89dChlLnBvcnRzLDEpWzBdO2lmKCEoInR5cGUiaW4gcil8fCJpbml0IiE9PXIudHlwZSlyZXR1cm4idHlwZSJpbiByJiYiY2xlYXIiPT09ci50eXBlPyhpPXt9LHZvaWQobnVsbD09b3x8by5wb3N0TWVzc2FnZSh7b2s6ITB9KSkpOiJ0eXBlImluIHImJiJyZXZva2UiPT09ci50eXBlP3AociwiL29hdXRoL3Jldm9rZSIpP3ZvaWQgZChlKTp2b2lkKG51bGw9PW98fG8ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSkpOnZvaWQoImZldGNoVXJsImluIHImJnAociwiL29hdXRoL3Rva2VuIik/aChlKTpudWxsPT1vfHxvLnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjoiaW52YWxpZF9mZXRjaF91cmwiLGVycm9yX2Rlc2NyaXB0aW9uOiJVbmF1dGhvcml6ZWQgZmV0Y2ggVVJMIn0saGVhZGVyczp7fX0pKTtpZihudWxsPT09YSl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxhPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX0pfSgpOwoK",lt=null,dt=!1,function(e){return pt=pt||ut(ht,lt,dt),new Worker(pt,e)});const mt={};class yt{constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId);}async add(e){var t;const n=new Set((null===(t=await this.cache.get(this.manifestKey))||void 0===t?void 0:t.keys)||[]);n.add(e),await this.cache.set(this.manifestKey,{keys:[...n]});}async remove(e){const t=await this.cache.get(this.manifestKey);if(t){const n=new Set(t.keys);return n.delete(e),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return "".concat(Ne,"::").concat(e)}}const wt="auth0.is.authenticated",gt={memory:()=>(new Me).enclosedCache,localstorage:()=>new Je},vt=e=>gt[e],bt=t=>{const n=t.openUrl,o=t.onRedirect,r=e(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:!1===n||n?n:o})},kt=(e,t,n)=>{const o=(null==e?void 0:e.split(" "))||[],r=n?o.filter(e=>e!==_):o;const i=(null==t?void 0:t.split(" "))||[];return r.filter(e=>-1==i.indexOf(e)).join(",")},_t={NONCE:"nonce",KEYPAIR:"keypair"};class St{constructor(e){this.clientId=e;}getVersion(){return 1}createDbHandle(){const e=window.indexedDB.open("auth0-spa-js",this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(_t).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result);})}async getDbHandle(){return this.dbHandle||(this.dbHandle=await this.createDbHandle()),this.dbHandle}async executeDbRequest(e,t,n){const o=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{o.onsuccess=()=>e(o.result),o.onerror=()=>t(o.error);})}buildKey(e){const t=e?"_".concat(e):"auth0";return "".concat(this.clientId,"::").concat(t)}setNonce(e,t){return this.save(_t.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(_t.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,"readwrite",e=>e.put(n,t));}findNonce(e){return this.find(_t.NONCE,this.buildKey(e))}findKeyPair(){return this.find(_t.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,"readonly",e=>e.get(t))}async deleteBy(e,t){const n=await this.executeDbRequest(e,"readonly",e=>e.getAllKeys());await Promise.all((null==n?void 0:n.filter(t).map(t=>this.executeDbRequest(e,"readwrite",e=>e.delete(t))))||[]);}deleteByClientId(e,t){return this.deleteBy(e,e=>"string"==typeof e&&e.startsWith("".concat(t,"::")))}clearNonces(){return this.deleteByClientId(_t.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(_t.KEYPAIR,this.clientId)}}class Tt{constructor(e){this.storage=new St(e);}getNonce(e){return this.storage.findNonce(e)}setNonce(e,t){return this.storage.setNonce(e,t)}async getOrGenerateKeyPair(){let e=await this.storage.findKeyPair();return e||(e=await Ie(),await this.storage.setKeyPair(e)),e}async generateProof(e){const t=await this.getOrGenerateKeyPair();return Re(Object.assign({keyPair:t},e))}async calculateThumbprint(){return xe(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()]);}}var Pt;!function(e){e.Bearer="Bearer",e.DPoP="DPoP";}(Pt||(Pt={}));class Et{constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||("undefined"==typeof window?fetch:window.fetch.bind(window))});}isAbsoluteUrl(e){return /^(https?:)?\/\//i.test(e)}buildUrl(e,t){if(t){if(this.isAbsoluteUrl(t))return t;if(e)return "".concat(e.replace(/\/?\/$/,""),"/").concat(t.replace(/^\/+/,""))}throw new TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(e){return this.config.getAccessToken?this.config.getAccessToken(e):this.hooks.getAccessToken(e)}extractUrl(e){return "string"==typeof e?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);const n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),o=e instanceof Request?new Request(n,e):n;return new Request(o,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Pt.Bearer;e.headers.set("authorization","".concat(n," ").concat(t));}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;const n=await this.hooks.getDpopNonce(),o=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set("dpop",o);}async prepareRequest(e,t){const n=await this.getAccessToken(t);let o,r;"string"==typeof n?(o=this.config.dpopNonceId?Pt.DPoP:Pt.Bearer,r=n):(o=n.token_type,r=n.access_token),this.setAuthorizationHeader(e,r,o),o===Pt.DPoP&&await this.setDpopProofHeader(e,r);}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||"":"function"==typeof e.get?e.get(t)||"":e[t]||""}hasUseDpopNonceError(e){if(401!==e.status)return !1;const t=this.getHeader(e.headers,"www-authenticate");return t.includes("invalid_dpop_nonce")||t.includes("use_dpop_nonce")}async handleResponse(e,t){const n=this.getHeader(e.headers,Ee);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new L(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,o){const r=this.buildBaseRequest(e,t);await this.prepareRequest(r,o);const i=await this.config.fetch(r);return this.handleResponse(i,n)}fetchWithAuth(e,t,n){const o={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,Object.assign(Object.assign({},o),{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,o,n)}}class At{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t;}async connectAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async completeAccount(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/connected-accounts/complete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async getFactors(){const e=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/factors"),{method:"GET"},{scope:["read:me:factors"]});return (await this._handleResponse(e)).factors}async getAuthenticationMethods(e){const t=e?"?".concat(new URLSearchParams({type:e})):"",n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods").concat(t),{method:"GET"},{scope:["read:me:authentication_methods"]});return (await this._handleResponse(n)).authentication_methods}async getAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"GET"},{scope:["read:me:authentication_methods"]});return this._handleResponse(t)}async deleteAuthenticationMethod(e){const t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"DELETE"},{scope:["delete:me:authentication_methods"]});t.ok||await this._handleResponse(t);}async updateAuthenticationMethod(e,t){const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["update:me:authentication_methods"]});return this._handleResponse(n)}async enrollmentChallenge(e){var t;const n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:authentication_methods"]}),o=await this._handleResponse(n),r=null!==(t=n.headers.get("location"))&&void 0!==t?t:"",i=decodeURIComponent(r.split("/").pop()||"");return Object.assign(Object.assign({},o),{id:i,location:r})}async enrollmentVerify(t){const n=t,o=n.location;n.type;const r=e(n,["location","type"]),i=await this.myAccountFetcher.fetchWithAuth("".concat(o,"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},{scope:["create:me:authentication_methods"]});return this._handleResponse(i)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t);}catch(n){throw new It({type:"invalid_json",status:e.status,title:"Invalid JSON response",detail:t||String(n)})}if(e.ok)return t;throw new It(t)}}class It extends Error{constructor(e){let t=e.type,n=e.status,o=e.title,r=e.detail,i=e.validation_errors;super(r),this.name="MyAccountApiError",this.type=t,this.status=n,this.title=o,this.detail=r,this.validation_errors=i,Object.setPrototypeOf(this,It.prototype);}}const xt={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}},Rt="http://auth0.com/oauth/grant-type/mfa-otp",Ot="http://auth0.com/oauth/grant-type/mfa-oob",Ct="http://auth0.com/oauth/grant-type/mfa-recovery-code";var Wt,jt;let Kt;if("undefined"==typeof navigator||null===(Wt=navigator.userAgent)||void 0===Wt||null===(jt=Wt.startsWith)||void 0===jt||!jt.call(Wt,"Mozilla/5.0 ")){const e="v3.8.6";Kt="".concat("oauth4webapi","/").concat(e);}function Ut(e,t){if(null==e)return !1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch(e){return !1}}const Lt="ERR_INVALID_ARG_VALUE",Nt="ERR_INVALID_ARG_TYPE";function zt(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}const Dt=Symbol(),Jt=Symbol(),Mt=Symbol(),Ht=Symbol(),Zt=Symbol(),Ft=Symbol(),Vt=new TextEncoder,Xt=new TextDecoder;function Gt(e){return "string"==typeof e?Vt.encode(e):Xt.decode(e)}let Yt,Bt;if(Uint8Array.prototype.toBase64)Yt=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0}));else {const e=32768;Yt=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));const n=[];for(let o=0;o<t.byteLength;o+=e)n.push(String.fromCharCode.apply(null,t.subarray(o,o+e)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};}function qt(e){return "string"==typeof e?Bt(e):Yt(e)}Bt=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(e){throw zt("The input to be decoded is not correctly encoded.",Lt,e)}}:e=>{try{const t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch(e){throw zt("The input to be decoded is not correctly encoded.",Lt,e)}};class Qt extends Error{constructor(e,t){var n;super(e,t),d(this,"code",void 0),this.name=this.constructor.name,this.code=eo,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class $t extends Error{constructor(e,t){var n;super(e,t),d(this,"code",void 0),this.name=this.constructor.name,null!=t&&t.code&&(this.code=null==t?void 0:t.code),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function en(e,t,n){return new $t(e,{code:t,cause:n})}function tn(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw zt("".concat(t," must be a CryptoKey"),Nt)}(e,t),"private"!==e.type)throw zt("".concat(t," must be a private CryptoKey"),Lt)}function nn(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function on(e){Ut(e,Headers)&&(e=Object.fromEntries(e.entries()));const t=new Headers(null!=e?e:{});if(Kt&&!t.has("user-agent")&&t.set("user-agent",Kt),t.has("authorization"))throw zt('"options.headers" must not include the "authorization" header name',Lt);return t}function rn(e,t){if(void 0!==t){if("function"==typeof t&&(t=t(e.href)),!(t instanceof AbortSignal))throw zt('"options.signal" must return or be an instance of AbortSignal',Nt);return t}}function an(e){return e.includes("//")?e.replace("//","/"):e}async function sn(e,t){return async function(e,t,n,o){if(!(e instanceof URL))throw zt('"'.concat(t,'" must be an instance of URL'),Nt);kn(e,!0!==(null==o?void 0:o[Dt]));const r=n(new URL(e.href)),i=on(null==o?void 0:o.headers);return i.set("accept","application/json"),((null==o?void 0:o[Ht])||fetch)(r.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:rn(r,null==o?void 0:o.signal)})}(e,"issuerIdentifier",e=>{switch(null==t?void 0:t.algorithm){case void 0:case"oidc":!function(e,t){e.pathname=an("".concat(e.pathname,"/").concat(t));}(e,".well-known/openid-configuration");break;case"oauth2":!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"/"===e.pathname?e.pathname=t:e.pathname=an("".concat(t,"/").concat(n?e.pathname:e.pathname.replace(/(\/)$/,"")));}(e,".well-known/oauth-authorization-server");break;default:throw zt('"options.algorithm" must be "oidc" (default), or "oauth2"',Lt)}return e},t)}function cn(e,t,n,o,r){try{if("number"!=typeof e||!Number.isFinite(e))throw zt("".concat(n," must be a number"),Nt,r);if(e>0)return;if(t){if(0!==e)throw zt("".concat(n," must be a non-negative number"),Lt,r);return}throw zt("".concat(n," must be a positive number"),Lt,r)}catch(e){if(o)throw en(e.message,o,r);throw e}}function un(e,t,n,o){try{if("string"!=typeof e)throw zt("".concat(t," must be a string"),Nt,o);if(0===e.length)throw zt("".concat(t," must not be empty"),Lt,o)}catch(e){if(n)throw en(e.message,n,o);throw e}}function hn(e){!function(e,t){if(Un(e)!==t)throw function(e){let t='"response" content-type must be ';for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];if(o.length>2){const e=o.pop();t+="".concat(o.join(", "),", or ").concat(e);}else 2===o.length?t+="".concat(o[0]," or ").concat(o[1]):t+=o[0];return en(t,ro,e)}(e,t)}(e,"application/json");}function ln(){return qt(crypto.getRandomValues(new Uint8Array(32)))}function dn(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){switch(e.algorithm.hash.name){case"SHA-256":return "PS256";case"SHA-384":return "PS384";case"SHA-512":return "PS512";default:throw new Qt("unsupported RsaHashedKeyAlgorithm hash name",{cause:e})}}(e);case"RSASSA-PKCS1-v1_5":return function(e){switch(e.algorithm.hash.name){case"SHA-256":return "RS256";case"SHA-384":return "RS384";case"SHA-512":return "RS512";default:throw new Qt("unsupported RsaHashedKeyAlgorithm hash name",{cause:e})}}(e);case"ECDSA":return function(e){switch(e.algorithm.namedCurve){case"P-256":return "ES256";case"P-384":return "ES384";case"P-521":return "ES512";default:throw new Qt("unsupported EcKeyAlgorithm namedCurve",{cause:e})}}(e);case"Ed25519":case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return e.algorithm.name;case"EdDSA":return "Ed25519";default:throw new Qt("unsupported CryptoKey algorithm name",{cause:e})}}function pn(e){const t=null==e?void 0:e[Jt];return "number"==typeof t&&Number.isFinite(t)?t:0}function fn(e){const t=null==e?void 0:e[Mt];return "number"==typeof t&&Number.isFinite(t)&&-1!==Math.sign(t)?t:30}function mn(){return Math.floor(Date.now()/1e3)}function yn(e){if("object"!=typeof e||null===e)throw zt('"as" must be an object',Nt);un(e.issuer,'"as.issuer"');}function wn(e){if("object"!=typeof e||null===e)throw zt('"client" must be an object',Nt);un(e.client_id,'"client.client_id"');}function gn(e){return un(e,'"clientSecret"'),(t,n,o,r)=>{o.set("client_id",n.client_id),o.set("client_secret",e);}}function vn(e,t){const n=(i=e)instanceof CryptoKey?{key:i}:(null==i?void 0:i.key)instanceof CryptoKey?(void 0!==i.kid&&un(i.kid,'"kid"'),{key:i.key,kid:i.kid}):{},o=n.key,r=n.kid;var i;return tn(o,'"clientPrivateKey.key"'),async(e,n,i,a)=>{var s;const c={alg:dn(o),kid:r},u=function(e,t){const n=mn()+pn(t);return {jti:ln(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,n);null==t||null===(s=t[Zt])||void 0===s||s.call(t,c,u),i.set("client_id",n.client_id),i.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),i.set("client_assertion",await async function(e,t,n){if(!n.usages.includes("sign"))throw zt('CryptoKey instances used for signing assertions must include "sign" in their "usages"',Lt);const o="".concat(qt(Gt(JSON.stringify(e))),".").concat(qt(Gt(JSON.stringify(t)))),r=qt(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return {name:e.algorithm.name,hash:yo(e)};case"RSA-PSS":switch(mo(e),e.algorithm.hash.name){case"SHA-256":case"SHA-384":case"SHA-512":return {name:e.algorithm.name,saltLength:parseInt(e.algorithm.hash.name.slice(-3),10)>>3};default:throw new Qt("unsupported RSA-PSS hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":return mo(e),e.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return e.algorithm.name}throw new Qt("unsupported CryptoKey algorithm name",{cause:e})}(n),n,Gt(o)));return "".concat(o,".").concat(r)}(c,u,o));}}const bn=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch(e){return null}};function kn(e,t){if(t&&"https:"!==e.protocol)throw en("only requests to HTTPS are allowed",ao,e);if("https:"!==e.protocol&&"http:"!==e.protocol)throw en("only HTTP and HTTPS requests are allowed",so,e)}function _n(e,t,n,o){let r;if("string"!=typeof e||!(r=bn(e)))throw en("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),void 0===e?lo:po,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return kn(r,o),r}function Sn(e,t,n,o){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?_n(e.mtls_endpoint_aliases[t],t,n,o):_n(e[t],t,n,o)}class Tn extends Error{constructor(e,t){var n;super(e,t),d(this,"cause",void 0),d(this,"code",void 0),d(this,"error",void 0),d(this,"status",void 0),d(this,"error_description",void 0),d(this,"response",void 0),this.name=this.constructor.name,this.code=$n,this.cause=t.cause,this.error=t.cause.error,this.status=t.response.status,this.error_description=t.cause.error_description,Object.defineProperty(this,"response",{enumerable:!1,value:t.response}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}class Pn extends Error{constructor(e,t){var n,o;super(e,t),d(this,"cause",void 0),d(this,"code",void 0),d(this,"error",void 0),d(this,"error_description",void 0),this.name=this.constructor.name,this.code=to,this.cause=t.cause,this.error=t.cause.get("error"),this.error_description=null!==(n=t.cause.get("error_description"))&&void 0!==n?n:void 0,null===(o=Error.captureStackTrace)||void 0===o||o.call(Error,this,this.constructor);}}class En extends Error{constructor(e,t){var n;super(e,t),d(this,"cause",void 0),d(this,"code",void 0),d(this,"response",void 0),d(this,"status",void 0),this.name=this.constructor.name,this.code=Qn,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,"response",{enumerable:!1}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}const An="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",In="("+An+')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"',xn="("+An+")\\s*=\\s*("+An+")",Rn=new RegExp("^[,\\s]*("+An+")"),On=new RegExp("^[,\\s]*"+In+"[,\\s]*(.*)"),Cn=new RegExp("^[,\\s]*"+xn+"[,\\s]*(.*)"),Wn=new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function jn(e,t,n){if(e.status!==t){let t;var o;if(function(e){let t;if(t=function(e){if(!Ut(e,Response))throw zt('"response" must be an instance of Response',Nt);const t=e.headers.get("www-authenticate");if(null===t)return;const n=[];let o=t;for(;o;){var r;let e=o.match(Rn);const t=null===(r=e)||void 0===r?void 0:r[1].toLowerCase();if(!t)return;const c=o.substring(e[0].length);if(c&&!c.match(/^[\s,]/))return;const u=c.match(/^\s+(.*)$/),h=!!u;o=u?u[1]:void 0;const l={};let d;if(h)for(;o;){let t,n;if(e=o.match(On)){var i=y(e,4);if(t=i[1],n=i[2],o=i[3],n.includes("\\"))try{n=JSON.parse('"'.concat(n,'"'));}catch(e){}l[t.toLowerCase()]=n;}else {if(!(e=o.match(Cn))){if(e=o.match(Wn)){if(Object.keys(l).length)break;var a=y(e,3);d=a[1],o=a[2];break}return}var s=y(e,4);t=s[1],n=s[2],o=s[3],l[t.toLowerCase()]=n;}}else o=c||void 0;const p={scheme:t,parameters:l};d&&(p.token68=d),n.push(p);}return n.length?n:void 0}(e))throw new En("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}(e),t=await async function(e){if(e.status>399&&e.status<500){fo(e),hn(e);try{const t=await e.clone().json();if(nn(t)&&"string"==typeof t.error&&t.error.length)return t}catch(e){}}}(e))throw await(null===(o=e.body)||void 0===o?void 0:o.cancel()),new Tn("server responded with an error in the response body",{cause:t,response:e});throw en('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),io,e)}}function Kn(e){if(!Fn.has(e))throw zt('"options.DPoP" is not a valid DPoPHandle',Lt)}function Un(e){var t;return null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";")[0]}async function Ln(e,t,n,o,r,i,a){return await n(e,t,r,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((null==a?void 0:a[Ht])||fetch)(o.href,{body:r,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:rn(o,null==a?void 0:a.signal)})}async function Nn(e,t,n,o,r,i){var a;const s=Sn(e,"token_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[Dt]));r.set("grant_type",o);const c=on(null==i?void 0:i.headers);c.set("accept","application/json"),void 0!==(null==i?void 0:i.DPoP)&&(Kn(i.DPoP),await i.DPoP.addProof(s,c,"POST"));const u=await Ln(e,t,n,s,r,c,i);return null==i||null===(a=i.DPoP)||void 0===a||a.cacheNonce(u,s),u}const zn=new WeakMap,Dn=new WeakMap;function Jn(e){if(!e.id_token)return;const t=zn.get(e);if(!t)throw zt('"ref" was already garbage collected or did not resolve from the proper sources',Lt);return t}async function Mn(e,t,n,o,r,i){if(yn(e),wn(t),!Ut(n,Response))throw zt('"response" must be an instance of Response',Nt);await jn(n,200,"Token Endpoint"),fo(n);const a=await So(n);if(un(a.access_token,'"response" body "access_token" property',oo,{body:a}),un(a.token_type,'"response" body "token_type" property',oo,{body:a}),a.token_type=a.token_type.toLowerCase(),void 0!==a.expires_in){let e="number"!=typeof a.expires_in?parseFloat(a.expires_in):a.expires_in;cn(e,!0,'"response" body "expires_in" property',oo,{body:a}),a.expires_in=e;}if(void 0!==a.refresh_token&&un(a.refresh_token,'"response" body "refresh_token" property',oo,{body:a}),void 0!==a.scope&&"string"!=typeof a.scope)throw en('"response" body "scope" property must be a string',oo,{body:a});if(void 0!==a.id_token){un(a.id_token,'"response" body "id_token" property',oo,{body:a});const i=["aud","exp","iat","iss","sub"];!0===t.require_auth_time&&i.push("auth_time"),void 0!==t.default_max_age&&(cn(t.default_max_age,!0,'"client.default_max_age"'),i.push("auth_time")),null!=o&&o.length&&i.push(...o);const s=await async function(e,t,n,o,r){let i,a,s=e.split("."),c=s[0],u=s[1],h=s.length;if(5===h){if(void 0===r)throw new Qt("JWE decryption is not configured",{cause:e});var l=(e=await r(e)).split(".");c=l[0],u=l[1],h=l.length;}if(3!==h)throw en("Invalid JWT",oo,e);try{i=JSON.parse(Gt(qt(c)));}catch(e){throw en("failed to parse JWT Header body as base64url encoded JSON",no,e)}if(!nn(i))throw en("JWT Header must be a top level object",oo,e);if(t(i),void 0!==i.crit)throw new Qt('no JWT "crit" header parameter extensions are supported',{cause:{header:i}});try{a=JSON.parse(Gt(qt(u)));}catch(e){throw en("failed to parse JWT Payload body as base64url encoded JSON",no,e)}if(!nn(a))throw en("JWT Payload must be a top level object",oo,e);const d=mn()+n;if(void 0!==a.exp){if("number"!=typeof a.exp)throw en('unexpected JWT "exp" (expiration time) claim type',oo,{claims:a});if(a.exp<=d-o)throw en('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',co,{claims:a,now:d,tolerance:o,claim:"exp"})}if(void 0!==a.iat&&"number"!=typeof a.iat)throw en('unexpected JWT "iat" (issued at) claim type',oo,{claims:a});if(void 0!==a.iss&&"string"!=typeof a.iss)throw en('unexpected JWT "iss" (issuer) claim type',oo,{claims:a});if(void 0!==a.nbf){if("number"!=typeof a.nbf)throw en('unexpected JWT "nbf" (not before) claim type',oo,{claims:a});if(a.nbf>d+o)throw en('unexpected JWT "nbf" (not before) claim value',co,{claims:a,now:d,tolerance:o,claim:"nbf"})}if(void 0!==a.aud&&"string"!=typeof a.aud&&!Array.isArray(a.aud))throw en('unexpected JWT "aud" (audience) claim type',oo,{claims:a});return {header:i,claims:a,jwt:e}}(a.id_token,go.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),pn(t),fn(t),r).then(Gn.bind(void 0,i)).then(Zn.bind(void 0,e)).then(Hn.bind(void 0,t.client_id)),c=s.claims,u=s.jwt;if(Array.isArray(c.aud)&&1!==c.aud.length){if(void 0===c.azp)throw en('ID Token "aud" (audience) claim includes additional untrusted audiences',uo,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw en('unexpected ID Token "azp" (authorized party) claim value',uo,{expected:t.client_id,claims:c,claim:"azp"})}void 0!==c.auth_time&&cn(c.auth_time,!0,'ID Token "auth_time" (authentication time)',oo,{claims:c}),Dn.set(n,u),zn.set(a,c);}if(void 0!==(null==i?void 0:i[a.token_type]))i[a.token_type](n,a);else if("dpop"!==a.token_type&&"bearer"!==a.token_type)throw new Qt("unsupported `token_type` value",{cause:{body:a}});return a}function Hn(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw en('unexpected JWT "aud" (audience) claim value',uo,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw en('unexpected JWT "aud" (audience) claim value',uo,{expected:e,claims:t.claims,claim:"aud"});return t}function Zn(e,t){var n,o;const r=null!==(n=null===(o=e[Po])||void 0===o?void 0:o.call(e,t))&&void 0!==n?n:e.issuer;if(t.claims.iss!==r)throw en('unexpected JWT "iss" (issuer) claim value',uo,{expected:r,claims:t.claims,claim:"iss"});return t}const Fn=new WeakSet;const Vn=Symbol();const Xn={aud:"audience",c_hash:"code hash",client_id:"client id",exp:"expiration time",iat:"issued at",iss:"issuer",jti:"jwt id",nonce:"nonce",s_hash:"state hash",sub:"subject",ath:"access token hash",htm:"http method",htu:"http uri",cnf:"confirmation",auth_time:"authentication time"};function Gn(e,t){for(const n of e)if(void 0===t.claims[n])throw en('JWT "'.concat(n,'" (').concat(Xn[n],") claim missing"),oo,{claims:t.claims});return t}const Yn=Symbol(),Bn=Symbol();async function qn(e,t,n,o){return "string"==typeof(null==o?void 0:o.expectedNonce)||"number"==typeof(null==o?void 0:o.maxAge)||null!=o&&o.requireIdToken?async function(e,t,n,o,r,i,a){const s=[];switch(o){case void 0:o=Yn;break;case Yn:break;default:un(o,'"expectedNonce" argument'),s.push("nonce");}switch(null!=r||(r=t.default_max_age),r){case void 0:r=Bn;break;case Bn:break;default:cn(r,!0,'"maxAge" argument'),s.push("auth_time");}const c=await Mn(e,t,n,s,i,a);un(c.id_token,'"response" body "id_token" property',oo,{body:c});const u=Jn(c);if(r!==Bn){const e=mn()+pn(t),n=fn(t);if(u.auth_time+r<e-n)throw en("too much time has elapsed since the last End-User authentication",co,{claims:u,now:e,tolerance:n,claim:"auth_time"})}if(o===Yn){if(void 0!==u.nonce)throw en('unexpected ID Token "nonce" claim value',uo,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==o)throw en('unexpected ID Token "nonce" claim value',uo,{expected:o,claims:u,claim:"nonce"});return c}(e,t,n,o.expectedNonce,o.maxAge,o[Ft],o.recognizedTokenTypes):async function(e,t,n,o,r){const i=await Mn(e,t,n,void 0,o,r),a=Jn(i);if(a){if(void 0!==t.default_max_age){cn(t.default_max_age,!0,'"client.default_max_age"');const e=mn()+pn(t),n=fn(t);if(a.auth_time+t.default_max_age<e-n)throw en("too much time has elapsed since the last End-User authentication",co,{claims:a,now:e,tolerance:n,claim:"auth_time"})}if(void 0!==a.nonce)throw en('unexpected ID Token "nonce" claim value',uo,{expected:void 0,claims:a,claim:"nonce"})}return i}(e,t,n,null==o?void 0:o[Ft],null==o?void 0:o.recognizedTokenTypes)}const Qn="OAUTH_WWW_AUTHENTICATE_CHALLENGE",$n="OAUTH_RESPONSE_BODY_ERROR",eo="OAUTH_UNSUPPORTED_OPERATION",to="OAUTH_AUTHORIZATION_RESPONSE_ERROR",no="OAUTH_PARSE_ERROR",oo="OAUTH_INVALID_RESPONSE",ro="OAUTH_RESPONSE_IS_NOT_JSON",io="OAUTH_RESPONSE_IS_NOT_CONFORM",ao="OAUTH_HTTP_REQUEST_FORBIDDEN",so="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",co="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",uo="OAUTH_JWT_CLAIM_COMPARISON_FAILED",ho="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED",lo="OAUTH_MISSING_SERVER_METADATA",po="OAUTH_INVALID_SERVER_METADATA";function fo(e){if(e.bodyUsed)throw zt('"response" body has been used already',Lt)}function mo(e){const t=e.algorithm;if("number"!=typeof t.modulusLength||t.modulusLength<2048)throw new Qt("unsupported ".concat(t.name," modulusLength"),{cause:e})}function yo(e){switch(e.algorithm.namedCurve){case"P-256":return "SHA-256";case"P-384":return "SHA-384";case"P-521":return "SHA-512";default:throw new Qt("unsupported ECDSA namedCurve",{cause:e})}}async function wo(e){if("POST"!==e.method)throw zt("form_post responses are expected to use the POST method",Lt,{cause:e});if("application/x-www-form-urlencoded"!==Un(e))throw zt("form_post responses are expected to use the application/x-www-form-urlencoded content-type",Lt,{cause:e});return async function(e){if(e.bodyUsed)throw zt("form_post Request instances must contain a readable body",Lt,{cause:e});return e.text()}(e)}function go(e,t,n,o){if(void 0===e)if(Array.isArray(t)){if(!t.includes(o.alg))throw en('unexpected JWT "alg" header parameter',oo,{header:o,expected:t,reason:"authorization server metadata"})}else {if(void 0===n)throw en('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n});if("string"==typeof n?o.alg!==n:"function"==typeof n?!n(o.alg):!n.includes(o.alg))throw en('unexpected JWT "alg" header parameter',oo,{header:o,expected:n,reason:"default value"})}else if("string"==typeof e?o.alg!==e:!e.includes(o.alg))throw en('unexpected JWT "alg" header parameter',oo,{header:o,expected:e,reason:"client configuration"})}function vo(e,t){const n=e.getAll(t),o=n[0];if(n.length>1)throw en('"'.concat(t,'" parameter must be provided only once'),oo);return o}const bo=Symbol(),ko=Symbol();function _o(e,t,n,o){if(yn(e),wn(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw zt('"parameters" must be an instance of URLSearchParams, or URL',Nt);if(vo(n,"response"))throw en('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',oo,{parameters:n});const r=vo(n,"iss"),i=vo(n,"state");if(!r&&e.authorization_response_iss_parameter_supported)throw en('response parameter "iss" (issuer) missing',oo,{parameters:n});if(r&&r!==e.issuer)throw en('unexpected "iss" (issuer) response parameter value',oo,{expected:e.issuer,parameters:n});switch(o){case void 0:case ko:if(void 0!==i)throw en('unexpected "state" response parameter encountered',oo,{expected:void 0,parameters:n});break;case bo:break;default:if(un(o,'"expectedState" argument'),i!==o)throw en(void 0===i?'response parameter "state" missing':'unexpected "state" response parameter value',oo,{expected:o,parameters:n})}if(vo(n,"error"))throw new Pn("authorization response from the server is an error",{cause:n});const a=vo(n,"id_token"),s=vo(n,"token");if(void 0!==a||void 0!==s)throw new Qt("implicit and hybrid flows are not supported");return c=new URLSearchParams(n),Fn.add(c),c;var c;}async function So(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:hn;try{t=await e.json();}catch(t){throw n(e),en('failed to parse "response" body as JSON',no,t)}if(!nn(t))throw en('"response" body must be a top level object',oo,{body:t});return t}const To=Symbol(),Po=Symbol(),Eo=new TextEncoder,Ao=new TextDecoder;function Io(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const o=t.reduce((e,t)=>e+t.length,0),r=new Uint8Array(o);let i=0;for(const e of t)r.set(e,i),i+=e.length;return r}function xo(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);if(o>127)throw new TypeError("non-ASCII string encountered in encode()");t[n]=o;}return t}function Ro(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Oo(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof e?e:Ao.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=Ao.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/");try{return Ro(t)}catch(e){throw new TypeError("The input to be decoded is not correctly encoded.")}}function Co(e){let t=e;return "string"==typeof t&&(t=Eo.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:"base64url",omitPadding:!0}):function(e){if(Uint8Array.prototype.toBase64)return e.toBase64();const t=[];for(let n=0;n<e.length;n+=32768)t.push(String.fromCharCode.apply(null,e.subarray(n,n+32768)));return btoa(t.join(""))}(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}const Wo=function(e){return new TypeError("CryptoKey does not support this operation, its ".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"algorithm.name"," must be ").concat(e))},jo=(e,t)=>e.name===t;function Ko(e,t){var n;if((n=e.hash,parseInt(n.name.slice(4),10))!==t)throw Wo("SHA-".concat(t),"algorithm.hash")}function Uo(e,t,n){switch(t){case"HS256":case"HS384":case"HS512":if(!jo(e.algorithm,"HMAC"))throw Wo("HMAC");Ko(e.algorithm,parseInt(t.slice(2),10));break;case"RS256":case"RS384":case"RS512":if(!jo(e.algorithm,"RSASSA-PKCS1-v1_5"))throw Wo("RSASSA-PKCS1-v1_5");Ko(e.algorithm,parseInt(t.slice(2),10));break;case"PS256":case"PS384":case"PS512":if(!jo(e.algorithm,"RSA-PSS"))throw Wo("RSA-PSS");Ko(e.algorithm,parseInt(t.slice(2),10));break;case"Ed25519":case"EdDSA":if(!jo(e.algorithm,"Ed25519"))throw Wo("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":if(!jo(e.algorithm,t))throw Wo(t);break;case"ES256":case"ES384":case"ES512":{if(!jo(e.algorithm,"ECDSA"))throw Wo("ECDSA");const n=function(e){switch(e){case"ES256":return "P-256";case"ES384":return "P-384";case"ES512":return "P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==n)throw Wo(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}!function(e,t){if(t&&!e.usages.includes(t))throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(t,"."))}(e,n);}function Lo(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];if((o=o.filter(Boolean)).length>2){const t=o.pop();e+="one of type ".concat(o.join(", "),", or ").concat(t,".");}else 2===o.length?e+="one of type ".concat(o[0]," or ").concat(o[1],"."):e+="of type ".concat(o[0],".");if(null==t)e+=" Received ".concat(t);else if("function"==typeof t&&t.name)e+=" Received function ".concat(t.name);else if("object"==typeof t&&null!=t){var i;null!==(i=t.constructor)&&void 0!==i&&i.name&&(e+=" Received an instance of ".concat(t.constructor.name));}return e}const No=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return Lo("Key for the ".concat(e," algorithm must be "),t,...o)};class zo extends Error{constructor(e,t){var n;super(e,t),d(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}d(zo,"code","ERR_JOSE_GENERIC");class Do extends zo{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),d(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),d(this,"claim",void 0),d(this,"reason",void 0),d(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}d(Do,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class Jo extends zo{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:o,payload:t}}),d(this,"code","ERR_JWT_EXPIRED"),d(this,"claim",void 0),d(this,"reason",void 0),d(this,"payload",void 0),this.claim=n,this.reason=o,this.payload=t;}}d(Jo,"code","ERR_JWT_EXPIRED");class Mo extends zo{constructor(){super(...arguments),d(this,"code","ERR_JOSE_ALG_NOT_ALLOWED");}}d(Mo,"code","ERR_JOSE_ALG_NOT_ALLOWED");class Ho extends zo{constructor(){super(...arguments),d(this,"code","ERR_JOSE_NOT_SUPPORTED");}}d(Ho,"code","ERR_JOSE_NOT_SUPPORTED");d(class extends zo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWE_DECRYPTION_FAILED");}},"code","ERR_JWE_DECRYPTION_FAILED");d(class extends zo{constructor(){super(...arguments),d(this,"code","ERR_JWE_INVALID");}},"code","ERR_JWE_INVALID");class Zo extends zo{constructor(){super(...arguments),d(this,"code","ERR_JWS_INVALID");}}d(Zo,"code","ERR_JWS_INVALID");class Fo extends zo{constructor(){super(...arguments),d(this,"code","ERR_JWT_INVALID");}}d(Fo,"code","ERR_JWT_INVALID");d(class extends zo{constructor(){super(...arguments),d(this,"code","ERR_JWK_INVALID");}},"code","ERR_JWK_INVALID");class Vo extends zo{constructor(){super(...arguments),d(this,"code","ERR_JWKS_INVALID");}}d(Vo,"code","ERR_JWKS_INVALID");class Xo extends zo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"no applicable key found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWKS_NO_MATCHING_KEY");}}d(Xo,"code","ERR_JWKS_NO_MATCHING_KEY");class Go extends zo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"multiple matching keys found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),d(this,Symbol.asyncIterator,void 0),d(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");}}d(Go,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class Yo extends zo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWKS_TIMEOUT");}}d(Yo,"code","ERR_JWKS_TIMEOUT");class Bo extends zo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),d(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");}}d(Bo,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const qo=e=>{if("CryptoKey"===(null==e?void 0:e[Symbol.toStringTag]))return !0;try{return e instanceof CryptoKey}catch(e){return !1}},Qo=e=>"KeyObject"===(null==e?void 0:e[Symbol.toStringTag]),$o=e=>qo(e)||Qo(e);function er(e,t){if(e)throw new TypeError("".concat(t," can only be called once"))}function tr(e,t,n){try{return Oo(e)}catch(e){throw new n("Failed to base64url decode the ".concat(t))}}function nr(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return !1;var t;if(null===Object.getPrototypeOf(e))return !0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}function or(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const o=t.filter(Boolean);if(0===o.length||1===o.length)return !0;let r;for(const e of o){const t=Object.keys(e);if(r&&0!==r.size)for(const e of t){if(r.has(e))return !1;r.add(e);}else r=new Set(t);}return !0}const rr=e=>nr(e)&&"string"==typeof e.kty;function ir(e,t){if(e.startsWith("RS")||e.startsWith("PS")){const n=t.algorithm.modulusLength;if("number"!=typeof n||n<2048)throw new TypeError("".concat(e," requires key modulusLength to be 2048 bits or larger"))}}function ar(e,t){const n="SHA-".concat(e.slice(-3));switch(e){case"HS256":case"HS384":case"HS512":return {hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return {hash:n,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return {hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return {hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return {name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return {name:e};default:throw new Ho("alg ".concat(e," is not supported either by JOSE or your javascript runtime"))}}async function sr(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return Lo("Key must be ",e,...n)}(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:"SHA-".concat(e.slice(-3)),name:"HMAC"},!1,[n])}return Uo(t,e,n),t}const cr='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function ur(e){var t,n;if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const o=function(e){let t,n;switch(e.kty){case"AKP":switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},n=e.priv?["sign"]:["verify"];break;default:throw new Ho(cr)}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:"SHA-".concat(e.alg.slice(-3))},n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(e.alg.slice(-3))},n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(e.alg.slice(-3),10)||1)},n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new Ho(cr)}break;case"EC":switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[e.alg]},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new Ho(cr)}break;case"OKP":switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new Ho(cr)}break;default:throw new Ho('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return {algorithm:t,keyUsages:n}}(e),r=o.algorithm,i=o.keyUsages,a=f({},e);return "AKP"!==a.kty&&delete a.alg,delete a.use,crypto.subtle.importKey("jwk",a,r,null!==(t=e.ext)&&void 0!==t?t:!e.d&&!e.priv,null!==(n=e.key_ops)&&void 0!==n?n:i)}const hr="given KeyObject instance cannot be used for this algorithm";let lr;const dr=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];lr||(lr=new WeakMap);let r=lr.get(e);if(null!=r&&r[n])return r[n];const i=await ur(f(f({},t),{},{alg:n}));return o&&Object.freeze(e),r?r[n]=i:lr.set(e,{[n]:i}),i};async function pr(e,t){if(e instanceof Uint8Array)return e;if(qo(e))return e;if(Qo(e)){if("secret"===e.type)return e.export();if("toCryptoKey"in e&&"function"==typeof e.toCryptoKey)try{return ((e,t)=>{lr||(lr=new WeakMap);let n=lr.get(e);if(null!=n&&n[t])return n[t];const o="public"===e.type,r=!!o;let i;if("x25519"===e.asymmetricKeyType){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError(hr)}i=e.toCryptoKey(e.asymmetricKeyType,r,o?[]:["deriveBits"]);}if("ed25519"===e.asymmetricKeyType){if("EdDSA"!==t&&"Ed25519"!==t)throw new TypeError(hr);i=e.toCryptoKey(e.asymmetricKeyType,r,[o?"verify":"sign"]);}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(t!==e.asymmetricKeyType.toUpperCase())throw new TypeError(hr);i=e.toCryptoKey(e.asymmetricKeyType,r,[o?"verify":"sign"]);}if("rsa"===e.asymmetricKeyType){let n;switch(t){case"RSA-OAEP":n="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":n="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":n="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":n="SHA-512";break;default:throw new TypeError(hr)}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:n},r,o?["encrypt"]:["decrypt"]);i=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:n},r,[o?"verify":"sign"]);}if("ec"===e.asymmetricKeyType){var a;const n=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(null===(a=e.asymmetricKeyDetails)||void 0===a?void 0:a.namedCurve);if(!n)throw new TypeError(hr);const s={ES256:"P-256",ES384:"P-384",ES512:"P-521"};s[t]&&n===s[t]&&(i=e.toCryptoKey({name:"ECDSA",namedCurve:n},r,[o?"verify":"sign"])),t.startsWith("ECDH-ES")&&(i=e.toCryptoKey({name:"ECDH",namedCurve:n},r,o?[]:["deriveBits"]));}if(!i)throw new TypeError(hr);return n?n[t]=i:lr.set(e,{[t]:i}),i})(e,t)}catch(e){if(e instanceof TypeError)throw e}let n=e.export({format:"jwk"});return dr(e,n,t)}if(rr(e))return e.k?Oo(e.k):dr(e,e,t,!0);throw new Error("unreachable")}const fr=(e,t)=>{if(e.byteLength!==t.length)return !1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return !1;return !0},mr=e=>{const t=e.data[e.pos++];if(128&t){const n=127&t;let o=0;for(let t=0;t<n;t++)o=o<<8|e.data[e.pos++];return o}return t},yr=(e,t,n)=>{if(e.data[e.pos++]!==t)throw new Error(n)},wr=(e,t)=>{const n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n};const gr=e=>{const t=(e=>{yr(e,6,"Expected algorithm OID");const t=mr(e);return wr(e,t)})(e);if(fr(t,[43,101,110]))return "X25519";if(!fr(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");yr(e,6,"Expected curve OID");const n=mr(e),o=wr(e,n);for(const e of [{name:"P-256",oid:[42,134,72,206,61,3,1,7]},{name:"P-384",oid:[43,129,4,0,34]},{name:"P-521",oid:[43,129,4,0,35]}]){const t=e.name,n=e.oid;if(fr(o,n))return t}throw new Error("Unsupported named curve")},vr=async(e,t,n,o)=>{var r;let i,a;const s="spki"===e,c=()=>s?["verify"]:["sign"];switch(n){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(n.slice(-3),10)||1)},a=s?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":case"ES384":case"ES512":i={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[n]},a=c();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{const e=o.getNamedCurve(t);i="X25519"===e?{name:"X25519"}:{name:"ECDH",namedCurve:e};}catch(e){throw new Ho("Invalid or unsupported key format")}a=s?[]:["deriveBits"];break;case"Ed25519":case"EdDSA":i={name:"Ed25519"},a=c();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:n},a=c();break;default:throw new Ho('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(e,t,i,null!==(r=null==o?void 0:o.extractable)&&void 0!==r?r:!!s,a)},br=(e,t,n)=>{var o;const r=((e,t)=>Ro(e.replace(t,"")))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);let i=n;return null!=t&&null!==(o=t.startsWith)&&void 0!==o&&o.call(t,"ECDH-ES")&&(i||(i={}),i.getNamedCurve=e=>{const t={data:e,pos:0};return function(e){yr(e,48,"Invalid PKCS#8 structure"),mr(e),yr(e,2,"Expected version field");const t=mr(e);e.pos+=t,yr(e,48,"Expected algorithm identifier");mr(e);e.pos;}(t),gr(t)}),vr("pkcs8",r,t,i)};async function kr(e,t,n){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return br(e,t,n)}function _r(e,t,n,o,r){if(void 0!==r.crit&&void 0===(null==o?void 0:o.crit))throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!o||void 0===o.crit)return new Set;if(!Array.isArray(o.crit)||0===o.crit.length||o.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;i=void 0!==n?new Map([...Object.entries(n),...t.entries()]):t;for(const t of o.crit){if(!i.has(t))throw new Ho('Extension Header Parameter "'.concat(t,'" is not recognized'));if(void 0===r[t])throw new e('Extension Header Parameter "'.concat(t,'" is missing'));if(i.get(t)&&void 0===o[t])throw new e('Extension Header Parameter "'.concat(t,'" MUST be integrity protected'))}return new Set(o.crit)}const Sr=e=>null==e?void 0:e[Symbol.toStringTag],Tr=(e,t,n)=>{if(void 0!==t.use){let e;switch(n){case"sign":case"verify":e="sig";break;case"encrypt":case"decrypt":e="enc";}if(t.use!==e)throw new TypeError('Invalid key for this operation, its "use" must be "'.concat(e,'" when present'))}if(void 0!==t.alg&&t.alg!==e)throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(e,'" when present'));if(Array.isArray(t.key_ops)){var o,r;let i;switch(!0){case"sign"===n||"verify"===n:case"dir"===e:case e.includes("CBC-HS"):i=n;break;case e.startsWith("PBES2"):i="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):i=!e.includes("GCM")&&e.endsWith("KW")?"encrypt"===n?"wrapKey":"unwrapKey":n;break;case"encrypt"===n&&e.startsWith("RSA"):i="wrapKey";break;case"decrypt"===n:i=e.startsWith("RSA")?"unwrapKey":"deriveBits";}if(i&&!1===(null===(o=t.key_ops)||void 0===o||null===(r=o.includes)||void 0===r?void 0:r.call(o,i)))throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(i,'" when present'))}return !0};function Pr(e,t,n){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((e,t,n)=>{if(!(t instanceof Uint8Array)){if(rr(t)){if((e=>"oct"===e.kty&&"string"==typeof e.k)(t)&&Tr(e,t,n))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!$o(t))throw new TypeError(No(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==t.type)throw new TypeError("".concat(Sr(t),' instances for symmetric algorithms must be of type "secret"'))}})(e,t,n);break;default:((e,t,n)=>{if(rr(t))switch(n){case"decrypt":case"sign":if((e=>"oct"!==e.kty&&("AKP"===e.kty&&"string"==typeof e.priv||"string"==typeof e.d))(t)&&Tr(e,t,n))return;throw new TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if((e=>"oct"!==e.kty&&void 0===e.d&&void 0===e.priv)(t)&&Tr(e,t,n))return;throw new TypeError("JSON Web Key for this operation must be a public JWK")}if(!$o(t))throw new TypeError(No(e,t,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===t.type)throw new TypeError("".concat(Sr(t),' instances for asymmetric algorithms must not be of type "secret"'));if("public"===t.type)switch(n){case"sign":throw new TypeError("".concat(Sr(t),' instances for asymmetric algorithm signing must be of type "private"'));case"decrypt":throw new TypeError("".concat(Sr(t),' instances for asymmetric algorithm decryption must be of type "private"'))}if("private"===t.type)switch(n){case"verify":throw new TypeError("".concat(Sr(t),' instances for asymmetric algorithm verifying must be of type "public"'));case"encrypt":throw new TypeError("".concat(Sr(t),' instances for asymmetric algorithm encryption must be of type "public"'))}})(e,t,n);}}var Er,Ar;let Ir,xr;if("undefined"==typeof navigator||null===(Er=navigator.userAgent)||void 0===Er||null===(Ar=Er.startsWith)||void 0===Ar||!Ar.call(Er,"Mozilla/5.0 ")){const e="v6.8.4";xr="".concat("openid-client","/").concat(e),Ir={"user-agent":xr};}const Rr=e=>Or.get(e);let Or,Cr;function Wr(e){return void 0!==e?gn(e):(Cr||(Cr=new WeakMap),(e,t,n,o)=>{let r;return (r=Cr.get(t))||(!function(e,t){if("string"!=typeof e)throw Lr("".concat(t," must be a string"),Ur);if(0===e.length)throw Lr("".concat(t," must not be empty"),Kr)}(t.client_secret,'"metadata.client_secret"'),r=gn(t.client_secret),Cr.set(t,r)),r(e,t,n,o)})}const jr=Ht,Kr="ERR_INVALID_ARG_VALUE",Ur="ERR_INVALID_ARG_TYPE";function Lr(e,t,n){const o=new TypeError(e,{cause:n});return Object.assign(o,{code:t}),o}function Nr(e){return async function(e){return un(e,"codeVerifier"),qt(await crypto.subtle.digest("SHA-256",Gt(e)))}(e)}function zr(){return ln()}class Dr extends Error{constructor(e,t){var n;super(e,t),d(this,"code",void 0),this.name=this.constructor.name,this.code=null==t?void 0:t.code,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor);}}function Jr(e,t,n){return new Dr(e,{cause:t,code:n})}function Mr(e){if(e instanceof TypeError||e instanceof Dr||e instanceof Tn||e instanceof Pn||e instanceof En)throw e;if(e instanceof $t)switch(e.code){case ao:throw Jr("only requests to HTTPS are allowed",e,e.code);case so:throw Jr("only requests to HTTP or HTTPS are allowed",e,e.code);case io:throw Jr("unexpected HTTP response status code",e.cause,e.code);case ro:throw Jr("unexpected response content-type",e.cause,e.code);case no:throw Jr("parsing error occured",e,e.code);case oo:throw Jr("invalid response encountered",e,e.code);case uo:throw Jr("unexpected JWT claim value encountered",e,e.code);case ho:throw Jr("unexpected JSON attribute value encountered",e,e.code);case co:throw Jr("JWT timestamp claim value failed validation",e,e.code);default:throw Jr(e.message,e,e.code)}if(e instanceof Qt)throw Jr("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw Jr("runtime operation error",e,eo);case"NotSupportedError":throw Jr("runtime unsupported operation",e,eo);case"TimeoutError":throw Jr("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw Jr("operation aborted",e,"OAUTH_ABORT")}throw new Dr("something went wrong",{cause:e})}async function Hr(e,t,n,o,r){const i=await async function(e,t){var n,o;if(!(e instanceof URL))throw Lr('"server" must be an instance of URL',Ur);const r=!e.href.includes("/.well-known/"),i=null!==(n=null==t?void 0:t.timeout)&&void 0!==n?n:30,a=AbortSignal.timeout(1e3*i),s=await(r?sn(e,{algorithm:null==t?void 0:t.algorithm,[Ht]:null==t?void 0:t[jr],[Dt]:null==t||null===(o=t.execute)||void 0===o?void 0:o.includes(qr),signal:a,headers:new Headers(Ir)}):((null==t?void 0:t[jr])||fetch)((kn(e,null==t||null===(c=t.execute)||void 0===c||!c.includes(qr)),e.href),{headers:Object.fromEntries(new Headers(f({accept:"application/json"},Ir)).entries()),body:void 0,method:"GET",redirect:"manual",signal:a})).then(e=>async function(e,t){const n=e;if(!(n instanceof URL)&&n!==To)throw zt('"expectedIssuerIdentifier" must be an instance of URL',Nt);if(!Ut(t,Response))throw zt('"response" must be an instance of Response',Nt);if(200!==t.status)throw en('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',io,t);fo(t);const o=await So(t);if(un(o.issuer,'"response" body "issuer" property',oo,{body:o}),n!==To&&new URL(o.issuer).href!==n.href)throw en('"response" body "issuer" property does not match the expected value',ho,{expected:n.href,body:o,attribute:"issuer"});return o}(To,e)).catch(Mr);var c;r&&new URL(s.issuer).href!==e.href&&(function(e,t,n){return !("https://login.microsoftonline.com"!==e.origin||null!=n&&n.algorithm&&"oidc"!==n.algorithm||(t[Zr]=!0,0))}(e,s,t)||function(e,t){return !(!e.hostname.endsWith(".b2clogin.com")||null!=t&&t.algorithm&&"oidc"!==t.algorithm)}(e,t)||(()=>{throw new Dr("discovered metadata issuer does not match the expected issuer",{code:ho,cause:{expected:e.href,body:s,attribute:"issuer"}})})());return s}(e,r),a=new Fr(i,t,n,o);let s=Rr(a);if(null!=r&&r[jr]&&(s.fetch=r[jr]),null!=r&&r.timeout&&(s.timeout=r.timeout),null!=r&&r.execute)for(const e of r.execute)e(a);return a}new TextDecoder;const Zr=Symbol();class Fr{constructor(e,t,n,o){var r,i,a,s,c;if("string"!=typeof t||!t.length)throw Lr('"clientId" must be a non-empty string',Ur);if("string"==typeof n&&(n={client_secret:n}),void 0!==(null===(r=n)||void 0===r?void 0:r.client_id)&&t!==n.client_id)throw Lr('"clientId" and "metadata.client_id" must be the same',Kr);const u=f(f({},structuredClone(n)),{},{client_id:t});let h;u[Jt]=null!==(i=null===(a=n)||void 0===a?void 0:a[Jt])&&void 0!==i?i:0,u[Mt]=null!==(s=null===(c=n)||void 0===c?void 0:c[Mt])&&void 0!==s?s:30,h=o||("string"==typeof u.client_secret&&u.client_secret.length?Wr(u.client_secret):(e,t,n,o)=>{n.set("client_id",t.client_id);});let l=Object.freeze(u);const d=structuredClone(e);Zr in e&&(d[Po]=t=>{let n=t.claims.tid;return e.issuer.replace("{tenantid}",n)});let p=Object.freeze(d);Or||(Or=new WeakMap),Or.set(this,{__proto__:null,as:p,c:l,auth:h,tlsOnly:!0,jwksCache:{}});}serverMetadata(){const e=structuredClone(Rr(this).as);return function(e){Object.defineProperties(e,function(e){return {supportsPKCE:{__proto__:null,value(){var t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"S256";return !0===(null===(t=e.code_challenge_methods_supported)||void 0===t?void 0:t.includes(n))}}}}(e));}(e),e}clientMetadata(){return structuredClone(Rr(this).c)}get timeout(){return Rr(this).timeout}set timeout(e){Rr(this).timeout=e;}get[jr](){return Rr(this).fetch}set[jr](e){Rr(this).fetch=e;}}function Vr(e){Object.defineProperties(e,function(e){let t;if(void 0!==e.expires_in){const n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime();}return {expiresIn:{__proto__:null,value(){if(t){const e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return Jn(this)}catch(e){return}}}}}(e));}async function Xr(e,t,n){var o;let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=null===(o=e.headers.get("retry-after"))||void 0===o?void 0:o.trim();if(void 0===i)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else {const e=new Date(i);if(Number.isFinite(e.getTime())){const t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3));}}if(r&&!Number.isFinite(a))throw new $t("invalid Retry-After header value",{cause:e});a>t&&await Gr(a-t,n);}function Gr(e,t){return new Promise((n,o)=>{const r=e=>{try{t.throwIfAborted();}catch(e){return void o(e)}if(e<=0)return void n();const i=Math.min(e,5);setTimeout(()=>r(e-i),1e3*i);};r(e);})}async function Yr(e,t){oi(e);const n=Rr(e),o=n.as,r=n.c,i=n.auth,a=n.fetch,s=n.tlsOnly,c=n.timeout;return async function(e,t,n,o,r){yn(e),wn(t);const i=Sn(e,"backchannel_authentication_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Dt])),a=new URLSearchParams(o);a.set("client_id",t.client_id);const s=on(null==r?void 0:r.headers);return s.set("accept","application/json"),Ln(e,t,n,i,a,s,r)}(o,r,i,t,{[Ht]:a,[Dt]:!s,headers:new Headers(Ir),signal:ri(c)}).then(e=>async function(e,t,n){if(yn(e),wn(t),!Ut(n,Response))throw zt('"response" must be an instance of Response',Nt);await jn(n,200,"Backchannel Authentication Endpoint"),fo(n);const o=await So(n);un(o.auth_req_id,'"response" body "auth_req_id" property',oo,{body:o});let r="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return cn(r,!0,'"response" body "expires_in" property',oo,{body:o}),o.expires_in=r,void 0!==o.interval&&cn(o.interval,!1,'"response" body "interval" property',oo,{body:o}),o}(o,r,e)).catch(Mr)}async function Br(e,t,n,o){var r,i;oi(e),n=new URLSearchParams(n);let a=null!==(r=t.interval)&&void 0!==r?r:5;const s=null!==(i=null==o?void 0:o.signal)&&void 0!==i?i:AbortSignal.timeout(1e3*t.expires_in);try{await Gr(a,s);}catch(e){Mr(e);}const c=Rr(e),u=c.as,h=c.c,l=c.auth,d=c.fetch,p=c.tlsOnly,m=c.nonRepudiation,y=c.timeout,w=c.decrypt,g=(r,i)=>Br(e,f(f({},t),{},{interval:r}),n,f(f({},o),{},{signal:s,flag:i})),v=function(e,t){const n=ri(t);if(!n)return {signal:e,cleanup(){}};const o=new AbortController,r=e=>{const t=e.target;o.abort(t.reason);};return e.aborted?o.abort(e.reason):n.aborted?o.abort(n.reason):(e.addEventListener("abort",r,{once:!0}),n.addEventListener("abort",r,{once:!0})),{signal:o.signal,cleanup(){e.removeEventListener("abort",r),n.removeEventListener("abort",r);}}}(s,y),b=await async function(e,t,n,o,r){yn(e),wn(t),un(o,'"authReqId"');const i=new URLSearchParams(null==r?void 0:r.additionalParameters);return i.set("auth_req_id",o),Nn(e,t,n,"urn:openid:params:grant-type:ciba",i,r)}(u,h,l,t.auth_req_id,{[Ht]:d,[Dt]:!p,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Ir),signal:v.signal}).catch(Mr).finally(v.cleanup);var k;if(503===b.status&&b.headers.has("retry-after"))return await Xr(b,a,s,!0),await(null===(k=b.body)||void 0===k?void 0:k.cancel()),g(a);const _=async function(e,t,n,o){return Mn(e,t,n,void 0,null==o?void 0:o[Ft],null==o?void 0:o.recognizedTokenTypes)}(u,h,b,{[Ft]:w});let S;try{S=await _;}catch(e){if(ii(e,o))return g(a,ai);if(e instanceof Tn)switch(e.error){case"slow_down":a+=5;case"authorization_pending":return await Xr(e.response,a,s),g(a)}Mr(e);}return S.id_token&&await(null==m?void 0:m(b)),Vr(S),S}function qr(e){Rr(e).tlsOnly=!1;}async function Qr(e,t,n,o,r){if(oi(e),!((null==r?void 0:r.flag)===ai||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch(e){return !1}}(t,"Request")))throw Lr('"currentUrl" must be an instance of URL, or Request',Ur);let i,a;const s=Rr(e),c=s.as,u=s.c,h=s.auth,l=s.fetch,d=s.tlsOnly,p=s.jarm,m=s.hybrid,w=s.nonRepudiation,g=s.timeout,v=s.decrypt,b=s.implicit;if((null==r?void 0:r.flag)===ai)i=r.authResponse,a=r.redirectUri;else {if(!(t instanceof URL)){const e=t;switch(t=new URL(t.url),e.method){case"GET":break;case"POST":const n=new URLSearchParams(await wo(e));if(m)t.hash=n.toString();else for(const e of n.entries()){var k=y(e,2);const n=k[0],o=k[1];t.searchParams.append(n,o);}break;default:throw Lr("unexpected Request HTTP method",Kr)}}switch(a=function(e){return (e=new URL(e)).search="",e.hash="",e.href}(t),!0){case!!p:i=await p(t,null==n?void 0:n.expectedState);break;case!!m:i=await m(t,null==n?void 0:n.expectedNonce,null==n?void 0:n.expectedState,null==n?void 0:n.maxAge);break;case!!b:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=_o(c,u,t.searchParams,null==n?void 0:n.expectedState);}catch(e){Mr(e);}}}const _=await async function(e,t,n,o,r,i,a){if(yn(e),wn(t),!Fn.has(o))throw zt('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',Lt);un(r,'"redirectUri"');const s=vo(o,"code");if(!s)throw en('no authorization code in "callbackParameters"',oo);const c=new URLSearchParams(null==a?void 0:a.additionalParameters);return c.set("redirect_uri",r),c.set("code",s),i!==Vn&&(un(i,'"codeVerifier"'),c.set("code_verifier",i)),Nn(e,t,n,"authorization_code",c,a)}(c,u,h,i,a,(null==n?void 0:n.pkceCodeVerifier)||Vn,{additionalParameters:o,[Ht]:l,[Dt]:!d,DPoP:null==r?void 0:r.DPoP,headers:new Headers(Ir),signal:ri(g)}).catch(Mr);"string"!=typeof(null==n?void 0:n.expectedNonce)&&"number"!=typeof(null==n?void 0:n.maxAge)||(n.idTokenExpected=!0);const S=qn(c,u,_,{expectedNonce:null==n?void 0:n.expectedNonce,maxAge:null==n?void 0:n.maxAge,requireIdToken:null==n?void 0:n.idTokenExpected,[Ft]:v});let T;try{T=await S;}catch(t){if(ii(t,r))return Qr(e,void 0,n,o,f(f({},r),{},{flag:ai,authResponse:i,redirectUri:a}));Mr(t);}return T.id_token&&await(null==w?void 0:w(_)),Vr(T),T}async function $r(e,t,n,o){oi(e),n=new URLSearchParams(n);const r=Rr(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,h=r.nonRepudiation,l=r.timeout,d=r.decrypt,p=await async function(e,t,n,o,r){yn(e),wn(t),un(o,'"refreshToken"');const i=new URLSearchParams(null==r?void 0:r.additionalParameters);return i.set("refresh_token",o),Nn(e,t,n,"refresh_token",i,r)}(i,a,s,t,{[Ht]:c,[Dt]:!u,additionalParameters:n,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Ir),signal:ri(l)}).catch(Mr),m=async function(e,t,n,o){return Mn(e,t,n,void 0,null==o?void 0:o[Ft],null==o?void 0:o.recognizedTokenTypes)}(i,a,p,{[Ft]:d});let y;try{y=await m;}catch(r){if(ii(r,o))return $r(e,t,n,f(f({},o),{},{flag:ai}));Mr(r);}return y.id_token&&await(null==h?void 0:h(p)),Vr(y),y}async function ei(e,t,n){oi(e),t=new URLSearchParams(t);const o=Rr(e),r=o.as,i=o.c,a=o.auth,s=o.fetch,c=o.tlsOnly,u=o.timeout,h=await async function(e,t,n,o,r){return yn(e),wn(t),Nn(e,t,n,"client_credentials",new URLSearchParams(o),r)}(r,i,a,t,{[Ht]:s,[Dt]:!c,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Ir),signal:ri(u)}).catch(Mr),l=async function(e,t,n,o){return Mn(e,t,n,void 0,null==o?void 0:o[Ft],null==o?void 0:o.recognizedTokenTypes)}(r,i,h);let d;try{d=await l;}catch(o){if(ii(o,n))return ei(e,t,f(f({},n),{},{flag:ai}));Mr(o);}return Vr(d),d}function ti(e,t){oi(e);const n=Rr(e),o=n.as,r=n.c,i=n.tlsOnly,a=n.hybrid,s=n.jarm,c=n.implicit,u=Sn(o,"authorization_endpoint",!1,i);if((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",a?"code id_token":c?"id_token":"code"),c&&!t.has("nonce"))throw Lr("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Kr);s&&t.set("response_mode","jwt");}for(const e of t.entries()){var h=y(e,2);const t=h[0],n=h[1];u.searchParams.append(t,n);}return u}async function ni(e,t,n){oi(e);const o=ti(e,t),r=Rr(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,h=r.timeout,l=await async function(e,t,n,o,r){var i;yn(e),wn(t);const a=Sn(e,"pushed_authorization_request_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[Dt])),s=new URLSearchParams(o);s.set("client_id",t.client_id);const c=on(null==r?void 0:r.headers);c.set("accept","application/json"),void 0!==(null==r?void 0:r.DPoP)&&(Kn(r.DPoP),await r.DPoP.addProof(a,c,"POST"));const u=await Ln(e,t,n,a,s,c,r);return null==r||null===(i=r.DPoP)||void 0===i||i.cacheNonce(u,a),u}(i,a,s,o.searchParams,{[Ht]:c,[Dt]:!u,DPoP:null==n?void 0:n.DPoP,headers:new Headers(Ir),signal:ri(h)}).catch(Mr),d=async function(e,t,n){if(yn(e),wn(t),!Ut(n,Response))throw zt('"response" must be an instance of Response',Nt);await jn(n,201,"Pushed Authorization Request Endpoint"),fo(n);const o=await So(n);un(o.request_uri,'"response" body "request_uri" property',oo,{body:o});let r="number"!=typeof o.expires_in?parseFloat(o.expires_in):o.expires_in;return cn(r,!0,'"response" body "expires_in" property',oo,{body:o}),o.expires_in=r,o}(i,a,l);let p;try{p=await d;}catch(o){if(ii(o,n))return ni(e,t,f(f({},n),{},{flag:ai}));Mr(o);}return ti(e,{request_uri:p.request_uri})}function oi(e){if(!(e instanceof Fr))throw Lr('"config" must be an instance of Configuration',Ur);if(Object.getPrototypeOf(e)!==Fr.prototype)throw Lr("subclassing Configuration is not allowed",Kr)}function ri(e){return e?AbortSignal.timeout(1e3*e):void 0}function ii(e,t){return !(null==t||!t.DPoP||t.flag===ai)&&function(e){if(e instanceof En){const t=e.cause,n=t[0];return 1===t.length&&"dpop"===n.scheme&&"use_dpop_nonce"===n.parameters.error}return e instanceof Tn&&"use_dpop_nonce"===e.error}(e)}Object.freeze(Fr.prototype);const ai=Symbol();async function si(e,t,n,o){oi(e);const r=Rr(e),i=r.as,a=r.c,s=r.auth,c=r.fetch,u=r.tlsOnly,h=r.timeout,l=r.decrypt,d=r.nonRepudiation,p=await async function(e,t,n,o,r,i){return yn(e),wn(t),un(o,'"grantType"'),Nn(e,t,n,o,new URLSearchParams(r),i)}(i,a,s,t,new URLSearchParams(n),{[Ht]:c,[Dt]:!u,DPoP:null==o?void 0:o.DPoP,headers:new Headers(Ir),signal:ri(h)}).catch(Mr);let m;"urn:ietf:params:oauth:grant-type:token-exchange"===t&&(m={n_a:()=>{}});const y=async function(e,t,n,o){return Mn(e,t,n,void 0,null==o?void 0:o[Ft],null==o?void 0:o.recognizedTokenTypes)}(i,a,p,{[Ft]:l,recognizedTokenTypes:m});let w;try{w=await y;}catch(r){if(ii(r,o))return si(e,t,n,f(f({},o),{},{flag:ai}));Mr(r);}return w.id_token&&await(null==d?void 0:d(p)),Vr(w),w}async function ci(e,t,n){if(!nr(e))throw new Zo("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new Zo('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new Zo("JWS Protected Header incorrect type");if(void 0===e.payload)throw new Zo("JWS Payload missing");if("string"!=typeof e.signature)throw new Zo("JWS Signature missing or incorrect type");if(void 0!==e.header&&!nr(e.header))throw new Zo("JWS Unprotected Header incorrect type");let o={};if(e.protected)try{const t=Oo(e.protected);o=JSON.parse(Ao.decode(t));}catch(e){throw new Zo("JWS Protected Header is invalid")}if(!or(o,e.header))throw new Zo("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r=f(f({},o),e.header);let i=!0;if(_r(Zo,new Map([["b64",!0]]),null==n?void 0:n.crit,o,r).has("b64")&&(i=o.b64,"boolean"!=typeof i))throw new Zo('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const a=r.alg;if("string"!=typeof a||!a)throw new Zo('JWS "alg" (Algorithm) Header Parameter missing or invalid');const s=n&&function(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError('"'.concat(e,'" option must be an array of strings'));if(t)return new Set(t)}("algorithms",n.algorithms);if(s&&!s.has(a))throw new Mo('"alg" (Algorithm) Header Parameter value not allowed');if(i){if("string"!=typeof e.payload)throw new Zo("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new Zo("JWS Payload must be a string or an Uint8Array instance");let c=!1;"function"==typeof t&&(t=await t(o,e),c=!0),Pr(a,t,"verify");const u=Io(void 0!==e.protected?xo(e.protected):new Uint8Array,xo("."),"string"==typeof e.payload?i?xo(e.payload):Eo.encode(e.payload):e.payload),h=tr(e.signature,"signature",Zo),l=await pr(t,a),d=await async function(e,t,n,o){const r=await sr(e,t,"verify");ir(e,r);const i=ar(e,r.algorithm);try{return await crypto.subtle.verify(i,r,n,o)}catch(e){return !1}}(a,l,h,u);if(!d)throw new Bo;let p;p=i?tr(e.payload,"payload",Zo):"string"==typeof e.payload?Eo.encode(e.payload):e.payload;const m={payload:p};return void 0!==e.protected&&(m.protectedHeader=o),void 0!==e.header&&(m.unprotectedHeader=e.header),c?f(f({},m),{},{key:l}):m}const ui=e=>Math.floor(e.getTime()/1e3),hi=86400,li=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function di(e){const t=li.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const n=parseFloat(t[2]);let o;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(60*n);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(3600*n);break;case"day":case"days":case"d":o=Math.round(n*hi);break;case"week":case"weeks":case"w":o=Math.round(604800*n);break;default:o=Math.round(31557600*n);}return "-"===t[1]||"ago"===t[4]?-o:o}function pi(e,t){if(!Number.isFinite(t))throw new TypeError("Invalid ".concat(e," input"));return t}const fi=e=>e.includes("/")?e.toLowerCase():"application/".concat(e.toLowerCase());function mi(e,t){let n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{n=JSON.parse(Ao.decode(t));}catch(e){}if(!nr(n))throw new Fo("JWT Claims Set must be a top-level JSON object");const r=o.typ;if(r&&("string"!=typeof e.typ||fi(e.typ)!==fi(r)))throw new Do('unexpected "typ" JWT header value',n,"typ","check_failed");const i=o.requiredClaims,a=void 0===i?[]:i,s=o.issuer,c=o.subject,u=o.audience,h=o.maxTokenAge,l=[...a];void 0!==h&&l.push("iat"),void 0!==u&&l.push("aud"),void 0!==c&&l.push("sub"),void 0!==s&&l.push("iss");for(const e of new Set(l.reverse()))if(!(e in n))throw new Do('missing required "'.concat(e,'" claim'),n,e,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(n.iss))throw new Do('unexpected "iss" claim value',n,"iss","check_failed");if(c&&n.sub!==c)throw new Do('unexpected "sub" claim value',n,"sub","check_failed");if(u&&(d=n.aud,p="string"==typeof u?[u]:u,!("string"==typeof d?p.includes(d):Array.isArray(d)&&p.some(Set.prototype.has.bind(new Set(d))))))throw new Do('unexpected "aud" claim value',n,"aud","check_failed");var d,p;let f;switch(typeof o.clockTolerance){case"string":f=di(o.clockTolerance);break;case"number":f=o.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const m=o.currentDate,y=ui(m||new Date);if((void 0!==n.iat||h)&&"number"!=typeof n.iat)throw new Do('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new Do('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>y+f)throw new Do('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new Do('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=y-f)throw new Jo('"exp" claim timestamp check failed',n,"exp","check_failed")}if(h){const e=y-n.iat;if(e-f>("number"==typeof h?h:di(h)))throw new Jo('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(e<0-f)throw new Do('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}var yi=new WeakMap;class wi{constructor(e){if(u(this,yi,void 0),!nr(e))throw new TypeError("JWT Claims Set MUST be an object");h(yi,this,structuredClone(e));}data(){return Eo.encode(JSON.stringify(c(yi,this)))}get iss(){return c(yi,this).iss}set iss(e){c(yi,this).iss=e;}get sub(){return c(yi,this).sub}set sub(e){c(yi,this).sub=e;}get aud(){return c(yi,this).aud}set aud(e){c(yi,this).aud=e;}set jti(e){c(yi,this).jti=e;}set nbf(e){"number"==typeof e?c(yi,this).nbf=pi("setNotBefore",e):e instanceof Date?c(yi,this).nbf=pi("setNotBefore",ui(e)):c(yi,this).nbf=ui(new Date)+di(e);}set exp(e){"number"==typeof e?c(yi,this).exp=pi("setExpirationTime",e):e instanceof Date?c(yi,this).exp=pi("setExpirationTime",ui(e)):c(yi,this).exp=ui(new Date)+di(e);}set iat(e){void 0===e?c(yi,this).iat=ui(new Date):e instanceof Date?c(yi,this).iat=pi("setIssuedAt",ui(e)):c(yi,this).iat=pi("setIssuedAt","string"==typeof e?ui(new Date)+di(e):e);}}async function gi(e,t,n){var o;const r=await async function(e,t,n){if(e instanceof Uint8Array&&(e=Ao.decode(e)),"string"!=typeof e)throw new Zo("Compact JWS must be a string or Uint8Array");const o=e.split("."),r=o[0],i=o[1],a=o[2];if(3!==o.length)throw new Zo("Invalid Compact JWS");const s=await ci({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return "function"==typeof t?f(f({},c),{},{key:s.key}):c}(e,t,n);if(null!==(o=r.protectedHeader.crit)&&void 0!==o&&o.includes("b64")&&!1===r.protectedHeader.b64)throw new Fo("JWTs MUST NOT use unencoded payload");const i={payload:mi(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return "function"==typeof t?f(f({},i),{},{key:r.key}):i}var vi=new WeakMap,bi=new WeakMap,ki=new WeakMap;class _i{constructor(e){if(u(this,vi,void 0),u(this,bi,void 0),u(this,ki,void 0),!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");h(vi,this,e);}setProtectedHeader(e){return er(c(bi,this),"setProtectedHeader"),h(bi,this,e),this}setUnprotectedHeader(e){return er(c(ki,this),"setUnprotectedHeader"),h(ki,this,e),this}async sign(e,t){if(!c(bi,this)&&!c(ki,this))throw new Zo("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!or(c(bi,this),c(ki,this)))throw new Zo("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const n=f(f({},c(bi,this)),c(ki,this));let o=!0;if(_r(Zo,new Map([["b64",!0]]),null==t?void 0:t.crit,c(bi,this),n).has("b64")&&(o=c(bi,this).b64,"boolean"!=typeof o))throw new Zo('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const r=n.alg;if("string"!=typeof r||!r)throw new Zo('JWS "alg" (Algorithm) Header Parameter missing or invalid');let i,a,s,u;Pr(r,e,"sign"),o?(i=Co(c(vi,this)),a=xo(i)):(a=c(vi,this),i=""),c(bi,this)?(s=Co(JSON.stringify(c(bi,this))),u=xo(s)):(s="",u=new Uint8Array);const h=Io(u,xo("."),a),l=await pr(e,r),d=await async function(e,t,n){const o=await sr(e,t,"sign");ir(e,o);const r=await crypto.subtle.sign(ar(e,o.algorithm),o,n);return new Uint8Array(r)}(r,l,h),p={signature:Co(d),payload:i};return c(ki,this)&&(p.header=c(ki,this)),c(bi,this)&&(p.protected=s),p}}var Si=new WeakMap;class Ti{constructor(e){u(this,Si,void 0),h(Si,this,new _i(e));}setProtectedHeader(e){return c(Si,this).setProtectedHeader(e),this}async sign(e,t){const n=await c(Si,this).sign(e,t);if(void 0===n.payload)throw new TypeError("use the flattened module for creating JWS with b64: false");return "".concat(n.protected,".").concat(n.payload,".").concat(n.signature)}}var Pi=new WeakMap,Ei=new WeakMap;class Ai{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,Pi,void 0),u(this,Ei,void 0),h(Ei,this,new wi(e));}setIssuer(e){return c(Ei,this).iss=e,this}setSubject(e){return c(Ei,this).sub=e,this}setAudience(e){return c(Ei,this).aud=e,this}setJti(e){return c(Ei,this).jti=e,this}setNotBefore(e){return c(Ei,this).nbf=e,this}setExpirationTime(e){return c(Ei,this).exp=e,this}setIssuedAt(e){return c(Ei,this).iat=e,this}setProtectedHeader(e){return h(Pi,this,e),this}async sign(e,t){var n;const o=new Ti(c(Ei,this).data());if(o.setProtectedHeader(c(Pi,this)),Array.isArray(null===(n=c(Pi,this))||void 0===n?void 0:n.crit)&&c(Pi,this).crit.includes("b64")&&!1===c(Pi,this).b64)throw new Fo("JWTs MUST NOT use unencoded payload");return o.sign(e,t)}}function Ii(e){return nr(e)}var xi,Ri,Oi=new WeakMap,Ci=new WeakMap;class Wi{constructor(e){if(u(this,Oi,void 0),u(this,Ci,new WeakMap),!function(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(Ii)}(e))throw new Vo("JSON Web Key Set malformed");h(Oi,this,structuredClone(e));}jwks(){return c(Oi,this)}async getKey(e,t){const n=f(f({},e),null==t?void 0:t.header),o=n.alg,r=n.kid,i=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return "RSA";case"ES":return "EC";case"Ed":return "OKP";case"ML":return "AKP";default:throw new Ho('Unsupported "alg" value for a JSON Web Key Set')}}(o),s=c(Oi,this).keys.filter(e=>{let t=i===e.kty;if(t&&"string"==typeof r&&(t=r===e.kid),!t||"string"!=typeof e.alg&&"AKP"!==i||(t=o===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(o){case"ES256":t="P-256"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":case"EdDSA":t="Ed25519"===e.crv;}return t}),u=s[0],h=s.length;if(0===h)throw new Xo;if(1!==h){const e=new Go,t=c(Ci,this);throw e[Symbol.asyncIterator]=w(function*(){for(const e of s)try{yield yield a(ji(t,e,o));}catch(e){}}),e}return ji(c(Ci,this),u,o)}}async function ji(e,t,n){const o=e.get(t)||e.set(t,{}).get(t);if(void 0===o[n]){const e=await async function(e,t,n){var o;if(!nr(e))throw new TypeError("JWK must be an object");let r;switch(null!=t||(t=e.alg),null!=r||(r=null!==(o=null==n?void 0:n.extractable)&&void 0!==o?o:e.ext),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return Oo(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new Ho('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return ur(f(f({},e),{},{alg:t,ext:r}));case"AKP":if("string"!=typeof e.alg||!e.alg)throw new TypeError('missing "alg" (Algorithm) Parameter value');if(void 0!==t&&t!==e.alg)throw new TypeError("JWK alg and alg option value mismatch");return ur(f(f({},e),{},{ext:r}));case"EC":case"OKP":return ur(f(f({},e),{},{alg:t,ext:r}));default:throw new Ho('Unsupported "kty" (Key Type) Parameter value')}}(f(f({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||"public"!==e.type)throw new Vo("JSON Web Key Set members must be public keys");o[n]=e;}return o[n]}function Ki(e){const t=new Wi(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}let Ui;if("undefined"==typeof navigator||null===(xi=navigator.userAgent)||void 0===xi||null===(Ri=xi.startsWith)||void 0===Ri||!Ri.call(xi,"Mozilla/5.0 ")){const e="v6.2.3";Ui="".concat("jose","/").concat(e);}const Li=Symbol();const Ni=Symbol();var zi=new WeakMap,Di=new WeakMap,Ji=new WeakMap,Mi=new WeakMap,Hi=new WeakMap,Zi=new WeakMap,Fi=new WeakMap,Vi=new WeakMap,Xi=new WeakMap,Gi=new WeakMap;class Yi{constructor(e,t){if(u(this,zi,void 0),u(this,Di,void 0),u(this,Ji,void 0),u(this,Mi,void 0),u(this,Hi,void 0),u(this,Zi,void 0),u(this,Fi,void 0),u(this,Vi,void 0),u(this,Xi,void 0),u(this,Gi,void 0),!(e instanceof URL))throw new TypeError("url must be an instance of URL");var n,o;h(zi,this,new URL(e.href)),h(Di,this,"number"==typeof(null==t?void 0:t.timeoutDuration)?null==t?void 0:t.timeoutDuration:5e3),h(Ji,this,"number"==typeof(null==t?void 0:t.cooldownDuration)?null==t?void 0:t.cooldownDuration:3e4),h(Mi,this,"number"==typeof(null==t?void 0:t.cacheMaxAge)?null==t?void 0:t.cacheMaxAge:6e5),h(Fi,this,new Headers(null==t?void 0:t.headers)),Ui&&!c(Fi,this).has("User-Agent")&&c(Fi,this).set("User-Agent",Ui),c(Fi,this).has("accept")||(c(Fi,this).set("accept","application/json"),c(Fi,this).append("accept","application/jwk-set+json")),h(Vi,this,null==t?void 0:t[Li]),void 0!==(null==t?void 0:t[Ni])&&(h(Gi,this,null==t?void 0:t[Ni]),n=null==t?void 0:t[Ni],o=c(Mi,this),"object"==typeof n&&null!==n&&"uat"in n&&"number"==typeof n.uat&&!(Date.now()-n.uat>=o)&&"jwks"in n&&nr(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,nr)&&(h(Hi,this,c(Gi,this).uat),h(Xi,this,Ki(c(Gi,this).jwks))));}pendingFetch(){return !!c(Zi,this)}coolingDown(){return "number"==typeof c(Hi,this)&&Date.now()<c(Hi,this)+c(Ji,this)}fresh(){return "number"==typeof c(Hi,this)&&Date.now()<c(Hi,this)+c(Mi,this)}jwks(){var e;return null===(e=c(Xi,this))||void 0===e?void 0:e.jwks()}async getKey(e,t){c(Xi,this)&&this.fresh()||await this.reload();try{return await c(Xi,this).call(this,e,t)}catch(n){if(n instanceof Xo&&!1===this.coolingDown())return await this.reload(),c(Xi,this).call(this,e,t);throw n}}async reload(){c(Zi,this)&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&h(Zi,this,void 0),c(Zi,this)||h(Zi,this,async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fetch;const r=await o(e,{method:"GET",signal:n,redirect:"manual",headers:t}).catch(e=>{if("TimeoutError"===e.name)throw new Yo;throw e});if(200!==r.status)throw new zo("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await r.json()}catch(e){throw new zo("Failed to parse the JSON Web Key Set HTTP response as JSON")}}(c(zi,this).href,c(Fi,this),AbortSignal.timeout(c(Di,this)),c(Vi,this)).then(e=>{h(Xi,this,Ki(e)),c(Gi,this)&&(c(Gi,this).uat=Date.now(),c(Gi,this).jwks=e),h(Hi,this,Date.now()),h(Zi,this,void 0);}).catch(e=>{throw h(Zi,this,void 0),e})),await c(Zi,this);}}const Bi=["mfaToken"],qi=["mfaToken"];var Qi,$i,ea,ta,na,oa,ra,ia,aa,sa,ca,ua,ha,la,da,pa,fa,ma,ya,wa,ga,va,ba,ka,_a,Sa,Ta,Pa,Ea;function Aa(e){var t,n;if("object"!=typeof e||null===e)return {error:"unknown_error",error_description:String(e)};const o=e,r={error:null!==(t=o.error)&&void 0!==t?t:"",error_description:null!==(n=o.error_description)&&void 0!==n?n:"",message:o.message};if("mfa_required"===o.error&&o.cause){r.mfa_token="string"==typeof o.cause.mfa_token?o.cause.mfa_token:void 0;const e=o.cause.mfa_requirements;"object"==typeof e&&null!==e&&(r.mfa_requirements=e);}return r}var Ia=class extends Error{constructor(e,t){super(t),d(this,"code",void 0),this.name="NotSupportedError",this.code=e;}},xa=class extends Error{constructor(e,t,n){super(t),d(this,"cause",void 0),d(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements};}},Ra=class extends xa{constructor(e,t){super("token_by_code_error",e,t),this.name="TokenByCodeError";}},Oa=class extends xa{constructor(e,t){super("token_by_client_credentials_error",e,t),this.name="TokenByClientCredentialsError";}},Ca=class extends xa{constructor(e,t){super("token_by_refresh_token_error",e,t),this.name="TokenByRefreshTokenError";}},Wa=class extends xa{constructor(e,t){super("token_by_password_error",e,t),this.name="TokenByPasswordError";}},ja=class extends xa{constructor(e,t){super("token_for_connection_error",e,t),this.name="TokenForConnectionErrorCode";}},Ka=class extends xa{constructor(e,t){super("token_exchange_error",e,t),this.name="TokenExchangeError";}},Ua=class extends Error{constructor(e){super(e),d(this,"code","verify_logout_token_error"),this.name="VerifyLogoutTokenError";}},La=class extends xa{constructor(e){super("backchannel_authentication_error","There was an error when trying to use Client-Initiated Backchannel Authentication.",e),d(this,"code","backchannel_authentication_error"),this.name="BackchannelAuthenticationError";}},Na=class extends xa{constructor(e){super("build_authorization_url_error","There was an error when trying to build the authorization URL.",e),this.name="BuildAuthorizationUrlError";}},za=class extends xa{constructor(e){super("build_link_user_url_error","There was an error when trying to build the Link User URL.",e),this.name="BuildLinkUserUrlError";}},Da=class extends xa{constructor(e){super("build_unlink_user_url_error","There was an error when trying to build the Unlink User URL.",e),this.name="BuildUnlinkUserUrlError";}},Ja=class extends Error{constructor(){super("The client secret or client assertion signing key must be provided."),d(this,"code","missing_client_auth_error"),this.name="MissingClientAuthError";}},Ma=class extends Error{constructor(e){super(e),d(this,"code","organization_validation_error"),this.name="OrganizationValidationError";}};function Ha(e){return Object.entries(e).filter(e=>void 0!==y(e,2)[1]).reduce((e,t)=>f(f({},e),{},{[t[0]]:t[1]}),{})}function Za(e){if(!e.trim())throw new Ma("organization must not be blank")}function Fa(e,t){if(!e)return;const n=t.trim();if(n.startsWith("org_")){const t=e.org_id;if("string"!=typeof t)throw new Ma("Organization Id (org_id) claim must be a string present in the ID token");if(t!==n)throw new Ma('Organization Id (org_id) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}else {const t=e.org_name;if("string"!=typeof t)throw new Ma("Organization Name (org_name) claim must be a string present in the ID token");if(t.toLowerCase()!==n.toLowerCase())throw new Ma('Organization Name (org_name) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}}var Va=class extends Error{constructor(e,t,n){super(t),d(this,"cause",void 0),d(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};}},Xa=class extends Va{constructor(e,t){super("mfa_list_authenticators_error",e,t),this.name="MfaListAuthenticatorsError";}},Ga=class extends Va{constructor(e,t){super("mfa_enrollment_error",e,t),this.name="MfaEnrollmentError";}},Ya=class extends Va{constructor(e,t){super("mfa_delete_authenticator_error",e,t),this.name="MfaDeleteAuthenticatorError";}},Ba=class extends Va{constructor(e,t){super("mfa_challenge_error",e,t),this.name="MfaChallengeError";}},qa=class extends Va{constructor(e,t){super("mfa_verify_error",e,t),this.name="MfaVerifyError";}};function Qa(e){return {id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var $a=class e{constructor(e,t,n,o,r,i,a){d(this,"accessToken",void 0),d(this,"idToken",void 0),d(this,"refreshToken",void 0),d(this,"expiresAt",void 0),d(this,"scope",void 0),d(this,"claims",void 0),d(this,"authorizationDetails",void 0),d(this,"tokenType",void 0),d(this,"issuedTokenType",void 0),d(this,"recoveryCode",void 0),d(this,"act",void 0),this.accessToken=e,this.idToken=n,this.refreshToken=o,this.expiresAt=t,this.scope=r,this.claims=i,this.authorizationDetails=a;}static fromTokenEndpointResponse(t){const n=t.id_token?t.claims():void 0,o=new e(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return o.tokenType=t.token_type,o.issuedTokenType=t.issued_token_type,o}},es={otp:"http://auth0.com/oauth/grant-type/mfa-otp",oob:"http://auth0.com/oauth/grant-type/mfa-oob","recovery-code":"http://auth0.com/oauth/grant-type/mfa-recovery-code"},ts=(Qi=new WeakMap,$i=new WeakMap,ea=new WeakMap,ta=new WeakMap,na=new WeakMap,class{constructor(e){var t;u(this,Qi,void 0),u(this,$i,void 0),u(this,ea,void 0),u(this,ta,void 0),u(this,na,void 0),h(Qi,this,"https://".concat(e.domain)),h($i,this,e.clientId),h(ea,this,e.clientSecret),h(ta,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),h(na,this,e.getConfiguration);}async listAuthenticators(e){const t="".concat(c(Qi,this),"/mfa/authenticators"),n=e.mfaToken,o=await c(ta,this).call(this,t,{method:"GET",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!o.ok){let e;try{e=await o.json();}catch(e){throw new Xa("Failed to list authenticators")}throw new Xa(e.error_description||"Failed to list authenticators",e)}return (await o.json()).map(Qa)}async enrollAuthenticator(e){const t="".concat(c(Qi,this),"/mfa/associate"),n=e.mfaToken,o=m(e,Bi),r={authenticator_types:o.authenticatorTypes};"oobChannels"in o&&(r.oob_channels=o.oobChannels),"phoneNumber"in o&&o.phoneNumber&&(r.phone_number=o.phoneNumber),"email"in o&&o.email&&(r.email=o.email);const i=await c(ta,this).call(this,t,{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let e;try{e=await i.json();}catch(e){throw new Ga("Failed to enroll authenticator")}throw new Ga(e.error_description||"Failed to enroll authenticator",e)}return function(e){if("otp"===e.authenticator_type)return {authenticatorType:"otp",secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if("oob"===e.authenticator_type)return {authenticatorType:"oob",oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes};throw new Error("Unexpected authenticator type: ".concat(e.authenticator_type))}(await i.json())}async deleteAuthenticator(e){const t=e.authenticatorId,n=e.mfaToken,o="".concat(c(Qi,this),"/mfa/authenticators/").concat(encodeURIComponent(t)),r=await c(ta,this).call(this,o,{method:"DELETE",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!r.ok){let e;try{e=await r.json();}catch(e){throw new Ya("Failed to delete authenticator")}throw new Ya(e.error_description||"Failed to delete authenticator",e)}}async challengeAuthenticator(e){const t="".concat(c(Qi,this),"/mfa/challenge"),n=e.mfaToken,o=m(e,qi),r={mfa_token:n,client_id:c($i,this),challenge_type:o.challengeType};c(ea,this)&&(r.client_secret=c(ea,this)),o.authenticatorId&&(r.authenticator_id=o.authenticatorId);const i=await c(ta,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let e;try{e=await i.json();}catch(e){throw new Ba("Failed to challenge authenticator")}throw new Ba(e.error_description||"Failed to challenge authenticator",e)}return function(e){const t={challengeType:e.challenge_type};return void 0!==e.oob_code&&(t.oobCode=e.oob_code),void 0!==e.binding_method&&(t.bindingMethod=e.binding_method),t}(await i.json())}async verify(e){if(!c(na,this))throw new Error("MFA verify requires a configuration provider (getConfiguration was not set)");const t=await c(na,this).call(this),n={mfa_token:e.mfaToken};e.audience&&(n.audience=e.audience),"otp"===e.factorType?n.otp=e.otp:"oob"===e.factorType?(n.oob_code=e.oobCode,e.bindingCode&&(n.binding_code=e.bindingCode)):"recovery-code"===e.factorType&&(n.recovery_code=e.recoveryCode);try{const o=await si(t,es[e.factorType],n),r=$a.fromTokenEndpointResponse(o);return o.recovery_code&&(r.recoveryCode=o.recovery_code),r}catch(e){var o,r,i;if(e instanceof qa)throw e;const t=e;throw new qa(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!==(o=t.error)&&void 0!==o?o:"mfa_verify_error",error_description:null!==(r=null!==(i=t.error_description)&&void 0!==i?i:t.message)&&void 0!==r?r:"Failed to verify MFA challenge"})}}}),ns=class extends Error{constructor(e,t,n){super(t),d(this,"cause",void 0),d(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};}},os=class extends ns{constructor(e,t){super("passkey_register_error",e,t),this.name="PasskeyRegisterError";}},rs=class extends ns{constructor(e,t){super("passkey_challenge_error",e,t),this.name="PasskeyChallengeError";}},is=class extends ns{constructor(e,t){super("passkey_get_token_error",e,t),this.name="PasskeyGetTokenError",this.cause=t&&{error:t.error,error_description:t.error_description,message:t.message,mfa_token:t.mfa_token,mfa_requirements:t.mfa_requirements};}};var as="urn:okta:params:oauth:grant-type:webauthn",ss=(oa=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa=new WeakMap,sa=new WeakSet,class{constructor(e){var t;l(this,sa),u(this,oa,void 0),u(this,ra,void 0),u(this,ia,void 0),u(this,aa,void 0),h(oa,this,"https://".concat(e.domain)),h(ra,this,e.clientId),h(ia,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),h(aa,this,e.grantRequest);}async register(e){const t="".concat(c(oa,this),"/passkey/register"),n=f(f(f(f(f(f(f(f({},e.email&&{email:e.email}),e.name&&{name:e.name}),e.phoneNumber&&{phone_number:e.phoneNumber}),e.username&&{username:e.username}),e.givenName&&{given_name:e.givenName}),e.familyName&&{family_name:e.familyName}),e.nickname&&{nickname:e.nickname}),e.picture&&{picture:e.picture}),o={client_id:c(ra,this),user_profile:n};e.realm&&(o.realm=e.realm),e.organization&&(o.organization=e.organization),e.userMetadata&&(o.user_metadata=e.userMetadata);const r=await c(ia,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){const e=await i(sa,this,cs).call(this,r);throw new os(e.error_description||"Failed to request signup challenge",e)}const a=await r.json();return {authSession:(s=a).auth_session,authnParamsPublicKey:f({},s.authn_params_public_key)};var s;}async challenge(e){const t="".concat(c(oa,this),"/passkey/challenge"),n={client_id:c(ra,this)};null!=e&&e.realm&&(n.realm=e.realm),null!=e&&e.organization&&(n.organization=e.organization);const o=await c(ia,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const e=await i(sa,this,cs).call(this,o);throw new rs(e.error_description||"Failed to request login challenge",e)}const r=await o.json();return {authSession:(a=r).auth_session,authnParamsPublicKey:f({},a.authn_params_public_key)};var a;}async getTokenByPasskey(e){void 0!==e.organization&&Za(e.organization);const t=new URLSearchParams({auth_session:e.authSession,authn_response:JSON.stringify(e.credential)});let n;e.realm&&t.append("realm",e.realm),e.scope&&t.append("scope",e.scope),e.audience&&t.append("audience",e.audience),e.organization&&t.append("organization",e.organization);try{n=await c(aa,this).call(this,as,t);}catch(e){const t=Aa(e);throw new is(t.error_description||"Failed to exchange passkey credential for tokens.",t)}return e.organization&&Fa(n.claims,e.organization),n}});async function cs(e){try{return await e.json()}catch(t){return {error:"unknown_error",error_description:"HTTP ".concat(e.status," ").concat(e.statusText)}}}var us=class extends Error{constructor(e,t,n){super(t),d(this,"cause",void 0),d(this,"code",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements};}},hs=class extends us{constructor(e,t){super("passwordless_start_error",e,t),this.name="PasswordlessStartError";}},ls=class extends us{constructor(e,t){super("passwordless_verify_error",e,t),this.name="PasswordlessVerifyError";}};function ds(e){return /^\+[1-9]\d{1,14}$/.test(e)}var ps=(ca=new WeakMap,ua=new WeakMap,ha=new WeakMap,la=new WeakMap,da=new WeakMap,pa=new WeakSet,class{constructor(e){var t;l(this,pa),u(this,ca,void 0),u(this,ua,void 0),u(this,ha,void 0),u(this,la,void 0),u(this,da,void 0),h(ua,this,e.domain),h(ca,this,"https://".concat(e.domain)),h(ha,this,e.clientId),h(la,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)}),h(da,this,{clientSecret:e.clientSecret,clientAssertionSigningKey:e.clientAssertionSigningKey,clientAssertionSigningAlg:e.clientAssertionSigningAlg,useMtls:e.useMtls});}async sendEmail(e){await i(pa,this,fs).call(this,function(e){var t;const n=null!==(t=e.send)&&void 0!==t?t:"code",o={email:e.email,connection:"email",send:n};return "link"===n&&e.authParams&&(o.authParams=e.authParams),o}(e),"Failed to send passwordless email",e.language);}async sendSms(e){if(!ds(e.phoneNumber))throw new hs("Phone number must be in E.164 format (e.g. +14155550100).");await i(pa,this,fs).call(this,function(e){return {phone_number:e.phoneNumber,connection:"sms"}}(e),"Failed to send passwordless SMS",e.language);}});async function fs(e,t,n){var o;const r=await async function(e,t,n){if(e.useMtls)return {};if(e.clientAssertionSigningKey){var o;const r=null!==(o=e.clientAssertionSigningAlg)&&void 0!==o?o:"RS256",i=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await kr(e.clientAssertionSigningKey,r);return {client_assertion:await new Ai({}).setProtectedHeader({alg:r}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(i),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}if(e.clientSecret)return {client_secret:e.clientSecret};throw new Ja}(c(da,this),c(ha,this),c(ua,this)),i=f(f({client_id:c(ha,this)},e),r);let a,s;try{a=await c(la,this).call(this,"".concat(c(ca,this),"/passwordless/start"),{method:"POST",headers:f({"Content-Type":"application/json"},n?{"x-request-language":n}:{}),body:JSON.stringify(i)});}catch(e){throw new hs("".concat(t,": a network error occurred."))}if(!a.ok){if(204!==a.status)try{s=await a.json();}catch(e){s=void 0;}throw new hs((null===(o=s)||void 0===o?void 0:o.error_description)||t,s)}}var ms=(fa=new WeakMap,ma=new WeakMap,ya=new WeakMap,class{constructor(e,t){u(this,fa,new Map),u(this,ma,void 0),u(this,ya,void 0),h(ya,this,Math.max(1,Math.floor(e))),h(ma,this,Math.max(0,Math.floor(t)));}get(e){const t=c(fa,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return c(fa,this).delete(e),c(fa,this).set(e,t),t.value;c(fa,this).delete(e);}}set(e,t){for(c(fa,this).has(e)&&c(fa,this).delete(e),c(fa,this).set(e,{value:t,expiresAt:Date.now()+c(ma,this)});c(fa,this).size>c(ya,this);){const e=c(fa,this).keys().next().value;if(void 0===e)break;c(fa,this).delete(e);}}}),ys=new Map;function ws(e){return {ttlMs:1e3*("number"==typeof(null==e?void 0:e.ttl)?e.ttl:600),maxEntries:"number"==typeof(null==e?void 0:e.maxEntries)&&e.maxEntries>0?e.maxEntries:100}}var gs=class{static createDiscoveryCache(e){const t=(n=e.maxEntries,o=e.ttlMs,"".concat(n,":").concat(o));var n,o;let r=(i=t,ys.get(i));var i;return r||(r=new ms(e.maxEntries,e.ttlMs),ys.set(t,r)),r}static createJwksCache(){return {}}},vs="openid profile email offline_access",bs=Object.freeze(new Set(["grant_type","client_id","client_secret","client_assertion","client_assertion_type","subject_token","subject_token_type","requested_token_type","actor_token","actor_token_type","audience","aud","resource","resources","resource_indicator","scope","connection","login_hint","organization","assertion"]));function ks(e){if(null==e)throw new Ka("subject_token is required");if("string"!=typeof e)throw new Ka("subject_token must be a string");if(0===e.trim().length)throw new Ka("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new Ka("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new Ka("subject_token must not include the 'Bearer ' prefix")}function _s(e,t){if(t)for(const o of Object.entries(t)){var n=y(o,2);const t=n[0],r=n[1];if(!bs.has(t))if(Array.isArray(r)){if(r.length>20)throw new Ka("Parameter '".concat(t,"' exceeds maximum array size of ").concat(20));r.forEach(n=>{e.append(t,n);});}else e.append(t,r);}}var Ss="urn:ietf:params:oauth:token-type:access_token";var Ts=(wa=new WeakMap,ga=new WeakMap,va=new WeakMap,ba=new WeakMap,ka=new WeakMap,_a=new WeakMap,Sa=new WeakMap,Ta=new WeakMap,Pa=new WeakMap,Ea=new WeakSet,class{constructor(e){var t,n,o,r;if(l(this,Ea),u(this,wa,void 0),u(this,ga,void 0),u(this,va,void 0),u(this,ba,void 0),u(this,ka,void 0),u(this,_a,void 0),u(this,Sa,void 0),u(this,Ta,void 0),u(this,Pa,void 0),d(this,"mfa",void 0),d(this,"passkey",void 0),d(this,"passwordless",void 0),h(ba,this,e),e.useMtls&&!e.customFetch)throw new Ia("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");h(ka,this,function(e,t){if(!1===t.enabled)return e;const n={name:t.name,version:t.version},o=btoa(JSON.stringify(n));return async(t,n)=>{const r=t instanceof Request?new Headers(t.headers):new Headers;return null!=n&&n.headers&&new Headers(n.headers).forEach((e,t)=>{r.set(t,e);}),r.set("Auth0-Client",o),e(t,f(f({},n),{},{headers:r}))}}(null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)},!1===(null==(n=e.telemetry)?void 0:n.enabled)?n:{enabled:!0,name:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:"@auth0/auth0-auth-js",version:null!==(r=null==n?void 0:n.version)&&void 0!==r?r:"1.10.0"}));const a=ws(e.discoveryCache);h(Sa,this,gs.createDiscoveryCache(a)),h(Ta,this,new Map),h(Pa,this,gs.createJwksCache()),this.mfa=new ts({domain:c(ba,this).domain,clientId:c(ba,this).clientId,clientSecret:c(ba,this).clientSecret,customFetch:c(ka,this),getConfiguration:async()=>(await i(Ea,this,As).call(this)).configuration}),this.passkey=new ss({domain:c(ba,this).domain,clientId:c(ba,this).clientId,customFetch:c(ka,this),grantRequest:async(e,t)=>{const n=(await i(Ea,this,As).call(this)).serverMetadata,o=await i(Ea,this,Es).call(this,n);o[jr]=function(e,t){return (n,o)=>{const r=null==o?void 0:o.body;if(t!==as||!(r instanceof URLSearchParams))return e(n,o);const i={};for(const e of r){var a=y(e,2);const t=a[0],n=a[1];i[t]="authn_response"===t?JSON.parse(n):n;}const s=new Headers(null==o?void 0:o.headers);return s.set("Content-Type","application/json"),e(n,f(f({},o),{},{headers:s,body:JSON.stringify(i)}))}}(c(ka,this),e);const r=await si(o,e,t);return $a.fromTokenEndpointResponse(r)}}),this.passwordless=new ps({domain:c(ba,this).domain,clientId:c(ba,this).clientId,customFetch:c(ka,this),clientSecret:c(ba,this).clientSecret,clientAssertionSigningKey:c(ba,this).clientAssertionSigningKey,clientAssertionSigningAlg:c(ba,this).clientAssertionSigningAlg,useMtls:c(ba,this).useMtls});}async getServerMetadata(){return (await i(Ea,this,As).call(this)).serverMetadata}async buildAuthorizationUrl(e){const t=(await i(Ea,this,As).call(this)).serverMetadata;if(null!=e&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new Ia("par_not_supported_error","The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par");try{return await i(Ea,this,Cs).call(this,e)}catch(e){throw new Na(e)}}async buildLinkUserUrl(e){try{const t=await i(Ea,this,Cs).call(this,{authorizationParams:f(f({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:"openid link_account offline_access",id_token_hint:e.idToken})});return {linkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new za(e)}}async buildUnlinkUserUrl(e){try{const t=await i(Ea,this,Cs).call(this,{authorizationParams:f(f({},e.authorizationParams),{},{requested_connection:e.connection,scope:"openid unlink_account",id_token_hint:e.idToken})});return {unlinkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new Da(e)}}async backchannelAuthentication(e){const t=await i(Ea,this,As).call(this),n=t.configuration,o=t.serverMetadata,r=Ha(f(f({},c(ba,this).authorizationParams),null==e?void 0:e.authorizationParams)),a=new URLSearchParams(f(f({scope:vs},r),{},{client_id:c(ba,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:o.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&a.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&a.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const e=await Yr(n,a),t=await Br(n,e);return $a.fromTokenEndpointResponse(t)}catch(e){throw new La(e)}}async initiateBackchannelAuthentication(e){const t=await i(Ea,this,As).call(this),n=t.configuration,o=t.serverMetadata,r=Ha(f(f({},c(ba,this).authorizationParams),null==e?void 0:e.authorizationParams)),a=new URLSearchParams(f(f({scope:vs},r),{},{client_id:c(ba,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:o.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&a.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&a.append("authorization_details",JSON.stringify(e.authorizationDetails));try{const e=await Yr(n,a);return {authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new La(e)}}async backchannelAuthenticationGrant(e){let t=e.authReqId;const n=(await i(Ea,this,As).call(this)).configuration,o=new URLSearchParams({auth_req_id:t});try{const e=await si(n,"urn:openid:params:grant-type:ciba",o);return $a.fromTokenEndpointResponse(e)}catch(e){throw new La(e)}}async getTokenForConnection(e){var t;if(e.refreshToken&&e.accessToken)throw new ja("Either a refresh or access token should be specified, but not both.");const n=null!==(t=e.accessToken)&&void 0!==t?t:e.refreshToken;if(!n)throw new ja("Either a refresh or access token must be specified.");try{return await this.exchangeToken({connection:e.connection,subjectToken:n,subjectTokenType:e.accessToken?Ss:"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint})}catch(e){if(e instanceof Ka)throw new ja(e.message,e.cause);throw e}}async exchangeToken(e){return "connection"in e?i(Ea,this,Is).call(this,e):i(Ea,this,xs).call(this,e)}async getTokenByCode(e,t){const n=(await i(Ea,this,As).call(this)).configuration;let o;void 0!==t.organization&&Za(t.organization);try{const r=await Qr(n,e,{pkceCodeVerifier:t.codeVerifier});o=$a.fromTokenEndpointResponse(r);}catch(e){throw new Ra("There was an error while trying to request a token.",Aa(e))}return t.organization&&Fa(o.claims,t.organization),o}async getTokenByMagicLinkCode(e,t){const n=(await i(Ea,this,As).call(this)).configuration;try{const o=await Qr(n,e,{expectedState:null==t?void 0:t.expectedState});return $a.fromTokenEndpointResponse(o)}catch(e){const t=e instanceof Error&&e.message?e.message:"There was an error while trying to request a token.";throw new Ra(t,e)}}async getTokenByRefreshToken(e){const t=(await i(Ea,this,As).call(this)).configuration,n=new URLSearchParams;e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope);try{const o=await $r(t,e.refreshToken,n);return $a.fromTokenEndpointResponse(o)}catch(e){throw new Ca("The access token has expired and there was an error while trying to refresh it.",Aa(e))}}async getTokenByPassword(e){const t=(await i(Ea,this,As).call(this)).configuration,n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.realm&&n.append("realm",e.realm);let o=t;if(e.auth0ForwardedFor){const n=await i(Ea,this,Os).call(this);o=new Fr(t.serverMetadata(),c(ba,this).clientId,c(ba,this).clientSecret,n),o[jr]=(t,n)=>c(ka,this).call(this,t,f(f({},n),{},{headers:f(f({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}));}try{const e=await si(o,"password",n);return $a.fromTokenEndpointResponse(e)}catch(e){throw new Wa("There was an error while trying to request a token.",Aa(e))}}async getTokenByPasswordlessEmail(e){const t=new URLSearchParams({username:e.email,otp:e.code,realm:"email"});return e.audience&&t.append("audience",e.audience),e.scope&&t.append("scope",e.scope),i(Ea,this,Rs).call(this,t)}async getTokenByPasswordlessSms(e){if(!ds(e.phoneNumber))throw new ls("Phone number must be in E.164 format (e.g. +14155550100).");const t=new URLSearchParams({username:e.phoneNumber,otp:e.code,realm:"sms"});return e.audience&&t.append("audience",e.audience),e.scope&&t.append("scope",e.scope),i(Ea,this,Rs).call(this,t)}async getTokenByClientCredentials(e){const t=(await i(Ea,this,As).call(this)).configuration;try{const n=new URLSearchParams({audience:e.audience});e.organization&&n.append("organization",e.organization);const o=await ei(t,n);return $a.fromTokenEndpointResponse(o)}catch(e){throw new Oa("There was an error while trying to request a token.",Aa(e))}}async buildLogoutUrl(e){const t=await i(Ea,this,As).call(this),n=t.configuration;if(!t.serverMetadata.end_session_endpoint){const t=new URL("https://".concat(c(ba,this).domain,"/v2/logout"));return t.searchParams.set("returnTo",e.returnTo),t.searchParams.set("client_id",c(ba,this).clientId),t}return function(e,t){oi(e);const n=Rr(e),o=n.as,r=n.c,i=Sn(o,"end_session_endpoint",!1,n.tlsOnly);(t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id);for(const e of t.entries()){var a=y(e,2);const t=a[0],n=a[1];i.searchParams.append(t,n);}return i}(n,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){const t=(await i(Ea,this,As).call(this)).serverMetadata,n=ws(c(ba,this).discoveryCache),o=t.jwks_uri;c(_a,this)||h(_a,this,function(e,t){const n=new Yi(e,t),o=async(e,t)=>n.getKey(e,t);return Object.defineProperties(o,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),o}(new URL(o),{cacheMaxAge:n.ttlMs,[Li]:c(ka,this),[Ni]:c(Pa,this)}));const r=(await gi(e.logoutToken,c(_a,this),{issuer:t.issuer,audience:c(ba,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]})).payload;if(!("sid"in r)&&!("sub"in r))throw new Ua('either "sid" or "sub" (or both) claims must be present');if("sid"in r&&"string"!=typeof r.sid)throw new Ua('"sid" claim must be a string');if("sub"in r&&"string"!=typeof r.sub)throw new Ua('"sub" claim must be a string');if("nonce"in r)throw new Ua('"nonce" claim is prohibited');if(!("events"in r))throw new Ua('"events" claim is missing');if("object"!=typeof r.events||null===r.events)throw new Ua('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in r.events))throw new Ua('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if("object"!=typeof r.events["http://schemas.openid.net/event/backchannel-logout"])throw new Ua('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return {sid:r.sid,sub:r.sub}}});function Ps(){const e=c(ba,this).domain.toLowerCase();return "".concat(e,"|mtls:").concat(c(ba,this).useMtls?"1":"0")}async function Es(e){const t=await i(Ea,this,Os).call(this),n=new Fr(e,c(ba,this).clientId,c(ba,this).clientSecret,t);return n[jr]=c(ka,this),n}async function As(){if(c(wa,this)&&c(ga,this))return {configuration:c(wa,this),serverMetadata:c(ga,this)};const e=i(Ea,this,Ps).call(this),t=c(Sa,this).get(e);if(t)return h(ga,this,t.serverMetadata),h(wa,this,await i(Ea,this,Es).call(this,t.serverMetadata)),{configuration:c(wa,this),serverMetadata:c(ga,this)};const n=c(Ta,this).get(e);if(n){const e=await n;return h(ga,this,e.serverMetadata),h(wa,this,await i(Ea,this,Es).call(this,e.serverMetadata)),{configuration:c(wa,this),serverMetadata:c(ga,this)}}const o=(async()=>{const t=await i(Ea,this,Os).call(this),n=await Hr(new URL("https://".concat(c(ba,this).domain)),c(ba,this).clientId,{use_mtls_endpoint_aliases:c(ba,this).useMtls},t,{[jr]:c(ka,this)}),o=n.serverMetadata();return c(Sa,this).set(e,{serverMetadata:o}),{configuration:n,serverMetadata:o}})(),r=o.then(e=>({serverMetadata:e.serverMetadata}));r.catch(()=>{}),c(Ta,this).set(e,r);try{const e=await o,t=e.configuration,n=e.serverMetadata;h(wa,this,t),h(ga,this,n),c(wa,this)[jr]=c(ka,this);}finally{c(Ta,this).delete(e);}return {configuration:c(wa,this),serverMetadata:c(ga,this)}}async function Is(e){var t,n;const o=(await i(Ea,this,As).call(this)).configuration;if("audience"in e||"resource"in e)throw new Ka("audience and resource parameters are not supported for Token Vault exchanges");ks(e.subjectToken);const r=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:null!==(t=e.subjectTokenType)&&void 0!==t?t:Ss,requested_token_type:null!==(n=e.requestedTokenType)&&void 0!==n?n:"http://auth0.com/oauth/token-type/federated-connection-access-token"});e.loginHint&&r.append("login_hint",e.loginHint),e.scope&&r.append("scope",e.scope),_s(r,e.extra);try{const e=await si(o,"urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",r);return $a.fromTokenEndpointResponse(e)}catch(t){throw new Ka("Failed to exchange token for connection '".concat(e.connection,"'."),Aa(t))}}async function xs(e){const t=(await i(Ea,this,As).call(this)).configuration;if(ks(e.subjectToken),void 0!==e.organization&&Za(e.organization),void 0!==e.actorToken&&void 0===e.actorTokenType)throw new Ka("actorTokenType is required when actorToken is provided");const n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});let o,r;e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),e.requestedTokenType&&n.append("requested_token_type",e.requestedTokenType),e.organization&&n.append("organization",e.organization),e.actorToken&&n.append("actor_token",e.actorToken),e.actorTokenType&&n.append("actor_token_type",e.actorTokenType),_s(n,e.extra);try{r=await si(t,"urn:ietf:params:oauth:grant-type:token-exchange",n),o=$a.fromTokenEndpointResponse(r);}catch(t){throw new Ka("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),Aa(t))}var a;if(e.organization&&Fa(o.claims,e.organization),e.actorToken)if(null!==(a=o.claims)&&void 0!==a&&a.act)o.act=o.claims.act;else try{o.act=function(e){if("string"!=typeof e)throw new Fo("JWTs must use Compact JWS serialization, JWT must be a string");const t=e.split("."),n=t[1],o=t.length;if(5===o)throw new Fo("Only JWTs using Compact JWS serialization can be decoded");if(3!==o)throw new Fo("Invalid JWT");if(!n)throw new Fo("JWTs must contain a payload");let r,i;try{r=Oo(n);}catch(e){throw new Fo("Failed to base64url decode the payload")}try{i=JSON.parse(Ao.decode(r));}catch(e){throw new Fo("Failed to parse the decoded payload as JSON")}if(!nr(i))throw new Fo("Invalid JWT Claims Set");return i}(r.access_token).act;}catch(e){}return o}async function Rs(e){const t=(await i(Ea,this,As).call(this)).configuration;try{const n=await si(t,"http://auth0.com/oauth/grant-type/passwordless/otp",e);return $a.fromTokenEndpointResponse(n)}catch(e){throw new ls("There was an error while trying to request a token.",Aa(e))}}async function Os(){return c(va,this)||h(va,this,(async()=>{if(!c(ba,this).clientSecret&&!c(ba,this).clientAssertionSigningKey&&!c(ba,this).useMtls)throw new Ja;if(c(ba,this).useMtls)return (e,t,n,o)=>{n.set("client_id",t.client_id);};let e=c(ba,this).clientAssertionSigningKey;return !e||e instanceof CryptoKey||(e=await kr(e,c(ba,this).clientAssertionSigningAlg||"RS256")),e?function(e,t){return vn(e,t)}(e):Wr(c(ba,this).clientSecret)})().catch(e=>{throw h(va,this,void 0),e})),c(va,this)}async function Cs(e){const t=(await i(Ea,this,As).call(this)).configuration,n=zr(),o=await Nr(n),r=Ha(f(f({},c(ba,this).authorizationParams),null==e?void 0:e.authorizationParams)),a=new URLSearchParams(f(f({scope:vs},r),{},{client_id:c(ba,this).clientId,code_challenge:o,code_challenge_method:"S256"}));return {authorizationUrl:null!=e&&e.pushedAuthorizationRequests?await ni(t,a):await ti(t,a),codeVerifier:n}}class Ws extends E{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ws.prototype);}static fromPayload(e){let t=e.error,n=e.error_description;return new Ws(t,n)}}class js extends Ws{constructor(e,t){super(e,t),Object.setPrototypeOf(this,js.prototype);}}class Ks extends Ws{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ks.prototype);}}class Us extends Ws{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Us.prototype);}}class Ls extends Ws{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ls.prototype);}}class Ns extends Ws{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ns.prototype);}}class zs{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e5;this.contexts=new Map,this.ttlMs=e;}set(e,t){this.cleanup(),this.contexts.set(e,Object.assign(Object.assign({},t),{createdAt:Date.now()}));}get(e){const t=this.contexts.get(e);if(t){if(!(Date.now()-t.createdAt>this.ttlMs))return t;this.contexts.delete(e);}}remove(e){this.contexts.delete(e);}cleanup(){const e=Date.now();for(const n of this.contexts){var t=y(n,2);const o=t[0];e-t[1].createdAt>this.ttlMs&&this.contexts.delete(o);}}get size(){return this.contexts.size}}class Ds{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new zs;}setMFAAuthDetails(e,t,n,o){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:o});}async getAuthenticators(e){var t,n,o;const r=this.contextManager.get(e);if(!r)throw new js("invalid_request","MFA context not found for this MFA token");const i=null===(n=null===(t=r.mfaRequirements)||void 0===t?void 0:t.challenge)||void 0===n?void 0:n.map(e=>e.type);try{const t=await this.authJsMfaClient.listAuthenticators({mfaToken:e});return i&&0!==i.length?t.filter(e=>!!e.type&&i.includes(e.type)):t}catch(e){if(e instanceof Xa)throw new js(null===(o=e.cause)||void 0===o?void 0:o.error,e.message);throw e}}async enroll(e){var t;const n=function(e){const t=xt[e.factorType];return Object.assign(Object.assign(Object.assign({mfaToken:e.mfaToken,authenticatorTypes:t.authenticatorTypes},t.oobChannels&&{oobChannels:t.oobChannels}),"phoneNumber"in e&&{phoneNumber:e.phoneNumber}),"email"in e&&{email:e.email})}(e);try{return await this.authJsMfaClient.enrollAuthenticator(n)}catch(e){if(e instanceof Ga)throw new Ks(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async challenge(e){var t;try{const t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){if(e instanceof Ba)throw new Us(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async getEnrollmentFactors(e){const t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new Ns("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");return t.mfaRequirements.enroll&&0!==t.mfaRequirements.enroll.length?t.mfaRequirements.enroll:[]}async verify(e){const t=this.contextManager.get(e.mfaToken);if(!t)throw new Ls("mfa_context_not_found","MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");const n=function(e){return "otp"in e&&e.otp?Rt:"oobCode"in e&&e.oobCode?Ot:"recoveryCode"in e&&e.recoveryCode?Ct:void 0}(e);if(!n)throw new Ls("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");const o=t.scope,r=t.audience;try{const t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:o,audience:r,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof Ls)throw new Ls(e.error,e.error_description);throw e}}}class Js extends Error{constructor(e,t,n){super(t),this.name="PasskeyError",this.code=e,this.cause=n,Object.setPrototypeOf(this,Js.prototype);}}var Ms,Hs;class Zs{constructor(e,t){Ms.set(this,void 0),Hs.set(this,void 0),n(this,Ms,e,"f"),n(this,Hs,t,"f");}async signup(n){if(!window.PublicKeyCredential)throw new Js("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n.scope,r=n.audience,i=e(n,["scope","audience"]),a=await t(this,Ms,"f").register(i),s=(c=a.authnParamsPublicKey,Object.assign(Object.assign({},c),{challenge:Vs(c.challenge),user:Object.assign(Object.assign({},c.user),{id:Vs(c.user.id)}),pubKeyCredParams:c.pubKeyCredParams,authenticatorSelection:c.authenticatorSelection}));var c;const u=await navigator.credentials.create({publicKey:s});if(!u)throw new Js("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");const h=function(e){var t;const n=e.response;return {id:e.id,rawId:Fs(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:Fs(n.clientDataJSON),attestationObject:Fs(n.attestationObject)},clientExtensionResults:e.getClientExtensionResults()}}(u);return t(this,Hs,"f")._requestTokenForPasskey({authSession:a.authSession,credential:h,realm:i.realm,organization:i.organization,scope:o,audience:r})}async login(n){if(!window.PublicKeyCredential)throw new Js("passkey_not_supported","WebAuthn is not supported in this browser.");const o=n||{},r=o.scope,i=o.audience,a=e(o,["scope","audience"]),s=await t(this,Ms,"f").challenge(Object.keys(a).length>0?a:void 0),c=(u=s.authnParamsPublicKey,Object.assign(Object.assign({},u),{challenge:Vs(u.challenge)}));var u;const h=await navigator.credentials.get({publicKey:c});if(!h)throw new Js("passkey_cancelled","Passkey authentication was cancelled or no credential was returned.");const l=function(e){var t;const n=e.response;return {id:e.id,rawId:Fs(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{clientDataJSON:Fs(n.clientDataJSON),authenticatorData:Fs(n.authenticatorData),signature:Fs(n.signature),userHandle:n.userHandle?Fs(n.userHandle):void 0},clientExtensionResults:e.getClientExtensionResults()}}(h);return t(this,Hs,"f")._requestTokenForPasskey({authSession:s.authSession,credential:l,realm:a.realm,organization:a.organization,scope:r,audience:i})}}function Fs(e){const t=new Uint8Array(e),n=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Vs(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),o=atob(n),r=new Uint8Array(o.length);for(let e=0;e<o.length;e++)r[e]=o.charCodeAt(e);return r.buffer}Ms=new WeakMap,Hs=new WeakMap;class Xs{resolveOnlineAccess(e){if("online"!==e.refreshTokenMode)return !1;if(!0!==e.useRefreshTokens)throw new A('`refreshTokenMode: "online"` requires the refresh-token grant.',"Set `useRefreshTokens: true`.");if(!0!==e.useDpop)throw new A('`refreshTokenMode: "online"` requires DPoP, which is missing or disabled.',"Set `useDpop: true` (DPoP is mandatory for online access).");return !0}constructor(e){let t,n;if(this.userCache=(new Me).enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0,refreshTokenMode:"offline"},this.onlineAccess=this.resolveOnlineAccess(e),this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),"undefined"!=typeof window&&(()=>{if(!z())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===z().subtle)throw new Error("\n 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.\n ")})(),this.lockManager=(le||(le=he()),le),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)n=e.cache;else {if(t=e.cacheLocation||k,!vt(t))throw new Error('Invalid cache location "'.concat(t,'"'));n=vt(t)();}var o;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:b,this.cookieStorage=!1===e.legacySameSiteCookie?nt:rt,this.orgHintCookieName=(o=this.options.clientId,"auth0.".concat(o,".organization_hint")),this.isAuthenticatedCookieName=(e=>"auth0.".concat(e,".is.authenticated"))(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const r=e.useCookiesForTransactions?this.cookieStorage:it;let i="";var a;this.onlineAccess?i=_:this.options.useRefreshTokens&&(i="offline_access"),this.scope=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];if("object"!=typeof e)return {[P]:Ue(t,e,...o)};let i={[P]:Ue(t,...o)};return Object.keys(e).forEach(n=>{const r=e[n];i[n]=Ue(t,r,...o);}),i}(this.options.authorizationParams.scope,"openid",i),this.transactionManager=new Ze(r,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||T,this.cacheManager=new He(n,n.allKeys?void 0:new yt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new Tt(this.options.clientId):void 0,this.domainUrl=(a=this.options.domain,/^https?:\/\//.test(a)?a:"https://".concat(a)),this.tokenIssuer=((e,t)=>e?e.startsWith("https://")?e:"https://".concat(e,"/"):"".concat(t,"/"))(this.options.issuer,this.domainUrl);const s="".concat(this.domainUrl,"/me/"),c=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:s},detailedResponse:!0})}}));this.myAccount=new At(c,s),this.authJsClient=new Ts({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new Ds(this.authJsClient.mfa,this),this.passkey=new Zs(this.authJsClient.passkey,this),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&t===k&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ft,this.worker.postMessage({type:"init",allowedBaseUrl:this.domainUrl}));}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){const t=this.options.auth0Client||S,n=H(t,!0),o=encodeURIComponent(btoa(JSON.stringify(n)));return "".concat(this.domainUrl).concat(e,"&auth0Client=").concat(o)}_authorizeUrl(e){return this._url("/authorize?".concat(Z(e)))}async _verifyIdToken(e,t,n){const o=await this.nowProvider();return Xe({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(r=this.options.authorizationParams.max_age,"string"!=typeof r?r:parseInt(r,10)||void 0),now:o});var 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});}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{const t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},"",t.toString()));}catch(e){}}_applySessionTransferToken(e){const t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;const n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),Object.assign(Object.assign({},e),{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){var o;const r=J(D()),i=J(D()),a=D(),s=await F(a),c=X(s),u=await(null===(o=this.dpop)||void 0===o?void 0:o.calculateThumbprint()),h=((e,t,n,o,r,i,a,s,c)=>Object.assign(Object.assign(Object.assign({client_id:e.clientId},e.authorizationParams),n),{scope:Le(t,n.scope,n.audience),response_type:"code",response_mode:s||"query",state:o,nonce:r,redirect_uri:a||e.authorizationParams.redirect_uri,code_challenge:i,code_challenge_method:"S256",dpop_jkt:c}))(this.options,this.scope,e,r,i,c,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,null==t?void 0:t.response_mode,u),l=this._authorizeUrl(h);return {nonce:i,code_verifier:a,scope:h.scope,audience:h.audience||P,redirect_uri:h.redirect_uri,state:r,url:l}}async loginWithPopup(e,t){var n;if(e=e||{},!(t=t||{}).popup&&(t.popup=(e=>{const t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,"auth0:authorize:popup","left=".concat(t,",top=").concat(n,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(""),!t.popup))throw new W;const o=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(o,{response_mode:"web_message"},window.location.origin);t.popup.location.href=r.url;const i=await((e,t)=>new Promise((n,o)=>{let r;const i=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(i),clearTimeout(a),window.removeEventListener("message",r,!1),o(new C(e.popup)));},1e3),a=setTimeout(()=>{clearInterval(i),o(new O(e.popup)),window.removeEventListener("message",r,!1);},1e3*(e.timeoutInSeconds||60));r=function(s){if(s.origin===t&&s.data&&"authorization_response"===s.data.type){if(clearTimeout(a),clearInterval(i),window.removeEventListener("message",r,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return o(E.fromPayload(s.data.response));n(s.data.response);}},window.addEventListener("message",r);}))(Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new E("state_mismatch","Invalid state");const a=(null===(n=e.authorizationParams)||void 0===n?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a});}async getUser(){var e;if(await this._isSessionCeilingReached())return;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.user}async getIdTokenClaims(){var e;if(await this._isSessionCeilingReached())return;const t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.claims}async loginWithRedirect(){var t;const n=bt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),o=n.openUrl,r=n.fragment,i=n.appState,a=e(n,["openUrl","fragment","appState"]),s=(null===(t=a.authorizationParams)||void 0===t?void 0:t.organization)||this.options.authorizationParams.organization,c=this._applySessionTransferToken(a.authorizationParams||{}),u=await this._prepareAuthorizeUrl(c),h=u.url,l=e(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},l),{appState:i,response_type:exports.ResponseType.Code}),s&&{organization:s}));const d=r?"".concat(h,"#").concat(r):h;o?await o(d):window.location.assign(d);}async handleRedirectCallback(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.href).split("?").slice(1);if(0===e.length)throw new Error("There are no query params available for parsing.");const t=this.transactionManager.get();if(!t)throw new E("missing_transaction","Invalid state");this.transactionManager.remove();const n=(e=>{e.indexOf("#")>-1&&(e=e.substring(0,e.indexOf("#")));const t=new URLSearchParams(e);return {state:t.get("state"),code:t.get("code")||void 0,connect_code:t.get("connect_code")||void 0,error:t.get("error")||void 0,error_description:t.get("error_description")||void 0}})(e.join(""));return t.response_type===exports.ResponseType.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){const n=e.code,o=e.state,r=e.error,i=e.error_description;if(r)throw new I(r,i||r,o,t.appState);if(!t.code_verifier||t.state&&t.state!==o)throw new E("state_mismatch","Invalid state");const a=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(Object.assign({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:"authorization_code",code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:a}),{appState:t.appState,response_type:exports.ResponseType.Code}}async _handleConnectAccountRedirectCallback(e,t){const n=e.connect_code,o=e.state,r=e.error,i=e.error_description;if(r)throw new x(r,i||r,t.connection,o,t.appState);if(!n)throw new E("missing_connect_code","Missing connect code");if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===o))throw new E("state_mismatch","Invalid state");const a=await this.myAccount.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier});return Object.assign(Object.assign({},a),{appState:t.appState,response_type:exports.ResponseType.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(wt))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(wt);}try{await this.getTokenSilently(e);}catch(e){}}async getTokenSilently(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,n;const o=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Le(this.scope,null===(t=e.authorizationParams)||void 0===t?void 0:t.scope,(null===(n=e.authorizationParams)||void 0===n?void 0:n.audience)||this.options.authorizationParams.audience)})}),r=await((e,t)=>{let n=mt[t];return n||(n=e().finally(()=>{delete mt[t],n=null;}),mt[t]=n),n})(()=>this._getTokenSilently(o),"".concat(this.options.clientId,"::").concat(o.authorizationParams.audience,"::").concat(o.authorizationParams.scope));return e.detailedResponse?r:null==r?void 0:r.access_token}async _getTokenSilently(t){const n=t.cacheMode,o=e(t,["cacheMode"]);if(await this._isSessionCeilingReached())return;if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||P,clientId:this.options.clientId,cacheMode:n});if(e)return e}if("cache-only"===n)return;const r=(i=this.options.clientId,a=o.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(i,".").concat(a));var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if("off"!==n){const e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||P,clientId:this.options.clientId});if(e)return e}const e=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(o):await this._getTokenFromIFrame(o),t=e.id_token,r=e.token_type,i=e.access_token,a=e.oauthTokenScope,s=e.expires_in;return Object.assign(Object.assign({id_token:t,token_type:r,access_token:i},a?{scope:a}:null),{expires_in:s})})}catch(e){if(this._isInteractiveError(e)&&"popup"===this.options.interactiveErrorHandler)return await this._handleInteractiveErrorWithPopup(o);throw e}}_isInteractiveError(e){return e instanceof j||e instanceof E&&this._isIframeMfaError(e)}_isIframeMfaError(e){return "login_required"===e.error&&"Multifactor authentication required"===e.error_description}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});const t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||P,clientId:this.options.clientId});if(!t)throw new E("interactive_handler_cache_miss","Token not found in cache after interactive authentication");return t}catch(e){throw e}}async getTokenWithPopup(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,o;const r=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Le(this.scope,null===(n=e.authorizationParams)||void 0===n?void 0:n.scope,(null===(o=e.authorizationParams)||void 0===o?void 0:o.audience)||this.options.authorizationParams.audience)})});t=Object.assign(Object.assign({},v),t),await this.loginWithPopup(r,t);return (await this.cacheManager.get(new De({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||P,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return !!await this.getUser()}_buildLogoutUrl(t){null!==t.clientId?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const n=t.logoutParams||{},o=n.federated,r=e(n,["federated"]),i=o?"&federated":"";return this._url("/v2/logout?".concat(Z(Object.assign({clientId:t.clientId},r))))+i}async revokeRefreshToken(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.options.useRefreshTokens)return;const t=e.audience||this.options.authorizationParams.audience||P,n=await this.cacheManager.getRefreshTokensByAudience(t,this.options.clientId);await async function(e,t){let n=e.baseUrl,o=e.timeout,r=e.auth0Client,i=e.useFormData,a=e.refreshTokens,s=e.audience,c=e.client_id,u=e.onRefreshTokenRevoked;const h=o||b,l="refresh_token",d="".concat(n,"/oauth/revoke"),p={"Content-Type":i?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(H(r||S)))};if(t){const e={client_id:c,token_type_hint:l},n=i?Z(e):JSON.stringify(e);try{return await Oe({type:"revoke",timeout:h,fetchUrl:d,fetchOptions:{method:"POST",body:n,headers:p},useFormData:i,auth:{audience:null!=s?s:P}},t)}catch(e){throw new E("revoke_error",e.message)}}for(const e of a){const t={client_id:c,token_type_hint:l,token:e},n=i?Z(t):JSON.stringify(t),o=await Ce(d,{method:"POST",body:n,headers:p},h);if(!o.ok){let e,t;try{var f=JSON.parse(await o.text());e=f.error,t=f.error_description;}catch(e){}throw new E(e||"revoke_error",t||"HTTP error ".concat(o.status))}await(null==u?void 0:u(e));}}({baseUrl:this.domainUrl,timeout:this.httpTimeoutMs,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,client_id:this.options.clientId,refreshTokens:n,audience:t,onRefreshTokenRevoked:e=>this.cacheManager.stripRefreshToken(e)},this.worker),this.onlineAccess&&await this._clearLocalSession();}async logout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=bt(t),o=n.openUrl,r=e(n,["openUrl"]);await this._clearLocalSession(t.clientId);const i=this._buildLogoutUrl(r);o?await o(i):!1!==o&&window.location.assign(i);}async _getTokenFromIFrame(e){const t=(n=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(n));var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{const t=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);const o=await this._prepareAuthorizeUrl(t,{response_mode:"web_message"},window.location.origin),r=o.url,i=o.state,a=o.nonce,s=o.code_verifier,c=o.redirect_uri,u=o.scope,h=o.audience;if(window.crossOriginIsolated)throw new E("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const l=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;let d;try{d=new URL(this.domainUrl).origin;}catch(e){d=this.domainUrl;}const p=await function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;return new Promise((o,r)=>{const i=window.document.createElement("iframe");i.setAttribute("width","0"),i.setAttribute("height","0"),i.style.display="none";const a=()=>{window.document.body.contains(i)&&(window.document.body.removeChild(i),window.removeEventListener("message",s,!1));};let s;const c=setTimeout(()=>{r(new R),a();},1e3*n);s=function(e){if(e.origin!=t)return;if(!e.data||"authorization_response"!==e.data.type)return;const n=e.source;n&&n.close(),e.data.response.error?r(E.fromPayload(e.data.response)):o(e.data.response),clearTimeout(c),window.removeEventListener("message",s,!1),setTimeout(a,2e3);},window.addEventListener("message",s,!1),window.document.body.appendChild(i),i.setAttribute("src",e);})}(r,d,l);if(i!==p.state)throw new E("state_mismatch","Invalid state");const f=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:p.code,grant_type:"authorization_code",redirect_uri:c,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return Object.assign(Object.assign({},f),{scope:u,oauthTokenScope:f.scope,audience:h})})}catch(e){if("login_required"===e.error){e instanceof E&&this._isIframeMfaError(e)&&"popup"===this.options.interactiveErrorHandler||this.logout({openUrl:!1});}throw e}}async _getTokenUsingRefreshToken(e){const t=await this.cacheManager.get(new De({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||P,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(t&&t.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new K(e.authorizationParams.audience||P,e.authorizationParams.scope)}const n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,o="number"==typeof e.timeoutInSeconds?1e3*e.timeoutInSeconds:null,r=((e,t,n,o)=>{var r;if(e&&n&&o){if(t.audience!==n)return t.scope;const e=o.split(" "),i=(null===(r=t.scope)||void 0===r?void 0:r.split(" "))||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?o:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,null==t?void 0:t.audience,null==t?void 0:t.scope);try{const u=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:t&&t.refresh_token,redirect_uri:n}),o&&{timeout:o}),{scopesToRequest:r});if(!this.onlineAccess&&u.refresh_token&&(null==t?void 0:t.refresh_token)&&await this.cacheManager.updateEntry(t.refresh_token,u.refresh_token),this.options.useMrrt){if(i=null==t?void 0:t.audience,a=null==t?void 0:t.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,i!==s||!((e,t)=>{const n=(null==t?void 0:t.split(" "))||[];return ((null==e?void 0:e.split(" "))||[]).every(e=>n.includes(e))})(c,a)){const t=kt(r,u.scope,this.onlineAccess);if(t){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope),new U(e.authorizationParams.audience||"default",t)}}}return Object.assign(Object.assign({},u),{scope:e.authorizationParams.scope,oauthTokenScope:u.scope,audience:e.authorizationParams.audience||P})}catch(t){if(t.message){if(t.message.includes("user is blocked"))throw await this.logout({openUrl:!1}),t;if((t.message.includes("Missing Refresh Token")||t.message.includes("invalid refresh token"))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t}var i,a,s,c;}async _saveEntryInCache(t){const n=t.decodedToken.claims,o=n.session_expiry,r=n.iat;if(void 0!==o){if("number"!=typeof o)throw new E("invalid_token","Invalid session_expiry: value must be a number.");if(o>=1e10)throw new E("invalid_token","Invalid session_expiry: value appears to be in milliseconds; expected a Unix timestamp in seconds.");if(void 0===r||o<=r)throw new E("invalid_token","Invalid session_expiry: session ceiling is before or at the token issue time.")}const i=t.id_token,a=t.decodedToken,s=e(t,["id_token","decodedToken"]);this.userCache.set(ze,{id_token:i,decodedToken:a}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(s);}async _clearLocalSession(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.clientId;var t;null===e?await this.cacheManager.clear():await this.cacheManager.clear(e),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(ze);try{await(null===(t=this.dpop)||void 0===t?void 0:t.clear());}catch(e){}if(this.worker)try{await Oe({type:"clear"},this.worker);}catch(e){}}async _isSessionCeilingReached(){var e,t;const n=this.userCache.get(ze),o=null!=n?n:await this.cacheManager.getIdToken(new De({clientId:this.options.clientId})),r=null===(t=null===(e=null==o?void 0:o.decodedToken)||void 0===e?void 0:e.claims)||void 0===t?void 0:t.session_expiry;if(void 0===r)return !1;const i=await this.nowProvider();return Math.floor(i/1e3)>=r-30&&(await this._clearLocalSession(),!0)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||P,t=this.scope[e],n=await this.cacheManager.getIdToken(new De({clientId:this.options.clientId,audience:e,scope:t})),o=this.userCache.get(ze);return n&&n.id_token===(null==o?void 0:o.id_token)?o:(this.userCache.set(ze,n),n)}async _getEntryFromCache(e){let t=e.scope,n=e.audience,o=e.clientId,r=e.cacheMode;const i=await this.cacheManager.get(new De({scope:t,audience:n,clientId:o}),60,this.options.useMrrt,r);if(i&&i.access_token){const e=i.token_type,t=i.access_token,n=i.oauthTokenScope,o=i.expires_in,r=await this._getIdTokenFromCache();return r&&Object.assign(Object.assign({id_token:r.id_token,token_type:e||"Bearer",access_token:t},n?{scope:n}:null),{expires_in:o})}}_storeMfaContext(e,t,n){e instanceof j&&this.mfa.setMFAAuthDetails(e.mfa_token,t,n,e.mfa_requirements);}async _requestToken(e,t){var n,o,r,i,a,s;const c=t||{},u=c.nonceIn,h=c.organization,l=c.scopesToRequest;try{const t=await Ke(Object.assign(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop,preserveRefreshToken:this.onlineAccess},e),{scope:l||e.scope}),this.worker);let c=await this._verifyIdToken(t.id_token,u,h);if("authorization_code"===e.grant_type){const e=await this._getIdTokenFromCache();(null===(o=null===(n=null==e?void 0:e.decodedToken)||void 0===n?void 0:n.claims)||void 0===o?void 0:o.sub)&&e.decodedToken.claims.sub!==c.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(ze));}if("authorization_code"!==e.grant_type){const e=await this._getIdTokenFromCache(),t=null===(i=null===(r=null==e?void 0:e.decodedToken)||void 0===r?void 0:r.claims)||void 0===i?void 0:i.session_expiry;void 0!==t&&(c=Object.assign(Object.assign({},c),{claims:Object.assign(Object.assign({},c.claims),{session_expiry:t})}));}return !t.refresh_token&&this.onlineAccess&&(t.refresh_token=null!==(a=e.refresh_token)&&void 0!==a?a:null===(s=await this.cacheManager.get(new De({scope:l||e.scope,audience:e.audience||P,clientId:this.options.clientId}),void 0,this.options.useMrrt))||void 0===s?void 0:s.refresh_token),await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},t),{decodedToken:c,scope:e.scope,audience:e.audience||P}),t.scope?{oauthTokenScope:t.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(h||c.claims.org_id),Object.assign(Object.assign({},t),{decodedToken:c})}catch(t){throw "authorization_code"!==e.grant_type&&this._storeMfaContext(t,l||e.scope,e.audience),t}}_buildTokenExchangeParams(e){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e),{grant_type:"urn:ietf:params:oauth:grant-type:token-exchange",subject_token:e.subject_token,subject_token_type:e.subject_token_type}),e.actor_token&&{actor_token:e.actor_token}),e.actor_token_type&&{actor_token_type:e.actor_token_type}),{scope:Le(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization})}async loginWithCustomTokenExchange(e){return this._requestToken(this._buildTokenExchangeParams(e))}async customTokenExchange(e){const t=this._buildTokenExchangeParams(e);try{const n=await Ke(Object.assign(Object.assign({},t),{baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,dpop:this.dpop}),this.worker,!0);return n.id_token&&await this._verifyIdToken(n.id_token,void 0,e.organization),n}catch(e){throw this._storeMfaContext(e,t.scope,t.audience),e}}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw new Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(e){return this._assertDpop(this.dpop),this.dpop.getNonce(e)}setDpopNonce(e,t){return this._assertDpop(this.dpop),this.dpop.setNonce(e,t)}generateDpopProof(e){return this._assertDpop(this.dpop),this.dpop.generateProof(e)}createFetcher(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Et(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:null==e?void 0:e.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){const t=e.openUrl,n=e.appState,o=e.connection,r=e.scopes,i=e.authorization_params,a=e.redirectUri,s=void 0===a?this.options.authorizationParams.redirect_uri||window.location.origin:a;if(!o)throw new Error("connection is required");const c=J(D()),u=D(),h=await F(u),l=X(h),d=await this.myAccount.connectAccount({connection:o,scopes:r,redirect_uri:s,state:c,code_challenge:l,code_challenge_method:"S256",authorization_params:i}),p=d.connect_uri,f=d.connect_params,m=d.auth_session;this.transactionManager.create({state:c,code_verifier:u,auth_session:m,redirect_uri:s,appState:n,connection:o,response_type:exports.ResponseType.ConnectCode});const y=new URL(p);y.searchParams.set("ticket",f.ticket),t?await t(y.toString()):window.location.assign(y);}async _requestTokenForPasskey(e){const t=e.audience||this.options.authorizationParams.audience,n=e.organization||this.options.authorizationParams.organization;return this._requestToken(Object.assign(Object.assign(Object.assign({grant_type:"urn:okta:params:oauth:grant-type:webauthn",auth_session:e.authSession,authn_response:e.credential},e.realm&&{realm:e.realm}),n&&{organization:n}),{scope:Le(this.scope,e.scope,t),audience:t}))}async _requestTokenForMfa(t,n){const o=t.mfaToken,r=e(t,["mfaToken"]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:o}),n)}}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* The initial auth state.
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
/**
|
|
133
133
|
* @ignore
|
|
134
134
|
*/
|
|
135
|
-
var initialContext = __assign(__assign({}, initialAuthState), { buildAuthorizeUrl: stub, buildLogoutUrl: stub, getAccessTokenSilently: stub, getAccessTokenWithPopup: stub, getIdTokenClaims: stub, loginWithCustomTokenExchange: stub, customTokenExchange: stub, exchangeToken: stub, loginWithRedirect: stub, loginWithPopup: stub, connectAccountWithRedirect: stub, logout: stub, handleRedirectCallback: stub, getDpopNonce: stub, setDpopNonce: stub, generateDpopProof: stub, createFetcher: stub, getConfiguration: stub, mfa: {
|
|
135
|
+
var initialContext = __assign(__assign({}, initialAuthState), { buildAuthorizeUrl: stub, buildLogoutUrl: stub, getAccessTokenSilently: stub, getAccessTokenWithPopup: stub, getIdTokenClaims: stub, loginWithCustomTokenExchange: stub, customTokenExchange: stub, exchangeToken: stub, loginWithRedirect: stub, loginWithPopup: stub, connectAccountWithRedirect: stub, logout: stub, revokeRefreshToken: stub, handleRedirectCallback: stub, getDpopNonce: stub, setDpopNonce: stub, generateDpopProof: stub, createFetcher: stub, getConfiguration: stub, mfa: {
|
|
136
136
|
getAuthenticators: stub,
|
|
137
137
|
enroll: stub,
|
|
138
138
|
challenge: stub,
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
deprecateRedirectUri(opts);
|
|
258
258
|
return __assign(__assign({}, opts), { auth0Client: {
|
|
259
259
|
name: 'auth0-react',
|
|
260
|
-
version: '2.
|
|
260
|
+
version: '2.21.0',
|
|
261
261
|
} });
|
|
262
262
|
};
|
|
263
263
|
/**
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
'configuration options. Remove `domain`, `clientId`, and any other Auth0Client configuration ' +
|
|
287
287
|
'props when using the `client` prop.');
|
|
288
288
|
}
|
|
289
|
-
var client = React.useState(function () { return providedClient !== null && providedClient !== void 0 ? providedClient : new
|
|
289
|
+
var client = React.useState(function () { return providedClient !== null && providedClient !== void 0 ? providedClient : new Xs(toAuth0ClientOptions(clientOpts)); })[0];
|
|
290
290
|
var _d = React.useReducer((reducer), initialAuthState), state = _d[0], dispatch = _d[1];
|
|
291
291
|
var didInitialise = React.useRef(false);
|
|
292
292
|
var handleError = React.useCallback(function (error) {
|
|
@@ -386,6 +386,9 @@
|
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
388
|
}, [client]);
|
|
389
|
+
var revokeRefreshToken = React.useCallback(function (options) {
|
|
390
|
+
return client.revokeRefreshToken(options);
|
|
391
|
+
}, [client]);
|
|
389
392
|
var getAccessTokenSilently = React.useCallback(
|
|
390
393
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
391
394
|
function (opts) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -583,7 +586,7 @@
|
|
|
583
586
|
}); }, [client]);
|
|
584
587
|
var passkey = React.useMemo(function () { return ({ signup: passkeySignup, login: passkeyLogin }); }, [passkeySignup, passkeyLogin]);
|
|
585
588
|
var contextValue = React.useMemo(function () {
|
|
586
|
-
return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount });
|
|
589
|
+
return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, revokeRefreshToken: revokeRefreshToken, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount });
|
|
587
590
|
}, [
|
|
588
591
|
state,
|
|
589
592
|
getAccessTokenSilently,
|
|
@@ -596,6 +599,7 @@
|
|
|
596
599
|
loginWithPopup,
|
|
597
600
|
connectAccountWithRedirect,
|
|
598
601
|
logout,
|
|
602
|
+
revokeRefreshToken,
|
|
599
603
|
handleRedirectCallback,
|
|
600
604
|
getDpopNonce,
|
|
601
605
|
setDpopNonce,
|
|
@@ -725,31 +729,31 @@
|
|
|
725
729
|
|
|
726
730
|
exports.Auth0Context = Auth0Context;
|
|
727
731
|
exports.Auth0Provider = Auth0Provider;
|
|
728
|
-
exports.AuthenticationError =
|
|
729
|
-
exports.ConnectError =
|
|
732
|
+
exports.AuthenticationError = I;
|
|
733
|
+
exports.ConnectError = x;
|
|
730
734
|
exports.GenericError = E;
|
|
731
|
-
exports.InMemoryCache =
|
|
735
|
+
exports.InMemoryCache = Me;
|
|
732
736
|
exports.LocalStorageCache = Je;
|
|
733
|
-
exports.MfaChallengeError =
|
|
734
|
-
exports.MfaEnrollmentError =
|
|
735
|
-
exports.MfaEnrollmentFactorsError =
|
|
736
|
-
exports.MfaError =
|
|
737
|
-
exports.MfaListAuthenticatorsError =
|
|
738
|
-
exports.MfaRequiredError =
|
|
739
|
-
exports.MfaVerifyError =
|
|
740
|
-
exports.MissingRefreshTokenError =
|
|
741
|
-
exports.MyAccountApiError =
|
|
737
|
+
exports.MfaChallengeError = Us;
|
|
738
|
+
exports.MfaEnrollmentError = Ks;
|
|
739
|
+
exports.MfaEnrollmentFactorsError = Ns;
|
|
740
|
+
exports.MfaError = Ws;
|
|
741
|
+
exports.MfaListAuthenticatorsError = js;
|
|
742
|
+
exports.MfaRequiredError = j;
|
|
743
|
+
exports.MfaVerifyError = Ls;
|
|
744
|
+
exports.MissingRefreshTokenError = K;
|
|
745
|
+
exports.MyAccountApiError = It;
|
|
742
746
|
exports.OAuthError = OAuthError;
|
|
743
|
-
exports.PasskeyChallengeError =
|
|
744
|
-
exports.PasskeyError =
|
|
745
|
-
exports.PasskeyGetTokenError =
|
|
746
|
-
exports.PasskeyRegisterError =
|
|
747
|
-
exports.PopupCancelledError =
|
|
748
|
-
exports.PopupOpenError =
|
|
749
|
-
exports.PopupTimeoutError =
|
|
747
|
+
exports.PasskeyChallengeError = rs;
|
|
748
|
+
exports.PasskeyError = Js;
|
|
749
|
+
exports.PasskeyGetTokenError = is;
|
|
750
|
+
exports.PasskeyRegisterError = os;
|
|
751
|
+
exports.PopupCancelledError = C;
|
|
752
|
+
exports.PopupOpenError = W;
|
|
753
|
+
exports.PopupTimeoutError = O;
|
|
750
754
|
exports.TimeoutError = R;
|
|
751
|
-
exports.UseDpopNonceError =
|
|
752
|
-
exports.User =
|
|
755
|
+
exports.UseDpopNonceError = L;
|
|
756
|
+
exports.User = ct;
|
|
753
757
|
exports.initialContext = initialContext;
|
|
754
758
|
exports.useAuth0 = useAuth0;
|
|
755
759
|
exports.withAuth0 = withAuth0;
|