11//! Catalyst Signed Document Metadata.
22use std:: fmt:: { Display , Formatter } ;
33
4- mod algorithm;
54mod content_encoding;
65mod content_type;
76mod document_ref;
87mod extra_fields;
98mod section;
109pub ( crate ) mod utils;
1110
12- pub use algorithm:: Algorithm ;
1311use catalyst_types:: {
1412 problem_report:: ProblemReport ,
1513 uuid:: { UuidV4 , UuidV7 } ,
@@ -42,8 +40,6 @@ pub struct Metadata(InnerMetadata);
4240/// An actual representation of all metadata fields.
4341#[ derive( Clone , Debug , PartialEq , serde:: Deserialize , Default ) ]
4442pub ( crate ) struct InnerMetadata {
45- /// Cryptographic Algorithm
46- alg : Option < Algorithm > ,
4743 /// Document Type `UUIDv4`.
4844 #[ serde( rename = "type" ) ]
4945 doc_type : Option < UuidV4 > ,
@@ -63,14 +59,6 @@ pub(crate) struct InnerMetadata {
6359}
6460
6561impl Metadata {
66- /// Return Document Cryptographic Algorithm
67- ///
68- /// # Errors
69- /// - Missing 'alg' field.
70- pub fn algorithm ( & self ) -> anyhow:: Result < Algorithm > {
71- self . 0 . alg . ok_or ( anyhow:: anyhow!( "Missing 'alg' field" ) )
72- }
73-
7462 /// Return Document Type `UUIDv4`.
7563 ///
7664 /// # Errors
@@ -121,9 +109,6 @@ impl Metadata {
121109
122110 /// Build `Metadata` object from the metadata fields, doing all necessary validation.
123111 pub ( crate ) fn from_metadata_fields ( metadata : InnerMetadata , report : & ProblemReport ) -> Self {
124- if metadata. alg . is_none ( ) {
125- report. missing_field ( "alg" , "Missing alg field in COSE protected header" ) ;
126- }
127112 if metadata. doc_type . is_none ( ) {
128113 report. missing_field ( "type" , "Missing type field in COSE protected header" ) ;
129114 }
@@ -181,20 +166,6 @@ impl InnerMetadata {
181166 ..Self :: default ( )
182167 } ;
183168
184- if let Some ( coset:: RegisteredLabelWithPrivate :: Assigned ( alg) ) = protected. header . alg {
185- match Algorithm :: try_from ( alg) {
186- Ok ( alg) => metadata. alg = Some ( alg) ,
187- Err ( e) => {
188- report. conversion_error (
189- "COSE protected header algorithm" ,
190- & format ! ( "{alg:?}" ) ,
191- & format ! ( "Expected Algorithm: {e}" ) ,
192- & format ! ( "{COSE_DECODING_CONTEXT}, Algorithm" ) ,
193- ) ;
194- } ,
195- }
196- }
197-
198169 if let Some ( value) = protected. header . content_type . as_ref ( ) {
199170 match ContentType :: try_from ( value) {
200171 Ok ( ct) => metadata. content_type = Some ( ct) ,
@@ -260,7 +231,6 @@ impl Display for Metadata {
260231 writeln ! ( f, " type: {:?}," , self . 0 . doc_type) ?;
261232 writeln ! ( f, " id: {:?}," , self . 0 . id) ?;
262233 writeln ! ( f, " ver: {:?}," , self . 0 . ver) ?;
263- writeln ! ( f, " alg: {:?}," , self . 0 . alg) ?;
264234 writeln ! ( f, " content_type: {:?}" , self . 0 . content_type) ?;
265235 writeln ! ( f, " content_encoding: {:?}" , self . 0 . content_encoding) ?;
266236 writeln ! ( f, " additional_fields: {:?}," , self . 0 . extra) ?;
@@ -273,7 +243,6 @@ impl TryFrom<&Metadata> for coset::Header {
273243
274244 fn try_from ( meta : & Metadata ) -> Result < Self , Self :: Error > {
275245 let mut builder = coset:: HeaderBuilder :: new ( )
276- . algorithm ( meta. algorithm ( ) ?. into ( ) )
277246 . content_format ( CoapContentFormat :: from ( meta. content_type ( ) ?) ) ;
278247
279248 if let Some ( content_encoding) = meta. content_encoding ( ) {
0 commit comments