@privy-io/react-auth 1.34.1-beta.3 → 1.34.1-beta.5
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 +159 -159
- package/dist/index.d.ts +107 -28
- package/dist/index.js +157 -157
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -462,15 +462,11 @@ interface BaseConnectedWallet {
|
|
|
462
462
|
/** The first time this wallet was connected without break. */
|
|
463
463
|
connectedAt: number;
|
|
464
464
|
/**
|
|
465
|
-
* @experimental **Experimental**: This property is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
466
|
-
*
|
|
467
465
|
* The wallet client where this key-pair is stored.
|
|
468
466
|
* e.g. metamask, rainbow, coinbase_wallet, etc.
|
|
469
467
|
*/
|
|
470
468
|
walletClientType: WalletClientType;
|
|
471
469
|
/**
|
|
472
|
-
* @experimental **Experimental**: This property is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
473
|
-
*
|
|
474
470
|
* The connector used to initiate the connection with the wallet client.
|
|
475
471
|
* e.g. injected, wallet_connect, coinbase_wallet, etc.
|
|
476
472
|
*/
|
|
@@ -501,9 +497,9 @@ interface BaseConnectedWallet {
|
|
|
501
497
|
/**
|
|
502
498
|
* @experimental **Experimental**: This property is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
503
499
|
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
500
|
+
* Not all wallet clients support programmatic disconnects (e.g. MetaMask, Phantom).
|
|
501
|
+
* In kind, if the wallet's client does not support programmatic disconnects,
|
|
502
|
+
* this method will no-op.
|
|
507
503
|
*/
|
|
508
504
|
disconnect: () => void;
|
|
509
505
|
}
|
|
@@ -672,6 +668,7 @@ type PrivyServerConfig = {
|
|
|
672
668
|
customApiUrl?: string | null;
|
|
673
669
|
walletConnectCloudProjectId?: string | null;
|
|
674
670
|
embeddedWalletConfig: EmbeddedWalletsConfig;
|
|
671
|
+
captchaEnabled?: boolean;
|
|
675
672
|
/** May be deprecated from the server config in a future release */
|
|
676
673
|
logoUrl?: string;
|
|
677
674
|
/** May be deprecated from the server config in a future release */
|
|
@@ -722,6 +719,7 @@ type PrivyClientConfig = {
|
|
|
722
719
|
privacyPolicyUrl?: string | null;
|
|
723
720
|
};
|
|
724
721
|
walletConnectCloudProjectId?: string;
|
|
722
|
+
captchaEnabled?: boolean;
|
|
725
723
|
/** All embedded wallets configuration */
|
|
726
724
|
embeddedWallets?: {
|
|
727
725
|
/**
|
|
@@ -848,11 +846,11 @@ type ContractUIOptions = {
|
|
|
848
846
|
/**
|
|
849
847
|
* URL with more information about the smart contract.
|
|
850
848
|
*/
|
|
851
|
-
url
|
|
849
|
+
url?: string;
|
|
852
850
|
/**
|
|
853
851
|
* Name of smart contract being called.
|
|
854
852
|
*/
|
|
855
|
-
name
|
|
853
|
+
name?: string;
|
|
856
854
|
/**
|
|
857
855
|
* URL for an image to show in the Send Transaction screen.
|
|
858
856
|
*/
|
|
@@ -1128,6 +1126,8 @@ interface PrivyInterface {
|
|
|
1128
1126
|
* You may use this token to authorize requests sent from your frontend, and can validate it in your backend against your app's Privy verification key.
|
|
1129
1127
|
*
|
|
1130
1128
|
* This will automatically attempt to refresh the session if the token is expired or about to expire.
|
|
1129
|
+
*
|
|
1130
|
+
* @returns Promise for the user's access token as a string if they are authenticated, null if they are unauthenticated.
|
|
1131
1131
|
*/
|
|
1132
1132
|
getAccessToken: () => Promise<string | null>;
|
|
1133
1133
|
/**
|
|
@@ -1164,35 +1164,59 @@ interface PrivyInterface {
|
|
|
1164
1164
|
walletConnectors: ConnectorManager | null;
|
|
1165
1165
|
/**
|
|
1166
1166
|
* Unlink an email account from a user, by passing the email address. Note that you can only unlink an email account if the user has at least one other account.
|
|
1167
|
+
*
|
|
1168
|
+
* @param address {string} email address to be unlinked
|
|
1169
|
+
* @returns Promise for the {@link User} object after the provided email has been unlinked
|
|
1167
1170
|
*/
|
|
1168
1171
|
unlinkEmail: (address: string) => Promise<User>;
|
|
1169
1172
|
/**
|
|
1170
1173
|
* Unlink a phone account from a user, by passing the phone number. Note that you can only unlink a phone account if the user has at least one other account.
|
|
1174
|
+
*
|
|
1175
|
+
* @param phoneNumber {string} phone number to be unlinked
|
|
1176
|
+
* @returns Promise for the {@link User} object after the provided phone number has been unlinked
|
|
1171
1177
|
*/
|
|
1172
1178
|
unlinkPhone: (phoneNumber: string) => Promise<User>;
|
|
1173
1179
|
/**
|
|
1174
1180
|
* Unlink a wallet account from a user, by passing the public address. Note that you can only unlink a wallet account if the user has at least one other account.
|
|
1175
1181
|
* If the unlinked wallet was the active one, and more wallets are linked to the user, then we attempt to make the most recently linked wallet active.
|
|
1182
|
+
*
|
|
1183
|
+
* @param address {string} wallet address to be unlinked
|
|
1184
|
+
* @returns Promise for the {@link User} object after the provided wallet has been unlinked
|
|
1176
1185
|
*/
|
|
1177
1186
|
unlinkWallet: (address: string) => Promise<User>;
|
|
1178
1187
|
/**
|
|
1179
1188
|
* Unlink a Google social account from a user, by passing the google subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1189
|
+
*
|
|
1190
|
+
* @param subject {string} google account's subject ID
|
|
1191
|
+
* @returns Promise for the {@link User} object after the provided Google account has been unlinked
|
|
1180
1192
|
*/
|
|
1181
1193
|
unlinkGoogle: (subject: string) => Promise<User>;
|
|
1182
1194
|
/**
|
|
1183
1195
|
* Unlink a Twitter social account from a user, by passing the twitter subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1196
|
+
*
|
|
1197
|
+
* @param subject {string} twitter account's subject ID
|
|
1198
|
+
* @returns Promise for the {@link User} object after the provided Twitter account has been unlinked
|
|
1184
1199
|
*/
|
|
1185
1200
|
unlinkTwitter: (subject: string) => Promise<User>;
|
|
1186
1201
|
/**
|
|
1187
1202
|
* Unlink a Discord social account from a user, by passing the discord subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1203
|
+
*
|
|
1204
|
+
* @param subject {string} discord account's subject ID
|
|
1205
|
+
* @returns Promise for the {@link User} object after the provided Discord account has been unlinked
|
|
1188
1206
|
*/
|
|
1189
1207
|
unlinkDiscord: (subject: string) => Promise<User>;
|
|
1190
1208
|
/**
|
|
1191
1209
|
* Unlink a Github social account from a user, by passing the github subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1210
|
+
*
|
|
1211
|
+
* @param subject {string} github account's subject ID
|
|
1212
|
+
* @returns Promise for the {@link User} object after the provided Github account has been unlinked
|
|
1192
1213
|
*/
|
|
1193
1214
|
unlinkGithub: (subject: string) => Promise<User>;
|
|
1194
1215
|
/**
|
|
1195
1216
|
* Unlink a Apple social account from a user, by passing the apple subject ID. Note that you can only unlink a social account if the user has at least one other account.
|
|
1217
|
+
*
|
|
1218
|
+
* @param subject {string} apple account's subject ID
|
|
1219
|
+
* @returns Promise for the {@link User} object after the provided Apple account has been unlinked
|
|
1196
1220
|
*/
|
|
1197
1221
|
unlinkApple: (subject: string) => Promise<User>;
|
|
1198
1222
|
/**
|
|
@@ -1209,28 +1233,62 @@ interface PrivyInterface {
|
|
|
1209
1233
|
*/
|
|
1210
1234
|
forkSession: () => Promise<string>;
|
|
1211
1235
|
/**
|
|
1212
|
-
*
|
|
1236
|
+
* Creates an embedded wallet for the current user.
|
|
1237
|
+
*
|
|
1238
|
+
* This method will error if the user already has an embedded wallet or if they
|
|
1239
|
+
* exit in the middle of the flow.
|
|
1213
1240
|
*
|
|
1214
|
-
*
|
|
1241
|
+
* If the `config.embeddedWallets.requireUserPasscodeOnCreate` property is set to true,
|
|
1242
|
+
* this will prompt the user to enter a passcode to secure the recovery share of their
|
|
1243
|
+
* embedded wallet.
|
|
1215
1244
|
*
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1245
|
+
* Otherwise (the default), Privy will secure the recovery share, and the embedded wallet
|
|
1246
|
+
* will be created without showing any UIs to the user.
|
|
1218
1247
|
*
|
|
1219
|
-
*
|
|
1220
|
-
* wallet or port it across devices.
|
|
1248
|
+
* @returns Promise for the {@link Wallet} object for the newly created embedded wallet
|
|
1221
1249
|
*/
|
|
1222
1250
|
createWallet: () => Promise<Wallet>;
|
|
1223
1251
|
/**
|
|
1224
|
-
*
|
|
1252
|
+
* Prompts a user to sign a message using their embedded wallet using EIP-191's `personal_sign`
|
|
1253
|
+
* method (0x45).
|
|
1225
1254
|
*
|
|
1226
|
-
*
|
|
1255
|
+
* This method will error if the user is not authenticated or does not have an embedded wallet.
|
|
1227
1256
|
*
|
|
1228
|
-
*
|
|
1257
|
+
* If the `config.embeddedWallets.noPromptOnSignature` property is set to true, the signature will
|
|
1258
|
+
* be computed without prompting the user. Otherwise (the default), Privy will show the user a modal
|
|
1259
|
+
* to prompt them for a signature. This can be customized via the {@link SignMessageModalUIOptions}.
|
|
1229
1260
|
*
|
|
1230
|
-
*
|
|
1261
|
+
* @param message {string} message to be signed
|
|
1262
|
+
* @param uiOptions {@link SignMessageModalUIOptions} (optional) UI options to customize the signature prompt modal
|
|
1263
|
+
* @returns Promise for the signature as a string
|
|
1231
1264
|
*/
|
|
1232
1265
|
signMessage: (message: string, uiOptions?: SignMessageModalUIOptions) => Promise<string>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Prompts a user to send a transaction using their embedded wallet.
|
|
1268
|
+
*
|
|
1269
|
+
* This method will error if the user is not authenticated or does not have an embedded wallet.
|
|
1270
|
+
*
|
|
1271
|
+
* If no `chainId` is specified as part of the {@link UnsignedTransactionRequest}, Privy will default
|
|
1272
|
+
* to the embedded wallet's current chain ID.
|
|
1273
|
+
*
|
|
1274
|
+
* If the `config.embeddedWallets.noPromptOnSignature` property is set to true, the wallet will
|
|
1275
|
+
* attempt to send the transaction without prompting the user. Otherwise (the default), Privy
|
|
1276
|
+
* will show the user a modal to have them confirm the transaction. This can be customized via
|
|
1277
|
+
* the {@link SendTransactionModalUIOptions}.
|
|
1278
|
+
*
|
|
1279
|
+
* @param data {@link UnsignedTransactionRequest} transaction to be sent
|
|
1280
|
+
* @param uiOptions {@link SendTransactionModalUIOptions} (optional) UI options to customize the transaction request modal
|
|
1281
|
+
* @returns Promise for the transaction's {@link TransactionReceipt}
|
|
1282
|
+
*/
|
|
1233
1283
|
sendTransaction: (data: UnsignedTransactionRequest, uiOptions?: SendTransactionModalUIOptions) => Promise<TransactionReceipt>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Shows the user a Privy modal, from which they can copy their embedded wallet's private
|
|
1286
|
+
* key for easy export to another wallet client (e.g. MetaMask). The private key is loaded
|
|
1287
|
+
* on an iframe running on a separate domain from your app, meaning your app cannot access it.
|
|
1288
|
+
*
|
|
1289
|
+
* This method will error if the user is not authenticated or does not have an embedded wallet.
|
|
1290
|
+
* @returns Promise that resolves once the user exits the modal
|
|
1291
|
+
*/
|
|
1234
1292
|
exportWallet: () => Promise<void>;
|
|
1235
1293
|
}
|
|
1236
1294
|
/**
|
|
@@ -1506,16 +1564,15 @@ type PrivyEvents = {
|
|
|
1506
1564
|
* this will run after the user successfully authenticates _and_ creates their wallet (if applicable).
|
|
1507
1565
|
* - If a user is already authenticated, this will run immediately and the `wasAlreadyAuthenticated` flag will be set to `true`.
|
|
1508
1566
|
*
|
|
1509
|
-
* @param user {User}
|
|
1510
|
-
* @param isNewUser {boolean}
|
|
1567
|
+
* @param user {@link User} the `user` oject corresponding to the authenticated user
|
|
1568
|
+
* @param isNewUser {boolean} boolean flag indicating if this is the user's first time logging in to your app
|
|
1511
1569
|
* @param wasAlreadyAuthenticated {boolean} - boolean flag indicating whether the user entered the application already authenticated
|
|
1512
|
-
*
|
|
1513
1570
|
*/
|
|
1514
1571
|
onComplete?: (user: User, isNewUser: boolean, wasAlreadyAuthenticated: boolean) => void;
|
|
1515
1572
|
/**
|
|
1516
1573
|
* Callback that will execute in the case of a non-successful login.
|
|
1517
1574
|
*
|
|
1518
|
-
* @param error {PrivyErrorCode} - the corresponding error code
|
|
1575
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1519
1576
|
*
|
|
1520
1577
|
*/
|
|
1521
1578
|
onError?: CallbackError;
|
|
@@ -1531,20 +1588,27 @@ type PrivyEvents = {
|
|
|
1531
1588
|
* Callback that will execute once a successful `connectWallet` completes.
|
|
1532
1589
|
* This will not run in the case of a wallet-based authentication flow.
|
|
1533
1590
|
*
|
|
1534
|
-
* @param wallet {BaseConnectedWallet}
|
|
1535
|
-
*
|
|
1591
|
+
* @param wallet {@link BaseConnectedWallet} the `wallet` object correspending to the connection
|
|
1536
1592
|
*/
|
|
1537
1593
|
onSuccess?: (wallet: BaseConnectedWallet) => void;
|
|
1538
1594
|
/**
|
|
1539
1595
|
* Callback that will execute in the case of a non-successful wallet connection.
|
|
1540
1596
|
*
|
|
1541
|
-
* @param error {PrivyErrorCode} - the corresponding error code
|
|
1542
|
-
*
|
|
1597
|
+
* @param error {@link PrivyErrorCode} - the corresponding error code
|
|
1543
1598
|
*/
|
|
1544
1599
|
onError?: CallbackError;
|
|
1545
1600
|
};
|
|
1546
1601
|
};
|
|
1547
1602
|
|
|
1603
|
+
/**
|
|
1604
|
+
* Use this hook to log the user in, and to attach callbacks
|
|
1605
|
+
* for successful `login`s, already-`authenticated` users, and
|
|
1606
|
+
* `login` errors.
|
|
1607
|
+
*
|
|
1608
|
+
* @param callbacks.onComplete {@link PrivyEvents} callback to execute for already- or newly-`authenticated` users
|
|
1609
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `login`.
|
|
1610
|
+
* @returns login - opens the Privy modal and prompts the user to login
|
|
1611
|
+
*/
|
|
1548
1612
|
declare function useLogin(callbacks?: PrivyEvents['login']): {
|
|
1549
1613
|
/**
|
|
1550
1614
|
* Opens the Privy login modal and prompts the user to login.
|
|
@@ -1552,6 +1616,12 @@ declare function useLogin(callbacks?: PrivyEvents['login']): {
|
|
|
1552
1616
|
login: () => void;
|
|
1553
1617
|
};
|
|
1554
1618
|
|
|
1619
|
+
/**
|
|
1620
|
+
* Use this hook to log the user out, and to attach a callback after a successful logout.
|
|
1621
|
+
*
|
|
1622
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute when a user successfully logs out.
|
|
1623
|
+
* @returns logout - logs the user out and clears their authentication state.
|
|
1624
|
+
*/
|
|
1555
1625
|
declare function useLogout(callbacks?: PrivyEvents['logout']): {
|
|
1556
1626
|
/**
|
|
1557
1627
|
* Log the current user out and clears their authentication state. `authenticated` will become false, `user` will become null, and the Privy Auth tokens will be deleted from the browser's local storage.
|
|
@@ -1559,6 +1629,15 @@ declare function useLogout(callbacks?: PrivyEvents['logout']): {
|
|
|
1559
1629
|
logout: () => Promise<void>;
|
|
1560
1630
|
};
|
|
1561
1631
|
|
|
1632
|
+
/**
|
|
1633
|
+
* Use this hook to connect the user's external wallet, and to attach
|
|
1634
|
+
* callbacks after a user succesfully connects their wallet, or if there
|
|
1635
|
+
* is an error during the connection attempt.
|
|
1636
|
+
*
|
|
1637
|
+
* @param callbacks.onSuccess {@link PrivyEvents} callback to execute when a user successfully connects their wallet
|
|
1638
|
+
* @param callbacks.onError {@link PrivyEvents} callback to execute when a user attempts to connect their wallet, but there is an error
|
|
1639
|
+
* @returns connectWallet - opens the Privy modal and prompts the user to connect an external wallet
|
|
1640
|
+
*/
|
|
1562
1641
|
declare function useConnectWallet(callbacks?: PrivyEvents['connectWallet']): {
|
|
1563
1642
|
/**
|
|
1564
1643
|
* Opens the Privy modal and prompts the user to connect a wallet.
|
|
@@ -1613,4 +1692,4 @@ type Chain = {
|
|
|
1613
1692
|
|
|
1614
1693
|
declare const SUPPORTED_CHAINS: readonly [Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain];
|
|
1615
1694
|
|
|
1616
|
-
export { Apple, AppleOAuthWithMetadata, AsExternalProvider, ConnectedWallet, ConnectorManager, ContractUIOptions, Discord, DiscordOAuthWithMetadata, EIP1193Provider, Email, EmailWithMetadata, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, Phone, PhoneWithMetadata, PrivyClient, PrivyClientConfig, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Quantity, SUPPORTED_CHAINS, SendTransactionModalUIOptions, SignMessageModalUIOptions, TransactionLog, TransactionReceipt, TransactionUIOptions, Twitter, TwitterOAuthWithMetadata, UnsignedTransactionRequest, UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletWithMetadata, getAccessToken, useConnectWallet, useLogin, useLogout, usePrivy, useWallets };
|
|
1695
|
+
export { Apple, AppleOAuthWithMetadata, AsExternalProvider, CallbackError, ConnectedWallet, ConnectorManager, ContractUIOptions, Discord, DiscordOAuthWithMetadata, EIP1193Provider, Email, EmailWithMetadata, Github, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, Phone, PhoneWithMetadata, PrivyClient, PrivyClientConfig, PrivyEvents, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Quantity, SUPPORTED_CHAINS, SendTransactionModalUIOptions, SignMessageModalUIOptions, TransactionLog, TransactionReceipt, TransactionUIOptions, Twitter, TwitterOAuthWithMetadata, UnsignedTransactionRequest, UseWalletsInterface, User, VERSION, Wallet, WalletConnector, WalletWithMetadata, getAccessToken, useConnectWallet, useLogin, useLogout, usePrivy, useWallets };
|