x402_extensions/lib.rs
1//! # X402 Extensions
2//!
3//! This crate provides concrete extension type implementations for the X402 protocol.
4//!
5//! Extensions enable modular optional functionality beyond core payment mechanics.
6//! Servers advertise supported extensions in `PaymentRequired`, and clients echo them
7//! in `PaymentPayload`.
8//!
9//! ## Available Extensions
10//!
11//! - [`bazaar`]: Resource discovery and cataloging for x402-enabled endpoints and MCP tools
12//! - [`sign_in_with_x`]: Authenticated sign-in alongside payment
13//!
14//! ## Defining Custom Extensions
15//!
16//! You can define your own extensions by implementing the [`ExtensionInfo`](x402_core::types::ExtensionInfo)
17//! trait from `x402-core`:
18//!
19//! ```
20//! use serde::{Serialize, Deserialize};
21//! use x402_core::types::{Extension, ExtensionInfo, AnyJson};
22//! use serde_json::json;
23//!
24//! #[derive(Debug, Clone, Serialize, Deserialize)]
25//! pub struct MyExtensionInfo {
26//! pub custom_field: String,
27//! }
28//!
29//! impl ExtensionInfo for MyExtensionInfo {
30//! const ID: &'static str = "my-custom-extension";
31//! fn schema() -> AnyJson {
32//! json!({
33//! "type": "object",
34//! "properties": {
35//! "custom_field": { "type": "string" }
36//! },
37//! "required": ["custom_field"]
38//! })
39//! }
40//! }
41//!
42//! let ext = Extension::typed(MyExtensionInfo {
43//! custom_field: "hello".to_string(),
44//! });
45//! let (key, transport) = ext.into_pair();
46//! assert_eq!(key, "my-custom-extension");
47//! ```
48
49/// The `bazaar` extension for resource discovery and cataloging.
50pub mod bazaar;
51
52/// The `sign-in-with-x` extension for authenticated access.
53pub mod sign_in_with_x;