freerasp-react-native 4.2.4 → 4.3.1

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 (182) hide show
  1. package/CHANGELOG.md +69 -4
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt +45 -22
  4. package/android/src/main/java/com/freeraspreactnative/FreeraspThreatHandler.kt +39 -19
  5. package/android/src/main/java/com/freeraspreactnative/events/BaseRaspEvent.kt +7 -0
  6. package/android/src/main/java/com/freeraspreactnative/events/RaspExecutionStateEvent.kt +20 -0
  7. package/android/src/main/java/com/freeraspreactnative/events/ThreatEvent.kt +67 -0
  8. package/android/src/main/java/com/freeraspreactnative/models/RNSuspiciousAppInfo.kt +1 -0
  9. package/android/src/main/java/com/freeraspreactnative/utils/Extensions.kt +1 -0
  10. package/android/src/main/java/com/freeraspreactnative/utils/RandomGenerator.kt +18 -0
  11. package/android/src/main/java/com/freeraspreactnative/utils/Utils.kt +2 -5
  12. package/example/android/app/src/main/AndroidManifest.xml +7 -0
  13. package/example/src/App.tsx +77 -3
  14. package/example/src/DemoApp.tsx +46 -1
  15. package/example/src/MalwareItem.tsx +4 -0
  16. package/example/src/checks.ts +3 -0
  17. package/example/src/styles.ts +2 -0
  18. package/freerasp-react-native.podspec +1 -1
  19. package/ios/FreeraspReactNative.m +4 -0
  20. package/ios/FreeraspReactNative.swift +37 -75
  21. package/ios/TalsecRuntime.xcframework/Info.plist +5 -5
  22. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeDirectory +0 -0
  23. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
  24. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeResources +144 -114
  25. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeSignature +0 -0
  26. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  27. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +1 -1
  28. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +380 -281
  29. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curlver.h +5 -6
  30. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/easy.h +4 -4
  31. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/header.h +1 -1
  32. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/mprintf.h +11 -4
  33. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +62 -22
  34. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +2 -2
  35. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/system.h +76 -164
  36. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
  37. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +5 -4
  38. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/websockets.h +17 -3
  39. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
  40. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +181 -146
  41. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +3 -0
  42. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +3 -0
  43. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
  44. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  45. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +2 -2
  46. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +380 -281
  47. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curlver.h +5 -6
  48. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/easy.h +4 -4
  49. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/header.h +1 -1
  50. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/mprintf.h +11 -4
  51. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +62 -22
  52. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +2 -2
  53. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/system.h +76 -164
  54. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
  55. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +5 -4
  56. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/websockets.h +17 -3
  57. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
  58. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +181 -146
  59. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3 -0
  60. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3 -0
  61. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +181 -146
  62. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +3 -0
  63. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +3 -0
  64. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
  65. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +52 -41
  66. package/ios/models/RaspExecutionStates.swift +15 -0
  67. package/ios/models/SecurityThreat.swift +40 -0
  68. package/ios/utils/EventIdentifiers.swift +13 -0
  69. package/ios/utils/RandomGenerator.swift +12 -0
  70. package/ios/utils/Utils.swift +34 -0
  71. package/lib/commonjs/api/listeners/raspExecutionState.js +40 -0
  72. package/lib/commonjs/api/listeners/raspExecutionState.js.map +1 -0
  73. package/lib/commonjs/api/listeners/threat.js +102 -0
  74. package/lib/commonjs/api/listeners/threat.js.map +1 -0
  75. package/lib/commonjs/api/methods/native.js +43 -0
  76. package/lib/commonjs/api/methods/native.js.map +1 -0
  77. package/lib/commonjs/api/methods/reactNative.js +35 -0
  78. package/lib/commonjs/api/methods/reactNative.js.map +1 -0
  79. package/lib/commonjs/api/nativeModules.js +12 -0
  80. package/lib/commonjs/api/nativeModules.js.map +1 -0
  81. package/lib/commonjs/channels/raspExecutionState.js +36 -0
  82. package/lib/commonjs/channels/raspExecutionState.js.map +1 -0
  83. package/lib/commonjs/channels/threat.js +37 -0
  84. package/lib/commonjs/channels/threat.js.map +1 -0
  85. package/lib/commonjs/index.js +39 -188
  86. package/lib/commonjs/index.js.map +1 -1
  87. package/lib/commonjs/internal.js +6 -0
  88. package/lib/commonjs/internal.js.map +1 -0
  89. package/lib/commonjs/models/raspExecutionState.js +17 -0
  90. package/lib/commonjs/models/raspExecutionState.js.map +1 -0
  91. package/lib/commonjs/{threat.js → models/threat.js} +4 -1
  92. package/lib/commonjs/models/threat.js.map +1 -0
  93. package/lib/commonjs/types/types.js.map +1 -0
  94. package/lib/commonjs/utils/malware.js +28 -0
  95. package/lib/commonjs/utils/malware.js.map +1 -0
  96. package/lib/commonjs/utils/utils.js +21 -0
  97. package/lib/commonjs/utils/utils.js.map +1 -0
  98. package/lib/module/api/listeners/raspExecutionState.js +32 -0
  99. package/lib/module/api/listeners/raspExecutionState.js.map +1 -0
  100. package/lib/module/api/listeners/threat.js +94 -0
  101. package/lib/module/api/listeners/threat.js.map +1 -0
  102. package/lib/module/api/methods/native.js +30 -0
  103. package/lib/module/api/methods/native.js.map +1 -0
  104. package/lib/module/api/methods/reactNative.js +28 -0
  105. package/lib/module/api/methods/reactNative.js.map +1 -0
  106. package/lib/module/api/nativeModules.js +5 -0
  107. package/lib/module/api/nativeModules.js.map +1 -0
  108. package/lib/module/channels/raspExecutionState.js +27 -0
  109. package/lib/module/channels/raspExecutionState.js.map +1 -0
  110. package/lib/module/channels/threat.js +28 -0
  111. package/lib/module/channels/threat.js.map +1 -0
  112. package/lib/module/index.js +5 -172
  113. package/lib/module/index.js.map +1 -1
  114. package/lib/module/internal.js +3 -0
  115. package/lib/module/internal.js.map +1 -0
  116. package/lib/module/models/raspExecutionState.js +10 -0
  117. package/lib/module/models/raspExecutionState.js.map +1 -0
  118. package/lib/module/{threat.js → models/threat.js} +4 -1
  119. package/lib/module/models/threat.js.map +1 -0
  120. package/lib/module/types/types.js.map +1 -0
  121. package/lib/module/utils/malware.js +20 -0
  122. package/lib/module/utils/malware.js.map +1 -0
  123. package/lib/module/utils/utils.js +12 -0
  124. package/lib/module/utils/utils.js.map +1 -0
  125. package/lib/typescript/src/api/listeners/raspExecutionState.d.ts +4 -0
  126. package/lib/typescript/src/api/listeners/raspExecutionState.d.ts.map +1 -0
  127. package/lib/typescript/src/api/listeners/threat.d.ts +4 -0
  128. package/lib/typescript/src/api/listeners/threat.d.ts.map +1 -0
  129. package/lib/typescript/src/api/methods/native.d.ts +9 -0
  130. package/lib/typescript/src/api/methods/native.d.ts.map +1 -0
  131. package/lib/typescript/src/api/methods/reactNative.d.ts +3 -0
  132. package/lib/typescript/src/api/methods/reactNative.d.ts.map +1 -0
  133. package/lib/typescript/src/api/nativeModules.d.ts +2 -0
  134. package/lib/typescript/src/api/nativeModules.d.ts.map +1 -0
  135. package/lib/typescript/src/channels/raspExecutionState.d.ts +7 -0
  136. package/lib/typescript/src/channels/raspExecutionState.d.ts.map +1 -0
  137. package/lib/typescript/src/channels/threat.d.ts +8 -0
  138. package/lib/typescript/src/channels/threat.d.ts.map +1 -0
  139. package/lib/typescript/src/index.d.ts +5 -13
  140. package/lib/typescript/src/index.d.ts.map +1 -1
  141. package/lib/typescript/src/internal.d.ts +2 -0
  142. package/lib/typescript/src/internal.d.ts.map +1 -0
  143. package/lib/typescript/src/models/raspExecutionState.d.ts +7 -0
  144. package/lib/typescript/src/models/raspExecutionState.d.ts.map +1 -0
  145. package/lib/typescript/src/{threat.d.ts → models/threat.d.ts} +3 -0
  146. package/lib/typescript/src/models/threat.d.ts.map +1 -0
  147. package/lib/typescript/src/{types.d.ts → types/types.d.ts} +12 -1
  148. package/lib/typescript/src/types/types.d.ts.map +1 -0
  149. package/lib/typescript/src/utils/malware.d.ts +4 -0
  150. package/lib/typescript/src/utils/malware.d.ts.map +1 -0
  151. package/lib/typescript/src/{utils.d.ts → utils/utils.d.ts} +1 -0
  152. package/lib/typescript/src/utils/utils.d.ts.map +1 -0
  153. package/package.json +2 -2
  154. package/src/api/listeners/raspExecutionState.ts +42 -0
  155. package/src/api/listeners/threat.ts +101 -0
  156. package/src/api/methods/native.ts +39 -0
  157. package/src/api/methods/reactNative.ts +42 -0
  158. package/src/api/nativeModules.ts +3 -0
  159. package/src/channels/raspExecutionState.ts +35 -0
  160. package/src/channels/threat.ts +35 -0
  161. package/src/index.tsx +5 -209
  162. package/src/internal.ts +2 -0
  163. package/src/models/raspExecutionState.ts +13 -0
  164. package/src/{threat.ts → models/threat.ts} +6 -0
  165. package/src/{types.ts → types/types.ts} +12 -1
  166. package/src/utils/malware.ts +24 -0
  167. package/src/utils/utils.ts +14 -0
  168. package/android/src/main/java/com/freeraspreactnative/Threat.kt +0 -57
  169. package/lib/commonjs/threat.js.map +0 -1
  170. package/lib/commonjs/types.js.map +0 -1
  171. package/lib/commonjs/utils.js +0 -16
  172. package/lib/commonjs/utils.js.map +0 -1
  173. package/lib/module/threat.js.map +0 -1
  174. package/lib/module/types.js.map +0 -1
  175. package/lib/module/utils.js +0 -8
  176. package/lib/module/utils.js.map +0 -1
  177. package/lib/typescript/src/threat.d.ts.map +0 -1
  178. package/lib/typescript/src/types.d.ts.map +0 -1
  179. package/lib/typescript/src/utils.d.ts.map +0 -1
  180. package/src/utils.ts +0 -9
  181. /package/lib/commonjs/{types.js → types/types.js} +0 -0
  182. /package/lib/module/{types.js → types/types.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,71 @@ 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
+ ## [4.3.1] - 2025-12-16
9
+
10
+ - Android SDK version: 17.0.1
11
+ - iOS SDK version: 6.13.0
12
+
13
+ ### React Native
14
+
15
+ #### Fixed
16
+
17
+ - Resolved duplicate classes error on iOS [(issue #128)](https://github.com/talsec/Free-RASP-ReactNative/issues/128)
18
+
19
+ ## [4.3.0] - 2025-10-31
20
+
21
+ - Android SDK version: 17.0.1
22
+ - iOS SDK version: 6.13.0
23
+
24
+ ### React Native
25
+
26
+ #### Added
27
+
28
+ - Added `killOnBypass` to `TalsecConfig` that configures if the app should be terminated when the threat callbacks are suppressed/hooked by an attacker (Android only) ([Issue 65](https://github.com/talsec/Free-RASP-Android/issues/65))
29
+ - Added API for `timeSpoofing` callback into `ThreatEventActions` (Android only)
30
+ - Added API for `unsecureWifi` callback into `ThreatEventActions` (Android only)
31
+ - Added API for `allChecksFinished` callback into new `RaspExecutionStateEventActions` object
32
+ - Added matched permissions to `SuspiciousAppInfo` object when malware detection reason is `suspiciousPermission`
33
+
34
+ #### Fixed
35
+
36
+ - Resolved potential collision in threat identifiers
37
+
38
+ ### Android
39
+
40
+ #### Added
41
+
42
+ - Added `killOnBypass` method to the `TalsecConfig.Builder` that configures if the app should be terminated when the threat callbacks are suppressed/hooked by an attacker [Issue 65](https://github.com/talsec/Free-RASP-Android/issues/65)
43
+ - We are introducing a new capability, detecting whether the device time has been tampered with (`timeSpoofing`)
44
+ - We are introducing a new capability, detecting whether the location is being spoofed on the device (`locationSpoofing`)
45
+ - We are introducing a new capability, detection of unsecure WiFi (`unecureWifi`)
46
+ - Removed deprecated functionality `Pbkdf2Native` and both related native libraries (`libpbkdf2_native.so` and `libpolarssl.so`)
47
+ - Added new `RaspExecutionState` which contains `onAllChecksFinished()` method, which is triggered after all checks are completed.
48
+ - Added matched permissions to `SuspiciousAppInfo` object when malware detection reason is `suspiciousPermission`
49
+ - New option to start Talsec, `Talsec.start()` takes new parameter `TalsecMode` that determines the dispatcher thread of initialization and sync checks (uses background thread by default)
50
+ - Capability to check if another app has an option `REQUEST_INSTALL_PACKAGES` enabled in the system settings to malware detection
51
+
52
+ #### Fixed
53
+
54
+ - ANR issue caused by `registerScreenCaptureCallback()` method on the main thread
55
+ - `NullPointerException` when checking key alias in Keystore on Android 7
56
+ - `JaCoCo` issue causing `MethodTooLargeException` during instrumentation
57
+ - `DeadApplicationException` when calling `Settings.Global.getInt` or `Settings.Secure.getInt` on invalid context
58
+ - `AndroidKeyStore` crashes causing `java.util.concurrent.TimeoutException` when calling `finalize()` method on `Cipher` (GC issues)
59
+ - Fixed issue with late initializers and `TalsecMode` coroutines scopes
60
+
61
+ #### Changed
62
+
63
+ - Shortened the value of threat detection interval
64
+ - Refactoring of internal architecture of SDK that newly uses Coroutines to manage threading
65
+ - Update of internal dependencies and security libraries
66
+
67
+ ### iOS
68
+
69
+ #### Changed
70
+
71
+ - Updated internal dependencies
72
+
8
73
  ## [4.2.4] - 2025-09-17
9
74
 
10
75
  - iOS SDK version: 6.12.1
@@ -112,7 +177,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
112
177
  - Added interface for screenshot / screen recording blocking on iOS
113
178
  - Added interface for external ID storage
114
179
 
115
- ### Android
180
+ ### Android
116
181
 
117
182
  #### Added
118
183
 
@@ -148,7 +213,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
148
213
  - Android SDK requires `kotlinVersion` >= `2.0.0`
149
214
  - Set Java verison to 17
150
215
 
151
- ### Android
216
+ ### Android
152
217
 
153
218
  #### Changed
154
219
 
@@ -200,7 +265,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
200
265
 
201
266
  - Raised Android compileSDK level to 35
202
267
 
203
- #### Fixed
268
+ #### Fixed
204
269
 
205
270
  - Compatibility issues with RN New Architecture
206
271
  - Added proguard rules for malware data serialization in release mode on Android
@@ -278,7 +343,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
278
343
 
279
344
  #### Added
280
345
 
281
- - Added configuration fields for malware detection
346
+ - Added configuration fields for malware detection
282
347
 
283
348
  ### Android
284
349
 
@@ -99,7 +99,7 @@ dependencies {
99
99
  implementation "com.facebook.react:react-native:$react_native_version"
100
100
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
101
101
  implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
102
- implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-ReactNative:16.0.4"
102
+ implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-ReactNative:17.0.1"
103
103
  }
104
104
 
105
105
  if (isNewArchitectureEnabled()) {
@@ -7,6 +7,7 @@ import android.os.Looper
7
7
  import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
8
8
  import com.aheaditec.talsec_security.security.api.Talsec
9
9
  import com.aheaditec.talsec_security.security.api.TalsecConfig
10
+ import com.aheaditec.talsec_security.security.api.TalsecMode
10
11
  import com.aheaditec.talsec_security.security.api.ThreatListener
11
12
  import com.facebook.react.bridge.Arguments
12
13
  import com.facebook.react.bridge.LifecycleEventListener
@@ -18,6 +19,9 @@ import com.facebook.react.bridge.ReadableMap
18
19
  import com.facebook.react.bridge.UiThreadUtil.runOnUiThread
19
20
  import com.facebook.react.bridge.WritableArray
20
21
  import com.facebook.react.modules.core.DeviceEventManagerModule
22
+ import com.freeraspreactnative.events.BaseRaspEvent
23
+ import com.freeraspreactnative.events.RaspExecutionStateEvent
24
+ import com.freeraspreactnative.events.ThreatEvent
21
25
  import com.freeraspreactnative.utils.Utils
22
26
  import com.freeraspreactnative.utils.getArraySafe
23
27
  import com.freeraspreactnative.utils.getBooleanSafe
@@ -29,7 +33,7 @@ import com.freeraspreactnative.utils.toEncodedWritableArray
29
33
  class FreeraspReactNativeModule(private val reactContext: ReactApplicationContext) :
30
34
  ReactContextBaseJavaModule(reactContext) {
31
35
 
32
- private val listener = ThreatListener(FreeraspThreatHandler, FreeraspThreatHandler)
36
+ private val listener = ThreatListener(FreeraspThreatHandler, FreeraspThreatHandler, FreeraspThreatHandler)
33
37
  private val lifecycleListener = object : LifecycleEventListener {
34
38
  override fun onHostResume() {
35
39
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
@@ -67,7 +71,7 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
67
71
  FreeraspThreatHandler.listener = ThreatListener
68
72
  listener.registerListener(reactContext)
69
73
  runOnUiThread {
70
- Talsec.start(reactContext, config)
74
+ Talsec.start(reactContext, config, TalsecMode.BACKGROUND)
71
75
  mainHandler.post {
72
76
  talsecStarted = true
73
77
  // This code must be called only AFTER Talsec.start
@@ -90,19 +94,39 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
90
94
  */
91
95
  @ReactMethod
92
96
  fun getThreatIdentifiers(promise: Promise) {
93
- promise.resolve(Threat.getThreatValues())
97
+ promise.resolve(ThreatEvent.ALL_EVENTS)
94
98
  }
95
99
 
96
100
  /**
97
- * Method to setup the message passing between native and React Native
101
+ * Method to get the random identifiers of callbacks
102
+ */
103
+ @ReactMethod
104
+ fun getRaspExecutionStateIdentifiers(promise: Promise) {
105
+ promise.resolve(RaspExecutionStateEvent.ALL_EVENTS)
106
+ }
107
+
108
+ /**
109
+ * Method to setup the threat message passing between native and React Native
98
110
  * @return list of [THREAT_CHANNEL_NAME, THREAT_CHANNEL_KEY]
99
111
  */
100
112
  @ReactMethod
101
113
  fun getThreatChannelData(promise: Promise) {
102
114
  val channelData: WritableArray = Arguments.createArray()
103
- channelData.pushString(THREAT_CHANNEL_NAME)
104
- channelData.pushString(THREAT_CHANNEL_KEY)
105
- channelData.pushString(MALWARE_CHANNEL_KEY)
115
+ channelData.pushString(ThreatEvent.CHANNEL_NAME)
116
+ channelData.pushString(ThreatEvent.CHANNEL_KEY)
117
+ channelData.pushString(ThreatEvent.MALWARE_CHANNEL_KEY)
118
+ promise.resolve(channelData)
119
+ }
120
+
121
+ /**
122
+ * Method to setup the execution state message passing between native and React Native
123
+ * @return list of [THREAT_CHANNEL_NAME, THREAT_CHANNEL_KEY]
124
+ */
125
+ @ReactMethod
126
+ fun getRaspExecutionStateChannelData(promise: Promise) {
127
+ val channelData: WritableArray = Arguments.createArray()
128
+ channelData.pushString(RaspExecutionStateEvent.CHANNEL_NAME)
129
+ channelData.pushString(RaspExecutionStateEvent.CHANNEL_KEY)
106
130
  promise.resolve(channelData)
107
131
  }
108
132
 
@@ -207,8 +231,9 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
207
231
 
208
232
  val talsecBuilder = TalsecConfig.Builder(packageName, certificateHashes)
209
233
  .watcherMail(config.getString("watcherMail"))
210
- .supportedAlternativeStores(androidConfig.getArraySafe("supportedAlternativeStores"))
211
234
  .prod(config.getBooleanSafe("isProd"))
235
+ .killOnBypass(config.getBooleanSafe("killOnBypass", false))
236
+ .supportedAlternativeStores(androidConfig.getArraySafe("supportedAlternativeStores"))
212
237
 
213
238
  if (androidConfig.hasKey("malwareConfig")) {
214
239
  val malwareConfig = androidConfig.getMapThrowing("malwareConfig")
@@ -223,12 +248,6 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
223
248
 
224
249
  companion object {
225
250
  const val NAME = "FreeraspReactNative"
226
- private val THREAT_CHANNEL_NAME = (10000..999999999).random()
227
- .toString() // name of the channel over which threat callbacks are sent
228
- private val THREAT_CHANNEL_KEY = (10000..999999999).random()
229
- .toString() // key of the argument map under which threats are expected
230
- private val MALWARE_CHANNEL_KEY = (10000..999999999).random()
231
- .toString() // key of the argument map under which malware data is expected
232
251
 
233
252
  private val backgroundHandlerThread = HandlerThread("BackgroundThread").apply { start() }
234
253
  private val backgroundHandler = Handler(backgroundHandlerThread.looper)
@@ -238,11 +257,11 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
238
257
 
239
258
  internal var talsecStarted = false
240
259
 
241
- private fun notifyListeners(threat: Threat) {
260
+ private fun notifyEvent(event: BaseRaspEvent) {
242
261
  val params = Arguments.createMap()
243
- params.putInt(THREAT_CHANNEL_KEY, threat.value)
262
+ params.putInt(event.channelKey, event.value)
244
263
  appReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
245
- .emit(THREAT_CHANNEL_NAME, params)
264
+ .emit(event.channelName, params)
246
265
  }
247
266
 
248
267
  /**
@@ -256,25 +275,29 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
256
275
 
257
276
  mainHandler.post {
258
277
  val params = Arguments.createMap()
259
- params.putInt(THREAT_CHANNEL_KEY, Threat.Malware.value)
278
+ params.putInt(ThreatEvent.CHANNEL_KEY, ThreatEvent.Malware.value)
260
279
  params.putArray(
261
- MALWARE_CHANNEL_KEY, encodedSuspiciousApps
280
+ ThreatEvent.MALWARE_CHANNEL_KEY, encodedSuspiciousApps
262
281
  )
263
282
 
264
283
  appReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
265
- .emit(THREAT_CHANNEL_NAME, params)
284
+ .emit(ThreatEvent.CHANNEL_NAME, params)
266
285
  }
267
286
  }
268
287
  }
269
288
  }
270
289
 
271
290
  internal object ThreatListener : FreeraspThreatHandler.TalsecReactNative {
272
- override fun threatDetected(threatType: Threat) {
273
- notifyListeners(threatType)
291
+ override fun threatDetected(threatEventType: ThreatEvent) {
292
+ notifyEvent(threatEventType)
274
293
  }
275
294
 
276
295
  override fun malwareDetected(suspiciousApps: MutableList<SuspiciousAppInfo>) {
277
296
  notifyMalware(suspiciousApps)
278
297
  }
298
+
299
+ override fun raspExecutionStateChanged(event: RaspExecutionStateEvent) {
300
+ notifyEvent(event)
301
+ }
279
302
  }
280
303
  }
@@ -2,82 +2,102 @@ package com.freeraspreactnative
2
2
 
3
3
  import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
4
4
  import com.aheaditec.talsec_security.security.api.ThreatListener
5
+ import com.freeraspreactnative.events.RaspExecutionStateEvent
6
+ import com.freeraspreactnative.events.ThreatEvent
5
7
 
6
- internal object FreeraspThreatHandler : ThreatListener.ThreatDetected, ThreatListener.DeviceState {
8
+ internal object FreeraspThreatHandler : ThreatListener.ThreatDetected, ThreatListener.DeviceState, ThreatListener.RaspExecutionState() {
7
9
 
8
10
  internal var listener: TalsecReactNative? = null
9
11
 
10
12
  override fun onRootDetected() {
11
- listener?.threatDetected(Threat.PrivilegedAccess)
13
+ listener?.threatDetected(ThreatEvent.PrivilegedAccess)
12
14
  }
13
15
 
14
16
  override fun onDebuggerDetected() {
15
- listener?.threatDetected(Threat.Debug)
17
+ listener?.threatDetected(ThreatEvent.Debug)
16
18
  }
17
19
 
18
20
  override fun onEmulatorDetected() {
19
- listener?.threatDetected(Threat.Simulator)
21
+ listener?.threatDetected(ThreatEvent.Simulator)
20
22
  }
21
23
 
22
24
  override fun onTamperDetected() {
23
- listener?.threatDetected(Threat.AppIntegrity)
25
+ listener?.threatDetected(ThreatEvent.AppIntegrity)
24
26
  }
25
27
 
26
28
  override fun onUntrustedInstallationSourceDetected() {
27
- listener?.threatDetected(Threat.UnofficialStore)
29
+ listener?.threatDetected(ThreatEvent.UnofficialStore)
28
30
  }
29
31
 
30
32
  override fun onHookDetected() {
31
- listener?.threatDetected(Threat.Hooks)
33
+ listener?.threatDetected(ThreatEvent.Hooks)
32
34
  }
33
35
 
34
36
  override fun onDeviceBindingDetected() {
35
- listener?.threatDetected(Threat.DeviceBinding)
37
+ listener?.threatDetected(ThreatEvent.DeviceBinding)
36
38
  }
37
39
 
38
40
  override fun onObfuscationIssuesDetected() {
39
- listener?.threatDetected(Threat.ObfuscationIssues)
41
+ listener?.threatDetected(ThreatEvent.ObfuscationIssues)
40
42
  }
41
43
 
42
- override fun onMalwareDetected(suspiciousAppInfos: MutableList<SuspiciousAppInfo>?) {
44
+ override fun onMalwareDetected(suspiciousAppInfos: MutableList<SuspiciousAppInfo>) {
43
45
  listener?.malwareDetected(suspiciousAppInfos ?: mutableListOf())
44
46
  }
45
47
 
46
48
  override fun onUnlockedDeviceDetected() {
47
- listener?.threatDetected(Threat.Passcode)
49
+ listener?.threatDetected(ThreatEvent.Passcode)
48
50
  }
49
51
 
50
52
  override fun onHardwareBackedKeystoreNotAvailableDetected() {
51
- listener?.threatDetected(Threat.SecureHardwareNotAvailable)
53
+ listener?.threatDetected(ThreatEvent.SecureHardwareNotAvailable)
52
54
  }
53
55
 
54
56
  override fun onDeveloperModeDetected() {
55
- listener?.threatDetected(Threat.DevMode)
57
+ listener?.threatDetected(ThreatEvent.DevMode)
56
58
  }
57
59
 
58
60
  override fun onADBEnabledDetected() {
59
- listener?.threatDetected(Threat.ADBEnabled)
61
+ listener?.threatDetected(ThreatEvent.ADBEnabled)
60
62
  }
61
63
 
62
64
  override fun onSystemVPNDetected() {
63
- listener?.threatDetected(Threat.SystemVPN)
65
+ listener?.threatDetected(ThreatEvent.SystemVPN)
64
66
  }
65
67
 
66
68
  override fun onScreenshotDetected() {
67
- listener?.threatDetected(Threat.Screenshot)
69
+ listener?.threatDetected(ThreatEvent.Screenshot)
68
70
  }
69
71
 
70
72
  override fun onScreenRecordingDetected() {
71
- listener?.threatDetected(Threat.ScreenRecording)
73
+ listener?.threatDetected(ThreatEvent.ScreenRecording)
72
74
  }
73
75
 
74
76
  override fun onMultiInstanceDetected() {
75
- listener?.threatDetected(Threat.MultiInstance)
77
+ listener?.threatDetected(ThreatEvent.MultiInstance)
78
+ }
79
+
80
+ override fun onUnsecureWifiDetected() {
81
+ listener?.threatDetected(ThreatEvent.UnsecureWifi)
82
+ }
83
+
84
+ override fun onTimeSpoofingDetected() {
85
+ listener?.threatDetected(ThreatEvent.TimeSpoofing)
86
+ }
87
+
88
+ override fun onLocationSpoofingDetected() {
89
+ listener?.threatDetected(ThreatEvent.LocationSpoofing)
90
+ }
91
+
92
+ override fun onAllChecksFinished() {
93
+ listener?.raspExecutionStateChanged(RaspExecutionStateEvent.AllChecksFinished)
76
94
  }
77
95
 
78
96
  internal interface TalsecReactNative {
79
- fun threatDetected(threatType: Threat)
97
+ fun threatDetected(threatEventType: ThreatEvent)
80
98
 
81
99
  fun malwareDetected(suspiciousApps: MutableList<SuspiciousAppInfo>)
100
+
101
+ fun raspExecutionStateChanged(event: RaspExecutionStateEvent)
82
102
  }
83
103
  }
@@ -0,0 +1,7 @@
1
+ package com.freeraspreactnative.events
2
+
3
+ internal interface BaseRaspEvent {
4
+ val value: Int
5
+ val channelName: String
6
+ val channelKey: String
7
+ }
@@ -0,0 +1,20 @@
1
+ package com.freeraspreactnative.events
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.freeraspreactnative.utils.RandomGenerator
5
+
6
+ internal sealed class RaspExecutionStateEvent(override val value: Int) : BaseRaspEvent {
7
+ override val channelName: String get() = CHANNEL_NAME
8
+ override val channelKey: String get() = CHANNEL_KEY
9
+
10
+ data object AllChecksFinished : RaspExecutionStateEvent(RandomGenerator.next())
11
+
12
+ companion object Companion {
13
+ internal val CHANNEL_NAME = RandomGenerator.next().toString()
14
+ internal val CHANNEL_KEY = RandomGenerator.next().toString()
15
+ internal val ALL_EVENTS = Arguments.fromList(
16
+ listOf(
17
+ AllChecksFinished
18
+ ).map { it.value })
19
+ }
20
+ }
@@ -0,0 +1,67 @@
1
+ package com.freeraspreactnative.events
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.freeraspreactnative.utils.RandomGenerator
5
+
6
+ /**
7
+ * Sealed class to represent the error codes.
8
+ *
9
+ * Sealed classes are used because of obfuscation - enums classes are not obfuscated well enough.
10
+ *
11
+ * @property value integer value of the error code.
12
+ */
13
+ internal sealed class ThreatEvent(override val value: Int) : BaseRaspEvent {
14
+ override val channelName: String get() = CHANNEL_NAME
15
+ override val channelKey: String get() = CHANNEL_KEY
16
+
17
+ data object AppIntegrity : ThreatEvent(RandomGenerator.next())
18
+ data object PrivilegedAccess : ThreatEvent(RandomGenerator.next())
19
+ data object Debug : ThreatEvent(RandomGenerator.next())
20
+ data object Hooks : ThreatEvent(RandomGenerator.next())
21
+ data object Passcode : ThreatEvent(RandomGenerator.next())
22
+ data object Simulator : ThreatEvent(RandomGenerator.next())
23
+ data object SecureHardwareNotAvailable : ThreatEvent(RandomGenerator.next())
24
+ data object DeviceBinding : ThreatEvent(RandomGenerator.next())
25
+ data object UnofficialStore : ThreatEvent(RandomGenerator.next())
26
+ data object ObfuscationIssues : ThreatEvent(RandomGenerator.next())
27
+ data object SystemVPN : ThreatEvent(RandomGenerator.next())
28
+ data object DevMode : ThreatEvent(RandomGenerator.next())
29
+ data object Malware : ThreatEvent(RandomGenerator.next())
30
+ data object ADBEnabled : ThreatEvent(RandomGenerator.next())
31
+ data object Screenshot : ThreatEvent(RandomGenerator.next())
32
+ data object ScreenRecording : ThreatEvent(RandomGenerator.next())
33
+ data object MultiInstance : ThreatEvent(RandomGenerator.next())
34
+ data object TimeSpoofing : ThreatEvent(RandomGenerator.next())
35
+ data object LocationSpoofing : ThreatEvent(RandomGenerator.next())
36
+ data object UnsecureWifi : ThreatEvent(RandomGenerator.next())
37
+
38
+ companion object {
39
+ internal val CHANNEL_NAME = RandomGenerator.next().toString()
40
+ internal val CHANNEL_KEY = RandomGenerator.next().toString()
41
+ internal val MALWARE_CHANNEL_KEY = RandomGenerator.next().toString()
42
+
43
+ internal val ALL_EVENTS = Arguments.fromList(
44
+ listOf(
45
+ AppIntegrity,
46
+ PrivilegedAccess,
47
+ Debug,
48
+ Hooks,
49
+ Passcode,
50
+ Simulator,
51
+ SecureHardwareNotAvailable,
52
+ SystemVPN,
53
+ DeviceBinding,
54
+ UnofficialStore,
55
+ ObfuscationIssues,
56
+ DevMode,
57
+ Malware,
58
+ ADBEnabled,
59
+ Screenshot,
60
+ ScreenRecording,
61
+ MultiInstance,
62
+ TimeSpoofing,
63
+ LocationSpoofing,
64
+ UnsecureWifi
65
+ ).map { it.value })
66
+ }
67
+ }
@@ -10,6 +10,7 @@ import kotlinx.serialization.Serializable
10
10
  data class RNSuspiciousAppInfo(
11
11
  val packageInfo: RNPackageInfo,
12
12
  val reason: String,
13
+ val permissions: Set<String>?
13
14
  )
14
15
 
15
16
  /**
@@ -75,6 +75,7 @@ internal fun SuspiciousAppInfo.toRNSuspiciousAppInfo(context: ReactContext): RNS
75
75
  return RNSuspiciousAppInfo(
76
76
  packageInfo = this.packageInfo.toRNPackageInfo(context),
77
77
  reason = this.reason,
78
+ permissions = this.permissions
78
79
  )
79
80
  }
80
81
 
@@ -0,0 +1,18 @@
1
+ package com.freeraspreactnative.utils
2
+
3
+ import java.security.SecureRandom
4
+
5
+ internal object RandomGenerator {
6
+ private val secureRandom = SecureRandom()
7
+ private val generatedNumbers = mutableSetOf<Int>()
8
+
9
+ internal fun next(): Int {
10
+ val min = 10000
11
+ val max = 999999999
12
+ var nextNumber = secureRandom.nextInt((max - min) + 1) + min
13
+ while (!generatedNumbers.add(nextNumber)) {
14
+ nextNumber = secureRandom.nextInt((max - min) + 1) + min
15
+ }
16
+ return nextNumber
17
+ }
18
+ }
@@ -9,6 +9,7 @@ import android.util.Base64
9
9
  import android.util.Log
10
10
  import com.facebook.react.bridge.ReactContext
11
11
  import java.io.ByteArrayOutputStream
12
+ import androidx.core.graphics.createBitmap
12
13
 
13
14
 
14
15
  internal object Utils {
@@ -43,11 +44,7 @@ internal object Utils {
43
44
  }
44
45
 
45
46
  if (drawable.intrinsicWidth > 0 && drawable.intrinsicHeight > 0) {
46
- val bitmap = Bitmap.createBitmap(
47
- drawable.intrinsicWidth,
48
- drawable.intrinsicHeight,
49
- Bitmap.Config.ARGB_8888
50
- )
47
+ val bitmap = createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight)
51
48
  val canvas = Canvas(bitmap)
52
49
  drawable.setBounds(0, 0, canvas.width, canvas.height)
53
50
  drawable.draw(canvas)
@@ -1,9 +1,16 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
2
 
3
3
  <uses-permission android:name="android.permission.INTERNET" />
4
+
5
+ <!-- These permissions are needed if want to detect screen capturing and recording. -->
4
6
  <uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" />
5
7
  <uses-permission android:name="android.permission.DETECT_SCREEN_RECORDING" />
6
8
 
9
+ <!-- These permissions are needed if want to detect location spoofing and unsecure wifi. -->
10
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
11
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
12
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
13
+
7
14
  <application
8
15
  android:name=".MainApplication"
9
16
  android:label="@string/app_name"