Skip to content

All methods are exposed on the cordova.drs object, which becomes available once the deviceready event has fired.

initializeSDK

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.

Returns

Promise<void>

Resolves when initialization succeeds and rejects on failure (missing configuration or SDK error).

Example

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

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.

Parameters

NameTypeDescription
clientIdstringYour client identifier
baseUrlstringAPI base URL for your environment
options?TSInitSDKConfigurationOptional configuration for location tracking
userId?stringOptional user ID to set during initialization

Returns

Promise<void>

Resolves when initialization succeeds and rejects on failure.

Example

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

triggerAction

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.

Parameters

NameTypeDescription
actionstringThe type of user action to report (see TSAction values)
options?TSActionEventOptionsAdditional context for the action event
locationConfig?TSLocationConfigControls location data collection for this action (see Track geolocation)
customAttributes?ObjectAdditional contextual data for the action; must match the schema defined in the Portal (see Custom attributes)

Returns

Promise<TSSetActionResponse>

Example

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

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.

Parameters

NameTypeDescription
userIdstringOpaque identifier of the user in your system
options?ObjectOptional user attributes

Returns

Promise<boolean>

Indicates if the call succeeded.

Example

await cordova.drs.setAuthenticatedUser('user-123', {
  loginMethod: 'password',
  email: 'user@example.com'
});

clearUser

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.

Returns

Promise<boolean>

Indicates if the call succeeded.

Example

await cordova.drs.clearUser();

getSessionToken

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.

Returns

Promise<string>

The session token.

Example

const sessionToken = await cordova.drs.getSessionToken();

logPageLoad

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.

Parameters

NameTypeDescription
pageNamestringThe name of the screen or page the user navigated to

Returns

Promise<void>

Example

await cordova.drs.logPageLoad('Dashboard');

setLogLevel

setLogLevel(isLogEnabled): Promise<void>

Enables or disables verbose plugin logging for debugging purposes.

Parameters

NameTypeDescription
isLogEnabledbooleanSet to true to enable debug logging

Returns

Promise<void>

Example

await cordova.drs.setLogLevel(true);