@2060.io/credo-ts-didcomm-receipts
v0.1.1
Published
DIDComm Message Receipts protocol implementation for @credo-ts/core
Readme
Credo Extension Module for Message Receipts Protocol

Overview
The Message Receipts extension module for Credo enables agents to manage Receipts protocol, allowing tracking and acknowledgment of message states (e.g., received, viewed) between agents.
Installation
npm install @2060.io/credo-ts-didcomm-receiptsUsage
Adding the Module to Your Agent To use the Receipts module, add it to your agent's modules configuration:
import { ReceiptsModule } from '@2060.io/credo-ts-didcomm-receipts'
const agent = new Agent({
modules: {
// ...other modules
receipts: new ReceiptsModule(),
},
})Sending Message Receipts
To send message receipts (e.g., when a message is received or viewed):
await agent.modules.receipts.send({
connectionId: connection.id,
receipts: [
{ messageId: 'message-id', state: MessageState.Received },
{ messageId: 'message-id', state: MessageState.Viewed },
],
})Requesting Message Receipts
To request receipts for specific messages or message types:
await agent.modules.receipts.request({
connectionId: connection.id,
requestedReceipts: [
{
messageType: 'https://didcomm.org/my-protocol/1.0/my-message',
states: [MessageState.Received, MessageState.Viewed],
},
],
})Handling Receipt Events
Subscribe to receipt events to react to incoming receipts:
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 })
})
})Features
- Send Message Receipts: Notify other agents about message states (received, viewed, etc.).
- Request Receipts: Ask for receipts for specific messages or message types.
- Event Subscription: Listen for receipt events to update UI or trigger workflows.
- Protocol Integration: Seamless integration with Credo agent and DIDComm protocols.
API Reference
See the source code for details on available classes and methods:
DidCommReceiptsApi: Main API for sending and requesting receipts.DidCommReceiptsService: Internal service for receipt logic.DidCommReceiptsModule: Module integration for Credo agent.
License
Apache 2.0
For more information, see the didcomm.org.
