No Description
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.

xep-0385.xml 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <!--
  9. TODO:
  10. - Example showing component cache usage
  11. - encrypted files
  12. - 3rdParty hosted reference (GDrive, Dropbox, etc.)
  13. -->
  14. <header>
  15. <title>Stateless Inline Media Sharing (SIMS)</title>
  16. <abstract>This specification describes a protocol for stateless asynchronous media sharing with integrity and transport flexibility. It allows clients to provide a good interoperable user experience in combination with Carbons and MAM.</abstract>
  17. &LEGALNOTICE;
  18. <number>0385</number>
  19. <status>Experimental</status>
  20. <type>Standards Track</type>
  21. <sig>Standards</sig>
  22. <approver>Council</approver>
  23. <dependencies>
  24. <spec>XMPP Core</spec>
  25. <spec>XEP-0001</spec>
  26. <spec>XEP-0234</spec>
  27. <spec>XEP-0300</spec>
  28. <spec>XEP-0363</spec>
  29. </dependencies>
  30. <supersedes/>
  31. <supersededby/>
  32. <shortname>sims</shortname>
  33. &tobias;
  34. <revision>
  35. <version>0.2.1</version>
  36. <date>2018-01-25</date>
  37. <initials>vv</initials>
  38. <remark><p>Fix reference to XEP-0234.</p></remark>
  39. </revision>
  40. <revision>
  41. <version>0.2.0</version>
  42. <date>2017-09-21</date>
  43. <initials>fs</initials>
  44. <remark><p>Use 'urn:xmpp:hashes:2' and 'urn:xmpp:jingle:apps:file-transfer:5'.</p></remark>
  45. </revision>
  46. <revision>
  47. <version>0.1.0</version>
  48. <date>2017-01-04</date>
  49. <initials>XEP Editor: ssw</initials>
  50. <remark><p>Initial version approved by the council.</p></remark>
  51. </revision>
  52. <revision>
  53. <version>0.0.1</version>
  54. <date>2016-12-21</date>
  55. <initials>tm (XEP Editor: ssw)</initials>
  56. <remark><p>First draft processed by editor.</p></remark>
  57. </revision>
  58. </header>
  59. <section1 topic='Introduction' anchor='intro'>
  60. <p>File sharing in XMPP has mainly been addressed by synchronous solutions like &xep0096; and &xep0234;.
  61. However, these extensions only address the transfer of files and there is more to file sharing than the simple transfer of the data.</p>
  62. <p>Extentions that go beyond the simple transfer of data are &xep0329; and &xep0363;. XEP-0329 allows sharing folder structures to other users, allowing them to browse the remote folder and fetch interesting files using existing file-transfer protocols. XEP-0363 describes a protocol to ask a server component for a HTTP storage URL where a client can use HTTP PUT to save a file to and afterwards share the public URL with other users to share the file. While this provides some form of asynchronus file sharing it does not provide integrity protection and requires a server component.</p>
  63. <p>This proposal aims to provide a protocol that will enable XMPP clients to implement a great user experience (UX) around the process of sharing media in conversations. Shared media can take any form of static media like photos, videos, documents, compresses archives, etc.
  64. This is directly refelected in the requirents of this extension lined out in the following sections.</p>
  65. </section1>
  66. <section1 topic='Related XEPs' anchor='related'>
  67. <p>The state of sharing media with chat partners in the XMPP community is a protocol zoo in 2016. There are three major protocols for sharing media in XMPP.</p>
  68. <section2 topic='Bits of Binary'>
  69. <p>&xep0231; is designed for small media, i.e. less than 8 KB in size, that is hosted server-side and transferred Base64 encoded in-band of an existing XMPP stream. Example use-cases are custom emoticons that are referenced in &xep0071; img-tags, or thumbnails for &xep0234;.</p>
  70. </section2>
  71. <section2 topic='Jingle File Transfer'>
  72. <p>&xep0234; describes a peer-to-peer protocol for synchronous file-transfer between two XMPP entities. It attempts a direct transmission, followed by a proxied transmission, via &xep0260;. If neither works it will fallback to &xep0261; which will transfer the data inband of the exsiting XMPP stream.</p>
  73. </section2>
  74. <section2 topic='HTTP File Upload'>
  75. <p>&xep0363; was designed as a simpler to implement alternative to &xep0231;. This is achieved by reusing the HTTP APIs in todays mobile and language SDKs. It requires a server component where clients can request HTTP URLs to upload data to and share the corresponding download URL as part of plain text in a conversation.</p>
  76. </section2>
  77. <section2 topic='Comparison of File Transfer Protocols'>
  78. <table caption='Comparison of File Transfer Protocols in 2016'>
  79. <tr>
  80. <th>Protocol</th>
  81. <th>File Size Limit</th>
  82. <th>Integrity Verification</th>
  83. <th>Transport</th>
  84. <th>Multi Receiver Support</th>
  85. <th>Server Support</th>
  86. <th>Resumption</th>
  87. </tr>
  88. <tr>
  89. <td>&xep0231;</td>
  90. <td>8 KB</td>
  91. <td>Yes</td>
  92. <td>Inband</td>
  93. <td>Yes</td>
  94. <td>Required</td>
  95. <td>No</td>
  96. </tr>
  97. <tr>
  98. <td>&xep0234;</td>
  99. <td>No</td>
  100. <td>Yes</td>
  101. <td>Inband/Direct/Proxy</td>
  102. <td>No</td>
  103. <td>Optional</td>
  104. <td>Yes</td>
  105. </tr>
  106. <tr>
  107. <td>&xep0363;</td>
  108. <td>Service Dependent</td>
  109. <td>No</td>
  110. <td>Outband (HTTP)</td>
  111. <td>Yes</td>
  112. <td>Required</td>
  113. <td>Download only</td>
  114. </tr>
  115. </table>
  116. </section2>
  117. </section1>
  118. <section1 topic='Requirements' anchor='reqs'>
  119. <ul>
  120. <li>Not require server components to work to ease deployment</li>
  121. <li>Can be improved by server components for taking load of clients</li>
  122. <li>Media sharing should work and enable a good UX in multi-user chats like &xep0045; and &xep0369;</li>
  123. <li>Media sharing should work great together with conversation synchronization protocols like &xep0280; and &xep0313;</li>
  124. <li>Reuse existing protocols for the actual transport of the data, i.e. &xep0096;, &xep0234; or &xep0363;</li>
  125. <li>Guarantee file integrity</li>
  126. <li>Enable aggresive caching</li>
  127. <li>Provide users with metadata, e.g. file size, file type or thumbnail, to help them decide whether or not they want to load the media file</li>
  128. <li>Support referring to third party hosting services</li>
  129. </ul>
  130. </section1>
  131. <section1 topic='Use Cases' anchor='usecases'>
  132. <section2 topic='Sharing a photo' anchor='usecases-sending-photo'>
  133. <p>To share a photo, or any kind of media, a user sends a message stanza to the contact. If the message has an empty body, it is recommended
  134. to add a message processing hint, see &xep0334;, to indicate the message to be stored in message stores like &xep0313;.</p>
  135. <p>Clients supporting &xep0363; can upload the media file to a HTTP service and add the corresponding HTTP URL to the sources.</p>
  136. <example caption='Sharing an image with a contact'><![CDATA[<message to='julient@shakespeare.lit' from='romeo@montague.lit'>
  137. <body>Look at the nice view from the summit.</body>
  138. <reference xmlns='urn:xmpp:reference:0' begin='17' end='20' type='data'>
  139. <media-sharing xmlns='urn:xmpp:sims:1'>
  140. <file xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  141. <media-type>image/jpeg</media-type>
  142. <name>summit.jpg</name>
  143. <size>3032449</size>
  144. <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=</hash>
  145. <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>2AfMGH8O7UNPTvUVAM9aK13mpCY=</hash>
  146. <desc>Photo from the summit.</desc>
  147. <thumbnail xmlns='urn:xmpp:thumbs:1'uri='cid:sha1+ffd7c8d28e9c5e82afea41f97108c6b4@bob.xmpp.org' media-type='image/png' width='128' height='96'/>
  148. </file>
  149. <sources>
  150. <reference xmlns='urn:xmpp:reference:0' type='data' uri='https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/summit.jpg' />
  151. <reference xmlns='urn:xmpp:reference:0' type='data' uri='xmpp:romeo@montague.lit/resource?jingle;id=9559976B-3FBF-4E7E-B457-2DAA225972BB' />
  152. </sources>
  153. </media-sharing>
  154. </reference>
  155. </message>]]></example>
  156. <p>The file element is the same as from &xep0234;. It MUST specify media-type, size, description, and one or multiple hash elements as described in &xep0300;.
  157. The hash elements are essential as they provide end-to-end file integrity and allow efficient caching and flexible retrieval methods.</p>
  158. </section2>
  159. <section2 topic='Receiving a shared photo'>
  160. <p>On receive of a reference to a &lt;media-sharing&gt; element inside a message, a client SHOULD lookup in a local storage, whether the media with any of the proivded hashes has already
  161. been retrieved and is available. In that case no transfer needs to be initated and the image can be displayed in-line of the chat.</p>
  162. <p>If the media file is not available locally, the media file can be obtained by one of the references in the &lt;sources&gt; element. If a client support HTTP downloads, it can simply download HTTP references.</p>
  163. <p>If not, it can fetch the media file via a &xep0358; URI reference in the sources and initiate a Jingle File-Transfer. If the client does not support &xep0358;, it can attempt fetching the media file via &xep0234; by using the hash elements in the file element as described in <link url='http://xmpp.org/extensions/xep-0234.html#requesting'>Jingle File-Transfer</link>.</p>
  164. <p>A client MAY retrieve the file from other sources than these mentioned in the sources element. This may be via &xep0234; from the senders' other resources or from a
  165. media caching service located at the local service. The standardization of such cache is out of scope for this document.</p>
  166. <p>Regardless of the transport method used to obtain the file, the received content MUST be verified against one of the hashes.
  167. If the verification fails, the retrieved content MUST be discarded and retrieval using a different source can be attempted.</p>
  168. </section2>
  169. </section1>
  170. <section1 topic='Business Rules' anchor='rules'>
  171. <section2 topic='Transport Method Preference'>
  172. <p>This XEP delegates actual transport of the media data to one of the existing file-transfer XEPs. Thus a client supporting this XEP MUST implement &xep0234; and &xep0363;.</p>
  173. <p>If a users server supports &xep0363;, it SHOULD upload the file to the service and add the retrieval URL to the &lt;sources&gt; tag, unless the user specifically asked to not store media in the cloud.</p>
  174. <p>Using &xep0363; for media file transfer highly increases the UX, since the HTTP server has a higher availability than XMPP end-user clients and can easily handle the load of lots of requests that result from sharing media in &xep0045; and &xep0369; rooms.</p>
  175. </section2>
  176. <section2 topic='Media Support'>
  177. <p>Sharing the raw data of media does not provide a complete user experience. Clients ideally need to be able to display the media inline of the chat. For this we set baseline requirements for audio, video and picture formats, that a client supports to display. These requrirements are shown in the following table.</p>
  178. <p>A client usually will always send in one format per media type, if it creates that media itself.</p>
  179. <table caption='Mandated encoding and in-line display support.'>
  180. <tr>
  181. <th>Media Type</th>
  182. <th>Mime Type</th>
  183. <th>Format/Container</th>
  184. <th>Codec</th>
  185. <th>Requirement</th>
  186. <th>Comment</th>
  187. </tr>
  188. <tr>
  189. <td>Audio</td>
  190. <td>audio/m4a</td>
  191. <td>MPEG4</td>
  192. <td>AAC</td>
  193. <td>SHOULD</td>
  194. <td>Can be encoded/decoded by stock <link url='https://developer.android.com/guide/appendix/media-formats.html'>Android</link> and <link url='https://developer.apple.com/library/content/documentation/Miscellaneous/Conceptual/iPhoneOSTechOverview/MediaLayer/MediaLayer.html'>iOS</link> systems.</td>
  195. </tr>
  196. <tr>
  197. <td>Image</td>
  198. <td>image/jpeg</td>
  199. <td>-</td>
  200. <td>JPEG</td>
  201. <td>SHOULD</td>
  202. <td>Supported on common desktop and mobile systems. Use for photos.</td>
  203. </tr>
  204. <tr>
  205. <td>Image</td>
  206. <td>image/png</td>
  207. <td>-</td>
  208. <td>PNG</td>
  209. <td>SHOULD</td>
  210. <td>Supported on common desktop and mobile systems. Use for non-photos.</td>
  211. </tr>
  212. <tr>
  213. <td>Video</td>
  214. <td>image/gif</td>
  215. <td>-</td>
  216. <td>GIF</td>
  217. <td>SHOULD</td>
  218. <td>Widespread history animation format supported everywhere.</td>
  219. </tr>
  220. <tr>
  221. <td>Video</td>
  222. <td>video/mp4</td>
  223. <td>MPEG4</td>
  224. <td>H.264 AVC</td>
  225. <td>SHOULD</td>
  226. <td>Can be encoded/decoded by stock <link url='https://developer.android.com/guide/appendix/media-formats.html'>Android</link> and <link url='https://developer.apple.com/library/content/documentation/Miscellaneous/Conceptual/iPhoneOSTechOverview/MediaLayer/MediaLayer.html'>iOS</link> systems.</td>
  227. </tr>
  228. </table>
  229. </section2>
  230. <section2 topic='Atomatic retrieval of shared media'>
  231. <p>Depending on the size of the shared media, a client MAY want to automatically download and display the media instead of fetching and displaying the thumbnail. The size threshold depends on the network environment the client currently runs in.</p>
  232. <p>If a client supports automatic retrieval it MUST disclose this feature to the end user and provide a way to disable it, as it may result in high network traffic.</p>
  233. </section2>
  234. <section2 topic='MUC and MIX related rules'>
  235. <p>In cases where media is shared in a &xep0045; or &xep0369; room the sender has to expect that a large number of clients may retrieve the shared media automatically. Ideally multiple sources, including HTTP or other high availability sources, are provided in the &lt;sources&gt; tag of the &lt;media-sharing&gt; tag in case the media is shared in a MUC/MIX room.</p>
  236. <p class='box'>TODO: Describe protocol for MIX members to advertise media availabililty to peers in a dedicated MIX channel PubSub node. Maybe as a dedicated XEP.</p>
  237. </section2>
  238. <section2 topic='MAM and Carbons related rules'>
  239. <p>For the media sharing described in this XEP to work, it is REQUIRED for MAM to store the whole stanza instead of only the body content. If the MAM component of the user's server strips away the &lt;media-sharing&gt; tag, any shared media will be missing in archived messages.</p>
  240. <p>If sensitve media is shared a client MAY add relevant hints for the server via &xep0334;.</p>
  241. </section2>
  242. <section2 topic='XHTML-IM related rules'>
  243. <p>To refer to shared media in a XHTML-IM message, this XEP takes advantage of the requirement for hash elements in the file metadata and &rfc6920; and its ni URI format. Using the URI format, XHTML-IM can easily refer to media that is attached to a message via a &lt;media-sharing&gt; element, as shown in the following example.</p>
  244. <example caption='Sharing an image with a contact'><![CDATA[<message to='julient@shakespeare.lit' from='romeo@montague.lit'>
  245. <body>Look at the nice view from the summit.</body>
  246. <html xmlns='http://jabber.org/protocol/xhtml-im'>
  247. <body xmlns='http://www.w3.org/1999/xhtml'>
  248. <p>Look at the nice <p style='font-weight:bold; display:inline">view</p> from the summit.</p>
  249. <img src="ni:///sha3-256;wqfDv8OGw7jCvx7Dl2ZRw4FHVsKgYcOWYsO14oKsw79Nw6Q7ScO64oCaw5gKS-KCrMO4Q0o" />
  250. </body>
  251. </html>
  252. <reference xmlns='urn:xmpp:reference:0' begin='17' end='20' type='data'>
  253. <media-sharing xmlns='urn:xmpp:sims:1'>
  254. <file xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  255. <media-type>image/jpeg</media-type>
  256. <name>summit.jpg</name>
  257. <size>3032449</size>
  258. <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=</hash>
  259. <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>2AfMGH8O7UNPTvUVAM9aK13mpCY=</hash>
  260. <desc>Photo from the summit.</desc>
  261. <thumbnail xmlns='urn:xmpp:thumbs:1'uri='cid:sha1+ffd7c8d28e9c5e82afea41f97108c6b4@bob.xmpp.org' media-type='image/png' width='128' height='96'/>
  262. </file>
  263. <sources>
  264. <reference xmlns='urn:xmpp:reference:0' type='data' uri='https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/summit.jpg' />
  265. <reference xmlns='urn:xmpp:reference:0' type='data' uri='xmpp:romeo@montague.lit/resource?jingle-ft' />
  266. </sources>
  267. </media-sharing>
  268. </reference>
  269. </message>]]></example>
  270. <p>This way the client can aquire the content addressable resource mentioned in the img-tag in the XHTML-IM message, and when finished show in in the rendered XHTML-IM message.</p>
  271. </section2>
  272. </section1>
  273. <section1 topic='Implementation Notes' anchor='impl'>
  274. <p></p>
  275. </section1>
  276. <section1 topic='Accessibility Considerations' anchor='access'>
  277. <p>The size element in the file element provides clients to automatically load small files and if not provide the users with a hint on how long a transfer might take.</p>
  278. <p>The OPTIONAL thumbnail element in the file element improves the user experience as it provides further hints for users on whether the file could be of interest to them.</p>
  279. <p>The desc element in the file element is criticial for clients to enable them to provide accessibility to users who use screen readers.</p>
  280. </section1>
  281. <section1 topic='Internationalization Considerations' anchor='i18n'>
  282. <p>OPTIONAL.</p>
  283. </section1>
  284. <section1 topic='Security Considerations' anchor='security'>
  285. <section2 topic='Clearing of privacy sensitive metadata'>
  286. <p>Mobile devices are able to attach the geographic location of where a photo was taken to the photo. It is RECOMMENDED that a client implementing this XEP attempts to detect privacy exposing metadata in media shared and if found provides the user with an option to clear the media of such metadata.</p>
  287. </section2>
  288. <section2 topic='The value and cost of end-to-end media integrity'>
  289. <p>Requiring end-to-end media integrity prevents trival server side optimizations or other processing on shared media as it will change the cryptographic hash of the media file. On the other hand, requring a matching cryptographic hash guarantees that everybody sees the exact same media a user has shared in a group conversation.</p>
  290. </section2>
  291. </section1>
  292. <section1 topic='Acknowledgements' anchor='ack'>
  293. <p>Thanks to Kim Alvefur, Emmanuel Gil Peyrot, Kevin Smith, Nicolas Vérité, and Florian Schmaus for their helpful comments.</p>
  294. </section1>
  295. <section1 topic='IANA Considerations' anchor='iana'>
  296. <p>REQUIRED.</p>
  297. </section1>
  298. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  299. <p>The &REGISTRAR; includes the following information in its registries.</p>
  300. <section2 topic='Protocol Namespaces' anchor='registrar-protocol'>
  301. <p>The XMPP Registrar will include the following namespace in its registry of protocol namespaces at &NAMESPACES;:</p>
  302. <ul>
  303. <li>urn:xmpp:sims:1</li>
  304. </ul>
  305. </section2>
  306. </section1>
  307. <section1 topic='XML Schema' anchor='schema'>
  308. <p>REQUIRED for protocol specifications.</p>
  309. </section1>
  310. </xep>