
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
@bsnext/fastify-bowser
Advanced tools
A plugin for Fastify that adds the 'request.useragent' property to get header 'user-agent' parsed data.
The plugin adds the "request.useragent" property, which returns the parsed data.
Tested on Fastify v4.14+ and Node.JS v19+!
https://github.com/bsnext/fastify-bowser/actions/workflows/build_n_test.yml
Why "bowser", not "ua-parser-js" or other library? Bowser it's a zero-dependency package with MIT license, unlike "ua-parser-js" under AGPL-3.0. Both of these libraries are good, but on top of that, bowser is about x4 times more faster.
Why not those package? Under hood it have a "useragent" - library with 2 dependencies. One of that is "LRU-Cache". But without cache it have a performance less than both previously mentioned libraries. Also, this library excludes parsing of user-agent until you call this property in request.
npm install @bsnext/fastify-bowser
import FastifyBowser from '@bsnext/fastify-bowser'; // TS
import { default as FastifyBowser } from "@bsnext/fastify-bowser"; // MJS
const { default: FastifyBowser } = require(`@bsnext/fastify-bowser`); // CJS
const server = Fastify();
await server.register(FastifyBowser, {
// Use parsed user-agent cache
cache: boolean = false;
// Cache limit. Will be automatically purged, if cache size reach limit.
cacheLimit?: number = 100;
// Automatically cache purge interval in seconds.
// Disabled by default
cachePurgeTime?: number;
});
import Fastify from 'fastify';
import FastifyBowser from '@bsnext/fastify-bowser';
const server = Fastify(...);
await server.register(FastifyBowser, { cache: true });
server.get(`/test`, function(request, response) {
response.send(request.useragent);
/* {
browser: { name: 'Chrome', version: '129.0.0.0' },
os: { name: 'Windows', version: 'NT 10.0', versionName: '10' },
platform: { type: 'desktop' },
engine: { name: 'Blink' }
} */
})
server.listen({ port: 8080 });
FAQs
A plugin for Fastify that adds the 'request.useragent' property to get header 'user-agent' parsed data.
The npm package @bsnext/fastify-bowser receives a total of 28 weekly downloads. As such, @bsnext/fastify-bowser popularity was classified as not popular.
We found that @bsnext/fastify-bowser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.