From 5e14a5854d4e94c69657432155cc45b23585a096 Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Tue, 1 Dec 2015 16:09:47 +0100 Subject: [PATCH 1/3] Add missing attributes to VerifyOptions --- jsonwebtoken/jsonwebtoken.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsonwebtoken/jsonwebtoken.d.ts b/jsonwebtoken/jsonwebtoken.d.ts index bb74aa853..b558df2e5 100644 --- a/jsonwebtoken/jsonwebtoken.d.ts +++ b/jsonwebtoken/jsonwebtoken.d.ts @@ -36,8 +36,10 @@ declare module "jsonwebtoken" { } export interface VerifyOptions { + algorithms?: string[]; audience?: string; issuer?: string; + ignoreExpiration?: boolean; maxAge?: string; } From d18b076ae91eb33f8d2d7d9536cda0ee3e1fb65b Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Tue, 1 Dec 2015 16:09:50 +0100 Subject: [PATCH 2/3] Add test cases for new VerifyOptions --- jsonwebtoken/jsonwebtoken-tests.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jsonwebtoken/jsonwebtoken-tests.ts b/jsonwebtoken/jsonwebtoken-tests.ts index 52f116335..c4e42f054 100644 --- a/jsonwebtoken/jsonwebtoken-tests.ts +++ b/jsonwebtoken/jsonwebtoken-tests.ts @@ -57,6 +57,18 @@ jwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer' }, function( // if issuer mismatch, err == invalid issuer }); +// verify algorithm +cert = fs.readFileSync('public.pem'); // get public key +jwt.verify(token, cert, { algorithms: ['RS256'] }, function(err, decoded) { + // if issuer mismatch, err == invalid issuer +}); + +// verify without expiration check +cert = fs.readFileSync('public.pem'); // get public key +jwt.verify(token, cert, { ignoreExpiration: true }, function(err, decoded) { + // if issuer mismatch, err == invalid issuer +}); + /** * jwt.decode * https://github.com/auth0/node-jsonwebtoken#jwtdecodetoken From 26a6aabce67f59b1e77825481f328f268493b136 Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Tue, 1 Dec 2015 16:14:25 +0100 Subject: [PATCH 3/3] Update comments in test cases --- jsonwebtoken/jsonwebtoken-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsonwebtoken/jsonwebtoken-tests.ts b/jsonwebtoken/jsonwebtoken-tests.ts index c4e42f054..6aadaa82c 100644 --- a/jsonwebtoken/jsonwebtoken-tests.ts +++ b/jsonwebtoken/jsonwebtoken-tests.ts @@ -60,13 +60,13 @@ jwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer' }, function( // verify algorithm cert = fs.readFileSync('public.pem'); // get public key jwt.verify(token, cert, { algorithms: ['RS256'] }, function(err, decoded) { - // if issuer mismatch, err == invalid issuer + // if algorithm mismatch, err == invalid algorithm }); // verify without expiration check cert = fs.readFileSync('public.pem'); // get public key jwt.verify(token, cert, { ignoreExpiration: true }, function(err, decoded) { - // if issuer mismatch, err == invalid issuer + // if ignoreExpration == false and token is expired, err == expired token }); /**