react-native-akamaibmp
Prerequisites
Akamai BMP native module requires the following minimum versions for Android and iOS
- Android API 15 (Android 4.0.4) or above
- iOS version 8.0 or above
- React Native 0.41 or above
Installation
$ npm install react-native-akamaibmp --save
Mostly automatic installation
$ react-native link react-native-akamaibmp
iOS
Update Build Settings: Under the Build Settings
tab, go to Linking
and then under Other Linker Flags
make sure -ObjC
linker option is set.
Android
Open up android/app/src/main/java/[...]/MainApplication.java
- Update
new RNAkamaibmpPackage()
tonew RNAkamaibmpPackage(MainApplication.this)
in the list returned by thegetPackages()
method
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-akamaibmp
➜ios
and addRNAkamaibmp.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNAkamaibmp.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.akamai.react.RNAkamaibmpPackage;
to the imports at the top of the file - Add
new RNAkamaibmpPackage(MainApplication.this)
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:
include ':react-native-akamaibmp'
project(':react-native-akamaibmp').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-akamaibmp/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
compile project(':react-native-akamaibmp')
Integration
The BMP SDK collects behavioral data while the user is interacting with the application. The behavioral data, also known as sensor data, includes the device characteristics, device orientation, accelerometer data, touch events, etc. Akamai BMP SDK provides a simple API to detect bot activities and defend against malicious bot and account takeover.
Import AkamaiBMP module
Once the native module has been added to your project, you can import AkamaiBMP native module in your JavaScript file index.ios.js
, index.android.js
or App.js
as shown below:
;const AkamaiBMP = NativeModules;
Collect Sensor Data
The BMP SDK’s sensor data contains serialized user behavioral data and device information.
However, the device information doesn’t contain any information that will identify this device
uniquely.
You can retrieve sensor data from the module by calling the AkamaiBMP.getSensorData
method. Sensor data should be sent in the REST API request as detailed below.
// Get the BMP sensor dataAkamaiBMP;
Important: Call the getSensorData method only on REST API requests to URLs that will be configured for protection in Bot Manager Premier Mobile. Do not call the getSensorData method for non-protected URLs.
Send Sensor Data
After the sensor data is retrieved from the module, it should be sent in X-acf-sensor-data
HTTP header as part your applications REST API (HTTP/S) request. We recommend using
HTTPS for the REST API request to ensure the integrity of sensor data and prevent
eavesdropping. Send the X-acf-sensor-data
header ONLY on HTTP requests to URLs configured for protection in Bot Manager Premier Mobile. Do not send the header and sensor data on every HTTP request the app makes.
AkamaiBMP;
Evaluate the Akamai Edge Response
Akamai edge server inspects sensor data and takes the predefined action on the request if the request is classified as BOT, otherwise Akamai sends the request to the origin server.
When the app makes a request, Akamai evaluates the sensor data at the edge. If the request is
classified as human, the traffic continues to the origin server and the response is sent back to
the app. If the request is BOT, there are two possible actions, monitor
and deny
.
- If the action is
monitor
, the traffic is allowed and the request is sent to the origin server. - If the action is
deny
, a403
HTTP response is sent back to the app, and the app should handle the situation and take appropriate action.
Logging
Akamai BMP plugin logs some messages at all log levels to verify the SDK initialization. These messages are helpful in identifying any integration issue and ensure the plugin is initialized successfully.
In addition to these messages, the plugin logs additional messages at info
, warn
and error
levels, to verify and debug that the SDK is working correctly. The default log level for the plugin is set to log warning and error messages only. This behavior can be changed by calling
setLogLevel
API.
To set the log level, call AkamaiBMP.setLogLevel
API with one of the log levels specified
below:
AkamaiBMP.logLevelInfo
- Print all messagesAkamaiBMP.logLevelWarn
- (Default) Print warning and error messages onlyAkamaiBMP.logLevelError
- Print error messages onlyAkamaiBMP.logLevelNone
- Turn off all log messages from the SDK
For example, to see all messages:
// Set the log level to InfoAkamaiBMP;
For further information please refer Akamai BMP SDK Documentation