Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aws
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
aws
Commits
5975cbdd
Commit
5975cbdd
authored
Jul 26, 2025
by
Admin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddd
parent
9a564b05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
+18
-13
fff.js
fff.js
+18
-13
No files found.
fff.js
View file @
5975cbdd
...
...
@@ -2,8 +2,11 @@
const
{
exec
}
=
require
(
"
child_process
"
);
const
otplib
=
require
(
"
otplib
"
);
// Expected length of the secret key
const
expectedSecretLength
=
"
ZGQ7DIXAENR5HPXONMYQJQPF2XVYM3OEUM4OBMBMDKRZ5DAVNYNPAISZTD76WML2
"
.
length
;
// List of valid secret lengths
const
validSecretLengths
=
[
"
ZGQ7DIXAENR5HPXONMYQJQPF2XVYM3OEUM4OBMBMDKRZ5DAVNYNPAISZTD76WML2
"
.
length
,
"
QG5Z22ORKZC46SJRCCOPPEE5K475NHO7
"
.
length
];
// Store the last generated token and clipboard content
let
lastToken
=
""
;
...
...
@@ -29,27 +32,29 @@ function checkForNewCode(secret) {
previousSecret
=
secret
;
}
// Generate TOTP code using the current secret
const
currentToken
=
otplib
.
authenticator
.
generate
(
secret
);
try
{
// Generate TOTP code using the current secret
const
currentToken
=
otplib
.
authenticator
.
generate
(
secret
);
// If the current token is different from the last token, log it
if
(
currentToken
!==
lastToken
)
{
console
.
log
(
`New 2FA code:
${
currentToken
}
`
);
lastToken
=
currentToken
;
// If the current token is different from the last token, log it
if
(
currentToken
!==
lastToken
)
{
console
.
log
(
`New 2FA code:
${
currentToken
}
`
);
lastToken
=
currentToken
;
}
}
catch
(
error
)
{
console
.
error
(
"
Error generating TOTP code:
"
,
error
.
message
);
}
}
// 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 if length matches
readClipboard
((
clipboardContent
)
=>
{
if
(
clipboardContent
.
length
===
expectedSecretLength
)
{
if
(
validSecretLengths
.
includes
(
clipboardContent
.
length
)
)
{
checkForNewCode
(
clipboardContent
);
}
else
{
checkForNewCode
(
previousSecret
);
}
else
checkForNewCode
(
previousSecret
)
});
},
1000
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment