Package Exports
- 2fa-plus
- 2fa-plus/dist/index.js
- 2fa-plus/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (2fa-plus) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
2fa-plus
Implementation of two-factor authentication in Node, made simple.
Credit for original implementation on which this has been abstracted from goes to node-2fa - Jeremy Scalpello.
This has been reworked from the ground up to:
- Not be reliant on Google Charts for QR code generation, and instead return a base64-png image.
- Full typescript support.
There are a number of applications which support 2-Factor Authentication, namely
- Authy iPhone | Android | Chrome | Linux | OS X
- Google Authenticator iPhone | Android
- Microsoft Authenticator iPhone | Android
This module uses notp which implements TOTP (RFC 6238)
(the Authenticator standard), which is based on HOTP (RFC 4226)
to provide codes that are exactly compatible with all other Authenticator apps and services that use them.
Usage
npm install 2fa-plus --saveGenerate a new secret
import { generateSecret } from "2fa-plus";
const secret = generateSecret('Name', 'account@demo.com');
// output: { secret, uri, qr }Generate a token from a secret
import { generateToken } from "2fa-plus";
const token = generateToken(secret.secret);
// output: tokenVerify a token
import { verifyToken } from "2fa-plus";
const isValid = verifyToken(secret, token);
// output: true/false