freerasp-react-native 3.3.1 → 3.6.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/README.md +17 -23
- package/android/build.gradle +3 -2
- package/android/gradle.properties +2 -1
- package/android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt +58 -48
- package/android/src/main/java/com/freeraspreactnative/FreeraspThreatHandler.kt +52 -0
- package/android/src/main/java/com/freeraspreactnative/Threat.kt +44 -0
- package/ios/FreeraspReactNative.m +8 -1
- package/ios/FreeraspReactNative.swift +82 -13
- package/ios/TalsecRuntime.xcframework/Info.plist +5 -5
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +2 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +142 -160
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +3 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +3 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +4 -4
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +142 -160
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +142 -160
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +3 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +3 -2
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
- package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +25 -25
- package/lib/commonjs/definitions.js +32 -0
- package/lib/commonjs/definitions.js.map +1 -0
- package/lib/commonjs/index.js +83 -20
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils.js +16 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/definitions.js +25 -0
- package/lib/module/definitions.js.map +1 -0
- package/lib/module/index.js +84 -21
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/definitions.d.ts +43 -0
- package/lib/typescript/definitions.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -32
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils.d.ts +3 -0
- package/lib/typescript/utils.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/definitions.ts +77 -0
- package/src/index.tsx +93 -60
- package/src/utils.ts +9 -0
- package/android/src/main/java/com/freeraspreactnative/FreeraspDeviceStateListener.kt +0 -25
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type TalsecConfig = {
|
|
2
|
+
androidConfig?: {
|
|
3
|
+
packageName: string;
|
|
4
|
+
certificateHashes: string[];
|
|
5
|
+
supportedAlternativeStores?: string[];
|
|
6
|
+
};
|
|
7
|
+
iosConfig?: {
|
|
8
|
+
appBundleId: string;
|
|
9
|
+
appTeamId: string;
|
|
10
|
+
};
|
|
11
|
+
watcherMail: string;
|
|
12
|
+
isProd?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type NativeEventEmitterActions = {
|
|
15
|
+
privilegedAccess?: () => any;
|
|
16
|
+
debug?: () => any;
|
|
17
|
+
simulator?: () => any;
|
|
18
|
+
appIntegrity?: () => any;
|
|
19
|
+
unofficialStore?: () => any;
|
|
20
|
+
hooks?: () => any;
|
|
21
|
+
deviceBinding?: () => any;
|
|
22
|
+
deviceID?: () => any;
|
|
23
|
+
passcode?: () => any;
|
|
24
|
+
secureHardwareNotAvailable?: () => any;
|
|
25
|
+
obfuscationIssues?: () => any;
|
|
26
|
+
};
|
|
27
|
+
export declare class Threat {
|
|
28
|
+
value: number;
|
|
29
|
+
static AppIntegrity: Threat;
|
|
30
|
+
static PrivilegedAccess: Threat;
|
|
31
|
+
static Debug: Threat;
|
|
32
|
+
static Hooks: Threat;
|
|
33
|
+
static Passcode: Threat;
|
|
34
|
+
static Simulator: Threat;
|
|
35
|
+
static SecureHardwareNotAvailable: Threat;
|
|
36
|
+
static DeviceBinding: Threat;
|
|
37
|
+
static DeviceID: Threat;
|
|
38
|
+
static UnofficialStore: Threat;
|
|
39
|
+
static ObfuscationIssues: Threat;
|
|
40
|
+
constructor(value: number);
|
|
41
|
+
static getValues(): Threat[];
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,CAAC,EAAE;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;QAC5B,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC;KACvC,CAAC;IACF,SAAS,CAAC,EAAE;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,GAAG,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC;IACrB,0BAA0B,CAAC,EAAE,MAAM,GAAG,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,GAAG,CAAC;CAC/B,CAAC;AAEF,qBAAa,MAAM;IACjB,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,YAAY,SAAiB;IACpC,MAAM,CAAC,gBAAgB,SAAiB;IACxC,MAAM,CAAC,KAAK,SAAiB;IAC7B,MAAM,CAAC,KAAK,SAAiB;IAC7B,MAAM,CAAC,QAAQ,SAAiB;IAChC,MAAM,CAAC,SAAS,SAAiB;IACjC,MAAM,CAAC,0BAA0B,SAAiB;IAClD,MAAM,CAAC,aAAa,SAAiB;IACrC,MAAM,CAAC,QAAQ,SAAiB;IAChC,MAAM,CAAC,eAAe,SAAiB;IACvC,MAAM,CAAC,iBAAiB,SAAiB;gBAE7B,KAAK,EAAE,MAAM;IAIzB,MAAM,CAAC,SAAS,IAAI,MAAM,EAAE;CA2B7B"}
|
|
@@ -1,37 +1,8 @@
|
|
|
1
|
-
type TalsecConfig
|
|
2
|
-
androidConfig?: {
|
|
3
|
-
packageName: string;
|
|
4
|
-
certificateHashes: string[];
|
|
5
|
-
supportedAlternativeStores?: string[];
|
|
6
|
-
};
|
|
7
|
-
iosConfig?: {
|
|
8
|
-
appBundleId: string;
|
|
9
|
-
appTeamId: string;
|
|
10
|
-
};
|
|
11
|
-
watcherMail: string;
|
|
12
|
-
isProd?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type NativeEventEmitterActions = {
|
|
15
|
-
privilegedAccess?: () => any;
|
|
16
|
-
debug?: () => any;
|
|
17
|
-
simulator?: () => any;
|
|
18
|
-
appIntegrity?: () => any;
|
|
19
|
-
unofficialStore?: () => any;
|
|
20
|
-
hooks?: () => any;
|
|
21
|
-
deviceBinding?: () => any;
|
|
22
|
-
deviceID?: () => any;
|
|
23
|
-
passcode?: () => any;
|
|
24
|
-
secureHardwareNotAvailable?: () => any;
|
|
25
|
-
obfuscationIssues?: () => any;
|
|
26
|
-
started?: () => any;
|
|
27
|
-
initializationError?: (reason: {
|
|
28
|
-
message: string;
|
|
29
|
-
}) => any;
|
|
30
|
-
};
|
|
1
|
+
import { type NativeEventEmitterActions, TalsecConfig } from './definitions';
|
|
31
2
|
declare const FreeraspReactNative: any;
|
|
32
|
-
export declare const setThreatListeners: <T extends NativeEventEmitterActions>(config: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>) => void
|
|
3
|
+
export declare const setThreatListeners: <T extends NativeEventEmitterActions>(config: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>) => Promise<void>;
|
|
33
4
|
export declare const removeThreatListeners: () => void;
|
|
34
|
-
export declare const talsecStart: (options: TalsecConfig) =>
|
|
5
|
+
export declare const talsecStart: (options: TalsecConfig) => Promise<string>;
|
|
35
6
|
export declare const useFreeRasp: <T extends NativeEventEmitterActions>(config: TalsecConfig, actions: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>) => void;
|
|
36
7
|
export default FreeraspReactNative;
|
|
37
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,yBAAyB,EAC9B,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAQ,mBAAmB,KAAkB,CAAC;AAqC9C,eAAO,MAAM,kBAAkB,mIA8C9B,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,IAExC,CAAC;AAEF,eAAO,MAAM,WAAW,YAAmB,YAAY,KAAG,QAAQ,MAAM,CAEvE,CAAC;AAEF,eAAO,MAAM,WAAW,gDACd,YAAY,qFAkBrB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,QAAO,MAEjC,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,GAAG,EAAE,eAAe,MAAM,YAE7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freerasp-react-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "React Native plugin for improving app security and threat monitoring on Android and iOS mobile devices.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type TalsecConfig = {
|
|
4
|
+
androidConfig?: {
|
|
5
|
+
packageName: string;
|
|
6
|
+
certificateHashes: string[];
|
|
7
|
+
supportedAlternativeStores?: string[];
|
|
8
|
+
};
|
|
9
|
+
iosConfig?: {
|
|
10
|
+
appBundleId: string;
|
|
11
|
+
appTeamId: string;
|
|
12
|
+
};
|
|
13
|
+
watcherMail: string;
|
|
14
|
+
isProd?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type NativeEventEmitterActions = {
|
|
18
|
+
privilegedAccess?: () => any;
|
|
19
|
+
debug?: () => any;
|
|
20
|
+
simulator?: () => any;
|
|
21
|
+
appIntegrity?: () => any;
|
|
22
|
+
unofficialStore?: () => any;
|
|
23
|
+
hooks?: () => any;
|
|
24
|
+
deviceBinding?: () => any;
|
|
25
|
+
deviceID?: () => any;
|
|
26
|
+
passcode?: () => any;
|
|
27
|
+
secureHardwareNotAvailable?: () => any;
|
|
28
|
+
obfuscationIssues?: () => any;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export class Threat {
|
|
32
|
+
value: number;
|
|
33
|
+
|
|
34
|
+
static AppIntegrity = new Threat(0);
|
|
35
|
+
static PrivilegedAccess = new Threat(0);
|
|
36
|
+
static Debug = new Threat(0);
|
|
37
|
+
static Hooks = new Threat(0);
|
|
38
|
+
static Passcode = new Threat(0);
|
|
39
|
+
static Simulator = new Threat(0);
|
|
40
|
+
static SecureHardwareNotAvailable = new Threat(0);
|
|
41
|
+
static DeviceBinding = new Threat(0);
|
|
42
|
+
static DeviceID = new Threat(0);
|
|
43
|
+
static UnofficialStore = new Threat(0);
|
|
44
|
+
static ObfuscationIssues = new Threat(0);
|
|
45
|
+
|
|
46
|
+
constructor(value: number) {
|
|
47
|
+
this.value = value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static getValues(): Threat[] {
|
|
51
|
+
return Platform.OS === 'android'
|
|
52
|
+
? [
|
|
53
|
+
this.AppIntegrity,
|
|
54
|
+
this.PrivilegedAccess,
|
|
55
|
+
this.Debug,
|
|
56
|
+
this.Hooks,
|
|
57
|
+
this.Passcode,
|
|
58
|
+
this.Simulator,
|
|
59
|
+
this.SecureHardwareNotAvailable,
|
|
60
|
+
this.DeviceBinding,
|
|
61
|
+
this.UnofficialStore,
|
|
62
|
+
this.ObfuscationIssues,
|
|
63
|
+
]
|
|
64
|
+
: [
|
|
65
|
+
this.AppIntegrity,
|
|
66
|
+
this.PrivilegedAccess,
|
|
67
|
+
this.Debug,
|
|
68
|
+
this.Hooks,
|
|
69
|
+
this.Passcode,
|
|
70
|
+
this.Simulator,
|
|
71
|
+
this.SecureHardwareNotAvailable,
|
|
72
|
+
this.DeviceBinding,
|
|
73
|
+
this.DeviceID,
|
|
74
|
+
this.UnofficialStore,
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -3,77 +3,104 @@ import {
|
|
|
3
3
|
EmitterSubscription,
|
|
4
4
|
NativeEventEmitter,
|
|
5
5
|
NativeModules,
|
|
6
|
-
Platform,
|
|
7
6
|
} from 'react-native';
|
|
7
|
+
import {
|
|
8
|
+
Threat,
|
|
9
|
+
type NativeEventEmitterActions,
|
|
10
|
+
TalsecConfig,
|
|
11
|
+
} from './definitions';
|
|
12
|
+
import { getThreatCount, itemsHaveType } from './utils';
|
|
13
|
+
|
|
14
|
+
const { FreeraspReactNative } = NativeModules;
|
|
15
|
+
|
|
16
|
+
const eventEmitter = new NativeEventEmitter(FreeraspReactNative);
|
|
17
|
+
let eventsListener: EmitterSubscription;
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
packageName: string;
|
|
12
|
-
certificateHashes: string[];
|
|
13
|
-
supportedAlternativeStores?: string[];
|
|
14
|
-
};
|
|
15
|
-
iosConfig?: {
|
|
16
|
-
appBundleId: string;
|
|
17
|
-
appTeamId: string;
|
|
18
|
-
};
|
|
19
|
-
watcherMail: string;
|
|
20
|
-
isProd?: boolean;
|
|
19
|
+
const onInvalidCallback = (): void => {
|
|
20
|
+
FreeraspReactNative.onInvalidCallback();
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
passcode?: () => any;
|
|
33
|
-
secureHardwareNotAvailable?: () => any;
|
|
34
|
-
obfuscationIssues?: () => any;
|
|
35
|
-
started?: () => any;
|
|
36
|
-
initializationError?: (reason: { message: string }) => any;
|
|
23
|
+
const getThreatIdentifiers = async (): Promise<number[]> => {
|
|
24
|
+
let identifiers = await FreeraspReactNative.getThreatIdentifiers();
|
|
25
|
+
if (
|
|
26
|
+
identifiers.length !== getThreatCount() ||
|
|
27
|
+
!itemsHaveType(identifiers, 'number')
|
|
28
|
+
) {
|
|
29
|
+
onInvalidCallback();
|
|
30
|
+
}
|
|
31
|
+
return identifiers;
|
|
37
32
|
};
|
|
38
33
|
|
|
39
|
-
const
|
|
34
|
+
const getThreatChannelData = async (): Promise<[string, string]> => {
|
|
35
|
+
let data = await FreeraspReactNative.getThreatChannelData();
|
|
36
|
+
if (data.length !== 2 || !itemsHaveType(data, 'string')) {
|
|
37
|
+
onInvalidCallback();
|
|
38
|
+
}
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
-
const
|
|
42
|
+
const prepareMapping = async (): Promise<void> => {
|
|
43
|
+
const newValues = await getThreatIdentifiers();
|
|
44
|
+
const threats = Threat.getValues();
|
|
45
|
+
|
|
46
|
+
threats.map((threat, index) => {
|
|
47
|
+
threat.value = newValues[index]!;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
43
50
|
|
|
44
|
-
export const setThreatListeners = <T extends NativeEventEmitterActions>(
|
|
51
|
+
export const setThreatListeners = async <T extends NativeEventEmitterActions>(
|
|
45
52
|
config: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>
|
|
46
53
|
) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
console.log('Talsec initialized.');
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
activeListeners.push(
|
|
54
|
-
eventEmitter.addListener(
|
|
55
|
-
'initializationError',
|
|
56
|
-
(e: { message: string }) => {
|
|
57
|
-
console.warn(
|
|
58
|
-
`Error during Talsec Native plugin initialization - ${e.message}`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
);
|
|
54
|
+
const [channel, key] = await getThreatChannelData();
|
|
55
|
+
await prepareMapping();
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
57
|
+
eventsListener = eventEmitter.addListener(channel, (event) => {
|
|
58
|
+
if (event[key] === undefined) {
|
|
59
|
+
onInvalidCallback();
|
|
67
60
|
}
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
switch (event[key]) {
|
|
62
|
+
case Threat.PrivilegedAccess.value:
|
|
63
|
+
config.privilegedAccess?.();
|
|
64
|
+
break;
|
|
65
|
+
case Threat.Debug.value:
|
|
66
|
+
config.debug?.();
|
|
67
|
+
break;
|
|
68
|
+
case Threat.Simulator.value:
|
|
69
|
+
config.simulator?.();
|
|
70
|
+
break;
|
|
71
|
+
case Threat.AppIntegrity.value:
|
|
72
|
+
config.appIntegrity?.();
|
|
73
|
+
break;
|
|
74
|
+
case Threat.UnofficialStore.value:
|
|
75
|
+
config.unofficialStore?.();
|
|
76
|
+
break;
|
|
77
|
+
case Threat.Hooks.value:
|
|
78
|
+
config.hooks?.();
|
|
79
|
+
break;
|
|
80
|
+
case Threat.DeviceBinding.value:
|
|
81
|
+
config.deviceBinding?.();
|
|
82
|
+
break;
|
|
83
|
+
case Threat.Passcode.value:
|
|
84
|
+
config.passcode?.();
|
|
85
|
+
break;
|
|
86
|
+
case Threat.SecureHardwareNotAvailable.value:
|
|
87
|
+
config.secureHardwareNotAvailable?.();
|
|
88
|
+
break;
|
|
89
|
+
case Threat.ObfuscationIssues.value:
|
|
90
|
+
config.obfuscationIssues?.();
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
onInvalidCallback();
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
70
97
|
};
|
|
71
98
|
|
|
72
|
-
export const removeThreatListeners = () => {
|
|
73
|
-
|
|
99
|
+
export const removeThreatListeners = (): void => {
|
|
100
|
+
eventsListener.remove();
|
|
74
101
|
};
|
|
75
102
|
|
|
76
|
-
export const talsecStart = (options: TalsecConfig):
|
|
103
|
+
export const talsecStart = async (options: TalsecConfig): Promise<string> => {
|
|
77
104
|
return FreeraspReactNative.talsecStart(options);
|
|
78
105
|
};
|
|
79
106
|
|
|
@@ -82,12 +109,18 @@ export const useFreeRasp = <T extends NativeEventEmitterActions>(
|
|
|
82
109
|
actions: T & Record<Exclude<keyof T, keyof NativeEventEmitterActions>, []>
|
|
83
110
|
) => {
|
|
84
111
|
useEffect(() => {
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
(async () => {
|
|
113
|
+
await setThreatListeners(actions);
|
|
114
|
+
let response = await talsecStart(config);
|
|
115
|
+
if (response !== 'freeRASP started') {
|
|
116
|
+
onInvalidCallback();
|
|
117
|
+
}
|
|
118
|
+
console.log(response);
|
|
87
119
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
120
|
+
return () => {
|
|
121
|
+
removeThreatListeners();
|
|
122
|
+
};
|
|
123
|
+
})();
|
|
91
124
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
92
125
|
}, []);
|
|
93
126
|
};
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Threat } from './definitions';
|
|
2
|
+
|
|
3
|
+
export const getThreatCount = (): number => {
|
|
4
|
+
return Threat.getValues().length;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const itemsHaveType = (data: any[], desidedType: string) => {
|
|
8
|
+
return data.every((item) => typeof item === desidedType);
|
|
9
|
+
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package com.freeraspreactnative
|
|
2
|
-
|
|
3
|
-
import com.aheaditec.talsec_security.security.api.ThreatListener
|
|
4
|
-
|
|
5
|
-
internal object FreeraspDeviceStateListener: ThreatListener.DeviceState {
|
|
6
|
-
|
|
7
|
-
internal var listener: DeviceStateListener? = null
|
|
8
|
-
|
|
9
|
-
override fun onUnlockedDeviceDetected() {
|
|
10
|
-
"unlockedDevice".let {
|
|
11
|
-
listener?.deviceStateChangeDetected("passcode")
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
override fun onHardwareBackedKeystoreNotAvailableDetected() {
|
|
16
|
-
"hardwareBackedKeystoreNotAvailable".let {
|
|
17
|
-
listener?.deviceStateChangeDetected("secureHardwareNotAvailable")
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
internal interface DeviceStateListener {
|
|
22
|
-
fun deviceStateChangeDetected(threatType: String)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|