title: JWT authentication with passport-jwt does not take expiration date into account
body: <p>I am trying to do an authentication system using JWT token in Express, using passport-jwt and jsonwebtoken. Everything works well now, but even if I set an expire date the token remains valid even after that date, if I try to use it with Postman, I can't figure out what am I missing.
  From my understanding, and from what I saw in many tutorials, expiration date should be handled by passsport-jwt itself, but if I try to use a token generated some days ago it still works, even if I did set the duration to one day. Here's my code:</p>
  <pre class="lang-js prettyprint-override"><code>//passport.jwt.ts
  
  const publicKey: string = process.env.PUBLIC_KEY.replace(/\\n/g, &quot;\n&quot;);
  
  const options = {
    jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
    secretOrKey: publicKey,
    algorithms: [&quot;RS256&quot;],
  };
  
  const strategy = new JWTStrategy(options, async (payload, done) =&gt; {
    const repo: UserRepository = RepoManager.getUserRepo();
    try {
      const user: UserModel = await repo.getUserById(payload.sub);
      if (user) {
        return done(null, user);
      } else {
        return done(null, false);
      }
    } catch (error) {
      done(error);
    }
  });
  
  export function JWTPassport(passport) {
    passport.use(strategy);
  }
  
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>//register user middleware for the /register route
  export async function registerUser(req, res) {
    try {
      const { salt, hash } = hashPassword(req.body.password);
  
      const newUser = {
        username: req.body.username,
        password: hash,
        salt: salt,
        email: req.body.email,
      };
  
      let model: UserModel = Deserialize(newUser);
      const repo: UserRepository = RepoManager.getUserRepo();
      model = await repo.createUser(model);
  
      const jwt = issueJWT(model);
      res.status(200).json({ user: model, jwt: jwt });
    } catch (e) {
      res
        .status(400)
        .json({ error: &quot;could not register user&quot; });
    }
  }
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>//function generating the JWT token
  export function issueJWT(user: UserModel) {
    const id = user.id;
  
    const expiresIn = &quot;1d&quot;;
  
    const payload = {
      sub: id,
      iat: Date.now(),
    };
  
    const signedToken = sign(payload, privateKey, {
      expiresIn: expiresIn,
      algorithm: &quot;RS256&quot;,
    });
  
    return {
      token: &quot;Bearer &quot; + signedToken,
      expires: expiresIn,
    };
  }
  </code></pre>
  <p>EDIT: I figured out part of the problem, the timestamps were being generated in milliseconds instead of seconds. Now I manually calculate the timestamps with <code>60 * 60 * 24</code>, but I'd like to understand why the syntax <code>&quot;1d&quot;</code> since it is recommended in the docs</p>