1.0.0 • Published 10 months ago

@credenceanalytics/aws-kms-adaptor v1.0.0

Weekly downloads
-
License
-
Repository
gitlab
Last release
10 months ago

AWS KMS Adaptor

Installation

  • Execute below mentioned command:
    npm install @credenceanalytics/aws-kms-adaptor

Requirements

  • AWS SDK: Ensure AWS credentials are properly configured for KMS access.
  • Dependencies: This library internally uses @aws-crypto/client-node.

Usage

Initialization

Import and initialize the AWS KMS Adaptor with your AWS configuration:

`const AwskmsInstance = require('aws-kms-adaptor');
 const kmsAdaptor = new AwskmsInstance(<awsconfig>);` 

Encrypt Data

const plaintext = 'Sensitive information';
kmsAdaptor.encryptDataAndReturn(<plaintext>).then((encryptedData) => {
  console.log('Encrypted Data:', encryptedData);
}).catch((error) => {
  console.error('Encryption Error:', error.message);
});

Decrypt Data

const encryptedData = '<Base64-encoded encrypted data>';
kmsAdaptor.decryptData(encryptedData).then((decryptedData) => {
  console.log('Decrypted Data:', decryptedData);
}).catch((error) => {
  console.error('Decryption Error:', error.message);
});

Configuration

  • AWS Key ARN: The kms_key_Arn parameter specifies the KMS key used for encryption and decryption.
  • Encryption Context: Default context includes metadata for purpose and environment. You can customize it in the encryptionContext field inside the class.

Feel free to modify this template further to fit your project's specific needs.

1.0.0

10 months ago