# azure-keyvault

> KeyVaultClient Library with typescript type definitions for node

Latest version **3.0.5** (published 2019-09-16) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install azure-keyvault
pnpm add azure-keyvault
yarn add azure-keyvault
bun add azure-keyvault
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.5 |
| Published | 2019-09-16 |
| First published | 2015-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1174 |
| Author | Microsoft Corporation |
| Maintainers | windowsazure |
| Keywords | node, azure |

## Links

- npm: https://www.npmjs.com/package/azure-keyvault
- Repository: https://github.com/azure/azure-sdk-for-node
- Homepage: http://github.com/azure/azure-sdk-for-node
- Issues: http://github.com/Azure/azure-sdk-for-node/issues
- npm.io page: https://npm.io/package/azure-keyvault

## Dependencies (2)

- [ms-rest](https://npm.io/package/ms-rest.md) ^2.5.0
- [ms-rest-azure](https://npm.io/package/ms-rest-azure.md) ^2.6.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 3.0.5 (latest) — 2019-09-16
- 3.0.4 — 2018-06-28
- 3.0.4-preview — 2018-03-27
- 3.0.3-preview — 2018-03-22
- 2.0.3-preview — 2018-03-19
- 3.0.1-preview — 2018-03-08
- 3.0.0-preview — 2018-01-31
- 2.0.2-preview — 2018-01-29
- 2.0.1-preview — 2017-04-18
- 2.0.0-preview — 2017-04-03
- 1.0.0 — 2016-12-07
- 0.11.0 — 2016-09-23
- 0.10.4 — 2016-09-02
- 0.10.3 — 2016-09-02
- 0.10.2 — 2016-08-27
- … 4 more at https://npm.io/package/azure-keyvault/versions

## README

# 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

```bash
npm install azure-keyvault
```
## Detailed Samples
A sample that can be cloned and run can be found [here](https://github.com/Azure-Samples/key-vault-node-authentication).

Others you might want to take a look at:
[Soft delete, recovery, backup and restore](https://github.com/Azure-Samples/key-vault-node-recovery)
[Managed storage accounts](https://github.com/Azure-Samples/key-vault-node-storage-accounts)
[Deploying certificates to a VM](https://github.com/Azure-Samples/key-vault-node-deploy-certificates-to-vm)
[Fetching keyvault secret from a web-application during runtime with MSI](https://github.com/Azure-Samples/app-service-msi-keyvault-node)

## 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

```javascript
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

```javascript

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

```javascript

// 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);
        });
      }
    });
    
  });
});
```

## Related projects

- [Microsoft Azure SDK for Node.js](https://github.com/azure/azure-sdk-for-node)
- [Microsoft Azure SDK for Node.js - Key Vault Management](https://github.com/Azure/azure-sdk-for-node/tree/master/lib/services/keyVaultManagement)


![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-node%2Flib%2Fservices%2FkeyVault%2FREADME.png)

---
_Source: https://npm.io/package/azure-keyvault · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
