Documentation ¶
Index ¶
- Constants
- Variables
- func CreateKeySalt(password string) ([32]byte, [128]byte, error)
- type AccessPeeringState
- type ChannelID
- type CwtchPeer
- func CreateEncryptedStorePeer(profileDirectory string, name string, password string) (CwtchPeer, error)
- func FromEncryptedDatabase(profileDirectory string, password string) (CwtchPeer, error)
- func FromEncryptedStorage(cps *CwtchProfileStorage) CwtchPeer
- func ImportLegacyProfile(profile *model.Profile, cps *CwtchProfileStorage) CwtchPeer
- func NewProfileWithEncryptedStorage(name string, cps *CwtchProfileStorage) CwtchPeer
- type CwtchProfileStorage
- func (cps *CwtchProfileStorage) AcceptConversation(id int) error
- func (cps *CwtchProfileStorage) Close()
- func (cps *CwtchProfileStorage) Delete()
- func (cps *CwtchProfileStorage) DeleteConversation(id int) error
- func (cps *CwtchProfileStorage) FetchConversations() ([]*model.Conversation, error)
- func (cps *CwtchProfileStorage) GetChannelMessage(conversation int, channel int, messageID int) (string, model.Attributes, error)
- func (cps *CwtchProfileStorage) GetChannelMessageByContentHash(conversation int, channel int, hash string) (int, error)
- func (cps *CwtchProfileStorage) GetChannelMessageBySignature(conversation int, channel int, signature string) (int, error)
- func (cps *CwtchProfileStorage) GetChannelMessageCount(conversation int, channel int) (int, error)
- func (cps *CwtchProfileStorage) GetConversation(id int) (*model.Conversation, error)
- func (cps *CwtchProfileStorage) GetConversationByHandle(handle string) (*model.Conversation, error)
- func (cps *CwtchProfileStorage) GetMostRecentMessages(conversation int, channel int, offset int, limit int) ([]model.ConversationMessage, error)
- func (cps *CwtchProfileStorage) GetRowNumberByMessageID(conversation int, channel int, id int) (int, error)
- func (cps *CwtchProfileStorage) InsertMessage(conversation int, channel int, body string, attributes model.Attributes, ...) (int, error)
- func (cps *CwtchProfileStorage) LoadProfileKeyValue(keyType StorageKeyType, key string) ([]byte, error)
- func (cps *CwtchProfileStorage) NewConversation(handle string, attributes model.Attributes, acl model.AccessControlList, ...) (int, error)
- func (cps *CwtchProfileStorage) PurgeConversationChannel(conversation int, channel int) error
- func (cps *CwtchProfileStorage) PurgeNonSavedMessages()
- func (cps *CwtchProfileStorage) Rekey(newkey [32]byte) error
- func (cps *CwtchProfileStorage) SetConversationACL(id int, acl model.AccessControlList) error
- func (cps *CwtchProfileStorage) SetConversationAttribute(id int, path attr.ScopedZonedPath, value string) error
- func (cps *CwtchProfileStorage) StoreProfileKeyValue(keyType StorageKeyType, key string, value []byte) error
- func (cps *CwtchProfileStorage) UpdateMessageAttributes(conversation int, channel int, messageID int, attributes model.Attributes) error
- type ModifyContactsAndPeers
- type ModifyGroups
- type ModifyPeeringState
- type ModifyServers
- type ReadServers
- type Response
- type SendMessages
- type StorageKeyType
Constants ¶
const ( // TypeAttribute for Profile Scoped and Zoned Attributes TypeAttribute = StorageKeyType("Attribute") // TypePrivateKey for Profile Private Keys TypePrivateKey = StorageKeyType("PrivateKey") // TypePublicKey for Profile Public Keys TypePublicKey = StorageKeyType("PublicKey") )
const SQLCreateTableConversations = `` /* 142-byte string literal not displayed */
SQLCreateTableConversations creates the Profile Key Value Table
const SQLCreateTableProfileKeyValue = `create table if not exists profile_kv (KeyType text, KeyName text, KeyValue blob, UNIQUE (KeyType,KeyName));`
SQLCreateTableProfileKeyValue creates the Profile Key Value Table
Variables ¶
var DefaultEventsToHandle = []event.Type{ event.EncryptedGroupMessage, event.NewMessageFromPeerEngine, event.PeerAcknowledgement, event.NewGroupInvite, event.PeerError, event.SendMessageToGroupError, event.NewGetValMessageFromPeer, event.ProtocolEngineStopped, event.RetryServerRequest, }
DefaultEventsToHandle specifies which events will be subscribed to
when a peer has its Init() function called
Functions ¶
Types ¶
type AccessPeeringState ¶ added in v0.6.3
type AccessPeeringState interface {
GetPeerState(string) connections.ConnectionState
}
AccessPeeringState provides access to functions relating to the underlying connections of a peer.
type ChannelID ¶ added in v0.14.0
ChannelID encapsulates the data necessary to reference a channel structure.
type CwtchPeer ¶
type CwtchPeer interface { // Core Cwtch Peer Functions that should not be exposed to // most functions Init(event.Manager) GenerateProtocolEngine(acn connectivity.ACN, bus event.Manager) (connections.Engine, error) AutoHandleEvents(events []event.Type) Listen() StartPeersConnections() StartServerConnections() Shutdown() // GetOnion is deprecated. If you find yourself needing to rely on this method it is time // to consider replacing this with a GetAddress(es) function that can fully expand cwtch beyond the boundaries // of tor v3 onion services. // Deprecated GetOnion() string // SetScopedZonedAttribute allows the setting of an attribute by scope and zone // scope.zone.key = value SetScopedZonedAttribute(scope attr.Scope, zone attr.Zone, key string, value string) // GetScopedZonedAttribute allows the retrieval of an attribute by scope and zone // scope.zone.key = value GetScopedZonedAttribute(scope attr.Scope, zone attr.Zone, key string) (string, bool) AccessPeeringState ModifyPeeringState ModifyGroups ReadServers ModifyServers SendMessages // Import Bundle ImportBundle(string) error // New Unified Conversation Interfaces NewContactConversation(handle string, acl model.AccessControl, accepted bool) (int, error) FetchConversations() ([]*model.Conversation, error) GetConversationInfo(conversation int) (*model.Conversation, error) FetchConversationInfo(handle string) (*model.Conversation, error) AcceptConversation(conversation int) error BlockConversation(conversation int) error UnblockConversation(conversation int) error SetConversationAttribute(conversation int, path attr.ScopedZonedPath, value string) error GetConversationAttribute(conversation int, path attr.ScopedZonedPath) (string, error) DeleteConversation(conversation int) error // New Unified Conversation Channel Interfaces GetChannelMessage(conversation int, channel int, id int) (string, model.Attributes, error) GetChannelMessageCount(conversation int, channel int) (int, error) GetChannelMessageByContentHash(conversation int, channel int, contenthash string) (int, error) GetMostRecentMessages(conversation int, channel int, offset int, limit int) ([]model.ConversationMessage, error) UpdateMessageAttribute(conversation int, channel int, id int, key string, value string) error CheckPassword(password string) bool ChangePassword(oldpassword string, newpassword string, newpasswordAgain string) error Delete() }
CwtchPeer provides us with a way of testing systems built on top of cwtch without having to directly implement a cwtchPeer.
func CreateEncryptedStorePeer ¶ added in v0.14.0
func CreateEncryptedStorePeer(profileDirectory string, name string, password string) (CwtchPeer, error)
CreateEncryptedStorePeer creates a *new* Cwtch Profile backed by an encrypted datastore
func FromEncryptedDatabase ¶ added in v0.14.0
FromEncryptedDatabase constructs a Cwtch Profile from an existing Encrypted Database
func FromEncryptedStorage ¶ added in v0.14.0
func FromEncryptedStorage(cps *CwtchProfileStorage) CwtchPeer
FromEncryptedStorage loads an existing Profile from Encrypted Storage
func ImportLegacyProfile ¶ added in v0.14.0
func ImportLegacyProfile(profile *model.Profile, cps *CwtchProfileStorage) CwtchPeer
ImportLegacyProfile generates a new peer from a profile. Deprecated - Only to be used for importing new profiles
func NewProfileWithEncryptedStorage ¶ added in v0.14.0
func NewProfileWithEncryptedStorage(name string, cps *CwtchProfileStorage) CwtchPeer
NewProfileWithEncryptedStorage instantiates a new Cwtch Profile from encrypted storage
type CwtchProfileStorage ¶ added in v0.14.0
type CwtchProfileStorage struct { ProfileDirectory string // contains filtered or unexported fields }
CwtchProfileStorage encapsulates common datastore requests so as to not pollute the main cwtch profile struct with database knowledge
func CreateEncryptedStore ¶ added in v0.14.0
func CreateEncryptedStore(profileDirectory string, password string) (*CwtchProfileStorage, error)
CreateEncryptedStore creates a encrypted datastore
func NewCwtchProfileStorage ¶ added in v0.14.0
func NewCwtchProfileStorage(db *sql.DB, profileDirectory string) (*CwtchProfileStorage, error)
NewCwtchProfileStorage constructs a new CwtchProfileStorage from a database. It is also responsible for Preparing commonly used SQL Statements
func (*CwtchProfileStorage) AcceptConversation ¶ added in v0.14.0
func (cps *CwtchProfileStorage) AcceptConversation(id int) error
AcceptConversation sets the accepted status of a conversation to true in the backing datastore
func (*CwtchProfileStorage) Close ¶ added in v0.14.0
func (cps *CwtchProfileStorage) Close()
Close closes the underlying database and prepared statements
func (*CwtchProfileStorage) Delete ¶ added in v0.14.0
func (cps *CwtchProfileStorage) Delete()
Delete unconditionally destroys the profile directory associated with the store. This is unrecoverable.
func (*CwtchProfileStorage) DeleteConversation ¶ added in v0.14.0
func (cps *CwtchProfileStorage) DeleteConversation(id int) error
DeleteConversation purges the conversation and any associated message history from the conversation store.
func (*CwtchProfileStorage) FetchConversations ¶ added in v0.14.0
func (cps *CwtchProfileStorage) FetchConversations() ([]*model.Conversation, error)
FetchConversations returns *all* active conversations. This method should only be called on app start up to build a summary of conversations for the UI. Any further updates should be integrated through the event bus.
func (*CwtchProfileStorage) GetChannelMessage ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetChannelMessage(conversation int, channel int, messageID int) (string, model.Attributes, error)
GetChannelMessage looks up a channel message by conversation, channel and message id. On success it returns the message body and the attributes associated with the message. Otherwise an error is returned.
func (*CwtchProfileStorage) GetChannelMessageByContentHash ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetChannelMessageByContentHash(conversation int, channel int, hash string) (int, error)
GetChannelMessageByContentHash looks up a conversation message by hash instead of identifier.
func (*CwtchProfileStorage) GetChannelMessageBySignature ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetChannelMessageBySignature(conversation int, channel int, signature string) (int, error)
GetChannelMessageBySignature looks up a conversation message by signature instead of identifier. Both are unique but signatures are common between conversation participants (in groups) and so are a more useful message to index.
func (*CwtchProfileStorage) GetChannelMessageCount ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetChannelMessageCount(conversation int, channel int) (int, error)
GetChannelMessageCount returns the number of messages in a channel
func (*CwtchProfileStorage) GetConversation ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetConversation(id int) (*model.Conversation, error)
GetConversation looks up a particular conversation by id
func (*CwtchProfileStorage) GetConversationByHandle ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetConversationByHandle(handle string) (*model.Conversation, error)
GetConversationByHandle is a convenience method to fetch an active conversation by a handle Usage Notes: This should **only** be used to look up p2p conversations by convention. Ideally this function should not exist, and all lookups should happen by ID (this is currently unavoidable in some circumstances because the event bus references conversations by handle, not by id)
func (*CwtchProfileStorage) GetMostRecentMessages ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetMostRecentMessages(conversation int, channel int, offset int, limit int) ([]model.ConversationMessage, error)
GetMostRecentMessages returns the most recent messages in a channel up to a given limit at a given offset
func (*CwtchProfileStorage) GetRowNumberByMessageID ¶ added in v0.14.0
func (cps *CwtchProfileStorage) GetRowNumberByMessageID(conversation int, channel int, id int) (int, error)
GetRowNumberByMessageID looks up the row number of a message by the message ID
func (*CwtchProfileStorage) InsertMessage ¶ added in v0.14.0
func (cps *CwtchProfileStorage) InsertMessage(conversation int, channel int, body string, attributes model.Attributes, signature string, contentHash string) (int, error)
InsertMessage appends a message to a conversation channel, with a given set of attributes
func (*CwtchProfileStorage) LoadProfileKeyValue ¶ added in v0.14.0
func (cps *CwtchProfileStorage) LoadProfileKeyValue(keyType StorageKeyType, key string) ([]byte, error)
LoadProfileKeyValue allows fetching of typed values via a known Key from the Storage Engine
func (*CwtchProfileStorage) NewConversation ¶ added in v0.14.0
func (cps *CwtchProfileStorage) NewConversation(handle string, attributes model.Attributes, acl model.AccessControlList, accepted bool) (int, error)
NewConversation stores a new conversation in the data store
func (*CwtchProfileStorage) PurgeConversationChannel ¶ added in v0.14.0
func (cps *CwtchProfileStorage) PurgeConversationChannel(conversation int, channel int) error
PurgeConversationChannel deletes all message for a conversation channel.
func (*CwtchProfileStorage) PurgeNonSavedMessages ¶ added in v0.14.0
func (cps *CwtchProfileStorage) PurgeNonSavedMessages()
PurgeNonSavedMessages deletes all message conversations that are not explicitly set to saved.
func (*CwtchProfileStorage) Rekey ¶ added in v0.14.6
func (cps *CwtchProfileStorage) Rekey(newkey [32]byte) error
Rekey re-encrypts the datastore with the new key. **note* this is technically a very dangerous API and should only be called after checks on the current password and the derived new password.
func (*CwtchProfileStorage) SetConversationACL ¶ added in v0.14.0
func (cps *CwtchProfileStorage) SetConversationACL(id int, acl model.AccessControlList) error
SetConversationACL sets a new ACL on a given conversation.
func (*CwtchProfileStorage) SetConversationAttribute ¶ added in v0.14.0
func (cps *CwtchProfileStorage) SetConversationAttribute(id int, path attr.ScopedZonedPath, value string) error
SetConversationAttribute sets a new attribute on a given conversation.
func (*CwtchProfileStorage) StoreProfileKeyValue ¶ added in v0.14.0
func (cps *CwtchProfileStorage) StoreProfileKeyValue(keyType StorageKeyType, key string, value []byte) error
StoreProfileKeyValue allows storing of typed Key/Value attribute in the Storage Engine
func (*CwtchProfileStorage) UpdateMessageAttributes ¶ added in v0.14.0
func (cps *CwtchProfileStorage) UpdateMessageAttributes(conversation int, channel int, messageID int, attributes model.Attributes) error
UpdateMessageAttributes updates the attributes associated with a message of a given conversation
type ModifyContactsAndPeers ¶ added in v0.6.3
type ModifyContactsAndPeers interface { ModifyPeeringState }
ModifyContactsAndPeers is a meta-interface intended to restrict a call to reading and modifying contacts and peers.
type ModifyGroups ¶ added in v0.6.3
type ModifyGroups interface { ImportGroup(string) (int, error) StartGroup(string, string) (int, error) }
ModifyGroups provides write-only access add/edit/remove new groups
type ModifyPeeringState ¶ added in v0.6.3
type ModifyPeeringState interface { BlockUnknownConnections() AllowUnknownConnections() PeerWithOnion(string) JoinServer(string) error }
ModifyPeeringState is a meta-interface intended to restrict callers to modify-only access to connection peers
type ModifyServers ¶ added in v0.6.3
ModifyServers provides write-only access to servers
type ReadServers ¶ added in v0.6.3
type ReadServers interface {
GetServers() []string
}
ReadServers provides access to the servers
type Response ¶ added in v0.14.0
type Response error
Response is a wrapper to better semantically convey the response type...
func ConstructResponse ¶ added in v0.14.0
ConstructResponse is a helper function for creating Response structures.
type SendMessages ¶ added in v0.6.3
type SendMessages interface { SendMessage(conversation int, message string) error SendInviteToConversation(conversationID int, inviteConversationID int) error SendScopedZonedGetValToContact(conversationID int, scope attr.Scope, zone attr.Zone, key string) }
SendMessages enables a caller to sender messages to a contact
type StorageKeyType ¶ added in v0.14.0
type StorageKeyType string
StorageKeyType is an interface wrapper around storage key types