Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure/keyvault-keys

Package Overview
Dependencies
Maintainers
2
Versions
449
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/keyvault-keys

Isomorphic client library for Azure KeyVault's keys.

  • 4.9.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
decreased by-22.39%
Maintainers
2
Weekly downloads
 
Created

What is @azure/keyvault-keys?

@azure/keyvault-keys is an npm package that provides a client library for managing keys in Azure Key Vault. It allows you to create, import, update, delete, and manage keys, as well as perform cryptographic operations such as encryption, decryption, signing, and verifying.

What are @azure/keyvault-keys's main functionalities?

Create a Key

This feature allows you to create a new key in Azure Key Vault. The code sample demonstrates how to create an RSA key using the KeyClient.

const { DefaultAzureCredential } = require('@azure/identity');
const { KeyClient } = require('@azure/keyvault-keys');

const credential = new DefaultAzureCredential();
const keyClient = new KeyClient('https://<your-key-vault-name>.vault.azure.net', credential);

async function createKey() {
  const keyName = 'myKey';
  const result = await keyClient.createKey(keyName, 'RSA');
  console.log('Key created:', result);
}

createKey();

Get a Key

This feature allows you to retrieve an existing key from Azure Key Vault. The code sample demonstrates how to get a key by its name using the KeyClient.

const { DefaultAzureCredential } = require('@azure/identity');
const { KeyClient } = require('@azure/keyvault-keys');

const credential = new DefaultAzureCredential();
const keyClient = new KeyClient('https://<your-key-vault-name>.vault.azure.net', credential);

async function getKey() {
  const keyName = 'myKey';
  const result = await keyClient.getKey(keyName);
  console.log('Key retrieved:', result);
}

getKey();

Delete a Key

This feature allows you to delete an existing key from Azure Key Vault. The code sample demonstrates how to start the deletion process for a key using the KeyClient.

const { DefaultAzureCredential } = require('@azure/identity');
const { KeyClient } = require('@azure/keyvault-keys');

const credential = new DefaultAzureCredential();
const keyClient = new KeyClient('https://<your-key-vault-name>.vault.azure.net', credential);

async function deleteKey() {
  const keyName = 'myKey';
  const result = await keyClient.beginDeleteKey(keyName);
  console.log('Key deletion started:', result);
}

deleteKey();

Encrypt Data

This feature allows you to encrypt data using a key stored in Azure Key Vault. The code sample demonstrates how to encrypt data using the CryptographyClient.

const { DefaultAzureCredential } = require('@azure/identity');
const { KeyClient, CryptographyClient } = require('@azure/keyvault-keys');

const credential = new DefaultAzureCredential();
const keyClient = new KeyClient('https://<your-key-vault-name>.vault.azure.net', credential);

async function encryptData() {
  const keyName = 'myKey';
  const key = await keyClient.getKey(keyName);
  const cryptoClient = new CryptographyClient(key.id, credential);
  const plaintext = Buffer.from('my secret data');
  const result = await cryptoClient.encrypt('RSA-OAEP', plaintext);
  console.log('Encrypted data:', result.result);
}

encryptData();

Decrypt Data

This feature allows you to decrypt data using a key stored in Azure Key Vault. The code sample demonstrates how to decrypt data using the CryptographyClient.

const { DefaultAzureCredential } = require('@azure/identity');
const { KeyClient, CryptographyClient } = require('@azure/keyvault-keys');

const credential = new DefaultAzureCredential();
const keyClient = new KeyClient('https://<your-key-vault-name>.vault.azure.net', credential);

async function decryptData() {
  const keyName = 'myKey';
  const key = await keyClient.getKey(keyName);
  const cryptoClient = new CryptographyClient(key.id, credential);
  const encryptedData = Buffer.from('<your-encrypted-data>', 'base64');
  const result = await cryptoClient.decrypt('RSA-OAEP', encryptedData);
  console.log('Decrypted data:', result.result.toString());
}

decryptData();

Other packages similar to @azure/keyvault-keys

Keywords

FAQs

Package last updated on 17 Oct 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc