Skip to content

litert/otp.js

Repository files navigation

LiteRT/OTP

Strict TypeScript Checked npm version License GitHub issues GitHub Releases

The TOTP & HOTP implement for Node.JS.

Features

  • HOTP (HMAC-based One-Time Password) algorithm implementation.
  • TOTP (Time-based One-Time Password) algorithm implementation.
  • OTP URL encoding and decoding.
  • Command line tool:
    • Generating OTP codes.
    • Generating OTP URLs.
    • Inspecting OTP URLs.
  • Customization:
    • Digits length from 4 - 10
    • TOTP time-step (period)
    • Digest algorithms including SHA-1, SHA-256, and SHA-512

Requirements

  • TypeScript v3.1.x (Or newer)

Installation

npm i @litert/otp --save

Usage

Use in code

See examples:

Click here for a quick start guide.

Use as a command line tool

You can use this library as a command line tool to do OTP operations.

There are two ways to use the CLI:

  1. Use npx to run the CLI without installing it manually.

    npx @litert/otp -k 'raw:1234567890'
    
    # Check the help message
    npx @litert/otp --help
  2. Install it globally or locally in your project.

    npm i -g @litert/otp
    # or install in local project only
    npm i @litert/otp # -D # if only used in dev environment

    Then you can use the otp command directly:

    npx otp -k 'raw:1234567890'

Click here for more details about the CLI usage.

Documents

License

This library is published under Apache-2.0 license.

About

The TOTP & HOTP implement for Node.JS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •