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.
- 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
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 androidOn 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.
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.
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:
| Environment | Base URL |
|---|---|
| US | https://api.transmitsecurity.io/risk-collect/ |
| EU | https://api.eu.transmitsecurity.io/risk-collect/ |
| Canada | https://api.ca.transmitsecurity.io/risk-collect/ |
| Australia | https://api.au.transmitsecurity.io/risk-collect/ |
| Custom domain | https://<your_custom_domain>/risk-collect/ |
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
);| Parameter | Type | Required | Description |
|---|---|---|---|
clientId | string | Yes | Your client ID from the Admin Portal |
baseUrl | string | Yes | The base URL for your environment (see table above) |
options | object | No | Optional configuration object (see below) |
userId | string | No | Set the user ID during initialization if already known |
Options object:
| Property | Type | Default | Description |
|---|---|---|---|
enableLocationEvents | boolean | false | Enables 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). |
For a complete end-to-end integration walkthrough, see the Cordova plugin quick start.