2019-01-04 21:44:21 +00:00
|
|
|
package event
|
|
|
|
|
|
|
|
// Type captures the definition of many common Cwtch application events
|
|
|
|
type Type string
|
|
|
|
|
|
|
|
// Defining Common Event Types
|
|
|
|
const (
|
|
|
|
StatusRequest = Type("StatusRequest")
|
|
|
|
ProtocolEngineStatus = Type("ProtocolEngineStatus")
|
|
|
|
|
2019-08-24 20:05:45 +00:00
|
|
|
// Attempt to outbound peer with a given remote peer
|
|
|
|
// attributes:
|
|
|
|
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
|
2019-01-04 21:44:21 +00:00
|
|
|
PeerRequest = Type("PeerRequest")
|
2019-08-07 18:49:44 +00:00
|
|
|
|
2019-08-24 20:05:45 +00:00
|
|
|
// RetryPeerRequest
|
|
|
|
// Identical to PeerRequest, but allows Engine to make decisions regarding blocked peers
|
|
|
|
// attributes:
|
|
|
|
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
|
|
|
|
RetryPeerRequest = Type("RetryPeerRequest")
|
|
|
|
|
2021-04-28 19:47:55 +00:00
|
|
|
// RetryServerRequest
|
|
|
|
// Asks CwtchPeer to retry a server connection...
|
|
|
|
// GroupServer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
|
|
|
|
RetryServerRequest = Type("RetryServerRequest")
|
|
|
|
|
2020-06-16 00:16:04 +00:00
|
|
|
// RemotePeer
|
2022-01-06 17:55:26 +00:00
|
|
|
// ConversationID
|
|
|
|
// Accepted
|
|
|
|
// Blocked
|
|
|
|
UpdateConversationAuthorization = Type("UpdateConversationAuthorization")
|
2019-08-07 18:49:44 +00:00
|
|
|
|
2019-08-21 19:25:26 +00:00
|
|
|
// Turn on/off blocking of unknown peers (if peers aren't in the contact list then they will be autoblocked
|
|
|
|
BlockUnknownPeers = Type("BlockUnknownPeers")
|
|
|
|
AllowUnknownPeers = Type("AllowUnknownPeers")
|
|
|
|
|
2019-09-26 23:43:34 +00:00
|
|
|
// GroupServer
|
2019-08-07 18:49:44 +00:00
|
|
|
JoinServer = Type("JoinServer")
|
2019-01-04 21:44:21 +00:00
|
|
|
|
2020-10-29 21:51:59 +00:00
|
|
|
// attributes GroupServer - the onion of the server to leave
|
|
|
|
LeaveServer = Type("LeaveServer")
|
|
|
|
|
2019-01-04 21:44:21 +00:00
|
|
|
ProtocolEngineStartListen = Type("ProtocolEngineStartListen")
|
|
|
|
ProtocolEngineStopped = Type("ProtocolEngineStopped")
|
|
|
|
|
|
|
|
InvitePeerToGroup = Type("InvitePeerToGroup")
|
2019-02-11 21:40:20 +00:00
|
|
|
|
|
|
|
// a group invite has been received from a remote peer
|
|
|
|
// attributes:
|
|
|
|
// TimestampReceived [eg time.Now().Format(time.RFC3339Nano)]
|
|
|
|
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
|
|
|
|
// GroupInvite: [eg "torv3....."]
|
2020-09-21 21:26:28 +00:00
|
|
|
// Imported
|
2019-02-13 02:00:05 +00:00
|
|
|
NewGroupInvite = Type("NewGroupInvite")
|
2019-01-04 21:44:21 +00:00
|
|
|
|
2020-12-17 01:40:03 +00:00
|
|
|
// Inform the UI about a new group
|
|
|
|
// GroupID: groupID (allows them to fetch from the peer)
|
|
|
|
NewGroup = Type("NewGroup")
|
|
|
|
|
2019-08-14 20:56:45 +00:00
|
|
|
SendMessageToGroup = Type("SendMessagetoGroup")
|
|
|
|
|
|
|
|
//Ciphertext, Signature:
|
2019-01-04 21:44:21 +00:00
|
|
|
EncryptedGroupMessage = Type("EncryptedGroupMessage")
|
2019-08-14 20:56:45 +00:00
|
|
|
//TimestampReceived, TimestampSent, Data(Message), GroupID, Signature, PreviousSignature, RemotePeer
|
|
|
|
NewMessageFromGroup = Type("NewMessageFromGroup")
|
2019-01-04 21:44:21 +00:00
|
|
|
|
2021-05-14 18:26:04 +00:00
|
|
|
// Sent if a Group Key is detected as being used outside of expected parameters (e.g. with tampered signatures)
|
|
|
|
// GroupID: The ID of the Group that is presumed compromised
|
|
|
|
GroupCompromised = Type("GroupCompromised")
|
|
|
|
|
2019-06-05 20:40:55 +00:00
|
|
|
// an error was encountered trying to send a particular Message to a group
|
2019-02-20 20:58:05 +00:00
|
|
|
// attributes:
|
2019-06-05 20:40:55 +00:00
|
|
|
// GroupServer: The server the Message was sent to
|
|
|
|
// Signature: The signature of the Message that failed to send
|
2019-02-20 20:58:05 +00:00
|
|
|
// Error: string describing the error
|
|
|
|
SendMessageToGroupError = Type("SendMessageToGroupError")
|
|
|
|
|
2021-12-06 20:20:38 +00:00
|
|
|
SendMessageToPeer = Type("SendMessageToPeer")
|
|
|
|
NewMessageFromPeer = Type("NewMessageFromPeer")
|
|
|
|
NewMessageFromPeerEngine = Type("NewMessageFromPeerEngine")
|
2019-01-21 20:11:40 +00:00
|
|
|
|
2020-03-07 07:41:00 +00:00
|
|
|
// RemotePeer, scope, path
|
|
|
|
NewGetValMessageFromPeer = Type("NewGetValMessageFromPeer")
|
|
|
|
|
|
|
|
// RemotePeer, val, exists
|
|
|
|
SendRetValMessageToPeer = Type("SendRetValMessageToPeer")
|
|
|
|
|
|
|
|
// RemotePeer, scope, val
|
|
|
|
SendGetValMessageToPeer = Type("SendGetValMessageToPeer")
|
|
|
|
|
|
|
|
// RemotePeer, scope, path, data, exists
|
|
|
|
NewRetValMessageFromPeer = Type("NewRetValMessageFromPeer")
|
|
|
|
|
2019-07-22 20:49:23 +00:00
|
|
|
// Peer acknowledges a previously sent message
|
|
|
|
// attributes
|
|
|
|
// EventID: The original event id that the peer is responding too.
|
2019-07-29 20:21:58 +00:00
|
|
|
// RemotePeer: The peer associated with the acknowledgement
|
2019-07-22 20:49:23 +00:00
|
|
|
PeerAcknowledgement = Type("PeerAcknowledgement")
|
|
|
|
|
2021-05-03 18:35:35 +00:00
|
|
|
// Like PeerAcknowledgement but with message index instead of event ID
|
|
|
|
// attributes
|
|
|
|
// Index: The original index of the message that the peer is responding too.
|
|
|
|
// RemotePeer: The peer associated with the acknowledgement
|
|
|
|
IndexedAcknowledgement = Type("IndexedAcknowledgement")
|
|
|
|
|
2021-05-26 17:07:08 +00:00
|
|
|
// Like PeerAcknowledgement but with message index instead of event ID
|
|
|
|
// attributes
|
|
|
|
// Index: The original index of the message that the peer is responding too.
|
|
|
|
// RemotePeer: The peer associated with the acknowledgement
|
|
|
|
IndexedFailure = Type("IndexedFailure")
|
|
|
|
|
2019-02-14 21:04:40 +00:00
|
|
|
// attributes:
|
|
|
|
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
|
|
|
|
// Error: string describing the error
|
|
|
|
SendMessageToPeerError = Type("SendMessageToPeerError")
|
|
|
|
|
2019-01-28 19:59:00 +00:00
|
|
|
// REQUESTS TO STORAGE ENGINE
|
|
|
|
|
2019-02-03 01:18:33 +00:00
|
|
|
// a peer contact has been added
|
|
|
|
// attributes:
|
|
|
|
// RemotePeer [eg ""]
|
2021-11-17 22:34:13 +00:00
|
|
|
ContactCreated = Type("ContactCreated")
|
2019-02-03 01:18:33 +00:00
|
|
|
|
2019-12-12 20:21:14 +00:00
|
|
|
// Password, NewPassword
|
|
|
|
ChangePassword = Type("ChangePassword")
|
|
|
|
|
2021-12-17 19:46:24 +00:00
|
|
|
// Error(err), EventID
|
|
|
|
ChangePasswordError = Type("ChangePasswordError")
|
|
|
|
|
|
|
|
// EventID
|
|
|
|
ChangePasswordSuccess = Type("ChangePasswordSuccess")
|
|
|
|
|
2019-02-03 01:18:33 +00:00
|
|
|
// a group has been successfully added or newly created
|
|
|
|
// attributes:
|
|
|
|
// Data [serialized *model.Group]
|
|
|
|
GroupCreated = Type("GroupCreated")
|
|
|
|
|
2019-08-07 05:27:11 +00:00
|
|
|
// RemotePeer
|
|
|
|
DeleteContact = Type("DeleteContact")
|
|
|
|
|
|
|
|
// GroupID
|
|
|
|
DeleteGroup = Type("DeleteGroup")
|
|
|
|
|
2019-09-19 23:14:35 +00:00
|
|
|
// PeerStateChange servers as a new incoming connection message as well, and can/is consumed by frontends to alert of new p2p connections
|
2019-05-15 20:12:11 +00:00
|
|
|
// RemotePeer
|
|
|
|
// ConnectionState
|
|
|
|
PeerStateChange = Type("PeerStateChange")
|
|
|
|
|
|
|
|
// GroupServer
|
|
|
|
// ConnectionState
|
2019-07-19 17:27:50 +00:00
|
|
|
ServerStateChange = Type("ServerStateChange")
|
2019-06-05 20:40:55 +00:00
|
|
|
|
|
|
|
/***** Application client / service messages *****/
|
|
|
|
|
2020-11-02 22:35:11 +00:00
|
|
|
// app: Identity(onion), Created(bool)
|
|
|
|
// service -> client: Identity(localId), Password, [Status(new/default=blank || from reload='running')], Created(bool)
|
2019-06-05 20:40:55 +00:00
|
|
|
NewPeer = Type("NewPeer")
|
|
|
|
|
2019-12-10 23:45:43 +00:00
|
|
|
// Identity(onion)
|
|
|
|
DeletePeer = Type("DeletePeer")
|
2021-06-14 23:50:35 +00:00
|
|
|
// Identity(onion)
|
|
|
|
PeerDeleted = Type("PeerDeleted")
|
2019-12-10 23:45:43 +00:00
|
|
|
|
2019-06-05 20:40:55 +00:00
|
|
|
// Identity(onion)
|
|
|
|
ShutdownPeer = Type("ShutdownPeer")
|
|
|
|
|
|
|
|
Shutdown = Type("Shutdown")
|
|
|
|
|
|
|
|
// Error(err)
|
2019-12-12 20:21:14 +00:00
|
|
|
// Error creating peer
|
2019-06-05 20:40:55 +00:00
|
|
|
PeerError = Type("PeerError")
|
|
|
|
|
|
|
|
// Error(err)
|
|
|
|
AppError = Type("AppError")
|
2019-07-10 20:30:24 +00:00
|
|
|
|
|
|
|
// Progress, Status
|
|
|
|
ACNStatus = Type("ACNStatus")
|
2019-10-31 23:05:01 +00:00
|
|
|
|
2020-12-01 03:25:17 +00:00
|
|
|
// Data
|
|
|
|
ACNVersion = Type("ACNVersion")
|
|
|
|
|
2019-10-31 23:05:01 +00:00
|
|
|
// Network Status
|
|
|
|
// Status: Success || Error
|
|
|
|
// Error: Description of the Error
|
|
|
|
// Onion: the local onion we attempt to check
|
|
|
|
NetworkStatus = Type("NetworkError")
|
2020-01-13 22:11:00 +00:00
|
|
|
|
|
|
|
// For debugging. Allows test to emit a Syn and get a response Ack(eventID) when the subsystem is done processing a queue
|
|
|
|
Syn = Type("Syn")
|
|
|
|
Ack = Type("Ack")
|
2021-06-17 21:40:06 +00:00
|
|
|
|
|
|
|
// For situations where we want to update $Identity -> $RemotePeer/$GroupID's total message count to be $Data
|
|
|
|
MessageCounterResync = Type("MessageCounterResync")
|
2021-09-30 00:57:13 +00:00
|
|
|
|
|
|
|
// File Handling Events
|
|
|
|
ShareManifest = Type("ShareManifest")
|
|
|
|
ManifestSizeReceived = Type("ManifestSizeReceived")
|
|
|
|
ManifestError = Type("ManifestError")
|
|
|
|
ManifestReceived = Type("ManifestReceived")
|
|
|
|
ManifestSaved = Type("ManifestSaved")
|
|
|
|
FileDownloadProgressUpdate = Type("FileDownloadProgressUpdate")
|
|
|
|
FileDownloaded = Type("FileDownloaded")
|
|
|
|
FileVerificationFailed = Type("FileVerificationFailed")
|
2021-11-25 22:34:47 +00:00
|
|
|
|
|
|
|
// Profile Attribute Event
|
|
|
|
UpdatedProfileAttribute = Type("UpdatedProfileAttribute")
|
2021-12-17 19:42:55 +00:00
|
|
|
|
|
|
|
StartingStorageMiragtion = Type("StartingStorageMigration")
|
|
|
|
DoneStorageMigration = Type("DoneStorageMigration")
|
2019-01-04 21:44:21 +00:00
|
|
|
)
|
2019-01-21 18:47:07 +00:00
|
|
|
|
|
|
|
// Field defines common event attributes
|
|
|
|
type Field string
|
|
|
|
|
|
|
|
// Defining Common Field Types
|
|
|
|
const (
|
2019-10-31 23:05:01 +00:00
|
|
|
|
|
|
|
// A peers local onion address
|
|
|
|
Onion = Field("Onion")
|
|
|
|
|
2019-01-21 20:08:03 +00:00
|
|
|
RemotePeer = Field("RemotePeer")
|
|
|
|
Ciphertext = Field("Ciphertext")
|
|
|
|
Signature = Field("Signature")
|
2019-02-04 01:55:13 +00:00
|
|
|
PreviousSignature = Field("PreviousSignature")
|
2019-01-21 18:47:07 +00:00
|
|
|
TimestampSent = Field("TimestampSent")
|
|
|
|
TimestampReceived = Field("TimestampReceived")
|
2019-01-21 20:08:03 +00:00
|
|
|
|
|
|
|
Identity = Field("Identity")
|
|
|
|
|
2021-11-17 22:34:13 +00:00
|
|
|
ConversationID = Field("ConversationID")
|
|
|
|
GroupID = Field("GroupID")
|
|
|
|
GroupServer = Field("GroupServer")
|
2021-12-16 18:11:16 +00:00
|
|
|
GroupName = Field("GroupName")
|
2021-11-17 22:34:13 +00:00
|
|
|
ServerTokenY = Field("ServerTokenY")
|
|
|
|
ServerTokenOnion = Field("ServerTokenOnion")
|
|
|
|
GroupInvite = Field("GroupInvite")
|
2019-01-21 20:08:03 +00:00
|
|
|
|
2019-01-21 20:37:06 +00:00
|
|
|
ProfileName = Field("ProfileName")
|
2019-06-05 20:40:55 +00:00
|
|
|
Password = Field("Password")
|
2019-12-12 20:21:14 +00:00
|
|
|
NewPassword = Field("NewPassword")
|
2019-01-21 20:37:06 +00:00
|
|
|
|
2020-11-02 22:35:11 +00:00
|
|
|
Created = Field("Created")
|
|
|
|
|
2019-05-15 20:12:11 +00:00
|
|
|
ConnectionState = Field("ConnectionState")
|
|
|
|
|
2020-03-07 07:41:00 +00:00
|
|
|
Key = Field("Key")
|
|
|
|
Data = Field("Data")
|
|
|
|
Scope = Field("Scope")
|
|
|
|
Path = Field("Path")
|
|
|
|
Exists = Field("Exists")
|
2019-01-21 20:08:03 +00:00
|
|
|
|
2020-01-13 22:11:00 +00:00
|
|
|
Salt = Field("Salt")
|
|
|
|
|
2019-01-21 20:08:03 +00:00
|
|
|
Error = Field("Error")
|
2019-07-10 20:30:24 +00:00
|
|
|
|
2021-04-13 22:12:12 +00:00
|
|
|
Progress = Field("Progress")
|
2019-07-22 20:49:23 +00:00
|
|
|
Status = Field("Status")
|
|
|
|
EventID = Field("EventID")
|
|
|
|
EventContext = Field("EventContext")
|
2021-05-03 18:35:35 +00:00
|
|
|
Index = Field("Index")
|
2020-06-16 00:16:04 +00:00
|
|
|
|
2021-06-08 22:29:04 +00:00
|
|
|
// Handle denotes a contact handle of any type.
|
|
|
|
Handle = Field("Handle")
|
|
|
|
|
|
|
|
// Flags denotes a set of message flags
|
|
|
|
Flags = Field("Flags")
|
2020-06-16 00:16:04 +00:00
|
|
|
|
2022-01-06 17:55:26 +00:00
|
|
|
Accepted = Field("Accepted")
|
|
|
|
Blocked = Field("Blocked")
|
2020-09-21 21:26:28 +00:00
|
|
|
|
|
|
|
KeyBundle = Field("KeyBundle")
|
|
|
|
|
|
|
|
// Indicate whether an event was triggered by a user import
|
|
|
|
Imported = Field("Imported")
|
2021-04-28 19:47:55 +00:00
|
|
|
|
|
|
|
Source = Field("Source")
|
2021-09-30 00:57:13 +00:00
|
|
|
|
|
|
|
FileKey = Field("FileKey")
|
|
|
|
FileSizeInChunks = Field("FileSizeInChunks")
|
|
|
|
ManifestSize = Field("ManifestSize")
|
|
|
|
SerializedManifest = Field("SerializedManifest")
|
|
|
|
TempFile = Field("TempFile")
|
|
|
|
FilePath = Field("FilePath")
|
|
|
|
NameSuggestion = Field("NameSuggestion")
|
2019-01-21 18:47:07 +00:00
|
|
|
)
|
2019-06-05 20:40:55 +00:00
|
|
|
|
|
|
|
// Defining Common errors
|
|
|
|
const (
|
2021-06-24 01:29:23 +00:00
|
|
|
AppErrLoaded0 = "Loaded 0 profiles"
|
2021-06-14 23:50:35 +00:00
|
|
|
PasswordMatchError = "Password did not match"
|
2019-06-05 20:40:55 +00:00
|
|
|
)
|
2019-07-23 17:57:04 +00:00
|
|
|
|
|
|
|
// Defining Protocol Contexts
|
|
|
|
const (
|
2021-09-30 00:57:13 +00:00
|
|
|
ContextAck = "im.cwtch.acknowledgement"
|
|
|
|
ContextInvite = "im.cwtch.invite"
|
|
|
|
ContextRaw = "im.cwtch.raw"
|
|
|
|
ContextGetVal = "im.cwtch.getVal"
|
|
|
|
ContextRetVal = "im.cwtch.retVal"
|
|
|
|
ContextRequestManifest = "im.cwtch.file.request.manifest"
|
|
|
|
ContextSendManifest = "im.cwtch.file.send.manifest"
|
|
|
|
ContextRequestFile = "im.cwtch.file.request.chunk"
|
|
|
|
ContextSendFile = "im.cwtch.file.send.chunk"
|
2019-07-23 17:57:04 +00:00
|
|
|
)
|
2020-07-08 18:29:33 +00:00
|
|
|
|
|
|
|
// Define Default Attribute Keys
|
|
|
|
const (
|
|
|
|
SaveHistoryKey = "SavePeerHistory"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Define Default Attribute Values
|
|
|
|
const (
|
|
|
|
// Save History has 3 distinct states. By default we don't save history (DefaultDeleteHistory), if the peer confirms this
|
|
|
|
// we change to DeleteHistoryConfirmed, if they confirm they want to save then this becomes SaveHistoryConfirmed
|
|
|
|
// We use this distinction between default and confirmed to drive UI
|
|
|
|
DeleteHistoryDefault = "DefaultDeleteHistory"
|
|
|
|
SaveHistoryConfirmed = "SaveHistory"
|
|
|
|
DeleteHistoryConfirmed = "DeleteHistoryConfirmed"
|
|
|
|
)
|
2020-11-02 22:35:11 +00:00
|
|
|
|
|
|
|
// Bool strings
|
|
|
|
const (
|
2020-11-02 23:53:13 +00:00
|
|
|
True = "true"
|
2020-11-02 22:35:11 +00:00
|
|
|
False = "false"
|
2020-11-02 23:53:13 +00:00
|
|
|
)
|