webcrypto-jwt
JSON Web Tokens (JWT) verify/sign implementation using W3C Web Cryptography (crypto.subtle).
Browser Support
The following browsers are supported without shims: IE TP, Firefox 35+ and Chrome 37+. Safari is not currently working. For more information about compatiblity check web cryptography browser support.
Install
With npm:
npm install webcrypto-jwt
or with bower:
bower install webcrypto-jwt
and then add the following script tag:
Usage
JWT verification and decoding:
var jwt = ; // token signed using 'secret' as secretvar token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.' + 'eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.' + 'TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ'; jwt; jwt; jwt; // '{"sub":"1234567890","name":"John Doe","admin":true}' jwt // Object {sub: "1234567890", name: "John Doe", admin: true}
JWT signing:
var signJWT = signJWT; ;