mediator

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 21 Imported by: 19

Documentation

Index

Constants

View Source
const (
	// Coordination route coordination protocol.
	Coordination = "coordinatemediation"

	// RouteCoordinationSpec defines the route coordination spec.
	CoordinationSpec = "https://didcomm.org/coordinatemediation/1.0/"

	// RouteRequestMsgType defines the route coordination request message type.
	RequestMsgType = CoordinationSpec + "mediate-request"

	// RouteGrantMsgType defines the route coordination request grant message type.
	GrantMsgType = CoordinationSpec + "mediate-grant"

	// KeyListUpdateMsgType defines the route coordination key list update message type.
	KeylistUpdateMsgType = CoordinationSpec + "keylist_update"

	// KeyListUpdateResponseMsgType defines the route coordination key list update message response type.
	KeylistUpdateResponseMsgType = CoordinationSpec + "keylist_update_response"
)

constants for route coordination spec types.

Variables

View Source
var ErrConnectionNotFound = errors.New("connection not found")

ErrConnectionNotFound connection not found error.

View Source
var ErrRouterNotRegistered = errors.New("router not registered")

ErrRouterNotRegistered router not registered error.

Functions

func AddKeyToRouter

func AddKeyToRouter(routeSvc ProtocolService, connID, recKey string) error

AddKeyToRouter util to add the recipient keys to the router.

func GetRouterConfig

func GetRouterConfig(routeSvc ProtocolService, connID, endpoint string) (string, []string, error)

GetRouterConfig util to get the router configuration. The endpoint is overridden with routers endpoint, if router is registered. Returns endpoint, routingKeys and error.

Types

type ClientOption

type ClientOption func(opts *ClientOptions)

ClientOption configures the route client.

type ClientOptions

type ClientOptions struct {
	Timeout time.Duration
}

ClientOptions holds options for the router client.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config provides the router configuration.

func NewConfig

func NewConfig(endpoint string, keys []string) *Config

NewConfig creates new config instance.

func (*Config) Endpoint

func (c *Config) Endpoint() string

Endpoint returns router endpoint.

func (*Config) Keys

func (c *Config) Keys() []string

Keys returns routing keys.

type Grant

type Grant struct {
	Type        string   `json:"@type,omitempty"`
	ID          string   `json:"@id,omitempty"`
	Endpoint    string   `json:"endpoint,omitempty"`
	RoutingKeys []string `json:"routing_keys,omitempty"`
}

Grant route grant message. https://github.com/hyperledger/aries-rfcs/tree/master/features/0211-route-coordination#route-grant

type KeylistUpdate

type KeylistUpdate struct {
	Type    string   `json:"@type,omitempty"`
	ID      string   `json:"@id,omitempty"`
	Updates []Update `json:"updates,omitempty"`
}

KeylistUpdate route keylist update message. https://github.com/hyperledger/aries-rfcs/tree/master/features/0211-route-coordination#keylist-update

type KeylistUpdateResponse

type KeylistUpdateResponse struct {
	Type    string           `json:"@type,omitempty"`
	ID      string           `json:"@id,omitempty"`
	Updated []UpdateResponse `json:"updated,omitempty"`
}

KeylistUpdateResponse route keylist update response message. https://github.com/hyperledger/aries-rfcs/tree/master/features/0211-route-coordination#keylist-update-response

type Options

type Options struct {
	ServiceEndpoint string
	RoutingKeys     []string
}

Options is a container for route protocol options.

type ProtocolService

type ProtocolService interface {
	// AddKey adds agents recKey to the router
	AddKey(connID, recKey string) error

	// Config gives back the router configuration
	Config(connID string) (*Config, error)

	// GetConnections returns all router connections
	GetConnections() ([]string, error)
}

ProtocolService service interface for router.

type Request

type Request struct {
	Type             string `json:"@type,omitempty"`
	ID               string `json:"@id,omitempty"`
	decorator.Timing `json:"~timing,omitempty"`
}

Request route request message. https://github.com/hyperledger/aries-rfcs/tree/master/features/0211-route-coordination#route-request

type Service

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

Service for Route Coordination protocol. https://github.com/hyperledger/aries-rfcs/tree/master/features/0211-route-coordination

func New

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

New return route coordination service.

func (*Service) Accept

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

Accept checks whether the service can handle the message type.

func (*Service) AddKey

func (s *Service) AddKey(connID, recKey string) error

AddKey adds a recKey of the agent to the registered router. This method blocks until a response is received from the router or it times out. TODO https://github.com/hyperledger/aries-framework-go/issues/1076 Support for multiple routers TODO https://github.com/hyperledger/aries-framework-go/issues/1105 Support to Add multiple

recKeys to the Router

func (*Service) Config

func (s *Service) Config(connID string) (*Config, error)

Config fetches the router config - endpoint and routingKeys.

func (*Service) GetConnections added in v0.1.5

func (s *Service) GetConnections() ([]string, error)

GetConnections returns the connections of the router.

func (*Service) HandleInbound

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

HandleInbound handles inbound route coordination messages.

func (*Service) HandleOutbound

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

HandleOutbound handles outbound route coordination 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 of the service.

func (*Service) Register

func (s *Service) Register(connectionID string, options ...ClientOption) error

Register registers the agent with the router on the other end of the connection identified by connectionID. This method blocks until a response is received from the router or it times out. The agent is registered with the router and retrieves the router endpoint and routing keys. This function throws an error if the agent is already registered against a router.

func (*Service) Unregister

func (s *Service) Unregister(connID string) error

Unregister unregisters the agent with the router.

type Update

type Update struct {
	RecipientKey string `json:"recipient_key,omitempty"`
	Action       string `json:"action,omitempty"`
}

Update route key update message.

type UpdateResponse

type UpdateResponse struct {
	RecipientKey string `json:"recipient_key,omitempty"`
	Action       string `json:"action,omitempty"`
	Result       string `json:"result,omitempty"`
}

UpdateResponse route key update response message.

Jump to

Keyboard shortcuts

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