@am92/kms

npm version  ECMAScript Module  License: MIT  Vulnerabilities: Snyk  Downloads Bundle Size


This package provides Key Management related functionalities using either Node Crypto or AWS KMS. It provides the following functionalities:

  • Generating Encryption Key for Symmetric and Asymmetric Algorithms
  • Encrypting and Decrypting data using:
    • Defined Master Key and Master IV in case of Node Crypto
    • KMS defined Master Key and IV in case of AWS KMS

Table of Content


Installation

$ npm install --save @am92/kms

Environment Variables

The following environment variables need to be set to work with this package:

##### KMS Config
export KMS_ENABLED=false
export KMS_TYPE=''
export KMS_KEY_SPEC='AES_256'
export KMS_KEY_PAIR_SPEC='RSA_2048'
export KMS_KEY_FORMAT='base64'
export KMS_PLAIN_TEXT_FORMAT='base64'
export KMS_CIPHER_TEXT_FORMAT='base64'
export KMS_MASTER_KEY_HEX='0000000000000000000000000000000000000000000000000000000000000000'
export KMS_MASTER_IV_HEX='00000000000000000000000000000000'
export KMS_AWS_REGION='ap-south-1'
export KMS_AWS_KEY_ID=''

Note:

  • If 'KMS_ENABLED' is set to 'true', 'KMS_TYPE' is required. Possible values are 'NODE' and 'AWS'
  • If 'KMS_TYPE' is set to 'AWS', 'KMS_AWS_KEY_ID'is required
  • Variables where values have been defined can be omitted from being defined as the mentioned values are internally defaulted.

Creating a KMS Instance

import { Kms } from '@am92/kms'

const kms = new Kms()
export default kms

If you wish to pass your custom 'config' to Kms Class, then you can build it as follows:

import { Kms } from '@am92/kms'

const config = {
  KMS_TYPE: 'NODE'
}

const kms = new Kms(config)
export default kms

Contributors

Ankit Gandhi
Ankit Gandhi
Mehul Agarwal
Mehul Agarwal

Resources


License



results matching ""

    No results matching ""