Trustify Dependency Analytics JavaScript Client
Usage
Prerequisites: Supply the Trustify Dependency Analytics backend URL through options.TRUSTIFY_DA_BACKEND_URL or the TRUSTIFY_DA_BACKEND_URL environment variable (see Customization). Programmatic options take precedence over environment variables.
-
Use as ESM Module from an ESM module
npm install @trustify-da/trustify-da-javascript-client
# Set the mandatory backend URL
export TRUSTIFY_DA_BACKEND_URL=https://trustify-da.example.com
import client from '@trustify-da/trustify-da-javascript-client'
import fs from 'node:fs'
// Get stack analysis in JSON format
let stackAnalysis = await client.stackAnalysis('/path/to/pom.xml')
// Get stack analysis in HTML format (string)
let stackAnalysisHtml = await client.stackAnalysis('/path/to/pom.xml', true)
// Get component analysis in JSON format
let componentAnalysis = await client.componentAnalysis('/path/to/pom.xml')
// For monorepos, pass workspace root so the client finds the lock file
let monorepoOpts = { workspaceDir: '/path/to/workspace-root' }
let stackAnalysisMonorepo = await client.stackAnalysis('/path/to/package.json', false, monorepoOpts)
// Batch analysis for entire workspace (Cargo or JS/TS); optional parallel SBOM generation
let batchReport = await client.stackAnalysisBatch('/path/to/workspace-root', false, { batchConcurrency: 10 })
// Get image analysis in JSON format
let imageAnalysis = await client.imageAnalysis(['docker.io/library/node:18'])
// Get image analysis in HTML format (string)
let imageAnalysisHtml = await client.imageAnalysis(['docker.io/library/node:18'], true)
// Analyze multiple images
let multipleImagesAnalysis = await client.imageAnalysis(['docker.io/library/node:18', 'docker.io/library/python:3.9'])
// Specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'])
License Detection
The client automatically detects your project's license with intelligent fallback:
- Manifest-first: For ecosystems with license support (Maven, JavaScript, Rust Cargo), reads from manifest file (
pom.xml, package.json, Cargo.toml)
- LICENSE file fallback: If no license in manifest, or for ecosystems without license support (Gradle, Go, Python), automatically reads from
LICENSE, LICENSE.md, or LICENSE.txt
- SBOM integration: Detected licenses are included in generated SBOMs for all ecosystems
- SPDX support: Automatically detects common licenses (Apache-2.0, MIT, GPL, BSD) from LICENSE file content
See License Resolution and Compliance for detailed documentation.
-
Use as ESM Module from Common-JS module
npm install @trustify-da/trustify-da-javascript-client
async function loadTrustifyDa()
{
// dynamic import is the only way to import ESM module into commonJS module
const { default: client } = await import('@trustify-da/trustify-da-javascript-client');
return client
}
const runTrustifyDa = (manifestPath) => {
return new Promise(async ( resolve, reject) => {
try {
let stackAnalysisReport = await (await loadTrustifyDa()).stackAnalysis(manifestPath,false)
resolve(stackAnalysisReport)
} catch (error)
{
reject(error)
}
});
};
runTrustifyDa("./path/to/manifest").then(resp => console.log(JSON.stringify(resp,null,4)))
-
Use as CLI Script
Click for help menu
$ npx @trustify-da/trustify-da-javascript-client help
Usage: trustify-da-javascript-client {component|stack|stack-batch|image|validate-token|license|sbom|remediate}
Commands:
trustify-da-javascript-client stack </path/to/manifest> [--workspace-dir <path>] [--html|--summary] produce stack report for manifest path
trustify-da-javascript-client stack-batch </path/to/workspace-root> [--html|--summary] produce stack report for all packages/crates in workspace
trustify-da-javascript-client component <path/to/manifest> [--workspace-dir <path>] produce component report for a manifest type and content
trustify-da-javascript-client image <image-refs..> [--html|--summary] produce image analysis report for OCI image references
trustify-da-javascript-client validate-token <token-provider> [--token-value <value>] validate input token if authentic and authorized
trustify-da-javascript-client license </path/to/manifest> display project license information from manifest and LICENSE file in JSON format
trustify-da-javascript-client sbom </path/to/manifest> [--output <file>] [--name <name>] generate a CycloneDX SBOM from a manifest file
trustify-da-javascript-client remediate <path> [--dry-run] [--providers <list>] [--sources <list>] [--group-by <strategy>] [--exclude <purl>...] scan and apply vulnerability remediations
Options:
--help Show help [boolean]
# get stack analysis in json format
$ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml
# get stack analysis in json format (summary only)
$ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --summary
# get stack analysis in html format format
$ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --html
# get stack analysis for monorepo (lock file at workspace root)
$ npx @trustify-da/trustify-da-javascript-client stack /path/to/package.json --workspace-dir /path/to/workspace-root
# get component analysis
$ npx @trustify-da/trustify-da-javascript-client component /path/to/pom.xml
# get component analysis for monorepo
$ npx @trustify-da/trustify-da-javascript-client component /path/to/package.json -w /path/to/workspace-root
# batch stack analysis for entire workspace (Cargo or JS/TS)
$ npx @trustify-da/trustify-da-javascript-client stack-batch /path/to/workspace-root
# optional: extra discovery excludes (merged with defaults); repeat --ignore or use TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE
$ npx @trustify-da/trustify-da-javascript-client stack-batch /path/to/workspace-root --ignore '**/fixtures/**'
# get image analysis in json format
$ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18
# get image analysis in json format (summary only)
# Note: summary returns an object with imageRef as key
$ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18 --summary
# get image analysis in html format
$ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18 --html
# analyze multiple images
$ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18 docker.io/library/python:3.9
# specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
$ npx @trustify-da/trustify-da-javascript-client image httpd:2.4.49^^amd64
# get project license information
$ npx @trustify-da/trustify-da-javascript-client license /path/to/package.json
# generate a CycloneDX SBOM from a manifest file
$ npx @trustify-da/trustify-da-javascript-client sbom /path/to/pom.xml
# generate SBOM and write to a file
$ npx @trustify-da/trustify-da-javascript-client sbom /path/to/pom.xml --output sbom.json
# generate SBOM with explicit root component name (for manifests without a name field)
$ npx @trustify-da/trustify-da-javascript-client sbom /path/to/package.json --name @myorg/mypackage
# scan a manifest and apply vulnerability remediations
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml
# preview remediations without modifying files
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --dry-run
# scan a directory for all supported manifests
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/project/
# filter by vulnerability providers (order determines priority)
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --providers provider1,provider2
# group report output by bundle instead of per-dependency
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --dry-run --group-by bundle
# exclude specific dependencies or groups from remediation (repeat --exclude per entry)
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --exclude pkg:maven/com.example/legacy-lib
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --exclude 'pkg:maven/com.example/*' --exclude 'pkg:npm/**'
-
Use as Global Binary
Installing globally puts the trustify-da binary on your PATH:
npm install --global @trustify-da/trustify-da-javascript-client
# get stack analysis in json format
$ trustify-da stack /path/to/pom.xml
# get stack analysis in json format (summary only)
$ trustify-da stack /path/to/pom.xml --summary
# get stack analysis in html format format
$ trustify-da stack /path/to/pom.xml --html
# get stack analysis for monorepo (lock file at workspace root)
$ trustify-da stack /path/to/package.json --workspace-dir /path/to/workspace-root
# get component analysis
$ trustify-da component /path/to/pom.xml
# get component analysis for monorepo
$ trustify-da component /path/to/package.json -w /path/to/workspace-root
# batch stack analysis for entire workspace
$ trustify-da stack-batch /path/to/workspace-root
# with extra discovery excludes
$ trustify-da stack-batch /path/to/workspace-root -i '**/vendor/**'
# get image analysis in json format
$ trustify-da image docker.io/library/node:18
# get image analysis in json format (summary only)
# Note: summary returns an object with imageRef as key
$ trustify-da image docker.io/library/node:18 --summary
# get image analysis in html format
$ trustify-da image docker.io/library/node:18 --html
# analyze multiple images
$ trustify-da image docker.io/library/node:18 docker.io/library/python:3.9
# specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
$ trustify-da image httpd:2.4.49^^amd64
# get project license information
$ trustify-da license /path/to/package.json
# generate a CycloneDX SBOM from a manifest file
$ trustify-da sbom /path/to/pom.xml
# generate SBOM and write to a file
$ trustify-da sbom /path/to/pom.xml --output sbom.json
# generate SBOM with explicit root component name (for manifests without a name field)
$ trustify-da-javascript-client sbom /path/to/package.json --name @myorg/mypackage
# scan a manifest and apply vulnerability remediations
$ trustify-da remediate /path/to/pom.xml
# preview remediations without modifying files
$ trustify-da remediate /path/to/pom.xml --dry-run
# scan a directory for all supported manifests
$ trustify-da remediate /path/to/project/
# filter by vulnerability providers (order determines priority)
$ trustify-da remediate /path/to/pom.xml --providers provider1,provider2
# group report output by bundle instead of per-dependency
$ trustify-da remediate /path/to/pom.xml --dry-run --group-by bundle
# exclude specific dependencies or groups from remediation (repeat --exclude per entry)
$ trustify-da remediate /path/to/pom.xml --exclude pkg:maven/com.example/legacy-lib
$ trustify-da remediate /path/to/pom.xml --exclude 'pkg:maven/com.example/*' --exclude 'pkg:npm/**'
Supported Ecosystems
Dockerfile Analysis Prerequisites
OCI image and Dockerfile/Containerfile analysis require the following external tools to be installed and available on your PATH:
- Syft — generates the image SBOM.
- skopeo — resolves the image digest and manifest from the registry.
Dockerfile analysis is not supported on Windows, because skopeo provides no native Windows binary.
License Detection
The client automatically detects your project's license with intelligent fallback: