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.
composite-disposable
Advanced tools
This is a simple library for implementing event subscription APIs. Inspired https://github.com/atom/event-kit. Use default event handler in Node.js.
const { EventEmitter } = require('events');
const CompositeDisposable = require('composite-disposable');
class User {
constructor() {
this.emitter = new EventEmitter();
this.subscriptions = new CompositeDisposable();
}
onDidChangeName(callback) {
this.subscriptions.add(this.emitter.on('change-name', callback));
}
setName(name) {
if (this.name !== name) {
this.name = name;
this.emitter.emit('change-name', this.name);
}
return this.name;
}
destroy() {
this.subscriptions.dispose();
}
}
In the example above, we implement ::onDidChangeName
on the user object, which will register callbacks to be invoked whenever the user's name changes. To do so, we make use of an internal EventEmitter
instance. We use ::on
to subscribe the given callback in ::onDidChangeName
, and ::emit
in ::setName
to notify subscribers. Finally, when the User instance is destroyed we call ::dispose
on the emitter to unsubscribe all subscribers.
FAQs
Simple library for implementing and consuming evented APIs
The npm package composite-disposable receives a total of 1 weekly downloads. As such, composite-disposable popularity was classified as not popular.
We found that composite-disposable 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.