import { J as JSONSchema, D as DiscoveryMetadata } from '../middleware-C2A30IXp.js'; import 'zod'; import '../network-N01ZIAhA.js'; import '../wallet-h2_C4cJt.js'; import 'viem'; import 'viem/chains'; import '../x402Specs-DDvn2leQ.js'; /** * Discovery Extension for x402 Bazaar * * This extension allows resource servers to declare discovery metadata * that will be registered with the facilitator's Bazaar catalog. * * @example * ```typescript * import { declareDiscoveryExtension } from "@b3dotfun/anyspend-x402/extensions"; * * app.use(paymentMiddleware("0xAddr", { * "/weather": { * price: "$0.01", * network: "base", * config: { * ...declareDiscoveryExtension({ * discoverable: true, * output: { * example: { temperature: 72, conditions: "sunny" }, * schema: { * type: "object", * properties: { * temperature: { type: "number" }, * conditions: { type: "string" }, * }, * }, * }, * metadata: { * name: "Weather API", * description: "Real-time weather data", * category: "data", * tags: ["weather", "api"], * }, * }), * }, * }, * }, facilitator)); * ``` */ /** * Schema definition for input/output */ interface SchemaDefinition { /** * Example value for documentation and testing */ example?: unknown; /** * JSON Schema definition */ schema?: JSONSchema; } /** * Options for declareDiscoveryExtension */ interface DiscoveryExtensionOptions { /** * Whether this endpoint should be discoverable in the Bazaar * * @default true */ discoverable?: boolean; /** * Input schema definition (request body/params) */ input?: SchemaDefinition; /** * Output schema definition (response) */ output?: SchemaDefinition; /** * Metadata for the discovery catalog */ metadata?: DiscoveryMetadata; } /** * Result of declareDiscoveryExtension to spread into config */ interface DiscoveryExtensionConfig { discoverable: boolean; discoveryInput?: SchemaDefinition; discoveryOutput?: SchemaDefinition; discoveryMetadata?: DiscoveryMetadata; } /** * Declares discovery metadata for a payment-protected endpoint. * * This helper function creates the configuration needed for automatic * registration with the facilitator's Bazaar discovery catalog. * * @param options - Discovery extension options * @returns Configuration object to spread into PaymentMiddlewareConfig * * @example * ```typescript * // Basic usage - just make discoverable * config: { * ...declareDiscoveryExtension({ discoverable: true }) * } * * // With output schema * config: { * ...declareDiscoveryExtension({ * output: { * example: { temperature: 72 }, * schema: { type: "object", properties: { temperature: { type: "number" } } } * } * }) * } * * // Full metadata * config: { * ...declareDiscoveryExtension({ * discoverable: true, * input: { * example: { city: "San Francisco" }, * schema: { type: "object", properties: { city: { type: "string" } } } * }, * output: { * example: { temperature: 72, conditions: "sunny" }, * schema: { * type: "object", * properties: { * temperature: { type: "number" }, * conditions: { type: "string" } * } * } * }, * metadata: { * name: "Weather API", * category: "data", * tags: ["weather"], * provider: "WeatherCorp" * } * }) * } * ``` */ declare function declareDiscoveryExtension(options?: DiscoveryExtensionOptions): DiscoveryExtensionConfig; /** * Type guard to check if config has discovery extension * * @param config - The configuration object to check * @returns True if the config has discovery extension properties */ declare function hasDiscoveryExtension(config: unknown): config is DiscoveryExtensionConfig; export { type DiscoveryExtensionConfig, type DiscoveryExtensionOptions, DiscoveryMetadata, JSONSchema, type SchemaDefinition, declareDiscoveryExtension, hasDiscoveryExtension };