import { DerivationInfoAddressFormatEnum, ExternalKmsOrganization, ExternalKmsAuthenticator, GrantOrganizationAccessRequest, AddUserToOrganizationRequest, PartialKmsUser, DerivationInfoCurveEnum, Algorithm as Algorithm$1 } from '@phantom/openapi-wallet-service'; export { DerivationInfoAddressFormatEnum as AddressType, CreateAuthenticatorRequest, CreateOrganizationRequest, DeleteAuthenticatorRequest, ExternalKmsOrganization as Organization } from '@phantom/openapi-wallet-service'; import { SdkAnalyticsHeaders, NetworkId } from '@phantom/constants'; export { NetworkId } from '@phantom/constants'; import { Algorithm, Stamper } from '@phantom/sdk-types'; import { Logger } from '@phantom/utils'; export { Logger } from '@phantom/utils'; export { Keypair, generateKeyPair } from '@phantom/crypto'; interface PresignTransactionContext { networkId: string; walletId: string; } interface PhantomClientConfig { apiBaseUrl: string; organizationId?: string; headers?: Partial; walletType?: "server-wallet" | "user-wallet"; /** Optional dynamic headers provider used for flows backed by live auth state. */ getHeaders?: () => Record; /** Optional logger — when provided, replaces console.error inside PhantomClient */ logger?: Logger; } interface CreateWalletResult { walletId: string; addresses: { addressType: string; address: string; }[]; } type Transaction = string; interface SignedTransaction { rawTransaction: string; hash?: string; } interface SignedTransactionResult { rawTransaction: string; } interface GetWalletsResult { wallets: Wallet[]; totalCount: number; limit: number; offset: number; } interface Wallet { walletId: string; walletName: string; } interface WalletSigningParams { walletId: string; networkId: NetworkId; derivationIndex?: number; } interface SignUtf8MessageParams extends WalletSigningParams { message: string; } interface SignEthereumMessageParams extends WalletSigningParams { message: string; } type SignMessageParams = SignUtf8MessageParams; interface SignTypedDataParams { walletId: string; typedData: any; networkId: NetworkId; derivationIndex?: number; } interface SignTransactionParams { walletId: string; transaction: Transaction; networkId: NetworkId; derivationIndex?: number; account?: string; presignTransaction?: (transaction: string, context: PresignTransactionContext) => Promise; } interface SignAndSendTransactionParams { walletId: string; transaction: Transaction; networkId: NetworkId; derivationIndex?: number; account?: string; presignTransaction?: (transaction: string, context: PresignTransactionContext) => Promise; } interface GetWalletWithTagParams { organizationId: string; tag: string; derivationPaths: string[]; } interface CreateAuthenticatorParams { organizationId: string; username: string; authenticatorName: string; authenticator: AuthenticatorConfig; replaceExpirable?: boolean; } interface DeleteAuthenticatorParams { organizationId: string; username: string; authenticatorId: string; } type AuthenticatorConfig = { authenticatorKind: "keypair"; authenticatorName: string; publicKey: string; algorithm: Algorithm; expiresInMs?: number; } | { authenticatorKind: "passkey"; authenticatorName: string; publicKey: string; algorithm: Algorithm; expiresInMs?: number; } | { authenticatorKind: "oidc"; authenticatorName: string; jwksUrl: string; idTokenClaims: { sub: string; iss: string; }; expiresInMs?: number; }; interface UserConfig { username: string; role?: "ADMIN" | "USER"; authenticators: AuthenticatorConfig[]; } interface SpendingLimitConfig { usdCentsLimitPerDay: number; } interface PrepareResponse { transaction: string; simulationResult?: any; memoryConfigUsed?: SpendingLimitConfig; } type WalletServiceErrorType = "spending-limit-exceeded" | "transaction-blocked"; interface IWalletServiceError { type: WalletServiceErrorType; title: string; detail: string; requestId: string; } interface PrepareErrorResponse extends IWalletServiceError { previousSpendCents?: number; transactionSpendCents?: number; totalSpendCents?: number; limitCents?: number; scannerResult?: any; } type AddUserToOrganizationParams = Omit & { replaceExpirable?: boolean; user: PartialKmsUser & { traits: { appId: string; }; expiresInMs?: number; }; }; declare class PhantomClient { private config; private kmsApi; private axiosInstance; stamper?: Stamper; private logger?; constructor(config: PhantomClientConfig, stamper?: Stamper); setOrganizationId(organizationId: string): void; /** * Gets the authenticator public key from the stamper if available. * Returns undefined if the stamper doesn't support key info retrieval. * * OIDC/Auth2 stampers (device-code flow) are excluded: their P-256 key is * not a KMS Keypair authenticator — it is only used for OIDC stamp signing — * so sending it as authenticatorPublicKey would cause a 400 (wrong key size). */ private getAuthenticatorPublicKey; createWallet(walletName?: string): Promise; private prepare; private getTransactionForSigning; private getRpcMethodName; /** * Private method for shared signing logic */ private performTransactionSigning; /** * Sign a transaction */ signTransaction(params: SignTransactionParams): Promise; /** * Sign and send a transaction */ signAndSendTransaction(params: SignAndSendTransactionParams): Promise; getWalletAddresses(walletId: string, derivationPaths?: string[], derivationIndex?: number): Promise<{ addressType: DerivationInfoAddressFormatEnum; address: string; }[]>; /** * Sign an Ethereum message using EIP-191 personal sign */ ethereumSignMessage(params: SignEthereumMessageParams): Promise; /** * Sign a UTF-8 message for Solana */ signUtf8Message(params: SignUtf8MessageParams): Promise; /** * Sign EIP-712 typed data for Ethereum */ ethereumSignTypedData(params: SignTypedDataParams): Promise; getWallets(limit?: number, offset?: number): Promise; /** * Get organization details by organization ID */ getOrganization(organizationId: string): Promise; /** * Create a new organization with the specified name and users * @param name Organization name * @param users Array of users with their authenticators */ private validateNameLength; createOrganization(name: string, users: UserConfig[], tags?: string[]): Promise; /** * Create an authenticator for a user in an organization */ createAuthenticator(params: CreateAuthenticatorParams): Promise; /** * Delete an authenticator for a user in an organization */ deleteAuthenticator(params: DeleteAuthenticatorParams): Promise; grantOrganizationAccess(params: GrantOrganizationAccessRequest): Promise; /** * Add a new user to an organization */ addUserToOrganization(params: AddUserToOrganizationParams): Promise; /** * Get a wallet by tag from the specified organization */ getWalletWithTag(params: GetWalletWithTagParams): Promise; /** * Stamp an axios request with the provided stamper */ private stampRequest; /** * Wraps an error message while preserving the original axios response so callers can inspect HTTP status codes. */ private wrapAxiosError; } declare class WalletServiceError extends Error implements IWalletServiceError { type: WalletServiceErrorType; title: string; detail: string; requestId: string; constructor(data: IWalletServiceError, errorName: string); } declare function getAxiosErrorData(error: unknown): T | undefined; declare function getErrorMessage(error: unknown, fallbackMessage?: string): string; declare function isAuthenticationError(error: unknown): boolean; declare function parseWalletServiceError(data: PrepareErrorResponse | undefined): WalletServiceError | null; declare class SpendingLimitError extends WalletServiceError { previousSpendCents?: number; transactionSpendCents?: number; totalSpendCents?: number; limitCents?: number; constructor(data: PrepareErrorResponse); } declare class TransactionBlockedError extends WalletServiceError { scannerResult?: any; constructor(data: PrepareErrorResponse); } interface SubmissionConfig { chain: string; network: string; } /** * Derive SubmissionConfig from a CAIP-2 network ID * @param networkId - CAIP-2 compliant network ID (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp') * @returns SubmissionConfig if network supports transaction submission, undefined otherwise */ declare function deriveSubmissionConfig(networkId: string): SubmissionConfig | undefined; /** * Check if a network ID supports transaction submission * @param networkId - CAIP-2 compliant network ID * @returns true if the network supports transaction submission */ declare function supportsTransactionSubmission(networkId: string): boolean; /** * Get network description for a CAIP-2 network ID * @param networkId - CAIP-2 compliant network ID * @returns Network description or undefined if not found */ declare function getNetworkDescription(networkId: string): string | undefined; /** * List all supported CAIP-2 network IDs * @returns Array of supported network IDs */ declare function getSupportedNetworkIds(): string[]; /** * Get all networks for a specific chain * @param chain - Chain name (e.g., 'solana', 'ethereum') * @returns Array of network IDs for the specified chain */ declare function getNetworkIdsByChain(chain: string): string[]; declare function normalizeEvmTransactionForNetwork(transaction: unknown, networkId: string): string; /** * Default derivation paths for different blockchain networks with interpolated account index */ declare const DerivationPath: { readonly Solana: (accountIndex?: number) => string; readonly Ethereum: (accountIndex?: number) => string; readonly Bitcoin: (accountIndex?: number) => string; readonly Sui: (accountIndex?: number) => string; }; /** * Helper function to get derivation path based on network ID */ declare function getDerivationPathForNetwork(networkId: string, accountIndex?: number): string; /** * Network configuration */ interface NetworkConfig { derivationPath: string; curve: DerivationInfoCurveEnum; algorithm: Algorithm$1; addressFormat: DerivationInfoAddressFormatEnum; } /** * Get complete network configuration */ declare function getNetworkConfig(networkId: NetworkId, accountIndex?: number): NetworkConfig | null; export { AuthenticatorConfig, CreateAuthenticatorParams, CreateWalletResult, DeleteAuthenticatorParams, DerivationPath, GetWalletWithTagParams, GetWalletsResult, IWalletServiceError, NetworkConfig, PhantomClient, PhantomClientConfig, PrepareErrorResponse, PrepareResponse, PresignTransactionContext, SignAndSendTransactionParams, SignEthereumMessageParams, SignMessageParams, SignTransactionParams, SignTypedDataParams, SignUtf8MessageParams, SignedTransaction, SignedTransactionResult, SpendingLimitConfig, SpendingLimitError, Transaction, TransactionBlockedError, UserConfig, Wallet, WalletServiceError, WalletServiceErrorType, deriveSubmissionConfig, getAxiosErrorData, getDerivationPathForNetwork, getErrorMessage, getNetworkConfig, getNetworkDescription, getNetworkIdsByChain, getSupportedNetworkIds, isAuthenticationError, normalizeEvmTransactionForNetwork, parseWalletServiceError, supportsTransactionSubmission };