# @intility/msal-keyvault-cache

> A cache for @azure/msal-node that uses Azure KeyVault as a store.

Latest version **1.0.2** (published 2024-07-23) · MIT license · 0 weekly downloads

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

## Install

```sh
npm install @intility/msal-keyvault-cache
pnpm add @intility/msal-keyvault-cache
yarn add @intility/msal-keyvault-cache
bun add @intility/msal-keyvault-cache
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-07-23 |
| First published | 2022-03-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Intility AS |
| Maintainers | linda.tran, xec, h3rmanj |
| Keywords | msal, msal-node, keyvault, azure, intility |

## Links

- npm: https://www.npmjs.com/package/@intility/msal-keyvault-cache
- Repository: https://github.com/Intility/msal-keyvault-cache
- Issues: https://github.com/Intility/msal-keyvault-cache/issues
- npm.io page: https://npm.io/package/@intility/msal-keyvault-cache

## Dependencies (2)

- [@azure/identity](https://npm.io/package/@azure/identity.md) ^4.4.0
- [@azure/keyvault-secrets](https://npm.io/package/@azure/keyvault-secrets.md) ^4.3.0

## Recent versions

- 1.0.2 (latest) — 2024-07-23
- 1.0.1 — 2023-10-20
- 1.0.0 — 2022-03-10
- 0.2.0 — 2022-03-10
- 0.1.3 — 2022-03-04
- 0.1.2 — 2022-03-04
- 0.1.1 — 2022-03-04

## README

<h1 align="center">
  <img src="https://avatars.githubusercontent.com/u/35199565" width="124px"/><br/>
  @intility/msal-keyvault-cache
</h1>

<p align="center">
  A cache for @azure/msal-node that uses Azure KeyVault as a store. 
</p>

<p align="center">
  <a href="https://github.com/Intility/msal-keyvault-cache/actions">
    <img alt="pipeline" src="https://github.com/Intility/msal-keyvault-cache/actions/workflows/publish.yml/badge.svg" style="max-width:100%;" />
  </a>
  <a href="https://www.npmjs.com/package/@intility/msal-keyvault-cache">
    <img alt="package version" src="https://img.shields.io/npm/v/@intility/msal-keyvault-cache?label=%40intility%2Fmsal-keyvault-cache" style="max-width:100%;" />
  </a>
</p>

## Usage

Install with

```
npm install @intility/msal-keyvault-cache
```

Then, initialize the cache and use it in your client configuration

```js
import { PublicClientApplication } from "@azure/msal-node";
import keyVaultCache from "@intility/msal-keyvault-cache";

let cachePlugin = keyVaultCache("https://YOUR_KEYVAULT_HERE.vault.azure.net/");

let publicClientConfig = {
  auth: {
    clientId: "CLIENT_ID",
    authority: "https://login.microsoftonline.com/TENANT_ID",
  },
  cache: {
    cachePlugin,
  },
};

let publicClientApplication = new PublicClientApplication(publicClientConfig);
```

By default, it will authenticate to the KeyVault by using [`DefaultAzureCredential` from '@azure/identity'](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#defaultazurecredential). This means you can authenticate a number of ways. In CI you can use [environment variables](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#defaultazurecredential), and locally you can use the Azure CLI.

### Syntax

```js
let cachePlugin = keyVaultCache(keyVaultUrl);
let cachePlugin = keyVaultCache(keyVaultUrl, secretName);
let cachePlugin = keyVaultCache(keyVaultUrl, secretName, credential);
```

### Parameters

#### `keyVaultUrl`

A JavaScript string containing the url to your Azure KeyVault.

#### `secretName` (optional)

- Default Value: `"msal-cache"`

A JavaScript string containing the name of the secret.

#### `credential` (optional)

- Default Value: `new DefaultAzureCredential()`

A [`Credential Class`](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#credential-classes) used to authenticate to the Azure KeyVault.

### Return value

A `cachePlugin` that can be used in a `@azure/msal-node` Client Configuration.

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