All methods are exposed on the cordova.drs object, which becomes available once the deviceready event has fired.
▸ initializeSDK(): Promise<void>
Initializes the plugin using platform-specific configuration files (TransmitSecurity.plist on iOS, strings.xml values on Android). This is the recommended initialization approach.
Promise<void>
Resolves when initialization succeeds and rejects on failure (missing configuration or SDK error).
document.addEventListener('deviceready', function () {
cordova.drs.initializeSDK()
.then(function () {
console.log('Fraud Prevention SDK initialized');
})
.catch(function (err) {
console.error(err.code, err.message);
});
});▸ initialize(clientId, baseUrl, options?, userId?): Promise<void>
Initializes the plugin with explicit parameters. Use this when you need to provide credentials programmatically instead of relying on platform configuration files.
| Name | Type | Description |
|---|---|---|
clientId | string | Your client identifier |
baseUrl | string | API base URL for your environment |
options? | TSInitSDKConfiguration | Optional configuration for location tracking |
userId? | string | Optional user ID to set during initialization |
Promise<void>
Resolves when initialization succeeds and rejects on failure.
cordova.drs.initialize(
'[CLIENT_ID]',
'https://api.transmitsecurity.io/risk-collect/',
{ enableLocationEvents: true },
null // optional userId
);▸ triggerAction(action, options?, locationConfig?, customAttributes?): Promise<TSSetActionResponse>
Reports a user action event and returns an action token. The action token should be passed to your backend to fetch risk recommendations via the Recommendation API. This method does not throw on SDK rejection—check result.success and use result.actionToken when successful.
| Name | Type | Description |
|---|---|---|
action | string | The type of user action to report (see TSAction values) |
options? | TSActionEventOptions | Additional context for the action event |
locationConfig? | TSLocationConfig | Controls location data collection for this action (see Track geolocation) |
customAttributes? | Object | Additional contextual data for the action; must match the schema defined in the Portal (see Custom attributes) |
Promise<TSSetActionResponse>
cordova.drs.triggerAction(
'login',
{
correlationId: 'CORRELATION_ID',
claimedUserId: '91e25bea0c...', // hashed email
claimedUserIdType: 'email'
},
{ mode: 'default' },
{ userLevel: 'premium' }
).then(function (result) {
if (result.success) {
console.log('Action Token:', result.actionToken);
}
});▸ setAuthenticatedUser(userId, options?): Promise<boolean>
Sets the user context for all subsequent events in the session (or until the user is explicitly cleared). It should be called only after you've fully authenticated the user (including, for example, any 2FA that was required). On Android, call this after the WebView activity is visible.
| Name | Type | Description |
|---|---|---|
userId | string | Opaque identifier of the user in your system |
options? | Object | Optional user attributes |
Promise<boolean>
Indicates if the call succeeded.
await cordova.drs.setAuthenticatedUser('user-123', {
loginMethod: 'password',
email: 'user@example.com'
});▸ clearUser(): Promise<boolean>
Clears the user context for all subsequent events in the mobile session. The user is automatically cleared once the session expires or in case of a new login action.
Promise<boolean>
Indicates if the call succeeded.
await cordova.drs.clearUser();▸ getSessionToken(): Promise<string>
Returns a device session token that can be used to trigger action events via the Backend API. The session token binds user interactions to their device and is required for backend integrations. Call this after plugin initialization and before triggering events.
Promise<string>
The session token.
const sessionToken = await cordova.drs.getSessionToken();▸ logPageLoad(pageName): Promise<void>
Reports a page-load event for behavioral data collection. The plugin tracks WebView navigation automatically, so use this method only when your app uses a custom SPA router and you want to report explicit page names.
| Name | Type | Description |
|---|---|---|
pageName | string | The name of the screen or page the user navigated to |
Promise<void>
await cordova.drs.logPageLoad('Dashboard');▸ setLogLevel(isLogEnabled): Promise<void>
Enables or disables verbose plugin logging for debugging purposes.
| Name | Type | Description |
|---|---|---|
isLogEnabled | boolean | Set to true to enable debug logging |
Promise<void>
await cordova.drs.setLogLevel(true);