@privy-io/react-auth 1.13.0-beta.8 → 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;
@@ -258,38 +258,57 @@ declare class AsExternalProvider extends PrivyProxyProvider implements ExternalP
258
258
  }, callback: (error: any, response: any) => void) => void;
259
259
  }
260
260
 
261
- declare class PrivyConnector {
262
- private ethProvider;
263
- 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;
264
281
  initialized: boolean;
265
282
  constructor();
266
- getEthereumProvider: () => EIP1193Provider;
267
283
  initialize(): void;
268
- destroy(): void;
269
- getConnectedWallet(): Promise<Wallet | null>;
284
+ getEthereumProvider: () => EIP1193Provider;
270
285
  /**
271
- * Connects to the wallet.
272
- *
273
- * @param options.showPrompt if true, prompts the user for a connection when no connection can be automatically re-established.
274
- * @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).
275
297
  */
276
- connect(options: {
277
- showPrompt: boolean;
278
- }): Promise<Wallet | null>;
279
- private isConnected;
280
- private promptConnection;
298
+ destroy(): void;
299
+ addWalletConnector(walletConnector: WalletConnector): void;
300
+ removeWallet(address: string): void;
281
301
  /**
282
- * The currently connected EIP-155 chain id. E.g., `1` for Ethereum mainnet.
283
- *
284
- * @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.
285
304
  */
286
- chainId(): Promise<string>;
305
+ activeWalletSign(message: string): Promise<string | null>;
287
306
  /**
288
- * The currently connected address.
289
- *
290
- * @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.
291
310
  */
292
- address(): Promise<string | null>;
311
+ setActiveWallet(address: string | null): boolean;
293
312
  }
294
313
 
295
314
  /**
@@ -384,10 +403,10 @@ interface PrivyInterface {
384
403
  */
385
404
  getWeb3jsProvider: () => AbstractProvider;
386
405
  /**
387
- * Get the PrivyConnector object
406
+ * Get the ConnectorManager object
388
407
  * This shouldn't need to be used directly unless creating a plugin, like a WAGMI plugin
389
408
  */
390
- walletConnector: PrivyConnector | null;
409
+ walletConnectors: ConnectorManager | null;
391
410
  /**
392
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.
393
412
  */
@@ -568,7 +587,7 @@ declare class PrivyClient {
568
587
  private appId;
569
588
  private session;
570
589
  authFlow?: AuthFlow;
571
- connector: PrivyConnector;
590
+ connectors: ConnectorManager;
572
591
  /**
573
592
  * Creates a new Privy client.
574
593
  * @param options Initialization options.
@@ -641,4 +660,4 @@ declare class PrivyClient {
641
660
  forkSession(): Promise<string>;
642
661
  }
643
662
 
644
- 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 };