1.11.7 • Published 4 years ago

@securenative/sdk v1.11.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

SecureNative performs user monitoring by analyzing user interactions with your application and various factors such as network, devices, locations and access patterns to stop and prevent account takeover attacks.

Install the SDK

Navigate to your application project folder and enter:

npm i @securenative/sdk

Verify that @securenative/sdk appears in your package to your package.json.

Initialize the SDK

To get your API KEY, login to your SecureNative account and go to project settings page:

import { SecureNative, EventTypes } from "@securenative/sdk";
or;
const { SecureNative, EventTypes } = require("@securenative/sdk"); // if your using ES5

Option 1: Initialize via Config file

SecureNative can automatically load your config from securenative.json that you can add to your application folder.

cat > securenative.json <<EOF
{
  "SECURENATIVE_APP_NAME": "YOUR_APPLICATION_NAME",
  "SECURENATIVE_API_KEY": "YOUR_API_KEY"
}
EOF

Option 2: Initialize via config options

SecureNative.init({ apiKey: "Your API_KEY" });

Getting SecureNative instance

Once initialized, sdk will create a singleton instance which you can get:

const secureNative = SecureNative.getInstance();

Tracking events

Once the SDK has been initialized, tracking requests sent through the SDK instance. Make sure you build event with the EventBuilder:

import { SecureNative, EventTypes, contextFromRequest } from "@securenative/sdk";

secureNative.track({
  event: EventTypes.LOG_IN,
  userId: '1234',
  userTraits: {
    name: 'Your Name',
    email: 'name@gmail.com',
    phone: '+1234567890'
  },
  context: contextFromRequest(req)
});

If you don't have acess to request object you can construct the context manually:

secureNative.track({
  event: EventTypes.LOG_IN,
  userId: '1234',
  userTraits: {
    name: 'Your Name',
    email: 'name@gmail.com',
    phone: '+1234567890'
  },
  context: {
    ip: '10.0.0.0',
    clientToken: 'Token from client',
    headers: {
      "user-agent": 'Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405"'
    }
  }
});

Verify events

  const verifyResult = await secureNative.verify({
    event: EventTypes.LOG_IN,
    userId: '1234',
    userTraits: {
      name: 'Your Name',
      email: 'name@gmail.com',
      phone: '+1234567890'
    },
    context: contextFromRequest(req)
  })

  verifyResult.riskLevel // Low, Medium, High
  verifyResult.score  // Risk score: 0 -1 (0 - Very Low, 1 - Very High)
  verifyResult.triggers // ["TOR", "New IP", "New City"]
}

Configuration

OptionTypeOptionalDefault ValueDescription
SECURENATIVE_API_KEYstringfalsenoneSecureNative api key
SECURENATIVE_APP_NAMEstringfalsepackage.jsonName of application source
SECURENATIVE_API_URLstringtruehttps://api.securenative.com/v1/collectorDefault api base address
SECURENATIVE_INTERVALnumbertrue1000Default interval for SDK to try to persist events
SECURENATIVE_MAX_EVENTSnumbertrue1000Max in-memory events queue
SECURENATIVE_TIMEOUTnumbertrue1500API call timeout in ms
SECURENATIVE_AUTO_SENDBooleantruetrueShould api auto send the events
SECURENATIVE_DISABLEBooleantruetrueAllow to disable agent functionality
SECURENATIVE_LOG_LEVELstringtruefatalDisplays debug info to stdout

Compatibility

This agent is compatible with Node.js 8 and higher.

For other compatibility related information, please visit the compatibility page.

Documentation

For more details, please visit documentation page, available on docs.securenative.com.

1.11.7

4 years ago

1.11.6

4 years ago

1.11.5

4 years ago

1.11.4

4 years ago

1.11.3

4 years ago

1.11.2

4 years ago

1.11.1

4 years ago

1.11.0

4 years ago

1.10.0

4 years ago

1.9.17

4 years ago

1.9.16

4 years ago

1.9.15

4 years ago

1.9.13

4 years ago

1.9.12

4 years ago

1.9.11

4 years ago

1.9.10

4 years ago

1.9.9

4 years ago

1.9.8

4 years ago

1.9.7

4 years ago

1.9.6

4 years ago

1.9.5

4 years ago

1.9.4

4 years ago

1.9.3

4 years ago

1.9.2

4 years ago

1.9.1

4 years ago

1.0.0

4 years ago

1.9.0

4 years ago

1.8.7

4 years ago

1.8.6

4 years ago

1.8.5

4 years ago

1.8.4

4 years ago

1.8.3

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.7.9

4 years ago

1.7.8

4 years ago

1.7.7

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.7.3

4 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago