freerasp-react-native 4.3.2 → 4.5.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 (100) hide show
  1. package/CHANGELOG.md +99 -1
  2. package/android/build.gradle +8 -2
  3. package/android/gradle.properties +2 -2
  4. package/android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt +87 -43
  5. package/android/src/main/java/com/freeraspreactnative/PluginThreatHandler.kt +126 -0
  6. package/android/src/main/java/com/freeraspreactnative/dispatchers/ExecutionStateDispatcher.kt +53 -0
  7. package/android/src/main/java/com/freeraspreactnative/dispatchers/ThreatDispatcher.kt +75 -0
  8. package/android/src/main/java/com/freeraspreactnative/events/ThreatEvent.kt +3 -1
  9. package/android/src/main/java/com/freeraspreactnative/interfaces/PluginExecutionStateListener.kt +7 -0
  10. package/android/src/main/java/com/freeraspreactnative/interfaces/PluginThreatListener.kt +9 -0
  11. package/example/src/App.tsx +11 -1
  12. package/example/src/DemoApp.tsx +32 -0
  13. package/example/src/checks.ts +2 -1
  14. package/freerasp-react-native.podspec +5 -1
  15. package/ios/FreeraspReactNative.m +5 -0
  16. package/ios/FreeraspReactNative.swift +39 -10
  17. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeDirectory +0 -0
  18. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeResources +82 -288
  19. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeSignature +0 -0
  20. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  21. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +7 -2
  22. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +7 -7
  23. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +4 -4
  24. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +1 -1
  25. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +1 -1
  26. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
  27. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +474 -547
  28. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +6 -3
  29. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  30. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +6 -3
  31. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/PrivacyInfo.xcprivacy +8 -0
  32. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
  33. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  34. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +14 -4
  35. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +7 -7
  36. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +4 -4
  37. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +1 -1
  38. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +1 -1
  39. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
  40. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +475 -548
  41. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +6 -3
  42. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  43. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -3
  44. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +475 -548
  45. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +6 -3
  46. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  47. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +6 -3
  48. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/PrivacyInfo.xcprivacy +8 -0
  49. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
  50. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +46 -35
  51. package/ios/dispatchers/ExecutionStateDispatcher.swift +35 -0
  52. package/ios/dispatchers/ThreatDispatcher.swift +36 -0
  53. package/ios/models/SecurityThreat.swift +2 -0
  54. package/ios/utils/EventIdentifiers.swift +2 -2
  55. package/lib/commonjs/api/listeners/raspExecutionState.js +28 -8
  56. package/lib/commonjs/api/listeners/raspExecutionState.js.map +1 -1
  57. package/lib/commonjs/api/listeners/threat.js +34 -10
  58. package/lib/commonjs/api/listeners/threat.js.map +1 -1
  59. package/lib/commonjs/api/methods/native.js +9 -1
  60. package/lib/commonjs/api/methods/native.js.map +1 -1
  61. package/lib/commonjs/api/methods/reactNative.js +13 -8
  62. package/lib/commonjs/api/methods/reactNative.js.map +1 -1
  63. package/lib/commonjs/channels/threat.js +1 -3
  64. package/lib/commonjs/channels/threat.js.map +1 -1
  65. package/lib/commonjs/models/threat.js +2 -1
  66. package/lib/commonjs/models/threat.js.map +1 -1
  67. package/lib/module/api/listeners/raspExecutionState.js +29 -9
  68. package/lib/module/api/listeners/raspExecutionState.js.map +1 -1
  69. package/lib/module/api/listeners/threat.js +35 -11
  70. package/lib/module/api/listeners/threat.js.map +1 -1
  71. package/lib/module/api/methods/native.js +6 -0
  72. package/lib/module/api/methods/native.js.map +1 -1
  73. package/lib/module/api/methods/reactNative.js +13 -7
  74. package/lib/module/api/methods/reactNative.js.map +1 -1
  75. package/lib/module/channels/threat.js +1 -3
  76. package/lib/module/channels/threat.js.map +1 -1
  77. package/lib/module/models/threat.js +2 -1
  78. package/lib/module/models/threat.js.map +1 -1
  79. package/lib/typescript/src/api/listeners/raspExecutionState.d.ts +1 -1
  80. package/lib/typescript/src/api/listeners/raspExecutionState.d.ts.map +1 -1
  81. package/lib/typescript/src/api/listeners/threat.d.ts +1 -1
  82. package/lib/typescript/src/api/listeners/threat.d.ts.map +1 -1
  83. package/lib/typescript/src/api/methods/native.d.ts +2 -0
  84. package/lib/typescript/src/api/methods/native.d.ts.map +1 -1
  85. package/lib/typescript/src/api/methods/reactNative.d.ts.map +1 -1
  86. package/lib/typescript/src/channels/threat.d.ts.map +1 -1
  87. package/lib/typescript/src/models/threat.d.ts +1 -0
  88. package/lib/typescript/src/models/threat.d.ts.map +1 -1
  89. package/lib/typescript/src/types/types.d.ts +1 -0
  90. package/lib/typescript/src/types/types.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/src/api/listeners/raspExecutionState.ts +39 -11
  93. package/src/api/listeners/threat.ts +41 -10
  94. package/src/api/methods/native.ts +8 -0
  95. package/src/api/methods/reactNative.ts +17 -8
  96. package/src/channels/threat.ts +1 -3
  97. package/src/models/threat.ts +3 -0
  98. package/src/types/types.ts +1 -0
  99. package/android/src/main/java/com/freeraspreactnative/FreeraspThreatHandler.kt +0 -103
  100. package/ios/TalsecRuntime.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
@@ -21,6 +21,7 @@ import {
21
21
  blockScreenCapture,
22
22
  type SuspiciousAppInfo,
23
23
  storeExternalId,
24
+ removeExternalId,
24
25
  } from 'freerasp-react-native';
25
26
  import {
26
27
  ALERT_TYPE,
@@ -84,6 +85,24 @@ export const DemoApp: React.FC<{
84
85
  }
85
86
  };
86
87
 
88
+ const handleModalRemove = async () => {
89
+ setModalVisible(false);
90
+ try {
91
+ await removeExternalId();
92
+ Toast.show({
93
+ type: ALERT_TYPE.SUCCESS,
94
+ title: 'Success',
95
+ textBody: 'External ID removed',
96
+ });
97
+ } catch (error: any) {
98
+ Toast.show({
99
+ type: ALERT_TYPE.WARNING,
100
+ title: 'Warning',
101
+ textBody: 'External ID not removed',
102
+ });
103
+ }
104
+ };
105
+
87
106
  const handleModalDismiss = () => {
88
107
  setModalVisible(false);
89
108
  };
@@ -140,6 +159,11 @@ export const DemoApp: React.FC<{
140
159
  onPress={handleModalSend}>
141
160
  <Text style={styles.modalText}>Send</Text>
142
161
  </TouchableOpacity>
162
+ <TouchableOpacity
163
+ style={styles.removeButton}
164
+ onPress={handleModalRemove}>
165
+ <Text style={styles.modalText}>Remove</Text>
166
+ </TouchableOpacity>
143
167
  <TouchableOpacity
144
168
  style={styles.dismissButton}
145
169
  onPress={handleModalDismiss}>
@@ -346,6 +370,14 @@ const styles = StyleSheet.create({
346
370
  marginRight: 10,
347
371
  alignItems: 'center',
348
372
  },
373
+ removeButton: {
374
+ backgroundColor: '#FF9800',
375
+ padding: 10,
376
+ borderRadius: 5,
377
+ flex: 1,
378
+ marginRight: 10,
379
+ alignItems: 'center',
380
+ },
349
381
  dismissButton: {
350
382
  backgroundColor: '#f44336',
351
383
  padding: 10,
@@ -11,6 +11,7 @@ export const commonChecks = [
11
11
  { name: 'Unofficial Store', status: 'ok' },
12
12
  { name: 'Screenshot', status: 'ok' },
13
13
  { name: 'Screen Recording', status: 'ok' },
14
+ { name: 'Time Spoofing', status: 'ok' },
14
15
  ];
15
16
 
16
17
  export const iosChecks = [{ name: 'Device ID', status: 'ok' }];
@@ -21,7 +22,7 @@ export const androidChecks = [
21
22
  { name: 'Malware', status: 'ok' },
22
23
  { name: 'ADB Enabled', status: 'ok' },
23
24
  { name: 'Multi Instance', status: 'ok' },
24
- { name: 'Time Spoofing', status: 'ok' },
25
25
  { name: 'Location Spoofing', status: 'ok' },
26
26
  { name: 'Unsecure Wifi', status: 'ok' },
27
+ { name: 'Automation', status: 'ok' },
27
28
  ];
@@ -14,7 +14,11 @@ Pod::Spec.new do |s|
14
14
  s.platforms = { :ios => "11.0" }
15
15
  s.source = { :git => "https://github.com/talsec/freerasp-react-native.git", :tag => "#{s.version}" }
16
16
 
17
- s.source_files = 'ios/models/*.{h,m,mm,swift}', 'ios/utils/*.{h,m,mm,swift}', 'ios/*.{h,m,mm,swift}', 'ios/TalsecRuntime.xcframework'
17
+ s.source_files = 'ios/models/*.{h,m,mm,swift}',
18
+ 'ios/utils/*.{h,m,mm,swift}',
19
+ 'ios/dispatchers/*.{h,m,mm,swift}',
20
+ 'ios/*.{h,m,mm,swift}',
21
+ 'ios/TalsecRuntime.xcframework'
18
22
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework TalsecRuntime' }
19
23
  s.ios.vendored_frameworks = "ios/TalsecRuntime.xcframework"
20
24
 
@@ -15,6 +15,9 @@ RCT_EXTERN_METHOD(getRaspExecutionStateChannelData:(RCTPromiseResolveBlock)resol
15
15
  withRejecter:(RCTPromiseRejectBlock)reject)
16
16
  RCT_EXTERN_METHOD(getRaspExecutionStateIdentifiers:(RCTPromiseResolveBlock)resolve
17
17
  withRejecter:(RCTPromiseRejectBlock)reject)
18
+ RCT_EXTERN_METHOD(removeListenerForEvent:(NSString *)eventName
19
+ withResolver:(RCTPromiseResolveBlock)resolve
20
+ withRejecter:(RCTPromiseRejectBlock)reject)
18
21
  RCT_EXTERN_METHOD(blockScreenCapture:(BOOL)enable
19
22
  withResolver:(RCTPromiseResolveBlock)resolve
20
23
  withRejecter:(RCTPromiseRejectBlock)reject)
@@ -23,6 +26,8 @@ RCT_EXTERN_METHOD(isScreenCaptureBlocked:(RCTPromiseResolveBlock)resolve
23
26
  RCT_EXTERN_METHOD(storeExternalId:(NSString *)externalId
24
27
  withResolver:(RCTPromiseResolveBlock)resolve
25
28
  withRejecter:(RCTPromiseRejectBlock)reject)
29
+ RCT_EXTERN_METHOD(removeExternalId:(RCTPromiseResolveBlock)resolve
30
+ withRejecter:(RCTPromiseRejectBlock)reject)
26
31
  RCT_EXTERN_METHOD(onInvalidCallback)
27
32
 
28
33
  + (BOOL)requiresMainQueueSetup
@@ -11,6 +11,30 @@ class FreeraspReactNative: RCTEventEmitter {
11
11
  FreeraspReactNative.shared = self
12
12
  }
13
13
 
14
+ @objc(addListener:)
15
+ override func addListener(_ eventName: String!) {
16
+ super.addListener(eventName)
17
+ if eventName == EventIdentifiers.threatChannelName {
18
+ ThreatDispatcher.shared.listener = { [weak self] threat in
19
+ self?.dispatchThreatEvent(threat: threat)
20
+ }
21
+ } else if eventName == EventIdentifiers.raspExecutionStateChannelName {
22
+ ExecutionStateDispatcher.shared.listener = { [weak self] event in
23
+ self?.dispatchRaspExecutionStateEvent(event: event)
24
+ }
25
+ }
26
+ }
27
+
28
+ @objc(removeListenerForEvent:withResolver:withRejecter:)
29
+ func removeListenerForEvent(eventName: String, resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
30
+ if eventName == EventIdentifiers.threatChannelName {
31
+ ThreatDispatcher.shared.listener = nil
32
+ } else if eventName == EventIdentifiers.raspExecutionStateChannelName {
33
+ ExecutionStateDispatcher.shared.listener = nil
34
+ }
35
+ resolve("Listener unregistered")
36
+ }
37
+
14
38
  @objc(talsecStart:withResolver:withRejecter:)
15
39
  func talsecStart(options: NSDictionary, resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
16
40
  do {
@@ -72,12 +96,18 @@ class FreeraspReactNative: RCTEventEmitter {
72
96
  resolve("OK - Store external ID")
73
97
  }
74
98
 
99
+ @objc(removeExternalId:withRejecter:)
100
+ private func removeExternalId(resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
101
+ UserDefaults.standard.removeObject(forKey: "app.talsec.externalid")
102
+ resolve("OK - External ID removed")
103
+ }
104
+
75
105
  /**
76
106
  * Method to setup the message passing between native and React Native
77
107
  */
78
108
  @objc(getThreatChannelData:withRejecter:)
79
109
  private func getThreatChannelData(resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
80
- resolve([EventIdentifiers.threatChannelName, EventIdentifiers.threatChannelKey])
110
+ resolve([EventIdentifiers.threatChannelName, EventIdentifiers.threatChannelKey, "0"])
81
111
  }
82
112
 
83
113
  /**
@@ -88,16 +118,16 @@ class FreeraspReactNative: RCTEventEmitter {
88
118
  resolve([EventIdentifiers.raspExecutionStateChannelName, EventIdentifiers.raspExecutionStateChannelKey])
89
119
  }
90
120
 
91
- func dispatchEvent(securityThreat: SecurityThreat) -> Void {
121
+ func dispatchThreatEvent(threat: SecurityThreat) {
92
122
  FreeraspReactNative.shared!.sendEvent(withName: EventIdentifiers.threatChannelName, body: [
93
- EventIdentifiers.threatChannelKey: securityThreat.callbackIdentifier,
123
+ EventIdentifiers.threatChannelKey: threat.callbackIdentifier
94
124
  ])
95
125
  }
96
126
 
97
- func dispatchRaspExecutionStateEvent(event: RaspExecutionStates) -> Void {
98
- FreeraspReactNative.shared!.sendEvent(withName: EventIdentifiers.raspExecutionStateChannelName, body: [
99
- EventIdentifiers.raspExecutionStateChannelKey: event.callbackIdentifier,
100
- ])
127
+ func dispatchRaspExecutionStateEvent(event: RaspExecutionStates) {
128
+ FreeraspReactNative.shared!.sendEvent(withName: EventIdentifiers.raspExecutionStateChannelName, body: [
129
+ EventIdentifiers.raspExecutionStateChannelKey: event.callbackIdentifier,
130
+ ])
101
131
  }
102
132
 
103
133
  /**
@@ -139,12 +169,11 @@ extension SecurityThreatCenter: @retroactive SecurityThreatHandler, @retroactive
139
169
  if (securityThreat.rawValue == "passcodeChange") {
140
170
  return
141
171
  }
142
- FreeraspReactNative.shared!.dispatchEvent(securityThreat: securityThreat)
172
+ ThreatDispatcher.shared.dispatch(threat: securityThreat)
143
173
  }
144
174
 
145
175
  public func onAllChecksFinished() {
146
-
147
- FreeraspReactNative.shared!.dispatchRaspExecutionStateEvent(event: RaspExecutionStates.allChecksFinished)
176
+ ExecutionStateDispatcher.shared.dispatch(event: RaspExecutionStates.allChecksFinished)
148
177
  }
149
178
  }
150
179