Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

speakeasy

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

speakeasy

Two-factor authentication for Node.js. One-time passcode generator (HOTP/TOTP) with support for Google Authenticator.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is speakeasy?

The speakeasy npm package is a library for handling Two-Factor Authentication (2FA) and One-Time Passwords (OTP) using the HMAC-based One-Time Password (HOTP) and Time-based One-Time Password (TOTP) algorithms. It is commonly used for implementing 2FA in web applications.

What are speakeasy's main functionalities?

Generate a TOTP Secret

This feature allows you to generate a secret key that can be used for TOTP. The secret key is typically shared with the user and stored securely.

const speakeasy = require('speakeasy');
const secret = speakeasy.generateSecret({ length: 20 });
console.log(secret.base32);

Generate a TOTP Token

This feature allows you to generate a TOTP token based on a secret key. The token is time-based and changes every 30 seconds by default.

const speakeasy = require('speakeasy');
const token = speakeasy.totp({ secret: 'your-secret-key', encoding: 'base32' });
console.log(token);

Verify a TOTP Token

This feature allows you to verify a TOTP token provided by the user. It checks if the token is valid based on the secret key and the current time.

const speakeasy = require('speakeasy');
const verified = speakeasy.totp.verify({ secret: 'your-secret-key', encoding: 'base32', token: 'user-token' });
console.log(verified);

Generate an HOTP Token

This feature allows you to generate an HOTP token based on a secret key and a counter. HOTP tokens are event-based and change with each event.

const speakeasy = require('speakeasy');
const token = speakeasy.hotp({ secret: 'your-secret-key', encoding: 'base32', counter: 123 });
console.log(token);

Verify an HOTP Token

This feature allows you to verify an HOTP token provided by the user. It checks if the token is valid based on the secret key and the counter.

const speakeasy = require('speakeasy');
const verified = speakeasy.hotp.verify({ secret: 'your-secret-key', encoding: 'base32', token: 'user-token', counter: 123 });
console.log(verified);

Other packages similar to speakeasy

Keywords

FAQs

Package last updated on 27 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc