Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cordova-plugin-safeguard

webileapps12MIT0.1.10

Cordova plugin for security checks and device integrity verification

ecosystem:cordova, cordova-android, cordova-ios, security, root-detection, malware-detection, tampering-detection

readme

Cordova Plugin Safeguard

A Cordova plugin for comprehensive security checks and device integrity verification on Android devices.

Features

  • Root Detection
  • Developer Options Detection
  • Malware and Tampering Detection
  • Network Security Checks
  • Screen Mirroring Detection
  • Application Spoofing Detection
  • Keylogger Detection

Installation

cordova plugin add cordova-plugin-safeguard

Or install directly from GitHub:

cordova plugin add https://github.com/webileapps/cordova-plugin-safeguard.git

Configuration

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

Usage

JavaScript API

// 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);

Automatic Checks

The plugin automatically performs security checks at these times:

  1. When the app starts
  2. When the activity starts
  3. When the app resumes from background

Error Handling

The error callback receives a JSON object with:

{
    "title": "Security Check Name",
    "message": "Detailed message about the security issue",
    "type": "error" // or "warning"
}

Sample App

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

Requirements

  • Cordova >= 9.0.0
  • Android >= 9.0.0 (API Level 28)
  • Gradle >= 7.0.0

License

MIT License - see LICENSE file for details

Support

For bugs, questions, and discussions please use the GitHub Issues.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Development

To set up the development environment:

  1. Clone the repository

    git clone https://github.com/webileapps/cordova-plugin-safeguard.git
    cd cordova-plugin-safeguard
  2. Install dependencies

    cd plugin
    npm install
  3. Make your changes and test using the sample app

    cd ../sample
    npm install
    cordova platform add android
    cordova run android

Publishing

To publish a new version:

  1. Update version

    cd plugin
    npm version patch  # or minor/major
  2. Publish to npm

    npm publish

This will automatically:

  • Update versions in package.json and plugin.xml
  • Create git tags
  • Publish to npm registry