react-native-shield-fraud-plugin 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/android/build.gradle +10 -4
- package/android/src/main/java/com/shieldfraudplugin/ShieldFraudPluginModule.java +10 -3
- package/android/src/main/java/com/shieldfraudplugin/ShieldFraudPluginPackage.java +1 -1
- package/ios/ShieldFraudPlugin.mm +10 -4
- package/lib/commonjs/NativeShieldFraudPlugin.js.map +1 -1
- package/lib/commonjs/index.js +24 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeShieldFraudPlugin.js.map +1 -1
- package/lib/module/index.js +24 -17
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/{NativeShieldFraudPlugin.d.ts → src/NativeShieldFraudPlugin.d.ts} +2 -1
- package/lib/typescript/src/NativeShieldFraudPlugin.d.ts.map +1 -0
- package/lib/typescript/{index.d.ts → src/index.d.ts} +7 -5
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +6 -2
- package/react-native-shield-fraud-plugin.podspec +3 -3
- package/react-native-shield-full-plugin.podspec +29 -0
- package/src/NativeShieldFraudPlugin.ts +2 -0
- package/src/index.tsx +45 -29
- package/lib/typescript/NativeShieldFraudPlugin.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -16,7 +16,9 @@ There are few steps to getting started with the SHIELD SDK:
|
|
|
16
16
|
|
|
17
17
|
5. [Send Custom Attributes](#send-custom-attributes)
|
|
18
18
|
|
|
19
|
-
6. [
|
|
19
|
+
6. [Send Device Fingerprint](#send-device-signature)
|
|
20
|
+
|
|
21
|
+
7. [Migration from BRIDGE CODE to PLUGIN](#migration-from-bridge-code-to-plugin)
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
|
|
@@ -167,6 +169,19 @@ ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
|
167
169
|
}
|
|
168
170
|
```
|
|
169
171
|
|
|
172
|
+
### Send Device Fingerprint
|
|
173
|
+
|
|
174
|
+
Use the sendDeviceSignature function to manually trigger device signature collection for a screen or user checkpoint.
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
// with screen name only
|
|
178
|
+
const deviceintelligence = await ShieldFraud.sendDeviceSignature('screen_name');
|
|
179
|
+
|
|
180
|
+
// with screen name and user id
|
|
181
|
+
const deviceintelligence = await ShieldFraud.sendDeviceSignature('screen_name', 'user_id');
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
|
|
170
185
|
### Migration from BRIDGE CODE to PLUGIN
|
|
171
186
|
If you've been using the old method of integrating the React Native bridge code for the Shield Fraud SDK on iOS and Android, follow these steps to migrate to our plugin.
|
|
172
187
|
|
package/android/build.gradle
CHANGED
|
@@ -13,6 +13,14 @@ def isNewArchitectureEnabled() {
|
|
|
13
13
|
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// Detect which npm package is installed by reading its own package.json.
|
|
17
|
+
// When published as react-native-shield-full-plugin the name field differs.
|
|
18
|
+
def packageJson = new groovy.json.JsonSlurper().parseText(
|
|
19
|
+
new File("${project.projectDir}/../package.json").text
|
|
20
|
+
)
|
|
21
|
+
def isFullPlugin = packageJson.name == "react-native-shield-full-plugin"
|
|
22
|
+
def shieldSdkArtifact = isFullPlugin ? "com.shield.android:shield:2.6.1" : "com.shield.android:shield-fraud:2.6.1"
|
|
23
|
+
|
|
16
24
|
apply plugin: "com.android.library"
|
|
17
25
|
|
|
18
26
|
if (isNewArchitectureEnabled()) {
|
|
@@ -95,9 +103,7 @@ rootProject.allprojects {
|
|
|
95
103
|
dependencies {
|
|
96
104
|
// For < 0.71, this will be from the local maven repo
|
|
97
105
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
98
|
-
|
|
99
|
-
implementation "com.facebook.react:react-native:+"
|
|
106
|
+
implementation "com.facebook.react:react-native:0.71.7"
|
|
100
107
|
|
|
101
|
-
|
|
102
|
-
implementation 'com.shield.android:shield-fraud:2.4.0'
|
|
108
|
+
implementation shieldSdkArtifact
|
|
103
109
|
}
|
|
@@ -27,6 +27,7 @@ import com.shield.android.ShieldCrossPlatformHelper;
|
|
|
27
27
|
import com.shield.android.ShieldCrossPlatformParams;
|
|
28
28
|
import com.shield.android.ShieldError;
|
|
29
29
|
import com.shield.android.ShieldFactory;
|
|
30
|
+
import com.shield.android.ShieldUserData;
|
|
30
31
|
|
|
31
32
|
import org.json.JSONArray;
|
|
32
33
|
import org.json.JSONObject;
|
|
@@ -48,9 +49,9 @@ import java.util.Map;
|
|
|
48
49
|
* 5. sendAttributes : void return
|
|
49
50
|
* → shield.sendAttributesWithCallback (Result<String> callback)
|
|
50
51
|
* 6. LogLevel enum : Shield.LogLevel.VERBOSE/DEBUG/INFO/NONE
|
|
51
|
-
* → LogLevel.DEBUG / INFO / NONE
|
|
52
|
+
* → LogLevel.VERBOSE / DEBUG / INFO / NONE
|
|
52
53
|
* 7. Environment enum : String constants ENVIRONMENT_PROD / DEV / STAGING
|
|
53
|
-
* → Environment.PROD / DEV
|
|
54
|
+
* → Environment.PROD / DEV / STAGING
|
|
54
55
|
*
|
|
55
56
|
* Architecture segmentation
|
|
56
57
|
* ─────────────────────────
|
|
@@ -283,6 +284,7 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
283
284
|
@ReactMethod
|
|
284
285
|
public void sendDeviceSignature(
|
|
285
286
|
String screenName,
|
|
287
|
+
@Nullable String userId,
|
|
286
288
|
Callback successCallback,
|
|
287
289
|
Callback errorCallback) {
|
|
288
290
|
if (shield == null) {
|
|
@@ -290,7 +292,12 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
290
292
|
return;
|
|
291
293
|
}
|
|
292
294
|
|
|
293
|
-
|
|
295
|
+
ShieldUserData userData = new ShieldUserData(screenName);
|
|
296
|
+
if (userId != null) {
|
|
297
|
+
userData.setUserId(userId);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
shield.sendDeviceSignatureWithCallback(userData, result ->
|
|
294
301
|
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
|
|
295
302
|
if (result instanceof Result.Success) {
|
|
296
303
|
JSONObject json = shield.getLatestDeviceResult();
|
|
@@ -67,7 +67,7 @@ public class ShieldFraudPluginPackage extends TurboReactPackage {
|
|
|
67
67
|
ShieldFraudPluginModule.NAME, // className
|
|
68
68
|
false, // canOverrideExistingModule
|
|
69
69
|
false, // needsEagerInit
|
|
70
|
-
|
|
70
|
+
false, // hasConstants
|
|
71
71
|
false, // isCxxModule
|
|
72
72
|
isTurboModule // isTurboModule
|
|
73
73
|
)
|
package/ios/ShieldFraudPlugin.mm
CHANGED
|
@@ -37,13 +37,13 @@ RCT_EXPORT_METHOD(getLatestDeviceResult:(RCTResponseSenderBlock)successCallback
|
|
|
37
37
|
errorCallback:(RCTResponseSenderBlock)errorCallback)
|
|
38
38
|
{
|
|
39
39
|
NSDictionary<NSString *, id> *result = [[Shield shared] getLatestDeviceResult];
|
|
40
|
-
if (result !=
|
|
40
|
+
if (result != nil) {
|
|
41
41
|
successCallback(@[result]);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
NSError *error = [[Shield shared] getErrorResponse];
|
|
46
|
-
if (error !=
|
|
46
|
+
if (error != nil) {
|
|
47
47
|
errorCallback(@[[error localizedDescription]]);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
@@ -95,14 +95,20 @@ RCT_EXPORT_METHOD(sendAttributesWithCallback:(NSString *)screenName
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// Trigger a device signature computation for a given screen name.
|
|
98
|
+
// Pass userId to associate the result with a specific user.
|
|
98
99
|
// The completionHandler fires when the SDK is done; results and errors
|
|
99
100
|
// are read back from getLatestDeviceResult / getErrorResponse.
|
|
100
101
|
RCT_EXPORT_METHOD(sendDeviceSignature:(NSString *)screenName
|
|
102
|
+
userId:(NSString * _Nullable)userId
|
|
101
103
|
successCallback:(RCTResponseSenderBlock)successCallback
|
|
102
104
|
errorCallback:(RCTResponseSenderBlock)errorCallback)
|
|
103
105
|
{
|
|
104
|
-
[[
|
|
105
|
-
|
|
106
|
+
ShieldUserData *userData = [[ShieldUserData alloc]
|
|
107
|
+
initWithScreenName:screenName
|
|
108
|
+
userId:userId];
|
|
109
|
+
|
|
110
|
+
[[Shield shared] sendDeviceSignatureWithUserData:userData
|
|
111
|
+
completionHandler:^{
|
|
106
112
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
107
113
|
NSDictionary<NSString *, id> *deviceResult = [[Shield shared] getLatestDeviceResult];
|
|
108
114
|
if (deviceResult != nil) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","TurboModuleRegistry","getEnforcing","exports","default"],"sourceRoot":"../../src","sources":["NativeShieldFraudPlugin.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AAJA,IAAAC,QAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","TurboModuleRegistry","getEnforcing","exports","default"],"sourceRoot":"../../src","sources":["NativeShieldFraudPlugin.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AAJA,IAAAC,QAAA,GAmFeC,gCAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.LogLevel = exports.EnvironmentInfo = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
+
var _package = _interopRequireDefault(require("../package.json"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
10
|
/**
|
|
9
11
|
* Resolve the native module through TurboModuleRegistry (New Architecture)
|
|
10
12
|
* with a fallback to NativeModules bridge (Old Architecture).
|
|
11
13
|
*/
|
|
12
|
-
const ShieldFraudPluginNativeModule = _reactNative.TurboModuleRegistry.get(
|
|
14
|
+
const ShieldFraudPluginNativeModule = _reactNative.TurboModuleRegistry.get('ShieldFraudPlugin') ?? _reactNative.NativeModules.ShieldFraudPlugin;
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Enum representing the log levels for ShieldFraud.
|
|
@@ -61,6 +63,7 @@ class ShieldFraud {
|
|
|
61
63
|
* The event emitter for listening to success and error events.
|
|
62
64
|
*/
|
|
63
65
|
static eventEmitter = new _reactNative.NativeEventEmitter(ShieldFraud.PlatformWrapper);
|
|
66
|
+
static callbackSubscriptions = {};
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
69
|
* Initializes the ShieldFraud plugin with the provided configuration.
|
|
@@ -83,7 +86,7 @@ class ShieldFraud {
|
|
|
83
86
|
// blockScreenRecording is Android-only; iOS native ignores the value.
|
|
84
87
|
// Always send a real boolean — the Old Arch bridge cannot handle null
|
|
85
88
|
// for boolean parameters (causes NPE in ReadableNativeArray.getBoolean).
|
|
86
|
-
const blockScreenRecording = _reactNative.Platform.OS ===
|
|
89
|
+
const blockScreenRecording = _reactNative.Platform.OS === 'android' ? config.blockScreenRecording ?? false : false;
|
|
87
90
|
|
|
88
91
|
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
89
92
|
await ShieldFraud.PlatformWrapper.initShield(config.siteID, config.secretKey, isOptimizedListener, config.blockedDialog ?? null, logLevel, environmentInfo, blockScreenRecording);
|
|
@@ -98,8 +101,8 @@ class ShieldFraud {
|
|
|
98
101
|
* The cross-platform name and the version is fetched from package.json.
|
|
99
102
|
*/
|
|
100
103
|
static setCrossPlatformParameters() {
|
|
101
|
-
const crossPlatformName =
|
|
102
|
-
const crossPlatformVersion =
|
|
104
|
+
const crossPlatformName = _package.default.name;
|
|
105
|
+
const crossPlatformVersion = _package.default.version;
|
|
103
106
|
ShieldFraud.PlatformWrapper.setCrossPlatformParameters(crossPlatformName, crossPlatformVersion);
|
|
104
107
|
}
|
|
105
108
|
|
|
@@ -109,15 +112,19 @@ class ShieldFraud {
|
|
|
109
112
|
* @param callbacks - The callback functions for success and failure events.
|
|
110
113
|
*/
|
|
111
114
|
static listeners(callbacks) {
|
|
115
|
+
var _ShieldFraud$callback, _ShieldFraud$callback2;
|
|
116
|
+
(_ShieldFraud$callback = ShieldFraud.callbackSubscriptions.success) === null || _ShieldFraud$callback === void 0 ? void 0 : _ShieldFraud$callback.remove();
|
|
117
|
+
(_ShieldFraud$callback2 = ShieldFraud.callbackSubscriptions.error) === null || _ShieldFraud$callback2 === void 0 ? void 0 : _ShieldFraud$callback2.remove();
|
|
118
|
+
|
|
112
119
|
// Listen for success events and invoke the onSuccess callback if provided.
|
|
113
|
-
ShieldFraud.eventEmitter.addListener(
|
|
120
|
+
ShieldFraud.callbackSubscriptions.success = ShieldFraud.eventEmitter.addListener('success', data => {
|
|
114
121
|
if (callbacks !== null && callbacks !== void 0 && callbacks.onSuccess) {
|
|
115
122
|
callbacks.onSuccess(data);
|
|
116
123
|
}
|
|
117
124
|
});
|
|
118
125
|
|
|
119
126
|
// Listen for error events and invoke the onFailure callback if provided.
|
|
120
|
-
ShieldFraud.eventEmitter.addListener(
|
|
127
|
+
ShieldFraud.callbackSubscriptions.error = ShieldFraud.eventEmitter.addListener('error', error => {
|
|
121
128
|
if (callbacks !== null && callbacks !== void 0 && callbacks.onFailure) {
|
|
122
129
|
callbacks.onFailure(error);
|
|
123
130
|
}
|
|
@@ -127,7 +134,7 @@ class ShieldFraud {
|
|
|
127
134
|
/**
|
|
128
135
|
* Retrieves the session ID from the ShieldFraud plugin.
|
|
129
136
|
*
|
|
130
|
-
* @returns
|
|
137
|
+
* @returns The current session ID.
|
|
131
138
|
*/
|
|
132
139
|
static getSessionId() {
|
|
133
140
|
return ShieldFraud.PlatformWrapper.getSessionId();
|
|
@@ -136,7 +143,7 @@ class ShieldFraud {
|
|
|
136
143
|
/**
|
|
137
144
|
* Checks whether the ShieldFraud plugin is initialized.
|
|
138
145
|
*
|
|
139
|
-
* @returns
|
|
146
|
+
* @returns Whether the ShieldFraud plugin is initialized.
|
|
140
147
|
*/
|
|
141
148
|
static isShieldInitialized() {
|
|
142
149
|
return ShieldFraud.PlatformWrapper.isShieldInitialized();
|
|
@@ -153,7 +160,7 @@ class ShieldFraud {
|
|
|
153
160
|
* - `isReady` (boolean): true when the SDK has produced a device result.
|
|
154
161
|
*/
|
|
155
162
|
static async isSDKready(callback) {
|
|
156
|
-
if (_reactNative.Platform.OS ===
|
|
163
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
157
164
|
const isInitialized = await this.isShieldInitialized();
|
|
158
165
|
callback(isInitialized);
|
|
159
166
|
return;
|
|
@@ -163,22 +170,22 @@ class ShieldFraud {
|
|
|
163
170
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
164
171
|
const isInitialized = await this.isShieldInitialized();
|
|
165
172
|
if (!isInitialized) {
|
|
166
|
-
console.log(
|
|
173
|
+
console.log('Shield SDK not initialized:');
|
|
167
174
|
callback(false);
|
|
168
175
|
return;
|
|
169
176
|
}
|
|
170
177
|
const deviceResultListener = event => {
|
|
171
|
-
if (event.status ===
|
|
172
|
-
ShieldFraud.eventEmitter.removeAllListeners(
|
|
178
|
+
if (event.status === 'isSDKReady') {
|
|
179
|
+
ShieldFraud.eventEmitter.removeAllListeners('device_result_state');
|
|
173
180
|
callback(true);
|
|
174
181
|
}
|
|
175
182
|
};
|
|
176
|
-
ShieldFraud.eventEmitter.addListener(
|
|
183
|
+
ShieldFraud.eventEmitter.addListener('device_result_state', deviceResultListener);
|
|
177
184
|
|
|
178
185
|
// Trigger the SDK subscription — iOS 1.x requires this explicit call.
|
|
179
186
|
ShieldFraud.PlatformWrapper.setDeviceResultStateListener();
|
|
180
187
|
} catch (error) {
|
|
181
|
-
console.error(
|
|
188
|
+
console.error('An error occurred:', error);
|
|
182
189
|
callback(false);
|
|
183
190
|
}
|
|
184
191
|
}
|
|
@@ -231,11 +238,12 @@ class ShieldFraud {
|
|
|
231
238
|
* On failure, rejects with the error message.
|
|
232
239
|
*
|
|
233
240
|
* @param screenName - The name of the screen triggering the signature.
|
|
241
|
+
* @param userId - (Optional) A user ID to associate with the device signature.
|
|
234
242
|
* @returns A Promise that resolves with the device result or rejects with an error.
|
|
235
243
|
*/
|
|
236
|
-
static sendDeviceSignature(screenName) {
|
|
244
|
+
static sendDeviceSignature(screenName, userId) {
|
|
237
245
|
return new Promise((resolve, reject) => {
|
|
238
|
-
ShieldFraud.PlatformWrapper.sendDeviceSignature(screenName, result => {
|
|
246
|
+
ShieldFraud.PlatformWrapper.sendDeviceSignature(screenName, userId ?? null, result => {
|
|
239
247
|
resolve(result);
|
|
240
248
|
}, error => {
|
|
241
249
|
reject(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","ShieldFraudPluginNativeModule","TurboModuleRegistry","get","NativeModules","ShieldFraudPlugin","LogLevel","exports","EnvironmentInfo","ShieldFraud","PlatformWrapper","eventEmitter","NativeEventEmitter","initShield","config","callbacks","isOptimizedListener","logLevel","LogLevelNone","environmentInfo","EnvironmentProd","setCrossPlatformParameters","blockScreenRecording","Platform","OS","siteID","secretKey","blockedDialog","listeners","crossPlatformName","crossPlatformVersion","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_package","_interopRequireDefault","obj","__esModule","default","ShieldFraudPluginNativeModule","TurboModuleRegistry","get","NativeModules","ShieldFraudPlugin","LogLevel","exports","EnvironmentInfo","ShieldFraud","PlatformWrapper","eventEmitter","NativeEventEmitter","callbackSubscriptions","initShield","config","callbacks","isOptimizedListener","logLevel","LogLevelNone","environmentInfo","EnvironmentProd","setCrossPlatformParameters","blockScreenRecording","Platform","OS","siteID","secretKey","blockedDialog","listeners","crossPlatformName","packageJson","name","crossPlatformVersion","version","_ShieldFraud$callback","_ShieldFraud$callback2","success","remove","error","addListener","data","onSuccess","onFailure","getSessionId","isShieldInitialized","isSDKready","callback","isInitialized","Promise","resolve","setTimeout","console","log","deviceResultListener","event","status","removeAllListeners","setDeviceResultStateListener","sendAttributes","screenName","sendAttributesWithCallback","reject","result","getLatestDeviceResult","sendDeviceSignature","userId","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0C,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1C;AACA;AACA;AACA;AACA,MAAMG,6BAA6B,GACjCC,gCAAmB,CAACC,GAAG,CAAM,mBAAmB,CAAC,IACjDC,0BAAa,CAACC,iBAAiB;;AAEjC;AACA;AACA;AAFA,IAGYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAOpB;AACA;AACA;AAFAC,OAAA,CAAAD,QAAA,GAAAA,QAAA;AAAA,IAGYE,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA,OAGD;AAG1B;AACA;AACA;AAkBA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAFAD,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAQA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,CAAC;EAChB;AACF;AACA;AACA;AACA;EACE,OAAeC,eAAe,GAAGT,6BAA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a,IAAK;QACjBuB,MAAM,CAACvB,KAAK,CAAC;MACf,CAAC,CACF;IACH,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAcyB,qBAAqBA,CAAA,EAAoB;IACrD,OAAO,IAAIf,OAAO,CAAC,CAACC,OAAO,EAAEY,MAAM,KAAK;MACtCrD,WAAW,CAACC,eAAe,CAACsD,qBAAqB,CAC9CD,MAAc,IAAK;QAClBb,OAAO,CAACa,MAAM,CAAC;MACjB,CAAC,EACAxB,KAAa,IAAK;QACjBuB,MAAM,CAACvB,KAAK,CAAC;MACf,CAAC,CACF;IACH,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAc0B,mBAAmBA,CAC/BL,UAAkB,EAClBM,MAAe,EACE;IACjB,OAAO,IAAIjB,OAAO,CAAC,CAACC,OAAO,EAAEY,MAAM,KAAK;MACtCrD,WAAW,CAACC,eAAe,CAACuD,mBAAmB,CAC7CL,UAAU,EACVM,MAAM,IAAI,IAAI,EACbH,MAAc,IAAK;QAClBb,OAAO,CAACa,MAAM,CAAC;MACjB,CAAC,EACAxB,KAAa,IAAK;QACjBuB,MAAM,CAACvB,KAAK,CAAC;MACf,CAAC,CACF;IACH,CAAC,CAAC;EACJ;AACF;AAAC,IAAA4B,QAAA,GAEc1D,WAAW;AAAAF,OAAA,CAAAP,OAAA,GAAAmE,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeShieldFraudPlugin.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAElD;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeShieldFraudPlugin.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAElD;AACA;AACA;AACA;AACA;;AA+EA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { NativeModules, NativeEventEmitter, Platform, TurboModuleRegistry } from
|
|
1
|
+
import { NativeModules, NativeEventEmitter, Platform, TurboModuleRegistry } from 'react-native';
|
|
2
|
+
import packageJson from '../package.json';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Resolve the native module through TurboModuleRegistry (New Architecture)
|
|
5
6
|
* with a fallback to NativeModules bridge (Old Architecture).
|
|
6
7
|
*/
|
|
7
|
-
const ShieldFraudPluginNativeModule = TurboModuleRegistry.get(
|
|
8
|
+
const ShieldFraudPluginNativeModule = TurboModuleRegistry.get('ShieldFraudPlugin') ?? NativeModules.ShieldFraudPlugin;
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Enum representing the log levels for ShieldFraud.
|
|
@@ -60,6 +61,7 @@ class ShieldFraud {
|
|
|
60
61
|
* The event emitter for listening to success and error events.
|
|
61
62
|
*/
|
|
62
63
|
static eventEmitter = new NativeEventEmitter(ShieldFraud.PlatformWrapper);
|
|
64
|
+
static callbackSubscriptions = {};
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
67
|
* Initializes the ShieldFraud plugin with the provided configuration.
|
|
@@ -82,7 +84,7 @@ class ShieldFraud {
|
|
|
82
84
|
// blockScreenRecording is Android-only; iOS native ignores the value.
|
|
83
85
|
// Always send a real boolean — the Old Arch bridge cannot handle null
|
|
84
86
|
// for boolean parameters (causes NPE in ReadableNativeArray.getBoolean).
|
|
85
|
-
const blockScreenRecording = Platform.OS ===
|
|
87
|
+
const blockScreenRecording = Platform.OS === 'android' ? config.blockScreenRecording ?? false : false;
|
|
86
88
|
|
|
87
89
|
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
88
90
|
await ShieldFraud.PlatformWrapper.initShield(config.siteID, config.secretKey, isOptimizedListener, config.blockedDialog ?? null, logLevel, environmentInfo, blockScreenRecording);
|
|
@@ -97,8 +99,8 @@ class ShieldFraud {
|
|
|
97
99
|
* The cross-platform name and the version is fetched from package.json.
|
|
98
100
|
*/
|
|
99
101
|
static setCrossPlatformParameters() {
|
|
100
|
-
const crossPlatformName =
|
|
101
|
-
const crossPlatformVersion =
|
|
102
|
+
const crossPlatformName = packageJson.name;
|
|
103
|
+
const crossPlatformVersion = packageJson.version;
|
|
102
104
|
ShieldFraud.PlatformWrapper.setCrossPlatformParameters(crossPlatformName, crossPlatformVersion);
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -108,15 +110,19 @@ class ShieldFraud {
|
|
|
108
110
|
* @param callbacks - The callback functions for success and failure events.
|
|
109
111
|
*/
|
|
110
112
|
static listeners(callbacks) {
|
|
113
|
+
var _ShieldFraud$callback, _ShieldFraud$callback2;
|
|
114
|
+
(_ShieldFraud$callback = ShieldFraud.callbackSubscriptions.success) === null || _ShieldFraud$callback === void 0 ? void 0 : _ShieldFraud$callback.remove();
|
|
115
|
+
(_ShieldFraud$callback2 = ShieldFraud.callbackSubscriptions.error) === null || _ShieldFraud$callback2 === void 0 ? void 0 : _ShieldFraud$callback2.remove();
|
|
116
|
+
|
|
111
117
|
// Listen for success events and invoke the onSuccess callback if provided.
|
|
112
|
-
ShieldFraud.eventEmitter.addListener(
|
|
118
|
+
ShieldFraud.callbackSubscriptions.success = ShieldFraud.eventEmitter.addListener('success', data => {
|
|
113
119
|
if (callbacks !== null && callbacks !== void 0 && callbacks.onSuccess) {
|
|
114
120
|
callbacks.onSuccess(data);
|
|
115
121
|
}
|
|
116
122
|
});
|
|
117
123
|
|
|
118
124
|
// Listen for error events and invoke the onFailure callback if provided.
|
|
119
|
-
ShieldFraud.eventEmitter.addListener(
|
|
125
|
+
ShieldFraud.callbackSubscriptions.error = ShieldFraud.eventEmitter.addListener('error', error => {
|
|
120
126
|
if (callbacks !== null && callbacks !== void 0 && callbacks.onFailure) {
|
|
121
127
|
callbacks.onFailure(error);
|
|
122
128
|
}
|
|
@@ -126,7 +132,7 @@ class ShieldFraud {
|
|
|
126
132
|
/**
|
|
127
133
|
* Retrieves the session ID from the ShieldFraud plugin.
|
|
128
134
|
*
|
|
129
|
-
* @returns
|
|
135
|
+
* @returns The current session ID.
|
|
130
136
|
*/
|
|
131
137
|
static getSessionId() {
|
|
132
138
|
return ShieldFraud.PlatformWrapper.getSessionId();
|
|
@@ -135,7 +141,7 @@ class ShieldFraud {
|
|
|
135
141
|
/**
|
|
136
142
|
* Checks whether the ShieldFraud plugin is initialized.
|
|
137
143
|
*
|
|
138
|
-
* @returns
|
|
144
|
+
* @returns Whether the ShieldFraud plugin is initialized.
|
|
139
145
|
*/
|
|
140
146
|
static isShieldInitialized() {
|
|
141
147
|
return ShieldFraud.PlatformWrapper.isShieldInitialized();
|
|
@@ -152,7 +158,7 @@ class ShieldFraud {
|
|
|
152
158
|
* - `isReady` (boolean): true when the SDK has produced a device result.
|
|
153
159
|
*/
|
|
154
160
|
static async isSDKready(callback) {
|
|
155
|
-
if (Platform.OS ===
|
|
161
|
+
if (Platform.OS === 'android') {
|
|
156
162
|
const isInitialized = await this.isShieldInitialized();
|
|
157
163
|
callback(isInitialized);
|
|
158
164
|
return;
|
|
@@ -162,22 +168,22 @@ class ShieldFraud {
|
|
|
162
168
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
163
169
|
const isInitialized = await this.isShieldInitialized();
|
|
164
170
|
if (!isInitialized) {
|
|
165
|
-
console.log(
|
|
171
|
+
console.log('Shield SDK not initialized:');
|
|
166
172
|
callback(false);
|
|
167
173
|
return;
|
|
168
174
|
}
|
|
169
175
|
const deviceResultListener = event => {
|
|
170
|
-
if (event.status ===
|
|
171
|
-
ShieldFraud.eventEmitter.removeAllListeners(
|
|
176
|
+
if (event.status === 'isSDKReady') {
|
|
177
|
+
ShieldFraud.eventEmitter.removeAllListeners('device_result_state');
|
|
172
178
|
callback(true);
|
|
173
179
|
}
|
|
174
180
|
};
|
|
175
|
-
ShieldFraud.eventEmitter.addListener(
|
|
181
|
+
ShieldFraud.eventEmitter.addListener('device_result_state', deviceResultListener);
|
|
176
182
|
|
|
177
183
|
// Trigger the SDK subscription — iOS 1.x requires this explicit call.
|
|
178
184
|
ShieldFraud.PlatformWrapper.setDeviceResultStateListener();
|
|
179
185
|
} catch (error) {
|
|
180
|
-
console.error(
|
|
186
|
+
console.error('An error occurred:', error);
|
|
181
187
|
callback(false);
|
|
182
188
|
}
|
|
183
189
|
}
|
|
@@ -230,11 +236,12 @@ class ShieldFraud {
|
|
|
230
236
|
* On failure, rejects with the error message.
|
|
231
237
|
*
|
|
232
238
|
* @param screenName - The name of the screen triggering the signature.
|
|
239
|
+
* @param userId - (Optional) A user ID to associate with the device signature.
|
|
233
240
|
* @returns A Promise that resolves with the device result or rejects with an error.
|
|
234
241
|
*/
|
|
235
|
-
static sendDeviceSignature(screenName) {
|
|
242
|
+
static sendDeviceSignature(screenName, userId) {
|
|
236
243
|
return new Promise((resolve, reject) => {
|
|
237
|
-
ShieldFraud.PlatformWrapper.sendDeviceSignature(screenName, result => {
|
|
244
|
+
ShieldFraud.PlatformWrapper.sendDeviceSignature(screenName, userId ?? null, result => {
|
|
238
245
|
resolve(result);
|
|
239
246
|
}, error => {
|
|
240
247
|
reject(error);
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","TurboModuleRegistry","ShieldFraudPluginNativeModule","get","ShieldFraudPlugin","LogLevel","EnvironmentInfo","ShieldFraud","PlatformWrapper","eventEmitter","initShield","config","callbacks","isOptimizedListener","logLevel","LogLevelNone","environmentInfo","EnvironmentProd","setCrossPlatformParameters","blockScreenRecording","OS","siteID","secretKey","blockedDialog","listeners","crossPlatformName","crossPlatformVersion","
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","TurboModuleRegistry","packageJson","ShieldFraudPluginNativeModule","get","ShieldFraudPlugin","LogLevel","EnvironmentInfo","ShieldFraud","PlatformWrapper","eventEmitter","callbackSubscriptions","initShield","config","callbacks","isOptimizedListener","logLevel","LogLevelNone","environmentInfo","EnvironmentProd","setCrossPlatformParameters","blockScreenRecording","OS","siteID","secretKey","blockedDialog","listeners","crossPlatformName","name","crossPlatformVersion","version","_ShieldFraud$callback","_ShieldFraud$callback2","success","remove","error","addListener","data","onSuccess","onFailure","getSessionId","isShieldInitialized","isSDKready","callback","isInitialized","Promise","resolve","setTimeout","console","log","deviceResultListener","event","status","removeAllListeners","setDeviceResultStateListener","sendAttributes","screenName","sendAttributesWithCallback","reject","result","getLatestDeviceResult","sendDeviceSignature","userId"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SACEA,aAAa,EACbC,kBAAkB,EAClBC,QAAQ,EACRC,mBAAmB,QACd,cAAc;AACrB,OAAOC,WAAW,MAAM,iBAAiB;;AAEzC;AACA;AACA;AACA;AACA,MAAMC,6BAA6B,GACjCF,mBAAmB,CAACG,GAAG,CAAM,mBAAmB,CAAC,IACjDN,aAAa,CAACO,iBAAiB;;AAEjC;AACA;AACA;AACA,WAAYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;;AAOpB;AACA;AACA;AACA,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA,OAGD;;AAG1B;AACA;AACA;;AAkBA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,CAAC;EAChB;AACF;AACA;AACA;AACA;EACE,OAAeC,eAAe,GAAGN,6BAA6B;;EAE9D;AACF;AACA;EACE,OAAeO,YAAY,GAAG,IAAIX,kBA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IACH,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAcyB,qBAAqBA,CAAA,EAAoB;IACrD,OAAO,IAAIf,OAAO,CAAC,CAACC,OAAO,EAAEY,MAAM,KAAK;MACtClD,WAAW,CAACC,eAAe,CAACmD,qBAAqB,CAC9CD,MAAc,IAAK;QAClBb,OAAO,CAACa,MAAM,CAAC;MACjB,CAAC,EACAxB,KAAa,IAAK;QACjBuB,MAAM,CAACvB,KAAK,CAAC;MACf,CAAC,CACF;IACH,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAc0B,mBAAmBA,CAC/BL,UAAkB,EAClBM,MAAe,EACE;IACjB,OAAO,IAAIjB,OAAO,CAAC,CAACC,OAAO,EAAEY,MAAM,KAAK;MACtClD,WAAW,CAACC,eAAe,CAACoD,mBAAmB,CAC7CL,UAAU,EACVM,MAAM,IAAI,IAAI,EACbH,MAAc,IAAK;QAClBb,OAAO,CAACa,MAAM,CAAC;MACjB,CAAC,EACAxB,KAAa,IAAK;QACjBuB,MAAM,CAACvB,KAAK,CAAC;MACf,CAAC,CACF;IACH,CAAC,CAAC;EACJ;AACF;AAEA,eAAe3B,WAAW"}
|
|
@@ -42,8 +42,9 @@ export interface Spec extends TurboModule {
|
|
|
42
42
|
/**
|
|
43
43
|
* Triggers a device signature computation for a given screen and returns
|
|
44
44
|
* the latest device result (or error) via callbacks once complete.
|
|
45
|
+
* Pass userId to associate the result with a specific user.
|
|
45
46
|
*/
|
|
46
|
-
sendDeviceSignature(screenName: string, successCallback: (result: Object) => void, errorCallback: (error: string) => void): void;
|
|
47
|
+
sendDeviceSignature(screenName: string, userId: string | null, successCallback: (result: Object) => void, errorCallback: (error: string) => void): void;
|
|
47
48
|
addListener(eventName: string): void;
|
|
48
49
|
removeListeners(count: number): void;
|
|
49
50
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeShieldFraudPlugin.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,MAAM,KAAK,IAAI,EACzC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GACrC,IAAI,CAAC;IAGR,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAED,wBAA2E"}
|
|
@@ -65,6 +65,7 @@ declare class ShieldFraud {
|
|
|
65
65
|
* The event emitter for listening to success and error events.
|
|
66
66
|
*/
|
|
67
67
|
private static eventEmitter;
|
|
68
|
+
private static callbackSubscriptions;
|
|
68
69
|
/**
|
|
69
70
|
* Initializes the ShieldFraud plugin with the provided configuration.
|
|
70
71
|
*
|
|
@@ -86,15 +87,15 @@ declare class ShieldFraud {
|
|
|
86
87
|
/**
|
|
87
88
|
* Retrieves the session ID from the ShieldFraud plugin.
|
|
88
89
|
*
|
|
89
|
-
* @returns
|
|
90
|
+
* @returns The current session ID.
|
|
90
91
|
*/
|
|
91
|
-
static getSessionId():
|
|
92
|
+
static getSessionId(): string;
|
|
92
93
|
/**
|
|
93
94
|
* Checks whether the ShieldFraud plugin is initialized.
|
|
94
95
|
*
|
|
95
|
-
* @returns
|
|
96
|
+
* @returns Whether the ShieldFraud plugin is initialized.
|
|
96
97
|
*/
|
|
97
|
-
static isShieldInitialized():
|
|
98
|
+
static isShieldInitialized(): boolean;
|
|
98
99
|
/**
|
|
99
100
|
* Checks if the ShieldFraud SDK is ready and invokes the provided callback
|
|
100
101
|
* with the readiness state.
|
|
@@ -133,9 +134,10 @@ declare class ShieldFraud {
|
|
|
133
134
|
* On failure, rejects with the error message.
|
|
134
135
|
*
|
|
135
136
|
* @param screenName - The name of the screen triggering the signature.
|
|
137
|
+
* @param userId - (Optional) A user ID to associate with the device signature.
|
|
136
138
|
* @returns A Promise that resolves with the device result or rejects with an error.
|
|
137
139
|
*/
|
|
138
|
-
static sendDeviceSignature(screenName: string): Promise<object>;
|
|
140
|
+
static sendDeviceSignature(screenName: string, userId?: string): Promise<object>;
|
|
139
141
|
}
|
|
140
142
|
export default ShieldFraud;
|
|
141
143
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAgBA;;GAEG;AACH,oBAAY,QAAQ;IAClB,eAAe,IAAI;IACnB,aAAa,IAAI;IACjB,YAAY,IAAI;IAChB,YAAY,IAAI;CACjB;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,eAAe,IAAI;IACnB,cAAc,IAAI;IAClB,kBAAkB,IAAI;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI,CAAC;IACT,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,KAAK,eAAe,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAE3C;;GAEG;AACH,KAAK,eAAe,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,cAAM,WAAW;IACf;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe,CAAiC;IAE/D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY,CAEzB;IAEF,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAG7B;IAEP;;;;;OAKG;WACiB,UAAU,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,IAAI,CAAC;IAoChB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAUzC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAqBxB;;;;OAIG;WACW,YAAY,IAAI,MAAM;IAIpC;;;;OAIG;WACW,mBAAmB,IAAI,OAAO;IAI5C;;;;;;;;;OASG;WACiB,UAAU,CAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GACnC,OAAO,CAAC,IAAI,CAAC;IAuChB;;;;;OAKG;WACW,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIpE;;;;;;OAMG;WACW,0BAA0B,CACtC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC;IAenB;;;;OAIG;WACW,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAatD;;;;;;;;OAQG;WACW,mBAAmB,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;CAcnB;AAED,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-shield-fraud-plugin",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "React Native Shield Fraud Plugin helps developers to assess malicious activities performed on mobile devices and return risk intelligence based on user's behaviour. It collects device's fingerprint, social metrics and network information.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -34,7 +34,11 @@
|
|
|
34
34
|
"release": "release-it",
|
|
35
35
|
"example": "yarn --cwd example",
|
|
36
36
|
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
37
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
37
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build",
|
|
38
|
+
"bump": "bash scripts/bump-version.sh",
|
|
39
|
+
"publish": "node scripts/publish.js",
|
|
40
|
+
"use-fraud": "node scripts/use-plugin.js fraud",
|
|
41
|
+
"use-full": "node scripts/use-plugin.js full"
|
|
38
42
|
},
|
|
39
43
|
"keywords": [
|
|
40
44
|
"react-native",
|
|
@@ -3,7 +3,7 @@ require "json"
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "
|
|
6
|
+
s.name = package["name"]
|
|
7
7
|
s.version = package["version"]
|
|
8
8
|
s.summary = package["description"]
|
|
9
9
|
s.homepage = package["homepage"]
|
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
13
|
s.platforms = { :ios => "12.0" }
|
|
14
|
-
s.source = { :git => "https://github.com/
|
|
14
|
+
s.source = { :git => "https://github.com/shield-ai-technology/react-native-shield-fraud-plugin.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm}"
|
|
17
17
|
|
|
@@ -25,5 +25,5 @@ Pod::Spec.new do |s|
|
|
|
25
25
|
# and replaces the legacy `s.dependency "React"` call.
|
|
26
26
|
install_modules_dependencies(s)
|
|
27
27
|
|
|
28
|
-
s.dependency "ShieldFraud", ">= 1.5.
|
|
28
|
+
s.dependency "ShieldFraud", ">= 1.5.59"
|
|
29
29
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = package["name"]
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "12.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/shield-ai-technology/react-native-shield-fraud-plugin.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
17
|
+
|
|
18
|
+
# Enable Clang modules in C++ mode so that @import ShieldFraud; works
|
|
19
|
+
s.pod_target_xcconfig = {
|
|
20
|
+
'CLANG_ENABLE_MODULES' => 'YES',
|
|
21
|
+
'OTHER_CPLUSPLUSFLAGS' => '$(inherited) -fmodules -fcxx-modules'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# install_modules_dependencies handles New Architecture (Turbo Modules / Fabric)
|
|
25
|
+
# and replaces the legacy `s.dependency "React"` call.
|
|
26
|
+
install_modules_dependencies(s)
|
|
27
|
+
|
|
28
|
+
s.dependency "ShieldFraud", ">= 1.5.58"
|
|
29
|
+
end
|
|
@@ -70,9 +70,11 @@ export interface Spec extends TurboModule {
|
|
|
70
70
|
/**
|
|
71
71
|
* Triggers a device signature computation for a given screen and returns
|
|
72
72
|
* the latest device result (or error) via callbacks once complete.
|
|
73
|
+
* Pass userId to associate the result with a specific user.
|
|
73
74
|
*/
|
|
74
75
|
sendDeviceSignature(
|
|
75
76
|
screenName: string,
|
|
77
|
+
userId: string | null,
|
|
76
78
|
successCallback: (result: Object) => void,
|
|
77
79
|
errorCallback: (error: string) => void
|
|
78
80
|
): void;
|
package/src/index.tsx
CHANGED
|
@@ -3,14 +3,15 @@ import {
|
|
|
3
3
|
NativeEventEmitter,
|
|
4
4
|
Platform,
|
|
5
5
|
TurboModuleRegistry,
|
|
6
|
-
} from
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import packageJson from '../package.json';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Resolve the native module through TurboModuleRegistry (New Architecture)
|
|
10
11
|
* with a fallback to NativeModules bridge (Old Architecture).
|
|
11
12
|
*/
|
|
12
13
|
const ShieldFraudPluginNativeModule =
|
|
13
|
-
TurboModuleRegistry.get<any>(
|
|
14
|
+
TurboModuleRegistry.get<any>('ShieldFraudPlugin') ??
|
|
14
15
|
NativeModules.ShieldFraudPlugin;
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -27,8 +28,8 @@ export enum LogLevel {
|
|
|
27
28
|
* Enum representing the environment information for ShieldFraud.
|
|
28
29
|
*/
|
|
29
30
|
export enum EnvironmentInfo {
|
|
30
|
-
EnvironmentProd = 0,
|
|
31
|
-
EnvironmentDev = 1,
|
|
31
|
+
EnvironmentProd = 0, // Environment.PROD
|
|
32
|
+
EnvironmentDev = 1, // Environment.DEV
|
|
32
33
|
EnvironmentStaging = 2, // Environment.STAGING
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -90,6 +91,11 @@ class ShieldFraud {
|
|
|
90
91
|
ShieldFraud.PlatformWrapper
|
|
91
92
|
);
|
|
92
93
|
|
|
94
|
+
private static callbackSubscriptions: {
|
|
95
|
+
success?: { remove: () => void };
|
|
96
|
+
error?: { remove: () => void };
|
|
97
|
+
} = {};
|
|
98
|
+
|
|
93
99
|
/**
|
|
94
100
|
* Initializes the ShieldFraud plugin with the provided configuration.
|
|
95
101
|
*
|
|
@@ -108,7 +114,7 @@ class ShieldFraud {
|
|
|
108
114
|
// Set default values if environmentInfo is not provided
|
|
109
115
|
const environmentInfo =
|
|
110
116
|
config.environmentInfo || EnvironmentInfo.EnvironmentProd;
|
|
111
|
-
|
|
117
|
+
|
|
112
118
|
// Set cross-platform parameters internally (React Native and version from package.json)
|
|
113
119
|
ShieldFraud.setCrossPlatformParameters();
|
|
114
120
|
|
|
@@ -116,7 +122,7 @@ class ShieldFraud {
|
|
|
116
122
|
// Always send a real boolean — the Old Arch bridge cannot handle null
|
|
117
123
|
// for boolean parameters (causes NPE in ReadableNativeArray.getBoolean).
|
|
118
124
|
const blockScreenRecording =
|
|
119
|
-
Platform.OS ===
|
|
125
|
+
Platform.OS === 'android' ? config.blockScreenRecording ?? false : false;
|
|
120
126
|
|
|
121
127
|
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
122
128
|
await ShieldFraud.PlatformWrapper.initShield(
|
|
@@ -140,8 +146,8 @@ class ShieldFraud {
|
|
|
140
146
|
* The cross-platform name and the version is fetched from package.json.
|
|
141
147
|
*/
|
|
142
148
|
private static setCrossPlatformParameters(): void {
|
|
143
|
-
const crossPlatformName =
|
|
144
|
-
const crossPlatformVersion =
|
|
149
|
+
const crossPlatformName = packageJson.name;
|
|
150
|
+
const crossPlatformVersion = packageJson.version;
|
|
145
151
|
|
|
146
152
|
ShieldFraud.PlatformWrapper.setCrossPlatformParameters(
|
|
147
153
|
crossPlatformName,
|
|
@@ -155,36 +161,41 @@ class ShieldFraud {
|
|
|
155
161
|
* @param callbacks - The callback functions for success and failure events.
|
|
156
162
|
*/
|
|
157
163
|
private static listeners(callbacks?: ShieldCallback): void {
|
|
164
|
+
ShieldFraud.callbackSubscriptions.success?.remove();
|
|
165
|
+
ShieldFraud.callbackSubscriptions.error?.remove();
|
|
166
|
+
|
|
158
167
|
// Listen for success events and invoke the onSuccess callback if provided.
|
|
159
|
-
ShieldFraud.
|
|
160
|
-
|
|
161
|
-
callbacks
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
ShieldFraud.callbackSubscriptions.success =
|
|
169
|
+
ShieldFraud.eventEmitter.addListener('success', (data) => {
|
|
170
|
+
if (callbacks?.onSuccess) {
|
|
171
|
+
callbacks.onSuccess(data);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
164
174
|
|
|
165
175
|
// Listen for error events and invoke the onFailure callback if provided.
|
|
166
|
-
ShieldFraud.
|
|
167
|
-
|
|
168
|
-
callbacks
|
|
169
|
-
|
|
170
|
-
|
|
176
|
+
ShieldFraud.callbackSubscriptions.error =
|
|
177
|
+
ShieldFraud.eventEmitter.addListener('error', (error) => {
|
|
178
|
+
if (callbacks?.onFailure) {
|
|
179
|
+
callbacks.onFailure(error);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
171
182
|
}
|
|
172
183
|
|
|
173
184
|
/**
|
|
174
185
|
* Retrieves the session ID from the ShieldFraud plugin.
|
|
175
186
|
*
|
|
176
|
-
* @returns
|
|
187
|
+
* @returns The current session ID.
|
|
177
188
|
*/
|
|
178
|
-
public static getSessionId():
|
|
189
|
+
public static getSessionId(): string {
|
|
179
190
|
return ShieldFraud.PlatformWrapper.getSessionId();
|
|
180
191
|
}
|
|
181
192
|
|
|
182
193
|
/**
|
|
183
194
|
* Checks whether the ShieldFraud plugin is initialized.
|
|
184
195
|
*
|
|
185
|
-
* @returns
|
|
196
|
+
* @returns Whether the ShieldFraud plugin is initialized.
|
|
186
197
|
*/
|
|
187
|
-
public static isShieldInitialized():
|
|
198
|
+
public static isShieldInitialized(): boolean {
|
|
188
199
|
return ShieldFraud.PlatformWrapper.isShieldInitialized();
|
|
189
200
|
}
|
|
190
201
|
|
|
@@ -201,7 +212,7 @@ class ShieldFraud {
|
|
|
201
212
|
public static async isSDKready(
|
|
202
213
|
callback: (isReady: boolean) => void
|
|
203
214
|
): Promise<void> {
|
|
204
|
-
|
|
215
|
+
if (Platform.OS === 'android') {
|
|
205
216
|
const isInitialized = await this.isShieldInitialized();
|
|
206
217
|
callback(isInitialized);
|
|
207
218
|
return;
|
|
@@ -214,27 +225,27 @@ class ShieldFraud {
|
|
|
214
225
|
const isInitialized = await this.isShieldInitialized();
|
|
215
226
|
|
|
216
227
|
if (!isInitialized) {
|
|
217
|
-
console.log(
|
|
228
|
+
console.log('Shield SDK not initialized:');
|
|
218
229
|
callback(false);
|
|
219
230
|
return;
|
|
220
231
|
}
|
|
221
232
|
|
|
222
233
|
const deviceResultListener = (event: { status: string }) => {
|
|
223
|
-
if (event.status ===
|
|
224
|
-
ShieldFraud.eventEmitter.removeAllListeners(
|
|
234
|
+
if (event.status === 'isSDKReady') {
|
|
235
|
+
ShieldFraud.eventEmitter.removeAllListeners('device_result_state');
|
|
225
236
|
callback(true);
|
|
226
237
|
}
|
|
227
238
|
};
|
|
228
239
|
|
|
229
240
|
ShieldFraud.eventEmitter.addListener(
|
|
230
|
-
|
|
241
|
+
'device_result_state',
|
|
231
242
|
deviceResultListener
|
|
232
243
|
);
|
|
233
244
|
|
|
234
245
|
// Trigger the SDK subscription — iOS 1.x requires this explicit call.
|
|
235
246
|
ShieldFraud.PlatformWrapper.setDeviceResultStateListener();
|
|
236
247
|
} catch (error) {
|
|
237
|
-
console.error(
|
|
248
|
+
console.error('An error occurred:', error);
|
|
238
249
|
callback(false);
|
|
239
250
|
}
|
|
240
251
|
}
|
|
@@ -298,12 +309,17 @@ class ShieldFraud {
|
|
|
298
309
|
* On failure, rejects with the error message.
|
|
299
310
|
*
|
|
300
311
|
* @param screenName - The name of the screen triggering the signature.
|
|
312
|
+
* @param userId - (Optional) A user ID to associate with the device signature.
|
|
301
313
|
* @returns A Promise that resolves with the device result or rejects with an error.
|
|
302
314
|
*/
|
|
303
|
-
public static sendDeviceSignature(
|
|
315
|
+
public static sendDeviceSignature(
|
|
316
|
+
screenName: string,
|
|
317
|
+
userId?: string
|
|
318
|
+
): Promise<object> {
|
|
304
319
|
return new Promise((resolve, reject) => {
|
|
305
320
|
ShieldFraud.PlatformWrapper.sendDeviceSignature(
|
|
306
321
|
screenName,
|
|
322
|
+
userId ?? null,
|
|
307
323
|
(result: object) => {
|
|
308
324
|
resolve(result);
|
|
309
325
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeShieldFraudPlugin.d.ts","sourceRoot":"","sources":["../../src/NativeShieldFraudPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;;;GAIG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;OAEG;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