1import{d as Ue,r,c as ie,w as Q,o as Ie,X as Ke,Z as ze,D as He,K as ke,B as n,k as we,G as l,u as s,z as _,E as D,Q as R,$ as xe,F as U,W as X,Y,_ as We,C as v}from"./vendor-vue-Dzwqm9Y9.js";import"./AppHeader.vue_vue_type_style_index_0_scoped_25b0c839_lang-B0lsvCqV.js";import{u as $e,a as je,s as Ae,v as Ce,L as Ge,U as Qe,T as Xe,f as re,$ as Fe,W as Ye,D as Ze}from"./index-Dg7iAOYr.js";import"./vendor-misc-B-nM3tYW.js";import"./useClipboard-DI2IZ1WO.js";/* empty css */import{A as Je}from"./AuthLayout-z7fxUHCk.js";import{P as et}from"./PendingOAuthCreateAccountForm-CA04567l.js";import{c as Z,l as Te,o as Se}from"./oauthAffiliate-CrlUwkd1.js";import{u as tt}from"./vendor-i18n-BuoWFzps.js";import"./CaptchaChallenge.vue_vue_type_script_setup_true_lang-CcmCoDPI.js";const at={class:"space-y-6"},ot={class:"text-center"},nt={class:"text-2xl font-bold text-gray-900 dark:text-white"},st={class:"mt-2 text-sm text-gray-500 dark:text-dark-400"},it={key:0,class:"space-y-4"},rt={key:0,class:"rounded-xl border border-gray-200 bg-gray-50 p-4 dark:border-dark-600 dark:bg-dark-800/60"},lt={class:"space-y-3"},ut={class:"space-y-1"},ct={class:"text-sm font-medium text-gray-900 dark:text-white"},dt={class:"text-xs text-gray-500 dark:text-dark-400"},vt={key:0,class:"flex items-start gap-3 rounded-lg border border-gray-200 bg-white p-3 text-sm dark:border-dark-600 dark:bg-dark-900/50"},ht={class:"space-y-1"},_t={class:"block font-medium text-gray-900 dark:text-white"},pt={class:"block text-gray-500 dark:text-dark-400"},gt={key:1,class:"flex items-start gap-3 rounded-lg border border-gray-200 bg-white p-3 text-sm dark:border-dark-600 dark:bg-dark-900/50"},ft=["src","alt"],mt={class:"space-y-1"},bt={class:"block font-medium text-gray-900 dark:text-white"},yt={class:"block break-all text-gray-500 dark:text-dark-400"},kt={class:"text-sm text-gray-700 dark:text-gray-300"},wt=["placeholder","disabled"],xt=["disabled"],At={class:"text-sm text-gray-700 dark:text-gray-300"},Ct=["disabled"],Ft={key:3,class:"rounded-xl border border-gray-200 bg-gray-50 p-4 dark:border-dark-600 dark:bg-dark-800/60"},Tt={class:"space-y-4"},St={class:"space-y-1"},Pt={class:"text-sm font-medium text-gray-900 dark:text-white"},Nt={class:"text-xs text-gray-500 dark:text-dark-400"},qt={class:"grid gap-3 sm:grid-cols-2"},Dt=["disabled"],Rt=["disabled"],Lt={class:"text-sm text-gray-700 dark:text-gray-300"},Et={class:"text-sm text-gray-700 dark:text-gray-300"},Bt={class:"space-y-3"},Ot=["placeholder","disabled"],Vt=["placeholder","disabled"],Mt=["disabled"],Ut=["disabled"],It={class:"text-sm text-gray-700 dark:text-gray-300"},Kt={class:"space-y-3"},zt=["disabled"],Ht=["disabled"],Wt=Ue({__name:"OidcCallbackView",setup($t){const le=Ke(),I=ze(),{t:o}=tt(),L=$e(),y=je(),h=r(!0),K=r(""),k=r(!1),T=r(""),i=r(!1),J=r(""),E=r("/dashboard"),p=r("OIDC"),ee=r(!1),B=r(""),P=r(""),z=r(!0),H=r(!0),w=r(!1),g=r("none"),x=r(""),f=r(""),S=r(""),te=r(""),m=r(""),N=r(!1),Pe=o("profile.authBindings.bindSuccess"),W=r(!1),$=r(""),q=r(""),O=r(""),ae=r(""),ue=ie(()=>g.value==="create_account"),ce=ie(()=>g.value==="choose_account_action"),de=ie(()=>g.value==="bind_login");Q(J,e=>{e&&y.showError(e)}),Q(m,e=>{e&&y.showError(e)}),Q(O,e=>{e&&y.showError(e)}),Q(K,e=>{e&&y.showError(e)});function A(e){L.setPendingAuthSession({token:"",token_field:"pending_oauth_token",provider:"oidc",redirect:V(e||E.value)})}function ve(){L.clearPendingAuthSession()}function Ne(){const e=typeof window<"u"?window.location.hash:"",t=e.startsWith("#")?e.slice(1):e;return new URLSearchParams(t)}function qe(e){var F,d,b,ye;const t=((F=e.get("access_token"))==null?void 0:F.trim())||"";if(!t)return null;const a={access_token:t},u=((d=e.get("refresh_token"))==null?void 0:d.trim())||"";u&&(a.refresh_token=u);const c=Number.parseInt(((b=e.get("expires_in"))==null?void 0:b.trim())||"",10);Number.isFinite(c)&&c>0&&(a.expires_in=c);const C=((ye=e.get("token_type"))==null?void 0:ye.trim())||"";return C&&(a.token_type=C),a}function V(e){return!e||!e.startsWith("/")||e.startsWith("//")||e.includes("://")||e.includes(` 2`)||e.includes("\r")?"/dashboard":e}async function De(){var e;try{const a=(e=(await Ge()).oidc_oauth_provider_name)==null?void 0:e.trim();a&&(p.value=a)}catch{}}function j(){return{adoptDisplayName:z.value,adoptAvatar:H.value}}function oe(e){const t={};return typeof e.adoptDisplayName=="boolean"&&(t.adopt_display_name=e.adoptDisplayName),typeof e.adoptAvatar=="boolean"&&(t.adopt_avatar=e.adoptAvatar),t}function he(e){ee.value=e.adoption_required===!0,B.value=e.suggested_display_name||"",P.value=e.suggested_avatar_url||"",B.value||(z.value=!1),P.value||(H.value=!1)}function Re(e){return!!(e.suggested_display_name||e.suggested_avatar_url)}function Le(e){return(e==null?void 0:e.trim().toLowerCase())||""}function Ee(e){return(e.pending_email||e.existing_account_email||e.compat_email||e.resolved_email||e.email||e.suggested_email||"").trim()}function Be(e){const t=Le(e.step||e.error||e.intent);
2return t==="choice"||t==="choose_account_action_required"||t==="choose_account_action"||t==="choose_account"||t==="choose"?"choose_account_action":t==="email_required"||t==="create_account_required"||t==="create_account"?"create_account":t==="bind_login_required"||t==="bind_login"||t==="existing_account_binding_required"||t==="existing_account_required"||t==="adopt_existing_user_by_email"?"bind_login":"none"}function _e(e){const t=Be(e);g.value=t,m.value="",W.value=!1,$.value="",q.value="",O.value="",ae.value="";const a=Ee(e);if(t==="choose_account_action"){x.value=a,f.value=a,S.value="",N.value=!1;return}if(t==="create_account"){x.value=a,N.value=!0;return}if(t==="bind_login"){f.value=a,S.value="",N.value=!1;return}N.value=!1}function pe(e){return e.requires_2fa!==!0||!e.temp_token?!1:(g.value="none",k.value=!1,w.value=!1,W.value=!0,$.value=e.temp_token,q.value="",O.value="",ae.value=e.user_email_masked||"",h.value=!1,!0)}function ne(e){g.value="bind_login",f.value=f.value.trim()||(e==null?void 0:e.trim())||x.value.trim(),S.value="",m.value="",N.value=!0}function ge(){g.value="create_account",x.value=x.value.trim()||f.value.trim(),m.value=""}function M(e,t){var u,c,C,F;const a=e;return((c=(u=a.response)==null?void 0:u.data)==null?void 0:c.detail)||((F=(C=a.response)==null?void 0:C.data)==null?void 0:F.message)||a.message||t}function Oe(e){var u;const t=(u=e.response)==null?void 0:u.data,a=[t==null?void 0:t.reason,t==null?void 0:t.error,t==null?void 0:t.code,t==null?void 0:t.step,t==null?void 0:t.intent].map(c=>c==null?void 0:c.trim().toLowerCase()).filter(c=>!!c);return a.includes("email_exists")||a.includes("bind_login_required")||a.includes("bind_login")||a.includes("adopt_existing_user_by_email")||a.includes("existing_account_required")||a.includes("existing_account_binding_required")}async function fe(e,t){if(Qe(e)==="bind"){const a=V(e.redirect||"/profile");ve(),Z(),y.showSuccess(Pe),await I.replace(a);return}if(!Xe(e))throw new Error(o("auth.oidc.callbackMissingToken"));Ae(e),await L.setToken(e.access_token),Z(),y.showSuccess(o("auth.loginSuccess")),await I.replace(t)}async function G(e){he(e);const t=V(e.redirect||E.value);if(e.error==="invitation_required"){g.value="none",k.value=!0,w.value=!1,h.value=!1,A(t);return}if(pe(e)){A(t);return}if(_e(e),g.value!=="none"){k.value=!1,w.value=!1,h.value=!1,A(t);return}if(e.auth_result==="pending_session"){k.value=!1,w.value=!1,h.value=!1,A(t);return}await fe(e,t)}async function me(){var e,t;if(J.value="",!!T.value.trim()){i.value=!0;try{const a=Te(),u=j(),c=te.value?(await re.post("/auth/oauth/oidc/complete-registration",{pending_oauth_token:te.value,invitation_code:T.value.trim(),...Se(a),...oe(u)})).data:a?await Fe(T.value.trim(),u,a):await Fe(T.value.trim(),u);await G(c)}catch(a){const u=a;J.value=((t=(e=u.response)==null?void 0:e.data)==null?void 0:t.message)||u.message||o("auth.oidc.completeRegistrationFailed")}finally{i.value=!1}}}async function Ve(){i.value=!0;try{const e=await Ce(j());await G(e)}catch(e){K.value=M(e,o("auth.loginFailed")),w.value=!1}finally{i.value=!1}}async function Me(e){if(m.value="",!(!e.email||!e.password)){i.value=!0;try{const{data:t}=await re.post("/auth/oauth/pending/create-account",{email:e.email,password:e.password,verify_code:e.verifyCode||void 0,...e.turnstileToken?{turnstile_token:e.turnstileToken}:{},...e.tencentCaptchaTicket?{tencent_captcha_ticket:e.tencentCaptchaTicket,tencent_captcha_randstr:e.tencentCaptchaRandstr}:{},invitation_code:e.invitationCode||void 0,...Se(Te()),...oe(j())});await G(t)}catch(t){if(Oe(t)){ne(e.email.trim());return}m.value=M(t,o("auth.loginFailed"))}finally{i.value=!1}}}async function se(){m.value="";const e=f.value.trim(),t=S.value;if(!(!e||!t)){i.value=!0;try{const{data:a}=await re.post("/auth/oauth/pending/bind-login",{email:e,password:t,...oe(j())});await G(a)}catch(a){m.value=M(a,o("auth.loginFailed"))}finally{i.value=!1}}}async function be(){O.value="";const e=q.value.trim();if(!(!$.value||e.length!==6)){i.value=!0;try{const t=await Ye({temp_token:$.value,totp_code:e});await L.setToken(t.access_token),Z(),y.showSuccess(o("auth.loginSuccess")),await I.replace(E.value)}catch(t){O.value=M(t,o("auth.loginFailed"))}finally{i.value=!1}}}return Ie(async()=>{var F;De();const e=Ne(),t=qe(e),a=((F=e.get("pending_oauth_token"))==null?void 0:F.trim())||"",u=e.get("error"),c=e.get("error_description")||e.get("error_message")||"",C=V(e.get("redirect")||le.query.redirect||"/dashboard");try{if(t){Ae(t),await L.setToken(t.access_token),Z(),y.showSuccess(o("auth.loginSuccess")),await I.replace(C);return}if(u==="invitation_required"&&a){te.value=a,E.value=C,k.value=!0,h.value=!1;return}if(u){K.value=c||u,h.value=!1;return}const d=await Ce(),b=V(d.redirect||le.query.redirect||"/dashboard");if(he(d),E.value=b,d.error==="invitation_required"){k.value=!0,h.value=!1,A(b);return}if(pe(d)){A(b);return}if(_e(d),g.value!=="none"){h.value=!1,A(b);return}if(ee.value&&Re(d)){w.value=!0,h.value=!1,A(b);return}await fe(d,b)}catch(d){ve(),K.value=M(d,o("auth.loginFailed")),h.value=!1}}),(e,t)=>(v(),He(s(Je),null,{default:ke(()=>[n("div",at,[n("div",ot,[n("h2",nt,l(s(o)("auth.oidc.callbackTitle",{providerName:p.value})),1),n("p",st,l(h.value?s(o)("auth.oidc.callbackProcessing",{providerName:p.value}):s(o)("auth.oidc.callbackHint")),1)]),we(We,{name:"fade"},{default:ke(()=>[k.value||w.value||ce.value||ue.value||de.value||W.value?(v(),_("div",it,[ee.value&&(B.value||P.value)?(v(),_("div",rt,[n("div",lt,[n("div",ut,[n("p",ct,l(s(o)("auth.oauth
2Flow.profileDetailsTitle",{providerName:p.value})),1),n("p",dt,l(s(o)("auth.oauthFlow.profileDetailsDescription",{providerName:p.value})),1)]),B.value?(v(),_("label",vt,[R(n("input",{"onUpdate:modelValue":t[0]||(t[0]=a=>z.value=a),type:"checkbox",class:"mt-1 h-4 w-4"},null,512),[[xe,z.value]]),n("span",ht,[n("span",_t,l(s(o)("auth.oauthFlow.useDisplayName")),1),n("span",pt,l(B.value),1)])])):D("",!0),P.value?(v(),_("label",gt,[R(n("input",{"onUpdate:modelValue":t[1]||(t[1]=a=>H.value=a),type:"checkbox",class:"mt-1 h-4 w-4"},null,512),[[xe,H.value]]),n("img",{src:P.value,alt:s(o)("auth.oauthFlow.avatarAlt",{providerName:p.value}),class:"h-10 w-10 rounded-full border border-gray-200 object-cover dark:border-dark-600"},null,8,ft),n("span",mt,[n("span",bt,l(s(o)("auth.oauthFlow.useAvatar")),1),n("span",yt,l(P.value),1)])])):D("",!0)])])):D("",!0),k.value?(v(),_(U,{key:1},[n("p",kt,l(s(o)("auth.oidc.invitationRequired",{providerName:p.value})),1),n("div",null,[R(n("input",{"onUpdate:modelValue":t[2]||(t[2]=a=>T.value=a),type:"text",class:"input w-full",placeholder:s(o)("auth.invitationCodePlaceholder"),disabled:i.value,onKeyup:Y(me,["enter"])},null,40,wt),[[X,T.value]])]),n("button",{class:"btn btn-primary w-full",disabled:i.value||!T.value.trim(),onClick:me},l(i.value?s(o)("auth.oidc.completing"):s(o)("auth.oidc.completeRegistration")),9,xt)],64)):w.value?(v(),_(U,{key:2},[n("p",At,l(s(o)("auth.oauthFlow.reviewProfileBeforeContinue",{providerName:p.value})),1),n("button",{class:"btn btn-primary w-full",disabled:i.value,onClick:Ve},l(i.value?s(o)("common.processing"):s(o)("auth.continue")),9,Ct)],64)):ce.value?(v(),_("div",Ft,[n("div",Tt,[n("div",St,[n("p",Pt,l(s(o)("auth.oauthFlow.chooseHowToContinue")),1),n("p",Nt,l(x.value?s(o)("auth.oauthFlow.suggestedEmail",{email:x.value}):s(o)("auth.oauthFlow.chooseAccountActionHint")),1)]),n("div",qt,[n("button",{class:"btn btn-secondary w-full",disabled:i.value,onClick:t[3]||(t[3]=a=>ne())},l(s(o)("auth.oauthFlow.bindExistingAccount")),9,Dt),n("button",{class:"btn btn-primary w-full",disabled:i.value,onClick:ge},l(s(o)("auth.oauthFlow.createNewAccount")),9,Rt)])])])):ue.value?(v(),_(U,{key:4},[n("p",Lt,l(s(o)("auth.oauthFlow.createAccountHint")),1),we(et,{"test-id-prefix":"oidc","initial-email":x.value,"is-submitting":i.value,"error-message":m.value,onSubmit:Me,onSwitchToBind:ne},null,8,["initial-email","is-submitting","error-message"])],64)):de.value?(v(),_(U,{key:5},[n("p",Et,l(s(o)("auth.oauthFlow.bindLoginHint",{providerName:p.value})),1),n("div",Bt,[R(n("input",{"onUpdate:modelValue":t[4]||(t[4]=a=>f.value=a),"data-testid":"oidc-bind-login-email",type:"email",class:"input w-full",placeholder:s(o)("auth.emailPlaceholder"),disabled:i.value,onKeyup:Y(se,["enter"])},null,40,Ot),[[X,f.value]]),R(n("input",{"onUpdate:modelValue":t[5]||(t[5]=a=>S.value=a),"data-testid":"oidc-bind-login-password",type:"password",class:"input w-full",placeholder:s(o)("auth.passwordPlaceholder"),disabled:i.value,onKeyup:Y(se,["enter"])},null,40,Vt),[[X,S.value]]),n("button",{"data-testid":"oidc-bind-login-submit",class:"btn btn-primary w-full",disabled:i.value||!f.value.trim()||!S.value,onClick:se},l(i.value?s(o)("common.processing"):s(o)("auth.oauthFlow.logInAndBind")),9,Mt),N.value?(v(),_("button",{key:0,class:"btn btn-secondary w-full",disabled:i.value,onClick:ge},l(s(o)("auth.oauthFlow.useDifferentEmail")),9,Ut)):D("",!0)])],64)):W.value?(v(),_(U,{key:6},[n("p",It,l(s(o)("auth.oauthFlow.totpHint",{providerName:p.value,account:ae.value||s(o)("auth.oauthFlow.yourAccount")})),1),n("div",Kt,[R(n("input",{"onUpdate:modelValue":t[6]||(t[6]=a=>q.value=a),"data-testid":"oidc-bind-login-totp",type:"text",inputmode:"numeric",maxlength:"6",class:"input w-full",placeholder:"123456",disabled:i.value,onKeyup:Y(be,["enter"])},null,40,zt),[[X,q.value]]),n("button",{"data-testid":"oidc-bind-login-totp-submit",class:"btn btn-primary w-full",disabled:i.value||q.value.trim().length!==6,onClick:be},l(i.value?s(o)("common.processing"):s(o)("auth.oauthFlow.verifyAndContinue")),9,Ht)])],64)):D("",!0)])):D("",!0)]),_:1})])]),_:1}))}}),na=Ze(Wt,[["__scopeId","data-v-5265e524"]]);export{na 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.