@privy-io/react-auth 1.18.0-beta.1 → 1.18.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/esm/index.js +190 -124
- package/dist/index.d.ts +55 -14
- package/dist/index.js +190 -124
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ import { AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
|
6
6
|
|
|
7
7
|
declare const SUPPORTED_OAUTH_PROVIDERS: readonly ["google", "discord", "twitter", "github"];
|
|
8
8
|
type OAuthProviderType = typeof SUPPORTED_OAUTH_PROVIDERS[number];
|
|
9
|
-
declare const
|
|
10
|
-
type WalletType = typeof
|
|
9
|
+
declare const SUPPORTED_WALLET_CONNECTION_TYPES: readonly ["metamask", "coinbase_wallet", "wallet_connect"];
|
|
10
|
+
type WalletType = typeof SUPPORTED_WALLET_CONNECTION_TYPES[number];
|
|
11
11
|
/**
|
|
12
12
|
* Wallet metadata currently for internal use only
|
|
13
13
|
*/
|
|
14
|
-
type
|
|
14
|
+
type WalletBranding = {
|
|
15
15
|
name: string;
|
|
16
16
|
icon?: string | EmbeddedSVG;
|
|
17
17
|
};
|
|
@@ -136,6 +136,9 @@ interface GithubOAuthWithMetadata extends LinkMetadata, Github {
|
|
|
136
136
|
/** Denotes that this is a Github account. */
|
|
137
137
|
type: 'github_oauth';
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Object representation of a user's linked accounts
|
|
141
|
+
*/
|
|
139
142
|
type LinkedAccountWithMetadata = WalletWithMetadata | EmailWithMetadata | PhoneWithMetadata | GoogleOAuthWithMetadata | TwitterOAuthWithMetadata | DiscordOAuthWithMetadata | GithubOAuthWithMetadata;
|
|
140
143
|
interface User {
|
|
141
144
|
/** The Privy-issued DID for the user. If you need to store additional information
|
|
@@ -294,7 +297,7 @@ declare abstract class WalletConnector {
|
|
|
294
297
|
fetchAddress(): Promise<string | null>;
|
|
295
298
|
fetchChainId(): Promise<string>;
|
|
296
299
|
getConnectedWallet(): Promise<Wallet | null>;
|
|
297
|
-
abstract get
|
|
300
|
+
abstract get walletBranding(): WalletBranding;
|
|
298
301
|
abstract connect(options: {
|
|
299
302
|
showPrompt: boolean;
|
|
300
303
|
}): Promise<Wallet | null>;
|
|
@@ -304,6 +307,12 @@ declare abstract class WalletConnector {
|
|
|
304
307
|
setActive(): Promise<boolean>;
|
|
305
308
|
}
|
|
306
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Types aren't included in the final distribution, so we can have the duplicates here to assure
|
|
312
|
+
* type-safety
|
|
313
|
+
*/
|
|
314
|
+
type WalletId = '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369' | '4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0' | 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96' | '225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f' | '74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d' | 'ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18' | '8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3' | '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662' | 'afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7' | 'ccb714920401f7d008dbe11281ae70e3a4bfb621763b187b9e4a3ce1ab8faa3b' | '7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26' | '2863183c3299d820fb9a4cb8aab4a34f50380c9992e8be871fd60a62e8d36481' | 'efba9ae0a9e0fdd9e3e055ddf3c8e75f294babb8aea3499456eff27f771fda61' | 'b021913ba555948a1c81eb3d89b372be46f8354e926679de648e4fa2938bed3e' | '7e90b95230bc462869bbb59f952273d89841e1c76bcc5319898e08c9f34bd4cd' | '138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98' | '468b4ab3582757233017ec10735863489104515ab160c053074905a1eecb7e63' | '29f4a70ad5993f3f73ae8119f0e78ecbae51deec2a021a770225c644935c0f09' | '8240fb8a7b117aed27f04aa8870c714eeb910f7c1b16c9b868e793c1836335b8' | '15d7610042217f691385d20e640869dc7273e991b04e8f476417cdc5ec856955' | 'a395dbfc92b5519cbd1cc6937a4e79830187daaeb2c6fcdf9b9cce4255f2dcd5' | '0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150' | '881946407ff22a32ec0e42b2cd31ea5dab52242dc3648d777b511a0440d59efb' | '3b0e861b3a57e98325b82ab687fe0a712c81366d521ceec49eebc35591f1b5d1' | '38ee551a01e3c5af9d8a9715768861e4d642e2381a62245083f96672b5646c6b' | 'f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d' | '15d1d97de89526a3c259a235304a7c510c40cda3331f0f8433da860ecc528bef' | '19ad8334f0f034f4176a95722b5746b539b47b37ce17a5abde4755956d05d44c' | '95501c1a07c8eb575cb28c753ab9044259546ebcefcd3645461086e49b671f5c' | '2ed796df33fdbde6a3ea6a47d3636b8341fe285038d844c7a78267b465b27028' | '4e6af4201658b52daad51a279bb363a08b3927e74c0f27abeca3b0110bddf0a9' | 'b13fcc7e3500a4580c9a5341ed64c49c17d7f864497881048eb160c089be5346' | '13c6a06b733edf51784f669f508826b2ab0dc80122a8b5d25d84b17d94bbdf70' | '0aafbedfb8eb56dae59ecc37c9a5388509cf9c082635e3f752581cc7128a17c0' | '761d3d98fd77bdb06e6c90092ee7071c6001e93401d05dcf2b007c1a6c9c222c' | 'ffa139f74d1c8ebbb748cf0166f92d886e8c81b521c2193aa940e00626f4e215' | '717911f4db0c5eda0e02e76ed179b7940ba1eefffdfb3c9e6540696226860da0' | '9d6c614d1995741d5313f1f3dbf1f66dcba694de782087d13b8721822502692f' | 'a6ffb821a3c32d36fc9d29e29c2ff79a0cd1db0bca453714777846ddf3fdff76' | '76745388a50e6fea982c4dee2a3ad61a8aa417668be870754689caa8a7506c93' | '6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa' | '2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568' | 'b823fb0d7228ef8e3c0bc9607df9ed79dae2ab3a2811d33f22ade4f573c18232' | 'dccbd717df77b395445cc6080e01fffada9d8b92dacfda312a26c70c2e9af673' | 'c6f3d04a4e1a51e7d2045f347a5ebdab30fc600950a740fca21f0c92e230ee05' | 'c482dfe368d4f004479977fd88e80dc9e81107f3245d706811581a6dfe69c534' | '14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd' | '0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92' | 'a2c031fccd13a6c16d7745c303507f78ae4da53fed064542804e9657d73e8b5c' | 'f593f4eb9755ff047681a37ebc46706e0e915cf1c2fe0102f5ae47c9f6aa4082' | '5859076ade608fbc4e9d3fe2f95e8527de80f8451ecbb1dced54ca84deae0dd6' | 'bb88a220ed4dcd3d717ec19b6ac00a672edf92e97ef7c243d35e25ff56a07301' | 'cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e' | 'b83a346877b71c02b8531f53485ce12bc00033eabcc1213ca3329cbc744813a5' | 'a92d512c649e87a5acba5885ac03f62662cff1f647c20a63833eb45a71a6f877' | '226d8a12a2e6e5c4185fa9c24313824bfb144c2a180325bddbd121844f497afa' | '11c5487e4d8dd8bf32d4c92222363df8296a27307b2531be1e25770365392ecb' | 'f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2' | '576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd' | '94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43' | 'bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6' | '664b505fea4c2117b8a55c054ef209664e0a68ddaafd7534df739f97a293fa1d' | '0c5bba82e70a2b62405871af809020a077d110d765c0798eb660ad5d3131b328' | '792fbacfe787d67595dd4eb38ac308e14b3bbc810393db56f477a92e5ac8764b' | '7ef337ff00714f179d38b8142398efa2ab902a53430e99ebce02892053d7a310' | '7e94e75c90964a69ea375b92214f50c4223dfbfa4913a3733b615444b322f687' | '107bb20463699c4e614d3a2fb7b961e66f48774cb8f6d6c1aee789853280972c' | '1986e7c874bb906f057d5d64a4806c004e021689536e5228c74d64a6058e8bac' | '19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b' | '37a686ab6223cd42e2886ed6e5477fce100a4fb565dcd57ed4f81f7c12e93053' | '4f5de5333fed2ccf47c690579aba3b9128aea78175339ff51ef61704bde7502a' | '9034d54985807aaf3d7780f50f155f954daa468fb58d7b14b216fc79d68bbd14' | 'c39d8ee468e50474fdf3a0bd6b981be404d4671e2702a3d633aae95bcbaa032a' | 'e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4' | '114efdbef4ce710081c1507f3dbc51f439c96a342cf33397799cd1c84b01a8c5' | '5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b' | '2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715' | 'e3787ea98d014ca77e2c3794db97c02ef8bcb39347705f5e79502a55434a1ecf' | '159b0423ce9075d5662f588f805931d989627affab3e63e4dd7ebc62b9c6738c' | 'fbea6f68df4e6ce163c144df86da89f24cb244f19b53903e26aea9ab7de6393c' | '1aedbcfc1f31aade56ca34c38b0a1607b41cccfa3de93c946ef3b4ba2dfab11c' | '14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc' | '031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa' | 'c40b9bcef32fa6ce4e0df98be1420628bbc4957646f742380fe618fcb4ab74f1' | 'b265ce38b94d602957a0946673c59a99a15d69adda4317544fec7298ea2d1387' | 'dc5415b6ea8114db518ae91195b027d690a11a1d2bfdd1a904e93c5cb746380e' | '41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071';
|
|
315
|
+
|
|
307
316
|
/**
|
|
308
317
|
* Light wrapper around WCConnectionManager that uses the global connection manager
|
|
309
318
|
* to manage the local storage layer and avoid conflicts.
|
|
@@ -312,8 +321,9 @@ declare abstract class WalletConnector {
|
|
|
312
321
|
* the appropriate WCWalletConnector for use with an action.
|
|
313
322
|
*/
|
|
314
323
|
declare class WCWalletConnector extends WalletConnector {
|
|
315
|
-
private
|
|
324
|
+
private connectionManager;
|
|
316
325
|
constructor(connectionManager: WCConnectionManager, proxyProvider: PrivyProxyProvider, address: string | null);
|
|
326
|
+
setActive(): Promise<boolean>;
|
|
317
327
|
connect(options: {
|
|
318
328
|
showPrompt: boolean;
|
|
319
329
|
}): Promise<Wallet | null>;
|
|
@@ -321,7 +331,7 @@ declare class WCWalletConnector extends WalletConnector {
|
|
|
321
331
|
/**
|
|
322
332
|
* Metadata about the wallet represented by this connector.
|
|
323
333
|
*/
|
|
324
|
-
get
|
|
334
|
+
get walletBranding(): {
|
|
325
335
|
name: string;
|
|
326
336
|
icon: string | EmbeddedSVG;
|
|
327
337
|
};
|
|
@@ -335,6 +345,10 @@ declare class WCWalletConnector extends WalletConnector {
|
|
|
335
345
|
* Access the underlying WCProvider directly with proper typings
|
|
336
346
|
*/
|
|
337
347
|
private get walletProvider();
|
|
348
|
+
/**
|
|
349
|
+
* Set the underlying WCProvider with proper typings
|
|
350
|
+
*/
|
|
351
|
+
setWalletProvider(walletProvider: WCProvider): void;
|
|
338
352
|
}
|
|
339
353
|
/**
|
|
340
354
|
* An object representation of the Wallet Connect V1 protocol. This is used to initiate and manage connections
|
|
@@ -342,26 +356,47 @@ declare class WCWalletConnector extends WalletConnector {
|
|
|
342
356
|
*/
|
|
343
357
|
declare class WCConnectionManager {
|
|
344
358
|
private _storageIdToProvider;
|
|
345
|
-
private
|
|
359
|
+
private reconnectDelayMs;
|
|
360
|
+
private reconnectBackoff;
|
|
346
361
|
constructor();
|
|
347
362
|
/**
|
|
348
363
|
* Builds a new WCWalletConnector instance
|
|
364
|
+
*
|
|
365
|
+
* If walletId is specified, attempts to launch into that specific flow.
|
|
366
|
+
*
|
|
367
|
+
* IMPORTANT! Nothing in this flow can be costly in order to properly launch our deep links. See:
|
|
368
|
+
* https://docs.walletconnect.com/1.0/mobile-linking#ios-app-link-constraints
|
|
349
369
|
*/
|
|
350
|
-
createConnector(
|
|
370
|
+
createConnector(proxyProvider: PrivyProxyProvider, address: string | null,
|
|
371
|
+
/**
|
|
372
|
+
* If provided, the connector will attempt to establish a connection directly using this
|
|
373
|
+
* wallet. If omitted, but an address is provided, the connector may still attempt to link
|
|
374
|
+
* up to a wallet, but may be unable to. If a wallet cannot be determined, the standard WC
|
|
375
|
+
* modal is shown.
|
|
376
|
+
*/
|
|
377
|
+
walletId?: WalletId): WCWalletConnector;
|
|
351
378
|
/**
|
|
352
379
|
* Disconnects all active Wallet Connect sessions.
|
|
353
380
|
*/
|
|
354
381
|
disconnect(): Promise<void>;
|
|
382
|
+
/**
|
|
383
|
+
* Fetch a storage id for an address/walletId pair. If we don't match exactly, we still
|
|
384
|
+
* attempt to discover if any legacy keys were matched using instant launch methods (currently)
|
|
385
|
+
* just metamask and reuse if that. Admittedly, this method feels very fragile and unknown.
|
|
386
|
+
*/
|
|
387
|
+
private getStorageId;
|
|
355
388
|
/**
|
|
356
389
|
* Given an address, either fetch (reusing a stored connection) or create a new one if no stored
|
|
357
390
|
* connection is found
|
|
358
391
|
*/
|
|
359
|
-
|
|
392
|
+
getProviderForAddress(address: string | null, walletId: WalletId | undefined): WCProvider | undefined;
|
|
393
|
+
private createProviderWithStorageId;
|
|
360
394
|
/**
|
|
361
395
|
* Create a WC provider and add an entry to the internal provider registry keyed on the internal
|
|
362
|
-
* WC storageId
|
|
396
|
+
* WC storageId. If walletId is specified, attempts to launch the WC flow for that particular
|
|
397
|
+
* wallet
|
|
363
398
|
*/
|
|
364
|
-
|
|
399
|
+
createProvider(connector: WCWalletConnector, walletId?: WalletId): WCProvider;
|
|
365
400
|
/**
|
|
366
401
|
* Replace the given provider, *assuming it's the one with null address*
|
|
367
402
|
*
|
|
@@ -369,7 +404,7 @@ declare class WCConnectionManager {
|
|
|
369
404
|
* seeing - WC sessions wouldn't open a new modal/etc when doing `provider.enable()` if it had
|
|
370
405
|
* previously been rejected: https://github.com/Uniswap/web3-react/issues/217
|
|
371
406
|
*/
|
|
372
|
-
replaceProvider(provider: WCProvider): WCProvider;
|
|
407
|
+
replaceProvider(connector: WCWalletConnector, provider: WCProvider): WCProvider;
|
|
373
408
|
/**
|
|
374
409
|
* Enables the provider. Under the hood, this calls connect() and 'eth_RequestAccounts'.
|
|
375
410
|
*/
|
|
@@ -391,7 +426,9 @@ declare class ConnectorManager {
|
|
|
391
426
|
* initialize their WalletConnector objects accordingly.
|
|
392
427
|
**/
|
|
393
428
|
initializeLinkedWallets(user: User): void;
|
|
429
|
+
/** Load the state from storage and hydrate the instance with WalletConnectors. */
|
|
394
430
|
load(): void;
|
|
431
|
+
/** Persist the instance state to storage to reload the connectors later. */
|
|
395
432
|
save(): void;
|
|
396
433
|
addWalletConnector(walletConnector: WalletConnector): void;
|
|
397
434
|
getConnectorByAddress(address: string): WalletConnector | undefined;
|
|
@@ -407,7 +444,9 @@ declare class ConnectorManager {
|
|
|
407
444
|
* If the connector was successfully found and set active, return true.
|
|
408
445
|
*/
|
|
409
446
|
setActiveWallet(address: string | null): Promise<boolean>;
|
|
410
|
-
createWalletConnector(walletType: WalletType, address: string | null
|
|
447
|
+
createWalletConnector(walletType: WalletType, address: string | null,
|
|
448
|
+
/** Only applicable for WalletConnect right now */
|
|
449
|
+
walletId?: WalletId): WalletConnector;
|
|
411
450
|
}
|
|
412
451
|
|
|
413
452
|
/**
|
|
@@ -516,6 +555,7 @@ interface PrivyInterface {
|
|
|
516
555
|
unlinkPhone: (phoneNumber: string) => Promise<User>;
|
|
517
556
|
/**
|
|
518
557
|
* 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.
|
|
558
|
+
* 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.
|
|
519
559
|
*/
|
|
520
560
|
unlinkWallet: (address: string) => Promise<User>;
|
|
521
561
|
/**
|
|
@@ -537,11 +577,12 @@ interface PrivyInterface {
|
|
|
537
577
|
/**
|
|
538
578
|
* Set one of the authenticated wallet addresses (part of user.linkedAccounts with type 'wallet'). as the active wallet.
|
|
539
579
|
* If you pass a wallet that's not one of the linkedAccounts, this will throw an error.
|
|
580
|
+
* This will prompt the user to reconnect their wallet if the connection is lost.
|
|
540
581
|
*
|
|
541
582
|
* The active wallet will be the one that getEthersProvider() will use as a signer (used for signing & transactions).
|
|
542
583
|
* It is also the wallet present at `user.wallet`, and that value is updated when this is called.
|
|
543
584
|
*
|
|
544
|
-
* Note that when you link a new wallet, it becomes
|
|
585
|
+
* Note that when you link a new wallet, it becomes active.
|
|
545
586
|
*/
|
|
546
587
|
setActiveWallet: (address: string) => Promise<void>;
|
|
547
588
|
/**
|