Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@bva/countdown
Advanced tools
This is a JS based component for adding countdown timers using data attributes and minimal JS.
yarn add @bva/countdown
to install, and then import with import Timer from '@bva/countdown';
At the moment there is only one (very optional) parameter (passed in an object):
This is how the component does most of its configuration. There are a couple of data attributes that can be added to timers to change how they operate:
%D:%H:%M:%S
):
The component introduces a custom event as well:
countdownTimerEnded
: this is bound directly to timer elements and is dispatched when the timer's countdown ends.<!-- HTML -->
<div class="my-timer"
data-timer="3600"
data-timer-format="%M:%H"
data-complete-message="Time's up!"
data-lazy-timer
data-pause-timer>
</div>
// JavaScript
import Timer from '@bva/countdown';
document.addEventListener('DOMContentLoaded', () => {
// add event listeners to the timer elements
const timerElements = document.querySelectorAll('[data-timer]');
timerElements.forEach((timerElement) => {
timerElement.addEventListener('countdownTimerEnded', (event) => {
console.log('Timer has ended for:', event.target);
});
});
// now setup all the timers to start their countdowns
Timer.setup({});
});
There are two other methods the component exposes for more manual control over timers:
startTimer
: takes in the timer element as a parameter and will start the timer for that timer element.pauseTimer
: takes in the timer element as a parameter and will stop the timer for that timer element.Here is an example for the two methods:
import Timer from '@bva/countdown';
document.addEventListener('DOMContentLoaded', () => {
// Assuming there is only one timer on the page I care about
const myTimer = document.querySelector('[data-timer]');
Timer.startTimer(myTimer);
const stopButton = document.querySelector('[data-stop-button]');
stopButton.addEventListener('click', () => {
Timer.pauseTimer(myTimer)
});
});
FAQs
Adds a JS component for adding countdown timers
We found that @bva/countdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.