Official cwtch.im peer and server implementations. https://cwtch.im
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

239 lines
6.7KB

  1. package event
  2. // Type captures the definition of many common Cwtch application events
  3. type Type string
  4. // Defining Common Event Types
  5. const (
  6. StatusRequest = Type("StatusRequest")
  7. ProtocolEngineStatus = Type("ProtocolEngineStatus")
  8. // Attempt to outbound peer with a given remote peer
  9. // attributes:
  10. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
  11. PeerRequest = Type("PeerRequest")
  12. // RetryPeerRequest
  13. // Identical to PeerRequest, but allows Engine to make decisions regarding blocked peers
  14. // attributes:
  15. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
  16. RetryPeerRequest = Type("RetryPeerRequest")
  17. // Blocking Events both Block and Unblock have the same structure
  18. // attributes:
  19. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
  20. BlockPeer = Type("BlockPeer")
  21. UnblockPeer = Type("UnblockPeer")
  22. // Turn on/off blocking of unknown peers (if peers aren't in the contact list then they will be autoblocked
  23. BlockUnknownPeers = Type("BlockUnknownPeers")
  24. AllowUnknownPeers = Type("AllowUnknownPeers")
  25. // GroupServer
  26. JoinServer = Type("JoinServer")
  27. ProtocolEngineStartListen = Type("ProtocolEngineStartListen")
  28. ProtocolEngineStopped = Type("ProtocolEngineStopped")
  29. InvitePeerToGroup = Type("InvitePeerToGroup")
  30. // a group invite has been received from a remote peer
  31. // attributes:
  32. // TimestampReceived [eg time.Now().Format(time.RFC3339Nano)]
  33. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
  34. // GroupInvite: [eg "torv3....."]
  35. NewGroupInvite = Type("NewGroupInvite")
  36. // GroupID
  37. AcceptGroupInvite = Type("AcceptGroupInvite")
  38. SendMessageToGroup = Type("SendMessagetoGroup")
  39. //Ciphertext, Signature:
  40. EncryptedGroupMessage = Type("EncryptedGroupMessage")
  41. //TimestampReceived, TimestampSent, Data(Message), GroupID, Signature, PreviousSignature, RemotePeer
  42. NewMessageFromGroup = Type("NewMessageFromGroup")
  43. // an error was encountered trying to send a particular Message to a group
  44. // attributes:
  45. // GroupServer: The server the Message was sent to
  46. // Signature: The signature of the Message that failed to send
  47. // Error: string describing the error
  48. SendMessageToGroupError = Type("SendMessageToGroupError")
  49. SendMessageToPeer = Type("SendMessageToPeer")
  50. NewMessageFromPeer = Type("NewMessageFromPeer")
  51. // Peer acknowledges a previously sent message
  52. // attributes
  53. // EventID: The original event id that the peer is responding too.
  54. // RemotePeer: The peer associated with the acknowledgement
  55. PeerAcknowledgement = Type("PeerAcknowledgement")
  56. // attributes:
  57. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
  58. // Error: string describing the error
  59. SendMessageToPeerError = Type("SendMessageToPeerError")
  60. // REQUESTS TO STORAGE ENGINE
  61. // a peer contact has been added
  62. // attributes:
  63. // RemotePeer [eg ""]
  64. PeerCreated = Type("PeerCreated")
  65. // Password, NewPassword
  66. ChangePassword = Type("ChangePassword")
  67. // Error(err), EventID
  68. ChangePasswordError = Type("ChangePasswordError")
  69. // EventID
  70. ChangePasswordSuccess = Type("ChangePasswordSuccess")
  71. // a group has been successfully added or newly created
  72. // attributes:
  73. // Data [serialized *model.Group]
  74. GroupCreated = Type("GroupCreated")
  75. // RemotePeer
  76. DeleteContact = Type("DeleteContact")
  77. // GroupID
  78. DeleteGroup = Type("DeleteGroup")
  79. // change the .Name attribute of a profile (careful - this is not a custom attribute. it is used in the underlying protocol during handshakes!)
  80. // attributes:
  81. // ProfileName [eg "erinn"]
  82. SetProfileName = Type("SetProfileName")
  83. // request to store a profile-wide attribute (good for e.g. per-profile settings like theme prefs)
  84. // attributes:
  85. // Key [eg "fontcolor"]
  86. // Data [eg "red"]
  87. SetAttribute = Type("SetAttribute")
  88. // request to store a per-contact attribute (e.g. display names for a peer)
  89. // attributes:
  90. // RemotePeer [eg ""]
  91. // Key [eg "nick"]
  92. // Data [eg "erinn"]
  93. SetPeerAttribute = Type("SetPeerAttribute")
  94. // request to store a per-cwtch-group attribute (e.g. display name for a group)
  95. // attributes:
  96. // GroupID [eg ""]
  97. // Key [eg "nick"]
  98. // Data [eg "open privacy board"]
  99. SetGroupAttribute = Type("SetGroupAttribute")
  100. // PeerStateChange servers as a new incoming connection message as well, and can/is consumed by frontends to alert of new p2p connections
  101. // RemotePeer
  102. // ConnectionState
  103. PeerStateChange = Type("PeerStateChange")
  104. // GroupServer
  105. // ConnectionState
  106. ServerStateChange = Type("ServerStateChange")
  107. /***** Application client / service messages *****/
  108. // ProfileName, Password, Data(tag)
  109. CreatePeer = Type("CreatePeer")
  110. // service -> client: Identity(localId), Password, [Status(new/default=blank || from reload='running')]
  111. // app -> Identity(onion)
  112. NewPeer = Type("NewPeer")
  113. // Identity(onion)
  114. DeletePeer = Type("DeletePeer")
  115. // Identity(onion), Data(pluginID)
  116. AddPeerPlugin = Type("AddPeerPlugin")
  117. // Password
  118. LoadProfiles = Type("LoadProfiles")
  119. // Client has reloaded, triggers NewPeer s then ReloadDone
  120. ReloadClient = Type("ReloadClient")
  121. ReloadDone = Type("ReloadDone")
  122. // Identity - Ask service to resend all connection states
  123. ReloadPeer = Type("ReloadPeer")
  124. // Identity(onion)
  125. ShutdownPeer = Type("ShutdownPeer")
  126. Shutdown = Type("Shutdown")
  127. // Error(err)
  128. // Error creating peer
  129. PeerError = Type("PeerError")
  130. // Error(err)
  131. AppError = Type("AppError")
  132. GetACNStatus = Type("GetACNStatus")
  133. // Progress, Status
  134. ACNStatus = Type("ACNStatus")
  135. // Network Status
  136. // Status: Success || Error
  137. // Error: Description of the Error
  138. // Onion: the local onion we attempt to check
  139. NetworkStatus = Type("NetworkError")
  140. )
  141. // Field defines common event attributes
  142. type Field string
  143. // Defining Common Field Types
  144. const (
  145. // A peers local onion address
  146. Onion = Field("Onion")
  147. RemotePeer = Field("RemotePeer")
  148. Ciphertext = Field("Ciphertext")
  149. Signature = Field("Signature")
  150. PreviousSignature = Field("PreviousSignature")
  151. TimestampSent = Field("TimestampSent")
  152. TimestampReceived = Field("TimestampReceived")
  153. Identity = Field("Identity")
  154. GroupID = Field("GroupID")
  155. GroupServer = Field("GroupServer")
  156. GroupInvite = Field("GroupInvite")
  157. ProfileName = Field("ProfileName")
  158. Password = Field("Password")
  159. NewPassword = Field("NewPassword")
  160. ConnectionState = Field("ConnectionState")
  161. Key = Field("Key")
  162. Data = Field("Data")
  163. Error = Field("Error")
  164. Progreess = Field("Progress")
  165. Status = Field("Status")
  166. EventID = Field("EventID")
  167. EventContext = Field("EventContext")
  168. )
  169. // Defining Common errors
  170. const (
  171. AppErrLoaded0 = "Loaded 0 profiles"
  172. )
  173. // Defining Protocol Contexts
  174. const (
  175. ContextAck = "im.cwtch.acknowledgement"
  176. ContextInvite = "im.cwtch.invite"
  177. ContextRaw = "im.cwtch.raw"
  178. )