1- # Exhort JavaScript API <br />![ latest-no-snapshot] [ 0 ] ![ latest-snapshot] [ 1 ]
1+ # Trustify Dependency Analytics JavaScript Client <br />![ latest-no-snapshot] [ 0 ] ![ latest-snapshot] [ 1 ]
22
3- * Looking for the OpenAPI Spec? Try [ Exhort API Spec ] ( https://github.com/trustify-da /trustify-da-api-model )
4- * Looking for our Java API? Try [ Exhort Java API ] ( https://github.com/guacsec/exhort- java-api ) .
5- * Looking for our Backend implementation? Try [ Exhort ] ( https://github.com/guacsec/exhort ) .
3+ * Looking for the OpenAPI Spec? Try [ Trustify Dependency Analytics API ] ( https://github.com/guacsec /trustify-da-api-spec )
4+ * Looking for our Java API? Try [ Trustify Dependency Analytics Java Client ] ( https://github.com/guacsec/trustify-da- java-client ) .
5+ * Looking for our Backend implementation? Try [ Trustify Dependency Analytics ] ( https://github.com/guacsec/trustify-dependency-analytics ) .
66
77<h3 >Usage</h3 >
88<p >
99
10+ <strong >Prerequisites:</strong > The <code >TRUSTIFY_DA_BACKEND_URL</code > environment variable must be set to the URL of the Trustify Dependency Analytics backend service. You can set it as an environment variable or pass it in the options object (see <a href =" #customization " >Customization</a > section).
11+
1012<ul >
1113<li >
1214Use as ESM Module from an ESM module
@@ -15,24 +17,29 @@ Use as ESM Module from an ESM module
1517npm install @trustify-da/trustify-da-javascript-client
1618```
1719
20+ ``` shell
21+ # Set the mandatory backend URL
22+ export TRUSTIFY_DA_BACKEND_URL=https://trustify-da.example.com
23+ ```
24+
1825``` javascript
19- import exhort from ' @trustify-da/trustify-da-javascript-client'
26+ import client from ' @trustify-da/trustify-da-javascript-client'
2027import fs from ' node:fs'
2128
2229// Get stack analysis in JSON format
23- let stackAnalysis = await exhort .stackAnalysis (' /path/to/pom.xml' )
30+ let stackAnalysis = await client .stackAnalysis (' /path/to/pom.xml' )
2431// Get stack analysis in HTML format (string)
25- let stackAnalysisHtml = await exhort .stackAnalysis (' /path/to/pom.xml' , true )
32+ let stackAnalysisHtml = await client .stackAnalysis (' /path/to/pom.xml' , true )
2633// Get component analysis in JSON format
27- let componentAnalysis = await exhort .componentAnalysis (' /path/to/pom.xml' )
34+ let componentAnalysis = await client .componentAnalysis (' /path/to/pom.xml' )
2835// Get image analysis in JSON format
29- let imageAnalysis = await exhort .imageAnalysis ([' docker.io/library/node:18' ])
36+ let imageAnalysis = await client .imageAnalysis ([' docker.io/library/node:18' ])
3037// Get image analysis in HTML format (string)
31- let imageAnalysisHtml = await exhort .imageAnalysis ([' docker.io/library/node:18' ], true )
38+ let imageAnalysisHtml = await client .imageAnalysis ([' docker.io/library/node:18' ], true )
3239// Analyze multiple images
33- let multipleImagesAnalysis = await exhort .imageAnalysis ([' docker.io/library/node:18' , ' docker.io/library/python:3.9' ])
40+ let multipleImagesAnalysis = await client .imageAnalysis ([' docker.io/library/node:18' , ' docker.io/library/python:3.9' ])
3441// Specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
35- let imageAnalysisWithArch = await exhort .imageAnalysis ([' httpd:2.4.49^^amd64' ])
42+ let imageAnalysisWithArch = await client .imageAnalysis ([' httpd:2.4.49^^amd64' ])
3643```
3744</li >
3845</ul >
@@ -45,16 +52,16 @@ npm install @trustify-da/trustify-da-javascript-client
4552```
4653
4754``` javascript
48- async function loadExhort ()
55+ async function loadTrustifyDa ()
4956{
5057// dynamic import is the only way to import ESM module into commonJS module
51- const { default: exhort } = await import (' @trustify-da/trustify-da-javascript-client' );
52- return exhort
58+ const { default: client } = await import (' @trustify-da/trustify-da-javascript-client' );
59+ return client
5360}
54- const runExhort = (manifestPath ) => {
61+ const runTrustifyDa = (manifestPath ) => {
5562 return new Promise (async ( resolve , reject ) => {
5663 try {
57- let stackAnalysisReport = await (await loadExhort ()).stackAnalysis (manifestPath,false )
64+ let stackAnalysisReport = await (await loadTrustifyDa ()).stackAnalysis (manifestPath,false )
5865 resolve (stackAnalysisReport)
5966
6067 } catch (error)
@@ -64,7 +71,7 @@ const runExhort = (manifestPath) => {
6471 });
6572};
6673
67- runExhort (" ./path/to/manifest" ).then (resp => console .log (JSON .stringify (resp,null ,4 )))
74+ runTrustifyDa (" ./path/to/manifest" ).then (resp => console .log (JSON .stringify (resp,null ,4 )))
6875```
6976</li >
7077
@@ -297,17 +304,21 @@ All of the 5 above examples are valid for marking a package to be ignored
297304
298305<h3 >Customization</h3 >
299306<p >
300- There are 2 approaches for customizing <em >Exhort JavaScript API </em >. Whether you're using this API as a
307+ There are 2 approaches for customizing <em >Trustify Dependency Analytics JavaScript Client </em >. Whether you're using this API as a
301308<em >Global Module</em >, a <em >Remote Script</em >, or an <em >ESM Module</em >, you can use <em >Environment Variables</em >
302309for various customization.
303310
311+ <strong >Note:</strong > The <code >TRUSTIFY_DA_BACKEND_URL</code > environment variable is <strong >mandatory</strong > and must be set to the URL of the Trustify Dependency Analytics backend service. Without this variable, the API will throw an error.
312+
304313However, <em >ESM Module</em > users, can opt for customizing programmatically:
305314
306315``` javascript
307- import exhort from ' @trustify-da/trustify-da-javascript-client'
316+ import client from ' @trustify-da/trustify-da-javascript-client'
308317import fs from ' node:fs'
309318
310319let options = {
320+ // Mandatory: Backend URL for Trustify Dependency Analytics service
321+ ' TRUSTIFY_DA_BACKEND_URL' : ' https://api.trustify.dev' ,
311322 ' TRUSTIFY_DA_MVN_PATH' : ' /path/to/my/mvn' ,
312323 ' TRUSTIFY_DA_NPM_PATH' : ' /path/to/npm' ,
313324 ' TRUSTIFY_DA_PNPM_PATH' : ' /path/to/pnpm' ,
@@ -323,19 +334,19 @@ let options = {
323334}
324335
325336// Get stack analysis in JSON format ( all package managers, pom.xml is as an example here)
326- let stackAnalysis = await exhort .stackAnalysis (' /path/to/pom.xml' , false , options)
337+ let stackAnalysis = await client .stackAnalysis (' /path/to/pom.xml' , false , options)
327338// Get stack analysis in HTML format in string ( all package managers, pom.xml is as an example here)
328- let stackAnalysisHtml = await exhort .stackAnalysis (' /path/to/pom.xml' , true , options)
339+ let stackAnalysisHtml = await client .stackAnalysis (' /path/to/pom.xml' , true , options)
329340
330341// Get component analysis in JSON format
331- let componentAnalysis = await exhort .componentAnalysis (' /path/to/pom.xml' , options)
342+ let componentAnalysis = await client .componentAnalysis (' /path/to/pom.xml' , options)
332343
333344// Get image analysis in JSON format
334- let imageAnalysis = await exhort .imageAnalysis ([' docker.io/library/node:18' ], false , options)
345+ let imageAnalysis = await client .imageAnalysis ([' docker.io/library/node:18' ], false , options)
335346// Get image analysis in HTML format in string
336- let imageAnalysisHtml = await exhort .imageAnalysis ([' docker.io/library/node:18' ], true , options)
347+ let imageAnalysisHtml = await client .imageAnalysis ([' docker.io/library/node:18' ], true , options)
337348// Specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
338- let imageAnalysisWithArch = await exhort .imageAnalysis ([' httpd:2.4.49^^amd64' ], false , options)
349+ let imageAnalysisWithArch = await client .imageAnalysis ([' httpd:2.4.49^^amd64' ], false , options)
339350```
340351 ** _ Environment variables takes precedence._ **
341352</p >
0 commit comments