Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Returns an object `{delta: #}` if the token is valid. `delta` is the count skew
**counter**
> Counter value. This should be stored by the application on a per user basis. It is up to the application to track and increment this value as needed. It is also up to the application to increment this value if there is a skew between the client and server (`delta`)

**digits**
> Number of digits.
> Default - 6

## totp.verify(token, key, opt)

Check a time based one time password for validity
Expand All @@ -90,6 +94,10 @@ Returns an object `{delta: #}` if the token is valid. `delta` is the count skew
> The time step of the counter. This must be the same for every request and is used to calculate C.
> Default - 30

**digits**
> Number of digits.
> Default - 6

## hotp.gen(key, opt)

Return a counter based one time password
Expand All @@ -98,6 +106,10 @@ Return a counter based one time password
**counter**
> Counter value. This should be stored by the application, must be user specific, and be incremented for each request.

**digits**
> Number of digits.
> Default - 6

## totp.gen(key, opt)

Return a time based one time password
Expand All @@ -107,6 +119,10 @@ Return a time based one time password
> The time step of the counter. This must be the same for every request and is used to calculate C.
> Default - 30

**digits**
> Number of digits.
> Default - 6

# Migrating from 1.x to 2.x

## Removed
Expand All @@ -128,7 +144,7 @@ Some of the required arguments to the functions have also been removed from the
The argument names have also changed to better describe the purpose of the argument.

* `K` -> no longer in args/opt but passed directly as a function argument
* `P` -> no longer in args/opt but passed directly as a function argument
* `P` -> `digits`
* `W` -> `window`
* `C` -> `counter`
* `T` -> `time`
Expand Down
18 changes: 17 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ var hotp = {};
* counter - Counter value. This should be stored by the application, must
* be user specific, and be incremented for each request.
*
* digits - The number of digits in one time password.
*
* Default - 6
*
*/
hotp.gen = function(key, opt) {
key = key || '';
opt = opt || {};
var counter = opt.counter || 0;

var p = 6;
var p = opt.digits || 6;

// Create the byte array
var b = new Buffer(intToBytes(counter));
Expand Down Expand Up @@ -106,6 +110,10 @@ hotp.gen = function(key, opt) {
* counter - Counter value. This should be stored by the application, must
* be user specific, and be incremented for each request.
*
* digits - The number of digits in one time password.
*
* Default - 6
*
*/
hotp.verify = function(token, key, opt) {
opt = opt || {};
Expand Down Expand Up @@ -145,6 +153,10 @@ var totp = {};
*
* Default - 30
*
* digits - The number of digits in one time password.
*
* Default - 6
*
*/
totp.gen = function(key, opt) {
opt = opt || {};
Expand Down Expand Up @@ -196,6 +208,10 @@ totp.gen = function(key, opt) {
*
* Default - 30
*
* digits - The number of digits in one time password.
*
* Default - 6
*
*/
totp.verify = function(token, key, opt) {
opt = opt || {};
Expand Down