Skip to content

πŸ” Node/Browser module for TOTP and HOTP generator based on RFC 6238 and RFC 4226 πŸ—οΈ

License

Notifications You must be signed in to change notification settings

haikelfazzani/otp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

one-time password (OTP) generator

Zero dependencies πŸ” Node/Browser module for TOTP and HOTP generator based on RFC 6238 and RFC 4226 πŸ—οΈ

one-time-pass one-time-pass one-time-pass one-time-pass one-time-pass

Usage

generate TOTP

import { generateTOTP } from "one-time-pass";

(async () => {

  const defaultOptions = {
    hash: 'sha-1',
    timeStep: 30, // epoch interval
    digits: 6,
    timestamp: Date.now()
  }

  const code = await generateTOTP("key", defaultOptions?);
  console.log(code);
})();

generate HOTP

import { generateHOTP } from "one-time-pass";

(async () => {
  const counter = 14653
  const hash = 'sha-1'
  const digits = 6

  const code = await generateHOTP("secretKey", counter, hash, digits);
  console.log(code);
})();

Or include it via jsDelivr CDN (UMD):

<script src="https://cdn.jsdelivr.net/npm/one-time-pass/dist/index.umd.js"></script>
<!-- Access via global object : window.OTP -->

window.OTP.generateTOTP("key");

Ressouces

Notes

  • All pull requests are welcome, feel free.

Author

License

GNU GENERAL PUBLIC LICENSE V3

About

πŸ” Node/Browser module for TOTP and HOTP generator based on RFC 6238 and RFC 4226 πŸ—οΈ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages