This JEP provides historical documentation of a vCard-based protocol for exchanging user avatars.
NOTICE: This Historical JEP attempts to provide canonical documentation of a protocol that is in use within the Jabber/XMPP community. Publication as a Jabber Enhancement Proposal does not imply approval of this proposal by the Jabber Software Foundation. This JEP is not a standards-track specification within the Jabber Software Foundation's standards process; however, it may be converted to standards-track in the future or may be obsoleted by a more modern protocol.
Status: Experimental
Type: Historical
Number: 0153
Version: 0.1
Last Updated: 2005-06-16
JIG: Standards JIG
Approving Body: Jabber Council
Dependencies: XMPP Core, XMPP IM, JEP-0054
Supersedes: None
Superseded By: None
Short Name: Not yet assigned
Email: stpeter@jabber.org
JID: stpeter@jabber.org
This Jabber Enhancement Proposal is copyright 1999 - 2005 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <http://www.jabber.org/jsf/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).
The preferred venue for discussion of this document is the Standards-JIG discussion list: <http://mail.jabber.org/mailman/listinfo/standards-jig>.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the Jabber Software Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this JEP has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
There exist several proposed protocols for communicating user avatar information over Jabber/XMPP (see IQ-Based Avatars [1] and User Avatar [2]). This JEP describes another such protocol that is in use today on the Jabber/XMPP network. This JEP is historical and does not purport to propose a standards-track protocol. However, a future protocol may improve on the approach documented herein.
The protocol described herein seems to have been designed with the following requirements in mind:
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 vcard-temp [3]. The avatar image (more precisely, the Base64-encoded image data) SHOULD be provided as the XML character data of the <BINVAL/> child of the <PHOTO/> element (rather than pointing to a URI for the image file in the <EXTVAL/> child), and the image type SHOULD be communicated as the XML character data of the <TYPE/> child of the <PHOTO/> element.
<iq from='juliet@capulet.com' type='set' id='vc1'> <vCard xmlns='vcard-temp'> <BDAY>1476-06-09</BDAY> <ADR> <CTRY>Italy</CTRY> <LOCALITY>Verona</LOCALITY> <HOME/> </ADR> <NICKNAME/> <N><GIVEN>Juliet</GIVEN><FAMILY>Capulet</FAMILY></N> <EMAIL>jcapulet@shakespeare.lit</EMAIL> <PHOTO> <TYPE>image/jpeg</TYPE> <BINVAL> Base64-encoded-avatar-file-here! </BINVAL> </PHOTO> </vCard> </iq>
<iq to='juliet@capulet.com' type='result' id='vc1'/>
Next, the user's client computes the SHA1 hash of the avatar image in accordance with RFC 3174 [4]. This hash is then included in the user's presence information as the XML character data of the <photo/> child of an <x/> element qualified by the 'vcard-temp:x:update' namespace, as shown in the following example:
<presence from='juliet@capulet.com/balcony'> <x xmlns='vcard-temp:x:update'><photo>sha1-hash-of-image</photo></x> </presence>
The user's server then broadcasts that presence information to all contacts who are subscribed to the user's presence information.
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 describerd in JEP-0054 (note that this request is sent to the user's bare JID, not full JID):
<iq from='romeo@montague.net/orchard' to='juliet@capulet.com' type='get' id='vc2'> <vCard xmlns='vcard-temp'/> </iq>
<iq from='juliet@capulet.com' to='romeo@montague.net/orchard' type='result' id='vc2'> <vCard xmlns='vcard-temp'> <BDAY>1476-06-09</BDAY> <ADR> <CTRY>Italy</CTRY> <LOCALITY>Verona</LOCALITY> <HOME/> </ADR> <NICKNAME/> <N><GIVEN>Juliet</GIVEN><FAMILY>Capulet</FAMILY></N> <EMAIL>jcapulet@shakespeare.lit</EMAIL> <PHOTO> <TYPE>image/jpeg</TYPE> <BINVAL> Base64-encoded-avatar-file-here! </BINVAL> </PHOTO> </vCard> </iq>
The following rules apply to inclusion of the update child element (<x xmlns='vcard-temp:x:update'/>) in presence broadcasts:
If a client supports the protocol defined herein, it MUST include the update child element in every presence broadcast it sends.
If a client is not yet ready to advertise an image, it MUST send an empty update child element, i.e.:
<presence> <x xmlns='vcard-temp:x:update'/> </presence>
If there is no avatar image to be advertised, the photo element MUST be empty, i.e.:
<presence> <x xmlns='vcard-temp:x:update'> <photo/> </x> </presence>
This enables recipients to distinguish between the absence of an image (empty photo element) and mere support for the protocol (empty update child).
The following rules apply to downloading and uploading the vCard:
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.
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.
The client MUST NOT poll for new versions of the user's vCard in order to determine whether to update the avatar image hash.
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:
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.
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:
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.
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.
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.
Resetting the image hash consists of the following steps:
Immediately send out a presence element with an empty update child element (containing no photo element).
Download the vCard from the server.
If the BINVAL is empty or missing, advertise an empty photo element in future presence broadcasts.
If the BINVAL contains image data, calculate the hash of image and advertise that hash in future presence broadcasts.
The following rules apply to images:
The image MUST use less than eight kilobytes (8k) of data; this restriction is to be enforced by the publishing client.
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.
The image SHOULD be square.
The image content type [5] 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.
This JEP introduces no security considerations above and beyond those described in RFC 3920 and RFC 3921.
This JEP requires no interaction with the Internet Assigned Numbers Authority (IANA) [6].
The Jabber Registrar [7] shall include 'vcard-temp:x:update' in its registry of protocol namespaces.
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='vcard-temp:x:update' xmlns='vcard-temp:x:update' elementFormDefault='qualified'> <xs:element name='x'> <xs:complexType> <xs:sequence> <xs:element name='photo' minOccurs='0' type='xs:string'/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
The author wishes to thank the helpful developers who have implemented this protocol and provided feedback regarding its documentation.
1. JEP-0008: IQ-Based Avatars <http://www.jabber.org/jeps/jep-0008.html>.
2. JEP-0084: User Avatar <http://www.jabber.org/jeps/jep-0084.html>.
3. JEP-0054: vcard-temp <http://www.jabber.org/jeps/jep-0054.html>.
4. RFC 3174: US Secure Hash Algorithm 1 (SHA1) <http://www.ietf.org/rfc/rfc3174.txt>.
5. The IANA registry of content types is located at <http://www.iana.org/assignments/media-types/>.
6. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
7. The Jabber Registrar maintains a list of reserved Jabber protocol namespaces as well as registries of parameters used in the context of protocols approved by the Jabber Software Foundation. For further information, see <http://www.jabber.org/registrar/>.
END