react-native-shield-full-plugin 2.3.1 → 2.4.1
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 +1 -233
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/shieldfraudplugin/ShieldFraudPluginModule.java +13 -22
- package/ios/ShieldFraudPlugin.h +2 -9
- package/ios/ShieldFraudPlugin.mm +169 -114
- package/lib/commonjs/NativeShieldFraudPlugin.js.map +1 -1
- package/lib/commonjs/index.js +12 -46
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeShieldFraudPlugin.js.map +1 -1
- package/lib/module/index.js +12 -46
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeShieldFraudPlugin.d.ts +1 -5
- package/lib/typescript/src/NativeShieldFraudPlugin.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -12
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-shield-fraud-plugin.podspec +1 -1
- package/react-native-shield-full-plugin.podspec +2 -2
- package/src/NativeShieldFraudPlugin.ts +1 -5
- package/src/index.tsx +17 -57
package/README.md
CHANGED
|
@@ -2,236 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
React Native Plugin for Shield Full (www.shield.com)
|
|
4
4
|
|
|
5
|
-
React Native Shield Full 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.
|
|
6
|
-
|
|
7
|
-
There are few steps to getting started with the SHIELD SDK:
|
|
8
|
-
|
|
9
|
-
1. [Integrate the SDK](#integrate-the-sdk)
|
|
10
|
-
|
|
11
|
-
2. [Initialize the SDK](#initialize-the-sdk)
|
|
12
|
-
|
|
13
|
-
3. [Get Session ID](#get-session-id)
|
|
14
|
-
|
|
15
|
-
4. [Get Device Results](#get-device-results)
|
|
16
|
-
|
|
17
|
-
5. [Send Custom Attributes](#send-custom-attributes)
|
|
18
|
-
|
|
19
|
-
6. [Send Device Fingerprint](#send-device-signature)
|
|
20
|
-
|
|
21
|
-
7. [Migration from BRIDGE CODE to PLUGIN](#migration-from-bridge-code-to-plugin)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Integrate the SDK
|
|
26
|
-
|
|
27
|
-
This package can be installed in two ways, you can choose a way depends on your need.
|
|
28
|
-
|
|
29
|
-
**NPM:**
|
|
30
|
-
```
|
|
31
|
-
npm install react-native-shield-full-plugin
|
|
32
|
-
```
|
|
33
|
-
**OR**
|
|
34
|
-
|
|
35
|
-
**YARN:**
|
|
36
|
-
```
|
|
37
|
-
yarn add react-native-shield-full-plugin
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
**Note**: We make continuous enhancements to our full library and detection capabilities which includes new functionalities, bug fixes and security updates. We recommend updating to the latest SDK version to protect against rapidly evolving fraud risks.
|
|
41
|
-
|
|
42
|
-
You can refer to the Changelog to see more details about our updates.
|
|
43
|
-
|
|
44
|
-
### Initialize the SDK
|
|
45
|
-
|
|
46
|
-
The SDK initialization should be configured on `useEffect` *(for **Functional Components**)* or `componentDidMount` *(for **Class Components**)* in your **App.tsx** or on **App launch** to ensure successful generation and processing of the device fingerprint. The SDK is to be initialized only once and will throw an exception if it is initialized more than once.
|
|
47
|
-
|
|
48
|
-
You need both the **SHIELD_SITE_ID** and **SHIELD_SECRET_KEY** to initialize the SDK. You can locate them at the top of the page.
|
|
49
|
-
```
|
|
50
|
-
const config: Config = {
|
|
51
|
-
siteID: 'SHIELD_SITE_ID',
|
|
52
|
-
secretKey: 'SHIELD_SECRET_KEY'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
const initializeShield = async () => {
|
|
57
|
-
await ShieldFraud.initShield(config);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
initializeShield();
|
|
61
|
-
}, []);
|
|
62
|
-
```
|
|
63
|
-
**Note** - ```await ShieldFraud.initShield(config)``` - *The await keyword is used to wait for the promise returned by the initShield function to resolve. In React Native, It is best practice to use `await` when calling native modules from React Native, especially during `asynchronous` operations such as SDK Initialization. This is because using `await` ensures that the main thread is not blocked while the native module is initializing.*
|
|
64
|
-
|
|
65
|
-
`Config` has these **optional** parameters:
|
|
66
|
-
|
|
67
|
-
1. `logLevel` Set your log level to `debug`, `info` or `none`. | Receives high-level information about how the SDK processes network requests, responses or error information during SDK integration. Default log level is `none`.
|
|
68
|
-
2. `environmentInfo` Set your environment info to `prod`, `dev` or `staging`. Default environment info is `prod`.
|
|
69
|
-
3. `blockedDialog` Set your dialog for the blocked dialog both title and body or you can send it as null as well
|
|
70
|
-
|
|
71
|
-
Note: You can check whether Shield SDK is ready or not by using isSDKready function
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
75
|
-
if (isReady) {
|
|
76
|
-
// Shield is Ready: Do your implementation
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Get Session ID
|
|
82
|
-
Session ID is the unique identifier of a user’s app session and acts as a point of reference when retrieving the device result for that session.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Session ID follows the OS lifecycle management, in-line with industry best practice. This means that a user’s session is active for as long as the device maintains it, unless the user terminates the app or the device runs out of memory and has to kill the app.
|
|
86
|
-
|
|
87
|
-
If you would like to retrieve device results using the backend API, it is important that you store the Session ID on your system. You will need to call the SHIELD backend API using this Session ID.
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
91
|
-
if (isReady) {
|
|
92
|
-
const sessionID = await ShieldFraud.getSessionId(); // Fetch session ID using await
|
|
93
|
-
console.log('session id: ', sessionID);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Get Device Results
|
|
99
|
-
SHIELD provides you actionable device intelligence which you can retrieve from the SDK, via the `Optimized Listener` or `Customized Pull method`. You can also retrieve results via the backend API.
|
|
100
|
-
|
|
101
|
-
*Warning: Only 1 method of obtaining device results **(Optimized Listener or Customized Pull)** can be in effect at any point in time.*
|
|
102
|
-
|
|
103
|
-
#### Retrieve device results via Optimized Listener
|
|
104
|
-
|
|
105
|
-
##### SHIELD recommends the Optimized Listener method to reduce number of API calls. #####
|
|
106
|
-
|
|
107
|
-
Our SDK will capture an initial device fingerprint upon SDK initialization and return an additional set of device intelligence ONLY if the device fingerprint changes along one session. This ensures a truly optimized end to end protection of your ecosystem.
|
|
108
|
-
|
|
109
|
-
You can register a callback if you would like to be notified in the event that the device attributes change during the session (for example, a user activates a malicious tool a moment after launching the page).
|
|
110
|
-
|
|
111
|
-
Add an additional parameter during intialization in order to register a callback.
|
|
112
|
-
|
|
113
|
-
**For example - `await ShieldFraud.initShield(config, callbacks);`**
|
|
114
|
-
```
|
|
115
|
-
const callbacks: ShieldCallback = {
|
|
116
|
-
onSuccess: (data) => {
|
|
117
|
-
// Handle success event here
|
|
118
|
-
console.log('Success:', data);
|
|
119
|
-
},
|
|
120
|
-
onFailure: (error) => {
|
|
121
|
-
// Handle failure event here
|
|
122
|
-
console.log('Error:', error);
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const config: Config = {
|
|
127
|
-
siteID: 'SHIELD_SITE_ID',
|
|
128
|
-
secretKey: 'SHIELD_SECRET_KEY'
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
const initializeShield = async () => {
|
|
133
|
-
await ShieldFraud.initShield(config, callbacks);
|
|
134
|
-
};
|
|
135
|
-
initializeShield();
|
|
136
|
-
}, []);
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
#### Retrieve device results via Customized Pull
|
|
140
|
-
You can retrieve device results via Customized Pull at specific user checkpoints or activities, such as account registration, login, or checkout. This is to ensure that there is adequate time to generate a device fingerprint.
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
144
|
-
if (isReady) {
|
|
145
|
-
ShieldFraud.getLatestDeviceResult()
|
|
146
|
-
.then((result: object) => {
|
|
147
|
-
// Handle success with the result object
|
|
148
|
-
console.log('Received latest device result:', result);
|
|
149
|
-
})
|
|
150
|
-
.catch((error: object) => {
|
|
151
|
-
// Handle error with the error object
|
|
152
|
-
console.log('Error retrieving device result:', error);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
It is possible that getLatestDeviceResult returns null if the device result retrieval is unsuccessful.
|
|
159
|
-
|
|
160
|
-
### Send Custom Attributes
|
|
161
|
-
|
|
162
|
-
Use the sendAttributes function to sent event-based attributes such as user_id or activity_id for enhanced analytics. This function accepts two parameters:screenName where the function is triggered, and data to provide any custom fields in key, value pairs.
|
|
163
|
-
|
|
164
|
-
```
|
|
165
|
-
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
166
|
-
if (isReady) {
|
|
167
|
-
ShieldFraud.sendAttributes('Screen_Name', { key1: 'value1', key2: 'value2' });
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
```
|
|
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
|
-
|
|
185
|
-
### Migration from BRIDGE CODE to PLUGIN
|
|
186
|
-
If you've been using the old method of integrating the React Native bridge code for the Shield Full SDK on iOS and Android, follow these steps to migrate to our plugin.
|
|
187
|
-
|
|
188
|
-
#### iOS Migration Steps
|
|
189
|
-
|
|
190
|
-
**1. Remove Old Pod Dependency:**
|
|
191
|
-
Open your iOS project's Podfile and remove the line `pod 'ShieldFraud'`. Then, in your project's root directory, run `pod deintegrate` followed by `pod install` to ensure the old ShieldFraud dependency is completely removed.
|
|
192
|
-
|
|
193
|
-
**2. Remove Old Bridge Code Files:**
|
|
194
|
-
In your Xcode project's file explorer, locate and remove the files `ShieldModule.h` and `ShieldModule.m`. Remove all these references as they are no longer needed.
|
|
195
|
-
|
|
196
|
-
**3. Clean the Project:**
|
|
197
|
-
Open your Xcode project. Go to `"Product"` in the top menu and select `"Clean Build Folder"` to make sure any residual build artifacts related to the old ShieldFraud library are removed.
|
|
198
|
-
|
|
199
|
-
**4. Update React Native Project:**
|
|
200
|
-
In your React Native project, search for any code that references the old `ShieldModule`. Remove all these references as they are no longer needed.
|
|
201
|
-
|
|
202
|
-
**5. Follow Plugin Integration Steps:**
|
|
203
|
-
Now that you've cleaned up the old bridge code, follow the integration steps outlined in the documentation under "Integrate the SDK" section, starting from the step of installing the plugin using npm or yarn.
|
|
204
|
-
|
|
205
|
-
#### Android Migration Steps
|
|
206
|
-
If you've been using the old method of integrating the React Native bridge code for the Shield Full SDK on Android, follow these steps to migrate to our plugin.
|
|
207
|
-
|
|
208
|
-
**1. Remove Old Dependencies:**
|
|
209
|
-
In your `app/build.gradle` file, locate and remove the line:
|
|
210
|
-
```
|
|
211
|
-
implementation 'com.shield.android:shield-fraud:1.5.+'
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**2. Update Android Settings:**
|
|
215
|
-
In your `settings.gradle` or project level `build.gradle` file from the `repositories` block, locate and remove the `maven url`:
|
|
216
|
-
```
|
|
217
|
-
allprojects {
|
|
218
|
-
repositories {
|
|
219
|
-
maven {
|
|
220
|
-
url "https://cashshield-sdk.s3.amazonaws.com/release/"
|
|
221
|
-
}
|
|
222
|
-
...
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
This is the maven url that you no longer need with the new plugin approach.
|
|
227
|
-
|
|
228
|
-
**3. Remove Old Bridge Code:**
|
|
229
|
-
In your Android project, if you have a ShieldModule.java file as part of the old bridge code integration, you can safely remove it.
|
|
230
|
-
|
|
231
|
-
**4. Update React Native Project:**
|
|
232
|
-
In your React Native project, search for any code that references the old ShieldModule in Java code. Also remove ShieldModule from ReactPackage, Remove all these references as they are no longer needed.
|
|
233
|
-
|
|
234
|
-
**5. Follow Plugin Integration Steps:**
|
|
235
|
-
Now that you've cleaned up the old bridge code, follow the integration steps outlined in the documentation under "Integrate the SDK" section, starting from the step of installing the plugin using npm or yarn.
|
|
236
|
-
|
|
237
|
-
By following these steps, you'll successfully migrate your React Native project from the old bridge code integration to the new Shield Full plugin. This migration will make your project more maintainable and allow you to take advantage of the new features and improvements offered by the plugin.
|
|
5
|
+
React Native Shield Full 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.
|
package/android/build.gradle
CHANGED
|
@@ -19,7 +19,7 @@ def packageJson = new groovy.json.JsonSlurper().parseText(
|
|
|
19
19
|
new File("${project.projectDir}/../package.json").text
|
|
20
20
|
)
|
|
21
21
|
def isFullPlugin = packageJson.name == "react-native-shield-full-plugin"
|
|
22
|
-
def shieldSdkArtifact = isFullPlugin ? "com.shield.android:shield:2.
|
|
22
|
+
def shieldSdkArtifact = isFullPlugin ? "com.shield.android:shield:2.7.0" : "com.shield.android:shield-fraud:2.7.0"
|
|
23
23
|
|
|
24
24
|
apply plugin: "com.android.library"
|
|
25
25
|
|
|
@@ -44,7 +44,7 @@ import java.util.Map;
|
|
|
44
44
|
* 1. Initialisation : Shield.Builder → ShieldConfig + ShieldFactory
|
|
45
45
|
* 2. Instance access : Shield.getInstance() → stored `shield` member
|
|
46
46
|
* 3. Session ID : Shield.getInstance().getSessionId() → shield.getSessionId()
|
|
47
|
-
* 4. Device results :
|
|
47
|
+
* 4. Device results : manual readiness subscription
|
|
48
48
|
* → ShieldFactory.createShieldWithCallback (SHIELD Sentinel)
|
|
49
49
|
* 5. sendAttributes : void return
|
|
50
50
|
* → shield.sendAttributesWithCallback (Result<String> callback)
|
|
@@ -116,6 +116,7 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
116
116
|
public void initShield(
|
|
117
117
|
String siteID,
|
|
118
118
|
String secretKey,
|
|
119
|
+
@Nullable String partnerId,
|
|
119
120
|
boolean isOptimizedListener,
|
|
120
121
|
@Nullable ReadableMap blockedDialog,
|
|
121
122
|
double logLevel,
|
|
@@ -133,6 +134,9 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
133
134
|
ShieldConfig config = new ShieldConfig(siteID, secretKey);
|
|
134
135
|
config.setLogLevel(getLogLevelFromInt((int) logLevel));
|
|
135
136
|
config.setEnvironment(getEnvironmentFromInt((int) environmentInfo));
|
|
137
|
+
if (partnerId != null) {
|
|
138
|
+
config.setPartnerId(partnerId);
|
|
139
|
+
}
|
|
136
140
|
|
|
137
141
|
if (blockedDialog != null) {
|
|
138
142
|
String title = blockedDialog.hasKey("title") ? blockedDialog.getString("title") : null;
|
|
@@ -147,8 +151,8 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
147
151
|
|
|
148
152
|
if (isOptimizedListener) {
|
|
149
153
|
// SDK 2.x: createShieldWithCallback initialises + acts as the Sentinel.
|
|
150
|
-
// Unlike 1.x (which required a separate
|
|
151
|
-
//
|
|
154
|
+
// Unlike 1.x (which required a separate readiness subscription),
|
|
155
|
+
// 2.x fires this callback automatically when device intelligence
|
|
152
156
|
// is ready and on every subsequent risk-profile change.
|
|
153
157
|
// The callback may arrive on a background thread — always post to main looper.
|
|
154
158
|
shield = ShieldFactory.createShieldWithCallback(
|
|
@@ -159,7 +163,7 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
159
163
|
DeviceIntelligence di =
|
|
160
164
|
((Result.Success<DeviceIntelligence>) result).getData();
|
|
161
165
|
JSONObject json = di != null ? di.getData() : null;
|
|
162
|
-
emitEvent("success", json != null ? json
|
|
166
|
+
emitEvent("success", json != null ? toWritableMap(json) : null);
|
|
163
167
|
} else if (result instanceof Result.Failure) {
|
|
164
168
|
ShieldError error =
|
|
165
169
|
((Result.Failure<DeviceIntelligence>) result).getError();
|
|
@@ -186,23 +190,6 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
186
190
|
ShieldCrossPlatformHelper.setCrossPlatformParameters(params);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
// =========================================================================
|
|
190
|
-
// setDeviceResultStateListener — no-op stub (SDK 2.x)
|
|
191
|
-
//
|
|
192
|
-
// SDK 1.x required a manual subscription call + Handler.postDelayed workaround.
|
|
193
|
-
// SDK 2.x fires device result events automatically via createShieldWithCallback
|
|
194
|
-
// when isOptimizedListener == true — no subscription call needed.
|
|
195
|
-
//
|
|
196
|
-
// The method is kept as a no-op stub so the shared TypeScript codegen spec
|
|
197
|
-
// and iOS (which still calls the SDK method) remain unaffected.
|
|
198
|
-
// =========================================================================
|
|
199
|
-
|
|
200
|
-
@ReactMethod
|
|
201
|
-
public void setDeviceResultStateListener() {
|
|
202
|
-
// No-op on Android SDK 2.x — device result events are delivered
|
|
203
|
-
// automatically through the createShieldWithCallback Sentinel.
|
|
204
|
-
}
|
|
205
|
-
|
|
206
193
|
// =========================================================================
|
|
207
194
|
// Retrieve the latest device intelligence result
|
|
208
195
|
//
|
|
@@ -301,7 +288,11 @@ public class ShieldFraudPluginModule extends com.shieldfraudplugin.ShieldFraudPl
|
|
|
301
288
|
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
|
|
302
289
|
if (result instanceof Result.Success) {
|
|
303
290
|
JSONObject json = shield.getLatestDeviceResult();
|
|
304
|
-
|
|
291
|
+
if (json != null) {
|
|
292
|
+
successCallback.invoke(toWritableMap(json));
|
|
293
|
+
} else {
|
|
294
|
+
errorCallback.invoke("No device result available.");
|
|
295
|
+
}
|
|
305
296
|
} else if (result instanceof Result.Failure) {
|
|
306
297
|
ShieldError error = ((Result.Failure<String>) result).getError();
|
|
307
298
|
errorCallback.invoke(error != null
|
package/ios/ShieldFraudPlugin.h
CHANGED
|
@@ -5,20 +5,13 @@
|
|
|
5
5
|
#import <React/RCTEventEmitter.h>
|
|
6
6
|
#import "RNShieldFraudPluginSpec.h"
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
// A forward declaration is sufficient for the @interface conformance declaration.
|
|
10
|
-
@protocol DeviceShieldCallback;
|
|
11
|
-
|
|
12
|
-
@interface ShieldFraudPlugin : RCTEventEmitter <NativeShieldFraudPluginSpec, DeviceShieldCallback>
|
|
8
|
+
@interface ShieldFraudPlugin : RCTEventEmitter <NativeShieldFraudPluginSpec>
|
|
13
9
|
#else
|
|
14
10
|
// Old Architecture: standard bridge module + event emitter.
|
|
15
11
|
#import <React/RCTBridgeModule.h>
|
|
16
12
|
#import <React/RCTEventEmitter.h>
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
@protocol DeviceShieldCallback;
|
|
20
|
-
|
|
21
|
-
@interface ShieldFraudPlugin : RCTEventEmitter <RCTBridgeModule, DeviceShieldCallback>
|
|
14
|
+
@interface ShieldFraudPlugin : RCTEventEmitter <RCTBridgeModule>
|
|
22
15
|
#endif
|
|
23
16
|
|
|
24
17
|
@end
|
package/ios/ShieldFraudPlugin.mm
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
#import "ShieldFraudPlugin.h"
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// without requiring Clang module syntax (@import), which fails in Obj-C++ files
|
|
7
|
-
// when C++ modules are not enabled (e.g. when the New Architecture codegen
|
|
8
|
-
// headers are included and the file is compiled as Obj-C++).
|
|
3
|
+
// ShieldFraud is Swift-based, but this source must remain Objective-C++ for
|
|
4
|
+
// React Native's New Architecture. Importing the generated Objective-C header
|
|
5
|
+
// avoids forcing -fcxx-modules on consumers that link the plugin statically.
|
|
9
6
|
#import <ShieldFraud/ShieldFraud-Swift.h>
|
|
10
7
|
|
|
11
|
-
@
|
|
8
|
+
@interface ShieldFraudPlugin ()
|
|
9
|
+
@property (nonatomic, strong) id<Shield> shield;
|
|
10
|
+
@end
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
@implementation ShieldFraudPlugin
|
|
14
13
|
|
|
15
14
|
RCT_EXPORT_MODULE();
|
|
16
15
|
|
|
@@ -36,40 +35,35 @@ RCT_EXPORT_METHOD(setCrossPlatformParameters:(NSString *)crossPlatformName
|
|
|
36
35
|
RCT_EXPORT_METHOD(getLatestDeviceResult:(RCTResponseSenderBlock)successCallback
|
|
37
36
|
errorCallback:(RCTResponseSenderBlock)errorCallback)
|
|
38
37
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
successCallback(@[result]);
|
|
38
|
+
if (self.shield == nil) {
|
|
39
|
+
errorCallback(@[@"Shield SDK is not initialized."]);
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
43
|
+
DeviceIntelligence *deviceIntelligence = [self.shield getLatestDeviceResult];
|
|
44
|
+
if (deviceIntelligence != nil) {
|
|
45
|
+
successCallback(@[deviceIntelligence.data]);
|
|
48
46
|
return;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
errorCallback(@[@"No device result available yet."]);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
// Subscribe to real-time device-result state changes
|
|
55
|
-
RCT_EXPORT_METHOD(setDeviceResultStateListener)
|
|
56
|
-
{
|
|
57
|
-
double delayInSeconds = 1.5;
|
|
58
|
-
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW,
|
|
59
|
-
(int64_t)(delayInSeconds * NSEC_PER_SEC));
|
|
60
|
-
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
|
|
61
|
-
[[Shield shared] setDeviceResultStateListener:^{
|
|
62
|
-
[self sendEventWithName:@"device_result_state"
|
|
63
|
-
body:@{@"status": @"isSDKReady"}];
|
|
64
|
-
}];
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
52
|
// Attach arbitrary screen-level attributes
|
|
69
53
|
RCT_EXPORT_METHOD(sendAttributes:(NSString *)screenName
|
|
70
54
|
data:(NSDictionary *)data)
|
|
71
55
|
{
|
|
72
|
-
|
|
56
|
+
if (self.shield == nil) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[self.shield sendAttributesWithScreenName:screenName
|
|
61
|
+
data:[self stringAttributesFromDictionary:data]
|
|
62
|
+
completion:^(NSString *sessionId, ShieldError *error) {
|
|
63
|
+
if (error != nil) {
|
|
64
|
+
[self sendEventWithName:@"error" body:error.errorMessage];
|
|
65
|
+
}
|
|
66
|
+
}];
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
RCT_EXPORT_METHOD(sendAttributesWithCallback:(NSString *)screenName
|
|
@@ -77,60 +71,65 @@ RCT_EXPORT_METHOD(sendAttributesWithCallback:(NSString *)screenName
|
|
|
77
71
|
successCallback:(RCTResponseSenderBlock)successCallback
|
|
78
72
|
errorCallback:(RCTResponseSenderBlock)errorCallback)
|
|
79
73
|
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
if (self.shield == nil) {
|
|
75
|
+
errorCallback(@[@"Shield SDK is not initialized."]);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[self.shield sendAttributesWithScreenName:screenName
|
|
80
|
+
data:[self stringAttributesFromDictionary:data]
|
|
81
|
+
completion:^(NSString *sessionId, ShieldError *error) {
|
|
82
|
+
if (sessionId != nil) {
|
|
83
|
+
successCallback(@[@(YES)]);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
87
|
+
NSString *errorMessage = error != nil
|
|
88
|
+
? error.errorMessage
|
|
89
|
+
: @"Failed to send attributes.";
|
|
90
|
+
errorCallback(@[errorMessage]);
|
|
94
91
|
}];
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
// Trigger a device signature computation for a given screen name.
|
|
98
95
|
// Pass userId to associate the result with a specific user.
|
|
99
|
-
// The
|
|
100
|
-
//
|
|
96
|
+
// The 2.x completion returns a session ID or ShieldError. On success, return
|
|
97
|
+
// the latest DeviceIntelligence payload to preserve the React Native API.
|
|
101
98
|
RCT_EXPORT_METHOD(sendDeviceSignature:(NSString *)screenName
|
|
102
99
|
userId:(NSString * _Nullable)userId
|
|
103
100
|
successCallback:(RCTResponseSenderBlock)successCallback
|
|
104
101
|
errorCallback:(RCTResponseSenderBlock)errorCallback)
|
|
105
102
|
{
|
|
103
|
+
if (self.shield == nil) {
|
|
104
|
+
errorCallback(@[@"Shield SDK is not initialized."]);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
106
108
|
ShieldUserData *userData = [[ShieldUserData alloc]
|
|
107
109
|
initWithScreenName:screenName
|
|
108
110
|
userId:userId];
|
|
109
111
|
|
|
110
|
-
[
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
112
|
+
[self.shield sendDeviceSignatureWithUserData:userData
|
|
113
|
+
completion:^(NSString *sessionId, ShieldError *error) {
|
|
114
|
+
if (error != nil) {
|
|
115
|
+
errorCallback(@[error.errorMessage]);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
DeviceIntelligence *deviceIntelligence = [self.shield getLatestDeviceResult];
|
|
120
|
+
if (sessionId != nil && deviceIntelligence != nil) {
|
|
121
|
+
successCallback(@[deviceIntelligence.data]);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
});
|
|
125
|
+
errorCallback(@[@"No device result available."]);
|
|
127
126
|
}];
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
// RCTEventEmitter — declare the events this module can emit
|
|
131
130
|
- (NSArray<NSString *> *)supportedEvents
|
|
132
131
|
{
|
|
133
|
-
return @[@"success", @"error"
|
|
132
|
+
return @[@"success", @"error"];
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
// RCTEventEmitter — required overrides (no-op wrappers keep the base class happy)
|
|
@@ -144,15 +143,95 @@ RCT_EXPORT_METHOD(sendDeviceSignature:(NSString *)screenName
|
|
|
144
143
|
[super removeListeners:count];
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
//
|
|
148
|
-
|
|
146
|
+
// =============================================================================
|
|
147
|
+
// MARK: - ShieldFraud 2.x helpers
|
|
148
|
+
// =============================================================================
|
|
149
|
+
|
|
150
|
+
- (void)initializeShieldWithSiteID:(NSString *)siteID
|
|
151
|
+
secretKey:(NSString *)secretKey
|
|
152
|
+
partnerId:(NSString * _Nullable)partnerId
|
|
153
|
+
optimizedListener:(BOOL)isOptimizedListener
|
|
154
|
+
blockedDialog:(NSDictionary * _Nullable)blockedDialog
|
|
155
|
+
logLevel:(NSInteger)logLevel
|
|
156
|
+
environmentInfo:(NSInteger)environmentInfo
|
|
157
|
+
{
|
|
158
|
+
if (self.shield != nil) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
ShieldConfig *config = [[ShieldConfig alloc] initWithSiteId:siteID
|
|
163
|
+
secretKey:secretKey];
|
|
164
|
+
config.logLevel = [self logLevelFromInteger:logLevel];
|
|
165
|
+
config.environment = [self environmentFromInteger:environmentInfo];
|
|
166
|
+
if (partnerId != nil) {
|
|
167
|
+
config.partnerId = partnerId;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (blockedDialog != nil) {
|
|
171
|
+
NSString *title = [blockedDialog objectForKey:@"title"];
|
|
172
|
+
NSString *body = [blockedDialog objectForKey:@"body"];
|
|
173
|
+
if (title != nil && body != nil) {
|
|
174
|
+
config.defaultBlockedDialog = [[BlockedDialog alloc] initWithTitle:title body:body];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
self.shield = [ShieldFactory createShieldWithConfig:config];
|
|
179
|
+
|
|
180
|
+
if (isOptimizedListener) {
|
|
181
|
+
__weak ShieldFraudPlugin *weakSelf = self;
|
|
182
|
+
[self.shield onDeviceResultWithHandler:^(DeviceIntelligence *deviceIntelligence,
|
|
183
|
+
ShieldError *error) {
|
|
184
|
+
ShieldFraudPlugin *strongSelf = weakSelf;
|
|
185
|
+
if (strongSelf == nil) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (deviceIntelligence != nil) {
|
|
190
|
+
[strongSelf sendEventWithName:@"success" body:deviceIntelligence.data];
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (error != nil) {
|
|
195
|
+
[strongSelf sendEventWithName:@"error" body:error.errorMessage];
|
|
196
|
+
}
|
|
197
|
+
}];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
- (NSDictionary<NSString *, NSString *> *)stringAttributesFromDictionary:(NSDictionary *)data
|
|
149
202
|
{
|
|
150
|
-
|
|
203
|
+
NSMutableDictionary<NSString *, NSString *> *attributes = [NSMutableDictionary dictionary];
|
|
204
|
+
[data enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
|
|
205
|
+
if ([key isKindOfClass:[NSString class]] && [value isKindOfClass:[NSString class]]) {
|
|
206
|
+
attributes[key] = value;
|
|
207
|
+
}
|
|
208
|
+
}];
|
|
209
|
+
return attributes;
|
|
151
210
|
}
|
|
152
211
|
|
|
153
|
-
- (
|
|
212
|
+
- (LogLevel)logLevelFromInteger:(NSInteger)logLevel
|
|
154
213
|
{
|
|
155
|
-
|
|
214
|
+
switch (logLevel) {
|
|
215
|
+
case 4:
|
|
216
|
+
case 3:
|
|
217
|
+
return LogLevelDebug;
|
|
218
|
+
case 2:
|
|
219
|
+
return LogLevelInfo;
|
|
220
|
+
default:
|
|
221
|
+
return LogLevelNone;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
- (Environment)environmentFromInteger:(NSInteger)environmentInfo
|
|
226
|
+
{
|
|
227
|
+
switch (environmentInfo) {
|
|
228
|
+
case 1:
|
|
229
|
+
return EnvironmentDev;
|
|
230
|
+
case 2:
|
|
231
|
+
return EnvironmentStag;
|
|
232
|
+
default:
|
|
233
|
+
return EnvironmentProd;
|
|
234
|
+
}
|
|
156
235
|
}
|
|
157
236
|
|
|
158
237
|
|
|
@@ -181,6 +260,7 @@ RCT_EXPORT_METHOD(sendDeviceSignature:(NSString *)screenName
|
|
|
181
260
|
|
|
182
261
|
- (void)initShield:(NSString *)siteID
|
|
183
262
|
secretKey:(NSString *)secretKey
|
|
263
|
+
partnerId:(NSString * _Nullable)partnerId
|
|
184
264
|
isOptimizedListener:(BOOL)isOptimizedListener
|
|
185
265
|
blockedDialog:(NSDictionary * _Nullable)blockedDialog
|
|
186
266
|
logLevel:(double)logLevel
|
|
@@ -189,38 +269,24 @@ blockScreenRecording:(BOOL)blockScreenRecording
|
|
|
189
269
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
190
270
|
reject:(RCTPromiseRejectBlock)reject
|
|
191
271
|
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (blockedDialog != nil) {
|
|
200
|
-
NSString *title = [blockedDialog objectForKey:@"title"];
|
|
201
|
-
NSString *body = [blockedDialog objectForKey:@"body"];
|
|
202
|
-
config.defaultBlockedDialog = [[BlockedDialog alloc] initWithTitle:title
|
|
203
|
-
body:body];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// JS numbers arrive as double; cast explicitly to Swift-bridged enum types.
|
|
207
|
-
config.logLevel = (LogLevel)(NSInteger)logLevel;
|
|
208
|
-
config.environment = (Environment)(NSInteger)environmentInfo;
|
|
209
|
-
|
|
210
|
-
[Shield setUpWith:config];
|
|
211
|
-
isShieldInitialized = YES;
|
|
212
|
-
}
|
|
272
|
+
[self initializeShieldWithSiteID:siteID
|
|
273
|
+
secretKey:secretKey
|
|
274
|
+
partnerId:partnerId
|
|
275
|
+
optimizedListener:isOptimizedListener
|
|
276
|
+
blockedDialog:blockedDialog
|
|
277
|
+
logLevel:(NSInteger)logLevel
|
|
278
|
+
environmentInfo:(NSInteger)environmentInfo];
|
|
213
279
|
resolve(nil);
|
|
214
280
|
}
|
|
215
281
|
|
|
216
282
|
- (NSString *)getSessionId
|
|
217
283
|
{
|
|
218
|
-
return
|
|
284
|
+
return self.shield != nil ? self.shield.sessionId : @"";
|
|
219
285
|
}
|
|
220
286
|
|
|
221
287
|
- (NSNumber *)isShieldInitialized
|
|
222
288
|
{
|
|
223
|
-
return @(
|
|
289
|
+
return @(self.shield != nil);
|
|
224
290
|
}
|
|
225
291
|
|
|
226
292
|
// Wires this Obj-C class into the JSI runtime.
|
|
@@ -243,51 +309,40 @@ blockScreenRecording:(BOOL)blockScreenRecording
|
|
|
243
309
|
//
|
|
244
310
|
// Key differences from New Arch:
|
|
245
311
|
// • initShield — logLevel/environmentInfo are NSInteger (bridge coerces
|
|
246
|
-
// from NSNumber);
|
|
247
|
-
// return automatically).
|
|
312
|
+
// from NSNumber); resolve/reject expose Promise<void> to JS.
|
|
248
313
|
// • getSessionId / isShieldInitialized — must use the blocking-synchronous
|
|
249
314
|
// macro so the bridge returns the value to JS synchronously.
|
|
250
315
|
// -----------------------------------------------------------------------------
|
|
251
316
|
|
|
252
317
|
RCT_EXPORT_METHOD(initShield:(NSString *)siteID
|
|
253
318
|
secretKey:(NSString *)secretKey
|
|
319
|
+
partnerId:(NSString * _Nullable)partnerId
|
|
254
320
|
isOptimizedListener:(BOOL)isOptimizedListener
|
|
255
321
|
blockedDialog:(NSDictionary *)blockedDialog
|
|
256
322
|
logLevel:(NSInteger)logLevel
|
|
257
323
|
environmentInfo:(NSInteger)environmentInfo
|
|
258
|
-
blockScreenRecording:(BOOL)blockScreenRecording
|
|
324
|
+
blockScreenRecording:(BOOL)blockScreenRecording
|
|
325
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
326
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
259
327
|
{
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
NSString *title = [blockedDialog objectForKey:@"title"];
|
|
269
|
-
NSString *body = [blockedDialog objectForKey:@"body"];
|
|
270
|
-
config.defaultBlockedDialog = [[BlockedDialog alloc] initWithTitle:title
|
|
271
|
-
body:body];
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Cast NSInteger to Swift-bridged enum types explicitly.
|
|
275
|
-
config.logLevel = (LogLevel)logLevel;
|
|
276
|
-
config.environment = (Environment)environmentInfo;
|
|
277
|
-
|
|
278
|
-
[Shield setUpWith:config];
|
|
279
|
-
isShieldInitialized = YES;
|
|
280
|
-
}
|
|
328
|
+
[self initializeShieldWithSiteID:siteID
|
|
329
|
+
secretKey:secretKey
|
|
330
|
+
partnerId:partnerId
|
|
331
|
+
optimizedListener:isOptimizedListener
|
|
332
|
+
blockedDialog:blockedDialog
|
|
333
|
+
logLevel:logLevel
|
|
334
|
+
environmentInfo:environmentInfo];
|
|
335
|
+
resolve(nil);
|
|
281
336
|
}
|
|
282
337
|
|
|
283
338
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getSessionId)
|
|
284
339
|
{
|
|
285
|
-
return
|
|
340
|
+
return self.shield != nil ? self.shield.sessionId : @"";
|
|
286
341
|
}
|
|
287
342
|
|
|
288
343
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isShieldInitialized)
|
|
289
344
|
{
|
|
290
|
-
return @(
|
|
345
|
+
return @(self.shield != nil);
|
|
291
346
|
}
|
|
292
347
|
|
|
293
348
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -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,GA+EeC,gCAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -48,7 +48,7 @@ let EnvironmentInfo = /*#__PURE__*/function (EnvironmentInfo) {
|
|
|
48
48
|
exports.EnvironmentInfo = EnvironmentInfo;
|
|
49
49
|
/**
|
|
50
50
|
* The `ShieldFraud` class is a wrapper for the ShieldFraudPlugin native module in React Native.
|
|
51
|
-
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
51
|
+
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
52
52
|
* sending attributes, and getting the latest device result.
|
|
53
53
|
*/
|
|
54
54
|
class ShieldFraud {
|
|
@@ -72,6 +72,12 @@ class ShieldFraud {
|
|
|
72
72
|
* @param callbacks - (Optional) The callback functions for success and failure events.
|
|
73
73
|
*/
|
|
74
74
|
static async initShield(config, callbacks) {
|
|
75
|
+
if (!config.siteID) {
|
|
76
|
+
throw new Error('siteId must not be empty');
|
|
77
|
+
}
|
|
78
|
+
if (!config.secretKey) {
|
|
79
|
+
throw new Error('secretKey must not be empty');
|
|
80
|
+
}
|
|
75
81
|
const isOptimizedListener = !!callbacks;
|
|
76
82
|
|
|
77
83
|
// Set default values if logLevel is not provided
|
|
@@ -87,13 +93,14 @@ class ShieldFraud {
|
|
|
87
93
|
// Always send a real boolean — the Old Arch bridge cannot handle null
|
|
88
94
|
// for boolean parameters (causes NPE in ReadableNativeArray.getBoolean).
|
|
89
95
|
const blockScreenRecording = _reactNative.Platform.OS === 'android' ? config.blockScreenRecording ?? false : false;
|
|
90
|
-
|
|
91
|
-
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
92
|
-
await ShieldFraud.PlatformWrapper.initShield(config.siteID, config.secretKey, isOptimizedListener, config.blockedDialog ?? null, logLevel, environmentInfo, blockScreenRecording);
|
|
93
96
|
if (isOptimizedListener) {
|
|
94
|
-
//
|
|
97
|
+
// Register JS listeners before native initialization because ShieldFraud may
|
|
98
|
+
// deliver a cached device result immediately when its handler is registered.
|
|
95
99
|
ShieldFraud.listeners(callbacks);
|
|
96
100
|
}
|
|
101
|
+
|
|
102
|
+
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
103
|
+
await ShieldFraud.PlatformWrapper.initShield(config.siteID, config.secretKey, config.partnerId ?? null, isOptimizedListener, config.blockedDialog ?? null, logLevel, environmentInfo, blockScreenRecording);
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
/**
|
|
@@ -149,47 +156,6 @@ class ShieldFraud {
|
|
|
149
156
|
return ShieldFraud.PlatformWrapper.isShieldInitialized();
|
|
150
157
|
}
|
|
151
158
|
|
|
152
|
-
/**
|
|
153
|
-
* Checks if the ShieldFraud SDK is ready and invokes the provided callback
|
|
154
|
-
* with the readiness state.
|
|
155
|
-
*
|
|
156
|
-
* On Android, readiness is approximated by the native initialization state
|
|
157
|
-
* to preserve backward compatibility without reporting ready before init.
|
|
158
|
-
*
|
|
159
|
-
* @param callback - A callback function to be invoked with the readiness state.
|
|
160
|
-
* - `isReady` (boolean): true when the SDK has produced a device result.
|
|
161
|
-
*/
|
|
162
|
-
static async isSDKready(callback) {
|
|
163
|
-
if (_reactNative.Platform.OS === 'android') {
|
|
164
|
-
const isInitialized = await this.isShieldInitialized();
|
|
165
|
-
callback(isInitialized);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
try {
|
|
169
|
-
// Adding a timeout of 100 milliseconds
|
|
170
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
171
|
-
const isInitialized = await this.isShieldInitialized();
|
|
172
|
-
if (!isInitialized) {
|
|
173
|
-
console.log('Shield SDK not initialized:');
|
|
174
|
-
callback(false);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const deviceResultListener = event => {
|
|
178
|
-
if (event.status === 'isSDKReady') {
|
|
179
|
-
ShieldFraud.eventEmitter.removeAllListeners('device_result_state');
|
|
180
|
-
callback(true);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
ShieldFraud.eventEmitter.addListener('device_result_state', deviceResultListener);
|
|
184
|
-
|
|
185
|
-
// Trigger the SDK subscription — iOS 1.x requires this explicit call.
|
|
186
|
-
ShieldFraud.PlatformWrapper.setDeviceResultStateListener();
|
|
187
|
-
} catch (error) {
|
|
188
|
-
console.error('An error occurred:', error);
|
|
189
|
-
callback(false);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
159
|
/**
|
|
194
160
|
* Sends attributes to the ShieldFraud plugin for a specific screen.
|
|
195
161
|
*
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","siteID","Error","secretKey","isOptimizedListener","logLevel","LogLevelNone","environmentInfo","EnvironmentProd","setCrossPlatformParameters","blockScreenRecording","Platform","OS","listeners","partnerId","blockedDialog","crossPlatformName","packageJson","name","crossPlatformVersion","version","_ShieldFraud$callback","_ShieldFraud$callback2","success","remove","error","addListener","data","onSuccess","onFailure","getSessionId","isShieldInitialized","sendAttributes","screenName","sendAttributesWithCallback","Promise","resolve","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,eA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EACE,OAAce,mBAAmBA,CAC/BP,UAAkB,EAClBQ,MAAe,EACE;IACjB,OAAO,IAAIN,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC5C,WAAW,CAACC,eAAe,CAAC8C,mBAAmB,CAC7CP,UAAU,EACVQ,MAAM,IAAI,IAAI,EACbH,MAAc,IAAK;QAClBF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,EACAb,KAAa,IAAK;QACjBY,MAAM,CAACZ,KAAK,CAAC;MACf,CAAC,CACF;IACH,CAAC,CAAC;EACJ;AACF;AAAC,IAAAiB,QAAA,GAEcjD,WAAW;AAAAF,OAAA,CAAAP,OAAA,GAAA0D,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;;AA2EA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC"}
|
package/lib/module/index.js
CHANGED
|
@@ -46,7 +46,7 @@ export let EnvironmentInfo = /*#__PURE__*/function (EnvironmentInfo) {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* The `ShieldFraud` class is a wrapper for the ShieldFraudPlugin native module in React Native.
|
|
49
|
-
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
49
|
+
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
50
50
|
* sending attributes, and getting the latest device result.
|
|
51
51
|
*/
|
|
52
52
|
class ShieldFraud {
|
|
@@ -70,6 +70,12 @@ class ShieldFraud {
|
|
|
70
70
|
* @param callbacks - (Optional) The callback functions for success and failure events.
|
|
71
71
|
*/
|
|
72
72
|
static async initShield(config, callbacks) {
|
|
73
|
+
if (!config.siteID) {
|
|
74
|
+
throw new Error('siteId must not be empty');
|
|
75
|
+
}
|
|
76
|
+
if (!config.secretKey) {
|
|
77
|
+
throw new Error('secretKey must not be empty');
|
|
78
|
+
}
|
|
73
79
|
const isOptimizedListener = !!callbacks;
|
|
74
80
|
|
|
75
81
|
// Set default values if logLevel is not provided
|
|
@@ -85,13 +91,14 @@ class ShieldFraud {
|
|
|
85
91
|
// Always send a real boolean — the Old Arch bridge cannot handle null
|
|
86
92
|
// for boolean parameters (causes NPE in ReadableNativeArray.getBoolean).
|
|
87
93
|
const blockScreenRecording = Platform.OS === 'android' ? config.blockScreenRecording ?? false : false;
|
|
88
|
-
|
|
89
|
-
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
90
|
-
await ShieldFraud.PlatformWrapper.initShield(config.siteID, config.secretKey, isOptimizedListener, config.blockedDialog ?? null, logLevel, environmentInfo, blockScreenRecording);
|
|
91
94
|
if (isOptimizedListener) {
|
|
92
|
-
//
|
|
95
|
+
// Register JS listeners before native initialization because ShieldFraud may
|
|
96
|
+
// deliver a cached device result immediately when its handler is registered.
|
|
93
97
|
ShieldFraud.listeners(callbacks);
|
|
94
98
|
}
|
|
99
|
+
|
|
100
|
+
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
101
|
+
await ShieldFraud.PlatformWrapper.initShield(config.siteID, config.secretKey, config.partnerId ?? null, isOptimizedListener, config.blockedDialog ?? null, logLevel, environmentInfo, blockScreenRecording);
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
/**
|
|
@@ -147,47 +154,6 @@ class ShieldFraud {
|
|
|
147
154
|
return ShieldFraud.PlatformWrapper.isShieldInitialized();
|
|
148
155
|
}
|
|
149
156
|
|
|
150
|
-
/**
|
|
151
|
-
* Checks if the ShieldFraud SDK is ready and invokes the provided callback
|
|
152
|
-
* with the readiness state.
|
|
153
|
-
*
|
|
154
|
-
* On Android, readiness is approximated by the native initialization state
|
|
155
|
-
* to preserve backward compatibility without reporting ready before init.
|
|
156
|
-
*
|
|
157
|
-
* @param callback - A callback function to be invoked with the readiness state.
|
|
158
|
-
* - `isReady` (boolean): true when the SDK has produced a device result.
|
|
159
|
-
*/
|
|
160
|
-
static async isSDKready(callback) {
|
|
161
|
-
if (Platform.OS === 'android') {
|
|
162
|
-
const isInitialized = await this.isShieldInitialized();
|
|
163
|
-
callback(isInitialized);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
try {
|
|
167
|
-
// Adding a timeout of 100 milliseconds
|
|
168
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
169
|
-
const isInitialized = await this.isShieldInitialized();
|
|
170
|
-
if (!isInitialized) {
|
|
171
|
-
console.log('Shield SDK not initialized:');
|
|
172
|
-
callback(false);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const deviceResultListener = event => {
|
|
176
|
-
if (event.status === 'isSDKReady') {
|
|
177
|
-
ShieldFraud.eventEmitter.removeAllListeners('device_result_state');
|
|
178
|
-
callback(true);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
ShieldFraud.eventEmitter.addListener('device_result_state', deviceResultListener);
|
|
182
|
-
|
|
183
|
-
// Trigger the SDK subscription — iOS 1.x requires this explicit call.
|
|
184
|
-
ShieldFraud.PlatformWrapper.setDeviceResultStateListener();
|
|
185
|
-
} catch (error) {
|
|
186
|
-
console.error('An error occurred:', error);
|
|
187
|
-
callback(false);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
157
|
/**
|
|
192
158
|
* Sends attributes to the ShieldFraud plugin for a specific screen.
|
|
193
159
|
*
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","TurboModuleRegistry","packageJson","ShieldFraudPluginNativeModule","get","ShieldFraudPlugin","LogLevel","EnvironmentInfo","ShieldFraud","PlatformWrapper","eventEmitter","callbackSubscriptions","initShield","config","callbacks","siteID","Error","secretKey","isOptimizedListener","logLevel","LogLevelNone","environmentInfo","EnvironmentProd","setCrossPlatformParameters","blockScreenRecording","OS","listeners","partnerId","blockedDialog","crossPlatformName","name","crossPlatformVersion","version","_ShieldFraud$callback","_ShieldFraud$callback2","success","remove","error","addListener","data","onSuccess","onFailure","getSessionId","isShieldInitialized","sendAttributes","screenName","sendAttributesWithCallback","Promise","resolve","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;;AAmBA;AAC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,IAAI,IAAI,EACbH,MAAc,IAAK;QAClBF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,EACAb,KAAa,IAAK;QACjBY,MAAM,CAACZ,KAAK,CAAC;MACf,CAAC,CACF;IACH,CAAC,CAAC;EACJ;AACF;AAEA,eAAe7B,WAAW"}
|
|
@@ -8,7 +8,7 @@ export interface Spec extends TurboModule {
|
|
|
8
8
|
/**
|
|
9
9
|
* Initializes the ShieldFraud SDK with the provided configuration.
|
|
10
10
|
*/
|
|
11
|
-
initShield(siteID: string, secretKey: string, isOptimizedListener: boolean, blockedDialog: Object | null, logLevel: number, environmentInfo: number,
|
|
11
|
+
initShield(siteID: string, secretKey: string, partnerId: string | null, isOptimizedListener: boolean, blockedDialog: Object | null, logLevel: number, environmentInfo: number,
|
|
12
12
|
/** Android-only: block screen recording while the SDK is active. Ignored on iOS. */
|
|
13
13
|
blockScreenRecording: boolean): Promise<void>;
|
|
14
14
|
/**
|
|
@@ -23,10 +23,6 @@ export interface Spec extends TurboModule {
|
|
|
23
23
|
* Returns whether the SDK has been initialized synchronously.
|
|
24
24
|
*/
|
|
25
25
|
isShieldInitialized(): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Registers a listener for the device-result-ready state event.
|
|
28
|
-
*/
|
|
29
|
-
setDeviceResultStateListener(): void;
|
|
30
26
|
/**
|
|
31
27
|
* Sends custom attributes for a given screen name.
|
|
32
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
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;IACH,UAAU,CACR,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,OAAO,EAC5B,aAAa,EAAE,MAAM,G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,MAAM,EAAE,OAAO,KAAK,IAAI,EAC1C,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GACrC,IAAI,CAAC;IAER;;OAEG;IACH,qBAAqB,CACnB,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,EACzC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GACrC,IAAI,CAAC;IAER;;;;OAIG;IACH,mBAAmB,CACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,eAAe,EAAE,CAAC,MAAM,EAAE,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"}
|
|
@@ -21,6 +21,7 @@ export declare enum EnvironmentInfo {
|
|
|
21
21
|
export interface Config {
|
|
22
22
|
siteID: string;
|
|
23
23
|
secretKey: string;
|
|
24
|
+
partnerId?: string | null;
|
|
24
25
|
blockedDialog?: {
|
|
25
26
|
title: string;
|
|
26
27
|
body: string;
|
|
@@ -51,7 +52,7 @@ export type ShieldCallback = {
|
|
|
51
52
|
};
|
|
52
53
|
/**
|
|
53
54
|
* The `ShieldFraud` class is a wrapper for the ShieldFraudPlugin native module in React Native.
|
|
54
|
-
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
55
|
+
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
55
56
|
* sending attributes, and getting the latest device result.
|
|
56
57
|
*/
|
|
57
58
|
declare class ShieldFraud {
|
|
@@ -96,17 +97,6 @@ declare class ShieldFraud {
|
|
|
96
97
|
* @returns Whether the ShieldFraud plugin is initialized.
|
|
97
98
|
*/
|
|
98
99
|
static isShieldInitialized(): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Checks if the ShieldFraud SDK is ready and invokes the provided callback
|
|
101
|
-
* with the readiness state.
|
|
102
|
-
*
|
|
103
|
-
* On Android, readiness is approximated by the native initialization state
|
|
104
|
-
* to preserve backward compatibility without reporting ready before init.
|
|
105
|
-
*
|
|
106
|
-
* @param callback - A callback function to be invoked with the readiness state.
|
|
107
|
-
* - `isReady` (boolean): true when the SDK has produced a device result.
|
|
108
|
-
*/
|
|
109
|
-
static isSDKready(callback: (isReady: boolean) => void): Promise<void>;
|
|
110
100
|
/**
|
|
111
101
|
* Sends attributes to the ShieldFraud plugin for a specific screen.
|
|
112
102
|
*
|
|
@@ -1 +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;IAC3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AAM,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;IA8ChB;;;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;;;;;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-full-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "React Native Shield Full 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",
|
|
@@ -13,6 +13,7 @@ export interface Spec extends TurboModule {
|
|
|
13
13
|
initShield(
|
|
14
14
|
siteID: string,
|
|
15
15
|
secretKey: string,
|
|
16
|
+
partnerId: string | null,
|
|
16
17
|
isOptimizedListener: boolean,
|
|
17
18
|
blockedDialog: Object | null,
|
|
18
19
|
logLevel: number,
|
|
@@ -39,11 +40,6 @@ export interface Spec extends TurboModule {
|
|
|
39
40
|
*/
|
|
40
41
|
isShieldInitialized(): boolean;
|
|
41
42
|
|
|
42
|
-
/**
|
|
43
|
-
* Registers a listener for the device-result-ready state event.
|
|
44
|
-
*/
|
|
45
|
-
setDeviceResultStateListener(): void;
|
|
46
|
-
|
|
47
43
|
/**
|
|
48
44
|
* Sends custom attributes for a given screen name.
|
|
49
45
|
*/
|
package/src/index.tsx
CHANGED
|
@@ -39,6 +39,7 @@ export enum EnvironmentInfo {
|
|
|
39
39
|
export interface Config {
|
|
40
40
|
siteID: string;
|
|
41
41
|
secretKey: string;
|
|
42
|
+
partnerId?: string | null;
|
|
42
43
|
blockedDialog?: {
|
|
43
44
|
title: string;
|
|
44
45
|
body: string;
|
|
@@ -73,7 +74,7 @@ export type ShieldCallback = {
|
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* The `ShieldFraud` class is a wrapper for the ShieldFraudPlugin native module in React Native.
|
|
76
|
-
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
77
|
+
* It provides methods for initializing ShieldFraud, retrieving session ID,
|
|
77
78
|
* sending attributes, and getting the latest device result.
|
|
78
79
|
*/
|
|
79
80
|
class ShieldFraud {
|
|
@@ -106,6 +107,14 @@ class ShieldFraud {
|
|
|
106
107
|
config: Config,
|
|
107
108
|
callbacks?: ShieldCallback
|
|
108
109
|
): Promise<void> {
|
|
110
|
+
if (!config.siteID) {
|
|
111
|
+
throw new Error('siteId must not be empty');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!config.secretKey) {
|
|
115
|
+
throw new Error('secretKey must not be empty');
|
|
116
|
+
}
|
|
117
|
+
|
|
109
118
|
const isOptimizedListener = !!callbacks;
|
|
110
119
|
|
|
111
120
|
// Set default values if logLevel is not provided
|
|
@@ -124,21 +133,23 @@ class ShieldFraud {
|
|
|
124
133
|
const blockScreenRecording =
|
|
125
134
|
Platform.OS === 'android' ? config.blockScreenRecording ?? false : false;
|
|
126
135
|
|
|
136
|
+
if (isOptimizedListener) {
|
|
137
|
+
// Register JS listeners before native initialization because ShieldFraud may
|
|
138
|
+
// deliver a cached device result immediately when its handler is registered.
|
|
139
|
+
ShieldFraud.listeners(callbacks);
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
// Call the native method to initialize ShieldFraud with the provided configuration.
|
|
128
143
|
await ShieldFraud.PlatformWrapper.initShield(
|
|
129
144
|
config.siteID,
|
|
130
145
|
config.secretKey,
|
|
146
|
+
config.partnerId ?? null,
|
|
131
147
|
isOptimizedListener,
|
|
132
148
|
config.blockedDialog ?? null,
|
|
133
149
|
logLevel,
|
|
134
150
|
environmentInfo,
|
|
135
151
|
blockScreenRecording
|
|
136
152
|
);
|
|
137
|
-
|
|
138
|
-
if (isOptimizedListener) {
|
|
139
|
-
// Set up listeners for success and error events if callbacks are provided.
|
|
140
|
-
ShieldFraud.listeners(callbacks);
|
|
141
|
-
}
|
|
142
153
|
}
|
|
143
154
|
|
|
144
155
|
/**
|
|
@@ -199,57 +210,6 @@ class ShieldFraud {
|
|
|
199
210
|
return ShieldFraud.PlatformWrapper.isShieldInitialized();
|
|
200
211
|
}
|
|
201
212
|
|
|
202
|
-
/**
|
|
203
|
-
* Checks if the ShieldFraud SDK is ready and invokes the provided callback
|
|
204
|
-
* with the readiness state.
|
|
205
|
-
*
|
|
206
|
-
* On Android, readiness is approximated by the native initialization state
|
|
207
|
-
* to preserve backward compatibility without reporting ready before init.
|
|
208
|
-
*
|
|
209
|
-
* @param callback - A callback function to be invoked with the readiness state.
|
|
210
|
-
* - `isReady` (boolean): true when the SDK has produced a device result.
|
|
211
|
-
*/
|
|
212
|
-
public static async isSDKready(
|
|
213
|
-
callback: (isReady: boolean) => void
|
|
214
|
-
): Promise<void> {
|
|
215
|
-
if (Platform.OS === 'android') {
|
|
216
|
-
const isInitialized = await this.isShieldInitialized();
|
|
217
|
-
callback(isInitialized);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
try {
|
|
222
|
-
// Adding a timeout of 100 milliseconds
|
|
223
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
224
|
-
|
|
225
|
-
const isInitialized = await this.isShieldInitialized();
|
|
226
|
-
|
|
227
|
-
if (!isInitialized) {
|
|
228
|
-
console.log('Shield SDK not initialized:');
|
|
229
|
-
callback(false);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const deviceResultListener = (event: { status: string }) => {
|
|
234
|
-
if (event.status === 'isSDKReady') {
|
|
235
|
-
ShieldFraud.eventEmitter.removeAllListeners('device_result_state');
|
|
236
|
-
callback(true);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
ShieldFraud.eventEmitter.addListener(
|
|
241
|
-
'device_result_state',
|
|
242
|
-
deviceResultListener
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
// Trigger the SDK subscription — iOS 1.x requires this explicit call.
|
|
246
|
-
ShieldFraud.PlatformWrapper.setDeviceResultStateListener();
|
|
247
|
-
} catch (error) {
|
|
248
|
-
console.error('An error occurred:', error);
|
|
249
|
-
callback(false);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
213
|
/**
|
|
254
214
|
* Sends attributes to the ShieldFraud plugin for a specific screen.
|
|
255
215
|
*
|