Skip to content

Commit b724a55

Browse files
committed
Added rawValue accessor for Claim
Added Example to Playground Added Tests
1 parent d455f44 commit b724a55

File tree

4 files changed

+54
-30
lines changed

4 files changed

+54
-30
lines changed

JWTDecode.playground/Contents.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import JWTDecode
99
/*:
1010
Then paste here the token you wish to decode
1111
*/
12-
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tIiwic3ViIjoiYXV0aDB8MTAxMDEwMTAxMCIsImF1ZCI6Imh0dHBzOi8vc2FtcGxlcy5hdXRoMC5jb20iLCJleHAiOjEzNzI2NzQzMzYsImlhdCI6MTM3MjYzODMzNiwianRpIjoicXdlcnR5MTIzNDU2IiwibmJmIjoxMzcyNjM4MzM2fQ.LvF9wSheCB5xarpydmurWgi9NOZkdES5AbNb_UWk9Ew"
12+
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tIiwic3ViIjoiYXV0aDB8MTAxMDEwMTAxMCIsImF1ZCI6Imh0dHBzOi8vc2FtcGxlcy5hdXRoMC5jb20iLCJleHAiOjEzNzI2NzQzMzYsImlhdCI6MTM3MjYzODMzNiwianRpIjoicXdlcnR5MTIzNDU2IiwibmJmIjoxMzcyNjM4MzM2LCJlbWFpbCI6InVzZXJAaG9zdC5jb20iLCJjdXN0b20iOlsxLDIsM119.JeMRyHLkcoiqGxd958B6PABKNvhOhIgw-kbjecmhR_E"
1313
//: You can generate a new token in [jwt.io](http://jwt.io)
1414

1515
/*:
@@ -44,11 +44,12 @@ do {
4444
jwt.issuedAt
4545
//: "exp" (Expiration Time)
4646
jwt.expiresAt
47-
4847
//: ### Custom Claims
4948
//: If we also have our custom claims we can retrive them calling `claim<T>(name: String) -> T?` where `T` is the value type of the claim, e.g.: a `String`
5049

5150
_ = jwt.claim(name: "email").string
51+
52+
_ = jwt.claim(name: "custom").rawValue as? [Int]
5253
//: ### Error Handling
5354
//: If the token is invalid an `NSError` will be thrown
5455
} catch let error as NSError {

0 commit comments

Comments
 (0)