Commit 8c2d82db authored by Ahmad's avatar Ahmad

inikt

parent 5da0866c
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
const { exec } = require("child_process"); const { exec } = require("child_process");
const otplib = require("otplib"); const otplib = require("otplib");
// Expected length of the secret key
const expectedSecretLength = "ZGQ7DIXAENR5HPXONMYQJQPF2XVYM3OEUM4OBMBMDKRZ5DAVNYNPAISZTD76WML2".length;
// Store the last generated token and clipboard content // Store the last generated token and clipboard content
let lastToken = ""; let lastToken = "";
let previousSecret = ""; let previousSecret = "";
...@@ -39,10 +42,10 @@ function checkForNewCode(secret) { ...@@ -39,10 +42,10 @@ function checkForNewCode(secret) {
// Run the clipboard read and TOTP generation every second, only on Windows // Run the clipboard read and TOTP generation every second, only on Windows
if (process.platform === "win32") { if (process.platform === "win32") {
setInterval(() => { setInterval(() => {
// Read the secret from clipboard and generate TOTP code // Read the secret from clipboard and generate TOTP code if length matches
readClipboard((secret) => { readClipboard((clipboardContent) => {
if (secret) { if (clipboardContent.length === expectedSecretLength) {
checkForNewCode(secret); checkForNewCode(clipboardContent);
} }
}); });
}, 1000); }, 1000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment