capacitor-freerasp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CapacitorFreerasp.podspec +19 -0
  2. package/LICENSE +20 -0
  3. package/README.md +431 -0
  4. package/android/build.gradle +75 -0
  5. package/android/consumer-rules.pro +1 -0
  6. package/android/gradle.properties +22 -0
  7. package/android/proguard-rules.pro +21 -0
  8. package/android/settings.gradle +2 -0
  9. package/android/src/main/AndroidManifest.xml +2 -0
  10. package/android/src/main/java/com/aheaditec/freerasp/FreeraspPlugin.kt +120 -0
  11. package/android/src/main/res/.gitkeep +0 -0
  12. package/dist/esm/definitions.d.ts +36 -0
  13. package/dist/esm/definitions.js +2 -0
  14. package/dist/esm/definitions.js.map +1 -0
  15. package/dist/esm/index.d.ts +7 -0
  16. package/dist/esm/index.js +25 -0
  17. package/dist/esm/index.js.map +1 -0
  18. package/dist/esm/web.d.ts +9 -0
  19. package/dist/esm/web.js +8 -0
  20. package/dist/esm/web.js.map +1 -0
  21. package/dist/plugin.cjs.js +45 -0
  22. package/dist/plugin.cjs.js.map +1 -0
  23. package/dist/plugin.js +48 -0
  24. package/dist/plugin.js.map +1 -0
  25. package/ios/Plugin/Freerasp.swift +8 -0
  26. package/ios/Plugin/FreeraspPlugin.h +10 -0
  27. package/ios/Plugin/FreeraspPlugin.m +9 -0
  28. package/ios/Plugin/FreeraspPlugin.swift +66 -0
  29. package/ios/Plugin/Info.plist +24 -0
  30. package/ios/Plugin/TalsecRuntime.xcframework/Info.plist +40 -0
  31. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CryptoBridgingHeader.h +14 -0
  32. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +25 -0
  33. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +297 -0
  34. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime_iOS.h +23 -0
  35. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +3029 -0
  36. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curlver.h +77 -0
  37. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/easy.h +123 -0
  38. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/mprintf.h +50 -0
  39. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +456 -0
  40. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +68 -0
  41. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/stdcheaders.h +33 -0
  42. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/system.h +504 -0
  43. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +125 -0
  44. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
  45. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +5255 -0
  46. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +54 -0
  47. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  48. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +54 -0
  49. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/module.modulemap +17 -0
  50. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
  51. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/cacert.pem +3154 -0
  52. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/module.modulemap +12 -0
  53. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CryptoBridgingHeader.h +14 -0
  54. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +25 -0
  55. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +590 -0
  56. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime_iOS.h +23 -0
  57. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +3029 -0
  58. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curlver.h +77 -0
  59. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/easy.h +123 -0
  60. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/mprintf.h +50 -0
  61. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +456 -0
  62. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +68 -0
  63. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/stdcheaders.h +33 -0
  64. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/system.h +504 -0
  65. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +125 -0
  66. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
  67. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +5220 -0
  68. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +54 -0
  69. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  70. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +54 -0
  71. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +5220 -0
  72. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +54 -0
  73. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  74. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +54 -0
  75. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/module.modulemap +17 -0
  76. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
  77. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +388 -0
  78. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/cacert.pem +3154 -0
  79. package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/module.modulemap +12 -0
  80. package/package.json +92 -0
@@ -0,0 +1,120 @@
1
+ package com.aheaditec.freerasp
2
+
3
+ import com.aheaditec.talsec_security.security.api.Talsec
4
+ import com.aheaditec.talsec_security.security.api.TalsecConfig
5
+ import com.aheaditec.talsec_security.security.api.ThreatListener
6
+ import com.getcapacitor.JSObject
7
+ import com.getcapacitor.Plugin
8
+ import com.getcapacitor.PluginCall
9
+ import com.getcapacitor.PluginMethod
10
+ import com.getcapacitor.annotation.CapacitorPlugin
11
+ import java.lang.Exception
12
+
13
+ @CapacitorPlugin(name = "Freerasp")
14
+ class FreeraspPlugin : Plugin(), ThreatListener.DeviceState, ThreatListener.ThreatDetected {
15
+
16
+ private val listener = ThreatListener(this, this)
17
+ private var registered = true
18
+ private val emptyData = JSObject()
19
+
20
+ @PluginMethod()
21
+ fun talsecStart(call: PluginCall) {
22
+ val config = call.getObject("config")
23
+ if (config == null) {
24
+ call.reject("Missing config parameter in freeRASP Native Plugin")
25
+ return
26
+ }
27
+ try {
28
+ val talsecConfig = parseTalsecConfigThrowing(config)
29
+ listener.registerListener(context)
30
+ Talsec.start(context, talsecConfig)
31
+ call.resolve(JSObject().put("started", true))
32
+ } catch (e: Exception) {
33
+ call.reject("Error during Talsec Native plugin initialization - ${e.message}", null, e)
34
+ }
35
+ }
36
+
37
+ override fun handleOnPause() {
38
+ super.handleOnPause()
39
+ listener.unregisterListener(context)
40
+ registered = false
41
+ }
42
+
43
+ override fun handleOnResume() {
44
+ super.handleOnResume()
45
+ if (!registered) {
46
+ registered = true
47
+ listener.registerListener(context)
48
+ }
49
+ }
50
+
51
+ override fun onRootDetected() {
52
+ notifyListeners("privilegedAccess", emptyData, true)
53
+ }
54
+
55
+ override fun onDebuggerDetected() {
56
+ notifyListeners("debug", emptyData, true)
57
+ }
58
+
59
+ override fun onEmulatorDetected() {
60
+ notifyListeners("simulator", emptyData, true)
61
+ }
62
+
63
+ override fun onTamperDetected() {
64
+ notifyListeners("appIntegrity", emptyData, true)
65
+ }
66
+
67
+ override fun onUntrustedInstallationSourceDetected() {
68
+ notifyListeners("unofficialStore", emptyData, true)
69
+ }
70
+
71
+ override fun onHookDetected() {
72
+ notifyListeners("hooks", emptyData, true)
73
+ }
74
+
75
+ override fun onDeviceBindingDetected() {
76
+ notifyListeners("deviceBinding", emptyData, true)
77
+ }
78
+
79
+ override fun onUnlockedDeviceDetected() {
80
+ notifyListeners("passcode", emptyData, true)
81
+ }
82
+
83
+ override fun onHardwareBackedKeystoreNotAvailableDetected() {
84
+ notifyListeners("secureHardwareNotAvailable", emptyData, true)
85
+ }
86
+
87
+ override fun onObfuscationIssuesDetected() {
88
+ notifyListeners("obfuscationIssues", emptyData, true)
89
+ }
90
+
91
+ private fun parseTalsecConfigThrowing(configJson: JSObject): TalsecConfig {
92
+ val androidConfig = configJson.getJSONObject("androidConfig")
93
+ val packageName = androidConfig.getString("packageName")
94
+ val certificateHashes = mutableListOf<String>()
95
+ val hashes = androidConfig.getJSONArray("certificateHashes")
96
+ if (hashes.length() == 0) {
97
+ throw IllegalArgumentException("At least 1 certificate hash is required.")
98
+ }
99
+ for (i in 0 until hashes.length()) {
100
+ certificateHashes.add(hashes.getString(i))
101
+ }
102
+ val watcherMail = configJson.getString("watcherMail")
103
+ val alternativeStores = mutableListOf<String>()
104
+ if (androidConfig.has("supportedAlternativeStores")) {
105
+ val stores = androidConfig.getJSONArray("supportedAlternativeStores")
106
+ for (i in 0 until stores.length()) {
107
+ alternativeStores.add(stores.getString(i))
108
+ }
109
+ }
110
+ val isProd = configJson.getBool("isProd") ?: true
111
+
112
+ return TalsecConfig(
113
+ packageName,
114
+ certificateHashes.toTypedArray(),
115
+ watcherMail,
116
+ alternativeStores.toTypedArray(),
117
+ isProd
118
+ )
119
+ }
120
+ }
File without changes
@@ -0,0 +1,36 @@
1
+ export interface FreeraspPlugin {
2
+ addListener(listener: string, callback: () => any): any;
3
+ talsecStart(options: {
4
+ config: FreeraspConfig;
5
+ }): Promise<{
6
+ started: boolean;
7
+ }>;
8
+ }
9
+ export declare type FreeraspConfig = {
10
+ androidConfig?: AndroidConfig;
11
+ iosConfig?: IOSConfig;
12
+ watcherMail: string;
13
+ isProd?: boolean;
14
+ };
15
+ export declare type AndroidConfig = {
16
+ packageName: string;
17
+ certificateHashes: string[];
18
+ supportedAlternativeStores?: string[];
19
+ };
20
+ export declare type IOSConfig = {
21
+ appBundleId: string;
22
+ appTeamId: string;
23
+ };
24
+ export declare type NativeEventEmitterActions = {
25
+ privilegedAccess?: () => any;
26
+ debug?: () => any;
27
+ simulator?: () => any;
28
+ appIntegrity?: () => any;
29
+ unofficialStore?: () => any;
30
+ hooks?: () => any;
31
+ deviceBinding?: () => any;
32
+ deviceID?: () => any;
33
+ passcode?: () => any;
34
+ secureHardwareNotAvailable?: () => any;
35
+ obfuscationIssues?: () => any;
36
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface FreeraspPlugin {\n addListener(listener: string, callback: () => any): any;\n talsecStart(options: { config: FreeraspConfig }): Promise<{ started: boolean }>;\n}\n\nexport type FreeraspConfig = {\n androidConfig?: AndroidConfig;\n iosConfig?: IOSConfig;\n watcherMail: string;\n isProd?: boolean;\n}\n\nexport type AndroidConfig = {\n packageName: string;\n certificateHashes: string[];\n supportedAlternativeStores?: string[];\n}\n\nexport type IOSConfig = {\n appBundleId: string;\n appTeamId: string;\n}\n\nexport type NativeEventEmitterActions = {\n privilegedAccess?: () => any;\n debug?: () => any;\n simulator?: () => any;\n appIntegrity?: () => any;\n unofficialStore?: () => any;\n hooks?: () => any;\n deviceBinding?: () => any;\n deviceID?: () => any;\n passcode?: () => any;\n secureHardwareNotAvailable?: () => any;\n obfuscationIssues?: () => any;\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import type { FreeraspPlugin, FreeraspConfig, NativeEventEmitterActions } from './definitions';
2
+ declare const Freerasp: FreeraspPlugin;
3
+ declare const setThreatListeners: <T extends NativeEventEmitterActions>(callbacks: T & Record<Exclude<keyof T, "privilegedAccess" | "debug" | "simulator" | "appIntegrity" | "unofficialStore" | "hooks" | "deviceBinding" | "deviceID" | "passcode" | "secureHardwareNotAvailable" | "obfuscationIssues">, []>) => Promise<void>;
4
+ declare const removeThreatListeners: () => void;
5
+ declare const startFreeRASP: <T extends NativeEventEmitterActions>(config: FreeraspConfig, reactions: T & Record<Exclude<keyof T, "privilegedAccess" | "debug" | "simulator" | "appIntegrity" | "unofficialStore" | "hooks" | "deviceBinding" | "deviceID" | "passcode" | "secureHardwareNotAvailable" | "obfuscationIssues">, []>) => Promise<boolean>;
6
+ export * from './definitions';
7
+ export { Freerasp, startFreeRASP, setThreatListeners, removeThreatListeners };
@@ -0,0 +1,25 @@
1
+ import { Capacitor, registerPlugin } from '@capacitor/core';
2
+ const activeListeners = [];
3
+ const Freerasp = registerPlugin('Freerasp', {
4
+ web: () => import('./web').then(m => new m.FreeraspWeb()),
5
+ });
6
+ const setThreatListeners = async (callbacks) => {
7
+ for (const [threat, action] of Object.entries(callbacks)) {
8
+ if ((threat === 'obfuscationIssues' && Capacitor.getPlatform() === 'ios') || (action === undefined)) {
9
+ continue;
10
+ }
11
+ const listener = await Freerasp.addListener(threat, action);
12
+ activeListeners.push(listener);
13
+ }
14
+ };
15
+ const removeThreatListeners = () => {
16
+ activeListeners.forEach((listener) => listener.remove());
17
+ };
18
+ const startFreeRASP = async (config, reactions) => {
19
+ await setThreatListeners(reactions);
20
+ const { started } = await Freerasp.talsecStart({ config });
21
+ return started;
22
+ };
23
+ export * from './definitions';
24
+ export { Freerasp, startFreeRASP, setThreatListeners, removeThreatListeners };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI5D,MAAM,eAAe,GAAU,EAAE,CAAC;AAElC,MAAM,QAAQ,GAAG,cAAc,CAAiB,UAAU,EAAE;IAC1D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,KAAK,EAC9B,SAA4E,EAC5E,EAAE;IAEF,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QACxD,IAAI,CAAC,MAAM,KAAK,mBAAmB,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,EAAE;YACnG,SAAS;SACV;QACD,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5D,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAChC;AACH,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,KAAK,EAAuC,MAAsB,EAAE,SAA6E,EAAE,EAAE;IAEzK,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,EAAC,MAAM,EAAC,CAAC,CAAA;IAExD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nimport type { FreeraspPlugin, FreeraspConfig, NativeEventEmitterActions } from './definitions';\n\nconst activeListeners: any[] = [];\n\nconst Freerasp = registerPlugin<FreeraspPlugin>('Freerasp', {\n web: () => import('./web').then(m => new m.FreeraspWeb()),\n});\n\nconst setThreatListeners = async <T extends NativeEventEmitterActions>(\n callbacks: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>\n) => {\n\n for (const [threat, action] of Object.entries(callbacks)) {\n if ((threat === 'obfuscationIssues' && Capacitor.getPlatform() === 'ios') || (action === undefined)) {\n continue;\n }\n const listener = await Freerasp.addListener(threat, action);\n activeListeners.push(listener);\n }\n};\n\nconst removeThreatListeners = () => {\n activeListeners.forEach((listener) => listener.remove());\n};\n\nconst startFreeRASP = async <T extends NativeEventEmitterActions>(config: FreeraspConfig, reactions: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>) => {\n \n await setThreatListeners(reactions);\n const { started } = await Freerasp.talsecStart({config})\n\n return started\n}\n\nexport * from './definitions';\nexport { Freerasp, startFreeRASP, setThreatListeners, removeThreatListeners };\n"]}
@@ -0,0 +1,9 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { FreeraspPlugin, FreeraspConfig } from './definitions';
3
+ export declare class FreeraspWeb extends WebPlugin implements FreeraspPlugin {
4
+ talsecStart(_options: {
5
+ config: FreeraspConfig;
6
+ }): Promise<{
7
+ started: boolean;
8
+ }>;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class FreeraspWeb extends WebPlugin {
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+ async talsecStart(_options) {
5
+ throw new Error('Method not implemented.');
6
+ }
7
+ }
8
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,6DAA6D;IAC7D,KAAK,CAAC,WAAW,CAAC,QAAoC;QACpD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { FreeraspPlugin, FreeraspConfig } from './definitions';\n\nexport class FreeraspWeb extends WebPlugin implements FreeraspPlugin {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async talsecStart(_options: { config: FreeraspConfig }): Promise<{ started: boolean }> {\n throw new Error('Method not implemented.');\n }\n}\n"]}
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const activeListeners = [];
8
+ const Freerasp = core.registerPlugin('Freerasp', {
9
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FreeraspWeb()),
10
+ });
11
+ const setThreatListeners = async (callbacks) => {
12
+ for (const [threat, action] of Object.entries(callbacks)) {
13
+ if ((threat === 'obfuscationIssues' && core.Capacitor.getPlatform() === 'ios') || (action === undefined)) {
14
+ continue;
15
+ }
16
+ const listener = await Freerasp.addListener(threat, action);
17
+ activeListeners.push(listener);
18
+ }
19
+ };
20
+ const removeThreatListeners = () => {
21
+ activeListeners.forEach((listener) => listener.remove());
22
+ };
23
+ const startFreeRASP = async (config, reactions) => {
24
+ await setThreatListeners(reactions);
25
+ const { started } = await Freerasp.talsecStart({ config });
26
+ return started;
27
+ };
28
+
29
+ class FreeraspWeb extends core.WebPlugin {
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ async talsecStart(_options) {
32
+ throw new Error('Method not implemented.');
33
+ }
34
+ }
35
+
36
+ var web = /*#__PURE__*/Object.freeze({
37
+ __proto__: null,
38
+ FreeraspWeb: FreeraspWeb
39
+ });
40
+
41
+ exports.Freerasp = Freerasp;
42
+ exports.removeThreatListeners = removeThreatListeners;
43
+ exports.setThreatListeners = setThreatListeners;
44
+ exports.startFreeRASP = startFreeRASP;
45
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\nconst activeListeners = [];\nconst Freerasp = registerPlugin('Freerasp', {\n web: () => import('./web').then(m => new m.FreeraspWeb()),\n});\nconst setThreatListeners = async (callbacks) => {\n for (const [threat, action] of Object.entries(callbacks)) {\n if ((threat === 'obfuscationIssues' && Capacitor.getPlatform() === 'ios') || (action === undefined)) {\n continue;\n }\n const listener = await Freerasp.addListener(threat, action);\n activeListeners.push(listener);\n }\n};\nconst removeThreatListeners = () => {\n activeListeners.forEach((listener) => listener.remove());\n};\nconst startFreeRASP = async (config, reactions) => {\n await setThreatListeners(reactions);\n const { started } = await Freerasp.talsecStart({ config });\n return started;\n};\nexport * from './definitions';\nexport { Freerasp, startFreeRASP, setThreatListeners, removeThreatListeners };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class FreeraspWeb extends WebPlugin {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async talsecStart(_options) {\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","Capacitor","WebPlugin"],"mappings":";;;;;;AACA,MAAM,eAAe,GAAG,EAAE,CAAC;AACtB,MAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;AAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7D,CAAC,EAAE;AACE,MAAC,kBAAkB,GAAG,OAAO,SAAS,KAAK;AAChD,IAAI,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;AAC9D,QAAQ,IAAI,CAAC,MAAM,KAAK,mBAAmB,IAAIC,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,MAAM,MAAM,KAAK,SAAS,CAAC,EAAE;AAC7G,YAAY,SAAS;AACrB,SAAS;AACT,QAAQ,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpE,QAAQ,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACvC,KAAK;AACL,EAAE;AACG,MAAC,qBAAqB,GAAG,MAAM;AACpC,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AAC7D,EAAE;AACG,MAAC,aAAa,GAAG,OAAO,MAAM,EAAE,SAAS,KAAK;AACnD,IAAI,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAC;AACxC,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/D,IAAI,OAAO,OAAO,CAAC;AACnB;;ACpBO,MAAM,WAAW,SAASC,cAAS,CAAC;AAC3C;AACA,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,48 @@
1
+ var capacitorFreerasp = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const activeListeners = [];
5
+ const Freerasp = core.registerPlugin('Freerasp', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FreeraspWeb()),
7
+ });
8
+ const setThreatListeners = async (callbacks) => {
9
+ for (const [threat, action] of Object.entries(callbacks)) {
10
+ if ((threat === 'obfuscationIssues' && core.Capacitor.getPlatform() === 'ios') || (action === undefined)) {
11
+ continue;
12
+ }
13
+ const listener = await Freerasp.addListener(threat, action);
14
+ activeListeners.push(listener);
15
+ }
16
+ };
17
+ const removeThreatListeners = () => {
18
+ activeListeners.forEach((listener) => listener.remove());
19
+ };
20
+ const startFreeRASP = async (config, reactions) => {
21
+ await setThreatListeners(reactions);
22
+ const { started } = await Freerasp.talsecStart({ config });
23
+ return started;
24
+ };
25
+
26
+ class FreeraspWeb extends core.WebPlugin {
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ async talsecStart(_options) {
29
+ throw new Error('Method not implemented.');
30
+ }
31
+ }
32
+
33
+ var web = /*#__PURE__*/Object.freeze({
34
+ __proto__: null,
35
+ FreeraspWeb: FreeraspWeb
36
+ });
37
+
38
+ exports.Freerasp = Freerasp;
39
+ exports.removeThreatListeners = removeThreatListeners;
40
+ exports.setThreatListeners = setThreatListeners;
41
+ exports.startFreeRASP = startFreeRASP;
42
+
43
+ Object.defineProperty(exports, '__esModule', { value: true });
44
+
45
+ return exports;
46
+
47
+ })({}, capacitorExports);
48
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\nconst activeListeners = [];\nconst Freerasp = registerPlugin('Freerasp', {\n web: () => import('./web').then(m => new m.FreeraspWeb()),\n});\nconst setThreatListeners = async (callbacks) => {\n for (const [threat, action] of Object.entries(callbacks)) {\n if ((threat === 'obfuscationIssues' && Capacitor.getPlatform() === 'ios') || (action === undefined)) {\n continue;\n }\n const listener = await Freerasp.addListener(threat, action);\n activeListeners.push(listener);\n }\n};\nconst removeThreatListeners = () => {\n activeListeners.forEach((listener) => listener.remove());\n};\nconst startFreeRASP = async (config, reactions) => {\n await setThreatListeners(reactions);\n const { started } = await Freerasp.talsecStart({ config });\n return started;\n};\nexport * from './definitions';\nexport { Freerasp, startFreeRASP, setThreatListeners, removeThreatListeners };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class FreeraspWeb extends WebPlugin {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async talsecStart(_options) {\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","Capacitor","WebPlugin"],"mappings":";;;IACA,MAAM,eAAe,GAAG,EAAE,CAAC;AACtB,UAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;IAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7D,CAAC,EAAE;AACE,UAAC,kBAAkB,GAAG,OAAO,SAAS,KAAK;IAChD,IAAI,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;IAC9D,QAAQ,IAAI,CAAC,MAAM,KAAK,mBAAmB,IAAIC,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,MAAM,MAAM,KAAK,SAAS,CAAC,EAAE;IAC7G,YAAY,SAAS;IACrB,SAAS;IACT,QAAQ,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpE,QAAQ,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,KAAK;IACL,EAAE;AACG,UAAC,qBAAqB,GAAG,MAAM;IACpC,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7D,EAAE;AACG,UAAC,aAAa,GAAG,OAAO,MAAM,EAAE,SAAS,KAAK;IACnD,IAAI,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,IAAI,OAAO,OAAO,CAAC;IACnB;;ICpBO,MAAM,WAAW,SAASC,cAAS,CAAC;IAC3C;IACA,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class Freerasp: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(FreeraspPlugin, "Freerasp",
7
+ CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(talsecStart, CAPPluginReturnPromise);
9
+ )
@@ -0,0 +1,66 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import TalsecRuntime
4
+
5
+ @objc(FreeraspPlugin)
6
+ public class FreeraspPlugin: CAPPlugin {
7
+
8
+ public static var shared:FreeraspPlugin?
9
+
10
+ override public func load() {
11
+ FreeraspPlugin.shared = self
12
+ }
13
+
14
+ /// Runs Talsec with given configuration
15
+ @objc func talsecStart(_ call: CAPPluginCall) {
16
+ guard let config = call.getObject("config") else {
17
+ call.reject("Missing config parameter in freeRASP Native Plugin")
18
+ return
19
+ }
20
+
21
+ do {
22
+ try initializeTalsec(talsecConfig: config)
23
+ } catch let error as NSError {
24
+ call.reject(error.localizedDescription)
25
+ return
26
+ }
27
+ call.resolve([
28
+ "started": true
29
+ ])
30
+ }
31
+
32
+ private func initializeTalsec(talsecConfig: JSObject) throws {
33
+ guard let iosConfig = talsecConfig["iosConfig"] as? JSObject else {
34
+ throw NSError(domain: "Missing iosConfig parameter in Talsec Native Plugin", code: 1)
35
+ }
36
+ guard let appBundleIds = iosConfig["appBundleId"] as? String else {
37
+ throw NSError(domain: "Missing appBundleId parameter in Talsec Native Plugin", code: 2)
38
+ }
39
+ guard let appTeamId = iosConfig["appTeamId"] as? String else {
40
+ throw NSError(domain: "Missing appTeamId parameter in Talsec Native Plugin", code: 3)
41
+ }
42
+ guard let watcherMailAddress = talsecConfig["watcherMail"] as? String else {
43
+ throw NSError(domain: "Missing watcherMail parameter in Talsec Native Plugin", code: 4)
44
+ }
45
+ let isProd = talsecConfig["isProd"] as? Bool ?? true
46
+
47
+ let config = TalsecConfig(appBundleIds: [appBundleIds], appTeamId: appTeamId, watcherMailAddress: watcherMailAddress, isProd: isProd)
48
+ Talsec.start(config: config)
49
+ }
50
+ }
51
+
52
+ extension SecurityThreatCenter: SecurityThreatHandler {
53
+
54
+ static let threatEventMap: [String: String] = [
55
+ "missingSecureEnclave": "secureHardwareNotAvailable",
56
+ "device binding": "deviceBinding",
57
+ ]
58
+
59
+ public func threatDetected(_ securityThreat: TalsecRuntime.SecurityThreat) {
60
+ let threatName = SecurityThreatCenter.threatEventMap[securityThreat.rawValue] ?? securityThreat.rawValue
61
+ if (threatName == "passcodeChange") {
62
+ return
63
+ }
64
+ FreeraspPlugin.shared!.notifyListeners(threatName, data: [:])
65
+ }
66
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>AvailableLibraries</key>
6
+ <array>
7
+ <dict>
8
+ <key>LibraryIdentifier</key>
9
+ <string>ios-arm64_x86_64-simulator</string>
10
+ <key>LibraryPath</key>
11
+ <string>TalsecRuntime.framework</string>
12
+ <key>SupportedArchitectures</key>
13
+ <array>
14
+ <string>arm64</string>
15
+ <string>x86_64</string>
16
+ </array>
17
+ <key>SupportedPlatform</key>
18
+ <string>ios</string>
19
+ <key>SupportedPlatformVariant</key>
20
+ <string>simulator</string>
21
+ </dict>
22
+ <dict>
23
+ <key>LibraryIdentifier</key>
24
+ <string>ios-arm64</string>
25
+ <key>LibraryPath</key>
26
+ <string>TalsecRuntime.framework</string>
27
+ <key>SupportedArchitectures</key>
28
+ <array>
29
+ <string>arm64</string>
30
+ </array>
31
+ <key>SupportedPlatform</key>
32
+ <string>ios</string>
33
+ </dict>
34
+ </array>
35
+ <key>CFBundlePackageType</key>
36
+ <string>XFWK</string>
37
+ <key>XCFrameworkFormatVersion</key>
38
+ <string>1.0</string>
39
+ </dict>
40
+ </plist>
@@ -0,0 +1,14 @@
1
+ //
2
+ // CryptoBridgingHeader.h
3
+ // Talsec
4
+ //
5
+ // Created by Jakub Mejtský on 05/08/2019.
6
+ // Copyright © 2019 AHEAD iTec, s.r.o. All rights reserved.
7
+ //
8
+
9
+ #ifndef Crypto_h
10
+ #define Crypto_h
11
+
12
+ #import <CommonCrypto/CommonCrypto.h>
13
+
14
+ #endif /* Crypto_h */
@@ -0,0 +1,25 @@
1
+ //
2
+ // CurlWrapper.h
3
+ // Talsec
4
+ //
5
+ // Created by Jakub Mejtský on 23/07/2019.
6
+ // Copyright © 2019 AHEAD iTec, s.r.o. All rights reserved.
7
+ //
8
+
9
+ #ifndef CurlWrapper_h
10
+ #define CurlWrapper_h
11
+
12
+ #include "curl.h"
13
+ #include <stdio.h>
14
+ #include <stdlib.h>
15
+ #include <sys/sysctl.h>
16
+ #include <unistd.h>
17
+ #include <string.h>
18
+
19
+ struct csYOEBgTUKWQ {
20
+ char *memory;
21
+ size_t size;
22
+ CURLcode ret;
23
+ };
24
+
25
+ #endif /* CurlWrapper_h */