https://github.com/lucianopalmeida/jwtwrapper
A Convenience class to wrapper the JWT token string
https://github.com/lucianopalmeida/jwtwrapper
convenience ios jwt jwt-token parser pods swift swift4 wrapper wrapper-api
Last synced: 5 months ago
JSON representation
A Convenience class to wrapper the JWT token string
- Host: GitHub
- URL: https://github.com/lucianopalmeida/jwtwrapper
- Owner: LucianoPAlmeida
- License: mit
- Created: 2017-09-26T21:43:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-14T12:13:06.000Z (over 5 years ago)
- Last Synced: 2024-11-18T04:16:40.968Z (5 months ago)
- Topics: convenience, ios, jwt, jwt-token, parser, pods, swift, swift4, wrapper, wrapper-api
- Language: Swift
- Size: 31.3 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JWTWrapper
[](https://opensource.org/licenses/MIT)
[](https://travis-ci.org/LucianoPAlmeida/JWTWrapper)
[](https://codecov.io/gh/LucianoPAlmeida/JWTWrapper)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
```swift
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") // "[email protected]"
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
```
# LicenceJWTWrapper is released under the [MIT License](https://opensource.org/licenses/MIT).