Gathering detailed insights and metrics for eventsource
Gathering detailed insights and metrics for eventsource
Gathering detailed insights and metrics for eventsource
Gathering detailed insights and metrics for eventsource
launchdarkly-eventsource
Fork of eventsource package - W3C compliant EventSource client for Node.js and browser (polyfill)
eventsource-polyfill
A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/)
@types/eventsource
TypeScript definitions for eventsource
@sanity/eventsource
EventSource polyfill for browser and node.js
EventSource client for Node.js and Browser (polyfill)
npm install eventsource
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
911 Stars
345 Commits
252 Forks
31 Watching
23 Branches
50 Contributors
Updated on 14 Nov 2024
Minified
Minified + Gzipped
JavaScript (99.78%)
HTML (0.22%)
Cumulative downloads
Total Downloads
Last day
-5.7%
952,969
Compared to previous day
Last week
2.5%
5,148,514
Compared to previous week
Last month
17.3%
21,226,211
Compared to previous month
Last year
-22.9%
232,255,216
Compared to previous year
8
This library is a pure JavaScript implementation of the EventSource client. The API aims to be W3C compatible.
You can use it with Node.js or as a browser polyfill for
browsers that don't have native EventSource
support.
npm install eventsource
npm install
node ./example/sse-server.js
node ./example/sse-client.js # Node.js client
open http://localhost:8080 # Browser client - both native and polyfill
curl http://localhost:8080/sse # Enjoy the simplicity of SSE
Just add example/eventsource-polyfill.js
file to your web page:
1<script src=/eventsource-polyfill.js></script>
Now you will have two global constructors:
1window.EventSourcePolyfill 2window.EventSource // Unchanged if browser has defined it. Otherwise, same as window.EventSourcePolyfill
If you're using webpack or browserify
you can of course build your own. (The example/eventsource-polyfill.js
is built with webpack).
You can define custom HTTP headers for the initial HTTP request. This can be useful for e.g. sending cookies
or to specify an initial Last-Event-ID
value.
HTTP headers are defined by assigning a headers
attribute to the optional eventSourceInitDict
argument:
1var eventSourceInitDict = {headers: {'Cookie': 'test=test'}}; 2var es = new EventSource(url, eventSourceInitDict);
By default, https requests that cannot be authorized will cause the connection to fail and an exception to be emitted. You can override this behaviour, along with other https options:
1var eventSourceInitDict = {https: {rejectUnauthorized: false}}; 2var es = new EventSource(url, eventSourceInitDict);
Note that for Node.js < v0.10.x this option has no effect - unauthorized HTTPS requests are always allowed.
Unauthorized and redirect error status codes (for example 401, 403, 301, 307) are available in the status
property in the error event.
1es.onerror = function (err) { 2 if (err) { 3 if (err.status === 401 || err.status === 403) { 4 console.log('not authorized'); 5 } 6 } 7};
You can define a proxy
option for the HTTP request to be used. This is typically useful if you are behind a corporate firewall.
1var es = new EventSource(url, {proxy: 'http://your.proxy.com'});
MIT-licensed. See LICENSE
The latest stable version of the package.
Stable Version
2
9.3/10
Summary
Exposure of Sensitive Information in eventsource
Affected Versions
>= 2.0.0, < 2.0.2
Patched Versions
2.0.2
9.3/10
Summary
Exposure of Sensitive Information in eventsource
Affected Versions
< 1.1.1
Patched Versions
1.1.1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 6/17 approved changesets -- score normalized to 3
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
63 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More