@privy-io/react-auth 1.18.0-beta.3 → 1.18.0-beta.5
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 +99 -122
- package/dist/index.d.ts +38 -19
- package/dist/index.js +99 -122
- 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
|
};
|
|
@@ -297,7 +297,7 @@ declare abstract class WalletConnector {
|
|
|
297
297
|
fetchAddress(): Promise<string | null>;
|
|
298
298
|
fetchChainId(): Promise<string>;
|
|
299
299
|
getConnectedWallet(): Promise<Wallet | null>;
|
|
300
|
-
abstract get
|
|
300
|
+
abstract get walletBranding(): WalletBranding;
|
|
301
301
|
abstract connect(options: {
|
|
302
302
|
showPrompt: boolean;
|
|
303
303
|
}): Promise<Wallet | null>;
|
|
@@ -307,6 +307,12 @@ declare abstract class WalletConnector {
|
|
|
307
307
|
setActive(): Promise<boolean>;
|
|
308
308
|
}
|
|
309
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
|
+
|
|
310
316
|
/**
|
|
311
317
|
* Light wrapper around WCConnectionManager that uses the global connection manager
|
|
312
318
|
* to manage the local storage layer and avoid conflicts.
|
|
@@ -316,8 +322,15 @@ declare abstract class WalletConnector {
|
|
|
316
322
|
*/
|
|
317
323
|
declare class WCWalletConnector extends WalletConnector {
|
|
318
324
|
private connectionManager;
|
|
319
|
-
|
|
320
|
-
|
|
325
|
+
constructor(connectionManager: WCConnectionManager, proxyProvider: PrivyProxyProvider, address: string | null,
|
|
326
|
+
/**
|
|
327
|
+
* If provided, the connector will attempt to establish a connection directly using this
|
|
328
|
+
* wallet. If omitted, but an address is provided, the connector may still attempt to link
|
|
329
|
+
* up to a wallet, but may be unable to. If a wallet cannot be determined, the standard WC
|
|
330
|
+
* modal is shown.
|
|
331
|
+
*/
|
|
332
|
+
walletId?: WalletId);
|
|
333
|
+
setActive(): Promise<boolean>;
|
|
321
334
|
connect(options: {
|
|
322
335
|
showPrompt: boolean;
|
|
323
336
|
}): Promise<Wallet | null>;
|
|
@@ -325,7 +338,7 @@ declare class WCWalletConnector extends WalletConnector {
|
|
|
325
338
|
/**
|
|
326
339
|
* Metadata about the wallet represented by this connector.
|
|
327
340
|
*/
|
|
328
|
-
get
|
|
341
|
+
get walletBranding(): {
|
|
329
342
|
name: string;
|
|
330
343
|
icon: string | EmbeddedSVG;
|
|
331
344
|
};
|
|
@@ -346,29 +359,34 @@ declare class WCWalletConnector extends WalletConnector {
|
|
|
346
359
|
*/
|
|
347
360
|
declare class WCConnectionManager {
|
|
348
361
|
private _storageIdToProvider;
|
|
349
|
-
private _addressToStorageId;
|
|
350
362
|
constructor();
|
|
351
363
|
/**
|
|
352
364
|
* Builds a new WCWalletConnector instance
|
|
353
365
|
*
|
|
354
|
-
* If
|
|
366
|
+
* If walletId is specified, attempts to launch into that specific flow
|
|
355
367
|
*/
|
|
356
|
-
createConnector(provider: PrivyProxyProvider, address: string | null,
|
|
368
|
+
createConnector(provider: PrivyProxyProvider, address: string | null, walletId?: WalletId): WCWalletConnector;
|
|
357
369
|
/**
|
|
358
370
|
* Disconnects all active Wallet Connect sessions.
|
|
359
371
|
*/
|
|
360
372
|
disconnect(): Promise<void>;
|
|
373
|
+
/**
|
|
374
|
+
* Fetch a storage id for an address/walletId pair. If we don't match exactly, we still
|
|
375
|
+
* attempt to discover if any legacy keys were matched using instant launch methods (currently)
|
|
376
|
+
* just metamask and reuse if that. Admittedly, this method feels very fragile and unknown.
|
|
377
|
+
*/
|
|
378
|
+
private getStorageId;
|
|
361
379
|
/**
|
|
362
380
|
* Given an address, either fetch (reusing a stored connection) or create a new one if no stored
|
|
363
381
|
* connection is found
|
|
364
382
|
*/
|
|
365
|
-
getOrCreateProviderForAddress(address: string | null,
|
|
383
|
+
getOrCreateProviderForAddress(address: string | null, walletId: WalletId | undefined): WCProvider;
|
|
366
384
|
/**
|
|
367
385
|
* Create a WC provider and add an entry to the internal provider registry keyed on the internal
|
|
368
|
-
* WC storageId. If
|
|
386
|
+
* WC storageId. If walletId is specified, attempts to launch the WC flow for that particular
|
|
369
387
|
* wallet
|
|
370
388
|
*/
|
|
371
|
-
createProvider(storageId: string,
|
|
389
|
+
createProvider(storageId: string, walletId: WalletId | undefined): WCProvider;
|
|
372
390
|
/**
|
|
373
391
|
* Replace the given provider, *assuming it's the one with null address*
|
|
374
392
|
*
|
|
@@ -376,14 +394,11 @@ declare class WCConnectionManager {
|
|
|
376
394
|
* seeing - WC sessions wouldn't open a new modal/etc when doing `provider.enable()` if it had
|
|
377
395
|
* previously been rejected: https://github.com/Uniswap/web3-react/issues/217
|
|
378
396
|
*/
|
|
379
|
-
replaceProvider(provider: WCProvider
|
|
397
|
+
replaceProvider(provider: WCProvider): WCProvider;
|
|
380
398
|
/**
|
|
381
399
|
* Enables the provider. Under the hood, this calls connect() and 'eth_RequestAccounts'.
|
|
382
400
|
*/
|
|
383
|
-
enableProvider(provider: WCProvider
|
|
384
|
-
}
|
|
385
|
-
declare enum InstantLaunchWallet {
|
|
386
|
-
metamask = "metamask"
|
|
401
|
+
enableProvider(provider: WCProvider): Promise<string[]>;
|
|
387
402
|
}
|
|
388
403
|
|
|
389
404
|
declare class ConnectorManager {
|
|
@@ -401,7 +416,9 @@ declare class ConnectorManager {
|
|
|
401
416
|
* initialize their WalletConnector objects accordingly.
|
|
402
417
|
**/
|
|
403
418
|
initializeLinkedWallets(user: User): void;
|
|
419
|
+
/** Load the state from storage and hydrate the instance with WalletConnectors. */
|
|
404
420
|
load(): void;
|
|
421
|
+
/** Persist the instance state to storage to reload the connectors later. */
|
|
405
422
|
save(): void;
|
|
406
423
|
addWalletConnector(walletConnector: WalletConnector): void;
|
|
407
424
|
getConnectorByAddress(address: string): WalletConnector | undefined;
|
|
@@ -417,7 +434,9 @@ declare class ConnectorManager {
|
|
|
417
434
|
* If the connector was successfully found and set active, return true.
|
|
418
435
|
*/
|
|
419
436
|
setActiveWallet(address: string | null): Promise<boolean>;
|
|
420
|
-
createWalletConnector(walletType: WalletType, address: string | null
|
|
437
|
+
createWalletConnector(walletType: WalletType, address: string | null,
|
|
438
|
+
/** Only applicable for WalletConnect right now */
|
|
439
|
+
walletId?: WalletId): WalletConnector;
|
|
421
440
|
}
|
|
422
441
|
|
|
423
442
|
/**
|