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.
no-sleep-app
Advanced tools
NoSleepApp is a lightweight JavaScript library that prevents devices from going to sleep during critical activities. It uses the Screen Wake Lock API or a fallback video playback method to keep the screen active, ensuring uninterrupted user experiences ac
no-sleep-app is a lightweight, powerful JavaScript library designed to prevent devices from going to sleep during crucial tasks. Whether you’re developing a media player, an interactive app, or a seamless web experience, no-sleep-app ensures your application keeps the screen active across all platforms.
As developers, maintaining an uninterrupted user experience is paramount. However, devices often go into sleep mode during long-running tasks or media playback, disrupting users. no-sleep-app offers a seamless, cross-platform solution with minimal configuration.
no-sleep-app uses the Screen Wake Lock API (when available) to keep the device screen active. For legacy devices, such as older iOS versions, it falls back to a simple video playback trick. This ensures reliable performance, no matter the device or platform.
no-sleep-app is fully compatible with both iOS and Android devices. Whether your users are on mobile phones or tablets, this library will keep their screens active during important tasks. The library automatically detects the platform and applies the most appropriate method to prevent the device from going to sleep.
Install no-sleep-app via npm or yarn:
npm install no-sleep-app
or
yarn add no-sleep-app
Alternatively, you can include the no-sleep-app.js
script directly in your HTML.
To use no-sleep-app, instantiate the library and call its enable()
and disable()
methods to start and stop preventing sleep mode:
import NoSleepApp from 'no-sleep-app';
const noSleep = new NoSleepApp();
// Enable to prevent sleep
noSleep.enable();
// Disable to allow the device to go to sleep
noSleep.disable();
Check whether no-sleep-app is currently active:
if (noSleep.isEnabled) {
console.log('NoSleep is enabled');
} else {
console.log('NoSleep is disabled');
}
With the latest update to no-sleep-app, a set of default options has been introduced to make customization easier when you instantiate the library without providing specific configuration options.
🛠️ Control Behavior: Configure how the app prevents sleep with options for strategies, retry intervals, and fallback mechanisms.
⚙️ Flexible and Reliable: Choose the Wake Lock strategy, set retry intervals, and enable or disable fallbacks based on device capabilities.
⚡ Performance Optimization: Control when and how often the app retries to ensure the best experience without unnecessary retries.
const defaultOptions = {
strategy: ''wakeLock'|'video'|'legacy'', // Default strategy is wakeLock
retryInterval: 10000, // Default retry interval is 10 seconds
fallbackEnabled: true, // Default fallback is enabled
};
defaultOptions
strategy: ''wakeLock'|'video'|'legacy'}'
retryInterval: 10000
: Control how often the library retries to enable the Wake Lock API if it initially fails. By default, it will retry every 10 seconds.
fallbackEnabled: true
: Enable or disable fallback mechanisms, such as video playback, when Wake Lock isn't supported. By default, this is set to true.
import NoSleepApp from 'no-sleep-app';
// Instantiate with default options
const noSleep = new NoSleepApp( {
strategy: 'wakeLock',
retryInterval: 10000,
fallbackEnabled: true,
});
defaultOptions
:If you want to modify the default behavior, simply pass custom options during initialization:
const customOptions = {
strategy: 'video', // Use video strategy instead of wakeLock
retryInterval: 5000, // Retry every 5 seconds
fallbackEnabled: false, // Disable fallback mechanisms
};
const noSleep = new NoSleepApp(customOptions);
noSleep.enable();
This makes it easy to control how no-sleep-app behaves across different devices and platforms!
In today’s world, where performance and user experience are critical, keeping a device from going to sleep can be essential for certain types of applications.
✅ Improved User Experience: Prevent interruptions during critical activities.
🎮 Perfect for Interactive Applications: Ideal for gaming platforms, media players, and more.
🌐 Cross-Browser Compatibility: Works seamlessly on modern and older devices.
⚡ Lightweight & Efficient: Keeps devices awake without draining the battery unnecessarily.
Whether you're building an interactive video player, a gaming platform, or any web-based service that requires continuous screen activity, no-sleep-js provides a reliable solution. It’s built to be cross-browser and fully functional on both modern and older devices, ensuring your users won’t face interruptions during their experience.
MIT License
Copyright (c) 2024 Vitalii Semianchuk
FAQs
NoSleepApp is a lightweight JavaScript library that prevents devices from going to sleep during critical activities. It uses the Screen Wake Lock API or a fallback video playback method to keep the screen active, ensuring uninterrupted user experiences ac
The npm package no-sleep-app receives a total of 256 weekly downloads. As such, no-sleep-app popularity was classified as not popular.
We found that no-sleep-app demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.