XEP-0020: Feature Negotiation

Abstract
This specification defines an XMPP protocol extension that enables two entities to mutually negotiate feature options, such as parameters related to a file transfer or a communications session.
Authors
  • Peter Millard
  • Peter Saint-Andre
  • Ian Paterson
Copyright
© 1999 – 2020 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

Deprecated

WARNING: This document has been Deprecated by the XMPP Standards Foundation. Implementation of the protocol described herein is not recommended. Developers desiring similar functionality are advised to implement the protocol that supersedes this one (if any).
Type
Standards Track
Version
1.6 (2018-03-07)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Draft
  4. Final
  5. Deprecated
  6. Obsolete

1. Introduction

A discovery protocol such as Service Discovery (XEP-0030) [1] enables Jabber entities to query other entities regarding the features they support, but does not provide a means for the two entities to negotiate specific options related to the advertised features.

The protocol defined herein enables Jabber entities to negotiate options for specific features. These features could be negotiated between any two endpoints on the Jabber network, such as two clients, a client and a component, two components, a client and a server, or two servers. The protocol is generic enough that it can be used whenever options need to be negotiated between two Jabber entities. For examples, Stream Initiation (XEP-0095) [2], SI File Transfer (XEP-0096) [3] or Stanza Session Negotiation (XEP-0155) [4].

2. Protocol Details

Features are negotiated through the exchange of <iq/> or <message/> stanzas containing <feature/> child elements qualified by the 'http://jabber.org/protocol/feature-neg' namespace. However, this <feature/> element is simply a wrapper for structured data encapsulated in the Data Forms (XEP-0004) [5] protocol. [6]

In order to begin a negotation, the initiator sends an <iq/> stanza of type "get" (or a <message/> stanza type "normal" - see Stanza Session Negotiation for examples) to the recipient with a single <feature/> element containing a data form of type "form" which defines the available options for one or more features. Each feature is represented as an x-data "field".

The recipient SHOULD examine each feature and the values of the options provided. In order to indicate preferred values, the recipient then SHOULD specify one value for each feature and return a data form of type "submit" to the initiator in an <iq/> stanza of type "result" (or a <message/> stanza type "normal").

The following examples show some likely scenarios for feature negotiation between entities. Further examples can be found in "using protocols", such as File Transfer.

2.1 Basic Flow

A typical negotiation flow is shown in the following example of two entities negotiating the time and place for a meeting.

Example 1. Initiating entity sends offer
<iq type='set'
    from='romeo@montague.net/orchard'
    to='juliet@capulet.com/balcony'
    id='neg1'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='form'>
      <field var='FORM_TYPE' type='hidden'>
        <value>romantic_meetings</value>
      </field>
      <field type='list-single' var='places-to-meet'>
         <option><value>Secret Grotto</value></option>
         <option><value>Verona Park</value></option>
      </field>
      <field type='list-single' var='times-to-meet'>
         <option><value>22:00</value></option>
         <option><value>22:30</value></option>
         <option><value>23:00</value></option>
      </field>
    </x>
  </feature>
</iq>
Example 2. Responding entity sends preferred option values
<iq type='result'
    id='neg1'
    from='juliet@jabber.org/balcony'
    to='romeo@montague.net/orchard'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='FORM_TYPE'>
        <value>romantic_meetings</value>
      </field>
      <field var='places-to-meet'>
        <value>Secret Grotto</value>
      </field>
      <field var='times-to-meet'>
        <value>22:30</value>
      </field>
    </x>
  </feature>
</iq>

Note: If the responding entity does not want to reveal presence to the initiating entity for whatever reason then the responding entity's client SHOULD return a <service-unavailable/> error (or return no response or error whatsoever if the offer was wrapped in a <message/> stanza) - see Security Considerations.

If the responding entity does not support Feature Negotiation or does not support the specified FORM_TYPE, it SHOULD also return a <service-unavailable/> error:

Example 3. Responding entity does not support feature negotiation
<iq type='error'
    id='neg1'
    from='juliet@jabber.org/balcony'
    to='romeo@montague.net/orchard'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='form'>
      <field var='FORM_TYPE' type='hidden'>
        <value>romantic_meetings</value>
      </field>
      ...
    </x>
  </feature>
  <error type='cancel'>
    <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>

If the responding entity does not support one or more of the features, it SHOULD return a <feature-not-implemented/> error, and SHOULD specify the feature(s) not implemented in the XMPP <text/> element.

Example 4. Responding entity does not support a feature
<iq type='error'
    id='neg1'
    from='juliet@jabber.org/balcony'
    to='romeo@montague.net/orchard'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='form'>
      <field var='FORM_TYPE' type='hidden'>
        <value>romantic_meetings</value>
      </field>
      ...
    </x>
  </feature>
  <error type='cancel'>
    <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>times-to-meet</text>
  </error>
</iq>

If the responding entity supports none of the options offered for one or more of the features, it SHOULD return a <not-acceptable/> error, and SHOULD specify the relevant feature(s) in the XMPP <text/> element.

Example 5. Responding entity supports no options
<iq type='error'
    from='juliet@jabber.org/balcony'
    to='romeo@montague.net/orchard'
    id='neg1'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='form'>
      <field var='FORM_TYPE' type='hidden'>
        <value>romantic_meetings</value>
      </field>
      ...
    </x>
  </feature>
  <error type='modify'>
    <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>places-to-meet</text>
  </error>
</iq>

2.2 Querying for Negotiable Features

If at least one feature offered by an entity is subject to Feature Negotiation, the entity's response to a service discovery information request MUST include <feature var='http://jabber.org/protocol/feature-neg'/> as one of the features.

Example 6. Client queries a chatroom for supported features
<iq type='get'
    from='juliet@capulet.com/balcony'
    to='balconyscene@plays.shakespeare.lit'
    id='neg1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
Example 7. Chatroom returns supported features
<iq type='result'
    from='balconyscene@plays.shakespeare.lit'
    to='juliet@capulet.com/balcony'
    id='neg1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='http://jabber.org/protocol/feature-neg'/>
    <feature var='muc-password'/>
    ...
  </query>
</iq>

The "using protocol" (in these examples, Multi-User Chat (XEP-0045) [7]) SHOULD specify which features might be negotiable, either in the relevant documentation or in the entry for that feature in the service discovery features registry maintained by the XMPP Registrar [8]. However, the initiating entity MAY also query the responding entity in order to determine which features are negotiable, as shown below.

Example 8. Client queries chatroom regarding options for a negotiable feature
<iq type='get'
    from='juliet@capulet.com/balcony'
    to='balconyscene@plays.shakespeare.lit'
    id='neg2'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='muc-password'/>
    </x>
  </feature>
</iq>

If that feature is not negotiable, the responding entity SHOULD return a "Feature Not Implemented" error:

Example 9. Chatroom returns error
<iq type='result'
    from='balconyscene@plays.shakespeare.lit'
    to='juliet@capulet.com/balcony'
    id='neg2'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='muc-password'/>
    </x>
  </feature>
  <error type='cancel'>
    <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>

If that feature is negotiable, the responding entity SHOULD return an appropriate negotiation form:

Example 10. Chatroom returns negotiation form
<iq type='result'
    from='balconyscene@plays.shakespeare.lit'
    to='juliet@capulet.com/balcony'
    id='neg2'>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='result'>
      <field var='FORM_TYPE'>
        <value>MUC</value>
      </field>
      <field var='muc-password' type='list-single'>
        <option><value>cleartext</value></option>
        <option><value>SHA1</value></option>
        <option><value>SASL</value></option>
      </field>
    </x>
  </feature>
</iq>

The initiating entity MAY then submit a data form containing the required information.

3. Security Considerations

If the responding entity responds to the initiating entity or returns an error (other than a <service-unavailable/> response to an <iq/> request), the initiating entity will effectively discover the presence of the responding entity's resource. Due care must therefore be exercised in determining how to respond (or whether to respond at all to a <message/> request). For examples, the responding entity SHOULD NOT automatically (i.e. without first asking its human user) either respond to the initiating entity's request or return a specific error unless the initiating entity is subscribing to the responding entity's presence (and the responding entity's presence is not currently "invisible" to the initiating entity). Note: There should be no need for the responding entity's client to consult its block list, since if the initiating entity is on the list then the responding entity would not receive any requests from the initiating entity anyway.

4. IANA Considerations

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

5. XMPP Registrar Considerations

In order for Jabber entities to adequately leverage Data Forms (e.g., by using machine-readable fields), it is RECOMMENDED to register standard x-data fields with the XMPP Registrar via the mechanisms defined in Field Standardization for Data Forms (XEP-0068) [10]. Whether to do so for any given features and options shall be determined by the "using protocol".

6. XML Schema

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

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/feature-neg'
    xmlns='http://jabber.org/protocol/feature-neg'
    elementFormDefault='qualified'>

  <xs:import namespace='jabber:x:data'
             schemaLocation='http://xmpp.org/schemas/x-data.xsd'/>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0020: http://www.xmpp.org/extensions/xep-0020.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='feature'>
    <xs:complexType>
      <xs:sequence xmlns:data='jabber:x:data'>
        <xs:element ref='data:x'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>

7. Author Note

Peter Millard, the primary author of this specification from version 0.1 through version 1.4, died on April 26, 2006. The remaining authors are thankful for Peter's work on this specification.


Appendices

Appendix A: Document Information

Series
XEP
Number
0020
Publisher
XMPP Standards Foundation
Status
Deprecated
Type
Standards Track
Version
1.6
Last Updated
2018-03-07
Approving Body
XMPP Council
Dependencies
XMPP Core, XEP-0004
Supersedes
None
Superseded By
None
Short Name
feature-neg
Schema
<http://xmpp.org/schemas/feature-neg.xsd>
Source Control
HTML

This document in other formats: XML  PDF

Appendix B: Author Information

Peter Millard
See Author Note
Peter Saint-Andre
Email
xsf@stpeter.im
JabberID
peter@jabber.org
URI
http://stpeter.im/
Ian Paterson
Email
ian.paterson@clientside.co.uk
JabberID
ian@zoofy.com

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2020 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. ##

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 from, out of, or in connection with the Specification or the implementation, deployment, or other use of 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 can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) 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.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

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

Appendix F: Requirements Conformance

The following requirements 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".

Appendix G: Notes

1. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

2. XEP-0095: Stream Initiation <https://xmpp.org/extensions/xep-0095.html>.

3. XEP-0096: SI File Transfer <https://xmpp.org/extensions/xep-0096.html>.

4. XEP-0155: Stanza Session Negotiation <https://xmpp.org/extensions/xep-0155.html>.

5. XEP-0004: Data Forms <https://xmpp.org/extensions/xep-0004.html>.

6. Earlier versions of this document defined a structured data format to handle the feature negotiation workflow; versions later than 0.4 use Data Forms, i.e., the 'jabber:x:data' namespace.

7. XEP-0045: Multi-User Chat <https://xmpp.org/extensions/xep-0045.html>.

8. 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 <https://xmpp.org/registrar/>.

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

10. XEP-0068: Field Data Standardization for Data Forms <https://xmpp.org/extensions/xep-0068.html>.

Appendix H: Revision History

Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/

  1. Version 1.6 (2018-03-07)
    Deprecated as per Council vote on 2018-03-07.
    jwi (Editor)
  2. Version 1.5 (2006-11-21)
    Added FORM_TYPEs to examples; added service-unavailable error and Security Considerations; various other updates and corrections avoiding material changes.
    ip
  3. Version 1.4 (2004-05-21)
    Moved remaining feature negotiation text from XEP-0030 to this document.
    psa
  4. Version 1.3 (2004-04-23)
    Per Council discussion, changed root element from <query/> to <feature/> for the sake of consistency with using protocols; moved some text from XEP-0030 to this document.
    psa
  5. Version 1.2 (2004-03-08)
    Added XMPP error handling; clarified the text; corrected the examples; fixed an error in the schema; added numerous references.
    psa
  6. Version 1.1 (2003-02-16)
    Made corrections to the text; added security and IANA considerations; added schema.
    psa
  7. Version 1.0 (2002-12-06)
    Per a vote of the Jabber Council, revision 0.4 was advanced to Draft on 2002-12-06.
    psa
  8. Version 0.4 (2002-11-17)
    Changed protocol to use jabber:x:data.
    pgm
  9. Version 0.3 (2002-10-01)
    Added some extra text to help clarify protocol & purpose.
    pgm
  10. Version 0.2 (2002-05-22)
    Changed examples.
    pgm
  11. Version 0.1 (2002-02-26)
    Initial version.
    pgm

END