idnits 2.17.1 draft-ietf-xmpp-3921bis-20.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (January 20, 2011) is 4838 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '1' on line 4977 -- Looks like a reference, but probably isn't: '2' on line 4947 -- Possible downref: Non-RFC (?) normative reference: ref. 'DELAY' -- Possible downref: Non-RFC (?) normative reference: ref. 'XML' -- Possible downref: Non-RFC (?) normative reference: ref. 'XML-NAMES' -- Obsolete informational reference (is this intentional?): RFC 3920 (Obsoleted by RFC 6120) -- Obsolete informational reference (is this intentional?): RFC 3921 (Obsoleted by RFC 6121) -- Obsolete informational reference (is this intentional?): RFC 5246 (ref. 'TLS') (Obsoleted by RFC 8446) -- Obsolete informational reference (is this intentional?): RFC 2426 (ref. 'VCARD') (Obsoleted by RFC 6350) Summary: 0 errors (**), 0 flaws (~~), 1 warning (==), 10 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 XMPP P. Saint-Andre 3 Internet-Draft Cisco 4 Obsoletes: 3921 (if approved) January 20, 2011 5 Intended status: Standards Track 6 Expires: July 24, 2011 8 Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and 9 Presence 10 draft-ietf-xmpp-3921bis-20 12 Abstract 14 This document defines extensions to core features of the Extensible 15 Messaging and Presence Protocol (XMPP) that provide basic instant 16 messaging (IM) and presence functionality in conformance with the 17 requirements in RFC 2779. This document obsoletes RFC 3921. 19 Status of this Memo 21 This Internet-Draft is submitted in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF). Note that other groups may also distribute 26 working documents as Internet-Drafts. The list of current Internet- 27 Drafts is at http://datatracker.ietf.org/drafts/current/. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 This Internet-Draft will expire on July 24, 2011. 36 Copyright Notice 38 Copyright (c) 2011 IETF Trust and the persons identified as the 39 document authors. All rights reserved. 41 This document is subject to BCP 78 and the IETF Trust's Legal 42 Provisions Relating to IETF Documents 43 (http://trustee.ietf.org/license-info) in effect on the date of 44 publication of this document. Please review these documents 45 carefully, as they describe your rights and restrictions with respect 46 to this document. Code Components extracted from this document must 47 include Simplified BSD License text as described in Section 4.e of 48 the Trust Legal Provisions and are provided without warranty as 49 described in the Simplified BSD License. 51 Table of Contents 53 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 54 1.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 6 55 1.2. History . . . . . . . . . . . . . . . . . . . . . . . . . 6 56 1.3. Requirements . . . . . . . . . . . . . . . . . . . . . . 6 57 1.4. Functional Summary . . . . . . . . . . . . . . . . . . . 7 58 1.5. Terminology . . . . . . . . . . . . . . . . . . . . . . . 9 59 2. Managing the Roster . . . . . . . . . . . . . . . . . . . . . 10 60 2.1. Syntax and Semantics . . . . . . . . . . . . . . . . . . 10 61 2.1.1. Ver Attribute . . . . . . . . . . . . . . . . . . . . 10 62 2.1.2. Roster Items . . . . . . . . . . . . . . . . . . . . 11 63 2.1.2.1. Approved Attribute . . . . . . . . . . . . . . . 11 64 2.1.2.2. Ask Attribute . . . . . . . . . . . . . . . . . . 11 65 2.1.2.3. JID Attribute . . . . . . . . . . . . . . . . . . 12 66 2.1.2.4. Name Attribute . . . . . . . . . . . . . . . . . 12 67 2.1.2.5. Subscription Attribute . . . . . . . . . . . . . 12 68 2.1.2.6. Group Element . . . . . . . . . . . . . . . . . . 13 69 2.1.3. Roster Get . . . . . . . . . . . . . . . . . . . . . 13 70 2.1.4. Roster Result . . . . . . . . . . . . . . . . . . . . 13 71 2.1.5. Roster Set . . . . . . . . . . . . . . . . . . . . . 14 72 2.1.6. Roster Push . . . . . . . . . . . . . . . . . . . . . 15 73 2.2. Retrieving the Roster on Login . . . . . . . . . . . . . 16 74 2.3. Adding a Roster Item . . . . . . . . . . . . . . . . . . 18 75 2.3.1. Request . . . . . . . . . . . . . . . . . . . . . . . 18 76 2.3.2. Success Case . . . . . . . . . . . . . . . . . . . . 18 77 2.3.3. Error Cases . . . . . . . . . . . . . . . . . . . . . 19 78 2.4. Updating a Roster Item . . . . . . . . . . . . . . . . . 23 79 2.4.1. Request . . . . . . . . . . . . . . . . . . . . . . . 23 80 2.4.2. Success Case . . . . . . . . . . . . . . . . . . . . 25 81 2.4.3. Error Cases . . . . . . . . . . . . . . . . . . . . . 25 82 2.5. Deleting a Roster Item . . . . . . . . . . . . . . . . . 25 83 2.5.1. Request . . . . . . . . . . . . . . . . . . . . . . . 25 84 2.5.2. Success Case . . . . . . . . . . . . . . . . . . . . 26 85 2.5.3. Error Cases . . . . . . . . . . . . . . . . . . . . . 26 86 2.6. Roster Versioning . . . . . . . . . . . . . . . . . . . . 27 87 2.6.1. Stream Feature . . . . . . . . . . . . . . . . . . . 27 88 2.6.2. Request . . . . . . . . . . . . . . . . . . . . . . . 27 89 2.6.3. Success Case . . . . . . . . . . . . . . . . . . . . 28 90 3. Managing Presence Subscriptions . . . . . . . . . . . . . . . 31 91 3.1. Requesting a Subscription . . . . . . . . . . . . . . . . 32 92 3.1.1. Client Generation of Outbound Subscription Request . 33 93 3.1.2. Server Processing of Outbound Subscription Request . 33 94 3.1.3. Server Processing of Inbound Subscription Request . . 35 95 3.1.4. Client Processing of Inbound Subscription Request . . 37 96 3.1.5. Server Processing of Outbound Subscription Approval . 38 97 3.1.6. Server Processing of Inbound Subscription Approval . 39 98 3.2. Cancelling a Subscription . . . . . . . . . . . . . . . . 42 99 3.2.1. Client Generation of Subscription Cancellation . . . 42 100 3.2.2. Server Processing of Outbound Subscription 101 Cancellation . . . . . . . . . . . . . . . . . . . . 42 102 3.2.3. Server Processing of Inbound Subscription 103 Cancellation . . . . . . . . . . . . . . . . . . . . 43 104 3.3. Unsubscribing . . . . . . . . . . . . . . . . . . . . . . 45 105 3.3.1. Client Generation of Unsubscribe . . . . . . . . . . 45 106 3.3.2. Server Processing of Outbound Unsubscribe . . . . . . 45 107 3.3.3. Server Processing of Inbound Unsubscribe . . . . . . 46 108 3.4. Pre-Approving a Subscription Request . . . . . . . . . . 48 109 3.4.1. Client Generation of Subscription Pre-Approval . . . 48 110 3.4.2. Server Processing of Subscription Pre-Approval . . . 49 111 4. Exchanging Presence Information . . . . . . . . . . . . . . . 50 112 4.1. Presence Fundamentals . . . . . . . . . . . . . . . . . . 50 113 4.2. Initial Presence . . . . . . . . . . . . . . . . . . . . 51 114 4.2.1. Client Generation of Initial Presence . . . . . . . . 51 115 4.2.2. Server Processing of Outbound Initial Presence . . . 52 116 4.2.3. Server Processing of Inbound Initial Presence . . . . 52 117 4.2.4. Client Processing of Initial Presence . . . . . . . . 53 118 4.3. Presence Probes . . . . . . . . . . . . . . . . . . . . . 53 119 4.3.1. Server Generation of Outbound Presence Probe . . . . 54 120 4.3.2. Server Processing of Inbound Presence Probe . . . . . 55 121 4.3.2.1. Handling of the 'id' Attribute . . . . . . . . . 57 122 4.4. Subsequent Presence Broadcast . . . . . . . . . . . . . . 59 123 4.4.1. Client Generation of Subsequent Presence Broadcast . 59 124 4.4.2. Server Processing of Subsequent Outbound Presence . . 59 125 4.4.3. Server Processing of Subsequent Inbound Presence . . 61 126 4.4.4. Client Processing of Subsequent Presence . . . . . . 61 127 4.5. Unavailable Presence . . . . . . . . . . . . . . . . . . 61 128 4.5.1. Client Generation of Unavailable Presence . . . . . . 61 129 4.5.2. Server Processing of Outbound Unavailable Presence . 62 130 4.5.3. Server Processing of Inbound Unavailable Presence . . 63 131 4.5.4. Client Processing of Unavailable Presence . . . . . . 64 132 4.6. Directed Presence . . . . . . . . . . . . . . . . . . . . 64 133 4.6.1. General Considerations . . . . . . . . . . . . . . . 64 134 4.6.2. Client Generation of Directed Presence . . . . . . . 65 135 4.6.3. Server Processing of Outbound Directed Presence . . . 65 136 4.6.4. Server Processing of Inbound Directed Presence . . . 66 137 4.6.5. Client Processing of Inbound Directed Presence . . . 66 138 4.6.6. Server Processing of Presence Probes . . . . . . . . 66 139 4.7. Presence Syntax . . . . . . . . . . . . . . . . . . . . . 67 140 4.7.1. Type Attribute . . . . . . . . . . . . . . . . . . . 67 141 4.7.2. Child Elements . . . . . . . . . . . . . . . . . . . 68 142 4.7.2.1. Show Element . . . . . . . . . . . . . . . . . . 68 143 4.7.2.2. Status Element . . . . . . . . . . . . . . . . . 69 144 4.7.2.3. Priority Element . . . . . . . . . . . . . . . . 70 145 4.7.3. Extended Content . . . . . . . . . . . . . . . . . . 71 146 5. Exchanging Messages . . . . . . . . . . . . . . . . . . . . . 71 147 5.1. One-to-One Chat Sessions . . . . . . . . . . . . . . . . 72 148 5.2. Message Syntax . . . . . . . . . . . . . . . . . . . . . 73 149 5.2.1. To Attribute . . . . . . . . . . . . . . . . . . . . 73 150 5.2.2. Type Attribute . . . . . . . . . . . . . . . . . . . 74 151 5.2.3. Body Element . . . . . . . . . . . . . . . . . . . . 75 152 5.2.4. Subject Element . . . . . . . . . . . . . . . . . . . 76 153 5.2.5. Thread Element . . . . . . . . . . . . . . . . . . . 77 154 5.3. Extended Content . . . . . . . . . . . . . . . . . . . . 79 155 6. Exchanging IQ Stanzas . . . . . . . . . . . . . . . . . . . . 79 156 7. A Sample Session . . . . . . . . . . . . . . . . . . . . . . 79 157 8. Server Rules for Processing XML Stanzas . . . . . . . . . . . 87 158 8.1. General Considerations . . . . . . . . . . . . . . . . . 88 159 8.2. No 'to' Address . . . . . . . . . . . . . . . . . . . . . 88 160 8.3. Remote Domain . . . . . . . . . . . . . . . . . . . . . . 88 161 8.4. Local Domain . . . . . . . . . . . . . . . . . . . . . . 89 162 8.5. Local User . . . . . . . . . . . . . . . . . . . . . . . 89 163 8.5.1. No Such User . . . . . . . . . . . . . . . . . . . . 89 164 8.5.2. localpart@domainpart . . . . . . . . . . . . . . . . 90 165 8.5.2.1. Available or Connected Resources . . . . . . . . 90 166 8.5.2.2. No Available or Connected Resources . . . . . . . 92 167 8.5.3. localpart@domainpart/resourcepart . . . . . . . . . . 93 168 8.5.3.1. Resource Matches . . . . . . . . . . . . . . . . 93 169 8.5.3.2. No Resource Matches . . . . . . . . . . . . . . . 94 170 8.5.4. Summary of Message Delivery Rules . . . . . . . . . . 95 171 9. Handling of URIs . . . . . . . . . . . . . . . . . . . . . . 96 172 10. Internationalization Considerations . . . . . . . . . . . . . 97 173 11. Security Considerations . . . . . . . . . . . . . . . . . . . 97 174 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 98 175 13. Conformance Requirements . . . . . . . . . . . . . . . . . . 99 176 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 102 177 14.1. Normative References . . . . . . . . . . . . . . . . . . 102 178 14.2. Informative References . . . . . . . . . . . . . . . . . 103 179 Appendix A. Subscription States . . . . . . . . . . . . . . . . 106 180 A.1. Defined States . . . . . . . . . . . . . . . . . . . . . 106 181 A.2. Server Processing of Outbound Presence Subscription 182 Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 107 183 A.2.1. Subscribe . . . . . . . . . . . . . . . . . . . . . . 108 184 A.2.2. Unsubscribe . . . . . . . . . . . . . . . . . . . . . 108 185 A.2.3. Subscribed . . . . . . . . . . . . . . . . . . . . . 109 186 A.2.4. Unsubscribed . . . . . . . . . . . . . . . . . . . . 109 187 A.3. Server Processing of Inbound Presence Subscription 188 Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 109 189 A.3.1. Subscribe . . . . . . . . . . . . . . . . . . . . . . 110 190 A.3.2. Unsubscribe . . . . . . . . . . . . . . . . . . . . . 110 191 A.3.3. Subscribed . . . . . . . . . . . . . . . . . . . . . 111 192 A.3.4. Unsubscribed . . . . . . . . . . . . . . . . . . . . 112 193 Appendix B. Blocking Communication . . . . . . . . . . . . . . . 113 194 Appendix C. vCards . . . . . . . . . . . . . . . . . . . . . . . 113 195 Appendix D. XML Schema for jabber:iq:roster . . . . . . . . . . 113 196 Appendix E. Differences From RFC 3921 . . . . . . . . . . . . . 115 197 Appendix F. Acknowledgements . . . . . . . . . . . . . . . . . . 116 198 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 116 200 1. Introduction 202 1.1. Overview 204 The Extensible Messaging and Presence Protocol (XMPP) is an 205 application profile of the Extensible Markup Language [XML] that 206 enables the near-real-time exchange of structured yet extensible data 207 between any two or more network entities. The core features of XMPP 208 defined in [XMPP-CORE] provide the building blocks for many types of 209 near-real-time applications, which can be layered on top of the core 210 by sending application-specific data qualified by particular XML 211 namespaces (refer to [XML-NAMES]). This document defines XMPP 212 extensions that provide the basic functionality expected of an 213 instant messaging (IM) and presence application as described in 214 [IMP-REQS]. 216 1.2. History 218 The basic syntax and semantics of XMPP were developed originally 219 within the Jabber open-source community, mainly in 1999. In late 220 2002, the XMPP Working Group was chartered with developing an 221 adaptation of the core Jabber protocol that would be suitable as an 222 IETF IM and presence technology in accordance with [IMP-REQS]. In 223 October 2004, [RFC3920] and [RFC3921] were published, representing 224 the most complete definition of XMPP at that time. 226 Since 2004 the Internet community has gained extensive implementation 227 and deployment experience with XMPP, including formal 228 interoperability testing carried out under the auspices of the XMPP 229 Standards Foundation (XSF). This document incorporates comprehensive 230 feedback from software developers and service providers, including a 231 number of backward-compatible modifications summarized under 232 Appendix E. As a result, this document reflects the rough consensus 233 of the Internet community regarding the IM and presence features of 234 XMPP 1.0, thus obsoleting RFC 3921. 236 1.3. Requirements 238 Traditionally, IM applications have combined the following factors: 240 1. The central point of focus is a list of one's contacts or 241 "buddies" (in XMPP this list is called a "roster"). 243 2. The purpose of using such an application is to exchange 244 relatively brief text messages with particular contacts in close 245 to real time -- often relatively large numbers of such messages 246 in rapid succession, in the form of a one-to-one "chat session" 247 as described under Section 5.1. 249 3. The catalyst for exchanging messages is "presence" -- i.e., 250 information about the network availability of particular contacts 251 (thus knowing who is online and available for a one-to-one chat 252 session). 254 4. Presence information is provided only to contacts that one has 255 authorized by means of an explicit agreement called a "presence 256 subscription". 258 Thus at a high level this document assumes that a user needs to be 259 able to complete the following use cases: 261 o Manage items in one's contact list 262 o Exchange messages with one's contacts 263 o Exchange presence information with one's contacts 264 o Manage presence subscriptions to and from one's contacts 266 Detailed definitions of these functionality areas are contained in 267 RFC 2779 [IMP-REQS], and the interested reader is referred to that 268 document regarding in-depth requirements. Although the XMPP IM and 269 presence extensions specified herein meet the requirements of RFC 270 2779, they were not designed explicitly with that specification in 271 mind, since the base protocol evolved through an open development 272 process within the Jabber open-source community before RFC 2779 was 273 written. Although XMPP protocol extensions addressing many other 274 functionality areas have been defined in the XMPP Standards 275 Foundation's XEP series (e.g., multi-user text chat as specified in 276 [XEP-0045]), such extensions are not specified in this document 277 because they are not mandated by RFC 2779. 279 Implementation Note: RFC 2779 stipulates that presence services 280 must be separable from IM services and vice-versa; i.e., it must 281 be possible to use the protocol to provide a presence service, a 282 messaging service, or both. Although the text of this document 283 assumes that implementations and deployments will want to offer a 284 unified IM and presence service, it is not mandatory for an XMPP 285 service to offer both a presence service and a messaging service, 286 and the protocol makes it possible to offer separate and distinct 287 services for presence and for messaging. (For example, a 288 presence-only service could return a stanza 289 error if a client attempts to send a stanza.) 291 1.4. Functional Summary 293 This non-normative section provides a developer-friendly, functional 294 summary of XMPP-based IM and presence features; consult the sections 295 that follow for a normative definition of these features. 297 [XMPP-CORE] specifies how an XMPP client connects to an XMPP server. 298 In particular, it specifies the preconditions that need to be 299 fulfilled before a client is allowed to send XML stanzas (the basic 300 unit of meaning in XMPP) to other entities on an XMPP network. These 301 preconditions comprise negotiation of the XML stream and include 302 exchange of XML stream headers, optional channel encryption via 303 Transport Layer Security [TLS], mandatory authentication via Simple 304 Authentication and Security Layer [SASL], and binding of a resource 305 to the stream for client addressing. The reader is referred to 306 [XMPP-CORE] for details regarding these preconditions, and knowledge 307 of [XMPP-CORE] is assumed herein. 309 Interoperability Note: [RFC3921] specified one additional 310 precondition: formal establishment of an instant messaging and 311 presence session. Implementation and deployment experience has 312 shown that this additional step is unnecessary. However, for 313 backward compatibility an implementation MAY still offer that 314 feature. This enables older software to connect while letting 315 newer software save a round trip. 317 Upon fulfillment of the preconditions specified in [XMPP-CORE], an 318 XMPP client has a long-lived XML stream with an XMPP server, which 319 enables the user controlling that client to send and receive a 320 potentially unlimited number of XML stanzas over the stream. Such a 321 stream can be used to exchange messages, share presence information, 322 and engage in structured request-response interactions in close to 323 real time. After negotiation of the XML stream, the typical flow for 324 an instant messaging and presence session is as follows: 326 1. Retrieve one's roster. (See Section 2.2.) 328 2. Send initial presence to the server for broadcast to all 329 subscribed contacts, thus "going online" from the perspective of 330 XMPP communication. (See Section 4.2.) 332 3. Exchange messages, manage presence subscriptions, perform roster 333 updates, and in general process and generate other XML stanzas 334 with particular semantics throughout the life of the session. 335 (See Section 5, Section 3, Section 2, and Section 6.) 337 4. Terminate the session when desired by sending unavailable 338 presence and closing the underlying XML stream. (See 339 Section 4.5.) 341 1.5. Terminology 343 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 344 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 345 "OPTIONAL" in this document are to be interpreted as described in RFC 346 2119 [KEYWORDS]. 348 This document inherits the terminology defined in [XMPP-CORE]. 350 The terms "automated client" and "interactive client" are to be 351 understood in the sense defined in [TLS-CERTS]. 353 For convenience, this document employs the term "user" to refer to 354 the owner of an XMPP account; however, account owners need not be 355 humans and can be bots, devices, or other automated applications. 357 Several other terms, such as "interested resource", are defined 358 within the body of this document. 360 Following the "XML Notation" used in [IRI] to represent characters 361 that cannot be rendered in ASCII-only documents, some examples in 362 this document use the form "&#x...." as a notational device to 363 represent [UNICODE] characters (e.g., the string "ř" stands 364 for the Unicode character LATIN SMALL LETTER R WITH CARON); this form 365 is definitely not to be sent over the wire in XMPP systems. 367 In examples, lines have been wrapped for improved readability, 368 "[...]" means elision, and the following prepended strings are used 369 (these prepended strings are not to be sent over the wire): 371 o C: = client 372 o CC: = contact's client 373 o CS: = contact's server 374 o S: = server 375 o UC: = user's client 376 o US: = user's server 378 Readers need to be aware that the examples are not exhaustive and 379 that, in examples for some protocol flows, the alternate steps shown 380 would not necessarily be triggered by the exact data sent in the 381 previous step; in all cases the protocol definitions specified in 382 this document or in normatively referenced documents rule over any 383 examples provided here. All examples are fictional and the 384 information exchanged (e.g., usernames and passwords) does not 385 represent any existing users or servers. 387 2. Managing the Roster 389 In XMPP, a user's roster contains any number of specific contacts. A 390 user's roster is stored by the user's server on the user's behalf so 391 that the user can access roster information from any device. When 392 the user adds items to the roster or modifies existing items, if an 393 error does not occur then the server SHOULD store that data 394 unmodified if at all possible and MUST return the data it has stored 395 when an authorized client requests the roster. 397 Security Warning: Because the user's roster can contain 398 confidential data, the server MUST restrict access to this data so 399 that only authorized entities (typically limited to the account 400 owner) are able to retrieve, modify, or delete it. 402 RFC 3921 assumed that the only place where a user stores their roster 403 is the server where the user's account is registered and at which the 404 user authenticates for access to the XMPP network. This 405 specification removes that strict coupling of roster storage to 406 account registration and network authentication, with the result that 407 a user could store their roster at another location, or could have 408 multiple rosters that are stored in multiple locations. However, in 409 the absence of implementation and deployment experience with a more 410 flexible roster storage model, this specification retains the 411 terminology of RFC 3921 by using the terms "client" and server" (and 412 "the roster" instead of "a roster"), rather than coining a new term 413 for "a place where a user stores a roster". Future documents might 414 provide normative rules for non-server roster storage or for the 415 management of multiple rosters, but such rules are out of scope for 416 this document. 418 2.1. Syntax and Semantics 420 Rosters are managed using IQ stanzas, specifically by means of a 421 child element qualified by the 'jabber:iq:roster' namespace. 422 The detailed syntax and semantics are defined in the following 423 sections. 425 2.1.1. Ver Attribute 427 The 'ver' attribute is a string that identifies a particular version 428 of the roster information. The value MUST be generated only by the 429 server and MUST be treated by the client as opaque. The server can 430 use any appropriate method for generating the version ID, such as a 431 hash of the roster data or a strictly-increasing sequence number. 433 Inclusion of the 'ver' attribute is RECOMMENDED. 435 Use of the 'ver' attribute is described more fully under Section 2.6. 437 Interoperability Note: The 'ver' attribute of the element 438 was not defined in RFC 3921 and is newly defined in this 439 specification. 441 2.1.2. Roster Items 443 The element inside a roster set (Section 2.1.5) contains one 444 child, and a roster result (Section 2.1.4) typically contains 445 multiple children. Each element describes a unique 446 "roster item" (sometimes also called a "contact"). 448 The syntax of the element is described in the following 449 sections. 451 2.1.2.1. Approved Attribute 453 The boolean 'approved' attribute with a value of "true" is used to 454 signal subscription pre-approval as described under Section 3.4 (the 455 default is "false", in accordance with [XML-DATATYPES]). 457 A server SHOULD include the 'approved' attribute to inform the client 458 of subscription pre-approvals. A client MUST NOT include the 459 'approved' attribute in the roster sets it sends to the server, but 460 instead MUST use presence stanzas of type "subscribed" and 461 "unsubscribed" to manage pre-approvals as described under 462 Section 3.4. 464 Interoperability Note: The 'approved' attribute of the 465 element was not defined in RFC 3921 and is newly defined in this 466 specification. 468 2.1.2.2. Ask Attribute 470 The 'ask' attribute of the element with a value of 471 "subscribe" is used to signal various subscription sub-states that 472 include a "Pending Out" aspect as described under Section 3.1.2. 474 A server SHOULD include the 'ask' attribute to inform the client of 475 "Pending Out" sub-states. A client MUST NOT include the 'ask' 476 attribute in the roster sets it sends to the server, but instead MUST 477 use presence stanzas of type "subscribe" and "unsubscribe" to manage 478 such sub-states as described under Section 3.1.2. 480 2.1.2.3. JID Attribute 482 The 'jid' attribute of the element specifies the Jabber 483 Identifier (JID) that uniquely identifies the roster item. 485 The 'jid' attribute is REQUIRED whenever a client or server adds, 486 updates, deletes, or returns a roster item. 488 2.1.2.4. Name Attribute 490 The 'name' attribute of the element specifies the "handle" to 491 be associated with the JID, as determined by the user (not the 492 contact). Although the value of the 'name' attribute MAY have 493 meaning to a human user, it is opaque to the server. However, the 494 'name' attribute MAY be used by the server for matching purposes 495 within the context of various XMPP extensions (one possible 496 comparison method is that described for XMPP resourceparts in 497 [XMPP-ADDR]). 499 It is OPTIONAL for a client to include the 'name' attribute when 500 adding or updating a roster item. 502 2.1.2.5. Subscription Attribute 504 The state of the presence subscription is captured in the 505 'subscription' attribute of the element. The defined 506 subscription-related values are: 508 none: the user does not have a subscription to the contact's 509 presence, and the contact does not have a subscription to the 510 user's presence; this is the default value, so if the subscription 511 attribute is not included then the state is to be understood as 512 "none" 514 to: the user has a subscription to the contact's presence, but the 515 contact does not have a subscription to the user's presence 517 from: the contact has a subscription to the user's presence, but the 518 user does not have a subscription to the contact's presence 520 both: the user and the contact have subscriptions to each other's 521 presence (also called a "mutual subscription") 523 In a roster result (Section 2.1.4), the client MUST ignore values of 524 the 'subscription' attribute other than "none", "to", "from", or 525 "both". 527 In a roster push (Section 2.1.6), the client MUST ignore values of 528 the 'subscription' attribute other than "none", "to", "from", "both", 529 or "remove". 531 In a roster set (Section 2.1.5), the 'subscription' attribute MAY be 532 included with a value of "remove", which indicates that the item is 533 to be removed from the roster; in a roster set the server MUST ignore 534 all values of the 'subscription' attribute other than "remove". 536 Inclusion of the 'subscription' attribute is OPTIONAL. 538 2.1.2.6. Group Element 540 The child element specifies a category or "bucket" into 541 which the roster item is to be grouped by a client. An 542 element MAY contain more than one element, which means that 543 roster groups are not exclusive. Although the XML character data of 544 the element MAY have meaning to a human user, it is opaque 545 to the server. However, the element MAY be used by the 546 server for matching purposes within the context of various XMPP 547 extensions (one possible comparison method is that described for XMPP 548 resourceparts in [XMPP-ADDR]). 550 It is OPTIONAL for a client to include the element when 551 adding or updating a roster item. If a roster set (Section 2.1.5) 552 includes no element, then the item is to be interpreted as 553 being affiliated with no group. 555 2.1.3. Roster Get 557 A "roster get" is a client's request for the server to return the 558 roster; syntactically it is an IQ stanza of type "get" sent from 559 client to server and containing a element qualified by the 560 'jabber:iq:roster' namespace, where the element MUST NOT 561 contain any child elements. 563 C: 566 567 569 The expected outcome of sending a roster get is for the server to 570 return a roster result. 572 2.1.4. Roster Result 574 A "roster result" is the server's response to a roster get; 575 syntactically it is an IQ stanza of type "result" sent from server to 576 client and containing a element qualified by the 'jabber:iq: 577 roster' namespace. 579 The element in a roster result contains one element 580 for each contact and therefore can contain more than one 581 element. 583 S: 586 587 588 589 590 592 If the roster exists but there are no contacts in the roster, then 593 the server MUST return an IQ-result containing a child 594 element that in turn contains no children (i.e., the server 595 MUST NOT return an empty stanza of type "error"). 597 S: 600 601 603 If the roster does not exist, then the server MUST return a stanza 604 error with a condition of . 606 S: 609 610 612 613 615 2.1.5. Roster Set 617 A "roster set" is a client's request for the server to modify (i.e., 618 create, update, or delete) a roster item; syntactically it is an IQ 619 stanza of type "set" sent from client to server and containing a 620 element qualified by the 'jabber:iq:roster' namespace. 622 The following rules apply to roster sets: 624 1. The element MUST contain one and only one 625 element. 627 2. The server MUST ignore any value of the 'subscription' attribute 628 other than "remove" (see Section 2.1.2.5). 630 Security Warning: Traditionally, the IQ stanza of the roster set 631 included no 'to' address, with the result that all roster sets 632 were sent from an authenticated resource (full JID) of the account 633 whose roster was being updated. Furthermore, RFC 3921 required a 634 server to perform special-case checking of roster sets to ignore 635 the 'to' address; however, this specification has removed that 636 special-casing, which means that a roster set might include a 'to' 637 address other than that of the sender. Therefore, the entity that 638 processes a roster set MUST verify that the sender of the roster 639 set is authorized to update the roster, and if not return a 640 error. 642 C: 645 646 647 648 650 2.1.6. Roster Push 652 A "roster push" is a newly created, updated, or deleted roster item 653 that is sent from the server to the client; syntactically it is an IQ 654 stanza of type "set" sent from server to client and containing a 655 element qualified by the 'jabber:iq:roster' namespace. 657 The following rules apply to roster pushes: 659 1. The element in a roster push MUST contain one and only 660 one element. 662 2. A receiving client MUST ignore the stanza unless it has no 'from' 663 attribute (i.e., implicitly from the bare JID of the user's 664 account) or it has a 'from' attribute whose value matches the 665 user's bare JID . 667 S: 670 671 672 673 675 As mandated by the semantics of the IQ stanza as defined in 676 [XMPP-CORE], each resource that receives a roster push from the 677 server is supposed to reply with an IQ stanza of type "result" or 678 "error" (however, it is known that many existing clients do not reply 679 to roster pushes). 681 C: 685 C: 689 Security Warning: Traditionally, a roster push included no 'from' 690 address, with the result that all roster pushes were sent 691 implicitly from the bare JID of the account itself. However, this 692 specification allows entities other than the user's server to 693 maintain roster information, which means that a roster push might 694 include a 'from' address other than the bare JID of the user's 695 account. Therefore, the client MUST check the 'from' address to 696 verify that the sender of the roster push is authorized to update 697 the roster. If the client receives a roster push from an 698 unauthorized entity, it MUST NOT process the pushed data; in 699 addition, the client can either return a stanza error of error or refuse to return a stanza error at all (the 701 latter behavior overrides a MUST-level requirement from 702 [XMPP-CORE] for the purpose of preventing a presence leak). 704 Implementation Note: There is no error case for client processing 705 of roster pushes; if the server receives an IQ of type "error" in 706 response to a roster push then it SHOULD ignore the error. 708 2.2. Retrieving the Roster on Login 710 Upon authenticating with a server and binding a resource (thus 711 becoming a connected resource as defined in [XMPP-CORE]), a client 712 SHOULD request the roster before sending initial presence (however, 713 because receiving the roster is not necessarily desirable for all 714 resources, e.g., a connection with limited bandwidth, the client's 715 request for the roster is not mandatory). After a connected resource 716 sends initial presence (see Section 4.2), it is referred to as an 717 "available resource". If a connected resource or available resource 718 requests the roster, it is referred to as an "interested resource". 719 The server MUST send roster pushes to all interested resources. 721 Implementation Note: Presence subscription requests are sent to 722 available resources, whereas the roster pushes associated with 723 subscription state changes are sent to interested resources. 724 Therefore if a resource wishes to receive both subscription 725 requests and roster pushes, it MUST both send initial presence and 726 request the roster. 728 A client requests the roster by sending a roster get over its stream 729 with the server. 731 C: 734 735 737 S: 740 741 744 Friends 745 746 749 752 753 755 If the server cannot process the roster get, it MUST return an 756 appropriate stanza error as described in [XMPP-CORE] (such as 757 if the roster namespace is not supported or 758 if the server experiences trouble processing 759 or returning the roster). 761 2.3. Adding a Roster Item 763 2.3.1. Request 765 At any time, a client can add an item to the roster. This is done by 766 sending a roster set containing a new item. 768 C: 771 772 774 Servants 775 776 777 779 2.3.2. Success Case 781 If the server can successfully process the roster set for the new 782 item (i.e., if no error occurs), it MUST create the item in the 783 user's roster and proceed as follows. 785 The server MUST return an IQ stanza of type "result" to the connected 786 resource that sent the roster set. 788 S: 792 The server MUST also send a roster push containing the new roster 793 item to all of the user's interested resources, including the 794 resource that generated the roster set. 796 S: 799 800 803 Servants 804 805 806 808 S: 811 812 815 Servants 816 817 818 820 As mandated by the semantics of the IQ stanza as defined in 821 [XMPP-CORE], each resource that receives a roster push from the 822 server is supposed to reply with an IQ stanza of type "result" or 823 "error" (however, it is known that many existing clients do not reply 824 to roster pushes). 826 C: 830 C: 834 2.3.3. Error Cases 836 If the server cannot successfully process the roster set, it MUST 837 return a stanza error. The following error cases are defined. 838 Naturally, other stanza errors can occur, such as if the server experiences an internal problem with processing 840 the roster get, or even if the server only allows 841 roster modifications by means of a non-XMPP method such as a web 842 interface. 844 The server MUST return a stanza error to the client if 845 the sender of the roster set is not authorized to update the roster 846 (where typically only an authenticated resource of the account itself 847 is authorized). 849 The server MUST return a stanza error to the client if 850 the roster set contains any of the following violations: 852 1. The element contains more than one child 853 element. 855 2. The element contains more than one element, but 856 there are duplicate groups (one possible comparison method for 857 determining duplicates is that described for XMPP resourceparts 858 in [XMPP-ADDR]). 860 The server MUST return a stanza error to the client 861 if the roster set contains any of the following violations: 863 1. The length of the 'name' attribute is greater than a server- 864 configured limit. 866 2. The XML character data of the element is of zero length 867 (to remove an item from all groups, the client instead needs to 868 exclude any element from the roster set). 870 3. The XML character data of the element is larger than a 871 server-configured limit. 873 Error: Roster set initiated by unauthorized entity 875 C: 879 880 881 882 884 S: 887 888 889 890 892 Error: Roster set contains more than one item 894 C: 897 898 900 Servants 901 902 904 Family 905 906 907 909 S: 912 913 914 915 917 Error: Roster set contains item with oversized handle 919 C: 922 923 925 Servants 926 927 928 930 S: 933 934 935 936 938 Error: Roster set contains duplicate groups 940 C: 943 944 946 Servants 947 Servants 948 949 950 952 S: 955 956 957 958 960 Error: Roster set contains empty group 962 C: 965 966 968 969 970 971 973 S: 976 977 978 979 981 Error: Roster set contains oversized group name 983 C: 986 987 989 [ ... some-very-long-group-name ... ] 990 991 992 994 S: 997 998 999 1000 1002 Interoperability Note: Some servers return a stanza 1003 error to the client if the value of the element's 'jid' 1004 attribute matches the bare JID of the 1005 user's account. 1007 2.4. Updating a Roster Item 1009 2.4.1. Request 1011 Updating an existing roster item is done in the same way as adding a 1012 new roster item, i.e., by sending a roster set to the server. 1013 Because a roster item is atomic, the item MUST be updated exactly as 1014 provided in the roster set. 1016 There are several reasons why a client might update a roster item: 1018 1. Adding a group 1019 2. Deleting a group 1020 3. Changing the handle 1021 4. Deleting the handle 1023 Consider a roster item that is defined as follows: 1025 1027 Friends 1028 1030 The user who has this item in her roster might want to add the item 1031 to another group. 1033 C: 1036 1037 1039 Friends 1040 Lovers 1041 1042 1043 1045 Sometime later, the user might want to remove the item from the 1046 original group. 1048 C: 1051 1052 1054 Lovers 1055 1056 1057 1059 The user might want to remove the item from all groups. 1061 C: 1064 1065 1066 1067 1069 The user might also want to change the handle for the item. 1071 C: 1074 1075 1077 1079 1081 The user might then want to remove the handle altogether. 1083 C: 1086 1087 1089 1090 1092 Implementation Note: Including an empty 'name' attribute is 1093 equivalent to including no 'name' attribute; both actions set the 1094 name to the empty string. 1096 2.4.2. Success Case 1098 As with adding a roster item, if the roster item can be successfully 1099 processed then the server MUST update the item in the user's roster, 1100 send a roster push to all of the user's interested resources, and 1101 send an IQ result to the initiating resource; details are provided 1102 under Section 2.3. 1104 2.4.3. Error Cases 1106 The error cases described under Section 2.3.3 also apply to updating 1107 a roster item. 1109 2.5. Deleting a Roster Item 1111 2.5.1. Request 1113 At any time, a client can delete an item from his or her roster by 1114 sending a roster set and specifying a value of "remove" for the 1115 'subscription' attribute. 1117 C: 1120 1121 1123 1124 1126 2.5.2. Success Case 1128 As with adding a roster item, if the server can successfully process 1129 the roster set then it MUST update the item in the user's roster, 1130 send a roster push to all of the user's interested resources (with 1131 the 'subscription' attribute set to a value of "remove"), and send an 1132 IQ result to the initiating resource; details are provided under 1133 Section 2.3. 1135 In addition, the user's server might need to generate one or more 1136 subscription-related presence stanzas, as follows: 1138 1. If the user has a presence subscription to the contact, then the 1139 user's server MUST send a presence stanza of type "unsubscribe" 1140 to the contact (in order to unsubscribe from the contact's 1141 presence). 1143 2. If the contact has a presence subscription to the user, then the 1144 user's server MUST send a presence stanza of type "unsubscribed" 1145 to the contact (in order to cancel the contact's subscription to 1146 the user). 1148 3. If the presence subscription is mutual, then the user's server 1149 MUST send both a presence stanza of type "unsubscribe" and a 1150 presence stanza of type "unsubscribed" to the contact. 1152 S: 1157 S: 1162 2.5.3. Error Cases 1164 If the value of the 'jid' attribute specifies an item that is not in 1165 the roster, then the server MUST return an stanza 1166 error. 1168 Error: Roster item not found 1170 C: 1173 1174 1176 1177 1179 S: 1182 1183 1185 1186 1188 2.6. Roster Versioning 1190 2.6.1. Stream Feature 1192 If a server supports roster versioning, then it MUST advertise the 1193 following stream feature during stream negotiation. 1195 1196 1197 1199 The roster versioning stream feature SHOULD always be voluntary-to- 1200 negotiate (advertised by means of the child element), not 1201 mandatory-to-negotiate (advertised by means of the child 1202 element). 1204 2.6.2. Request 1206 If a client supports roster versioning and the server to which it has 1207 connected advertises support for roster versioning as described in 1208 the foregoing section, then the client SHOULD include the 'ver' 1209 element in its request for the roster. If the server does not 1210 advertise support for roster versioning, the client MUST NOT include 1211 the 'ver' attribute. If the client includes the 'ver' attribute in 1212 its roster get, it sets the attribute's value to the version ID 1213 associated with its last cache of the roster. 1215 C: 1219 1220 1222 If the client has not yet cached the roster or the cache is lost or 1223 corrupted, but the client wishes to bootstrap the use of roster 1224 versioning, it MUST set the 'ver' attribute to the empty string 1225 (i.e., ver=""). 1227 Naturally, if the client does not support roster versioning or does 1228 not wish to bootstrap the use of roster versioning, it will not 1229 include the 'ver' attribute. 1231 2.6.3. Success Case 1233 Whether or not the roster has been modified since the version ID 1234 enumerated by the client, the server MUST either return the complete 1235 roster as described under Section 2.1.4 (including a 'ver' attribute 1236 that signals the latest version) or return an empty IQ-result (thus 1237 indicating that any roster modifications will be sent via roster 1238 pushes, as described below). In general, unless returning the 1239 complete roster would (1) use less bandwidth than sending individual 1240 roster pushes to the client (e.g., if the roster contains only a few 1241 items) or (2) the server cannot associate the version ID with any 1242 previous version it has on file, the server SHOULD send an empty IQ- 1243 result and then send the modifications (if any) via roster pushes. 1245 S: 1250 Implementation Note: This empty IQ-result is different from an 1251 empty element, thus disambiguating this usage from an 1252 empty roster. 1254 If roster versioning is enabled and the roster has not been modified 1255 since the version ID enumerated by the client, the server will simply 1256 not send any roster pushes to the client (until and unless some 1257 relevant event triggers a roster push during the lifetime of the 1258 client's session). 1260 If the roster has been modified since the version ID enumerated by 1261 the client, the server MUST then send one roster push to the client 1262 for each roster item that has been modified since the version ID 1263 enumerated by the client. (We call a roster push that is sent for 1264 purposes of roster version synchronization an "interim roster push".) 1266 Definition: A "roster modification" is any change to the roster 1267 data that would result in a roster push to a connected client. 1268 Therefore internal states related to roster processing within the 1269 server that would not result in a roster push to a connected 1270 client do not necessitate a change to the version. 1272 S: 1276 1277 1278 1279 1281 S: 1285 1286 1287 1288 1290 S: 1294 1295 1298 Servants 1299 1300 1301 1303 S: 1307 1308 1311 VIPs 1312 1313 1314 1316 These "interim roster pushes" can be understood as follows: 1318 1. Imagine that the client had an active presence session for the 1319 entire time between its cached roster version (say, "ver14") and 1320 the new roster version (say, "ver96"). 1322 2. During that time, the client might have received roster pushes 1323 related to various roster versions (which might have been, say, 1324 "ver51" and "ver79"). However, some of those roster pushes might 1325 have contained intermediate updates to the same roster item 1326 (e.g., modifications to the subscription state for 1327 bill@example.org from "none" to "to" and from "to" to "both"). 1329 3. The interim roster pushes would not include all of the 1330 intermediate steps, only the final result of all modifications 1331 applied to each item while the client was in fact offline (which 1332 might have been, say, "ver34", "ver42", "ver72", and "ver96"). 1334 The client MUST handle an "interim roster push" in the same way it 1335 handles any roster push (indeed, from the client's perspective it 1336 cannot tell the difference between an "interim" roster push and a 1337 "live" roster push and therefore it has no way of knowing when it has 1338 received all of the interim roster pushes). When requesting the 1339 roster after reconnection, the client SHOULD request the version 1340 associated with the last roster push it received during its previous 1341 session, not the version associated with the roster result it 1342 received at the start of its previous session. 1344 When roster versioning is enabled, the server MUST include the 1345 updated roster version with each roster push. Roster pushes MUST 1346 occur in order of modification and the version contained in a roster 1347 push MUST be unique. Even if the client has not included the 'ver' 1348 attribute in its roster gets or sets, the server SHOULD include the 1349 'ver' attribute on all roster pushes and results that it sends to the 1350 client. 1352 Implementation Note: Guidelines and more detailed examples for 1353 roster versioning are provided in [XEP-0237]. 1355 3. Managing Presence Subscriptions 1357 In order to protect the privacy of XMPP users, presence information 1358 is disclosed only to other entities that a user has approved. When a 1359 user has agreed that another entity is allowed to view its presence, 1360 the entity is said to have a "subscription" to the user's presence. 1361 An entity that has a subscription to a user's presence or to which a 1362 user has a presence subscription is called a "contact" (in this 1363 document the term "contact" is also used in a less strict sense to 1364 refer to a potential contact or any item in a user's roster). 1366 In XMPP, a subscription lasts across presence sessions; indeed, it 1367 lasts until the contact unsubscribes or the user cancels the 1368 previously-granted subscription. (This model is different from that 1369 used for presence subscriptions in the Session Initiation Protocol 1370 (SIP), as defined in [SIP-PRES].) 1372 Subscriptions are managed within XMPP by sending presence stanzas 1373 containing specially-defined attributes ("subscribe", "unsubscribe", 1374 "subscribed", and "unsubscribed"). 1376 Implementation Note: When a server processes or generates an 1377 outbound presence stanza of type "subscribe", "subscribed", 1378 "unsubscribe", or "unsubscribed", the server MUST stamp the 1379 outgoing presence stanza with the bare JID 1380 of the sending entity, not the full JID 1381 . Enforcement of this rule 1382 simplifies the presence subscription model and helps to prevent 1383 presence leaks; for information about presence leaks, refer to the 1384 security considerations of [XMPP-CORE]. 1386 Subscription states are reflected in the rosters of both the user and 1387 the contact. This section does not cover every possible case related 1388 to presence subscriptions, and mainly narrates the protocol flows for 1389 bootstrapping a mutual subscription between a user and a contact. 1390 Complete details regarding subscription states can be found under 1391 Appendix A. 1393 3.1. Requesting a Subscription 1395 A "subscription request" is a request from a user for authorization 1396 to permanently subscribe to a contact's presence information; 1397 syntactically it is a presence stanza whose 'type' attribute has a 1398 value of "subscribe". A subscription request is generated by a 1399 user's client, processed by the (potential) contact's server, and 1400 acted on by the contact via the contact's client. The workflow is 1401 described in the following sections. 1403 Implementation Note: Presence subscription requests are sent to 1404 available resources, whereas the roster pushes associated with 1405 subscription state changes are sent to interested resources. 1406 Therefore if a resource wishes to receive both subscription 1407 requests and roster pushes, it MUST both send initial presence and 1408 request the roster. 1410 3.1.1. Client Generation of Outbound Subscription Request 1412 A user's client generates a subscription request by sending a 1413 presence stanza of type "subscribe" and specifying a 'to' address of 1414 the potential contact's bare JID . 1416 UC: 1420 When a user sends a presence subscription request to a potential 1421 instant messaging and presence contact, the value of the 'to' 1422 attribute MUST be a bare JID rather than a full 1423 JID , since the desired result is 1424 for the user to receive presence from all of the contact's resources, 1425 not merely the particular resource specified in the 'to' attribute. 1426 Use of bare JIDs also simplifies subscription processing, presence 1427 probes, and presence notifications by the user's server and the 1428 contact's server. 1430 For tracking purposes, a client SHOULD include an 'id' attribute in a 1431 presence subscription request. 1433 Implementation Note: Many XMPP clients prompt the user for 1434 information about the potential contact (e.g., "handle" and 1435 desired roster group) when generating an outbound presence 1436 subscription request and therefore send a roster set before 1437 sending the outbound presence subscription request. This behavior 1438 is OPTIONAL, because a client MAY instead wait until receiving the 1439 initial roster push from the server before uploading user-provided 1440 information about the contact. A server MUST process a roster set 1441 and outbound presence subscription request in either order (i.e., 1442 in whatever order generated by the client). 1444 3.1.2. Server Processing of Outbound Subscription Request 1446 Upon receiving the outbound presence subscription request, the user's 1447 server MUST proceed as follows. 1449 1. Before processing the request, the user's server MUST check the 1450 syntax of the JID contained in the 'to' attribute (however, it is 1451 known that some existing implementations do not perform this 1452 check). If the JID is of the form 1453 instead of 1454 , the user's server SHOULD treat it as if the 1455 request had been directed to the contact's bare JID and modify 1456 the 'to' address accordingly. The server MAY also verify that 1457 the JID adheres to the format defined in [XMPP-ADDR] and possibly 1458 return a stanza error. 1460 2. If the potential contact is hosted on the same server as the 1461 user, then the server MUST adhere to the rules specified in the 1462 next section when processing the subscription request and 1463 delivering it to the (local) contact. 1465 3. If the potential contact is hosted on a remote server, subject to 1466 local service policies the user's server MUST then route the 1467 stanza to that remote domain in accordance with core XMPP stanza 1468 processing rules. (This can result in returning an appropriate 1469 stanza error to the user, such as .) 1471 As mentioned, before locally delivering or remotely routing the 1472 presence subscription request, the user's server MUST stamp the 1473 outbound subscription request with the bare JID of 1474 the user. 1476 US: 1481 If the presence subscription request cannot be locally delivered or 1482 remotely routed (e.g., because the request is malformed, the local 1483 contact does not exist, the remote server does not exist, an attempt 1484 to contact the remote server times out, or any other error is 1485 determined or experienced by the user's server), then the user's 1486 server MUST return an appropriate error stanza to the user. An 1487 example follows. 1489 US: 1493 1494 1496 1497 1499 After locally delivering or remotely routing the presence 1500 subscription request, the user's server MUST then send a roster push 1501 to all of the user's interested resources, containing the potential 1502 contact with a subscription state of "none" and with notation that 1503 the subscription is pending (via an 'ask' attribute whose value is 1504 "subscribe"). 1506 US: 1509 1510 1513 1514 1516 US: 1519 1520 1523 1524 1525 1527 If a remote contact does not approve or deny the subscription request 1528 within some configurable amount of time, the user's server SHOULD 1529 resend the subscription request to the contact based on an 1530 implementation-specific algorithm (e.g., whenever a new resource 1531 becomes available for the user, or after a certain amount of time has 1532 elapsed); this helps to recover from transient, silent errors that 1533 might have occurred when the original subscription request was routed 1534 to the remote domain. When doing so, it is RECOMMENDED for the 1535 server to include an 'id' attribute so that it can track responses to 1536 the resent subscription request. 1538 3.1.3. Server Processing of Inbound Subscription Request 1540 Before processing the inbound presence subscription request, the 1541 contact's server SHOULD check the syntax of the JID contained in the 1542 'to' attribute. If the JID is of the form 1543 instead of , 1544 the contact's server SHOULD treat it as if the request had been 1545 directed to the contact's bare JID and modify the 'to' address 1546 accordingly. The server MAY also verify that the JID adheres to the 1547 format defined in [XMPP-ADDR] and possibly return a 1548 stanza error. 1550 When processing the inbound presence subscription request, the 1551 contact's server MUST adhere to the following rules: 1553 1. Above all, the contact's server MUST NOT automatically approve 1554 subscription requests on the contact's behalf -- unless the 1555 contact has (a) pre-approved subscription requests from the user 1556 as described under Section 3.4, (b) configured its account to 1557 automatically approve subscription requests, or (c) accepted an 1558 agreement with its service provider that allows automatic 1559 approval (for instance via an employment agreement within an 1560 enterprise deployment). Instead, if a subscription request 1561 requires approval then the contact's server MUST deliver that 1562 request to the contact's available resource(s) for approval or 1563 denial by the contact. 1565 2. If the contact exists and the user already has a subscription to 1566 the contact's presence, then the contact's server MUST auto-reply 1567 on behalf of the contact by sending a presence stanza of type 1568 "subscribed" from the contact's bare JID to the user's bare JID. 1569 Likewise, if the contact previously sent a presence stanza of 1570 type "subscribed" and the contact's server treated that as 1571 indicating "pre-approval" for the user's presence subscription 1572 (see Section 3.4), then the contact's server SHOULD also auto- 1573 reply on behalf of the contact. 1575 CS: 1580 3. Otherwise, if there is at least one available resource associated 1581 with the contact when the subscription request is received by the 1582 contact's server, then the contact's server MUST send that 1583 subscription request to all available resources in accordance 1584 with Section 8. 1586 As a way of acknowledging receipt of the presence subscription 1587 request, the contact's server MAY send a presence stanza of type 1588 "unavailable" from the bare JID of the contact to the bare JID of 1589 the user (the user's client MUST NOT assume that this 1590 acknowledgement provides presence information about the contact, 1591 since it comes from the contact's bare JID and is received before 1592 the subscription request has been approved). 1594 4. Otherwise, if the contact has no available resources when the 1595 subscription request is received by the contact's server, then 1596 the contact's server MUST keep a record of the complete presence 1597 stanza comprising the subscription request, including any 1598 extended content contained therein (see Section 8.4 of 1599 [XMPP-CORE]), and then deliver the request when the contact next 1600 has an available resource. The contact's server MUST continue to 1601 deliver the subscription request whenever the contact creates an 1602 available resource, until the contact either approves or denies 1603 the request. (The contact's server MUST NOT deliver more than 1604 one subscription request from any given user when the contact 1605 next has an available resource; e.g., if the user sends multiple 1606 subscription requests to the contact while the contact is 1607 offline, the contact's server SHOULD store only one of those 1608 requests, such as the first request or last request, and MUST 1609 deliver only one of the requests when the contact next has an 1610 available resource; this helps to prevent "subscription request 1611 spam".) 1613 Security Warning: Until and unless the contact approves the 1614 subscription request as described under Section 3.1.4, the 1615 contact's server MUST NOT add an item for the user to the 1616 contact's roster. 1618 Security Warning: The mandate for the contact's server to store 1619 the complete stanza of the presence subscription request 1620 introduces the possibility of an application resource exhaustion 1621 attack (see Section 2.1.2 of [DOS]), for example by a rogue server 1622 or a coordinated group of users (e.g., a botnet) against the 1623 contact's server or particular contact. Server implementors are 1624 advised to consider the possibility of such attacks and provide 1625 tools for counteracting it, such as enabling service 1626 administrators to set limits on the number or size of inbound 1627 presence subscription requests that the server will store in 1628 aggregate or for any given contact. 1630 3.1.4. Client Processing of Inbound Subscription Request 1632 When an interactive client receives a subscription request, it MUST 1633 present the request to the natural person controlling the client 1634 (i.e., the "contact") for approval, unless the contact has explicitly 1635 configured the client to automatically approve or deny some or all 1636 subscription requests as described above. An automated client that 1637 is not controlled by a natural person will have its own application- 1638 specific rules for approving or denying subscription requests. 1640 A client approves a subscription request by sending a presence stanza 1641 of type "subscribed", which is processed as described under 1642 Section 3.1.5 for the contact's server and Section 3.1.6 for the 1643 user's server. 1645 CC: 1649 A client denies a subscription request by sending a presence stanza 1650 of type "unsubscribed", which is processed as described under 1651 Section 3.2 for both the contact's server and the user's server. 1653 CC: 1657 For tracking purposes, a client SHOULD include an 'id' attribute in a 1658 subscription approval or subscription denial; this 'id' attribute 1659 MUST NOT mirror the 'id' attribute of the subscription request. 1661 3.1.5. Server Processing of Outbound Subscription Approval 1663 When the contact's client sends the subscription approval, the 1664 contact's server MUST stamp the outbound stanza with the bare JID 1665 of the contact and locally deliver or remotely 1666 route the stanza to the user. 1668 CS: 1673 The contact's server then MUST send an updated roster push to all of 1674 the contact's interested resources, with the 'subscription' attribute 1675 set to a value of "from". (Here we assume that the contact does not 1676 already have a subscription to the user; if that were the case, the 1677 'subscription' attribute would be set to a value of "both", as 1678 explained under Appendix A.) 1680 CS: 1683 1684 1686 1687 1689 CS: 1692 1693 1695 1696 1698 From the perspective of the contact, there now exists a subscription 1699 from the user, which is why the 'subscription' attribute is set to a 1700 value of "from". (Here we assume that the contact does not already 1701 have a subscription to the user; if that were the case, the 1702 'subscription' attribute would be set to a value of "both", as 1703 explained under Appendix A.) 1705 The contact's server MUST then also send current presence to the user 1706 from each of the contact's available resources. 1708 CS: 1712 CS: 1716 In order to subscribe to the user's presence, the contact would then 1717 need to send a subscription request to the user. (XMPP clients will 1718 often automatically send the subscription request instead of 1719 requiring the contact to initiate the subscription request, since it 1720 is assumed that the desired end state is a mutual subscription.) 1721 Naturally, when the contact sends a subscription request to the user, 1722 the subscription states will be different from those shown in the 1723 foregoing examples (see Appendix A) and the roles will be reversed. 1725 3.1.6. Server Processing of Inbound Subscription Approval 1727 When the user's server receives a subscription approval, it MUST 1728 first check if the contact is in the user's roster with 1729 subscription='none' or subscription='from' and the 'ask' flag set to 1730 "subscribe" (i.e., a subscription state of "None + Pending Out", 1731 "None + Pending Out+In", or "From + Pending Out"; see Appendix A). 1732 If this check is successful, then the user's server MUST: 1734 1. Deliver the inbound subscription approval to all of the user's 1735 interested resources (this helps to give the user's client(s) 1736 proper context regarding the subscription approval so that they 1737 can differentiate between a roster push originated by another of 1738 the user's resources and a subscription approval received from 1739 the contact). This MUST occur before sending the roster push 1740 described in the next step. 1742 US: 1747 2. Initiate a roster push to all of the user's interested resources, 1748 containing an updated roster item for the contact with the 1749 'subscription' attribute set to a value of "to" (if the 1750 subscription state was "None + Pending Out" or "None + Pending 1751 Out+In") or "both" (if the subscription state was "From + Pending 1752 Out"). 1754 US: 1757 1758 1760 1761 1763 US: 1766 1767 1769 1770 1771 1773 3. The user's server MUST also deliver the available presence stanza 1774 received from each of the contact's available resources to each 1775 of the user's available resources. 1777 [ ... to resource1 ... ] 1779 US: 1783 [ ... to resource2 ... ] 1785 US: 1789 [ ... to resource1 ... ] 1791 US: 1795 [ ... to resource2 ... ] 1797 US: 1801 Implementation Note: If the user's account has no available 1802 resources when the inbound subscription approval notification is 1803 received, the user's server MAY keep a record of the notification 1804 (ideally the complete presence stanza) and then deliver the 1805 notification when the account next has an available resource. 1806 This behavior provides more complete signalling to the user 1807 regarding the reasons for the roster change that occurred while 1808 the user was offline. 1810 Otherwise -- that is, if the user does not exist, if the contact is 1811 not in the user's roster, or if the contact is in the user's roster 1812 with a subscription state other than those described in the foregoing 1813 check -- then the user's server MUST silently ignore the subscription 1814 approval notification by not delivering it to the user, not modifying 1815 the user's roster, and not generating a roster push to the user's 1816 interested resources. 1818 From the perspective of the user, there now exists a subscription to 1819 the contact's presence (which is why the 'subscription' attribute is 1820 set to a value of "to"). 1822 3.2. Cancelling a Subscription 1824 3.2.1. Client Generation of Subscription Cancellation 1826 If a contact would like to cancel a subscription that it has 1827 previously granted to a user, to cancel a subscription pre-approval 1828 (Section 3.4), or to deny a subscription request, it sends a presence 1829 stanza of type "unsubscribed". 1831 CC: 1835 3.2.2. Server Processing of Outbound Subscription Cancellation 1837 Upon receiving the outbound subscription cancellation, the contact's 1838 server MUST proceed as follows. 1840 1. If the user's bare JID is not yet in the contact's roster or is 1841 in the contact's roster with a state of "None", "None + Pending 1842 Out", or "To", the contact's server SHOULD NOT route or deliver 1843 the presence stanza of type "unsubscribed" to the user and MUST 1844 NOT send presence notifications of type "unavailable" to the user 1845 as described below. 1847 2. If the user's bare JID is in the contact's roster with a state of 1848 "None", "None + Pending Out", or "To" and the 'approved' flag is 1849 set to "true" (thus signalling a subscription pre-approval as 1850 described under Section 3.4), the contact's server MUST remove 1851 the pre-approval and MUST NOT route or deliver the presence 1852 stanza of type "unsubscribed" to the user. 1854 3. Otherwise, as shown in the following examples, the contact's 1855 server MUST route or deliver both presence notifications of type 1856 "unavailable" and presence stanzas of type "unsubscribed" to the 1857 user and MUST send a roster push to the contact. 1859 While the user is still subscribed to the contact's presence (i.e., 1860 before the contact's server routes or delivers the presence stanza of 1861 type "unsubscribed" to the user), the contact's server MUST send a 1862 presence stanza of type "unavailable" from all of the contact's 1863 online resources to the user. 1865 CS: 1869 CS: 1873 Then the contact's server MUST route or deliver the presence stanza 1874 of type "unsubscribed" to the user, making sure to stamp the outbound 1875 subscription cancellation with the bare JID of 1876 the contact. 1878 CS: 1883 The contact's server then MUST send a roster push with the updated 1884 roster item to all of the contact's interested resources, where the 1885 subscription state is now either "none" or "to" (see Appendix A). 1887 CS: 1890 1891 1893 1894 1896 CS: 1899 1900 1902 1903 1905 3.2.3. Server Processing of Inbound Subscription Cancellation 1907 When the user's server receives the inbound subscription 1908 cancellation, it MUST first check if the contact is in the user's 1909 roster with subscription='to' or subscription='both' (see 1910 Appendix A). If this check is successful, then the user's server 1911 MUST: 1913 1. Deliver the inbound subscription cancellation to all of the 1914 user's interested resources (this helps to give the user's 1915 client(s) proper context regarding the subscription cancellation 1916 so that they can differentiate between a roster push originated 1917 by another of the user's resources and a subscription 1918 cancellation received from the contact). This MUST occur before 1919 sending the roster push described in the next step. 1921 US: 1926 2. Initiate a roster push to all of the user's interested resources, 1927 containing an updated roster item for the contact with the 1928 'subscription' attribute set to a value of "none" (if the 1929 subscription state was "To" or "To + Pending In") or "from" (if 1930 the subscription state was "Both"). 1932 US: 1935 1936 1938 1939 1941 US: 1944 1945 1947 1948 1949 1951 The user's server MUST also deliver the inbound presence stanzas of 1952 type "unavailable". 1954 Implementation Note: If the user's account has no available 1955 resources when the inbound unsubscribed notification is received, 1956 the user's server MAY keep a record of the notification (ideally 1957 the complete presence stanza) and then deliver the notification 1958 when the account next has an available resource. This behavior 1959 provides more complete signalling to the user regarding the 1960 reasons for the roster change that occurred while the user was 1961 offline. 1963 Otherwise -- that is, if the user does not exist, if the contact is 1964 not in the user's roster, or if the contact is in the user's roster 1965 with a subscription state other than those described in the foregoing 1966 check -- then the user's server MUST silently ignore the unsubscribed 1967 notification by not delivering it to the user, not modifying the 1968 user's roster, and not generating a roster push to the user's 1969 interested resources. 1971 3.3. Unsubscribing 1973 3.3.1. Client Generation of Unsubscribe 1975 If a user would like to unsubscribe from a contact's presence, it 1976 sends a presence stanza of type "unsubscribe". 1978 UC: 1982 3.3.2. Server Processing of Outbound Unsubscribe 1984 Upon receiving the outbound unsubscribe, the user's server MUST 1985 proceed as follows. 1987 1. If the contact is hosted on the same server as the user, then the 1988 server MUST adhere to the rules specified in the next section 1989 when processing the subscription request. 1991 2. If the contact is hosted on a remote server, subject to local 1992 service policies the user's server MUST then route the stanza to 1993 that remote domain in accordance with core XMPP stanza processing 1994 rules. (This can result in returning an appropriate stanza error 1995 to the user, such as .) 1997 As mentioned, before locally delivering or remotely routing the 1998 unsubscribe, the user's server MUST stamp the stanza with the bare 1999 JID of the user. 2001 US: 2006 The user's server then MUST send a roster push with the updated 2007 roster item to all of the user's interested resources, where the 2008 subscription state is now either "none" or "from" (see Appendix A). 2010 US: 2013 2014 2016 2017 2019 US: 2022 2023 2025 2026 2027 2029 3.3.3. Server Processing of Inbound Unsubscribe 2031 When the contact's server receives the unsubscribe notification, it 2032 MUST first check if the user's bare JID is in the contact's roster 2033 with subscription='from' or subscription='both' (i.e., a subscription 2034 state of "From", "From + Pending Out", or "Both"; see Appendix A). 2035 If this check is successful, then the contact's server MUST: 2037 1. Deliver the inbound unsubscribe to all of the contact's 2038 interested resources (this helps to give the contact's client(s) 2039 proper context regarding the unsubscribe so that they can 2040 differentiate between a roster push originated by another of the 2041 contact's resources and an unsubscribe received from the user). 2042 This MUST occur before sending the roster push described in the 2043 next step. 2045 CS: 2050 2. Initiate a roster push to all of the contact's interested 2051 resources, containing an updated roster item for the user with 2052 the 'subscription' attribute set to a value of "none" (if the 2053 subscription state was "From" or "From + Pending Out") or "to" 2054 (if the subscription state was "Both"). 2056 CS: 2059 2060 2062 2063 2065 CS: 2068 2069 2071 2072 2074 3. Generate an outbound presence stanza of type "unavailable" from 2075 each of the contact's available resources to the user. 2077 CS: 2082 CS: 2087 Implementation Note: If the contact's account has no available 2088 resources when the inbound unsubscribe notification is received, 2089 the contact's server MAY keep a record of the notification 2090 (ideally the complete presence stanza) and then deliver the 2091 notification when the account next has an available resource. 2092 This behavior provides more complete signalling to the user 2093 regarding the reasons for the roster change that occurred while 2094 the user was offline. 2096 Otherwise -- that is, if the contact does not exist, if the user is 2097 not in the contact's roster, or if the user's bare JID is in the 2098 contact's roster with a subscription state other than those described 2099 in the foregoing check -- then the contact's server MUST silently 2100 ignore the unsubscribe stanza by not delivering it to the contact, 2101 not modifying the contact's roster, and not generating a roster push 2102 to the contact's interested resources. However, if the contact's 2103 server is keeping track of an inbound presence subscription request 2104 from the user to the contact but the user is not yet in the contact's 2105 roster (functionally equivalent to a subscription state of "None + 2106 Pending In" where the contact never added the user to the contact's 2107 roster), then the contact's server MUST simply remove any record of 2108 the inbound presence subscription request (it cannot remove the user 2109 from the contact's roster because the user was never added to the 2110 contact's roster). 2112 Implementation Note: The user's client MUST NOT depend on 2113 receiving the unavailable presence notification from the contact, 2114 since it MUST consider its presence subscription to the contact, 2115 and its presence information about the contact, to be null and 2116 void when it sends the presence stanza of type "unsubscribe" or 2117 when it receives the roster push triggered by the unsubscribe 2118 request. 2120 3.4. Pre-Approving a Subscription Request 2122 If a user has not received a subscription request from a contact, the 2123 user can "pre-approve" such a request so that it will be 2124 automatically approved by the user's server. 2126 Support for subscription pre-approvals is OPTIONAL on the part of 2127 clients and servers. If a server supports subscription pre- 2128 approvals, then it MUST advertise the following stream feature during 2129 stream negotiation. 2131 2133 The subscription pre-approval stream feature is merely informative 2134 and therefore is never mandatory-to-negotiate. 2136 3.4.1. Client Generation of Subscription Pre-Approval 2138 If the server to which a client connects has advertised support for 2139 subscription pre-approvals, the client MAY generate a subscription 2140 pre-approval by sending a presence stanza of type "subscribed" to the 2141 contact. 2143 UC: 2147 If the server does not advertise support for subscription pre- 2148 approvals, the client MUST NOT attempt to pre-approve subscription 2149 requests from potential or actual contacts. 2151 3.4.2. Server Processing of Subscription Pre-Approval 2153 Upon receiving the presence stanza of type "subscribed", the user's 2154 server MUST proceed as follows if it supports subscription pre- 2155 approvals. 2157 1. If the contact is in the user's roster with a state of "Both", 2158 "From", or "From + Pending Out", the user's server MUST silently 2159 ignore the stanza. 2161 2. If the contact is in the user's roster with a state of "To + 2162 Pending In", "None + Pending In", or "None + Pending Out+In", the 2163 user's server MUST handle the stanza as a normal subscription 2164 approval (see under Section 3.1.5) by updating the existing 2165 roster item to a state of "Both", "From", or "From + Pending Out" 2166 (respectively), pushing the modified roster item to all of the 2167 user's interested resources, and routing the presence stanza of 2168 type "subscribed" to the contact. 2170 3. If the contact is in the user's roster with a state of "To", 2171 "None", or "None + Pending Out", the user's server MUST note the 2172 subscription pre-approval by setting the 'approved' flag to a 2173 value of "true", then push the modified roster item to all of the 2174 user's interested resources. However, the user's server MUST NOT 2175 route the presence stanza of type "subscribed" to the contact. 2177 4. If the contact is not yet in the user's roster, the user's server 2178 MUST create a roster item for the contact with a state of "None" 2179 and set the 'approved' flag to a value of "true", then push the 2180 roster item to all of the user's interested resources. However, 2181 the user's server MUST NOT route the presence stanza of type 2182 "subscribed" to the contact. 2184 An example of the roster push follows. 2186 US: 2189 2190 2193 2194 2196 2198 When the 'approved' flag is set to "true", the user's server MUST NOT 2199 deliver a presence stanza of type "subscribe" from the contact to the 2200 user, but instead MUST automatically respond to such a stanza on 2201 behalf of the user by returning a presence stanza of type 2202 "subscribed" from the bare JID of the user to the bare JID of the 2203 contact. 2205 Implementation Note: It is a matter of implementation or local 2206 service policy whether the server maintains a record of the 2207 subscription approval after it has received a presence 2208 subscription request from the contact. If the server does not 2209 maintain such a record, upon receiving the subscription request it 2210 will not include the 'approved' attribute in the roster item for 2211 the contact (i.e., in subsequent roster pushes and roster 2212 results). If the server maintains such a record, it will always 2213 include the 'approved' attribute (set to "true") in the roster 2214 item for the contact, until and unless the user sends a presence 2215 stanza of type "unsubscribed" to the contact (or removes the 2216 contact from the roster entirely). 2218 Implementation Note: A client can cancel a pre-approval by sending 2219 a presence stanza of type "unsubscribed", as described more fully 2220 under Section 3.2. In this case the user's server would send a 2221 roster push to all of the user's interested resources with the 2222 'approved' attribute removed. (Alternatively, the client can 2223 simply remove the roster item entirely.) 2225 4. Exchanging Presence Information 2227 4.1. Presence Fundamentals 2229 The concept of presence refers to an entity's availability for 2230 communication over a network. At the most basic level, presence is a 2231 boolean "on/off" variable that signals whether an entity is available 2232 or unavailable for communication (the terms "online" and "offline" 2233 are also used). In XMPP, an entity's availability is signalled when 2234 its client generates a stanza with no 'type' attribute, 2235 and an entity's lack of availability is signalled when its client 2236 generates a stanza whose 'type' attribute has a value of 2237 "unavailable". 2239 XMPP presence typically follows a "publish-subscribe" or "observer" 2240 pattern, wherein an entity sends presence to its server, and its 2241 server then broadcasts that information to all of the entity's 2242 contacts who have a subscription to the entity's presence (in the 2243 terminology of [IMP-MODEL], an entity that generates presence is a 2244 "presentity" and the entities that receive presence are 2245 "subscribers"). A client generates presence for broadcast to all 2246 subscribed entities by sending a presence stanza to its server with 2247 no 'to' address, where the presence stanza has either no 'type' 2248 attribute or a 'type' attribute whose value is "unavailable". This 2249 kind of presence is called "broadcast presence". (A client can also 2250 send "directed presence", i.e., a presence stanza with a 'to' 2251 address; this is less common but is sometimes used to send presence 2252 to entities that are not subscribed to the user's presence; see 2253 Section 4.6.) 2255 After a client completes the preconditions specified in [XMPP-CORE], 2256 it can establish a "presence session" at its server by sending 2257 initial presence (Section 4.2), where the presence session is 2258 terminated by sending unavailable presence (Section 4.5). For the 2259 duration of its presence session, a connected resource (in the 2260 terminology of [XMPP-CORE]) is said to be an "available resource". 2262 In XMPP applications that combine messaging and presence 2263 functionality, the default type of communication for which presence 2264 signals availability is messaging; however, it is not necessary for 2265 XMPP applications to combine messaging and presence functionality, 2266 and they can provide standalone presence features without messaging 2267 (in addition, XMPP servers do not require information about network 2268 availability in order to successfully route message and IQ stanzas). 2270 Informational Note: In the examples that follow, the user is 2271 , she has two available resources ("balcony" 2272 and "chamber"), and she has three contacts in her roster with a 2273 subscription state of "from" or "both": , 2274 , and . 2276 4.2. Initial Presence 2278 4.2.1. Client Generation of Initial Presence 2280 After completing the preconditions described in [XMPP-CORE] 2281 (REQUIRED) and requesting the roster (RECOMMENDED), a client signals 2282 its availability for communication by sending "initial presence" to 2283 its server, i.e., a presence stanza with no 'to' address (indicating 2284 that it is meant to be broadcast by the server on behalf of the 2285 client) and no 'type' attribute (indicating the user's availability). 2287 UC: 2289 The initial presence stanza MAY contain the element, the 2290 element, and one or more instances of the element, 2291 as well as extended content; details are provided under Section 4.7. 2293 4.2.2. Server Processing of Outbound Initial Presence 2295 Upon receiving initial presence from a client, the user's server MUST 2296 send the initial presence stanza from the full JID 2297 of the user to all contacts that are 2298 subscribed to the user's presence; such contacts are those for which 2299 a JID is present in the user's roster with the 'subscription' 2300 attribute set to a value of "from" or "both". 2302 US: 2305 US: 2308 US: 2311 The user's server MUST also broadcast initial presence from the 2312 user's newly available resource to all of the user's available 2313 resources, including the resource that generated the presence 2314 notification in the first place (i.e., an entity is implicitly 2315 subscribed to its own presence). 2317 [... to the "balcony" resource ...] 2319 US: 2322 [... to the "chamber" resource ...] 2324 US: 2327 In the absence of presence information about the user's contacts, the 2328 user's server MUST also send presence probes to the user's contacts 2329 on behalf of the user as specified under Section 4.3. 2331 4.2.3. Server Processing of Inbound Initial Presence 2333 Upon receiving presence from the user, the contact's server MUST 2334 deliver the user's presence stanza to all of the contact's available 2335 resources. 2337 [ ... to resource1 ... ] 2339 CS: 2342 [ ... to resource2 ... ] 2344 CS: 2347 4.2.4. Client Processing of Initial Presence 2349 When the contact's client receives presence from the user, the 2350 following behavior is suggested for interactive clients: 2352 1. If the user's bare JID is in the contact's roster, display the 2353 presence information in an appropriate roster interface. 2355 2. If the user is not in the contact's roster but the contact and 2356 the user are actively exchanging message or IQ stanzas, display 2357 the presence information in the user interface for that 2358 communication session (see also Section 4.6 and Section 5.1). 2360 3. Otherwise, ignore the presence information and do not display it 2361 to the contact. 2363 4.3. Presence Probes 2365 A "presence probe" is a request for a contact's current presence 2366 information, sent on behalf of a user by the user's server; 2367 syntactically it is a presence stanza whose 'type' attribute has a 2368 value of "probe". In the context of presence subscriptions, the 2369 value of the 'from' address MUST be the bare JID of the subscribed 2370 user and the value of the 'to' address MUST be the bare JID of the 2371 contact to which the user is subscribed, since presence subscriptions 2372 are based on the bare JID. 2374 US: 2379 Interoperability Note: RFC 3921 specified that probes are sent 2380 from the full JID, not the bare JID (a rule which was changed 2381 because subscriptions are based on the bare JID). Some existing 2382 implementations send from the full JID instead of the bare JID. 2384 Probes can also be sent by an entity that has received presence 2385 outside the context of a presence subscription, typically when the 2386 contact has sent directed presence as described under Section 4.6; in 2387 this case the value of the 'from' or 'to' address can be a full JID 2388 instead of a bare JID. See Section 4.6 for a complete discussion. 2390 Presence probes SHOULD NOT be sent by a client, because in general a 2391 client will not need to send them since the task of gathering 2392 presence from a user's contacts is managed by the user's server. 2393 However, if a user's client generates an outbound presence probe then 2394 the user's server SHOULD route the probe (if the contact is at 2395 another server) or process the probe (if the contact is at the same 2396 server) and MUST NOT use its receipt of the presence probe from a 2397 connected client as the sole cause for returning a stanza or stream 2398 error to the client. 2400 4.3.1. Server Generation of Outbound Presence Probe 2402 When a server needs to discover the availability of a user's contact, 2403 it sends a presence probe from the bare JID of the 2404 user to the bare JID of the contact. 2406 Implementation Note: Although presence probes are intended for 2407 sending to contacts (i.e., entities to which a user is 2408 subscribed), a server MAY send a presence probe to the full JID of 2409 an entity from which the user has received presence information 2410 during the current session. 2412 The user's server SHOULD send a presence probe whenever the user 2413 starts a new presence session by sending initial presence; however, 2414 the server MAY choose not to send the probe at that point if it has 2415 what it deems to be reliable and up-to-date presence information 2416 about the user's contacts (e.g., because the user has another 2417 available resource or because the user briefly logged off and on 2418 before the new presence session began). In addition, a server MAY 2419 periodically send a presence probe to a contact if it has not 2420 received presence information or other traffic from the contact in 2421 some configurable amount of time; this can help to prevent "ghost" 2422 contacts who appear to be online but in fact are not. 2424 US: 2429 US: 2434 Naturally, the user's server does not need to send a presence probe 2435 to a contact if the contact's account resides on the same server as 2436 the user, since the server possesses the contact's information 2437 locally. 2439 4.3.2. Server Processing of Inbound Presence Probe 2441 Upon receiving a presence probe to the contact's bare JID from the 2442 user's server on behalf of the user, the contact's server MUST reply 2443 as follows: 2445 1. If the contact account does not exist or the user's bare JID is 2446 in the contact's roster with a subscription state other than 2447 "From", "From + Pending Out", or "Both" (as explained under 2448 Appendix A), then the contact's server SHOULD return a presence 2449 stanza of type "unsubscribed" in response to the presence probe 2450 (this will trigger a protocol flow for cancelling the user's 2451 subscription to the contact as described under Section 3.2; 2452 however, this MUST NOT result in cancellation of a subscription 2453 pre-approval as described under Section 3.4). Here the 'from' 2454 address MUST be the bare JID of the contact, since specifying a 2455 full JID would constitute a presence leak as described in 2456 [XMPP-CORE]. 2458 CS: 2463 However, if a server receives a presence probe from a configured 2464 domain of the server itself or another such trusted service, it 2465 MAY provide presence information about the user to that entity. 2467 2. Else, if the contact has moved temporarily or permanently to 2468 another address, then the server SHOULD return a presence stanza 2469 of type "error" with a stanza error condition of 2470 (temporary) or (permanent) that includes the new address 2471 of the contact. 2473 CS: 2477 2478 2479 xmpp:la-mer@example.com 2480 2481 2482 2484 3. Else, if the contact has no available resources, then the server 2485 SHOULD reply to the presence probe by sending to the user a 2486 presence stanza of type "unavailable" (although sending 2487 unavailable presence here is preferable because it results in a 2488 deterministic answer to the probe, it is not mandatory because it 2489 can greatly increase the number of presence notifications 2490 generated by the contact's server). Here the 'from' address is 2491 the bare JID because there is no available resource associated 2492 with the contact. 2494 If appropriate in accordance with local security policies this 2495 presence notification MAY include the full XML of the last 2496 unavailable presence stanza that the server received from the 2497 contact (including the 'id' of the original stanza), but if not 2498 then the presence notification SHOULD simply indicate that the 2499 contact is unavailable without any of the details originally 2500 provided. In any case the presence notification returned to the 2501 probing entity SHOULD include information about the time when the 2502 last unavailable presence stanza was generated (formatted using 2503 the XMPP delayed delivery extension [DELAY]). 2505 CS: 2509 2511 2513 4. Else, if the contact has at least one available resource, then 2514 the server MUST reply to the presence probe by sending to the 2515 user the full XML of the last presence stanza with no 'to' 2516 attribute received by the server from each of the contact's 2517 available resources. Here the 'from' addresses are the full JIDs 2518 of each available resource. 2520 CS: 2524 CS: 2527 away 2528 2530 Implementation Note: By "full XML" is meant the complete stanza 2531 from the opening tag to the closing tag, 2532 including all elements and attributes whether qualified by the 2533 content namespace or extended namespaces; however, in accordance 2534 with [XMPP-CORE], the contact's server will need to transform the 2535 content namespace from 'jabber:client' to 'jabber:server' if it 2536 sends the complete stanza over a server-to-server stream. 2538 If the contact's server receives a presence probe addressed to a full 2539 JID of the contact, the server MUST NOT return presence information 2540 about any resource except the resource specified by the 'to' address 2541 of the probe. Rules #1 and #2 for a bare JID probe apply equally to 2542 the case of a full JID probe. If there is a resource matching the 2543 full JID and the probing entity has authorization via a presence 2544 subscription to see the contact's presence, then the server MUST 2545 return an available presence notification, which SHOULD communicate 2546 only the fact that the resource is available (not detailed 2547 information such as the , , , or presence 2548 extensions). 2550 CS: 2553 Implementation Note: See Section 4.6 regarding rules that 2554 supplement the foregoing for handling of directed presence. 2556 4.3.2.1. Handling of the 'id' Attribute 2558 The handling of the 'id' attribute in relation to presence probes was 2559 unspecified in RFC 3921. Although the pattern of "send a probe and 2560 receive a reply" might seem like a request-response protocol similar 2561 to the XMPP stanza, in fact it is not because the response to a 2562 probe might consist of multiple presence stanzas (one for each 2563 available resource currently active for the contact). For this 2564 reason, if the contact currently has available resources then the 2565 contact's server SHOULD preserve the 'id' attribute of the contact's 2566 original presence stanza (if any) when sending those presence 2567 notifications to the probing entity; by contrast, if the contact 2568 currently has no available resources, the probing entity is not 2569 authorized (via presence subscription) to see the contact's presence, 2570 or an error occurs in relation to the probe, then the contact's 2571 server SHOULD mirror the 'id' of the user's presence probe when 2572 replying to the probing entity. 2574 The following examples illustrate the difference. 2576 In the first scenario, Juliet sends presence from her "chamber" 2577 resource. 2579 CC: 2580 dnd 2581 busy! 2582 2584 She also sends presence from her "balcony" resource. 2586 CC: 2587 away 2588 stepped away 2589 2591 Romeo's server then sends a probe to Juliet. 2593 US: 2595 Juliet's server then sends both of her presence notifications to 2596 Romeo, preserving the 'id' attributes included in the stanzas that 2597 her client has sent. 2599 CS: 2600 dnd 2601 busy! 2602 2604 CS: 2605 away 2606 stepped away 2607 2609 In the second scenario, Juliet is offline when Romeo's server sends a 2610 probe. 2612 US: 2616 Juliet's server replies with an unavailable notification, mirroring 2617 the 'id' of Rome's presence probe because there is no 'id' to 2618 preserve from an available notification that her client has sent. 2620 CS: 2624 4.4. Subsequent Presence Broadcast 2626 4.4.1. Client Generation of Subsequent Presence Broadcast 2628 After sending initial presence, at any time during its session the 2629 user's client can update its availability for broadcast by sending a 2630 presence stanza with no 'to' address and no 'type' attribute. 2632 UC: 2633 away 2634 2636 The presence broadcast MAY contain the element, the 2637 element, and one or more instances of the element, 2638 as well as extended content; details are provided under Section 4.7. 2640 However, a user SHOULD send a presence update only to broadcast 2641 information that is relevant to the user's availability for 2642 communication or the communication capabilities of the resource. 2643 Information that is not relevant in this way might be of interest to 2644 the user's contacts but SHOULD be sent via other means, such as the 2645 "publish-subscribe" method described in [XEP-0163]. 2647 4.4.2. Server Processing of Subsequent Outbound Presence 2649 Upon receiving a presence stanza expressing updated availability, the 2650 user's server MUST broadcast the full XML of that presence stanza to 2651 the contacts who are in the user's roster with a subscription type of 2652 "from" or "both". 2654 Interoperability Note: RFC 3921 specified that the user's server 2655 would check to make sure that it had not received a presence error 2656 from the contact before sending subsequent presence notifications; 2657 that rule has been removed because this specification uses 2658 presence stanzas of type "unsubscribe" (not "error") to solve 2659 subscription synchronization problems, in part because such 2660 stanzas change the contact's subscription state in the user's 2661 roster to either "none" or "to" (see Section 3.3 and Appendix A), 2662 thus obviating the need for the error check. 2664 Interoperability Note: If the subscription type is "both", some 2665 existing server implementations send subsequent presence 2666 notifications to a contact only if the contact is online according 2667 to the user's server (that is, if the user's server never received 2668 a positive indication that the contact is online in response to 2669 the presence probe it sent to the contact, the user's server does 2670 not send subsequent presence notifications from the user to the 2671 contact). This behavior is perceived to save bandwidth, since 2672 most presence subscriptions are bidirectional and many contacts 2673 will not be online at any given time. 2675 US: 2677 away 2678 2680 US: 2682 away 2683 2685 US: 2687 away 2688 2690 Implementation Note: See Section 4.6 regarding rules that 2691 supplement the foregoing for handling of directed presence. 2693 The user's server MUST also send the presence stanza to all of the 2694 user's available resources (including the resource that generated the 2695 presence notification in the first place). 2697 US: 2699 away 2700 2702 US: 2704 away 2705 2707 4.4.3. Server Processing of Subsequent Inbound Presence 2709 Upon receiving presence from the user, the contact's server MUST 2710 deliver the user's presence stanza to all of the contact's available 2711 resources. 2713 [ ... to resource1 ... ] 2715 CS: 2717 away 2718 2720 [ ... to resource2 ... ] 2722 CS: 2724 away 2725 2727 4.4.4. Client Processing of Subsequent Presence 2729 From the perspective of the contact's client, there is no significant 2730 difference between initial presence broadcast and subsequent 2731 presence, so the contact's client follows the rules for processing of 2732 inbound presence defined under Section 4.4.3. 2734 4.5. Unavailable Presence 2736 4.5.1. Client Generation of Unavailable Presence 2738 Before ending its presence session with a server, the user's client 2739 SHOULD gracefully become unavailable by sending "unavailable 2740 presence", i.e., a presence stanza that possesses no 'to' attribute 2741 and that possesses a 'type' attribute whose value is "unavailable". 2743 UC: 2745 Optionally, the unavailable presence stanza MAY contain one or more 2746 elements specifying the reason why the user is no longer 2747 available. 2749 UC: 2750 going on vacation 2751 2753 However, the unavailable presence stanza MUST NOT contain the 2754 element or the element, since these elements 2755 apply only to available resources. 2757 4.5.2. Server Processing of Outbound Unavailable Presence 2759 The user's server MUST NOT depend on receiving unavailable presence 2760 from an available resource, since the resource might become 2761 unavailable ungracefully (e.g., the resource's XML stream might be 2762 closed with or without a stream error for any of the reasons 2763 described in [XMPP-CORE]). 2765 If an available resource becomes unavailable for any reason (either 2766 gracefully or ungracefully), the user's server MUST broadcast 2767 unavailable presence to all contacts that are in the user's roster 2768 with a subscription type of "from" or "both". 2770 Interoperability Note: RFC 3921 specified that the user's server 2771 would check to make sure that it had not received a presence error 2772 from the contact before sending unavailable presence 2773 notifications; that rule has been removed because this 2774 specification uses presence stanzas of type "unsubscribe" (not 2775 "error") to solve subscription synchronization problems, in part 2776 because such stanzas change the contact's subscription state in 2777 the user's roster to either "none" or "to" (see Section 3.3 and 2778 Appendix A), thus obviating the need for the error check. 2780 Implementation Note: Even if the user's server does not broadcast 2781 the user's subsequent presence notifications to contacts who are 2782 offline (as described under Section 4.4.2), it MUST broadcast the 2783 user's unavailable presence notification; if it did not do so, the 2784 last presence received by the contact's server would be the user's 2785 initial presence for the presence session, with the result that 2786 the contact would consider the user to be online. 2788 Implementation Note: See Section 4.6 regarding rules that 2789 supplement the foregoing for handling of directed presence. 2791 If the unavailable notification was gracefully received from the 2792 client, then the server MUST broadcast the full XML of the presence 2793 stanza. 2795 US: 2798 going on vacation 2799 2801 US: 2804 going on vacation 2805 2807 US: 2810 going on vacation 2811 2813 The user's server MUST also send the unavailable notification to all 2814 of the user's available resources (as well as to the resource that 2815 generated the unavailable presence in the first place). 2817 US: 2820 going on vacation 2821 2823 If the server detects that the user has gone offline ungracefully, 2824 then the server MUST generate the unavailable presence broadcast on 2825 the user's behalf. 2827 Implementation Note: Any presence stanza with no 'type' attribute 2828 and no 'to' attribute that the client sends after the server 2829 broadcasts or generates an unavailable presence notification MUST 2830 be routed or delivered by the user's server to all subscribers 2831 (i.e., MUST be treated as equivalent to initial presence for a new 2832 presence session). 2834 4.5.3. Server Processing of Inbound Unavailable Presence 2836 Upon receiving an unavailable notification from the user, the 2837 contact's server MUST deliver the user's presence stanza to all of 2838 the contact's available resources. 2840 [ ... to resource1 ... ] 2842 CS: 2845 going on vacation 2846 2848 [ ... to resource2 ... ] 2850 CS: 2853 going on vacation 2854 2856 Implementation Note: If the contact's server does not broadcast 2857 subsequent presence notifications to users who are offline (as 2858 described under Section 4.4.2), it MUST also update its internal 2859 representation of which entities are online by noting that the 2860 user is unavailable. 2862 4.5.4. Client Processing of Unavailable Presence 2864 From the perspective of the contact's client, there is no significant 2865 difference between available presence broadcast and unavailable 2866 presence broadcast, so in general the contact's client follows the 2867 rules for processing of inbound presence defined under Section 4.4.3. 2869 However, if the contact receives an unavailable notification from the 2870 bare JID of the user (rather than the full JID of a particular 2871 available resource), the contact's client SHOULD treat the 2872 unavailable notification as applying to all resources. 2874 4.6. Directed Presence 2876 This section supplements the rules for client and server processing 2877 of presence notifications and presence probes, but only for the 2878 special case of directed presence. 2880 4.6.1. General Considerations 2882 In general, a client sends directed presence when it wishes to share 2883 availability information with an entity that is not subscribed to its 2884 presence, typically on a temporary basis. Common uses of directed 2885 presence include casual one-to-one chat sessions as described under 2886 Section 5.1 and multi-user chat rooms as described in [XEP-0045]. 2888 The temporary relationship established by sharing directed presence 2889 with another entity is secondary to the permanent relationship 2890 established through a presence subscription. Therefore, the acts of 2891 creating, modifying, or cancelling a presence subscription MUST take 2892 precedence over the rules specified in the following subsections. 2893 For example, if a user shares directed presence with a contact but 2894 then adds the contact to the user's roster by completing the presence 2895 subscription "handshake", the user's server MUST treat the contact 2896 just as it would any normal subscriber as described under Section 3, 2897 for example by sending subsequent presence broadcasts to the contact. 2898 As another example, if the user then cancels the contact's 2899 subscription to the user's presence, the user's server MUST handle 2900 the cancellation just as it normally would as described under 2901 Section 3.2, which includes sending unavailable presence to the 2902 contact even if the user has sent directed presence to the contact. 2904 XMPP servers typically implement directed presence by keeping a list 2905 of the entities (bare JIDs or full JIDs) to which a user has sent 2906 directed presence during the user's current session for a given 2907 resource (full JID), then clearing the list when the user goes 2908 offline (e.g., by sending a broadcast presence stanza of type 2909 "unavailable"). The server MUST remove from the directed presence 2910 list (or its functional equivalent) any entity to which the user 2911 sends directed unavailable presence and SHOULD remove any entity that 2912 sends unavailable presence to the user. 2914 4.6.2. Client Generation of Directed Presence 2916 As noted, directed presence is a client-generated presence stanza 2917 with a 'to' attribute whose value is the bare JID or full JID of the 2918 other entity and with either no 'type' attribute (indicating 2919 availability) or a 'type' attribute whose value is "unavailable". 2921 4.6.3. Server Processing of Outbound Directed Presence 2923 When the user's server receives a directed presence stanza, it SHOULD 2924 process it according to the following rules. 2926 1. If the user sends directed available or unavailable presence to a 2927 contact that is in the user's roster with a subscription type of 2928 "from" or "both" after having sent initial presence and before 2929 sending unavailable presence broadcast (i.e., during the user's 2930 presence session), the user's server MUST locally deliver or 2931 remotely route the full XML of that presence stanza but SHOULD 2932 NOT otherwise modify the contact's status regarding presence 2933 broadcast (i.e., it SHOULD include the contact's JID in any 2934 subsequent presence broadcasts initiated by the user). 2936 2. If the user sends directed presence to an entity that is not in 2937 the user's roster with a subscription type of "from" or "both" 2938 after having sent initial presence and before sending unavailable 2939 presence broadcast (i.e., during the user's presence session), 2940 the user's server MUST locally deliver or remotely route the full 2941 XML of that presence stanza to the entity but MUST NOT modify the 2942 contact's status regarding available presence broadcast (i.e., it 2943 MUST NOT include the entity's JID in any subsequent broadcasts of 2944 available presence initiated by the user); however, if the 2945 available resource from which the user sent the directed presence 2946 becomes unavailable, the user's server MUST route that 2947 unavailable presence to the entity (if the user has not yet sent 2948 directed unavailable presence to that entity). 2950 3. If the user sends directed presence without first sending initial 2951 presence or after having sent unavailable presence broadcast 2952 (i.e., the resource is connected but not available), the user's 2953 server MUST treat the entity to which the user sends directed 2954 presence as in case #2 above. 2956 4.6.4. Server Processing of Inbound Directed Presence 2958 From the perspective of the contact's server, there is no significant 2959 difference between presence broadcast and directed presence, so the 2960 contact's server follows the rules for processing of inbound presence 2961 defined under Section 4.3.2, Section 4.4.3, and Section 4.5.3. 2963 4.6.5. Client Processing of Inbound Directed Presence 2965 From the perspective of the contact's client, there is no significant 2966 difference between presence broadcast and directed presence, so the 2967 contact's client follows the rules for processing of inbound presence 2968 defined under Section 4.4.3. 2970 4.6.6. Server Processing of Presence Probes 2972 If a user's client has sent directed presence to another entity 2973 (e.g., a one-to-one chat partner or a multi-user chat room), after 2974 some time the entity or its server might want to know if the client 2975 is still online. This scenario is especially common in the case of 2976 multi-user chat rooms, in which the user might be a participant for a 2977 long period of time. If the user's client goes offline without the 2978 chat room being informed (either by the client or the client's 2979 server), the user's representation in the room might become a "ghost" 2980 which appears to be participating but which in fact is no longer 2981 present in the room. To detect such "ghosts", some multi-user chat 2982 room implementations send presence probes to users that have joined 2983 the room. 2985 In the case of directed presence, the probing entity SHOULD send the 2986 probe from the JID that received directed presence (whether a full 2987 JID or a bare JID). The probe SHOULD be sent to the user's full JID, 2988 not the user's bare JID without a resourcepart, because the temporary 2989 "authorization" involved with directed presence is based on the full 2990 JID from which the user sent directed presence to the probing entity. 2991 When the user's server receives a probe, it MUST first apply any 2992 logic associated with presence subscriptions as described under 2993 Section 4.3.2. If the probing entity does not have a subscription to 2994 the user's presence, then the server MUST check if the user has sent 2995 directed presence to the entity during its current session; if so, 2996 the server SHOULD answer the probe with only mere presence of type 2997 "available" or "unavailable" (i.e., not including child elements) and 2998 only for that full JID (i.e., not for any other resources that might 2999 be currently associated with the user's bare JID). 3001 4.7. Presence Syntax 3003 4.7.1. Type Attribute 3005 The absence of a 'type' attribute signals that the relevant entity is 3006 available for communication (see Section 4.2 and Section 4.4). 3008 A 'type' attribute with a value of "unavailable" signals that the 3009 relevant entity is not available for communication (see Section 4.5). 3011 The XMPP presence stanza is also used to negotiate and manage 3012 subscriptions to the presence of other entities. These tasks are 3013 completed via presence stanzas of type "subscribe", "unsubscribe", 3014 "subscribed", and "unsubscribed" as described under Section 3. 3016 If a user and contact are associated with different XMPP servers, 3017 those servers also use a special presence stanza of type "probe" in 3018 order to determine the availability of the entity on the peer server; 3019 details are provided under Section 4.3. Clients SHOULD NOT send 3020 presence stanzas of type "probe". 3022 The values of the 'type' attribute can be summarized as follows: 3024 o error -- An error has occurred regarding processing of a 3025 previously-sent presence stanza; if the presence stanza is of type 3026 "error", it MUST include an child element (refer to 3027 [XMPP-CORE]). 3029 o probe -- A request for an entity's current presence; SHOULD be 3030 generated only by a server on behalf of a user. 3032 o subscribe -- The sender wishes to subscribe to the recipient's 3033 presence. 3035 o subscribed -- The sender has allowed the recipient to receive 3036 their presence. 3038 o unavailable -- The sender is no longer available for 3039 communication. 3041 o unsubscribe -- The sender is unsubscribing from the receiver's 3042 presence. 3044 o unsubscribed -- The subscription request has been denied or a 3045 previously-granted subscription has been cancelled. 3047 If the value of the 'type' attribute is not one of the foregoing 3048 values, the recipient or an intermediate router SHOULD return a 3049 stanza error of . 3051 Implementation Note: There is no default value for the 'type' 3052 attribute of the element. 3054 Implementation Note: There is no value of "available" for the 3055 'type' attribute of the element. 3057 4.7.2. Child Elements 3059 In accordance with the default namespace declaration, a presence 3060 stanza is qualified by the 'jabber:client' or 'jabber:server' 3061 namespace, which defines certain child elements of presence stanzas, 3062 in particular the , , and elements. 3063 These child elements are used to provide more detailed information 3064 about an entity's availability. Typically these child elements are 3065 included only if the presence stanza possesses no 'type' attribute, 3066 although exceptions are noted in the text that follows. 3068 4.7.2.1. Show Element 3070 The OPTIONAL element specifies the particular availability 3071 sub-state of an entity or a specific resource thereof. A presence 3072 stanza MUST NOT contain more than one element. There are no 3073 attributes defined for the element. The element MUST 3074 NOT contain mixed content (as defined in Section 3.2.2 of [XML]). 3075 The XML character data of the element is not meant for 3076 presentation to a human user. The XML character data MUST be one of 3077 the following (additional availability states could be defined 3078 through extended content elements): 3080 o away -- The entity or resource is temporarily away. 3082 o chat -- The entity or resource is actively interested in chatting. 3084 o dnd -- The entity or resource is busy (dnd = "Do Not Disturb"). 3086 o xa -- The entity or resource is away for an extended period (xa = 3087 "eXtended Away"). 3089 If no element is provided, the entity is assumed to be online 3090 and available. 3092 Any specialized processing of availability states by recipients and 3093 intermediate routers is up to the implementation (e.g., incorporation 3094 of availability states into stanza routing and delivery logic). 3096 4.7.2.2. Status Element 3098 The OPTIONAL element contains human-readable XML character 3099 data specifying a natural-language description of an entity's 3100 availability. It is normally used in conjunction with the show 3101 element to provide a detailed description of an availability state 3102 (e.g., "In a meeting") when the presence stanza has no 'type' 3103 attribute. 3105 3107 dnd 3108 Wooing Juliet 3109 3111 There are no attributes defined for the element, with the 3112 exception of the 'xml:lang' attribute inherited from [XML]. The 3113 element MUST NOT contain mixed content (as defined in 3114 Section 3.2.2 of [XML]). Multiple instances of the element 3115 MAY be included, but only if each instance possesses an 'xml:lang' 3116 attribute with a distinct language value (either explicitly or by 3117 inheritance from the 'xml:lang' value of an element farther up in the 3118 XML hierarchy, which from the sender's perspective can include the 3119 XML stream header as described in [XMPP-CORE]). 3121 3124 dnd 3125 Wooing Juliet 3126 Dvořím se Julii 3127 3129 A presence stanza of type "unavailable" MAY also include a 3130 element to provide detailed information about why the entity is going 3131 offline. 3133 3137 Busy IRL 3138 3140 The child MAY also be sent in a subscription-related 3141 presence stanza (i.e., type "subscribe", "subscribed", "unsubscribe", 3142 or "unsubscribed") to provide a description of the action. An 3143 interactive client MAY present this information to a human 3144 user (see Section 11). 3146 3150 Hi, Juliet told me to add you to my buddy list. 3151 3153 4.7.2.3. Priority Element 3155 The OPTIONAL element contains non-human-readable XML 3156 character data that specifies the priority level of the resource. 3157 The value MUST be an integer between -128 and +127. A presence 3158 stanza MUST NOT contain more than one element. There are 3159 no attributes defined for the element. The 3160 element MUST NOT contain mixed content (as defined in Section 3.2.2 3161 of [XML]). 3163 3164 dnd 3165 Wooing Juliet 3166 Dvořím se Julii 3167 1 3168 3169 If no priority is provided, the processing server or client MUST 3170 consider the priority to be zero ("0"). 3172 The client's server MAY override the priority value provided by the 3173 client (e.g., in order to impose a message handling rule of 3174 delivering a message intended for the account's bare JID to all of 3175 the account's available resources); if the server does so, it MUST 3176 communicate the modified priority value when it echoes the client's 3177 presence back to itself and sends the presence notification to the 3178 user's contacts (because this modified priority value is typically 3179 the default value of zero, communicating the modified priority value 3180 can be done by not including the child element). 3182 For information regarding the semantics of priority values in stanza 3183 processing within instant messaging and presence applications, refer 3184 to Section 8. 3186 4.7.3. Extended Content 3188 As described in [XMPP-CORE], an XML stanza MAY contain any child 3189 element that is qualified by a namespace other than the default 3190 namespace; this applies to the presence stanza as well. 3192 (In the following example, the presence stanza includes entity 3193 capabilities information as defined in [XEP-0115].) 3195 3196 3200 3202 Any extended content included in a presence stanza SHOULD represent 3203 aspects of an entity's availability for communication or provide 3204 information about communication-related capabilities. 3206 5. Exchanging Messages 3208 Once a client has authenticated with a server and bound a resource to 3209 an XML stream as described in [XMPP-CORE], an XMPP server will route 3210 XML stanzas to and from that client. One kind of stanza that can be 3211 exchanged is (if, that is, messaging functionality is 3212 enabled on the server). Exchanging messages is a basic use of XMPP 3213 and occurs when a user generates a message stanza that is addressed 3214 to another entity. As defined under Section 8, the sender's server 3215 is responsible for delivering the message to the intended recipient 3216 (if the recipient is on the same local server) or for routing the 3217 message to the recipient's server (if the recipient is on a remote 3218 server). Thus a message stanza is used to "push" information to 3219 another entity. 3221 5.1. One-to-One Chat Sessions 3223 In practice, instant messaging activity between human users tends to 3224 occur in the form of a conversational burst that we call a "chat 3225 session": the exchange of multiple messages between two parties in 3226 relatively rapid succession within a relatively brief period of time. 3228 When a human user intends to engage in such a chat session with a 3229 contact (rather than sending a single message to which no reply is 3230 expected), the message type generated by the user's client SHOULD be 3231 "chat" and the contact's client SHOULD preserve that message type in 3232 subsequent replies. The user's client also SHOULD include a 3233 element with its initial message, which the contact's 3234 client SHOULD also preserve during the life of the chat session (see 3235 Section 5.2.5). 3237 The user's client SHOULD address the initial message in a chat 3238 session to the bare JID of the contact (rather 3239 than attempting to guess an appropriate full JID 3240 based on the , , or 3241 value of any presence notifications it might have 3242 received from the contact). Until and unless the user's client 3243 receives a reply from the contact, it SHOULD send any further 3244 messages to the contact's bare JID. The contact's client SHOULD 3245 address its replies to the user's full JID 3246 as provided in the 'from' address of 3247 the initial message. Once the user's client receives a reply from 3248 the contact's full JID, it SHOULD address its subsequent messages to 3249 the contact's full JID as provided in the 'from' address of the 3250 contact's replies, thus "locking in" on that full JID. A client 3251 SHOULD "unlock" after having received a or 3252 stanza from any other resource controlled by the peer (or a presence 3253 stanza from the locked resource); as a result, it SHOULD address its 3254 next message(s) in the chat session to the bare JID of the peer (thus 3255 "unlocking" the previous "lock") until it receives a message from one 3256 of the peer's full JIDs. 3258 When two parties engage in a chat session but do not share presence 3259 with each other based on a presence subscription, they SHOULD send 3260 directed presence to each other so that either party can easily 3261 discover if the peer goes offline during the course of the chat 3262 session. However, a client MUST provide a way for a user to disable 3263 such presence sharing globally or to enable it only with particular 3264 entities. Furthermore, a party SHOULD send directed unavailable 3265 presence to the peer when it has reason to believe that the chat 3266 session is over (e.g., if, after some reasonable amount of time, no 3267 subsequent messages have been exchanged between the parties). 3269 An example of a chat session is provided under Section 7. 3271 5.2. Message Syntax 3273 The following sections describe the syntax of the stanza. 3275 5.2.1. To Attribute 3277 An instant messaging client specifies an intended recipient for a 3278 message by providing the JID of the intended recipient in the 'to' 3279 attribute of the stanza. 3281 If the message is being sent outside the context of any existing chat 3282 session or received message, the value of the 'to' address SHOULD be 3283 of the form rather than of the form 3284 (see Section 5.1). 3286 3292 Art thou not Romeo, and a Montague? 3293 3295 If the message is being sent in reply to a message previously 3296 received from an address of the form 3297 (e.g., within the context of a 3298 one-to-one chat session as described under Section 5.1), the value of 3299 the 'to' address SHOULD be of the form 3300 rather than of the form 3301 unless the sender has knowledge (e.g., via 3302 presence) that the intended recipient's resource is no longer 3303 available. 3305 3311 Neither, fair saint, if either thee dislike. 3313 3315 5.2.2. Type Attribute 3317 Common uses of the message stanza in instant messaging applications 3318 include: single messages; messages sent in the context of a one-to- 3319 one chat session; messages sent in the context of a multi-user chat 3320 room; alerts, notifications, or other information to which no reply 3321 is expected; and errors. These uses are differentiated via the 3322 'type' attribute. Inclusion of the 'type' attribute is RECOMMENDED. 3323 If included, the 'type' attribute MUST have one of the following 3324 values: 3326 o chat -- The message is sent in the context of a one-to-one chat 3327 session. Typically an interactive client will present a message 3328 of type "chat" in an interface that enables one-to-one chat 3329 between the two parties, including an appropriate conversation 3330 history. Detailed recommendations regarding one-to-one chat 3331 sessions are provided under Section 5.1. 3333 o error -- The message is generated by an entity that experiences an 3334 error when processing a message received from another entity (for 3335 details regarding stanza error syntax, refer to [XMPP-CORE]). A 3336 client that receives a message of type "error" SHOULD present an 3337 appropriate interface informing the original sender regarding the 3338 nature of the error. 3340 o groupchat -- The message is sent in the context of a multi-user 3341 chat environment (similar to that of [IRC]). Typically a 3342 receiving client will present a message of type "groupchat" in an 3343 interface that enables many-to-many chat between the parties, 3344 including a roster of parties in the chatroom and an appropriate 3345 conversation history. For detailed information about XMPP-based 3346 groupchat, refer to [XEP-0045]. 3348 o headline -- The message provides an alert, a notification, or 3349 other transient information to which no reply is expected (e.g., 3350 news headlines, sports updates, near-real-time market data, or 3351 syndicated content). Because no reply to the message is expected, 3352 typically a receiving client will present a message of type 3353 "headline" in an interface that appropriately differentiates the 3354 message from standalone messages, chat messages, and groupchat 3355 messages (e.g., by not providing the recipient with the ability to 3356 reply). If the 'to' address is the bare JID, the receiving server 3357 SHOULD deliver the message to all of the recipient's available 3358 resources with non-negative presence priority and MUST deliver the 3359 message to at least one of those resources; if the 'to' address is 3360 a full JID and there is a matching resource, the server MUST 3361 deliver the message to that resource; otherwise the server MUST 3362 either silently ignore the message or return an error (see 3363 Section 8). 3365 o normal -- The message is a standalone message that is sent outside 3366 the context of a one-to-one conversation or groupchat, and to 3367 which it is expected that the recipient will reply. Typically a 3368 receiving client will present a message of type "normal" in an 3369 interface that enables the recipient to reply, but without a 3370 conversation history. The default value of the 'type' attribute 3371 is "normal". 3373 An IM application SHOULD support all of the foregoing message types. 3374 If an application receives a message with no 'type' attribute or the 3375 application does not understand the value of the 'type' attribute 3376 provided, it MUST consider the message to be of type "normal" (i.e., 3377 "normal" is the default). 3379 Guidelines for server handling of different message types is provided 3380 under Section 8. 3382 Although the 'type' attribute is OPTIONAL, it is considered polite to 3383 mirror the type in any replies to a message; furthermore, some 3384 specialized applications (e.g., a multi-user chat service) MAY at 3385 their discretion enforce the use of a particular message type (e.g., 3386 type='groupchat'). 3388 5.2.3. Body Element 3390 The element contains human-readable XML character data that 3391 specifies the textual contents of the message; this child element is 3392 normally included but is OPTIONAL. 3394 3400 Wherefore art thou, Romeo? 3401 3403 There are no attributes defined for the element, with the 3404 exception of the 'xml:lang' attribute. Multiple instances of the 3405 element MAY be included in a message stanza for the purpose 3406 of providing alternate versions of the same body, but only if each 3407 instance possesses an 'xml:lang' attribute with a distinct language 3408 value (either explicitly or by inheritance from the 'xml:lang' value 3409 of an element farther up in the XML hierarchy, which from the 3410 sender's perspective can include the XML stream header as described 3411 in [XMPP-CORE]). 3413 3419 Wherefore art thou, Romeo? 3420 3421 PročeŽ jsi ty, Romeo? 3422 3423 3425 The element MUST NOT contain mixed content (as defined in 3426 Section 3.2.2 of [XML]). 3428 5.2.4. Subject Element 3430 The element contains human-readable XML character data 3431 that specifies the topic of the message. 3433 3439 I implore you! 3440 Wherefore art thou, Romeo? 3441 3443 There are no attributes defined for the element, with the 3444 exception of the 'xml:lang' attribute inherited from [XML]. Multiple 3445 instances of the element MAY be included for the purpose 3446 of providing alternate versions of the same subject, but only if each 3447 instance possesses an 'xml:lang' attribute with a distinct language 3448 value (either explicitly or by inheritance from the 'xml:lang' value 3449 of an element farther up in the XML hierarchy, which from the 3450 sender's perspective can include the XML stream header as described 3451 in [XMPP-CORE]). 3453 3459 I implore you! 3460 3461 Úpěnlivě prosím! 3462 3463 Wherefore art thou, Romeo? 3464 3465 Pročež jsi ty, Romeo? 3466 3467 3469 The element MUST NOT contain mixed content (as defined in 3470 Section 3.2.2 of [XML]). 3472 5.2.5. Thread Element 3474 The primary use of the XMPP element is to uniquely identify 3475 a conversation thread or "chat session" between two entities 3476 instantiated by stanzas of type 'chat'. However, the XMPP 3477 element MAY also be used to uniquely identify an analogous 3478 thread between two entities instantiated by stanzas of 3479 type 'headline' or 'normal', or among multiple entities in the 3480 context of a multi-user chat room instantiated by stanzas 3481 of type 'groupchat'. It MAY also be used for stanzas not 3482 related to a human conversation, such as a game session or an 3483 interaction between plugins. The element is not used to 3484 identify individual messages, only conversations or messaging 3485 sessions. 3487 The inclusion of the element is OPTIONAL. Because the 3488 element identifies the particular conversation thread to 3489 which a message belongs, a message stanza MUST NOT contain more than 3490 one element. 3492 The element MAY possess a 'parent' attribute that 3493 identifies another thread of which the current thread is an offshoot 3494 or child. The 'parent' attribute MUST conform to the syntax of the 3495 element itself and its value MUST be different from the XML 3496 character data of the element on which the 'parent' 3497 attribute is included. 3499 Implementation Note: The ability to specify both a parent thread 3500 and a child thread introduces the possibility of conflicts between 3501 thread identifiers for overlapping threads. For example, one 3502 element might contain XML character data of "foo" and a 3503 'parent' attribute whose value is "bar", a second 3504 element might contain XML character data of "bar" and a 'parent' 3505 attribute whose value is "baz", and a third element 3506 might contain XML character data of "baz" and a 'parent' attribute 3507 whose value is once again "foo". It is up to the implementation 3508 how it will treat conflicts between such overlapping thread 3509 identifiers (e.g., whether it will "chain together" thread 3510 identifiers by showing "foo" as both a parent and grandchild of 3511 "baz" in a multi-level user interface, or whether it will show 3512 only one level of dependency at a time). 3514 The value of the element is not human-readable and MUST be 3515 treated as opaque by entities; no semantic meaning can be derived 3516 from it, and only exact comparisons can be made against it. The 3517 value of the element MUST uniquely identify the 3518 conversation thread either between the conversation partners or more 3519 generally (one way to ensure uniqueness is by generating a 3520 universally unique identifier (UUID) as described in [UUID]). 3522 Security Warning: An application that generates a ThreadID MUST 3523 ensure that it does not reveal identifying information about the 3524 entity (e.g., the MAC address of the device on which the XMPP 3525 application is running). 3527 The element MUST NOT contain mixed content (as defined in 3528 Section 3.2.2 of [XML]). 3530 3535 I implore you! 3536 3537 Úpěnlivě prosím! 3538 3539 Wherefore art thou, Romeo? 3540 3541 Pročež jsi ty, Romeo? 3542 3543 3544 0e3141cd80894871a68e6fe6b1ec56fa 3545 3546 3547 For detailed recommendations regarding use of the element, 3548 refer to [XEP-0201]. 3550 5.3. Extended Content 3552 As described in [XMPP-CORE], an XML stanza MAY contain any child 3553 element that is qualified by a namespace other than the default 3554 namespace; this applies to the message stanza as well. Guidelines 3555 for handling extended content on the part of both routing servers and 3556 end recipients are provided in Section 8.4 of [XMPP-CORE]. 3558 (In the following example, the message stanza includes an XHTML- 3559 formatted version of the message as defined in [XEP-0071]).) 3561 3566 Wherefore art thou, Romeo? 3567 3568 3569

Wherefore art 3570 thou, Romeo?

3571 3572 3573
3575 6. Exchanging IQ Stanzas 3577 As described in [XMPP-CORE], IQ stanzas provide a structured request- 3578 response mechanism. The basic semantics of that mechanism (e.g., 3579 that the 'id' attribute is mandatory) are defined in [XMPP-CORE], 3580 whereas the specific semantics needed to complete particular use 3581 cases are defined in all instances by the extended namespace that 3582 qualifies the direct child element of an IQ stanza of type "get" or 3583 "set". The 'jabber:client' and 'jabber:server' namespaces do not 3584 define any children of IQ stanzas other than the element 3585 common to all stanza types. This document defines one such extended 3586 namespace, for Managing the Roster (Section 2). However, an IQ 3587 stanza MAY contain structured information qualified by any extended 3588 namespace. 3590 7. A Sample Session 3592 The examples in this section illustrate a possible instant messaging 3593 and presence session. The user is , he has an 3594 available resource whose resourcepart is "orchard", and he has the 3595 following individuals in his roster: 3597 o (subscription="both" and she has two 3598 available resources, "chamber" and "balcony") 3600 o (subscription="to") 3602 o (subscription="from") 3604 First, the user completes the preconditions (stream establishment, 3605 TLS and SASL negotiation, and resource binding) described in 3606 [XMPP-CORE]; those protocol flows are not reproduced here. 3608 Next, the user requests his roster. 3610 Example 1: User requests current roster from server 3612 UC: 3615 3616 3618 Example 2: User receives roster from server 3620 US: 3623 3624 3627 Friends 3628 3629 3632 3635 3636 3638 Now the user begins a presence session. 3640 Example 3: User sends initial presence 3642 UC: 3644 Example 4: User's server sends presence probes to contacts with 3645 subscription="to" and subscription="both" on behalf of the user 3647 US: 3652 US: 3657 Example 5: User's server sends initial presence to contacts with 3658 subscription="from" and subscription="both" on behalf of the user's 3659 available resource, as well as to user 3661 US: 3665 US: 3669 US: 3673 Example 6: Contacts' servers reply to presence probe on behalf of all 3674 available resources 3676 CS: 3680 away 3681 be right back 3682 0 3683 3685 CS: 3688 1 3689 3691 CS: 3695 dnd 3696 gallivanting 3697 3699 Example 7: Contacts' servers deliver user's initial presence to all 3700 available resources 3702 CS: 3706 CS: 3710 CS: 3714 Example 8: User sends directed presence to another user not in his 3715 roster 3717 UC: 3721 dnd 3722 courting Juliet 3723 0 3724 3726 Now the user engages in a chat session with one of his contacts. 3728 Example 9: A threaded conversation 3730 CC: 3735 My ears have not yet drunk a hundred words 3736 e0ffe42b28561960c6b12b944a092794b9683a38 3737 3739 CC: 3744 Of that tongue's utterance, yet I know the sound: 3745 e0ffe42b28561960c6b12b944a092794b9683a38 3746 3748 CC: 3753 Art thou not Romeo, and a Montague? 3754 e0ffe42b28561960c6b12b944a092794b9683a38 3755 3757 UC: 3762 Neither, fair saint, if either thee dislike. 3763 e0ffe42b28561960c6b12b944a092794b9683a38 3764 3766 CC: 3771 How cam'st thou hither, tell me, and wherefore? 3772 e0ffe42b28561960c6b12b944a092794b9683a38 3773 3775 And so on. 3777 The user can also send subsequent presence broadcast. 3779 Example 10: User sends updated available presence for broadcast 3781 UC: 3782 away 3783 I shall return! 3784 1 3785 3787 Example 11: User's server broadcasts updated presence to the contacts 3788 who have a subscription of type "both" or "from" (but not to the 3789 entity to which the user sent directed presence) 3791 US: 3795 away 3796 I shall return! 3797 1 3798 3800 US: 3804 away 3805 I shall return! 3806 1 3807 3809 Example 12: Contacts' servers deliver updated presence 3811 CS: 3815 away 3816 I shall return! 3817 1 3818 3820 CS: 3824 away 3825 I shall return! 3826 1 3827 3829 CS: 3833 away 3834 I shall return! 3835 1 3836 3838 Example 13: One of the contact's resources broadcasts unavailable 3839 notification 3841 CC: 3843 Example 14: Contact's server sends unavailable notification to user 3845 CS: 3850 Now the user ends his presence session. 3852 Example 15: User sends unavailable notification 3854 UC: 3855 gone home 3856 3858 Example 16: User's server broadcasts unavailable notification to 3859 contacts as well as to the entity to whom the user sent directed 3860 presence 3862 US: 3867 gone home 3868 3870 US: 3875 gone home 3876 3878 US: 3883 gone home 3884 3886 Finally the user closes his stream and the server responds in kind. 3888 Example 17: User closes stream 3890 UC: 3892 Example 18: User's server closes stream 3894 US: 3896 THE END 3898 8. Server Rules for Processing XML Stanzas 3900 Basic server rules for processing XML stanzas are defined in 3901 [XMPP-CORE], and the reader is referred to that specification for 3902 underlying rules and security implications. This section defines 3903 supplementary rules for XMPP instant messaging and presence servers. 3905 Some delivery rules defined in this section specify the use of 3906 "offline storage", i.e., the server's act of storing a message stanza 3907 on behalf of the user and then delivering it when the user next 3908 becomes available. For recommendations regarding offline message 3909 storage, refer to [XEP-0160]. 3911 8.1. General Considerations 3913 [XMPP-CORE] discusses general considerations for stanza delivery, in 3914 particular the tradeoffs between (i) providing an acceptable level of 3915 service regarding stanza delivery and (ii) preventing directory 3916 harvesting attacks and presence leaks. However, the concept of a 3917 directory harvesting attack does not apply if a contact is known to 3918 and trusted by a user (because the contact is in the user's roster as 3919 described under Section 2). Similarly, the concept of a presence 3920 leak does not apply if a contact is authorized to know a user's 3921 presence (by means of a presence subscription as described under 3922 Section 3) or if the user has voluntarily sent presence to an entity 3923 (by means of directed presence as described under Section 4.6). 3924 Therefore, in cases where the following sections guard against 3925 directory harvesting attacks and presence leaks by providing an 3926 alternative of (a) silently ignoring a stanza or (b) returning an 3927 error, a server SHOULD return an error if the originating entity is 3928 in the user's roster (when the error would reveal whether the user's 3929 account exists) or is authorized to receive presence from the user or 3930 has received directed presence from the user (when the error would 3931 reveal the presence of a user's resource). 3933 Security Warning: All of the stanza processing rules described 3934 below are defined with the understanding that they will be applied 3935 subject to enforcement of relevant privacy and security policies, 3936 such as those deployed by means of [XEP-0016] or [XEP-0191]. The 3937 conformance language (MUST, SHOULD, etc.) in the following 3938 sections is not meant to override any such local service policies. 3940 8.2. No 'to' Address 3942 If the stanza possesses no 'to' attribute, the rules defined in 3943 [XMPP-CORE] apply. 3945 8.3. Remote Domain 3947 If the domainpart of the address contained in the 'to' attribute of 3948 an outbound stanza does not match a configured domain of the server 3949 itself, then the rules provided in Section 10.4 of [XMPP-CORE] apply. 3951 Interoperability Note: RFC 3921 specified how to use the _im._xmpp 3952 and _pres._xmpp SRV records [IMP-SRV] as a fallback method for 3953 discovering whether a remote instant messaging and presence 3954 service communicates via XMPP. Because those SRV records have not 3955 been widely deployed, this document no longer specifies their use, 3956 and new implementations are not encouraged. 3958 8.4. Local Domain 3960 If the domainpart of the JID contained in the 'to' attribute matches 3961 one of the configured domains of the server, the domain is serviced 3962 by the server itself (not by a specialized local service), and the 3963 JID is of the form or , the 3964 rules defined in [XMPP-CORE] apply. 3966 8.5. Local User 3968 If the 'to' address specifies a bare JID or 3969 full JID where the domainpart of 3970 the JID matches a configured domain that is serviced by the server 3971 itself, the server MUST proceed as follows. 3973 8.5.1. No Such User 3975 If the user account identified by the 'to' attribute does not exist, 3976 how the stanza is processed depends on the stanza type. 3978 o For an IQ stanza, the server MUST return a 3979 stanza error to the sender. 3981 o For a message stanza, the server MUST either (a) silently ignore 3982 the message or (b) return a stanza error to 3983 the sender. 3985 o For a presence stanza with no 'type' attribute or a 'type' 3986 attribute of "unavailable", the server MUST silently ignore the 3987 stanza. 3989 o For a presence stanza of type "subscribe", "subscribed", 3990 "unsubscribe", or "unsubscribed", the server MUST silently ignore 3991 the stanza. 3993 o For a presence stanza of type "probe", the server MUST either (a) 3994 silently ignore the stanza or (b) return a presence stanza of type 3995 "unsubscribed". 3997 8.5.2. localpart@domainpart 3999 If the JID contained in the 'to' attribute is of the form 4000 , then the server MUST adhere to the following 4001 rules. 4003 8.5.2.1. Available or Connected Resources 4005 If there is at least one available resource or connected resource, 4006 how the stanza is processed depends on the stanza type. 4008 8.5.2.1.1. Message 4010 For a message stanza of type "normal": 4012 o If all of the available resources have a negative presence 4013 priority then the server SHOULD either (a) store the message 4014 offline for later delivery or (b) return a stanza error to the 4015 sender, which SHOULD be . 4017 o If there is one available resource with a non-negative presence 4018 priority then the server MUST deliver the message to that 4019 resource. 4021 o If there is more than one resource with a non-negative presence 4022 priority then the server MUST either (a) deliver the message to 4023 the "most available" resource or resources (according to the 4024 server's implementation-specific algorithm, e.g., treating the 4025 resource or resources with the highest presence priority as "most 4026 available") or (b) deliver the message to all of the non-negative 4027 resources. 4029 For a message stanza of type "chat": 4031 o If the only available resource has a negative presence priority 4032 then the server SHOULD either (a) store the message offline for 4033 later delivery or (b) return a stanza error to the sender, which 4034 SHOULD be . 4036 o If the only available resource has a non-negative presence 4037 priority then the server MUST deliver the message to that 4038 resource. 4040 o If there is more than one resource with a non-negative presence 4041 priority then the server MUST either (a) deliver the message to 4042 the "most available" resource or resources (according to the 4043 server's implementation-specific algorithm, e.g., treating the 4044 resource or resources with the highest presence priority as "most 4045 available") or (b) deliver the message to all of the non-negative 4046 resources that have opted in to receive chat messages. 4048 For a message stanza of type "groupchat", the server MUST NOT deliver 4049 the stanza to any of the available resources but instead MUST return 4050 a stanza error to the sender, which SHOULD be . 4052 For a message stanza of type "headline": 4054 o If the only available resource has a negative presence priority 4055 then the server MUST silently ignore the stanza. 4057 o If the only available resource has a non-negative presence 4058 priority then the server MUST deliver the message to that 4059 resource. 4061 o If there is more than one resource with a non-negative presence 4062 priority then the server MUST deliver the message to all of the 4063 non-negative resources. 4065 For a message stanza of type "error", the server MUST silently ignore 4066 the message. 4068 However, for any message type the server MUST NOT deliver the stanza 4069 to any available resource with a negative priority; if the only 4070 available resource has a negative priority, the server SHOULD handle 4071 the message as if there were no available resources or connected 4072 resources as described under Section 8.5.2.2. 4074 In all cases, the server MUST NOT rewrite the 'to' attribute (i.e., 4075 it MUST leave it as rather than change it to 4076 ). 4078 8.5.2.1.2. Presence 4080 For a presence stanza with no type or of type "unavailable", the 4081 server MUST deliver it to all available resources. 4083 For a presence stanza of type "subscribe", "subscribed", 4084 "unsubscribe", or "unsubscribed", the server MUST adhere to the rules 4085 defined under Section 3 and summarized under Appendix A. 4087 For a presence stanza of type "probe", the server MUST handle it 4088 directly as described under Section 4.3. 4090 In all cases, the server MUST NOT rewrite the 'to' attribute (i.e., 4091 it MUST leave it as rather than change it to 4092 ). 4094 8.5.2.1.3. IQ 4096 For an IQ stanza, the server itself MUST reply on behalf of the user 4097 with either an IQ result or an IQ error, and MUST NOT deliver the IQ 4098 stanza to any of the user's available resources. Specifically, if 4099 the semantics of the qualifying namespace define a reply that the 4100 server can provide on behalf of the user, then the server MUST reply 4101 to the stanza on behalf of the user by returning either an IQ stanza 4102 of type "result" or an IQ stanza of type "error" that is appropriate 4103 to the original payload; if not, then the server MUST reply with a 4104 stanza error. 4106 8.5.2.2. No Available or Connected Resources 4108 If there are no available resources or connected resources associated 4109 with the user, how the stanza is processed depends on the stanza 4110 type. 4112 8.5.2.2.1. Message 4114 For a message stanza of type "normal" or "chat", the server SHOULD 4115 either (a) add the message to offline storage or (b) return a stanza 4116 error to the sender, which SHOULD be . 4118 For a message stanza of type "groupchat", the server MUST return an 4119 error to the sender, which SHOULD be . 4121 For a message stanza of type "headline" or "error", the server MUST 4122 silently ignore the message. 4124 8.5.2.2.2. Presence 4126 For a presence stanza with no type or of type "unavailable", the 4127 server SHOULD silently ignore the stanza by not storing it for later 4128 delivery and not replying to it on behalf of the user. 4130 For a presence stanza of type "subscribe", "subscribed", 4131 "unsubscribe", or "unsubscribed", the server MUST adhere to the rules 4132 defined under Section 3 and summarized under Appendix A. 4134 For a presence stanza of type "probe", the server MUST handle it 4135 directly as described under Section 4.3. 4137 8.5.2.2.3. IQ 4139 For an IQ stanza, the server itself MUST reply on behalf of the user 4140 with either an IQ result or an IQ error. Specifically, if the 4141 semantics of the qualifying namespace define a reply that the server 4142 can provide on behalf of the user, then the server MUST reply to the 4143 stanza on behalf of the user by returning either an IQ stanza of type 4144 "result" or an IQ stanza of type "error" that is appropriate to the 4145 original payload; if not, then the server MUST reply with a stanza error. 4148 8.5.3. localpart@domainpart/resourcepart 4150 If the domainpart of the JID contained in the 'to' attribute of an 4151 inbound stanza matches one of the configured domains of the server 4152 itself and the JID contained in the 'to' attribute is of the form 4153 , then the server MUST adhere to 4154 the following rules. 4156 8.5.3.1. Resource Matches 4158 If an available resource or connected resource exactly matches the 4159 full JID, how the stanza is processed depends on the stanza type. 4161 o For an IQ stanza of type "get" or "set", if the intended recipient 4162 does not share presence with the requesting entity either by means 4163 of a presence subscription of type "both" or "from" or by means of 4164 directed presence, then the server SHOULD NOT deliver the IQ 4165 stanza but instead SHOULD return a stanza 4166 error to the requesting entity. This policy helps to prevent 4167 presence leaks (see Section 11). 4169 o For an IQ stanza of type "result" or "error", the server MUST 4170 deliver the stanza to the resource. 4172 o For a message stanza, the server MUST deliver the stanza to the 4173 resource. 4175 o For a presence stanza with no 'type' attribute or a 'type' 4176 attribute of "unavailable", the server MUST deliver the stanza to 4177 the resource. 4179 o For a presence stanza of type "subscribe", "subscribed", 4180 "unsubscribe", or "unsubscribed", the server MUST follow the 4181 guidelines provided under Section 3. 4183 o For a presence stanza of type "probe", the server MUST follow the 4184 guidelines provided under Section 4.3. 4186 8.5.3.2. No Resource Matches 4188 If no available resource or connected resource exactly matches the 4189 full JID, how the stanza is processed depends on the stanza type. 4191 8.5.3.2.1. Message 4193 For a message stanza of type "normal", "groupchat", or "headline", 4194 the server MUST either (a) silently ignore the stanza or (b) return 4195 an error stanza to the sender, which SHOULD be . 4198 For a message stanza of type "chat": 4200 o If there is no available or connected resource, the server MUST 4201 either (a) store the message offline for later delivery or (b) 4202 return an error stanza to the sender, which SHOULD be . 4205 o If all of the available resources have a negative presence 4206 priority then the server SHOULD (a) store the message offline for 4207 later delivery or (b) return a stanza error to the sender, which 4208 SHOULD be . 4210 o If there is one available resource with a non-negative presence 4211 priority then the server MUST deliver the message to that 4212 resource. 4214 o If there is more than one resource with a non-negative presence 4215 priority then the server MUST either (a) deliver the message to 4216 the "most available" resource or resources (according to the 4217 server's implementation-specific algorithm, e.g., treating the 4218 resource or resources with the highest presence priority as "most 4219 available") or (b) deliver the message to all of the non-negative 4220 resources that have opted in to receive chat messages. 4222 For a message stanza of type "error", the server MUST silently ignore 4223 the stanza. 4225 8.5.3.2.2. Presence 4227 For a presence stanza with no 'type' attribute or a 'type' attribute 4228 of "unavailable", the server MUST silently ignore the stanza. 4230 For a presence stanza of type "subscribe", the server MUST follow the 4231 guidelines provided under Section 3.1.3. 4233 For a presence stanza of type "subscribed", "unsubscribe", or 4234 "unsubscribed", the server MUST ignore the stanza. 4236 For a presence stanza of type "probe", the server MUST follow the 4237 guidelines provided under Section 4.3. 4239 8.5.3.2.3. IQ 4241 For an IQ stanza, the server MUST return a 4242 stanza error to the sender. 4244 8.5.4. Summary of Message Delivery Rules 4246 The following table summarizes the message (not stanza) delivery 4247 rules described earlier in this section. The left column shows 4248 various combinations of conditions (non-existent account, no active 4249 resources, only one resource and it has a negative presence priority, 4250 only one resource and it has a non-negative presence priority, or 4251 more than one resource and each one has a non-negative presence 4252 priority) and 'to' addresses (bare JID, full JID matching an 4253 available resource, or full JID matching no available resource). The 4254 subsequent columns list the four primary message types (normal, chat, 4255 groupchat, or headline) along with six possible delivery options: 4256 storing the message offline (O), bouncing the message with a stanza 4257 error (E), silently ignoring the message (S), delivering the message 4258 to the resource specified in the 'to' address (D), delivering the 4259 message to the "most available" resource or resources according to 4260 the server's implementation-specific algorithm, e.g., treating the 4261 resource or resources with the highest presence priority as "most 4262 available" (M), or delivering the message to all resources with non- 4263 negative presence priority (A -- where for chat messages "all 4264 resources" can mean the set of resources that have explicitly opted 4265 in to receiving every chat message). The '/' character stands for 4266 "exclusive or". The server SHOULD observe the rules given in section 4267 8.1 when choosing which action to take for a particular message. 4269 Table 1: Message Delivery Rules 4271 +----------------------------------------------------------+ 4272 | Condition | Normal | Chat | Groupchat | Headline | 4273 +----------------------------------------------------------+ 4274 | ACCOUNT DOES NOT EXIST | 4275 | bare | S/E | S/E | E | S | 4276 | full | S/E | S/E | S/E | S/E | 4277 +----------------------------------------------------------+ 4278 | ACCOUNT EXISTS, BUT NO ACTIVE RESOURCES | 4279 | bare | O/E | O/E | E | S | 4280 | full (no match) | S/E | O/E | S/E | S/E | 4281 +----------------------------------------------------------+ 4282 | 1+ NEGATIVE RESOURCES BUT ZERO NON-NEGATIVE RESOURCES | 4283 | bare | O/E | O/E | E | S | 4284 | full match | D | D | D | D | 4285 | full no match | S/E | O/E | S/E | S/E | 4286 +----------------------------------------------------------+ 4287 | 1 NON-NEGATIVE RESOURCE | 4288 | bare | D | D | E | D | 4289 | full match | D | D | D | D | 4290 | full no match | S/E | D | S/E | S/E | 4291 +----------------------------------------------------------+ 4292 | 1+ NON-NEGATIVE RESOURCES | 4293 | bare | M/A | M/A* | E | A | 4294 | full match | D | D/A* | D | D | 4295 | full no match | S/E | M/A* | S/E | S/E | 4296 +----------------------------------------------------------+ 4298 * For messages of type "chat", a server SHOULD NOT act in 4299 accordance with option (A) unless clients can explicitly opt in to 4300 receiving all chat messages; however, methods for opting in are 4301 outside the scope of this specification. 4303 9. Handling of URIs 4305 The addresses of XMPP entities as used in communication over an XMPP 4306 network (e.g., in the 'from' and 'to' addresses of an XML stanza) 4307 MUST NOT be prepended with a Uniform Resource Identifier [URI] 4308 scheme. 4310 However, an application that is external to XMPP itself (e.g., a page 4311 on the World Wide Web) might need to identify an XMPP entity either 4312 as a URI or as an Internationalized Resource Identifier [IRI], and an 4313 XMPP client might need to interact with such an external application 4314 (for example, an XMPP client might be invoked by clicking a link 4315 provided on a web page). In the context of such interactions, XMPP 4316 clients are encouraged to handle addresses that are encoded as 4317 "xmpp:" URIs and IRIs as specified in [XMPP-URI] and further 4318 described in [XEP-0147]. Although XMPP clients are also encouraged 4319 to handle addresses that are encoded as "im:" URIs as specified in 4320 [CPIM] and "pres:" URIs as specified in [CPP], they can do so by 4321 removing the "im:" or "pres:" scheme and entrusting address 4322 resolution to the server as specified under Section 8.3. 4324 10. Internationalization Considerations 4326 For internationalization considerations, refer to the relevant 4327 section of [XMPP-CORE]. 4329 11. Security Considerations 4331 Core security considerations for XMPP are provided in Section 13 of 4332 [XMPP-CORE], including discussion of channel encryption, 4333 authentication, information leaks, denial of service attacks, and 4334 interdomain federation. 4336 Section 13.1 of [XMPP-CORE] outlines the architectural roles of 4337 clients and servers in typical deployments of XMPP, and discusses the 4338 security properties associated with those roles. These roles have an 4339 impact on the security of instant messages, presence subscriptions, 4340 and presence notifications as described in this document. In 4341 essence, an XMPP user registers (or has provisioned) an account on an 4342 XMPP server and therefore places some level of trust in the server to 4343 complete various tasks on the user's behalf, enforce security 4344 policies, etc. Thus it is the server's responsibility to: 4346 1. Preferably mandate the use of channel encryption for 4347 communication with local clients and remote servers. 4349 2. Authenticate any client that wishes to access the user's account. 4351 3. Process XML stanzas to and from clients that have authenticated 4352 as the user (specifically with regard to instant messaging and 4353 presence functionality, store the user's roster, process inbound 4354 and outbound subscription requests and responses, generate and 4355 handle presence probes, broadcast outbound presence 4356 notifications, route outbound messages, and deliver inbound 4357 messages and presence notifications). 4359 As discussed in Sections 13.1 and 13.4 of [XMPP-CORE], even if the 4360 server fulfills the foregoing responsibilities, the client does not 4361 have any assurance that stanzas it might exchange with other clients 4362 (whether on the same server or a remote server) are protected for all 4363 hops along the XMPP communication path, or within the server itself. 4364 It is the responsibility of the client to use an appropriate 4365 technology for encryption and signing of XML stanzas if it wishes to 4366 ensure end-to-end confidentiality and integrity of its 4367 communications. 4369 Additional considerations that apply only to instant messaging and 4370 presence applications of XMPP are defined in several places within 4371 this document; specifically: 4373 o When a server processes an inbound presence stanza of type "probe" 4374 whose intended recipient is a user associated with one of the 4375 server's configured domains, the server MUST NOT reveal the user's 4376 presence if the sender is an entity that is not authorized to 4377 receive that information as determined by presence subscriptions 4378 (see Section 4). 4380 o A user's server MUST NOT leak the user's network availability to 4381 entities who are not authorized to know the user's presence. In 4382 XMPP itself, authorization takes the form of an explicit 4383 subscription from a contact to the user (as described under 4384 Section 3). However, some XMPP deployments might consider an 4385 entity to be authorized if there is an existing trust relationship 4386 between the entity and the user who is generating presence 4387 information (as an example, a corporate deployment of XMPP might 4388 automatically add the user's presence information to a private 4389 directory of employees if the organization mandates the sharing of 4390 presence information as part of an employment agreement). 4392 o When a server processes an outbound presence stanza with no type 4393 or of type "unavailable", it MUST follow the rules defined under 4394 Section 4 in order to ensure that such presence information is not 4395 sent to entities that are not authorized to know such information. 4397 o A client MAY ignore the element when contained in a 4398 presence stanza of type "subscribe", "unsubscribe", "subscribed", 4399 or "unsubscribed"; this can help prevent "presence subscription 4400 spam". 4402 12. IANA Considerations 4404 This specification requests no actions from the IANA. 4406 13. Conformance Requirements 4408 This section describes a protocol feature set that summarizes the 4409 conformance requirements of this specification. This feature set is 4410 appropriate for use in software certification, interoperability 4411 testing, and implementation reports. For each feature, this section 4412 provides the following information: 4414 o A human-readable name 4416 o An informational description 4418 o A reference to the particular section of this document that 4419 normatively defines the feature 4421 o Whether the feature applies to the Client role, the Server role, 4422 or both (where "N/A" signifies that the feature is not applicable 4423 to the specified role) 4425 o Whether the feature MUST or SHOULD be implemented, where the 4426 capitalized terms are to be understood as described in [KEYWORDS] 4428 The feature set specified here attempts to adhere to the concepts and 4429 formats proposed by Larry Masinter within the IETF's NEWTRK Working 4430 Group in 2005, as captured in [INTEROP]. Although this feature set 4431 is more detailed than called for by [REPORTS], it provides a suitable 4432 basis for the generation of implementation reports to be submitted in 4433 support of advancing this specification from Proposed Standard to 4434 Draft Standard in accordance with [PROCESS]. 4436 Feature: message-body 4437 Description: Support the child element of the 4438 stanza. 4439 Section: Section 5.2.3 4440 Roles: Client MUST, Server N/A. 4442 Feature: message-subject 4443 Description: Support the child element of the 4444 stanza. 4445 Section: Section 5.2.4 4446 Roles: Client SHOULD, Server N/A. 4448 Feature: message-thread 4449 Description: Support the child element of the 4450 stanza. 4452 Section: Section 5.2.5 4453 Roles: Client SHOULD, Server N/A. 4455 Feature: message-type-support 4456 Description: Support reception of messages of type "normal", "chat", 4457 "groupchat", "headline", and "error". 4458 Section: Section 5.2.2 4459 Roles: Client SHOULD, Server N/A. 4461 Feature: message-type-deliver 4462 Description: Appropriately deliver messages of type "normal", 4463 "chat", "groupchat", "headline", and "error". 4464 Section: Section 8 4465 Roles: Client N/A, Server SHOULD. 4467 Feature: presence-notype 4468 Description: Treat a presence stanza with no 'type' attribute as 4469 indicating availability. 4470 Section: Section 4.7.1 4471 Roles: Client MUST, Server MUST. 4473 Feature: presence-probe 4474 Description: Send and receive presence stanzas with a 'type' 4475 attribute of "probe" for the discovery of presence information. 4476 Section: Section 4.7.1 4477 Roles: Client N/A, Server MUST. 4479 Feature: presence-sub-approval 4480 Description: Treat an outbound presence stanza of type "subscribed" 4481 as the act of approving a presence subscription request previously 4482 received from another entity, and treat an inbound presence stanza 4483 of type "subscribed" as a subscription approval from another 4484 entity. 4485 Section: Section 3.1 4486 Roles: Client MUST, Server MUST. 4488 Feature: presence-sub-cancel 4489 Description: Treat an outbound presence stanza of type 4490 "unsubscribed" as the act of denying a subscription request 4491 received from another entity or cancelling a subscription approval 4492 previously granted to another entity, and treat an inbound 4493 presence stanza of type "unsubscribed" as an subscription denial 4494 or cancellation from another entity. 4495 Section: Section 3.2 4496 Roles: Client MUST, Server MUST. 4498 Feature: presence-sub-preapproval 4499 Description: Treat an outbound presence stanza of type "subscribed" 4500 in certain circumstances as the act of pre-approving a 4501 subscription request received from another entity; this includes 4502 support for the 'approved' attribute of the element within 4503 the 'jabber:iq:roster' namespace. 4504 Section: Section 3.4 4505 Roles: Client MAY, Server MAY. 4507 Feature: presence-sub-request 4508 Description: Treat an outbound presence stanza of type "subscribe" 4509 as the act of requesting a subscription to the presence 4510 information of another entity, and treat an inbound presence 4511 stanza of type "subscribe" as a presence subscription request from 4512 another entity. 4513 Section: Section 3.1 4514 Roles: Client MUST, Server MUST. 4516 Feature: presence-sub-unsubscribe 4517 Description: Treat an outbound presence stanza of type "unsubscribe" 4518 as the act of unsubscribing from another entity, and treat an 4519 inbound presence stanza of type "unsubscribe" as an unsubscribe 4520 notification from another entity. 4521 Section: Section 3.3 4522 Roles: Client MUST, Server MUST. 4524 Feature: presence-unavailable 4525 Description: Treat a presence stanza with a 'type' attribute of 4526 "unavailable" as indicating lack of availability. 4527 Section: Section 4.7.1 4528 Roles: Client MUST, Server MUST. 4530 Feature: roster-get 4531 Description: Treat an IQ stanza of type "get" containing an empty 4532 element qualified by the 'jabber:iq:roster' namespace as 4533 a request to retrieve the roster information associated with an 4534 account on a server. 4535 Section: Section 2.1.3 4536 Roles: Client MUST, Server MUST. 4538 Feature: roster-set 4539 Description: Treat an IQ stanza of type "set" containing a 4540 element qualified by the 'jabber:iq:roster' namespace as a request 4541 to add or update the item contained in the element. 4543 Section: Section 2.1.5 4544 Roles: Client MUST, Server MUST. 4546 Feature: roster-push 4547 Description: Send a roster push to each interested resource whenever 4548 the server-side representation of the roster information 4549 materially changes, or handle such a push when received from the 4550 server. 4551 Section: Section 2.1.6 4552 Roles: Client MUST, Server MUST. 4554 Feature: roster-version 4555 Description: Treat the 'ver' attribute of the element 4556 qualified by the 'jabber:iq:roster' namespace as an identifier of 4557 the particular version of roster information being sent or 4558 received. 4559 Section: Section 2.1.1 4560 Roles: Client SHOULD, Server MUST. 4562 14. References 4564 14.1. Normative References 4566 [DELAY] Saint-Andre, P., "Delayed Delivery", XSF XEP 0203, 4567 September 2009. 4569 [KEYWORDS] 4570 Bradner, S., "Key words for use in RFCs to Indicate 4571 Requirement Levels", BCP 14, RFC 2119, March 1997. 4573 [XML] Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., 4574 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fifth 4575 Edition)", World Wide Web Consortium Recommendation REC- 4576 xml-20081126, November 2008, 4577 . 4579 [XML-NAMES] 4580 Bray, T., Hollander, D., and A. Layman, "Namespaces in 4581 XML", W3C REC-xml-names, January 1999, 4582 . 4584 [XMPP-CORE] 4585 Saint-Andre, P., "Extensible Messaging and Presence 4586 Protocol (XMPP): Core", draft-ietf-xmpp-3920bis-22 (work 4587 in progress), December 2010. 4589 14.2. Informative References 4591 [CPIM] Peterson, J., "Common Profile for Instant Messaging 4592 (CPIM)", RFC 3860, August 2004. 4594 [CPP] Peterson, J., "Common Profile for Presence (CPP)", 4595 RFC 3859, August 2004. 4597 [DOS] Handley, M., Rescorla, E., and IAB, "Internet Denial-of- 4598 Service Considerations", RFC 4732, December 2006. 4600 [IMP-MODEL] 4601 Day, M., Rosenberg, J., and H. Sugano, "A Model for 4602 Presence and Instant Messaging", RFC 2778, February 2000. 4604 [IMP-REQS] 4605 Day, M., Aggarwal, S., and J. Vincent, "Instant Messaging 4606 / Presence Protocol Requirements", RFC 2779, 4607 February 2000. 4609 [IMP-SRV] Peterson, J., "Address Resolution for Instant Messaging 4610 and Presence", RFC 3861, August 2004. 4612 [INTEROP] Masinter, L., "Formalizing IETF Interoperability 4613 Reporting", draft-ietf-newtrk-interop-reports-00 (work in 4614 progress), October 2005. 4616 [IRC] Kalt, C., "Internet Relay Chat: Architecture", RFC 2810, 4617 April 2000. 4619 [IRI] Duerst, M. and M. Suignard, "Internationalized Resource 4620 Identifiers (IRIs)", RFC 3987, January 2005. 4622 [PROCESS] Bradner, S., "The Internet Standards Process -- Revision 4623 3", BCP 9, RFC 2026, October 1996. 4625 [REPORTS] Dusseault, L. and R. Sparks, "Guidance on Interoperation 4626 and Implementation Reports for Advancement to Draft 4627 Standard", BCP 9, RFC 5657, September 2009. 4629 [RFC3920] Saint-Andre, P., Ed., "Extensible Messaging and Presence 4630 Protocol (XMPP): Core", RFC 3920, October 2004. 4632 [RFC3921] Saint-Andre, P., Ed., "Extensible Messaging and Presence 4633 Protocol (XMPP): Instant Messaging and Presence", 4634 RFC 3921, October 2004. 4636 [SASL] Melnikov, A. and K. Zeilenga, "Simple Authentication and 4637 Security Layer (SASL)", RFC 4422, June 2006. 4639 [SIP-PRES] 4640 Rosenberg, J., "A Presence Event Package for the Session 4641 Initiation Protocol (SIP)", RFC 3856, August 2004. 4643 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 4644 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 4646 [TLS-CERTS] 4647 Saint-Andre, P. and J. Hodges, "Representation and 4648 Verification of Domain-Based Application Service Identity 4649 within Internet Public Key Infrastructure Using X.509 4650 (PKIX) Certificates in the Context of Transport Layer 4651 Security (TLS)", draft-saintandre-tls-server-id-check-14 4652 (work in progress), January 2011. 4654 [UNICODE] The Unicode Consortium, "The Unicode Standard, Version 4655 6.0", 2010, 4656 . 4658 [URI] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 4659 Resource Identifier (URI): Generic Syntax", STD 66, 4660 RFC 3986, January 2005. 4662 [UUID] Leach, P., Mealling, M., and R. Salz, "A Universally 4663 Unique IDentifier (UUID) URN Namespace", RFC 4122, 4664 July 2005. 4666 [XEP-0016] 4667 Millard, P. and P. Saint-Andre, "Privacy Lists", XSF 4668 XEP 0016, February 2007. 4670 [XEP-0045] 4671 Saint-Andre, P., "Multi-User Chat", XSF XEP 0045, 4672 July 2008. 4674 [XEP-0054] 4675 Saint-Andre, P., "vcard-temp", XSF XEP 0054, July 2008. 4677 [XEP-0071] 4678 Saint-Andre, P., "XHTML-IM", XSF XEP 0071, September 2008. 4680 [XEP-0115] 4681 Hildebrand, J., Saint-Andre, P., and R. Troncon, "Entity 4682 Capabilities", XSF XEP 0115, February 2008. 4684 [XEP-0147] 4685 Saint-Andre, P., "XMPP URI Scheme Query Components", XSF 4686 XEP 0147, September 2006. 4688 [XEP-0160] 4689 Saint-Andre, P., "Best Practices for Handling Offline 4690 Messages", XSF XEP 0160, January 2006. 4692 [XEP-0163] 4693 Saint-Andre, P. and K. Smith, "Personal Eventing 4694 Protocol", XSF XEP 0163, July 2010. 4696 [XEP-0191] 4697 Saint-Andre, P., "Simple Communications Blocking", XSF 4698 XEP 0191, February 2007. 4700 [XEP-0201] 4701 Saint-Andre, P., Paterson, I., and K. Smith, "Best 4702 Practices for Message Threads", XSF XEP 0201, May 2010. 4704 [XEP-0237] 4705 Saint-Andre, P. and D. Cridland, "Roster Versioning", XSF 4706 XEP 0237, March 2010. 4708 [XML-DATATYPES] 4709 Biron, P. and A. Malhotra, "XML Schema Part 2: Datatypes 4710 Second Edition", W3C REC-xmlschema-2, October 2004, 4711 . 4713 [XML-SCHEMA] 4714 Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, 4715 "XML Schema Part 1: Structures Second Edition", World Wide 4716 Web Consortium Recommendation REC-xmlschema-1-20041028, 4717 October 2004, 4718 . 4720 [XMPP-ADDR] 4721 Saint-Andre, P., "Extensible Messaging and Presence 4722 Protocol (XMPP): Address Format", 4723 draft-ietf-xmpp-address-09 (work in progress), 4724 January 2011. 4726 [XMPP-URI] 4727 Saint-Andre, P., "Internationalized Resource Identifiers 4728 (IRIs) and Uniform Resource Identifiers (URIs) for the 4729 Extensible Messaging and Presence Protocol (XMPP)", 4730 RFC 5122, February 2008. 4732 [VCARD] Dawson, F. and T. Howes, "vCard MIME Directory Profile", 4733 RFC 2426, September 1998. 4735 Appendix A. Subscription States 4737 This section provides detailed information about subscription states 4738 and server processing of subscription-related presence stanzas (i.e., 4739 presence stanzas of type "subscribe", "subscribed", "unsubscribe", 4740 and "unsubscribed"). 4742 A.1. Defined States 4744 There are four primary subscription states (these states are 4745 described from the perspective of the user, not the contact): 4747 None: The user does not have a subscription to the contact's 4748 presence, and the contact does not have a subscription to the 4749 user's presence. 4751 To: The user has a subscription to the contact's presence, but the 4752 contact does not have a subscription to the user's presence. 4754 From: The contact has a subscription to the user's presence, but the 4755 user does not have a subscription to the contact's presence. 4757 Both: Both the user and the contact have subscriptions to each 4758 other's presence (i.e., the union of 'from' and 'to'). 4760 Implementation Note: For the purpose of processing subscription- 4761 related presence stanzas as described in the following sections, a 4762 subscription state of "None" includes the case of the contact not 4763 being in the user's roster at all, i.e., an unknown entity from 4764 the perspective of the user's roster. 4766 The foregoing states are supplemented by various sub-states related 4767 to pending inbound and outbound subscriptions, thus yielding nine 4768 possible subscription states: 4770 1. "None" = Contact and user are not subscribed to each other, and 4771 neither has requested a subscription from the other; this is 4772 reflected in the user's roster by subscription='none'. 4774 2. "None + Pending Out" = Contact and user are not subscribed to 4775 each other, and user has sent contact a subscription request but 4776 contact has not replied yet; this is reflected in the user's 4777 roster by subscription='none' and ask='subscribe'. 4779 3. "None + Pending In" = Contact and user are not subscribed to each 4780 other, and contact has sent user a subscription request but user 4781 has not replied yet; this state might or might not be reflected 4782 in the user's roster, as follows: if the user has created a 4783 roster item for the contact then the server MUST maintain that 4784 roster item and also note the existence of the inbound presence 4785 subscription request, whereas if the user has not created a 4786 roster item for the contact then the user's server MUST note the 4787 existence of the inbound presence subscription request but MUST 4788 NOT create a roster item for the contact (instead, the server 4789 MUST wait until the user has approved the subscription request 4790 before adding the contact to the user's roster). 4792 4. "None + Pending Out+In" = Contact and user are not subscribed to 4793 each other, contact has sent user a subscription request but user 4794 has not replied yet, and user has sent contact a subscription 4795 request but contact has not replied yet; this is reflected in the 4796 user's roster by subscription='none' and ask='subscribe'. 4798 5. "To" = User is subscribed to contact (one-way); this is reflected 4799 in the user's roster by subscription='to'. 4801 6. "To + Pending In" = User is subscribed to contact, and contact 4802 has sent user a subscription request but user has not replied 4803 yet; this is reflected in the user's roster by subscription='to'. 4805 7. "From" = Contact is subscribed to user (one-way); this is 4806 reflected in the user's roster by subscription='from'. 4808 8. "From + Pending Out" = Contact is subscribed to user, and user 4809 has sent contact a subscription request but contact has not 4810 replied yet; this is reflected in the user's roster by 4811 subscription='from' and ask='subscribe'. 4813 9. "Both" = User and contact are subscribed to each other (two-way); 4814 this is reflected in the user's roster by subscription='both'. 4816 A.2. Server Processing of Outbound Presence Subscription Stanzas 4818 Outbound presence subscription stanzas enable the user to manage his 4819 or her subscription to the contact's presence (via the "subscribe" 4820 and "unsubscribe" types), and to manage the contact's access to the 4821 user's presence (via the "subscribed" and "unsubscribed" types). 4823 The following rules apply to outbound routing of the stanza as well 4824 as changes to the user's roster. (These rules are described from the 4825 perspective of the user, not the contact. In addition, "S.N." stands 4826 for SHOULD NOT and "M.N." stands for MUST NOT.) 4828 A.2.1. Subscribe 4830 Table 2: Processing of outbound "subscribe" stanzas 4832 +------------------------------------------------------------------+ 4833 | EXISTING STATE | ROUTE? | NEW STATE | 4834 +------------------------------------------------------------------+ 4835 | "None" | MUST [1] | "None + Pending Out" | 4836 | "None + Pending Out" | MUST | no state change | 4837 | "None + Pending In" | MUST [1] | "None + Pending Out+In" | 4838 | "None + Pending Out+In" | MUST | no state change | 4839 | "To" | MUST | no state change | 4840 | "To + Pending In" | MUST | no state change | 4841 | "From" | MUST [1] | "From + Pending Out" | 4842 | "From + Pending Out" | MUST | no state change | 4843 | "Both" | MUST | no state change | 4844 +------------------------------------------------------------------+ 4846 [1] A state change to "pending out" includes setting the 'ask' 4847 flag to a value of "subscribe" in the user's roster. 4849 A.2.2. Unsubscribe 4851 Table 3: Processing of outbound "unsubscribe" stanzas 4853 +-----------------------------------------------------------------+ 4854 | EXISTING STATE | ROUTE? | NEW STATE | 4855 +-----------------------------------------------------------------+ 4856 | "None" | MUST | no state change | 4857 | "None + Pending Out" | MUST | "None" | 4858 | "None + Pending In" | MUST | no state change | 4859 | "None + Pending Out+In" | MUST | "None + Pending In" | 4860 | "To" | MUST | "None" | 4861 | "To + Pending In" | MUST | "None + Pending In" | 4862 | "From" | MUST | no state change | 4863 | "From + Pending Out" | MUST | "From" | 4864 | "Both" | MUST | "From" | 4865 +-----------------------------------------------------------------+ 4867 A.2.3. Subscribed 4869 Table 4: Processing of outbound "subscribed" stanzas 4871 +-----------------------------------------------------------------+ 4872 | EXISTING STATE | ROUTE? | NEW STATE | 4873 +-----------------------------------------------------------------+ 4874 | "None" | M.N. | pre-approval [1] | 4875 | "None + Pending Out" | M.N. | pre-approval [1] | 4876 | "None + Pending In" | MUST | "From" | 4877 | "None + Pending Out+In" | MUST | "From + Pending Out" | 4878 | "To" | M.N. | pre-approval [1] | 4879 | "To + Pending In" | MUST | "Both" | 4880 | "From" | M.N. | no state change | 4881 | "From + Pending Out" | M.N. | no state change | 4882 | "Both" | M.N. | no state change | 4883 +-----------------------------------------------------------------+ 4885 [1] Detailed information regarding subscription pre-approval is 4886 provided under Section 3.4. 4888 A.2.4. Unsubscribed 4890 Table 5: Processing of outbound "unsubscribed" stanzas 4892 +-----------------------------------------------------------------+ 4893 | EXISTING STATE | ROUTE? | NEW STATE | 4894 +-----------------------------------------------------------------+ 4895 | "None" | S.N. | no state change [1] | 4896 | "None + Pending Out" | S.N. | no state change [1] | 4897 | "None + Pending In" | MUST | "None" | 4898 | "None + Pending Out+In" | MUST | "None + Pending Out" | 4899 | "To" | S.N. | no state change [1] | 4900 | "To + Pending In" | MUST | "To" | 4901 | "From" | MUST | "None" | 4902 | "From + Pending Out" | MUST | "None + Pending Out" | 4903 | "Both" | MUST | "To" | 4904 +-----------------------------------------------------------------+ 4906 [1] This event can result in cancellation of a subscription pre- 4907 approval, as described under Section 3.4. 4909 A.3. Server Processing of Inbound Presence Subscription Stanzas 4911 Inbound presence subscription stanzas request a subscription-related 4912 action from the user (via the "subscribe" type), inform the user of 4913 subscription-related actions taken by the contact (via the 4914 "unsubscribe" type), or enable the user to manage the contact's 4915 access to the user's presence information (via the "subscribed" and 4916 "unsubscribed" types). 4918 The following rules apply to delivery of the inbound stanza as well 4919 as changes to the user's roster. (These rules for server processing 4920 of inbound presence subscription stanzas are described from the 4921 perspective of the user, not the contact. In addition, "S.N." stands 4922 for SHOULD NOT.) 4924 A.3.1. Subscribe 4926 Table 6: Processing of inbound "subscribe" stanzas 4928 +------------------------------------------------------------------+ 4929 | EXISTING STATE | DELIVER? | NEW STATE | 4930 +------------------------------------------------------------------+ 4931 | "None" | MUST [1] | "None + Pending In" | 4932 | "None + Pending Out" | MUST | "None + Pending Out+In" | 4933 | "None + Pending In" | S.N. | no state change | 4934 | "None + Pending Out+In" | S.N. | no state change | 4935 | "To" | MUST | "To + Pending In" | 4936 | "To + Pending In" | S.N. | no state change | 4937 | "From" | S.N. [2] | no state change | 4938 | "From + Pending Out" | S.N. [2] | no state change | 4939 | "Both" | S.N. [2] | no state change | 4940 +------------------------------------------------------------------+ 4942 [1] If the user previously sent presence of type "subscribed" as 4943 described under Appendix A.2.3 and Section 3.4, then the server 4944 MAY auto-reply with "subscribed" and change the state to "From" 4945 rather than "None + Pending In". 4947 [2] Server SHOULD auto-reply with "subscribed". 4949 A.3.2. Unsubscribe 4951 When the user's server receives a presence stanza of type 4952 "unsubscribe" for the user from the contact, if the stanza results in 4953 a subscription state change from the user's perspective then the 4954 user's server MUST change the state, MUST deliver the presence stanza 4955 from the contact to the user, and SHOULD auto-reply by sending a 4956 presence stanza of type "unsubscribed" to the contact on behalf of 4957 the user. Otherwise the user's server MUST NOT change the state and 4958 (because there is no state change) SHOULD NOT deliver the stanza. 4959 These rules are summarized in the following table. 4961 Table 7: Processing of inbound "unsubscribe" stanzas 4963 +------------------------------------------------------------------+ 4964 | EXISTING STATE | DELIVER? | NEW STATE | 4965 +------------------------------------------------------------------+ 4966 | "None" | S.N. | no state change | 4967 | "None + Pending Out" | S.N. | no state change | 4968 | "None + Pending In" | MUST [1] | "None" | 4969 | "None + Pending Out+In" | MUST [1] | "None + Pending Out" | 4970 | "To" | S.N. | no state change | 4971 | "To + Pending In" | MUST [1] | "To" | 4972 | "From" | MUST [1] | "None" | 4973 | "From + Pending Out" | MUST [1] | "None + Pending Out | 4974 | "Both" | MUST [1] | "To" | 4975 +------------------------------------------------------------------+ 4977 [1] Server SHOULD auto-reply with "unsubscribed". 4979 A.3.3. Subscribed 4981 When the user's server receives a presence stanza of type 4982 "subscribed" for the user from the contact, if there is no pending 4983 outbound request for access to the contact's presence information, 4984 then it MUST NOT change the subscription state and (because there is 4985 no state change) SHOULD NOT deliver the stanza to the user. If there 4986 is a pending outbound request for access to the contact's presence 4987 information and the inbound presence stanza of type "subscribed" 4988 results in a subscription state change, then the user's server MUST 4989 change the subscription state and MUST deliver the stanza to the 4990 user. If the user already is subscribed to the contact's presence 4991 information, the inbound presence stanza of type "subscribed" does 4992 not result in a subscription state change; therefore the user's 4993 server MUST NOT change the subscription state and (because there is 4994 no state change) SHOULD NOT deliver the stanza to the user. These 4995 rules are summarized in the following table. 4997 Table 8: Processing of inbound "subscribed" stanzas 4999 +------------------------------------------------------------------+ 5000 | EXISTING STATE | DELIVER? | NEW STATE | 5001 +------------------------------------------------------------------+ 5002 | "None" | S.N. | no state change | 5003 | "None + Pending Out" | MUST | "To" | 5004 | "None + Pending In" | S.N. | no state change | 5005 | "None + Pending Out+In" | MUST | "To + Pending In" | 5006 | "To" | S.N. | no state change | 5007 | "To + Pending In" | S.N. | no state change | 5008 | "From" | S.N. | no state change | 5009 | "From + Pending Out" | MUST | "Both" | 5010 | "Both" | S.N. | no state change | 5011 +------------------------------------------------------------------+ 5013 A.3.4. Unsubscribed 5015 When the user's server receives a presence stanza of type 5016 "unsubscribed" for the user from the contact, if there is a pending 5017 outbound request for access to the contact's presence information or 5018 if the user currently is subscribed to the contact's presence 5019 information, then the user's server MUST change the subscription 5020 state and MUST deliver the stanza to the user. Otherwise, the user's 5021 server MUST NOT change the subscription state and (because there is 5022 no state change) SHOULD NOT deliver the stanza. These rules are 5023 summarized in the following table. 5025 Table 9: Processing of inbound "unsubscribed" stanzas 5027 +------------------------------------------------------------------+ 5028 | EXISTING STATE | DELIVER? | NEW STATE | 5029 +------------------------------------------------------------------+ 5030 | "None" | S.N. | no state change | 5031 | "None + Pending Out" | MUST | "None" | 5032 | "None + Pending In" | S.N. | no state change | 5033 | "None + Pending Out+In" | MUST | "None + Pending In" | 5034 | "To" | MUST | "None" | 5035 | "To + Pending In" | MUST | "None + Pending In" | 5036 | "From" | S.N. | no state change | 5037 | "From + Pending Out" | MUST | "From" | 5038 | "Both" | MUST | "From" | 5039 +------------------------------------------------------------------+ 5041 Appendix B. Blocking Communication 5043 Sections 2.3.5 and 5.4.10 of [IMP-REQS] require that a compliant 5044 instant messaging and presence technology needs to enable a user to 5045 block communications from selected users. Protocols for doing so are 5046 specified in [XEP-0016] and [XEP-0191]. 5048 Appendix C. vCards 5050 Sections 3.1.3 and 4.1.4 of [IMP-REQS] require that it be possible to 5051 retrieve out-of-band contact information for other users (e.g., 5052 telephone number or email address). An XML representation of the 5053 vCard specification defined in RFC 2426 [VCARD] is in common use 5054 within the XMPP community to provide such information but is out of 5055 scope for this specification (documentation of this protocol is 5056 contained in [XEP-0054]). 5058 Appendix D. XML Schema for jabber:iq:roster 5060 The following schema formally defines the 'jabber:iq:roster' 5061 namespace used in this document, in conformance with [XML-SCHEMA]. 5062 Because validation of XML streams and stanzas is optional, this 5063 schema is not normative and is provided for descriptive purposes 5064 only. For schemas defining core XMPP namespaces, refer to 5065 [XMPP-CORE]. 5067 5069 5075 5076 5077 5078 5081 5082 5085 5086 5087 5088 5089 5090 5093 5094 5097 5099 5100 5101 5102 5103 5104 5105 5108 5111 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5127 5129 5131 Appendix E. Differences From RFC 3921 5133 Based on consensus derived from implementation and deployment 5134 experience as well as formal interoperability testing, the following 5135 substantive modifications were made from [RFC3921] (in addition to 5136 numerous changes of an editorial nature). 5138 o The protocol for session establishment was determined to be 5139 unnecessary and therefore the content previously defined in 5140 Section 3 of RFC 3921 was removed. However, for the sake of 5141 backward-compatibility server implementations are encouraged to 5142 advertise support for the feature, even though session 5143 establishment is a "no-op". 5144 o In order to more seamlessly repair lack of synchronization in 5145 subscription states between rosters located at different servers, 5146 clarified and modified error handling related to presence 5147 subscription requests, presence probes and presence notifications. 5148 o Changed the 'from' address for presence probes so that it is the 5149 bare JID, not the full JID. 5150 o Adjusted and clarified stanza delivery rules based on 5151 implementation and deployment experience. 5152 o Explicitly specified that a server is allowed to deliver a message 5153 stanza of type "normal" or "chat" to all resources if it has a 5154 method for allowing resources to opt in to such behavior. 5155 o Allowed a server to use its own algorithm for determining the 5156 "most available" resource for the purpose of message delivery, but 5157 mentioned the recommended algorithm from RFC 3921 (based on 5158 presence priority) as one possible algorithm. 5159 o Added optional versioning of roster information to save bandwidth 5160 in cases where the roster has not changed (or has changed very 5161 little) between sessions; the relevant protocol interactions were 5162 originally described in [XEP-0237]. 5163 o Added optional server support for pre-approved presence 5164 subscriptions via presence stanzas of type "subscribed", including 5165 a new 'approved' attribute that can be set to "true" (for a pre- 5166 approved subscription) or false (the default). 5167 o Added optional 'parent' attribute to element 5168 o Moved the protocol for communications blocking (specified in 5169 Section 10 of RFC 3921) back to [XEP-0016], from which it was 5170 originally taken. 5171 o Recommended returning presence unavailable in response to probes. 5172 o Clarified handling of presence probes sent to full JIDs. 5173 o Explicitly specified that the default value for the presence 5174 element is zero. 5175 o Removed recommendation to support the "_im" and "_pres" SRV 5176 records. 5178 Appendix F. Acknowledgements 5180 This document is an update to, and derived from, RFC 3921. This 5181 document would have been impossible without the work of the 5182 contributors and commenters acknowledged there. 5184 Hundreds of people have provided implementation feedback, bug 5185 reports, requests for clarification, and suggestions for improvement 5186 since publication of RFC 3921. Although the document editor has 5187 endeavored to address all such feedback, he is solely responsible for 5188 any remaining errors and ambiguities. 5190 Some of the text about roster versioning was borrowed from [XEP-0237] 5191 and some of the text about message threads was borrowed from 5192 [XEP-0201]. 5194 Special thanks are due to Kevin Smith, Matthew Wild, Dave Cridland, 5195 Waqas Hussain, Philipp Hancke, Florian Zeitz, Jonas Lindberg, Jehan 5196 Pages, Tory Patnoe, and others for their comments during Working 5197 Group Last Call. 5199 Thanks also to Richard Barnes for his review on behalf of the 5200 Security Directorate. 5202 The Working Group chairs were Ben Campbell and Joe Hildebrand. The 5203 responsible Area Director was Gonzalo Camarillo. 5205 Author's Address 5207 Peter Saint-Andre 5208 Cisco 5209 1899 Wyknoop Street, Suite 600 5210 Denver, CO 80202 5211 USA 5213 Phone: +1-303-308-3282 5214 Email: psaintan@cisco.com