Skip to content

Commit

Permalink
Address PR comments: rename profile metadata to configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Nascimento <tiago.nascimento@spruceid.com>
  • Loading branch information
theosirian committed Aug 24, 2024
1 parent aa5f9c8 commit 276293f
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 54 deletions.
6 changes: 3 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
batch_credential_endpoint: Option<BatchCredentialUrl>,
deferred_credential_endpoint: Option<DeferredCredentialUrl>,
credential_response_encryption: Option<CredentialResponseEncryptionMetadata<JE, JA>>,
credential_configurations_supported: Vec<CredentialMetadata<C::Metadata>>,
credential_configurations_supported: Vec<CredentialMetadata<C::Configuration>>,
display: Option<Vec<CredentialIssuerMetadataDisplay>>,
}

Expand Down Expand Up @@ -104,13 +104,13 @@ where
set_batch_credential_endpoint -> batch_credential_endpoint[Option<BatchCredentialUrl>],
set_deferred_credential_endpoint -> deferred_credential_endpoint[Option<DeferredCredentialUrl>],
set_credential_response_encryption -> credential_response_encryption[Option<CredentialResponseEncryptionMetadata<JE, JA>>],
set_credential_configurations_supported -> credential_configurations_supported[Vec<CredentialMetadata<C::Metadata>>],
set_credential_configurations_supported -> credential_configurations_supported[Vec<CredentialMetadata<C::Configuration>>],
set_display -> display[Option<Vec<CredentialIssuerMetadataDisplay>>],
}
];

pub fn from_issuer_metadata(
credential_issuer_metadata: CredentialIssuerMetadata<C::Metadata, JE, JA>,
credential_issuer_metadata: CredentialIssuerMetadata<C::Configuration, JE, JA>,
authorization_metadata: AuthorizationMetadata,
client_id: ClientId,
redirect_uri: RedirectUrl,
Expand Down
8 changes: 4 additions & 4 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
>;
Expand Down Expand Up @@ -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()]),
)),
)],
Expand All @@ -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(),
)],
Expand Down
10 changes: 5 additions & 5 deletions src/core/profiles/isomdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<cose::Algorithm>>, // TODO cose
doctype: DocType,
claims: Option<HashMap<Namespace, CredentialSubjectClaims>>,
order: Option<Vec<String>>,
}

impl Metadata {
impl Configuration {
pub fn new(doctype: DocType) -> Self {
Self {
doctype,
Expand All @@ -34,7 +34,7 @@ impl Metadata {
}
];
}
impl CredentialMetadataProfile for Metadata {
impl CredentialConfigurationProfile for Configuration {
type Request = Request;

fn to_request(&self) -> Self::Request {
Expand Down Expand Up @@ -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": {
Expand Down
24 changes: 12 additions & 12 deletions src/core/profiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt::Debug;
use serde::{Deserialize, Serialize};

use crate::profiles::{
AuthorizationDetailsProfile, CredentialMetadataProfile, CredentialOfferProfile,
AuthorizationDetailsProfile, CredentialConfigurationProfile, CredentialOfferProfile,
CredentialRequestProfile, CredentialResponseProfile, Profile,
};

Expand All @@ -12,39 +12,39 @@ 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;
}

#[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()))
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/profiles/w3c/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<ssi_jwk::Algorithm>>,
credential_definition: CredentialDefinition,
order: Option<Vec<String>>,
}

impl Metadata {
impl Configuration {
pub fn new(credential_definition: CredentialDefinition) -> Self {
Self {
credential_signing_alg_values_supported: None,
Expand All @@ -31,7 +31,7 @@ impl Metadata {
}
];
}
impl CredentialMetadataProfile for Metadata {
impl CredentialConfigurationProfile for Configuration {
type Request = Request;

fn to_request(&self) -> Self::Request {
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/core/profiles/w3c/jwtld.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -26,7 +26,7 @@ impl Metadata {
];
}

impl CredentialMetadataProfile for Metadata {
impl CredentialConfigurationProfile for Configuration {
type Request = Request;

fn to_request(&self) -> Self::Request {
Expand Down
10 changes: 5 additions & 5 deletions src/core/profiles/w3c/ldp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<String>>,
#[serde(rename = "@context")]
context: Vec<serde_json::Value>,
Expand All @@ -21,7 +21,7 @@ pub struct Metadata {
order: Option<Vec<String>>,
}

impl Metadata {
impl Configuration {
pub fn new(
context: Vec<serde_json::Value>,
credential_definition: CredentialDefinitionLD,
Expand All @@ -42,7 +42,7 @@ impl Metadata {
}
];
}
impl CredentialMetadataProfile for Metadata {
impl CredentialConfigurationProfile for Configuration {
type Request = Request;

fn to_request(&self) -> Self::Request {
Expand Down Expand Up @@ -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"
Expand Down
Loading

0 comments on commit 276293f

Please sign in to comment.