@privy-io/react-auth 1.68.0 → 1.69.0-alpha-20240606205421
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/esm/index.js +293 -285
- package/dist/index.d.ts +118 -15
- package/dist/index.js +293 -285
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -238,15 +238,12 @@ type WalletImportRequestDataType = {
|
|
|
238
238
|
accessToken: string;
|
|
239
239
|
privateKey: string;
|
|
240
240
|
};
|
|
241
|
-
type
|
|
241
|
+
type WalletSetRecoveryRequestDataType = {
|
|
242
242
|
accessToken: string;
|
|
243
243
|
address: string;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
* @deprecated
|
|
248
|
-
*/
|
|
249
|
-
recoveryPin?: string;
|
|
244
|
+
recoveryMethod: UserRecoveryMethod;
|
|
245
|
+
recoveryPassword?: string;
|
|
246
|
+
recoveryAccessToken?: string;
|
|
250
247
|
};
|
|
251
248
|
type WalletRecoverRequestDataType = {
|
|
252
249
|
address: string;
|
|
@@ -256,7 +253,7 @@ type WalletRecoverRequestDataType = {
|
|
|
256
253
|
mfaMethod?: MfaMethod;
|
|
257
254
|
relyingParty?: string;
|
|
258
255
|
recoveryPassword?: string;
|
|
259
|
-
recoveryMethod?: UserRecoveryMethod;
|
|
256
|
+
recoveryMethod?: UserRecoveryMethod | 'privy';
|
|
260
257
|
recoveryAccessToken?: string;
|
|
261
258
|
/**
|
|
262
259
|
* Will be deprecated in a future release, use `recoveryPassword` instead
|
|
@@ -340,7 +337,7 @@ type WalletConnectResponseDataType = {
|
|
|
340
337
|
type WalletRecoverResponseDataType = {
|
|
341
338
|
address: string;
|
|
342
339
|
};
|
|
343
|
-
type
|
|
340
|
+
type WalletSetRecoveryResponseDataType = {
|
|
344
341
|
address: string;
|
|
345
342
|
};
|
|
346
343
|
type WalletRpcResponseDataType = {
|
|
@@ -368,7 +365,7 @@ interface EmbeddedWalletProxy {
|
|
|
368
365
|
import: (data: WalletImportRequestDataType) => Promise<WalletImportResponseDataType>;
|
|
369
366
|
connect: (data: WalletConnectRequestDataType) => Promise<WalletConnectResponseDataType>;
|
|
370
367
|
recover: (data: WalletRecoverRequestDataType) => Promise<WalletRecoverResponseDataType>;
|
|
371
|
-
|
|
368
|
+
setRecovery: (data: WalletSetRecoveryRequestDataType) => Promise<WalletSetRecoveryResponseDataType>;
|
|
372
369
|
rpc: (data: WalletRpcRequestDataType) => Promise<WalletRpcResponseDataType>;
|
|
373
370
|
verifyMfa: (data: MfaVerifyRequestDataType) => Promise<MfaVerifyResponseDataType>;
|
|
374
371
|
initEnrollMfa: (data: MfaInitEnrollmentRequestDataType) => Promise<MfaInitEnrollmentResponseDataType>;
|
|
@@ -800,7 +797,17 @@ interface ResponseTelegramAccount {
|
|
|
800
797
|
first_verified_at: number | null;
|
|
801
798
|
latest_verified_at: number | null;
|
|
802
799
|
}
|
|
803
|
-
|
|
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>;
|
|
804
811
|
interface ResponseSmsMfaMethod {
|
|
805
812
|
type: 'sms';
|
|
806
813
|
verified_at: number;
|
|
@@ -1040,6 +1047,7 @@ declare class PrivyClient {
|
|
|
1040
1047
|
user: User | null;
|
|
1041
1048
|
oAuthProviderTokens?: OAuthProviderTokens | undefined;
|
|
1042
1049
|
}>;
|
|
1050
|
+
storeGuestAccessToken(appId: string, guestAccessToken: string | null): void;
|
|
1043
1051
|
logout(): Promise<void>;
|
|
1044
1052
|
startAuthFlow<T extends AuthFlow>(authFlow: T): T;
|
|
1045
1053
|
initMfaSmsVerification(): Promise<void>;
|
|
@@ -1165,7 +1173,7 @@ type OAuthProviderType = (typeof SUPPORTED_OAUTH_PROVIDERS)[number];
|
|
|
1165
1173
|
* Supported OAuth providers for the recovery flow. Can be `'google-drive'`
|
|
1166
1174
|
*/
|
|
1167
1175
|
type RecoveryProviderType = (typeof SUPPORTED_RECOVERY_PROVIDERS)[number];
|
|
1168
|
-
type LoginMethod = 'email' | 'sms' | 'siwe' | 'farcaster' | OAuthProviderType | 'passkey' | 'telegram'
|
|
1176
|
+
type LoginMethod = 'email' | 'sms' | 'siwe' | 'farcaster' | OAuthProviderType | 'passkey' | 'telegram' | `privy:${string}`;
|
|
1169
1177
|
type LoginWithCode = {
|
|
1170
1178
|
/**
|
|
1171
1179
|
* One-time password _([OTP](https://en.wikipedia.org/wiki/One-time_password))_ that was sent to user during first login step
|
|
@@ -1192,7 +1200,7 @@ type WalletBranding = {
|
|
|
1192
1200
|
id: string;
|
|
1193
1201
|
icon?: string | EmbeddedSVG;
|
|
1194
1202
|
};
|
|
1195
|
-
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';
|
|
1203
|
+
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';
|
|
1196
1204
|
/** @ignore */
|
|
1197
1205
|
interface LinkMetadata {
|
|
1198
1206
|
/** Account type, most commonly useful when filtering through linkedAccounts */
|
|
@@ -1524,6 +1532,22 @@ interface Passkey {
|
|
|
1524
1532
|
/** Metadata about the browser that registered the passkey */
|
|
1525
1533
|
createdWithBrowser?: string;
|
|
1526
1534
|
}
|
|
1535
|
+
/** Metadata about the provider app for a cross-app account */
|
|
1536
|
+
interface ProviderAppMetadata {
|
|
1537
|
+
/** Privy app ID for the provider app. */
|
|
1538
|
+
id: string;
|
|
1539
|
+
/** Name for the provider app. */
|
|
1540
|
+
name?: string;
|
|
1541
|
+
/** Logo URL for the provider app. */
|
|
1542
|
+
logoUrl?: string;
|
|
1543
|
+
}
|
|
1544
|
+
interface CrossAppAccount {
|
|
1545
|
+
/** The user's embedded wallet address(es) from the provider app */
|
|
1546
|
+
embeddedWallets: {
|
|
1547
|
+
address: string;
|
|
1548
|
+
}[];
|
|
1549
|
+
providerApp: ProviderAppMetadata;
|
|
1550
|
+
}
|
|
1527
1551
|
/** Object representation of a user's email, with additional metadata for advanced use cases. */
|
|
1528
1552
|
interface EmailWithMetadata extends LinkMetadata, Email {
|
|
1529
1553
|
/** Denotes that this is an email account. */
|
|
@@ -1604,10 +1628,15 @@ interface TelegramWithMetadata extends LinkMetadata, Telegram {
|
|
|
1604
1628
|
/** Denotes that this is a Telegram account. */
|
|
1605
1629
|
type: 'telegram';
|
|
1606
1630
|
}
|
|
1631
|
+
/** Object representation of a user's cross-app account, with additional metadata for advanced use cases. */
|
|
1632
|
+
interface CrossAppAccountWithMetadata extends LinkMetadata, CrossAppAccount {
|
|
1633
|
+
/** Denotes that this is a cross-app account */
|
|
1634
|
+
type: 'cross_app';
|
|
1635
|
+
}
|
|
1607
1636
|
/**
|
|
1608
1637
|
* Object representation of a user's linked accounts
|
|
1609
1638
|
*/
|
|
1610
|
-
type LinkedAccountWithMetadata = WalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata;
|
|
1639
|
+
type LinkedAccountWithMetadata = WalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata | SpotifyOAuthWithMetadata | InstagramOAuthWithMetadata | TiktokOAuthWithMetadata | LinkedInOAuthWithMetadata | AppleOAuthWithMetadata | CustomJwtAccountWithMetadata | FarcasterWithMetadata | PasskeyWithMetadata | TelegramWithMetadata | CrossAppAccountWithMetadata;
|
|
1611
1640
|
interface User {
|
|
1612
1641
|
/** The Privy-issued DID for the user. If you need to store additional information
|
|
1613
1642
|
* about a user, you can use this DID to reference them. */
|
|
@@ -2620,6 +2649,8 @@ interface PrivyInterface {
|
|
|
2620
2649
|
*/
|
|
2621
2650
|
createWallet: () => Promise<Wallet>;
|
|
2622
2651
|
/**
|
|
2652
|
+
* @deprecated. Use `setWalletRecovery` instead.
|
|
2653
|
+
*
|
|
2623
2654
|
* Set (or reset) a password on a wallet.
|
|
2624
2655
|
*
|
|
2625
2656
|
* This method will error if the user does not have an embedded wallet or if the user exits in the middle of the flow.
|
|
@@ -2627,6 +2658,15 @@ interface PrivyInterface {
|
|
|
2627
2658
|
* @returns Promise for the {@link Wallet} object for the updated embedded wallet
|
|
2628
2659
|
*/
|
|
2629
2660
|
setWalletPassword: () => Promise<Wallet>;
|
|
2661
|
+
/**
|
|
2662
|
+
* Prompt the user to enable wallet recovery. Current recovery options include password, Google Drive, and iCloud.
|
|
2663
|
+
*
|
|
2664
|
+
* This method will error if the user does not have an embedded wallet, if the user's
|
|
2665
|
+
* embedded wallet already has a cloud-based recovery set, or if the user exits in the middle of the flow.
|
|
2666
|
+
*
|
|
2667
|
+
* @returns Promise for the {@link Wallet} object for the updated embedded wallet
|
|
2668
|
+
*/
|
|
2669
|
+
setWalletRecovery: () => Promise<Wallet>;
|
|
2630
2670
|
/**
|
|
2631
2671
|
* Prompts a user to sign a message using their embedded wallet using EIP-191's `personal_sign`
|
|
2632
2672
|
* method (0x45).
|
|
@@ -3089,6 +3129,19 @@ interface PrivyEvents {
|
|
|
3089
3129
|
*/
|
|
3090
3130
|
onError?: CallbackError;
|
|
3091
3131
|
};
|
|
3132
|
+
setWalletRecovery: {
|
|
3133
|
+
/**
|
|
3134
|
+
* Callback that will execute once a successful `setWalletRecovery` completes.
|
|
3135
|
+
* @param wallet {@link Wallet}- the `walle]et` object that the recovery was set for
|
|
3136
|
+
*/
|
|
3137
|
+
onSuccess?: (method: UserRecoveryMethod, wallet: Wallet) => void;
|
|
3138
|
+
/**
|
|
3139
|
+
* Callback that will execute in the case of a non-successful setWalletRecovery.
|
|
3140
|
+
*
|
|
3141
|
+
* @param error {PrivyErrorCode} - the corresponding error code
|
|
3142
|
+
*/
|
|
3143
|
+
onError?: CallbackError;
|
|
3144
|
+
};
|
|
3092
3145
|
signMessage: {
|
|
3093
3146
|
/**
|
|
3094
3147
|
* Callback that will execute once a successful `signMessage` completes.
|
|
@@ -3447,6 +3500,31 @@ interface UseFundWalletInterface {
|
|
|
3447
3500
|
*/
|
|
3448
3501
|
declare const useFundWallet: () => UseFundWalletInterface;
|
|
3449
3502
|
|
|
3503
|
+
/**
|
|
3504
|
+
* Hook to access to link and interact with cross-app accounts from a provider app.
|
|
3505
|
+
* You can access the fields and methods documented here via the {@link useCrossAppAccounts} hook.
|
|
3506
|
+
*/
|
|
3507
|
+
interface UseCrossAppAccountsInterface {
|
|
3508
|
+
/**
|
|
3509
|
+
* For users who are authenticated, prompts the user to link their account from another Privy app to their account
|
|
3510
|
+
* within your app. Once a user has linked their account, you can request signatures and transactions from their embedded wallet
|
|
3511
|
+
* in the linked app.
|
|
3512
|
+
*
|
|
3513
|
+
* This will redirect the user to a page on the target Privy app ID where they can login and authorize access to your app.
|
|
3514
|
+
* @param options.appId {string} the target Privy app ID from which the user should link another Privy account
|
|
3515
|
+
*/
|
|
3516
|
+
linkCrossAppAccount: ({ appId }: {
|
|
3517
|
+
appId: string;
|
|
3518
|
+
}) => void;
|
|
3519
|
+
}
|
|
3520
|
+
/**
|
|
3521
|
+
* Hook to use cross-app accounts
|
|
3522
|
+
*
|
|
3523
|
+
* @experimental
|
|
3524
|
+
* @returns linkCrossAppAccount - method to link a user's account from a provider app
|
|
3525
|
+
*/
|
|
3526
|
+
declare const useCrossAppAccounts: () => UseCrossAppAccountsInterface;
|
|
3527
|
+
|
|
3450
3528
|
/**
|
|
3451
3529
|
* Use this hook to send a transaction using the embedded wallet and to attach callbacks for success and errors.
|
|
3452
3530
|
* Transactions sent from the embedded wallet using transaction functions from non-Privy libraries
|
|
@@ -3480,6 +3558,23 @@ declare function useSetWalletPassword(callbacks?: PrivyEvents['setWalletPassword
|
|
|
3480
3558
|
setWalletPassword: () => Promise<Wallet>;
|
|
3481
3559
|
};
|
|
3482
3560
|
|
|
3561
|
+
/**
|
|
3562
|
+
* Use this hook to set user-controlled recovery on the embedded wallet, and to attach callbacks
|
|
3563
|
+
* for successful `recovery set`s, and `recovery set` errors.
|
|
3564
|
+
* Note that the callbacks will only fire for explicit `setWalletRecovery` calls from the Privy SDK.
|
|
3565
|
+
*
|
|
3566
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute for a successful recovery setting
|
|
3567
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `setWalletRecovery` -- ie.
|
|
3568
|
+
* the user doesn't have an embedded wallet, the user already has a cloud-based recovery on the wallet, or the password flow is prematurely exited.
|
|
3569
|
+
* @returns setWalletRecovery - opens the Privy modal and prompts the user to set a password on the embedded wallet
|
|
3570
|
+
*/
|
|
3571
|
+
declare function useSetWalletRecovery(callbacks?: PrivyEvents['setWalletRecovery']): {
|
|
3572
|
+
/**
|
|
3573
|
+
* Opens the Privy set recovery modal and prompts the user to set wallet password.
|
|
3574
|
+
*/
|
|
3575
|
+
setWalletRecovery: () => Promise<Wallet>;
|
|
3576
|
+
};
|
|
3577
|
+
|
|
3483
3578
|
/**
|
|
3484
3579
|
* Use this hook to sign a message using the embedded wallet, and to attach callbacks for success and errors.
|
|
3485
3580
|
*
|
|
@@ -3594,8 +3689,16 @@ declare function addRpcUrlOverrideToChain(chain: Chain, rpcUrl: string): {
|
|
|
3594
3689
|
testnet?: boolean | undefined;
|
|
3595
3690
|
};
|
|
3596
3691
|
|
|
3692
|
+
/**
|
|
3693
|
+
* Get the embedded wallet for the user if they have one.
|
|
3694
|
+
*
|
|
3695
|
+
* @param wallets {@link ConnectedWallet} the array of wallets fetched via {@link useWallets}
|
|
3696
|
+
* @returns the embedded wallet if it exists, otherwise null
|
|
3697
|
+
*/
|
|
3698
|
+
declare function getEmbeddedConnectedWallet(wallets: ConnectedWallet[]): ConnectedWallet | null;
|
|
3699
|
+
|
|
3597
3700
|
declare const LoginModal: ({ open }: {
|
|
3598
3701
|
open: boolean;
|
|
3599
3702
|
}) => react_jsx_runtime.JSX.Element;
|
|
3600
3703
|
|
|
3601
|
-
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, useConnectWallet, useCreateWallet, useExperimentalFarcasterSigner, useFundWallet, useLinkAccount, useLogin, useLoginWithEmail, useLoginWithOAuth, useLoginWithSms, useLogout, useMfa, useMfaEnrollment, useModalStatus, usePrivy, useRegisterMfaListener, useSendTransaction, useSetWalletPassword, useSignMessage, useSignTypedData, useToken, useWallets };
|
|
3704
|
+
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, useCrossAppAccounts, useExperimentalFarcasterSigner, useFundWallet, useLinkAccount, useLogin, useLoginWithEmail, useLoginWithOAuth, useLoginWithSms, useLogout, useMfa, useMfaEnrollment, useModalStatus, usePrivy, useRegisterMfaListener, useSendTransaction, useSetWalletPassword, useSetWalletRecovery, useSignMessage, useSignTypedData, useToken, useWallets };
|