Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
User-Agent string parser based on Browserscope.org algorithms for more browser reporting
The 'useragent' npm package is used to parse and identify user agent strings. It helps in detecting the browser, version, operating system, and device type from a given user agent string.
Parsing User Agent Strings
This feature allows you to parse a user agent string and get a readable format of the browser, version, and operating system.
const useragent = require('useragent');
const agent = useragent.parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
console.log(agent.toString());
Detecting Browser
This feature allows you to detect the browser family from a user agent string.
const useragent = require('useragent');
const agent = useragent.parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
console.log(agent.family);
Detecting Operating System
This feature allows you to detect the operating system from a user agent string.
const useragent = require('useragent');
const agent = useragent.parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
console.log(agent.os.toString());
Detecting Device Type
This feature allows you to detect the device type from a user agent string.
const useragent = require('useragent');
const agent = useragent.parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
console.log(agent.device.toString());
The 'ua-parser-js' package is a JavaScript-based user agent string parser. It provides similar functionalities to 'useragent' but is known for its speed and lightweight nature. It can parse user agent strings to detect browser, engine, OS, CPU, and device information.
The 'useragent-parser' package is another alternative for parsing user agent strings. It offers similar features to 'useragent' but focuses on providing a more straightforward API and better performance.
The 'detect-browser' package is a lightweight library for detecting browser information from user agent strings. It is simpler and more focused on browser detection compared to 'useragent'.
#node-useragent
A user agent string parser for Node.js. Based on the Browserscope.org UA parser so we can actually get accurate version numbers of the browsers instead parsing out the render engine version numbers.
Using the npm package manager
npm install useragent
Through git
git clone git://github.com/3rd-Eden/node-useragent.git
I could write a whole story about it, but just fire check out the example node example.js
and navigate to http://127.0.0.1:8000/
In your browser you will see the following ( if you are using Chrome like I did ):
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.559.0 Safari/534.10
userAgent.is
{"version":"534.10","webkit":true,"opera":false,"ie":false,"firefox":true,"safari":true,"mobile_safari":false}
userAgent.parser
{"family":"Chrome","V1":"8","V2":"0","V3":"559","match":"Chrome/8.0.559","os":{"match":"OS X 10_6_4","family":"OS X","V1":"10","V2":"6","V3":"4"}}
userAgent response.pretty
Chrome 8.0.559
userAgent response.prettyOs
OS X 10.6.4
As you can see in the example above, there are different ways of parsing the user-agent string. Usually using .browser() would be enough to do some low level user-agent targeting. It parses it in a way that most client side libraries would parse the user-agent. This is however not that accurate. As you can see in the in the output above the .browser() tell us the version if 533.8, but the real version of the browser is 4.0.4.
The .parser() generates a user_agent object, this contains the:
FAQs
Fastest, most accurate & effecient user agent string parser, uses Browserscope's research for parsing
The npm package useragent receives a total of 556,412 weekly downloads. As such, useragent popularity was classified as popular.
We found that useragent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.