JWT-Verifier
JWT (JSON Web Tokens) and JWKS (JSON Web Key Set) verifier for node / typescript (https://jwt.io)
Works with Express (https://expressjs.com/)
Uses jsrsasign to verify tokens (https://kjur.github.io/jsrsasign/)
Supported Algorithms
- RS256
- HS256
Installation
npm install jwt-verifier --save
Usage
Basic
// JWTVerifier.verify() returns an Observable (http://reactivex.io/rxjs/)JWTVerifier;
Express middleware
; ; ; const app: express.Express = ; // Needed if you wish to auto retrieve your JWKS from a URL. JWTConfiginstanceCERT_URL = "https://somejkwserver/jwks"; // Add express middleware to check auth token app;
API
- JWTVerifier.verify(token: string, key?: string | RSAKey, acceptFieldParams?: AcceptFieldParams) - returns Observable<boolean> (http://reactivex.io/rxjs/).
- token: string | required
- key: string (HS256 key) or RSAKey | optional - see https://kjur.github.io/jsrsasign/api/symbols/KJUR.jws.JWS.html#.verifyJWT
- acceptFieldParams: Object | optional - see https://kjur.github.io/jsrsasign/api/symbols/KJUR.jws.JWS.html#.verifyJWT
Contributions
Contributions are welcome via issues / pull requests
Tests
Unit tests are run with npm run test
Build
Build is run with npm run build