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.
detect-touch-events
Advanced tools
Detect if the browser supports the Touch Events API.
Exports a reference to a singleton object (a micro state machine with an update function) with its state set to if the device supports the Touch Events API, as well as an update()
function which re-runs the tests and updates the object's state.
Note that detect-touch-events
is one of the micro state machines used by detect-it
to determine if a device is mouseOnly
, touchOnly
, or hybrid
.
For more information on the touch events api, please see MDN's Touch Events, or the W3C Touch Events specification.
detectTouchEvents
micro state machineconst detectTouchEvents = {
hasSupport: true / false,
browserSupportsApi: true / false,
// re-run all the detection tests and update state
update() {...},
}
detect-touch-events
$ npm install --save detect-touch-events
detect-touch-events
import detectTouchEvents from 'detect-touch-events';
// touch events api is present on a device with a touch screen - *most useful*
detectTouchEvents.hasSupport === true;
// browser supports the touch events api, but the device may or may not have a touch screen
detectTouchEvents.browserSupportsApi === true;
// updating the state - most apps won't need to use this at all
detectTouchEvents.update();
/*
* note that in the case of a browser that doesn't support touch events,
* including when using a legacy computer and browser, the default state will be:
*/
const detectTouchEvents = {
hasSupport: false,
browserSupportsApi: false,
}
Note that hasSupport
is still just an api presence test and some browsers (notably Firefox) may give a false positive (saying it has support on a device without a touch screen), so it is recommended to use detect-it
which factors in other tests as well to determine device capabilities.
Note that the update()
function is run once at the time of import to set the object's initial state, and generally doesn't need to be run again. If it doesn't have access to the window
, then the state will be undefined
(detect-touch-events
will not throw an error), and you will need to call the update()
function manually at a later time to update its state.
detect-it
familydetect-it
detect-hover
detect-pointer
detect-touch-events
detect-passive-events
FAQs
Detect if the browser supports the touch events api
The npm package detect-touch-events receives a total of 42,342 weekly downloads. As such, detect-touch-events popularity was classified as popular.
We found that detect-touch-events 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.