GitXplorerGitXplorer
L

JWTWrapper

public
3 stars
1 forks
0 issues

Commits

List of commits on branch master.
Verified
8f8e04ff13c31b68bb0a3d021ace13ea3573be2b

Merge pull request #2 from jhoogstraat/patch-1

LLucianoPAlmeida committed 5 years ago
Verified
2d64d55b0c0facf708832f42e4205544e94dfd7b

Create Package.swift

jjhoogstraat committed 5 years ago
Unverified
22b7333f8ab285ba1ea15e5a98ff97c5b0f4eccc

Bump spec.

committed 7 years ago
Unverified
b68305277b7a9d03806d0d8ab0046ae397bae2af

Updating tests to expired token.

committed 7 years ago
Verified
f4411de9bca11e32d288a6291ca028814e36862b

Merge pull request #1 from siggb/patch-1

LLucianoPAlmeida committed 7 years ago
Verified
f7ed493d47865cbedf9007c1f2c16d93e65d1f49

Fix `isExpired` dates comparison logic

committed 7 years ago

README

The README file for this repository.

JWTWrapper

license Travis Codecov

This is a convenience library to wrapper the JWT in a structure and make more parser easier. This is NOT a JWT issuer or validator, is just a simple abstraction to parse token payload and info in your app.

Instalation

Carthage

  github "LucianoPAlmeida/JWTWrapper" ~> 1.0

CocoaPods

    pod 'JWTWrapper', '~> 1.0'

Usage

       let jwt = JWT(string: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNZSIsImlhdCI6MTUwNjI4Nzg3MCwiZXhwIjoxNTA2Mzc0MjcwLCJhdWQiOiJ3d3cuZXhhbXBsZS5jb20iLCJzdWIiOiJleGVtcGxlIiwianRpIjoiand0aWQxMCIsIm5iZiI6MTUwNjM3NDI3MCwiZmlyc3RfbmFtZSI6IkpvaG4iLCJsYXN0X25hbWUiOiJEb2UiLCJlbWFpbCI6ImRvZUBleGFtcGxlLmNvbSIsImlkIjoxMiwiaGVpZ2h0IjoxLjc1LCJudW1iZXIiOjc4OX0.sJVuJ39lIouTnTEYlE_0ZlXVp8GXCy9Z7djQwZUDwLI")
       
       // Headers
       jwt.algorithm // "HS256"
       jwt.type //"JWT"
       
       // Claims
       jwt.issuer //"Me"
       jwt.audience //"www.example.com")
       jwt.subject //"exemple"
       jwt.issuedAt //"2017-09-24"
       jwt.expirationDate //"2017-09-25"
       jwt.id //"jwtid10" 
       jwt.notBefore //"2017-09-25"
       jwt.isExpired //false or true in case its expired
       
       //Payload
       jwt.payload["first_name"] // "John"
       jwt.payload.string(for: "last_name") //"Doe"
       jwt.payload.string(for: "email") // "doe@example.com"
       jwt.payload.int(for: "id") // 12
       jwt.payload.double(for: "height") // 1.75
       jwt.payload.float(for: "height") // 1.75
       jwt.payload.number(for: "number") // 789
   

Licence

JWTWrapper is released under the MIT License.