@okta/okta-auth-js
Version:
The Okta Auth SDK
2 lines • 332 kB
JavaScript
/*! For license information please see default.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.OktaAuth=t():e.OktaAuth=t()}(self,(function(){return function(){var e={1506:function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},4575:function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},9100:function(e,t,n){var r=n(9489),o=n(7067);function i(t,n,a){return o()?(e.exports=i=Reflect.construct,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=i=function(e,t,n){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return n&&r(i,n.prototype),i},e.exports.__esModule=!0,e.exports.default=e.exports),i.apply(null,arguments)}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},3913:function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},9754:function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},2205:function(e,t,n){var r=n(9489);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},430:function(e){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},e.exports.__esModule=!0,e.exports.default=e.exports},7067:function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports},8585:function(e,t,n){var r=n(8).default,o=n(1506);e.exports=function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return o(e)},e.exports.__esModule=!0,e.exports.default=e.exports},9489:function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},8:function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},5957:function(e,t,n){var r=n(9754),o=n(9489),i=n(430),a=n(9100);function u(t){var n="function"==typeof Map?new Map:void 0;return e.exports=u=function(e){if(null===e||!i(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return a(e,arguments,r(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),o(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,u(t)}e.exports=u,e.exports.__esModule=!0,e.exports.default=e.exports},7757:function(e,t,n){e.exports=n(5666)},9748:function(e,t,n){"use strict";n.d(t,{b:function(){return O}});var r=n(5385),o=n(9123),i=n(1971);function a(e,t){var n={};return Object.assign(n,t),!n.stateToken&&e.stateToken&&(n.stateToken=e.stateToken),n}function u(e,t){return t=a(e,t),(0,r.v_)(e,e.getIssuerOrigin()+"/api/v1/authn",t,{withCredentials:!0})}function c(e){return!!f(e)}function s(e,t,n,o,i){return i=Object.assign({withCredentials:!0},i),(0,r.v_)(e,n,o,i).then((function(e){return t.createTransaction(e)}))}function f(e){return e.options.storageUtil.storage.get(i.STATE_TOKEN_KEY_NAME)}var l=n(5671),p=n(4942),h=n(3193),d=n(4771),v=n(6718);function y(e,t,n,i,u,c){if(Array.isArray(u))return function(r,a){if(!r)throw new o.Z("Must provide a link name");var s=(0,h.sE)(u,{name:r});if(!s)throw new o.Z("No link found for that name");return y(e,t,n,i,s,c)(a)};if(u.hints&&u.hints.allow&&1===u.hints.allow.length)switch(u.hints.allow[0]){case"GET":return function(){return(0,r.U2)(e,u.href,{withCredentials:!0})};case"POST":return function(r){c&&c.isPolling&&(c.isPolling=!1);var f=a(n,r);"MFA_ENROLL"!==n.status&&"FACTOR_ENROLL"!==n.status||Object.assign(f,{factorType:i.factorType,provider:i.provider});var l={},p=f.autoPush;if(void 0!==p){if("function"==typeof p)try{l.autoPush=!!p()}catch(e){return Promise.reject(new o.Z("AutoPush resulted in an error."))}else null!==p&&(l.autoPush=!!p);f=(0,h.CE)(f,"autoPush")}var d=f.rememberDevice;if(void 0!==d){if("function"==typeof d)try{l.rememberDevice=!!d()}catch(e){return Promise.reject(new o.Z("RememberDevice resulted in an error."))}else null!==d&&(l.rememberDevice=!!d);f=(0,h.CE)(f,"rememberDevice")}else f.profile&&void 0!==f.profile.updatePhone&&(f.profile.updatePhone&&(l.updatePhone=!0),f.profile=(0,h.CE)(f.profile,"updatePhone"));var y=u.href+(0,v.UK)(l);return s(e,t,y,f)}}}var g=n(8750),m=n(6573);function b(e,t,n){return function(u){var c,s,f,l;(0,d.hj)(u)?c=u:(0,d.Kn)(u)&&(c=u.delay,s=u.rememberDevice,f=u.autoPush,l=u.transactionCallBack),c||0===c||(c=i.DEFAULT_POLLING_DELAY);var p=(0,h.Rg)(t,"next","poll");n.isPolling=!0;var y=0;return function i(){return n.isPolling?function(){var n={};if("function"==typeof f)try{n.autoPush=!!f()}catch(e){return Promise.reject(new o.Z("AutoPush resulted in an error."))}else null!=f&&(n.autoPush=!!f);if("function"==typeof s)try{n.rememberDevice=!!s()}catch(e){return Promise.reject(new o.Z("RememberDevice resulted in an error."))}else null!=s&&(n.rememberDevice=!!s);var i=p.href+(0,v.UK)(n);return(0,r.v_)(e,i,function(e){return a(e)}(t),{saveAuthnState:!1,withCredentials:!0})}().then((function(t){if(y=0,t.factorResult&&"WAITING"===t.factorResult){if(!n.isPolling)throw new m.Z;return"function"==typeof l&&l(t),(0,g.gw)(c).then(i)}return n.isPolling=!1,e.tx.createTransaction(t)})).catch((function(e){if(e.xhr&&(0===e.xhr.status||429===e.xhr.status)&&y<=4){var t=1e3*Math.pow(2,y);return y++,(0,g.gw)(t).then(i)}throw e})):Promise.reject(new m.Z)}().catch((function(e){throw n.isPolling=!1,e}))}}function k(e,t,n,r,o){if(r=r||n,r=(0,h.d9)(r),Array.isArray(r)){for(var i=[],a=0,u=r.length;a<u;a++)i.push(k(e,t,n,r[a],o));return i}var c=r._embedded||{};for(var s in c)Object.prototype.hasOwnProperty.call(c,s)&&((0,d.Kn)(c[s])||Array.isArray(c[s]))&&(c[s]=k(e,t,n,c[s],o));var f=function(e,t,n,r,o){var i={};for(var a in r._links)if(Object.prototype.hasOwnProperty.call(r._links,a)){var u=r._links[a];if("next"===a&&(a=u.name),u.type)i[a]=u;else if("poll"===a)i.poll=b(e,n,o);else{var c=y(e,t,n,r,u,o);c&&(i[a]=c)}}return i}(e,t,n,r,o);return Object.assign(c,f),r=(0,h.CE)(r,"_embedded","_links"),Object.assign(r,c),r}var w=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;(0,l.Z)(this,e),(0,p.Z)(this,"next",void 0),(0,p.Z)(this,"cancel",void 0),(0,p.Z)(this,"skip",void 0),(0,p.Z)(this,"unlock",void 0),(0,p.Z)(this,"changePassword",void 0),(0,p.Z)(this,"resetPassword",void 0),(0,p.Z)(this,"answer",void 0),(0,p.Z)(this,"recovery",void 0),(0,p.Z)(this,"verify",void 0),(0,p.Z)(this,"resend",void 0),(0,p.Z)(this,"activate",void 0),(0,p.Z)(this,"poll",void 0),(0,p.Z)(this,"prev",void 0),(0,p.Z)(this,"data",void 0),(0,p.Z)(this,"stateToken",void 0),(0,p.Z)(this,"sessionToken",void 0),(0,p.Z)(this,"status",void 0),(0,p.Z)(this,"user",void 0),(0,p.Z)(this,"factor",void 0),(0,p.Z)(this,"factors",void 0),(0,p.Z)(this,"policy",void 0),(0,p.Z)(this,"scopes",void 0),(0,p.Z)(this,"target",void 0),(0,p.Z)(this,"authentication",void 0),this.data=void 0,this.status=void 0,r&&(this.data=r,Object.assign(this,k(t,n,r,r,{})),delete this.stateToken,"RECOVERY_CHALLENGE"!==r.status||r._links||(this.cancel=function(){return Promise.resolve(n.createTransaction())}))};function O(e){var t={status:u.bind(null,e),resume:function(n){return function(e,t,n){if(!n||!n.stateToken){var r=f(e);if(!r)return Promise.reject(new o.Z("No transaction to resume"));n={stateToken:r}}return u(e,n).then((function(e){return t.createTransaction(e)}))}(e,t,n)},exists:c.bind(null,e),introspect:function(n){return function(e,t,n){if(!n||!n.stateToken){var i=f(e);if(!i)return Promise.reject(new o.Z("No transaction to evaluate"));n={stateToken:i}}return function(e,t){return t=a(e,t),(0,r.v_)(e,e.getIssuerOrigin()+"/api/v1/authn/introspect",t,{withCredentials:!0})}(e,n).then((function(e){return t.createTransaction(e)}))}(e,t,n)},createTransaction:function(n){return new w(e,t,n)},postToTransaction:function(n,r,o){return s(e,t,n,r,o)}};return t}},3398:function(e,t,n){"use strict";n.d(t,{b:function(){return r.b},t:function(){return o.t}});var r=n(9748),o=n(8284)},8284:function(e,t,n){"use strict";n.d(t,{t:function(){return b}});var r=n(5861),o=n(5671),i=n(3144),a=n(7326),u=n(136),c=n(2963),s=n(1120),f=n(4942),l=n(7757),p=n.n(l),h=n(3193),d=n(9123),v=n(415),y=n(4970);function g(e,t){return t=t||{},(0,v.isFingerprintSupported)()?new Promise((function(i,a){var u;(r=document.createElement("iframe")).style.display="none",o=function(t){if(t&&t.data&&t.origin===e.getIssuerOrigin()){try{var n=JSON.parse(t.data)}catch(e){return}if(n)return"FingerprintAvailable"===n.type?i(n.fingerprint):void("FingerprintServiceReady"===n.type&&t.source.postMessage(JSON.stringify({type:"GetFingerprint"}),t.origin))}},(0,y.NH)(window,"message",o),r.src=e.getIssuerOrigin()+"/auth/services/devicefingerprint",document.body.appendChild(r),n=setTimeout((function(){a(new d.Z("Fingerprinting timed out"))}),(null===(u=t)||void 0===u?void 0:u.timeout)||15e3)})).finally((function(){clearTimeout(n),(0,y.ys)(window,"message",o),document.body.contains(r)&&r.parentElement.removeChild(r)})):Promise.reject(new d.Z("Fingerprinting is not supported on this device"));var n,r,o}var m=n(9748);function b(e){return function(e){(0,u.Z)(y,e);var t,n,l,d,v=(l=y,d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=(0,s.Z)(l);if(d){var n=(0,s.Z)(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return(0,c.Z)(this,e)});function y(){var e;(0,o.Z)(this,y);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e=v.call.apply(v,[this].concat(n)),(0,f.Z)((0,a.Z)(e),"tx",void 0),(0,f.Z)((0,a.Z)(e),"authn",void 0),(0,f.Z)((0,a.Z)(e),"fingerprint",void 0),e.authn=e.tx=(0,m.b)((0,a.Z)(e)),e.fingerprint=g.bind(null,(0,a.Z)(e)),e}return(0,i.Z)(y,[{key:"signIn",value:(n=(0,r.Z)(p().mark((function e(t){var n,r=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=(0,h.d9)(t||{}),n=function(e){return delete t.sendFingerprint,r.tx.postToTransaction("/api/v1/authn",t,e)},t.sendFingerprint){e.next=4;break}return e.abrupt("return",n());case 4:return e.abrupt("return",this.fingerprint().then((function(e){return n({headers:{"X-Device-Fingerprint":e}})})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"signInWithCredentials",value:(t=(0,r.Z)(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.signIn(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"forgotPassword",value:function(e){return this.tx.postToTransaction("/api/v1/authn/recovery/password",e)}},{key:"unlockAccount",value:function(e){return this.tx.postToTransaction("/api/v1/authn/recovery/unlock",e)}},{key:"verifyRecoveryToken",value:function(e){return this.tx.postToTransaction("/api/v1/authn/recovery/token",e)}}]),y}(e)}},9893:function(e,t,n){"use strict";n.d(t,{a:function(){return f}});var r=n(5671),o=n(4942),i=n(3193),a=n(415),u=n(1971),c=n(4279),s=n.n(c);function f(e){var t=function t(){(0,r.Z)(this,t),(0,o.Z)(this,"options",void 0),(0,o.Z)(this,"emitter",void 0),(0,o.Z)(this,"features",void 0);var n=new e(arguments.length&&(arguments.length<=0?void 0:arguments[0])||{});this.options=(0,i.YY)(n),this.emitter=new(s()),this.features=a};return(0,o.Z)(t,"features",a),(0,o.Z)(t,"constants",u),t.features=t.prototype.features=a,Object.assign(t,{constants:u}),t}},3306:function(e,t,n){"use strict";n.d(t,{a:function(){return r.a},X:function(){return o.X}});var r=n(9893),o=n(5093)},5093:function(e,t,n){"use strict";n.d(t,{X:function(){return i}});var r=n(5671),o=n(4942);function i(){return function e(t){(0,r.Z)(this,e),(0,o.Z)(this,"devMode",void 0),this.devMode=!!t.devMode}}},4858:function(e,t,n){"use strict";function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}n.d(t,{Z:function(){return f}});var o=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=r({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var u in i)i[u]&&(a+="; "+u,!0!==i[u]&&(a+="="+i[u].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+a}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(r[u]=t.read(a,u),e===u)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){o(e,"",r({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,r({},this.attributes,t))},withConverter:function(t){return e(r({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),i=o,a=n(9123),u=n(146),c=n(415),s={browserHasLocalStorage:function(){try{var e=this.getLocalStorage();return this.testStorage(e)}catch(e){return!1}},browserHasSessionStorage:function(){try{var e=this.getSessionStorage();return this.testStorage(e)}catch(e){return!1}},testStorageType:function(e){var t=!1;switch(e){case"sessionStorage":t=this.browserHasSessionStorage();break;case"localStorage":t=this.browserHasLocalStorage();break;case"cookie":case"memory":t=!0;break;default:t=!1}return t},getStorageByType:function(e,t){var n;switch(e){case"sessionStorage":n=this.getSessionStorage();break;case"localStorage":n=this.getLocalStorage();break;case"cookie":n=this.getCookieStorage(t);break;case"memory":n=this.getInMemoryStorage();break;default:throw new a.Z("Unrecognized storage option: ".concat(e))}return n},findStorageType:function(e){var t,n;return t=(e=e.slice()).shift(),(n=e.length?e[0]:null)?this.testStorageType(t)?t:((0,u.ZK)("This browser doesn't support ".concat(t,". Switching to ").concat(n,".")),this.findStorageType(e)):t},getLocalStorage:function(){return(0,c.isIE11OrLess)()&&!window.onstorage&&(window.onstorage=function(){}),localStorage},getSessionStorage:function(){return sessionStorage},getCookieStorage:function(e){var t=this,n=e.secure,r=e.sameSite,o=e.sessionCookie;if(void 0===n||void 0===r)throw new a.Z('getCookieStorage: "secure" and "sameSite" options must be provided');var i={getItem:this.storage.get,setItem:function(e,i){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"2200-01-01T00:00:00.000Z";a=o?null:a,t.storage.set(e,i,a,{secure:n,sameSite:r})},removeItem:function(e){t.storage.delete(e)}};return e.useSeparateCookies?{getItem:function(e){var t=i.getItem(),n={};return Object.keys(t).forEach((function(r){0===r.indexOf(e)&&(n[r.replace("".concat(e,"_"),"")]=JSON.parse(t[r]))})),JSON.stringify(n)},setItem:function(e,t){var n=JSON.parse(this.getItem(e));t=JSON.parse(t),Object.keys(t).forEach((function(r){var o=e+"_"+r,a=JSON.stringify(t[r]);i.setItem(o,a),delete n[r]})),Object.keys(n).forEach((function(t){i.removeItem(e+"_"+t)}))},removeItem:function(e){var t=JSON.parse(this.getItem(e));Object.keys(t).forEach((function(t){i.removeItem(e+"_"+t)}))}}:i},inMemoryStore:{},getInMemoryStorage:function(){var e=this;return{getItem:function(t){return e.inMemoryStore[t]},setItem:function(t,n){e.inMemoryStore[t]=n}}},testStorage:function(e){var t="okta-test-storage";try{return e.setItem(t,t),e.removeItem(t),!0}catch(e){return!1}},storage:{set:function(e,t,n,r){var o=r.sameSite,u=r.secure;if(void 0===u||void 0===o)throw new a.Z('storage.set: "secure" and "sameSite" options must be provided');var c={path:r.path||"/",secure:u,sameSite:o};return Date.parse(n)&&(c.expires=new Date(n)),i.set(e,t,c),this.get(e)},get:function(e){return arguments.length?i.get(e):i.get()},delete:function(e){return i.remove(e,{path:"/"})}}},f=s},1971:function(e,t,n){"use strict";n.r(t),n.d(t,{STATE_TOKEN_KEY_NAME:function(){return r},DEFAULT_POLLING_DELAY:function(){return o},DEFAULT_MAX_CLOCK_SKEW:function(){return i},DEFAULT_CACHE_DURATION:function(){return a},TOKEN_STORAGE_NAME:function(){return u},CACHE_STORAGE_NAME:function(){return c},PKCE_STORAGE_NAME:function(){return s},TRANSACTION_STORAGE_NAME:function(){return f},SHARED_TRANSACTION_STORAGE_NAME:function(){return l},ORIGINAL_URI_STORAGE_NAME:function(){return p},IDX_RESPONSE_STORAGE_NAME:function(){return h},ACCESS_TOKEN_STORAGE_KEY:function(){return d},ID_TOKEN_STORAGE_KEY:function(){return v},REFRESH_TOKEN_STORAGE_KEY:function(){return y},REFERRER_PATH_STORAGE_KEY:function(){return g},MIN_VERIFIER_LENGTH:function(){return m},MAX_VERIFIER_LENGTH:function(){return b},DEFAULT_CODE_CHALLENGE_METHOD:function(){return k},IDX_API_VERSION:function(){return w}});var r="oktaStateToken",o=500,i=300,a=86400,u="okta-token-storage",c="okta-cache-storage",s="okta-pkce-storage",f="okta-transaction-storage",l="okta-shared-transaction-storage",p="okta-original-uri-storage",h="okta-idx-response-storage",d="accessToken",v="idToken",y="refreshToken",g="referrerPath",m=43,b=128,k="S256",w="1.0.0"},1018:function(e,t,n){"use strict";n.d(t,{a:function(){return g},E:function(){return k}});var r=n(5861),o=n(5671),i=n(3144),a=n(4942),u=n(7757),c=n.n(u),s=n(3615),f=n.n(s),l=n(9123),p=n(7088),h=n(3548),d=n(146);function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){(0,a.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var g=null,m={updateAuthStatePromise:null,canceledTimes:0},b="authStateChange",k=function(){function e(t){var n=this;if((0,o.Z)(this,e),(0,a.Z)(this,"_sdk",void 0),(0,a.Z)(this,"_pending",void 0),(0,a.Z)(this,"_authState",void 0),(0,a.Z)(this,"_prevAuthState",void 0),(0,a.Z)(this,"_logOptions",void 0),(0,a.Z)(this,"_transformQueue",void 0),!t.emitter)throw new l.Z("Emitter should be initialized before AuthStateManager");this._sdk=t,this._pending=y({},m),this._authState=g,this._logOptions={},this._prevAuthState=null,this._transformQueue=new h.b({quiet:!0}),t.tokenManager.on(p.O3,(function(e,t){n._setLogOptions({event:p.O3,key:e,token:t}),n.updateAuthState()})),t.tokenManager.on(p.FT,(function(e,t){n._setLogOptions({event:p.FT,key:e,token:t}),n.updateAuthState()}))}var t;return(0,i.Z)(e,[{key:"_setLogOptions",value:function(e){this._logOptions=e}},{key:"getAuthState",value:function(){return this._authState}},{key:"getPreviousAuthState",value:function(){return this._prevAuthState}},{key:"updateAuthState",value:(t=(0,r.Z)(c().mark((function e(){var t,n,r,o,i,a,u,s=this;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._sdk.options,n=t.transformAuthState,r=t.devMode,o=function(e){var t=s._logOptions,n=t.event,r=t.key,o=t.token;(0,d.dr)().group("OKTA-AUTH-JS:updateAuthState: Event:".concat(n," Status:").concat(e)),(0,d.dr)().log(r,o),(0,d.dr)().log("Current authState",s._authState),(0,d.dr)().groupEnd(),s._logOptions={}},i=function(e){var t,n;n=e,(t=s._authState)&&t.isAuthenticated===n.isAuthenticated&&JSON.stringify(t.idToken)===JSON.stringify(n.idToken)&&JSON.stringify(t.accessToken)===JSON.stringify(n.accessToken)&&t.error===n.error?r&&o("unchanged"):(s._prevAuthState=s._authState,s._authState=e,s._sdk.emitter.emit(b,y({},e)),r&&o("emitted"))},a=function e(t){return s._pending.updateAuthStatePromise.then((function(){var n=s._pending.updateAuthStatePromise;return n&&n!==t?e(n):s.getAuthState()}))},!this._pending.updateAuthStatePromise){e.next=11;break}if(!(this._pending.canceledTimes>=10)){e.next=10;break}return r&&o("terminated"),e.abrupt("return",a(this._pending.updateAuthStatePromise));case 10:this._pending.updateAuthStatePromise.cancel();case 11:return u=new(f())((function(e,t,a){a.shouldReject=!1,a((function(){s._pending.updateAuthStatePromise=null,s._pending.canceledTimes=s._pending.canceledTimes+1,r&&o("canceled")}));var c=function(t){u.isCanceled?e():(i(t),e(),s._pending=y({},m))};s._sdk.isAuthenticated().then((function(){if(u.isCanceled)e();else{var t=s._sdk.tokenManager.getTokensSync(),r=t.accessToken,o=t.idToken,i=t.refreshToken,a={accessToken:r,idToken:o,refreshToken:i,isAuthenticated:!(!r||!o)};(n?s._transformQueue.push(n,null,s._sdk,a):Promise.resolve(a)).then((function(e){return c(e)})).catch((function(e){return c({accessToken:r,idToken:o,refreshToken:i,isAuthenticated:!1,error:e})}))}}))})),this._pending.updateAuthStatePromise=u,e.abrupt("return",a(u));case 14:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"subscribe",value:function(e){this._sdk.emitter.on(b,e)}},{key:"unsubscribe",value:function(e){this._sdk.emitter.off(b,e)}}]),e}()},2397:function(e,t,n){"use strict";n.d(t,{W:function(){return ye}});var r=n(885),o=n(2982),i=n(5861),a=n(5671),u=n(3144),c=n(4942),s=n(7757),f=n.n(s);Promise.resolve(!1);var l=Promise.resolve(!0),p=Promise.resolve();function h(e,t){return e||(e=0),new Promise((function(n){return setTimeout((function(){return n(t)}),e)}))}function d(){return Math.random().toString(36).substring(2)}var v=0,y=0;function g(){var e=(new Date).getTime();return e===v?1e3*e+ ++y:(v=e,y=0,1e3*e)}var m={create:function(e){var t={messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(e){t.messagesCallback&&t.messagesCallback(e.data)},t},close:function(e){e.bc.close(),e.subFns=[]},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){try{return e.bc.postMessage(t,!1),p}catch(e){return Promise.reject(e)}},canBeUsed:function(){if("undefined"==typeof window)return!1;if("function"==typeof BroadcastChannel){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}return!1},type:"native",averageResponseTime:function(){return 150},microSeconds:g},b=function(){function e(e){this.ttl=e,this.map=new Map,this._to=!1}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.add=function(e){var t=this;this.map.set(e,k()),this._to||(this._to=!0,setTimeout((function(){t._to=!1,function(e){for(var t=k()-e.ttl,n=e.map[Symbol.iterator]();;){var r=n.next().value;if(!r)return;var o=r[0];if(!(r[1]<t))return;e.map.delete(o)}}(t)}),0))},e.prototype.clear=function(){this.map.clear()},e}();function k(){return(new Date).getTime()}function w(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=JSON.parse(JSON.stringify(e));return void 0===t.webWorkerSupport&&(t.webWorkerSupport=!0),t.idb||(t.idb={}),t.idb.ttl||(t.idb.ttl=45e3),t.idb.fallbackInterval||(t.idb.fallbackInterval=150),e.idb&&"function"==typeof e.idb.onclose&&(t.idb.onclose=e.idb.onclose),t.localstorage||(t.localstorage={}),t.localstorage.removeTimeout||(t.localstorage.removeTimeout=6e4),e.methods&&(t.methods=e.methods),t.node||(t.node={}),t.node.ttl||(t.node.ttl=12e4),t.node.maxParallelWrites||(t.node.maxParallelWrites=2048),void 0===t.node.useFastPath&&(t.node.useFastPath=!0),t}var O="messages",T={durability:"relaxed"};function E(){if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof window){if(void 0!==window.mozIndexedDB)return window.mozIndexedDB;if(void 0!==window.webkitIndexedDB)return window.webkitIndexedDB;if(void 0!==window.msIndexedDB)return window.msIndexedDB}return!1}function Z(e){e.commit&&e.commit()}function S(e){e.closed||x(e).then((function(){return h(e.options.idb.fallbackInterval)})).then((function(){return S(e)}))}function x(e){return e.closed?p:e.messagesCallback?function(e,t){var n=e.transaction(O,"readonly",T),r=n.objectStore(O),o=[],i=IDBKeyRange.bound(t+1,1/0);if(r.getAll){var a=r.getAll(i);return new Promise((function(e,t){a.onerror=function(e){return t(e)},a.onsuccess=function(t){e(t.target.result)}}))}return new Promise((function(e,a){var u=function(){try{return i=IDBKeyRange.bound(t+1,1/0),r.openCursor(i)}catch(e){return r.openCursor()}}();u.onerror=function(e){return a(e)},u.onsuccess=function(r){var i=r.target.result;i?i.value.id<t+1?i.continue(t+1):(o.push(i.value),i.continue()):(Z(n),e(o))}}))}(e.db,e.lastCursorId).then((function(t){var n=t.filter((function(e){return!!e})).map((function(t){return t.id>e.lastCursorId&&(e.lastCursorId=t.id),t})).filter((function(t){return function(e,t){return!(e.uuid===t.uuid||t.eMIs.has(e.id)||e.data.time<t.messagesCallbackTime)}(t,e)})).sort((function(e,t){return e.time-t.time}));return n.forEach((function(t){e.messagesCallback&&(e.eMIs.add(t.id),e.messagesCallback(t.data))})),p})):p}var A={create:function(e,t){return t=w(t),function(e){var t="pubkey.broadcast-channel-0-"+e,n=E().open(t);return n.onupgradeneeded=function(e){e.target.result.createObjectStore(O,{keyPath:"id",autoIncrement:!0})},new Promise((function(e,t){n.onerror=function(e){return t(e)},n.onsuccess=function(){e(n.result)}}))}(e).then((function(n){var r={closed:!1,lastCursorId:0,channelName:e,options:t,uuid:d(),eMIs:new b(2*t.idb.ttl),writeBlockPromise:p,messagesCallback:null,readQueuePromises:[],db:n};return n.onclose=function(){r.closed=!0,t.idb.onclose&&t.idb.onclose()},S(r),r}))},close:function(e){e.closed=!0,e.db.close()},onMessage:function(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t,x(e)},postMessage:function(e,t){return e.writeBlockPromise=e.writeBlockPromise.then((function(){return function(e,t,n){var r={uuid:t,time:(new Date).getTime(),data:n},o=e.transaction([O],"readwrite",T);return new Promise((function(e,t){o.oncomplete=function(){return e()},o.onerror=function(e){return t(e)},o.objectStore(O).add(r),Z(o)}))}(e.db,e.uuid,t)})).then((function(){var t,n;0===(0,10,Math.floor(11*Math.random()+0))&&(t=e.db,n=e.options.idb.ttl,function(e,t){var n=(new Date).getTime()-t,r=e.transaction(O,"readonly",T),o=r.objectStore(O),i=[];return new Promise((function(e){o.openCursor().onsuccess=function(t){var o=t.target.result;if(o){var a=o.value;if(!(a.time<n))return Z(r),void e(i);i.push(a),o.continue()}else e(i)}}))}(t,n).then((function(e){return function(e,t){var n=e.transaction([O],"readwrite",T).objectStore(O);return Promise.all(t.map((function(e){var t=n.delete(e);return new Promise((function(e){t.onsuccess=function(){return e()}}))})))}(t,e.map((function(e){return e.id})))})))})),e.writeBlockPromise},canBeUsed:function(){return!!E()},type:"idb",averageResponseTime:function(e){return 2*e.idb.fallbackInterval},microSeconds:g};function P(){var e;if("undefined"==typeof window)return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch(e){}return e}function R(e){return"pubkey.broadcastChannel-"+e}function _(){var e=P();if(!e)return!1;try{var t="__broadcastchannel_check";e.setItem(t,"works"),e.removeItem(t)}catch(e){return!1}return!0}var j={create:function(e,t){if(t=w(t),!_())throw new Error("BroadcastChannel: localstorage cannot be used");var n=d(),r=new b(t.localstorage.removeTimeout),o={channelName:e,uuid:n,eMIs:r};return o.listener=function(e,t){var i=R(e),a=function(e){var t;e.key===i&&(t=JSON.parse(e.newValue),o.messagesCallback&&t.uuid!==n&&t.token&&!r.has(t.token)&&(t.data.time&&t.data.time<o.messagesCallbackTime||(r.add(t.token),o.messagesCallback(t.data))))};return window.addEventListener("storage",a),a}(e),o},close:function(e){var t;t=e.listener,window.removeEventListener("storage",t)},onMessage:function(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t},postMessage:function(e,t){return new Promise((function(n){h().then((function(){var r=R(e.channelName),o={token:d(),time:(new Date).getTime(),data:t,uuid:e.uuid},i=JSON.stringify(o);P().setItem(r,i);var a=document.createEvent("Event");a.initEvent("storage",!0,!0),a.key=r,a.newValue=i,window.dispatchEvent(a),n()}))}))},canBeUsed:_,type:"localstorage",averageResponseTime:function(){var e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?240:120},microSeconds:g},C=g,D=new Set,I={create:function(e){var t={name:e,messagesCallback:null};return D.add(t),t},close:function(e){D.delete(e)},onMessage:function(e,t){e.messagesCallback=t},postMessage:function(e,t){return new Promise((function(n){return setTimeout((function(){Array.from(D).filter((function(t){return t.name===e.name})).filter((function(t){return t!==e})).filter((function(e){return!!e.messagesCallback})).forEach((function(e){return e.messagesCallback(t)})),n()}),5)}))},canBeUsed:function(){return!0},type:"simulate",averageResponseTime:function(){return 5},microSeconds:C},N=[m,A,j],M=new Set,U=0,L=function(e,t){var n,r,o;this.id=U++,M.add(this),this.name=e,this.options=w(t),this.method=function(e){var t=[].concat(e.methods,N).filter(Boolean);if(e.type){if("simulate"===e.type)return I;var n=t.find((function(t){return t.type===e.type}));if(n)return n;throw new Error("method-type "+e.type+" not found")}e.webWorkerSupport||(t=t.filter((function(e){return"idb"!==e.type})));var r=t.find((function(e){return e.canBeUsed()}));if(r)return r;throw new Error("No useable method found in "+JSON.stringify(N.map((function(e){return e.type}))))}(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,(o=r=(n=this).method.create(n.name,n.options))&&"function"==typeof o.then?(n._prepP=r,r.then((function(e){n._state=e}))):n._state=r};function F(e,t,n){var r={time:e.method.microSeconds(),type:t,data:n};return(e._prepP?e._prepP:p).then((function(){var t=e.method.postMessage(e._state,r);return e._uMP.add(t),t.catch().then((function(){return e._uMP.delete(t)})),t}))}function B(e){return e._addEL.message.length>0||e._addEL.internal.length>0}function H(e,t,n){e._addEL[t].push(n),function(e){if(!e._iL&&B(e)){var t=function(t){e._addEL[t.type].forEach((function(e){var n=e.time-1e5;t.time>=n&&e.fn(t.data)}))},n=e.method.microSeconds();e._prepP?e._prepP.then((function(){e._iL=!0,e.method.onMessage(e._state,t,n)})):(e._iL=!0,e.method.onMessage(e._state,t,n))}}(e)}function K(e,t,n){e._addEL[t]=e._addEL[t].filter((function(e){return e!==n})),function(e){if(e._iL&&!B(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}(e)}L._pubkey=!0,L.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return F(this,"message",e)},postInternal:function(e){return F(this,"internal",e)},set onmessage(e){var t={time:this.method.microSeconds(),fn:e};K(this,"message",this._onML),e&&"function"==typeof e?(this._onML=t,H(this,"message",t)):this._onML=null},addEventListener:function(e,t){H(this,e,{time:this.method.microSeconds(),fn:t})},removeEventListener:function(e,t){K(this,e,this._addEL[e].find((function(e){return e.fn===t})))},close:function(){var e=this;if(!this.closed){M.delete(this),this.closed=!0;var t=this._prepP?this._prepP:p;return this._onML=null,this._addEL.message=[],t.then((function(){return Promise.all(Array.from(e._uMP))})).then((function(){return Promise.all(e._befC.map((function(e){return e()})))})).then((function(){return e.method.close(e._state)}))}},get type(){return this.method.type},get isClosed(){return this.closed}};var G=n(5643),q=n.n(G),V={add:function(e){if("function"==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope);else{if("function"!=typeof window.addEventListener)return;window.addEventListener("beforeunload",(function(){e()}),!0),window.addEventListener("unload",(function(){e()}),!0)}}},Y=n(199),W=n.n(Y),Q=q()?W():V,z=new Set,X=!1;function J(){var e=[];return z.forEach((function(t){e.push(t()),z.delete(t)})),Promise.all(e)}var $=function(e,t){var n=this;this.broadcastChannel=e,this._options=t,this.isLeader=!1,this.hasLeader=!1,this.isDead=!1,this.token=d(),this._aplQ=p,this._aplQC=0,this._unl=[],this._lstns=[],this._dpL=function(){},this._dpLC=!1;var r=function(e){"leader"===e.context&&("death"===e.action&&(n.hasLeader=!1),"tell"===e.action&&(n.hasLeader=!0))};this.broadcastChannel.addEventListener("internal",r),this._lstns.push(r)};function ee(e,t){var n={context:"leader",action:t,token:e.token};return e.broadcastChannel.postInternal(n)}function te(e,t){if(e._leaderElector)throw new Error("BroadcastChannel already has a leader-elector");t=function(e,t){return e||(e={}),(e=JSON.parse(JSON.stringify(e))).fallbackInterval||(e.fallbackInterval=3e3),e.responseTime||(e.responseTime=t.method.averageResponseTime(t.options)),e}(t,e);var n=new $(e,t);return e._befC.push((function(){return n.die()})),e._leaderElector=n,n}$.prototype={applyOnce:function(e){var t=this;if(this.isLeader)return h(0,!0);if(this.isDead)return h(0,!1);if(this._aplQC>1)return this._aplQ;var n=function(){if(t.isLeader)return l;var n,r=!1,o=new Promise((function(e){n=function(){r=!0,e()}})),i=[],a=function(e){"leader"===e.context&&e.token!=t.token&&(i.push(e),"apply"===e.action&&e.token>t.token&&n(),"tell"===e.action&&(n(),t.hasLeader=!0))};t.broadcastChannel.addEventListener("internal",a);var u=e?4*t._options.responseTime:t._options.responseTime;return ee(t,"apply").then((function(){return Promise.race([h(u),o.then((function(){return Promise.reject(new Error)}))])})).then((function(){return ee(t,"apply")})).then((function(){return Promise.race([h(u),o.then((function(){return Promise.reject(new Error)}))])})).catch((function(){})).then((function(){return t.broadcastChannel.removeEventListener("internal",a),!r&&function(e){e.isLeader=!0,e.hasLeader=!0;var t=function(e){if(X||(X=!0,Q.add(J)),"function"!=typeof e)throw new Error("Listener is no function");return z.add(e),{remove:function(){return z.delete(e)},run:function(){return z.delete(e),e()}}}((function(){return e.die()}));e._unl.push(t);var n=function(t){"leader"===t.context&&"apply"===t.action&&ee(e,"tell"),"leader"!==t.context||"tell"!==t.action||e._dpLC||(e._dpLC=!0,e._dpL(),ee(e,"tell"))};return e.broadcastChannel.addEventListener("internal",n),e._lstns.push(n),ee(e,"tell")}(t).then((function(){return!0}))}))};return this._aplQC=this._aplQC+1,this._aplQ=this._aplQ.then((function(){return n()})).then((function(){t._aplQC=t._aplQC-1})),this._aplQ.then((function(){return t.isLeader}))},awaitLeadership:function(){return this._aLP||(this._aLP=(e=this).isLeader?p:new Promise((function(t){var n=!1;function r(){n||(n=!0,e.broadcastChannel.removeEventListener("internal",o),t(!0))}e.applyOnce().then((function(){e.isLeader&&r()})),function t(){return h(e._options.fallbackInterval).then((function(){if(!e.isDead&&!n)return e.isLeader?void r():e.applyOnce(!0).then((function(){e.isLeader?r():t()}))}))}();var o=function(t){"leader"===t.context&&"death"===t.action&&(e.hasLeader=!1,e.applyOnce().then((function(){e.isLeader&&r()})))};e.broadcastChannel.addEventListener("internal",o),e._lstns.push(o)}))),this._aLP;var e},set onduplicate(e){this._dpL=e},die:function(){var e=this;return this._lstns.forEach((function(t){return e.broadcastChannel.removeEventListener("internal",t)})),this._lstns=[],this._unl.forEach((function(e){return e.remove()})),this._unl=[],this.isLeader&&(this.hasLeader=!1,this.isLeader=!1),this.isDead=!0,ee(this,"death")}};var ne=n(415),re=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.Z)(this,e),(0,c.Z)(this,"options",void 0),(0,c.Z)(this,"channel",void 0),(0,c.Z)(this,"elector",void 0),(0,c.Z)(this,"started",!1),this.options=t,this.onLeaderDuplicate=this.onLeaderDuplicate.bind(this),this.onLeader=this.onLeader.bind(this)}var t,n,r;return(0,u.Z)(e,[{key:"onLeaderDuplicate",value:function(){}},{key:"onLeader",value:(r=(0,i.Z)(f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=(n=this.options).onLeader)||void 0===t?void 0:t.call(n);case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"isLeader",value:function(){var e;return!(null===(e=this.elector)||void 0===e||!e.isLeader)}},{key:"hasLeader",value:function(){var e;return!(null===(e=this.elector)||void 0===e||!e.hasLeader)}},{key:"start",value:(n=(0,i.Z)(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.stop();case 2:this.canStart()&&(t=this.options.electionChannelName,this.channel=new L(t),this.elector=te(this.channel),this.elector.onduplicate=this.onLeaderDuplicate,this.elector.awaitLeadership().then(this.onLeader),this.started=!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"stop",value:(t=(0,i.Z)(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.started){e.next=11;break}if(!this.elector){e.next=5;break}return e.next=4,this.elector.die();case 4:this.elector=void 0;case 5:if(!this.channel){e.next=10;break}return this.channel.postInternal=function(){return Promise.resolve()},e.next=9,this.channel.close();case 9:this.channel=void 0;case 10:this.started=!1;case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"requiresLeadership",value:function(){return!1}},{key:"isStarted",value:function(){return this.started}},{key:"canStart",value:function(){return(0,ne.isBrowser)()}}]),e}(),oe=n(9123),ie=n(7088),ae=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.Z)(this,e),(0,c.Z)(this,"tokenManager",void 0),(0,c.Z)(this,"options",void 0),(0,c.Z)(this,"renewTimeQueue",void 0),(0,c.Z)(this,"started",!1),this.tokenManager=t,this.options=n,this.renewTimeQueue=[],this.onTokenExpiredHandler=this.onTokenExpiredHandler.bind(this)}var t,n;return(0,u.Z)(e,[{key:"shouldThrottleRenew",value:function(){var e=!1;if(this.renewTimeQueue.push(Date.now()),this.renewTimeQueue.length>=10){var t=this.renewTimeQueue.shift();e=this.renewTimeQueue[this.renewTimeQueue.length-1]-t<3e4}return e}},{key:"requiresLeadership",value:function(){return!!this.options.syncStorage&&(0,ne.isBrowser)()}},{key:"onTokenExpiredHandler",value:function(e){if(this.options.autoRenew)if(this.shouldThrottleRenew()){var t=new oe.Z("Too many token renew requests");this.tokenManager.emitError(t)}else this.tokenManager.renew(e).catch((function(){}));else this.options.autoRemove&&this.tokenManager.remove(e)}},{key:"canStart",value:function(){return!!this.options.autoRenew||!!this.options.autoRemove}},{key:"start",value:(n=(0,i.Z)(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.canStart()){e.next=5;break}return e.next=3,this.stop();case 3:this.tokenManager.on(ie.$Y,this.onTokenExpiredHandler),this.started=!0;case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"stop",value:(t=(0,i.Z)(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.started&&(this.tokenManager.off(ie.$Y,this.onTokenExpiredHandler),this.renewTimeQueue=[],this.started=!1);case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"isStarted",value:function(){return this.started}}]),e}(),ue=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.Z)(this,e),(0,c.Z)(this,"tokenManager",void 0),(0,c.Z)(this,"options",void 0),(0,c.Z)(this,"channel",void 0),(0,c.Z)(this,"started",!1),(0,c.Z)(this,"enablePostMessage",!0),this.tokenManager=t,this.options=n,this.onTokenAddedHandler=this.onTokenAddedHandler.bind(this),this.onTokenRemovedHandler=this.onTokenRemovedHandler.bind(this),this.onTokenRenewedHandler=this.onTokenRenewedHandler.bind(this),this.onSetStorageHandler=this.onSetStorageHandler.bind(this),this.onSyncMessageHandler=this.onSyncMessageHandler.bind(this)}var t,n;return(0,u.Z)(e,[{key:"requiresLeadership",value:function(){return!1}},{key:"isStarted",value:function(){return this.started}},{key:"canStart",value:function(){return!!this.options.syncStorage&&(0,ne.isBrowser)()}},{key:"start",value:(n=(0,i.Z)(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.canStart()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.stop();case 4:t=this.options.syncChannelName,e.prev=5,this.channel=new L(t),e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(5),new oe.Z("SyncStorageService is not supported in current browser.");case 12:this.tokenManager.on(ie.O3,this.onTokenAddedHandler),this.tokenManager.on(ie.FT,this.onTokenRemovedHandler),this.tokenManager.on(ie.E,this.onTokenRenewedHandler),this.tokenManager.on(ie.zr,this.onSetStorageHandler),this.channel.addEventListener("message",this.onSyncMessageHandler),this.started=!0;case 18:case"end":return e.stop()}}),e,this,[[5,9]])}))),function(){return n.apply(this,arguments)})},{key:"stop",value:(t=(0,i.Z)(f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.started){e.next=10;break}return this.tokenManager.off(ie.O3,this.onTokenAddedHandler),this.tokenManager.off(ie.FT,this.onTokenRemovedHandler),this.tokenManager.off(ie.E,this.onTokenRenewedHandler),this.tokenManager.off(ie.zr,this.onSetStorageHandler),null===(t=this.channel)||void 0===t||t.removeEventListener("message",this.onSyncMessageHandler),e.next=8,null===(n=this.channel)||void 0===n?void 0:n.close();case 8:this.channel=void 0,this.started=!1;case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"onTokenAddedHandler",value:function(e,t){var n;this.enablePostMessage&&(null===(n=this.channel)||void 0===n||n.postMessage({type:ie.O3,key:e,token:t}))}},{key:"onTokenRemovedHandler",value:function(e,t){var n;this.enablePostMessage&&(null===(n=this.channel)||void 0===n||n.postMessage({type:ie.FT,key:e,token:t}))}},{key:"onTokenRenewedHandler",value:function(e,t,n){var r;this.enablePostMessage&&(null===(r=this.channel)||void 0===r||r.postMessage({type:ie.E,key:e,token:t,oldToken:n}))}},{key:"onSetStorageHandler",value:function(e){var t;null===(t=this.channel)||void 0===t||t.postMessage({type:ie.zr,storage:e})}},{key:"onSyncMessageHandler",value:function(e){switch(this.enablePostMessage=!1,e.type){case ie.zr:this.tokenManager.getStorage().setStorage(e.storage);break;case ie.O3:this.tokenManager.emitAdded(e.key,e.token),this.tokenManager.setExpireEventTimeout(e.key,e.token);break;case ie.FT:this.tokenManager.clearExpireEventTimeout(e.key),this.tokenManager.emitRemoved(e.key,e.token);break;case ie.E:this.tokenManager.emitRenewed(e.key,e.token,e.oldToken)}this.enablePostMessage=!0}}]),e}(),ce=n(3193);function se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(Object(n),!0).forEach((function(t){(0,c.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function le(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return pe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pe(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var he="autoRenew",de="syncStorage",ve="leaderElection",ye=function(){function e(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.Z)(this,e),(0,c.Z)(this,"sdk",void 0),(0,c.Z)(this,"options",void 0),(0,c.Z)(this,"services",void 0),(0,c.Z)(this,"started",void 0),this.sdk=t,this.onLeader=this.onLeader.bind(this);var o=t.tokenManager.getOptions(),i=o.autoRenew,u=o.autoRemove,s=o.syncStorage;r.electionChannelName=r.electionChannelName||r.broadcastChannelName,this.options=Object.assign({},e.defaultOptions,{autoRenew:i,autoRemove:u,syncStorage:s},{electionChannelName:"".concat(t.options.clientId,"-election"),syncChannelName:"".concat(t.options.clientId,"-sync")},(0,ce.YY)(r)),this.started=!1,this.services=new Map,e.knownServices.forEach((function(e){var t=n.createService(e);t&&n.services.set(e,t)}))}var t,n,s,l,p;return(0,u.Z)(e,[{key:"onLeader",value:(p=(0,i.Z)(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.started){e.next=3;break}return e.next=3,this.startServices();case 3:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"isLeader",value:function(){var e;return null===(e=this.getService(ve))||void 0===e?void 0:e.isLeader()}},{key:"isLeaderRequired",value:function(){return(0,o.Z)(this.services.values()).some((function(e){return e.canStart()&&e.requiresLeadership()}))}},{key:"start",value:(l=(0,i.Z)(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.started){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.startServices();case 4:this.started=!0;case 5:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"stop",value:(s=(0,i.Z)(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.stopServices();case 2:this.started=!1;case 3:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getService",value:function(e){return this.services.get(e)}},{key:"startServices",value:(n=(0,i.Z)(f().mark((function e(){var t,n,o,i,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=le(this.services.entries()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=10;break}if(o=(0,r.Z)(n.value,2),i=o[0],a=o[1],!this.canStartService(i,a)){e.next=8;break}return e.next=8,a.start();case 8:e.next=3;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(1),t.e(e.t0);case 15:return e.prev=15,t.f(),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[1,12,15,18]])}))),function(){return n.apply(this,arguments)})},{key:"stopServices",value:(t=(0,i.Z)(f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=le(this.services.values()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=n.value,e.next=7,r.stop();case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))),function(){return t.apply(this,arguments)})},{key:"canStartService",value:function(e,t){var n=t.canStart()&&!t.isStarted();return e===ve?n&&(n=this.isLeaderRequired()):t.requiresLeadership()&&n&&(n=this.isLeader()),n}},{key:"createService",value:function(e){var t,n=this.sdk.tokenManager;switch(e){case ve:t=new re(fe(fe({},this.options),{},{onLea