Socket
Socket
Sign inDemoInstall

@auth0/auth0-spa-js

Package Overview
Dependencies
20
Maintainers
37
Versions
89
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

6

CHANGELOG.md

@@ -0,3 +1,9 @@

## [v1.0.1](https://github.com/auth0/auth0-spa-js/tree/v1.0.1) (2019-06-24)
**Changed**
- Reduce transaction cookie size - https://github.com/auth0/auth0-spa-js/pull/32
## [v1.0.0](https://github.com/auth0/auth0-spa-js/tree/v1.0.0) (2019-06-19)
**Initial Release**

14

dist/auth0-spa-js.development.js

@@ -988,3 +988,3 @@ (function (global, factory) {

const COOKIE_KEY = 'Auth0.spa-js.transactions.';
const COOKIE_KEY = 'a0.spajs.txs.';
const getTransactionKey = (state) => `${COOKIE_KEY}${state}`;

@@ -1001,5 +1001,5 @@ class TransactionManager {

}
create(transaction) {
this.transactions[transaction.state] = transaction;
save(getTransactionKey(transaction.state), transaction, {
create(state, transaction) {
this.transactions[state] = transaction;
save(getTransactionKey(state), transaction, {
daysUntilExpire: 1

@@ -1110,3 +1110,3 @@ });

var version = '1.0.0';
var version = '1.0.1';

@@ -1252,7 +1252,5 @@ /**

const url = this._authorizeUrl(params);
this.transactionManager.create({
state: stateIn,
this.transactionManager.create(stateIn, {
nonce: nonceIn,
code_verifier,
code_challenge: code_challenge,
appState,

@@ -1259,0 +1257,0 @@ scope: params.scope,

@@ -1,2 +0,2 @@

function e(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&(r[o[n]]=e[o[n]])}return r}function t(e,t,r,o){return new(r||(r=Promise))(function(n,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?n(e.value):new r(function(t){t(e.value)}).then(a,s)}c((o=o.apply(e,t||[])).next())})}var r=Object.prototype.hasOwnProperty,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),n=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},o=0;o<e.length;++o)void 0!==e[o]&&(r[o]=e[o]);return r},i={arrayToObject:n,assign:function(e,t){return Object.keys(t).reduce(function(e,r){return e[r]=t[r],e},e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],o=0;o<t.length;++o)for(var n=t[o],i=n.obj[n.prop],a=Object.keys(i),s=0;s<a.length;++s){var c=a[s],d=i[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:i,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(Array.isArray(r)){for(var o=[],n=0;n<r.length;++n)void 0!==r[n]&&o.push(r[n]);t.obj[t.prop]=o}}}(t),e},decode:function(e,t,r){var o=e.replace(/\+/g," ");if("iso-8859-1"===r)return o.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(o)}catch(e){return o}},encode:function(e,t,r){if(0===e.length)return e;var n="string"==typeof e?e:String(e);if("iso-8859-1"===r)return escape(n).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var i="",a=0;a<n.length;++a){var s=n.charCodeAt(a);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?i+=n.charAt(a):s<128?i+=o[s]:s<2048?i+=o[192|s>>6]+o[128|63&s]:s<55296||s>=57344?i+=o[224|s>>12]+o[128|s>>6&63]+o[128|63&s]:(a+=1,s=65536+((1023&s)<<10|1023&n.charCodeAt(a)),i+=o[240|s>>18]+o[128|s>>12&63]+o[128|s>>6&63]+o[128|63&s])}return i},isBuffer:function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,o,i){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if("object"!=typeof t)return[t,o];(i&&(i.plainObjects||i.allowPrototypes)||!r.call(Object.prototype,o))&&(t[o]=!0)}return t}if("object"!=typeof t)return[t].concat(o);var a=t;return Array.isArray(t)&&!Array.isArray(o)&&(a=n(t,i)),Array.isArray(t)&&Array.isArray(o)?(o.forEach(function(o,n){r.call(t,n)?t[n]&&"object"==typeof t[n]?t[n]=e(t[n],o,i):t.push(o):t[n]=o}),t):Object.keys(o).reduce(function(t,n){var a=o[n];return r.call(t,n)?t[n]=e(t[n],a,i):t[n]=a,t},a)}},a=String.prototype.replace,s=/%20/g,c={default:"RFC3986",formatters:{RFC1738:function(e){return a.call(e,s,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"},d={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},l=Array.isArray,u=Array.prototype.push,p=function(e,t){u.apply(e,l(t)?t:[t])},h=Date.prototype.toISOString,f={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:i.encode,encodeValuesOnly:!1,indices:!1,serializeDate:function(e){return h.call(e)},skipNulls:!1,strictNullHandling:!1},y=function e(t,r,o,n,a,s,c,d,l,u,h,y,m){var g=t;if("function"==typeof c?g=c(r,g):g instanceof Date&&(g=u(g)),null===g){if(n)return s&&!y?s(r,f.encoder,m):r;g=""}if("string"==typeof g||"number"==typeof g||"boolean"==typeof g||i.isBuffer(g))return s?[h(y?r:s(r,f.encoder,m))+"="+h(s(g,f.encoder,m))]:[h(r)+"="+h(String(g))];var v,w=[];if(void 0===g)return w;if(Array.isArray(c))v=c;else{var b=Object.keys(g);v=d?b.sort(d):b}for(var _=0;_<v.length;++_){var O=v[_];a&&null===g[O]||(Array.isArray(g)?p(w,e(g[O],o(r,O),o,n,a,s,c,d,l,u,h,y,m)):p(w,e(g[O],r+(l?"."+O:"["+O+"]"),o,n,a,s,c,d,l,u,h,y,m)))}return w},m=Object.prototype.hasOwnProperty,g={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,decoder:i.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},v=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},w=function(e,t,r){if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,n=/(\[[^[\]]*])/g,i=/(\[[^[\]]*])/.exec(o),a=i?o.slice(0,i.index):o,s=[];if(a){if(!r.plainObjects&&m.call(Object.prototype,a)&&!r.allowPrototypes)return;s.push(a)}for(var c=0;null!==(i=n.exec(o))&&c<r.depth;){if(c+=1,!r.plainObjects&&m.call(Object.prototype,i[1].slice(1,-1))&&!r.allowPrototypes)return;s.push(i[1])}return i&&s.push("["+o.slice(i.index)+"]"),function(e,t,r){for(var o=t,n=e.length-1;n>=0;--n){var i,a=e[n];if("[]"===a&&r.parseArrays)i=[].concat(o);else{i=r.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(s,10);r.parseArrays||""!==s?!isNaN(c)&&a!==s&&String(c)===s&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(i=[])[c]=o:i[s]=o:i={0:o}}o=i}return o}(s,t,r)}},b=function(e,t){var r=t?i.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||i.isRegExp(r.delimiter)?r.delimiter:g.delimiter,r.depth="number"==typeof r.depth?r.depth:g.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:g.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:g.decoder,r.allowDots=void 0===r.allowDots?g.allowDots:!!r.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:g.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:g.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:g.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:g.strictNullHandling,void 0!==r.charset&&"utf-8"!==r.charset&&"iso-8859-1"!==r.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===r.charset&&(r.charset=g.charset),""===e||null==e)return r.plainObjects?Object.create(null):{};for(var o="string"==typeof e?function(e,t){var r,o={},n=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,s=n.split(t.delimiter,a),c=-1,d=t.charset;if(t.charsetSentinel)for(r=0;r<s.length;++r)0===s[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===s[r]?d="utf-8":"utf8=%26%2310003%3B"===s[r]&&(d="iso-8859-1"),c=r,r=s.length);for(r=0;r<s.length;++r)if(r!==c){var l,u,p=s[r],h=p.indexOf("]="),f=-1===h?p.indexOf("="):h+1;-1===f?(l=t.decoder(p,g.decoder,d),u=t.strictNullHandling?null:""):(l=t.decoder(p.slice(0,f),g.decoder,d),u=t.decoder(p.slice(f+1),g.decoder,d)),u&&t.interpretNumericEntities&&"iso-8859-1"===d&&(u=v(u)),m.call(o,l)?o[l]=i.combine(o[l],u):o[l]=u}return o}(e,r):e,n=r.plainObjects?Object.create(null):{},a=Object.keys(o),s=0;s<a.length;++s){var c=a[s],d=w(c,o[c],r);n=i.merge(n,d,r)}return i.compact(n)},_=function(e,t){var r=e,o=t?i.assign({},t):{};if(null!==o.encoder&&void 0!==o.encoder&&"function"!=typeof o.encoder)throw new TypeError("Encoder has to be a function.");var n=void 0===o.delimiter?f.delimiter:o.delimiter,a="boolean"==typeof o.strictNullHandling?o.strictNullHandling:f.strictNullHandling,s="boolean"==typeof o.skipNulls?o.skipNulls:f.skipNulls,l="boolean"==typeof o.encode?o.encode:f.encode,u="function"==typeof o.encoder?o.encoder:f.encoder,h="function"==typeof o.sort?o.sort:null,m=void 0===o.allowDots?f.allowDots:!!o.allowDots,g="function"==typeof o.serializeDate?o.serializeDate:f.serializeDate,v="boolean"==typeof o.encodeValuesOnly?o.encodeValuesOnly:f.encodeValuesOnly,w=o.charset||f.charset;if(void 0!==o.charset&&"utf-8"!==o.charset&&"iso-8859-1"!==o.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===o.format)o.format=c.default;else if(!Object.prototype.hasOwnProperty.call(c.formatters,o.format))throw new TypeError("Unknown format option provided.");var b,_,O=c.formatters[o.format];"function"==typeof o.filter?r=(_=o.filter)("",r):Array.isArray(o.filter)&&(b=_=o.filter);var j,E=[];if("object"!=typeof r||null===r)return"";j=o.arrayFormat in d?o.arrayFormat:"indices"in o?o.indices?"indices":"repeat":"indices";var A=d[j];b||(b=Object.keys(r)),h&&b.sort(h);for(var C=0;C<b.length;++C){var S=b[C];s&&null===r[S]||p(E,y(r[S],S,A,a,s,l?u:null,_,h,m,g,O,v,w))}var U=E.join(n),x=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&(x+="iso-8859-1"===w?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),U.length>0?x+U:""};const O={error:"timeout",error_description:"Timeout"},j=(...e)=>{const t=e.filter(Boolean).join();return Array.from(new Set(t.replace(/\s/g,",").split(","))).join(" ").trim()},E=e=>{var t=b(e);return Object.assign({},t,{expires_in:parseInt(t.expires_in)})},A=(e,t)=>new Promise((r,o)=>{var n=window.document.createElement("iframe");n.setAttribute("width","0"),n.setAttribute("height","0"),n.style.display="none";const i=setTimeout(()=>{o(O),window.document.body.removeChild(n)},6e4),a=function(e){e.origin==t&&e.data&&"authorization_response"===e.data.type&&(e.source.close(),e.data.response.error?o(e.data.response):r(e.data.response),clearTimeout(i),window.removeEventListener("message",a,!1),window.document.body.removeChild(n))};window.addEventListener("message",a,!1),window.document.body.appendChild(n),n.setAttribute("src",e)}),C=()=>{const 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},S=(e,t)=>(e.location.href=t,new Promise((t,r)=>{const o=setTimeout(()=>{r(O)},6e4);window.addEventListener("message",n=>{if(n.data&&"authorization_response"===n.data.type){if(clearTimeout(o),e.close(),n.data.response.error)return r(n.data.response);t(n.data.response)}})})),U=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";return crypto.getRandomValues(new Uint8Array(43)).forEach(r=>t+=e[r%e.length]),t},x=e=>btoa(e),k=e=>_(e),T=e=>window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e)),P=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),D=e=>(e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[\+\/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(new Uint8Array(e))))),I=r=>t(void 0,void 0,void 0,function*(){var{baseUrl:t}=r,o=e(r,["baseUrl"]);return yield fetch(`${t}/oauth/token`,{method:"POST",body:JSON.stringify(Object.assign({grant_type:"authorization_code",redirect_uri:window.location.origin},o)),headers:{"Content-type":"application/json"}}).then(e=>e.json())}),L=e=>`${e.audience}::${e.scope}`,N=(e,t)=>{const r=(new Date(1e3*t).getTime()-(new Date).getTime())/1e3;return 1e3*Math.min(e,r)};class R{constructor(){this.cache={}}save(e){const t=L(e);this.cache[t]=e;const r=N(e.expires_in,e.decodedToken.claims.exp);setTimeout(()=>{delete this.cache[t]},r)}get(e){return this.cache[L(e)]}}var F="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var z,B,$=(function(e,t){var r=F&&F.__assign||Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e};function o(e,t){if(!t)return"";var r="; "+e;return!0===t?r:r+"="+t}function n(e,t,r){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 o("Expires",e.expires?e.expires.toUTCString():"")+o("Domain",e.domain)+o("Path",e.path)+o("Secure",e.secure)+o("SameSite",e.sameSite)}(r)}function i(e){for(var t={},r=e?e.split("; "):[],o=/(%[0-9A-Z]{2})+/g,n=0;n<r.length;n++){var i=r[n].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}function a(){return i(document.cookie)}function s(e,t,o){document.cookie=n(e,t,r({path:"/"},o))}t.__esModule=!0,t.encode=n,t.parse=i,t.getAll=a,t.get=function(e){return a()[e]},t.set=s,t.remove=function(e,t){s(e,"",r({},t,{expires:-1}))}}(z={exports:{}},z.exports),z.exports);(B=$)&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")&&B.default;$.encode,$.parse;var H=$.getAll,M=$.get,J=$.set,Q=$.remove;const V=()=>Object.keys(H()||{}),W=e=>{const t=M(e);if(void 0!==t)return JSON.parse(t)},q=(e,t,r)=>{J(e,JSON.stringify(t),{expires:r.daysUntilExpire})},Z=e=>{Q(e)},G="Auth0.spa-js.transactions.",K=e=>`${G}${e}`;class X{constructor(){this.transactions={},V().filter(e=>e.startsWith(G)).forEach(e=>{const t=e.replace(G,"");this.transactions[t]=W(e)})}create(e){this.transactions[e.state]=e,q(K(e.state),e,{daysUntilExpire:1})}get(e){return this.transactions[e]}remove(e){delete this.transactions[e],Z(K(e))}}const Y=["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"],ee=e=>{const t=(e=>{const[t,r,o]=e.split("."),n=JSON.parse(P(r)),i={},a={};return Object.keys(n).forEach(e=>{i[e]=n[e],Y.includes(e)||(a[e]=n[e])}),{encoded:{header:t,payload:r,signature:o},header:JSON.parse(P(t)),claims:i,user:a}})(e.id_token);if(t.claims.iss!==e.iss)throw new Error("Invalid issuer");if(t.claims.aud!==e.aud)throw new Error("Invalid audience");if("RS256"!==t.header.alg)throw new Error("Invalid algorithm");if(t.claims.nonce!==e.nonce)throw new Error("Invalid nonce");const r=new Date,o=new Date(0),n=new Date(0),i=new Date(0),a=e.leeway||60;if(o.setUTCSeconds(t.claims.exp+a),n.setUTCSeconds(t.claims.iat-a),i.setUTCSeconds(t.claims.nbf-a),r>o)throw new Error("id_token expired");if(r<n)throw new Error("id_token was issued in the future (invalid iat)");if(void 0!==t.claims.nbf&&r<i)throw new Error("token is not yet valid (invalid notBefore)");return t};class te extends Error{constructor(e,t,r){super(t),this.error=e,this.error_description=t,this.state=r}}var re="1.0.0";class oe{constructor(e){this.options=e,this.DEFAULT_SCOPE="openid profile email",this.cache=new R,this.transactionManager=new X,this.domainUrl=`https://${this.options.domain}`}_url(e){const t=encodeURIComponent(btoa(JSON.stringify({name:"auth0-spa-js",version:re})));return`${this.domainUrl}${e}&auth0Client=${t}`}_getParams(t,r,o,n,i){const a=e(this.options,["domain"]);return Object.assign({},a,t,{scope:j(this.DEFAULT_SCOPE,this.options.scope,t.scope),response_type:"code",response_mode:"query",state:r,nonce:o,redirect_uri:this.options.redirect_uri||i,code_challenge:n,code_challenge_method:"S256"})}_authorizeUrl(e){return this._url(`/authorize?${k(e)}`)}_verifyIdToken(e,t){return ee({iss:`${this.domainUrl}/`,aud:this.options.client_id,id_token:e,nonce:t,leeway:this.options.leeway})}loginWithPopup(r){return t(this,void 0,void 0,function*(){const t=yield C(),o=e(r,[]),n=x(U()),i=U(),a=U(),s=yield T(a),c=D(s),d=this._getParams(o,n,i,c,window.location.origin),l=this._authorizeUrl(Object.assign({},d,{response_mode:"web_message"})),u=yield S(t,l);if(n!==u.state)throw new Error("Invalid state");const p=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:a,code:u.code}),h=this._verifyIdToken(p.id_token,i),f=Object.assign({},p,{decodedToken:h,scope:d.scope,audience:d.audience||"default"});this.cache.save(f),q("auth0.is.authenticated",!0,{daysUntilExpire:1})})}getUser(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.user})}getIdTokenClaims(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.claims})}loginWithRedirect(r){return t(this,void 0,void 0,function*(){const{redirect_uri:t,appState:o}=r,n=e(r,["redirect_uri","appState"]),i=x(U()),a=U(),s=U(),c=yield T(s),d=D(c),l=this._getParams(n,i,a,d,t),u=this._authorizeUrl(l);this.transactionManager.create({state:i,nonce:a,code_verifier:s,code_challenge:d,appState:o,scope:l.scope,audience:l.audience||"default"}),window.location.assign(u)})}handleRedirectCallback(){return t(this,void 0,void 0,function*(){if(!window.location.search)throw new Error("There are no query params available at `window.location.search`.");const{state:e,code:t,error:r,error_description:o}=E(window.location.search.substr(1));if(r)throw new te(r,o,e);const n=this.transactionManager.get(e);if(!n)throw new Error("Invalid state");this.transactionManager.remove(e);const i=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:n.code_verifier,code:t}),a=this._verifyIdToken(i.id_token,n.nonce),s=Object.assign({},i,{decodedToken:a,audience:n.audience,scope:n.scope});return this.cache.save(s),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),{appState:n.appState}})}getTokenSilently(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE,ignoreCache:!1}){return t(this,void 0,void 0,function*(){if(e.scope=j(this.DEFAULT_SCOPE,e.scope),!e.ignoreCache){const t=this.cache.get({scope:e.scope,audience:e.audience||"default"});if(t)return t.access_token}const t=x(U()),r=U(),o=U(),n=yield T(o),i=D(n),a={audience:e.audience,scope:e.scope},s=this._getParams(a,t,r,i,window.location.origin),c=this._authorizeUrl(Object.assign({},s,{prompt:"none",response_mode:"web_message"})),d=yield A(c,this.domainUrl);if(t!==d.state)throw new Error("Invalid state");const l=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:o,code:d.code}),u=this._verifyIdToken(l.id_token,r),p=Object.assign({},l,{decodedToken:u,scope:s.scope,audience:s.audience||"default"});return this.cache.save(p),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),l.access_token})}getTokenWithPopup(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){return e.scope=j(this.DEFAULT_SCOPE,this.options.scope,e.scope),yield this.loginWithPopup(e),this.cache.get({scope:e.scope,audience:e.audience||"default"}).access_token})}isAuthenticated(){return t(this,void 0,void 0,function*(){return!!(yield this.getUser())})}logout(e={}){null!==e.client_id?e.client_id=e.client_id||this.options.client_id:delete e.client_id,Z("auth0.is.authenticated");const t=this._url(`/v2/logout?${k(e)}`);window.location.assign(t)}}export default function(e){return t(this,void 0,void 0,function*(){const t=new oe(e);if(!W("auth0.is.authenticated"))return t;try{yield t.getTokenSilently({audience:e.audience,scope:e.scope,ignoreCache:!0})}catch(e){}return t})}
function e(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&(r[o[n]]=e[o[n]])}return r}function t(e,t,r,o){return new(r||(r=Promise))(function(n,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?n(e.value):new r(function(t){t(e.value)}).then(a,s)}c((o=o.apply(e,t||[])).next())})}var r=Object.prototype.hasOwnProperty,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),n=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},o=0;o<e.length;++o)void 0!==e[o]&&(r[o]=e[o]);return r},i={arrayToObject:n,assign:function(e,t){return Object.keys(t).reduce(function(e,r){return e[r]=t[r],e},e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],o=0;o<t.length;++o)for(var n=t[o],i=n.obj[n.prop],a=Object.keys(i),s=0;s<a.length;++s){var c=a[s],d=i[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:i,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(Array.isArray(r)){for(var o=[],n=0;n<r.length;++n)void 0!==r[n]&&o.push(r[n]);t.obj[t.prop]=o}}}(t),e},decode:function(e,t,r){var o=e.replace(/\+/g," ");if("iso-8859-1"===r)return o.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(o)}catch(e){return o}},encode:function(e,t,r){if(0===e.length)return e;var n="string"==typeof e?e:String(e);if("iso-8859-1"===r)return escape(n).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var i="",a=0;a<n.length;++a){var s=n.charCodeAt(a);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?i+=n.charAt(a):s<128?i+=o[s]:s<2048?i+=o[192|s>>6]+o[128|63&s]:s<55296||s>=57344?i+=o[224|s>>12]+o[128|s>>6&63]+o[128|63&s]:(a+=1,s=65536+((1023&s)<<10|1023&n.charCodeAt(a)),i+=o[240|s>>18]+o[128|s>>12&63]+o[128|s>>6&63]+o[128|63&s])}return i},isBuffer:function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,o,i){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if("object"!=typeof t)return[t,o];(i&&(i.plainObjects||i.allowPrototypes)||!r.call(Object.prototype,o))&&(t[o]=!0)}return t}if("object"!=typeof t)return[t].concat(o);var a=t;return Array.isArray(t)&&!Array.isArray(o)&&(a=n(t,i)),Array.isArray(t)&&Array.isArray(o)?(o.forEach(function(o,n){r.call(t,n)?t[n]&&"object"==typeof t[n]?t[n]=e(t[n],o,i):t.push(o):t[n]=o}),t):Object.keys(o).reduce(function(t,n){var a=o[n];return r.call(t,n)?t[n]=e(t[n],a,i):t[n]=a,t},a)}},a=String.prototype.replace,s=/%20/g,c={default:"RFC3986",formatters:{RFC1738:function(e){return a.call(e,s,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"},d={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},l=Array.isArray,u=Array.prototype.push,p=function(e,t){u.apply(e,l(t)?t:[t])},f=Date.prototype.toISOString,h={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:i.encode,encodeValuesOnly:!1,indices:!1,serializeDate:function(e){return f.call(e)},skipNulls:!1,strictNullHandling:!1},y=function e(t,r,o,n,a,s,c,d,l,u,f,y,m){var g=t;if("function"==typeof c?g=c(r,g):g instanceof Date&&(g=u(g)),null===g){if(n)return s&&!y?s(r,h.encoder,m):r;g=""}if("string"==typeof g||"number"==typeof g||"boolean"==typeof g||i.isBuffer(g))return s?[f(y?r:s(r,h.encoder,m))+"="+f(s(g,h.encoder,m))]:[f(r)+"="+f(String(g))];var v,w=[];if(void 0===g)return w;if(Array.isArray(c))v=c;else{var b=Object.keys(g);v=d?b.sort(d):b}for(var _=0;_<v.length;++_){var O=v[_];a&&null===g[O]||(Array.isArray(g)?p(w,e(g[O],o(r,O),o,n,a,s,c,d,l,u,f,y,m)):p(w,e(g[O],r+(l?"."+O:"["+O+"]"),o,n,a,s,c,d,l,u,f,y,m)))}return w},m=Object.prototype.hasOwnProperty,g={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,decoder:i.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},v=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},w=function(e,t,r){if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,n=/(\[[^[\]]*])/g,i=/(\[[^[\]]*])/.exec(o),a=i?o.slice(0,i.index):o,s=[];if(a){if(!r.plainObjects&&m.call(Object.prototype,a)&&!r.allowPrototypes)return;s.push(a)}for(var c=0;null!==(i=n.exec(o))&&c<r.depth;){if(c+=1,!r.plainObjects&&m.call(Object.prototype,i[1].slice(1,-1))&&!r.allowPrototypes)return;s.push(i[1])}return i&&s.push("["+o.slice(i.index)+"]"),function(e,t,r){for(var o=t,n=e.length-1;n>=0;--n){var i,a=e[n];if("[]"===a&&r.parseArrays)i=[].concat(o);else{i=r.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(s,10);r.parseArrays||""!==s?!isNaN(c)&&a!==s&&String(c)===s&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(i=[])[c]=o:i[s]=o:i={0:o}}o=i}return o}(s,t,r)}},b=function(e,t){var r=t?i.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||i.isRegExp(r.delimiter)?r.delimiter:g.delimiter,r.depth="number"==typeof r.depth?r.depth:g.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:g.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:g.decoder,r.allowDots=void 0===r.allowDots?g.allowDots:!!r.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:g.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:g.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:g.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:g.strictNullHandling,void 0!==r.charset&&"utf-8"!==r.charset&&"iso-8859-1"!==r.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===r.charset&&(r.charset=g.charset),""===e||null==e)return r.plainObjects?Object.create(null):{};for(var o="string"==typeof e?function(e,t){var r,o={},n=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,s=n.split(t.delimiter,a),c=-1,d=t.charset;if(t.charsetSentinel)for(r=0;r<s.length;++r)0===s[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===s[r]?d="utf-8":"utf8=%26%2310003%3B"===s[r]&&(d="iso-8859-1"),c=r,r=s.length);for(r=0;r<s.length;++r)if(r!==c){var l,u,p=s[r],f=p.indexOf("]="),h=-1===f?p.indexOf("="):f+1;-1===h?(l=t.decoder(p,g.decoder,d),u=t.strictNullHandling?null:""):(l=t.decoder(p.slice(0,h),g.decoder,d),u=t.decoder(p.slice(h+1),g.decoder,d)),u&&t.interpretNumericEntities&&"iso-8859-1"===d&&(u=v(u)),m.call(o,l)?o[l]=i.combine(o[l],u):o[l]=u}return o}(e,r):e,n=r.plainObjects?Object.create(null):{},a=Object.keys(o),s=0;s<a.length;++s){var c=a[s],d=w(c,o[c],r);n=i.merge(n,d,r)}return i.compact(n)},_=function(e,t){var r=e,o=t?i.assign({},t):{};if(null!==o.encoder&&void 0!==o.encoder&&"function"!=typeof o.encoder)throw new TypeError("Encoder has to be a function.");var n=void 0===o.delimiter?h.delimiter:o.delimiter,a="boolean"==typeof o.strictNullHandling?o.strictNullHandling:h.strictNullHandling,s="boolean"==typeof o.skipNulls?o.skipNulls:h.skipNulls,l="boolean"==typeof o.encode?o.encode:h.encode,u="function"==typeof o.encoder?o.encoder:h.encoder,f="function"==typeof o.sort?o.sort:null,m=void 0===o.allowDots?h.allowDots:!!o.allowDots,g="function"==typeof o.serializeDate?o.serializeDate:h.serializeDate,v="boolean"==typeof o.encodeValuesOnly?o.encodeValuesOnly:h.encodeValuesOnly,w=o.charset||h.charset;if(void 0!==o.charset&&"utf-8"!==o.charset&&"iso-8859-1"!==o.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===o.format)o.format=c.default;else if(!Object.prototype.hasOwnProperty.call(c.formatters,o.format))throw new TypeError("Unknown format option provided.");var b,_,O=c.formatters[o.format];"function"==typeof o.filter?r=(_=o.filter)("",r):Array.isArray(o.filter)&&(b=_=o.filter);var j,E=[];if("object"!=typeof r||null===r)return"";j=o.arrayFormat in d?o.arrayFormat:"indices"in o?o.indices?"indices":"repeat":"indices";var A=d[j];b||(b=Object.keys(r)),f&&b.sort(f);for(var C=0;C<b.length;++C){var S=b[C];s&&null===r[S]||p(E,y(r[S],S,A,a,s,l?u:null,_,f,m,g,O,v,w))}var U=E.join(n),x=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&(x+="iso-8859-1"===w?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),U.length>0?x+U:""};const O={error:"timeout",error_description:"Timeout"},j=(...e)=>{const t=e.filter(Boolean).join();return Array.from(new Set(t.replace(/\s/g,",").split(","))).join(" ").trim()},E=e=>{var t=b(e);return Object.assign({},t,{expires_in:parseInt(t.expires_in)})},A=(e,t)=>new Promise((r,o)=>{var n=window.document.createElement("iframe");n.setAttribute("width","0"),n.setAttribute("height","0"),n.style.display="none";const i=setTimeout(()=>{o(O),window.document.body.removeChild(n)},6e4),a=function(e){e.origin==t&&e.data&&"authorization_response"===e.data.type&&(e.source.close(),e.data.response.error?o(e.data.response):r(e.data.response),clearTimeout(i),window.removeEventListener("message",a,!1),window.document.body.removeChild(n))};window.addEventListener("message",a,!1),window.document.body.appendChild(n),n.setAttribute("src",e)}),C=()=>{const 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},S=(e,t)=>(e.location.href=t,new Promise((t,r)=>{const o=setTimeout(()=>{r(O)},6e4);window.addEventListener("message",n=>{if(n.data&&"authorization_response"===n.data.type){if(clearTimeout(o),e.close(),n.data.response.error)return r(n.data.response);t(n.data.response)}})})),U=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";return crypto.getRandomValues(new Uint8Array(43)).forEach(r=>t+=e[r%e.length]),t},x=e=>btoa(e),k=e=>_(e),T=e=>window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e)),P=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),D=e=>(e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[\+\/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(new Uint8Array(e))))),I=r=>t(void 0,void 0,void 0,function*(){var{baseUrl:t}=r,o=e(r,["baseUrl"]);return yield fetch(`${t}/oauth/token`,{method:"POST",body:JSON.stringify(Object.assign({grant_type:"authorization_code",redirect_uri:window.location.origin},o)),headers:{"Content-type":"application/json"}}).then(e=>e.json())}),L=e=>`${e.audience}::${e.scope}`,N=(e,t)=>{const r=(new Date(1e3*t).getTime()-(new Date).getTime())/1e3;return 1e3*Math.min(e,r)};class R{constructor(){this.cache={}}save(e){const t=L(e);this.cache[t]=e;const r=N(e.expires_in,e.decodedToken.claims.exp);setTimeout(()=>{delete this.cache[t]},r)}get(e){return this.cache[L(e)]}}var F="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var z,B,$=(function(e,t){var r=F&&F.__assign||Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e};function o(e,t){if(!t)return"";var r="; "+e;return!0===t?r:r+"="+t}function n(e,t,r){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 o("Expires",e.expires?e.expires.toUTCString():"")+o("Domain",e.domain)+o("Path",e.path)+o("Secure",e.secure)+o("SameSite",e.sameSite)}(r)}function i(e){for(var t={},r=e?e.split("; "):[],o=/(%[0-9A-Z]{2})+/g,n=0;n<r.length;n++){var i=r[n].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}function a(){return i(document.cookie)}function s(e,t,o){document.cookie=n(e,t,r({path:"/"},o))}t.__esModule=!0,t.encode=n,t.parse=i,t.getAll=a,t.get=function(e){return a()[e]},t.set=s,t.remove=function(e,t){s(e,"",r({},t,{expires:-1}))}}(z={exports:{}},z.exports),z.exports);(B=$)&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")&&B.default;$.encode,$.parse;var H=$.getAll,M=$.get,J=$.set,Q=$.remove;const V=()=>Object.keys(H()||{}),W=e=>{const t=M(e);if(void 0!==t)return JSON.parse(t)},q=(e,t,r)=>{J(e,JSON.stringify(t),{expires:r.daysUntilExpire})},Z=e=>{Q(e)},G="a0.spajs.txs.",K=e=>`${G}${e}`;class X{constructor(){this.transactions={},V().filter(e=>e.startsWith(G)).forEach(e=>{const t=e.replace(G,"");this.transactions[t]=W(e)})}create(e,t){this.transactions[e]=t,q(K(e),t,{daysUntilExpire:1})}get(e){return this.transactions[e]}remove(e){delete this.transactions[e],Z(K(e))}}const Y=["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"],ee=e=>{const t=(e=>{const[t,r,o]=e.split("."),n=JSON.parse(P(r)),i={},a={};return Object.keys(n).forEach(e=>{i[e]=n[e],Y.includes(e)||(a[e]=n[e])}),{encoded:{header:t,payload:r,signature:o},header:JSON.parse(P(t)),claims:i,user:a}})(e.id_token);if(t.claims.iss!==e.iss)throw new Error("Invalid issuer");if(t.claims.aud!==e.aud)throw new Error("Invalid audience");if("RS256"!==t.header.alg)throw new Error("Invalid algorithm");if(t.claims.nonce!==e.nonce)throw new Error("Invalid nonce");const r=new Date,o=new Date(0),n=new Date(0),i=new Date(0),a=e.leeway||60;if(o.setUTCSeconds(t.claims.exp+a),n.setUTCSeconds(t.claims.iat-a),i.setUTCSeconds(t.claims.nbf-a),r>o)throw new Error("id_token expired");if(r<n)throw new Error("id_token was issued in the future (invalid iat)");if(void 0!==t.claims.nbf&&r<i)throw new Error("token is not yet valid (invalid notBefore)");return t};class te extends Error{constructor(e,t,r){super(t),this.error=e,this.error_description=t,this.state=r}}var re="1.0.1";class oe{constructor(e){this.options=e,this.DEFAULT_SCOPE="openid profile email",this.cache=new R,this.transactionManager=new X,this.domainUrl=`https://${this.options.domain}`}_url(e){const t=encodeURIComponent(btoa(JSON.stringify({name:"auth0-spa-js",version:re})));return`${this.domainUrl}${e}&auth0Client=${t}`}_getParams(t,r,o,n,i){const a=e(this.options,["domain"]);return Object.assign({},a,t,{scope:j(this.DEFAULT_SCOPE,this.options.scope,t.scope),response_type:"code",response_mode:"query",state:r,nonce:o,redirect_uri:this.options.redirect_uri||i,code_challenge:n,code_challenge_method:"S256"})}_authorizeUrl(e){return this._url(`/authorize?${k(e)}`)}_verifyIdToken(e,t){return ee({iss:`${this.domainUrl}/`,aud:this.options.client_id,id_token:e,nonce:t,leeway:this.options.leeway})}loginWithPopup(r){return t(this,void 0,void 0,function*(){const t=yield C(),o=e(r,[]),n=x(U()),i=U(),a=U(),s=yield T(a),c=D(s),d=this._getParams(o,n,i,c,window.location.origin),l=this._authorizeUrl(Object.assign({},d,{response_mode:"web_message"})),u=yield S(t,l);if(n!==u.state)throw new Error("Invalid state");const p=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:a,code:u.code}),f=this._verifyIdToken(p.id_token,i),h=Object.assign({},p,{decodedToken:f,scope:d.scope,audience:d.audience||"default"});this.cache.save(h),q("auth0.is.authenticated",!0,{daysUntilExpire:1})})}getUser(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.user})}getIdTokenClaims(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.claims})}loginWithRedirect(r){return t(this,void 0,void 0,function*(){const{redirect_uri:t,appState:o}=r,n=e(r,["redirect_uri","appState"]),i=x(U()),a=U(),s=U(),c=yield T(s),d=D(c),l=this._getParams(n,i,a,d,t),u=this._authorizeUrl(l);this.transactionManager.create(i,{nonce:a,code_verifier:s,appState:o,scope:l.scope,audience:l.audience||"default"}),window.location.assign(u)})}handleRedirectCallback(){return t(this,void 0,void 0,function*(){if(!window.location.search)throw new Error("There are no query params available at `window.location.search`.");const{state:e,code:t,error:r,error_description:o}=E(window.location.search.substr(1));if(r)throw new te(r,o,e);const n=this.transactionManager.get(e);if(!n)throw new Error("Invalid state");this.transactionManager.remove(e);const i=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:n.code_verifier,code:t}),a=this._verifyIdToken(i.id_token,n.nonce),s=Object.assign({},i,{decodedToken:a,audience:n.audience,scope:n.scope});return this.cache.save(s),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),{appState:n.appState}})}getTokenSilently(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE,ignoreCache:!1}){return t(this,void 0,void 0,function*(){if(e.scope=j(this.DEFAULT_SCOPE,e.scope),!e.ignoreCache){const t=this.cache.get({scope:e.scope,audience:e.audience||"default"});if(t)return t.access_token}const t=x(U()),r=U(),o=U(),n=yield T(o),i=D(n),a={audience:e.audience,scope:e.scope},s=this._getParams(a,t,r,i,window.location.origin),c=this._authorizeUrl(Object.assign({},s,{prompt:"none",response_mode:"web_message"})),d=yield A(c,this.domainUrl);if(t!==d.state)throw new Error("Invalid state");const l=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:o,code:d.code}),u=this._verifyIdToken(l.id_token,r),p=Object.assign({},l,{decodedToken:u,scope:s.scope,audience:s.audience||"default"});return this.cache.save(p),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),l.access_token})}getTokenWithPopup(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){return e.scope=j(this.DEFAULT_SCOPE,this.options.scope,e.scope),yield this.loginWithPopup(e),this.cache.get({scope:e.scope,audience:e.audience||"default"}).access_token})}isAuthenticated(){return t(this,void 0,void 0,function*(){return!!(yield this.getUser())})}logout(e={}){null!==e.client_id?e.client_id=e.client_id||this.options.client_id:delete e.client_id,Z("auth0.is.authenticated");const t=this._url(`/v2/logout?${k(e)}`);window.location.assign(t)}}export default function(e){return t(this,void 0,void 0,function*(){const t=new oe(e);if(!W("auth0.is.authenticated"))return t;try{yield t.getTokenSilently({audience:e.audience,scope:e.scope,ignoreCache:!0})}catch(e){}return t})}
//# sourceMappingURL=auth0-spa-js.production.esm.js.map

@@ -1,2 +0,2 @@

!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";function e(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&(r[o[n]]=e[o[n]])}return r}function t(e,t,r,o){return new(r||(r=Promise))(function(n,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?n(e.value):new r(function(t){t(e.value)}).then(a,s)}c((o=o.apply(e,t||[])).next())})}var r=Object.prototype.hasOwnProperty,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),n=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},o=0;o<e.length;++o)void 0!==e[o]&&(r[o]=e[o]);return r},i={arrayToObject:n,assign:function(e,t){return Object.keys(t).reduce(function(e,r){return e[r]=t[r],e},e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],o=0;o<t.length;++o)for(var n=t[o],i=n.obj[n.prop],a=Object.keys(i),s=0;s<a.length;++s){var c=a[s],d=i[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:i,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(Array.isArray(r)){for(var o=[],n=0;n<r.length;++n)void 0!==r[n]&&o.push(r[n]);t.obj[t.prop]=o}}}(t),e},decode:function(e,t,r){var o=e.replace(/\+/g," ");if("iso-8859-1"===r)return o.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(o)}catch(e){return o}},encode:function(e,t,r){if(0===e.length)return e;var n="string"==typeof e?e:String(e);if("iso-8859-1"===r)return escape(n).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var i="",a=0;a<n.length;++a){var s=n.charCodeAt(a);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?i+=n.charAt(a):s<128?i+=o[s]:s<2048?i+=o[192|s>>6]+o[128|63&s]:s<55296||s>=57344?i+=o[224|s>>12]+o[128|s>>6&63]+o[128|63&s]:(a+=1,s=65536+((1023&s)<<10|1023&n.charCodeAt(a)),i+=o[240|s>>18]+o[128|s>>12&63]+o[128|s>>6&63]+o[128|63&s])}return i},isBuffer:function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,o,i){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if("object"!=typeof t)return[t,o];(i&&(i.plainObjects||i.allowPrototypes)||!r.call(Object.prototype,o))&&(t[o]=!0)}return t}if("object"!=typeof t)return[t].concat(o);var a=t;return Array.isArray(t)&&!Array.isArray(o)&&(a=n(t,i)),Array.isArray(t)&&Array.isArray(o)?(o.forEach(function(o,n){r.call(t,n)?t[n]&&"object"==typeof t[n]?t[n]=e(t[n],o,i):t.push(o):t[n]=o}),t):Object.keys(o).reduce(function(t,n){var a=o[n];return r.call(t,n)?t[n]=e(t[n],a,i):t[n]=a,t},a)}},a=String.prototype.replace,s=/%20/g,c={default:"RFC3986",formatters:{RFC1738:function(e){return a.call(e,s,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"},d={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},l=Array.isArray,u=Array.prototype.push,p=function(e,t){u.apply(e,l(t)?t:[t])},f=Date.prototype.toISOString,h={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:i.encode,encodeValuesOnly:!1,indices:!1,serializeDate:function(e){return f.call(e)},skipNulls:!1,strictNullHandling:!1},y=function e(t,r,o,n,a,s,c,d,l,u,f,y,m){var g=t;if("function"==typeof c?g=c(r,g):g instanceof Date&&(g=u(g)),null===g){if(n)return s&&!y?s(r,h.encoder,m):r;g=""}if("string"==typeof g||"number"==typeof g||"boolean"==typeof g||i.isBuffer(g))return s?[f(y?r:s(r,h.encoder,m))+"="+f(s(g,h.encoder,m))]:[f(r)+"="+f(String(g))];var v,w=[];if(void 0===g)return w;if(Array.isArray(c))v=c;else{var b=Object.keys(g);v=d?b.sort(d):b}for(var _=0;_<v.length;++_){var O=v[_];a&&null===g[O]||(Array.isArray(g)?p(w,e(g[O],o(r,O),o,n,a,s,c,d,l,u,f,y,m)):p(w,e(g[O],r+(l?"."+O:"["+O+"]"),o,n,a,s,c,d,l,u,f,y,m)))}return w},m=Object.prototype.hasOwnProperty,g={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,decoder:i.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},v=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},w=function(e,t,r){if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,n=/(\[[^[\]]*])/g,i=/(\[[^[\]]*])/.exec(o),a=i?o.slice(0,i.index):o,s=[];if(a){if(!r.plainObjects&&m.call(Object.prototype,a)&&!r.allowPrototypes)return;s.push(a)}for(var c=0;null!==(i=n.exec(o))&&c<r.depth;){if(c+=1,!r.plainObjects&&m.call(Object.prototype,i[1].slice(1,-1))&&!r.allowPrototypes)return;s.push(i[1])}return i&&s.push("["+o.slice(i.index)+"]"),function(e,t,r){for(var o=t,n=e.length-1;n>=0;--n){var i,a=e[n];if("[]"===a&&r.parseArrays)i=[].concat(o);else{i=r.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(s,10);r.parseArrays||""!==s?!isNaN(c)&&a!==s&&String(c)===s&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(i=[])[c]=o:i[s]=o:i={0:o}}o=i}return o}(s,t,r)}},b=function(e,t){var r=t?i.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||i.isRegExp(r.delimiter)?r.delimiter:g.delimiter,r.depth="number"==typeof r.depth?r.depth:g.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:g.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:g.decoder,r.allowDots=void 0===r.allowDots?g.allowDots:!!r.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:g.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:g.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:g.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:g.strictNullHandling,void 0!==r.charset&&"utf-8"!==r.charset&&"iso-8859-1"!==r.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===r.charset&&(r.charset=g.charset),""===e||null==e)return r.plainObjects?Object.create(null):{};for(var o="string"==typeof e?function(e,t){var r,o={},n=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,s=n.split(t.delimiter,a),c=-1,d=t.charset;if(t.charsetSentinel)for(r=0;r<s.length;++r)0===s[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===s[r]?d="utf-8":"utf8=%26%2310003%3B"===s[r]&&(d="iso-8859-1"),c=r,r=s.length);for(r=0;r<s.length;++r)if(r!==c){var l,u,p=s[r],f=p.indexOf("]="),h=-1===f?p.indexOf("="):f+1;-1===h?(l=t.decoder(p,g.decoder,d),u=t.strictNullHandling?null:""):(l=t.decoder(p.slice(0,h),g.decoder,d),u=t.decoder(p.slice(h+1),g.decoder,d)),u&&t.interpretNumericEntities&&"iso-8859-1"===d&&(u=v(u)),m.call(o,l)?o[l]=i.combine(o[l],u):o[l]=u}return o}(e,r):e,n=r.plainObjects?Object.create(null):{},a=Object.keys(o),s=0;s<a.length;++s){var c=a[s],d=w(c,o[c],r);n=i.merge(n,d,r)}return i.compact(n)},_=function(e,t){var r=e,o=t?i.assign({},t):{};if(null!==o.encoder&&void 0!==o.encoder&&"function"!=typeof o.encoder)throw new TypeError("Encoder has to be a function.");var n=void 0===o.delimiter?h.delimiter:o.delimiter,a="boolean"==typeof o.strictNullHandling?o.strictNullHandling:h.strictNullHandling,s="boolean"==typeof o.skipNulls?o.skipNulls:h.skipNulls,l="boolean"==typeof o.encode?o.encode:h.encode,u="function"==typeof o.encoder?o.encoder:h.encoder,f="function"==typeof o.sort?o.sort:null,m=void 0===o.allowDots?h.allowDots:!!o.allowDots,g="function"==typeof o.serializeDate?o.serializeDate:h.serializeDate,v="boolean"==typeof o.encodeValuesOnly?o.encodeValuesOnly:h.encodeValuesOnly,w=o.charset||h.charset;if(void 0!==o.charset&&"utf-8"!==o.charset&&"iso-8859-1"!==o.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===o.format)o.format=c.default;else if(!Object.prototype.hasOwnProperty.call(c.formatters,o.format))throw new TypeError("Unknown format option provided.");var b,_,O=c.formatters[o.format];"function"==typeof o.filter?r=(_=o.filter)("",r):Array.isArray(o.filter)&&(b=_=o.filter);var j,E=[];if("object"!=typeof r||null===r)return"";j=o.arrayFormat in d?o.arrayFormat:"indices"in o?o.indices?"indices":"repeat":"indices";var A=d[j];b||(b=Object.keys(r)),f&&b.sort(f);for(var C=0;C<b.length;++C){var S=b[C];s&&null===r[S]||p(E,y(r[S],S,A,a,s,l?u:null,_,f,m,g,O,v,w))}var U=E.join(n),x=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&(x+="iso-8859-1"===w?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),U.length>0?x+U:""};const O={error:"timeout",error_description:"Timeout"},j=(...e)=>{const t=e.filter(Boolean).join();return Array.from(new Set(t.replace(/\s/g,",").split(","))).join(" ").trim()},E=e=>{var t=b(e);return Object.assign({},t,{expires_in:parseInt(t.expires_in)})},A=(e,t)=>new Promise((r,o)=>{var n=window.document.createElement("iframe");n.setAttribute("width","0"),n.setAttribute("height","0"),n.style.display="none";const i=setTimeout(()=>{o(O),window.document.body.removeChild(n)},6e4),a=function(e){e.origin==t&&e.data&&"authorization_response"===e.data.type&&(e.source.close(),e.data.response.error?o(e.data.response):r(e.data.response),clearTimeout(i),window.removeEventListener("message",a,!1),window.document.body.removeChild(n))};window.addEventListener("message",a,!1),window.document.body.appendChild(n),n.setAttribute("src",e)}),C=()=>{const 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},S=(e,t)=>(e.location.href=t,new Promise((t,r)=>{const o=setTimeout(()=>{r(O)},6e4);window.addEventListener("message",n=>{if(n.data&&"authorization_response"===n.data.type){if(clearTimeout(o),e.close(),n.data.response.error)return r(n.data.response);t(n.data.response)}})})),U=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";return crypto.getRandomValues(new Uint8Array(43)).forEach(r=>t+=e[r%e.length]),t},x=e=>btoa(e),k=e=>_(e),T=e=>window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e)),P=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),D=e=>(e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[\+\/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(new Uint8Array(e))))),I=r=>t(void 0,void 0,void 0,function*(){var{baseUrl:t}=r,o=e(r,["baseUrl"]);return yield fetch(`${t}/oauth/token`,{method:"POST",body:JSON.stringify(Object.assign({grant_type:"authorization_code",redirect_uri:window.location.origin},o)),headers:{"Content-type":"application/json"}}).then(e=>e.json())}),L=e=>`${e.audience}::${e.scope}`,N=(e,t)=>{const r=(new Date(1e3*t).getTime()-(new Date).getTime())/1e3;return 1e3*Math.min(e,r)};class R{constructor(){this.cache={}}save(e){const t=L(e);this.cache[t]=e;const r=N(e.expires_in,e.decodedToken.claims.exp);setTimeout(()=>{delete this.cache[t]},r)}get(e){return this.cache[L(e)]}}var F="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var z,B,$=(function(e,t){var r=F&&F.__assign||Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e};function o(e,t){if(!t)return"";var r="; "+e;return!0===t?r:r+"="+t}function n(e,t,r){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 o("Expires",e.expires?e.expires.toUTCString():"")+o("Domain",e.domain)+o("Path",e.path)+o("Secure",e.secure)+o("SameSite",e.sameSite)}(r)}function i(e){for(var t={},r=e?e.split("; "):[],o=/(%[0-9A-Z]{2})+/g,n=0;n<r.length;n++){var i=r[n].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}function a(){return i(document.cookie)}function s(e,t,o){document.cookie=n(e,t,r({path:"/"},o))}t.__esModule=!0,t.encode=n,t.parse=i,t.getAll=a,t.get=function(e){return a()[e]},t.set=s,t.remove=function(e,t){s(e,"",r({},t,{expires:-1}))}}(z={exports:{}},z.exports),z.exports);(B=$)&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")&&B.default;$.encode,$.parse;var H=$.getAll,M=$.get,J=$.set,Q=$.remove;const V=()=>Object.keys(H()||{}),W=e=>{const t=M(e);if(void 0!==t)return JSON.parse(t)},q=(e,t,r)=>{J(e,JSON.stringify(t),{expires:r.daysUntilExpire})},Z=e=>{Q(e)},G="Auth0.spa-js.transactions.",K=e=>`${G}${e}`;class X{constructor(){this.transactions={},V().filter(e=>e.startsWith(G)).forEach(e=>{const t=e.replace(G,"");this.transactions[t]=W(e)})}create(e){this.transactions[e.state]=e,q(K(e.state),e,{daysUntilExpire:1})}get(e){return this.transactions[e]}remove(e){delete this.transactions[e],Z(K(e))}}const Y=["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"],ee=e=>{const t=(e=>{const[t,r,o]=e.split("."),n=JSON.parse(P(r)),i={},a={};return Object.keys(n).forEach(e=>{i[e]=n[e],Y.includes(e)||(a[e]=n[e])}),{encoded:{header:t,payload:r,signature:o},header:JSON.parse(P(t)),claims:i,user:a}})(e.id_token);if(t.claims.iss!==e.iss)throw new Error("Invalid issuer");if(t.claims.aud!==e.aud)throw new Error("Invalid audience");if("RS256"!==t.header.alg)throw new Error("Invalid algorithm");if(t.claims.nonce!==e.nonce)throw new Error("Invalid nonce");const r=new Date,o=new Date(0),n=new Date(0),i=new Date(0),a=e.leeway||60;if(o.setUTCSeconds(t.claims.exp+a),n.setUTCSeconds(t.claims.iat-a),i.setUTCSeconds(t.claims.nbf-a),r>o)throw new Error("id_token expired");if(r<n)throw new Error("id_token was issued in the future (invalid iat)");if(void 0!==t.claims.nbf&&r<i)throw new Error("token is not yet valid (invalid notBefore)");return t};class te extends Error{constructor(e,t,r){super(t),this.error=e,this.error_description=t,this.state=r}}var re="1.0.0";class oe{constructor(e){this.options=e,this.DEFAULT_SCOPE="openid profile email",this.cache=new R,this.transactionManager=new X,this.domainUrl=`https://${this.options.domain}`}_url(e){const t=encodeURIComponent(btoa(JSON.stringify({name:"auth0-spa-js",version:re})));return`${this.domainUrl}${e}&auth0Client=${t}`}_getParams(t,r,o,n,i){const a=e(this.options,["domain"]);return Object.assign({},a,t,{scope:j(this.DEFAULT_SCOPE,this.options.scope,t.scope),response_type:"code",response_mode:"query",state:r,nonce:o,redirect_uri:this.options.redirect_uri||i,code_challenge:n,code_challenge_method:"S256"})}_authorizeUrl(e){return this._url(`/authorize?${k(e)}`)}_verifyIdToken(e,t){return ee({iss:`${this.domainUrl}/`,aud:this.options.client_id,id_token:e,nonce:t,leeway:this.options.leeway})}loginWithPopup(r){return t(this,void 0,void 0,function*(){const t=yield C(),o=e(r,[]),n=x(U()),i=U(),a=U(),s=yield T(a),c=D(s),d=this._getParams(o,n,i,c,window.location.origin),l=this._authorizeUrl(Object.assign({},d,{response_mode:"web_message"})),u=yield S(t,l);if(n!==u.state)throw new Error("Invalid state");const p=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:a,code:u.code}),f=this._verifyIdToken(p.id_token,i),h=Object.assign({},p,{decodedToken:f,scope:d.scope,audience:d.audience||"default"});this.cache.save(h),q("auth0.is.authenticated",!0,{daysUntilExpire:1})})}getUser(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.user})}getIdTokenClaims(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.claims})}loginWithRedirect(r){return t(this,void 0,void 0,function*(){const{redirect_uri:t,appState:o}=r,n=e(r,["redirect_uri","appState"]),i=x(U()),a=U(),s=U(),c=yield T(s),d=D(c),l=this._getParams(n,i,a,d,t),u=this._authorizeUrl(l);this.transactionManager.create({state:i,nonce:a,code_verifier:s,code_challenge:d,appState:o,scope:l.scope,audience:l.audience||"default"}),window.location.assign(u)})}handleRedirectCallback(){return t(this,void 0,void 0,function*(){if(!window.location.search)throw new Error("There are no query params available at `window.location.search`.");const{state:e,code:t,error:r,error_description:o}=E(window.location.search.substr(1));if(r)throw new te(r,o,e);const n=this.transactionManager.get(e);if(!n)throw new Error("Invalid state");this.transactionManager.remove(e);const i=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:n.code_verifier,code:t}),a=this._verifyIdToken(i.id_token,n.nonce),s=Object.assign({},i,{decodedToken:a,audience:n.audience,scope:n.scope});return this.cache.save(s),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),{appState:n.appState}})}getTokenSilently(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE,ignoreCache:!1}){return t(this,void 0,void 0,function*(){if(e.scope=j(this.DEFAULT_SCOPE,e.scope),!e.ignoreCache){const t=this.cache.get({scope:e.scope,audience:e.audience||"default"});if(t)return t.access_token}const t=x(U()),r=U(),o=U(),n=yield T(o),i=D(n),a={audience:e.audience,scope:e.scope},s=this._getParams(a,t,r,i,window.location.origin),c=this._authorizeUrl(Object.assign({},s,{prompt:"none",response_mode:"web_message"})),d=yield A(c,this.domainUrl);if(t!==d.state)throw new Error("Invalid state");const l=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:o,code:d.code}),u=this._verifyIdToken(l.id_token,r),p=Object.assign({},l,{decodedToken:u,scope:s.scope,audience:s.audience||"default"});return this.cache.save(p),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),l.access_token})}getTokenWithPopup(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){return e.scope=j(this.DEFAULT_SCOPE,this.options.scope,e.scope),yield this.loginWithPopup(e),this.cache.get({scope:e.scope,audience:e.audience||"default"}).access_token})}isAuthenticated(){return t(this,void 0,void 0,function*(){return!!(yield this.getUser())})}logout(e={}){null!==e.client_id?e.client_id=e.client_id||this.options.client_id:delete e.client_id,Z("auth0.is.authenticated");const t=this._url(`/v2/logout?${k(e)}`);window.location.assign(t)}}return function(e){return t(this,void 0,void 0,function*(){const t=new oe(e);if(!W("auth0.is.authenticated"))return t;try{yield t.getTokenSilently({audience:e.audience,scope:e.scope,ignoreCache:!0})}catch(e){}return t})}});
!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";function e(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&(r[o[n]]=e[o[n]])}return r}function t(e,t,r,o){return new(r||(r=Promise))(function(n,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?n(e.value):new r(function(t){t(e.value)}).then(a,s)}c((o=o.apply(e,t||[])).next())})}var r=Object.prototype.hasOwnProperty,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),n=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},o=0;o<e.length;++o)void 0!==e[o]&&(r[o]=e[o]);return r},i={arrayToObject:n,assign:function(e,t){return Object.keys(t).reduce(function(e,r){return e[r]=t[r],e},e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],o=0;o<t.length;++o)for(var n=t[o],i=n.obj[n.prop],a=Object.keys(i),s=0;s<a.length;++s){var c=a[s],d=i[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:i,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(Array.isArray(r)){for(var o=[],n=0;n<r.length;++n)void 0!==r[n]&&o.push(r[n]);t.obj[t.prop]=o}}}(t),e},decode:function(e,t,r){var o=e.replace(/\+/g," ");if("iso-8859-1"===r)return o.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(o)}catch(e){return o}},encode:function(e,t,r){if(0===e.length)return e;var n="string"==typeof e?e:String(e);if("iso-8859-1"===r)return escape(n).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var i="",a=0;a<n.length;++a){var s=n.charCodeAt(a);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?i+=n.charAt(a):s<128?i+=o[s]:s<2048?i+=o[192|s>>6]+o[128|63&s]:s<55296||s>=57344?i+=o[224|s>>12]+o[128|s>>6&63]+o[128|63&s]:(a+=1,s=65536+((1023&s)<<10|1023&n.charCodeAt(a)),i+=o[240|s>>18]+o[128|s>>12&63]+o[128|s>>6&63]+o[128|63&s])}return i},isBuffer:function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,o,i){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if("object"!=typeof t)return[t,o];(i&&(i.plainObjects||i.allowPrototypes)||!r.call(Object.prototype,o))&&(t[o]=!0)}return t}if("object"!=typeof t)return[t].concat(o);var a=t;return Array.isArray(t)&&!Array.isArray(o)&&(a=n(t,i)),Array.isArray(t)&&Array.isArray(o)?(o.forEach(function(o,n){r.call(t,n)?t[n]&&"object"==typeof t[n]?t[n]=e(t[n],o,i):t.push(o):t[n]=o}),t):Object.keys(o).reduce(function(t,n){var a=o[n];return r.call(t,n)?t[n]=e(t[n],a,i):t[n]=a,t},a)}},a=String.prototype.replace,s=/%20/g,c={default:"RFC3986",formatters:{RFC1738:function(e){return a.call(e,s,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"},d={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},l=Array.isArray,u=Array.prototype.push,p=function(e,t){u.apply(e,l(t)?t:[t])},f=Date.prototype.toISOString,h={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:i.encode,encodeValuesOnly:!1,indices:!1,serializeDate:function(e){return f.call(e)},skipNulls:!1,strictNullHandling:!1},y=function e(t,r,o,n,a,s,c,d,l,u,f,y,m){var g=t;if("function"==typeof c?g=c(r,g):g instanceof Date&&(g=u(g)),null===g){if(n)return s&&!y?s(r,h.encoder,m):r;g=""}if("string"==typeof g||"number"==typeof g||"boolean"==typeof g||i.isBuffer(g))return s?[f(y?r:s(r,h.encoder,m))+"="+f(s(g,h.encoder,m))]:[f(r)+"="+f(String(g))];var v,w=[];if(void 0===g)return w;if(Array.isArray(c))v=c;else{var b=Object.keys(g);v=d?b.sort(d):b}for(var _=0;_<v.length;++_){var O=v[_];a&&null===g[O]||(Array.isArray(g)?p(w,e(g[O],o(r,O),o,n,a,s,c,d,l,u,f,y,m)):p(w,e(g[O],r+(l?"."+O:"["+O+"]"),o,n,a,s,c,d,l,u,f,y,m)))}return w},m=Object.prototype.hasOwnProperty,g={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,decoder:i.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},v=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},w=function(e,t,r){if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,n=/(\[[^[\]]*])/g,i=/(\[[^[\]]*])/.exec(o),a=i?o.slice(0,i.index):o,s=[];if(a){if(!r.plainObjects&&m.call(Object.prototype,a)&&!r.allowPrototypes)return;s.push(a)}for(var c=0;null!==(i=n.exec(o))&&c<r.depth;){if(c+=1,!r.plainObjects&&m.call(Object.prototype,i[1].slice(1,-1))&&!r.allowPrototypes)return;s.push(i[1])}return i&&s.push("["+o.slice(i.index)+"]"),function(e,t,r){for(var o=t,n=e.length-1;n>=0;--n){var i,a=e[n];if("[]"===a&&r.parseArrays)i=[].concat(o);else{i=r.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(s,10);r.parseArrays||""!==s?!isNaN(c)&&a!==s&&String(c)===s&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(i=[])[c]=o:i[s]=o:i={0:o}}o=i}return o}(s,t,r)}},b=function(e,t){var r=t?i.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||i.isRegExp(r.delimiter)?r.delimiter:g.delimiter,r.depth="number"==typeof r.depth?r.depth:g.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:g.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:g.decoder,r.allowDots=void 0===r.allowDots?g.allowDots:!!r.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:g.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:g.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:g.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:g.strictNullHandling,void 0!==r.charset&&"utf-8"!==r.charset&&"iso-8859-1"!==r.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===r.charset&&(r.charset=g.charset),""===e||null==e)return r.plainObjects?Object.create(null):{};for(var o="string"==typeof e?function(e,t){var r,o={},n=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,s=n.split(t.delimiter,a),c=-1,d=t.charset;if(t.charsetSentinel)for(r=0;r<s.length;++r)0===s[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===s[r]?d="utf-8":"utf8=%26%2310003%3B"===s[r]&&(d="iso-8859-1"),c=r,r=s.length);for(r=0;r<s.length;++r)if(r!==c){var l,u,p=s[r],f=p.indexOf("]="),h=-1===f?p.indexOf("="):f+1;-1===h?(l=t.decoder(p,g.decoder,d),u=t.strictNullHandling?null:""):(l=t.decoder(p.slice(0,h),g.decoder,d),u=t.decoder(p.slice(h+1),g.decoder,d)),u&&t.interpretNumericEntities&&"iso-8859-1"===d&&(u=v(u)),m.call(o,l)?o[l]=i.combine(o[l],u):o[l]=u}return o}(e,r):e,n=r.plainObjects?Object.create(null):{},a=Object.keys(o),s=0;s<a.length;++s){var c=a[s],d=w(c,o[c],r);n=i.merge(n,d,r)}return i.compact(n)},_=function(e,t){var r=e,o=t?i.assign({},t):{};if(null!==o.encoder&&void 0!==o.encoder&&"function"!=typeof o.encoder)throw new TypeError("Encoder has to be a function.");var n=void 0===o.delimiter?h.delimiter:o.delimiter,a="boolean"==typeof o.strictNullHandling?o.strictNullHandling:h.strictNullHandling,s="boolean"==typeof o.skipNulls?o.skipNulls:h.skipNulls,l="boolean"==typeof o.encode?o.encode:h.encode,u="function"==typeof o.encoder?o.encoder:h.encoder,f="function"==typeof o.sort?o.sort:null,m=void 0===o.allowDots?h.allowDots:!!o.allowDots,g="function"==typeof o.serializeDate?o.serializeDate:h.serializeDate,v="boolean"==typeof o.encodeValuesOnly?o.encodeValuesOnly:h.encodeValuesOnly,w=o.charset||h.charset;if(void 0!==o.charset&&"utf-8"!==o.charset&&"iso-8859-1"!==o.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0===o.format)o.format=c.default;else if(!Object.prototype.hasOwnProperty.call(c.formatters,o.format))throw new TypeError("Unknown format option provided.");var b,_,O=c.formatters[o.format];"function"==typeof o.filter?r=(_=o.filter)("",r):Array.isArray(o.filter)&&(b=_=o.filter);var j,E=[];if("object"!=typeof r||null===r)return"";j=o.arrayFormat in d?o.arrayFormat:"indices"in o?o.indices?"indices":"repeat":"indices";var A=d[j];b||(b=Object.keys(r)),f&&b.sort(f);for(var C=0;C<b.length;++C){var S=b[C];s&&null===r[S]||p(E,y(r[S],S,A,a,s,l?u:null,_,f,m,g,O,v,w))}var x=E.join(n),U=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&(U+="iso-8859-1"===w?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),x.length>0?U+x:""};const O={error:"timeout",error_description:"Timeout"},j=(...e)=>{const t=e.filter(Boolean).join();return Array.from(new Set(t.replace(/\s/g,",").split(","))).join(" ").trim()},E=e=>{var t=b(e);return Object.assign({},t,{expires_in:parseInt(t.expires_in)})},A=(e,t)=>new Promise((r,o)=>{var n=window.document.createElement("iframe");n.setAttribute("width","0"),n.setAttribute("height","0"),n.style.display="none";const i=setTimeout(()=>{o(O),window.document.body.removeChild(n)},6e4),a=function(e){e.origin==t&&e.data&&"authorization_response"===e.data.type&&(e.source.close(),e.data.response.error?o(e.data.response):r(e.data.response),clearTimeout(i),window.removeEventListener("message",a,!1),window.document.body.removeChild(n))};window.addEventListener("message",a,!1),window.document.body.appendChild(n),n.setAttribute("src",e)}),C=()=>{const 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},S=(e,t)=>(e.location.href=t,new Promise((t,r)=>{const o=setTimeout(()=>{r(O)},6e4);window.addEventListener("message",n=>{if(n.data&&"authorization_response"===n.data.type){if(clearTimeout(o),e.close(),n.data.response.error)return r(n.data.response);t(n.data.response)}})})),x=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";return crypto.getRandomValues(new Uint8Array(43)).forEach(r=>t+=e[r%e.length]),t},U=e=>btoa(e),k=e=>_(e),T=e=>window.crypto.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e)),P=e=>(e=>decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))(e.replace(/_/g,"/").replace(/-/g,"+")),D=e=>(e=>{const t={"+":"-","/":"_","=":""};return e.replace(/[\+\/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(new Uint8Array(e))))),I=r=>t(void 0,void 0,void 0,function*(){var{baseUrl:t}=r,o=e(r,["baseUrl"]);return yield fetch(`${t}/oauth/token`,{method:"POST",body:JSON.stringify(Object.assign({grant_type:"authorization_code",redirect_uri:window.location.origin},o)),headers:{"Content-type":"application/json"}}).then(e=>e.json())}),L=e=>`${e.audience}::${e.scope}`,N=(e,t)=>{const r=(new Date(1e3*t).getTime()-(new Date).getTime())/1e3;return 1e3*Math.min(e,r)};class R{constructor(){this.cache={}}save(e){const t=L(e);this.cache[t]=e;const r=N(e.expires_in,e.decodedToken.claims.exp);setTimeout(()=>{delete this.cache[t]},r)}get(e){return this.cache[L(e)]}}var F="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var z,B,$=(function(e,t){var r=F&&F.__assign||Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e};function o(e,t){if(!t)return"";var r="; "+e;return!0===t?r:r+"="+t}function n(e,t,r){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 o("Expires",e.expires?e.expires.toUTCString():"")+o("Domain",e.domain)+o("Path",e.path)+o("Secure",e.secure)+o("SameSite",e.sameSite)}(r)}function i(e){for(var t={},r=e?e.split("; "):[],o=/(%[0-9A-Z]{2})+/g,n=0;n<r.length;n++){var i=r[n].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}function a(){return i(document.cookie)}function s(e,t,o){document.cookie=n(e,t,r({path:"/"},o))}t.__esModule=!0,t.encode=n,t.parse=i,t.getAll=a,t.get=function(e){return a()[e]},t.set=s,t.remove=function(e,t){s(e,"",r({},t,{expires:-1}))}}(z={exports:{}},z.exports),z.exports);(B=$)&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")&&B.default;$.encode,$.parse;var H=$.getAll,M=$.get,J=$.set,Q=$.remove;const V=()=>Object.keys(H()||{}),W=e=>{const t=M(e);if(void 0!==t)return JSON.parse(t)},q=(e,t,r)=>{J(e,JSON.stringify(t),{expires:r.daysUntilExpire})},Z=e=>{Q(e)},G="a0.spajs.txs.",K=e=>`${G}${e}`;class X{constructor(){this.transactions={},V().filter(e=>e.startsWith(G)).forEach(e=>{const t=e.replace(G,"");this.transactions[t]=W(e)})}create(e,t){this.transactions[e]=t,q(K(e),t,{daysUntilExpire:1})}get(e){return this.transactions[e]}remove(e){delete this.transactions[e],Z(K(e))}}const Y=["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"],ee=e=>{const t=(e=>{const[t,r,o]=e.split("."),n=JSON.parse(P(r)),i={},a={};return Object.keys(n).forEach(e=>{i[e]=n[e],Y.includes(e)||(a[e]=n[e])}),{encoded:{header:t,payload:r,signature:o},header:JSON.parse(P(t)),claims:i,user:a}})(e.id_token);if(t.claims.iss!==e.iss)throw new Error("Invalid issuer");if(t.claims.aud!==e.aud)throw new Error("Invalid audience");if("RS256"!==t.header.alg)throw new Error("Invalid algorithm");if(t.claims.nonce!==e.nonce)throw new Error("Invalid nonce");const r=new Date,o=new Date(0),n=new Date(0),i=new Date(0),a=e.leeway||60;if(o.setUTCSeconds(t.claims.exp+a),n.setUTCSeconds(t.claims.iat-a),i.setUTCSeconds(t.claims.nbf-a),r>o)throw new Error("id_token expired");if(r<n)throw new Error("id_token was issued in the future (invalid iat)");if(void 0!==t.claims.nbf&&r<i)throw new Error("token is not yet valid (invalid notBefore)");return t};class te extends Error{constructor(e,t,r){super(t),this.error=e,this.error_description=t,this.state=r}}var re="1.0.1";class oe{constructor(e){this.options=e,this.DEFAULT_SCOPE="openid profile email",this.cache=new R,this.transactionManager=new X,this.domainUrl=`https://${this.options.domain}`}_url(e){const t=encodeURIComponent(btoa(JSON.stringify({name:"auth0-spa-js",version:re})));return`${this.domainUrl}${e}&auth0Client=${t}`}_getParams(t,r,o,n,i){const a=e(this.options,["domain"]);return Object.assign({},a,t,{scope:j(this.DEFAULT_SCOPE,this.options.scope,t.scope),response_type:"code",response_mode:"query",state:r,nonce:o,redirect_uri:this.options.redirect_uri||i,code_challenge:n,code_challenge_method:"S256"})}_authorizeUrl(e){return this._url(`/authorize?${k(e)}`)}_verifyIdToken(e,t){return ee({iss:`${this.domainUrl}/`,aud:this.options.client_id,id_token:e,nonce:t,leeway:this.options.leeway})}loginWithPopup(r){return t(this,void 0,void 0,function*(){const t=yield C(),o=e(r,[]),n=U(x()),i=x(),a=x(),s=yield T(a),c=D(s),d=this._getParams(o,n,i,c,window.location.origin),l=this._authorizeUrl(Object.assign({},d,{response_mode:"web_message"})),u=yield S(t,l);if(n!==u.state)throw new Error("Invalid state");const p=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:a,code:u.code}),f=this._verifyIdToken(p.id_token,i),h=Object.assign({},p,{decodedToken:f,scope:d.scope,audience:d.audience||"default"});this.cache.save(h),q("auth0.is.authenticated",!0,{daysUntilExpire:1})})}getUser(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.user})}getIdTokenClaims(e={audience:this.options.audience||"default",scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){e.scope=j(this.DEFAULT_SCOPE,e.scope);const t=this.cache.get(e);return t&&t.decodedToken.claims})}loginWithRedirect(r){return t(this,void 0,void 0,function*(){const{redirect_uri:t,appState:o}=r,n=e(r,["redirect_uri","appState"]),i=U(x()),a=x(),s=x(),c=yield T(s),d=D(c),l=this._getParams(n,i,a,d,t),u=this._authorizeUrl(l);this.transactionManager.create(i,{nonce:a,code_verifier:s,appState:o,scope:l.scope,audience:l.audience||"default"}),window.location.assign(u)})}handleRedirectCallback(){return t(this,void 0,void 0,function*(){if(!window.location.search)throw new Error("There are no query params available at `window.location.search`.");const{state:e,code:t,error:r,error_description:o}=E(window.location.search.substr(1));if(r)throw new te(r,o,e);const n=this.transactionManager.get(e);if(!n)throw new Error("Invalid state");this.transactionManager.remove(e);const i=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:n.code_verifier,code:t}),a=this._verifyIdToken(i.id_token,n.nonce),s=Object.assign({},i,{decodedToken:a,audience:n.audience,scope:n.scope});return this.cache.save(s),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),{appState:n.appState}})}getTokenSilently(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE,ignoreCache:!1}){return t(this,void 0,void 0,function*(){if(e.scope=j(this.DEFAULT_SCOPE,e.scope),!e.ignoreCache){const t=this.cache.get({scope:e.scope,audience:e.audience||"default"});if(t)return t.access_token}const t=U(x()),r=x(),o=x(),n=yield T(o),i=D(n),a={audience:e.audience,scope:e.scope},s=this._getParams(a,t,r,i,window.location.origin),c=this._authorizeUrl(Object.assign({},s,{prompt:"none",response_mode:"web_message"})),d=yield A(c,this.domainUrl);if(t!==d.state)throw new Error("Invalid state");const l=yield I({baseUrl:this.domainUrl,audience:this.options.audience,client_id:this.options.client_id,code_verifier:o,code:d.code}),u=this._verifyIdToken(l.id_token,r),p=Object.assign({},l,{decodedToken:u,scope:s.scope,audience:s.audience||"default"});return this.cache.save(p),q("auth0.is.authenticated",!0,{daysUntilExpire:1}),l.access_token})}getTokenWithPopup(e={audience:this.options.audience,scope:this.options.scope||this.DEFAULT_SCOPE}){return t(this,void 0,void 0,function*(){return e.scope=j(this.DEFAULT_SCOPE,this.options.scope,e.scope),yield this.loginWithPopup(e),this.cache.get({scope:e.scope,audience:e.audience||"default"}).access_token})}isAuthenticated(){return t(this,void 0,void 0,function*(){return!!(yield this.getUser())})}logout(e={}){null!==e.client_id?e.client_id=e.client_id||this.options.client_id:delete e.client_id,Z("auth0.is.authenticated");const t=this._url(`/v2/logout?${k(e)}`);window.location.assign(t)}}return function(e){return t(this,void 0,void 0,function*(){const t=new oe(e);if(!W("auth0.is.authenticated"))return t;try{yield t.getTokenSilently({audience:e.audience,scope:e.scope,ignoreCache:!0})}catch(e){}return t})}});
//# sourceMappingURL=auth0-spa-js.production.js.map

@@ -176,3 +176,3 @@ 'use strict';

const COOKIE_KEY = 'Auth0.spa-js.transactions.';
const COOKIE_KEY = 'a0.spajs.txs.';
const getTransactionKey = (state) => `${COOKIE_KEY}${state}`;

@@ -189,5 +189,5 @@ class TransactionManager {

}
create(transaction) {
this.transactions[transaction.state] = transaction;
save(getTransactionKey(transaction.state), transaction, {
create(state, transaction) {
this.transactions[state] = transaction;
save(getTransactionKey(state), transaction, {
daysUntilExpire: 1

@@ -298,3 +298,3 @@ });

var version = '1.0.0';
var version = '1.0.1';

@@ -440,7 +440,5 @@ /**

const url = this._authorizeUrl(params);
this.transactionManager.create({
state: stateIn,
this.transactionManager.create(stateIn, {
nonce: nonceIn,
code_verifier,
code_challenge: code_challenge,
appState,

@@ -447,0 +445,0 @@ scope: params.scope,

interface Transaction {
state: string;
nonce: string;

@@ -8,3 +7,2 @@ scope: string;

code_verifier: string;
code_challenge: string;
}

@@ -14,3 +12,3 @@ export default class TransactionManager {

constructor();
create(transaction: Transaction): void;
create(state: string, transaction: Transaction): void;
get(state: string): Transaction;

@@ -17,0 +15,0 @@ remove(state: string): void;

@@ -1,2 +0,2 @@

declare const _default: "1.0.0";
declare const _default: "1.0.1";
export default _default;

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/lib/auth0-spa-js.cjs.js",

@@ -9,0 +9,0 @@ "types": "dist/typings/index.d.ts",

@@ -209,7 +209,5 @@ import {

const url = this._authorizeUrl(params);
this.transactionManager.create({
state: stateIn,
this.transactionManager.create(stateIn, {
nonce: nonceIn,
code_verifier,
code_challenge: code_challenge,
appState,

@@ -216,0 +214,0 @@ scope: params.scope,

import * as ClientStorage from './storage';
const COOKIE_KEY = 'Auth0.spa-js.transactions.';
const COOKIE_KEY = 'a0.spajs.txs.';
const getTransactionKey = (state: string) => `${COOKIE_KEY}${state}`;
interface Transaction {
state: string;
nonce: string;

@@ -13,3 +12,2 @@ scope: string;

code_verifier: string;
code_challenge: string;
}

@@ -30,5 +28,5 @@ interface Transactions {

}
public create(transaction: Transaction) {
this.transactions[transaction.state] = transaction;
ClientStorage.save(getTransactionKey(transaction.state), transaction, {
public create(state: string, transaction: Transaction) {
this.transactions[state] = transaction;
ClientStorage.save(getTransactionKey(state), transaction, {
daysUntilExpire: 1

@@ -35,0 +33,0 @@ });

@@ -1,1 +0,1 @@

export default '1.0.0';
export default '1.0.1';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc