# @2060\.io/credo-ts-didcomm-receipts 中文文档

规范地址：https://npmcn.com/package/%402060.io/credo-ts-didcomm-receipts/

版本：0\.1\.1
npm 元数据更新时间：2026-03-11T18:06:55.714Z
中文译文更新时间：2026-11-08T10:34:25.496Z
软件包许可：Apache-2\.0

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

原始 npm 页面：https://www.npmjs.com/package/%402060.io/credo-ts-didcomm-receipts
原文对照：https://npmcn.com/package/%402060.io/credo-ts-didcomm-receipts/?lang=original
项目主页：https://github.com/2060-io/credo-ts-didcomm-ext/tree/main/packages/receipts
源码仓库：https://github.com/2060-io/credo-ts-didcomm-ext

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

- 包体积（解压后）：48.4 kB，6 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：6 个
- peer 依赖：@credo-ts/core ^0\.6\.1，@credo-ts/didcomm ^0\.6\.1
- 首次发布：2025-02-15T21:57:06.180Z
- 最新版本发布：2026-03-11T18:06:55.387Z
- 近 30 天下载量：1798（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 3 个）

## 中文简介

DIDComm 信件接收协议执行@ credo- ts/ core

## 安装

```sh
npm install @2060.io/credo-ts-didcomm-receipts
```

也可以使用：`pnpm add @2060.io/credo-ts-didcomm-receipts`、`yarn add @2060.io/credo-ts-didcomm-receipts`、`bun add @2060.io/credo-ts-didcomm-receipts`

## README

# 信件接收协议的克里多扩展模块

![Credo logo](https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png)

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://raw.githubusercontent.com/openwallet-foundation/credo-ts-ext/main/LICENSE) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/) [![@2060.io/credo-ts-didcomm-receipts](https://img.shields.io/npm/v/@2060.io/credo-ts-didcomm-receipts)](https://www.npmjs.com/package/credo-ts-didcomm-receipts)

## 概览

这个 **信件收据** 扩展模块 [克里多语](https://github.com/openwallet-foundation/credo-ts) 使代理人能够管理 [收款协议](https://didcomm.org/receipts/1.0/),允许追踪和确认代理商之间的电文状态(例如,接收和查看).

## 安装

```bash
npm install @2060.io/credo-ts-didcomm-receipts
```

## 使用量

将模块添加到您的代理 要使用接收模块,请添加到您的代理模块配置中:

```typescript
import { ReceiptsModule } from '@2060.io/credo-ts-didcomm-receipts'

const agent = new Agent({
  modules: {
    // ...other modules
    receipts: new ReceiptsModule(),
  },
})
```

### 发送信件收据

发送电文收据(如收到或查看电文时):

```typescript
await agent.modules.receipts.send({
  connectionId: connection.id,
  receipts: [
    { messageId: 'message-id', state: MessageState.Received },
    { messageId: 'message-id', state: MessageState.Viewed },
  ],
})
```

### 请求信件收据

要求提供特定电文或电文类型的收据:

```typescript
await agent.modules.receipts.request({
  connectionId: connection.id,
  requestedReceipts: [
    {
      messageType: 'https://didcomm.org/my-protocol/1.0/my-message',
      states: [MessageState.Received, MessageState.Viewed],
    },
  ],
})
```

### 处理接收事件

订阅收件事件以响应收件:

```typescript
import { ReceiptsEventTypes, MessageReceiptsReceivedEvent } from '@2060.io/credo-ts-didcomm-receipts'

agent.events.on(ReceiptsEventTypes.MessageReceiptsReceived, async ({ payload }: MessageReceiptsReceivedEvent) => {
  const connectionId = payload.connectionId
  const receipts = payload.receipts

  receipts.forEach((receipt) => {
    const { messageId, timestamp, state } = receipt
    sendMessageStateUpdatedEvent({ agent, messageId, connectionId, state, timestamp, config })
  })
})
```

### 特征

-   **发送信件收据**:将消息状态通知其他代理(收到,查看等).
-   **索取收据**:询问特定电文或电文类型的收据.
-   **事件订阅**:聆听接收事件以更新UI或触发工作流程.
-   **协议整合**:与Credo代理和DIDComm协议的无缝集成.

## API 参考

见 [源代码](https://npmcn.com/package/%402060.io/credo-ts-didcomm-receipts/src/) 关于现有类别和方法的详细信息:

-   [`DidCommReceiptsApi`数字 :](https://npmcn.com/package/%402060.io/credo-ts-didcomm-receipts/src/DidCommReceiptsApi.ts) 主API用于发送和请求收据.
-   [`DidCommReceiptsService`数字 :](https://npmcn.com/package/%402060.io/credo-ts-didcomm-receipts/src/services/DidCommReceiptsService.ts) 内部服务 接收逻辑.
-   [`DidCommReceiptsModule`数字 :](https://npmcn.com/package/%402060.io/credo-ts-didcomm-receipts/src/DidCommReceiptsModule.ts) Credo 代理模块集成 .

## 许可证

Apache 2.0 (英语)

* * *

更多信息,请参见 [docomm.org (英语)](https://didcomm.org/receipts/1.0/)。 。 。 .

## 常见问题

### @2060\.io/credo-ts-didcomm-receipts 是什么？

DIDComm 信件接收协议执行@ credo- ts/ core

### 如何安装 @2060\.io/credo-ts-didcomm-receipts？

在项目目录运行 npm install @2060\.io/credo-ts-didcomm-receipts，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@credo-ts/core（^0\.6\.1）、@credo-ts/didcomm（^0\.6\.1）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @2060\.io/credo-ts-didcomm-receipts 支持 TypeScript 吗？

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

### @2060\.io/credo-ts-didcomm-receipts 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @2060\.io/credo-ts-didcomm-receipts 可以商用吗？

@2060\.io/credo-ts-didcomm-receipts 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @2060\.io/credo-ts-didcomm-receipts 的下载量有多少？

根据 npm 官方下载统计，@2060\.io/credo-ts-didcomm-receipts 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,798 次，日均约 60 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @2060\.io/credo-ts-didcomm-receipts 还在维护吗？

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

