npm

Need private packages and team management tools?Check out npm Orgs. »

react-native-akamaibmp

2.2.2 • Public • Published

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() to new RNAkamaibmpPackage(MainApplication.this) in the list returned by the getPackages() method

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-akamaibmpios and add RNAkamaibmp.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNAkamaibmp.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. 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 the getPackages() method
  1. 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')
  1. 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:

import { NativeModules } from 'react-native';
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 data
AkamaiBMP.getSensorData((sd) => {
});

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.getSensorData((sd) => {
    // send the sensor data in the API request
});

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, a 403 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 messages
  • AkamaiBMP.logLevelWarn - (Default)​ Print warning and error messages only
  • AkamaiBMP.logLevelError - Print error messages only
  • AkamaiBMP.logLevelNone - Turn off all log messages from the SDK

For example, to see all messages:

// Set the log level to Info
AkamaiBMP.setLogLevel(AkamaiBMP.logLevelInfo);

For further information please refer Akamai BMP SDK Documentation

install

npm i react-native-akamaibmp

Downloadsweekly downloads

16

version

2.2.2

license

ISC

last publish

collaborators

  • avatar
Report a vulnerability