-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fc1dc96
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package-lock.json | ||
settings.json | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# TOTP Generator | ||
This is a simple TOTP (Time-based One-Time Password) generator that generates TOTP codes for multiple accounts. | ||
|
||
## Usage | ||
1. Create a settings.json file with your account tokens: | ||
|
||
```json | ||
{ | ||
"keys": [ | ||
{ | ||
"account": "Email", | ||
"token": "JBSWY3DPEHPK3PXP" | ||
}, | ||
{ | ||
"account": "GitHub", | ||
"token": "JBSWY3DPEHPK3PXP" | ||
} | ||
] | ||
} | ||
``` | ||
1. Run node index.js | ||
|
||
It will generate and print the current TOTP codes for each account every 30 seconds. | ||
|
||
## Dependencies | ||
|
||
- totp-generator - Used to generate the TOTP codes | ||
- fs - Used to read the settings file | ||
|
||
## License | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {TOTP} from 'totp-generator' | ||
import { readFileSync } from 'fs' | ||
import { exit } from 'process' | ||
|
||
let keys = [{ | ||
account: 'UNDEFINED', | ||
token: 'CCCCCCCCCCCCCCCC' | ||
}] | ||
|
||
try { | ||
const settings = readFileSync('./settings.json') | ||
keys = JSON.parse(settings).keys | ||
} catch (error) { | ||
console.log('No settings file found (settings.json)') | ||
exit(0) | ||
} | ||
|
||
while (true) { | ||
console.clear() | ||
console.log('.........TOTP GENERATOR.........') | ||
keys.forEach(element => { | ||
GenerateOTP(element.account, element.token) | ||
}) | ||
|
||
let nextIn = 0 | ||
let secondsNow = new Date().getSeconds() | ||
nextIn = secondsNow < 30 ? 30 - secondsNow : 60 - secondsNow | ||
while (nextIn > 1) { | ||
secondsNow = new Date().getSeconds() | ||
nextIn = secondsNow < 30 ? 30 - secondsNow : 60 - secondsNow | ||
process.stdout.write('\r'+new Date().toTimeString()+' Next in: '+nextIn+' seconds...') | ||
await new Promise(resolve => setTimeout(resolve, 1000)) | ||
} | ||
} | ||
|
||
function GenerateOTP(account, token) { | ||
const { otp } = TOTP.generate(token) | ||
console.log(account) | ||
console.log(otp) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "totp-generator", | ||
"version": "1.0.0", | ||
"description": "This is a simple TOTP (Time-based One-Time Password) generator that generates TOTP codes for multiple accounts.", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"start": "node index.js", | ||
"dev": "nodemon index.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"totp-generator": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^3.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"keys":[ | ||
{ | ||
"account":"Google Account", | ||
"token":"AAAAAAAAAAAAAAAA" | ||
}, | ||
{ | ||
"account":"GitHub Account", | ||
"token":"BBBBBBBBBBBBBBBB" | ||
} | ||
] | ||
} |