UNPKG

@digital-blueprint/cabinet-app

Version:

[GitHub Repository](https://github.com/digital-blueprint/cabinet-app) | [npmjs package](https://www.npmjs.com/package/@digital-blueprint/cabinet-app) | [Unpkg CDN](https://unpkg.com/browse/@digital-blueprint/cabinet-app/) | [Cabinet Bundle](https://github

57 lines (56 loc) 37.6 kB
/*! * License: LGPL-2.1-or-later * Dependencies: * * @webcomponents/scoped-custom-element-registry: BSD-3-Clause * @dbp-toolkit/app-shell: LGPL-2.1-or-later * @dbp-toolkit/language-select: LGPL-2.1-or-later * @dbp-toolkit/common: LGPL-2.1-or-later * @dbp-toolkit/auth: LGPL-2.1-or-later * event-target-shim: MIT * @dbp-toolkit/notification: LGPL-2.1-or-later * @dbp-toolkit/theme-switcher: LGPL-2.1-or-later * path-to-regexp: MIT * universal-router: MIT * generateUrls: MIT * @dbp-toolkit/matomo: LGPL-2.1-or-later * @digital-blueprint/esign-app: LGPL-2.1-or-later * @digital-blueprint/annotpdf: MIT * @digital-blueprint/dispatch-app: LGPL-2.1-or-later * @popperjs/core: MIT * tippy.js: MIT * @dbp-toolkit/tooltip: LGPL-2.1-or-later * @dbp-toolkit/person-select: LGPL-2.1-or-later * @dbp-toolkit/pdf-viewer: LGPL-2.1-or-later * lit-html: BSD-3-Clause * pdfjs-dist: Apache-2.0 * dommatrix: MIT * web-streams-polyfill: MIT * @dbp-toolkit/file-handling: LGPL-2.1-or-later * webdav: MIT * tabulator-tables: MIT * jose: MIT * file-saver: MIT * jquery: MIT * select2: MIT * @dbp-toolkit/resource-select: LGPL-2.1-or-later * i18next: MIT * @lit/reactive-element: BSD-3-Clause * lit-element: BSD-3-Clause * @open-wc/dedupe-mixin: MIT * @open-wc/scoped-elements: MIT * base64-js: MIT * js-sha256: MIT * jwt-decode: MIT * keycloak-js: Apache-2.0 */ import{c as e,g as t}from"./notification.CFCZBGs5.es.js";import{r}from"./__node-resolve_empty.CAW0VbeZ.es.js";for(var n={byteLength:function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},toByteArray:function(e){var t,r,n=u(e),o=n[0],a=n[1],c=new s(function(e,t,r){return 3*(t+r)/4-r}(0,o,a)),d=0,l=a>0?o-4:o;for(r=0;r<l;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],c[d++]=t>>16&255,c[d++]=t>>8&255,c[d++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,c[d++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,c[d++]=t>>8&255,c[d++]=255&t);return c},fromByteArray:function(e){for(var t,r=e.length,n=r%3,i=[],s=16383,a=0,c=r-n;a<c;a+=s)i.push(d(e,a,a+s>c?c:a+s));1===n?(t=e[r-1],i.push(o[t>>2]+o[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],i.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"="));return i.join("")}},o=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0;c<64;++c)o[c]=a[c],i[a.charCodeAt(c)]=c;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function d(e,t,r){for(var n,i,s=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(o[(i=n)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63;var l,h={exports:{}}; /** * [js-sha256]{@link https://github.com/emn178/js-sha256} * * @version 0.10.1 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2023 * @license MIT */l=h,function(){var t="input is invalid type",n="object"==typeof window,o=n?window:{};o.JS_SHA256_NO_WINDOW&&(n=!1);var i=!n&&"object"==typeof self,s=!o.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;s?o=e:i&&(o=self);var a=!o.JS_SHA256_NO_COMMON_JS&&l.exports,c=!o.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),d=[-2147483648,8388608,32768,128],h=[24,16,8,0],f=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],p=["hex","array","digest","arrayBuffer"],m=[];!o.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!c||!o.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var g=function(e,t){return function(r){return new b(t,!0).update(r)[e]()}},k=function(e){var t=g("hex",e);s&&(t=v(t,e)),t.create=function(){return new b(e)},t.update=function(e){return t.create().update(e)};for(var r=0;r<p.length;++r){var n=p[r];t[n]=g(n,e)}return t},v=function(e,n){var i,s=r,a=r.Buffer,c=n?"sha224":"sha256";return i=a.from&&!o.JS_SHA256_NO_BUFFER_FROM?a.from:function(e){return new a(e)},function(r){if("string"==typeof r)return s.createHash(c).update(r,"utf8").digest("hex");if(null==r)throw new Error(t);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===a?s.createHash(c).update(i(r)).digest("hex"):e(r)}},w=function(e,t){return function(r,n){return new S(r,t,!0).update(n)[e]()}},y=function(e){var t=w("hex",e);t.create=function(t){return new S(t,e)},t.update=function(e,r){return t.create(e).update(r)};for(var r=0;r<p.length;++r){var n=p[r];t[n]=w(n,e)}return t};function b(e,t){t?(m[0]=m[16]=m[1]=m[2]=m[3]=m[4]=m[5]=m[6]=m[7]=m[8]=m[9]=m[10]=m[11]=m[12]=m[13]=m[14]=m[15]=0,this.blocks=m):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}function S(e,r,n){var o,i=typeof e;if("string"===i){var s,a=[],u=e.length,d=0;for(o=0;o<u;++o)(s=e.charCodeAt(o))<128?a[d++]=s:s<2048?(a[d++]=192|s>>6,a[d++]=128|63&s):s<55296||s>=57344?(a[d++]=224|s>>12,a[d++]=128|s>>6&63,a[d++]=128|63&s):(s=65536+((1023&s)<<10|1023&e.charCodeAt(++o)),a[d++]=240|s>>18,a[d++]=128|s>>12&63,a[d++]=128|s>>6&63,a[d++]=128|63&s);e=a}else{if("object"!==i)throw new Error(t);if(null===e)throw new Error(t);if(c&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||c&&ArrayBuffer.isView(e)))throw new Error(t)}e.length>64&&(e=new b(r,!0).update(e).array());var l=[],h=[];for(o=0;o<64;++o){var f=e[o]||0;l[o]=92^f,h[o]=54^f}b.call(this,r,n),this.update(h),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}b.prototype.update=function(e){if(!this.finalized){var r,n=typeof e;if("string"!==n){if("object"!==n)throw new Error(t);if(null===e)throw new Error(t);if(c&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||c&&ArrayBuffer.isView(e)))throw new Error(t);r=!0}for(var o,i,s=0,a=e.length,u=this.blocks;s<a;){if(this.hashed&&(this.hashed=!1,u[0]=this.block,u[16]=u[1]=u[2]=u[3]=u[4]=u[5]=u[6]=u[7]=u[8]=u[9]=u[10]=u[11]=u[12]=u[13]=u[14]=u[15]=0),r)for(i=this.start;s<a&&i<64;++s)u[i>>2]|=e[s]<<h[3&i++];else for(i=this.start;s<a&&i<64;++s)(o=e.charCodeAt(s))<128?u[i>>2]|=o<<h[3&i++]:o<2048?(u[i>>2]|=(192|o>>6)<<h[3&i++],u[i>>2]|=(128|63&o)<<h[3&i++]):o<55296||o>=57344?(u[i>>2]|=(224|o>>12)<<h[3&i++],u[i>>2]|=(128|o>>6&63)<<h[3&i++],u[i>>2]|=(128|63&o)<<h[3&i++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),u[i>>2]|=(240|o>>18)<<h[3&i++],u[i>>2]|=(128|o>>12&63)<<h[3&i++],u[i>>2]|=(128|o>>6&63)<<h[3&i++],u[i>>2]|=(128|63&o)<<h[3&i++]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.block=u[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},b.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=d[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},b.prototype.hash=function(){var e,t,r,n,o,i,s,a,c,u=this.h0,d=this.h1,l=this.h2,h=this.h3,p=this.h4,m=this.h5,g=this.h6,k=this.h7,v=this.blocks;for(e=16;e<64;++e)t=((o=v[e-15])>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,r=((o=v[e-2])>>>17|o<<15)^(o>>>19|o<<13)^o>>>10,v[e]=v[e-16]+t+v[e-7]+r<<0;for(c=d&l,e=0;e<64;e+=4)this.first?(this.is224?(i=300032,k=(o=v[0]-1413257819)-150054599<<0,h=o+24177077<<0):(i=704751109,k=(o=v[0]-210244248)-1521486534<<0,h=o+143694565<<0),this.first=!1):(t=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),n=(i=u&d)^u&l^c,k=h+(o=k+(r=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(p&m^~p&g)+f[e]+v[e])<<0,h=o+(t+n)<<0),t=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),n=(s=h&u)^h&d^i,g=l+(o=g+(r=(k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&p^~k&m)+f[e+1]+v[e+1])<<0,t=((l=o+(t+n)<<0)>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),n=(a=l&h)^l&u^s,m=d+(o=m+(r=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&k^~g&p)+f[e+2]+v[e+2])<<0,t=((d=o+(t+n)<<0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),n=(c=d&l)^d&h^a,p=u+(o=p+(r=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7))+(m&g^~m&k)+f[e+3]+v[e+3])<<0,u=o+(t+n)<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+u<<0,this.h1=this.h1+d<<0,this.h2=this.h2+l<<0,this.h3=this.h3+h<<0,this.h4=this.h4+p<<0,this.h5=this.h5+m<<0,this.h6=this.h6+g<<0,this.h7=this.h7+k<<0},b.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,o=this.h4,i=this.h5,s=this.h6,a=this.h7,c=u[e>>28&15]+u[e>>24&15]+u[e>>20&15]+u[e>>16&15]+u[e>>12&15]+u[e>>8&15]+u[e>>4&15]+u[15&e]+u[t>>28&15]+u[t>>24&15]+u[t>>20&15]+u[t>>16&15]+u[t>>12&15]+u[t>>8&15]+u[t>>4&15]+u[15&t]+u[r>>28&15]+u[r>>24&15]+u[r>>20&15]+u[r>>16&15]+u[r>>12&15]+u[r>>8&15]+u[r>>4&15]+u[15&r]+u[n>>28&15]+u[n>>24&15]+u[n>>20&15]+u[n>>16&15]+u[n>>12&15]+u[n>>8&15]+u[n>>4&15]+u[15&n]+u[o>>28&15]+u[o>>24&15]+u[o>>20&15]+u[o>>16&15]+u[o>>12&15]+u[o>>8&15]+u[o>>4&15]+u[15&o]+u[i>>28&15]+u[i>>24&15]+u[i>>20&15]+u[i>>16&15]+u[i>>12&15]+u[i>>8&15]+u[i>>4&15]+u[15&i]+u[s>>28&15]+u[s>>24&15]+u[s>>20&15]+u[s>>16&15]+u[s>>12&15]+u[s>>8&15]+u[s>>4&15]+u[15&s];return this.is224||(c+=u[a>>28&15]+u[a>>24&15]+u[a>>20&15]+u[a>>16&15]+u[a>>12&15]+u[a>>8&15]+u[a>>4&15]+u[15&a]),c},b.prototype.toString=b.prototype.hex,b.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,o=this.h4,i=this.h5,s=this.h6,a=this.h7,c=[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,o>>24&255,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s];return this.is224||c.push(a>>24&255,a>>16&255,a>>8&255,255&a),c},b.prototype.array=b.prototype.digest,b.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e},S.prototype=new b,S.prototype.finalize=function(){if(b.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();b.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),b.prototype.finalize.call(this)}};var A=k();A.sha256=A,A.sha224=k(!0),A.sha256.hmac=y(),A.sha224.hmac=y(!0),a?l.exports=A:(o.sha256=A.sha256,o.sha224=A.sha224)}();var f=t(h.exports);class p extends Error{}function m(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return atob(t)}}function g(e,t){if("string"!=typeof e)throw new p("Invalid token specified: must be a string");t||(t={});const r=!0===t.header?0:1,n=e.split(".")[r];if("string"!=typeof n)throw new p(`Invalid token specified: missing part #${r+1}`);let o;try{o=m(n)}catch(e){throw new p(`Invalid token specified: invalid base64 for part #${r+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new p(`Invalid token specified: invalid json for part #${r+1} (${e.message})`)}}if(p.prototype.name="InvalidTokenError","undefined"==typeof Promise)throw Error("Keycloak requires an environment that supports Promises. Make sure that you include the appropriate polyfill.");function k(e){if(!(this instanceof k))throw new Error("The 'Keycloak' constructor must be invoked with 'new'.");for(var t,r,o=this,i=[],s={enable:!0,callbackList:[],interval:5},a=document.getElementsByTagName("script"),c=0;c<a.length;c++)-1===a[c].src.indexOf("keycloak.js")&&-1===a[c].src.indexOf("keycloak.min.js")||-1===a[c].src.indexOf("version=")||(o.iframeVersion=a[c].src.substring(a[c].src.indexOf("version=")+8).split("&")[0]);var u=!0,d=O(console.info),l=O(console.warn);function h(e,t){for(var r=function(e){var t=null,r=window.crypto||window.msCrypto;if(r&&r.getRandomValues&&window.Uint8Array)return t=new Uint8Array(e),r.getRandomValues(t),t;t=new Array(e);for(var n=0;n<t.length;n++)t[n]=Math.floor(256*Math.random());return t}(e),n=new Array(e),o=0;o<e;o++)n[o]=t.charCodeAt(r[o]%t.length);return String.fromCharCode.apply(null,n)}function p(){return void 0!==o.authServerUrl?"/"==o.authServerUrl.charAt(o.authServerUrl.length-1)?o.authServerUrl+"realms/"+encodeURIComponent(o.realm):o.authServerUrl+"/realms/"+encodeURIComponent(o.realm):void 0}function m(e,t){var r=e.code,n=e.error,i=e.prompt,s=(new Date).getTime();if(e.kc_action_status&&o.onActionUpdate&&o.onActionUpdate(e.kc_action_status),n)if("none"!=i){var a={error:n,error_description:e.error_description};o.onAuthError&&o.onAuthError(a),t&&t.setError(a)}else t&&t.setSuccess();else if("standard"!=o.flow&&(e.access_token||e.id_token)&&f(e.access_token,null,e.id_token,!0),"implicit"!=o.flow&&r){var c="code="+r+"&grant_type=authorization_code",l=o.endpoints.token(),h=new XMLHttpRequest;h.open("POST",l,!0),h.setRequestHeader("Content-type","application/x-www-form-urlencoded"),c+="&client_id="+encodeURIComponent(o.clientId),c+="&redirect_uri="+e.redirectUri,e.pkceCodeVerifier&&(c+="&code_verifier="+e.pkceCodeVerifier),h.withCredentials=!0,h.onreadystatechange=function(){if(4==h.readyState)if(200==h.status){var e=JSON.parse(h.responseText);f(e.access_token,e.refresh_token,e.id_token,"standard"===o.flow),U()}else o.onAuthError&&o.onAuthError(),t&&t.setError()},h.send(c)}function f(r,n,i,a){w(r,n,i,s=(s+(new Date).getTime())/2),u&&(o.tokenParsed&&o.tokenParsed.nonce!=e.storedNonce||o.refreshTokenParsed&&o.refreshTokenParsed.nonce!=e.storedNonce||o.idTokenParsed&&o.idTokenParsed.nonce!=e.storedNonce)?(d("[KEYCLOAK] Invalid nonce, clearing token"),o.clearToken(),t&&t.setError()):a&&(o.onAuthSuccess&&o.onAuthSuccess(),t&&t.setSuccess())}}function v(e){return 0==e.status&&e.responseText&&e.responseURL.startsWith("file:")}function w(e,t,r,n){if(o.tokenTimeoutHandle&&(clearTimeout(o.tokenTimeoutHandle),o.tokenTimeoutHandle=null),t?(o.refreshToken=t,o.refreshTokenParsed=g(t)):(delete o.refreshToken,delete o.refreshTokenParsed),r?(o.idToken=r,o.idTokenParsed=g(r)):(delete o.idToken,delete o.idTokenParsed),e){if(o.token=e,o.tokenParsed=g(e),o.sessionId=o.tokenParsed.session_state,o.authenticated=!0,o.subject=o.tokenParsed.sub,o.realmAccess=o.tokenParsed.realm_access,o.resourceAccess=o.tokenParsed.resource_access,n&&(o.timeSkew=Math.floor(n/1e3)-o.tokenParsed.iat),null!=o.timeSkew&&(d("[KEYCLOAK] Estimated time difference between browser and server is "+o.timeSkew+" seconds"),o.onTokenExpired)){var i=1e3*(o.tokenParsed.exp-(new Date).getTime()/1e3+o.timeSkew);d("[KEYCLOAK] Token expires in "+Math.round(i/1e3)+" s"),i<=0?o.onTokenExpired():o.tokenTimeoutHandle=setTimeout(o.onTokenExpired,i)}}else delete o.token,delete o.tokenParsed,delete o.subject,delete o.realmAccess,delete o.resourceAccess,o.authenticated=!1}function y(){var e="0123456789abcdef",t=h(36,e).split("");return t[14]="4",t[19]=e.substr(3&t[19]|8,1),t[8]=t[13]=t[18]=t[23]="-",t.join("")}function b(e){var t=function(e){var t;switch(o.flow){case"standard":t=["code","state","session_state","kc_action_status","iss"];break;case"implicit":t=["access_token","token_type","id_token","state","session_state","expires_in","kc_action_status","iss"];break;case"hybrid":t=["access_token","token_type","id_token","code","state","session_state","expires_in","kc_action_status","iss"]}t.push("error"),t.push("error_description"),t.push("error_uri");var r,n,i=e.indexOf("?"),s=e.indexOf("#");"query"===o.responseMode&&-1!==i?(r=e.substring(0,i),""!==(n=S(e.substring(i+1,-1!==s?s:e.length),t)).paramsString&&(r+="?"+n.paramsString),-1!==s&&(r+=e.substring(s))):"fragment"===o.responseMode&&-1!==s&&(r=e.substring(0,s),""!==(n=S(e.substring(s+1),t)).paramsString&&(r+="#"+n.paramsString));if(n&&n.oauthParams)if("standard"===o.flow||"hybrid"===o.flow){if((n.oauthParams.code||n.oauthParams.error)&&n.oauthParams.state)return n.oauthParams.newUrl=r,n.oauthParams}else if("implicit"===o.flow&&(n.oauthParams.access_token||n.oauthParams.error)&&n.oauthParams.state)return n.oauthParams.newUrl=r,n.oauthParams}(e);if(t){var n=r.get(t.state);return n&&(t.valid=!0,t.redirectUri=n.redirectUri,t.storedNonce=n.nonce,t.prompt=n.prompt,t.pkceCodeVerifier=n.pkceCodeVerifier),t}}function S(e,t){for(var r=e.split("&"),n={paramsString:"",oauthParams:{}},o=0;o<r.length;o++){var i=r[o].indexOf("="),s=r[o].slice(0,i);-1!==t.indexOf(s)?n.oauthParams[s]=r[o].slice(i+1):(""!==n.paramsString&&(n.paramsString+="&"),n.paramsString+=r[o])}return n}function A(){var e={setSuccess:function(t){e.resolve(t)},setError:function(t){e.reject(t)}};return e.promise=new Promise((function(t,r){e.resolve=t,e.reject=r})),e}function _(){var e=A();if(!s.enable)return e.setSuccess(),e.promise;if(s.iframe)return e.setSuccess(),e.promise;var t=document.createElement("iframe");s.iframe=t,t.onload=function(){var t=o.endpoints.authorize();"/"===t.charAt(0)?s.iframeOrigin=window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""):s.iframeOrigin=t.substring(0,t.indexOf("/",8)),e.setSuccess()};var r=o.endpoints.checkSessionIframe();t.setAttribute("src",r),t.setAttribute("sandbox","allow-storage-access-by-user-activation allow-scripts allow-same-origin"),t.setAttribute("title","keycloak-session-iframe"),t.style.display="none",document.body.appendChild(t);return window.addEventListener("message",(function(e){if(e.origin===s.iframeOrigin&&s.iframe.contentWindow===e.source&&("unchanged"==e.data||"changed"==e.data||"error"==e.data)){"unchanged"!=e.data&&o.clearToken();for(var t=s.callbackList.splice(0,s.callbackList.length),r=t.length-1;r>=0;--r){var n=t[r];"error"==e.data?n.setError():n.setSuccess("unchanged"==e.data)}}}),!1),e.promise}function U(){s.enable&&o.token&&setTimeout((function(){C().then((function(e){e&&U()}))}),1e3*s.interval)}function C(){var e=A();if(s.iframe&&s.iframeOrigin){var t=o.clientId+" "+(o.sessionId?o.sessionId:"");s.callbackList.push(e);var r=s.iframeOrigin;1==s.callbackList.length&&s.iframe.contentWindow.postMessage(t,r)}else e.setSuccess();return e.promise}function I(){var e=A();if(s.enable||o.silentCheckSsoRedirectUri){var t=document.createElement("iframe");t.setAttribute("src",o.endpoints.thirdPartyCookiesIframe()),t.setAttribute("sandbox","allow-storage-access-by-user-activation allow-scripts allow-same-origin"),t.setAttribute("title","keycloak-3p-check-iframe"),t.style.display="none",document.body.appendChild(t);window.addEventListener("message",(function r(n){t.contentWindow===n.source&&("supported"!==n.data&&"unsupported"!==n.data||("unsupported"===n.data&&(l("[KEYCLOAK] Your browser is blocking access to 3rd-party cookies, this means:\n\n - It is not possible to retrieve tokens without redirecting to the Keycloak server (a.k.a. no support for silent authentication).\n - It is not possible to automatically detect changes to the session status (such as the user logging out in another tab).\n\nFor more information see: https://www.keycloak.org/docs/latest/securing_apps/#_modern_browsers"),s.enable=!1,o.silentCheckSsoFallback&&(o.silentCheckSsoRedirectUri=!1)),document.body.removeChild(t),window.removeEventListener("message",r),e.setSuccess()))}),!1)}else e.setSuccess();return function(e,t,r){var n=null,o=new Promise((function(e,o){n=setTimeout((function(){o({error:r||"Promise is not settled within timeout of "+t+"ms"})}),t)}));return Promise.race([e,o]).finally((function(){clearTimeout(n)}))}(e.promise,o.messageReceiveTimeout,"Timeout when waiting for 3rd party check iframe message.")}function E(e){if(!e||"default"==e)return{login:function(e){return window.location.assign(o.createLoginUrl(e)),A().promise},logout:function(e){return window.location.replace(o.createLogoutUrl(e)),A().promise},register:function(e){return window.location.assign(o.createRegisterUrl(e)),A().promise},accountManagement:function(){var e=o.createAccountUrl();if(void 0===e)throw"Not supported by the OIDC server";return window.location.href=e,A().promise},redirectUri:function(e,t){return e&&e.redirectUri?e.redirectUri:o.redirectUri?o.redirectUri:location.href}};if("cordova"==e){s.enable=!1;var t=function(e,t,r){return window.cordova&&window.cordova.InAppBrowser?window.cordova.InAppBrowser.open(e,t,r):window.open(e,t,r)},r=function(e){var t=function(e){return e&&e.cordovaOptions?Object.keys(e.cordovaOptions).reduce((function(t,r){return t[r]=e.cordovaOptions[r],t}),{}):{}}(e);return t.location="no",e&&"none"==e.prompt&&(t.hidden="yes"),function(e){return Object.keys(e).reduce((function(t,r){return t.push(r+"="+e[r]),t}),[]).join(",")}(t)},n=function(){return o.redirectUri||"http://localhost"};return{login:function(e){var i=A(),s=r(e),a=o.createLoginUrl(e),c=t(a,"_blank",s),u=!1,d=!1,l=function(){d=!0,c.close()};return c.addEventListener("loadstart",(function(e){0==e.url.indexOf(n())&&(m(b(e.url),i),l(),u=!0)})),c.addEventListener("loaderror",(function(e){u||(0==e.url.indexOf(n())?(m(b(e.url),i),l(),u=!0):(i.setError(),l()))})),c.addEventListener("exit",(function(e){d||i.setError({reason:"closed_by_user"})})),i.promise},logout:function(e){var r,i=A(),s=o.createLogoutUrl(e),a=t(s,"_blank","location=no,hidden=yes,clearcache=yes");return a.addEventListener("loadstart",(function(e){0==e.url.indexOf(n())&&a.close()})),a.addEventListener("loaderror",(function(e){0==e.url.indexOf(n())||(r=!0),a.close()})),a.addEventListener("exit",(function(e){r?i.setError():(o.clearToken(),i.setSuccess())})),i.promise},register:function(e){var i=A(),s=o.createRegisterUrl(),a=r(e),c=t(s,"_blank",a);return c.addEventListener("loadstart",(function(e){0==e.url.indexOf(n())&&(c.close(),m(b(e.url),i))})),i.promise},accountManagement:function(){var e=o.createAccountUrl();if(void 0===e)throw"Not supported by the OIDC server";var r=t(e,"_blank","location=no");r.addEventListener("loadstart",(function(e){0==e.url.indexOf(n())&&r.close()}))},redirectUri:function(e){return n()}}}if("cordova-native"==e)return s.enable=!1,{login:function(e){var t=A(),r=o.createLoginUrl(e);return universalLinks.subscribe("keycloak",(function(e){universalLinks.unsubscribe("keycloak"),window.cordova.plugins.browsertab.close(),m(b(e.url),t)})),window.cordova.plugins.browsertab.openUrl(r),t.promise},logout:function(e){var t=A(),r=o.createLogoutUrl(e);return universalLinks.subscribe("keycloak",(function(e){universalLinks.unsubscribe("keycloak"),window.cordova.plugins.browsertab.close(),o.clearToken(),t.setSuccess()})),window.cordova.plugins.browsertab.openUrl(r),t.promise},register:function(e){var t=A(),r=o.createRegisterUrl(e);return universalLinks.subscribe("keycloak",(function(e){universalLinks.unsubscribe("keycloak"),window.cordova.plugins.browsertab.close(),m(b(e.url),t)})),window.cordova.plugins.browsertab.openUrl(r),t.promise},accountManagement:function(){var e=o.createAccountUrl();if(void 0===e)throw"Not supported by the OIDC server";window.cordova.plugins.browsertab.openUrl(e)},redirectUri:function(e){return e&&e.redirectUri?e.redirectUri:o.redirectUri?o.redirectUri:"http://localhost"}};throw"invalid adapter type: "+e}o.init=function(n){if(o.didInitialize)throw new Error("A 'Keycloak' instance can only be initialized once.");o.didInitialize=!0,o.authenticated=!1,r=function(){try{return new R}catch(e){}return new T}();if(t=n&&["default","cordova","cordova-native"].indexOf(n.adapter)>-1?E(n.adapter):n&&"object"==typeof n.adapter?n.adapter:window.Cordova||window.cordova?E("cordova"):E(),n){if(void 0!==n.useNonce&&(u=n.useNonce),void 0!==n.checkLoginIframe&&(s.enable=n.checkLoginIframe),n.checkLoginIframeInterval&&(s.interval=n.checkLoginIframeInterval),"login-required"===n.onLoad&&(o.loginRequired=!0),n.responseMode){if("query"!==n.responseMode&&"fragment"!==n.responseMode)throw"Invalid value for responseMode";o.responseMode=n.responseMode}if(n.flow){switch(n.flow){case"standard":o.responseType="code";break;case"implicit":o.responseType="id_token token";break;case"hybrid":o.responseType="code id_token token";break;default:throw"Invalid value for flow"}o.flow=n.flow}if(null!=n.timeSkew&&(o.timeSkew=n.timeSkew),n.redirectUri&&(o.redirectUri=n.redirectUri),n.silentCheckSsoRedirectUri&&(o.silentCheckSsoRedirectUri=n.silentCheckSsoRedirectUri),"boolean"==typeof n.silentCheckSsoFallback?o.silentCheckSsoFallback=n.silentCheckSsoFallback:o.silentCheckSsoFallback=!0,n.pkceMethod){if("S256"!==n.pkceMethod)throw"Invalid value for pkceMethod";o.pkceMethod=n.pkceMethod}"boolean"==typeof n.enableLogging?o.enableLogging=n.enableLogging:o.enableLogging=!1,"string"==typeof n.scope&&(o.scope=n.scope),"string"==typeof n.acrValues&&(o.acrValues=n.acrValues),"number"==typeof n.messageReceiveTimeout&&n.messageReceiveTimeout>0?o.messageReceiveTimeout=n.messageReceiveTimeout:o.messageReceiveTimeout=1e4}o.responseMode||(o.responseMode="fragment"),o.responseType||(o.responseType="code",o.flow="standard");var i=A(),a=A();a.promise.then((function(){o.onReady&&o.onReady(o.authenticated),i.setSuccess(o.authenticated)})).catch((function(e){i.setError(e)}));var c=function(t){var r,n=A();e?"string"==typeof e&&(r=e):r="keycloak.json";function i(e){o.endpoints=e?{authorize:function(){return e.authorization_endpoint},token:function(){return e.token_endpoint},logout:function(){if(!e.end_session_endpoint)throw"Not supported by the OIDC server";return e.end_session_endpoint},checkSessionIframe:function(){if(!e.check_session_iframe)throw"Not supported by the OIDC server";return e.check_session_iframe},register:function(){throw'Redirection to "Register user" page not supported in standard OIDC mode'},userinfo:function(){if(!e.userinfo_endpoint)throw"Not supported by the OIDC server";return e.userinfo_endpoint}}:{authorize:function(){return p()+"/protocol/openid-connect/auth"},token:function(){return p()+"/protocol/openid-connect/token"},logout:function(){return p()+"/protocol/openid-connect/logout"},checkSessionIframe:function(){var e=p()+"/protocol/openid-connect/login-status-iframe.html";return o.iframeVersion&&(e=e+"?version="+o.iframeVersion),e},thirdPartyCookiesIframe:function(){var e=p()+"/protocol/openid-connect/3p-cookies/step1.html";return o.iframeVersion&&(e=e+"?version="+o.iframeVersion),e},register:function(){return p()+"/protocol/openid-connect/registrations"},userinfo:function(){return p()+"/protocol/openid-connect/userinfo"}}}if(r){(c=new XMLHttpRequest).open("GET",r,!0),c.setRequestHeader("Accept","application/json"),c.onreadystatechange=function(){if(4==c.readyState)if(200==c.status||v(c)){var e=JSON.parse(c.responseText);o.authServerUrl=e["auth-server-url"],o.realm=e.realm,o.clientId=e.resource,i(null),n.setSuccess()}else n.setError()},c.send()}else{if(!e.clientId)throw"clientId missing";o.clientId=e.clientId;var s=e.oidcProvider;if(s){var a,c;if("string"==typeof s)a="/"==s.charAt(s.length-1)?s+".well-known/openid-configuration":s+"/.well-known/openid-configuration",(c=new XMLHttpRequest).open("GET",a,!0),c.setRequestHeader("Accept","application/json"),c.onreadystatechange=function(){4==c.readyState&&(200==c.status||v(c)?(i(JSON.parse(c.responseText)),n.setSuccess()):n.setError())},c.send();else i(s),n.setSuccess()}else{if(!e.url)for(var u=document.getElementsByTagName("script"),d=0;d<u.length;d++)if(u[d].src.match(/.*keycloak\.js/)){e.url=u[d].src.substr(0,u[d].src.indexOf("/js/keycloak.js"));break}if(!e.realm)throw"realm missing";o.authServerUrl=e.url,o.realm=e.realm,i(null),n.setSuccess()}}return n.promise}();function d(){var e=function(e){e||(r.prompt="none"),n&&n.locale&&(r.locale=n.locale),o.login(r).then((function(){a.setSuccess()})).catch((function(e){a.setError(e)}))},t=function(){var e=document.createElement("iframe"),t=o.createLoginUrl({prompt:"none",redirectUri:o.silentCheckSsoRedirectUri});e.setAttribute("src",t),e.setAttribute("sandbox","allow-storage-access-by-user-activation allow-scripts allow-same-origin"),e.setAttribute("title","keycloak-silent-check-sso"),e.style.display="none",document.body.appendChild(e);window.addEventListener("message",(function t(r){r.origin===window.location.origin&&e.contentWindow===r.source&&(m(b(r.data),a),document.body.removeChild(e),window.removeEventListener("message",t))}))},r={};switch(n.onLoad){case"check-sso":s.enable?_().then((function(){C().then((function(r){r?a.setSuccess():o.silentCheckSsoRedirectUri?t():e(!1)})).catch((function(e){a.setError(e)}))})):o.silentCheckSsoRedirectUri?t():e(!1);break;case"login-required":e(!0);break;default:throw"Invalid value for onLoad"}}function l(){var e=b(window.location.href);if(e&&window.history.replaceState(window.history.state,null,e.newUrl),e&&e.valid)return _().then((function(){m(e,a)})).catch((function(e){a.setError(e)}));n?n.token&&n.refreshToken?(w(n.token,n.refreshToken,n.idToken),s.enable?_().then((function(){C().then((function(e){e?(o.onAuthSuccess&&o.onAuthSuccess(),a.setSuccess(),U()):a.setSuccess()})).catch((function(e){a.setError(e)}))})):o.updateToken(-1).then((function(){o.onAuthSuccess&&o.onAuthSuccess(),a.setSuccess()})).catch((function(e){o.onAuthError&&o.onAuthError(),n.onLoad?d():a.setError(e)}))):n.onLoad?d():a.setSuccess():a.setSuccess()}return c.then((function(){(function(){var e=A(),t=function t(){"interactive"!==document.readyState&&"complete"!==document.readyState||(document.removeEventListener("readystatechange",t),e.setSuccess())};return document.addEventListener("readystatechange",t),t(),e.promise})().then(I).then(l).catch((function(e){i.setError(e)}))})),c.catch((function(e){i.setError(e)})),i.promise},o.login=function(e){return t.login(e)},o.createLoginUrl=function(e){var i,s=y(),a=y(),c=t.redirectUri(e),d={state:s,nonce:a,redirectUri:encodeURIComponent(c)};e&&e.prompt&&(d.prompt=e.prompt),i=e&&"register"==e.action?o.endpoints.register():o.endpoints.authorize();var l=e&&e.scope||o.scope;l?-1===l.indexOf("openid")&&(l="openid "+l):l="openid";var p,m,g=i+"?client_id="+encodeURIComponent(o.clientId)+"&redirect_uri="+encodeURIComponent(c)+"&state="+encodeURIComponent(s)+"&response_mode="+encodeURIComponent(o.responseMode)+"&response_type="+encodeURIComponent(o.responseType)+"&scope="+encodeURIComponent(l);if(u&&(g=g+"&nonce="+encodeURIComponent(a)),e&&e.prompt&&(g+="&prompt="+encodeURIComponent(e.prompt)),e&&e.maxAge&&(g+="&max_age="+encodeURIComponent(e.maxAge)),e&&e.loginHint&&(g+="&login_hint="+encodeURIComponent(e.loginHint)),e&&e.idpHint&&(g+="&kc_idp_hint="+encodeURIComponent(e.idpHint)),e&&e.action&&"register"!=e.action&&(g+="&kc_action="+encodeURIComponent(e.action)),e&&e.locale&&(g+="&ui_locales="+encodeURIComponent(e.locale)),e&&e.acr){var k=(p=e.acr,m={id_token:{acr:p}},JSON.stringify(m));g+="&claims="+encodeURIComponent(k)}if((e&&e.acrValues||o.acrValues)&&(g+="&acr_values="+encodeURIComponent(e.acrValues||o.acrValues)),o.pkceMethod){var v=function(e){return h(e,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")}(96);d.pkceCodeVerifier=v;var w=function(e,t){if("S256"===e){var r=new Uint8Array(f.arrayBuffer(t));return n.fromByteArray(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}throw"Invalid value for pkceMethod"}(o.pkceMethod,v);g+="&code_challenge="+w,g+="&code_challenge_method="+o.pkceMethod}return r.add(d),g},o.logout=function(e){return t.logout(e)},o.createLogoutUrl=function(e){var r=o.endpoints.logout()+"?client_id="+encodeURIComponent(o.clientId)+"&post_logout_redirect_uri="+encodeURIComponent(t.redirectUri(e,!1));return o.idToken&&(r+="&id_token_hint="+encodeURIComponent(o.idToken)),r},o.register=function(e){return t.register(e)},o.createRegisterUrl=function(e){return e||(e={}),e.action="register",o.createLoginUrl(e)},o.createAccountUrl=function(e){var r=p(),n=void 0;return void 0!==r&&(n=r+"/account?referrer="+encodeURIComponent(o.clientId)+"&referrer_uri="+encodeURIComponent(t.redirectUri(e))),n},o.accountManagement=function(){return t.accountManagement()},o.hasRealmRole=function(e){var t=o.realmAccess;return!!t&&t.roles.indexOf(e)>=0},o.hasResourceRole=function(e,t){if(!o.resourceAccess)return!1;var r=o.resourceAccess[t||o.clientId];return!!r&&r.roles.indexOf(e)>=0},o.loadUserProfile=function(){var e=p()+"/account",t=new XMLHttpRequest;t.open("GET",e,!0),t.setRequestHeader("Accept","application/json"),t.setRequestHeader("Authorization","bearer "+o.token);var r=A();return t.onreadystatechange=function(){4==t.readyState&&(200==t.status?(o.profile=JSON.parse(t.responseText),r.setSuccess(o.profile)):r.setError())},t.send(),r.promise},o.loadUserInfo=function(){var e=o.endpoints.userinfo(),t=new XMLHttpRequest;t.open("GET",e,!0),t.setRequestHeader("Accept","application/json"),t.setRequestHeader("Authorization","bearer "+o.token);var r=A();return t.onreadystatechange=function(){4==t.readyState&&(200==t.status?(o.userInfo=JSON.parse(t.responseText),r.setSuccess(o.userInfo)):r.setError())},t.send(),r.promise},o.isTokenExpired=function(e){if(!o.tokenParsed||!o.refreshToken&&"implicit"!=o.flow)throw"Not authenticated";if(null==o.timeSkew)return d("[KEYCLOAK] Unable to determine if token is expired as timeskew is not set"),!0;var t=o.tokenParsed.exp-Math.ceil((new Date).getTime()/1e3)+o.timeSkew;if(e){if(isNaN(e))throw"Invalid minValidity";t-=e}return t<0},o.updateToken=function(e){var t=A();if(!o.refreshToken)return t.setError(),t.promise;e=e||5;var r=function(){var r=!1;if(-1==e?(r=!0,d("[KEYCLOAK] Refreshing token: forced refresh")):o.tokenParsed&&!o.isTokenExpired(e)||(r=!0,d("[KEYCLOAK] Refreshing token: token expired")),r){var n="grant_type=refresh_token&refresh_token="+o.refreshToken,s=o.endpoints.token();if(i.push(t),1==i.length){var a=new XMLHttpRequest;a.open("POST",s,!0),a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a.withCredentials=!0,n+="&client_id="+encodeURIComponent(o.clientId);var c=(new Date).getTime();a.onreadystatechange=function(){if(4==a.readyState)if(200==a.status){d("[KEYCLOAK] Token refreshed"),c=(c+(new Date).getTime())/2;var e=JSON.parse(a.responseText);w(e.access_token,e.refresh_token,e.id_token,c),o.onAuthRefreshSuccess&&o.onAuthRefreshSuccess();for(var t=i.pop();null!=t;t=i.pop())t.setSuccess(!0)}else{l("[KEYCLOAK] Failed to refresh token"),400==a.status&&o.clearToken(),o.onAuthRefreshError&&o.onAuthRefreshError();for(t=i.pop();null!=t;t=i.pop())t.setError(!0)}},a.send(n)}}else t.setSuccess(!1)};s.enable?C().then((function(){r()})).catch((function(e){t.setError(e)})):r();return t.promise},o.clearToken=function(){o.token&&(w(null,null,null),o.onAuthLogout&&o.onAuthLogout(),o.loginRequired&&o.login())};var R=function e(){if(!(this instanceof e))return new e;localStorage.setItem("kc-test","test"),localStorage.removeItem("kc-test");function t(){for(var e=(new Date).getTime(),t=0;t<localStorage.length;t++){var r=localStorage.key(t);if(r&&0==r.indexOf("kc-callback-")){var n=localStorage.getItem(r);if(n)try{var o=JSON.parse(n).expires;(!o||o<e)&&localStorage.removeItem(r)}catch(e){localStorage.removeItem(r)}}}}this.get=function(e){if(e){var r="kc-callback-"+e,n=localStorage.getItem(r);return n&&(localStorage.removeItem(r),n=JSON.parse(n)),t(),n}},this.add=function(e){t();var r="kc-callback-"+e.state;e.expires=(new Date).getTime()+36e5,localStorage.setItem(r,JSON.stringify(e))}},T=function e(){if(!(this instanceof e))return new e;var t=this;t.get=function(e){if(e){var t=n("kc-callback-"+e);return o("kc-callback-"+e,"",r(-100)),t?JSON.parse(t):void 0}},t.add=function(e){o("kc-callback-"+e.state,JSON.stringify(e),r(60))},t.removeItem=function(e){o(e,"",r(-100))};var r=function(e){var t=new Date;return t.setTime(t.getTime()+60*e*1e3),t},n=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""},o=function(e,t,r){var n=e+"="+t+"; expires="+r.toUTCString()+"; ";document.cookie=n}};function O(e){return function(){o.enableLogging&&e.apply(console,Array.prototype.slice.call(arguments))}}}export{k as default}; //# sourceMappingURL=keycloak.Bslg7_f5.es.js.map