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.
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.)
-
Download the JavaScript SDK.
-
Extract the dsm-js-sdk.zip file.
- Open Command Line or Terminal and change the current directory to the directory of the extracted contents.
-
Enter the following command to install dependencies:
yarn install
-
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.
- Create a folder for your NodeJS project.
- In the NodeJS project folder you created, open Command Line or Terminal.
- 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 theyarn unlink
command, see the Yarn unlink documentation. - Open Visual Studio Code.
- Click File > Add folder to workspace and select the NodeJS project folder.
- 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.
- Open Command Line or Terminal and change the current directory to your project directory.
-
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
</span>yarn<span class="pl-pds">
to re-install the package that was linked. Done in 0.12s. -
Change the current directory to the directory where you extracted the JavaScript SDK archive.
-
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
</span>yarn unlink <span class="pl-pds">"</span>@trendmicro/deepsecurity<span class="pl-pds">"</span><span class="pl-pds">
in the projects where you no longer want to use this package.Done in 0.05s. -
To upgrade the package, use the steps in the previous sections to download and install the SDK and link your project to the package.
For more information about the yarn unlink
command, see the Yarn unlink documentation.