react-native-trustdevice 0.1.1 → 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/README.md CHANGED
@@ -1,118 +1,394 @@
1
- [![npm version](https://badge.fury.io/js/react-native-blur.svg)](https://badge.fury.io/js/react-native-blur)
1
+ # Integrated Requirement
2
2
 
3
- ### React Native Counting
4
- Component implementation for Dynamic digital effect.<br>
3
+ ## Compliance Explanation
5
4
 
5
+ Please note that when integrating SDK products provided by the TrustDecision in the APP of your company:
6
6
 
7
- <img src='http://image18-c.poco.cn/mypoco/myphoto/20170303/17/18509322420170303172443095.gif?311x565_110' />
7
+ 1.1 According to the user's information protection regulations, before your users start the App for the first time and start collecting information, your company should fully inform the user of the purpose, method, and scope of collecting, using, and sharing the user's personal information with a third party through an interactive interface or design (such as a pop-up window of the privacy policy), and obtain the express consent of the end user.
8
8
 
9
- ### 用法
10
- 1. npm install react-native-counting --save
11
- 2. react-native link react-native-counting
9
+ 1.2 To provide business security and risk control services to your company, the TrustDecision SDK will collect, process, and use the identification information(IMEI/IDFA), AndroidID, IMSI, MEID, MAC address, SIM card serial number, device type, device model, system type, geographical location, login IP address, application list, running process, sensor information(light sensor, gravity sensor, magnetic field sensor, acceleration sensor, gyroscope sensor) and other device information of the user's device. To ensure compliance with your use of related services, the aforementioned privacy policy should cover the authorization of TrustDecision SDK to provide services and collect, process, and use relevant information. The following terms are for your reference. The specific expression can be determined by your company according to the overall framework and content of your privacy agreement:
12
10
 
13
- ### 注意
14
- Android暂时无法使用border相关的属性
11
+ <table border="1">
12
+ <tr>
13
+ <td style="background-color:#FAFAFA"><font size="2">TrustDecision SDK: For business security and risk control, our company uses the TrustDecision SDK. The SDK needs to obtain the information of your devices, such as (IMEI/IDFA), AndroidID, IMSI, MAC address, SIM card serial number, device type, device model, system type, geographic location, login IP address, application list, running process, sensor information(light sensor, gravity sensor, magnetic field sensor, acceleration sensor, gyroscope sensor) and other related device information, for fraud risk identification.</font></td>
14
+ </tr>
15
+ </table>
15
16
 
16
- ### 属性&&方法
17
- * text:String 默认显示的文字
18
- * fontProperty:object 传入一个对象</br>
19
- 1. fontSize:字体大小(Int)
20
- 2. textAlignment:center || left ||right 对齐方式(string)
21
- 3. boldSystem:是否加粗(bool)
22
- 4. method:动画方式(String) EaseInOut || EaseIn || EaseOut || Linear
23
- * textColor 文字底色(Colo)
24
- * onFinish 完成回调执行的方法(func)
17
+ **Privacy Protocol:** [https://www.trustdecision.com/legal/privacy-policy](https://www.trustdecision.com/legal/privacy-policy)
25
18
 
19
+ **Precautions**
26
20
 
27
- #### Counting:
21
+ When the installation starts for the first time, the SDK initialization is performed after the user agrees with the privacy agreement.
22
+ Avoid SDK initialization collection without the user agreeing to the privacy agreement, causing compliance risk accidents.
28
23
 
29
- ```javascript
30
- import React, { Component } from 'react';
31
- import Counting from 'react-native-counting';
32
- import {
33
- AppRegistry,
34
- StyleSheet,
35
- Text,
36
- View,
37
- TouchableOpacity
38
- } from 'react-native';
39
24
 
25
+ # Integrate Steps
40
26
 
27
+ ## Integrated SDK
41
28
 
42
- export default class nodeforum extends Component {
29
+ Execute in your react native project root directory
43
30
 
44
- constructor(props){
45
- super(props)
46
- this.state = {
47
- finshded:false
48
- }
49
- }
50
-
51
- _onPressButton(){
52
- this.counting.countingStart(0,5200.10,3000);
53
- this.setState({
54
- finshded:false
55
- })
56
- }
31
+ ```
32
+
33
+ npm install --save react-native-trustdevice@0.1.0
34
+
35
+ ```
36
+
37
+ ### Android
38
+
39
+ ### iOS
40
+
41
+ Update cocoapods
42
+
43
+ ```
44
+ npx pod-install
45
+ ```
46
+
47
+ ## Android permission application
48
+
49
+ Declare the following permissions in the AndroidManifest.xml file under the application module
50
+
51
+ ```xml
52
+ <manifest>
53
+ <!--Compulsory permissions-->
54
+ <uses-permission android:name="android.permission.INTERNET"/>
55
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
56
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
57
+
58
+ <!--The following permissions are optional. If this part of the authority is not declared, the acquisition of some device information will be abandoned, which will have a certain effect on data analysis and the accuracy of the fingerprint of the device fingerprint-->
59
+ <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
60
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
61
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
62
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
63
+ <!-- This permission is required for Android 11 and above to obtain the installation package list. Collecting the installation package list involves risk and compliance. Whether this permission is required is optional for the business party
64
+ select -->
65
+ <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
66
+ </manifest>
67
+ ```
68
+
69
+ Dynamic application permissions: Android 6.0 or above requires dynamic application permissions. Dynamic application permissions code must be placed before the initial plugin. The code example is as follows:
57
70
 
58
- _finish(){
59
- this.setState({
60
- finshded:true
61
- })
71
+ ```dart
72
+ //The following permissions are not required to be applied for,
73
+ //and can be selectively applied for according to business conditions
74
+ Future<void> _requestPermission() async {
75
+ Map<Permission, PermissionStatus> statuses = await [
76
+ Permission.location,
77
+ Permission.phone,
78
+ ].request();
62
79
  }
80
+ ```
81
+
82
+ ## Initialization
83
+
84
+
85
+ ## get TrustDevice Module
86
+
87
+
88
+ ```
89
+ const TrustDevice = NativeModules.TrustDevice;
90
+
91
+ ```
63
92
 
64
- render() {
93
+ **Sample Code**
65
94
 
66
- const fontProperty = {
67
- fontSize:35,
68
- textAlignment:'center',
69
- boldSystem:false,
70
- method:'Linear'
95
+ ```dart
96
+ import 'package:trustdevice_pro_plugin/trustdevice_pro_plugin.dart';
97
+ // ...
98
+
99
+ // Initialization
100
+ class _MyAppState extends State<MyApp> {
101
+ final _trustdeviceProPlugin = TrustdeviceProPlugin();
102
+ @override
103
+ void initState() {
104
+ super.initState();
105
+ _initWithOptions();
71
106
  }
72
- const { finshded } = this.state;
73
- return (
74
- <View style={styles.container}>
75
- <Counting style={styles.counting} text="0.00" ref={(ref) => this.counting = ref} fontProperty={fontProperty} textColor="white" onFinish={this._finish.bind(this)}/>
76
- <TouchableOpacity onPress={this._onPressButton.bind(this)} style={styles.button}>
77
- <Text>click Me</Text>
78
- </TouchableOpacity>
79
- <Text style={styles.isfinish}>{finshded?"finished":"dnf"}</Text>
80
- </View>
81
- );
107
+ //initialize the configuration
108
+ Future<void> _initWithOptions() async {
109
+ var options = {
110
+ "partner": "[Your partner]",
111
+ "appKey": "[Your appKey]",
112
+ "appName": "[Your appName]",
113
+ "country": "[Your country code]",
114
+ };
115
+ _trustdeviceProPlugin.initWithOptions(options);
82
116
  }
117
+ // ...
83
118
  }
84
119
 
85
- const styles = StyleSheet.create({
86
- container: {
87
- flex: 1,
88
- alignItems: 'center',
89
- },
90
- button:{
91
- marginTop:20,
92
- },
93
- counting:{
94
- marginTop:60,
95
- backgroundColor:'black',
96
- width:180,
97
- height:150,
98
- borderRadius:20,
99
- },
100
- isfinish:{
101
- marginTop:20,
102
- color:'red'
120
+
121
+ async function initWithOptions() {
122
+
123
+ var options = {
124
+ "partner": "[Your partner]",
125
+ "appKey": "[Your appKey]",
126
+ "appName": "[Your appName]",
127
+ "country": "[Your country code]",
128
+ "debug": false,
129
+ }
130
+
131
+ const isDebugMode = __DEV__;
132
+ // !!! If not set this parameter in DEBUG mode, the app will terminate
133
+ if (isDebugMode) {
134
+ options["debug"] = true;
135
+ }
136
+
137
+ TrustDevice.initWithOptions(options);
103
138
  }
104
-
105
- });
106
139
 
107
- AppRegistry.registerComponent('nodeforum', () => nodeforum);
140
+
108
141
  ```
109
142
 
110
- In this example, `Image` component will be blurred, a `BlurView` content will stay untouched.
143
+ **Required Configuration**
144
+
145
+ <table>
146
+ <tr>
147
+ <th>Key</th>
148
+ <th>Definition</th>
149
+ <th>Description</th>
150
+ <th>Platform</th>
151
+ <th>Sample code</th>
152
+ </tr>
153
+ <tr>
154
+ <td>partner</td>
155
+ <td>Partner code </td>
156
+ <td>Partner, please contact TrustDecision to obtain</td>
157
+ <td>All</td>
158
+ <td>
159
+ options["partner"] = "[Your partner]"
160
+ </td>
161
+ </tr>
162
+ <tr>
163
+ <td>appKey</td>
164
+ <td>App key</td>
165
+ <td>Appkey, please offer your App bundleId for TrustDecision to obtain<br>
166
+ appkey creation requires the user to provide the application bundleId.<br>
167
+ ⚠️ Different values for bundleId are used for different applications
168
+ </td>
169
+ <td>All</td>
170
+ <td>
171
+ options["appKey"] = "[Your appKey]"
172
+ </td>
173
+ </tr>
174
+ <tr>
175
+ <td>appName</td>
176
+ <td>App name</td>
177
+ <td>AppName, please contact TrustDecision to obtain</td>
178
+ <td>All</td>
179
+ <td>
180
+ options["appName"] = "[Your appName]"
181
+ </td>
182
+ </tr>
183
+ <tr>
184
+ <td>country</td>
185
+ <td> Country code</td>
186
+ <td> cn: means China;<br>sg: means Singapore;<br>us: means North America;<br>fra: means Europe</td>
187
+ <td>All</td>
188
+ <td>
189
+ options["country"] = "[Your country code]"
190
+ </td>
191
+ </tr>
192
+ </table>
111
193
 
112
194
 
113
- ### Questions?
114
- Feel free to contact me By qq(452359549)
195
+ ## Get SDK Version
115
196
 
116
- ### thanks
197
+ Sample Code
117
198
 
199
+ ```dart
200
+ // Get SDK Version
201
+ async function getSDKVersion() {
202
+ const version = await TrustDevice.getSDKVersion();
203
+ console.log(version);
204
+ }
205
+ ```
206
+
207
+ ## Other Instructions
208
+
209
+ Android obfuscated packaging If developers need to use proguard for obfuscated packaging, please add the following code to the proguard configuration file:
210
+
211
+ ```java
212
+ -keep class cn.tongdun.**{*;}
213
+ ```
214
+
215
+ # Fingerprint
216
+
217
+ ## initWithOptions Optional Parameter
218
+
219
+ <table>
220
+ <tr>
221
+ <th>Key</th>
222
+ <th>Definition</th>
223
+ <th>Description</th>
224
+ <th>Platform</th>
225
+ <th>Sample code</th>
226
+ </tr>
227
+ <tr>
228
+ <td>debug</td>
229
+ <td>Whether allow debug</td>
230
+ <td>default is false,After the SDK is integrated, the app has the anti-debugging function by default. <br><b>Develop: </b>Please set value to true.<br><b>Release: </b>Please not set this key or set value to false <br><b>Options:</b><br>true: allow debug;<br>false: not allow debug</td>
231
+ <td>All</td>
232
+ <td>
233
+ options["debug"] = true
234
+ </td>
235
+ </tr>
236
+ <tr>
237
+ <td>timeLimit</td>
238
+ <td>SDK timeout interval Configuration (unit: seconds)</td>
239
+ <td>Timeout interval of network request callback after SDK initialization. Default is 15s.</td>
240
+ <td>All</td>
241
+ <td>
242
+ options["timeLimit"] = 5
243
+ </td>
244
+ </tr>
245
+ <tr>
246
+ <td>location</td>
247
+ <td>Whether collect location information</td>
248
+ <td>default is true,SDK will collect location if the app has been authorized to get location information. <br><b>Options:</b><br>true: allow collect location information;<br>false: not allow collect location information</td>
249
+ <td>All</td>
250
+ <td>
251
+ options["location"] = true
252
+ </td>
253
+ </tr>
254
+ <tr>
255
+ <td>collectLevel</td>
256
+ <td>Degraded blackbox length configuration</td>
257
+ <td>Degraded blackbox will be longer. This configuration allows you to control the length of the degraded blackbox. <br><b>Options:</b><br>"M": After setting, the degraded blackbox length is about 2000 characters;<br>"L": default value, after setting, the degraded length is about 5000 characters</td>
258
+ <td>All</td>
259
+ <td>
260
+ options["collectLevel"] = "M"
261
+ </td>
262
+ </tr>
263
+ <tr>
264
+ <td>IDFA</td>
265
+ <td>Whether collect Advertising Identifier (IDFA) information</td>
266
+ <td>default is true,SDK will collect IDFA information if the app has been authorized to get IDFA information. <br><b>Options:</b><br>true: allow collect IDFA information;<br>false: not allow collect IDFA information</td>
267
+ <td>iOS</td>
268
+ <td>
269
+ options["IDFA"] = true
270
+ </td>
271
+ </tr>
272
+ <tr>
273
+ <td>deviceName</td>
274
+ <td>Whether collect device's name information</td>
275
+ <td>default is true,SDK will collect device's name information. <br><b>Options:</b><br>true: allow collect device's name information;<br>false: not allow collect device's name information</td>
276
+ <td>iOS</td>
277
+ <td>
278
+ options["deviceName"] = true
279
+ </td>
280
+ </tr>
281
+ <tr>
282
+ <td>blackBoxMaxSize</td>
283
+ <td>blackbox maximum length</td>
284
+ <td>The default length is Integer.MAX_VALUE, it will increase according to the actual device situation </td>
285
+ <td>Android</td>
286
+ <td>
287
+ options["blackBoxMaxSize"] = 3000
288
+ </td>
289
+ </tr>
290
+ <tr>
291
+ <td>customProcessName</td>
292
+ <td>custom process name</td>
293
+ <td>change the name of the SDK's process</td>
294
+ <td>Android</td>
295
+ <td>
296
+ options["customProcessName"] = "td"
297
+ </td>
298
+ </tr>
299
+ <tr>
300
+ <td>forceTLSVersion</td>
301
+ <td>Whether https is mandatory to use TLS-v1.1 version</td>
302
+ <td>default is false, and the developer can set the corresponding settings according to the specific situation. <br><b>Options:</b><br>true: use TLS-v1.1 version;<br>false: not use TLS-v1.1 version</td>
303
+ <td>Android</td>
304
+ <td>
305
+ options["forceTLSVersion"] = true
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <td>runningTasks</td>
310
+ <td>Whether allow getting running tasks</td>
311
+ <td>default is true. <br><b>Options:</b><br>true: allow getting running tasks;<br>false: not allow getting running tasks</td>
312
+ <td>Android</td>
313
+ <td>
314
+ options["runningTasks"] = true
315
+ </td>
316
+ </tr>
317
+ <tr>
318
+ <td>sensor</td>
319
+ <td>Whether collect sensor information</td>
320
+ <td>default is true,SDK will collect sensor-related information. <br><b>Options:</b><br>true: collect sensor information;<br>false: not collect sensor information</td>
321
+ <td>Android</td>
322
+ <td>
323
+ options["sensor"] = true
324
+ </td>
325
+ </tr>
326
+ <tr>
327
+ <td>readPhone</td>
328
+ <td>Whether collect READ_PHONE_STATE related information</td>
329
+ <td>default is true,SDK will collect READ_PHONE_STATE information if app gained READ_PHONE_STATE permission<br><b>Options:</b><br>true: collect READ_PHONE_STATE related information;<br>false: not collect READ_PHONE_STATE related information</td>
330
+ <td>Android</td>
331
+ <td>
332
+ options["readPhone"] = true
333
+ </td>
334
+ <tr>
335
+ <td>installPackageList</td>
336
+ <td>Whether collect the list of installation packages</td>
337
+ <td>default is true,SDK will collect the list of installation packages.
338
+ <br><b>Options:</b><br>true: collect the list of installation packages;<br>false: not collect the list of installation packages</td>
339
+ <td>Android</td>
340
+ <td>
341
+ options["installPackageList"] = true
342
+ </td>
343
+ </tr>
344
+ </table>
345
+
346
+
347
+ ## Get Blackbox
348
+
349
+ **Attention**
350
+
351
+ - Please `getBlackBox` after `initWithOptions`, otherwise SDK exceptions will be caused.
352
+ - We suggest that developers do not cache the results returned by `getBlackBox` in the app. Please rely on this function to get blackbox.
353
+
354
+ ### Synchronous method getBlackBox
355
+
356
+ #### Usage Scenario Description
357
+
358
+ **Advantages:** The blackBox will be returned immediately, not affected by the network status;<br/> **Disadvantages:** After the device fingerprint SDK is integrated, if the non-degraded blackBox has not been obtained before, it will return to the degraded blackBox will increase the amount of data uploaded by the subsequent query interface, and the data size is about 5000 bytes;<br/>**Applicable scenarios:** Scenes where blackBox needs to be obtained immediately;<br/>
359
+
360
+ **Sample Code**
361
+
362
+ ```
363
+ async function getBlackBox() {
364
+ const blackBox = await TrustDevice.getBlackBox()
365
+ console.log(blackBox);
366
+ }
367
+ ```
368
+
369
+ ### Asynchronous method getBlackBoxAsync
370
+
371
+
372
+ #### Usage Scenario Description
373
+
374
+ **Advantages:** Under normal circumstances, the network returns a non-degraded blackBox, which will reduce the amount of data uploaded by the subsequent query interface, and the data size is about 26 bytes;<br/>**Disadvantages:** Not returned immediately, according to the network It usually takes about 300ms to return;<br/> **Applicable scenario:** Need to get the latest and non-degraded blackBox scenario;<br/>
375
+
376
+ **Sample Code**
377
+
378
+ ```
379
+ async function getBlackBoxAsync() {
380
+ const blackBox = await TrustDevice.getBlackBoxAsync()
381
+ console.log(blackBox);
382
+ }
383
+ ```
384
+
385
+ # FAQ
386
+
387
+ **Q1**:After Integrating the TrustDecision SDK, the project cannot be debugged in Xcode. How to solve it?
388
+
389
+ **A1**:Please refer to [Initialization](#initialization) When the TrustDecision SDK is initialized, add the following parameters
390
+
391
+ ```
392
+ options["debug"] = true
393
+ ```
118
394
 
@@ -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,6 @@
1
+
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ package="com.trustdevice">
4
+
5
+ </manifest>
6
+
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-trustdevice",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "React Native TrustDevice component",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,37 +1,4 @@
1
1
 
2
- import React, { Component, PropTypes } from 'react';
3
- import { requireNativeComponent,NativeModules } from 'react-native';
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;