> For the complete documentation index, see [llms.txt](https://docs.talsec.app/freerasp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.talsec.app/freerasp/freerasp/integration/kotlin-multiplatform/api.md).

# API

## Configuration

These classes define the behavior of the freeRASP SDK. You must instantiate `freeraspConfig` to pass it into the `start()` method.

**`class freeraspConfig`**

The root configuration object required to initialize the SDK.

<table><thead><tr><th width="143.671875">Property</th><th width="151.328125">Type</th><th width="97.5078125">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>androidConfig</code></td><td><code>AndroidConfig?</code></td><td><code>null</code></td><td>Configuration specific to the <strong>Android</strong> platform.</td></tr><tr><td><code>iosConfig</code></td><td><code>IOSConfig?</code></td><td><code>null</code></td><td>Configuration specific to the <strong>iOS</strong> platform.</td></tr><tr><td><code>watcherMail</code></td><td><code>String</code></td><td><strong>-</strong></td><td><strong>Required</strong>. The email address where security reports will be sent.</td></tr><tr><td><code>isProd</code></td><td><code>Boolean</code></td><td><code>true</code></td><td>If <code>true</code>, the SDK runs in production mode. If <code>false</code>, strict checks are disabled for development. <a href="/pages/7yacIIMeggggnd8upsxD">See Wiki↗</a></td></tr><tr><td><code>killOnBypass</code></td><td><code>Boolean</code></td><td><code>true</code></td><td>If <code>true</code>, the app will terminate automatically when a critical threat (e.g., Hooking, Debugging) is detected.</td></tr></tbody></table>

**`class AndroidConfig`**

Settings specific to the Android platform.

<table><thead><tr><th width="239.125">Property</th><th width="138.71875">Type</th><th width="102.88671875">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>packageName</code></td><td><code>String</code></td><td><code>-</code></td><td>The expected package name of the app.</td></tr><tr><td><code>certificateHashes</code></td><td><code>List&#x3C;String></code></td><td><code>-</code></td><td>A list of expected signing certificate hashes (Base64 encoded).</td></tr><tr><td><code>supportedAlternativeStores</code></td><td><code>List&#x3C;String></code></td><td><code>[]</code></td><td>A list of allowed alternative app stores .</td></tr><tr><td><code>malwareConfig</code></td><td><code>MalwareConfig?</code></td><td><code>null</code></td><td><strong>Optional</strong> configuration for the Malware Detection module.</td></tr></tbody></table>

**`class IOSConfig`**

Settings specific to the iOS platform.

<table><thead><tr><th width="113.265625">Property</th><th width="138.71875">Type</th><th width="102.88671875">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>bundleIds</code></td><td><code>List&#x3C;String></code></td><td><code>-</code></td><td>A list of expected Bundle IDs for the app.</td></tr><tr><td><code>teamId</code></td><td><code>String</code></td><td><code>-</code></td><td>The Apple Team ID associated with your developer account.</td></tr></tbody></table>

**`class MalwareConfig`**

Advanced configuration for the Malware Detection feature **(Android only)**.

<table><thead><tr><th width="274.67578125">Property</th><th width="138.71875">Type</th><th width="102.88671875">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>blacklistedPackageNames</code></td><td><code>List&#x3C;String></code></td><td><code>[]</code></td><td>A list of package names that should trigger a malware alert.</td></tr><tr><td><code>blacklistedHashes</code></td><td><code>List&#x3C;String></code></td><td><code>[]</code></td><td>A list of certificate hashes for blacklisted apps.</td></tr><tr><td><code>suspiciousPermissions</code></td><td><code>List&#x3C;String></code></td><td><code>[]</code></td><td>A list of suspicious permission combinations.</td></tr><tr><td><code>whitelistedInstallationSources</code></td><td><code>List&#x3C;String></code></td><td><code>[]</code></td><td>A list of trusted installation sources (stores).</td></tr></tbody></table>

## Core Interface

**`object FreeraspKMP`**

The main singleton object used to interact with the library.

<table><thead><tr><th width="135.19921875">Property</th><th width="246.97265625">Type </th><th>Description</th></tr></thead><tbody><tr><td><code>threatEvents</code></td><td><code>SharedFlow&#x3C;FreeRaspEvent></code></td><td><p></p><p>A stream of security events detected by the SDK. Subscribe to this flow to react to threats in real-time.</p></td></tr><tr><td><code>raspExecutionStateEvents</code></td><td><code>SharedFlow&#x3C;RaspExecutionStateEvent></code></td><td>A stream of RASP execution lifecycle events. Subscribe to receive execution state updates such as <code>AllChecksFinished</code>.</td></tr></tbody></table>

#### Methods

`start(config)`

Initializes and starts the freeRASP protection.

```kts
suspend fun start(config: freeraspConfig)
```

`addToWhiteList(packageName)`

Adds a package name to the whitelist. Useful if the malware detector falsely flags a legitimate app.

```kts
suspend fun addToWhiteList(packageName: String)
```

`blockScreenCapture(enable)`

Enables or disables protection against screen recording and screenshots.

```kts
suspend fun blockScreenCapture(enable: Boolean)
```

* **enable**: Set to `true` to block capture, `false` to allow it.

`isScreenCaptureBlocked()`

Checks if screen capture blocking is currently active.

```kts
suspend fun isScreenCaptureBlocked(): Boolean
```

* **Returns**: `true` if blocked, `false` otherwise.

`getAppIcon(packageName)`

Retrieves the icon of an installed application as a Base64 string.

```kts
suspend fun getAppIcon(packageName: String): String
```

* **Returns**: Base64 encoded string of the icon.

`storeExternalId(data)`

Stores an external identifier (e.g., User ID) to correlate reports in the Talsec Dashboard.

```kts
suspend fun storeExternalId(data: String)
```

{% hint style="info" %}
Throws `FreeraspKMPException` if the operation fails.
{% endhint %}

`removeExternalId()`

Removes a previously stored external identifier.

```kts
suspend fun removeExternalId()
```

## Events

All events inherit from `sealed class FreeRaspEvent`. They are emitted via the `threatEvents` flow.

### `FreeRaspEvent`

<table><thead><tr><th width="251.703125">Event</th><th width="106.0546875">Platform</th><th>Description</th></tr></thead><tbody><tr><td><code>PrivilegedAccess</code></td><td>🤖 🍎</td><td>Detects Root (Android) or Jailbreak (iOS) access.</td></tr><tr><td><code>Debug</code></td><td>🤖 🍎</td><td>Detects if a Debugger is attached to the application.</td></tr><tr><td><code>Simulator</code></td><td>🤖 🍎</td><td>Detects if the app is running on an Emulator or Simulator.</td></tr><tr><td><code>AppIntegrity</code></td><td>🤖 🍎</td><td>Detects if the app signature or checksum has been tampered with.</td></tr><tr><td><code>UnofficialStore</code></td><td>🤖 🍎</td><td>Detects if the app was installed from an unrecognized source.</td></tr><tr><td><code>Hooks</code></td><td>🤖 🍎</td><td>Detects hooking frameworks (e.g., Frida, Xposed) injected into the process.</td></tr><tr><td><code>DeviceBinding</code></td><td>🤖 🍎</td><td>Detects if the device identity or cryptographic keys have changed.</td></tr><tr><td><code>Screenshot</code></td><td>🤖 🍎</td><td>Notification that a screenshot was taken.</td></tr><tr><td><code>ScreenRecording</code></td><td>🤖 🍎</td><td>Notification that screen recording is active.</td></tr><tr><td><code>Passcode</code></td><td>🤖 🍎</td><td>Detects if the device is not protected by a lock screen.</td></tr><tr><td><code>SecureHardwareNotAvailable</code></td><td>🤖 🍎</td><td>Detects if the hardware-backed keystore is unavailable.</td></tr><tr><td><code>SystemVPN</code></td><td>🤖 🍎</td><td>Detects if a system-wide VPN is active.</td></tr><tr><td><code>DeviceID</code></td><td>🍎</td><td>Indicates that the unique device identifier has changed or is inconsistent.</td></tr><tr><td><code>ObfuscationIssues</code></td><td>🤖</td><td>Detects if the code is not properly obfuscated (missing ProGuard/R8).</td></tr><tr><td><code>DevMode</code></td><td>🤖</td><td>Detects if Developer Options are enabled in settings.</td></tr><tr><td><code>AdbEnabled</code></td><td>🤖</td><td>Detects if USB Debugging (ADB) is active.</td></tr><tr><td><code>MultiInstance</code></td><td>🤖</td><td>Detects App Cloning (multiple instances running).</td></tr><tr><td><code>UnsecureWifi</code></td><td>🤖</td><td>Detects connection to an unencrypted Wi-Fi network.</td></tr><tr><td><code>TimeSpoofing</code></td><td>🤖🍎</td><td>Detects manual manipulation of system time.</td></tr><tr><td><code>LocationSpoofing</code></td><td>🤖</td><td>Detects attempts to falsify the device’s location to bypass geofences or fake presence.</td></tr><tr><td><code>Automation</code></td><td>🤖</td><td>Detects automation frameworks (e.g. Appium)</td></tr><tr><td><code>Bootloader</code></td><td>🤖</td><td>Detects that the device bootloader is unlocked or otherwise compromised.</td></tr><tr><td><code>Malware</code></td><td>🤖</td><td>Detects suspicious applications. Contains <code>suspiciousAppInfo</code>.</td></tr></tbody></table>

### `RaspExecutionStateEvent`

<table><thead><tr><th width="251.703125">Event</th><th width="106.0546875">Platform</th><th>Description</th></tr></thead><tbody><tr><td>AllChecksFinished</td><td>🤖 🍎</td><td>Confirms that the initialization is complete and all active security checks have been executed.</td></tr></tbody></table>

{% hint style="info" %}
**Platform Availability**

🤖 **Android** - Supported on Android devices.

🍎 **iOS** - Supported on iOS devices.
{% endhint %}

For a detailed description of each event and its security implications, please refer to the [Wiki section ↗](/freerasp/freerasp/wiki/threat-detection.md).

#### Malware Detection Configuration

`class SuspiciousAppDetectionConfig`

Advanced configuration for the Malware Detection feature **(Android only)**.

| Property               | Type                  | Default                                | Description                                                                        |
| ---------------------- | --------------------- | -------------------------------------- | ---------------------------------------------------------------------------------- |
| `packageNames`         | `List<String>?`       | `null`                                 | Package names of known malicious apps.                                             |
| `hashes`               | `List<String>?`       | `null`                                 | Certificate hashes of known malicious apps.                                        |
| `requestedPermissions` | `List<List<String>>?` | `null`                                 | Permission groups an app must **request** to be flagged as suspicious.             |
| `grantedPermissions`   | `List<List<String>>?` | `null`                                 | Permission groups an app must be actively **granted** to be flagged as suspicious. |
| `scanScope`            | `ScanScope`           | `ScanScope(ScopeType.SIDELOADED_ONLY)` | Defines which installed apps are scanned.                                          |
| `reasonMode`           | `ReasonMode`          | `ReasonMode.HIGHEST_CONFIDENCE`        | Controls how detection reasons are reported.                                       |

For full details on `ScanScope`, `ScopeType`, and `ReasonMode` behavior, see the[ Malware Detection Configuration guide](/freerasp/freemalwaredetection/integration-guide/configuration.md).

`data class SuspiciousAppInfo`

Found inside the payload of the `Malware` event.

<table><thead><tr><th width="218.25390625">Property</th><th width="175.4921875">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>packageInfo</code></td><td><code>PackageInfo</code></td><td>Detailed information about the detected application.</td></tr><tr><td><code>reasons</code></td><td><code>Set&#x3C;String></code></td><td>The specific detection rule that triggered the alert (e.g., <code>"Blacklisted Package"</code> or <code>"Suspicious Permissions"</code>).</td></tr><tr><td><code>permissions</code></td><td><code>List&#x3C;String></code></td><td>List of permissions declared by the suspicious app.</td></tr></tbody></table>

`data class PackageInfo`

Contains metadata about an installed application.

<table><thead><tr><th width="218.25390625">Property</th><th width="175.4921875">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>packageName</code></td><td><code>String</code></td><td>The unique package name (Application ID).</td></tr><tr><td><code>appName</code></td><td><code>String?</code></td><td>The name of the app.</td></tr><tr><td><code>version</code></td><td><code>String?</code></td><td>The version of the app. </td></tr><tr><td><code>appIcon</code></td><td><code>String?</code></td><td>The app icon as a Base64 encoded string.</td></tr><tr><td><code>installerStore</code></td><td><code>String?</code></td><td>The store from which the app was installed.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.talsec.app/freerasp/freerasp/integration/kotlin-multiplatform/api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
