Latest 1.0.3
Homepage https://github.com/LucianoPAlmeida/JWTWrapper
License MIT
Platforms ios 10.0
Authors

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") // "[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

Licence

JWTWrapper is released under the MIT License.

Latest podspec

{
    "name": "JWTWrapper",
    "version": "1.0.3",
    "summary": "A Convenience class to wrapper the JWT token string",
    "description": "Convenience class for wrapper JWT to easilly get info and payload data. This is NOT an issuer or validator library is just a simple wrapper to parse the token in a structure.",
    "homepage": "https://github.com/LucianoPAlmeida/JWTWrapper",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "LucianoAlmeida": "[email protected]"
    },
    "source": {
        "git": "https://github.com/LucianoPAlmeida/JWTWrapper.git",
        "tag": "1.0.3"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "JWTWrapper/**/*.{swift,h}",
    "public_header_files": "JWTWrapper/JWTWrapper.h"
}

Pin It on Pinterest

Share This