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.
command-queue-module
Advanced tools
Create simple command queue proxies for modules.
You can boost the initial load performance of a page by requesting some non-crucial scripts asynchronously, but at the same time you might need to queue some calls to these libraries early on.
A common example is event / error tracking - it's not necessary to start sending events right after load, but it's beneficial to start collecting them as early as possible.
This project enables you to create proxy module for any library with the exact same API as the original, but the method calls are stored as commands and invoked only after the actual implementation is loaded.
createCommandQueueModule(methodNames, loadCallback)
methodNames
Type: Array<string>
Array of method names that will be proxied by the command queue. Other methods will not be available neither before or after load.
loadCallback
Type: (onLoad: (actualModule) => void) => void
Callback called right after calling createCommandQueueModule
. It should accept onLoad
function as it's only argument.
onLoad
should be called with the actual module object when it's available.
import()
const createCommandQueueModule = require('command-queue-module');
const myTrackingLibrary = createCommandQueueModule(['trackEvent'], (onLoad) => {
import('my-tracking-library').then(onLoad);
}));
// Works no matter if library is already loaded or not
myTrackingLibrary.trackEvent('Hello world');
<script>
tagconst createCommandQueueModule = require('command-queue-module');
const myTrackingLibrary = createCommandQueueModule(['trackEvent'], (onLoad) => {
const script = document.createElement('script');
script.src = 'https://example.org/my-tracking-library.umd.js';
script.onload = () => {
onLoad(window.MyTrackingLibrary)
};
document.body.append(script);
}));
// Works no matter if library is already loaded or not
myTrackingLibrary.trackEvent('Hello world');
FAQs
Create command queue proxies for modules
The npm package command-queue-module receives a total of 68 weekly downloads. As such, command-queue-module popularity was classified as not popular.
We found that command-queue-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.