One time password plugin for eggjs.
$ npm i egg-otp --save
// {app_root}/config/plugin.js
exports.otp = {
enable: true,
package: 'egg-otp',
};
// {app_root}/controller/home.js
const key = ctx.otp.generateOtpKey();
const token = ctx.otp.hotp.gen(key, {counter: 0});
ctx.otp.hotp.verify(token, key, {counter: 0, window: 10});
you can see lib/hotp.js AND lib/totp.js for more option.
see config/config.default.js for more detail.