@privy-io/react-auth 1.17.0 → 1.18.0-beta.1

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
@@ -8,6 +8,13 @@ declare const SUPPORTED_OAUTH_PROVIDERS: readonly ["google", "discord", "twitter
8
8
  type OAuthProviderType = typeof SUPPORTED_OAUTH_PROVIDERS[number];
9
9
  declare const SUPPORTED_WALLET_TYPES: readonly ["metamask", "coinbase_wallet", "wallet_connect"];
10
10
  type WalletType = typeof SUPPORTED_WALLET_TYPES[number];
11
+ /**
12
+ * Wallet metadata currently for internal use only
13
+ */
14
+ type WalletMeta = {
15
+ name: string;
16
+ icon?: string | EmbeddedSVG;
17
+ };
11
18
  type LinkedAccountType = 'wallet' | 'email' | 'phone' | 'google_oauth' | 'twitter_oauth' | 'discord_oauth' | 'github_oauth';
12
19
  /** @ignore */
13
20
  interface LinkMetadata {
@@ -207,14 +214,17 @@ interface PrivyProviderProps {
207
214
  *
208
215
  */
209
216
  onSuccess?: (user: User, isNewUser: boolean) => void;
210
- /** @ignore */
211
- children: React.ReactNode;
212
217
  /**
213
218
  * If true, the user will be prompted to create a Privy wallet
214
- * after they have successfully logged in if they do not currently
215
- * have any wallet associated with their user account.
219
+ * after successfully logging in, if they do not currently
220
+ * have any wallet associated with their user object.
216
221
  */
217
222
  createPrivyWalletOnLogin?: boolean;
223
+ /**
224
+ * @ignore
225
+ * @class
226
+ */
227
+ children: React.ReactNode;
218
228
  }
219
229
  /**
220
230
  * Passes the Privy authentication context to your React components.
@@ -249,14 +259,14 @@ interface EIP1193Provider {
249
259
  declare class PrivyProxyProvider implements EIP1193Provider {
250
260
  walletProvider?: EIP1193Provider;
251
261
  private _subscriptions;
252
- constructor(provider?: EIP1193Provider);
262
+ constructor(walletProvider?: EIP1193Provider);
253
263
  on(eventName: string, listener: (...args: any[]) => void): any;
254
264
  request(request: {
255
265
  method: string;
256
266
  params?: any[] | undefined;
257
267
  }): Promise<any>;
258
268
  removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => any;
259
- setProvider: (provider: EIP1193Provider) => void;
269
+ setWalletProvider: (provider: EIP1193Provider) => void;
260
270
  }
261
271
  declare class AsExternalProvider extends PrivyProxyProvider implements ExternalProvider {
262
272
  constructor(provider: EIP1193Provider);
@@ -275,15 +285,16 @@ declare class AsExternalProvider extends PrivyProxyProvider implements ExternalP
275
285
  }
276
286
 
277
287
  declare abstract class WalletConnector {
278
- provider: PrivyProxyProvider;
288
+ proxyProvider: PrivyProxyProvider;
279
289
  walletType: WalletType;
280
290
  connected: boolean;
281
291
  address: string | null;
282
292
  chain: string | null;
283
- constructor(walletType: WalletType, provider: PrivyProxyProvider, address: string | null);
293
+ constructor(walletType: WalletType, proxyProvider: PrivyProxyProvider, address: string | null);
284
294
  fetchAddress(): Promise<string | null>;
285
295
  fetchChainId(): Promise<string>;
286
296
  getConnectedWallet(): Promise<Wallet | null>;
297
+ abstract get walletMeta(): WalletMeta;
287
298
  abstract connect(options: {
288
299
  showPrompt: boolean;
289
300
  }): Promise<Wallet | null>;
@@ -296,21 +307,34 @@ declare abstract class WalletConnector {
296
307
  /**
297
308
  * Light wrapper around WCConnectionManager that uses the global connection manager
298
309
  * to manage the local storage layer and avoid conflicts.
310
+ * There can be multiple WCWalletConnectors, but should only ever be a single
311
+ * WCConnectionManager, which should be the class referenced - it will in turn find
312
+ * the appropriate WCWalletConnector for use with an action.
299
313
  */
300
314
  declare class WCWalletConnector extends WalletConnector {
301
315
  private _connectionManager;
302
- private _provider;
303
- constructor(connectionManager: WCConnectionManager, provider: PrivyProxyProvider, address: string | null);
316
+ constructor(connectionManager: WCConnectionManager, proxyProvider: PrivyProxyProvider, address: string | null);
304
317
  connect(options: {
305
318
  showPrompt: boolean;
306
319
  }): Promise<Wallet | null>;
307
320
  isConnected(): Promise<boolean>;
321
+ /**
322
+ * Metadata about the wallet represented by this connector.
323
+ */
324
+ get walletMeta(): {
325
+ name: string;
326
+ icon: string | EmbeddedSVG;
327
+ };
308
328
  promptConnection(): Promise<void>;
309
329
  /**
310
- * Perform personal_sign with the user's wallet.
330
+ * Perform personal_sign with the user's first wallet associated with WalletConnect
311
331
  */
312
332
  sign(message: string): Promise<string>;
313
333
  disconnect(): void;
334
+ /**
335
+ * Access the underlying WCProvider directly with proper typings
336
+ */
337
+ private get walletProvider();
314
338
  }
315
339
  /**
316
340
  * An object representation of the Wallet Connect V1 protocol. This is used to initiate and manage connections
@@ -329,13 +353,27 @@ declare class WCConnectionManager {
329
353
  */
330
354
  disconnect(): Promise<void>;
331
355
  /**
332
- * Handles storage retrieval and assignment for WalletConnectProvider instances
356
+ * Given an address, either fetch (reusing a stored connection) or create a new one if no stored
357
+ * connection is found
358
+ */
359
+ getOrCreateProviderForAddress(address: string | null): WCProvider;
360
+ /**
361
+ * Create a WC provider and add an entry to the internal provider registry keyed on the internal
362
+ * WC storageId
363
+ */
364
+ private createProvider;
365
+ /**
366
+ * Replace the given provider, *assuming it's the one with null address*
367
+ *
368
+ * Couldn't find any WC docs, but a reference implementation library had a similar error we were
369
+ * seeing - WC sessions wouldn't open a new modal/etc when doing `provider.enable()` if it had
370
+ * previously been rejected: https://github.com/Uniswap/web3-react/issues/217
333
371
  */
334
- getProviderForAddress(address: string | null): WCProvider;
372
+ replaceProvider(provider: WCProvider): WCProvider;
335
373
  /**
336
- * Updates internal global connector data structures with address mappings as new accounts are added
374
+ * Enables the provider. Under the hood, this calls connect() and 'eth_RequestAccounts'.
337
375
  */
338
- indexProvider(provider: WCProvider): void;
376
+ enableProvider(provider: WCProvider): Promise<string[]>;
339
377
  }
340
378
 
341
379
  declare class ConnectorManager {