JWT token expiration event handler from server using Socket.io?

Viewed 179

I'm currently using JWT to log user in with expiration time of 1 hour expiresIn: '1h'. I was wondering if there's a way for the server to inform client right when the token expires (kind of like an event-listener) using Socket.io?

const token = jwt.sign(
{
   foo: 'bar',
   random: 'string'
},
'some very long secret',
{ expiresIn: '1h' }) // Will expire after 1h.

I was thinking about using new Date() or even setTimeout() to countdown but I figured those will eventually eat up server memory. If there's any other better method, please suggest me. Thanks.

0 Answers
Related