UNPKG

@turnkey/core

Version:

A core JavaScript web and React Native package for interfacing with Turnkey's infrastructure.

90 lines 4.02 kB
import { type WalletInterface, type TStamp, type TStamper, type WalletProvider, WalletInterfaceType } from "../__types__"; export declare class CrossPlatformWalletStamper implements TStamper { private readonly ctx; private activeInterfaceType?; /** * Constructs a CrossPlatformWalletStamper. * * - Validates that at least one wallet interface is provided. * - For each wallet interface, creates an internal `WalletStamper` bound to it. * - Ensures the stamper instance is always initialized in a usable state. * * @param wallets - A partial mapping of wallet interfaces by type. * @throws {Error} If no wallet interfaces are provided. */ constructor(wallets: Partial<Record<WalletInterfaceType, WalletInterface>>); /** * Stamps a payload using the specified wallet interface and provider. * * - Uses the explicitly provided interface and provider if given. * - Falls back to the default interface and stored provider otherwise. * * @param payload - The string payload to sign. * @param interfaceType - Optional wallet interface type (defaults to the active or first available). * @param provider - Optional provider (defaults to the one set via `setProvider`). * @returns A `TStamp` object containing the stamp header name and encoded value. * @throws {Error} If no provider is available for the selected interface. */ stamp(payload: string, interfaceType?: WalletInterfaceType, provider?: WalletProvider): Promise<TStamp>; /** * Retrieves the public key for the given provider. * * @param interfaceType - Optional wallet interface type (defaults to the active or first available). * @param provider - Wallet provider for which to fetch the public key. * @returns A promise resolving to the public key in hex format. */ getPublicKey(interfaceType: WalletInterfaceType | undefined, provider: WalletProvider): Promise<string>; /** * Sets the active provider for a given wallet interface. * * - The active provider is used as a fallback in `stamp` if none is passed explicitly. * * @param interfaceType - Wallet interface type. * @param provider - Provider instance to associate with the interface. */ setProvider(interfaceType: WalletInterfaceType, provider: WalletProvider): void; /** * Determines the default wallet interface to use when none is specified. * * - Preference order: Active provider > Ethereum > Solana > WalletConnect. * * @returns The default wallet interface type. * @throws {Error} If no wallet interfaces are initialized. */ private defaultInterface; /** * Retrieves the internal context for a given wallet interface. * * @param interfaceType - Wallet interface type. * @returns The context including wallet, stamper, and optional provider. * @throws {Error} If the interface is not initialized. */ private getCtx; } export declare class WalletStamper { private readonly wallet; /** * Constructs a WalletStamper bound to a single wallet interface. * * @param wallet - The wallet interface used for signing. */ constructor(wallet: WalletInterface); /** * Signs a payload and returns a standardized stamp header. * * - For Ethereum: * - Signs using EIP-191. * - Recovers and compresses the public key. * - Converts the signature into DER format. * - For Solana: * - Signs using Ed25519. * - Fetches the public key directly from the wallet. * * @param payload - The payload to sign. * @param provider - The wallet provider used for signing. * @returns A `TStamp` containing the header name and base64url-encoded JSON value. * @throws {Error} If signing or public key recovery fails. */ stamp(payload: string, provider: WalletProvider): Promise<TStamp>; } //# sourceMappingURL=stamper.d.ts.map