Skip to content

ridays2001/tulip-2fa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tulip 2FA

A simple 2FA library for Node.js

Usage

  • Generate a random 2FA secret.
import { generateSecret } from 'tulip-2fa';

// Default usage - Generate a base32-encoded secret of 20 bytes (recommended by RFC4226 for TOTP and HOTP)
console.log(generateSecret());

// Advanced usage - Generate a base32-encoded secret of x bytes.
console.log(generateSecret(x));
  • Generate the 2FA code using a secret.
import { generateCode } from 'tulip-2fa';

const secret = '<SOME-BASE32-ENCODED-SECRET>';

// Default usage.
console.log(generateCode(secret));

// Advanced usage.
console.log(generateCode({ secret, step: 30, length: 6, algorithm: 'sha1' }));

About

A simple 2FA library for Node.js.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published