Swiftpack.co - Package - vapor/jwt

JWT

Documentation Slack Team MIT License Continuous Integration Swift 4.1


Original author

Github

link
Stars: 168
Help us keep the lights on

Dependencies

Releases

3.0.0-rc.2.1 - Mar 25, 2018

Fixed:

  • Updated to latest crypto digest methods.

API Docs: https://api.vapor.codes/jwt/3.0.0-rc.2.1/JWT/

Milestone: 3.0.0-rc.2.1

3.0.0-rc.2 - Mar 21, 2018

New:

  • Vapor is now running on Swift NIO!

Milestone

3.0.0-rc.1 - Feb 28, 2018

New:

  • Added RS256, RS384, and RS512 signature support
import Crypto
import JWT

// create public and private key (only public required for verification)
let privateKey: Data = ...
let publicKey: Data = ...
let privateSigner = JWTSigner.rs256(key: .private2048(privateKey))
let publicSigner = JWTSigner.rs256(key: .public2048(publicKey))

// serialize jwt (requires private key)
let payload: TestPayload = ...
var jwt = JWT(payload: payload)
_ = try jwt.sign(using: publicSigner) // throws, can't sign w/ public signer
let data = try jwt.sign(using: privateSigner)

// parse jwt (public and private key work)
let parsed = try JWT<TestPayload>(from: data, verifiedUsing: publicSigner)
let parsed2 = try JWT<TestPayload>(from: data, verifiedUsing: privateSigner) // also works
print(parsed.payload)
print(parsed2.payload)

Milestone

3.0.0-beta.1.1 - Feb 15, 2018

3.0.0-beta.1 - Feb 12, 2018