@fntio/infra-client
Version:
Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.
5 lines (4 loc) • 20.8 kB
JavaScript
import{a as p}from"./chunk-J7PZFXOE.js";import{a as I,c as B}from"./chunk-KCJ5HNXP.js";import{a as Y,b as z,c as m}from"./chunk-ZRDXKVPG.js";import{C as H,F as c,I as a,R as d,Rb as K,g as x,j as U,k as $,qb as k,rb as V,s as j}from"./chunk-FYA6QUPZ.js";import{a as g,b as O,e as u}from"./chunk-WFIHWVQO.js";var h=class r{static SAFETY_MS=3e4;cache=new Map;key(e,t){return`${e}#${t}`}get(e,t){let i=this.key(e,t),s=this.cache.get(i);return s?new Date(s.expiration).getTime()-Date.now()<=r.SAFETY_MS?(this.cache.delete(i),null):s:null}set(e,t,i){this.cache.set(this.key(e,t),i)}peekExpiration(e,t){return this.cache.get(this.key(e,t))?.expiration??null}live(e){let t=[];for(let[i,s]of this.cache){if(new Date(s.expiration).getTime()<=e)continue;let n=i.indexOf("#");t.push({accountNumber:i.slice(0,n),role:i.slice(n+1),expiration:s.expiration})}return t}clear(e,t){this.cache.delete(this.key(e,t))}clearAll(){this.cache.clear()}static \u0275fac=function(t){return new(t||r)};static \u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})};var f="autoLogin:",T=class r{api=a(p);cache=a(h);bridge=a(m);inFlight=new Set;enabled=d(this.loadLocal());hydrated=!1;compound(e,t){return`${e}#${t}`}isEnabled(e,t){return this.enabled().has(this.compound(e,t))}hydrate(){return this.hydrated?x(void 0):this.api.getPreferences().pipe(H(e=>{this.hydrated=!0;let t=new Set;for(let i of e)i.autoVend&&t.add(this.compound(i.accountNumber,i.role));this.mirrorLocal(t),this.enabled.set(t)}),$(()=>{}),j(()=>x(void 0)))}setEnabled(e,t,i){let s=this.compound(e,t),n=new Set(this.enabled());i?n.add(s):n.delete(s),this.enabled.set(n),i?localStorage.setItem(f+s,"1"):localStorage.removeItem(f+s),this.api.setAutoVend(e,t,i).subscribe({error:()=>{}}),i&&this.prewarmRole(e,t)}prewarm(e){for(let t of e)for(let i of t.roles)this.isEnabled(t.accountNumber,i.role)&&this.prewarmRole(t.accountNumber,i.role)}prewarmRole(e,t){if(this.bridge.isDesktop)return;let i=this.compound(e,t);this.cache.get(e,t)||this.inFlight.has(i)||(this.inFlight.add(i),this.api.vendCredentials(e,t).subscribe({next:s=>{this.cache.set(e,t,s),this.inFlight.delete(i)},error:()=>this.inFlight.delete(i)}))}loadLocal(){let e=new Set;for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);i?.startsWith(f)&&localStorage.getItem(i)==="1"&&e.add(i.slice(f.length))}return e}mirrorLocal(e){let t=[];for(let i=0;i<localStorage.length;i++){let s=localStorage.key(i);s?.startsWith(f)&&!e.has(s.slice(f.length))&&t.push(s)}for(let i of t)localStorage.removeItem(i);for(let i of e)localStorage.setItem(f+i,"1")}static \u0275fac=function(t){return new(t||r)};static \u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})};function ve(r){return[`export AWS_ACCESS_KEY_ID=${r.accessKeyId}`,`export AWS_SECRET_ACCESS_KEY=${r.secretKey}`,`export AWS_SESSION_TOKEN=${r.sessionToken}`].join(`
`)}function ye(r,e){return[`[${e}]`,`aws_access_key_id = ${r.accessKeyId}`,`aws_secret_access_key = ${r.secretKey}`,`aws_session_token = ${r.sessionToken}`].join(`
`)}function Ae(r){return[`$Env:AWS_ACCESS_KEY_ID = "${r.accessKeyId}"`,`$Env:AWS_SECRET_ACCESS_KEY = "${r.secretKey}"`,`$Env:AWS_SESSION_TOKEN = "${r.sessionToken}"`].join(`
`)}function G(r,e){return`${r}-${e}`.toLowerCase().replace(/[^a-z0-9_-]/g,"-")}var w="profile:",C=class r{api=a(p);profiles=d(se());key(e,t){return`${e}#${t}`}resolved(e,t){let i=G(e,t);return this.profiles().get(this.key(e,t))??{name:i,source:"default",suggested:i}}profileName(e,t){return this.resolved(e,t).name}hydrateFrom(e){let t=new Map;for(let i of e)for(let s of i.roles)s.profileName&&t.set(this.key(i.accountNumber,s.role),{name:s.profileName,source:s.profileSource??"default",suggested:s.suggestedProfileName??s.profileName});this.profiles.set(t),J(t)}mergeFrom(e){let t=new Map(this.profiles());for(let i of e)for(let s of i.roles)s.profileName&&t.set(this.key(i.accountNumber,s.role),{name:s.profileName,source:s.profileSource??"default",suggested:s.suggestedProfileName??s.profileName});this.profiles.set(t)}setProfileName(e,t,i){let s=(i??"").trim(),n=this.resolved(e,t);if(!s||s===n.suggested){this.resetProfileName(e,t);return}this.update(e,t,{name:s,source:"override",suggested:n.suggested}),this.api.setProfileName(e,t,s).subscribe({error:()=>this.update(e,t,n)})}resetProfileName(e,t){let i=this.resolved(e,t);this.update(e,t,{name:i.suggested,source:i.source==="override"?"role":i.source,suggested:i.suggested}),this.api.clearProfileName(e,t).subscribe({error:()=>{}})}update(e,t,i){let s=new Map(this.profiles());s.set(this.key(e,t),i),this.profiles.set(s),J(s)}static \u0275fac=function(t){return new(t||r)};static \u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})};function se(){let r=new Map;try{for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(!t?.startsWith(w))continue;let i=localStorage.getItem(t);if(!i)continue;let s=JSON.parse(i);s?.name&&r.set(t.slice(w.length),s)}}catch{}return r}var re=200;function J(r){try{for(let e=localStorage.length-1;e>=0;e--){let t=localStorage.key(e);(t?.startsWith(w)||t?.startsWith("profileName:"))&&localStorage.removeItem(t)}if(r.size>re)return;for(let[e,t]of r)localStorage.setItem(w+e,JSON.stringify(t))}catch{}}var R=class r{api=a(p);cache=a(h);autoLogin=a(T);bridge=a(m);toast=a(B);personalization=a(C);writeFailWarned=new Set;renewFailWarned=new Set;static RENEW_BEFORE_MS=5*6e4;static RETRY_MIN_MS=3e4;static RETRY_MAX_MS=5*6e4;static VEND_TIMEOUT_MS=6e4;timers=new Map;inFlight=new Set;failures=new Map;ended=new Set;accounts=[];constructor(){this.bridge.onRenewAll(e=>this.renewAllNow(e)),this.bridge.isDesktop&&(this.bridge.onWake(()=>this.recheck()),window.addEventListener("online",()=>this.recheck()),document.addEventListener("visibilitychange",()=>{document.hidden||this.recheck()}))}key(e,t){return`${e}#${t}`}start(e){if(this.bridge.isDesktop){this.accounts=e,this.ended.clear();for(let t of this.keptFresh())this.vendWriteSchedule(t.account,t.role)}}stopAll(){for(let e of this.timers.values())clearTimeout(e);this.timers.clear(),this.inFlight.clear(),this.failures.clear(),this.renewFailWarned.clear(),this.ended.clear(),this.accounts=[]}recheck(){if(this.bridge.isDesktop)for(let{account:e,role:t}of this.keptFresh()){let i=this.key(e,t);if(this.inFlight.has(i)||this.ended.has(i))continue;let s=this.cache.get(e,t);s&&this.msLeft(s)>r.RENEW_BEFORE_MS?this.schedule(e,t,s):(this.clearTimer(e,t),this.cache.clear(e,t),this.vendWriteSchedule(e,t))}}renewAllNow(e){if(this.bridge.isDesktop)for(let t of e??this.keptFresh())this.ended.delete(this.key(t.account,t.role)),this.clearTimer(t.account,t.role),this.cache.clear(t.account,t.role),this.vendWriteSchedule(t.account,t.role)}keptFresh(){return this.accounts.flatMap(e=>e.roles.filter(t=>this.autoLogin.isEnabled(e.accountNumber,t.role)).map(t=>({account:e.accountNumber,role:t.role})))}onToggle(e,t,i){this.bridge.isDesktop&&(i?(this.ended.delete(this.key(e,t)),this.vendWriteSchedule(e,t)):this.clearTimer(e,t))}clearTimer(e,t){let i=this.key(e,t),s=this.timers.get(i);s&&(clearTimeout(s),this.timers.delete(i))}vendWriteSchedule(e,t){let i=this.key(e,t);if(this.inFlight.has(i)||this.timers.has(i))return;let s=this.cache.get(e,t);if(s&&this.msLeft(s)>r.RENEW_BEFORE_MS){this.writeAndSchedule(e,t,s);return}this.inFlight.add(i),this.api.vendCredentials(e,t,{background:!0}).pipe(U(r.VEND_TIMEOUT_MS)).subscribe({next:n=>{this.inFlight.delete(i),this.failures.delete(i),this.renewFailWarned.delete(i),this.cache.set(e,t,n),this.writeAndSchedule(e,t,n)},error:n=>{this.inFlight.delete(i),this.retryLater(e,t,n)}})}retryLater(e,t,i){let s=this.key(e,t),n=i?.status;if(n===401||n===403){this.ended.add(s);return}if(!this.autoLogin.isEnabled(e,t))return;let l=(this.failures.get(s)??0)+1;this.failures.set(s,l);let E=Math.min(r.RETRY_MIN_MS*2**(l-1),r.RETRY_MAX_MS);this.clearTimer(e,t),this.timers.set(s,setTimeout(()=>{this.timers.delete(s),this.vendWriteSchedule(e,t)},E)),l>=2&&!this.renewFailWarned.has(s)&&(this.renewFailWarned.add(s),this.toast.error(`Couldn't renew ${t} credentials \u2014 retrying in the background.`,{label:"Open Get credentials",path:`/accounts?vend=${e}:${encodeURIComponent(t)}`}))}writeAndSchedule(e,t,i){this.bridge.writeCredentials({accountNumber:e,role:t,profile:this.profileName(e,t),creds:i}).then(()=>this.writeFailWarned.delete(this.key(e,t))).catch(s=>{let n=this.key(e,t);if(this.writeFailWarned.has(n))return;this.writeFailWarned.add(n);let l=Y(s),E=z(s);this.toast.error(l?`Profile "${this.profileName(e,t)}" is already used by another connected backend.`:E?`Profile "${this.profileName(e,t)}" already exists in your ~/.aws/credentials and was not written by this app \u2014 rename it here.`:`Couldn't keep ${t} fresh in ~/.aws/credentials.`,{label:l||E?"Rename in Get credentials":"Open Get credentials",path:`/accounts?vend=${e}:${encodeURIComponent(t)}`})}),this.schedule(e,t,i)}schedule(e,t,i){if(this.clearTimer(e,t),!this.autoLogin.isEnabled(e,t))return;let s=this.key(e,t),n=Math.max(this.msLeft(i)-r.RENEW_BEFORE_MS,1e3),l=setTimeout(()=>{this.timers.delete(s),this.cache.clear(e,t),this.vendWriteSchedule(e,t)},n);this.timers.set(s,l)}msLeft(e){return new Date(e.expiration).getTime()-Date.now()}profileName(e,t){return this.personalization.profileName(e,t)}static \u0275fac=function(t){return new(t||r)};static \u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})};var ne="vendor/amazon-cognito-advanced-security-data.min.js";var P=null;function X(){return globalThis.AmazonCognitoAdvancedSecurityData}function q(){return X()?Promise.resolve():P||(typeof document>"u"?Promise.resolve():(P=new Promise(r=>{let e=()=>{clearTimeout(t),r()},t=setTimeout(e,3e3),i=document.createElement("script");i.src=new URL(ne,document.baseURI).toString(),i.async=!0,i.addEventListener("load",e),i.addEventListener("error",e),document.head.appendChild(i)}),P))}function Q(r,e,t){try{let i=X()?.getData(r,e,t);return i?{EncodedData:i}:void 0}catch{return}}var v=class extends Error{constructor(t,i){super(i);this.code=t}code},b=class r{configService=a(I);call(e,t){let{region:i}=this.configService.config;return fetch(`https://cognito-idp.${i}.amazonaws.com/`,{method:"POST",headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":`AWSCognitoIdentityProviderService.${e}`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)}).then(s=>u(this,null,function*(){let n=yield s.json().catch(()=>({}));if(!s.ok){let l=String(n.__type??"UnknownError").split("#").pop();throw new v(l,n.message??n.Message??l)}return n}))}context(e){return u(this,null,function*(){if(!e)return{};yield q();let{userPoolId:t,spaClientId:i}=this.configService.config,s=Q(e,t,i);return s?{UserContextData:s}:{}})}initiate(e){return u(this,null,function*(){return this.call("InitiateAuth",g({AuthFlow:"USER_AUTH",ClientId:this.configService.config.spaClientId,AuthParameters:e},yield this.context(e.USERNAME)))})}startSignIn(e){return this.initiate({USERNAME:e})}signInWithPassword(e,t){return this.initiate({USERNAME:e,PREFERRED_CHALLENGE:"PASSWORD",PASSWORD:t})}requestEmailCode(e){return this.initiate({USERNAME:e,PREFERRED_CHALLENGE:"EMAIL_OTP"})}startPasskeySignIn(e){return this.initiate({USERNAME:e,PREFERRED_CHALLENGE:"WEB_AUTHN"})}respondToChallenge(e,t,i){return u(this,null,function*(){return this.call("RespondToAuthChallenge",g({ClientId:this.configService.config.spaClientId,ChallengeName:e,Session:t,ChallengeResponses:i},yield this.context(i.USERNAME)))})}forgotPassword(e){return this.call("ForgotPassword",{ClientId:this.configService.config.spaClientId,Username:e})}confirmForgotPassword(e,t,i){return this.call("ConfirmForgotPassword",{ClientId:this.configService.config.spaClientId,Username:e,ConfirmationCode:t,Password:i})}refresh(e,t){return this.call("InitiateAuth",{AuthFlow:"REFRESH_TOKEN_AUTH",ClientId:t??this.configService.config.spaClientId,AuthParameters:{REFRESH_TOKEN:e}}).then(i=>i.AuthenticationResult)}revoke(e,t){return this.call("RevokeToken",{ClientId:t??this.configService.config.spaClientId,Token:e})}associateSoftwareToken(e){return this.call("AssociateSoftwareToken",g(g({},e.accessToken?{AccessToken:e.accessToken}:{}),e.session?{Session:e.session}:{}))}verifySoftwareToken(e,t){return this.call("VerifySoftwareToken",O(g(g({},e.accessToken?{AccessToken:e.accessToken}:{}),e.session?{Session:e.session}:{}),{UserCode:t}))}setTotpEnabled(e,t){return this.call("SetUserMFAPreference",{AccessToken:e,SoftwareTokenMfaSettings:{Enabled:t,PreferredMfa:t}})}totpEnabled(e){return this.call("GetUser",{AccessToken:e}).then(t=>(t.UserMFASettingList??[]).includes("SOFTWARE_TOKEN_MFA"))}listPasskeys(e){return this.call("ListWebAuthnCredentials",{AccessToken:e,MaxResults:20}).then(t=>t.Credentials??[])}startPasskeyRegistration(e){return this.call("StartWebAuthnRegistration",{AccessToken:e})}completePasskeyRegistration(e,t){return this.call("CompleteWebAuthnRegistration",{AccessToken:e,Credential:t})}deletePasskey(e,t){return this.call("DeleteWebAuthnCredential",{AccessToken:e,CredentialId:t})}static \u0275fac=function(t){return new(t||r)};static \u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})};var D="signIn.lastEmail",oe="signIn.method:",Z=r=>oe+r.trim().toLowerCase();function Ye(){return localStorage.getItem(D)??""}function ze(r){let e=localStorage.getItem(Z(r));return e==="passkey"||e==="password"||e==="email-code"||e==="sso"?e:null}function ee(r,e){localStorage.setItem(D,r.trim()),localStorage.setItem(Z(r),e)}function Be(){localStorage.removeItem(D)}var N="signIn.passkeysHere",M=r=>r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function F(){try{let r=JSON.parse(localStorage.getItem(N)??"[]");return Array.isArray(r)?r.filter(e=>typeof e=="string"):[]}catch{return[]}}function Ge(r){let e=new Set(F());e.add(M(r)),localStorage.setItem(N,JSON.stringify([...e]))}function Je(r){let e=F().filter(t=>t!==M(r));localStorage.setItem(N,JSON.stringify(e))}function Xe(r){let e=new Set(F());return r.some(t=>e.has(M(t)))}var ae="https://signin.aws.amazon.com/oauth?Action=logout",L="aws.consoleOpened",_=6e4,le=12,o={id:"auth.idToken",access:"auth.accessToken",refresh:"auth.refreshToken",expiresAt:"auth.expiresAt",client:"auth.clientId",sessionStartedAt:"auth.sessionStartedAt"},y="auth.redirect",te="auth.sessionEnded",A="auth.reauth",ie=class r{api=a(b);router=a(K);credsCache=a(h);autoVend=a(R);bridge=a(m);configService=a(I);claims=d(null);ready=d(!1);isAuthenticated=d(!1);sessionEndsAt=d(null);constructor(){this.bridge.isDesktop&&(V(()=>this.bridge.sessionEnds(this.sessionEndsAt())),this.bridge.onRenewSignIn(()=>{this.isAuthenticated()&&this.reauthenticate()}))}userEmail=k(()=>this.claims()?.email??"");userSub=k(()=>this.claims()?.sub??"");isFederatedSession=d(!1);isAdmin=k(()=>this.claims()?.["cognito:groups"]?.includes("admins")??!1);renewTimer=null;refreshing=null;readyResolvers=[];init(){let e=localStorage.getItem(o.id),t=Number(localStorage.getItem(o.expiresAt)),i=localStorage.getItem(o.refresh);if(document.addEventListener("visibilitychange",()=>{document.hidden||this.refreshIfStale()}),window.addEventListener("online",()=>{this.refreshIfStale()}),window.addEventListener("storage",s=>{s.key===o.refresh&&s.newValue===null&&this.isAuthenticated()&&(this.autoVend.stopAll(),this.credsCache.clearAll(),sessionStorage.setItem(te,this.atTheWall()?"expired":"elsewhere"),this.clearTokens(),this.goToLogin()),s.key===o.sessionStartedAt&&s.newValue!==null&&this.syncSessionEnd()}),this.isFederatedSession.set(localStorage.getItem(o.client)!==null),this.syncSessionEnd(),e&&Date.now()<t-_/2){this.claims.set(W(e)),this.isAuthenticated.set(!0),this.scheduleRenew(t),this.markReady();return}if(!i){this.markReady();return}this.refreshNow().finally(()=>this.markReady())}whenReady(){return this.ready()?Promise.resolve():new Promise(e=>this.readyResolvers.push(e))}markReady(){this.ready.set(!0),this.readyResolvers.splice(0).forEach(e=>e())}idToken(){return localStorage.getItem(o.id)}idTokenExpiresAt(){return Number(localStorage.getItem(o.expiresAt))||0}freshAccessToken(){return u(this,null,function*(){let e=Number(localStorage.getItem(o.expiresAt));return Date.now()>e-_&&(yield this.refreshNow()),localStorage.getItem(o.access)})}completeSignIn(e,t,i,s={}){ee(t,i);let n=localStorage.getItem(o.refresh),l=localStorage.getItem(o.client)??void 0;n&&n!==e.RefreshToken&&this.api.revoke(n,l).catch(()=>{}),sessionStorage.removeItem(A),s.federationClientId?localStorage.setItem(o.client,s.federationClientId):localStorage.removeItem(o.client),this.isFederatedSession.set(!!s.federationClientId),localStorage.setItem(o.sessionStartedAt,String(Date.now())),this.storeTokens(e)}reauthenticate(){let e=this.router.url;e&&e!=="/"&&!this.onSignInPage()&&sessionStorage.setItem(y,e),sessionStorage.setItem(A,"1"),this.router.navigateByUrl("/login")}reauthPending(){return sessionStorage.getItem(A)==="1"}atTheWall(){let e=this.sessionEndsAt();return e!==null&&Date.now()>=e-5*6e4}sessionHours(){return this.configService.config.sessionHours??le}syncSessionEnd(){if(!localStorage.getItem(o.refresh)){this.sessionEndsAt.set(null);return}let e=Number(localStorage.getItem(o.sessionStartedAt)),t=localStorage.getItem(o.id),i=t?W(t).auth_time:void 0,s=e>0?e:i?i*1e3:null;this.sessionEndsAt.set(s?s+this.sessionHours()*36e5:null)}refreshNow(){if(this.refreshing)return this.refreshing;let e=localStorage.getItem(o.refresh);return e?(this.refreshing=this.api.refresh(e,localStorage.getItem(o.client)??void 0).then(t=>localStorage.getItem(o.refresh)!==e?!1:(this.storeTokens(t),!0)).catch(t=>{let i=t instanceof v&&(t.code==="NotAuthorizedException"||t.code==="UserNotFoundException"),s=localStorage.getItem(o.refresh)!==e;return i&&!s?this.sessionGone():i||this.scheduleRenewIn(3e4),!1}).finally(()=>{this.refreshing=null}),this.refreshing):(this.isAuthenticated.set(!1),this.goToLogin(),Promise.resolve(!1))}refreshIfStale(){if(!this.isAuthenticated())return Promise.resolve(!1);let e=Number(localStorage.getItem(o.expiresAt));return Date.now()>e-_?this.refreshNow():Promise.resolve(!0)}storeTokens(e){let t=Date.now()+e.ExpiresIn*1e3;if(localStorage.setItem(o.id,e.IdToken),localStorage.setItem(o.access,e.AccessToken),e.RefreshToken&&localStorage.setItem(o.refresh,e.RefreshToken),localStorage.setItem(o.expiresAt,String(t)),this.claims.set(W(e.IdToken)),this.isAuthenticated.set(!0),this.syncSessionEnd(),this.scheduleRenew(t),this.onSignInPage()&&!this.reauthPending()){let i=sessionStorage.getItem(y);sessionStorage.removeItem(y);let s=i&&i.startsWith("/")&&!i.startsWith("//")?i:"/";this.router.navigateByUrl(s).catch(()=>{window.location.assign(s)})}}scheduleRenew(e){this.scheduleRenewIn(Math.max(e-_-Date.now(),5e3))}scheduleRenewIn(e){this.renewTimer&&clearTimeout(this.renewTimer),this.renewTimer=setTimeout(()=>this.refreshNow(),e)}clearTokens(){this.renewTimer&&clearTimeout(this.renewTimer),this.renewTimer=null;for(let e of Object.values(o))localStorage.removeItem(e);this.claims.set(null),this.isAuthenticated.set(!1),this.isFederatedSession.set(!1),this.sessionEndsAt.set(null)}sessionGone(){this.syncSessionEnd(),sessionStorage.setItem(te,this.atTheWall()?"expired":"invalid"),sessionStorage.removeItem(A),this.autoVend.stopAll(),this.credsCache.clearAll(),this.clearTokens(),this.toLogin().finally(()=>this.purgeDesktopCredentials())}toLogin(){let e=this.router.url;return e&&e!=="/"&&!this.onSignInPage()&&sessionStorage.setItem(y,e),this.goToLogin()}onSignInPage(){return this.router.url.startsWith("/login")||this.router.url.startsWith("/auth/callback")}goToLogin(){return this.onSignInPage()?Promise.resolve():this.router.navigateByUrl("/login").then(()=>{},()=>{this.router.navigated&&!this.isAuthenticated()&&window.location.assign("/login")})}logout(){this.autoVend.stopAll(),this.credsCache.clearAll();let e=localStorage.getItem(o.refresh);if(e&&this.api.revoke(e,localStorage.getItem(o.client)??void 0).catch(()=>{}),this.purgeDesktopCredentials(),this.clearTokens(),sessionStorage.removeItem(y),sessionStorage.removeItem(A),localStorage.getItem(L)===null){this.goToLogin();return}let t=window.open(ae,"_blank","popup,width=480,height=360");if(!t){this.bridge.isDesktop&&localStorage.removeItem(L),this.goToLogin();return}localStorage.removeItem(L),setTimeout(()=>{t.close(),this.goToLogin()},2e3)}purgeDesktopCredentials(){this.bridge.isDesktop&&this.bridge.logout().catch(()=>{})}static \u0275fac=function(t){return new(t||r)};static \u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})};function W(r){try{let e=r.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(e))}catch{return{}}}export{q as a,v as b,b as c,Ye as d,ze as e,ee as f,Be as g,Ge as h,Je as i,Xe as j,h as k,T as l,ve as m,ye as n,Ae as o,C as p,R as q,L as r,y as s,te as t,A as u,ie as v,W as w};