jwt-simple
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -46,3 +46,3 @@ /* | ||
*/ | ||
jwt.version = '0.5.0'; | ||
jwt.version = '0.5.1'; | ||
@@ -86,2 +86,8 @@ /** | ||
// verify signature. `sign` will return base64 string. | ||
var signingInput = [headerSeg, payloadSeg].join('.'); | ||
if (!verify(signingInput, key, signingMethod, signingType, signatureSeg)) { | ||
throw new Error('Signature verification failed'); | ||
} | ||
// Support for nbf and exp claims. | ||
@@ -96,8 +102,2 @@ // According to the RFC, they should be in seconds. | ||
} | ||
// verify signature. `sign` will return base64 string. | ||
var signingInput = [headerSeg, payloadSeg].join('.'); | ||
if (!verify(signingInput, key, signingMethod, signingType, signatureSeg)) { | ||
throw new Error('Signature verification failed'); | ||
} | ||
} | ||
@@ -104,0 +104,0 @@ |
{ | ||
"name": "jwt-simple", | ||
"description": "JWT(JSON Web Token) encode and decode module", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"author": "Kazuhito Hokamura <k.hokamura@gmail.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -16,2 +16,5 @@ # node-jwt-simple | ||
// HS256 secrets are typically 128-bit random strings, for example hex-encoded: | ||
// var secret = Buffer.from('fe1a1915a379f3be5394b64d14794932', 'hex) | ||
// encode | ||
@@ -25,2 +28,24 @@ var token = jwt.encode(payload, secret); | ||
### decode params | ||
```javascript | ||
/* | ||
* jwt.decode(token, key, noVerify, algorithm) | ||
*/ | ||
// decode, by default the signature of the token is verified | ||
var decoded = jwt.decode(token, secret); | ||
console.log(decoded); //=> { foo: 'bar' } | ||
// decode without verify the signature of the token, | ||
// be sure to KNOW WHAT ARE YOU DOING because not verify the signature | ||
// means you can't be sure that someone hasn't modified the token payload | ||
var decoded = jwt.decode(token, secret, true); | ||
console.log(decoded); //=> { foo: 'bar' } | ||
// decode with a specific algorithm (not using the algorithm described in the token payload) | ||
var decoded = jwt.decode(token, secret, false, 'HS256'); | ||
console.log(decoded); //=> { foo: 'bar' } | ||
``` | ||
### Algorithms | ||
@@ -27,0 +52,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14913
59