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.

common.go 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. PeerRequest = Type("PeerRequest")
  9. BlockPeer = Type("BlockPeer")
  10. JoinServer = Type("JoinServer")
  11. // attributes: GroupServer
  12. FinishedFetch = Type("FinishedFetch")
  13. ProtocolEngineStartListen = Type("ProtocolEngineStartListen")
  14. ProtocolEngineStopped = Type("ProtocolEngineStopped")
  15. InvitePeerToGroup = Type("InvitePeerToGroup")
  16. // a group invite has been received from a remote peer
  17. // attributes:
  18. // TimestampReceived [eg time.Now().Format(time.RFC3339Nano)]
  19. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
  20. // GroupInvite: [eg "torv3....."]
  21. NewGroupInvite = Type("NewGroupInvite")
  22. // GroupID
  23. AcceptGroupInvite = Type("AcceptGroupInvite")
  24. SendMessageToGroup = Type("SendMessagetoGroup")
  25. EncryptedGroupMessage = Type("EncryptedGroupMessage")
  26. NewMessageFromGroup = Type("NewMessageFromGroup")
  27. // an error was encountered trying to send a particular Message to a group
  28. // attributes:
  29. // GroupServer: The server the Message was sent to
  30. // Signature: The signature of the Message that failed to send
  31. // Error: string describing the error
  32. SendMessageToGroupError = Type("SendMessageToGroupError")
  33. SendMessageToPeer = Type("SendMessageToPeer")
  34. NewMessageFromPeer = Type("NewMessageFromPeer")
  35. // attributes:
  36. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
  37. // Error: string describing the error
  38. SendMessageToPeerError = Type("SendMessageToPeerError")
  39. // REQUESTS TO STORAGE ENGINE
  40. // a peer contact has been added
  41. // attributes:
  42. // RemotePeer [eg ""]
  43. PeerCreated = Type("PeerCreated")
  44. // a group has been successfully added or newly created
  45. // attributes:
  46. // Data [serialized *model.Group]
  47. GroupCreated = Type("GroupCreated")
  48. // change the .Name attribute of a profile (careful - this is not a custom attribute. it is used in the underlying protocol during handshakes!)
  49. // attributes:
  50. // ProfileName [eg "erinn"]
  51. SetProfileName = Type("SetProfileName")
  52. // request to store a profile-wide attribute (good for e.g. per-profile settings like theme prefs)
  53. // attributes:
  54. // Key [eg "fontcolor"]
  55. // Data [eg "red"]
  56. SetAttribute = Type("SetAttribute")
  57. // request to store a per-contact attribute (e.g. display names for a peer)
  58. // attributes:
  59. // RemotePeer [eg ""]
  60. // Key [eg "nick"]
  61. // Data [eg "erinn"]
  62. SetPeerAttribute = Type("SetPeerAttribute")
  63. // request to store a per-cwtch-group attribute (e.g. display name for a group)
  64. // attributes:
  65. // GroupID [eg ""]
  66. // Key [eg "nick"]
  67. // Data [eg "open privacy board"]
  68. SetGroupAttribute = Type("SetGroupAttribute")
  69. // RemotePeer
  70. // ConnectionState
  71. PeerStateChange = Type("PeerStateChange")
  72. // GroupServer
  73. // ConnectionState
  74. ServerStateChange = Type("GroupStateChange")
  75. /***** Application client / service messages *****/
  76. // ProfileName, Password
  77. CreatePeer = Type("CreatePeer")
  78. // service -> client: Identity(localId), Password
  79. // app -> Identity(onion)
  80. NewPeer = Type("NewPeer")
  81. // Password
  82. LoadProfiles = Type("LoadProfiles")
  83. // Identity(onion)
  84. ShutdownPeer = Type("ShutdownPeer")
  85. Shutdown = Type("Shutdown")
  86. // Error(err)
  87. PeerError = Type("PeerError")
  88. // Error(err)
  89. AppError = Type("AppError")
  90. )
  91. // Field defines common event attributes
  92. type Field string
  93. // Defining Common Field Types
  94. const (
  95. RemotePeer = Field("RemotePeer")
  96. Ciphertext = Field("Ciphertext")
  97. Signature = Field("Signature")
  98. PreviousSignature = Field("PreviousSignature")
  99. TimestampSent = Field("TimestampSent")
  100. TimestampReceived = Field("TimestampReceived")
  101. Identity = Field("Identity")
  102. GroupID = Field("GroupID")
  103. GroupServer = Field("GroupServer")
  104. GroupInvite = Field("GroupInvite")
  105. ProfileName = Field("ProfileName")
  106. Password = Field("Password")
  107. ConnectionState = Field("ConnectionState")
  108. Key = Field("Key")
  109. Data = Field("Data")
  110. Error = Field("Error")
  111. )
  112. // Defining Common errors
  113. const (
  114. AppErrLoaded0 = "Loaded 0 profiles"
  115. )