@privy-io/react-auth 2.14.2 → 2.15.0

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 (57) hide show
  1. package/dist/cjs/abstract-smart-wallets.js +1 -1
  2. package/dist/cjs/extended-chains.js +1 -0
  3. package/dist/cjs/farcaster.js +1 -1
  4. package/dist/cjs/frame-B38H7ILa.js +1 -0
  5. package/dist/cjs/index.js +1 -1
  6. package/dist/cjs/internal-context-CrTqNb_c.js +1 -0
  7. package/dist/cjs/paths-CdRs2pll.js +1 -0
  8. package/dist/cjs/privy-provider-BH0F7-54.js +28 -0
  9. package/dist/cjs/smart-wallets-DvmTShkt.js +1 -0
  10. package/dist/cjs/smart-wallets.js +1 -1
  11. package/dist/cjs/solana.js +1 -1
  12. package/dist/cjs/ui.js +2 -2
  13. package/dist/cjs/use-sign-with-user-signer-h5JGn1CY.js +1 -0
  14. package/dist/cjs/useActiveWallet-XehugIB6.js +1 -0
  15. package/dist/cjs/{useFundWallet-IzxVl7fC.js → useFundWallet-hXyQXO7U.js} +1 -1
  16. package/dist/dts/extended-chains.d.mts +53 -0
  17. package/dist/dts/extended-chains.d.ts +53 -0
  18. package/dist/dts/farcaster.d.mts +1 -1
  19. package/dist/dts/farcaster.d.ts +1 -1
  20. package/dist/dts/index.d.mts +84 -9
  21. package/dist/dts/index.d.ts +84 -9
  22. package/dist/dts/smart-wallets.d.mts +1 -1
  23. package/dist/dts/smart-wallets.d.ts +1 -1
  24. package/dist/dts/solana.d.mts +4 -4
  25. package/dist/dts/solana.d.ts +4 -4
  26. package/dist/dts/{types-CCLHKw4p.d.mts → types-BVjRQyBr.d.mts} +2 -2
  27. package/dist/dts/{types-CCLHKw4p.d.ts → types-BVjRQyBr.d.ts} +2 -2
  28. package/dist/dts/ui.d.mts +1 -1
  29. package/dist/dts/ui.d.ts +1 -1
  30. package/dist/dts/{useSolanaWallets-CbaQnTe_.d.mts → useSolanaWallets-B9ju3nTn.d.mts} +1 -1
  31. package/dist/dts/{useSolanaWallets-CbaQnTe_.d.ts → useSolanaWallets-B9ju3nTn.d.ts} +1 -1
  32. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  33. package/dist/esm/extended-chains.mjs +1 -0
  34. package/dist/esm/farcaster.mjs +1 -1
  35. package/dist/esm/frame-UsDF_L76.mjs +1 -0
  36. package/dist/esm/index.mjs +1 -1
  37. package/dist/esm/internal-context-Bxhby7Hv.mjs +1 -0
  38. package/dist/esm/paths-j39vuJt8.mjs +1 -0
  39. package/dist/esm/privy-provider-DyqReHyu.mjs +28 -0
  40. package/dist/esm/smart-wallets-BuJFWcoC.mjs +1 -0
  41. package/dist/esm/smart-wallets.mjs +1 -1
  42. package/dist/esm/solana.mjs +1 -1
  43. package/dist/esm/ui.mjs +2 -2
  44. package/dist/esm/use-sign-with-user-signer-CEyk1z8w.mjs +1 -0
  45. package/dist/esm/useActiveWallet-CKb44UC5.mjs +1 -0
  46. package/dist/esm/{useFundWallet-3u6nKvq9.mjs → useFundWallet-BjWNYKHD.mjs} +1 -1
  47. package/package.json +16 -3
  48. package/dist/cjs/frame-Czznns2Z.js +0 -1
  49. package/dist/cjs/internal-context-VGU3duZo.js +0 -1
  50. package/dist/cjs/privy-provider-CtJSaVGS.js +0 -28
  51. package/dist/cjs/smart-wallets-DamcfGy2.js +0 -1
  52. package/dist/cjs/useActiveWallet-CLlUzbbD.js +0 -1
  53. package/dist/esm/frame-S_4wR3Zf.mjs +0 -1
  54. package/dist/esm/internal-context-pX7RZwl3.mjs +0 -1
  55. package/dist/esm/privy-provider-B_tc-pgO.mjs +0 -28
  56. package/dist/esm/smart-wallets-CLORSRVb.mjs +0 -1
  57. package/dist/esm/useActiveWallet-mXvtXdOw.mjs +0 -1
@@ -1 +1 @@
1
- import{u as e,g as t,a as r,b as o,c as i,d as s,C as n,e as l,s as d,P as h,f as w,h as p,i as m,G as y,W as k,j as f,k as C,l as W,m as v,n as P,o as _,p as x,q as j,r as q,t as G,v as $,w as Y,x as Z,y as ee}from"./privy-provider-B_tc-pgO.mjs";export{B as Captcha,D as ConnectorManager,F as EthereumWalletConnector,X as LoginModal,N as PrivyClient,z as PrivyProvider,V as VERSION,E as WalletConnector,L as errorIndicatesMaxMfaRetries,M as errorIndicatesMfaTimeout,K as errorIndicatesMfaVerificationFailed,A as getAccessToken,S as useCreateWallet,O as useIdentityToken,U as useImportWallet,Q as useLogout,I as useMfa,J as useMfaEnrollment,H as usePrivy,R as useRegisterMfaListener,T as useSolanaWallets}from"./privy-provider-B_tc-pgO.mjs";import{useCallback as te,useMemo as re,useEffect as oe,useContext as ie,useState as ae,useRef as se}from"react";import{u as ne,P as le,a as ce,I as ue}from"./internal-context-pX7RZwl3.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-mXvtXdOw.mjs";import{F as de}from"./frame-S_4wR3Zf.mjs";import{zeroAddress as he,getAddress as we,createWalletClient as pe,http as ge,parseSignature as me}from"viem";import{hashAuthorization as ye}from"viem/utils";import{getWallet as Ae,updateWallet as ke}from"@privy-io/js-sdk-core";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"@privy-io/ethereum";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/solid/ArrowsRightLeftIcon";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/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 fe=()=>{let{user:o}=e(),{walletProxy:i}=ne();return{recover:te((async e=>{if(!i)throw Error("Wallet proxy is not ready");let a=await t();if(!o||!a)throw new le("User must be logged in before attempting to modify the recovery method.");let{entropyId:s,entropyIdVerifier:n}=r(o);try{await i.recover({entropyId:s,entropyIdVerifier:n,accessToken:a,...e})}catch{throw new le("Unable to recover wallets")}}),[i,o])}},Ce=()=>{let{client:e,setAuthenticated:t,setUser:r}=ne();return re((()=>({init:async()=>{if(!e)throw new le("Must initialize Privy client first.");let t=new de;return e.startAuthFlow(t),await t.init()},login:async({fid:o,message:i,signature:a})=>{if(!e)throw new le("Must initialize Privy client first.");if(!(e.authFlow instanceof de))throw new le("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:i,signature:a,fid:o});let{user:s}=await e.authenticate();if(!s)throw new le("Failed to login with Farcaster V2");return r(s),t(!0),{user:s}}})),[e,r,t])},Ie=t=>{o("login",t);let r=i(),a=s(),{ready:c,user:u}=e(),{initLoginWithHeadlessOAuth:h,loginWithHeadlessOAuth:w,oAuthState:p,setOAuthState:g,isHeadlessOAuthLoading:m}=ne(),y=te((async e=>{try{if(r.enabled&&"success"!==r.status)throw new n(r.error,null,ce.CAPTCHA_FAILURE);return await h(e.provider,r.token,e.disableSignup)}catch(e){throw g({status:"error",error:e}),e}}),[h,r]),A=te((async()=>{let e=l();try{if(u)return console.warn("Cannot login with OAuth when already logged in"),u;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw g({status:"error",error:e}),e}try{return await w(e)}catch(e){throw g({status:"error",error:e}),e}finally{d()}}),[w]);return oe((()=>{let e=l();c&&a&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&A().catch((()=>{}))}),[c,a]),{initOAuth:y,loading:m,state:p}},Ee=e=>{let t=i(),{emailOtpState:r,setEmailOtpState:o,initLoginWithEmail:a,loginWithCode:s}=ne();return{sendCode:te((async({email:r,disableSignup:i})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({email:r,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:te((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await s(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"email",loginAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),r}}),[s,t.status]),state:r}},We=e=>{let t=i(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:s}=ne();return{signupWithPasskey:te((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await r({captchaToken:i,withPrivyUi:!1});let{user:a,isNewUser:s,wasAlreadyAuthenticated:l,loginAccount:c}=await o();e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),t}}),[o,t.status]),state:a}},Te=e=>{let t=i(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:s}=ne();return{loginWithPasskey:te((async i=>{try{let a;if(t.enabled&&"error"===t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await r({captchaToken:a,withPrivyUi:!1});let{user:s,isNewUser:l,wasAlreadyAuthenticated:c,loginAccount:u}=await o(i);e?.onComplete?.({user:s,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(i){throw s({status:"error",error:i}),e?.onError?.(i.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),i}}),[o,t.status]),state:a}},Ue=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:o,setPasskeyAuthState:i}=ne();return{linkWithPasskey:te((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||ce.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:o}},Se=e=>{let t=i(),{smsOtpState:r,setSmsOtpState:o,initLoginWithSms:a,loginWithCode:s}=ne();return{sendCode:te((async({phoneNumber:r,disableSignup:i})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({phoneNumber:r,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:te((async({code:r})=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await s(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"sms",loginAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),r}}),[s,t.status]),state:r}},ve=t=>{let{connectOrCreateWallet:r}=e();return o("connectOrCreateWallet",t),{connectOrCreateWallet:r}},Re=e=>{let t=i(),{siweState:r,setSiweState:o,linkWithSiwe:a,generateSiweMessage:s}=ne();return{generateSiweMessage:te((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await s({address:t,chainId:r}).then((e=>e))}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||ce.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[s]),linkWithSiwe:te((async({signature:r,message:i,chainId:s,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);let{user:o,linkedAccount:u}=await a({message:i,signature:r,chainId:s,walletClientType:l,connectorType:c});u&&e?.onSuccess?.({user:o,linkMethod:"siwe",linkedAccount:u})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[a,t.status]),state:r}},Pe=e=>{let t=i(),{siweState:r,setSiweState:o,client:a,generateSiweMessage:s,loginWithSiwe:l}=ne();return{generateSiweNonce:te((async r=>{try{let e;if(t.enabled&&"error"===t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),o({status:"generating-message"});let i=await a.generateSiweNonce({address:r?.address,captchaToken:e});return o({status:"awaiting-signature"}),i}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),r}}),[a,t]),generateSiweMessage:te((async({address:t,chainId:r})=>{try{return await s({address:t,chainId:r})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),t}}),[s]),loginWithSiwe:te((async({message:r,signature:i,disableSignup:a})=>{try{let o;if(t.enabled&&"error"===t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),o=await t.waitForResult());let s=await l({message:r,signature:i,captchaToken:o,disableSignup:a});return e?.onComplete?.({user:s,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),s}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),r}}),[l,t.status]),state:r}};function Ne(){let{signTransaction:e}=ie(h);return{signTransaction:e}}function be(e){let{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:s,linkTwitter:n,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:w,linkInstagram:p,linkTelegram:g,linkFarcaster:m,linkPasskey:y}=ie(h);return o("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:s,linkTwitter:n,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:w,linkInstagram:p,linkFarcaster:m,linkTelegram:g,linkPasskey:y}}function Oe(e){let{updateEmail:t,updatePhone:r}=ie(h);return o("update",e),{updateEmail:t,updatePhone:r}}const _e=()=>{let{connectCoinbaseSmartWallet:e}=ne();return{connectCoinbaseSmartWallet:e}},Me=()=>{let{startCrossAppAuthFlow:t,unlinkCrossAppAccount:r,signMessageWithCrossAppWallet:o,signTypedDataWithCrossAppWallet:i,sendTransactionWithCrossAppWallet:a}=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:a}};function Fe(e){let{sendTransaction:t}=ie(h);return o("sendTransaction",e),{sendTransaction:t}}function Le(e){let{setWalletPassword:t}=ie(h);return o("setWalletPassword",e),{setWalletPassword:t}}function He(){let t=w(),{getAccessToken:r}=e(),o=p(),{client:i,setUser:a,setAuthenticated:s,setIsNewUser:n,initializeWalletProxy:l}=ne(),{create:c}=m();return{createGuestAccount:async()=>{if(!t.id||!i)throw Error("SDK not yet ready");i.startAuthFlow(new y(t.id));try{let e=await i.authenticate(),u=e.user,d=e.isNewUser??!1;if(!u)throw new le("Unable to authenticate guest account");let h=await r(),w=await l(k);if(h&&w)try{let e=f(u,t.embeddedWallets.ethereum.createOnLogin),r=C(u,t.embeddedWallets.solana.createOnLogin);e&&r?(u=(await c({chainType:"ethereum",latestUser:u})).user,u=(await c({chainType:"solana",latestUser:u})).user):r?u=(await c({chainType:"solana",latestUser:u})).user:e?u=(await c({chainType:"ethereum",latestUser:u})).user:a(u)}catch(e){a(u),console.warn("Unable to create embedded wallet for guest account")}return n(d),s(!0),o("login","onComplete",{user:u,isNewUser:d,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw o("login","onError",e.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),e}}}}function De(e){let{setWalletRecovery:t}=ie(h);return o("setWalletRecovery",e),{setWalletRecovery:t}}function xe(e){let{signMessage:t}=ie(h);return o("signMessage",e),{signMessage:t}}const Ke=()=>{let{ready:t,wallets:r}=W(),{user:o}=e(),{rpcConfig:i,chains:a,appId:s}=ne();return{signAuthorization:te((async(e,n)=>{let l;if(!o)throw Error("User must be authenticated before signing with a Privy wallet");if(!t)throw Error("Wallets are not ready");let c=n?.address??v(o)?.address??he,u=r.find((e=>we(e.address)===we(c)));if(!u)throw Error("Signing wallet not found.");let d=e.chainId??Number(u.chainId.split(":")[1]);if(0===d)l={chainId:0,address:e.contractAddress,nonce:e.nonce??0};else{let t=a.find((e=>e.id===d));if(!t)throw Error("Error, chain not configured in PrivyProvider config");let r=pe({account:c,chain:t,transport:ge(P(t,i,s))});l=await r.prepareAuthorization({...e})}let h=await u.getEthereumProvider(),w=await h.request({method:"secp256k1_sign",params:[ye(l)]});return{...l,...me(w)}}),[t,r,o,a])}};function ze(e){let{signTypedData:t}=ie(h);return o("signTypedData",e),{signTypedData:t}}const je=()=>{let{isModalOpen:e}=ie(h);return{isOpen:e}};function qe(e){let{getAccessToken:t}=ie(h);return o("accessToken",e),{getAccessToken:t}}function Ve(t){let{authenticated:r,user:i}=e(),{initLoginWithOAuth:a}=ne(),s=p();return o("oAuthAuthorization",t),{reauthorize:e=>Ge(r,i,a,s,e.provider)}}let Ge=async(e,t,r,o,i)=>{if(!e)throw o("linkAccount","onError",ce.MUST_BE_AUTHENTICATED,{linkMethod:i}),new le("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new le(`OAuth account of type ${i} not linked to the account.`);await r(i)};function Be(e){let{client:t}=ne(),[r,o]=ae({status:"initial"});return{linkWithCustomJwt:te((async r=>{try{o({status:"initial"}),t.startAuthFlow(new _(r)),o({status:"loading"});let{user:i}=await t.link();if(!i)throw Error("Error, user not found");let a=i.linkedAccounts.filter((e=>"custom_auth"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())).at(0);return o({status:"done"}),e?.onSuccess?.({user:i,linkMethod:"custom",linkedAccount:a}),{user:i}}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR,{linkMethod:"custom"}),r}}),[t.startAuthFlow,t.link]),state:r}}const Qe=e=>{let t=x();return o("customAuth",e),{status:t}};function Xe({isAuthenticated:e,isLoading:t,...r}){let o=se();oe((()=>{t||o.current?.()}),[e,t]);let i=te((e=>(o.current=e,()=>{o.current=void 0})),[]);return j({...r,subscribe:i})}function Je(){let{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}=e();return{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}}const $e=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=ne();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Ye=()=>{let{addSessionSignersInternal:t,removeSessionSignersInternal:r}=(()=>{let{getAccessToken:t,user:r}=e(),o=ne(),{signWithUserSigner:i}=q(),a=async({wallet:e,additional_signers:a})=>{let s=await t();if(!r||!s)throw new le("User must be authenticated and have an embedded wallet to delegate actions.");if(!e.id)throw new le("Wallet to add signers to must have ID on server");if(!o.walletProxy)throw new le("Wallet proxy not initialized.");await ke(o.privy,{wallet_id:e.id},i,{additional_signers:a})};return{addSessionSignersInternal:async({address:e,signers:i})=>{let s=await t();if(!r||!s)throw new le("User must be authenticated and have an embedded wallet to add a session signer.");let n=o.walletProxy??await o.initializeWalletProxy(15e3);if(!n)throw new le("Wallet proxy not initialized.");let l=G(r,e);if(!l)throw new le("Address to add signers too is not associated with current user.");if($(l)){if(0===i.length)throw new le("Must specify at least one signer to add.");let e=[...(await Ae(o.privy,{wallet_id:l.id})).additional_signers,...Y(i)];await a({wallet:l,additional_signers:e})}else{if(l.delegated)return{user:r};if(i.length>0)throw new le("addSessionSigners is only supported for TEE execution and this app uses On-device execution. Use the useHeadlessDelegatedActions hook to manage server side access on behalf of your users. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let t=Z({address:e,user:r}),a=ee({address:e,user:r});await o.recoverEmbeddedWallet({address:e}),await n.createDelegatedAction({accessToken:s,rootWallet:a,delegatedWallets:[t]})}let c=await o.refreshSessionAndUser();if(!c)throw Error("Could not refresh user");return{user:c}},removeSessionSignersInternal:async({address:e})=>{let i=await t();if(!r||!i)throw new le("User must be authenticated and have an embedded wallet to delegate actions.");if(!(o.walletProxy??await o.initializeWalletProxy(15e3)))throw new le("Wallet proxy not initialized.");let s=G(r,e);if(!s)throw new le("Address to remove signers from is not associated with current user.");$(s)?await a({wallet:s,additional_signers:[]}):await o.client.revokeDelegatedWallet();let n=await o.refreshSessionAndUser();if(!n)throw Error("Could not refresh user");return{user:n}}}})();return{addSessionSigners:async({address:e,signers:r})=>t({address:e,signers:r}),removeSessionSigners:async({address:e})=>r({address:e})}},Ze=()=>{let{setUser:e,client:t}=ie(ue),{user:r}=ie(h);return{user:r,refreshUser:te((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},et=e=>{let t=i(),{initLoginWithTelegram:r,loginWithTelegram:o,telegramAuthState:a,setTelegramAuthState:s}=ne();return{login:te((async i=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,ce.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:a,isNewUser:s,loginAccount:l,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:l})}catch(i){throw s({status:"error",error:i}),e?.onError?.(i.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:a}},tt=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=ne();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{_e as useConnectCoinbaseSmartWallet,ve as useConnectOrCreateWallet,Me as useCrossAppAccounts,Qe as useCustomAuth,$e as useDelegatedActions,Je as useFarcasterSigner,He as useGuestAccounts,tt as useHeadlessDelegatedActions,be as useLinkAccount,Be as useLinkJwtAccount,Ue as useLinkWithPasskey,Re as useLinkWithSiwe,Ee as useLoginWithEmail,Ce as useLoginWithFarcasterV2,Ie as useLoginWithOAuth,Te as useLoginWithPasskey,Pe as useLoginWithSiwe,Se as useLoginWithSms,et as useLoginWithTelegram,je as useModalStatus,Ve as useOAuthTokens,fe as useRecoverEmbeddedWallet,Fe as useSendTransaction,Ye as useSessionSigners,Le as useSetWalletPassword,De as useSetWalletRecovery,Ke as useSignAuthorization,xe as useSignMessage,Ne as useSignTransaction,ze as useSignTypedData,We as useSignupWithPasskey,Xe as useSubscribeToJwtAuthWithFlag,j as useSyncJwtBasedAuthState,qe as useToken,Oe as useUpdateAccount,Ze as useUser,W as useWallets};
1
+ import{g as e,a as r,u as o,b as i,c as s,C as n,d as l,s as d,e as h,f as p,h as m,G as f,W as k,i as C,j as W,k as T,l as U,m as S,n as R,o as _,p as j,q,r as G}from"./privy-provider-DyqReHyu.mjs";export{v as Captcha,w as ConnectorManager,E as EthereumWalletConnector,O as LoginModal,H as PrivyClient,P as PrivyProvider,V as VERSION,x as WalletConnector,D as errorIndicatesMaxMfaRetries,F as errorIndicatesMfaTimeout,B as errorIndicatesMfaVerificationFailed,t as getAccessToken,L as useCreateWallet,I as useIdentityToken,N as useImportWallet,J as useLogout,z as useMfa,A as useMfaEnrollment,y as usePrivy,K as useRegisterMfaListener,M as useSolanaWallets}from"./privy-provider-DyqReHyu.mjs";import{useCallback as Q,useMemo as X,useEffect as $,useContext as Y,useState as Z,useRef as ee}from"react";import{P as te,a as re}from"./paths-j39vuJt8.mjs";import{u as oe,I as ie}from"./internal-context-Bxhby7Hv.mjs";import{u as ae,P as se,g as ne,a as le,b as ce,c as ue}from"./use-sign-with-user-signer-CEyk1z8w.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-CKb44UC5.mjs";import{F as de}from"./frame-UsDF_L76.mjs";import{zeroAddress as he,getAddress as we,createWalletClient as pe,http as ge,parseSignature as me}from"viem";import{hashAuthorization as ye}from"viem/utils";import{getWallet as Ae,updateWallet as fe,generateAuthorizationSignature as ke}from"@privy-io/js-sdk-core";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"@privy-io/ethereum";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/solid/ArrowsRightLeftIcon";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/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 Ce=()=>{let{user:t}=ae(),{walletProxy:o}=oe();return{recover:Q((async i=>{if(!o)throw Error("Wallet proxy is not ready");let a=await e();if(!t||!a)throw new te("User must be logged in before attempting to modify the recovery method.");let{entropyId:s,entropyIdVerifier:n}=r(t);try{await o.recover({entropyId:s,entropyIdVerifier:n,accessToken:a,...i})}catch{throw new te("Unable to recover wallets")}}),[o,t])}},Ie=()=>{let{client:e,setAuthenticated:t,setUser:r}=oe();return X((()=>({init:async()=>{if(!e)throw new te("Must initialize Privy client first.");let t=new de;return e.startAuthFlow(t),await t.init()},login:async({fid:o,message:i,signature:a})=>{if(!e)throw new te("Must initialize Privy client first.");if(!(e.authFlow instanceof de))throw new te("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:i,signature:a,fid:o});let{user:s}=await e.authenticate();if(!s)throw new te("Failed to login with Farcaster V2");return r(s),t(!0),{user:s}}})),[e,r,t])},Ee=e=>{o("login",e);let t=i(),r=s(),{ready:a,user:c}=ae(),{initLoginWithHeadlessOAuth:u,loginWithHeadlessOAuth:h,oAuthState:w,setOAuthState:p,isHeadlessOAuthLoading:g}=oe(),m=Q((async e=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);return await u(e.provider,t.token,e.disableSignup)}catch(e){throw p({status:"error",error:e}),e}}),[u,t]),y=Q((async()=>{let e=l();try{if(c)return console.warn("Cannot login with OAuth when already logged in"),c;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 h(e)}catch(e){throw p({status:"error",error:e}),e}finally{d()}}),[h]);return $((()=>{let e=l();a&&r&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&y().catch((()=>{}))}),[a,r]),{initOAuth:m,loading:g,state:w}},We=e=>{let t=i(),{emailOtpState:r,setEmailOtpState:o,initLoginWithEmail:a,loginWithCode:s}=oe();return{sendCode:Q((async({email:r,disableSignup:i})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({email:r,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:Q((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await s(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"email",loginAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR),r}}),[s,t.status]),state:r}},Te=e=>{let t=i(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:s}=oe();return{signupWithPasskey:Q((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await r({captchaToken:i,withPrivyUi:!1});let{user:a,isNewUser:s,wasAlreadyAuthenticated:l,loginAccount:c}=await o();e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||re.UNKNOWN_AUTH_ERROR),t}}),[o,t.status]),state:a}},Ue=e=>{let t=i(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:s}=oe();return{loginWithPasskey:Q((async i=>{try{let a;if(t.enabled&&"error"===t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await r({captchaToken:a,withPrivyUi:!1});let{user:s,isNewUser:l,wasAlreadyAuthenticated:c,loginAccount:u}=await o(i);e?.onComplete?.({user:s,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(i){throw s({status:"error",error:i}),e?.onError?.(i.privyErrorCode||re.UNKNOWN_AUTH_ERROR),i}}),[o,t.status]),state:a}},Se=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:o,setPasskeyAuthState:i}=oe();return{linkWithPasskey:Q((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||re.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:o}},ve=e=>{let t=i(),{smsOtpState:r,setSmsOtpState:o,initLoginWithSms:a,loginWithCode:s}=oe();return{sendCode:Q((async({phoneNumber:r,disableSignup:i})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({phoneNumber:r,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:Q((async({code:r})=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await s(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"sms",loginAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR),r}}),[s,t.status]),state:r}},Re=e=>{let{connectOrCreateWallet:t}=ae();return o("connectOrCreateWallet",e),{connectOrCreateWallet:t}},Pe=e=>{let t=i(),{siweState:r,setSiweState:o,linkWithSiwe:a,generateSiweMessage:s}=oe();return{generateSiweMessage:Q((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await s({address:t,chainId:r}).then((e=>e))}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||re.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[s]),linkWithSiwe:Q((async({signature:r,message:i,chainId:s,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);let{user:o,linkedAccount:u}=await a({message:i,signature:r,chainId:s,walletClientType:l,connectorType:c});u&&e?.onSuccess?.({user:o,linkMethod:"siwe",linkedAccount:u})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[a,t.status]),state:r}},Ne=e=>{let t=i(),{siweState:r,setSiweState:o,client:a,generateSiweMessage:s,loginWithSiwe:l}=oe();return{generateSiweNonce:Q((async r=>{try{let e;if(t.enabled&&"error"===t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),o({status:"generating-message"});let i=await a.generateSiweNonce({address:r?.address,captchaToken:e});return o({status:"awaiting-signature"}),i}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR),r}}),[a,t]),generateSiweMessage:Q((async({address:t,chainId:r})=>{try{return await s({address:t,chainId:r})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||re.UNKNOWN_AUTH_ERROR),t}}),[s]),loginWithSiwe:Q((async({message:r,signature:i,disableSignup:a})=>{try{let o;if(t.enabled&&"error"===t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),o=await t.waitForResult());let s=await l({message:r,signature:i,captchaToken:o,disableSignup:a});return e?.onComplete?.({user:s,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),s}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR),r}}),[l,t.status]),state:r}};function be(){let{signTransaction:e}=Y(se);return{signTransaction:e}}function Oe(e){let{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:s,linkTwitter:n,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:h,linkInstagram:w,linkTelegram:p,linkFarcaster:g,linkPasskey:m}=Y(se);return o("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:s,linkTwitter:n,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:h,linkInstagram:w,linkFarcaster:g,linkTelegram:p,linkPasskey:m}}function _e(e){let{updateEmail:t,updatePhone:r}=Y(se);return o("update",e),{updateEmail:t,updatePhone:r}}const Me=()=>{let{connectCoinbaseSmartWallet:e}=oe();return{connectCoinbaseSmartWallet:e}},Fe=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:o,sendTransactionWithCrossAppWallet:i}=ae();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:r,signTypedData:o,sendTransaction:i}};function Le(e){let{sendTransaction:t}=Y(se);return o("sendTransaction",e),{sendTransaction:t}}function He(e){let{setWalletPassword:t}=Y(se);return o("setWalletPassword",e),{setWalletPassword:t}}function De(){let e=h(),{getAccessToken:t}=ae(),r=p(),{client:o,setUser:i,setAuthenticated:a,setIsNewUser:s,initializeWalletProxy:n}=oe(),{create:l}=m();return{createGuestAccount:async()=>{if(!e.id||!o)throw Error("SDK not yet ready");o.startAuthFlow(new f(e.id));try{let c=await o.authenticate(),u=c.user,d=c.isNewUser??!1;if(!u)throw new te("Unable to authenticate guest account");let h=await t(),w=await n(k);if(h&&w)try{let t=C(u,e.embeddedWallets.ethereum.createOnLogin),r=W(u,e.embeddedWallets.solana.createOnLogin);t&&r?(u=(await l({chainType:"ethereum",latestUser:u})).user,u=(await l({chainType:"solana",latestUser:u})).user):r?u=(await l({chainType:"solana",latestUser:u})).user:t?u=(await l({chainType:"ethereum",latestUser:u})).user:i(u)}catch(e){i(u),console.warn("Unable to create embedded wallet for guest account")}return s(d),a(!0),r("login","onComplete",{user:u,isNewUser:d,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw r("login","onError",e.privyErrorCode||re.UNKNOWN_AUTH_ERROR),e}}}}function xe(e){let{setWalletRecovery:t}=Y(se);return o("setWalletRecovery",e),{setWalletRecovery:t}}function Ke(e){let{signMessage:t}=Y(se);return o("signMessage",e),{signMessage:t}}const ze=()=>{let{ready:e,wallets:t}=T(),{user:r}=ae(),{rpcConfig:o,chains:i,appId:a}=oe();return{signAuthorization:Q((async(s,n)=>{let l;if(!r)throw Error("User must be authenticated before signing with a Privy wallet");if(!e)throw Error("Wallets are not ready");let c=n?.address??ne(r)?.address??he,u=t.find((e=>we(e.address)===we(c)));if(!u)throw Error("Signing wallet not found.");let d=s.chainId??Number(u.chainId.split(":")[1]);if(0===d)l={chainId:0,address:s.contractAddress,nonce:s.nonce??0};else{let e=i.find((e=>e.id===d));if(!e)throw Error("Error, chain not configured in PrivyProvider config");let t=pe({account:c,chain:e,transport:ge(U(e,o,a))});l=await t.prepareAuthorization({...s})}let h=await u.getEthereumProvider(),w=await h.request({method:"secp256k1_sign",params:[ye(l)]});return{...l,...me(w)}}),[e,t,r,i])}},je=ze;function qe(e){let{signTypedData:t}=Y(se);return o("signTypedData",e),{signTypedData:t}}const Ve=()=>{let{isModalOpen:e}=Y(se);return{isOpen:e}};function Ge(e){let{getAccessToken:t}=Y(se);return o("accessToken",e),{getAccessToken:t}}function Be(e){let{authenticated:t,user:r}=ae(),{initLoginWithOAuth:i}=oe(),a=p();return o("oAuthAuthorization",e),{reauthorize:e=>Je(t,r,i,a,e.provider)}}let Je=async(e,t,r,o,i)=>{if(!e)throw o("linkAccount","onError",re.MUST_BE_AUTHENTICATED,{linkMethod:i}),new te("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new te(`OAuth account of type ${i} not linked to the account.`);await r(i)};function Qe(e){let{client:t}=oe(),[r,o]=Z({status:"initial"});return{linkWithCustomJwt:Q((async r=>{try{o({status:"initial"}),t.startAuthFlow(new S(r)),o({status:"loading"});let{user:i}=await t.link();if(!i)throw Error("Error, user not found");let a=i.linkedAccounts.filter((e=>"custom_auth"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())).at(0);return o({status:"done"}),e?.onSuccess?.({user:i,linkMethod:"custom",linkedAccount:a}),{user:i}}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||re.UNKNOWN_AUTH_ERROR,{linkMethod:"custom"}),r}}),[t.startAuthFlow,t.link]),state:r}}const Xe=e=>{let t=R();return o("customAuth",e),{status:t}};function $e({isAuthenticated:e,isLoading:t,...r}){let o=ee();$((()=>{t||o.current?.()}),[e,t]);let i=Q((e=>(o.current=e,()=>{o.current=void 0})),[]);return _({...r,subscribe:i})}function Ye(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=ae();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}const Ze=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=oe();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},et=()=>{let{addSessionSignersInternal:e,removeSessionSignersInternal:t}=(()=>{let{getAccessToken:e,user:t}=ae(),r=oe(),{signWithUserSigner:o}=le(),i=async({wallet:i,additional_signers:a})=>{let s=await e();if(!t||!s)throw new te("User must be authenticated and have an embedded wallet to delegate actions.");if(!i.id)throw new te("Wallet to add signers to must have ID on server");if(!r.walletProxy)throw new te("Wallet proxy not initialized.");await fe(r.privy,{wallet_id:i.id},o,{additional_signers:a})};return{addSessionSignersInternal:async({address:o,signers:a})=>{let s=await e();if(!t||!s)throw new te("User must be authenticated and have an embedded wallet to add a session signer.");let n=r.walletProxy??await r.initializeWalletProxy(15e3);if(!n)throw new te("Wallet proxy not initialized.");let l=ce(t,o);if(!l)throw new te("Address to add signers too is not associated with current user.");if(ue(l)){if(0===a.length)throw new te("Must specify at least one signer to add.");let e=[...(await Ae(r.privy,{wallet_id:l.id})).additional_signers,...j(a)];await i({wallet:l,additional_signers:e})}else{if(l.delegated)return{user:t};if(a.length>0)throw new te("addSessionSigners is only supported for TEE execution and this app uses On-device execution. Use the useHeadlessDelegatedActions hook to manage server side access on behalf of your users. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let e=q({address:o,user:t}),i=G({address:o,user:t});await r.recoverEmbeddedWallet({address:o}),await n.createDelegatedAction({accessToken:s,rootWallet:i,delegatedWallets:[e]})}let c=await r.refreshSessionAndUser();if(!c)throw Error("Could not refresh user");return{user:c}},removeSessionSignersInternal:async({address:o})=>{let a=await e();if(!t||!a)throw new te("User must be authenticated and have an embedded wallet to delegate actions.");if(!(r.walletProxy??await r.initializeWalletProxy(15e3)))throw new te("Wallet proxy not initialized.");let s=ce(t,o);if(!s)throw new te("Address to remove signers from is not associated with current user.");ue(s)?await i({wallet:s,additional_signers:[]}):await r.client.revokeDelegatedWallet();let n=await r.refreshSessionAndUser();if(!n)throw Error("Could not refresh user");return{user:n}}}})();return{addSessionSigners:async({address:t,signers:r})=>e({address:t,signers:r}),removeSessionSigners:async({address:e})=>t({address:e})}},tt=()=>{let{signWithUserSigner:e}=le();return X((()=>({async generateAuthorizationSignature(t){let{signature:r}=await ke(e,t);return{signature:r}}})),[e])},rt=()=>{let{setUser:e,client:t}=Y(ie),{user:r}=Y(se);return{user:r,refreshUser:Q((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},ot=e=>{let t=i(),{initLoginWithTelegram:r,loginWithTelegram:o,telegramAuthState:a,setTelegramAuthState:s}=oe();return{login:Q((async i=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,re.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:a,isNewUser:s,loginAccount:l,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:l})}catch(i){throw s({status:"error",error:i}),e?.onError?.(i.privyErrorCode||re.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:a}},it=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=oe();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{tt as useAuthorizationSignature,Me as useConnectCoinbaseSmartWallet,Re as useConnectOrCreateWallet,Fe as useCrossAppAccounts,Xe as useCustomAuth,Ze as useDelegatedActions,Ye as useFarcasterSigner,De as useGuestAccounts,it as useHeadlessDelegatedActions,Oe as useLinkAccount,Qe as useLinkJwtAccount,Se as useLinkWithPasskey,Pe as useLinkWithSiwe,We as useLoginWithEmail,Ie as useLoginWithFarcasterV2,Ee as useLoginWithOAuth,Ue as useLoginWithPasskey,Ne as useLoginWithSiwe,ve as useLoginWithSms,ot as useLoginWithTelegram,Ve as useModalStatus,Be as useOAuthTokens,Ce as useRecoverEmbeddedWallet,Le as useSendTransaction,et as useSessionSigners,He as useSetWalletPassword,xe as useSetWalletRecovery,ze as useSign7702Authorization,je as useSignAuthorization,Ke as useSignMessage,be as useSignTransaction,qe as useSignTypedData,Te as useSignupWithPasskey,$e as useSubscribeToJwtAuthWithFlag,_ as useSyncJwtBasedAuthState,Ge as useToken,_e as useUpdateAccount,rt as useUser,T as useWallets};
@@ -0,0 +1 @@
1
+ import{createContext as t,useContext as e}from"react";const i=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},a=t=>()=>{throw Error(t.trim())},s=/*#__PURE__*/t({setAuthenticated:i,setUser:i,setIsNewUser:i,isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:i,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:i,initializeWalletProxy:i,getAuthMeta:i,getAuthFlow:i,closePrivyModal:i,openPrivyModal:i,connectWallet:i,initLoginWithWallet:i,loginWithWallet:i,initLoginWithFarcaster:i,loginWithFarcaster:i,loginWithCode:i,initLoginWithEmail:i,initLoginWithSms:i,initUpdateEmail:i,initUpdatePhone:i,resendEmailCode:i,resendSmsCode:i,initLoginWithHeadlessOAuth:i,loginWithHeadlessOAuth:i,crossAppAuthFlow:i,initLoginWithOAuth:i,loginWithOAuth:i,passkeyAuthState:{status:"initial"},setPasskeyAuthState:i,initSignupWithPasskey:i,signupWithPasskey:i,initLoginWithPasskey:i,loginWithPasskey:i,initLinkWithPasskey:i,linkWithPasskey:i,refreshSessionAndUser:i,walletProxy:null,createAnalyticsEvent:i,acceptTerms:i,getUsdTokenPrice:i,getUsdPriceForSol:i,getSplTokenMetadata:i,recoverEmbeddedWallet:i,updateWallets:i,fundWallet:i,openModal:i,setReadyToTrue:i,requestFarcasterSignerStatus:i,initLoginWithTelegram:i,loginWithTelegram:i,generateSiweMessage:i,generateSiweMessageForSmartWallet:i,loginWithSiwe:i,linkWithSiwe:i,linkSmartWallet:i,delegateWallet:i,revokeDelegatedWallets:i,exportSolanaWallet:i,connectCoinbaseSmartWallet:i,initiateAccountTransfer:i,emailOtpState:{status:"initial"},setEmailOtpState:i,smsOtpState:{status:"initial"},setSmsOtpState:i,siweState:{status:"initial"},setSiweState:i,oAuthState:{status:"initial"},setOAuthState:i,telegramAuthState:{status:"initial"},setTelegramAuthState:i,isHeadlessOAuthLoading:!1,isHeadlessSigning:i}),n=()=>e(s);export{s as I,i as a,a as n,n as u};
@@ -0,0 +1 @@
1
+ import{FetchError as a}from"ofetch";var s;class e extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(a,s,e){super(a),s instanceof Error&&(this.cause=s),this.privyErrorCode=e}}class t extends e{constructor(a,s,e,t,_,i){super(e,t,_),this.type=a,this.status=s,this.data=i}}class _ extends e{constructor(a,s,e){super(a,s,e),this.type="client_error"}}class i extends _{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class r extends e{constructor(a,s,e){super(a,s,e),this.type="connector_error"}}const n=s=>{if(s instanceof e)return s;if(!(s instanceof a))return o(s);if(!s.response)return new t("api_error",null,s.message,s);let{type:_,message:i,error:r,code:n}=s.data;return new t(_||"ApiError",s.response.status,i||r,s,n,s.data)},o=a=>a instanceof e?a:a instanceof Error?new _(a.message,a):new _(`Internal error: ${a}`);var p=((s={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",s.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",s.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",s.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",s.INVALID_DATA="invalid_data",s.INVALID_CAPTCHA="invalid_captcha",s.LINKED_TO_ANOTHER_USER="linked_to_another_user",s.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",s.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",s.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",s.USER_EXITED_UPDATE_FLOW="exited_update_flow",s.ALLOWLIST_REJECTED="allowlist_rejected",s.OAUTH_USER_DENIED="oauth_user_denied",s.OAUTH_UNEXPECTED="oauth_unexpected",s.UNKNOWN_AUTH_ERROR="unknown_auth_error",s.USER_EXITED_AUTH_FLOW="exited_auth_flow",s.USER_EXITED_LINK_FLOW="exited_link_flow",s.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",s.MUST_BE_AUTHENTICATED="must_be_authenticated",s.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",s.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",s.CLIENT_REQUEST_TIMEOUT="client_request_timeout",s.INVALID_CREDENTIALS="invalid_credentials",s.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",s.UNKNOWN_MFA_ERROR="unknown_mfa_error",s.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",s.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",s.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",s.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",s.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",s.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",s.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",s.TRANSACTION_FAILURE="transaction_failure",s.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",s.NOT_SUPPORTED="not_supported",s.CAPTCHA_TIMEOUT="captcha_timeout",s.INVALID_MESSAGE="invalid_message",s.UNABLE_TO_SIGN="unable_to_sign",s.CAPTCHA_FAILURE="captcha_failure",s.CAPTCHA_DISABLED="captcha_disabled",s.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",s.TOO_MANY_REQUESTS="too_many_requests",s.USER_LIMIT_REACHED="max_accounts_reached",s.DISALLOWED_LOGIN_METHOD="disallowed_login_method",s.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",s.PASSKEY_NOT_ALLOWED="passkey_not_allowed",s.USER_DOES_NOT_EXIST="user_does_not_exist",s.INSUFFICIENT_BALANCE="insufficient_balance",s.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",s.BUFFER_NOT_DEFINED="buffer_not_defined",s.UNSUPPORTED_WALLET_TYPE="unsupported_wallet_type",s);class E extends _{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class u extends _{constructor(a="Embedded wallet error",s){super(a,s,"unknown_embedded_wallet_error")}}class l extends _{constructor(a="User must be authenticated"){super(a,void 0,"must_be_authenticated")}}class c extends _{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 d="/api/v1/sessions",v="/api/v1/sessions/logout",A="/api/v1/siwe/init",T="/api/v1/siwe/authenticate",D="/api/v1/siwe/link",N="/api/v1/siwe/link_smart_wallet",I="/api/v1/siwe/unlink",O="/api/v1/siwe/transfer",L="/api/v1/siws/init",R="/api/v1/siws/authenticate",m="/api/v1/siws/link",w="/api/v1/siws/unlink",S="/api/v1/farcaster/init",h="/api/v1/farcaster/authenticate",f="/api/v1/farcaster/link",U="/api/v1/farcaster/status",C="/api/v1/farcaster/unlink",k="/api/v1/farcaster/transfer",y="api/v2/farcaster/init",g="api/v2/farcaster/authenticate",P="/api/v1/passwordless/init",W="/api/v1/passwordless/authenticate",M="/api/v1/passwordless/link",b="/api/v1/passwordless/unlink",x="/api/v1/passwordless/update",F="/api/v1/passwordless/transfer",H="/api/v1/passwordless_sms/init",B="/api/v1/passwordless_sms/link",V="/api/v1/passwordless_sms/unlink",K="/api/v1/passwordless_sms/authenticate",Y="/api/v1/passwordless_sms/update",G="/api/v1/passwordless_sms/transfer",X="/api/v1/oauth/init",$="/api/v1/oauth/authenticate",q="/api/v1/oauth/link",j="/api/v1/oauth/unlink",Q="/api/v1/oauth/transfer",J="/api/v1/recovery/oauth/init",z="/api/v1/recovery/oauth/init_icloud",Z="/api/v1/recovery/oauth/authenticate",aa="/api/v1/passkeys/link/init",sa="/api/v1/passkeys/authenticate/init",ea="/api/v1/passkeys/register/init",ta="/api/v1/passkeys/link",_a="/api/v1/passkeys/authenticate",ia="/api/v1/passkeys/register",ra="/api/v1/telegram/authenticate",na="/api/v1/telegram/link",oa="/api/v1/telegram/unlink",pa="/api/v1/telegram/transfer",Ea="/api/v1/mfa/passwordless_sms/init",ua="/api/v1/mfa/passkeys/init",la="/api/v1/users/me/accept_terms",ca="/api/v1/analytics_events",da="/api/v1/custom_jwt_account/authenticate",va="/api/v1/custom_jwt_account/link",Aa="/api/v1/guest/authenticate",Ta="/api/v1/plugins/moonpay_on_ramp/sign",Da="/api/v1/funding/coinbase_on_ramp/init",Na="/api/v1/funding/coinbase_on_ramp/status",Ia="/api/v1/wallets/revoke",Oa="/api/v1/users/me",La="/api/v1/scan/transaction";export{D as $,na as A,i as B,d as C,v as D,ca as E,da as F,va as G,Aa as H,o as I,t as J,Ea as K,ua as L,la as M,b as N,V as O,_ as P,I as Q,w as R,j as S,C as T,oa as U,Ia as V,Ta as W,Da as X,Na as Y,A as Z,T as _,p as a,N as a0,L as a1,R as a2,Q as a3,pa as a4,k as a5,O as a6,G as a7,F as a8,m as a9,Oa as aa,La as ab,Z as ac,z as ad,J as ae,u as af,c as ag,l as ah,E as ai,y as aj,g as ak,M as b,P as c,r as d,h as e,n as f,f as g,S as h,U as i,q as j,X as k,ia as l,_a as m,ta as n,$ as o,W as p,ea as q,sa as r,aa as s,K as t,x as u,B as v,H as w,Y as x,e as y,ra as z};