mpay 0.2.0

Machine Payment Protocol - Rust library for Web Payment Auth
Documentation
//! mpay - Machine Payment Protocol for Rust
//!
//! A Rust library implementing the Web Payment Auth protocol.
//!
//! # Quick Start
//!
//! ```no_run
//! use mpay::{PaymentChallenge, PaymentCredential, Receipt, ChargeRequest};
//! use mpay::{parse_www_authenticate, format_authorization};
//! # fn main() {}
//! ```
//!
//! # Signer Integration
//!
#![cfg_attr(feature = "evm", doc = "```no_run")]
#![cfg_attr(not(feature = "evm"), doc = "```ignore")]
//! use mpay::{Signer, PrivateKeySigner};
//! # fn main() {}
//! ```
//!
//! Consumers provide their own signer. The library does not manage keystores.

pub const VERSION: &str = env!("CARGO_PKG_VERSION");

// ==================== Internal Modules ====================

pub mod error;
pub mod protocol;
pub mod utils;

#[cfg(feature = "evm")]
pub mod evm;

#[cfg(feature = "client")]
pub mod client;

#[cfg(feature = "server")]
pub mod server;

#[cfg(feature = "tempo")]
pub mod tempo;

// ==================== Flat Re-exports ====================

// Error types
pub use error::{MppError, Result, ResultExt, SigningContext};

// RFC 9457 Problem Details
pub use error::{PaymentError, PaymentErrorDetails, PROBLEM_TYPE_BASE};

// Core protocol types
pub use protocol::core::{
    ChallengeEcho, PaymentChallenge, PaymentCredential, PaymentPayload, Receipt, ReceiptStatus,
};

// Header parsing/formatting
pub use protocol::core::{
    format_authorization, format_receipt, format_www_authenticate, format_www_authenticate_many,
    parse_authorization, parse_receipt, parse_www_authenticate, parse_www_authenticate_all,
};

// Schema types
pub use protocol::core::{
    base64url_decode, base64url_encode, Base64UrlJson, IntentName, MethodName, PayloadType,
    PaymentProtocol, AUTHORIZATION_HEADER, PAYMENT_RECEIPT_HEADER, PAYMENT_SCHEME,
    WWW_AUTHENTICATE_HEADER,
};

// Intent types
pub use protocol::intents::ChargeRequest;

// ==================== Alloy Re-exports ====================

#[cfg(feature = "evm")]
pub use alloy::signers::Signer;

#[cfg(feature = "evm")]
pub use alloy_signer_local::PrivateKeySigner;

#[cfg(feature = "evm")]
pub use alloy::primitives::{Address, U256};

#[cfg(feature = "server")]
pub use alloy::providers::{ProviderBuilder, RootProvider};