didexchange

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 30 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// DIDExchange did exchange protocol.
	DIDExchange = "didexchange"
	// PIURI is the did-exchange protocol identifier URI.
	PIURI = "https://didcomm.org/didexchange/1.0"
	// InvitationMsgType defines the did-exchange invite message type.
	InvitationMsgType = PIURI + "/invitation"
	// RequestMsgType defines the did-exchange request message type.
	RequestMsgType = PIURI + "/request"
	// ResponseMsgType defines the did-exchange response message type.
	ResponseMsgType = PIURI + "/response"
	// AckMsgType defines the did-exchange ack message type.
	AckMsgType = PIURI + "/ack"
	// CompleteMsgType defines the did-exchange complete message type.
	CompleteMsgType = PIURI + "/complete"
)
View Source
const (

	// StateIDInvited marks the invited phase of the did-exchange protocol.
	StateIDInvited = "invited"
	// StateIDRequested marks the requested phase of the did-exchange protocol.
	StateIDRequested = "requested"
	// StateIDResponded marks the responded phase of the did-exchange protocol.
	StateIDResponded = "responded"
	// StateIDCompleted marks the completed phase of the did-exchange protocol.
	StateIDCompleted = "completed"
	// StateIDAbandoned marks the abandoned phase of the did-exchange protocol.
	StateIDAbandoned = "abandoned"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Complete added in v0.1.7

type Complete struct {
	Type   string            `json:"@type,omitempty"`
	ID     string            `json:"@id,omitempty"`
	Thread *decorator.Thread `json:"~thread,omitempty"`
}

Complete defines a2a DID exchange complete message. https://github.com/hyperledger/aries-rfcs/tree/master/features/0023-did-exchange#3-exchange-complete

type Connection

type Connection struct {
	DID    string   `json:"did,omitempty"`
	DIDDoc *did.Doc `json:"did_doc,omitempty"`
}

Connection connection.

type ConnectionSignature

type ConnectionSignature struct {
	Type       string `json:"@type,omitempty"`
	Signature  string `json:"signature,omitempty"`
	SignedData string `json:"sig_data,omitempty"`
	SignVerKey string `json:"signers,omitempty"`
}

ConnectionSignature connection signature.

type Invitation

type Invitation struct {
	// the Image URL of the connection invitation
	ImageURL string `json:"imageUrl,omitempty"`

	// the Service endpoint of the connection invitation
	ServiceEndpoint string `json:"serviceEndpoint,omitempty"`

	// the RecipientKeys for the connection invitation
	RecipientKeys []string `json:"recipientKeys,omitempty"`

	// the ID of the connection invitation
	ID string `json:"@id,omitempty"`

	// the Label of the connection invitation
	Label string `json:"label,omitempty"`

	// the DID of the connection invitation
	DID string `json:"did,omitempty"`

	// the RoutingKeys of the connection invitation
	RoutingKeys []string `json:"routingKeys,omitempty"`

	// the Type of the connection invitation
	Type   string            `json:"@type,omitempty"`
	Thread *decorator.Thread `json:"~thread,omitempty"`
}

Invitation model

Invitation defines DID exchange invitation message https://github.com/hyperledger/aries-rfcs/tree/master/features/0023-did-exchange#0-invitation-to-exchange

TODO all uses of this invitation struct should be replaced with the new OOB one. The new one should be renamed

to 'Invitation'.

type OOBInvitation added in v0.1.3

type OOBInvitation struct {
	// ID of this invitation (for record-keeping purposes).
	// TODO can we remove this?
	ID string `json:"@id"`
	// TODO remove this
	Type string `json:"@type"`
	// ID of the thread from which this invitation originated.
	// This will become the parent thread ID of the didexchange protocol instance.
	ThreadID string
	// TheirLabel is the label on the other party's connection invitation.
	TheirLabel string
	// MyLabel is the label we will use during the did-exchange.
	MyLabel string
	// Target destination.
	// This can be any on of:
	// - a string with a valid DID
	// - a valid `did.Service`
	Target interface{}
	// MediaTypeProfiles are the message format profiles supported by the sender of this invitation
	// as defined in RFC 0044.
	MediaTypeProfiles []string
}

OOBInvitation to connect with did-exchange.

type Request

type Request struct {
	Type   string            `json:"@type,omitempty"`
	ID     string            `json:"@id,omitempty"`
	Label  string            `json:"label"`
	Thread *decorator.Thread `json:"~thread,omitempty"`
	// DID the did of the requester.
	// Mandatory in did-exchange, but optional for backwards-compatibility with rfc 0160 connection protocol.
	DID string `json:"did,omitempty"`
	// DocAttach an attachment containing the did doc of the requester.
	// Optional, a requester may provide a publicly-resolvable DID, rather than including an attached did doc.
	DocAttach *decorator.Attachment `json:"did_doc~attach,omitempty"`
	// Connection is used for backwards-compatibility with rfc 0160 connection protocol.
	Connection *Connection `json:"connection,omitempty"`
}

Request defines a2a DID exchange request https://github.com/hyperledger/aries-rfcs/tree/master/features/0023-did-exchange#1-exchange-request

type Response

type Response struct {
	Type                string               `json:"@type,omitempty"`
	ID                  string               `json:"@id,omitempty"`
	ConnectionSignature *ConnectionSignature `json:"connection~sig,omitempty"`
	Thread              *decorator.Thread    `json:"~thread,omitempty"`
	// DID the did of the responder.
	// Mandatory in did-exchange, but optional for backwards-compatibility with rfc 0160 connection protocol.
	DID string `json:"did,omitempty"`
	// DocAttach an attachment containing the did doc of the responder.
	// Optional, a responder may provide a publicly-resolvable DID, rather than including an attached did doc.
	DocAttach *decorator.Attachment `json:"did_doc~attach,omitempty"`
}

Response defines a2a DID exchange response https://github.com/hyperledger/aries-rfcs/tree/master/features/0023-did-exchange#2-exchange-response

type Service

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

Service for DID exchange protocol.

func New

func New(prov provider) (*Service, error)

New return didexchange service.

func (*Service) Accept

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

Accept msg checks the msg type.

func (*Service) AcceptExchangeRequest

func (s *Service) AcceptExchangeRequest(connectionID, publicDID, label string, routerConnections []string) error

AcceptExchangeRequest accepts/approves connection request.

func (*Service) AcceptInvitation

func (s *Service) AcceptInvitation(connectionID, publicDID, label string, routerConnections []string) error

AcceptInvitation accepts/approves connection invitation.

func (*Service) CreateConnection added in v0.1.4

func (s *Service) CreateConnection(record *connection.Record, theirDID *did.Doc) error

CreateConnection saves the record to the connection store and maps TheirDID to their recipient keys in the did connection store.

func (*Service) CreateImplicitInvitation added in v0.1.1

func (s *Service) CreateImplicitInvitation(inviterLabel, inviterDID,
	inviteeLabel, inviteeDID string, routerConnections []string) (string, error)

CreateImplicitInvitation creates implicit invitation. Inviter DID is required, invitee DID is optional. If invitee DID is not provided new peer DID will be created for implicit invitation exchange request.

func (*Service) HandleInbound

func (s *Service) HandleInbound(msg service.DIDCommMsg, ctx service.DIDCommContext) (string, error)

HandleInbound handles inbound didexchange messages.

func (*Service) HandleOutbound

func (s *Service) HandleOutbound(_ service.DIDCommMsg, _, _ string) (string, error)

HandleOutbound handles outbound didexchange messages.

func (*Service) Initialize added in v0.1.8

func (s *Service) Initialize(p interface{}) error

Initialize initializes the Service. If Initialize succeeds, any further call is a no-op.

func (*Service) Name

func (s *Service) Name() string

Name return service name.

func (*Service) RespondTo added in v0.1.3

func (s *Service) RespondTo(i *OOBInvitation, routerConnections []string) (string, error)

RespondTo this inbound invitation and return with the new connection record's ID.

func (*Service) SaveInvitation added in v0.1.3

func (s *Service) SaveInvitation(i *OOBInvitation) error

SaveInvitation saves this invitation created by you.

Jump to

Keyboard shortcuts

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