1import{r as m,j as e}from"./jsx-runtime-CkEshw3w.js";import{T as x,g as j,F as $,m as F}from"./ModalHeader-C1WIsRkF-DxNzVmnq.js";import{F as J}from"./ShieldCheckIcon-BDvXCWO-.js";import{b as Q}from"./AuthContext-bkbKwU9c.js";import{k as X,g as Y,l as Z}from"./usePrivy-DVdXmoXg-BAvq-LeG.js";import{o as _,y as P,l as ee,i as te}from"./EnrollTotp-Bqnei-2B-ajgVhbiZ.js";import{o as oe,p as re,w as b,l as C,d as R,m as S}from"./PinInput-YqT0dSuH-DVtyrGYR.js";import"./root.store-D9wlavSr.js";import"./QrCode-mmar0Iu7-CR5NEcA8.js";import"./theme.utils-CP9rIRov.js";import"./auth.selectors-CIPEABoB.js";import"./settingsStore-DWRd2nZJ.js";import"./react-7fSPz3Wt.js";import"./index-w9FDnNPn.js";import"./actions-DSVb6pm_.js";import"./tradingView.standalone-BnYG56H6.js";import"./featureFlags.store-up1mUsFP.js";import"./adminConsole.store-gV0xzIhI.js";import"./withQueuedInterval-DAyrrt_8.js";import"./json-rpc-provider-BO1nKuXk.js";import"./components-ZpK05beY.js";import"./index-EJ8ptJ-Q.js";import"./index-fHwawp4L.js";import"./FingerPrintIcon-CvHWIce6.js";import"./PhoneIcon-CR0TrIQV.js";import"./Chip-D2-wZOHJ-DUM3638B.js";import"./LoadingSkeleton-U6-3yFwI-DeziIYHU.js";import"./ErrorScreen-DkigBJc0-3VNFqcbH.js";import"./reservoir-B7XIq5qj-DVoFLuDH.js";import"./safe-url-D7SRPu33-A8zMgOTd.js";import"./ScreenLayout-b9cixoV5-CmjsYb7H.js";import"./Screen-My4NO62A-XRCw7XDD.js";import"./index-Dq_xe9dz-DOSmELmw.js";import"./triangle-alert-JWekFlHS.js";import"./createLucideIcon-BOAmC-Ke.js";import"./lock-DRQB-DZz.js";import"./LinkPasskeyScreen-C2ClLwr7-BfXgp17J.js";import"./TodoList-CgrU7uwu-CP-BN6AQ.js";import"./x-Ck9Pz856.js";import"./check-BCS3P9-4.js";import"./circle-check-big-DNIrev3d.js";import"./fingerprint-pattern-cOWClbDv.js";import"./CopyToClipboard-DSTf_eKU-YYUIoZPi.js";import"./Layouts-BlFm53ED-DAoa78t_.js";import"./LabelXs-oqZNqbm_-BdRSdEHu.js";import"./Subtitle-CV-2yKE4-iXYF_RaW.js";import"./Title-BnzYV3Is-ZYIKNF-b.js";import"./shared-FM0rljBt-D-MRvHsV.js";import"./dijkstra-D_NXgYpA.js";const Pe={component:()=>{let{user:o,ready:L}=X(),{data:c,onUserCloseViaDialogOrKeybindRef:O}=Y(),n=Z(),[v,l]=m.useState(null),[h,f]=m.useState(null),[g,k]=m.useState(null),[W,D]=m.useState(!1),[M,i]=m.useState(!1),[y,s]=m.useState(),a=async()=>{y?E(y):o?await u({user:o}):E(Error("Must be logged in to manage MFA")),setTimeout(()=>{l(null),f(null)},500)};if(O.current=a,!(c!=null&&c.mfaEnroll))throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:E,onSuccess:u,onBack:w,mfaMethods:H,verify:A,generateTotpSecret:I,enrollTotp:K,unenrollTotp:N,enrollPasskey:T}=c.mfaEnroll,V=o==null?void 0:o.mfaMethods.includes("sms"),q=o==null?void 0:o.mfaMethods.includes("totp"),z=o==null?void 0:o.mfaMethods.includes("passkey"),G=!!(o!=null&&o.phone),U=(o==null?void 0:o.linkedAccounts.filter(t=>t.type==="passkey").map(t=>t.credentialId))??[];function p(){l(null),f(null),s(void 0)}async function B(t=U){try{s(void 0),i(!0);let r=await T(t);return await u({user:r})}catch(r){s(r)}finally{i(!1),D(!1)}}if(!L||!o||!n)return e.jsxs(e.Fragment,{children:[e.jsx(x,{onClose:a,backFn:w},"header"),e.jsx(oe,{children:e.jsx(_,{})}),e.jsx(re,{children:e.jsx(Q,{})}),e.jsx(j,{})]});if(v==="sms")return null;if(v==="totp")return e.jsxs(e.Fragment,{children:[e.jsx(x,{backFn:p,onClose:a},"header"),e.jsx(b,{style:{marginBottom:"1.5rem"},children:e.jsx($,{})}),e.jsx(C,{children:"Remove authenticator app verification?"}),e.jsxs(R,{children:["MFA adds an extra layer of security to your ",n==null?void 0:n.name," account. Make sure you have other methods to secure your account."]}),e.jsx(S,{children:e.jsx(F,{$warn:!0,onClick:async function(){try{s(void 0),i(!0);let t=await N();return await u({user:t})}catch(t){s(t)}finally{i(!1),l(null)}},loading:M,children:"Remove"})}),e.jsx(j,{})]});if(v==="passkey"){let t=c.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;return e.jsxs(e.Fragment,{children:[e.jsx(x,{backFn:p,onClose:a},"header"),e.jsx(b,{style:{marginBottom:"1.5rem"},children:e.jsx($,{})}),e.jsx(C,{children:"Are you sure you want to remove this passkey?"}),e.jsx(R,{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(S,{children:e.jsx(F,{$warn:!0,onClick:async function(){try{
1s(void 0),i(!0);let r=await T([]);return await u({user:r})}catch(r){s(r)}finally{i(!1),l(null)}},loading:M,children:"Remove"})}),e.jsx(j,{})]})}return H.length!==0||V||q||z?h==="sms"?null:h==="totp"&&g?e.jsx(P,{onClose:a,onReset:p,submitEnrollmentWithTotp:t=>async function(r){try{s(void 0),i(!0);let d=await K(r);return await u({user:d})}catch(d){s(d)}finally{i(!1),l(null)}}(t.mfaCode),error:y,totpInfo:{...g,appName:(n==null?void 0:n.name)||"Privy"}}):h==="passkey"?e.jsx(ee,{onReset:p,onClose:a,submitEnrollmentWithPasskey:B}):e.jsx(te,{showIntro:!0,userMfaMethods:o.mfaMethods,appMfaMethods:n.mfa.methods,userHasAuthSms:G,backFn:w,handleSelectMethod:async function(t){s(void 0);try{await A()}catch(r){return void s(r)}return t==="totp"?(f(t),k(null),void I().then(({totpSecret:r,totpAuthUrl:d})=>{k({authUrl:d,secret:r})}).catch(()=>{k(null),p()})):t==="passkey"&&U.length===1?await B():void f(t)},isTotpLoading:h==="totp"&&!g,isPasskeyLoading:W,error:y,onClose:a,setRemovingMfaMethod:async function(t){s(void 0);try{await A()}catch(r){return void s(r)}l(t)}}):e.jsxs(e.Fragment,{children:[e.jsx(x,{onClose:a,backFn:w},"header"),e.jsx(b,{style:{marginBottom:"1.5rem"},children:e.jsx(J,{})}),e.jsx(C,{children:"Add more security"}),e.jsxs(R,{children:[n==null?void 0:n.name," does not have any verification methods enabled."]}),e.jsx(S,{children:e.jsx(F,{onClick:a,children:"Close"})}),e.jsx(j,{})]})}};export{Pe as MfaAuthEnrollmentFlowScreen,Pe 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.