github.com/hyperledger/aries-framework-go@v0.3.2/pkg/didcomm/protocol/issuecredential/models.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package issuecredential
     8  
     9  import "github.com/hyperledger/aries-framework-go/pkg/didcomm/protocol/decorator"
    10  
    11  // ProposeCredentialV2 is an optional message sent by the potential Holder to the Issuer
    12  // to initiate the protocol or in response to a offer-credential message when the Holder
    13  // wants some adjustments made to the credential data offered by Issuer.
    14  type ProposeCredentialV2 struct {
    15  	Type string `json:"@type,omitempty"`
    16  	// Comment is an optional field that provides human readable information about this Credential Offer,
    17  	// so the offer can be evaluated by human judgment.
    18  	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300]
    19  	Comment string `json:"comment,omitempty"`
    20  	// CredentialProposal is an optional JSON-LD object that represents
    21  	// the credential data that the Prover wants to receive.
    22  	CredentialProposal PreviewCredential `json:"credential_proposal,omitempty"`
    23  	// Formats contains an entry for each filters~attach array entry, providing the the value of the attachment @id
    24  	// and the verifiable credential format and version of the attachment.
    25  	Formats []Format `json:"formats,omitempty"`
    26  	// FiltersAttach is an array of attachments that further define the credential being proposed.
    27  	// This might be used to clarify which formats or format versions are wanted.
    28  	FiltersAttach []decorator.Attachment `json:"filters~attach,omitempty"`
    29  	// Optional field containing ID of the invitation which initiated this protocol.
    30  	InvitationID string `json:"invitationID,omitempty"`
    31  }
    32  
    33  // ProposeCredentialV3 is an optional message sent by the potential Holder to the Issuer
    34  // to initiate the protocol or in response to a offer-credential message when the Holder
    35  // wants some adjustments made to the credential data offered by Issuer.
    36  type ProposeCredentialV3 struct {
    37  	Type string                  `json:"type,omitempty"`
    38  	ID   string                  `json:"id,omitempty"`
    39  	Body ProposeCredentialV3Body `json:"body,omitempty"`
    40  	// Attachments is an array of attachments containing the presentation in the requested format(s).
    41  	// Accepted values for the format attribute of each attachment are provided in the per format Attachment
    42  	// registry immediately below.
    43  	Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
    44  	// Optional field containing ID of the invitation which initiated this protocol.
    45  	InvitationID string `json:"pthid,omitempty"`
    46  }
    47  
    48  // ProposeCredentialV3Body represents body for ProposeCredentialV3.
    49  type ProposeCredentialV3Body struct {
    50  	GoalCode string `json:"goal_code,omitempty"`
    51  	Comment  string `json:"comment,omitempty"`
    52  	// credentialPreview is an optional JSON-LD object that represents the credential data that Prover wants to receive.
    53  	CredentialPreview interface{} `json:"credential_preview,omitempty"`
    54  }
    55  
    56  // Format contains the value of the attachment @id and the verifiable credential format of the attachment.
    57  type Format struct {
    58  	AttachID string `json:"attach_id,omitempty"`
    59  	Format   string `json:"format,omitempty"`
    60  }
    61  
    62  // OfferCredentialV2 is a message sent by the Issuer to the potential Holder,
    63  // describing the credential they intend to offer and possibly the price they expect to be paid.
    64  // TODO: Need to add ~payment_request and ~timing.expires_time decorators [Issue #1297].
    65  type OfferCredentialV2 struct {
    66  	Type string `json:"@type,omitempty"`
    67  	// Comment is an optional field that provides human readable information about this Credential Offer,
    68  	// so the offer can be evaluated by human judgment.
    69  	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300].
    70  	Comment string `json:"comment,omitempty"`
    71  	// CredentialPreview is a JSON-LD object that represents the credential data that Issuer is willing to issue.
    72  	CredentialPreview PreviewCredential `json:"credential_preview,omitempty"`
    73  	// Formats contains an entry for each offers~attach array entry, providing the the value
    74  	// of the attachment @id and the verifiable credential format and version of the attachment.
    75  	Formats []Format `json:"formats,omitempty"`
    76  	// OffersAttach is a slice of attachments that further define the credential being offered.
    77  	// This might be used to clarify which formats or format versions will be issued.
    78  	OffersAttach []decorator.Attachment `json:"offers~attach,omitempty"`
    79  }
    80  
    81  // OfferCredentialV3 is a message sent by the Issuer to the potential Holder,
    82  // describing the credential they intend to offer and possibly the price they expect to be paid.
    83  type OfferCredentialV3 struct {
    84  	Type string                `json:"type,omitempty"`
    85  	ID   string                `json:"id,omitempty"`
    86  	Body OfferCredentialV3Body `json:"body,omitempty"`
    87  	// Attachments is an array of attachments containing the presentation in the requested format(s).
    88  	// Accepted values for the format attribute of each attachment are provided in the per format Attachment
    89  	// registry immediately below.
    90  	Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
    91  }
    92  
    93  // OfferCredentialV3Body represents body for OfferCredentialV3.
    94  type OfferCredentialV3Body struct {
    95  	GoalCode      string `json:"goal_code,omitempty"`
    96  	Comment       string `json:"comment,omitempty"`
    97  	ReplacementID string `json:"replacement_id,omitempty"`
    98  	// credentialPreview is an optional JSON-LD object that represents the credential data that Prover wants to receive.
    99  	CredentialPreview interface{} `json:"credential_preview,omitempty"`
   100  }
   101  
   102  // RequestCredentialV2 is a message sent by the potential Holder to the Issuer,
   103  // to request the issuance of a credential. Where circumstances do not require
   104  // a preceding Offer Credential message (e.g., there is no cost to issuance
   105  // that the Issuer needs to explain in advance, and there is no need for cryptographic negotiation),
   106  // this message initiates the protocol.
   107  // TODO: Need to add ~payment-receipt decorator [Issue #1298].
   108  type RequestCredentialV2 struct {
   109  	Type string `json:"@type,omitempty"`
   110  	// Comment is an optional field that provides human readable information about this Credential Offer,
   111  	// so the offer can be evaluated by human judgment.
   112  	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300].
   113  	Comment string `json:"comment,omitempty"`
   114  	// Formats contains an entry for each requests~attach array entry, providing the the value
   115  	// of the attachment @id and the verifiable credential format and version of the attachment.
   116  	Formats []Format `json:"formats,omitempty"`
   117  	// RequestsAttach is a slice of attachments defining the requested formats for the credential
   118  	RequestsAttach []decorator.Attachment `json:"requests~attach,omitempty"`
   119  }
   120  
   121  // RequestCredentialV3 is a message sent by the potential Holder to the Issuer,
   122  // to request the issuance of a credential. Where circumstances do not require
   123  // a preceding Offer Credential message (e.g., there is no cost to issuance
   124  // that the Issuer needs to explain in advance, and there is no need for cryptographic negotiation),
   125  // this message initiates the protocol.
   126  type RequestCredentialV3 struct {
   127  	Type string                  `json:"type,omitempty"`
   128  	ID   string                  `json:"id,omitempty"`
   129  	Body RequestCredentialV3Body `json:"body,omitempty"`
   130  	// Attachments is an array of attachments containing the presentation in the requested format(s).
   131  	// Accepted values for the format attribute of each attachment are provided in the per format Attachment
   132  	// registry immediately below.
   133  	Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
   134  }
   135  
   136  // RequestCredentialV3Body represents body for RequestCredentialV3.
   137  type RequestCredentialV3Body struct {
   138  	GoalCode string `json:"goal_code,omitempty"`
   139  	Comment  string `json:"comment,omitempty"`
   140  }
   141  
   142  // IssueCredentialV2 contains as attached payload the credentials being issued and is
   143  // sent in response to a valid Invitation Credential message.
   144  // TODO: Need to add ~please-ack decorator [Issue #1299].
   145  type IssueCredentialV2 struct { //nolint: golint
   146  	Type string `json:"@type,omitempty"`
   147  	// Comment is an optional field that provides human readable information about this Credential Offer,
   148  	// so the offer can be evaluated by human judgment.
   149  	// TODO: Should follow DIDComm conventions for l10n. [Issue #1300].
   150  	Comment string `json:"comment,omitempty"`
   151  	// Formats contains an entry for each credentials~attach array entry, providing the value
   152  	// of the attachment @id and the verifiable credential format and version of the attachment.
   153  	Formats []Format `json:"formats,omitempty"`
   154  	// CredentialsAttach is a slice of attachments containing the issued credentials.
   155  	CredentialsAttach []decorator.Attachment `json:"credentials~attach,omitempty"`
   156  	// WebRedirect contains optional web redirect info to be sent to holder for redirect.
   157  	WebRedirect *decorator.WebRedirect `json:"~web-redirect,omitempty"`
   158  }
   159  
   160  // IssueCredentialV3 contains as attached payload the credentials being issued and is
   161  // sent in response to a valid Invitation Credential message.
   162  type IssueCredentialV3 struct { //nolint: golint
   163  	Type string                `json:"type,omitempty"`
   164  	ID   string                `json:"id,omitempty"`
   165  	Body IssueCredentialV3Body `json:"body,omitempty"`
   166  	// WebRedirect contains optional web redirect info to be sent to holder for redirect.
   167  	WebRedirect *decorator.WebRedirect `json:"web_redirect,omitempty"`
   168  	// Attachments is an array of attachments containing the presentation in the requested format(s).
   169  	// Accepted values for the format attribute of each attachment are provided in the per format Attachment
   170  	// registry immediately below.
   171  	Attachments []decorator.AttachmentV2 `json:"attachments,omitempty"`
   172  }
   173  
   174  // IssueCredentialV3Body represents body for IssueCredentialV3.
   175  type IssueCredentialV3Body struct { //nolint: golint
   176  	GoalCode      string `json:"goal_code,omitempty"`
   177  	ReplacementID string `json:"replacement_id,omitempty"`
   178  	Comment       string `json:"comment,omitempty"`
   179  }
   180  
   181  // PreviewCredential is used to construct a preview of the data for the credential that is to be issued.
   182  type PreviewCredential struct {
   183  	Type       string      `json:"@type,omitempty"`
   184  	Attributes []Attribute `json:"attributes,omitempty"`
   185  }
   186  
   187  // PreviewCredentialV3 is used to construct a preview of the data for the credential that is to be issued.
   188  type PreviewCredentialV3 struct {
   189  	Type string                `json:"type,omitempty"`
   190  	ID   string                `json:"id,omitempty"`
   191  	Body IssueCredentialV3Body `json:"body,omitempty"`
   192  }
   193  
   194  // PreviewCredentialV3Body represents body for PreviewCredentialV3.
   195  type PreviewCredentialV3Body struct {
   196  	Attributes []Attribute `json:"attributes,omitempty"`
   197  }
   198  
   199  // Attribute describes an attribute for a Preview Credential.
   200  type Attribute struct {
   201  	Name     string `json:"name,omitempty"`
   202  	MimeType string `json:"mime-type,omitempty"`
   203  	Value    string `json:"value,omitempty"`
   204  }