@privy-io/react-auth 1.70.0 → 1.71.0-beta-20240611222124

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
@@ -797,7 +797,17 @@ interface ResponseTelegramAccount {
797
797
  first_verified_at: number | null;
798
798
  latest_verified_at: number | null;
799
799
  }
800
- type LinkedAccountsResponseType = Array<ResponseEmailAccount | ResponsePhoneAccount | ResponseEthereumAccount | ResponseOAuthGoogle | ResponseOAuthTwitter | ResponseOAuthDiscord | ResponseOAuthGithub | ResponseOAuthSpotify | ResponseOAuthInstagram | ResponseOAuthTiktok | ResponseOAuthLinkedIn | ResponseOAuthApple | ResponseCustomJwtAccount | ResponseFarcasterAccount | ResponsePasskeyAccount | ResponseTelegramAccount>;
800
+ interface ResponseCrossAppAccount {
801
+ type: 'cross_app';
802
+ embedded_wallets: {
803
+ address: string;
804
+ }[];
805
+ provider_app_id: string;
806
+ verified_at: number;
807
+ first_verified_at: number | null;
808
+ latest_verified_at: number | null;
809
+ }
810
+ type LinkedAccountsResponseType = Array<ResponseEmailAccount | ResponsePhoneAccount | ResponseEthereumAccount | ResponseOAuthGoogle | ResponseOAuthTwitter | ResponseOAuthDiscord | ResponseOAuthGithub | ResponseOAuthSpotify | ResponseOAuthInstagram | ResponseOAuthTiktok | ResponseOAuthLinkedIn | ResponseOAuthApple | ResponseCustomJwtAccount | ResponseFarcasterAccount | ResponsePasskeyAccount | ResponseTelegramAccount | ResponseCrossAppAccount>;
801
811
  interface ResponseSmsMfaMethod {
802
812
  type: 'sms';
803
813
  verified_at: number;
@@ -1037,6 +1047,8 @@ declare class PrivyClient {
1037
1047
  user: User | null;
1038
1048
  oAuthProviderTokens?: OAuthProviderTokens | undefined;
1039
1049
  }>;
1050
+ storeProviderAccessToken(appId: string, providerAccessToken: string | null): void;
1051
+ getProviderAccessToken(appId: string): string | null;
1040
1052
  logout(): Promise<void>;
1041
1053
  startAuthFlow<T extends AuthFlow>(authFlow: T): T;
1042
1054
  initMfaSmsVerification(): Promise<void>;
@@ -1162,7 +1174,7 @@ type OAuthProviderType = (typeof SUPPORTED_OAUTH_PROVIDERS)[number];
1162
1174
  * Supported OAuth providers for the recovery flow. Can be `'google-drive'`
1163
1175
  */
1164
1176
  type RecoveryProviderType = (typeof SUPPORTED_RECOVERY_PROVIDERS)[number];
1165
- type LoginMethod = 'email' | 'sms' | 'siwe' | 'farcaster' | OAuthProviderType | 'passkey' | 'telegram';
1177
+ type LoginMethod = 'email' | 'sms' | 'siwe' | 'farcaster' | OAuthProviderType | 'passkey' | 'telegram' | `privy:${string}`;
1166
1178
  type LoginWithCode = {
1167
1179
  /**
1168
1180
  * One-time password _([OTP](https://en.wikipedia.org/wiki/One-time_password))_ that was sent to user during first login step
@@ -1189,7 +1201,7 @@ type WalletBranding = {
1189
1201
  id: string;
1190
1202
  icon?: string | EmbeddedSVG;
1191
1203
  };
1192
- type LinkedAccountType = 'wallet' | 'email' | 'phone' | 'google_oauth' | 'twitter_oauth' | 'discord_oauth' | 'github_oauth' | 'spotify_oauth' | 'instagram_oauth' | 'tiktok_oauth' | 'linkedin_oauth' | 'apple_oauth' | 'custom_auth' | 'farcaster' | 'passkey' | 'telegram';
1204
+ type LinkedAccountType = 'wallet' | 'email' | 'phone' | 'google_oauth' | 'twitter_oauth' | 'discord_oauth' | 'github_oauth' | 'spotify_oauth' | 'instagram_oauth' | 'tiktok_oauth' | 'linkedin_oauth' | 'apple_oauth' | 'custom_auth' | 'farcaster' | 'passkey' | 'telegram' | 'cross_app';
1193
1205
  /** @ignore */
1194
1206
  interface LinkMetadata {
1195
1207
  /** Account type, most commonly useful when filtering through linkedAccounts */
@@ -1521,6 +1533,22 @@ interface Passkey {
1521
1533
  /** Metadata about the browser that registered the passkey */
1522
1534
  createdWithBrowser?: string;
1523
1535
  }
1536
+ /** Metadata about the provider app for a cross-app account */
1537
+ interface ProviderAppMetadata {
1538
+ /** Privy app ID for the provider app. */
1539
+ id: string;
1540
+ /** Name for the provider app. */
1541
+ name?: string;
1542
+ /** Logo URL for the provider app. */
1543
+ logoUrl?: string;
1544
+ }
1545
+ interface CrossAppAccount {
1546
+ /** The user's embedded wallet address(es) from the provider app */
1547
+ embeddedWallets: {
1548
+ address: string;
1549
+ }[];
1550
+ providerApp: ProviderAppMetadata;
1551
+ }
1524
1552
  /** Object representation of a user's email, with additional metadata for advanced use cases. */
1525
1553
  interface EmailWithMetadata extends LinkMetadata, Email {
1526
1554
  /** Denotes that this is an email account. */
@@ -1601,10 +1629,15 @@ interface TelegramWithMetadata extends LinkMetadata, Telegram {
1601
1629
  /** Denotes that this is a Telegram account. */
1602
1630
  type: 'telegram';
1603
1631
  }
1632
+ /** Object representation of a user's cross-app account, with additional metadata for advanced use cases. */
1633
+ interface CrossAppAccountWithMetadata extends LinkMetadata, CrossAppAccount {
1634
+ /** Denotes that this is a cross-app account */
1635
+ type: 'cross_app';
1636
+ }
1604
1637
  /**
1605
1638
  * Object representation of a user's linked accounts
1606
1639
  */
1607
- type LinkedAccountWithMetadata = WalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata;
1640
+ type LinkedAccountWithMetadata = WalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata | CrossAppAccountWithMetadata;
1608
1641
  interface User {
1609
1642
  /** The Privy-issued DID for the user. If you need to store additional information
1610
1643
  * about a user, you can use this DID to reference them. */
@@ -2225,6 +2258,20 @@ type SendTransactionModalUIOptions = {
2225
2258
  */
2226
2259
  senderInfo?: ContractUIOptions;
2227
2260
  };
2261
+ /**
2262
+ * Our external-facing `UnsignedTransactionRequest` type makes the `chainId` field optional,
2263
+ * matching ethers, wagmi, and a bunch of other libraries. However, our modal needs to be "aware"
2264
+ * of the transaction's `chainId` to ensure it does price conversion, quote labeling, etc. importantly.
2265
+ *
2266
+ * Thus, in the modal, we enforce a stricter type `UnsignedTransactionRequestWithChainId` which wraps
2267
+ * `UnsignedTransactionRequest` to make `chainId` required.
2268
+ *
2269
+ * If the developer does not set a `chainId` in their `UnsignedTransactionRequest`, we default to the embedded
2270
+ * provider's current `chainId` in `privy-provider.tsx` > `sendTransaction`
2271
+ */
2272
+ type UnsignedTransactionRequestWithChainId = UnsignedTransactionRequest & {
2273
+ chainId: number;
2274
+ };
2228
2275
  type PrivyFarcasterSignerInitResponse = {
2229
2276
  public_key: string;
2230
2277
  status: 'pending_approval';
@@ -3470,6 +3517,71 @@ interface UseFundWalletInterface {
3470
3517
  */
3471
3518
  declare const useFundWallet: () => UseFundWalletInterface;
3472
3519
 
3520
+ /**
3521
+ * Hook to access to link and interact with cross-app accounts from a provider app.
3522
+ * You can access the fields and methods documented here via the {@link useCrossAppAccounts} hook.
3523
+ */
3524
+ interface UseCrossAppAccountsInterface {
3525
+ /**
3526
+ * For users who are authenticated, prompts the user to link their account from another Privy app to their account
3527
+ * within your app. Once a user has linked their account, you can request signatures and transactions from their embedded wallet
3528
+ * in the linked app.
3529
+ *
3530
+ * This will redirect the user to a page on the target Privy app ID where they can login and authorize access to your app.
3531
+ * @param options.appId {string} the target Privy app ID from which the user should link another Privy account
3532
+ */
3533
+ linkCrossAppAccount: ({ appId }: {
3534
+ appId: string;
3535
+ }) => void;
3536
+ /**
3537
+ * For users who have linked an account from another privy app, prompts the user to sign a message
3538
+ * with their embedded wallet from the linked privy app.
3539
+ *
3540
+ * This will redirect the user to a page on the target Privy app where they can sign the message.
3541
+ *
3542
+ *
3543
+ * @param message {string} the message to sign
3544
+ * @param options.address {string} the address of the embedded wallet from the linked privy app
3545
+ */
3546
+ signMessage: (message: string, o: {
3547
+ address: string;
3548
+ }) => Promise<string>;
3549
+ /**
3550
+ * For users who have linked an account from another privy app, prompts the user to sign typed data
3551
+ * with their embedded wallet from the linked privy app.
3552
+ *
3553
+ * This will redirect the user to a page on the target Privy app where they can sign the message.
3554
+ *
3555
+ *
3556
+ * @param data {SignTypedDataParameters} the typed data to sign
3557
+ * @param options.address {string} the address of the embedded wallet from the linked privy app
3558
+ */
3559
+ signTypedData: (data: SignTypedDataParams, o: {
3560
+ address: string;
3561
+ }) => Promise<string>;
3562
+ /**
3563
+ * For users who have linked an account from another privy app, prompts the user to send a
3564
+ * transaction with their embedded wallet from the linked privy app.
3565
+ *
3566
+ * This will redirect the user to a page on the target Privy app where they can sign the message.
3567
+ *
3568
+ *
3569
+ * @param tx {UnsignedTransactionRequestWithChainId} the transaction to send
3570
+ * @param options.address {string} the address of the embedded wallet from the linked privy app
3571
+ */
3572
+ sendTransaction: (tx: UnsignedTransactionRequestWithChainId, o: {
3573
+ address: string;
3574
+ }) => Promise<string>;
3575
+ }
3576
+ /**
3577
+ * Hook to use cross-app accounts
3578
+ *
3579
+ * @experimental
3580
+ * @returns o.linkCrossAppAccount - method to link a user's account from a provider app
3581
+ * @returns o.signMessage - method sign a message with a user's embedded wallet from a provider app
3582
+ */
3583
+ declare const useCrossAppAccounts: () => UseCrossAppAccountsInterface;
3584
+
3473
3585
  /**
3474
3586
  * Use this hook to send a transaction using the embedded wallet and to attach callbacks for success and errors.
3475
3587
  * Transactions sent from the embedded wallet using transaction functions from non-Privy libraries
@@ -3646,4 +3758,4 @@ declare const LoginModal: ({ open }: {
3646
3758
  open: boolean;
3647
3759
  }) => react_jsx_runtime.JSX.Element;
3648
3760
 
3649
- export { Apple, AppleOAuthWithMetadata, AsExternalProvider, CallbackError, Captcha, ConnectedWallet, ConnectorManager, ContractUIOptions, Discord, DiscordOAuthWithMetadata, EIP1193Provider, Email, EmailWithMetadata, Farcaster, FarcasterWithMetadata, FundWalletConfig, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, LinkedIn, LinkedInOAuthWithMetadata, LoginMethodOrderOption, LoginModal, LoginWithCode, MessageTypes, MfaMethod, MoonpayConfig, MoonpayCurrencyCode, MoonpayPaymentMethod, NonEmptyArray, OAuthProviderTokens, OAuthProviderType, Passkey, PasskeyWithMetadata, 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, UseFundWalletInterface, UseLoginWithEmail, UseLoginWithSms, UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletListEntry, WalletWithMetadata, addRpcUrlOverrideToChain, errorIndicatesMaxMfaRetries, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, getAccessToken, getEmbeddedConnectedWallet, useConnectWallet, useCreateWallet, useExperimentalFarcasterSigner, useFundWallet, useLinkAccount, useLogin, useLoginWithEmail, useLoginWithOAuth, useLoginWithSms, useLogout, useMfa, useMfaEnrollment, useModalStatus, usePrivy, useRegisterMfaListener, useSendTransaction, useSetWalletPassword, useSetWalletRecovery, useSignMessage, useSignTypedData, useToken, useWallets };
3761
+ export { Apple, AppleOAuthWithMetadata, AsExternalProvider, CallbackError, Captcha, ConnectedWallet, ConnectorManager, ContractUIOptions, CrossAppAccount, CrossAppAccountWithMetadata, Discord, DiscordOAuthWithMetadata, EIP1193Provider, Email, EmailWithMetadata, Farcaster, FarcasterWithMetadata, FundWalletConfig, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, LinkedIn, LinkedInOAuthWithMetadata, LoginMethodOrderOption, LoginModal, LoginWithCode, MessageTypes, MfaMethod, MoonpayConfig, MoonpayCurrencyCode, MoonpayPaymentMethod, NonEmptyArray, OAuthProviderTokens, OAuthProviderType, Passkey, PasskeyWithMetadata, Phone, PhoneWithMetadata, PriceDisplayOptions, PrivyClient, PrivyClientConfig, PrivyEvents, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Quantity, DEFAULT_SUPPORTED_CHAINS as SUPPORTED_CHAINS, SendCodeToEmail, SendCodeToSms, SendTransactionModalUIOptions, SignMessageModalUIOptions, SignTypedDataParams, Telegram, TelegramWithMetadata, Tiktok, TiktokOAuthWithMetadata, TransactionLog, TransactionReceipt, TransactionUIOptions, Twitter, TwitterOAuthWithMetadata, TypedMessage, UnsignedTransactionRequest, UseFundWalletInterface, UseLoginWithEmail, UseLoginWithSms, UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletListEntry, WalletWithMetadata, addRpcUrlOverrideToChain, errorIndicatesMaxMfaRetries, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, getAccessToken, getEmbeddedConnectedWallet, useConnectWallet, useCreateWallet, useCrossAppAccounts, useExperimentalFarcasterSigner, useFundWallet, useLinkAccount, useLogin, useLoginWithEmail, useLoginWithOAuth, useLoginWithSms, useLogout, useMfa, useMfaEnrollment, useModalStatus, usePrivy, useRegisterMfaListener, useSendTransaction, useSetWalletPassword, useSetWalletRecovery, useSignMessage, useSignTypedData, useToken, useWallets };