Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
medooze-event-emitter
Advanced tools
This is a modified version of Node.js EventEmitter
class for use within Medooze's codebase.
It's exported directly by this module, and meant to be extended rather than used as a standalone object.
The changes are:
emit()
is marked protected to prevent it from accidentally being called from outside of the classmaxListener
limit is removedstop()
method, which removes all listeners and causes future calls (except emit()
) to be no-opsemit()
(thrown at the next tick instead)Using the same mechanism as tiny-typed-emitter, this class allows users to declare the events that a class may emit, as well as the arguments each one accepts. Calls to on()
/ once()
/ emit()
are then typechecked accordingly.
Usage is as follows: projects that use type checking must supply an interface as generic parameter to the class when extending it. Each property of this interface is an event, and its type must be that of the listener (a function accepting some arguments and returning void
).
Here's an example of how that would look in a project that uses JSDoc annotations (see tiny-typed-emitter for an example using TypeScript syntax):
const Emitter = require("medooze-event-emitter");
/**
* @typedef {Object} SubscriptionEvents
* @property {(transport: Transport, kind: boolean) => void} inited - subscription has initialized
* @property {() => void} stopped - subscription has stopped
*/
/** @extends {Emitter<SubscriptionEvents>} */
class Subscription extends Emitter {
// ...
}
Here we define a Subscription
class that may emit two events: stopped
, with no arguments, and inited
with an argument of type Transport
and another of type boolean
.
FAQs
type-safe, modified version of EventEmitter
We found that medooze-event-emitter 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.