msgproto

package module
v0.0.0-...-438ab31 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 4 Imported by: 0

README

self-messaging-proto

Defines the protobuf files for messaging services and client

All changes to .proto files must be built before commiting.

Generating

To generate the go bindings, run:

$ make generate

Protocol specifications

There are a number of different type of messages, these are distinguished by the specified type.

Field Type Required
id string yes
type enum yes

Valid type enums are:

  • MsgType_MSG (0)
  • MsgType_ACK (1)
  • MsgType_ERR (2)
  • MsgType_AUTH (3)
  • MsgType_ACL (4)
authentication

The first message that should be sent when connecting is an authentication message.

The JWT token provided must be signed by the identity denoted in the issuer iss field.

A device ID must also be provided to denote the id of the device that is connecting.

On a successful auth, the server will send back a ACK message. On a failure, an ERR message will be returned.

Field Type Value Required
id string UUID true
type enum MsgType_AUTH true
token string valid jwt token true
device int32 id of device true
message

Messages will be sent in real-time to the authenticated user.

On a successful message send, the server will reply with an ACK.

If there is an error sending the message, the server will respond with an ERR message.

Field Type Value Required
id string UUID true
type enum MsgType_MSG true
sender string sender-id true
recipient string recipient-id true
ciphertext bytes encrypted cyphertext false
timestamp timestamp timestamp false
acl

Each identity has an access control list. This list determines what other identities are allowed to send messages to the server.

The ACL is a whitelist that requires a specific rule to a allow messages through. Rules can optionally specify an expiry time.

There are 3 acl commands, LIST, PERMIT and REVOKE.

Field Type Value Required
id string UUID true
type enum MsgType_MSG true
command enum ACLCommand_LIST, ACLCommand_PERMIT, ACLCommand_REVOKE true
payload bytes JWS payload for permit, revoke. Array of rules for list true

To list all active ACL rules, issue an ACL message with the LIST command. The payload of the response will contain an array of rules.

[
    {
        "acl_source": "self-id",
        "acl_exp": "RFC3339"
    }
]

To permit or revoke a sender, you must send an ACL message with the PERMIT or REVOKE command. The payload of the message will be a JWS payload signed by the identity. The payload of the JWS must contain the following fields:

{
    "iss": "the issuing self ID",
    "acl_source": "id of the permitted|revoked self identity",
    "acl_exp": "RFC3339 time of rule expiry"
}

To allow messages from all identities, you can set the acl_source to *.

When the ACL has been updated, the server will respond with an ACK or ERR message.

acknowledgement
Field Type Value
id string id of message
type enum MsgType_ACK
error
Field Type Value
id string UUID of related message
type enum MsgType_ERR
error string error message

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ACLCommand_name = map[int32]string{
	0: "LIST",
	1: "PERMIT",
	2: "REVOKE",
}
View Source
var ACLCommand_value = map[string]int32{
	"LIST":   0,
	"PERMIT": 1,
	"REVOKE": 2,
}
View Source
var ErrType_name = map[int32]string{
	0: "ErrConnection",
	1: "ErrBadRequest",
	2: "ErrInternal",
	3: "ErrMessage",
	4: "ErrAuth",
	5: "ErrACL",
}
View Source
var ErrType_value = map[string]int32{
	"ErrConnection": 0,
	"ErrBadRequest": 1,
	"ErrInternal":   2,
	"ErrMessage":    3,
	"ErrAuth":       4,
	"ErrACL":        5,
}
View Source
var MsgType_name = map[int32]string{
	0: "MSG",
	1: "ACK",
	2: "ERR",
	3: "AUTH",
	4: "ACL",
}
View Source
var MsgType_value = map[string]int32{
	"MSG":  0,
	"ACK":  1,
	"ERR":  2,
	"AUTH": 3,
	"ACL":  4,
}

Functions

This section is empty.

Types

type ACLCommand

type ACLCommand int32
const (
	ACLCommand_LIST   ACLCommand = 0
	ACLCommand_PERMIT ACLCommand = 1
	ACLCommand_REVOKE ACLCommand = 2
)

func (ACLCommand) EnumDescriptor

func (ACLCommand) EnumDescriptor() ([]byte, []int)

func (ACLCommand) String

func (x ACLCommand) String() string

type AccessControlList

type AccessControlList struct {
	Type                 MsgType    `protobuf:"varint,1,opt,name=type,proto3,enum=msgproto.MsgType" json:"type,omitempty"`
	Id                   string     `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	Command              ACLCommand `protobuf:"varint,3,opt,name=command,proto3,enum=msgproto.ACLCommand" json:"command,omitempty"`
	Payload              []byte     `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func (*AccessControlList) Descriptor

func (*AccessControlList) Descriptor() ([]byte, []int)

func (*AccessControlList) GetCommand

func (m *AccessControlList) GetCommand() ACLCommand

func (*AccessControlList) GetId

func (m *AccessControlList) GetId() string

func (*AccessControlList) GetPayload

func (m *AccessControlList) GetPayload() []byte

func (*AccessControlList) GetType

func (m *AccessControlList) GetType() MsgType

func (*AccessControlList) ProtoMessage

func (*AccessControlList) ProtoMessage()

func (*AccessControlList) Reset

func (m *AccessControlList) Reset()

func (*AccessControlList) String

func (m *AccessControlList) String() string

func (*AccessControlList) XXX_DiscardUnknown

func (m *AccessControlList) XXX_DiscardUnknown()

func (*AccessControlList) XXX_Marshal

func (m *AccessControlList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AccessControlList) XXX_Merge

func (m *AccessControlList) XXX_Merge(src proto.Message)

func (*AccessControlList) XXX_Size

func (m *AccessControlList) XXX_Size() int

func (*AccessControlList) XXX_Unmarshal

func (m *AccessControlList) XXX_Unmarshal(b []byte) error

type Auth

type Auth struct {
	Type                 MsgType  `protobuf:"varint,1,opt,name=type,proto3,enum=msgproto.MsgType" json:"type,omitempty"`
	Id                   string   `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	Token                string   `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"`
	Device               string   `protobuf:"bytes,4,opt,name=device,proto3" json:"device,omitempty"`
	Offset               uint64   `protobuf:"varint,5,opt,name=offset,proto3" json:"offset,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Auth) Descriptor

func (*Auth) Descriptor() ([]byte, []int)

func (*Auth) GetDevice

func (m *Auth) GetDevice() string

func (*Auth) GetId

func (m *Auth) GetId() string

func (*Auth) GetOffset

func (m *Auth) GetOffset() uint64

func (*Auth) GetToken

func (m *Auth) GetToken() string

func (*Auth) GetType

func (m *Auth) GetType() MsgType

func (*Auth) ProtoMessage

func (*Auth) ProtoMessage()

func (*Auth) Reset

func (m *Auth) Reset()

func (*Auth) String

func (m *Auth) String() string

func (*Auth) XXX_DiscardUnknown

func (m *Auth) XXX_DiscardUnknown()

func (*Auth) XXX_Marshal

func (m *Auth) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Auth) XXX_Merge

func (m *Auth) XXX_Merge(src proto.Message)

func (*Auth) XXX_Size

func (m *Auth) XXX_Size() int

func (*Auth) XXX_Unmarshal

func (m *Auth) XXX_Unmarshal(b []byte) error

type ErrType

type ErrType int32
const (
	ErrType_ErrConnection ErrType = 0
	ErrType_ErrBadRequest ErrType = 1
	ErrType_ErrInternal   ErrType = 2
	ErrType_ErrMessage    ErrType = 3
	ErrType_ErrAuth       ErrType = 4
	ErrType_ErrACL        ErrType = 5
)

func (ErrType) EnumDescriptor

func (ErrType) EnumDescriptor() ([]byte, []int)

func (ErrType) String

func (x ErrType) String() string
type Header struct {
	Type                 MsgType  `protobuf:"varint,1,opt,name=type,proto3,enum=msgproto.MsgType" json:"type,omitempty"`
	Id                   string   `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Header) Descriptor

func (*Header) Descriptor() ([]byte, []int)

func (*Header) GetId

func (m *Header) GetId() string

func (*Header) GetType

func (m *Header) GetType() MsgType

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) Reset

func (m *Header) Reset()

func (*Header) String

func (m *Header) String() string

func (*Header) XXX_DiscardUnknown

func (m *Header) XXX_DiscardUnknown()

func (*Header) XXX_Marshal

func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Header) XXX_Merge

func (m *Header) XXX_Merge(src proto.Message)

func (*Header) XXX_Size

func (m *Header) XXX_Size() int

func (*Header) XXX_Unmarshal

func (m *Header) XXX_Unmarshal(b []byte) error

type Message

type Message struct {
	Type                 MsgType              `protobuf:"varint,1,opt,name=type,proto3,enum=msgproto.MsgType" json:"type,omitempty"`
	Id                   string               `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	Sender               string               `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"`
	Recipient            string               `protobuf:"bytes,4,opt,name=recipient,proto3" json:"recipient,omitempty"`
	Ciphertext           []byte               `protobuf:"bytes,5,opt,name=ciphertext,proto3" json:"ciphertext,omitempty"`
	Timestamp            *timestamp.Timestamp `protobuf:"bytes,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Offset               int64                `protobuf:"varint,7,opt,name=offset,proto3" json:"offset,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetCiphertext

func (m *Message) GetCiphertext() []byte

func (*Message) GetId

func (m *Message) GetId() string

func (*Message) GetOffset

func (m *Message) GetOffset() int64

func (*Message) GetRecipient

func (m *Message) GetRecipient() string

func (*Message) GetSender

func (m *Message) GetSender() string

func (*Message) GetTimestamp

func (m *Message) GetTimestamp() *timestamp.Timestamp

func (*Message) GetType

func (m *Message) GetType() MsgType

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Message) XXX_Merge

func (m *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

func (m *Message) XXX_Unmarshal(b []byte) error

type MsgType

type MsgType int32
const (
	MsgType_MSG  MsgType = 0
	MsgType_ACK  MsgType = 1
	MsgType_ERR  MsgType = 2
	MsgType_AUTH MsgType = 3
	MsgType_ACL  MsgType = 4
)

func (MsgType) EnumDescriptor

func (MsgType) EnumDescriptor() ([]byte, []int)

func (MsgType) String

func (x MsgType) String() string

type Notification

type Notification struct {
	Type                 MsgType  `protobuf:"varint,1,opt,name=type,proto3,enum=msgproto.MsgType" json:"type,omitempty"`
	Id                   string   `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	Error                string   `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
	Errtype              ErrType  `protobuf:"varint,4,opt,name=errtype,proto3,enum=msgproto.ErrType" json:"errtype,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Notification) Descriptor

func (*Notification) Descriptor() ([]byte, []int)

func (*Notification) GetError

func (m *Notification) GetError() string

func (*Notification) GetErrtype

func (m *Notification) GetErrtype() ErrType

func (*Notification) GetId

func (m *Notification) GetId() string

func (*Notification) GetType

func (m *Notification) GetType() MsgType

func (*Notification) ProtoMessage

func (*Notification) ProtoMessage()

func (*Notification) Reset

func (m *Notification) Reset()

func (*Notification) String

func (m *Notification) String() string

func (*Notification) XXX_DiscardUnknown

func (m *Notification) XXX_DiscardUnknown()

func (*Notification) XXX_Marshal

func (m *Notification) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Notification) XXX_Merge

func (m *Notification) XXX_Merge(src proto.Message)

func (*Notification) XXX_Size

func (m *Notification) XXX_Size() int

func (*Notification) XXX_Unmarshal

func (m *Notification) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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