3.0.3 • Published 10 months ago

@am92/kms v3.0.3

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

@am92/kms

npm version  Security: Snyk  License: MIT  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

For full documentation, visit here.

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=
export KMS_TYPE=''
export KMS_KEY_SPEC=''
export KMS_KEY_PAIR_SPEC=''
export KMS_KEY_FORMAT=''
export KMS_PLAIN_TEXT_FORMAT=''
export KMS_CIPHER_TEXT_FORMAT=''
export KMS_MASTER_KEY_HEX=''
export KMS_MASTER_IV_HEX=''
export KMS_AWS_REGION=''
export KMS_AWS_KEY_ID=''
Variable NameRequiredDefaultDescription
KMS_ENABLEDNofalseEnables/Disables KMS functionality
KMS_TYPENo*-Type of KMS to use. Possible values: NODE, AWS
KMS_KEY_SPECNoAES_256Specification for symmetric key generation
KMS_KEY_PAIR_SPECNoRSA_2048Specification for asymmetric key pair generation
KMS_KEY_FORMATNobase64Format for generated keys
KMS_PLAIN_TEXT_FORMATNobase64Format for plain text data
KMS_CIPHER_TEXT_FORMATNobase64Format for encrypted data
KMS_MASTER_KEY_HEXNo0000000000000000000000000000000000000000000000000000000000000000Master key in hex format for Node Crypto
KMS_MASTER_IV_HEXNo00000000000000000000000000000000Master IV in hex format for Node Crypto
KMS_AWS_REGIONNoap-south-1AWS region for KMS operations
KMS_AWS_KEY_IDNo**-AWS KMS key ID for encryption/decryption

Note:

  • * - Required if KMS_ENABLED is set to true.
  • ** - Required if KMS_TYPE is set to AWS.

Creating an Instance

import { generateKmsInstance } from '@am92/kms'

const kms = generateKmsInstance()

export default kms

Self-managed Config

If you wish to pass your custom 'config' for Kms, then you can avoid setting any environment variables defined above and pass your own config as follows:

import { generateKmsInstance } from '@am92/kms'

const config = {
  KMS_TYPE: 'NODE'
}

const kms = generateKmsInstance(config)

export default kms

Contributors

Resources

License

2.1.1

11 months ago

2.1.0

11 months ago

3.0.3

10 months ago

3.0.2

10 months ago

3.0.1

10 months ago

3.0.0

10 months ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.2

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago