];
}
- get _algorithmKeyLengths() {
+ static get _algorithmKeyLengths() {
return {
...super._algorithmKeyLengths,
'sha256': 32,
};
}
+ /**
+ * The type used when constructing the otpauth URI.
+ */
+ static get _type() {
+ return 'totp';
+ }
+
+ /**
+ * Derive counter from epoch.
+ */
get counter() {
const epoch = Math.floor(Date.now() / 1000);
return BigInt(Math.floor((epoch - this.timeStepStartSeconds) / this.timeStepSeconds));
}
- set counter(_) { /* */ }
+ set counter(_) { /* ignore assignment */ } // eslint-disable-line class-methods-use-this
- get _defaultOptions() {
+ static get _defaultOptions() {
const options = Object.assign(super._defaultOptions, {
timeStepSeconds: 30,
timeStepStartSeconds: 0,
return options;
}
+ /**
+ *
+ * @param {BigInt=} count
+ * @returns {String}
+ */
generate(count = this.counter) {
return super.generate(count);
}
}
return false;
}
-
+
}
module.exports = TimeBasedOneTimePassword;