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.
cordova-plugin-flashlight2
Advanced tools
This plugin allows you switch the Flashlight / Torch of your device on or off.
This is a fork of EddyVerbruggen/Flashlight-PhoneGap-Plugin
This plugin allows you to switch the flashlight / torch of the device on and off.
$ cordova plugin add cordova-plugin-flashlight2
or
$ cordova plugin add https://github.com/derodero24/Cordova-Plugin-Flashlight2
Flashlight works with PhoneGap build too! Compatible with PhoneGap 3.0.0 and up.
Just add the following xml to your config.xml
to always use the latest version of this plugin:
<gap:plugin name="cordova-plugin-flashlight2" source="npm" />
Since version 3.2.0 of this plugin you can pass in an intensity
property
which needs to be anywhere between 0.0 and 1.0. Only on iOS this will affect the
brightness of the torch.
const flashlightPlugin = window.plugins.flashlight;
flashlightPlugin.available().then(result => {
if (result) {
// If available, switch the light on.
flashlightPlugin
.switchOn({ intensity: 0.3 }) // optional as well
.then(() => {
// If successful, switch off after 3 seconds.
setTimeout(() => {
flashlightPlugin.switchOff();
}, 3000);
})
.catch(() => {
// If it fails, show alert.
alert('Cannot switch the light on.');
});
} else {
alert('Flashlight not available on this device.');
}
});
As an alternative to switchOn
and switchOff
, you can use the toggle
function
window.plugins.flashlight
.toggle(
{ intensity: 0.3 } // optional as well, used on iOS when switching on
)
.then(() => {}) // optional success callback
.catch(() => {}); // optional error callback
To know if the flashlight is on or off you can call isSwitchedOn
window.plugins.flashlight.isSwitchedOn(); // returns true/false
A hint for Android developers
: you'll want to make sure the torch is switched off when the app is exited via the backbutton.
Otherwise, the camera may be locked so it can't be used by other apps:
document.addEventListener(
'backbutton',
// pass exitApp as callbacks to the switchOff method
() => window.plugins.flashlight.switchOff().finally(exitApp),
false
);
function exitApp() {
navigator.app.exitApp();
}
FAQs
This plugin allows you switch the Flashlight / Torch of your device on or off.
The npm package cordova-plugin-flashlight2 receives a total of 0 weekly downloads. As such, cordova-plugin-flashlight2 popularity was classified as not popular.
We found that cordova-plugin-flashlight2 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.
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.