@privy-io/react-auth 2.23.0 → 2.24.0-beta-20250829191935
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/extended-chains.js +1 -1
- package/dist/cjs/farcaster.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{internal-context-C3Ps4gAt.js → internal-context-B_aIJuQh.js} +1 -1
- package/dist/cjs/privy-provider-DvBetfj7.js +34 -0
- package/dist/cjs/{smart-wallets-DiLEwIKs.js → smart-wallets-BxzUj4XV.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/{use-sign-with-user-signer-L1_W0zce.js → use-sign-with-user-signer-mIruAdfm.js} +1 -1
- package/dist/cjs/{useActiveWallet-DEknGgdp.js → useActiveWallet-BI2cGlZO.js} +1 -1
- package/dist/cjs/{useFundWallet-BOm_c85i.js → useFundWallet-DIA0rzqo.js} +1 -1
- package/dist/dts/extended-chains.d.mts +2 -1
- package/dist/dts/extended-chains.d.ts +2 -1
- package/dist/dts/farcaster.d.mts +2 -1
- package/dist/dts/farcaster.d.ts +2 -1
- package/dist/dts/index.d.mts +9 -17
- package/dist/dts/index.d.ts +9 -17
- package/dist/dts/smart-wallets.d.mts +2 -1
- package/dist/dts/smart-wallets.d.ts +2 -1
- package/dist/dts/solana.d.mts +99 -16
- package/dist/dts/solana.d.ts +99 -16
- package/dist/dts/{types-cjyKPOmY.d.mts → types-zpHmPFW8.d.mts} +37 -1
- package/dist/dts/{types-cjyKPOmY.d.ts → types-zpHmPFW8.d.ts} +37 -1
- package/dist/dts/ui.d.mts +2 -1
- package/dist/dts/ui.d.ts +2 -1
- package/dist/dts/{useSolanaWallets-CZcmg0rm.d.mts → useSolanaWallets-Bnyf2wo3.d.mts} +1 -1
- package/dist/dts/{useSolanaWallets-CZcmg0rm.d.ts → useSolanaWallets-Bnyf2wo3.d.ts} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/extended-chains.mjs +1 -1
- package/dist/esm/farcaster.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{internal-context-D0EM1HLm.mjs → internal-context-qdNgTV5f.mjs} +1 -1
- package/dist/esm/privy-provider-CAS3yDsS.mjs +31 -0
- package/dist/esm/{smart-wallets-eeVPZj7Y.mjs → smart-wallets-DyGp_Lr1.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/{use-sign-with-user-signer-BWQ0PcRX.mjs → use-sign-with-user-signer-CpL9I6iB.mjs} +1 -1
- package/dist/esm/{useActiveWallet-CzofJJwe.mjs → useActiveWallet-DgjaLYuh.mjs} +1 -1
- package/dist/esm/{useFundWallet-YwYOhvEX.mjs → useFundWallet-Cd4d05ts.mjs} +1 -1
- package/package.json +9 -4
- package/dist/cjs/privy-provider-Q9EYyb3N.js +0 -34
- package/dist/esm/privy-provider-BOSSQASA.mjs +0 -31
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCoinbaseWalletSDK } from '@coinbase/wallet-sdk';
|
|
2
2
|
import { AppKit } from '@reown/appkit';
|
|
3
|
+
import { Rpc, SolanaRpcApi, RpcSubscriptions, SolanaRpcSubscriptionsApi } from '@solana/kit';
|
|
3
4
|
import { StandardWalletAdapter, Adapter, WalletError, MessageSignerWalletAdapterProps, WalletAdapterProps, SignerWalletAdapterProps } from '@solana/wallet-adapter-base';
|
|
4
5
|
import { ReactElement, ReactNode } from 'react';
|
|
5
6
|
import { Hex } from 'viem';
|
|
@@ -344,6 +345,10 @@ type BaseAccountSdkCreateParams = Parameters<typeof createBaseAccountSDK>[0];
|
|
|
344
345
|
type BaseAccountSdkType = ReturnType<typeof createBaseAccountSDK>;
|
|
345
346
|
type SetBaseAccountSdkType = (sdk: BaseAccountSdkType | undefined) => void;
|
|
346
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Type of all Solana chains supported by Privy.
|
|
350
|
+
*/
|
|
351
|
+
type SolanaChain = (typeof SOLANA_CHAINS)[number];
|
|
347
352
|
/**
|
|
348
353
|
* Helper type for defining a Standard Wallet with a union of Solana features.
|
|
349
354
|
*/
|
|
@@ -1737,6 +1742,32 @@ interface PrivyClientConfig {
|
|
|
1737
1742
|
uiConfig?: MoonpayUiConfig;
|
|
1738
1743
|
};
|
|
1739
1744
|
};
|
|
1745
|
+
/**
|
|
1746
|
+
* Configuration for Solana
|
|
1747
|
+
*/
|
|
1748
|
+
solana?: {
|
|
1749
|
+
/**
|
|
1750
|
+
* @solana/kit RPC configuration objects for each solana chain. This applies for solana standard wallet hooks like `useStandardSignMessage`,
|
|
1751
|
+
* `useStandardSignTransaction`, `useStandardSignAndSendTransaction`.
|
|
1752
|
+
*
|
|
1753
|
+
* @example
|
|
1754
|
+
* ```typescript
|
|
1755
|
+
* import {createSolanaRpc, createSolanaRpcSubscriptions} from '@solana/kit';
|
|
1756
|
+
*
|
|
1757
|
+
* const rpcs = {
|
|
1758
|
+
* 'solana:mainnet': {
|
|
1759
|
+
* rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
|
|
1760
|
+
* rpcSubscriptions: createSolanaRpcSubscriptions('wss://api.mainnet-beta.solana.com'),
|
|
1761
|
+
* blockExplorerUrl: 'https://explorer.solana.com',
|
|
1762
|
+
* },
|
|
1763
|
+
* }
|
|
1764
|
+
*/
|
|
1765
|
+
rpcs?: Partial<Record<SolanaChain, {
|
|
1766
|
+
rpc: Rpc<SolanaRpcApi>;
|
|
1767
|
+
rpcSubscriptions: RpcSubscriptions<SolanaRpcSubscriptionsApi>;
|
|
1768
|
+
blockExplorerUrl?: string;
|
|
1769
|
+
}>>;
|
|
1770
|
+
};
|
|
1740
1771
|
}
|
|
1741
1772
|
/**
|
|
1742
1773
|
* The data received from Telegram when the user is authenticated.
|
|
@@ -1957,6 +1988,11 @@ type AppConfig = {
|
|
|
1957
1988
|
};
|
|
1958
1989
|
fundingMethodConfig: NonNullable<PrivyClientConfig['fundingMethodConfig']>;
|
|
1959
1990
|
whatsAppEnabled: boolean;
|
|
1991
|
+
solanaRpcs: Record<SolanaChain, {
|
|
1992
|
+
rpc: Rpc<SolanaRpcApi>;
|
|
1993
|
+
rpcSubscriptions: RpcSubscriptions<SolanaRpcSubscriptionsApi>;
|
|
1994
|
+
blockExplorerUrl?: string;
|
|
1995
|
+
} | null>;
|
|
1960
1996
|
};
|
|
1961
1997
|
/** Privy's generated color palette.
|
|
1962
1998
|
* This will be generated, given a passed theme and accent color (from configuration),
|
|
@@ -2389,4 +2425,4 @@ type SessionSignerInput = {
|
|
|
2389
2425
|
policyIds?: string[];
|
|
2390
2426
|
}[];
|
|
2391
2427
|
|
|
2392
|
-
export { type
|
|
2428
|
+
export { type CrossAppProviderDetails as $, type ConnectedWalletMetadata as A, type BaseConnectedEthereumWallet as B, type ConnectedSolanaWallet as C, type PrivyClientConfig as D, type EthereumRpcRequestType as E, type FundingMethod as F, type ConnectorType as G, type HDWalletWithMetadata as H, type SetBaseAccountSdkType as I, type WalletListEntry as J, type AppConfig as K, type LoginMethod as L, type MfaMethod as M, type BaseConnectedWallet as N, type OAuthTokens as O, PrivyErrorCode as P, type ConnectWalletModalOptions as Q, type RuntimeLoginOverridableOptions as R, type SolanaTransactionReceipt as S, type LoginModalOptions as T, type User as U, type SetWalletRecoveryOptions as V, type Wallet as W, type SignTypedDataParams as X, type UnsignedTransactionRequest as Y, type FundWalletConfig as Z, type ConnectedWallet as _, type LinkedAccountWithMetadata as a, type Passkey as a$, type OAuthProviderType as a0, type MoonpaySignRequest as a1, type MoonpaySignResponse as a2, type SmartWalletConfig as a3, type SiwsMessageType as a4, type ExternalWalletMetadata as a5, type TelegramAuthResult as a6, type TelegramWebAppData as a7, type OAuthUserInfo as a8, type OAuthFlowState as a9, type LinkedIn as aA, type Apple as aB, type Tiktok as aC, type Line as aD, type Telegram as aE, type CrossAppAccount as aF, type LinkedAccountType as aG, type GoogleOAuthWithMetadata as aH, type TwitterOAuthWithMetadata as aI, type DiscordOAuthWithMetadata as aJ, type GithubOAuthWithMetadata as aK, type TiktokOAuthWithMetadata as aL, type LineOAuthWithMetadata as aM, type LinkedInOAuthWithMetadata as aN, type AppleOAuthWithMetadata as aO, type FarcasterWithMetadata as aP, type TelegramWithMetadata as aQ, type CrossAppAccountWithMetadata as aR, type PasskeyWithMetadata as aS, type Email as aT, type Phone as aU, type TransactionUIOptions as aV, type ContractUIOptions as aW, type NativeFundingConfig as aX, type MoonpayFundingConfig as aY, type PriceDisplayOptions as aZ, type Farcaster as a_, type LoginWithCode as aa, type OtpFlowState as ab, type PasskeyFlowState as ac, type SiweFlowState as ad, type BaseAccountSdkType as ae, type UnsignedTransactionRequestWithChainId as af, type BaseConnectedWalletType as ag, type SessionSignerInput as ah, type TelegramAuthFlowState as ai, type TypedMessage as aj, type MessageTypes as ak, type SmartWallet as al, type MoonpayConfig as am, type MoonpayCurrencyCode as an, type MoonpayPaymentMethod as ao, type Quantity as ap, type TransactionLog as aq, type TransactionReceipt as ar, type NonEmptyArray as as, type EmailWithMetadata as at, type PhoneWithMetadata as au, type WalletWithMetadata as av, type Google as aw, type Twitter as ax, type Discord as ay, type Github as az, type BaseConnectedSolanaWallet as b, type LoginMethodOrderOption as b0, type SiwsFlowState as b1, type UserRecoveryMethod as c, type SupportedSolanaTransaction as d, type SolanaCluster as e, type CreateWalletOptions as f, type LoginToFrame as g, type LoginToMiniApp as h, type SendTransactionModalUIOptions as i, type SignMessageModalUIOptions as j, type SolanaChain as k, type SolanaStandardWallet as l, type SolanaFundingConfig as m, SolanaWalletConnector as n, type PrivyFarcasterSignerInitResponse as o, type MfaSubmitArgs as p, type SolanaRpcRequestType as q, type EthereumRpcResponseType as r, type SolanaRpcResponseType as s, toSolanaWalletConnectors as t, type EIP1193Provider as u, type EntropyIdVerifier as v, type RequestArguments as w, WalletConnector as x, PrivyProxyProvider as y, type WalletClientType as z };
|
package/dist/dts/ui.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { R as RuntimeLoginOverridableOptions } from './types-
|
|
2
|
+
import { R as RuntimeLoginOverridableOptions } from './types-zpHmPFW8.js';
|
|
3
3
|
import { Hex } from 'viem';
|
|
4
4
|
import { Chain, Cluster } from '@privy-io/js-sdk-core';
|
|
5
5
|
import '@coinbase/wallet-sdk';
|
|
6
6
|
import '@reown/appkit';
|
|
7
|
+
import '@solana/kit';
|
|
7
8
|
import '@solana/wallet-adapter-base';
|
|
8
9
|
import 'react';
|
|
9
10
|
import '@privy-io/public-api';
|
package/dist/dts/ui.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { R as RuntimeLoginOverridableOptions } from './types-
|
|
2
|
+
import { R as RuntimeLoginOverridableOptions } from './types-zpHmPFW8.js';
|
|
3
3
|
import { Hex } from 'viem';
|
|
4
4
|
import { Chain, Cluster } from '@privy-io/js-sdk-core';
|
|
5
5
|
import '@coinbase/wallet-sdk';
|
|
6
6
|
import '@reown/appkit';
|
|
7
|
+
import '@solana/kit';
|
|
7
8
|
import '@solana/wallet-adapter-base';
|
|
8
9
|
import 'react';
|
|
9
10
|
import '@privy-io/public-api';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chain } from '@privy-io/js-sdk-core';
|
|
2
|
-
import { P as PrivyErrorCode, U as User, L as LoginMethod, a as LinkedAccountWithMetadata, B as BaseConnectedEthereumWallet, b as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, c as UserRecoveryMethod, S as SolanaTransactionReceipt, d as SupportedSolanaTransaction, O as OAuthTokens, F as FundingMethod, e as SolanaCluster, C as ConnectedSolanaWallet, f as CreateWalletOptions } from './types-
|
|
2
|
+
import { P as PrivyErrorCode, U as User, L as LoginMethod, a as LinkedAccountWithMetadata, B as BaseConnectedEthereumWallet, b as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, c as UserRecoveryMethod, S as SolanaTransactionReceipt, d as SupportedSolanaTransaction, O as OAuthTokens, F as FundingMethod, e as SolanaCluster, C as ConnectedSolanaWallet, f as CreateWalletOptions } from './types-zpHmPFW8.js';
|
|
3
3
|
import { MouseEvent } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chain } from '@privy-io/js-sdk-core';
|
|
2
|
-
import { P as PrivyErrorCode, U as User, L as LoginMethod, a as LinkedAccountWithMetadata, B as BaseConnectedEthereumWallet, b as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, c as UserRecoveryMethod, S as SolanaTransactionReceipt, d as SupportedSolanaTransaction, O as OAuthTokens, F as FundingMethod, e as SolanaCluster, C as ConnectedSolanaWallet, f as CreateWalletOptions } from './types-
|
|
2
|
+
import { P as PrivyErrorCode, U as User, L as LoginMethod, a as LinkedAccountWithMetadata, B as BaseConnectedEthereumWallet, b as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, c as UserRecoveryMethod, S as SolanaTransactionReceipt, d as SupportedSolanaTransaction, O as OAuthTokens, F as FundingMethod, e as SolanaCluster, C as ConnectedSolanaWallet, f as CreateWalletOptions } from './types-zpHmPFW8.js';
|
|
3
3
|
import { MouseEvent } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAbstractClient as e}from"@abstract-foundation/agw-client";import{getBatchTransactionObject as t}from"@abstract-foundation/agw-client/actions";import{hexToNumber as r,createWalletClient as o,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,g as l,c as p}from"./use-sign-with-user-signer-
|
|
1
|
+
import{createAbstractClient as e}from"@abstract-foundation/agw-client";import{getBatchTransactionObject as t}from"@abstract-foundation/agw-client/actions";import{hexToNumber as r,createWalletClient as o,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,g as l,c as p}from"./use-sign-with-user-signer-CpL9I6iB.mjs";import{q as d,y as m,f as u,a as h,b1 as y,b2 as g,ba as I,z as f}from"./privy-provider-CAS3yDsS.mjs";import{u as v}from"./internal-context-qdNgTV5f.mjs";import{g as w}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import{c as C}from"./smart-wallets-DyGp_Lr1.mjs";import"react";import"react/jsx-runtime";import"mipd";import"react-device-detect";import"viem/utils";import"@privy-io/js-sdk-core";import"./paths-DCwuPDUk.mjs";import"ofetch";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/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"zustand";import"@headlessui/react";import"lucide-react";import"@walletconnect/ethereum-provider";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";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/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/outline/ClockIcon";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:P,openPrivyModal:S,chains:b,appId:A,rpcConfig:W,client:M}=v(),k=d(),{wallets:F}=m(),{setModalData:q}=u(),x=l(T),_=!!x&&p(x),E=async(t=s.id)=>{let c=w(F);if(!c)throw Error("No connected wallet found");let l="string"==typeof t?r(t):t;if(![s.id,2741].includes(l))throw Error("Error, only Abstract chains are supported");let p=b.find((e=>e.id===l));if(!p)throw Error("Chain not configured");await c.switchChain(p.id);let d=await c.getEthereumProvider(),m=o({account:c.address,transport:n(d)}),u=a({address:c.address,signMessage:m.signMessage,signTransaction:m.signTransaction,signTypedData:m.signTypedData});return await e({chain:p,transport:i(f(p,W,A)),publicTransport:i(f(p,W,A)),signer:u})};return{signMessage:async({message:e},t)=>{let r=await E(t);return new Promise((async(t,o)=>{let{entropyId:n,entropyIdVerifier:i}=h(T);P.current=!0,q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:_,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:y,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>r.signMessage({message:e}),onSuccess:e=>t(e),onFailure:o,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))},signTypedData:async(e,t)=>{let r=await E(t);return new Promise((async(t,o)=>{P.current=!0;let{entropyId:n,entropyIdVerifier:i}=h(T);q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:_,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:y,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>t(e),onFailure:o,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))},sendTransaction:async e=>{let r=await E(e.chainId),o=[],n="calls"in e&&void 0!==e.calls;return o=n?[...e.calls]:[e],new Promise((async(i,a)=>{P.current=!0;let{entropyId:s,entropyIdVerifier:c}=h(T);q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:_,entropyId:s,entropyIdVerifier:c,onCompleteNavigateTo:I,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:o,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 o=n?t(r.account.address,e):e;return await r.prepareAbstractTransactionRequest(o)},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let o=n?t(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(o);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}}}),S(g)})).finally((()=>{P.current=!1}))},signTransaction:async e=>{let r=await E(e.chainId),o=[],n="calls"in e&&void 0!==e.calls;return o=n?[...e.calls]:[e],new Promise((async(i,a)=>{P.current=!0;let{entropyId:s,entropyIdVerifier:c}=h(T);q({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:_,entropyId:s,entropyIdVerifier:c,onCompleteNavigateTo:I,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:o,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 o=n?t(r.account.address,e):e;return await r.prepareAbstractTransactionRequest(o)},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let o=n?t(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(o);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:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:async()=>{let o=n?t(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(o);return r.signTransaction(i)},onSuccess:e=>i(e.hash),onFailure:a,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))}}}export{T as useAbstractSmartWallets};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as r}from"react";import{create as e,rawSign as t}from"@privy-io/js-sdk-core";import{u as a}from"./internal-context-
|
|
1
|
+
import{useMemo as r}from"react";import{create as e,rawSign as t}from"@privy-io/js-sdk-core";import{u as a}from"./internal-context-qdNgTV5f.mjs";import{u as i,a as s,h as n,c as o}from"./use-sign-with-user-signer-CpL9I6iB.mjs";import"viem";const h=()=>{let{refreshSessionAndUser:t,privy:i}=a();return r((()=>({async createWallet(r){let a=await e(i,{request:{chain_type:r.chainType}}),s=await t();if(!s)throw Error("User must be authenticated before creating a Privy wallet");return{user:s,wallet:a}}})),[t,i])},u=()=>{let{user:e}=i(),{privy:h}=a(),{signWithUserSigner:u}=s();return r((()=>({async signRawHash({address:r,chainType:a,hash:i}){if(!e)throw Error("User must be authenticated before signing");let s=n(e,a).filter((r=>o(r))).find((e=>e.address===r));if(!s)throw Error("Wallet not found");let d=await t(h,u,{wallet_id:s.id,params:{hash:i}});if(d.data&&"signature"in d.data&&"hex"===d.data.encoding)return{signature:d.data.signature};throw Error("Failed to sign")}})),[h,u,e])};export{h as useCreateWallet,u as useSignRawHash};
|
package/dist/esm/farcaster.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as t}from"react";import{F as i}from"./frame-DMd4vZ0H.mjs";import{P as e}from"./paths-DCwuPDUk.mjs";import{u as a}from"./internal-context-
|
|
1
|
+
import{useCallback as t}from"react";import{F as i}from"./frame-DMd4vZ0H.mjs";import{P as e}from"./paths-DCwuPDUk.mjs";import{u as a}from"./internal-context-qdNgTV5f.mjs";import"ofetch";const n=()=>{let{client:n,setAuthenticated:r,setUser:s}=a();return{initLoginToMiniApp:t((async()=>{let t=new i;if(!n)throw new e("Must initialize Privy client first.");return n.startAuthFlow(t),await t.init()}),[n]),loginToMiniApp:t((async({message:t,signature:a})=>{if(!n)throw new e("Must initialize Privy client first.");if(!(n.authFlow instanceof i))throw new e("Must initialize Farcaster Mini App flow first.");let o=(t=>{let i=t.match(/farcaster:\/\/fid\/(\d+)/);return i&&i[1]?parseInt(i[1],10):null})(t);if(!o)throw new e("Invalid message format; could not parse Farcaster ID.");n.authFlow.setAuthData({message:t,signature:a,fid:o});let{user:l}=await n.authenticate();return l&&(s(l),r(!0)),l}),[n,s,r])}},r=()=>{let{initLoginToMiniApp:i,loginToMiniApp:e}=n();return{initLoginToFrame:t((async()=>await i()),[i]),loginToFrame:t((async({message:t,signature:i})=>await e({message:t,signature:i})),[e])}};export{r as useLoginToFrame,n as useLoginToMiniApp};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,a as t,u as r,b as s,c as o,C as n,d as i,s as l,U as d,e as h,f as w,t as p,h as y,M as m,i as A,A as f,j as k,k as C,L as v,l as E,I as S,T,S as U,B as W,P as I,E as P,m as M,n as F,o as H,p as L,q as x,G as D,W as q,r as z,v as j,w as B,x as G,y as J,z as ee,D as te,F as re,H as ae,J as se}from"./privy-provider-BOSSQASA.mjs";export{O as Captcha,Q as ConnectorManager,V as EthereumWalletConnector,a9 as LoginModal,a2 as PrivyClient,K as PrivyProvider,a1 as VERSION,R as WalletConnector,$ as errorIndicatesMaxMfaRetries,a0 as errorIndicatesMfaTimeout,_ as errorIndicatesMfaVerificationFailed,N as getAccessToken,a6 as useCreateWallet,a3 as useIdentityToken,a8 as useImportWallet,a4 as useLogout,Y as useMfa,Z as useMfaEnrollment,aa as useMigrateWallets,X as usePrivy,a5 as useRegisterMfaListener,a7 as useSolanaWallets}from"./privy-provider-BOSSQASA.mjs";import{useCallback as oe,useMemo as ne,useEffect as ie,useContext as le,useState as ce,useRef as ue}from"react";import{P as de,a as he}from"./paths-DCwuPDUk.mjs";import{u as we,I as pe}from"./internal-context-D0EM1HLm.mjs";import{u as ye,P as me,g as ge,a as Ae,b as fe,c as ke}from"./use-sign-with-user-signer-BWQ0PcRX.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-CzofJJwe.mjs";import{F as Ce}from"./frame-DMd4vZ0H.mjs";import{MfaAuthTotpVerify as ve,MfaAuthPasskeyInit as Ee,MfaAuthPasskeyVerify as Se,MfaAuthTotpInit as Te,MfaAuthTotpEnroll as Ue,MfaAuthTotpUnenroll as Re,MfaAuthPasskeyEnrollment as We}from"@privy-io/public-api";import{jsxs as Ie,Fragment as be,jsx as Pe}from"react/jsx-runtime";import Me from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Ne from"@heroicons/react/24/outline/ShieldCheckIcon";import{zeroAddress as _e,getAddress as Oe,createWalletClient as Fe,http as He,parseSignature as Le}from"viem";import{hashAuthorization as xe}from"viem/utils";import{getWallet as De,updateWallet as Ke,generateAuthorizationSignature as qe,PrivyClientError as ze}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{toAccount as je}from"viem/accounts";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/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"zustand";import"@headlessui/react";import"lucide-react";import"@walletconnect/ethereum-provider";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";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/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const Ve=()=>{let{user:r}=ye(),{walletProxy:a}=we();return{recover:oe((async s=>{if(!a)throw Error("Wallet proxy is not ready");let o=await e();if(!r||!o)throw new de("User must be logged in before attempting to modify the recovery method.");let{entropyId:n,entropyIdVerifier:i}=t(r);try{await a.recover({entropyId:n,entropyIdVerifier:i,accessToken:o,...s})}catch{throw new de("Unable to recover wallets")}}),[a,r])}},Be=()=>{let{client:e,setAuthenticated:t,setUser:r}=we();return ne((()=>({init:async()=>{if(!e)throw new de("Must initialize Privy client first.");let t=new Ce;return e.startAuthFlow(t),await t.init()},login:async({fid:a,message:s,signature:o})=>{if(!e)throw new de("Must initialize Privy client first.");if(!(e.authFlow instanceof Ce))throw new de("Must initialize Farcaster Mini App flow first.");e.authFlow.setAuthData({message:s,signature:o,fid:a});let{user:n}=await e.authenticate();if(!n)throw new de("Failed to login with Farcaster V2");return r(n),t(!0),{user:n}}})),[e,r,t])},Ge=e=>{r("login",e);let t=s(),a=o(),{ready:c,user:u}=ye(),{initLoginWithHeadlessOAuth:d,loginWithHeadlessOAuth:h,oAuthState:w,setOAuthState:p,isHeadlessOAuthLoading:y}=we(),m=oe((async e=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);return await d(e.provider,t.token,e.disableSignup)}catch(e){throw p({status:"error",error:e}),e}}),[d,t]),g=oe((async()=>{let e=i();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 p({status:"error",error:e}),e}try{return await h(e)}catch(e){throw p({status:"error",error:e}),e}finally{l()}}),[h]);return ie((()=>{let e=i();c&&a&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&g().catch((()=>{}))}),[c,a]),{initOAuth:m,loading:y,state:w}},$e=e=>{let t=s(),{emailOtpState:r,setEmailOtpState:a,initLoginWithEmail:o,loginWithCode:i}=we();return{sendCode:oe((async({email:r,disableSignup:s})=>{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,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await o({email:r,captchaToken:e,disableSignup:s,withPrivyUi:!1})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[o]),loginWithCode:oe((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:s,wasAlreadyAuthenticated:o,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:o,loginMethod:"email",loginAccount:l})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[i,t.status]),state:r}},Qe=e=>{let t=s(),{initSignupWithPasskey:r,signupWithPasskey:a,passkeyAuthState:o,setPasskeyAuthState:i}=we();return{signupWithPasskey:oe((async()=>{try{let s;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),s=await t.waitForResult()),await r({captchaToken:s,withPrivyUi:!1});let{user:o,isNewUser:i,wasAlreadyAuthenticated:l,loginAccount:c}=await a();e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR),t}}),[a,t.status]),state:o}},Xe=e=>{let t=s(),{initLoginWithPasskey:r,loginWithPasskey:a,passkeyAuthState:o,setPasskeyAuthState:i}=we();return{loginWithPasskey:oe((async s=>{try{let o;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),o=await t.waitForResult()),await r({captchaToken:o,withPrivyUi:!1});let{user:i,isNewUser:l,wasAlreadyAuthenticated:c,loginAccount:u}=await a(s);e?.onComplete?.({user:i,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(s){throw i({status:"error",error:s}),e?.onError?.(s.privyErrorCode||he.UNKNOWN_AUTH_ERROR),s}}),[a,t.status]),state:o}},Je=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:s}=we();return{linkWithPasskey:oe((async()=>{try{await t();let a=await r();if(!a)throw Error("Error, user not found");let s=a.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:a,linkMethod:"passkey",linkedAccount:s})}catch(t){throw s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:a}},Ye=e=>{let t=s(),{smsOtpState:r,setSmsOtpState:a,initLoginWithSms:o,loginWithCode:i}=we();return{sendCode:oe((async({phoneNumber:r,disableSignup:s})=>{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,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await o({phoneNumber:r,captchaToken:e,disableSignup:s,withPrivyUi:!1})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[o]),loginWithCode:oe((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:s,wasAlreadyAuthenticated:o,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:o,loginMethod:"sms",loginAccount:l})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[i,t.status]),state:r}},Ze=e=>{let{connectOrCreateWallet:t}=ye();return r("connectOrCreateWallet",e),{connectOrCreateWallet:t}},et=e=>{let t=s(),{siweState:r,setSiweState:a,linkWithSiwe:o,generateSiweMessage:i}=we();return{generateSiweMessage:oe((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await i({address:t,chainId:r}).then((e=>e))}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[i]),linkWithSiwe:oe((async({signature:r,message:s,chainId:i,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);let{user:a,linkedAccount:u}=await o({message:s,signature:r,chainId:i,walletClientType:l,connectorType:c});u&&e?.onSuccess?.({user:a,linkMethod:"siwe",linkedAccount:u})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[o,t.status]),state:r}},tt=e=>{let t=s(),{siweState:r,setSiweState:a,client:o,generateSiweMessage:i,loginWithSiwe:l}=we();return{generateSiweNonce:oe((async r=>{try{let e;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),a({status:"generating-message"});let s=await o.generateSiweNonce({address:r?.address,captchaToken:e});return a({status:"awaiting-signature"}),s}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[o,t]),generateSiweMessage:oe((async({address:r,chainId:s})=>{try{let e;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({address:r,chainId:s,captchaToken:e})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[i,t]),loginWithSiwe:oe((async({message:r,signature:s,disableSignup:o})=>{try{let a;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult());let i=await l({message:r,signature:s,captchaToken:a,disableSignup:o});return e?.onComplete?.({user:i,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),i}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[l,t.status]),state:r}},rt=e=>{let t=s(),{siwsState:r,setSiwsState:a,generateSiwsMessage:o,loginWithSiws:i}=we();return{generateSiwsMessage:oe((async({address:r})=>{try{let e;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await o({address:r,captchaToken:e})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[o,t]),loginWithSiws:oe((async({message:r,signature:s,disableSignup:o})=>{try{let a;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult());let l=await i({message:r,signature:s,captchaToken:a,disableSignup:o});return e?.onComplete?.({user:l,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siws",loginAccount:null}),l}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[i,t.status]),state:r}},at=e=>{let t=s(),{siwsState:r,setSiwsState:a,generateSiwsMessage:o,linkWithSiws:i}=we();return{generateSiwsMessage:oe((async({address:r})=>{try{let e;if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await o({address:r,captchaToken:e})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"siws"}),r}}),[o,t,a,e]),linkWithSiws:oe((async({signature:r,message:s,walletClientType:o,connectorType:l})=>{try{if(t.enabled&&"error"===t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);let{user:a,linkedAccount:c}=await i({message:s,signature:r,walletClientType:o,connectorType:l});return c&&e?.onSuccess?.({user:a,linkMethod:"siws",linkedAccount:c}),{user:a,linkedAccount:c}}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"siws"}),r}}),[i,t.status,a,e]),state:r}};function st(){let{signTransaction:e}=le(me);return{signTransaction:e}}function ot(e){let{linkEmail:t,linkPhone:a,linkWallet:s,linkGoogle:o,linkApple:n,linkTwitter:i,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkLine:h,linkSpotify:w,linkInstagram:p,linkTelegram:y,linkFarcaster:m,linkPasskey:g}=le(me);return r("linkAccount",e),{linkEmail:t,linkPhone:a,linkWallet:s,linkGoogle:o,linkApple:n,linkTwitter:i,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkLine:h,linkSpotify:w,linkInstagram:p,linkFarcaster:m,linkTelegram:y,linkPasskey:g}}function nt(e){let{updateEmail:t,updatePhone:a}=le(me);return r("update",e),{updateEmail:t,updatePhone:a}}const it=e=>{let{user:t}=ye(),{loginWithCode:r,emailOtpState:a,setEmailOtpState:s,client:o,inProgressAuthFlowRef:n,inProgressLoginOrLinkMethodRef:i}=we();return{state:a,sendCode:oe((async({newEmailAddress:r})=>{try{if(!t?.email)throw Error("User is required to have an email address to update it.");let e=new d(t.email.address,r);o.startAuthFlow(e),await e.sendCodeEmail({withPrivyUi:!1})}catch(r){s({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[t?.email]),verifyCode:oe((async({code:a})=>{try{if(!t?.email)throw Error("User is required to have an email address to update it.");n.current="update",i.current="email";let{user:s,linkedAccount:o}=await r(a);return e?.onSuccess?.({user:s,updateMethod:"email",updatedAccount:o}),{user:s}}catch(a){s({status:"error",error:a}),e?.onError?.(a.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[t?.email])}},lt=()=>{let{connectCoinbaseSmartWallet:e}=we();return{connectCoinbaseSmartWallet:e}},ct=()=>{let{connectBaseAccount:e}=we();return{connectBaseAccount:e}},ut=()=>{let{baseAccountSdk:e}=we();return{baseAccountSdk:e}},dt=()=>{let{setModalData:e}=h(),{openModal:t,privy:r,closePrivyModal:a}=we(),{user:s}=ye();return ne((()=>({verify:async({standalone:o=!0}={standalone:!0})=>new Promise(((n,i)=>s?0===s.mfaMethods.length?n():(e((e=>({...e,mfaVerify:{onSuccess:async()=>{o?await a({shouldCallAuthOnSuccess:!1,isSuccess:!0}):w.setState({inProgressMfaFlow:void 0}),n()},onFailure:async e=>{o?await a({shouldCallAuthOnSuccess:!1,isSuccess:!1}):w.setState({inProgressMfaFlow:void 0}),i(e)},sendSmsCode:async()=>{throw Error("Not enabled")},verifySmsCode:async()=>{throw Error("Not enabled")},verifyTotpCode:async e=>{await r.fetchPrivyRoute(ve,{body:{code:e}})},generateOptions:async()=>p((await r.fetchPrivyRoute(Ee,{body:{}})).options),verifyPasskey:async e=>{let t=await import("@simplewebauthn/browser"),a=await t.startAuthentication(e);await r.fetchPrivyRoute(Se,{body:{authenticator_response:y(a)}})}}}))),void(o?t(m):w.setState({inProgressMfaFlow:"auth"}))):i(Error("Must be logged in to verify MFA"))))})),[r,e,t,a])},ht={component:()=>{let{user:e,ready:t}=ye(),{app:r,data:a,onUserCloseViaDialogOrKeybindRef:s}=h(),[o,n]=ce(null),[i,l]=ce(null),[c,u]=ce(null),[d,w]=ce(!1),[p,y]=ce(!1),[m,g]=ce(),R=async()=>{m?b(m):e?await N({user:e}):b(Error("Must be logged in to manage MFA")),setTimeout((()=>{n(null),l(null)}),500)};if(s.current=R,!a?.mfaEnroll)throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:b,onSuccess:N,mfaMethods:_,verify:O,generateTotpSecret:H,enrollTotp:L,unenrollTotp:x,enrollPasskey:D}=a.mfaEnroll,K=e?.mfaMethods.includes("sms"),q=e?.mfaMethods.includes("totp"),z=e?.mfaMethods.includes("passkey"),j=!!e?.phone,V=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function B(){n(null),l(null),g(void 0)}async function G(e=V){try{g(void 0),y(!0);let t=await D(e);return await N({user:t})}catch(e){g(e)}finally{y(!1),w(!1)}}if(!t||!e||!r)/*#__PURE__*/return Ie(be,{children:[/*#__PURE__*/Pe(A,{onClose:R},"header"),/*#__PURE__*/Pe(f,{children:/*#__PURE__*/Pe(k,{})}),/*#__PURE__*/Pe(C,{children:/*#__PURE__*/Pe(v,{})}),/*#__PURE__*/Pe(E,{})]});if("sms"===o)return null;if("totp"===o)/*#__PURE__*/return Ie(be,{children:[/*#__PURE__*/Pe(A,{backFn:B,onClose:R},"header"),/*#__PURE__*/Pe(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/Pe(Me,{})}),/*#__PURE__*/Pe(T,{children:"Remove authenticator app verification?"}),/*#__PURE__*/Ie(U,{children:["MFA adds an extra layer of security to your ",r?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/Pe(W,{children:/*#__PURE__*/Pe(I,{$warn:!0,onClick:async function(){try{g(void 0),y(!0);let e=await x();return await N({user:e})}catch(e){g(e)}finally{y(!1),n(null)}},loading:p,children:"Remove"})}),/*#__PURE__*/Pe(E,{})]});if("passkey"===o){let e=a.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return Ie(be,{children:[/*#__PURE__*/Pe(A,{backFn:B,onClose:R},"header"),/*#__PURE__*/Pe(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/Pe(Me,{})}),/*#__PURE__*/Pe(T,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/Pe(U,{children:e?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/Pe(W,{children:/*#__PURE__*/Pe(I,{$warn:!0,onClick:async function(){try{g(void 0),y(!0);let e=await D([]);return await N({user:e})}catch(e){g(e)}finally{y(!1),n(null)}},loading:p,children:"Remove"})}),/*#__PURE__*/Pe(E,{})]})}return 0!==_.length||K||q||z?"sms"===i?null:"totp"===i&&c?/*#__PURE__*/Pe(P,{onClose:R,onReset:B,submitEnrollmentWithTotp:e=>async function(e){try{g(void 0),y(!0);let t=await L(e);return await N({user:t})}catch(e){g(e)}finally{y(!1),n(null)}}(e.mfaCode),error:m,totpInfo:{...c,appName:r?.name||"Privy"}}):"passkey"===i?/*#__PURE__*/Pe(M,{onReset:B,onClose:R,submitEnrollmentWithPasskey:G}):/*#__PURE__*/Pe(F,{showIntro:!1,userMfaMethods:e.mfaMethods,appMfaMethods:r.mfa.methods,userHasAuthSms:j,onBackToIntro:()=>{},handleSelectMethod:async function(e){g(void 0);try{await O()}catch(e){return void g(e)}return"totp"===e?(l(e),u(null),void H().then((({totpSecret:e,totpAuthUrl:t})=>{u({authUrl:t,secret:e})})).catch((()=>{u(null),B()}))):"passkey"===e&&1===V.length?await G():void l(e)},isTotpLoading:"totp"===i&&!c,isPasskeyLoading:d,error:m,onClose:R,setRemovingMfaMethod:async function(e){g(void 0);try{await O()}catch(e){return void g(e)}n(e)}}):/*#__PURE__*/Ie(be,{children:[/*#__PURE__*/Pe(A,{onClose:R},"header"),/*#__PURE__*/Pe(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/Pe(Ne,{})}),/*#__PURE__*/Pe(T,{children:"Add more security"}),/*#__PURE__*/Ie(U,{children:[r?.name," does not have any verification methods enabled."]}),/*#__PURE__*/Pe(W,{children:/*#__PURE__*/Pe(I,{onClick:R,children:"Close"})}),/*#__PURE__*/Pe(E,{})]})}},wt=()=>{let e=H(),{setModalData:t}=h(),{verify:r}=dt(),{openModal:a,privy:s,closePrivyModal:o,refreshSessionAndUser:n,setUser:i}=we();return ne((()=>({enroll:async()=>new Promise(((l,c)=>{t({mfaEnroll:{onSuccess:async e=>{await o({shouldCallAuthOnSuccess:!1,isSuccess:!0}),l(e)},onFailure:async e=>{await o({shouldCallAuthOnSuccess:!1,isSuccess:!1}),c(e)},verify:()=>r({standalone:!1}),shouldUnlinkOnUnenrollMfa:!0,mfaMethods:e.mfa.methods,sendSmsCode:async()=>{throw Error("Not enabled")},enrollSms:async()=>{throw Error("Not enabled")},unenrollSms:async()=>{throw Error("Not enabled")},generateTotpSecret:async()=>await s.fetchPrivyRoute(Te,{body:{}}),enrollTotp:async e=>{await s.fetchPrivyRoute(Ue,{body:{code:e}});let t=await n();return i(t),t},unenrollTotp:async()=>{await s.fetchPrivyRoute(Re,{body:{}});let e=await n();return i(e),e},enrollPasskey:async e=>{await s.fetchPrivyRoute(We,{body:{credential_ids:e,remove_for_login:!0}});let t=await n();return i(t),t}}}),a(ht)}))})),[s,t,a,o])},pt=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:a,sendTransactionWithCrossAppWallet:s,signTransactionWithCrossAppWallet:o}=ye();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:r,signTypedData:a,sendTransaction:s,signTransaction:o}};function yt(e){let{sendTransaction:t}=le(me);return r("sendTransaction",e),{sendTransaction:t}}function mt(e){let{setWalletPassword:t}=le(me);return r("setWalletPassword",e),{setWalletPassword:t}}function gt(){let e=H(),t=L(),{client:r,setUser:a,setAuthenticated:s,setIsNewUser:o,initializeWalletProxy:n}=we(),{create:i}=x();return{createGuestAccount:async()=>{if(!e.id||!r)throw Error("SDK not yet ready");r.startAuthFlow(new D(e.id));try{let l=await r.authenticate(),c=l.user,u=l.isNewUser??!1;if(!c)throw new de("Unable to authenticate guest account");let d=await r.getAccessToken(),h=await n(q);if(d&&h)try{let t=z(c,e.embeddedWallets.ethereum.createOnLogin),r=j(c,e.embeddedWallets.solana.createOnLogin);t&&r?(c=(await i({chainType:"ethereum",latestUser:c})).user,c=(await i({chainType:"solana",latestUser:c})).user):r?c=(await i({chainType:"solana",latestUser:c})).user:t?c=(await i({chainType:"ethereum",latestUser:c})).user:a(c)}catch(e){a(c),console.warn("Unable to create embedded wallet for guest account")}return o(u),s(!0),t("login","onComplete",{user:c,isNewUser:u,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),c}catch(e){throw t("login","onError",e.privyErrorCode||he.UNKNOWN_AUTH_ERROR),e}}}}function At(e){let{setWalletRecovery:t}=le(me);return r("setWalletRecovery",e),{setWalletRecovery:t}}function ft(e){let{signMessage:t}=le(me);return r("signMessage",e),{signMessage:t}}const kt=()=>{let{ready:e,wallets:t}=B(),{user:r}=ye(),{rpcConfig:a,chains:s,appId:o}=we();return{signAuthorization:oe((async(n,i)=>{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=i?.address??ge(r)?.address??_e,u=t.find((e=>Oe(e.address)===Oe(c)));if(!u)throw Error("Signing wallet not found.");let d=n.chainId??Number(u.chainId.split(":")[1]);if(0===d)l={chainId:0,address:n.contractAddress,nonce:n.nonce??0};else{let e=s.find((e=>e.id===d));if(!e)throw Error("Error, chain not configured in PrivyProvider config");let t=Fe({account:c,chain:e,transport:He(G(e,a,o))});l=await t.prepareAuthorization({...n})}let h=await u.getEthereumProvider(),w=await h.request({method:"secp256k1_sign",params:[xe(l)]});return{...l,...Le(w)}}),[e,t,r,s])}},Ct=kt;function vt(e){let{signTypedData:t}=le(me);return r("signTypedData",e),{signTypedData:t}}const Et=()=>{let{isModalOpen:e}=le(me);return{isOpen:e}};function St(e){let{getAccessToken:t}=le(me);return r("accessToken",e),{getAccessToken:t}}function Tt(e){let{authenticated:t,user:a}=ye(),{initLoginWithOAuth:s}=we(),o=L();return r("oAuthAuthorization",e),{reauthorize:e=>Ut(t,a,s,o,e.provider)}}let Ut=async(e,t,r,a,s)=>{if(!e)throw a("linkAccount","onError",he.MUST_BE_AUTHENTICATED,{linkMethod:s}),new de("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(s))))throw new de(`OAuth account of type ${s} not linked to the account.`);await r(s)};function Rt(e){let{client:t}=we(),[r,a]=ce({status:"initial"});return{linkWithCustomJwt:oe((async r=>{try{a({status:"initial"}),t.startAuthFlow(new J(r)),a({status:"loading"});let{user:s}=await t.link();if(!s)throw Error("Error, user not found");let o=s.linkedAccounts.filter((e=>"custom_auth"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())).at(0);return a({status:"done"}),e?.onSuccess?.({user:s,linkMethod:"custom",linkedAccount:o}),{user:s}}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"custom"}),r}}),[t.startAuthFlow,t.link]),state:r}}const Wt=e=>{let t=ee();return r("customAuth",e),{status:t}};function It({isAuthenticated:e,isLoading:t,...r}){let a=ue();ie((()=>{t||a.current?.()}),[e,t]);let s=oe((e=>(a.current=e,()=>{a.current=void 0})),[]);return te({...r,subscribe:s})}function bt(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=ye();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}const Pt=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=we();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Mt=()=>{let{addSessionSignersInternal:e,removeSessionSignersInternal:t}=(()=>{let{user:e}=ye(),t=we(),{signWithUserSigner:r}=Ae(),a=async({wallet:a,additional_signers:s})=>{let o=await t.client.getAccessToken();if(!e||!o)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!a.id)throw new de("Wallet to add signers to must have ID on server");if(!t.walletProxy)throw new de("Wallet proxy not initialized.");await Ke(t.privy,{wallet_id:a.id},r,{additional_signers:s})};return{addSessionSignersInternal:async({address:r,signers:s})=>{let o=await t.client.getAccessToken();if(!e||!o)throw new de("User must be authenticated and have an embedded wallet to add a session signer.");let n=t.walletProxy??await t.initializeWalletProxy(15e3);if(!n)throw new de("Wallet proxy not initialized.");let i=fe(e,r);if(!i)throw new de("Address to add signers too is not associated with current user.");if(ke(i)){if(0===s.length)throw new de("Must specify at least one signer to add.");let e=[...(await De(t.privy,{wallet_id:i.id})).additional_signers,...re(s)];await a({wallet:i,additional_signers:e})}else{if(i.delegated)return{user:e};if(s.length>0)throw new de("Specifying signers in addSessionSigners is only supported for TEE execution and this app uses On-device execution. Pass an empty array for signers instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let a=ae({address:r,user:e}),l=se({address:r,user:e});await t.recoverEmbeddedWallet({address:r}),await n.createDelegatedAction({accessToken:o,rootWallet:l,delegatedWallets:[a]})}let l=await t.refreshSessionAndUser();if(!l)throw Error("Could not refresh user");return{user:l}},removeSessionSignersInternal:async({address:r})=>{let s=await t.client.getAccessToken();if(!e||!s)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!(t.walletProxy??await t.initializeWalletProxy(15e3)))throw new de("Wallet proxy not initialized.");let o=fe(e,r);if(!o)throw new de("Address to remove signers from is not associated with current user.");ke(o)?await a({wallet:o,additional_signers:[]}):await t.client.revokeDelegatedWallet();let n=await t.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})}},Nt=()=>{let{signWithUserSigner:e}=Ae();return ne((()=>({async generateAuthorizationSignature(t){let{signature:r}=await qe(e,t);return{signature:r}}})),[e])},_t=()=>{let{setUser:e,client:t}=le(pe),{user:r}=le(me);return{user:r,refreshUser:oe((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},Ot=e=>{let t=s(),{initLoginWithTelegram:r,loginWithTelegram:a,telegramAuthState:o,setTelegramAuthState:i}=we();return{login:oe((async s=>{try{if(t.enabled&&"success"!==t.status)throw new n(t.error,null,he.CAPTCHA_FAILURE);await r(t.token,s?.disableSignup);let{user:o,isNewUser:i,loginAccount:l,wasAlreadyAuthenticated:c}=await a({intent:"login"});e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:l})}catch(s){throw i({status:"error",error:s}),e?.onError?.(s.privyErrorCode||he.UNKNOWN_AUTH_ERROR),s}}),[r,a,t]),state:o}},Ft=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=we();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}},Ht=async({wallet:e})=>{let t=await e.getEthereumProvider();return je({address:e.address,sign:async({hash:r})=>{if("privy"!==e.walletClientType)throw new ze({error:"Unprefixed signing is not supported by external wallets.",code:"unsupported_wallet_type"});return await t.request({method:"secp256k1_sign",params:[r]})},signMessage:async({message:r})=>await t.request({method:"personal_sign",params:[r,e.address]}),signTypedData:async r=>await t.request({method:"eth_signTypedData_v4",params:[e.address,r]}),signTransaction:async e=>await t.request({method:"eth_signTransaction",params:[e]})})};export{Ht as toViemAccount,dt as useAuthMfa,wt as useAuthMfaEnrollment,Nt as useAuthorizationSignature,ut as useBaseAccountSdk,ct as useConnectBaseAccount,lt as useConnectCoinbaseSmartWallet,Ze as useConnectOrCreateWallet,pt as useCrossAppAccounts,Wt as useCustomAuth,Pt as useDelegatedActions,bt as useFarcasterSigner,gt as useGuestAccounts,Ft as useHeadlessDelegatedActions,ot as useLinkAccount,Rt as useLinkJwtAccount,Je as useLinkWithPasskey,et as useLinkWithSiwe,at as useLinkWithSiws,$e as useLoginWithEmail,Be as useLoginWithFarcasterV2,Ge as useLoginWithOAuth,Xe as useLoginWithPasskey,tt as useLoginWithSiwe,rt as useLoginWithSiws,Ye as useLoginWithSms,Ot as useLoginWithTelegram,Et as useModalStatus,Tt as useOAuthTokens,Ve as useRecoverEmbeddedWallet,yt as useSendTransaction,Mt as useSessionSigners,mt as useSetWalletPassword,At as useSetWalletRecovery,kt as useSign7702Authorization,Ct as useSignAuthorization,ft as useSignMessage,st as useSignTransaction,vt as useSignTypedData,Qe as useSignupWithPasskey,It as useSubscribeToJwtAuthWithFlag,te as useSyncJwtBasedAuthState,St as useToken,nt as useUpdateAccount,it as useUpdateEmail,_t as useUser,B as useWallets};
|
|
1
|
+
import{g as e,a as t,u as r,b as s,c as n,C as o,d as i,s as l,e as d,p as h,U as w,f as p,h as m,t as y,i as f,M as A,j as k,A as C,k as v,l as E,L as T,m as S,I as U,T as W,S as I,B as P,P as M,E as N,n as F,o as L,q as H,r as x,v as D,G as K,W as q,w as z,x as j,y as B,z as G,D as J,F as ee,H as te,J as re,K as ae,N as se}from"./privy-provider-CAS3yDsS.mjs";export{R as Captcha,V as ConnectorManager,Y as EthereumWalletConnector,aa as LoginModal,a3 as PrivyClient,O as PrivyProvider,a2 as VERSION,X as WalletConnector,a0 as errorIndicatesMaxMfaRetries,a1 as errorIndicatesMfaTimeout,$ as errorIndicatesMfaVerificationFailed,Q as getAccessToken,a7 as useCreateWallet,a4 as useIdentityToken,a9 as useImportWallet,a5 as useLogout,Z as useMfa,_ as useMfaEnrollment,ab as useMigrateWallets,a6 as useRegisterMfaListener,a8 as useSolanaWallets}from"./privy-provider-CAS3yDsS.mjs";import{useCallback as ne,useMemo as oe,useEffect as ie,useContext as le,useState as ce,useRef as ue}from"react";import{P as de,a as he}from"./paths-DCwuPDUk.mjs";import{u as we,I as pe}from"./internal-context-qdNgTV5f.mjs";import{u as me,P as ye,g as ge,a as fe,b as Ae,c as ke}from"./use-sign-with-user-signer-CpL9I6iB.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-DgjaLYuh.mjs";import{F as Ce}from"./frame-DMd4vZ0H.mjs";import{MfaAuthTotpVerify as ve,MfaAuthPasskeyInit as Ee,MfaAuthPasskeyVerify as Te,MfaAuthTotpInit as Se,MfaAuthTotpEnroll as Ue,MfaAuthTotpUnenroll as We,MfaAuthPasskeyEnrollment as Ie}from"@privy-io/public-api";import{jsxs as Re,Fragment as be,jsx as Pe}from"react/jsx-runtime";import Me from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Ne from"@heroicons/react/24/outline/ShieldCheckIcon";import{zeroAddress as _e,getAddress as Oe,createWalletClient as Fe,http as Le,parseSignature as He}from"viem";import{hashAuthorization as xe}from"viem/utils";import{getWallet as De,updateWallet as Ke,generateAuthorizationSignature as qe,PrivyClientError as ze}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{toAccount as je}from"viem/accounts";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/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"zustand";import"@headlessui/react";import"lucide-react";import"@walletconnect/ethereum-provider";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";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/solid/CheckCircleIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const Ve=()=>{let{user:r}=me(),{walletProxy:a}=we();return{recover:ne((async s=>{if(!a)throw Error("Wallet proxy is not ready");let n=await e();if(!r||!n)throw new de("User must be logged in before attempting to modify the recovery method.");let{entropyId:o,entropyIdVerifier:i}=t(r);try{await a.recover({entropyId:o,entropyIdVerifier:i,accessToken:n,...s})}catch{throw new de("Unable to recover wallets")}}),[a,r])}},Be=()=>{let{client:e,setAuthenticated:t,setUser:r}=we();return oe((()=>({init:async()=>{if(!e)throw new de("Must initialize Privy client first.");let t=new Ce;return e.startAuthFlow(t),await t.init()},login:async({fid:a,message:s,signature:n})=>{if(!e)throw new de("Must initialize Privy client first.");if(!(e.authFlow instanceof Ce))throw new de("Must initialize Farcaster Mini App flow first.");e.authFlow.setAuthData({message:s,signature:n,fid:a});let{user:o}=await e.authenticate();if(!o)throw new de("Failed to login with Farcaster V2");return r(o),t(!0),{user:o}}})),[e,r,t])},Ge=e=>{r("login",e);let t=s(),a=n(),{ready:c,user:u}=me(),{initLoginWithHeadlessOAuth:d,loginWithHeadlessOAuth:h,oAuthState:w,setOAuthState:p,isHeadlessOAuthLoading:m}=we(),y=ne((async e=>{try{if(t.enabled&&"success"!==t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);return await d(e.provider,t.token,e.disableSignup)}catch(e){throw p({status:"error",error:e}),e}}),[d,t]),g=ne((async()=>{let e=i();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 p({status:"error",error:e}),e}try{return await h(e)}catch(e){throw p({status:"error",error:e}),e}finally{l()}}),[h]);return ie((()=>{let e=i();c&&a&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&g().catch((()=>{}))}),[c,a]),{initOAuth:y,loading:m,state:w}},$e=e=>{let t=s(),{emailOtpState:r,setEmailOtpState:a,initLoginWithEmail:n,loginWithCode:i}=we();return{sendCode:ne((async({email:r,disableSignup:s})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await n({email:r,captchaToken:e,disableSignup:s,withPrivyUi:!1})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[n]),loginWithCode:ne((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:s,wasAlreadyAuthenticated:n,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:n,loginMethod:"email",loginAccount:l})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[i,t.status]),state:r}},Qe=e=>{let t=s(),{initSignupWithPasskey:r,signupWithPasskey:a,passkeyAuthState:n,setPasskeyAuthState:i}=we();return{signupWithPasskey:ne((async()=>{try{let s;if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),s=await t.waitForResult()),await r({captchaToken:s,withPrivyUi:!1});let{user:n,isNewUser:i,wasAlreadyAuthenticated:l,loginAccount:c}=await a();e?.onComplete?.({user:n,isNewUser:i,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR),t}}),[a,t.status]),state:n}},Xe=e=>{let t=s(),{initLoginWithPasskey:r,loginWithPasskey:a,passkeyAuthState:n,setPasskeyAuthState:i}=we();return{loginWithPasskey:ne((async s=>{try{let n;if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),n=await t.waitForResult()),await r({captchaToken:n,withPrivyUi:!1});let{user:i,isNewUser:l,wasAlreadyAuthenticated:c,loginAccount:u}=await a(s);e?.onComplete?.({user:i,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(s){throw i({status:"error",error:s}),e?.onError?.(s.privyErrorCode||he.UNKNOWN_AUTH_ERROR),s}}),[a,t.status]),state:n}},Je=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:s}=we();return{linkWithPasskey:ne((async()=>{try{await t();let a=await r();if(!a)throw Error("Error, user not found");let s=a.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:a,linkMethod:"passkey",linkedAccount:s})}catch(t){throw s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:a}},Ye=e=>{let t=s(),{smsOtpState:r,setSmsOtpState:a,initLoginWithSms:n,loginWithCode:i}=we();return{sendCode:ne((async({phoneNumber:r,disableSignup:s})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await n({phoneNumber:r,captchaToken:e,disableSignup:s,withPrivyUi:!1})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[n]),loginWithCode:ne((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:s,wasAlreadyAuthenticated:n,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:n,loginMethod:"sms",loginAccount:l})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[i,t.status]),state:r}},Ze=e=>{let{connectOrCreateWallet:t}=me();return r("connectOrCreateWallet",e),{connectOrCreateWallet:t}},et=e=>{let t=s(),{siweState:r,setSiweState:a,linkWithSiwe:n,generateSiweMessage:i}=we();return{generateSiweMessage:ne((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await i({address:t,chainId:r}).then((e=>e))}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[i]),linkWithSiwe:ne((async({signature:r,message:s,chainId:i,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);let{user:a,linkedAccount:u}=await n({message:s,signature:r,chainId:i,walletClientType:l,connectorType:c});u&&e?.onSuccess?.({user:a,linkMethod:"siwe",linkedAccount:u})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[n,t.status]),state:r}},tt=e=>{let t=s(),{siweState:r,setSiweState:a,client:n,generateSiweMessage:i,loginWithSiwe:l}=we();return{generateSiweNonce:ne((async r=>{try{let e;if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),a({status:"generating-message"});let s=await n.generateSiweNonce({address:r?.address,captchaToken:e});return a({status:"awaiting-signature"}),s}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[n,t]),generateSiweMessage:ne((async({address:r,chainId:s})=>{try{let e;if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({address:r,chainId:s,captchaToken:e})}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[i,t]),loginWithSiwe:ne((async({message:r,signature:s,disableSignup:n})=>{try{let a;if(t.enabled&&"error"===t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult());let i=await l({message:r,signature:s,captchaToken:a,disableSignup:n});return e?.onComplete?.({user:i,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),i}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR),r}}),[l,t.status]),state:r}},rt=()=>{let e=s(),{client:t,setAuthenticated:r,setUser:a,setIsNewUser:n}=we(),{authenticated:i}=d();return{generateSiwsMessage:ne((async({address:r})=>{let a;if(e.enabled&&"error"===e.status)throw new o(e.error,null,he.CAPTCHA_FAILURE);e.enabled&&"success"!==e.status&&(e.execute(),a=await e.waitForResult());let s=await t.generateSiwsNonce({address:r,captchaToken:a});return h({address:r,nonce:s})}),[e,t]),loginWithSiws:ne((async({message:s,signature:l,disableSignup:c})=>{if(i)throw Error("User already authenticated");if(e.enabled&&"error"===e.status)throw new o(e.error,null,he.CAPTCHA_FAILURE);e.enabled&&"success"!==e.status&&(e.execute(),await e.waitForResult());let{user:u,isNewUser:d}=await t.authenticateWithSiws({message:s,signature:l,mode:c?"no-signup":"login-or-sign-up",messageType:"plain"});if(!u)throw Error("Authentication failed - no user returned");return a(u),n(d||!1),r(!0),u}),[i,e,t,r,a,n])}},at=()=>{let e=s(),{client:t,setUser:r,refreshSessionAndUser:a}=we(),{authenticated:n}=d();return{generateSiwsMessage:ne((async({address:r})=>{let a;if(e.enabled&&"error"===e.status)throw new o(e.error,null,he.CAPTCHA_FAILURE);e.enabled&&"success"!==e.status&&(e.execute(),a=await e.waitForResult());let s=await t.generateSiwsNonce({address:r,captchaToken:a});return h({address:r,nonce:s})}),[e,t]),linkWithSiws:ne((async({signature:s,message:i,walletClientType:l,connectorType:c})=>{if(!n)throw Error("User must be authenticated before linking");if(e.enabled&&"error"===e.status)throw new o(e.error,null,he.CAPTCHA_FAILURE);let u=await t.linkWithSiws({message:i,signature:s,walletClientType:l,connectorType:c,messageType:"plain"}),d=(e=>{if(!e)return;let t=e.linkedAccounts;return t&&0!==t.length?t[t.length-1]:void 0})(u=await a()??u)||null;return r(u||null),{user:u,linkedAccount:d}}),[n,e,t,a,r])}};function st(){let{signTransaction:e}=le(ye);return{signTransaction:e}}function nt(e){let{linkEmail:t,linkPhone:a,linkWallet:s,linkGoogle:n,linkApple:o,linkTwitter:i,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkLine:h,linkSpotify:w,linkInstagram:p,linkTelegram:m,linkFarcaster:y,linkPasskey:g}=le(ye);return r("linkAccount",e),{linkEmail:t,linkPhone:a,linkWallet:s,linkGoogle:n,linkApple:o,linkTwitter:i,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkLine:h,linkSpotify:w,linkInstagram:p,linkFarcaster:y,linkTelegram:m,linkPasskey:g}}function ot(e){let{updateEmail:t,updatePhone:a}=le(ye);return r("update",e),{updateEmail:t,updatePhone:a}}const it=e=>{let{user:t}=me(),{loginWithCode:r,emailOtpState:a,setEmailOtpState:s,client:n,inProgressAuthFlowRef:o,inProgressLoginOrLinkMethodRef:i}=we();return{state:a,sendCode:ne((async({newEmailAddress:r})=>{try{if(!t?.email)throw Error("User is required to have an email address to update it.");let e=new w(t.email.address,r);n.startAuthFlow(e),await e.sendCodeEmail({withPrivyUi:!1})}catch(r){s({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[t?.email]),verifyCode:ne((async({code:a})=>{try{if(!t?.email)throw Error("User is required to have an email address to update it.");o.current="update",i.current="email";let{user:s,linkedAccount:n}=await r(a);return e?.onSuccess?.({user:s,updateMethod:"email",updatedAccount:n}),{user:s}}catch(a){s({status:"error",error:a}),e?.onError?.(a.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[t?.email])}},lt=()=>{let{connectCoinbaseSmartWallet:e}=we();return{connectCoinbaseSmartWallet:e}},ct=()=>{let{connectBaseAccount:e}=we();return{connectBaseAccount:e}},ut=()=>{let{baseAccountSdk:e}=we();return{baseAccountSdk:e}},dt=()=>{let{setModalData:e}=p(),{openModal:t,privy:r,closePrivyModal:a}=we(),{user:s}=me();return oe((()=>({verify:async({standalone:n=!0}={standalone:!0})=>new Promise(((o,i)=>s?0===s.mfaMethods.length?o():(e((e=>({...e,mfaVerify:{onSuccess:async()=>{n?await a({shouldCallAuthOnSuccess:!1,isSuccess:!0}):m.setState({inProgressMfaFlow:void 0}),o()},onFailure:async e=>{n?await a({shouldCallAuthOnSuccess:!1,isSuccess:!1}):m.setState({inProgressMfaFlow:void 0}),i(e)},sendSmsCode:async()=>{throw Error("Not enabled")},verifySmsCode:async()=>{throw Error("Not enabled")},verifyTotpCode:async e=>{await r.fetchPrivyRoute(ve,{body:{code:e}})},generateOptions:async()=>y((await r.fetchPrivyRoute(Ee,{body:{}})).options),verifyPasskey:async e=>{let t=await import("@simplewebauthn/browser"),a=await t.startAuthentication(e);await r.fetchPrivyRoute(Te,{body:{authenticator_response:f(a)}})}}}))),void(n?t(A):m.setState({inProgressMfaFlow:"auth"}))):i(Error("Must be logged in to verify MFA"))))})),[r,e,t,a])},ht={component:()=>{let{user:e,ready:t}=me(),{app:r,data:a,onUserCloseViaDialogOrKeybindRef:s}=p(),[n,o]=ce(null),[i,l]=ce(null),[c,u]=ce(null),[d,h]=ce(!1),[w,m]=ce(!1),[y,g]=ce(),f=async()=>{y?A(y):e?await R({user:e}):A(Error("Must be logged in to manage MFA")),setTimeout((()=>{o(null),l(null)}),500)};if(s.current=f,!a?.mfaEnroll)throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:A,onSuccess:R,mfaMethods:b,verify:_,generateTotpSecret:O,enrollTotp:H,unenrollTotp:x,enrollPasskey:D}=a.mfaEnroll,K=e?.mfaMethods.includes("sms"),q=e?.mfaMethods.includes("totp"),z=e?.mfaMethods.includes("passkey"),j=!!e?.phone,V=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function B(){o(null),l(null),g(void 0)}async function G(e=V){try{g(void 0),m(!0);let t=await D(e);return await R({user:t})}catch(e){g(e)}finally{m(!1),h(!1)}}if(!t||!e||!r)/*#__PURE__*/return Re(be,{children:[/*#__PURE__*/Pe(k,{onClose:f},"header"),/*#__PURE__*/Pe(C,{children:/*#__PURE__*/Pe(v,{})}),/*#__PURE__*/Pe(E,{children:/*#__PURE__*/Pe(T,{})}),/*#__PURE__*/Pe(S,{})]});if("sms"===n)return null;if("totp"===n)/*#__PURE__*/return Re(be,{children:[/*#__PURE__*/Pe(k,{backFn:B,onClose:f},"header"),/*#__PURE__*/Pe(U,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/Pe(Me,{})}),/*#__PURE__*/Pe(W,{children:"Remove authenticator app verification?"}),/*#__PURE__*/Re(I,{children:["MFA adds an extra layer of security to your ",r?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/Pe(P,{children:/*#__PURE__*/Pe(M,{$warn:!0,onClick:async function(){try{g(void 0),m(!0);let e=await x();return await R({user:e})}catch(e){g(e)}finally{m(!1),o(null)}},loading:w,children:"Remove"})}),/*#__PURE__*/Pe(S,{})]});if("passkey"===n){let e=a.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return Re(be,{children:[/*#__PURE__*/Pe(k,{backFn:B,onClose:f},"header"),/*#__PURE__*/Pe(U,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/Pe(Me,{})}),/*#__PURE__*/Pe(W,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/Pe(I,{children:e?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/Pe(P,{children:/*#__PURE__*/Pe(M,{$warn:!0,onClick:async function(){try{g(void 0),m(!0);let e=await D([]);return await R({user:e})}catch(e){g(e)}finally{m(!1),o(null)}},loading:w,children:"Remove"})}),/*#__PURE__*/Pe(S,{})]})}return 0!==b.length||K||q||z?"sms"===i?null:"totp"===i&&c?/*#__PURE__*/Pe(N,{onClose:f,onReset:B,submitEnrollmentWithTotp:e=>async function(e){try{g(void 0),m(!0);let t=await H(e);return await R({user:t})}catch(e){g(e)}finally{m(!1),o(null)}}(e.mfaCode),error:y,totpInfo:{...c,appName:r?.name||"Privy"}}):"passkey"===i?/*#__PURE__*/Pe(F,{onReset:B,onClose:f,submitEnrollmentWithPasskey:G}):/*#__PURE__*/Pe(L,{showIntro:!1,userMfaMethods:e.mfaMethods,appMfaMethods:r.mfa.methods,userHasAuthSms:j,onBackToIntro:()=>{},handleSelectMethod:async function(e){g(void 0);try{await _()}catch(e){return void g(e)}return"totp"===e?(l(e),u(null),void O().then((({totpSecret:e,totpAuthUrl:t})=>{u({authUrl:t,secret:e})})).catch((()=>{u(null),B()}))):"passkey"===e&&1===V.length?await G():void l(e)},isTotpLoading:"totp"===i&&!c,isPasskeyLoading:d,error:y,onClose:f,setRemovingMfaMethod:async function(e){g(void 0);try{await _()}catch(e){return void g(e)}o(e)}}):/*#__PURE__*/Re(be,{children:[/*#__PURE__*/Pe(k,{onClose:f},"header"),/*#__PURE__*/Pe(U,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/Pe(Ne,{})}),/*#__PURE__*/Pe(W,{children:"Add more security"}),/*#__PURE__*/Re(I,{children:[r?.name," does not have any verification methods enabled."]}),/*#__PURE__*/Pe(P,{children:/*#__PURE__*/Pe(M,{onClick:f,children:"Close"})}),/*#__PURE__*/Pe(S,{})]})}},wt=()=>{let e=H(),{setModalData:t}=p(),{verify:r}=dt(),{openModal:a,privy:s,closePrivyModal:n,refreshSessionAndUser:o,setUser:i}=we();return oe((()=>({enroll:async()=>new Promise(((l,c)=>{t({mfaEnroll:{onSuccess:async e=>{await n({shouldCallAuthOnSuccess:!1,isSuccess:!0}),l(e)},onFailure:async e=>{await n({shouldCallAuthOnSuccess:!1,isSuccess:!1}),c(e)},verify:()=>r({standalone:!1}),shouldUnlinkOnUnenrollMfa:!0,mfaMethods:e.mfa.methods,sendSmsCode:async()=>{throw Error("Not enabled")},enrollSms:async()=>{throw Error("Not enabled")},unenrollSms:async()=>{throw Error("Not enabled")},generateTotpSecret:async()=>await s.fetchPrivyRoute(Se,{body:{}}),enrollTotp:async e=>{await s.fetchPrivyRoute(Ue,{body:{code:e}});let t=await o();return i(t),t},unenrollTotp:async()=>{await s.fetchPrivyRoute(We,{body:{}});let e=await o();return i(e),e},enrollPasskey:async e=>{await s.fetchPrivyRoute(Ie,{body:{credential_ids:e,remove_for_login:!0}});let t=await o();return i(t),t}}}),a(ht)}))})),[s,t,a,n])},pt=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:a,sendTransactionWithCrossAppWallet:s,signTransactionWithCrossAppWallet:n}=me();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:r,signTypedData:a,sendTransaction:s,signTransaction:n}};function mt(e){let{sendTransaction:t}=le(ye);return r("sendTransaction",e),{sendTransaction:t}}function yt(e){let{setWalletPassword:t}=le(ye);return r("setWalletPassword",e),{setWalletPassword:t}}function gt(){let e=H(),t=x(),{client:r,setUser:a,setAuthenticated:s,setIsNewUser:n,initializeWalletProxy:o}=we(),{create:i}=D();return{createGuestAccount:async()=>{if(!e.id||!r)throw Error("SDK not yet ready");r.startAuthFlow(new K(e.id));try{let l=await r.authenticate(),c=l.user,u=l.isNewUser??!1;if(!c)throw new de("Unable to authenticate guest account");let d=await r.getAccessToken(),h=await o(q);if(d&&h)try{let t=z(c,e.embeddedWallets.ethereum.createOnLogin),r=j(c,e.embeddedWallets.solana.createOnLogin);t&&r?(c=(await i({chainType:"ethereum",latestUser:c})).user,c=(await i({chainType:"solana",latestUser:c})).user):r?c=(await i({chainType:"solana",latestUser:c})).user:t?c=(await i({chainType:"ethereum",latestUser:c})).user:a(c)}catch(e){a(c),console.warn("Unable to create embedded wallet for guest account")}return n(u),s(!0),t("login","onComplete",{user:c,isNewUser:u,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),c}catch(e){throw t("login","onError",e.privyErrorCode||he.UNKNOWN_AUTH_ERROR),e}}}}function ft(e){let{setWalletRecovery:t}=le(ye);return r("setWalletRecovery",e),{setWalletRecovery:t}}function At(e){let{signMessage:t}=le(ye);return r("signMessage",e),{signMessage:t}}const kt=()=>{let{ready:e,wallets:t}=B(),{user:r}=me(),{rpcConfig:a,chains:s,appId:n}=we();return{signAuthorization:ne((async(o,i)=>{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=i?.address??ge(r)?.address??_e,u=t.find((e=>Oe(e.address)===Oe(c)));if(!u)throw Error("Signing wallet not found.");let d=o.chainId??Number(u.chainId.split(":")[1]);if(0===d)l={chainId:0,address:o.contractAddress,nonce:o.nonce??0};else{let e=s.find((e=>e.id===d));if(!e)throw Error("Error, chain not configured in PrivyProvider config");let t=Fe({account:c,chain:e,transport:Le(G(e,a,n))});l=await t.prepareAuthorization({...o})}let h=await u.getEthereumProvider(),w=await h.request({method:"secp256k1_sign",params:[xe(l)]});return{...l,...He(w)}}),[e,t,r,s])}},Ct=kt;function vt(e){let{signTypedData:t}=le(ye);return r("signTypedData",e),{signTypedData:t}}const Et=()=>{let{isModalOpen:e}=le(ye);return{isOpen:e}};function Tt(e){let{getAccessToken:t}=le(ye);return r("accessToken",e),{getAccessToken:t}}function St(e){let{authenticated:t,user:a}=me(),{initLoginWithOAuth:s}=we(),n=x();return r("oAuthAuthorization",e),{reauthorize:e=>Ut(t,a,s,n,e.provider)}}let Ut=async(e,t,r,a,s)=>{if(!e)throw a("linkAccount","onError",he.MUST_BE_AUTHENTICATED,{linkMethod:s}),new de("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(s))))throw new de(`OAuth account of type ${s} not linked to the account.`);await r(s)};function Wt(e){let{client:t}=we(),[r,a]=ce({status:"initial"});return{linkWithCustomJwt:ne((async r=>{try{a({status:"initial"}),t.startAuthFlow(new J(r)),a({status:"loading"});let{user:s}=await t.link();if(!s)throw Error("Error, user not found");let n=s.linkedAccounts.filter((e=>"custom_auth"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())).at(0);return a({status:"done"}),e?.onSuccess?.({user:s,linkMethod:"custom",linkedAccount:n}),{user:s}}catch(r){throw a({status:"error",error:r}),e?.onError?.(r.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"custom"}),r}}),[t.startAuthFlow,t.link]),state:r}}const It=e=>{let t=ee();return r("customAuth",e),{status:t}};function Rt({isAuthenticated:e,isLoading:t,...r}){let a=ue();ie((()=>{t||a.current?.()}),[e,t]);let s=ne((e=>(a.current=e,()=>{a.current=void 0})),[]);return te({...r,subscribe:s})}function bt(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=me();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}const Pt=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=we();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Mt=()=>{let{addSessionSignersInternal:e,removeSessionSignersInternal:t}=(()=>{let{user:e}=me(),t=we(),{signWithUserSigner:r}=fe(),a=async({wallet:a,additional_signers:s})=>{let n=await t.client.getAccessToken();if(!e||!n)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!a.id)throw new de("Wallet to add signers to must have ID on server");if(!t.walletProxy)throw new de("Wallet proxy not initialized.");await Ke(t.privy,{wallet_id:a.id},r,{additional_signers:s})};return{addSessionSignersInternal:async({address:r,signers:s})=>{let n=await t.client.getAccessToken();if(!e||!n)throw new de("User must be authenticated and have an embedded wallet to add a session signer.");let o=t.walletProxy??await t.initializeWalletProxy(15e3);if(!o)throw new de("Wallet proxy not initialized.");let i=Ae(e,r);if(!i)throw new de("Address to add signers too is not associated with current user.");if(ke(i)){if(0===s.length)throw new de("Must specify at least one signer to add.");let e=[...(await De(t.privy,{wallet_id:i.id})).additional_signers,...re(s)];await a({wallet:i,additional_signers:e})}else{if(i.delegated)return{user:e};if(s.length>0)throw new de("Specifying signers in addSessionSigners is only supported for TEE execution and this app uses On-device execution. Pass an empty array for signers instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let a=ae({address:r,user:e}),l=se({address:r,user:e});await t.recoverEmbeddedWallet({address:r}),await o.createDelegatedAction({accessToken:n,rootWallet:l,delegatedWallets:[a]})}let l=await t.refreshSessionAndUser();if(!l)throw Error("Could not refresh user");return{user:l}},removeSessionSignersInternal:async({address:r})=>{let s=await t.client.getAccessToken();if(!e||!s)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!(t.walletProxy??await t.initializeWalletProxy(15e3)))throw new de("Wallet proxy not initialized.");let n=Ae(e,r);if(!n)throw new de("Address to remove signers from is not associated with current user.");ke(n)?await a({wallet:n,additional_signers:[]}):await t.client.revokeDelegatedWallet();let o=await t.refreshSessionAndUser();if(!o)throw Error("Could not refresh user");return{user:o}}}})();return{addSessionSigners:async({address:t,signers:r})=>e({address:t,signers:r}),removeSessionSigners:async({address:e})=>t({address:e})}},Nt=()=>{let{signWithUserSigner:e}=fe();return oe((()=>({async generateAuthorizationSignature(t){let{signature:r}=await qe(e,t);return{signature:r}}})),[e])},_t=()=>{let{setUser:e,client:t}=le(pe),{user:r}=le(ye);return{user:r,refreshUser:ne((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},Ot=e=>{let t=s(),{initLoginWithTelegram:r,loginWithTelegram:a,telegramAuthState:n,setTelegramAuthState:i}=we();return{login:ne((async s=>{try{if(t.enabled&&"success"!==t.status)throw new o(t.error,null,he.CAPTCHA_FAILURE);await r(t.token,s?.disableSignup);let{user:n,isNewUser:i,loginAccount:l,wasAlreadyAuthenticated:c}=await a({intent:"login"});e?.onComplete?.({user:n,isNewUser:i,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:l})}catch(s){throw i({status:"error",error:s}),e?.onError?.(s.privyErrorCode||he.UNKNOWN_AUTH_ERROR),s}}),[r,a,t]),state:n}},Ft=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=we();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}},Lt=async({wallet:e})=>{let t=await e.getEthereumProvider();return je({address:e.address,sign:async({hash:r})=>{if("privy"!==e.walletClientType)throw new ze({error:"Unprefixed signing is not supported by external wallets.",code:"unsupported_wallet_type"});return await t.request({method:"secp256k1_sign",params:[r]})},signMessage:async({message:r})=>await t.request({method:"personal_sign",params:[r,e.address]}),signTypedData:async r=>await t.request({method:"eth_signTypedData_v4",params:[e.address,r]}),signTransaction:async e=>await t.request({method:"eth_signTransaction",params:[e]})})};export{Lt as toViemAccount,dt as useAuthMfa,wt as useAuthMfaEnrollment,Nt as useAuthorizationSignature,ut as useBaseAccountSdk,ct as useConnectBaseAccount,lt as useConnectCoinbaseSmartWallet,Ze as useConnectOrCreateWallet,pt as useCrossAppAccounts,It as useCustomAuth,Pt as useDelegatedActions,bt as useFarcasterSigner,gt as useGuestAccounts,Ft as useHeadlessDelegatedActions,nt as useLinkAccount,Wt as useLinkJwtAccount,Je as useLinkWithPasskey,et as useLinkWithSiwe,at as useLinkWithSiws,$e as useLoginWithEmail,Be as useLoginWithFarcasterV2,Ge as useLoginWithOAuth,Xe as useLoginWithPasskey,tt as useLoginWithSiwe,rt as useLoginWithSiws,Ye as useLoginWithSms,Ot as useLoginWithTelegram,Et as useModalStatus,St as useOAuthTokens,d as usePrivy,Ve as useRecoverEmbeddedWallet,mt as useSendTransaction,Mt as useSessionSigners,yt as useSetWalletPassword,ft as useSetWalletRecovery,kt as useSign7702Authorization,Ct as useSignAuthorization,At as useSignMessage,st as useSignTransaction,vt as useSignTypedData,Qe as useSignupWithPasskey,Rt as useSubscribeToJwtAuthWithFlag,te as useSyncJwtBasedAuthState,Tt as useToken,ot as useUpdateAccount,it as useUpdateEmail,_t as useUser,B as useWallets};
|
|
@@ -1 +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())},
|
|
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())},n=/*#__PURE__*/t({setAuthenticated:i,setUser:i,setIsNewUser:i,isNewUserThisSession:!1,walletConnectionStatus:null,setWalletConnectionStatus:i,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,connectBaseAccount: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,inProgressAuthFlowRef:{current:null},inProgressLoginOrLinkMethodRef:{current:null},baseAccountSdk:void 0,setBaseAccountSdk:i}),s=()=>e(n);export{n as I,i as a,a as n,s as u};
|