Installation

Distribution

Malwarelytics Cordova Plugin is distributed as an NPM package. The private Maven repository for the Android native library and the private CocoaPods repository for the iOS native library is used under the hood.

Platform Support

Malwarelytics Cordova Plugin supports iOS 10 and Android 4.4 (SDK version 19) and above.

Prerequisities

Personalized Configuration Required.
In order to use the Malwarelytics Cordova Plugin, you need a custom configuration and access credentials for both the service and artifact repositories. Contact your sales representative or technical consultant in order to obtain the required prerequisites.

1. Create the malwarelytics.xml file

Create the malwarelytics.xml file inside your app root folder with your Malwarelytics service credentials and credentials for the repository of the Android/iOS native library.

You can visit malwarelytics.xml inside the demo app..

<?xml version='1.0' encoding='utf-8'?>
<malwarelytics>

    <!-- Configuration for the integration in the Android platform. -->
    <android>
        <!-- 
            Service configuration (different than the Apple service settings).

            username : Username for the Malwarelytics service
            password : Password for the Malwarelytics service
            publicKey : [OPTIONAL] Public key of the service
            environment: Either 'PRODUCTION' or 'TEST' 
        -->
        <service 
            username="SERVICE_USERNAME"
            password="SERVICE_PASSWORD"
            publicKey="SERVICE_PUB_KEY"
            environment="PRODUCTION"
        />

        <!-- 
            Maven repository configuration 

            username : Username for the m2 repo
            password : Password for the m2 repo
            url : [OPTIONAL] Custom URL to the m2 repo
        -->
        <maven 
            username="M2_USERNAME" 
            password="M2_PASSWORD" 
            url="M2_URL" 
        /> 

        <!-- 
            UI configuration [OPTIONAL] 

             resourcesFolder : Folder that will be copied (merged) into the android app resources folder
                       theme : Theme resource path that will be applied to the threat screen
            notificationIcon : Resource icon used in threat notifications
                settingsIcon : Resource icon used in threat screen for settings
                  deleteIcon : Resource icon used in threat screen for deleting malware
        -->
        <ui
            resourcesFolder="./malwarelytics_resources"
            theme="R.style.CustomAppTheme"
            notificationIcon="R.mipmap.ic_launcher"
            settingsIcon="R.drawable.custom_av_settings_outline"
            deleteIcon="R.drawable.custom_av_delete_outline"
        />
    </android>

    <!-- Configuration for the integration in Apple platforms (iOS/iPadOS). -->
    <apple>

        <!-- 
            Service configuration (different than the Android service settings).

            username  : Username for the Malwarelytics service
            password  : Password for the Malwarelytics service
            publicKey : [OPTIONAL] Public key of the service
        -->
        <service 
            username="SERVICE_USERNAME_APPLE"
            password="SERVICE_PASSWORD_APPLE"
            publicKey="SERVICE_PUB_KEY_APPLE"
        />

         <!-- 
            netrc file configuration (for private CocoaPods access)
            
            Note that artifactory credentials will be added (if not present) to the
            .netrc/_netrc file in your home folder.

               login : Login for the repo
            password : Password for the repo
             machine : [OPTIONAL] Custom URL to the repo
        -->
        <artifactory
            username="ARTIFACTORY_USERNAME"
            password="ARTIFACTORY_PASSWORD"
            url="ARTIFACTORY_URL"
        />
    </apple>

</malwarelytics>


Mode detailed explanation of the <ui> tag inside the <android> configuration can be found here.

2. Install the plugin into your app

For “vanilla” Cordova app

cordova plugin add cordova-plugin-malwarelytics

For the Ionic Cordova app

ionic cordova plugin add cordova-plugin-malwarelytics

3. Initialize and use the plugin

In your app js or ts file, you can now access window.plugins.malwarelytics property.

Initialize the plugin:

async initializeMalwarelytics() {
    try {
        // example configuration
        await window.plugins.malwarelytics.initialize({
            androidConfig: {
                languageCode: "en",
                antivirus: {
                    enableSilentMode: false
                },
                rasp: {
                    exitOnRoot: true
                }
            },
            appleConfig: {
                rasp: {
                    debugger: {
                        action: "EXIT",
                        exitUrl: "https://wultra.com"
                    }
                }
            }
        });
        console.log("initialized");
    } catch (error) {
        console.log(error);        
    }
}

Typescript support

In case you’re using TypeScript to build the app, there is a Malwarelytics.d.ts definition file in the package. You can reference it in your file and use it as follow:

/// <reference path="../../plugins/cordova-plugin-malwarelytics/www/MalwarelyticsPlugin.d.ts"/>

declare interface Window {
    plugins: {
        malwarelytics: MalwarelyticsPlugin;
    }
}

// now you can use window.plugins.malwarelytics with autocompletion

Last updated on Aug 15, 2022 (16:31) Edit on Github Send Feedback
Search

4.1.x

Malwarelytics for Cordova