mesg

package
v0.24.14 Latest Latest
Warning

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

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

Documentation

Overview

Package mesg is implementation package for didcomm messages. See related package aries which is for our legacy messages. Both aries and mesg messages share same interfaces defined in the didcomm package. didcomm defines a message factor interfaces as well. With the help of the factoring system, the actual messages can be constructed from the incoming messages with the correct type. We use statically typed JSON messages i.e. they are always mapped to corresponding Go struct.

Because the development was started with indy's first agent to agent protocol, and because the message types were taken from it, we had to refactor message types when we implemented aries protocol. With the current didcomm package based messaging system we can use polymorphic approach to all of the didcomm messages. We doesn't need to know if the message is in coming indy message or aries message.

Index

Constants

This section is empty.

Variables

View Source
var MsgCreator = MsgFactor{}
View Source
var PayloadCreator = PayloadFactor{}

Functions

func NewPayloadBase

func NewPayloadBase(id, t string) didcomm.Payload

func NewPayloadImpl

func NewPayloadImpl(pl *Payload) didcomm.Payload

func NewPayloadWithMsg

func NewPayloadWithMsg(id, t string, m *Msg) didcomm.Payload

func ProtocolForType

func ProtocolForType(typeStr string) string

func ProtocolMsgForType

func ProtocolMsgForType(typeStr string) string

func SubFromJSON

func SubFromJSON(s string) (sub map[string]interface{})

func SubFromJSONData

func SubFromJSONData(data []byte) (sub map[string]interface{})

Types

type Msg

type Msg struct {
	Error           string                         `json:"error,omitempty"`           // If error happens includes error msg
	Encrypted       string                         `json:"encrypted,omitempty"`       // If the whole msg is encrypted is transferred in this field
	Did             string                         `json:"did,omitempty"`             // Usually senders DID and corresponding VerKey
	Nonce           string                         `json:"nonce,omitempty"`           // Important field to keep track receiving/sending sync
	VerKey          string                         `json:"verkey,omitempty"`          // Senders Verkey for DID
	RcvrEndp        string                         `json:"rcvr_endp,omitempty"`       // Receivers own endpoint, usually the public URL
	RcvrKey         string                         `json:"rcvr_key,omitempty"`        // Receiver endpoint ver key
	Endpoint        string                         `json:"endpoint,omitempty"`        // Multipurpose field which still is under design
	EndpVerKey      string                         `json:"endp_ver_key,omitempty"`    // VerKey associated to endpoint i.e. payload verkey
	Name            string                         `json:"name,omitempty"`            // Multipurpose field which still is under design
	Info            string                         `json:"info,omitempty"`            // Used for transferring additional info like the Msg in IM-cases, and Pairwise name
	TimestampMs     *uint64                        `json:"timestamp,omitempty"`       // Used for transferring timestamp info
	Invitation      *didexchange.Invitation        `json:"invitation,omitempty"`      // Used for connection invitation
	CredentialAttrs *[]didcomm.CredentialAttribute `json:"credAttributes,omitempty"`  // Used for credential attributes values
	CredDefID       *string                        `json:"credDefId,omitempty"`       // Used for credential definition ID
	ProofAttrs      *[]didcomm.ProofAttribute      `json:"proofAttributes,omitempty"` // Used for proof attributes
	ProofValues     *[]didcomm.ProofValue          `json:"proofValues,omitempty"`     // Used for proof values
	ID              string                         `json:"id,omitempty"`              // Used for transferring additional ID like the Cred Def ID
	Ready           bool                           `json:"ready,omitempty"`           // In queries tells if something is ready when true
	Schema          *ssi.Schema                    `json:"schema,omitempty"`          // Schema data for creating schemas for the cred defs
	Msg             map[string]interface{}         `json:"msg,omitempty"`             // Generic sub message to transport JSON between Indy SDK and EAs
	Body            interface{}                    `json:"body,omitempty"`            // Task status data
}

The Msg is multipurpose way to transfer messages inside actual Payload which will be standardized hopefully by hyperledger-indy or someone. The Msg works like C language union i.e. if Error happened is filled and others are empty. Very similarly works Encrypted field. Please feel free to add new fields if needed.

func CreateMsg

func CreateMsg(d didcomm.MsgInit) Msg

CreateMsg is a helper function for creating MsgInits to help constructing "wrappers" for Msgs.

func NewAnonDecryptedMsg

func NewAnonDecryptedMsg(wallet int, cryptStr string, did *ssi.DID) *Msg

func NewHandshake

func NewHandshake(email, pwName string) *Msg

func (*Msg) AnonEncrypt

func (m *Msg) AnonEncrypt(did *ssi.DID) *Msg

func (*Msg) ChecksumOK

func (m *Msg) ChecksumOK() bool

func (*Msg) Decrypt

func (m *Msg) Decrypt(cp sec.Pipe) *Msg

func (*Msg) Encrypt

func (m *Msg) Encrypt(cp sec.Pipe) *Msg

func (*Msg) SetEndpoint

func (m *Msg) SetEndpoint(ae service.Addr)

func (*Msg) SetRcvrEndp

func (m *Msg) SetRcvrEndp(ae service.Addr)

type MsgFactor

type MsgFactor struct{}

func (MsgFactor) Create

func (MsgFactor) NewAnonDecryptedMsg

func (f MsgFactor) NewAnonDecryptedMsg(wallet int, cryptStr string, did *ssi.DID) didcomm.Msg

func (MsgFactor) NewMessage

func (f MsgFactor) NewMessage(data []byte) didcomm.MessageHdr

func (MsgFactor) NewMsg

func (f MsgFactor) NewMsg(init didcomm.MsgInit) didcomm.MessageHdr

type MsgImpl

type MsgImpl struct {
	*Msg
}

func (*MsgImpl) AnonEncrypt

func (m *MsgImpl) AnonEncrypt(did *ssi.DID) didcomm.Msg

func (*MsgImpl) ConnectionInvitation

func (m *MsgImpl) ConnectionInvitation() *didexchange.Invitation

func (*MsgImpl) CredDefID

func (m *MsgImpl) CredDefID() *string

func (*MsgImpl) CredentialAttributes

func (m *MsgImpl) CredentialAttributes() *[]didcomm.CredentialAttribute

func (*MsgImpl) Decr

func (m *MsgImpl) Decr(cp sec.Pipe) didcomm.Msg

func (*MsgImpl) Did

func (m *MsgImpl) Did() string

func (*MsgImpl) Encr

func (m *MsgImpl) Encr(cp sec.Pipe) didcomm.Msg

func (*MsgImpl) Encrypted

func (m *MsgImpl) Encrypted() string

func (*MsgImpl) Endpoint

func (m *MsgImpl) Endpoint() service.Addr

func (*MsgImpl) Error

func (m *MsgImpl) Error() string

func (*MsgImpl) FieldObj

func (m *MsgImpl) FieldObj() interface{}

func (*MsgImpl) ID

func (m *MsgImpl) ID() string

func (*MsgImpl) Info

func (m *MsgImpl) Info() string

func (*MsgImpl) JSON

func (m *MsgImpl) JSON() []byte

func (*MsgImpl) Name

func (m *MsgImpl) Name() string

func (*MsgImpl) Nonce

func (m *MsgImpl) Nonce() string

func (*MsgImpl) ProofAttributes

func (m *MsgImpl) ProofAttributes() *[]didcomm.ProofAttribute

func (*MsgImpl) ProofValues

func (m *MsgImpl) ProofValues() *[]didcomm.ProofValue

func (*MsgImpl) Ready

func (m *MsgImpl) Ready() bool

func (*MsgImpl) ReceiverEP

func (m *MsgImpl) ReceiverEP() service.Addr

func (*MsgImpl) Schema

func (m *MsgImpl) Schema() *ssi.Schema

func (*MsgImpl) SetBody

func (m *MsgImpl) SetBody(b interface{})

func (*MsgImpl) SetDid

func (m *MsgImpl) SetDid(s string)

func (*MsgImpl) SetError

func (m *MsgImpl) SetError(s string)

func (*MsgImpl) SetID

func (m *MsgImpl) SetID(id string)

func (*MsgImpl) SetInfo

func (m *MsgImpl) SetInfo(s string)

func (*MsgImpl) SetInvitation

func (m *MsgImpl) SetInvitation(i *didexchange.Invitation)

func (*MsgImpl) SetNonce

func (m *MsgImpl) SetNonce(n string)

func (*MsgImpl) SetReady

func (m *MsgImpl) SetReady(yes bool)

func (*MsgImpl) SetSchema

func (m *MsgImpl) SetSchema(sch *ssi.Schema)

func (*MsgImpl) SetSubLevelID

func (m *MsgImpl) SetSubLevelID(s string)

func (*MsgImpl) SetSubMsg

func (m *MsgImpl) SetSubMsg(sm map[string]interface{})

func (*MsgImpl) SetType

func (m *MsgImpl) SetType(t string)

func (*MsgImpl) SetVerKey

func (m *MsgImpl) SetVerKey(s string)

func (*MsgImpl) SubLevelID

func (m *MsgImpl) SubLevelID() string

func (*MsgImpl) SubMsg

func (m *MsgImpl) SubMsg() map[string]interface{}

func (*MsgImpl) Thread

func (m *MsgImpl) Thread() *decorator.Thread

func (*MsgImpl) TimestampMs

func (m *MsgImpl) TimestampMs() *uint64

func (*MsgImpl) Type

func (m *MsgImpl) Type() string

func (*MsgImpl) VerKey

func (m *MsgImpl) VerKey() string

type Payload

type Payload struct {
	ID      string `json:"id"`
	Type    string `json:"type"`
	Message Msg    `json:"message"`
}

func NewPayload

func NewPayload(data []byte) (p *Payload)

func (*Payload) JSON

func (pl *Payload) JSON() []byte

func (*Payload) Namespace

func (pl *Payload) Namespace() string

func (*Payload) Protocol

func (pl *Payload) Protocol() string

func (*Payload) ProtocolMsg

func (pl *Payload) ProtocolMsg() string

type PayloadFactor

type PayloadFactor struct{}

func (PayloadFactor) New

func (PayloadFactor) NewError

func (f PayloadFactor) NewError(pl didcomm.Payload, err error) didcomm.Payload

func (PayloadFactor) NewFromData

func (f PayloadFactor) NewFromData(data []byte) didcomm.Payload

func (PayloadFactor) NewMsg

type PayloadImpl

type PayloadImpl struct {
	*Payload
}

func (*PayloadImpl) Creator

func (pl *PayloadImpl) Creator() didcomm.PayloadFactor

func (*PayloadImpl) FieldObj

func (pl *PayloadImpl) FieldObj() interface{}

func (*PayloadImpl) ID

func (pl *PayloadImpl) ID() string

func (*PayloadImpl) Message

func (pl *PayloadImpl) Message() didcomm.Msg

func (*PayloadImpl) MsgCreator

func (pl *PayloadImpl) MsgCreator() didcomm.MsgFactor

func (*PayloadImpl) MsgHdr

func (pl *PayloadImpl) MsgHdr() didcomm.MessageHdr

func (*PayloadImpl) SetThread

func (pl *PayloadImpl) SetThread(t *decorator.Thread)

func (*PayloadImpl) SetType

func (pl *PayloadImpl) SetType(t string)

func (*PayloadImpl) Thread

func (pl *PayloadImpl) Thread() *decorator.Thread

func (*PayloadImpl) ThreadID

func (pl *PayloadImpl) ThreadID() string

func (*PayloadImpl) Type

func (pl *PayloadImpl) Type() string

Jump to

Keyboard shortcuts

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