@azure/core-auth

中文文档
1.11.0发布于 2026/07/14MITTypeScriptESM + CJS近 30 天下载 9846万

Provides low-level interfaces and helper methods for authentication in Azure SDK

原始使用文档
文档目录10 节
  1. Getting started
  2. Installation
  3. Key Concepts
  4. Examples
  5. AzureKeyCredential
  6. AzureNamedKeyCredential
  7. AzureSASCredential
  8. Next steps
  9. Troubleshooting
  10. Contributing

Azure Core Authentication client library for JavaScript

The @azure/core-auth package provides core interfaces and helper methods for authenticating with Azure services using Azure Active Directory and other authentication schemes common across the Azure SDK. As a "core" library, it shouldn't need to be added as a dependency to any user code, only other Azure SDK libraries.

Getting started

Installation

Install this library using npm as follows

npm install @azure/core-auth

Key Concepts

The TokenCredential interface represents a credential capable of providing an authentication token. The @azure/identity package contains various credentials that implement the TokenCredential interface.

The AzureKeyCredential is a static key-based credential that supports key rotation via the update method. Use this when a single secret value is needed for authentication, e.g. when using a shared access key.

The AzureNamedKeyCredential is a static name/key-based credential that supports name and key rotation via the update method. Use this when both a secret value and a label are needed, e.g. when using a shared access key and shared access key name.

The AzureSASCredential is a static signature-based credential that supports updating the signature value via the update method. Use this when using a shared access signature.

Examples

AzureKeyCredential

import { AzureKeyCredential } from "@azure/core-auth";

const credential = new AzureKeyCredential("secret value");

console.log(credential.key); // prints: "secret value"

credential.update("other secret value");

console.log(credential.key); // prints: "other secret value"

AzureNamedKeyCredential

import { AzureNamedKeyCredential } from "@azure/core-auth";

const credential = new AzureNamedKeyCredential("ManagedPolicy", "secret value");

console.log(`${credential.name}, ${credential.key}`); // prints: "ManagedPolicy, secret value"

credential.update("OtherManagedPolicy", "other secret value");

console.log(`${credential.name}, ${credential.key}`); // prints: "OtherManagedPolicy, other secret value"

AzureSASCredential

import { AzureSASCredential } from "@azure/core-auth";

const credential = new AzureSASCredential("signature1");

console.log(credential.signature); // prints: "signature1"

credential.update("signature2");

console.log(credential.signature); // prints: "signature2"

Next steps

You can build and run the tests locally by executing npm run test. Explore the test folder to see advanced usage and behavior of the public classes.

Troubleshooting

If you run into issues while using this library, please feel free to file 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.

版本与发布记录

@azure/core-auth 共发布 483 个版本,首次发布于 2019/07/27;过去 12 个月发布了 26 个版本。

版本发布日期距今
1.11.0latest2026/07/143 个月前
1.10.2-alpha.20260305.6dev2026/03/068 个月前
1.10.2-alpha.20260227.22026/02/288 个月前
1.10.2-alpha.20260226.12026/02/278 个月前
1.10.2-alpha.20260223.32026/02/248 个月前
1.10.2-alpha.20260210.12026/02/118 个月前

关于 @azure/core-auth 的常见问题

@azure/core-auth 是什么?

Provides low-level interfaces and helper methods for authentication in Azure SDK

如何安装 @azure/core-auth?

在项目目录运行 npm install @azure/core-auth,或使用 pnpm add / yarn add / bun add。

@azure/core-auth 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@azure/core-auth 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@azure/core-auth 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@azure/core-auth 可以商用吗?

@azure/core-auth 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@azure/core-auth 的下载量有多少?

根据 npm 官方下载统计,@azure/core-auth 在 2026/10/08 – 2026/11/06 这 30 天内被下载 98,460,370 次,日均约 3,282,012 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@azure/core-auth 还在维护吗?

最新版本 1.11.0 发布于 2026/07/14(3 个月前);至今共发布 483 个版本,其中过去 12 个月发布了 26 个;首次发布于 2019/07/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。