ppoppo-token 0.2.0

JWT (RFC 9068, EdDSA) issuance + verification engine for the Ppoppo ecosystem. Single deep module with a small interface (issue, verify) hiding RFC 8725 mitigations M01-M45, JWKS handling, and substrate ports (epoch, session, replay).
Documentation
//! M67 — id_token at_hash binding (OIDC Core 1.0 §3.1.3.8).
//!
//! Defends against access-token substitution: when an authorization
//! response carries both an id_token and an access_token, the id_token's
//! `at_hash` claim binds the two together. An attacker cannot swap in a
//! different access_token without either re-issuing the id_token (which
//! requires the IdP's signing key) or stripping the binding (which
//! `AtHashMissing` catches).
//!
//! ── Opt-in semantics ────────────────────────────────────────────────────
//!
//! Engine inspects `at_hash` only when the verifier supplied an expected
//! access_token via `VerifyConfig::with_access_token_binding`. Pure code
//! flow consumers (today: RCW/CTW) leave the binding unset and the
//! engine returns `Ok(())` without touching the claim — at_hash is
//! conditionally required by RFC, never universally.
//!
//! ── Composition ─────────────────────────────────────────────────────────
//!
//! Cryptography lives in `engine::hash_binding`. This module is a thin
//! adapter that maps `HashBindingError` → `id_token::AuthError` (the
//! profile-specific carrier). The same shape is mirrored at `check_c_hash`
//! for M68; consolidating them into one file would couple two distinct
//! mitigation rows behind one entry-point and break the codebase's
//! per-row file convention (see `check_nonce.rs`, `check_replay.rs`).

use crate::engine::hash_binding::{self, HashBindingError};
use crate::id_token::{AuthError, VerifyConfig};

pub(crate) fn run(
    payload: &serde_json::Value,
    cfg: &VerifyConfig,
) -> Result<(), AuthError> {
    let Some(expected) = cfg.expected_access_token.as_deref() else {
        // Binding not configured — engine is opt-in. Pure code flow
        // consumers reach this path on every verify.
        return Ok(());
    };
    hash_binding::verify_match(payload, "at_hash", expected.as_bytes()).map_err(|e| match e {
        HashBindingError::ClaimMissing => AuthError::AtHashMissing,
        HashBindingError::Mismatch => AuthError::AtHashMismatch,
    })
}