From 3db792b26aa64a4ead8e808cd8f173d4650ba443 Mon Sep 17 00:00:00 2001 From: Halt <9273697+Halt001@users.noreply.github.com> Date: Sun, 10 Dec 2017 11:33:53 +0100 Subject: [PATCH] @types/jsonwebtoken: Added clockTimestamp member to VerifyOptions interface --- types/jsonwebtoken/index.d.ts | 1 + types/jsonwebtoken/jsonwebtoken-tests.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/types/jsonwebtoken/index.d.ts b/types/jsonwebtoken/index.d.ts index 766042e627..26e223df53 100644 --- a/types/jsonwebtoken/index.d.ts +++ b/types/jsonwebtoken/index.d.ts @@ -58,6 +58,7 @@ export interface SignOptions { export interface VerifyOptions { algorithms?: string[]; audience?: string | string[]; + clockTimestamp?: number; clockTolerance?: number; issuer?: string | string[]; ignoreExpiration?: boolean; diff --git a/types/jsonwebtoken/jsonwebtoken-tests.ts b/types/jsonwebtoken/jsonwebtoken-tests.ts index 9e495d31cb..0b04c23e63 100644 --- a/types/jsonwebtoken/jsonwebtoken-tests.ts +++ b/types/jsonwebtoken/jsonwebtoken-tests.ts @@ -57,6 +57,13 @@ jwt.verify(token, 'shhhhh', function(err, decoded) { console.log(result.foo) // bar }); +// use external time for verifying +jwt.verify(token, 'shhhhh', { clockTimestamp: 1 }, function(err, decoded) { + const result = decoded as ITestObject + + console.log(result.foo) // bar +}); + // invalid token jwt.verify(token, 'wrong-secret', function(err, decoded) { // err