pdk-contracts-lib 1.9.1-alpha.2

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. It periodically fetches contracts from the
//! platform and keeps a local cache to enable fast authentication and authorization
//! decisions within the policy request path.
//!
//! ## Highlights
//!
//! - Local contracts cache with concurrency-safe updates
//! - Periodic polling and incremental updates from the platform
//! - Authorization via `client_id` and authentication via `client_id`/`client_secret`
//! - Helpers to parse HTTP Basic Auth credentials
//!
//! ## Primary types
//!
//! - [`ContractValidator`]: contracts fetch/update plus `authenticate` and `authorize`
//! - [`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 implementation;

pub use api::basic_auth::{basic_auth_credentials, BasicAuthError};
pub use api::credentials::*;
pub use api::error::*;
pub use api::validator::ContractValidator;
pub use api::ClientData;

#[cfg(test)]
mod mocks;