Jump to content
McKay Development

Recommended Posts

Posted

Is there any feasible way to get the "remaining time" on a given TOTP code? I take it that there's a global tripping point where all codes older than 60? seconds expire, but I was unable to find any resources on this. Would it be enough to figure out this tripping point (and does it even exist)?

 

I'd appreciate any pointers on the topic, no need for full solutions or anything. Cheers.

Posted

Assuming your clock is correct, this will tell you how many seconds are left until the code will change:

let secondsRemaining = 30 - (Math.floor(Date.now() / 1000) % 30);

But note that once a code changes, you still have another 30 seconds to use it before it comes invalid.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...