pub struct Dat {
pub header: DatHeader,
pub claims: DatClaims,
/* private fields */
}Expand description
A complete Delegation Attestation Token.
Fields§
§header: DatHeader§claims: DatClaimsImplementations§
Source§impl Dat
impl Dat
Sourcepub fn issue(
issuer_did: &str,
subject_did: &str,
scope: Vec<String>,
expires_at: DateTime<Utc>,
constraints: Option<DatConstraints>,
config_attestation: Option<String>,
signing_key: &KeyPair,
) -> Result<Self>
pub fn issue( issuer_did: &str, subject_did: &str, scope: Vec<String>, expires_at: DateTime<Utc>, constraints: Option<DatConstraints>, config_attestation: Option<String>, signing_key: &KeyPair, ) -> Result<Self>
Issue a new DAT signed by the issuer’s keypair.
Sourcepub fn to_compact(&self) -> Result<String>
pub fn to_compact(&self) -> Result<String>
Serialize to compact JWS format: header.payload.signature
Sourcepub fn from_compact(compact: &str) -> Result<Self>
pub fn from_compact(compact: &str) -> Result<Self>
Parse a compact JWS string into a DAT (without verifying the signature).
Preserves the raw base64url-encoded header.payload as raw_signing_input
so that verify_signature can verify against the exact original bytes.
Sourcepub fn verify_signature(&self, public_key_bytes: &[u8; 32]) -> Result<()>
pub fn verify_signature(&self, public_key_bytes: &[u8; 32]) -> Result<()>
Verify the DAT’s signature against a public key.
Uses the raw signing input from the original compact JWS when available,
falling back to re-serialization for tokens created via issue().
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the DAT is expired.
Sourcepub fn is_not_yet_valid(&self) -> bool
pub fn is_not_yet_valid(&self) -> bool
Check if the DAT is not yet valid (before nbf).
Sourcepub fn validate_timing(&self) -> Result<()>
pub fn validate_timing(&self) -> Result<()>
Validate timing constraints (not expired, not before valid).
Sourcepub fn verify(
&self,
public_key_bytes: &[u8; 32],
required_scope: &str,
ctx: &EvaluationContext,
) -> Result<()>
pub fn verify( &self, public_key_bytes: &[u8; 32], required_scope: &str, ctx: &EvaluationContext, ) -> Result<()>
Full verification pipeline.
Runs all checks in order:
- Signature verification
- Timing (exp + nbf)
- Scope —
required_scopemust be permitted by the DAT’s scope set - Constraint policy engine (rate limit, IP, trust, depth, geofence, time windows)
- Config attestation (if constraint requires it)
Delegation depth is taken as the maximum of ctx.delegation_depth and the
length of claims.delegation_chain, so the stricter value always wins.
Pass required_scope = "" to skip the scope check (e.g. for token introspection).