Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@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("@bonniernews/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 3 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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.