Documentation ¶
Index ¶
- Constants
- Variables
- func Decrypt(cyphertext []byte, key []byte) ([]byte, error)
- func Encrypt(plaintext []byte, key []byte, reader io.Reader) ([]byte, error)
- func HashPublicKey(pk *ecdsa.PublicKey) []byte
- func HexToPubkey(pk string) (*ecdsa.PublicKey, error)
- func IsPubKeyEqual(a, b *ecdsa.PublicKey) bool
- func MessageSpecToWhisper(spec *encryption.ProtocolMessageSpec) (*types.NewMessage, error)
- func PubkeyToHex(key *ecdsa.PublicKey) string
- func PubkeyToHexBytes(key *ecdsa.PublicKey) types.HexBytes
- func Shake256(buf []byte) []byte
- type ChatEntity
- type CommandParameters
- type CommandState
- type FeatureFlags
- type MentionsAndLinksVisitor
- type Message
- func (m *Message) GetProtobuf() proto.Message
- func (m *Message) GetSenderPubKey() (*ecdsa.PublicKey, error)
- func (m Message) GetSigPubKey() *ecdsa.PublicKey
- func (m *Message) GetSimplifiedText(canonicalNames map[string]string) (string, error)
- func (m *Message) MarshalJSON() ([]byte, error)
- func (m *Message) PrepareContent() error
- func (m *Message) SetMessageType(messageType protobuf.MessageType)
- func (m *Message) UnmarshalJSON(data []byte) error
- func (m *Message) WrapGroupMessage() bool
- type MessageProcessor
- func (p *MessageProcessor) AddEphemeralKey(privateKey *ecdsa.PrivateKey) (*transport.Filter, error)
- func (p *MessageProcessor) EncodeAbridgedMembershipUpdate(group *v1protocol.Group, chatEntity ChatEntity) ([]byte, error)
- func (p *MessageProcessor) EncodeMembershipUpdate(group *v1protocol.Group, chatEntity ChatEntity) ([]byte, error)
- func (p *MessageProcessor) HandleMessages(shhMessage *types.Message, applicationLayer bool) ([]*v1protocol.StatusMessage, [][]byte, error)
- func (p *MessageProcessor) JoinPublic(id string) (*transport.Filter, error)
- func (p *MessageProcessor) SendCommunityMessage(ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SendGroup(ctx context.Context, recipients []*ecdsa.PublicKey, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SendPairInstallation(ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SendPrivate(ctx context.Context, recipient *ecdsa.PublicKey, rawMessage *RawMessage) ([]byte, error)
- func (p *MessageProcessor) SendPublic(ctx context.Context, chatName string, rawMessage RawMessage) ([]byte, error)
- func (p *MessageProcessor) SetHandleSharedSecrets(handler func([]*sharedsecret.Secret) error)
- func (p *MessageProcessor) Stop()
- func (p *MessageProcessor) SubscribeToScheduledMessages() <-chan *RawMessage
- func (p *MessageProcessor) SubscribeToSentMessages() <-chan *SentMessage
- type QuotedMessage
- type RawMessage
- type RawMessageConfirmation
- type RawMessagesPersistence
- func (db RawMessagesPersistence) InsertPendingConfirmation(confirmation *RawMessageConfirmation) error
- func (db RawMessagesPersistence) MarkAsConfirmed(dataSyncID []byte, atLeastOne bool) (messageID types.HexBytes, err error)
- func (db RawMessagesPersistence) RawMessageByID(id string) (*RawMessage, error)
- func (db RawMessagesPersistence) RawMessagesIDsByType(t protobuf.ApplicationMetadataMessage_Type) ([]string, error)
- func (db RawMessagesPersistence) SaveRawMessage(message *RawMessage) error
- type SentMessage
- type SimplifiedTextVisitor
- type TimeSource
Constants ¶
const ( OutgoingStatusSending = "sending" OutgoingStatusSent = "sent" OutgoingStatusDelivered = "delivered" )
Variables ¶
var ErrInvalidCiphertextLength = errors.New("invalid cyphertext length")
var ErrRecordNotFound = errors.New("record not found")
Functions ¶
func HashPublicKey ¶
func IsPubKeyEqual ¶
IsPubKeyEqual checks that two public keys are equal
func MessageSpecToWhisper ¶
func MessageSpecToWhisper(spec *encryption.ProtocolMessageSpec) (*types.NewMessage, error)
func PubkeyToHex ¶ added in v0.67.0
Types ¶
type ChatEntity ¶ added in v0.56.4
type ChatEntity interface { proto.Message GetChatId() string GetMessageType() protobuf.MessageType GetSigPubKey() *ecdsa.PublicKey GetProtobuf() proto.Message GetGrant() []byte WrapGroupMessage() bool SetMessageType(messageType protobuf.MessageType) }
ChatEntity is anything that is sendable in a chat. Currently it encompass a Message and EmojiReaction.
type CommandParameters ¶ added in v0.61.0
type CommandParameters struct { // ID is the ID of the initial message ID string `json:"id"` // From is the address we are sending the command from From string `json:"from"` // Address is the address sent with the command Address string `json:"address"` // Contract is the contract address for ERC20 tokens Contract string `json:"contract"` // Value is the value as a string sent Value string `json:"value"` // TransactionHash is the hash of the transaction TransactionHash string `json:"transactionHash"` // CommandState is the state of the command CommandState CommandState `json:"commandState"` // The Signature of the pk-bytes+transaction-hash from the wallet // address originating Signature []byte `json:"signature"` }
func (*CommandParameters) IsTokenTransfer ¶ added in v0.61.0
func (c *CommandParameters) IsTokenTransfer() bool
type CommandState ¶ added in v0.61.0
type CommandState int
const ( CommandStateRequestAddressForTransaction CommandState = iota + 1 CommandStateRequestAddressForTransactionDeclined CommandStateRequestAddressForTransactionAccepted CommandStateRequestTransaction CommandStateRequestTransactionDeclined CommandStateTransactionPending CommandStateTransactionSent )
type FeatureFlags ¶
type FeatureFlags struct { // Datasync indicates whether direct messages should be sent exclusively // using datasync, breaking change for non-v1 clients. Public messages // are not impacted Datasync bool // PushNotification indicates whether we should be enabling the push notification feature PushNotifications bool }
type MentionsAndLinksVisitor ¶ added in v0.74.2
type MentionsAndLinksVisitor struct {
// contains filtered or unexported fields
}
implement interface of https://github.com/status-im/markdown/blob/b9fe921681227b1dace4b56364e15edb3b698308/ast/node.go#L701
func (*MentionsAndLinksVisitor) Visit ¶ added in v0.74.2
func (v *MentionsAndLinksVisitor) Visit(node ast.Node, entering bool) ast.WalkStatus
type Message ¶ added in v0.61.0
type Message struct { protobuf.ChatMessage // ID calculated as keccak256(compressedAuthorPubKey, data) where data is unencrypted payload. ID string `json:"id"` // WhisperTimestamp is a timestamp of a Whisper envelope. WhisperTimestamp uint64 `json:"whisperTimestamp"` // From is a public key of the author of the message. From string `json:"from"` // Random 3 words name Alias string `json:"alias"` // Identicon of the author Identicon string `json:"identicon"` // The chat id to be stored locally LocalChatID string `json:"localChatId"` // Seen set to true when user have read this message already Seen bool `json:"seen"` OutgoingStatus string `json:"outgoingStatus,omitempty"` QuotedMessage *QuotedMessage `json:"quotedMessage"` // CommandParameters is the parameters sent with the message CommandParameters *CommandParameters `json:"commandParameters"` // Computed fields // RTL is whether this is a right-to-left message (arabic/hebrew script etc) RTL bool `json:"rtl"` // ParsedText is the parsed markdown for displaying ParsedText []byte `json:"parsedText,omitempty"` // ParsedTextAst is the ast of the parsed text ParsedTextAst *ast.Node `json:"-"` // LineCount is the count of newlines in the message LineCount int `json:"lineCount"` // Base64Image is the converted base64 image Base64Image string `json:"image,omitempty"` // ImagePath is the path of the image to be sent ImagePath string `json:"imagePath,omitempty"` // Base64Audio is the converted base64 audio Base64Audio string `json:"audio,omitempty"` // AudioPath is the path of the audio to be sent AudioPath string `json:"audioPath,omitempty"` // CommunityID is the id of the community to advertise CommunityID string `json:"communityId,omitempty"` // Replace indicates that this is a replacement of a message // that has been updated Replace string `json:"replace,omitempty"` New bool `json:"new,omitempty"` SigPubKey *ecdsa.PublicKey `json:"-"` // Mentions is an array of mentions for a given message Mentions []string // Links is an array of links within given message Links []string }
Message represents a message record in the database, more specifically in user_messages table.
func (*Message) GetProtobuf ¶ added in v0.61.0
GetProtoBuf returns the struct's embedded protobuf struct this function is required to implement the ChatEntity interface
func (*Message) GetSenderPubKey ¶ added in v0.71.5
GetPublicKey attempts to return or recreate the *ecdsa.PublicKey of the Message sender. If the m.SigPubKey is set this will be returned If the m.From is present the string is decoded and unmarshalled into a *ecdsa.PublicKey, the m.SigPubKey is set and returned Else an error is thrown This function differs from GetSigPubKey() as this function may return an error
func (Message) GetSigPubKey ¶ added in v0.61.0
GetSigPubKey returns an ecdsa encoded public key this function is required to implement the ChatEntity interface
func (*Message) GetSimplifiedText ¶ added in v0.74.2
GetSimplifiedText returns a the text stripped of all the markdown and with mentions replaced by canonical names
func (*Message) MarshalJSON ¶ added in v0.61.0
func (*Message) PrepareContent ¶ added in v0.61.0
PrepareContent return the parsed content of the message, the line-count and whether is a right-to-left message
func (*Message) SetMessageType ¶ added in v0.61.0
func (m *Message) SetMessageType(messageType protobuf.MessageType)
SetMessageType a setter for the MessageType field this function is required to implement the ChatEntity interface
func (*Message) UnmarshalJSON ¶ added in v0.61.0
func (*Message) WrapGroupMessage ¶ added in v0.69.0
WrapGroupMessage indicates whether we should wrap this in membership information
type MessageProcessor ¶
type MessageProcessor struct {
// contains filtered or unexported fields
}
func NewMessageProcessor ¶
func NewMessageProcessor( identity *ecdsa.PrivateKey, database *sql.DB, enc *encryption.Protocol, transport *transport.Transport, logger *zap.Logger, features FeatureFlags, ) (*MessageProcessor, error)
func (*MessageProcessor) AddEphemeralKey ¶
func (p *MessageProcessor) AddEphemeralKey(privateKey *ecdsa.PrivateKey) (*transport.Filter, error)
AddEphemeralKey adds an ephemeral key that we will be listening to note that we never removed them from now, as waku/whisper does not recalculate topics on removal, so effectively there's no benefit. On restart they will be gone.
func (*MessageProcessor) EncodeAbridgedMembershipUpdate ¶ added in v0.69.0
func (p *MessageProcessor) EncodeAbridgedMembershipUpdate( group *v1protocol.Group, chatEntity ChatEntity, ) ([]byte, error)
EncodeAbridgedMembershipUpdate takes a group and an optional chat message and returns the protobuf representation to be sent on the wire. Only the events relevant to the sender are encoded
func (*MessageProcessor) EncodeMembershipUpdate ¶
func (p *MessageProcessor) EncodeMembershipUpdate( group *v1protocol.Group, chatEntity ChatEntity, ) ([]byte, error)
EncodeMembershipUpdate takes a group and an optional chat message and returns the protobuf representation to be sent on the wire. All the events in a group are encoded and added to the payload
func (*MessageProcessor) HandleMessages ¶
func (p *MessageProcessor) HandleMessages(shhMessage *types.Message, applicationLayer bool) ([]*v1protocol.StatusMessage, [][]byte, error)
HandleMessages expects a whisper message as input, and it will go through a series of transformations until the message is parsed into an application layer message, or in case of Raw methods, the processing stops at the layer before. It returns an error only if the processing of required steps failed.
func (*MessageProcessor) JoinPublic ¶
func (p *MessageProcessor) JoinPublic(id string) (*transport.Filter, error)
func (*MessageProcessor) SendCommunityMessage ¶ added in v0.72.0
func (p *MessageProcessor) SendCommunityMessage( ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage, ) ([]byte, error)
SendCommunityMessage takes encoded data, encrypts it and sends through the wire using the community topic and their key
func (*MessageProcessor) SendGroup ¶
func (p *MessageProcessor) SendGroup( ctx context.Context, recipients []*ecdsa.PublicKey, rawMessage RawMessage, ) ([]byte, error)
SendGroup takes encoded data, encrypts it and sends through the wire, always return the messageID
func (*MessageProcessor) SendPairInstallation ¶
func (p *MessageProcessor) SendPairInstallation( ctx context.Context, recipient *ecdsa.PublicKey, rawMessage RawMessage, ) ([]byte, error)
sendPairInstallation sends data to the recipients, using DH
func (*MessageProcessor) SendPrivate ¶
func (p *MessageProcessor) SendPrivate( ctx context.Context, recipient *ecdsa.PublicKey, rawMessage *RawMessage, ) ([]byte, error)
SendPrivate takes encoded data, encrypts it and sends through the wire.
func (*MessageProcessor) SendPublic ¶
func (p *MessageProcessor) SendPublic( ctx context.Context, chatName string, rawMessage RawMessage, ) ([]byte, error)
SendPublic takes encoded data, encrypts it and sends through the wire.
func (*MessageProcessor) SetHandleSharedSecrets ¶ added in v0.59.0
func (p *MessageProcessor) SetHandleSharedSecrets(handler func([]*sharedsecret.Secret) error)
func (*MessageProcessor) Stop ¶
func (p *MessageProcessor) Stop()
func (*MessageProcessor) SubscribeToScheduledMessages ¶
func (p *MessageProcessor) SubscribeToScheduledMessages() <-chan *RawMessage
SubscribeToScheduledMessages returns a channel where we publish every time a message is scheduled for sending
func (*MessageProcessor) SubscribeToSentMessages ¶
func (p *MessageProcessor) SubscribeToSentMessages() <-chan *SentMessage
SubscribeToSentMessages returns a channel where we publish every time a message is sent
type QuotedMessage ¶ added in v0.61.0
type QuotedMessage struct { // From is a public key of the author of the message. From string `json:"from"` Text string `json:"text"` ParsedText json.RawMessage `json:"parsedText,omitempty"` // Base64Image is the converted base64 image Base64Image string `json:"image,omitempty"` // Base64Audio is the converted base64 audio Base64Audio string `json:"audio,omitempty"` // AudioDurationMs is the audio duration in milliseconds AudioDurationMs uint64 `json:"audioDurationMs,omitempty"` // CommunityID is the id of the community advertised CommunityID string `json:"communityId,omitempty"` }
QuotedMessage contains the original text of the message replied to
type RawMessage ¶
type RawMessage struct { ID string LocalChatID string LastSent uint64 SendCount int Sent bool ResendAutomatically bool SkipEncryption bool SendPushNotification bool MessageType protobuf.ApplicationMetadataMessage_Type Payload []byte Sender *ecdsa.PrivateKey Recipients []*ecdsa.PublicKey SkipGroupMessageWrap bool SendOnPersonalTopic bool }
RawMessage represent a sent or received message, kept for being able to re-send/propagate
type RawMessageConfirmation ¶ added in v0.73.5
type RawMessageConfirmation struct { // DataSyncID is the ID of the datasync message sent DataSyncID []byte // MessageID is the message id of the message MessageID []byte // PublicKey is the compressed receiver public key PublicKey []byte // ConfirmedAt is the unix timestamp in seconds of when the message was confirmed ConfirmedAt int64 }
type RawMessagesPersistence ¶ added in v0.73.5
type RawMessagesPersistence struct {
// contains filtered or unexported fields
}
func NewRawMessagesPersistence ¶ added in v0.73.5
func NewRawMessagesPersistence(db *sql.DB) *RawMessagesPersistence
func (RawMessagesPersistence) InsertPendingConfirmation ¶ added in v0.73.5
func (db RawMessagesPersistence) InsertPendingConfirmation(confirmation *RawMessageConfirmation) error
func (RawMessagesPersistence) MarkAsConfirmed ¶ added in v0.73.5
func (db RawMessagesPersistence) MarkAsConfirmed(dataSyncID []byte, atLeastOne bool) (messageID types.HexBytes, err error)
MarkAsConfirmed marks all the messages with dataSyncID as confirmed and returns the messageIDs that can be considered confirmed. If atLeastOne is set it will return messageid if at least once of the messages sent has been confirmed
func (RawMessagesPersistence) RawMessageByID ¶ added in v0.73.5
func (db RawMessagesPersistence) RawMessageByID(id string) (*RawMessage, error)
func (RawMessagesPersistence) RawMessagesIDsByType ¶ added in v0.73.5
func (db RawMessagesPersistence) RawMessagesIDsByType(t protobuf.ApplicationMetadataMessage_Type) ([]string, error)
func (RawMessagesPersistence) SaveRawMessage ¶ added in v0.73.5
func (db RawMessagesPersistence) SaveRawMessage(message *RawMessage) error
type SentMessage ¶
type SentMessage struct { PublicKey *ecdsa.PublicKey Spec *encryption.ProtocolMessageSpec MessageIDs [][]byte }
SentMessage reprent a message that has been passed to the transport layer
type SimplifiedTextVisitor ¶ added in v0.74.2
type SimplifiedTextVisitor struct {
// contains filtered or unexported fields
}
implement interface of https://github.com/status-im/markdown/blob/b9fe921681227b1dace4b56364e15edb3b698308/ast/node.go#L701
func (*SimplifiedTextVisitor) Visit ¶ added in v0.74.2
func (v *SimplifiedTextVisitor) Visit(node ast.Node, entering bool) ast.WalkStatus
type TimeSource ¶ added in v0.67.0
type TimeSource interface {
GetCurrentTime() uint64
}
TimeSource provides a unified way of getting the current time. The intention is to always use a synchronized time source between all components of the protocol.
This is required by Whisper and Waku protocols which rely on a fact that all peers have a synchronized time source.