Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

2fa-plus

Implementation of two-factor authentication in Node, made simple.

2faauthbase32codegeneratorkeymfanotptokentotp
Published29 May 2024
Direct dependencies12
Transitive dependenciesNot calculated

README

Current package documentation

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

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 --save

Generate 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: token

Verify a token

import { verifyToken } from "2fa-plus";

const isValid = verifyToken(secret, token);

// output: true/false

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 12

Native requirements
12 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
notp
Environment
{
  "local_name": "notp",
  "alias": false,
  "peer_metadata": null
}
^2.0.3runtime
tslib
Environment
{
  "local_name": "tslib",
  "alias": false,
  "peer_metadata": null
}
^2.6.2runtime
qrcode
Environment
{
  "local_name": "qrcode",
  "alias": false,
  "peer_metadata": null
}
^1.5.3runtime
thirty-two
Environment
{
  "local_name": "thirty-two",
  "alias": false,
  "peer_metadata": null
}
^1.0.2runtime
@types/notp
Environment
{
  "local_name": "@types/notp",
  "alias": false,
  "peer_metadata": null
}
^2.0.5runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.7.0development
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^8.0.2development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.1.4development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^10.9.2development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.4.5development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^29.5.12development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^20.12.12development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "f64d61279f3ca47fa952074872d9da2869e155f6",
  "tarball": "https://registry.npmjs.org/2fa-plus/-/2fa-plus-1.0.0.tgz",
  "fileCount": 9,
  "integrity": "sha512-41Nw6e64Xruv3z5uAjumYwABjqSEiks2xhzAf7L/B36CsC8CFuBL8mSX86h38jTt8Yf/jeVIV/YMtxlKeEwC0w==",
  "signatures": [
    {
      "sig": "MEUCIEVU/vEgAy3Uv4ZXRm6f3dCkREXEx6egHsogowjxTgtIAiEAwoNPdh/WmmQql0I7knu4UvzzT3BpK3kFnMr+VyiX3Ec=",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 27804
}

Repository

PENDING
aaronduce/2fa-plus

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:12 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:733fe188df7df18da00f8a1c1be525b433b3beb897818a9b66329fc60c2eb9fa

Other collected versions

1.0.129 MayView all collected versions →