@@ -10,23 +10,59 @@ import Foundation
1010
1111
1212struct JOSEHeader : Codable {
13- var type : String ?
13+ /// The "alg" (algorithm) identifies the cryptographic algorithm used to secure the JWS
1414 var algorithm : String ?
1515
16+ /// jwu
17+ // TODO
18+
19+ /// jwk
20+ // TODO
21+
22+ /// The "kid" (key ID) is a hint indicating which key was used to secure the JWS
23+ var keyID : String ?
24+
25+ /// x5u
26+ // TODO
27+
28+ /// x5c
29+ // TODO
30+
31+ /// x5t
32+ // TODO
33+
34+ /// x5t#S256
35+ // TODO
36+
37+ /// The "typ" (type) is used by JWS applications to declare the media type [IANA.MediaTypes] of this complete JWS
38+ var type : String ?
39+
40+ /// The "cty" (content type) is used by JWS application to declare the media type [IANA.MediaTypes] of the secured content (the payload).
41+ var contentType : String ?
42+
43+ /// The "crit" (critical) indicates that extensions to JWS, JWE and/or [JWA] are being used that MUST be understood and processed
44+ // TODO
45+
1646 init ( from decoder: Decoder ) throws {
1747 let container = try decoder. container ( keyedBy: CodingKeys . self)
18- type = try container. decodeIfPresent ( String . self, forKey: . type)
1948 algorithm = try container. decodeIfPresent ( String . self, forKey: . algorithm)
49+ keyID = try container. decodeIfPresent ( String . self, forKey: . keyID)
50+ type = try container. decodeIfPresent ( String . self, forKey: . type)
51+ contentType = try container. decodeIfPresent ( String . self, forKey: . contentType)
2052 }
2153
2254 func encode( to encoder: Encoder ) throws {
2355 var container = encoder. container ( keyedBy: CodingKeys . self)
24- try container. encodeIfPresent ( type, forKey: . type)
2556 try container. encodeIfPresent ( algorithm, forKey: . algorithm)
57+ try container. encodeIfPresent ( keyID, forKey: . keyID)
58+ try container. encodeIfPresent ( type, forKey: . type)
59+ try container. encodeIfPresent ( contentType, forKey: . contentType)
2660 }
2761
2862 enum CodingKeys : String , CodingKey {
29- case type = " typ "
3063 case algorithm = " alg "
64+ case keyID = " kid "
65+ case type = " typ "
66+ case contentType = " cty "
3167 }
3268}
0 commit comments