evident
The javascript SDK for the Evident Security Platform for AWS.
install
npm install --save evident
credentials
API keys are stored in environment variables ESP_ACCESS_KEY_ID
and ESP_SECRET_ACCESS_KEY
. If the environment variables are not set every callback will return early with an error specifying missing credentials.
export ESP_ACCESS_KEY_ID=PxfX+2+Ll4ZJk...export ESP_SECRET_ACCESS_KEY=9jtmPHfVA23BM...
Create new credentials in the API Keys section of your ESP settings.
new
To hardcode the credentials for use in AWS Lambda edit the esp_sdk.js lines 1 and 2.
// esp_sdk.js
var PUBKEY = process.env.ESP_ACCESS_KEY_ID || 'PUT YOUR KEY HERE'
var SECKEY = process.env.ESP_SECRET_ACCESS_KEY || 'AND HERE.'
include the code
// include the sdk by requiring the modulevar sdk =
error first callback model
The SDK utilizes the "Error First" callback model that is standard to NodeJS. If the first argument in the callback is null, then the request was successful and any returned data will be found in the second argument.
create the SDK object
// create an sdk object that can make API callsvar esp =
The object returned by the require
statement is a function that returns a closure that manages the method calls, isolates special parameters, and maintains associated callbacks during pagination calls.
Do not make the method calls on the sdk
object
// DO NOT DO THISsdk // INVALID CODE
Instead create more than one instance of the SDK object by running the function again.
// DO THIS // VALID CODE// OR THISvar req = req var req_b = req_b
optional pass the SDK object an include parameter at construction
// pass the included to the sdk constructorvar esp = esp
Some requests call for extra parameters, you pass those to the SDK constructor function for that request.
next([callback])
pagination var esp = var all_alerts = esp
Some requests will have multiple pages of data. In the callback call the anotherpage()
method of the SDK instance. It will return true
if another page is available.
Call next()
and the latest callback function passed to the SDK instance will be automatically invoked with the path of the next page in the series as the path.
You can also pass an alternative callback to the next()
function.
var esp = var all_alerts = esp
methods
var sdk = // with included parameters