capacitor-freerasp 2.5.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/aheaditec/freerasp/FreeraspPlugin.kt +21 -21
  4. package/android/src/main/java/com/aheaditec/freerasp/PluginThreatHandler.kt +23 -30
  5. package/android/src/main/java/com/aheaditec/freerasp/dispatchers/ExecutionStateDispatcher.kt +4 -2
  6. package/android/src/main/java/com/aheaditec/freerasp/dispatchers/ThreatDispatcher.kt +4 -2
  7. package/android/src/main/java/com/aheaditec/freerasp/models/CapSuspiciousAppInfo.kt +1 -1
  8. package/android/src/main/java/com/aheaditec/freerasp/utils/Extensions.kt +25 -1
  9. package/android/src/main/java/com/aheaditec/freerasp/utils/RandomGenerator.kt +1 -2
  10. package/dist/esm/api/methods/capacitor.d.ts +1 -1
  11. package/dist/esm/api/methods/capacitor.js +2 -1
  12. package/dist/esm/api/methods/capacitor.js.map +1 -1
  13. package/dist/esm/types/types.d.ts +15 -7
  14. package/dist/esm/types/types.js.map +1 -1
  15. package/dist/esm/utils/config.d.ts +6 -0
  16. package/dist/esm/utils/config.js +21 -0
  17. package/dist/esm/utils/config.js.map +1 -0
  18. package/dist/esm/utils/malware.js +1 -1
  19. package/dist/esm/utils/malware.js.map +1 -1
  20. package/dist/plugin.cjs.js +23 -2
  21. package/dist/plugin.cjs.js.map +1 -1
  22. package/dist/plugin.js +23 -2
  23. package/dist/plugin.js.map +1 -1
  24. package/ios/Plugin/TalsecRuntime.xcframework/Info.plist +5 -5
  25. package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeDirectory +0 -0
  26. package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeResources +51 -40
  27. package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeSignature +0 -0
  28. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  29. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +1 -1
  30. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +7 -7
  31. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +4 -4
  32. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +1 -1
  33. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +1 -1
  34. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
  35. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +185 -185
  36. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
  37. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/_CodeSignature/CodeResources +377 -0
  38. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  39. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +2 -2
  40. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +7 -7
  41. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +4 -4
  42. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +1 -1
  43. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +1 -1
  44. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
  45. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +104 -104
  46. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +104 -104
  47. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
  48. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +17 -39
  49. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,67 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.0.0] - 2026-05-15
9
+
10
+ - Android SDK version: 18.3.0
11
+ - iOS SDK version: 6.14.4
12
+
13
+ ### Breaking
14
+
15
+ - `SuspiciousAppInfo.reason` (String) renamed to `reasons` (string[])
16
+ - Value `"blacklist"` in `reasons` renamed to `"blocklist"`
17
+ - Removed `TalsecMalwareConfig` and `TalsecAndroidConfig.malwareConfig`
18
+ - `SuspiciousAppDetectionConfig.malwareScanScope` and `reasonMode` are now required
19
+
20
+ ### Capacitor
21
+
22
+ #### Added
23
+
24
+ - `SuspiciousAppDetectionConfig` for malware detection configuration
25
+
26
+ #### Removed
27
+
28
+ - `TalsecMalwareConfig` type and `TalsecAndroidConfig.malwareConfig` field
29
+
30
+ ### Android
31
+
32
+ #### Added
33
+
34
+ - New API class `SuspiciousAppDetectionConfig` that can be used to configure malware detection
35
+ - New API for malware detection configuration in `TalsecConfig`, see `TalsecConfig.Builder#suspiciousAppDetection`
36
+
37
+ #### Fixed
38
+
39
+ - Fixed `VerifyError` caused by JaCoCo bytecode instrumentation
40
+ - Fixed a potential cause of crash in the multi-instance detector
41
+ - Fixed Java interoperability of `ScreenProtector` methods
42
+ - Fixed Kotlin classpath conflicts in SDK dependency resolution (Kotlin 2.0.0)
43
+
44
+ #### Changed
45
+
46
+ - Fine-tuned location spoofing detection
47
+ - Modified malware incident log structure for better aggregation
48
+
49
+ ## [2.5.1] - 2026-03-24
50
+
51
+ - Android SDK version: 18.0.4
52
+ - iOS SDK version: 6.14.4
53
+
54
+ ### Capacitor
55
+
56
+ #### Fixed
57
+
58
+ - Fixed case where event dispatchers on Android were not initialized before calling onResume at the app launch
59
+
60
+ ### iOS
61
+
62
+ #### Fixed
63
+
64
+ - Fixed new jailbreak checks false positives on iOS 14 and 13.
65
+ - Fixed false positives with jailbreak on iOS 15 and 16.
66
+ - Fixed issue with app crashing on screenshot/screen recording.
67
+ - Fixed retrigger jailbreak issue on iOS 15 and 16.
68
+
8
69
  ## [2.5.0] - 2026-03-03
9
70
 
10
71
  - Android SDK version: 18.0.4
@@ -76,5 +76,5 @@ dependencies {
76
76
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
77
77
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
78
78
 
79
- implementation 'com.aheaditec.talsec.security:TalsecSecurity-Community-Capacitor:18.0.4'
79
+ implementation 'com.aheaditec.talsec.security:TalsecSecurity-Community-Capacitor:18.3.0'
80
80
  }
@@ -5,10 +5,12 @@ import android.os.Build
5
5
  import android.os.Handler
6
6
  import android.os.HandlerThread
7
7
  import android.os.Looper
8
+ import com.aheaditec.freerasp.dispatchers.ExecutionStateDispatcher
9
+ import com.aheaditec.freerasp.dispatchers.ThreatDispatcher
8
10
  import com.aheaditec.freerasp.utils.Utils
9
11
  import com.aheaditec.freerasp.utils.getArraySafe
10
- import com.aheaditec.freerasp.utils.getNestedArraySafe
11
12
  import com.aheaditec.freerasp.utils.toEncodedJSArray
13
+ import com.aheaditec.freerasp.utils.toSuspiciousAppDetectionConfig
12
14
  import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
13
15
  import com.aheaditec.talsec_security.security.api.Talsec
14
16
  import com.aheaditec.talsec_security.security.api.TalsecConfig
@@ -31,10 +33,6 @@ class FreeraspPlugin : Plugin() {
31
33
 
32
34
  override fun load() {
33
35
  initializeEventKeys()
34
- val pluginCallback: CapacitorCallback = { eventName, data ->
35
- notifyListeners(eventName, data, true)
36
- }
37
- PluginThreatHandler.initializeDispatchers(PluginListener(context, pluginCallback))
38
36
  super.load()
39
37
  }
40
38
 
@@ -78,11 +76,14 @@ class FreeraspPlugin : Plugin() {
78
76
  @PluginMethod(returnType = PluginMethod.RETURN_NONE)
79
77
  override fun addListener(call: PluginCall) {
80
78
  val eventName = call.getString("eventName")
79
+ val pluginCallback: CapacitorCallback = { eventName, data ->
80
+ notifyListeners(eventName, data, true)
81
+ }
81
82
  if (eventName == ThreatEvent.CHANNEL_NAME) {
82
- PluginThreatHandler.threatDispatcher.registerListener()
83
+ ThreatDispatcher.registerListener(PluginListener(context, pluginCallback))
83
84
  }
84
85
  if (eventName == RaspExecutionStateEvent.CHANNEL_NAME) {
85
- PluginThreatHandler.executionStateDispatcher.registerListener()
86
+ ExecutionStateDispatcher.registerListener(PluginListener(context, pluginCallback))
86
87
  }
87
88
  super.addListener(call)
88
89
  }
@@ -91,31 +92,31 @@ class FreeraspPlugin : Plugin() {
91
92
  fun removeListenerForEvent(call: PluginCall) {
92
93
  val eventName = call.getString("eventName")
93
94
  if (eventName == ThreatEvent.CHANNEL_NAME) {
94
- PluginThreatHandler.threatDispatcher.unregisterListener()
95
+ ThreatDispatcher.unregisterListener()
95
96
  }
96
97
  if (eventName == RaspExecutionStateEvent.CHANNEL_NAME) {
97
- PluginThreatHandler.executionStateDispatcher.unregisterListener()
98
+ ExecutionStateDispatcher.unregisterListener()
98
99
  }
99
100
  }
100
101
 
101
102
  override fun handleOnPause() {
102
103
  super.handleOnPause()
103
- PluginThreatHandler.threatDispatcher.onPause()
104
- PluginThreatHandler.executionStateDispatcher.onPause()
104
+ ThreatDispatcher.onPause()
105
+ ExecutionStateDispatcher.onPause()
105
106
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
106
107
  ScreenProtector.unregister(activity)
107
108
  }
108
109
  if (activity.isFinishing) {
109
- PluginThreatHandler.threatDispatcher.unregisterListener()
110
- PluginThreatHandler.executionStateDispatcher.unregisterListener()
110
+ ThreatDispatcher.unregisterListener()
111
+ ExecutionStateDispatcher.unregisterListener()
111
112
  PluginThreatHandler.unregisterSDKListener(context)
112
113
  }
113
114
  }
114
115
 
115
116
  override fun handleOnResume() {
116
117
  super.handleOnResume()
117
- PluginThreatHandler.threatDispatcher.onResume()
118
- PluginThreatHandler.executionStateDispatcher.onResume()
118
+ ThreatDispatcher.onResume()
119
+ ExecutionStateDispatcher.onResume()
119
120
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
120
121
  ScreenProtector.register(activity)
121
122
  }
@@ -314,13 +315,12 @@ class FreeraspPlugin : Plugin() {
314
315
  .prod(configJson.getBool("isProd") ?: true)
315
316
  .killOnBypass(configJson.getBool("killOnBypass") ?: false)
316
317
 
317
- if (androidConfig.has("malwareConfig")) {
318
- val malwareConfig = androidConfig.getJSONObject("malwareConfig")
319
- talsecBuilder.whitelistedInstallationSources(malwareConfig.getArraySafe("whitelistedInstallationSources"))
320
- talsecBuilder.blacklistedHashes(malwareConfig.getArraySafe("blacklistedHashes"))
321
- talsecBuilder.blacklistedPackageNames(malwareConfig.getArraySafe("blacklistedPackageNames"))
322
- talsecBuilder.suspiciousPermissions(malwareConfig.getNestedArraySafe("suspiciousPermissions"))
318
+ if (androidConfig.has("suspiciousAppDetectionConfig")) {
319
+ talsecBuilder.suspiciousAppDetection(
320
+ androidConfig.getJSONObject("suspiciousAppDetectionConfig").toSuspiciousAppDetectionConfig()
321
+ )
323
322
  }
323
+
324
324
  return talsecBuilder.build()
325
325
  }
326
326
 
@@ -10,107 +10,100 @@ import com.aheaditec.freerasp.events.ThreatEvent
10
10
 
11
11
  internal object PluginThreatHandler {
12
12
 
13
- internal lateinit var threatDispatcher: ThreatDispatcher
14
- internal lateinit var executionStateDispatcher: ExecutionStateDispatcher
15
-
16
- fun initializeDispatchers(listener: FreeraspPlugin.PluginListener) {
17
- threatDispatcher = ThreatDispatcher(listener)
18
- executionStateDispatcher = ExecutionStateDispatcher(listener)
19
- }
20
13
 
21
14
  private val threatDetected = object : ThreatListener.ThreatDetected() {
22
15
 
23
16
  override fun onRootDetected() {
24
- threatDispatcher.dispatchThreat(ThreatEvent.PrivilegedAccess)
17
+ ThreatDispatcher.dispatchThreat(ThreatEvent.PrivilegedAccess)
25
18
  }
26
19
 
27
20
  override fun onDebuggerDetected() {
28
- threatDispatcher.dispatchThreat(ThreatEvent.Debug)
21
+ ThreatDispatcher.dispatchThreat(ThreatEvent.Debug)
29
22
  }
30
23
 
31
24
  override fun onEmulatorDetected() {
32
- threatDispatcher.dispatchThreat(ThreatEvent.Simulator)
25
+ ThreatDispatcher.dispatchThreat(ThreatEvent.Simulator)
33
26
  }
34
27
 
35
28
  override fun onTamperDetected() {
36
- threatDispatcher.dispatchThreat(ThreatEvent.AppIntegrity)
29
+ ThreatDispatcher.dispatchThreat(ThreatEvent.AppIntegrity)
37
30
  }
38
31
 
39
32
  override fun onUntrustedInstallationSourceDetected() {
40
- threatDispatcher.dispatchThreat(ThreatEvent.UnofficialStore)
33
+ ThreatDispatcher.dispatchThreat(ThreatEvent.UnofficialStore)
41
34
  }
42
35
 
43
36
  override fun onHookDetected() {
44
- threatDispatcher.dispatchThreat(ThreatEvent.Hooks)
37
+ ThreatDispatcher.dispatchThreat(ThreatEvent.Hooks)
45
38
  }
46
39
 
47
40
  override fun onDeviceBindingDetected() {
48
- threatDispatcher.dispatchThreat(ThreatEvent.DeviceBinding)
41
+ ThreatDispatcher.dispatchThreat(ThreatEvent.DeviceBinding)
49
42
  }
50
43
 
51
44
  override fun onObfuscationIssuesDetected() {
52
- threatDispatcher.dispatchThreat(ThreatEvent.ObfuscationIssues)
45
+ ThreatDispatcher.dispatchThreat(ThreatEvent.ObfuscationIssues)
53
46
  }
54
47
 
55
48
  override fun onMalwareDetected(suspiciousAppInfos: MutableList<SuspiciousAppInfo>) {
56
- threatDispatcher.dispatchMalware(suspiciousAppInfos ?: mutableListOf())
49
+ ThreatDispatcher.dispatchMalware(suspiciousAppInfos ?: mutableListOf())
57
50
  }
58
51
 
59
52
  override fun onScreenshotDetected() {
60
- threatDispatcher.dispatchThreat(ThreatEvent.Screenshot)
53
+ ThreatDispatcher.dispatchThreat(ThreatEvent.Screenshot)
61
54
  }
62
55
 
63
56
  override fun onScreenRecordingDetected() {
64
- threatDispatcher.dispatchThreat(ThreatEvent.ScreenRecording)
57
+ ThreatDispatcher.dispatchThreat(ThreatEvent.ScreenRecording)
65
58
  }
66
59
 
67
60
  override fun onMultiInstanceDetected() {
68
- threatDispatcher.dispatchThreat(ThreatEvent.MultiInstance)
61
+ ThreatDispatcher.dispatchThreat(ThreatEvent.MultiInstance)
69
62
  }
70
63
 
71
64
  override fun onUnsecureWifiDetected() {
72
- threatDispatcher.dispatchThreat(ThreatEvent.UnsecureWifi)
65
+ ThreatDispatcher.dispatchThreat(ThreatEvent.UnsecureWifi)
73
66
  }
74
67
 
75
68
  override fun onTimeSpoofingDetected() {
76
- threatDispatcher.dispatchThreat(ThreatEvent.TimeSpoofing)
69
+ ThreatDispatcher.dispatchThreat(ThreatEvent.TimeSpoofing)
77
70
  }
78
71
 
79
72
  override fun onLocationSpoofingDetected() {
80
- threatDispatcher.dispatchThreat(ThreatEvent.LocationSpoofing)
73
+ ThreatDispatcher.dispatchThreat(ThreatEvent.LocationSpoofing)
81
74
  }
82
75
 
83
76
  override fun onAutomationDetected() {
84
- threatDispatcher.dispatchThreat(ThreatEvent.Automation)
77
+ ThreatDispatcher.dispatchThreat(ThreatEvent.Automation)
85
78
  }
86
79
  }
87
80
 
88
81
  private val deviceState = object : ThreatListener.DeviceState() {
89
82
 
90
83
  override fun onUnlockedDeviceDetected() {
91
- threatDispatcher.dispatchThreat(ThreatEvent.Passcode)
84
+ ThreatDispatcher.dispatchThreat(ThreatEvent.Passcode)
92
85
  }
93
86
 
94
87
  override fun onHardwareBackedKeystoreNotAvailableDetected() {
95
- threatDispatcher.dispatchThreat(ThreatEvent.SecureHardwareNotAvailable)
88
+ ThreatDispatcher.dispatchThreat(ThreatEvent.SecureHardwareNotAvailable)
96
89
  }
97
90
 
98
91
  override fun onDeveloperModeDetected() {
99
- threatDispatcher.dispatchThreat(ThreatEvent.DevMode)
92
+ ThreatDispatcher.dispatchThreat(ThreatEvent.DevMode)
100
93
  }
101
94
 
102
95
  override fun onADBEnabledDetected() {
103
- threatDispatcher.dispatchThreat(ThreatEvent.ADBEnabled)
96
+ ThreatDispatcher.dispatchThreat(ThreatEvent.ADBEnabled)
104
97
  }
105
98
 
106
99
  override fun onSystemVPNDetected() {
107
- threatDispatcher.dispatchThreat(ThreatEvent.SystemVPN)
100
+ ThreatDispatcher.dispatchThreat(ThreatEvent.SystemVPN)
108
101
  }
109
102
  }
110
103
 
111
104
  private val raspExecutionState = object : ThreatListener.RaspExecutionState() {
112
105
  override fun onAllChecksFinished() {
113
- executionStateDispatcher.dispatch(RaspExecutionStateEvent.AllChecksFinished)
106
+ ExecutionStateDispatcher.dispatch(RaspExecutionStateEvent.AllChecksFinished)
114
107
  }
115
108
  }
116
109
 
@@ -123,4 +116,4 @@ internal object PluginThreatHandler {
123
116
  internal fun unregisterSDKListener(context: Context) {
124
117
  internalListener.unregisterListener(context)
125
118
  }
126
- }
119
+ }
@@ -3,13 +3,15 @@ package com.aheaditec.freerasp.dispatchers
3
3
  import com.aheaditec.freerasp.events.RaspExecutionStateEvent
4
4
  import com.aheaditec.freerasp.interfaces.PluginExecutionStateListener
5
5
 
6
- internal class ExecutionStateDispatcher(private val listener: PluginExecutionStateListener) {
6
+ internal object ExecutionStateDispatcher {
7
+ private lateinit var listener: PluginExecutionStateListener
7
8
  private val cache = mutableSetOf<RaspExecutionStateEvent>()
8
9
 
9
10
  private var isAppInForeground = false
10
11
  private var isListenerRegistered = false
11
12
 
12
- fun registerListener() {
13
+ fun registerListener(newListener: PluginExecutionStateListener) {
14
+ listener = newListener
13
15
  isListenerRegistered = true
14
16
  isAppInForeground = true
15
17
  flushCache()
@@ -4,14 +4,16 @@ import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
4
4
  import com.aheaditec.freerasp.events.ThreatEvent
5
5
  import com.aheaditec.freerasp.interfaces.PluginThreatListener
6
6
 
7
- internal class ThreatDispatcher(private val listener: PluginThreatListener) {
7
+ internal object ThreatDispatcher {
8
+ private lateinit var listener: PluginThreatListener
8
9
  private val threatCache = mutableSetOf<ThreatEvent>()
9
10
  private val malwareCache = mutableSetOf<SuspiciousAppInfo>()
10
11
 
11
12
  private var isAppInForeground = false
12
13
  private var isListenerRegistered = false
13
14
 
14
- fun registerListener() {
15
+ fun registerListener(newListener: PluginThreatListener) {
16
+ listener = newListener
15
17
  isListenerRegistered = true
16
18
  isAppInForeground = true
17
19
  flushCache()
@@ -9,7 +9,7 @@ import kotlinx.serialization.Serializable
9
9
  @Serializable
10
10
  data class CapSuspiciousAppInfo(
11
11
  val packageInfo: CapPackageInfo,
12
- val reason: String,
12
+ val reasons: Set<String>,
13
13
  val permissions: Set<String>?
14
14
  )
15
15
 
@@ -6,6 +6,10 @@ import android.util.Base64
6
6
  import android.util.Log
7
7
  import com.aheaditec.freerasp.models.CapPackageInfo
8
8
  import com.aheaditec.freerasp.models.CapSuspiciousAppInfo
9
+ import com.aheaditec.talsec_security.security.api.MalwareScanScope
10
+ import com.aheaditec.talsec_security.security.api.ReasonMode
11
+ import com.aheaditec.talsec_security.security.api.ScopeType
12
+ import com.aheaditec.talsec_security.security.api.SuspiciousAppDetectionConfig
9
13
  import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
10
14
  import com.getcapacitor.JSArray
11
15
  import kotlinx.serialization.encodeToString
@@ -50,13 +54,33 @@ internal fun JSONObject.getNestedArraySafe(key: String): Array<Array<String>> {
50
54
  return outArray.toTypedArray()
51
55
  }
52
56
 
57
+ internal fun JSONObject.toScanScope(): MalwareScanScope {
58
+ val scopeType = ScopeType.valueOf(getString("scopeType"))
59
+ val trustedInstallSources = optJSONArray("trustedInstallSources")
60
+ ?.toPrimitiveArray<String>()?.toList()
61
+ return MalwareScanScope(scopeType, trustedInstallSources)
62
+ }
63
+
64
+ internal fun JSONObject.toSuspiciousAppDetectionConfig(): SuspiciousAppDetectionConfig {
65
+ val scanScope = getJSONObject("scanScope").toScanScope()
66
+ val reasonMode = ReasonMode.valueOf(getString("reasonMode"))
67
+ return SuspiciousAppDetectionConfig(
68
+ getArraySafe("packageNames").toSet().takeIf { it.isNotEmpty() },
69
+ getArraySafe("hashes").toSet().takeIf { it.isNotEmpty() },
70
+ getNestedArraySafe("requestedPermissions").map { it.toSet() }.toSet().takeIf { it.isNotEmpty() },
71
+ getNestedArraySafe("grantedPermissions").map { it.toSet() }.toSet().takeIf { it.isNotEmpty() },
72
+ scanScope,
73
+ reasonMode,
74
+ )
75
+ }
76
+
53
77
  /**
54
78
  * Converts the Talsec's SuspiciousAppInfo to Capacitor equivalent
55
79
  */
56
80
  internal fun SuspiciousAppInfo.toCapSuspiciousAppInfo(context: Context): CapSuspiciousAppInfo {
57
81
  return CapSuspiciousAppInfo(
58
82
  packageInfo = this.packageInfo.toCapPackageInfo(context),
59
- reason = this.reason,
83
+ reasons = this.reasons,
60
84
  permissions = this.permissions
61
85
  )
62
86
  }
@@ -20,5 +20,4 @@ internal object RandomGenerator {
20
20
 
21
21
  return nextNumber
22
22
  }
23
-
24
- }
23
+ }
@@ -1,4 +1,4 @@
1
- import type { TalsecConfig, ThreatEventActions, RaspExecutionStateEventActions } from '../../types/types';
1
+ import type { RaspExecutionStateEventActions, TalsecConfig, ThreatEventActions } from '../../types/types';
2
2
  export declare const startFreeRASP: (config: TalsecConfig, actions: ThreatEventActions, raspExecutionStateActions?: RaspExecutionStateEventActions) => Promise<{
3
3
  started: boolean;
4
4
  }>;
@@ -1,3 +1,4 @@
1
+ import { withDefaults } from '../../utils/config';
1
2
  import { registerRaspExecutionStateListener } from '../listeners/raspExecutionState';
2
3
  import { registerThreatListener } from '../listeners/threat';
3
4
  import { Talsec } from '../nativeModules';
@@ -10,7 +11,7 @@ export const startFreeRASP = async (config, actions, raspExecutionStateActions)
10
11
  if (isRaspStarted) {
11
12
  return { started: true };
12
13
  }
13
- const response = await Talsec.talsecStart({ config });
14
+ const response = await Talsec.talsecStart({ config: withDefaults(config) });
14
15
  isRaspStarted = true;
15
16
  return response;
16
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"capacitor.js","sourceRoot":"","sources":["../../../../src/api/methods/capacitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,MAAoB,EACpB,OAA2B,EAC3B,yBAA0D,EAC3B,EAAE;IACjC,MAAM,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,yBAAyB,EAAE,CAAC;QAC9B,MAAM,kCAAkC,CAAC,yBAAyB,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,aAAa,GAAG,IAAI,CAAC;IAErB,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { TalsecConfig, ThreatEventActions, RaspExecutionStateEventActions } from '../../types/types';\nimport { registerRaspExecutionStateListener } from '../listeners/raspExecutionState';\nimport { registerThreatListener } from '../listeners/threat';\nimport { Talsec } from '../nativeModules';\n\nlet isRaspStarted = false;\n\nexport const startFreeRASP = async (\n config: TalsecConfig,\n actions: ThreatEventActions,\n raspExecutionStateActions?: RaspExecutionStateEventActions,\n): Promise<{ started: boolean }> => {\n await registerThreatListener(actions);\n if (raspExecutionStateActions) {\n await registerRaspExecutionStateListener(raspExecutionStateActions);\n }\n if (isRaspStarted) {\n return { started: true };\n }\n\n const response = await Talsec.talsecStart({ config });\n isRaspStarted = true;\n\n return response;\n};\n"]}
1
+ {"version":3,"file":"capacitor.js","sourceRoot":"","sources":["../../../../src/api/methods/capacitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,MAAoB,EACpB,OAA2B,EAC3B,yBAA0D,EAC3B,EAAE;IACjC,MAAM,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,yBAAyB,EAAE,CAAC;QAC9B,MAAM,kCAAkC,CAAC,yBAAyB,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5E,aAAa,GAAG,IAAI,CAAC;IAErB,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { RaspExecutionStateEventActions, TalsecConfig, ThreatEventActions } from '../../types/types';\nimport { withDefaults } from '../../utils/config';\nimport { registerRaspExecutionStateListener } from '../listeners/raspExecutionState';\nimport { registerThreatListener } from '../listeners/threat';\nimport { Talsec } from '../nativeModules';\n\nlet isRaspStarted = false;\n\nexport const startFreeRASP = async (\n config: TalsecConfig,\n actions: ThreatEventActions,\n raspExecutionStateActions?: RaspExecutionStateEventActions,\n): Promise<{ started: boolean }> => {\n await registerThreatListener(actions);\n if (raspExecutionStateActions) {\n await registerRaspExecutionStateListener(raspExecutionStateActions);\n }\n if (isRaspStarted) {\n return { started: true };\n }\n\n const response = await Talsec.talsecStart({ config: withDefaults(config) });\n isRaspStarted = true;\n\n return response;\n};\n"]}
@@ -61,21 +61,29 @@ export type TalsecAndroidConfig = {
61
61
  packageName: string;
62
62
  certificateHashes: string[];
63
63
  supportedAlternativeStores?: string[];
64
- malwareConfig?: TalsecMalwareConfig;
64
+ suspiciousAppDetectionConfig?: SuspiciousAppDetectionConfig;
65
65
  };
66
66
  export type TalsecIosConfig = {
67
67
  appBundleId: string;
68
68
  appTeamId: string;
69
69
  };
70
- export type TalsecMalwareConfig = {
71
- blacklistedHashes?: string[];
72
- blacklistedPackageNames?: string[];
73
- suspiciousPermissions?: string[][];
74
- whitelistedInstallationSources?: string[];
70
+ export type ScopeType = 'SIDELOADED_ONLY' | 'SIDELOADED_AND_SYSTEM_EXCLUDE_OEM' | 'SIDELOADED_AND_OEM' | 'SIDELOADED_AND_SYSTEM_AND_OEM' | 'ALL';
71
+ export type ReasonMode = 'ALL' | 'HIGHEST_CONFIDENCE';
72
+ export type ScanScope = {
73
+ scopeType: ScopeType;
74
+ trustedInstallSources?: string[];
75
+ };
76
+ export type SuspiciousAppDetectionConfig = {
77
+ packageNames?: string[];
78
+ hashes?: string[];
79
+ requestedPermissions?: string[][];
80
+ grantedPermissions?: string[][];
81
+ scanScope: ScanScope;
82
+ reasonMode: ReasonMode;
75
83
  };
76
84
  export type SuspiciousAppInfo = {
77
85
  packageInfo: PackageInfo;
78
- reason: string;
86
+ reasons: string[];
79
87
  permissions?: string[];
80
88
  };
81
89
  export type PackageInfo = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface TalsecPlugin {\n talsecStart(options: { config: TalsecConfig }): Promise<{ started: boolean }>;\n addListener(listener: string, callback: any): any;\n onInvalidCallback(): void;\n removeListenerForEvent(options: { eventName: string }): Promise<{ result: string }>;\n getThreatIdentifiers(): Promise<{ ids: number[] }>;\n getThreatChannelData(): Promise<{ ids: [string, string, string] }>;\n getRaspExecutionStateIdentifiers(): Promise<{ ids: number[] }>;\n getRaspExecutionStateChannelData(): Promise<{ ids: [string, string] }>;\n storeExternalId(options: { data: string }): Promise<{ result: boolean }>;\n removeExternalId(): Promise<{ result: boolean }>;\n addToWhitelist(options: { packageName: string }): Promise<{ result: boolean }>;\n blockScreenCapture(options: { enable: boolean }): Promise<{ result: boolean }>;\n isScreenCaptureBlocked(): Promise<{ result: boolean }>;\n getAppIcon(options: { packageName: string }): Promise<{ result: string }>;\n}\n\nexport type TalsecConfig = {\n androidConfig?: TalsecAndroidConfig;\n iosConfig?: TalsecIosConfig;\n watcherMail: string;\n isProd?: boolean;\n killOnBypass?: boolean;\n};\n\nexport type TalsecAndroidConfig = {\n packageName: string;\n certificateHashes: string[];\n supportedAlternativeStores?: string[];\n malwareConfig?: TalsecMalwareConfig;\n};\n\nexport type TalsecIosConfig = {\n appBundleId: string;\n appTeamId: string;\n};\n\nexport type TalsecMalwareConfig = {\n blacklistedHashes?: string[];\n blacklistedPackageNames?: string[];\n suspiciousPermissions?: string[][];\n whitelistedInstallationSources?: string[];\n};\n\nexport type SuspiciousAppInfo = {\n packageInfo: PackageInfo;\n reason: string;\n permissions?: string[];\n};\n\nexport type PackageInfo = {\n packageName: string;\n appName?: string;\n version?: string;\n appIcon?: string;\n installerStore?: string;\n};\n\nexport type ThreatEventActions = {\n privilegedAccess?: () => any;\n debug?: () => any;\n simulator?: () => any;\n appIntegrity?: () => any;\n unofficialStore?: () => any;\n hooks?: () => any;\n deviceBinding?: () => any;\n deviceID?: () => any;\n passcode?: () => any;\n secureHardwareNotAvailable?: () => any;\n obfuscationIssues?: () => any;\n devMode?: () => any;\n systemVPN?: () => any;\n malware?: (suspiciousApps: SuspiciousAppInfo[]) => any;\n adbEnabled?: () => any;\n screenshot?: () => any;\n screenRecording?: () => any;\n multiInstance?: () => any;\n timeSpoofing?: () => any;\n locationSpoofing?: () => any;\n unsecureWifi?: () => any;\n automation?: () => any;\n};\n\nexport type NativeEvent = { [key: string]: number | string[] | undefined };\n\nexport type RaspExecutionStateEventActions = {\n allChecksFinished?: () => any;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface TalsecPlugin {\n talsecStart(options: { config: TalsecConfig }): Promise<{ started: boolean }>;\n addListener(listener: string, callback: any): any;\n onInvalidCallback(): void;\n removeListenerForEvent(options: { eventName: string }): Promise<{ result: string }>;\n getThreatIdentifiers(): Promise<{ ids: number[] }>;\n getThreatChannelData(): Promise<{ ids: [string, string, string] }>;\n getRaspExecutionStateIdentifiers(): Promise<{ ids: number[] }>;\n getRaspExecutionStateChannelData(): Promise<{ ids: [string, string] }>;\n storeExternalId(options: { data: string }): Promise<{ result: boolean }>;\n removeExternalId(): Promise<{ result: boolean }>;\n addToWhitelist(options: { packageName: string }): Promise<{ result: boolean }>;\n blockScreenCapture(options: { enable: boolean }): Promise<{ result: boolean }>;\n isScreenCaptureBlocked(): Promise<{ result: boolean }>;\n getAppIcon(options: { packageName: string }): Promise<{ result: string }>;\n}\n\nexport type TalsecConfig = {\n androidConfig?: TalsecAndroidConfig;\n iosConfig?: TalsecIosConfig;\n watcherMail: string;\n isProd?: boolean;\n killOnBypass?: boolean;\n};\n\nexport type TalsecAndroidConfig = {\n packageName: string;\n certificateHashes: string[];\n supportedAlternativeStores?: string[];\n suspiciousAppDetectionConfig?: SuspiciousAppDetectionConfig;\n};\n\nexport type TalsecIosConfig = {\n appBundleId: string;\n appTeamId: string;\n};\n\nexport type ScopeType =\n | 'SIDELOADED_ONLY'\n | 'SIDELOADED_AND_SYSTEM_EXCLUDE_OEM'\n | 'SIDELOADED_AND_OEM'\n | 'SIDELOADED_AND_SYSTEM_AND_OEM'\n | 'ALL';\n\nexport type ReasonMode = 'ALL' | 'HIGHEST_CONFIDENCE';\n\nexport type ScanScope = {\n scopeType: ScopeType;\n trustedInstallSources?: string[];\n};\n\nexport type SuspiciousAppDetectionConfig = {\n packageNames?: string[];\n hashes?: string[];\n requestedPermissions?: string[][];\n grantedPermissions?: string[][];\n scanScope: ScanScope;\n reasonMode: ReasonMode;\n};\n\nexport type SuspiciousAppInfo = {\n packageInfo: PackageInfo;\n reasons: string[];\n permissions?: string[];\n};\n\nexport type PackageInfo = {\n packageName: string;\n appName?: string;\n version?: string;\n appIcon?: string;\n installerStore?: string;\n};\n\nexport type ThreatEventActions = {\n privilegedAccess?: () => any;\n debug?: () => any;\n simulator?: () => any;\n appIntegrity?: () => any;\n unofficialStore?: () => any;\n hooks?: () => any;\n deviceBinding?: () => any;\n deviceID?: () => any;\n passcode?: () => any;\n secureHardwareNotAvailable?: () => any;\n obfuscationIssues?: () => any;\n devMode?: () => any;\n systemVPN?: () => any;\n malware?: (suspiciousApps: SuspiciousAppInfo[]) => any;\n adbEnabled?: () => any;\n screenshot?: () => any;\n screenRecording?: () => any;\n multiInstance?: () => any;\n timeSpoofing?: () => any;\n locationSpoofing?: () => any;\n unsecureWifi?: () => any;\n automation?: () => any;\n};\n\nexport type NativeEvent = { [key: string]: number | string[] | undefined };\n\nexport type RaspExecutionStateEventActions = {\n allChecksFinished?: () => any;\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ScanScope, ReasonMode, SuspiciousAppDetectionConfig, TalsecAndroidConfig, TalsecConfig } from '../types/types';
2
+ export declare const DEFAULT_SCAN_SCOPE: ScanScope;
3
+ export declare const DEFAULT_REASON_MODE: ReasonMode;
4
+ export declare const withDetectionDefaults: (config: SuspiciousAppDetectionConfig) => SuspiciousAppDetectionConfig;
5
+ export declare const normalizeAndroidConfig: (androidConfig: TalsecAndroidConfig) => TalsecAndroidConfig;
6
+ export declare const withDefaults: (config: TalsecConfig) => TalsecConfig;
@@ -0,0 +1,21 @@
1
+ export const DEFAULT_SCAN_SCOPE = {
2
+ scopeType: 'SIDELOADED_ONLY',
3
+ };
4
+ export const DEFAULT_REASON_MODE = 'HIGHEST_CONFIDENCE';
5
+ export const withDetectionDefaults = (config) => {
6
+ var _a, _b;
7
+ return (Object.assign(Object.assign({}, config), { scanScope: (_a = config.scanScope) !== null && _a !== void 0 ? _a : DEFAULT_SCAN_SCOPE, reasonMode: (_b = config.reasonMode) !== null && _b !== void 0 ? _b : DEFAULT_REASON_MODE }));
8
+ };
9
+ export const normalizeAndroidConfig = (androidConfig) => {
10
+ if (!androidConfig.suspiciousAppDetectionConfig) {
11
+ return androidConfig;
12
+ }
13
+ return Object.assign(Object.assign({}, androidConfig), { suspiciousAppDetectionConfig: withDetectionDefaults(androidConfig.suspiciousAppDetectionConfig) });
14
+ };
15
+ export const withDefaults = (config) => {
16
+ if (!config.androidConfig) {
17
+ return config;
18
+ }
19
+ return Object.assign(Object.assign({}, config), { androidConfig: normalizeAndroidConfig(config.androidConfig) });
20
+ };
21
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,SAAS,EAAE,iBAAiB;CAC7B,CAAC;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAe,oBAAoB,CAAC;AAEpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAoC,EAAgC,EAAE;;IAAC,OAAA,iCACxG,MAAM,KACT,SAAS,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,kBAAkB,EACjD,UAAU,EAAE,MAAA,MAAM,CAAC,UAAU,mCAAI,mBAAmB,IACpD,CAAA;CAAA,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,aAAkC,EAAuB,EAAE;IAChG,IAAI,CAAC,aAAa,CAAC,4BAA4B,EAAE,CAAC;QAChD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,uCACK,aAAa,KAChB,4BAA4B,EAAE,qBAAqB,CAAC,aAAa,CAAC,4BAA4B,CAAC,IAC/F;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAoB,EAAgB,EAAE;IACjE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,uCACK,MAAM,KACT,aAAa,EAAE,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,IAC3D;AACJ,CAAC,CAAC","sourcesContent":["import type {\n ScanScope,\n ReasonMode,\n SuspiciousAppDetectionConfig,\n TalsecAndroidConfig,\n TalsecConfig,\n} from '../types/types';\n\nexport const DEFAULT_SCAN_SCOPE: ScanScope = {\n scopeType: 'SIDELOADED_ONLY',\n};\nexport const DEFAULT_REASON_MODE: ReasonMode = 'HIGHEST_CONFIDENCE';\n\nexport const withDetectionDefaults = (config: SuspiciousAppDetectionConfig): SuspiciousAppDetectionConfig => ({\n ...config,\n scanScope: config.scanScope ?? DEFAULT_SCAN_SCOPE,\n reasonMode: config.reasonMode ?? DEFAULT_REASON_MODE,\n});\n\nexport const normalizeAndroidConfig = (androidConfig: TalsecAndroidConfig): TalsecAndroidConfig => {\n if (!androidConfig.suspiciousAppDetectionConfig) {\n return androidConfig;\n }\n return {\n ...androidConfig,\n suspiciousAppDetectionConfig: withDetectionDefaults(androidConfig.suspiciousAppDetectionConfig),\n };\n};\n\nexport const withDefaults = (config: TalsecConfig): TalsecConfig => {\n if (!config.androidConfig) {\n return config;\n }\n return {\n ...config,\n androidConfig: normalizeAndroidConfig(config.androidConfig),\n };\n};\n"]}
@@ -15,7 +15,7 @@ export const toSuspiciousAppInfo = (base64Value) => {
15
15
  const packageInfo = data.packageInfo;
16
16
  return {
17
17
  packageInfo,
18
- reason: data.reason,
18
+ reasons: data.reasons,
19
19
  permissions: data.permissions,
20
20
  };
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"malware.js","sourceRoot":"","sources":["../../../src/utils/malware.ts"],"names":[],"mappings":"AAEA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAc,EAAgC,EAAE;IACrF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC;YACH,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,WAAmB,EAAqB,EAAE;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,WAA0B,CAAC;IACpD,OAAO;QACL,WAAW;QACX,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,WAAW,EAAE,IAAI,CAAC,WAAW;KACT,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import type { PackageInfo, SuspiciousAppInfo } from '../types/types';\n\n// parses base64-encoded malware data to SuspiciousAppInfo[]\nexport const parseMalwareData = async (data: string[]): Promise<SuspiciousAppInfo[]> => {\n return new Promise((resolve, reject) => {\n try {\n const suspiciousAppData = data.map((entry) => toSuspiciousAppInfo(entry));\n resolve(suspiciousAppData);\n } catch (error: any) {\n reject(`Parsing app data failed: ${error}`);\n }\n });\n};\n\nexport const toSuspiciousAppInfo = (base64Value: string): SuspiciousAppInfo => {\n const data = JSON.parse(atob(base64Value));\n const packageInfo = data.packageInfo as PackageInfo;\n return {\n packageInfo,\n reason: data.reason,\n permissions: data.permissions,\n } as SuspiciousAppInfo;\n};\n"]}
1
+ {"version":3,"file":"malware.js","sourceRoot":"","sources":["../../../src/utils/malware.ts"],"names":[],"mappings":"AAEA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAc,EAAgC,EAAE;IACrF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC;YACH,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,WAAmB,EAAqB,EAAE;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,WAA0B,CAAC;IACpD,OAAO;QACL,WAAW;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,WAAW,EAAE,IAAI,CAAC,WAAW;KACT,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import type { PackageInfo, SuspiciousAppInfo } from '../types/types';\n\n// parses base64-encoded malware data to SuspiciousAppInfo[]\nexport const parseMalwareData = async (data: string[]): Promise<SuspiciousAppInfo[]> => {\n return new Promise((resolve, reject) => {\n try {\n const suspiciousAppData = data.map((entry) => toSuspiciousAppInfo(entry));\n resolve(suspiciousAppData);\n } catch (error: any) {\n reject(`Parsing app data failed: ${error}`);\n }\n });\n};\n\nexport const toSuspiciousAppInfo = (base64Value: string): SuspiciousAppInfo => {\n const data = JSON.parse(atob(base64Value));\n const packageInfo = data.packageInfo as PackageInfo;\n return {\n packageInfo,\n reasons: data.reasons,\n permissions: data.permissions,\n } as SuspiciousAppInfo;\n};\n"]}
@@ -174,7 +174,7 @@ const toSuspiciousAppInfo = (base64Value) => {
174
174
  const packageInfo = data.packageInfo;
175
175
  return {
176
176
  packageInfo,
177
- reason: data.reason,
177
+ reasons: data.reasons,
178
178
  permissions: data.permissions,
179
179
  };
180
180
  };
@@ -362,6 +362,27 @@ const removeRaspExecutionStateListener = async () => {
362
362
  await Talsec.removeListenerForEvent({ eventName: executionStateChannel });
363
363
  };
364
364
 
365
+ const DEFAULT_SCAN_SCOPE = {
366
+ scopeType: 'SIDELOADED_ONLY',
367
+ };
368
+ const DEFAULT_REASON_MODE = 'HIGHEST_CONFIDENCE';
369
+ const withDetectionDefaults = (config) => {
370
+ var _a, _b;
371
+ return (Object.assign(Object.assign({}, config), { scanScope: (_a = config.scanScope) !== null && _a !== void 0 ? _a : DEFAULT_SCAN_SCOPE, reasonMode: (_b = config.reasonMode) !== null && _b !== void 0 ? _b : DEFAULT_REASON_MODE }));
372
+ };
373
+ const normalizeAndroidConfig = (androidConfig) => {
374
+ if (!androidConfig.suspiciousAppDetectionConfig) {
375
+ return androidConfig;
376
+ }
377
+ return Object.assign(Object.assign({}, androidConfig), { suspiciousAppDetectionConfig: withDetectionDefaults(androidConfig.suspiciousAppDetectionConfig) });
378
+ };
379
+ const withDefaults = (config) => {
380
+ if (!config.androidConfig) {
381
+ return config;
382
+ }
383
+ return Object.assign(Object.assign({}, config), { androidConfig: normalizeAndroidConfig(config.androidConfig) });
384
+ };
385
+
365
386
  let isRaspStarted = false;
366
387
  const startFreeRASP = async (config, actions, raspExecutionStateActions) => {
367
388
  await registerThreatListener(actions);
@@ -371,7 +392,7 @@ const startFreeRASP = async (config, actions, raspExecutionStateActions) => {
371
392
  if (isRaspStarted) {
372
393
  return { started: true };
373
394
  }
374
- const response = await Talsec.talsecStart({ config });
395
+ const response = await Talsec.talsecStart({ config: withDefaults(config) });
375
396
  isRaspStarted = true;
376
397
  return response;
377
398
  };