1.0.2 • Published 3 months ago

lockerpm v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

Locker Secret NodeJS SDK


The Locker Secret NodeJS SDK provides convenient access to the Locker Secret API from applications written in the JavaScript language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Locker Secret API.

The Developer - CyStack

The Locker Secret NodeJS SDK is developed by CyStack, one of the leading cybersecurity companies in Vietnam. CyStack is a member of Vietnam Information Security Association (VNISA) and Vietnam Association of CyberSecurity Product Development. CyStack is a partner providing security solutions and services for many large domestic and international enterprises.

CyStack’s research has been featured at the world’s top security events such as BlackHat USA (USA), BlackHat Asia (Singapore), T2Fi (Finland), XCon - XFocus (China)... CyStack experts have been honored by global corporations such as Microsoft, Dell, Deloitte, D-link...

Documentation

The documentation will be updated later.

Requirements

  • Node 12+

Installation

Install from npm:

npm install -S lockerpm

Install from yarn:

yarn add lockerpm

Usages

Set up access key

The SDK needs to be configured with your access key which is available in your Locker Secret Dashboard. Initialize the accessKeyId and secretAccessKey to their value. You also need to set apiBase value (default value is https://api.locker.io/locker_secrets).

import { Locker } from 'lockerpm'

const locker = new Locker({
  accessKeyId: '<your access key id>',
  secretAccessKey: '<your access key secret>',
  apiBase: '<your api base>'
})

All initialization options are listed below:

KeyDescriptionTypeRequired
accessKeyIdYour access key idstring
secretAccessKeyYour access key secretstring
apiBaseYour server base API URL, default value is https://api.locker.io/locker_secretsstring
headersCustom headers for API calls{[header: string]: string}
unsafeSet TLS to unsafe if you use a server with self-signed certificate, default value is falseboolean
logLevelRefer to Logging, default value is 1number

Now, you can use SDK to get or set values:

// Get list secrets quickly
const secrets = await locker.list()
// or
const secrets = locker.listSync()

// Get a secret value by secret key
// Replace 'ENVIRONMENT' with null or undefined for the enviroment ALL 
const secretValue1 = await locker.get('SECRET_NAME_1')
const secretValue2 = await locker.get('SECRET_NAME_2', 'ENVIRONMENT')
const secretValue3 = await locker.get('SECRET_NAME_3', 'ENVIRONMENT', 'default value')
// or
const secretValue3 = locker.getSync('SECRET_NAME_3', 'ENVIRONMENT', 'default value')

// Create new secret
const secret = await locker.create({
  key: 'key',
  value: 'value',
  environmentName: 'environmentName'
})

// Update secret
const secret = await locker.modify('SECRET', 'ENVIRONMENT', {
  value: 'value',
  environmentName: 'environmentName'
})

// List environments
const environments = await locker.listEnvironments()
// or
const environments = locker.listEnvironmentsSync()

// Get an environment object by name
const environment = await locker.getEnvironment('prod')
// or
const environment = locker.getEnvironmentSync('prod')

# Create new environment
const newEnvironment = await locker.createEnvironment({
  name: 'name',
  externalUrl: 'externalUrl'
})

# Update an environment by name
const environment = await locker.modifyEnvironment("name", {
  externalUrl: 'new value',
})

Logging

The library can be configured to emit logging that will give you better insight into what it's doing. There are some levels: NONE (0), ERROR (1), DEBUG (2). Set the logging level when creating a Locker instance to enabling it:

const locker = new Locker({
  // ...
  logLevel: 1  // default is ERROR
})

Development

Install required packages.

npm install

Run tests

Create a .env file with required access keys (refer to .env.example)

To run all tests, use:

npm test

Run some tests only, please update mocharc.js:

ignore: [
  // './tests/index.spec.ts', // Comment the file you want to test
  './tests/sync.spec.ts',
  './tests/invalid.spec.ts',
  './tests/readonly.spec.ts'
]

Reporting security issues

We take the security and our users' trust very seriously. If you found a security issue in Locker SDK Python, please report the issue by contacting us at contact@locker.io. Do not file an issue on the tracker.

Contributing

Please check CONTRIBUTING before making a contribution.

Help and media

License

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

4 months ago

0.2.0

5 months ago

0.1.7

5 months ago

0.1.6

5 months ago

0.1.5

6 months ago

0.1.4

7 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago