Skip to content

Commit

Permalink
feat: correlating invitation with propose credential message
Browse files Browse the repository at this point in the history
- WACI way of using invitation as parent threadID may not work with
DIDCommV1 where parent thread ID gets reset by messenger while sending
propose credential message
- As a work around, invitation ID can be explicitly used while sending
propose credential message
- Part of hyperledger-archives#3073

Signed-off-by: sudesh.shetty <sudesh.shetty@securekey.com>
  • Loading branch information
sudeshrshetty committed Jan 6, 2022
1 parent 1f7d634 commit 6011ca4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/didcomm/protocol/issuecredential/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type ProposeCredentialV2 struct {
// FiltersAttach is an array of attachments that further define the credential being proposed.
// This might be used to clarify which formats or format versions are wanted.
FiltersAttach []decorator.Attachment `json:"filters~attach,omitempty"`
// Optional field containing ID of the invitation which initiated this protocol.
InvitationID string `json:"invitationID,omitempty"`
}

// ProposeCredentialV3 is an optional message sent by the potential Holder to the Issuer
Expand All @@ -39,6 +41,8 @@ type ProposeCredentialV3 struct {
// Accepted values for the format attribute of each attachment are provided in the per format Attachment
// registry immediately below.
Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
// Optional field containing ID of the invitation which initiated this protocol.
InvitationID string `json:"pthid,omitempty"`
}

// ProposeCredentialV3Body represents body for ProposeCredentialV3.
Expand Down
7 changes: 5 additions & 2 deletions pkg/didcomm/protocol/issuecredential/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ProposeCredentialParams struct {
Formats []Format
GoalCode string
CredentialPreview interface{}
InvitationID string
}

// AsV2 translates this credential proposal into an issue credential 2.0 proposal message.
Expand All @@ -32,14 +33,16 @@ func (p *ProposeCredentialParams) AsV2() *ProposeCredentialV2 {
CredentialProposal: p.CredentialProposal,
Formats: p.Formats,
FiltersAttach: decorator.GenericAttachmentsToV1(p.Attachments),
InvitationID: p.InvitationID,
}
}

// AsV3 translates this credential proposal into an issue credential 3.0 proposal message.
func (p *ProposeCredentialParams) AsV3() *ProposeCredentialV3 {
return &ProposeCredentialV3{
Type: p.Type,
ID: p.ID,
Type: p.Type,
ID: p.ID,
InvitationID: p.InvitationID,
Body: ProposeCredentialV3Body{
GoalCode: p.GoalCode,
Comment: p.Comment,
Expand Down
5 changes: 4 additions & 1 deletion pkg/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,10 @@ func (c *Wallet) ProposeCredential(authToken string, invitation *GenericInvitati

opts = prepareInteractionOpts(connRecord, opts)

_, err = c.issueCredentialClient.SendProposal(&issuecredential.ProposeCredential{}, connRecord)
_, err = c.issueCredentialClient.SendProposal(
&issuecredential.ProposeCredential{InvitationID: invitation.ID},
connRecord,
)
if err != nil {
return nil, fmt.Errorf("failed to propose credential from wallet: %w", err)
}
Expand Down

0 comments on commit 6011ca4

Please sign in to comment.