XEP-0231: Data Element

This specification defines an XMPP protocol extension for including small bits of binary data in an XML stanza.


NOTICE: This document is currently within Last Call or under consideration by the XMPP Council for advancement to the next stage in the XSF standards process.


Document Information

Series: XEP
Number: 0231
Publisher: XMPP Standards Foundation
Status: Proposed
Type: Standards Track
Version: 0.4
Last Updated: 2008-08-05
Approving Body: XMPP Council
Dependencies: XMPP Core, RFC 2045, RFC 2111, RFC 2965, RFC 4648
Supersedes: None
Superseded By: None
Short Name: NOT_YET_ASSIGNED
Wiki Page: <http://wiki.jabber.org/index.php/Data Element (XEP-0231)>


Author Information

Peter Saint-Andre

JabberID: stpeter@jabber.org
URI: https://stpeter.im/


Legal Notices

Copyright

This XMPP Extension Protocol is copyright (c) 1999 - 2008 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. In no event shall the XMPP Standards Foundation or the authors of this Specification be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising out of the use or inability to use the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which may be found at <http://www.xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).

Discussion Venue

The preferred venue for discussion of this document is the Standards discussion list: <http://mail.jabber.org/mailman/listinfo/standards>.

Given that this XMPP Extension Protocol normatively references IETF technologies, discussion on the XSF-IETF list may also be appropriate (see <http://mail.jabber.org/mailman/listinfo/jsf-ietf> for details).

Errata may be sent to <editor@xmpp.org>.

Relation to XMPP

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.

Conformance Terms

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".


Table of Contents


1. Introduction
2. Format
3. Caching of Data
4. Use Cases
    4.1. In-Band Images for XMPP Messaging
    4.2. Media Data in XMPP Data Forms
    4.3. Previews for XMPP File Transfers
    4.4. Retrieving Uncached Media Data
5. Security Considerations
6. IANA Considerations
7. XMPP Registrar Considerations
    7.1. Protocol Namespaces
    7.2. Service Discovery Features
8. XML Schema
9. Acknowledgements
Notes
Revision History


1. Introduction

Sometimes it is desirable to include a small bit of binary data in an XMPP stanza. Typical use cases might be inclusion of an icon or emoticon in a message, a thumbnail in a file transfer request, a rasterized image in a whiteboarding session, or a small bit of media in a data form. At present, there is no lightweight method for including such data in an XMPP stanza, since existing methods (e.g., In-Band Bytestreams [1]) are designed for larger blobs of data and therefore require some form of negotiation (e.g., via SI File Transfer [2] or Jingle File Transfer [3]). Therefore, this document specifies just such a lightweight method, using a <data/> element that provides semantics similar to the data: URL scheme defined in RFC 2397 [4].

2. Format

The format for including binary data is straightforward: the data is encapsulated as the XML character data of a <data/> element qualified by the 'urn:xmpp:tmp:data-element' namespace (see Protocol Namespaces regarding issuance of one or more permanent namespaces), where the data MUST be encoded as Base64 in accordance with Section 4 of RFC 4648 [5] (note: the Base64 output MUST NOT include whitespace and MUST set the number of pad bits to zero).

The <data/> element MUST be used only to encapsulate small bits of binary data and MUST NOT be used for large data transfers. Naturally the definitions of "small" and "large" are rather loose. In general, the data SHOULD NOT be more than 8 kilobytes, and dedicated file transfer methods (e.g., SOCKS5 Bytestreams [6] or In-Band Bytestreams [7]) SHOULD be used for exchanging blobs of data larger than 8 kilobytes. Naturally, implementations or deployments may impose their own limits.

The following attributes are defined for the <data/> element.

Table 1: Defined Attributes

Attribute Description Inclusion
alt A human-readable description of the data. RECOMMENDED
cid A Content-ID that can be mapped to a cid: URL as specified in RFC 2111 [8]. The 'cid' value MUST be generated so that the local-part is a UUID as specified in RFC 4122 [9] and the domain is the XMPP domain identifier portion of the sending entity's JabberID. RECOMMENDED
max-age A suggestion regarding how long (in seconds) to cache the data; the meaning matches the Max-Age attribute from RFC 2965 [10]. RECOMMENDED when sending a <data/> element containing XML character data
type The value of the 'type' attribute MUST match the syntax specified in RFC 2045 [11]. That is, the value MUST include a top-level media type, the "/" character, and a subtype; in addition, it MAY include one or more optional parameters (e.g., the "audio/ogg" MIME type in the example shown below includes a "codecs" parameter as specified in RFC 4281 [12]). The "type/subtype" string SHOULD be registered in the IANA MIME Media Types Registry [13], but MAY be an unregistered or yet-to-be-registered value. REQUIRED

The following example illustrates the format (line endings are provided for readability only).

Example 1. Data element format

<data xmlns='urn:xmpp:tmp:data-element' 
      alt='A spot'
      cid='f81d4fae-7dec-11d0-a765-00a0c91e6bf6@shakespeare.lit'
      max-age='86400'
      type='image/png'>
  iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
  C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
  AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
  REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
  ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
  vr4MkhoXe0rZigAAAABJRU5ErkJggg==
</data>
  

3. Caching of Data

When one party sends a data element to another party, it SHOULD NOT include the data itself unless the data is particularly small (e.g., less than 1k) or is ephemeral and therefore will never be used again. Instead, it SHOULD send an empty <data/> element with a 'cid' attribute, then depend on the receiving party to retrieve the data if not cached.

As a hint regarding the suggested period for caching the data, the sending party SHOULD include a 'max-age' attribute whenever it sends a non-empty <data/> element. The semantics of the 'max-age' attribute exactly matches that of the Max-Age attribute from RFC 2965.

It is RECOMMENDED for the receiving entity to cache data; however, the receiving entity MAY opt not to cache data, for example because it runs on an a device that does not have sufficient space for data storage.

The default behavior is for the receiving entity to cache the data only for the life of the entity's application session (not a controlling user's presence session with the server or the controlling user's communication session with the contact from whom the user received the data); that is, the receiving entity would clear the cache when the application is terminated or restarted.

If it is not suggested to cache the data (e.g., because it is ephemeral), the value of the 'max-age' attribute MUST be "0" (the number zero).

A receiving entity MUST cache based on the JID of the sending entity; this helps to prevent certain data poisoning attacks.

4. Use Cases

4.1 In-Band Images for XMPP Messaging

The <data/> element can be used in conjunction with XHTML-IM [14] and the cid: URL scheme to point to binary data that is provided in-band within a <message/> stanza.

Note: The sender SHOULD NOT include an in-band image unless the intended recipient advertises (via Service Discovery [15] or Entity Capabilities [16]) support for the "urn:xmpp:tmp:data-element:inband-image" service discovery feature (see Protocol Namespaces regarding issuance of one or more permanent namespaces).

Example 2. A message with included data

<message from='ladymacbeth@shakespeare.lit/castle'
         to='macbeth@chat.shakespeare.lit'
         type='groupchat'>
  <body>Yet here's a spot.</body>
  <html xmlns='http://jabber.org/protocol/xhtml-im'>
    <body xmlns='http://www.w3.org/1999/xhtml'>
      <p>
        Yet here's a spot.
        <img alt='A spot'
             src='cid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6@shakespeare.lit'/>
      </p>
    </body>
  </html>
  <data xmlns='urn:xmpp:tmp:data-element' 
        alt='A spot'
        cid='f81d4fae-7dec-11d0-a765-00a0c91e6bf6@shakespeare.lit'
        max-age='86400'
        type='image/png'>
    iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
    C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
    AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
    REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
    ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
    vr4MkhoXe0rZigAAAABJRU5ErkJggg==
  </data>
</message>
    

Once the data is provided, a subsequent message in the same session can refer to the data again without including the data itself.

Example 3. A message with referenced data

<message from='ladymacbeth@shakespeare.lit/castle'
         to='macbeth@chat.shakespeare.lit'
         type='groupchat'>
  <body>Out, damned spot!</body>
  <html xmlns='http://jabber.org/protocol/xhtml-im'>
    <body xmlns='http://www.w3.org/1999/xhtml'>
      <p>
        Out damned spot! 
        <img alt='A spot'
             src='cid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6@shakespeare.lit'/>
      </p>
    </body>
  </html>
</message>
    

If the receiving entity has not cached the data, it can request the data as described in the Retrieving Data section of this document.

4.2 Media Data in XMPP Data Forms

Data Forms Media Element [17] describes how to include a media element in Data Forms [18], e.g. for the purpose of placing a human-viewable "CAPTCHA" in a form that is used for CAPTCHA Forms [19] or In-Band Registration [20]. The <media/> element described in XEP-0221 contains one or more <uri/> elements (which point to locations where the media can be downloaded, e.g. via HTTP) as well as a <data/> element that includes the data itself. The <media/> element would contain a <data/> element as described herein and shown in the following example.

Example 4. Audio Media Element

<media xmlns='urn:xmpp:tmp:media-element'>
  <uri type='audio/x-wav'>
    http://victim.example.com/challenges/speech.wav?F3A6292C
  </uri>
  <uri type='audio/ogg; codecs=speex'>
    http://victim.example.com/challenges/speech.ogg?F3A6292C
  </uri>
  <uri type='audio/mpeg'>
    http://victim.example.com/challenges/speech.mp3?F3A6292C
  </uri>
  <data xmlns='urn:xmpp:tmp:data-element' 
        alt='An audio file'
        type='audio/ogg; codecs=speex'/>
  </data>
</media>
    

The media would then be included in a data form as illustrated in XEP-0221.

4.3 Previews for XMPP File Transfers

A previous proposal [21] described a method for including a thumbnail or file preview in a file transfer request. Such a preview can be included using the <data/> element, as shown below.

Note: The initiator SHOULD NOT include a file preview unless the receiving entity advertises (via XEP-0030 or XEP-0115) support for the "urn:xmpp:tmp:data-element:file-preview" service discovery feature (see Protocol Namespaces regarding issuance of one or more permanent namespaces).

Example 5. File transfer offer with preview

<iq from='romeo@montague.lit/home'
    id='offer1'
    to='juliet@capulet.com/chamber'
    type='set'>
  <si xmlns='http://jabber.org/protocol/si' 
      profile='http://jabber.org/protocol/si/profile/file-transfer' 
      id='s5b_46e78e4a0ddacc74' >
    <file xmlns='http://jabber.org/protocol/si/profile/file-transfer' 
          size='330527' 
          name='image.png'>
      <data xmlns='urn:xmpp:tmp:data-element' 
            alt='There be dragons!'
            cid='d8f904ac-636c-11dd-8a2f-001143d5d5db@montague.lit'
            type='image/png'>
        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
        5v4/R2f0swq2hnQAAAAASUVORK5CYII=
      </data>
      <range/>
    </file>
    <feature xmlns='http://jabber.org/protocol/feature-neg'>
      <x xmlns='jabber:x:data' type='form'>
        <field var='stream-method' type='list-single'>
          <option><value>http://jabber.org/protocol/bytestreams</value></option>
          <option><value>http://jabber.org/protocol/ibb</value></option>
        </field>
      </x>
    </feature>
  </si>
</iq>
    

4.4 Retrieving Uncached Media Data

Data can be requested and transferred using the XMPP <iq/> stanza type by making reference to the 'cid' of the data to be retrieved. In particular, the requesting entity can request data by sending an IQ-get containing an empty <data/> element with a 'cid' attribute.

Example 6. Requesting data

<iq from='doctor@shakespeare.lit/pda'
    id='get-data-1'
    to='gentlewoman@shakespeare.lit/phone'
    type='get'>
  <data xmlns='urn:xmpp:tmp:data-element' 
        cid='f81d4fae-7dec-11d0-a765-00a0c91e6bf6@shakespeare.lit'/>
</iq>
    

The responding entity then would either return an error (e.g., <item-not-found/> if it does not have data matching the Content-ID) or return the data.

Example 7. Returning data

<iq from='gentlewoman@shakespeare.lit/phone'
    id='get-data-1'
    to='doctor@shakespeare.lit/pda'
    type='result'>
  <data xmlns='urn:xmpp:tmp:data-element' 
        alt='A spot'
        cid='f81d4fae-7dec-11d0-a765-00a0c91e6bf6@shakespeare.lit'
        max-age='86400'
        type='image/png'>
    iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
    C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
    AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
    REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
    ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
    vr4MkhoXe0rZigAAAABJRU5ErkJggg==
  </data>
</iq>
    

This specification does not place limits on the entities from which data can be requested. In particular, such an entity need not be the "owner" of the data (e.g., it could be a peer in a chatroom or whiteboarding session, or the chatroom or whiteboarding service itself).

In addition, bits of data could be hosted by XMPP servers, distributed via Publish-Subscribe [22] nodes, or included in data collections that are available via HTTP (e.g., emoticon sets). Such data could be identified by the value of the 'cid' attribute, but methods for specifying those values are out of scope for this specification.

5. Security Considerations

The ability to include arbitrary binary data implies that it is possible to send scripts, applets, images, and executable code, which may be potentially harmful. To reduce the risk of such exposure, an implementation MAY choose to not display or process such data but instead either completely ignore the data, show only the value of the 'alt' attribute, or prompt a human user for approval (either explicitly via user action or implicitly via a list of approved entities from whom the user will accept binary data without per-event approval).

The receiving entity SHOULD cache data based on the sender's JabberID; this helps to avoid data poisoning attacks.

6. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [23].

7. XMPP Registrar Considerations

7.1 Protocol Namespaces

Until this specification advances to a status of Draft, its associated namespace shall be "urn:xmpp:tmp:data-element"; upon advancement of this specification, the XMPP Registrar [24] shall issue a permanent namespace in accordance with the process defined in Section 4 of XMPP Registrar Function [25].

7.2 Service Discovery Features

If an entity is willing to accept data elements in file transfer requests for the purpose of previewing the file to be sent, it SHOULD advertise support for the "urn:xmpp:tmp:data-element:file-preview" feature.

The registry submission is as follows.

Registry Submission

<var>
  <name>urn:xmpp:tmp:data-element:file-preview</name>
  <desc>Signals a willingness to accept data elements for previewing file transfers</desc>
  <doc>XEP-0231</doc>
</var>
<var>
  <name>urn:xmpp:tmp:data-element:inband-image</name>
  <desc>Signals a willingness to accept data elements for in-band message images</desc>
  <doc>XEP-0231</doc>
</var>
    

8. XML Schema

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:tmp:data-element'
    xmlns='urn:xmpp:tmp:data-element'
    elementFormDefault='qualified'>

  <xs:element name='data'>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base='xs:base64Binary'>
          <xs:attribute name='alt' type='xs:string' use='optional'/>
          <xs:attribute name='cid' type='xs:string' use='optional'/>
          <xs:attribute name='max-age' type='xs:nonNegativeInteger' use='optional'/>
          <xs:attribute name='type' type='xs:string' use='required'/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

</xs:schema>
  

9. Acknowledgements

Thanks to Rachel Blackman, Dave Cridland, Pavel Šimerda, and Tomasz Sterna for their feedback.


Notes

1. XEP-0047: In-Band Bytestreams <http://www.xmpp.org/extensions/xep-0047.html>.

2. XEP-0096: SI File Transfer <http://www.xmpp.org/extensions/xep-0096.html>.

3. XEP-0234: Jingle File Transfer <http://www.xmpp.org/extensions/xep-0234.html>.

4. RFC 2397: The data: URL scheme <http://tools.ietf.org/html/rfc2397>.

5. RFC 4648: The Base16, Base32, and Base64 Data Encodings <http://tools.ietf.org/html/rfc4648>.

6. XEP-0065: SOCKS5 Bytestreams <http://www.xmpp.org/extensions/xep-0065.html>.

7. XEP-0047: In-Band Bytestreams <http://www.xmpp.org/extensions/xep-0047.html>.

8. RFC 2111: Content-ID and Message-ID Uniform Resource Locators <http://tools.ietf.org/html/rfc2111>.

9. RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace <http://tools.ietf.org/html/rfc4122>.

10. RFC 2965: HTTP State Management Mechanism <http://tools.ietf.org/html/rfc2965>.

11. RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies <http://tools.ietf.org/html/rfc2045>.

12. RFC 4281: The Codecs Parameter for "Bucket" Media Types <http://tools.ietf.org/html/rfc4281>.

13. IANA registry of MIME media types <http://www.iana.org/assignments/media-types>.

14. XEP-0071: XHTML-IM <http://www.xmpp.org/extensions/xep-0071.html>.

15. XEP-0030: Service Discovery <http://www.xmpp.org/extensions/xep-0030.html>.

16. XEP-0115: Entity Capabilities <http://www.xmpp.org/extensions/xep-0115.html>.

17. XEP-0221: Data Forms Media Element <http://www.xmpp.org/extensions/xep-0221.html>.

18. XEP-0004: Data Forms <http://www.xmpp.org/extensions/xep-0004.html>.

19. XEP-0158: CAPTCHA Forms <http://www.xmpp.org/extensions/xep-0158.html>.

20. XEP-0077: In-Band Registration <http://www.xmpp.org/extensions/xep-0077.html>.

21. See <http://www.xmpp.org/extensions/inbox/file-preview.html>.

22. XEP-0060: Publish-Subscribe <http://www.xmpp.org/extensions/xep-0060.html>.

23. 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/>.

24. 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/>.

25. XEP-0053: XMPP Registrar Function <http://www.xmpp.org/extensions/xep-0053.html>.


Revision History

Version 0.4 (2008-08-05)

Generalized text regarding inclusion of parameters in type attribute per RFC 2045; added max-age attribute, matching semantics from RFC 2965; added section on caching of data; more clearly specified generation of Content-ID.

(psa)

Version 0.3 (2008-06-18)

Allowed inclusion of codecs parameter in type attribute per RFC 4281.

(psa)

Version 0.2 (2008-05-29)

Added service discovery feature for in-band message images use case.

(psa)

Version 0.1 (2008-01-30)

Initial published version.

(psa)

Version 0.0.4 (2008-01-29)

Separately described service discovery feature for inclusion of the data element in file previews.

(psa)

Version 0.0.3 (2007-12-27)

Described use cases for previewing data to be exchanged in file transfers and for inclusion of media information in data forms.

(psa)

Version 0.0.2 (2007-12-18)

Changed syntax to not use data: URL scheme; added cid and type attributes; described use cases for messaging and data retrieval.

(psa)

Version 0.0.1 (2007-11-09)

First draft.

(psa)

END