pub mod approval;
pub mod approval_gate;
pub mod audit;
pub mod cel;
pub mod constraints;
pub mod crypto;
pub mod diff;
pub mod domain;
pub mod error;
pub mod extraction;
pub mod gateway_config;
pub mod mcp;
pub mod payload;
pub mod planes;
pub mod revocation;
pub mod revocation_manager;
pub mod warrant;
pub mod wire;
pub use extraction::{
CompiledExtractionRule, CompiledExtractionRules, CompiledPath, ExtractionRule,
ExtractionSource, RequestContext,
};
pub use gateway_config::{
CompiledGatewayConfig, CompiledRoute, GatewayConfig, GatewaySettings, MethodMask, RouteConfig,
RouteMatch, ToolConfig,
};
pub use mcp::{CompiledMcpConfig, CompiledTool, McpConfig, McpSettings};
#[cfg(feature = "python")]
pub mod python;
#[cfg(feature = "server")]
pub mod connect_token;
#[cfg(feature = "server")]
pub mod heartbeat;
#[cfg(feature = "python-server")]
pub mod python_control_plane;
pub use constraints::{
All, Any, CelConstraint, Cidr, Constraint, ConstraintSet, ConstraintValue, Contains, Exact,
Not, NotOneOf, OneOf, Pattern, Range, RegexConstraint, Subset, UrlPattern, Wildcard,
MAX_CONSTRAINT_DEPTH,
};
pub use crypto::{PublicKey, Signature, SigningKey};
pub use error::{Error, Result};
pub use planes::{
Authorizer, AuthorizerBuilder, ChainStep, ChainVerificationResult, ControlPlane, DataPlane,
VerifiedApproval, DEFAULT_CLOCK_TOLERANCE_SECS,
};
pub use revocation::{
RevocationRequest, SignedRevocationList, SrlBuilder, MAX_REVOCATION_REQUEST_AGE_SECS,
};
pub use revocation_manager::RevocationManager;
pub use warrant::{
Clearance, OwnedAttenuationBuilder, OwnedIssuanceBuilder, Warrant, WarrantBuilder, WarrantId,
WarrantType, POP_MAX_WINDOWS, POP_TIMESTAMP_WINDOW_SECS, WARRANT_ID_PREFIX,
};
pub use wire::MAX_WARRANT_SIZE;
pub use approval_gate::{
encode_approval_gate_map, evaluate_approval_gates, merge_approval_gate_maps,
parse_approval_gate_map, propagate_approval_gates, ApprovalGateError, ApprovalGateMap,
ArgApprovalGate, ToolApprovalGate,
};
pub use approval::ApprovalRequest;
pub use approval_gate::APPROVAL_GATE_EXTENSION_KEY; pub const IDENTITY_BINDING_EXTENSION_KEY: &str = "tenuo.identity_binding";
pub use diff::{
ChangeType, ClearanceDiff, ConstraintDiff, DelegationDiff, DelegationReceipt, DepthDiff,
ToolsDiff, TtlDiff,
};
pub const MAX_DELEGATION_DEPTH: u32 = 64;
const _: () = assert!(
MAX_DELEGATION_DEPTH <= 255,
"MAX_DELEGATION_DEPTH must not exceed 255 (u8 max) for wire format compatibility"
);
pub const MAX_WARRANT_TTL_SECS: u64 = 90 * 24 * 60 * 60;
pub const DEFAULT_WARRANT_TTL_SECS: u64 = 5 * 60;
pub use domain::WARRANT_CONTEXT as SIGNATURE_CONTEXT;
pub const WIRE_VERSION: u8 = 1;
#[cfg(test)]
mod tests {
use super::*;
use std::time::Duration;
#[test]
fn test_basic_warrant_creation() {
let keypair = SigningKey::generate();
let mut constraints = ConstraintSet::new();
constraints.insert("cluster".to_string(), Pattern::new("staging-*").unwrap());
let warrant = Warrant::builder()
.capability("upgrade_cluster", constraints)
.ttl(Duration::from_secs(600))
.holder(keypair.public_key())
.build(&keypair)
.unwrap();
let caps = warrant.capabilities().unwrap();
assert!(caps.contains_key("upgrade_cluster"));
assert!(warrant.verify(&keypair.public_key()).is_ok());
}
#[test]
fn test_attenuation_narrows_constraints() {
let keypair = SigningKey::generate();
let _child_keypair = SigningKey::generate();
let mut p_constraints = ConstraintSet::new();
p_constraints.insert("cluster".to_string(), Pattern::new("staging-*").unwrap());
let parent = Warrant::builder()
.capability("upgrade_cluster", p_constraints)
.ttl(Duration::from_secs(600))
.holder(keypair.public_key())
.build(&keypair)
.unwrap();
let mut c_constraints = ConstraintSet::new();
c_constraints.insert("cluster".to_string(), Exact::new("staging-web"));
let child = parent
.attenuate()
.capability("upgrade_cluster", c_constraints)
.build(&keypair) .unwrap();
assert!(child.expires_at() <= parent.expires_at());
assert_eq!(child.depth(), parent.depth() + 1);
}
}