@nsshunt/stsoauth2plugin 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/384.index.js CHANGED
@@ -1 +1 @@
1
- var stsoauth2plugin;(()=>{"use strict";var e,t,s={9384:(e,t,s)=>{var o=s(1227),r=s.n(o),n=s(9669),a=s.n(n),i=s(7557);var c,l,h=s(6245),u=s(6378),p=function(e,t,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(e):o?o.value:t.get(e)},f=function(e,t,s,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,s):r?r.value=s:t.set(e,s),s};const d=r()(`proc:${process.pid}:storage.ts`);var g;!function(e){e.LOCAL_STORAGE="LocalStorage",e.SESSION_STORAGE="SessionStorage",e.COOKIE_STORAGE="CookieStorage",e.MEMORY_STORAGE="MemoryStorage"}(g||(g={}));class m{constructor(){this.get=e=>{const t=u.get(e);return t?JSON.parse(t):null},this.set=(e,t,s={})=>{let o={};"https:"===window.location.protocol&&(o={secure:!0,sameSite:"none"}),s&&s.daysUntilExpire?o.expires=s.daysUntilExpire:o.expires=1,d(`CookieStorage.set: key: ${e}, value: [${t}]`),u.set(e,JSON.stringify(t),o)},this.remove=e=>{u.remove(e)}}}class O{constructor(){this.get=e=>{const t=sessionStorage.getItem(e);return null==t?null:JSON.parse(t)},this.set=(e,t)=>{d(`SessionStorage.set: key: ${e}, value: [${t}]`),sessionStorage.setItem(e,JSON.stringify(t))},this.remove=e=>{sessionStorage.removeItem(e)}}}class E{constructor(){this.get=e=>{const t=localStorage.getItem(e);return null==t?null:JSON.parse(t)},this.set=(e,t)=>{d(`LocalStorage.set: key: ${e}, value: [${t}]`),localStorage.setItem(e,JSON.stringify(t))},this.remove=e=>{localStorage.removeItem(e)}}}class w{constructor(){c.set(this,{}),this.get=e=>{const t=p(this,c,"f")[e];return null==t?null:t},this.set=(e,t)=>{d(`MemoryStorage.set: key: ${e}, value: [${t}]`),p(this,c,"f")[e]=t},this.remove=e=>{delete p(this,c,"f")[e]}}}c=new WeakMap;class R{constructor(e){switch(l.set(this,null),e.clientStorageType){case g.SESSION_STORAGE:f(this,l,new O,"f");break;case g.LOCAL_STORAGE:f(this,l,new E,"f");break;case g.COOKIE_STORAGE:f(this,l,new m,"f");break;case g.MEMORY_STORAGE:f(this,l,new w,"f");break;default:throw new Error(`Unknown [${e.clientStorageType}] storage type.`)}}GetStorage(){return p(this,l,"f")}}l=new WeakMap;var y,T,v,S,_=s(6647);!function(e){e.CODE="code",e.ID_TOKEN="id_token",e.TOKEN="token"}(y||(y={})),function(e){e.QUERY="query",e.FRAGMENT="fragment",e.FORM_POST="form_post"}(T||(T={})),function(e){e.CLIENT_CREDENTIALS="client_credentials",e.AUTHORIZATION_CODE="authorization_code",e.REFRESH_TOKEN="refresh_token"}(v||(v={})),function(e){e.RESTORE_SESSION="RestoreSession",e.AUTHORIZE="Authorize",e.HANDLE_REDIRECT="HandleRedirect",e.LOGOUT="Logout",e.AUTHENTICATE_EVENT="AuthenticateEvent",e.ERROR="Error"}(S||(S={}));var I,k,C,A,N,P,M,U,b,$,D,L,W,G,H,K,x,J,j=function(e,t,s,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,s):r?r.value=s:t.set(e,s),s},B=function(e,t,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(e):o?o.value:t.get(e)};r()(`proc:${process.pid}:stsoauth2worker.ts`);class z{constructor(e){I.set(this,null),k.set(this,new class{constructor(){this.DigestMessage=async function(e){const t=(new TextEncoder).encode(e),s=await crypto.subtle.digest("SHA-256",t),o=Array.from(new Uint8Array(s));return btoa(String.fromCharCode(...o))},this.CreateRandomString=(e=43)=>{const t=Array.from(crypto.getRandomValues(new Uint8Array(e)));return btoa(String.fromCharCode(...t))},this.CreateRandomStringEx=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";return Array.from(crypto.getRandomValues(new Uint8Array(43))).forEach((s=>t+=e[s%e.length])),t}}}),C.set(this,new class{constructor(){this.DecodeQueryParams=e=>{const t={};return Object.keys(e).filter((t=>void 0!==e[t])).map((s=>{t[decodeURIComponent(s)]=decodeURIComponent(e[s])})),t},this.CreateQueryParams=e=>Object.keys(e).filter((t=>void 0!==e[t])).map((t=>Array.isArray(e[t])?encodeURIComponent(t)+"="+encodeURIComponent(e[t].join(" ")):encodeURIComponent(t)+"="+encodeURIComponent(e[t]))).join("&"),this._GetQueryParams=e=>{let t={};const s=e.split("?");if(2==s.length){const e=s[1].split("&"),o={};let r="";e.forEach((function(e){r=e.split("="),2==r.length&&(o[r[0]]=r[1])})),t=this.DecodeQueryParams(o)}return t},this.GetQueryParams=()=>this._GetQueryParams(window.location.href)}}),A.set(this,"authorize_options.stsmda.com.au"),N.set(this,"session.stsmda.com.au"),P.set(this,null),M.set(this,null),U.set(this,null),b.set(this,null),$.set(this,0),this.SetupListener=()=>{B(this,b,"f").onmessage=async e=>{const t=e.data;switch(t.command){case S.RESTORE_SESSION:B(this,D,"f").call(this,t,await B(this,L,"f").call(this));break;case S.AUTHORIZE:B(this,D,"f").call(this,t,await B(this,W,"f").call(this));break;case S.HANDLE_REDIRECT:B(this,D,"f").call(this,t,await B(this,G,"f").call(this,t.payload));break;case S.LOGOUT:B(this,D,"f").call(this,t,await B(this,J,"f").call(this));break;default:throw new Error(`Command: [${t.command}'] not found.`)}}},D.set(this,(async(e,t)=>{const s={messageId:e.messageId,command:e.command,payload:t};B(this,b,"f").postMessage(s)})),L.set(this,(async()=>{let e=null;if(e=B(this,I,"f").get(B(this,N,"f")),null!==e)console.log("Session restored from client storage."),B(this,P,"f")&&B(this,P,"f").UpdateInstrument("m",{LogMessage:"Session restored from client storage."});else{const t=`${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/session`;console.log("RestoreSession"),console.log(t),B(this,P,"f")&&(B(this,P,"f").UpdateInstrument("m",{LogMessage:"RestoreSession"}),B(this,P,"f").UpdateInstrument("m",{LogMessage:t}));try{const s=await a()({method:"post",url:t,data:{[i.OAuth2ParameterType.CLIENT_ID]:process.env.CLIENT_ID,[i.OAuth2ParameterType.SCOPE]:process.env.SCOPE,[i.OAuth2ParameterType.REDIRECT_URI]:process.env.REDIRECT_URI,[i.OAuth2ParameterType.AUDIENCE]:process.env.AUDIENCE},withCredentials:!0,timeout:parseInt(process.env.TIMEOUT)});s.data.status===_.W.OK?(e=s.data.detail,B(this,I,"f").set(B(this,N,"f"),e),console.log("Session restored from server side cookie.")):(console.log("Could not restore previous session:-"),console.log(JSON.stringify(s.data)))}catch(e){console.log("Could not restore previous session (error state):-"),console.log(e),console.log(JSON.stringify(e))}}return null!==e?(B(this,U,"f").call(this,e.id_token),console.log("Refreshing tokens ..."),B(this,x,"f").call(this)):(B(this,U,"f").call(this,null),!1)})),W.set(this,(async()=>{console.log("Authorize ...");const e=process.env.CLIENT_ID,t=B(this,k,"f").CreateRandomString(),s=[y.CODE],o=process.env.REDIRECT_URI,r=T.QUERY,n=process.env.SCOPE,a=B(this,k,"f").CreateRandomString(),i=B(this,k,"f").CreateRandomString(),c={client_id:e,nonce:t,response_type:s,redirect_uri:o,response_mode:r,scope:n,state:a,code_challenge:await B(this,k,"f").DigestMessage(i),code_challenge_method:"S256"},l=`${process.env.AUTH_ENDPOINT}:${process.env.AUTH_PORT}${process.env.AUTH_APIROOT}?${B(this,C,"f").CreateQueryParams(c)}`;return console.log(l),c.code_verifier=i,console.log(`Authorize:authorizeOptions: [${JSON.stringify(c)}]`),{url:l,authorizeOptions:c}})),G.set(this,(async e=>{const t=e.queryVars,s=e.authorizeOptions;if(console.log("HandleRedirect"),console.log(`HandleRedirect:Query Vars: [${JSON.stringify(t)}]`),t[i.OAuth2ParameterType.CODE]){const e=t;console.log(`authorizeOptions from transaction state: [${JSON.stringify(s)}]`);const o=e.state;return 0===s.state.localeCompare(o)?(console.log("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"),await B(this,K,"f").call(this,s,e)):(console.log("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"),B(this,M,"f").call(this,{message:"State un-matched"}),!1)}if(t[i.OAuth2ParameterType.ERROR]){const e=t;return e.error,e.error_description,B(this,M,"f").call(this,{message:"State un-matched"}),!1}return B(this,M,"f").call(this,{message:"State un-matched"}),!1})),H.set(this,(async e=>{console.log("#GetTokenFromBroker"),B(this,I,"f").remove(B(this,N,"f"));const t=`${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/token`;console.log(`#GetTokenFromBroker:url = [${t}]`),console.log(e);try{const s=await a()({method:"post",url:t,data:e,withCredentials:!0,timeout:parseInt(process.env.TIMEOUT)});if(console.log(`retVal: ${JSON.stringify(s)}`),s.status===_.W.OK){console.log("Storing tokens...");const e=s.data;return B(this,U,"f").call(this,e.id_token),B(this,I,"f").set(B(this,N,"f"),e),!0}return s.status===_.W.UNAUTHORIZED?(console.log("NOT Storing tokens..."),console.log(s.status),B(this,U,"f").call(this,null),s.data,!1):(console.log("NOT Storing tokens..."),console.log(s.status),B(this,U,"f").call(this,null),console.log("Could not obtain access_token from token end-point:-"),console.log(JSON.stringify(s.data)),!1)}catch(e){return B(this,U,"f").call(this,null),console.log(e),console.log(JSON.stringify(e)),!1}})),K.set(this,(async(e,t)=>{console.log("#GetToken"),console.log(t),B(this,I,"f").set(B(this,N,"f"),null);const s={client_id:process.env.CLIENT_ID,scope:process.env.SCOPE,code:t.code,redirect_uri:process.env.REDIRECT_URI,grant_type:v.AUTHORIZATION_CODE,code_verifier:e.code_verifier};return B(this,H,"f").call(this,s)})),x.set(this,(async()=>{console.log("RefreshToken");const e=B(this,I,"f").get(B(this,N,"f"));if(e){const t={client_id:process.env.CLIENT_ID,scope:process.env.SCOPE,refresh_token:e.refresh_token,grant_type:v.REFRESH_TOKEN};return B(this,H,"f").call(this,t)}return!1})),J.set(this,(async()=>{console.log("Logout");const e=`${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/logout`;console.log(e);const t=B(this,I,"f").get(B(this,N,"f")).refresh_token;console.log(t);const s=(0,h.Z)(t);console.log(s);const o=s.sts_session;console.log(o),B(this,I,"f").remove(B(this,N,"f")),B(this,U,"f").call(this,null);try{const t=await a()({method:"post",url:e,data:{sessionId:o},withCredentials:!0,timeout:parseInt(process.env.TIMEOUT)});return t.data.status===_.W.OK||(console.log("Error during logout (server side)"),console.log(JSON.stringify(t.data)),!1)}catch(e){return console.log("Error during logout (server side)"),console.log(e),console.log(JSON.stringify(e)),!1}})),j(this,I,new R({clientStorageType:g.MEMORY_STORAGE}).GetStorage(),"f"),j(this,U,(e=>{const t={messageId:-1,command:S.AUTHENTICATE_EVENT};B(this,D,"f").call(this,t,e)}),"f"),j(this,M,(e=>{const t={messageId:-1,command:S.ERROR};B(this,D,"f").call(this,t,e)}),"f"),j(this,b,e,"f"),this.SetupListener()}}I=new WeakMap,k=new WeakMap,C=new WeakMap,A=new WeakMap,N=new WeakMap,P=new WeakMap,M=new WeakMap,U=new WeakMap,b=new WeakMap,$=new WeakMap,D=new WeakMap,L=new WeakMap,W=new WeakMap,G=new WeakMap,H=new WeakMap,K=new WeakMap,x=new WeakMap,J=new WeakMap;let Q=null;onmessage=async function(e){const t=e.data;Q=new z(t)}}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return s[e].call(n.exports,n,n.exports,r),n.exports}r.m=s,r.x=()=>{var e=r.O(void 0,[311],(()=>r(9384)));return r.O(e)},e=[],r.O=(t,s,o,n)=>{if(!s){var a=1/0;for(h=0;h<e.length;h++){for(var[s,o,n]=e[h],i=!0,c=0;c<s.length;c++)(!1&n||a>=n)&&Object.keys(r.O).every((e=>r.O[e](s[c])))?s.splice(c--,1):(i=!1,n<a&&(a=n));if(i){e.splice(h--,1);var l=o();void 0!==l&&(t=l)}}return t}n=n||0;for(var h=e.length;h>0&&e[h-1][2]>n;h--)e[h]=e[h-1];e[h]=[s,o,n]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((t,s)=>(r.f[s](e,t),t)),[])),r.u=e=>e+".index.js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var s=t.getElementsByTagName("script");s.length&&(e=s[s.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),(()=>{var e={384:1};r.f.i=(t,s)=>{e[t]||importScripts(r.p+r.u(t))};var t=self.webpackChunkstsoauth2plugin=self.webpackChunkstsoauth2plugin||[],s=t.push.bind(t);t.push=t=>{var[o,n,a]=t;for(var i in n)r.o(n,i)&&(r.m[i]=n[i]);for(a&&a(r);o.length;)e[o.pop()]=1;s(t)}})(),t=r.x,r.x=()=>r.e(311).then(t);var n=r.x();stsoauth2plugin=n})();
1
+ var e,t,s={9384:(e,t,s)=>{var o=s(1227),r=s.n(o),n=s(9669),a=s.n(n),i=s(7557);var c,l,h=s(6245),u=s(6378),p=function(e,t,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(e):o?o.value:t.get(e)},f=function(e,t,s,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,s):r?r.value=s:t.set(e,s),s};const d=r()(`proc:${process.pid}:storage.ts`);var g;!function(e){e.LOCAL_STORAGE="LocalStorage",e.SESSION_STORAGE="SessionStorage",e.COOKIE_STORAGE="CookieStorage",e.MEMORY_STORAGE="MemoryStorage"}(g||(g={}));class m{constructor(){this.get=e=>{const t=u.get(e);return t?JSON.parse(t):null},this.set=(e,t,s={})=>{let o={};"https:"===window.location.protocol&&(o={secure:!0,sameSite:"none"}),s&&s.daysUntilExpire?o.expires=s.daysUntilExpire:o.expires=1,d(`CookieStorage.set: key: ${e}, value: [${t}]`),u.set(e,JSON.stringify(t),o)},this.remove=e=>{u.remove(e)}}}class O{constructor(){this.get=e=>{const t=sessionStorage.getItem(e);return null==t?null:JSON.parse(t)},this.set=(e,t)=>{d(`SessionStorage.set: key: ${e}, value: [${t}]`),sessionStorage.setItem(e,JSON.stringify(t))},this.remove=e=>{sessionStorage.removeItem(e)}}}class E{constructor(){this.get=e=>{const t=localStorage.getItem(e);return null==t?null:JSON.parse(t)},this.set=(e,t)=>{d(`LocalStorage.set: key: ${e}, value: [${t}]`),localStorage.setItem(e,JSON.stringify(t))},this.remove=e=>{localStorage.removeItem(e)}}}class R{constructor(){c.set(this,{}),this.get=e=>{const t=p(this,c,"f")[e];return null==t?null:t},this.set=(e,t)=>{d(`MemoryStorage.set: key: ${e}, value: [${t}]`),p(this,c,"f")[e]=t},this.remove=e=>{delete p(this,c,"f")[e]}}}c=new WeakMap;class w{constructor(e){switch(l.set(this,null),e.clientStorageType){case g.SESSION_STORAGE:f(this,l,new O,"f");break;case g.LOCAL_STORAGE:f(this,l,new E,"f");break;case g.COOKIE_STORAGE:f(this,l,new m,"f");break;case g.MEMORY_STORAGE:f(this,l,new R,"f");break;default:throw new Error(`Unknown [${e.clientStorageType}] storage type.`)}}GetStorage(){return p(this,l,"f")}}l=new WeakMap;var y,T,S,v,_=s(6647);!function(e){e.CODE="code",e.ID_TOKEN="id_token",e.TOKEN="token"}(y||(y={})),function(e){e.QUERY="query",e.FRAGMENT="fragment",e.FORM_POST="form_post"}(T||(T={})),function(e){e.CLIENT_CREDENTIALS="client_credentials",e.AUTHORIZATION_CODE="authorization_code",e.REFRESH_TOKEN="refresh_token"}(S||(S={})),function(e){e.RESTORE_SESSION="RestoreSession",e.AUTHORIZE="Authorize",e.HANDLE_REDIRECT="HandleRedirect",e.LOGOUT="Logout",e.AUTHENTICATE_EVENT="AuthenticateEvent",e.ERROR="Error"}(v||(v={}));var I,k,C,A,N,P,M,U,b,$,D,L,W,G,H,K,x,J,j=function(e,t,s,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,s):r?r.value=s:t.set(e,s),s},z=function(e,t,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(e):o?o.value:t.get(e)};r()(`proc:${process.pid}:stsoauth2worker.ts`);class B{constructor(e){I.set(this,null),k.set(this,new class{constructor(){this.DigestMessage=async function(e){const t=(new TextEncoder).encode(e),s=await crypto.subtle.digest("SHA-256",t),o=Array.from(new Uint8Array(s));return btoa(String.fromCharCode(...o))},this.CreateRandomString=(e=43)=>{const t=Array.from(crypto.getRandomValues(new Uint8Array(e)));return btoa(String.fromCharCode(...t))},this.CreateRandomStringEx=()=>{const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let t="";return Array.from(crypto.getRandomValues(new Uint8Array(43))).forEach((s=>t+=e[s%e.length])),t}}}),C.set(this,new class{constructor(){this.DecodeQueryParams=e=>{const t={};return Object.keys(e).filter((t=>void 0!==e[t])).map((s=>{t[decodeURIComponent(s)]=decodeURIComponent(e[s])})),t},this.CreateQueryParams=e=>Object.keys(e).filter((t=>void 0!==e[t])).map((t=>Array.isArray(e[t])?encodeURIComponent(t)+"="+encodeURIComponent(e[t].join(" ")):encodeURIComponent(t)+"="+encodeURIComponent(e[t]))).join("&"),this._GetQueryParams=e=>{let t={};const s=e.split("?");if(2==s.length){const e=s[1].split("&"),o={};let r="";e.forEach((function(e){r=e.split("="),2==r.length&&(o[r[0]]=r[1])})),t=this.DecodeQueryParams(o)}return t},this.GetQueryParams=()=>this._GetQueryParams(window.location.href)}}),A.set(this,"authorize_options.stsmda.com.au"),N.set(this,"session.stsmda.com.au"),P.set(this,null),M.set(this,null),U.set(this,null),b.set(this,null),$.set(this,0),this.SetupListener=()=>{z(this,b,"f").onmessage=async e=>{const t=e.data;switch(t.command){case v.RESTORE_SESSION:z(this,D,"f").call(this,t,await z(this,L,"f").call(this));break;case v.AUTHORIZE:z(this,D,"f").call(this,t,await z(this,W,"f").call(this));break;case v.HANDLE_REDIRECT:z(this,D,"f").call(this,t,await z(this,G,"f").call(this,t.payload));break;case v.LOGOUT:z(this,D,"f").call(this,t,await z(this,J,"f").call(this));break;default:throw new Error(`Command: [${t.command}'] not found.`)}}},D.set(this,(async(e,t)=>{const s={messageId:e.messageId,command:e.command,payload:t};z(this,b,"f").postMessage(s)})),L.set(this,(async()=>{let e=null;if(e=z(this,I,"f").get(z(this,N,"f")),null!==e)console.log("Session restored from client storage."),z(this,P,"f")&&z(this,P,"f").UpdateInstrument("m",{LogMessage:"Session restored from client storage."});else{const t=`${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/session`;console.log("RestoreSession"),console.log(t),z(this,P,"f")&&(z(this,P,"f").UpdateInstrument("m",{LogMessage:"RestoreSession"}),z(this,P,"f").UpdateInstrument("m",{LogMessage:t}));try{const s=await a()({method:"post",url:t,data:{[i.OAuth2ParameterType.CLIENT_ID]:process.env.CLIENT_ID,[i.OAuth2ParameterType.SCOPE]:process.env.SCOPE,[i.OAuth2ParameterType.REDIRECT_URI]:process.env.REDIRECT_URI,[i.OAuth2ParameterType.AUDIENCE]:process.env.AUDIENCE},withCredentials:!0,timeout:parseInt(process.env.TIMEOUT)});s.data.status===_.W.OK?(e=s.data.detail,z(this,I,"f").set(z(this,N,"f"),e),console.log("Session restored from server side cookie.")):(console.log("Could not restore previous session:-"),console.log(JSON.stringify(s.data)))}catch(e){console.log("Could not restore previous session (error state):-"),console.log(e),console.log(JSON.stringify(e))}}return null!==e?(z(this,U,"f").call(this,e.id_token),console.log("Refreshing tokens ..."),z(this,x,"f").call(this)):(z(this,U,"f").call(this,null),!1)})),W.set(this,(async()=>{console.log("Authorize ...");const e=process.env.CLIENT_ID,t=z(this,k,"f").CreateRandomString(),s=[y.CODE],o=process.env.REDIRECT_URI,r=T.QUERY,n=process.env.SCOPE,a=z(this,k,"f").CreateRandomString(),i=z(this,k,"f").CreateRandomString(),c={client_id:e,nonce:t,response_type:s,redirect_uri:o,response_mode:r,scope:n,state:a,code_challenge:await z(this,k,"f").DigestMessage(i),code_challenge_method:"S256"},l=`${process.env.AUTH_ENDPOINT}:${process.env.AUTH_PORT}${process.env.AUTH_APIROOT}?${z(this,C,"f").CreateQueryParams(c)}`;return console.log(l),c.code_verifier=i,console.log(`Authorize:authorizeOptions: [${JSON.stringify(c)}]`),{url:l,authorizeOptions:c}})),G.set(this,(async e=>{const t=e.queryVars,s=e.authorizeOptions;if(console.log("HandleRedirect"),console.log(`HandleRedirect:Query Vars: [${JSON.stringify(t)}]`),t[i.OAuth2ParameterType.CODE]){const e=t;console.log(`authorizeOptions from transaction state: [${JSON.stringify(s)}]`);const o=e.state;return 0===s.state.localeCompare(o)?(console.log("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"),await z(this,K,"f").call(this,s,e)):(console.log("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"),z(this,M,"f").call(this,{message:"State un-matched"}),!1)}if(t[i.OAuth2ParameterType.ERROR]){const e=t;return e.error,e.error_description,z(this,M,"f").call(this,{message:"State un-matched"}),!1}return z(this,M,"f").call(this,{message:"State un-matched"}),!1})),H.set(this,(async e=>{console.log("#GetTokenFromBroker"),z(this,I,"f").remove(z(this,N,"f"));const t=`${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/token`;console.log(`#GetTokenFromBroker:url = [${t}]`),console.log(e);try{const s=await a()({method:"post",url:t,data:e,withCredentials:!0,timeout:parseInt(process.env.TIMEOUT)});if(console.log(`retVal: ${JSON.stringify(s)}`),s.status===_.W.OK){console.log("Storing tokens...");const e=s.data;return z(this,U,"f").call(this,e.id_token),z(this,I,"f").set(z(this,N,"f"),e),!0}return s.status===_.W.UNAUTHORIZED?(console.log("NOT Storing tokens..."),console.log(s.status),z(this,U,"f").call(this,null),s.data,!1):(console.log("NOT Storing tokens..."),console.log(s.status),z(this,U,"f").call(this,null),console.log("Could not obtain access_token from token end-point:-"),console.log(JSON.stringify(s.data)),!1)}catch(e){return z(this,U,"f").call(this,null),console.log(e),console.log(JSON.stringify(e)),!1}})),K.set(this,(async(e,t)=>{console.log("#GetToken"),console.log(t),z(this,I,"f").set(z(this,N,"f"),null);const s={client_id:process.env.CLIENT_ID,scope:process.env.SCOPE,code:t.code,redirect_uri:process.env.REDIRECT_URI,grant_type:S.AUTHORIZATION_CODE,code_verifier:e.code_verifier};return z(this,H,"f").call(this,s)})),x.set(this,(async()=>{console.log("RefreshToken");const e=z(this,I,"f").get(z(this,N,"f"));if(e){const t={client_id:process.env.CLIENT_ID,scope:process.env.SCOPE,refresh_token:e.refresh_token,grant_type:S.REFRESH_TOKEN};return z(this,H,"f").call(this,t)}return!1})),J.set(this,(async()=>{console.log("Logout");const e=`${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/logout`;console.log(e);const t=z(this,I,"f").get(z(this,N,"f")).refresh_token;console.log(t);const s=(0,h.Z)(t);console.log(s);const o=s.sts_session;console.log(o),z(this,I,"f").remove(z(this,N,"f")),z(this,U,"f").call(this,null);try{const t=await a()({method:"post",url:e,data:{sessionId:o},withCredentials:!0,timeout:parseInt(process.env.TIMEOUT)});return t.data.status===_.W.OK||(console.log("Error during logout (server side)"),console.log(JSON.stringify(t.data)),!1)}catch(e){return console.log("Error during logout (server side)"),console.log(e),console.log(JSON.stringify(e)),!1}})),j(this,I,new w({clientStorageType:g.MEMORY_STORAGE}).GetStorage(),"f"),j(this,U,(e=>{const t={messageId:-1,command:v.AUTHENTICATE_EVENT};z(this,D,"f").call(this,t,e)}),"f"),j(this,M,(e=>{const t={messageId:-1,command:v.ERROR};z(this,D,"f").call(this,t,e)}),"f"),j(this,b,e,"f"),this.SetupListener()}}I=new WeakMap,k=new WeakMap,C=new WeakMap,A=new WeakMap,N=new WeakMap,P=new WeakMap,M=new WeakMap,U=new WeakMap,b=new WeakMap,$=new WeakMap,D=new WeakMap,L=new WeakMap,W=new WeakMap,G=new WeakMap,H=new WeakMap,K=new WeakMap,x=new WeakMap,J=new WeakMap;let Q=null;onmessage=async function(e){const t=e.data;Q=new B(t)}}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return s[e].call(n.exports,n,n.exports,r),n.exports}r.m=s,r.x=()=>{var e=r.O(void 0,[311],(()=>r(9384)));return r.O(e)},e=[],r.O=(t,s,o,n)=>{if(!s){var a=1/0;for(h=0;h<e.length;h++){for(var[s,o,n]=e[h],i=!0,c=0;c<s.length;c++)(!1&n||a>=n)&&Object.keys(r.O).every((e=>r.O[e](s[c])))?s.splice(c--,1):(i=!1,n<a&&(a=n));if(i){e.splice(h--,1);var l=o();void 0!==l&&(t=l)}}return t}n=n||0;for(var h=e.length;h>0&&e[h-1][2]>n;h--)e[h]=e[h-1];e[h]=[s,o,n]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((t,s)=>(r.f[s](e,t),t)),[])),r.u=e=>e+".index.js",r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e;if("string"==typeof import.meta.url&&(e=import.meta.url),!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),(()=>{var e={384:1};r.f.i=(t,s)=>{e[t]||importScripts(r.p+r.u(t))};var t=self.webpackChunk_nsshunt_stsoauth2plugin=self.webpackChunk_nsshunt_stsoauth2plugin||[],s=t.push.bind(t);t.push=t=>{var[o,n,a]=t;for(var i in n)r.o(n,i)&&(r.m[i]=n[i]);for(a&&a(r);o.length;)e[o.pop()]=1;s(t)}})(),t=r.x,r.x=()=>r.e(311).then(t),r.x();