jeremyscalpello / node-2fa

Easy 2-Factor Integration For Node.JS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Differences in delta number

SirPhemmiey opened this issue · comments

Hi guys. You guys have done a great job.

I am just curious. I want to know the meaning behind the delta numbers.

Sometimes i see, -4, -1, 0. What do they all mean? Are there more delta numbers?

Hey! Thanks for using the library :)

The delta describes how many time slots away the entered code was from the current time-based code.

So for example, if the delta is 0, then the user's code matches the current code which would be generated with the current time. A delta value of -2 means the user's code would have been generated 2 slots (I.E 60 seconds) in the past. A positive value would indicate the user's code is from the future.

This was done to prevent a little time drift on the user's device or data entry delay (I.E while the user types the code after reading it from their device) from disrupting the authentication flow.

Does that make sense?

Great! I now understand.

Thanks.

A positive value would indicate the user's code is from the future

BTW, that got me chuckled. :)