Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
enhanced-datachannel
Advanced tools
Wanna enhance(RTCDataChannel)
for general usage.
npm i enhanced-datachannel
You need to bundle it into your app.
import { based, promised, chunked } from "enhanced-datachannel";
const pc = new RTCPeerConnection();
// create DataChannel instance
const dc = pc.createDataChannel("mych");
// or
pc.addEventListener("datachannel", ev => {
const dc = ev.channel;
});
// signaling by yourself and connect p2p...
// enhance it for your usage!
const basedDC = based(dc);
// or
const promisedDC = promised(dc);
// or
const chunkedDC = chunked(dc);
Passed instance should be reliable
and ordered
mode.
const basedDC = based(dc);
Do nothing, just wrap with EventEmitter
.
This class has the same properties which RTCDataChannel
instance has.
readyState
label
binaryType
See spec for the detail.
and also emits the same event types via EventEmitter
.
open
close
error
message
bufferedamountlow
The send()
method is equivalent to dc.send()
and on("message")
handler is equivalent to dc.onmessage
.
// recv
basedDC.on("message", data => {});
// send
basedDC.send(data);
const promisedDC = promised(dc);
Make it possible to await dc.send(json)
.
This class extends BasedDataChannel
.
But this class has special send()
method and on("message")
handler.
// recv
promisedDC.on("message", (data, resolve, reject) => {
try {
console.log(data); // "Take this!"
resolve("Thank you!");
} catch (err) {
reject(err);
}
});
// send
const res = await promisedDC.send("Take this!");
console.log(res); // "Thank you!"
If recv side does not resolve()
neither nor reject()
, it is treated as reject()
with timeout.
const chunkedDC = chunked(dc);
Make it possible to send a large file.
This class extends BasedDataChannel
.
But this class has special send()
method and on("message")
handler.
// recv
chunkedDC.on("message", (blob, meta) => {
// download it
const $downloadLink = document.createElement("a");
$downloadLink.href = URL.createObjectURL(blob);
$downloadLink.download = meta.name;
$downloadLink.textContent = meta.name;
document.body.append($downloadLink);
});
// send
await chunkedDC.send(file, { name: "prof.png" });
FAQs
Wanna `enhance(RTCDataChannel)` for general usage.
The npm package enhanced-datachannel receives a total of 1 weekly downloads. As such, enhanced-datachannel popularity was classified as not popular.
We found that enhanced-datachannel 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.