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
2e1b7867
Commit
2e1b7867
authored
Nov 07, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
f232942d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
22 deletions
+14
-22
fff.js
fff.js
+13
-22
package.json
package.json
+1
-0
No files found.
fff.js
View file @
2e1b7867
// Import the required packages
import
clipboardy
from
'
clipboardy
'
;
const
otplib
=
require
(
'
otplib
'
);
const
clipboardy
=
require
(
'
clipboardy
'
);
// Variable to store the last generated token
let
lastToken
=
''
;
// Function to check and display the 2FA code if it changes
// Stores the previous clipboard content to detect changes
async
function
checkForNewCode
()
{
let
previousContent
=
""
;
try
{
// Read the secret key from the clipboard
const
secret
=
await
clipboardy
.
read
();
// Generate the TOTP code using the secret from the clipboard
// Function to check the clipboard content
const
currentToken
=
otplib
.
authenticator
.
generate
(
secret
);
const
checkClipboard
=
()
=>
{
const
currentContent
=
clipboardy
.
readSync
();
// If the current token is different from the last token, log it
// If the content has changed, display it
if
(
currentToken
!==
lastToken
)
{
if
(
currentContent
!==
previousContent
)
{
console
.
log
(
`New 2FA code:
${
currentToken
}
`
);
console
.
log
(
"
Clipboard Content:
"
,
currentContent
);
lastToken
=
currentToken
;
previousContent
=
currentContent
;
}
}
catch
(
error
)
{
console
.
error
(
"
Failed to read from clipboard or generate TOTP:
"
,
error
);
}
}
}
}
;
//
Run the check every second (1000 ms) to monitor changes in the TOTP code
//
Check the clipboard every second
setInterval
(
check
ForNewCode
,
1000
);
setInterval
(
check
Clipboard
,
1000
);
package.json
View file @
2e1b7867
{
{
"name"
:
"aws"
,
"name"
:
"aws"
,
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"type"
:
"module"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
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