export { B as BAZAAR, a as BazaarClientExtension, b as BodyDiscoveryExtension, c as BodyDiscoveryInfo, D as DiscoveryExtension, d as DiscoveryInfo, e as DiscoveryResource, f as DiscoveryResourcesResponse, L as ListDiscoveryResourcesParams, Q as QueryDiscoveryExtension, g as QueryDiscoveryInfo, V as ValidationResult, W as WithExtensions, h as bazaarResourceServerExtension, i as declareDiscoveryExtension, j as extractDiscoveryInfo, k as extractDiscoveryInfoFromExtension, l as extractDiscoveryInfoV1, m as extractResourceMetadataV1, n as isDiscoverableV1, v as validateAndExtract, o as validateDiscoveryExtension, w as withBazaar } from './index-Mk5Ypp8M.js'; export { DeclareSIWxOptions, SIWX_EXTENSION_KEY, SIWX_HEADER_NAME, SIWxExtension, SIWxExtensionInfo, SIWxPayload, SIWxSigner, SIWxValidationResult, SIWxVerificationResult, SignatureScheme, ValidateSIWxOptions, VerifySIWxOptions, constructMessage, createSIWxMessage, createSIWxPayload, createSIWxTypedData, declareSIWxExtension, encodeSIWxHeader, hashMessage, parseSIWxHeader, signSIWxMessage, validateSIWxMessage, verifyEIP6492Signature, verifySIWxSignature } from './sign-in-with-x/index.js'; export { DeclarePaymentIdOptions, PAYMENT_ID_EXTENSION_KEY, PaymentIdExtension, PaymentIdExtensionInfo, PaymentIdPayload, createPaymentIdPayload, declarePaymentIdExtension, encodePaymentIdHeader, parsePaymentIdPayload, validatePaymentId } from './payment-id/index.js'; export { CreatePermitParams, DeclareEip2612GasSponsorOptions, EIP2612_GAS_SPONSOR_EXTENSION_KEY, EIP2612_GAS_SPONSOR_HEADER_NAME, Eip2612GasSponsorExtension, Eip2612GasSponsorExtensionInfo, Eip2612GasSponsorPayload, Eip2612GasSponsorValidationResult, PermitSigner, ValidateEip2612GasSponsorOptions, buildPermitCallData, createEip2612GasSponsorPayload, createPermitSignature, declareEip2612GasSponsorExtension, encodeEip2612GasSponsorHeader, extractEip2612GasSponsorPayload, parseEip2612GasSponsorHeader, validateAndExtractPermit, validateEip2612GasSponsorPayload } from './eip2612-gas-sponsoring/index.js'; export { APPROVE_FUNCTION_SELECTOR, CreateERC20ApprovalParams, DeclareERC20ApprovalGasSponsorOptions, ERC20ApprovalGasSponsorExtension, ERC20ApprovalGasSponsorExtensionInfo, ERC20ApprovalGasSponsorPayload, ERC20ApprovalGasSponsorValidationResult, ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY, ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME, ValidateERC20ApprovalGasSponsorOptions, createERC20ApprovalGasSponsorPayload, declareERC20ApprovalGasSponsorExtension, decodeApproveCalldata, encodeApproveCalldata, encodeERC20ApprovalGasSponsorHeader, extractERC20ApprovalGasSponsorPayload, parseERC20ApprovalGasSponsorHeader, processERC20ApprovalPayload, validateAndExtractApproval, validateERC20ApprovalGasSponsorPayload } from './erc20-approval-gas-sponsoring/index.js'; import { ResourceServerExtension } from '@t402/core/types'; import '@t402/core/http'; /** * Types for the Offer and Receipt extension. * * Offers: Server commits to payment terms (signed before payment). * Receipts: Server confirms transaction completion (signed after payment). */ /** Signature format for offers and receipts */ type SignatureFormat = "eip712" | "jws"; /** Canonical offer payload fields */ interface OfferPayload { /** Schema version (currently 1) */ version: number; /** URL of the paid resource */ resourceUrl: string; /** Payment scheme (e.g., "exact") */ scheme: string; /** CAIP-2 network identifier */ network: string; /** Token contract address */ asset: string; /** Recipient wallet address */ payTo: string; /** Required payment amount (string to preserve precision) */ amount: string; /** Unix timestamp expiration (0 if not set) */ validUntil?: number; } /** A signed offer (EIP-712 format) */ interface EIP712Offer { format: "eip712"; payload: OfferPayload; signature: string; acceptIndex?: number; } /** A signed offer (JWS format) */ interface JWSOffer { format: "jws"; signature: string; acceptIndex?: number; } /** A signed offer in either format */ type SignedOffer = EIP712Offer | JWSOffer; /** Canonical receipt payload fields */ interface ReceiptPayload { /** Schema version (currently 1) */ version: number; /** CAIP-2 network identifier */ network: string; /** URL of the paid resource */ resourceUrl: string; /** Payer identifier (wallet address) */ payer: string; /** Unix timestamp when issued (seconds) */ issuedAt: number; /** Blockchain transaction hash (empty string if not available) */ transaction?: string; } /** A signed receipt (EIP-712 format) */ interface EIP712Receipt { format: "eip712"; payload: ReceiptPayload; signature: string; } /** A signed receipt (JWS format) */ interface JWSReceipt { format: "jws"; signature: string; } /** A signed receipt in either format */ type SignedReceipt = EIP712Receipt | JWSReceipt; /** Extension data in the 402 response (payment requirements) */ interface OfferReceiptRequirementsExtension { info: { offers: SignedOffer[]; }; } /** Extension data in the success response */ interface OfferReceiptSettlementExtension { info: { receipt: SignedReceipt; }; } /** Signer for creating EIP-712 offers and receipts */ interface EIP712OfferReceiptSigner { /** Sign an offer payload, returning the EIP-712 signature */ signOffer(payload: OfferPayload): Promise; /** Sign a receipt payload, returning the EIP-712 signature */ signReceipt(payload: ReceiptPayload): Promise; /** Get the signer's address for verification */ getAddress(): string; } /** Verifier for checking EIP-712 signatures */ interface EIP712OfferReceiptVerifier { /** Verify an offer signature, returning the recovered signer address */ recoverOfferSigner(payload: OfferPayload, signature: string): Promise; /** Verify a receipt signature, returning the recovered signer address */ recoverReceiptSigner(payload: ReceiptPayload, signature: string): Promise; } /** * EIP-712 type definitions for Offer and Receipt signing. * * The chainId is fixed at 1 (Ethereum mainnet) for all signatures, * as EIP-712 serves as an off-chain format independent of actual payment networks. */ /** EIP-712 domain for offer signing */ declare const OFFER_DOMAIN: { readonly name: "t402 offer"; readonly version: "1"; readonly chainId: 1; }; /** EIP-712 domain for receipt signing */ declare const RECEIPT_DOMAIN: { readonly name: "t402 receipt"; readonly version: "1"; readonly chainId: 1; }; /** EIP-712 typed data types for Offer */ declare const OFFER_TYPES: { readonly Offer: readonly [{ readonly name: "version"; readonly type: "uint256"; }, { readonly name: "resourceUrl"; readonly type: "string"; }, { readonly name: "scheme"; readonly type: "string"; }, { readonly name: "network"; readonly type: "string"; }, { readonly name: "asset"; readonly type: "string"; }, { readonly name: "payTo"; readonly type: "string"; }, { readonly name: "amount"; readonly type: "string"; }, { readonly name: "validUntil"; readonly type: "uint256"; }]; }; /** EIP-712 typed data types for Receipt */ declare const RECEIPT_TYPES: { readonly Receipt: readonly [{ readonly name: "version"; readonly type: "uint256"; }, { readonly name: "network"; readonly type: "string"; }, { readonly name: "resourceUrl"; readonly type: "string"; }, { readonly name: "payer"; readonly type: "string"; }, { readonly name: "issuedAt"; readonly type: "uint256"; }, { readonly name: "transaction"; readonly type: "string"; }]; }; /** Primary type name for offers */ declare const OFFER_PRIMARY_TYPE: "Offer"; /** Primary type name for receipts */ declare const RECEIPT_PRIMARY_TYPE: "Receipt"; /** * Normalize an OfferPayload for EIP-712 signing. * Optional fields use 0 or "" when absent. */ declare function normalizeOfferForSigning(payload: { version: number; resourceUrl: string; scheme: string; network: string; asset: string; payTo: string; amount: string; validUntil?: number; }): Record; /** * Normalize a ReceiptPayload for EIP-712 signing. * Optional fields use "" when absent. */ declare function normalizeReceiptForSigning(payload: { version: number; network: string; resourceUrl: string; payer: string; issuedAt: number; transaction?: string; }): Record; /** * Offer and Receipt signing and verification logic. * * Supports EIP-712 format. JWS support can be added later. */ /** * Create a signed offer from payment requirements. */ declare function createSignedOffer(signer: EIP712OfferReceiptSigner, payload: OfferPayload, acceptIndex?: number): Promise; /** * Create a signed receipt after successful payment. */ declare function createSignedReceipt(signer: EIP712OfferReceiptSigner, payload: ReceiptPayload): Promise; /** * Verify an EIP-712 signed offer. * Returns the recovered signer address, or throws if invalid. */ declare function verifyOffer(verifier: EIP712OfferReceiptVerifier, offer: SignedOffer): Promise<{ valid: boolean; signer?: string; payload?: OfferPayload; }>; /** * Verify an EIP-712 signed receipt. * Returns the recovered signer address, or throws if invalid. */ declare function verifyReceipt(verifier: EIP712OfferReceiptVerifier, receipt: SignedReceipt): Promise<{ valid: boolean; signer?: string; payload?: ReceiptPayload; }>; /** * Match an offer to payment requirements by comparing key fields. */ declare function matchOfferToRequirements(offer: SignedOffer, requirements: { scheme: string; network: string; asset: string; payTo: string; amount: string; }): boolean; /** * Check if an offer has expired. */ declare function isOfferExpired(offer: SignedOffer, nowSeconds?: number): boolean; /** * Server-side offer-receipt extension. * * Signs offers when generating 402 responses and * signs receipts when payment succeeds. */ /** Extension key for offer-receipt */ declare const OFFER_RECEIPT_KEY = "offer-receipt"; /** * Configuration for the offer-receipt server extension. */ interface OfferReceiptServerConfig { /** EIP-712 signer for creating offers and receipts */ signer: EIP712OfferReceiptSigner; /** URL of the protected resource (used in offer/receipt payloads) */ resourceUrl: string; /** Optional: default validUntil offset in seconds (0 = no expiry) */ offerValiditySeconds?: number; } /** * Create signed offers from payment requirements (accepts array). * * Called by the server when generating a 402 response. * Each accepted payment method gets a corresponding signed offer. */ declare function createOffersFromRequirements(config: OfferReceiptServerConfig, accepts: Array<{ scheme: string; network: string; asset: string; payTo: string; amount: string; }>): Promise; /** * Create a signed receipt after successful payment. * * Called by the server after verifying and settling a payment. */ declare function createReceiptForPayment(config: OfferReceiptServerConfig, params: { network: string; payer: string; transaction?: string; }): Promise; /** * Resource server extension that attaches signed offers to 402 responses. * * Usage: * ```ts * const extension = offerReceiptServerExtension({ * signer: myEIP712Signer, * resourceUrl: "https://api.example.com/data", * offerValiditySeconds: 300, * }); * * server.registerExtension(extension); * ``` */ declare function offerReceiptServerExtension(_config: OfferReceiptServerConfig): ResourceServerExtension; /** * Client-side offer-receipt extension. * * Verifies offers before making payment and * extracts/stores receipts from success responses. */ /** * Extract offers from a 402 response's extensions. */ declare function extractOffers(extensions?: Record): SignedOffer[]; /** * Extract a receipt from a success response's extensions. */ declare function extractReceipt(extensions?: Record): SignedReceipt | null; /** * Find and verify the offer that matches specific payment requirements. * * Returns the verified offer if found and valid, null otherwise. */ declare function findAndVerifyOffer(verifier: EIP712OfferReceiptVerifier, offers: SignedOffer[], requirements: { scheme: string; network: string; asset: string; payTo: string; amount: string; }, options?: { /** Expected signer address (e.g., payTo). If set, verification checks this. */ expectedSigner?: string; /** Current time in seconds (for expiry check). Defaults to now. */ nowSeconds?: number; }): Promise<{ offer: SignedOffer; signer: string; payload: OfferPayload; } | null>; /** * Verify a receipt from a success response. * * Returns the verified receipt data if valid, null otherwise. */ declare function verifyReceiptFromResponse(verifier: EIP712OfferReceiptVerifier, extensions?: Record, options?: { /** Expected signer address. */ expectedSigner?: string; }): Promise<{ signer: string; payload: ReceiptPayload; } | null>; export { type EIP712Offer, type EIP712OfferReceiptSigner, type EIP712OfferReceiptVerifier, type EIP712Receipt, type JWSOffer, type JWSReceipt, OFFER_DOMAIN, OFFER_PRIMARY_TYPE, OFFER_RECEIPT_KEY, OFFER_TYPES, type OfferPayload, type OfferReceiptRequirementsExtension, type OfferReceiptServerConfig, type OfferReceiptSettlementExtension, RECEIPT_DOMAIN, RECEIPT_PRIMARY_TYPE, RECEIPT_TYPES, type ReceiptPayload, type SignatureFormat, type SignedOffer, type SignedReceipt, createOffersFromRequirements, createReceiptForPayment, createSignedOffer, createSignedReceipt, extractOffers, extractReceipt, findAndVerifyOffer, isOfferExpired, matchOfferToRequirements, normalizeOfferForSigning, normalizeReceiptForSigning, offerReceiptServerExtension, verifyOffer, verifyReceipt, verifyReceiptFromResponse };