UNPKG

@auth0/auth0-spa-js

Version:

Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE

3 lines (2 loc) 43.5 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).createAuth0Client=t()}(this,function(){"use strict";var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};var t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function n(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function r(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,c)}u((r=r.apply(e,t||[])).next())})}function o(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(e,t){return e(t={exports:{}},t.exports),t.exports}var c,u,s,f="object",l=function(e){return e&&e.Math==Math&&e},p=l(typeof globalThis==f&&globalThis)||l(typeof window==f&&window)||l(typeof self==f&&self)||l(typeof i==f&&i)||Function("return this")(),d=function(e){try{return!!e()}catch(e){return!0}},h=!d(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),y={}.propertyIsEnumerable,v=Object.getOwnPropertyDescriptor,m={f:v&&!y.call({1:2},1)?function(e){var t=v(this,e);return!!t&&t.enumerable}:y},w=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},g={}.toString,b=function(e){return g.call(e).slice(8,-1)},_="".split,E=d(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==b(e)?_.call(e,""):Object(e)}:Object,T=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},S=function(e){return E(T(e))},O=function(e){return"object"==typeof e?null!==e:"function"==typeof e},k=function(e,t){if(!O(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!O(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!O(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!O(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},A={}.hasOwnProperty,x=function(e,t){return A.call(e,t)},j=p.document,I=O(j)&&O(j.createElement),P=function(e){return I?j.createElement(e):{}},C=!h&&!d(function(){return 7!=Object.defineProperty(P("div"),"a",{get:function(){return 7}}).a}),U=Object.getOwnPropertyDescriptor,D={f:h?U:function(e,t){if(e=S(e),t=k(t,!0),C)try{return U(e,t)}catch(e){}if(x(e,t))return w(!m.f.call(e,t),e[t])}},F=function(e){if(!O(e))throw TypeError(String(e)+" is not an object");return e},R=Object.defineProperty,L={f:h?R:function(e,t,n){if(F(e),t=k(t,!0),F(n),C)try{return R(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},M=h?function(e,t,n){return L.f(e,t,w(1,n))}:function(e,t,n){return e[t]=n,e},z=function(e,t){try{M(p,e,t)}catch(n){p[e]=t}return t},N=a(function(e){var t=p["__core-js_shared__"]||z("__core-js_shared__",{});(e.exports=function(e,n){return t[e]||(t[e]=void 0!==n?n:{})})("versions",[]).push({version:"3.2.1",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),W=N("native-function-to-string",Function.toString),q=p.WeakMap,B="function"==typeof q&&/native code/.test(W.call(q)),J=0,G=Math.random(),H=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++J+G).toString(36)},Y=N("keys"),V=function(e){return Y[e]||(Y[e]=H(e))},K={},Q=p.WeakMap;if(B){var X=new Q,Z=X.get,$=X.has,ee=X.set;c=function(e,t){return ee.call(X,e,t),t},u=function(e){return Z.call(X,e)||{}},s=function(e){return $.call(X,e)}}else{var te=V("state");K[te]=!0,c=function(e,t){return M(e,te,t),t},u=function(e){return x(e,te)?e[te]:{}},s=function(e){return x(e,te)}}var ne={set:c,get:u,has:s,enforce:function(e){return s(e)?u(e):c(e,{})},getterFor:function(e){return function(t){var n;if(!O(t)||(n=u(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},re=a(function(e){var t=ne.get,n=ne.enforce,r=String(W).split("toString");N("inspectSource",function(e){return W.call(e)}),(e.exports=function(e,t,o,i){var a=!!i&&!!i.unsafe,c=!!i&&!!i.enumerable,u=!!i&&!!i.noTargetGet;"function"==typeof o&&("string"!=typeof t||x(o,"name")||M(o,"name",t),n(o).source=r.join("string"==typeof t?t:"")),e!==p?(a?!u&&e[t]&&(c=!0):delete e[t],c?e[t]=o:M(e,t,o)):c?e[t]=o:z(t,o)})(Function.prototype,"toString",function(){return"function"==typeof this&&t(this).source||W.call(this)})}),oe=p,ie=function(e){return"function"==typeof e?e:void 0},ae=function(e,t){return arguments.length<2?ie(oe[e])||ie(p[e]):oe[e]&&oe[e][t]||p[e]&&p[e][t]},ce=Math.ceil,ue=Math.floor,se=function(e){return isNaN(e=+e)?0:(e>0?ue:ce)(e)},fe=Math.min,le=function(e){return e>0?fe(se(e),9007199254740991):0},pe=Math.max,de=Math.min,he=function(e){return function(t,n,r){var o,i=S(t),a=le(i.length),c=function(e,t){var n=se(e);return n<0?pe(n+t,0):de(n,t)}(r,a);if(e&&n!=n){for(;a>c;)if((o=i[c++])!=o)return!0}else for(;a>c;c++)if((e||c in i)&&i[c]===n)return e||c||0;return!e&&-1}},ye={includes:he(!0),indexOf:he(!1)},ve=ye.indexOf,me=function(e,t){var n,r=S(e),o=0,i=[];for(n in r)!x(K,n)&&x(r,n)&&i.push(n);for(;t.length>o;)x(r,n=t[o++])&&(~ve(i,n)||i.push(n));return i},we=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ge=we.concat("length","prototype"),be={f:Object.getOwnPropertyNames||function(e){return me(e,ge)}},_e={f:Object.getOwnPropertySymbols},Ee=ae("Reflect","ownKeys")||function(e){var t=be.f(F(e)),n=_e.f;return n?t.concat(n(e)):t},Te=function(e,t){for(var n=Ee(t),r=L.f,o=D.f,i=0;i<n.length;i++){var a=n[i];x(e,a)||r(e,a,o(t,a))}},Se=/#|\.prototype\./,Oe=function(e,t){var n=Ae[ke(e)];return n==je||n!=xe&&("function"==typeof t?d(t):!!t)},ke=Oe.normalize=function(e){return String(e).replace(Se,".").toLowerCase()},Ae=Oe.data={},xe=Oe.NATIVE="N",je=Oe.POLYFILL="P",Ie=Oe,Pe=D.f,Ce=function(e,t){var n,r,o,i,a,c=e.target,u=e.global,s=e.stat;if(n=u?p:s?p[c]||z(c,{}):(p[c]||{}).prototype)for(r in t){if(i=t[r],o=e.noTargetGet?(a=Pe(n,r))&&a.value:n[r],!Ie(u?r:c+(s?".":"#")+r,e.forced)&&void 0!==o){if(typeof i==typeof o)continue;Te(i,o)}(e.sham||o&&o.sham)&&M(i,"sham",!0),re(n,r,i,e)}},Ue=!!Object.getOwnPropertySymbols&&!d(function(){return!String(Symbol())}),De=p.Symbol,Fe=N("wks"),Re=function(e){return Fe[e]||(Fe[e]=Ue&&De[e]||(Ue?De:H)("Symbol."+e))},Le=Re("match"),Me=function(e){if(function(e){var t;return O(e)&&(void 0!==(t=e[Le])?!!t:"RegExp"==b(e))}(e))throw TypeError("The method doesn't accept regular expressions");return e},ze=Re("match"),Ne="".startsWith,We=Math.min;Ce({target:"String",proto:!0,forced:!function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[ze]=!1,"/./"[e](t)}catch(e){}}return!1}("startsWith")},{startsWith:function(e){var t=String(T(this));Me(e);var n=le(We(arguments.length>1?arguments[1]:void 0,t.length)),r=String(e);return Ne?Ne.call(t,r,n):t.slice(n,n+r.length)===r}});var qe,Be,Je,Ge=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},He=function(e,t,n){if(Ge(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,o){return e.call(t,n,r,o)}}return function(){return e.apply(t,arguments)}},Ye=Function.call,Ve=function(e,t,n){return He(Ye,p[e].prototype[t],n)},Ke=(Ve("String","startsWith"),function(e){return function(t,n){var r,o,i=String(T(t)),a=se(n),c=i.length;return a<0||a>=c?e?"":void 0:(r=i.charCodeAt(a))<55296||r>56319||a+1===c||(o=i.charCodeAt(a+1))<56320||o>57343?e?i.charAt(a):r:e?i.slice(a,a+2):o-56320+(r-55296<<10)+65536}}),Qe={codeAt:Ke(!1),charAt:Ke(!0)},Xe=function(e){return Object(T(e))},Ze=!d(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),$e=V("IE_PROTO"),et=Object.prototype,tt=Ze?Object.getPrototypeOf:function(e){return e=Xe(e),x(e,$e)?e[$e]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?et:null},nt=Re("iterator"),rt=!1;[].keys&&("next"in(Je=[].keys())?(Be=tt(tt(Je)))!==Object.prototype&&(qe=Be):rt=!0),null==qe&&(qe={}),x(qe,nt)||M(qe,nt,function(){return this});var ot={IteratorPrototype:qe,BUGGY_SAFARI_ITERATORS:rt},it=Object.keys||function(e){return me(e,we)},at=h?Object.defineProperties:function(e,t){F(e);for(var n,r=it(t),o=r.length,i=0;o>i;)L.f(e,n=r[i++],t[n]);return e},ct=ae("document","documentElement"),ut=V("IE_PROTO"),st=function(){},ft=function(){var e,t=P("iframe"),n=we.length;for(t.style.display="none",ct.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write("<script>document.F=Object<\/script>"),e.close(),ft=e.F;n--;)delete ft.prototype[we[n]];return ft()},lt=Object.create||function(e,t){var n;return null!==e?(st.prototype=F(e),n=new st,st.prototype=null,n[ut]=e):n=ft(),void 0===t?n:at(n,t)};K[ut]=!0;var pt=L.f,dt=Re("toStringTag"),ht=function(e,t,n){e&&!x(e=n?e:e.prototype,dt)&&pt(e,dt,{configurable:!0,value:t})},yt={},vt=ot.IteratorPrototype,mt=function(){return this},wt=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return F(n),function(e){if(!O(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype")}(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),gt=ot.IteratorPrototype,bt=ot.BUGGY_SAFARI_ITERATORS,_t=Re("iterator"),Et=function(){return this},Tt=Qe.charAt,St=ne.set,Ot=ne.getterFor("String Iterator");!function(e,t,n,r,o,i,a){!function(e,t,n){var r=t+" Iterator";e.prototype=lt(vt,{next:w(1,n)}),ht(e,r,!1),yt[r]=mt}(n,t,r);var c,u,s,f=function(e){if(e===o&&y)return y;if(!bt&&e in d)return d[e];switch(e){case"keys":case"values":case"entries":return function(){return new n(this,e)}}return function(){return new n(this)}},l=t+" Iterator",p=!1,d=e.prototype,h=d[_t]||d["@@iterator"]||o&&d[o],y=!bt&&h||f(o),v="Array"==t&&d.entries||h;if(v&&(c=tt(v.call(new e)),gt!==Object.prototype&&c.next&&(tt(c)!==gt&&(wt?wt(c,gt):"function"!=typeof c[_t]&&M(c,_t,Et)),ht(c,l,!0))),"values"==o&&h&&"values"!==h.name&&(p=!0,y=function(){return h.call(this)}),d[_t]!==y&&M(d,_t,y),yt[t]=y,o)if(u={values:f("values"),keys:i?y:f("keys"),entries:f("entries")},a)for(s in u)!bt&&!p&&s in d||re(d,s,u[s]);else Ce({target:t,proto:!0,forced:bt||p},u)}(String,"String",function(e){St(this,{type:"String Iterator",string:String(e),index:0})},function(){var e,t=Ot(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=Tt(n,r),t.index+=e.length,{value:e,done:!1})});var kt=function(e,t,n,r){try{return r?t(F(n)[0],n[1]):t(n)}catch(t){var o=e.return;throw void 0!==o&&F(o.call(e)),t}},At=Re("iterator"),xt=Array.prototype,jt=function(e){return void 0!==e&&(yt.Array===e||xt[At]===e)},It=function(e,t,n){var r=k(t);r in e?L.f(e,r,w(0,n)):e[r]=n},Pt=Re("toStringTag"),Ct="Arguments"==b(function(){return arguments}()),Ut=function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Pt))?n:Ct?b(t):"Object"==(r=b(t))&&"function"==typeof t.callee?"Arguments":r},Dt=Re("iterator"),Ft=function(e){if(null!=e)return e[Dt]||e["@@iterator"]||yt[Ut(e)]},Rt=Re("iterator"),Lt=!1;try{var Mt=0,zt={next:function(){return{done:!!Mt++}},return:function(){Lt=!0}};zt[Rt]=function(){return this},Array.from(zt,function(){throw 2})}catch(e){}var Nt=!function(e,t){if(!t&&!Lt)return!1;var n=!1;try{var r={};r[Rt]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n}(function(e){Array.from(e)});Ce({target:"Array",stat:!0,forced:Nt},{from:function(e){var t,n,r,o,i=Xe(e),a="function"==typeof this?this:Array,c=arguments.length,u=c>1?arguments[1]:void 0,s=void 0!==u,f=0,l=Ft(i);if(s&&(u=He(u,c>2?arguments[2]:void 0,2)),null==l||a==Array&&jt(l))for(n=new a(t=le(i.length));t>f;f++)It(n,f,s?u(i[f],f):i[f]);else for(o=l.call(i),n=new a;!(r=o.next()).done;f++)It(n,f,s?kt(o,u,[r.value,f],!0):r.value);return n.length=f,n}});oe.Array.from;var Wt,qt=L.f,Bt=p.DataView,Jt=Bt&&Bt.prototype,Gt=p.Int8Array,Ht=Gt&&Gt.prototype,Yt=p.Uint8ClampedArray,Vt=Yt&&Yt.prototype,Kt=Gt&&tt(Gt),Qt=Ht&&tt(Ht),Xt=Object.prototype,Zt=Xt.isPrototypeOf,$t=Re("toStringTag"),en=H("TYPED_ARRAY_TAG"),tn=!(!p.ArrayBuffer||!Bt),nn=tn&&!!wt&&"Opera"!==Ut(p.opera),rn={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},on=function(e){return O(e)&&x(rn,Ut(e))};for(Wt in rn)p[Wt]||(nn=!1);if((!nn||"function"!=typeof Kt||Kt===Function.prototype)&&(Kt=function(){throw TypeError("Incorrect invocation")},nn))for(Wt in rn)p[Wt]&&wt(p[Wt],Kt);if((!nn||!Qt||Qt===Xt)&&(Qt=Kt.prototype,nn))for(Wt in rn)p[Wt]&&wt(p[Wt].prototype,Qt);if(nn&&tt(Vt)!==Qt&&wt(Vt,Qt),h&&!x(Qt,$t))for(Wt in!0,qt(Qt,$t,{get:function(){return O(this)?this[en]:void 0}}),rn)p[Wt]&&M(p[Wt],en,Wt);tn&&wt&&tt(Jt)!==Xt&&wt(Jt,Xt);var an=function(e){if(on(e))return e;throw TypeError("Target is not a typed array")},cn=function(e){if(wt){if(Zt.call(Kt,e))return e}else for(var t in rn)if(x(rn,Wt)){var n=p[t];if(n&&(e===n||Zt.call(n,e)))return e}throw TypeError("Target is not a typed array constructor")},un=function(e,t,n){if(h){if(n)for(var r in rn){var o=p[r];o&&x(o.prototype,e)&&delete o.prototype[e]}Qt[e]&&!n||re(Qt,e,n?t:nn&&Ht[e]||t)}},sn=Re("species"),fn=an,ln=cn,pn=[].slice;un("slice",function(e,t){for(var n=pn.call(fn(this),e,t),r=function(e,t){var n,r=F(e).constructor;return void 0===r||null==(n=F(r)[sn])?t:Ge(n)}(this,this.constructor),o=0,i=n.length,a=new(ln(r))(i);i>o;)a[o]=n[o++];return a},d(function(){new Int8Array(1).slice()}));var dn=Re("unscopables"),hn=Array.prototype;null==hn[dn]&&M(hn,dn,lt(null));var yn,vn=ye.includes;Ce({target:"Array",proto:!0},{includes:function(e){return vn(this,e,arguments.length>1?arguments[1]:void 0)}}),yn="includes",hn[dn][yn]=!0;Ve("Array","includes");function mn(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){return t.reject(n)})})}var wn=setTimeout;function gn(e){return Boolean(e&&void 0!==e.length)}function bn(){}function _n(e){if(!(this instanceof _n))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],An(e,this)}function En(e,t){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,_n._immediateFn(function(){var n=1===e._state?t.onFulfilled:t.onRejected;if(null!==n){var r;try{r=n(e._value)}catch(e){return void Sn(t.promise,e)}Tn(t.promise,r)}else(1===e._state?Tn:Sn)(t.promise,e._value)})):e._deferreds.push(t)}function Tn(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if(t instanceof _n)return e._state=3,e._value=t,void On(e);if("function"==typeof n)return void An((r=n,o=t,function(){r.apply(o,arguments)}),e)}e._state=1,e._value=t,On(e)}catch(t){Sn(e,t)}var r,o}function Sn(e,t){e._state=2,e._value=t,On(e)}function On(e){2===e._state&&0===e._deferreds.length&&_n._immediateFn(function(){e._handled||_n._unhandledRejectionFn(e._value)});for(var t=0,n=e._deferreds.length;t<n;t++)En(e,e._deferreds[t]);e._deferreds=null}function kn(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function An(e,t){var n=!1;try{e(function(e){n||(n=!0,Tn(t,e))},function(e){n||(n=!0,Sn(t,e))})}catch(e){if(n)return;n=!0,Sn(t,e)}}_n.prototype.catch=function(e){return this.then(null,e)},_n.prototype.then=function(e,t){var n=new this.constructor(bn);return En(this,new kn(e,t,n)),n},_n.prototype.finally=mn,_n.all=function(e){return new _n(function(t,n){if(!gn(e))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(e);if(0===r.length)return t([]);var o=r.length;function i(e,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var c=a.then;if("function"==typeof c)return void c.call(a,function(t){i(e,t)},n)}r[e]=a,0==--o&&t(r)}catch(e){n(e)}}for(var a=0;a<r.length;a++)i(a,r[a])})},_n.resolve=function(e){return e&&"object"==typeof e&&e.constructor===_n?e:new _n(function(t){t(e)})},_n.reject=function(e){return new _n(function(t,n){n(e)})},_n.race=function(e){return new _n(function(t,n){if(!gn(e))return n(new TypeError("Promise.race accepts an array"));for(var r=0,o=e.length;r<o;r++)_n.resolve(e[r]).then(t,n)})},_n._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){wn(e,0)},_n._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var xn=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();"Promise"in xn?xn.Promise.prototype.finally||(xn.Promise.prototype.finally=mn):xn.Promise=_n,function(e){function t(e){if("utf-8"!==(e=void 0===e?"utf-8":e))throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('"+e+"') is invalid.")}function n(e,t){if(t=void 0===t?{fatal:!1}:t,"utf-8"!==(e=void 0===e?"utf-8":e))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+e+"') is invalid.");if(t.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(e.TextEncoder&&e.TextDecoder)return!1;Object.defineProperty(t.prototype,"encoding",{value:"utf-8"}),t.prototype.encode=function(e,t){if((t=void 0===t?{stream:!1}:t).stream)throw Error("Failed to encode: the 'stream' option is unsupported.");t=0;for(var n=e.length,r=0,o=Math.max(32,n+(n>>1)+7),i=new Uint8Array(o>>3<<3);t<n;){var a=e.charCodeAt(t++);if(55296<=a&&56319>=a){if(t<n){var c=e.charCodeAt(t);56320==(64512&c)&&(++t,a=((1023&a)<<10)+(1023&c)+65536)}if(55296<=a&&56319>=a)continue}if(r+4>i.length&&(o+=8,o=(o*=1+t/e.length*2)>>3<<3,(c=new Uint8Array(o)).set(i),i=c),0==(4294967168&a))i[r++]=a;else{if(0==(4294965248&a))i[r++]=a>>6&31|192;else if(0==(4294901760&a))i[r++]=a>>12&15|224,i[r++]=a>>6&63|128;else{if(0!=(4292870144&a))continue;i[r++]=a>>18&7|240,i[r++]=a>>12&63|128,i[r++]=a>>6&63|128}i[r++]=63&a|128}}return i.slice(0,r)},Object.defineProperty(n.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(n.prototype,"fatal",{value:!1}),Object.defineProperty(n.prototype,"ignoreBOM",{value:!1}),n.prototype.decode=function(e,t){if((t=void 0===t?{stream:!1}:t).stream)throw Error("Failed to decode: the 'stream' option is unsupported.");t=0;for(var n=(e=new Uint8Array(e)).length,r=[];t<n;){var o=e[t++];if(0===o)break;if(0==(128&o))r.push(o);else if(192==(224&o)){var i=63&e[t++];r.push((31&o)<<6|i)}else if(224==(240&o)){i=63&e[t++];var a=63&e[t++];r.push((31&o)<<12|i<<6|a)}else if(240==(248&o)){65535<(o=(7&o)<<18|(i=63&e[t++])<<12|(a=63&e[t++])<<6|63&e[t++])&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o)}}return String.fromCharCode.apply(null,r)},e.TextEncoder=t,e.TextDecoder=n}("undefined"!=typeof window?window:i);var jn=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,c)}u((r=r.apply(e,t||[])).next())})},In=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},Pn="browser-tabs-lock-key";function Cn(e){return new Promise(function(t){return setTimeout(t,e)})}function Un(e){for(var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",r=0;r<e;r++){n+=t[Math.floor(Math.random()*t.length)]}return n}var Dn=function(){function e(){this.id=Date.now().toString()+Un(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),void 0===e.waiters&&(e.waiters=[])}return e.prototype.acquireLock=function(e,t){return void 0===t&&(t=5e3),jn(this,void 0,void 0,function(){var n,r,o,i,a,c;return In(this,function(u){switch(u.label){case 0:n=Date.now()+Un(4),r=Date.now()+t,o=Pn+"-"+e,i=window.localStorage,u.label=1;case 1:return Date.now()<r?null!==i.getItem(o)?[3,4]:(a=this.id+"-"+e+"-"+n,[4,Cn(Math.floor(25*Math.random()))]):[3,7];case 2:return u.sent(),i.setItem(o,JSON.stringify({id:this.id,iat:n,timeoutKey:a,timeAcquired:Date.now()})),[4,Cn(30)];case 3:return u.sent(),null!==(c=i.getItem(o))&&(c=JSON.parse(c)).id===this.id&&c.iat===n?[2,!0]:[3,6];case 4:return Fn(),[4,this.waitForSomethingToChange(r)];case 5:u.sent(),u.label=6;case 6:return n=Date.now()+Un(4),[3,1];case 7:return[2,!1]}})})},e.prototype.waitForSomethingToChange=function(t){return jn(this,void 0,void 0,function(){return In(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var r=!1,o=Date.now(),i=50,a=!1;function c(){if(a||(window.removeEventListener("storage",c),e.removeFromWaiting(c),clearTimeout(u),a=!0),!r){r=!0;var t=i-(Date.now()-o);t>0?setTimeout(n,t):n()}}window.addEventListener("storage",c),e.addToWaiting(c);var u=setTimeout(c,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 this.releaseLock__private__(e)},e.prototype.releaseLock__private__=function(t,n){void 0===n&&(n=null);var r=window.localStorage,o=Pn+"-"+t,i=r.getItem(o);null!==i&&((i=JSON.parse(i)).id!==this.id||null!==n&&i.iat!==n||(r.removeItem(o),e.notifyWaiters()))},e.waiters=void 0,e}();function Fn(){for(var e=Date.now()-1e4,t=window.localStorage,n=Object.keys(t),r=!1,o=0;o<n.length;o++){var i=n[o];if(i.includes(Pn)){var a=t.getItem(i);null!==a&&(a=JSON.parse(a)).timeAcquired<e&&(t.removeItem(i),r=!0)}}r&&Dn.notifyWaiters()}function Rn(e,t){return t=t||{},new Promise(function(n,r){var o=new XMLHttpRequest,i=[],a=[],c={},u=function(){return{ok:2==(o.status/100|0),statusText:o.statusText,status:o.status,url:o.responseURL,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(JSON.parse(o.responseText))},blob:function(){return Promise.resolve(new Blob([o.response]))},clone:u,headers:{keys:function(){return i},entries:function(){return a},get:function(e){return c[e.toLowerCase()]},has:function(e){return e.toLowerCase()in c}}}};for(var s in o.open(t.method||"get",e,!0),o.onload=function(){o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,n){i.push(t=t.toLowerCase()),a.push([t,n]),c[t]=c[t]?c[t]+","+n:n}),n(u())},o.onerror=r,o.withCredentials="include"==t.credentials,t.headers)o.setRequestHeader(s,t.headers[s]);o.send(t.body||null)})}var Ln,Mn={timeoutInSeconds:60},zn=function(e){return e.filter(function(t,n){return e.indexOf(t)===n})},Nn={error:"timeout",error_description:"Timeout"},Wn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(Boolean).join();return zn(n.replace(/\s/g,",").split(",")).join(" ").trim()},qn=function(){var e=window.open("","auth0:authorize:popup","left=100,top=100,width=400,height=600,resizable,scrollbars=yes,status=1");if(!e)throw new Error("Could not open popup");return e},Bn=function(e,n,r){return e.location.href=n,new Promise(function(n,o){var i=setTimeout(function(){o(t(t({},Nn),{popup:e}))},1e3*(r.timeoutInSeconds||60));window.addEventListener("message",function(t){if(t.data&&"authorization_response"===t.data.type){if(clearTimeout(i),e.close(),t.data.response.error)return o(t.data.response);n(t.data.response)}})})},Jn=function(){var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.",t="";return Array.from(Zn().getRandomValues(new Uint8Array(43))).forEach(function(n){return t+=e[n%e.length]}),t},Gn=function(e){return btoa(e)},Hn=function(e){return Object.keys(e).filter(function(t){return void 0!==e[t]}).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")},Yn=function(e){return r(void 0,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return t=$n().digest({name:"SHA-256"},(new TextEncoder).encode(e)),window.msCrypto?[2,new Promise(function(e,n){t.oncomplete=function(t){e(t.target.result)},t.onerror=function(e){n(e.error)},t.onabort=function(){n("The digest operation was aborted")}})]:[4,t];case 1:return[2,n.sent()]}})})},Vn=function(e){return function(e){return decodeURIComponent(atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""))}(e.replace(/_/g,"/").replace(/-/g,"+"))},Kn=function(e){var t=new Uint8Array(e);return function(e){var t={"+":"-","/":"_","=":""};return e.replace(/[\+\/=]/g,function(e){return t[e]})}(window.btoa(String.fromCharCode.apply(String,Array.from(t))))},Qn=function(e,t){return r(void 0,void 0,void 0,function(){var r,i,a,c,u,s,f;return o(this,function(o){switch(o.label){case 0:return[4,Rn(e,t)];case 1:return[4,(r=o.sent()).json()];case 2:if(i=o.sent(),a=i.error,c=i.error_description,u=n(i,["error","error_description"]),!r.ok)throw s=c||"HTTP error. Unable to fetch "+e,(f=new Error(s)).error=a||"request_error",f.error_description=s,f;return[2,u]}})})},Xn=function(e){return r(void 0,void 0,void 0,function(){var r=e.baseUrl,i=n(e,["baseUrl"]);return o(this,function(e){switch(e.label){case 0:return[4,Qn(r+"/oauth/token",{method:"POST",body:JSON.stringify(t({grant_type:"authorization_code",redirect_uri:window.location.origin},i)),headers:{"Content-type":"application/json"}})];case 1:return[2,e.sent()]}})})},Zn=function(){return window.crypto||window.msCrypto},$n=function(){var e=Zn();return e.subtle||e.webkitSubtle},er=function(){if(!Zn())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===$n())throw new Error("\n auth0-spa-js must run on a secure origin.\n See https://github.com/auth0/auth0-spa-js/blob/master/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin \n for more information.\n ")},tr=function(e){return e.audience+"::"+e.scope},nr=function(){function e(){this.cache={}}return e.prototype.save=function(e){var t=this,n=tr(e);this.cache[n]=e;var r,o,i,a=(r=e.expires_in,o=e.decodedToken.claims.exp,i=(new Date(1e3*o).getTime()-(new Date).getTime())/1e3,1e3*Math.min(r,i)*.8);setTimeout(function(){delete t.cache[n]},a)},e.prototype.get=function(e){return this.cache[tr(e)]},e}(),rr=a(function(e,t){var n=i&&i.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};function r(e,t){if(!t)return"";var n="; "+e;return!0===t?n:n+"="+t}function o(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 r("Expires",e.expires?e.expires.toUTCString():"")+r("Domain",e.domain)+r("Path",e.path)+r("Secure",e.secure)+r("SameSite",e.sameSite)}(n)}function a(e){for(var t={},n=e?e.split("; "):[],r=/(%[0-9A-Z]{2})+/g,o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");'"'===a.charAt(0)&&(a=a.slice(1,-1));try{t[i[0].replace(r,decodeURIComponent)]=a.replace(r,decodeURIComponent)}catch(e){}}return t}function c(){return a(document.cookie)}function u(e,t,r){document.cookie=o(e,t,n({path:"/"},r))}t.__esModule=!0,t.encode=o,t.parse=a,t.getAll=c,t.get=function(e){return c()[e]},t.set=u,t.remove=function(e,t){u(e,"",n({},t,{expires:-1}))}});(Ln=rr)&&Ln.__esModule&&Object.prototype.hasOwnProperty.call(Ln,"default")&&Ln.default;rr.encode,rr.parse;var or=rr.getAll,ir=rr.get,ar=rr.set,cr=rr.remove,ur=function(){return Object.keys(or()||{})},sr=function(e){var t=ir(e);if(void 0!==t)return JSON.parse(t)},fr=function(e,t,n){ar(e,JSON.stringify(t),{expires:n.daysUntilExpire})},lr=function(e){cr(e)},pr="a0.spajs.txs.",dr=function(e){return""+pr+e},hr=function(){function e(){var e=this;this.transactions={},ur().filter(function(e){return e.startsWith(pr)}).forEach(function(t){var n=t.replace(pr,"");e.transactions[n]=sr(t)})}return e.prototype.create=function(e,t){this.transactions[e]=t,fr(dr(e),t,{daysUntilExpire:1})},e.prototype.get=function(e){return this.transactions[e]},e.prototype.remove=function(e){delete this.transactions[e],lr(dr(e))},e}(),yr=function(e){return"number"==typeof e},vr=["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"],mr=function(e){if(!e.id_token)throw new Error("ID token is required but missing");var t=function(e){var t=e.split("."),n=t[0],r=t[1],o=t[2];if(3!==t.length||!n||!r||!o)throw new Error("ID token could not be decoded");var i=JSON.parse(Vn(r)),a={__raw:e},c={};return Object.keys(i).forEach(function(e){a[e]=i[e],vr.includes(e)||(c[e]=i[e])}),{encoded:{header:n,payload:r,signature:o},header:JSON.parse(Vn(n)),claims:a,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 "'+e.iss+'", found "'+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 "'+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 "'+e.aud+'" but was not one of "'+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 "'+e.aud+'", found "'+t.claims.azp+'"')}}else if(t.claims.aud!==e.aud)throw new Error('Audience (aud) claim mismatch in the ID token; expected "'+e.aud+'" but found "'+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 "'+e.nonce+'", found "'+t.claims.nonce+'"')}if(e.max_age&&!yr(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(!yr(t.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!yr(t.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");var n=e.leeway||60,r=new Date,o=new Date(0),i=new Date(0),a=new Date(0),c=new Date(0);if(c.setUTCSeconds((parseInt(t.claims.auth_time)+e.max_age)/1e3+n),o.setUTCSeconds(t.claims.exp+n),i.setUTCSeconds(t.claims.iat-n),a.setUTCSeconds(t.claims.nbf-n),r>o)throw new Error("Expiration Time (exp) claim error in the ID token; current time ("+r+") is after expiration time ("+o+")");if(r<i)throw new Error("Issued At (iat) claim error in the ID token; current time ("+r+") is before issued at time ("+i+")");if(yr(t.claims.nbf)&&r<a)throw new Error("Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Currrent time ("+r+") is before "+a);if(yr(t.claims.auth_time)&&r>c)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. Currrent time ("+r+") is after last auth at "+c);return t},wr=function(t){function n(e,r,o){var i=t.call(this,r)||this;return i.error=e,i.error_description=r,i.state=o,Object.setPrototypeOf(i,n.prototype),i}return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n}(Error),gr=new Dn,br=function(){function e(e){this.options=e,this.DEFAULT_SCOPE="openid profile email",this.cache=new nr,this.transactionManager=new hr,this.domainUrl="https://"+this.options.domain,this.tokenIssuer=this.options.issuer?"https://"+this.options.issuer+"/":this.domainUrl+"/"}return e.prototype._url=function(e){var t=encodeURIComponent(btoa(JSON.stringify({name:"auth0-spa-js",version:"1.6.0"})));return""+this.domainUrl+e+"&auth0Client="+t},e.prototype._getParams=function(e,r,o,i,a){var c=this.options,u=(c.domain,c.leeway,n(c,["domain","leeway"]));return t(t(t({},u),e),{scope:Wn(this.DEFAULT_SCOPE,this.options.scope,e.scope),response_type:"code",response_mode:"query",state:r,nonce:o,redirect_uri:a||this.options.redirect_uri,code_challenge:i,code_challenge_method:"S256"})},e.prototype._authorizeUrl=function(e){return this._url("/authorize?"+Hn(e))},e.prototype._verifyIdToken=function(e,t){return mr({iss:this.tokenIssuer,aud:this.options.client_id,id_token:e,nonce:t,leeway:this.options.leeway,max_age:this._parseNumber(this.options.max_age)})},e.prototype._parseNumber=function(e){return"string"!=typeof e?e:parseInt(e,10)||void 0},e.prototype.buildAuthorizeUrl=function(e){return void 0===e&&(e={}),r(this,void 0,void 0,function(){var t,r,i,a,c,u,s,f,l,p,d;return o(this,function(o){switch(o.label){case 0:return t=e.redirect_uri,r=e.appState,i=n(e,["redirect_uri","appState"]),a=Gn(Jn()),c=Jn(),u=Jn(),[4,Yn(u)];case 1:return s=o.sent(),f=Kn(s),l=e.fragment?"#"+e.fragment:"",p=this._getParams(i,a,c,f,t),d=this._authorizeUrl(p),this.transactionManager.create(a,{nonce:c,code_verifier:u,appState:r,scope:p.scope,audience:p.audience||"default"}),[2,d+l]}})})},e.prototype.loginWithPopup=function(e,i){return void 0===e&&(e={}),void 0===i&&(i=Mn),r(this,void 0,void 0,function(){var r,a,c,u,s,f,l,p,d,h,y,v,m;return o(this,function(o){switch(o.label){case 0:return[4,qn()];case 1:return r=o.sent(),a=n(e,[]),c=Gn(Jn()),u=Jn(),s=Jn(),[4,Yn(s)];case 2:return f=o.sent(),l=Kn(f),p=this._getParams(a,c,u,l,this.options.redirect_uri||window.location.origin),d=this._authorizeUrl(t(t({},p),{response_mode:"web_message"})),[4,Bn(r,d,i)];case 3:if(h=o.sent(),c!==h.state)throw new Error("Invalid state");return[4,Xn({baseUrl:this.domainUrl,audience:e.audience||this.options.audience,client_id:this.options.client_id,code_verifier:s,code:h.code})];case 4:return y=o.sent(),v=this._verifyIdToken(y.id_token,u),m=t(t({},y),{decodedToken:v,scope:p.scope,audience:p.audience||"default"}),this.cache.save(m),fr("auth0.is.authenticated",!0,{daysUntilExpire:1}),[2]}})})},e.prototype.getUser=function(e){return void 0===e&&(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}),r(this,void 0,void 0,function(){var t;return o(this,function(n){return e.scope=Wn(this.DEFAULT_SCOPE,e.scope),[2,(t=this.cache.get(e))&&t.decodedToken.user]})})},e.prototype.getIdTokenClaims=function(e){return void 0===e&&(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}),r(this,void 0,void 0,function(){var t;return o(this,function(n){return e.scope=Wn(this.DEFAULT_SCOPE,e.scope),[2,(t=this.cache.get(e))&&t.decodedToken.claims]})})},e.prototype.loginWithRedirect=function(e){return void 0===e&&(e={}),r(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return[4,this.buildAuthorizeUrl(e)];case 1:return t=n.sent(),window.location.assign(t),[2]}})})},e.prototype.handleRedirectCallback=function(e){return void 0===e&&(e=window.location.href),r(this,void 0,void 0,function(){var n,r,i,a,c,u,s,f,l,p;return o(this,function(o){switch(o.label){case 0:if(0===(n=e.split("?").slice(1)).length)throw new Error("There are no query params available for parsing.");if(r=function(e){e.indexOf("#")>-1&&(e=e.substr(0,e.indexOf("#")));var n=e.split("&"),r={};return n.forEach(function(e){var t=e.split("="),n=t[0],o=t[1];r[n]=decodeURIComponent(o)}),t(t({},r),{expires_in:parseInt(r.expires_in)})}(n.join("")),i=r.state,a=r.code,c=r.error,u=r.error_description,c)throw this.transactionManager.remove(i),new wr(c,u,i);if(!(s=this.transactionManager.get(i)))throw new Error("Invalid state");return this.transactionManager.remove(i),[4,Xn({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:s.code_verifier,code:a})];case 1:return f=o.sent(),l=this._verifyIdToken(f.id_token,s.nonce),p=t(t({},f),{decodedToken:l,audience:s.audience,scope:s.scope}),this.cache.save(p),fr("auth0.is.authenticated",!0,{daysUntilExpire:1}),[2,{appState:s.appState}]}})})},e.prototype.getTokenSilently=function(e){return void 0===e&&(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE,ignoreCache:!1}),r(this,void 0,void 0,function(){var n,r,i,a,c,u,s,f,l,p,d,h,y;return o(this,function(o){switch(o.label){case 0:e.scope=Wn(this.DEFAULT_SCOPE,e.scope),o.label=1;case 1:return o.trys.push([1,8,9,11]),[4,gr.acquireLock("auth0.lock.getTokenSilently",5e3)];case 2:return o.sent(),e.ignoreCache?[3,4]:(n=this.cache.get({scope:e.scope,audience:e.audience||"default"}))?[4,gr.releaseLock("auth0.lock.getTokenSilently")]:[3,4];case 3:return o.sent(),[2,n.access_token];case 4:return r=Gn(Jn()),i=Jn(),a=Jn(),[4,Yn(a)];case 5:return c=o.sent(),u=Kn(c),s={audience:e.audience,scope:e.scope},f=this._getParams(s,r,i,u,this.options.redirect_uri||window.location.origin),l=this._authorizeUrl(t(t({},f),{prompt:"none",response_mode:"web_message"})),[4,(v=l,m=this.domainUrl,new Promise(function(e,t){var n=window.document.createElement("iframe");n.setAttribute("width","0"),n.setAttribute("height","0"),n.style.display="none";var r=setTimeout(function(){t(Nn),window.document.body.removeChild(n)},6e4),o=function(i){i.origin==m&&i.data&&"authorization_response"===i.data.type&&(i.source.close(),i.data.response.error?t(i.data.response):e(i.data.response),clearTimeout(r),window.removeEventListener("message",o,!1),window.document.body.removeChild(n))};window.addEventListener("message",o,!1),window.document.body.appendChild(n),n.setAttribute("src",v)}))];case 6:if(p=o.sent(),r!==p.state)throw new Error("Invalid state");return[4,Xn({baseUrl:this.domainUrl,audience:e.audience||this.options.audience,client_id:this.options.client_id,code_verifier:a,code:p.code})];case 7:return d=o.sent(),h=this._verifyIdToken(d.id_token,i),y=t(t({},d),{decodedToken:h,scope:f.scope,audience:f.audience||"default"}),this.cache.save(y),fr("auth0.is.authenticated",!0,{daysUntilExpire:1}),[2,d.access_token];case 8:throw o.sent();case 9:return[4,gr.releaseLock("auth0.lock.getTokenSilently")];case 10:return o.sent(),[7];case 11:return[2]}var v,m})})},e.prototype.getTokenWithPopup=function(e,t){return void 0===e&&(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE}),void 0===t&&(t=Mn),r(this,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return e.scope=Wn(this.DEFAULT_SCOPE,this.options.scope,e.scope),[4,this.loginWithPopup(e,t)];case 1:return n.sent(),[2,this.cache.get({scope:e.scope,audience:e.audience||"default"}).access_token]}})})},e.prototype.isAuthenticated=function(){return r(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,this.getUser()];case 1:return[2,!!e.sent()]}})})},e.prototype.logout=function(e){void 0===e&&(e={}),null!==e.client_id?e.client_id=e.client_id||this.options.client_id:delete e.client_id,lr("auth0.is.authenticated");var t=e.federated,r=n(e,["federated"]),o=t?"&federated":"",i=this._url("/v2/logout?"+Hn(r));window.location.assign(""+i+o)},e}();return function(e){return r(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:if(er(),t=new br(e),!sr("auth0.is.authenticated"))return[2,t];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.getTokenSilently({audience:e.audience,scope:e.scope,ignoreCache:!0})];case 2:case 3:return n.sent(),[3,4];case 4:return[2,t]}})})}}); //# sourceMappingURL=auth0-spa-js.production.js.map