Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@bonniernews/local-esi
Advanced tools
Make your Express app work like it had Akamai Edge Side Includes parsing or just stream your ESI decorated markup to the parser.
localEsi(html, req, res, next)
localEsi.createStream(req)
localEsi.createParser(req)
localEsi.htmlWriter()
localEsi(html, req, res, next)
Use as an expressjs request callback function.
Arguments:
html
: string with markupreq
: request with headers and cookiesres
: response with send, redirect, set, and status functionnext
: function to catch occasional error in"use strict";
const localEsi = require("@bonniernews/local-esi");
module.exports = (req, res, next) => {
res.render("index", { data: "a" }, (err, html) => {
if (err) return next(err);
localEsi(html, req, res, next);
});
};
localEsi.createStream(req)
Create pipable ESI parse as stream. Emits events.
Arguments:
req
: request with headers and cookiesReturns markup stream.
"use strict";
const {createStream} = require("@bonniernews/local-esi");
module.exports = (req, res, next) => {
const esiParseStream = createStream(req)
.on("add_header", (name, value) => res.set(name, value))
.once("set_redirect", (statusCode, location) => res.redirect(statusCode, location));
res.render("index")
.pipe(esiParseStream)
.on("error", next);
};
localEsi.createParser(req)
Create ESI parse transform stream. Emits events.
Arguments:
req
: request with headers and cookiesRequires markup stream to read from. Writes object stream.
"use strict";
const HtmlParser = require("atlas-html-stream");
const {createParser: createESIParser, htmlWriter} = require("@bonniernews/local-esi");
module.exports = function channelRendering(req, res, next) {
const esiParser = createESIParser(req)
.once("set_redirect", (statusCode, location) => {
res.status(statusCode).redirect(location);
})
.on("set_response_code", (statusCode, body) => {
res.status(statusCode);
if (body) res.send(body);
})
.on("add_header", (name, value) => {
res.set(name, value);
});
return res.render("index")
.pipe(new HtmlParser({preserveWS: true}))
.pipe(esiParser)
.pipe(htmlWriter())
.pipe(res)
.once("error", (err) => {
next(err);
});
};
localEsi.htmlWriter()
Returns transform object stream to markup buffer stream.
ESI instructions are emitted as events.
set_response_code
Set status code and optional body.
add_header
Set header name and value.
set_redirect
Redirect with status code and location.
Object streams requires the schema {name, data, text}
representing tag name, tag attributes, and text. This project uses atlas-html-stream for html parsing.
FAQs
Local Edge Side Includes parser
The npm package @bonniernews/local-esi receives a total of 20 weekly downloads. As such, @bonniernews/local-esi popularity was classified as not popular.
We found that @bonniernews/local-esi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 27 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
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.