@privy-io/react-auth 1.57.1 → 1.57.2-beta-20240227212848

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import react, { ReactElement } from 'react';
2
- import { ExternalProvider, StaticJsonRpcProvider, Web3Provider } from '@ethersproject/providers';
2
+ import { ExternalProvider, StaticJsonRpcProvider, Web3Provider, TransactionResponse } from '@ethersproject/providers';
3
3
  import { CountryCode } from 'libphonenumber-js/min';
4
4
  import { AbstractProvider } from 'web3-core';
5
5
  import EventEmitter from 'eventemitter3';
@@ -379,8 +379,11 @@ declare enum PrivyErrorCode {
379
379
  UNKNOWN_EMBEDDED_WALLET_ERROR = "unknown_embedded_wallet_error",
380
380
  EMBEDDED_WALLET_PASSWORD_UNCONFIRMED = "embedded_wallet_password_unconfirmed",
381
381
  EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS = "embedded_wallet_password_already_exists",
382
+ TRANSACTION_FAILURE = "transaction_failure",
382
383
  UNSUPPORTED_CHAIN_ID = "unsupported_chain_id",
383
384
  CAPTCHA_TIMEOUT = "captcha_timeout",
385
+ INVALID_MESSAGE = "invalid_message",
386
+ UNABLE_TO_SIGN = "unable_to_sign",
384
387
  CAPTCHA_FAILURE = "captcha_failure",
385
388
  CAPTCHA_DISABLED = "captcha_disabled",
386
389
  SESSION_STORAGE_UNAVAILABLE = "session_storage_unavailable",
@@ -2538,7 +2541,7 @@ interface PrivyEvents {
2538
2541
  connectWallet: {
2539
2542
  /**
2540
2543
  * Callback that will execute once a successful `connectWallet` completes.
2541
- * This will not run in the case of a wallet-based authentication flow.
2544
+ * This will not run in the case of a wallet-based authentication or link flow.
2542
2545
  *
2543
2546
  * @param wallet {@link BaseConnectedWallet} the `wallet` object correspending to the connection
2544
2547
  */
@@ -2588,6 +2591,47 @@ interface PrivyEvents {
2588
2591
  */
2589
2592
  onError?: CallbackError;
2590
2593
  };
2594
+ signMessage: {
2595
+ /**
2596
+ * Callback that will execute once a successful `signMessage` completes.
2597
+ * This will not run in the case of a wallet-based authentication or link flow.
2598
+ * @param signature - the signature of the embedded wallet used to sign message
2599
+ */
2600
+ onSuccess?: (signature: string) => void;
2601
+ /**
2602
+ * Callback that will execute in the case of a non-successful signMessage.
2603
+ *
2604
+ * @param error {@link PrivyErrorCode} - the corresponding error code
2605
+ * */
2606
+ onError?: CallbackError;
2607
+ };
2608
+ signTypedData: {
2609
+ /**
2610
+ * Callback that will execute once a successful `signTypedData` completes.
2611
+ * @param signature - the signature of the embedded wallet used to sign
2612
+ */
2613
+ onSuccess?: (signature: string) => void;
2614
+ /**
2615
+ * Callback that will execute in the case of a non-successful signTypedData.
2616
+ *
2617
+ * @param error {@link PrivyErrorCode} - the corresponding error code
2618
+ * */
2619
+ onError?: CallbackError;
2620
+ };
2621
+ sendTransaction: {
2622
+ /**
2623
+ * Callback that will execute once a successful `sendTransaction` completes.
2624
+ * This will not run in the case of a wallet-based authentication or link flow.
2625
+ * @param response - the response from the successful transaction
2626
+ */
2627
+ onSuccess?: (response: TransactionResponse) => void;
2628
+ /**
2629
+ * Callback that will execute in the case of a non-successful sendTransaction.
2630
+ *
2631
+ * @param error {@link PrivyErrorCode} - the corresponding error code
2632
+ * */
2633
+ onError?: CallbackError;
2634
+ };
2591
2635
  accessToken: {
2592
2636
  /**
2593
2637
  * Callback that will execute when a user's access token is granted.
@@ -2798,6 +2842,23 @@ declare function useCreateWallet(callbacks?: PrivyEvents['createWallet']): {
2798
2842
  createWallet: () => Promise<Wallet>;
2799
2843
  };
2800
2844
 
2845
+ /**
2846
+ * Use this hook to send a transaction using the embedded wallet and to attach callbacks for success and errors.
2847
+ * Note that the callbacks will only fire for explicit sendTransaction calls from the Privy SDK.
2848
+ * Transactions sent from the embedded wallet using transaction functions from non-Privy libraries
2849
+ * will not trigger the callbacks.
2850
+ *
2851
+ * @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful transaction sent
2852
+ * @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `sendTransaction`
2853
+ * @returns sendTransaction - prompts the user send a transaction using their embedded wallet
2854
+ */
2855
+ declare function useSendTransaction(callbacks?: PrivyEvents['sendTransaction']): {
2856
+ /**
2857
+ * Prompts a user to send a transaction using their embedded wallet.
2858
+ */
2859
+ sendTransaction: (data: UnsignedTransactionRequest, uiOptions?: SendTransactionModalUIOptions | undefined, fundWalletConfig?: FundWalletConfig | undefined) => Promise<TransactionReceipt>;
2860
+ };
2861
+
2801
2862
  /**
2802
2863
  * Use this hook to set a password on the embedded wallet, and to attach callbacks
2803
2864
  * for successful `password set`s, and `password set` errors.
@@ -2814,6 +2875,36 @@ declare function useSetWalletPassword(callbacks?: PrivyEvents['setWalletPassword
2814
2875
  setWalletPassword: () => Promise<Wallet>;
2815
2876
  };
2816
2877
 
2878
+ /**
2879
+ * Use this hook to sign a message using the embedded wallet, and to attach callbacks for success and errors.
2880
+ * Note that the callbacks will only fire for explicit `signMessage` calls from the Privy SDK.
2881
+ *
2882
+ * @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful message signature
2883
+ * @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `signMessage`
2884
+ * @returns signMessage - prompts the user to sign a message with their embedded wallet
2885
+ */
2886
+ declare function useSignMessage(callbacks?: PrivyEvents['signMessage']): {
2887
+ /**
2888
+ * Prompts a user to sign a message using their embedded wallet.
2889
+ */
2890
+ signMessage: (message: string, uiOptions?: SignMessageModalUIOptions | undefined) => Promise<string>;
2891
+ };
2892
+
2893
+ /**
2894
+ * Use this hook to sign typed data using the embedded wallet, and to attach callbacks for success and errors.
2895
+ * Note that the callbacks will only fire for explicit `signTypedData` calls from the Privy SDK.
2896
+ *
2897
+ * @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful signature
2898
+ * @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `signTypedData`
2899
+ * @returns signTypedData - prompts the user to sign typed data with their embedded wallet
2900
+ */
2901
+ declare function useSignTypedData(callbacks?: PrivyEvents['signTypedData']): {
2902
+ /**
2903
+ * Prompts a user to sign typed data using their embedded wallet.
2904
+ */
2905
+ signTypedData: (typedData: SignTypedDataParams, uiOptions?: SignMessageModalUIOptions | undefined) => Promise<string>;
2906
+ };
2907
+
2817
2908
  /**
2818
2909
  * Use this hook to check whether or not the Privy modal is currently visible.
2819
2910
  *
@@ -2889,4 +2980,4 @@ declare function addRpcUrlOverrideToChain(chain: Chain, rpcUrl: string): {
2889
2980
  testnet?: boolean | undefined;
2890
2981
  };
2891
2982
 
2892
- export { Apple, AppleOAuthWithMetadata, AsExternalProvider, CallbackError, Captcha, ConnectedWallet, ConnectorManager, ContractUIOptions, Discord, DiscordOAuthWithMetadata, EIP1193Provider, Email, EmailWithMetadata, Farcaster, FarcasterWithMetadata, FundWalletConfig, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, LinkedIn, LinkedInOAuthWithMetadata, LoginWithCode, MessageTypes, MfaMethod, MoonpayConfig, MoonpayCurrencyCode, MoonpayPaymentMethod, Phone, PhoneWithMetadata, PriceDisplayOptions, PrivyClient, PrivyClientConfig, PrivyEvents, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Quantity, DEFAULT_SUPPORTED_CHAINS as SUPPORTED_CHAINS, SendCodeToEmail, SendCodeToSms, SendTransactionModalUIOptions, SignMessageModalUIOptions, SignTypedDataParams, Tiktok, TiktokOAuthWithMetadata, TransactionLog, TransactionReceipt, TransactionUIOptions, Twitter, TwitterOAuthWithMetadata, TypedMessage, UnsignedTransactionRequest, UseLoginWithEmail, UseLoginWithSms, UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletListEntry, WalletWithMetadata, addRpcUrlOverrideToChain, errorIndicatesMaxMfaRetries, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, getAccessToken, useConnectWallet, useCreateWallet, useLogin, useLoginWithEmail, useLoginWithSms, useLogout, useMfa, useMfaEnrollment, useModalStatus, usePrivy, useRegisterMfaListener, useSetWalletPassword, useToken, useWallets };
2983
+ export { Apple, AppleOAuthWithMetadata, AsExternalProvider, CallbackError, Captcha, ConnectedWallet, ConnectorManager, ContractUIOptions, Discord, DiscordOAuthWithMetadata, EIP1193Provider, Email, EmailWithMetadata, Farcaster, FarcasterWithMetadata, FundWalletConfig, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, LinkedIn, LinkedInOAuthWithMetadata, LoginWithCode, MessageTypes, MfaMethod, MoonpayConfig, MoonpayCurrencyCode, MoonpayPaymentMethod, Phone, PhoneWithMetadata, PriceDisplayOptions, PrivyClient, PrivyClientConfig, PrivyEvents, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Quantity, DEFAULT_SUPPORTED_CHAINS as SUPPORTED_CHAINS, SendCodeToEmail, SendCodeToSms, SendTransactionModalUIOptions, SignMessageModalUIOptions, SignTypedDataParams, Tiktok, TiktokOAuthWithMetadata, TransactionLog, TransactionReceipt, TransactionUIOptions, Twitter, TwitterOAuthWithMetadata, TypedMessage, UnsignedTransactionRequest, UseLoginWithEmail, UseLoginWithSms, UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletListEntry, WalletWithMetadata, addRpcUrlOverrideToChain, errorIndicatesMaxMfaRetries, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, getAccessToken, useConnectWallet, useCreateWallet, useLogin, useLoginWithEmail, useLoginWithSms, useLogout, useMfa, useMfaEnrollment, useModalStatus, usePrivy, useRegisterMfaListener, useSendTransaction, useSetWalletPassword, useSignMessage, useSignTypedData, useToken, useWallets };