@privy-io/react-auth 1.26.0-beta.9 → 1.26.1-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/esm/index.js +108 -108
- package/dist/index.d.ts +87 -14
- package/dist/index.js +103 -103
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -140,12 +140,65 @@ interface EmbeddedWalletProxy {
|
|
|
140
140
|
rpc: (data: WalletRpcRequestDataType) => Promise<WalletRpcResponseDataType>;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
declare abstract class PrivyError extends Error {
|
|
144
|
+
/**
|
|
145
|
+
* Privy error type.
|
|
146
|
+
*/
|
|
147
|
+
abstract type: string;
|
|
148
|
+
/**
|
|
149
|
+
* Original Error object, it the error originated client-side.
|
|
150
|
+
*/
|
|
151
|
+
cause?: Error;
|
|
152
|
+
/**
|
|
153
|
+
* An optional error code, often included in Privy API responses.
|
|
154
|
+
*/
|
|
155
|
+
privyErrorCode?: PrivyErrorCode;
|
|
156
|
+
/**
|
|
157
|
+
* @param type Privy error type.
|
|
158
|
+
* @param message Human-readable message.
|
|
159
|
+
* @param cause Source of this error.
|
|
160
|
+
*/
|
|
161
|
+
protected constructor(message: string, cause?: unknown, privyErrorCode?: PrivyErrorCode);
|
|
162
|
+
toString(): string;
|
|
163
|
+
}
|
|
164
|
+
declare enum PrivyErrorCode {
|
|
165
|
+
MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
|
|
166
|
+
MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",
|
|
167
|
+
INVALID_DATA = "invalid_data",
|
|
168
|
+
LINKED_TO_ANOTHER_USER = "linked_to_another_user",
|
|
169
|
+
ALLOWLIST_REJECTED = "allowlist_rejected"
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* A ProviderRpcError combines the necessary bits of the {PrivyError} with the
|
|
174
|
+
* EIP-compliant ProviderRpcError. This is meant to be a type around errors raised
|
|
175
|
+
* by the ethereum provider.
|
|
176
|
+
*/
|
|
177
|
+
declare class ProviderRpcError extends PrivyError {
|
|
178
|
+
type: string;
|
|
179
|
+
readonly code: number;
|
|
180
|
+
readonly data?: unknown;
|
|
181
|
+
constructor(message: string, code: number, data?: unknown);
|
|
182
|
+
}
|
|
183
|
+
|
|
143
184
|
declare global {
|
|
144
185
|
interface Window {
|
|
145
186
|
ethereum?: unknown;
|
|
146
187
|
}
|
|
147
188
|
}
|
|
148
|
-
type
|
|
189
|
+
type ProviderConnectInfo = {
|
|
190
|
+
chainId: string;
|
|
191
|
+
};
|
|
192
|
+
type OnConnectEventHandler = (connectInfo: ProviderConnectInfo) => void;
|
|
193
|
+
type OnDisconnectEventHandler = (error: ProviderRpcError) => void;
|
|
194
|
+
type OnChainChangedEventHandler = (chainId: string | number) => void;
|
|
195
|
+
type OnAccountsChangedEventHandler = (accounts: string[]) => void;
|
|
196
|
+
type ProviderMessage = {
|
|
197
|
+
type: string;
|
|
198
|
+
data: unknown;
|
|
199
|
+
};
|
|
200
|
+
type OnMessageEventHandler = (message: ProviderMessage) => void;
|
|
201
|
+
type EIP1193OnEventHandler = OnConnectEventHandler | OnDisconnectEventHandler | OnChainChangedEventHandler | OnAccountsChangedEventHandler | OnMessageEventHandler;
|
|
149
202
|
interface EIP1193Provider {
|
|
150
203
|
request: (request: {
|
|
151
204
|
method: string;
|
|
@@ -251,8 +304,10 @@ declare abstract class WalletConnector extends EventEmitter<ConnectorEvents> {
|
|
|
251
304
|
buildConnectedWallet(address: string, chainId: string): BaseConnectedWallet;
|
|
252
305
|
/**
|
|
253
306
|
* Sync all accounts available via the provider if the wallet is connected.
|
|
307
|
+
*
|
|
308
|
+
* @param prefetchedAccounts - pass in an accounts array from eth_accounts if already fetched to avoid a repeated call
|
|
254
309
|
*/
|
|
255
|
-
syncAccounts(): Promise<void>;
|
|
310
|
+
syncAccounts(prefetchedAccounts?: string[]): Promise<void>;
|
|
256
311
|
/**
|
|
257
312
|
* Get the most recently connected wallet.
|
|
258
313
|
*/
|
|
@@ -269,7 +324,7 @@ declare abstract class WalletConnector extends EventEmitter<ConnectorEvents> {
|
|
|
269
324
|
* @returns {string} The resulting signature.
|
|
270
325
|
*/
|
|
271
326
|
sign(message: string): Promise<string>;
|
|
272
|
-
protected onAccountsChanged: (
|
|
327
|
+
protected onAccountsChanged: (accounts: string[]) => void;
|
|
273
328
|
protected onChainChanged: (chainId: string) => void;
|
|
274
329
|
protected onDisconnect: () => void;
|
|
275
330
|
protected onConnect: () => void;
|
|
@@ -362,7 +417,7 @@ interface Wallet {
|
|
|
362
417
|
walletClient: 'privy' | 'unknown';
|
|
363
418
|
}
|
|
364
419
|
/**
|
|
365
|
-
* Object representation of a connected wallet.
|
|
420
|
+
* Object representation of a base connected wallet from a wallet connector.
|
|
366
421
|
*/
|
|
367
422
|
interface BaseConnectedWallet {
|
|
368
423
|
/** The wallet address. */
|
|
@@ -371,16 +426,26 @@ interface BaseConnectedWallet {
|
|
|
371
426
|
chainId: string;
|
|
372
427
|
/** The first time this wallet was connected without break. */
|
|
373
428
|
connectedAt: number;
|
|
374
|
-
/**
|
|
429
|
+
/**
|
|
430
|
+
* @experimental **Experimental**: This property is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
431
|
+
*
|
|
432
|
+
* The wallet client where this key-pair is stored.
|
|
433
|
+
* e.g. metamask, rainbow, coinbase_wallet, etc.
|
|
434
|
+
*/
|
|
375
435
|
walletClientType: WalletClientType;
|
|
376
|
-
/**
|
|
436
|
+
/**
|
|
437
|
+
* @experimental **Experimental**: This property is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
438
|
+
*
|
|
439
|
+
* The connector used to initiate the connection with the wallet client.
|
|
440
|
+
* e.g. injected, wallet_connect, coinbase_wallet, etc.
|
|
441
|
+
*/
|
|
377
442
|
connectorType: ConnectorType;
|
|
378
443
|
/** Returns true if the wallet is connected, false otherwise */
|
|
379
444
|
isConnected: () => Promise<boolean>;
|
|
380
445
|
/** Helper methods to build providers for interfacing with this wallet. */
|
|
381
|
-
getEthereumProvider: () => EIP1193Provider
|
|
382
|
-
getEthersProvider: () => Web3Provider
|
|
383
|
-
getWeb3jsProvider: () => AbstractProvider
|
|
446
|
+
getEthereumProvider: () => Promise<EIP1193Provider>;
|
|
447
|
+
getEthersProvider: () => Promise<Web3Provider>;
|
|
448
|
+
getWeb3jsProvider: () => Promise<AbstractProvider>;
|
|
384
449
|
/**
|
|
385
450
|
* Perform personal_sign with the user's wallet.
|
|
386
451
|
*
|
|
@@ -388,10 +453,18 @@ interface BaseConnectedWallet {
|
|
|
388
453
|
* @returns {string} The resulting signature.
|
|
389
454
|
*/
|
|
390
455
|
sign: (message: string) => Promise<string>;
|
|
391
|
-
/**
|
|
392
|
-
*
|
|
456
|
+
/**
|
|
457
|
+
* @experimental **Experimental**: This property is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
458
|
+
*
|
|
459
|
+
* Disconnect method does not work on all connector types and will no-op if
|
|
460
|
+
* an incompatible connector is used (metamask and phantom do not support
|
|
461
|
+
* programmatic disconnects)
|
|
462
|
+
*/
|
|
393
463
|
disconnect: () => void;
|
|
394
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Object representation of a connected wallet.
|
|
467
|
+
*/
|
|
395
468
|
interface ConnectedWallet extends BaseConnectedWallet {
|
|
396
469
|
/** True if this wallet is linked to the authenticated user. False if it is not yet linked or
|
|
397
470
|
* the user has not yet authenticated. */
|
|
@@ -954,13 +1027,13 @@ interface PrivyInterface {
|
|
|
954
1027
|
*/
|
|
955
1028
|
setActiveWallet: (address: string) => Promise<void>;
|
|
956
1029
|
/**
|
|
957
|
-
* @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/
|
|
1030
|
+
* @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
958
1031
|
*
|
|
959
1032
|
* Get a short-lived, one-time-use token to start a new Privy session from the existing authenticated session. Raises an exception if the current session was already forked from a previous session.
|
|
960
1033
|
*/
|
|
961
1034
|
forkSession: () => Promise<string>;
|
|
962
1035
|
/**
|
|
963
|
-
* @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/
|
|
1036
|
+
* @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
964
1037
|
*
|
|
965
1038
|
* Prompts a user to create an Ethereum wallet through Privy.
|
|
966
1039
|
*
|
|
@@ -972,7 +1045,7 @@ interface PrivyInterface {
|
|
|
972
1045
|
*/
|
|
973
1046
|
createWallet: () => Promise<Wallet>;
|
|
974
1047
|
/**
|
|
975
|
-
* @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/
|
|
1048
|
+
* @experimental **Experimental**: This feature is {@link https://docs.privy.io/guide/guides/experimental-features subject to change at any time}.
|
|
976
1049
|
*
|
|
977
1050
|
* Prompts a user to sign a message using their Privy wallet.
|
|
978
1051
|
*
|