
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@types/eventsource
Advanced tools
TypeScript definitions for eventsource
@types/eventsource provides TypeScript definitions for the EventSource API, which is used for receiving server-sent events (SSE). This package allows TypeScript developers to use the EventSource API with type safety and autocompletion in their projects.
Creating an EventSource instance
This feature allows you to create a new EventSource instance to listen for server-sent events from a specified URL.
const eventSource = new EventSource('https://example.com/events');
Listening for messages
This feature allows you to set up an event listener for incoming messages from the server. The event handler receives an event object containing the data sent by the server.
eventSource.onmessage = (event) => { console.log(event.data); };
Handling errors
This feature allows you to handle errors that occur while receiving events. The event handler receives an event object that can be used to log or handle the error.
eventSource.onerror = (event) => { console.error('Error:', event); };
Closing the connection
This feature allows you to close the EventSource connection when it is no longer needed, freeing up resources.
eventSource.close();
The 'eventsource' package is a polyfill for the EventSource API, allowing it to be used in environments where it is not natively supported, such as Node.js. Unlike @types/eventsource, which provides TypeScript definitions, 'eventsource' provides the actual implementation of the EventSource API.
The 'sse-channel' package provides a simple way to implement server-sent events in Node.js. It allows you to create an SSE channel and send events to connected clients. This package is more focused on the server-side implementation of SSE, whereas @types/eventsource is focused on the client-side TypeScript definitions.
The 'express-sse' package is an easy-to-use SSE middleware for Express.js. It simplifies the process of setting up SSE endpoints in an Express application. This package is more about integrating SSE with Express, while @types/eventsource provides TypeScript support for the EventSource API.
npm install --save @types/eventsource
This package contains type definitions for eventsource (https://github.com/EventSource/eventsource).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/eventsource.
These definitions were written by Scott Lee Davis, Ali Afroozeh, Pedro Gámez, and Akuukis.
FAQs
Stub TypeScript definitions entry for eventsource, which provides its own types definitions
We found that @types/eventsource 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.