Skip to main content

hyprstream_rpc/auth/
mod.rs

1//! JWT authorization types and utilities.
2//!
3//! This module provides:
4//! - Structured scopes for fine-grained authorization
5//! - JWT claims with scope validation
6//! - JWT encoding/decoding with Ed25519 signatures
7//! - Compile-time scope registration via inventory pattern
8//! - JWT key source abstraction for unified key resolution
9
10/// ATProto perimeter gateway: external-DID → assurance binding (#549, first half).
11/// Native-only — depends on the admission gate (`did:web`/`did:key` resolution).
12#[cfg(not(target_arch = "wasm32"))]
13pub mod atproto_perimeter;
14pub mod claims;
15#[cfg(not(target_arch = "wasm32"))]
16pub mod composite;
17pub mod credential;
18pub mod det_cbor;
19#[cfg(not(target_arch = "wasm32"))]
20pub mod federation;
21pub mod internal_work;
22pub mod jti_blocklist;
23pub mod jwt;
24#[cfg(not(target_arch = "wasm32"))]
25pub mod key_source;
26#[cfg(not(target_arch = "wasm32"))]
27pub mod key_subject_resolver;
28/// Native MAC: security labels, lattice, subject contexts, genesis labeling
29/// (S1, #567). Platform-independent (no std-only deps) so it compiles for wasm.
30pub mod mac;
31pub mod scope;
32#[cfg(not(target_arch = "wasm32"))]
33pub mod scope_registry;
34#[cfg(not(target_arch = "wasm32"))]
35pub mod session_store;
36pub mod signer_suite;
37/// UCAN → Casbin/TE compiler foundation (S5, #571): the UCAN token model,
38/// delegation-chain + ceiling/attenuation validation, and the signed
39/// `(UCAN, bundle_hash)` approval binding (hybrid EdDSA + ML-DSA-65 COSE).
40pub mod ucan;
41
42#[cfg(not(target_arch = "wasm32"))]
43pub use atproto_perimeter::{AtprotoPerimeterGateway, EnrolledPeer, EnrollmentStore};
44// The identity-resolution contract (#579) lives canonically in `crate::identity`;
45// re-exported here so existing `crate::auth::{IdentityResolver, ...}` paths keep working.
46pub use crate::identity::{
47    Ed25519Vk, IdentityKeyCandidate, IdentityKeys, IdentityResolver, MlDsaVk,
48};
49pub use claims::{
50    compute_jkt, federate_tui_class_client, install_federate_tui_class_client, is_local_iss,
51    ActClaim, Claims, Cnf, CnfJwk, IdTokenClaims, OneOrMany, SessionClaimError,
52};
53#[cfg(not(target_arch = "wasm32"))]
54pub use composite::{
55    global_composite_key_set, CompositeKeyPair, CompositeKeySet, CompositeKeySetSnapshot,
56    CompositePairRole, CompositePairState,
57};
58pub use credential::{
59    global_session_registry, set_global_session_registry, ActiveOrRevoked, CredentialId,
60    CredentialValue, GlobalSessionRegistryAlreadySet, InMemorySessionRegistry,
61    InvalidSessionRecord, SessionExists, SessionIdentifier, SessionKey, SessionKind,
62    SessionKindMismatch, SessionPublicationFailed, SessionRegisterError, SessionRegistry,
63    SessionRevokeError, SessionState,
64};
65pub use det_cbor::{det_cbor, DetCborValue};
66#[cfg(not(target_arch = "wasm32"))]
67pub use federation::{FederationKey, FederationKeySource};
68pub use internal_work::{
69    admit_internal_work_jti_once, encode_internal_work, verify_internal_work, InternalWorkClaims,
70    InternalWorkContext, InternalWorkScope, INTERNAL_WORK_ISSUER, INTERNAL_WORK_JWT_TYP,
71    MAX_IAT_SKEW_SECS, MAX_LIFETIME_SECS,
72};
73#[cfg(not(target_arch = "wasm32"))]
74pub use jti_blocklist::FileBackedCredentialRevocationStore;
75pub use jti_blocklist::{
76    global_credential_revocation_store, set_global_credential_revocation_store,
77    CredentialRevocationStore, GlobalStoreAlreadySet, InMemoryCredentialRevocationStore,
78    RevocationPublishError,
79};
80#[cfg(not(target_arch = "wasm32"))]
81pub use jwt::decode_with_federation_candidates;
82pub use jwt::{
83    composite_kid, decode, decode_unverified, decode_with_any_key, decode_with_any_key_lenient,
84    decode_with_key, encode, encode_service_jwt, header_alg, header_kid,
85    is_rfc9068_access_token_type, jwk_thumbprint, parse_composite_dispatch, parse_protected_header,
86    CompositeJwtDispatch, JwkThumbprintInput, JwtError, ProtectedHeader,
87    RFC9068_ACCESS_TOKEN_TYPES,
88};
89#[cfg(not(target_arch = "wasm32"))]
90pub use key_source::{
91    ClusterKeySource, FederatedKeySource, IssuerResolver, JwksFetcher, JwksKeySource, JwksMode,
92    JwtKeySource,
93};
94#[cfg(not(target_arch = "wasm32"))]
95pub use key_subject_resolver::{set_global as set_global_key_subject_resolver, KeySubjectResolver};
96pub use mac::{
97    bind_time_label, import_label, Assurance, Compartment, CompartmentSet, ContentBoundLabel,
98    GenesisMap, GenesisReport, LabelError, LabeledObject, Lattice, LatticeCodecError,
99    LatticeDecodeError, LatticeVersion, Level, ObjectLabelResolver, ObjectRef, SecurityContext,
100    SecurityLabel, StaticNodeLabel, SubjectContextClaims, VerifiedKeyMaterial, MAX_COMPARTMENTS,
101};
102pub use scope::Scope;
103#[cfg(not(target_arch = "wasm32"))]
104pub use scope_registry::ScopeDefinition;
105#[cfg(not(target_arch = "wasm32"))]
106pub use session_store::FileBackedSessionRegistry;
107pub use signer_suite::{
108    service_signer_suite_b64, signer_suite_thumbprint, SUITE_CLASSICAL_ED25519,
109    SUITE_HYBRID_ED25519_MLDSA65,
110};
111pub use ucan::{
112    set_attenuates, Ability, ApprovalBinding, ApprovalError, Capability, CaveatValue, Caveats,
113    ChainError, Did, Resource, SignedApproval, Ucan, UcanError, UcanPayload, UcanVerifier,
114};