introduce

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Overview

Package introduce is responsible for the introduction between agents. The protocol involves at least two participants. A maximum of three participants is currently supported. The example below shows how to use the client.

introduce := client.New(...)
introduce.RegisterActionEvent(actions)
for {
  select {
    case event := <-actions:
      if event.Message.Type() == introduce.RequestMsgType {
        // if you want to accept request and you do not have a public invitation
        event.Continue(WithRecipients(...))
        // or you have a public invitation
        event.Continue(WithPublicInvitation(...))
      } else {
        // to share your invitation
        event.Continue(WithInvitation(...))
        // or if you do now want to share your invitation
        event.Continue(nil)
      }
  }
}

Possible use cases: 1) The introducer wants to commit an introduction. To do that SendProposal or SendProposalWithInvitation functions should be used. SendProposalWithInvitation is used in case if introducer has a public invitation. Otherwise, SendProposal function is used. An invitation, in that case, should be provided by one of the introducees. 2) Introducee asks the introducer about the agent. SendRequest function is used to do that.

Basic Flow:
1) Prepare client context
2) Create client
3) Register for action events
4) Handle actions
5) Send proposal

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithInvitation added in v0.1.2

func WithInvitation(inv *didexchange.Invitation) introduce.Opt

WithInvitation is used when introducee wants to provide invitation. NOTE: Introducee can provide invitation only after receiving ProposalMsgType USAGE: event.Continue(WithInvitation(inv))

func WithPublicInvitation added in v0.1.2

func WithPublicInvitation(inv *didexchange.Invitation, to *introduce.To) introduce.Opt

WithPublicInvitation is used when introducer wants to provide public invitation. NOTE: Introducer can provide invitation only after receiving RequestMsgType USAGE: event.Continue(WithPublicInvitation(inv, to))

func WithRecipients added in v0.1.2

func WithRecipients(to *introduce.To, recipient *introduce.Recipient) introduce.Opt

WithRecipients is used when the introducer does not have a public invitation but he is willing to introduce agents to each other. NOTE: Introducer can provide recipients only after receiving RequestMsgType. USAGE: event.Continue(WithRecipients(to, recipient))

Types

type Client

type Client struct {
	service.Event
	// contains filtered or unexported fields
}

Client enable access to introduce API

func New

func New(ctx Provider) (*Client, error)

New return new instance of introduce client

func (*Client) AcceptProposal added in v0.1.2

func (c *Client) AcceptProposal(piID string, inv *didexchange.Invitation) error

AcceptProposal is used when introducee wants to provide invitation. NOTE: For async usage. Introducee can provide invitation only after receiving ProposalMsgType

func (*Client) AcceptRequestWithPublicInvitation added in v0.1.2

func (c *Client) AcceptRequestWithPublicInvitation(piID string, inv *didexchange.Invitation, to *introduce.To) error

AcceptRequestWithPublicInvitation is used when introducer wants to provide public invitation. NOTE: For async usage. Introducer can provide invitation only after receiving RequestMsgType

func (*Client) AcceptRequestWithRecipients added in v0.1.2

func (c *Client) AcceptRequestWithRecipients(piID string, to *introduce.To, recipient *introduce.Recipient) error

AcceptRequestWithRecipients is used when the introducer does not have a public invitation but he is willing to introduce agents to each other. NOTE: For async usage. Introducer can provide recipients only after receiving RequestMsgType.

func (*Client) Actions added in v0.1.2

func (c *Client) Actions() ([]introduce.Action, error)

Actions returns unfinished actions for the async usage

func (*Client) SendProposal

func (c *Client) SendProposal(recipient1, recipient2 *introduce.Recipient) error

SendProposal sends a proposal to the introducees (the client does not have a public Invitation).

func (*Client) SendProposalWithInvitation

func (c *Client) SendProposalWithInvitation(inv *didexchange.Invitation, recipient *introduce.Recipient) error

SendProposalWithInvitation sends a proposal to the introducee (the client has a public Invitation).

func (*Client) SendRequest

func (c *Client) SendRequest(to *introduce.PleaseIntroduceTo, myDID, theirDID string) error

SendRequest sends a request. Sending a request means that the introducee is willing to share its invitation.

type ProtocolService added in v0.1.2

type ProtocolService interface {
	service.DIDComm
	Continue(piID string, opt introduce.Opt) error
	Actions() ([]introduce.Action, error)
}

ProtocolService defines the introduce service.

type Provider

type Provider interface {
	Service(id string) (interface{}, error)
}

Provider contains dependencies for the introduce protocol and is typically created by using aries.Context()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL