> For the complete documentation index, see [llms.txt](https://sentinel.rexiox.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sentinel.rexiox.co/getting-started/quick-start.md).

# Quick Start

Sentinel is a lightweight, modular security toolkit designed specifically for Kotlin Multiplatform (KMP). It empowers mobile developers to analyze runtime environments and detect potential security threats in real-time across both Android and iOS applications from a single codebase.

### Dependency

```kotlin
implementation("co.rexiox:sentinel:{version}")
```

### Configuration

You can use the following method to print the appId and appIntegrity values required for your security or configuration processes and assign them to the relevant fields within the config as a ByteList:

* `appId`: Package name for Android, Bundle Identifier for iOS
* `appIntegrity`: Package signature for Android, unique digital fingerprint of the Provisioning Profile file for iOS

```kotlin
SentinelLogger.print(tag = "APP_ID", msg = Sentinel.Identity.appId.toByteList())
SentinelLogger.print(tag = "APP_INTEGRITY", msg = Sentinel.Identity.appIntegrity.toByteList())
```

#### Android Setup

```kotlin
val sentinel = Sentinel.configure(context = context) {
    config {
        appId = listOf<Byte>()
        appIntegrity = listOf<Byte>()
        threshold = 90
        isLoggingEnabled = true
    }

    all()
    // root()
    // tamper()
    // hook()
    // emulator()
    // debug()
    // location()
}
```

#### iOS Setup

```kotlin
val sentinel = Sentinel.configure {
    config {
        appId = listOf<Byte>()
        appIntegrity = listOf<Byte>()
        threshold = 90
        isLoggingEnabled = true
    }

    all()
    // jailbreak()
    // tamper()
    // hook()
    // simulator()
    // debug()
}
```

Instead of basic checks, Sentinel performs a thorough inspection of the environment and provides a detailed report based on threat severity.

> `inspect()` is a suspend function and must be executed within a coroutine scope.

```kt
val report = sentinel.inspect()
```

### Report

After the inspection completes, Sentinel returns a `SecurityReport`. This report aggregates all detected threats and provides a unified severity score and risk level for the current runtime environment.

```kotlin
println("Risk Level: ${report.riskLevel}")
println("Total Risk Score: ${report.severity} / ${report.threshold}")
println("Threat Count: ${report.threats.size}")
println("Timestamp: ${report.timestamp}")

if (report.isCompromised) println("Device integrity failed (Root/Jailbreak detected).")
if (report.isRooted) println("Root detected")
if (report.isJailbroken) println("Jailbreak detected")
if (report.isTampered) println("App tampering detected")
if (report.isHooked) println("Hooking detected")
if (report.isEmulator) println("Emulator detected")
if (report.isSimulator) println("Simulator detected")
if (report.isDebugged) println("Debugger detected")
if (report.isMockLocation) println("Mock location detected")

if (report.isSafe()) {
    println("Device is secure")
} else {
    println("Security risks detected!")
}

if (report.isCritical()) {
    println("Block app usage.")
}
```
