Documentation
¶
Index ¶
- Constants
- func IsValidPack(data string) bool
- type Message
- func New(from string, to string, body []byte, mime_type string) (*Message, error)
- func OpenEnvelope(e *envelope.Envelope, privKey []byte) (*Message, error)
- func Parse(data string) (*Message, error)
- func Signed(from string, to string, body []byte, mime_type string, ...) (*Message, error)
- func UnmarshalFromCBOR(data []byte) (*Message, error)
- func Unpack(data string) (*Message, error)
- func ValidExampleMessage() *Message
- func (m *Message) Bytes() []byte
- func (m *Message) CreatedTime() (time.Time, error)
- func (m *Message) Enclose() (*envelope.Envelope, error)
- func (m *Message) ExpiresTime() (time.Time, error)
- func (m *Message) IsValid() bool
- func (m *Message) MarshalToCBOR() ([]byte, error)
- func (m *Message) MarshalToJSON() ([]byte, error)
- func (m *Message) MarshalUnsignedToCBOR() ([]byte, error)
- func (m *Message) MultibaseEncodedPayloadHash() string
- func (m *Message) Pack() (string, error)
- func (m *Message) Recipient() (*did.DID, error)
- func (m *Message) SemVersion() (semver.Version, error)
- func (m *Message) Send(ctx context.Context, t *pubsub.Topic) error
- func (m *Message) Sender() (*did.DID, error)
- func (m *Message) Sign(privKey *ed25519.PrivateKey) error
- func (m *Message) SignatureBytes() []byte
- func (m *Message) Unsigned() (Message, error)
- func (m *Message) Validate() error
- func (m *Message) VerifyActors() error
- func (m *Message) VerifyID() error
- func (m *Message) VerifyMessageVersion() error
- func (m *Message) VerifySignature() error
- func (m *Message) VerifyTimestamps() error
Constants ¶
const ( // Messages which are older than a day should be ignored MESSAGE_TTL = time.Hour * 24 // How we identify the messages we support MESSAGE_ENCRYPTION_LABEL = mime.MESSAGE_MIME_TYPE )
const ( // This is the packed message. You can generate it using cmd/pack_valid_message.go Message_test_packed_valid_message = "" /* 359-byte string literal not displayed */ )
It's really meant for testing, but we might want to use it in other places too.
Variables ¶
This section is empty.
Functions ¶
func IsValidPack ¶ added in v0.0.3
Types ¶
type Message ¶
type Message struct { ID string `cbor:"id" json:"id"` MimeType string `cbor:"type" json:"type"` From string `cbor:"from" json:"from"` To string `cbor:"to" json:"to"` Created int64 `cbor:"created_time,keyasint64" json:"created_time"` Expires int64 `cbor:"expires_time,keyasint64" json:"expires_time"` BodyMimeType string `cbor:"body_mime_type" json:"body_mime_type"` Body []byte `cbor:"body" json:"body"` Version string `cbor:"versionId" json:"versionId"` Signature string `cbor:"signature" json:"signature"` // contains filtered or unexported fields }
This struct mimicks the Message format, but it's *not* Message. It should enable using Message later, if that's a good idea.
func OpenEnvelope ¶ added in v0.0.3
Takes an envelope an an x25519 privkey byte[] and returns a decrypted message
func UnmarshalFromCBOR ¶ added in v0.0.3
func ValidExampleMessage ¶
func ValidExampleMessage() *Message
func (*Message) Bytes ¶ added in v0.0.3
Returns a copy of the Message payload as a byte slice No error messages, just nil Try with IsValidPack() first, if you need to make sure.
func (*Message) MarshalToCBOR ¶
func (*Message) MarshalToJSON ¶
func (*Message) MarshalUnsignedToCBOR ¶ added in v0.0.3
func (*Message) MultibaseEncodedPayloadHash ¶ added in v0.0.3
Returns the multibase-encoded hash of the Message payload Or empty string if an error occurs This is mostly intended for debugging purposes
func (*Message) Send ¶ added in v0.0.3
Send message to a pubsub topic We could have done p2p here, but it's much cleaner to take a topic as an argument. The topic is just a medium for sending messages, not actually the recipient necessarily.
func (*Message) SignatureBytes ¶ added in v0.0.3
SignatureBytes returns the signature bytes It doesn't return an error, but logs it instead
func (*Message) Unsigned ¶ added in v0.0.3
Returns a copy of the Message payload This is just meant to be used for signatures.
func (*Message) VerifyActors ¶
func (*Message) VerifyMessageVersion ¶
Compare messageVersion. Return nil if ok else an error
func (*Message) VerifySignature ¶ added in v0.0.3
VerifySignature verifies the Message's signature Returns nil if the signature is valid