@privy-io/react-auth 1.5.0 → 1.6.0-beta.10

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
@@ -7,7 +7,7 @@ declare type WalletType = typeof SUPPORTED_WALLET_TYPES[number];
7
7
  /** @ignore */
8
8
  interface LinkMetadata {
9
9
  /** Account type, most commonly useful when filtering through linkedAccounts */
10
- type: 'wallet' | 'email' | 'google_oauth' | 'twitter_oauth' | 'discord_oauth';
10
+ type: 'wallet' | 'email' | 'phone' | 'google_oauth' | 'twitter_oauth' | 'discord_oauth';
11
11
  /** Datetime when this account was linked to the user. */
12
12
  verifiedAt: Date;
13
13
  }
@@ -42,6 +42,11 @@ interface Email {
42
42
  /** The email address. */
43
43
  address: string;
44
44
  }
45
+ /** Object representation of a user's phone number. */
46
+ interface Phone {
47
+ /** The phone number. */
48
+ number: string;
49
+ }
45
50
  /** Object representation of a user's Google account. */
46
51
  interface Google {
47
52
  /** The `sub` claim from the Google-issued JWT for this account. */
@@ -74,6 +79,11 @@ interface EmailWithMetadata extends LinkMetadata, Email {
74
79
  /** Denotes that this is an email account. */
75
80
  type: 'email';
76
81
  }
82
+ /** Object representation of a user's phone number, with additional metadata for advanced use cases. */
83
+ interface PhoneWithMetadata extends LinkMetadata, Phone {
84
+ /** Denotes that this is a phone account. */
85
+ type: 'phone';
86
+ }
77
87
  /** Object representation of a user's wallet, with additional metadata for advanced use cases. */
78
88
  interface WalletWithMetadata extends LinkMetadata, Wallet {
79
89
  /** Denotes that this is a wallet account. */
@@ -102,6 +112,8 @@ interface User {
102
112
  createdAt: Date;
103
113
  /** The user's email address, if they have linked one. It cannot be linked to another user. */
104
114
  email?: Email;
115
+ /** The user's phone number, if they have linked one. It cannot be linked to another user. */
116
+ phone?: Phone;
105
117
  /** The user's wallet address, if they have linked one. It cannot be linked to another user. */
106
118
  wallet?: Wallet;
107
119
  /** The user's Google account, if they have linked one. It cannot be linked to another user. */
@@ -112,7 +124,7 @@ interface User {
112
124
  discord?: Discord;
113
125
  /** The list of accounts associated with this user. Each account contains additional metadata
114
126
  * that may be helpful for advanced use cases. */
115
- linkedAccounts: Array<WalletWithMetadata | EmailWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata>;
127
+ linkedAccounts: Array<WalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata>;
116
128
  }
117
129
 
118
130
  /**
@@ -189,12 +201,34 @@ interface PrivyInterface {
189
201
  login: () => void;
190
202
  /**
191
203
  * For users who are authenticated, opens the Privy modal and prompts the user to link an email.
204
+ * This will open the Privy Modal which will guide the user through this action.
192
205
  */
193
206
  linkEmail: () => void;
207
+ /**
208
+ * For users who are authenticated, opens the Privy modal and prompts the user to link a phone number.
209
+ * This will open the Privy Modal which will guide the user through this action.
210
+ */
211
+ linkPhone: () => void;
194
212
  /**
195
213
  * For users who are authenticated, opens the Privy modal and prompts the user to link a wallet.
214
+ * This will open the Privy Modal which will guide the user through this action.
196
215
  */
197
216
  linkWallet: () => void;
217
+ /**
218
+ * For users who are authenticated, prompts the user to link a Google OAuth account.
219
+ * This will directly initiate the OAuth flow for Google.
220
+ */
221
+ linkGoogle: () => void;
222
+ /**
223
+ * For users who are authenticated, prompts the user to link a Twitter OAuth account
224
+ * This will directly initiate the OAuth flow for Twitter.
225
+ */
226
+ linkTwitter: () => void;
227
+ /**
228
+ * For users who are authenticated, prompts the user to link Discord OAuth account
229
+ * This will directly initiate the OAuth flow for Discord.
230
+ */
231
+ linkDiscord: () => void;
198
232
  /**
199
233
  * 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.
200
234
  *
@@ -226,10 +260,29 @@ interface PrivyInterface {
226
260
  */
227
261
  getWeb3jsProvider: () => AbstractProvider;
228
262
  /**
229
- * Unlink accounts.
263
+ * 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.
230
264
  */
231
265
  unlinkEmail: (address: string) => Promise<User>;
266
+ /**
267
+ * 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.
268
+ */
269
+ unlinkPhone: (phoneNumber: string) => Promise<User>;
270
+ /**
271
+ * 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.
272
+ */
232
273
  unlinkWallet: (address: string) => Promise<User>;
274
+ /**
275
+ * 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.
276
+ */
277
+ unlinkGoogle: (subject: string) => Promise<User>;
278
+ /**
279
+ * 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.
280
+ */
281
+ unlinkTwitter: (subject: string) => Promise<User>;
282
+ /**
283
+ * 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.
284
+ */
285
+ unlinkDiscord: (subject: string) => Promise<User>;
233
286
  }
234
287
  /**
235
288
  * [React Hook](https://reactjs.org/docs/hooks-intro.html) that allows you to manage the user's current authentication state and access their linked accounts.
@@ -238,4 +291,6 @@ interface PrivyInterface {
238
291
  */
239
292
  declare const usePrivy: () => PrivyInterface;
240
293
 
241
- export { Discord, DiscordOAuthWithMetadata, Email, EmailWithMetadata, Google, GoogleOAuthWithMetadata, PrivyInterface, PrivyProvider, PrivyProviderProps, Twitter, TwitterOAuthWithMetadata, User, Wallet, WalletWithMetadata, usePrivy };
294
+ declare const VERSION: string;
295
+
296
+ export { Discord, DiscordOAuthWithMetadata, Email, EmailWithMetadata, Google, GoogleOAuthWithMetadata, Phone, PhoneWithMetadata, PrivyInterface, PrivyProvider, PrivyProviderProps, Twitter, TwitterOAuthWithMetadata, User, VERSION, Wallet, WalletWithMetadata, usePrivy };