didcomm

package
v0.25.24 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package didcomm is package to offer interfaces for all types of the didcomm messages. The package helps to abstract indy's legacy messages as well as new Aries messages. Corresponding packages are mesg and aries.

The package offers needed interfaces, some helper functions and variables. More information can be found from each individual type.

Index

Constants

This section is empty.

Variables

View Source
var CreatorGod = God{}

CreatorGod creates payloads and messages by namespace string.

Functions

func FieldAtInd

func FieldAtInd(s string, where int) string

Types

type CredentialAttribute

type CredentialAttribute struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

CredentialAttribute for credential value

type Factor

type Factor interface {
	NewMessage(data []byte) MessageHdr
	NewMsg(init MsgInit) MessageHdr
}

type God

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

func (*God) AddMsgCreator

func (g *God) AddMsgCreator(namespace string, c MsgFactor)

func (*God) AddPayloadCreator

func (g *God) AddPayloadCreator(namespace string, c PayloadFactor)

func (*God) MsgCreator

func (g *God) MsgCreator(namespace string) MsgFactor

func (*God) MsgCreatorByType

func (g *God) MsgCreatorByType(t string) MsgFactor

func (*God) PayloadCreator

func (g *God) PayloadCreator(namespace string) PayloadFactor

func (*God) PayloadCreatorByType

func (g *God) PayloadCreatorByType(t string) PayloadFactor

type JSONSpeaker

type JSONSpeaker interface {
	JSON() []byte
}

type MessageHdr

type MessageHdr interface {
	PayloadHdr
	PayloadWriteHdr

	JSON() []byte
	Thread() *decorator.Thread
	FieldObj() interface{}
}

MessageHdr is the base interface for all protocol messages. It has the minimum needed to handle and process inbound and outbound protocol messages. The are message factors to help creation of these messages as well. This is the interface which should be used for all common references to didcomm messages. Please be noted that there still is a Payload concept which is a envelope level abstraction, and works well with the message.

type Msg

type Msg interface {
	PwMsg

	Error() string
	SetError(s string)
	Info() string
	TimestampMs() *uint64
	ConnectionInvitation() *didexchange.Invitation
	CredentialAttributes() *[]CredentialAttribute
	CredDefID() *string
	ProofAttributes() *[]ProofAttribute
	ProofValues() *[]ProofValue

	SubLevelID() string
	SetSubLevelID(s string)

	Schema() *ssi.Schema
	SetSchema(sch *ssi.Schema)

	ReceiverEP() service.Addr

	SetRcvrEndp(ae service.Addr)
	SetNonce(n string)
	SetReady(yes bool)
	SetBody(b interface{})
	SetSubMsg(sm map[string]interface{})
	SetDid(s string)
	SetVerKey(s string)
	SetInfo(s string)
	SetInvitation(i *didexchange.Invitation)

	Ready() bool
	SubMsg() map[string]interface{}
}

Msg is a legacy interface for before Aries message protocols. For new Aries protocols it isn't recommended to use it, but use MessageHdr instead.

type MsgFactor

type MsgFactor interface {
	Factor

	Create(mcd MsgInit) MessageHdr
}

type MsgInit

type MsgInit struct {
	AID         string
	Type        string
	Nonce       string
	Error       string
	Encrypted   string
	Did         string
	VerKey      string
	Endpoint    string
	EndpVerKey  string
	RcvrEndp    service.Addr
	Name        string
	Info        string
	ID          string
	Ready       bool
	Msg         map[string]interface{}
	Body        interface{}
	ProofValues *[]ProofValue
	Thread      *decorator.Thread
	DIDObj      *ssi.DID
}

MsgInit is a helper struct for factors to construct new message instances.

type Payload

type Payload interface {
	PayloadHdr
	PayloadThread
	JSONSpeaker

	SetType(t string)

	Creator() PayloadFactor
	MsgCreator() MsgFactor

	FieldObj() interface{}

	Message() Msg       // this is mostly for legacy message handling, before Aries
	MsgHdr() MessageHdr // this generic and preferable way to get the message

	Protocol() string
	ProtocolMsg() string
	Namespace() string
}

type PayloadFactor

type PayloadFactor interface {
	NewFromData(data []byte) Payload
	New(pi PayloadInit) Payload
	NewMsg(id, t string, m MessageHdr) Payload
}

type PayloadHdr

type PayloadHdr interface {
	ID() string
	Type() string
}

type PayloadInit

type PayloadInit struct {
	ID   string
	Type string
	MsgInit
}

type PayloadThread

type PayloadThread interface {
	Thread() *decorator.Thread
	SetThread(t *decorator.Thread)
	ThreadID() string
}

type PayloadWriteHdr

type PayloadWriteHdr interface {
	SetID(id string)
	SetType(t string)
}

type ProofAttribute

type ProofAttribute struct {
	ID        string `json:"-"`
	Name      string `json:"name,omitempty"`
	CredDefID string `json:"credDefId,omitempty"`
	Predicate string `json:"predicate,omitempty"`
	Value     string `json:"-"`
}

ProofAttribute for proof request attributes

type ProofPredicate added in v0.24.26

type ProofPredicate struct {
	ID     string `json:"-"`
	Name   string `json:"name,omitempty"`
	PType  string `json:"p_type,omitempty"`
	PValue int64  `json:"p_value,omitempty"`
}

ProofPredicate for proof request predicates

type ProofValue

type ProofValue struct {
	Name      string `json:"name,omitempty"`
	Value     string `json:"value,omitempty"`
	CredDefID string `json:"credDefId,omitempty"`
	Predicate string `json:"predicate,omitempty"`
}

ProofValue for proof values

type PwMsg

type PwMsg interface {
	MessageHdr
	Reply

	Endpoint() service.Addr
	SetEndpoint(ae service.Addr)
	Did() string
	VerKey() string
	Name() string // Todo: should be named as a Label? That's in the standard
}

PwMsg is an interface for pairwise level messages. With this interface we have managed to abstract and implement both old indy agent2agent handshake and the Aries connection protocol. In the future there is chance that we are able to do the same for Aries did exchange protocol.

type Reply

type Reply interface {
	Nonce() string
}

Reply is an interface for having a common nonce with the protocol messages. Our old system did use Nonce as common id during the whole protocol conversation, not only as a message reply id. In Aries implementation this is implemented with Thread decorator, where you can use both of them.

Jump to

Keyboard shortcuts

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