npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@azure/identity-cache-persistence

v1.3.0

Published

A secure, persistent token cache for Azure Identity credentials that uses the OS secret-management API

Readme

Azure Identity Plugin for Token Cache Persistence

This package provides a plugin to the Azure Identity library for JavaScript (@azure/identity) that enables persistent token caching. Token cache persistence allows the built-in token cache to persist across sessions using a secure storage system provided by the local operating system.

Source code | Samples

Getting started

Prerequisites

Install the package

This package is designed to be used with Azure Identity for JavaScript. Install both @azure/identity and this package using npm:

$ npm install --save @azure/identity
$ npm install --save @azure/identity-cache-persistence

Supported Environments

Azure Identity plugins for JavaScript support stable (even numbered) versions of Node.js starting from v12. While the plugins may run in other Node versions, no support is guaranteed. @azure/identity-cache-persistence does not support browser environments.

Key concepts

If this is your first time using @azure/identity or Microsoft Entra ID, we recommend that you read Using @azure/identity with Microsoft Entra ID first. This document will give you a deeper understanding of the platform and how to configure your Azure account correctly.

Azure Identity Plugins

As of @azure/identity version 2.0.0, the Identity client library for JavaScript includes a plugin API. This package (@azure/identity-cache-persistence) exports a plugin object that you must pass as an argument to the top-level useIdentityPlugin function from the @azure/identity package. Enable token cache persistence in your program as follows:

import { useIdentityPlugin } from "@azure/identity";
import { cachePersistencePlugin } from "@azure/identity-cache-persistence";

useIdentityPlugin(cachePersistencePlugin);

After calling useIdentityPlugin, the persistent token cache plugin is registered to the @azure/identity package and will be available on all credentials that support persistent token caching (those that have tokenCachePersistenceOptions in their constructor options).

Examples

Once the plugin is registered, you can enable token cache persistence by passing tokenCachePersistenceOptions with an enabled property set to true to a credential constructor. In the following example, we use the DeviceCodeCredential, since persistent caching of its tokens allows you to skip the interactive device-code authentication flow if a cached token is available.

import { DeviceCodeCredential } from "@azure/identity";

const credential = new DeviceCodeCredential({
  tokenCachePersistenceOptions: {
    enabled: true,
  },
});

// We'll use the Microsoft Graph scope as an example
const scope = "https://graph.microsoft.com/.default";

// Print out part of the access token
console.log((await credential.getToken(scope)).token.substring(0, 10), "...");

Troubleshooting

Logging

Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the AZURE_LOG_LEVEL environment variable to info. Alternatively, logging can be enabled at runtime by calling setLogLevel in the @azure/logger:

import { setLogLevel } from "@azure/logger";

setLogLevel("info");

Next steps

Provide Feedback

If you encounter bugs or have suggestions, please open an issue.

Contributing

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.