To ensure compatibility with this script, install Node.js version 16.0.0 or higher (but avoid the latest experimental versions to minimize issues). Here’s a detailed guide for downloading and installing the prerequisites on a Linux machine using Node.js:
Prerequisites
-
Node.js: Ensure Node.js and
npm(Node Package Manager) are installed on your Linux box.sudo apt updatesudo apt install nodejs npm -y -
Required Libraries: Use Node.js to handle HTTP requests (
node-fetch) and HMAC signing (built-incryptomodule).
Node.js Script
Here’s an equivalent Node.js script that mimics your Google Apps Script functionality, including HMAC generation and API requests.
-
Create a New Directory for Your Project:
mkdir virtru-api-script cd virtru-api-script -
Initialize a New Node.js Project:
npm init -y -
Install Dependencies:
-
Install
node-fetchfor handling HTTP requests.
npm install node-fetch@2 install axios dotenv -
-
Environment Variables:
Create a.envfile in the project root and add your API token details:API_TOKEN=<your_api_token> API_TOKEN_ID=<your_api_token_id>Continue to install the JavaScript Audit Export Tool