pdk-contracts-lib 1.10.0

PDK Contracts Library
Documentation
// Copyright (c) 2026, Salesforce, Inc.,
// All rights reserved.
// For full license text, see the LICENSE.txt file

//! PDK Contracts Library
//!
//! Library for validating client credentials against Anypoint Platform API contracts
//! in Flex Gateway custom policies.
//!
//! ## Highlights
//!
//! - [`ContractValidator`]: periodic polling and incremental updates from the platform
//!   with a local cache for synchronous `authenticate` and `authorize` decisions
//! - Authorization via `client_id` and authentication via `client_id`/`client_secret`
//! - Helpers to parse HTTP Basic Auth credentials
//!
//! ## Primary types
//!
//! - [`ContractValidator`]: periodic polling + local cache validation
//! - [`ClientData`]: resolved client metadata for successful validations
//! - [`basic_auth_credentials`]: parse the HTTP Basic `Authorization` header
//! - [`BasicAuthError`]
//!
//! ## Readiness and polling cadence
//!
//! - Use [`ContractValidator::is_ready`] to check if contracts have been pulled and cached locally.
//! - Call [`ContractValidator::update_contracts`] periodically. During startup, invoke it every
//!   [`ContractValidator::INITIALIZATION_PERIOD`]. After initialization, invoke it every
//!   [`ContractValidator::UPDATE_PERIOD`].
//!

pub(crate) mod api;
pub(crate) mod legacy;

pub use api::basic_auth::{basic_auth_credentials, BasicAuthError};
#[cfg(feature = "experimental_contracts_v2")]
pub use api::contracts::ApiContracts;
pub use api::credentials::*;
pub use api::error::*;
pub use api::ClientData;

#[allow(deprecated)]
pub use legacy::api::validator::ContractValidator;

#[cfg(test)]
mod mocks;