Skip to main content

pas_external/
lib.rs

1#![doc = include_str!("../README.md")]
2
3pub mod audit;
4// Clock port re-export — External Developer consumers can use
5// `pas_external::clock::ArcClock` / `pas_external::clock::FrozenClock`
6// without a separate `ppoppo-clock` dep in their Cargo.toml.
7pub mod clock {
8    pub use ::ppoppo_clock::*;
9}
10// Perimeter Bearer-auth Layer kit — Phase A Slice 4 lifted the kit to
11// `ppoppo_sdk_core::bearer::*`. pas-external 0.11.0 re-exports the
12// kit at `pas_external::bearer::*` (audit decision D — 1-level
13// role-named module, no `oidc::axum::*` nesting) for 3rd-party
14// consumers (RCW/CTW). 1st-party services (chat-auth) import direct
15// from sdk-core (audit decision B). The framework-dep visibility
16// (axum / tower) is signalled by the `axum` feature gate, not by a
17// nested `pas_external::oidc::axum::*` namespace.
18#[cfg(feature = "axum")]
19pub mod bearer {
20    pub use ::ppoppo_sdk_core::bearer::*;
21}
22// `epoch` re-exports the engine `EpochRevocation` port + ships the
23// canonical adapter set (Phase 11.Z, RFC_2026-05-09 §3.5). Gated on
24// `well-known-fetch` because the engine port itself needs `token` and
25// the original `UserinfoFetcher` (deleted in 0.10.0) required the HTTP
26// client (`oauth`) — both implied by the `well-known-fetch` flag.
27// `SharedCacheCache` (0.10.0, RFC_2026-05-08 §4.1) requires the
28// additional `shared-cache` feature for the `ppoppo-infra` adapter dep.
29#[cfg(feature = "well-known-fetch")]
30pub mod epoch;
31pub mod error;
32// `oauth` is two-tiered: the `TokenResponse` wire DTO compiles at the
33// `oauth` tier (consumed by `pas_port` / `session_liveness`), while the
34// `OAuthConfig` + `AuthClient` HTTP adapter is gated inside the module on
35// `well-known-fetch` — the tier of its sole constructor,
36// `oidc::RelyingParty::new`. As of 0.8.0 the module is `pub(crate)`:
37// consumers reach the OIDC RP composition root (`oidc::RelyingParty<S>`)
38// and never the raw OAuth surface. See `oidc::RefreshOutcome` for the
39// boundary type at `RelyingParty::refresh`.
40#[cfg(feature = "oauth")]
41pub(crate) mod oauth;
42#[cfg(feature = "token")]
43pub mod oidc;
44#[cfg(feature = "oauth")]
45pub mod pas_port;
46// Renewing `TokenSource` (G3 / RTR) — `RefreshTokenSource` + `TokenStore`.
47// For native / CLI clients (CNC) that hold a durable refresh token and feed a
48// `ppoppo_sdk_core::TokenCache`; depends on the `PasAuthPort` port (`oauth`)
49// and sdk-core's `token-cache` (the `TokenSource` trait it implements).
50#[cfg(feature = "refresh-source")]
51pub mod refresh_source;
52// `pkce` primitives (`generate_state`, `generate_code_verifier`,
53// `generate_code_challenge`) are SDK plumbing — `oidc::RelyingParty::start`
54// is the sole consumer, so the module is gated on `well-known-fetch`
55// (the RP's tier) rather than the lower `oauth` tier, which would orphan
56// it under the default feature set. `pub(crate)` since 0.8.0.
57#[cfg(feature = "well-known-fetch")]
58pub(crate) mod pkce;
59// `session_liveness` is intentionally ungated at module level — the
60// 0.10.0 `SessionLiveness` port has no AES / OAuth deps and ships
61// regardless of feature configuration so the verifier slot
62// (`PasJwtVerifier::with_session_liveness`) can reference it under
63// just `feature = "well-known-fetch"`. Internal sub-modules
64// (`cipher`, `liveness`) remain gated on `feature = "session-liveness"`
65// for the AES wrapper + PAS refresh-token check.
66pub mod session_liveness;
67pub mod types;
68
69// Test-support helpers. `FakePasServer` is the SDK-owned wiremock-wrapped
70// fake PAS Authorization Server, replacing the 0.7.x
71// `RelyingParty::for_test_with_parts` escape hatch. Consumer integration
72// tests construct a real `RelyingParty::new(...)` against
73// `FakePasServer.issuer_url()` so production and test go through the same
74// public interface.
75#[cfg(feature = "test-support")]
76pub mod test_support;
77
78// Re-exports for convenient access
79pub use audit::{
80    AuditEvent, AuditSink, IdTokenFailureKind, MemoryRateLimiter, NoopAuditSink, RateLimitKey,
81    RateLimitedAuditSink, RateLimiter, VerifyErrorKind, compose_id_token_source_id,
82    compose_source_id,
83};
84#[cfg(any(test, feature = "test-support"))]
85pub use audit::MemoryAuditSink;
86pub use error::{Error, TokenError};
87// 0.10.0 — ungated L2 verifier-slot port (RFC_2026-05-08 §4.2 lock).
88pub use session_liveness::{SessionLiveness, SessionLivenessError};
89#[cfg(feature = "session-liveness")]
90pub use session_liveness::{
91    CipherError, EncryptedRefreshToken, LivenessFailure, LivenessOutcome, RevokeCause,
92    TokenCipher, TransientCause, attempt_liveness_refresh,
93};
94// γ port-and-adapter — Phase 6.1 (D-04 = γ, locked 2026-05-05).
95// Phase A (RFC `RFC_2026-05-08_app-credential-collapse.md`, audit
96// decisions E + G) lifted the cohesive verifier group to
97// `ppoppo_sdk_core::verifier::*`. pas-external re-exports at top level
98// (no `token::` namespace — audit decision E) so consumer code
99// reaches `pas_external::{BearerVerifier, JwtVerifier, ...}`. Renames:
100// `PasJwtVerifier` → `JwtVerifier`; `Expectations` → `VerifyConfig`;
101// `AuthSession` → `VerifiedClaims`. The `crypto-side` `VerifyError`
102// re-exports as `TokenVerifyError` (BREAKING) to make space for the
103// Layer-side `VerifyError` from `pas_external::bearer::*` (Slice 4
104// migration). Phase A 0.11.0 ships clean — no transitional alias.
105#[cfg(feature = "token")]
106pub use ::ppoppo_sdk_core::verifier::{
107    BearerVerifier, VerifiedClaims, VerifyConfig, VerifyError as TokenVerifyError,
108};
109#[cfg(feature = "well-known-fetch")]
110pub use ::ppoppo_sdk_core::verifier::{EpochEnforcement, JwksCache, JwtVerifier};
111#[cfg(all(feature = "token", any(test, feature = "test-support")))]
112pub use ::ppoppo_sdk_core::verifier::MemoryBearerVerifier;
113// OIDC RP surface — composition root + post-verify shapes + ports.
114// `RelyingParty<S>` is the consumer-facing entry point; `RefreshOutcome`
115// is the typed boundary return for `RelyingParty::refresh` (replaces
116// the 0.7.x `oauth::TokenResponse` re-export).
117#[cfg(feature = "token")]
118pub use oidc::{Address, IdAssertion, IdTokenVerifier, IdVerifyError, Nonce, ScopePiiReader};
119#[cfg(all(feature = "token", any(test, feature = "test-support")))]
120pub use oidc::MemoryIdTokenVerifier;
121pub use types::{KeyId, Ppnum, PpnumId, SessionId, UserId};
122
123// Renewing TokenSource (G3 / RTR).
124#[cfg(feature = "refresh-source")]
125pub use refresh_source::{MemoryTokenStore, RefreshTokenSource, TokenStore, TokenStoreError};
126// `Url` is consumer-facing via `Config::new(client_id, redirect_uri: Url, ...)`
127// and `Discovery::for_test`. Re-exported so consumers reach the same `url`
128// crate version the SDK uses without separately tracking it in their
129// Cargo.toml.
130#[cfg(feature = "oauth")]
131pub use url::Url;