@privy-io/react-auth 2.11.1 → 2.12.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 (41) hide show
  1. package/dist/cjs/abstract-smart-wallets.js +1 -1
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/privy-provider-WROKgGLv.js +28 -0
  4. package/dist/cjs/smart-wallets-BOO4AAyW.js +1 -0
  5. package/dist/cjs/smart-wallets.js +1 -1
  6. package/dist/cjs/solana.js +1 -1
  7. package/dist/cjs/ui.js +1 -1
  8. package/dist/cjs/{useActiveWallet-BJPtwRwN.js → useActiveWallet-jRYT06Mr.js} +1 -1
  9. package/dist/cjs/{useFundWallet-CHZEiRO4.js → useFundWallet-Cgo-Ct91.js} +1 -1
  10. package/dist/dts/farcaster.d.mts +1 -1
  11. package/dist/dts/farcaster.d.ts +1 -1
  12. package/dist/dts/index.d.mts +67 -39
  13. package/dist/dts/index.d.ts +67 -39
  14. package/dist/dts/smart-wallets.d.mts +1 -1
  15. package/dist/dts/smart-wallets.d.ts +1 -1
  16. package/dist/dts/solana.d.mts +113 -7
  17. package/dist/dts/solana.d.ts +113 -7
  18. package/dist/dts/{types-B6jqW_Bc.d.mts → types-Nqh9YCV3.d.mts} +6 -12
  19. package/dist/dts/{types-B6jqW_Bc.d.ts → types-Nqh9YCV3.d.ts} +6 -12
  20. package/dist/dts/ui.d.mts +1 -1
  21. package/dist/dts/ui.d.ts +1 -1
  22. package/dist/dts/{useSolanaWallets-DtHAHWtA.d.mts → useSolanaWallets-BSVQS05e.d.mts} +1 -1
  23. package/dist/dts/{useSolanaWallets-DtHAHWtA.d.ts → useSolanaWallets-BSVQS05e.d.ts} +1 -1
  24. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  25. package/dist/esm/farcaster.mjs +1 -1
  26. package/dist/esm/{frame-BeG8p5X6.mjs → frame-B1kjU0LI.mjs} +1 -1
  27. package/dist/esm/index.mjs +1 -1
  28. package/dist/esm/{internal-context-eu0bC04Q.mjs → internal-context-lAHxpYRu.mjs} +1 -1
  29. package/dist/esm/privy-provider-CE4-s2JH.mjs +28 -0
  30. package/dist/esm/smart-wallets-C2dDEs0t.mjs +1 -0
  31. package/dist/esm/smart-wallets.mjs +1 -1
  32. package/dist/esm/solana.mjs +1 -1
  33. package/dist/esm/ui.mjs +2 -2
  34. package/dist/esm/useActiveWallet-B62Sy0KW.mjs +1 -0
  35. package/dist/esm/{useFundWallet-CCbN4yzN.mjs → useFundWallet-D2_dle4r.mjs} +1 -1
  36. package/package.json +6 -5
  37. package/dist/cjs/privy-provider-Cddj6OMJ.js +0 -28
  38. package/dist/cjs/smart-wallets-CyVw0HIK.js +0 -1
  39. package/dist/esm/privy-provider-B9IzlOpv.mjs +0 -28
  40. package/dist/esm/smart-wallets-D0LqwcPM.mjs +0 -1
  41. package/dist/esm/useActiveWallet-Cvm0O_EX.mjs +0 -1
@@ -1,15 +1,18 @@
1
- import { W as Wallet, j as SolanaFundingConfig, e as SupportedSolanaTransaction, h as SendTransactionModalUIOptions, S as SolanaTransactionReceipt, i as SignMessageModalUIOptions } from './types-B6jqW_Bc.js';
2
- export { C as ConnectedSolanaWallet, k as SolanaAdapterConnector, t as toSolanaWalletConnectors } from './types-B6jqW_Bc.js';
3
- import { P as PrivyEvents } from './useSolanaWallets-DtHAHWtA.js';
4
- export { U as UseSolanaWalletsInterface, u as useSolanaWallets } from './useSolanaWallets-DtHAHWtA.js';
1
+ import { W as Wallet, j as SolanaFundingConfig, e as SupportedSolanaTransaction, h as SendTransactionModalUIOptions, S as SolanaTransactionReceipt, i as SignMessageModalUIOptions } from './types-Nqh9YCV3.js';
2
+ export { C as ConnectedSolanaWallet, k as SolanaAdapterConnector, t as toSolanaWalletConnectors } from './types-Nqh9YCV3.js';
3
+ import { P as PrivyEvents } from './useSolanaWallets-BSVQS05e.js';
4
+ export { U as UseSolanaWalletsInterface, u as useSolanaWallets } from './useSolanaWallets-BSVQS05e.js';
5
+ import { WalletWithSolanaFeatures, SolanaSignAndSendTransactionFeature, SolanaSignTransactionFeature, SolanaSignMessageFeature } from '@solana/wallet-standard-features';
6
+ import { WalletAccount, WalletIcon, WalletVersion } from '@wallet-standard/base';
7
+ import { StandardConnectFeature, StandardDisconnectFeature, StandardEventsFeature } from '@wallet-standard/features';
8
+ import { Transaction, VersionedTransaction, Cluster, SendOptions, TransactionSignature, Connection } from '@solana/web3.js';
9
+ import EventEmitter from 'eventemitter3';
5
10
  import { SendTransactionOptions } from '@solana/wallet-adapter-base';
6
- import { Connection } from '@solana/web3.js';
7
11
  import 'react';
8
12
  import 'viem';
9
13
  import '@privy-io/js-sdk-core';
10
14
  import '@privy-io/public-api';
11
15
  import '@metamask/eth-sig-util';
12
- import 'eventemitter3';
13
16
 
14
17
  interface UseImportWalletInterface {
15
18
  /**
@@ -33,6 +36,109 @@ interface UseImportWalletInterface {
33
36
  */
34
37
  declare const useImportWallet: () => UseImportWalletInterface;
35
38
 
39
+ /**
40
+ * Object representation of a Privy Solana wallet account.
41
+ */
42
+ declare class PrivyWalletAccount implements WalletAccount {
43
+ #private;
44
+ get address(): string;
45
+ get publicKey(): Uint8Array;
46
+ get chains(): `${string}:${string}`[];
47
+ get features(): `${string}:${string}`[];
48
+ get label(): string | undefined;
49
+ get icon(): `data:image/svg+xml;base64,${string}` | `data:image/webp;base64,${string}` | `data:image/png;base64,${string}` | `data:image/gif;base64,${string}` | undefined;
50
+ constructor({ address, publicKey, label, icon }: Omit<WalletAccount, 'chains' | 'features'>);
51
+ }
52
+
53
+ /**
54
+ * Standard wallet implementation interface
55
+ */
56
+ interface StandardWalletImplementation {
57
+ /**
58
+ * Sign a message.
59
+ */
60
+ signMessage(message: Uint8Array, address: string): Promise<{
61
+ signature: Uint8Array;
62
+ }>;
63
+ /**
64
+ * Sign and send a transaction.
65
+ */
66
+ signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, address: string, cluster: Cluster, options?: SendOptions): Promise<{
67
+ signature: TransactionSignature;
68
+ }>;
69
+ /**
70
+ * Sign a transaction without sending it to the network.
71
+ */
72
+ signTransaction<T extends Transaction | VersionedTransaction>(transaction: T, address: string, cluster: Cluster, options?: SendOptions): Promise<T>;
73
+ }
74
+ type StandardWalletInjectionEvents = {
75
+ accountChanged: (accounts?: Array<{
76
+ address: string;
77
+ }>) => void;
78
+ };
79
+ /**
80
+ * Event emitter for the provider solana injection.
81
+ * This provides all the methods to sign messages, transactions, etc.
82
+ * Implementation is updated everytime the references to the wallets change.
83
+ */
84
+ declare class StandardWalletInjection extends EventEmitter<StandardWalletInjectionEvents> {
85
+ #private;
86
+ constructor(implementation: StandardWalletImplementation);
87
+ setImplementation(implementation: StandardWalletImplementation): void;
88
+ signMessage(message: Uint8Array, address: string): Promise<{
89
+ signature: Uint8Array;
90
+ }>;
91
+ signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, address: string, cluster: Cluster, options?: SendOptions): Promise<{
92
+ signature: TransactionSignature;
93
+ }>;
94
+ signTransaction<T extends Transaction | VersionedTransaction>(transaction: T, address: string, cluster: Cluster, options?: SendOptions): Promise<T>;
95
+ }
96
+
97
+ type PrivyFeature = {
98
+ 'privy:': {
99
+ privy: StandardWalletImplementation;
100
+ };
101
+ };
102
+ /**
103
+ * Privy standard wallet implementation.
104
+ */
105
+ declare class PrivyStandardWallet implements WalletWithSolanaFeatures {
106
+ #private;
107
+ get version(): "1.0.0";
108
+ get name(): string;
109
+ get icon(): `data:image/svg+xml;base64,${string}` | `data:image/webp;base64,${string}` | `data:image/png;base64,${string}` | `data:image/gif;base64,${string}`;
110
+ get chains(): ("solana:mainnet" | "solana:devnet" | "solana:testnet")[];
111
+ get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SolanaSignAndSendTransactionFeature & SolanaSignTransactionFeature & SolanaSignMessageFeature & PrivyFeature;
112
+ get accounts(): PrivyWalletAccount[];
113
+ constructor({ name, icon, version, injection, wallets, }: {
114
+ name: string;
115
+ icon: WalletIcon;
116
+ version: WalletVersion;
117
+ injection: StandardWalletInjection;
118
+ wallets: Array<{
119
+ address: string;
120
+ }>;
121
+ });
122
+ }
123
+
124
+ /**
125
+ * Use this hook to get Privy's implementation of the Standard Wallet interface.
126
+ */
127
+ interface UsePrivyStandardWalletInterface {
128
+ /**
129
+ * Whether the wallet is ready to be used.
130
+ */
131
+ ready: boolean;
132
+ /**
133
+ * The wallet that implements the Standard Wallet interface.
134
+ */
135
+ wallet: PrivyStandardWallet;
136
+ }
137
+ /**
138
+ * Use this hook to get Privy's implementation of the Standard Wallet interface.
139
+ */
140
+ declare function usePrivyStandardWallet(): UsePrivyStandardWalletInterface;
141
+
36
142
  /**
37
143
  * Method to fund a user's Solana wallet via Privy's funding feature by inputting a valid wallet address.
38
144
  * You can access the fields and methods documented here via the {@link useFundWallet} hook.
@@ -189,4 +295,4 @@ declare function useSignMessage(callbacks?: PrivyEvents['signSolanaMessage']): {
189
295
  }) => Promise<Uint8Array>;
190
296
  };
191
297
 
192
- export { SolanaTransactionReceipt, SupportedSolanaTransaction, type UseFundWalletInterface, type UseImportWalletInterface, type UseSendTransactionInterface, type UseSignMessageInterface, type UseSignTransactionInterface, useFundWallet, useImportWallet, useSendTransaction, useSignMessage, useSignTransaction, useSolanaFundingPlugin };
298
+ export { PrivyStandardWallet, SolanaTransactionReceipt, SupportedSolanaTransaction, type UseFundWalletInterface, type UseImportWalletInterface, type UsePrivyStandardWalletInterface, type UseSendTransactionInterface, type UseSignMessageInterface, type UseSignTransactionInterface, useFundWallet, useImportWallet, usePrivyStandardWallet, useSendTransaction, useSignMessage, useSignTransaction, useSolanaFundingPlugin };
@@ -380,7 +380,7 @@ type MfaSubmitArgs = {
380
380
  mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'];
381
381
  relyingParty: string;
382
382
  };
383
- type EntropyIdVerifier = 'ethereum-address-verifier' | 'solana-address-verifier' | 'p256';
383
+ type EntropyIdVerifier = 'ethereum-address-verifier' | 'solana-address-verifier';
384
384
  /**
385
385
  * Supported OAuth providers. Can be `'google'`, `'discord'`, `'twitter'`, `'github'`, `'spotify'`,
386
386
  * `'instagram'`, `'tiktok'`, `'linkedin'`, or `'apple'`
@@ -542,7 +542,7 @@ interface Wallet {
542
542
  * 1. 'privy': privy escrow of the recovery material
543
543
  * 2. 'user-passcode': recovery protected by user-input passcode
544
544
  */
545
- recoveryMethod?: 'privy' | UserRecoveryMethod;
545
+ recoveryMethod?: RecoveryMethod;
546
546
  /** Whether the wallet is imported. Only applies to embedded wallets (`walletClientType === 'privy'`). */
547
547
  imported: boolean;
548
548
  /** Whether the wallet is delegated. Only applies to embedded wallets (`walletClientType === 'privy'`). */
@@ -863,9 +863,6 @@ interface CrossAppAccount {
863
863
  providerApp: ProviderAppMetadata;
864
864
  subject: string;
865
865
  }
866
- interface AuthorizationKeyAccount {
867
- publicKey: string;
868
- }
869
866
  /** Object representation of a user's email, with additional metadata for advanced use cases. */
870
867
  interface EmailWithMetadata extends LinkMetadata, Email {
871
868
  /** Denotes that this is an email account. */
@@ -955,15 +952,10 @@ interface CrossAppAccountWithMetadata extends LinkMetadata, CrossAppAccount {
955
952
  /** Denotes that this is a cross-app account */
956
953
  type: 'cross_app';
957
954
  }
958
- /** Object representation of a user's authorization key, with additional metadata for advanced use cases. */
959
- interface AuthorizationKeyAccountWithMetadata extends LinkMetadata, AuthorizationKeyAccount {
960
- /** Denotes that this is an authorization key */
961
- type: 'authorization_key';
962
- }
963
955
  /**
964
956
  * Object representation of a user's linked accounts
965
957
  */
966
- type LinkedAccountWithMetadata = WalletWithMetadata | SmartWalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata | CrossAppAccountWithMetadata | AuthorizationKeyAccountWithMetadata;
958
+ type LinkedAccountWithMetadata = WalletWithMetadata | SmartWalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata | CrossAppAccountWithMetadata;
967
959
  interface User {
968
960
  /** The Privy-issued DID for the user. If you need to store additional information
969
961
  * about a user, you can use this DID to reference them. */
@@ -1764,7 +1756,9 @@ type SendTransactionModalUIOptions = {
1764
1756
  type UnsignedTransactionRequestWithChainId = UnsignedTransactionRequest & {
1765
1757
  chainId: number;
1766
1758
  };
1767
- type LoginModalOptions = RuntimeLoginOverridableOptions;
1759
+ type LoginModalOptions = RuntimeLoginOverridableOptions & {
1760
+ isLedgerSolana?: boolean;
1761
+ };
1768
1762
  type ConnectWalletModalOptions = ExternalConnectWalletModalOptions;
1769
1763
  type PrivyFarcasterSignerInitResponse = {
1770
1764
  public_key: string;
@@ -380,7 +380,7 @@ type MfaSubmitArgs = {
380
380
  mfaCode: string | PasskeyAuthenticateInputType['authenticator_response'];
381
381
  relyingParty: string;
382
382
  };
383
- type EntropyIdVerifier = 'ethereum-address-verifier' | 'solana-address-verifier' | 'p256';
383
+ type EntropyIdVerifier = 'ethereum-address-verifier' | 'solana-address-verifier';
384
384
  /**
385
385
  * Supported OAuth providers. Can be `'google'`, `'discord'`, `'twitter'`, `'github'`, `'spotify'`,
386
386
  * `'instagram'`, `'tiktok'`, `'linkedin'`, or `'apple'`
@@ -542,7 +542,7 @@ interface Wallet {
542
542
  * 1. 'privy': privy escrow of the recovery material
543
543
  * 2. 'user-passcode': recovery protected by user-input passcode
544
544
  */
545
- recoveryMethod?: 'privy' | UserRecoveryMethod;
545
+ recoveryMethod?: RecoveryMethod;
546
546
  /** Whether the wallet is imported. Only applies to embedded wallets (`walletClientType === 'privy'`). */
547
547
  imported: boolean;
548
548
  /** Whether the wallet is delegated. Only applies to embedded wallets (`walletClientType === 'privy'`). */
@@ -863,9 +863,6 @@ interface CrossAppAccount {
863
863
  providerApp: ProviderAppMetadata;
864
864
  subject: string;
865
865
  }
866
- interface AuthorizationKeyAccount {
867
- publicKey: string;
868
- }
869
866
  /** Object representation of a user's email, with additional metadata for advanced use cases. */
870
867
  interface EmailWithMetadata extends LinkMetadata, Email {
871
868
  /** Denotes that this is an email account. */
@@ -955,15 +952,10 @@ interface CrossAppAccountWithMetadata extends LinkMetadata, CrossAppAccount {
955
952
  /** Denotes that this is a cross-app account */
956
953
  type: 'cross_app';
957
954
  }
958
- /** Object representation of a user's authorization key, with additional metadata for advanced use cases. */
959
- interface AuthorizationKeyAccountWithMetadata extends LinkMetadata, AuthorizationKeyAccount {
960
- /** Denotes that this is an authorization key */
961
- type: 'authorization_key';
962
- }
963
955
  /**
964
956
  * Object representation of a user's linked accounts
965
957
  */
966
- type LinkedAccountWithMetadata = WalletWithMetadata | SmartWalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata | CrossAppAccountWithMetadata | AuthorizationKeyAccountWithMetadata;
958
+ type LinkedAccountWithMetadata = WalletWithMetadata | SmartWalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata | CrossAppAccountWithMetadata;
967
959
  interface User {
968
960
  /** The Privy-issued DID for the user. If you need to store additional information
969
961
  * about a user, you can use this DID to reference them. */
@@ -1764,7 +1756,9 @@ type SendTransactionModalUIOptions = {
1764
1756
  type UnsignedTransactionRequestWithChainId = UnsignedTransactionRequest & {
1765
1757
  chainId: number;
1766
1758
  };
1767
- type LoginModalOptions = RuntimeLoginOverridableOptions;
1759
+ type LoginModalOptions = RuntimeLoginOverridableOptions & {
1760
+ isLedgerSolana?: boolean;
1761
+ };
1768
1762
  type ConnectWalletModalOptions = ExternalConnectWalletModalOptions;
1769
1763
  type PrivyFarcasterSignerInitResponse = {
1770
1764
  public_key: string;
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-B6jqW_Bc.js';
2
+ import { R as RuntimeLoginOverridableOptions } from './types-Nqh9YCV3.js';
3
3
  import { Hex } from 'viem';
4
4
  import { Chain, Cluster } from '@privy-io/js-sdk-core';
5
5
  import '@solana/wallet-adapter-base';
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-B6jqW_Bc.js';
2
+ import { R as RuntimeLoginOverridableOptions } from './types-Nqh9YCV3.js';
3
3
  import { Hex } from 'viem';
4
4
  import { Chain, Cluster } from '@privy-io/js-sdk-core';
5
5
  import '@solana/wallet-adapter-base';
@@ -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-B6jqW_Bc.js';
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-Nqh9YCV3.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-B6jqW_Bc.js';
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-Nqh9YCV3.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,f as l,l as d,an as m,m as p,a as u,av as h,aw as I,ax as g,n as y}from"./privy-provider-B9IzlOpv.mjs";import{u as f}from"./internal-context-eu0bC04Q.mjs";import{g as v}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import{c as w}from"./smart-wallets-D0LqwcPM.mjs";import"react/jsx-runtime";import"mipd";import"react";import"react-device-detect";import"viem/utils";import"@privy-io/js-sdk-core";import"uuid";import"jose";import"eventemitter3";import"@coinbase/wallet-sdk";import"@marsidev/react-turnstile";import"styled-components";import"tinycolor2";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@headlessui/react";import"@walletconnect/ethereum-provider";import"zustand";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"qrcode";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";function C(){let{user:C}=s(),{hideWalletUIs:T,openPrivyModal:P,chains:S,appId:b,rpcConfig:A,client:M}=f(),k=l(),{wallets:F}=d(),{setModalData:W}=m(),x=p(C),E=async(o=c.id)=>{let s=v(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=S.find((e=>e.id===l));if(!d)throw Error("Chain not configured");await s.switchChain(d.id);let m=await s.getEthereumProvider(),p=t({account:s.address,transport:n(m)}),u=a({address:s.address,signMessage:p.signMessage,signTransaction:p.signTransaction,signTypedData:p.signTypedData});return await e({chain:d,transport:i(y(d,A,b)),publicTransport:i(y(d,A,b)),signer:u})};return{signMessage:async({message:e},o)=>{let r=await E(o);return new Promise((async(o,t)=>{let{entropyId:n,entropyIdVerifier:i}=u(C);T.current=!0,W({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"personal_sign",data:e,confirmAndSign:()=>r.signMessage({message:e}),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{T.current=!1}))},signTypedData:async(e,o)=>{let r=await E(o);return new Promise((async(o,t)=>{T.current=!0;let{entropyId:n,entropyIdVerifier:i}=u(C);W({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,entropyId:n,entropyIdVerifier:i,onCompleteNavigateTo:h,onFailure:()=>{}},signMessage:{method:"eth_signTypedData_v4",data:e,confirmAndSign:()=>r.signTypedData(e),onSuccess:e=>o(e),onFailure:t,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{T.current=!1}))},sendTransaction:async e=>{let r=await E(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{T.current=!0;let{entropyId:c,entropyIdVerifier:s}=u(C);W({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,entropyId:c,entropyIdVerifier:s,onCompleteNavigateTo:g,onFailure:()=>{}},sendTransaction:{transactionRequests:w({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,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:i.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data,eip_712_meta:{paymaster_params:{paymaster:i.paymaster,paymaster_input:i.paymasterInput}}}]}})},signOnly:!1,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>n?r.sendTransactionBatch(e):r.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:a,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{T.current=!1}))},signTransaction:async e=>{let r=await E(e.chainId),t=[],n="calls"in e&&void 0!==e.calls;return t=n?[...e.calls]:[e],new Promise((async(i,a)=>{T.current=!0;let{entropyId:c,entropyIdVerifier:s}=u(C);W({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,entropyId:c,entropyIdVerifier:s,onCompleteNavigateTo:g,onFailure:()=>{}},sendTransaction:{transactionRequests:w({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,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:i.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:()=>{if(!n)return r.signTransaction(e);throw Error("Batch transactions not supported for signing")},onSuccess:e=>i(e.hash),onFailure:a,uiOptions:{isCancellable:!0}}}),P(I)})).finally((()=>{T.current=!1}))}}}export{C 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,f as l,l as d,at as m,m as p,t as u,a as h,aE as I,aF as g,aG as y,n as f}from"./privy-provider-CE4-s2JH.mjs";import{u as v}from"./internal-context-lAHxpYRu.mjs";import{g as w}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import{c as C}from"./smart-wallets-C2dDEs0t.mjs";import"react/jsx-runtime";import"mipd";import"react";import"react-device-detect";import"viem/utils";import"@privy-io/js-sdk-core";import"uuid";import"jose";import"eventemitter3";import"@coinbase/wallet-sdk";import"@marsidev/react-turnstile";import"styled-components";import"tinycolor2";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@headlessui/react";import"@walletconnect/ethereum-provider";import"zustand";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"qrcode";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";import"permissionless";import"permissionless/accounts";import"permissionless/clients/pimlico";import"viem/account-abstraction";function T(){let{user:T}=s(),{hideWalletUIs:P,openPrivyModal:S,chains:W,appId:b,rpcConfig:A,client:M}=v(),k=l(),{wallets:F}=d(),{setModalData:E}=m(),x=p(T),D=!!x&&u(x),_=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=W.find((e=>e.id===l));if(!d)throw Error("Chain not configured");await s.switchChain(d.id);let m=await s.getEthereumProvider(),p=t({account:s.address,transport:n(m)}),u=a({address:s.address,signMessage:p.signMessage,signTransaction:p.signTransaction,signTypedData:p.signTypedData});return await e({chain:d,transport:i(f(d,A,b)),publicTransport:i(f(d,A,b)),signer:u})};return{signMessage:async({message:e},o)=>{let r=await _(o);return new Promise((async(o,t)=>{let{entropyId:n,entropyIdVerifier:i}=h(T);P.current=!0,E({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:D,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 _(o);return new Promise((async(o,t)=>{P.current=!0;let{entropyId:n,entropyIdVerifier:i}=h(T);E({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:D,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 _(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);E({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:D,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,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:i.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:i.from,to:i.to,value:i.value?.toString(),gas:i.gas?.toString(),gasPrice:i.gasPrice?.toString(),nonce:i.nonce?.toString(),data:i.data,eip_712_meta:{paymaster_params:{paymaster:i.paymaster,paymaster_input:i.paymasterInput}}}]}})},signOnly:!1,getIsSponsored:async()=>void 0!==e.paymaster&&void 0!==e.paymasterInput,onConfirm:()=>n?r.sendTransactionBatch(e):r.sendTransaction(e),onSuccess:e=>i(e.hash),onFailure:a,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))},signTransaction:async e=>{let r=await _(e.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);E({connectWallet:{recoveryMethod:x.recoveryMethod,connectingWalletAddress:x.address,isUnifiedWallet:D,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,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:i.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:()=>{if(!n)return r.signTransaction(e);throw Error("Batch transactions not supported for signing")},onSuccess:e=>i(e.hash),onFailure:a,uiOptions:{isCancellable:!0}}}),S(g)})).finally((()=>{P.current=!1}))}}}export{T as useAbstractSmartWallets};
@@ -1 +1 @@
1
- import{useCallback as t}from"react";import{F as e}from"./frame-BeG8p5X6.mjs";import{u as i,P as r}from"./internal-context-eu0bC04Q.mjs";import"ofetch";const a=()=>{let{client:a,setAuthenticated:n,setUser:s}=i();return{initLoginToFrame:t((async()=>{let t=new e;if(!a)throw new r("Must initialize Privy client first.");return a.startAuthFlow(t),await t.init()}),[a]),loginToFrame:t((async({message:t,signature:i})=>{if(!a)throw new r("Must initialize Privy client first.");if(!(a.authFlow instanceof e))throw new r("Must initialize Farcaster frame flow first.");let o=(t=>{let e=t.match(/farcaster:\/\/fid\/(\d+)/);return e&&e[1]?parseInt(e[1],10):null})(t);if(!o)throw new r("Invalid message format; could not parse Farcaster ID.");a.authFlow.setAuthData({message:t,signature:i,fid:o});let{user:l}=await a.authenticate();return l&&(s(l),n(!0)),l}),[a,s,n])}};export{a as useLoginToFrame};
1
+ import{useCallback as t}from"react";import{F as e}from"./frame-B1kjU0LI.mjs";import{u as i,P as r}from"./internal-context-lAHxpYRu.mjs";import"ofetch";const a=()=>{let{client:a,setAuthenticated:n,setUser:s}=i();return{initLoginToFrame:t((async()=>{let t=new e;if(!a)throw new r("Must initialize Privy client first.");return a.startAuthFlow(t),await t.init()}),[a]),loginToFrame:t((async({message:t,signature:i})=>{if(!a)throw new r("Must initialize Privy client first.");if(!(a.authFlow instanceof e))throw new r("Must initialize Farcaster frame flow first.");let o=(t=>{let e=t.match(/farcaster:\/\/fid\/(\d+)/);return e&&e[1]?parseInt(e[1],10):null})(t);if(!o)throw new r("Invalid message format; could not parse Farcaster ID.");a.authFlow.setAuthData({message:t,signature:i,fid:o});let{user:l}=await a.authenticate();return l&&(s(l),n(!0)),l}),[a,s,n])}};export{a as useLoginToFrame};
@@ -1 +1 @@
1
- import{P as t,am as s,an as i,f as e}from"./internal-context-eu0bC04Q.mjs";class a{async init(){if(!this.api)throw new t("Auth flow has no API instance");let{nonce:i,expires_at:e}=await this.api.post(s,{});return{nonce:i,expiresAt:e}}async authenticate(){if(!this.message||!this.signature||!this.fid)throw new t("Auth flow has no message, signature, or fid");if(!this.api)throw new t("Auth flow has no API instance");try{let s=await this.api.post(i,{message:this.message,signature:this.signature,fid:this.fid});if(!s)throw new t("No response from authentication");return s}catch(t){throw e(t)}}async link(){throw Error("Not implemented")}setAuthData({message:t,signature:s,fid:i}){this.message=t,this.signature=s,this.fid=i}constructor(){this.meta={}}}export{a as F};
1
+ import{P as t,am as s,an as i,f as e}from"./internal-context-lAHxpYRu.mjs";class a{async init(){if(!this.api)throw new t("Auth flow has no API instance");let{nonce:i,expires_at:e}=await this.api.post(s,{});return{nonce:i,expiresAt:e}}async authenticate(){if(!this.message||!this.signature||!this.fid)throw new t("Auth flow has no message, signature, or fid");if(!this.api)throw new t("Auth flow has no API instance");try{let s=await this.api.post(i,{message:this.message,signature:this.signature,fid:this.fid});if(!s)throw new t("No response from authentication");return s}catch(t){throw e(t)}}async link(){throw Error("Not implemented")}setAuthData({message:t,signature:s,fid:i}){this.message=t,this.signature=s,this.fid=i}constructor(){this.meta={}}}export{a as F};
@@ -1 +1 @@
1
- import{u as e,g as o,a as i,b as n,c as s,d as l,C as h,e as d,s as p,P as m,f as k,h as C,i as f,G as T,W,j as U,k as R,l as S,m as P,n as O,o as _,p as j}from"./privy-provider-B9IzlOpv.mjs";export{t as Captcha,v as ConnectorManager,E as EthereumWalletConnector,N as LoginModal,F as PrivyClient,q as PrivyProvider,V as VERSION,w as WalletConnector,B as errorIndicatesMaxMfaRetries,D as errorIndicatesMfaTimeout,A as errorIndicatesMfaVerificationFailed,r as getAccessToken,K as useCreateWallet,H as useIdentityToken,M as useImportWallet,I as useLogout,y as useMfa,z as useMfaEnrollment,x as usePrivy,J as useRegisterMfaListener,L as useSolanaWallets}from"./privy-provider-B9IzlOpv.mjs";import{useCallback as G,useMemo as Q,useEffect as X,useContext as $,useRef as Y}from"react";import{u as Z,P as ee,a as te,I as re}from"./internal-context-eu0bC04Q.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-Cvm0O_EX.mjs";import{F as oe}from"./frame-BeG8p5X6.mjs";import{zeroAddress as ie,getAddress as ae,createWalletClient as ne,http as se,parseSignature as ce}from"viem";import{hashAuthorization as le}from"viem/utils";export{DEFAULT_SUPPORTED_CHAINS as SUPPORTED_CHAINS,addPrivyRpcToChain,addRpcUrlOverrideToChain}from"@privy-io/js-sdk-core";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"react/jsx-runtime";import"mipd";import"react-device-detect";import"uuid";import"jose";import"eventemitter3";import"@coinbase/wallet-sdk";import"@marsidev/react-turnstile";import"styled-components";import"tinycolor2";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@headlessui/react";import"@walletconnect/ethereum-provider";import"zustand";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"qrcode";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const ue=()=>{let{user:t}=e(),{walletProxy:r}=Z();return{recover:G((async e=>{if(!r)throw Error("Wallet proxy is not ready");let a=await o();if(!t||!a)throw new ee("User must be logged in before attempting to modify the recovery method.");let{entropyId:n,entropyIdVerifier:s}=i(t);try{await r.recover({entropyId:n,entropyIdVerifier:s,accessToken:a,...e})}catch{throw new ee("Unable to recover wallets")}}),[r,t])}},he=()=>{let{client:e,setAuthenticated:t,setUser:r}=Z();return Q((()=>({init:async()=>{if(!e)throw new ee("Must initialize Privy client first.");let t=new oe;return e.startAuthFlow(t),await t.init()},login:async({fid:o,message:i,signature:a})=>{if(!e)throw new ee("Must initialize Privy client first.");if(!(e.authFlow instanceof oe))throw new ee("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:i,signature:a,fid:o});let{user:n}=await e.authenticate();if(!n)throw new ee("Failed to login with Farcaster V2");return r(n),t(!0),{user:n}}})),[e,r,t])},de=t=>{n("login",t);let r=s(),o=l(),{ready:i,user:a}=e(),{initLoginWithHeadlessOAuth:c,loginWithHeadlessOAuth:u,oAuthState:w,setOAuthState:g,isHeadlessOAuthLoading:m}=Z(),y=G((async e=>{try{if(r.enabled&&"success"!==r.status)throw new h(r.error,null,te.CAPTCHA_FAILURE);return await c(e.provider,r.token,e.disableSignup)}catch(e){throw g({status:"error",error:e}),e}}),[c,r]),A=G((async()=>{let e=d();try{if(a)return console.warn("Cannot login with OAuth when already logged in"),a;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw g({status:"error",error:e}),e}try{return await u(e)}catch(e){throw g({status:"error",error:e}),e}finally{p()}}),[u]);return X((()=>{let e=d();i&&o&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&A().catch((()=>{}))}),[i,o]),{initOAuth:y,loading:m,state:w}},pe=e=>{let t=s(),{emailOtpState:r,setEmailOtpState:o,initLoginWithEmail:i,loginWithCode:a}=Z();return{sendCode:G((async({email:r,disableSignup:a})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({email:r,captchaToken:e,disableSignup:a,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||te.UNKNOWN_AUTH_ERROR),r}}),[i]),loginWithCode:G((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:n,linkedAccount:s}=await a(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:n,loginMethod:"email",loginAccount:s})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||te.UNKNOWN_AUTH_ERROR),r}}),[a,t.status]),state:r}},we=e=>{let t=s(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:i,setPasskeyAuthState:a}=Z();return{signupWithPasskey:G((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await r({captchaToken:i,withPrivyUi:!1});let{user:a,isNewUser:n,wasAlreadyAuthenticated:s,loginAccount:c}=await o();e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:s,loginMethod:"passkey",loginAccount:c})}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||te.UNKNOWN_AUTH_ERROR),t}}),[o,t.status]),state:i}},ge=e=>{let t=s(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:i,setPasskeyAuthState:a}=Z();return{loginWithPasskey:G((async i=>{try{let a;if(t.enabled&&"error"===t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await r({captchaToken:a,withPrivyUi:!1});let{user:n,isNewUser:s,wasAlreadyAuthenticated:c,loginAccount:l}=await o(i);e?.onComplete?.({user:n,isNewUser:s,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:l})}catch(i){throw a({status:"error",error:i}),e?.onError?.(i.privyErrorCode||te.UNKNOWN_AUTH_ERROR),i}}),[o,t.status]),state:i}},me=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:o,setPasskeyAuthState:i}=Z();return{linkWithPasskey:G((async()=>{try{await t();let o=await r();if(!o)throw Error("Error, user not found");let i=o.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:o,linkMethod:"passkey",linkedAccount:i})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||te.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:o}},ye=e=>{let t=s(),{smsOtpState:r,setSmsOtpState:o,initLoginWithSms:i,loginWithCode:a}=Z();return{sendCode:G((async({phoneNumber:r,disableSignup:a})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await i({phoneNumber:r,captchaToken:e,disableSignup:a,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||te.UNKNOWN_AUTH_ERROR),r}}),[i]),loginWithCode:G((async({code:r})=>{try{if(t.enabled&&"success"!==t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:n,linkedAccount:s}=await a(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:n,loginMethod:"sms",loginAccount:s})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||te.UNKNOWN_AUTH_ERROR),r}}),[a,t.status]),state:r}},Ae=t=>{let{connectOrCreateWallet:r}=e();return n("connectOrCreateWallet",t),{connectOrCreateWallet:r}},ke=e=>{let t=s(),{siweState:r,setSiweState:o,linkWithSiwe:i,generateSiweMessage:a}=Z();return{generateSiweMessage:G((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await a({address:t,chainId:r}).then((e=>e))}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||te.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[a]),linkWithSiwe:G((async({signature:r,message:a,chainId:n,walletClientType:s,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);let{user:o,linkedAccount:l}=await i({message:a,signature:r,chainId:n,walletClientType:s,connectorType:c});l&&e?.onSuccess?.({user:o,linkMethod:"siwe",linkedAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||te.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[i,t.status]),state:r}},Ce=e=>{let t=s(),{siweState:r,setSiweState:o,client:i,generateSiweMessage:a,loginWithSiwe:n}=Z();return{generateSiweNonce:G((async({address:r})=>{try{let e;if(t.enabled&&"error"===t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),o({status:"generating-message"});let a=await i.generateSiweNonce({address:r,captchaToken:e});return o({status:"awaiting-signature"}),a}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||te.UNKNOWN_AUTH_ERROR),r}}),[i,t]),generateSiweMessage:G((async({address:t,chainId:r})=>{try{return await a({address:t,chainId:r})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||te.UNKNOWN_AUTH_ERROR),t}}),[a]),loginWithSiwe:G((async({message:r,signature:i,disableSignup:a})=>{try{let o;if(t.enabled&&"error"===t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),o=await t.waitForResult());let s=await n({message:r,signature:i,captchaToken:o,disableSignup:a});return e?.onComplete?.({user:s,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),s}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||te.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}};function fe(){let{signTransaction:e}=$(m);return{signTransaction:e}}function Ie(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:i,linkApple:a,linkTwitter:s,linkDiscord:c,linkGithub:l,linkLinkedIn:u,linkTiktok:h,linkSpotify:d,linkInstagram:p,linkTelegram:w,linkFarcaster:g}=$(m);return n("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:i,linkApple:a,linkTwitter:s,linkDiscord:c,linkGithub:l,linkLinkedIn:u,linkTiktok:h,linkSpotify:d,linkInstagram:p,linkFarcaster:g,linkTelegram:w}}function Ee(e){let{updateEmail:t,updatePhone:r}=$(m);return n("update",e),{updateEmail:t,updatePhone:r}}const Te=()=>{let{connectCoinbaseSmartWallet:e}=Z();return{connectCoinbaseSmartWallet:e}},We=()=>{let{startCrossAppAuthFlow:t,unlinkCrossAppAccount:r,signMessageWithCrossAppWallet:o,signTypedDataWithCrossAppWallet:i,sendTransactionWithCrossAppWallet:a}=e();return{loginWithCrossAppAccount:({appId:e})=>t({appId:e,action:"login"}),linkCrossAppAccount:({appId:e})=>t({appId:e,action:"link"}),unlinkCrossAppAccount:r,signMessage:o,signTypedData:i,sendTransaction:a}};function Ue(e){let{sendTransaction:t}=$(m);return n("sendTransaction",e),{sendTransaction:t}}function Re(e){let{setWalletPassword:t}=$(m);return n("setWalletPassword",e),{setWalletPassword:t}}function Se(){let t=k(),{getAccessToken:r}=e(),o=C(),{client:i,setUser:a,setAuthenticated:n,setIsNewUser:s,initializeWalletProxy:c}=Z(),{create:l}=f();return{createGuestAccount:async()=>{if(!t.id||!i)throw Error("SDK not yet ready");i.startAuthFlow(new T(t.id));try{let e=await i.authenticate(),u=e.user,h=e.isNewUser??!1;if(!u)throw new ee("Unable to authenticate guest account");let d=await r(),p=await c(W);if(d&&p)try{let e=U(u,t.embeddedWallets.ethereum.createOnLogin),r=R(u,t.embeddedWallets.solana.createOnLogin);e&&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:e?u=(await l({chainType:"ethereum",latestUser:u})).user:a(u)}catch(e){a(u),console.warn("Unable to create embedded wallet for guest account")}return s(h),n(!0),o("login","onComplete",{user:u,isNewUser:h,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw o("login","onError",e.privyErrorCode||te.UNKNOWN_AUTH_ERROR),e}}}}function Ne(e){let{setWalletRecovery:t}=$(m);return n("setWalletRecovery",e),{setWalletRecovery:t}}function Pe(e){let{signMessage:t}=$(m);return n("signMessage",e),{signMessage:t}}const ve=()=>{let{ready:t,wallets:r}=S(),{user:o}=e(),{rpcConfig:i,chains:a,appId:n}=Z();return{signAuthorization:G((async(e,s)=>{if(!o)throw Error("User must be authenticated before signing with a Privy wallet");if(!t)throw Error("Wallets are not ready");let c=s?.address??P(o)?.address??ie,l=r.find((e=>ae(e.address)===ae(c)));if(!l)throw Error("Signing wallet not found.");let u=e.chainId??Number(l.chainId.split(":")[1]),h=a.find((e=>e.id===u));if(!h)throw Error("Error, chain not configured in PrivyProvider config");let d=ne({account:c,chain:h,transport:se(O(h,i,n))}),p=await d.prepareAuthorization({...e}),w=await l.getEthereumProvider(),g=await w.request({method:"secp256k1_sign",params:[le(p)]});return{...p,...ce(g)}}),[t,r,o,a])}};function be(e){let{signTypedData:t}=$(m);return n("signTypedData",e),{signTypedData:t}}const Oe=()=>{let{isModalOpen:e}=$(m);return{isOpen:e}};function _e(e){let{getAccessToken:t}=$(m);return n("accessToken",e),{getAccessToken:t}}function Me(t){let{authenticated:r,user:o}=e(),{initLoginWithOAuth:i}=Z(),a=C();return n("oAuthAuthorization",t),{reauthorize:e=>Fe(r,o,i,a,e.provider)}}let Fe=async(e,t,r,o,i)=>{if(!e)throw o("linkAccount","onError",te.MUST_BE_AUTHENTICATED,{linkMethod:i}),new ee("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new ee(`OAuth account of type ${i} not linked to the account.`);await r(i)};const Le=e=>{let t=_();return n("customAuth",e),{status:t}};function He({isAuthenticated:e,isLoading:t,...r}){let o=Y();X((()=>{t||o.current?.()}),[e,t]);let i=G((e=>(o.current=e,()=>{o.current=void 0})),[]);return j({...r,subscribe:i})}function De(){let{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}=e();return{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}}const xe=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=Z();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Ke=()=>{let{setUser:e,client:t}=$(re),{user:r}=$(m);return{user:r,refreshUser:G((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},je=e=>{let t=s(),{initLoginWithTelegram:r,loginWithTelegram:o,telegramAuthState:i,setTelegramAuthState:a}=Z();return{login:G((async i=>{try{if(t.enabled&&"success"!==t.status)throw new h(t.error,null,te.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:a,isNewUser:n,loginAccount:s,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:s})}catch(i){throw a({status:"error",error:i}),e?.onError?.(i.privyErrorCode||te.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:i}},qe=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=Z();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{Te as useConnectCoinbaseSmartWallet,Ae as useConnectOrCreateWallet,We as useCrossAppAccounts,Le as useCustomAuth,xe as useDelegatedActions,De as useFarcasterSigner,Se as useGuestAccounts,qe as useHeadlessDelegatedActions,Ie as useLinkAccount,me as useLinkWithPasskey,ke as useLinkWithSiwe,pe as useLoginWithEmail,he as useLoginWithFarcasterV2,de as useLoginWithOAuth,ge as useLoginWithPasskey,Ce as useLoginWithSiwe,ye as useLoginWithSms,je as useLoginWithTelegram,Oe as useModalStatus,Me as useOAuthTokens,ue as useRecoverEmbeddedWallet,Ue as useSendTransaction,Re as useSetWalletPassword,Ne as useSetWalletRecovery,ve as useSignAuthorization,Pe as useSignMessage,fe as useSignTransaction,be as useSignTypedData,we as useSignupWithPasskey,He as useSubscribeToJwtAuthWithFlag,j as useSyncJwtBasedAuthState,_e as useToken,Ee as useUpdateAccount,Ke as useUser,S as useWallets};
1
+ import{u as e,g as t,a as r,b as o,c as i,d as n,C as s,e as l,s as d,P as h,f as w,h as p,i as m,G as f,W as k,j as C,k as W,l as v,m as P,n as _,o as x,p as j,q,r as G,t as X,v as $,w as Y,x as Z}from"./privy-provider-CE4-s2JH.mjs";export{A as Captcha,B as ConnectorManager,E as EthereumWalletConnector,U as LoginModal,M as PrivyClient,y as PrivyProvider,V as VERSION,D as WalletConnector,K as errorIndicatesMaxMfaRetries,L as errorIndicatesMfaTimeout,J as errorIndicatesMfaVerificationFailed,z as getAccessToken,R as useCreateWallet,N as useIdentityToken,T as useImportWallet,O as useLogout,H as useMfa,I as useMfaEnrollment,F as usePrivy,Q as useRegisterMfaListener,S as useSolanaWallets}from"./privy-provider-CE4-s2JH.mjs";import{useCallback as ee,useMemo as te,useEffect as re,useContext as oe,useRef as ie}from"react";import{u as ae,P as ne,a as se,I as le}from"./internal-context-lAHxpYRu.mjs";export{c as useActiveWallet,a as useConnectWallet,b as useFundWallet,u as useLogin}from"./useActiveWallet-B62Sy0KW.mjs";import{F as ce}from"./frame-B1kjU0LI.mjs";import{zeroAddress as ue,getAddress as de,createWalletClient as he,http as we,parseSignature as pe}from"viem";import{hashAuthorization as ge}from"viem/utils";import{getWallet as me,updateWallet as ye}from"@privy-io/js-sdk-core";export{DEFAULT_SUPPORTED_CHAINS as SUPPORTED_CHAINS,addPrivyRpcToChain,addRpcUrlOverrideToChain}from"@privy-io/js-sdk-core";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"react/jsx-runtime";import"mipd";import"react-device-detect";import"uuid";import"jose";import"eventemitter3";import"@coinbase/wallet-sdk";import"@marsidev/react-turnstile";import"styled-components";import"tinycolor2";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@heroicons/react/24/outline/ChevronDownIcon";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"@headlessui/react";import"@walletconnect/ethereum-provider";import"zustand";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/UserCircleIcon";import"@heroicons/react/24/outline/EnvelopeIcon";import"@heroicons/react/20/solid/CheckIcon";import"@heroicons/react/24/outline/WalletIcon";import"@heroicons/react/24/outline/CheckIcon";import"@heroicons/react/24/outline/Square2StackIcon";import"@heroicons/react/24/outline/ExclamationCircleIcon";import"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import"@heroicons/react/24/solid/DocumentCheckIcon";import"@heroicons/react/24/solid/XCircleIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"qrcode";import"@heroicons/react/24/outline/ChevronRightIcon";import"@heroicons/react/24/outline/LockClosedIcon";import"@heroicons/react/24/outline/PencilSquareIcon";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/LockClosedIcon";import"@heroicons/react/24/outline/CheckCircleIcon";import"@heroicons/react/24/outline/InformationCircleIcon";import"@heroicons/react/24/outline/CreditCardIcon";import"@heroicons/react/24/outline/QrCodeIcon";import"@heroicons/react/24/solid/ArrowsRightLeftIcon";import"@heroicons/react/24/outline/GlobeAltIcon";import"ofetch";import"@heroicons/react/24/outline";import"@heroicons/react/24/outline/ClipboardDocumentIcon";import"@heroicons/react/24/outline/CloudArrowUpIcon";import"@heroicons/react/24/outline/NoSymbolIcon";import"@heroicons/react/24/outline/ClockIcon";import"@heroicons/react/24/outline/TrashIcon";import"@heroicons/react/24/solid/CheckBadgeIcon";import"@heroicons/react/24/solid/IdentificationIcon";import"@heroicons/react/24/outline/MinusCircleIcon";import"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import"@heroicons/react/24/solid/ShieldCheckIcon";import"js-cookie";const Ae=()=>{let{user:o}=e(),{walletProxy:i}=ae();return{recover:ee((async e=>{if(!i)throw Error("Wallet proxy is not ready");let a=await t();if(!o||!a)throw new ne("User must be logged in before attempting to modify the recovery method.");let{entropyId:n,entropyIdVerifier:s}=r(o);try{await i.recover({entropyId:n,entropyIdVerifier:s,accessToken:a,...e})}catch{throw new ne("Unable to recover wallets")}}),[i,o])}},fe=()=>{let{client:e,setAuthenticated:t,setUser:r}=ae();return te((()=>({init:async()=>{if(!e)throw new ne("Must initialize Privy client first.");let t=new ce;return e.startAuthFlow(t),await t.init()},login:async({fid:o,message:i,signature:a})=>{if(!e)throw new ne("Must initialize Privy client first.");if(!(e.authFlow instanceof ce))throw new ne("Must initialize Farcaster frame flow first.");e.authFlow.setAuthData({message:i,signature:a,fid:o});let{user:n}=await e.authenticate();if(!n)throw new ne("Failed to login with Farcaster V2");return r(n),t(!0),{user:n}}})),[e,r,t])},ke=t=>{o("login",t);let r=i(),a=n(),{ready:c,user:u}=e(),{initLoginWithHeadlessOAuth:h,loginWithHeadlessOAuth:w,oAuthState:p,setOAuthState:g,isHeadlessOAuthLoading:m}=ae(),y=ee((async e=>{try{if(r.enabled&&"success"!==r.status)throw new s(r.error,null,se.CAPTCHA_FAILURE);return await h(e.provider,r.token,e.disableSignup)}catch(e){throw g({status:"error",error:e}),e}}),[h,r]),A=ee((async()=>{let e=l();try{if(u)return console.warn("Cannot login with OAuth when already logged in"),u;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw g({status:"error",error:e}),e}try{return await w(e)}catch(e){throw g({status:"error",error:e}),e}finally{d()}}),[w]);return re((()=>{let e=l();c&&a&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&A().catch((()=>{}))}),[c,a]),{initOAuth:y,loading:m,state:p}},Ce=e=>{let t=i(),{emailOtpState:r,setEmailOtpState:o,initLoginWithEmail:a,loginWithCode:n}=ae();return{sendCode:ee((async({email:r,disableSignup:i})=>{try{let e;if(!r)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({email:r,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:ee((async({code:r})=>{try{if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await n(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"email",loginAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},Ie=e=>{let t=i(),{initSignupWithPasskey:r,signupWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:n}=ae();return{signupWithPasskey:ee((async()=>{try{let i;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await r({captchaToken:i,withPrivyUi:!1});let{user:a,isNewUser:n,wasAlreadyAuthenticated:l,loginAccount:c}=await o();e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw n({status:"error",error:t}),e?.onError?.(t.privyErrorCode||se.UNKNOWN_AUTH_ERROR),t}}),[o,t.status]),state:a}},We=e=>{let t=i(),{initLoginWithPasskey:r,loginWithPasskey:o,passkeyAuthState:a,setPasskeyAuthState:n}=ae();return{loginWithPasskey:ee((async i=>{try{let a;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await r({captchaToken:a,withPrivyUi:!1});let{user:n,isNewUser:l,wasAlreadyAuthenticated:c,loginAccount:u}=await o(i);e?.onComplete?.({user:n,isNewUser:l,wasAlreadyAuthenticated:c,loginMethod:"passkey",loginAccount:u})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||se.UNKNOWN_AUTH_ERROR),i}}),[o,t.status]),state:a}},Ee=e=>{let{initLinkWithPasskey:t,linkWithPasskey:r,passkeyAuthState:o,setPasskeyAuthState:i}=ae();return{linkWithPasskey:ee((async()=>{try{await t();let o=await r();if(!o)throw Error("Error, user not found");let i=o.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:o,linkMethod:"passkey",linkedAccount:i})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||se.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[r]),state:o}},Te=e=>{let t=i(),{smsOtpState:r,setSmsOtpState:o,initLoginWithSms:a,loginWithCode:n}=ae();return{sendCode:ee((async({phoneNumber:r,disableSignup:i})=>{try{let e;if(!r)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({phoneNumber:r,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR),r}}),[a]),loginWithCode:ee((async({code:r})=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);let{user:o,isNewUser:i,wasAlreadyAuthenticated:a,linkedAccount:l}=await n(r);e?.onComplete?.({user:o,isNewUser:i,wasAlreadyAuthenticated:a,loginMethod:"sms",loginAccount:l})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR),r}}),[n,t.status]),state:r}},Ue=t=>{let{connectOrCreateWallet:r}=e();return o("connectOrCreateWallet",t),{connectOrCreateWallet:r}},Se=e=>{let t=i(),{siweState:r,setSiweState:o,linkWithSiwe:a,generateSiweMessage:n}=ae();return{generateSiweMessage:ee((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await n({address:t,chainId:r}).then((e=>e))}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||se.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[n]),linkWithSiwe:ee((async({signature:r,message:i,chainId:n,walletClientType:l,connectorType:c})=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);let{user:o,linkedAccount:u}=await a({message:i,signature:r,chainId:n,walletClientType:l,connectorType:c});u&&e?.onSuccess?.({user:o,linkMethod:"siwe",linkedAccount:u})}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),r}}),[a,t.status]),state:r}},ve=e=>{let t=i(),{siweState:r,setSiweState:o,client:a,generateSiweMessage:n,loginWithSiwe:l}=ae();return{generateSiweNonce:ee((async({address:r})=>{try{let e;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),o({status:"generating-message"});let i=await a.generateSiweNonce({address:r,captchaToken:e});return o({status:"awaiting-signature"}),i}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR),r}}),[a,t]),generateSiweMessage:ee((async({address:t,chainId:r})=>{try{return await n({address:t,chainId:r})}catch(t){throw o({status:"error",error:t}),e?.onError?.(t.privyErrorCode||se.UNKNOWN_AUTH_ERROR),t}}),[n]),loginWithSiwe:ee((async({message:r,signature:i,disableSignup:a})=>{try{let o;if(t.enabled&&"error"===t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),o=await t.waitForResult());let n=await l({message:r,signature:i,captchaToken:o,disableSignup:a});return e?.onComplete?.({user:n,isNewUser:!1,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),n}catch(r){throw o({status:"error",error:r}),e?.onError?.(r.privyErrorCode||se.UNKNOWN_AUTH_ERROR),r}}),[l,t.status]),state:r}};function Re(){let{signTransaction:e}=oe(h);return{signTransaction:e}}function Pe(e){let{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:n,linkTwitter:s,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:w,linkInstagram:p,linkTelegram:g,linkFarcaster:m}=oe(h);return o("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:i,linkGoogle:a,linkApple:n,linkTwitter:s,linkDiscord:l,linkGithub:c,linkLinkedIn:u,linkTiktok:d,linkSpotify:w,linkInstagram:p,linkFarcaster:m,linkTelegram:g}}function be(e){let{updateEmail:t,updatePhone:r}=oe(h);return o("update",e),{updateEmail:t,updatePhone:r}}const Ne=()=>{let{connectCoinbaseSmartWallet:e}=ae();return{connectCoinbaseSmartWallet:e}},Oe=()=>{let{startCrossAppAuthFlow:t,unlinkCrossAppAccount:r,signMessageWithCrossAppWallet:o,signTypedDataWithCrossAppWallet:i,sendTransactionWithCrossAppWallet:a}=e();return{loginWithCrossAppAccount:({appId:e})=>t({appId:e,action:"login"}),linkCrossAppAccount:({appId:e})=>t({appId:e,action:"link"}),unlinkCrossAppAccount:r,signMessage:o,signTypedData:i,sendTransaction:a}};function _e(e){let{sendTransaction:t}=oe(h);return o("sendTransaction",e),{sendTransaction:t}}function Me(e){let{setWalletPassword:t}=oe(h);return o("setWalletPassword",e),{setWalletPassword:t}}function Fe(){let t=w(),{getAccessToken:r}=e(),o=p(),{client:i,setUser:a,setAuthenticated:n,setIsNewUser:s,initializeWalletProxy:l}=ae(),{create:c}=m();return{createGuestAccount:async()=>{if(!t.id||!i)throw Error("SDK not yet ready");i.startAuthFlow(new f(t.id));try{let e=await i.authenticate(),u=e.user,d=e.isNewUser??!1;if(!u)throw new ne("Unable to authenticate guest account");let h=await r(),w=await l(k);if(h&&w)try{let e=C(u,t.embeddedWallets.ethereum.createOnLogin),r=W(u,t.embeddedWallets.solana.createOnLogin);e&&r?(u=(await c({chainType:"ethereum",latestUser:u})).user,u=(await c({chainType:"solana",latestUser:u})).user):r?u=(await c({chainType:"solana",latestUser:u})).user:e?u=(await c({chainType:"ethereum",latestUser:u})).user:a(u)}catch(e){a(u),console.warn("Unable to create embedded wallet for guest account")}return s(d),n(!0),o("login","onComplete",{user:u,isNewUser:d,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),u}catch(e){throw o("login","onError",e.privyErrorCode||se.UNKNOWN_AUTH_ERROR),e}}}}function Le(e){let{setWalletRecovery:t}=oe(h);return o("setWalletRecovery",e),{setWalletRecovery:t}}function He(e){let{signMessage:t}=oe(h);return o("signMessage",e),{signMessage:t}}const De=()=>{let{ready:t,wallets:r}=v(),{user:o}=e(),{rpcConfig:i,chains:a,appId:n}=ae();return{signAuthorization:ee((async(e,s)=>{if(!o)throw Error("User must be authenticated before signing with a Privy wallet");if(!t)throw Error("Wallets are not ready");let l=s?.address??P(o)?.address??ue,c=r.find((e=>de(e.address)===de(l)));if(!c)throw Error("Signing wallet not found.");let u=e.chainId??Number(c.chainId.split(":")[1]),d=a.find((e=>e.id===u));if(!d)throw Error("Error, chain not configured in PrivyProvider config");let h=he({account:l,chain:d,transport:we(_(d,i,n))}),w=await h.prepareAuthorization({...e}),p=await c.getEthereumProvider(),g=await p.request({method:"secp256k1_sign",params:[ge(w)]});return{...w,...pe(g)}}),[t,r,o,a])}};function xe(e){let{signTypedData:t}=oe(h);return o("signTypedData",e),{signTypedData:t}}const Ke=()=>{let{isModalOpen:e}=oe(h);return{isOpen:e}};function ze(e){let{getAccessToken:t}=oe(h);return o("accessToken",e),{getAccessToken:t}}function je(t){let{authenticated:r,user:i}=e(),{initLoginWithOAuth:a}=ae(),n=p();return o("oAuthAuthorization",t),{reauthorize:e=>qe(r,i,a,n,e.provider)}}let qe=async(e,t,r,o,i)=>{if(!e)throw o("linkAccount","onError",se.MUST_BE_AUTHENTICATED,{linkMethod:i}),new ne("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new ne(`OAuth account of type ${i} not linked to the account.`);await r(i)};const Ve=e=>{let t=x();return o("customAuth",e),{status:t}};function Ge({isAuthenticated:e,isLoading:t,...r}){let o=ie();re((()=>{t||o.current?.()}),[e,t]);let i=ee((e=>(o.current=e,()=>{o.current=void 0})),[]);return j({...r,subscribe:i})}function Be(){let{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}=e();return{getFarcasterSignerPublicKey:t,signFarcasterMessage:r,requestFarcasterSignerFromWarpcast:o}}const Qe=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=ae();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Xe=()=>{let{addSessionSignersInternal:t,removeSessionSignersInternal:r}=(()=>{let{getAccessToken:t,user:r}=e(),o=ae(),{signWithUserSigner:i}=q(),a=async({wallet:e,additional_signers:a})=>{let n=await t();if(!r||!n)throw new ne("User must be authenticated and have an embedded wallet to delegate actions.");if(!e.id)throw new ne("Wallet to add signers to must have ID on server");if(!o.walletProxy)throw new ne("Wallet proxy not initialized.");await ye(o.privy,{wallet_id:e.id},i,{additional_signers:a})};return{addSessionSignersInternal:async({address:e,signers:i})=>{let n=await t();if(!r||!n)throw new ne("User must be authenticated and have an embedded wallet to add a session signer.");let s=o.walletProxy??await o.initializeWalletProxy(15e3);if(!s)throw new ne("Wallet proxy not initialized.");let l=G(r,e);if(!l)throw new ne("Address to add signers too is not associated with current user.");if(X(l)){if(0===i.length)throw new ne("Must specify at least one signer to add.");let e=[...(await me(o.privy,{wallet_id:l.id})).additional_signers,...$(i)];await a({wallet:l,additional_signers:e})}else{if(l.delegated)return{user:r};if(i.length>0)throw new ne("This embedded wallet does not support specifying signers. If signing is enabled in the dashboard, signer will default to that key. Otherwise, no signatures will be required for the wallet.");let t=Y({address:e,user:r}),a=Z({address:e,user:r});await o.recoverPrimaryWallet(),await s.createDelegatedAction({accessToken:n,rootWallet:a,delegatedWallets:[t]})}let c=await o.refreshSessionAndUser();if(!c)throw Error("Could not refresh user");return{user:c}},removeSessionSignersInternal:async({address:e})=>{let i=await t();if(!r||!i)throw new ne("User must be authenticated and have an embedded wallet to delegate actions.");if(!(o.walletProxy??await o.initializeWalletProxy(15e3)))throw new ne("Wallet proxy not initialized.");let n=G(r,e);if(!n)throw new ne("Address to remove signers from is not associated with current user.");X(n)?await a({wallet:n,additional_signers:[]}):await o.client.revokeDelegatedWallet();let s=await o.refreshSessionAndUser();if(!s)throw Error("Could not refresh user");return{user:s}}}})();return{addSessionSigners:async({address:e,signers:r})=>t({address:e,signers:r}),removeSessionSigners:async({address:e})=>r({address:e})}},Je=()=>{let{setUser:e,client:t}=oe(le),{user:r}=oe(h);return{user:r,refreshUser:ee((async()=>{let r=await(t?.updateUserAndIdToken());return e(r??null),r}),[t,e])}},$e=e=>{let t=i(),{initLoginWithTelegram:r,loginWithTelegram:o,telegramAuthState:a,setTelegramAuthState:n}=ae();return{login:ee((async i=>{try{if(t.enabled&&"success"!==t.status)throw new s(t.error,null,se.CAPTCHA_FAILURE);await r(t.token,i?.disableSignup);let{user:a,isNewUser:n,loginAccount:l,wasAlreadyAuthenticated:c}=await o({intent:"login"});e?.onComplete?.({user:a,isNewUser:n,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:l})}catch(i){throw n({status:"error",error:i}),e?.onError?.(i.privyErrorCode||se.UNKNOWN_AUTH_ERROR),i}}),[r,o,t]),state:a}},Ye=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=ae();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{Ne as useConnectCoinbaseSmartWallet,Ue as useConnectOrCreateWallet,Oe as useCrossAppAccounts,Ve as useCustomAuth,Qe as useDelegatedActions,Be as useFarcasterSigner,Fe as useGuestAccounts,Ye as useHeadlessDelegatedActions,Pe as useLinkAccount,Ee as useLinkWithPasskey,Se as useLinkWithSiwe,Ce as useLoginWithEmail,fe as useLoginWithFarcasterV2,ke as useLoginWithOAuth,We as useLoginWithPasskey,ve as useLoginWithSiwe,Te as useLoginWithSms,$e as useLoginWithTelegram,Ke as useModalStatus,je as useOAuthTokens,Ae as useRecoverEmbeddedWallet,_e as useSendTransaction,Xe as useSessionSigners,Me as useSetWalletPassword,Le as useSetWalletRecovery,De as useSignAuthorization,He as useSignMessage,Re as useSignTransaction,xe as useSignTypedData,Ie as useSignupWithPasskey,Ge as useSubscribeToJwtAuthWithFlag,j as useSyncJwtBasedAuthState,ze as useToken,be as useUpdateAccount,Je as useUser,v as useWallets};
@@ -1 +1 @@
1
- import{FetchError as a}from"ofetch";import{createContext as e,useContext as s}from"react";var t;class i extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(a,e,s){super(a),e instanceof Error&&(this.cause=e),this.privyErrorCode=s}}class n extends i{constructor(a,e,s,t,i,n){super(s,t,i),this.type=a,this.status=e,this.data=n}}class r extends i{constructor(a,e,s){super(a,e,s),this.type="client_error"}}class _ extends r{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class o extends i{constructor(a,e,s){super(a,e,s),this.type="connector_error"}}const l=e=>{if(e instanceof i)return e;if(!(e instanceof a))return u(e);if(!e.response)return new n("api_error",null,e.message,e);let{type:s,message:t,error:r,code:_}=e.data;return new n(s||"ApiError",e.response.status,t||r,e,_,e.data)},u=a=>a instanceof i?a:a instanceof Error?new r(a.message,a):new r(`Internal error: ${a}`);var p=((t={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",t.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",t.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",t.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",t.INVALID_DATA="invalid_data",t.INVALID_CAPTCHA="invalid_captcha",t.LINKED_TO_ANOTHER_USER="linked_to_another_user",t.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",t.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",t.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",t.USER_EXITED_UPDATE_FLOW="exited_update_flow",t.ALLOWLIST_REJECTED="allowlist_rejected",t.OAUTH_USER_DENIED="oauth_user_denied",t.OAUTH_UNEXPECTED="oauth_unexpected",t.UNKNOWN_AUTH_ERROR="unknown_auth_error",t.USER_EXITED_AUTH_FLOW="exited_auth_flow",t.USER_EXITED_LINK_FLOW="exited_link_flow",t.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",t.MUST_BE_AUTHENTICATED="must_be_authenticated",t.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",t.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",t.CLIENT_REQUEST_TIMEOUT="client_request_timeout",t.INVALID_CREDENTIALS="invalid_credentials",t.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",t.UNKNOWN_MFA_ERROR="unknown_mfa_error",t.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",t.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",t.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",t.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",t.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",t.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",t.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",t.TRANSACTION_FAILURE="transaction_failure",t.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",t.NOT_SUPPORTED="not_supported",t.CAPTCHA_TIMEOUT="captcha_timeout",t.INVALID_MESSAGE="invalid_message",t.UNABLE_TO_SIGN="unable_to_sign",t.CAPTCHA_FAILURE="captcha_failure",t.CAPTCHA_DISABLED="captcha_disabled",t.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",t.TOO_MANY_REQUESTS="too_many_requests",t.USER_LIMIT_REACHED="max_accounts_reached",t.DISALLOWED_LOGIN_METHOD="disallowed_login_method",t.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",t.PASSKEY_NOT_ALLOWED="passkey_not_allowed",t.USER_DOES_NOT_EXIST="user_does_not_exist",t.INSUFFICIENT_BALANCE="insufficient_balance",t.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",t.BUFFER_NOT_DEFINED="buffer_not_defined",t);class d extends r{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class c extends r{constructor(a="Embedded wallet error",e){super(a,e,"unknown_embedded_wallet_error")}}class E extends r{constructor(a="User must be authenticated"){super(a,void 0,"must_be_authenticated")}}class A extends r{constructor(a){super("This application is in development mode and must be upgraded to production to log in new users.",a,"max_accounts_reached")}}const h="/api/v1/sessions",v="/api/v1/sessions/logout",S="/api/v1/siwe/init",T="/api/v1/siwe/authenticate",m="/api/v1/siwe/link",w="/api/v1/siwe/link_smart_wallet",I="/api/v1/siwe/unlink",D="/api/v1/siwe/transfer",N="/api/v1/siws/init",O="/api/v1/siws/authenticate",L="/api/v1/siws/link",g="/api/v1/siws/unlink",R="/api/v1/farcaster/init",W="/api/v1/farcaster/authenticate",U="/api/v1/farcaster/link",f="/api/v1/farcaster/status",k="/api/v1/farcaster/unlink",y="/api/v1/farcaster/transfer",C="api/v2/farcaster/init",P="api/v2/farcaster/authenticate",M="/api/v1/passwordless/init",F="/api/v1/passwordless/authenticate",b="/api/v1/passwordless/link",x="/api/v1/passwordless/unlink",H="/api/v1/passwordless/update",B="/api/v1/passwordless/transfer",V="/api/v1/passwordless_sms/init",K="/api/v1/passwordless_sms/link",Y="/api/v1/passwordless_sms/unlink",G="/api/v1/passwordless_sms/authenticate",X="/api/v1/passwordless_sms/update",$="/api/v1/passwordless_sms/transfer",q="/api/v1/oauth/init",j="/api/v1/oauth/authenticate",Q="/api/v1/oauth/link",z="/api/v1/oauth/unlink",J="/api/v1/oauth/transfer",Z="/api/v1/recovery/oauth/init",aa="/api/v1/recovery/oauth/init_icloud",ea="/api/v1/recovery/oauth/authenticate",sa="/api/v1/passkeys/link/init",ta="/api/v1/passkeys/authenticate/init",ia="/api/v1/passkeys/register/init",na="/api/v1/passkeys/link",ra="/api/v1/passkeys/authenticate",_a="/api/v1/passkeys/register",oa="/api/v1/telegram/authenticate",la="/api/v1/telegram/link",ua="/api/v1/telegram/unlink",pa="/api/v1/telegram/transfer",da="/api/v1/mfa/passwordless_sms/init",ca="/api/v1/mfa/passkeys/init",Ea="/api/v1/users/me/accept_terms",Aa="/api/v1/analytics_events",ha="/api/v1/custom_jwt_account/authenticate",va="/api/v1/guest/authenticate",Sa="/api/v1/plugins/moonpay_on_ramp/sign",Ta="/api/v1/funding/coinbase_on_ramp/init",ma="/api/v1/funding/coinbase_on_ramp/status",wa="/api/v1/wallets/revoke",Ia="/api/v1/users/me",Da="/api/v1/scan/transaction",Na=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},Oa=a=>()=>{throw Error(a.trim())},La=/*#__PURE__*/e({setAuthenticated:Na,setUser:Na,setIsNewUser:Na,isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:Na,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:Na,initializeWalletProxy:Na,getAuthMeta:Na,getAuthFlow:Na,closePrivyModal:Na,openPrivyModal:Na,connectWallet:Na,initLoginWithWallet:Na,loginWithWallet:Na,initLoginWithFarcaster:Na,loginWithFarcaster:Na,loginWithCode:Na,initLoginWithEmail:Na,initLoginWithSms:Na,initUpdateEmail:Na,initUpdatePhone:Na,resendEmailCode:Na,resendSmsCode:Na,initLoginWithHeadlessOAuth:Na,loginWithHeadlessOAuth:Na,crossAppAuthFlow:Na,initLoginWithOAuth:Na,loginWithOAuth:Na,passkeyAuthState:{status:"initial"},setPasskeyAuthState:Na,initSignupWithPasskey:Na,signupWithPasskey:Na,initLoginWithPasskey:Na,loginWithPasskey:Na,initLinkWithPasskey:Na,linkWithPasskey:Na,refreshSessionAndUser:Na,walletProxy:null,createAnalyticsEvent:Na,acceptTerms:Na,getUsdTokenPrice:Na,getUsdPriceForSol:Na,getSplTokenMetadata:Na,recoverPrimaryWallet:Na,updateWallets:Na,fundWallet:Na,openModal:Na,setReadyToTrue:Na,requestFarcasterSignerStatus:Na,initLoginWithTelegram:Na,loginWithTelegram:Na,generateSiweMessage:Na,generateSiweMessageForSmartWallet:Na,loginWithSiwe:Na,linkWithSiwe:Na,linkSmartWallet:Na,delegateWallet:Na,revokeDelegatedWallets:Na,exportSolanaWallet:Na,connectCoinbaseSmartWallet:Na,initiateAccountTransfer:Na,emailOtpState:{status:"initial"},setEmailOtpState:Na,smsOtpState:{status:"initial"},setSmsOtpState:Na,siweState:{status:"initial"},setSiweState:Na,oAuthState:{status:"initial"},setOAuthState:Na,telegramAuthState:{status:"initial"},setTelegramAuthState:Na,isHeadlessOAuthLoading:!1,isHeadlessSigning:Na}),ga=()=>s(La);export{ma as $,i as A,oa as B,la as C,Oa as D,_ as E,h as F,v as G,Aa as H,La as I,ha as J,va as K,u as L,n as M,da as N,ca as O,r as P,Ea as Q,x as R,Y as S,I as T,g as U,z as V,k as W,ua as X,wa as Y,Sa as Z,Ta as _,p as a,S as a0,T as a1,m as a2,w as a3,N as a4,O as a5,J as a6,pa as a7,y as a8,D as a9,$ as aa,B as ab,L as ac,Ia as ad,Da as ae,ea as af,aa as ag,Z as ah,c as ai,A as aj,E as ak,d as al,C as am,P as an,b,M as c,H as d,o as e,l as f,W as g,U as h,R as i,f as j,Q as k,q as l,_a as m,Na as n,j as o,F as p,ra as q,na as r,ia as s,ta as t,ga as u,sa as v,G as w,K as x,V as y,X as z};
1
+ import{FetchError as a}from"ofetch";import{createContext as e,useContext as s}from"react";var t;class i extends Error{toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(a,e,s){super(a),e instanceof Error&&(this.cause=e),this.privyErrorCode=s}}class n extends i{constructor(a,e,s,t,i,n){super(s,t,i),this.type=a,this.status=e,this.data=n}}class r extends i{constructor(a,e,s){super(a,e,s),this.type="client_error"}}class _ extends r{constructor(){super("Request timed out",void 0,"client_request_timeout")}}class o extends i{constructor(a,e,s){super(a,e,s),this.type="connector_error"}}const l=e=>{if(e instanceof i)return e;if(!(e instanceof a))return u(e);if(!e.response)return new n("api_error",null,e.message,e);let{type:s,message:t,error:r,code:_}=e.data;return new n(s||"ApiError",e.response.status,t||r,e,_,e.data)},u=a=>a instanceof i?a:a instanceof Error?new r(a.message,a):new r(`Internal error: ${a}`);var p=((t={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",t.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",t.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",t.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",t.INVALID_DATA="invalid_data",t.INVALID_CAPTCHA="invalid_captcha",t.LINKED_TO_ANOTHER_USER="linked_to_another_user",t.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",t.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",t.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",t.USER_EXITED_UPDATE_FLOW="exited_update_flow",t.ALLOWLIST_REJECTED="allowlist_rejected",t.OAUTH_USER_DENIED="oauth_user_denied",t.OAUTH_UNEXPECTED="oauth_unexpected",t.UNKNOWN_AUTH_ERROR="unknown_auth_error",t.USER_EXITED_AUTH_FLOW="exited_auth_flow",t.USER_EXITED_LINK_FLOW="exited_link_flow",t.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",t.MUST_BE_AUTHENTICATED="must_be_authenticated",t.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",t.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",t.CLIENT_REQUEST_TIMEOUT="client_request_timeout",t.INVALID_CREDENTIALS="invalid_credentials",t.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",t.UNKNOWN_MFA_ERROR="unknown_mfa_error",t.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",t.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",t.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",t.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",t.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",t.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",t.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",t.TRANSACTION_FAILURE="transaction_failure",t.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",t.NOT_SUPPORTED="not_supported",t.CAPTCHA_TIMEOUT="captcha_timeout",t.INVALID_MESSAGE="invalid_message",t.UNABLE_TO_SIGN="unable_to_sign",t.CAPTCHA_FAILURE="captcha_failure",t.CAPTCHA_DISABLED="captcha_disabled",t.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",t.TOO_MANY_REQUESTS="too_many_requests",t.USER_LIMIT_REACHED="max_accounts_reached",t.DISALLOWED_LOGIN_METHOD="disallowed_login_method",t.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",t.PASSKEY_NOT_ALLOWED="passkey_not_allowed",t.USER_DOES_NOT_EXIST="user_does_not_exist",t.INSUFFICIENT_BALANCE="insufficient_balance",t.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",t.BUFFER_NOT_DEFINED="buffer_not_defined",t);class d extends r{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}}class c extends r{constructor(a="Embedded wallet error",e){super(a,e,"unknown_embedded_wallet_error")}}class E extends r{constructor(a="User must be authenticated"){super(a,void 0,"must_be_authenticated")}}class A extends r{constructor(a){super("This application is in development mode and must be upgraded to production to log in new users.",a,"max_accounts_reached")}}const h="/api/v1/sessions",v="/api/v1/sessions/logout",S="/api/v1/siwe/init",T="/api/v1/siwe/authenticate",m="/api/v1/siwe/link",w="/api/v1/siwe/link_smart_wallet",I="/api/v1/siwe/unlink",D="/api/v1/siwe/transfer",N="/api/v1/siws/init",O="/api/v1/siws/authenticate",L="/api/v1/siws/link",g="/api/v1/siws/unlink",R="/api/v1/farcaster/init",W="/api/v1/farcaster/authenticate",U="/api/v1/farcaster/link",f="/api/v1/farcaster/status",k="/api/v1/farcaster/unlink",y="/api/v1/farcaster/transfer",C="api/v2/farcaster/init",P="api/v2/farcaster/authenticate",M="/api/v1/passwordless/init",F="/api/v1/passwordless/authenticate",b="/api/v1/passwordless/link",x="/api/v1/passwordless/unlink",H="/api/v1/passwordless/update",B="/api/v1/passwordless/transfer",V="/api/v1/passwordless_sms/init",K="/api/v1/passwordless_sms/link",Y="/api/v1/passwordless_sms/unlink",G="/api/v1/passwordless_sms/authenticate",X="/api/v1/passwordless_sms/update",$="/api/v1/passwordless_sms/transfer",q="/api/v1/oauth/init",j="/api/v1/oauth/authenticate",Q="/api/v1/oauth/link",z="/api/v1/oauth/unlink",J="/api/v1/oauth/transfer",Z="/api/v1/recovery/oauth/init",aa="/api/v1/recovery/oauth/init_icloud",ea="/api/v1/recovery/oauth/authenticate",sa="/api/v1/passkeys/link/init",ta="/api/v1/passkeys/authenticate/init",ia="/api/v1/passkeys/register/init",na="/api/v1/passkeys/link",ra="/api/v1/passkeys/authenticate",_a="/api/v1/passkeys/register",oa="/api/v1/telegram/authenticate",la="/api/v1/telegram/link",ua="/api/v1/telegram/unlink",pa="/api/v1/telegram/transfer",da="/api/v1/mfa/passwordless_sms/init",ca="/api/v1/mfa/passkeys/init",Ea="/api/v1/users/me/accept_terms",Aa="/api/v1/analytics_events",ha="/api/v1/custom_jwt_account/authenticate",va="/api/v1/guest/authenticate",Sa="/api/v1/plugins/moonpay_on_ramp/sign",Ta="/api/v1/funding/coinbase_on_ramp/init",ma="/api/v1/funding/coinbase_on_ramp/status",wa="/api/v1/wallets/revoke",Ia="/api/v1/users/me",Da="/api/v1/scan/transaction",Na=()=>{throw Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")},Oa=a=>()=>{throw Error(a.trim())},La=/*#__PURE__*/e({setAuthenticated:Na,setUser:Na,setIsNewUser:Na,isNewUserThisSession:!1,walletConnectionStatus:null,connectors:[],solanaWallets:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,client:null,privy:null,appId:"notAdded",onCustomAuthAuthenticated:Na,hideWalletUIs:{current:!1},nativeTokenSymbolForChainId:Na,initializeWalletProxy:Na,getAuthMeta:Na,getAuthFlow:Na,closePrivyModal:Na,openPrivyModal:Na,connectWallet:Na,initLoginWithWallet:Na,loginWithWallet:Na,initLoginWithFarcaster:Na,loginWithFarcaster:Na,loginWithCode:Na,initLoginWithEmail:Na,initLoginWithSms:Na,initUpdateEmail:Na,initUpdatePhone:Na,resendEmailCode:Na,resendSmsCode:Na,initLoginWithHeadlessOAuth:Na,loginWithHeadlessOAuth:Na,crossAppAuthFlow:Na,initLoginWithOAuth:Na,loginWithOAuth:Na,passkeyAuthState:{status:"initial"},setPasskeyAuthState:Na,initSignupWithPasskey:Na,signupWithPasskey:Na,initLoginWithPasskey:Na,loginWithPasskey:Na,initLinkWithPasskey:Na,linkWithPasskey:Na,refreshSessionAndUser:Na,walletProxy:null,createAnalyticsEvent:Na,acceptTerms:Na,getUsdTokenPrice:Na,getUsdPriceForSol:Na,getSplTokenMetadata:Na,recoverPrimaryWallet:Na,updateWallets:Na,fundWallet:Na,openModal:Na,setReadyToTrue:Na,requestFarcasterSignerStatus:Na,initLoginWithTelegram:Na,loginWithTelegram:Na,generateSiweMessage:Na,generateSiweMessageForSmartWallet:Na,loginWithSiwe:Na,linkWithSiwe:Na,linkSmartWallet:Na,delegateWallet:Na,revokeDelegatedWallets:Na,exportSolanaWallet:Na,connectCoinbaseSmartWallet:Na,initiateAccountTransfer:Na,emailOtpState:{status:"initial"},setEmailOtpState:Na,smsOtpState:{status:"initial"},setSmsOtpState:Na,siweState:{status:"initial"},setSiweState:Na,oAuthState:{status:"initial"},setOAuthState:Na,telegramAuthState:{status:"initial"},setTelegramAuthState:Na,isHeadlessOAuthLoading:!1,isHeadlessSigning:Na}),ga=()=>s(La);export{ma as $,X as A,i as B,oa as C,la as D,_ as E,h as F,v as G,Aa as H,La as I,ha as J,va as K,u as L,n as M,da as N,ca as O,r as P,Ea as Q,x as R,Y as S,I as T,g as U,z as V,k as W,ua as X,wa as Y,Sa as Z,Ta as _,p as a,S as a0,T as a1,m as a2,w as a3,N as a4,O as a5,J as a6,pa as a7,y as a8,D as a9,$ as aa,B as ab,L as ac,Ia as ad,Da as ae,ea as af,aa as ag,Z as ah,c as ai,A as aj,E as ak,d as al,C as am,P as an,Na as b,b as c,M as d,H as e,l as f,o as g,W as h,U as i,R as j,f as k,Q as l,q as m,Oa as n,j as o,F as p,_a as q,ra as r,na as s,ia as t,ga as u,ta as v,sa as w,G as x,K as y,V as z};