github.com/hyperledger/aries-framework-go@v0.3.2/pkg/client/issuecredential/doc.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  // Package issuecredential provides support for the Issue Credential Protocol 2.0:
     8  // https://github.com/hyperledger/aries-rfcs/blob/master/features/0453-issue-credential-v2/README.md.
     9  //
    10  // Formalizes messages used to issue a credential. The protocol is responsible for orchestrating
    11  // the message flow according to the RFC.
    12  //
    13  // 1. Create your client:
    14  //
    15  // 	client, err := issuecredential.New(ctx)
    16  // 	if err != nil {
    17  // 	 panic(err)
    18  // 	}
    19  //
    20  // 2. Register an action event channel.
    21  //
    22  // 	actions := make(chan service.DIDCommAction)
    23  // 	client.RegisterActionEvent(actions)
    24  //
    25  // 3. Handle incoming actions.
    26  //
    27  //  for {
    28  //    select {
    29  //      case event := <-actions:
    30  //        piid := e.Properties.All()["piid"].(string)
    31  //
    32  //        if event.Message.Type() == presentproof.ProposeCredentialMsgType {
    33  //          // If Issuer is willing to accept the proposal.
    34  //          client.AcceptProposalV2(piid, &OfferCredentialV2{})
    35  //          // If Issuer is not willing to accept the proposal.
    36  //          client.DeclineProposal(piid, reason)
    37  //        }
    38  //
    39  //        if event.Message.Type() == presentproof.OfferCredentialMsgType {
    40  //          // If Holder is willing to accept the offer.
    41  //          client.AcceptOfferV2(piid)
    42  //          // If Holder wants to counter an offer they received with a proposal.
    43  //          client.NegotiateProposalV2(piid, &ProposeCredentialV2{})
    44  //          // If Holder is not willing to accept the offer.
    45  //          client.DeclineOffer(piid, reason)
    46  //        }
    47  //
    48  //        if event.Message.Type() == presentproof.RequestCredentialMsgType {
    49  //          // If Issuer is willing to accept the request.
    50  //          client.AcceptRequestV2(piid, &IssueCredentialV2{})
    51  //          // If Issuer is not willing to accept the request.
    52  //          client.DeclineRequest(piid, reason)
    53  //        }
    54  //        if event.Message.Type() == presentproof.IssueCredentialMsgType {
    55  //          // If Holder is willing to accept the credentials.
    56  //          client.AcceptCredential(piid, names)
    57  //          // If Holder is not willing to accept the credentials.
    58  //          client.DeclineCredential(piid, reason)
    59  //        }
    60  //
    61  //        if event.Message.Type() == presentproof.ProblemReportMsgType {
    62  //          // Problem report message is triggered to notify client about the error.
    63  //          // In that case, there is only one option - accept it.
    64  //          client.AcceptProblemReport(piid)
    65  //        }
    66  //    }
    67  //  }
    68  //
    69  // How to initiate the protocol?
    70  // The protocol can be initiated by the Issuer or by the Holder.
    71  // Issuer initiates the protocol.
    72  //  client.SendOfferV2(&OfferCredentialV2{}, myDID, theirDID)
    73  // Holder initiates the protocol. There are two options of how to initiate the protocol.
    74  //
    75  // 1. The Holder can begin with a proposal.
    76  //  client.SendProposalV2(&ProposeCredentialV2{}, myDID, theirDID)
    77  // 2. Holder can begin with a request.
    78  //  client.SendRequestV2(&RequestCredentialV2{}, myDID, theirDID)
    79  //
    80  package issuecredential