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-0153.xml 16KB

  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. <header>
  9. <title>vCard-Based Avatars</title>
  10. <abstract>This document provides historical documentation of a vCard-based protocol for exchanging user avatars.</abstract>
  12. <number>0153</number>
  13. <status>Active</status>
  14. <type>Historical</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XMPP IM</spec>
  20. <spec>XEP-0054</spec>
  21. </dependencies>
  22. <supersedes/>
  23. <supersededby/>
  24. <shortname>vcard-avatar</shortname>
  25. <schemaloc>
  26. <url></url>
  27. </schemaloc>
  28. &stpeter;
  29. <revision>
  30. <version>1.1</version>
  31. <date>2018-02-26</date>
  32. <initials>jwi</initials>
  33. <remark>Clarify encoding of the photo hash in the presence update.</remark>
  34. </revision>
  35. <revision>
  36. <version>1.0</version>
  37. <date>2006-08-16</date>
  38. <initials>psa</initials>
  39. <remark>Per a vote of the Jabber Council, advanced status to Active.</remark>
  40. </revision>
  41. <revision>
  42. <version>0.3</version>
  43. <date>2006-01-12</date>
  44. <initials>psa</initials>
  45. <remark>Collected all syntax rules into dedicated section; incorporated feedback from implementation experience; adjusted text regarding base64 encoding.</remark>
  46. </revision>
  47. <revision>
  48. <version>0.2</version>
  49. <date>2005-10-18</date>
  50. <initials>psa</initials>
  51. <remark>Changed 8k limit from MUST NOT to SHOULD NOT; specified that client should publish new presence stanza if it obtains an avatar image after sending an empty photo element; specified that the update child should be included in directed presence stanzas; more clearly specified Base64 rules.</remark>
  52. </revision>
  53. <revision>
  54. <version>0.1</version>
  55. <date>2005-06-16</date>
  56. <initials>psa</initials>
  57. <remark>Initial version.</remark>
  58. </revision>
  59. <revision>
  60. <version>0.0.3</version>
  61. <date>2005-06-14</date>
  62. <initials>psa</initials>
  63. <remark>Changed type from Informational to Historical, adjusted text accordingly.</remark>
  64. </revision>
  65. <revision>
  66. <version>0.0.2</version>
  67. <date>2005-06-13</date>
  68. <initials>psa</initials>
  69. <remark>Specified that the image data is actually Base64 encoded.</remark>
  70. </revision>
  71. <revision>
  72. <version>0.0.1</version>
  73. <date>2005-06-09</date>
  74. <initials>psa</initials>
  75. <remark>First draft.</remark>
  76. </revision>
  77. </header>
  78. <section1 topic='Introduction' anchor='intro'>
  79. <p>There exist several proposed protocols for communicating user avatar information over Jabber/XMPP (see &xep0008; and &xep0084;). This document describes another such protocol that is in use today on the Jabber/XMPP network. This document is historical and does not purport to propose a standards-track protocol. However, a future protocol may improve on the approach documented herein.</p>
  80. </section1>
  81. <section1 topic='Requirements' anchor='reqs'>
  82. <p>The protocol described herein seems to have been designed with the following requirements in mind:</p>
  83. <ul>
  84. <li>Enable a user to store an avatar image in his or her vCard.</li>
  85. <li>Provide notice of avatar changes via the &PRESENCE; stanza.</li>
  86. <li>Enable a contact to retrieve a user's avatar image if the user is offline.</li>
  87. <li>Enable a contact to retrieve a user's avatar image without requesting it of the user's particular client, thus preserving bandwidth.</li>
  88. </ul>
  89. </section1>
  90. <section1 topic='Use Cases' anchor='usecases'>
  91. <section2 topic='User Publishes Avatar' anchor='publish'>
  92. <p>Before informing contacts of the user's avatar, the user's client first publishes the avatar data to the user's public vCard using the protocol defined in &xep0054;.</p>
  93. <example caption="User&apos;s Client Publishes Avatar Data to vCard"><![CDATA[
  94. <iq from=''
  95. type='set'
  96. id='vc1'>
  97. <vCard xmlns='vcard-temp'>
  98. <BDAY>1476-06-09</BDAY>
  99. <ADR>
  100. <CTRY>Italy</CTRY>
  101. <LOCALITY>Verona</LOCALITY>
  102. <HOME/>
  103. </ADR>
  104. <NICKNAME/>
  105. <N><GIVEN>Juliet</GIVEN><FAMILY>Capulet</FAMILY></N>
  106. <EMAIL>jcapulet@shakespeare.lit</EMAIL>
  107. <PHOTO>
  108. <TYPE>image/jpeg</TYPE>
  109. <BINVAL>
  110. Base64-encoded-avatar-file-here!
  111. </BINVAL>
  112. </PHOTO>
  113. </vCard>
  114. </iq>
  115. ]]></example>
  116. <example caption="User&apos;s Server Acknowledges Publish"><![CDATA[
  117. <iq to='' type='result' id='vc1'/>
  118. ]]></example>
  119. <p>Next, the user's client computes the SHA1 hash of the avatar image data itself (not the base64-encoded version) in accordance with &rfc3174;. This hash is then included in the user's presence information. This is done by putting the hash encoded as hexadecimal digits as the XML character data of the &lt;photo/&gt; child of an &X; element qualified by the 'vcard-temp:x:update' namespace, as shown in the following example:</p>
  120. <example caption="User&apos;s Client Includes Avatar Hash in Presence Broadcast"><![CDATA[
  121. <presence from=''>
  122. <x xmlns='vcard-temp:x:update'>
  123. <photo>01b87fcd030b72895ff8e88db57ec525450f000d</photo>
  124. </x>
  125. </presence>
  126. ]]></example>
  127. <p>Note that while XML Schema defines the canonical representation of hexadecimal values to be upper-case, the historical use throughout the XMPP ecosystem has established lower-case use. Entities need to be able to process both and may prefer to emit lower-case for compatibility.</p>
  128. <p>The user's server then broadcasts that presence information to all contacts who are subscribed to the user's presence information.</p>
  129. </section2>
  130. <section2 topic='Contact Retrieves Avatar' anchor='retrieve'>
  131. <p>When the recipient's client receives the hash of the avatar image, it SHOULD check the hash to determine if it already has a cached copy of that avatar image. If not, it retrieves the sender's full vCard in accordance with the protocol flow described in <cite>XEP-0054</cite> (note that this request is sent to the user's bare JID, not full JID):</p>
  132. <example caption="Contact&apos;s Client Requests User&apos;s vCard"><![CDATA[
  133. <iq from=''
  134. to=''
  135. type='get'
  136. id='vc2'>
  137. <vCard xmlns='vcard-temp'/>
  138. </iq>
  139. ]]></example>
  140. <example caption="Server Returns vCard on Behalf of User"><![CDATA[
  141. <iq from=''
  142. to=''
  143. type='result'
  144. id='vc2'>
  145. <vCard xmlns='vcard-temp'>
  146. <BDAY>1476-06-09</BDAY>
  147. <ADR>
  148. <CTRY>Italy</CTRY>
  149. <LOCALITY>Verona</LOCALITY>
  150. <HOME/>
  151. </ADR>
  152. <NICKNAME/>
  153. <N><GIVEN>Juliet</GIVEN><FAMILY>Capulet</FAMILY></N>
  154. <EMAIL>jcapulet@shakespeare.lit</EMAIL>
  155. <PHOTO>
  156. <TYPE>image/jpeg</TYPE>
  157. <BINVAL>
  158. Base64-encoded-avatar-file-here!
  159. </BINVAL>
  160. </PHOTO>
  161. </vCard>
  162. </iq>
  163. ]]></example>
  164. </section2>
  165. </section1>
  166. <section1 topic='Business Rules' anchor='bizrules'>
  167. <section2 topic='Inclusion of Update Data in Presence' anchor='bizrules-presence'>
  168. <p>The following rules apply to inclusion of the update child element (&lt;x xmlns='vcard-temp:x:update'/&gt;) in presence broadcasts:</p>
  169. <ol>
  170. <li><p>If a client supports the protocol defined herein, it MUST include the update child element in every presence broadcast it sends and SHOULD also include the update child in directed presence stanzas (e.g., directed presence sent when joining &xep0045; rooms).</p></li>
  171. <li>
  172. <p>If a client is not yet ready to advertise an image, it MUST send an empty update child element, i.e.:</p>
  173. <example caption="User Is Not Ready to Advertise an Image"><![CDATA[
  174. <presence>
  175. <x xmlns='vcard-temp:x:update'/>
  176. </presence>
  177. ]]></example>
  178. </li>
  179. <li>
  180. <p>If there is no avatar image to be advertised, the photo element MUST be empty, i.e.:</p>
  181. <example caption="No Image to be Advertised"><![CDATA[
  182. <presence>
  183. <x xmlns='vcard-temp:x:update'>
  184. <photo/>
  185. </x>
  186. </presence>
  187. ]]></example>
  188. <p>If the client subsequently obtains an avatar image (e.g., by updating or retrieving the vCard), it SHOULD then publish a new &PRESENCE; stanza with character data in the &lt;photo/&gt; element.</p>
  189. <p>Note: This enables recipients to distinguish between the absence of an image (empty photo element) and mere support for the protocol (empty update child).</p>
  190. </li>
  191. </ol>
  192. </section2>
  193. <section2 topic='Downloading and Uploading the vCard' anchor='bizrules-vcard'>
  194. <p>The following rules apply to downloading and uploading the vCard:</p>
  195. <ol>
  196. <li><p>A client MUST NOT advertise an avatar image without first downloading the current vCard. Once it has done this, it MAY advertise an image. However, a client MUST advertise an image if it has just uploaded the vCard with a new avatar image. In this case, the client MAY choose not to redownload the vCard to verify its contents.</p></li>
  197. <li><p>Within a given session, a client MUST NOT attempt to upload a given avatar image more than once. The client MAY upload the avatar image to the vCard on login and after that MUST NOT upload the vCard again unless the user actively changes the avatar image.</p></li>
  198. <li><p>The client MUST NOT poll for new versions of the user's vCard in order to determine whether to update the avatar image hash.</p></li>
  199. </ol>
  200. </section2>
  201. <section2 topic='Multiple Resources' anchor='bizrules-resources'>
  202. <p>Jabber/XMPP allows multiple resources to authenticate for the same JID simultaneously. This introduces the potential of conflict between the resources regarding the user's avatar image. The following rules apply when a client receives a presence broadcast from another resource of its own JID:</p>
  203. <ol>
  204. <li><p>If the presence stanza received from the other resource does not contain the update child element, then the other resource does not support vCard-based avatars. That resource could modify the contents of the vCard (including the photo element); because polling for vCard updates is not allowed, the client MUST stop advertising the avatar image hash. However, the client MAY reset its hash if all instances of non-conforming resources have gone offline.</p></li>
  205. <li>
  206. <p>If the presence stanza received from the other resource contains the update child element, then the other resource conforms to the protocol for vCard-based avatars. There are three possible scenarios:</p>
  207. <ul>
  208. <li><p>If the update child element is empty, then the other resource supports the protocol but does not have its own avatar image. Therefore the client can ignore the other resource and continue to broadcast the existing image hash.</p></li>
  209. <li><p>If the update child element contains an empty photo element, then the other resource has updated the vCard with an empty BINVAL. Therefore the client MUST retrieve the vCard. If the retrieved vCard contains a photo element with an empty BINVAL, then the client MUST stop advertising the old image.</p></li>
  210. <li><p>If the update child element contains a non-empty photo element, then the client MUST compare the image hashes. If the hashes are identical, then the client can ignore the other resource and continue to broadcast the existing image hash. If the hashes are different, then the client MUST NOT attempt to resolve the conflict by uploading its avatar image again. Instead, it MUST defer to the content of the retrieved vCard by resetting its image hash (see below) and providing that hash in future presence broadcasts.</p></li>
  211. </ul>
  212. </li>
  213. </ol>
  214. </section2>
  215. <section2 topic='Resetting the Image Hash' anchor='bizrules-reset'>
  216. <p>Resetting the image hash consists of the following steps:</p>
  217. <ol>
  218. <li><p>Immediately send out a presence element with an empty update child element (containing no photo element).</p></li>
  219. <li><p>Download the vCard from the server.</p></li>
  220. <li><p>If the BINVAL is empty or missing, advertise an empty photo element in future presence broadcasts.</p></li>
  221. <li><p>If the BINVAL contains image data, calculate the hash of image and advertise that hash in future presence broadcasts.</p></li>
  222. </ol>
  223. </section2>
  224. <section2 topic='XML Syntax' anchor='bizrules-xml'>
  225. <p>The following rules apply to the XML syntax:</p>
  226. <ol>
  227. <li><p>The &lt;PHOTO/&gt; element SHOULD contain a &lt;BINVAL/&gt; child whose XML character data is Base64-encoded data for the avatar image.</p></li>
  228. <li><p>The &lt;PHOTO/&gt; element SHOULD NOT contain an &lt;EXTVAL/&gt; that points to a URI for the image file.</p></li>
  229. <li><p>The &lt;PHOTO/&gt; element MUST NOT contain the avatar image itself.</p></li>
  230. <li><p>The &lt;PHOTO/&gt; element SHOULD contain a &lt;TYPE/&gt; child whose XML character data specifies the content-type of the image data. The XML character data SHOULD be "image/gif", "image/jpeg", or "image/png".</p></li>
  231. <li><p>The &lt;PHOTO/&gt; element MUST NOT possess a 'mime-type' attribute.</p></li>
  232. </ol>
  233. </section2>
  234. <section2 topic='Image Restrictions' anchor='bizrules-image'>
  235. <p>The following rules apply to images:</p>
  236. <ol>
  237. <li><p>The image SHOULD use less than eight kilobytes (8k) of data; this restriction is to be enforced by the publishing client.</p></li>
  238. <li><p>The image height and width SHOULD be between thirty-two (32) and ninety-six (96) pixels; the recommended size is sixty-four (64) pixels high and sixty-four (64) pixels wide.</p></li>
  239. <li><p>The image SHOULD be square.</p></li>
  240. <li><p>The image content type <note>The IANA registry of content types is located at &lt;<link url=''></link>&gt;.</note> SHOULD be image/gif, image/jpeg, or image/png; support for the "image/png" content type is REQUIRED, support for the "image/gif" and "image/jpeg" content types is RECOMMENDED, and support for any other content type is OPTIONAL.</p></li>
  241. <li><p>The image data MUST conform to the base64Binary datatype <note>See &lt;<link url=''></link>&gt;.</note> and thus be encoded in accordance with Section 6.8 of &rfc2045;, which recommends that base64 data should have lines limited to at most 76 characters in length. However, any whitespace characters (e.g., '\r' and '\n') MUST be ignored.</p></li>
  242. </ol>
  243. </section2>
  244. </section1>
  245. <section1 topic='Implementation Notes' anchor='impl'>
  246. <p>The XML character data of the &lt;TYPE/&gt; element is a hint. If the XML character data of the &lt;TYPE/&gt; specifies a content type that does not match the data provided in the &lt;BINVAL/&gt; element, the processing application MUST adhere to the content type of the actual image data and MUST ignore the &lt;TYPE/&gt;. If the &lt;TYPE/&gt; is something other than image/gif, image/jpeg, or image/png, it SHOULD be ignored.</p>
  247. <p>If the image data exceeds the 8 KB restriction, the processing application SHOULD process the data.</p>
  248. </section1>
  249. <section1 topic='Security Considerations' anchor='security'>
  250. <p>This document introduces no security considerations above and beyond those described in &xmppcore;, &xmppim;, and &xep0054;.</p>
  251. </section1>
  252. <section1 topic='IANA Considerations' anchor='iana'>
  253. <p>This document requires no interaction with &IANA;.</p>
  254. </section1>
  255. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  256. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  257. <p>The &REGISTRAR; includes 'vcard-temp:x:update' in its registry of protocol namespaces (see &NAMESPACES;).</p>
  258. </section2>
  259. </section1>
  260. <section1 topic='XML Schema' anchor='schema'>
  261. <code><![CDATA[
  262. <?xml version='1.0' encoding='UTF-8'?>
  263. <xs:schema
  264. xmlns:xs=''
  265. targetNamespace='vcard-temp:x:update'
  266. xmlns='vcard-temp:x:update'
  267. elementFormDefault='qualified'>
  268. <xs:annotation>
  269. <xs:documentation>
  270. The protocol documented by this schema is defined in
  271. XEP-0153:
  272. </xs:documentation>
  273. </xs:annotation>
  274. <xs:element name='x'>
  275. <xs:complexType>
  276. <xs:sequence>
  277. <xs:element name='photo' minOccurs='0' type='xs:hexBinary'/>
  278. </xs:sequence>
  279. </xs:complexType>
  280. </xs:element>
  281. </xs:schema>
  282. ]]></code>
  283. </section1>
  284. <section1 topic='Acknowledgements' anchor='ack'>
  285. <p>The author wishes to thank the helpful developers who have implemented this protocol and provided feedback regarding its documentation.</p>
  286. </section1>
  287. </xep>