freerasp-react-native 4.2.3 → 4.3.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 (194) hide show
  1. package/6.13.0/dSYMs/iphoneos/TalsecRuntime.framework.dSYM/Contents/Info.plist +20 -0
  2. package/6.13.0/dSYMs/iphoneos/TalsecRuntime.framework.dSYM/Contents/Resources/DWARF/TalsecRuntime +0 -0
  3. package/6.13.0/dSYMs/iphoneos/TalsecRuntime.framework.dSYM/Contents/Resources/Relocations/aarch64/TalsecRuntime.yml +4153 -0
  4. package/6.13.0/dSYMs/iphonesimulator/TalsecRuntime.framework.dSYM/Contents/Info.plist +20 -0
  5. package/6.13.0/dSYMs/iphonesimulator/TalsecRuntime.framework.dSYM/Contents/Resources/DWARF/TalsecRuntime +0 -0
  6. package/6.13.0/dSYMs/iphonesimulator/TalsecRuntime.framework.dSYM/Contents/Resources/Relocations/aarch64/TalsecRuntime.yml +4036 -0
  7. package/6.13.0/dSYMs/iphonesimulator/TalsecRuntime.framework.dSYM/Contents/Resources/Relocations/x86_64/TalsecRuntime.yml +3951 -0
  8. package/CHANGELOG.md +69 -4
  9. package/android/build.gradle +1 -1
  10. package/android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt +45 -22
  11. package/android/src/main/java/com/freeraspreactnative/FreeraspThreatHandler.kt +39 -19
  12. package/android/src/main/java/com/freeraspreactnative/events/BaseRaspEvent.kt +7 -0
  13. package/android/src/main/java/com/freeraspreactnative/events/RaspExecutionStateEvent.kt +20 -0
  14. package/android/src/main/java/com/freeraspreactnative/events/ThreatEvent.kt +67 -0
  15. package/android/src/main/java/com/freeraspreactnative/models/RNSuspiciousAppInfo.kt +1 -0
  16. package/android/src/main/java/com/freeraspreactnative/utils/Extensions.kt +1 -0
  17. package/android/src/main/java/com/freeraspreactnative/utils/RandomGenerator.kt +18 -0
  18. package/android/src/main/java/com/freeraspreactnative/utils/Utils.kt +2 -5
  19. package/example/android/app/release/app-release.apk +0 -0
  20. package/example/android/app/release/baselineProfiles/0/app-release.dm +0 -0
  21. package/example/android/app/release/baselineProfiles/1/app-release.dm +0 -0
  22. package/example/android/app/release/output-metadata.json +37 -0
  23. package/example/android/app/src/main/AndroidManifest.xml +7 -0
  24. package/example/src/App.tsx +77 -3
  25. package/example/src/DemoApp.tsx +46 -1
  26. package/example/src/MalwareItem.tsx +4 -0
  27. package/example/src/checks.ts +3 -0
  28. package/example/src/styles.ts +2 -0
  29. package/freerasp-react-native.podspec +21 -16
  30. package/ios/FreeraspReactNative.m +4 -0
  31. package/ios/FreeraspReactNative.swift +37 -75
  32. package/ios/TalsecRuntime.xcframework/Info.plist +5 -5
  33. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeDirectory +0 -0
  34. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
  35. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeResources +144 -114
  36. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeSignature +0 -0
  37. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  38. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +1 -1
  39. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +380 -281
  40. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curlver.h +5 -6
  41. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/easy.h +4 -4
  42. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/header.h +1 -1
  43. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/mprintf.h +11 -4
  44. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +62 -22
  45. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +2 -2
  46. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/system.h +76 -164
  47. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
  48. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +5 -4
  49. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/websockets.h +17 -3
  50. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
  51. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +181 -146
  52. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +3 -0
  53. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +3 -0
  54. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
  55. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  56. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +2 -2
  57. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +380 -281
  58. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curlver.h +5 -6
  59. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/easy.h +4 -4
  60. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/header.h +1 -1
  61. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/mprintf.h +11 -4
  62. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +62 -22
  63. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +2 -2
  64. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/system.h +76 -164
  65. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
  66. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +5 -4
  67. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/websockets.h +17 -3
  68. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
  69. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +181 -146
  70. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3 -0
  71. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3 -0
  72. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +181 -146
  73. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +3 -0
  74. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +3 -0
  75. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
  76. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +52 -41
  77. package/ios/models/RaspExecutionStates.swift +15 -0
  78. package/ios/models/SecurityThreat.swift +40 -0
  79. package/ios/utils/EventIdentifiers.swift +13 -0
  80. package/ios/utils/RandomGenerator.swift +12 -0
  81. package/ios/utils/Utils.swift +34 -0
  82. package/lib/commonjs/api/listeners/raspExecutionState.js +40 -0
  83. package/lib/commonjs/api/listeners/raspExecutionState.js.map +1 -0
  84. package/lib/commonjs/api/listeners/threat.js +102 -0
  85. package/lib/commonjs/api/listeners/threat.js.map +1 -0
  86. package/lib/commonjs/api/methods/native.js +43 -0
  87. package/lib/commonjs/api/methods/native.js.map +1 -0
  88. package/lib/commonjs/api/methods/reactNative.js +35 -0
  89. package/lib/commonjs/api/methods/reactNative.js.map +1 -0
  90. package/lib/commonjs/api/nativeModules.js +12 -0
  91. package/lib/commonjs/api/nativeModules.js.map +1 -0
  92. package/lib/commonjs/channels/raspExecutionState.js +36 -0
  93. package/lib/commonjs/channels/raspExecutionState.js.map +1 -0
  94. package/lib/commonjs/channels/threat.js +37 -0
  95. package/lib/commonjs/channels/threat.js.map +1 -0
  96. package/lib/commonjs/index.js +39 -188
  97. package/lib/commonjs/index.js.map +1 -1
  98. package/lib/commonjs/internal.js +6 -0
  99. package/lib/commonjs/internal.js.map +1 -0
  100. package/lib/commonjs/models/raspExecutionState.js +17 -0
  101. package/lib/commonjs/models/raspExecutionState.js.map +1 -0
  102. package/lib/commonjs/{threat.js → models/threat.js} +4 -1
  103. package/lib/commonjs/models/threat.js.map +1 -0
  104. package/lib/commonjs/types/types.js.map +1 -0
  105. package/lib/commonjs/utils/malware.js +28 -0
  106. package/lib/commonjs/utils/malware.js.map +1 -0
  107. package/lib/commonjs/utils/utils.js +21 -0
  108. package/lib/commonjs/utils/utils.js.map +1 -0
  109. package/lib/module/api/listeners/raspExecutionState.js +32 -0
  110. package/lib/module/api/listeners/raspExecutionState.js.map +1 -0
  111. package/lib/module/api/listeners/threat.js +94 -0
  112. package/lib/module/api/listeners/threat.js.map +1 -0
  113. package/lib/module/api/methods/native.js +30 -0
  114. package/lib/module/api/methods/native.js.map +1 -0
  115. package/lib/module/api/methods/reactNative.js +28 -0
  116. package/lib/module/api/methods/reactNative.js.map +1 -0
  117. package/lib/module/api/nativeModules.js +5 -0
  118. package/lib/module/api/nativeModules.js.map +1 -0
  119. package/lib/module/channels/raspExecutionState.js +27 -0
  120. package/lib/module/channels/raspExecutionState.js.map +1 -0
  121. package/lib/module/channels/threat.js +28 -0
  122. package/lib/module/channels/threat.js.map +1 -0
  123. package/lib/module/index.js +5 -172
  124. package/lib/module/index.js.map +1 -1
  125. package/lib/module/internal.js +3 -0
  126. package/lib/module/internal.js.map +1 -0
  127. package/lib/module/models/raspExecutionState.js +10 -0
  128. package/lib/module/models/raspExecutionState.js.map +1 -0
  129. package/lib/module/{threat.js → models/threat.js} +4 -1
  130. package/lib/module/models/threat.js.map +1 -0
  131. package/lib/module/types/types.js.map +1 -0
  132. package/lib/module/utils/malware.js +20 -0
  133. package/lib/module/utils/malware.js.map +1 -0
  134. package/lib/module/utils/utils.js +12 -0
  135. package/lib/module/utils/utils.js.map +1 -0
  136. package/lib/typescript/src/api/listeners/raspExecutionState.d.ts +4 -0
  137. package/lib/typescript/src/api/listeners/raspExecutionState.d.ts.map +1 -0
  138. package/lib/typescript/src/api/listeners/threat.d.ts +4 -0
  139. package/lib/typescript/src/api/listeners/threat.d.ts.map +1 -0
  140. package/lib/typescript/src/api/methods/native.d.ts +9 -0
  141. package/lib/typescript/src/api/methods/native.d.ts.map +1 -0
  142. package/lib/typescript/src/api/methods/reactNative.d.ts +3 -0
  143. package/lib/typescript/src/api/methods/reactNative.d.ts.map +1 -0
  144. package/lib/typescript/src/api/nativeModules.d.ts +2 -0
  145. package/lib/typescript/src/api/nativeModules.d.ts.map +1 -0
  146. package/lib/typescript/src/channels/raspExecutionState.d.ts +7 -0
  147. package/lib/typescript/src/channels/raspExecutionState.d.ts.map +1 -0
  148. package/lib/typescript/src/channels/threat.d.ts +8 -0
  149. package/lib/typescript/src/channels/threat.d.ts.map +1 -0
  150. package/lib/typescript/src/index.d.ts +5 -13
  151. package/lib/typescript/src/index.d.ts.map +1 -1
  152. package/lib/typescript/src/internal.d.ts +2 -0
  153. package/lib/typescript/src/internal.d.ts.map +1 -0
  154. package/lib/typescript/src/models/raspExecutionState.d.ts +7 -0
  155. package/lib/typescript/src/models/raspExecutionState.d.ts.map +1 -0
  156. package/lib/typescript/src/{threat.d.ts → models/threat.d.ts} +3 -0
  157. package/lib/typescript/src/models/threat.d.ts.map +1 -0
  158. package/lib/typescript/src/{types.d.ts → types/types.d.ts} +12 -1
  159. package/lib/typescript/src/types/types.d.ts.map +1 -0
  160. package/lib/typescript/src/utils/malware.d.ts +4 -0
  161. package/lib/typescript/src/utils/malware.d.ts.map +1 -0
  162. package/lib/typescript/src/{utils.d.ts → utils/utils.d.ts} +1 -0
  163. package/lib/typescript/src/utils/utils.d.ts.map +1 -0
  164. package/package.json +1 -1
  165. package/plugin/build/index.d.ts +0 -1
  166. package/src/api/listeners/raspExecutionState.ts +42 -0
  167. package/src/api/listeners/threat.ts +101 -0
  168. package/src/api/methods/native.ts +39 -0
  169. package/src/api/methods/reactNative.ts +42 -0
  170. package/src/api/nativeModules.ts +3 -0
  171. package/src/channels/raspExecutionState.ts +35 -0
  172. package/src/channels/threat.ts +35 -0
  173. package/src/index.tsx +5 -209
  174. package/src/internal.ts +2 -0
  175. package/src/models/raspExecutionState.ts +13 -0
  176. package/src/{threat.ts → models/threat.ts} +6 -0
  177. package/src/{types.ts → types/types.ts} +12 -1
  178. package/src/utils/malware.ts +24 -0
  179. package/src/utils/utils.ts +14 -0
  180. package/android/src/main/java/com/freeraspreactnative/Threat.kt +0 -57
  181. package/lib/commonjs/threat.js.map +0 -1
  182. package/lib/commonjs/types.js.map +0 -1
  183. package/lib/commonjs/utils.js +0 -16
  184. package/lib/commonjs/utils.js.map +0 -1
  185. package/lib/module/threat.js.map +0 -1
  186. package/lib/module/types.js.map +0 -1
  187. package/lib/module/utils.js +0 -8
  188. package/lib/module/utils.js.map +0 -1
  189. package/lib/typescript/src/threat.d.ts.map +0 -1
  190. package/lib/typescript/src/types.d.ts.map +0 -1
  191. package/lib/typescript/src/utils.d.ts.map +0 -1
  192. package/src/utils.ts +0 -9
  193. /package/lib/commonjs/{types.js → types/types.js} +0 -0
  194. /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.0] - 2025-10-31
9
+
10
+ - Android SDK version: 17.0.1
11
+ - iOS SDK version: 6.13.0
12
+
13
+ ### React Native
14
+
15
+ #### Added
16
+
17
+ - 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))
18
+ - Added API for `timeSpoofing` callback into `ThreatEventActions` (Android only)
19
+ - Added API for `unsecureWifi` callback into `ThreatEventActions` (Android only)
20
+ - Added API for `allChecksFinished` callback into new `RaspExecutionStateEventActions` object
21
+ - Added matched permissions to `SuspiciousAppInfo` object when malware detection reason is `suspiciousPermission`
22
+
23
+ #### Fixed
24
+
25
+ - Resolved potential collision in threat identifiers
26
+
27
+ ### Android
28
+
29
+ #### Added
30
+
31
+ - 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)
32
+ - We are introducing a new capability, detecting whether the device time has been tampered with (`timeSpoofing`)
33
+ - We are introducing a new capability, detecting whether the location is being spoofed on the device (`locationSpoofing`)
34
+ - We are introducing a new capability, detection of unsecure WiFi (`unecureWifi`)
35
+ - Removed deprecated functionality `Pbkdf2Native` and both related native libraries (`libpbkdf2_native.so` and `libpolarssl.so`)
36
+ - Added new `RaspExecutionState` which contains `onAllChecksFinished()` method, which is triggered after all checks are completed.
37
+ - Added matched permissions to `SuspiciousAppInfo` object when malware detection reason is `suspiciousPermission`
38
+ - 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)
39
+ - Capability to check if another app has an option `REQUEST_INSTALL_PACKAGES` enabled in the system settings to malware detection
40
+
41
+ #### Fixed
42
+
43
+ - ANR issue caused by `registerScreenCaptureCallback()` method on the main thread
44
+ - `NullPointerException` when checking key alias in Keystore on Android 7
45
+ - `JaCoCo` issue causing `MethodTooLargeException` during instrumentation
46
+ - `DeadApplicationException` when calling `Settings.Global.getInt` or `Settings.Secure.getInt` on invalid context
47
+ - `AndroidKeyStore` crashes causing `java.util.concurrent.TimeoutException` when calling `finalize()` method on `Cipher` (GC issues)
48
+ - Fixed issue with late initializers and `TalsecMode` coroutines scopes
49
+
50
+ #### Changed
51
+
52
+ - Shortened the value of threat detection interval
53
+ - Refactoring of internal architecture of SDK that newly uses Coroutines to manage threading
54
+ - Update of internal dependencies and security libraries
55
+
56
+ ### iOS
57
+
58
+ #### Changed
59
+
60
+ - Updated internal dependencies
61
+
62
+ ## [4.2.4] - 2025-09-17
63
+
64
+ - iOS SDK version: 6.12.1
65
+ - Android SDK version: 16.0.4
66
+
67
+ ### React Native
68
+
69
+ #### Fixed
70
+
71
+ - iOS dependencies are now installed via `install_modules_dependencies` by default
72
+
8
73
  ## [4.2.3] - 2025-09-03
9
74
 
10
75
  - iOS SDK version: 6.12.1
@@ -101,7 +166,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
101
166
  - Added interface for screenshot / screen recording blocking on iOS
102
167
  - Added interface for external ID storage
103
168
 
104
- ### Android
169
+ ### Android
105
170
 
106
171
  #### Added
107
172
 
@@ -137,7 +202,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
137
202
  - Android SDK requires `kotlinVersion` >= `2.0.0`
138
203
  - Set Java verison to 17
139
204
 
140
- ### Android
205
+ ### Android
141
206
 
142
207
  #### Changed
143
208
 
@@ -189,7 +254,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
189
254
 
190
255
  - Raised Android compileSDK level to 35
191
256
 
192
- #### Fixed
257
+ #### Fixed
193
258
 
194
259
  - Compatibility issues with RN New Architecture
195
260
  - Added proguard rules for malware data serialization in release mode on Android
@@ -267,7 +332,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
267
332
 
268
333
  #### Added
269
334
 
270
- - Added configuration fields for malware detection
335
+ - Added configuration fields for malware detection
271
336
 
272
337
  ### Android
273
338
 
@@ -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)
@@ -0,0 +1,37 @@
1
+ {
2
+ "version": 3,
3
+ "artifactType": {
4
+ "type": "APK",
5
+ "kind": "Directory"
6
+ },
7
+ "applicationId": "com.freerasp.rn.example",
8
+ "variantName": "release",
9
+ "elements": [
10
+ {
11
+ "type": "SINGLE",
12
+ "filters": [],
13
+ "attributes": [],
14
+ "versionCode": 1,
15
+ "versionName": "1.0",
16
+ "outputFile": "app-release.apk"
17
+ }
18
+ ],
19
+ "elementType": "File",
20
+ "baselineProfiles": [
21
+ {
22
+ "minApi": 28,
23
+ "maxApi": 30,
24
+ "baselineProfiles": [
25
+ "baselineProfiles/1/app-release.dm"
26
+ ]
27
+ },
28
+ {
29
+ "minApi": 31,
30
+ "maxApi": 2147483647,
31
+ "baselineProfiles": [
32
+ "baselineProfiles/0/app-release.dm"
33
+ ]
34
+ }
35
+ ],
36
+ "minSdkVersionForDexing": 24
37
+ }
@@ -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"