react-native-shield-fraud-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +161 -0
- package/android/build.gradle +85 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/shieldfraudplugin/ShieldFraudPluginModule.java +190 -0
- package/android/src/main/java/com/shieldfraudplugin/ShieldFraudPluginPackage.java +28 -0
- package/ios/Podfile +10 -0
- package/ios/Podfile.lock +16 -0
- package/ios/Pods/Manifest.lock +16 -0
- package/ios/Pods/Pods.xcodeproj/project.pbxproj +536 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/deepakraj.xcuserdatad/xcschemes/Pods-ShieldFraudPlugin.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/deepakraj.xcuserdatad/xcschemes/ShieldFraud.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/deepakraj.xcuserdatad/xcschemes/xcschememanagement.plist +25 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/Info.plist +44 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Headers/ShieldFraud-Swift.h +394 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Headers/ShieldFraud.h +20 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Info.plist +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios.abi.json +6726 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios.private.swiftinterface +207 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios.swiftinterface +207 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/Modules/module.modulemap +11 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/ShieldFraud +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/ShieldFraud.framework/_CodeSignature/CodeResources +222 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/dSYMs/ShieldFraud.framework.dSYM/Contents/Info.plist +20 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64/dSYMs/ShieldFraud.framework.dSYM/Contents/Resources/DWARF/ShieldFraud +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Headers/ShieldFraud-Swift.h +784 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Headers/ShieldFraud.h +20 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Info.plist +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios-simulator.abi.json +6726 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +207 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/arm64-apple-ios-simulator.swiftinterface +207 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/x86_64-apple-ios-simulator.abi.json +6712 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +207 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/ShieldFraud.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +207 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/Modules/module.modulemap +11 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/ShieldFraud +0 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/ShieldFraud.framework/_CodeSignature/CodeResources +297 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/dSYMs/ShieldFraud.framework.dSYM/Contents/Info.plist +20 -0
- package/ios/Pods/ShieldFraud/ShieldFraud.xcframework/ios-arm64_x86_64-simulator/dSYMs/ShieldFraud.framework.dSYM/Contents/Resources/DWARF/ShieldFraud +0 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin-acknowledgements.markdown +7 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin-acknowledgements.plist +39 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin-umbrella.h +16 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin.debug.xcconfig +13 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin.modulemap +6 -0
- package/ios/Pods/Target Support Files/Pods-ShieldFraudPlugin/Pods-ShieldFraudPlugin.release.xcconfig +13 -0
- package/ios/Pods/Target Support Files/ShieldFraud/ShieldFraud-xcframeworks.sh +121 -0
- package/ios/Pods/Target Support Files/ShieldFraud/ShieldFraud.debug.xcconfig +14 -0
- package/ios/Pods/Target Support Files/ShieldFraud/ShieldFraud.release.xcconfig +14 -0
- package/ios/ShieldFraudPlugin.h +15 -0
- package/ios/ShieldFraudPlugin.m +90 -0
- package/ios/ShieldFraudPlugin.xcodeproj/project.pbxproj +326 -0
- package/ios/ShieldFraudPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/ShieldFraudPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/ShieldFraudPlugin.xcodeproj/project.xcworkspace/xcuserdata/deepakraj.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/ShieldFraudPlugin.xcodeproj/xcuserdata/deepakraj.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/ShieldFraudPlugin.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/ShieldFraudPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/ShieldFraudPlugin.xcworkspace/xcuserdata/deepakraj.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/ShieldFraudPlugin.xcworkspace/xcuserdata/deepakraj.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
- package/lib/commonjs/index.js +150 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +148 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +100 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +160 -0
- package/react-native-shield-fraud-plugin.podspec +19 -0
- package/src/index.tsx +173 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 shield.com
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# React Native Shield Fraud Plugin
|
|
2
|
+
|
|
3
|
+
React Native Plugin for Shield Fraud (www.shield.com)
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
There are four 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
|
+
|
|
20
|
+
### Integrate the SDK
|
|
21
|
+
|
|
22
|
+
This package can be installed in two ways, you can choose a way depends on your need.
|
|
23
|
+
|
|
24
|
+
**NPM:**
|
|
25
|
+
```
|
|
26
|
+
npm install react-native-shield-fraud-plugin
|
|
27
|
+
```
|
|
28
|
+
**OR**
|
|
29
|
+
|
|
30
|
+
**YARN:**
|
|
31
|
+
```
|
|
32
|
+
yarn add react-native-shield-fraud-plugin
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Note**: We make continuous enhancements to our fraud 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.
|
|
36
|
+
|
|
37
|
+
You can refer to the Changelog to see more details about our updates.
|
|
38
|
+
|
|
39
|
+
### Initialize the SDK
|
|
40
|
+
|
|
41
|
+
The SDK initialization should be configured at the earliest of the App Lifecycle to ensure successful generation and processing of the device fingerprint. SDK is to be initialised only once and will throw an exception if it is initialised more than once.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
You can initialize the SDK by calling it inside UseEffect()
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
const config: Config = {
|
|
50
|
+
siteID: 'SHIELD_SITE_ID',
|
|
51
|
+
secretKey: 'SHIELD_SECRET_KEY'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
ShieldFraud.initShield(config)
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`Config` has these **optional** parameters:
|
|
60
|
+
|
|
61
|
+
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.
|
|
62
|
+
2. `environmentInfo` Set your environment info to prod, dev or staging. Default environment info is prod.
|
|
63
|
+
3. `blockedDialog` Set your dialog for the blocked dialog both title and body or you can send it as null as well
|
|
64
|
+
|
|
65
|
+
Note: You can check whether Shield SDK is ready or not by using isSDKready function
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
69
|
+
if (isReady) {
|
|
70
|
+
// Shield is Ready: Do your implementation
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Get Session ID
|
|
76
|
+
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.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
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.
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
85
|
+
if (isReady) {
|
|
86
|
+
const sessionID = await ShieldFraud.getSessionId(); // Fetch session ID using await
|
|
87
|
+
console.log('session id: ', sessionID);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Get Device Results
|
|
93
|
+
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.
|
|
94
|
+
|
|
95
|
+
*Warning: Only 1 method of obtaining device results **(Optimized Listener or Customized Pull)** can be in effect at any point in time.*
|
|
96
|
+
|
|
97
|
+
#### Retrieve device results via Optimized Listener
|
|
98
|
+
|
|
99
|
+
##### SHIELD recommends the Optimized Listener method to reduce number of API calls. #####
|
|
100
|
+
|
|
101
|
+
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.
|
|
102
|
+
|
|
103
|
+
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).
|
|
104
|
+
|
|
105
|
+
Add an additional parameter during intialization in order to register a callback.
|
|
106
|
+
|
|
107
|
+
For example - ShieldFraud.initShield(config, **callbacks**);
|
|
108
|
+
```
|
|
109
|
+
const callbacks: ShieldCallback = {
|
|
110
|
+
onSuccess: (data) => {
|
|
111
|
+
// Handle success event here
|
|
112
|
+
console.log('Success:', data);
|
|
113
|
+
},
|
|
114
|
+
onFailure: (error) => {
|
|
115
|
+
// Handle failure event here
|
|
116
|
+
console.log('Error:', error);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const config: Config = {
|
|
121
|
+
siteID: 'SHIELD_SITE_ID',
|
|
122
|
+
secretKey: 'SHIELD_SECRET_KEY'
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
ShieldFraud.initShield(config, callbacks);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Retrieve device results via Customized Pull
|
|
129
|
+
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.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
133
|
+
if (isReady) {
|
|
134
|
+
ShieldFraud.getLatestDeviceResult()
|
|
135
|
+
.then((result: object) => {
|
|
136
|
+
// Handle success with the result object
|
|
137
|
+
console.log('Received latest device result:', result);
|
|
138
|
+
})
|
|
139
|
+
.catch((error: object) => {
|
|
140
|
+
// Handle error with the error object
|
|
141
|
+
console.log('Error retrieving device result:', error);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
It is possible that getLatestDeviceResult returns null if the device result retrieval is unsuccessful.
|
|
148
|
+
|
|
149
|
+
### Send Custom Attributes
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
ShieldFraud.isSDKready(async (isReady: boolean) => {
|
|
155
|
+
if (isReady) {
|
|
156
|
+
ShieldFraud.sendAttributes('Screen_Name', { key1: 'value1', key2: 'value2' });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:4.1.3"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def isNewArchitectureEnabled() {
|
|
13
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apply plugin: "com.android.library"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
20
|
+
|
|
21
|
+
if (isNewArchitectureEnabled()) {
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def getExtOrDefault(name) {
|
|
26
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ShieldFraudPlugin_" + name]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def getExtOrIntegerDefault(name) {
|
|
30
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ShieldFraudPlugin_" + name]).toInteger()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
android {
|
|
34
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
35
|
+
|
|
36
|
+
defaultConfig {
|
|
37
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
38
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
39
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
40
|
+
}
|
|
41
|
+
buildTypes {
|
|
42
|
+
release {
|
|
43
|
+
minifyEnabled false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
lintOptions {
|
|
48
|
+
disable "GradleCompatible"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
compileOptions {
|
|
52
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
53
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if (isNewArchitectureEnabled()) {
|
|
58
|
+
react {
|
|
59
|
+
jsRootDir = file("../src/")
|
|
60
|
+
libraryName = "ShieldFraudPlugin"
|
|
61
|
+
codegenJavaPackageName = "com.shieldfraudplugin"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
rootProject.allprojects {
|
|
67
|
+
repositories {
|
|
68
|
+
mavenCentral()
|
|
69
|
+
google()
|
|
70
|
+
maven {
|
|
71
|
+
url "https://cashshield-sdk.s3.amazonaws.com/release/"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
dependencies {
|
|
79
|
+
// For < 0.71, this will be from the local maven repo
|
|
80
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
81
|
+
//noinspection GradleDynamicVersion
|
|
82
|
+
implementation "com.facebook.react:react-native:+"
|
|
83
|
+
implementation 'com.shield.android:shield-fraud:1.6.+'
|
|
84
|
+
}
|
|
85
|
+
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
package com.shieldfraudplugin;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.bridge.Promise;
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
11
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
12
|
+
|
|
13
|
+
import com.facebook.react.bridge.Callback;
|
|
14
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
15
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
16
|
+
import com.shield.android.BlockedDialog;
|
|
17
|
+
import com.shield.android.Shield;
|
|
18
|
+
import com.shield.android.ShieldCallback;
|
|
19
|
+
import com.shield.android.ShieldException;
|
|
20
|
+
|
|
21
|
+
import org.json.JSONObject;
|
|
22
|
+
|
|
23
|
+
import java.util.HashMap;
|
|
24
|
+
import java.util.Map;
|
|
25
|
+
|
|
26
|
+
import javax.annotation.Nonnull;
|
|
27
|
+
import javax.annotation.Nullable;
|
|
28
|
+
|
|
29
|
+
@ReactModule(name = ShieldFraudPluginModule.NAME)
|
|
30
|
+
public class ShieldFraudPluginModule extends ReactContextBaseJavaModule implements ShieldCallback<JSONObject> {
|
|
31
|
+
public static final String NAME = "ShieldFraudPlugin";
|
|
32
|
+
private final ReactApplicationContext reactContext;
|
|
33
|
+
|
|
34
|
+
public ShieldFraudPluginModule(ReactApplicationContext reactContext) {
|
|
35
|
+
super(reactContext);
|
|
36
|
+
this.reactContext = reactContext;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
@NonNull
|
|
41
|
+
public String getName() {
|
|
42
|
+
return NAME;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private boolean isShieldInitialized() {
|
|
46
|
+
try {
|
|
47
|
+
return Shield.getInstance() != null;
|
|
48
|
+
} catch (IllegalStateException e) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@ReactMethod
|
|
54
|
+
public void initShield(String siteID, String secretKey, Boolean isOptimizedListener, ReadableMap blockedDialog, Integer logLevel, Integer environment) {
|
|
55
|
+
if (isShieldInitialized()) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
Activity currentActivity = getCurrentActivity();
|
|
59
|
+
if (currentActivity != null) {
|
|
60
|
+
Shield.Builder builder = new Shield.Builder(currentActivity, siteID, secretKey)
|
|
61
|
+
.setAutoBlockDialog(getBlockedDialogFromReadableMap(blockedDialog));
|
|
62
|
+
|
|
63
|
+
if (isOptimizedListener) {
|
|
64
|
+
builder.registerDeviceShieldCallback(this);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
String environmentString = getEnvironmentStringFromInteger(environment);
|
|
68
|
+
builder.setEnvironment(environmentString);
|
|
69
|
+
|
|
70
|
+
Shield.LogLevel logLevelEnum = getLogLevelEnumFromInteger(logLevel);
|
|
71
|
+
builder.setLogLevel(logLevelEnum);
|
|
72
|
+
|
|
73
|
+
Shield shield = builder.build();
|
|
74
|
+
Shield.setSingletonInstance(shield);
|
|
75
|
+
System.out.println("SHIELD:: Init Done");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private BlockedDialog getBlockedDialogFromReadableMap(ReadableMap blockedDialog) {
|
|
80
|
+
if (blockedDialog != null) {
|
|
81
|
+
String title = blockedDialog.hasKey("title") ? blockedDialog.getString("title") : null;
|
|
82
|
+
String body = blockedDialog.hasKey("body") ? blockedDialog.getString("body") : null;
|
|
83
|
+
return new BlockedDialog(title, body);
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private String getEnvironmentStringFromInteger(Integer environment) {
|
|
89
|
+
String environmentString;
|
|
90
|
+
switch (environment) {
|
|
91
|
+
case 1:
|
|
92
|
+
environmentString = Shield.ENVIRONMENT_DEV;
|
|
93
|
+
break;
|
|
94
|
+
case 2:
|
|
95
|
+
environmentString = Shield.ENVIRONMENT_STAGING;
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
environmentString = Shield.ENVIRONMENT_PROD;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return environmentString;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private Shield.LogLevel getLogLevelEnumFromInteger(Integer logLevel) {
|
|
105
|
+
Shield.LogLevel logLevelEnum;
|
|
106
|
+
switch (logLevel) {
|
|
107
|
+
case 1:
|
|
108
|
+
logLevelEnum = Shield.LogLevel.NONE;
|
|
109
|
+
break;
|
|
110
|
+
case 2:
|
|
111
|
+
logLevelEnum = Shield.LogLevel.INFO;
|
|
112
|
+
break;
|
|
113
|
+
case 3:
|
|
114
|
+
logLevelEnum = Shield.LogLevel.DEBUG;
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
logLevelEnum = Shield.LogLevel.VERBOSE;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
return logLevelEnum;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactMethod
|
|
124
|
+
public void setDeviceResultStateListener(Callback callback) {
|
|
125
|
+
Shield.getInstance().setDeviceResultStateListener(new Shield.DeviceResultStateListener() {
|
|
126
|
+
@Override
|
|
127
|
+
public void isReady() {
|
|
128
|
+
// Invoke the callback when the device is ready
|
|
129
|
+
callback.invoke();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
136
|
+
public String getSessionId() {
|
|
137
|
+
System.out.println("SHIELD:: GetSession Id");
|
|
138
|
+
return Shield.getInstance().getSessionId();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@Override
|
|
142
|
+
public void onSuccess(@Nullable JSONObject jsonObject) {
|
|
143
|
+
if (jsonObject != null) {
|
|
144
|
+
reactContext
|
|
145
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
146
|
+
.emit("success", jsonObject.toString());
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@Override
|
|
151
|
+
public void onFailure(@Nullable ShieldException e) {
|
|
152
|
+
if (e != null) {
|
|
153
|
+
reactContext
|
|
154
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
155
|
+
.emit("error", e.getLocalizedMessage());
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@ReactMethod
|
|
161
|
+
public void sendAttributes(String screenName, ReadableMap json) {
|
|
162
|
+
HashMap<String,String> data =new HashMap<String,String>();
|
|
163
|
+
for (Map.Entry<String, Object> entry : json.toHashMap().entrySet()) {
|
|
164
|
+
data.put(entry.getKey(), (String) entry.getValue());
|
|
165
|
+
}
|
|
166
|
+
Shield.getInstance().setDeviceResultStateListener(new Shield.DeviceResultStateListener(){
|
|
167
|
+
// check whether device fingerprinting is completed
|
|
168
|
+
@Override
|
|
169
|
+
public void isReady() {
|
|
170
|
+
Shield.getInstance().sendAttributes(screenName, data);
|
|
171
|
+
System.out.println("the attribteus are sent to the server");
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@ReactMethod
|
|
177
|
+
public void getLatestDeviceResult(Callback successCallback, Callback errorCallback) {
|
|
178
|
+
if (Shield.getInstance().getLatestDeviceResult() != null) {
|
|
179
|
+
JSONObject deviceResult = Shield.getInstance().getLatestDeviceResult();
|
|
180
|
+
successCallback.invoke(deviceResult.toString());
|
|
181
|
+
} else {
|
|
182
|
+
ShieldException error = Shield.getInstance().getResponseError();
|
|
183
|
+
String errorMessage = "unknown error";
|
|
184
|
+
if (error != null) {
|
|
185
|
+
errorMessage = error.getMessage();
|
|
186
|
+
}
|
|
187
|
+
errorCallback.invoke(errorMessage);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.shieldfraudplugin;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.Collections;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
public class ShieldFraudPluginPackage implements ReactPackage {
|
|
15
|
+
@NonNull
|
|
16
|
+
@Override
|
|
17
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
18
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
19
|
+
modules.add(new ShieldFraudPluginModule(reactContext));
|
|
20
|
+
return modules;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@NonNull
|
|
24
|
+
@Override
|
|
25
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
26
|
+
return Collections.emptyList();
|
|
27
|
+
}
|
|
28
|
+
}
|
package/ios/Podfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Uncomment the next line to define a global platform for your project
|
|
2
|
+
platform :ios, '11.0'
|
|
3
|
+
|
|
4
|
+
target 'ShieldFraudPlugin' do
|
|
5
|
+
# Comment the next line if you don't want to use dynamic frameworks
|
|
6
|
+
use_frameworks!
|
|
7
|
+
|
|
8
|
+
# Pods for ShieldFraudPlugin
|
|
9
|
+
pod 'ShieldFraud'
|
|
10
|
+
end
|
package/ios/Podfile.lock
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
PODS:
|
|
2
|
+
- ShieldFraud (1.5.24)
|
|
3
|
+
|
|
4
|
+
DEPENDENCIES:
|
|
5
|
+
- ShieldFraud
|
|
6
|
+
|
|
7
|
+
SPEC REPOS:
|
|
8
|
+
trunk:
|
|
9
|
+
- ShieldFraud
|
|
10
|
+
|
|
11
|
+
SPEC CHECKSUMS:
|
|
12
|
+
ShieldFraud: 83c34e06aca03c764534c25c9e19752ae1837acc
|
|
13
|
+
|
|
14
|
+
PODFILE CHECKSUM: a5054f2edb3e213ae2ca7daafb855d17cf61674c
|
|
15
|
+
|
|
16
|
+
COCOAPODS: 1.11.3
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
PODS:
|
|
2
|
+
- ShieldFraud (1.5.24)
|
|
3
|
+
|
|
4
|
+
DEPENDENCIES:
|
|
5
|
+
- ShieldFraud
|
|
6
|
+
|
|
7
|
+
SPEC REPOS:
|
|
8
|
+
trunk:
|
|
9
|
+
- ShieldFraud
|
|
10
|
+
|
|
11
|
+
SPEC CHECKSUMS:
|
|
12
|
+
ShieldFraud: 83c34e06aca03c764534c25c9e19752ae1837acc
|
|
13
|
+
|
|
14
|
+
PODFILE CHECKSUM: a5054f2edb3e213ae2ca7daafb855d17cf61674c
|
|
15
|
+
|
|
16
|
+
COCOAPODS: 1.11.3
|