Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
browser-detect
Advanced tools
$ npm install browser-detect
$ yarn add browser-detect
<script src="node_modules/browser-detect/dist/browser-detect.umd.js"></script>
const result = browserDetect();
console.log(result);
output
{
name: 'chrome',
version: '58.0.3029',
versionNumber: 58.03029,
mobile: false,
os: 'Windows NT 10.0'
}
import browser from 'browser-detect';
const result = browser();
console.log(result);
output
{
name: 'chrome',
version: '58.0.3029',
versionNumber: 58.03029,
mobile: false,
os: 'Windows NT 10.0'
}
Just simple :trollface:
const browser = require('browser-detect');
const result = browser();
console.log(result);
output
{
name: 'node',
version: '9.9.0',
versionNumber: 9.9,
mobile: false,
os: 'win32'
}
const router = express.Router();
const browser = require('browser-detect');
router.get('/', req => {
const result = browser(req.headers['user-agent']);
console.log(result);
});
return router;
output
{
name: 'ie',
version: '9.0',
versionNumber: 9,
mobile: false,
os: 'Windows NT 10.0'
}
Or set a middleware and send to res.locals
.
// browserDetectMiddleware.js
const browser = require('browser-detect');
const MiddleWare = () => req => {
res.locals.browser = browser(req.headers['user-agent']);
next();
};
module.exports = MiddleWare;
// app.js
const express = require('express');
const browserDetectMiddleware = require('./browserDetectMiddleware');
const app = express();
app.use(browserDetectMiddleware())
View will can access browser
variable.
<!-- view.ejs -->
<%=JSON.stringify(browser)%>
output
"{ name: 'firefox', version: '53.0.0', versionNumber: 53, mobile: false, os: 'Windows NT 10.0' }"
examples/client.html
by your browser.browser-detect
path that you download$ node ./examples/server.js
name | type | description | example |
---|---|---|---|
name | string | a browser name | ie, chrome, firefox |
version | string | browser or node version | 59.2.22 |
versionNumber | number | browser or node number casted to number | 59.222 |
mobile | boolean | if browser is in mobile environment, it will be true | ture |
os | string | os type name | Windows NT 10.0 |
$ git clone git@github.com:KennethanCeyer/browser-detect.git
$ cd browser-detect
$ npm install
$ npm run build
$ npm run test
FAQs
Simplify detecting your browser
The npm package browser-detect receives a total of 26,259 weekly downloads. As such, browser-detect popularity was classified as popular.
We found that browser-detect 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.