https://github.com/frani/totp
⏰ 🗝️ Time based One Time Password - Zero Dependencies
https://github.com/frani/totp
no-dependencies otp time-based-one-time-password time-based-otp totp totp-generator zero-dependencies
Last synced: 3 months ago
JSON representation
⏰ 🗝️ Time based One Time Password - Zero Dependencies
- Host: GitHub
- URL: https://github.com/frani/totp
- Owner: frani
- License: mit
- Created: 2023-06-13T22:38:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-08T01:03:22.000Z (about 2 years ago)
- Last Synced: 2025-07-08T23:51:38.177Z (3 months ago)
- Topics: no-dependencies, otp, time-based-one-time-password, time-based-otp, totp, totp-generator, zero-dependencies
- Language: JavaScript
- Homepage: https://npmjs.com/package/@frani/totp
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Time based One Time Password
Simple TOTP, one function to call and generate OTP token.
This is a no-depenencies package
# Install
if you are using Yarn:
```sh
yarn add @frani/totp
```if you are using NPM:
```sh
npm i @frani/totp
```# Usage
to generate:
```js
const totp = require("@frani/totp");const token = totp.generate({
secret: "123", // optional - default is 'secret'
timeStep: 30, // optional - default is 30 seconds
digits: 6, // optional - default is 6
});
console.log(token); // 480143
```in case you want to compare, simple regenerate and check with '===', example:
```js
const totp = require("@frani/totp");const CODE = "123123";
const token = totp.generate({
secret: "123", // optional - default is 'secret'
timeStep: 30, // optional - default is 30 seconds
digits: 6, // optional - default is 6
});
console.log(token); // 480143if (CODE === token) return true; // is false
```