1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9884],{59884:function(e,t,r){r.r(t),r.d(t,{RecoveryOAuthScreen:function(){return C},default:function(){return C}});var o=r(27573),a=r(7653),i=r(81781),n=r(75593),l=r(71844),c=r(31796),s=r(80223),d=r(88089),u=r(36170),h=r(60464),p=r(17754),v=r(2181),w=r(2261),y=r(5409);async function f({url:e,popup:t,provider:r}){return t.location=e,new Promise((e,r)=>{function o(){t?.close(),window.removeEventListener("message",a)}function a(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),o()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),o()),"PRIVY_OAUTH_ERROR"===t.data.type&&(r(t.data.error),o()))}window.addEventListener("message",a)})}async function g({api:e,provider:t,stateCode:r,codeVerifier:o,authorizationCode:a}){if(!a||!r)throw new d.a("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===a)throw new d.a("User denied confirmation during OAuth flow");try{return(await e.post(h.a8,{authorization_code:a,state_code:r,code_verifier:o,provider:t})).access_token}catch(t){let e=(0,d.f)(t);if(e.privyErrorCode)throw new d.a(e.message||"Invalid code during OAuth flow.",void 0,e.privyErrorCode);if("User denied confirmation during OAuth flow"===e.message)throw new d.a("Invalid code during oauth flow.",void 0,d.b.OAUTH_USER_DENIED);throw new d.a("Invalid code during OAuth flow.",void 0,d.b.UNKNOWN_AUTH_ERROR)}}async function m({api:e,provider:t}){let r=(0,s.o)(),o=(0,s.q)(),a=await (0,s.r)(r);try{return"icloud"===t?{url:(await e.post(h.a9,{client_type:"web"})).url}:{url:(await e.post(h.aa,{redirect_to:window.location.href,code_challenge:a,state_code:o})).url,codeVerifier:r,stateCode:o,provider:t}}catch(e){throw(0,d.f)(e)}}r(26996),r(97347),r(69021),r(7220),r(61899);let x={"google-drive":{name:"Google Drive",component:y.G},icloud:{name:"iCloud",component:y.A}},C={component:()=>{let{logout:e}=(0,u.u)(),{navigate:t,setModalData:r,data:h}=(0,u.a)(),{closePrivyModal:C,createAnalyticsEvent:_}=(0,d.u)(),{execute:A}=(()=>{let{client:e,walletProxy:t,refreshSessionAndUser:r}=(0,d.u)(),{data:o}=(0,u.a)(),{user:a}=(0,u.u)(),i=(0,v.a)(),{create:n}=(0,w.u)();return{execute:async({provider:l,action:c,popup:s,shouldCreateEth:h,shouldCreateSol:v})=>{let w,y;if(!e)throw new d.a("Missing client");function x(t){if(!t&&e)throw e.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:l}}),new d.a("Recovery OAuth failed")}switch(l){case"google-drive":{let t,r,{url:o,codeVerifier:a,stateCode:i}=await m({api:e.api,provider:l});x(o);try{let a=await f({url:o,popup:s,provider:l});if(t=a.stateCode,r=a.authorizationCode,t!==i)throw e.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:l,storedStateCode:i??"",returnedStateCode:t??""}}),new d.a("Unexpected auth flow. This may be a phishing attempt.",void 0,d.b.OAUTH_UNEXPECTED)}catch(t){throw e.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:l}}),new d.a("Recovery OAuth failed")}[w,y]=await Promise.all([e.getAccessToken(),g({api:e.api,provider:l,codeVerifier:a,stateCode:t,authorizationCode:r})]);break}case"icloud":{let{url:t}=await m({api:e.api,provider:l});x(t);let{ckWebAuthToken:r}=await f({url:t,popup:s,provider:l});y=r,w=await e.getAccessToken()}}if(!t)throw new d.a("Cannot connect to wallet proxy");if(!w)throw new d.a("Unable to authorize user");switch(c){case"recover":{let r=o?.recoverWallet?.entropyId,a=o?.recoverWallet?.entropyIdVerifier;if(!r||!a)throw new d.a("Recovery OAuth failed");e.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:r,recoveryMethod:l}}),await t.recover({accessToken:w,entropyId:r,entropyIdVerifier:a,recoveryAccessToken:y}),e.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r,recoveryMethod:l}});break}case"create-wallet":{let t;if(e.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),h&&v)t=await n({recoveryMethod:l,recoveryAccessToken:y,chainType:"ethereum",walletIndex:0,latestUser:a}),t=await n({chainType:"solana",walletIndex:0,latestUser:t.user});else if(v)t=await n({recoveryMethod:l,recoveryAccessToken:y,chainType:"solana",walletIndex:0,latestUser:a});else{if(!h)throw Error("Invalid args to create wallet");t=await n({recoveryMethod:l,recoveryAccessToken:y,chainType:"ethereum",walletIndex:0,latestUser:a})}if(!t)throw i("createWallet","onError",d.b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");e.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.account.address}}),i("createWallet","onSuccess",{wallet:t.account});break}case"set-recovery":{let o=(0,u.g)(a);if(!o)throw i("setWalletRecovery","onError",d.b.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");e.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:o.address,existingRecoveryMethod:o.recoveryMethod,targetRecoveryMethod:l}});let{entropyId:n,entropyIdVerifier:c}=(0,p.g)(a);await t.setRecovery({accessToken:w,entropyId:n,entropyIdVerifier:c,recoveryMethod:l,recoveryAccessToken:y});let s=(0,u.g)(await r());if(!s)throw i("createWallet","onError",d.b.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");e.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:o.address,existingRecoveryMethod:o.recoveryMethod,targetRecoveryMethod:l}}),i("setWalletRecovery","onSuccess",{method:l,wallet:s});break}default:throw new d.a("Unsupported recovery action")}}}})(),[E,b]=(0,a.useState)(!1),{provider:k,action:R,isInAccountCreateFlow:T,shouldCreateEth:j,shouldCreateSol:S}=h?.recoveryOAuthStatus,[O,N]=(0,a.useState)(void 0),[U,L]=(0,a.useState)("create-wallet"===R);if("user-passcode"===k)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let M=x[k].name,I=x[k].component,P=h?.recoverWallet?.onCompleteNavigateTo,W=new s.R(async(e="create-wallet")=>(L(!0),new Promise((t,r)=>{setTimeout(async()=>{try{let r=window.open();await A({provider:k,action:e,popup:r,shouldCreateEth:j,shouldCreateSol:S}),b(!0),t()}
1catch(t){N({message:`${"recover"===e?"Recovery":"Back up"} with ${M} unsuccessful`,detail:"recover"===R?`Please verify that you are selecting the ${M} account associated with your backup.`:"",retryable:!0}),r()}},0)})));(0,a.useEffect)(()=>{"recover"!==R&&W.execute(T?"create-wallet":"set-recovery")},[]),(0,a.useEffect)(()=>{if(!E)return;let o=setTimeout(()=>{T?(r({createWallet:{onSuccess:()=>{},onFailure:t=>{_({eventName:"embedded_wallet_creation_failure_logout",payload:{error:t,screen:"RecoveryOAuthScreen"}}),e()},callAuthOnSuccessOnClose:!0,shouldCreateEth:!1,shouldCreateSol:!1}}),t("EmbeddedWalletCreatedScreen")):C({shouldCallAuthOnSuccess:!1})},c.q);return()=>clearTimeout(o)},[E]);let D=(0,a.useCallback)(async()=>{await W.execute("recover"),P?t(P):b(!0)},[]),F="google-drive"===k?"Google Drive":"Apple iCloud",z=E&&`Successfully ${"recover"===R?"recovered":"backed up"} with ${F}.`||O&&O.message||`${"recover"===R?"Recovering":"Backing up"} with ${F}...`,H=O?O.detail:"";return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.M,{}),U?(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(y.R,{children:[(0,o.jsx)(l.C,{title:z,icon:(0,o.jsx)(I,{style:{width:"38px",height:"38px"}}),description:H}),O&&O?.retryable?(0,o.jsx)(i.P,{onClick:()=>{(0,s.l)(),N(void 0),"create-wallet"===R?W.execute("create-wallet"):D()},disabled:!E&&!O?.retryable,children:"Try again"}):null]})}):(0,o.jsxs)(y.R,{children:[(0,o.jsx)(l.C,{title:"Confirm it's really you",icon:(0,o.jsx)(I,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${F} where your account is backed up.`}),(0,o.jsxs)(i.P,{onClick:D,children:["Confirm with ",F]})]}),(0,o.jsx)(n.B,{})]})}}},71844:function(e,t,r){r.d(t,{C:function(){return n},S:function(){return i}});var o=r(27573),a=r(91628);let i=({title:e,description:t,children:r,...a})=>(0,o.jsx)(l,{...a,children:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("h3",{children:e}),"string"==typeof t?(0,o.jsx)("p",{children:t}):t,r]})}),n=({title:e,description:t,icon:r,children:a,...i})=>(0,o.jsxs)(c,{...i,children:[r||null,(0,o.jsx)("h3",{children:e}),t&&"string"==typeof t?(0,o.jsx)("p",{children:t}):t,a]}),l=a.zo.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),c=(0,a.zo)(l).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"])},5409:function(e,t,r){r.d(t,{A:function(){return i},G:function(){return n},R:function(){return l},a:function(){return c}});var o=r(27573),a=r(91628);let i=e=>(0,o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 21 20",...e,children:[(0,o.jsx)("path",{fill:"url(#icloud-gradient)",d:"M12.34 7.315a4.26 4.26 0 0 0-3.707 2.18 2.336 2.336 0 0 0-1.02-.236 2.336 2.336 0 0 0-2.3 1.963 3.217 3.217 0 0 0 1.244 6.181c.135-.001.27-.01.404-.029h8.943c.047.004.094.006.141.007.045-.001.09-.004.135-.007h.214v-.016a2.99 2.99 0 0 0 1.887-.988c.487-.55.757-1.261.757-1.998v-.006a3.017 3.017 0 0 0-.69-1.915 2.992 2.992 0 0 0-1.748-1.034 4.26 4.26 0 0 0-4.26-4.102Z"}),(0,o.jsx)("defs",{children:(0,o.jsxs)("linearGradient",{id:"icloud-gradient",x1:19.086,x2:3.333,y1:14.38,y2:14.163,gradientUnits:"userSpaceOnUse",children:[(0,o.jsx)("stop",{stopColor:"#3E82F4"}),(0,o.jsx)("stop",{offset:1,stopColor:"#93DCF7"})]})})]}),n=({style:e,...t})=>(0,o.jsxs)("svg",{width:"16",height:"14",style:e,viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[(0,o.jsxs)("g",{clipPath:"url(#clip0_2115_829)",children:[(0,o.jsx)("path",{d:"M2.34709 12.9404L2.3471 12.9404L2.34565 12.938L1.64031 11.7448L1.64004 11.7444L0.651257 10.0677C0.640723 10.0496 0.630746 10.0314 0.621325 10.0129H4.16461L2.39424 13.0139C2.3775 12.9901 2.36178 12.9656 2.34709 12.9404Z",fill:"#0066DA",stroke:"#6366F1"}),(0,o.jsx)("path",{d:"M8 4.48713L5.47995 0.215332C5.23253 0.358922 5.02176 0.556358 4.87514 0.80764L0.219931 8.70508C0.076007 8.95094 0.000191627 9.22937 0 9.5127
17H5.04009L8 4.48713Z",fill:"#00AC47"}),(0,o.jsx)("path",{d:"M13.48 13.7847C13.7274 13.6411 13.9382 13.4437 14.0848 13.1924L14.3781 12.6988L15.7801 10.3206C15.9267 10.0693 16.0001 9.79114 16.0001 9.51294H10.9596L12.0321 11.577L13.48 13.7847Z",fill:"#EA4335"}),(0,o.jsx)("path",{d:"M8.00003 4.48718L10.5201 0.215385C10.2726 0.0717949 9.98857 0 9.69533 0H6.30472C6.01148 0 5.7274 0.0807692 5.47998 0.215385L8.00003 4.48718Z",fill:"#00832D"}),(0,o.jsx)("path",{d:"M10.9599 9.51294H5.04007L2.52002 13.7847C2.76744 13.9283 3.05152 14.0001 3.34476 14.0001H12.6552C12.9484 14.0001 13.2325 13.9194 13.4799 13.7847L10.9599 9.51294Z",fill:"#2684FC"}),(0,o.jsx)("path",{d:"M13.4525 4.75636L11.1249 0.80764C10.9782 0.556358 10.7675 0.358922 10.52 0.215332L8 4.48713L10.9599 9.51277H15.9908C15.9908 9.23456 15.9175 8.95636 15.7709 8.70508L13.4525 4.75636Z",fill:"#FFBA00"})]}),(0,o.jsx)("defs",{children:(0,o.jsx)("clipPath",{id:"clip0_2115_829",children:(0,o.jsx)("rect",{width:"16",height:"14",fill:"white"})})})]}),l=a.zo.div.withConfig({displayName:"RecoveryContainer",componentId:"sc-12b46968-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),c=a.zo.div.withConfig({displayName:"RecoveryExplainerContainer",componentId:"sc-12b46968-1"})(["padding-bottom:24px;"])},2261:function(e,t,r){r.d(t,{u:function(){return n}});var o=r(63002),a=r(31796),i=r(88089);let n=()=>{let{walletProxy:e,recoverEmbeddedWallet:t,setUser:r,refreshSessionAndUser:n,privy:l,client:c}=(0,i.u)(),s=(0,a.u)();return{create:async({walletIndex:a,chainType:i,latestUser:d,recoveryMethod:u,recoveryPassword:h,recoveryAccessToken:p})=>{let v=d;v||(v=await n());let w=await c.getAccessToken();if(!v||!w||!e)throw Error("User must be authenticated before creating a Privy wallet");return await (0,o.k)({appConfig:s,user:v,refreshSessionAndUser:n,privy:l,accessToken:w,proxy:e,recoverEmbeddedWallet:t,setUser:r,walletIndex:a,chainType:i,recoveryMethod:u,recoveryPassword:h,recoveryAccessToken:p})}}}}}]);
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.