From 276293f2da807828e90bc0dc52ea279a798f94b2 Mon Sep 17 00:00:00 2001 From: Tiago Nascimento Date: Sat, 24 Aug 2024 00:52:15 -0300 Subject: [PATCH] Address PR comments: rename profile metadata to configuration Signed-off-by: Tiago Nascimento --- src/client.rs | 6 +++--- src/core/mod.rs | 8 ++++---- src/core/profiles/isomdl.rs | 10 +++++----- src/core/profiles/mod.rs | 24 ++++++++++++------------ src/core/profiles/w3c/jwt.rs | 10 +++++----- src/core/profiles/w3c/jwtld.rs | 8 ++++---- src/core/profiles/w3c/ldp.rs | 10 +++++----- src/metadata.rs | 28 ++++++++++++++-------------- src/profiles.rs | 4 ++-- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/client.rs b/src/client.rs index 666a85d..18aadf3 100644 --- a/src/client.rs +++ b/src/client.rs @@ -61,7 +61,7 @@ where batch_credential_endpoint: Option, deferred_credential_endpoint: Option, credential_response_encryption: Option>, - credential_configurations_supported: Vec>, + credential_configurations_supported: Vec>, display: Option>, } @@ -104,13 +104,13 @@ where set_batch_credential_endpoint -> batch_credential_endpoint[Option], set_deferred_credential_endpoint -> deferred_credential_endpoint[Option], set_credential_response_encryption -> credential_response_encryption[Option>], - set_credential_configurations_supported -> credential_configurations_supported[Vec>], + set_credential_configurations_supported -> credential_configurations_supported[Vec>], set_display -> display[Option>], } ]; pub fn from_issuer_metadata( - credential_issuer_metadata: CredentialIssuerMetadata, + credential_issuer_metadata: CredentialIssuerMetadata, authorization_metadata: AuthorizationMetadata, client_id: ClientId, redirect_uri: RedirectUrl, diff --git a/src/core/mod.rs b/src/core/mod.rs index 0c8bdf0..01eb862 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -5,10 +5,10 @@ pub mod metadata { use crate::metadata; - use super::profiles::CoreProfilesMetadata; + use super::profiles::CoreProfilesConfiguration; pub type CredentialIssuerMetadata = metadata::CredentialIssuerMetadata< - CoreProfilesMetadata, + CoreProfilesConfiguration, CoreJweContentEncryptionAlgorithm, CoreJweKeyManagementAlgorithm, >; @@ -72,7 +72,7 @@ mod test { CredentialUrl::from_url("https://example.com/credential".parse().unwrap()), vec![CredentialMetadata::new( "credential1".into(), - profiles::CoreProfilesMetadata::JWTVC(w3c::jwt::Metadata::new( + profiles::CoreProfilesConfiguration::JWTVC(w3c::jwt::Configuration::new( w3c::CredentialDefinition::new(vec!["type1".into()]), )), )], @@ -87,7 +87,7 @@ mod test { CredentialUrl::from_url("https://example.com/credential".parse().unwrap()), vec![CredentialMetadata::new( "credential1".into(), - profiles::CoreProfilesMetadata::LDVC(w3c::ldp::Metadata::new( + profiles::CoreProfilesConfiguration::LDVC(w3c::ldp::Configuration::new( vec![serde_json::Value::String( "http://example.com/context".into(), )], diff --git a/src/core/profiles/isomdl.rs b/src/core/profiles/isomdl.rs index 1e8903d..d508186 100644 --- a/src/core/profiles/isomdl.rs +++ b/src/core/profiles/isomdl.rs @@ -4,21 +4,21 @@ use isomdl::definitions::device_request::DocType; use serde::{Deserialize, Serialize}; use super::{ - w3c::CredentialSubjectClaims, AuthorizationDetailsProfile, CredentialMetadataProfile, + w3c::CredentialSubjectClaims, AuthorizationDetailsProfile, CredentialConfigurationProfile, CredentialOfferProfile, CredentialRequestProfile, CredentialResponseProfile, }; pub type Namespace = String; #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct Metadata { +pub struct Configuration { // credential_signing_alg_values_supported: Option>, // TODO cose doctype: DocType, claims: Option>, order: Option>, } -impl Metadata { +impl Configuration { pub fn new(doctype: DocType) -> Self { Self { doctype, @@ -34,7 +34,7 @@ impl Metadata { } ]; } -impl CredentialMetadataProfile for Metadata { +impl CredentialConfigurationProfile for Configuration { type Request = Request; fn to_request(&self) -> Self::Request { @@ -151,7 +151,7 @@ mod test { #[test] fn example_metadata() { - let _: Metadata = serde_json::from_value(json!({ + let _: Configuration = serde_json::from_value(json!({ "doctype": "org.iso.18013.5.1.mDL", "claims": { "org.iso.18013.5.1": { diff --git a/src/core/profiles/mod.rs b/src/core/profiles/mod.rs index 9ee8298..cdcf5bd 100644 --- a/src/core/profiles/mod.rs +++ b/src/core/profiles/mod.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use serde::{Deserialize, Serialize}; use crate::profiles::{ - AuthorizationDetailsProfile, CredentialMetadataProfile, CredentialOfferProfile, + AuthorizationDetailsProfile, CredentialConfigurationProfile, CredentialOfferProfile, CredentialRequestProfile, CredentialResponseProfile, Profile, }; @@ -12,7 +12,7 @@ pub mod w3c; pub struct CoreProfiles {} impl Profile for CoreProfiles { - type Metadata = CoreProfilesMetadata; + type Configuration = CoreProfilesConfiguration; type Offer = CoreProfilesOffer; type Authorization = CoreProfilesAuthorizationDetails; type Credential = CoreProfilesRequest; @@ -20,31 +20,31 @@ impl Profile for CoreProfiles { #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(tag = "format")] -pub enum CoreProfilesMetadata { +pub enum CoreProfilesConfiguration { #[serde(rename = "jwt_vc_json")] - JWTVC(w3c::jwt::Metadata), + JWTVC(w3c::jwt::Configuration), #[serde(rename = "jwt_vc_json-ld")] - JWTLDVC(w3c::jwtld::Metadata), + JWTLDVC(w3c::jwtld::Configuration), #[serde(rename = "ldp_vc")] - LDVC(w3c::ldp::Metadata), + LDVC(w3c::ldp::Configuration), #[serde(rename = "mso_mdoc")] - ISOmDL(isomdl::Metadata), + ISOmDL(isomdl::Configuration), } -impl CredentialMetadataProfile for CoreProfilesMetadata { +impl CredentialConfigurationProfile for CoreProfilesConfiguration { type Request = CoreProfilesRequest; fn to_request(&self) -> Self::Request { match self { - CoreProfilesMetadata::JWTVC(m) => { + CoreProfilesConfiguration::JWTVC(m) => { Self::Request::Value(ValueRequest::JWTVC(m.to_request())) } - CoreProfilesMetadata::JWTLDVC(m) => { + CoreProfilesConfiguration::JWTLDVC(m) => { Self::Request::Value(ValueRequest::JWTLDVC(m.to_request())) } - CoreProfilesMetadata::LDVC(m) => { + CoreProfilesConfiguration::LDVC(m) => { Self::Request::Value(ValueRequest::LDVC(m.to_request())) } - CoreProfilesMetadata::ISOmDL(m) => { + CoreProfilesConfiguration::ISOmDL(m) => { Self::Request::Value(ValueRequest::ISOmDL(m.to_request())) } } diff --git a/src/core/profiles/w3c/jwt.rs b/src/core/profiles/w3c/jwt.rs index a13f2aa..5748c33 100644 --- a/src/core/profiles/w3c/jwt.rs +++ b/src/core/profiles/w3c/jwt.rs @@ -2,20 +2,20 @@ use serde::{Deserialize, Serialize}; use ssi_claims::CompactJWSString; use crate::profiles::{ - AuthorizationDetailsProfile, CredentialMetadataProfile, CredentialOfferProfile, + AuthorizationDetailsProfile, CredentialConfigurationProfile, CredentialOfferProfile, CredentialRequestProfile, CredentialResponseProfile, }; use super::{CredentialDefinition, CredentialOfferDefinition}; #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct Metadata { +pub struct Configuration { credential_signing_alg_values_supported: Option>, credential_definition: CredentialDefinition, order: Option>, } -impl Metadata { +impl Configuration { pub fn new(credential_definition: CredentialDefinition) -> Self { Self { credential_signing_alg_values_supported: None, @@ -31,7 +31,7 @@ impl Metadata { } ]; } -impl CredentialMetadataProfile for Metadata { +impl CredentialConfigurationProfile for Configuration { type Request = Request; fn to_request(&self) -> Self::Request { @@ -141,7 +141,7 @@ mod test { #[test] fn example_metadata() { - let _: Metadata = serde_json::from_value(json!({ + let _: Configuration = serde_json::from_value(json!({ "credential_definition":{ "type": [ "VerifiableCredential", diff --git a/src/core/profiles/w3c/jwtld.rs b/src/core/profiles/w3c/jwtld.rs index cba8a01..489cd49 100644 --- a/src/core/profiles/w3c/jwtld.rs +++ b/src/core/profiles/w3c/jwtld.rs @@ -1,18 +1,18 @@ use serde::{Deserialize, Serialize}; use crate::profiles::{ - AuthorizationDetailsProfile, CredentialMetadataProfile, CredentialOfferProfile, + AuthorizationDetailsProfile, CredentialConfigurationProfile, CredentialOfferProfile, CredentialRequestProfile, CredentialResponseProfile, }; use super::{CredentialDefinitionLD, CredentialOfferDefinitionLD}; #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct Metadata { +pub struct Configuration { credential_definition: CredentialDefinitionLD, } -impl Metadata { +impl Configuration { pub fn new(credential_definition: CredentialDefinitionLD) -> Self { Self { credential_definition, @@ -26,7 +26,7 @@ impl Metadata { ]; } -impl CredentialMetadataProfile for Metadata { +impl CredentialConfigurationProfile for Configuration { type Request = Request; fn to_request(&self) -> Self::Request { diff --git a/src/core/profiles/w3c/ldp.rs b/src/core/profiles/w3c/ldp.rs index eef9452..8d9d556 100644 --- a/src/core/profiles/w3c/ldp.rs +++ b/src/core/profiles/w3c/ldp.rs @@ -5,14 +5,14 @@ use ssi_claims::{ }; use crate::profiles::{ - AuthorizationDetailsProfile, CredentialMetadataProfile, CredentialOfferProfile, + AuthorizationDetailsProfile, CredentialConfigurationProfile, CredentialOfferProfile, CredentialRequestProfile, CredentialResponseProfile, }; use super::{CredentialDefinitionLD, CredentialOfferDefinitionLD}; #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct Metadata { +pub struct Configuration { credential_signing_alg_values_supported: Option>, #[serde(rename = "@context")] context: Vec, @@ -21,7 +21,7 @@ pub struct Metadata { order: Option>, } -impl Metadata { +impl Configuration { pub fn new( context: Vec, credential_definition: CredentialDefinitionLD, @@ -42,7 +42,7 @@ impl Metadata { } ]; } -impl CredentialMetadataProfile for Metadata { +impl CredentialConfigurationProfile for Configuration { type Request = Request; fn to_request(&self) -> Self::Request { @@ -157,7 +157,7 @@ mod test { #[test] fn example_metadata() { - let _: Metadata = serde_json::from_value(json!({ + let _: Configuration = serde_json::from_value(json!({ "@context": [ "https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1" diff --git a/src/metadata.rs b/src/metadata.rs index 7f20f1d..567077c 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -22,7 +22,7 @@ use tracing::{debug, info, warn}; use crate::{ credential_response_encryption::CredentialResponseEncryptionMetadata, http_utils::{check_content_type, MIME_TYPE_JSON}, - profiles::CredentialMetadataProfile, + profiles::CredentialConfigurationProfile, proof_of_possession::KeyProofTypesSupported, types::ImageUrl, }; @@ -39,7 +39,7 @@ const AUTHORIZATION_METADATA_URL_SUFFIX: &str = ".well-known/oauth-authorization #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct CredentialIssuerMetadata where - CM: CredentialMetadataProfile, + CM: CredentialConfigurationProfile, JE: JweContentEncryptionAlgorithm, JA: JweKeyManagementAlgorithm + Clone, { @@ -54,14 +54,14 @@ where credential_identifiers_supported: Option, signed_metadata: Option, display: Option>, - #[serde(bound = "CM: CredentialMetadataProfile")] + #[serde(bound = "CM: CredentialConfigurationProfile")] #[serde_as(as = "KeyValueMap<_>")] credential_configurations_supported: Vec>, } impl CredentialIssuerMetadata where - CM: CredentialMetadataProfile, + CM: CredentialConfigurationProfile, JE: JweContentEncryptionAlgorithm, JA: JweKeyManagementAlgorithm + Clone, { @@ -254,7 +254,7 @@ impl MetadataDisplayLogo { #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct CredentialMetadata where - CM: CredentialMetadataProfile, + CM: CredentialConfigurationProfile, { #[serde(rename = "$key$")] name: String, @@ -263,7 +263,7 @@ where #[serde_as(as = "Option>")] proof_types_supported: Option>, display: Option>, - #[serde(bound = "CM: CredentialMetadataProfile")] + #[serde(bound = "CM: CredentialConfigurationProfile")] #[serde(flatten)] additional_fields: CM, } @@ -281,7 +281,7 @@ where impl CredentialMetadata where - CM: CredentialMetadataProfile, + CM: CredentialConfigurationProfile, { pub fn new(name: String, additional_fields: CM) -> Self { Self { @@ -486,7 +486,7 @@ impl AuthorizationMetadata { ) -> Result::Error>> where C: SyncHttpClient, - CM: CredentialMetadataProfile, + CM: CredentialConfigurationProfile, JE: JweContentEncryptionAlgorithm, JA: JweKeyManagementAlgorithm + Clone, { @@ -557,7 +557,7 @@ impl AuthorizationMetadata { where Self: 'c, C: AsyncHttpClient<'c>, - CM: CredentialMetadataProfile, + CM: CredentialConfigurationProfile, JE: JweContentEncryptionAlgorithm, JA: JweKeyManagementAlgorithm + Clone, { @@ -668,7 +668,7 @@ impl AuthorizationMetadata { #[cfg(test)] mod test { - use crate::core::profiles::CoreProfilesMetadata; + use crate::core::profiles::CoreProfilesConfiguration; use serde_json::json; use super::*; @@ -676,7 +676,7 @@ mod test { #[test] fn example_credential_issuer_metadata() { let _: CredentialIssuerMetadata< - CoreProfilesMetadata, + CoreProfilesConfiguration, CoreJweContentEncryptionAlgorithm, CoreJweKeyManagementAlgorithm, > = serde_json::from_value(json!({ @@ -775,7 +775,7 @@ mod test { #[test] fn example_credential_metadata_jwt() { - let _: CredentialMetadata = serde_json::from_value(json!({ + let _: CredentialMetadata = serde_json::from_value(json!({ "$key$": "name", // purely for test reason, you cannot really deserialize CredentialMetadata on its own "format": "jwt_vc_json", "id": "UniversityDegree_JWT", @@ -845,7 +845,7 @@ mod test { #[test] fn example_credential_metadata_ldp() { - let _: CredentialMetadata = serde_json::from_value(json!({ + let _: CredentialMetadata = serde_json::from_value(json!({ "$key$": "name", // purely for test reason, you cannot really deserialize CredentialMetadata on its own "format": "ldp_vc", "@context": [ @@ -919,7 +919,7 @@ mod test { #[test] fn example_credential_metadata_isomdl() { - let _: CredentialMetadata = serde_json::from_value(json!({ + let _: CredentialMetadata = serde_json::from_value(json!({ "$key$": "name", // purely for test reason, you cannot really deserialize CredentialMetadata on its own "format": "mso_mdoc", "doctype": "org.iso.18013.5.1.mDL", diff --git a/src/profiles.rs b/src/profiles.rs index e5493a4..a12a674 100644 --- a/src/profiles.rs +++ b/src/profiles.rs @@ -3,12 +3,12 @@ use std::fmt::Debug; use serde::{de::DeserializeOwned, Serialize}; pub trait Profile { - type Metadata: CredentialMetadataProfile; + type Configuration: CredentialConfigurationProfile; type Offer: CredentialOfferProfile; type Authorization: AuthorizationDetailsProfile; type Credential: CredentialRequestProfile; } -pub trait CredentialMetadataProfile: Clone + Debug + DeserializeOwned + Serialize { +pub trait CredentialConfigurationProfile: Clone + Debug + DeserializeOwned + Serialize { type Request: CredentialRequestProfile; fn to_request(&self) -> Self::Request;