@privy-io/react-auth 1.74.1 → 1.75.0-beta-20240715213704

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
@@ -510,7 +510,8 @@ declare enum PrivyErrorCode {
510
510
  USER_LIMIT_REACHED = "max_accounts_reached",
511
511
  DISALLOWED_LOGIN_METHOD = "disallowed_login_method",
512
512
  PASSKEY_NOT_ALLOWED = "passkey_not_allowed",
513
- USER_DOES_NOT_EXIST = "user_does_not_exist"
513
+ USER_DOES_NOT_EXIST = "user_does_not_exist",
514
+ INSUFFICIENT_BALANCE = "insufficient_balance"
514
515
  }
515
516
 
516
517
  declare class WalletTimeoutError extends PrivyConnectorError {
@@ -1227,6 +1228,10 @@ declare class PrivyClient {
1227
1228
  * Accepted payment methods for the MoonPay fiat on-ramp.
1228
1229
  */
1229
1230
  type MoonpayPaymentMethod = 'ach_bank_transfer' | 'credit_debit_card' | 'gbp_bank_transfer' | 'gbp_open_banking_payment' | 'mobile_wallet' | 'sepa_bank_transfer' | 'sepa_open_banking_payment' | 'pix_instant_payment' | 'yellow_card_bank_transfer';
1231
+ type MoonpayUiConfig = {
1232
+ accentColor?: string;
1233
+ theme?: 'light' | 'dark';
1234
+ };
1230
1235
  /**
1231
1236
  * Cryptocurrency codes for the MoonPay fiat on-ramp. These codes
1232
1237
  * follow the format {TOKEN_NAME}_{NETWORK_NAME}.
@@ -1239,10 +1244,7 @@ type MoonpayConfig = {
1239
1244
  currencyCode?: MoonpayCurrencyCode;
1240
1245
  quoteCurrencyAmount?: number;
1241
1246
  paymentMethod?: MoonpayPaymentMethod;
1242
- uiConfig?: {
1243
- accentColor?: string;
1244
- theme?: 'light' | 'dark';
1245
- };
1247
+ uiConfig?: MoonpayUiConfig;
1246
1248
  };
1247
1249
  type MoonpaySignRequest = {
1248
1250
  address: string;
@@ -1314,6 +1316,9 @@ interface LinkMetadata {
1314
1316
  type FundWalletConfig = {
1315
1317
  config: MoonpayConfig;
1316
1318
  provider?: 'moonpay';
1319
+ } | {
1320
+ chain?: Chain;
1321
+ amount?: string;
1317
1322
  };
1318
1323
  /**
1319
1324
  * Possible methods of user-driven recovery.
@@ -1464,18 +1469,19 @@ interface ConnectedWallet extends BaseConnectedWallet {
1464
1469
  * Throws a PrivyClientError if the wallet is not connected.
1465
1470
  */
1466
1471
  loginOrLink: () => Promise<void>;
1467
- /** Prompt the user to go through the fiat onramp flow.
1472
+ /**
1473
+ * Prompt the user to go through the funding flow and for the connected wallet.
1468
1474
  *
1469
- * This will open the modal with a prompt for the user to navigate to a third-party on-ramp provider.
1475
+ * This will open the modal with a prompt for the user to select a funding method (if multiple are enabled).
1470
1476
  *
1471
- * Once the user continues to the on-ramp flow, Privy will display the on-ramp status screen, and wait
1472
- * for the transaction to complete.
1477
+ * Once the user continues to the funding flow, Privy will display the funding status screen, and wait
1478
+ * for the transaction to complete.
1473
1479
  *
1474
- * Note: Even after a successful funding, funds can take a few minutes to arrive in the user's wallet.
1480
+ * Note: Even after a successful funding, funds can take a few minutes to arrive in the user's wallet.
1475
1481
  *
1476
- * The current supported provider is Moonpay.
1482
+ * Privy currently supports funding via external wallets and Moonpay.
1477
1483
  *
1478
- * @param {FundWalletConfig} fundWalletConfig The configuration for the fiat onramp flow.
1484
+ * @param {FundWalletConfig} fundWalletConfig Funding configuration to specify chain and funding amount (if enabled)
1479
1485
  * **/
1480
1486
  fund: (fundWalletConfig?: FundWalletConfig) => Promise<void>;
1481
1487
  /** Unlink this wallet to the authenticated user. Throws a PrivyClientError if the user is not
@@ -1825,6 +1831,19 @@ type TelegramAuthConfiguration = {
1825
1831
  linkEnabled: boolean;
1826
1832
  seamlessAuthEnabled: boolean;
1827
1833
  };
1834
+ type FundingMethod = 'moonpay' | 'coinbase-onramp' | 'external';
1835
+ type FundingConfig = {
1836
+ /** The recommended currency for the user to fund. Note: to begin with we default to the chain's native currency. */
1837
+ defaultRecommendedCurrency: {
1838
+ chain: string;
1839
+ };
1840
+ /** The recommended amount of the specified currency to fund, in human readable format (eg '0.1') */
1841
+ defaultRecommendedAmount: string;
1842
+ /** The list of funding methods enabled for the app */
1843
+ methods: FundingMethod[];
1844
+ /** Whether to prompt the user to fund upon embedded wallet creation */
1845
+ promptFundingOnWalletCreation: boolean;
1846
+ };
1828
1847
  type PrivyServerConfig = {
1829
1848
  id?: string;
1830
1849
  name?: string;
@@ -1866,6 +1885,7 @@ type PrivyServerConfig = {
1866
1885
  accentColor?: string;
1867
1886
  mfaMethods?: Array<MfaMethod>;
1868
1887
  telegramAuthConfiguration?: TelegramAuthConfiguration;
1888
+ fundingConfig?: FundingConfig;
1869
1889
  };
1870
1890
  type HexColor = `#${string}`;
1871
1891
  /**
@@ -2204,6 +2224,7 @@ interface PrivyClientConfig {
2204
2224
  noPromptOnMfaRequired?: boolean;
2205
2225
  };
2206
2226
  /**
2227
+ * @deprecated. Use `fundingMethodConfigurations -> moonpay -> useSandbox` instead.
2207
2228
  * Setting associated with fiat-on-ramp flows
2208
2229
  */
2209
2230
  fiatOnRamp?: {
@@ -2214,6 +2235,31 @@ interface PrivyClientConfig {
2214
2235
  */
2215
2236
  useSandbox?: boolean;
2216
2237
  };
2238
+ /**
2239
+ * Settings associated with funding methods
2240
+ */
2241
+ fundingMethodConfig?: {
2242
+ moonpay: {
2243
+ /**
2244
+ * Determines whether to use the Moonpay sandbox flow.
2245
+ *
2246
+ * Defaults to false.
2247
+ */
2248
+ useSandbox?: boolean;
2249
+ /**
2250
+ * Determines the payment method for each Moonpay transaction.
2251
+ *
2252
+ * Defaults to Moonpay's default.
2253
+ */
2254
+ paymentMethod?: MoonpayPaymentMethod;
2255
+ /**
2256
+ * Determines the UI settings for each Moonpay transaction.
2257
+ *
2258
+ * Defaults to Moonpay's default.
2259
+ */
2260
+ uiConfig?: MoonpayUiConfig;
2261
+ };
2262
+ };
2217
2263
  }
2218
2264
  interface AllowlistConfig {
2219
2265
  errorTitle: string | null;
@@ -2426,6 +2472,9 @@ type PrivyFarcasterSignerInitResponse = {
2426
2472
  public_key: string;
2427
2473
  status: 'revoked';
2428
2474
  };
2475
+ type RuntimeLoginOverridableOptions = {
2476
+ loginMethods?: PrivyClientConfig['loginMethods'];
2477
+ };
2429
2478
 
2430
2479
  declare function getAccessToken(): Promise<string | null>;
2431
2480
  /**
@@ -2524,8 +2573,9 @@ interface PrivyInterface {
2524
2573
  } | MouseEvent<any, any>) => void;
2525
2574
  /**
2526
2575
  * Opens the Privy login modal and prompts the user to login.
2576
+ * @param options.loginMethods {LoginMethod[]} custom login methods to display in the login modal. This will overwrite the value provider to the client config.
2527
2577
  */
2528
- login: () => void;
2578
+ login: (options?: RuntimeLoginOverridableOptions | MouseEvent<any, any>) => void;
2529
2579
  /**
2530
2580
  * Opens the Privy login modal and prompts the user to login or connect a wallet.
2531
2581
  */
@@ -2988,7 +3038,7 @@ interface PrivyInterface {
2988
3038
  *
2989
3039
  * @param data {@link UnsignedTransactionRequest} transaction to be sent
2990
3040
  * @param uiOptions {@link SendTransactionModalUIOptions} (optional) UI options to customize the transaction request modal
2991
- * @param fundWalletConfig {@link FundWalletConfig} (optional) Configuration surrounding funding the wallet (if enabled), in the case of insufficient funds
3041
+ * @param fundWalletConfig {@link FundWalletConfig} (optional) Funding configuration to specify chain and funding amount (if enabled), in the case of insufficient funds
2992
3042
  * @returns Promise for the transaction's {@link TransactionReceipt}
2993
3043
  */
2994
3044
  sendTransaction: (data: UnsignedTransactionRequest, uiOptions?: SendTransactionModalUIOptions, fundWalletConfig?: FundWalletConfig) => Promise<TransactionReceipt>;
@@ -3408,7 +3458,7 @@ declare function useLogin(callbacks?: PrivyEvents['login']): {
3408
3458
  /**
3409
3459
  * Opens the Privy login modal and prompts the user to login.
3410
3460
  */
3411
- login: () => void;
3461
+ login: (options?: RuntimeLoginOverridableOptions | react.MouseEvent<any, any> | undefined) => void;
3412
3462
  };
3413
3463
 
3414
3464
  /**
@@ -3717,24 +3767,24 @@ declare function useCreateWallet(callbacks?: PrivyEvents['createWallet']): {
3717
3767
  };
3718
3768
 
3719
3769
  /**
3720
- * Method to fund a user's wallet via Privy's fiat on-ramp integration by inputting a valid wallet address.
3770
+ * Method to fund a user's wallet via Privy's funding feature by inputting a valid wallet address.
3721
3771
  * You can access the fields and methods documented here via the {@link useFundWallet} hook.
3722
3772
  */
3723
3773
  interface UseFundWalletInterface {
3724
3774
  /**
3725
- * Prompt the user to go through the fiat onramp flow and fund the specified wallet.
3775
+ * Prompt the user to go through the funding flow and for a specified wallet.
3726
3776
  *
3727
- * This will open the modal with a prompt for the user to navigate to a third-party on-ramp provider.
3777
+ * This will open the modal with a prompt for the user to select a funding method (if multiple are enabled).
3728
3778
  *
3729
- * Once the user continues to the on-ramp flow, Privy will display the on-ramp status screen, and wait
3779
+ * Once the user continues to the funding flow, Privy will display the funding status screen, and wait
3730
3780
  * for the transaction to complete.
3731
3781
  *
3732
3782
  * Note: Even after a successful funding, funds can take a few minutes to arrive in the user's wallet.
3733
3783
  *
3734
- * The current supported provider is Moonpay.
3784
+ * Privy currently supports funding via external wallets and Moonpay.
3735
3785
  *
3736
3786
  * @param address typed data payload to be signed
3737
- * @param fundWalletConfig {@link FundWalletConfig} (optional) options to customize the wallet fund modal
3787
+ * @param fundWalletConfig {@link FundWalletConfig} Funding configuration to specify chain and funding amount (if enabled)
3738
3788
  */
3739
3789
  fundWallet: (address: string, fundWalletConfig?: FundWalletConfig) => Promise<void>;
3740
3790
  }