https://github.com/eggjs-community/egg-otp
One time password plugin for eggjs.
https://github.com/eggjs-community/egg-otp
egg-otp egg-plugin eggjs hotp totp
Last synced: 5 months ago
JSON representation
One time password plugin for eggjs.
- Host: GitHub
- URL: https://github.com/eggjs-community/egg-otp
- Owner: eggjs-community
- License: mit
- Created: 2018-02-26T10:22:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-10T03:51:43.000Z (over 6 years ago)
- Last Synced: 2025-05-01T01:17:39.695Z (5 months ago)
- Topics: egg-otp, egg-plugin, eggjs, hotp, totp
- Language: JavaScript
- Size: 92.8 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# egg-otp
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![npm download][download-image]][download-url]
[](https://app.fossa.io/projects/git%2Bgithub.com%2Feggjs-community%2Fegg-otp?ref=badge_shield)[npm-image]: https://img.shields.io/npm/v/egg-otp.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-otp
[travis-image]: https://img.shields.io/travis/eggjs-community/egg-otp.svg?style=flat-square
[travis-url]: https://travis-ci.org/eggjs-community/egg-otp
[download-image]: https://img.shields.io/npm/dm/egg-otp.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-otpOne time password plugin for eggjs.
## Install
```bash
$ npm i egg-otp --save
```## Usage
```js
// {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](lib/hotp.js) AND [lib/totp.js](lib/totp.js) for more option.## Configuration
see [config/config.default.js](config/config.default.js) for more detail.
## License
[MIT](LICENSE)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Feggjs-community%2Fegg-otp?ref=badge_large)