ppoppo_token/lib.rs
1//! **NOT a stable public API.** Engine-tier JWT engine — 3rd parties never
2//! reach it directly: the External-Developer verification surface is
3//! `pas_external`'s verifier facade (the γ-port), which re-exports what
4//! integrations need. Published only because cargo requires every crate in
5//! the SDK family's dependency closure on the registry.
6
7// JWT engine (RFC_2026-05-04_jwt-full-adoption Phase 1+).
8//
9// Profile-aware top-level layout (Phase 10.0 — D1):
10//
11// - `access_token::*` — RFC 9068 access-token profile (Phase 1-5 code).
12// Public re-exports: `verify` / `issue` entry points, `Claims`,
13// `VerifyConfig`, `IssueConfig`, `IssueRequest`, `AuthError`,
14// `IssueError`, plus the operational ports `EpochRevocation` /
15// `ReplayDefense` / `SessionRevocation` (RFC 9068 sv-/jti-/sid-coupled).
16//
17// - `id_token::*` — OIDC Core 1.0 id-token profile. Phase 10.1+ scaffold;
18// ships in subsequent commits.
19//
20// - Crate-root pubs (this file): JOSE-shared primitives that neither
21// profile owns — `Algorithm`, `KeySet`, `SigningKey`, `Jwk`, `Jwks`,
22// plus the operational shared-cache contract (`SV_CACHE_TTL`,
23// `sv_cache_key`).
24//
25// - `engine::*` — `pub(crate)` only. JWS check pipeline reachable solely
26// through `access_token::verify` / `access_token::issue` (and Phase
27// 10.1's `id_token::verify` / `id_token::issue`). Direct calls to
28// `jsonwebtoken::*` outside `engine/` are forbidden (M51/M52 lint,
29// landed Phase 7).
30mod algorithm;
31pub(crate) mod engine;
32mod jwks;
33mod key_set;
34mod signing_key;
35
36pub mod access_token;
37pub mod id_token;
38
39pub use crate::algorithm::Algorithm;
40pub use crate::engine::shared_error::SharedAuthError;
41pub use crate::jwks::{Jwk, Jwks, JwksError};
42pub use crate::key_set::KeySet;
43pub use crate::signing_key::{ed25519_public_from_pem, SigningKey};
44
45pub const DEFAULT_ISSUER: &str = "accounts.ppoppo.com";
46
47/// TTL for the `sv:{ppnum_id}` cache entry shared between PAS (writer) and
48/// PCS / external SDK consumers (readers). Bounds the post-break-glass
49/// staleness window when the writer cannot preemptively invalidate.
50///
51/// Value contract: 60 s. See STANDARDS_SHARED_CACHE §3.1 (Reader / Writer
52/// table) and STANDARDS_AUTH_PPOPPO §17.7 (wiring status).
53pub const SV_CACHE_TTL: std::time::Duration = std::time::Duration::from_secs(60);
54
55/// Build the shared cache key for a given Human ppnum's `session_version`.
56///
57/// Returned shape: `sv:{ppnum_id}`. Encapsulates the prefix so callers
58/// cannot accidentally mis-format the key (forgetting the colon, double
59/// prefixing, etc.). PAS writes this key on break-glass commit; PCS
60/// chat-auth and the pas-external SDK validator read it.
61///
62/// SSOT: STANDARDS_SHARED_CACHE §3.1 (`sv:` shared contract).
63#[must_use]
64pub fn sv_cache_key(ppnum_id: &str) -> String {
65 format!("sv:{ppnum_id}")
66}