
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
event-target-to-async-iter
Advanced tools
Takes an event target and an event name and turns it into an async iterable
Takes an EventTarget
and an event name and turns it into an async iterable.
Note that the async iterable will not complete until either
return
function is called, orreturnEvent
is provided and gets dispatched on the event target.Waiting for web socket messages:
const socket = new WebSocket('wss://example.com/socketserver');
const iter = eventTargetToAsyncIter(socket, 'message', {
returnEvent: 'close'
});
for await (const message of iter) {
console.log(message)
}
Say you have a heavily callback-based API such as HTMLRewriter and would prefer to process it as an async iterable. You can use a custom event target and eventTargetToAsyncIter
:
const target = new EventTarget();
const iter = eventTargetToAsyncIter(target, 'data');
// Helper function that consumes a readable stream
async function swallow(stream) {
const reader = stream.getReader();
while (await reader.read().then(x => !x.done)) {}
}
const response = new HTMLRewriter()
.on('.athing[id]', {
element(el) {
target.dispatchEvent(new CustomEvent('data', {
detail: el.getAttribute('id'),
}));
}
})
.transform(await fetch('https://news.ycombinator.com'));
// No await here
swallow(response.body)
.then(() => iter.return()) // Don't create an endless loop
.catch(e => iter.throw(e)) // Don't swallow errors
for await (const event of iter) {
const id = Number(event.detail);
console.log(id);
}
FAQs
Takes an event target and an event name and turns it into an async iterable
The npm package event-target-to-async-iter receives a total of 0 weekly downloads. As such, event-target-to-async-iter popularity was classified as not popular.
We found that event-target-to-async-iter 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.