dax_core 0.1.0

Common data types for dax-rs
Documentation
// SPDX-FileCopyrightText: 2024 Yarmo Mackenbach
//
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use crate::{
    claim::{Claim, ClaimMatchingError, ClaimVerificationError, ClaimVerificationResult},
    proof::Proof,
};

/// Source of identity proof
pub trait Service {
    /// Instantiate a new service definition
    fn new() -> Self
    where
        Self: Sized;
    /// Get the proof provider information
    fn info(&self) -> &ServiceInfo;
    /// Check whether a claim is a match for this service
    fn match_claim(&self, claim: &Claim) -> Result<bool, ClaimMatchingError>;
    /// Verify an identity claim
    fn verify_claim(
        &self,
        claim: &Claim,
        proofs: &[Proof],
    ) -> Result<ClaimVerificationResult, ClaimVerificationError>;
}

/// Information about a service
#[derive(Debug)]
pub struct ServiceInfo {
    /// Name
    pub name: String,
    /// Short id
    pub id: String,
    /// Website pertinent to the service or project
    pub homepage: String,
}

pub enum ServicePriority {
    WildcardDomain = 1,
    UniqueDomain = 2,
}