UNPKG

run402-mcp

Version:

MCP server for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.

94 lines • 3.72 kB
import type { PaymentRequirements } from "@x402/core/types"; import { type RequestBindingExtra } from "./binding.js"; import { type DecodedInvoice } from "./bolt11.js"; import { type LnbtcErrorReason } from "./constants.js"; /** * Throws an {@link LnbtcError} with the given reason. * * @param reason - Stable reason * @returns Never returns */ export declare function reject(reason: LnbtcErrorReason): never; /** * Validates the core requirement terms (step 2 of facilitator validation). * * @param req - Payment requirements * @param networks - Supported networks mapped to BOLT11 currency */ export declare function validateCoreTerms(req: PaymentRequirements, networks: Readonly<Record<string, string>>): void; /** * Validates the transfer method and payment flow of an `extra` object. * * @param extra - Requirements `extra` */ export declare function validateMethodAndFlow(extra: Record<string, unknown> | undefined): void; /** * Validates every requirement field a client or server checks before paying or * issuing: core terms, method, flow, and binding fields. * * @param req - Payment requirements * @param networks - Supported networks mapped to BOLT11 currency * @returns The validated binding fields */ export declare function validateRequirements(req: PaymentRequirements, networks: Readonly<Record<string, string>>): RequestBindingExtra; /** * Options for invoice validation. */ export interface InvoiceCheckOptions { /** Validation time, Unix seconds. */ now: number; /** Non-negative clock-skew allowance, seconds. */ skew: number; } /** * Strictly decodes an invoice and checks it against the requirements: the * facilitator's step 5, and the client and server pre-payment checks except * expiry (see {@link checkExpiry}). * * @param invoice - BOLT11 invoice text * @param req - Requirements whose terms the invoice must match * @param expectedRequestHash - The expected request hash, lowercase hex * @param networks - Supported networks mapped to BOLT11 currency * @param options - Time and expiry policy * @returns The decoded invoice */ export declare function validateInvoice(invoice: unknown, req: PaymentRequirements, expectedRequestHash: string, networks: Readonly<Record<string, string>>, options: InvoiceCheckOptions): DecodedInvoice; /** * Applies an expiry policy to a decoded invoice. * * @param invoice - Decoded invoice * @param options - Validation time and skew * @param policy - `unexpired`: the invoice must not have expired at `now` * (client, server). `settlement`: the paid-but-expired window, valid through * `invoice_end + skew` inclusive (facilitator). */ export declare function checkExpiry(invoice: DecodedInvoice, options: InvoiceCheckOptions, policy: "unexpired" | "settlement"): void; /** * Checks that a network is one of the configured networks (own keys only, so * names such as `constructor` never match). * * @param network - Candidate network * @param networks - Supported networks mapped to BOLT11 currency * @returns Whether the network is supported */ export declare function isSupportedNetwork(network: unknown, networks: Readonly<Record<string, string>>): network is string; /** * Validates a clock-skew allowance. * * @param skew - Seconds */ export declare function validateSkew(skew: number): void; /** * Checks for a lowercase compressed secp256k1 public key on the curve. * * @param value - Candidate * @returns Whether it is valid */ export declare function isCompressedPubkey(value: unknown): value is string; /** * Current Unix time in whole seconds. * * @returns Seconds since the epoch */ export declare function unixNow(): number; //# sourceMappingURL=validation.d.ts.map