Skip to content

Commit

Permalink
fixed broken tests and updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-p-r committed Apr 30, 2017
1 parent a4da7c3 commit 602427e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@ exports.verify = (options, cb) => {
};


exports.verifySync = (options) => {
exports.verifySync = (options, type) => {

const schema = internals.schema.verify;
const result = Joi.validate(options, schema);
if (result.error) {
return false;
}
};

const verifyOptions = result.value;
const decoded = exports.decode(verifyOptions.signature);
if (decoded === null) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yajwt",
"version": "1.5.4",
"version": "1.5.5",
"description": "yet another json web token library",
"main": "lib/index.js",
"directories": {
Expand All @@ -17,15 +17,15 @@
"author": "simon-p-r",
"license": "BSD-3-Clause",
"dependencies": {
"basic-utils": "^1.7.3",
"basic-utils": "^1.7.4",
"joi": "^10.4.1",
"jws": "^3.1.4",
"moment": "^2.18.1",
"ms": "^1.0.0"
},
"devDependencies": {
"code": "^4.0.0",
"coveralls": "^2.13.0",
"lab": "^13.0.1"
"coveralls": "^2.13.1",
"lab": "^13.0.2"
}
}
1 change: 0 additions & 1 deletion test/fixtures/test.token

This file was deleted.

9 changes: 5 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const Path = require('path');
// fixtures
const PrivateKey = Fs.readFileSync(Path.resolve(__dirname, './fixtures/private.pem'));
const PublicKey = Fs.readFileSync(Path.resolve(__dirname, './fixtures/public.pem'));
const Token = Fs.readFileSync(Path.resolve(__dirname, './fixtures/test.token'), 'utf8');

// Set-up lab
const lab = exports.lab = Lab.script();
Expand Down Expand Up @@ -40,7 +39,7 @@ const signingOptions = () => {
// payload can be object, buffer or string
payload: {
exp: '365d',
nbf: Date.now(),
nbf: Date.now() - 10000,
iat: '01-01-1990',
host: Os.hostname(),
port: 3000
Expand Down Expand Up @@ -169,7 +168,8 @@ describe('Jwt', () => {

it('should verify a payload sync', (done) => {

const ops = verifyOptions(Token);
const result = Jwt.signSync(signingOptions());
const ops = verifyOptions(result.token);
const valid = Jwt.verifySync(ops);
expect(valid).to.be.true();
done();
Expand Down Expand Up @@ -199,7 +199,8 @@ describe('Jwt', () => {

it('should verify a payload async', (done) => {

const ops = verifyOptions(Token);
const result = Jwt.signSync(signingOptions());
const ops = verifyOptions(result.token);
Jwt.verify(ops, (err, decoded) => {

expect(err).to.not.exist();
Expand Down

0 comments on commit 602427e

Please sign in to comment.