UNPKG

eth-signature-verifier

Version:

Minimal Ethereum signature verifier supporting EIP-712, EIP-191, and eth_sign. No ethers.js or web3.js.

58 lines (57 loc) 2.05 kB
/** * EIP-712 Domain separator configuration * Used to prevent signature replay attacks across different domains */ export interface TypedDataDomain { /** Human-readable name of the signing domain */ name?: string; /** Current major version of the signing domain */ version?: string; /** Chain ID of the network */ chainId?: number; /** Address of the contract that will verify the signature */ verifyingContract?: string; /** Additional domain fields for future extensions */ salt?: string; } /** * Type definitions for EIP-712 structured data * Maps type names to their field definitions */ export interface TypedDataField { name: string; type: string; } export type TypedDataTypes = Record<string, TypedDataField[]>; /** * Parameters for message signature verification */ export interface VerifyMessageParams { /** Ethereum address that should have signed the message */ address: string; /** Original message that was signed */ message: string; /** Signature to verify (0x-prefixed hex string) */ signature: string; } /** * Parameters for EIP-712 typed data signature verification */ export interface VerifyTypedDataParams { /** Ethereum address that should have signed the data */ address: string; /** Signature to verify (0x-prefixed hex string) */ signature: string; /** Domain separator configuration */ domain: TypedDataDomain; /** Type definitions for the structured data */ types: TypedDataTypes; /** The actual data that was signed */ value: Record<string, any>; } import type { TypedDataDomain as EthersTypedDataDomain, TypedDataField as EthersTypedDataField } from 'ethers'; import type { TypedData as ViemTypedData, TypedDataDomain as ViemTypedDataDomain } from 'viem'; export type EthersCompatibleDomain = EthersTypedDataDomain; export type EthersCompatibleTypes = Record<string, EthersTypedDataField[]>; export type ViemCompatibleDomain = ViemTypedDataDomain; export type ViemCompatibleTypes = ViemTypedData;