1import{m as T}from"./main.mixinBLnF4qNw.js";import{f,P as S,_ as A}from"./chunkReloadRecoveryrjuMb-b8.js";import{c as m,r as _,g as C}from"./authCallbackIssuerln68Th8H.js";import{d as b,a4 as l,b as o,o as n,j as r,w,e as u,z as c,n as L,l as g}from"./vue-runtimeBHGad_ZB.js";import"./refresh.storeCM69jM7x.js";import"./OperationQueueKzEpmh-u.js";import"./item-name.utilsBH3paGZr.js";import"./dexie2jmnBxhj.js";import"./item.typesx7Q7rrX9.js";import"./content.typesyje91KzF.js";import"./constantsDW26WJ6H.js";import"./extraction.pure.utilsDQPW8yIh.js";import"./url.utils3SlYVg-c.js";import"./file_utilsBvAXo0vA.js";import"./agentParentalGrantCz4Xs1Ac.js";import"./trackCl4T-c2s.js";import"./common.storeDJ22K8d0.js";import"./adminsite.storeDFHoYU-A.js";import"./modal.mixinD4dgi5bV.js";import"./browserTabsCpW6SD42.js";import"./scopedSettings39hV2RLq.js";import"./subscription.storeCcIX6Rgu.js";import"./bootstrap-vue-nextDXY4qsO1.js";import"./cjs-helpersC4iS2aBk.js";function k(e){return e?{serverBaseURLOverride:e}:{}}const I=b({name:"AuthTokenLogin",mixins:[T],data(){return{authSuccess:null,errorMessage:null,loading:!1,authToken:null,sessionToken:null,failToken:null,sourceId:null,timeleft:3}},mounted(){},computed:{},methods:{getRedirectServerHostname(e){return C(e||this.config.serverHostname,this.config.publicServerHostname)||this.config.serverHostname},getAppSigninHref(){return`${this.appPrefix}#/signin`},async closeExternalSigninSurfaceIfNeeded(){if(!(this.sourceId!=="app"||!this.isNativeClient))try{await S.sendAppRequest({action:"CLOSE_SIGNIN_WINDOW"})}catch(e){console.warn("Unable to close external sign-in surface after token login callback",e)}},async completeAppSuccess(){return this.sourceId!=="app"?!1:(this.isNativeClient&&!window.opener?(await this.closeExternalSigninSurfaceIfNeeded(),await this.countDown(2),await this.$router.replace("/")):window.location.href=this.appPrefix,!0)},async redirectAppAfterFailure(){return this.sourceId!=="app"?!1:(this.isNativeClient&&!window.opener?(await this.closeExternalSigninSurfaceIfNeeded(),await this.countDown(2),await this.$router.replace("/signin")):window.location.href=this.getAppSigninHref(),!0)},async getAuthCallbackServerContext(){return await _({sourceId:this.sourceId,sessionToken:this.sessionToken,failToken:this.failToken,queryServerBaseURL:this.$route.query.serverBaseURL,queryServerHostname:this.$route.query.serverHostname})},async reportProviderFailure(e,t){if(!(!this.sessionToken||!this.failToken))try{await this.typedSendReq("/auth/providerLogin/fail",{sessionToken:this.sessionToken,failToken:this.failToken,status:"failed",message:e},k(t))}catch(s){console.warn("Failed to persist token login failure state",s)}finally{await m(this.sessionToken)}},async countDown(e){for(this.timeleft=e;this.timeleft>0;)this.timeleft-=1,await new Promise(t=>window.setTimeout(t,1e3))},async loadTokenAuth(){var e,t;this.loading=!0;try{const s=await this.getAuthCallbackServerContext();f("[AUTH_CALLBACK][TOKEN_LOGIN][SERVER_CONTEXT]",{route:this.$route.fullPath,locationOrigin:typeof window<"u"&&((e=window.location)==null?void 0:e.origin)||null,locationHref:typeof window<"u"&&((t=window.location)==null?void 0:t.href)||null,sourceId:this.sourceId,hasAuthToken:!!this.authToken,hasSessionToken:!!this.sessionToken,hasFailToken:!!this.failToken,resolutionSource:s.resolutionSource,serverHostname:s.serverHostname,serverBaseURL:s.serverBaseURL});const i=await this.typedSendReq("/auth/tokenLogin",{token:this.authToken},k(s.serverBaseURL));if(i!=null&&i.success){if(await m(this.sessionToken),this.authSuccess=!0,this.loading=!1,this.sessionToken)this.sourceId==="app"?await this.completeAppSuccess():(await this.countDown(2),this.closeWindow());else{let a=this.$route.query.target||this.appPrefix;window.location.href=`${this.getRedirectServerHostname(s.serverHostname)}${a}`}return}else{const a=(i==null?void 0:i.message)||"Authentication failed. Please try again.";await this.reportProviderFailure(a,s.serverBaseURL),console.error("Error:",a),this.errorMessage=a,this.authSuccess=!1,this.loading=!1,this.sessionToken&&(await this.redirectAppAfterFailure()||(await this.countDown(2),this.closeWindow()));return}}catch(s){const i=s instanceof Error?s.message:"Authentication failed. Please try again.";await this.reportProviderFailure(i,(await this.getAuthCallbackServerContext()).serverBaseURL),this.errorMessage=i,this.authSuccess=!1,this.loading=!1,this.sessionToken&&(await this.redirectAppAfterFailure()||(await this.countDown(2),this.closeWindow()));return}this.loading=!1},closeWindow(){window.close()}},created(){var e,t;this.authToken=this.$route.query.token,this.sessionToken=this.$route.query.session,this.failToken=this.$route.query.failToken,this.sourceId=this.$route.query.sourceId,f("[AUTH_CALLBACK][TOKEN_LOGIN][ENTRY]",{route:this.$route.fullPath,locationOrigin:typeof window<"u"&&((e=window.location)==null?void 0:e.origin)||null,locationHref:typeof window<"u"&&((t=window.location)==null?void 0:t.href)||null,sourceId:this.sourceId,hasAuthToken:!!this.authToken,hasSessionToken:!!this.sessionToken,hasFailToken:!!this.failToken,hasQueryServerBaseURL:typeof this.$route.query.serverBaseURL=="str
1ing"&&!!this.$route.query.serverBaseURL,hasQueryServerHostname:typeof this.$route.query.serverHostname=="string"&&!!this.$route.query.serverHostname}),this.loadTokenAuth()}}),$={class:"text-center"},H={key:0,href:"/"},N=["href"],q={key:0,class:"d-flex justify-content-center"},P={key:0,class:"mt-2 small"},R={key:1},B={key:2},E={class:"mt-2"},U={key:0,class:"mt-4 small text-muted"},x={key:1,class:"mt-4"};function D(e,t,s,i,a,F){const h=l("AppLogo"),d=l("b-icon"),y=l("b-alert"),p=l("b-spinner"),v=l("b-container");return n(),o("div",$,[r(v,{class:"mt-5 justify-content-center"},{default:w(()=>[u("div",{class:L(["text-center",e.isMobile?"mt-3 mb-3":"mt-5 mb-5"])},[e.isBrowserMode?(n(),o("a",H,[r(h)])):(n(),o("a",{key:1,href:e.appPrefix},[r(h)],8,N))],2),!e.loading&&!e.authSuccess?(n(),o("div",q,[r(y,{variant:"danger",class:"mt-2","model-value":!0},{default:w(()=>[r(d,{icon:"exclamation-triangle"}),t[0]||(t[0]=u("span",{class:"ml-2"}," Authentication failed. Please try again.",-1)),e.errorMessage?(n(),o("div",P,g(e.errorMessage),1)):c("",!0)]),_:1})])):c("",!0),e.loading?(n(),o("div",R,[r(p,{style:{width:"3rem",height:"3rem"},label:"Loading current status...",variant:"primary"})])):c("",!0),!e.loading&&e.authSuccess?(n(),o("div",B,[u("div",E,[r(d,{icon:"check-circle-fill",class:"success-color"}),t[1]||(t[1]=u("span",{class:"ms-2"},"Authentication successful!",-1))]),e.sessionToken?(n(),o("div",U,g(e.sourceId==="app"&&e.isNativeClient?"Returning to the appâ¦":"You may close this window."),1)):(n(),o("div",x,[r(p,{style:{width:"3rem",height:"3rem"},label:"Loading app...",variant:"primary"})]))])):c("",!0)]),_:1})])}const he=A(I,[["render",D]]);export{he as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.