1import{dV as G,dq as J,dr as Q,d4 as m,d0 as e,dO as X}from"./index-DcjYXpHu.js";import{T as j,g as x,F as B,m as F}from"./ModalHeader-BYl15uiI-DnFK1y3B.js";import{F as Y}from"./ShieldCheckIcon-BZq3HaFR.js";import{t as Z,f as _,l as ee,i as te}from"./EnrollTotp-BO69q5na-BV65JIAr.js";import{a as oe,d as re,w as C,l as R,p as S,m as b}from"./PinInput-B8vD-umi-Csrtp7kA.js";import"./QrCode-C3Xo6IrX-0xQU8sXZ.js";import"./FingerPrintIcon-59mGwShM.js";import"./PhoneIcon-DhpaApHU.js";import"./Chip-DXYSoMJU-CvRSMqiR.js";import"./LoadingSkeleton-U6-3yFwI-BAb7OLe9.js";import"./ErrorScreen-CGuIgbqJ-U70Yykxe.js";import"./reservoir-CqMw4DDq-yJp8xiUO.js";import"./ScreenLayout-yWVsP0Du-ZFkenmxj.js";import"./Screen-DtggdpY6-GbMo0fLY.js";import"./index-Dq_xe9dz-8oG4tpdE.js";import"./triangle-alert-Bl4kcRNp.js";import"./createLucideIcon-BC3sYUb5.js";import"./lock-BSxZCLVp.js";import"./LinkPasskeyScreen-Du4Oqkvq-CJN8-v71.js";import"./TodoList-CgrU7uwu-C_VSiwTZ.js";import"./check-IAjUBUkt.js";import"./circle-check-big-CiDossuY.js";import"./fingerprint-pattern-D2EgFmxl.js";import"./CopyToClipboard-DSTf_eKU-CGPsgqyF.js";import"./Layouts-BlFm53ED-BRQuLn8k.js";import"./LabelXs-oqZNqbm_-BwqHBQTs.js";import"./Subtitle-CV-2yKE4-DPPTXjyF.js";import"./Title-BnzYV3Is-CMdESGad.js";import"./shared-FM0rljBt-3aZNEgb1.js";import"./dijkstra-D_NXgYpA.js";const Be={component:()=>{let{user:o,ready:P}=G(),{data:c,onUserCloseViaDialogOrKeybindRef:O}=J(),a=Q(),[v,l]=m.useState(null),[p,f]=m.useState(null),[g,k]=m.useState(null),[L,V]=m.useState(!1),[M,i]=m.useState(!1),[y,s]=m.useState(),n=async()=>{y?A(y):o?await d({user:o}):A(Error("Must be logged in to manage MFA")),setTimeout(()=>{l(null),f(null)},500)};if(O.current=n,!(c!=null&&c.mfaEnroll))throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:A,onSuccess:d,onBack:w,mfaMethods:W,verify:E,generateTotpSecret:q,enrollTotp:D,unenrollTotp:H,enrollPasskey:$}=c.mfaEnroll,I=o==null?void 0:o.mfaMethods.includes("sms"),K=o==null?void 0:o.mfaMethods.includes("totp"),N=o==null?void 0:o.mfaMethods.includes("passkey"),z=!!(o!=null&&o.phone),T=(o==null?void 0:o.linkedAccounts.filter(t=>t.type==="passkey").map(t=>t.credentialId))??[];function u(){l(null),f(null),s(void 0)}async function U(t=T){try{s(void 0),i(!0);let r=await $(t);return await d({user:r})}catch(r){s(r)}finally{i(!1),V(!1)}}if(!P||!o||!a)return e.jsxs(e.Fragment,{children:[e.jsx(j,{onClose:n,backFn:w},"header"),e.jsx(oe,{children:e.jsx(Z,{})}),e.jsx(re,{children:e.jsx(X,{})}),e.jsx(x,{})]});if(v==="sms")return null;if(v==="totp")return e.jsxs(e.Fragment,{children:[e.jsx(j,{backFn:u,onClose:n},"header"),e.jsx(C,{style:{marginBottom:"1.5rem"},children:e.jsx(B,{})}),e.jsx(R,{children:"Remove authenticator app verification?"}),e.jsxs(S,{children:["MFA adds an extra layer of security to your ",a==null?void 0:a.name," account. Make sure you have other methods to secure your account."]}),e.jsx(b,{children:e.jsx(F,{$warn:!0,onClick:async function(){try{s(void 0),i(!0);let t=await H();return await d({user:t})}catch(t){s(t)}finally{i(!1),l(null)}},loading:M,children:"Remove"})}),e.jsx(x,{})]});if(v==="passkey"){let t=c.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;return e.jsxs(e.Fragment,{children:[e.jsx(j,{backFn:u,onClose:n},"header"),e.jsx(C,{style:{marginBottom:"1.5rem"},children:e.jsx(B,{})}),e.jsx(R,{children:"Are you sure you want to remove this passkey?"}),e.jsx(S,{children:t?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),e.jsx(b,{children:e.jsx(F,{$warn:!0,onClick:async function(){try{s(void 0),i(!0);let r=await $([]);return await d({user:r})}catch(r){s(r)}finally{i(!1),l(null)}},loading:M,children:"Remove"})}),e.jsx(x,{})]})}return W.length!==0||I||K||N?p==="sms"?null:p==="totp"&&g?e.jsx(_,{onClose:n,onReset:u,submitEnrollmentWithTotp:t=>async function(r){try{s(void 0),i(!0);let h=await D(r);return await d({user:h})}catch(h){s(h)}finally{i(!1),l(null)}}(t.mfaCode),error:y,totpInfo:{...g,appName:(a==null?void 0:a.name)||"Privy"}}):p==="passkey"?e.jsx(ee,{onReset:u,onClose:n,submitEnrollmentWithPasskey:U}):e.jsx(te,{showIntro:!0,userMfaMethods:o.mfaMethods,appMfaMethods:a.mfa.methods,userHasAuthSms:z,backFn:w,handleSelectMethod:async function(t){s(void 0);try{await E()}catch(r){return void s(r)}return t==="totp"?(f(t),k(null),void q().then(({totpSecret:r,totpAuthUrl:h})=>{k({authUrl:h,secret:r})}).catch(()=>{k(null),u()})):t==="passkey"&&T.length===1?await U():void f(t)},isTotpLoading:p==="totp"&&!g,isPasskeyLoading:L,error:y,onClose:n,setRemovingMfaMethod:async function(t){s(void 0);try{await E()}catch(r){return void s(r)}l(t)}}):e.jsxs(e.Fragment,{children:[e.jsx(j,{onClose:n,backFn:w},"header"),e.jsx(C,{style:{marginBottom:"1.5rem"},children:e.jsx(Y,{})}),e.jsx(R,{children:"Add more security"}),e.jsxs(S,{children:[a==null?void 0:a.name," does not have any verification methods enabled."]}),e.jsx(b,{children:e.jsx(F,{onClick:n,children:"Close"})}),e.jsx(x,{})]})}};export{Be as MfaAuthEnrollmentFlowScreen,Be 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.