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")
|
|
|
|
|
2019-08-07 18:49:44 +00:00
|
|
|
// Blocking Events both Block and Unblock have the same structure
|
|
|
|
// attributes:
|
|
|
|
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
|
2019-01-04 21:44:21 +00:00
|
|
|
BlockPeer = Type("BlockPeer")
|
2019-08-07 18:49:44 +00:00
|
|
|
UnblockPeer = Type("UnblockPeer")
|
|
|
|
|
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
|
|
|
|
|
|
|
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....."]
|
2019-02-13 02:00:05 +00:00
|
|
|
NewGroupInvite = Type("NewGroupInvite")
|
2019-01-04 21:44:21 +00:00
|
|
|
|
2019-02-14 01:57:42 +00:00
|
|
|
// GroupID
|
|
|
|
AcceptGroupInvite = Type("AcceptGroupInvite")
|
|
|
|
|
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
|
|
|
|
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")
|
|
|
|
|
2019-01-04 21:44:21 +00:00
|
|
|
SendMessageToPeer = Type("SendMessageToPeer")
|
|
|
|
NewMessageFromPeer = Type("NewMessageFromPeer")
|
2019-01-21 20:11:40 +00:00
|
|
|
|
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")
|
|
|
|
|
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 ""]
|
|
|
|
PeerCreated = Type("PeerCreated")
|
|
|
|
|
|
|
|
// 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-01-28 19:59:00 +00:00
|
|
|
// change the .Name attribute of a profile (careful - this is not a custom attribute. it is used in the underlying protocol during handshakes!)
|
|
|
|
// attributes:
|
|
|
|
// ProfileName [eg "erinn"]
|
2019-01-21 20:11:40 +00:00
|
|
|
SetProfileName = Type("SetProfileName")
|
2019-01-22 19:11:25 +00:00
|
|
|
|
2019-01-28 19:59:00 +00:00
|
|
|
// request to store a profile-wide attribute (good for e.g. per-profile settings like theme prefs)
|
|
|
|
// attributes:
|
|
|
|
// Key [eg "fontcolor"]
|
|
|
|
// Data [eg "red"]
|
|
|
|
SetAttribute = Type("SetAttribute")
|
|
|
|
|
|
|
|
// request to store a per-contact attribute (e.g. display names for a peer)
|
|
|
|
// attributes:
|
|
|
|
// RemotePeer [eg ""]
|
|
|
|
// Key [eg "nick"]
|
|
|
|
// Data [eg "erinn"]
|
|
|
|
SetPeerAttribute = Type("SetPeerAttribute")
|
|
|
|
|
|
|
|
// request to store a per-cwtch-group attribute (e.g. display name for a group)
|
|
|
|
// attributes:
|
|
|
|
// GroupID [eg ""]
|
|
|
|
// Key [eg "nick"]
|
|
|
|
// Data [eg "open privacy board"]
|
|
|
|
SetGroupAttribute = Type("SetGroupAttribute")
|
2019-05-15 20:12:11 +00:00
|
|
|
|
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 *****/
|
|
|
|
|
|
|
|
// ProfileName, Password
|
|
|
|
CreatePeer = Type("CreatePeer")
|
|
|
|
|
2019-07-19 17:27:50 +00:00
|
|
|
// service -> client: Identity(localId), Password, [Status(new/default=blank || from reload='running')]
|
2019-06-05 20:40:55 +00:00
|
|
|
// app -> Identity(onion)
|
|
|
|
NewPeer = Type("NewPeer")
|
|
|
|
|
2019-08-02 01:09:01 +00:00
|
|
|
// Identity(onion), Data(pluginID)
|
|
|
|
AddPeerPlugin = Type("AddPeerPlugin")
|
|
|
|
|
2019-06-05 20:40:55 +00:00
|
|
|
// Password
|
|
|
|
LoadProfiles = Type("LoadProfiles")
|
|
|
|
|
2019-07-19 17:27:50 +00:00
|
|
|
// Client has reloaded, triggers NewPeer s then ReloadDone
|
|
|
|
ReloadClient = Type("ReloadClient")
|
|
|
|
|
|
|
|
ReloadDone = Type("ReloadDone")
|
|
|
|
|
|
|
|
// Identity - Ask service to resend all connection states
|
|
|
|
ReloadPeer = Type("ReloadPeer")
|
|
|
|
|
2019-06-05 20:40:55 +00:00
|
|
|
// Identity(onion)
|
|
|
|
ShutdownPeer = Type("ShutdownPeer")
|
|
|
|
|
|
|
|
Shutdown = Type("Shutdown")
|
|
|
|
|
|
|
|
// Error(err)
|
|
|
|
PeerError = Type("PeerError")
|
|
|
|
|
|
|
|
// Error(err)
|
|
|
|
AppError = Type("AppError")
|
2019-07-10 20:30:24 +00:00
|
|
|
|
2019-09-26 23:43:34 +00:00
|
|
|
GetACNStatus = Type("GetACNStatus")
|
|
|
|
|
2019-07-10 20:30:24 +00:00
|
|
|
// Progress, Status
|
|
|
|
ACNStatus = Type("ACNStatus")
|
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")
|
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")
|
|
|
|
|
|
|
|
GroupID = Field("GroupID")
|
|
|
|
GroupServer = Field("GroupServer")
|
|
|
|
GroupInvite = Field("GroupInvite")
|
|
|
|
|
2019-01-21 20:37:06 +00:00
|
|
|
ProfileName = Field("ProfileName")
|
2019-06-05 20:40:55 +00:00
|
|
|
Password = Field("Password")
|
2019-01-21 20:37:06 +00:00
|
|
|
|
2019-05-15 20:12:11 +00:00
|
|
|
ConnectionState = Field("ConnectionState")
|
|
|
|
|
2019-01-29 20:56:59 +00:00
|
|
|
Key = Field("Key")
|
2019-01-21 20:08:03 +00:00
|
|
|
Data = Field("Data")
|
|
|
|
|
|
|
|
Error = Field("Error")
|
2019-07-10 20:30:24 +00:00
|
|
|
|
2019-07-22 20:49:23 +00:00
|
|
|
Progreess = Field("Progress")
|
|
|
|
Status = Field("Status")
|
|
|
|
EventID = Field("EventID")
|
|
|
|
EventContext = Field("EventContext")
|
2019-01-21 18:47:07 +00:00
|
|
|
)
|
2019-06-05 20:40:55 +00:00
|
|
|
|
|
|
|
// Defining Common errors
|
|
|
|
const (
|
|
|
|
AppErrLoaded0 = "Loaded 0 profiles"
|
|
|
|
)
|
2019-07-23 17:57:04 +00:00
|
|
|
|
|
|
|
// Defining Protocol Contexts
|
|
|
|
const (
|
|
|
|
ContextAck = "im.cwtch.acknowledgement"
|
|
|
|
ContextInvite = "im.cwtch.invite"
|
|
|
|
ContextRaw = "im.cwtch.raw"
|
|
|
|
)
|