JavaScript SDK

The Deep Security JavaScript SDK consists of a JavaScript library that you can use to develop JavaScript client programs that execute on the NodeJS runtime. The SDK simplifies the development of JavaScript clients that interact with Deep Security API endpoints.

If you prefer, your JavaScript clients can interact with the API endpoints directly using the NodeJS HTTP core module, or using other 3rd-party libraries such as Request, SuperAgent, or the promise-based axios module. If you are not a programmer, or you want to quickly explore API endpoints, you can use the API directly via tools such as Postman and curl.

To provide you with the JavaScript SDK as early as possible, we are temporarily releasing it as a download that you manually add to your local package repository. We will update this page when the SDK is available on a public repository.

Supported software

The JavaScript SDK supports ECMAScript 2015 Language (ES6) with promises.

You should use the latest LTS version of NodeJS. We do not support versions of NodeJS for which LTS has ended.

Get set up to use the JavaScript SDK

Prerequisites

Install the following software:

We recommend Yarn as the package manager for installing and upgrading the JavaScript SDK in your local package repository. Yarn is specifically effective for unlinking projects from locally-installed packages. Of course, if you are accustomed to using a different package manager you can use that.

Download and install the JavaScript SDK

Download the SDK and set it up as a JavaScript runtime dependency for your NodeJS JavaScript project. (Make sure that you download the SDK that is compatible with your Deep Security Manager.)

  1. Download the JavaScript SDK.

    Download SDK

  2. Extract the dsm-js-sdk.zip file.

  3. Open Command Line or Terminal and change the current directory to the directory of the extracted contents.
  4. Enter the following command to install dependencies:

    yarn install

  5. Enter the following command to create a symbolic link from the repository to the package in the SDK directory:

    yarn link
    You should see output that is similar to the following example:
    yarn link v1.6.0
    success Registered "@trendmicro/deepsecurity".
    info You can now run yarn link "@trendmicro/deepsecurity" in the projects where you want to use this package and it will be used instead.
    Done in 0.05s.

Trend Micro Deep Security SDKs are distributed under the Apache 2.0 license.

Install a JavaScript IDE

You can use any JavaScript IDE to develop for the Deep Security API. If you need to install one, we recommend using Visual Studio Code. It is free, lightweight, and requires minimal configuration to run the JavaScript SDK.

Windows

Download and install Visual Studio Code.

Linux

Follow the Visual Studio Code installation instructions for your Linux distribution.

Add the SDK to a workspace in Visual Studio Code

Follow the procedure below to create a NodeJS project that can run the code examples in the Automation Center guides.

  1. Create a folder for your NodeJS project.
  2. In the NodeJS project folder you created, open Command Line or Terminal.
  3. Enter the following command to create a symbolic link from your NodeJS project to the @trendmicro/deepsecurity package:
    yarn link "@trendmicro/deepsecurity"
    You should see output that is similar to the following example:
    yarn link v1.6.0
    success Using linked package for "@trendmicro/deepsecurity".
    Done in 0.06s.
    For more information about the yarn unlink command, see the Yarn unlink documentation.
  4. Open Visual Studio Code.
  5. Click File > Add folder to workspace and select the NodeJS project folder.
  6. Click File > Save Workspace as and save your project.
    You can save the project workspace in any location; it does not have to be in the NodeJS project folder.

Next Steps

  • To get familiar with how to use the SDK with the Deep Security API, see the Send Your First Request Using the API guide.
  • If you are already familiar with using an API or have specific tasks that you want to use the SDK for, see Run the Code Examples to get started with the task-based examples in other Automation Center guides.
You can add the code examples from any of the other Automation Center guides to the project you created above.

Upgrade the JavaScript SDK

If your project is linked to the @trendmicro/deepsecurity package and you want to use a newer release of the package, remove the links that you set up for the previous version. After you remove the links, you can install the newer package and set up links as you did for the previous package.

  1. Open Command Line or Terminal and change the current directory to your project directory.
  2. Enter the following command:
    yarn unlink "@trendmicro/deepsecurity"
    You should see output that is similar to the following example:
    yarn unlink v1.6.0
    success Removed linked package "@trendmicro/deepsecurity".
    info You will need to run `yarn` to re-install the package that was linked.
    Done in 0.12s.
  3. Change the current directory to the directory where you extracted the JavaScript SDK archive.
  4. Enter the following command:
    yarn unlink
    You should see output that is similar to the following example:
    yarn unlink v1.6.0
    success Unregistered "@trendmicro/deepsecurity".
    info You can now run `yarn unlink "@trendmicro/deepsecurity"` in the projects where you no longer want to use this package.Done in 0.05s.
  5. To upgrade the package, use the steps in the previous sections to [download and install the SDK](#install) and link your project to the package.

For more information about the yarn unlink command, see the Yarn unlink documentation.