Comparing version 0.3.3 to 0.4.0
@@ -7,5 +7,3 @@ 'use strict' | ||
decodeToken: require('./lib/decode'), | ||
MissingParametersError: require('./lib/errors').MissingParametersError, | ||
// Deprecated | ||
Tokenizer: require('./lib/tokenizer') | ||
MissingParametersError: require('./lib/errors').MissingParametersError | ||
} |
{ | ||
"name": "jwt-js", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "node.js library for encoding, decoding, and verifying JSON Web Tokens (JWTs)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,3 @@ # JSON Web Token JS | ||
[![](https://nodei.co/npm/jwt-js.png)](https://www.npmjs.com/package/jwt-js) | ||
[![](https://nodei.co/npm/jwt-js.png?downloads=true)](https://www.npmjs.com/package/jwt-js) | ||
@@ -9,0 +9,0 @@ node.js library for signing, decoding, and verifying JSON Web Tokens (JWTs) |
55
test.js
'use strict' | ||
var test = require('tape'), | ||
Tokenizer = require('./index').Tokenizer, | ||
TokenSigner = require('./index').TokenSigner, | ||
@@ -10,4 +9,2 @@ TokenVerifier = require('./index').TokenVerifier, | ||
var tokenizer = new Tokenizer('ES256k') | ||
var rawPrivateKey = '278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f', | ||
@@ -29,44 +26,5 @@ rawPublicKey = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479', | ||
test('testSign', function(t) { | ||
test('TokenSigner', function(t) { | ||
t.plan(5) | ||
var encodedToken = tokenizer.sign(sampleDecodedToken.payload, rawPrivateKey) | ||
t.ok(encodedToken, 'token should have been created') | ||
t.equal(typeof encodedToken, 'string', 'token should be a string') | ||
var decodedToken = decodeToken(encodedToken) | ||
t.equal(JSON.stringify(decodedToken.header), JSON.stringify(sampleDecodedToken.header), 'decodedToken header should match the reference header') | ||
t.equal(JSON.stringify(decodedToken.payload), JSON.stringify(sampleDecodedToken.payload), 'decodedToken payload should match the reference payload') | ||
try { | ||
encodedToken = tokenizer.sign(sampleDecodedToken.payload) | ||
} catch(err) { | ||
t.equal(err.name, 'MissingParametersError', 'token signing without a private key should throw an error') | ||
} | ||
}) | ||
test('testDecode', function(t) { | ||
t.plan(2) | ||
var decodedToken = decodeToken(sampleToken) | ||
t.ok(decodedToken, 'token should have been decoded') | ||
t.equal(JSON.stringify(decodedToken.payload), JSON.stringify(sampleDecodedToken.payload), 'decodedToken payload should match the reference payload') | ||
}) | ||
test('testVerify', function(t) { | ||
t.plan(2) | ||
var tokenVerified = tokenizer.verify(sampleToken, rawPublicKey) | ||
t.equal(tokenVerified, true, 'token should have been verified') | ||
try { | ||
tokenVerified = tokenizer.verify(sampleToken) | ||
} catch(err) { | ||
t.equal(err.name, 'MissingParametersError', 'token verification without a public key should throw an error') | ||
} | ||
}) | ||
test('tokenSigner', function(t) { | ||
t.plan(5) | ||
var tokenSigner = new TokenSigner('ES256k', rawPrivateKey) | ||
@@ -82,6 +40,5 @@ t.ok(tokenSigner, 'token signer should have been created') | ||
t.equal(JSON.stringify(decodedToken.payload), JSON.stringify(sampleDecodedToken.payload), 'decodedToken payload should match the reference payload') | ||
}) | ||
test('tokenVerifier', function(t) { | ||
test('TokenVerifier', function(t) { | ||
t.plan(2) | ||
@@ -95,1 +52,9 @@ | ||
}) | ||
test('decodeToken', function(t) { | ||
t.plan(2) | ||
var decodedToken = decodeToken(sampleToken) | ||
t.ok(decodedToken, 'token should have been decoded') | ||
t.equal(JSON.stringify(decodedToken.payload), JSON.stringify(sampleDecodedToken.payload), 'decodedToken payload should match the reference payload') | ||
}) |
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
14431
12
205