0.3.0 • Published 12 months ago

@timcrider/aquasec-client v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Aqua Security REST Client

@timcrider/aquasec-client is a Node.js simple REST client for the Aqua Security API. This client is not intended to be a complete implementation of the Aqua API, but rather a simple way to interact with the API using Node.js. This client bundles several useful features such as authentication, credentials management, and some quality of life improvements.

Check the official Aquasec documentation for specific endpoint information.

Usage

Installation

$ npm i @timcrider/aqua-client

Connecting to Aqua

// Load the client and credentials classes
const {AquaClient, Credentials} = require('@timcrider/aqua-client');

// Create Aqua rest client using the Aqua instance URL
const client = new AquaClient('<Aqua URL>');

// Create authentication credentials object
const auth = new Credentials().store({
  id: '<Aqua User>',
  password: '<Aqua Password>'
});

// Login to Aqua and store the token in the client.
// This method also returns the token for use in other clients
await client.authenticate(auth);

// List all registries
let registries = await client.get('/api/v1/registries');
console.log(JSON.stringify(registries, null, 2));

The Credentials Object

The credentials object does not keep your secrets completely safe. The purpose of this object is to limit the exposure of the credentials at rest during the aqua client lifecycle.

    /* String creds */
    let strCreds = new Credentials().store("this is a secret");

    // Credentials {
    //   _hasData: true,
    //   _algorithm: 'aes-256-cbc',
    //   _encrypted: '<some hash>',
    //   _env: { id: 'AQUA_ID', password: 'AQUA_PASSWORD' }
    // }
    console.log(strCreds);

    // strCreds is this is a secret
    console.log(`strCreds is ${strCreds.fetch()}`);


    /* Object creds */
    let objCreds = new Credentials().store({foo: 'bar'});

    // Credentials {
    //   _hasData: true,
    //   _algorithm: 'aes-256-cbc',
    //   _encrypted: '<some hash>',
    //   _env: { id: 'AQUA_ID', password: 'AQUA_PASSWORD' }
    // }
    console.log(objCreds);

    // objCreds is {
    //   "foo": "bar"
    // }
    console.log(`objCreds is ${JSON.stringify(objCreds.fetch(), null, 2)}`);

    /* Store credentials using environment variables */
    process.env.AQUA_ID = "foo";
    process.env.AQUA_PASSWORD = "bar"
    let envCreds = new Credentials().storeEnv();

    // Credentials {
    //   _hasData: true,
    //   _algorithm: 'aes-256-cbc',
    //   _encrypted: '<some hash>',
    //   _env: { id: 'AQUA_ID', password: 'AQUA_PASSWORD' }
    // }
    console.log(envCreds);

    // envCreds is {
    //  "id": "foo",
    //  "password": "bar"
    // }
    console.log(`envCreds is ${JSON.stringify(envCreds.fetch(), null, 2)}`);

Environment Variables

VariableDescriptionUsed By
AQUA_IDAqua usernameCredentials
AQUA_PASSWORDAqua passwordCredentials
AQUA_URLAqua instance URLAquaClient

Development

VSCode DevContainer

Visual Studio Code DevContainers are supported. Simply open the project in VSCode and select the "Reopen in Container" option. This will build the container and open the project in the container.

Uses Native Node Testing Framework

This project uses the native Node.js testing framework. To run the tests, use the following command:

$ npm run test

Contributing

Contributions are welcome! Please submit a pull request with your changes.


Disclaimer: This product is not associated with Aqua Security. It is a personal project that I am sharing with the community. I am not responsible for any damages that may occur from the use of this software. Please use at your own risk.

0.3.0

12 months ago

0.2.8

12 months ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago