Socket
Socket
Sign inDemoInstall

@sunknudsen/totp

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sunknudsen/totp

Generate and validate TOTP tokens.


Version published
Weekly downloads
17K
increased by0.13%
Maintainers
1
Install size
14.6 kB
Created
Weekly downloads
 

Readme

Source

@sunknudsen/totp

Generate and validate TOTP tokens.

Installation

$ npm install @sunknudsen/totp

Usage

import {
  generateSecret,
  generateUri,
  generateToken,
  validateToken,
} from "@sunknudsen/totp"

const secret = generateSecret()

console.log(secret)
// DMJKP7AU22WKWRG3DNIQ3ERA

const uri = generateUri(
  "Superbacked",
  "john@protonmail.com",
  "DMJKP7AU22WKWRG3DNIQ3ERA",
  "Superbacked"
)

console.log(uri)
// otpauth://totp/Superbacked:john%40protonmail.com?secret=DMJKP7AU22WKWRG3DNIQ3ERA&issuer=Superbacked&algorithm=SHA1&digits=6&period=30

const token = generateToken("DMJKP7AU22WKWRG3DNIQ3ERA")

console.log(token)
// 616692

const result = validateToken("DMJKP7AU22WKWRG3DNIQ3ERA", "616692")

console.log(result)
// true

Keywords

FAQs

Last updated on 31 Jul 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc