react-native-trustdevice 0.1.2 → 0.1.3
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/android/build.gradle +38 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/trustdevice/TrustdeviceModule.java +71 -0
- package/android/src/main/java/com/trustdevice/TrustdevicePackage.java +31 -0
- package/android/src/main/java/com/trustdevice/utils/TDUniRiskUtils.java +195 -0
- package/package.json +1 -1
- package/src/TrustDevice.android.js +3 -36
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
buildscript {
|
|
3
|
+
repositories {
|
|
4
|
+
google()
|
|
5
|
+
mavenCentral()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
dependencies {
|
|
9
|
+
classpath("com.android.tools.build:gradle:4.1.3")
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
apply plugin: 'com.android.library'
|
|
14
|
+
|
|
15
|
+
android {
|
|
16
|
+
compileSdkVersion 34
|
|
17
|
+
|
|
18
|
+
defaultConfig {
|
|
19
|
+
minSdkVersion 21
|
|
20
|
+
targetSdkVersion 34
|
|
21
|
+
versionCode 1
|
|
22
|
+
versionName "1.0"
|
|
23
|
+
}
|
|
24
|
+
lintOptions {
|
|
25
|
+
abortOnError false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
repositories {
|
|
30
|
+
google()
|
|
31
|
+
mavenCentral()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
dependencies {
|
|
35
|
+
implementation 'com.facebook.react:react-native:+'
|
|
36
|
+
implementation 'com.trustdecision.android:mobrisk:4.3.5.1'
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
package com.trustdevice;
|
|
3
|
+
|
|
4
|
+
import androidx.annotation.NonNull;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.Promise;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
9
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
11
|
+
import com.trustdevice.utils.TDUniRiskUtils;
|
|
12
|
+
|
|
13
|
+
import java.util.HashMap;
|
|
14
|
+
|
|
15
|
+
import cn.tongdun.mobrisk.TDRisk;
|
|
16
|
+
import cn.tongdun.mobrisk.TDRiskCallback;
|
|
17
|
+
|
|
18
|
+
public class TrustdeviceModule extends ReactContextBaseJavaModule {
|
|
19
|
+
private final ReactApplicationContext reactContext;
|
|
20
|
+
|
|
21
|
+
public TrustdeviceModule(ReactApplicationContext reactContext) {
|
|
22
|
+
super(reactContext);
|
|
23
|
+
this.reactContext = reactContext;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@NonNull
|
|
27
|
+
@Override
|
|
28
|
+
public String getName() {
|
|
29
|
+
return "TrustDevice";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactMethod
|
|
33
|
+
public void initWithOptions(ReadableMap readableMap, Promise promise) {
|
|
34
|
+
if (readableMap != null) {
|
|
35
|
+
HashMap<String, Object> options = readableMap.toHashMap();
|
|
36
|
+
TDRisk.Builder builder = TDUniRiskUtils.mapToBuilder(options);
|
|
37
|
+
TDRisk.initWithOptions(this.reactContext.getApplicationContext(), builder);
|
|
38
|
+
promise.resolve(null);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
public void getBlackBox(Promise promise) {
|
|
44
|
+
try {
|
|
45
|
+
String blackBox = TDRisk.getBlackBox();
|
|
46
|
+
promise.resolve(blackBox);
|
|
47
|
+
} catch (Exception e) {
|
|
48
|
+
promise.reject("getBlackBox Error", e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactMethod
|
|
53
|
+
public void getBlackBoxAsync(Promise promise) {
|
|
54
|
+
try {
|
|
55
|
+
TDRisk.getBlackBoxAsync(new TDRiskCallback() {
|
|
56
|
+
@Override
|
|
57
|
+
public void onEvent(String blackbox) {
|
|
58
|
+
promise.resolve(blackbox);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
} catch (Exception e) {
|
|
62
|
+
promise.reject("getBlackBoxAsync Error", e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@ReactMethod
|
|
67
|
+
public void getSDKVersion(Promise promise) {
|
|
68
|
+
String sdkVersion = TDRisk.getSDKVersion();
|
|
69
|
+
promise.resolve(sdkVersion);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
package com.trustdevice;
|
|
3
|
+
|
|
4
|
+
import androidx.annotation.NonNull;
|
|
5
|
+
|
|
6
|
+
import java.util.Collections;
|
|
7
|
+
import java.util.List;
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.ReactPackage;
|
|
10
|
+
import com.facebook.react.bridge.NativeModule;
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
13
|
+
import com.facebook.react.bridge.JavaScriptModule;
|
|
14
|
+
public class TrustdevicePackage implements ReactPackage {
|
|
15
|
+
@NonNull
|
|
16
|
+
@Override
|
|
17
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
18
|
+
return List.<NativeModule>of(new TrustdeviceModule(reactContext));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Deprecated from RN 0.47
|
|
22
|
+
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
23
|
+
return Collections.emptyList();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@NonNull
|
|
27
|
+
@Override
|
|
28
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
29
|
+
return Collections.emptyList();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
package com.trustdevice.utils;
|
|
2
|
+
|
|
3
|
+
import android.text.TextUtils;
|
|
4
|
+
|
|
5
|
+
import java.util.Map;
|
|
6
|
+
|
|
7
|
+
import cn.tongdun.mobrisk.TDRisk;
|
|
8
|
+
|
|
9
|
+
public class TDUniRiskUtils {
|
|
10
|
+
///Mandatory Shared Configuration
|
|
11
|
+
static final String KEY_PARTNER = "partner";
|
|
12
|
+
static final String KEY_APPKEY = "appKey";
|
|
13
|
+
static final String KEY_APPNAME = "appName";
|
|
14
|
+
static final String KEY_COUNTRY = "country";
|
|
15
|
+
static final String KEY_DEBUG = "debug";
|
|
16
|
+
static final String KEY_TIME_LIMIT = "timeLimit";
|
|
17
|
+
static final String KEY_LOCATION = "location";
|
|
18
|
+
static final String KEY_COLLECT_LEVEL = "collectLevel";
|
|
19
|
+
|
|
20
|
+
///Android device fingerprint configuration
|
|
21
|
+
static final String KEY_FP_ANDROID_RUNNING_TASKS = "runningTasks";
|
|
22
|
+
static final String KEY_FP_ANDROID_SENSOR = "sensor";
|
|
23
|
+
static final String KEY_FP_ANDROID_READ_PHONE = "readPhone";
|
|
24
|
+
static final String KEY_FP_ANDROID_INSTALLPACKAGE_LIST = "installPackageList";
|
|
25
|
+
static final String KEY_FP_ANDROID_WIFIMAC = "wifiMac";
|
|
26
|
+
|
|
27
|
+
static final String KEY_FP_ANDROID_GOOGLE_AID = "googleAid";
|
|
28
|
+
|
|
29
|
+
///Android device Captcha configuration
|
|
30
|
+
static final String KEY_CAPTCHA_LANGUAGE = "language";
|
|
31
|
+
static final String KEY_CAPTCHA_TAPTOCLOSE = "tapToClose";
|
|
32
|
+
static final String KEY_CAPTCHA_NEEDSEQID = "needSeqid";
|
|
33
|
+
static final String KEY_CAPTCHA_HIDE_LOADHUD = "hideLoadHud";
|
|
34
|
+
static final String KEY_CAPTCHA_HIDE_WEBCLOSEBUTTON = "hideWebCloseButton";
|
|
35
|
+
static final String KEY_CAPTCHA_OPENLOG = "openLog";
|
|
36
|
+
static final String KEY_CAPTCHA_SKIP_CAPTCHA = "skipCaptcha";
|
|
37
|
+
static final String KEY_CAPTCHA_MFAID = "mfaId";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 转换configMap成builder
|
|
41
|
+
*
|
|
42
|
+
* @param configMap
|
|
43
|
+
* @return
|
|
44
|
+
*/
|
|
45
|
+
public static TDRisk.Builder mapToBuilder(Map configMap) {
|
|
46
|
+
TDRisk.Builder builder = null;
|
|
47
|
+
if (configMap == null)
|
|
48
|
+
return builder;
|
|
49
|
+
builder = new TDRisk.Builder();
|
|
50
|
+
if (configMap.containsKey(KEY_PARTNER)) {
|
|
51
|
+
builder.partnerCode((String) configMap.get(KEY_PARTNER));
|
|
52
|
+
}
|
|
53
|
+
if (configMap.containsKey(KEY_APPKEY)) {
|
|
54
|
+
builder.appKey((String) configMap.get(KEY_APPKEY));
|
|
55
|
+
}
|
|
56
|
+
if (configMap.containsKey(KEY_APPNAME)) {
|
|
57
|
+
builder.appName((String) configMap.get(KEY_APPNAME));
|
|
58
|
+
}
|
|
59
|
+
if (configMap.containsKey(KEY_COUNTRY)) {
|
|
60
|
+
String country = (String) configMap.get(KEY_COUNTRY);
|
|
61
|
+
if (!TextUtils.isEmpty(country)) {
|
|
62
|
+
builder.country(country.toUpperCase());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (configMap.containsKey(KEY_DEBUG)) {
|
|
66
|
+
Object debug = configMap.get(KEY_DEBUG);
|
|
67
|
+
if (debug != null) {
|
|
68
|
+
if (!(boolean) debug)
|
|
69
|
+
builder.disableDebugger();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (configMap.containsKey(KEY_TIME_LIMIT)) {
|
|
73
|
+
Object timeLimit = configMap.get(KEY_TIME_LIMIT);
|
|
74
|
+
if (timeLimit != null) {
|
|
75
|
+
builder.httpTimeOut(((int) timeLimit) * 1000);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (configMap.containsKey(KEY_LOCATION)) {
|
|
79
|
+
Object location = configMap.get(KEY_LOCATION);
|
|
80
|
+
if (location != null) {
|
|
81
|
+
if (!(boolean) location)
|
|
82
|
+
builder.disableGPS();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (configMap.containsKey(KEY_COLLECT_LEVEL)) {
|
|
86
|
+
String collectLevel = (String) configMap.get(KEY_COLLECT_LEVEL);
|
|
87
|
+
if ("M".equals(collectLevel)) {
|
|
88
|
+
builder.collectLevel(TDRisk.COLLECT_LEVEL_M);
|
|
89
|
+
} else if ("L".equals(collectLevel)) {
|
|
90
|
+
builder.collectLevel(TDRisk.COLLECT_LEVEL_L);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
///Android device fingerprint configuration
|
|
94
|
+
if (configMap.containsKey(KEY_FP_ANDROID_RUNNING_TASKS)) {
|
|
95
|
+
Object runningTasks = configMap.get(KEY_FP_ANDROID_RUNNING_TASKS);
|
|
96
|
+
if (runningTasks != null) {
|
|
97
|
+
if (!(boolean) runningTasks)
|
|
98
|
+
builder.disableRunningTasks();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (configMap.containsKey(KEY_FP_ANDROID_SENSOR)) {
|
|
102
|
+
Object sensor = configMap.get(KEY_FP_ANDROID_SENSOR);
|
|
103
|
+
if (sensor != null) {
|
|
104
|
+
if (!(boolean) sensor)
|
|
105
|
+
builder.disableSensor();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (configMap.containsKey(KEY_FP_ANDROID_READ_PHONE)) {
|
|
109
|
+
Object readPhone = configMap.get(KEY_FP_ANDROID_READ_PHONE);
|
|
110
|
+
if (readPhone != null) {
|
|
111
|
+
if (!(boolean) readPhone)
|
|
112
|
+
builder.disableReadPhone();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (configMap.containsKey(KEY_FP_ANDROID_INSTALLPACKAGE_LIST)) {
|
|
116
|
+
Object installPackageList = configMap.get(KEY_FP_ANDROID_INSTALLPACKAGE_LIST);
|
|
117
|
+
if (installPackageList != null) {
|
|
118
|
+
if (!(boolean) installPackageList)
|
|
119
|
+
builder.disableInstallPackageList();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (configMap.containsKey(KEY_FP_ANDROID_WIFIMAC)) {
|
|
123
|
+
Object wifiMac = configMap.get(KEY_FP_ANDROID_WIFIMAC);
|
|
124
|
+
if (wifiMac != null) {
|
|
125
|
+
if (!(boolean) wifiMac) {
|
|
126
|
+
builder.disableWifiMac();
|
|
127
|
+
} else {
|
|
128
|
+
builder.enableWifiMac();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (configMap.containsKey(KEY_FP_ANDROID_GOOGLE_AID)) {
|
|
133
|
+
Object googleAid = configMap.get(KEY_FP_ANDROID_GOOGLE_AID);
|
|
134
|
+
if (googleAid != null) {
|
|
135
|
+
if (!(boolean) googleAid) {
|
|
136
|
+
builder.disableGoogleAid();
|
|
137
|
+
} else {
|
|
138
|
+
builder.enableGoogleAid();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
///Android device Captcha configuration
|
|
143
|
+
if (configMap.containsKey(KEY_CAPTCHA_LANGUAGE)) {
|
|
144
|
+
Object languageObj = configMap.get(KEY_CAPTCHA_LANGUAGE);
|
|
145
|
+
if (languageObj != null) {
|
|
146
|
+
String languageStr = (String) languageObj;
|
|
147
|
+
if (!TextUtils.isEmpty(languageStr))
|
|
148
|
+
builder.language(Integer.parseInt(languageStr));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (configMap.containsKey(KEY_CAPTCHA_TAPTOCLOSE)) {
|
|
152
|
+
Object tapToCloseObj = configMap.get(KEY_CAPTCHA_TAPTOCLOSE);
|
|
153
|
+
if (tapToCloseObj != null) {
|
|
154
|
+
builder.tapToClose((Boolean) tapToCloseObj);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (configMap.containsKey(KEY_CAPTCHA_NEEDSEQID)) {
|
|
158
|
+
Object needSeqidObj = configMap.get(KEY_CAPTCHA_NEEDSEQID);
|
|
159
|
+
if (needSeqidObj != null) {
|
|
160
|
+
builder.needSeqId((Boolean) needSeqidObj);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (configMap.containsKey(KEY_CAPTCHA_HIDE_LOADHUD)) {
|
|
164
|
+
Object hideLoadHudObj = configMap.get(KEY_CAPTCHA_HIDE_LOADHUD);
|
|
165
|
+
if (hideLoadHudObj != null) {
|
|
166
|
+
builder.hideLoadHud((Boolean) hideLoadHudObj);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (configMap.containsKey(KEY_CAPTCHA_HIDE_WEBCLOSEBUTTON)) {
|
|
170
|
+
Object hideWebCloseButtonObj = configMap.get(KEY_CAPTCHA_HIDE_WEBCLOSEBUTTON);
|
|
171
|
+
if (hideWebCloseButtonObj != null) {
|
|
172
|
+
builder.hideWebCloseButton((Boolean) hideWebCloseButtonObj);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (configMap.containsKey(KEY_CAPTCHA_OPENLOG)) {
|
|
176
|
+
Object openLogObj = configMap.get(KEY_CAPTCHA_OPENLOG);
|
|
177
|
+
if (openLogObj != null) {
|
|
178
|
+
builder.openLog((Boolean) openLogObj);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (configMap.containsKey(KEY_CAPTCHA_SKIP_CAPTCHA)) {
|
|
182
|
+
Object skipCaptchaObj = configMap.get(KEY_CAPTCHA_SKIP_CAPTCHA);
|
|
183
|
+
if (skipCaptchaObj != null) {
|
|
184
|
+
builder.skipCaptcha((Boolean) skipCaptchaObj);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (configMap.containsKey(KEY_CAPTCHA_MFAID)) {
|
|
188
|
+
Object mfaIdObj = configMap.get(KEY_CAPTCHA_MFAID);
|
|
189
|
+
if (mfaIdObj != null) {
|
|
190
|
+
builder.mfaId((String) mfaIdObj);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return builder;
|
|
194
|
+
}
|
|
195
|
+
}
|
package/package.json
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var Count = requireNativeComponent('SwipeMenuListView', Counting);
|
|
6
|
-
var CountManager = NativeModules.SwipeMenuListView;
|
|
7
|
-
|
|
8
|
-
export default class Counting extends Component {
|
|
9
|
-
|
|
10
|
-
static defaultProps = {
|
|
11
|
-
text:'0',
|
|
12
|
-
fontProperty:{
|
|
13
|
-
fontSize:17,
|
|
14
|
-
textAlignment:'center',
|
|
15
|
-
boldSystem:false,
|
|
16
|
-
method:'Linear'
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static propTypes = {
|
|
22
|
-
text:PropTypes.string,
|
|
23
|
-
fontProperty:PropTypes.element,
|
|
24
|
-
onFinish:PropTypes.func
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
countingStart(start,end,duration){
|
|
29
|
-
CountManager.numberTimer(start,end,duration);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
render() {
|
|
33
|
-
return <Count {...this.props} onChange={this.props.onFinish}/>;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
import {NativeModules} from 'react-native';
|
|
3
|
+
const TrustDevice = NativeModules.TrustDevice;
|
|
4
|
+
var _default=exports.default=TrustDevice;
|