d2d.proto 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. syntax = "proto3";
  2. package d2d;
  3. option java_package = "ch.threema.protobuf.d2d";
  4. import "common.proto";
  5. import "safe.proto";
  6. // Device to Device Protocol
  7. // =========================
  8. //
  9. // General Information
  10. // -------------------
  11. //
  12. // All messages are symmetrically encrypted with the Mediator Key (MK).
  13. //
  14. // Encryption format: 24 byte nonce prepended, followed by an NaCl box.
  15. //
  16. // All strings are UTF-8 encoded.
  17. // Initial data sent to a device that wants to participate in the device
  18. // group (i.e. a new device to be added by the user).
  19. message InitialData {
  20. // Threema Safe Backup
  21. safe.Backup backup = 1;
  22. }
  23. // Data shared across all devices and transmitted during the handshake.
  24. message SharedDeviceData {
  25. // Random amount of padding, ignored by the receiver
  26. bytes padding = 1;
  27. // MDM parameters to be applied on all devices
  28. MdmParameters mdm_parameters = 2;
  29. }
  30. // Metadata about a device, determined by the device itself.
  31. message DeviceInfo {
  32. // Random amount of padding, ignored by the receiver
  33. bytes padding = 1;
  34. // Platform
  35. enum Platform {
  36. // Unknown platform
  37. UNSPECIFIED = 0;
  38. // Android
  39. ANDROID = 1;
  40. // Apple iOS
  41. IOS = 2;
  42. // Web application
  43. WEB = 3;
  44. }
  45. Platform platform = 2;
  46. // App version
  47. string app_version = 3;
  48. // Device description (smartphone model / browser)
  49. string description = 4;
  50. }
  51. // A transaction scope. Used in the d2m transaction messages.
  52. message TransactionScope {
  53. enum Scope {
  54. USER_PROFILE_SYNC = 0;
  55. CONTACT_SYNC = 1;
  56. GROUP_SYNC = 2;
  57. DISTRIBUTION_LIST_SYNC = 3;
  58. SETTINGS_SYNC = 4;
  59. }
  60. Scope scope = 1;
  61. }
  62. // Root message
  63. message Envelope {
  64. // Random amount of padding, ignored by the receiver
  65. bytes padding = 1;
  66. // The enveloped reflected message
  67. oneof content {
  68. OutgoingMessage outgoing_message = 2;
  69. IncomingMessage incoming_message = 3;
  70. UserProfileSync user_profile_sync = 4;
  71. ContactSync contact_sync = 5;
  72. GroupSync group_sync = 6;
  73. DistributionListSync distribution_list_sync = 7;
  74. SettingsSync settings_sync = 8;
  75. MdmParameters mdm_parameters = 9999;
  76. };
  77. }
  78. // Mobile device management parameters shared across Threema Work devices.
  79. //
  80. // More detailed parameter information is available here:
  81. // https://work.threema.ch/en/docs/mdm_configuration
  82. message MdmParameters {
  83. // Username required for activation of the app
  84. // References: `th_license_username`
  85. oneof license_username { string license_username_value = 1; }
  86. // Password required for activation of the app
  87. // References: `th_license_password`
  88. oneof license_password { string license_password_value = 2; }
  89. // Nickname to be used
  90. // References: `th_nickname`
  91. oneof nickname { string nickname_value = 3; }
  92. // First name of the user
  93. // References: `th_firstname`
  94. oneof first_name { string first_name_value = 4; }
  95. // Last name of the user
  96. // References: `th_lastname`
  97. oneof last_name { string last_name_value = 5; }
  98. // Customer specific identifier
  99. // References: `th_csi`
  100. oneof customer_specific_id { string customer_specific_id_value = 6; }
  101. // User category
  102. // References: `th_category`
  103. oneof category { string category_value = 7; }
  104. // Email address linked to the ID
  105. // References: `th_linked_email`
  106. oneof linked_email { string linked_email_value = 8; }
  107. // Phone number linked to the ID
  108. // References: `th_linked_phone`
  109. oneof linked_phone { string linked_phone_value = 9; }
  110. // Restore a Threema ID
  111. // References: `th_id_backup`
  112. oneof identity_restore { string identity_restore_value = 10; }
  113. // Password for restoring a Threema ID
  114. // References: `th_id_backup_password`
  115. oneof identity_restore_password {
  116. string identity_restore_password_value = 11;
  117. }
  118. // Threema Safe configuration
  119. // References: `th_safe_enable`
  120. enum ThreemaSafePolicy {
  121. // Configurable by the user
  122. SAFE_OPTIONAL = 0;
  123. // Forcibly enabled
  124. SAFE_MANDATORY = 1;
  125. // Forcibly disabled
  126. SAFE_DISABLED = 2;
  127. }
  128. ThreemaSafePolicy threema_safe_policy = 12;
  129. // Threema Safe password (predefined)
  130. // References: `th_safe_password`
  131. oneof threema_safe_password { string threema_safe_password_value = 13; }
  132. // Threema Safe password pattern
  133. // References: `th_safe_password_pattern`
  134. oneof threema_safe_password_pattern {
  135. string threema_safe_password_pattern_value = 14;
  136. }
  137. // Threema Safe password pattern error (mismatch) message
  138. // References: `th_safe_password_message`
  139. oneof threema_safe_password_pattern_error_message {
  140. string threema_safe_password_pattern_error_message_value = 15;
  141. }
  142. // Threema Safe server URL
  143. // References: `th_safe_server_url`
  144. oneof threema_safe_server_url { string threema_safe_server_url_value = 16; }
  145. // Threema Safe server username for authentication
  146. // References: `th_safe_server_username`
  147. oneof threema_safe_server_username {
  148. string threema_safe_server_username_value = 17;
  149. }
  150. // Threema Safe server password for authentication
  151. // References: `th_safe_server_password`
  152. oneof threema_safe_server_password {
  153. string threema_safe_server_password_value = 18;
  154. }
  155. // Restore policy for restoring from a Threema Safe backup
  156. // References: `th_safe_restore_enable`
  157. enum ThreemaSafeRestorePolicy {
  158. // Choosable by the user
  159. SAFE_RESTORE_OPTIONAL = 0;
  160. // Automatic restore
  161. SAFE_RESTORE_MANDATORY = 1;
  162. // Forcibly disabled
  163. SAFE_RESTORE_DISABLED = 2;
  164. }
  165. ThreemaSafeRestorePolicy threema_safe_restore_policy = 19;
  166. // Threema ID to be restored from Threema Safe
  167. // References: `th_safe_restore_id`
  168. oneof threema_safe_restore_identity {
  169. string threema_safe_restore_identity_value = 20;
  170. }
  171. // Override policy in regards to MDM parameters (profile, settings, ...)
  172. // References: `th_readonly_profile`
  173. enum OverridePolicy {
  174. // Allows the user to override some of the MDM parameter presets
  175. LOOSE = 0;
  176. // The user may not override any MDM parameter presets
  177. STRICT = 1;
  178. }
  179. OverridePolicy override_policy = 21;
  180. // Contact synchronisation policy
  181. // References: `th_contact_sync`
  182. enum ContactSyncPolicy {
  183. // Not synced
  184. NOT_SYNCED = 0;
  185. // Synced
  186. SYNC = 1;
  187. }
  188. ContactSyncPolicy contact_sync_policy = 22;
  189. // Inactive Threema ID display policy
  190. // References: `th_hide_inactive_ids`
  191. enum InactiveIdentityDisplayPolicy {
  192. // Show inactive IDs
  193. SHOW_INACTIVE = 0;
  194. // Hide inactive IDs
  195. HIDE_INACTIVE = 1;
  196. }
  197. InactiveIdentityDisplayPolicy inactive_identity_display_policy = 23;
  198. // Unknown contacts policy
  199. // References: `th_block_unknown`
  200. enum UnknownContactPolicy {
  201. // Allowed to contact the user
  202. ALLOW_UNKNOWN = 0;
  203. // Will be blocked by the user
  204. BLOCK_UNKNOWN = 1;
  205. }
  206. UnknownContactPolicy unknown_contact_policy = 24;
  207. // Auto-save media policy
  208. // References: `th_disable_save_to_gallery`
  209. enum AutoSaveMediaPolicy {
  210. // Allow auto-saving, configurable by the user
  211. ALLOW_AUTO_SAVE = 0;
  212. // Deny auto-saving
  213. DENY_AUTO_SAVE = 1;
  214. }
  215. AutoSaveMediaPolicy auto_save_media_policy = 25;
  216. // Screenshot policy
  217. // References: `th_disable_screenshots`
  218. enum ScreenshotPolicy {
  219. // Allow taking screenshots
  220. ALLOW_SCREENSHOT = 0;
  221. // Deny taking screenshots, if possible
  222. DENY_SCREENSHOT = 1;
  223. }
  224. ScreenshotPolicy screenshot_policy = 26;
  225. // Add contact policy
  226. // References: `th_disable_add_contact`
  227. enum AddContactPolicy {
  228. // Allow manually adding contacts
  229. ALLOW_ADD_CONTACT = 0;
  230. // Deny manually adding contacts
  231. DENY_ADD_CONTACT = 1;
  232. }
  233. AddContactPolicy add_contact_policy = 27;
  234. // Chat export policy
  235. // References: `th_disable_export`
  236. enum ChatExportPolicy {
  237. // Allow exporting chats
  238. ALLOW_CHAT_EXPORT = 0;
  239. // Deny exporting of chats
  240. DENY_CHAT_EXPORT = 1;
  241. }
  242. ChatExportPolicy chat_export_policy = 28;
  243. // Backup policy
  244. // References: `th_disable_backups`
  245. enum BackupPolicy {
  246. // Generally allow backups to be made
  247. ALLOW_BACKUP = 0;
  248. // Deny creating backups
  249. DENY_BACKUP = 1;
  250. }
  251. BackupPolicy backup_policy = 29;
  252. // Threema ID export policy
  253. // References: `th_disable_id_export`
  254. enum IdentityExportPolicy {
  255. // Allow exporting of the Threema ID
  256. ALLOW_IDENTITY_EXPORT = 0;
  257. // Deny exporting of the Threema ID
  258. DENY_IDENTITY_EXPORT = 1;
  259. }
  260. IdentityExportPolicy identity_export_policy = 30;
  261. // Data backup policy
  262. // References: `th_disable_data_backups`
  263. enum DataBackupPolicy {
  264. // Allow creating data backups
  265. ALLOW_DATA_BACKUP = 0;
  266. // Deny creating data backups
  267. DENY_DATA_BACKUP = 1;
  268. }
  269. DataBackupPolicy data_backup_policy = 31;
  270. // System backup policy
  271. // References: `th_disable_system_backups`
  272. enum SystemBackupPolicy {
  273. // The system may include app data
  274. ALLOW_SYSTEM_BACKUP = 0;
  275. // The system is denied from including app data
  276. DENY_SYSTEM_BACKUP = 1;
  277. }
  278. SystemBackupPolicy system_backup_policy = 32;
  279. // Message preview (in notifications)
  280. // References: `th_disable_message_preview`
  281. enum MessagePreviewPolicy {
  282. // Allow showing a message preview
  283. ALLOW_PREVIEW = 0;
  284. // Deny showing a message preview
  285. DENY_PREVIEW = 1;
  286. }
  287. MessagePreviewPolicy message_preview_policy = 33;
  288. // Profile picture sharing policy
  289. // References: `th_disable_send_profile_picture`
  290. enum ProfilePictureSharePolicy {
  291. // Allow the profile picture to be shared with contacts
  292. ALLOW_SHARE = 0;
  293. // Denied from sharing the profile picture with contacts
  294. DENY_SHARE = 1;
  295. }
  296. ProfilePictureSharePolicy profile_picture_share_policy = 34;
  297. // Threema Call policy
  298. // References: `th_disable_calls`
  299. enum CallPolicy {
  300. // Allow creating/receiving Threema Calls
  301. ALLOW_CALL = 0;
  302. // Denied from creating/receiving any Threema Calls
  303. DENY_CALL = 1;
  304. }
  305. CallPolicy call_policy = 35;
  306. // Setup wizard policy
  307. // References: `th_skip_wizard`
  308. enum SetupWizardPolicy {
  309. // Show the setup wizard
  310. SHOW_WIZARD = 0;
  311. // Skip the setup wizard (restores an ID or a backup and sets up the
  312. // profile automatically).
  313. SKIP_WIZARD = 1;
  314. }
  315. SetupWizardPolicy setup_wizard_policy = 36;
  316. // Group creation policy
  317. // References: `th_disable_create_group`
  318. enum CreateGroupPolicy {
  319. // Allow manually creating groups
  320. ALLOW_CREATE_GROUP = 0;
  321. // Deny manually creating groups
  322. DENY_CREATE_GROUP = 1;
  323. }
  324. CreateGroupPolicy create_group_policy = 37;
  325. // Share media policy
  326. // References: `th_disable_share_media`
  327. enum ShareMediaPolicy {
  328. // Allow unrestricted sharing of media
  329. ALLOW_SHARE_MEDIA = 0;
  330. // Deny sharing of media outside of Threema, if possible
  331. DENY_OUTSIDE_APP = 1;
  332. }
  333. ShareMediaPolicy share_media_policy = 38;
  334. }
  335. // Message type as defined by the Chat Server Protocol.
  336. enum MessageType {
  337. // Invalid message type
  338. INVALID = 0x00;
  339. // Text message
  340. TEXT = 0x01;
  341. // Image message (deprecated, use `FILE_MESSAGE`)
  342. IMAGE = 0x02;
  343. // Location message
  344. LOCATION = 0x10;
  345. // Audio message (deprecated, use `FILE_MESSAGE`)
  346. AUDIO = 0x14;
  347. // Video message (deprecated, use `FILE_MESSAGE`)
  348. VIDEO = 0x13;
  349. // File message
  350. FILE = 0x17;
  351. // Create a poll
  352. POLL_CREATE = 0x15;
  353. // Cast a vote on a poll
  354. POLL_VOTE = 0x16;
  355. // Call offer
  356. CALL_OFFER = 0x60;
  357. // Call answer
  358. CALL_ANSWER = 0x61;
  359. // Call ICE Candidate
  360. CALL_ICE_CANDIDATE = 0x62;
  361. // Call hangup
  362. CALL_HANGUP = 0x63;
  363. // Call ringing
  364. CALL_RINGING = 0x64;
  365. // Call missed
  366. CALL_MISSED = 0x65;
  367. // Delivery receipt
  368. DELIVERY_RECEIPT = 0x80;
  369. // Typing indicator
  370. TYPING_INDICATOR = 0x90;
  371. // Set profile picture of a contact
  372. CONTACT_SET_PROFILE_PICTURE = 0x18;
  373. // Delete profile picture of a contact
  374. CONTACT_DELETE_PROFILE_PICTURE = 0x19;
  375. // Request profile picture of a contact
  376. CONTACT_REQUEST_PROFILE_PICTURE = 0x1a;
  377. // Create a group
  378. GROUP_CREATE = 0x4a;
  379. // Rename a group
  380. GROUP_RENAME = 0x4b;
  381. // Leave a group
  382. GROUP_LEAVE = 0x4c;
  383. // Set a group's profile picture
  384. GROUP_SET_PROFILE_PICTURE = 0x50;
  385. // Delete a group's profile picture
  386. GROUP_DELETE_PROFILE_PICTURE = 0x54;
  387. // Request group synchronisation
  388. GROUP_REQUEST_SYNC = 0x51;
  389. // Group text message
  390. GROUP_TEXT = 0x41;
  391. // Group location message
  392. GROUP_LOCATION = 0x42;
  393. // Group image message
  394. GROUP_IMAGE = 0x43;
  395. // Group audio message
  396. GROUP_AUDIO = 0x45;
  397. // Group video message
  398. GROUP_VIDEO = 0x44;
  399. // Group file message
  400. GROUP_FILE = 0x46;
  401. // Create a group poll
  402. GROUP_POLL_CREATE = 0x52;
  403. // Cast a vote on a group poll
  404. GROUP_POLL_VOTE = 0x53;
  405. }
  406. // A message receiver can be a single user or a group.
  407. message MessageReceiver {
  408. // The recipient's Threema ID or a group identity.
  409. oneof receiver {
  410. string identity = 1;
  411. common.GroupIdentity group = 2;
  412. }
  413. }
  414. // An outgoing message, reflected to other devices.
  415. message OutgoingMessage {
  416. // Recipient of the enclosed message.
  417. //
  418. // Note: If the receiver is a group identity, group and group creator id of
  419. // the enclosed message must match the values of the supplied group
  420. // identity. Otherwise, the message must be considered invalid.
  421. MessageReceiver receiver = 1;
  422. // Unique ID of the enclosed message
  423. fixed64 message_id = 2;
  424. // Unix-ish timestamp in milliseconds for when the message has been created
  425. uint64 created_at = 3;
  426. // Enclosed message's type
  427. MessageType type = 4;
  428. // The message's body as defined for `Message` (0x01/0x02) of the Chat
  429. // Server Protocol.
  430. bytes body = 5;
  431. }
  432. // An outgoing message has been delivered to the chat server.
  433. //
  434. // Note: This indicates that the message has been successfully stored in the
  435. // message queue of the server. It does NOT indicate that the message has
  436. // been delivered to the intended receiver.
  437. message OutgoingMessageDelivered {
  438. // Recipient of the delivered message.
  439. MessageReceiver receiver = 1;
  440. // Unique ID of the delivered message
  441. fixed64 message_id = 2;
  442. }
  443. // An incoming message, reflected to other devices.
  444. message IncomingMessage {
  445. // Sender's Threema ID
  446. string sender_identity = 1;
  447. // Sender's public nickname
  448. string sender_nickname = 2;
  449. // Unique ID of the enclosed message
  450. fixed64 message_id = 3;
  451. // Unix-ish timestamp in milliseconds for when the message has been created
  452. uint64 created_at = 4;
  453. // Enclosed message's type
  454. MessageType type = 5;
  455. // The message's body as defined for `Message` (0x01/0x02) of the Chat
  456. // Server Protocol.
  457. bytes body = 6;
  458. }
  459. // User profile synchronisation message.
  460. message UserProfileSync {
  461. // Update the user's profile
  462. message Set {
  463. safe.UserProfile user_profile = 1;
  464. }
  465. // Synchronisation type
  466. oneof action {
  467. Set set = 1;
  468. }
  469. }
  470. // Contact synchronisation message.
  471. message ContactSync {
  472. // Set a Threema contact
  473. message Set {
  474. safe.Contact contact = 1;
  475. }
  476. // Delete a Threema contact
  477. message Delete {
  478. string delete_identity = 1;
  479. }
  480. // Synchronisation type
  481. oneof action {
  482. Set set = 1;
  483. Delete delete = 2;
  484. }
  485. }
  486. // Group synchronisation message.
  487. message GroupSync {
  488. // Set a group
  489. message Set {
  490. safe.Group group = 1;
  491. }
  492. // Delete a group
  493. message Delete {
  494. // Unique group identity
  495. common.GroupIdentity group_identity = 1;
  496. }
  497. // Synchronisation type
  498. oneof action {
  499. Set set = 1;
  500. Delete delete = 2;
  501. }
  502. }
  503. // Distribution list synchronisation message.
  504. message DistributionListSync {
  505. // Set a distribution list
  506. message Set {
  507. safe.DistributionList distribution_list = 1;
  508. }
  509. // Delete a group
  510. message Delete {
  511. // Unique ID of the distribution list
  512. fixed64 distribution_list_id = 1;
  513. }
  514. // Synchronisation type
  515. oneof action {
  516. Set set = 1;
  517. Delete delete = 2;
  518. }
  519. }
  520. // Settings synchronisation message.
  521. message SettingsSync {
  522. // Apply settings
  523. message Set {
  524. safe.Settings settings = 1;
  525. }
  526. // Synchronisation type
  527. oneof action {
  528. Set set = 1;
  529. }
  530. }