Skip to content

Commit 3c6d68c

Browse files
elinacadourigitbook-bot
authored andcommitted
GITBOOK-471: No subject
1 parent aad9fe8 commit 3c6d68c

3 files changed

Lines changed: 106 additions & 18 deletions

File tree

SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
* [Templates](truvera-api/templates.md)
6868
* [Sub-accounts](truvera-api/sub-accounts.md)
6969
* [Teams](truvera-api/teams.md)
70-
* [Messaging](truvera-api/messaging.md)
70+
* [Holder messaging via DIDComm](truvera-api/messaging/README.md)
71+
* [Messaging API calls](truvera-api/messaging/messaging-api-calls.md)
7172
* [OpenID](truvera-api/openid/README.md)
7273
* [OpenID Issuance and Verification Integration Guide](truvera-api/openid/openid-issuance-and-verification-integration-guide.md)
7374
* [iden3comm](truvera-api/iden3comm.md)

truvera-api/messaging/README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Holder messaging via DIDComm
2+
3+
Holder messaging enables secure, encrypted communication between organizations and digital wallet holders using the DIDComm protocol. This feature allows verifiers to send authenticated requests directly to credential holders' wallets, enabling real-time verification workflows without requiring traditional authentication methods.
4+
5+
### Example use case 
6+
7+
Consider a customer service scenario where enhanced identity verification is needed. A customer calls their bank to request a credit limit increase or password change. Rather than relying solely on traditional phone-based verification, the call center can leverage the customer's existing digital credentials for stronger authentication.
8+
9+
The process works as follows: the customer receives a credential during onboarding. The call center agent can initiate a credential verification request. The customer receives a secure message in their digital wallet via push notification, reviews the request, and responds using biometric authentication to unlock their wallet and confirm the data sharing.
10+
11+
### Technical implementation
12+
13+
#### Prerequisites
14+
15+
* Issuer has captured the holder's DID during credential issuance
16+
17+
#### **Encrypted message dispatch**
18+
19+
Uses the Truvera API to send an encrypted DIDComm message to the holders DID. The message script:
20+
21+
```javascript
22+
const axios = require("axios").default;
23+
const API_KEY = ;//Your Truvera API key//
24+
const API_URL = "https://api-testnet.truvera.io";//for production https://api.truvera.io
25+
const WALLET_DID = ;//Holders wallet DID//
26+
27+
const apiClient = axios.create({
28+
baseURL: API_URL,
29+
headers: {
30+
"Content-Type": "application/json",
31+
"User-Agent": "insomnia/9.3.2",
32+
Authorization: `Bearer ${API_KEY}`,
33+
},
34+
});
35+
36+
async function sendYesNoMessage() {
37+
const payload = {
38+
type: "text",
39+
payload: {
40+
senderName: , //Name of the message sender DID//
41+
senderDid: , //Message sender DID//
42+
senderLogo: , //Logo of the message sender DID//
43+
title: "Are you currently speaking with our customer support team?",
44+
question:
45+
"This confirms you initiated the call and helps prevent fraud. Your personal information will not be shared.",
46+
yesText: "Yes",
47+
noText: "No",
48+
expirationDate: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(),
49+
messageId: 'Internal-message-1234'//add a message ID to track the message
50+
},
51+
type: "https://schema.truvera.io/yes-no-payload-V1.json",
52+
senderDid: ,//the message sender DID//
53+
algorithm: "ECDH-1PU+A256KW",
54+
recipientDids: [WALLET_DID],
55+
};
56+
57+
const { data: encryptedMessage } = await apiClient.post(
58+
"/messaging/encrypt",
59+
payload
60+
);
61+
console.log("Message encrypted successfully:", encryptedMessage);
62+
63+
const sendPayload = {
64+
to: WALLET_DID,
65+
message: encryptedMessage.jwe,
66+
};
67+
68+
const { data: sentMessage } = await apiClient.post(
69+
"/messaging/send",
70+
sendPayload
71+
);
72+
console.log("Message sent successfully:", sentMessage);
73+
}
74+
75+
76+
sendYesNoMessage();
77+
```
78+
79+
#### **Response notification and retrieval**
80+
81+
Configure a webhook via the [API](../webhooks/) or the Truvera [Workspace](../../workspace/creating-api-keys-and-webhook-endpoints.md#h_fae99467a4) to listen to didcomm\_message\_received event. 
82+
83+
You can also get all the received messages using the API.
84+
85+
{% openapi-operation spec="dock-labs-api" path="/messaging/messages" method="get" %}
86+
[OpenAPI dock-labs-api](https://swagger-api.truvera.io/openapi.yaml)
87+
{% endopenapi-operation %}
88+
89+
To get the message content make an API call to retrieve the full response.
90+
91+
{% openapi-operation spec="dock-labs-api" path="/messaging/messages/{messageId}" method="get" %}
92+
[OpenAPI dock-labs-api](https://swagger-api.truvera.io/openapi.yaml)
93+
{% endopenapi-operation %}
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# Messaging
2-
3-
Operations about DIDComm messaging. DIDComm messages are addressed by DID using Dock's relay service.
4-
5-
The current most common use case for the messaging service is to send credentials and presentation requests to the Truvera Wallet, but other clients can use it too.
1+
# Messaging API calls
62

73
## Encrypt Message
84

@@ -16,19 +12,19 @@ In most cases you'll want to ensure the privacy of the message by encrypting it
1612

1713
<table data-full-width="false"><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td>» algorithm</td><td>ECDH-1PU+A256KW</td></tr><tr><td>» algorithm</td><td>ECDH-ES+A256KW</td></tr></tbody></table>
1814

19-
{% swagger src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/encrypt" method="post" %}
15+
{% openapi src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/encrypt" method="post" %}
2016
[https://swagger-api.truvera.io/openapi.yaml](https://swagger-api.truvera.io/openapi.yaml)
21-
{% endswagger %}
17+
{% endopenapi %}
2218

2319
## Decrypt Message
2420

2521
### Parameters <a href="#post__messaging_decrypt-parameters" id="post__messaging_decrypt-parameters"></a>
2622

2723
<table data-full-width="false"><thead><tr><th>Name</th><th>In</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>body</td><td>body</td><td>object</td><td>true</td><td>The JWM</td></tr><tr><td>» jwe</td><td>body</td><td>object</td><td>true</td><td>none</td></tr></tbody></table>
2824

29-
{% swagger src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/decrypt" method="post" %}
25+
{% openapi src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/decrypt" method="post" %}
3026
[https://swagger-api.truvera.io/openapi.yaml](https://swagger-api.truvera.io/openapi.yaml)
31-
{% endswagger %}
27+
{% endopenapi %}
3228

3329
## Signing Messages
3430

@@ -38,9 +34,9 @@ Signing a message helps to prove to the recipient that the message is valid and
3834

3935
<table data-full-width="false"><thead><tr><th width="169">Name</th><th width="79">In</th><th width="89">Type</th><th width="108">Required</th><th>Description</th></tr></thead><tbody><tr><td>body</td><td>body</td><td>object</td><td>true</td><td>The message payload</td></tr><tr><td>» payload</td><td>body</td><td>object</td><td>true</td><td>none</td></tr><tr><td>» senderDid</td><td>body</td><td>string</td><td>true</td><td>none</td></tr><tr><td>» type</td><td>body</td><td>string</td><td>false</td><td>none</td></tr></tbody></table>
4036

41-
{% swagger src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/sign" method="post" %}
37+
{% openapi src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/sign" method="post" %}
4238
[https://swagger-api.truvera.io/openapi.yaml](https://swagger-api.truvera.io/openapi.yaml)
43-
{% endswagger %}
39+
{% endopenapi %}
4440

4541
## Verifying a Message
4642

@@ -50,11 +46,9 @@ Verify that the message is valid.
5046

5147
<table data-full-width="false"><thead><tr><th width="112">Name</th><th width="88">In</th><th width="110">Type</th><th width="135">Required</th><th>Description</th></tr></thead><tbody><tr><td>body</td><td>body</td><td>object</td><td>true</td><td>The message payload</td></tr><tr><td>» jws</td><td>body</td><td>string</td><td>true</td><td>none</td></tr></tbody></table>
5248

53-
{% swagger src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/verify" method="post" %}
49+
{% openapi src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/verify" method="post" %}
5450
[https://swagger-api.truvera.io/openapi.yaml](https://swagger-api.truvera.io/openapi.yaml)
55-
{% endswagger %}
56-
57-
51+
{% endopenapi %}
5852

5953
## Send Message
6054

@@ -66,6 +60,6 @@ The `typ` attribute must be a DIDComm type (i.e. starts with "application/didcom
6660

6761
<table data-full-width="false"><thead><tr><th width="134">Name</th><th width="83">In</th><th width="107">Type</th><th width="116">Required</th><th>Description</th></tr></thead><tbody><tr><td>body</td><td>body</td><td>object</td><td>true</td><td>The message payload</td></tr><tr><td>» to</td><td>body</td><td>string</td><td>true</td><td>none</td></tr><tr><td>» message</td><td>body</td><td>Message</td><td>true</td><td>none</td></tr></tbody></table>
6862

69-
{% swagger src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/send" method="post" %}
63+
{% openapi src="https://swagger-api.truvera.io/openapi.yaml" path="/messaging/send" method="post" %}
7064
[https://swagger-api.truvera.io/openapi.yaml](https://swagger-api.truvera.io/openapi.yaml)
71-
{% endswagger %}
65+
{% endopenapi %}

0 commit comments

Comments
 (0)