@privy-io/react-auth 2.7.0 → 2.7.1

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.
Files changed (42) hide show
  1. package/dist/cjs/abstract-smart-wallets.js +1 -1
  2. package/dist/cjs/farcaster.js +1 -1
  3. package/dist/cjs/{frame-Mqj2ph9n.js → frame-B-Or6HA6.js} +1 -1
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/internal-context-D-972JmA.js +1 -0
  6. package/dist/cjs/privy-provider-kUjrC6Cw.js +27 -0
  7. package/dist/cjs/{smart-wallets-C7PSePsj.js → smart-wallets-DC0Ul4x6.js} +1 -1
  8. package/dist/cjs/smart-wallets.js +1 -1
  9. package/dist/cjs/solana.js +1 -1
  10. package/dist/cjs/ui.js +1 -1
  11. package/dist/cjs/{useActiveWallet-ZMzj2yZK.js → useActiveWallet-Vcnggwyv.js} +1 -1
  12. package/dist/cjs/{useFundWallet-B-le1Hwp.js → useFundWallet-BYGqrtqz.js} +1 -1
  13. package/dist/dts/farcaster.d.mts +2 -2
  14. package/dist/dts/farcaster.d.ts +2 -2
  15. package/dist/dts/index.d.mts +19 -121
  16. package/dist/dts/index.d.ts +19 -121
  17. package/dist/dts/smart-wallets.d.mts +3 -3
  18. package/dist/dts/smart-wallets.d.ts +3 -3
  19. package/dist/dts/solana.d.mts +5 -5
  20. package/dist/dts/solana.d.ts +5 -5
  21. package/dist/dts/{types-Bv6KFBSe.d.mts → types-Cq3xKsys.d.mts} +3 -195
  22. package/dist/dts/{types-Bv6KFBSe.d.ts → types-Cq3xKsys.d.ts} +3 -195
  23. package/dist/dts/ui.d.mts +3 -3
  24. package/dist/dts/ui.d.ts +3 -3
  25. package/dist/dts/{useSolanaWallets-DmfTxIs8.d.mts → useSolanaWallets-BADh6ZyK.d.mts} +2 -1
  26. package/dist/dts/{useSolanaWallets-DmfTxIs8.d.ts → useSolanaWallets-BADh6ZyK.d.ts} +2 -1
  27. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  28. package/dist/esm/farcaster.mjs +1 -1
  29. package/dist/esm/{frame-BqfuK5mX.mjs → frame-BpnDpebm.mjs} +1 -1
  30. package/dist/esm/index.mjs +1 -1
  31. package/dist/esm/{internal-context-cnN4FGtP.mjs → internal-context-D95Bns6A.mjs} +1 -1
  32. package/dist/esm/privy-provider-BCKJFtPt.mjs +27 -0
  33. package/dist/esm/{smart-wallets-CD4dnxap.mjs → smart-wallets-CkUTq3Ym.mjs} +1 -1
  34. package/dist/esm/smart-wallets.mjs +1 -1
  35. package/dist/esm/solana.mjs +1 -1
  36. package/dist/esm/ui.mjs +2 -2
  37. package/dist/esm/{useActiveWallet-BX_Fj6ki.mjs → useActiveWallet-jAsui8zn.mjs} +1 -1
  38. package/dist/esm/{useFundWallet-C43hxi7R.mjs → useFundWallet-ChktspDK.mjs} +1 -1
  39. package/package.json +6 -5
  40. package/dist/cjs/internal-context-D_DHIn45.js +0 -1
  41. package/dist/cjs/privy-provider-BZuQMAQL.js +0 -27
  42. package/dist/esm/privy-provider-CPOch3uT.mjs +0 -27
@@ -1 +1 @@
1
- import{u as e,g as i,a as n,b as s,c as l,d as h,C as d,e as m,s as k,P as f,f as C,h as W,i as T,G as U,W as R,j as S,k as P,l as N,m as O,n as _}from"./privy-provider-CPOch3uT.mjs";export{q as Captcha,r as ConnectorManager,E as EthereumWalletConnector,M as LoginModal,A as PrivyClient,o as PrivyProvider,J as SUPPORTED_CHAINS,V as VERSION,t as WalletConnector,L as addPrivyRpcToChain,K as addRpcUrlOverrideToChain,y as errorIndicatesMaxMfaRetries,z as errorIndicatesMfaTimeout,x as errorIndicatesMfaVerificationFailed,p as getAccessToken,B as useIdentityToken,I as useImportWallet,D as useLogout,v as useMfa,w as useMfaEnrollment,F as useRegisterMfaListener,H as useSolanaWallets}from"./privy-provider-CPOch3uT.mjs";import{useCallback as j,useMemo as G,useEffect as Q,useContext as X}from"react";import{u as $,P as Y,a as Z,I as ee}from"./internal-context-cnN4FGtP.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-BX_Fj6ki.mjs";import{F as te}from"./frame-BqfuK5mX.mjs";import{zeroAddress as re,getAddress as oe,createWalletClient as ie,http as ne,parseSignature as ae}from"viem";import{eip7702Actions as se,hashAuthorization as ce}from"viem/experimental";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"react/jsx-runtime";import"mipd";import"react-device-detect";import"viem/utils";import"uuid";import"jose";import"eventemitter3";import"@coinbase/wallet-sdk";import"@privy-io/js-sdk-core";import"@marsidev/react-turnstile";import"styled-components";import"tinycolor2";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@headlessui/react";import"@walletconnect/ethereum-provider";import"zustand";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"qrcode";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const le=()=>{let{user:t}=e(),{walletProxy:r}=$();return{recover:j((async e=>{if(!r)throw Error("Wallet proxy is not ready");let o=await i();if(!t||!o)throw new Y("User must be logged in before attempting to modify the recovery method.");let{entropyId:a,entropyIdVerifier:s}=n(t);try{await r.recover({entropyId:a,entropyIdVerifier:s,accessToken:o,...e})}catch{throw new Y("Unable to recover wallets")}}),[r,t])}},ue=()=>{let{client:e,setAuthenticated:t,setUser:r}=$();return G((()=>({init:async()=>{if(!e)throw new Y("Must initialize Privy client first.");let t=new te;return e.startAuthFlow(t),await t.init()},login:async({fid:o,message:i,signature:n})=>{if(!e)throw new Y("Must initialize Privy client first.");if(!(e.authFlow instanceof te))throw new Y("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:i,signature:n,fid:o});let{user:a}=await e.authenticate();if(!a)throw new Y("Failed to login with Farcaster V2");return r(a),t(!0),{user:a}}})),[e,r,t])},he=t=>{s("login",t);let r=l(),o=h(),{ready:i,user:n}=e(),{initLoginWithHeadlessOAuth:a,loginWithHeadlessOAuth:c,oAuthState:u,setOAuthState:p,isHeadlessOAuthLoading:w}=$(),g=j((async e=>{try{if(r.enabled&&"success"!==r.status)throw new d(r.error,null,Z.CAPTCHA_FAILURE);return await a(e.provider,r.token,e.disableSignup)}catch(e){throw p({status:"error",error:e}),e}}),[a,r]),A=j((async()=>{let e=m();try{if(n)return console.warn("Cannot login with OAuth when already logged in"),n;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw p({status:"error",error:e}),e}try{return await c(e)}catch(e){throw p({status:"error",error:e}),e}finally{k()}}),[c]);return Q((()=>{let e=m();i&&o&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&A().catch((()=>{}))}),[i,o]),{initOAuth:g,loading:w,state:u}},de=e=>{let t=l(),{emailOtpState:r,setEmailOtpState:o,initLoginWithEmail:i,loginWithCode:n}=$();return{sendCode:j((async({email:r,disableSignup:n})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({email:r,captchaToken:e,disableSignup:n,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),r}}),[i]),loginWithCode:j((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:s}=await n(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"email",loginAccount:s})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},pe=e=>{let t=l(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:i,setPasskeyAuthState:n}=$();return{signupWithPasskey:j((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await r({captchaToken:i,withPrivyUi:!1});let{user:n,isNewUser:a,wasAlreadyAuthenticated:s,loginAccount:c}=await o();e?.onComplete?.({user:n,isNewUser:a,wasAlreadyAuthenticated:s,loginMethod:"passkey",loginAccount:c})}catch(t){throw n({status:"error",error:t}),e?.onError?.(t.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),t}}),[o,t.status]),state:i}},we=e=>{let t=l(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:i,setPasskeyAuthState:n}=$();return{loginWithPasskey:j((async i=>{try{let n;if(t.enabled&&"error"===t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),n=await t.waitForResult()),await r({captchaToken:n,withPrivyUi:!1});let{user:a,isNewUser:s,wasAlreadyAuthenticated:c,loginAccount:l}=await o(i);e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:l})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),i}}),[o,t.status]),state:i}},me=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:o,setPasskeyAuthState:i}=$();return{linkWithPasskey:j((async()=>{try{await t();let o=await r();if(!o)throw Error("Error, user not found");let i=o.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:o,linkMethod:"passkey",linkedAccount:i})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||Z.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:o}},ge=e=>{let t=l(),{smsOtpState:r,setSmsOtpState:o,initLoginWithSms:i,loginWithCode:n}=$();return{sendCode:j((async({phoneNumber:r,disableSignup:n})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({phoneNumber:r,captchaToken:e,disableSignup:n,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),r}}),[i]),loginWithCode:j((async({code:r})=>{try{if(t.enabled&&"success"!==t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:s}=await n(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"sms",loginAccount:s})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},Ae=t=>{let{connectOrCreateWallet:r}=e();return s("connectOrCreateWallet",t),{connectOrCreateWallet:r}},ye=e=>{let t=l(),{siweState:r,setSiweState:o,linkWithSiwe:i,generateSiweMessage:n}=$();return{generateSiweMessage:j((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await n({address:t,chainId:r}).then((e=>e))}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||Z.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[n]),linkWithSiwe:j((async({signature:r,message:n,chainId:a,walletClientType:s,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);let{user:o,linkedAccount:l}=await i({message:n,signature:r,chainId:a,walletClientType:s,connectorType:c});l&&e?.onSuccess?.({user:o,linkMethod:"siwe",linkedAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||Z.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[i,t.status]),state:r}};function ke(){let{signTransaction:e}=X(f);return{signTransaction:e}}function fe(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:i,linkApple:n,linkTwitter:a,linkDiscord:c,linkGithub:l,linkLinkedIn:u,linkTiktok:h,linkSpotify:d,linkInstagram:p,linkTelegram:w,linkFarcaster:m}=X(f);return s("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:i,linkApple:n,linkTwitter:a,linkDiscord:c,linkGithub:l,linkLinkedIn:u,linkTiktok:h,linkSpotify:d,linkInstagram:p,linkFarcaster:m,linkTelegram:w}}function Ce(e){let{updateEmail:t,updatePhone:r}=X(f);return s("update",e),{updateEmail:t,updatePhone:r}}function Ie(e){let{createWallet:t}=X(f);return s("createWallet",e),{createWallet:t}}const We=()=>{let{connectCoinbaseSmartWallet:e}=$();return{connectCoinbaseSmartWallet:e}},Ee=()=>{let{startCrossAppAuthFlow:t,unlinkCrossAppAccount:r,signMessageWithCrossAppWallet:o,signTypedDataWithCrossAppWallet:i,sendTransactionWithCrossAppWallet:n}=e();return{loginWithCrossAppAccount:({appId:e})=>t({appId:e,action:"login"}),linkCrossAppAccount:({appId:e})=>t({appId:e,action:"link"}),unlinkCrossAppAccount:r,signMessage:o,signTypedData:i,sendTransaction:n}};function Te(e){let{sendTransaction:t}=X(f);return s("sendTransaction",e),{sendTransaction:t}}function Ue(e){let{setWalletPassword:t}=X(f);return s("setWalletPassword",e),{setWalletPassword:t}}function Re(){let e=C(),{getAccessToken:t,createWallet:r}=W(),o=T(),{client:i,setUser:n,setAuthenticated:a,setIsNewUser:s,initializeWalletProxy:c,refreshSessionAndUser:l}=$();return{createGuestAccount:async()=>{if(!e.id||!i)throw Error("SDK not yet ready");i.startAuthFlow(new U(e.id));try{let{user:u,isNewUser:h}=await i.authenticate();if(h=h||!1,!u)throw new Y("Unable to authenticate guest account");let d=await t(),p=await c(R);if(d&&p)try{let t=S(u,e.embeddedWallets.ethereum.createOnLogin),o=P(u,e.embeddedWallets.solana.createOnLogin);if(t&&o){let e=await r();await p.createSolana({accessToken:d,ethereumAddress:e?.address}),u=await l()}else o?(await p.createSolana({accessToken:d,ethereumAddress:N(u)?.address}),u=await l()):t?(await r(),u=await l()):n(u)}catch(e){n(u),console.warn("Unable to create embedded wallet for guest account")}return s(h),a(!0),o("login","onComplete",{user:u,isNewUser:h,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw o("login","onError",e.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),e}}}}function Se(e){let{setWalletRecovery:t}=X(f);return s("setWalletRecovery",e),{setWalletRecovery:t}}function ve(e){let{signMessage:t}=X(f);return s("signMessage",e),{signMessage:t}}const Pe=()=>{let{ready:t,wallets:r}=O(),{user:o}=e(),{rpcConfig:i,chains:n,appId:a}=$();return{signAuthorization:j((async(e,s)=>{if(!o)throw Error("User must be authenticated before signing with a Privy wallet");if(!t)throw Error("Wallets are not ready");let c=s?.address??N(o)?.address??re,l=r.find((e=>oe(e.address)===oe(c)));if(!l)throw Error("Signing wallet not found.");let u=e.chainId??Number(l.chainId.split(":")[1]),h=n.find((e=>e.id===u));if(!h)throw Error("Error, chain not configured in PrivyProvider config");let d=ie({account:c,chain:h,transport:ne(_(h,i,a))}).extend(se()),p=await d.prepareAuthorization({...e,sponsor:e.sponsor||void 0}),w=await l.getEthereumProvider(),m=await w.request({method:"secp256k1_sign",params:[ce(p)]});return{...p,...ae(m)}}),[t,r,o,n])}};function Ne(e){let{signTypedData:t}=X(f);return s("signTypedData",e),{signTypedData:t}}const be=()=>{let{isModalOpen:e}=X(f);return{isOpen:e}};function Oe(e){let{getAccessToken:t}=X(f);return s("accessToken",e),{getAccessToken:t}}function Me(t){let{authenticated:r,user:o}=e(),{initLoginWithOAuth:i}=$(),n=T();return s("oAuthAuthorization",t),{reauthorize:e=>Fe(r,o,i,n,e.provider)}}let Fe=async(e,t,r,o,i)=>{if(!e)throw o("linkAccount","onError",Z.MUST_BE_AUTHENTICATED,{linkMethod:i}),new Y("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new Y(`OAuth account of type ${i} not linked to the account.`);await r(i)};const _e=e=>{let{customAuthStatus:t}=$();return s("customAuth",e),{status:t}};function Le(){let{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}=e();return{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}}const De=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=$();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},He=()=>{let{setUser:e,client:t}=X(ee),{user:r}=X(f);return{user:r,refreshUser:j((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},xe=e=>{let t=l(),{initLoginWithTelegram:r,loginWithTelegram:o,telegramAuthState:i,setTelegramAuthState:n}=$();return{login:j((async i=>{try{if(t.enabled&&"success"!==t.status)throw new d(t.error,null,Z.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:n,isNewUser:a,loginAccount:s,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:n,isNewUser:a,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:s})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||Z.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:i}},Ke=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=$();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{We as useConnectCoinbaseSmartWallet,Ae as useConnectOrCreateWallet,Ie as useCreateWallet,Ee as useCrossAppAccounts,_e as useCustomAuth,De as useDelegatedActions,Le as useFarcasterSigner,Re as useGuestAccounts,Ke as useHeadlessDelegatedActions,fe as useLinkAccount,me as useLinkWithPasskey,ye as useLinkWithSiwe,de as useLoginWithEmail,ue as useLoginWithFarcasterV2,he as useLoginWithOAuth,we as useLoginWithPasskey,ge as useLoginWithSms,xe as useLoginWithTelegram,be as useModalStatus,Me as useOAuthTokens,W as usePrivy,le as useRecoverEmbeddedWallet,Te as useSendTransaction,Ue as useSetWalletPassword,Se as useSetWalletRecovery,Pe as useSignAuthorization,ve as useSignMessage,ke as useSignTransaction,Ne as useSignTypedData,pe as useSignupWithPasskey,Oe as useToken,Ce as useUpdateAccount,He as useUser,O as useWallets};
1
+ import{u as e,g as i,a as n,b as s,c as l,d as h,C as d,e as m,s as k,P as f,f as C,h as W,i as T,G as U,W as S,j as P,k as R,l as N,m as O,n as M}from"./privy-provider-BCKJFtPt.mjs";export{q as Captcha,r as ConnectorManager,E as EthereumWalletConnector,L as LoginModal,A as PrivyClient,o as PrivyProvider,V as VERSION,t as WalletConnector,y as errorIndicatesMaxMfaRetries,z as errorIndicatesMfaTimeout,x as errorIndicatesMfaVerificationFailed,p as getAccessToken,B as useIdentityToken,I as useImportWallet,D as useLogout,v as useMfa,w as useMfaEnrollment,F as useRegisterMfaListener,H as useSolanaWallets}from"./privy-provider-BCKJFtPt.mjs";import{useCallback as _,useMemo as K,useEffect as j,useContext as G}from"react";import{u as Q,P as X,a as $,I as J}from"./internal-context-D95Bns6A.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-jAsui8zn.mjs";import{F as Y}from"./frame-BpnDpebm.mjs";import{zeroAddress as Z,getAddress as ee,createWalletClient as te,http as re,parseSignature as oe}from"viem";import{hashAuthorization as ie}from"viem/utils";export{DEFAULT_SUPPORTED_CHAINS as SUPPORTED_CHAINS,addPrivyRpcToChain,addRpcUrlOverrideToChain}from"@privy-io/js-sdk-core";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"react/jsx-runtime";import"mipd";import"react-device-detect";import"uuid";import"jose";import"eventemitter3";import"@coinbase/wallet-sdk";import"@marsidev/react-turnstile";import"styled-components";import"tinycolor2";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@headlessui/react";import"@walletconnect/ethereum-provider";import"zustand";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"qrcode";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@solana/web3.js";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const ne=()=>{let{user:t}=e(),{walletProxy:r}=Q();return{recover:_((async e=>{if(!r)throw Error("Wallet proxy is not ready");let o=await i();if(!t||!o)throw new X("User must be logged in before attempting to modify the recovery method.");let{entropyId:a,entropyIdVerifier:s}=n(t);try{await r.recover({entropyId:a,entropyIdVerifier:s,accessToken:o,...e})}catch{throw new X("Unable to recover wallets")}}),[r,t])}},ae=()=>{let{client:e,setAuthenticated:t,setUser:r}=Q();return K((()=>({init:async()=>{if(!e)throw new X("Must initialize Privy client first.");let t=new Y;return e.startAuthFlow(t),await t.init()},login:async({fid:o,message:i,signature:n})=>{if(!e)throw new X("Must initialize Privy client first.");if(!(e.authFlow instanceof Y))throw new X("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:i,signature:n,fid:o});let{user:a}=await e.authenticate();if(!a)throw new X("Failed to login with Farcaster V2");return r(a),t(!0),{user:a}}})),[e,r,t])},se=t=>{s("login",t);let r=l(),o=h(),{ready:i,user:n}=e(),{initLoginWithHeadlessOAuth:a,loginWithHeadlessOAuth:c,oAuthState:u,setOAuthState:p,isHeadlessOAuthLoading:w}=Q(),g=_((async e=>{try{if(r.enabled&&"success"!==r.status)throw new d(r.error,null,$.CAPTCHA_FAILURE);return await a(e.provider,r.token,e.disableSignup)}catch(e){throw p({status:"error",error:e}),e}}),[a,r]),A=_((async()=>{let e=m();try{if(n)return console.warn("Cannot login with OAuth when already logged in"),n;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw p({status:"error",error:e}),e}try{return await c(e)}catch(e){throw p({status:"error",error:e}),e}finally{k()}}),[c]);return j((()=>{let e=m();i&&o&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&A().catch((()=>{}))}),[i,o]),{initOAuth:g,loading:w,state:u}},ce=e=>{let t=l(),{emailOtpState:r,setEmailOtpState:o,initLoginWithEmail:i,loginWithCode:n}=Q();return{sendCode:_((async({email:r,disableSignup:n})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({email:r,captchaToken:e,disableSignup:n,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||$.UNKNOWN_AUTH_ERROR),r}}),[i]),loginWithCode:_((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:s}=await n(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"email",loginAccount:s})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||$.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},le=e=>{let t=l(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:i,setPasskeyAuthState:n}=Q();return{signupWithPasskey:_((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await r({captchaToken:i,withPrivyUi:!1});let{user:n,isNewUser:a,wasAlreadyAuthenticated:s,loginAccount:c}=await o();e?.onComplete?.({user:n,isNewUser:a,wasAlreadyAuthenticated:s,loginMethod:"passkey",loginAccount:c})}catch(t){throw n({status:"error",error:t}),e?.onError?.(t.privyErrorCode||$.UNKNOWN_AUTH_ERROR),t}}),[o,t.status]),state:i}},ue=e=>{let t=l(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:i,setPasskeyAuthState:n}=Q();return{loginWithPasskey:_((async i=>{try{let n;if(t.enabled&&"error"===t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),n=await t.waitForResult()),await r({captchaToken:n,withPrivyUi:!1});let{user:a,isNewUser:s,wasAlreadyAuthenticated:c,loginAccount:l}=await o(i);e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:l})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||$.UNKNOWN_AUTH_ERROR),i}}),[o,t.status]),state:i}},he=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:o,setPasskeyAuthState:i}=Q();return{linkWithPasskey:_((async()=>{try{await t();let o=await r();if(!o)throw Error("Error, user not found");let i=o.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:o,linkMethod:"passkey",linkedAccount:i})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||$.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:o}},de=e=>{let t=l(),{smsOtpState:r,setSmsOtpState:o,initLoginWithSms:i,loginWithCode:n}=Q();return{sendCode:_((async({phoneNumber:r,disableSignup:n})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({phoneNumber:r,captchaToken:e,disableSignup:n,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||$.UNKNOWN_AUTH_ERROR),r}}),[i]),loginWithCode:_((async({code:r})=>{try{if(t.enabled&&"success"!==t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:s}=await n(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"sms",loginAccount:s})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||$.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},pe=t=>{let{connectOrCreateWallet:r}=e();return s("connectOrCreateWallet",t),{connectOrCreateWallet:r}},we=e=>{let t=l(),{siweState:r,setSiweState:o,linkWithSiwe:i,generateSiweMessage:n}=Q();return{generateSiweMessage:_((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await n({address:t,chainId:r}).then((e=>e))}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||$.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[n]),linkWithSiwe:_((async({signature:r,message:n,chainId:a,walletClientType:s,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);let{user:o,linkedAccount:l}=await i({message:n,signature:r,chainId:a,walletClientType:s,connectorType:c});l&&e?.onSuccess?.({user:o,linkMethod:"siwe",linkedAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||$.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[i,t.status]),state:r}};function me(){let{signTransaction:e}=G(f);return{signTransaction:e}}function ge(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:i,linkApple:n,linkTwitter:a,linkDiscord:c,linkGithub:l,linkLinkedIn:u,linkTiktok:h,linkSpotify:d,linkInstagram:p,linkTelegram:w,linkFarcaster:m}=G(f);return s("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:i,linkApple:n,linkTwitter:a,linkDiscord:c,linkGithub:l,linkLinkedIn:u,linkTiktok:h,linkSpotify:d,linkInstagram:p,linkFarcaster:m,linkTelegram:w}}function Ae(e){let{updateEmail:t,updatePhone:r}=G(f);return s("update",e),{updateEmail:t,updatePhone:r}}function ye(e){let{createWallet:t}=G(f);return s("createWallet",e),{createWallet:t}}const ke=()=>{let{connectCoinbaseSmartWallet:e}=Q();return{connectCoinbaseSmartWallet:e}},fe=()=>{let{startCrossAppAuthFlow:t,unlinkCrossAppAccount:r,signMessageWithCrossAppWallet:o,signTypedDataWithCrossAppWallet:i,sendTransactionWithCrossAppWallet:n}=e();return{loginWithCrossAppAccount:({appId:e})=>t({appId:e,action:"login"}),linkCrossAppAccount:({appId:e})=>t({appId:e,action:"link"}),unlinkCrossAppAccount:r,signMessage:o,signTypedData:i,sendTransaction:n}};function Ce(e){let{sendTransaction:t}=G(f);return s("sendTransaction",e),{sendTransaction:t}}function Ie(e){let{setWalletPassword:t}=G(f);return s("setWalletPassword",e),{setWalletPassword:t}}function We(){let e=C(),{getAccessToken:t,createWallet:r}=W(),o=T(),{client:i,setUser:n,setAuthenticated:a,setIsNewUser:s,initializeWalletProxy:c,refreshSessionAndUser:l}=Q();return{createGuestAccount:async()=>{if(!e.id||!i)throw Error("SDK not yet ready");i.startAuthFlow(new U(e.id));try{let{user:u,isNewUser:h}=await i.authenticate();if(h=h||!1,!u)throw new X("Unable to authenticate guest account");let d=await t(),p=await c(S);if(d&&p)try{let t=P(u,e.embeddedWallets.ethereum.createOnLogin),o=R(u,e.embeddedWallets.solana.createOnLogin);if(t&&o){let e=await r();await p.createSolana({accessToken:d,ethereumAddress:e?.address}),u=await l()}else o?(await p.createSolana({accessToken:d,ethereumAddress:N(u)?.address}),u=await l()):t?(await r(),u=await l()):n(u)}catch(e){n(u),console.warn("Unable to create embedded wallet for guest account")}return s(h),a(!0),o("login","onComplete",{user:u,isNewUser:h,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw o("login","onError",e.privyErrorCode||$.UNKNOWN_AUTH_ERROR),e}}}}function Ee(e){let{setWalletRecovery:t}=G(f);return s("setWalletRecovery",e),{setWalletRecovery:t}}function Te(e){let{signMessage:t}=G(f);return s("signMessage",e),{signMessage:t}}const Ue=()=>{let{ready:t,wallets:r}=O(),{user:o}=e(),{rpcConfig:i,chains:n,appId:a}=Q();return{signAuthorization:_((async(e,s)=>{if(!o)throw Error("User must be authenticated before signing with a Privy wallet");if(!t)throw Error("Wallets are not ready");let c=s?.address??N(o)?.address??Z,l=r.find((e=>ee(e.address)===ee(c)));if(!l)throw Error("Signing wallet not found.");let u=e.chainId??Number(l.chainId.split(":")[1]),h=n.find((e=>e.id===u));if(!h)throw Error("Error, chain not configured in PrivyProvider config");let d=te({account:c,chain:h,transport:re(M(h,i,a))}),p=await d.prepareAuthorization({...e}),w=await l.getEthereumProvider(),m=await w.request({method:"secp256k1_sign",params:[ie(p)]});return{...p,...oe(m)}}),[t,r,o,n])}};function Se(e){let{signTypedData:t}=G(f);return s("signTypedData",e),{signTypedData:t}}const Pe=()=>{let{isModalOpen:e}=G(f);return{isOpen:e}};function Re(e){let{getAccessToken:t}=G(f);return s("accessToken",e),{getAccessToken:t}}function ve(t){let{authenticated:r,user:o}=e(),{initLoginWithOAuth:i}=Q(),n=T();return s("oAuthAuthorization",t),{reauthorize:e=>Ne(r,o,i,n,e.provider)}}let Ne=async(e,t,r,o,i)=>{if(!e)throw o("linkAccount","onError",$.MUST_BE_AUTHENTICATED,{linkMethod:i}),new X("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new X(`OAuth account of type ${i} not linked to the account.`);await r(i)};const be=e=>{let{customAuthStatus:t}=Q();return s("customAuth",e),{status:t}};function Oe(){let{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}=e();return{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}}const Me=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=Q();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Fe=()=>{let{setUser:e,client:t}=G(J),{user:r}=G(f);return{user:r,refreshUser:_((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},_e=e=>{let t=l(),{initLoginWithTelegram:r,loginWithTelegram:o,telegramAuthState:i,setTelegramAuthState:n}=Q();return{login:_((async i=>{try{if(t.enabled&&"success"!==t.status)throw new d(t.error,null,$.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:n,isNewUser:a,loginAccount:s,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:n,isNewUser:a,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:s})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||$.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:i}},Le=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=Q();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{ke as useConnectCoinbaseSmartWallet,pe as useConnectOrCreateWallet,ye as useCreateWallet,fe as useCrossAppAccounts,be as useCustomAuth,Me as useDelegatedActions,Oe as useFarcasterSigner,We as useGuestAccounts,Le as useHeadlessDelegatedActions,ge as useLinkAccount,he as useLinkWithPasskey,we as useLinkWithSiwe,ce as useLoginWithEmail,ae as useLoginWithFarcasterV2,se as useLoginWithOAuth,ue as useLoginWithPasskey,de as useLoginWithSms,_e as useLoginWithTelegram,Pe as useModalStatus,ve as useOAuthTokens,W as usePrivy,ne as useRecoverEmbeddedWallet,Ce as useSendTransaction,Ie as useSetWalletPassword,Ee as useSetWalletRecovery,Ue as useSignAuthorization,Te as useSignMessage,me as useSignTransaction,Se as useSignTypedData,le as useSignupWithPasskey,Re as useToken,Ae as useUpdateAccount,Fe as useUser,O as useWallets};
@@ -1 +1 @@
1
- import{FetchError as a}from"ofetch";import{createContext as e,useContext as s}from"react";var t;class i extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(a,e,s){super(a),e instanceof Error&&(this.cause=e),this.privyErrorCode=s}}class n extends i{constructor(a,e,s,t,i,n){super(s,t,i),this.type=a,this.status=e,this.data=n}}class r extends i{constructor(a,e,s){super(a,e,s),this.type="client_error"}}class _ extends r{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class o extends i{constructor(a,e,s){super(a,e,s),this.type="connector_error"}}const l=e=>{if(e instanceof i)return e;if(!(e instanceof a))return u(e);if(!e.response)return new n("api_error",null,e.message,e);let{type:s,message:t,error:r,code:_}=e.data;return new n(s||"ApiError",e.response.status,t||r,e,_,e.data)},u=a=>a instanceof i?a:a instanceof Error?new r(a.message,a):new r(`Internal error: ${a}`);var d=((t={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",t.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",t.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",t.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",t.INVALID_DATA="invalid_data",t.INVALID_CAPTCHA="invalid_captcha",t.LINKED_TO_ANOTHER_USER="linked_to_another_user",t.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",t.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",t.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",t.USER_EXITED_UPDATE_FLOW="exited_update_flow",t.ALLOWLIST_REJECTED="allowlist_rejected",t.OAUTH_USER_DENIED="oauth_user_denied",t.OAUTH_UNEXPECTED="oauth_unexpected",t.UNKNOWN_AUTH_ERROR="unknown_auth_error",t.USER_EXITED_AUTH_FLOW="exited_auth_flow",t.USER_EXITED_LINK_FLOW="exited_link_flow",t.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",t.MUST_BE_AUTHENTICATED="must_be_authenticated",t.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",t.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",t.CLIENT_REQUEST_TIMEOUT="client_request_timeout",t.INVALID_CREDENTIALS="invalid_credentials",t.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",t.UNKNOWN_MFA_ERROR="unknown_mfa_error",t.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",t.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",t.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",t.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",t.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",t.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",t.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",t.TRANSACTION_FAILURE="transaction_failure",t.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",t.NOT_SUPPORTED="not_supported",t.CAPTCHA_TIMEOUT="captcha_timeout",t.INVALID_MESSAGE="invalid_message",t.UNABLE_TO_SIGN="unable_to_sign",t.CAPTCHA_FAILURE="captcha_failure",t.CAPTCHA_DISABLED="captcha_disabled",t.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",t.TOO_MANY_REQUESTS="too_many_requests",t.USER_LIMIT_REACHED="max_accounts_reached",t.DISALLOWED_LOGIN_METHOD="disallowed_login_method",t.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",t.PASSKEY_NOT_ALLOWED="passkey_not_allowed",t.USER_DOES_NOT_EXIST="user_does_not_exist",t.INSUFFICIENT_BALANCE="insufficient_balance",t.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",t.BUFFER_NOT_DEFINED="buffer_not_defined",t);class p extends r{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class c extends r{constructor(a="Embedded wallet error",e){super(a,e,"unknown_embedded_wallet_error")}}class E extends r{constructor(a="User must be authenticated"){super(a,void 0,"must_be_authenticated")}}class A extends r{constructor(a){super("This application is in development mode and must be upgraded to production to log in new users.",a,"max_accounts_reached")}}const h="/api/v1/sessions",v="/api/v1/sessions/logout",S="/api/v1/siwe/init",T="/api/v1/siwe/authenticate",m="/api/v1/siwe/link",w="/api/v1/siwe/link_smart_wallet",I="/api/v1/siwe/unlink",D="/api/v1/siwe/transfer",N="/api/v1/siws/init",O="/api/v1/siws/authenticate",L="/api/v1/siws/link",g="/api/v1/siws/unlink",R="/api/v1/farcaster/init",W="/api/v1/farcaster/authenticate",U="/api/v1/farcaster/link",f="/api/v1/farcaster/status",k="/api/v1/farcaster/unlink",y="/api/v1/farcaster/transfer",C="api/v2/farcaster/init",P="api/v2/farcaster/authenticate",M="/api/v1/passwordless/init",F="/api/v1/passwordless/authenticate",b="/api/v1/passwordless/link",x="/api/v1/passwordless/unlink",H="/api/v1/passwordless/update",B="/api/v1/passwordless/transfer",V="/api/v1/passwordless_sms/init",K="/api/v1/passwordless_sms/link",Y="/api/v1/passwordless_sms/unlink",G="/api/v1/passwordless_sms/authenticate",X="/api/v1/passwordless_sms/update",$="/api/v1/passwordless_sms/transfer",q="/api/v1/oauth/init",j="/api/v1/oauth/authenticate",Q="/api/v1/oauth/link",z="/api/v1/oauth/unlink",J="/api/v1/oauth/transfer",Z="/api/v1/recovery/oauth/init",aa="/api/v1/recovery/oauth/init_icloud",ea="/api/v1/recovery/oauth/authenticate",sa="/api/v1/passkeys/link/init",ta="/api/v1/passkeys/authenticate/init",ia="/api/v1/passkeys/register/init",na="/api/v1/passkeys/link",ra="/api/v1/passkeys/authenticate",_a="/api/v1/passkeys/register",oa="/api/v1/telegram/authenticate",la="/api/v1/telegram/link",ua="/api/v1/telegram/unlink",da="/api/v1/telegram/transfer",pa="/api/v1/mfa/passwordless_sms/init",ca="/api/v1/mfa/passkeys/init",Ea="/api/v1/users/me/accept_terms",Aa="/api/v1/analytics_events",ha="/api/v1/custom_jwt_account/authenticate",va="/api/v1/guest/authenticate",Sa="/api/v1/plugins/moonpay_on_ramp/sign",Ta="/api/v1/funding/coinbase_on_ramp/init",ma="/api/v1/funding/coinbase_on_ramp/status",wa="/api/v1/wallets/revoke",Ia="/api/v1/users/me",Da="/api/v1/scan/transaction",Na=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},Oa=a=>()=>{throw Error(a.trim())},La=/*#__PURE__*/e({setAuthenticated:Na,setUser:Na,setIsNewUser:Na,isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,appId:"notAdded",customAuthStatus:{status:"not-enabled"},hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:Na,initializeWalletProxy:Na,getAuthMeta:Na,getAuthFlow:Na,closePrivyModal:Na,openPrivyModal:Na,connectWallet:Na,initLoginWithWallet:Na,loginWithWallet:Na,initLoginWithFarcaster:Na,loginWithFarcaster:Na,loginWithCode:Na,initLoginWithEmail:Na,initLoginWithSms:Na,initUpdateEmail:Na,initUpdatePhone:Na,resendEmailCode:Na,resendSmsCode:Na,initLoginWithHeadlessOAuth:Na,loginWithHeadlessOAuth:Na,crossAppAuthFlow:Na,initLoginWithOAuth:Na,loginWithOAuth:Na,passkeyAuthState:{status:"initial"},setPasskeyAuthState:Na,initSignupWithPasskey:Na,signupWithPasskey:Na,initLoginWithPasskey:Na,loginWithPasskey:Na,initLinkWithPasskey:Na,linkWithPasskey:Na,refreshSessionAndUser:Na,walletProxy:null,createAnalyticsEvent:Na,acceptTerms:Na,getUsdTokenPrice:Na,getUsdPriceForSol:Na,getSplTokenMetadata:Na,recoverPrimaryWallet:Na,updateWallets:Na,fundWallet:Na,openModal:Na,setReadyToTrue:Na,requestFarcasterSignerStatus:Na,initLoginWithTelegram:Na,loginWithTelegram:Na,generateSiweMessage:Na,generateSiweMessageForSmartWallet:Na,linkWithSiwe:Na,linkSmartWallet:Na,delegateWallet:Na,revokeDelegatedWallets:Na,createEmbeddedSolanaWallet:Na,exportSolanaWallet:Na,connectCoinbaseSmartWallet:Na,initiateAccountTransfer:Na,emailOtpState:{status:"initial"},setEmailOtpState:Na,smsOtpState:{status:"initial"},setSmsOtpState:Na,siweState:{status:"initial"},setSiweState:Na,oAuthState:{status:"initial"},setOAuthState:Na,telegramAuthState:{status:"initial"},setTelegramAuthState:Na,isHeadlessOAuthLoading:!1,isHeadlessSigning:Na}),ga=()=>s(La);export{ma as $,i as A,oa as B,la as C,Oa as D,_ as E,h as F,v as G,Aa as H,La as I,ha as J,va as K,u as L,n as M,pa as N,ca as O,r as P,Ea as Q,x as R,Y as S,I as T,g as U,z as V,k as W,ua as X,wa as Y,Sa as Z,Ta as _,d as a,S as a0,T as a1,m as a2,w as a3,N as a4,O as a5,J as a6,da as a7,y as a8,D as a9,$ as aa,B as ab,L as ac,Ia as ad,Da as ae,ea as af,aa as ag,Z as ah,c as ai,A as aj,E as ak,p as al,C as am,P as an,b,M as c,H as d,o as e,l as f,W as g,U as h,R as i,f as j,Q as k,q as l,_a as m,Na as n,j as o,F as p,ra as q,na as r,ia as s,ta as t,ga as u,sa as v,G as w,K as x,V as y,X as z};
1
+ import{FetchError as a}from"ofetch";import{createContext as e,useContext as s}from"react";var t;class i extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(a,e,s){super(a),e instanceof Error&&(this.cause=e),this.privyErrorCode=s}}class n extends i{constructor(a,e,s,t,i,n){super(s,t,i),this.type=a,this.status=e,this.data=n}}class r extends i{constructor(a,e,s){super(a,e,s),this.type="client_error"}}class _ extends r{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class o extends i{constructor(a,e,s){super(a,e,s),this.type="connector_error"}}const l=e=>{if(e instanceof i)return e;if(!(e instanceof a))return u(e);if(!e.response)return new n("api_error",null,e.message,e);let{type:s,message:t,error:r,code:_}=e.data;return new n(s||"ApiError",e.response.status,t||r,e,_,e.data)},u=a=>a instanceof i?a:a instanceof Error?new r(a.message,a):new r(`Internal error: ${a}`);var d=((t={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",t.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",t.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",t.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",t.INVALID_DATA="invalid_data",t.INVALID_CAPTCHA="invalid_captcha",t.LINKED_TO_ANOTHER_USER="linked_to_another_user",t.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",t.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",t.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",t.USER_EXITED_UPDATE_FLOW="exited_update_flow",t.ALLOWLIST_REJECTED="allowlist_rejected",t.OAUTH_USER_DENIED="oauth_user_denied",t.OAUTH_UNEXPECTED="oauth_unexpected",t.UNKNOWN_AUTH_ERROR="unknown_auth_error",t.USER_EXITED_AUTH_FLOW="exited_auth_flow",t.USER_EXITED_LINK_FLOW="exited_link_flow",t.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",t.MUST_BE_AUTHENTICATED="must_be_authenticated",t.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",t.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",t.CLIENT_REQUEST_TIMEOUT="client_request_timeout",t.INVALID_CREDENTIALS="invalid_credentials",t.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",t.UNKNOWN_MFA_ERROR="unknown_mfa_error",t.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",t.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",t.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",t.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",t.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",t.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",t.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",t.TRANSACTION_FAILURE="transaction_failure",t.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",t.NOT_SUPPORTED="not_supported",t.CAPTCHA_TIMEOUT="captcha_timeout",t.INVALID_MESSAGE="invalid_message",t.UNABLE_TO_SIGN="unable_to_sign",t.CAPTCHA_FAILURE="captcha_failure",t.CAPTCHA_DISABLED="captcha_disabled",t.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",t.TOO_MANY_REQUESTS="too_many_requests",t.USER_LIMIT_REACHED="max_accounts_reached",t.DISALLOWED_LOGIN_METHOD="disallowed_login_method",t.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",t.PASSKEY_NOT_ALLOWED="passkey_not_allowed",t.USER_DOES_NOT_EXIST="user_does_not_exist",t.INSUFFICIENT_BALANCE="insufficient_balance",t.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",t.BUFFER_NOT_DEFINED="buffer_not_defined",t);class p extends r{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class c extends r{constructor(a="Embedded wallet error",e){super(a,e,"unknown_embedded_wallet_error")}}class E extends r{constructor(a="User must be authenticated"){super(a,void 0,"must_be_authenticated")}}class A extends r{constructor(a){super("This application is in development mode and must be upgraded to production to log in new users.",a,"max_accounts_reached")}}const h="/api/v1/sessions",v="/api/v1/sessions/logout",S="/api/v1/siwe/init",T="/api/v1/siwe/authenticate",m="/api/v1/siwe/link",w="/api/v1/siwe/link_smart_wallet",I="/api/v1/siwe/unlink",D="/api/v1/siwe/transfer",N="/api/v1/siws/init",O="/api/v1/siws/authenticate",L="/api/v1/siws/link",g="/api/v1/siws/unlink",R="/api/v1/farcaster/init",W="/api/v1/farcaster/authenticate",U="/api/v1/farcaster/link",f="/api/v1/farcaster/status",k="/api/v1/farcaster/unlink",y="/api/v1/farcaster/transfer",C="api/v2/farcaster/init",P="api/v2/farcaster/authenticate",M="/api/v1/passwordless/init",F="/api/v1/passwordless/authenticate",b="/api/v1/passwordless/link",x="/api/v1/passwordless/unlink",H="/api/v1/passwordless/update",B="/api/v1/passwordless/transfer",V="/api/v1/passwordless_sms/init",K="/api/v1/passwordless_sms/link",Y="/api/v1/passwordless_sms/unlink",G="/api/v1/passwordless_sms/authenticate",X="/api/v1/passwordless_sms/update",$="/api/v1/passwordless_sms/transfer",q="/api/v1/oauth/init",j="/api/v1/oauth/authenticate",Q="/api/v1/oauth/link",z="/api/v1/oauth/unlink",J="/api/v1/oauth/transfer",Z="/api/v1/recovery/oauth/init",aa="/api/v1/recovery/oauth/init_icloud",ea="/api/v1/recovery/oauth/authenticate",sa="/api/v1/passkeys/link/init",ta="/api/v1/passkeys/authenticate/init",ia="/api/v1/passkeys/register/init",na="/api/v1/passkeys/link",ra="/api/v1/passkeys/authenticate",_a="/api/v1/passkeys/register",oa="/api/v1/telegram/authenticate",la="/api/v1/telegram/link",ua="/api/v1/telegram/unlink",da="/api/v1/telegram/transfer",pa="/api/v1/mfa/passwordless_sms/init",ca="/api/v1/mfa/passkeys/init",Ea="/api/v1/users/me/accept_terms",Aa="/api/v1/analytics_events",ha="/api/v1/custom_jwt_account/authenticate",va="/api/v1/guest/authenticate",Sa="/api/v1/plugins/moonpay_on_ramp/sign",Ta="/api/v1/funding/coinbase_on_ramp/init",ma="/api/v1/funding/coinbase_on_ramp/status",wa="/api/v1/wallets/revoke",Ia="/api/v1/users/me",Da="/api/v1/scan/transaction",Na=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},Oa=a=>()=>{throw Error(a.trim())},La=/*#__PURE__*/e({setAuthenticated:Na,setUser:Na,setIsNewUser:Na,isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",customAuthStatus:{status:"not-enabled"},hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:Na,initializeWalletProxy:Na,getAuthMeta:Na,getAuthFlow:Na,closePrivyModal:Na,openPrivyModal:Na,connectWallet:Na,initLoginWithWallet:Na,loginWithWallet:Na,initLoginWithFarcaster:Na,loginWithFarcaster:Na,loginWithCode:Na,initLoginWithEmail:Na,initLoginWithSms:Na,initUpdateEmail:Na,initUpdatePhone:Na,resendEmailCode:Na,resendSmsCode:Na,initLoginWithHeadlessOAuth:Na,loginWithHeadlessOAuth:Na,crossAppAuthFlow:Na,initLoginWithOAuth:Na,loginWithOAuth:Na,passkeyAuthState:{status:"initial"},setPasskeyAuthState:Na,initSignupWithPasskey:Na,signupWithPasskey:Na,initLoginWithPasskey:Na,loginWithPasskey:Na,initLinkWithPasskey:Na,linkWithPasskey:Na,refreshSessionAndUser:Na,walletProxy:null,createAnalyticsEvent:Na,acceptTerms:Na,getUsdTokenPrice:Na,getUsdPriceForSol:Na,getSplTokenMetadata:Na,recoverPrimaryWallet:Na,updateWallets:Na,fundWallet:Na,openModal:Na,setReadyToTrue:Na,requestFarcasterSignerStatus:Na,initLoginWithTelegram:Na,loginWithTelegram:Na,generateSiweMessage:Na,generateSiweMessageForSmartWallet:Na,linkWithSiwe:Na,linkSmartWallet:Na,delegateWallet:Na,revokeDelegatedWallets:Na,createEmbeddedSolanaWallet:Na,exportSolanaWallet:Na,connectCoinbaseSmartWallet:Na,initiateAccountTransfer:Na,emailOtpState:{status:"initial"},setEmailOtpState:Na,smsOtpState:{status:"initial"},setSmsOtpState:Na,siweState:{status:"initial"},setSiweState:Na,oAuthState:{status:"initial"},setOAuthState:Na,telegramAuthState:{status:"initial"},setTelegramAuthState:Na,isHeadlessOAuthLoading:!1,isHeadlessSigning:Na}),ga=()=>s(La);export{ma as $,i as A,oa as B,la as C,Oa as D,_ as E,h as F,v as G,Aa as H,La as I,ha as J,va as K,u as L,n as M,pa as N,ca as O,r as P,Ea as Q,x as R,Y as S,I as T,g as U,z as V,k as W,ua as X,wa as Y,Sa as Z,Ta as _,d as a,S as a0,T as a1,m as a2,w as a3,N as a4,O as a5,J as a6,da as a7,y as a8,D as a9,$ as aa,B as ab,L as ac,Ia as ad,Da as ae,ea as af,aa as ag,Z as ah,c as ai,A as aj,E as ak,p as al,C as am,P as an,b,M as c,H as d,o as e,l as f,W as g,U as h,R as i,f as j,Q as k,q as l,_a as m,Na as n,j as o,F as p,ra as q,na as r,ia as s,ta as t,ga as u,sa as v,G as w,K as x,V as y,X as z};