A Cordova plugin for comprehensive security checks and device integrity verification on Android devices.
- Root Detection
- Developer Options Detection
- Malware and Tampering Detection
- Network Security Checks
- Screen Mirroring Detection
- Application Spoofing Detection
- Keylogger Detection
cordova plugin add cordova-plugin-safeguard
Or install directly from GitHub:
cordova plugin add https://github.com/webileapps/cordova-plugin-safeguard.git
Add preferences to your config.xml
to customize security check behaviors:
<preference name="ROOT_CHECK_STATE" value="ERROR" />
<preference name="DEVELOPER_OPTIONS_CHECK_STATE" value="WARNING" />
<preference name="MALWARE_CHECK_STATE" value="WARNING" />
<preference name="TAMPERING_CHECK_STATE" value="WARNING" />
<preference name="NETWORK_SECURITY_CHECK_STATE" value="WARNING" />
<preference name="SCREEN_SHARING_CHECK_STATE" value="WARNING" />
<preference name="APP_SPOOFING_CHECK_STATE" value="WARNING" />
<preference name="KEYLOGGER_CHECK_STATE" value="WARNING" />
<preference name="EXPECTED_PACKAGE_NAME" value="com.your.package.name" />
Each security check can be configured with one of these states:
-
ERROR
: Blocks app usage when the check fails -
WARNING
: Shows a warning but allows continuing -
DISABLED
: Skip the check entirely
// Run all security checks
Safeguard.checkAll(
function(success) {
console.log('All security checks passed');
},
function(error) {
console.error('Security check failed:', error);
}
);
// Individual checks
Safeguard.checkRoot(successCallback, errorCallback);
Safeguard.checkDeveloperOptions(successCallback, errorCallback);
Safeguard.checkMalware(successCallback, errorCallback);
Safeguard.checkNetwork(successCallback, errorCallback);
Safeguard.checkScreenMirroring(successCallback, errorCallback);
Safeguard.checkApplicationSpoofing(successCallback, errorCallback);
Safeguard.checkKeyLogger(successCallback, errorCallback);
The plugin automatically performs security checks at these times:
- When the app starts
- When the activity starts
- When the app resumes from background
The error callback receives a JSON object with:
{
"title": "Security Check Name",
"message": "Detailed message about the security issue",
"type": "error" // or "warning"
}
A sample application demonstrating all features is available in the sample
directory. To run it:
cd sample
npm install
cordova platform add android
cordova run android
- Cordova >= 9.0.0
- Android >= 9.0.0 (API Level 28)
- Gradle >= 7.0.0
MIT License - see LICENSE file for details
For bugs, questions, and discussions please use the GitHub Issues.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
To set up the development environment:
- Clone the repository
git clone https://github.com/webileapps/cordova-plugin-safeguard.git
cd cordova-plugin-safeguard
- Install dependencies
cd plugin
npm install
- Make your changes and test using the sample app
cd ../sample
npm install
cordova platform add android
cordova run android
To publish a new version:
- Update version
cd plugin
npm version patch # or minor/major
- Publish to npm
npm publish
This will automatically:
- Update versions in package.json and plugin.xml
- Create git tags
- Publish to npm registry