Skip to content

The cordova_ts_account_protection_plugin is a Cordova plugin for Mosaic Fraud Prevention on Android and iOS.

When initialized, the plugin automatically starts collecting and submitting telemetry data to Mosaic—including information about the user journey, device data, and user interactions. Once specific user actions are performed on the client side (such as login), Fraud Prevention should be called to track those action events and obtain action tokens. The data collected can then be queried for recommendations using the Recommendations backend API.

Requirements

  • Cordova CLI 12.0 or higher (tested with cordova-ios 8.x and cordova-android 14.x)
  • iOS 13.0 or higher, Xcode 16 or higher
  • Android API level 24 (Android 7.0) or higher
  • Node.js LTS

Installation

Add the plugin to your project from the published plugin repository:

cordova plugin add https://github.com/TransmitSecurity/cordova_ts_account_protection_plugin.git#v0.1.0
cordova platform add ios android
cordova prepare ios android

On iOS, the plugin resolves the native Fraud Prevention SDK through Swift Package Manager. On Android, it pulls the SDK from the Transmit Security Maven repository.

Platform configuration

The plugin adds the INTERNET, ACCESS_NETWORK_STATE, and ACCESS_FINE_LOCATION permissions to the manifest and resolves the Fraud Prevention SDK from the Transmit Security Maven repository.

strings.xml

Add your credentials to res/values/strings.xml:

<resources>
    <string name="transmit_security_client_id">[YOUR_CLIENT_ID]</string>
    <string name="transmit_security_base_url">https://api.transmitsecurity.io/risk-collect/</string>
</resources>

Use the appropriate base URL for your environment:

EnvironmentBase URL
UShttps://api.transmitsecurity.io/risk-collect/
EUhttps://api.eu.transmitsecurity.io/risk-collect/
Canadahttps://api.ca.transmitsecurity.io/risk-collect/
Australiahttps://api.au.transmitsecurity.io/risk-collect/
Custom domainhttps://<your_custom_domain>/risk-collect/

Initialization

The plugin exposes the cordova.drs object once the deviceready event has fired.

Simple initialization (using platform configuration files):

document.addEventListener('deviceready', function () {
  cordova.drs.initializeSDK();
});

With explicit parameters:

cordova.drs.initialize(
  '[CLIENT_ID]',
  'https://api.transmitsecurity.io/risk-collect/',
  { enableLocationEvents: true },
  null // optional userId
);

initialize parameters

ParameterTypeRequiredDescription
clientIdstringYesYour client ID from the Admin Portal
baseUrlstringYesThe base URL for your environment (see table above)
optionsobjectNoOptional configuration object (see below)
userIdstringNoSet the user ID during initialization if already known

Options object:

PropertyTypeDefaultDescription
enableLocationEventsbooleanfalseEnables reporting device location during plugin initialization and when the app moves to the foreground. The user must consent to sharing location in advance (see Track geolocation).

Next steps

For a complete end-to-end integration walkthrough, see the Cordova plugin quick start.