export interface MerchantClientOptions { baseUrl?: string; fetch?: typeof globalThis.fetch }
export interface AgentApproval { schema: 'gregers.merchant-agent-approval.v1'; merchant: string; approval_hash_sha256: string; approved_identity: Record<string, unknown> }
export interface TrustReceipt { verdict: 'accept' | 'block' | 'reapproval_required'; receipt_hash_sha256: string; [key: string]: unknown }
export interface MandatePolicy { max_order_amount: string; assets: string[]; products: string[]; categories: string[]; human_confirmation_above: string; expires_at: string }
export interface OrderItem { product_id: string; category: string; quantity: number; unit_amount: string }
export interface OrderRequest { merchant_order_id: string; amount: string; asset: string; items: OrderItem[] }
export interface MandateReceipt { verdict: 'accept' | 'block' | 'human_confirmation_required'; receipt_hash_sha256: string; reason_codes: string[]; [key: string]: unknown }
export class MerchantApiError extends Error { status: number; body: unknown }
export class MerchantDecisionError extends Error { receipt: TrustReceipt | MandateReceipt }
export class MerchantClient {
  constructor(options?: MerchantClientOptions);
  contract(): Promise<Record<string, unknown>>;
  onboardAgent(input: {merchant: string; token_id?: number; presented_namespace?: string}): Promise<{approval: AgentApproval}>;
  checkRepeatOrder(approval: AgentApproval, scenario?: 'live' | 'tampered_website' | 'legitimate_reanchor'): Promise<{receipt: TrustReceipt}>;
  createAuthChallenge(approval: AgentApproval): Promise<{challenge: {challenge_id: string; message: string; expires_at: string}}>;
  verifyAuthChallenge(input: {challenge_id: string; signature: string; signature_encoding?: 'hex' | 'base64'; credential_index?: number; key_index?: number}): Promise<{auth_session: {session_id: string; expires_at: string}}>;
  createMandate(approval: AgentApproval, authSessionId: string, policy: MandatePolicy): Promise<{mandate: Record<string, unknown>}>;
  evaluateMandate(mandateId: string, order: OrderRequest, approval: AgentApproval): Promise<{receipt: MandateReceipt; continuity_receipt: TrustReceipt}>;
  revokeMandate(mandateId: string, approval: AgentApproval, authSessionId: string, reason?: string): Promise<{mandate: Record<string, unknown>}>;
  previewSubscription(url: string, events: string[]): Promise<{preview: Record<string, unknown>}>;
  checkoutGuard(input: {approval: AgentApproval; mandateId: string; order: OrderRequest}): Promise<{ok: true; continuity_receipt: TrustReceipt; mandate_receipt: MandateReceipt}>;
}
export function verifyWebhookSignature(rawBody: string | Uint8Array, timestamp: string, signatureHeader: string, secret: string, options?: {nowMs?: number; toleranceSeconds?: number; crypto?: Crypto}): Promise<boolean>;
