albertusdev / hotp-totp-generator

A HMAC-based OTP (HOTP) and Time-based OTP (TOTP) that generates OTP tokens from OTP key with customizable hash algorithm.
MIT License
15 stars 6 forks source link

Turn this into a CLI tool #2

Closed ajmalsiddiqui closed 1 year ago

ajmalsiddiqui commented 6 years ago

This module can be easily turned into a CLI tool, don't you think? Something like this for example: TOTP (-t flag specifies algorithm - TOTP, -a flag specifies hash algo, -d specifies digits): hotp-totp-generator -t -a "sha512" -d "10" "my-totp-key"

albertusdev commented 6 years ago

Thanks for your star! This is a nice idea! But if -t flag specifies TOTP algorithm, what would happen if a user specify -t and -h (HOTP) in the same command line? Since I don't have any prior experience developing a CLI tool, I think we need to do a lot of input checking here.

Would you like to contribute since you have better experience on developing CLI tool than I am?

Thank you!

ajmalsiddiqui commented 6 years ago

Since it is a CLI tool, one common approach to the problem that you have specified here is to consider only the most recent flag. So if someone types -h -t or -ht, it will be considered as -t only. NPM modules like yargs (I guess) and frameworks like commander are easy ways to make CLI tools for NPM. I made my CLI tool, autodot, using oclif - the open source CLI framework that powers the Heroku and Salesforce CLIs. But that will be overkill here. I would like to help contribute the moment I find some free time. :)

albertusdev commented 6 years ago

Sure! Feel free to make the pull request once you are done :) Thank you very much :+1: