3.0.3 • Published 6 months ago
@am92/kms v3.0.3
@am92/kms
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
- Environment Variables
- Creating an Instance
- Self-managed Config
- Contributors
- Resources
- License
Installation
npm install --save @am92/kmsEnvironment 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 Name | Required | Default | Description |
|---|---|---|---|
KMS_ENABLED | No | false | Enables/Disables KMS functionality |
KMS_TYPE | No* | - | Type of KMS to use. Possible values: NODE, AWS |
KMS_KEY_SPEC | No | AES_256 | Specification for symmetric key generation |
KMS_KEY_PAIR_SPEC | No | RSA_2048 | Specification for asymmetric key pair generation |
KMS_KEY_FORMAT | No | base64 | Format for generated keys |
KMS_PLAIN_TEXT_FORMAT | No | base64 | Format for plain text data |
KMS_CIPHER_TEXT_FORMAT | No | base64 | Format for encrypted data |
KMS_MASTER_KEY_HEX | No | 0000000000000000000000000000000000000000000000000000000000000000 | Master key in hex format for Node Crypto |
KMS_MASTER_IV_HEX | No | 00000000000000000000000000000000 | Master IV in hex format for Node Crypto |
KMS_AWS_REGION | No | ap-south-1 | AWS region for KMS operations |
KMS_AWS_KEY_ID | No** | - | AWS KMS key ID for encryption/decryption |
Note:
- * - Required if
KMS_ENABLEDis set totrue. - ** - Required if
KMS_TYPEis set toAWS.
Creating an Instance
import { generateKmsInstance } from '@am92/kms'
const kms = generateKmsInstance()
export default kmsSelf-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 kmsContributors
Resources
License
2.1.1
7 months ago
2.1.0
7 months ago
3.0.3
6 months ago
3.0.2
6 months ago
3.0.1
6 months ago
3.0.0
6 months ago
2.0.3
1 year ago
2.0.2
1 year 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