@privy-io/js-sdk-core 0.46.1 → 0.46.3
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/cjs/client/EmbeddedWalletApi.js +1 -1
- package/dist/cjs/client/Privy.js +1 -1
- package/dist/cjs/client/PrivyInternal.js +1 -1
- package/dist/cjs/client/funding/FundingApi.js +1 -1
- package/dist/cjs/client/funding/MoonpayOnRampApi.js +1 -1
- package/dist/cjs/embedded/EmbeddedWalletProvider.js +1 -1
- package/dist/cjs/embedded/gas/arbitrum.js +1 -1
- package/dist/cjs/embedded/gas/op-stack.js +1 -1
- package/dist/cjs/embedded/gas/polygon.js +1 -1
- package/dist/cjs/embedded/index.js +1 -1
- package/dist/cjs/embedded/polygonGasStation.js +1 -1
- package/dist/cjs/embedded/utils/gas.js +1 -1
- package/dist/cjs/embedded/utils/index.js +1 -1
- package/dist/cjs/funding/coinbase.js +1 -1
- package/dist/cjs/funding/moonpay.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils/getIsTokenUsdc.js +1 -1
- package/dist/cjs/wallet-api/create.js +1 -0
- package/dist/cjs/wallet-api/rpc.js +1 -0
- package/dist/dts/index.d.mts +43 -119
- package/dist/dts/index.d.ts +43 -119
- package/dist/esm/client/EmbeddedWalletApi.mjs +1 -1
- package/dist/esm/client/Privy.mjs +1 -1
- package/dist/esm/client/PrivyInternal.mjs +1 -1
- package/dist/esm/client/funding/FundingApi.mjs +1 -1
- package/dist/esm/client/funding/MoonpayOnRampApi.mjs +1 -1
- package/dist/esm/embedded/EmbeddedWalletProvider.mjs +1 -1
- package/dist/esm/embedded/gas/arbitrum.mjs +1 -1
- package/dist/esm/embedded/gas/op-stack.mjs +1 -1
- package/dist/esm/embedded/gas/polygon.mjs +1 -1
- package/dist/esm/embedded/index.mjs +1 -1
- package/dist/esm/embedded/polygonGasStation.mjs +1 -1
- package/dist/esm/embedded/utils/gas.mjs +1 -1
- package/dist/esm/embedded/utils/index.mjs +1 -1
- package/dist/esm/funding/coinbase.mjs +1 -1
- package/dist/esm/funding/moonpay.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils/getIsTokenUsdc.mjs +1 -1
- package/dist/esm/wallet-api/create.mjs +1 -0
- package/dist/esm/wallet-api/rpc.mjs +1 -0
- package/package.json +5 -3
- package/dist/cjs/chains/arbitrum.js +0 -1
- package/dist/cjs/chains/arbitrumGoerli.js +0 -1
- package/dist/cjs/chains/arbitrumSepolia.js +0 -1
- package/dist/cjs/chains/avalanche.js +0 -1
- package/dist/cjs/chains/avalancheFuji.js +0 -1
- package/dist/cjs/chains/base.js +0 -1
- package/dist/cjs/chains/baseGoerli.js +0 -1
- package/dist/cjs/chains/baseSepolia.js +0 -1
- package/dist/cjs/chains/berachainArtio.js +0 -1
- package/dist/cjs/chains/celo.js +0 -1
- package/dist/cjs/chains/celoAlfajores.js +0 -1
- package/dist/cjs/chains/filecoin.js +0 -1
- package/dist/cjs/chains/filecoinCalibration.js +0 -1
- package/dist/cjs/chains/garnetHolesky.js +0 -1
- package/dist/cjs/chains/goerli.js +0 -1
- package/dist/cjs/chains/holesky.js +0 -1
- package/dist/cjs/chains/index.js +0 -1
- package/dist/cjs/chains/linea.js +0 -1
- package/dist/cjs/chains/lineaTestnet.js +0 -1
- package/dist/cjs/chains/mainnet.js +0 -1
- package/dist/cjs/chains/optimism.js +0 -1
- package/dist/cjs/chains/optimismGoerli.js +0 -1
- package/dist/cjs/chains/optimismSepolia.js +0 -1
- package/dist/cjs/chains/polygon.js +0 -1
- package/dist/cjs/chains/polygonAmoy.js +0 -1
- package/dist/cjs/chains/polygonMumbai.js +0 -1
- package/dist/cjs/chains/redstone.js +0 -1
- package/dist/cjs/chains/redstoneHolesky.js +0 -1
- package/dist/cjs/chains/sepolia.js +0 -1
- package/dist/cjs/chains/types.js +0 -1
- package/dist/cjs/chains/zora.js +0 -1
- package/dist/cjs/chains/zoraSepolia.js +0 -1
- package/dist/cjs/chains/zoraTestnet.js +0 -1
- package/dist/esm/chains/arbitrum.mjs +0 -1
- package/dist/esm/chains/arbitrumGoerli.mjs +0 -1
- package/dist/esm/chains/arbitrumSepolia.mjs +0 -1
- package/dist/esm/chains/avalanche.mjs +0 -1
- package/dist/esm/chains/avalancheFuji.mjs +0 -1
- package/dist/esm/chains/base.mjs +0 -1
- package/dist/esm/chains/baseGoerli.mjs +0 -1
- package/dist/esm/chains/baseSepolia.mjs +0 -1
- package/dist/esm/chains/berachainArtio.mjs +0 -1
- package/dist/esm/chains/celo.mjs +0 -1
- package/dist/esm/chains/celoAlfajores.mjs +0 -1
- package/dist/esm/chains/filecoin.mjs +0 -1
- package/dist/esm/chains/filecoinCalibration.mjs +0 -1
- package/dist/esm/chains/garnetHolesky.mjs +0 -1
- package/dist/esm/chains/goerli.mjs +0 -1
- package/dist/esm/chains/holesky.mjs +0 -1
- package/dist/esm/chains/index.mjs +0 -1
- package/dist/esm/chains/linea.mjs +0 -1
- package/dist/esm/chains/lineaTestnet.mjs +0 -1
- package/dist/esm/chains/mainnet.mjs +0 -1
- package/dist/esm/chains/optimism.mjs +0 -1
- package/dist/esm/chains/optimismGoerli.mjs +0 -1
- package/dist/esm/chains/optimismSepolia.mjs +0 -1
- package/dist/esm/chains/polygon.mjs +0 -1
- package/dist/esm/chains/polygonAmoy.mjs +0 -1
- package/dist/esm/chains/polygonMumbai.mjs +0 -1
- package/dist/esm/chains/redstone.mjs +0 -1
- package/dist/esm/chains/redstoneHolesky.mjs +0 -1
- package/dist/esm/chains/sepolia.mjs +0 -1
- package/dist/esm/chains/types.mjs +0 -1
- package/dist/esm/chains/zora.mjs +0 -1
- package/dist/esm/chains/zoraSepolia.mjs +0 -1
- package/dist/esm/chains/zoraTestnet.mjs +0 -1
package/dist/dts/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Chain, RpcConfig } from '@privy-io/chains';
|
|
2
|
+
export * from '@privy-io/chains';
|
|
1
3
|
import * as _privy_io_public_api from '@privy-io/public-api';
|
|
2
|
-
import { PasskeyAuthenticateInputType, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput } from '@privy-io/public-api';
|
|
4
|
+
import { PasskeyAuthenticateInputType, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, Route, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput, WalletApiCreateResponseType, WalletApiCreateInputType, WalletApiRpcResponseType, WalletApiRpcInputType } from '@privy-io/public-api';
|
|
3
5
|
export { BICONOMY, COINBASE_SMART_WALLET, KERNEL, LIGHT_ACCOUNT, OAuthProviderType, SAFE, SmartWalletType, THIRDWEB } from '@privy-io/public-api';
|
|
4
6
|
import EventEmitter from 'eventemitter3';
|
|
5
7
|
import { PrivyErrorCode } from '@privy-io/api-base';
|
|
@@ -14,65 +16,6 @@ import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
|
|
|
14
16
|
import { UnsignedTransaction } from '@ethersproject/transactions';
|
|
15
17
|
import { Hex, TypedDataDefinition } from 'viem';
|
|
16
18
|
|
|
17
|
-
/**
|
|
18
|
-
* These types are fully compatible with WAGMI chain types, in case
|
|
19
|
-
* we need interop in the future.
|
|
20
|
-
*/
|
|
21
|
-
type RpcUrls = {
|
|
22
|
-
http: readonly string[];
|
|
23
|
-
webSocket?: readonly string[];
|
|
24
|
-
};
|
|
25
|
-
type NativeCurrency = {
|
|
26
|
-
name: string;
|
|
27
|
-
/** 2-6 characters long */
|
|
28
|
-
symbol: string;
|
|
29
|
-
decimals: number;
|
|
30
|
-
};
|
|
31
|
-
type BlockExplorer = {
|
|
32
|
-
name: string;
|
|
33
|
-
url: string;
|
|
34
|
-
};
|
|
35
|
-
type Unit = 'ether' | 'gwei' | 'wei' | number;
|
|
36
|
-
/** A subset of WAGMI's chain type
|
|
37
|
-
* https://github.com/wagmi-dev/references/blob/6aea7ee9c65cfac24f33173ab3c98176b8366f05/packages/chains/src/types.ts#L8
|
|
38
|
-
*/
|
|
39
|
-
type Chain = {
|
|
40
|
-
/** Id in number form */
|
|
41
|
-
id: number;
|
|
42
|
-
/** Human readable name */
|
|
43
|
-
name: string;
|
|
44
|
-
/** Internal network name */
|
|
45
|
-
network?: string;
|
|
46
|
-
/** Currency used by chain */
|
|
47
|
-
nativeCurrency: NativeCurrency;
|
|
48
|
-
/** Collection of block explorers */
|
|
49
|
-
blockExplorers?: {
|
|
50
|
-
[key: string]: BlockExplorer;
|
|
51
|
-
default: BlockExplorer;
|
|
52
|
-
};
|
|
53
|
-
/** Collection of RPC endpoints */
|
|
54
|
-
rpcUrls: {
|
|
55
|
-
[key: string]: RpcUrls;
|
|
56
|
-
default: RpcUrls;
|
|
57
|
-
};
|
|
58
|
-
/** Flag for test networks */
|
|
59
|
-
testnet?: boolean;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* RPC overrides to support custom RPC URLs. Do not provide an RPC URL
|
|
63
|
-
* that can serve multiple networks. You should only provide RPC URLs that
|
|
64
|
-
* are specific to the network you'd like to override.
|
|
65
|
-
*/
|
|
66
|
-
type RpcConfig = {
|
|
67
|
-
/**
|
|
68
|
-
* Mapping of chainId to RPC URL. Overrides Privy default RPC URLs that are shared across projects. Set your own RPC URLs
|
|
69
|
-
* to avoid rate limits or other throughput bottlenecks.
|
|
70
|
-
*/
|
|
71
|
-
rpcUrls: {
|
|
72
|
-
[key: number]: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
19
|
declare enum PrivyEmbeddedWalletErrorCode {
|
|
77
20
|
MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
|
|
78
21
|
MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",
|
|
@@ -834,6 +777,7 @@ declare class AppApi {
|
|
|
834
777
|
wallet_connect_cloud_project_id: string | null;
|
|
835
778
|
custom_api_url: string | null;
|
|
836
779
|
embedded_wallet_config: {
|
|
780
|
+
mode: "legacy-embedded-wallets-only" | "user-controlled-server-wallets-only";
|
|
837
781
|
solana: {
|
|
838
782
|
create_on_login: "users-without-wallets" | "all-users" | "off";
|
|
839
783
|
};
|
|
@@ -908,41 +852,6 @@ declare class DelegatedWalletsApi {
|
|
|
908
852
|
revoke(): Promise<void>;
|
|
909
853
|
}
|
|
910
854
|
|
|
911
|
-
declare const chainDefs: {
|
|
912
|
-
readonly mainnet: Chain;
|
|
913
|
-
readonly goerli: Chain;
|
|
914
|
-
readonly sepolia: Chain;
|
|
915
|
-
readonly arbitrum: Chain;
|
|
916
|
-
readonly arbitrumGoerli: Chain;
|
|
917
|
-
readonly arbitrumSepolia: Chain;
|
|
918
|
-
readonly optimism: Chain;
|
|
919
|
-
readonly optimismGoerli: Chain;
|
|
920
|
-
readonly optimismSepolia: Chain;
|
|
921
|
-
readonly polygon: Chain;
|
|
922
|
-
readonly polygonMumbai: Chain;
|
|
923
|
-
readonly celo: Chain;
|
|
924
|
-
readonly celoAlfajores: Chain;
|
|
925
|
-
readonly filecoin: Chain;
|
|
926
|
-
readonly filecoinCalibration: Chain;
|
|
927
|
-
readonly base: Chain;
|
|
928
|
-
readonly baseGoerli: Chain;
|
|
929
|
-
readonly baseSepolia: Chain;
|
|
930
|
-
readonly linea: Chain;
|
|
931
|
-
readonly lineaTestnet: Chain;
|
|
932
|
-
readonly avalanche: Chain;
|
|
933
|
-
readonly avalancheFuji: Chain;
|
|
934
|
-
readonly holesky: Chain;
|
|
935
|
-
readonly redstone: Chain;
|
|
936
|
-
readonly garnetHolesky: Chain;
|
|
937
|
-
readonly redstoneHolesky: Chain;
|
|
938
|
-
readonly zora: Chain;
|
|
939
|
-
readonly zoraSepolia: Chain;
|
|
940
|
-
readonly zoraTestnet: Chain;
|
|
941
|
-
};
|
|
942
|
-
declare const DEFAULT_SUPPORTED_CHAINS: readonly [Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain];
|
|
943
|
-
declare const DEFAULT_SUPPORTED_CHAIN_IDS: Set<number>;
|
|
944
|
-
declare function getSupportedChainById(id: number): Chain | undefined;
|
|
945
|
-
|
|
946
855
|
type SignMessageRequestArguments = {
|
|
947
856
|
method: 'signMessage';
|
|
948
857
|
params: {
|
|
@@ -6796,29 +6705,6 @@ type PrivyOptions = {
|
|
|
6796
6705
|
* an unsupported network will throw an error.
|
|
6797
6706
|
*
|
|
6798
6707
|
* For embedded wallets, the wallet will automatically default to the first supplied `supportedChain`.
|
|
6799
|
-
*
|
|
6800
|
-
* Defaults to:
|
|
6801
|
-
* - mainnet
|
|
6802
|
-
* - goerli
|
|
6803
|
-
* - sepolia
|
|
6804
|
-
* - arbitrum
|
|
6805
|
-
* - arbitrumGoerli
|
|
6806
|
-
* - optimism
|
|
6807
|
-
* - optimismGoerli
|
|
6808
|
-
* - polygon
|
|
6809
|
-
* - polygonMumbai
|
|
6810
|
-
* - celo
|
|
6811
|
-
* - celoAlfajores
|
|
6812
|
-
* - filecoin
|
|
6813
|
-
* - filecoinCalibration
|
|
6814
|
-
* - base
|
|
6815
|
-
* - baseGoerli
|
|
6816
|
-
* - linea
|
|
6817
|
-
* - lineaTestnet
|
|
6818
|
-
* - avalanche
|
|
6819
|
-
* - avalancheFuji
|
|
6820
|
-
* - holesky
|
|
6821
|
-
* - redstoneHolesky
|
|
6822
6708
|
*/
|
|
6823
6709
|
supportedChains?: NonEmptyArray<Chain>;
|
|
6824
6710
|
};
|
|
@@ -6878,6 +6764,16 @@ declare class Privy {
|
|
|
6878
6764
|
setMessagePoster(poster: EmbeddedWalletMessagePoster): void;
|
|
6879
6765
|
getAccessToken(): Promise<string | null>;
|
|
6880
6766
|
getIdentityToken(): Promise<string | null>;
|
|
6767
|
+
getCompiledPath<const T extends Route<U, V>, const U, const V>(r: T, opts: {
|
|
6768
|
+
body?: T['body'];
|
|
6769
|
+
params?: Record<string, string | number>;
|
|
6770
|
+
headers?: HeadersInit;
|
|
6771
|
+
}): Promise<string>;
|
|
6772
|
+
fetchPrivyRoute<const T extends Route<U, V>, const U, const V>(r: T, opts: {
|
|
6773
|
+
body?: T['body'];
|
|
6774
|
+
params?: Record<string, string | number>;
|
|
6775
|
+
headers?: HeadersInit;
|
|
6776
|
+
}): Promise<NonNullable<T['response']>>;
|
|
6881
6777
|
}
|
|
6882
6778
|
|
|
6883
6779
|
declare class LocalStorage implements Storage {
|
|
@@ -7897,4 +7793,32 @@ declare namespace index {
|
|
|
7897
7793
|
export { type index_LinkWithCrossAppAuthDependencies as LinkWithCrossAppAuthDependencies, type index_LinkWithCrossAppAuthInput as LinkWithCrossAppAuthInput, type index_LinkWithCrossAppAuthOutput as LinkWithCrossAppAuthOutput, type index_LoginWithCrossAppAuthDependencies as LoginWithCrossAppAuthDependencies, type index_LoginWithCrossAppAuthInput as LoginWithCrossAppAuthInput, type index_LoginWithCrossAppAuthOutput as LoginWithCrossAppAuthOutput, index_linkWithCrossAppAuth as linkWithCrossAppAuth, index_loginWithCrossAppAuth as loginWithCrossAppAuth, index$1 as wallet };
|
|
7898
7794
|
}
|
|
7899
7795
|
|
|
7900
|
-
|
|
7796
|
+
type Input$1 = {
|
|
7797
|
+
request: WalletApiCreateInputType & {
|
|
7798
|
+
owner_id: string;
|
|
7799
|
+
};
|
|
7800
|
+
};
|
|
7801
|
+
declare function create(
|
|
7802
|
+
/** A instance of the Privy client */
|
|
7803
|
+
client: Privy,
|
|
7804
|
+
/** Request input */
|
|
7805
|
+
{ request }: Input$1): Promise<WalletApiCreateResponseType>;
|
|
7806
|
+
|
|
7807
|
+
type Input = WalletApiRpcInputType & {
|
|
7808
|
+
wallet_id: string;
|
|
7809
|
+
};
|
|
7810
|
+
/**
|
|
7811
|
+
* TODO: docs for this. Privy Wallet API rpc request logic.
|
|
7812
|
+
*
|
|
7813
|
+
* @param client
|
|
7814
|
+
* @param sign
|
|
7815
|
+
* @param param2
|
|
7816
|
+
* @returns
|
|
7817
|
+
*/
|
|
7818
|
+
declare function rpc(client: Privy, sign: (o: {
|
|
7819
|
+
message: string;
|
|
7820
|
+
}) => Promise<{
|
|
7821
|
+
signature: string;
|
|
7822
|
+
}>, { wallet_id, ...request }: Input): Promise<WalletApiRpcResponseType>;
|
|
7823
|
+
|
|
7824
|
+
export { ALL_WALLET_CLIENT_TYPES, type Cluster, type CoinbaseAssetId, type CoinbaseWalletClientType, type ConnectorType, type CreateSiwsMessageOpts, type EIP1193Provider, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, type EmbeddedWalletClientType, type EmbeddedWalletConfig, type EmbeddedWalletRecoveryOptions, type EntropyIdVerifier, type ErrorMessageMap, type ExternalWallet, type ExternalWalletMetadata, type FundingMethod, type FundingProvider, InMemoryCache, type InjectedWalletClientType, LocalStorage, type LogLevel, type MfaMethod, type MfaPromise, type MfaSubmitArgs, type MfaSubmitPromise, MoonpayApiError, type MoonpayTransactionStatus, type MoonpayTransactionStatusResponse, type OnNeedsRecovery, type PaymentOption, type PreparedTransactionRequest, PrivyApiError, PrivyClientError, PrivyConnectorError, type PrivyEmbeddedSolanaWalletProvider, PrivyEmbeddedWalletErrorCode, type PrivyEmbeddedWalletProvider, PrivyProviderRpcError, ProviderErrors, type Quantity, QuantityToBigNumber, SUPPORTED_CONNECTOR_TYPES, type SetRecoveryInput, SolanaClient, type SolanaCluster, type Storage, type UnknownWalletClientType, type UnsignedTransactionRequest, type UnsignedTransactionRequestWithChainId, UsdcAddressMap, type WalletBranding, type WalletClientType, type WalletConnectWalletClientType, calculateTotalGasEstimate, chainToMoonpayCurrency, convertBigNumberish, countryCodesAndNumbers, create, createErrorFormatter, createSiwsMessage, index as crossApp, Privy as default, index$2 as delegatedActions, errorIndicatesMaxMfaRetries, errorIndicatesMfaCanceled, errorIndicatesMfaRateLimit, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, errorIndicatesRecoveryIsNeeded, formatLamportsAmount, formatPhoneNumber, formatTokenAmount, formatWalletAddress, formatWeiAmount, fundingMethodToMoonpayPaymentMethod, getAllUserEmbeddedBitcoinWallets, getAllUserEmbeddedEthereumWallets, getAllUserEmbeddedSolanaWallets, getCoinbaseOnRampUrl, getEntropyDetailsFromAccount, getEntropyDetailsFromUser, getIsTokenUsdc, getJsonRpcEndpointFromChain, getPhoneCountryCodeAndNumber, getPlaceholderPhoneNumber, getSolanaClusterDisplayName, getSolanaRpcEndpointForCluster, getSolanaUsdcMintAddressForCluster, getUserEmbeddedEthereumWallet, getUserEmbeddedSolanaWallet, getUserEmbeddedWallet, getUserSmartWallet, isSupportedChainIdForCoinbaseOnramp, isSupportedChainIdForMoonpay, lastFourDigits, phoneNumberTypingFormatter, populateTransactionRequest, rpc, throwIfInvalidRecoveryUpgradePath, toCoinbaseAssetId, toCoinbaseBlockchainFromChainId, toEthersUnsignedTransaction, toObjectKeys, validatePhoneNumber };
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Chain, RpcConfig } from '@privy-io/chains';
|
|
2
|
+
export * from '@privy-io/chains';
|
|
1
3
|
import * as _privy_io_public_api from '@privy-io/public-api';
|
|
2
|
-
import { PasskeyAuthenticateInputType, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput } from '@privy-io/public-api';
|
|
4
|
+
import { PasskeyAuthenticateInputType, PrivyEthereumEmbeddedWalletAccount, PrivySolanaEmbeddedWalletAccount, PrivyUser, PrivySmartWalletConfigurationResponse, PrivyAuthenticatedUser, OAuthProviderType, SmartWalletType, CoinbaseOnRampInitInput, PrivyMoonpayOnRampSignInput, MfaPasskeyInitInputType, MfaSmsInitInputType, Route, PrivyBitcoinSegwitEmbeddedWalletAccount as PrivyBitcoinSegwitEmbeddedWalletAccount$1, PrivyBitcoinTaprootEmbeddedWalletAccount as PrivyBitcoinTaprootEmbeddedWalletAccount$1, PrivySmartWalletAccount, PrivyCoinbaseOnRampInitResponse, PrivyCoinbaseOnRampInitInput, WalletApiCreateResponseType, WalletApiCreateInputType, WalletApiRpcResponseType, WalletApiRpcInputType } from '@privy-io/public-api';
|
|
3
5
|
export { BICONOMY, COINBASE_SMART_WALLET, KERNEL, LIGHT_ACCOUNT, OAuthProviderType, SAFE, SmartWalletType, THIRDWEB } from '@privy-io/public-api';
|
|
4
6
|
import EventEmitter from 'eventemitter3';
|
|
5
7
|
import { PrivyErrorCode } from '@privy-io/api-base';
|
|
@@ -14,65 +16,6 @@ import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
|
|
|
14
16
|
import { UnsignedTransaction } from '@ethersproject/transactions';
|
|
15
17
|
import { Hex, TypedDataDefinition } from 'viem';
|
|
16
18
|
|
|
17
|
-
/**
|
|
18
|
-
* These types are fully compatible with WAGMI chain types, in case
|
|
19
|
-
* we need interop in the future.
|
|
20
|
-
*/
|
|
21
|
-
type RpcUrls = {
|
|
22
|
-
http: readonly string[];
|
|
23
|
-
webSocket?: readonly string[];
|
|
24
|
-
};
|
|
25
|
-
type NativeCurrency = {
|
|
26
|
-
name: string;
|
|
27
|
-
/** 2-6 characters long */
|
|
28
|
-
symbol: string;
|
|
29
|
-
decimals: number;
|
|
30
|
-
};
|
|
31
|
-
type BlockExplorer = {
|
|
32
|
-
name: string;
|
|
33
|
-
url: string;
|
|
34
|
-
};
|
|
35
|
-
type Unit = 'ether' | 'gwei' | 'wei' | number;
|
|
36
|
-
/** A subset of WAGMI's chain type
|
|
37
|
-
* https://github.com/wagmi-dev/references/blob/6aea7ee9c65cfac24f33173ab3c98176b8366f05/packages/chains/src/types.ts#L8
|
|
38
|
-
*/
|
|
39
|
-
type Chain = {
|
|
40
|
-
/** Id in number form */
|
|
41
|
-
id: number;
|
|
42
|
-
/** Human readable name */
|
|
43
|
-
name: string;
|
|
44
|
-
/** Internal network name */
|
|
45
|
-
network?: string;
|
|
46
|
-
/** Currency used by chain */
|
|
47
|
-
nativeCurrency: NativeCurrency;
|
|
48
|
-
/** Collection of block explorers */
|
|
49
|
-
blockExplorers?: {
|
|
50
|
-
[key: string]: BlockExplorer;
|
|
51
|
-
default: BlockExplorer;
|
|
52
|
-
};
|
|
53
|
-
/** Collection of RPC endpoints */
|
|
54
|
-
rpcUrls: {
|
|
55
|
-
[key: string]: RpcUrls;
|
|
56
|
-
default: RpcUrls;
|
|
57
|
-
};
|
|
58
|
-
/** Flag for test networks */
|
|
59
|
-
testnet?: boolean;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* RPC overrides to support custom RPC URLs. Do not provide an RPC URL
|
|
63
|
-
* that can serve multiple networks. You should only provide RPC URLs that
|
|
64
|
-
* are specific to the network you'd like to override.
|
|
65
|
-
*/
|
|
66
|
-
type RpcConfig = {
|
|
67
|
-
/**
|
|
68
|
-
* Mapping of chainId to RPC URL. Overrides Privy default RPC URLs that are shared across projects. Set your own RPC URLs
|
|
69
|
-
* to avoid rate limits or other throughput bottlenecks.
|
|
70
|
-
*/
|
|
71
|
-
rpcUrls: {
|
|
72
|
-
[key: number]: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
19
|
declare enum PrivyEmbeddedWalletErrorCode {
|
|
77
20
|
MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
|
|
78
21
|
MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",
|
|
@@ -834,6 +777,7 @@ declare class AppApi {
|
|
|
834
777
|
wallet_connect_cloud_project_id: string | null;
|
|
835
778
|
custom_api_url: string | null;
|
|
836
779
|
embedded_wallet_config: {
|
|
780
|
+
mode: "legacy-embedded-wallets-only" | "user-controlled-server-wallets-only";
|
|
837
781
|
solana: {
|
|
838
782
|
create_on_login: "users-without-wallets" | "all-users" | "off";
|
|
839
783
|
};
|
|
@@ -908,41 +852,6 @@ declare class DelegatedWalletsApi {
|
|
|
908
852
|
revoke(): Promise<void>;
|
|
909
853
|
}
|
|
910
854
|
|
|
911
|
-
declare const chainDefs: {
|
|
912
|
-
readonly mainnet: Chain;
|
|
913
|
-
readonly goerli: Chain;
|
|
914
|
-
readonly sepolia: Chain;
|
|
915
|
-
readonly arbitrum: Chain;
|
|
916
|
-
readonly arbitrumGoerli: Chain;
|
|
917
|
-
readonly arbitrumSepolia: Chain;
|
|
918
|
-
readonly optimism: Chain;
|
|
919
|
-
readonly optimismGoerli: Chain;
|
|
920
|
-
readonly optimismSepolia: Chain;
|
|
921
|
-
readonly polygon: Chain;
|
|
922
|
-
readonly polygonMumbai: Chain;
|
|
923
|
-
readonly celo: Chain;
|
|
924
|
-
readonly celoAlfajores: Chain;
|
|
925
|
-
readonly filecoin: Chain;
|
|
926
|
-
readonly filecoinCalibration: Chain;
|
|
927
|
-
readonly base: Chain;
|
|
928
|
-
readonly baseGoerli: Chain;
|
|
929
|
-
readonly baseSepolia: Chain;
|
|
930
|
-
readonly linea: Chain;
|
|
931
|
-
readonly lineaTestnet: Chain;
|
|
932
|
-
readonly avalanche: Chain;
|
|
933
|
-
readonly avalancheFuji: Chain;
|
|
934
|
-
readonly holesky: Chain;
|
|
935
|
-
readonly redstone: Chain;
|
|
936
|
-
readonly garnetHolesky: Chain;
|
|
937
|
-
readonly redstoneHolesky: Chain;
|
|
938
|
-
readonly zora: Chain;
|
|
939
|
-
readonly zoraSepolia: Chain;
|
|
940
|
-
readonly zoraTestnet: Chain;
|
|
941
|
-
};
|
|
942
|
-
declare const DEFAULT_SUPPORTED_CHAINS: readonly [Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain, Chain];
|
|
943
|
-
declare const DEFAULT_SUPPORTED_CHAIN_IDS: Set<number>;
|
|
944
|
-
declare function getSupportedChainById(id: number): Chain | undefined;
|
|
945
|
-
|
|
946
855
|
type SignMessageRequestArguments = {
|
|
947
856
|
method: 'signMessage';
|
|
948
857
|
params: {
|
|
@@ -6796,29 +6705,6 @@ type PrivyOptions = {
|
|
|
6796
6705
|
* an unsupported network will throw an error.
|
|
6797
6706
|
*
|
|
6798
6707
|
* For embedded wallets, the wallet will automatically default to the first supplied `supportedChain`.
|
|
6799
|
-
*
|
|
6800
|
-
* Defaults to:
|
|
6801
|
-
* - mainnet
|
|
6802
|
-
* - goerli
|
|
6803
|
-
* - sepolia
|
|
6804
|
-
* - arbitrum
|
|
6805
|
-
* - arbitrumGoerli
|
|
6806
|
-
* - optimism
|
|
6807
|
-
* - optimismGoerli
|
|
6808
|
-
* - polygon
|
|
6809
|
-
* - polygonMumbai
|
|
6810
|
-
* - celo
|
|
6811
|
-
* - celoAlfajores
|
|
6812
|
-
* - filecoin
|
|
6813
|
-
* - filecoinCalibration
|
|
6814
|
-
* - base
|
|
6815
|
-
* - baseGoerli
|
|
6816
|
-
* - linea
|
|
6817
|
-
* - lineaTestnet
|
|
6818
|
-
* - avalanche
|
|
6819
|
-
* - avalancheFuji
|
|
6820
|
-
* - holesky
|
|
6821
|
-
* - redstoneHolesky
|
|
6822
6708
|
*/
|
|
6823
6709
|
supportedChains?: NonEmptyArray<Chain>;
|
|
6824
6710
|
};
|
|
@@ -6878,6 +6764,16 @@ declare class Privy {
|
|
|
6878
6764
|
setMessagePoster(poster: EmbeddedWalletMessagePoster): void;
|
|
6879
6765
|
getAccessToken(): Promise<string | null>;
|
|
6880
6766
|
getIdentityToken(): Promise<string | null>;
|
|
6767
|
+
getCompiledPath<const T extends Route<U, V>, const U, const V>(r: T, opts: {
|
|
6768
|
+
body?: T['body'];
|
|
6769
|
+
params?: Record<string, string | number>;
|
|
6770
|
+
headers?: HeadersInit;
|
|
6771
|
+
}): Promise<string>;
|
|
6772
|
+
fetchPrivyRoute<const T extends Route<U, V>, const U, const V>(r: T, opts: {
|
|
6773
|
+
body?: T['body'];
|
|
6774
|
+
params?: Record<string, string | number>;
|
|
6775
|
+
headers?: HeadersInit;
|
|
6776
|
+
}): Promise<NonNullable<T['response']>>;
|
|
6881
6777
|
}
|
|
6882
6778
|
|
|
6883
6779
|
declare class LocalStorage implements Storage {
|
|
@@ -7897,4 +7793,32 @@ declare namespace index {
|
|
|
7897
7793
|
export { type index_LinkWithCrossAppAuthDependencies as LinkWithCrossAppAuthDependencies, type index_LinkWithCrossAppAuthInput as LinkWithCrossAppAuthInput, type index_LinkWithCrossAppAuthOutput as LinkWithCrossAppAuthOutput, type index_LoginWithCrossAppAuthDependencies as LoginWithCrossAppAuthDependencies, type index_LoginWithCrossAppAuthInput as LoginWithCrossAppAuthInput, type index_LoginWithCrossAppAuthOutput as LoginWithCrossAppAuthOutput, index_linkWithCrossAppAuth as linkWithCrossAppAuth, index_loginWithCrossAppAuth as loginWithCrossAppAuth, index$1 as wallet };
|
|
7898
7794
|
}
|
|
7899
7795
|
|
|
7900
|
-
|
|
7796
|
+
type Input$1 = {
|
|
7797
|
+
request: WalletApiCreateInputType & {
|
|
7798
|
+
owner_id: string;
|
|
7799
|
+
};
|
|
7800
|
+
};
|
|
7801
|
+
declare function create(
|
|
7802
|
+
/** A instance of the Privy client */
|
|
7803
|
+
client: Privy,
|
|
7804
|
+
/** Request input */
|
|
7805
|
+
{ request }: Input$1): Promise<WalletApiCreateResponseType>;
|
|
7806
|
+
|
|
7807
|
+
type Input = WalletApiRpcInputType & {
|
|
7808
|
+
wallet_id: string;
|
|
7809
|
+
};
|
|
7810
|
+
/**
|
|
7811
|
+
* TODO: docs for this. Privy Wallet API rpc request logic.
|
|
7812
|
+
*
|
|
7813
|
+
* @param client
|
|
7814
|
+
* @param sign
|
|
7815
|
+
* @param param2
|
|
7816
|
+
* @returns
|
|
7817
|
+
*/
|
|
7818
|
+
declare function rpc(client: Privy, sign: (o: {
|
|
7819
|
+
message: string;
|
|
7820
|
+
}) => Promise<{
|
|
7821
|
+
signature: string;
|
|
7822
|
+
}>, { wallet_id, ...request }: Input): Promise<WalletApiRpcResponseType>;
|
|
7823
|
+
|
|
7824
|
+
export { ALL_WALLET_CLIENT_TYPES, type Cluster, type CoinbaseAssetId, type CoinbaseWalletClientType, type ConnectorType, type CreateSiwsMessageOpts, type EIP1193Provider, EmbeddedBitcoinWalletProvider, EmbeddedProviderError, type EmbeddedWalletClientType, type EmbeddedWalletConfig, type EmbeddedWalletRecoveryOptions, type EntropyIdVerifier, type ErrorMessageMap, type ExternalWallet, type ExternalWalletMetadata, type FundingMethod, type FundingProvider, InMemoryCache, type InjectedWalletClientType, LocalStorage, type LogLevel, type MfaMethod, type MfaPromise, type MfaSubmitArgs, type MfaSubmitPromise, MoonpayApiError, type MoonpayTransactionStatus, type MoonpayTransactionStatusResponse, type OnNeedsRecovery, type PaymentOption, type PreparedTransactionRequest, PrivyApiError, PrivyClientError, PrivyConnectorError, type PrivyEmbeddedSolanaWalletProvider, PrivyEmbeddedWalletErrorCode, type PrivyEmbeddedWalletProvider, PrivyProviderRpcError, ProviderErrors, type Quantity, QuantityToBigNumber, SUPPORTED_CONNECTOR_TYPES, type SetRecoveryInput, SolanaClient, type SolanaCluster, type Storage, type UnknownWalletClientType, type UnsignedTransactionRequest, type UnsignedTransactionRequestWithChainId, UsdcAddressMap, type WalletBranding, type WalletClientType, type WalletConnectWalletClientType, calculateTotalGasEstimate, chainToMoonpayCurrency, convertBigNumberish, countryCodesAndNumbers, create, createErrorFormatter, createSiwsMessage, index as crossApp, Privy as default, index$2 as delegatedActions, errorIndicatesMaxMfaRetries, errorIndicatesMfaCanceled, errorIndicatesMfaRateLimit, errorIndicatesMfaTimeout, errorIndicatesMfaVerificationFailed, errorIndicatesRecoveryIsNeeded, formatLamportsAmount, formatPhoneNumber, formatTokenAmount, formatWalletAddress, formatWeiAmount, fundingMethodToMoonpayPaymentMethod, getAllUserEmbeddedBitcoinWallets, getAllUserEmbeddedEthereumWallets, getAllUserEmbeddedSolanaWallets, getCoinbaseOnRampUrl, getEntropyDetailsFromAccount, getEntropyDetailsFromUser, getIsTokenUsdc, getJsonRpcEndpointFromChain, getPhoneCountryCodeAndNumber, getPlaceholderPhoneNumber, getSolanaClusterDisplayName, getSolanaRpcEndpointForCluster, getSolanaUsdcMintAddressForCluster, getUserEmbeddedEthereumWallet, getUserEmbeddedSolanaWallet, getUserEmbeddedWallet, getUserSmartWallet, isSupportedChainIdForCoinbaseOnramp, isSupportedChainIdForMoonpay, lastFourDigits, phoneNumberTypingFormatter, populateTransactionRequest, rpc, throwIfInvalidRecoveryUpgradePath, toCoinbaseAssetId, toCoinbaseBlockchainFromChainId, toEthersUnsignedTransaction, toObjectKeys, validatePhoneNumber };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PrivyClientError as e}from"../Error.mjs";import{DEFAULT_SUPPORTED_CHAINS as r}from"../chains/index.mjs";import{EmbeddedBitcoinWalletProvider as t}from"../embedded/EmbeddedBitcoinWalletProvider.mjs";import{errorIndicatesRecoveryIsNeeded as o}from"../embedded/errors.mjs";import{throwIfInvalidRecoveryUpgradePath as i}from"../embedded/utils/index.mjs";import{EmbeddedWalletProxy as s}from"../embedded/EmbeddedWalletProxy.mjs";import{EmbeddedWalletProvider as d}from"../embedded/EmbeddedWalletProvider.mjs";import{EmbeddedSolanaWalletProvider as a}from"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../chains/arbitrum.mjs";import"../chains/arbitrumGoerli.mjs";import"../chains/arbitrumSepolia.mjs";import"../chains/avalanche.mjs";import"../chains/avalancheFuji.mjs";import"../chains/base.mjs";import"../chains/baseGoerli.mjs";import"../chains/baseSepolia.mjs";import"../chains/berachainArtio.mjs";import"../chains/celo.mjs";import"../chains/celoAlfajores.mjs";import"../chains/filecoin.mjs";import"../chains/filecoinCalibration.mjs";import"../chains/garnetHolesky.mjs";import"../chains/goerli.mjs";import"../chains/holesky.mjs";import"../chains/linea.mjs";import"../chains/lineaTestnet.mjs";import"../chains/mainnet.mjs";import"../chains/optimism.mjs";import"../chains/optimismGoerli.mjs";import"../chains/optimismSepolia.mjs";import"../chains/polygon.mjs";import"../chains/polygonMumbai.mjs";import"../chains/redstone.mjs";import"../chains/redstoneHolesky.mjs";import"../chains/sepolia.mjs";import"../chains/zora.mjs";import"../chains/zoraSepolia.mjs";import"../chains/zoraTestnet.mjs";import"../embedded/types.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"../embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"../embedded/utils/ethers.mjs";import"../embedded/gas/bsc.mjs";import"../embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"../embedded/gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"../chains/polygonAmoy.mjs";import"../embedded/utils/gas.mjs";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"eventemitter3";import"../embedded/methods.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";class n{setMessagePoster(e){this._proxy=new s(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async add(r){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let t=await this._privyInternal.getAccessToken();if(!t)throw new e({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:t,...r});let{user:o}=await this._privyInternal.refreshSession();return{user:o}}async getBitcoinProvider({wallet:e,entropyId:r,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:s,recoverySecretOverride:d}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessToken())throw Error("User must be logged in to create an embedded wallet");return await this._load({entropyId:r,entropyIdVerifier:o,wallet:e,recoveryPassword:i,recoveryAccessToken:s,recoverySecretOverride:d}),new t({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:o})}async create({password:e,recoveryMethod:r,recoveryToken:t,recoveryKey:o,recoverySecretOverride:i,iCloudRecordNameOverride:s,solanaAccount:d,skipCallbacks:a}){let n;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(n=r||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===n&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let c=await this._privyInternal.getAccessToken();if(!c)throw Error("User must be logged in to create an embedded wallet");let{address:l}=await this._proxy.create({accessToken:c,recoveryMethod:n,recoveryKey:o,recoveryPassword:e,recoveryAccessToken:t,recoverySecretOverride:i,iCloudRecordNameOverride:s,solanaAddress:d?.address});if(!l)throw Error("Failed to create wallet");return await this._privyInternal.refreshSession(a)}async createSolana(r){if(!this._proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let t=await this._privyInternal.getAccessToken();if(!t)throw new e({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});r?.ethereumAccount&&await this.getProvider(r.ethereumAccount);let{publicKey:o}=await this._proxy.createSolana({accessToken:t,ethereumAddress:r?.ethereumAccount?.address});if(!o)throw new e({error:"Failed to create wallet",code:"embedded_wallet_creation_error"});return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:r,rootWallet:t}){if(!this._proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let o=await this._privyInternal.getAccessToken();if(!o)throw new e({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:o,delegatedWallets:r,rootWallet:t})}async getProvider(e,r,t,o,i){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._load({wallet:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:r,recoveryKey:i,recoveryAccessToken:t,recoverySecretOverride:o}),new d({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy})}async getEthereumProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:s,recoveryKey:a,onNeedsRecovery:n}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessToken())throw Error("User must be logged in to create an embedded wallet");return(!n||o||i||s||a)&&await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:o,recoveryAccessToken:i,recoverySecretOverride:s,recoveryKey:a}),new d({account:e,entropyId:r,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:n})}async getSolanaProvider(r,t,o,i,s,d,n){if(!this._proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return(!n||i||s||d)&&await this._load({wallet:r,entropyId:t,entropyIdVerifier:o,recoveryPassword:i,recoveryAccessToken:s,recoverySecretOverride:d}),new a({account:r,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:t,entropyIdVerifier:o})}async setRecovery(e){let{wallet:r,...t}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");i({currentRecoveryMethod:r.recovery_method,upgradeToRecoveryMethod:"icloud-native"===t.recoveryMethod?"icloud":t.recoveryMethod}),await this._load("solana"===r.chain_type?{wallet:r,entropyId:r.address,entropyIdVerifier:"solana-address-verifier"}:{wallet:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier"});let o=await this._privyInternal.getAccessToken();if(!o)throw Error("User must be logged in to interact with embedded wallets");let s=r.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:r.address,target_recovery_method:t.recoveryMethod,existing_recovery_method:s});try{let e;if("user-passcode"===t.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:t.password};else if("google-drive"===t.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:t.recoveryAccessToken};else if("icloud"===t.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:t.recoveryAccessToken};else if("icloud-native"===t.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:t.iCloudRecordNameOverride,recoverySecretOverride:t.recoverySecretOverride};else if("recovery-encryption-key"===t.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:t.recoveryKey};else{if("privy"!==t.recoveryMethod)throw Error(`Unknown recovery method: ${t.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:o,entropyId:r.address,entropyIdVerifier:"solana"===r.chain_type?"solana-address-verifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:r.address,target_recovery_method:t.recoveryMethod,existing_recovery_method:s});let{user:i}=await this._privyInternal.refreshSession();return{user:i,provider:"ethereum"!==r.chain_type?null:new d({account:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:r.address,recovery_method:r.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");this._proxy.reload()}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return console.error(e),!1}}async _load({entropyId:e,entropyIdVerifier:r,wallet:t,recoveryPassword:i,recoveryKey:s,recoveryAccessToken:d,recoverySecretOverride:a}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let n=await this._privyInternal.getAccessToken();if(!n)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:n,entropyId:e,entropyIdVerifier:r}),e}catch(c){if(o(c))try{if("privy"===t.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("user-passcode"===t.recovery_method&&i){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryPassword:i,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if(["google-drive","icloud"].includes(t.recovery_method)&&d){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryAccessToken:d,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("icloud"===t.recovery_method&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:"icloud-native"});let o=await this._proxy.recover({accessToken:n,recoverySecretOverride:a,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:"icloud-native"}),o.entropyId}if("recovery-encryption-key"===t.recovery_method&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryKey:s,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}}catch(r){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:r instanceof Error?r.message:`Unable to recover wallet: ${e}`}),r}throw c}}constructor(e,t,o,i,d){this._chains=Array.from(r),this._privyInternal=e,t&&(this._proxy=new s(t,d),i.setProxy(this._proxy));let a=o?.map((e=>e.rpcUrls.privyWalletOverride?e:r.find((r=>r.id===e.id))||e));a&&a.length&&(this._chains=a),this._mfa=i,this._mfaPromises=d}}export{n as default};
|
|
1
|
+
import{DEFAULT_SUPPORTED_CHAINS as e,dedupeSupportedChains as r}from"@privy-io/chains";import{PrivyClientError as t}from"../Error.mjs";import{EmbeddedBitcoinWalletProvider as o}from"../embedded/EmbeddedBitcoinWalletProvider.mjs";import{errorIndicatesRecoveryIsNeeded as d}from"../embedded/errors.mjs";import{throwIfInvalidRecoveryUpgradePath as i}from"../embedded/utils/index.mjs";import{EmbeddedWalletProxy as s}from"../embedded/EmbeddedWalletProxy.mjs";import{EmbeddedWalletProvider as a}from"../embedded/EmbeddedWalletProvider.mjs";import{EmbeddedSolanaWalletProvider as n}from"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../embedded/types.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"../embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"../embedded/utils/ethers.mjs";import"../embedded/gas/bsc.mjs";import"../embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"../embedded/gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"../embedded/utils/gas.mjs";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"eventemitter3";import"../embedded/methods.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";class c{setMessagePoster(e){this._proxy=new s(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async add(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let r=await this._privyInternal.getAccessToken();if(!r)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:r,...e});let{user:o}=await this._privyInternal.refreshSession();return{user:o}}async getBitcoinProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:d,recoveryAccessToken:i,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessToken())throw Error("User must be logged in to create an embedded wallet");return await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:d,recoveryAccessToken:i,recoverySecretOverride:s}),new o({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:t})}async create({password:e,recoveryMethod:r,recoveryToken:t,recoveryKey:o,recoverySecretOverride:d,iCloudRecordNameOverride:i,solanaAccount:s,skipCallbacks:a}){let n;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(n=r||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===n&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let c=await this._privyInternal.getAccessToken();if(!c)throw Error("User must be logged in to create an embedded wallet");let{address:y}=await this._proxy.create({accessToken:c,recoveryMethod:n,recoveryKey:o,recoveryPassword:e,recoveryAccessToken:t,recoverySecretOverride:d,iCloudRecordNameOverride:i,solanaAddress:s?.address});if(!y)throw Error("Failed to create wallet");return await this._privyInternal.refreshSession(a)}async createSolana(e){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let r=await this._privyInternal.getAccessToken();if(!r)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});e?.ethereumAccount&&await this.getProvider(e.ethereumAccount);let{publicKey:o}=await this._proxy.createSolana({accessToken:r,ethereumAddress:e?.ethereumAccount?.address});if(!o)throw new t({error:"Failed to create wallet",code:"embedded_wallet_creation_error"});return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:e,rootWallet:r}){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let o=await this._privyInternal.getAccessToken();if(!o)throw new t({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:o,delegatedWallets:e,rootWallet:r})}async getProvider(e,r,t,o,d){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._load({wallet:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:r,recoveryKey:d,recoveryAccessToken:t,recoverySecretOverride:o}),new a({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy})}async getEthereumProvider({wallet:e,entropyId:r,entropyIdVerifier:t,recoveryPassword:o,recoveryAccessToken:d,recoverySecretOverride:i,recoveryKey:s,onNeedsRecovery:n}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessToken())throw Error("User must be logged in to create an embedded wallet");return(!n||o||d||i||s)&&await this._load({entropyId:r,entropyIdVerifier:t,wallet:e,recoveryPassword:o,recoveryAccessToken:d,recoverySecretOverride:i,recoveryKey:s}),new a({account:e,entropyId:r,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:n})}async getSolanaProvider(e,r,o,d,i,s,a){if(!this._proxy)throw new t({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return(!a||d||i||s)&&await this._load({wallet:e,entropyId:r,entropyIdVerifier:o,recoveryPassword:d,recoveryAccessToken:i,recoverySecretOverride:s}),new n({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:r,entropyIdVerifier:o})}async setRecovery(e){let{wallet:r,...t}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");i({currentRecoveryMethod:r.recovery_method,upgradeToRecoveryMethod:"icloud-native"===t.recoveryMethod?"icloud":t.recoveryMethod}),await this._load("solana"===r.chain_type?{wallet:r,entropyId:r.address,entropyIdVerifier:"solana-address-verifier"}:{wallet:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier"});let o=await this._privyInternal.getAccessToken();if(!o)throw Error("User must be logged in to interact with embedded wallets");let d=r.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:r.address,target_recovery_method:t.recoveryMethod,existing_recovery_method:d});try{let e;if("user-passcode"===t.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:t.password};else if("google-drive"===t.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:t.recoveryAccessToken};else if("icloud"===t.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:t.recoveryAccessToken};else if("icloud-native"===t.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:t.iCloudRecordNameOverride,recoverySecretOverride:t.recoverySecretOverride};else if("recovery-encryption-key"===t.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:t.recoveryKey};else{if("privy"!==t.recoveryMethod)throw Error(`Unknown recovery method: ${t.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:o,entropyId:r.address,entropyIdVerifier:"solana"===r.chain_type?"solana-address-verifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:r.address,target_recovery_method:t.recoveryMethod,existing_recovery_method:d});let{user:i}=await this._privyInternal.refreshSession();return{user:i,provider:"ethereum"!==r.chain_type?null:new a({account:r,entropyId:r.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:r.address,recovery_method:r.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");this._proxy.reload()}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return console.error(e),!1}}async _load({entropyId:e,entropyIdVerifier:r,wallet:t,recoveryPassword:o,recoveryKey:i,recoveryAccessToken:s,recoverySecretOverride:a}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let n=await this._privyInternal.getAccessToken();if(!n)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:n,entropyId:e,entropyIdVerifier:r}),e}catch(c){if(d(c))try{if("privy"===t.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("user-passcode"===t.recovery_method&&o){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let d=await this._proxy.recover({accessToken:n,recoveryPassword:o,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),d.entropyId}if(["google-drive","icloud"].includes(t.recovery_method)&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryAccessToken:s,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}if("icloud"===t.recovery_method&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:"icloud-native"});let o=await this._proxy.recover({accessToken:n,recoverySecretOverride:a,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:"icloud-native"}),o.entropyId}if("recovery-encryption-key"===t.recovery_method&&i){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:t.address,recovery_method:t.recovery_method});let o=await this._proxy.recover({accessToken:n,recoveryKey:i,entropyId:e,entropyIdVerifier:r});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:t.address,recovery_method:t.recovery_method}),o.entropyId}}catch(r){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:r instanceof Error?r.message:`Unable to recover wallet: ${e}`}),r}throw c}}constructor(t,o,d,i,a){if(this._chains=Array.from(e),this._privyInternal=t,o&&(this._proxy=new s(o,a),i.setProxy(this._proxy)),d){let e=r(d);this._chains=e}this._mfa=i,this._mfaPromises=a}}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./AppApi.mjs";import
|
|
1
|
+
import e from"./AppApi.mjs";import t from"./CrossAppApi.mjs";import r from"./DelegatedWalletsApi.mjs";import i from"./EmbeddedWalletApi.mjs";import s from"./MfaPromises.mjs";import{PrivyInternal as m}from"./PrivyInternal.mjs";import o from"./UserApi.mjs";import p from"./auth/AuthApi.mjs";import a from"./funding/FundingApi.mjs";import d from"./mfa/MfaApi.mjs";import n from"./recovery/RecoveryApi.mjs";import"@privy-io/public-api";import"../Token.mjs";import"jose";import"@privy-io/chains";import"../Error.mjs";import"../embedded/EmbeddedBitcoinWalletProvider.mjs";import"../embedded/errors.mjs";import"../embedded/types.mjs";import"../embedded/utils/index.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"../embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"../embedded/utils/ethers.mjs";import"../embedded/gas/bsc.mjs";import"../embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"../embedded/gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"../embedded/utils/gas.mjs";import"../embedded/EmbeddedWalletProxy.mjs";import"../utils/sleep.mjs";import"../embedded/EventCallbackQueue.mjs";import"../embedded/withMfa.mjs";import"../embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"../embedded/methods.mjs";import"../embedded/EmbeddedSolanaWalletProvider.mjs";import"../solana/getWalletPublicKeyFromTransaction.mjs";import"../solana/isVersionedTransaction.mjs";import"uuid";import"@privy-io/api-base";import"../Session.mjs";import"js-cookie";import"../utils/allSettled.mjs";import"../toAbortSignalTimeout.mjs";import"../utils/toSearchParams.mjs";import"./auth/CustomProviderApi.mjs";import"./auth/maybeCreateWalletOnLogin.mjs";import"../utils/getUserEmbeddedEthereumWallet.mjs";import"../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../utils/getUserEmbeddedSolanaWallet.mjs";import"../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../utils/shouldCreateEmbeddedEthWallet.mjs";import"../utils/shouldCreateEmbeddedSolWallet.mjs";import"./auth/EmailApi.mjs";import"./auth/FarcasterApi.mjs";import"./auth/FarcasterV2Api.mjs";import"./auth/GuestApi.mjs";import"./auth/OAuthApi.mjs";import"../pkce.mjs";import"./auth/PasskeyApi.mjs";import"./auth/PhoneApi.mjs";import"./auth/SiweApi.mjs";import"./auth/SiwsApi.mjs";import"./auth/SmartWalletApi.mjs";import"./funding/CoinbaseOnRampApi.mjs";import"./funding/MoonpayOnRampApi.mjs";import"../funding/moonpay.mjs";import"./mfa/MfaPasskeyApi.mjs";import"./mfa/MfaSmsApi.mjs";import"./recovery/RecoveryICloudApi.mjs";import"./recovery/RecoveryOAuthApi.mjs";class l{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}async getCompiledPath(e,t){return this._privyInternal.getPath(e,t)}async fetchPrivyRoute(e,t){return this._privyInternal.fetch(e,t)}constructor({clientId:l,...h}){this._privyInternal=new m({...h,appClientId:l}),this.mfa=new d(this._privyInternal),this.mfaPromises=new s,this.embeddedWallet=new i(this._privyInternal,h.embeddedWalletMessagePoster,h.supportedChains,this.mfa,this.mfaPromises),this.user=new o(this._privyInternal),this.app=new e(this._privyInternal),this.auth=new p(this._privyInternal,this.embeddedWallet,h.storage,h.crypto),this.recovery=new n(this._privyInternal,h.storage,h.crypto),this.funding=new a(this._privyInternal),this.delegated=new r(this._privyInternal),this.crossApp=new t(this._privyInternal,h.storage)}}export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as n}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as d}from"../utils/toSearchParams.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this.createAnalyticsEvent("sdk_initialize",{})}}async fetch(e,{body:t,params:s,query:
|
|
1
|
+
import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as n}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as d}from"../utils/toSearchParams.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i(e.path,t)}${d(s)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let n=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),o=await a(n),c=await this._fetch(n,o),l=await c.json();if(c.status>299)throw new h(l);return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getToken(),s=new Headers(e.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-client",this._sdkVersion),t&&s.set("Authorization",`Bearer ${t}`),s.set("Content-Type","application/json"),s.set("Accept","application/json");let i=await this._getOrGenerateClientAnalyticsId();return i&&s.set("privy-ca-id",i),this.nativeAppIdentifier&&s.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:l(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(p);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){console.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){console.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(p,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){console.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(a,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return console.debug("Found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(s,r);try{return await r}finally{this._cache.delete(s)}}async _refreshSession(e,t){let i=await this.session.getToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.debug(`[privy:refresh] fetching: ${n.path}`);let s=await this.fetch(n,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=s.session_update_action;return this.debug(`[privy:refresh] response: ${i}`),t||this.callbacks?.setUser?.(s.user),"set"===i&&(await this.session.updateWithTokensResponse(s),this.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&s.token&&(await this.session.storeToken(s.token),this.debug("[privy:refresh] access token stored"),s.identity_token&&(this.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.debug("[privy:refresh] returning response"),s}catch(e){throw this.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof h&&e.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getToken();return t.token||this.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return console.error(e),!1}}debug(e){"DEBUG"===this._logLevel&&console.debug(e)}constructor(t){this._sdkVersion="js-sdk-core:0.46.3",this._cache=new Map,this._storage=t.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=t.baseUrl??"https://auth.privy.io",this.appId=t.appId,this.appClientId=t.appClientId,this._sdkVersion=t.sdkVersion??this._sdkVersion,this._logLevel=t.logLevel,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new c({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}}export{u as PrivyInternal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"./CoinbaseOnRampApi.mjs";import i from"./MoonpayOnRampApi.mjs";import"@privy-io/public-api";import"fetch-retry";import"../../Error.mjs";import"../../funding/moonpay.mjs";import"@privy-io/chains";class p{constructor(p){this.moonpay=new i(p),this.coinbase=new o(p)}}export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"fetch-retry";import{MoonpayOnRampSign as r}from"@privy-io/public-api";import{MoonpayApiError as a}from"../../Error.mjs";import{MoonpayEnvironments as
|
|
1
|
+
import t from"fetch-retry";import{MoonpayOnRampSign as r}from"@privy-io/public-api";import{MoonpayApiError as a}from"../../Error.mjs";import{MoonpayEnvironments as o}from"../../funding/moonpay.mjs";import"@privy-io/chains";let i=class{async sign(t){return await this._privyInternal.fetch(r,{body:t})}async getTransactionStatus({transactionId:r,useSandbox:i}){let{url:n,key:e}=o[i?"sandbox":"prod"],s=await t(fetch,{retries:3,retryDelay:500})(`${n}/transactions/ext/${r}?apiKey=${e}`);if(!s.ok)throw new a({error:`Failed to fetch transaction status for Transaction ${r}`,code:"failed_to_fetch_moonpay_transaction_status",response:s});let c=await s.json();return Array.isArray(c)?c.at(0):void 0}constructor(t){this._privyInternal=t}};export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"eventemitter3";import{PrivyClientError as t}from"../Error.mjs";import{EmbeddedProviderError as r,errorIndicatesRecoveryIsNeeded as
|
|
1
|
+
import e from"eventemitter3";import{PrivyClientError as t}from"../Error.mjs";import{EmbeddedProviderError as r,errorIndicatesRecoveryIsNeeded as a}from"./errors.mjs";import{isSupportedIframeRpcMethod as s}from"./methods.mjs";import{getJsonRpcProvider as i,populateTransactionRequest as n}from"./utils/index.mjs";import"./types.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"./gas/arbitrum.mjs";import"@ethersproject/bignumber";import"@privy-io/chains";import"./utils/ethers.mjs";import"./gas/bsc.mjs";import"./gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"./utils/gas.mjs";class o extends e{async request(e){if(s(e.method))return this.handleIFrameRpc(e);switch(e.method){case"eth_accounts":case"eth_requestAccounts":return this._account.address?[this._account.address]:[];case"eth_chainId":return`0x${this._chainId.toString(16)}`;case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":{let t=e.params?.[0];return this.handleSendTransaction(t)}case"eth_populateTransactionRequest":{let t=e.params?.[0];return this.handlePopulateTransaction(t)}default:return this.handleJsonRpc(e)}}ensureChainId(e){let t={chainId:this._chainId,...e};return this.internalSwitchEthereumChain(t.chainId),t}internalSwitchEthereumChain(e){e&&Number(e)!==this._chainId&&(this._chainId=Number(e),this._jsonRpcProvider=i(this._chainId,this._chains,{rpcUrls:[]},{appId:this._privyInternal.appId}),this.emit("chainChanged",e))}async handlePopulateTransaction(e){let t=this.ensureChainId(e);return n(this._account.address,t,this._jsonRpcProvider)}async handleSendTransaction(e){let t=this.ensureChainId(e),r=await n(this._account.address,t,this._jsonRpcProvider),a=await this.handleIFrameRpc({method:"eth_signTransaction",params:[r]});return await this.handleJsonRpc({method:"eth_sendRawTransaction",params:[a]})}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:`0x${this._chainId.toString(16)}`};this.internalSwitchEthereumChain(t.chainId);try{return await this._jsonRpcProvider.send("eth_estimateGas",[t])}catch(e){console.warn(`Gas estimation failed with error: ${e}. Retrying gas estimation by omitting the 'from' address`);try{return delete t.from,await this._jsonRpcProvider.send("eth_estimateGas",[t])}catch(t){throw console.warn(`Gas estimation failed with error: ${t} when omitting the 'from' address`),e}}}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new r(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new r(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.internalSwitchEthereumChain(t)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessToken();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address});try{await this._walletProxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(e){let r=a(e);if(r&&"privy"===this._account.recovery_method)await this._walletProxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!r||!this._onNeedsRecovery)throw e;{let e;await new Promise((async(t,r)=>{e=setTimeout(r,12e4),await(this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)}))})).finally((()=>clearTimeout(e)))}}}return(await this._walletProxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:"ethereum"})).response.data}catch(r){console.error(r);let a=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:a}),new t({code:"embedded_wallet_request_error",error:a})}}async handleJsonRpc(e){return this._jsonRpcProvider.send(e.method,e.params??[])}toJSON(){return`PrivyEIP1193Provider { address: '${this._account.address}', chainId: ${this._chainId}, request: [Function] }`}constructor({walletProxy:e,privyInternal:t,account:r,entropyId:a,entropyIdVerifier:s,chains:n,onNeedsRecovery:o,chainId:h=n[0].id}){super(),this._walletProxy=e,this._privyInternal=t,this._account=r,this._entropyId=a,this._entropyIdVerifier=s,this._chainId=h,this._chains=n,this._onNeedsRecovery=o,this._jsonRpcProvider=i(h,n,{rpcUrls:[]},{appId:this._privyInternal.appId})}}export{o as EmbeddedWalletProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BigNumber as r}from"@ethersproject/bignumber";import{arbitrum as
|
|
1
|
+
import{BigNumber as r}from"@ethersproject/bignumber";import{arbitrum as e,arbitrumSepolia as t}from"@privy-io/chains";import{convertBigNumberish as i}from"../utils/ethers.mjs";const a=r=>[e.id,t.id].includes(r),o=async(e,t)=>{if(!a(e.chainId))throw Error("Invalid chain ID for Arbitrum gas estimation.");if(void 0===e.type&&(e.type=2),e.maxFeePerGas)return e;try{let{lastBaseFeePerGas:a}=await t.getFeeData();if(a){let t=a.mul(r.from(120)).div(r.from(100));e.maxFeePerGas=i(t),e.maxPriorityFeePerGas=i(r.from(0))}}catch(r){throw Error(`Failed to set gas price for Arbitrum transaction: ${r}.`)}return e};export{o as defaultGasForArbitrum,a as isArbitrum};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BigNumber as e}from"@ethersproject/bignumber";import{Contract as r}from"@ethersproject/contracts";import{serialize as a}from"@ethersproject/transactions";import{base as
|
|
1
|
+
import{BigNumber as e}from"@ethersproject/bignumber";import{Contract as r}from"@ethersproject/contracts";import{serialize as a}from"@ethersproject/transactions";import{base as t,baseSepolia as i,optimism as o,optimismSepolia as s,zora as n,zoraTestnet as c,zoraSepolia as m}from"@privy-io/chains";import{convertBigNumberish as P,toEthersUnsignedTransaction as d}from"../utils/ethers.mjs";const l="0x420000000000000000000000000000000000000F",f=["function getL1Fee(bytes memory _data) external view returns (uint256)"],h=e=>[t.id,i.id,o.id,s.id,n.id,c.id,m.id,81457,168587773].includes(e),F=async(r,a)=>{if(!h(r.chainId))throw Error("Invalid chain ID for OP Stack gas estimation.");if(void 0===r.type&&(r.type=2),r.gasPrice&&(console.warn("`gasPrice` is not supported on this chain and will be ignored. Use `maxPriorityFeePerGas` and/or `maxFeePerGas` instead."),delete r.gasPrice),r.maxPriorityFeePerGas&&r.maxFeePerGas)return r;try{if(!r.maxPriorityFeePerGas){let e=await a.send("eth_maxPriorityFeePerGas",[]);r.maxPriorityFeePerGas=e}if(r.maxFeePerGas&&(console.warn("maxFeePerGas is specified without maxPriorityFeePerGas - this can result in hung transactions."),r.maxPriorityFeePerGas>=r.maxFeePerGas))throw Error("Overridden maxFeePerGas is less than or equal to the calculated maxPriorityFeePerGas. Please set both values or maxPriorityFeePerGas alone for correct gas estimation.");if(!r.maxFeePerGas){let{lastBaseFeePerGas:t}=await a.getFeeData();if(!t)throw Error("Unable to fetch baseFee for last block.");let i=e.from(t).mul(e.from(126)).div(e.from(100)).add(e.from(r.maxPriorityFeePerGas));r.maxFeePerGas=P(i)}}catch(e){throw Error(`Failed to set gas price for OP stack transaction: ${e}.`)}return r};async function x(t,i){if(!t.chainId||t.chainId&&!h(t.chainId))return e.from(0);let o=e.from(0);try{let e=new r("0x420000000000000000000000000000000000000F",f,i),s=d(t),n=a(s);o=await e.getL1Fee(n)}catch(e){}return o}export{f as OPTIMISM_STACK_GAS_PRICE_ORACLE_ABI,l as OPTIMISM_STACK_GAS_PRICE_ORACLE_ADDRESS,F as defaultGasForOpStack,x as estimateOpStackL1Gas,h as isOpStack};
|