@privy-io/react-auth 1.13.0-beta.7 → 1.13.0-beta.9

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
@@ -78,7 +78,7 @@ interface Discord {
78
78
  /** The email associated with the Discord account. */
79
79
  email: string | null;
80
80
  }
81
- /** Object representation of a user's Discord account. */
81
+ /** Object representation of a user's Github account. */
82
82
  interface Github {
83
83
  /** The `sub` claim from the Github-issued JWT for this account. */
84
84
  subject: string;
@@ -197,16 +197,6 @@ interface PrivyProviderProps {
197
197
  *
198
198
  */
199
199
  onSuccess?: (user: User, isNewUser: boolean) => void;
200
- /**
201
- * @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/faq/experimental-features subject to change at any time}.
202
- *
203
- * An optional callback that will execute if a `login` call fails.
204
- *
205
- * Within this callback, you can access:
206
- * - an `isNotAllowed` boolean flag indicating if the user was prevented from logging in by
207
- * your app's allowlist, if you have one enabled
208
- */
209
- onError?: (isNotAllowed: boolean) => void;
210
200
  /** @ignore */
211
201
  children: React.ReactNode;
212
202
  }
@@ -268,38 +258,57 @@ declare class AsExternalProvider extends PrivyProxyProvider implements ExternalP
268
258
  }, callback: (error: any, response: any) => void) => void;
269
259
  }
270
260
 
271
- declare class PrivyConnector {
272
- private ethProvider;
273
- walletType: WalletType | null;
261
+ declare abstract class WalletConnector {
262
+ provider: PrivyProxyProvider;
263
+ walletType: WalletType;
264
+ connected: boolean;
265
+ address: string | null;
266
+ chain: string | null;
267
+ constructor(walletType: WalletType, provider: PrivyProxyProvider, address: string | null);
268
+ fetchAddress(): Promise<string | null>;
269
+ fetchChainId(): Promise<string>;
270
+ getConnectedWallet(): Promise<Wallet | null>;
271
+ abstract connect(options: {
272
+ showPrompt: boolean;
273
+ }): Promise<Wallet | null>;
274
+ abstract isConnected(): Promise<boolean>;
275
+ abstract promptConnection(walletType: WalletType): void;
276
+ }
277
+
278
+ declare class ConnectorManager {
279
+ walletConnectors: WalletConnector[];
280
+ activeWalletConnector?: WalletConnector;
274
281
  initialized: boolean;
275
282
  constructor();
276
- getEthereumProvider: () => EIP1193Provider;
277
283
  initialize(): void;
278
- destroy(): void;
279
- getConnectedWallet(): Promise<Wallet | null>;
284
+ getEthereumProvider: () => EIP1193Provider;
280
285
  /**
281
- * Connects to the wallet.
282
- *
283
- * @param options.showPrompt if true, prompts the user for a connection when no connection can be automatically re-established.
284
- * @returns {string | null} EIP-55 mixed-case checksum-encoded address of connected wallet or null if user does not connect.
286
+ * Load state from the server user object (linked wallets).
287
+ * Currently, we can't load them because we don't know the wallet type.
288
+ * Once we've fixed this, we can load the wallets from the server and
289
+ * initialize their WalletConnector objects accordingly.
290
+ **/
291
+ initializeLinkedWallets(user: User): void;
292
+ load(): void;
293
+ save(): void;
294
+ /**
295
+ * Note that we purposefully don't delete CONNECTORS_STATE_KEY from localStorage
296
+ * This is because we can't recuperate state from the server state along yet (PRI-569).
285
297
  */
286
- connect(options: {
287
- showPrompt: boolean;
288
- }): Promise<Wallet | null>;
289
- private isConnected;
290
- private promptConnection;
298
+ destroy(): void;
299
+ addWalletConnector(walletConnector: WalletConnector): void;
300
+ removeWallet(address: string): void;
291
301
  /**
292
- * The currently connected EIP-155 chain id. E.g., `1` for Ethereum mainnet.
293
- *
294
- * @returns {string} The EIP-155 chain id.
302
+ * Performing personal_sign with the active wallet
303
+ * If the active wallet is not connected, we connect it in just-in-time" fashion.
295
304
  */
296
- chainId(): Promise<string>;
305
+ activeWalletSign(message: string): Promise<string | null>;
297
306
  /**
298
- * The currently connected address.
299
- *
300
- * @returns {string | null} EIP-55 mixed-case checksum-encoded address or null if not connected.
307
+ * Set a wallet as active, by passing the address.
308
+ * If the address is null or not found, do nothing and return false.
309
+ * If the connector was successfully found and set active, return true.
301
310
  */
302
- address(): Promise<string | null>;
311
+ setActiveWallet(address: string | null): boolean;
303
312
  }
304
313
 
305
314
  /**
@@ -394,10 +403,10 @@ interface PrivyInterface {
394
403
  */
395
404
  getWeb3jsProvider: () => AbstractProvider;
396
405
  /**
397
- * Get the PrivyConnector object
406
+ * Get the ConnectorManager object
398
407
  * This shouldn't need to be used directly unless creating a plugin, like a WAGMI plugin
399
408
  */
400
- walletConnector: PrivyConnector | null;
409
+ walletConnectors: ConnectorManager | null;
401
410
  /**
402
411
  * 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.
403
412
  */
@@ -578,7 +587,7 @@ declare class PrivyClient {
578
587
  private appId;
579
588
  private session;
580
589
  authFlow?: AuthFlow;
581
- connector: PrivyConnector;
590
+ connectors: ConnectorManager;
582
591
  /**
583
592
  * Creates a new Privy client.
584
593
  * @param options Initialization options.
@@ -651,4 +660,4 @@ declare class PrivyClient {
651
660
  forkSession(): Promise<string>;
652
661
  }
653
662
 
654
- export { AsExternalProvider, Discord, DiscordOAuthWithMetadata, Email, EmailWithMetadata, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, Phone, PhoneWithMetadata, PrivyClient, PrivyConnector, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Twitter, TwitterOAuthWithMetadata, User, VERSION, Wallet, WalletWithMetadata, getAccessToken, usePrivy };
663
+ export { AsExternalProvider, ConnectorManager, Discord, DiscordOAuthWithMetadata, Email, EmailWithMetadata, GithubOAuthWithMetadata, Google, GoogleOAuthWithMetadata, Phone, PhoneWithMetadata, PrivyClient, PrivyInterface, PrivyProvider, PrivyProviderProps, PrivyProxyProvider, Twitter, TwitterOAuthWithMetadata, User, VERSION, Wallet, WalletWithMetadata, getAccessToken, usePrivy };