react-native-trustdevice 1.1.5 → 2.0.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/Package.swift +35 -0
- package/README.md +94 -3
- package/android/build.gradle +0 -1
- package/android/src/main/java/com/trustdevice/TrustdeviceModule.java +110 -2
- package/android/src/main/java/com/trustdevice/TrustdeviceSeModule.java +32 -9
- package/android/src/main/java/com/trustdevice/TrustdeviceUiBridge.java +125 -0
- package/index.d.ts +65 -2
- package/index.js +11 -4
- package/ios/TrustDevice.h +2 -2
- package/ios/TrustDevice.m +186 -27
- package/ios/TrustDeviceSe.h +2 -2
- package/ios/TrustDeviceSe.m +111 -62
- package/package.json +9 -3
- package/react-native-trustdevice.podspec +0 -2
- package/react-native.config.js +10 -0
- package/src/TrustDevice.android.js +2 -1
- package/src/TrustDevice.ios.js +3 -4
- package/android/build/.transforms/34a3c3baa7ee620e604d2c62960577c0/results.bin +0 -1
- package/android/build/.transforms/34a3c3baa7ee620e604d2c62960577c0/transformed/classes/classes.dex +0 -0
- 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_metadata/debug/aar-metadata.properties +0 -5
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- 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 -0
- 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/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/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 -7
- 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/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -16
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
package/ios/TrustDevice.m
CHANGED
|
@@ -10,10 +10,31 @@
|
|
|
10
10
|
#import <React/RCTConvert.h>
|
|
11
11
|
#import <TDMobRisk/TDMobRisk.h>
|
|
12
12
|
|
|
13
|
+
static NSString *TDString(const char *value) {
|
|
14
|
+
return value ? ([NSString stringWithUTF8String:value] ?: @"") : @"";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static NSDictionary *TDDeviceInfoDictionary(TDDeviceResponse response) {
|
|
18
|
+
NSString *message = TDString(response.apiStatus.message);
|
|
19
|
+
return @{
|
|
20
|
+
@"blackBox": TDString(response.blackBox),
|
|
21
|
+
@"fpVersion": TDString(response.fpVersion),
|
|
22
|
+
@"anonymousId": TDString(response.anonymousId),
|
|
23
|
+
@"deviceRiskScore": @(response.deviceRiskScore),
|
|
24
|
+
@"sealedResult": TDString(response.sealedResult),
|
|
25
|
+
@"apiStatus": @{ @"code": @(response.apiStatus.code), @"message": message },
|
|
26
|
+
@"code": @(response.apiStatus.code),
|
|
27
|
+
@"msg": message,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
@implementation TrustDevice
|
|
14
32
|
|
|
15
33
|
RCT_EXPORT_MODULE();
|
|
16
34
|
|
|
35
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
36
|
+
return @[@"TrustDeviceCaptcha"];
|
|
37
|
+
}
|
|
17
38
|
|
|
18
39
|
RCT_REMAP_METHOD(getSDKVersion,
|
|
19
40
|
getSDKVersionResolver:(RCTPromiseResolveBlock)resolve
|
|
@@ -26,21 +47,22 @@ RCT_REMAP_METHOD(getSDKVersion,
|
|
|
26
47
|
|
|
27
48
|
RCT_EXPORT_METHOD(initWithOptions:(NSDictionary*)options)
|
|
28
49
|
{
|
|
29
|
-
NSMutableDictionary*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
id debugValue = options[@"debug"];
|
|
33
|
-
if (debugValue && debugValue != [NSNull null]) {
|
|
34
|
-
mutableOptions[@"allowd"] = debugValue; // 原逻辑保留
|
|
35
|
-
} else {
|
|
36
|
-
// debug 为空时,可能设置默认值或不设置
|
|
37
|
-
mutableOptions[@"allowd"] = @(NO); // 示例默认 false
|
|
50
|
+
NSMutableDictionary *mutableOptions = [options mutableCopy];
|
|
51
|
+
if ([options[@"debug"] isKindOfClass:[NSNumber class]] && [options[@"debug"] boolValue]) {
|
|
52
|
+
mutableOptions[@"allowed"] = @"allowed";
|
|
38
53
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
|
|
54
|
+
if ([options[@"location"] isKindOfClass:[NSNumber class]] && ![options[@"location"] boolValue]) {
|
|
55
|
+
mutableOptions[@"noLocation"] = @"noLocation";
|
|
56
|
+
}
|
|
57
|
+
if ([options[@"IDFA"] isKindOfClass:[NSNumber class]] && ![options[@"IDFA"] boolValue]) {
|
|
58
|
+
mutableOptions[@"noIDFA"] = @"noIDFA";
|
|
59
|
+
}
|
|
60
|
+
if ([options[@"deviceName"] isKindOfClass:[NSNumber class]] && ![options[@"deviceName"] boolValue]) {
|
|
61
|
+
mutableOptions[@"noDeviceName"] = @"noDeviceName";
|
|
62
|
+
}
|
|
63
|
+
NSString *dataCenter = options[@"dataCenter"];
|
|
64
|
+
if ([dataCenter isKindOfClass:[NSString class]] && dataCenter.length > 0) {
|
|
65
|
+
mutableOptions[@"country"] = dataCenter;
|
|
44
66
|
}
|
|
45
67
|
|
|
46
68
|
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
@@ -66,6 +88,35 @@ RCT_REMAP_METHOD(getBlackBoxAsync,
|
|
|
66
88
|
});
|
|
67
89
|
}
|
|
68
90
|
|
|
91
|
+
RCT_REMAP_METHOD(getDeviceInfo,
|
|
92
|
+
getDeviceInfoResolver:(RCTPromiseResolveBlock)resolve
|
|
93
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
94
|
+
{
|
|
95
|
+
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
|
|
96
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
97
|
+
if (manager == NULL || manager->getDeviceInfoSync == NULL) {
|
|
98
|
+
reject(@"device_info_unavailable", @"getDeviceInfoSync is unavailable", nil);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
TDDeviceResponse response = manager->getDeviceInfoSync();
|
|
102
|
+
resolve(TDDeviceInfoDictionary(response));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
RCT_REMAP_METHOD(getDeviceInfoAsync,
|
|
107
|
+
getDeviceInfoAsyncResolver:(RCTPromiseResolveBlock)resolve
|
|
108
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
109
|
+
{
|
|
110
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
111
|
+
if (manager == NULL || manager->getDeviceInfo == NULL) {
|
|
112
|
+
reject(@"device_info_unavailable", @"getDeviceInfo is unavailable", nil);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
manager->getDeviceInfo(^(TDDeviceResponse response) {
|
|
116
|
+
resolve(TDDeviceInfoDictionary(response));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
69
120
|
RCT_EXPORT_METHOD(sign:(NSString*)path
|
|
70
121
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
71
122
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
@@ -93,6 +144,72 @@ RCT_EXPORT_METHOD(sign:(NSString*)path
|
|
|
93
144
|
resolve(resultDict);
|
|
94
145
|
}
|
|
95
146
|
|
|
147
|
+
RCT_REMAP_METHOD(start,
|
|
148
|
+
startResolver:(RCTPromiseResolveBlock)resolve
|
|
149
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
150
|
+
{
|
|
151
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
152
|
+
if (manager == NULL || manager->start == NULL) {
|
|
153
|
+
reject(@"behavior_unavailable",
|
|
154
|
+
@"TDBehavior is unavailable. Add TDBehavior_spm 1.5.2 to the host App Target.",
|
|
155
|
+
nil);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// TDBehavior starts UIKit-backed providers (for example device orientation),
|
|
160
|
+
// which must be created and stopped on the main thread. React Native invokes
|
|
161
|
+
// native module methods on a background method queue by default.
|
|
162
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
163
|
+
manager->start();
|
|
164
|
+
resolve(nil);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
RCT_REMAP_METHOD(stop,
|
|
169
|
+
stopResolver:(RCTPromiseResolveBlock)resolve
|
|
170
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
171
|
+
{
|
|
172
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
173
|
+
if (manager == NULL || manager->stop == NULL) {
|
|
174
|
+
reject(@"behavior_unavailable",
|
|
175
|
+
@"TDBehavior is unavailable. Add TDBehavior_spm 1.5.2 to the host App Target.",
|
|
176
|
+
nil);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
181
|
+
manager->stop();
|
|
182
|
+
resolve(nil);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
RCT_REMAP_METHOD(collect,
|
|
187
|
+
collectResolver:(RCTPromiseResolveBlock)resolve
|
|
188
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
189
|
+
{
|
|
190
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
191
|
+
if (manager == NULL || manager->collect == NULL) {
|
|
192
|
+
reject(@"behavior_unavailable",
|
|
193
|
+
@"TDBehavior is unavailable. Add TDBehavior_spm 1.5.2 to the host App Target.",
|
|
194
|
+
nil);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
TDBehaviorResultStruct behaviorResult = manager->collect();
|
|
198
|
+
|
|
199
|
+
NSString *payload = behaviorResult.payload
|
|
200
|
+
? [NSString stringWithUTF8String:behaviorResult.payload]
|
|
201
|
+
: @"";
|
|
202
|
+
NSString *message = behaviorResult.msg
|
|
203
|
+
? [NSString stringWithUTF8String:behaviorResult.msg]
|
|
204
|
+
: @"";
|
|
205
|
+
|
|
206
|
+
resolve(@{
|
|
207
|
+
@"code": @(behaviorResult.code),
|
|
208
|
+
@"payload": payload,
|
|
209
|
+
@"msg": message
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
96
213
|
- (UIWindow *)getKeyWindow
|
|
97
214
|
{
|
|
98
215
|
if (@available(iOS 13.0, *))
|
|
@@ -122,37 +239,79 @@ RCT_REMAP_METHOD(showCaptcha,
|
|
|
122
239
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
123
240
|
{
|
|
124
241
|
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
125
|
-
|
|
242
|
+
if (manager == NULL || manager->showCaptcha == NULL) {
|
|
243
|
+
reject(@"captcha_unavailable", @"showCaptcha is unavailable", nil);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
126
246
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
127
247
|
UIWindow *keyWindow = [self getKeyWindow];
|
|
248
|
+
if (keyWindow == nil) {
|
|
249
|
+
reject(@"captcha_no_window", @"No active application window", nil);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
128
252
|
manager->showCaptcha(keyWindow,^(TDShowCaptchaResultStruct resultStruct) {
|
|
129
|
-
|
|
253
|
+
NSDictionary *resultDictionary;
|
|
130
254
|
switch (resultStruct.resultType) {
|
|
131
255
|
case TDShowCaptchaResultTypeSuccess:
|
|
132
|
-
resultDictionary
|
|
133
|
-
resultDictionary[@"token"] = @(resultStruct.validateToken);
|
|
256
|
+
resultDictionary = @{ @"function": @"onSuccess", @"token": TDString(resultStruct.validateToken) };
|
|
134
257
|
break;
|
|
135
258
|
case TDShowCaptchaResultTypeFailed:
|
|
136
|
-
resultDictionary
|
|
137
|
-
|
|
138
|
-
resultDictionary[@"errorMsg"] = @(resultStruct.errorMsg);
|
|
139
|
-
break;
|
|
140
|
-
case TDShowCaptchaResultTypeReady:
|
|
141
|
-
resultDictionary[@"function"] = @"onReady";
|
|
259
|
+
resultDictionary = @{ @"function": @"onFailed", @"errorCode": @(resultStruct.errorCode),
|
|
260
|
+
@"errorMsg": TDString(resultStruct.errorMsg) };
|
|
142
261
|
break;
|
|
262
|
+
case TDShowCaptchaResultTypeReady: {
|
|
263
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
264
|
+
[self sendEventWithName:@"TrustDeviceCaptcha" body:@{ @"function": @"onReady" }];
|
|
265
|
+
});
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
143
268
|
default:
|
|
144
|
-
|
|
269
|
+
return;
|
|
145
270
|
}
|
|
146
271
|
resolve(resultDictionary);
|
|
147
272
|
});
|
|
148
273
|
});
|
|
149
274
|
}
|
|
150
275
|
|
|
276
|
+
RCT_REMAP_METHOD(showLiveness,
|
|
277
|
+
showLivenessWithOptions:(NSDictionary *)options
|
|
278
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
279
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
280
|
+
{
|
|
281
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
282
|
+
if (manager == NULL || manager->showLivenessWithShowStyle == NULL) {
|
|
283
|
+
reject(@"liveness_unavailable", @"showLiveness is unavailable", nil);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
288
|
+
UIViewController *controller = [self getKeyWindow].rootViewController;
|
|
289
|
+
while (controller.presentedViewController != nil) {
|
|
290
|
+
controller = controller.presentedViewController;
|
|
291
|
+
}
|
|
292
|
+
if (controller == nil) {
|
|
293
|
+
reject(@"liveness_no_controller", @"No active view controller", nil);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
NSString *license = [options[@"license"] isKindOfClass:[NSString class]] ? options[@"license"] : nil;
|
|
297
|
+
TDLivenessShowStyle style = [options[@"showStyle"] isEqual:@"push"]
|
|
298
|
+
? TDLivenessShowStylePush : TDLivenessShowStylePresent;
|
|
299
|
+
manager->showLivenessWithShowStyle(controller, license, style,
|
|
300
|
+
^(NSDictionary *success) {
|
|
301
|
+
NSMutableDictionary *result = [success mutableCopy] ?: [NSMutableDictionary dictionary];
|
|
302
|
+
result[@"function"] = @"onSuccess";
|
|
303
|
+
resolve(result);
|
|
304
|
+
},
|
|
305
|
+
^(NSDictionary *failure) {
|
|
306
|
+
NSMutableDictionary *result = [failure mutableCopy] ?: [NSMutableDictionary dictionary];
|
|
307
|
+
result[@"function"] = @"onFailed";
|
|
308
|
+
resolve(result);
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
}
|
|
151
312
|
|
|
152
313
|
|
|
153
314
|
|
|
154
315
|
|
|
155
316
|
|
|
156
317
|
@end
|
|
157
|
-
|
|
158
|
-
|
package/ios/TrustDeviceSe.h
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
9
|
-
#import <React/
|
|
9
|
+
#import <React/RCTEventEmitter.h>
|
|
10
10
|
|
|
11
11
|
NS_ASSUME_NONNULL_BEGIN
|
|
12
12
|
|
|
13
|
-
@interface TrustDeviceSe :
|
|
13
|
+
@interface TrustDeviceSe : RCTEventEmitter <RCTBridgeModule>
|
|
14
14
|
|
|
15
15
|
@end
|
|
16
16
|
|
package/ios/TrustDeviceSe.m
CHANGED
|
@@ -10,10 +10,31 @@
|
|
|
10
10
|
#import <React/RCTConvert.h>
|
|
11
11
|
#import <TDMobRisk/TDMobRisk.h>
|
|
12
12
|
|
|
13
|
+
static NSString *TDSeString(const char *value) {
|
|
14
|
+
return value ? ([NSString stringWithUTF8String:value] ?: @"") : @"";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static NSDictionary *TDSeDeviceInfoDictionary(TDDeviceResponse response) {
|
|
18
|
+
NSString *message = TDSeString(response.apiStatus.message);
|
|
19
|
+
return @{
|
|
20
|
+
@"blackBox": TDSeString(response.blackBox),
|
|
21
|
+
@"fpVersion": TDSeString(response.fpVersion),
|
|
22
|
+
@"anonymousId": TDSeString(response.anonymousId),
|
|
23
|
+
@"deviceRiskScore": @(response.deviceRiskScore),
|
|
24
|
+
@"sealedResult": TDSeString(response.sealedResult),
|
|
25
|
+
@"apiStatus": @{ @"code": @(response.apiStatus.code), @"message": message },
|
|
26
|
+
@"code": @(response.apiStatus.code),
|
|
27
|
+
@"msg": message,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
@implementation TrustDeviceSe
|
|
14
32
|
|
|
15
33
|
RCT_EXPORT_MODULE();
|
|
16
34
|
|
|
35
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
36
|
+
return @[@"TrustDeviceSeCaptcha"];
|
|
37
|
+
}
|
|
17
38
|
|
|
18
39
|
RCT_REMAP_METHOD(getSDKVersion,
|
|
19
40
|
getSDKVersionResolver:(RCTPromiseResolveBlock)resolve
|
|
@@ -26,22 +47,23 @@ RCT_REMAP_METHOD(getSDKVersion,
|
|
|
26
47
|
|
|
27
48
|
RCT_EXPORT_METHOD(initWithOptions:(NSDictionary*)options)
|
|
28
49
|
{
|
|
29
|
-
NSMutableDictionary*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
NSMutableDictionary *mutableOptions = [options mutableCopy];
|
|
51
|
+
if ([options[@"debug"] isKindOfClass:[NSNumber class]] && [options[@"debug"] boolValue]) {
|
|
52
|
+
mutableOptions[@"allowed"] = @"allowed";
|
|
53
|
+
}
|
|
54
|
+
if ([options[@"location"] isKindOfClass:[NSNumber class]] && ![options[@"location"] boolValue]) {
|
|
55
|
+
mutableOptions[@"noLocation"] = @"noLocation";
|
|
56
|
+
}
|
|
57
|
+
if ([options[@"IDFA"] isKindOfClass:[NSNumber class]] && ![options[@"IDFA"] boolValue]) {
|
|
58
|
+
mutableOptions[@"noIDFA"] = @"noIDFA";
|
|
59
|
+
}
|
|
60
|
+
if ([options[@"deviceName"] isKindOfClass:[NSNumber class]] && ![options[@"deviceName"] boolValue]) {
|
|
61
|
+
mutableOptions[@"noDeviceName"] = @"noDeviceName";
|
|
62
|
+
}
|
|
63
|
+
NSString *dataCenter = options[@"dataCenter"];
|
|
64
|
+
if ([dataCenter isKindOfClass:[NSString class]] && dataCenter.length > 0) {
|
|
65
|
+
mutableOptions[@"country"] = dataCenter;
|
|
66
|
+
}
|
|
45
67
|
|
|
46
68
|
TDDeviceManager_t *manager = [TDDeviceManager sharedManager];
|
|
47
69
|
manager->initWithOptions([mutableOptions copy]);
|
|
@@ -51,41 +73,25 @@ RCT_REMAP_METHOD(getDeviceInfo,
|
|
|
51
73
|
getDeviceInfoResolver:(RCTPromiseResolveBlock)resolve
|
|
52
74
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
53
75
|
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else {
|
|
74
|
-
message = response.apiStatus.message ? [NSString stringWithUTF8String:response.apiStatus.message] : @"";
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 创建结果字典
|
|
78
|
-
NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
|
|
79
|
-
resultDict[@"code"] = @(code);
|
|
80
|
-
resultDict[@"blackBox"] = blackBox;
|
|
81
|
-
resultDict[@"fpVersion"] = fpVersion;
|
|
82
|
-
resultDict[@"anonymousId"] = anonymousId;
|
|
83
|
-
resultDict[@"sealedResult"] = sealedResult;
|
|
84
|
-
resultDict[@"deviceRiskScore"] = @(deviceRiskScore);
|
|
85
|
-
resultDict[@"msg"] = message;
|
|
86
|
-
|
|
87
|
-
resolve(resultDict);
|
|
88
|
-
});
|
|
76
|
+
[self resolveDeviceInfo:resolve rejecter:reject];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
RCT_REMAP_METHOD(getDeviceInfoAsync,
|
|
80
|
+
getDeviceInfoAsyncResolver:(RCTPromiseResolveBlock)resolve
|
|
81
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
82
|
+
{
|
|
83
|
+
[self resolveDeviceInfo:resolve rejecter:reject];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (void)resolveDeviceInfo:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
|
|
87
|
+
TDDeviceManager_t *manager = [TDDeviceManager sharedManager];
|
|
88
|
+
if (manager == NULL || manager->getDeviceInfo == NULL) {
|
|
89
|
+
reject(@"device_info_unavailable", @"getDeviceInfo is unavailable", nil);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
manager->getDeviceInfo(^(TDDeviceResponse response) {
|
|
93
|
+
resolve(TDSeDeviceInfoDictionary(response));
|
|
94
|
+
});
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
RCT_EXPORT_METHOD(sign:(NSString*)path
|
|
@@ -144,32 +150,75 @@ RCT_REMAP_METHOD(showCaptcha,
|
|
|
144
150
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
145
151
|
{
|
|
146
152
|
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
147
|
-
|
|
153
|
+
if (manager == NULL || manager->showCaptcha == NULL) {
|
|
154
|
+
reject(@"captcha_unavailable", @"showCaptcha is unavailable", nil);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
148
157
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
149
158
|
UIWindow *keyWindow = [self getKeyWindow];
|
|
159
|
+
if (keyWindow == nil) {
|
|
160
|
+
reject(@"captcha_no_window", @"No active application window", nil);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
150
163
|
manager->showCaptcha(keyWindow,^(TDShowCaptchaResultStruct resultStruct) {
|
|
151
|
-
|
|
164
|
+
NSDictionary *resultDictionary;
|
|
152
165
|
switch (resultStruct.resultType) {
|
|
153
166
|
case TDShowCaptchaResultTypeSuccess:
|
|
154
|
-
resultDictionary
|
|
155
|
-
resultDictionary[@"token"] = @(resultStruct.validateToken);
|
|
167
|
+
resultDictionary = @{ @"function": @"onSuccess", @"token": TDSeString(resultStruct.validateToken) };
|
|
156
168
|
break;
|
|
157
169
|
case TDShowCaptchaResultTypeFailed:
|
|
158
|
-
resultDictionary
|
|
159
|
-
|
|
160
|
-
resultDictionary[@"errorMsg"] = @(resultStruct.errorMsg);
|
|
161
|
-
break;
|
|
162
|
-
case TDShowCaptchaResultTypeReady:
|
|
163
|
-
resultDictionary[@"function"] = @"onReady";
|
|
170
|
+
resultDictionary = @{ @"function": @"onFailed", @"errorCode": @(resultStruct.errorCode),
|
|
171
|
+
@"errorMsg": TDSeString(resultStruct.errorMsg) };
|
|
164
172
|
break;
|
|
173
|
+
case TDShowCaptchaResultTypeReady: {
|
|
174
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
175
|
+
[self sendEventWithName:@"TrustDeviceSeCaptcha" body:@{ @"function": @"onReady" }];
|
|
176
|
+
});
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
165
179
|
default:
|
|
166
|
-
|
|
180
|
+
return;
|
|
167
181
|
}
|
|
168
182
|
resolve(resultDictionary);
|
|
169
183
|
});
|
|
170
184
|
});
|
|
171
185
|
}
|
|
172
186
|
|
|
187
|
+
RCT_REMAP_METHOD(showLiveness,
|
|
188
|
+
showLivenessWithOptions:(NSDictionary *)options
|
|
189
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
190
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
191
|
+
{
|
|
192
|
+
TDMobRiskManager_t *manager = [TDMobRiskManager sharedManager];
|
|
193
|
+
if (manager == NULL || manager->showLivenessWithShowStyle == NULL) {
|
|
194
|
+
reject(@"liveness_unavailable", @"showLiveness is unavailable", nil);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
198
|
+
UIViewController *controller = [self getKeyWindow].rootViewController;
|
|
199
|
+
while (controller.presentedViewController != nil) {
|
|
200
|
+
controller = controller.presentedViewController;
|
|
201
|
+
}
|
|
202
|
+
if (controller == nil) {
|
|
203
|
+
reject(@"liveness_no_controller", @"No active view controller", nil);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
NSString *license = [options[@"license"] isKindOfClass:[NSString class]] ? options[@"license"] : nil;
|
|
207
|
+
TDLivenessShowStyle style = [options[@"showStyle"] isEqual:@"push"]
|
|
208
|
+
? TDLivenessShowStylePush : TDLivenessShowStylePresent;
|
|
209
|
+
manager->showLivenessWithShowStyle(controller, license, style,
|
|
210
|
+
^(NSDictionary *success) {
|
|
211
|
+
NSMutableDictionary *result = [success mutableCopy] ?: [NSMutableDictionary dictionary];
|
|
212
|
+
result[@"function"] = @"onSuccess";
|
|
213
|
+
resolve(result);
|
|
214
|
+
},
|
|
215
|
+
^(NSDictionary *failure) {
|
|
216
|
+
NSMutableDictionary *result = [failure mutableCopy] ?: [NSMutableDictionary dictionary];
|
|
217
|
+
result[@"function"] = @"onFailed";
|
|
218
|
+
resolve(result);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
173
222
|
|
|
174
223
|
|
|
175
224
|
|
package/package.json
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "2.0.0",
|
|
7
7
|
"description": "React Native TrustDevice component",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"react-native": "index.js",
|
|
10
|
+
"swiftpmConfig": {
|
|
11
|
+
"name": "ReactNativeTrustDevice"
|
|
12
|
+
},
|
|
10
13
|
"scripts": {
|
|
11
14
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
15
|
},
|
|
@@ -21,11 +24,14 @@
|
|
|
21
24
|
"react-native-trustdevice"
|
|
22
25
|
],
|
|
23
26
|
"files": [
|
|
24
|
-
"android",
|
|
27
|
+
"android/build.gradle",
|
|
28
|
+
"android/src",
|
|
25
29
|
"ios",
|
|
30
|
+
"Package.swift",
|
|
26
31
|
"src",
|
|
27
32
|
"index.js",
|
|
28
33
|
"index.d.ts",
|
|
34
|
+
"react-native.config.js",
|
|
29
35
|
"react-native-trustdevice.podspec"
|
|
30
36
|
],
|
|
31
37
|
|
|
@@ -34,4 +40,4 @@
|
|
|
34
40
|
"react": "*",
|
|
35
41
|
"react-native": "*"
|
|
36
42
|
}
|
|
37
|
-
}
|
|
43
|
+
}
|
package/src/TrustDevice.ios.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
3
|
-
import { requireNativeComponent,NativeModules } from 'react-native';
|
|
2
|
+
import {NativeModules} from 'react-native';
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
const TrustDevice = NativeModules.TrustDevice;
|
|
6
|
+
export const TrustDeviceSe = NativeModules.TrustDeviceSe;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
export default TrustDevice;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
o/classes
|
package/android/build/.transforms/34a3c3baa7ee620e604d2c62960577c0/transformed/classes/classes.dex
DELETED
|
Binary file
|
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
|
-
}
|
package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#Thu Jun 04 19:37:14 CST 2026
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/main/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/main/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/debug/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/debug/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated" generated-set="generated$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/build/generated/res/resValues/debug"/></dataSet><mergedItems/></merger>
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/main/jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/debug/jniLibs"/></dataSet></merger>
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/main/shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/debug/shaders"/></dataSet></merger>
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/main/assets"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/src/debug/assets"/></dataSet><dataSet config="generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/rhett/Code/dun/reactnew/TrustDeviceReactNative/node_modules/react-native-trustdevice/android/build/intermediates/shader_assets/debug/out"/></dataSet></merger>
|