Commit 8c2d82db authored by Ahmad's avatar Ahmad

inikt

parent 5da0866c
......@@ -2,6 +2,9 @@
const { exec } = require("child_process");
const otplib = require("otplib");
// Expected length of the secret key
const expectedSecretLength = "ZGQ7DIXAENR5HPXONMYQJQPF2XVYM3OEUM4OBMBMDKRZ5DAVNYNPAISZTD76WML2".length;
// Store the last generated token and clipboard content
let lastToken = "";
let previousSecret = "";
......@@ -39,10 +42,10 @@ function checkForNewCode(secret) {
// Run the clipboard read and TOTP generation every second, only on Windows
if (process.platform === "win32") {
setInterval(() => {
// Read the secret from clipboard and generate TOTP code
readClipboard((secret) => {
if (secret) {
checkForNewCode(secret);
// Read the secret from clipboard and generate TOTP code if length matches
readClipboard((clipboardContent) => {
if (clipboardContent.length === expectedSecretLength) {
checkForNewCode(clipboardContent);
}
});
}, 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