npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mitre/emass_client

v3.12.0

Published

OpenAPI client for @mitre/emass_client

Downloads

7,960

Readme

eMASS API v3.12 Specification

The @mitre/[email protected] is a TypeScript/JavaScript client that utilizes axios that implements the Enterprise Mission Assurance Support Service (eMASS) Representational State Transfer (REST) Application Programming Interface (API) specifications

The @mitre/[email protected] npm package can be used in the following environments:

  • Node.js
  • Webpack
  • Browserify

Language level

  • ES5 - you must have a Promises/A+ library installed
  • ES6

Module system

  • CommonJS
  • ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via package.json. (Reference - archive)

The latest publishing instruction can be found in the Typescript handbook

Building

To build and compile the typescript sources to javascript use:

npm install
npm run build

Publishing

After building the package (above step) login into the NPM registry ( account required )

Login with the following command:

npm login

To test that the login was successful, use command npm whoami, the username for the account is displayed.

Publishing the NPM package is accomplished by executing the following command:

npm publish

After the publish is done without any error, visit the account used to published in the NPM registry, and verify that the package is there.

Unpublish NPM

For detailed information on unpublishing an NPM packages visit the npm-unpuplish docs

npm unpublish [<@scope>/]<pkg>[@<version>]

References the npm Unpublish Policy for detail information and restrictions related to unpublishing npm pakages.

Consuming

navigate to the folder of your consuming project and run one of the following commands.

published:

npm install @mitre/[email protected] --save

unPublished (not recommended):

npm install PATH_TO_GENERATED_PACKAGE --save

Getting Started

Before accessing any of the endpoints provided by the @mitre/emass_client, we need to configure common axios settings.

Axios Configuration

All calls utilizing the @mitre/[email protected] need to initialize axios as follows:

// Load the necessary modules
import * as fs from 'fs';
import * as https from 'https';
import { Configuration } from "@mitre/emass_client/dist/configuration"
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from '@mitre/emass_client/node_modules/axios';

// Initialize the configuration interface. The apikey is initialized via axios default headers.
const configuration = new Configuration({
  basePath: 'https://emass-url-instances.com',
});

// Initialize the axios request configuration
const axiosRequestConfig: AxiosRequestConfig = {
  httpsAgent: new https.Agent({
    keepAlive: true,
    rejectUnauthorized: false,
    key: fs.readFileSync("path/to/the/key.pem"),
    cert: fs.readFileSync("path/to/the/client.pem"),
    passphrase: "certificate passphrase",
    port: 443,
  })
}

// Create an axios instances
const axiosInstances: AxiosInstance =  globalAxios.create(axiosRequestConfig);
// Configure the necessary keys (api-key and user-uid)
axiosInstances.defaults.headers.common = {
  "api-key": "the-proper-api-key-value",
  "user-uid": 'the.use.id.information'
};

Documentation for API Endpoints Examples

Test Connection endpoint

// Load the TestApi module
import { TestApi } from '@mitre/emass_client/dist/api';

// Create and initialize a TestApi instances (references Axios Configuration for proper parameters configurations)
const testApi = new TestApi(configuration, configuration.basePath, axiosInstances);

// Invoke the endpoint 
testApi.testConnection().then((response:any) => {
  console.log("API called successfully. Returned data: " + JSON.stringify(response.data, null,2));
}).catch((error:any) => console.error(JSON.stringify(error.response.data,null,2)));

Artifacts Export endpoint

This example uses the colorize module to color format the output to the command line.

// Load the TestApi module
import { ArtifactsExportApi } from '@mitre/emass_client/dist/api';
import colorize from 'json-colorizer';

// Create and initialize a ArtifactsExportApi instances (references Axios Configuration for proper parameters configurations)
const exportArtifacts = new ArtifactsExportApi(configuration, configuration.basePath, axiosInstances);

// Invoke the endpoint 
exportArtifacts.getSystemArtifactsExport(34, "artifact.txt").then((response:any) => {
  console.log(colorize(JSON.stringify(response.data, null,2)));
}).catch((error:any) => console.error(colorize(JSON.stringify(error.response.data,null,2))));