@privy-io/react-auth 2.19.3 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cjs/abstract-smart-wallets.js +1 -1
  2. package/dist/cjs/extended-chains.js +1 -1
  3. package/dist/cjs/farcaster.js +1 -1
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/privy-provider-NikYcweE.js +29 -0
  6. package/dist/cjs/smart-wallets-mWRMk0wI.js +1 -0
  7. package/dist/cjs/smart-wallets.js +1 -1
  8. package/dist/cjs/solana.js +1 -1
  9. package/dist/cjs/ui.js +1 -1
  10. package/dist/cjs/use-sign-with-user-signer-pdwGPuUl.js +1 -0
  11. package/dist/cjs/{useActiveWallet-C3sUASyl.js → useActiveWallet-D0kSB8pr.js} +1 -1
  12. package/dist/cjs/{useFundWallet-CjIOl8K5.js → useFundWallet-BLnL9YuU.js} +1 -1
  13. package/dist/dts/extended-chains.d.mts +3 -3
  14. package/dist/dts/extended-chains.d.ts +3 -3
  15. package/dist/dts/farcaster.d.mts +37 -7
  16. package/dist/dts/farcaster.d.ts +37 -7
  17. package/dist/dts/index.d.mts +19 -6
  18. package/dist/dts/index.d.ts +19 -6
  19. package/dist/dts/smart-wallets.d.mts +3 -2
  20. package/dist/dts/smart-wallets.d.ts +3 -2
  21. package/dist/dts/solana.d.mts +4 -4
  22. package/dist/dts/solana.d.ts +4 -4
  23. package/dist/dts/{types-ZqHmGCwO.d.mts → types-DYBA51G_.d.mts} +17 -2
  24. package/dist/dts/{types-ZqHmGCwO.d.ts → types-DYBA51G_.d.ts} +17 -2
  25. package/dist/dts/ui.d.mts +1 -1
  26. package/dist/dts/ui.d.ts +1 -1
  27. package/dist/dts/{useSolanaWallets-idhSZbQC.d.mts → useSolanaWallets-BiSasRT6.d.mts} +1 -1
  28. package/dist/dts/{useSolanaWallets-idhSZbQC.d.ts → useSolanaWallets-BiSasRT6.d.ts} +1 -1
  29. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  30. package/dist/esm/extended-chains.mjs +1 -1
  31. package/dist/esm/farcaster.mjs +1 -1
  32. package/dist/esm/index.mjs +1 -1
  33. package/dist/esm/privy-provider-NPBEALzA.mjs +29 -0
  34. package/dist/esm/smart-wallets-JbwIgnkS.mjs +1 -0
  35. package/dist/esm/smart-wallets.mjs +1 -1
  36. package/dist/esm/solana.mjs +1 -1
  37. package/dist/esm/ui.mjs +2 -2
  38. package/dist/esm/use-sign-with-user-signer-CyFzXla-.mjs +1 -0
  39. package/dist/esm/{useActiveWallet-BJC5_xsQ.mjs → useActiveWallet-MSI4YjRM.mjs} +1 -1
  40. package/dist/esm/{useFundWallet-C-F8T0D8.mjs → useFundWallet-Cv33RFig.mjs} +1 -1
  41. package/package.json +6 -6
  42. package/dist/cjs/privy-provider-BxMgsOWd.js +0 -29
  43. package/dist/cjs/smart-wallets-B_hWSx5K.js +0 -1
  44. package/dist/cjs/use-sign-with-user-signer-BQ_24mRh.js +0 -1
  45. package/dist/esm/privy-provider-DhzPL6wG.mjs +0 -29
  46. package/dist/esm/smart-wallets-CYZi_N_3.mjs +0 -1
  47. package/dist/esm/use-sign-with-user-signer-DnNPDfxp.mjs +0 -1
@@ -894,6 +894,8 @@ interface SmartWallet {
894
894
  address: string;
895
895
  /** The provider of the smart wallet. */
896
896
  smartWalletType: SmartWalletType;
897
+ /** The version of the smart wallet. */
898
+ smartWalletVersion?: string;
897
899
  }
898
900
  /** Object representation of a user's email. */
899
901
  interface Email {
@@ -1606,6 +1608,13 @@ interface PrivyClientConfig {
1606
1608
  */
1607
1609
  createOnLogin?: EmbeddedWalletCreateOnLoginConfig;
1608
1610
  };
1611
+ /**
1612
+ * Set to `true` to disable automatic migration, if you are migrating
1613
+ * manually via the `useMigrateWallets` hook.
1614
+ *
1615
+ * @default false
1616
+ */
1617
+ disableAutomaticMigration?: boolean;
1609
1618
  /**
1610
1619
  * @deprecated. Instead, use the server-driven configuration found in the Privy console: https://dashboard.privy.io/apps/YOUR_APP_ID/embedded. This client-side setting
1611
1620
  * is currently honored, but will be fully removed in a future release.
@@ -1783,6 +1792,7 @@ type SmartWalletConfig = {
1783
1792
  } | {
1784
1793
  enabled: true;
1785
1794
  smartWalletType: SmartWalletType;
1795
+ smartWalletVersion?: string;
1786
1796
  configuredNetworks: SmartWalletNetworkConfig[];
1787
1797
  };
1788
1798
  type SmartWalletNetworkConfig = {
@@ -1890,6 +1900,7 @@ type AppConfig = {
1890
1900
  solana: {
1891
1901
  createOnLogin: NonNullable<PrivyAppResponse['embedded_wallet_config']>['solana']['create_on_login'];
1892
1902
  };
1903
+ disableAutomaticMigration: NonNullable<NonNullable<PrivyClientConfig['embeddedWallets']>['disableAutomaticMigration']>;
1893
1904
  requireUserOwnedRecoveryOnCreate: NonNullable<PrivyAppResponse['embedded_wallet_config']>['require_user_owned_recovery_on_create'];
1894
1905
  userOwnedRecoveryOptions: NonNullable<PrivyAppResponse['embedded_wallet_config']>['user_owned_recovery_options'];
1895
1906
  mode: 'legacy-embedded-wallets-only' | 'user-controlled-server-wallets-only';
@@ -2277,7 +2288,7 @@ type CrossAppProviderDetails = {
2277
2288
  name: string;
2278
2289
  icon_url: string | null;
2279
2290
  };
2280
- type LoginToFrame = {
2291
+ type LoginToMiniApp = {
2281
2292
  /**
2282
2293
  * The message the Farcaster wallet signed
2283
2294
  */
@@ -2287,6 +2298,10 @@ type LoginToFrame = {
2287
2298
  */
2288
2299
  signature: string;
2289
2300
  };
2301
+ /**
2302
+ * @deprecated Use `LoginToMiniApp` instead
2303
+ */
2304
+ type LoginToFrame = LoginToMiniApp;
2290
2305
  /**
2291
2306
  * For SIWS flows, indicates whether or not the SIWS message is plaintext, or wrapped in a memo transaction
2292
2307
  */
@@ -2296,4 +2311,4 @@ type SessionSignerInput = {
2296
2311
  policyIds?: string[];
2297
2312
  }[];
2298
2313
 
2299
- export { type MoonpaySignRequest as $, type ConnectorType as A, type BaseConnectedEthereumWallet as B, type ConnectedSolanaWallet as C, type SetBaseAccountSdkType as D, type EthereumRpcRequestType as E, type FundingMethod as F, type WalletListEntry as G, type HDWalletWithMetadata as H, type AppConfig as I, type BaseConnectedWallet as J, type ConnectWalletModalOptions as K, type LoginToFrame as L, type MfaMethod as M, type LoginModalOptions as N, type OAuthTokens as O, PrivyErrorCode as P, type SetWalletRecoveryOptions as Q, type RuntimeLoginOverridableOptions as R, type SolanaTransactionReceipt as S, type SignTypedDataParams as T, type User as U, type UnsignedTransactionRequest as V, type Wallet as W, type FundWalletConfig as X, type ConnectedWallet as Y, type CrossAppProviderDetails as Z, type OAuthProviderType as _, type LoginMethod as a, type MoonpaySignResponse as a0, type SmartWalletConfig as a1, type ExternalWalletMetadata as a2, type TelegramAuthResult as a3, type TelegramWebAppData as a4, type OAuthUserInfo as a5, type SiwsMessageType as a6, type OAuthFlowState as a7, type LoginWithCode as a8, type OtpFlowState as a9, type Tiktok as aA, type Line as aB, type Telegram as aC, type CrossAppAccount as aD, type LinkedAccountType as aE, type GoogleOAuthWithMetadata as aF, type TwitterOAuthWithMetadata as aG, type DiscordOAuthWithMetadata as aH, type GithubOAuthWithMetadata as aI, type TiktokOAuthWithMetadata as aJ, type LineOAuthWithMetadata as aK, type LinkedInOAuthWithMetadata as aL, type AppleOAuthWithMetadata as aM, type FarcasterWithMetadata as aN, type TelegramWithMetadata as aO, type CrossAppAccountWithMetadata as aP, type PasskeyWithMetadata as aQ, type Email as aR, type Phone as aS, type TransactionUIOptions as aT, type ContractUIOptions as aU, type NativeFundingConfig as aV, type MoonpayFundingConfig as aW, type PriceDisplayOptions as aX, type Farcaster as aY, type Passkey as aZ, type LoginMethodOrderOption as a_, type PasskeyFlowState as aa, type SiweFlowState as ab, type BaseAccountSdkType as ac, type UnsignedTransactionRequestWithChainId as ad, type BaseConnectedWalletType as ae, type SessionSignerInput as af, type TelegramAuthFlowState as ag, type TypedMessage as ah, type MessageTypes as ai, type SmartWallet as aj, type MoonpayConfig as ak, type MoonpayCurrencyCode as al, type MoonpayPaymentMethod as am, type Quantity as an, type TransactionLog as ao, type TransactionReceipt as ap, type NonEmptyArray as aq, type EmailWithMetadata as ar, type PhoneWithMetadata as as, type WalletWithMetadata as at, type Google as au, type Twitter as av, type Discord as aw, type Github as ax, type LinkedIn as ay, type Apple as az, type LinkedAccountWithMetadata as b, type BaseConnectedSolanaWallet as c, type UserRecoveryMethod as d, type SupportedSolanaTransaction as e, type SolanaCluster as f, type CreateWalletOptions as g, type SendTransactionModalUIOptions as h, type SignMessageModalUIOptions as i, type SolanaStandardWallet as j, type SolanaFundingConfig as k, SolanaWalletConnector as l, type PrivyFarcasterSignerInitResponse as m, type MfaSubmitArgs as n, type SolanaRpcRequestType as o, type EthereumRpcResponseType as p, type SolanaRpcResponseType as q, type EIP1193Provider as r, type EntropyIdVerifier as s, toSolanaWalletConnectors as t, type RequestArguments as u, WalletConnector as v, PrivyProxyProvider as w, type WalletClientType as x, type ConnectedWalletMetadata as y, type PrivyClientConfig as z };
2314
+ export { type OAuthProviderType as $, type PrivyClientConfig as A, type BaseConnectedEthereumWallet as B, type ConnectedSolanaWallet as C, type ConnectorType as D, type EthereumRpcRequestType as E, type FundingMethod as F, type SetBaseAccountSdkType as G, type HDWalletWithMetadata as H, type WalletListEntry as I, type AppConfig as J, type BaseConnectedWallet as K, type LoginMethod as L, type MfaMethod as M, type ConnectWalletModalOptions as N, type OAuthTokens as O, PrivyErrorCode as P, type LoginModalOptions as Q, type RuntimeLoginOverridableOptions as R, type SolanaTransactionReceipt as S, type SetWalletRecoveryOptions as T, type User as U, type SignTypedDataParams as V, type Wallet as W, type UnsignedTransactionRequest as X, type FundWalletConfig as Y, type ConnectedWallet as Z, type CrossAppProviderDetails as _, type LinkedAccountWithMetadata as a, type LoginMethodOrderOption as a$, type MoonpaySignRequest as a0, type MoonpaySignResponse as a1, type SmartWalletConfig as a2, type ExternalWalletMetadata as a3, type TelegramAuthResult as a4, type TelegramWebAppData as a5, type OAuthUserInfo as a6, type SiwsMessageType as a7, type OAuthFlowState as a8, type LoginWithCode as a9, type Apple as aA, type Tiktok as aB, type Line as aC, type Telegram as aD, type CrossAppAccount as aE, type LinkedAccountType as aF, type GoogleOAuthWithMetadata as aG, type TwitterOAuthWithMetadata as aH, type DiscordOAuthWithMetadata as aI, type GithubOAuthWithMetadata as aJ, type TiktokOAuthWithMetadata as aK, type LineOAuthWithMetadata as aL, type LinkedInOAuthWithMetadata as aM, type AppleOAuthWithMetadata as aN, type FarcasterWithMetadata as aO, type TelegramWithMetadata as aP, type CrossAppAccountWithMetadata as aQ, type PasskeyWithMetadata as aR, type Email as aS, type Phone as aT, type TransactionUIOptions as aU, type ContractUIOptions as aV, type NativeFundingConfig as aW, type MoonpayFundingConfig as aX, type PriceDisplayOptions as aY, type Farcaster as aZ, type Passkey as a_, type OtpFlowState as aa, type PasskeyFlowState as ab, type SiweFlowState as ac, type BaseAccountSdkType as ad, type UnsignedTransactionRequestWithChainId as ae, type BaseConnectedWalletType as af, type SessionSignerInput as ag, type TelegramAuthFlowState as ah, type TypedMessage as ai, type MessageTypes as aj, type SmartWallet as ak, type MoonpayConfig as al, type MoonpayCurrencyCode as am, type MoonpayPaymentMethod as an, type Quantity as ao, type TransactionLog as ap, type TransactionReceipt as aq, type NonEmptyArray as ar, type EmailWithMetadata as as, type PhoneWithMetadata as at, type WalletWithMetadata as au, type Google as av, type Twitter as aw, type Discord as ax, type Github as ay, type LinkedIn as az, type BaseConnectedSolanaWallet as b, 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 SolanaStandardWallet as k, type SolanaFundingConfig as l, SolanaWalletConnector as m, type PrivyFarcasterSignerInitResponse as n, type MfaSubmitArgs as o, type SolanaRpcRequestType as p, type EthereumRpcResponseType as q, type SolanaRpcResponseType as r, type EIP1193Provider as s, toSolanaWalletConnectors as t, type EntropyIdVerifier as u, type RequestArguments as v, WalletConnector as w, PrivyProxyProvider as x, type WalletClientType as y, type ConnectedWalletMetadata as z };
package/dist/dts/ui.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { R as RuntimeLoginOverridableOptions } from './types-ZqHmGCwO.js';
2
+ import { R as RuntimeLoginOverridableOptions } from './types-DYBA51G_.js';
3
3
  import { Hex } from 'viem';
4
4
  import { Chain, Cluster } from '@privy-io/js-sdk-core';
5
5
  import '@coinbase/wallet-sdk';
package/dist/dts/ui.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { R as RuntimeLoginOverridableOptions } from './types-ZqHmGCwO.js';
2
+ import { R as RuntimeLoginOverridableOptions } from './types-DYBA51G_.js';
3
3
  import { Hex } from 'viem';
4
4
  import { Chain, Cluster } from '@privy-io/js-sdk-core';
5
5
  import '@coinbase/wallet-sdk';
@@ -1,5 +1,5 @@
1
1
  import { Chain } from '@privy-io/js-sdk-core';
2
- import { P as PrivyErrorCode, U as User, a as LoginMethod, b as LinkedAccountWithMetadata, B as BaseConnectedEthereumWallet, c as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, d as UserRecoveryMethod, S as SolanaTransactionReceipt, e as SupportedSolanaTransaction, O as OAuthTokens, F as FundingMethod, f as SolanaCluster, C as ConnectedSolanaWallet, g as CreateWalletOptions } from './types-ZqHmGCwO.js';
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-DYBA51G_.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, a as LoginMethod, b as LinkedAccountWithMetadata, B as BaseConnectedEthereumWallet, c as BaseConnectedSolanaWallet, W as Wallet, M as MfaMethod, d as UserRecoveryMethod, S as SolanaTransactionReceipt, e as SupportedSolanaTransaction, O as OAuthTokens, F as FundingMethod, f as SolanaCluster, C as ConnectedSolanaWallet, g as CreateWalletOptions } from './types-ZqHmGCwO.js';
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-DYBA51G_.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 o}from"@abstract-foundation/agw-client/actions";import{hexToNumber as r,createWalletClient as t,custom as n,http as i}from"viem";import{toAccount as a}from"viem/accounts";import{abstractTestnet as c}from"viem/chains";import{u as s,g as l,c as d}from"./use-sign-with-user-signer-DnNPDfxp.mjs";import{o as p,w as m,e as u,a as h,a$ as I,b0 as g,b1 as y,x as f}from"./privy-provider-DhzPL6wG.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-CYZi_N_3.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"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";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/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"qrcode";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";function T(){let{user:T}=s(),{hideWalletUIs:P,openPrivyModal:S,chains:b,appId:A,rpcConfig:W,client:M}=v(),k=p(),{wallets:F}=m(),{setModalData:x}=u(),q=l(T),R=!!q&&d(q),D=async(o=c.id)=>{let s=w(F);if(!s)throw Error("No connected wallet found");let l="string"==typeof o?r(o):o;if(![c.id,2741].includes(l))throw Error("Error, only Abstract chains are supported");let d=b.find((e=>e.id===l));if(!d)throw Error("Chain not configured");await s.switchChain(d.id);let p=await s.getEthereumProvider(),m=t({account:s.address,transport:n(p)}),u=a({address:s.address,signMessage:m.signMessage,signTransaction:m.signTransaction,signTypedData:m.signTypedData});return await e({chain:d,transport:i(f(d,W,A)),publicTransport:i(f(d,W,A)),signer:u})};return{signMessage:async({message:e},o)=>{let r=await D(o);return new Promise((async(o,t)=>{let{entropyId:n,entropyIdVerifier:i}=h(T);P.current=!0,x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:I,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>r.signMessage({message:e}),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))},signTypedData:async(e,o)=>{let r=await D(o);return new Promise((async(o,t)=>{P.current=!0;let{entropyId:n,entropyIdVerifier:i}=h(T);x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:I,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))},sendTransaction:async e=>{let r=await D(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{P.current=!0;let{entropyId:c,entropyIdVerifier:s}=h(T);x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:c,entropyIdVerifier:s,onCompleteNavigateTo:y,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:t,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:c,entropyIdVerifier:s,transactingWalletAddress:r.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=n?o(r.account.address,e):e;return await r.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(t);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 D(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{P.current=!0;let{entropyId:c,entropyIdVerifier:s}=h(T);x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:c,entropyIdVerifier:s,onCompleteNavigateTo:y,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:t,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:c,entropyIdVerifier:s,transactingWalletAddress:r.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=n?o(r.account.address,e):e;return await r.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(t);return await M.scanTransaction({metadata:{domain:k.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data}]}})},signOnly:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:async()=>{let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(t);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
+ import{createAbstractClient as e}from"@abstract-foundation/agw-client";import{getBatchTransactionObject as o}from"@abstract-foundation/agw-client/actions";import{hexToNumber as r,createWalletClient as t,custom as n,http as i}from"viem";import{toAccount as a}from"viem/accounts";import{abstractTestnet as c}from"viem/chains";import{u as s,g as l,c as d}from"./use-sign-with-user-signer-CyFzXla-.mjs";import{o as p,w as m,e as u,a as h,b0 as I,b1 as g,b2 as y,x as f}from"./privy-provider-NPBEALzA.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-JbwIgnkS.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"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";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/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"qrcode";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";function T(){let{user:T}=s(),{hideWalletUIs:P,openPrivyModal:S,chains:b,appId:A,rpcConfig:W,client:M}=v(),k=p(),{wallets:F}=m(),{setModalData:x}=u(),q=l(T),R=!!q&&d(q),D=async(o=c.id)=>{let s=w(F);if(!s)throw Error("No connected wallet found");let l="string"==typeof o?r(o):o;if(![c.id,2741].includes(l))throw Error("Error, only Abstract chains are supported");let d=b.find((e=>e.id===l));if(!d)throw Error("Chain not configured");await s.switchChain(d.id);let p=await s.getEthereumProvider(),m=t({account:s.address,transport:n(p)}),u=a({address:s.address,signMessage:m.signMessage,signTransaction:m.signTransaction,signTypedData:m.signTypedData});return await e({chain:d,transport:i(f(d,W,A)),publicTransport:i(f(d,W,A)),signer:u})};return{signMessage:async({message:e},o)=>{let r=await D(o);return new Promise((async(o,t)=>{let{entropyId:n,entropyIdVerifier:i}=h(T);P.current=!0,x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:I,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>r.signMessage({message:e}),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))},signTypedData:async(e,o)=>{let r=await D(o);return new Promise((async(o,t)=>{P.current=!0;let{entropyId:n,entropyIdVerifier:i}=h(T);x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:I,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))},sendTransaction:async e=>{let r=await D(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{P.current=!0;let{entropyId:c,entropyIdVerifier:s}=h(T);x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:c,entropyIdVerifier:s,onCompleteNavigateTo:y,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:t,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:c,entropyIdVerifier:s,transactingWalletAddress:r.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=n?o(r.account.address,e):e;return await r.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(t);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 D(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{P.current=!0;let{entropyId:c,entropyIdVerifier:s}=h(T);x({connectWallet:{recoveryMethod:q.recoveryMethod,connectingWalletAddress:q.address,isUnifiedWallet:R,entropyId:c,entropyIdVerifier:s,onCompleteNavigateTo:y,onFailure:()=>{}},sendTransaction:{transactionRequests:C({calls:t,chain:r.chain,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,nonce:e.nonce?BigInt(e.nonce):void 0}),entropyId:c,entropyIdVerifier:s,transactingWalletAddress:r.account.address,transactingWalletIndex:void 0,prepareTransactionRequest:async()=>{let t=n?o(r.account.address,e):e;return await r.prepareAbstractTransactionRequest(t)},scanTransaction:async()=>{if(!M)throw Error("Privy client not found");let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(t);return await M.scanTransaction({metadata:{domain:k.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data}]}})},signOnly:!0,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:async()=>{let t=n?o(r.account.address,e):e,i=await r.prepareAbstractTransactionRequest(t);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-qdNgTV5f.mjs";import{u as i,a as s,f as n,c as o}from"./use-sign-with-user-signer-DnNPDfxp.mjs";import"viem";const u=()=>{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])},d=()=>{let{user:e}=i(),{privy:u}=a(),{signWithUserSigner:d}=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 h=await t(u,d,{wallet_id:s.id,params:{hash:i}});if(h.data&&"signature"in h.data&&"hex"===h.data.encoding)return{signature:h.data.signature};throw Error("Failed to sign")}})),[u])};export{u as useCreateWallet,d as useSignRawHash};
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,f as n,c as o}from"./use-sign-with-user-signer-CyFzXla-.mjs";import"viem";const u=()=>{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])},d=()=>{let{user:e}=i(),{privy:u}=a(),{signWithUserSigner:d}=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 h=await t(u,d,{wallet_id:s.id,params:{hash:i}});if(h.data&&"signature"in h.data&&"hex"===h.data.encoding)return{signature:h.data.signature};throw Error("Failed to sign")}})),[u,d,e])};export{u as useCreateWallet,d as useSignRawHash};
@@ -1 +1 @@
1
- import{useCallback as t}from"react";import{F as e}from"./frame-DMd4vZ0H.mjs";import{P as r}from"./paths-DCwuPDUk.mjs";import{u as i}from"./internal-context-qdNgTV5f.mjs";import"ofetch";const a=()=>{let{client:a,setAuthenticated:s,setUser:n}=i();return{initLoginToFrame:t((async()=>{let t=new e;if(!a)throw new r("Must initialize Privy client first.");return a.startAuthFlow(t),await t.init()}),[a]),loginToFrame:t((async({message:t,signature:i})=>{if(!a)throw new r("Must initialize Privy client first.");if(!(a.authFlow instanceof e))throw new r("Must initialize Farcaster frame flow first.");let o=(t=>{let e=t.match(/farcaster:\/\/fid\/(\d+)/);return e&&e[1]?parseInt(e[1],10):null})(t);if(!o)throw new r("Invalid message format; could not parse Farcaster ID.");a.authFlow.setAuthData({message:t,signature:i,fid:o});let{user:l}=await a.authenticate();return l&&(n(l),s(!0)),l}),[a,n,s])}};export{a as useLoginToFrame};
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};
@@ -1 +1 @@
1
- import{g as e,a as t,u as r,b as o,c as n,C as s,d as i,s as l,U as d,e as h,f as w,t as p,h as m,M as y,i as f,A,j as k,k as C,L as v,l as E,I as S,T,S as U,B as I,P as W,E as P,m as M,n as F,o as L,p as H,q as D,G as x,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 oe}from"./privy-provider-DhzPL6wG.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,X as usePrivy,a5 as useRegisterMfaListener,a7 as useSolanaWallets}from"./privy-provider-DhzPL6wG.mjs";import{useCallback as ne,useMemo as se,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-DnNPDfxp.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-BJC5_xsQ.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 Ie,MfaAuthPasskeyEnrollment as Re}from"@privy-io/public-api";import{jsxs as We,Fragment as Pe,jsx as be}from"react/jsx-runtime";import Me from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Ne from"@heroicons/react/24/outline/ShieldCheckIcon";import{zeroAddress as Oe,getAddress as _e,createWalletClient as Fe,http as Le,parseSignature as He}from"viem";import{hashAuthorization as De}from"viem/utils";import{getWallet as xe,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"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";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/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"qrcode";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const Ve=()=>{let{user:r}=me(),{walletProxy:a}=we();return{recover:ne((async o=>{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:s,entropyIdVerifier:i}=t(r);try{await a.recover({entropyId:s,entropyIdVerifier:i,accessToken:n,...o})}catch{throw new de("Unable to recover wallets")}}),[a,r])}},Be=()=>{let{client:e,setAuthenticated:t,setUser:r}=we();return se((()=>({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:o,signature:n})=>{if(!e)throw new de("Must initialize Privy client first.");if(!(e.authFlow instanceof Ce))throw new de("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:o,signature:n,fid:a});let{user:s}=await e.authenticate();if(!s)throw new de("Failed to login with Farcaster V2");return r(s),t(!0),{user:s}}})),[e,r,t])},Ge=e=>{r("login",e);let t=o(),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 s(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=o(),{emailOtpState:r,setEmailOtpState:a,initLoginWithEmail:n,loginWithCode:i}=we();return{sendCode:ne((async({email:r,disableSignup:o})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await n({email:r,captchaToken:e,disableSignup:o,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 s(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:o,wasAlreadyAuthenticated:n,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:o,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=o(),{initSignupWithPasskey:r,signupWithPasskey:a,passkeyAuthState:n,setPasskeyAuthState:i}=we();return{signupWithPasskey:ne((async()=>{try{let o;if(t.enabled&&"error"===t.status)throw new s(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: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=o(),{initLoginWithPasskey:r,loginWithPasskey:a,passkeyAuthState:n,setPasskeyAuthState:i}=we();return{loginWithPasskey:ne((async o=>{try{let n;if(t.enabled&&"error"===t.status)throw new s(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(o);e?.onComplete?.({user:i,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(o){throw i({status:"error",error:o}),e?.onError?.(o.privyErrorCode||he.UNKNOWN_AUTH_ERROR),o}}),[a,t.status]),state:n}},Je=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:o}=we();return{linkWithPasskey:ne((async()=>{try{await t();let a=await r();if(!a)throw Error("Error, user not found");let o=a.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:a,linkMethod:"passkey",linkedAccount:o})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:a}},Ye=e=>{let t=o(),{smsOtpState:r,setSmsOtpState:a,initLoginWithSms:n,loginWithCode:i}=we();return{sendCode:ne((async({phoneNumber:r,disableSignup:o})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await n({phoneNumber:r,captchaToken:e,disableSignup:o,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 s(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:o,wasAlreadyAuthenticated:n,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:o,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=o(),{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:o,chainId:i,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);let{user:a,linkedAccount:u}=await n({message:o,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=o(),{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 s(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),a({status:"generating-message"});let o=await n.generateSiweNonce({address:r?.address,captchaToken:e});return a({status:"awaiting-signature"}),o}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:o})=>{try{let e;if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({address:r,chainId:o,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:o,disableSignup:n})=>{try{let a;if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult());let i=await l({message:r,signature:o,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}};function rt(){let{signTransaction:e}=le(ye);return{signTransaction:e}}function at(e){let{linkEmail:t,linkPhone:a,linkWallet:o,linkGoogle:n,linkApple:s,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:o,linkGoogle:n,linkApple:s,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 nt=e=>{let{user:t}=me(),{loginWithCode:r,emailOtpState:a,setEmailOtpState:o,client:n,inProgressAuthFlowRef:s,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 d(t.email.address,r);n.startAuthFlow(e),await e.sendCodeEmail({withPrivyUi:!1})}catch(r){o({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.");s.current="update",i.current="email";let{user:o,linkedAccount:n}=await r(a);return e?.onSuccess?.({user:o,updateMethod:"email",updatedAccount:n}),{user:o}}catch(a){o({status:"error",error:a}),e?.onError?.(a.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[t?.email])}},st=()=>{let{connectCoinbaseSmartWallet:e}=we();return{connectCoinbaseSmartWallet:e}},it=()=>{let{connectBaseAccount:e}=we();return{connectBaseAccount:e}},lt=()=>{let{baseAccountSdk:e}=we();return{baseAccountSdk:e}},ct=()=>{let{setModalData:e}=h(),{openModal:t,privy:r,closePrivyModal:a}=we(),{user:o}=me();return se((()=>({verify:async({standalone:n=!0}={standalone:!0})=>new Promise(((s,i)=>o?0===o.mfaMethods.length?s():(e((e=>({...e,mfaVerify:{onSuccess:async()=>{n?await a({shouldCallAuthOnSuccess:!1,isSuccess:!0}):w.setState({inProgressMfaFlow:void 0}),s()},onFailure:async e=>{n?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:m(a)}})}}}))),void(n?t(y):w.setState({inProgressMfaFlow:"auth"}))):i(Error("Must be logged in to verify MFA"))))})),[r,e,t,a])},ut={component:()=>{let{user:e,ready:t}=me(),{app:r,data:a,onUserCloseViaDialogOrKeybindRef:o}=h(),[n,s]=ce(null),[i,l]=ce(null),[c,u]=ce(null),[d,w]=ce(!1),[p,m]=ce(!1),[y,g]=ce(),R=async()=>{y?b(y):e?await N({user:e}):b(Error("Must be logged in to manage MFA")),setTimeout((()=>{s(null),l(null)}),500)};if(o.current=R,!a?.mfaEnroll)throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:b,onSuccess:N,mfaMethods:O,verify:_,generateTotpSecret:L,enrollTotp:H,unenrollTotp:D,enrollPasskey:x}=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(){s(null),l(null),g(void 0)}async function G(e=V){try{g(void 0),m(!0);let t=await x(e);return await N({user:t})}catch(e){g(e)}finally{m(!1),w(!1)}}if(!t||!e||!r)/*#__PURE__*/return We(Pe,{children:[/*#__PURE__*/be(f,{onClose:R},"header"),/*#__PURE__*/be(A,{children:/*#__PURE__*/be(k,{})}),/*#__PURE__*/be(C,{children:/*#__PURE__*/be(v,{})}),/*#__PURE__*/be(E,{})]});if("sms"===n)return null;if("totp"===n)/*#__PURE__*/return We(Pe,{children:[/*#__PURE__*/be(f,{backFn:B,onClose:R},"header"),/*#__PURE__*/be(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/be(Me,{})}),/*#__PURE__*/be(T,{children:"Remove authenticator app verification?"}),/*#__PURE__*/We(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__*/be(I,{children:/*#__PURE__*/be(W,{$warn:!0,onClick:async function(){try{g(void 0),m(!0);let e=await D();return await N({user:e})}catch(e){g(e)}finally{m(!1),s(null)}},loading:p,children:"Remove"})}),/*#__PURE__*/be(E,{})]});if("passkey"===n){let e=a.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return We(Pe,{children:[/*#__PURE__*/be(f,{backFn:B,onClose:R},"header"),/*#__PURE__*/be(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/be(Me,{})}),/*#__PURE__*/be(T,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/be(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__*/be(I,{children:/*#__PURE__*/be(W,{$warn:!0,onClick:async function(){try{g(void 0),m(!0);let e=await x([]);return await N({user:e})}catch(e){g(e)}finally{m(!1),s(null)}},loading:p,children:"Remove"})}),/*#__PURE__*/be(E,{})]})}return 0!==O.length||K||q||z?"sms"===i?null:"totp"===i&&c?/*#__PURE__*/be(P,{onClose:R,onReset:B,submitEnrollmentWithTotp:e=>async function(e){try{g(void 0),m(!0);let t=await H(e);return await N({user:t})}catch(e){g(e)}finally{m(!1),s(null)}}(e.mfaCode),error:y,totpInfo:{...c,appName:r?.name||"Privy"}}):"passkey"===i?/*#__PURE__*/be(M,{onReset:B,onClose:R,submitEnrollmentWithPasskey:G}):/*#__PURE__*/be(F,{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 L().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:R,setRemovingMfaMethod:async function(e){g(void 0);try{await _()}catch(e){return void g(e)}s(e)}}):/*#__PURE__*/We(Pe,{children:[/*#__PURE__*/be(f,{onClose:R},"header"),/*#__PURE__*/be(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/be(Ne,{})}),/*#__PURE__*/be(T,{children:"Add more security"}),/*#__PURE__*/We(U,{children:[r?.name," does not have any verification methods enabled."]}),/*#__PURE__*/be(I,{children:/*#__PURE__*/be(W,{onClick:R,children:"Close"})}),/*#__PURE__*/be(E,{})]})}},dt=()=>{let e=L(),{setModalData:t}=h(),{verify:r}=ct(),{openModal:a,privy:o,closePrivyModal:n,refreshSessionAndUser:s,setUser:i}=we();return se((()=>({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 o.fetchPrivyRoute(Te,{body:{}}),enrollTotp:async e=>{await o.fetchPrivyRoute(Ue,{body:{code:e}});let t=await s();return i(t),t},unenrollTotp:async()=>{await o.fetchPrivyRoute(Ie,{body:{}});let e=await s();return i(e),e},enrollPasskey:async e=>{await o.fetchPrivyRoute(Re,{body:{credential_ids:e,remove_for_login:!0}});let t=await s();return i(t),t}}}),a(ut)}))})),[o,t,a,n])},ht=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:a,sendTransactionWithCrossAppWallet:o}=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:o}};function wt(e){let{sendTransaction:t}=le(ye);return r("sendTransaction",e),{sendTransaction:t}}function pt(e){let{setWalletPassword:t}=le(ye);return r("setWalletPassword",e),{setWalletPassword:t}}function mt(){let e=L(),{getAccessToken:t}=me(),r=H(),{client:a,setUser:o,setAuthenticated:n,setIsNewUser:s,initializeWalletProxy:i}=we(),{create:l}=D();return{createGuestAccount:async()=>{if(!e.id||!a)throw Error("SDK not yet ready");a.startAuthFlow(new x(e.id));try{let c=await a.authenticate(),u=c.user,d=c.isNewUser??!1;if(!u)throw new de("Unable to authenticate guest account");let h=await t(),w=await i(q);if(h&&w)try{let t=z(u,e.embeddedWallets.ethereum.createOnLogin),r=j(u,e.embeddedWallets.solana.createOnLogin);t&&r?(u=(await l({chainType:"ethereum",latestUser:u})).user,u=(await l({chainType:"solana",latestUser:u})).user):r?u=(await l({chainType:"solana",latestUser:u})).user:t?u=(await l({chainType:"ethereum",latestUser:u})).user:o(u)}catch(e){o(u),console.warn("Unable to create embedded wallet for guest account")}return s(d),n(!0),r("login","onComplete",{user:u,isNewUser:d,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw r("login","onError",e.privyErrorCode||he.UNKNOWN_AUTH_ERROR),e}}}}function yt(e){let{setWalletRecovery:t}=le(ye);return r("setWalletRecovery",e),{setWalletRecovery:t}}function gt(e){let{signMessage:t}=le(ye);return r("signMessage",e),{signMessage:t}}const ft=()=>{let{ready:e,wallets:t}=B(),{user:r}=me(),{rpcConfig:a,chains:o,appId:n}=we();return{signAuthorization:ne((async(s,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??Oe,u=t.find((e=>_e(e.address)===_e(c)));if(!u)throw Error("Signing wallet not found.");let d=s.chainId??Number(u.chainId.split(":")[1]);if(0===d)l={chainId:0,address:s.contractAddress,nonce:s.nonce??0};else{let e=o.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({...s})}let h=await u.getEthereumProvider(),w=await h.request({method:"secp256k1_sign",params:[De(l)]});return{...l,...He(w)}}),[e,t,r,o])}},At=ft;function kt(e){let{signTypedData:t}=le(ye);return r("signTypedData",e),{signTypedData:t}}const Ct=()=>{let{isModalOpen:e}=le(ye);return{isOpen:e}};function vt(e){let{getAccessToken:t}=le(ye);return r("accessToken",e),{getAccessToken:t}}function Et(e){let{authenticated:t,user:a}=me(),{initLoginWithOAuth:o}=we(),n=H();return r("oAuthAuthorization",e),{reauthorize:e=>St(t,a,o,n,e.provider)}}let St=async(e,t,r,a,o)=>{if(!e)throw a("linkAccount","onError",he.MUST_BE_AUTHENTICATED,{linkMethod:o}),new de("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(o))))throw new de(`OAuth account of type ${o} not linked to the account.`);await r(o)};function Tt(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:o}=await t.link();if(!o)throw Error("Error, user not found");let n=o.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:o,linkMethod:"custom",linkedAccount:n}),{user:o}}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 Ut=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 o=ne((e=>(a.current=e,()=>{a.current=void 0})),[]);return te({...r,subscribe:o})}function Rt(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=me();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}const Wt=()=>{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})}},Pt=()=>{let{addSessionSignersInternal:e,removeSessionSignersInternal:t}=(()=>{let{getAccessToken:e,user:t}=me(),r=we(),{signWithUserSigner:a}=fe(),o=async({wallet:o,additional_signers:n})=>{let s=await e();if(!t||!s)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!o.id)throw new de("Wallet to add signers to must have ID on server");if(!r.walletProxy)throw new de("Wallet proxy not initialized.");await Ke(r.privy,{wallet_id:o.id},a,{additional_signers:n})};return{addSessionSignersInternal:async({address:a,signers:n})=>{let s=await e();if(!t||!s)throw new de("User must be authenticated and have an embedded wallet to add a session signer.");let i=r.walletProxy??await r.initializeWalletProxy(15e3);if(!i)throw new de("Wallet proxy not initialized.");let l=Ae(t,a);if(!l)throw new de("Address to add signers too is not associated with current user.");if(ke(l)){if(0===n.length)throw new de("Must specify at least one signer to add.");let e=[...(await xe(r.privy,{wallet_id:l.id})).additional_signers,...re(n)];await o({wallet:l,additional_signers:e})}else{if(l.delegated)return{user:t};if(n.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 e=ae({address:a,user:t}),o=oe({address:a,user:t});await r.recoverEmbeddedWallet({address:a}),await i.createDelegatedAction({accessToken:s,rootWallet:o,delegatedWallets:[e]})}let c=await r.refreshSessionAndUser();if(!c)throw Error("Could not refresh user");return{user:c}},removeSessionSignersInternal:async({address:a})=>{let n=await e();if(!t||!n)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!(r.walletProxy??await r.initializeWalletProxy(15e3)))throw new de("Wallet proxy not initialized.");let s=Ae(t,a);if(!s)throw new de("Address to remove signers from is not associated with current user.");ke(s)?await o({wallet:s,additional_signers:[]}):await r.client.revokeDelegatedWallet();let i=await r.refreshSessionAndUser();if(!i)throw Error("Could not refresh user");return{user:i}}}})();return{addSessionSigners:async({address:t,signers:r})=>e({address:t,signers:r}),removeSessionSigners:async({address:e})=>t({address:e})}},bt=()=>{let{signWithUserSigner:e}=fe();return se((()=>({async generateAuthorizationSignature(t){let{signature:r}=await qe(e,t);return{signature:r}}})),[e])},Mt=()=>{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])}},Nt=e=>{let t=o(),{initLoginWithTelegram:r,loginWithTelegram:a,telegramAuthState:n,setTelegramAuthState:i}=we();return{login:ne((async o=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);await r(t.token,o?.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(o){throw i({status:"error",error:o}),e?.onError?.(o.privyErrorCode||he.UNKNOWN_AUTH_ERROR),o}}),[r,a,t]),state:n}},Ot=()=>{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})}},_t=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{_t as toViemAccount,ct as useAuthMfa,dt as useAuthMfaEnrollment,bt as useAuthorizationSignature,lt as useBaseAccountSdk,it as useConnectBaseAccount,st as useConnectCoinbaseSmartWallet,Ze as useConnectOrCreateWallet,ht as useCrossAppAccounts,Ut as useCustomAuth,Wt as useDelegatedActions,Rt as useFarcasterSigner,mt as useGuestAccounts,Ot as useHeadlessDelegatedActions,at as useLinkAccount,Tt as useLinkJwtAccount,Je as useLinkWithPasskey,et as useLinkWithSiwe,$e as useLoginWithEmail,Be as useLoginWithFarcasterV2,Ge as useLoginWithOAuth,Xe as useLoginWithPasskey,tt as useLoginWithSiwe,Ye as useLoginWithSms,Nt as useLoginWithTelegram,Ct as useModalStatus,Et as useOAuthTokens,Ve as useRecoverEmbeddedWallet,wt as useSendTransaction,Pt as useSessionSigners,pt as useSetWalletPassword,yt as useSetWalletRecovery,ft as useSign7702Authorization,At as useSignAuthorization,gt as useSignMessage,rt as useSignTransaction,kt as useSignTypedData,Qe as useSignupWithPasskey,It as useSubscribeToJwtAuthWithFlag,te as useSyncJwtBasedAuthState,vt as useToken,ot as useUpdateAccount,nt as useUpdateEmail,Mt as useUser,B as useWallets};
1
+ import{g as e,a as t,u as r,b as o,c as n,C as s,d as i,s as l,U as d,e as h,f as w,t as p,h as m,M as y,i as f,A,j as k,k as C,L as v,l as E,I as S,T,S as U,B as I,P as W,E as P,m as M,n as F,o as L,p as H,q as D,G as x,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 oe}from"./privy-provider-NPBEALzA.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-NPBEALzA.mjs";import{useCallback as ne,useMemo as se,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-CyFzXla-.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-MSI4YjRM.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 Ie,MfaAuthPasskeyEnrollment as We}from"@privy-io/public-api";import{jsxs as Re,Fragment as Pe,jsx as be}from"react/jsx-runtime";import Me from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Ne from"@heroicons/react/24/outline/ShieldCheckIcon";import{zeroAddress as Oe,getAddress as _e,createWalletClient as Fe,http as Le,parseSignature as He}from"viem";import{hashAuthorization as De}from"viem/utils";import{getWallet as xe,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"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";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/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"@heroicons/react/24/outline";import"@tanstack/react-virtual";import"qrcode";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const Ve=()=>{let{user:r}=me(),{walletProxy:a}=we();return{recover:ne((async o=>{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:s,entropyIdVerifier:i}=t(r);try{await a.recover({entropyId:s,entropyIdVerifier:i,accessToken:n,...o})}catch{throw new de("Unable to recover wallets")}}),[a,r])}},Be=()=>{let{client:e,setAuthenticated:t,setUser:r}=we();return se((()=>({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:o,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:o,signature:n,fid:a});let{user:s}=await e.authenticate();if(!s)throw new de("Failed to login with Farcaster V2");return r(s),t(!0),{user:s}}})),[e,r,t])},Ge=e=>{r("login",e);let t=o(),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 s(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=o(),{emailOtpState:r,setEmailOtpState:a,initLoginWithEmail:n,loginWithCode:i}=we();return{sendCode:ne((async({email:r,disableSignup:o})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await n({email:r,captchaToken:e,disableSignup:o,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 s(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:o,wasAlreadyAuthenticated:n,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:o,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=o(),{initSignupWithPasskey:r,signupWithPasskey:a,passkeyAuthState:n,setPasskeyAuthState:i}=we();return{signupWithPasskey:ne((async()=>{try{let o;if(t.enabled&&"error"===t.status)throw new s(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: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=o(),{initLoginWithPasskey:r,loginWithPasskey:a,passkeyAuthState:n,setPasskeyAuthState:i}=we();return{loginWithPasskey:ne((async o=>{try{let n;if(t.enabled&&"error"===t.status)throw new s(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(o);e?.onComplete?.({user:i,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(o){throw i({status:"error",error:o}),e?.onError?.(o.privyErrorCode||he.UNKNOWN_AUTH_ERROR),o}}),[a,t.status]),state:n}},Je=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:o}=we();return{linkWithPasskey:ne((async()=>{try{await t();let a=await r();if(!a)throw Error("Error, user not found");let o=a.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:a,linkMethod:"passkey",linkedAccount:o})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:a}},Ye=e=>{let t=o(),{smsOtpState:r,setSmsOtpState:a,initLoginWithSms:n,loginWithCode:i}=we();return{sendCode:ne((async({phoneNumber:r,disableSignup:o})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await n({phoneNumber:r,captchaToken:e,disableSignup:o,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 s(t.error,null,he.CAPTCHA_FAILURE);let{user:a,isNewUser:o,wasAlreadyAuthenticated:n,linkedAccount:l}=await i(r);e?.onComplete?.({user:a,isNewUser:o,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=o(),{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:o,chainId:i,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);let{user:a,linkedAccount:u}=await n({message:o,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=o(),{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 s(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),a({status:"generating-message"});let o=await n.generateSiweNonce({address:r?.address,captchaToken:e});return a({status:"awaiting-signature"}),o}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:o})=>{try{let e;if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({address:r,chainId:o,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:o,disableSignup:n})=>{try{let a;if(t.enabled&&"error"===t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult());let i=await l({message:r,signature:o,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}};function rt(){let{signTransaction:e}=le(ye);return{signTransaction:e}}function at(e){let{linkEmail:t,linkPhone:a,linkWallet:o,linkGoogle:n,linkApple:s,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:o,linkGoogle:n,linkApple:s,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 nt=e=>{let{user:t}=me(),{loginWithCode:r,emailOtpState:a,setEmailOtpState:o,client:n,inProgressAuthFlowRef:s,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 d(t.email.address,r);n.startAuthFlow(e),await e.sendCodeEmail({withPrivyUi:!1})}catch(r){o({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.");s.current="update",i.current="email";let{user:o,linkedAccount:n}=await r(a);return e?.onSuccess?.({user:o,updateMethod:"email",updatedAccount:n}),{user:o}}catch(a){o({status:"error",error:a}),e?.onError?.(a.privyErrorCode||he.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[t?.email])}},st=()=>{let{connectCoinbaseSmartWallet:e}=we();return{connectCoinbaseSmartWallet:e}},it=()=>{let{connectBaseAccount:e}=we();return{connectBaseAccount:e}},lt=()=>{let{baseAccountSdk:e}=we();return{baseAccountSdk:e}},ct=()=>{let{setModalData:e}=h(),{openModal:t,privy:r,closePrivyModal:a}=we(),{user:o}=me();return se((()=>({verify:async({standalone:n=!0}={standalone:!0})=>new Promise(((s,i)=>o?0===o.mfaMethods.length?s():(e((e=>({...e,mfaVerify:{onSuccess:async()=>{n?await a({shouldCallAuthOnSuccess:!1,isSuccess:!0}):w.setState({inProgressMfaFlow:void 0}),s()},onFailure:async e=>{n?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:m(a)}})}}}))),void(n?t(y):w.setState({inProgressMfaFlow:"auth"}))):i(Error("Must be logged in to verify MFA"))))})),[r,e,t,a])},ut={component:()=>{let{user:e,ready:t}=me(),{app:r,data:a,onUserCloseViaDialogOrKeybindRef:o}=h(),[n,s]=ce(null),[i,l]=ce(null),[c,u]=ce(null),[d,w]=ce(!1),[p,m]=ce(!1),[y,g]=ce(),R=async()=>{y?b(y):e?await N({user:e}):b(Error("Must be logged in to manage MFA")),setTimeout((()=>{s(null),l(null)}),500)};if(o.current=R,!a?.mfaEnroll)throw Error("Missing modal data for MFA enrollment screen.");let{onFailure:b,onSuccess:N,mfaMethods:O,verify:_,generateTotpSecret:L,enrollTotp:H,unenrollTotp:D,enrollPasskey:x}=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(){s(null),l(null),g(void 0)}async function G(e=V){try{g(void 0),m(!0);let t=await x(e);return await N({user:t})}catch(e){g(e)}finally{m(!1),w(!1)}}if(!t||!e||!r)/*#__PURE__*/return Re(Pe,{children:[/*#__PURE__*/be(f,{onClose:R},"header"),/*#__PURE__*/be(A,{children:/*#__PURE__*/be(k,{})}),/*#__PURE__*/be(C,{children:/*#__PURE__*/be(v,{})}),/*#__PURE__*/be(E,{})]});if("sms"===n)return null;if("totp"===n)/*#__PURE__*/return Re(Pe,{children:[/*#__PURE__*/be(f,{backFn:B,onClose:R},"header"),/*#__PURE__*/be(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/be(Me,{})}),/*#__PURE__*/be(T,{children:"Remove authenticator app verification?"}),/*#__PURE__*/Re(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__*/be(I,{children:/*#__PURE__*/be(W,{$warn:!0,onClick:async function(){try{g(void 0),m(!0);let e=await D();return await N({user:e})}catch(e){g(e)}finally{m(!1),s(null)}},loading:p,children:"Remove"})}),/*#__PURE__*/be(E,{})]});if("passkey"===n){let e=a.mfaEnroll.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return Re(Pe,{children:[/*#__PURE__*/be(f,{backFn:B,onClose:R},"header"),/*#__PURE__*/be(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/be(Me,{})}),/*#__PURE__*/be(T,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/be(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__*/be(I,{children:/*#__PURE__*/be(W,{$warn:!0,onClick:async function(){try{g(void 0),m(!0);let e=await x([]);return await N({user:e})}catch(e){g(e)}finally{m(!1),s(null)}},loading:p,children:"Remove"})}),/*#__PURE__*/be(E,{})]})}return 0!==O.length||K||q||z?"sms"===i?null:"totp"===i&&c?/*#__PURE__*/be(P,{onClose:R,onReset:B,submitEnrollmentWithTotp:e=>async function(e){try{g(void 0),m(!0);let t=await H(e);return await N({user:t})}catch(e){g(e)}finally{m(!1),s(null)}}(e.mfaCode),error:y,totpInfo:{...c,appName:r?.name||"Privy"}}):"passkey"===i?/*#__PURE__*/be(M,{onReset:B,onClose:R,submitEnrollmentWithPasskey:G}):/*#__PURE__*/be(F,{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 L().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:R,setRemovingMfaMethod:async function(e){g(void 0);try{await _()}catch(e){return void g(e)}s(e)}}):/*#__PURE__*/Re(Pe,{children:[/*#__PURE__*/be(f,{onClose:R},"header"),/*#__PURE__*/be(S,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/be(Ne,{})}),/*#__PURE__*/be(T,{children:"Add more security"}),/*#__PURE__*/Re(U,{children:[r?.name," does not have any verification methods enabled."]}),/*#__PURE__*/be(I,{children:/*#__PURE__*/be(W,{onClick:R,children:"Close"})}),/*#__PURE__*/be(E,{})]})}},dt=()=>{let e=L(),{setModalData:t}=h(),{verify:r}=ct(),{openModal:a,privy:o,closePrivyModal:n,refreshSessionAndUser:s,setUser:i}=we();return se((()=>({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 o.fetchPrivyRoute(Te,{body:{}}),enrollTotp:async e=>{await o.fetchPrivyRoute(Ue,{body:{code:e}});let t=await s();return i(t),t},unenrollTotp:async()=>{await o.fetchPrivyRoute(Ie,{body:{}});let e=await s();return i(e),e},enrollPasskey:async e=>{await o.fetchPrivyRoute(We,{body:{credential_ids:e,remove_for_login:!0}});let t=await s();return i(t),t}}}),a(ut)}))})),[o,t,a,n])},ht=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:a,sendTransactionWithCrossAppWallet:o}=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:o}};function wt(e){let{sendTransaction:t}=le(ye);return r("sendTransaction",e),{sendTransaction:t}}function pt(e){let{setWalletPassword:t}=le(ye);return r("setWalletPassword",e),{setWalletPassword:t}}function mt(){let e=L(),{getAccessToken:t}=me(),r=H(),{client:a,setUser:o,setAuthenticated:n,setIsNewUser:s,initializeWalletProxy:i}=we(),{create:l}=D();return{createGuestAccount:async()=>{if(!e.id||!a)throw Error("SDK not yet ready");a.startAuthFlow(new x(e.id));try{let c=await a.authenticate(),u=c.user,d=c.isNewUser??!1;if(!u)throw new de("Unable to authenticate guest account");let h=await t(),w=await i(q);if(h&&w)try{let t=z(u,e.embeddedWallets.ethereum.createOnLogin),r=j(u,e.embeddedWallets.solana.createOnLogin);t&&r?(u=(await l({chainType:"ethereum",latestUser:u})).user,u=(await l({chainType:"solana",latestUser:u})).user):r?u=(await l({chainType:"solana",latestUser:u})).user:t?u=(await l({chainType:"ethereum",latestUser:u})).user:o(u)}catch(e){o(u),console.warn("Unable to create embedded wallet for guest account")}return s(d),n(!0),r("login","onComplete",{user:u,isNewUser:d,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw r("login","onError",e.privyErrorCode||he.UNKNOWN_AUTH_ERROR),e}}}}function yt(e){let{setWalletRecovery:t}=le(ye);return r("setWalletRecovery",e),{setWalletRecovery:t}}function gt(e){let{signMessage:t}=le(ye);return r("signMessage",e),{signMessage:t}}const ft=()=>{let{ready:e,wallets:t}=B(),{user:r}=me(),{rpcConfig:a,chains:o,appId:n}=we();return{signAuthorization:ne((async(s,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??Oe,u=t.find((e=>_e(e.address)===_e(c)));if(!u)throw Error("Signing wallet not found.");let d=s.chainId??Number(u.chainId.split(":")[1]);if(0===d)l={chainId:0,address:s.contractAddress,nonce:s.nonce??0};else{let e=o.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({...s})}let h=await u.getEthereumProvider(),w=await h.request({method:"secp256k1_sign",params:[De(l)]});return{...l,...He(w)}}),[e,t,r,o])}},At=ft;function kt(e){let{signTypedData:t}=le(ye);return r("signTypedData",e),{signTypedData:t}}const Ct=()=>{let{isModalOpen:e}=le(ye);return{isOpen:e}};function vt(e){let{getAccessToken:t}=le(ye);return r("accessToken",e),{getAccessToken:t}}function Et(e){let{authenticated:t,user:a}=me(),{initLoginWithOAuth:o}=we(),n=H();return r("oAuthAuthorization",e),{reauthorize:e=>St(t,a,o,n,e.provider)}}let St=async(e,t,r,a,o)=>{if(!e)throw a("linkAccount","onError",he.MUST_BE_AUTHENTICATED,{linkMethod:o}),new de("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(o))))throw new de(`OAuth account of type ${o} not linked to the account.`);await r(o)};function Tt(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:o}=await t.link();if(!o)throw Error("Error, user not found");let n=o.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:o,linkMethod:"custom",linkedAccount:n}),{user:o}}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 Ut=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 o=ne((e=>(a.current=e,()=>{a.current=void 0})),[]);return te({...r,subscribe:o})}function Wt(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=me();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}const Rt=()=>{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})}},Pt=()=>{let{addSessionSignersInternal:e,removeSessionSignersInternal:t}=(()=>{let{getAccessToken:e,user:t}=me(),r=we(),{signWithUserSigner:a}=fe(),o=async({wallet:o,additional_signers:n})=>{let s=await e();if(!t||!s)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!o.id)throw new de("Wallet to add signers to must have ID on server");if(!r.walletProxy)throw new de("Wallet proxy not initialized.");await Ke(r.privy,{wallet_id:o.id},a,{additional_signers:n})};return{addSessionSignersInternal:async({address:a,signers:n})=>{let s=await e();if(!t||!s)throw new de("User must be authenticated and have an embedded wallet to add a session signer.");let i=r.walletProxy??await r.initializeWalletProxy(15e3);if(!i)throw new de("Wallet proxy not initialized.");let l=Ae(t,a);if(!l)throw new de("Address to add signers too is not associated with current user.");if(ke(l)){if(0===n.length)throw new de("Must specify at least one signer to add.");let e=[...(await xe(r.privy,{wallet_id:l.id})).additional_signers,...re(n)];await o({wallet:l,additional_signers:e})}else{if(l.delegated)return{user:t};if(n.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 e=ae({address:a,user:t}),o=oe({address:a,user:t});await r.recoverEmbeddedWallet({address:a}),await i.createDelegatedAction({accessToken:s,rootWallet:o,delegatedWallets:[e]})}let c=await r.refreshSessionAndUser();if(!c)throw Error("Could not refresh user");return{user:c}},removeSessionSignersInternal:async({address:a})=>{let n=await e();if(!t||!n)throw new de("User must be authenticated and have an embedded wallet to delegate actions.");if(!(r.walletProxy??await r.initializeWalletProxy(15e3)))throw new de("Wallet proxy not initialized.");let s=Ae(t,a);if(!s)throw new de("Address to remove signers from is not associated with current user.");ke(s)?await o({wallet:s,additional_signers:[]}):await r.client.revokeDelegatedWallet();let i=await r.refreshSessionAndUser();if(!i)throw Error("Could not refresh user");return{user:i}}}})();return{addSessionSigners:async({address:t,signers:r})=>e({address:t,signers:r}),removeSessionSigners:async({address:e})=>t({address:e})}},bt=()=>{let{signWithUserSigner:e}=fe();return se((()=>({async generateAuthorizationSignature(t){let{signature:r}=await qe(e,t);return{signature:r}}})),[e])},Mt=()=>{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])}},Nt=e=>{let t=o(),{initLoginWithTelegram:r,loginWithTelegram:a,telegramAuthState:n,setTelegramAuthState:i}=we();return{login:ne((async o=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,he.CAPTCHA_FAILURE);await r(t.token,o?.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(o){throw i({status:"error",error:o}),e?.onError?.(o.privyErrorCode||he.UNKNOWN_AUTH_ERROR),o}}),[r,a,t]),state:n}},Ot=()=>{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})}},_t=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{_t as toViemAccount,ct as useAuthMfa,dt as useAuthMfaEnrollment,bt as useAuthorizationSignature,lt as useBaseAccountSdk,it as useConnectBaseAccount,st as useConnectCoinbaseSmartWallet,Ze as useConnectOrCreateWallet,ht as useCrossAppAccounts,Ut as useCustomAuth,Rt as useDelegatedActions,Wt as useFarcasterSigner,mt as useGuestAccounts,Ot as useHeadlessDelegatedActions,at as useLinkAccount,Tt as useLinkJwtAccount,Je as useLinkWithPasskey,et as useLinkWithSiwe,$e as useLoginWithEmail,Be as useLoginWithFarcasterV2,Ge as useLoginWithOAuth,Xe as useLoginWithPasskey,tt as useLoginWithSiwe,Ye as useLoginWithSms,Nt as useLoginWithTelegram,Ct as useModalStatus,Et as useOAuthTokens,Ve as useRecoverEmbeddedWallet,wt as useSendTransaction,Pt as useSessionSigners,pt as useSetWalletPassword,yt as useSetWalletRecovery,ft as useSign7702Authorization,At as useSignAuthorization,gt as useSignMessage,rt as useSignTransaction,kt as useSignTypedData,Qe as useSignupWithPasskey,It as useSubscribeToJwtAuthWithFlag,te as useSyncJwtBasedAuthState,vt as useToken,ot as useUpdateAccount,nt as useUpdateEmail,Mt as useUser,B as useWallets};