view Side-By-Side changes
Network Working Group P. Saint-Andre, Ed. Internet-Draft XMPP Standards Foundation Obsoletes: 3921 (if approved)June 6,July 12, 2008 Intended status: Standards Track Expires:December 8, 2008January 13, 2009 Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presencedraft-saintandre-rfc3921bis-05draft-saintandre-rfc3921bis-06 Status of this Memo By submitting this Internet-Draft, each author represents that any applicable patent or other IPR claims of which he or she is aware have been or will be disclosed, and any of which he or she becomes aware will be disclosed, in accordance with Section 6 of BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet- Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. This Internet-Draft will expire onDecember 8, 2008.January 13, 2009. Abstract This documentdescribesdefines extensions to core features of the Extensible Messaging and Presence Protocol (XMPP) that provide basic instant messaging (IM) and presence functionality in conformance with RFC 2779. This document obsoletes RFC 3921. Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page 1] Internet-Draft XMPP IMJuneJuly 2008 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . .56 1.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . .56 1.2. Requirements . . . . . . . . . . . . . . . . . . . . . . .56 1.3. Functional Summary . . . . . . . . . . . . . . . . . . . .68 1.4. Conventions . . . . . . . . . . . . . . . . . . . . . . .78 1.5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . 9 1.6. Discussion Venue . . . . . . . . . . . . . . . . . . . . .79 2. Managing the Roster . . . . . . . . . . . . . . . . . . . . .89 2.1. Syntax and Semantics . . . . . . . . . . . . . . . . . . .810 2.1.1. Roster Items . . . . . . . . . . . . . . . . . . . . . 10 2.1.1.1. Ask Attribute . . .8. . . . . . . . . . . . . . . 10 2.1.1.2. Jid Attribute . . . . . . . . . . . . . . . . . . 10 2.1.1.3. Name Attribute . . . . . . . . . . . . . . . . . . 10 2.1.1.4. Subscription Attribute . . . . . . . . . . . . . . 10 2.1.1.5. Group Element . . . . . . . . . . . . . . . . . . 11 2.1.2. Roster Get . . . . . . . . . . . . . . . . . . . . . .811 2.1.3. Roster Set . . . . . . . . . . . . . . . . . . . . . .911 2.1.4. Roster Push . . . . . . . . . . . . . . . . . . . . .912 2.1.5. Roster Result . . . . . . . . . . . . . . . . . . . .1013 2.1.6. Subscription Attribute . . . . . . . . . . . . . . . .1013 2.2. Retrieving the Roster on Login . . . . . . . . . . . . . .1114 2.3. Adding a Roster Item . . . . . . . . . . . . . . . . . . .1215 2.3.1. Request . . . . . . . . . . . . . . . . . . . . . . . 15 2.3.2. Success Case . . . . . . . . . . . . . . . . . . . . .12 2.3.2.16 2.3.3. Error Cases . . . . . . . . . . . . . . . . . . . . .1417 2.4. Updating a Roster Item . . . . . . . . . . . . . . . . . .1721 2.4.1. Request . . . . . . . . . . . . . . . . . . . . . . . 21 2.4.2. Success Case . . . . . . . . . . . . . . . . . . . . .17 2.4.2.23 2.4.3. Error Cases . . . . . . . . . . . . . . . . . . . . .1923 2.5. Deleting a Roster Item . . . . . . . . . . . . . . . . . .1923 2.5.1. Request . . . . . . . . . . . . . . . . . . . . . . . 23 2.5.2. Success Case . . . . . . . . . . . . . . . . . . . . .19 2.5.2.23 2.5.3. Error Cases . . . . . . . . . . . . . . . . . . . . .2024 3. Managing Presence Subscriptions . . . . . . . . . . . . . . .2024 3.1. Requesting a Subscription . . . . . . . . . . . . . . . .2125 3.1.1. Client Generation of Outbound Subscription Request . .2125 3.1.2. Server Processing of Outbound Subscription Request . .2226 3.1.3. Server Processing of Inbound Subscription Request . .2327 3.1.4. Client Processing of Inbound Subscription Request . .2429 3.1.5. Server Processing of Outbound Subscription Approval .2529 3.1.6. Server Processing of Inbound Subscription Approval . .2630 3.2. Cancelling a Subscription . . . . . . . . . . . . . . . .2732 3.2.1. Client Generation of Subscription Cancellation . . . .2732 3.2.2. Server Processing of Outbound Subscription Cancellation . . . . . . . . . . . . . . . . . . . . .2732 3.2.3. Server Processing of Inbound Subscription Saint-Andre Expires January 13, 2009 [Page 2] Internet-Draft XMPP IM July 2008 Cancellation . . . . . . . . . . . . . . . . . . . . .2833 3.3. Unsubscribing . . . . . . . . . . . . . . . . . . . . . .2934 3.3.1. Client Generation of Unsubscribe . . . . . . . . . . .2934 3.3.2. Server Processing of Outbound Unsubscribe . . . . . .2934 3.3.3. Server Processing of Inbound Unsubscribe . . . . . . .3035 4. Exchanging Presence Information . . . . . . . . . . . . . . .3136 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . .3136 4.2. Initial Presence . . . . . . . . . . . . . . . . . . . . .3137 4.2.1. Client Generation of Initial Presence . . . . . . . .31 Saint-Andre Expires December 8, 2008 [Page 2] Internet-Draft XMPP IM June 200837 4.2.2. Server Processing of Outbound Presence . . . . . . . .3238 4.2.3. Server Processing of Inbound Presence . . . . . . . .3338 4.2.4. Client Processing of Inbound Presence . . . . . . . .3339 4.3. Presence Probes . . . . . . . . . . . . . . . . . . . . .3339 4.3.1. Server Generation of Outbound Presence Probe . . . . .3439 4.3.2. Server Processing of Inbound Presence Probe . . . . .3440 4.4. Subsequent Presence Broadcast . . . . . . . . . . . . . .3541 4.4.1. Client Generation of Presence Broadcast . . . . . . .3541 4.4.2. Server Processing of Outbound Presence . . . . . . . .3641 4.4.3. Server Processing of Inbound Presence . . . . . . . .3743 4.4.4. Client Processing of Inbound Presence . . . . . . . .3743 4.5. Unavailable Presence . . . . . . . . . . . . . . . . . . .3743 4.5.1. Client Generation of Unavailable Presence . . . . . .3743 4.5.2. Server Processing of Outbound Unavailable Presence . .3844 4.5.3. Server Processing of Inbound Unavailable Presence . .3945 4.5.4. Client Processing of Inbound Unavailable Presence . .3946 4.6. Directed Presence . . . . . . . . . . . . . . . . . . . .4046 4.6.1. Client Generation of Directed Presence . . . . . . . .4046 4.6.2. Server Processing of Outbound Directed Presence . . .4047 4.6.3. Server Processing of Inbound Directed Presence . . . .4147 4.6.4. Client Processing of Inbound Directed Presence . . . .4147 4.7. Presence Syntax . . . . . . . . . . . . . . . . . . . . .4148 4.7.1. Type Attribute . . . . . . . . . . . . . . . . . . . .4148 4.7.2. Child Elements . . . . . . . . . . . . . . . . . . . .4249 4.7.3. Show Element . . . . . . . . . . . . . . . . . . . . .4249 4.7.4. Status Element . . . . . . . . . . . . . . . . . . . .4350 4.7.5. Priority Element . . . . . . . . . . . . . . . . . . .4451 4.7.6. Extended Content . . . . . . . . . . . . . . . . . . .4451 5. Exchanging Messages . . . . . . . . . . . . . . . . . . . . .4552 5.1.Attributes . . . . . .One-to-One Chat Sessions . . . . . . . . . . . . . . . . . 52 5.2. Message Syntax .45 5.1.1. To Attribute. . . . . . . . . . . . . . . . . . . . .45 5.1.2. Type53 5.2.1. To Attribute . . . . . . . . . . . . . . . . . . . .46 5.2. Child Elements .. 53 5.2.2. Type Attribute . . . . . . . . . . . . . . . . . . . .47 5.2.1.53 5.2.3. Body Element . . . . . . . . . . . . . . . . . . . . .. . . . 47 5.2.2.55 5.2.4. Subject Element . . . . . . . . . . . . . . . . . . .. . . . 48 5.2.3.55 5.2.5. Thread Element . . . . . . . . . . . . . . . . . . . .. . . . 4956 5.3. Extended Content . . . . . . . . . . . . . . . . . . . . .50 5.4. One-to-One Chat Sessions . . . . . . . . . . . . . . . . . 5157 6. Exchanging IQ Stanzas . . . . . . . . . . . . . . . . . . . .5158 7. A Sample Session . . . . . . . . . . . . . . . . . . . . . . .5258 Saint-Andre Expires January 13, 2009 [Page 3] Internet-Draft XMPP IM July 2008 8. Server Rules for Processing XML Stanzas . . . . . . . . . . .5966 8.1. No Such User . . . . . . . . . . . . . . . . . . . . . . .5966 8.2. Full JID at Local Domain . . . . . . . . . . . . . . . . .5966 8.2.1. Available Resource Matches . . . . . . . . . . . . . .5966 8.2.2. No Available Resource Matches . . . . . . . . . . . .6067 8.3. Bare JID at Local Domain . . . . . . . . . . . . . . . . .6067 8.3.1. Available Resources . . . . . . . . . . . . . . . . .6067 8.3.1.1. Message . . . . . . . . . . . . . . . . . . . . .60 Saint-Andre Expires December 8, 2008 [Page 3] Internet-Draft XMPP IM June 200867 8.3.1.2. Presence . . . . . . . . . . . . . . . . . . . . .6168 8.3.1.3. IQ . . . . . . . . . . . . . . . . . . . . . . . .6168 8.3.2. No Available Resources . . . . . . . . . . . . . . . .6169 8.3.2.1. Message . . . . . . . . . . . . . . . . . . . . .6269 8.3.2.2. Presence . . . . . . . . . . . . . . . . . . . . .6269 8.3.2.3. IQ . . . . . . . . . . . . . . . . . . . . . . . .6269 8.4.ForeignRemote Domain . . . . . . . . . . . . . . . . . . . . . .6370 9. IM and Presence Compliance Requirements . . . . . . . . . . .6471 9.1. Servers . . . . . . . . . . . . . . . . . . . . . . . . .6471 9.2. Clients . . . . . . . . . . . . . . . . . . . . . . . . .6471 10. Internationalization Considerations . . . . . . . . . . . . .6572 11. Security Considerations . . . . . . . . . . . . . . . . . . .6572 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . .6673 12.1. Instant Messaging SRV Protocol Label Registration . . . .6673 12.2. Presence SRV Protocol Label Registration . . . . . . . . .6673 13. References . . . . . . . . . . . . . . . . . . . . . . . . . .6774 13.1. Normative References . . . . . . . . . . . . . . . . . . .6774 13.2. Informative References . . . . . . . . . . . . . . . . . .6875 Appendix A. Subscription States . . . . . . . . . . . . . . . . .6976 A.1. Defined States . . . . . . . . . . . . . . . . . . . . . .6976 A.2. Server Processing of Outbound Presence Subscription Stanzas . . . . . . . . . . . . . . . . . . . . . . . . .7077 A.2.1. Subscribe . . . . . . . . . . . . . . . . . . . . . .7178 A.2.2. Unsubscribe . . . . . . . . . . . . . . . . . . . . .7178 A.2.3. Subscribed . . . . . . . . . . . . . . . . . . . . . .7279 A.2.4. Unsubscribed . . . . . . . . . . . . . . . . . . . . .7279 A.3. Server Processing of Inbound Presence Subscription Stanzas . . . . . . . . . . . . . . . . . . . . . . . . .7380 A.3.1. Subscribe . . . . . . . . . . . . . . . . . . . . . .7380 A.3.2. Unsubscribe . . . . . . . . . . . . . . . . . . . . .7380 A.3.3. Subscribed . . . . . . . . . . . . . . . . . . . . . .7481 A.3.4. Unsubscribed . . . . . . . . . . . . . . . . . . . . .7582 Appendix B. Blocking Communication . . . . . . . . . . . . . . .7683 Appendix C. vCards . . . . . . . . . . . . . . . . . . . . . . .7683 Appendix D. XML Schemas . . . . . . . . . . . . . . . . . . . . .7683 D.1. jabber:client . . . . . . . . . . . . . . . . . . . . . .7683 D.2. jabber:server . . . . . . . . . . . . . . . . . . . . . .8088 D.3. jabber:iq:roster . . . . . . . . . . . . . . . . . . . . .8592 Appendix E. Differences From RFC 3921 . . . . . . . . . . . . . .8693 Appendix F. Copying Conditions . . . . . . . . . . . . . . . . .8694 Saint-Andre Expires January 13, 2009 [Page 4] Internet-Draft XMPP IM July 2008 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8794 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . .8795 Intellectual Property and Copyright Statements . . . . . . . . . .8996 Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page4]5] Internet-Draft XMPP IMJuneJuly 2008 1. Introduction 1.1. Overview The Extensible Messaging and Presence Protocol (XMPP) is an application profile of the Extensible Markup Language [XML] for streaming XML data in close to real time between any two (or more) network-aware entities. XMPP is typically used to exchange messages, share presence information, and engage in structured request-response interactions. The core features of XMPP defined in [XMPP-CORE] provide the building blocks for many types of near-real-time applications, whichmaycan be layered on top of the core by sending application-specific data qualified by particular XML namespaces (refer to [XML-NAMES]). This documentdescribesdefines XMPP extensions that provide the basic functionality expected of an instant messaging (IM) and presence application as defined in [IMP-REQS].ThisAs a result of extensive implementation and deployment experience with XMPP since 2004, as well as more formal interoperability testing carried out under the auspices of the XMPP Standards Foundation (XSF), this documentobsoletesreflects consensus from the XMPP developer community regarding XMPP's basic instant messaging and presence features. In particular, this document incorporates the following backward-compatible changes from RFC 3921: o Incorporated corrections and errata o Added examples throughout o Clarified and more completely specified matters that were underspecified o Removed the protocol for session establishment, which was deemed unnecessary o Modified error handling related to presence stanzas to more seamlessly repair lack of synchronization in subscription states between rosters located at different servers o Added optional server support for pre-approved presence subscriptions o Added optional 'parent' attribute to <thread/> element o Transferred documentation for the communications blocking protocol from this specification to a separate specification Therefore, this document defines the basic instant messaging and presence features of XMPP 1.0, thus obsoleting RFC 3921. 1.2. Requirements Traditionally, instant messaging applications have combined the following factors: Saint-Andre Expires January 13, 2009 [Page 6] Internet-Draft XMPP IM July 2008 1. The central point of focus is a list of one's contacts or "buddies" (in XMPP this list is called a ROSTER). 2. The purpose of using such an application is to exchange relatively brief text messages witheach of one'sparticular contacts in close to real time -- often relatively large numbers of such messages in rapid succession, in the form of a one-to-onechat sessionsCHAT SESSION as described under Section5.4.5.1. 3. The catalyst for exchanging messages is PRESENCE -- i.e., information about the network availability ofeach of one'sparticular contacts (thus knowing who is online and available for aone-to- oneone-to-one chat session). 4. Presence information is provided only to contacts thata userone has authorizedviaby means of an explicit agreement called apresence subscription.PRESENCE SUBSCRIPTION. Thus at a high level this document assumes that a user must be able to complete the following use cases: o Manage items in one's contact list o Exchange messages with one's contacts o Exchange presence information with one's contacts o Manage presence subscriptions to and from one's contacts Detailed definitions of these functionality areas are contained in RFC 2779 [IMP-REQS], and the interested reader is referred to thatSaint-Andre Expires December 8, 2008 [Page 5] Internet-Draft XMPP IM June 2008document regarding the requirements addressed herein. While the XMPP instant messaging and presence extensions specified herein meet the requirements of RFC 2779, they were not designed explicitly with that specification in mind, since the base protocol evolved through an open development process within the Jabber open-source community before RFC 2779 was written. Although XMPP protocol extensions addressing many other functionality areas have been defined in the XMPP Standards Foundation's XEP series (e.g., multi-user text chat as specified in [XEP-0045]), such extensions are not specified in this document because they are notrequiredmandated by RFC 2779. Note: RFC 2779 stipulates that presence services must be separable from instant messaging services and vice-versa; i.e., it must be possible to use the protocol to provide a presence service, an instant messaging service, or both. Although the text of this document assumes that implementations and deployments will want to offer a unified instant messaging and presence service, there is no requirement that a service must offer both a presence service and an instant messaging service, and the protocol makes it possible to offer separate and distinct services for presence and for instant messaging. (For example, a presence-only service could return a <service-unavailable/> stanza error if a client attempt to send a <message/>stanzas.)stanza.) Saint-Andre Expires January 13, 2009 [Page 7] Internet-Draft XMPP IM July 2008 1.3. Functional Summary This non-normative section provides a developer-friendly, functional summary of XMPP-based instant messaging and presence features;refer toconsult the sections that follow for a normative definition of these features. [XMPP-CORE] specifies how an XMPP client connects to an XMPP server. In particular, it specifies the preconditions that must be fulfilled before a client is allowed to send XML stanzas (the basic unit of meaning in XMPP) to other entities on an XMPP network. These preconditions comprise negotiation of the XML stream and include XML stream establishment, optional channel encryption via Transport Layer Security [TLS], mandatory authentication via Simple Authentication and Security Layer [SASL], and binding of a resource to the stream for client addressing. The reader is referred to [XMPP-CORE] for details regarding these preconditions, and knowledge of [XMPP-CORE] is assumed herein. Upon fulfillment of the preconditions specified in [XMPP-CORE], an XMPP client has a long-lived XML stream with an XMPP server, which enables the user controlling that client to send and receive a potentially unlimited number of XML stanzas over the stream. Such a stream can be used to exchange messages, share presence information, and engage inSaint-Andre Expires December 8, 2008 [Page 6] Internet-Draft XMPP IM June 2008structured request-response interactions in close to real time. After negotiation of the XML stream, the typical flow for an instant messaging and presence session is as follows: 1. Retrieve one's roster. (See Section 2.2.) 2. Send initial presence to the server for broadcasting to all subscribed contacts, thus "going online" from the perspective of XMPPcommunications.communication. (See Section 4.2.) 3. Exchange messages, manage presence subscriptions, perform roster updates, and in general process and generate other XML stanzas with particular semantics throughout the life of the session. (See Section 5, Section 3, Section 2, and Section 6.) 4. Terminate the session when desired by sending unavailable presence and closing the underlying XML stream. (See Section 4.5.) 1.4. Conventions This document inherits the terminology defined in [XMPP-CORE]. The following keywords are to be interpreted as described in [TERMS]: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL". Saint-Andre Expires January 13, 2009 [Page 8] Internet-Draft XMPP IM July 2008 For convenience, this document employs the term "user" to refer to the owner of an XMPP account; however, account owners need not be human persons andmaycan be bots, devices, or other non-human applications.In examples, lines have been wrappedFollowing the "XML Notation" used in [IRI] to represent characters that cannot be rendered in ASCII-only documents, some examples in this document use the form "&#x...." as a notational device to represent Unicode characters (e.g., the string "ř" stands for the Unicode character LATIN SMALL LETTER R WITH CARON). In examples, lines have been wrapped for improved readability, "[...]" means elision, and the following prepended strings areused:used (these prepended strings are not to be sent over the wire): o C: = client o CC: = contact's client o CS: = contact's server o S: = server o UC: = user's client o US: = user's server 1.5. Acknowledgements The editor of this document finds it impossible to appropriately acknowledge the many individuals who have provided comments regarding the protocols defined herein. However, thanks are due to those who have who have provided implementation feedback, bug reports, requests for clarification, and suggestions for improvement since the publication of the RFC this document supersedes. The editor has endeavored to address all such feedback, but is solely responsible for any remaining errors and ambiguities. 1.6. Discussion Venue The document editorwelcomesand the broader XMPP developer community welcome discussion and comments related to the topics presented in this document. The preferred forum is the <standards@xmpp.org> mailing list, for which archives and subscription information are available at<<http://mail.jabber.org/mailman/listinfo/standards>>. Saint-Andre Expires December 8, 2008 [Page 7] Internet-Draft XMPP IM June 2008<http://mail.jabber.org/mailman/listinfo/standards>. 2. Managing the Roster In XMPP, one's roster contains any number of specific contacts. A user's roster is stored by the user's server on the user's behalf so that the usermaycan access roster information from any resource. Saint-Andre Expires January 13, 2009 [Page 9] Internet-Draft XMPP IM July 2008 2.1. Syntax and Semantics Rosters are managed using IQ stanzas, specifically by means of a <query/> child element qualified by the 'jabber:iq:roster' namespace. The detailed syntax and semantics are defined in the following sections. 2.1.1. Roster Items The <query/> element MAY contain one or more <item/> children, each describing a uniqueroster itemROSTER ITEM or "contact". The syntax of the <item/> element isas follows: 1.described in the following sections. 2.1.1.1. Ask Attribute The'jid''ask' attribute isREQUIRED; the valueused to specify certain subscription sub- states; for details, see Section 3.1.2. Inclusion ofthisthe 'ask' attribute is OPTIONAL. 2.1.1.2. Jid Attribute The 'jid' attribute specifies the Jabber Identifier (JID) that uniquely identifies the roster item.2. The 'name'Inclusion of the 'jid' attribute isOPTIONAL; the value of thisREQUIRED. 2.1.1.3. Name Attribute The 'name' attribute specifies the "handle" to be associated with the JID, as determined by the user (not the contact).WhileAlthough the value of the 'name' attributemayMAY have meaning to a human user,typicallyit is opaque to theserver (although itserver. However, the 'name' attribute MAY be used by the server for matching purposes within the context of various XMPPextensions). 3.extensions, in which case the values MUST be compared only after application of the Resourceprep profile of stringprep as defined in [XMPP-CORE]. Inclusion of the 'name' attribute is OPTIONAL. 2.1.1.4. Subscription Attribute The 'subscription' attribute is OPTIONAL; see Section 2.1.6.4. The 'ask'Inclusion of the 'subscription' attribute isOPTIONAL and is used to specify certain subscription sub-states; for details, see Section 3.1.2. 5. The <group/> element is OPTIONAL; the XML character data of thisOPTIONAL. Saint-Andre Expires January 13, 2009 [Page 10] Internet-Draft XMPP IM July 2008 2.1.1.5. Group Element The <group/> child element specifies a category or "bucket" into which the roster itemshouldis to be grouped by a client.TheAn <item/> element MAY contain more than one <group/>element. Theelement, so that roster groups are not exclusive. Although the XML character data of the <group/> elementis typically opaque to the server but mayMAY have meaning to a humanuser.user, it is opaque to the server. However, the <group/> element MAY be used by the server for matching purposes within the context of various XMPP extensions, in which case the data MUST be compared only after application of the Resourceprep profile of stringprep as defined in [XMPP-CORE]. Inclusion of the <group/> child element is OPTIONAL. 2.1.2. Roster Get A ROSTER GET is a client's request for the server to send the roster; syntactically it is an IQ stanza of type "get" sent from client to server and containing a <query/> element qualified by the'jabber:iq:roster' namespace. The'jabber:iq: roster' namespace, where the <query/> elementin a roster getMUST NOT contain any <item/> child elements.Saint-Andre Expires December 8, 2008 [Page 8] Internet-Draft XMPP IM June 2008C: <iq from='juliet@example.com/balcony'type='get' id='roster_get'>id='rg1' type='get'> <query xmlns='jabber:iq:roster'/> </iq> The expected outcome of sending a roster get is for the server to return a roster result. 2.1.3. Roster Set A ROSTER SET is a client's request for the server to modify (i.e., create, update, or delete) a roster item; syntactically it is an IQ stanza of type "set" sent from client to server and containing a <query/> element qualified by the 'jabber:iq:roster' namespace. The following rules apply to roster sets: 1. The <query/> element MUST contain one and only one <item/> element. 2.A receivingThe server MUST ignore any value of the 'subscription' attribute other than "remove" (see Section 2.1.6). 3.A receivingThe server MUST ignore any 'to' address specified on the IQ stanza and MUST handle the IQ stanza as if it included no 'to' attribute. Saint-Andre Expires January 13, 2009 [Page 11] Internet-Draft XMPP IM July 2008 C: <iq from='juliet@example.com/balcony'type='set' id='roster_set'>id='rs1' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com'/> </query> </iq> 2.1.4. Roster Push A ROSTER PUSH is a newly created, updated, or deleted roster item that is sent from the server to the client; syntactically it is an IQ stanza of type "set" sent from server to client and containing a <query/> element qualified by the'jabber:iq: roster''jabber:iq:roster' namespace. The following rules apply to roster pushes: 1. The <query/> element in a roster push MUST contain one and only one <item/> element. 2. A receiving client MUST ignore the stanza unless it has no 'from' attribute (i.e., implicitly from theserver)user's bare JID) or it has a 'from' attribute whose value matches the user's bare JID <user@domain>.Saint-Andre Expires December 8, 2008 [Page 9] Internet-Draft XMPP IM June 2008S: <iq id='a78b4q6ha463' to='juliet@example.com/chamber'type='set' id='roster_push'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com'/> </query> </iq>2.1.5. Roster Result A ROSTER RESULT isAs mandated by the semantics of the IQ stanza as defined in [XMPP-CORE], each resource that receives a roster push MUST reply with an IQ stanza of type "result"sent from server to client and containing a <query/> element qualified by the 'jabber:iq: roster' namespace.(or "error"). C: <iq from='juliet@example.com/balcony' id='a78b4q6ha463' type='result'/> C: <iq from='juliet@example.com/chamber' id='a78b4q6ha463' type='result'/> Note: There is no error case for client processing of roster pushes; if the server receives an IQ of type "error" in response to a roster push it SHOULD ignore the error. Saint-Andre Expires January 13, 2009 [Page 12] Internet-Draft XMPP IM July 2008 2.1.5. Roster Result A ROSTER RESULT is the server's response to a roster get; syntactically it is an IQ stanza of type "result" sent from server to client and containing a <query/> element qualified by the 'jabber:iq: roster' namespace. The <query/> element in a roster result contains one <item/> element for each contact and thereforeMAYcan contain more than one <item/> element. S: <iq id='rg1' to='juliet@example.com/chamber'type='result' id='roster_result'>type='result'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com'/> <item jid='romeo@example.net'/> </query> </iq> If there are no contacts in the roster, the <query/> element MUST be empty. S: <iq to='juliet@example.com/chamber'type='result' id='roster_result'>id='roster_result' type='result'> <query xmlns='jabber:iq:roster'/> </iq> 2.1.6. Subscription Attribute The state of the presence subscription in relation to a roster item is captured in the 'subscription' attribute of the <item/> element. Allowable subscription-related values for this attribute are: o "none" -- the user does not have a subscription to the contact's presence, and the contact does not have a subscription to the user's presence o "to" -- the user has a subscription to the contact's presence, but the contact does not have a subscription to the user's presenceSaint-Andre Expires December 8, 2008 [Page 10] Internet-Draft XMPP IM June 2008o "from" -- the contact has a subscription to the user's presence, but the user does not have a subscription to the contact's presence o "both" -- both the user and the contact have subscriptions to each other's presence (also called a "mutual subscription") In a roster result,a receivingthe client MUST ignore values of the 'subscription' attribute other than "none", "to", "from", or "both". Saint-Andre Expires January 13, 2009 [Page 13] Internet-Draft XMPP IM July 2008 In a roster push,a receivingthe client MUST ignore values of the 'subscription' attribute other than "none", "to", "from", "both", or "remove". In a roster set, the value of the 'subscription' attribute MAY be included with a value of "remove", which indicates that the item is to be removed from the roster;a receivingthe server MUST ignore all values of the 'subscription' attribute other than "remove". 2.2. Retrieving the Roster on Login Upon authenticating with a server and binding a resource (thus becoming a connected resource), a client SHOULD request the roster before sending initial presence (however, because receiving the rostermayis notbenecessarily desirable for all resources, e.g., a connection with limited bandwidth, the client's request for the roster isrecommended andnotrequired).mandatory). After a connected resource sends initial presence (see Section 4.2), it is referred to as an available resource. If a connected resource or available resource requests theroster but does not send initial presence, theroster, it is referred to as an INTERESTED RESOURCE. The server MUSTNOTsendit presenceroster pushes to all interested resources. Note: Presence subscription requestsand SHOULD NOT send it associated roster pushes. If anare sent to availableresource does not requestresources, whereas the rosterduring a session, the server SHOULD NOT send it presence subscription requests and MUST NOT send itpushes associatedroster pushes. Therefore,with subscription state changes are sent to interested resources. Therefore if aclientresource wishes toengage in the full range of interactions related to contact lists (rosters)receive both subscription requests andpresence subscriptions,roster pushes, itSHOULDMUST bothrequest the roster andsend initialpresence. For the sake of brevity, the term INTERESTED RESOURCE is used herein to refer to the concept of "an available resource that has requestedpresence and request theroster".roster. A client requests the roster by sending a roster get over its stream to the server. C: <iq from='juliet@example.com/balcony'type='get' id='roster_1'>id='roster_1' type='get'> <query xmlns='jabber:iq:roster'/> </iq> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page11]14] Internet-Draft XMPP IMJuneJuly 2008 S: <iq id='roster_1' to='juliet@example.com/balcony'type='result' id='roster_1'>type='result'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' name='Romeo' subscription='both'> <group>Friends</group> </item> <itemjid='mercutio@example.org'jid='mercutio@example.com' name='Mercutio' subscription='from'/> <itemjid='nurse@example.com' name='Nurse' subscription='to'/> <item jid='benvolio@example.org'jid='benvolio@example.net' name='Benvolio' subscription='both'/> </query> </iq> If the server cannot process the roster get, it MUST return an appropriate stanza error as described in [XMPP-CORE] (such as <service-unavailable/> if the roster namespace is not supported or <internal-server-error/> if the server experiences trouble processing or returning the roster). 2.3. Adding a Roster Item 2.3.1.Success CaseRequest At any time, a clientmaycan add an item to therosterroster. This is done by sending a roster setto the server. Note: When the item added represents another IM user, the value of the 'jid' attribute MUST be a bare JID <contact@domain> rathercontaining afull JID <contact@domain/resource>, since the desired result is for the user to receive presence from all of the contact's resources, not merely the particular resource specified in the 'to' attribute.new item. C: <iq from='juliet@example.com/balcony'type='set' id='roster_2'>id='roster_2' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='Nurse'> <group>Servants</group> </item> </query> </iq> Note: When a user adds a contact for the purpose of tracking the user's presence subscription to a contact, the user's client MUST send a presence subscription request to the contact before generating any roster set related to the contact. This enables the user's server to enforce any policies relevant to presence subscriptions (e.g., a prohibition on presence subscriptions to Saint-Andre Expires January 13, 2009 [Page 15] Internet-Draft XMPP IM July 2008 full JIDs). For details, see Section 3. 2.3.2. Success Case If the server can successfully process the roster set (i.e., if noneSaint-Andre Expires December 8, 2008 [Page 12] Internet-Draft XMPP IM June 2008of the error cases occurs), it MUST create the roster item in persistentstorage andstorage. The server MUST then return an IQ stanza of type "result" to the connected resource that sent the roster set. S: <iq id='roster_2' to='juliet@example.com/balcony' type='result'/> The server MUST also send a roster push containing the new roster item to all of the user's interestedresources.resources, including the resource that generated the roster set. S: <iq to='juliet@example.com/balcony'type='set' id='a78b4q6ha463'>id='a78b4q6ha463' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='Nurse' subscription='none'> <group>Servants</group> </item> </query> </iq> S: <iq to='juliet@example.com/chamber'type='set' id='a78b4q6ha464'>id='a78b4q6ha464' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='Nurse' subscription='none'> <group>Servants</group> </item> </query> </iq>The server MUST also return an IQ stanza of type "result" to the connected resource that sent the roster set. S: <iq to='juliet@example.com/balcony' type='result' id='roster_2'/>Asrequiredmandated by the semantics of the IQ stanza as defined in [XMPP-CORE], each resource thatreceived thereceives a roster push MUST reply with an IQ stanza of type "result" (or "error"). Saint-Andre Expires January 13, 2009 [Page 16] Internet-Draft XMPP IM July 2008 C: <iq from='juliet@example.com/balcony'type='result' id='a78b4q6ha463'/>id='a78b4q6ha463' type='result'/> C: <iq from='juliet@example.com/chamber'type='result' id='a78b4q6ha464'/> Note: There is no error case for client replies to roster pushes, and if the server receives an IQ of type "error" in response to a roster push it SHOULD ignore the error. Saint-Andre Expires December 8, 2008 [Page 13] Internet-Draft XMPP IM June 2008 2.3.2.id='a78b4q6ha464' type='result'/> 2.3.3. Error Cases If the server cannot successfully process the roster set, it MUST returnana stanza error. The following error cases are defined (naturally, other stanza errorsmaycan occur,e.g., <internal-server-error/>).such as <internal-server- error/>). The server SHOULD return a <bad-request/> stanza error to the client if the roster set violates any of the following conditions: 1. The <query/> element contains more than one <item/> child element. 2. The <item/> element contains more than one <group/> element, but there are duplicate groups (where duplicates are determined using the Resourceprep profile of stringprep as defined in [XMPP-CORE]). The server SHOULD return a <not-acceptable/> stanza error to the client if the roster set violates any of the following conditions: 1. The value of the 'name' attribute is greater than a server- configured limit. 2. The XML character data of the <group/> element is of zero length. 3. The XML character data of the <group/> element is greater than a server-configured limit. Alternatively, the server MAY ignore the foregoing violations and process the roster set as best as possible (e.g., process only the first <item/> element, ignore duplicate <group/> elements, place the roster item in no group or a default group if the <group/> element is empty, and truncate 'name' attributes and <group/> elements that are too long). Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page14]17] Internet-Draft XMPP IMJuneJuly 2008 Error: Roster set contains more than one item C: <iq from='juliet@example.com/balcony'type='set' id='roster_3'>id='roster_3' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='Nurse'> <group>Servants</group> </item> <item jid='mother@example.com' name='Mom'> <group>Family</group> </item> </query> </iq> S: <iq id='roster_3' to='juliet@example.com/balcony'type='error' id='roster_3'>type='error'> <error type='modify'> <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> Error: Roster set contains item with oversized handle C: <iq from='juliet@example.com/balcony'type='set' id='roster_4'>id='roster_4' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='[ ... some-very-long-handle ... ]'> <group>Servants</group> </item> </query> </iq> S: <iq id='roster_4' to='juliet@example.com/balcony'type='error' id='roster_4'>type='error'> <error type='modify'> <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page15]18] Internet-Draft XMPP IMJuneJuly 2008 Error: Roster set contains duplicate groups C: <iq from='juliet@example.com/balcony'type='set' id='roster_5'>id='roster_5' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='Nurse'> <group>Servants</group> <group>Servants</group> </item> </query> </iq> S: <iq id='roster_5' to='juliet@example.com/balcony'type='error' id='roster_5'>type='error'> <error type='modify'> <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> Error: Roster set contains empty group C: <iq from='juliet@example.com/balcony'type='set' id='roster_6'>id='roster_6' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='Nurse'> <group></group> </item> </query> </iq> S: <iq id='roster_6' to='juliet@example.com/balcony'type='error' id='roster_6'>type='error'> <error type='modify'> <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page16]19] Internet-Draft XMPP IMJuneJuly 2008 Error: Roster set contains oversized group C: <iq from='juliet@example.com/balcony'type='set' id='roster_7'>id='roster_7' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' name='Nurse'> <group>[ ... some-very-long-group-name ... ]</group> </item> </query> </iq> S: <iq id='roster_7' to='juliet@example.com/balcony'type='error' id='roster_7'>type='error'> <error type='modify'> <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> The server MUST return a <not-allowed/> stanza error to the client if the value of the <item/> element's 'jid' attribute matches the bare JID <node@domain> portion of the <iq/> element's 'from' attribute (i.e., a JIDmust notMUST NOT be allowed to add itself to its own roster). Error: Roster set contains sender's JID C: <iq from='juliet@example.com/balcony'type='set' id='roster_8'>id='roster_8' type='set'> <query xmlns='jabber:iq:roster'> <item jid='juliet@example.com'/> </query> </iq> S: <iq id='roster_8' to='juliet@example.com/balcony'type='error' id='roster_8'>type='error'> <error type='cancel'> <not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> Saint-Andre Expires January 13, 2009 [Page 20] Internet-Draft XMPP IM July 2008 2.4. Updating a Roster Item 2.4.1.Success CaseRequest Updating an existing roster item is done in the same way as adding a new roster item, i.e., by sending a roster set to the server. Because a roster item is atomic, the itemshallMUST be updated exactly as provided in the roster set. There are several reasons why a client might update a roster item:Saint-Andre Expires December 8, 2008 [Page 17] Internet-Draft XMPP IM June 20081. Adding a group 2. Deleting a group 3. Changing the handle 4. Deleting the handle Consider a roster item that is defined as follows: <item jid='romeo@example.net' name='Romeo'> <group>Friends</group> </item> The user who has this item in her rostermaymight want to add the item to another group. C: <iqfrom='juliet@example.com/chamber' type='set' id='update_1'>from='juliet@example.com/balcony' id='update_1' type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' name='Romeo'> <group>Friends</group> <group>Lovers</group> </item> </query> </iq> The usermaymight then want to remove the item from the original group. Saint-Andre Expires January 13, 2009 [Page 21] Internet-Draft XMPP IM July 2008 C: <iqfrom='juliet@example.com/chamber' type='set' id='update_2'>from='juliet@example.com/balcony' id='update_2' type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' name='Romeo'> <group>Lovers</group> </item> </query> </iq> The usermaymight then want to change the handle for the item. C: <iqfrom='juliet@example.com/chamber' type='set' id='update_3'>from='juliet@example.com/balcony' id='update_3' type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' name='MyRomeo'> <group>Lovers</group> </item> </query> </iq> The usermaymight then want to remove the handle altogether (note:Saint-Andre Expires December 8, 2008 [Page 18] Internet-Draft XMPP IM June 2008including an empty 'name' attribute is equivalent to including no 'name' attribute). C: <iqfrom='juliet@example.com/chamber' type='set' id='update_4'>from='juliet@example.com/balcony' id='update_4' type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' name=''> <group>Lovers</group> </item> </query> </iq> The usermaymight then want to remove the item from all groups. C: <iqfrom='juliet@example.com/chamber' type='set' id='update_5'>from='juliet@example.com/balcony' id='update_5' type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net'/> </query> </iq> Saint-Andre Expires January 13, 2009 [Page 22] Internet-Draft XMPP IM July 2008 2.4.2. Success Case As with adding a roster item,when updating aif the roster item can be successfully processed then the server MUST update the roster information in persistent storage, send a roster push to all of the user's interested resources, and send an IQ result to the initiating resource; for details, see Section 2.3.2.4.2.2.4.3. Error Cases The error cases described under Section2.3.22.3.3 also apply to updating a roster item. 2.5. Deleting a Roster Item 2.5.1.Success CaseRequest At any time, a clientmaycan delete an item from his or her roster by sending a roster set and specifying the value of the 'subscription' attribute to be "remove". C: <iq from='juliet@example.com/balcony'type='set' id='delete_1'>id='delete_1' type='set'> <query xmlns='jabber:iq:roster'> <item jid='nurse@example.com' subscription='remove'/> </query> </iq> 2.5.2. Success Case As with adding a roster item, if the server can successfully process the roster set then it MUST update the roster information in persistent storage, send a roster push to all of the user's interested resources (with the 'subscription' attribute set to aSaint-Andre Expires December 8, 2008 [Page 19] Internet-Draft XMPP IM June 2008value of "remove"), and send an IQ result to the initiating resource; for details, see Section 2.3.TheIf the user has a presence subscription to the contact or the contact has a presence subscription to the user, the user's server MUST also generate a presence stanza of type "unsubscribe"and(to unsubscribe from the contact's presence) or a presence stanza of type "unsubscribed"from(to cancel theusercontact's subscription to thecontact.user), or both. Saint-Andre Expires January 13, 2009 [Page 23] Internet-Draft XMPP IM July 2008 S: <presence from='juliet@example.com' to='nurse@example.com' type='unsubscribe'/> S: <presence from='juliet@example.com' to='nurse@example.com' type='unsubscribed'/>2.5.2.2.5.3. Error Cases If the value of the 'jid' attribute specifies an item that is not in the roster, the server MUST return an <item-not-found/> stanza error. Error: Roster item not found C: <iq from='juliet@example.com/balcony'type='set' id='delete_2'>id='delete_2' type='set'> <query xmlns='jabber:iq:roster'> <item jid='[ ... non-existent-jid ... ]' subscription='remove'/> </query> </iq> S: <iq id='delete_2' to='juliet@example.com/balcony'type='error' id='delete_2'>type='error'> <error type='modify'> <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </iq> 3. Managing Presence Subscriptions In order to protect the privacy of instant messaging users, presence information is disclosed only to other entities thatthea user has approved. When a user has agreed that another entitymayis allowed to view its presence, the entity is said to have a SUBSCRIPTION to the user's presence. An entity that has a subscription to a user's presence or to which a user has a presence subscription is called a CONTACT (in this document the term "contact" is also used in a less strict sense to refer to a potential contact or an item in a user's roster).Saint-Andre Expires December 8, 2008 [Page 20] Internet-Draft XMPP IM June 2008In XMPP, a subscription lasts across presence sessions; indeed, it lasts until the contact unsubscribes or the user cancels the previously-granted subscription. Saint-Andre Expires January 13, 2009 [Page 24] Internet-Draft XMPP IM July 2008 Subscriptions are managed within XMPP by sending presence stanzas containing specially-defined attributes ("subscribe", "unsubscribe", "subscribed", and "unsubscribed").Subscription states are reflected in the rosters of both the user and the contact. Complete details regarding these subscription states can be found Appendix A; those details are not provided in this section, which simply narrates the protocol flows for common use cases related to presence subscriptions.Note: When a server processes or generates an outbound presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST stamp the outgoing presence stanza with the bare JID <node@domain> of the sending entity, not the full JID <node@domain/resource>.ThisEnforcement of this rule simplifies the presence subscription model and helps to prevent presence leaks; fordetails, seeinformation about presence leaks, refer to the security considerations of [XMPP-CORE]. Subscription states are reflected in the rosters of both the user and the contact. Complete details regarding these subscription states can be found Appendix A; those details are not provided in this section, which simply narrates the protocol flows for common use cases related to presence subscriptions. 3.1. Requesting a Subscription A SUBSCRIPTION REQUEST is a request from a user for authorization to permanently subscribe to a contact's presence information; syntactically it is a presence stanza whose 'type' attribute has a value of "subscribe". A subscription request is generated by a user's client, processed by the (potential) contact's server, and acted on by the contact via the contact's client. The workflow is described in the following sections. Note: Presence subscription requests are sent to available resources, whereas the roster pushes associated with subscription state changes are sent to interested resources. Therefore if a resource wishes to receive both subscription requests and roster pushes, it MUST both send initial presence and request the roster. 3.1.1. Client Generation of Outbound Subscription Request A user's client generates a subscription request by sending a presence stanza of type "subscribe" and specifying a 'to' address of the potential contact's bare JID <contact@domain>. UC: <presence to='juliet@example.com' type='subscribe'/>A user's client SHOULD NOT sendWhen a user sends a presence subscription request to a potential instant messaging and presence contact, the value of the 'to' attribute MUST be a bare JID <contact@domain> rather a full JID<contact@domain/resource>. Typically the user's client prompts<contact@domain/resource>, since theuserdesired result is forinformation aboutthepotential contact ("handle" and desired roster group) and generates a roster set with that information before sendinguser to receive presence from all of thesubscription request, but that behavior is recommended rather than required.contact's resources, not merely Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page21]25] Internet-Draft XMPP IMJuneJuly 2008 the particular resource specified in the 'to' attribute. Use of bare JIDs also simplifies subscription processing, presence probes, and presence notifications by the user's server and the contact's server. Although many XMPP clients prompt the user for information about the potential contact (e.g., "handle" and desired roster group) when generating an outbound presence subscription request, the client MUST NOT send a roster set before sending the presence subscription request, but instead MUST wait until receiving the initial roster push from the server. This enables the user's server to enforce any policies relevant to presence subscriptions (e.g., a prohibition on presence subscriptions to full JIDs). 3.1.2. Server Processing of Outbound Subscription RequestAs mentioned,Upon receiving the outbound presence subscription request, the user's server MUSTstampproceed as follows. 1. Before processing theoutbound subscription request withrequest, thebare JID <user@domain>user's server SHOULD check the syntax of theuser. US: <presence from='romeo@example.net' to='juliet@example.com' type='subscribe'/> Note:JID contained in the 'to' attribute. If thesubscription request is directed to a fullJID is of the form <contact@domain/resource> instead ofa bare JID<contact@domain>, the user's serverMAYSHOULD treat it as if the request had been directed to the contact's bare JID and modify the 'to' address accordingly.This simplifies processing of presence subscriptions.The server MAY also verify that the JID adheres to the format defined in [XMPP-CORE], including checking against the relevant stringprep profiles. 2. If the potential contact is hosted on the sameserver,server as the user, the server MUST adhere to the rules specified in the next section in processing the subscription request and delivering it to the (local) contact. 3. If the potential contact is hosted on adifferentremote server, subject to local service policies the user's server MUST thenroutesroute the stanza to thatforeignremote domain in accordance with core XMPP stanza processing rules.The user's server MUST then send a roster push(This can result in returning an appropriate stanza error toall ofthe user, such as <remote-server-timeout/>.) As mentioned, before locally delivering or remotely routing the presence subscription request, the user'sinterested resources, containingserver MUST stamp thepotential contact with aoutbound subscriptionstate of "none" andrequest withnotation thatthesubscriptionbare JID <user@domain> of the user. US: <presence from='romeo@example.net' to='juliet@example.com' type='subscribe'/> After locally delivering or remotely routing the presence subscription request, the user's server MUST then send a roster push to all of the user's interested resources, containing the potential Saint-Andre Expires January 13, 2009 [Page 26] Internet-Draft XMPP IM July 2008 contact with a subscription state of "none" and with notation that the subscription is pending (via an 'ask' attribute whose value is "subscribe"). US: <iq id='b89c5r7ib574' to='romeo@example.net/foo'type='set' id='b89c5r7ib574'>type='set'> <query xmlns='jabber:iq:roster'> <item ask='subscribe' jid='juliet@example.com'subscription='none' ask='subscribe'/>subscription='none'/> </query> </iq> US: <iq id='b89c5r7ib575' to='romeo@example.net/bar'type='set' id='b89c5r7ib575'>type='set'> <query xmlns='jabber:iq:roster'> <item ask='subscribe' jid='juliet@example.com'subscription='none' ask='subscribe'/>subscription='none'/> </item> </query> </iq>Saint-Andre Expires December 8, 2008 [Page 22] Internet-Draft XMPP IM June 2008 Note: Because the server must send this roster push, a client MAY simply wait for the roster push rather than proactively adding the contact to the user's roster before sending the subscription request. Note:If the contact does not approve or deny the subscription request within some configurable amount of time, the user's server SHOULDre-sendre- send the subscription request to the contact based on an implementation-specific algorithm (e.g., whenever a new resource becomes available for the user, or after a certain amount of time has elapsed); this helps to recover from transient, silent errors thatmaymight have occurred in relation to the original subscription request. 3.1.3. Server Processing of Inbound Subscription RequestTheBefore processing the inbound presence subscription request, the contact's serverMUST adhereSHOULD check the syntax of the JID contained in the 'to' attribute. If the JID is of the form <contact@domain/resource> instead of <contact@domain>, the contact's server SHOULD treat it as if the request had been directed to thefollowing rules whencontact's bare JID and modify the 'to' address accordingly. The server MAY also verify that the JID adheres to the format defined in [XMPP-CORE], including checking against the relevant stringprep profiles. When processing the inbound presence subscriptionrequest:request, the contact's server MUST adhere to the following rules: Saint-Andre Expires January 13, 2009 [Page 27] Internet-Draft XMPP IM July 2008 1. Above all, the contact's server MUST NOT automatically approve subscription requests on the contact's behalf; instead, if a subscription request requires approval then the contact's server MUST deliver that request to the contact'sinterestedavailable resource(s) for approval or denial by the contact. 2. If the contact does not exist, then the contact's server MUST automatically return a presence stanza of type "unsubscribed" to the user. CS: <presence from='juliet@example.com' to='romeo@example.net' type='unsubscribed'/> 3. If the contact exists and the user already has a subscription to the user's presence, then the contact's serverSHOULDMUST auto-reply on behalf of the contact by sending a presence stanza of type "subscribed" from the contact's bare JID to the user's bare JID. If the contact previously sent a presence stanza of type "subscribed" and the contact's server treated that as indicating "pre-approval" for the user's presence subscription (see Appendix A), then the contact's serverMAYSHOULD also auto-reply on behalf of the contact. 4. If the contact exists, the user does not already have a subscription to the contact's presence, and there is at least oneinterestedavailable resource associated with the contact when the subscription request is received by the contact's server, then the contact's server MUST broadcast that subscription request to allinterestedavailable resources in accordance withServer Rules for Processing XML Stanzas (Section 8). Saint-Andre Expires December 8, 2008 [Page 23] Internet-Draft XMPP IM June 2008Section 8. 5. If the contact exists, the user does not already have a subscription to the contact's presence, and the contact has nointerestedavailable resources when the subscription request is received by the contact's server, then the contact's server MUST keep a record of the complete presence stanza comprising the subscription request, including any extended content contained therein, and deliver the request when the contact next has aninterestedavailable resource. The contact's server MUST continue to deliver the subscription request whenever the contact creates aninterestedavailable resource, until the contact either approves or denies the request. (Note: The contact's server MUST NOT deliver more than one subscription request from any given user when the contact next has aninterestedavailable resource; e.g., if the user sends multiple subscription requests to the contact while the contact is offline, the contact's server SHOULD store only one of those requests, such as the first request or last request, and MUST deliver only one of the requests when the contact next has aninterestedavailable resource; this helps to prevent "subscription request spam".)Note: If the subscription request is directed to a full JID <contact@domain/resource> instead of a bare JID <contact@domain>, the contact's server MAY treat it as if the request had been directed to the contact's bare JID. This simplifies processing of presence subscriptions.Saint-Andre Expires January 13, 2009 [Page 28] Internet-Draft XMPP IM July 2008 Note: Until and unless the contact approves the subscription request as described under Section 3.1.4, the contact's server MUST NOT add an item for the user to the contact's roster. 3.1.4. Client Processing of Inbound Subscription Request When the contact's client receives a subscription request from the user, it MUST present the request to the contact for approval (unless the contact has explicitly configured the client to automatically approve or deny some or all subscription requests). A subscription request is approved by sending a presence stanza of type "subscribed", which is processed as described in the following sections for both the contact's server and the user's server. CC: <presence to='romeo@example.net' type='subscribed'/>Note: Before approving a presence subscription, the contact MAY generate a roster set that includes a handle for the user and that places the user in one or more roster groups; see Section 2.3.A subscription request is denied by sending a presence stanza of typeSaint-Andre Expires December 8, 2008 [Page 24] Internet-Draft XMPP IM June 2008"unsubscribed", which is processed as described under Section 3.2 for both the contact's server and the user's server. CC: <presence to='romeo@example.net' type='unsubscribed'/> 3.1.5. Server Processing of Outbound Subscription Approval When the contact's client sends the subscription approval, the contact's server MUST stamp the outbound stanza with the bare JID <contact@domain> of the contact androute orlocally deliver or remotely route the stanza to the user. CS: <presence from='juliet@example.com' to='romeo@example.net' type='subscribed'/> The contact's server then MUST send a roster push to all of the contact's interested resources. Saint-Andre Expires January 13, 2009 [Page 29] Internet-Draft XMPP IM July 2008 CS: <iq id='a78b4q6ha463' to='juliet@example.com/balcony'type='set' id='a78b4q6ha463'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' subscription='from'/> </query> </iq> CS: <iq id='a78b4q6ha464' to='juliet@example.com/chamber'type='set' id='a78b4q6ha464'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' subscription='from'/> </query> </iq> The contact's server MUST then also send current presence to the user from each of the contact's available resources. CS: <presence from='juliet@example.com/balcony' to='romeo@example.net'/> CS: <presence from='juliet@example.com/chamber' to='romeo@example.net'/> From the perspective of the contact, there now exists a subscription from the user.Saint-Andre Expires December 8, 2008 [Page 25] Internet-Draft XMPP IM June 2008In order to subscribe to the user's presence, the contact would then send a subscription request to the user. (XMPP clients will often automatically send the subscription request instead of requiring the contact to initiate the subscription request, since it is assumed that the desired end state is a mutual subscription.) Naturally, when the contact sends a subscription request to the user, the subscription states will be different from those shown in the foregoing examples (see Appendix A) and the roles will be reversed. 3.1.6. Server Processing of Inbound Subscription Approval When the user's server receives the subscription approval, it MUST first check if the contact is in the user's roster withasubscription='none' or subscription='from' and the 'ask' flag set to "subscribe" (i.e., a subscriptionstatesstate of "None + PendingOut"Out", "None + Pending Out+In", or "From + Pending Out"; see Appendix A). Ifthe contact is not in the user's roster with either of those states, the user's server MUST silently ignore the presence stanza of type "subscribed" (i.e., it MUST NOT route it to the user, modify the user's roster, or generate a roster push to the user's interested resources). If the foregoingthis check is successful, the user's server MUST initiate a roster push to all of the user's interested resources, containing an updated Saint-Andre Expires January 13, 2009 [Page 30] Internet-Draft XMPP IM July 2008 roster item for the contact with the 'subscription' attribute set to a value of"to"."to" (if the subscription state was "None + Pending Out" or "None + Pending Out+In") or "both" (if the subscription state was "From + Pending Out"). US: <iq id='b89c5r7ib576' to='romeo@example.net/foo'type='set' id='b89c5r7ib576'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='juliet@example.com' subscription='to'/> </query> </iq> US: <iq id='b89c5r7ib577' to='romeo@example.net/bar'type='set' id='b89c5r7ib577'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='juliet@example.com' subscription='to'/> </item> </query> </iq>From(Otherwise -- that is, if theperspective ofuser does not exist, if theuser, there now exists a subscription tocontact is not in thecontact's presence. Saint-Andre Expires December 8, 2008 [Page 26] Internet-Draft XMPP IM June 2008 Theuser'sserver MUSTroster, or if the contact is in the user's roster with a subscription state other than those described in the foregoing check -- then the user's server MUST silently ignore the stanza by not delivering it to the user, not modifying the user's roster, and not generating a roster push to the user's interested resources.) From the perspective of the user, there now exists a subscription to the contact's presence. The user's server MUST also deliver the available presence stanza received from each of the contact's available resources to each of the user's available resources. Saint-Andre Expires January 13, 2009 [Page 31] Internet-Draft XMPP IM July 2008 [ ... to resource1 ... ] US: <presence from='juliet@example.com/balcony' to='romeo@example.net'/> [ ... to resource2 ... ] US: <presence from='juliet@example.com/balcony' to='romeo@example.net'/> [ ... to resource1 ... ] US: <presence from='juliet@example.com/chamber' to='romeo@example.net'/> [ ... to resource2 ... ] US: <presence from='juliet@example.com/chamber' to='romeo@example.net'/> 3.2. Cancelling a Subscription 3.2.1. Client Generation of Subscription Cancellation If a contact would like to cancel a subscription that it has previously granted to a user (or deny a subscription request), it sends a presence stanza of type "unsubscribed". CC: <presence to='romeo@example.net' type='unsubscribed'/> 3.2.2. Server Processing of Outbound Subscription CancellationAs mentioned,Upon receiving the outound subscription cancellation, the contact's server MUSTstamp the outbound subscription cancellation with the bare JID <contact@domain> of the contact. CS: <presence from='juliet@example.com' to='romeo@example.net' type='unsubscribed'/>proceed as follows. 1. If the user is hosted on the sameserver,server as the contact, the server MUST adhere to the rules specified in the next sectionwhenin processing the subscription cancellation.Saint-Andre Expires December 8, 2008 [Page 27] Internet-Draft XMPP IM June 20082. If the user is hosted on adifferentremote server, subject to local service policies the contact's server MUST thenroutesroute the stanza to thatforeignremote domain in accordance with core XMPP stanza processing rules.If the user is(This can result in returning an appropriate stanza error to the contact, such as <remote-server-timeout/>.) As mentioned, before locally delivering or remotely routing the stanza, the contact'sroster,server MUST stamp the outbound subscription cancellation with the bare JID <contact@domain> of the contact. Saint-Andre Expires January 13, 2009 [Page 32] Internet-Draft XMPP IM July 2008 CS: <presence from='juliet@example.com' to='romeo@example.net' type='unsubscribed'/> The contact's server then MUST send a roster push with the updated roster item to all of the contact's interested resources, where the subscription state is now either "none" or "to" (see Appendix A). CS: <iq id='a78b4q6ha465' to='juliet@example.com/balcony'type='set' id='a78b4q6ha465'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' subscription='none'/> </query> </iq> CS: <iq id='a78b4q6ha466' to='juliet@example.com/chamber'type='set' id='a78b4q6ha466'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' subscription='none'/> </query> </iq> 3.2.3. Server Processing of Inbound Subscription Cancellation When the user's server receives the inbound subscription cancellation, it MUSTmodifyfirst check if thesubscription state and sendcontact is in the user's roster with subscription='to' or subscription='both' (see Appendix A). If this check is successful, the user's server MUST initiate a roster push to all of the user's interested resources,wherecontaining an updated roster item for the contact with the 'subscription' attribute set to a value of "none" (if the subscription stateis now either "none"was "To" or "To + Pending In") or "from"(see Appendix A).(if the subscription state was "Both"). Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page28]33] Internet-Draft XMPP IMJuneJuly 2008 US: <iq id='h37h3u1bv400' to='romeo@example.net/foo'type='set' id='h37h3u1bv400'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='juliet@example.com' subscription='none'/> </query> </iq> US: <iq id='h37h3u1bv401' to='romeo@example.net/bar'type='set' id='h37h3u1bv401'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='juliet@example.com' subscription='none'/> </item> </query> </iq> (Otherwise -- that is, if the user does not exist, if the contact is not in the user's roster, or if the contact is in the user's roster with a subscription state other than those described in the foregoing check -- then the user's server MUST silently ignore the stanza by not delivering it to the user, not modifying the user's roster, and not generating a roster push to the user's interested resources.) 3.3. Unsubscribing 3.3.1. Client Generation of Unsubscribe If a user would like to unsubscribe from a contact's presence, it sends a presence stanza of type "unsubscribe". UC: <presence to='juliet@example.com' type='unsubscribe'/> 3.3.2. Server Processing of Outbound UnsubscribeAs mentioned,Upon receiving the outbound unsubscribe, the user's server MUSTstamp the outbound unsubscribe with the bare JID <user@domain> of the user. US: <presence from='romeo@example.net' to='juliet@example.com' type='unsubscribe'/>proceed as follows. 1. If the contact is hosted on the sameserver,server as the user, the server MUST adhere to the rules specified in the next sectionwhenin processing theunsubscribe.subscription request. 2. If the contact is hosted on adifferentremote server, subject to local service policies the user's server MUST thenroutesroute the stanza to thatforeignremote domain in accordance with core XMPP stanza processing rules. (This can result in returning an appropriate stanza error to the user, such as <remote-server-timeout/>.) Saint-Andre Expires January 13, 2009 [Page 34] Internet-Draft XMPP IM July 2008 As mentioned, before locally delivering or remotely routing the unsubscrbe, the user's server MUST stamp the stanza with the bare JID <user@domain> of the user. US: <presence from='romeo@example.net' to='juliet@example.com' type='unsubscribe'/> The user's server then MUST send a roster push with the updated roster item to all of the user's interested resources, where the subscription state is now either "none" or "from" (see Appendix A).Saint-Andre Expires December 8, 2008 [Page 29] Internet-Draft XMPP IM June 2008US: <iq id='h37h3u1bv402' to='romeo@example.net/foo'type='set' id='h37h3u1bv402'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='juliet@example.com' subscription='none'/> </query> </iq> US: <iq to='romeo@example.net/bar' type='set' id='h37h3u1bv403'> <query xmlns='jabber:iq:roster'> <item jid='juliet@example.com' subscription='none'/> </item> </query> </iq> 3.3.3. Server Processing of Inbound Unsubscribe When the contact's server receives theinbound unsubscribe,subscription approval, it MUSTmodifyfirst check if the user is in the contact's roster with subscription='from' or subscription='both' (i.e., a subscription stateand sendof "From", "From + Pending Out", or "Both"; see Appendix A). If this check is successful, the contact's server MUST initiate a roster push to all of the contact's interested resources,wherecontaining an updated roster item for the contact with the 'subscription' attribute set to a value of "none" (if the subscription stateis now either "none"was "From" or "From + Pending Out") or "to"(see Appendix A).(if the subscription state was "Both"). Saint-Andre Expires January 13, 2009 [Page 35] Internet-Draft XMPP IM July 2008 CS: <iq id='a78b4q6ha467' to='juliet@example.com/balcony'type='set' id='a78b4q6ha467'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' subscription='none'/> </query> </iq> CS: <iq id='a78b4q6ha468' to='juliet@example.com/chamber'type='set' id='a78b4q6ha468'>type='set'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' subscription='none'/> </query> </iq>Saint-Andre Expires December 8, 2008 [Page 30] Internet-Draft XMPP IM June 2008(Otherwise -- that is, if the contact does not exist, if the user is not in the contact's roster, or if the user is in the contact's roster with a subscription state other than those described in the foregoing check -- then the contact's server MUST silently ignore the stanza by not delivering it to the contact, not modifying the contact's roster, and not generating a roster push to the contact's interested resources.) 4. Exchanging Presence Information 4.1. Overview The concept of presence refers to an entity's availability for communication over a network. At the most basic level, presence is a boolean "on/off" variable that signals whether an entity is available or unavailable for communication (the terms "online" and "offline" are also used). In XMPP, aprincipal'suser's availability is signalled when a client controlled by theprincipaluser generates a <presence/> stanza with no 'type' attribute, and an entity's lack of availability is signalled when a client generates a <presence/> stanza whose 'type' attribute has a value of "unavailable".In XMPP-based applications that combine messaging and presence functionality, the default type of communication for which presence signals availability is messaging; however, XMPP-based applications are not required to combine messaging and presence functionality, and can provide standalone presence features without messaging (in addition, XMPP servers do not require information about network availability in order to successfully route message and IQ stanzas).XMPP presence typically follows a "publish-subscribe" or "observer" pattern, wherein an entity sends presence to its server, and its server then broadcasts that information to all of the entity's contacts who have a subscription to the entity's presence (in the terminology of [IMP-MODEL], an entity that generates presence is a "presentity" and the entities that receive presence are "subscribers"). A client generates presence for broadcasting to all Saint-Andre Expires January 13, 2009 [Page 36] Internet-Draft XMPP IM July 2008 subscribed entities by sending a presence stanza to its server with no 'to' address, where the presence stanza has either no 'type' attribute or a 'type' attribute whose value is "unavailable". This kind of presence is calledBROADCASTEDBROADCAST PRESENCE. (A clientMAYcan also send DIRECTED PRESENCE, i.e., a presence stanza with a 'to' address; this is less common but is sometimes used to send presence to entities that are not subscribed to theprincipal'suser's presence; see Section 4.6.) After a client completes the preconditions specified in [XMPP-CORE], it can establish a PRESENCE SESSION at its server by sending initial presence (Section4.2). Such a4.2), where the presence session is terminated by sending unavailable presence (Section 4.5).4.2. Initial Presence 4.2.1. Client GenerationFor the duration ofInitial Presence After completingits presence session, a connected resource (in thepreconditions described in [XMPP-CORE] (REQUIRED)terminology of [XMPP-CORE]) is said to be an AVAILABLE RESOURCE. In XMPP-based applications that combine messaging andrequestingpresence functionality, theroster (RECOMMENDED), a client SHOULD Saint-Andre Expires December 8, 2008 [Page 31] Internet-Draft XMPP IM June 2008 signal its availability fordefault type of communicationbyfor which presence signals availability is messaging; however, it is not necessary for XMPP-based applications to combine messaging and presence functionality, and can provide standalone presence features without messaging (in addition, XMPP servers do not require information about network availability in order to successfully route message and IQ stanzas). Note: In the following examples, the "user" is juliet@example.com and the user has three contacts in her roster with a subscription state of "from" or "both": romeo@example.net, mercutio@example.com, and benvolio@example.net. 4.2. Initial Presence 4.2.1. Client Generation of Initial Presence After completing the preconditions described in [XMPP-CORE] (REQUIRED) and requesting the roster (RECOMMENDED), a client signals its availability for communication by sending INITIAL PRESENCE to its server, i.e., a presence stanza with no 'to' address (indicating that it is meant to bebroadcastedbroadcast by the server on behalf of the client) and no 'type' attribute (indicating the user's availability).After sendingUC: <presence/> The initialpresence, a connected resource (inpresence stanza MAY contain theterminology<priority/> element, the <show/> element, and one or more instances of[XMPP-CORE]) is said to be an AVAILABLE RESOURCE. UC: <presence/>the <status/> element, as well as extended content. Saint-Andre Expires January 13, 2009 [Page 37] Internet-Draft XMPP IM July 2008 4.2.2. Server Processing of Outbound Presence Upon receiving initial presence from a client, the user's server MUST send the initial presence stanza from the full JID <user@domain/resource> of the user to all contacts that are subscribed to the user's presence; such contacts are those for which a JID is present in the user's roster with the 'subscription' attribute set to a value of "from" or "both".Note: In the following examples, the "user" is juliet@example.com and the user has three contacts in her roster with a subscription state of "from" or "both": romeo@example.net, mercutio@example.com, and benvolio@example.com.US: <presence from='juliet@example.com/balcony' to='romeo@example.net'/> US: <presence from='juliet@example.com/balcony' to='mercutio@example.com'/> US: <presence from='juliet@example.com/balcony'to='benvolio@example.com'/>to='benvolio@example.net'/> The user's server MUST also broadcast initial presence from the user's newly available resource to all of the user's availableresources.resources (including the resource that generated the presence notification in the first place). US: <presence from='juliet@example.com/balcony' to='juliet@example.com/balcony'/> US: <presence from='juliet@example.com/balcony' to='juliet@example.com/chamber'/> In the absence of presence information about the user's contacts, the user's serverSHOULDMUST also send presence probes to the user's contacts on behalf of the user as specified under Section 4.3.Saint-Andre Expires December 8, 2008 [Page 32] Internet-Draft XMPP IM June 20084.2.3. Server Processing of Inbound Presence Upon receiving presence from the user, the contact's server MUST deliver the user's presence stanza to all of the contact's available resources. [ ... to resource1 ... ] CS: <presence from='juliet@example.com/balcony' to='romeo@example.net'/> [ ... to resource2 ... ] CS: <presence from='juliet@example.com/balcony' to='romeo@example.net'/> Saint-Andre Expires January 13, 2009 [Page 38] Internet-Draft XMPP IM July 2008 If there is no such contact, the contact's server MUST silently ignore the presence stanza. 4.2.4. Client Processing of Inbound Presence When the contact's client receives presence from theuser anduser, it SHOULD proceed as follows: 1. If the user is in the contact's roster,it SHOULDthe client MUST display the presence information in an appropriate roster interface. 2. If the user is not in the contact's roster but the contact and the user are actively exchanging message or IQ stanzas, the contact's client SHOULD display the presence information in the user interface for that chat session (see also Section 4.6 and Section5.4).5.1). 3. Otherwise, the clientSHOULDMUST ignore the presence information and not display it to the contact. 4.3. Presence Probes A PRESENCE PROBE is a request for a contact's current presence information, sent on behalf of a user by the user's server; syntactically it is a presence stanza whose 'type' attribute has a value of "probe". The value of the 'from' addressSHOULDMUST be the full JID <user@domain/resource> of theprobinguser and the value of the 'to' addressSHOULDMUST be the bare JID <contact@domain> of the contactwhose availabilityto which the userwants to discover.is subscribed. US: <presence from='juliet@example.com/balcony' to='romeo@example.net' type='probe'/> A presence probe SHOULD NOT be sent by a client. Instead, it is designed to be sent by a user's server on the user's behalf in order to discover the availability of the user's contacts. If a server receives a presence probe intended for a full JID <contact@domain/resource>, it SHOULD treat the probe as if the 'to'Saint-Andre Expires December 8, 2008 [Page 33] Internet-Draft XMPP IM June 2008address was a bare JID, but MAY instead handle it on behalf of the connected resource by returning only the presence information for that particular resources (and in any case MUST NOT deliver it to the resource). 4.3.1. Server Generation of Outbound Presence Probe When a server needs to discover the availability of a user's contact, itSHOULD sendsends a presence probe from the full JID <user@domain/resource> of the user to the bare JID <contact@domain> of the contact. The serverSHOULDSaint-Andre Expires January 13, 2009 [Page 39] Internet-Draft XMPP IM July 2008 MUST NOT send a probe to a contactonlyif the user is not subscribed to the contact's presence (i.e., if the contact is not in the user's roster with the 'subscription' attribute set to a value of "to" or"both" (i.e., if the user is subscribed to the contact's presence)."both". The user's server SHOULD send a presence probe whenever the user starts a new presence session by sending initial presence; however, the server MAY choose not to send the probe at that point if it has what it deems to be reliable and up-to-date presence information about the user's contacts (e.g., because the user has another available resource or because the user briefly logged off and on before the new presence session began). In addition, a server MAY periodically send a presence probe to a contact if it has not received presence information or other traffic from the contact in some configurable amount of time; this can help to prevent "ghost" contacts who appear to be online but in fact are not. US: <presence from='juliet@example.com/balcony' to='romeo@example.net' type='probe'/> US: <presence from='juliet@example.com/balcony'to='benvolio@example.com' type='probe'/> US: <presence from='juliet@example.com/balcony' to='nurse@example.com'to='benvolio@example.net' type='probe'/> Naturally, the user's server does not need to send a presence probe to a contact if the contact's account resides on the same server as the user, since the server possesses contact's information locally. 4.3.2. Server Processing of Inbound Presence Probe Upon receiving a presence probe from the user's server on behalf of the user, the contact's server SHOULD reply as follows: 1. If the contact account does not exist or the user is in the contact's roster with a subscription state other than "From", "From + Pending Out", or "Both" (as defined under Appendix A), the contact's server MUST return a presence stanza of typeSaint-Andre Expires December 8, 2008 [Page 34] Internet-Draft XMPP IM June 2008"unsubscribed" in response to the presence probe (however, if a server receives a presence probe from a configured hostname of the server itself or another such trusted service, it MAY provide presence information about the user to that entity). CS: <presence from='mercutio@example.com' to='juliet@example.com' type='unsubscribed'/> Saint-Andre Expires January 13, 2009 [Page 40] Internet-Draft XMPP IM July 2008 2. Else, if the contact has no available resources, the server SHOULD reply to the presence probe by sending to the user the full XML of the last presence stanza of type "unavailable" received by the server from the contact(but(however, the server MAY opt to not reply at all). 3. Else, if the contact has at least one available resource, the server MUST reply to the presence probe by sending to the user the full XML of the last presence stanza with no 'to' attribute received by the server from each of the contact's available resources. CS: <presence from='romeo@example.net/foo' to='juliet@example.com'/> CS: <presence from='romeo@example.net/bar' to='juliet@example.com'> <show>away</show> </presence> 4.4. Subsequent Presence Broadcast 4.4.1. Client Generation of Presence Broadcast After sending initial presence, the user's clientmaycan update its availability for broadcasting at any time during its session by sending a presence stanza with no 'to' address and no 'type' attribute. UC: <presence> <show>away</show> </presence>Note: AThe presence broadcast MAY contain the <priority/> element, the <show/> element, and one or more instances of the <status/> element, as well as extended content. However, a user SHOULDNOTsend a presence update only to broadcast information thatchanges independently ofis relevant to the user's availability forcommunication. Saint-Andre Expires December 8, 2008 [Page 35] Internet-Draftcommunication or the communication capabilities of the connected resource. Information that is not relevant in this way can be of interest to the user's contacts but SHOULD be sent via other means, such as the XMPPIM June 2008message stanza. 4.4.2. Server Processing of Outbound Presence Upon receiving a presence stanza expressing updated availability, the user's server MUST broadcast the full XML of that presence stanza to the contacts who meet all of the following criteria: Saint-Andre Expires January 13, 2009 [Page 41] Internet-Draft XMPP IM July 2008 1. The contact is in the user's roster with a subscription type of "from" or "both". 2. The last presence stanza received from the contact during the user's presence session was not of type "error" or "unsubscribe". As an optimization, if the subscription type is "both", the serverMAYSHOULD send subsequent presence notifications to a contact only if the contact is online according to the user's server. That is, if the user's server never received a positive indication that the contact is online in response to the presence probe it sent to the contact or if the last presence stanza it received from the contact during the user's presence session was of type "unavailable", the user's serverMAY opt not toSHOULD NOT send subsequent presence notifications from the user to the contact.US: <presence from='juliet@example.com/balcony' to='romeo@example.net'> <show>away</show> </presence> US:This optimization helps to save bandwidth, since most presence subscriptions are bidirectional and many contacts will not be online at any given time. US: <presence from='juliet@example.com/balcony' to='romeo@example.net'> <show>away</show> </presence> US: <presence from='juliet@example.com/balcony'to='benvolio@example.com'>to='benvolio@example.net'> <show>away</show> </presence> US: <presence from='juliet@example.com/balcony' to='mercutio@example.com'> <show>away</show> </presence> See Section 4.6 regarding rules that supplement the foregoing for handling of directed presence. The user's server MUST also send the presence stanza to all of the user's availableresources.resources (including the resource that generated the presence notification in the first place). US: <presence from='juliet@example.com/balcony' to='juliet@example.com/chamber'> <show>away</show> </presence> US: <presence from='juliet@example.com/balcony' to='juliet@example.com/balcony'> <show>away</show> </presence> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page36]42] Internet-Draft XMPP IMJuneJuly 2008 4.4.3. Server Processing of Inbound Presence Upon receiving presence from the user, the contact's server MUST deliver the user's presence stanza to all of the contact's available resources. [ ... to resource1 ... ] CS: <presence from='juliet@example.com/balcony' to='romeo@example.net'> <show>away</show> </presence> [ ... to resource2 ... ] CS: <presence from='juliet@example.com/balcony' to='romeo@example.net'> <show>away</show> </presence> 4.4.4. Client Processing of Inbound Presence When the contact's client receives presence from theuser anduser, it SHOULD proceed as follows: 1. If the user is in the contact's roster,it SHOULDthe client MUST display the presence information in an appropriate roster interface. 2. If the user is not in the contact's roster but the contact and the user are actively exchanging message or IQ stanzas, the contact's client SHOULD display the presence information in the user interface for that chat session (see also Section 4.6 and Section5.4).5.1). 3. Otherwise, the clientSHOULDMUST ignore the presence information and not display it to the contact. 4.5. Unavailable Presence 4.5.1. Client Generation of Unavailable Presence Before ending its presence session with a server, the user's client SHOULD gracefully become unavailable by sending UNAVAILABLE PRESENCE, i.e., a presence stanza that possesses no 'to' attribute and that possesses a 'type' attribute whose value is "unavailable". UC: <presence type='unavailable'/> Optionally, thefinalunavailable presence stanza MAY contain one or more <status/> elements specifying the reason why the user is no longeravailable.Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page37]43] Internet-Draft XMPP IMJuneJuly 2008 available. US: <presence type='unavailable'> <status>going on vacation</status> </presence> However, the unavailable presence stanza MUST NOT contain the <priority/≫ element or the <show/> element, since these elements apply only to available presence. 4.5.2. Server Processing of Outbound Unavailable Presence The user's server MUST NOT depend on receiving unavailable presence from an available resource, since the resourcemaycan become unavailable ungracefully (e.g., the resourcemaycan be timed out by the server because of inactivity). If an available resource becomes unavailable for any reason (either gracefully or ungracefully), the user's server MUST broadcast unavailable presence to all contacts that meet all of the following criteria: 1. The contact is in the user's roster with a subscription type of "from" or "both". 2. The last presence stanza received from the contact during the user's presence session was not of type "error" or "unsubscribe".As an optimization, if the subscription type is "both", the server MAY sendSee Section 4.6 regarding rules that supplement theunavailableforegoing for handling of directed presence. The optimization employed for subsequent presencenotification tobroadcast during acontact only if the contact is online according to the user's server. That is, if theuser'sserver never received a positive indication that the contact is online in response to thepresenceprobe it sent to the contact orsession MUST NOT be employed for unavailable presence broadcast; if it were, the last presencestanzareceivedfromby thecontact duringcontact's server would be the user's initial presencesession was of type "unavailable", the user's server MAY opt not to sendfor theunavailablepresencenotification from the user tosession, with thecontact. See Section 4.6 regarding rulesresult thatsupplementtheforegoing.contact would consider the user to be online. If the unavailable presence stanza was gracefully received from the client, the server MUST broadcast the full XML of the presence stanza. Saint-Andre Expires January 13, 2009 [Page 44] Internet-Draft XMPP IM July 2008 US: <presence from='juliet@example.com/balcony' to='romeo@example.net' type='unavailable'/> <status>going on vacation</status> </presence> US: <presence from='juliet@example.com/balcony'to='benvolio@example.com' type='unavailable'/>to='benvolio@example.net' type='unavailable'> <status>going on vacation</status> </presence> US: <presence from='juliet@example.com/balcony' to='mercutio@example.com'type='unavailable'/> Saint-Andre Expires December 8, 2008 [Page 38] Internet-Draft XMPP IM June 2008type='unavailable'> <status>going on vacation</status> </presence> The user's server MUST also send the unavailable presence stanza to all of the user's remaining available resources. US: <presence from='juliet@example.com/balcony' to='juliet@example.com/chamber'type='unavailable'/>type='unavailable'> <status>going on vacation</status> </presence> If the server detects that the user has gone offline ungracefully, the server MUST generate the unavailable presence broadcast on the user's behalf. Note: Any presence stanza with no 'type' attribute and no 'to' attribute that is sent after sendingbroadcastedunavailable presence broadcast MUST bebroadcastedsent by the user's server to all subscribers (i.e., MUST be treated as equivalent to"initial presence"initial presence for a new presence session). 4.5.3. Server Processing of Inbound Unavailable Presence Upon receiving unavailable presence from the user, the contact's server MUST deliver the user's presence stanza to all of the contact's available resources. Saint-Andre Expires January 13, 2009 [Page 45] Internet-Draft XMPP IM July 2008 [ ... to resource1 ... ] CS: <presence from='juliet@example.com/balcony' to='romeo@example.net'type='unavailable'/>type='unavailable'> <status>going on vacation</status> </presence> [ ... to resource2 ... ] CS: <presence from='juliet@example.com/balcony' to='romeo@example.net'type='unavailable'/>type='unavailable'> <status>going on vacation</status> </presence> If the contact's server is optimizing subsequent presence delivery as described under Section 4.4, itSHOULDMUST also note that the user is unavailable and appropriately update its internal representation of whichusersentities are online. 4.5.4. Client Processing of Inbound Unavailable Presence When the contact's client receives unavailable presence from theuser anduser, it SHOULD proceed as follows: 1. If the user is in the contact's roster,it SHOULDthe client MUST display the unavailable presence information in an appropriate roster interface. 2. If the user is not in the contact's roster but the contact and the user are actively exchanging message or IQ stanzas, the contact's client SHOULD display the unavailable presence information in the user interface for that chat session (see also Section 4.6 and Section5.4). Saint-Andre Expires December 8, 2008 [Page 39] Internet-Draft XMPP IM June 20085.1). 3. Otherwise, the clientSHOULDMUST ignore the unavailable presence information and not display it to the contact. 4.6. Directed Presence This section supplements and in some respects modifies the rulesdefined above,for client and server processing of presence notifications, but only for the special case of directed presence. 4.6.1. Client Generation of Directed Presence As noted, directed presence is a presence stanza with a 'to' attribute whose value is the bare JID or full JID of the other entity and with either no 'type' attribute (indicating availability) or a Saint-Andre Expires January 13, 2009 [Page 46] Internet-Draft XMPP IM July 2008 'type' attribute whose value is "unavailable". Information about the use of directed presence in the context of a one-to-one chat session is provided under Section5.4.5.1. 4.6.2. Server Processing of Outbound Directed Presence When the user's server receivesthea directed presence stanza, it SHOULD process it according to the following rules. 1. If the user sends directed available or unavailable presence to a contact that is in the user's roster with a subscription type of "from" or "both" after having sent initial presence and before sendingbroadcastedunavailable presence broadcast (i.e., during the user's presence session), the user's server MUSTroute orlocally deliver or remotely route the full XML of that presence stanza but SHOULD NOT otherwise modify the contact's status regardingbroadcastedpresence broadcast (i.e., it SHOULD include the contact's JID in any subsequent presence broadcasts initiated by the user). 2. If the user sends directed presence to an entity that is not in the user's roster with a subscription type of "from" or "both" after having sent initial presence and before sendingbroadcastedunavailable presence broadcast (i.e., during the user's presence session), the user's server MUSTroute orlocally deliver or remotely route the full XML of that presence stanza to the entity but MUST NOT modify the contact's status regarding available presence broadcast (i.e., it MUST NOT include the entity's JID in any subsequent broadcasts of available presence initiated by the user); however, if the available resource from which the user sent the directed presence become unavailable, the user's server MUST route that unavailable presence to the entity (if the user has not yet sent directed unavailable presence to that entity). 3. If the user sends directed presence without first sending initial presence or after having sent unavailable presence broadcast (i.e., the resource is connected but not available), the user'sSaint-Andre Expires December 8, 2008 [Page 40] Internet-Draft XMPP IM June 2008server MUST treat theentitiesentity to which the user sends directed presencein the same way that it treats the entities listedas in case #2 above. 4.6.3. Server Processing of Inbound Directed Presence From the perspective of the contact's server, there is no difference betweenbroadcastedpresence broadcast and directed presence, so the contact's server follows the existing rules for processing of inbound presence. 4.6.4. Client Processing of Inbound Directed Presence When the contact's client receives directed presence from theuser anduser, it SHOULD proceed as follows: Saint-Andre Expires January 13, 2009 [Page 47] Internet-Draft XMPP IM July 2008 1. If the user is in the contact's roster,it SHOULDthe client MUST display the presence information in an appropriate roster interface. 2. If the user is not in the contact's roster but the contact and the user are actively exchanging message or IQ stanzas, the contact's client SHOULD display the presence information inan appropriatethe userinterface.interface for that chat session (see also Section 4.6 and Section 5.1). 3. Otherwise, the clientSHOULDMUST ignore the presence information and not display it to the contact. 4.7. Presence Syntax 4.7.1. Type Attribute The absence of a 'type' attribute signals that the relevant entity is available for communication (see Section 4.2 and Section 4.4). A 'type' attribute with a value of "unavailable" signals that the relevant entity is not available for communication (see Section 4.5). The XMPP presence stanza is also used to negotiate and manage subscriptions to the presence of other entities. These tasks are completed via presence stanzas of type "subscribe", "unsubscribe", "subscribed", and "unsubscribed" as described under Section 3. If a user and contact are associated with different XMPP servers, those servers also use a special presence stanza of type "probe" in order to determine the availability of the entity on the peer server; for details, see Section 4.3. Clients SHOULD NOT send presence stanzas of type "probe". The values of the 'type' attribute can be summarized as follows:Saint-Andre Expires December 8, 2008 [Page 41] Internet-Draft XMPP IM June 2008o error -- An error has occurred regarding processing of a previously-sent presence stanza; if the presence stanza is of type "error", it MUST include an <error/> child element (refer to [XMPP-CORE]). o probe -- A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user. o subscribe -- The sender wishes to subscribe to the recipient's presence. o subscribed -- The sender has allowed the recipient to receive their presence. o unavailable -- Signals that the entity is no longer available for communication. o unsubscribe -- The sender is unsubscribing fromanother entity'sthe receiver's presence. Saint-Andre Expires January 13, 2009 [Page 48] Internet-Draft XMPP IM July 2008 o unsubscribed -- The subscription request has been denied or a previously-granted subscription has been cancelled.o unavailable -- Signals that the entity is no longer available for communication. IfIf the value of the 'type' attribute is not one of the foregoing values, the recipient or an intermediate router SHOULD return a stanza error of <bad-request/>. Note: There is no default value for the 'type' attribute of the <presence/>element. Therefore if the intended recipient or intermediate router receives a <presence/> element whose 'type' valueelement; in particular, there isundefined, it SHOULD return a stanza errorno value of<bad-request/>."available". 4.7.2. Child Elements In accordance with the default namespace declaration, a presence stanza is qualified by the 'jabber:client' or 'jabber:server' namespace, which defines certain allowable children of presence stanzas, in particular the <show/>, <status/>, and <priority/> elements. These child elements are used to provide more detailed information about an entity's availability. Typically these child elements are provided only if the presence stanza possesses no 'type' attribute, although exceptions are noted in the text that follows. 4.7.3. Show Element The OPTIONAL <show/> element specifies the particular availability sub-state of an entity or a specific resource thereof. A presence stanza MUST NOT contain more than one <show/> element. The <show/> element MUST NOT possess any attributes. The XML character data of the <show/> element is not human-readable. The XML character data MUST be one of the following (additional availability states could be defined through aproperly-namespacedchild element of the presencestanza): Saint-Andre Expires December 8, 2008 [Page 42] Internet-Draft XMPP IM June 2008stanza that is qualified by a namespace other than the default namespace): o away -- The entity or resource is temporarily away. o chat -- The entity or resource is actively interested in chatting. o dnd -- The entity or resource is busy (dnd = "Do Not Disturb"). o xa -- The entity or resource is away for an extended period (xa = "eXtended Away"). If no <show/> element is provided, the entity is assumed to be online and available. Any specialized processing of availability states by recipients and intermediate routers is up to the implementation (e.g., incorporation of availability states intoserverstanza routing and delivery logic). Saint-Andre Expires January 13, 2009 [Page 49] Internet-Draft XMPP IM July 2008 4.7.4. Status Element The OPTIONAL <status/> element contains human-readable XML character data specifying a natural-language description of an entity's availability. It is normally used in conjunction with the show element to provide a detailed description of an availability state (e.g., "In a meeting") when the presence stanza has no 'type' attribute. <presence from='romeo@example.net/orchard' xml:lang='en'> <show>dnd</show> <status>Wooing Juliet</status> </presence> The <status/> element MUST NOT possess any attributes, with the exception of the 'xml:lang' attribute. Multiple instances of the <status/> element MAY be included, but only if each instance possesses an 'xml:lang' attribute with a distinct language value (either explicitly or by inheritance from the 'xml:lang' value of an element farther up in the XML hierarchy, whichmaycan include the XML stream header as described in [XMPP-CORE]). <presence from='romeo@example.net/orchard' xml:lang='en'> <show>dnd</show> <status>Wooing Juliet</status> <status xml:lang='cs'>Dvořím se Julii</status> </presence> A presence stanza of type "unavailable" MAY also include a <status/> element to provide detailed information about why the entity is going offline.Saint-Andre Expires December 8, 2008 [Page 43] Internet-Draft XMPP IM June 2008<presence from='romeo@example.net/orchard'type='unavailable'>type='unavailable' xml:lang='en'> <status>Busy IRL</status> </presence> The <status/> child MAY also be sent in a subscription-related presence stanza (i.e., type "subscribe", "subscribed", "unsubscribe", or "unsubscribed") to provide a description of the action. The receiving client MAY present this <status/> information to a human user (see Section 11). Saint-Andre Expires January 13, 2009 [Page 50] Internet-Draft XMPP IM July 2008 <presence from='romeo@example.net' to='nurse@example.com' type='subscribe'> <status>Hi, Julietsaid I shouldtold to add you to my buddy list.</status> </presence> 4.7.5. Priority Element The OPTIONAL <priority/> element contains non-human-readable XML character data that specifies the priority level of the resource. The value MUST be an integer between -128 and +127. A presence stanza MUST NOT contain more than one <priority/> element. The <priority/> element MUST NOT possess any attributes. <presence xml:lang='en'> <show>dnd</show> <status>Wooing Juliet</status> <status xml:lang='cs'>Dvořím se Julii</status> <priority>1</priority> </presence> If no priority is provided, the processing server or clientSHOULDMUST consider the priority to bezero.zero ("0"). For information regarding the semantics of priority values in stanza processing within instant messaging and presence applications, refer toServer Rules for Processing XML Stanzas (Section 8).Section 8. 4.7.6. Extended Content As described in [XMPP-CORE], an XML stanza MAY contain anyproperly- namespacedchildelement;element that is qualified by a namespace other than the default namespace; this applies to the presence stanza as well. (In the following example, the presence stanza includes entity capabilities information as defined in [XEP-0115]).)Saint-Andre Expires December 8, 2008 [Page 44] Internet-Draft XMPP IM June 2008<presence from='romeo@example.net'> <c xmlns='http://jabber.org/protocol/caps'node='http://psi-im.org/caps' ver='0.11'/>hash='sha-1' node='http://psi-im.org' ver='q07IKJEyjvHSyhy//CH0CxmKi8w='/> </presence> Any extended content included in a presence stanza SHOULD represent aspects of an entity's availability for communication or provide information about communication-related capabilities. Saint-Andre Expires January 13, 2009 [Page 51] Internet-Draft XMPP IM July 2008 5. Exchanging Messages Once a client has authenticated with a server and bound a resource to an XML stream as described in [XMPP-CORE], an XMPP server will route XML stanzas to and from thatclientclient. One kind of stanza that can be exchanged is <message/> (if, that is, messaging functionality is enabled and the server is not a presence-only service).One kind of stanza that may be exchanged is <message/>.Exchanging messages is a basic use of XMPP and occurs when a user generates a message stanza that is addressed to another entity. As defined underServer Rules for Processing XML Stanzas (Section 8),Section 8, the sender's server is responsible for delivering the message to the intended recipient (if the recipient is on the same local server) or for routing the message to the recipient's server (if the recipient is on adifferentremote server). Thus a message stanza is used to "push" information to another entity.As noted under Section 4.6, if a user exchanges messages with another entity but does not share presence with the entity based on a presence subscription, it is RECOMMENDED for the user's client to send directed presence to the other entity. The following sections describe the syntax of the <message/> stanza.5.1.Attributes 5.1.1. To Attribute AnOne-to-One Chat Sessions In practice, instant messagingclient SHOULD specify an intended recipient for a message by providing the JIDactivity between human users tends to occur in form ofan entity other thana conversational burst that we call a CHAT SESSION: thesenderexchange of at least several messages between two parties inthe 'to' attributerelatively rapid succession within a relatively brief period ofthe <message/> stanza. If thetime. When a human user intends to engage in such a chat session with a contact (rather than sending a single message to which no reply isbeing sent outsideexpected), thecontextuser's client SHOULD send a message ofany existing chat session or received message,type "chat" and thevalue ofcontact's client SHOULD preserve that message type in subsequent replies. The user's client also SHOULD include a <thread/> element with its initial message, which the'to' addresscontact's client SHOULDbe ofalso preserve during theform <user@domain> rather thanlife of theform <user@domain/resource>. Saint-Andre Expires December 8, 2008 [Page 45] Internet-Draft XMPP IM June 2008 <message from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>Art thou not Romeo, and a Montague?</body> </message> Ifchat session. The user's client MUST address the initial messageis being sentinreply toamessage previously received from an address ofchat session to theform <user@domain/resource> (e.g., withinbare JID <contact@domain> (rather than attempting to guess an appropriate full JID <contact@domain/resource>). Until and unless thecontext ofuser's client receives achat session),reply from thevalue ofcontact, it MUST continue sending any further messages to the'to' addresscontact's bare JID. The contact's client SHOULDbe ofaddress its subsequent replies to theformuser's full JID <user@domain/resource>rather than ofas provided in theform <user@domain> unless'from' address of thesender has knowledge (via presence) thatinitial message. Once theintended recipient's resourceuser's client receives a reply from the contact's full JID, it SHOULD address its subsequent messages to the contact's full JID as provided in the 'from' address of the contact's replies. As noted under Section 4.6, if a user exchanges message stanzas with another entity but does not share presence with the entity based on a presence subscription, it is RECOMMENDED for the user's client to send directed presence to the other entity. An example of a chat session is provided under Section 7. Saint-Andre Expires January 13, 2009 [Page 52] Internet-Draft XMPP IM July 2008 5.2. Message Syntax The following sections describe the syntax of the <message/> stanza. 5.2.1. To Attribute An instant messaging client specifies an intended recipient for a message by providing the JID of an entity other than the sender in the 'to' attribute of the <message/> stanza. If the message is being sent outside the context of any existing chat session or received message, the value of the 'to' address SHOULD be of the form <user@domain> rather than of the form <user@domain/resource>. <message from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>Art thou not Romeo, and a Montague?</body> </message> If the message is being sent in reply to a message previously received from an address of the form <user@domain/resource> (e.g., within the context of a one-to-one chat session as described under Section 5.1), the value of the 'to' address SHOULD be of the form <user@domain/resource> rather than of the form <user@domain> unless the sender has knowledge (via presence) that the intended recipient's resource is no longer available. <message from='romeo@example.net/orchard' to='juliet@example.com/balcony' type='chat' xml:lang='en'> <body>Neither, fair saint, if either thee dislike.</body> </message>5.1.2.5.2.2. Type Attribute Common uses of the message stanza in instant messaging applicationsincludeinclude: singlemessages,messages; messages sent in the context of a one-to- one chatconversation,session; messages sent in the context of a multi-user chatroom, headlines and otherroom; alerts, notifications, or other information to which no reply is expected; and errors. These uses are differentiated via the 'type' attribute. Inclusion of the 'type' attribute is RECOMMENDED. If included, the 'type' attribute MUST have one of the following Saint-Andre Expires January 13, 2009 [Page 53] Internet-Draft XMPP IM July 2008 values: o chat -- The message is sent in the context of a one-to-one chat session. A receiving client SHOULD present the message in an interface enabling one-to-one chat between the two parties, including an appropriate conversation history. Detailed recommendations regarding one-to-one chat sessions are provided under Section5.4.5.1. o error -- The message is generated by an entity that experiences an error in processing a message received from another entity (for details regarding stanza error syntax, refer to [XMPP-CORE]). A client that receives a message of type "error" SHOULD present an appropriate interface informing the sender of the nature of the error. o groupchat -- The message is sent in the context of a multi-user chat environment (similar to that of [IRC]). A receiving client SHOULD present the message in an interface enabling many-to-manySaint-Andre Expires December 8, 2008 [Page 46] Internet-Draft XMPP IM June 2008chat between the parties, including a roster of parties in the chatroom and an appropriate conversation history.Full definitionDefinition of XMPP-based groupchatprotocolsfunctionality is out of scope for this document (for details, refer to [XEP-0045]). o headline -- The messageis probably generated byprovides anautomated service that deliversalert, a notification, orbroadcasts content (news, sports,other information to which no reply is expected (e.g., news headlines, sports updates, near-real-time marketinformation,data, and syndicatedcontent, alerts, etc.), or the sender wishes the message to be delivered as if it were so generated. Nocontent). Because no reply to the message is expected, and a receiving client SHOULD present the message in an interface that appropriately differentiates the message from standalone messages, chatsessions,messages, or groupchatsessionsmessages (e.g., by not providing the recipient with the ability to reply). The receiving server SHOULD deliver the message to all of the recipient's available resources. o normal -- The message is a standalone message that is sent outside the context of a one-to-one conversation or groupchat, and to which it is expected that the recipient will reply. A receiving client SHOULD present the message in an interface enabling the recipient to reply, but without a conversation history. This is the default value of the 'type' attribute. An IM application SHOULD support all of the foregoing message types. If an application receives a message with no 'type' attribute or the application does not understand the value of the 'type' attribute provided, it MUST consider the message to be of type "normal" (i.e., "normal" is the default). Although the 'type' attribute is OPTIONAL, it is considered polite to mirror the type in any replies to a message; furthermore, some specialized applications (e.g., a multi-user chat service) MAY at their discretion enforce the use of a particular message type (e.g.,type='groupchat'). 5.2. Child Elements An XMPP message stanza MAY contain any allowable child elements qualified by the 'jabber:client' (or 'jabber:server') namespace, as well as any other properly-namespaced child element that consists of extended content. The defined payloads are described in the following sections and extended content payloads are described in the appropriateSaint-Andre Expires January 13, 2009 [Page 54] Internet-Draft XMPPextension specifications (not herein). 5.2.1.IM July 2008 type='groupchat'). 5.2.3. Body Element The <body/> element contains human-readable XML character data that specifies the textual contents of the message; this child element is normally included but is OPTIONAL.Saint-Andre Expires December 8, 2008 [Page 47] Internet-Draft XMPP IM June 2008<messageto='romeo@example.net'from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>Wherefore art thou, Romeo?</body> </message> The <body/> element MUST NOT possess any attributes, with the exception of the 'xml:lang' attribute. Multiple instances of the <body/> element MAY be included in a message stanza, but only if each instance possesses an 'xml:lang' attribute with a distinct language value (either explicitly or by inheritance from the 'xml:lang' value of an element farther up in the XML hierarchy, whichmaycan include the XML stream header as described in [XMPP-CORE]). <messageto='romeo@example.net'from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>Wherefore art thou, Romeo?</body> <body xml:lang='cs'> PročeŽ jsi ty, Romeo? </body> </message> The <body/> element MUST NOT contain mixed content (as defined in Section 3.2.2 of [XML]).5.2.2.5.2.4. Subject Element The <subject/> element contains human-readable XML character data that specifies the topic of the message. Saint-Andre Expires January 13, 2009 [Page 55] Internet-Draft XMPP IM July 2008 <messageto='romeo@example.net'from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <subject>I implore you!</subject> <body>Wherefore art thou, Romeo?</body> </message> The <subject/> element MUST NOT possess any attributes, with the exception of the 'xml:lang' attribute. Multiple instances of the <subject/> element MAY be included for the purpose of providing alternate versions of the same subject, but only if each instanceSaint-Andre Expires December 8, 2008 [Page 48] Internet-Draft XMPP IM June 2008possesses an 'xml:lang' attribute with a distinct language value (either explicitly or by inheritance from the 'xml:lang' value of an element farther up in the XML hierarchy, whichmaycan include the XML stream header as described in [XMPP-CORE]). <messageto='romeo@example.net'from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <subject>I implore you!</subject> <subject xml:lang='cs'> Úpěnlivě prosím! </subject> <body>Wherefore art thou, Romeo?</body> <body xml:lang='cs'> Pročež jsi ty, Romeo? </body> </message> The <subject/> element MUST NOT contain mixed content (as defined in Section 3.2.2 of [XML]).5.2.3.5.2.5. Thread Element The primary use of the XMPP <thread/> element is to uniquely identify a conversation thread or "chat session" between two entities instantiated by <message/> stanzas of type 'chat'. However, the XMPP <thread/> elementmaycan also be used to uniquely identify an analogous thread between two entities instantiated by <message/> stanzas of type 'headline' or 'normal', or among multiple entities in the context of a multi-user chat room instantiated by <message/> stanzas of type 'groupchat'. ItmayMAY also be used for <message/> stanzas not related to a human conversation, such as a game session or an interaction between plugins. The <thread/> element is not used to Saint-Andre Expires January 13, 2009 [Page 56] Internet-Draft XMPP IM July 2008 identify individual messages, onlyconversations.conversations or messagingg sessions. The inclusion of the <thread/> element is OPTIONAL. Because the <thread/> element uniquely identifies the particular conversation thread to which a message belongs, a message stanza MUST NOT contain more than one <thread/> element. The value of the <thread/> element is not human-readable and MUST be treated as opaque by entities; no semantic meaningmaycan be derived from it, and only exact comparisonsmaycan be made against it. The value of the <thread/> element MUST be a universally unique identifier (UUID) as described in [UUID].Saint-Andre Expires December 8, 2008 [Page 49] Internet-Draft XMPP IM June 2008The <thread/> element MAY possess a 'parent' attribute that identifies another thread of which the current thread is an offshoot or child; thevalue of the 'parent' MUST conform to the syntax of the <thread/> element itself. The <thread/> element MUST NOT contain mixed content (as defined in Section 3.2.2 of [XML]). <message to='romeo@example.net' from='juliet@example.com/balcony' type='chat' xml:lang='en'> <subject>I implore you!</subject> <subject xml:lang='cs'> Úpěnlivě prosím! </subject> <body>Wherefore art thou, Romeo?</body> <body xml:lang='cs'> Pročež jsi ty, Romeo? </body> <thread parent='e0ffe42b28561960c6b12b944a092794b9683a38'> 0e3141cd80894871a68e6fe6b1ec56fa </thread> </message> For detailed recommendations regarding use of the <thread/> element, refer to [XEP-0201]. 5.3. Extended Content As described in [XMPP-CORE], an XML stanza MAY contain any properly- namespaced child element; this applies to the message stanza as well. (In the following example, the message stanza includes an XHTML- formatted version of the message as defined in [XEP-0071]).) <message to='romeo@example.net' from='juliet@example.com/balcony' type='chat' xml:lang='en'> <body>Wherefore art thou, Romeo?</body> <html xmlns='http://jabber.org/protocol/xhtml-im'> <body xmlns='http://www.w3.org/1999/xhtml'> Wherefore <span style='font-style: italic'>art</span> thou, <span style='color:red'>Romeo</span>? </body> </html> </message> Saint-Andre Expires December 8, 2008 [Page 50] Internet-Draft XMPP IM June 2008 5.4. One-to-One Chat Sessions In practice, instant messaging activity between human users tends to occur in form of a conversational burst that we call a CHAT SESSION: the exchange of at least several messages between two parties in relatively rapid succession within a relatively brief period of time. When a human user intends to engage in such a chat session with a contact (rather than sending a single message to which no reply is expected), the user's client SHOULD send a message of type "chat" and the contact's client SHOULD preserve that message type in subsequent replies. The user's client also SHOULD include a <thread/> element on its initial message, which the contact's client SHOULD also preserve during the life of the chat session. The user's client MUST address the initial message in a chat session to the bare JID <contact@domain> (rather than attempting to guess an appropriate full JID <contact@domain/resource>). Until and unless the user's client receives a reply from the contact, it MUST continue sending any further messages to the contact's bare JID. The contact's client SHOULD address its subsequent replies to the user's full JID <user@domain/resource> as provided in the 'from' address of the initial message. Once the user's client receives a reply from the contact's full JID, it SHOULD address its subsequent messages to the contact's full JID as provided in the 'from' addressvalue of thecontact's replies. If a user exchanges messages with a contact but the user does not normally share presence with'parent' MUST conform to thecontact via a presence subscription, it is RECOMMENDED forsyntax of theuser's client to send directed presence to<thread/> element itself. The <thread/> element MUST NOT contain mixed content (as defined in Section 3.2.2 of [XML]). <message from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <subject>I implore you!</subject> <subject xml:lang='cs'> Úpěnlivě prosím! </subject> <body>Wherefore art thou, Romeo?</body> <body xml:lang='cs'> Pročež jsi ty, Romeo? </body> <thread parent='e0ffe42b28561960c6b12b944a092794b9683a38'> 0e3141cd80894871a68e6fe6b1ec56fa </thread> </message> For detailed recommendations regarding use of thecontact, subject<thread/> element, refer touser approval (either explicitly for this contact or implicitly via a configuration setting). If[XEP-0201]. 5.3. Extended Content As described in [XMPP-CORE], an XML stanza MAY contain any child element that is qualified by aclient supports this feature, it MUST allownamespace other than theuserdefault namespace; this applies todisablethefeature in order to prevent presence sharing with unknown entities. An examplemessage stanza as well. Saint-Andre Expires January 13, 2009 [Page 57] Internet-Draft XMPP IM July 2008 (In the following example, the message stanza includes an XHTML- formatted version ofa chat sessionthe message asdescribed above is provided under Section 7.defined in [XEP-0071]).) <message from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>Wherefore art thou, Romeo?</body> <html xmlns='http://jabber.org/protocol/xhtml-im'> <body xmlns='http://www.w3.org/1999/xhtml'> Wherefore <span style='font-style: italic'>art</span> thou, <span style='color:red'>Romeo</span>? </body> </html> </message> 6. Exchanging IQ Stanzas As described in [XMPP-CORE], IQ stanzas provide a structured request- response mechanism. The basic semantics of that mechanism (e.g., that the 'id' attribute isrequired)mandatory) are defined in [XMPP-CORE], whereas the specific semanticsrequiredneeded to complete particular use cases are defined in allcasesinstances by the extended namespace that qualifies the direct child element of an IQ stanza of type "get" or "set". The 'jabber:client' and 'jabber:server' namespaces do notSaint-Andre Expires December 8, 2008 [Page 51] Internet-Draft XMPP IM June 2008define any children of IQ stanzas other than the <error/> element common to all stanza types. This document defines one such extended namespace, for Managing the Roster (Section 2). However, an IQ stanza MAY contain structured information qualified by any extended namespace. As noted under Section 4.6, if a user exchanges IQ stanzas with another entity but does not share presence with the entity based on a presence subscription, it is RECOMMENDED for the user's client to send directed presence to the other entity. 7. A Sample Session The examples in this section illustrate a possible instant messaging and presence session. The user is romeo@example.net, he has an available resource whose resource identifier is "orchard", and he has the following individuals in his roster: Saint-Andre Expires January 13, 2009 [Page 58] Internet-Draft XMPP IM July 2008 o juliet@example.com (subscription="both" and she has two available resources, one whose resource identifier is "chamber" and another whose resource identifier is "balcony") obenvolio@example.orgbenvolio@example.net (subscription="to") o mercutio@example.org (subscription="from") First, the user completes the preconditions (stream establishment, TLS and SASL negotiation, and resource binding) described in [XMPP-CORE]; those protocol flows are not reproduced here. Next, the user requests his roster. Example 1: User requests current roster from server: UC: <iq from='romeo@example.net/balcony'type='get' id='ex1'>id='ex1' type='get'> <query xmlns='jabber:iq:roster'/> </iq>Saint-Andre Expires December 8, 2008 [Page 52] Internet-Draft XMPP IM June 2008Example 2: User receives roster from server: US: <iq to='romeo@example.net/balcony'type='result' id='ex1'>id='ex1' type='result'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.com' name='Juliet' subscription='both'> <group>Friends</group> </item> <item jid='benvolio@example.org' name='Benvolio' subscription='to'/> <item jid='mercutio@example.org' name='Mercutio' subscription='from'/> </query> </iq> Now the user begins a presence session. Example 3: User sends initial presence: UC: <presence from='romeo@example.net/orchard'/> Saint-Andre Expires January 13, 2009 [Page 59] Internet-Draft XMPP IM July 2008 Example 4: User's server sends presence probes to contacts with subscription="to" and subscription="both" on behalf of the user's available resource: US: <presencetype='probe'from='romeo@example.net/orchard'to='juliet@example.com'/>to='juliet@example.com' type='probe'/> US: <presencetype='probe'from='romeo@example.net/orchard'to='benvolio@example.org'/>to='benvolio@example.org' type='probe'/> Example 5: User's server sends initial presence to contacts with subscription="from" and subscription="both" on behalf of the user's available resource: US: <presence from='romeo@example.net/orchard' to='juliet@example.com'/> US: <presence from='romeo@example.net/orchard' to='mercutio@example.org'/> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page53]60] Internet-Draft XMPP IMJuneJuly 2008to='mercutio@example.org'/>Example 6: Contacts' servers reply to presence probe on behalf of all available resources: CS: <presence from='juliet@example.com/balcony' to='romeo@example.net/orchard' xml:lang='en'> <show>away</show> <status>be right back</status> <priority>0</priority> </presence> CS: <presence from='juliet@example.com/chamber' to='romeo@example.net/orchard'> <priority>1</priority> </presence> CS: <presence from='benvolio@example.org/pda' to='romeo@example.net/orchard' xml:lang='en'> <show>dnd</show> <status>gallivanting</status> </presence> Example 7: Contacts' servers deliver user's initial presence to all availableresources or return unsubscribed to user:resources: CS: <presence from='romeo@example.net/orchard' to='juliet@example.com'/> CS: <presence from='romeo@example.net/orchard' to='juliet@example.com'/> CS: <presence from='mercutio@example.org'to='romeo@example.net' type='unsubscribed'/>to='romeo@example.net'/> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page54]61] Internet-Draft XMPP IMJuneJuly 2008 Example 8: User sends directed presence to another user not in his roster: UC: <presence from='romeo@example.net/orchard' to='nurse@example.com' xml:lang='en'> <show>dnd</show> <status>courting Juliet</status> <priority>0</priority> </presence> Now the userhasengages in a chat session with one of his contacts. Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page55]62] Internet-Draft XMPP IMJuneJuly 2008 Example 9: A threaded conversation CC: <message from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>My ears have not yet drunk a hundred words</body> <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread> </message> CC: <message from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>Of that tongue's utterance, yet I know the sound:</body> <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread> </message> CC: <message from='juliet@example.com/balcony' to='romeo@example.net' type='chat' xml:lang='en'> <body>Art thou not Romeo, and a Montague?</body> <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread> </message> UC: <message from='romeo@example.net/orchard' to='juliet@example.com/balcony' type='chat' xml:lang='en'> <body>Neither, fair saint, if either thee dislike.</body> <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread> </message> CC: <message from='juliet@example.com/balcony' to='romeo@example.net/orchard' type='chat' xml:lang='en'> <body>How cam'st thou hither, tell me, and wherefore?</body> <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread> </message> And so on. Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page56]63] Internet-Draft XMPP IMJuneJuly 2008 The user can also send subsequentbroadcasted presence.presence broadcast. Example 10: User sends updated available presence for broadcasting: UC: <presence xml:lang='en'> <show>away</show> <status>I shall return!</status> <priority>1</priority> </presence> Example 11: User's server broadcasts updated presence only to one contact: US: <presence from='romeo@example.net/orchard' to='juliet@example.com' xml:lang='en'> <show>away</show> <status>I shall return!</status> <priority>1</priority> </presence> Example 12: Contact's server delivers updated presence to all of the contact's available resources ("balcony" and "chamber"): CS: <presence from='romeo@example.net/orchard' to='juliet@example.com' xml:lang='en'> <show>away</show> <status>I shall return!</status> <priority>1</priority> </presence> CS: <presence from='romeo@example.net/orchard' to='juliet@example.com' xml:lang='en'> <show>away</show> <status>I shall return!</status> <priority>1</priority> </presence> Example 13: One of the contact's resources broadcasts unavailable presence: CC: <presence from='juliet@example.com/chamber' type='unavailable'/> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page57]64] Internet-Draft XMPP IMJuneJuly 2008 Example 14: Contact's server sends unavailable presence to user: CS: <presencetype='unavailable'from='juliet@example.com/chamber'to='romeo@example.net'/>to='romeo@example.net' type='unavailable'/> Now the user ends his presence session. Example 15: User sends unavailable presence: UC: <presence from='romeo@example.net/orchard' type='unavailable' xml:lang='en'> <status>gone home</status> </presence> Example 16: User's server broadcasts unavailable presence tocontactcontacts as well as to the person to whom the user sent directed presence: US: <presencetype='unavailable'from='romeo@example.net/orchard' to='juliet@example.com' type='unavailable' xml:lang='en'> <status>gone home</status> </presence> US: <presencetype='unavailable'from='romeo@example.net/orchard' to='nurse@example.com' type='unavailable' xml:lang='en'> <status>gone home</status> </presence> Finally the user closes his stream and the server responds in kind. Example 17: User closes stream: UC: </stream:stream> Example 18: User's server closes stream: US: </stream:stream> THE END Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page58]65] Internet-Draft XMPP IMJuneJuly 2008 8. Server Rules for Processing XML Stanzas Basic server rules for processing XML stanzas are defined in [XMPP-CORE]. This section defines supplementary rules for XMPP instant messaging and presence servers; in the absence of a supplementary rule defined below (e.g., for stanzas without a 'to' address), the rule defined in [XMPP-CORE]shall apply.applies. 8.1. No Such User If the user account identified by the 'to' attribute does not exist, how the stanzashall beis processed depends on the stanza type. o For an IQ stanza, the server MUST return a <service-unavailable/> stanza error to the sender. o For a message stanza, the serverSHOULDMUST return a <service- unavailable/> stanza error to the sender. o For a presence stanza with no 'type' attribute or a 'type' attribute of "unavailable", the serverSHOULDMUST silently ignore the stanza. o For a presence stanza(i.e., notof type "subscribe", the server MUST returnan error ora presence stanza of type"unsubscribed")."unsubscribed". o For a presence stanza of type"subscribe","subscribed", "unsubscribe", or "unsubscribed", the server MUSTfollowsilently ignroe theguidelines provided under Section 3.stanza. 8.2. Full JID at Local Domain If the hostname of the domain identifier portion of the JID contained in the 'to' attribute of an inbound stanza matches one of the configured hostnames of the server itself and the JID contained in the 'to' attribute is of the form <user@domain/resource>, the server MUST adhere to the following rules. 8.2.1. Available Resource Matches If an available resource exactly matches the full JID, how therecipient's server MUST deliverstanza is processed depends on the stanzato that resource (subject to appropriate security policies as described under Section 11 and in [XMPP-CORE]). However, fortype. o For an IQ stanzas of type "get" or "set", if the intended recipient does not share presence with the requesting entity either by means of a presence subscription of type "both" or "from" or by means of directed presence, then the server SHOULD NOT deliver the IQ stanza but instead SHOULD return a<service-unavailable/><service- unavailable/> stanza error to the requesting entity. This policy helps to prevent presence leaks (see Section 11). o For a message stanza, the server MUST deliver the stanza to the resource. Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page59]66] Internet-Draft XMPP IMJuneJuly 2008 o For a presence stanza with no 'type' attribute or a 'type' attribute of "unavailable", the server MUST deliver the stanza to the resource. o For a presence stanza of type "subscribe", the server MUST follow the guidelines provided under Section 3.1.3. o For a presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST follow the guidelines provided under Section 3. 8.2.2. No Available Resource Matches If no connected or available resource exactly matches the full JID, how the stanzashall beis processed depends on the stanzatype.type. o For an IQ stanza, the server MUST return a <service-unavailable/> stanza error to the sender. o For amessage,message stanza, the server SHOULD treat the stanza as if it were addressed to <user@domain> as described in the next section. o For a presence stanza with no 'type' attribute or a 'type' attribute of "unavailable", the serverSHOULDMUST silently ignore thestanza (i.e., not return an error or a presence stanza of type "unsubscribed").stanza. o For a presence stanza of type "subscribe","subscribed", "unsubscribe", or "unsubscribed",the server MUST follow the guidelines provided under Section3.3.1.3. o Foran IQ stanza,a presence stanza of type "subscribed", "unsubscribe", or "unsubscribed", the server MUSTreturn a <service-unavailable/> stanza error toignore thesender.stanza. 8.3. Bare JID at Local Domain If the hostname of the domain identifier portion of the JID contained in the 'to' attribute of an inbound stanza matches one of the configured hostnames of the server itself and the JID contained in the 'to' attribute is of the form <user@domain>, the server MUST adhere to the following rules. 8.3.1. Available Resources If there is at least one available resource, how the stanzashall beis processed depends on the stanza type. 8.3.1.1. Message For a message stanza of type "headline", the server SHOULD deliver the stanza to all available resources. For a message stanza of type "chat", "error", "groupchat", or "normal", the server SHOULD deliver the stanza to the highest- priority available resource. If there is not one highest-priority available resource but instead the highest priority is asserted by Saint-Andre Expires January 13, 2009 [Page 67] Internet-Draft XMPP IM July 2008 two or more available resources, these resources are said to form a "delivery tie". In the case of a delivery tie, a server SHOULD deliver the message to all of the tied resources. However, before delivering the message, a server MAY remove one or more resources from the tie. Methods for doing so are outside the scope of this specification, but could include factors such as the resource's time of connection, time of last network or application activity, availability as determined by some hierarchy of <show/> values, or user-configured rules. Nevertheless, a server MUST NOT remove allSaint-Andre Expires December 8, 2008 [Page 60] Internet-Draft XMPP IM June 2008resources from the tie, and MUST deliver the message to at least one of the highest-priority resources (subject to appropriate security policies as described under Section 11 and in [XMPP-CORE]). However, for any message type the server MUST NOT deliver the stanza to any available resource with a negative priority; if the only available resource has a negative priority, the server SHOULD handle the message as if there were no available resources as described under Section 8.3.2. In all cases, the server MUST NOT rewrite the 'to' attribute (i.e., it MUST leave it as <user@domain> rather than change it to <user@domain/resource>). 8.3.1.2. Presence For a presence stanza of type "probe", the server MUST handle it directly as described under Section 4.3. For a presence stanza with no type or of type "unavailable", the server MUST deliver the stanza to all available resources. For a presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST adhere to the rules defined under Section 3 and summarized under Appendix A. In all cases, the server MUST NOT rewrite the 'to' attribute (i.e., it MUST leave it as <user@domain> rather than change it to <user@domain/resource>). 8.3.1.3. IQ For an IQ stanza, the server itself MUST reply on behalf of the user with either an IQ result or an IQ error, and MUST NOT deliver the IQ stanza to any of the user's available resources. Specifically, if the semantics of the qualifying namespace define a reply that the server can provide on behalf of the user, the server MUST reply to the stanza on behalf of the user by returning either an IQ stanza of type "result" or an IQ stanza of type "error" that is appropriate to Saint-Andre Expires January 13, 2009 [Page 68] Internet-Draft XMPP IM July 2008 the original payload; if not, the server MUST reply with a <service- unavailable/> stanza error. 8.3.2. No Available Resources If there are no available resources associated with the user, how the stanzashall beis processed depends on the stanza type.Saint-Andre Expires December 8, 2008 [Page 61] Internet-Draft XMPP IM June 20088.3.2.1. Message In order to properly handle message stanzas, it is strongly RECOMMENDED for an implementation to support,OFFLIST STORAGE, i.e., the server SHOULD store the stanza on behalf of the user and deliver it when the user next becomes available. For recommendations regarding offline message storage refer to [XEP-0160]. For a message stanza of type "chat", "groupchat", or "normal", the server SHOULD add the message to offline storage or forward the message to the user via a non-XMPP messaging system (e.g., to the user's email account). However, if offline message storage or message forwarding is not enabled, the serverSHOULDMUST return a<service-unavailable/><service- unavailable/> stanza error to the sender. For a message stanza of type "headline", the server SHOULD NOTaddedadd the message to offline storage but instead SHOULD silently discard the message (i.e., neither deliver it to the intended recipient nor return an error to the sender). For a message stanza of type "error", the server MUST NOTaddedadd the message to offline storage but instead SHOULD silently discard the message (i.e., neither deliver it to the intended recipient nor return an error to the sender). 8.3.2.2. Presence For a presence stanza with no type or of type "unavailable" or "probe", the server SHOULD silently ignore the stanza by not storing it for later delivery and not replying to it on behalf of the user. For a presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST adhere to the rules defined under Section 3 and summarized under Appendix A. 8.3.2.3. IQ For an IQ stanza, the server itself MUST reply on behalf of the user with either an IQ result or an IQ error. Specifically, if the semantics of the qualifying namespace define a reply that the server Saint-Andre Expires January 13, 2009 [Page 69] Internet-Draft XMPP IM July 2008 can provide on behalf of the user, the server MUST reply to the stanza on behalf of the user by returning either an IQ stanza of type "result" or an IQ stanza of type "error" that is appropriate to the original payload; if not, the server MUST reply with a <service- unavailable/> stanza error.Saint-Andre Expires December 8, 2008 [Page 62] Internet-Draft XMPP IM June 20088.4.ForeignRemote Domain If the hostname of the domain identifier portion of the address contained in the 'to' attribute of an outbound stanza does not match a configured hostname of the server itself, the server MUST attempt to route the stanza to theforeignremote domain. If there exists an active stream between the two peers, the servershallMUST route the stanza over that stream for processing by the peer server. If not, the server MUST do the following. First, resolve the hostname of theforeignremote domain (or use a cached resolution of theforeignremote domain to an IP address). TherecommendedRECOMMENDED order of attempted resolutions is as follows: 1. Attempt to resolve theforeignremote hostname using a DNS service location record [SRV] Service of "xmpp-server" and a Proto of "tcp", resulting in resource records such as "_xmpp- server._tcp.example.com.", as specified in [XMPP-CORE]. 2. If the "xmpp-server" address record resolution fails, attempt to resolve the "_im" or "_pres" SRV Service as specified in [IMP-SRV], using the "_im" Service for <message/> stanzas and the "_pres" Service for <presence/> stanzas (it is up to the implementation how to handle <iq/> stanzas). This will result in one or more resolutions of the form "_im.<proto>.example.com." or "_pres.<proto>.example.com.", where "<proto>" would be a label registered in the Instant Messaging SRV Protocol Label registry or the Presence SRV Protocol Label registry: either "_xmpp" for an XMPP-aware domain or some other IANA-registered label (e.g., "_simple") for a non-XMPP-aware domain. 3. If both SRV address record resolutions fail, attempt to perform a normal IPv4/IPv6 address record resolution to determine the IP address using the "xmpp-server" port of 5269 registered with the IANA, as specified in [XMPP-CORE]. If the server cannot resolve theforeignremote domain, itSHOULDMUST return a <remote-server-not-found/> stanza error. Second, negotiate XML streams with theforeignremote domain by following the process defined in [XMPP-CORE]. If the server can resolve theforeignremote domain but cannot establish streams with the XMPP service at that domain, itSHOULDMUST return a <remote-server-timeout/> stanza error. Saint-Andre Expires January 13, 2009 [Page 70] Internet-Draft XMPP IM July 2008 Third, route the stanza to theforeignremote domain for processing by the peer server. Note: Administrators of server deployments are strongly encouraged to keep the _im._xmpp, _pres._xmpp, and _xmpp._tcp SRV records properlySaint-Andre Expires December 8, 2008 [Page 63] Internet-Draft XMPP IM June 2008synchronized, since different implementations might perform the "_im" and "_pres" lookups before the "xmpp-server" lookup. 9. IM and Presence Compliance Requirements This section summarizes the specific aspects of the Extensible Messaging and Presence Protocol that MUST be supported by instant messaging and presence servers and clients in order to be considered compliant implementations. All such applications MUST comply with the requirements specified in [XMPP-CORE]. The text in this section specifies additional compliance requirements for instant messaging and presence servers and clients (the requirements described here supplement but do not supersede the core requirements). Note: A server or client MAY support only presence or instantmessaging, andmessaging; therefore is notrequirednecessary to support both if only a presence service or an instant messaging service is desired. 9.1. Servers In addition to the core server compliance requirements, an instant messaging and presence server MUST additionally support all server- related instant messaging and presence syntax and semantics defined in this document, including: o Presence broadcast on behalf of clients as specified under Section 4 o Presence subscriptions as specified under Section 3 o Roster storage and management as specified under Section 2 o IM-specific routing and delivery rules as specified under Section 8 9.2. Clients In addition to the core client compliance requirements, an instant messaging and presence client MUST additionally support the following protocols: o Generation and processing of the IM-specific semantics of XML stanzas as defined by the XML schemas, including the 'type' attribute of message and presence stanzas as well as their child elements (see Section 5 and Section 4) Saint-Andre Expires January 13, 2009 [Page 71] Internet-Draft XMPP IM July 2008 o All client-related instant messaging syntax and semantics defined in this document, including presence subscriptions and roster management (see Section 3 and Section 2)Saint-Andre Expires December 8, 2008 [Page 64] Internet-Draft XMPP IM June 2008 o End-to-end object signing and encryption as defined in [XMPP-E2E]A client MUST also handle addresses that are encoded as "im:" URIs as specified in [CPIM] and "pres:" URIs as specified in [CPP], although it MAY do so by removing the "im:" or "pres:" scheme and entrusting address resolution to the server as specified under Section 8.4. A client SHOULD also handle addresses that are encoded as "xmpp:" URIs and IRIs as specified in[XMPP-URI].[XMPP-URI], although here again it MAY do so by removing the scheme and entrusting address resolution to the server. 10. Internationalization Considerations For internationalization considerations, refer to the relevant section of [XMPP-CORE]. 11. Security Considerations Core security considerations for XMPP are defined in the relevant section of [XMPP-CORE]. Additional considerations that apply only to instant messaging and presence applications of XMPP are defined in several places within this document; specifically: o When a server processes an inbound presence stanza of type "probe" whose intended recipient is a user associated with one of the server's hostnames, the server MUST NOT reveal the user's presence if the sender is an entity that is not authorized to receive that information as determined by presence subscriptions (seeExchanging Presence Information (Section 4)).Section 4). o A user's server MUST NOT leak the user's network availability to entities who are not authorized to know the user's presence, either via an explicit subscription as described herein or via an existing trust relationship (such as presence-enabled user directories within organizations). o When a server processes an outbound presence stanza with no type or of type "unavailable", it MUST follow the rules defined underExchanging Presence Information (Section 4)Section 4 in order to ensure that such presence information is notbroadcastedsent to entities that are not authorized to know such information. o When a server generates an error stanza in response to receiving a stanza for a userwhoaccount that does not exist, the use of the<service- unavailable/><service-unavailable/> stanza error condition can help protect against dictionary attacks, since this is the same error condition Saint-Andre Expires January 13, 2009 [Page 72] Internet-Draft XMPP IM July 2008 that is returned if, for instance, the namespace of an IQ child element is not understood, or if offline message storage or message forwarding is not enabled for a domain. However, subtle differences in theSaint-Andre Expires December 8, 2008 [Page 65] Internet-Draft XMPP IM June 2008exact XML of error stanzas, as well as in the timing with which such errors are returned, can enable an attacker to determine the network presence of a user when more advanced blocking technologies are not used (see for instance[XEP-0016]).[XEP-0016] and [XEP-0191]). o A client MAY ignore the <status/> element when contained in a presence stanza of type "subscribe", "unsubscribe", "subscribed", or"unsubscribed" in order to"unsubscribed"; this can help prevent "presence subscription spam". 12. IANA Considerations The following sections update the registrations provided in [RFC3921]. For a number of related IANA considerations, refer to the relevant section of [XMPP-CORE]. 12.1. Instant Messaging SRV Protocol Label Registration Address Resolution for Instant Messaging and Presence [IMP-SRV] defines an Instant Messaging SRV Protocol Label registry for protocols that can provide services that conform to the "_im" SRV Service label. Because XMPP is one such protocol, the IANA registers the "_xmpp" protocol label in the appropriate registry, as follows: Protocol label: _xmpp Specification: XXXX Description: Instant messaging protocol label for the Extensible Messaging and Presence Protocol (XMPP) as defined by XXXX. Registrant Contact: IETF, XMPP Working Group, <xmppwg@xmpp.org> 12.2. Presence SRV Protocol Label Registration Address Resolution for Instant Messaging and Presence [IMP-SRV] defines a Presence SRV Protocol Label registry for protocols that can provide services that conform to the "_pres" SRV Service label. Because XMPP is one such protocol, the IANA registers the "_xmpp" protocol label in the appropriate registry, as follows: Saint-Andre Expires January 13, 2009 [Page 73] Internet-Draft XMPP IM July 2008 Protocol label: _xmpp Specification: XXXX Description: Presence protocol label for the Extensible Messaging and Presence Protocol (XMPP) as defined by XXXX.Saint-Andre Expires December 8, 2008 [Page 66] Internet-Draft XMPP IM June 2008Registrant Contact: IETF, XMPP Working Group, <xmppwg@xmpp.org> 13. References 13.1. Normative References [IMP-REQS] Day, M., Aggarwal, S., and J. Vincent, "Instant Messaging / Presence Protocol Requirements", RFC 2779, February 2000. [IMP-SRV] Peterson, J., "Address Resolution for Instant Messaging and Presence", RFC 3861, August 2004. [SRV] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for specifying the location of services (DNS SRV)", RFC 2782, February 2000. [TERMS] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. [UUID] Leach, P., Mealling, M., and R. Salz, "A Universally Unique IDentifier (UUID) URN Namespace", RFC 4122, July 2005. [XML] Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., and T. Bray, "Extensible Markup Language (XML) 1.0 (Fourth Edition)", World Wide Web Consortium Recommendation REC- xml-20060816, August 2006, <http://www.w3.org/TR/2006/REC-xml-20060816>. [XML-NAMES] Bray, T., Hollander, D., and A. Layman, "Namespaces in XML", W3C REC-xml-names, January 1999, <http://www.w3.org/TR/REC-xml-names>. [XMPP-CORE] Saint-Andre, P., "Extensible Messaging and Presence Protocol (XMPP): Core", draft-saintandre-rfc3920bis-04 (work in progress), October 2007.[XMPP-E2E][XMPP-URI] Saint-Andre, P.,"End-to-End Signing and Object Encryption for the Extensible Messaging and Presence Protocol (XMPP)", RFC 3923, October 2004. [XMPP-URI]"Internationalized Resource Identifiers Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page67]74] Internet-Draft XMPP IMJuneJuly 2008Saint-Andre, P., "Internationalized Resource Identifiers(IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP)", RFC 4622, July 2006. 13.2. Informative References [CPIM] Peterson, J., "Common Profile for Instant Messaging (CPIM)", RFC 3860, August 2004. [CPP] Peterson, J., "Common Profile for Presence (CPP)", RFC 3859, August 2004. [IMP-MODEL] Day, M., Rosenberg, J., and H. Sugano, "A Model for Presence and Instant Messaging", RFC 2778, February 2000. [IRC] Kalt, C., "Internet Relay Chat: Architecture", RFC 2810, April 2000. [IRI] Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, January 2005. [RFC3921] Saint-Andre, P., "Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence", RFC 3921, October 2004. [SASL] Melnikov, A. and K. Zeilenga, "Simple Authentication and Security Layer (SASL)", RFC 4422, June 2006. [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security (TLS) Protocol Version 1.1", RFC 4346, April 2006. [XEP-0016] Millard, P. and P. Saint-Andre, "Privacy Lists", XSF XEP 0016, February 2007. [XEP-0045] Saint-Andre, P., "Multi-User Chat", XSF XEP 0045,April 2007.January 2008. [XEP-0054] Saint-Andre, P., "vcard-temp", XSF XEP 0054, March 2003. [XEP-0071] Saint-Andre, P., "XHTML-IM", XSF XEP 0071, August 2007. [XEP-0115] Hildebrand, J., Saint-Andre, P., and R. Troncon, "EntityCapabilities", XSF XEP 0115, August 2007.Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page68]75] Internet-Draft XMPP IMJuneJuly 2008 Capabilities", XSF XEP 0115, February 2008. [XEP-0160] Saint-Andre, P., "Best Practices for Handling Offline Messages", XSF XEP 0160, January 2006. [XEP-0191] Saint-Andre, P., "Simple Communications Blocking", XSF XEP 0191, February 2007. [XEP-0201] Saint-Andre, P., Paterson, I., and K. Smith, "Best Practices for Message Threads", XSF XEP 0201,August 2007.February 2008. [XML-SCHEMA] Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, "XML Schema Part 1: Structures Second Edition", World Wide Web Consortium Recommendation REC-xmlschema-1-20041028, October 2004, <http://www.w3.org/TR/2004/REC-xmlschema-1-20041028>. [VCARD] Dawson, F. and T. Howes, "vCard MIME Directory Profile", RFC 2426, September 1998. Appendix A. Subscription States This section provides detailed information about subscription states and server processing of subscription-related presence stanzas (i.e., presence stanzas of type "subscribe", "subscribed", "unsubscribe", and "unsubscribed"). A.1. Defined States There are four primary subscription states (note: these states are described from the perspective of the user, not the contact): o None -- the user does not have a subscription to the contact's presence, and the contact does not have a subscription to the user's presence o To -- the user has a subscription to the contact's presence, but the contact does not have a subscription to the user's presence o From -- the contact has a subscription to the user's presence, but the user does not have a subscription to the contact's presence o Both -- both the user and the contact have subscriptions to each other's presence (i.e., the union of 'from' and 'to') Saint-Andre Expires January 13, 2009 [Page 76] Internet-Draft XMPP IM July 2008 These states are supplemented by various pending sub-states to yield nine possible subscription states: 1. "None" = contact and user are not subscribed to each other, and neither has requested a subscription from the other; this is reflected in the user's roster by subscription='none'Saint-Andre Expires December 8, 2008 [Page 69] Internet-Draft XMPP IM June 20082. "None + Pending Out" = contact and user are not subscribed to each other, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe' 3. "None + Pending In" = contact and user are not subscribed to each other, and contact has sent user a subscription request but user has not replied yet (note: contact's server SHOULD NOT push or deliver roster items in this state, but instead SHOULD wait until user has approved subscription request from contact); this is reflected in the user's roster by subscription='none' 4. "None + Pending Out+In" = contact and user are not subscribed to each other, contact has sent user a subscription request but user has not replied yet, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe' 5. "To" = user is subscribed to contact (one-way); this is reflected in the user's roster by subscription='to' 6. "To + Pending In" = user is subscribed to contact, and contact has sent user a subscription request but user has not replied yet; this is reflected in the user's roster by subscription='to' 7. "From" = contact is subscribed to user (one-way); this is reflected in the user's roster by subscription='from' 8. "From + Pending Out" = contact is subscribed to user, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='from' and ask='subscribe' 9. "Both" = user and contact are subscribed to each other (two-way); this is reflected in the user's roster by subscription='both' A.2. Server Processing of Outbound Presence Subscription Stanzas Outbound presence subscription stanzas enable the user to manage his or her subscription to the contact's presence (via the "subscribe" and "unsubscribe" types), and to manage the contact's access to the user's presence (via the "subscribed" and "unsubscribed" types). The following rules apply to outbound routing of the stanza as well as changes to the user's roster. Note: The rules for server processing of outbound presence subscription stanzas are described from the perspective of the user, not the contact. Saint-Andre Expires January 13, 2009 [Page 77] Internet-Draft XMPP IM July 2008 Note: In the following tables, "S.N."standstands for SHOULD NOT.Saint-Andre Expires December 8, 2008 [Page 70] Internet-Draft XMPP IM June 2008A.2.1. Subscribe Table 1: Processing of outbound "subscribe" stanzas +-----------------------------------------------------------------+ | EXISTING STATE | ROUTE? | NEW STATE | +-----------------------------------------------------------------+ | "None" | MUST | "None + Pending Out"[1]| | "None + Pending Out" | MUST | no state change | | "None + Pending In" | MUST | "None + Pending Out+In" | | "None + Pending Out+In" | MUST | no state change | | "To" | MUST | no state change | | "To + Pending In" | MUST | no state change | | "From" | MUST | "From + Pending Out"[1]| | "From + Pending Out" | MUST | no state change | | "Both" | MUST | no state change | +-----------------------------------------------------------------+[1]Note: A state change to "pending out" includes setting the 'ask' flag to a value of "subscribe" in the user's roster. A.2.2. Unsubscribe Table 2: Processing of outbound "unsubscribe" stanzas +-----------------------------------------------------------------+ | EXISTING STATE | ROUTE? | NEW STATE | +-----------------------------------------------------------------+ | "None" | MUST | no state change | | "None + Pending Out" | MUST | "None" | | "None + Pending In" | MUST | no state change | | "None + Pending Out+In" | MUST | "None + Pending In" | | "To" | MUST | "None" | | "To + Pending In" | MUST | "Pending In" | | "From" | MUST | no state change | | "From + Pending Out" | MUST | "From" | | "Both" | MUST | "From" | +-----------------------------------------------------------------+ Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page71]78] Internet-Draft XMPP IMJuneJuly 2008 A.2.3. Subscribed Table 3: Processing of outbound "subscribed" stanzas +-----------------------------------------------------------------+ | EXISTING STATE | ROUTE? | NEW STATE | +-----------------------------------------------------------------+ | "None" | S.N. | no state change [1] | | "None + Pending Out" | S.N. | no state change | | "None + Pending In" | MUST | "From" | | "None + Pending Out+In" | MUST | "From + Pending Out" | | "To" | S.N. | no state change | | "To + Pending In" | MUST | "Both" | | "From" | S.N. | no state change | | "From + Pending Out" | S.N. | no state change | | "Both" | S.N. | no state change | +-----------------------------------------------------------------+ [1] A server MAY note the fact that the user wishes to allow the contact to be subscribed to the user's presence and automatically approve any subscription request received from the contact; if it does so, upon the receiving presence stanza of type "subscribed" from the user's client it MUST add a roster item for the contact to the user's roster and set the 'ask' flag to a value of "subscribed". However, the user's server still SHOULD NOT route the presence stanza of type "subscribed" to the contact. This optional functionality applies only if the contact is not already in the user's roster or if the contact is in the user's roster with a state of "None" (not including a state of "None + Pending Out"). A.2.4. Unsubscribed Table 4: Processing of outbound "unsubscribed" stanzas +-----------------------------------------------------------------+ | EXISTING STATE | ROUTE? | NEW STATE | +-----------------------------------------------------------------+ | "None" | S.N. | no state change | | "None + Pending Out" | S.N. | no state change | | "None + Pending In" | MUST | "None" | | "None + Pending Out+In" | MUST | "None + Pending Out" | | "To" | S.N. | no state change | | "To + Pending In" | MUST | "To" | | "From" | MUST | "None" | | "From + Pending Out" | MUST | "None + Pending Out" | | "Both" | MUST | "To" | +-----------------------------------------------------------------+ Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page72]79] Internet-Draft XMPP IMJuneJuly 2008 A.3. Server Processing of Inbound Presence Subscription Stanzas Inbound presence subscription stanzas request a subscription-related action from the user (via the "subscribe" type), inform the user of subscription-related actions taken by the contact (via the "unsubscribe" type), or enable the user to manage the contact's access to the user's presence information (via the "subscribed" and "unsubscribed" types). The following rules apply to delivery of the inbound stanza as well as changes to the user's roster. Note: The rules for server processing of inbound presence subscription stanzas are described from the perspective of the user, not the contact. Note: In the following tables, "S.N." stand for SHOULD NOT. A.3.1. Subscribe Table 5: Processing of inbound "subscribe" stanzas +------------------------------------------------------------------+ | EXISTING STATE | DELIVER? | NEW STATE | +------------------------------------------------------------------+ | "None" | MUST [1] | "None + Pending In" | | "None + Pending Out" | MUST | "None + Pending Out+In" | | "None + Pending In" | S.N. | no state change | | "None + Pending Out+In" | S.N. | no state change | | "To" | MUST | "To + Pending In" | | "To + Pending In" | S.N. | no state change | | "From" | S.N. [2] | no state change | | "From + Pending Out" | S.N. [2] | no state change | | "Both" | S.N. [2] | no state change | +------------------------------------------------------------------+ [1] If the user previously sent presence of type "subscribed" as described under Appendix A.2.3, then the server MAY auto-reply with "subscribed" and change the state to "From" rather than "None + Pending In". [2] Server SHOULD auto-reply with "subscribed". A.3.2. Unsubscribe When the user's server receives a presence stanza of type "unsubscribe" for the user from the contact, if the stanza results in a subscription state change from the user's perspective then the Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page73]80] Internet-Draft XMPP IMJuneJuly 2008 user's server MUST change the state and SHOULD auto-reply by sending a presence stanza of type "unsubscribed" to the contact on behalf of the user. Otherwise the user's server MUST NOT change the state and SHOULD NOT deliver the stanza. These rules are summarized in the following table. Table 6: Processing of inbound "unsubscribe" stanzas +------------------------------------------------------------------+ | EXISTING STATE | DELIVER? | NEW STATE | +------------------------------------------------------------------+ | "None" | S.N. | no state change | | "None + Pending Out" | S.N. | no state change | | "None + Pending In" | S.N. [1] | "None" | | "None + Pending Out+In" | S.N. [1] | "None + Pending Out" | | "To" | S.N. | no state change | | "To + Pending In" | S.N. [1] | "To" | | "From" | S.N. [1] | "None" | | "From + Pending Out" | S.N. [1] | "None + Pending Out | | "Both" | S.N. [1] | "To" | +------------------------------------------------------------------+ [1] Server SHOULD auto-reply with "unsubscribed". A.3.3. Subscribed When the user's server receives a presence stanza of type "subscribed" for the user from the contact, if there is no pending outbound request for access to the contact's presence information, then it MUST NOT change the subscription state and SHOULD NOT deliver the stanza to the user. If there is a pending outbound request for access to the contact's presence information and the inbound presence stanza of type "subscribed" results in a subscription state change, then the user's server MUST change the subscription state but SHOULD NOT deliver the stanza to the user. If the user already has access to the contact's presence information, the inbound presence stanza of type "subscribed" does not result in a subscription state change; therefore the user's server MUST NOT change the subscription state and SHOULD NOT deliver the stanza to the user. These rules are summarized in the following table. Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page74]81] Internet-Draft XMPP IMJuneJuly 2008 Table 7: Processing of inbound "subscribed" stanzas +------------------------------------------------------------------+ | EXISTING STATE | DELIVER? | NEW STATE | +------------------------------------------------------------------+ | "None" | S.N. | no state change | | "None + Pending Out" | S.N. | "To" | | "None + Pending In" | S.N. | no state change | | "None + Pending Out+In" | S.N. | "To + Pending In" | | "To" | S.N. | no state change | | "To + Pending In" | S.N. | no state change | | "From" | S.N. | no state change | | "From + Pending Out" | S.N. | "Both" | | "Both" | S.N. | no state change | +------------------------------------------------------------------+ A.3.4. Unsubscribed When the user's server receives a presence stanza of type "unsubscribed" for the user from the contact, if there is a pending outbound request for access to the contact's presence information or if the user currently has access to the contact's presence information, then the user's server MUST change the subscription state but SHOULD NOT deliver the stanza to the user. Otherwise, the user's server MUST NOT change the subscription state and SHOULD NOT deliver the stanza. These rules are summarized in the following table. Table 8: Processing of inbound "unsubscribed" stanzas +------------------------------------------------------------------+ | EXISTING STATE | DELIVER? | NEW STATE | +------------------------------------------------------------------+ | "None" | S.N. | no state change | | "None + Pending Out" | S.N. | "None" | | "None + Pending In" | S.N. | no state change | | "None + Pending Out+In" | S.N. | "None + Pending In" | | "To" | S.N. | "None" | | "To + Pending In" | S.N. | "None + Pending In" | | "From" | S.N. | no state change | | "From + Pending Out" | S.N. | "From" | | "Both" | S.N. | "From" | +------------------------------------------------------------------+ Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page75]82] Internet-Draft XMPP IMJuneJuly 2008 Appendix B. Blocking Communication Sections 2.3.5 and 5.4.10 of [IMP-REQS] require that a compliant instant messaging and presence technology must enable a user to block communications from selected users.A protocolProtocols for doing soisare specified in[XEP-0016].[XEP-0016] and [XEP-0191]. Appendix C. vCards Sections 3.1.3 and 4.1.4 of [IMP-REQS] require that it be possible to retrieve out-of-band contact information for other users (e.g., telephone number or email address). An XML representation of the vCard specification defined in RFC 2426 [VCARD] is in common use within the Jabber community to provide such information but is out of scope forXMPPthis specification (documentation of this protocol is contained in [XEP-0054]). Appendix D. XML Schemas Because validation of XML streams and stanzas is optional, the following XML schemas are provided for descriptive purposes only. These schemas are not normative. The following schemas formally define various XML namespaces used in the core XMPP protocols, in conformance with [XML-SCHEMA]. For schemas defining namespaces for XML streams and other core aspects of XMPP, refer to [XMPP-CORE]. D.1. jabber:client <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='jabber:client' xmlns='jabber:client' elementFormDefault='qualified'> <xs:import namespace='urn:ietf:params:xml:ns:xmpp-stanzas'/> <xs:element name='message'> <xs:complexType> <xs:sequence> <xs:choice minOccurs='0' maxOccurs='unbounded'> <xs:element ref='subject'/> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page76]83] Internet-Draft XMPP IMJuneJuly 2008 <xs:element ref='body'/> <xs:element ref='thread'/> </xs:choice> <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/> <xs:element ref='error' minOccurs='0'/> </xs:sequence> <xs:attribute name='from' type='xs:string' use='optional'/> <xs:attribute name='id' type='xs:NMTOKEN' use='optional'/> <xs:attribute name='to' type='xs:string' use='optional'/> <xs:attribute name='type' use='optional' default='normal'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='chat'/> <xs:enumeration value='error'/> <xs:enumeration value='groupchat'/> <xs:enumeration value='headline'/> <xs:enumeration value='normal'/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute ref='xml:lang' use='optional'/> </xs:complexType> </xs:element> <xs:element name='body'> <xs:complexType> <xs:simpleContent> <xs:extension base='xs:string'> <xs:attribute ref='xml:lang' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name='subject'> <xs:complexType> <xs:simpleContent> Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page77]84] Internet-Draft XMPP IMJuneJuly 2008 <xs:extension base='xs:string'> <xs:attribute ref='xml:lang' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:elementname='thread' type='xs:NMTOKEN'/>name='thread'> <xs:complexType> <xs:simpleContent> <xs:extension base='xs:NMTOKEN'> <xs:attribute name='parent' type='xs:NMTOKEN' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name='presence'> <xs:complexType> <xs:sequence> <xs:choice minOccurs='0' maxOccurs='unbounded'> <xs:element ref='show'/> <xs:element ref='status'/> <xs:element ref='priority'/> </xs:choice> <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/> <xs:element ref='error' minOccurs='0'/> </xs:sequence> <xs:attribute name='from' type='xs:string' use='optional'/> <xs:attribute name='id' type='xs:NMTOKEN' use='optional'/> <xs:attribute name='to' type='xs:string' use='optional'/> <xs:attribute name='type' use='optional'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='error'/> <xs:enumeration value='probe'/> <xs:enumeration value='subscribe'/> Saint-Andre Expires January 13, 2009 [Page 85] Internet-Draft XMPP IM July 2008 <xs:enumeration value='subscribed'/> <xs:enumeration value='unavailable'/> <xs:enumeration value='unsubscribe'/> <xs:enumeration value='unsubscribed'/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute ref='xml:lang' use='optional'/> </xs:complexType> </xs:element>Saint-Andre Expires December 8, 2008 [Page 78] Internet-Draft XMPP IM June 2008<xs:element name='show'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='away'/> <xs:enumeration value='chat'/> <xs:enumeration value='dnd'/> <xs:enumeration value='xa'/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name='status'> <xs:complexType> <xs:simpleContent> <xs:extension base='string1024'> <xs:attribute ref='xml:lang' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:simpleType name='string1024'> <xs:restriction base='xs:string'> <xs:minLength value='1'/> <xs:maxLength value='1024'/> </xs:restriction> </xs:simpleType> <xs:element name='priority' type='xs:byte'/> <xs:element name='iq'> <xs:complexType> <xs:sequence> <xs:any namespace='##other' minOccurs='0'/> <xs:element ref='error' minOccurs='0'/> Saint-Andre Expires January 13, 2009 [Page 86] Internet-Draft XMPP IM July 2008 </xs:sequence> <xs:attribute name='from' type='xs:string' use='optional'/> <xs:attribute name='id' type='xs:NMTOKEN' use='required'/> <xs:attribute name='to' type='xs:string' use='optional'/> <xs:attribute name='type' use='required'>Saint-Andre Expires December 8, 2008 [Page 79] Internet-Draft XMPP IM June 2008<xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='error'/> <xs:enumeration value='get'/> <xs:enumeration value='result'/> <xs:enumeration value='set'/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute ref='xml:lang' use='optional'/> </xs:complexType> </xs:element> <xs:element name='error'> <xs:complexType> <xs:sequence xmlns:err='urn:ietf:params:xml:ns:xmpp-stanzas'> <xs:group ref='err:stanzaErrorGroup'/> <xs:element ref='err:text' minOccurs='0'/> </xs:sequence> <xs:attribute name='type' use='required'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='auth'/> <xs:enumeration value='cancel'/> <xs:enumeration value='continue'/> <xs:enumeration value='modify'/> <xs:enumeration value='wait'/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> </xs:schema> D.2. jabber:server Saint-Andre Expires January 13, 2009 [Page 87] Internet-Draft XMPP IM July 2008 <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='jabber:server' xmlns='jabber:server' elementFormDefault='qualified'> <xs:import namespace='urn:ietf:params:xml:ns:xmpp-stanzas'/>Saint-Andre Expires December 8, 2008 [Page 80] Internet-Draft XMPP IM June 2008<xs:element name='message'> <xs:complexType> <xs:sequence> <xs:choice minOccurs='0' maxOccurs='unbounded'> <xs:element ref='subject'/> <xs:element ref='body'/> <xs:element ref='thread'/> </xs:choice> <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/> <xs:element ref='error' minOccurs='0'/> </xs:sequence> <xs:attribute name='from' type='xs:string' use='required'/> <xs:attribute name='id' type='xs:NMTOKEN' use='optional'/> <xs:attribute name='to' type='xs:string' use='required'/> <xs:attribute name='type' use='optional' default='normal'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='chat'/> <xs:enumeration value='error'/> <xs:enumeration value='groupchat'/> <xs:enumeration value='headline'/> <xs:enumeration value='normal'/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute ref='xml:lang' use='optional'/> Saint-Andre Expires January 13, 2009 [Page 88] Internet-Draft XMPP IM July 2008 </xs:complexType> </xs:element> <xs:element name='body'> <xs:complexType> <xs:simpleContent> <xs:extension base='xs:string'> <xs:attribute ref='xml:lang' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType>Saint-Andre Expires December 8, 2008 [Page 81] Internet-Draft XMPP IM June 2008</xs:element> <xs:element name='subject'> <xs:complexType> <xs:simpleContent> <xs:extension base='xs:string'> <xs:attribute ref='xml:lang' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:elementname='thread' type='xs:NMTOKEN'/>name='thread'> <xs:complexType> <xs:simpleContent> <xs:extension base='xs:NMTOKEN'> <xs:attribute name='parent' type='xs:NMTOKEN' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name='subject'> <xs:complexType> <xs:simpleContent> <xs:extension base='xs:NMTOKEN'> <xs:attribute name='parent' type='xs:NMTOKEN' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name='presence'> Saint-Andre Expires January 13, 2009 [Page 89] Internet-Draft XMPP IM July 2008 <xs:complexType> <xs:sequence> <xs:choice minOccurs='0' maxOccurs='unbounded'> <xs:element ref='show'/> <xs:element ref='status'/> <xs:element ref='priority'/> </xs:choice> <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/> <xs:element ref='error' minOccurs='0'/> </xs:sequence> <xs:attribute name='from' type='xs:string' use='required'/> <xs:attribute name='id' type='xs:NMTOKEN' use='optional'/> <xs:attribute name='to' type='xs:string' use='required'/>Saint-Andre Expires December 8, 2008 [Page 82] Internet-Draft XMPP IM June 2008<xs:attribute name='type' use='optional'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='error'/> <xs:enumeration value='probe'/> <xs:enumeration value='subscribe'/> <xs:enumeration value='subscribed'/> <xs:enumeration value='unavailable'/> <xs:enumeration value='unsubscribe'/> <xs:enumeration value='unsubscribed'/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute ref='xml:lang' use='optional'/> </xs:complexType> </xs:element> <xs:element name='show'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='away'/> <xs:enumeration value='chat'/> <xs:enumeration value='dnd'/> <xs:enumeration value='xa'/> </xs:restriction> </xs:simpleType> Saint-Andre Expires January 13, 2009 [Page 90] Internet-Draft XMPP IM July 2008 </xs:element> <xs:element name='status'> <xs:complexType> <xs:simpleContent> <xs:extension base='string1024'> <xs:attribute ref='xml:lang' use='optional'/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:simpleType name='string1024'> <xs:restriction base='xs:string'> <xs:minLength value='1'/> <xs:maxLength value='1024'/> </xs:restriction> </xs:simpleType> <xs:element name='priority' type='xs:byte'/> <xs:element name='iq'>Saint-Andre Expires December 8, 2008 [Page 83] Internet-Draft XMPP IM June 2008<xs:complexType> <xs:sequence> <xs:any namespace='##other' minOccurs='0'/> <xs:element ref='error' minOccurs='0'/> </xs:sequence> <xs:attribute name='from' type='xs:string' use='required'/> <xs:attribute name='id' type='xs:NMTOKEN' use='required'/> <xs:attribute name='to' type='xs:string' use='required'/> <xs:attribute name='type' use='required'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='error'/> <xs:enumeration value='get'/> <xs:enumeration value='result'/> <xs:enumeration value='set'/> </xs:restriction> </xs:simpleType> </xs:attribute> Saint-Andre Expires January 13, 2009 [Page 91] Internet-Draft XMPP IM July 2008 <xs:attribute ref='xml:lang' use='optional'/> </xs:complexType> </xs:element> <xs:element name='error'> <xs:complexType> <xs:sequence xmlns:err='urn:ietf:params:xml:ns:xmpp-stanzas'> <xs:group ref='err:stanzaErrorGroup'/> <xs:element ref='err:text' minOccurs='0'/> </xs:sequence> <xs:attribute name='type' use='required'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='auth'/> <xs:enumeration value='cancel'/> <xs:enumeration value='continue'/> <xs:enumeration value='modify'/> <xs:enumeration value='wait'/> </xs:restriction> </xs:simpleType> </xs:attribute>Saint-Andre Expires December 8, 2008 [Page 84] Internet-Draft XMPP IM June 2008</xs:complexType> </xs:element> </xs:schema> D.3. jabber:iq:roster <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='jabber:iq:roster' xmlns='jabber:iq:roster' elementFormDefault='qualified'> <xs:element name='query'> <xs:complexType> <xs:sequence> <xs:element ref='item' minOccurs='0' maxOccurs='unbounded'/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name='item'> Saint-Andre Expires January 13, 2009 [Page 92] Internet-Draft XMPP IM July 2008 <xs:complexType> <xs:sequence> <xs:element ref='group' minOccurs='0' maxOccurs='unbounded'/> </xs:sequence> <xs:attribute name='ask' use='optional'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='subscribe'/> <xs:enumeration value='subscribed'/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name='jid' type='xs:string' use='required'/> <xs:attribute name='name' type='xs:string' use='optional'/> <xs:attribute name='subscription' use='optional'> <xs:simpleType> <xs:restriction base='xs:NCName'> <xs:enumeration value='both'/> <xs:enumeration value='from'/> <xs:enumeration value='none'/>Saint-Andre Expires December 8, 2008 [Page 85] Internet-Draft XMPP IM June 2008<xs:enumeration value='remove'/> <xs:enumeration value='to'/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> <xs:element name='group' type='xs:string'/> </xs:schema> Appendix E. Differences From RFC 3921 Based on consensus derived from implementation and deployment experience as well as formal interoperability testing, the following substantive modifications were made from RFC 3921. o The protocol for session establishment was determined to be unnecessary and therefore the content previously defined in Section 3 of RFC 3921 was removed. However, for the sake of backward-compatibility server implementations are encouraged to advertise support for the feature, even though session establishment is a "no-op".o The protocol for communications blocking specified in Section 10 of RFC 3921 has been moved to [XEP-0016].Saint-Andre Expires January 13, 2009 [Page 93] Internet-Draft XMPP IM July 2008 o In order to more seamlessly repair lack of synchronization in subscription states between rosters located at different servers, error handling related to presence probes and presence notifications was modified to return presence stanzas of type "unsubscribe" or "unsubscribed" rather than error stanzas. o Added optional server support for pre-approved presence subscriptions via presence stanzas of type "subscribed" and the optional "subscribed" value for the 'ask' flag. o Added optional 'parent' attribute to <thread/> element o The protocol for communications blocking specified in Section 10 of RFC 3921 has been moved to [XEP-0016]. In addition, numerous changes of an editorial nature were made in order to more fully specify and clearly explain the protocols. Appendix F. Copying Conditions Regarding this entire document or any portion of it, the author makes no guarantees and is not responsible for any damage resulting from its use. The author grants irrevocable permission to anyone to use, modify, and distribute it in any way that does not diminish the rights of anyone else to use, modify, and distribute it, provided that redistributed derivative works do not contain misleading authorSaint-Andre Expires December 8, 2008 [Page 86] Internet-Draft XMPP IM June 2008or version information. Derivative works need not be licensed under similar terms. Index A Available Resource32 B Broadcasted Presence 3137 C Chat Session5152 Contact2024 D Directed Presence3137 I Initial Presence31 Interested Resource 1137 O Offline Message Storage6269 P Presence57 Saint-Andre Expires January 13, 2009 [Page 94] Internet-Draft XMPP IM July 2008 Presence Broadcast 37 Presence Probe3339 Presence Session3137 Presence Subscription2024 R Roster57 Roster Get811 Roster Push912 Roster Result1013 Roster Set911 S Subscription Request2125 U Unavailable Presence37 Saint-Andre Expires December 8, 2008 [Page 87] Internet-Draft XMPP IM June 200843 Author's Address Peter Saint-Andre (editor) XMPP Standards Foundation Email: stpeter@jabber.org URI: https://stpeter.im/ Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page88]95] Internet-Draft XMPP IMJuneJuly 2008 Full Copyright Statement Copyright (C) The IETF Trust (2008). This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights. This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Intellectual Property The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79. Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr. The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org. Saint-Andre ExpiresDecember 8, 2008January 13, 2009 [Page89]96] ----