JWT Verify client-side? : <p>I have a nodejs api with an angular frontend. The API is successfully using JWT with passport to secure it's endpoints. </p>

<p>I am now conscious that after the tokens have expired, my front end will still allow the user to request my api endpoints without prompting them to reenter their log in details to get a fresh token. </p>

<p>This is how my backend generates the token:</p>

<pre><code>function generateToken(user) {
  return jwt.sign(user, secret, {
    expiresIn: 10080 // in seconds
  });
}
</code></pre>

<p>So to implement this logic I think I need to verify the JWT token client-side. Q1, is this a sensible approach. </p>

<p>Q2, the <a href="https://github.com/auth0/node-jsonwebtoken" rel="noreferrer"><code>JWT</code></a> library I am using seems to require a public key to use it's <code>verify()</code> function. I don't seem to have a public key, only a secret, which I just made up, so it wasn't generated with a pair. Where does my public key come from, or is there another way of verifying my token without this?  </p>

<p>This all seems like it should be obvious and that I have missed something, so apologies if this is a stupid question, but I can't seem to find the answer?</p>
