introduce

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 12 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// Introduce protocol name.
	Introduce = "introduce"
	// IntroduceSpec defines the introduce spec.
	IntroduceSpec = "https://didcomm.org/introduce/1.0/"
	// ProposalMsgType defines the introduce proposal message type.
	ProposalMsgType = IntroduceSpec + "proposal"
	// RequestMsgType defines the introduce request message type.
	RequestMsgType = IntroduceSpec + "request"
	// ResponseMsgType defines the introduce response message type.
	ResponseMsgType = IntroduceSpec + "response"
	// AckMsgType defines the introduce ack message type.
	AckMsgType = IntroduceSpec + "ack"
	// ProblemReportMsgType defines the introduce problem-report message type.
	ProblemReportMsgType = IntroduceSpec + "problem-report"
)

Variables

This section is empty.

Functions

func CreateProposal added in v0.1.2

func CreateProposal(r *Recipient) service.DIDCommMsgMap

CreateProposal creates a DIDCommMsgMap proposal.

func WrapWithMetadataPIID added in v0.1.2

func WrapWithMetadataPIID(msgMap ...service.DIDCommMsg)

WrapWithMetadataPIID wraps message with metadata. The function is used by the introduce client to define that a few messages are related to each other. e.g When two proposals are sent simultaneously piID helps the protocol to determine that messages are related.

func WrapWithMetadataPublicOOBRequest added in v0.1.3

func WrapWithMetadataPublicOOBRequest(msg service.DIDCommMsgMap, req *outofband.Request)

WrapWithMetadataPublicOOBRequest wraps message with metadata. The function is used by the introduce client to define skip proposal. It also saves invitation and will provide it later to the introducee.

Types

type Action added in v0.1.2

type Action struct {
	// Protocol instance ID
	PIID     string
	Msg      service.DIDCommMsgMap
	MyDID    string
	TheirDID string
}

Action contains helpful information about action.

type Content

type Content struct {
	Link      string `json:"link,omitempty"`
	ByteCount int    `json:"byte_count,omitempty"`
	Sha256    string `json:"sha256,omitempty"`
}

Content keeps image data.

type DescriptionL10N

type DescriptionL10N map[string]string

DescriptionL10N may contain locale field and key->val pair for translation e.g { "locale": "en", "es": "Donde se toma el MRI; no en el centro"}, where locale field tells that field Description form To struct has en translation.

func (DescriptionL10N) Locale

func (d DescriptionL10N) Locale() string

Locale returns locale for the specified description (To.Description).

type ImgAttach

type ImgAttach struct {
	Description string  `json:"description,omitempty"`
	MimeType    string  `json:"mime-type,omitempty"`
	Filename    string  `json:"filename,omitempty"`
	Content     Content `json:"content,omitempty"`
}

ImgAttach represent information about the image.

type Opt added in v0.1.2

type Opt func(m map[string]interface{})

Opt describes option signature for the Continue function.

func WithOOBRequest added in v0.1.3

func WithOOBRequest(req *outofband.Request, attachments ...*decorator.Attachment) Opt

WithOOBRequest is used when introducee wants to provide an out-of-band request. NOTE: Introducee can provide this request only after receiving ProposalMsgType USAGE: event.Continue(WithOOBRequest(req)).

func WithPublicOOBRequest added in v0.1.3

func WithPublicOOBRequest(req *outofband.Request, to *To) Opt

WithPublicOOBRequest is used when introducer wants to provide public an out-of-band request. NOTE: Introducer can provide this request only after receiving RequestMsgType USAGE: event.Continue(WithPublicOOBRequest(req, to)).

func WithRecipients added in v0.1.2

func WithRecipients(to *To, recipient *Recipient) 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)).

type PleaseIntroduceTo

type PleaseIntroduceTo struct {
	// nolint: staticcheck
	To `json:",squash"`
}

PleaseIntroduceTo includes all field from To structure also it has Discovered the field which should be provided by help-me-discover protocol.

type Proposal

type Proposal struct {
	Type     string            `json:"@type,omitempty"`
	ID       string            `json:"@id,omitempty"`
	To       *To               `json:"to,omitempty"`
	NWise    bool              `json:"nwise,omitempty"`
	Thread   *decorator.Thread `json:"~thread,omitempty"`
	Timing   *decorator.Timing `json:"~timing,omitempty"`
	Goal     string            `json:"goal,omitempty"`
	GoalCode string            `json:"goal-code,omitempty"`
}

Proposal defines proposal request.

type Provider added in v0.1.1

type Provider interface {
	Messenger() service.Messenger
	StorageProvider() storage.Provider
	Service(id string) (interface{}, error)
}

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

type Recipient added in v0.1.1

type Recipient struct {
	To       *To    `json:"to"`
	Goal     string `json:"goal"`
	GoalCode string `json:"goal_code"`
	MyDID    string `json:"my_did,omitempty"`
	TheirDID string `json:"their_did,omitempty"`
}

Recipient keeps information needed for the service 'To' field is needed for the proposal message 'MyDID' and 'TheirDID' fields are needed for sending messages e.g report-problem, proposal, ack etc.

type Request

type Request struct {
	Type              string             `json:"@type,omitempty"`
	ID                string             `json:"@id,omitempty"`
	PleaseIntroduceTo *PleaseIntroduceTo `json:"please_introduce_to,omitempty"`
	NWise             bool               `json:"nwise,omitempty"`
	Timing            *decorator.Timing  `json:"~timing,omitempty"`
}

Request is not part of any state machine, it can be sent at any time, and when it is received, the recipient can choose whether or not to honor it in their own way TODO: need to clarify about decorator ~please_ack and problem_report

should Request contain those fields? What type it should be for each field?

type Response

type Response struct {
	Type        string                  `json:"@type,omitempty"`
	ID          string                  `json:"@id,omitempty"`
	Thread      *decorator.Thread       `json:"~thread,omitempty"`
	Approve     bool                    `json:"approve,omitempty"`
	OOBMessage  map[string]interface{}  `json:"oob-message,omitempty"`
	Attachments []*decorator.Attachment `json:"~attach,omitempty"`
}

Response message that introducee usually sends in response to an introduction proposal.

type Service

type Service struct {
	service.Action
	service.Message
	// contains filtered or unexported fields
}

Service for introduce protocol.

func New

func New(p Provider) (*Service, error)

New returns introduce service.

func (*Service) Accept

func (s *Service) Accept(msgType string) bool

Accept msg checks the msg type.

func (*Service) ActionContinue added in v0.1.4

func (s *Service) ActionContinue(piID string, opt Opt) error

ActionContinue allows proceeding with the action by the piID.

func (*Service) ActionStop added in v0.1.4

func (s *Service) ActionStop(piID string, cErr error) error

ActionStop allows stopping the action by the piID.

func (*Service) Actions added in v0.1.2

func (s *Service) Actions() ([]Action, error)

Actions returns actions for the async usage.

func (*Service) HandleInbound

func (s *Service) HandleInbound(msg service.DIDCommMsg, myDID, theirDID string) (string, error)

HandleInbound handles inbound message (introduce protocol).

func (*Service) HandleOutbound

func (s *Service) HandleOutbound(msg service.DIDCommMsg, myDID, theirDID string) (string, error)

HandleOutbound handles outbound message (introduce protocol).

func (*Service) Name

func (s *Service) Name() string

Name returns service name.

func (*Service) OOBMessageReceived added in v0.1.3

func (s *Service) OOBMessageReceived(msg service.StateMsg) error

OOBMessageReceived is used to finish the state machine the function should be called by the out-of-band service after receiving an oob message.

type To

type To struct {
	Name            string          `json:"name,omitempty"`
	Description     string          `json:"description,omitempty"`
	DescriptionL10N DescriptionL10N `json:"description~l10n,omitempty"`
	Where           string          `json:"where,omitempty"`
	ImgAttach       ImgAttach       `json:"img~attach,omitempty"`
	Proposed        bool            `json:"proposed,omitempty"`
}

To introducee descriptor keeps information about the introduction e.g introducer wants to introduce Bot to introducee { "name": "Bob" }.

Jump to

Keyboard shortcuts

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