🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@aws-crypto/kms-keyring-node

Package Overview
Dependencies
Maintainers
8
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-crypto/kms-keyring-node

4.2.1
latest
npm
Version published
Weekly downloads
221K
-12.98%
Maintainers
8
Weekly downloads
 
Created

What is @aws-crypto/kms-keyring-node?

@aws-crypto/kms-keyring-node is an AWS SDK package that provides keyring implementations for AWS Key Management Service (KMS). It allows you to encrypt and decrypt data using AWS KMS keys in a Node.js environment.

What are @aws-crypto/kms-keyring-node's main functionalities?

Encrypting Data

This feature allows you to encrypt data using a KMS key. The code sample demonstrates how to create a KMS keyring and use it to encrypt a plaintext message.

const { KmsKeyringNode, buildClient, CommitmentPolicy } = require('@aws-crypto/kms-keyring-node');
const { encrypt } = require('@aws-crypto/client-node');

const keyring = new KmsKeyringNode({ generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678' });
const plaintext = Buffer.from('Hello, world!');

(async () => {
  const { result } = await encrypt(keyring, plaintext);
  console.log(result); // Encrypted data
})();

Decrypting Data

This feature allows you to decrypt data that was encrypted using a KMS key. The code sample demonstrates how to create a KMS keyring and use it to decrypt an encrypted message.

const { KmsKeyringNode, buildClient, CommitmentPolicy } = require('@aws-crypto/kms-keyring-node');
const { decrypt } = require('@aws-crypto/client-node');

const keyring = new KmsKeyringNode({ generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678' });
const encryptedData = Buffer.from('...'); // Encrypted data from previous step

(async () => {
  const { plaintext } = await decrypt(keyring, encryptedData);
  console.log(plaintext.toString()); // Decrypted data
})();

Multi-Region Keyring

This feature allows you to create a multi-region keyring that can use multiple KMS keys from different regions. The code sample demonstrates how to configure a keyring with multiple KMS key ARNs.

const { KmsKeyringNode } = require('@aws-crypto/kms-keyring-node');

const keyring = new KmsKeyringNode({
  generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678',
  keyIds: [
    'arn:aws:kms:us-east-1:123456789012:key/abcd-1234-efgh-5678',
    'arn:aws:kms:eu-west-1:123456789012:key/abcd-1234-efgh-5678'
  ]
});

console.log(keyring);

Other packages similar to @aws-crypto/kms-keyring-node

FAQs

Package last updated on 10 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts