add: basic function with comments

This commit is contained in:
lancegin
2017-06-28 21:03:18 +08:00
parent c8853d9ae8
commit b144a14efe
4 changed files with 139 additions and 9 deletions
+57 -2
View File
@@ -3,6 +3,61 @@
* @author : Gin (gin.lance.inside@hotmail.com)
*/
class TOTP {
import OTP from './otp';
class TOTP extends OTP {
/*
* @param {interval}
* @type {int}
* @desc the time interval in seconds for OTP.
* This defaults to 30.
*
* @return {OTP}
*/
constructor(interval=30, ...args) {
this.interval = interval;
super(...args);
}
/*
* Generate the OTP with current time.
*
* @return {OTP}
*
* @example
* ```javascript
* let totp = jsotp.TOTP.gen('BASE32_ENCODED_SECRET');
* totp.now(); // => 432143
* ```
*/
now() {
console.log("TOTP.now");
}
/*
* Verifies the OTP passed in against the current time OTP.
*
* @param {otp}
* @type {String}
* @desc the OTP waiting for checking
*
* @param {time}
* @type {int or datetime}
* @desc Time to check OTP at (defaults to now)
*
* @return {Boolean}
*
* @example
* ```javascript
* let totp = jsotp.TOTP.gen('BASE32_ENCODED_SECRET');
* totp.now(); // => 432143
* // Verify for current time
* totp.verify(432143); // => true
* // Verify after 30s
* totp.verify(432143); // => false
* ```
*/
verify(otp, time=null) {
console.log("TOTP.verify");
}
}