This document defines an XMPP protocol extension for exchanging user avatars.
WARNING: This Standards-Track document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the XMPP Standards Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems should not deploy implementations of this protocol until it advances to a status of Draft.
Series: XEP
Number: 0084
Publisher: XMPP Standards Foundation
Status:
Experimental
Type:
Standards Track
Version: 0.10
Last Updated: 2007-06-18
Approving Body: XMPP Council
Dependencies: XMPP Core, XEP-0030, XEP-0060, XEP-0163
Supersedes: XEP-0008
Superseded By: None
Short Name: TO BE ASSIGNED
Wiki Page: <http://wiki.jabber.org/index.php/User Avatar (XEP-0084)>
Email:
stpeter@jabber.org
JabberID:
stpeter@jabber.org
See Author Note
Email:
temas@jabber.org
JabberID:
temas@jabber.org
Email:
julian@jabber.org
JabberID:
julian@jabber.org
This XMPP Extension Protocol is copyright 1999 - 2007 by the XMPP Standards Foundation (XSF) and is in full conformance with the XSF's Intellectual Property Rights Policy <http://www.xmpp.org/extensions/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 discussion list: <http://mail.jabber.org/mailman/listinfo/standards>.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards 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 document 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 following keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
1. Introduction
2. Requirements
3. Basic Process Flow
3.1. User Publishes Data
3.2. User Publishes Metadata Notification
3.3. Subscribers Receive Metadata Notification
3.4. Subscribers Retrieve Data
3.5. Publisher Disables Avatars
4. Protocol Syntax
4.1. Data Element
4.2. Metadata Element
4.2.1. Info Element
4.2.2. Pointer Element
4.2.3. Stop Element
5. Additional Examples
5.1. Metadata With Multiple Content-Types
5.2. Metadata With Pointer
6. Service Discovery
6.1. Discovering Avatar Availability
7. Business Rules
7.1. Image Requirements
8. Implementation Notes
8.1. Multiple Resources
8.2. Avatar Synchronization
8.3. Image Handling
9. Security Considerations
10. IANA Considerations
11. XMPP Registrar Considerations
11.1. Protocol Namespaces
12. XML Schema
12.1. Data Namespace
12.2. Metadata Namespace
13. Author Note
Notes
Revision History
Many communication applications allow for the association of a small image or icon with a user of that application. Usually, such an "avatar" is not intended to be an accurate picture of the user's actual physical appearance, but rather a representation (often fanciful) of the user's desired self-image or a transient state of the user (such as a mood or activity). This document outlines a way to incorporate avatars into current Jabber/XMPP systems by layering this functionality on top of the XMPP Publish-Subscribe [1] extension ("pubsub"), specifically the Personal Eventing via Pubsub [2] subset ("PEP"), which is designed for use in the context of XMPP instant messaging and presence systems that conform to RFC 3921 [3].
The protocol defined herein uses two pubsub nodes: one node for "metadata" about the avatar state (called the "metadata node") and one for the avatar data itself (called the "data node"). This separation of metadata from data conserves bandwidth and enables both the publisher and the subscriber to cache the avatar data. (For example, a user might toggle between two or three avatars, in which case the user's contacts can display a locally cached version of the images without having to retrieve or receive the full image each time.)
This protocol also allows storage of avatar data at a URL accessible via HTTP (see RFC 2616 [4]). [5] This can be helpful as a fallback mechanism if a pubsub-aware data repository is not available. It also makes it possible for avatar images to be hosted on public websites (e.g., an end-user-oriented community site) and retrieved from that site rather than handled directly by the publishing client in any fashion.
Finally, this protocol also enables XMPP applications to optionally integrate with third-party services that host user avatars (e.g., online gaming systems and virtual worlds).
This document addresses the following use cases for avatar publishers:
This document addresses the following use cases for avatar subscribers:
The process for publishing and updating user avatars is as follows:
This process flow is described more fully in the following sections.
Note: Before publishing avatar data and metadata, the user MUST determine if his or her server supports the PEP subset of pubsub by following the procedures specified in XEP-0163, since such support simplifies avatar publication. The following examples assume the availability of a PEP service.
Before updating the avatar metadata node, the publisher MUST make sure that the avatar data is available at the data node or URL. When publishing the avatar data to the data node, the publisher MUST ensure that the value of the pubsub ItemID is the SHA1 hash of the data for the "image/png" content-type (this is used by the subscriber to determine if a locally cached copy can be displayed).
The following example illustrates the XML structure to be sent when publishing avatar data to the data node.
<iq type='set' from='juliet@capulet.com/chamber' id='publish1'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='http://www.xmpp.org/extensions/xep-0084.html#ns-data'> <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'> <data xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-data'> qANQR1DBwU4DX7jmYZnncm... </data> </item> </publish> </pubsub> </iq>
<iq type='result' to='juliet@capulet.com/chamber' id='publish1'/>
Whenever the publisher wishes to change its current avatar, it MUST update the metadata node.
The following example shows metadata specifying avatar data that is available in only one format ("image/png") and accessible only at the data node:
<iq type='set' from='juliet@capulet.com/chamber' id='publish2'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'> <metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <info id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f' type='image/png' bytes='12345' height='64' width='64'/> </metadata> </item> </publish> </pubsub> </iq>
Subscribers to the metadata node would then receive the notification:
<message to='romeo@montague.net' from='juliet@capulet.com'> <event xmlns='http://jabber.org/protocol/pubsub#event'> <items node='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'> <metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <info id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f' type='image/png' bytes='12345' height='64' width='64'/> </metadata> </item> </items> </event> <addresses xmlns='http://jabber.org/protocol/address'> <address type='replyto' jid='juliet@capulet.com/chamber'/> </addresses> </message>
Depending on node configuration, the item may include Extended Stanza Addressing [6] information about the publishing resource (see XEP-0163 and XEP-0060 for details).
Upon receiving the notification, each subscriber SHOULD determine if it has a locally cached copy of that avatar (which it can determine by searching for an image identified by the ItemID). If the subscriber already has a locally cached copy of the avatar image, it MUST NOT retrieve the image data.
If the subscriber does not have a locally cached copy of the avatar image, it SHOULD retrieve the data. It can do this by sending a pubsub get-items request to the data node, specifying the appropriate ItemID:
<iq type='get' from='romeo@montague.net/home' to='juliet@capulet.com' id='retrieve1'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <items node='http://www.xmpp.org/extensions/xep-0084.html#ns-data'> <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'> </items> </pubsub> </iq>
The PEP service running at the user's server then SHOULD return the avatar data:
<iq type='result' from='juliet@capulet.com' to='romeo@montague.net/home' id='retrieve1'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <items node='http://www.xmpp.org/extensions/xep-0084.html#ns-data'> <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'> <data xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-data'> qANQR1DBwU4DX7jmYZnncm... </data> </item> </items> </pubsub> </iq>
If the <info/> element sent to the metadata node possesses a 'url' attribute, the avatar data is hosted at a URL. Therefore, in order to retrieve the avatar image data for that content-type, the requesting entity MUST send an HTTP request to the specified URL. Methods for doing so are out of scope for this document.
In order to temporarily disable any avatar, the user publishes an empty <stop/> element to the metadata node (this item SHOULD NOT possess an ItemID):
<iq type='set' from='juliet@capulet.com/chamber' id='publish3'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='avatar/info/juliet@capulet.com'> <item> <metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <stop/> </metadata> </item> </publish> </pubsub> </iq>
As before, subscribers to the metadata node would then receive the notification:
<message to='romeo@montague.net' from='juliet@capulet.com'> <event xmlns='http://jabber.org/protocol/pubsub#event'> <items node='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <item> <metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <stop/> </metadata> </item> </items> </event> <addresses xmlns='http://jabber.org/protocol/address'> <address type='replyto' jid='juliet@capulet.com/chamber'/> </addresses> </message>
The PEP subset of pubsub requires that there shall exist a one-to-one relationship between namespaces and nodes. Because the protocol defined herein stipulates the use of two nodes (one for avatar data and one for avatar metadata), we define two namespaces, each with a corresponding root element:
These are further specified below.
The <data/> element is used to communicate the avatar data itself, and only for the "image/png" content-type (support for which is REQUIRED):
<data xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-data'> IMAGE DATA </data>
The XML character data MUST represent the image data for the avatar with a content-type of "image/png", Base64-encoded in accordance with Section 4 of RFC 4648 [7]. (Note: Line feeds SHOULD NOT be added but MUST be accepted.)
Support for the <data/> element is REQUIRED.
The <metadata/> element is used to communicate information about the avatar. There are three allowable children of the <metadata/> element:
These are further specified below.
The <info/> child element is used to communicate avatar metadata:
<metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <info bytes='size-of-image-data-in-bytes' height='image-height-in-pixels' id='SHA1-hash-of-image-data' type='content-type-of-image-data' url='HTTP-URL-for-image-data' width='image-width-in-pixels'/> </metadata>
The <info/> child element MUST be empty.
The <info/> child element MUST possess the following attributes:
The <info/> child element SHOULD possess the following attributes:
The <info/> element MAY possess the following attribute:
If the <info/> element element does not possess a 'url' attribute, then it is assumed that the data is available at the data node rather than an HTTP URL.
The <metadata/> root element MAY contain more than one <info/> element. Each <info/> element MUST specify metadata for the same avatar image but in alternate content-types (e.g., "image/png", "image/gif", and "image/jpeg"), and one of the formats MUST be "image/png" to ensure interoperability. The value of the 'type' attribute MUST be an IANA-registered content type of type "image" or "video". [8] Support for the "image/png" content type is REQUIRED. Support for the "image/gif" and "image/jpeg" content types is RECOMMENDED. Support for any other content type is OPTIONAL.
The value of the 'id' attribute MUST be the SHA1 (RFC 3174 [9]) hash of the image data for the specified content-type.
Support for the <info/> element is REQUIRED.
The <pointer/> child element is used to point to an avatar that is not published via pubsub or HTTP, but rather is provided by a third-party service such as an online gaming system or virtual world:
<metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <pointer> ... APPLICATION-SPECIFIC DATA ... </pointer> </metadata>
The <pointer/> element MAY possess the following attributes if the publishing application has the relevant information:
The content of the <pointer/> element MUST be a properly-namespaced child element that specifies information about how to retrieve the avatar from the third-party service. The structure for any such child element is out of scope for this document.
Even if the <pointer> element is included, it MUST be preceded by at least one instance of the <info/> element so that implementations that do not support the <pointer/> element can display a "fallback" format of the avatar (at a minimum, "image/png").
Support for the <pointer/> element is OPTIONAL.
The <stop/> child element is used to signal that avatar publishing has been disabled:
<metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <stop/> </metadata>
The <stop/> element MUST be empty and MUST NOT possess any attributes.
Support for the <stop/> element is REQUIRED.
The following example shows metadata specifying avatar data that is available in multiple formats ("image/png", "image/gif", and "image/mng"), where the "image/png" content-type is available only at the data node and the other content-types are available HTTP URLs:
<iq type='set' from='juliet@capulet.com/chamber' id='publish3'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'> <metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <info id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f' type='image/png' bytes='12345' height='64' width='64'/> <info id='222f4b3c50d7b0df729d299bc6f8e9ef9066971f' url='http://avatars.jabberstudio.org/happy.gif' type='image/gif' bytes='23456' height='64' width='64'/> <info id='333f4b3c50d7b0df729d299bc6f8e9ef9066971f' url='http://avatars.jabberstudio.org/happy.mng' type='image/mng' bytes='78912' height='64' width='64'/> </metadata> </item> </publish> </pubsub> </iq>
The following example shows metadata specifying avatar data that is available in "image/png" at the data node and also with a pointer to an external service.
<iq type='set' from='juliet@capulet.com/chamber' id='publish4'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'> <metadata xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'> <info id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f' type='image/png' bytes='12345' height='64' width='64'/> <pointer> <x xmlns='http://example.com/virtualworlds'> <game>Ancapistan</game> <character>Kropotkin</character> </x> </pointer> </metadata> </item> </publish> </pubsub> </iq>
The pubsub "auto-subscribe" and "filtered-notifications" features enable a contact to automatically subscribe to a user's avatar. However, a contact can also explicitly determine if another user publishes avatars using this protocol by sending a Service Discovery [10] items ("disco#items") request to the user's bare JID (<node@domain.tld>):
<iq type='get' from='romeo@montague.net/orchard' to='juliet@capulet.com' id='items1'> <query xmlns='http://jabber.org/protocol/disco#items'/> </iq>
If the user publishes avatar data to an PEP node, the result MUST contain the appropriate items:
<iq type='result' from='juliet@capulet.com' to='romeo@montague.net/orchard' id='items1'> <query xmlns='http://jabber.org/protocol/disco#items'> <item jid='juliet@capulet.com' node='http://www.xmpp.org/extensions/xep-0084.html#ns-data'/> <item jid='juliet@capulet.com' node='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata'/> </query> </iq>
The contact then MAY subscribe to the metadata node following the protocol specified in XEP-0060. However, the contact SHOULD NOT subscribe to the data node (instead, it SHOULD simply retrieve items from that node when needed, as described above).
The following restrictions apply to the image:
If a user has multiple online resources at the same time, each resource MAY publish a different avatar. The PEP service SHOULD include the replyto address of the publishing resource as shown above in order to facilitate differentiation between per-resource avatars.
When a user logs in with a new resource and before publishing an avatar, its client SHOULD retrieve its last published avatar, either automatically by sending presence with the appropriate Entity Capabilities [11] information or using the "get-items" method described in XEP-0060.
It is the responsibility of the receiving application to determine which avatar format to retrieve (e.g., "image/gif" rather than "image/png") and to determine the appropriate method for retrieval (e.g., HTTP rather than pubsub).
The receiving application SHOULD NOT scale up an image when displaying it.
If an avatar is not available for a contact, the receiving MAY display the contact's photo, e.g., as provided in the contact's vCard (see vcard-temp [12]) or other profile information.
See XEP-0060 and XEP-0163 regarding security considerations related to the underlying transport protocol.
It is possible that output of the SHA-1 hashing algorithm can result in collisions; however, the use of SHA-1 in producing a hash of the avatar data is not security-critical.
This document makes use of IANA-registered content types, but requires no interaction with the Internet Assigned Numbers Authority (IANA) [13].
Until this specification advances to a status of Draft, its associated namespaces shall be "http://www.xmpp.org/extensions/xep-0084.html#ns-data" and "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata"; upon advancement of this specification, the XMPP Registrar [14] shall issue permanent namespaces in accordance with the process defined in Section 4 of XMPP Registrar Function [15].
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata' xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata' elementFormDefault='qualified'> <xs:element name='data' type='xs:base64Binary'> </xs:schema>
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata' xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-metadata' elementFormDefault='qualified'> <xs:element name='metadata'> <xs:complexType> <xs:choice> <xs:sequence minOccurs='0' maxOccurs='1'> <xs:element ref='info' minOccurs='1' maxOccurs='unbounded'/> <xs:element ref='pointer' minOccurs='0' maxOccurs='unbounded'/> </xs:sequence> <xs:element name='stop' type='empty'/> </xs:choice> </xs:complexType> </xs:element> <xs:element name='info'> <xs:complexType> <xs:simpleContent> <xs:extension base='empty'> <xs:attribute name='bytes' type='xs:unsignedShort' use='required'/> <xs:attribute name='type' type='xs:string' use='required'/> <xs:attribute name='height' type='xs:unsignedByte' use='optional'/> <xs:attribute name='id' type='xs:string' use='required'/> <xs:attribute name='url' type='xs:anyURI' use='optional'/> <xs:attribute name='width' type='xs:unsignedByte' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name='pointer'> <xs:complexType> <xs:sequence> <xs:any namespace='##other'/> </xs:sequence> </xs:complexType> </xs:element> <xs:simpleType name='empty'> <xs:restriction base='xs:string'> <xs:enumeration value=''/> </xs:restriction> </xs:simpleType> </xs:schema>
Peter Millard, a co-author of this specification from version 0.1 through version 0.7, died on April 26, 2006. The remaining authors are thankful for his work on user avatars.
1. XEP-0060: Publish-Subscribe <http://www.xmpp.org/extensions/xep-0060.html>.
2. XEP-0163: Personal Eventing via Pubsub <http://www.xmpp.org/extensions/xep-0163.html>.
3. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc3921>.
4. RFC 2616: Hypertext Transport Protocol -- HTTP/1.1 <http://tools.ietf.org/html/rfc2616>.
5. By "accessible via HTTP" is meant that the data is available at an http: or https: URI.
6. XEP-0033: Extended Stanza Addressing <http://www.xmpp.org/extensions/xep-0033.html>.
7. RFC 4648: The Base16, Base32, and Base64 Data Encodings <http://tools.ietf.org/html/rfc4648>.
8. The IANA registry of content types is located at <http://www.iana.org/assignments/media-types/>.
9. RFC 3174: US Secure Hash Algorithm 1 (SHA1) <http://tools.ietf.org/html/rfc3174>.
10. XEP-0030: Service Discovery <http://www.xmpp.org/extensions/xep-0030.html>.
11. XEP-0115: Entity Capabilities <http://www.xmpp.org/extensions/xep-0115.html>.
12. XEP-0054: vcard-temp <http://www.xmpp.org/extensions/xep-0054.html>.
13. 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/>.
14. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <http://www.xmpp.org/registrar/>.
15. XEP-0053: XMPP Registrar Function <http://www.xmpp.org/extensions/xep-0053.html>.
Changed height and width attributes from required to recommended; updated security considerations to reflect problems with SHA-1; further specified datatypes.
(psa)Updated to reflect pubsub and PEP changes; added implementation notes about multiple resources and avatar synchronization; modified experimental namespaces to conform to XEP-0053.
(psa)Updated to reflect pubsub and PEP changes; added implementation notes about multiple resources and avatar synchronization.
(psa)Updated to use PEP.
(psa)Major modification per list discussion: specified that metadata may include the same avatar in multiple alternate formats; allowed pointers to third-party avatars not available via pubsub or HTTP; changed pixel size restrictions; specified that bytes, content-type, height, id, and width are required metadata; changed type attribute to content-type; made explicit that URLs can be http: or https: URIs; more fully specified protocol, updated the examples, updated the schemas.
(psa)Friendly fork per Council discussion: allowed data to be stored in a pubsub data repository or at a URL accessible via HTTP; also split text into publisher and subscriber use cases, specified requirements, added more examples, etc.
(psa/pgm)Lessen the image requirements. Include the content type in info.
(tjm)Drastic change to use two nodes on pubsub, allowing for hash updates independently of the data. This makes client caching much easier. Allow only PNG and MNG currently.
(tjm)Clarified the use of "current" as the item id. Fixed some example errors. Made the interaction with disco more clear. The reason to use pubsub is made more clear as well.
(tjm)Initial version.
(tjm)END