Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 071ce8f

Browse files
authored
fix: outbound didcomm v2 messages always have 'body' and 'from' fields (#3209)
Signed-off-by: Filip Burlacu <[email protected]>
1 parent 18c8766 commit 071ce8f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/didcomm/common/middleware/middleware.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ type rotatePayload struct {
7777
const (
7878
fromPriorJSONKey = "from_prior"
7979
fromDIDJSONKey = "from"
80+
bodyJSONKey = "body"
8081
initialStateParam = "initialState"
8182
)
8283

@@ -160,6 +161,16 @@ func (h *DIDCommMessageMiddleware) HandleOutboundMessage(msg didcomm.DIDCommMsgM
160161
return msg
161162
}
162163

164+
// if there's no from DID, add a from DID.
165+
if _, ok := msg[fromDIDJSONKey]; !ok {
166+
msg[fromDIDJSONKey] = rec.MyDID
167+
}
168+
169+
// if there's no body, add a body.
170+
if _, ok := msg[bodyJSONKey]; !ok {
171+
msg[bodyJSONKey] = map[string]interface{}{}
172+
}
173+
163174
if rec.MyDIDRotation != nil {
164175
msg[fromPriorJSONKey] = rec.MyDIDRotation.FromPrior
165176
}

0 commit comments

Comments
 (0)