File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1
1
# JSON Web Token Changelog
2
2
3
+ ## Master
4
+
5
+ ### Enhancements
6
+
7
+ - Introduces a new ` ClaimSet ` structure. The structure can be returned from
8
+ ` decode ` providing you convenience accessors. ` encode ` will now accept a
9
+ ` ClaimSet ` .
10
+
11
+
3
12
## 2.0.2
4
13
5
14
### Enhancements
Original file line number Diff line number Diff line change @@ -21,7 +21,18 @@ import JWT
21
21
### Encoding a claim
22
22
23
23
``` swift
24
- JWT.encode ([" my" : " payload" ], algorithm : .hs256 (" secret" .data (using : .utf8 )! ))
24
+ JWT.encode (claims : [" my" : " payload" ], algorithm : .hs256 (" secret" .data (using : .utf8 )! ))
25
+ ```
26
+
27
+ #### Encoding a claim set
28
+
29
+ ``` swift
30
+ var claims = ClaimSet ()
31
+ claims.issuer = " fuller.li"
32
+ claims.issuedAt = Date ()
33
+ claims[" custom" ] = " Hi"
34
+
35
+ JWT.encode (claims : claims, algorithm, algorithm : .hs256 (" secret" .data (using : .utf8 )))
25
36
```
26
37
27
38
#### Building a JWT with the builder pattern
@@ -40,8 +51,8 @@ When decoding a JWT, you must supply one or more algorithms and keys.
40
51
41
52
``` swift
42
53
do {
43
- let payload = try JWT.decode (" eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w" , algorithm : .hs256 (" secret" .data (using : .utf8 )! ))
44
- print (payload )
54
+ let claims = try JWT.decode (" eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w" , algorithm : .hs256 (" secret" .data (using : .utf8 )! ))
55
+ print (claims )
45
56
} catch {
46
57
print (" Failed to decode JWT: \( error ) " )
47
58
}
@@ -79,4 +90,3 @@ This library supports the following algorithms:
79
90
## License
80
91
81
92
JSONWebToken is licensed under the BSD license. See [ LICENSE] ( LICENSE ) for more info.
82
-
You can’t perform that action at this time.
0 commit comments