Documentation ¶
Index ¶
- Variables
- func CalcMessageClock(lastObservedValue uint64, timeInMs uint64) uint64
- func EncodeMembershipUpdateMessage(value MembershipUpdateMessage) ([]byte, error)
- func EncodePairMessage(value PairMessage) ([]byte, error)
- func MessageID(author *ecdsa.PublicKey, data []byte) types.HexBytes
- func NewMessageDecoder(r io.Reader) *transit.Decoder
- func NewMessageEncoder(w io.Writer) *transit.Encoder
- func TimestampInMsFromTime(t time.Time) uint64
- func WrapMessageV1(payload []byte, messageType protobuf.ApplicationMetadataMessage_Type, ...) ([]byte, error)
- type Group
- func (g Group) Admins() []string
- func (g Group) ChatID() string
- func (g Group) Events() []MembershipUpdateEvent
- func (g Group) IsMember(id string) bool
- func (g Group) Joined() []string
- func (g Group) LastClockValue() uint64
- func (g Group) Members() []string
- func (g Group) Name() string
- func (g *Group) ProcessEvent(event MembershipUpdateEvent) error
- func (g *Group) ProcessEvents(events []MembershipUpdateEvent) error
- type MembershipUpdateEvent
- func MembershipUpdateEventFromProtobuf(chatID string, raw []byte) (*MembershipUpdateEvent, error)
- func MergeMembershipUpdateEvents(dest []MembershipUpdateEvent, src []MembershipUpdateEvent) []MembershipUpdateEvent
- func NewAdminRemovedEvent(admin string, clock uint64) MembershipUpdateEvent
- func NewAdminsAddedEvent(admins []string, clock uint64) MembershipUpdateEvent
- func NewChatCreatedEvent(name string, clock uint64) MembershipUpdateEvent
- func NewMemberJoinedEvent(clock uint64) MembershipUpdateEvent
- func NewMemberRemovedEvent(member string, clock uint64) MembershipUpdateEvent
- func NewMembersAddedEvent(members []string, clock uint64) MembershipUpdateEvent
- func NewNameChangedEvent(name string, clock uint64) MembershipUpdateEvent
- type MembershipUpdateMessage
- type PairMessage
- type StatusMessage
- func (m *StatusMessage) Clone() (*StatusMessage, error)
- func (m *StatusMessage) HandleApplication() error
- func (m *StatusMessage) HandleApplicationMetadata() error
- func (m *StatusMessage) HandleDatasync(datasync *datasync.DataSync) ([]*StatusMessage, error)
- func (m *StatusMessage) HandleEncryption(myKey *ecdsa.PrivateKey, senderKey *ecdsa.PublicKey, enc *encryption.Protocol) error
- func (m *StatusMessage) HandleTransport(shhMessage *types.Message) error
- func (m *StatusMessage) MarshalJSON() ([]byte, error)
- func (m *StatusMessage) SigPubKey() *ecdsa.PublicKey
- type StatusMessageT
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidDecodedValue means that the decoded message is of wrong type. // This might mean that the status message serialization tag changed. ErrInvalidDecodedValue = errors.New("invalid decoded value type") )
Functions ¶
func CalcMessageClock ¶
CalcMessageClock calculates a new clock value for Message. It is used to properly sort messages and accommodate the fact that time might be different on each device.
func EncodeMembershipUpdateMessage ¶
func EncodeMembershipUpdateMessage(value MembershipUpdateMessage) ([]byte, error)
EncodeMembershipUpdateMessage encodes a MembershipUpdateMessage using protobuf serialization.
func EncodePairMessage ¶
func EncodePairMessage(value PairMessage) ([]byte, error)
EncodePairMessage encodes a PairMessage using Transit serialization.
func MessageID ¶
MessageID calculates the messageID from author's compressed public key and not encrypted but encoded payload.
func NewMessageDecoder ¶
NewMessageDecoder returns a new Transit decoder that can deserialize Message structs. More about Transit: https://github.com/cognitect/transit-format
func NewMessageEncoder ¶
NewMessageEncoder returns a new Transit encoder that can encode Message values. More about Transit: https://github.com/cognitect/transit-format
func TimestampInMsFromTime ¶
TimestampInMsFromTime returns a TimestampInMs from a time.Time instance.
func WrapMessageV1 ¶
func WrapMessageV1(payload []byte, messageType protobuf.ApplicationMetadataMessage_Type, identity *ecdsa.PrivateKey) ([]byte, error)
WrapMessageV1 wraps a payload into a protobuf message and signs it if an identity is provided
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func NewGroupWithCreator ¶
func NewGroupWithCreator(name string, creator *ecdsa.PrivateKey) (*Group, error)
func NewGroupWithEvents ¶
func NewGroupWithEvents(chatID string, events []MembershipUpdateEvent) (*Group, error)
func (Group) Events ¶
func (g Group) Events() []MembershipUpdateEvent
func (Group) LastClockValue ¶
func (*Group) ProcessEvent ¶
func (g *Group) ProcessEvent(event MembershipUpdateEvent) error
func (*Group) ProcessEvents ¶
func (g *Group) ProcessEvents(events []MembershipUpdateEvent) error
type MembershipUpdateEvent ¶
type MembershipUpdateEvent struct { Type protobuf.MembershipUpdateEvent_EventType `json:"type"` ClockValue uint64 `json:"clockValue"` Members []string `json:"members,omitempty"` // in "members-added" and "admins-added" events Name string `json:"name,omitempty"` // name of the group chat From string Signature []byte ChatID string RawPayload []byte }
MembershipUpdateEvent contains an event information. Member and Members are hex-encoded values with 0x prefix.
func MembershipUpdateEventFromProtobuf ¶
func MembershipUpdateEventFromProtobuf(chatID string, raw []byte) (*MembershipUpdateEvent, error)
func MergeMembershipUpdateEvents ¶
func MergeMembershipUpdateEvents(dest []MembershipUpdateEvent, src []MembershipUpdateEvent) []MembershipUpdateEvent
func NewAdminRemovedEvent ¶
func NewAdminRemovedEvent(admin string, clock uint64) MembershipUpdateEvent
func NewAdminsAddedEvent ¶
func NewAdminsAddedEvent(admins []string, clock uint64) MembershipUpdateEvent
func NewChatCreatedEvent ¶
func NewChatCreatedEvent(name string, clock uint64) MembershipUpdateEvent
func NewMemberJoinedEvent ¶
func NewMemberJoinedEvent(clock uint64) MembershipUpdateEvent
func NewMemberRemovedEvent ¶
func NewMemberRemovedEvent(member string, clock uint64) MembershipUpdateEvent
func NewMembersAddedEvent ¶
func NewMembersAddedEvent(members []string, clock uint64) MembershipUpdateEvent
func NewNameChangedEvent ¶
func NewNameChangedEvent(name string, clock uint64) MembershipUpdateEvent
func (*MembershipUpdateEvent) Equal ¶
func (u *MembershipUpdateEvent) Equal(update MembershipUpdateEvent) bool
func (*MembershipUpdateEvent) Sign ¶
func (u *MembershipUpdateEvent) Sign(key *ecdsa.PrivateKey) error
func (*MembershipUpdateEvent) ToProtobuf ¶
func (u *MembershipUpdateEvent) ToProtobuf() *protobuf.MembershipUpdateEvent
type MembershipUpdateMessage ¶
type MembershipUpdateMessage struct { ChatID string `json:"chatId"` // UUID concatenated with hex-encoded public key of the creator for the chat Events []MembershipUpdateEvent `json:"events"` Message *protobuf.ChatMessage `json:"-"` }
MembershipUpdateMessage is a message used to propagate information about group membership changes. For more information, see https://github.com/status-im/specs/blob/master/status-group-chats-spec.md.
func MembershipUpdateMessageFromProtobuf ¶
func MembershipUpdateMessageFromProtobuf(raw *protobuf.MembershipUpdateMessage) (*MembershipUpdateMessage, error)
func (*MembershipUpdateMessage) ToProtobuf ¶
func (m *MembershipUpdateMessage) ToProtobuf() *protobuf.MembershipUpdateMessage
type PairMessage ¶
type PairMessage struct { InstallationID string `json:"installationId"` // The type of the device DeviceType string `json:"deviceType"` // Name the user set name Name string `json:"name"` // The FCMToken for mobile platforms FCMToken string `json:"fcmToken"` // not protocol defined fields ID []byte `json:"-"` }
PairMessage contains all message details.
func CreatePairMessage ¶
func CreatePairMessage(installationID string, name string, deviceType string, fcmToken string) PairMessage
CreatePairMessage creates a PairMessage which is used to pair devices.
func DecodePairMessage ¶
func DecodePairMessage(data []byte) (message PairMessage, err error)
DecodePairMessage decodes a raw payload to Message struct.
func (*PairMessage) MarshalJSON ¶
func (m *PairMessage) MarshalJSON() ([]byte, error)
type StatusMessage ¶
type StatusMessage struct { // TransportMessage is the parsed message received from the transport layer, i.e the input TransportMessage *types.Message `json:"transportMessage"` // Type is the type of application message contained Type protobuf.ApplicationMetadataMessage_Type `json:"-"` // ParsedMessage is the parsed message by the application layer, i.e the output ParsedMessage interface{} `json:"-"` // TransportPayload is the payload as received from the transport layer TransportPayload []byte `json:"-"` // DecryptedPayload is the payload after having been processed by the encryption layer DecryptedPayload []byte `json:"decryptedPayload"` // ID is the canonical ID of the message ID types.HexBytes `json:"id"` // Hash is the transport layer hash Hash []byte `json:"-"` // TransportLayerSigPubKey contains the public key provided by the transport layer TransportLayerSigPubKey *ecdsa.PublicKey `json:"-"` // ApplicationMetadataLayerPubKey contains the public key provided by the application metadata layer ApplicationMetadataLayerSigPubKey *ecdsa.PublicKey `json:"-"` }
StatusMessage is any Status Protocol message.
func (*StatusMessage) Clone ¶
func (m *StatusMessage) Clone() (*StatusMessage, error)
func (*StatusMessage) HandleApplication ¶
func (m *StatusMessage) HandleApplication() error
func (*StatusMessage) HandleApplicationMetadata ¶
func (m *StatusMessage) HandleApplicationMetadata() error
func (*StatusMessage) HandleDatasync ¶
func (m *StatusMessage) HandleDatasync(datasync *datasync.DataSync) ([]*StatusMessage, error)
HandleDatasync processes StatusMessage through data sync layer. This is optional and DataSync might be nil. In such a case, only one payload will be returned equal to DecryptedPayload.
func (*StatusMessage) HandleEncryption ¶
func (m *StatusMessage) HandleEncryption(myKey *ecdsa.PrivateKey, senderKey *ecdsa.PublicKey, enc *encryption.Protocol) error
func (*StatusMessage) HandleTransport ¶
func (m *StatusMessage) HandleTransport(shhMessage *types.Message) error
func (*StatusMessage) MarshalJSON ¶
func (m *StatusMessage) MarshalJSON() ([]byte, error)
Temporary JSON marshaling for those messages that are not yet processed by the go code
func (*StatusMessage) SigPubKey ¶
func (m *StatusMessage) SigPubKey() *ecdsa.PublicKey
SigPubKey returns the most important signature, from the application layer to transport
type StatusMessageT ¶
type StatusMessageT int