react-native-shield-full-plugin 2.3.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.
Files changed (30) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +237 -0
  3. package/android/build.gradle +109 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +5 -0
  6. package/android/src/main/java/com/shieldfraudplugin/ShieldFraudPluginModule.java +441 -0
  7. package/android/src/main/java/com/shieldfraudplugin/ShieldFraudPluginPackage.java +78 -0
  8. package/android/src/newarch/java/com/shieldfraudplugin/ShieldFraudPluginSpec.java +41 -0
  9. package/android/src/oldarch/java/com/shieldfraudplugin/ShieldFraudPluginSpec.java +36 -0
  10. package/ios/ShieldFraudPlugin.h +24 -0
  11. package/ios/ShieldFraudPlugin.mm +295 -0
  12. package/ios/ShieldFraudPlugin.xcodeproj/project.pbxproj +282 -0
  13. package/ios/ShieldFraudPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  14. package/lib/commonjs/NativeShieldFraudPlugin.js +15 -0
  15. package/lib/commonjs/NativeShieldFraudPlugin.js.map +1 -0
  16. package/lib/commonjs/index.js +256 -0
  17. package/lib/commonjs/index.js.map +1 -0
  18. package/lib/module/NativeShieldFraudPlugin.js +10 -0
  19. package/lib/module/NativeShieldFraudPlugin.js.map +1 -0
  20. package/lib/module/index.js +253 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/typescript/src/NativeShieldFraudPlugin.d.ts +53 -0
  23. package/lib/typescript/src/NativeShieldFraudPlugin.d.ts.map +1 -0
  24. package/lib/typescript/src/index.d.ts +143 -0
  25. package/lib/typescript/src/index.d.ts.map +1 -0
  26. package/package.json +169 -0
  27. package/react-native-shield-fraud-plugin.podspec +29 -0
  28. package/react-native-shield-full-plugin.podspec +29 -0
  29. package/src/NativeShieldFraudPlugin.ts +87 -0
  30. package/src/index.tsx +334 -0
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Enum representing the log levels for ShieldFraud.
3
+ */
4
+ export declare enum LogLevel {
5
+ LogLevelVerbose = 4,
6
+ LogLevelDebug = 3,
7
+ LogLevelInfo = 2,
8
+ LogLevelNone = 1
9
+ }
10
+ /**
11
+ * Enum representing the environment information for ShieldFraud.
12
+ */
13
+ export declare enum EnvironmentInfo {
14
+ EnvironmentProd = 0,
15
+ EnvironmentDev = 1,
16
+ EnvironmentStaging = 2
17
+ }
18
+ /**
19
+ * Configuration object for initializing ShieldFraud.
20
+ */
21
+ export interface Config {
22
+ siteID: string;
23
+ secretKey: string;
24
+ blockedDialog?: {
25
+ title: string;
26
+ body: string;
27
+ } | null;
28
+ logLevel?: LogLevel;
29
+ environmentInfo?: EnvironmentInfo;
30
+ /**
31
+ * Android-only: when true, the Shield SDK will block screen recording
32
+ * while it is active. Has no effect on iOS (the value is forwarded but
33
+ * the native side ignores it). Defaults to false when not provided.
34
+ */
35
+ blockScreenRecording?: boolean;
36
+ }
37
+ /**
38
+ * Type definition for the success callback function.
39
+ */
40
+ type SuccessCallback = (data: any) => void;
41
+ /**
42
+ * Type definition for the failure callback function.
43
+ */
44
+ type FailureCallback = (error: any) => void;
45
+ /**
46
+ * Type definition for the ShieldFraud callback functions.
47
+ */
48
+ export type ShieldCallback = {
49
+ onSuccess?: SuccessCallback;
50
+ onFailure?: FailureCallback;
51
+ };
52
+ /**
53
+ * The `ShieldFraud` class is a wrapper for the ShieldFraudPlugin native module in React Native.
54
+ * It provides methods for initializing ShieldFraud, retrieving session ID, checking the SDK readiness,
55
+ * sending attributes, and getting the latest device result.
56
+ */
57
+ declare class ShieldFraud {
58
+ /**
59
+ * The native module for accessing the ShieldFraudPlugin.
60
+ * Resolved via TurboModuleRegistry on New Architecture, with
61
+ * a NativeModules bridge fallback for Old Architecture.
62
+ */
63
+ private static PlatformWrapper;
64
+ /**
65
+ * The event emitter for listening to success and error events.
66
+ */
67
+ private static eventEmitter;
68
+ private static callbackSubscriptions;
69
+ /**
70
+ * Initializes the ShieldFraud plugin with the provided configuration.
71
+ *
72
+ * @param config - The configuration object containing the required properties.
73
+ * @param callbacks - (Optional) The callback functions for success and failure events.
74
+ */
75
+ static initShield(config: Config, callbacks?: ShieldCallback): Promise<void>;
76
+ /**
77
+ * Private method to set cross-platform parameters.
78
+ * The cross-platform name and the version is fetched from package.json.
79
+ */
80
+ private static setCrossPlatformParameters;
81
+ /**
82
+ * Sets up event listeners for success and error events.
83
+ *
84
+ * @param callbacks - The callback functions for success and failure events.
85
+ */
86
+ private static listeners;
87
+ /**
88
+ * Retrieves the session ID from the ShieldFraud plugin.
89
+ *
90
+ * @returns The current session ID.
91
+ */
92
+ static getSessionId(): string;
93
+ /**
94
+ * Checks whether the ShieldFraud plugin is initialized.
95
+ *
96
+ * @returns Whether the ShieldFraud plugin is initialized.
97
+ */
98
+ 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
+ /**
111
+ * Sends attributes to the ShieldFraud plugin for a specific screen.
112
+ *
113
+ * @param screenName - The name of the screen.
114
+ * @param data - The attribute data object.
115
+ */
116
+ static sendAttributes(screenName: string, data: object): void;
117
+ /**
118
+ * Sends attributes and resolves with `true` when the native SDK confirms success.
119
+ *
120
+ * @param screenName - The name of the screen.
121
+ * @param data - The attribute data object.
122
+ * @returns A Promise that resolves to true on success and rejects on error.
123
+ */
124
+ static sendAttributesWithCallback(screenName: string, data: object): Promise<boolean>;
125
+ /**
126
+ * Retrieves the latest device result from the ShieldFraud plugin.
127
+ *
128
+ * @returns A Promise that resolves with the latest device result object.
129
+ */
130
+ static getLatestDeviceResult(): Promise<object>;
131
+ /**
132
+ * Triggers a device signature computation for a given screen name.
133
+ * On success, resolves with the latest device result object.
134
+ * On failure, rejects with the error message.
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.
138
+ * @returns A Promise that resolves with the device result or rejects with an error.
139
+ */
140
+ static sendDeviceSignature(screenName: string, userId?: string): Promise<object>;
141
+ }
142
+ export default ShieldFraud;
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 ADDED
@@ -0,0 +1,169 @@
1
+ {
2
+ "name": "react-native-shield-full-plugin",
3
+ "version": "2.3.0",
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
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "*.podspec",
17
+ "!lib/typescript/example",
18
+ "!ios/build",
19
+ "!android/build",
20
+ "!android/gradle",
21
+ "!android/gradlew",
22
+ "!android/gradlew.bat",
23
+ "!android/local.properties",
24
+ "!**/__tests__",
25
+ "!**/__fixtures__",
26
+ "!**/__mocks__",
27
+ "!**/.*"
28
+ ],
29
+ "scripts": {
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "prepack": "bob build",
34
+ "release": "release-it",
35
+ "example": "yarn --cwd example",
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",
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"
42
+ },
43
+ "keywords": [
44
+ "react-native",
45
+ "ios",
46
+ "android",
47
+ "shieldfull",
48
+ "device-intelligence",
49
+ "mobile-fingerprint"
50
+ ],
51
+ "repository": "https://github.com/shield-ai-technology/react-native-shield-fraud-plugin",
52
+ "author": "www.shield.com",
53
+ "license": "MIT",
54
+ "homepage": "https://github.com/shield-ai-technology/react-native-shield-fraud-plugin#readme",
55
+ "devDependencies": {
56
+ "@evilmartians/lefthook": "^1.2.2",
57
+ "@commitlint/config-conventional": "^17.0.2",
58
+ "@react-native-community/eslint-config": "^3.0.2",
59
+ "@release-it/conventional-changelog": "^5.0.0",
60
+ "@types/jest": "^28.1.2",
61
+ "@types/react": "~17.0.21",
62
+ "@types/react-native": "0.70.0",
63
+ "commitlint": "^17.0.2",
64
+ "del-cli": "^5.0.0",
65
+ "eslint": "^8.4.1",
66
+ "eslint-config-prettier": "^8.5.0",
67
+ "eslint-plugin-prettier": "^4.0.0",
68
+ "jest": "^28.1.1",
69
+ "pod-install": "^0.1.0",
70
+ "prettier": "^2.0.5",
71
+ "react": "18.2.0",
72
+ "react-native": "0.71.7",
73
+ "react-native-builder-bob": "^0.20.0",
74
+ "release-it": "^15.0.0",
75
+ "typescript": "^4.5.2"
76
+ },
77
+ "resolutions": {
78
+ "@types/react": "17.0.21"
79
+ },
80
+ "peerDependencies": {
81
+ "react": "*",
82
+ "react-native": "*"
83
+ },
84
+ "engines": {
85
+ "node": ">= 16.0.0"
86
+ },
87
+ "packageManager": "yarn@1.22.15",
88
+ "jest": {
89
+ "preset": "react-native",
90
+ "modulePathIgnorePatterns": [
91
+ "<rootDir>/example/node_modules",
92
+ "<rootDir>/lib/"
93
+ ]
94
+ },
95
+ "commitlint": {
96
+ "extends": [
97
+ "@commitlint/config-conventional"
98
+ ]
99
+ },
100
+ "release-it": {
101
+ "git": {
102
+ "commitMessage": "chore: release ${version}",
103
+ "tagName": "v${version}"
104
+ },
105
+ "npm": {
106
+ "publish": true
107
+ },
108
+ "github": {
109
+ "release": true
110
+ },
111
+ "plugins": {
112
+ "@release-it/conventional-changelog": {
113
+ "preset": "angular"
114
+ }
115
+ }
116
+ },
117
+ "eslintConfig": {
118
+ "root": true,
119
+ "extends": [
120
+ "@react-native-community",
121
+ "prettier"
122
+ ],
123
+ "rules": {
124
+ "prettier/prettier": [
125
+ "error",
126
+ {
127
+ "quoteProps": "consistent",
128
+ "singleQuote": true,
129
+ "tabWidth": 2,
130
+ "trailingComma": "es5",
131
+ "useTabs": false
132
+ }
133
+ ]
134
+ }
135
+ },
136
+ "eslintIgnore": [
137
+ "node_modules/",
138
+ "lib/"
139
+ ],
140
+ "prettier": {
141
+ "quoteProps": "consistent",
142
+ "singleQuote": true,
143
+ "tabWidth": 2,
144
+ "trailingComma": "es5",
145
+ "useTabs": false
146
+ },
147
+ "react-native-builder-bob": {
148
+ "source": "src",
149
+ "output": "lib",
150
+ "targets": [
151
+ "commonjs",
152
+ "module",
153
+ [
154
+ "typescript",
155
+ {
156
+ "project": "tsconfig.build.json"
157
+ }
158
+ ]
159
+ ]
160
+ },
161
+ "codegenConfig": {
162
+ "name": "RNShieldFraudPluginSpec",
163
+ "type": "modules",
164
+ "jsSrcsDir": "src",
165
+ "android": {
166
+ "javaPackageName": "com.shieldfraudplugin"
167
+ }
168
+ }
169
+ }
@@ -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.59"
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
@@ -0,0 +1,87 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ /**
5
+ * TypeScript spec for the ShieldFraudPlugin Turbo Module.
6
+ * This file is used by React Native codegen to auto-generate
7
+ * native interface code for both iOS and Android.
8
+ */
9
+ export interface Spec extends TurboModule {
10
+ /**
11
+ * Initializes the ShieldFraud SDK with the provided configuration.
12
+ */
13
+ initShield(
14
+ siteID: string,
15
+ secretKey: string,
16
+ isOptimizedListener: boolean,
17
+ blockedDialog: Object | null,
18
+ logLevel: number,
19
+ environmentInfo: number,
20
+ /** Android-only: block screen recording while the SDK is active. Ignored on iOS. */
21
+ blockScreenRecording: boolean
22
+ ): Promise<void>;
23
+
24
+ /**
25
+ * Sets cross-platform metadata (name + version) on the SDK.
26
+ */
27
+ setCrossPlatformParameters(
28
+ crossPlatformName: string,
29
+ crossPlatformVersion: string
30
+ ): void;
31
+
32
+ /**
33
+ * Returns the current session ID synchronously.
34
+ */
35
+ getSessionId(): string;
36
+
37
+ /**
38
+ * Returns whether the SDK has been initialized synchronously.
39
+ */
40
+ isShieldInitialized(): boolean;
41
+
42
+ /**
43
+ * Registers a listener for the device-result-ready state event.
44
+ */
45
+ setDeviceResultStateListener(): void;
46
+
47
+ /**
48
+ * Sends custom attributes for a given screen name.
49
+ */
50
+ sendAttributes(screenName: string, data: Object): void;
51
+
52
+ /**
53
+ * Sends custom attributes for a given screen name with success/error callbacks.
54
+ */
55
+ sendAttributesWithCallback(
56
+ screenName: string,
57
+ data: Object,
58
+ successCallback: (result: boolean) => void,
59
+ errorCallback: (error: string) => void
60
+ ): void;
61
+
62
+ /**
63
+ * Retrieves the latest device result via success/error callbacks.
64
+ */
65
+ getLatestDeviceResult(
66
+ successCallback: (result: Object) => void,
67
+ errorCallback: (error: Object) => void
68
+ ): void;
69
+
70
+ /**
71
+ * Triggers a device signature computation for a given screen and returns
72
+ * the latest device result (or error) via callbacks once complete.
73
+ * Pass userId to associate the result with a specific user.
74
+ */
75
+ sendDeviceSignature(
76
+ screenName: string,
77
+ userId: string | null,
78
+ successCallback: (result: Object) => void,
79
+ errorCallback: (error: string) => void
80
+ ): void;
81
+
82
+ // Required by RCTEventEmitter for New Architecture compatibility
83
+ addListener(eventName: string): void;
84
+ removeListeners(count: number): void;
85
+ }
86
+
87
+ export default TurboModuleRegistry.getEnforcing<Spec>('ShieldFraudPlugin');