capacitor-freerasp 2.2.1 → 2.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 (119) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/CapacitorFreerasp.podspec +1 -1
  3. package/README.md +8 -8
  4. package/android/build.gradle +1 -1
  5. package/android/proguard-rules.pro +23 -0
  6. package/android/src/main/java/com/aheaditec/freerasp/FreeraspPlugin.kt +39 -18
  7. package/android/src/main/java/com/aheaditec/freerasp/ScreenProtector.kt +24 -2
  8. package/android/src/main/java/com/aheaditec/freerasp/ThreatHandler.kt +36 -18
  9. package/android/src/main/java/com/aheaditec/freerasp/events/BaseRaspEvent.kt +7 -0
  10. package/android/src/main/java/com/aheaditec/freerasp/events/RaspExecutionStateEvent.kt +22 -0
  11. package/android/src/main/java/com/aheaditec/freerasp/events/ThreatEvent.kt +69 -0
  12. package/android/src/main/java/com/aheaditec/freerasp/models/CapSuspiciousAppInfo.kt +1 -0
  13. package/android/src/main/java/com/aheaditec/freerasp/utils/Extensions.kt +1 -0
  14. package/android/src/main/java/com/aheaditec/freerasp/utils/RandomGenerator.kt +24 -0
  15. package/android/src/main/java/com/aheaditec/freerasp/utils/Utils.kt +3 -5
  16. package/dist/esm/api/listeners/raspExecutionState.d.ts +2 -0
  17. package/dist/esm/api/listeners/raspExecutionState.js +23 -0
  18. package/dist/esm/api/listeners/raspExecutionState.js.map +1 -0
  19. package/dist/esm/api/listeners/threat.d.ts +2 -0
  20. package/dist/esm/api/listeners/threat.js +84 -0
  21. package/dist/esm/api/listeners/threat.js.map +1 -0
  22. package/dist/esm/api/methods/capacitor.d.ts +4 -0
  23. package/dist/esm/api/methods/capacitor.js +11 -0
  24. package/dist/esm/api/methods/capacitor.js.map +1 -0
  25. package/dist/esm/api/methods/native.d.ts +6 -0
  26. package/dist/esm/api/methods/native.js +32 -0
  27. package/dist/esm/api/methods/native.js.map +1 -0
  28. package/dist/esm/api/nativeModules.d.ts +2 -0
  29. package/dist/esm/api/nativeModules.js +3 -0
  30. package/dist/esm/api/nativeModules.js.map +1 -0
  31. package/dist/esm/channels/raspExecutionState.d.ts +3 -0
  32. package/dist/esm/channels/raspExecutionState.js +27 -0
  33. package/dist/esm/channels/raspExecutionState.js.map +1 -0
  34. package/dist/esm/channels/threat.d.ts +3 -0
  35. package/dist/esm/channels/threat.js +34 -0
  36. package/dist/esm/channels/threat.js.map +1 -0
  37. package/dist/esm/index.d.ts +7 -12
  38. package/dist/esm/index.js +7 -158
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/models/raspExecutionState.d.ts +6 -0
  41. package/dist/esm/models/raspExecutionState.js +10 -0
  42. package/dist/esm/models/raspExecutionState.js.map +1 -0
  43. package/dist/esm/models/threat.d.ts +26 -0
  44. package/dist/esm/{definitions.js → models/threat.js} +7 -3
  45. package/dist/esm/models/threat.js.map +1 -0
  46. package/dist/esm/{definitions.d.ts → types/types.d.ts} +37 -44
  47. package/dist/esm/types/types.js +2 -0
  48. package/dist/esm/types/types.js.map +1 -0
  49. package/dist/esm/utils/malware.d.ts +3 -0
  50. package/dist/esm/utils/malware.js +22 -0
  51. package/dist/esm/utils/malware.js.map +1 -0
  52. package/dist/esm/utils/utils.d.ts +3 -0
  53. package/dist/esm/utils/utils.js +12 -0
  54. package/dist/esm/utils/utils.js.map +1 -0
  55. package/dist/plugin.cjs.js +153 -78
  56. package/dist/plugin.cjs.js.map +1 -1
  57. package/dist/plugin.js +153 -78
  58. package/dist/plugin.js.map +1 -1
  59. package/ios/Plugin/FreeraspPlugin.m +2 -0
  60. package/ios/Plugin/FreeraspPlugin.swift +50 -75
  61. package/ios/Plugin/Info.plist +1 -1
  62. package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeDirectory +0 -0
  63. package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeResources +100 -298
  64. package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeSignature +0 -0
  65. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  66. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +7 -2
  67. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +380 -281
  68. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curlver.h +5 -6
  69. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/easy.h +4 -4
  70. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/header.h +1 -1
  71. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/mprintf.h +11 -4
  72. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +62 -22
  73. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +2 -2
  74. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/system.h +76 -164
  75. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
  76. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +5 -4
  77. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/websockets.h +17 -3
  78. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
  79. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +233 -528
  80. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +7 -3
  81. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  82. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +7 -3
  83. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
  84. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  85. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +14 -4
  86. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +380 -281
  87. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curlver.h +5 -6
  88. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/easy.h +4 -4
  89. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/header.h +1 -1
  90. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/mprintf.h +11 -4
  91. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +62 -22
  92. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +2 -2
  93. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/system.h +76 -164
  94. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
  95. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +5 -4
  96. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/websockets.h +17 -3
  97. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
  98. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +233 -528
  99. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +7 -3
  100. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  101. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -3
  102. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +233 -528
  103. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +7 -3
  104. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  105. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +7 -3
  106. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
  107. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +56 -45
  108. package/ios/Plugin/models/RaspExecutionStates.swift +15 -0
  109. package/ios/Plugin/models/SecurityThreat.swift +40 -0
  110. package/ios/Plugin/utils/EventIdentifiers.swift +17 -0
  111. package/ios/Plugin/utils/RandomGenerator.swift +23 -0
  112. package/ios/Plugin/utils/Utils.swift +32 -0
  113. package/package.json +15 -10
  114. package/android/src/main/java/com/aheaditec/freerasp/Threat.kt +0 -58
  115. package/dist/esm/definitions.js.map +0 -1
  116. package/dist/esm/utils.d.ts +0 -2
  117. package/dist/esm/utils.js +0 -8
  118. package/dist/esm/utils.js.map +0 -1
  119. package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
package/CHANGELOG.md CHANGED
@@ -5,8 +5,79 @@ 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
+ ## [2.3.0] - 2025-12-15
9
+
10
+ - Android SDK version: 17.0.1
11
+ - iOS SDK version: 6.13.0
12
+
13
+ ### Capacitor
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
+ - Root detection related bugs causing false positives
44
+ - ANR issue caused by `registerScreenCaptureCallback()` method on the main thread
45
+ - `NullPointerException` when checking key alias in Keystore on Android 7
46
+ - `JaCoCo` issue causing `MethodTooLargeException` during instrumentation
47
+ - `DeadApplicationException` when calling `Settings.Global.getInt` or `Settings.Secure.getInt` on invalid context
48
+ - `AndroidKeyStore` crashes causing `java.util.concurrent.TimeoutException` when calling `finalize()` method on `Cipher` (GC issues)
49
+ - Fixed issue with late initializers and `TalsecMode` coroutines scopes
50
+
51
+
52
+ #### Changed
53
+
54
+ - Deprecated Nexus repository removed (GCP artifact registry is the main supported distribution repository)
55
+ - Shortened the value of threat detection interval
56
+ - Refactoring of internal architecture of SDK that newly uses Coroutines to manage threading
57
+ - Update of internal dependencies and security libraries
58
+
59
+ ### iOS
60
+
61
+ #### Changed
62
+
63
+ - Updated internal dependencies
64
+
65
+ ## [2.2.2] - 2025-08-12
66
+
67
+ - iOS SDK version: 6.12.1
68
+ - Android SDK version: 16.0.2
69
+
70
+ ### Capacitor
71
+
72
+ #### Fixed
73
+
74
+ - Added missing `proguard-rules.pro` into package on npmjs
75
+
8
76
  ## [2.2.1] - 2025-08-05
9
77
 
78
+ - iOS SDK version: 6.12.1
79
+ - Android SDK version: 16.0.2
80
+
10
81
  ### Android
11
82
 
12
83
  #### Fixed
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
10
10
  s.homepage = package['repository']['url']
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Plugin/*.{swift,h,m,c,cc,mm,cpp}', 'ios/Plugin/TalsecRuntime.xcframework'
13
+ s.source_files = 'ios/Plugin/models/*.{swift,h,m,c,cc,mm,cpp}', 'ios/Plugin/utils/*.{swift,h,m,c,cc,mm,cpp}', 'ios/Plugin/*.{swift,h,m,c,cc,mm,cpp}', 'ios/Plugin/TalsecRuntime.xcframework'
14
14
  s.ios.deployment_target = '13.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.swift_version = '5.1'
package/README.md CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  # freeRASP for Capacitor
8
8
 
9
- freeRASP for Capacitor is a mobile in-app protection and security monitoring plugin. It aims to cover the main aspects of RASP (Runtime App Self Protection) and application shielding.
9
+ freeRASP for Capacitor is a mobile in-app threat detection and security monitoring plugin. It aims to cover the main aspects of RASP (Runtime App Self Protection) and application shielding.
10
10
 
11
- :loudspeaker: [The official documentation has been moved to a new location. You can now find it here](https://docs.talsec.app/docs-and-articles-portal). :loudspeaker:
11
+ :loudspeaker: [The official documentation has been moved to a new location. You can now find it here](https://docs.talsec.app/docs-and-articles-portal?utm_source=github). :loudspeaker:
12
12
 
13
13
  # Overview
14
14
 
@@ -28,7 +28,7 @@ Key features are the detection and prevention of
28
28
  - Untrusted installation method
29
29
  - App/Device (un)binding
30
30
 
31
- Additional freeRASP features include low latency, easy integration and a weekly [Security Report](https://docs.talsec.app/freerasp/security-report) containing detailed information about detected incidents and potential threats, summarizing the state of your app security.
31
+ Additional freeRASP features include low latency, easy integration and a weekly [Security Report](https://docs.talsec.app/freerasp/security-report?utm_source=github) containing detailed information about detected incidents and potential threats, summarizing the state of your app security.
32
32
 
33
33
  The commercial version provides a top-notch protection level, extra features, support and maintenance. One of the most valued commercial features is AppiCrypt® - App Integrity Cryptogram.
34
34
 
@@ -41,7 +41,7 @@ It allows easy to implement API protection and App Integrity verification on the
41
41
 
42
42
  It is a unified solution that works across all mobile platforms without dependency on external web services (i.e., without extra latency, an additional point of failure, and maintenance costs).
43
43
 
44
- Learn more about commercial features at [https://talsec.app](https://talsec.app).
44
+ Learn more about commercial features at [https://talsec.app](https://talsec.app?utm_source=github).
45
45
 
46
46
  Learn more about freemium freeRASP features at [GitHub main repository](https://github.com/talsec/Free-RASP-Community).
47
47
 
@@ -54,17 +54,17 @@ After the integration of freeRASP, make sure you visit the [freeMalwareDetection
54
54
 
55
55
  Visit the [GitBook page](https://docs.talsec.app/freerasp) for comprehensive and up-to-date guides, tutorials, and technical documentation specifically for freeRASP. It serves as your go-to resource, offering everything from basic instructions to advanced tips and tricks to help you get the most out of the project.
56
56
 
57
- :loudspeaker: [The official documentation has been moved to a new location. You can now find it here](https://docs.talsec.app/docs-and-articles-portal). :loudspeaker:
57
+ :loudspeaker: [The official documentation has been moved to a new location. You can now find it here](https://docs.talsec.app/docs-and-articles-portal?utm_source=github). :loudspeaker:
58
58
 
59
59
  ## :link: Integration Guide
60
60
 
61
- For integrating freeRASP on the Capacitor platform, be sure to follow all the steps in the [Integration Guide](https://docs.talsec.app/freerasp/integration). This guide provides detailed instructions to help you achieve a smooth and efficient integration.
61
+ For integrating freeRASP on the Capacitor platform, be sure to follow all the steps in the [Integration Guide](https://docs.talsec.app/freerasp/integration?utm_source=github). This guide provides detailed instructions to help you achieve a smooth and efficient integration.
62
62
 
63
63
  Be sure to bookmark it and stay informed! :books: :sparkles:.
64
64
 
65
65
  # :rocket: What's New and Changelog
66
66
 
67
- Stay informed and make the most of freeRASP by checking out [What's New and Changelog](https://docs.talsec.app/freerasp/whats-new-and-changelog)! Here, you’ll discover the latest features, enhancements, and bug fixes we’ve implemented to improve your experience across all platforms, including Android, iOS, Flutter, React Native, Capacitor, and Cordova.
67
+ Stay informed and make the most of freeRASP by checking out [What's New and Changelog](https://docs.talsec.app/freerasp/whats-new-and-changelog?utm_source=github)! Here, you’ll discover the latest features, enhancements, and bug fixes we’ve implemented to improve your experience across all platforms, including Android, iOS, Flutter, React Native, Capacitor, and Cordova.
68
68
 
69
69
  Don’t miss out on any updates and explore the changelog to see how we’re continually making freeRASP better for you!
70
70
 
@@ -76,4 +76,4 @@ You can check out the project board [here](https://github.com/orgs/talsec/projec
76
76
 
77
77
  # :page_facing_up: License
78
78
 
79
- This project is provided as freemium software, i.e. there is a [fair usage policy](https://docs.talsec.app/freerasp/features-and-pricing-plans#plans-comparison) that imposes some limitations on the free usage. The SDK software consists of open-source and binary parts, which is the property of Talsec. The open-source part is licensed under the MIT License - see the LICENSE file for details.
79
+ This project is provided as freemium software, i.e. there is a [fair usage policy](https://docs.talsec.app/freerasp/features-and-pricing-plans#plans-comparison?utm_source=github) that imposes some limitations on the free usage. The SDK software consists of open-source and binary parts, which is the property of Talsec. The open-source part is licensed under the MIT License - see the LICENSE file for details.
@@ -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:16.0.2'
79
+ implementation 'com.aheaditec.talsec.security:TalsecSecurity-Community-Capacitor:17.0.1'
80
80
  }
@@ -0,0 +1,23 @@
1
+ # Add project specific ProGuard rules here.
2
+ # You can control the set of applied configuration files using the
3
+ # proguardFiles setting in build.gradle.
4
+ #
5
+ # For more details, see
6
+ # http://developer.android.com/guide/developing/tools/proguard.html
7
+
8
+ # If your project uses WebView with JS, uncomment the following
9
+ # and specify the fully qualified class name to the JavaScript interface
10
+ # class:
11
+ #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12
+ # public *;
13
+ #}
14
+
15
+ # Uncomment this to preserve the line number information for
16
+ # debugging stack traces.
17
+ #-keepattributes SourceFile,LineNumberTable
18
+
19
+ # If you keep the line number information, uncomment this to
20
+ # hide the original source file name.
21
+ #-renamesourcefileattribute SourceFile
22
+
23
+ -dontwarn java.lang.invoke.StringConcatFactory
@@ -12,6 +12,9 @@ import com.aheaditec.talsec_security.security.api.SuspiciousAppInfo
12
12
  import com.aheaditec.talsec_security.security.api.Talsec
13
13
  import com.aheaditec.talsec_security.security.api.TalsecConfig
14
14
  import com.aheaditec.talsec_security.security.api.ThreatListener
15
+ import com.aheaditec.freerasp.events.BaseRaspEvent
16
+ import com.aheaditec.freerasp.events.RaspExecutionStateEvent
17
+ import com.aheaditec.freerasp.events.ThreatEvent
15
18
  import com.getcapacitor.JSObject
16
19
  import com.getcapacitor.Plugin
17
20
  import com.getcapacitor.PluginCall
@@ -23,7 +26,7 @@ import org.json.JSONArray
23
26
  class FreeraspPlugin : Plugin() {
24
27
 
25
28
  private val threatHandler = TalsecThreatHandler(this)
26
- private val listener = ThreatListener(threatHandler, threatHandler)
29
+ private val listener = ThreatListener(threatHandler, threatHandler, threatHandler)
27
30
  private var registered = true
28
31
 
29
32
  @PluginMethod
@@ -97,29 +100,51 @@ class FreeraspPlugin : Plugin() {
97
100
  */
98
101
  @PluginMethod
99
102
  fun getThreatIdentifiers(call: PluginCall) {
100
- call.resolve(JSObject().put("ids", Threat.getThreatValues()))
103
+ call.resolve(JSObject().put("ids", ThreatEvent.ALL_EVENTS))
101
104
  }
102
105
 
103
106
  /**
104
- * Method to setup the message passing between native and React Native
105
- * @return list of [THREAT_CHANNEL_NAME, THREAT_CHANNEL_KEY]
107
+ * Method to get the random identifiers of callbacks
108
+ */
109
+ @PluginMethod
110
+ fun getRaspExecutionStateIdentifiers(call: PluginCall) {
111
+ call.resolve(JSObject().put("ids", RaspExecutionStateEvent.ALL_EVENTS))
112
+ }
113
+
114
+ /**
115
+ * Method to setup the message passing between native and Capacitor
116
+ * @return list of [CHANNEL_NAME, CHANNEL_KEY, MALWARE_CHANNEL_KEY]
106
117
  */
107
118
  @PluginMethod
108
119
  fun getThreatChannelData(call: PluginCall) {
109
120
  val channelData = JSONArray(
110
121
  (listOf(
111
- THREAT_CHANNEL_NAME, THREAT_CHANNEL_KEY, MALWARE_CHANNEL_KEY
122
+ ThreatEvent.CHANNEL_NAME, ThreatEvent.CHANNEL_KEY, ThreatEvent.MALWARE_CHANNEL_KEY
112
123
  ))
113
124
  )
114
125
  call.resolve(JSObject().put("ids", channelData))
115
126
  }
116
127
 
128
+ /**
129
+ * Method to setup the execution state message passing between native and Capacitor
130
+ * @return list of [CHANNEL_NAME, CHANNEL_KEY]
131
+ */
132
+ @PluginMethod
133
+ fun getRaspExecutionStateChannelData(call: PluginCall) {
134
+ val channelData = JSONArray(
135
+ (listOf(
136
+ RaspExecutionStateEvent.CHANNEL_NAME, RaspExecutionStateEvent.CHANNEL_KEY
137
+ ))
138
+ )
139
+ call.resolve(JSObject().put("ids", channelData))
140
+ }
141
+
117
142
  /**
118
143
  * We never send an invalid callback over our channel.
119
144
  * Therefore, if this happens, we want to kill the app.
120
145
  */
121
146
  @PluginMethod
122
- fun onInvalidCallback() {
147
+ fun onInvalidCallback(call: PluginCall) {
123
148
  android.os.Process.killProcess(android.os.Process.myPid())
124
149
  }
125
150
 
@@ -179,7 +204,7 @@ class FreeraspPlugin : Plugin() {
179
204
 
180
205
  activity?.runOnUiThread {
181
206
  try {
182
- Talsec.blockScreenCapture(context, enable)
207
+ Talsec.blockScreenCapture(activity, enable)
183
208
  call.resolve(JSObject().put("result", true))
184
209
  } catch (e: Exception) {
185
210
  call.reject(
@@ -224,11 +249,12 @@ class FreeraspPlugin : Plugin() {
224
249
  "Error during storeExternalId operation in freeRASP Native Plugin",
225
250
  "NativePluginError"
226
251
  )
252
+ return
227
253
  }
228
254
  }
229
255
 
230
- internal fun notifyListeners(threat: Threat) {
231
- notifyListeners(THREAT_CHANNEL_NAME, JSObject().put(THREAT_CHANNEL_KEY, threat.value), true)
256
+ internal fun notifyListeners(event: BaseRaspEvent) {
257
+ notifyListeners(event.channelName, JSObject().put(event.channelKey, event.value), true)
232
258
  }
233
259
 
234
260
  internal fun notifyMalware(suspiciousApps: MutableList<SuspiciousAppInfo>) {
@@ -238,9 +264,9 @@ class FreeraspPlugin : Plugin() {
238
264
  val encodedSuspiciousApps = suspiciousApps.toEncodedJSArray(context)
239
265
  mainHandler.post {
240
266
  val params = JSObject()
241
- .put(THREAT_CHANNEL_KEY, Threat.Malware.value)
242
- .put(MALWARE_CHANNEL_KEY, encodedSuspiciousApps)
243
- notifyListeners(THREAT_CHANNEL_NAME, params, true)
267
+ .put(ThreatEvent.CHANNEL_KEY, ThreatEvent.Malware.value)
268
+ .put(ThreatEvent.MALWARE_CHANNEL_KEY, encodedSuspiciousApps)
269
+ notifyListeners(ThreatEvent.CHANNEL_NAME, params, true)
244
270
  }
245
271
  }
246
272
  }
@@ -253,6 +279,7 @@ class FreeraspPlugin : Plugin() {
253
279
  .watcherMail(configJson.getString("watcherMail"))
254
280
  .supportedAlternativeStores(androidConfig.getArraySafe("supportedAlternativeStores"))
255
281
  .prod(configJson.getBool("isProd") ?: true)
282
+ .killOnBypass(configJson.getBool("killOnBypass") ?: false)
256
283
 
257
284
  if (androidConfig.has("malwareConfig")) {
258
285
  val malwareConfig = androidConfig.getJSONObject("malwareConfig")
@@ -266,12 +293,6 @@ class FreeraspPlugin : Plugin() {
266
293
 
267
294
 
268
295
  companion object {
269
- private val THREAT_CHANNEL_NAME = (10000..999999999).random()
270
- .toString() // name of the channel over which threat callbacks are sent
271
- private val THREAT_CHANNEL_KEY = (10000..999999999).random()
272
- .toString() // key of the argument map under which threats are expected
273
- private val MALWARE_CHANNEL_KEY = (10000..999999999).random()
274
- .toString() // key of the argument map under which malware data is expected
275
296
  private val backgroundHandlerThread = HandlerThread("BackgroundThread").apply { start() }
276
297
  private val backgroundHandler = Handler(backgroundHandlerThread.looper)
277
298
  private val mainHandler = Handler(Looper.getMainLooper())
@@ -11,6 +11,7 @@ import android.view.WindowManager.SCREEN_RECORDING_STATE_VISIBLE
11
11
  import androidx.annotation.RequiresApi
12
12
  import androidx.core.content.ContextCompat
13
13
  import com.aheaditec.talsec_security.security.api.Talsec
14
+ import com.aheaditec.freerasp.events.ThreatEvent
14
15
  import java.util.function.Consumer
15
16
 
16
17
  @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@@ -18,14 +19,35 @@ internal object ScreenProtector {
18
19
  private const val TAG = "TalsecScreenProtector"
19
20
  private const val SCREEN_CAPTURE_PERMISSION = "android.permission.DETECT_SCREEN_CAPTURE"
20
21
  private const val SCREEN_RECORDING_PERMISSION = "android.permission.DETECT_SCREEN_RECORDING"
22
+
21
23
  private var registered = false
22
- private val screenCaptureCallback = ScreenCaptureCallback { Talsec.onScreenshotDetected() }
24
+ private val cachedThreats = mutableSetOf<ThreatEvent>()
25
+
26
+ private val screenCaptureCallback = ScreenCaptureCallback { handleThreat(ThreatEvent.Screenshot) }
23
27
  private val screenRecordCallback: Consumer<Int> = Consumer<Int> { state ->
24
28
  if (state == SCREEN_RECORDING_STATE_VISIBLE) {
25
- Talsec.onScreenRecordingDetected()
29
+ handleThreat(ThreatEvent.ScreenRecording)
30
+ }
31
+ }
32
+
33
+ private fun handleThreat(threat: ThreatEvent) {
34
+ if(!FreeraspPlugin.talsecStarted) {
35
+ cachedThreats.add(threat)
36
+ return
37
+ }
38
+
39
+ when (threat) {
40
+ ThreatEvent.Screenshot -> Talsec.onScreenshotDetected()
41
+ ThreatEvent.ScreenRecording -> Talsec.onScreenRecordingDetected()
42
+ else -> throw IllegalArgumentException("Unexpected Threat type: $threat")
26
43
  }
27
44
  }
28
45
 
46
+ internal fun flushCache() {
47
+ cachedThreats.forEach { handleThreat(it) }
48
+ cachedThreats.clear()
49
+ }
50
+
29
51
  /**
30
52
  * Registers screenshot and screen recording detector with the given activity
31
53
  *
@@ -2,75 +2,93 @@ package com.aheaditec.freerasp
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.aheaditec.freerasp.events.RaspExecutionStateEvent
6
+ import com.aheaditec.freerasp.events.ThreatEvent
5
7
 
6
8
  internal class TalsecThreatHandler(private val instance: FreeraspPlugin) :
7
- ThreatListener.ThreatDetected, ThreatListener.DeviceState {
9
+ ThreatListener.ThreatDetected, ThreatListener.DeviceState, ThreatListener.RaspExecutionState() {
8
10
 
9
11
  override fun onRootDetected() {
10
- instance.notifyListeners(Threat.PrivilegedAccess)
12
+ instance.notifyListeners(ThreatEvent.PrivilegedAccess)
11
13
  }
12
14
 
13
15
  override fun onDebuggerDetected() {
14
- instance.notifyListeners(Threat.Debug)
16
+ instance.notifyListeners(ThreatEvent.Debug)
15
17
  }
16
18
 
17
19
  override fun onEmulatorDetected() {
18
- instance.notifyListeners(Threat.Simulator)
20
+ instance.notifyListeners(ThreatEvent.Simulator)
19
21
  }
20
22
 
21
23
  override fun onTamperDetected() {
22
- instance.notifyListeners(Threat.AppIntegrity)
24
+ instance.notifyListeners(ThreatEvent.AppIntegrity)
23
25
  }
24
26
 
25
27
  override fun onUntrustedInstallationSourceDetected() {
26
- instance.notifyListeners(Threat.UnofficialStore)
28
+ instance.notifyListeners(ThreatEvent.UnofficialStore)
27
29
  }
28
30
 
29
31
  override fun onHookDetected() {
30
- instance.notifyListeners(Threat.Hooks)
32
+ instance.notifyListeners(ThreatEvent.Hooks)
31
33
  }
32
34
 
33
35
  override fun onDeviceBindingDetected() {
34
- instance.notifyListeners(Threat.DeviceBinding)
36
+ instance.notifyListeners(ThreatEvent.DeviceBinding)
35
37
  }
36
38
 
37
39
  override fun onObfuscationIssuesDetected() {
38
- instance.notifyListeners(Threat.ObfuscationIssues)
40
+ instance.notifyListeners(ThreatEvent.ObfuscationIssues)
39
41
  }
40
42
 
41
- override fun onMalwareDetected(suspiciousAppInfos: MutableList<SuspiciousAppInfo>?) {
43
+ override fun onMalwareDetected(suspiciousAppInfos: MutableList<SuspiciousAppInfo>) {
42
44
  instance.notifyMalware(suspiciousAppInfos ?: mutableListOf())
43
45
  }
44
46
 
45
47
  override fun onUnlockedDeviceDetected() {
46
- instance.notifyListeners(Threat.Passcode)
48
+ instance.notifyListeners(ThreatEvent.Passcode)
47
49
  }
48
50
 
49
51
  override fun onHardwareBackedKeystoreNotAvailableDetected() {
50
- instance.notifyListeners(Threat.SecureHardwareNotAvailable)
52
+ instance.notifyListeners(ThreatEvent.SecureHardwareNotAvailable)
51
53
  }
52
54
 
53
55
  override fun onDeveloperModeDetected() {
54
- instance.notifyListeners(Threat.DevMode)
56
+ instance.notifyListeners(ThreatEvent.DevMode)
55
57
  }
56
58
 
57
59
  override fun onADBEnabledDetected() {
58
- instance.notifyListeners(Threat.ADBEnabled)
60
+ instance.notifyListeners(ThreatEvent.ADBEnabled)
59
61
  }
60
62
 
61
63
  override fun onSystemVPNDetected() {
62
- instance.notifyListeners(Threat.SystemVPN)
64
+ instance.notifyListeners(ThreatEvent.SystemVPN)
63
65
  }
64
66
 
65
67
  override fun onScreenshotDetected() {
66
- instance.notifyListeners(Threat.Screenshot)
68
+ instance.notifyListeners(ThreatEvent.Screenshot)
67
69
  }
68
70
 
69
71
  override fun onScreenRecordingDetected() {
70
- instance.notifyListeners(Threat.ScreenRecording)
72
+ instance.notifyListeners(ThreatEvent.ScreenRecording)
71
73
  }
72
74
 
73
75
  override fun onMultiInstanceDetected() {
74
- instance.notifyListeners(Threat.MultiInstance)
76
+ instance.notifyListeners(ThreatEvent.MultiInstance)
77
+ }
78
+
79
+ override fun onUnsecureWifiDetected() {
80
+ instance.notifyListeners(ThreatEvent.UnsecureWifi)
81
+ }
82
+
83
+ override fun onTimeSpoofingDetected() {
84
+ instance.notifyListeners(ThreatEvent.TimeSpoofing)
85
+ }
86
+
87
+ override fun onLocationSpoofingDetected() {
88
+ instance.notifyListeners(ThreatEvent.LocationSpoofing)
89
+ }
90
+
91
+ override fun onAllChecksFinished() {
92
+ instance.notifyListeners(RaspExecutionStateEvent.AllChecksFinished)
75
93
  }
76
94
  }
@@ -0,0 +1,7 @@
1
+ package com.aheaditec.freerasp.events
2
+
3
+ internal interface BaseRaspEvent {
4
+ val value: Int
5
+ val channelName: String
6
+ val channelKey: String
7
+ }
@@ -0,0 +1,22 @@
1
+ package com.aheaditec.freerasp.events
2
+
3
+ import com.aheaditec.freerasp.utils.RandomGenerator
4
+ import org.json.JSONArray
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
+ object AllChecksFinished : RaspExecutionStateEvent(RandomGenerator.next())
11
+
12
+ companion object {
13
+ internal val CHANNEL_NAME = RandomGenerator.next().toString()
14
+ internal val CHANNEL_KEY = RandomGenerator.next().toString()
15
+
16
+ internal val ALL_EVENTS = JSONArray(
17
+ listOf(
18
+ AllChecksFinished.value
19
+ )
20
+ )
21
+ }
22
+ }
@@ -0,0 +1,69 @@
1
+ package com.aheaditec.freerasp.events
2
+
3
+ import com.aheaditec.freerasp.utils.RandomGenerator
4
+ import org.json.JSONArray
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
+ object AppIntegrity : ThreatEvent(RandomGenerator.next())
18
+ object PrivilegedAccess : ThreatEvent(RandomGenerator.next())
19
+ object Debug : ThreatEvent(RandomGenerator.next())
20
+ object Hooks : ThreatEvent(RandomGenerator.next())
21
+ object Passcode : ThreatEvent(RandomGenerator.next())
22
+ object Simulator : ThreatEvent(RandomGenerator.next())
23
+ object SecureHardwareNotAvailable : ThreatEvent(RandomGenerator.next())
24
+ object DeviceBinding : ThreatEvent(RandomGenerator.next())
25
+ object UnofficialStore : ThreatEvent(RandomGenerator.next())
26
+ object ObfuscationIssues : ThreatEvent(RandomGenerator.next())
27
+ object SystemVPN : ThreatEvent(RandomGenerator.next())
28
+ object DevMode : ThreatEvent(RandomGenerator.next())
29
+ object Malware : ThreatEvent(RandomGenerator.next())
30
+ object ADBEnabled : ThreatEvent(RandomGenerator.next())
31
+ object Screenshot : ThreatEvent(RandomGenerator.next())
32
+ object ScreenRecording : ThreatEvent(RandomGenerator.next())
33
+ object MultiInstance : ThreatEvent(RandomGenerator.next())
34
+ object TimeSpoofing : ThreatEvent(RandomGenerator.next())
35
+ object LocationSpoofing : ThreatEvent(RandomGenerator.next())
36
+ object UnsecureWifi : ThreatEvent(RandomGenerator.next())
37
+
38
+ companion object {
39
+
40
+ internal val CHANNEL_NAME = RandomGenerator.next().toString()
41
+ internal val CHANNEL_KEY = RandomGenerator.next().toString()
42
+ internal val MALWARE_CHANNEL_KEY = RandomGenerator.next().toString()
43
+
44
+ internal val ALL_EVENTS = JSONArray(
45
+ listOf(
46
+ AppIntegrity,
47
+ PrivilegedAccess,
48
+ Debug,
49
+ Hooks,
50
+ Passcode,
51
+ Simulator,
52
+ SecureHardwareNotAvailable,
53
+ SystemVPN,
54
+ DeviceBinding,
55
+ UnofficialStore,
56
+ ObfuscationIssues,
57
+ DevMode,
58
+ Malware,
59
+ ADBEnabled,
60
+ Screenshot,
61
+ ScreenRecording,
62
+ MultiInstance,
63
+ TimeSpoofing,
64
+ LocationSpoofing,
65
+ UnsecureWifi
66
+ ).map { it.value }
67
+ )
68
+ }
69
+ }
@@ -10,6 +10,7 @@ import kotlinx.serialization.Serializable
10
10
  data class CapSuspiciousAppInfo(
11
11
  val packageInfo: CapPackageInfo,
12
12
  val reason: String,
13
+ val permissions: Set<String>?
13
14
  )
14
15
 
15
16
  /**
@@ -57,6 +57,7 @@ internal fun SuspiciousAppInfo.toCapSuspiciousAppInfo(context: Context): CapSusp
57
57
  return CapSuspiciousAppInfo(
58
58
  packageInfo = this.packageInfo.toCapPackageInfo(context),
59
59
  reason = this.reason,
60
+ permissions = this.permissions
60
61
  )
61
62
  }
62
63
 
@@ -0,0 +1,24 @@
1
+ package com.aheaditec.freerasp.utils
2
+
3
+ import java.security.SecureRandom
4
+ import java.util.concurrent.ConcurrentHashMap
5
+
6
+ internal object RandomGenerator {
7
+ private val secureRandom = SecureRandom()
8
+
9
+ private val generatedNumbers = ConcurrentHashMap.newKeySet<Int>()
10
+
11
+ internal fun next(): Int {
12
+ val min = 10_000_000
13
+ val max = 999_999_999
14
+ val range = (max - min) + 1
15
+
16
+ var nextNumber: Int
17
+ do {
18
+ nextNumber = secureRandom.nextInt(range) + min
19
+ } while (!generatedNumbers.add(nextNumber))
20
+
21
+ return nextNumber
22
+ }
23
+
24
+ }
@@ -9,6 +9,8 @@ import android.os.Build
9
9
  import android.util.Base64
10
10
  import android.util.Log
11
11
  import java.io.ByteArrayOutputStream
12
+ import androidx.core.graphics.createBitmap
13
+
12
14
 
13
15
  internal object Utils {
14
16
 
@@ -42,11 +44,7 @@ internal object Utils {
42
44
  }
43
45
 
44
46
  if (drawable.intrinsicWidth > 0 && drawable.intrinsicHeight > 0) {
45
- val bitmap = Bitmap.createBitmap(
46
- drawable.intrinsicWidth,
47
- drawable.intrinsicHeight,
48
- Bitmap.Config.ARGB_8888
49
- )
47
+ val bitmap = createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight)
50
48
  val canvas = Canvas(bitmap)
51
49
  drawable.setBounds(0, 0, canvas.width, canvas.height)
52
50
  drawable.draw(canvas)
@@ -0,0 +1,2 @@
1
+ import type { RaspExecutionStateEventActions } from '../../types/types';
2
+ export declare const registerRaspExecutionStateListener: (config: RaspExecutionStateEventActions) => Promise<void>;