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 IsPubKeyEqual(a, b *ecdsa.PublicKey) bool
- func MessageSpecToWhisper(spec *encryption.ProtocolMessageSpec) (*types.NewMessage, error)
- func Shake256(buf []byte) []byte
- type ChatEntity
- type CommandParameters
- type CommandState
- type FeatureFlags
- type Message
- func (m *Message) GetProtobuf() proto.Message
- func (m Message) GetSigPubKey() *ecdsa.PublicKey
- 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
- type MessageProcessor
- func (p *MessageProcessor) AddEphemeralKey(privateKey *ecdsa.PrivateKey) (*transport.Filter, error)
- func (p *MessageProcessor) EncodeMembershipUpdate(group *v1protocol.Group, chatEntity ChatEntity) ([]byte, error)
- func (p *MessageProcessor) HandleMessages(shhMessage *types.Message, applicationLayer bool) ([]*v1protocol.StatusMessage, error)
- func (p *MessageProcessor) JoinPublic(chatID string) 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 NodeVisitor
- type QuotedMessage
- type RawMessage
- type SentMessage
Constants ¶
const ( OutgoingStatusSending = "sending" OutgoingStatusSent = "sent" )
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)
Types ¶
type ChatEntity ¶ added in v0.56.4
type ChatEntity interface { proto.Message GetChatId() string GetMessageType() protobuf.MessageType GetSigPubKey() *ecdsa.PublicKey GetProtobuf() proto.Message 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 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 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"` // 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"` // Replace indicates that this is a replacement of a message // that has been updated Replace string `json:"replace,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) GetSigPubKey ¶ added in v0.61.0
GetSigPubKey returns an ecdsa encoded public key this function is required to implement the ChatEntity interface
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
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) 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, 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(chatID string) error
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 NodeVisitor ¶ added in v0.62.15
type NodeVisitor struct {
// contains filtered or unexported fields
}
implement interface of https://github.com/status-im/markdown/blob/b9fe921681227b1dace4b56364e15edb3b698308/ast/node.go#L701
func (*NodeVisitor) Visit ¶ added in v0.62.15
func (v *NodeVisitor) Visit(node ast.Node, entering bool) ast.WalkStatus
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"` }
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 }
RawMessage represent a sent or received message, kept for being able to re-send/propagate
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