@privy-io/react-auth 1.54.1 → 1.54.2-beta-20240123002429
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +3 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -769,9 +769,9 @@ Resources:
|
|
|
769
769
|
transform: rotate(360deg);
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
-
`;var tp=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];var xe=class extends Error{constructor(o,r){super(r);this.type=o}};function er(e){let t=e.type;return typeof t=="string"&&tp.includes(t)}function lg(e){let t=e.type;return typeof t=="string"&&t==="client_error"}function tr(e){return er(e)&&e.type==="wallet_not_on_device"}function op(e){return er(e)&&(e.type==="invalid_recovery_pin"||e.type==="invalid_request_arguments")}function rp(e){return!!(er(e)&&e.type==="insufficient_funds"||e.code==="INSUFFICIENT_FUNDS")}function Fr(e){return!!(er(e)&&e.type==="mfa_timeout")}function Br(e){return!!(er(e)&&e.type==="missing_or_invalid_mfa")}function Ds(e){return!!(er(e)&&e.type==="mfa_verification_max_attempts_reached")}function Us(e){return!!(er(e)&&e.message.includes("code 429"))}function Fs(e){return!!(lg(e)&&e.message==="MFA canceled")}import{Fragment as ip,jsx as Hr,jsxs as Bs}from"react/jsx-runtime";var np=1,ap=()=>{let{authenticated:e,user:t,getAccessToken:o}=H(),{closePrivyModal:r,createAnalyticsEvent:n,walletProxy:i}=A(),{navigate:a,data:s,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=S(),u=pg(()=>Date.now(),[]),[f,w]=ug(!1),{onCompleteNavigateTo:v,onFailure:T}=s?.connectWallet,y=b=>{f||(w(!0),T(typeof b=="string"?new Error(b):b))};dg(()=>{let b=ne(t),W;return!e||!b?y("User must be authenticated and have a Privy wallet before it can be connected"):i?((async()=>{let N=await o();if(!N)return y("User must be authenticated and have a Privy wallet before it can be connected");try{await i.connect({accessToken:N,address:b.address});let I=(Date.now()-u)/1e3;v==="EMBEDDED_WALLET_KEY_EXPORT_SCREEN"&&I<np?W=setTimeout(()=>{a(v)},(np-I)*1e3):a(v)}catch(I){if(tr(I)&&b.recoveryMethod==="privy"){let k=await o();if(!k)return y("User must be authenticated and have a Privy wallet before it can be recovered");try{n("embedded_wallet_pinless_recovery_started",{walletAddress:b.address}),(await i?.recover({address:b.address,accessToken:k}))?.address||y(new Error("Unable to recover wallet")),v?a(v):r({shouldCallAuthOnSuccess:!1}),n("embedded_wallet_recovery_completed",{walletAddress:b.address}),a(v)}catch{y("An error has occurred, please try again.")}}else tr(I)?(l({...s,recoverWallet:{privyWallet:b,onCompleteNavigateTo:v,onFailure:T}}),a("EMBEDDED_WALLET_RECOVERY_SCREEN")):y(I)}})(),()=>clearTimeout(W)):void 0},[e,t,i]);let E=()=>{y("User exited before wallet could be connected"),r({shouldCallAuthOnSuccess:!1})};return c.current=E,Bs(ip,{children:[Hr(x,{onClose:E}),f?Bs(ip,{children:[Bs(xt,{children:[Hr(cg,{fill:"var(--privy-color-error)",
|
|
772
|
+
`;var tp=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];var xe=class extends Error{constructor(o,r){super(r);this.type=o}};function er(e){let t=e.type;return typeof t=="string"&&tp.includes(t)}function lg(e){let t=e.type;return typeof t=="string"&&t==="client_error"}function tr(e){return er(e)&&e.type==="wallet_not_on_device"}function op(e){return er(e)&&(e.type==="invalid_recovery_pin"||e.type==="invalid_request_arguments")}function rp(e){return!!(er(e)&&e.type==="insufficient_funds"||e.code==="INSUFFICIENT_FUNDS")}function Fr(e){return!!(er(e)&&e.type==="mfa_timeout")}function Br(e){return!!(er(e)&&e.type==="missing_or_invalid_mfa")}function Ds(e){return!!(er(e)&&e.type==="mfa_verification_max_attempts_reached")}function Us(e){return!!(er(e)&&e.message.includes("code 429"))}function Fs(e){return!!(lg(e)&&e.message==="MFA canceled")}import{Fragment as ip,jsx as Hr,jsxs as Bs}from"react/jsx-runtime";var np=1,ap=()=>{let{authenticated:e,user:t,getAccessToken:o}=H(),{closePrivyModal:r,createAnalyticsEvent:n,walletProxy:i}=A(),{navigate:a,data:s,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=S(),u=pg(()=>Date.now(),[]),[f,w]=ug(!1),{onCompleteNavigateTo:v,onFailure:T}=s?.connectWallet,y=b=>{f||(w(!0),T(typeof b=="string"?new Error(b):b))};dg(()=>{let b=ne(t),W;return!e||!b?y("User must be authenticated and have a Privy wallet before it can be connected"):i?((async()=>{let N=await o();if(!N)return y("User must be authenticated and have a Privy wallet before it can be connected");try{await i.connect({accessToken:N,address:b.address});let I=(Date.now()-u)/1e3;v==="EMBEDDED_WALLET_KEY_EXPORT_SCREEN"&&I<np?W=setTimeout(()=>{a(v)},(np-I)*1e3):a(v)}catch(I){if(tr(I)&&b.recoveryMethod==="privy"){let k=await o();if(!k)return y("User must be authenticated and have a Privy wallet before it can be recovered");try{n("embedded_wallet_pinless_recovery_started",{walletAddress:b.address}),(await i?.recover({address:b.address,accessToken:k}))?.address||y(new Error("Unable to recover wallet")),v?a(v):r({shouldCallAuthOnSuccess:!1}),n("embedded_wallet_recovery_completed",{walletAddress:b.address}),a(v)}catch{y("An error has occurred, please try again.")}}else tr(I)?(l({...s,recoverWallet:{privyWallet:b,onCompleteNavigateTo:v,onFailure:T}}),a("EMBEDDED_WALLET_RECOVERY_SCREEN")):y(I)}})(),()=>clearTimeout(W)):void 0},[e,t,i]);let E=()=>{y("User exited before wallet could be connected"),r({shouldCallAuthOnSuccess:!1})};return c.current=E,Bs(ip,{children:[Hr(x,{onClose:E}),f?Bs(ip,{children:[Bs(xt,{children:[Hr(cg,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),Hr(he,{title:"Something went wrong",description:"We\u2019re on it. Please try again later."})]}),Hr(U,{onClick:()=>r({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):Hr(Ur,{}),Hr(fg,{})]})},fg=mg.div`
|
|
773
773
|
height: 44px;
|
|
774
|
-
`;import{CheckCircleIcon as hg}from"@heroicons/react/24/solid";import{useEffect as yg}from"react";import{Fragment as gg,jsx as Gr,jsxs as sp}from"react/jsx-runtime";var lp=()=>{let{user:e}=H(),{closePrivyModal:t,isNewUserThisSession:o,updateWallets:r}=A(),{app:n,data:i,onUserCloseViaDialogOrKeybindRef:a}=S(),{onSuccess:s,onFailure:l,callAuthOnSuccessOnClose:c}=i.createWallet,u=()=>{let f=ne(e);f?(r(),s(f)):l(new Error("Failed to create wallet")),t({shouldCallAuthOnSuccess:c})};return yg(()=>{let f=setTimeout(u,Ec);return()=>clearTimeout(f)},[]),a.current=u,sp(gg,{children:[Gr(x,{onClose:u}),Gr(q,{}),sp(xt,{children:[Gr(hg,{fill:"var(--privy-color-accent)",
|
|
774
|
+
`;import{CheckCircleIcon as hg}from"@heroicons/react/24/solid";import{useEffect as yg}from"react";import{Fragment as gg,jsx as Gr,jsxs as sp}from"react/jsx-runtime";var lp=()=>{let{user:e}=H(),{closePrivyModal:t,isNewUserThisSession:o,updateWallets:r}=A(),{app:n,data:i,onUserCloseViaDialogOrKeybindRef:a}=S(),{onSuccess:s,onFailure:l,callAuthOnSuccessOnClose:c}=i.createWallet,u=()=>{let f=ne(e);f?(r(),s(f)):l(new Error("Failed to create wallet")),t({shouldCallAuthOnSuccess:c})};return yg(()=>{let f=setTimeout(u,Ec);return()=>clearTimeout(f)},[]),a.current=u,sp(gg,{children:[Gr(x,{onClose:u}),Gr(q,{}),sp(xt,{children:[Gr(hg,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),Gr(he,{title:o?`Welcome${n?.name?` to ${n?.name}`:""}`:"All set!",description:o?"You\u2019ve successfully created an account.":"Your account is secured."})]}),Gr(K,{}),Gr(F,{protectedByPrivy:!0})]})};import{ExclamationTriangleIcon as vg}from"@heroicons/react/20/solid";import{ArrowRightOnRectangleIcon as wg}from"@heroicons/react/24/outline";import{useEffect as pp,useRef as Cg,useState as Hs}from"react";import ko from"styled-components";import{Fragment as Ag,jsx as ge,jsxs as _t}from"react/jsx-runtime";var up=()=>{let[e,t]=Hs(null),{authenticated:o,user:r,getAccessToken:n}=H(),{closePrivyModal:i,createAnalyticsEvent:a,clientAnalyticsId:s}=A(),{data:l,onUserCloseViaDialogOrKeybindRef:c}=S(),u=ne(r)?.address,{onFailure:f,onSuccess:w,origin:v,appId:T}=l.keyExport,y=b=>{i({shouldCallAuthOnSuccess:!1}),f(typeof b=="string"?new Error(b):b)},E=()=>{i({shouldCallAuthOnSuccess:!1}),w(),a("embedded_wallet_key_export_completed",{walletAddress:u})};return pp(()=>{let b=ne(r);if(!o||!b)return y("User must be authenticated before exporting their wallet");n().then(t,y)},[o,r]),c.current=E,_t(Ag,{children:[ge(x,{onClose:E}),_t(Pg,{children:[_t(he,{icon:ge(wg,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),title:"Transfer Wallet",children:[_t(_g,{children:[ge(Eg,{style:{marginRight:6}}),bo(u)]}),ge("p",{children:"You can bring your account with you to another site using an external wallet."})]}),_t(Tg,{children:[_t(cp,{children:[ge(dp,{children:"1"}),_t("span",{children:[ge("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Follow the guide"})," ","to transfer your account to your wallet of choice."]})]}),_t(cp,{children:[ge(dp,{children:"2"}),ge("span",{children:"Copy this key into your other wallet"})]})]}),ge("div",{style:{width:"100%"},children:e&&ge(bg,{origin:v,appId:T,accessToken:e,clientAnalyticsId:s,address:u,dimensions:{height:"44px"}})}),_t(kg,{children:[_t("div",{children:[ge(vg,{viewBox:"0 0 20 18"}),ge("h4",{children:"Warning"})]}),ge("p",{children:"Never share your private key with anyone! It controls your account."})]})]}),ge(F,{protectedByPrivy:!0})]})};function bg(e){let[t,o]=Hs(e.dimensions.width),[r,n]=Hs(void 0),i=Cg(null);return pp(()=>{if(i.current&&t===void 0){let{width:s}=i.current.getBoundingClientRect();o(s)}let a=getComputedStyle(document.documentElement);n({background2:a.getPropertyValue("--privy-color-background-2"),foreground3:a.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:a.getPropertyValue("--privy-color-foreground-accent"),accent:a.getPropertyValue("--privy-color-accent"),accentDark:a.getPropertyValue("--privy-color-accent-dark"),success:a.getPropertyValue("--privy-color-success")})},[]),ge("div",{ref:i,children:t&&_t(xg,{children:[ge("iframe",{style:{position:"absolute",zIndex:1},width:t,height:e.dimensions.height,allow:"clipboard-write self *",src:wi(e.origin,`/apps/${e.appId}/embedded-wallets/export`,{token:e.accessToken,address:e.address,width:`${t}px`,caid:e.clientAnalyticsId,...r})}),ge(Sg,{children:"Loading..."})]})})}function Eg(e){return ge("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:e.style,children:ge("path",{d:"M14 8.81335C14 7.98493 13.3284 7.31335 12.5 7.31335H10C10 8.41792 9.10457 9.31335 8 9.31335C6.89543 9.31335 6 8.41792 6 7.31335H3.5C2.67157 7.31335 2 7.98493 2 8.81335M14 8.81335V12.8134C14 13.6418 13.3284 14.3134 12.5 14.3134H3.5C2.67157 14.3134 2 13.6418 2 12.8134V8.81335M14 8.81335V6.81335M2 8.81335V6.81335M14 6.81335C14 5.98493 13.3284 5.31335 12.5 5.31335H3.5C2.67157 5.31335 2 5.98493 2 6.81335M14 6.81335V4.81335C14 3.98493 13.3284 3.31335 12.5 3.31335H3.5C2.67157 3.31335 2 3.98493 2 4.81335V6.81335",stroke:"var(--privy-color-foreground-3)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var Pg=ko.div`
|
|
775
775
|
display: flex;
|
|
776
776
|
flex-direction: column;
|
|
777
777
|
text-align: left;
|
|
@@ -1085,7 +1085,7 @@ Resources:
|
|
|
1085
1085
|
|
|
1086
1086
|
${t}
|
|
1087
1087
|
|
|
1088
|
-
You will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;import{CheckCircleIcon as y1,XCircleIcon as g1}from"@heroicons/react/24/outline";import{Fragment as v1,jsx as co,jsxs as qs}from"react/jsx-runtime";var Np=({error:e,onClose:t})=>qs(v1,{children:[co(x,{closeable:!1}),co(q,{}),e?qs(xt,{children:[co(g1,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}),co(he,{title:"Something went wrong",description:e})]}):qs(xt,{children:[co(y1,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),co(he,{title:"Success"})]}),co(U,{onClick:t,children:"Close"}),co(K,{}),co(F,{protectedByPrivy:!0})]});import{useReducer as w1}from"react";var C1=(e,t)=>{switch(e){case"creating":return t==="back"?e:"saving";case"saving":return t==="back"?"creating":"confirming";case"confirming":return t==="back"?"saving":"finalizing";case"finalizing":return t==="back"?"confirming":"done";default:return e}},Op=()=>{let[e,t]=w1(C1,"creating");return{send:t,state:e}};import{jsx as An}from"react/jsx-runtime";var Qi=({onSubmit:e,...t})=>{let{send:o,state:r}=Op(),n=Dp(async()=>{r==="finalizing"&&await e(),o("next")},[r,o,e]);b1(()=>{let a;return r==="done"&&t.config.initiatedBy==="automatic"&&(a=setTimeout(()=>t.onClose?.(),et)),()=>{a&&clearTimeout(a)}},[r,t.config.initiatedBy,t.onClose]);let i=Dp(()=>{o("back")},[o]);return r==="creating"?An(Wp,{...t,onSubmit:n}):r==="saving"?An(Lp,{...t,onSubmit:n,onBack:i}):r==="confirming"?An(gp,{...t,onSubmit:n,onBack:i}):r==="finalizing"?An(Ep,{...t,onSubmit:n,onBack:i}):r==="done"?An(Np,{...t,onSubmit:n}):null};import{Fragment as x1,jsx as jr,jsxs as Fp}from"react/jsx-runtime";var T1=250,Bp=()=>{let{app:e,navigate:t,data:o,onUserCloseViaDialogOrKeybindRef:r}=S(),[n,i]=Rn(""),[a,s]=Rn(!1),[l,c]=Rn(),[u,f]=Rn(null),[w,v]=Rn(null),T=P1(!1),{authenticated:y,getAccessToken:E}=H(),{refreshUser:b,closePrivyModal:W,createAnalyticsEvent:M,isNewUserThisSession:N,initializeWalletProxy:I}=A(),{onSuccess:k,onFailure:R,callAuthOnSuccessOnClose:D}=o.createWallet,$=e?.embeddedWallets.requireUserPasswordOnCreate===!0,B=!!(!n||T.current)&&!$,_=new dt(async()=>se());Up(()=>{u||I(3e4).then(O=>f(O))},[u]),Up(()=>{if(!y){t("LANDING"),R(new Error("User must be authenticated before creating a Privy wallet"));return}!$&&!a&&!T.current&&(s(!0),_.execute().finally(()=>s(!1)))},[$,y]);let J=()=>{$&&w&&w?.recoveryMethod!=="user-passcode"?R(new Ze("User created a wallet but failed to set a password for it")):w?k(w):R(new Ze("User wallet creation failed")),W({shouldCallAuthOnSuccess:D})};r.current=()=>null;let se=async function(){let O=await E();if(O)try{if(M("embedded_wallet_creation_started"),!await(await I(br))?.create({accessToken:O,recoveryPassword:l}))throw M("embedded_wallet_creation_failed",{error:"walletProxy did not send a response."}),new Error("Unable to create wallet");let le=await b(),vt=ne(le);if(!vt)throw M("embedded_wallet_creation_failed",{error:"Updated user is missing embedded wallet."}),new Error("Unable to create wallet");v(vt),M("embedded_wallet_creation_completed",{walletAddress:vt.address}),i(""),T.current=!0,$?t("EMBEDDED_WALLET_CREATED_SCREEN"):N?t("EMBEDDED_WALLET_CREATED_SCREEN"):vt&&(k(vt),W({shouldCallAuthOnSuccess:D}))}catch(De){if(T.current)return;i("An error has occurred, please try again."),console.warn(De)}else i("An error has occured, please login again."),M("embedded_wallet_creation_failed",{error:"Missing access token for user."})},ve=async()=>$?(s(!0),_.execute().then(()=>new Promise(O=>setTimeout(O,T1))).finally(()=>s(!1))):W({shouldCallAuthOnSuccess:D});return!$&&n?Fp(x1,{children:[jr(x,{closeable:!1}),Fp(xt,{children:[jr(E1,{fill:"var(--privy-color-error)",
|
|
1088
|
+
You will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;import{CheckCircleIcon as y1,XCircleIcon as g1}from"@heroicons/react/24/outline";import{Fragment as v1,jsx as co,jsxs as qs}from"react/jsx-runtime";var Np=({error:e,onClose:t})=>qs(v1,{children:[co(x,{closeable:!1}),co(q,{}),e?qs(xt,{children:[co(g1,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}),co(he,{title:"Something went wrong",description:e})]}):qs(xt,{children:[co(y1,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),co(he,{title:"Success"})]}),co(U,{onClick:t,children:"Close"}),co(K,{}),co(F,{protectedByPrivy:!0})]});import{useReducer as w1}from"react";var C1=(e,t)=>{switch(e){case"creating":return t==="back"?e:"saving";case"saving":return t==="back"?"creating":"confirming";case"confirming":return t==="back"?"saving":"finalizing";case"finalizing":return t==="back"?"confirming":"done";default:return e}},Op=()=>{let[e,t]=w1(C1,"creating");return{send:t,state:e}};import{jsx as An}from"react/jsx-runtime";var Qi=({onSubmit:e,...t})=>{let{send:o,state:r}=Op(),n=Dp(async()=>{r==="finalizing"&&await e(),o("next")},[r,o,e]);b1(()=>{let a;return r==="done"&&t.config.initiatedBy==="automatic"&&(a=setTimeout(()=>t.onClose?.(),et)),()=>{a&&clearTimeout(a)}},[r,t.config.initiatedBy,t.onClose]);let i=Dp(()=>{o("back")},[o]);return r==="creating"?An(Wp,{...t,onSubmit:n}):r==="saving"?An(Lp,{...t,onSubmit:n,onBack:i}):r==="confirming"?An(gp,{...t,onSubmit:n,onBack:i}):r==="finalizing"?An(Ep,{...t,onSubmit:n,onBack:i}):r==="done"?An(Np,{...t,onSubmit:n}):null};import{Fragment as x1,jsx as jr,jsxs as Fp}from"react/jsx-runtime";var T1=250,Bp=()=>{let{app:e,navigate:t,data:o,onUserCloseViaDialogOrKeybindRef:r}=S(),[n,i]=Rn(""),[a,s]=Rn(!1),[l,c]=Rn(),[u,f]=Rn(null),[w,v]=Rn(null),T=P1(!1),{authenticated:y,getAccessToken:E}=H(),{refreshUser:b,closePrivyModal:W,createAnalyticsEvent:M,isNewUserThisSession:N,initializeWalletProxy:I}=A(),{onSuccess:k,onFailure:R,callAuthOnSuccessOnClose:D}=o.createWallet,$=e?.embeddedWallets.requireUserPasswordOnCreate===!0,B=!!(!n||T.current)&&!$,_=new dt(async()=>se());Up(()=>{u||I(3e4).then(O=>f(O))},[u]),Up(()=>{if(!y){t("LANDING"),R(new Error("User must be authenticated before creating a Privy wallet"));return}!$&&!a&&!T.current&&(s(!0),_.execute().finally(()=>s(!1)))},[$,y]);let J=()=>{$&&w&&w?.recoveryMethod!=="user-passcode"?R(new Ze("User created a wallet but failed to set a password for it")):w?k(w):R(new Ze("User wallet creation failed")),W({shouldCallAuthOnSuccess:D})};r.current=()=>null;let se=async function(){let O=await E();if(O)try{if(M("embedded_wallet_creation_started"),!await(await I(br))?.create({accessToken:O,recoveryPassword:l}))throw M("embedded_wallet_creation_failed",{error:"walletProxy did not send a response."}),new Error("Unable to create wallet");let le=await b(),vt=ne(le);if(!vt)throw M("embedded_wallet_creation_failed",{error:"Updated user is missing embedded wallet."}),new Error("Unable to create wallet");v(vt),M("embedded_wallet_creation_completed",{walletAddress:vt.address}),i(""),T.current=!0,$?t("EMBEDDED_WALLET_CREATED_SCREEN"):N?t("EMBEDDED_WALLET_CREATED_SCREEN"):vt&&(k(vt),W({shouldCallAuthOnSuccess:D}))}catch(De){if(T.current)return;i("An error has occurred, please try again."),console.warn(De)}else i("An error has occured, please login again."),M("embedded_wallet_creation_failed",{error:"Missing access token for user."})},ve=async()=>$?(s(!0),_.execute().then(()=>new Promise(O=>setTimeout(O,T1))).finally(()=>s(!1))):W({shouldCallAuthOnSuccess:D});return!$&&n?Fp(x1,{children:[jr(x,{closeable:!1}),Fp(xt,{children:[jr(E1,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),jr(he,{title:"Something went wrong",description:n})]}),jr(U,{onClick:J,children:"Close"})]}):B?jr(Ur,{}):jr(Qi,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:B||!u,buttonLoading:a,buttonHideAnimations:!w&&a,error:n,password:l||"",onClose:J,onPasswordChange:c,onPasswordGenerate:()=>c(Ji()),onSubmit:ve})};import{useEffect as S1,useState as Zi}from"react";import{jsx as _1}from"react/jsx-runtime";var Hp=()=>{let[e,t]=Zi(null),[o,r]=Zi(!1),[n,i]=Zi(null),[a,s]=Zi(""),{authenticated:l,getAccessToken:c,user:u}=H(),{walletProxy:f,refreshUser:w,closePrivyModal:v,createAnalyticsEvent:T}=A(),{app:y,navigate:E,data:b,onUserCloseViaDialogOrKeybindRef:W}=S(),{onSuccess:M,onFailure:N}=b.createWallet,I=ne(u),k=e?.recoveryMethod==="user-passcode";S1(()=>{l||(E("LANDING"),N(new li("User must be authenticated before setting a password on a Privy wallet")))},[l]);let R=()=>{if(n){N(n),v({shouldCallAuthOnSuccess:!1});return}if(!k){N(new Ze("Exited before password was added to wallet")),v({shouldCallAuthOnSuccess:!1});return}M(e),v({shouldCallAuthOnSuccess:!1})};W.current=R;let D=async()=>{let B=await c();if(B&&I?.address&&a&&f)try{if(T("embedded_wallet_set_password_started",{walletAddress:I.address}),!(await f.setRecoveryPassword({accessToken:B,address:I.address,recoveryPassword:a})).address){i(new Ze("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:I.address,reason:"error setting password"});return}let J=await w(),se=ne(J);if(!se){i(new Ze("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:I.address,reason:"wallet disconnected"});return}t(se),T("embedded_wallet_set_password_completed",{walletAddress:I.address})}catch(_){console.warn(_),i(_ instanceof Error?_:new Error("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:I.address,reason:_})}},$=async()=>{k?(M(e),v({shouldCallAuthOnSuccess:!1})):(r(!0),i(null),await D(),r(!1))};return _1(Qi,{appName:y?.name||"privy",config:{initiatedBy:"user",onCancel:R},error:n?"An error has occurred, please try again.":void 0,buttonLoading:o,buttonHideAnimations:!1,password:a,onPasswordGenerate:()=>s(Ji()),onPasswordChange:s,onSubmit:$,onClose:R})};import{UserCircleIcon as k1}from"@heroicons/react/24/outline";import{LockClosedIcon as A1}from"@heroicons/react/24/solid";import{Fragment as R1,jsx as po,jsxs as Xi}from"react/jsx-runtime";var Gp=()=>{let{user:e}=H(),{closePrivyModal:t,createAnalyticsEvent:o}=A(),{data:r,setModalData:n,navigate:i,onUserCloseViaDialogOrKeybindRef:a}=S(),{onSuccess:s,onFailure:l}=r.setWalletPassword,c=()=>{l(new Ze("Exited before password was added to wallet")),t({shouldCallAuthOnSuccess:!1})};return a.current=c,Xi(R1,{children:[po(x,{onClose:c}),po(q,{}),Xi(xt,{children:[Xi(kd,{children:[po(k1,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),po(Ad,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:po(A1,{width:"12px",height:"12px",fill:"white"})})]}),Xi(he,{title:"Secure Your Account",children:["Please set a password to secure your account.",po("p",{children:"Losing this password will make your account inaccessible on new devices. You will only be asked for it when you log on to a new device."})]})]}),po(U,{onClick:()=>{let f=ne(e);o("embedded_wallet_set_password_started",{walletAddress:f?.address}),n({createWallet:{onFailure:l,onSuccess:s,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),i("EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN")},children:"Add password"}),po(K,{}),po(F,{protectedByPrivy:!0})]})};import{ShieldCheckIcon as I1}from"@heroicons/react/24/outline";import{useEffect as W1,useState as ea}from"react";import ta,{css as M1}from"styled-components";import{Fragment as U1,jsx as Be,jsxs as nr}from"react/jsx-runtime";var zp=()=>{let[e,t]=ea(!0),{authenticated:o,getAccessToken:r}=H(),{walletProxy:n,closePrivyModal:i,createAnalyticsEvent:a}=A(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:c}=S(),[u,f]=ea(void 0),[w,v]=ea(""),[T,y]=ea(!1),{privyWallet:E,onCompleteNavigateTo:b,onSuccess:W,onFailure:M}=l.recoverWallet,N=(R="User exited before their wallet could be recovered")=>{i({shouldCallAuthOnSuccess:!1}),M(typeof R=="string"?new Ze(R):R)};c.current=N,W1(()=>{if(!o||!E)return N("User must be authenticated and have a Privy wallet before it can be recovered")},[o]);let I=R=>{R&&f(R)};return nr(U1,{children:[Be(x,{onClose:N}),Be(q,{}),nr(N1,{children:[nr(L1,{children:[Be(I1,{height:48,width:48,stroke:"var(--privy-color-accent)"}),Be("h3",{style:{color:"var(--privy-color-foreground)"},children:"Load your account"}),Be("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),nr("div",{children:[nr(Io,{children:[Be(or,{type:e?"password":"text",onChange:R=>I(R.target.value),disabled:T}),Be(zr,{style:{right:"0.75rem"},children:e?Be(Vr,{onClick:()=>t(!1)}):Be($r,{onClick:()=>t(!0)})})]}),!!w&&Be(O1,{children:w})]}),nr("div",{children:[nr(_d,{children:[Be("h4",{children:"Why is this necessary?"}),Be("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),Be(D1,{loading:T||!n,disabled:!u,onClick:async()=>{y(!0);let R=await r();if(R&&E&&u!==null)try{a("embedded_wallet_recovery_started",{walletAddress:E.address}),await n?.recover({address:E.address,accessToken:R,recoveryPin:u}),v(""),b?s(b):i({shouldCallAuthOnSuccess:!1}),W?.(E),a("embedded_wallet_recovery_completed",{walletAddress:E.address})}catch(D){op(D)?v("Invalid recovery password, please try again."):v("An error has occurred, please try again.")}finally{y(!1)}else return N("User must be authenticated and have a Privy wallet before it can be recovered")},warn:!1,hideAnimations:!E&&T,children:"Recover your account"})]})]}),Be(K,{}),Be(F,{protectedByPrivy:!0})]})},L1=ta.div`
|
|
1089
1089
|
display: flex;
|
|
1090
1090
|
flex-direction: column;
|
|
1091
1091
|
align-items: center;
|
package/dist/index.js
CHANGED
|
@@ -769,9 +769,9 @@ Resources:
|
|
|
769
769
|
transform: rotate(360deg);
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
-
`;var Yp=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];var Ve=class extends Error{constructor(o,r){super(r);this.type=o}};function Lr(e){let t=e.type;return typeof t=="string"&&Yp.includes(t)}function cg(e){let t=e.type;return typeof t=="string"&&t==="client_error"}function Nr(e){return Lr(e)&&e.type==="wallet_not_on_device"}function Jp(e){return Lr(e)&&(e.type==="invalid_recovery_pin"||e.type==="invalid_request_arguments")}function Qp(e){return!!(Lr(e)&&e.type==="insufficient_funds"||e.code==="INSUFFICIENT_FUNDS")}function Or(e){return!!(Lr(e)&&e.type==="mfa_timeout")}function Dr(e){return!!(Lr(e)&&e.type==="missing_or_invalid_mfa")}function $a(e){return!!(Lr(e)&&e.type==="mfa_verification_max_attempts_reached")}function Nl(e){return!!(Lr(e)&&e.message.includes("code 429"))}function Ol(e){return!!(cg(e)&&e.message==="MFA canceled")}var ft=require("react/jsx-runtime"),Zp=1,tu=()=>{let{authenticated:e,user:t,getAccessToken:o}=V(),{closePrivyModal:r,createAnalyticsEvent:n,walletProxy:i}=R(),{navigate:a,data:s,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=_(),m=(0,In.useMemo)(()=>Date.now(),[]),[h,w]=(0,In.useState)(!1),{onCompleteNavigateTo:v,onFailure:T}=s?.connectWallet,y=b=>{h||(w(!0),T(typeof b=="string"?new Error(b):b))};(0,In.useEffect)(()=>{let b=ve(t),M;return!e||!b?y("User must be authenticated and have a Privy wallet before it can be connected"):i?((async()=>{let O=await o();if(!O)return y("User must be authenticated and have a Privy wallet before it can be connected");try{await i.connect({accessToken:O,address:b.address});let W=(Date.now()-m)/1e3;v==="EMBEDDED_WALLET_KEY_EXPORT_SCREEN"&&W<Zp?M=setTimeout(()=>{a(v)},(Zp-W)*1e3):a(v)}catch(W){if(Nr(W)&&b.recoveryMethod==="privy"){let A=await o();if(!A)return y("User must be authenticated and have a Privy wallet before it can be recovered");try{n("embedded_wallet_pinless_recovery_started",{walletAddress:b.address}),(await i?.recover({address:b.address,accessToken:A}))?.address||y(new Error("Unable to recover wallet")),v?a(v):r({shouldCallAuthOnSuccess:!1}),n("embedded_wallet_recovery_completed",{walletAddress:b.address}),a(v)}catch{y("An error has occurred, please try again.")}}else Nr(W)?(l({...s,recoverWallet:{privyWallet:b,onCompleteNavigateTo:v,onFailure:T}}),a("EMBEDDED_WALLET_RECOVERY_SCREEN")):y(W)}})(),()=>clearTimeout(M)):void 0},[e,t,i]);let E=()=>{y("User exited before wallet could be connected"),r({shouldCallAuthOnSuccess:!1})};return c.current=E,(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsx)(S,{onClose:E}),h?(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsxs)(Zt,{children:[(0,ft.jsx)(Xp.XCircleIcon,{fill:"var(--privy-color-error)",
|
|
772
|
+
`;var Yp=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];var Ve=class extends Error{constructor(o,r){super(r);this.type=o}};function Lr(e){let t=e.type;return typeof t=="string"&&Yp.includes(t)}function cg(e){let t=e.type;return typeof t=="string"&&t==="client_error"}function Nr(e){return Lr(e)&&e.type==="wallet_not_on_device"}function Jp(e){return Lr(e)&&(e.type==="invalid_recovery_pin"||e.type==="invalid_request_arguments")}function Qp(e){return!!(Lr(e)&&e.type==="insufficient_funds"||e.code==="INSUFFICIENT_FUNDS")}function Or(e){return!!(Lr(e)&&e.type==="mfa_timeout")}function Dr(e){return!!(Lr(e)&&e.type==="missing_or_invalid_mfa")}function $a(e){return!!(Lr(e)&&e.type==="mfa_verification_max_attempts_reached")}function Nl(e){return!!(Lr(e)&&e.message.includes("code 429"))}function Ol(e){return!!(cg(e)&&e.message==="MFA canceled")}var ft=require("react/jsx-runtime"),Zp=1,tu=()=>{let{authenticated:e,user:t,getAccessToken:o}=V(),{closePrivyModal:r,createAnalyticsEvent:n,walletProxy:i}=R(),{navigate:a,data:s,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=_(),m=(0,In.useMemo)(()=>Date.now(),[]),[h,w]=(0,In.useState)(!1),{onCompleteNavigateTo:v,onFailure:T}=s?.connectWallet,y=b=>{h||(w(!0),T(typeof b=="string"?new Error(b):b))};(0,In.useEffect)(()=>{let b=ve(t),M;return!e||!b?y("User must be authenticated and have a Privy wallet before it can be connected"):i?((async()=>{let O=await o();if(!O)return y("User must be authenticated and have a Privy wallet before it can be connected");try{await i.connect({accessToken:O,address:b.address});let W=(Date.now()-m)/1e3;v==="EMBEDDED_WALLET_KEY_EXPORT_SCREEN"&&W<Zp?M=setTimeout(()=>{a(v)},(Zp-W)*1e3):a(v)}catch(W){if(Nr(W)&&b.recoveryMethod==="privy"){let A=await o();if(!A)return y("User must be authenticated and have a Privy wallet before it can be recovered");try{n("embedded_wallet_pinless_recovery_started",{walletAddress:b.address}),(await i?.recover({address:b.address,accessToken:A}))?.address||y(new Error("Unable to recover wallet")),v?a(v):r({shouldCallAuthOnSuccess:!1}),n("embedded_wallet_recovery_completed",{walletAddress:b.address}),a(v)}catch{y("An error has occurred, please try again.")}}else Nr(W)?(l({...s,recoverWallet:{privyWallet:b,onCompleteNavigateTo:v,onFailure:T}}),a("EMBEDDED_WALLET_RECOVERY_SCREEN")):y(W)}})(),()=>clearTimeout(M)):void 0},[e,t,i]);let E=()=>{y("User exited before wallet could be connected"),r({shouldCallAuthOnSuccess:!1})};return c.current=E,(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsx)(S,{onClose:E}),h?(0,ft.jsxs)(ft.Fragment,{children:[(0,ft.jsxs)(Zt,{children:[(0,ft.jsx)(Xp.XCircleIcon,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),(0,ft.jsx)(Ie,{title:"Something went wrong",description:"We\u2019re on it. Please try again later."})]}),(0,ft.jsx)(B,{onClick:()=>r({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):(0,ft.jsx)(Rn,{}),(0,ft.jsx)(dg,{})]})},dg=eu.default.div`
|
|
773
773
|
height: 44px;
|
|
774
|
-
`;var ou=require("@heroicons/react/24/solid"),ru=require("react");var Nt=require("react/jsx-runtime"),nu=()=>{let{user:e}=V(),{closePrivyModal:t,isNewUserThisSession:o,updateWallets:r}=R(),{app:n,data:i,onUserCloseViaDialogOrKeybindRef:a}=_(),{onSuccess:s,onFailure:l,callAuthOnSuccessOnClose:c}=i.createWallet,m=()=>{let h=ve(e);h?(r(),s(h)):l(new Error("Failed to create wallet")),t({shouldCallAuthOnSuccess:c})};return(0,ru.useEffect)(()=>{let h=setTimeout(m,ad);return()=>clearTimeout(h)},[]),a.current=m,(0,Nt.jsxs)(Nt.Fragment,{children:[(0,Nt.jsx)(S,{onClose:m}),(0,Nt.jsx)(Q,{}),(0,Nt.jsxs)(Zt,{children:[(0,Nt.jsx)(ou.CheckCircleIcon,{fill:"var(--privy-color-accent)",
|
|
774
|
+
`;var ou=require("@heroicons/react/24/solid"),ru=require("react");var Nt=require("react/jsx-runtime"),nu=()=>{let{user:e}=V(),{closePrivyModal:t,isNewUserThisSession:o,updateWallets:r}=R(),{app:n,data:i,onUserCloseViaDialogOrKeybindRef:a}=_(),{onSuccess:s,onFailure:l,callAuthOnSuccessOnClose:c}=i.createWallet,m=()=>{let h=ve(e);h?(r(),s(h)):l(new Error("Failed to create wallet")),t({shouldCallAuthOnSuccess:c})};return(0,ru.useEffect)(()=>{let h=setTimeout(m,ad);return()=>clearTimeout(h)},[]),a.current=m,(0,Nt.jsxs)(Nt.Fragment,{children:[(0,Nt.jsx)(S,{onClose:m}),(0,Nt.jsx)(Q,{}),(0,Nt.jsxs)(Zt,{children:[(0,Nt.jsx)(ou.CheckCircleIcon,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),(0,Nt.jsx)(Ie,{title:o?`Welcome${n?.name?` to ${n?.name}`:""}`:"All set!",description:o?"You\u2019ve successfully created an account.":"Your account is secured."})]}),(0,Nt.jsx)(Z,{}),(0,Nt.jsx)(G,{protectedByPrivy:!0})]})};var su=require("@heroicons/react/20/solid"),lu=require("@heroicons/react/24/outline"),zo=require("react"),Vo=x(require("styled-components"));var K=require("react/jsx-runtime"),cu=()=>{let[e,t]=(0,zo.useState)(null),{authenticated:o,user:r,getAccessToken:n}=V(),{closePrivyModal:i,createAnalyticsEvent:a,clientAnalyticsId:s}=R(),{data:l,onUserCloseViaDialogOrKeybindRef:c}=_(),m=ve(r)?.address,{onFailure:h,onSuccess:w,origin:v,appId:T}=l.keyExport,y=b=>{i({shouldCallAuthOnSuccess:!1}),h(typeof b=="string"?new Error(b):b)},E=()=>{i({shouldCallAuthOnSuccess:!1}),w(),a("embedded_wallet_key_export_completed",{walletAddress:m})};return(0,zo.useEffect)(()=>{let b=ve(r);if(!o||!b)return y("User must be authenticated before exporting their wallet");n().then(t,y)},[o,r]),c.current=E,(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(S,{onClose:E}),(0,K.jsxs)(mg,{children:[(0,K.jsxs)(Ie,{icon:(0,K.jsx)(lu.ArrowRightOnRectangleIcon,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),title:"Transfer Wallet",children:[(0,K.jsxs)(gg,{children:[(0,K.jsx)(ug,{style:{marginRight:6}}),or(m)]}),(0,K.jsx)("p",{children:"You can bring your account with you to another site using an external wallet."})]}),(0,K.jsxs)(fg,{children:[(0,K.jsxs)(iu,{children:[(0,K.jsx)(au,{children:"1"}),(0,K.jsxs)("span",{children:[(0,K.jsx)("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Follow the guide"})," ","to transfer your account to your wallet of choice."]})]}),(0,K.jsxs)(iu,{children:[(0,K.jsx)(au,{children:"2"}),(0,K.jsx)("span",{children:"Copy this key into your other wallet"})]})]}),(0,K.jsx)("div",{style:{width:"100%"},children:e&&(0,K.jsx)(pg,{origin:v,appId:T,accessToken:e,clientAnalyticsId:s,address:m,dimensions:{height:"44px"}})}),(0,K.jsxs)(vg,{children:[(0,K.jsxs)("div",{children:[(0,K.jsx)(su.ExclamationTriangleIcon,{viewBox:"0 0 20 18"}),(0,K.jsx)("h4",{children:"Warning"})]}),(0,K.jsx)("p",{children:"Never share your private key with anyone! It controls your account."})]})]}),(0,K.jsx)(G,{protectedByPrivy:!0})]})};function pg(e){let[t,o]=(0,zo.useState)(e.dimensions.width),[r,n]=(0,zo.useState)(void 0),i=(0,zo.useRef)(null);return(0,zo.useEffect)(()=>{if(i.current&&t===void 0){let{width:s}=i.current.getBoundingClientRect();o(s)}let a=getComputedStyle(document.documentElement);n({background2:a.getPropertyValue("--privy-color-background-2"),foreground3:a.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:a.getPropertyValue("--privy-color-foreground-accent"),accent:a.getPropertyValue("--privy-color-accent"),accentDark:a.getPropertyValue("--privy-color-accent-dark"),success:a.getPropertyValue("--privy-color-success")})},[]),(0,K.jsx)("div",{ref:i,children:t&&(0,K.jsxs)(hg,{children:[(0,K.jsx)("iframe",{style:{position:"absolute",zIndex:1},width:t,height:e.dimensions.height,allow:"clipboard-write self *",src:ca(e.origin,`/apps/${e.appId}/embedded-wallets/export`,{token:e.accessToken,address:e.address,width:`${t}px`,caid:e.clientAnalyticsId,...r})}),(0,K.jsx)(yg,{children:"Loading..."})]})})}function ug(e){return(0,K.jsx)("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:e.style,children:(0,K.jsx)("path",{d:"M14 8.81335C14 7.98493 13.3284 7.31335 12.5 7.31335H10C10 8.41792 9.10457 9.31335 8 9.31335C6.89543 9.31335 6 8.41792 6 7.31335H3.5C2.67157 7.31335 2 7.98493 2 8.81335M14 8.81335V12.8134C14 13.6418 13.3284 14.3134 12.5 14.3134H3.5C2.67157 14.3134 2 13.6418 2 12.8134V8.81335M14 8.81335V6.81335M2 8.81335V6.81335M14 6.81335C14 5.98493 13.3284 5.31335 12.5 5.31335H3.5C2.67157 5.31335 2 5.98493 2 6.81335M14 6.81335V4.81335C14 3.98493 13.3284 3.31335 12.5 3.31335H3.5C2.67157 3.31335 2 3.98493 2 4.81335V6.81335",stroke:"var(--privy-color-foreground-3)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var mg=Vo.default.div`
|
|
775
775
|
display: flex;
|
|
776
776
|
flex-direction: column;
|
|
777
777
|
text-align: left;
|
|
@@ -1085,7 +1085,7 @@ Resources:
|
|
|
1085
1085
|
|
|
1086
1086
|
${t}
|
|
1087
1087
|
|
|
1088
|
-
You will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;var Ka=require("@heroicons/react/24/outline");var Ze=require("react/jsx-runtime"),Lu=({error:e,onClose:t})=>(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)(S,{closeable:!1}),(0,Ze.jsx)(Q,{}),e?(0,Ze.jsxs)(Zt,{children:[(0,Ze.jsx)(Ka.XCircleIcon,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}),(0,Ze.jsx)(Ie,{title:"Something went wrong",description:e})]}):(0,Ze.jsxs)(Zt,{children:[(0,Ze.jsx)(Ka.CheckCircleIcon,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,Ze.jsx)(Ie,{title:"Success"})]}),(0,Ze.jsx)(B,{onClick:t,children:"Close"}),(0,Ze.jsx)(Z,{}),(0,Ze.jsx)(G,{protectedByPrivy:!0})]});var Nu=require("react"),Fg=(e,t)=>{switch(e){case"creating":return t==="back"?e:"saving";case"saving":return t==="back"?"creating":"confirming";case"confirming":return t==="back"?"saving":"finalizing";case"finalizing":return t==="back"?"confirming":"done";default:return e}},Ou=()=>{let[e,t]=(0,Nu.useReducer)(Fg,"creating");return{send:t,state:e}};var Dn=require("react/jsx-runtime"),Ya=({onSubmit:e,...t})=>{let{send:o,state:r}=Ou(),n=(0,bi.useCallback)(async()=>{r==="finalizing"&&await e(),o("next")},[r,o,e]);(0,bi.useEffect)(()=>{let a;return r==="done"&&t.config.initiatedBy==="automatic"&&(a=setTimeout(()=>t.onClose?.(),Et)),()=>{a&&clearTimeout(a)}},[r,t.config.initiatedBy,t.onClose]);let i=(0,bi.useCallback)(()=>{o("back")},[o]);return r==="creating"?(0,Dn.jsx)(Wu,{...t,onSubmit:n}):r==="saving"?(0,Dn.jsx)(Mu,{...t,onSubmit:n,onBack:i}):r==="confirming"?(0,Dn.jsx)(hu,{...t,onSubmit:n,onBack:i}):r==="finalizing"?(0,Dn.jsx)(Eu,{...t,onSubmit:n,onBack:i}):r==="done"?(0,Dn.jsx)(Lu,{...t,onSubmit:n}):null};var Ot=require("react/jsx-runtime"),Bg=250,Uu=()=>{let{app:e,navigate:t,data:o,onUserCloseViaDialogOrKeybindRef:r}=_(),[n,i]=(0,ro.useState)(""),[a,s]=(0,ro.useState)(!1),[l,c]=(0,ro.useState)(),[m,h]=(0,ro.useState)(null),[w,v]=(0,ro.useState)(null),T=(0,ro.useRef)(!1),{authenticated:y,getAccessToken:E}=V(),{refreshUser:b,closePrivyModal:M,createAnalyticsEvent:L,isNewUserThisSession:O,initializeWalletProxy:W}=R(),{onSuccess:A,onFailure:I,callAuthOnSuccessOnClose:F}=o.createWallet,Y=e?.embeddedWallets.requireUserPasswordOnCreate===!0,$=!!(!n||T.current)&&!Y,k=new It(async()=>be());(0,ro.useEffect)(()=>{m||W(3e4).then(U=>h(U))},[m]),(0,ro.useEffect)(()=>{if(!y){t("LANDING"),I(new Error("User must be authenticated before creating a Privy wallet"));return}!Y&&!a&&!T.current&&(s(!0),k.execute().finally(()=>s(!1)))},[Y,y]);let X=()=>{Y&&w&&w?.recoveryMethod!=="user-passcode"?I(new Ct("User created a wallet but failed to set a password for it")):w?A(w):I(new Ct("User wallet creation failed")),M({shouldCallAuthOnSuccess:F})};r.current=()=>null;let be=async function(){let U=await E();if(U)try{if(L("embedded_wallet_creation_started"),!await(await W(sn))?.create({accessToken:U,recoveryPassword:l}))throw L("embedded_wallet_creation_failed",{error:"walletProxy did not send a response."}),new Error("Unable to create wallet");let Ee=await b(),zt=ve(Ee);if(!zt)throw L("embedded_wallet_creation_failed",{error:"Updated user is missing embedded wallet."}),new Error("Unable to create wallet");v(zt),L("embedded_wallet_creation_completed",{walletAddress:zt.address}),i(""),T.current=!0,Y?t("EMBEDDED_WALLET_CREATED_SCREEN"):O?t("EMBEDDED_WALLET_CREATED_SCREEN"):zt&&(A(zt),M({shouldCallAuthOnSuccess:F}))}catch(tt){if(T.current)return;i("An error has occurred, please try again."),console.warn(tt)}else i("An error has occured, please login again."),L("embedded_wallet_creation_failed",{error:"Missing access token for user."})},Le=async()=>Y?(s(!0),k.execute().then(()=>new Promise(U=>setTimeout(U,Bg))).finally(()=>s(!1))):M({shouldCallAuthOnSuccess:F});return!Y&&n?(0,Ot.jsxs)(Ot.Fragment,{children:[(0,Ot.jsx)(S,{closeable:!1}),(0,Ot.jsxs)(Zt,{children:[(0,Ot.jsx)(Du.XCircleIcon,{fill:"var(--privy-color-error)",stroke:"white",strokeWidth:".25px",width:"64px",height:"64px"}),(0,Ot.jsx)(Ie,{title:"Something went wrong",description:n})]}),(0,Ot.jsx)(B,{onClick:X,children:"Close"})]}):$?(0,Ot.jsx)(Rn,{}):(0,Ot.jsx)(Ya,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:$||!m,buttonLoading:a,buttonHideAnimations:!w&&a,error:n,password:l||"",onClose:X,onPasswordChange:c,onPasswordGenerate:()=>c(qa()),onSubmit:Le})};var Fr=require("react");var Bu=require("react/jsx-runtime"),Fu=()=>{let[e,t]=(0,Fr.useState)(null),[o,r]=(0,Fr.useState)(!1),[n,i]=(0,Fr.useState)(null),[a,s]=(0,Fr.useState)(""),{authenticated:l,getAccessToken:c,user:m}=V(),{walletProxy:h,refreshUser:w,closePrivyModal:v,createAnalyticsEvent:T}=R(),{app:y,navigate:E,data:b,onUserCloseViaDialogOrKeybindRef:M}=_(),{onSuccess:L,onFailure:O}=b.createWallet,W=ve(m),A=e?.recoveryMethod==="user-passcode";(0,Fr.useEffect)(()=>{l||(E("LANDING"),O(new Qi("User must be authenticated before setting a password on a Privy wallet")))},[l]);let I=()=>{if(n){O(n),v({shouldCallAuthOnSuccess:!1});return}if(!A){O(new Ct("Exited before password was added to wallet")),v({shouldCallAuthOnSuccess:!1});return}L(e),v({shouldCallAuthOnSuccess:!1})};M.current=I;let F=async()=>{let $=await c();if($&&W?.address&&a&&h)try{if(T("embedded_wallet_set_password_started",{walletAddress:W.address}),!(await h.setRecoveryPassword({accessToken:$,address:W.address,recoveryPassword:a})).address){i(new Ct("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:W.address,reason:"error setting password"});return}let X=await w(),be=ve(X);if(!be){i(new Ct("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:W.address,reason:"wallet disconnected"});return}t(be),T("embedded_wallet_set_password_completed",{walletAddress:W.address})}catch(k){console.warn(k),i(k instanceof Error?k:new Error("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:W.address,reason:k})}},Y=async()=>{A?(L(e),v({shouldCallAuthOnSuccess:!1})):(r(!0),i(null),await F(),r(!1))};return(0,Bu.jsx)(Ya,{appName:y?.name||"privy",config:{initiatedBy:"user",onCancel:I},error:n?"An error has occurred, please try again.":void 0,buttonLoading:o,buttonHideAnimations:!1,password:a,onPasswordGenerate:()=>s(qa()),onPasswordChange:s,onSubmit:Y,onClose:I})};var Hu=require("@heroicons/react/24/outline"),Gu=require("@heroicons/react/24/solid");var $e=require("react/jsx-runtime"),zu=()=>{let{user:e}=V(),{closePrivyModal:t,createAnalyticsEvent:o}=R(),{data:r,setModalData:n,navigate:i,onUserCloseViaDialogOrKeybindRef:a}=_(),{onSuccess:s,onFailure:l}=r.setWalletPassword,c=()=>{l(new Ct("Exited before password was added to wallet")),t({shouldCallAuthOnSuccess:!1})};return a.current=c,(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(S,{onClose:c}),(0,$e.jsx)(Q,{}),(0,$e.jsxs)(Zt,{children:[(0,$e.jsxs)(wp,{children:[(0,$e.jsx)(Hu.UserCircleIcon,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),(0,$e.jsx)(Cp,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:(0,$e.jsx)(Gu.LockClosedIcon,{width:"12px",height:"12px",fill:"white"})})]}),(0,$e.jsxs)(Ie,{title:"Secure Your Account",children:["Please set a password to secure your account.",(0,$e.jsx)("p",{children:"Losing this password will make your account inaccessible on new devices. You will only be asked for it when you log on to a new device."})]})]}),(0,$e.jsx)(B,{onClick:()=>{let h=ve(e);o("embedded_wallet_set_password_started",{walletAddress:h?.address}),n({createWallet:{onFailure:l,onSuccess:s,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),i("EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN")},children:"Add password"}),(0,$e.jsx)(Z,{}),(0,$e.jsx)(G,{protectedByPrivy:!0})]})};var Vu=require("@heroicons/react/24/outline"),Br=require("react"),Hr=x(require("styled-components"));var de=require("react/jsx-runtime"),$u=()=>{let[e,t]=(0,Br.useState)(!0),{authenticated:o,getAccessToken:r}=V(),{walletProxy:n,closePrivyModal:i,createAnalyticsEvent:a}=R(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:c}=_(),[m,h]=(0,Br.useState)(void 0),[w,v]=(0,Br.useState)(""),[T,y]=(0,Br.useState)(!1),{privyWallet:E,onCompleteNavigateTo:b,onSuccess:M,onFailure:L}=l.recoverWallet,O=(I="User exited before their wallet could be recovered")=>{i({shouldCallAuthOnSuccess:!1}),L(typeof I=="string"?new Ct(I):I)};c.current=O,(0,Br.useEffect)(()=>{if(!o||!E)return O("User must be authenticated and have a Privy wallet before it can be recovered")},[o]);let W=I=>{I&&h(I)};return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(S,{onClose:O}),(0,de.jsx)(Q,{}),(0,de.jsxs)(Gg,{children:[(0,de.jsxs)(Hg,{children:[(0,de.jsx)(Vu.ShieldCheckIcon,{height:48,width:48,stroke:"var(--privy-color-accent)"}),(0,de.jsx)("h3",{style:{color:"var(--privy-color-foreground)"},children:"Load your account"}),(0,de.jsx)("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)(ur,{children:[(0,de.jsx)(Ur,{type:e?"password":"text",onChange:I=>W(I.target.value),disabled:T}),(0,de.jsx)(Mn,{style:{right:"0.75rem"},children:e?(0,de.jsx)(Ln,{onClick:()=>t(!1)}):(0,de.jsx)(Nn,{onClick:()=>t(!0)})})]}),!!w&&(0,de.jsx)(zg,{children:w})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)(vp,{children:[(0,de.jsx)("h4",{children:"Why is this necessary?"}),(0,de.jsx)("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),(0,de.jsx)(Vg,{loading:T||!n,disabled:!m,onClick:async()=>{y(!0);let I=await r();if(I&&E&&m!==null)try{a("embedded_wallet_recovery_started",{walletAddress:E.address}),await n?.recover({address:E.address,accessToken:I,recoveryPin:m}),v(""),b?s(b):i({shouldCallAuthOnSuccess:!1}),M?.(E),a("embedded_wallet_recovery_completed",{walletAddress:E.address})}catch(F){Jp(F)?v("Invalid recovery password, please try again."):v("An error has occurred, please try again.")}finally{y(!1)}else return O("User must be authenticated and have a Privy wallet before it can be recovered")},warn:!1,hideAnimations:!E&&T,children:"Recover your account"})]})]}),(0,de.jsx)(Z,{}),(0,de.jsx)(G,{protectedByPrivy:!0})]})},Hg=Hr.default.div`
|
|
1088
|
+
You will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;var Ka=require("@heroicons/react/24/outline");var Ze=require("react/jsx-runtime"),Lu=({error:e,onClose:t})=>(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)(S,{closeable:!1}),(0,Ze.jsx)(Q,{}),e?(0,Ze.jsxs)(Zt,{children:[(0,Ze.jsx)(Ka.XCircleIcon,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}),(0,Ze.jsx)(Ie,{title:"Something went wrong",description:e})]}):(0,Ze.jsxs)(Zt,{children:[(0,Ze.jsx)(Ka.CheckCircleIcon,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),(0,Ze.jsx)(Ie,{title:"Success"})]}),(0,Ze.jsx)(B,{onClick:t,children:"Close"}),(0,Ze.jsx)(Z,{}),(0,Ze.jsx)(G,{protectedByPrivy:!0})]});var Nu=require("react"),Fg=(e,t)=>{switch(e){case"creating":return t==="back"?e:"saving";case"saving":return t==="back"?"creating":"confirming";case"confirming":return t==="back"?"saving":"finalizing";case"finalizing":return t==="back"?"confirming":"done";default:return e}},Ou=()=>{let[e,t]=(0,Nu.useReducer)(Fg,"creating");return{send:t,state:e}};var Dn=require("react/jsx-runtime"),Ya=({onSubmit:e,...t})=>{let{send:o,state:r}=Ou(),n=(0,bi.useCallback)(async()=>{r==="finalizing"&&await e(),o("next")},[r,o,e]);(0,bi.useEffect)(()=>{let a;return r==="done"&&t.config.initiatedBy==="automatic"&&(a=setTimeout(()=>t.onClose?.(),Et)),()=>{a&&clearTimeout(a)}},[r,t.config.initiatedBy,t.onClose]);let i=(0,bi.useCallback)(()=>{o("back")},[o]);return r==="creating"?(0,Dn.jsx)(Wu,{...t,onSubmit:n}):r==="saving"?(0,Dn.jsx)(Mu,{...t,onSubmit:n,onBack:i}):r==="confirming"?(0,Dn.jsx)(hu,{...t,onSubmit:n,onBack:i}):r==="finalizing"?(0,Dn.jsx)(Eu,{...t,onSubmit:n,onBack:i}):r==="done"?(0,Dn.jsx)(Lu,{...t,onSubmit:n}):null};var Ot=require("react/jsx-runtime"),Bg=250,Uu=()=>{let{app:e,navigate:t,data:o,onUserCloseViaDialogOrKeybindRef:r}=_(),[n,i]=(0,ro.useState)(""),[a,s]=(0,ro.useState)(!1),[l,c]=(0,ro.useState)(),[m,h]=(0,ro.useState)(null),[w,v]=(0,ro.useState)(null),T=(0,ro.useRef)(!1),{authenticated:y,getAccessToken:E}=V(),{refreshUser:b,closePrivyModal:M,createAnalyticsEvent:L,isNewUserThisSession:O,initializeWalletProxy:W}=R(),{onSuccess:A,onFailure:I,callAuthOnSuccessOnClose:F}=o.createWallet,Y=e?.embeddedWallets.requireUserPasswordOnCreate===!0,$=!!(!n||T.current)&&!Y,k=new It(async()=>be());(0,ro.useEffect)(()=>{m||W(3e4).then(U=>h(U))},[m]),(0,ro.useEffect)(()=>{if(!y){t("LANDING"),I(new Error("User must be authenticated before creating a Privy wallet"));return}!Y&&!a&&!T.current&&(s(!0),k.execute().finally(()=>s(!1)))},[Y,y]);let X=()=>{Y&&w&&w?.recoveryMethod!=="user-passcode"?I(new Ct("User created a wallet but failed to set a password for it")):w?A(w):I(new Ct("User wallet creation failed")),M({shouldCallAuthOnSuccess:F})};r.current=()=>null;let be=async function(){let U=await E();if(U)try{if(L("embedded_wallet_creation_started"),!await(await W(sn))?.create({accessToken:U,recoveryPassword:l}))throw L("embedded_wallet_creation_failed",{error:"walletProxy did not send a response."}),new Error("Unable to create wallet");let Ee=await b(),zt=ve(Ee);if(!zt)throw L("embedded_wallet_creation_failed",{error:"Updated user is missing embedded wallet."}),new Error("Unable to create wallet");v(zt),L("embedded_wallet_creation_completed",{walletAddress:zt.address}),i(""),T.current=!0,Y?t("EMBEDDED_WALLET_CREATED_SCREEN"):O?t("EMBEDDED_WALLET_CREATED_SCREEN"):zt&&(A(zt),M({shouldCallAuthOnSuccess:F}))}catch(tt){if(T.current)return;i("An error has occurred, please try again."),console.warn(tt)}else i("An error has occured, please login again."),L("embedded_wallet_creation_failed",{error:"Missing access token for user."})},Le=async()=>Y?(s(!0),k.execute().then(()=>new Promise(U=>setTimeout(U,Bg))).finally(()=>s(!1))):M({shouldCallAuthOnSuccess:F});return!Y&&n?(0,Ot.jsxs)(Ot.Fragment,{children:[(0,Ot.jsx)(S,{closeable:!1}),(0,Ot.jsxs)(Zt,{children:[(0,Ot.jsx)(Du.XCircleIcon,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),(0,Ot.jsx)(Ie,{title:"Something went wrong",description:n})]}),(0,Ot.jsx)(B,{onClick:X,children:"Close"})]}):$?(0,Ot.jsx)(Rn,{}):(0,Ot.jsx)(Ya,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:$||!m,buttonLoading:a,buttonHideAnimations:!w&&a,error:n,password:l||"",onClose:X,onPasswordChange:c,onPasswordGenerate:()=>c(qa()),onSubmit:Le})};var Fr=require("react");var Bu=require("react/jsx-runtime"),Fu=()=>{let[e,t]=(0,Fr.useState)(null),[o,r]=(0,Fr.useState)(!1),[n,i]=(0,Fr.useState)(null),[a,s]=(0,Fr.useState)(""),{authenticated:l,getAccessToken:c,user:m}=V(),{walletProxy:h,refreshUser:w,closePrivyModal:v,createAnalyticsEvent:T}=R(),{app:y,navigate:E,data:b,onUserCloseViaDialogOrKeybindRef:M}=_(),{onSuccess:L,onFailure:O}=b.createWallet,W=ve(m),A=e?.recoveryMethod==="user-passcode";(0,Fr.useEffect)(()=>{l||(E("LANDING"),O(new Qi("User must be authenticated before setting a password on a Privy wallet")))},[l]);let I=()=>{if(n){O(n),v({shouldCallAuthOnSuccess:!1});return}if(!A){O(new Ct("Exited before password was added to wallet")),v({shouldCallAuthOnSuccess:!1});return}L(e),v({shouldCallAuthOnSuccess:!1})};M.current=I;let F=async()=>{let $=await c();if($&&W?.address&&a&&h)try{if(T("embedded_wallet_set_password_started",{walletAddress:W.address}),!(await h.setRecoveryPassword({accessToken:$,address:W.address,recoveryPassword:a})).address){i(new Ct("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:W.address,reason:"error setting password"});return}let X=await w(),be=ve(X);if(!be){i(new Ct("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:W.address,reason:"wallet disconnected"});return}t(be),T("embedded_wallet_set_password_completed",{walletAddress:W.address})}catch(k){console.warn(k),i(k instanceof Error?k:new Error("Error setting password on privy wallet")),T("embedded_wallet_set_password_failed",{walletAddress:W.address,reason:k})}},Y=async()=>{A?(L(e),v({shouldCallAuthOnSuccess:!1})):(r(!0),i(null),await F(),r(!1))};return(0,Bu.jsx)(Ya,{appName:y?.name||"privy",config:{initiatedBy:"user",onCancel:I},error:n?"An error has occurred, please try again.":void 0,buttonLoading:o,buttonHideAnimations:!1,password:a,onPasswordGenerate:()=>s(qa()),onPasswordChange:s,onSubmit:Y,onClose:I})};var Hu=require("@heroicons/react/24/outline"),Gu=require("@heroicons/react/24/solid");var $e=require("react/jsx-runtime"),zu=()=>{let{user:e}=V(),{closePrivyModal:t,createAnalyticsEvent:o}=R(),{data:r,setModalData:n,navigate:i,onUserCloseViaDialogOrKeybindRef:a}=_(),{onSuccess:s,onFailure:l}=r.setWalletPassword,c=()=>{l(new Ct("Exited before password was added to wallet")),t({shouldCallAuthOnSuccess:!1})};return a.current=c,(0,$e.jsxs)($e.Fragment,{children:[(0,$e.jsx)(S,{onClose:c}),(0,$e.jsx)(Q,{}),(0,$e.jsxs)(Zt,{children:[(0,$e.jsxs)(wp,{children:[(0,$e.jsx)(Hu.UserCircleIcon,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),(0,$e.jsx)(Cp,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:(0,$e.jsx)(Gu.LockClosedIcon,{width:"12px",height:"12px",fill:"white"})})]}),(0,$e.jsxs)(Ie,{title:"Secure Your Account",children:["Please set a password to secure your account.",(0,$e.jsx)("p",{children:"Losing this password will make your account inaccessible on new devices. You will only be asked for it when you log on to a new device."})]})]}),(0,$e.jsx)(B,{onClick:()=>{let h=ve(e);o("embedded_wallet_set_password_started",{walletAddress:h?.address}),n({createWallet:{onFailure:l,onSuccess:s,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),i("EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN")},children:"Add password"}),(0,$e.jsx)(Z,{}),(0,$e.jsx)(G,{protectedByPrivy:!0})]})};var Vu=require("@heroicons/react/24/outline"),Br=require("react"),Hr=x(require("styled-components"));var de=require("react/jsx-runtime"),$u=()=>{let[e,t]=(0,Br.useState)(!0),{authenticated:o,getAccessToken:r}=V(),{walletProxy:n,closePrivyModal:i,createAnalyticsEvent:a}=R(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:c}=_(),[m,h]=(0,Br.useState)(void 0),[w,v]=(0,Br.useState)(""),[T,y]=(0,Br.useState)(!1),{privyWallet:E,onCompleteNavigateTo:b,onSuccess:M,onFailure:L}=l.recoverWallet,O=(I="User exited before their wallet could be recovered")=>{i({shouldCallAuthOnSuccess:!1}),L(typeof I=="string"?new Ct(I):I)};c.current=O,(0,Br.useEffect)(()=>{if(!o||!E)return O("User must be authenticated and have a Privy wallet before it can be recovered")},[o]);let W=I=>{I&&h(I)};return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(S,{onClose:O}),(0,de.jsx)(Q,{}),(0,de.jsxs)(Gg,{children:[(0,de.jsxs)(Hg,{children:[(0,de.jsx)(Vu.ShieldCheckIcon,{height:48,width:48,stroke:"var(--privy-color-accent)"}),(0,de.jsx)("h3",{style:{color:"var(--privy-color-foreground)"},children:"Load your account"}),(0,de.jsx)("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)(ur,{children:[(0,de.jsx)(Ur,{type:e?"password":"text",onChange:I=>W(I.target.value),disabled:T}),(0,de.jsx)(Mn,{style:{right:"0.75rem"},children:e?(0,de.jsx)(Ln,{onClick:()=>t(!1)}):(0,de.jsx)(Nn,{onClick:()=>t(!0)})})]}),!!w&&(0,de.jsx)(zg,{children:w})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)(vp,{children:[(0,de.jsx)("h4",{children:"Why is this necessary?"}),(0,de.jsx)("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),(0,de.jsx)(Vg,{loading:T||!n,disabled:!m,onClick:async()=>{y(!0);let I=await r();if(I&&E&&m!==null)try{a("embedded_wallet_recovery_started",{walletAddress:E.address}),await n?.recover({address:E.address,accessToken:I,recoveryPin:m}),v(""),b?s(b):i({shouldCallAuthOnSuccess:!1}),M?.(E),a("embedded_wallet_recovery_completed",{walletAddress:E.address})}catch(F){Jp(F)?v("Invalid recovery password, please try again."):v("An error has occurred, please try again.")}finally{y(!1)}else return O("User must be authenticated and have a Privy wallet before it can be recovered")},warn:!1,hideAnimations:!E&&T,children:"Recover your account"})]})]}),(0,de.jsx)(Z,{}),(0,de.jsx)(G,{protectedByPrivy:!0})]})},Hg=Hr.default.div`
|
|
1089
1089
|
display: flex;
|
|
1090
1090
|
flex-direction: column;
|
|
1091
1091
|
align-items: center;
|
package/package.json
CHANGED