initial commit
This commit is contained in:
parent
3ebf15ffff
commit
f0da6f3db8
43
README.md
43
README.md
|
@ -1,2 +1,43 @@
|
|||
# authenticator-cli
|
||||
A commandline Authenticator App (for Authy, Google Authenticator, Microsoft Authenticator, TOTP, etc)
|
||||
|
||||
A commandline Authenticator App (for Authy, Google Authenticator, Microsoft Authenticator, Facebook Authenticator, TOTP, etc)
|
||||
|
||||
**Install node.js 4.0+**:
|
||||
|
||||
```bash
|
||||
curl -L https://bit.ly/iojs-min | bash
|
||||
```
|
||||
|
||||
**Install authenticator**:
|
||||
```bash
|
||||
npm install --global authenticator-cli
|
||||
```
|
||||
|
||||
```
|
||||
Usage:
|
||||
authenticator [OPTIONS]
|
||||
|
||||
Options:
|
||||
--account user@example.com Account Name, typically email address (Default is user@example.com)
|
||||
|
||||
--algo SHA1 Algorithm, typically SHA1 (also SHA256, SHA512) (Default is SHA1)
|
||||
|
||||
--digits 6 Number of digits, typically 6 (also 8) (Default is 6)
|
||||
|
||||
--generate Create a cryptographically-random TOTP key
|
||||
formatted in base32 with spaces. (Default is true)
|
||||
|
||||
--issuer ACME Issuer, typically the company name (Google,
|
||||
Facebook, Digital Ocean, etc) (Default is ACME)
|
||||
|
||||
--key 'xxxx xxxx ...' Supply the base32 key yourself (with or without
|
||||
delimeters). Takes precedence over --generate
|
||||
|
||||
--period 30 Number of seconds between tokens, typically 30 (Default is 30)
|
||||
|
||||
--qr Print the QR Code to the Terminal.
|
||||
|
||||
--verify '123 456' Verify a token. Must be used with --key.
|
||||
|
||||
-h, --help Display help and usage details
|
||||
```
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var cli = require('cli');
|
||||
var authenticator = require('authenticator');
|
||||
var qrcode = require('qrcode-terminal');
|
||||
|
||||
cli.parse({
|
||||
account: [ false, "Account Name, typically email address", 'string', 'user@example.com' ]
|
||||
, algo: [ false, "Algorithm, typically SHA1 (also SHA256, SHA512)", 'string', 'SHA1' ]
|
||||
, digits: [ false, "Number of digits, typically 6 (also 8)", 'integer', 6 ]
|
||||
, generate: [ false, "Create a cryptographically-random TOTP key formatted in base32 with spaces.", 'boolean', true ]
|
||||
, issuer: [ false, "Issuer, typically the company name (Google, Facebook, Digital Ocean, etc)", 'string', 'ACME' ]
|
||||
, key: [ false, "Supply the base32 key yourself (with or without delimeters). Takes precedence over --generate", 'string' ]
|
||||
, period: [ false, "Number of seconds between tokens, typically 30", 'integer', 30 ]
|
||||
, qr: [ false, "Print the QR Code to the Terminal.", 'boolean', false ]
|
||||
//, token: [ false, "Print the current token for the given (or generated) key.", 'boolean', false ]
|
||||
, verify: [ false, "Verify a token. Must be used with --key.", 'string' ]
|
||||
});
|
||||
|
||||
// ignore certonly and extraneous arguments
|
||||
cli.main(function(_, options) {
|
||||
var key = (options.key || authenticator.generateKey()).toString();
|
||||
var token = (options.verify || authenticator.generateToken(key)).toString();
|
||||
var url = authenticator.generateTotpUri(
|
||||
key
|
||||
, options.account || null
|
||||
, options.issuer || null
|
||||
, options.algo || 'SHA1'
|
||||
, options.digits || 6
|
||||
, options.perdiod || 30
|
||||
);
|
||||
|
||||
console.log('');
|
||||
console.log('Key:', key);
|
||||
console.log('Token:', token);
|
||||
console.log('URL:', url);
|
||||
|
||||
if (options.qr) {
|
||||
console.log('');
|
||||
qrcode.setErrorLevel('L'); // L: 7%, M: 15%, Q: 25%, H: 30%
|
||||
qrcode.generate(url, function (qr) {
|
||||
console.log(qr);
|
||||
});
|
||||
}
|
||||
|
||||
if (options.verify) {
|
||||
console.log('');
|
||||
console.log('Verified:', !!authenticator.verifyToken(key, token));
|
||||
}
|
||||
|
||||
console.log('');
|
||||
});
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "authenticator-cli",
|
||||
"version": "1.0.0",
|
||||
"description": "A commandline Authenticator App (for Authy, Google Authenticator, Microsoft Authenticator, TOTP / 2FA / MFA / OTP, etc)",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"authenticator-cli": "authenticator.js"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "node bin/authenticator.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Daplie/authenticator-cli.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Authenticator",
|
||||
"CLI",
|
||||
"Commandline",
|
||||
"command",
|
||||
"line",
|
||||
"authy",
|
||||
"google",
|
||||
"microsoft",
|
||||
"facebook",
|
||||
"daplie",
|
||||
"totp",
|
||||
"2fa",
|
||||
"mfa",
|
||||
"otp",
|
||||
"one-time",
|
||||
"password"
|
||||
],
|
||||
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
|
||||
"license": "MPL-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Daplie/authenticator-cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Daplie/authenticator-cli#readme"
|
||||
}
|
Loading…
Reference in New Issue