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 ¶
- func WithInvitation(inv *didexchange.Invitation) introduce.Opt
- func WithPublicInvitation(inv *didexchange.Invitation, to *introduce.To) introduce.Opt
- func WithRecipients(to *introduce.To, recipient *introduce.Recipient) introduce.Opt
- type Client
- func (c *Client) AcceptProposal(piID string, inv *didexchange.Invitation) error
- func (c *Client) AcceptRequestWithPublicInvitation(piID string, inv *didexchange.Invitation, to *introduce.To) error
- func (c *Client) AcceptRequestWithRecipients(piID string, to *introduce.To, recipient *introduce.Recipient) error
- func (c *Client) Actions() ([]introduce.Action, error)
- func (c *Client) SendProposal(recipient1, recipient2 *introduce.Recipient) error
- func (c *Client) SendProposalWithInvitation(inv *didexchange.Invitation, recipient *introduce.Recipient) error
- func (c *Client) SendRequest(to *introduce.PleaseIntroduceTo, myDID, theirDID string) error
- type ProtocolService
- type Provider
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
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 ¶
Client enable access to introduce API
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) SendProposal ¶
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.