@@ -10,23 +10,59 @@ import Foundation
10
10
11
11
12
12
struct JOSEHeader : Codable {
13
- var type : String ?
13
+ /// The "alg" (algorithm) identifies the cryptographic algorithm used to secure the JWS
14
14
var algorithm : String ?
15
15
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
+
16
46
init ( from decoder: Decoder ) throws {
17
47
let container = try decoder. container ( keyedBy: CodingKeys . self)
18
- type = try container. decodeIfPresent ( String . self, forKey: . type)
19
48
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)
20
52
}
21
53
22
54
func encode( to encoder: Encoder ) throws {
23
55
var container = encoder. container ( keyedBy: CodingKeys . self)
24
- try container. encodeIfPresent ( type, forKey: . type)
25
56
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)
26
60
}
27
61
28
62
enum CodingKeys : String , CodingKey {
29
- case type = " typ "
30
63
case algorithm = " alg "
64
+ case keyID = " kid "
65
+ case type = " typ "
66
+ case contentType = " cty "
31
67
}
32
68
}
0 commit comments