Skip to content

Commit

Permalink
feat: impl debug for multiple structs needed in the identity-wallet A…
Browse files Browse the repository at this point in the history
…ppState managers struct
  • Loading branch information
Oran-Dan committed Jan 20, 2025
1 parent 22b02b0 commit c2f3175
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dif-presentation-exchange/src/presentation_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub enum ClaimFormatDesignation {
pub enum ClaimFormatProperty {
Alg(Vec<Algorithm>),
ProofType(Vec<String>),
#[serde(untagged)]
// TODO: removed serde(untagged) line here to fix error, i've not checked consequences
SdJwt {
#[serde(rename = "sd-jwt_alg_values", default, skip_serializing_if = "Vec::is_empty")]
sd_jwt_alg_values: Vec<Algorithm>,
Expand Down
4 changes: 2 additions & 2 deletions oid4vc-core/src/authentication/sign.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use async_trait::async_trait;
use jsonwebtoken::Algorithm;
use std::sync::Arc;
use std::{fmt::Debug, sync::Arc};

#[async_trait]
pub trait Sign: Send + Sync {
Expand All @@ -12,6 +12,6 @@ pub trait Sign: Send + Sync {
fn external_signer(&self) -> Option<Arc<dyn ExternalSign>>;
}

pub trait ExternalSign: Send + Sync {
pub trait ExternalSign: Send + Sync + Debug{
fn sign(&self, message: &str) -> Result<Vec<u8>>;
}
4 changes: 2 additions & 2 deletions oid4vc-core/src/authentication/subject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use crate::{Sign, Verify};
use anyhow::Result;
use async_trait::async_trait;
use jsonwebtoken::Algorithm;
use std::sync::Arc;
use std::{fmt::Debug, sync::Arc};

pub type SigningSubject = Arc<dyn Subject>;

// TODO: Use a URI of some sort.
/// This [`Subject`] trait is used to sign and verify JWTs.
#[async_trait]
pub trait Subject: Sign + Verify + Send + Sync {
pub trait Subject: Sign + Verify + Send + Sync + Debug {
async fn identifier(&self, subject_syntax_type: &str, algorithm: Algorithm) -> Result<String>;
}
2 changes: 1 addition & 1 deletion oid4vc-core/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lazy_static! {
pub static ref TEST_KEYPAIR: SigningKey = SigningKey::generate(&mut OsRng);
}

#[derive(Derivative)]
#[derive(Derivative, Debug)]
#[derivative(Default)]
pub struct TestSubject {
#[derivative(Default(value = "did_url::DID::parse(\"did:test:123\").unwrap()"))]
Expand Down
2 changes: 1 addition & 1 deletion oid4vc-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ serde_with.workspace = true
tokio.workspace = true
tower-http = { version = "0.4", features = ["cors"]}
url.workspace = true
derivative = "2.2"

[dev-dependencies]
oid4vc-core = { path = "../oid4vc-core", features = ["test-utils"] }

derivative = "2.2"
ed25519-dalek = { version = "2.0.0", features = ["rand_core"] }
lazy_static = "1.4"
rand = "0.8"
Expand Down
1 change: 1 addition & 0 deletions oid4vc-manager/src/managers/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use siopv2::Provider;
use std::sync::Arc;

/// Manager struct for [`siopv2::Provider`].
#[derive(Debug)]
pub struct ProviderManager {
pub provider: Provider,
}
Expand Down
4 changes: 4 additions & 0 deletions oid4vc-manager/src/methods/key_method.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use derivative::Derivative;
use did_key::{generate, resolve, Config, CoreSign, DIDCore, Document, Ed25519KeyPair, KeyMaterial, PatchedKeyPair};
use jsonwebtoken::Algorithm;
use oid4vc_core::{authentication::sign::ExternalSign, Sign, Subject, Verify};
use std::sync::Arc;

/// This [`KeySubject`] implements the [`Subject`] trait and can be used as a subject for a [`Provider`]. It uses the
/// 'key' DID method.
#[derive(Derivative)]
#[derivative(Debug)]
pub struct KeySubject {
#[derivative(Debug = "ignore")]
keypair: PatchedKeyPair,
document: Document,
external_signer: Option<Arc<dyn ExternalSign>>,
Expand Down
2 changes: 1 addition & 1 deletion oid4vc-manager/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lazy_static! {
pub static ref TEST_KEYPAIR: SigningKey = SigningKey::generate(&mut OsRng);
}

#[derive(Derivative)]
#[derive(Derivative, Debug)]
#[derivative(Default)]
pub struct TestSubject {
#[derivative(Default(value = "did_url::DID::parse(\"did:test:123\").unwrap()"))]
Expand Down
3 changes: 2 additions & 1 deletion oid4vc-manager/tests/siopv2/implicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use wiremock::{
};

/// A Subject that can sign and verify messages with multiple different DID Methods.
#[derive(Debug)]
pub struct MultiDidMethodSubject {
pub test_subject: TestSubject,
pub key_subject: KeySubject,
Expand Down Expand Up @@ -134,7 +135,7 @@ async fn test_implicit_flow(#[case] did_method: &str) {
.scope(Scope::from(vec![ScopeValue::OpenId, ScopeValue::Phone]))
.redirect_uri(format!("{server_url}/redirect_uri").parse::<url::Url>().unwrap())
.response_mode("direct_post".to_string())
.client_metadata(ClientMetadataResource::<ClientMetadataParameters>::ClientMetadata {
.client_metadata(ClientMetadataResource::ClientMetadata { // TODO: removed <ClientMetadataParameters>::, not sure of the consequences
client_name: None,
logo_uri: None,
extension: ClientMetadataParameters {
Expand Down
1 change: 1 addition & 0 deletions oid4vci/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use reqwest_retry::RetryTransientMiddleware;
use serde::de::DeserializeOwned;
use std::str::FromStr;

#[derive(Debug)]
pub struct Wallet<CFC = CredentialFormats<WithParameters>>
where
CFC: CredentialFormatCollection,
Expand Down
1 change: 1 addition & 0 deletions siopv2/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware};
/// A Self-Issued OpenID Provider (SIOP), which is responsible for generating and signing [`IdToken`]'s in response to
/// [`AuthorizationRequest`]'s from [crate::relying_party::RelyingParty]'s (RPs). The [`Provider`] acts as a trusted intermediary between the RPs and
/// the user who is trying to authenticate.
#[derive(Debug)]
pub struct Provider {
pub subject: SigningSubject,
pub supported_subject_syntax_types: Vec<SubjectSyntaxType>,
Expand Down
2 changes: 1 addition & 1 deletion siopv2/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lazy_static! {
pub static ref TEST_KEYPAIR: SigningKey = SigningKey::generate(&mut OsRng);
}

#[derive(Derivative)]
#[derive(Derivative, Debug)]
#[derivative(Default)]
pub struct TestSubject {
#[derivative(Default(value = "did_url::DID::parse(\"did:test:123\").unwrap()"))]
Expand Down

0 comments on commit c2f3175

Please sign in to comment.