# @curity/identityserver-haapi-web-driver 中文文档

规范地址：https://npmcn.com/package/%40curity/identityserver-haapi-web-driver/

版本：1\.5\.0
npm 元数据更新时间：2026-03-23T11:20:45.379Z
中文译文更新时间：2026-11-11T04:59:08.482Z
软件包许可：UNLICENSED

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40curity/identityserver-haapi-web-driver
原文对照：https://npmcn.com/package/%40curity/identityserver-haapi-web-driver/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：17 kB，5 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2020-11-30T09:53:45.115Z
- 最新版本发布：2026-03-23T11:20:45.135Z
- 近 30 天下载量：9499（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：11（近 12 个月 1 个）

## 中文简介

用户身份服务器 HAPI 网络驱动程序

## 安装

```sh
npm install @curity/identityserver-haapi-web-driver
```

也可以使用：`pnpm add @curity/identityserver-haapi-web-driver`、`yarn add @curity/identityserver-haapi-web-driver`、`bun add @curity/identityserver-haapi-web-driver`

## README

# HAAPI 网络驱动程序

Typescript/ Javascript 库, 有类和功能访问 Curity 身份服务器 [超媒体认证 API (HAAPI)](https://developer.curity.io/docs/latest/developer-guide/haapi/index.html) 从基于浏览器的应用程序。 该图书馆可在npm公共登记簿上查阅,并可通过下列方式安装:

```
npm install @curity/identityserver-haapi-web-driver
```

## 用法实例

软件包定义 `createHaapiFetch` 函数,可以创建类似获取的函数,用于执行 HAAPI 请求。 返回的函数在封面下自动管理验证,访问符,DPoP令牌和会话-Id.

```js
// 0 - Import the createHaapiFetch function
import { createHaapiFetch } from '@curity/identityserver-haapi-web-driver';

// 1 - Create a fetch-like function to perform HAAPI requests
const haapiFetch = createHaapiFetch({
    clientId: 'test-client-id',
    tokenEndpoint: 'https://localhost:8443/dev/oauth/token',
});

// 2 - Use haapiFetch to access HAAPI resources
const authorizeRequest = '/dev/oauth/authorize?client_id=test-client-id&response_type=code&scope=read&state=foobar&redirect_uri=https://localhost:7777/client-callback';
haapiFetch(authorizeRequest)
    .then(res => {
        // ...
    });
```

## 常见问题

### @curity/identityserver-haapi-web-driver 是什么？

用户身份服务器 HAPI 网络驱动程序

### 如何安装 @curity/identityserver-haapi-web-driver？

在项目目录运行 npm install @curity/identityserver-haapi-web-driver，或使用 pnpm add / yarn add / bun add。

### @curity/identityserver-haapi-web-driver 支持 TypeScript 吗？

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

### @curity/identityserver-haapi-web-driver 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @curity/identityserver-haapi-web-driver 可以商用吗？

@curity/identityserver-haapi-web-driver 使用 UNLICENSED 许可。作者声明为 UNLICENSED，即不授予公开使用许可（与公共领域的 Unlicense 不同）。使用前需获得作者授权。以上为概括，不构成法律意见，请以许可原文为准。

### @curity/identityserver-haapi-web-driver 的下载量有多少？

根据 npm 官方下载统计，@curity/identityserver-haapi-web-driver 在 2026/10/11 – 2026/11/09 这 30 天内被下载 9,499 次，日均约 317 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @curity/identityserver-haapi-web-driver 还在维护吗？

最新版本 1\.5\.0 发布于 2026/03/23（7 个月前）；至今共发布 11 个版本，其中过去 12 个月发布了 1 个；首次发布于 2020/11/30。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

