UNPKG

oidc-client

Version:

OpenID Connect (OIDC) & OAuth2 client library

1 lines 141 kB
!function e(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n=r();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function t(){return e.default}:function t(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=22)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o={debug:function e(){},info:function e(){},warn:function e(){},error:function e(){}},i=void 0,s=void 0;(t.Log=function(){function e(){!function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.reset=function e(){s=3,i=o},e.debug=function e(){if(s>=4){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];i.debug.apply(i,Array.from(r))}},e.info=function e(){if(s>=3){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];i.info.apply(i,Array.from(r))}},e.warn=function e(){if(s>=2){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];i.warn.apply(i,Array.from(r))}},e.error=function e(){if(s>=1){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];i.error.apply(i,Array.from(r))}},n(e,null,[{key:"NONE",get:function e(){return 0}},{key:"ERROR",get:function e(){return 1}},{key:"WARN",get:function e(){return 2}},{key:"INFO",get:function e(){return 3}},{key:"DEBUG",get:function e(){return 4}},{key:"level",get:function e(){return s},set:function e(t){if(!(0<=t&&t<=4))throw new Error("Invalid log level");s=t}},{key:"logger",get:function e(){return i},set:function e(t){if(!t.debug&&t.info&&(t.debug=t.info),!(t.debug&&t.info&&t.warn&&t.error))throw new Error("Invalid logger");i=t}}]),e}()).reset()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o={setInterval:function(e){function t(t,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){return setInterval(e,t)}),clearInterval:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return clearInterval(e)})},i=!1,s=null;t.Global=function(){function e(){!function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)}return e._testing=function e(){i=!0},e.setXMLHttpRequest=function e(t){s=t},n(e,null,[{key:"location",get:function e(){if(!i)return location}},{key:"localStorage",get:function e(){if(!i&&"undefined"!=typeof window)return localStorage}},{key:"sessionStorage",get:function e(){if(!i&&"undefined"!=typeof window)return sessionStorage}},{key:"XMLHttpRequest",get:function e(){if(!i&&"undefined"!=typeof window)return s||XMLHttpRequest}},{key:"timer",get:function e(){if(!i)return o}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataService=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(7);t.MetadataService=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.JsonService;if(function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw o.Log.error("MetadataService: No settings passed to MetadataService"),new Error("settings");this._settings=t,this._jsonService=new r(["application/jwk-set+json"])}return e.prototype.getMetadata=function e(){var t=this;return this._settings.metadata?(o.Log.debug("MetadataService.getMetadata: Returning metadata from settings"),Promise.resolve(this._settings.metadata)):this.metadataUrl?(o.Log.debug("MetadataService.getMetadata: getting metadata from",this.metadataUrl),this._jsonService.getJson(this.metadataUrl).then(function(e){return o.Log.debug("MetadataService.getMetadata: json received"),t._settings.metadata=e,e})):(o.Log.error("MetadataService.getMetadata: No authority or metadataUrl configured on settings"),Promise.reject(new Error("No authority or metadataUrl configured on settings")))},e.prototype.getIssuer=function e(){return this._getMetadataProperty("issuer")},e.prototype.getAuthorizationEndpoint=function e(){return this._getMetadataProperty("authorization_endpoint")},e.prototype.getUserInfoEndpoint=function e(){return this._getMetadataProperty("userinfo_endpoint")},e.prototype.getTokenEndpoint=function e(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._getMetadataProperty("token_endpoint",t)},e.prototype.getCheckSessionIframe=function e(){return this._getMetadataProperty("check_session_iframe",!0)},e.prototype.getEndSessionEndpoint=function e(){return this._getMetadataProperty("end_session_endpoint",!0)},e.prototype.getRevocationEndpoint=function e(){return this._getMetadataProperty("revocation_endpoint",!0)},e.prototype.getKeysEndpoint=function e(){return this._getMetadataProperty("jwks_uri",!0)},e.prototype._getMetadataProperty=function e(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o.Log.debug("MetadataService.getMetadataProperty for: "+t),this.getMetadata().then(function(e){if(o.Log.debug("MetadataService.getMetadataProperty: metadata recieved"),void 0===e[t]){if(!0===r)return void o.Log.warn("MetadataService.getMetadataProperty: Metadata does not contain optional property "+t);throw o.Log.error("MetadataService.getMetadataProperty: Metadata does not contain property "+t),new Error("Metadata does not contain property "+t)}return e[t]})},e.prototype.getSigningKeys=function e(){var t=this;return this._settings.signingKeys?(o.Log.debug("MetadataService.getSigningKeys: Returning signingKeys from settings"),Promise.resolve(this._settings.signingKeys)):this._getMetadataProperty("jwks_uri").then(function(e){return o.Log.debug("MetadataService.getSigningKeys: jwks_uri received",e),t._jsonService.getJson(e).then(function(e){if(o.Log.debug("MetadataService.getSigningKeys: key set received",e),!e.keys)throw o.Log.error("MetadataService.getSigningKeys: Missing keys on keyset"),new Error("Missing keys on keyset");return t._settings.signingKeys=e.keys,t._settings.signingKeys})})},n(e,[{key:"metadataUrl",get:function e(){return this._metadataUrl||(this._settings.metadataUrl?this._metadataUrl=this._settings.metadataUrl:(this._metadataUrl=this._settings.authority,this._metadataUrl&&this._metadataUrl.indexOf(".well-known/openid-configuration")<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=".well-known/openid-configuration"))),this._metadataUrl}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UrlUtility=void 0;var n=r(0),o=r(1);t.UrlUtility=function(){function e(){!function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.addQueryParam=function e(t,r,n){return t.indexOf("?")<0&&(t+="?"),"?"!==t[t.length-1]&&(t+="&"),t+=encodeURIComponent(r),t+="=",t+=encodeURIComponent(n)},e.parseUrlFragment=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.Global;"string"!=typeof t&&(t=i.location.href);var s=t.lastIndexOf(r);s>=0&&(t=t.substr(s+1)),"?"===r&&(s=t.indexOf("#"))>=0&&(t=t.substr(0,s));for(var a,u={},c=/([^&=]+)=([^&]*)/g,d=0;a=c.exec(t);)if(u[decodeURIComponent(a[1])]=decodeURIComponent(a[2]),d++>50)return n.Log.error("UrlUtility.parseUrlFragment: response exceeded expected number of parameters",t),{error:"Response exceeded expected number of parameters"};for(var l in u)return u;return{}},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JoseUtil=void 0;var n=r(25),o=function i(e){return e&&e.__esModule?e:{default:e}}(r(30));t.JoseUtil=(0,o.default)({jws:n.jws,KeyUtil:n.KeyUtil,X509:n.X509,crypto:n.crypto,hextob64u:n.hextob64u,b64tohex:n.b64tohex,AllowedSigningAlgs:n.AllowedSigningAlgs})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OidcClientSettings=void 0;var n="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},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),s=r(6),a=r(23),u=r(2);var c="id_token",d="openid",l=900,p=300;t.OidcClientSettings=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.authority,o=t.metadataUrl,i=t.metadata,f=t.signingKeys,h=t.client_id,g=t.client_secret,_=t.response_type,v=void 0===_?c:_,y=t.scope,m=void 0===y?d:y,b=t.redirect_uri,k=t.post_logout_redirect_uri,S=t.prompt,w=t.display,T=t.max_age,E=t.ui_locales,L=t.acr_values,P=t.resource,R=t.response_mode,U=t.filterProtocolClaims,C=void 0===U||U,M=t.loadUserInfo,I=void 0===M||M,O=t.staleStateAge,x=void 0===O?l:O,j=t.clockSkew,A=void 0===j?p:j,N=t.userInfoJwtIssuer,q=void 0===N?"OP":N,J=t.stateStore,F=void 0===J?new s.WebStorageStateStore:J,B=t.ResponseValidatorCtor,V=void 0===B?a.ResponseValidator:B,W=t.MetadataServiceCtor,D=void 0===W?u.MetadataService:W,H=t.extraQueryParams,z=void 0===H?{}:H,K=t.extraTokenParams,Q=void 0===K?{}:K;!function X(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._authority=r,this._metadataUrl=o,this._metadata=i,this._signingKeys=f,this._client_id=h,this._client_secret=g,this._response_type=v,this._scope=m,this._redirect_uri=b,this._post_logout_redirect_uri=k,this._prompt=S,this._display=w,this._max_age=T,this._ui_locales=E,this._acr_values=L,this._resource=P,this._response_mode=R,this._filterProtocolClaims=!!C,this._loadUserInfo=!!I,this._staleStateAge=x,this._clockSkew=A,this._userInfoJwtIssuer=q,this._stateStore=F,this._validator=new V(this),this._metadataService=new D(this),this._extraQueryParams="object"===(void 0===z?"undefined":n(z))?z:{},this._extraTokenParams="object"===(void 0===Q?"undefined":n(Q))?Q:{}}return o(e,[{key:"client_id",get:function e(){return this._client_id},set:function e(t){if(this._client_id)throw i.Log.error("OidcClientSettings.set_client_id: client_id has already been assigned."),new Error("client_id has already been assigned.");this._client_id=t}},{key:"client_secret",get:function e(){return this._client_secret}},{key:"response_type",get:function e(){return this._response_type}},{key:"scope",get:function e(){return this._scope}},{key:"redirect_uri",get:function e(){return this._redirect_uri}},{key:"post_logout_redirect_uri",get:function e(){return this._post_logout_redirect_uri}},{key:"prompt",get:function e(){return this._prompt}},{key:"display",get:function e(){return this._display}},{key:"max_age",get:function e(){return this._max_age}},{key:"ui_locales",get:function e(){return this._ui_locales}},{key:"acr_values",get:function e(){return this._acr_values}},{key:"resource",get:function e(){return this._resource}},{key:"response_mode",get:function e(){return this._response_mode}},{key:"authority",get:function e(){return this._authority},set:function e(t){if(this._authority)throw i.Log.error("OidcClientSettings.set_authority: authority has already been assigned."),new Error("authority has already been assigned.");this._authority=t}},{key:"metadataUrl",get:function e(){return this._metadataUrl||(this._metadataUrl=this.authority,this._metadataUrl&&this._metadataUrl.indexOf(".well-known/openid-configuration")<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=".well-known/openid-configuration")),this._metadataUrl}},{key:"metadata",get:function e(){return this._metadata},set:function e(t){this._metadata=t}},{key:"signingKeys",get:function e(){return this._signingKeys},set:function e(t){this._signingKeys=t}},{key:"filterProtocolClaims",get:function e(){return this._filterProtocolClaims}},{key:"loadUserInfo",get:function e(){return this._loadUserInfo}},{key:"staleStateAge",get:function e(){return this._staleStateAge}},{key:"clockSkew",get:function e(){return this._clockSkew}},{key:"userInfoJwtIssuer",get:function e(){return this._userInfoJwtIssuer}},{key:"stateStore",get:function e(){return this._stateStore}},{key:"validator",get:function e(){return this._validator}},{key:"metadataService",get:function e(){return this._metadataService}},{key:"extraQueryParams",get:function e(){return this._extraQueryParams},set:function e(t){"object"===(void 0===t?"undefined":n(t))?this._extraQueryParams=t:this._extraQueryParams={}}},{key:"extraTokenParams",get:function e(){return this._extraTokenParams},set:function e(t){"object"===(void 0===t?"undefined":n(t))?this._extraTokenParams=t:this._extraTokenParams={}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebStorageStateStore=void 0;var n=r(0),o=r(1);t.WebStorageStateStore=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.prefix,n=void 0===r?"oidc.":r,i=t.store,s=void 0===i?o.Global.localStorage:i;!function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._store=s,this._prefix=n}return e.prototype.set=function e(t,r){return n.Log.debug("WebStorageStateStore.set",t),t=this._prefix+t,this._store.setItem(t,r),Promise.resolve()},e.prototype.get=function e(t){n.Log.debug("WebStorageStateStore.get",t),t=this._prefix+t;var r=this._store.getItem(t);return Promise.resolve(r)},e.prototype.remove=function e(t){n.Log.debug("WebStorageStateStore.remove",t),t=this._prefix+t;var r=this._store.getItem(t);return this._store.removeItem(t),Promise.resolve(r)},e.prototype.getAllKeys=function e(){n.Log.debug("WebStorageStateStore.getAllKeys");for(var t=[],r=0;r<this._store.length;r++){var o=this._store.key(r);0===o.indexOf(this._prefix)&&t.push(o.substr(this._prefix.length))}return Promise.resolve(t)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonService=void 0;var n=r(0),o=r(1);t.JsonService=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.Global.XMLHttpRequest,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;!function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t&&Array.isArray(t)?this._contentTypes=t.slice():this._contentTypes=[],this._contentTypes.push("application/json"),n&&this._contentTypes.push("application/jwt"),this._XMLHttpRequest=r,this._jwtHandler=n}return e.prototype.getJson=function e(t,r){var o=this;if(!t)throw n.Log.error("JsonService.getJson: No url passed"),new Error("url");return n.Log.debug("JsonService.getJson, url: ",t),new Promise(function(e,i){var s=new o._XMLHttpRequest;s.open("GET",t);var a=o._contentTypes,u=o._jwtHandler;s.onload=function(){if(n.Log.debug("JsonService.getJson: HTTP response received, status",s.status),200===s.status){var r=s.getResponseHeader("Content-Type");if(r){var o=a.find(function(e){if(r.startsWith(e))return!0});if("application/jwt"==o)return void u(s).then(e,i);if(o)try{return void e(JSON.parse(s.responseText))}catch(e){return n.Log.error("JsonService.getJson: Error parsing JSON response",e.message),void i(e)}}i(Error("Invalid response Content-Type: "+r+", from URL: "+t))}else i(Error(s.statusText+" ("+s.status+")"))},s.onerror=function(){n.Log.error("JsonService.getJson: network error"),i(Error("Network Error"))},r&&(n.Log.debug("JsonService.getJson: token passed, setting Authorization header"),s.setRequestHeader("Authorization","Bearer "+r)),s.send()})},e.prototype.postForm=function e(t,r){var o=this;if(!t)throw n.Log.error("JsonService.postForm: No url passed"),new Error("url");return n.Log.debug("JsonService.postForm, url: ",t),new Promise(function(e,i){var s=new o._XMLHttpRequest;s.open("POST",t);var a=o._contentTypes;s.onload=function(){if(n.Log.debug("JsonService.postForm: HTTP response received, status",s.status),200!==s.status){if(400===s.status)if(o=s.getResponseHeader("Content-Type"))if(a.find(function(e){if(o.startsWith(e))return!0}))try{var r=JSON.parse(s.responseText);if(r&&r.error)return n.Log.error("JsonService.postForm: Error from server: ",r.error),void i(new Error(r.error))}catch(e){return n.Log.error("JsonService.postForm: Error parsing JSON response",e.message),void i(e)}i(Error(s.statusText+" ("+s.status+")"))}else{var o;if((o=s.getResponseHeader("Content-Type"))&&a.find(function(e){if(o.startsWith(e))return!0}))try{return void e(JSON.parse(s.responseText))}catch(e){return n.Log.error("JsonService.postForm: Error parsing JSON response",e.message),void i(e)}i(Error("Invalid response Content-Type: "+o+", from URL: "+t))}},s.onerror=function(){n.Log.error("JsonService.postForm: network error"),i(Error("Network Error"))};var u="";for(var c in r){var d=r[c];d&&(u.length>0&&(u+="&"),u+=encodeURIComponent(c),u+="=",u+=encodeURIComponent(d))}s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(u)})},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.State=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=function s(e){return e&&e.__esModule?e:{default:e}}(r(14));t.State=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.id,n=t.data,o=t.created,s=t.request_type;!function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=r||(0,i.default)(),this._data=n,this._created="number"==typeof o&&o>0?o:parseInt(Date.now()/1e3),this._request_type=s}return e.prototype.toStorageString=function e(){return o.Log.debug("State.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})},e.fromStorageString=function t(r){return o.Log.debug("State.fromStorageString"),new e(JSON.parse(r))},e.clearStaleState=function t(r,n){var i=Date.now()/1e3-n;return r.getAllKeys().then(function(t){o.Log.debug("State.clearStaleState: got keys",t);for(var n=[],s=function s(a){var c=t[a];u=r.get(c).then(function(t){var n=!1;if(t)try{var s=e.fromStorageString(t);o.Log.debug("State.clearStaleState: got item from key: ",c,s.created),s.created<=i&&(n=!0)}catch(e){o.Log.error("State.clearStaleState: Error parsing state for key",c,e.message),n=!0}else o.Log.debug("State.clearStaleState: no item in storage for key: ",c),n=!0;if(n)return o.Log.debug("State.clearStaleState: removed item for key: ",c),r.remove(c)}),n.push(u)},a=0;a<t.length;a++){var u;s(a)}return o.Log.debug("State.clearStaleState: waiting on promise count:",n.length),Promise.all(n)})},n(e,[{key:"id",get:function e(){return this._id}},{key:"data",get:function e(){return this._data}},{key:"created",get:function e(){return this._created}},{key:"request_type",get:function e(){return this._request_type}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OidcClient=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(5),s=r(11),a=r(12),u=r(34),c=r(35),d=r(36),l=r(13),p=r(8);t.OidcClient=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t instanceof i.OidcClientSettings?this._settings=t:this._settings=new i.OidcClientSettings(t)}return e.prototype.createSigninRequest=function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.response_type,i=r.scope,s=r.redirect_uri,u=r.data,c=r.state,d=r.prompt,l=r.display,p=r.max_age,f=r.ui_locales,h=r.id_token_hint,g=r.login_hint,_=r.acr_values,v=r.resource,y=r.request,m=r.request_uri,b=r.response_mode,k=r.extraQueryParams,S=r.extraTokenParams,w=r.request_type,T=r.skipUserInfo,E=arguments[1];o.Log.debug("OidcClient.createSigninRequest");var L=this._settings.client_id;n=n||this._settings.response_type,i=i||this._settings.scope,s=s||this._settings.redirect_uri,d=d||this._settings.prompt,l=l||this._settings.display,p=p||this._settings.max_age,f=f||this._settings.ui_locales,_=_||this._settings.acr_values,v=v||this._settings.resource,b=b||this._settings.response_mode,k=k||this._settings.extraQueryParams,S=S||this._settings.extraTokenParams;var P=this._settings.authority;return a.SigninRequest.isCode(n)&&"code"!==n?Promise.reject(new Error("OpenID Connect hybrid flow is not supported")):this._metadataService.getAuthorizationEndpoint().then(function(e){o.Log.debug("OidcClient.createSigninRequest: Received authorization endpoint",e);var r=new a.SigninRequest({url:e,client_id:L,redirect_uri:s,response_type:n,scope:i,data:u||c,authority:P,prompt:d,display:l,max_age:p,ui_locales:f,id_token_hint:h,login_hint:g,acr_values:_,resource:v,request:y,request_uri:m,extraQueryParams:k,extraTokenParams:S,request_type:w,response_mode:b,client_secret:t._settings.client_secret,skipUserInfo:T}),R=r.state;return(E=E||t._stateStore).set(R.id,R.toStorageString()).then(function(){return r})})},e.prototype.readSigninResponseState=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];o.Log.debug("OidcClient.readSigninResponseState");var i="query"===this._settings.response_mode||!this._settings.response_mode&&a.SigninRequest.isCode(this._settings.response_type)?"?":"#",s=new u.SigninResponse(t,i);return s.state?(r=r||this._stateStore,(n?r.remove.bind(r):r.get.bind(r))(s.state).then(function(e){if(!e)throw o.Log.error("OidcClient.readSigninResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:l.SigninState.fromStorageString(e),response:s}})):(o.Log.error("OidcClient.readSigninResponseState: No state in response"),Promise.reject(new Error("No state in response")))},e.prototype.processSigninResponse=function e(t,r){var n=this;return o.Log.debug("OidcClient.processSigninResponse"),this.readSigninResponseState(t,r,!0).then(function(e){var t=e.state,r=e.response;return o.Log.debug("OidcClient.processSigninResponse: Received state from storage; validating response"),n._validator.validateSigninResponse(t,r)})},e.prototype.createSignoutRequest=function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.id_token_hint,i=r.data,s=r.state,a=r.post_logout_redirect_uri,u=r.extraQueryParams,d=r.request_type,l=arguments[1];return o.Log.debug("OidcClient.createSignoutRequest"),a=a||this._settings.post_logout_redirect_uri,u=u||this._settings.extraQueryParams,this._metadataService.getEndSessionEndpoint().then(function(e){if(!e)throw o.Log.error("OidcClient.createSignoutRequest: No end session endpoint url returned"),new Error("no end session endpoint");o.Log.debug("OidcClient.createSignoutRequest: Received end session endpoint",e);var r=new c.SignoutRequest({url:e,id_token_hint:n,post_logout_redirect_uri:a,data:i||s,extraQueryParams:u,request_type:d}),p=r.state;return p&&(o.Log.debug("OidcClient.createSignoutRequest: Signout request has state to persist"),(l=l||t._stateStore).set(p.id,p.toStorageString())),r})},e.prototype.readSignoutResponseState=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];o.Log.debug("OidcClient.readSignoutResponseState");var i=new d.SignoutResponse(t);if(!i.state)return o.Log.debug("OidcClient.readSignoutResponseState: No state in response"),i.error?(o.Log.warn("OidcClient.readSignoutResponseState: Response was error: ",i.error),Promise.reject(new s.ErrorResponse(i))):Promise.resolve({undefined:void 0,response:i});var a=i.state;return r=r||this._stateStore,(n?r.remove.bind(r):r.get.bind(r))(a).then(function(e){if(!e)throw o.Log.error("OidcClient.readSignoutResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:p.State.fromStorageString(e),response:i}})},e.prototype.processSignoutResponse=function e(t,r){var n=this;return o.Log.debug("OidcClient.processSignoutResponse"),this.readSignoutResponseState(t,r,!0).then(function(e){var t=e.state,r=e.response;return t?(o.Log.debug("OidcClient.processSignoutResponse: Received state from storage; validating response"),n._validator.validateSignoutResponse(t,r)):(o.Log.debug("OidcClient.processSignoutResponse: No state from storage; skipping validating response"),r)})},e.prototype.clearStaleState=function e(t){return o.Log.debug("OidcClient.clearStaleState"),t=t||this._stateStore,p.State.clearStaleState(t,this.settings.staleStateAge)},n(e,[{key:"_stateStore",get:function e(){return this.settings.stateStore}},{key:"_validator",get:function e(){return this.settings.validator}},{key:"_metadataService",get:function e(){return this.settings.metadataService}},{key:"settings",get:function e(){return this._settings}},{key:"metadataService",get:function e(){return this._metadataService}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TokenClient=void 0;var n=r(7),o=r(2),i=r(0);t.TokenClient=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.JsonService,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.MetadataService;if(function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw i.Log.error("TokenClient.ctor: No settings passed"),new Error("settings");this._settings=t,this._jsonService=new r,this._metadataService=new s(this._settings)}return e.prototype.exchangeCode=function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(r=Object.assign({},r)).grant_type=r.grant_type||"authorization_code",r.client_id=r.client_id||this._settings.client_id,r.redirect_uri=r.redirect_uri||this._settings.redirect_uri,r.code?r.redirect_uri?r.code_verifier?r.client_id?this._metadataService.getTokenEndpoint(!1).then(function(e){return i.Log.debug("TokenClient.exchangeCode: Received token endpoint"),t._jsonService.postForm(e,r).then(function(e){return i.Log.debug("TokenClient.exchangeCode: response received"),e})}):(i.Log.error("TokenClient.exchangeCode: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(i.Log.error("TokenClient.exchangeCode: No code_verifier passed"),Promise.reject(new Error("A code_verifier is required"))):(i.Log.error("TokenClient.exchangeCode: No redirect_uri passed"),Promise.reject(new Error("A redirect_uri is required"))):(i.Log.error("TokenClient.exchangeCode: No code passed"),Promise.reject(new Error("A code is required")))},e.prototype.exchangeRefreshToken=function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(r=Object.assign({},r)).grant_type=r.grant_type||"refresh_token",r.client_id=r.client_id||this._settings.client_id,r.client_secret=r.client_secret||this._settings.client_secret,r.refresh_token?r.client_id?this._metadataService.getTokenEndpoint(!1).then(function(e){return i.Log.debug("TokenClient.exchangeRefreshToken: Received token endpoint"),t._jsonService.postForm(e,r).then(function(e){return i.Log.debug("TokenClient.exchangeRefreshToken: response received"),e})}):(i.Log.error("TokenClient.exchangeRefreshToken: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(i.Log.error("TokenClient.exchangeRefreshToken: No refresh_token passed"),Promise.reject(new Error("A refresh_token is required")))},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorResponse=void 0;var n=r(0);t.ErrorResponse=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.error,i=r.error_description,s=r.error_uri,a=r.state,u=r.session_state;if(function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),!o)throw n.Log.error("No error passed to ErrorResponse"),new Error("error");var d=function l(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,i||o));return d.name="ErrorResponse",d.error=o,d.error_description=i,d.error_uri=s,d.state=a,d.session_state=u,d}return function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t}(Error)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SigninRequest=void 0;var n=r(0),o=r(3),i=r(13);t.SigninRequest=function(){function e(t){var r=t.url,s=t.client_id,a=t.redirect_uri,u=t.response_type,c=t.scope,d=t.authority,l=t.data,p=t.prompt,f=t.display,h=t.max_age,g=t.ui_locales,_=t.id_token_hint,v=t.login_hint,y=t.acr_values,m=t.resource,b=t.response_mode,k=t.request,S=t.request_uri,w=t.extraQueryParams,T=t.request_type,E=t.client_secret,L=t.extraTokenParams,P=t.skipUserInfo;if(function R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw n.Log.error("SigninRequest.ctor: No url passed"),new Error("url");if(!s)throw n.Log.error("SigninRequest.ctor: No client_id passed"),new Error("client_id");if(!a)throw n.Log.error("SigninRequest.ctor: No redirect_uri passed"),new Error("redirect_uri");if(!u)throw n.Log.error("SigninRequest.ctor: No response_type passed"),new Error("response_type");if(!c)throw n.Log.error("SigninRequest.ctor: No scope passed"),new Error("scope");if(!d)throw n.Log.error("SigninRequest.ctor: No authority passed"),new Error("authority");var U=e.isOidc(u),C=e.isCode(u);b||(b=e.isCode(u)?"query":null),this.state=new i.SigninState({nonce:U,data:l,client_id:s,authority:d,redirect_uri:a,code_verifier:C,request_type:T,response_mode:b,client_secret:E,scope:c,extraTokenParams:L,skipUserInfo:P}),r=o.UrlUtility.addQueryParam(r,"client_id",s),r=o.UrlUtility.addQueryParam(r,"redirect_uri",a),r=o.UrlUtility.addQueryParam(r,"response_type",u),r=o.UrlUtility.addQueryParam(r,"scope",c),r=o.UrlUtility.addQueryParam(r,"state",this.state.id),U&&(r=o.UrlUtility.addQueryParam(r,"nonce",this.state.nonce)),C&&(r=o.UrlUtility.addQueryParam(r,"code_challenge",this.state.code_challenge),r=o.UrlUtility.addQueryParam(r,"code_challenge_method","S256"));var M={prompt:p,display:f,max_age:h,ui_locales:g,id_token_hint:_,login_hint:v,acr_values:y,resource:m,request:k,request_uri:S,response_mode:b};for(var I in M)M[I]&&(r=o.UrlUtility.addQueryParam(r,I,M[I]));for(var O in w)r=o.UrlUtility.addQueryParam(r,O,w[O]);this.url=r}return e.isOidc=function e(t){return!!t.split(/\s+/g).filter(function(e){return"id_token"===e})[0]},e.isOAuth=function e(t){return!!t.split(/\s+/g).filter(function(e){return"token"===e})[0]},e.isCode=function e(t){return!!t.split(/\s+/g).filter(function(e){return"code"===e})[0]},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SigninState=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(8),s=r(4),a=function u(e){return e&&e.__esModule?e:{default:e}}(r(14));t.SigninState=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.nonce,o=r.authority,i=r.client_id,u=r.redirect_uri,c=r.code_verifier,d=r.response_mode,l=r.client_secret,p=r.scope,f=r.extraTokenParams,h=r.skipUserInfo;!function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var _=function v(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,arguments[0]));if(!0===n?_._nonce=(0,a.default)():n&&(_._nonce=n),!0===c?_._code_verifier=(0,a.default)()+(0,a.default)()+(0,a.default)():c&&(_._code_verifier=c),_.code_verifier){var y=s.JoseUtil.hashString(_.code_verifier,"SHA256");_._code_challenge=s.JoseUtil.hexToBase64Url(y)}return _._redirect_uri=u,_._authority=o,_._client_id=i,_._response_mode=d,_._client_secret=l,_._scope=p,_._extraTokenParams=f,_._skipUserInfo=h,_}return function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.toStorageString=function e(){return o.Log.debug("SigninState.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,nonce:this.nonce,code_verifier:this.code_verifier,redirect_uri:this.redirect_uri,authority:this.authority,client_id:this.client_id,response_mode:this.response_mode,client_secret:this.client_secret,scope:this.scope,extraTokenParams:this.extraTokenParams,skipUserInfo:this.skipUserInfo})},t.fromStorageString=function e(r){return o.Log.debug("SigninState.fromStorageString"),new t(JSON.parse(r))},n(t,[{key:"nonce",get:function e(){return this._nonce}},{key:"authority",get:function e(){return this._authority}},{key:"client_id",get:function e(){return this._client_id}},{key:"redirect_uri",get:function e(){return this._redirect_uri}},{key:"code_verifier",get:function e(){return this._code_verifier}},{key:"code_challenge",get:function e(){return this._code_challenge}},{key:"response_mode",get:function e(){return this._response_mode}},{key:"client_secret",get:function e(){return this._client_secret}},{key:"scope",get:function e(){return this._scope}},{key:"extraTokenParams",get:function e(){return this._extraTokenParams}},{key:"skipUserInfo",get:function e(){return this._skipUserInfo}}]),t}(i.State)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function n(){return(0,o.default)().replace(/-/g,"")};var o=function i(e){return e&&e.__esModule?e:{default:e}}(r(31));e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.User=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0);t.User=function(){function e(t){var r=t.id_token,n=t.session_state,o=t.access_token,i=t.refresh_token,s=t.token_type,a=t.scope,u=t.profile,c=t.expires_at,d=t.state;!function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.id_token=r,this.session_state=n,this.access_token=o,this.refresh_token=i,this.token_type=s,this.scope=a,this.profile=u,this.expires_at=c,this.state=d}return e.prototype.toStorageString=function e(){return o.Log.debug("User.toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})},e.fromStorageString=function t(r){return o.Log.debug("User.fromStorageString"),new e(JSON.parse(r))},n(e,[{key:"expires_in",get:function e(){if(this.expires_at){var t=parseInt(Date.now()/1e3);return this.expires_at-t}},set:function e(t){var r=parseInt(t);if("number"==typeof r&&r>0){var n=parseInt(Date.now()/1e3);this.expires_at=n+r}}},{key:"expired",get:function e(){var t=this.expires_in;if(void 0!==t)return t<=0}},{key:"scopes",get:function e(){return(this.scope||"").split(" ")}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AccessTokenEvents=void 0;var n=r(0),o=r(46);var i=60;t.AccessTokenEvents=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.accessTokenExpiringNotificationTime,n=void 0===r?i:r,s=t.accessTokenExpiringTimer,a=void 0===s?new o.Timer("Access token expiring"):s,u=t.accessTokenExpiredTimer,c=void 0===u?new o.Timer("Access token expired"):u;!function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._accessTokenExpiringNotificationTime=n,this._accessTokenExpiring=a,this._accessTokenExpired=c}return e.prototype.load=function e(t){if(t.access_token&&void 0!==t.expires_in){var r=t.expires_in;if(n.Log.debug("AccessTokenEvents.load: access token present, remaining duration:",r),r>0){var o=r-this._accessTokenExpiringNotificationTime;o<=0&&(o=1),n.Log.debug("AccessTokenEvents.load: registering expiring timer in:",o),this._accessTokenExpiring.init(o)}else n.Log.debug("AccessTokenEvents.load: canceling existing expiring timer becase we're past expiration."),this._accessTokenExpiring.cancel();var i=r+1;n.Log.debug("AccessTokenEvents.load: registering expired timer in:",i),this._accessTokenExpired.init(i)}else this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},e.prototype.unload=function e(){n.Log.debug("AccessTokenEvents.unload: canceling existing access token timers"),this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},e.prototype.addAccessTokenExpiring=function e(t){this._accessTokenExpiring.addHandler(t)},e.prototype.removeAccessTokenExpiring=function e(t){this._accessTokenExpiring.removeHandler(t)},e.prototype.addAccessTokenExpired=function e(t){this._accessTokenExpired.addHandler(t)},e.prototype.removeAccessTokenExpired=function e(t){this._accessTokenExpired.removeHandler(t)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;var n=r(0);t.Event=function(){function e(t){!function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._name=t,this._callbacks=[]}return e.prototype.addHandler=function e(t){this._callbacks.push(t)},e.prototype.removeHandler=function e(t){var r=this._callbacks.findIndex(function(e){return e===t});r>=0&&this._callbacks.splice(r,1)},e.prototype.raise=function e(){n.Log.debug("Event: Raising event: "+this._name);for(var t=0;t<this._callbacks.length;t++){var r;(r=this._callbacks)[t].apply(r,arguments)}},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SessionMonitor=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),i=r(19),s=r(1);t.SessionMonitor=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.CheckSessionIFrame,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.Global.timer;if(function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw o.Log.error("SessionMonitor.ctor: No user manager passed to SessionMonitor"),new Error("userManager");this._userManager=t,this._CheckSessionIFrameCtor=n,this._timer=a,this._userManager.events.addUserLoaded(this._start.bind(this)),this._userManager.events.addUserUnloaded(this._stop.bind(this)),this._userManager.getUser().then(function(e){e?r._start(e):r._settings.monitorAnonymousSession&&r._userManager.querySessionStatus().then(function(e){var t={session_state:e.session_state};e.sub&&e.sid&&(t.profile={sub:e.sub,sid:e.sid}),r._start(t)}).catch(function(e){o.Log.error("SessionMonitor ctor: error from querySessionStatus:",e.message)})}).catch(function(e){o.Log.error("SessionMonitor ctor: error from getUser:",e.message)})}return e.prototype._start=function e(t){var r=this,n=t.session_state;n&&(t.profile?(this._sub=t.profile.sub,this._sid=t.profile.sid,o.Log.debug("SessionMonitor._start: session_state:",n,", sub:",this._sub)):(this._sub=void 0,this._sid=void 0,o.Log.debug("SessionMonitor._start: session_state:",n,", anonymous user")),this._checkSessionIFrame?this._checkSessionIFrame.start(n):this._metadataService.getCheckSessionIframe().then(function(e){if(e){o.Log.debug("SessionMonitor._start: Initializing check session iframe");var t=r._client_id,i=r._checkSessionInterval,s=r._stopCheckSessionOnError;r._checkSessionIFrame=new r._CheckSessionIFrameCtor(r._callback.bind(r),t,e,i,s),r._checkSessionIFrame.load().then(function(){r._checkSessionIFrame.start(n)})}else o.Log.warn("SessionMonitor._start: No check session iframe found in the metadata")}).catch(function(e){o.Log.error("SessionMonitor._start: Error from getCheckSessionIframe:",e.message)}))},e.prototype._stop=function e(){var t=this;if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&(o.Log.debug("SessionMonitor._stop"),this._checkSessionIFrame.stop()),this._settings.monitorAnonymousSession)var r=this._timer.setInterval(function(){t._timer.clearInterval(r),t._userManager.querySessionStatus().then(function(e){var r={session_state:e.session_state};e.sub&&e.sid&&(r.profile={sub:e.sub,sid:e.sid}),t._start(r)}).catch(function(e){o.Log.error("SessionMonitor: error from querySessionStatus:",e.message)})},1e3)},e.prototype._callback=function e(){var t=this;this._userManager.querySessionStatus().then(function(e){var r=!0;e?e.sub===t._sub?(r=!1,t._checkSessionIFrame.start(e.session_state),e.sid===t._sid?o.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",e.session_state):(o.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",e.session_state),t._userManager.events._raiseUserSessionChanged())):o.Log.debug("SessionMonitor._callback: Different subject signed into OP:",e.sub):o.Log.debug("SessionMonitor._callback: Subject no longer signed into OP"),r&&(t._sub?(o.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed out event"),t._userManager.events._raiseUserSignedOut()):(o.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed in event"),t._userManager.events._raiseUserSignedIn()))}).catch(function(e){t._sub&&(o.Log.debug("SessionMonitor._callback: Error calling queryCurrentSigninSession; raising signed out event",e.message),t._userManager.events._raiseUserSignedOut())})},n(e,[{key:"_settings",get:function e(){return this._userManager.settings}},{key:"_metadataService",get:function e(){return this._userManager.metadataService}},{key:"_client_id",get:function e(){return this._settings.client_id}},{key:"_checkSessionInterval",get:function e(){return this._settings.checkSessionInterval}},{key:"_stopCheckSessionOnError",get:function e(){return this._settings.stopCheckSessionOnError}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckSessionIFrame=void 0;var n=r(0);var o=2e3;t.CheckSessionIFrame=function(){function e(t,r,n,i){var s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];!function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._callback=t,this._client_id=r,this._url=n,this._interval=i||o,this._stopOnError=s;var u=n.indexOf("/",n.indexOf("//")+2);this._frame_origin=n.substr(0,u),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.style.width=0,this._frame.style.height=0,this._frame.src=n}return e.prototype.load=function e(){var t=this;return new Promise(function(e){t._frame.onload=function(){e()},window.document.body.appendChild(t._frame),t._boundMessageEvent=t._message.bind(t),window.addEventListener("message",t._boundMessageEvent,!1)})},e.prototype._message=function e(t){t.origin===this._frame_origin&&t.source===this._frame.contentWindow&&("error"===t.data?(n.Log.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===t.data?(n.Log.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):n.Log.debug("CheckSessionIFrame: "+t.data+" message from check session op iframe"))},e.prototype.start=function e(t){var r=this;if(this._session_state!==t){n.Log.debug("CheckSessionIFrame.start"),this.stop(),this._session_state=t;var o=function e(){r._frame.contentWindow.postMessage(r._client_id+" "+r._session_state,r._frame_origin)};o(),this._timer=window.setInterval(o,this._interval)}},e.prototype.stop=function e(){this._session_state=null,this._timer&&(n.Log.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TokenRevocationClient=void 0;var n=r(0),o=r(2),i=r(1);t.TokenRevocationClient=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.Global.XMLHttpRequest,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.MetadataService;if(function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw n.Log.error("TokenRevocationClient.ctor: No settings provided"),new Error("No settings provided.");this._settings=t,this._XMLHttpRequestCtor=r,this._metadataService=new s(this._settings)}return e.prototype.revoke=function e(t,r){var o=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"access_token";if(!t)throw n.Log.error("TokenRevocationClient.revoke: No token provided"),new Error("No token provided.");if("access_token"!==i&&"refresh_token"!=i)throw n.Log.error("TokenRevocationClient.revoke: Invalid token type"),new Error("Invalid token type.");return this._metadataService.getRevocationEndpoint().then(function(e){if(e){n.Log.debug("TokenRevocationClient.revoke: Revoking "+i);var s=o._settings.client_id,a=o._settings.client_secret;return o._revoke(e,s,a,t,i)}if(r)throw n.Log.error("TokenRevocationClient.revoke: Revocation not supported"),new Error("Revocation not supported")})},e.prototype._revoke=function e(t,r,o,i,s){var a=this;return new Promise(function(e,u){var c=new a._XMLHttpRequestCtor;c.open("POST",t),c.onload=function(){n.Log.debug("TokenRevocationClient.revoke: HTTP response received, status",c.status),200===c.status?e():u(Error(c.statusText+" ("+c.status+")"))},c.onerror=function(){n.Log.debug("TokenRevocationClient.revoke: Network Error."),u("Network Error")};var d="client_id="+encodeURIComponent(r);o&&(d+="&client_secret="+encodeURIComponent(o)),d+="&token_type_hint="+encodeURIComponent(s),d+="&token="+encodeURIComponent(i),c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),c.send(d)})},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CordovaPopupWindow=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0);var i="location=no,toolbar=no,zoom=no",s="_blank";t.CordovaPopupWindow=function(){function e(t){var r=this;!function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._promise=new Promise(function(e,t){r._resolve=e,r._reject=t}),this.features=t.popupWindowFeatures||i,this.target=t.popupWindowTarget||s,this.redirect_uri=t.startUrl,o.Log.debug("CordovaPopupWindow.ctor: redirect_uri: "+this.redirect_uri)}return e.prototype._isInAppBrowserInstalled=function e(t){return["cordova-plugin-inappbrowser","cordova-plugin-inappbrowser.inappbrowser","org.apache.cordova.inappbrowser"].some(function(e){return t.hasOwnProperty(e)})},e.prototype.navigate=function e(t){if(t&&t.url){if(!window.cordova)return this._error("cordova is undefined");var r=window.cordova.require("cordova/plugin_list").metadata;if(!1===this._isInAppBrowserIn