
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
eventsource-polyfill
Advanced tools
A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/)
The eventsource-polyfill npm package provides a polyfill for the EventSource API, which is used for receiving server-sent events (SSE). This is particularly useful for environments that do not natively support EventSource, such as older browsers.
Basic EventSource Connection
This feature allows you to establish a basic connection to a server that sends events. The code sample demonstrates how to create an EventSource instance and handle incoming messages.
const EventSource = require('eventsource-polyfill');
const es = new EventSource('http://example.com/events');
es.onmessage = function(event) {
console.log('New message:', event.data);
};
Handling Different Event Types
This feature allows you to listen for specific types of events sent by the server. The code sample shows how to add an event listener for a custom event type.
const EventSource = require('eventsource-polyfill');
const es = new EventSource('http://example.com/events');
es.addEventListener('customEvent', function(event) {
console.log('Custom event received:', event.data);
});
Error Handling
This feature provides a way to handle errors that may occur during the connection. The code sample demonstrates how to set up an error handler.
const EventSource = require('eventsource-polyfill');
const es = new EventSource('http://example.com/events');
es.onerror = function(event) {
console.error('Error occurred:', event);
};
The eventsource package is a robust implementation of the EventSource API for Node.js. It provides similar functionalities to eventsource-polyfill but is specifically designed for server-side use in Node.js environments.
The sse package is another implementation of server-sent events for Node.js. It offers a simple API for creating and managing SSE connections, similar to eventsource-polyfill, but is more focused on server-side applications.
FAQs
A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/)
The npm package eventsource-polyfill receives a total of 191,312 weekly downloads. As such, eventsource-polyfill popularity was classified as popular.
We found that eventsource-polyfill 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.