Files
jsotp/src/hotp.js
T
2017-06-29 13:28:40 +08:00

52 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* @module : HOTP module to generate and verify HOTP password
* @author : Gin (gin.lance.inside@hotmail.com)
*/
import OTP from './otp';
export default class HOTP extends OTP {
/*
* Generate the OTP with the given count
*
* @param {count}
* @type {int}
* @desc the OTP HMAC counter
*
* @return {OTP}
*
* @example
* ```javascript
* let hotp = jsotp.HOTP.gen('BASE32_ENCODED_SECRET');
* hotp.at(0); // => 432143
* ```
*/
at(count) {
console.log("HOTP.at");
}
/*
* Verifies the OTP passed in against the current counter.
*
* @param {otp}
* @type {String}
* @desc the OTP waiting for checking
*
* @param {counter}
* @type {int}
* @desc the OTP HMAC counter
*
* @return {Boolean}
*
* @example
* ```javascript
* let hotp = jsotp.HOTP.gen('BASE32_ENCODED_SECRET');
* hotp.at(0); // => 432143
* hotp.verify(432143, 0); // => true
* hotp.verify(432143, 1); // => false
* ```
*/
verify(otp, counter) {
console.log("HOTP.verify");
}
}