@privy-io/react-auth 2.13.2 → 2.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/abstract-smart-wallets.js +1 -1
- package/dist/cjs/farcaster.js +1 -1
- package/dist/cjs/{frame-mbQ9YqJg.js → frame-gaUtF4i1.js} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{internal-context-Bj24LJZ_.js → internal-context-D-v3o9iX.js} +1 -1
- package/dist/cjs/{privy-provider-Dg-HUZ-W.js → privy-provider-BZ-EOdfp.js} +6 -6
- package/dist/cjs/{smart-wallets-BejovVNZ.js → smart-wallets-ZbySP4Ih.js} +1 -1
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/ui.js +1 -1
- package/dist/cjs/{useActiveWallet-JXvj09eK.js → useActiveWallet-DHiaJEM-.js} +1 -1
- package/dist/cjs/{useFundWallet-BiK8UG5d.js → useFundWallet-DAr5V8vT.js} +1 -1
- package/dist/dts/index.d.mts +31 -1
- package/dist/dts/index.d.ts +31 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/farcaster.mjs +1 -1
- package/dist/esm/{frame-8dYl0aUa.mjs → frame-DcLJJ5Fa.mjs} +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{internal-context-tkv6NwcA.mjs → internal-context-BOEPXMqX.mjs} +1 -1
- package/dist/esm/privy-provider-CeZefZDF.mjs +28 -0
- package/dist/esm/{smart-wallets-AW28DdL2.mjs → smart-wallets-DO8wiGL0.mjs} +1 -1
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +2 -2
- package/dist/esm/{useActiveWallet-BuX3SOsQ.mjs → useActiveWallet-BzaD7wH1.mjs} +1 -1
- package/dist/esm/{useFundWallet-BVsCwXLF.mjs → useFundWallet-5tP5V2a8.mjs} +1 -1
- package/package.json +4 -4
- package/dist/esm/privy-provider-CjEHJneX.mjs +0 -28
package/dist/dts/index.d.ts
CHANGED
|
@@ -3817,6 +3817,36 @@ interface UseSubscribeToJwtAuthWithFlagInput extends Omit<UseSyncJwtBasedAuthSta
|
|
|
3817
3817
|
*/
|
|
3818
3818
|
declare function useSubscribeToJwtAuthWithFlag({ isAuthenticated, isLoading, ...useSyncJwtBasedAuthStateInput }: UseSubscribeToJwtAuthWithFlagInput): UseSyncJwtBasedAuthStateInterface;
|
|
3819
3819
|
|
|
3820
|
+
/**
|
|
3821
|
+
* Use this hook to link a new custom JWT account to an authenticated user, and to attach
|
|
3822
|
+
* callbacks for success and errors.
|
|
3823
|
+
*
|
|
3824
|
+
*/
|
|
3825
|
+
type UseLinkJwtAccount = {
|
|
3826
|
+
/**
|
|
3827
|
+
* Link a new custom JWT account to the authenticated user.
|
|
3828
|
+
*
|
|
3829
|
+
* @param jwt - The custom JWT to link to the user.
|
|
3830
|
+
* @returns The user and the linked account.
|
|
3831
|
+
*/
|
|
3832
|
+
linkWithCustomJwt: (jwt: string) => Promise<{
|
|
3833
|
+
user: User;
|
|
3834
|
+
}>;
|
|
3835
|
+
/**
|
|
3836
|
+
* The current state of the JWT account linkage flow.
|
|
3837
|
+
*/
|
|
3838
|
+
state: JwtAuthFlowState;
|
|
3839
|
+
};
|
|
3840
|
+
/**
|
|
3841
|
+
* Use this hook to link a new custom JWT account to an authenticated user, and to attach
|
|
3842
|
+
* callbacks for success and errors.
|
|
3843
|
+
*
|
|
3844
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute after a successful account linkage
|
|
3845
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `link`.
|
|
3846
|
+
*
|
|
3847
|
+
*/
|
|
3848
|
+
declare function useLinkJwtAccount(callbacks?: PrivyEvents['linkAccount']): UseLinkJwtAccount;
|
|
3849
|
+
|
|
3820
3850
|
/**
|
|
3821
3851
|
* Use this hook to write to Farcaster.
|
|
3822
3852
|
*
|
|
@@ -3971,4 +4001,4 @@ declare const LoginModal: ({ open }: {
|
|
|
3971
4001
|
open: boolean;
|
|
3972
4002
|
}) => react_jsx_runtime.JSX.Element;
|
|
3973
4003
|
|
|
3974
|
-
export { BaseConnectedWalletType, Captcha, ConnectWalletModalOptions, ConnectedSolanaWallet, ConnectedWallet, ConnectorManager, type CustomAuthFlowState, EIP1193Provider, EthereumWalletConnector, FundWalletConfig, type JwtAuthFlowState, LoginModal, LoginModalOptions, LoginWithCode, MfaMethod, OAuthFlowState, OAuthProviderType, OAuthTokens, OtpFlowState, PasskeyFlowState, PrivyClient, PrivyClientConfig, PrivyEvents, type PrivyInterface, PrivyProvider, type PrivyProviderProps, type SendCodeToEmail, type SendCodeToSms, SendTransactionModalUIOptions, SignMessageModalUIOptions, SignTypedDataParams, SiweFlowState, TelegramAuthFlowState, UnsignedTransactionRequest, type UseConnectCoinbaseSmartWalletInterface, type UseCustomAuth, type UseDelegatedActionsInterface, type UseFundWalletInterface, type UseImportWalletInterface, type UseLinkWithPasskey, type UseLoginWithEmail, type UseLoginWithPasskey, type UseLoginWithSms, type UseLoginWithTelegram, type UseOAuthTokens, type UseRecoverEmbeddedWalletInterface, type UseSessionSignersInterface, type UseSignupWithPasskey, type UseSubscribeToJwtAuthWithFlagInput, type UseSyncJwtBasedAuthStateInput, type UseSyncJwtBasedAuthStateInterface, type UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletListEntry, errorIndicatesMaxMfaRetries, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, getCustomerAccessToken as getAccessToken, getEmbeddedConnectedWallet, useActiveWallet, useConnectCoinbaseSmartWallet, useConnectOrCreateWallet, useConnectWallet, useCreateWallet, useCrossAppAccounts, useCustomAuth, useDelegatedActions, useFarcasterSigner, useFundWallet, useGuestAccounts, useHeadlessDelegatedActions, useIdentityToken, useImportWallet, useLinkAccount, useLinkWithPasskey, useLinkWithSiwe, useLogin, useLoginWithEmail, useLoginWithFarcasterV2, useLoginWithOAuth, useLoginWithPasskey, useLoginWithSiwe, useLoginWithSms, useLoginWithTelegram, useLogout, useMfa, useMfaEnrollment, useModalStatus, useOAuthTokens, usePrivy, useRecoverEmbeddedWallet, useRegisterMfaListener, useSendTransaction, useSessionSigners, useSetWalletPassword, useSetWalletRecovery, useSignAuthorization, useSignMessage, useSignTransaction, useSignTypedData, useSignupWithPasskey, useSubscribeToJwtAuthWithFlag, useSyncJwtBasedAuthState, useToken, useUpdateAccount, useUser, useWallets };
|
|
4004
|
+
export { BaseConnectedWalletType, Captcha, ConnectWalletModalOptions, ConnectedSolanaWallet, ConnectedWallet, ConnectorManager, type CustomAuthFlowState, EIP1193Provider, EthereumWalletConnector, FundWalletConfig, type JwtAuthFlowState, LoginModal, LoginModalOptions, LoginWithCode, MfaMethod, OAuthFlowState, OAuthProviderType, OAuthTokens, OtpFlowState, PasskeyFlowState, PrivyClient, PrivyClientConfig, PrivyEvents, type PrivyInterface, PrivyProvider, type PrivyProviderProps, type SendCodeToEmail, type SendCodeToSms, SendTransactionModalUIOptions, SignMessageModalUIOptions, SignTypedDataParams, SiweFlowState, TelegramAuthFlowState, UnsignedTransactionRequest, type UseConnectCoinbaseSmartWalletInterface, type UseCustomAuth, type UseDelegatedActionsInterface, type UseFundWalletInterface, type UseImportWalletInterface, type UseLinkJwtAccount, type UseLinkWithPasskey, type UseLoginWithEmail, type UseLoginWithPasskey, type UseLoginWithSms, type UseLoginWithTelegram, type UseOAuthTokens, type UseRecoverEmbeddedWalletInterface, type UseSessionSignersInterface, type UseSignupWithPasskey, type UseSubscribeToJwtAuthWithFlagInput, type UseSyncJwtBasedAuthStateInput, type UseSyncJwtBasedAuthStateInterface, type UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletListEntry, errorIndicatesMaxMfaRetries, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, getCustomerAccessToken as getAccessToken, getEmbeddedConnectedWallet, useActiveWallet, useConnectCoinbaseSmartWallet, useConnectOrCreateWallet, useConnectWallet, useCreateWallet, useCrossAppAccounts, useCustomAuth, useDelegatedActions, useFarcasterSigner, useFundWallet, useGuestAccounts, useHeadlessDelegatedActions, useIdentityToken, useImportWallet, useLinkAccount, useLinkJwtAccount, useLinkWithPasskey, useLinkWithSiwe, useLogin, useLoginWithEmail, useLoginWithFarcasterV2, useLoginWithOAuth, useLoginWithPasskey, useLoginWithSiwe, useLoginWithSms, useLoginWithTelegram, useLogout, useMfa, useMfaEnrollment, useModalStatus, useOAuthTokens, usePrivy, useRecoverEmbeddedWallet, useRegisterMfaListener, useSendTransaction, useSessionSigners, useSetWalletPassword, useSetWalletRecovery, useSignAuthorization, useSignMessage, useSignTransaction, useSignTypedData, useSignupWithPasskey, useSubscribeToJwtAuthWithFlag, useSyncJwtBasedAuthState, useToken, useUpdateAccount, useUser, useWallets };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAbstractClient as e}from"@abstract-foundation/agw-client";import{getBatchTransactionObject as o}from"@abstract-foundation/agw-client/actions";import{hexToNumber as r,createWalletClient as t,custom as n,http as i}from"viem";import{toAccount as a}from"viem/accounts";import{abstractTestnet as
|
|
1
|
+
import{createAbstractClient as e}from"@abstract-foundation/agw-client";import{getBatchTransactionObject as o}from"@abstract-foundation/agw-client/actions";import{hexToNumber as r,createWalletClient as t,custom as n,http as i}from"viem";import{toAccount as a}from"viem/accounts";import{abstractTestnet as s}from"viem/chains";import{u as c,f as l,l as d,au as p,m,v as u,a as h,aH as y,aI as I,aJ as g,n as v}from"./privy-provider-CeZefZDF.mjs";import{u as f}from"./internal-context-BOEPXMqX.mjs";import{g as w}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import{c as C}from"./smart-wallets-DO8wiGL0.mjs";import"react/jsx-runtime";import"mipd";import"react";import"react-device-detect";import"viem/utils";import"@privy-io/js-sdk-core";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";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";function T(){let{user:T}=c(),{hideWalletUIs:S,openPrivyModal:P,chains:b,appId:A,rpcConfig:W,client:M}=f(),k=l(),{wallets:F}=d(),{setModalData:q}=p(),x=m(T),R=!!x&&u(x),D=async(o=s.id)=>{let c=w(F);if(!c)throw Error("No connected wallet found");let l="string"==typeof o?r(o):o;if(![s.id,2741].includes(l))throw Error("Error, only Abstract chains are supported");let d=b.find((e=>e.id===l));if(!d)throw Error("Chain not configured");await c.switchChain(d.id);let p=await c.getEthereumProvider(),m=t({account:c.address,transport:n(p)}),u=a({address:c.address,signMessage:m.signMessage,signTransaction:m.signTransaction,signTypedData:m.signTypedData});return await e({chain:d,transport:i(v(d,W,A)),publicTransport:i(v(d,W,A)),signer:u})};return{signMessage:async({message:e},o)=>{let r=await D(o);return new Promise((async(o,t)=>{let{entropyId:n,entropyIdVerifier:i}=h(T);S.current=!0,q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:R,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:y,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>r.signMessage({message:e}),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{S.current=!1}))},signTypedData:async(e,o)=>{let r=await D(o);return new Promise((async(o,t)=>{S.current=!0;let{entropyId:n,entropyIdVerifier:i}=h(T);q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:R,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:y,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{S.current=!1}))},sendTransaction:async e=>{let r=await D(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{S.current=!0;let{entropyId:s,entropyIdVerifier:c}=h(T);q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:R,entropyId:s,entropyIdVerifier:c,onCompleteNavigateTo:g,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:t,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:s,entropyIdVerifier:c,transactingWalletAddress:r.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=n?o(r.account.address,e):e;return await r.prepareAbstractTransactionRequest({...t,isSponsored:void 0!==t.paymaster&&void 0!==t.paymasterInput})},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest({...t,isSponsored:void 0!==t.paymaster&&void 0!==t.paymasterInput});return await M.scanTransaction({metadata:{domain:k.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data,eip_712_meta:{paymaster_params:{paymaster:i.paymaster,paymaster_input:i.paymasterInput}}}]}})},signOnly:!1,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>n?r.sendTransactionBatch(e):r.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:a,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{S.current=!1}))},signTransaction:async e=>{let r=await D(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{S.current=!0;let{entropyId:s,entropyIdVerifier:c}=h(T);q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:R,entropyId:s,entropyIdVerifier:c,onCompleteNavigateTo:g,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:t,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:s,entropyIdVerifier:c,transactingWalletAddress:r.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=n?o(r.account.address,e):e;return await r.prepareAbstractTransactionRequest({...t,isSponsored:void 0!==t.paymaster&&void 0!==t.paymasterInput})},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest({...t,isSponsored:void 0!==t.paymaster&&void 0!==t.paymasterInput});return await M.scanTransaction({metadata:{domain:k.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data}]}})},signOnly:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:async()=>{let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest({...t,isSponsored:void 0!==t.paymaster&&void 0!==t.paymasterInput});return r.signTransaction(i)},onSuccess:e=>i(e.hash),onFailure:a,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{S.current=!1}))}}}export{T as useAbstractSmartWallets};
|
package/dist/esm/farcaster.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as t}from"react";import{F as e}from"./frame-
|
|
1
|
+
import{useCallback as t}from"react";import{F as e}from"./frame-DcLJJ5Fa.mjs";import{u as i,P as r}from"./internal-context-BOEPXMqX.mjs";import"ofetch";const a=()=>{let{client:a,setAuthenticated:n,setUser:s}=i();return{initLoginToFrame:t((async()=>{let t=new e;if(!a)throw new r("Must initialize Privy client first.");return a.startAuthFlow(t),await t.init()}),[a]),loginToFrame:t((async({message:t,signature:i})=>{if(!a)throw new r("Must initialize Privy client first.");if(!(a.authFlow instanceof e))throw new r("Must initialize Farcaster frame flow first.");let o=(t=>{let e=t.match(/farcaster:\/\/fid\/(\d+)/);return e&&e[1]?parseInt(e[1],10):null})(t);if(!o)throw new r("Invalid message format; could not parse Farcaster ID.");a.authFlow.setAuthData({message:t,signature:i,fid:o});let{user:l}=await a.authenticate();return l&&(s(l),n(!0)),l}),[a,s,n])}};export{a as useLoginToFrame};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as t,
|
|
1
|
+
import{P as t,an as s,ao as i,f as e}from"./internal-context-BOEPXMqX.mjs";class a{async init(){if(!this.api)throw new t("Auth flow has no API instance");let{nonce:i,expires_at:e}=await this.api.post(s,{});return{nonce:i,expiresAt:e}}async authenticate(){if(!this.message||!this.signature||!this.fid)throw new t("Auth flow has no message, signature, or fid");if(!this.api)throw new t("Auth flow has no API instance");try{let s=await this.api.post(i,{message:this.message,signature:this.signature,fid:this.fid});if(!s)throw new t("No response from authentication");return s}catch(t){throw e(t)}}async link(){throw Error("Not implemented")}setAuthData({message:t,signature:s,fid:i}){this.message=t,this.signature=s,this.fid=i}constructor(){this.meta={}}}export{a as F};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e,g as t,a as r,b as o,c as i,d as n,C as s,e as l,s as d,P as h,f as w,h as p,i as m,G as k,W as f,j as C,k as W,l as v,m as P,n as _,o as x,p as j,q,r as G,t as X,v as $,w as Y,x as Z}from"./privy-provider-CjEHJneX.mjs";export{A as Captcha,B as ConnectorManager,E as EthereumWalletConnector,U as LoginModal,M as PrivyClient,y as PrivyProvider,V as VERSION,D as WalletConnector,K as errorIndicatesMaxMfaRetries,L as errorIndicatesMfaTimeout,J as errorIndicatesMfaVerificationFailed,z as getAccessToken,R as useCreateWallet,N as useIdentityToken,T as useImportWallet,O as useLogout,H as useMfa,I as useMfaEnrollment,F as usePrivy,Q as useRegisterMfaListener,S as useSolanaWallets}from"./privy-provider-CjEHJneX.mjs";import{useCallback as ee,useMemo as te,useEffect as re,useContext as oe,useRef as ie}from"react";import{u as ae,P as ne,a as se,I as le}from"./internal-context-tkv6NwcA.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-BuX3SOsQ.mjs";import{F as ce}from"./frame-8dYl0aUa.mjs";import{zeroAddress as ue,getAddress as de,createWalletClient as he,http as we,parseSignature as pe}from"viem";import{hashAuthorization as ge}from"viem/utils";import{getWallet as me,updateWallet as ye}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 Ae=()=>{let{user:o}=e(),{walletProxy:i}=ae();return{recover:ee((async e=>{if(!i)throw Error("Wallet proxy is not ready");let a=await t();if(!o||!a)throw new ne("User must be logged in before attempting to modify the recovery method.");let{entropyId:n,entropyIdVerifier:s}=r(o);try{await i.recover({entropyId:n,entropyIdVerifier:s,accessToken:a,...e})}catch{throw new ne("Unable to recover wallets")}}),[i,o])}},ke=()=>{let{client:e,setAuthenticated:t,setUser:r}=ae();return te((()=>({init:async()=>{if(!e)throw new ne("Must initialize Privy client first.");let t=new ce;return e.startAuthFlow(t),await t.init()},login:async({fid:o,message:i,signature:a})=>{if(!e)throw new ne("Must initialize Privy client first.");if(!(e.authFlow instanceof ce))throw new ne("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:i,signature:a,fid:o});let{user:n}=await e.authenticate();if(!n)throw new ne("Failed to login with Farcaster V2");return r(n),t(!0),{user:n}}})),[e,r,t])},fe=t=>{o("login",t);let r=i(),a=n(),{ready:c,user:u}=e(),{initLoginWithHeadlessOAuth:h,loginWithHeadlessOAuth:w,oAuthState:p,setOAuthState:g,isHeadlessOAuthLoading:m}=ae(),y=ee((async e=>{try{if(r.enabled&&"success"!==r.status)throw new s(r.error,null,se.CAPTCHA_FAILURE);return await h(e.provider,r.token,e.disableSignup)}catch(e){throw g({status:"error",error:e}),e}}),[h,r]),A=ee((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 re((()=>{let e=l();c&&a&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&A().catch((()=>{}))}),[c,a]),{initOAuth:y,loading:m,state:p}},Ce=e=>{let t=i(),{emailOtpState:r,setEmailOtpState:o,initLoginWithEmail:a,loginWithCode:n}=ae();return{sendCode:ee((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 s(t.error,null,se.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||se.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:ee((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await n(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||se.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},Ie=e=>{let t=i(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:n}=ae();return{signupWithPasskey:ee((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await r({captchaToken:i,withPrivyUi:!1});let{user:a,isNewUser:n,wasAlreadyAuthenticated:l,loginAccount:c}=await o();e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw n({status:"error",error:t}),e?.onError?.(t.privyErrorCode||se.UNKNOWN_AUTH_ERROR),t}}),[o,t.status]),state:a}},We=e=>{let t=i(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:n}=ae();return{loginWithPasskey:ee((async i=>{try{let a;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await r({captchaToken:a,withPrivyUi:!1});let{user:n,isNewUser:l,wasAlreadyAuthenticated:c,loginAccount:u}=await o(i);e?.onComplete?.({user:n,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||se.UNKNOWN_AUTH_ERROR),i}}),[o,t.status]),state:a}},Ee=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:o,setPasskeyAuthState:i}=ae();return{linkWithPasskey:ee((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||se.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:o}},Te=e=>{let t=i(),{smsOtpState:r,setSmsOtpState:o,initLoginWithSms:a,loginWithCode:n}=ae();return{sendCode:ee((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 s(t.error,null,se.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||se.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:ee((async({code:r})=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await n(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||se.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},Ue=t=>{let{connectOrCreateWallet:r}=e();return o("connectOrCreateWallet",t),{connectOrCreateWallet:r}},Se=e=>{let t=i(),{siweState:r,setSiweState:o,linkWithSiwe:a,generateSiweMessage:n}=ae();return{generateSiweMessage:ee((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||se.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[n]),linkWithSiwe:ee((async({signature:r,message:i,chainId:n,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);let{user:o,linkedAccount:u}=await a({message:i,signature:r,chainId:n,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||se.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[a,t.status]),state:r}},ve=e=>{let t=i(),{siweState:r,setSiweState:o,client:a,generateSiweMessage:n,loginWithSiwe:l}=ae();return{generateSiweNonce:ee((async r=>{try{let e;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.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||se.UNKNOWN_AUTH_ERROR),r}}),[a,t]),generateSiweMessage:ee((async({address:t,chainId:r})=>{try{return await n({address:t,chainId:r})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||se.UNKNOWN_AUTH_ERROR),t}}),[n]),loginWithSiwe:ee((async({message:r,signature:i,disableSignup:a})=>{try{let o;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),o=await t.waitForResult());let n=await l({message:r,signature:i,captchaToken:o,disableSignup:a});return e?.onComplete?.({user:n,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),n}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR),r}}),[l,t.status]),state:r}};function Re(){let{signTransaction:e}=oe(h);return{signTransaction:e}}function Pe(e){let{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:n,linkTwitter:s,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:w,linkInstagram:p,linkTelegram:g,linkFarcaster:m,linkPasskey:y}=oe(h);return o("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:n,linkTwitter:s,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:w,linkInstagram:p,linkFarcaster:m,linkTelegram:g,linkPasskey:y}}function be(e){let{updateEmail:t,updatePhone:r}=oe(h);return o("update",e),{updateEmail:t,updatePhone:r}}const Ne=()=>{let{connectCoinbaseSmartWallet:e}=ae();return{connectCoinbaseSmartWallet:e}},Oe=()=>{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 _e(e){let{sendTransaction:t}=oe(h);return o("sendTransaction",e),{sendTransaction:t}}function Me(e){let{setWalletPassword:t}=oe(h);return o("setWalletPassword",e),{setWalletPassword:t}}function Fe(){let t=w(),{getAccessToken:r}=e(),o=p(),{client:i,setUser:a,setAuthenticated:n,setIsNewUser:s,initializeWalletProxy:l}=ae(),{create:c}=m();return{createGuestAccount:async()=>{if(!t.id||!i)throw Error("SDK not yet ready");i.startAuthFlow(new k(t.id));try{let e=await i.authenticate(),u=e.user,d=e.isNewUser??!1;if(!u)throw new ne("Unable to authenticate guest account");let h=await r(),w=await l(f);if(h&&w)try{let e=C(u,t.embeddedWallets.ethereum.createOnLogin),r=W(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 s(d),n(!0),o("login","onComplete",{user:u,isNewUser:d,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw o("login","onError",e.privyErrorCode||se.UNKNOWN_AUTH_ERROR),e}}}}function Le(e){let{setWalletRecovery:t}=oe(h);return o("setWalletRecovery",e),{setWalletRecovery:t}}function He(e){let{signMessage:t}=oe(h);return o("signMessage",e),{signMessage:t}}const De=()=>{let{ready:t,wallets:r}=v(),{user:o}=e(),{rpcConfig:i,chains:a,appId:n}=ae();return{signAuthorization:ee((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 l=s?.address??P(o)?.address??ue,c=r.find((e=>de(e.address)===de(l)));if(!c)throw Error("Signing wallet not found.");let u=e.chainId??Number(c.chainId.split(":")[1]),d=a.find((e=>e.id===u));if(!d)throw Error("Error, chain not configured in PrivyProvider config");let h=he({account:l,chain:d,transport:we(_(d,i,n))}),w=await h.prepareAuthorization({...e}),p=await c.getEthereumProvider(),g=await p.request({method:"secp256k1_sign",params:[ge(w)]});return{...w,...pe(g)}}),[t,r,o,a])}};function xe(e){let{signTypedData:t}=oe(h);return o("signTypedData",e),{signTypedData:t}}const Ke=()=>{let{isModalOpen:e}=oe(h);return{isOpen:e}};function ze(e){let{getAccessToken:t}=oe(h);return o("accessToken",e),{getAccessToken:t}}function je(t){let{authenticated:r,user:i}=e(),{initLoginWithOAuth:a}=ae(),n=p();return o("oAuthAuthorization",t),{reauthorize:e=>qe(r,i,a,n,e.provider)}}let qe=async(e,t,r,o,i)=>{if(!e)throw o("linkAccount","onError",se.MUST_BE_AUTHENTICATED,{linkMethod:i}),new ne("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new ne(`OAuth account of type ${i} not linked to the account.`);await r(i)};const Ve=e=>{let t=x();return o("customAuth",e),{status:t}};function Ge({isAuthenticated:e,isLoading:t,...r}){let o=ie();re((()=>{t||o.current?.()}),[e,t]);let i=ee((e=>(o.current=e,()=>{o.current=void 0})),[]);return j({...r,subscribe:i})}function Be(){let{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}=e();return{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}}const Qe=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=ae();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Xe=()=>{let{addSessionSignersInternal:t,removeSessionSignersInternal:r}=(()=>{let{getAccessToken:t,user:r}=e(),o=ae(),{signWithUserSigner:i}=q(),a=async({wallet:e,additional_signers:a})=>{let n=await t();if(!r||!n)throw new ne("User must be authenticated and have an embedded wallet to delegate actions.");if(!e.id)throw new ne("Wallet to add signers to must have ID on server");if(!o.walletProxy)throw new ne("Wallet proxy not initialized.");await ye(o.privy,{wallet_id:e.id},i,{additional_signers:a})};return{addSessionSignersInternal:async({address:e,signers:i})=>{let n=await t();if(!r||!n)throw new ne("User must be authenticated and have an embedded wallet to add a session signer.");let s=o.walletProxy??await o.initializeWalletProxy(15e3);if(!s)throw new ne("Wallet proxy not initialized.");let l=G(r,e);if(!l)throw new ne("Address to add signers too is not associated with current user.");if(X(l)){if(0===i.length)throw new ne("Must specify at least one signer to add.");let e=[...(await me(o.privy,{wallet_id:l.id})).additional_signers,...$(i)];await a({wallet:l,additional_signers:e})}else{if(l.delegated)return{user:r};if(i.length>0)throw new ne("This embedded wallet does not support specifying signers. If signing is enabled in the dashboard, signer will default to that key. Otherwise, no signatures will be required for the wallet.");let t=Y({address:e,user:r}),a=Z({address:e,user:r});await o.recoverEmbeddedWallet({address:e}),await s.createDelegatedAction({accessToken:n,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 ne("User must be authenticated and have an embedded wallet to delegate actions.");if(!(o.walletProxy??await o.initializeWalletProxy(15e3)))throw new ne("Wallet proxy not initialized.");let n=G(r,e);if(!n)throw new ne("Address to remove signers from is not associated with current user.");X(n)?await a({wallet:n,additional_signers:[]}):await o.client.revokeDelegatedWallet();let s=await o.refreshSessionAndUser();if(!s)throw Error("Could not refresh user");return{user:s}}}})();return{addSessionSigners:async({address:e,signers:r})=>t({address:e,signers:r}),removeSessionSigners:async({address:e})=>r({address:e})}},Je=()=>{let{setUser:e,client:t}=oe(le),{user:r}=oe(h);return{user:r,refreshUser:ee((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},$e=e=>{let t=i(),{initLoginWithTelegram:r,loginWithTelegram:o,telegramAuthState:a,setTelegramAuthState:n}=ae();return{login:ee((async i=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:a,isNewUser:n,loginAccount:l,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:l})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||se.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:a}},Ye=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=ae();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{Ne as useConnectCoinbaseSmartWallet,Ue as useConnectOrCreateWallet,Oe as useCrossAppAccounts,Ve as useCustomAuth,Qe as useDelegatedActions,Be as useFarcasterSigner,Fe as useGuestAccounts,Ye as useHeadlessDelegatedActions,Pe as useLinkAccount,Ee as useLinkWithPasskey,Se as useLinkWithSiwe,Ce as useLoginWithEmail,ke as useLoginWithFarcasterV2,fe as useLoginWithOAuth,We as useLoginWithPasskey,ve as useLoginWithSiwe,Te as useLoginWithSms,$e as useLoginWithTelegram,Ke as useModalStatus,je as useOAuthTokens,Ae as useRecoverEmbeddedWallet,_e as useSendTransaction,Xe as useSessionSigners,Me as useSetWalletPassword,Le as useSetWalletRecovery,De as useSignAuthorization,He as useSignMessage,Re as useSignTransaction,xe as useSignTypedData,Ie as useSignupWithPasskey,Ge as useSubscribeToJwtAuthWithFlag,j as useSyncJwtBasedAuthState,ze as useToken,be as useUpdateAccount,Je as useUser,v as useWallets};
|
|
1
|
+
import{u as e,g as t,a as r,b as o,c as i,d as n,C as s,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-CeZefZDF.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-CeZefZDF.mjs";import{useCallback as te,useMemo as re,useEffect as oe,useContext as ie,useState as ae,useRef as ne}from"react";import{u as se,P as le,a as ce,I as ue}from"./internal-context-BOEPXMqX.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-BzaD7wH1.mjs";import{F as de}from"./frame-DcLJJ5Fa.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}=se();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:n,entropyIdVerifier:s}=r(o);try{await i.recover({entropyId:n,entropyIdVerifier:s,accessToken:a,...e})}catch{throw new le("Unable to recover wallets")}}),[i,o])}},Ce=()=>{let{client:e,setAuthenticated:t,setUser:r}=se();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:n}=await e.authenticate();if(!n)throw new le("Failed to login with Farcaster V2");return r(n),t(!0),{user:n}}})),[e,r,t])},Ie=t=>{o("login",t);let r=i(),a=n(),{ready:c,user:u}=e(),{initLoginWithHeadlessOAuth:h,loginWithHeadlessOAuth:w,oAuthState:p,setOAuthState:g,isHeadlessOAuthLoading:m}=se(),y=te((async e=>{try{if(r.enabled&&"success"!==r.status)throw new s(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:n}=se();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 s(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 s(t.error,null,ce.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await n(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}}),[n,t.status]),state:r}},We=e=>{let t=i(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:n}=se();return{signupWithPasskey:te((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new s(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:n,wasAlreadyAuthenticated:l,loginAccount:c}=await o();e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw n({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:n}=se();return{loginWithPasskey:te((async i=>{try{let a;if(t.enabled&&"error"===t.status)throw new s(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:n,isNewUser:l,wasAlreadyAuthenticated:c,loginAccount:u}=await o(i);e?.onComplete?.({user:n,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(i){throw n({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}=se();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:n}=se();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 s(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 s(t.error,null,ce.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await n(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}}),[n,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:n}=se();return{generateSiweMessage:te((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||ce.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[n]),linkWithSiwe:te((async({signature:r,message:i,chainId:n,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,ce.CAPTCHA_FAILURE);let{user:o,linkedAccount:u}=await a({message:i,signature:r,chainId:n,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:n,loginWithSiwe:l}=se();return{generateSiweNonce:te((async r=>{try{let e;if(t.enabled&&"error"===t.status)throw new s(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 n({address:t,chainId:r})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),t}}),[n]),loginWithSiwe:te((async({message:r,signature:i,disableSignup:a})=>{try{let o;if(t.enabled&&"error"===t.status)throw new s(t.error,null,ce.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),o=await t.waitForResult());let n=await l({message:r,signature:i,captchaToken:o,disableSignup:a});return e?.onComplete?.({user:n,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),n}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),r}}),[l,t.status]),state:r}};function be(){let{signTransaction:e}=ie(h);return{signTransaction:e}}function Ne(e){let{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:n,linkTwitter:s,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:n,linkTwitter:s,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}=se();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:n,setIsNewUser:s,initializeWalletProxy:l}=se(),{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 s(d),n(!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:n}=se();return{signAuthorization:te((async(e,s)=>{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=s?.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,n))});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}=se(),n=p();return o("oAuthAuthorization",t),{reauthorize:e=>Ge(r,i,a,n,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}=se(),[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=ne();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}=se();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=se(),{signWithUserSigner:i}=q(),a=async({wallet:e,additional_signers:a})=>{let n=await t();if(!r||!n)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 n=await t();if(!r||!n)throw new le("User must be authenticated and have an embedded wallet to add a session signer.");let s=o.walletProxy??await o.initializeWalletProxy(15e3);if(!s)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("This embedded wallet does not support specifying signers. If signing is enabled in the dashboard, signer will default to that key. Otherwise, no signatures will be required for the wallet.");let t=Z({address:e,user:r}),a=ee({address:e,user:r});await o.recoverEmbeddedWallet({address:e}),await s.createDelegatedAction({accessToken:n,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 n=G(r,e);if(!n)throw new le("Address to remove signers from is not associated with current user.");$(n)?await a({wallet:n,additional_signers:[]}):await o.client.revokeDelegatedWallet();let s=await o.refreshSessionAndUser();if(!s)throw Error("Could not refresh user");return{user:s}}}})();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:n}=se();return{login:te((async i=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,ce.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:a,isNewUser:n,loginAccount:l,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:l})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||ce.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:a}},tt=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=se();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,Ne 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,be 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 +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",
|
|
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/custom_jwt_account/link",Sa="/api/v1/guest/authenticate",Ta="/api/v1/plugins/moonpay_on_ramp/sign",ma="/api/v1/funding/coinbase_on_ramp/init",wa="/api/v1/funding/coinbase_on_ramp/status",Ia="/api/v1/wallets/revoke",Da="/api/v1/users/me",Na="/api/v1/scan/transaction",Oa=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},La=a=>()=>{throw Error(a.trim())},ga=/*#__PURE__*/e({setAuthenticated:Oa,setUser:Oa,setIsNewUser:Oa,isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:Oa,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:Oa,initializeWalletProxy:Oa,getAuthMeta:Oa,getAuthFlow:Oa,closePrivyModal:Oa,openPrivyModal:Oa,connectWallet:Oa,initLoginWithWallet:Oa,loginWithWallet:Oa,initLoginWithFarcaster:Oa,loginWithFarcaster:Oa,loginWithCode:Oa,initLoginWithEmail:Oa,initLoginWithSms:Oa,initUpdateEmail:Oa,initUpdatePhone:Oa,resendEmailCode:Oa,resendSmsCode:Oa,initLoginWithHeadlessOAuth:Oa,loginWithHeadlessOAuth:Oa,crossAppAuthFlow:Oa,initLoginWithOAuth:Oa,loginWithOAuth:Oa,passkeyAuthState:{status:"initial"},setPasskeyAuthState:Oa,initSignupWithPasskey:Oa,signupWithPasskey:Oa,initLoginWithPasskey:Oa,loginWithPasskey:Oa,initLinkWithPasskey:Oa,linkWithPasskey:Oa,refreshSessionAndUser:Oa,walletProxy:null,createAnalyticsEvent:Oa,acceptTerms:Oa,getUsdTokenPrice:Oa,getUsdPriceForSol:Oa,getSplTokenMetadata:Oa,recoverEmbeddedWallet:Oa,updateWallets:Oa,fundWallet:Oa,openModal:Oa,setReadyToTrue:Oa,requestFarcasterSignerStatus:Oa,initLoginWithTelegram:Oa,loginWithTelegram:Oa,generateSiweMessage:Oa,generateSiweMessageForSmartWallet:Oa,loginWithSiwe:Oa,linkWithSiwe:Oa,linkSmartWallet:Oa,delegateWallet:Oa,revokeDelegatedWallets:Oa,exportSolanaWallet:Oa,connectCoinbaseSmartWallet:Oa,initiateAccountTransfer:Oa,emailOtpState:{status:"initial"},setEmailOtpState:Oa,smsOtpState:{status:"initial"},setSmsOtpState:Oa,siweState:{status:"initial"},setSiweState:Oa,oAuthState:{status:"initial"},setOAuthState:Oa,telegramAuthState:{status:"initial"},setTelegramAuthState:Oa,isHeadlessOAuthLoading:!1,isHeadlessSigning:Oa}),Ra=()=>s(ga);export{ma as $,X as A,i as B,oa as C,la as D,_ as E,h as F,v as G,Aa as H,ga as I,ha as J,va as K,Sa as L,u as M,n as N,pa as O,r as P,ca as Q,Ea as R,x as S,Y as T,I as U,g as V,z as W,k as X,ua as Y,Ia as Z,Ta as _,d as a,wa as a0,S as a1,T as a2,m as a3,w as a4,N as a5,O as a6,J as a7,da as a8,y as a9,D as aa,$ as ab,B as ac,L as ad,Da as ae,Na as af,ea as ag,aa as ah,Z as ai,c as aj,A as ak,E as al,p as am,C as an,P as ao,Oa as b,b as c,M as d,H as e,l as f,o as g,W as h,U as i,R as j,f as k,Q as l,q as m,La as n,j as o,F as p,_a as q,ra as r,na as s,ia as t,Ra as u,ta as v,sa as w,G as x,K as y,V as z};
|