diff --git a/jsonwebtoken/jsonwebtoken-tests.ts b/jsonwebtoken/jsonwebtoken-tests.ts index 52f116335..6aadaa82c 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 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 ignoreExpration == false and token is expired, err == expired token +}); + /** * jwt.decode * https://github.com/auth0/node-jsonwebtoken#jwtdecodetoken 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; }