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.
- package/CHANGELOG.md +71 -0
- package/CapacitorFreerasp.podspec +1 -1
- package/README.md +8 -8
- package/android/build.gradle +1 -1
- package/android/proguard-rules.pro +23 -0
- package/android/src/main/java/com/aheaditec/freerasp/FreeraspPlugin.kt +39 -18
- package/android/src/main/java/com/aheaditec/freerasp/ScreenProtector.kt +24 -2
- package/android/src/main/java/com/aheaditec/freerasp/ThreatHandler.kt +36 -18
- package/android/src/main/java/com/aheaditec/freerasp/events/BaseRaspEvent.kt +7 -0
- package/android/src/main/java/com/aheaditec/freerasp/events/RaspExecutionStateEvent.kt +22 -0
- package/android/src/main/java/com/aheaditec/freerasp/events/ThreatEvent.kt +69 -0
- package/android/src/main/java/com/aheaditec/freerasp/models/CapSuspiciousAppInfo.kt +1 -0
- package/android/src/main/java/com/aheaditec/freerasp/utils/Extensions.kt +1 -0
- package/android/src/main/java/com/aheaditec/freerasp/utils/RandomGenerator.kt +24 -0
- package/android/src/main/java/com/aheaditec/freerasp/utils/Utils.kt +3 -5
- package/dist/esm/api/listeners/raspExecutionState.d.ts +2 -0
- package/dist/esm/api/listeners/raspExecutionState.js +23 -0
- package/dist/esm/api/listeners/raspExecutionState.js.map +1 -0
- package/dist/esm/api/listeners/threat.d.ts +2 -0
- package/dist/esm/api/listeners/threat.js +84 -0
- package/dist/esm/api/listeners/threat.js.map +1 -0
- package/dist/esm/api/methods/capacitor.d.ts +4 -0
- package/dist/esm/api/methods/capacitor.js +11 -0
- package/dist/esm/api/methods/capacitor.js.map +1 -0
- package/dist/esm/api/methods/native.d.ts +6 -0
- package/dist/esm/api/methods/native.js +32 -0
- package/dist/esm/api/methods/native.js.map +1 -0
- package/dist/esm/api/nativeModules.d.ts +2 -0
- package/dist/esm/api/nativeModules.js +3 -0
- package/dist/esm/api/nativeModules.js.map +1 -0
- package/dist/esm/channels/raspExecutionState.d.ts +3 -0
- package/dist/esm/channels/raspExecutionState.js +27 -0
- package/dist/esm/channels/raspExecutionState.js.map +1 -0
- package/dist/esm/channels/threat.d.ts +3 -0
- package/dist/esm/channels/threat.js +34 -0
- package/dist/esm/channels/threat.js.map +1 -0
- package/dist/esm/index.d.ts +7 -12
- package/dist/esm/index.js +7 -158
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models/raspExecutionState.d.ts +6 -0
- package/dist/esm/models/raspExecutionState.js +10 -0
- package/dist/esm/models/raspExecutionState.js.map +1 -0
- package/dist/esm/models/threat.d.ts +26 -0
- package/dist/esm/{definitions.js → models/threat.js} +7 -3
- package/dist/esm/models/threat.js.map +1 -0
- package/dist/esm/{definitions.d.ts → types/types.d.ts} +37 -44
- package/dist/esm/types/types.js +2 -0
- package/dist/esm/types/types.js.map +1 -0
- package/dist/esm/utils/malware.d.ts +3 -0
- package/dist/esm/utils/malware.js +22 -0
- package/dist/esm/utils/malware.js.map +1 -0
- package/dist/esm/utils/utils.d.ts +3 -0
- package/dist/esm/utils/utils.js +12 -0
- package/dist/esm/utils/utils.js.map +1 -0
- package/dist/plugin.cjs.js +153 -78
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +153 -78
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/FreeraspPlugin.m +2 -0
- package/ios/Plugin/FreeraspPlugin.swift +50 -75
- package/ios/Plugin/Info.plist +1 -1
- package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeDirectory +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeResources +100 -298
- package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeSignature +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +7 -2
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curl.h +380 -281
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/curlver.h +5 -6
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/easy.h +4 -4
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/header.h +1 -1
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/mprintf.h +11 -4
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/multi.h +62 -22
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/options.h +2 -2
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/system.h +76 -164
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/urlapi.h +5 -4
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/websockets.h +17 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +233 -528
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +7 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +7 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +14 -4
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curl.h +380 -281
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/curlver.h +5 -6
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/easy.h +4 -4
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/header.h +1 -1
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/mprintf.h +11 -4
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/multi.h +62 -22
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/options.h +2 -2
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/system.h +76 -164
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/typecheck-gcc.h +947 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/urlapi.h +5 -4
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/websockets.h +17 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +233 -528
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +7 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +233 -528
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +7 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +7 -3
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
- package/ios/Plugin/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +56 -45
- package/ios/Plugin/models/RaspExecutionStates.swift +15 -0
- package/ios/Plugin/models/SecurityThreat.swift +40 -0
- package/ios/Plugin/utils/EventIdentifiers.swift +17 -0
- package/ios/Plugin/utils/RandomGenerator.swift +23 -0
- package/ios/Plugin/utils/Utils.swift +32 -0
- package/package.json +15 -10
- package/android/src/main/java/com/aheaditec/freerasp/Threat.kt +0 -58
- package/dist/esm/definitions.js.map +0 -1
- package/dist/esm/utils.d.ts +0 -2
- package/dist/esm/utils.js +0 -8
- package/dist/esm/utils.js.map +0 -1
- package/ios/Plugin/TalsecRuntime.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
addListener(listener: string, callback: (event: any) => void): any;
|
|
1
|
+
export interface TalsecPlugin {
|
|
3
2
|
talsecStart(options: {
|
|
4
|
-
config:
|
|
3
|
+
config: TalsecConfig;
|
|
5
4
|
}): Promise<{
|
|
6
5
|
started: boolean;
|
|
7
6
|
}>;
|
|
7
|
+
addListener(listner: string, callback: any): any;
|
|
8
8
|
onInvalidCallback(): void;
|
|
9
9
|
getThreatIdentifiers(): Promise<{
|
|
10
10
|
ids: number[];
|
|
@@ -12,15 +12,21 @@ export interface FreeraspPlugin {
|
|
|
12
12
|
getThreatChannelData(): Promise<{
|
|
13
13
|
ids: [string, string, string];
|
|
14
14
|
}>;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
getRaspExecutionStateIdentifiers(): Promise<{
|
|
16
|
+
ids: number[];
|
|
17
|
+
}>;
|
|
18
|
+
getRaspExecutionStateChannelData(): Promise<{
|
|
19
|
+
ids: [string, string];
|
|
20
|
+
}>;
|
|
21
|
+
storeExternalId(options: {
|
|
22
|
+
data: string;
|
|
17
23
|
}): Promise<{
|
|
18
24
|
result: boolean;
|
|
19
25
|
}>;
|
|
20
|
-
|
|
26
|
+
addToWhitelist(options: {
|
|
21
27
|
packageName: string;
|
|
22
28
|
}): Promise<{
|
|
23
|
-
result:
|
|
29
|
+
result: boolean;
|
|
24
30
|
}>;
|
|
25
31
|
blockScreenCapture(options: {
|
|
26
32
|
enable: boolean;
|
|
@@ -30,46 +36,48 @@ export interface FreeraspPlugin {
|
|
|
30
36
|
isScreenCaptureBlocked(): Promise<{
|
|
31
37
|
result: boolean;
|
|
32
38
|
}>;
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
getAppIcon(options: {
|
|
40
|
+
packageName: string;
|
|
35
41
|
}): Promise<{
|
|
36
|
-
result:
|
|
42
|
+
result: string;
|
|
37
43
|
}>;
|
|
38
44
|
}
|
|
39
|
-
export
|
|
40
|
-
androidConfig?:
|
|
41
|
-
iosConfig?:
|
|
45
|
+
export type TalsecConfig = {
|
|
46
|
+
androidConfig?: TalsecAndroidConfig;
|
|
47
|
+
iosConfig?: TalsecIosConfig;
|
|
42
48
|
watcherMail: string;
|
|
43
49
|
isProd?: boolean;
|
|
50
|
+
killOnBypass?: boolean;
|
|
44
51
|
};
|
|
45
|
-
export
|
|
52
|
+
export type TalsecAndroidConfig = {
|
|
46
53
|
packageName: string;
|
|
47
54
|
certificateHashes: string[];
|
|
48
55
|
supportedAlternativeStores?: string[];
|
|
49
|
-
malwareConfig?:
|
|
56
|
+
malwareConfig?: TalsecMalwareConfig;
|
|
50
57
|
};
|
|
51
|
-
export
|
|
58
|
+
export type TalsecIosConfig = {
|
|
52
59
|
appBundleId: string;
|
|
53
60
|
appTeamId: string;
|
|
54
61
|
};
|
|
55
|
-
export
|
|
62
|
+
export type TalsecMalwareConfig = {
|
|
56
63
|
blacklistedHashes?: string[];
|
|
57
64
|
blacklistedPackageNames?: string[];
|
|
58
65
|
suspiciousPermissions?: string[][];
|
|
59
66
|
whitelistedInstallationSources?: string[];
|
|
60
67
|
};
|
|
61
|
-
export
|
|
68
|
+
export type SuspiciousAppInfo = {
|
|
62
69
|
packageInfo: PackageInfo;
|
|
63
70
|
reason: string;
|
|
71
|
+
permissions?: string[];
|
|
64
72
|
};
|
|
65
|
-
export
|
|
73
|
+
export type PackageInfo = {
|
|
66
74
|
packageName: string;
|
|
67
75
|
appName?: string;
|
|
68
76
|
version?: string;
|
|
69
77
|
appIcon?: string;
|
|
70
78
|
installerStore?: string;
|
|
71
79
|
};
|
|
72
|
-
export
|
|
80
|
+
export type ThreatEventActions = {
|
|
73
81
|
privilegedAccess?: () => any;
|
|
74
82
|
debug?: () => any;
|
|
75
83
|
simulator?: () => any;
|
|
@@ -88,28 +96,13 @@ export declare type NativeEventEmitterActions = {
|
|
|
88
96
|
screenshot?: () => any;
|
|
89
97
|
screenRecording?: () => any;
|
|
90
98
|
multiInstance?: () => any;
|
|
99
|
+
timeSpoofing?: () => any;
|
|
100
|
+
locationSpoofing?: () => any;
|
|
101
|
+
unsecureWifi?: () => any;
|
|
102
|
+
};
|
|
103
|
+
export type NativeEvent = {
|
|
104
|
+
[key: string]: number | string[] | undefined;
|
|
105
|
+
};
|
|
106
|
+
export type RaspExecutionStateEventActions = {
|
|
107
|
+
allChecksFinished?: () => any;
|
|
91
108
|
};
|
|
92
|
-
export declare class Threat {
|
|
93
|
-
value: number;
|
|
94
|
-
static AppIntegrity: Threat;
|
|
95
|
-
static PrivilegedAccess: Threat;
|
|
96
|
-
static Debug: Threat;
|
|
97
|
-
static Hooks: Threat;
|
|
98
|
-
static Passcode: Threat;
|
|
99
|
-
static Simulator: Threat;
|
|
100
|
-
static SecureHardwareNotAvailable: Threat;
|
|
101
|
-
static SystemVPN: Threat;
|
|
102
|
-
static DeviceBinding: Threat;
|
|
103
|
-
static DeviceID: Threat;
|
|
104
|
-
static UnofficialStore: Threat;
|
|
105
|
-
static Overlay: Threat;
|
|
106
|
-
static ObfuscationIssues: Threat;
|
|
107
|
-
static DevMode: Threat;
|
|
108
|
-
static Malware: Threat;
|
|
109
|
-
static ADBEnabled: Threat;
|
|
110
|
-
static Screenshot: Threat;
|
|
111
|
-
static ScreenRecording: Threat;
|
|
112
|
-
static MultiInstance: Threat;
|
|
113
|
-
constructor(value: number);
|
|
114
|
-
static getValues(): Threat[];
|
|
115
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface TalsecPlugin {\n talsecStart(options: { config: TalsecConfig }): Promise<{ started: boolean }>;\n addListener(listner: string, callback: any): any;\n onInvalidCallback(): void;\n getThreatIdentifiers(): Promise<{ ids: number[] }>;\n getThreatChannelData(): Promise<{ ids: [string, string, string] }>;\n getRaspExecutionStateIdentifiers(): Promise<{ ids: number[] }>;\n getRaspExecutionStateChannelData(): Promise<{ ids: [string, string] }>;\n storeExternalId(options: { data: string }): Promise<{ result: boolean }>;\n addToWhitelist(options: { packageName: string }): Promise<{ result: boolean }>;\n blockScreenCapture(options: { enable: boolean }): Promise<{ result: boolean }>;\n isScreenCaptureBlocked(): Promise<{ result: boolean }>;\n getAppIcon(options: { packageName: string }): Promise<{ result: string }>;\n}\n\nexport type TalsecConfig = {\n androidConfig?: TalsecAndroidConfig;\n iosConfig?: TalsecIosConfig;\n watcherMail: string;\n isProd?: boolean;\n killOnBypass?: boolean;\n};\n\nexport type TalsecAndroidConfig = {\n packageName: string;\n certificateHashes: string[];\n supportedAlternativeStores?: string[];\n malwareConfig?: TalsecMalwareConfig;\n};\n\nexport type TalsecIosConfig = {\n appBundleId: string;\n appTeamId: string;\n};\n\nexport type TalsecMalwareConfig = {\n blacklistedHashes?: string[];\n blacklistedPackageNames?: string[];\n suspiciousPermissions?: string[][];\n whitelistedInstallationSources?: string[];\n};\n\nexport type SuspiciousAppInfo = {\n packageInfo: PackageInfo;\n reason: string;\n permissions?: string[];\n};\n\nexport type PackageInfo = {\n packageName: string;\n appName?: string;\n version?: string;\n appIcon?: string;\n installerStore?: string;\n};\n\nexport type ThreatEventActions = {\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 devMode?: () => any;\n systemVPN?: () => any;\n malware?: (suspiciousApps: SuspiciousAppInfo[]) => any;\n adbEnabled?: () => any;\n screenshot?: () => any;\n screenRecording?: () => any;\n multiInstance?: () => any;\n timeSpoofing?: () => any;\n locationSpoofing?: () => any;\n unsecureWifi?: () => any;\n};\n\nexport type NativeEvent = { [key: string]: number | string[] | undefined };\n\nexport type RaspExecutionStateEventActions = {\n allChecksFinished?: () => any;\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// parses base64-encoded malware data to SuspiciousAppInfo[]
|
|
2
|
+
export const parseMalwareData = async (data) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
try {
|
|
5
|
+
const suspiciousAppData = data.map((entry) => toSuspiciousAppInfo(entry));
|
|
6
|
+
resolve(suspiciousAppData);
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
reject(`Parsing app data failed: ${error}`);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export const toSuspiciousAppInfo = (base64Value) => {
|
|
14
|
+
const data = JSON.parse(atob(base64Value));
|
|
15
|
+
const packageInfo = data.packageInfo;
|
|
16
|
+
return {
|
|
17
|
+
packageInfo,
|
|
18
|
+
reason: data.reason,
|
|
19
|
+
permissions: data.permissions,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=malware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"malware.js","sourceRoot":"","sources":["../../../src/utils/malware.ts"],"names":[],"mappings":"AAEA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAc,EAAgC,EAAE;IACrF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC;YACH,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,WAAmB,EAAqB,EAAE;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,WAA0B,CAAC;IACpD,OAAO;QACL,WAAW;QACX,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,WAAW,EAAE,IAAI,CAAC,WAAW;KACT,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import type { PackageInfo, SuspiciousAppInfo } from '../types/types';\n\n// parses base64-encoded malware data to SuspiciousAppInfo[]\nexport const parseMalwareData = async (data: string[]): Promise<SuspiciousAppInfo[]> => {\n return new Promise((resolve, reject) => {\n try {\n const suspiciousAppData = data.map((entry) => toSuspiciousAppInfo(entry));\n resolve(suspiciousAppData);\n } catch (error: any) {\n reject(`Parsing app data failed: ${error}`);\n }\n });\n};\n\nexport const toSuspiciousAppInfo = (base64Value: string): SuspiciousAppInfo => {\n const data = JSON.parse(atob(base64Value));\n const packageInfo = data.packageInfo as PackageInfo;\n return {\n packageInfo,\n reason: data.reason,\n permissions: data.permissions,\n } as SuspiciousAppInfo;\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RaspExecutionState } from '../models/raspExecutionState';
|
|
2
|
+
import { Threat } from '../models/threat';
|
|
3
|
+
export const getThreatCount = () => {
|
|
4
|
+
return Threat.getValues().length;
|
|
5
|
+
};
|
|
6
|
+
export const getRaspExecutionStateCount = () => {
|
|
7
|
+
return RaspExecutionState.getValues().length;
|
|
8
|
+
};
|
|
9
|
+
export const itemsHaveType = (data, expectedType) => {
|
|
10
|
+
return data.every((item) => typeof item === expectedType);
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAW,EAAE;IACrD,OAAO,kBAAkB,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAW,EAAE,YAAoB,EAAW,EAAE;IAC1E,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,YAAY,CAAC,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import { RaspExecutionState } from '../models/raspExecutionState';\nimport { Threat } from '../models/threat';\n\nexport const getThreatCount = (): number => {\n return Threat.getValues().length;\n};\n\nexport const getRaspExecutionStateCount = (): number => {\n return RaspExecutionState.getValues().length;\n};\n\nexport const itemsHaveType = (data: any[], expectedType: string): boolean => {\n return data.every((item) => typeof item === expectedType);\n};\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -4,6 +4,38 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@capacitor/core');
|
|
6
6
|
|
|
7
|
+
const Talsec = core.registerPlugin('Freerasp', {});
|
|
8
|
+
|
|
9
|
+
const addToWhitelist = async (packageName) => {
|
|
10
|
+
if (core.Capacitor.getPlatform() === 'ios') {
|
|
11
|
+
return Promise.reject('Malware detection is not available on iOS');
|
|
12
|
+
}
|
|
13
|
+
const { result } = await Talsec.addToWhitelist({ packageName });
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
const blockScreenCapture = async (enable) => {
|
|
17
|
+
const { result } = await Talsec.blockScreenCapture({ enable });
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
const isScreenCaptureBlocked = async () => {
|
|
21
|
+
const { result } = await Talsec.isScreenCaptureBlocked();
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
const storeExternalId = async (data) => {
|
|
25
|
+
const { result } = await Talsec.storeExternalId({ data });
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
const getAppIcon = async (packageName) => {
|
|
29
|
+
if (core.Capacitor.getPlatform() === 'ios') {
|
|
30
|
+
return Promise.reject('App icon retrieval for Malware detection is not available on iOS');
|
|
31
|
+
}
|
|
32
|
+
const { result } = await Talsec.getAppIcon({ packageName });
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
const onInvalidCallback = () => {
|
|
36
|
+
Talsec.onInvalidCallback();
|
|
37
|
+
};
|
|
38
|
+
|
|
7
39
|
class Threat {
|
|
8
40
|
constructor(value) {
|
|
9
41
|
this.value = value;
|
|
@@ -21,7 +53,6 @@ class Threat {
|
|
|
21
53
|
this.SystemVPN,
|
|
22
54
|
this.DeviceBinding,
|
|
23
55
|
this.UnofficialStore,
|
|
24
|
-
this.Overlay,
|
|
25
56
|
this.ObfuscationIssues,
|
|
26
57
|
this.DevMode,
|
|
27
58
|
this.Malware,
|
|
@@ -29,6 +60,9 @@ class Threat {
|
|
|
29
60
|
this.Screenshot,
|
|
30
61
|
this.ScreenRecording,
|
|
31
62
|
this.MultiInstance,
|
|
63
|
+
this.TimeSpoofing,
|
|
64
|
+
this.LocationSpoofing,
|
|
65
|
+
this.UnsecureWifi,
|
|
32
66
|
]
|
|
33
67
|
: [
|
|
34
68
|
this.AppIntegrity,
|
|
@@ -58,7 +92,6 @@ Threat.SystemVPN = new Threat(0);
|
|
|
58
92
|
Threat.DeviceBinding = new Threat(0);
|
|
59
93
|
Threat.DeviceID = new Threat(0);
|
|
60
94
|
Threat.UnofficialStore = new Threat(0);
|
|
61
|
-
Threat.Overlay = new Threat(0);
|
|
62
95
|
Threat.ObfuscationIssues = new Threat(0);
|
|
63
96
|
Threat.DevMode = new Threat(0);
|
|
64
97
|
Threat.Malware = new Threat(0);
|
|
@@ -66,46 +99,64 @@ Threat.ADBEnabled = new Threat(0);
|
|
|
66
99
|
Threat.Screenshot = new Threat(0);
|
|
67
100
|
Threat.ScreenRecording = new Threat(0);
|
|
68
101
|
Threat.MultiInstance = new Threat(0);
|
|
102
|
+
Threat.TimeSpoofing = new Threat(0);
|
|
103
|
+
Threat.LocationSpoofing = new Threat(0);
|
|
104
|
+
Threat.UnsecureWifi = new Threat(0);
|
|
105
|
+
|
|
106
|
+
class RaspExecutionState {
|
|
107
|
+
constructor(value) {
|
|
108
|
+
this.value = value;
|
|
109
|
+
}
|
|
110
|
+
static getValues() {
|
|
111
|
+
return [this.AllChecksFinished];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
RaspExecutionState.AllChecksFinished = new RaspExecutionState(0);
|
|
69
115
|
|
|
70
116
|
const getThreatCount = () => {
|
|
71
117
|
return Threat.getValues().length;
|
|
72
118
|
};
|
|
73
|
-
const
|
|
74
|
-
return
|
|
119
|
+
const getRaspExecutionStateCount = () => {
|
|
120
|
+
return RaspExecutionState.getValues().length;
|
|
75
121
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const Freerasp = core.registerPlugin('Freerasp', {});
|
|
79
|
-
const onInvalidCallback = () => {
|
|
80
|
-
Freerasp.onInvalidCallback();
|
|
122
|
+
const itemsHaveType = (data, expectedType) => {
|
|
123
|
+
return data.every((item) => typeof item === expectedType);
|
|
81
124
|
};
|
|
125
|
+
|
|
82
126
|
const getThreatIdentifiers = async () => {
|
|
83
|
-
const { ids } = await
|
|
127
|
+
const { ids } = await Talsec.getThreatIdentifiers();
|
|
84
128
|
if (ids.length !== getThreatCount() || !itemsHaveType(ids, 'number')) {
|
|
85
|
-
|
|
129
|
+
console.error(`Threat count mismatch: Native ${ids.length} vs JS ${getThreatCount()}. Items are numbers: ${itemsHaveType(ids, 'number')}`);
|
|
130
|
+
// onInvalidCallback();
|
|
86
131
|
}
|
|
87
132
|
return ids;
|
|
88
133
|
};
|
|
89
134
|
const getThreatChannelData = async () => {
|
|
90
135
|
const dataLength = core.Capacitor.getPlatform() === 'ios' ? 2 : 3;
|
|
91
|
-
const { ids } = await
|
|
136
|
+
const { ids } = await Talsec.getThreatChannelData();
|
|
92
137
|
if (ids.length !== dataLength || !itemsHaveType(ids, 'string')) {
|
|
93
138
|
onInvalidCallback();
|
|
94
139
|
}
|
|
95
140
|
return ids;
|
|
96
141
|
};
|
|
97
|
-
const
|
|
142
|
+
const prepareThreatMapping = async () => {
|
|
98
143
|
const newValues = await getThreatIdentifiers();
|
|
99
144
|
const threats = Threat.getValues();
|
|
100
|
-
|
|
101
|
-
threat
|
|
102
|
-
|
|
145
|
+
try {
|
|
146
|
+
threats.map((threat, index) => {
|
|
147
|
+
threat.value = newValues[index];
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
console.error('Could not map Talsec threats', err);
|
|
152
|
+
}
|
|
103
153
|
};
|
|
154
|
+
|
|
104
155
|
// parses base64-encoded malware data to SuspiciousAppInfo[]
|
|
105
156
|
const parseMalwareData = async (data) => {
|
|
106
157
|
return new Promise((resolve, reject) => {
|
|
107
158
|
try {
|
|
108
|
-
const suspiciousAppData = data.map(entry => toSuspiciousAppInfo(entry));
|
|
159
|
+
const suspiciousAppData = data.map((entry) => toSuspiciousAppInfo(entry));
|
|
109
160
|
resolve(suspiciousAppData);
|
|
110
161
|
}
|
|
111
162
|
catch (error) {
|
|
@@ -116,70 +167,84 @@ const parseMalwareData = async (data) => {
|
|
|
116
167
|
const toSuspiciousAppInfo = (base64Value) => {
|
|
117
168
|
const data = JSON.parse(atob(base64Value));
|
|
118
169
|
const packageInfo = data.packageInfo;
|
|
119
|
-
return {
|
|
170
|
+
return {
|
|
171
|
+
packageInfo,
|
|
172
|
+
reason: data.reason,
|
|
173
|
+
permissions: data.permissions,
|
|
174
|
+
};
|
|
120
175
|
};
|
|
121
|
-
|
|
176
|
+
|
|
177
|
+
const registerThreatListener = async (config) => {
|
|
122
178
|
const [channel, key, malwareKey] = await getThreatChannelData();
|
|
123
|
-
await
|
|
124
|
-
await
|
|
125
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
126
|
-
if (event[key]
|
|
179
|
+
await prepareThreatMapping();
|
|
180
|
+
await Talsec.addListener(channel, async (event) => {
|
|
181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
182
|
+
if (event[key] == undefined) {
|
|
127
183
|
onInvalidCallback();
|
|
128
184
|
}
|
|
129
185
|
switch (event[key]) {
|
|
130
186
|
case Threat.PrivilegedAccess.value:
|
|
131
|
-
(_a =
|
|
187
|
+
(_a = config.privilegedAccess) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
132
188
|
break;
|
|
133
189
|
case Threat.Debug.value:
|
|
134
|
-
(_b =
|
|
190
|
+
(_b = config.debug) === null || _b === void 0 ? void 0 : _b.call(config);
|
|
135
191
|
break;
|
|
136
192
|
case Threat.Simulator.value:
|
|
137
|
-
(_c =
|
|
193
|
+
(_c = config.simulator) === null || _c === void 0 ? void 0 : _c.call(config);
|
|
138
194
|
break;
|
|
139
195
|
case Threat.AppIntegrity.value:
|
|
140
|
-
(_d =
|
|
196
|
+
(_d = config.appIntegrity) === null || _d === void 0 ? void 0 : _d.call(config);
|
|
141
197
|
break;
|
|
142
198
|
case Threat.UnofficialStore.value:
|
|
143
|
-
(_e =
|
|
199
|
+
(_e = config.unofficialStore) === null || _e === void 0 ? void 0 : _e.call(config);
|
|
144
200
|
break;
|
|
145
201
|
case Threat.Hooks.value:
|
|
146
|
-
(_f =
|
|
202
|
+
(_f = config.hooks) === null || _f === void 0 ? void 0 : _f.call(config);
|
|
147
203
|
break;
|
|
148
204
|
case Threat.DeviceBinding.value:
|
|
149
|
-
(_g =
|
|
205
|
+
(_g = config.deviceBinding) === null || _g === void 0 ? void 0 : _g.call(config);
|
|
150
206
|
break;
|
|
151
207
|
case Threat.Passcode.value:
|
|
152
|
-
(_h =
|
|
208
|
+
(_h = config.passcode) === null || _h === void 0 ? void 0 : _h.call(config);
|
|
153
209
|
break;
|
|
154
210
|
case Threat.SecureHardwareNotAvailable.value:
|
|
155
|
-
(_j =
|
|
211
|
+
(_j = config.secureHardwareNotAvailable) === null || _j === void 0 ? void 0 : _j.call(config);
|
|
156
212
|
break;
|
|
157
213
|
case Threat.ObfuscationIssues.value:
|
|
158
|
-
(_k =
|
|
214
|
+
(_k = config.obfuscationIssues) === null || _k === void 0 ? void 0 : _k.call(config);
|
|
159
215
|
break;
|
|
160
216
|
case Threat.DeviceID.value:
|
|
161
|
-
(_l =
|
|
217
|
+
(_l = config.deviceID) === null || _l === void 0 ? void 0 : _l.call(config);
|
|
162
218
|
break;
|
|
163
219
|
case Threat.DevMode.value:
|
|
164
|
-
(_m =
|
|
220
|
+
(_m = config.devMode) === null || _m === void 0 ? void 0 : _m.call(config);
|
|
165
221
|
break;
|
|
166
222
|
case Threat.SystemVPN.value:
|
|
167
|
-
(_o =
|
|
223
|
+
(_o = config.systemVPN) === null || _o === void 0 ? void 0 : _o.call(config);
|
|
168
224
|
break;
|
|
169
225
|
case Threat.Malware.value:
|
|
170
|
-
(_p =
|
|
226
|
+
(_p = config.malware) === null || _p === void 0 ? void 0 : _p.call(config, await parseMalwareData(event[malwareKey]));
|
|
171
227
|
break;
|
|
172
228
|
case Threat.ADBEnabled.value:
|
|
173
|
-
(_q =
|
|
229
|
+
(_q = config.adbEnabled) === null || _q === void 0 ? void 0 : _q.call(config);
|
|
174
230
|
break;
|
|
175
231
|
case Threat.Screenshot.value:
|
|
176
|
-
(_r =
|
|
232
|
+
(_r = config.screenshot) === null || _r === void 0 ? void 0 : _r.call(config);
|
|
177
233
|
break;
|
|
178
234
|
case Threat.ScreenRecording.value:
|
|
179
|
-
(_s =
|
|
235
|
+
(_s = config.screenRecording) === null || _s === void 0 ? void 0 : _s.call(config);
|
|
180
236
|
break;
|
|
181
237
|
case Threat.MultiInstance.value:
|
|
182
|
-
(_t =
|
|
238
|
+
(_t = config.multiInstance) === null || _t === void 0 ? void 0 : _t.call(config);
|
|
239
|
+
break;
|
|
240
|
+
case Threat.TimeSpoofing.value:
|
|
241
|
+
(_u = config.timeSpoofing) === null || _u === void 0 ? void 0 : _u.call(config);
|
|
242
|
+
break;
|
|
243
|
+
case Threat.LocationSpoofing.value:
|
|
244
|
+
(_v = config.locationSpoofing) === null || _v === void 0 ? void 0 : _v.call(config);
|
|
245
|
+
break;
|
|
246
|
+
case Threat.UnsecureWifi.value:
|
|
247
|
+
(_w = config.unsecureWifi) === null || _w === void 0 ? void 0 : _w.call(config);
|
|
183
248
|
break;
|
|
184
249
|
default:
|
|
185
250
|
onInvalidCallback();
|
|
@@ -187,55 +252,65 @@ const setThreatListeners = async (callbacks) => {
|
|
|
187
252
|
}
|
|
188
253
|
});
|
|
189
254
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
try {
|
|
196
|
-
const { started } = await Freerasp.talsecStart({ config });
|
|
197
|
-
return started;
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
console.error(`${e.code}: ${e.message}`);
|
|
201
|
-
return Promise.reject(`${e.code}: ${e.message}`);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
const addToWhitelist = async (packageName) => {
|
|
205
|
-
if (core.Capacitor.getPlatform() === 'ios') {
|
|
206
|
-
return Promise.reject('Malware detection not available on iOS');
|
|
255
|
+
|
|
256
|
+
const getRaspExecutionStateIdentifiers = async () => {
|
|
257
|
+
const { ids } = await Talsec.getRaspExecutionStateIdentifiers();
|
|
258
|
+
if (ids.length !== getRaspExecutionStateCount() || !itemsHaveType(ids, 'number')) {
|
|
259
|
+
onInvalidCallback();
|
|
207
260
|
}
|
|
208
|
-
|
|
209
|
-
return result;
|
|
261
|
+
return ids;
|
|
210
262
|
};
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
263
|
+
const getRaspExecutionStateChannelData = async () => {
|
|
264
|
+
const dataLength = 2;
|
|
265
|
+
const { ids } = await Talsec.getRaspExecutionStateChannelData();
|
|
266
|
+
if (ids.length !== dataLength || !itemsHaveType(ids, 'string')) {
|
|
267
|
+
onInvalidCallback();
|
|
214
268
|
}
|
|
215
|
-
|
|
216
|
-
return result;
|
|
269
|
+
return ids;
|
|
217
270
|
};
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
|
|
271
|
+
const prepareRaspExecutionStateMapping = async () => {
|
|
272
|
+
const newValues = await getRaspExecutionStateIdentifiers();
|
|
273
|
+
const threats = RaspExecutionState.getValues();
|
|
274
|
+
threats.map((threat, index) => {
|
|
275
|
+
threat.value = newValues[index];
|
|
276
|
+
});
|
|
221
277
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
278
|
+
|
|
279
|
+
const registerRaspExecutionStateListener = async (config) => {
|
|
280
|
+
const [channel, key] = await getRaspExecutionStateChannelData();
|
|
281
|
+
await prepareRaspExecutionStateMapping();
|
|
282
|
+
await Talsec.addListener(channel, async (event) => {
|
|
283
|
+
var _a;
|
|
284
|
+
if (event[key] == undefined) {
|
|
285
|
+
onInvalidCallback();
|
|
286
|
+
}
|
|
287
|
+
switch (event[key]) {
|
|
288
|
+
case RaspExecutionState.AllChecksFinished.value:
|
|
289
|
+
(_a = config.allChecksFinished) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
290
|
+
break;
|
|
291
|
+
default:
|
|
292
|
+
onInvalidCallback();
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
225
296
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
297
|
+
|
|
298
|
+
const startFreeRASP = async (config, actions, raspExecutionStateActions) => {
|
|
299
|
+
await registerThreatListener(actions);
|
|
300
|
+
if (raspExecutionStateActions) {
|
|
301
|
+
await registerRaspExecutionStateListener(raspExecutionStateActions);
|
|
302
|
+
}
|
|
303
|
+
return Talsec.talsecStart({ config });
|
|
229
304
|
};
|
|
230
305
|
|
|
231
|
-
exports.
|
|
232
|
-
exports.Threat = Threat;
|
|
306
|
+
exports.abortApp = onInvalidCallback;
|
|
233
307
|
exports.addToWhitelist = addToWhitelist;
|
|
234
308
|
exports.blockScreenCapture = blockScreenCapture;
|
|
235
309
|
exports.getAppIcon = getAppIcon;
|
|
236
310
|
exports.isScreenCaptureBlocked = isScreenCaptureBlocked;
|
|
237
|
-
exports.
|
|
238
|
-
exports.
|
|
311
|
+
exports.onInvalidCallback = onInvalidCallback;
|
|
312
|
+
exports.registerRaspExecutionStateListener = registerRaspExecutionStateListener;
|
|
313
|
+
exports.registerThreatListener = registerThreatListener;
|
|
239
314
|
exports.startFreeRASP = startFreeRASP;
|
|
240
315
|
exports.storeExternalId = storeExternalId;
|
|
241
316
|
//# sourceMappingURL=plugin.cjs.js.map
|