@privy-io/react-auth 1.34.1-beta.2 → 1.34.1-beta.4

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
@@ -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
- * Disconnect method does not work on all connector types and will no-op if
505
- * an incompatible connector is used (metamask and phantom do not support
506
- * programmatic disconnects)
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
  }
@@ -848,11 +844,11 @@ type ContractUIOptions = {
848
844
  /**
849
845
  * URL with more information about the smart contract.
850
846
  */
851
- url: string;
847
+ url?: string;
852
848
  /**
853
849
  * Name of smart contract being called.
854
850
  */
855
- name: string;
851
+ name?: string;
856
852
  /**
857
853
  * URL for an image to show in the Send Transaction screen.
858
854
  */
@@ -1128,6 +1124,8 @@ interface PrivyInterface {
1128
1124
  * 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
1125
  *
1130
1126
  * This will automatically attempt to refresh the session if the token is expired or about to expire.
1127
+ *
1128
+ * @returns Promise for the user's access token as a string if they are authenticated, null if they are unauthenticated.
1131
1129
  */
1132
1130
  getAccessToken: () => Promise<string | null>;
1133
1131
  /**
@@ -1164,35 +1162,59 @@ interface PrivyInterface {
1164
1162
  walletConnectors: ConnectorManager | null;
1165
1163
  /**
1166
1164
  * 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.
1165
+ *
1166
+ * @param address {string} email address to be unlinked
1167
+ * @returns Promise for the {@link User} object after the provided email has been unlinked
1167
1168
  */
1168
1169
  unlinkEmail: (address: string) => Promise<User>;
1169
1170
  /**
1170
1171
  * 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.
1172
+ *
1173
+ * @param phoneNumber {string} phone number to be unlinked
1174
+ * @returns Promise for the {@link User} object after the provided phone number has been unlinked
1171
1175
  */
1172
1176
  unlinkPhone: (phoneNumber: string) => Promise<User>;
1173
1177
  /**
1174
1178
  * 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
1179
  * 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.
1180
+ *
1181
+ * @param address {string} wallet address to be unlinked
1182
+ * @returns Promise for the {@link User} object after the provided wallet has been unlinked
1176
1183
  */
1177
1184
  unlinkWallet: (address: string) => Promise<User>;
1178
1185
  /**
1179
1186
  * 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.
1187
+ *
1188
+ * @param subject {string} google account's subject ID
1189
+ * @returns Promise for the {@link User} object after the provided Google account has been unlinked
1180
1190
  */
1181
1191
  unlinkGoogle: (subject: string) => Promise<User>;
1182
1192
  /**
1183
1193
  * 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.
1194
+ *
1195
+ * @param subject {string} twitter account's subject ID
1196
+ * @returns Promise for the {@link User} object after the provided Twitter account has been unlinked
1184
1197
  */
1185
1198
  unlinkTwitter: (subject: string) => Promise<User>;
1186
1199
  /**
1187
1200
  * 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.
1201
+ *
1202
+ * @param subject {string} discord account's subject ID
1203
+ * @returns Promise for the {@link User} object after the provided Discord account has been unlinked
1188
1204
  */
1189
1205
  unlinkDiscord: (subject: string) => Promise<User>;
1190
1206
  /**
1191
1207
  * 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.
1208
+ *
1209
+ * @param subject {string} github account's subject ID
1210
+ * @returns Promise for the {@link User} object after the provided Github account has been unlinked
1192
1211
  */
1193
1212
  unlinkGithub: (subject: string) => Promise<User>;
1194
1213
  /**
1195
1214
  * 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.
1215
+ *
1216
+ * @param subject {string} apple account's subject ID
1217
+ * @returns Promise for the {@link User} object after the provided Apple account has been unlinked
1196
1218
  */
1197
1219
  unlinkApple: (subject: string) => Promise<User>;
1198
1220
  /**
@@ -1209,28 +1231,62 @@ interface PrivyInterface {
1209
1231
  */
1210
1232
  forkSession: () => Promise<string>;
1211
1233
  /**
1212
- * @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
1234
+ * Creates an embedded wallet for the current user.
1235
+ *
1236
+ * This method will error if the user already has an embedded wallet or if they
1237
+ * exit in the middle of the flow.
1213
1238
  *
1214
- * Prompts a user to create an Ethereum wallet through Privy.
1239
+ * If the `config.embeddedWallets.requireUserPasscodeOnCreate` property is set to true,
1240
+ * this will prompt the user to enter a passcode to secure the recovery share of their
1241
+ * embedded wallet.
1215
1242
  *
1216
- * This function will fail if the user has already created a wallet through Privy,
1217
- * as Privy currently only supports creating one wallet per user.
1243
+ * Otherwise (the default), Privy will secure the recovery share, and the embedded wallet
1244
+ * will be created without showing any UIs to the user.
1218
1245
  *
1219
- * This requires a user to enter a recovery pin that can later be used to recover the
1220
- * wallet or port it across devices.
1246
+ * @returns Promise for the {@link Wallet} object for the newly created embedded wallet
1221
1247
  */
1222
1248
  createWallet: () => Promise<Wallet>;
1223
1249
  /**
1224
- * @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
1250
+ * Prompts a user to sign a message using their embedded wallet using EIP-191's `personal_sign`
1251
+ * method (0x45).
1225
1252
  *
1226
- * Prompts a user to sign a message using their Privy wallet.
1253
+ * This method will error if the user is not authenticated or does not have an embedded wallet.
1227
1254
  *
1228
- * The resulting signature is an EIP-191 personal_sign signature (0x45).
1255
+ * If the `config.embeddedWallets.noPromptOnSignature` property is set to true, the signature will
1256
+ * be computed without prompting the user. Otherwise (the default), Privy will show the user a modal
1257
+ * to prompt them for a signature. This can be customized via the {@link SignMessageModalUIOptions}.
1229
1258
  *
1230
- * This function currently has a precondition that the user has a Privy wallet. It will fail otherwise.
1259
+ * @param message {string} message to be signed
1260
+ * @param uiOptions {@link SignMessageModalUIOptions} (optional) UI options to customize the signature prompt modal
1261
+ * @returns Promise for the signature as a string
1231
1262
  */
1232
1263
  signMessage: (message: string, uiOptions?: SignMessageModalUIOptions) => Promise<string>;
1264
+ /**
1265
+ * Prompts a user to send a transaction using their embedded wallet.
1266
+ *
1267
+ * This method will error if the user is not authenticated or does not have an embedded wallet.
1268
+ *
1269
+ * If no `chainId` is specified as part of the {@link UnsignedTransactionRequest}, Privy will default
1270
+ * to the embedded wallet's current chain ID.
1271
+ *
1272
+ * If the `config.embeddedWallets.noPromptOnSignature` property is set to true, the wallet will
1273
+ * attempt to send the transaction without prompting the user. Otherwise (the default), Privy
1274
+ * will show the user a modal to have them confirm the transaction. This can be customized via
1275
+ * the {@link SendTransactionModalUIOptions}.
1276
+ *
1277
+ * @param data {@link UnsignedTransactionRequest} transaction to be sent
1278
+ * @param uiOptions {@link SendTransactionModalUIOptions} (optional) UI options to customize the transaction request modal
1279
+ * @returns Promise for the transaction's {@link TransactionReceipt}
1280
+ */
1233
1281
  sendTransaction: (data: UnsignedTransactionRequest, uiOptions?: SendTransactionModalUIOptions) => Promise<TransactionReceipt>;
1282
+ /**
1283
+ * Shows the user a Privy modal, from which they can copy their embedded wallet's private
1284
+ * key for easy export to another wallet client (e.g. MetaMask). The private key is loaded
1285
+ * on an iframe running on a separate domain from your app, meaning your app cannot access it.
1286
+ *
1287
+ * This method will error if the user is not authenticated or does not have an embedded wallet.
1288
+ * @returns Promise that resolves once the user exits the modal
1289
+ */
1234
1290
  exportWallet: () => Promise<void>;
1235
1291
  }
1236
1292
  /**
@@ -1506,16 +1562,15 @@ type PrivyEvents = {
1506
1562
  * this will run after the user successfully authenticates _and_ creates their wallet (if applicable).
1507
1563
  * - If a user is already authenticated, this will run immediately and the `wasAlreadyAuthenticated` flag will be set to `true`.
1508
1564
  *
1509
- * @param user {User} - the `user` oject corresponding to the authenticated user
1510
- * @param isNewUser {boolean} - boolean flag indicating if this is the user's first time logging in to your app
1565
+ * @param user {@link User} the `user` oject corresponding to the authenticated user
1566
+ * @param isNewUser {boolean} boolean flag indicating if this is the user's first time logging in to your app
1511
1567
  * @param wasAlreadyAuthenticated {boolean} - boolean flag indicating whether the user entered the application already authenticated
1512
- *
1513
1568
  */
1514
1569
  onComplete?: (user: User, isNewUser: boolean, wasAlreadyAuthenticated: boolean) => void;
1515
1570
  /**
1516
1571
  * Callback that will execute in the case of a non-successful login.
1517
1572
  *
1518
- * @param error {PrivyErrorCode} - the corresponding error code
1573
+ * @param error {@link PrivyErrorCode} - the corresponding error code
1519
1574
  *
1520
1575
  */
1521
1576
  onError?: CallbackError;
@@ -1531,20 +1586,27 @@ type PrivyEvents = {
1531
1586
  * Callback that will execute once a successful `connectWallet` completes.
1532
1587
  * This will not run in the case of a wallet-based authentication flow.
1533
1588
  *
1534
- * @param wallet {BaseConnectedWallet}- the `wallet` object correspending to the connection
1535
- *
1589
+ * @param wallet {@link BaseConnectedWallet} the `wallet` object correspending to the connection
1536
1590
  */
1537
1591
  onSuccess?: (wallet: BaseConnectedWallet) => void;
1538
1592
  /**
1539
1593
  * Callback that will execute in the case of a non-successful wallet connection.
1540
1594
  *
1541
- * @param error {PrivyErrorCode} - the corresponding error code
1542
- *
1595
+ * @param error {@link PrivyErrorCode} - the corresponding error code
1543
1596
  */
1544
1597
  onError?: CallbackError;
1545
1598
  };
1546
1599
  };
1547
1600
 
1601
+ /**
1602
+ * Use this hook to log the user in, and to attach callbacks
1603
+ * for successful `login`s, already-`authenticated` users, and
1604
+ * `login` errors.
1605
+ *
1606
+ * @param callbacks.onComplete {@link PrivyEvents} callback to execute for already- or newly-`authenticated` users
1607
+ * @param callbacks.onError {@link PrivyEvents} callback to execute if there is an error during `login`.
1608
+ * @returns login - opens the Privy modal and prompts the user to login
1609
+ */
1548
1610
  declare function useLogin(callbacks?: PrivyEvents['login']): {
1549
1611
  /**
1550
1612
  * Opens the Privy login modal and prompts the user to login.
@@ -1552,6 +1614,12 @@ declare function useLogin(callbacks?: PrivyEvents['login']): {
1552
1614
  login: () => void;
1553
1615
  };
1554
1616
 
1617
+ /**
1618
+ * Use this hook to log the user out, and to attach a callback after a successful logout.
1619
+ *
1620
+ * @param callbacks.onSuccess {@link PrivyEvents} callback to execute when a user successfully logs out.
1621
+ * @returns logout - logs the user out and clears their authentication state.
1622
+ */
1555
1623
  declare function useLogout(callbacks?: PrivyEvents['logout']): {
1556
1624
  /**
1557
1625
  * 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 +1627,15 @@ declare function useLogout(callbacks?: PrivyEvents['logout']): {
1559
1627
  logout: () => Promise<void>;
1560
1628
  };
1561
1629
 
1630
+ /**
1631
+ * Use this hook to connect the user's external wallet, and to attach
1632
+ * callbacks after a user succesfully connects their wallet, or if there
1633
+ * is an error during the connection attempt.
1634
+ *
1635
+ * @param callbacks.onSuccess {@link PrivyEvents} callback to execute when a user successfully connects their wallet
1636
+ * @param callbacks.onError {@link PrivyEvents} callback to execute when a user attempts to connect their wallet, but there is an error
1637
+ * @returns connectWallet - opens the Privy modal and prompts the user to connect an external wallet
1638
+ */
1562
1639
  declare function useConnectWallet(callbacks?: PrivyEvents['connectWallet']): {
1563
1640
  /**
1564
1641
  * Opens the Privy modal and prompts the user to connect a wallet.
@@ -1613,4 +1690,4 @@ type Chain = {
1613
1690
 
1614
1691
  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
1692
 
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 };
1693
+ 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 };