
Research
/Security News
jscrambler npm Package Compromised in Supply Chain Attack
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.
eventsource-client
Advanced tools
A modern, streaming client for server-sent events/eventsource.
Yes! There are indeed lots of different EventSource clients and polyfills out there. In fact, I am a co-maintainer of the most popular one. This one is different in a few ways, however:
fetch() API and Web Streamserrornpm install --save eventsource-client
Basically, any environment that supports:
import {createEventSource} from 'eventsource-client'
const es = createEventSource({
url: 'https://my-server.com/sse',
// your `fetch()` implementation of choice, or `globalThis.fetch` if not set
fetch: myFetch,
})
let seenMessages = 0
for await (const {data, event, id} of es) {
console.log('Data: %s', data)
console.log('Event ID: %s', id) // Note: can be undefined
console.log('Event: %s', event) // Note: can be undefined
if (++seenMessages === 10) {
break
}
}
// IMPORTANT: EventSource is _not_ closed automatically when breaking out of
// loop. You must manually call `close()` to close the connection.
es.close()
onMessage callback)import {createEventSource} from 'eventsource-client'
const es = createEventSource({
url: 'https://my-server.com/sse',
onMessage: ({data, event, id}) => {
console.log('Data: %s', data)
console.log('Event ID: %s', id) // Note: can be undefined
console.log('Event: %s', event) // Note: can be undefined
},
// your `fetch()` implementation of choice, or `globalThis.fetch` if not set
fetch: myFetch,
})
console.log(es.readyState) // `open`, `closed` or `connecting`
console.log(es.lastEventId)
// Later, to terminate and prevent reconnections:
es.close()
import {createEventSource} from 'eventsource-client'
const es = createEventSource('https://my-server.com/sse')
for await (const {data} of es) {
console.log('Data: %s', data)
}
MIT © Espen Hovlandsdal
FAQs
Modern EventSource client for browsers and Node.js
The npm package eventsource-client receives a total of 148,039 weekly downloads. As such, eventsource-client popularity was classified as popular.
We found that eventsource-client demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.

Research
/Security News
A malicious .NET package is typosquatting the Braintree SDK to steal live payment card data, merchant API keys, and host secrets from production apps.

Security News
/Research
Compromised Injective SDK npm version 1.20.21 exfiltrates wallet private keys and mnemonics through fake telemetry functionality.