aries-vcx icon indicating copy to clipboard operation
aries-vcx copied to clipboard

Credential and Presentation attributes mime-type adjustments

Open bobozaur opened this issue 1 year ago • 4 comments

The attributes (CredentialAttr and PresentationAttr) could benefit from handling the value and mime-type pair in a different manner. Right now both fields are deserialized and handling would have to be done based on whether a MimeType is present or not.

A better idea would be to use an AttrValue #[serde(flatten)] enum with two variants:

  • Plain { value: String }
  • Encoded { value: String, mime_type: MaybeKnown<MimeType> }

Note the MaybeKnown enum use, which would also be a beneficial addition in case we get a mime_type we don't recognize.

Having the attribute value deserialized this way would make handling it easier since we can match and deduce that:

  • if it's Plain, it's just a string,
  • if it's Encoded, it's a base64 encoded string that then has to be processed according to the MimeType.

Steps: - [ ] Wrap MimeType in MaybeKnown - [ ] Create and use the AttrValue enum in both attribute types.

bobozaur avatar May 02 '23 07:05 bobozaur

@bobozaur I would like to work on this issue could you assign it to me plz.

SumantxD avatar May 05 '23 21:05 SumantxD

@bobozaur can you help me locate Attribute struct inside the file structure, i'am struggling to find it

SumantxD avatar May 06 '23 07:05 SumantxD

@SumantxD My bad, the struct rename was already done but I was looking at an older branch when drafting this issue. I updated the issue description to match the main branch.

bobozaur avatar May 06 '23 07:05 bobozaur

@bobozaur I have tried solving the issue here is the PR https://github.com/hyperledger/aries-vcx/pull/831

SumantxD avatar May 07 '23 10:05 SumantxD