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

azure-keyvault

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azure-keyvault

KeyVaultClient Library with typescript type definitions for node

  • 3.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25K
increased by30.22%
Maintainers
1
Weekly downloads
 
Created
Source

Microsoft Azure SDK for Node.js - Key Vault

This project provides a Node.js package for accessing keys, secrets and certificates on Azure Key Vault. Right now it supports:

  • Node.js version: 6.x.x or higher
  • REST API version: 2016-10-01

Features

  • Manage keys: create, import, update, delete, backup, restore, list and get.
  • Key operations: sign, verify, encrypt, decrypt, wrap, unwrap.
  • Secret operations: set, get, update and list.
  • Certificate operations: create, get, update, import, list, and manage contacts and issuers.

How to Install

npm install azure-keyvault

Detailed Samples

A sample that can be cloned and run can be found here.

Others you might want to take a look at: Soft delete, recovery, backup and restore Managed storage accounts Deploying certificates to a VM Fetching keyvault secret from a web-application during runtime with MSI

How to Use

The following are some examples on how to create and consume secrets, certificates and keys. For a complete sample, please check one of the above links.

Authentication and Client creation

var KeyVault = require('azure-keyvault');
var msRestAzure = require('ms-rest-azure');

async function main(): Promise<void> {
  const credentials = await msRestAzure.interactiveLogin();
  // OR const credentials = await msRestAzure.loginWithServicePrincipalSecret("clientId", "secret", "domain");
  // OR any other login method from msRestAzure.
  const client = new KeyVault.KeyVaultClient(credentials);
}

main();

Create a key and use it


client.createKey(vaultUri, 'mykey', 'RSA', options).then( (keyBundle) => {
    // Encrypt some plain text
    return client.encrypt(keyBundle.key.kid, 'RSA-OAEP', "ciphertext");
});

Create a certificate and delete it


// Create a certificate
client.createCertificate(vaultUri, 'mycertificate', options).then( (certificateOperation) => {
  console.log(certificateOperation);
  var parsedId = KeyVault.parseCertificateOperationIdentifier(certificateOperation.id);
  
  // Poll the certificate status until it is created
  var interval = setInterval( () => {
    client.getCertificateOperation(parsedId.vault, parsedId.name).then( (pendingCertificate) => {
      if (pendingCertificate.status.toUpperCase() === 'completed'.toUpperCase()) {
        clearInterval(interval); // clear our polling function
        console.log(pendingCertificate);
        var parsedCertId = KeyVault.parseCertificateIdentifier(pendingCertificate.target);
        client.deleteCertificate(parsedCertId.vault, parsedCertId.name).then( (deleteResponse) => {
          console.log(deleteResponse);
        });
      }
    });
    
  });
});

Impressions

Keywords

FAQs

Package last updated on 16 Sep 2019

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