Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
detect-browser-es
Advanced tools
[![bundle size](https://flat.badgen.net/bundlephobia/minzip/detect-browser-es)](https://bundlephobia.com/package/detect-browser-es)
ESM build of detect-browser with server info via std-env.
Install:
# pnpm
pnpm add detect-browser-es
# npm
npm i detect-browser-es
# yarn
yarn add detect-browser-es
Import:
// ESM
import { detect } from 'detect-browser-es'
// CommonJS
const { detect } = require('detect-browser-es')
NodeInfo and getNodeVersion have been deprecated and replaced with ServerInfo and getServerVersion respectively.
Calling detect
function returns ServerInfo
instead NodeInfo
. If you still want to use NodeInfo
, use deprecated getNodeVersion
function.
asyncDetect
function.asyncDetect
function (there is no way to detect Windows 11 using only user-agent
).The new asyncDetect
function should be used when you need to detect Windows 11 or any User-Agent Client Hints, otherwise you can still use the detect
function.
To access the low-entropy User-Agent Client Hints values (mobile
, platform
and brands
), you don't need to use the asyncDetect
function, you can use the navigator.userAgentData
object when available in the browser (check browser compatibility), or using lookupServerUserAgentHints
function for server.
There is no way to detect Windows 11 using only user-agent
, you need to use the asyncDetect
function or the serverResponseHeadersForUserAgentHints
function and will work only on Chromium based and Opera browsers (those supporting the User-Agent Client Hints API).
To detect Windows 11 in the browser, you need to use the asyncDetect
function providing platformVersion
in the options.hints
array.
To detect Windows 11 in the server, you need to send Accept-CH
http response header to the client with the corresponding Sec-CH-UA-*
values. You can use the serverResponseHeadersForUserAgentHints
function providing the required entries for your application, it will return the corresponding Accept-CH
header. The function accepts the hint names you use in the browser, you don't need to worry about http header names.
To run the tests, from root folder run nr dev
or nr test
(with coverage), the script will run:
detect-browser
To run tests using Vitest Browser with WebdriverIO, run one of the following commands:
nr test:chrome
: Chrome must be installednr test:edge
: Edge must be installednr test:firefox
: Firefox must be installednr test:safari
: Safari must be installed and only on macOS machineTo test WebdriverIO detection, run one of the following commands (will not work, there is a bug in @wdio/browser-runner
):
nr wdio:chrome
: Chrome must be installednr wdio:edge
: Edge must be installednr wdio:firefox
: Firefox must be installednr wdio:safari
: Safari must be installed and only on macOS machineFAQs
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![License][license-src]][license-href]
The npm package detect-browser-es receives a total of 33 weekly downloads. As such, detect-browser-es popularity was classified as not popular.
We found that detect-browser-es 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.