@privy-io/js-sdk-core 0.28.0 → 0.28.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.cjs.js → cjs/index.js} +1 -2
- package/dist/dts/AuthApi.d.mts +46 -0
- package/dist/dts/CustomProviderApi.d.mts +8 -0
- package/dist/dts/EmailApi.d.mts +451 -0
- package/dist/dts/EmbeddedWalletApi.d.mts +103 -0
- package/dist/dts/Error.d.mts +20 -0
- package/dist/dts/FarcasterApi.d.mts +467 -0
- package/dist/dts/GuestApi.d.mts +9 -0
- package/dist/dts/OAuthApi.d.mts +461 -0
- package/dist/dts/PasskeyApi.d.mts +80 -0
- package/dist/dts/PhoneApi.d.mts +451 -0
- package/dist/dts/Privy.d.mts +78 -0
- package/dist/dts/PrivyInternal.d.mts +1 -0
- package/dist/dts/RecoveryApi.d.mts +19 -0
- package/dist/dts/RecoveryICloudApi.d.mts +15 -0
- package/dist/dts/RecoveryOAuthApi.d.mts +16 -0
- package/dist/dts/Session.d.mts +88 -0
- package/dist/dts/SiweApi.d.mts +75 -0
- package/dist/dts/Token.d.mts +31 -0
- package/dist/dts/UserApi.d.mts +221 -0
- package/dist/dts/chains/arbitrum.d.mts +2 -0
- package/dist/dts/chains/arbitrumGoerli.d.mts +7 -0
- package/dist/dts/chains/arbitrumSepolia.d.mts +2 -0
- package/dist/dts/chains/avalanche.d.mts +5 -0
- package/dist/dts/chains/avalancheFuji.d.mts +5 -0
- package/dist/dts/chains/base.d.mts +2 -0
- package/dist/dts/chains/baseGoerli.d.mts +7 -0
- package/dist/dts/chains/baseSepolia.d.mts +5 -0
- package/dist/dts/chains/berachainArtio.d.mts +5 -0
- package/dist/dts/chains/celo.d.mts +2 -0
- package/dist/dts/chains/celoAlfajores.d.mts +2 -0
- package/dist/dts/chains/filecoin.d.mts +2 -0
- package/dist/dts/chains/filecoinCalibration.d.mts +2 -0
- package/dist/dts/chains/garnetHolesky.d.mts +2 -0
- package/dist/dts/chains/goerli.d.mts +5 -0
- package/dist/dts/chains/holesky.d.mts +2 -0
- package/dist/dts/chains/index.d.mts +34 -0
- package/dist/dts/chains/linea.d.mts +2 -0
- package/dist/dts/chains/lineaTestnet.d.mts +2 -0
- package/dist/dts/chains/mainnet.d.mts +2 -0
- package/dist/dts/chains/optimism.d.mts +2 -0
- package/dist/dts/chains/optimismGoerli.d.mts +5 -0
- package/dist/dts/chains/optimismSepolia.d.mts +2 -0
- package/dist/dts/chains/polygon.d.mts +2 -0
- package/dist/dts/chains/polygonAmoy.d.mts +2 -0
- package/dist/dts/chains/polygonMumbai.d.mts +5 -0
- package/dist/dts/chains/redstone.d.mts +2 -0
- package/dist/dts/chains/redstoneHolesky.d.mts +5 -0
- package/dist/dts/chains/sepolia.d.mts +2 -0
- package/dist/dts/chains/types.d.mts +59 -0
- package/dist/dts/chains/zora.d.mts +2 -0
- package/dist/dts/chains/zoraSepolia.d.mts +2 -0
- package/dist/dts/chains/zoraTestnet.d.mts +2 -0
- package/dist/dts/crypto/types.d.mts +1 -0
- package/dist/dts/embedded/EmbeddedSolanaWalletProvider.d.mts +11 -0
- package/dist/dts/embedded/EmbeddedWalletProvider.d.mts +47 -0
- package/dist/dts/embedded/EmbeddedWalletProxy.d.mts +1 -0
- package/dist/dts/embedded/EventCallbackQueue.d.mts +26 -0
- package/dist/dts/embedded/errors.d.mts +254 -0
- package/dist/dts/embedded/gas/arbitrum.d.mts +31 -0
- package/dist/dts/embedded/gas/bsc.d.mts +26 -0
- package/dist/dts/embedded/gas/op-stack.d.mts +42 -0
- package/dist/dts/embedded/gas/polygon.d.mts +42 -0
- package/dist/dts/embedded/index.d.mts +3 -0
- package/dist/dts/embedded/methods.d.mts +1 -0
- package/dist/dts/embedded/polygonGasStation.d.mts +15 -0
- package/dist/dts/embedded/types.d.mts +385 -0
- package/dist/dts/embedded/utils/ethers.d.mts +7 -0
- package/dist/dts/embedded/utils/gas.d.mts +45 -0
- package/dist/dts/embedded/utils/index.d.mts +36 -0
- package/dist/dts/index.d.mts +16 -0
- package/dist/dts/pkce.d.mts +33 -0
- package/dist/dts/storage/InMemoryStorage.d.mts +8 -0
- package/dist/dts/storage/LocalStorage.d.mts +7 -0
- package/dist/dts/storage/Storage.d.mts +6 -0
- package/dist/dts/toAbortSignalTimeout.d.mts +6 -0
- package/dist/dts/types.d.mts +54 -0
- package/dist/dts/utils/NonEmptyArray.d.mts +1 -0
- package/dist/dts/utils/getUserEmbeddedSolanaWallet.d.mts +12 -0
- package/dist/dts/utils/getUserEmbeddedWallet.d.mts +13 -0
- package/dist/dts/utils/toObjectKeys.d.mts +4 -0
- package/dist/esm/AuthApi.mjs +1 -0
- package/dist/{CustomProviderApi.js → esm/CustomProviderApi.mjs} +0 -1
- package/dist/{EmailApi.js → esm/EmailApi.mjs} +0 -1
- package/dist/esm/EmbeddedWalletApi.mjs +1 -0
- package/dist/{Error.js → esm/Error.mjs} +0 -1
- package/dist/{FarcasterApi.js → esm/FarcasterApi.mjs} +0 -1
- package/dist/{GuestApi.js → esm/GuestApi.mjs} +0 -1
- package/dist/esm/OAuthApi.mjs +1 -0
- package/dist/{PasskeyApi.js → esm/PasskeyApi.mjs} +0 -1
- package/dist/{PhoneApi.js → esm/PhoneApi.mjs} +0 -1
- package/dist/esm/Privy.mjs +1 -0
- package/dist/esm/PrivyInternal.mjs +1 -0
- package/dist/esm/RecoveryApi.mjs +1 -0
- package/dist/{RecoveryICloudApi.js → esm/RecoveryICloudApi.mjs} +0 -1
- package/dist/esm/RecoveryOAuthApi.mjs +1 -0
- package/dist/esm/Session.mjs +1 -0
- package/dist/{SiweApi.js → esm/SiweApi.mjs} +0 -1
- package/dist/{Token.js → esm/Token.mjs} +0 -1
- package/dist/{UserApi.js → esm/UserApi.mjs} +0 -1
- package/dist/{chains/arbitrum.js → esm/chains/arbitrum.mjs} +0 -1
- package/dist/{chains/arbitrumGoerli.js → esm/chains/arbitrumGoerli.mjs} +0 -1
- package/dist/{chains/arbitrumSepolia.js → esm/chains/arbitrumSepolia.mjs} +0 -1
- package/dist/{chains/avalanche.js → esm/chains/avalanche.mjs} +0 -1
- package/dist/{chains/avalancheFuji.js → esm/chains/avalancheFuji.mjs} +0 -1
- package/dist/{chains/base.js → esm/chains/base.mjs} +0 -1
- package/dist/{chains/baseGoerli.js → esm/chains/baseGoerli.mjs} +0 -1
- package/dist/{chains/baseSepolia.js → esm/chains/baseSepolia.mjs} +0 -1
- package/dist/{chains/berachainArtio.js → esm/chains/berachainArtio.mjs} +0 -1
- package/dist/{chains/celo.js → esm/chains/celo.mjs} +0 -1
- package/dist/{chains/celoAlfajores.js → esm/chains/celoAlfajores.mjs} +0 -1
- package/dist/{chains/filecoin.js → esm/chains/filecoin.mjs} +0 -1
- package/dist/{chains/filecoinCalibration.js → esm/chains/filecoinCalibration.mjs} +0 -1
- package/dist/{chains/garnetHolesky.js → esm/chains/garnetHolesky.mjs} +0 -1
- package/dist/{chains/goerli.js → esm/chains/goerli.mjs} +0 -1
- package/dist/{chains/holesky.js → esm/chains/holesky.mjs} +0 -1
- package/dist/esm/chains/index.mjs +1 -0
- package/dist/{chains/linea.js → esm/chains/linea.mjs} +0 -1
- package/dist/{chains/lineaTestnet.js → esm/chains/lineaTestnet.mjs} +0 -1
- package/dist/{chains/mainnet.js → esm/chains/mainnet.mjs} +0 -1
- package/dist/{chains/optimism.js → esm/chains/optimism.mjs} +0 -1
- package/dist/{chains/optimismGoerli.js → esm/chains/optimismGoerli.mjs} +0 -1
- package/dist/{chains/optimismSepolia.js → esm/chains/optimismSepolia.mjs} +0 -1
- package/dist/{chains/polygon.js → esm/chains/polygon.mjs} +0 -1
- package/dist/{chains/polygonAmoy.js → esm/chains/polygonAmoy.mjs} +0 -1
- package/dist/{chains/polygonMumbai.js → esm/chains/polygonMumbai.mjs} +0 -1
- package/dist/{chains/redstone.js → esm/chains/redstone.mjs} +0 -1
- package/dist/{chains/redstoneHolesky.js → esm/chains/redstoneHolesky.mjs} +0 -1
- package/dist/{chains/sepolia.js → esm/chains/sepolia.mjs} +0 -1
- package/dist/esm/chains/types.mjs +1 -0
- package/dist/{chains/zora.js → esm/chains/zora.mjs} +0 -1
- package/dist/{chains/zoraSepolia.js → esm/chains/zoraSepolia.mjs} +0 -1
- package/dist/{chains/zoraTestnet.js → esm/chains/zoraTestnet.mjs} +0 -1
- package/dist/esm/crypto/types.mjs +1 -0
- package/dist/esm/embedded/EmbeddedSolanaWalletProvider.mjs +1 -0
- package/dist/esm/embedded/EmbeddedWalletProvider.mjs +1 -0
- package/dist/esm/embedded/EmbeddedWalletProxy.mjs +1 -0
- package/dist/{embedded/EventCallbackQueue.js → esm/embedded/EventCallbackQueue.mjs} +0 -1
- package/dist/esm/embedded/errors.mjs +1 -0
- package/dist/esm/embedded/gas/arbitrum.mjs +1 -0
- package/dist/{embedded/gas/bsc.js → esm/embedded/gas/bsc.mjs} +0 -1
- package/dist/esm/embedded/gas/op-stack.mjs +1 -0
- package/dist/esm/embedded/gas/polygon.mjs +1 -0
- package/dist/esm/embedded/index.mjs +1 -0
- package/dist/{embedded/methods.js → esm/embedded/methods.mjs} +0 -1
- package/dist/esm/embedded/polygonGasStation.mjs +1 -0
- package/dist/{embedded/types.js → esm/embedded/types.mjs} +0 -1
- package/dist/{embedded/utils/ethers.js → esm/embedded/utils/ethers.mjs} +0 -1
- package/dist/esm/embedded/utils/gas.mjs +1 -0
- package/dist/esm/embedded/utils/index.mjs +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/{pkce.js → esm/pkce.mjs} +0 -1
- package/dist/{storage/InMemoryStorage.js → esm/storage/InMemoryStorage.mjs} +0 -1
- package/dist/{storage/LocalStorage.js → esm/storage/LocalStorage.mjs} +0 -1
- package/dist/esm/storage/Storage.mjs +1 -0
- package/dist/{toAbortSignalTimeout.js → esm/toAbortSignalTimeout.mjs} +0 -1
- package/dist/{types.js → esm/types.mjs} +0 -1
- package/dist/esm/utils/NonEmptyArray.mjs +1 -0
- package/dist/{utils/getUserEmbeddedSolanaWallet.js → esm/utils/getUserEmbeddedSolanaWallet.mjs} +0 -1
- package/dist/{utils/getUserEmbeddedWallet.js → esm/utils/getUserEmbeddedWallet.mjs} +0 -1
- package/dist/{utils/toObjectKeys.js → esm/utils/toObjectKeys.mjs} +0 -1
- package/package.json +42 -36
- package/dist/AuthApi.js +0 -2
- package/dist/AuthApi.js.map +0 -1
- package/dist/CustomProviderApi.js.map +0 -1
- package/dist/EmailApi.js.map +0 -1
- package/dist/EmbeddedWalletApi.js +0 -2
- package/dist/EmbeddedWalletApi.js.map +0 -1
- package/dist/Error.js.map +0 -1
- package/dist/FarcasterApi.js.map +0 -1
- package/dist/GuestApi.js.map +0 -1
- package/dist/OAuthApi.js +0 -2
- package/dist/OAuthApi.js.map +0 -1
- package/dist/PasskeyApi.js.map +0 -1
- package/dist/PhoneApi.js.map +0 -1
- package/dist/Privy.js +0 -2
- package/dist/Privy.js.map +0 -1
- package/dist/PrivyInternal.js +0 -2
- package/dist/PrivyInternal.js.map +0 -1
- package/dist/RecoveryApi.js +0 -2
- package/dist/RecoveryApi.js.map +0 -1
- package/dist/RecoveryICloudApi.js.map +0 -1
- package/dist/RecoveryOAuthApi.js +0 -2
- package/dist/RecoveryOAuthApi.js.map +0 -1
- package/dist/Session.js +0 -2
- package/dist/Session.js.map +0 -1
- package/dist/SiweApi.js.map +0 -1
- package/dist/Token.js.map +0 -1
- package/dist/UserApi.js.map +0 -1
- package/dist/chains/arbitrum.js.map +0 -1
- package/dist/chains/arbitrumGoerli.js.map +0 -1
- package/dist/chains/arbitrumSepolia.js.map +0 -1
- package/dist/chains/avalanche.js.map +0 -1
- package/dist/chains/avalancheFuji.js.map +0 -1
- package/dist/chains/base.js.map +0 -1
- package/dist/chains/baseGoerli.js.map +0 -1
- package/dist/chains/baseSepolia.js.map +0 -1
- package/dist/chains/berachainArtio.js.map +0 -1
- package/dist/chains/celo.js.map +0 -1
- package/dist/chains/celoAlfajores.js.map +0 -1
- package/dist/chains/filecoin.js.map +0 -1
- package/dist/chains/filecoinCalibration.js.map +0 -1
- package/dist/chains/garnetHolesky.js.map +0 -1
- package/dist/chains/goerli.js.map +0 -1
- package/dist/chains/holesky.js.map +0 -1
- package/dist/chains/index.js +0 -2
- package/dist/chains/index.js.map +0 -1
- package/dist/chains/linea.js.map +0 -1
- package/dist/chains/lineaTestnet.js.map +0 -1
- package/dist/chains/mainnet.js.map +0 -1
- package/dist/chains/optimism.js.map +0 -1
- package/dist/chains/optimismGoerli.js.map +0 -1
- package/dist/chains/optimismSepolia.js.map +0 -1
- package/dist/chains/polygon.js.map +0 -1
- package/dist/chains/polygonAmoy.js.map +0 -1
- package/dist/chains/polygonMumbai.js.map +0 -1
- package/dist/chains/redstone.js.map +0 -1
- package/dist/chains/redstoneHolesky.js.map +0 -1
- package/dist/chains/sepolia.js.map +0 -1
- package/dist/chains/types.js +0 -2
- package/dist/chains/types.js.map +0 -1
- package/dist/chains/zora.js.map +0 -1
- package/dist/chains/zoraSepolia.js.map +0 -1
- package/dist/chains/zoraTestnet.js.map +0 -1
- package/dist/crypto/types.js +0 -2
- package/dist/crypto/types.js.map +0 -1
- package/dist/embedded/EmbeddedSolanaWalletProvider.js +0 -2
- package/dist/embedded/EmbeddedSolanaWalletProvider.js.map +0 -1
- package/dist/embedded/EmbeddedWalletProvider.js +0 -2
- package/dist/embedded/EmbeddedWalletProvider.js.map +0 -1
- package/dist/embedded/EmbeddedWalletProxy.js +0 -2
- package/dist/embedded/EmbeddedWalletProxy.js.map +0 -1
- package/dist/embedded/EventCallbackQueue.js.map +0 -1
- package/dist/embedded/errors.js +0 -2
- package/dist/embedded/errors.js.map +0 -1
- package/dist/embedded/gas/arbitrum.js +0 -2
- package/dist/embedded/gas/arbitrum.js.map +0 -1
- package/dist/embedded/gas/bsc.js.map +0 -1
- package/dist/embedded/gas/op-stack.js +0 -2
- package/dist/embedded/gas/op-stack.js.map +0 -1
- package/dist/embedded/gas/polygon.js +0 -2
- package/dist/embedded/gas/polygon.js.map +0 -1
- package/dist/embedded/index.js +0 -2
- package/dist/embedded/index.js.map +0 -1
- package/dist/embedded/methods.js.map +0 -1
- package/dist/embedded/polygonGasStation.js +0 -2
- package/dist/embedded/polygonGasStation.js.map +0 -1
- package/dist/embedded/types.js.map +0 -1
- package/dist/embedded/utils/ethers.js.map +0 -1
- package/dist/embedded/utils/gas.js +0 -2
- package/dist/embedded/utils/gas.js.map +0 -1
- package/dist/embedded/utils/index.js +0 -2
- package/dist/embedded/utils/index.js.map +0 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/pkce.js.map +0 -1
- package/dist/storage/InMemoryStorage.js.map +0 -1
- package/dist/storage/LocalStorage.js.map +0 -1
- package/dist/storage/Storage.js +0 -2
- package/dist/storage/Storage.js.map +0 -1
- package/dist/toAbortSignalTimeout.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/NonEmptyArray.js +0 -2
- package/dist/utils/NonEmptyArray.js.map +0 -1
- package/dist/utils/getUserEmbeddedSolanaWallet.js.map +0 -1
- package/dist/utils/getUserEmbeddedWallet.js.map +0 -1
- package/dist/utils/toObjectKeys.js.map +0 -1
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We support a subset of the provider methods found here:
|
|
3
|
+
*
|
|
4
|
+
* https://ethereum.org/en/developers/docs/apis/json-rpc/#json-rpc-methods
|
|
5
|
+
*
|
|
6
|
+
* For now, we're focused on signing-related methods because the iframe (this code)
|
|
7
|
+
* is the only place that has access to the private key and thus is the only one
|
|
8
|
+
* who can create signatures. All other methods do not need the private key and
|
|
9
|
+
* can therefore be implemented by clients of the iframe.
|
|
10
|
+
*/
|
|
11
|
+
import type { TypedMessage, MessageTypes } from '@metamask/eth-sig-util';
|
|
12
|
+
import type { PrivyEthereumEmbeddedWalletAccount } from '@privy-io/public-api';
|
|
13
|
+
export declare const SUPPORTED_JSON_RPC_METHODS: readonly ["eth_sign", "eth_populateTransactionRequest", "eth_signTransaction", "personal_sign", "eth_signTypedData_v4"];
|
|
14
|
+
export type JsonRpcMethodType = (typeof SUPPORTED_JSON_RPC_METHODS)[number];
|
|
15
|
+
export declare const isSupportedRpcMethod: (method: any) => method is JsonRpcMethodType;
|
|
16
|
+
export type Quantity = string | number | bigint;
|
|
17
|
+
export type UnsignedTransactionRequest = {
|
|
18
|
+
from?: string;
|
|
19
|
+
to?: string;
|
|
20
|
+
nonce?: Quantity;
|
|
21
|
+
gasLimit?: Quantity;
|
|
22
|
+
gasPrice?: Quantity;
|
|
23
|
+
data?: ArrayLike<number> | string;
|
|
24
|
+
value?: Quantity;
|
|
25
|
+
chainId?: number;
|
|
26
|
+
type?: number;
|
|
27
|
+
accessList?: Array<{
|
|
28
|
+
address: string;
|
|
29
|
+
storageKeys: Array<string>;
|
|
30
|
+
}> | Array<[string, Array<string>]> | Record<string, Array<string>>;
|
|
31
|
+
maxPriorityFeePerGas?: Quantity;
|
|
32
|
+
maxFeePerGas?: Quantity;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* {@link UnsignedTransactionRequest} specifies the `chainId` field as optional,
|
|
36
|
+
* which matches ethers, wagmi, and a bunch of other libraries.
|
|
37
|
+
*
|
|
38
|
+
* However, we need the transaction's `chainId` to ensure it does price conversion, quote
|
|
39
|
+
* labeling, etc. importantly.
|
|
40
|
+
*
|
|
41
|
+
* > Note:
|
|
42
|
+
* > If the developer does not set a `chainId` in their `UnsignedTransactionRequest`,
|
|
43
|
+
* > we default to the embedded provider's current `chainId`
|
|
44
|
+
*/
|
|
45
|
+
export type UnsignedTransactionRequestWithChainId = UnsignedTransactionRequest & {
|
|
46
|
+
chainId: number;
|
|
47
|
+
};
|
|
48
|
+
export type TransactionLog = {
|
|
49
|
+
blockNumber: number;
|
|
50
|
+
blockHash: string;
|
|
51
|
+
transactionIndex: number;
|
|
52
|
+
removed: boolean;
|
|
53
|
+
address: string;
|
|
54
|
+
data: string;
|
|
55
|
+
topics: Array<string>;
|
|
56
|
+
transactionHash: string;
|
|
57
|
+
logIndex: number;
|
|
58
|
+
};
|
|
59
|
+
export type TransactionReceipt = {
|
|
60
|
+
to: string;
|
|
61
|
+
from: string;
|
|
62
|
+
contractAddress: string;
|
|
63
|
+
transactionIndex: number;
|
|
64
|
+
root?: string;
|
|
65
|
+
logs: Array<TransactionLog>;
|
|
66
|
+
logsBloom: string;
|
|
67
|
+
blockHash: string;
|
|
68
|
+
transactionHash: string;
|
|
69
|
+
blockNumber: number;
|
|
70
|
+
confirmations: number;
|
|
71
|
+
byzantium: boolean;
|
|
72
|
+
type: number;
|
|
73
|
+
status?: number;
|
|
74
|
+
gasUsed: string;
|
|
75
|
+
cumulativeGasUsed: string;
|
|
76
|
+
effectiveGasPrice: string;
|
|
77
|
+
};
|
|
78
|
+
interface BaseRpcRequestType {
|
|
79
|
+
method: JsonRpcMethodType;
|
|
80
|
+
}
|
|
81
|
+
interface eth_populateTransactionRequest extends BaseRpcRequestType {
|
|
82
|
+
method: 'eth_populateTransactionRequest';
|
|
83
|
+
params: [UnsignedTransactionRequest];
|
|
84
|
+
}
|
|
85
|
+
interface eth_populateTransactionRequestResponse {
|
|
86
|
+
method: 'eth_populateTransactionRequest';
|
|
87
|
+
data: UnsignedTransactionRequest;
|
|
88
|
+
}
|
|
89
|
+
interface eth_signTransaction extends BaseRpcRequestType {
|
|
90
|
+
method: 'eth_signTransaction';
|
|
91
|
+
params: [UnsignedTransactionRequest];
|
|
92
|
+
}
|
|
93
|
+
interface eth_sign extends BaseRpcRequestType {
|
|
94
|
+
method: 'eth_sign';
|
|
95
|
+
params: [address: string, message: string];
|
|
96
|
+
}
|
|
97
|
+
interface eth_signResponse {
|
|
98
|
+
method: 'eth_sign';
|
|
99
|
+
data: string;
|
|
100
|
+
}
|
|
101
|
+
interface personal_sign extends BaseRpcRequestType {
|
|
102
|
+
method: 'personal_sign';
|
|
103
|
+
params: [string, string];
|
|
104
|
+
}
|
|
105
|
+
interface personal_signResponse {
|
|
106
|
+
method: 'personal_sign';
|
|
107
|
+
data: string;
|
|
108
|
+
}
|
|
109
|
+
interface eth_signTransactionResponse {
|
|
110
|
+
method: 'eth_signTransaction';
|
|
111
|
+
data: string;
|
|
112
|
+
}
|
|
113
|
+
interface eth_sendTransaction {
|
|
114
|
+
method: 'eth_sendTransaction';
|
|
115
|
+
data: string;
|
|
116
|
+
}
|
|
117
|
+
interface eth_signTypedData_v4 extends BaseRpcRequestType {
|
|
118
|
+
method: 'eth_signTypedData_v4';
|
|
119
|
+
params: [string, TypedMessage<MessageTypes> | string];
|
|
120
|
+
}
|
|
121
|
+
interface eth_signTypedData_v4Response {
|
|
122
|
+
method: 'eth_signTypedData_v4';
|
|
123
|
+
data: string;
|
|
124
|
+
}
|
|
125
|
+
export type RpcRequestType = eth_sendTransaction | eth_signTransaction | eth_populateTransactionRequest | eth_sign | personal_sign | eth_signTypedData_v4;
|
|
126
|
+
export type RpcResponseType = eth_signTransactionResponse | eth_populateTransactionRequestResponse | eth_signResponse | personal_signResponse | eth_signTypedData_v4Response;
|
|
127
|
+
declare const SUPPORTED_SOLANA_RPC_METHODS: readonly ["signMessage"];
|
|
128
|
+
type SolanaRpcMethodType = (typeof SUPPORTED_SOLANA_RPC_METHODS)[number];
|
|
129
|
+
export declare const isSupportedSolanaRpcMethod: (method: any) => method is SolanaRpcMethodType;
|
|
130
|
+
export interface BaseSolanaRpcRequestType {
|
|
131
|
+
method: SolanaRpcMethodType;
|
|
132
|
+
params: any;
|
|
133
|
+
}
|
|
134
|
+
export interface SolanaRpcRequestType extends BaseSolanaRpcRequestType {
|
|
135
|
+
method: 'signMessage';
|
|
136
|
+
params: {
|
|
137
|
+
message: string;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export interface SolanaRpcResponseType {
|
|
141
|
+
data: {
|
|
142
|
+
signature: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export type PrivyEventType = 'privy:iframe:ready' | 'privy:wallet:create' | 'privy:wallet:connect' | 'privy:wallet:recover' | 'privy:wallet:rpc' | 'privy:wallet:set-recovery' | 'privy:solana-wallet:create' | 'privy:solana-wallet:connect' | 'privy:solana-wallet:recover' | 'privy:solana-wallet:rpc';
|
|
146
|
+
export type IEmbeddedWalletRecoveryOptions = 'privy' | 'user-passcode' | 'google-drive' | 'icloud' | 'icloud-native';
|
|
147
|
+
export type IUserRecoveryMethod = 'user-passcode' | 'google-drive' | 'icloud' | 'icloud-native';
|
|
148
|
+
export type EmbeddedWalletRecoveryOptions = 'privy' | 'user-passcode' | 'google-drive' | 'icloud';
|
|
149
|
+
export type PasswordRecoveryInput = {
|
|
150
|
+
recoveryMethod: 'user-passcode';
|
|
151
|
+
password: string;
|
|
152
|
+
};
|
|
153
|
+
export type CloudRecoveryInput = {
|
|
154
|
+
recoveryMethod: 'google-drive' | 'icloud';
|
|
155
|
+
recoveryAccessToken: string;
|
|
156
|
+
};
|
|
157
|
+
export type ICloudNativeRecoveryInput = {
|
|
158
|
+
recoveryMethod: 'icloud-native';
|
|
159
|
+
recoverySecretOverride: string;
|
|
160
|
+
iCloudRecordNameOverride: string;
|
|
161
|
+
};
|
|
162
|
+
export type SetRecoveryInput = {
|
|
163
|
+
wallet: PrivyEthereumEmbeddedWalletAccount;
|
|
164
|
+
} & (PasswordRecoveryInput | CloudRecoveryInput | ICloudNativeRecoveryInput | PrivyRecoveryInput);
|
|
165
|
+
export type IframeReadyRequestDataType = Record<string, never>;
|
|
166
|
+
export type WalletCreateRequestDataType = {
|
|
167
|
+
accessToken: string;
|
|
168
|
+
recoveryPassword?: string;
|
|
169
|
+
recoveryMethod?: IEmbeddedWalletRecoveryOptions;
|
|
170
|
+
recoveryAccessToken?: string;
|
|
171
|
+
recoverySecretOverride?: string;
|
|
172
|
+
iCloudRecordNameOverride?: string;
|
|
173
|
+
};
|
|
174
|
+
export type WalletConnectRequestDataType = {
|
|
175
|
+
accessToken: string;
|
|
176
|
+
address: string;
|
|
177
|
+
};
|
|
178
|
+
export type WalletRecoverRequestDataType = {
|
|
179
|
+
accessToken: string;
|
|
180
|
+
address: string;
|
|
181
|
+
recoveryPassword?: string;
|
|
182
|
+
recoveryMethod?: string;
|
|
183
|
+
recoveryAccessToken?: string;
|
|
184
|
+
recoverySecretOverride?: string;
|
|
185
|
+
};
|
|
186
|
+
export type WalletSetRecoveryRequestDataType = {
|
|
187
|
+
accessToken: string;
|
|
188
|
+
address: string;
|
|
189
|
+
recoveryMethod: IUserRecoveryMethod;
|
|
190
|
+
recoveryPassword?: string;
|
|
191
|
+
recoveryAccessToken?: string;
|
|
192
|
+
recoverySecretOverride?: string;
|
|
193
|
+
iCloudRecordNameOverride?: string;
|
|
194
|
+
};
|
|
195
|
+
export type WalletRpcRequestDataType = {
|
|
196
|
+
accessToken: string;
|
|
197
|
+
address: string;
|
|
198
|
+
request: RpcRequestType;
|
|
199
|
+
};
|
|
200
|
+
export type SolanaWalletCreateRequestDataType = {
|
|
201
|
+
accessToken: string;
|
|
202
|
+
/**
|
|
203
|
+
* The user's existing Ethereum embedded wallet address if they have one. This parameter must be passed
|
|
204
|
+
* if the user has an Ethereum embedded wallet, otherwise Solana wallet creation will fail.
|
|
205
|
+
*/
|
|
206
|
+
ethereumAddress?: string;
|
|
207
|
+
};
|
|
208
|
+
export type SolanaWalletConnectRequestDataType = {
|
|
209
|
+
accessToken: string;
|
|
210
|
+
publicKey: string;
|
|
211
|
+
};
|
|
212
|
+
export type SolanaWalletRecoverRequestDataType = {
|
|
213
|
+
accessToken: string;
|
|
214
|
+
publicKey: string;
|
|
215
|
+
};
|
|
216
|
+
export type SolanaWalletRpcRequestDataType = {
|
|
217
|
+
accessToken: string;
|
|
218
|
+
publicKey: string;
|
|
219
|
+
request: SolanaRpcRequestType;
|
|
220
|
+
};
|
|
221
|
+
export type PrivyRequestDataType = IframeReadyRequestDataType | WalletCreateRequestDataType | WalletConnectRequestDataType | WalletRecoverRequestDataType | WalletRpcRequestDataType | SolanaWalletCreateRequestDataType | SolanaWalletRecoverRequestDataType | SolanaWalletConnectRequestDataType | SolanaWalletRpcRequestDataType;
|
|
222
|
+
export type PrivyErrorResponseDataType = {
|
|
223
|
+
error: Error;
|
|
224
|
+
};
|
|
225
|
+
export type IframeReadyResponseDataType = Record<string, never>;
|
|
226
|
+
export type WalletCreateResponseDataType = {
|
|
227
|
+
address: string;
|
|
228
|
+
};
|
|
229
|
+
export type WalletConnectResponseDataType = {
|
|
230
|
+
address: string;
|
|
231
|
+
};
|
|
232
|
+
export type WalletRecoverResponseDataType = {
|
|
233
|
+
address: string;
|
|
234
|
+
};
|
|
235
|
+
export type WalletSetRecoveryResponseDataType = {
|
|
236
|
+
address: string;
|
|
237
|
+
};
|
|
238
|
+
export type WalletRpcResponseDataType = {
|
|
239
|
+
address: string;
|
|
240
|
+
response: RpcResponseType;
|
|
241
|
+
};
|
|
242
|
+
export type SolanaWalletCreateResponseDataType = {
|
|
243
|
+
publicKey: string;
|
|
244
|
+
};
|
|
245
|
+
export type SolanaWalletConnectResponseDataType = {
|
|
246
|
+
publicKey: string;
|
|
247
|
+
};
|
|
248
|
+
export type SolanaWalletRecoverResponseDataType = {
|
|
249
|
+
publicKey: string;
|
|
250
|
+
};
|
|
251
|
+
export type SolanaWalletSetRecoveryPasswordResponseDataType = {
|
|
252
|
+
publicKey: string;
|
|
253
|
+
};
|
|
254
|
+
export type SolanaWalletRpcResponseDataType = {
|
|
255
|
+
publicKey: string;
|
|
256
|
+
response: SolanaRpcResponseType;
|
|
257
|
+
};
|
|
258
|
+
export type PrivyResponseDataType = IframeReadyResponseDataType | WalletCreateResponseDataType | WalletConnectResponseDataType | WalletRecoverResponseDataType | WalletSetRecoveryResponseDataType | WalletRpcResponseDataType | SolanaWalletCreateResponseDataType | SolanaWalletConnectResponseDataType | SolanaWalletRecoverResponseDataType | SolanaWalletRpcResponseDataType;
|
|
259
|
+
export declare const PrivyIframeErrorTypes: readonly ["error", "invalid_request_arguments", "wallet_not_on_device", "invalid_recovery_pin", "insufficient_funds"];
|
|
260
|
+
export type PrivyIframeErrorTypesType = (typeof PrivyIframeErrorTypes)[number];
|
|
261
|
+
interface PrivyResponseBaseEventType {
|
|
262
|
+
id: string;
|
|
263
|
+
event: PrivyEventType;
|
|
264
|
+
}
|
|
265
|
+
export interface PrivyErrorResponseEventType extends PrivyResponseBaseEventType {
|
|
266
|
+
error: {
|
|
267
|
+
type: PrivyIframeErrorTypesType;
|
|
268
|
+
message: string;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
interface IframeReadyResponseEventType extends PrivyResponseBaseEventType {
|
|
272
|
+
event: 'privy:iframe:ready';
|
|
273
|
+
data: IframeReadyResponseDataType;
|
|
274
|
+
}
|
|
275
|
+
interface WalletCreateResponseEventType extends PrivyResponseBaseEventType {
|
|
276
|
+
event: 'privy:wallet:create';
|
|
277
|
+
data: WalletCreateResponseDataType;
|
|
278
|
+
}
|
|
279
|
+
interface WalletConnectResponseEventType extends PrivyResponseBaseEventType {
|
|
280
|
+
event: 'privy:wallet:connect';
|
|
281
|
+
data: WalletConnectResponseDataType;
|
|
282
|
+
}
|
|
283
|
+
interface WalletRecoverResponseEventType extends PrivyResponseBaseEventType {
|
|
284
|
+
event: 'privy:wallet:recover';
|
|
285
|
+
data: WalletRecoverResponseDataType;
|
|
286
|
+
}
|
|
287
|
+
interface WalletSetRecoveryResponseEventType extends PrivyResponseBaseEventType {
|
|
288
|
+
event: 'privy:wallet:set-recovery';
|
|
289
|
+
data: WalletSetRecoveryResponseDataType;
|
|
290
|
+
}
|
|
291
|
+
interface WalletRpcResponseEventType extends PrivyResponseBaseEventType {
|
|
292
|
+
event: 'privy:wallet:rpc';
|
|
293
|
+
data: WalletRpcResponseDataType;
|
|
294
|
+
}
|
|
295
|
+
interface SolanaWalletCreateResponseEventType extends PrivyResponseBaseEventType {
|
|
296
|
+
event: 'privy:solana-wallet:create';
|
|
297
|
+
data: SolanaWalletCreateResponseDataType;
|
|
298
|
+
}
|
|
299
|
+
interface SolanaWalletConnectResponseEventType extends PrivyResponseBaseEventType {
|
|
300
|
+
event: 'privy:solana-wallet:connect';
|
|
301
|
+
data: SolanaWalletConnectResponseDataType;
|
|
302
|
+
}
|
|
303
|
+
interface SolanaWalletRecoverResponseEventType extends PrivyResponseBaseEventType {
|
|
304
|
+
event: 'privy:solana-wallet:recover';
|
|
305
|
+
data: SolanaWalletRecoverResponseDataType;
|
|
306
|
+
}
|
|
307
|
+
interface SolanaWalletRpcResponseEventType extends PrivyResponseBaseEventType {
|
|
308
|
+
event: 'privy:solana-wallet:rpc';
|
|
309
|
+
data: SolanaWalletRpcResponseDataType;
|
|
310
|
+
}
|
|
311
|
+
export type PrivyResponseEvent = IframeReadyResponseEventType | PrivyErrorResponseEventType | WalletCreateResponseEventType | WalletConnectResponseEventType | WalletRecoverResponseEventType | WalletSetRecoveryResponseEventType | WalletRpcResponseEventType | SolanaWalletCreateResponseEventType | SolanaWalletConnectResponseEventType | SolanaWalletRecoverResponseEventType | SolanaWalletRpcResponseEventType;
|
|
312
|
+
export type IframeReadyResponseCallbacksType = {
|
|
313
|
+
reject: (error: Error) => void;
|
|
314
|
+
resolve: (res: IframeReadyResponseDataType) => void;
|
|
315
|
+
};
|
|
316
|
+
export type WalletCreateResponseCallbacksType = {
|
|
317
|
+
reject: (error: Error) => void;
|
|
318
|
+
resolve: (res: WalletCreateResponseDataType) => void;
|
|
319
|
+
};
|
|
320
|
+
export type WalletConnectResponseCallbacksType = {
|
|
321
|
+
reject: (error: Error) => void;
|
|
322
|
+
resolve: (res: WalletConnectResponseDataType) => void;
|
|
323
|
+
};
|
|
324
|
+
export type WalletRecoverResponseCallbacksType = {
|
|
325
|
+
reject: (error: Error) => void;
|
|
326
|
+
resolve: (res: WalletRecoverResponseDataType) => void;
|
|
327
|
+
};
|
|
328
|
+
export type WalletSetRecoveryResponseCallbacksType = {
|
|
329
|
+
reject: (error: Error) => void;
|
|
330
|
+
resolve: (res: WalletSetRecoveryResponseDataType) => void;
|
|
331
|
+
};
|
|
332
|
+
export type WalletRpcResponseCallbacksType = {
|
|
333
|
+
reject: (error: Error) => void;
|
|
334
|
+
resolve: (res: WalletRpcResponseDataType) => void;
|
|
335
|
+
};
|
|
336
|
+
export type SolanaWalletCreateResponseCallbacksType = {
|
|
337
|
+
reject: (error: Error) => void;
|
|
338
|
+
resolve: (res: SolanaWalletCreateResponseDataType) => void;
|
|
339
|
+
};
|
|
340
|
+
export type SolanaWalletConnectResponseCallbacksType = {
|
|
341
|
+
reject: (error: Error) => void;
|
|
342
|
+
resolve: (res: SolanaWalletConnectResponseDataType) => void;
|
|
343
|
+
};
|
|
344
|
+
export type SolanaWalletRecoverResponseCallbacksType = {
|
|
345
|
+
reject: (error: Error) => void;
|
|
346
|
+
resolve: (res: SolanaWalletRecoverResponseDataType) => void;
|
|
347
|
+
};
|
|
348
|
+
export type SolanaWalletRpcResponseCallbacksType = {
|
|
349
|
+
reject: (error: Error) => void;
|
|
350
|
+
resolve: (res: SolanaWalletRpcResponseDataType) => void;
|
|
351
|
+
};
|
|
352
|
+
export type PrivyResponseCallbacksType = IframeReadyResponseCallbacksType | WalletCreateResponseCallbacksType | WalletConnectResponseCallbacksType | WalletRecoverResponseCallbacksType | WalletSetRecoveryResponseCallbacksType | WalletRpcResponseCallbacksType | SolanaWalletCreateResponseCallbacksType | SolanaWalletConnectResponseCallbacksType | SolanaWalletRecoverResponseCallbacksType | SolanaWalletRpcResponseCallbacksType;
|
|
353
|
+
export interface EmbeddedWalletProxy {
|
|
354
|
+
create: (data: WalletCreateRequestDataType) => Promise<WalletCreateResponseDataType>;
|
|
355
|
+
connect: (data: WalletConnectRequestDataType) => Promise<WalletConnectResponseDataType>;
|
|
356
|
+
recover: (data: WalletRecoverRequestDataType) => Promise<WalletRecoverResponseDataType>;
|
|
357
|
+
rpc: (data: WalletRpcRequestDataType) => Promise<WalletRpcResponseDataType>;
|
|
358
|
+
createSolana: (data: WalletCreateRequestDataType) => Promise<SolanaWalletCreateResponseDataType>;
|
|
359
|
+
connectSolana: (data: WalletConnectRequestDataType) => Promise<SolanaWalletConnectResponseDataType>;
|
|
360
|
+
recoverSolana: (data: WalletRecoverRequestDataType) => Promise<SolanaWalletRecoverResponseDataType>;
|
|
361
|
+
rpcSolana: (data: WalletRpcRequestDataType) => Promise<SolanaWalletRpcResponseDataType>;
|
|
362
|
+
}
|
|
363
|
+
export type EmbeddedWalletMessagePoster = {
|
|
364
|
+
postMessage: (message: any, targetOrigin: string, transfer?: Transferable) => void;
|
|
365
|
+
};
|
|
366
|
+
export type PreparedTransactionRequestEIP1559 = UnsignedTransactionRequest & {
|
|
367
|
+
from: string;
|
|
368
|
+
to: string;
|
|
369
|
+
nonce: Quantity;
|
|
370
|
+
chainId: number;
|
|
371
|
+
gasLimit: Quantity;
|
|
372
|
+
type: 2;
|
|
373
|
+
maxFeePerGas: Quantity;
|
|
374
|
+
};
|
|
375
|
+
export type PreparedTransactionRequestLegacy = UnsignedTransactionRequest & {
|
|
376
|
+
from: string;
|
|
377
|
+
to: string;
|
|
378
|
+
nonce: Quantity;
|
|
379
|
+
chainId: number;
|
|
380
|
+
gasLimit: Quantity;
|
|
381
|
+
type: 0 | 1;
|
|
382
|
+
gasPrice: Quantity;
|
|
383
|
+
};
|
|
384
|
+
export type PreparedTransactionRequest = PreparedTransactionRequestEIP1559 | PreparedTransactionRequestLegacy;
|
|
385
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BigNumberish } from '@ethersproject/bignumber';
|
|
2
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
3
|
+
import type { UnsignedTransaction as EthersUnsignedTransaction } from '@ethersproject/transactions';
|
|
4
|
+
import type { Quantity, UnsignedTransactionRequest } from '../types';
|
|
5
|
+
export declare const QuantityToBigNumber: (quantity: Quantity) => BigNumber;
|
|
6
|
+
export declare function convertBigNumberish(value: BigNumberish): string | number | bigint;
|
|
7
|
+
export declare function toEthersUnsignedTransaction(txRequest: UnsignedTransactionRequest): EthersUnsignedTransaction;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import type { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
3
|
+
import type { Quantity, UnsignedTransactionRequestWithChainId } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Defaults the gas parameters for a "generic chain" that we do not have special handling for. This is anything
|
|
6
|
+
* not in the Polygon, OP Stack, Arbitrum, or BSC families of chains.
|
|
7
|
+
*
|
|
8
|
+
* Pre-condition: `from`, `to`, `nonce`, and `gasLimit` are already set
|
|
9
|
+
*
|
|
10
|
+
* Post-conditions:
|
|
11
|
+
* - An undefined `type` gets defaulted to 2.
|
|
12
|
+
* - If the tx type is 2, we will default `maxFeePerGas` and `maxPriorityFeePerGas`.
|
|
13
|
+
* - If the tx type is 0, 1, we will default `gasPrice`.
|
|
14
|
+
*
|
|
15
|
+
* @param txRequest {UnsignedTransactionRequestWithChainId}
|
|
16
|
+
* @param provider {StaticJsonRpcProvider}
|
|
17
|
+
* @returns UnsignedTransactionRequestWithChainId with gas fees defaulted
|
|
18
|
+
*/
|
|
19
|
+
export declare const defaultGasForEvmChain: (txRequest: UnsignedTransactionRequestWithChainId, provider: StaticJsonRpcProvider) => Promise<UnsignedTransactionRequestWithChainId>;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate the total estimated gas cost from the transaction request. This method assumes
|
|
22
|
+
* the transaction has already been processed by Privy's `populateTransactionRequest` and that
|
|
23
|
+
* both a `gasLimit` and one of the `gasPrice` or `maxFeePerGas` have been set.
|
|
24
|
+
*
|
|
25
|
+
* If the transaction is on an OP Stack chain, this method will include the L1 execution fee in the returned
|
|
26
|
+
* `totalGasEstimate` and will also return the execution fee as a separate `l1ExecutionFeeEstimate`. For
|
|
27
|
+
* non-OP Stack chains, the `l1ExecutionFeeEstimate` will be 0.
|
|
28
|
+
*
|
|
29
|
+
* @param txRequest {UnsignedTransactionRequest} the transaction request for which to total estimated gas for
|
|
30
|
+
* @param provider {StaticJsonRpcProvider} ethers provider
|
|
31
|
+
* @returns the `totalGasEstimate` and `l1ExecutionFeeEstimate`
|
|
32
|
+
*/
|
|
33
|
+
export declare function calculateTotalGasEstimate(txRequest: UnsignedTransactionRequestWithChainId, provider: StaticJsonRpcProvider): Promise<{
|
|
34
|
+
totalGasEstimate: BigNumber;
|
|
35
|
+
l1ExecutionFeeEstimate: BigNumber;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Defaults the `gasLimit` for the transaction if not already set by calling the
|
|
39
|
+
* `eth_estimateGas` RPC for the network.
|
|
40
|
+
*
|
|
41
|
+
* @param txRequest {UnsignedTransactionRequestWithChainId}
|
|
42
|
+
* @param provider {StaticJsonRpcProvider}
|
|
43
|
+
* @returns `gasLimit` in gas units as a hexstring `Quantity`
|
|
44
|
+
*/
|
|
45
|
+
export declare function defaultGasLimit(txRequest: UnsignedTransactionRequestWithChainId, provider: StaticJsonRpcProvider): Promise<Quantity>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
2
|
+
import type { Chain, RpcConfig } from '../../chains';
|
|
3
|
+
import type { EmbeddedWalletRecoveryOptions, PreparedTransactionRequest, UnsignedTransactionRequest, UnsignedTransactionRequestWithChainId, IEmbeddedWalletRecoveryOptions } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Build a JSON RPC provider for a given chainId if it is one of our
|
|
6
|
+
* supported chains.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getJsonRpcProvider: (chainId: number, chains: Chain[], rpcConfig: RpcConfig, options: {
|
|
9
|
+
appId: string;
|
|
10
|
+
}) => StaticJsonRpcProvider;
|
|
11
|
+
export declare function validateTransactionRequest(txRequest: UnsignedTransactionRequest): void;
|
|
12
|
+
/**
|
|
13
|
+
* This method takes the `UnsignedTransactionRequestWithChainId` provided by the app
|
|
14
|
+
* and ensures that the following parameters are set, or at least defaulted by Privy;
|
|
15
|
+
* `from`, `chainId`, `nonce`, `gasLimit`, `type`, `gasPrice` OR `maxFeePerGas`.
|
|
16
|
+
* These values must be set before sending the transaction to the network.
|
|
17
|
+
*
|
|
18
|
+
* This method will NOT throw an error if the user does not have sufficient funds
|
|
19
|
+
* to cover gas costs - that must be explicitly checked elsewhere with `getAndCheckBalance`.
|
|
20
|
+
*
|
|
21
|
+
* @param address {string} wallet address sending the transaction
|
|
22
|
+
* @param txRequest {UnsignedTransactionRequestWithChainId} the transaction request from the app
|
|
23
|
+
* @param provider {StaticJsonRpcProvider} a provider connected to the chain of the transaction
|
|
24
|
+
* @returns {UnsignedTransactionRequestWithChainId} the transaction request with the necessary defaults set
|
|
25
|
+
*/
|
|
26
|
+
export declare function populateTransactionRequest(address: string, txRequest: UnsignedTransactionRequestWithChainId, provider: StaticJsonRpcProvider): Promise<PreparedTransactionRequest>;
|
|
27
|
+
/**
|
|
28
|
+
* Ensure that the recovery upgrade path is valid.
|
|
29
|
+
*
|
|
30
|
+
* @param currentRecoveryType The existing wallet's recovery type
|
|
31
|
+
* @param upgradeToRecoveryType The desired recovery type
|
|
32
|
+
*/
|
|
33
|
+
export declare function throwIfInvalidRecoveryUpgradePath({ currentRecoveryMethod, upgradeToRecoveryMethod, }: {
|
|
34
|
+
currentRecoveryMethod: EmbeddedWalletRecoveryOptions;
|
|
35
|
+
upgradeToRecoveryMethod: IEmbeddedWalletRecoveryOptions;
|
|
36
|
+
}): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Privy from './Privy';
|
|
2
|
+
export type { OAuthProviderType } from '@privy-io/public-api';
|
|
3
|
+
export type { default as Storage } from './storage/Storage';
|
|
4
|
+
export { LocalStorage } from './storage/LocalStorage';
|
|
5
|
+
export { InMemoryCache } from './storage/InMemoryStorage';
|
|
6
|
+
export { PrivyApiError, PrivyClientError } from './Error';
|
|
7
|
+
export { PrivyEmbeddedWalletErrorCode, errorIndicatesRecoveryIsNeeded, ProviderErrors, PrivyProviderRpcError, PrivyConnectorError, EmbeddedProviderError, } from './embedded/errors';
|
|
8
|
+
export { getUserEmbeddedWallet } from './utils/getUserEmbeddedWallet';
|
|
9
|
+
export { getUserEmbeddedSolanaWallet } from './utils/getUserEmbeddedSolanaWallet';
|
|
10
|
+
export { toObjectKeys } from './utils/toObjectKeys';
|
|
11
|
+
export { populateTransactionRequest, throwIfInvalidRecoveryUpgradePath } from './embedded/utils';
|
|
12
|
+
export { calculateTotalGasEstimate } from './embedded/utils/gas';
|
|
13
|
+
export { QuantityToBigNumber, convertBigNumberish, toEthersUnsignedTransaction, } from './embedded/utils/ethers';
|
|
14
|
+
export * from './types';
|
|
15
|
+
export * from './chains';
|
|
16
|
+
export default Privy;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** This module is a port of the PKCE implementation in react-auth */
|
|
2
|
+
import type { CryptoFns } from './crypto/types';
|
|
3
|
+
export declare const STATE_CODE_KEY = "privy:state_code";
|
|
4
|
+
export declare const CODE_VERIFIER_KEY = "privy:code_verifier";
|
|
5
|
+
/** Web compatible method to create a hash buffer, using SHA256 */
|
|
6
|
+
export declare function createHashBuffer(message: string, digest: NonNullable<CryptoFns['digest']>): Promise<Uint8Array>;
|
|
7
|
+
export declare function randomBytes(size: number): Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* Create a cryptographic random string to be used as the code_verifier in PKCE.
|
|
10
|
+
*
|
|
11
|
+
* @returns a cryptographic random string to be used as a code_verifier in PKCE
|
|
12
|
+
*/
|
|
13
|
+
export declare function createCodeVerifier(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Create a state code to be used in the OAuth flow. State code can be a random set of characers,
|
|
16
|
+
* or optionally can be used to store state information. In either case, it is used by the client to verify
|
|
17
|
+
* that it is communicating with the same server throughout the auth process.
|
|
18
|
+
*
|
|
19
|
+
* This same implementation also exists in the backend crypto module.
|
|
20
|
+
*
|
|
21
|
+
* @returns a valid state code to be used in PKCE flow
|
|
22
|
+
*/
|
|
23
|
+
export declare function createStateCode(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Derive the code_challenge from the code verifier, using the specified method.
|
|
26
|
+
*
|
|
27
|
+
* @param codeVerifier the code_challenge derived from the provided code verifier
|
|
28
|
+
*/
|
|
29
|
+
export declare function deriveCodeChallengeFromCodeVerifier({ codeVerifier, method, digest, }: {
|
|
30
|
+
codeVerifier: string;
|
|
31
|
+
method?: string;
|
|
32
|
+
digest?: CryptoFns['digest'];
|
|
33
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patch for AbortSignal.timeout since it is not supported in iOS Safari < 16
|
|
3
|
+
* Adapted from: https://github.com/mo/abortcontroller-polyfill/issues/73#issuecomment-1541180943
|
|
4
|
+
*/
|
|
5
|
+
declare const toAbortSignalTimeout: (duration: number) => AbortSignal;
|
|
6
|
+
export default toAbortSignalTimeout;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { EmbeddedWalletProvider, EmbeddedSolanaWalletProvider } from './embedded';
|
|
2
|
+
export type PrivyEmbeddedWalletProvider = EmbeddedWalletProvider;
|
|
3
|
+
export type PrivyEmbeddedSolanaWalletProvider = EmbeddedSolanaWalletProvider;
|
|
4
|
+
export type { EmbeddedWalletRecoveryOptions, SetRecoveryInput } from './embedded/types';
|
|
5
|
+
export type LogLevel = 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';
|
|
6
|
+
declare const EMBEDDED_WALLET_CLIENT_TYPES: readonly ["privy"];
|
|
7
|
+
export type EmbeddedWalletClientType = (typeof EMBEDDED_WALLET_CLIENT_TYPES)[number];
|
|
8
|
+
declare const INJECTED_WALLET_CLIENT_TYPES: readonly ["metamask", "phantom", "brave_wallet", "rainbow"];
|
|
9
|
+
export type InjectedWalletClientType = (typeof INJECTED_WALLET_CLIENT_TYPES)[number];
|
|
10
|
+
declare const COINBASE_WALLET_CLIENT_TYPES: readonly ["coinbase_wallet"];
|
|
11
|
+
export type CoinbaseWalletClientType = (typeof COINBASE_WALLET_CLIENT_TYPES)[number];
|
|
12
|
+
export type WalletConnectWalletClientType = (typeof WALLET_CONNECT_WALLET_CLIENT_TYPES)[number];
|
|
13
|
+
declare const UNKNOWN_WALLET_CLIENT_TYPES: readonly ["unknown"];
|
|
14
|
+
export type UnknownWalletClientType = (typeof UNKNOWN_WALLET_CLIENT_TYPES)[number];
|
|
15
|
+
export declare const ALL_WALLET_CLIENT_TYPES: ("unknown" | "safe" | "privy" | "metamask" | "phantom" | "brave_wallet" | "rainbow" | "coinbase_wallet" | "trust" | "uniswap" | "zerion" | "argent" | "spot" | "omni" | "cryptocom" | "blockchain" | "safepal" | "bitkeep" | "zengo" | "1inch" | "binance" | "exodus" | "mew_wallet" | "alphawallet" | "keyring_pro" | "mathwallet" | "unstoppable" | "obvious" | "ambire" | "internet_money_wallet" | "coin98" | "abc_wallet" | "arculus_wallet" | "haha" | "cling_wallet" | "broearn" | "copiosa" | "burrito_wallet" | "enjin_wallet" | "plasma_wallet" | "avacus" | "bee" | "pitaka" | "pltwallet" | "minerva" | "kryptogo" | "prema" | "slingshot" | "kriptonio" | "timeless" | "secux" | "bitizen" | "blocto" | "safemoon")[];
|
|
16
|
+
export type WalletClientType = InjectedWalletClientType | CoinbaseWalletClientType | WalletConnectWalletClientType | EmbeddedWalletClientType | UnknownWalletClientType;
|
|
17
|
+
export declare const SUPPORTED_CONNECTOR_TYPES: readonly ["injected", "wallet_connect", "wallet_connect_v2", "coinbase_wallet", "embedded"];
|
|
18
|
+
export type ConnectorType = (typeof SUPPORTED_CONNECTOR_TYPES)[number];
|
|
19
|
+
export type WalletBranding = {
|
|
20
|
+
/** The display name for the wallet. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Unique identifier for this wallet, can be RDNS or other unique data. */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Wallet brand icon url. */
|
|
25
|
+
icon?: string;
|
|
26
|
+
};
|
|
27
|
+
export type ExternalWalletMetadata = {
|
|
28
|
+
/** The wallet name (e.g. MetaMask). */
|
|
29
|
+
name: string;
|
|
30
|
+
/** The wallet RDNS, falls back to the wallet name if none is available. */
|
|
31
|
+
id: string;
|
|
32
|
+
/** The wallet logo */
|
|
33
|
+
icon?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Wallet to request a [Sign-In With Ethereum](https://eips.ethereum.org/EIPS/eip-4361) signature from
|
|
37
|
+
*/
|
|
38
|
+
export type ExternalWallet = {
|
|
39
|
+
/** [EIP-55](https://eips.ethereum.org/EIPS/eip-55) mixed-case checksum-encoded address */
|
|
40
|
+
address: string;
|
|
41
|
+
/** [EIP-155](https://eips.ethereum.org/EIPS/eip-155) Chain ID with [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md) formatting */
|
|
42
|
+
chainId: string;
|
|
43
|
+
/**
|
|
44
|
+
* The wallet client where this key-pair is stored.
|
|
45
|
+
* e.g. `metamask`, `rainbow`, `coinbase_wallet`, etc.
|
|
46
|
+
*/
|
|
47
|
+
walletClientType?: WalletClientType;
|
|
48
|
+
/**
|
|
49
|
+
* The connector used to initiate the connection with the wallet client.
|
|
50
|
+
* e.g. `injected`, `wallet_connect`, `coinbase_wallet`, etc.
|
|
51
|
+
*/
|
|
52
|
+
connectorType?: ConnectorType;
|
|
53
|
+
meta?: ExternalWalletMetadata;
|
|
54
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type NonEmptyArray<T> = [T, ...T[]];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PrivyUser, PrivySolanaEmbeddedWalletAccount } from '@privy-io/public-api';
|
|
2
|
+
/**
|
|
3
|
+
* @description Finds the embedded Solana wallet account (if it exists) for a given user.
|
|
4
|
+
*
|
|
5
|
+
* @param user A privy user object
|
|
6
|
+
*
|
|
7
|
+
* @returns The user's embedded wallet account
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const account = getUserEmbeddedSolanaWallet(user)
|
|
11
|
+
*/
|
|
12
|
+
export declare const getUserEmbeddedSolanaWallet: (user: PrivyUser | null) => PrivySolanaEmbeddedWalletAccount | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PrivyUser, PrivyEthereumEmbeddedWalletAccount } from '@privy-io/public-api';
|
|
2
|
+
/**
|
|
3
|
+
* @description Finds the embedded wallet account (if it exists) for a given user.
|
|
4
|
+
*
|
|
5
|
+
* @param user A privy user object
|
|
6
|
+
*
|
|
7
|
+
* @returns The user's embedded wallet account
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const account = getUserEmbeddedWallet(user)
|
|
11
|
+
* console.log(account.address)
|
|
12
|
+
*/
|
|
13
|
+
export declare const getUserEmbeddedWallet: (user: PrivyUser | null) => PrivyEthereumEmbeddedWalletAccount | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Logout as r}from"@privy-io/public-api";import t from"./CustomProviderApi.mjs";import i from"./EmailApi.mjs";import s from"./FarcasterApi.mjs";import e from"./GuestApi.mjs";import o from"./OAuthApi.mjs";import n from"./PasskeyApi.mjs";import a from"./PhoneApi.mjs";import p from"./SiweApi.mjs";import"./Error.mjs";import"./pkce.mjs";import"jose";class m{_privyInternal;customProvider;phone;email;oauth;siwe;passkey;farcaster;guest;constructor(r,m,l){this._privyInternal=r,this.customProvider=new t(this._privyInternal),this.phone=new a(this._privyInternal),this.email=new i(this._privyInternal),this.oauth=new o(this._privyInternal,m,l),this.guest=new e(this._privyInternal),this.siwe=new p(this._privyInternal),this.passkey=new n(this._privyInternal),this.farcaster=new s(this._privyInternal)}async logout(){try{const t=await this._privyInternal.session.getRefreshToken()??void 0;await this._privyInternal.fetch(r,{body:{refresh_token:t}})}catch(r){console.warn("Error destroying session")}await Promise.all([this._privyInternal.session.destroyLocalState({reason:"logout"}),this._privyInternal.destroyClientAnalyticsId()]),this._privyInternal.callbacks?.setUser?.(null)}}export{m as default};
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
import{CustomJWTAuthenticate as t}from"@privy-io/public-api";class s{_privyInternal;constructor(t){this._privyInternal=t}async syncWithToken(s){const n=await this._privyInternal.fetch(t,{body:{token:s}});return await this._privyInternal.session.updateWithTokensResponse(n),this._privyInternal.callbacks?.setUser?.(n.user),n}}export{s as default};
|
|
2
|
-
//# sourceMappingURL=CustomProviderApi.js.map
|