github.com/hyperledger/aries-framework-go@v0.3.2/pkg/didcomm/transport/transport_interface.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package transport 8 9 import ( 10 "github.com/hyperledger/aries-framework-go/pkg/didcomm/common/service" 11 ) 12 13 // OutboundTransport interface definition for transport layer 14 // This is the client side of the agent. 15 type OutboundTransport interface { 16 // starts the outbound transport 17 Start(prov Provider) error 18 19 // Send send a2a exchange data 20 Send(data []byte, destination *service.Destination) (string, error) 21 22 // AcceptRecipient checks if there is a connection for the list of recipient keys. The framework executes this 23 // function before Accept() in outbound message dispatcher. 24 AcceptRecipient([]string) bool 25 26 // Accept url 27 Accept(string) bool 28 } 29 30 // Envelope holds message data and metadata for inbound and outbound messaging. 31 type Envelope struct { 32 MediaTypeProfile string 33 Message []byte 34 FromKey []byte 35 // ToKeys stores keys for an outbound message packing 36 ToKeys []string 37 // ToKey holds the key that was used to decrypt an inbound message 38 ToKey []byte 39 } 40 41 // InboundMessageHandler handles the inbound requests. The transport will unpack the payload prior to the 42 // message handle invocation. 43 type InboundMessageHandler func(envelope *Envelope) error 44 45 // Provider contains dependencies for starting the inbound/outbound transports. 46 // It is typically created by using aries.Context(). 47 type Provider interface { 48 InboundMessageHandler() InboundMessageHandler 49 Packager() Packager 50 AriesFrameworkID() string 51 } 52 53 // InboundTransport interface definition for inbound transport layer. 54 type InboundTransport interface { 55 // starts the inbound transport 56 Start(prov Provider) error 57 58 // stops the inbound transport 59 Stop() error 60 61 // returns the endpoint 62 Endpoint() string 63 } 64 65 // Packager manages the handling, building and parsing of DIDComm raw messages in JSON envelopes. 66 // 67 // These envelopes are used as wire-level wrappers of messages sent in Aries agent-agent communication. 68 type Packager interface { 69 // PackMessage Pack a message for one or more recipients. 70 // 71 // Args: 72 // 73 // envelope: The message to pack 74 // 75 // Returns: 76 // 77 // []byte: The packed message 78 // 79 // error: error 80 PackMessage(envelope *Envelope) ([]byte, error) 81 82 // UnpackMessage Unpack a message. 83 // 84 // Args: 85 // 86 // encMessage: The encrypted message 87 // 88 // Returns: 89 // 90 // envelope: unpack message 91 // 92 // error: error 93 UnpackMessage(encMessage []byte) (*Envelope, error) 94 }