
var sinon = require('sinon'),
    jsjws = require('jsjws');

function generate(time, header, claims, expires, not_before, key)
{
    if (key.indexOf('-----BEGIN') === 0)
    {
        key = jsjws.createPrivateKey(key, 'utf8');
    }

    var clock = sinon.useFakeTimers(time * 1000);

    try
    {
        expires = new Date(expires * 1000);
        not_before = new Date(not_before * 1000);

        process.stdout.write(new jsjws.JWT().generateJWTByKey(header, claims, expires, not_before, key));
    }
    finally
    {
        clock.restore();
    }
}

function verify(time, sjwt, iat_skew, key)
{
    if (key.indexOf('-----BEGIN') === 0)
    {
        key = jsjws.createPublicKey(key, 'utf8');
    }

    var clock = sinon.useFakeTimers(time * 1000);

    try
    {
        var jwt = new jsjws.JWT();

        jwt.verifyJWTByKey(sjwt, {iat_skew: iat_skew}, key);

        process.stdout.write(JSON.stringify([jwt.getParsedHeader(), jwt.getParsedPayload()]));
    }
    finally
    {
        clock.restore();
    }
}

exports.generate = generate;
exports.verify = verify;

@@ -1,8 +1,45 @@
+/*jslint node: true */%0A%22use strict%22;%0A
 %0Avar sin
@@ -778,32 +778,37 @@
 ers(time * 1000)
+, jwt
 ;%0A%0A    try%0A    %7B
@@ -816,20 +816,16 @@
         
-var 
 jwt = ne

Fix jslint errors