open-index/open-npm huggingface dataset:
npm package: 2fa
Description: TOTP + HOTP library, with nice utilities for handing 2FA
Author: Simon Tabor
Latest version: 0.1.2

# 2FA

Module for generating and verifying 2FA codes (specifically TOTP and HOTP).

Also contains utilities for handing 2FA logic, such as generating Google Authenticator compatible QR codes (without going via Google Charts) and generating backup codes.

## Install
```
npm install --save 2fa
```

## Usage

```js
var tfa = require('2fa');

// lets generate a new key for a user
// tfa.generateKey(length (optional), cb)
tfa.generateKey(32, function(err, key) {
  // crypto secure hex key with 32 characters

  // generate crypto-secure backups codes in a user-friendly pattern
  // tfa.generateBackupCodes(num, pattern (optional), cb)
  tfa.generateBackupCodes(8, 'xxxx-xxxx-xxxx', function(err, codes) {
    // [ '7818-b7b8-c928', '3526-dc04-d3f2', 'be3c-5d9f-cb68', ... ]

    // these should be sent to the user, stored and checked when we get a 2fa code
  });

  // generate a google QR code so the user can save their new key
  // tfa.generateGoogleQR(name, accountname, secretkey, cb)
  tfa.generateGoogleQR('Company', 'email@gmail.com', key, function(err, qr) {
    // data URL png image for google authenticator
  });

  var opts = {
    // the number of counters to check before what we're given
    // default: 0
    beforeDrift: 2,
    // and the number to check after
    // default: 0
    afterDrift: 2,
    // if before and after drift aren't specified,
    // before + after drift are set to drift / 2
    // default: 0
    drift: 4,
    // the step for the TOTP counter in seconds
    // default: 30
    step: 30
  };

  // calculate the counter for the HOTP (pretending it's actually TOTP)
  var counter = Math.floor(Date.now() / 1000 / opts.step);

  // generate a valid code (in real-life this will be user-input)
  var code = tfa.generateCode(key, counter);

  // verify it as a HOTP
  var validHOTP = tfa.verifyHOTP(key, code, counter, opts);
  // true

  // for TOTP, the counter is calculated internally using Date.now();
  var validTOTP = tfa.verifyTOTP(key, code, opts);
  // true

});
```
npm package: 2fa-app
Description: A HOTP/TOTP app
Author: Coolchickenguy
Latest version: 1.0.1

# 2fa-app
A nodejs TOTP code creation app
### Install
```bash
# Globaly
npm i -G 2fa-app
# Or Use with npx
npx 2fa-app
```
### Options
```
      --help      Show help                                            [boolean]
      --version   Show version number                                  [boolean]
  -A, --add       add a platform (requires platform, may optionaly add
                  --length/-L)                                          [string]
  -R, --remove    remove a platform (requires platform)                 [string]
  -P, --platform  the platform to use. By itself generates a code for the
                  platform                                              [string]
  -L, --length    Length of the code (Optional, defaults to 6. May be used in
                  adding the key of mey override when generating.)      [number]
  -D, --dump      Create the codes for all platforms                   [boolean]
```
npm package: 2fa-cmd
Description: A command tool for Google Authenticator
Author: x-ray-s
Latest version: 0.0.6

# 2fa-cmd

Google Authenticator or other OTP application in command.

![screenshot](screenshot.png)

## Install

```bash
npm i 2fa-cmd -g
```

## Contribute

```bash
$ git clone git@github.com:x-ray-s/2fa-cmd.git
$ cd 2fa-cmd
$ npm i && npm run build && npm link
```

## CLI

```
$ 2fa --help

	Usage
	  $ 2fa <input>

	Input
	  add - Add a new secret
	  remove - Remove a secret
	  verify - verify a token
	  import - Import a secret from url
	  rename - Rename
	  get - get one otp

	Options
		--name <The name of the secret>
		--secret <Your secret>
		--token <Your token>
		--url <The URL parsed by QR code exported from Google Authenticator>

	Examples
	  $ 2fa
	  $ 2fa add --name <name> --secret FCRJQZSGFD3VMZDE
	  $ 2fa remove --name <name>
	  $ 2fa verify --name <name> --token 643223
	  $ 2fa import --url 'otpauth://totp/...'
	  $ 2fa rename <old> --name <new>
	  $ 2fa get --name <name>
	  $ 2fa --name <name> // same as get
```

## TODO

- [x] npm publish
- [x] rename
- [ ] password
- [ ] encrypto
- [ ] custom storage path

## HOW

#### How to import Google Authenticator in command?

1. Open the Authenticator, Click Menu on left top;
2. Transform account and export accounts;
3. You will get a qrcode image;
4. Decode the qrcode. eg. [https://cli.im/deqr]()
5. You will get a schema URL like _otpauth-migration://offline?data=_
6. `2fa import --url '<your url>'` > notice the quotation mark
npm package: 2fa-hotp-totp
Description: Zero dependency HOTP/TOTP 2FA
Author: TAB_mk
Latest version: 2.1.3

[<img src="https://img.shields.io/npm/v/2fa-hotp-totp">](https://www.npmjs.com/package/2fa-hotp-totp) [<img src="https://img.shields.io/npm/l/2fa-hotp-totp">](https://github.com/TABmk/2fa-hotp-totp/blob/master/LICENSE) <img src="https://badgen.net/npm/types/2fa-hotp-totp">

<img src="https://badgen.net/npm/dt/2fa-hotp-totp">
<img src="https://badgen.net/npm/dm/2fa-hotp-totp">

__Help__ [<img src="https://img.shields.io/github/issues/tabmk/2fa-hotp-totp">](https://github.com/TABmk/2fa-hotp-totp/issues?q=is%3Aopen+is%3Aissue) [<img src="https://img.shields.io/github/issues-pr/tabmk/2fa-hotp-totp">](https://github.com/TABmk/2fa-hotp-totp/pulls?q=is%3Aopen+is%3Apr)

#### __Rate me__ [<img src="https://img.shields.io/github/stars/tabmk/2fa-hotp-totp?style=social">](https://github.com/TABmk/2fa-hotp-totp)

<p align="center">
  <img src="https://github.com/TABmk/2fa-hotp-totp/raw/master/img/1.png">
</p>

# __2FA-HOTP-TOTP__

Zero-dependency <img src="https://badgen.net/bundlephobia/dependency-count/2fa-hotp-totp">

__1kB gzipped__ <img src="https://badgen.net/bundlephobia/minzip/2fa-hotp-totp">

#### The minimum version of Node.js required is 15 ⚠️

My implementation of 2FA HOTP/TOTP algorithms in TypeScript + base32 encoder for creating links for authenticator programs like [Google Authenticator](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2)

### Full documentation 👇

https://tabmk.github.io/2fa-hotp-totp/