react-native-trustdevice 1.1.4 → 1.1.6
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 +61 -5
- package/android/build.gradle +2 -13
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/trustdevice/TrustdeviceModule.java +44 -2
- package/android/src/main/java/com/trustdevice/utils/TDUniRiskUtils.java +13 -0
- package/index.d.ts +25 -2
- package/index.js +9 -4
- package/ios/TrustDevice.m +82 -3
- package/ios/TrustDeviceSe.m +16 -1
- package/package.json +7 -2
- package/react-native-trustdevice.podspec +0 -2
- package/src/TrustDevice.android.js +1 -1
- package/src/TrustDevice.ios.js +0 -1
- package/android/.gradle/8.10/checksums/checksums.lock +0 -0
- package/android/.gradle/8.10/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.10/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.10/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.10/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.10/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.10/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.10/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/nb-cache/trust/6BEC0066B99297FC163AB3C2D5CC7668CDC2525F18622C2FFD1FE9D77756146A +0 -1
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/.transforms/41053347d20d0a776c1e1d56e9cc047e/results.bin +0 -1
- package/android/build/.transforms/41053347d20d0a776c1e1d56e9cc047e/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/5932fa5b98f0003ce689cad35520f6df/results.bin +0 -1
- package/android/build/.transforms/5932fa5b98f0003ce689cad35520f6df/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/ff2232c43c8cccbad5f33e76433cddb2/results.bin +0 -1
- package/android/build/.transforms/ff2232c43c8cccbad5f33e76433cddb2/transformed/classes/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/com/trustdevice/BuildConfig.java +0 -10
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -5
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/annotations_typedef_file/debug/typedefs.txt +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -1954
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/TrustdeviceModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/TrustdeviceModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/TrustdevicePackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/TrustdeviceSeModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/TrustdeviceSeModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/TrustdeviceSeModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/trustdevice/utils/TDUniRiskUtils.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -8
- package/android/build/intermediates/merged_java_res/debug/feature-react-native-trustdevice.jar +0 -0
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
- package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1447
- package/android/build/outputs/aar/react-native-trustdevice-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -25
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/TrustdevicePackage.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/TrustdeviceSeModule$1.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/TrustdeviceSeModule$2.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/TrustdeviceSeModule.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Please note that when integrating SDK products provided by the TrustDecision in
|
|
|
21
21
|
| | Android | iOS |
|
|
22
22
|
| ------------------------- | ------------------------------------ | :----------------- |
|
|
23
23
|
| Supported System Versions | Android 5.0 and above | iOS 9.0 and above |
|
|
24
|
-
| Supported Architectures | armeabi
|
|
24
|
+
| Supported Architectures | armeabi-v7a, arm64-v8a, x86 | armv7,arm64,x86_64 |
|
|
25
25
|
|
|
26
26
|
# Integrate
|
|
27
27
|
|
|
@@ -32,9 +32,47 @@ Please note that when integrating SDK products provided by the TrustDecision in
|
|
|
32
32
|
Please execute in your react native project root directory
|
|
33
33
|
|
|
34
34
|
```shell
|
|
35
|
-
npm install --save react-native-trustdevice@1.1.
|
|
35
|
+
npm install --save react-native-trustdevice@1.1.6
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
### iOS behavior collection dependency (Swift Package Manager)
|
|
39
|
+
|
|
40
|
+
The React Native bridge is still auto-linked through CocoaPods, but the iOS
|
|
41
|
+
behavior collection SDK is distributed through Swift Package Manager. After
|
|
42
|
+
running `pod install`, the host app must add the following package in Xcode:
|
|
43
|
+
|
|
44
|
+
1. Open `ios/<YourApp>.xcworkspace`.
|
|
45
|
+
2. Select **File > Add Package Dependencies...**.
|
|
46
|
+
3. Enter `https://github.com/trustdecision/TDBehavior_spm`.
|
|
47
|
+
4. Select **Exact Version** and enter `1.5.2`.
|
|
48
|
+
5. Add the `TDBehavior` product to the host application target. Do not add it
|
|
49
|
+
to the Pods project or a Pods target.
|
|
50
|
+
|
|
51
|
+
This app-target dependency cannot be declared by the plugin podspec. It is a
|
|
52
|
+
one-time host project setting and remains in the Xcode project after subsequent
|
|
53
|
+
`npm install` and `pod install` commands. CI can resolve it with:
|
|
54
|
+
|
|
55
|
+
```shell
|
|
56
|
+
xcodebuild -resolvePackageDependencies \
|
|
57
|
+
-workspace ios/<YourApp>.xcworkspace \
|
|
58
|
+
-scheme <YourApp>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Android behavior collection dependency
|
|
62
|
+
|
|
63
|
+
The plugin does not bundle the Android behavior collection SDK. If behavior
|
|
64
|
+
collection is required, add the following dependency to the host application's
|
|
65
|
+
`android/app/build.gradle`:
|
|
66
|
+
|
|
67
|
+
```gradle
|
|
68
|
+
dependencies {
|
|
69
|
+
implementation 'com.trustdecision.android:behavior:1.5.1'
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then rebuild the native application. Adding or removing this dependency cannot
|
|
74
|
+
be applied through Metro hot reload.
|
|
75
|
+
|
|
38
76
|
### AndroidManifest.xml
|
|
39
77
|
|
|
40
78
|
Declare the following permissions in the AndroidManifest.xml file under the application module
|
|
@@ -99,6 +137,24 @@ Declare the following permissions in the AndroidManifest.xml file under the appl
|
|
|
99
137
|
async function getBlackBoxAsync();
|
|
100
138
|
```
|
|
101
139
|
|
|
140
|
+
## Behavior collection
|
|
141
|
+
|
|
142
|
+
Initialize the SDK before starting collection. There must be a real user
|
|
143
|
+
interaction such as typing, tapping, or scrolling between `start` and
|
|
144
|
+
`collect`; otherwise `collect` may return code `104`.
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
await TrustDevice.start();
|
|
148
|
+
|
|
149
|
+
const result = await TrustDevice.collect();
|
|
150
|
+
// result: {code: number, payload: string, msg: string}
|
|
151
|
+
|
|
152
|
+
await TrustDevice.stop();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`collect` returns and clears the currently buffered behavior data. `stop`
|
|
156
|
+
stops collection and clears any uncollected data.
|
|
157
|
+
|
|
102
158
|
## Best Practices
|
|
103
159
|
|
|
104
160
|
1. Get TrustDevice Module
|
|
@@ -116,7 +172,7 @@ Declare the following permissions in the AndroidManifest.xml file under the appl
|
|
|
116
172
|
"partner": "[Your partner]",
|
|
117
173
|
"appKey": "[Your appKey]",
|
|
118
174
|
"appName": "[Your appName]",
|
|
119
|
-
"
|
|
175
|
+
"dataCenter": "[Your dataCenter]",
|
|
120
176
|
"debug": false,
|
|
121
177
|
}
|
|
122
178
|
|
|
@@ -165,7 +221,7 @@ Declare the following permissions in the AndroidManifest.xml file under the appl
|
|
|
165
221
|
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------ |
|
|
166
222
|
| partner(required) | Partner code, contact operator to obtain. | All | options["partner"] = "your partner" |
|
|
167
223
|
| appKey(required) | Application identification, please refer to[how to get appKey](https://en-doc.trustdecision.com/reference/android-get-appkey) | All | options["appKey"] = "your appKey" |
|
|
168
|
-
|
|
|
224
|
+
| dataCenter(required) | Data-center: **cn** for China **fra** for Europe **sg** for Singapore **inda** for Indonesia **us** for the USA | All | options["dataCenter"] = "your dataCenter" |
|
|
169
225
|
| appName | Application name, contact operator to obtain | All | options["appName"] = "your appName" |
|
|
170
226
|
| debug | Allow debugging, default false, must be closed before the application release. | All | options["debug"] = true |
|
|
171
227
|
| timeLimit | Network timeout configuration, in seconds, default 15s | All | options["timeLimit"] = 5 |
|
|
@@ -176,4 +232,4 @@ Declare the following permissions in the AndroidManifest.xml file under the appl
|
|
|
176
232
|
| runningTasks | Whether collecting running tasks, default allowed | Android | options["runningTasks"] = true |
|
|
177
233
|
| sensor | Whether collecting sensor information, default allowed | Android | options["sensor"] = true |
|
|
178
234
|
| readPhone | Whether collecting READ _PHONE_ STATE permission-related information, default allowed | Android | options["readPhone"] = true |
|
|
179
|
-
| installPackageList | Whether collecting application list information, default allowed | Android | options["installPackageList"] = true |
|
|
235
|
+
| installPackageList | Whether collecting application list information, default allowed | Android | options["installPackageList"] = true |
|
package/android/build.gradle
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
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
1
|
apply plugin: 'com.android.library'
|
|
14
2
|
|
|
15
3
|
android {
|
|
4
|
+
namespace 'com.trustdevice' // 添加这一行,AGP8.0+需要namespace
|
|
5
|
+
|
|
16
6
|
compileSdkVersion 34
|
|
17
7
|
|
|
18
8
|
defaultConfig {
|
|
@@ -35,4 +25,3 @@ dependencies {
|
|
|
35
25
|
implementation 'com.facebook.react:react-native:+'
|
|
36
26
|
implementation 'com.trustdecision.android:mobrisk:+'
|
|
37
27
|
}
|
|
38
|
-
|
|
@@ -17,6 +17,7 @@ import java.util.HashMap;
|
|
|
17
17
|
import com.trustdecision.mobrisk.TDRisk;
|
|
18
18
|
import com.trustdecision.mobrisk.TDRiskCallback;
|
|
19
19
|
import com.trustdecision.mobrisk.TDAPISignResult;
|
|
20
|
+
import com.trustdecision.mobrisk.TDBehaviorResult;
|
|
20
21
|
|
|
21
22
|
public class TrustdeviceModule extends ReactContextBaseJavaModule {
|
|
22
23
|
private final ReactApplicationContext reactContext;
|
|
@@ -34,11 +35,18 @@ public class TrustdeviceModule extends ReactContextBaseJavaModule {
|
|
|
34
35
|
|
|
35
36
|
@ReactMethod
|
|
36
37
|
public void initWithOptions(ReadableMap readableMap, Promise promise) {
|
|
37
|
-
if (readableMap
|
|
38
|
+
if (readableMap == null) {
|
|
39
|
+
promise.reject("initWithOptions Error", "options must not be null");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
38
44
|
HashMap<String, Object> options = readableMap.toHashMap();
|
|
39
45
|
TDRisk.Builder builder = TDUniRiskUtils.mapToBuilder(options);
|
|
40
46
|
TDRisk.initWithOptions(this.reactContext.getApplicationContext(), builder);
|
|
41
47
|
promise.resolve(null);
|
|
48
|
+
} catch (Exception e) {
|
|
49
|
+
promise.reject("initWithOptions Error", e);
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
|
|
@@ -83,9 +91,43 @@ public class TrustdeviceModule extends ReactContextBaseJavaModule {
|
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
93
|
|
|
94
|
+
@ReactMethod
|
|
95
|
+
public void start(Promise promise) {
|
|
96
|
+
try {
|
|
97
|
+
TDRisk.start();
|
|
98
|
+
promise.resolve(null);
|
|
99
|
+
} catch (Exception e) {
|
|
100
|
+
promise.reject("behaviorStart Error", e);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@ReactMethod
|
|
105
|
+
public void stop(Promise promise) {
|
|
106
|
+
try {
|
|
107
|
+
TDRisk.stop();
|
|
108
|
+
promise.resolve(null);
|
|
109
|
+
} catch (Exception e) {
|
|
110
|
+
promise.reject("behaviorStop Error", e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@ReactMethod
|
|
115
|
+
public void collect(Promise promise) {
|
|
116
|
+
try {
|
|
117
|
+
TDBehaviorResult behaviorResult = TDRisk.collect();
|
|
118
|
+
WritableMap resultMap = Arguments.createMap();
|
|
119
|
+
resultMap.putInt("code", behaviorResult.code());
|
|
120
|
+
resultMap.putString("payload", behaviorResult.payload());
|
|
121
|
+
resultMap.putString("msg", behaviorResult.msg());
|
|
122
|
+
promise.resolve(resultMap);
|
|
123
|
+
} catch (Exception e) {
|
|
124
|
+
promise.reject("behaviorCollect Error", e);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
86
128
|
@ReactMethod
|
|
87
129
|
public void getSDKVersion(Promise promise) {
|
|
88
130
|
String sdkVersion = TDRisk.getSDKVersion();
|
|
89
131
|
promise.resolve(sdkVersion);
|
|
90
132
|
}
|
|
91
|
-
}
|
|
133
|
+
}
|
|
@@ -13,6 +13,7 @@ public class TDUniRiskUtils {
|
|
|
13
13
|
static final String KEY_APPKEY = "appKey";
|
|
14
14
|
static final String KEY_APPNAME = "appName";
|
|
15
15
|
static final String KEY_COUNTRY = "country";
|
|
16
|
+
static final String KEY_DATACENTER = "dataCenter";
|
|
16
17
|
static final String KEY_CHANNEL = "channel";
|
|
17
18
|
static final String KEY_DEBUG = "debug";
|
|
18
19
|
static final String KEY_TIME_LIMIT = "timeLimit";
|
|
@@ -71,6 +72,12 @@ public class TDUniRiskUtils {
|
|
|
71
72
|
builder.country(country.toUpperCase());
|
|
72
73
|
}
|
|
73
74
|
}
|
|
75
|
+
if (configMap.containsKey(KEY_DATACENTER)) {
|
|
76
|
+
String dataCenter = (String) configMap.get(KEY_DATACENTER);
|
|
77
|
+
if (!TextUtils.isEmpty(dataCenter)) {
|
|
78
|
+
builder.country(dataCenter.toUpperCase());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
74
81
|
// if (configMap.containsKey(KEY_URL)) {
|
|
75
82
|
// String url = (String) configMap.get(KEY_URL);
|
|
76
83
|
// if (!TextUtils.isEmpty(url)) {
|
|
@@ -232,6 +239,12 @@ public class TDUniRiskUtils {
|
|
|
232
239
|
builder.country(country.toUpperCase());
|
|
233
240
|
}
|
|
234
241
|
}
|
|
242
|
+
if (configMap.containsKey(KEY_DATACENTER)) {
|
|
243
|
+
String dataCenter = (String) configMap.get(KEY_DATACENTER);
|
|
244
|
+
if (!TextUtils.isEmpty(dataCenter)) {
|
|
245
|
+
builder.country(dataCenter.toUpperCase());
|
|
246
|
+
}
|
|
247
|
+
}
|
|
235
248
|
if (configMap.containsKey(KEY_DEBUG)) {
|
|
236
249
|
Object debug = configMap.get(KEY_DEBUG);
|
|
237
250
|
if (debug != null) {
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
+
export interface TDSignResult {
|
|
2
|
+
code: number;
|
|
3
|
+
sign: string;
|
|
4
|
+
msg: string;
|
|
5
|
+
}
|
|
1
6
|
|
|
2
|
-
|
|
7
|
+
export interface TDBehaviorResult {
|
|
8
|
+
code: number;
|
|
9
|
+
payload: string;
|
|
10
|
+
msg: string;
|
|
11
|
+
}
|
|
3
12
|
|
|
4
|
-
|
|
13
|
+
export interface TrustDeviceModule {
|
|
14
|
+
initWithOptions(options: Record<string, unknown>): Promise<void> | void;
|
|
15
|
+
getSDKVersion(): Promise<string>;
|
|
16
|
+
getBlackBox(): Promise<string>;
|
|
17
|
+
getBlackBoxAsync(): Promise<string>;
|
|
18
|
+
sign(path: string): Promise<TDSignResult>;
|
|
19
|
+
start(): Promise<void>;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
collect(): Promise<TDBehaviorResult>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare const TrustDevice: TrustDeviceModule;
|
|
25
|
+
|
|
26
|
+
export {TrustDevice};
|
|
27
|
+
export default TrustDevice;
|
package/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
1
|
+
// Platform files are transpiled as ES modules by Metro, while older published
|
|
2
|
+
// versions of this package were consumed as CommonJS. Normalize the platform
|
|
3
|
+
// export once and preserve all existing public import styles.
|
|
4
|
+
const platformModule = require('./src/TrustDevice');
|
|
5
|
+
const TrustDevice = platformModule.default || platformModule;
|
|
6
|
+
|
|
7
|
+
module.exports = TrustDevice;
|
|
8
|
+
module.exports.default = TrustDevice;
|
|
9
|
+
module.exports.TrustDevice = TrustDevice;
|
package/ios/TrustDevice.m
CHANGED
|
@@ -27,7 +27,22 @@ RCT_REMAP_METHOD(getSDKVersion,
|
|
|
27
27
|
RCT_EXPORT_METHOD(initWithOptions:(NSDictionary*)options)
|
|
28
28
|
{
|
|
29
29
|
NSMutableDictionary* mutableOptions = [options mutableCopy];
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
// 1. 判断 debug 是否为空(nil 或 NSNull)
|
|
32
|
+
id debugValue = options[@"debug"];
|
|
33
|
+
if (debugValue && debugValue != [NSNull null]) {
|
|
34
|
+
mutableOptions[@"allowd"] = debugValue; // 原逻辑保留
|
|
35
|
+
} else {
|
|
36
|
+
// debug 为空时,可能设置默认值或不设置
|
|
37
|
+
mutableOptions[@"allowd"] = @(NO); // 示例默认 false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 2. 增加 dataCenter 赋值给 country
|
|
41
|
+
id dataCenter = options[@"dataCenter"];
|
|
42
|
+
if (dataCenter && dataCenter != [NSNull null]) {
|
|
43
|
+
mutableOptions[@"country"] = dataCenter;
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
32
47
|
manager->initWithOptions([mutableOptions copy]);
|
|
33
48
|
}
|
|
@@ -78,6 +93,72 @@ RCT_EXPORT_METHOD(sign:(NSString*)path
|
|
|
78
93
|
resolve(resultDict);
|
|
79
94
|
}
|
|
80
95
|
|
|
96
|
+
RCT_REMAP_METHOD(start,
|
|
97
|
+
startResolver:(RCTPromiseResolveBlock)resolve
|
|
98
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
99
|
+
{
|
|
100
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
101
|
+
if (manager == NULL || manager->start == NULL) {
|
|
102
|
+
reject(@"behavior_unavailable",
|
|
103
|
+
@"TDBehavior is unavailable. Add TDBehavior_spm 1.5.2 to the host App Target.",
|
|
104
|
+
nil);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// TDBehavior starts UIKit-backed providers (for example device orientation),
|
|
109
|
+
// which must be created and stopped on the main thread. React Native invokes
|
|
110
|
+
// native module methods on a background method queue by default.
|
|
111
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
112
|
+
manager->start();
|
|
113
|
+
resolve(nil);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
RCT_REMAP_METHOD(stop,
|
|
118
|
+
stopResolver:(RCTPromiseResolveBlock)resolve
|
|
119
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
120
|
+
{
|
|
121
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
122
|
+
if (manager == NULL || manager->stop == NULL) {
|
|
123
|
+
reject(@"behavior_unavailable",
|
|
124
|
+
@"TDBehavior is unavailable. Add TDBehavior_spm 1.5.2 to the host App Target.",
|
|
125
|
+
nil);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
130
|
+
manager->stop();
|
|
131
|
+
resolve(nil);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
RCT_REMAP_METHOD(collect,
|
|
136
|
+
collectResolver:(RCTPromiseResolveBlock)resolve
|
|
137
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
138
|
+
{
|
|
139
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
140
|
+
if (manager == NULL || manager->collect == NULL) {
|
|
141
|
+
reject(@"behavior_unavailable",
|
|
142
|
+
@"TDBehavior is unavailable. Add TDBehavior_spm 1.5.2 to the host App Target.",
|
|
143
|
+
nil);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
TDBehaviorResultStruct behaviorResult = manager->collect();
|
|
147
|
+
|
|
148
|
+
NSString *payload = behaviorResult.payload
|
|
149
|
+
? [NSString stringWithUTF8String:behaviorResult.payload]
|
|
150
|
+
: @"";
|
|
151
|
+
NSString *message = behaviorResult.msg
|
|
152
|
+
? [NSString stringWithUTF8String:behaviorResult.msg]
|
|
153
|
+
: @"";
|
|
154
|
+
|
|
155
|
+
resolve(@{
|
|
156
|
+
@"code": @(behaviorResult.code),
|
|
157
|
+
@"payload": payload,
|
|
158
|
+
@"msg": message
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
81
162
|
- (UIWindow *)getKeyWindow
|
|
82
163
|
{
|
|
83
164
|
if (@available(iOS 13.0, *))
|
|
@@ -139,5 +220,3 @@ RCT_REMAP_METHOD(showCaptcha,
|
|
|
139
220
|
|
|
140
221
|
|
|
141
222
|
@end
|
|
142
|
-
|
|
143
|
-
|
package/ios/TrustDeviceSe.m
CHANGED
|
@@ -27,7 +27,22 @@ RCT_REMAP_METHOD(getSDKVersion,
|
|
|
27
27
|
RCT_EXPORT_METHOD(initWithOptions:(NSDictionary*)options)
|
|
28
28
|
{
|
|
29
29
|
NSMutableDictionary* mutableOptions = [options mutableCopy];
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
// 1. 判断 debug 是否为空(nil 或 NSNull)
|
|
32
|
+
id debugValue = options[@"debug"];
|
|
33
|
+
if (debugValue && debugValue != [NSNull null]) {
|
|
34
|
+
mutableOptions[@"allowd"] = debugValue; // 原逻辑保留
|
|
35
|
+
} else {
|
|
36
|
+
// debug 为空时,可能设置默认值或不设置
|
|
37
|
+
mutableOptions[@"allowd"] = @(NO); // 示例默认 false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 2. 增加 dataCenter 赋值给 country
|
|
41
|
+
id dataCenter = options[@"dataCenter"];
|
|
42
|
+
if (dataCenter && dataCenter != [NSNull null]) {
|
|
43
|
+
mutableOptions[@"country"] = dataCenter;
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
TDDeviceManager_t *manager = [TDDeviceManager sharedManager];
|
|
32
47
|
manager->initWithOptions([mutableOptions copy]);
|
|
33
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-trustdevice",
|
|
3
|
-
"
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.1.6",
|
|
4
7
|
"description": "React Native TrustDevice component",
|
|
5
8
|
"main": "index.js",
|
|
6
9
|
"react-native": "index.js",
|
|
@@ -18,13 +21,15 @@
|
|
|
18
21
|
"react-native-trustdevice"
|
|
19
22
|
],
|
|
20
23
|
"files": [
|
|
21
|
-
"android",
|
|
24
|
+
"android/build.gradle",
|
|
25
|
+
"android/src",
|
|
22
26
|
"ios",
|
|
23
27
|
"src",
|
|
24
28
|
"index.js",
|
|
25
29
|
"index.d.ts",
|
|
26
30
|
"react-native-trustdevice.podspec"
|
|
27
31
|
],
|
|
32
|
+
|
|
28
33
|
"homepage": "https://trustdecision.com",
|
|
29
34
|
"peerDependencies": {
|
|
30
35
|
"react": "*",
|
package/src/TrustDevice.ios.js
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
78098113B327001A7ADBB2DD53260281F0DC0024D59151B959C636AEF9B80944
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
o/classes
|
package/android/build/.transforms/41053347d20d0a776c1e1d56e9cc047e/transformed/classes/classes.dex
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
o/classes
|
package/android/build/.transforms/5932fa5b98f0003ce689cad35520f6df/transformed/classes/classes.dex
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
o/classes
|
package/android/build/.transforms/ff2232c43c8cccbad5f33e76433cddb2/transformed/classes/classes.dex
DELETED
|
Binary file
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Automatically generated file. DO NOT MODIFY
|
|
3
|
-
*/
|
|
4
|
-
package com.trustdevice;
|
|
5
|
-
|
|
6
|
-
public final class BuildConfig {
|
|
7
|
-
public static final boolean DEBUG = Boolean.parseBoolean("true");
|
|
8
|
-
public static final String LIBRARY_PACKAGE_NAME = "com.trustdevice";
|
|
9
|
-
public static final String BUILD_TYPE = "debug";
|
|
10
|
-
}
|
package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"artifactType": {
|
|
4
|
-
"type": "AAPT_FRIENDLY_MERGED_MANIFESTS",
|
|
5
|
-
"kind": "Directory"
|
|
6
|
-
},
|
|
7
|
-
"applicationId": "com.trustdevice",
|
|
8
|
-
"variantName": "debug",
|
|
9
|
-
"elements": [
|
|
10
|
-
{
|
|
11
|
-
"type": "SINGLE",
|
|
12
|
-
"filters": [],
|
|
13
|
-
"attributes": [],
|
|
14
|
-
"outputFile": "AndroidManifest.xml"
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
"elementType": "File"
|
|
18
|
-
}
|
|
Binary file
|
package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
File without changes
|
|
Binary file
|
|
Binary file
|